[Previous] [Contents] [Next]

rsrcdbmgr_query()

Query the resource database

Synopsis:

#include <sys/rsrcdbmgr.h>
#include <sys/rsrcdbmsg.h>

int rsrcdbmgr_query( rsrc_alloc_t *list,
                     int listcnt,
                     int start,
                     uint32_t type );

Library:

libc

Description:

The rsrcdbmgr_query() function queries the database for listcnt count of type resources in use, beginning at the index start. If the query is made with a non-NULL list, then the function stores a maximum of found listcnt resources in a list of rsrc_alloc_t structures:

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 function stores the type resources until the list is full.

Resource types

The possible resource types (defined in <sys/rsrcdbmgr.h>) are:

RSRCDBMGR_DMA_CHANNEL
DMA channel
RSRCDBMGR_IO_PORT
I/O port address
RSRCDBMGR_IRQ
Interrupt address
RSRCDBMGR_MEMORY
Memory address
RSRCDBMGR_PCI_MEMORY
PCI memory address

Returns:

If list is NULL or listcnt is 0, then the function returns the number of resources of type in the database.

If list is non-NULL, then the function returns the number of type resources available in the system.

If an error occurs, the function returns -1 and sets errno.

Errors:

EINVAL
Invalid argument
ENOMEM
Insufficient memory to allocate internal data structures.

Examples:

This example lists all of the memory resource blocks available in the system:

rsrc_alloc_t  list[20];
int           size, count = 0, start = 0;

while (1) {
   count = rsrcdbmgr_query( &list, 20, start, RSRCDBMGR_MEMORY );
   if (count == -1) 
   break;

   size = min( count-start, 20 );  /* In case more than 20 blocks
                                      were returned. */
   printf( "Retrieved %d of a possible %d resource blocks", \
            size, count);

   for (count=0; count<size; count++) {
       printf( "RSRC[%d] Start %d End %d \n",  \
                start+count, list[count].start, list[count].end);
   }
   start += size;  /* Loop again, in case there are more than
                      20 blocks. */
}

Classification:

QNX 6

Safety:
Cancellation point Yes
Interrupt handler No
Signal handler Yes
Thread Yes

See also:

rsrcdbmgr_attach()


[Previous] [Contents] [Next]