Create a system resource
#include <sys/rsrcdbmgr.h>
#include <sys/rsrcdbmsg.h>
int rsrcdbmgr_create( rsrc_alloc_t *item,
                      int count );
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
The rsrcdbmgr_create() function creates the system resources specified in the item array.
rsrc_alloc_t structure
The structure of a basic resource request looks like this:
typedef struct _rsrc_alloc {
	uint64_t	start;
	uint64_t	end;
	uint32_t	flags;
	const char	*name;
} rsrc_alloc_t;
The members include:
You can OR in the following bits (also defined in <sys/rsrcdbmgr.h>):
You must set all the members.
0 on success, or -1 if an error occurred (errno is set).
/*
 * 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);
}
| Safety: | |
|---|---|
| Cancellation point | Yes | 
| Interrupt handler | No | 
| Signal handler | Yes | 
| Thread | Yes |