ADC Home > Reference Library > Technical Q&As > Legacy Documents > Hardware & Drivers >

Legacy Documentclose button

Important: This document is part of the Legacy section of the ADC Reference Library. This information should not be used for new development.

Current information on this Reference Library topic can be found here:

Determining if a PCI Bus Exists


Q: How do I determine if the Power Macintosh has PCI expansion slots?

A The only way to do this is to use the Name Registry. Use the RegistryEntrySearch routine to search for entries whose "device_type" value is "pci." If an entry is found (RegistryEntrySearch returns noErr and done is false), there is at least one PCI bus. The Name Registry is documented in Chapter 8 of "Designing PCI Cards and Drivers for Power Macintosh Computers".

To allow your program to run on machines that don't have the Name Registry, you should weak link to "NameRegistryLib." You can then determine whether the Name Registry is available by testing the address of a symbol in the library against kUnresolvedCFragSymbolAddress. This technique is documented in Inside Macintosh: PowerPC System Software, p1-25.

The following snippet demonstrates both techniques:

static Boolean HasPCISlots(void)
    // Returns true if the machine has any PCI slots.   Guards against the
    //  absence of NameRegistryLib, so you can run this function on any PPC
    //  computer.
{
    Boolean result;
    RegEntryIter myIterator;
    OSStatus err;
    Boolean done;
    RegEntryID foundEntry;
    // Assume the worst.
    result = false;
    // Check that the link to NameRegistryLib was successful.
    if (RegistryEntryIterateCreate != kUnresolvedCFragSymbolAddress) {
        // Create an iterator
        if (RegistryEntryIterateCreate(&myIterator) == noErr) {
            // Search for a node of type "pci".
            (void) RegistryEntryIDInit(&foundEntry);
            err = RegistryEntrySearch(&myIterator, kRegIterContinue,
                                        &foundEntry, &done,
                                        "device_type",
                                        "pci", sizeof("pci"));
            // See whether we found one.
            if (err == noErr && !done) {
                result = true;
                (void) RegistryEntryIDDispose(&foundEntry);
            }
            (void) RegistryEntryIterateDispose(&myIterator);
        }
    }
    return (result);
}

[Nov 27 1996]


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.