PATH 
ADC Home > Documentation > Hardware > Device Managers and Drivers > PCI Card Services > Designing PCI Cards and Drivers for Power Macintosh Computers


  

Finding a Device Entry

Every device driver typically needs to retrieve information about the device from the Name Registry. The example in Listing 10-13 retrieves the value of a single property for a specified name entry in the Name Registry.

Listing 10-13 Retrieving the value of a property

#include <NameRegistry.h>

OSStatus
JoePro_LookupProperty(
    const RegCStrPathName           *name,
    const RegPropertyName           *prop,
    RegPropertyValue                *val,
    RegPropertyValueSize            *siz
    )
{
    OSErr err = noErr;
    RegEntryID entry;
    err = JoePro_FindEntry(name, &entry);
    if (err == noErr) {
        err = JoePro_GetProperty(&entry, prop, val, siz);
        RegistryEntryIDDispose(&entry);
    }
    return err;
}

OSStatus JoePro_FindEntry(
    const RegCStrPathName           *name,
    RegEntryID                      *entry
    )
{
    return RegistryCStrEntryLookup(
            NULL /* start root */, name, entry);
}

OSStatus JoePro_GetProperty(
    RegEntryID                  *entry,
    RegPropertyName             *prop,
    RegPropertyValue            *val,
    RegPropertyValueSize        *siz
    )
{

    OSErr err = noErr;
    /*
    * Figure out how big a buffer we need for the value
    */
    err = RegistryPropertyGetSize(entry, prop, siz);
    if (err == noErr) {
        *val = (RegPropertyValue) malloc(*siz);
        assert(*val != NULL);

        err = RegistryPropertyGet(entry, prop, val, siz);
        if (err != noErr) {
            free(*val);
            *val = NULL;
        }
    }
    return err;
}

© 1999 Apple Computer, Inc. – (Last Updated 26 March 99)