Changeset 58178 in vbox
- Timestamp:
- Oct 12, 2015 11:40:57 AM (9 years ago)
- Location:
- trunk
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/VBoxGuestLib.h
r58154 r58178 94 94 # define DECLVBGL(type) DECLR0VBGL(type) 95 95 96 typedef uint32_t VBGLIOPORT; /**< @todo r=bird: We have RTIOPORT (uint16_t) for this. */97 98 96 99 97 # ifdef VBGL_VBOXGUEST … … 105 103 * @return VBox status code. 106 104 */ 107 DECLVBGL(int) VbglInit (VBGLIOPORT portVMMDev, struct VMMDevMemory *pVMMDevMemory);105 DECLVBGL(int) VbglInitPrimary(RTIOPORT portVMMDev, struct VMMDevMemory *pVMMDevMemory); 108 106 109 107 # else … … 115 113 * @return VBox status code. 116 114 */ 117 DECLVBGL(int) VbglInit 115 DECLVBGL(int) VbglInitClient(void); 118 116 119 117 # endif … … 122 120 * The library termination function. 123 121 */ 124 DECLVBGL(void) VbglTerminate 122 DECLVBGL(void) VbglTerminate(void); 125 123 126 124 … … 132 130 * Allocate memory for generic request and initialize the request header. 133 131 * 134 * @param ppReq pointer to resulting memory address. 135 * @param cbSize size of memory block required for the request. 136 * @param reqType the generic request type. 137 * 138 * @return VBox status code. 139 */ 140 DECLVBGL(int) VbglGRAlloc (VMMDevRequestHeader **ppReq, uint32_t cbSize, VMMDevRequestType reqType); 132 * @returns VBox status code. 133 * @param ppReq Where to return the pointer to the allocated memory. 134 * @param cbReq Size of memory block required for the request. 135 * @param enmReqType the generic request type. 136 */ 137 DECLVBGL(int) VbglGRAlloc(VMMDevRequestHeader **ppReq, uint32_t cbReq, VMMDevRequestType enmReqType); 141 138 142 139 /** … … 147 144 * @return VBox status code. 148 145 */ 149 DECLVBGL(int) VbglGRPerform 146 DECLVBGL(int) VbglGRPerform(VMMDevRequestHeader *pReq); 150 147 151 148 /** … … 156 153 * @return VBox status code. 157 154 */ 158 DECLVBGL(void) VbglGRFree 155 DECLVBGL(void) VbglGRFree(VMMDevRequestHeader *pReq); 159 156 160 157 /** … … 168 165 * @return VBox status code. 169 166 */ 170 DECLVBGL(int) VbglGRVerify 167 DECLVBGL(int) VbglGRVerify(const VMMDevRequestHeader *pReq, size_t cbReq); 171 168 /** @} */ 172 169 -
trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPWddm.cpp
r57848 r58178 7462 7462 NTSTATUS Status = STATUS_SUCCESS; 7463 7463 /* Initialize VBoxGuest library, which is used for requests which go through VMMDev. */ 7464 int rc = VbglInit ();7464 int rc = VbglInitClient(); 7465 7465 if (RT_SUCCESS(rc)) 7466 7466 { … … 7592 7592 else 7593 7593 { 7594 WARN(("VbglInit failed, rc(%d)", rc));7594 WARN(("VbglInitClient failed, rc(%d)", rc)); 7595 7595 Status = STATUS_UNSUCCESSFUL; 7596 7596 } -
trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/xpdm/VBoxMPDriver.cpp
r56431 r58178 130 130 131 131 /* Initialize VBoxGuest library, which is used for requests which go through VMMDev. */ 132 rc = VbglInit ();132 rc = VbglInitClient(); 133 133 VBOXMP_WARN_VPS(rc); 134 134 -
trunk/src/VBox/Additions/WINNT/Mouse/NT4/VBoxPS2NT.cpp
r42154 r58178 2137 2137 ASSERT(status == STATUS_SUCCESS); 2138 2138 2139 int rcVBox = VbglInit ();2139 int rcVBox = VbglInitClient(); 2140 2140 if (RT_FAILURE(rcVBox)) 2141 2141 { -
trunk/src/VBox/Additions/WINNT/Mouse/NT5/VBoxMFInternal.cpp
r44529 r58178 333 333 if (!vboxIsVBGLInited() && !vboxIsVBGLInitFailed()) 334 334 { 335 int rc = VbglInit ();335 int rc = VbglInitClient(); 336 336 337 337 if (RT_SUCCESS(rc)) -
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest.cpp
r58089 r58178 1065 1065 * made by the VMM. 1066 1066 */ 1067 rc = VbglInit (pDevExt->IOPortBase, (VMMDevMemory *)pDevExt->pVMMDevMemory);1067 rc = VbglInitPrimary(pDevExt->IOPortBase, (VMMDevMemory *)pDevExt->pVMMDevMemory); 1068 1068 if (RT_SUCCESS(rc)) 1069 1069 { -
trunk/src/VBox/Additions/common/VBoxGuestLib/GenericRequest.cpp
r56294 r58178 31 31 #include <iprt/string.h> 32 32 33 DECLVBGL(int) VbglGRVerify (const VMMDevRequestHeader *pReq, size_t cbReq) 33 34 DECLVBGL(int) VbglGRVerify(const VMMDevRequestHeader *pReq, size_t cbReq) 34 35 { 35 36 size_t cbReqExpected; 36 37 37 if ( !pReq || cbReq < sizeof (VMMDevRequestHeader))38 if (RT_UNLIKELY(!pReq || cbReq < sizeof(VMMDevRequestHeader))) 38 39 { 39 40 dprintf(("VbglGRVerify: Invalid parameter: pReq = %p, cbReq = %zu\n", pReq, cbReq)); … … 41 42 } 42 43 43 if ( pReq->size > cbReq)44 if (RT_UNLIKELY(pReq->size > cbReq)) 44 45 { 45 46 dprintf(("VbglGRVerify: request size %u > buffer size %zu\n", pReq->size, cbReq)); … … 49 50 /* The request size must correspond to the request type. */ 50 51 cbReqExpected = vmmdevGetRequestSize(pReq->requestType); 51 52 if (cbReq < cbReqExpected) 52 if (RT_UNLIKELY(cbReq < cbReqExpected)) 53 53 { 54 54 dprintf(("VbglGRVerify: buffer size %zu < expected size %zu\n", cbReq, cbReqExpected)); … … 58 58 if (cbReqExpected == cbReq) 59 59 { 60 /* This is most likely a fixed size request, and in this case the request size 61 * must be also equal to the expected size. 60 /* 61 * This is most likely a fixed size request, and in this case the 62 * request size must be also equal to the expected size. 62 63 */ 63 if ( pReq->size != cbReqExpected)64 if (RT_UNLIKELY(pReq->size != cbReqExpected)) 64 65 { 65 66 dprintf(("VbglGRVerify: request size %u != expected size %zu\n", pReq->size, cbReqExpected)); … … 82 83 #else 83 84 || pReq->requestType == VMMDevReq_HGCMCall 84 #endif /* VBOX_WITH_64_BITS_GUESTS */85 #endif 85 86 || pReq->requestType == VMMDevReq_RegisterSharedModule 86 87 || pReq->requestType == VMMDevReq_ReportGuestUserState … … 89 90 || pReq->requestType == VMMDevReq_VideoSetVisibleRegion) 90 91 { 91 if ( cbReq > VMMDEV_MAX_VMMDEVREQ_SIZE)92 if (RT_UNLIKELY(cbReq > VMMDEV_MAX_VMMDEVREQ_SIZE)) 92 93 { 93 94 dprintf(("VbglGRVerify: VMMDevReq_LogString: buffer size %zu too big\n", cbReq)); 94 return VERR_BUFFER_OVERFLOW; /* @todo is this error code ok? */95 return VERR_BUFFER_OVERFLOW; /** @todo is this error code ok? */ 95 96 } 96 97 } … … 98 99 { 99 100 dprintf(("VbglGRVerify: request size %u > buffer size %zu\n", pReq->size, cbReq)); 100 return VERR_IO_BAD_LENGTH; /* @todo is this error code ok? */101 return VERR_IO_BAD_LENGTH; /** @todo is this error code ok? */ 101 102 } 102 103 … … 104 105 } 105 106 106 DECLVBGL(int) VbglGRAlloc (VMMDevRequestHeader **ppReq, uint32_t cbSize, VMMDevRequestType reqType)107 DECLVBGL(int) VbglGRAlloc(VMMDevRequestHeader **ppReq, uint32_t cbReq, VMMDevRequestType enmReqType) 107 108 { 108 VMMDevRequestHeader *pReq; 109 int rc = vbglR0Enter (); 109 int rc = vbglR0Enter(); 110 if (RT_SUCCESS(rc)) 111 { 112 if (ppReq && cbReq >= sizeof(VMMDevRequestHeader)) 113 { 114 VMMDevRequestHeader *pReq = (VMMDevRequestHeader *)VbglPhysHeapAlloc(cbReq); 115 AssertMsgReturn(pReq, ("VbglGRAlloc: no memory (cbReq=%u)\n", cbReq), VERR_NO_MEMORY); 116 memset(pReq, 0xAA, cbReq); 110 117 111 if (RT_FAILURE(rc)) 112 return rc; 118 pReq->size = cbReq; 119 pReq->version = VMMDEV_REQUEST_HEADER_VERSION; 120 pReq->requestType = enmReqType; 121 pReq->rc = VERR_GENERAL_FAILURE; 122 pReq->reserved1 = 0; 123 pReq->reserved2 = 0; 113 124 114 if (!ppReq || cbSize < sizeof (VMMDevRequestHeader)) 115 { 116 dprintf(("VbglGRAlloc: Invalid parameter: ppReq = %p, cbSize = %u\n", ppReq, cbSize)); 117 return VERR_INVALID_PARAMETER; 118 } 119 120 pReq = (VMMDevRequestHeader *)VbglPhysHeapAlloc (cbSize); 121 if (!pReq) 122 { 123 AssertMsgFailed(("VbglGRAlloc: no memory\n")); 124 rc = VERR_NO_MEMORY; 125 } 126 else 127 { 128 memset(pReq, 0xAA, cbSize); 129 130 pReq->size = cbSize; 131 pReq->version = VMMDEV_REQUEST_HEADER_VERSION; 132 pReq->requestType = reqType; 133 pReq->rc = VERR_GENERAL_FAILURE; 134 pReq->reserved1 = 0; 135 pReq->reserved2 = 0; 136 137 *ppReq = pReq; 138 } 139 140 return rc; 141 } 142 143 DECLVBGL(int) VbglGRPerform (VMMDevRequestHeader *pReq) 144 { 145 RTCCPHYS physaddr; 146 int rc = vbglR0Enter (); 147 148 if (RT_FAILURE(rc)) 149 return rc; 150 151 if (!pReq) 152 return VERR_INVALID_PARAMETER; 153 154 physaddr = VbglPhysHeapGetPhysAddr (pReq); 155 if ( !physaddr 156 || (physaddr >> 32) != 0) /* Port IO is 32 bit. */ 157 { 158 rc = VERR_VBGL_INVALID_ADDR; 159 } 160 else 161 { 162 ASMOutU32(g_vbgldata.portVMMDev + VMMDEV_PORT_OFF_REQUEST, (uint32_t)physaddr); 163 /* Make the compiler aware that the host has changed memory. */ 164 ASMCompilerBarrier(); 165 rc = pReq->rc; 125 *ppReq = pReq; 126 rc = VINF_SUCCESS; 127 } 128 else 129 { 130 dprintf(("VbglGRAlloc: Invalid parameter: ppReq=%p cbReq=%u\n", ppReq, cbReq)); 131 rc = VERR_INVALID_PARAMETER; 132 } 166 133 } 167 134 return rc; 168 135 } 169 136 170 DECLVBGL( void) VbglGRFree(VMMDevRequestHeader *pReq)137 DECLVBGL(int) VbglGRPerform(VMMDevRequestHeader *pReq) 171 138 { 172 int rc = vbglR0Enter (); 173 174 if (RT_FAILURE(rc)) 175 return; 176 177 VbglPhysHeapFree (pReq); 139 int rc = vbglR0Enter(); 140 if (RT_SUCCESS(rc)) 141 { 142 if (pReq) 143 { 144 RTCCPHYS PhysAddr = VbglPhysHeapGetPhysAddr(pReq); 145 if ( PhysAddr != 0 146 && PhysAddr < _4G) /* Port IO is 32 bit. */ 147 { 148 ASMOutU32(g_vbgldata.portVMMDev + VMMDEV_PORT_OFF_REQUEST, (uint32_t)PhysAddr); 149 /* Make the compiler aware that the host has changed memory. */ 150 ASMCompilerBarrier(); 151 rc = pReq->rc; 152 } 153 else 154 rc = VERR_VBGL_INVALID_ADDR; 155 } 156 else 157 rc = VERR_INVALID_PARAMETER; 158 } 159 return rc; 178 160 } 179 161 162 DECLVBGL(void) VbglGRFree(VMMDevRequestHeader *pReq) 163 { 164 int rc = vbglR0Enter(); 165 if (RT_SUCCESS(rc)) 166 VbglPhysHeapFree(pReq); 167 } 168 -
trunk/src/VBox/Additions/common/VBoxGuestLib/Init.cpp
r57358 r58178 113 113 dprintf (("port = 0x%04X, mem = %p\n", port.portAddress, port.pVMMDevMemory)); 114 114 115 g_vbgldata.portVMMDev = port.portAddress;115 g_vbgldata.portVMMDev = (RTIOPORT)port.portAddress; 116 116 g_vbgldata.pVMMDevMemory = port.pVMMDevMemory; 117 117 … … 187 187 #ifdef VBGL_VBOXGUEST 188 188 189 DECLVBGL(int) VbglInit (VBGLIOPORT portVMMDev, VMMDevMemory *pVMMDevMemory)189 DECLVBGL(int) VbglInitPrimary(RTIOPORT portVMMDev, VMMDevMemory *pVMMDevMemory) 190 190 { 191 191 int rc = VINF_SUCCESS; … … 194 194 dprintf(("vbglInit: starts g_vbgldata.status %d\n", g_vbgldata.status)); 195 195 196 if ( g_vbgldata.status == VbglStatusInitializing196 if ( g_vbgldata.status == VbglStatusInitializing 197 197 || g_vbgldata.status == VbglStatusReady) 198 198 { … … 233 233 #else /* !VBGL_VBOXGUEST */ 234 234 235 DECLVBGL(int) VbglInit 235 DECLVBGL(int) VbglInitClient(void) 236 236 { 237 237 int rc = VINF_SUCCESS; 238 238 239 if ( g_vbgldata.status == VbglStatusInitializing239 if ( g_vbgldata.status == VbglStatusInitializing 240 240 || g_vbgldata.status == VbglStatusReady) 241 241 { -
trunk/src/VBox/Additions/common/VBoxGuestLib/VBGLInternal.h
r56294 r58178 73 73 * Lives in VbglR0Init.cpp. 74 74 */ 75 typedef struct _VBGLDATA75 typedef struct VBGLDATA 76 76 { 77 77 enum VbglLibStatus status; 78 78 79 VBGLIOPORT portVMMDev;79 RTIOPORT portVMMDev; 80 80 81 81 VMMDevMemory *pVMMDevMemory; -
trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR0LibSharedFolders.c
r57358 r58178 65 65 int rc = VINF_SUCCESS; 66 66 67 rc = VbglInit 67 rc = VbglInitClient(); 68 68 return rc; 69 69 } -
trunk/src/VBox/Additions/os2/VBoxSF/VBoxSFInit.cpp
r57358 r58178 64 64 * The caller will do the necessary AttachDD and calling of the 16 bit 65 65 * IDC to initialize the g_VBoxGuestIDC global. Perhaps we should move 66 * this bit to VbglInit ? It's just that it's so much simpler to do it66 * this bit to VbglInitClient? It's just that it's so much simpler to do it 67 67 * while we're on the way here... 68 68 * 69 69 */ 70 DECLASM(void) 71 VBoxSFR0Init(void) 70 DECLASM(void) VBoxSFR0Init(void) 72 71 { 73 72 Log(("VBoxSFR0Init: g_fpfnDevHlp=%lx u32Version=%RX32 u32Session=%RX32 pfnServiceEP=%p g_u32Info=%u (%#x)\n", … … 84 83 if (RT_SUCCESS(rc)) 85 84 { 86 rc = VbglInit ();85 rc = VbglInitClient(); 87 86 if (RT_SUCCESS(rc)) 88 87 { -
trunk/src/VBox/Additions/solaris/Mouse/testcase/solaris.h
r41852 r58178 351 351 #define VbglGRFree(...) do {} while(0) 352 352 #endif 353 #define VbglInit (...) VINF_SUCCESS353 #define VbglInitClient(...) VINF_SUCCESS 354 354 #define vbglDriverOpen(...) VINF_SUCCESS 355 355 #define vbglDriverClose(...) do {} while(0) -
trunk/src/VBox/Additions/solaris/Mouse/vboxms.c
r57605 r58178 471 471 * init, and create a new session. 472 472 */ 473 rc = VbglInit ();473 rc = VbglInitClient(); 474 474 if (RT_SUCCESS(rc)) 475 475 {
Note:
See TracChangeset
for help on using the changeset viewer.