示例#1
0
bool AppleIntelPIIXATARoot::start( IOService * provider )
{
    if ( super::start(provider) != true )
        return false;

    // Allocate a mutex to serialize access to PCI config space.
    
    _pciConfigLock = IOLockAlloc();
    if ( _pciConfigLock == 0 )
        return false;

    _provider = OSDynamicCast( IOPCIDevice, provider );
    if ( _provider == 0 )
        return false;

    _provider->retain();

    _nubs = createATAChannelNubs();
    if ( _nubs == 0 )
        return false;

    _openNubs = OSSet::withCapacity( _nubs->getCount() );
    if ( _openNubs == 0 )
        return false;

    // Register channel nubs.

    applyToClients( registerClientApplier, 0 );

    return true;
}
bool AppleNForceATARoot::start( IOService * provider )
{
    OSDictionary * match;

    if (super::start(provider) != true)
        return false;

    fProvider = OSDynamicCast( IOPCIDevice, provider );
    if (fProvider == 0)
        return false;

    fProvider->retain();

    // Enable bus master.

    fProvider->setBusMasterEnable( true );

    // Allocate a mutex to serialize access to PCI config space between
    // the primary and secondary ATA channels.

    fPCILock = IOLockAlloc();
    if (fPCILock == 0)
        return false;

    fIsSATA = (getProperty(kSerialATAKey) == kOSBooleanTrue);

    fChannels = createATAChannels();
    if (fChannels == 0)
        return false;

    fOpenChannels = OSSet::withCapacity( fChannels->getCount() );
    if (fOpenChannels == 0)
        return false;

    if (fIsSATA)
    {
        // Register SATA channels without delay.
        fHardwareType  = PCI_HW_SATA;
        fHardwareFlags = 0;
        applyToClients( registerClientApplier, 0 );
    }
    else if ((match = OSDynamicCast(OSDictionary,
                                    getProperty(kISABridgeMatchingKey))))
    {        
        match->retain();  // remove notification will consume a reference
    
        // Provider's PCI device ID does not tell us the hardware features
        // of the ATA controller. We need to locate the PCI-ISA bridge and
        // lookup a table before registering the channel nub(s). If bridge
        // is absent, we're in trouble.

        fISABridgeNotifier = addNotification(
                             /* type    */  gIOFirstPublishNotification,
                             /* match   */  match,
                             /* handler */  isaBridgePublished,
                             /* target  */  this,
                             /* refcon  */  0 );

        if (fISABridgeNotifier == 0)
        {
            match->release();
            return false;
        }
    }
    else
    {
        return false;
    }

    return true;
}