Warning: main(/www/www/htdocs/style/globals.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/r/rsrcdbmgr_create.html on line 1
Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/globals.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/r/rsrcdbmgr_create.html on line 1
Warning: main(/www/www/htdocs/style/header.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/r/rsrcdbmgr_create.html on line 8
Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/header.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/r/rsrcdbmgr_create.html on line 8
Create a system resource
#include <sys/rsrcdbmgr.h>
#include <sys/rsrcdbmsg.h>
int rsrcdbmgr_create( rsrc_alloc_t *item,
int count );
- 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.
libc
Use the -l c option to
qcc
to link against this library.
This library is usually included automatically.
The rsrcdbmgr_create() function creates one or more system resources.
If the function completes successfully, count
resources are returned in item.
The structure of a basic resource request looks like this:
typedef struct _rsrc_alloc {
_Uint64t start;
_Uint64t end;
_Uint32t flags;
const char *name;
} 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_NAME — the name field
is valid, and is a system name.
- 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.
- name
- NULL, or a pointer to the name of the resource class.
This field is used only if you set RSRCDBMGR_FLAG_NAME
in the flags field.
For more information, see
rsrcdbmgr_attach().
You must set all the members.
EOK, or -1 if an error occurred
(errno is set).
- EAGAIN
- The resource request can't be created.
- EINVAL
- Invalid argument.
- ENOMEM
- Insufficient memory to allocate internal data structures.
/*
* 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);
}
QNX Neutrino
Safety: | |
Cancellation point |
Yes |
Interrupt handler |
No |
Signal handler |
Yes |
Thread |
Yes |
rsrcdbmgr_attach(),
rsrcdbmgr_destroy()
Warning: main(/www/www/htdocs/style/footer.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/r/rsrcdbmgr_create.html on line 274
Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/footer.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/r/rsrcdbmgr_create.html on line 274