Changeset 80396 in vbox for trunk/src/VBox/Main
- Timestamp:
- Aug 23, 2019 1:27:22 PM (6 years ago)
- svn:sync-xref-src-repo-rev:
- 132865
- Location:
- trunk/src/VBox/Main
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/Makefile.kmk
r80370 r80396 853 853 $(if $(VBOX_WITH_USB),VBOX_WITH_USB,) \ 854 854 $(if $(VBOX_WITH_VRDEAUTH_IN_VBOXSVC),VBOX_WITH_VRDEAUTH_IN_VBOXSVC,) 855 ifdef VBOX_WITH_CRHGSMI856 VBoxC_DEFS += VBOX_WITH_CRHGSMI857 endif858 855 ifdef VBOX_WITH_NETSHAPER 859 856 VBoxC_DEFS += VBOX_WITH_NETSHAPER -
trunk/src/VBox/Main/include/HGCM.h
r76562 r80396 50 50 int HGCMBroadcastEvent(HGCMNOTIFYEVENT enmEvent); 51 51 52 #ifdef VBOX_WITH_CRHGSMI53 int HGCMHostSvcHandleCreate(const char *pszServiceName, HGCMCVSHANDLE * phSvc);54 int HGCMHostSvcHandleDestroy(HGCMCVSHANDLE hSvc);55 int HGCMHostFastCallAsync(HGCMCVSHANDLE hSvc, uint32_t function, PVBOXHGCMSVCPARM pParm,56 PHGCMHOSTFASTCALLCB pfnCompletion, void *pvCompletion);57 #endif58 59 52 int HGCMHostSaveState(PSSMHANDLE pSSM); 60 53 int HGCMHostLoadState(PSSMHANDLE pSSM, uint32_t uVersion); -
trunk/src/VBox/Main/include/VMMDev.h
r76562 r80396 63 63 int hgcmLoadService (const char *pszServiceLibrary, const char *pszServiceName); 64 64 int hgcmHostCall (const char *pszServiceName, uint32_t u32Function, uint32_t cParms, PVBOXHGCMSVCPARM paParms); 65 # ifdef VBOX_WITH_CRHGSMI66 int hgcmHostSvcHandleCreate (const char *pszServiceName, HGCMCVSHANDLE * phSvc);67 int hgcmHostSvcHandleDestroy (HGCMCVSHANDLE hSvc);68 int hgcmHostFastCallAsync (HGCMCVSHANDLE hSvc, uint32_t function, PVBOXHGCMSVCPARM pParm, PHGCMHOSTFASTCALLCB pfnCompletion, void *pvCompletion);69 # endif70 65 void hgcmShutdown(bool fUvmIsInvalid = false); 71 66 -
trunk/src/VBox/Main/src-client/HGCM.cpp
r78910 r80396 110 110 111 111 uint32_t *m_paClientIds; 112 113 #ifdef VBOX_WITH_CRHGSMI114 uint32_t m_cHandleAcquires;115 #endif116 112 117 113 HGCMSVCEXTHANDLE m_hExtension; … … 180 176 void Notify(HGCMNOTIFYEVENT enmEvent); 181 177 182 #ifdef VBOX_WITH_CRHGSMI183 int HandleAcquired();184 int HandleReleased();185 int HostFastCallAsync(uint32_t u32Function, VBOXHGCMSVCPARM *pParm, PHGCMHOSTFASTCALLCB pfnCompletion,186 void *pvCompletion);187 #endif188 189 178 uint32_t SizeOfClient(void) { return m_fntable.cbClient; }; 190 179 … … 280 269 m_cClientsAllocated (0), 281 270 m_paClientIds (NULL), 282 #ifdef VBOX_WITH_CRHGSMI283 m_cHandleAcquires (0),284 #endif285 271 m_hExtension (NULL), 286 272 m_pUVM (NULL), … … 418 404 #define SVC_MSG_NOTIFY (11) /**< pfnNotify */ 419 405 #define SVC_MSG_GUESTCANCELLED (12) /**< pfnCancelled */ 420 #ifdef VBOX_WITH_CRHGSMI421 # define SVC_MSG_HOSTFASTCALLASYNC (21) /* pfnHostCall */422 #endif423 406 424 407 class HGCMMsgSvcLoad: public HGCMMsgCore … … 553 536 }; 554 537 555 #ifdef VBOX_WITH_CRHGSMI556 class HGCMMsgHostFastCallAsyncSvc: public HGCMMsgCore557 {558 public:559 /* function number */560 uint32_t u32Function;561 /* parameter */562 VBOXHGCMSVCPARM Param;563 /* completion info */564 PHGCMHOSTFASTCALLCB pfnCompletion;565 void *pvCompletion;566 };567 #endif568 569 538 static HGCMMsgCore *hgcmMessageAllocSvc(uint32_t u32MsgId) 570 539 { 571 540 switch (u32MsgId) 572 541 { 573 #ifdef VBOX_WITH_CRHGSMI574 case SVC_MSG_HOSTFASTCALLASYNC: return new HGCMMsgHostFastCallAsyncSvc();575 #endif576 542 case SVC_MSG_LOAD: return new HGCMMsgSvcLoad(); 577 543 case SVC_MSG_UNLOAD: return new HGCMMsgSvcUnload(); … … 622 588 switch (u32MsgId) 623 589 { 624 #ifdef VBOX_WITH_CRHGSMI625 case SVC_MSG_HOSTFASTCALLASYNC:626 {627 HGCMMsgHostFastCallAsyncSvc *pMsg = (HGCMMsgHostFastCallAsyncSvc *)pMsgCore;628 629 LogFlowFunc(("SVC_MSG_HOSTFASTCALLASYNC u32Function = %d, pParm = %p\n", pMsg->u32Function, &pMsg->Param));630 631 rc = pSvc->m_fntable.pfnHostCall(pSvc->m_fntable.pvService, pMsg->u32Function, 1, &pMsg->Param);632 } break;633 #endif634 590 case SVC_MSG_LOAD: 635 591 { … … 1428 1384 } 1429 1385 1430 #ifdef VBOX_WITH_CRHGSMI1431 /** @todo could this actually happen that the service is destroyed on ReleaseService? */1432 HGCMService *pNextSvc = pSvc->m_pSvcNext;1433 while (pSvc->m_cHandleAcquires)1434 {1435 pSvc->HandleReleased();1436 pSvc->ReleaseService();1437 }1438 pSvc = pNextSvc;1439 #else1440 1386 pSvc = pSvc->m_pSvcNext; 1441 #endif1442 1387 } 1443 1388 … … 1941 1886 } 1942 1887 1943 #ifdef VBOX_WITH_CRHGSMI1944 1945 static DECLCALLBACK(int) hgcmMsgFastCallCompletionCallback(int32_t result, HGCMMsgCore *pMsgCore)1946 {1947 /* Call the VMMDev port interface to issue IRQ notification. */1948 LogFlow(("MAIN::hgcmMsgFastCallCompletionCallback: message %p\n", pMsgCore));1949 1950 HGCMMsgHostFastCallAsyncSvc *pMsg = (HGCMMsgHostFastCallAsyncSvc *)pMsgCore;1951 if (pMsg->pfnCompletion)1952 pMsg->pfnCompletion(result, pMsg->u32Function, &pMsg->Param, pMsg->pvCompletion);1953 return VINF_SUCCESS;1954 }1955 1956 int HGCMService::HandleAcquired()1957 {1958 ++m_cHandleAcquires;1959 return VINF_SUCCESS;1960 }1961 1962 int HGCMService::HandleReleased()1963 {1964 Assert(m_cHandleAcquires);1965 if (m_cHandleAcquires)1966 {1967 --m_cHandleAcquires;1968 return VINF_SUCCESS;1969 }1970 return VERR_INVALID_STATE;1971 }1972 1973 int HGCMService::HostFastCallAsync(uint32_t u32Function, VBOXHGCMSVCPARM *pParm, PHGCMHOSTFASTCALLCB pfnCompletion,1974 void *pvCompletion)1975 {1976 LogFlowFunc(("%s u32Function = %d, pParm = %p\n",1977 m_pszSvcName, u32Function, pParm));1978 1979 HGCMMsgCore *pCoreMsg;1980 int rc = hgcmMsgAlloc(m_pThread, &pCoreMsg, SVC_MSG_HOSTFASTCALLASYNC, hgcmMessageAllocSvc);1981 1982 if (RT_SUCCESS(rc))1983 {1984 HGCMMsgHostFastCallAsyncSvc *pMsg = (HGCMMsgHostFastCallAsyncSvc *)pCoreMsg;1985 1986 pMsg->u32Function = u32Function;1987 pMsg->Param = *pParm;1988 pMsg->pfnCompletion = pfnCompletion;1989 pMsg->pvCompletion = pvCompletion;1990 1991 rc = hgcmMsgPost(pMsg, hgcmMsgFastCallCompletionCallback);1992 }1993 1994 LogFlowFunc(("rc = %Rrc\n", rc));1995 return rc;1996 }1997 1998 #endif /* VBOX_WITH_CRHGSMI */1999 2000 1888 /* 2001 1889 * Main HGCM thread that manages services. … … 2014 1902 #define HGCM_MSG_UNREGEXT (19) /**< Unregister a service extension. */ 2015 1903 #define HGCM_MSG_BRD_NOTIFY (20) /**< Broadcast notification event (VM state change). */ 2016 #ifdef VBOX_WITH_CRHGSMI2017 # define HGCM_MSG_SVCAQUIRE (30) /**< Acquire a service handle (for fast host calls) */2018 # define HGCM_MSG_SVCRELEASE (31) /**< Release a service */2019 #endif2020 1904 2021 1905 class HGCMMsgMainConnect: public HGCMMsgHeader … … 2110 1994 HGCMNOTIFYEVENT enmEvent; 2111 1995 }; 2112 2113 #ifdef VBOX_WITH_CRHGSMI2114 class HGCMMsgMainSvcAcquire: public HGCMMsgCore2115 {2116 public:2117 /* Which service to call. */2118 const char *pszServiceName;2119 /* Returned service. */2120 HGCMService *pService;2121 };2122 2123 class HGCMMsgMainSvcRelease: public HGCMMsgCore2124 {2125 public:2126 /* Svc . */2127 HGCMService *pService;2128 };2129 #endif2130 1996 2131 1997 … … 2145 2011 case HGCM_MSG_UNREGEXT: return new HGCMMsgMainUnregisterExtension(); 2146 2012 case HGCM_MSG_BRD_NOTIFY: return new HGCMMsgMainBroadcastNotify(); 2147 #ifdef VBOX_WITH_CRHGSMI2148 case HGCM_MSG_SVCAQUIRE: return new HGCMMsgMainSvcAcquire();2149 case HGCM_MSG_SVCRELEASE: return new HGCMMsgMainSvcRelease();2150 #endif2151 2013 2152 2014 default: … … 2269 2131 HGCMService::BroadcastNotify(pMsg->enmEvent); 2270 2132 } break; 2271 2272 #ifdef VBOX_WITH_CRHGSMI2273 case HGCM_MSG_SVCAQUIRE:2274 {2275 HGCMMsgMainSvcAcquire *pMsg = (HGCMMsgMainSvcAcquire *)pMsgCore;2276 2277 LogFlowFunc(("HGCM_MSG_SVCAQUIRE pszServiceName %s\n", pMsg->pszServiceName));2278 2279 /* Resolve the service name to the pointer to service instance. */2280 HGCMService *pService;2281 rc = HGCMService::ResolveService(&pService, pMsg->pszServiceName);2282 if (RT_SUCCESS(rc))2283 {2284 rc = pService->HandleAcquired();2285 if (RT_SUCCESS(rc))2286 {2287 pMsg->pService = pService;2288 }2289 else2290 {2291 pService->ReleaseService();2292 }2293 }2294 } break;2295 2296 case HGCM_MSG_SVCRELEASE:2297 {2298 HGCMMsgMainSvcRelease *pMsg = (HGCMMsgMainSvcRelease *)pMsgCore;2299 2300 LogFlowFunc(("HGCM_MSG_SVCARELEASE pService %p\n", pMsg->pService));2301 2302 /* Resolve the service name to the pointer to service instance. */2303 2304 rc = pMsg->pService->HandleReleased();2305 if (RT_SUCCESS(rc))2306 {2307 pMsg->pService->ReleaseService();2308 }2309 } break;2310 #endif2311 2133 2312 2134 case HGCM_MSG_RESET: … … 2824 2646 2825 2647 2826 #ifdef VBOX_WITH_CRHGSMI2827 int HGCMHostSvcHandleCreate(const char *pszServiceName, HGCMCVSHANDLE * phSvc)2828 {2829 LogFlowFunc(("name = %s\n", pszServiceName));2830 2831 if (!pszServiceName)2832 {2833 return VERR_INVALID_PARAMETER;2834 }2835 2836 if (!phSvc)2837 {2838 return VERR_INVALID_PARAMETER;2839 }2840 2841 /* Host calls go to main HGCM thread that resolves the service name to the2842 * service instance pointer and then, using the service pointer, forwards2843 * the message to the service thread.2844 * So it is slow but host calls are intended mostly for configuration and2845 * other non-time-critical functions.2846 */2847 HGCMMsgCore *pCoreMsg;2848 int rc = hgcmMsgAlloc(g_pHgcmThread, &pCoreMsg, HGCM_MSG_SVCAQUIRE, hgcmMainMessageAlloc);2849 2850 if (RT_SUCCESS(rc))2851 {2852 HGCMMsgMainSvcAcquire *pMsg = (HGCMMsgMainSvcAcquire *)pCoreMsg;2853 2854 pMsg->pszServiceName = (char *)pszServiceName;2855 pMsg->pService = NULL;2856 2857 pMsg->Reference();2858 2859 rc = hgcmMsgSend(pMsg);2860 if (RT_SUCCESS(rc))2861 {2862 /* for simplicity just use a svc ptr as handle for now */2863 *phSvc = (HGCMCVSHANDLE)pMsg->pService;2864 }2865 pMsg->Dereference();2866 }2867 2868 LogFlowFunc(("rc = %Rrc\n", rc));2869 return rc;2870 }2871 2872 int HGCMHostSvcHandleDestroy(HGCMCVSHANDLE hSvc)2873 {2874 LogFlowFunc(("hSvc = %p\n", hSvc));2875 2876 if (!hSvc)2877 {2878 return VERR_INVALID_PARAMETER;2879 }2880 2881 /* Host calls go to main HGCM thread that resolves the service name to the2882 * service instance pointer and then, using the service pointer, forwards2883 * the message to the service thread.2884 * So it is slow but host calls are intended mostly for configuration and2885 * other non-time-critical functions.2886 */2887 HGCMMsgCore *pCoreMsg;2888 int rc = hgcmMsgAlloc(g_pHgcmThread, &pCoreMsg, HGCM_MSG_SVCRELEASE, hgcmMainMessageAlloc);2889 2890 if (RT_SUCCESS(rc))2891 {2892 HGCMMsgMainSvcRelease *pMsg = (HGCMMsgMainSvcRelease *)pCoreMsg;2893 2894 pMsg->pService = (HGCMService *)hSvc;2895 2896 rc = hgcmMsgSend(pMsg);2897 }2898 2899 LogFlowFunc(("rc = %Rrc\n", rc));2900 return rc;2901 }2902 2903 int HGCMHostFastCallAsync(HGCMCVSHANDLE hSvc, uint32_t function, VBOXHGCMSVCPARM *pParm, PHGCMHOSTFASTCALLCB pfnCompletion,2904 void *pvCompletion)2905 {2906 LogFlowFunc(("hSvc = %p, u32Function = %d, pParm = %p\n",2907 hSvc, function, pParm));2908 2909 if (!hSvc)2910 {2911 return VERR_INVALID_PARAMETER;2912 }2913 2914 HGCMService *pService = (HGCMService *)hSvc;2915 int rc = pService->HostFastCallAsync(function, pParm, pfnCompletion, pvCompletion);2916 2917 LogFlowFunc(("rc = %Rrc\n", rc));2918 return rc;2919 }2920 #endif2921 2922 2648 int HGCMHostReset(bool fForShutdown) 2923 2649 { -
trunk/src/VBox/Main/src-client/VMMDevInterface.cpp
r79263 r80396 754 754 HGCMHostShutdown(fUvmIsInvalid); 755 755 } 756 757 # ifdef VBOX_WITH_CRHGSMI758 int VMMDev::hgcmHostSvcHandleCreate(const char *pszServiceName, HGCMCVSHANDLE * phSvc)759 {760 if (!hgcmIsActive())761 return VERR_INVALID_STATE;762 return HGCMHostSvcHandleCreate(pszServiceName, phSvc);763 }764 765 int VMMDev::hgcmHostSvcHandleDestroy(HGCMCVSHANDLE hSvc)766 {767 if (!hgcmIsActive())768 return VERR_INVALID_STATE;769 return HGCMHostSvcHandleDestroy(hSvc);770 }771 772 int VMMDev::hgcmHostFastCallAsync(HGCMCVSHANDLE hSvc, uint32_t function, PVBOXHGCMSVCPARM pParm,773 PHGCMHOSTFASTCALLCB pfnCompletion, void *pvCompletion)774 {775 if (!hgcmIsActive())776 return VERR_INVALID_STATE;777 return HGCMHostFastCallAsync(hSvc, function, pParm, pfnCompletion, pvCompletion);778 }779 # endif780 756 781 757 #endif /* HGCM */
Note:
See TracChangeset
for help on using the changeset viewer.