- Timestamp:
- Jun 23, 2023 2:57:53 PM (18 months ago)
- Location:
- trunk
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/VBoxGuest.h
r98103 r100267 266 266 /** The MMIO mapping. NULL if no MMIO region. */ 267 267 struct VMMDevMemory volatile RT_FAR *pvVmmDevMapping; 268 /** The MMIO region for the request port, NULL if not available. */ 269 uintptr_t volatile RT_FAR *pMmioReq; 268 270 /** The I/O port address. */ 269 271 RTIOPORT IoPort; … … 273 275 } u; 274 276 } VBGLIOCGETVMMDEVIOINFO, RT_FAR *PVBGLIOCGETVMMDEVIOINFO; 275 AssertCompileSize(VBGLIOCGETVMMDEVIOINFO, 24 + (HC_ARCH_BITS == 64 ? 16 : 8));277 AssertCompileSize(VBGLIOCGETVMMDEVIOINFO, 24 + (HC_ARCH_BITS == 64 ? 24 : 12)); 276 278 /** @} */ 277 279 … … 388 390 VBGLREQHDR Hdr; 389 391 /** The physical address of the following VMMDevHGCMCall structure. */ 390 RTGCPHYS32 GCPhysReq; 392 RTGCPHYS64 GCPhysReq; 393 uint64_t uTimestamp[2]; /** @todo Looks completely unused. */ 391 394 /** Set if interruptible. */ 392 395 bool fInterruptible; 393 396 /** Reserved. */ 394 397 uint8_t abReserved0[3]; 395 uint64_t uTimestamp[2];396 uint8_t abReserved1[4];397 398 /* After this structure follows a VMMDevHGCMCall strcuture (44 bytes), then 398 399 zero or more HGCMFunctionParameter structures (12 or 16 bytes), and finally … … 400 401 } VBGLIOCIDCHGCMFASTCALL, RT_FAR *PVBGLIOCIDCHGCMFASTCALL; 401 402 #pragma pack() 402 AssertCompileSize(VBGLIOCIDCHGCMFASTCALL, /* 24 + 4 + 1 + 3 + 2*8 + 4= 0x34 (52) = */ 0x34);403 AssertCompileSize(VBGLIOCIDCHGCMFASTCALL, /* 24 + 8 + 2*8 + 1 + 3 = 0x34 (52) = */ 0x34); 403 404 404 405 /** … … 407 408 * 408 409 * @param a_pHdr The request header to initialize. 409 * @param a_HdrPhys The 32-bitphysical address corresponding to @a a_pHdr.410 * @param a_HdrPhys The physical address corresponding to @a a_pHdr. 410 411 * @param a_pCall Pointer to the VMMDevHGCMCall structure. 411 412 * @param a_idClient The HGCM client ID. -
trunk/include/VBox/VBoxGuestLib.h
r100205 r100267 121 121 * @return VBox status code. 122 122 */ 123 DECLR0VBGL(int) VbglR0InitPrimary(RTIOPORT portVMMDev, VMMDevMemory *pVMMDevMemory, uint32_t *pfFeatures);123 DECLR0VBGL(int) VbglR0InitPrimary(RTIOPORT portVMMDev, uintptr_t volatile *pMmioReq, VMMDevMemory *pVMMDevMemory, uint32_t *pfFeatures); 124 124 125 125 /** … … 484 484 * 485 485 * @returns VBox status code. 486 */ 487 DECLR0VBGL(int) VbglR0PhysHeapInit(void); 486 * @param fAlloc32BitAddr Flag whether all allocations should be below 4GiB, 487 * so they fit into a 32-bit address. 488 */ 489 DECLR0VBGL(int) VbglR0PhysHeapInit(bool fAlloc32BitAddr); 488 490 489 491 /** … … 513 515 * isn't valid. 514 516 */ 515 DECLR0VBGL( uint32_t) VbglR0PhysHeapGetPhysAddr(void *pv);517 DECLR0VBGL(RTCCPHYS) VbglR0PhysHeapGetPhysAddr(void *pv); 516 518 517 519 # ifdef IN_TESTCASE -
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-darwin.cpp
r98103 r100267 922 922 * Initialize the device extension. 923 923 */ 924 int rc = VGDrvCommonInitDevExt(&g_DevExt, IOPortBase, pvMMIOBase, cbMMIO,924 int rc = VGDrvCommonInitDevExt(&g_DevExt, IOPortBase, NULL /*pvMmioReq*/, pvMMIOBase, cbMMIO, 925 925 ARCH_BITS == 64 ? VBOXOSTYPE_MacOS_x64 : VBOXOSTYPE_MacOS, 0); 926 926 if (RT_SUCCESS(rc)) -
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-freebsd.c
r98103 r100267 717 717 */ 718 718 rc = VGDrvCommonInitDevExt(&g_DevExt, pState->uIOPortBase, 719 NULL /*pvMmioReq*/, 719 720 pState->pMMIOBase, pState->VMMDevMemSize, 720 721 #if ARCH_BITS == 64 -
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-haiku.c
r98103 r100267 476 476 * Call the common device extension initializer. 477 477 */ 478 rc = VGDrvCommonInitDevExt(&g_DevExt, pState->uIOPortBase, pState->pMMIOBase, pState->VMMDevMemSize, 478 rc = VGDrvCommonInitDevExt(&g_DevExt, pState->uIOPortBase, NULL /*pvMmioReq*/, 479 pState->pMMIOBase, pState->VMMDevMemSize, 479 480 #if ARCH_BITS == 64 480 481 VBOXOSTYPE_Haiku_x64, -
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-linux.c
r98542 r100267 148 148 /** The pointer to the mapping of the MMIO range. */ 149 149 static void *g_pvMMIOBase; 150 151 static RTHCPHYS g_MmioReqPhysAddr = NIL_RTHCPHYS; 152 static uint32_t g_cbMmioReq; 153 static void *g_pvMmioReq = NULL; 154 150 155 /** Wait queue used by polling. */ 151 156 static wait_queue_head_t g_PollEventQueue; … … 288 293 289 294 295 #if defined(RT_ARCH_ARM64) || defined(RT_ARCH_ARM32) 296 static int vgdrvLinuxMapMmio(struct pci_dev *pPciDev) 297 { 298 g_MmioReqPhysAddr = pci_resource_start(pPciDev, 3); 299 g_cbMmioReq = pci_resource_len(pPciDev, 3); 300 if (request_mem_region(g_MmioReqPhysAddr, g_cbMmioReq, DEVICE_NAME) != NULL) 301 { 302 g_pvMmioReq = ioremap(g_MmioReqPhysAddr, g_cbMmioReq); 303 if (g_pvMmioReq) 304 return 0; 305 306 /* failure cleanup path */ 307 LogRel((DEVICE_NAME ": ioremap failed; MMIO Addr=%RHp cb=%#x\n", g_MmioReqPhysAddr, g_cbMmioReq)); 308 release_mem_region(g_MmioReqPhysAddr, g_cbMmioReq); 309 return -ENOMEM; 310 } 311 else 312 LogRel((DEVICE_NAME ": failed to obtain adapter memory\n")); 313 314 return -EBUSY; 315 } 316 #endif 317 318 290 319 /** 291 320 * Does the PCI detection and init of the device. … … 302 331 if (rc >= 0) 303 332 { 333 #if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86) 304 334 /* I/O Ports are mandatory, the MMIO bit is not. */ 305 335 g_IOPortBase = pci_resource_start(pPciDev, 0); 306 336 if (g_IOPortBase != 0) 337 #elif defined(RT_ARCH_ARM64) || defined(RT_ARCH_ARM32) 338 rc = vgdrvLinuxMapMmio(pPciDev); 339 if (!rc) 340 #else 341 # error "I have no memory of this arechitecture" 342 #endif 307 343 { 308 344 /* … … 356 392 if (pPciDev) 357 393 { 394 if (g_pvMmioReq) 395 { 396 iounmap(g_pvMmioReq); 397 g_pvMmioReq = NULL; 398 399 release_mem_region(g_MmioReqPhysAddr, g_cbMmioReq); 400 g_MmioReqPhysAddr = NIL_RTHCPHYS; 401 g_cbMmioReq = 0; 402 } 403 358 404 iounmap(g_pvMMIOBase); 359 405 g_pvMMIOBase = NULL; … … 703 749 * Call the common device extension initializer. 704 750 */ 705 #if RTLNX_VER_MIN(2,6,0) && defined(RT_ARCH_X86) 751 #if RTLNX_VER_MIN(2,6,0) && defined(RT_ARCH_X86) || defined(RT_ARCH_ARM32) 706 752 VBOXOSTYPE enmOSType = VBOXOSTYPE_Linux26; 707 #elif RTLNX_VER_MIN(2,6,0) && defined(RT_ARCH_AMD64)753 #elif RTLNX_VER_MIN(2,6,0) && (defined(RT_ARCH_AMD64) || defined(RT_ARCH_ARM64)) 708 754 VBOXOSTYPE enmOSType = VBOXOSTYPE_Linux26_x64; 709 755 #elif RTLNX_VER_MIN(2,4,0) && defined(RT_ARCH_X86) … … 717 763 rc = VGDrvCommonInitDevExt(&g_DevExt, 718 764 g_IOPortBase, 765 g_pvMmioReq, 719 766 g_pvMMIOBase, 720 767 g_cbMMIO, -
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-netbsd.c
r98103 r100267 334 334 */ 335 335 rc = VGDrvCommonInitDevExt(&g_DevExt, sc->sc_iobase, 336 NULL /*pvMmioReq*/, 336 337 bus_space_vaddr(sc->sc_memt, sc->sc_memh), 337 338 sc->sc_memsize, -
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-os2.cpp
r98103 r100267 187 187 if (g_MemMapMMIO != NIL_RTR0MEMOBJ) 188 188 rc = VGDrvCommonInitDevExt(&g_DevExt, g_IOPortBase, 189 NULL /*pvMmioReq*/, 189 190 RTR0MemObjAddress(g_MemMapMMIO), 190 191 RTR0MemObjSize(g_MemMapMMIO), -
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-solaris.c
r98103 r100267 335 335 * Call the common device extension initializer. 336 336 */ 337 rc = VGDrvCommonInitDevExt(&g_DevExt, g_uIOPortBase, g_pMMIOBase, g_cbMMIO, 337 rc = VGDrvCommonInitDevExt(&g_DevExt, g_uIOPortBase, 338 NULL /*pvMmioReq*/, 339 g_pMMIOBase, g_cbMMIO, 338 340 #if ARCH_BITS == 64 339 341 VBOXOSTYPE_Solaris_x64, -
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-win.cpp
r99365 r100267 1072 1072 int vrc = VGDrvCommonInitDevExtResources(&pDevExt->Core, 1073 1073 pDevExt->Core.IOPortBase, 1074 NULL /*pvMmioReq*/, 1074 1075 pvMMIOBase, cbMMIO, 1075 1076 vgdrvNtVersionToOSType(g_enmVGDrvNtVer), -
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest.cpp
r98103 r100267 72 72 #include <iprt/memobj.h> 73 73 #include <iprt/asm.h> 74 #include <iprt/asm-amd64-x86.h> 74 #if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86) 75 # include <iprt/asm-amd64-x86.h> 76 #endif 75 77 #include <iprt/string.h> 76 78 #include <iprt/process.h> … … 994 996 */ 995 997 pDevExt->IOPortBase = UINT16_MAX; 998 pDevExt->pMmioReq = NULL; 999 pDevExt->pMmioReqFast = NULL; 996 1000 pDevExt->pVMMDevMemory = NULL; 997 1001 pDevExt->hGuestMappings = NIL_RTR0MEMOBJ; … … 1098 1102 * @param pDevExt The device extension. Allocated by the native code. 1099 1103 * @param IOPortBase The base of the I/O port range. 1104 * @param pvMmioReq The base of the MMIO request region. 1100 1105 * @param pvMMIOBase The base of the MMIO memory mapping. 1101 1106 * This is optional, pass NULL if not present. … … 1107 1112 */ 1108 1113 int VGDrvCommonInitDevExtResources(PVBOXGUESTDEVEXT pDevExt, uint16_t IOPortBase, 1109 void *pvMMIOBase, uint32_t cbMMIO, VBOXOSTYPE enmOSType, uint32_t fFixedEvents) 1114 void *pvMmioReq, void *pvMMIOBase, uint32_t cbMMIO, 1115 VBOXOSTYPE enmOSType, uint32_t fFixedEvents) 1110 1116 { 1111 1117 int rc; … … 1138 1144 * made by the VMM. 1139 1145 */ 1140 pDevExt->IOPortBase = IOPortBase; 1141 rc = VbglR0InitPrimary(pDevExt->IOPortBase, (VMMDevMemory *)pDevExt->pVMMDevMemory, &pDevExt->fHostFeatures); 1146 pDevExt->IOPortBase = IOPortBase; 1147 pDevExt->pMmioReq = (uintptr_t volatile *)pvMmioReq; 1148 pDevExt->pMmioReqFast = (uint32_t volatile *)((uintptr_t)pvMmioReq + VMMDEV_MMIO_OFF_REQUEST_FAST); 1149 rc = VbglR0InitPrimary(pDevExt->IOPortBase, pDevExt->pMmioReq, (VMMDevMemory *)pDevExt->pVMMDevMemory, &pDevExt->fHostFeatures); 1142 1150 if (RT_SUCCESS(rc)) 1143 1151 { … … 1147 1155 { 1148 1156 pDevExt->PhysIrqAckEvents = VbglR0PhysHeapGetPhysAddr(pAckReq); 1149 Assert(pDevExt->PhysIrqAckEvents != 0); 1157 Assert( pDevExt->PhysIrqAckEvents != 0 1158 && pDevExt->PhysIrqAckEvents == (uintptr_t)pDevExt->PhysIrqAckEvents); 1150 1159 ASMCompilerBarrier(); /* linux + solaris already have IRQs hooked up at this point, so take care. */ 1151 1160 pDevExt->pIrqAckEvents = (VMMDevEvents *)pAckReq; … … 1321 1330 * @param pDevExt The device extension. Allocated by the native code. 1322 1331 * @param IOPortBase The base of the I/O port range. 1332 * @param pvMmioReq The base of the MMIO request region. 1323 1333 * @param pvMMIOBase The base of the MMIO memory mapping. 1324 1334 * This is optional, pass NULL if not present. … … 1330 1340 */ 1331 1341 int VGDrvCommonInitDevExt(PVBOXGUESTDEVEXT pDevExt, uint16_t IOPortBase, 1332 void *pvMMIOBase, uint32_t cbMMIO, VBOXOSTYPE enmOSType, uint32_t fFixedEvents) 1342 void *pvMmioReq, void *pvMMIOBase, uint32_t cbMMIO, 1343 VBOXOSTYPE enmOSType, uint32_t fFixedEvents) 1333 1344 { 1334 1345 int rc; … … 1338 1349 if (RT_SUCCESS(rc)) 1339 1350 { 1340 rc = VGDrvCommonInitDevExtResources(pDevExt, IOPortBase, pvMMIOBase, cbMMIO, enmOSType, fFixedEvents); 1351 rc = VGDrvCommonInitDevExtResources(pDevExt, IOPortBase, pvMmioReq, pvMMIOBase, cbMMIO, 1352 enmOSType, fFixedEvents); 1341 1353 if (RT_SUCCESS(rc)) 1342 1354 return rc; … … 2076 2088 pInfo->u.Out.IoPort = pDevExt->IOPortBase; 2077 2089 pInfo->u.Out.pvVmmDevMapping = pDevExt->pVMMDevMemory; 2090 pInfo->u.Out.pMmioReq = pDevExt->pMmioReq; 2078 2091 pInfo->u.Out.auPadding[0] = 0; 2079 2092 #if HC_ARCH_BITS != 32 … … 2799 2812 fFlags = !fUserData && pSession->R0Process == NIL_RTR0PROCESS ? VBGLR0_HGCMCALL_F_KERNEL : VBGLR0_HGCMCALL_F_USER; 2800 2813 uint32_t cbInfo = (uint32_t)(cbData - cbExtra); 2801 #if def RT_ARCH_AMD642814 #if defined(RT_ARCH_AMD64) || defined(RT_ARCH_ARM64) 2802 2815 if (f32bit) 2803 2816 { … … 2864 2877 */ 2865 2878 Assert((pCallReq->GCPhysReq & PAGE_OFFSET_MASK) == ((uintptr_t)pHgcmCall & PAGE_OFFSET_MASK)); 2879 AssertReturn(pCallReq->GCPhysReq == (uintptr_t)pCallReq->GCPhysReq, VERR_VBGL_INVALID_ADDR); 2866 2880 2867 2881 AssertReturn(!pCallReq->fInterruptible, VERR_NOT_IMPLEMENTED); … … 2871 2885 */ 2872 2886 Log(("vgdrvIoCtl_HGCMFastCall -> host\n")); 2873 ASMOutU32(pDevExt->IOPortBase + VMMDEV_PORT_OFF_REQUEST, (uint32_t)pCallReq->GCPhysReq); 2887 if (pDevExt->pMmioReq) 2888 *pDevExt->pMmioReq = (uintptr_t)pCallReq->GCPhysReq; 2889 else 2890 { 2891 #if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86) 2892 ASMOutU32(pDevExt->IOPortBase + VMMDEV_PORT_OFF_REQUEST, (uint32_t)pCallReq->GCPhysReq); 2893 #elif defined(RT_ARCH_ARM64) || defined(RT_ARCH_ARM32) 2894 AssertReleaseFailed(); /* Not possible on ARM. */ 2895 return VERR_INVALID_STATE; 2896 #else 2897 # error "I have no memory of this architecture" 2898 #endif 2899 } 2874 2900 2875 2901 /* Make the compiler aware that the host has changed memory. */ … … 4413 4439 if (!pReq) 4414 4440 { 4415 fEvents = ASMInU32(pDevExt->IOPortBase + VMMDEV_PORT_OFF_REQUEST_FAST); 4441 if (pDevExt->pMmioReqFast) 4442 fEvents = *pDevExt->pMmioReqFast; 4443 else 4444 { 4445 #if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86) 4446 fEvents = ASMInU32(pDevExt->IOPortBase + VMMDEV_PORT_OFF_REQUEST_FAST); 4447 #elif defined(RT_ARCH_ARM64) || defined(RT_ARCH_ARM32) 4448 AssertReleaseFailed(); /* No port I/O on ARM. */ 4449 #else 4450 # error "I have no memory of this architecture" 4451 #endif 4452 } 4416 4453 ASMCompilerBarrier(); /* paranoia */ 4417 4454 rc = fEvents != UINT32_MAX ? VINF_SUCCESS : VERR_INTERNAL_ERROR; … … 4422 4459 pReq->events = 0; 4423 4460 ASMCompilerBarrier(); 4424 ASMOutU32(pDevExt->IOPortBase + VMMDEV_PORT_OFF_REQUEST, (uint32_t)pDevExt->PhysIrqAckEvents); 4461 if (pDevExt->pMmioReq) 4462 *pDevExt->pMmioReq = pDevExt->PhysIrqAckEvents; 4463 else 4464 { 4465 #if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86) 4466 ASMOutU32(pDevExt->IOPortBase + VMMDEV_PORT_OFF_REQUEST, (uint32_t)pDevExt->PhysIrqAckEvents); 4467 #elif defined(RT_ARCH_ARM64) || defined(RT_ARCH_ARM32) 4468 AssertReleaseFailed(); 4469 #else 4470 # error "I have no memory of this architecture" 4471 #endif 4472 } 4473 4425 4474 ASMCompilerBarrier(); /* paranoia */ 4426 4475 fEvents = pReq->events; -
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuestInternal.h
r98103 r100267 157 157 /** The base of the adapter I/O ports. */ 158 158 RTIOPORT IOPortBase; 159 /** Pointer to the mapping of the MMIO request region if available. */ 160 uintptr_t volatile *pMmioReq; 161 /** Pointer to the fast request register in the MMIO region if available. */ 162 uint32_t volatile *pMmioReqFast; 159 163 /** Pointer to the mapping of the VMMDev adapter memory. */ 160 164 VMMDevMemory volatile *pVMMDevMemory; … … 350 354 RT_C_DECLS_BEGIN 351 355 352 int VGDrvCommonInitDevExt(PVBOXGUESTDEVEXT pDevExt, uint16_t IOPortBase, void *pvMMIOBase, uint32_t cbMMIO, 356 int VGDrvCommonInitDevExt(PVBOXGUESTDEVEXT pDevExt, uint16_t IOPortBase, void *pvMmioReq, 357 void *pvMMIOBase, uint32_t cbMMIO, 353 358 VBOXOSTYPE enmOSType, uint32_t fEvents); 354 359 void VGDrvCommonDeleteDevExt(PVBOXGUESTDEVEXT pDevExt); … … 359 364 void VGDrvCommonDeleteDevExtFundament(PVBOXGUESTDEVEXT pDevExt); 360 365 int VGDrvCommonInitDevExtResources(PVBOXGUESTDEVEXT pDevExt, uint16_t IOPortBase, 361 void *pvMMIOBase, uint32_t cbMMIO, VBOXOSTYPE enmOSType, uint32_t fFixedEvents); 366 void *pvMmioReq, void *pvMMIOBase, uint32_t cbMMIO, 367 VBOXOSTYPE enmOSType, uint32_t fFixedEvents); 362 368 void VGDrvCommonDeleteDevExtResources(PVBOXGUESTDEVEXT pDevExt); 363 369 int VGDrvCommonReinitDevExtAfterHibernation(PVBOXGUESTDEVEXT pDevExt, VBOXOSTYPE enmOSType); -
trunk/src/VBox/Additions/common/VBoxGuest/lib/VBoxGuestR0LibGenericRequest.cpp
r98103 r100267 35 35 #include "VBoxGuestR0LibInternal.h" 36 36 #include <iprt/asm.h> 37 #include <iprt/asm-amd64-x86.h> 37 #if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86) 38 # include <iprt/asm-amd64-x86.h> 39 #endif 38 40 #include <iprt/assert.h> 39 41 #include <iprt/string.h> … … 159 161 { 160 162 RTCCPHYS PhysAddr = VbglR0PhysHeapGetPhysAddr(pReq); 161 if ( PhysAddr != 0 162 && PhysAddr < _4G) /* Port IO is 32 bit. */ 163 if (PhysAddr != 0) 163 164 { 164 ASMOutU32(g_vbgldata.portVMMDev + VMMDEV_PORT_OFF_REQUEST, (uint32_t)PhysAddr); 165 if (g_vbgldata.pMmioReq) 166 { 167 Assert((uintptr_t)PhysAddr == PhysAddr); 168 *g_vbgldata.pMmioReq = (uintptr_t)PhysAddr; 169 } 170 else if (PhysAddr < _4G) /* Port IO is 32 bit. */ 171 { 172 #if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86) 173 ASMOutU32(g_vbgldata.portVMMDev + VMMDEV_PORT_OFF_REQUEST, (uint32_t)PhysAddr); 174 #elif defined(RT_ARCH_ARM64) || defined(RT_ARCH_ARM32) 175 rc = VERR_INVALID_STATE; 176 #else 177 # error "I have no memory of this architecture" 178 #endif 179 } 180 else 181 rc = VERR_VBGL_INVALID_ADDR; 182 165 183 /* Make the compiler aware that the host has changed memory. */ 166 ASMCompilerBarrier(); 167 rc = pReq->rc; 184 if (RT_SUCCESS(rc)) 185 { 186 ASMCompilerBarrier(); 187 rc = pReq->rc; 188 } 168 189 } 169 190 else -
trunk/src/VBox/Additions/common/VBoxGuest/lib/VBoxGuestR0LibInit.cpp
r98103 r100267 115 115 g_vbgldata.portVMMDev = PortInfo.u.Out.IoPort; 116 116 g_vbgldata.pVMMDevMemory = (VMMDevMemory *)PortInfo.u.Out.pvVmmDevMapping; 117 g_vbgldata.status = VbglStatusReady; 118 119 vbglR0QueryHostVersion(); 117 g_vbgldata.pMmioReq = PortInfo.u.Out.pMmioReq; 118 119 rc = VbglR0PhysHeapInit(g_vbgldata.pMmioReq == NULL /*fAlloc32BitAddr*/); 120 if (RT_SUCCESS(rc)) 121 { 122 g_vbgldata.status = VbglStatusReady; 123 vbglR0QueryHostVersion(); 124 } 125 else 126 { 127 LogRel(("vbglR0QueryDriverInfo: VbglR0PhysHeapInit() -> %Rrc\n", rc)); 128 g_vbgldata.status = VbglStatusNotInitialized; 129 } 120 130 } 121 131 } … … 160 170 static int vbglR0InitCommon(void) 161 171 { 162 int rc;163 164 172 RT_ZERO(g_vbgldata); 165 173 g_vbgldata.status = VbglStatusInitializing; 166 167 rc = VbglR0PhysHeapInit(); 168 if (RT_SUCCESS(rc)) 169 { 170 dprintf(("vbglR0InitCommon: returns rc = %d\n", rc)); 171 return rc; 172 } 173 174 LogRel(("vbglR0InitCommon: VbglR0PhysHeapInit failed: rc=%Rrc\n", rc)); 175 g_vbgldata.status = VbglStatusNotInitialized; 176 return rc; 174 return VINF_SUCCESS; 177 175 } 178 176 … … 186 184 #ifdef VBGL_VBOXGUEST 187 185 188 DECLR0VBGL(int) VbglR0InitPrimary(RTIOPORT portVMMDev, VMMDevMemory *pVMMDevMemory, uint32_t *pfFeatures)186 DECLR0VBGL(int) VbglR0InitPrimary(RTIOPORT portVMMDev, uintptr_t volatile *pMmioReq, VMMDevMemory *pVMMDevMemory, uint32_t *pfFeatures) 189 187 { 190 188 int rc; … … 208 206 g_vbgldata.portVMMDev = portVMMDev; 209 207 g_vbgldata.pVMMDevMemory = pVMMDevMemory; 210 g_vbgldata.status = VbglStatusReady; 211 212 vbglR0QueryHostVersion(); 213 *pfFeatures = g_vbgldata.hostVersion.features; 214 return VINF_SUCCESS; 208 g_vbgldata.pMmioReq = pMmioReq; 209 210 rc = VbglR0PhysHeapInit(pMmioReq == NULL /*fAlloc32BitAddr*/); 211 if (RT_SUCCESS(rc)) 212 { 213 g_vbgldata.status = VbglStatusReady; 214 215 vbglR0QueryHostVersion(); 216 *pfFeatures = g_vbgldata.hostVersion.features; 217 return VINF_SUCCESS; 218 } 219 else 220 { 221 LogRel(("VbglR0InitPrimary: VbglR0PhysHeapInit() -> %Rrc\n", rc)); 222 g_vbgldata.status = VbglStatusNotInitialized; 223 } 215 224 } 216 225 -
trunk/src/VBox/Additions/common/VBoxGuest/lib/VBoxGuestR0LibInternal.h
r98103 r100267 125 125 typedef struct VBGLDATA 126 126 { 127 enum VbglLibStatus status; 128 129 RTIOPORT portVMMDev; 130 131 VMMDevMemory *pVMMDevMemory; 127 /** Init status of the library. */ 128 enum VbglLibStatus status; 129 /** I/O port to issue requests to. */ 130 RTIOPORT portVMMDev; 131 /** MMIO request region if available. */ 132 volatile uintptr_t *pMmioReq; 133 /** VMMDev adapter memory region if available. */ 134 VMMDevMemory *pVMMDevMemory; 132 135 133 136 /** Physical memory heap data. … … 149 152 /** Head of the chunk list. */ 150 153 VBGLPHYSHEAPCHUNK *pChunkHead; 154 /** Flag whether all allocations should be below 4GiB to fit into 155 * a 32-bit address. */ 156 bool fAlloc32BitAddr; 151 157 /** @} */ 152 158 -
trunk/src/VBox/Additions/common/VBoxGuest/lib/VBoxGuestR0LibPhysHeap.cpp
r98103 r100267 215 215 /** Magic value (VBGL_PH_CHUNKSIGNATURE). */ 216 216 uint32_t u32Signature; 217 218 217 /** Size of the chunk. Includes the chunk header. */ 219 218 uint32_t cbChunk; 220 221 /** Physical address of the chunk (contiguous). */222 uint32_t physAddr;223 224 #if !defined(VBGL_PH_USE_MEMOBJ) || ARCH_BITS != 32225 uint32_t uPadding1;226 #endif227 228 219 /** Number of block of any kind. */ 229 220 int32_t cBlocks; … … 231 222 int32_t cFreeBlocks; 232 223 224 /** Physical address of the chunk (contiguous). */ 225 RTCCPHYS physAddr; 226 233 227 /** Pointer to the next chunk. */ 234 228 VBGLPHYSHEAPCHUNK *pNext; … … 239 233 /** The allocation handle. */ 240 234 RTR0MEMOBJ hMemObj; 241 #endif 242 243 #if ARCH_BITS == 64 235 #elif ARCH_BITS == 64 244 236 /** Pad the size up to 64 bytes. */ 245 237 # ifdef VBGL_PH_USE_MEMOBJ … … 252 244 #if ARCH_BITS == 64 253 245 AssertCompileSize(VBGLPHYSHEAPCHUNK, 64); 246 #elif ARCH_BITS == 32 247 AssertCompileSize(VBGLPHYSHEAPCHUNK, 32); 248 #else 249 # error "Unknown architecture!" 254 250 #endif 255 251 … … 536 532 cbChunk = RT_ALIGN_32(cbChunk, VBGL_PH_CHUNKSIZE); 537 533 538 /* 539 * This function allocates physical contiguous memory below 4 GB. This 4GB 540 * limitation stems from using a 32-bit OUT instruction to pass a block 541 * physical address to the host. 542 */ 534 if (g_vbgldata.fAlloc32BitAddr) 535 { 536 /* 537 * This function allocates physical contiguous memory below 4 GB. This 4GB 538 * limitation stems from using a 32-bit OUT instruction to pass a block 539 * physical address to the host. 540 */ 543 541 #ifdef VBGL_PH_USE_MEMOBJ 544 rc = RTR0MemObjAllocCont(&hMemObj, cbChunk, false /*fExecutable*/);545 pChunk = (VBGLPHYSHEAPCHUNK *)(RT_SUCCESS(rc) ? RTR0MemObjAddress(hMemObj) : NULL);542 rc = RTR0MemObjAllocCont(&hMemObj, cbChunk, false /*fExecutable*/); 543 pChunk = (VBGLPHYSHEAPCHUNK *)(RT_SUCCESS(rc) ? RTR0MemObjAddress(hMemObj) : NULL); 546 544 #else 547 pChunk = (VBGLPHYSHEAPCHUNK *)RTMemContAlloc(&PhysAddr, cbChunk); 548 #endif 545 pChunk = (VBGLPHYSHEAPCHUNK *)RTMemContAlloc(&PhysAddr, cbChunk); 546 #endif 547 } 548 else 549 { 550 /** @todo Provide appropriate memory API. */ 551 #ifdef VBGL_PH_USE_MEMOBJ 552 rc = RTR0MemObjAllocCont(&hMemObj, cbChunk, false /*fExecutable*/); 553 pChunk = (VBGLPHYSHEAPCHUNK *)(RT_SUCCESS(rc) ? RTR0MemObjAddress(hMemObj) : NULL); 554 #else 555 pChunk = (VBGLPHYSHEAPCHUNK *)RTMemContAlloc(&PhysAddr, cbChunk); 556 #endif 557 } 549 558 if (!pChunk) 550 559 { … … 569 578 VBGLPHYSHEAPCHUNK *pOldHeadChunk; 570 579 VBGLPHYSHEAPFREEBLOCK *pBlock; 571 AssertRelease(PhysAddr < _4G && PhysAddr + cbChunk <= _4G); 580 AssertRelease( !g_vbgldata.fAlloc32BitAddr 581 || (PhysAddr < _4G && PhysAddr + cbChunk <= _4G)); 572 582 573 583 /* … … 576 586 pChunk->u32Signature = VBGL_PH_CHUNKSIGNATURE; 577 587 pChunk->cbChunk = cbChunk; 578 pChunk->physAddr = (uint32_t)PhysAddr;588 pChunk->physAddr = PhysAddr; 579 589 pChunk->cBlocks = 0; 580 590 pChunk->cFreeBlocks = 0; … … 586 596 587 597 /* Initialize the padding too: */ 588 #if !defined(VBGL_PH_USE_MEMOBJ) || ARCH_BITS != 32589 pChunk->uPadding1 = UINT32_C(0xADDCAAA1);590 #endif591 598 #if ARCH_BITS == 64 592 599 pChunk->auPadding2[0] = UINT64_C(0xADDCAAA3ADDCAAA2); … … 865 872 866 873 867 DECLR0VBGL( uint32_t) VbglR0PhysHeapGetPhysAddr(void *pv)874 DECLR0VBGL(RTCCPHYS) VbglR0PhysHeapGetPhysAddr(void *pv) 868 875 { 869 876 /* … … 1176 1183 #endif /* IN_TESTCASE */ 1177 1184 1178 DECLR0VBGL(int) VbglR0PhysHeapInit(void) 1179 { 1180 g_vbgldata.hMtxHeap = NIL_RTSEMFASTMUTEX; 1185 DECLR0VBGL(int) VbglR0PhysHeapInit(bool fAlloc32BitAddr) 1186 { 1187 g_vbgldata.fAlloc32BitAddr = fAlloc32BitAddr; 1188 g_vbgldata.hMtxHeap = NIL_RTSEMFASTMUTEX; 1181 1189 1182 1190 /* Allocate the first chunk of the heap. */
Note:
See TracChangeset
for help on using the changeset viewer.