Changeset 29521 in vbox
- Timestamp:
- May 17, 2010 10:14:22 AM (15 years ago)
- Location:
- trunk
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/pdmapi.h
r28801 r29521 8 8 9 9 /* 10 * Copyright (C) 2006-20 07Oracle Corporation10 * Copyright (C) 2006-2010 Oracle Corporation 11 11 * 12 12 * This file is part of VirtualBox Open Source Edition (OSE), as … … 33 33 #include <VBox/types.h> 34 34 #include <VBox/sup.h> 35 #include <VBox/pdmcommon.h> 35 36 36 37 RT_C_DECLS_BEGIN … … 167 168 VMMR0_INT_DECL(int) PDMR0DriverCallReqHandler(PVM pVM, PPDMDRIVERCALLREQHANDLERREQ pReq); 168 169 170 /** 171 * Request buffer for PDMR0DeviceCallReqHandler / VMMR0_DO_PDM_DEVICE_CALL_REQ_HANDLER. 172 * @see PDMR0DeviceCallReqHandler. 173 */ 174 typedef struct PDMDEVICECALLREQHANDLERREQ 175 { 176 /** The header. */ 177 SUPVMMR0REQHDR Hdr; 178 /** The device instance. */ 179 PPDMDEVINSR0 pDevInsR0; 180 /** The request handler for the device. */ 181 PFNPDMDEVREQHANDLERR0 pfnReqHandlerR0; 182 /** The operation. */ 183 uint32_t uOperation; 184 /** Explicit alignment padding. */ 185 uint32_t u32Alignment; 186 /** Optional 64-bit integer argument. */ 187 uint64_t u64Arg; 188 } PDMDEVICECALLREQHANDLERREQ; 189 /** Pointer to a PDMR0DeviceCallReqHandler / 190 * VMMR0_DO_PDM_DEVICE_CALL_REQ_HANDLER request buffer. */ 191 typedef PDMDEVICECALLREQHANDLERREQ *PPDMDEVICECALLREQHANDLERREQ; 192 193 VMMR0_INT_DECL(int) PDMR0DeviceCallReqHandler(PVM pVM, PPDMDEVICECALLREQHANDLERREQ pReq); 194 169 195 /** @} */ 170 196 -
trunk/include/VBox/pdmcommon.h
r28800 r29521 4 4 5 5 /* 6 * Copyright (C) 2006-20 07Oracle Corporation6 * Copyright (C) 2006-2010 Oracle Corporation 7 7 * 8 8 * This file is part of VirtualBox Open Source Edition (OSE), as … … 132 132 typedef FNPDMDRVASYNCNOTIFY *PFNPDMDRVASYNCNOTIFY; 133 133 134 134 135 /** 135 * The ring-0 driver request handle. 136 * The ring-0 driver request handler. 137 * 138 * @returns VBox status code. PDMDevHlpCallR0 will return this. 139 * @param pDevIns The device instance (the ring-0 mapping). 140 * @param uOperation The operation. 141 * @param u64Arg Optional integer argument for the operation. 142 */ 143 typedef DECLCALLBACK(int) FNPDMDEVREQHANDLERR0(PPDMDEVINS pDevIns, uint32_t uOperation, uint64_t u64Arg); 144 /** Ring-0 pointer to a FNPDMDEVREQHANDLERR0. */ 145 typedef R0PTRTYPE(FNPDMDEVREQHANDLERR0 *) PFNPDMDEVREQHANDLERR0; 146 147 /** 148 * The ring-0 driver request handler. 136 149 * 137 150 * @returns VBox status code. PDMDrvHlpCallR0 will return this. … … 144 157 typedef R0PTRTYPE(FNPDMDRVREQHANDLERR0 *) PFNPDMDRVREQHANDLERR0; 145 158 159 146 160 /** @} */ 147 161 -
trunk/include/VBox/pdmdev.h
r28800 r29521 2995 2995 const char *pszSymPrefix, const char *pszSymList)); 2996 2996 2997 /** 2998 * Call the ring-0 request handler routine of the device. 2999 * 3000 * For this to work, the device must be ring-0 enabled and export a request 3001 * handler function. The name of the function must be the device name in 3002 * the PDMDRVREG struct prefixed with 'drvR0' and suffixed with 3003 * 'ReqHandler'. The device name will be captialized. It shall take the 3004 * exact same arguments as this function and be declared using 3005 * PDMBOTHCBDECL. See FNPDMDEVREQHANDLERR0. 3006 * 3007 * Unlike PDMDrvHlpCallR0, this is current unsuitable for more than a call 3008 * or two as the handler address will be resolved on each invocation. This 3009 * is the reason for the EMT only restriction as well. 3010 * 3011 * @returns VBox status code. 3012 * @retval VERR_SYMBOL_NOT_FOUND if the device doesn't export the required 3013 * handler function. 3014 * @retval VERR_ACCESS_DENIED if the device isn't ring-0 capable. 3015 * 3016 * @param pDevIns The device instance. 3017 * @param uOperation The operation to perform. 3018 * @param u64Arg 64-bit integer argument. 3019 * @thread EMT 3020 */ 3021 DECLR3CALLBACKMEMBER(int, pfnCallR0,(PPDMDEVINS pDevIns, uint32_t uOperation, uint64_t u64Arg)); 3022 2997 3023 /** Space reserved for future members. 2998 3024 * @{ */ … … 3564 3590 || !PDM_VERSION_ARE_COMPATIBLE((pDevIns)->pHlpR3->u32Version, PDM_DEVHLPR3_VERSION) )) \ 3565 3591 return VERR_VERSION_MISMATCH; \ 3592 } while (0) 3593 3594 /** 3595 * Wrapper around CFGMR3ValidateConfig for the root config for use in the 3596 * constructor - returns on failure. 3597 * 3598 * This should be invoked after having initialized the instance data 3599 * sufficiently for the correct operation of the destructor. The destructor is 3600 * always called! 3601 * 3602 * @param pDevIns Pointer to the PDM device instance. 3603 * @param pszValidValues Patterns describing the valid value names. See 3604 * RTStrSimplePatternMultiMatch for details on the 3605 * pattern syntax. 3606 * @param pszValidNodes Patterns describing the valid node (key) names. 3607 * Pass empty string if no valid nodess. 3608 */ 3609 #define PDMDEV_VALIDATE_CONFIG_RETURN(pDevIns, pszValidValues, pszValidNodes) \ 3610 do \ 3611 { \ 3612 int rcValCfg = CFGMR3ValidateConfig((pDevIns)->pCfg, "/", pszValidValues, pszValidNodes, \ 3613 (pDevIns)->pReg->szName, (pDevIns)->iInstance); \ 3614 if (RT_FAILURE(rcValCfg)) \ 3615 return rcValCfg; \ 3566 3616 } while (0) 3567 3617 … … 4289 4339 } 4290 4340 4341 /** 4342 * @copydoc PDMDEVHLP::pfnCallR0 4343 */ 4344 DECLINLINE(int) PDMDevHlpCallR0(PPDMDEVINS pDevIns, uint32_t uOperation, uint64_t u64Arg) 4345 { 4346 return pDevIns->pHlpR3->pfnCallR0(pDevIns, uOperation, u64Arg); 4347 } 4348 4291 4349 #endif /* IN_RING3 */ 4292 4350 -
trunk/include/VBox/pdmdrv.h
r28800 r29521 1162 1162 * 1163 1163 * @returns VBox status code. 1164 * @param pD evIns The deviceinstance.1164 * @param pDrvIns The driver instance. 1165 1165 * @param pCritSect Pointer to the critical section. 1166 1166 * @param RT_SRC_POS_DECL Use RT_SRC_POS. … … 1179 1179 * For this to work, the driver must be ring-0 enabled and export a request 1180 1180 * handler function. The name of the function must be the driver name in the 1181 * PDMDRVREG struct prefixed with 'drvR0' and suffixed with 'ReqHandler'. It 1182 * shall take the exact same arguments as this function and be declared using 1183 * PDMBOTHCBDECL. See FNPDMDRVREQHANDLERR0. 1181 * PDMDRVREG struct prefixed with 'drvR0' and suffixed with 'ReqHandler'. 1182 * The driver name will be capitalized. It shall take the exact same 1183 * arguments as this function and be declared using PDMBOTHCBDECL. See 1184 * FNPDMDRVREQHANDLERR0. 1184 1185 * 1185 1186 * @returns VBox status code. … … 1188 1189 * @retval VERR_ACCESS_DENIED if the driver isn't ring-0 capable. 1189 1190 * 1190 * @param pD evIns The deviceinstance.1191 * @param pDrvIns The driver instance. 1191 1192 * @param uOperation The operation to perform. 1192 1193 * @param u64Arg 64-bit integer argument. -
trunk/include/VBox/vmm.h
r29424 r29521 4 4 5 5 /* 6 * Copyright (C) 2006-20 07Oracle Corporation6 * Copyright (C) 2006-2010 Oracle Corporation 7 7 * 8 8 * This file is part of VirtualBox Open Source Edition (OSE), as … … 322 322 /** Call PDMR0DriverCallReqHandler. */ 323 323 VMMR0_DO_PDM_DRIVER_CALL_REQ_HANDLER, 324 /** Call PDMR0DeviceCallReqHandler. */ 325 VMMR0_DO_PDM_DEVICE_CALL_REQ_HANDLER, 324 326 325 327 /** The start of the R0 service operations. */ -
trunk/src/VBox/VMM/PDMDevHlp.cpp
r28800 r29521 36 36 #include <iprt/asm.h> 37 37 #include <iprt/assert.h> 38 #include <iprt/ctype.h> 38 39 #include <iprt/string.h> 39 40 #include <iprt/thread.h> … … 1847 1848 1848 1849 LogFlow(("pdmR3DevHlp_PDMLdrGetR0InterfaceSymbols: caller='%s'/%d: returns %Rrc\n", pDevIns->pReg->szName, 1850 pDevIns->iInstance, rc)); 1851 return rc; 1852 } 1853 1854 1855 /** @interface_method_impl{PDMDEVHLP,pfnCallR0} */ 1856 static DECLCALLBACK(int) pdmR3DevHlp_CallR0(PPDMDEVINS pDevIns, uint32_t uOperation, uint64_t u64Arg) 1857 { 1858 PDMDEV_ASSERT_DEVINS(pDevIns); 1859 PVM pVM = pDevIns->Internal.s.pVMR3; 1860 VM_ASSERT_EMT(pDevIns->Internal.s.pVMR3); 1861 LogFlow(("pdmR3DevHlp_CallR0: caller='%s'/%d: uOperation=%#x u64Arg=%#RX64\n", 1862 pDevIns->pReg->szName, pDevIns->iInstance, uOperation, u64Arg)); 1863 1864 /* 1865 * Resolve the ring-0 entry point. There is not need to remember this like 1866 * we do for drivers since this is mainly for construction time hacks and 1867 * other things that aren't performance critical. 1868 */ 1869 int rc; 1870 if (pDevIns->pReg->fFlags & PDM_DEVREG_FLAGS_R0) 1871 { 1872 char szSymbol[ sizeof("devR0") + sizeof(pDevIns->pReg->szName) + sizeof("ReqHandler")]; 1873 strcat(strcat(strcpy(szSymbol, "devR0"), pDevIns->pReg->szName), "ReqHandler"); 1874 szSymbol[sizeof("devR0") - 1] = RT_C_TO_UPPER(szSymbol[sizeof("devR0") - 1]); 1875 1876 PFNPDMDRVREQHANDLERR0 pfnReqHandlerR0; 1877 rc = PDMR3LdrGetSymbolR0Lazy(pVM, pDevIns->pReg->szR0Mod, szSymbol, &pfnReqHandlerR0); 1878 if (RT_SUCCESS(rc)) 1879 { 1880 /* 1881 * Make the ring-0 call. 1882 */ 1883 PDMDEVICECALLREQHANDLERREQ Req; 1884 Req.Hdr.u32Magic = SUPVMMR0REQHDR_MAGIC; 1885 Req.Hdr.cbReq = sizeof(Req); 1886 Req.pDevInsR0 = PDMDEVINS_2_R0PTR(pDevIns); 1887 Req.pfnReqHandlerR0 = pfnReqHandlerR0; 1888 Req.uOperation = uOperation; 1889 Req.u32Alignment = 0; 1890 Req.u64Arg = u64Arg; 1891 rc = SUPR3CallVMMR0Ex(pVM->pVMR0, NIL_VMCPUID, VMMR0_DO_PDM_DEVICE_CALL_REQ_HANDLER, 0, &Req.Hdr); 1892 } 1893 else 1894 pfnReqHandlerR0 = NIL_RTR0PTR; 1895 } 1896 else 1897 rc = VERR_ACCESS_DENIED; 1898 LogFlow(("pdmR3DevHlp_CallR0: caller='%s'/%d: returns %Rrc\n", pDevIns->pReg->szName, 1849 1899 pDevIns->iInstance, rc)); 1850 1900 return rc; … … 2928 2978 pdmR3DevHlp_LdrGetRCInterfaceSymbols, 2929 2979 pdmR3DevHlp_LdrGetR0InterfaceSymbols, 2980 pdmR3DevHlp_CallR0, 2930 2981 0, 2931 2982 0, … … 3123 3174 pdmR3DevHlp_LdrGetRCInterfaceSymbols, 3124 3175 pdmR3DevHlp_LdrGetR0InterfaceSymbols, 3176 pdmR3DevHlp_CallR0, 3125 3177 0, 3126 3178 0, -
trunk/src/VBox/VMM/PDMDriver.cpp
r28853 r29521 33 33 #include <VBox/log.h> 34 34 #include <iprt/assert.h> 35 #include <iprt/asm.h> 36 #include <iprt/ctype.h> 37 #include <iprt/mem.h> 35 38 #include <iprt/thread.h> 39 #include <iprt/path.h> 36 40 #include <iprt/string.h> 37 #include <iprt/asm.h>38 #include <iprt/alloc.h>39 #include <iprt/path.h>40 41 41 42 … … 1319 1320 char szSymbol[ sizeof("drvR0") + sizeof(pDrvIns->pReg->szName) + sizeof("ReqHandler")]; 1320 1321 strcat(strcat(strcpy(szSymbol, "drvR0"), pDrvIns->pReg->szName), "ReqHandler"); 1322 szSymbol[sizeof("drvR0") - 1] = RT_C_TO_UPPER(szSymbol[sizeof("drvR0") - 1]); 1323 1321 1324 rc = PDMR3LdrGetSymbolR0Lazy(pVM, pDrvIns->pReg->szR0Mod, szSymbol, &pfnReqHandlerR0); 1322 1325 if (RT_SUCCESS(rc)) -
trunk/src/VBox/VMM/PDMInternal.h
r28800 r29521 5 5 6 6 /* 7 * Copyright (C) 2006-20 07Oracle Corporation7 * Copyright (C) 2006-2010 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as -
trunk/src/VBox/VMM/VMMR0/PDMR0Device.cpp
r28800 r29521 718 718 719 719 /** 720 * The R aw-ModeContext Driver Helper Callbacks.720 * The Ring-0 Context Driver Helper Callbacks. 721 721 */ 722 722 extern DECLEXPORT(const PDMDRVHLPR0) g_pdmR0DrvHlp = … … 809 809 } 810 810 } 811 812 813 /** 814 * PDMDevHlpCallR0 helper. 815 * 816 * @returns See PFNPDMDEVREQHANDLERR0. 817 * @param pVM The VM handle (for validation). 818 * @param pReq The request buffer. 819 */ 820 VMMR0_INT_DECL(int) PDMR0DeviceCallReqHandler(PVM pVM, PPDMDEVICECALLREQHANDLERREQ pReq) 821 { 822 /* 823 * Validate input and make the call. 824 */ 825 AssertPtrReturn(pVM, VERR_INVALID_POINTER); 826 AssertPtrReturn(pReq, VERR_INVALID_POINTER); 827 AssertMsgReturn(pReq->Hdr.cbReq == sizeof(*pReq), ("%#x != %#x\n", pReq->Hdr.cbReq, sizeof(*pReq)), VERR_INVALID_PARAMETER); 828 829 PPDMDEVINS pDevIns = pReq->pDevInsR0; 830 AssertPtrReturn(pDevIns, VERR_INVALID_POINTER); 831 AssertReturn(pDevIns->Internal.s.pVMR0 == pVM, VERR_INVALID_PARAMETER); 832 833 PFNPDMDEVREQHANDLERR0 pfnReqHandlerR0 = pReq->pfnReqHandlerR0; 834 AssertPtrReturn(pfnReqHandlerR0, VERR_INVALID_POINTER); 835 836 return pfnReqHandlerR0(pDevIns, pReq->uOperation, pReq->u64Arg); 837 } 838 -
trunk/src/VBox/VMM/VMMR0/VMMR0.cpp
r29458 r29521 5 5 6 6 /* 7 * Copyright (C) 2006-20 07Oracle Corporation7 * Copyright (C) 2006-2010 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 1015 1015 } 1016 1016 1017 case VMMR0_DO_PDM_DEVICE_CALL_REQ_HANDLER: 1018 { 1019 if (!pVM || !pReqHdr || u64Arg || idCpu != NIL_VMCPUID) 1020 return VERR_INVALID_PARAMETER; 1021 return PDMR0DeviceCallReqHandler(pVM, (PPDMDEVICECALLREQHANDLERREQ)pReqHdr); 1022 } 1023 1017 1024 /* 1018 1025 * Requests to the internal networking service.
Note:
See TracChangeset
for help on using the changeset viewer.