hwi_next_item()

Updated: October 26, 2022

Find the next item in the hwinfo structure

Synopsis:

#include <hw/sysinfo.h>

unsigned hwi_next_item( unsigned off );

Arguments:

off
The offset, in bytes from the start of the hwinfo section, to start from.

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

The hwi_next_item() function finds the next item in the hwinfo structure of the system page.

Returns:

The offset of the next item, or HWI_NULL_OFF if there isn't another item.

Examples:

This program produces a summary of the information that the pidin syspage=hwinfo command displays:

#include <stdio.h>
#include <stdlib.h>
#include <hw/sysinfo.h>
#include <sys/syspage.h>

int main ( void )
{
    unsigned item_offset = 0, tag_offset = 0;
    struct hwi_item *curr_item, *curr_tag;
    int first_tag;

    printf ("Item              Offset  Owner  Tags\n");
    printf ("----              ------  -----  ----\n");
    
    while (item_offset != HWI_NULL_OFF)
    {
        /* Print the type, name, and offset of the current item */

        curr_item = hwi_off2tag (item_offset);  
        printf ("%-6s %-11s %3d",
                &SYSPAGE_ENTRY(strings)->data[curr_item->prefix.name],
                &SYSPAGE_ENTRY(strings)->data[curr_item->itemname],
                item_offset);
        
        /* Print the offset of the owner (if any) */

        if (curr_item->owner == HWI_NULL_OFF)
        {
            printf ("       ");
        } else {
            printf ("    %3d", curr_item->owner);
        }
        
        /* List the tags in this item */

        first_tag = 1;
        tag_offset = hwi_next_tag (item_offset, 1);

        while (tag_offset != HWI_NULL_OFF)
        {
            printf ("%s", first_tag ? "    " : ", ");
            first_tag = 0;
            
            curr_tag = hwi_off2tag (tag_offset);
            printf ("%s",
                    &SYSPAGE_ENTRY(strings)->data[curr_tag->prefix.name]);

            /* Get the offset of the next tag in the current item */

            tag_offset = hwi_next_tag (tag_offset, 1);
        }

        printf ("\n");
        
        /* Get the offset of the next item */

        item_offset = hwi_next_item (item_offset);
    }
    return (EXIT_SUCCESS);
}

The output from this program looks something like this:

Item             Offset Owner Tags
----             ------ ----- ----
Group  hw           0
Bus    unknown     12     0
Group  rtc         24    12
Device mc146818    36    24   pad, location
Bus    pci         80     0
Device bios        92    80
Bus    isa        108     0
Group  disk       120   108   diskgeometry
Group  misc       148   108
Device pckbd      160   148   irq, location
Group  serial     208   108
Device 8250       220   208   irq, pad, location, irq, location
Group  parallel   304   108
Device centronics 316   304   pad, location
Group  misc       360    12
Device in-use     372   360   pad, location, location, location, location, irq, irq

Classification:

QNX Neutrino

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