Changeset 28425 in vbox
- Timestamp:
- Apr 16, 2010 6:06:35 PM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 60191
- Location:
- trunk
- Files:
-
- 1 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/pdmapi.h
r27254 r28425 36 36 37 37 #include <VBox/types.h> 38 #include <VBox/sup.h> 38 39 39 40 RT_C_DECLS_BEGIN … … 57 58 VMMDECL(bool) PDMVMMDevHeapIsEnabled(PVM pVM); 58 59 59 #ifdef IN_RING3 60 60 61 /** @defgroup grp_pdm_r3 The PDM Host Context Ring-3 API 61 62 * @ingroup grp_pdm … … 129 130 VMMR3DECL(void) PDMR3ReleaseOwnedLocks(PVM pVM); 130 131 /** @} */ 131 #endif132 132 133 133 134 #ifdef IN_RC 135 /** @defgroup grp_pdm_ gc The PDM GuestContext API134 135 /** @defgroup grp_pdm_rc The PDM Raw-Mode Context API 136 136 * @ingroup grp_pdm 137 137 * @{ 138 138 */ 139 139 /** @} */ 140 #endif 140 141 142 143 /** @defgroup grp_pdm_r0 The PDM Ring-0 Context API 144 * @ingroup grp_pdm 145 * @{ 146 */ 147 148 /** 149 * Request buffer for PDMR0DriverCallReqHandler / VMMR0_DO_PDM_DRIVER_CALL_REQ_HANDLER. 150 * @see PDMR0DriverCallReqHandler. 151 */ 152 typedef struct PDMDRIVERCALLREQHANDLERREQ 153 { 154 /** The header. */ 155 SUPVMMR0REQHDR Hdr; 156 /** The driver instance. */ 157 PPDMDRVINSR0 pDrvInsR0; 158 /** The operation. */ 159 uint32_t uOperation; 160 /** Explicit alignment padding. */ 161 uint32_t u32Alignment; 162 /** Optional 64-bit integer argument. */ 163 uint64_t u64Arg; 164 } PDMDRIVERCALLREQHANDLERREQ; 165 /** Pointer to a PDMR0DriverCallReqHandler / VMMR0_DO_PDM_DRIVER_CALL_REQ_HANDLER 166 * request buffer. */ 167 typedef PDMDRIVERCALLREQHANDLERREQ *PPDMDRIVERCALLREQHANDLERREQ; 168 169 VMMR0_INT_DECL(int) PDMR0DriverCallReqHandler(PVM pVM, PPDMDRIVERCALLREQHANDLERREQ pReq); 170 171 /** @} */ 141 172 142 173 RT_C_DECLS_END -
trunk/include/VBox/pdmcommon.h
r26001 r28425 136 136 typedef FNPDMDRVASYNCNOTIFY *PFNPDMDRVASYNCNOTIFY; 137 137 138 /** 139 * The ring-0 driver request handle. 140 * 141 * @returns VBox status code. PDMDrvHlpCallR0 will return this. 142 * @param pDrvIns The driver instance (the ring-0 mapping). 143 * @param uOperation The operation. 144 * @param u64Arg Optional integer argument for the operation. 145 */ 146 typedef DECLCALLBACK(int) FNPDMDRVREQHANDLERR0(PPDMDRVINS pDrvIns, uint32_t uOperation, uint64_t u64Arg); 147 /** Ring-0 pointer to a FNPDMDRVREQHANDLERR0. */ 148 typedef R0PTRTYPE(FNPDMDRVREQHANDLERR0 *) PFNPDMDRVREQHANDLERR0; 149 138 150 /** @} */ 139 151 -
trunk/include/VBox/pdmdrv.h
r28329 r28425 403 403 404 404 /** Converts a pointer to the PDMDRVINS::IBase to a pointer to PDMDRVINS. */ 405 #define PDMIBASE_2_PDMDRV(pInterface) ( (PPDMDRVINS)((char *)(pInterface) - RT_OFFSETOF(PDMDRVINS, IBase)) ) 405 #define PDMIBASE_2_PDMDRV(pInterface) ( (PPDMDRVINS)((char *)(pInterface) - RT_OFFSETOF(PDMDRVINS, IBase)) ) 406 407 /** @def PDMDRVINS_2_RCPTR 408 * Converts a PDM Driver instance pointer a RC PDM Driver instance pointer. 409 */ 410 #define PDMDRVINS_2_RCPTR(pDrvIns) ( (RCPTRTYPE(PPDMDRVINS))((RTGCUINTPTR)(pDrvIns)->pvInstanceDataRC - RT_OFFSETOF(PDMDRVINS, achInstanceData)) ) 411 412 /** @def PDMDRVINS_2_R3PTR 413 * Converts a PDM Driver instance pointer a R3 PDM Driver instance pointer. 414 */ 415 #define PDMDRVINS_2_R3PTR(pDrvIns) ( (R3PTRTYPE(PPDMDRVINS))((RTHCUINTPTR)(pDrvIns)->pvInstanceDataR3 - RT_OFFSETOF(PDMDRVINS, achInstanceData)) ) 416 417 /** @def PDMDRVINS_2_R0PTR 418 * Converts a PDM Driver instance pointer a R0 PDM Driver instance pointer. 419 */ 420 #define PDMDRVINS_2_R0PTR(pDrvIns) ( (R0PTRTYPE(PPDMDRVINS))((RTR0UINTPTR)(pDrvIns)->pvInstanceDataR0 - RT_OFFSETOF(PDMDRVINS, achInstanceData)) ) 421 422 406 423 407 424 /** … … 1160 1177 DECLR3CALLBACKMEMBER(int, pfnCritSectInit,(PPDMDRVINS pDrvIns, PPDMCRITSECT pCritSect, 1161 1178 RT_SRC_POS_DECL, const char *pszName)); 1179 1180 /** 1181 * Call the ring-0 request handler routine of the driver. 1182 * 1183 * For this to work, the driver must be ring-0 enabled and export a request 1184 * handler function. The name of the function must be the driver name in the 1185 * PDMDRVREG struct prefixed with 'drvR0' and suffixed with 'ReqHandler'. It 1186 * shall take the exact same arguments as this function and be declared using 1187 * PDMBOTHCBDECL. See FNPDMDRVREQHANDLERR0. 1188 * 1189 * @returns VBox status code. 1190 * @retval VERR_SYMBOL_NOT_FOUND if the driver doesn't export the required 1191 * handler function. 1192 * @retval VERR_ACCESS_DENIED if the driver isn't ring-0 capable. 1193 * 1194 * @param pDevIns The device instance. 1195 * @param uOperation The operation to perform. 1196 * @param u64Arg 64-bit integer argument. 1197 * @thread Any 1198 */ 1199 DECLR3CALLBACKMEMBER(int, pfnCallR0,(PPDMDRVINS pDrvIns, uint32_t uOperation, uint64_t u64Arg)); 1200 1162 1201 /** Just a safety precaution. */ 1163 1202 uint32_t u32TheEnd; … … 1526 1565 } 1527 1566 1567 /** 1568 * @copydoc PDMDRVHLP::pfnCallR0 1569 */ 1570 DECLINLINE(int) PDMDrvHlpCallR0(PPDMDRVINS pDrvIns, uint32_t uOperation, uint64_t u64Arg) 1571 { 1572 return pDrvIns->pHlpR3->pfnCallR0(pDrvIns, uOperation, u64Arg); 1573 } 1574 1528 1575 1529 1576 /** Pointer to callbacks provided to the VBoxDriverRegister() call. */ -
trunk/include/VBox/vmm.h
r28422 r28425 300 300 /** Call GMMR0FreeLargePage(). */ 301 301 VMMR0_DO_GMM_FREE_LARGE_PAGE, 302 /** Call GMMR0QueryVMMMemoryStatsReq */302 /** Call GMMR0QueryVMMMemoryStatsReq(). */ 303 303 VMMR0_DO_GMM_QUERY_VMM_MEM_STATS, 304 304 /** Call GMMR0BalloonedPages(). */ … … 319 319 /** Query a GVMM or GMM configuration value. */ 320 320 VMMR0_DO_GCFGM_QUERY_VALUE, 321 322 /** Call PDMR0DriverCallReqHandler. */ 323 VMMR0_DO_PDM_DRIVER_CALL_REQ_HANDLER, 321 324 322 325 /** The start of the R0 service operations. */ -
trunk/src/VBox/VMM/PDMDriver.cpp
r28330 r28425 1305 1305 1306 1306 1307 /** @interface_method_impl{PDMDRVHLP,pfnCallR0} */ 1308 static DECLCALLBACK(int) pdmR3DrvHlp_CallR0(PPDMDRVINS pDrvIns, uint32_t uOperation, uint64_t u64Arg) 1309 { 1310 PDMDRV_ASSERT_DRVINS(pDrvIns); 1311 PVM pVM = pDrvIns->Internal.s.pVMR3; 1312 LogFlow(("pdmR3DrvHlp_CallR0: caller='%s'/%d: uOperation=%#x u64Arg=%#RX64\n", 1313 pDrvIns->pReg->szName, pDrvIns->iInstance, uOperation, u64Arg)); 1314 1315 /* 1316 * Lazy resolve the ring-0 entry point. 1317 */ 1318 int rc = VINF_SUCCESS; 1319 PFNPDMDRVREQHANDLERR0 pfnReqHandlerR0 = pDrvIns->Internal.s.pfnReqHandlerR0; 1320 if (RT_UNLIKELY(pfnReqHandlerR0 == NIL_RTR0PTR)) 1321 { 1322 if (pDrvIns->pReg->fFlags & PDM_DRVREG_FLAGS_R0) 1323 { 1324 char szSymbol[ sizeof("drvR0") + sizeof(pDrvIns->pReg->szName) + sizeof("ReqHandler")]; 1325 strcat(strcat(strcpy(szSymbol, "drvR0"), pDrvIns->pReg->szName), "ReqHandler"); 1326 rc = PDMR3LdrGetSymbolR0Lazy(pVM, pDrvIns->pReg->szR0Mod, szSymbol, &pfnReqHandlerR0); 1327 if (RT_SUCCESS(rc)) 1328 pDrvIns->Internal.s.pfnReqHandlerR0 = pfnReqHandlerR0; 1329 else 1330 pfnReqHandlerR0 = NIL_RTR0PTR; 1331 } 1332 else 1333 rc = VERR_ACCESS_DENIED; 1334 } 1335 if (RT_LIKELY(pfnReqHandlerR0 != NIL_RTR0PTR)) 1336 { 1337 /* 1338 * Make the ring-0 call. 1339 */ 1340 PDMDRIVERCALLREQHANDLERREQ Req; 1341 Req.Hdr.u32Magic = SUPVMMR0REQHDR_MAGIC; 1342 Req.Hdr.cbReq = sizeof(Req); 1343 Req.pDrvInsR0 = PDMDRVINS_2_R0PTR(pDrvIns); 1344 Req.uOperation = uOperation; 1345 Req.u32Alignment = 0; 1346 Req.u64Arg = u64Arg; 1347 rc = SUPR3CallVMMR0Ex(pVM->pVMR0, NIL_VMCPUID, VMMR0_DO_PDM_DRIVER_CALL_REQ_HANDLER, 0, &Req.Hdr); 1348 } 1349 1350 LogFlow(("pdmR3DrvHlp_CallR0: caller='%s'/%d: returns %Rrc\n", pDrvIns->pReg->szName, 1351 pDrvIns->iInstance, rc)); 1352 return rc; 1353 } 1354 1355 1307 1356 /** 1308 1357 * The driver helper structure. … … 1343 1392 pdmR3DrvHlp_LdrGetR0InterfaceSymbols, 1344 1393 pdmR3DrvHlp_CritSectInit, 1394 pdmR3DrvHlp_CallR0, 1345 1395 PDM_DRVHLPR3_VERSION /* u32TheEnd */ 1346 1396 }; -
trunk/src/VBox/VMM/PDMInternal.h
r28266 r28425 246 246 /** Configuration handle to the instance node. */ 247 247 R3PTRTYPE(PCFGMNODE) pCfgHandle; 248 /** Pointer to the ring-0 request handler function. */ 249 PFNPDMDRVREQHANDLERR0 pfnReqHandlerR0; 248 250 } PDMDRVINSINT; 249 251 -
trunk/src/VBox/VMM/VMMR0/VMMR0.cpp
r28422 r28425 28 28 #include <VBox/trpm.h> 29 29 #include <VBox/cpum.h> 30 #include <VBox/pdmapi.h> 30 31 #include <VBox/pgm.h> 31 32 #include <VBox/stam.h> … … 824 825 /* 825 826 * Attempt to enable hwacc mode and check the current setting. 826 *827 827 */ 828 828 case VMMR0_DO_HWACC_ENABLE: … … 980 980 } 981 981 982 /* 983 * PDM Wrappers. 984 */ 985 case VMMR0_DO_PDM_DRIVER_CALL_REQ_HANDLER: 986 { 987 if (!pVM || !pReqHdr || u64Arg || idCpu != NIL_VMCPUID) 988 return VERR_INVALID_PARAMETER; 989 return PDMR0DriverCallReqHandler(pVM, (PPDMDRIVERCALLREQHANDLERREQ)pReqHdr); 990 } 982 991 983 992 /*
Note:
See TracChangeset
for help on using the changeset viewer.