QNX Developer Support
![]() |
![]() |
![]() |
![]() |
rsrcdbmgr_create()
Create a system resource
Synopsis:
#include <sys/rsrcdbmgr.h>
#include <sys/rsrcdbmsg.h>
int rsrcdbmgr_create( rsrc_alloc_t *item,
int count );
Arguments:
- item
- An array of rsrc_alloc_t structures that describe the resources that you want to create; see below.
- count
- The number of entries in the array.
Library:
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
Description:
The rsrcdbmgr_create() function creates one or more system resources. If the function completes successfully, count resources are returned in item.
rsrc_alloc_t structure
The structure of a basic resource request looks like this:
typedef struct _rsrc_alloc {
uint64_t start; /* Start of resource range */
uint64_t end; /* End of resource range */
uint32_t flags; /* Resource type | Resource flags */
} rsrc_alloc_t;
The members include:
- start, end
- The resource range.
- flags
- The type of the resource, as well as flags that affect the request.
You must set this member to be one of the following resource types
(defined in <sys/rsrcdbmgr.h>):
- RSRCDBMGR_DMA_CHANNEL -- DMA channel
- RSRCDBMGR_IO_PORT -- I/O port address
- RSRCDBMGR_IRQ or RSRCMGR_IRQ -- interrupt address
- RSRCDBMGR_MEMORY -- Memory address
- RSRCDBMGR_PCI_MEMORY -- PCI memory address
You can OR in the following bits (also defined in <sys/rsrcdbmgr.h>):
- RSRCDBMGR_FLAG_NOREMOVE -- don't remove this resource when the process dies.
- RSRCDBMGR_FLAG_RSVP -- create and reserve a resource with a higher priority than other resources. The resource is given out only when there are no other valid ranges available.
You must set all the members.
Returns:
EOK, or -1 if an error occurred (errno is set).
Errors:
- EAGAIN
- The resource request can't be created.
- EINVAL
- Invalid argument.
- ENOMEM
- Insufficient memory to allocate internal data structures.
Examples:
/*
* Create two resources:
* 0-4K memory allocation and 5 DMA channels.
*/
#include <stdio.h>
#include <sys/rsrcdbmgr.h>
#include <sys/rsrcdbmsg.h>
int main(int argc, char **argv) {
rsrc_alloc_t alloc[2];
memset(alloc, 0, 2* sizeof(*alloc));
alloc[0].start = 0;
alloc[0].end = 4*1024;
alloc[0].flags = RSRCDBMGR_MEMORY;
alloc[1].start = 1;
alloc[1].end = 5;
alloc[1].flags = RSRCDBMGR_DMA_CHANNEL;
/* Allocate resources to the system. */
if (rsrcdbmgr_create( alloc, 2 ) == -1) {
perror("Problem creating resources \n");
exit(1);
}
...
/* Do something with the created resource */
...
/* Remove the allocated resources. */
rsrcdbmgr_destroy ( alloc, 2 );
return(0);
}
Classification:
| Safety: | |
|---|---|
| Cancellation point | Yes |
| Interrupt handler | No |
| Signal handler | Yes |
| Thread | Yes |
See also:
rsrcdbmgr_attach(), rsrcdbmgr_destroy()
![]() |
![]() |
![]() |
![]() |

![[Previous]](../prev.gif)
![[Contents]](../contents.gif)
![[Index]](../keyword_index.gif)
![[Next]](../next.gif)
