bool AppleMacIO::start( IOService * provider ) { IOPCIDevice *pciNub = (IOPCIDevice *)provider; if( !super::start( provider)) return( false); // Make sure memory space is on. pciNub->setMemoryEnable(true); fNub = provider; fMemory = provider->mapDeviceMemoryWithIndex( 0 ); if( 0 == fMemory) IOLog("%s: unexpected ranges\n", getName()); else if( !selfTest()) IOLog("Warning: AppleMacIO self test fails\n"); PMinit(); // initialize for power management temporaryPowerClampOn(); // hold power on till we get children return( true); }
/** * at_probe - Device Initialization Routine * @pdev: PCI device information struct * @ent: entry in at_pci_tbl * * Returns 0 on success, negative on failure * * at_probe initializes an adapter identified by a pci_dev structure. * The OS initialization, configuring of the adapter private structure, * and a hardware reset occur. **/ bool AtherosL1Ethernet::atProbe() { u16 vendorId, deviceId; at_adapter *adapter=&adapter_; IOPCIDevice *pdev = adapter_.pdev; pdev->setBusMasterEnable(true); pdev->setMemoryEnable(true); pdev->setIOEnable(true); vendorId = pdev->configRead16(kIOPCIConfigVendorID); deviceId = pdev->configRead16(kIOPCIConfigDeviceID); DbgPrint("Vendor ID %x, device ID %x\n", vendorId, deviceId); DbgPrint("MMR0 address %x\n", (u32)pdev->configRead32(kIOPCIConfigBaseAddress0)); pdev->enablePCIPowerManagement(); hw_addr_ = pdev->mapDeviceMemoryWithRegister(kIOPCIConfigBaseAddress0); if (hw_addr_ == NULL) { ErrPrint("Couldn't map io regs\n"); return false; } DbgPrint("Memory mapped at bus address %x, virtual address %x, length %d\n", (u32)hw_addr_->getPhysicalAddress(), (u32)hw_addr_->getVirtualAddress(), (u32)hw_addr_->getLength()); hw_addr_->retain(); adapter->hw.mmr_base = reinterpret_cast<char *>(hw_addr_->getVirtualAddress()); DbgPrint("REG_VPD_CAP = %x\n", OSReadLittleInt32(adapter->hw.mmr_base, REG_VPD_CAP)); DbgPrint("REG_PCIE_CAP_LIST = %x\n", OSReadLittleInt32(adapter->hw.mmr_base, REG_PCIE_CAP_LIST)); DbgPrint("REG_MASTER_CTRL = %x\n", OSReadLittleInt32(adapter->hw.mmr_base, REG_MASTER_CTRL)); at_setup_pcicmd(pdev); /* get user settings */ at_check_options(adapter); /* setup the private structure */ if(at_sw_init(adapter)) { ErrPrint("Couldn't init software\n"); return false; } /* Init GPHY as early as possible due to power saving issue */ at_phy_init(&adapter->hw); /* reset the controller to * put the device in a known good starting state */ if (at_reset_hw(&adapter->hw)) { ErrPrint("Couldn't reset hardware\n"); return false; //TO-DO: Uncomment } /* copy the MAC address out of the EEPROM */ at_read_mac_addr(&adapter->hw); return true; }
/** * Start this service. */ bool org_virtualbox_VBoxGuest::start(IOService *pProvider) { if (!IOService::start(pProvider)) return false; /* Low level initialization should be performed only once */ if (!ASMAtomicCmpXchgBool(&g_fInstantiated, true, false)) { IOService::stop(pProvider); return false; } m_pIOPCIDevice = OSDynamicCast(IOPCIDevice, pProvider); if (m_pIOPCIDevice) { if (isVmmDev(m_pIOPCIDevice)) { /* Enable memory response from VMM device */ m_pIOPCIDevice->setMemoryEnable(true); m_pIOPCIDevice->setIOEnable(true); IOMemoryDescriptor *pMem = m_pIOPCIDevice->getDeviceMemoryWithIndex(0); if (pMem) { IOPhysicalAddress IOPortBasePhys = pMem->getPhysicalAddress(); /* Check that returned value is from I/O port range (at least it is 16-bit lenght) */ if((IOPortBasePhys >> 16) == 0) { RTIOPORT IOPortBase = (RTIOPORT)IOPortBasePhys; void *pvMMIOBase = NULL; uint32_t cbMMIO = 0; m_pMap = m_pIOPCIDevice->mapDeviceMemoryWithIndex(1); if (m_pMap) { pvMMIOBase = (void *)m_pMap->getVirtualAddress(); cbMMIO = m_pMap->getLength(); } int rc = VBoxGuestInitDevExt(&g_DevExt, IOPortBase, pvMMIOBase, cbMMIO, #if ARCH_BITS == 64 VBOXOSTYPE_MacOS_x64, #else VBOXOSTYPE_MacOS, #endif 0); if (RT_SUCCESS(rc)) { rc = VbgdDarwinCharDevInit(); if (rc == KMOD_RETURN_SUCCESS) { if (setupVmmDevInterrupts(pProvider)) { /* register the service. */ registerService(); LogRel(("VBoxGuest: IOService started\n")); return true; } LogRel(("VBoxGuest: Failed to set up interrupts\n")); VbgdDarwinCharDevRemove(); } else LogRel(("VBoxGuest: Failed to initialize character device (rc=%d).\n", rc)); VBoxGuestDeleteDevExt(&g_DevExt); } else LogRel(("VBoxGuest: Failed to initialize common code (rc=%d).\n", rc)); if (m_pMap) { m_pMap->release(); m_pMap = NULL; } } } else LogRel(("VBoxGuest: The device missing is the I/O port range (#0).\n")); } else