本文整理汇总了C++中IOPCIDevice::mapDeviceMemoryWithIndex方法的典型用法代码示例。如果您正苦于以下问题:C++ IOPCIDevice::mapDeviceMemoryWithIndex方法的具体用法?C++ IOPCIDevice::mapDeviceMemoryWithIndex怎么用?C++ IOPCIDevice::mapDeviceMemoryWithIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IOPCIDevice
的用法示例。
在下文中一共展示了IOPCIDevice::mapDeviceMemoryWithIndex方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: start
/**
* 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