bool RTL8139::start( IOService *provider )
{
	OSObject	*builtinProperty;

    bool success = false;
    
	ELG( IOThreadSelf(), provider, 'Strt', "RTL8139::start - this, provider." );
    DEBUG_LOG( "start() ===>\n" );

    do
	{
        if ( false == super::start( provider ) )	// Start our superclass first
            break;

			// Save a reference to our provider.

        pciNub = OSDynamicCast( IOPCIDevice, provider );
        if ( 0 == pciNub )
            break;

        pciNub->retain();						// Retain provider, released in free().

        if ( false == pciNub->open( this ) )	// Open our provider.
            break;

		fBuiltin = false;
		builtinProperty = provider->getProperty( "built-in" );
	    if ( builtinProperty )
	    {
	    	fBuiltin = true;
			ELG( 0, 0, 'b-in', "RTL8139::start - found built-in property." );

		}

        if ( false == initEventSources( provider ) )
            break;

			// Allocate memory for descriptors. This function will leak memory
			// if called more than once. So don't do it.

        if ( false == allocateDescriptorMemory() )
            break;

			// Get the virtual address mapping of CSR registers located at
			// Base Address Range 0 (0x10).

        csrMap = pciNub->mapDeviceMemoryWithRegister( kIOPCIConfigBaseAddress1 );
        if ( 0 == csrMap )
            break;

        csrBase = (volatile void*)csrMap->getVirtualAddress();

			// Init PCI config space:

        if ( false == initPCIConfigSpace( pciNub ) )
            break;

			// Reset chip to bring it to a known state.

        if ( initAdapter( kResetChip ) == false )
        {
            IOLog( "%s: initAdapter() failed\n", getName() );
            break;
        }

		registerEEPROM();

			// Publish our media capabilities:

        phyProbeMediaCapability();
        if ( false == publishMediumDictionary( mediumDict ) )
			break;

        success = true;
	} while ( false );

		// Close our provider, it will be re-opened on demand when
		// our enable() is called by a client.

    if ( pciNub )
		 pciNub->close( this );
    
    do
	{
        if ( false == success )
            break;

        success = false;

			// Allocate and attach an IOEthernetInterface instance.

        if ( false == attachInterface( (IONetworkInterface**)&netif, false) )
            break;

			// Optional: this driver supports kernel debugging.

        attachDebuggerClient( &debugger );

			// Trigger matching for clients of netif.

        netif->registerService();
        success = true;
    }
    while ( false );

    DEBUG_LOG( "start() <===\n" );
    return success;
}/* end start */
bool AgereET131x::start(IOService* provider)
{
	//IOLog("%s::%s()\n",getName(),__FUNCTION__);
    bool success = false;
	
	if (super::start(provider) == false) {
		IOLog("supper::start failed.\n");
		return false;
	}
	pciDevice = OSDynamicCast(IOPCIDevice, provider);
	if (pciDevice == NULL)
		return false;
	
	
	pciDevice->retain();
	if (pciDevice->open(this) == false)
		return false;

	adapter.VendorID = pciDevice->configRead16(kIOPCIConfigVendorID);
	adapter.DeviceID = pciDevice->configRead16(kIOPCIConfigDeviceID);
	adapter.SubVendorID = pciDevice->configRead16(kIOPCIConfigSubSystemVendorID);
	adapter.SubSystemID = pciDevice->configRead16(kIOPCIConfigSubSystemID);
	adapter.RevisionID = pciDevice->configRead8(kIOPCIConfigRevisionID);
	
	
	// adapter.hw.device_id will be used later
	IOLog("vendor:device: 0x%x:0x%x.\n", adapter.VendorID, adapter.DeviceID);
	
	do {
		if(!initEventSources(provider)){
			break;
		}
		
		csrPCIAddress = pciDevice->mapDeviceMemoryWithRegister(kIOPCIConfigBaseAddress0);
		if (csrPCIAddress == NULL) {
			IOLog("csrPCIAddress.\n");
			break;
		}
		adapter.CSRAddress = (ADDRESS_MAP_t*)csrPCIAddress->getVirtualAddress();
		
		adapter.netdev = this;
		adapter.pdev = pciDevice;
		
		set_mtu( ETH_DATA_LEN );

		// Init PCI config space:
        if ( false == initPCIConfigSpace() )
            break;
		
		
		// reset the hardware with the new settings
		addNetworkMedium(kIOMediumEthernetAuto, 0, MEDIUM_INDEX_AUTO);
		addNetworkMedium(kIOMediumEthernet10BaseT | kIOMediumOptionHalfDuplex,
						 10 * MBit, MEDIUM_INDEX_10HD);
		addNetworkMedium(kIOMediumEthernet10BaseT | kIOMediumOptionFullDuplex,
						 10 * MBit, MEDIUM_INDEX_10FD);
		addNetworkMedium(kIOMediumEthernet100BaseTX | kIOMediumOptionHalfDuplex,
						 100 * MBit, MEDIUM_INDEX_100HD);
		addNetworkMedium(kIOMediumEthernet100BaseTX | kIOMediumOptionFullDuplex,
						 100 * MBit, MEDIUM_INDEX_100FD);
		addNetworkMedium(kIOMediumEthernet1000BaseT | kIOMediumOptionFullDuplex,
						 1000 * MBit, MEDIUM_INDEX_1000FD);
		
		if (!publishMediumDictionary(mediumDict)) {
			IOLog("publishMediumDictionary.\n");
			break;
		}
		
		success = true;
	} while(false);
	
	// Close our provider, it will be re-opened on demand when
	// our enable() is called by a client.
	pciDevice->close(this);

	do {
		if ( false == success )
			break;
		
		// Allocate and attach an IOEthernetInterface instance.
		if (attachInterface((IONetworkInterface **)(&netif), true) == false) {
			IOLog("Failed to attach data link layer.\n");
			break;
		}
		
		success = true;
	} while(false);

	if(false == success){
		adapter_memory_free();
	}
	return success;
}