- Timestamp:
- Oct 8, 2015 10:13:54 AM (9 years ago)
- Location:
- trunk
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/log.h
r58111 r58113 745 745 LOG_GROUP_USB_WEBCAM, 746 746 /** VBox Guest Additions Driver (VBoxGuest). */ 747 LOG_GROUP_V BGD,747 LOG_GROUP_VGDRV, 748 748 /** VBox Guest Additions Library. */ 749 749 LOG_GROUP_VBGL, … … 1145 1145 "USB_REMOTE", \ 1146 1146 "USB_WEBCAM", \ 1147 "V BGD",\1147 "VGDRV", \ 1148 1148 "VBGL", \ 1149 1149 "VD", \ -
trunk/src/VBox/Additions/common/VBoxGuest/VBoxDev-haiku.c
r58053 r58113 72 72 73 73 /********************************************************************************************************************************* 74 * Internal Functions*74 * Global Variables * 75 75 *********************************************************************************************************************************/ 76 static status_t VBoxGuestHaikuOpen(const char *name, uint32 flags, void **cookie); 77 static status_t VBoxGuestHaikuClose(void *cookie); 78 static status_t VBoxGuestHaikuFree(void *cookie); 79 static status_t VBoxGuestHaikuIOCtl(void *cookie, uint32 op, void *data, size_t len); 80 static status_t VBoxGuestHaikuSelect(void *cookie, uint8 event, uint32 ref, selectsync *sync); 81 static status_t VBoxGuestHaikuDeselect(void *cookie, uint8 event, selectsync *sync); 82 static status_t VBoxGuestHaikuWrite(void *cookie, off_t position, const void *data, size_t *numBytes); 83 static status_t VBoxGuestHaikuRead(void *cookie, off_t position, void *data, size_t *numBytes); 84 85 static device_hooks g_VBoxGuestHaikuDeviceHooks = 86 { 87 VBoxGuestHaikuOpen, 88 VBoxGuestHaikuClose, 89 VBoxGuestHaikuFree, 90 VBoxGuestHaikuIOCtl, 91 VBoxGuestHaikuRead, 92 VBoxGuestHaikuWrite, 93 VBoxGuestHaikuSelect, 94 VBoxGuestHaikuDeselect, 95 }; 76 int32 api_version = B_CUR_DRIVER_API_VERSION; 96 77 97 78 … … 105 86 * @return Haiku status code. 106 87 */ 107 static status_t VBoxGuestHaikuOpen(const char *name, uint32 flags, void **cookie)88 static status_t vgdrvHaikuOpen(const char *name, uint32 flags, void **cookie) 108 89 { 109 90 int rc; 110 91 PVBOXGUESTSESSION pSession; 111 92 112 LogFlow((DRIVER_NAME ": VBoxGuestHaikuOpen\n"));93 LogFlow((DRIVER_NAME ":vgdrvHaikuOpen\n")); 113 94 114 95 /* … … 118 99 if (RT_SUCCESS(rc)) 119 100 { 120 Log((DRIVER_NAME ": VBoxGuestHaikuOpen success: g_DevExt=%p pSession=%p rc=%d pid=%d\n",&g_DevExt, pSession, rc,(int)RTProcSelf()));101 Log((DRIVER_NAME ":vgdrvHaikuOpen success: g_DevExt=%p pSession=%p rc=%d pid=%d\n",&g_DevExt, pSession, rc,(int)RTProcSelf())); 121 102 ASMAtomicIncU32(&cUsers); 122 103 *cookie = pSession; … … 124 105 } 125 106 126 LogRel((DRIVER_NAME ": VBoxGuestHaikuOpen: failed. rc=%d\n", rc));107 LogRel((DRIVER_NAME ":vgdrvHaikuOpen: failed. rc=%d\n", rc)); 127 108 return RTErrConvertToErrno(rc); 128 109 } … … 135 116 * @return Haiku status code. 136 117 */ 137 static status_t VBoxGuestHaikuClose(void *cookie)138 { 139 PVBOXGUESTSESSION pSession = (PVBOXGUESTSESSION)cookie; 140 Log((" VBoxGuestHaikuClose: pSession=%p\n", pSession));118 static status_t vgdrvHaikuClose(void *cookie) 119 { 120 PVBOXGUESTSESSION pSession = (PVBOXGUESTSESSION)cookie; 121 Log(("vgdrvHaikuClose: pSession=%p\n", pSession)); 141 122 142 123 /** @todo r=ramshankar: should we really be using the session spinlock here? */ … … 164 145 * @return Haiku status code. 165 146 */ 166 static status_t VBoxGuestHaikuFree(void *cookie)167 { 168 PVBOXGUESTSESSION pSession = (PVBOXGUESTSESSION)cookie; 169 Log((" VBoxGuestHaikuFree: pSession=%p\n", pSession));147 static status_t vgdrvHaikuFree(void *cookie) 148 { 149 PVBOXGUESTSESSION pSession = (PVBOXGUESTSESSION)cookie; 150 Log(("vgdrvHaikuFree: pSession=%p\n", pSession)); 170 151 171 152 /* … … 178 159 } 179 160 else 180 Log((" VBoxGuestHaikuFree: si_drv1=%p!\n", pSession));161 Log(("vgdrvHaikuFree: si_drv1=%p!\n", pSession)); 181 162 return B_OK; 182 163 } … … 192 173 * @return Haiku status code. 193 174 */ 194 static status_t VBoxGuestHaikuIOCtl(void *cookie, uint32 op, void *data, size_t len) 195 { 196 PVBOXGUESTSESSION pSession = (PVBOXGUESTSESSION)cookie; 197 Log((DRIVER_NAME ":VBoxGuestHaikuIOCtl cookie=%p op=0x%08x data=%p len=%lu)\n", cookie, op, data, len)); 198 199 int rc = B_OK; 175 static status_t vgdrvHaikuIOCtl(void *cookie, uint32 op, void *data, size_t len) 176 { 177 PVBOXGUESTSESSION pSession = (PVBOXGUESTSESSION)cookie; 178 int rc; 179 Log(("vgdrvHaikuIOCtl: cookie=%p op=0x%08x data=%p len=%lu)\n", cookie, op, data, len)); 200 180 201 181 /* … … 211 191 if (IOCPARM_LEN(ulCmd) != sizeof(VBGLBIGREQ)) 212 192 { 213 Log((DRIVER_NAME ": VBoxGuestHaikuIOCtl: bad request %lu size=%lu expected=%d\n", ulCmd, IOCPARM_LEN(ulCmd),193 Log((DRIVER_NAME ": vgdrvHaikuIOCtl: bad request %lu size=%lu expected=%d\n", ulCmd, IOCPARM_LEN(ulCmd), 214 194 sizeof(VBGLBIGREQ))); 215 195 return ENOTTY; … … 219 199 if (RT_UNLIKELY(len > _1M * 16)) 220 200 { 221 dprintf(DRIVER_NAME ": VBoxGuestHaikuIOCtl: bad size %#x; pArg=%p Cmd=%lu.\n", (unsigned)len, data, op);201 dprintf(DRIVER_NAME ": vgdrvHaikuIOCtl: bad size %#x; pArg=%p Cmd=%lu.\n", (unsigned)len, data, op); 222 202 return EINVAL; 223 203 } … … 232 212 if (RT_UNLIKELY(!pvBuf)) 233 213 { 234 LogRel((DRIVER_NAME ": VBoxGuestHaikuIOCtl: RTMemTmpAlloc failed to alloc %d bytes.\n", len));214 LogRel((DRIVER_NAME ":vgdrvHaikuIOCtl: RTMemTmpAlloc failed to alloc %d bytes.\n", len)); 235 215 return ENOMEM; 236 216 } … … 241 221 { 242 222 RTMemTmpFree(pvBuf); 243 LogRel((DRIVER_NAME ": VBoxGuestHaikuIOCtl: user_memcpy failed; pvBuf=%p data=%p op=%d. rc=%d\n", pvBuf, data, op, rc));223 LogRel((DRIVER_NAME ":vgdrvHaikuIOCtl: user_memcpy failed; pvBuf=%p data=%p op=%d. rc=%d\n", pvBuf, data, op, rc)); 244 224 return EFAULT; 245 225 } … … 247 227 { 248 228 RTMemTmpFree(pvBuf); 249 LogRel((DRIVER_NAME ": VBoxGuestHaikuIOCtl: pvBuf invalid pointer %p\n", pvBuf));229 LogRel((DRIVER_NAME ":vgdrvHaikuIOCtl: pvBuf invalid pointer %p\n", pvBuf)); 250 230 return EINVAL; 251 231 } 252 232 } 253 Log(( DRIVER_NAME ":VBoxGuestHaikuIOCtl: pSession=%p pid=%d.\n", pSession,(int)RTProcSelf()));233 Log(("vgdrvHaikuIOCtl: pSession=%p pid=%d.\n", pSession,(int)RTProcSelf())); 254 234 255 235 /* … … 263 243 if (RT_UNLIKELY(cbDataReturned > len)) 264 244 { 265 Log(( DRIVER_NAME ":VBoxGuestHaikuIOCtl: too much output data %d expected %d\n", cbDataReturned, len));245 Log(("vgdrvHaikuIOCtl: too much output data %d expected %d\n", cbDataReturned, len)); 266 246 cbDataReturned = len; 267 247 } … … 271 251 if (RT_UNLIKELY(rc < 0)) 272 252 { 273 Log(( DRIVER_NAME ":VBoxGuestHaikuIOCtl: user_memcpy failed; pvBuf=%p pArg=%p Cmd=%lu. rc=%d\n", pvBuf, data, op, rc));253 Log(("vgdrvHaikuIOCtl: user_memcpy failed; pvBuf=%p pArg=%p Cmd=%lu. rc=%d\n", pvBuf, data, op, rc)); 274 254 rc = EFAULT; 275 255 } … … 278 258 else 279 259 { 280 Log(( DRIVER_NAME ":VBoxGuestHaikuIOCtl: VbgdCommonIoCtl failed. rc=%d\n", rc));260 Log(("vgdrvHaikuIOCtl: VGDrvCommonIoCtl failed. rc=%d\n", rc)); 281 261 rc = EFAULT; 282 262 } … … 296 276 * @return Haiku status code. 297 277 */ 298 static status_t VBoxGuestHaikuSelect(void *cookie, uint8 event, uint32 ref, selectsync *sync)278 static status_t vgdrvHaikuSelect(void *cookie, uint8 event, uint32 ref, selectsync *sync) 299 279 { 300 280 PVBOXGUESTSESSION pSession = (PVBOXGUESTSESSION)cookie; … … 340 320 * @return Haiku status code. 341 321 */ 342 static status_t VBoxGuestHaikuDeselect(void *cookie, uint8 event, selectsync *sync)322 static status_t vgdrvHaikuDeselect(void *cookie, uint8 event, selectsync *sync) 343 323 { 344 324 PVBOXGUESTSESSION pSession = (PVBOXGUESTSESSION)cookie; … … 372 352 * @return Haiku status code. 373 353 */ 374 static status_t VBoxGuestHaikuWrite(void *cookie, off_t position, const void *data, size_t *numBytes)354 static status_t vgdrvHaikuWrite(void *cookie, off_t position, const void *data, size_t *numBytes) 375 355 { 376 356 *numBytes = 0; … … 388 368 * @return Haiku status code. 389 369 */ 390 static status_t VBoxGuestHaikuRead(void *cookie, off_t position, void *data, size_t *numBytes)370 static status_t vgdrvHaikuRead(void *cookie, off_t position, void *data, size_t *numBytes) 391 371 { 392 372 PVBOXGUESTSESSION pSession = (PVBOXGUESTSESSION)cookie; … … 408 388 409 389 410 int32 api_version = B_CUR_DRIVER_API_VERSION;411 390 412 391 status_t init_hardware() … … 420 399 } 421 400 422 device_hooks *find_device(const char *name)423 { 424 static device_hooks g_VBoxGuestHaikuDeviceHooks =425 { 426 VBoxGuestHaikuOpen,427 VBoxGuestHaikuClose,428 VBoxGuestHaikuFree,429 VBoxGuestHaikuIOCtl,430 VBoxGuestHaikuRead,431 VBoxGuestHaikuWrite,432 VBoxGuestHaikuSelect,433 VBoxGuestHaikuDeselect401 device_hooks *find_device(const char *name) 402 { 403 static device_hooks s_vgdrvHaikuDeviceHooks = 404 { 405 vgdrvHaikuOpen, 406 vgdrvHaikuClose, 407 vgdrvHaikuFree, 408 vgdrvHaikuIOCtl, 409 vgdrvHaikuRead, 410 vgdrvHaikuWrite, 411 vgdrvHaikuSelect, 412 vgdrvHaikuDeselect, 434 413 }; 435 return & g_VBoxGuestHaikuDeviceHooks;436 } 437 438 const char **publish_devices()439 { 440 static const char * devices[] = { DEVICE_NAME, NULL };441 return devices;414 return &s_vgdrvHaikuDeviceHooks; 415 } 416 417 const char **publish_devices() 418 { 419 static const char *s_papszDevices[] = { DEVICE_NAME, NULL }; 420 return s_papszDevices; 442 421 } 443 422 -
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-darwin.cpp
r58053 r58113 20 20 * Header Files * 21 21 *********************************************************************************************************************************/ 22 #define LOG_GROUP LOG_GROUP_V BGD22 #define LOG_GROUP LOG_GROUP_VGDRV 23 23 /* 24 24 * Deal with conflicts first. … … 71 71 72 72 73 /** PINFO() - always does printf(). */74 #define PINFO(fmt, args...) \75 printf(fmt "\n", ## args)76 77 /** PDEBUG() - does printf() with extra debug data on DEBUG build and keep silence on a release one. */78 #if DEBUG79 # define MODULE_NAME "VBoxGuest"80 # define PDEBUG(fmt, args...) \81 do { \82 printf(MODULE_NAME ": DEBUG: %s:%d %s(): " fmt "\n", __FILE__, __LINE__, __FUNCTION__, ## args); \83 } while (0)84 #else85 # define PDEBUG(fmt, args...) do {} while (0)86 #endif87 88 89 73 /********************************************************************************************************************************* 90 74 * Internal Functions * 91 75 *********************************************************************************************************************************/ 92 76 RT_C_DECLS_BEGIN 93 static kern_return_t VbgdDarwinStart(struct kmod_info *pKModInfo, void *pvData);94 static kern_return_t VbgdDarwinStop(struct kmod_info *pKModInfo, void *pvData);95 static int VbgdDarwinCharDevRemove(void);96 97 static int VbgdDarwinOpen(dev_t Dev, int fFlags, int fDevType, struct proc *pProcess);98 static int VbgdDarwinClose(dev_t Dev, int fFlags, int fDevType, struct proc *pProcess);99 static int VbgdDarwinIOCtlSlow(PVBOXGUESTSESSION pSession, u_long iCmd, caddr_t pData, struct proc *pProcess);100 static int VbgdDarwinIOCtl(dev_t Dev, u_long iCmd, caddr_t pData, int fFlags, struct proc *pProcess);101 102 static int VbgdDarwinErr2DarwinErr(int rc);103 104 static IOReturn VbgdDarwinSleepHandler(void *pvTarget, void *pvRefCon, UInt32 uMessageType, IOService *pProvider, void *pvMessageArgument, vm_size_t argSize);77 static kern_return_t vgdrvDarwinStart(struct kmod_info *pKModInfo, void *pvData); 78 static kern_return_t vgdrvDarwinStop(struct kmod_info *pKModInfo, void *pvData); 79 static int vgdrvDarwinCharDevRemove(void); 80 81 static int vgdrvDarwinOpen(dev_t Dev, int fFlags, int fDevType, struct proc *pProcess); 82 static int vgdrvDarwinClose(dev_t Dev, int fFlags, int fDevType, struct proc *pProcess); 83 static int vgdrvDarwinIOCtlSlow(PVBOXGUESTSESSION pSession, u_long iCmd, caddr_t pData, struct proc *pProcess); 84 static int vgdrvDarwinIOCtl(dev_t Dev, u_long iCmd, caddr_t pData, int fFlags, struct proc *pProcess); 85 86 static int vgdrvDarwinErr2DarwinErr(int rc); 87 88 static IOReturn vgdrvDarwinSleepHandler(void *pvTarget, void *pvRefCon, UInt32 uMessageType, IOService *pProvider, void *pvMessageArgument, vm_size_t argSize); 105 89 RT_C_DECLS_END 106 90 … … 178 162 179 163 KMOD_EXPLICIT_DECL(VBoxGuest, VBOX_VERSION_STRING, _start, _stop) 180 DECLHIDDEN(kmod_start_func_t *) _realmain = VbgdDarwinStart;181 DECLHIDDEN(kmod_stop_func_t *) _antimain = VbgdDarwinStop;164 DECLHIDDEN(kmod_start_func_t *) _realmain = vgdrvDarwinStart; 165 DECLHIDDEN(kmod_stop_func_t *) _antimain = vgdrvDarwinStop; 182 166 DECLHIDDEN(int) _kext_apple_cc = __APPLE_CC__; 183 167 RT_C_DECLS_END … … 194 178 static struct cdevsw g_DevCW = 195 179 { 196 /*.d_open = */ VbgdDarwinOpen,197 /*.d_close = */ VbgdDarwinClose,180 /*.d_open = */ vgdrvDarwinOpen, 181 /*.d_close = */ vgdrvDarwinClose, 198 182 /*.d_read = */ eno_rdwrt, 199 183 /*.d_write = */ eno_rdwrt, 200 /*.d_ioctl = */ VbgdDarwinIOCtl,184 /*.d_ioctl = */ vgdrvDarwinIOCtl, 201 185 /*.d_stop = */ eno_stop, 202 186 /*.d_reset = */ eno_reset, … … 242 226 * Start the kernel module. 243 227 */ 244 static kern_return_t VbgdDarwinStart(struct kmod_info *pKModInfo, void *pvData)228 static kern_return_t vgdrvDarwinStart(struct kmod_info *pKModInfo, void *pvData) 245 229 { 246 230 /* … … 248 232 */ 249 233 int rc = RTR0Init(0); 250 if (RT_FAILURE(rc)) 251 { 252 PDEBUG("VBoxGuest: RTR0Init failed with rc=%d\n", rc); 253 return KMOD_RETURN_FAILURE; 254 } 255 256 PDEBUG("VBoxGuest: driver loaded\n"); 257 234 if (RT_SUCCESS(rc)) 235 { 236 Log(("VBoxGuest: driver loaded\n")); 237 return KMOD_RETURN_SUCCESS; 238 } 239 240 printf("VBoxGuest: RTR0Init failed with rc=%d\n", rc); 241 return KMOD_RETURN_FAILURE; 242 } 243 244 245 /** 246 * Register VBoxGuest char device 247 */ 248 static int vgdrvDarwinCharDevInit(void) 249 { 250 int rc = RTSpinlockCreate(&g_Spinlock, RTSPINLOCK_FLAGS_INTERRUPT_SAFE, "VBoxGuestDarwin"); 251 if (RT_SUCCESS(rc)) 252 { 253 /* 254 * Registering ourselves as a character device. 255 */ 256 g_iMajorDeviceNo = cdevsw_add(-1, &g_DevCW); 257 if (g_iMajorDeviceNo >= 0) 258 { 259 g_hDevFsDeviceSys = devfs_make_node(makedev(g_iMajorDeviceNo, 0), DEVFS_CHAR, 260 UID_ROOT, GID_WHEEL, 0666, DEVICE_NAME_SYS); 261 if (g_hDevFsDeviceSys != NULL) 262 { 263 /* 264 * Register a sleep/wakeup notification callback. 265 */ 266 g_pSleepNotifier = registerPrioritySleepWakeInterest(&vgdrvDarwinSleepHandler, &g_DevExt, NULL); 267 if (g_pSleepNotifier != NULL) 268 { 269 return KMOD_RETURN_SUCCESS; 270 } 271 } 272 } 273 vgdrvDarwinCharDevRemove(); 274 } 275 return KMOD_RETURN_FAILURE; 276 } 277 278 279 /** 280 * Stop the kernel module. 281 */ 282 static kern_return_t vgdrvDarwinStop(struct kmod_info *pKModInfo, void *pvData) 283 { 284 RTR0TermForced(); 285 286 printf("VBoxGuest: driver unloaded\n"); 258 287 return KMOD_RETURN_SUCCESS; 259 288 } 260 289 261 290 262 /* Register VBoxGuest char device */263 static int VbgdDarwinCharDevInit(void)264 {265 int rc = RTSpinlockCreate(&g_Spinlock, RTSPINLOCK_FLAGS_INTERRUPT_SAFE, "VBoxGuestDarwin");266 if (RT_FAILURE(rc))267 {268 return KMOD_RETURN_FAILURE;269 }270 271 /*272 * Registering ourselves as a character device.273 */274 g_iMajorDeviceNo = cdevsw_add(-1, &g_DevCW);275 if (g_iMajorDeviceNo < 0)276 {277 VbgdDarwinCharDevRemove();278 return KMOD_RETURN_FAILURE;279 }280 281 g_hDevFsDeviceSys = devfs_make_node(makedev(g_iMajorDeviceNo, 0), DEVFS_CHAR,282 UID_ROOT, GID_WHEEL, 0666, DEVICE_NAME_SYS);283 if (!g_hDevFsDeviceSys)284 {285 VbgdDarwinCharDevRemove();286 return KMOD_RETURN_FAILURE;287 }288 289 /* Register a sleep/wakeup notification callback */290 g_pSleepNotifier = registerPrioritySleepWakeInterest(&VbgdDarwinSleepHandler, &g_DevExt, NULL);291 if (g_pSleepNotifier == NULL)292 {293 VbgdDarwinCharDevRemove();294 return KMOD_RETURN_FAILURE;295 }296 297 return KMOD_RETURN_SUCCESS;298 }299 300 301 /**302 * Stop the kernel module.303 */304 static kern_return_t VbgdDarwinStop(struct kmod_info *pKModInfo, void *pvData)305 {306 RTR0TermForced();307 308 PDEBUG("VBoxGuest: driver unloaded\n");309 310 return KMOD_RETURN_SUCCESS;311 }312 313 314 291 /* Unregister VBoxGuest char device */ 315 static int 316 VbgdDarwinCharDevRemove(void) 292 static int vgdrvDarwinCharDevRemove(void) 317 293 { 318 294 int rc = KMOD_RETURN_SUCCESS; … … 361 337 * @param pProcess The process issuing this request. 362 338 */ 363 static int VbgdDarwinOpen(dev_t Dev, int fFlags, int fDevType, struct proc *pProcess)339 static int vgdrvDarwinOpen(dev_t Dev, int fFlags, int fDevType, struct proc *pProcess) 364 340 { 365 341 /* … … 412 388 rc = VERR_INVALID_PARAMETER; 413 389 414 Log((" VbgdDarwinOpen: g_DevExt=%p pSession=%p rc=%d pid=%d\n", &g_DevExt, pSession, rc, proc_pid(pProcess)));415 return VbgdDarwinErr2DarwinErr(rc);390 Log(("vgdrvDarwinOpen: g_DevExt=%p pSession=%p rc=%d pid=%d\n", &g_DevExt, pSession, rc, proc_pid(pProcess))); 391 return vgdrvDarwinErr2DarwinErr(rc); 416 392 } 417 393 … … 420 396 * Close device. 421 397 */ 422 static int VbgdDarwinClose(dev_t Dev, int fFlags, int fDevType, struct proc *pProcess)423 { 424 Log((" VbgdDarwinClose: pid=%d\n", (int)RTProcSelf()));398 static int vgdrvDarwinClose(dev_t Dev, int fFlags, int fDevType, struct proc *pProcess) 399 { 400 Log(("vgdrvDarwinClose: pid=%d\n", (int)RTProcSelf())); 425 401 Assert(proc_pid(pProcess) == (int)RTProcSelf()); 426 402 … … 443 419 * @param pProcess The process issuing this request. 444 420 */ 445 static int VbgdDarwinIOCtl(dev_t Dev, u_long iCmd, caddr_t pData, int fFlags, struct proc *pProcess)421 static int vgdrvDarwinIOCtl(dev_t Dev, u_long iCmd, caddr_t pData, int fFlags, struct proc *pProcess) 446 422 { 447 423 //const bool fUnrestricted = minor(Dev) == 0; … … 460 436 if (!pSession) 461 437 { 462 Log(("VBoxDrvDarwinIOCtl: WHAT?!? pSession == NULL! This must be a mistake... pid=%d iCmd=%#lx\n", 463 (int)Process, iCmd)); 438 Log(("VBoxDrvDarwinIOCtl: WHAT?!? pSession == NULL! This must be a mistake... pid=%d iCmd=%#lx\n", (int)Process, iCmd)); 464 439 return EINVAL; 465 440 } … … 469 444 */ 470 445 471 return VbgdDarwinIOCtlSlow(pSession, iCmd, pData, pProcess);472 } 473 474 475 /** 476 * Worker for VbgdDarwinIOCtl that takes the slow IOCtl functions.446 return vgdrvDarwinIOCtlSlow(pSession, iCmd, pData, pProcess); 447 } 448 449 450 /** 451 * Worker for vgdrvDarwinIOCtl that takes the slow IOCtl functions. 477 452 * 478 453 * @returns Darwin errno. … … 483 458 * @param pProcess The calling process. 484 459 */ 485 static int VbgdDarwinIOCtlSlow(PVBOXGUESTSESSION pSession, u_long iCmd, caddr_t pData, struct proc *pProcess)486 { 487 LogFlow((" VbgdDarwinIOCtlSlow: pSession=%p iCmd=%p pData=%p pProcess=%p\n", pSession, iCmd, pData, pProcess));460 static int vgdrvDarwinIOCtlSlow(PVBOXGUESTSESSION pSession, u_long iCmd, caddr_t pData, struct proc *pProcess) 461 { 462 LogFlow(("vgdrvDarwinIOCtlSlow: pSession=%p iCmd=%p pData=%p pProcess=%p\n", pSession, iCmd, pData, pProcess)); 488 463 489 464 … … 512 487 if (RT_UNLIKELY(rc)) 513 488 { 514 Log((" VbgdDarwinIOCtlSlow: copyin(%llx,Hdr,) -> %#x; iCmd=%#lx\n", (unsigned long long)pUser, rc, iCmd));489 Log(("vgdrvDarwinIOCtlSlow: copyin(%llx,Hdr,) -> %#x; iCmd=%#lx\n", (unsigned long long)pUser, rc, iCmd)); 515 490 return rc; 516 491 } 517 492 if (RT_UNLIKELY(Hdr.u32Magic != VBGLBIGREQ_MAGIC)) 518 493 { 519 Log((" VbgdDarwinIOCtlSlow: bad magic u32Magic=%#x; iCmd=%#lx\n", Hdr.u32Magic, iCmd));494 Log(("vgdrvDarwinIOCtlSlow: bad magic u32Magic=%#x; iCmd=%#lx\n", Hdr.u32Magic, iCmd)); 520 495 return EINVAL; 521 496 } … … 523 498 if (RT_UNLIKELY(cbReq > _1M*16)) 524 499 { 525 Log((" VbgdDarwinIOCtlSlow: %#x; iCmd=%#lx\n", Hdr.cbData, iCmd));500 Log(("vgdrvDarwinIOCtlSlow: %#x; iCmd=%#lx\n", Hdr.cbData, iCmd)); 526 501 return EINVAL; 527 502 } … … 536 511 if (RT_UNLIKELY(!pvReqData)) 537 512 { 538 Log((" VbgdDarwinIOCtlSlow: failed to allocate buffer of %d bytes; iCmd=%#lx\n", cbReq, iCmd));513 Log(("vgdrvDarwinIOCtlSlow: failed to allocate buffer of %d bytes; iCmd=%#lx\n", cbReq, iCmd)); 539 514 return ENOMEM; 540 515 } … … 542 517 if (RT_UNLIKELY(rc)) 543 518 { 544 Log((" VbgdDarwinIOCtlSlow: copyin(%llx,%p,%#x) -> %#x; iCmd=%#lx\n",519 Log(("vgdrvDarwinIOCtlSlow: copyin(%llx,%p,%#x) -> %#x; iCmd=%#lx\n", 545 520 (unsigned long long)pUser, pvReqData, Hdr.cbData, rc, iCmd)); 546 521 if (pvPageBuf) … … 553 528 else 554 529 { 555 Log((" VbgdDarwinIOCtlSlow: huh? cbReq=%#x iCmd=%#lx\n", cbReq, iCmd));530 Log(("vgdrvDarwinIOCtlSlow: huh? cbReq=%#x iCmd=%#lx\n", cbReq, iCmd)); 556 531 return EINVAL; 557 532 } … … 571 546 if (cbReqRet > cbReq) 572 547 { 573 Log((" VbgdDarwinIOCtlSlow: too much output! %#x > %#x; uCmd=%#lx!\n", cbReqRet, cbReq, iCmd));548 Log(("vgdrvDarwinIOCtlSlow: too much output! %#x > %#x; uCmd=%#lx!\n", cbReqRet, cbReq, iCmd)); 574 549 cbReqRet = cbReq; 575 550 } 576 551 rc = copyout(pvReqData, pUser, cbReqRet); 577 552 if (RT_UNLIKELY(rc)) 578 Log((" VbgdDarwinIOCtlSlow: copyout(%p,%llx,%#x) -> %d; uCmd=%#lx!\n",553 Log(("vgdrvDarwinIOCtlSlow: copyout(%p,%llx,%#x) -> %d; uCmd=%#lx!\n", 579 554 pvReqData, (unsigned long long)pUser, cbReqRet, rc, iCmd)); 580 555 … … 601 576 } 602 577 603 Log((" VbgdDarwinIOCtlSlow: pid=%d iCmd=%lx pData=%p failed, rc=%d\n", proc_pid(pProcess), iCmd, (void *)pData, rc));578 Log(("vgdrvDarwinIOCtlSlow: pid=%d iCmd=%lx pData=%p failed, rc=%d\n", proc_pid(pProcess), iCmd, (void *)pData, rc)); 604 579 rc = EINVAL; 605 580 } 606 581 607 Log2((" VbgdDarwinIOCtlSlow: returns %d\n", rc));582 Log2(("vgdrvDarwinIOCtlSlow: returns %d\n", rc)); 608 583 return rc; 609 584 } … … 627 602 * Callback for blah blah blah. 628 603 */ 629 IOReturn VbgdDarwinSleepHandler(void * /* pvTarget */, void *pvRefCon, UInt32 uMessageType, IOService * /* pProvider */, void * /* pvMessageArgument */, vm_size_t /* argSize */) 630 { 631 LogFlow(("VBoxGuest: Got sleep/wake notice. Message type was %X\n", (uint)uMessageType)); 604 static IOReturn vgdrvDarwinSleepHandler(void *pvTarget, void *pvRefCon, UInt32 uMessageType, 605 IOService *pProvider, void *pvMsgArg, vm_size_t cbMsgArg) 606 { 607 LogFlow(("VBoxGuest: Got sleep/wake notice. Message type was %x\n", uMessageType)); 632 608 633 609 if (uMessageType == kIOMessageSystemWillSleep) … … 648 624 * @param rc IPRT status code. 649 625 */ 650 static int VbgdDarwinErr2DarwinErr(int rc)626 static int vgdrvDarwinErr2DarwinErr(int rc) 651 627 { 652 628 switch (rc) … … 675 651 676 652 677 IOWorkLoop * 678 org_virtualbox_VBoxGuest::getWorkLoop() 679 { 680 /* Handle the case when work loop was not created yet */ 681 if(ASMAtomicCmpXchgU8(&g_fWorkLoopCreated, VBOXGUEST_OBJECT_INITIALIZING, VBOXGUEST_OBJECT_UNINITIALIZED)) 653 /** 654 * Lazy initialization of the m_pWorkLoop member. 655 * 656 * @returns m_pWorkLoop. 657 */ 658 IOWorkLoop *org_virtualbox_VBoxGuest::getWorkLoop() 659 { 660 /** @todo r=bird: This is actually a classic RTOnce scenario, except it's 661 * tied to a org_virtualbox_VBoxGuest instance. */ 662 /* 663 * Handle the case when work loop was not created yet. 664 */ 665 if (ASMAtomicCmpXchgU8(&g_fWorkLoopCreated, VBOXGUEST_OBJECT_INITIALIZING, VBOXGUEST_OBJECT_UNINITIALIZED)) 682 666 { 683 667 m_pWorkLoop = IOWorkLoop::workLoop(); … … 686 670 /* Notify the rest of threads about the fact that work 687 671 * loop was successully allocated and can be safely used */ 688 PDEBUG("created new work loop\n");672 Log(("VBoxGuest: created new work loop\n")); 689 673 ASMAtomicWriteU8(&g_fWorkLoopCreated, VBOXGUEST_OBJECT_INITIALIZED); 690 674 } … … 693 677 /* Notify the rest of threads about the fact that there was 694 678 * an error during allocation of a work loop */ 695 PDEBUG("unable new work loop\n");679 Log(("VBoxGuest: failed to create new work loop!\n")); 696 680 ASMAtomicWriteU8(&g_fWorkLoopCreated, VBOXGUEST_OBJECT_UNINITIALIZED); 697 681 } 698 682 } 683 /* 684 * Handle the case when work loop is already create or 685 * in the process of being. 686 */ 699 687 else 700 688 { 701 /* Handle the case when work loop is currently being 702 * created or it was previously failed to create */ 703 uint8_t fWorkLoopCreated = VBOXGUEST_OBJECT_INVALID; 704 while (fWorkLoopCreated != VBOXGUEST_OBJECT_INITIALIZED 705 && fWorkLoopCreated != VBOXGUEST_OBJECT_UNINITIALIZED) 706 { 689 uint8_t fWorkLoopCreated = ASMAtomicReadU8(&g_fWorkLoopCreated); 690 while (fWorkLoopCreated == VBOXGUEST_OBJECT_INITIALIZING) 691 { 692 thread_block(0); 707 693 fWorkLoopCreated = ASMAtomicReadU8(&g_fWorkLoopCreated); 708 thread_block(0); 709 } 710 if (fWorkLoopCreated == VBOXGUEST_OBJECT_INITIALIZED) 711 PDEBUG("returned existing work loop"); 712 else 713 PDEBUG("work loop was not allocated correctly"); 694 } 695 if (fWorkLoopCreated != VBOXGUEST_OBJECT_INITIALIZED) 696 Log(("VBoxGuest: No work loop!\n")); 714 697 } 715 698 … … 721 704 * Perform pending wake ups in work loop context. 722 705 */ 723 static void 724 deferredInterruptHandler(OSObject *pOwner, IOInterruptEventSource *pSrc, int cInts) 706 static void vgdrvDarwinDeferredIrqHandler(OSObject *pOwner, IOInterruptEventSource *pSrc, int cInts) 725 707 { 726 708 NOREF(pOwner); NOREF(pSrc); NOREF(cInts); … … 729 711 } 730 712 713 731 714 /** 732 715 * Callback triggered when interrupt occurs. 733 716 */ 734 static bool 735 directInterruptHandler(OSObject *pOwner, IOFilterInterruptEventSource *pSrc) 717 static bool vgdrvDarwinDirectIrqHandler(OSObject *pOwner, IOFilterInterruptEventSource *pSrc) 736 718 { 737 719 if (!pSrc) … … 740 722 bool fTaken = VGDrvCommonISR(&g_DevExt); 741 723 if (!fTaken) /** @todo r=bird: This looks bogus as we might actually be sharing interrupts with someone. */ 742 PDEBUG("VbgdCommonISR error\n");724 Log(("VGDrvCommonISR error\n")); 743 725 744 726 return fTaken; 745 727 } 746 728 747 bool 748 org_virtualbox_VBoxGuest::setupVmmDevInterrupts(IOService *pProvider)729 730 bool org_virtualbox_VBoxGuest::setupVmmDevInterrupts(IOService *pProvider) 749 731 { 750 732 IOWorkLoop *pWorkLoop = getWorkLoop(); 751 752 733 if (!pWorkLoop) 753 734 return false; 754 735 755 736 m_pInterruptSrc = IOFilterInterruptEventSource::filterInterruptEventSource(this, 756 & deferredInterruptHandler,757 & directInterruptHandler,737 &vgdrvDarwinDeferredIrqHandler, 738 &vgdrvDarwinDirectIrqHandler, 758 739 pProvider); 759 760 if (kIOReturnSuccess != pWorkLoop->addEventSource(m_pInterruptSrc)) 761 { 762 m_pInterruptSrc->disable(); 763 m_pInterruptSrc->release(); 764 m_pInterruptSrc = 0; 765 return false; 766 } 767 768 m_pInterruptSrc->enable(); 769 770 return true; 771 } 772 773 bool 774 org_virtualbox_VBoxGuest::disableVmmDevInterrupts(void) 740 IOReturn rc = pWorkLoop->addEventSource(m_pInterruptSrc); 741 if (rc == kIOReturnSuccess) 742 { 743 m_pInterruptSrc->enable(); 744 return true; 745 } 746 747 m_pInterruptSrc->disable(); 748 m_pInterruptSrc->release(); 749 m_pInterruptSrc = NULL; 750 return false; 751 } 752 753 754 bool org_virtualbox_VBoxGuest::disableVmmDevInterrupts(void) 775 755 { 776 756 IOWorkLoop *pWorkLoop = (IOWorkLoop *)getWorkLoop(); … … 785 765 pWorkLoop->removeEventSource(m_pInterruptSrc); 786 766 m_pInterruptSrc->release(); 787 m_pInterruptSrc = 0;767 m_pInterruptSrc = NULL; 788 768 789 769 return true; 790 770 } 771 791 772 792 773 bool org_virtualbox_VBoxGuest::isVmmDev(IOPCIDevice *pIOPCIDevice) … … 812 793 bool org_virtualbox_VBoxGuest::start(IOService *pProvider) 813 794 { 795 /* 796 * Low level initialization / device initialization should be performed only once. 797 */ 798 if (!ASMAtomicCmpXchgBool(&g_fInstantiated, true, false)) 799 return false; 800 814 801 if (!IOService::start(pProvider)) 815 802 return false; 816 817 /* Low level initialization should be performed only once */818 if (!ASMAtomicCmpXchgBool(&g_fInstantiated, true, false))819 {820 IOService::stop(pProvider);821 return false;822 }823 803 824 804 m_pIOPCIDevice = OSDynamicCast(IOPCIDevice, pProvider); … … 861 841 if (RT_SUCCESS(rc)) 862 842 { 863 rc = VbgdDarwinCharDevInit();843 rc = vgdrvDarwinCharDevInit(); 864 844 if (rc == KMOD_RETURN_SUCCESS) 865 845 { … … 873 853 874 854 LogRel(("VBoxGuest: Failed to set up interrupts\n")); 875 VbgdDarwinCharDevRemove();855 vgdrvDarwinCharDevRemove(); 876 856 } 877 857 else … … 901 881 902 882 ASMAtomicXchgBool(&g_fInstantiated, false); 903 904 883 IOService::stop(pProvider); 905 906 884 return false; 907 885 } … … 915 893 /* Do not use Log*() here (in IOService instance) because its instance 916 894 * already terminated in BSD's module unload callback! */ 917 PDEBUG("org_virtualbox_VBoxGuest::stop([%p], %p)\n", this, pProvider);895 Log(("org_virtualbox_VBoxGuest::stop([%p], %p)\n", this, pProvider)); 918 896 919 897 AssertReturnVoid(ASMAtomicReadBool(&g_fInstantiated)); … … 921 899 /* Low level termination should be performed only once */ 922 900 if (!disableVmmDevInterrupts()) 923 PDEBUG("VBoxGuest: unable to unregister interrupt handler\n");924 925 VbgdDarwinCharDevRemove();901 printf("VBoxGuest: unable to unregister interrupt handler\n"); 902 903 vgdrvDarwinCharDevRemove(); 926 904 VGDrvCommonDeleteDevExt(&g_DevExt); 927 905 … … 936 914 ASMAtomicWriteBool(&g_fInstantiated, false); 937 915 938 PINFO("VBoxGuest: IOService stopped\n");916 printf("VBoxGuest: IOService stopped\n"); 939 917 } 940 918 … … 950 928 /* Do not use Log*() here (in IOService instance) because its instance 951 929 * already terminated in BSD's module unload callback! */ 930 #ifdef LOG_ENABLED 931 printf("org_virtualbox_VBoxGuest::terminate: reference_count=%d g_cSessions=%d (fOptions=%#x)\n", 932 KMOD_INFO_NAME.reference_count, ASMAtomicUoReadS32(&g_cSessions), fOptions); 933 #endif 952 934 953 935 bool fRc; 954 PDEBUG("org_virtualbox_VBoxGuest::terminate: reference_count=%d g_cSessions=%d (fOptions=%#x)\n",955 KMOD_INFO_NAME.reference_count, ASMAtomicUoReadS32(&g_cSessions), fOptions);956 936 if ( KMOD_INFO_NAME.reference_count != 0 957 937 || ASMAtomicUoReadS32(&g_cSessions)) … … 959 939 else 960 940 fRc = IOService::terminate(fOptions); 961 PDEBUG("org_virtualbox_SupDrv::terminate: returns %d\n", fRc); 941 942 #ifdef LOG_ENABLED 943 printf("org_virtualbox_SupDrv::terminate: returns %d\n", fRc); 944 #endif 962 945 return fRc; 963 946 } … … 1081 1064 * 1082 1065 * Note! Only one session per process. (Both start() and 1083 * VbgdDarwinOpen makes sure this is so.)1066 * vgdrvDarwinOpen makes sure this is so.) 1084 1067 */ 1085 1068 const unsigned iHash = SESSION_HASH(Process); -
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-freebsd.c
r58053 r58113 21 21 * applied to the other. */ 22 22 23 24 /********************************************************************************************************************************* 25 * Header Files * 26 *********************************************************************************************************************************/ 23 27 #include <sys/param.h> 28 #undef PVM 29 #include <sys/types.h> 30 #include <sys/module.h> 24 31 #include <sys/systm.h> 32 #include <sys/errno.h> 33 #include <sys/kernel.h> 34 #include <sys/fcntl.h> 25 35 #include <sys/conf.h> 26 #include <sys/kernel.h> 27 #include <sys/module.h> 36 #include <sys/uio.h> 28 37 #include <sys/bus.h> 29 38 #include <sys/poll.h> … … 32 41 #include <sys/lock.h> 33 42 #include <sys/lockmgr.h> 34 #include <sys/types.h>35 #include <sys/conf.h>36 43 #include <sys/malloc.h> 37 #include <sys/uio.h>38 44 #include <sys/file.h> 39 45 #include <sys/rman.h> … … 43 49 #include <dev/pci/pcireg.h> 44 50 45 #ifdef PVM46 # undef PVM47 #endif48 51 #include "VBoxGuestInternal.h" 52 #include <VBox/version.h> 49 53 #include <VBox/log.h> 50 54 #include <iprt/assert.h> … … 54 58 #include <iprt/asm.h> 55 59 60 61 /********************************************************************************************************************************* 62 * Defined Constants And Macros * 63 *********************************************************************************************************************************/ 56 64 /** The module name. */ 57 #define DEVICE_NAME "vboxguest" 58 65 #define DEVICE_NAME "vboxguest" 66 67 68 /********************************************************************************************************************************* 69 * Structures and Typedefs * 70 *********************************************************************************************************************************/ 59 71 struct VBoxGuestDeviceState 60 72 { … … 85 97 }; 86 98 87 static MALLOC_DEFINE(M_VBOXDEV, "vboxdev_pci", "VirtualBox Guest driver PCI"); 88 99 100 /********************************************************************************************************************************* 101 * Internal Functions * 102 *********************************************************************************************************************************/ 89 103 /* 90 104 * Character device file handlers. 91 105 */ 92 static d_fdopen_t VBoxGuestFreeBSDOpen;93 static d_close_t VBoxGuestFreeBSDClose;94 static d_ioctl_t VBoxGuestFreeBSDIOCtl;95 static d_write_t VBoxGuestFreeBSDWrite;96 static d_read_t VBoxGuestFreeBSDRead;97 static d_poll_t VBoxGuestFreeBSDPoll;106 static d_fdopen_t vgdrvFreeBSDOpen; 107 static d_close_t vgdrvFreeBSDClose; 108 static d_ioctl_t vgdrvFreeBSDIOCtl; 109 static d_write_t vgdrvFreeBSDWrite; 110 static d_read_t vgdrvFreeBSDRead; 111 static d_poll_t vgdrvFreeBSDPoll; 98 112 99 113 /* 100 114 * IRQ related functions. 101 115 */ 102 static void VBoxGuestFreeBSDRemoveIRQ(device_t pDevice, void *pvState); 103 static int VBoxGuestFreeBSDAddIRQ(device_t pDevice, void *pvState); 104 static int VBoxGuestFreeBSDISR(void *pvState); 105 106 /* 107 * Available functions for kernel drivers. 108 */ 109 DECLVBGL(int) VBoxGuestFreeBSDServiceCall(void *pvSession, unsigned uCmd, void *pvData, size_t cbData, size_t *pcbDataReturned); 110 DECLVBGL(void *) VBoxGuestFreeBSDServiceOpen(uint32_t *pu32Version); 111 DECLVBGL(int) VBoxGuestFreeBSDServiceClose(void *pvSession); 116 static void vgdrvFreeBSDRemoveIRQ(device_t pDevice, void *pvState); 117 static int vgdrvFreeBSDAddIRQ(device_t pDevice, void *pvState); 118 static int vgdrvFreeBSDISR(void *pvState); 119 120 121 /********************************************************************************************************************************* 122 * Global Variables * 123 *********************************************************************************************************************************/ 124 static MALLOC_DEFINE(M_VBOXGUEST, "vboxguest", "VirtualBox Guest Device Driver"); 112 125 113 126 #ifndef D_NEEDMINOR … … 116 129 117 130 /* 118 * Device node entry points.119 */ 120 static struct cdevsw g_ VBoxGuestFreeBSDChrDevSW =131 * The /dev/vboxguest character device entry points. 132 */ 133 static struct cdevsw g_vgdrvFreeBSDChrDevSW = 121 134 { 122 135 .d_version = D_VERSION, 123 136 .d_flags = D_TRACKCLOSE | D_NEEDMINOR, 124 .d_fdopen = VBoxGuestFreeBSDOpen,125 .d_close = VBoxGuestFreeBSDClose,126 .d_ioctl = VBoxGuestFreeBSDIOCtl,127 .d_read = VBoxGuestFreeBSDRead,128 .d_write = VBoxGuestFreeBSDWrite,129 .d_poll = VBoxGuestFreeBSDPoll,130 .d_name = DEVICE_NAME137 .d_fdopen = vgdrvFreeBSDOpen, 138 .d_close = vgdrvFreeBSDClose, 139 .d_ioctl = vgdrvFreeBSDIOCtl, 140 .d_read = vgdrvFreeBSDRead, 141 .d_write = vgdrvFreeBSDWrite, 142 .d_poll = vgdrvFreeBSDPoll, 143 .d_name = "vboxguest" 131 144 }; 132 145 133 146 /** Device extention & session data association structure. */ 134 147 static VBOXGUESTDEVEXT g_DevExt; 148 135 149 /** List of cloned device. Managed by the kernel. */ 136 static struct clonedevs *g_p VBoxGuestFreeBSDClones;150 static struct clonedevs *g_pvgdrvFreeBSDClones; 137 151 /** The dev_clone event handler tag. */ 138 static eventhandler_tag g_ VBoxGuestFreeBSDEHTag;152 static eventhandler_tag g_vgdrvFreeBSDEHTag; 139 153 /** Reference counter */ 140 154 static volatile uint32_t cUsers; … … 145 159 * DEVFS event handler. 146 160 */ 147 static void VBoxGuestFreeBSDClone(void *pvArg, struct ucred *pCred, char *pszName, int cchName, struct cdev **ppDev)161 static void vgdrvFreeBSDClone(void *pvArg, struct ucred *pCred, char *pszName, int cchName, struct cdev **ppDev) 148 162 { 149 163 int iUnit; 150 164 int rc; 151 165 152 Log((" VBoxGuestFreeBSDClone: pszName=%s ppDev=%p\n", pszName, ppDev));166 Log(("vgdrvFreeBSDClone: pszName=%s ppDev=%p\n", pszName, ppDev)); 153 167 154 168 /* … … 164 178 if (iUnit >= 256) 165 179 { 166 Log((" VBoxGuestFreeBSDClone: iUnit=%d >= 256 - rejected\n", iUnit));180 Log(("vgdrvFreeBSDClone: iUnit=%d >= 256 - rejected\n", iUnit)); 167 181 return; 168 182 } 169 183 170 Log((" VBoxGuestFreeBSDClone: pszName=%s iUnit=%d\n", pszName, iUnit));171 172 rc = clone_create(&g_p VBoxGuestFreeBSDClones, &g_VBoxGuestFreeBSDChrDevSW, &iUnit, ppDev, 0);173 Log((" VBoxGuestFreeBSDClone: clone_create -> %d; iUnit=%d\n", rc, iUnit));184 Log(("vgdrvFreeBSDClone: pszName=%s iUnit=%d\n", pszName, iUnit)); 185 186 rc = clone_create(&g_pvgdrvFreeBSDClones, &g_vgdrvFreeBSDChrDevSW, &iUnit, ppDev, 0); 187 Log(("vgdrvFreeBSDClone: clone_create -> %d; iUnit=%d\n", rc, iUnit)); 174 188 if (rc) 175 189 { 176 *ppDev = make_dev(&g_ VBoxGuestFreeBSDChrDevSW,190 *ppDev = make_dev(&g_vgdrvFreeBSDChrDevSW, 177 191 iUnit, 178 192 UID_ROOT, … … 184 198 dev_ref(*ppDev); 185 199 (*ppDev)->si_flags |= SI_CHEAPCLONE; 186 Log((" VBoxGuestFreeBSDClone: Created *ppDev=%p iUnit=%d si_drv1=%p si_drv2=%p\n",200 Log(("vgdrvFreeBSDClone: Created *ppDev=%p iUnit=%d si_drv1=%p si_drv2=%p\n", 187 201 *ppDev, iUnit, (*ppDev)->si_drv1, (*ppDev)->si_drv2)); 188 202 (*ppDev)->si_drv1 = (*ppDev)->si_drv2 = NULL; 189 203 } 190 204 else 191 Log((" VBoxGuestFreeBSDClone: make_dev iUnit=%d failed\n", iUnit));205 Log(("vgdrvFreeBSDClone: make_dev iUnit=%d failed\n", iUnit)); 192 206 } 193 207 else 194 Log((" VBoxGuestFreeBSDClone: Existing *ppDev=%p iUnit=%d si_drv1=%p si_drv2=%p\n",208 Log(("vgdrvFreeBSDClone: Existing *ppDev=%p iUnit=%d si_drv1=%p si_drv2=%p\n", 195 209 *ppDev, iUnit, (*ppDev)->si_drv1, (*ppDev)->si_drv2)); 196 210 } … … 201 215 */ 202 216 #if __FreeBSD_version >= 700000 203 static int VBoxGuestFreeBSDOpen(struct cdev *pDev, int fOpen, struct thread *pTd, struct file *pFd)217 static int vgdrvFreeBSDOpen(struct cdev *pDev, int fOpen, struct thread *pTd, struct file *pFd) 204 218 #else 205 static int VBoxGuestFreeBSDOpen(struct cdev *pDev, int fOpen, struct thread *pTd)219 static int vgdrvFreeBSDOpen(struct cdev *pDev, int fOpen, struct thread *pTd) 206 220 #endif 207 221 { … … 209 223 PVBOXGUESTSESSION pSession; 210 224 211 LogFlow(( DEVICE_NAME ":VBoxGuestFreeBSDOpen\n"));225 LogFlow(("vgdrvFreeBSDOpen:\n")); 212 226 213 227 /* … … 225 239 if (ASMAtomicCmpXchgPtr(&pDev->si_drv1, pSession, (void *)0x42)) 226 240 { 227 Log(( DEVICE_NAME ":VBoxGuestFreeBSDOpen success:g_DevExt=%p pSession=%p rc=%d pid=%d\n", &g_DevExt, pSession, rc, (int)RTProcSelf()));241 Log(("vgdrvFreeBSDOpen: success - g_DevExt=%p pSession=%p rc=%d pid=%d\n", &g_DevExt, pSession, rc, (int)RTProcSelf())); 228 242 ASMAtomicIncU32(&cUsers); 229 243 return 0; … … 233 247 } 234 248 235 LogRel(( DEVICE_NAME ":VBoxGuestFreeBSDOpen: failed. rc=%d\n", rc));249 LogRel(("vgdrvFreeBSDOpen: failed. rc=%d\n", rc)); 236 250 return RTErrConvertToErrno(rc); 237 251 } … … 241 255 * 242 256 */ 243 static int VBoxGuestFreeBSDClose(struct cdev *pDev, int fFile, int DevType, struct thread *pTd)257 static int vgdrvFreeBSDClose(struct cdev *pDev, int fFile, int DevType, struct thread *pTd) 244 258 { 245 259 PVBOXGUESTSESSION pSession = (PVBOXGUESTSESSION)pDev->si_drv1; 246 Log((" VBoxGuestFreeBSDClose: fFile=%#x pSession=%p\n", fFile, pSession));260 Log(("vgdrvFreeBSDClose: fFile=%#x pSession=%p\n", fFile, pSession)); 247 261 248 262 /* … … 253 267 VGDrvCommonCloseSession(&g_DevExt, pSession); 254 268 if (!ASMAtomicCmpXchgPtr(&pDev->si_drv1, NULL, pSession)) 255 Log((" VBoxGuestFreeBSDClose: si_drv1=%p expected %p!\n", pDev->si_drv1, pSession));269 Log(("vgdrvFreeBSDClose: si_drv1=%p expected %p!\n", pDev->si_drv1, pSession)); 256 270 ASMAtomicDecU32(&cUsers); 257 271 /* Don't use destroy_dev here because it may sleep resulting in a hanging user process. */ … … 259 273 } 260 274 else 261 Log((" VBoxGuestFreeBSDClose: si_drv1=%p!\n", pSession));275 Log(("vgdrvFreeBSDClose: si_drv1=%p!\n", pSession)); 262 276 return 0; 263 277 } … … 267 281 * 268 282 */ 269 static int VBoxGuestFreeBSDIOCtl(struct cdev *pDev, u_long ulCmd, caddr_t pvData, int fFile, struct thread *pTd)270 { 271 LogFlow(( DEVICE_NAME ":VBoxGuestFreeBSDIOCtl\n"));283 static int vgdrvFreeBSDIOCtl(struct cdev *pDev, u_long ulCmd, caddr_t pvData, int fFile, struct thread *pTd) 284 { 285 LogFlow(("vgdrvFreeBSDIOCtl\n")); 272 286 273 287 int rc = 0; … … 285 299 if (IOCPARM_LEN(ulCmd) != sizeof(VBGLBIGREQ)) 286 300 { 287 Log(( DEVICE_NAME ": VBoxGuestFreeBSDIOCtl: bad request %lu size=%lu expected=%d\n", ulCmd, IOCPARM_LEN(ulCmd), sizeof(VBGLBIGREQ)));301 Log(("vgdrvFreeBSDIOCtl: bad request %lu size=%lu expected=%d\n", ulCmd, IOCPARM_LEN(ulCmd), sizeof(VBGLBIGREQ))); 288 302 return ENOTTY; 289 303 } … … 292 306 if (ReqWrap->u32Magic != VBGLBIGREQ_MAGIC) 293 307 { 294 Log(( DEVICE_NAME ": VBoxGuestFreeBSDIOCtl: bad magic %#x; pArg=%p Cmd=%lu.\n", ReqWrap->u32Magic, pvData, ulCmd));308 Log(("vgdrvFreeBSDIOCtl: bad magic %#x; pArg=%p Cmd=%lu.\n", ReqWrap->u32Magic, pvData, ulCmd)); 295 309 return EINVAL; 296 310 } … … 298 312 || ReqWrap->cbData > _1M*16)) 299 313 { 300 printf( DEVICE_NAME ": VBoxGuestFreeBSDIOCtl: bad size %#x; pArg=%p Cmd=%lu.\n", ReqWrap->cbData, pvData, ulCmd);314 printf("vgdrvFreeBSDIOCtl: bad size %#x; pArg=%p Cmd=%lu.\n", ReqWrap->cbData, pvData, ulCmd); 301 315 return EINVAL; 302 316 } … … 308 322 if (RT_UNLIKELY(!pvBuf)) 309 323 { 310 Log(( DEVICE_NAME ":VBoxGuestFreeBSDIOCtl: RTMemTmpAlloc failed to alloc %d bytes.\n", ReqWrap->cbData));324 Log(("vgdrvFreeBSDIOCtl: RTMemTmpAlloc failed to alloc %d bytes.\n", ReqWrap->cbData)); 311 325 return ENOMEM; 312 326 } … … 316 330 { 317 331 RTMemTmpFree(pvBuf); 318 Log(( DEVICE_NAME ":VBoxGuestFreeBSDIOCtl: copyin failed; pvBuf=%p pArg=%p Cmd=%lu. rc=%d\n", pvBuf, pvData, ulCmd, rc));332 Log(("vgdrvFreeBSDIOCtl: copyin failed; pvBuf=%p pArg=%p Cmd=%lu. rc=%d\n", pvBuf, pvData, ulCmd, rc)); 319 333 return EFAULT; 320 334 } … … 323 337 { 324 338 RTMemTmpFree(pvBuf); 325 Log(( DEVICE_NAME ":VBoxGuestFreeBSDIOCtl: pvBuf invalid pointer %p\n", pvBuf));339 Log(("vgdrvFreeBSDIOCtl: pvBuf invalid pointer %p\n", pvBuf)); 326 340 return EINVAL; 327 341 } 328 Log(( DEVICE_NAME ":VBoxGuestFreeBSDIOCtl: pSession=%p pid=%d.\n", pSession, (int)RTProcSelf()));342 Log(("vgdrvFreeBSDIOCtl: pSession=%p pid=%d.\n", pSession, (int)RTProcSelf())); 329 343 330 344 /* … … 338 352 if (RT_UNLIKELY(cbDataReturned > ReqWrap->cbData)) 339 353 { 340 Log(( DEVICE_NAME ":VBoxGuestFreeBSDIOCtl: too much output data %d expected %d\n", cbDataReturned, ReqWrap->cbData));354 Log(("vgdrvFreeBSDIOCtl: too much output data %d expected %d\n", cbDataReturned, ReqWrap->cbData)); 341 355 cbDataReturned = ReqWrap->cbData; 342 356 } … … 346 360 if (RT_UNLIKELY(rc)) 347 361 { 348 Log(( DEVICE_NAME ":VBoxGuestFreeBSDIOCtl: copyout failed; pvBuf=%p pArg=%p Cmd=%lu. rc=%d\n", pvBuf, pvData, ulCmd, rc));362 Log(("vgdrvFreeBSDIOCtl: copyout failed; pvBuf=%p pArg=%p Cmd=%lu. rc=%d\n", pvBuf, pvData, ulCmd, rc)); 349 363 rc = EFAULT; 350 364 } … … 353 367 else 354 368 { 355 Log(( DEVICE_NAME ":VBoxGuestFreeBSDIOCtl: VbgdCommonIoCtl failed. rc=%d\n", rc));369 Log(("vgdrvFreeBSDIOCtl: VGDrvCommonIoCtl failed. rc=%d\n", rc)); 356 370 rc = EFAULT; 357 371 } … … 360 374 } 361 375 362 static int VBoxGuestFreeBSDPoll(struct cdev *pDev, int fEvents, struct thread *td)376 static int vgdrvFreeBSDPoll(struct cdev *pDev, int fEvents, struct thread *td) 363 377 { 364 378 int fEventsProcessed; 365 379 366 LogFlow(( DEVICE_NAME "::Poll: fEvents=%d\n", fEvents));380 LogFlow(("vgdrvFreeBSDPoll: fEvents=%d\n", fEvents)); 367 381 368 382 PVBOXGUESTSESSION pSession = (PVBOXGUESTSESSION)pDev->si_drv1; 369 383 if (RT_UNLIKELY(!VALID_PTR(pSession))) { 370 Log(( DEVICE_NAME "::Poll: no state data for %s\n", devtoname(pDev)));384 Log(("vgdrvFreeBSDPoll: no state data for %s\n", devtoname(pDev))); 371 385 return (fEvents & (POLLHUP|POLLIN|POLLRDNORM|POLLOUT|POLLWRNORM)); 372 386 } … … 388 402 } 389 403 390 static int VBoxGuestFreeBSDWrite(struct cdev *pDev, struct uio *pUio, int fIo)404 static int vgdrvFreeBSDWrite(struct cdev *pDev, struct uio *pUio, int fIo) 391 405 { 392 406 return 0; 393 407 } 394 408 395 static int VBoxGuestFreeBSDRead(struct cdev *pDev, struct uio *pUio, int fIo)409 static int vgdrvFreeBSDRead(struct cdev *pDev, struct uio *pUio, int fIo) 396 410 { 397 411 return 0; 398 412 } 399 413 400 static int VBoxGuestFreeBSDDetach(device_t pDevice)414 static int vgdrvFreeBSDDetach(device_t pDevice) 401 415 { 402 416 struct VBoxGuestDeviceState *pState = device_get_softc(pDevice); … … 406 420 407 421 /* 408 * Reverse what we did in VBoxGuestFreeBSDAttach.409 */ 410 if (g_ VBoxGuestFreeBSDEHTag != NULL)411 EVENTHANDLER_DEREGISTER(dev_clone, g_ VBoxGuestFreeBSDEHTag);412 413 clone_cleanup(&g_p VBoxGuestFreeBSDClones);414 415 VBoxGuestFreeBSDRemoveIRQ(pDevice, pState);422 * Reverse what we did in vgdrvFreeBSDAttach. 423 */ 424 if (g_vgdrvFreeBSDEHTag != NULL) 425 EVENTHANDLER_DEREGISTER(dev_clone, g_vgdrvFreeBSDEHTag); 426 427 clone_cleanup(&g_pvgdrvFreeBSDClones); 428 429 vgdrvFreeBSDRemoveIRQ(pDevice, pState); 416 430 417 431 if (pState->pVMMDevMemRes) … … 433 447 * @param pvState Opaque pointer to the device state. 434 448 */ 435 static int VBoxGuestFreeBSDISR(void *pvState)436 { 437 LogFlow(( DEVICE_NAME ":VBoxGuestFreeBSDISRpvState=%p\n", pvState));449 static int vgdrvFreeBSDISR(void *pvState) 450 { 451 LogFlow(("vgdrvFreeBSDISR: pvState=%p\n", pvState)); 438 452 439 453 bool fOurIRQ = VGDrvCommonISR(&g_DevExt); … … 444 458 void VGDrvNativeISRMousePollEvent(PVBOXGUESTDEVEXT pDevExt) 445 459 { 446 LogFlow(( DEVICE_NAME ":VGDrvNativeISRMousePollEvent:\n"));460 LogFlow(("VGDrvNativeISRMousePollEvent:\n")); 447 461 448 462 /* … … 459 473 * @param pvState Pointer to the state info structure. 460 474 */ 461 static int VBoxGuestFreeBSDAddIRQ(device_t pDevice, void *pvState)475 static int vgdrvFreeBSDAddIRQ(device_t pDevice, void *pvState) 462 476 { 463 477 int iResId = 0; … … 468 482 469 483 #if __FreeBSD_version >= 700000 470 rc = bus_setup_intr(pDevice, pState->pIrqRes, INTR_TYPE_BIO | INTR_MPSAFE, NULL, (driver_intr_t *) VBoxGuestFreeBSDISR, pState,484 rc = bus_setup_intr(pDevice, pState->pIrqRes, INTR_TYPE_BIO | INTR_MPSAFE, NULL, (driver_intr_t *)vgdrvFreeBSDISR, pState, 471 485 &pState->pfnIrqHandler); 472 486 #else 473 rc = bus_setup_intr(pDevice, pState->pIrqRes, INTR_TYPE_BIO, (driver_intr_t *) VBoxGuestFreeBSDISR, pState, &pState->pfnIrqHandler);487 rc = bus_setup_intr(pDevice, pState->pIrqRes, INTR_TYPE_BIO, (driver_intr_t *)vgdrvFreeBSDISR, pState, &pState->pfnIrqHandler); 474 488 #endif 475 489 … … 491 505 * @param pvState Opaque pointer to the state info structure. 492 506 */ 493 static void VBoxGuestFreeBSDRemoveIRQ(device_t pDevice, void *pvState)507 static void vgdrvFreeBSDRemoveIRQ(device_t pDevice, void *pvState) 494 508 { 495 509 struct VBoxGuestDeviceState *pState = (struct VBoxGuestDeviceState *)pvState; … … 502 516 } 503 517 504 static int VBoxGuestFreeBSDAttach(device_t pDevice)505 { 506 int rc = VINF_SUCCESS;507 int iResId = 0;508 struct VBoxGuestDeviceState *pState = NULL;518 static int vgdrvFreeBSDAttach(device_t pDevice) 519 { 520 int rc; 521 int iResId; 522 struct VBoxGuestDeviceState *pState; 509 523 510 524 cUsers = 0; … … 539 553 pState->VMMDevMemSize = rman_get_size(pState->pVMMDevMemRes); 540 554 541 pState->pMMIOBase = rman_get_virtual(pState->pVMMDevMemRes);542 pState->iVMMDevMemResId = iResId;555 pState->pMMIOBase = rman_get_virtual(pState->pVMMDevMemRes); 556 pState->iVMMDevMemResId = iResId; 543 557 if (pState->pMMIOBase) 544 558 { … … 559 573 * Add IRQ of VMMDev. 560 574 */ 561 rc = VBoxGuestFreeBSDAddIRQ(pDevice, pState);575 rc = vgdrvFreeBSDAddIRQ(pDevice, pState); 562 576 if (RT_SUCCESS(rc)) 563 577 { … … 565 579 * Configure device cloning. 566 580 */ 567 clone_setup(&g_p VBoxGuestFreeBSDClones);568 g_ VBoxGuestFreeBSDEHTag = EVENTHANDLER_REGISTER(dev_clone, VBoxGuestFreeBSDClone, 0, 1000);569 if (g_ VBoxGuestFreeBSDEHTag)581 clone_setup(&g_pvgdrvFreeBSDClones); 582 g_vgdrvFreeBSDEHTag = EVENTHANDLER_REGISTER(dev_clone, vgdrvFreeBSDClone, 0, 1000); 583 if (g_vgdrvFreeBSDEHTag) 570 584 { 571 585 printf(DEVICE_NAME ": loaded successfully\n"); … … 574 588 575 589 printf(DEVICE_NAME ": EVENTHANDLER_REGISTER(dev_clone,,,) failed\n"); 576 clone_cleanup(&g_p VBoxGuestFreeBSDClones);577 VBoxGuestFreeBSDRemoveIRQ(pDevice, pState);590 clone_cleanup(&g_pvgdrvFreeBSDClones); 591 vgdrvFreeBSDRemoveIRQ(pDevice, pState); 578 592 } 579 593 else 580 printf((DEVICE_NAME ": VbgdCommonInitDevExt failed.\n"));594 printf((DEVICE_NAME ": VGDrvCommonInitDevExt failed.\n")); 581 595 VGDrvCommonDeleteDevExt(&g_DevExt); 582 596 } 583 597 else 584 printf((DEVICE_NAME ": VBoxGuestFreeBSDAddIRQ failed.\n"));598 printf((DEVICE_NAME ": vgdrvFreeBSDAddIRQ failed.\n")); 585 599 } 586 600 else 587 printf((DEVICE_NAME ": MMIO region setup failed.\n"));601 printf((DEVICE_NAME ": MMIO region setup failed.\n")); 588 602 } 589 603 else 590 printf((DEVICE_NAME ": IOport setup failed.\n"));604 printf((DEVICE_NAME ": IOport setup failed.\n")); 591 605 592 606 RTR0Term(); … … 594 608 } 595 609 596 static int VBoxGuestFreeBSDProbe(device_t pDevice)610 static int vgdrvFreeBSDProbe(device_t pDevice) 597 611 { 598 612 if ((pci_get_vendor(pDevice) == VMMDEV_VENDORID) && (pci_get_device(pDevice) == VMMDEV_DEVICEID)) … … 602 616 } 603 617 604 static device_method_t VBoxGuestFreeBSDMethods[] =618 static device_method_t vgdrvFreeBSDMethods[] = 605 619 { 606 620 /* Device interface. */ 607 DEVMETHOD(device_probe, VBoxGuestFreeBSDProbe),608 DEVMETHOD(device_attach, VBoxGuestFreeBSDAttach),609 DEVMETHOD(device_detach, VBoxGuestFreeBSDDetach),621 DEVMETHOD(device_probe, vgdrvFreeBSDProbe), 622 DEVMETHOD(device_attach, vgdrvFreeBSDAttach), 623 DEVMETHOD(device_detach, vgdrvFreeBSDDetach), 610 624 {0,0} 611 625 }; 612 626 613 static driver_t VBoxGuestFreeBSDDriver =627 static driver_t vgdrvFreeBSDDriver = 614 628 { 615 629 DEVICE_NAME, 616 VBoxGuestFreeBSDMethods,630 vgdrvFreeBSDMethods, 617 631 sizeof(struct VBoxGuestDeviceState), 618 632 }; 619 633 620 static devclass_t VBoxGuestFreeBSDClass;621 622 DRIVER_MODULE(vboxguest, pci, VBoxGuestFreeBSDDriver, VBoxGuestFreeBSDClass, 0, 0);634 static devclass_t vgdrvFreeBSDClass; 635 636 DRIVER_MODULE(vboxguest, pci, vgdrvFreeBSDDriver, vgdrvFreeBSDClass, 0, 0); 623 637 MODULE_VERSION(vboxguest, 1); 624 638 -
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-haiku.c
r58053 r58113 70 70 #include <iprt/heap.h> 71 71 72 73 /********************************************************************************************************************************* 74 * Defined Constants And Macros * 75 *********************************************************************************************************************************/ 72 76 #define MODULE_NAME VBOXGUEST_MODULE_NAME 73 77 78 79 /********************************************************************************************************************************* 80 * Internal Functions * 81 *********************************************************************************************************************************/ 74 82 /* 75 83 * IRQ related functions. 76 84 */ 77 static void VBoxGuestHaikuRemoveIRQ(void *pvState); 78 static int VBoxGuestHaikuAddIRQ(void *pvState); 79 static int32 VBoxGuestHaikuISR(void *pvState); 80 81 /* 82 * Available functions for kernel drivers. 83 */ 84 DECLVBGL(int) VBoxGuestHaikuServiceCall(void *pvSession, unsigned uCmd, void *pvData, size_t cbData, size_t *pcbDataReturned); 85 DECLVBGL(void *) VBoxGuestHaikuServiceOpen(uint32_t *pu32Version); 86 DECLVBGL(int) VBoxGuestHaikuServiceClose(void *pvSession); 87 DECLVBGL(void *) VBoxGuestIDCOpen(uint32_t *pu32Version); 88 DECLVBGL(int) VBoxGuestIDCClose(void *pvSession); 89 DECLVBGL(int) VBoxGuestIDCCall(void *pvSession, unsigned iCmd, void *pvData, size_t cbData, size_t *pcbDataReturned); 90 85 static void vgdrvHaikuRemoveIRQ(void *pvState); 86 static int vgdrvHaikuAddIRQ(void *pvState); 87 static int32 vgdrvHaikuISR(void *pvState); 88 89 90 /********************************************************************************************************************************* 91 * Global Variables * 92 *********************************************************************************************************************************/ 91 93 static status_t std_ops(int32 op, ...); 92 94 … … 96 98 97 99 /** List of cloned device. Managed by the kernel. */ 98 //static struct clonedevs *g_p VBoxGuestHaikuClones;100 //static struct clonedevs *g_pvgdrvHaikuClones; 99 101 /** The dev_clone event handler tag. */ 100 //static eventhandler_tag g_ VBoxGuestHaikuEHTag;102 //static eventhandler_tag g_vgdrvHaikuEHTag; 101 103 /** selinfo structure used for polling. */ 102 104 //static struct selinfo g_SelInfo; … … 213 215 * DEVFS event handler. 214 216 */ 215 static void VBoxGuestHaikuClone(void *pvArg, struct ucred *pCred, char *pszName, int cchName, struct cdev **ppDev)217 static void vgdrvHaikuClone(void *pvArg, struct ucred *pCred, char *pszName, int cchName, struct cdev **ppDev) 216 218 { 217 219 int iUnit; 218 220 int rc; 219 221 220 Log((" VBoxGuestHaikuClone: pszName=%s ppDev=%p\n", pszName, ppDev));222 Log(("vgdrvHaikuClone: pszName=%s ppDev=%p\n", pszName, ppDev)); 221 223 222 224 /* … … 232 234 if (iUnit >= 256) 233 235 { 234 Log((" VBoxGuestHaikuClone: iUnit=%d >= 256 - rejected\n", iUnit));236 Log(("vgdrvHaikuClone: iUnit=%d >= 256 - rejected\n", iUnit)); 235 237 return; 236 238 } 237 239 238 Log((" VBoxGuestHaikuClone: pszName=%s iUnit=%d\n", pszName, iUnit));239 240 rc = clone_create(&g_p VBoxGuestHaikuClones, &g_VBoxGuestHaikuDeviceHooks, &iUnit, ppDev, 0);241 Log((" VBoxGuestHaikuClone: clone_create -> %d; iUnit=%d\n", rc, iUnit));240 Log(("vgdrvHaikuClone: pszName=%s iUnit=%d\n", pszName, iUnit)); 241 242 rc = clone_create(&g_pvgdrvHaikuClones, &g_vgdrvHaikuDeviceHooks, &iUnit, ppDev, 0); 243 Log(("vgdrvHaikuClone: clone_create -> %d; iUnit=%d\n", rc, iUnit)); 242 244 if (rc) 243 245 { 244 *ppDev = make_dev(&g_ VBoxGuestHaikuDeviceHooks,246 *ppDev = make_dev(&g_vgdrvHaikuDeviceHooks, 245 247 iUnit, 246 248 UID_ROOT, … … 252 254 dev_ref(*ppDev); 253 255 (*ppDev)->si_flags |= SI_CHEAPCLONE; 254 Log((" VBoxGuestHaikuClone: Created *ppDev=%p iUnit=%d si_drv1=%p si_drv2=%p\n",256 Log(("vgdrvHaikuClone: Created *ppDev=%p iUnit=%d si_drv1=%p si_drv2=%p\n", 255 257 *ppDev, iUnit, (*ppDev)->si_drv1, (*ppDev)->si_drv2)); 256 258 (*ppDev)->si_drv1 = (*ppDev)->si_drv2 = NULL; 257 259 } 258 260 else 259 Log((" VBoxGuestHaikuClone: make_dev iUnit=%d failed\n", iUnit));261 Log(("vgdrvHaikuClone: make_dev iUnit=%d failed\n", iUnit)); 260 262 } 261 263 else 262 Log((" VBoxGuestHaikuClone: Existing *ppDev=%p iUnit=%d si_drv1=%p si_drv2=%p\n",264 Log(("vgdrvHaikuClone: Existing *ppDev=%p iUnit=%d si_drv1=%p si_drv2=%p\n", 263 265 *ppDev, iUnit, (*ppDev)->si_drv1, (*ppDev)->si_drv2)); 264 266 } … … 266 268 267 269 268 static status_t VBoxGuestHaikuDetach(void)270 static status_t vgdrvHaikuDetach(void) 269 271 { 270 272 struct VBoxGuestDeviceState *pState = &sState; … … 274 276 275 277 /* 276 * Reverse what we did in VBoxGuestHaikuAttach.278 * Reverse what we did in vgdrvHaikuAttach. 277 279 */ 278 VBoxGuestHaikuRemoveIRQ(pState);280 vgdrvHaikuRemoveIRQ(pState); 279 281 280 282 if (pState->iVMMDevMemAreaId) … … 303 305 * @param pvState Opaque pointer to the device state. 304 306 */ 305 static int32 VBoxGuestHaikuISR(void *pvState)306 { 307 LogFlow((MODULE_NAME ": VBoxGuestHaikuISR pvState=%p\n", pvState));307 static int32 vgdrvHaikuISR(void *pvState) 308 { 309 LogFlow((MODULE_NAME ":vgdrvHaikuISR pvState=%p\n", pvState)); 308 310 309 311 bool fOurIRQ = VGDrvCommonISR(&g_DevExt); … … 316 318 void VGDrvNativeISRMousePollEvent(PVBOXGUESTDEVEXT pDevExt) 317 319 { 318 LogFlow(( MODULE_NAME ":VGDrvNativeISRMousePollEvent:\n"));320 LogFlow(("VGDrvNativeISRMousePollEvent:\n")); 319 321 320 322 status_t err = B_OK; … … 349 351 * @param pvState Pointer to the state info structure. 350 352 */ 351 static int VBoxGuestHaikuAddIRQ(void *pvState)353 static int vgdrvHaikuAddIRQ(void *pvState) 352 354 { 353 355 status_t err; … … 356 358 AssertReturn(pState, VERR_INVALID_PARAMETER); 357 359 358 err = install_io_interrupt_handler(pState->iIrqResId, VBoxGuestHaikuISR, pState, 0);360 err = install_io_interrupt_handler(pState->iIrqResId, vgdrvHaikuISR, pState, 0); 359 361 if (err == B_OK) 360 362 return VINF_SUCCESS; … … 368 370 * @param pvState Opaque pointer to the state info structure. 369 371 */ 370 static void VBoxGuestHaikuRemoveIRQ(void *pvState)372 static void vgdrvHaikuRemoveIRQ(void *pvState) 371 373 { 372 374 struct VBoxGuestDeviceState *pState = (struct VBoxGuestDeviceState *)pvState; 373 375 AssertPtr(pState); 374 376 375 remove_io_interrupt_handler(pState->iIrqResId, VBoxGuestHaikuISR, pState);376 } 377 378 379 static status_t VBoxGuestHaikuAttach(const pci_info *pDevice)377 remove_io_interrupt_handler(pState->iIrqResId, vgdrvHaikuISR, pState); 378 } 379 380 381 static status_t vgdrvHaikuAttach(const pci_info *pDevice) 380 382 { 381 383 status_t status; 382 int rc = VINF_SUCCESS;383 int iResId = 0;384 int rc; 385 int iResId; 384 386 struct VBoxGuestDeviceState *pState = &sState; 385 387 static const char *const s_apszGroups[] = VBOX_LOGGROUP_NAMES; … … 396 398 if (RT_FAILURE(rc)) 397 399 { 398 /** @todo r=ramshankar: use dprintf here. */ 399 LogFunc(("RTR0Init failed.\n")); 400 dprintf(MODULE_NAME ": RTR0Init failed: %d\n", rc); 400 401 return ENXIO; 401 402 } 402 403 403 rc = RTSpinlockCreate(&g_Spinlock, RTSPINLOCK_FLAGS_INTERRUPT_SAFE, " VBoxGuestHaiku");404 rc = RTSpinlockCreate(&g_Spinlock, RTSPINLOCK_FLAGS_INTERRUPT_SAFE, "vgdrvHaiku"); 404 405 if (RT_FAILURE(rc)) 405 406 { 406 LogRel((" VBoxGuestHaikuAttach: RTSpinlock create failed. rc=%Rrc\n", rc));407 LogRel(("vgdrvHaikuAttach: RTSpinlock create failed. rc=%Rrc\n", rc)); 407 408 return ENXIO; 408 409 } … … 462 463 */ 463 464 pState->iIrqResId = pDevice->u.h0.interrupt_line; 464 rc = VBoxGuestHaikuAddIRQ(pState);465 rc = vgdrvHaikuAddIRQ(pState); 465 466 if (RT_SUCCESS(rc)) 466 467 { … … 469 470 } 470 471 471 LogRel((MODULE_NAME ": VbgdCommonInitDevExt failed.\n"));472 LogRel((MODULE_NAME ": VGDrvCommonInitDevExt failed.\n")); 472 473 VGDrvCommonDeleteDevExt(&g_DevExt); 473 474 } 474 475 else 475 LogRel((MODULE_NAME ": VBoxGuestHaikuAddIRQ failed.\n"));476 LogRel((MODULE_NAME ": vgdrvHaikuAddIRQ failed.\n")); 476 477 } 477 478 else 478 LogRel((MODULE_NAME ": MMIO region setup failed.\n"));479 LogRel((MODULE_NAME ": MMIO region setup failed.\n")); 479 480 } 480 481 else 481 LogRel((MODULE_NAME ": IOport setup failed.\n"));482 LogRel((MODULE_NAME ": IOport setup failed.\n")); 482 483 483 484 RTR0Term(); … … 486 487 487 488 488 static status_t VBoxGuestHaikuProbe(pci_info *pDevice) 489 { 490 if ((pDevice->vendor_id == VMMDEV_VENDORID) && (pDevice->device_id == VMMDEV_DEVICEID)) 489 static status_t vgdrvHaikuProbe(pci_info *pDevice) 490 { 491 if ( pDevice->vendor_id == VMMDEV_VENDORID 492 && pDevice->device_id == VMMDEV_DEVICEID) 491 493 return B_OK; 492 494 … … 507 509 while ((*gPCI->get_nth_pci_info)(ix++, &info) == B_OK) 508 510 { 509 if ( VBoxGuestHaikuProbe(&info) == 0)511 if (vgdrvHaikuProbe(&info) == 0) 510 512 { 511 513 /* We found it */ 512 err = VBoxGuestHaikuAttach(&info);514 err = vgdrvHaikuAttach(&info); 513 515 return err; 514 516 } … … 521 523 void uninit_module(void) 522 524 { 523 VBoxGuestHaikuDetach();525 vgdrvHaikuDetach(); 524 526 put_module(B_PCI_MODULE_NAME); 525 527 } -
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-haiku.h
r58053 r58113 224 224 #endif 225 225 226 #endif /* ___VBoxGuest_haiku_h */227 226 #endif /* !___VBoxGuest_haiku_h */ 227 -
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-linux.c
r58089 r58113 72 72 * Internal Functions * 73 73 *********************************************************************************************************************************/ 74 static void vboxguestLinuxTermPci(struct pci_dev *pPciDev); 75 static int vboxguestLinuxModInit(void); 76 static void vboxguestLinuxModExit(void); 77 static int vboxguestLinuxOpen(struct inode *pInode, struct file *pFilp); 78 static int vboxguestLinuxRelease(struct inode *pInode, struct file *pFilp); 74 static void vgdrvLinuxTermPci(struct pci_dev *pPciDev); 75 static int vgdrvLinuxProbePci(struct pci_dev *pPciDev, const struct pci_device_id *id); 76 static int vgdrvLinuxModInit(void); 77 static void vgdrvLinuxModExit(void); 78 static int vgdrvLinuxOpen(struct inode *pInode, struct file *pFilp); 79 static int vgdrvLinuxRelease(struct inode *pInode, struct file *pFilp); 79 80 #ifdef HAVE_UNLOCKED_IOCTL 80 static long v boxguestLinuxIOCtl(struct file *pFilp, unsigned int uCmd, unsigned long ulArg);81 static long vgdrvLinuxIOCtl(struct file *pFilp, unsigned int uCmd, unsigned long ulArg); 81 82 #else 82 static int v boxguestLinuxIOCtl(struct inode *pInode, struct file *pFilp, unsigned int uCmd, unsigned long ulArg);83 #endif 84 static int v boxguestFAsync(int fd, struct file *pFile, int fOn);85 static unsigned int v boxguestPoll(struct file *pFile, poll_table *pPt);86 static ssize_t v boxguestRead(struct file *pFile, char *pbBuf, size_t cbRead, loff_t *poff);83 static int vgdrvLinuxIOCtl(struct inode *pInode, struct file *pFilp, unsigned int uCmd, unsigned long ulArg); 84 #endif 85 static int vgdrvLinuxFAsync(int fd, struct file *pFile, int fOn); 86 static unsigned int vgdrvLinuxPoll(struct file *pFile, poll_table *pPt); 87 static ssize_t vgdrvLinuxRead(struct file *pFile, char *pbBuf, size_t cbRead, loff_t *poff); 87 88 88 89 … … 141 142 { 142 143 owner: THIS_MODULE, 143 open: v boxguestLinuxOpen,144 release: v boxguestLinuxRelease,144 open: vgdrvLinuxOpen, 145 release: vgdrvLinuxRelease, 145 146 #ifdef HAVE_UNLOCKED_IOCTL 146 unlocked_ioctl: v boxguestLinuxIOCtl,147 unlocked_ioctl: vgdrvLinuxIOCtl, 147 148 #else 148 ioctl: v boxguestLinuxIOCtl,149 #endif 150 fasync: v boxguestFAsync,151 read: v boxguestRead,152 poll: v boxguestPoll,149 ioctl: vgdrvLinuxIOCtl, 150 #endif 151 fasync: vgdrvLinuxFAsync, 152 read: vgdrvLinuxRead, 153 poll: vgdrvLinuxPoll, 153 154 llseek: no_llseek, 154 155 }; … … 168 169 { 169 170 owner: THIS_MODULE, 170 open: v boxguestLinuxOpen,171 release: v boxguestLinuxRelease,171 open: vgdrvLinuxOpen, 172 release: vgdrvLinuxRelease, 172 173 #ifdef HAVE_UNLOCKED_IOCTL 173 unlocked_ioctl: v boxguestLinuxIOCtl,174 unlocked_ioctl: vgdrvLinuxIOCtl, 174 175 #else 175 ioctl: v boxguestLinuxIOCtl,176 ioctl: vgdrvLinuxIOCtl, 176 177 #endif 177 178 }; … … 201 202 } 202 203 }; 204 203 205 MODULE_DEVICE_TABLE(pci, g_VBoxGuestPciId); 204 206 207 /** Structure for registering the PCI driver. */ 208 static struct pci_driver g_PciDriver = 209 { 210 name: DRIVER_NAME, 211 id_table: g_VBoxGuestPciId, 212 probe: vgdrvLinuxProbePci, 213 remove: vgdrvLinuxTermPci 214 }; 215 205 216 static PVBOXGUESTSESSION g_pKernelSession = NULL; 217 218 206 219 207 220 /** … … 211 224 * @param rc supdrv error code (SUPDRV_ERR_* defines). 212 225 */ 213 static int v boxguestLinuxConvertToNegErrno(int rc)226 static int vgdrvLinuxConvertToNegErrno(int rc) 214 227 { 215 228 if ( rc > -1000 … … 234 247 235 248 236 237 249 /** 238 250 * Does the PCI detection and init of the device. … … 240 252 * @returns 0 on success, negated errno on failure. 241 253 */ 242 static int vboxguestLinuxProbePci(struct pci_dev *pPciDev, 243 const struct pci_device_id *id) 244 { 245 int rc; 254 static int vgdrvLinuxProbePci(struct pci_dev *pPciDev, const struct pci_device_id *id) 255 { 256 int rc; 246 257 247 258 NOREF(id); … … 299 310 * Clean up the usage of the PCI device. 300 311 */ 301 static void v boxguestLinuxTermPci(struct pci_dev *pPciDev)312 static void vgdrvLinuxTermPci(struct pci_dev *pPciDev) 302 313 { 303 314 g_pPciDev = NULL; … … 316 327 317 328 318 /** Structure for registering the PCI driver. */319 static struct pci_driver g_PciDriver =320 {321 name: DRIVER_NAME,322 id_table: g_VBoxGuestPciId,323 probe: vboxguestLinuxProbePci,324 remove: vboxguestLinuxTermPci325 };326 327 328 329 /** 329 330 * Interrupt service routine. … … 337 338 */ 338 339 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19) && !defined(DOXYGEN_RUNNING) 339 static irqreturn_t v boxguestLinuxISR(int iIrq, void *pvDevId)340 static irqreturn_t vgdrvLinuxISR(int iIrq, void *pvDevId) 340 341 #else 341 static irqreturn_t v boxguestLinuxISR(int iIrq, void *pvDevId, struct pt_regs *pRegs)342 static irqreturn_t vgdrvLinuxISR(int iIrq, void *pvDevId, struct pt_regs *pRegs) 342 343 #endif 343 344 { … … 350 351 * Registers the ISR and initializes the poll wait queue. 351 352 */ 352 static int __init v boxguestLinuxInitISR(void)353 static int __init vgdrvLinuxInitISR(void) 353 354 { 354 355 int rc; … … 356 357 init_waitqueue_head(&g_PollEventQueue); 357 358 rc = request_irq(g_pPciDev->irq, 358 v boxguestLinuxISR,359 vgdrvLinuxISR, 359 360 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20) 360 361 IRQF_SHARED, … … 376 377 * Deregisters the ISR. 377 378 */ 378 static void v boxguestLinuxTermISR(void)379 static void vgdrvLinuxTermISR(void) 379 380 { 380 381 free_irq(g_pPciDev->irq, &g_DevExt); … … 383 384 384 385 #ifdef VBOXGUEST_WITH_INPUT_DRIVER 385 /** Calls the kernel IOCtl to report mouse status to the host on behalf of 386 * our kernel session. */ 387 static int vboxguestLinuxSetMouseStatus(uint32_t fStatus) 386 387 /** 388 * Reports the mouse integration status to the host. 389 * 390 * Calls the kernel IOCtl to report mouse status to the host on behalf of 391 * our kernel session. 392 * 393 * @param fStatus The mouse status to report. 394 */ 395 static int vgdrvLinuxSetMouseStatus(uint32_t fStatus) 388 396 { 389 397 return VGDrvCommonIoCtl(VBOXGUEST_IOCTL_SET_MOUSE_STATUS, &g_DevExt, g_pKernelSession, &fStatus, sizeof(fStatus), NULL); … … 391 399 392 400 393 /** Called when the input device is first opened. Sets up absolute reporting. 401 /** 402 * Called when the input device is first opened. 403 * 404 * Sets up absolute mouse reporting. 394 405 */ 395 406 static int vboxguestOpenInputDevice(struct input_dev *pDev) 396 407 { 397 int rc = vboxguestLinuxSetMouseStatus(VMMDEV_MOUSE_GUEST_CAN_ABSOLUTE | VMMDEV_MOUSE_NEW_PROTOCOL);408 int rc = vgdrvLinuxSetMouseStatus(VMMDEV_MOUSE_GUEST_CAN_ABSOLUTE | VMMDEV_MOUSE_NEW_PROTOCOL); 398 409 if (RT_FAILURE(rc)) 399 410 return ENODEV; … … 403 414 404 415 405 /** Called if all open handles to the device are closed, disables absolute 406 * reporting. */ 416 /** 417 * Called if all open handles to the input device are closed. 418 * 419 * Disables absolute reporting. 420 */ 407 421 static void vboxguestCloseInputDevice(struct input_dev *pDev) 408 422 { 409 423 NOREF(pDev); 410 v boxguestLinuxSetMouseStatus(0);424 vgdrvLinuxSetMouseStatus(0); 411 425 } 412 426 … … 415 429 * Creates the kernel input device. 416 430 */ 417 static int __init vboxguestLinuxCreateInputDevice(void) 418 { 419 int rc; 420 421 rc = VbglGRAlloc((VMMDevRequestHeader **)&g_pMouseStatusReq, 422 sizeof(*g_pMouseStatusReq), 423 VMMDevReq_GetMouseStatus); 424 if (RT_FAILURE(rc)) 425 return -ENOMEM; 426 g_pInputDevice = input_allocate_device(); 427 if (!g_pInputDevice) 428 { 431 static int __init vgdrvLinuxCreateInputDevice(void) 432 { 433 int rc = VbglGRAlloc((VMMDevRequestHeader **)&g_pMouseStatusReq, sizeof(*g_pMouseStatusReq), VMMDevReq_GetMouseStatus); 434 if (RT_SUCCESS(rc)) 435 { 436 g_pInputDevice = input_allocate_device(); 437 if (g_pInputDevice) 438 { 439 g_pInputDevice->id.bustype = BUS_PCI; 440 g_pInputDevice->id.vendor = VMMDEV_VENDORID; 441 g_pInputDevice->id.product = VMMDEV_DEVICEID; 442 g_pInputDevice->id.version = VBOX_SHORT_VERSION; 443 g_pInputDevice->open = vboxguestOpenInputDevice; 444 g_pInputDevice->close = vboxguestCloseInputDevice; 445 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 22) 446 g_pInputDevice->cdev.dev = &g_pPciDev->dev; 447 # else 448 g_pInputDevice->dev.parent = &g_pPciDev->dev; 449 # endif 450 rc = input_register_device(g_pInputDevice); 451 if (rc == 0) 452 { 453 /* Do what one of our competitors apparently does as that works. */ 454 ASMBitSet(g_pInputDevice->evbit, EV_ABS); 455 ASMBitSet(g_pInputDevice->evbit, EV_KEY); 456 # ifdef EV_SYN 457 ASMBitSet(g_pInputDevice->evbit, EV_SYN); 458 # endif 459 input_set_abs_params(g_pInputDevice, ABS_X, VMMDEV_MOUSE_RANGE_MIN, VMMDEV_MOUSE_RANGE_MAX, 0, 0); 460 input_set_abs_params(g_pInputDevice, ABS_Y, VMMDEV_MOUSE_RANGE_MIN, VMMDEV_MOUSE_RANGE_MAX, 0, 0); 461 ASMBitSet(g_pInputDevice->keybit, BTN_MOUSE); 462 /** @todo this string should be in a header file somewhere. */ 463 g_pInputDevice->name = "VirtualBox mouse integration"; 464 return 0; 465 } 466 467 input_free_device(g_pInputDevice); 468 } 469 else 470 rc = -ENOMEM; 429 471 VbglGRFree(&g_pMouseStatusReq->header); 430 return -ENOMEM; 431 } 432 g_pInputDevice->id.bustype = BUS_PCI; 433 g_pInputDevice->id.vendor = VMMDEV_VENDORID; 434 g_pInputDevice->id.product = VMMDEV_DEVICEID; 435 g_pInputDevice->id.version = VBOX_SHORT_VERSION; 436 g_pInputDevice->open = vboxguestOpenInputDevice; 437 g_pInputDevice->close = vboxguestCloseInputDevice; 438 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 22) 439 g_pInputDevice->cdev.dev = &g_pPciDev->dev; 440 # else 441 g_pInputDevice->dev.parent = &g_pPciDev->dev; 442 # endif 443 { 444 int rc = input_register_device(g_pInputDevice); 445 if (rc) 446 { 447 VbglGRFree(&g_pMouseStatusReq->header); 448 input_free_device(g_pInputDevice); 449 return rc; 450 } 451 } 452 /* Do what one of our competitors apparently does as that works. */ 453 ASMBitSet(g_pInputDevice->evbit, EV_ABS); 454 ASMBitSet(g_pInputDevice->evbit, EV_KEY); 455 # ifdef EV_SYN 456 ASMBitSet(g_pInputDevice->evbit, EV_SYN); 457 # endif 458 input_set_abs_params(g_pInputDevice, ABS_X, VMMDEV_MOUSE_RANGE_MIN, 459 VMMDEV_MOUSE_RANGE_MAX, 0, 0); 460 input_set_abs_params(g_pInputDevice, ABS_Y, VMMDEV_MOUSE_RANGE_MIN, 461 VMMDEV_MOUSE_RANGE_MAX, 0, 0); 462 ASMBitSet(g_pInputDevice->keybit, BTN_MOUSE); 463 /** @todo this string should be in a header file somewhere. */ 464 g_pInputDevice->name = "VirtualBox mouse integration"; 465 return 0; 472 g_pMouseStatusReq = NULL; 473 } 474 else 475 rc = -ENOMEM; 476 return rc; 466 477 } 467 478 … … 470 481 * Terminates the kernel input device. 471 482 */ 472 static void v boxguestLinuxTermInputDevice(void)483 static void vgdrvLinuxTermInputDevice(void) 473 484 { 474 485 VbglGRFree(&g_pMouseStatusReq->header); 486 g_pMouseStatusReq = NULL; 487 475 488 /* See documentation of input_register_device(): input_free_device() 476 489 * should not be called after a device has been registered. */ 477 490 input_unregister_device(g_pInputDevice); 478 491 } 492 479 493 #endif /* VBOXGUEST_WITH_INPUT_DRIVER */ 480 494 … … 485 499 * @returns 0 on success, negated errno on failure. 486 500 */ 487 static int __init vboxguestLinuxInitDeviceNodes(void) 488 { 489 int rc; 490 501 static int __init vgdrvLinuxInitDeviceNodes(void) 502 { 491 503 /* 492 504 * The full feature device node. 493 505 */ 494 rc = misc_register(&g_MiscDevice); 495 if (rc) 496 { 497 LogRel((DEVICE_NAME ": misc_register failed for %s (rc=%d)\n", DEVICE_NAME, rc)); 498 return rc; 499 } 500 501 /* 502 * The device node intended to be accessible by all users. 503 */ 504 rc = misc_register(&g_MiscDeviceUser); 505 if (rc) 506 { 506 int rc = misc_register(&g_MiscDevice); 507 if (!rc) 508 { 509 /* 510 * The device node intended to be accessible by all users. 511 */ 512 rc = misc_register(&g_MiscDeviceUser); 513 if (!rc) 514 return 0; 507 515 LogRel((DEVICE_NAME ": misc_register failed for %s (rc=%d)\n", DEVICE_NAME_USER, rc)); 508 516 misc_deregister(&g_MiscDevice); 509 return rc;510 }511 512 return 0;517 } 518 else 519 LogRel((DEVICE_NAME ": misc_register failed for %s (rc=%d)\n", DEVICE_NAME, rc)); 520 return rc; 513 521 } 514 522 … … 517 525 * Deregisters the device nodes. 518 526 */ 519 static void v boxguestLinuxTermDeviceNodes(void)527 static void vgdrvLinuxTermDeviceNodes(void) 520 528 { 521 529 misc_deregister(&g_MiscDevice); … … 529 537 * @returns appropriate status code. 530 538 */ 531 static int __init v boxguestLinuxModInit(void)539 static int __init vgdrvLinuxModInit(void) 532 540 { 533 541 static const char * const s_apszGroups[] = VBOX_LOGGROUP_NAMES; … … 575 583 * Register the interrupt service routine for it. 576 584 */ 577 rc = v boxguestLinuxInitISR();585 rc = vgdrvLinuxInitISR(); 578 586 if (rc >= 0) 579 587 { … … 611 619 */ 612 620 #ifdef VBOXGUEST_WITH_INPUT_DRIVER 613 rc = v boxguestLinuxCreateInputDevice();621 rc = vgdrvLinuxCreateInputDevice(); 614 622 if (rc >= 0) 615 623 { … … 618 626 * Finally, create the device nodes. 619 627 */ 620 rc = v boxguestLinuxInitDeviceNodes();628 rc = vgdrvLinuxInitDeviceNodes(); 621 629 if (rc >= 0) 622 630 { … … 631 639 /* bail out */ 632 640 #ifdef VBOXGUEST_WITH_INPUT_DRIVER 633 v boxguestLinuxTermInputDevice();641 vgdrvLinuxTermInputDevice(); 634 642 } 635 643 else … … 645 653 else 646 654 { 647 LogRel((DEVICE_NAME ": V bgdCommonInitDevExt failed with rc=%Rrc\n", rc));655 LogRel((DEVICE_NAME ": VGDrvCommonInitDevExt failed with rc=%Rrc\n", rc)); 648 656 rc = RTErrConvertFromErrno(rc); 649 657 } 650 v boxguestLinuxTermISR();658 vgdrvLinuxTermISR(); 651 659 } 652 660 } … … 667 675 * Unload the module. 668 676 */ 669 static void __exit v boxguestLinuxModExit(void)677 static void __exit vgdrvLinuxModExit(void) 670 678 { 671 679 /* 672 680 * Inverse order of init. 673 681 */ 674 v boxguestLinuxTermDeviceNodes();682 vgdrvLinuxTermDeviceNodes(); 675 683 #ifdef VBOXGUEST_WITH_INPUT_DRIVER 676 v boxguestLinuxTermInputDevice();684 vgdrvLinuxTermInputDevice(); 677 685 #endif 678 686 VGDrvCommonCloseSession(&g_DevExt, g_pKernelSession); 679 687 VGDrvCommonDeleteDevExt(&g_DevExt); 680 v boxguestLinuxTermISR();688 vgdrvLinuxTermISR(); 681 689 pci_unregister_driver(&g_PciDriver); 682 690 RTLogDestroy(RTLogRelSetDefaultInstance(NULL)); … … 692 700 * @param pFilp Associated file pointer. 693 701 */ 694 static int v boxguestLinuxOpen(struct inode *pInode, struct file *pFilp)702 static int vgdrvLinuxOpen(struct inode *pInode, struct file *pFilp) 695 703 { 696 704 int rc; … … 710 718 } 711 719 712 Log(("vboxguestLinuxOpen: g_DevExt=%p pSession=%p rc=%d/%d (pid=%d/%d %s)\n", 713 &g_DevExt, pSession, rc, vboxguestLinuxConvertToNegErrno(rc), 714 RTProcSelf(), current->pid, current->comm)); 715 return vboxguestLinuxConvertToNegErrno(rc); 720 Log(("vgdrvLinuxOpen: g_DevExt=%p pSession=%p rc=%d/%d (pid=%d/%d %s)\n", 721 &g_DevExt, pSession, rc, vgdrvLinuxConvertToNegErrno(rc), RTProcSelf(), current->pid, current->comm)); 722 return vgdrvLinuxConvertToNegErrno(rc); 716 723 } 717 724 … … 723 730 * @param pFilp Associated file pointer. 724 731 */ 725 static int v boxguestLinuxRelease(struct inode *pInode, struct file *pFilp)726 { 727 Log(("v boxguestLinuxRelease: pFilp=%p pSession=%p pid=%d/%d %s\n",732 static int vgdrvLinuxRelease(struct inode *pInode, struct file *pFilp) 733 { 734 Log(("vgdrvLinuxRelease: pFilp=%p pSession=%p pid=%d/%d %s\n", 728 735 pFilp, pFilp->private_data, RTProcSelf(), current->pid, current->comm)); 729 736 … … 731 738 /* This housekeeping was needed in older kernel versions to ensure that 732 739 * the file pointer didn't get left on the polling queue. */ 733 v boxguestFAsync(-1, pFilp, 0);740 vgdrvLinuxFAsync(-1, pFilp, 0); 734 741 #endif 735 742 VGDrvCommonCloseSession(&g_DevExt, (PVBOXGUESTSESSION)pFilp->private_data); … … 748 755 */ 749 756 #ifdef HAVE_UNLOCKED_IOCTL 750 static long v boxguestLinuxIOCtl(struct file *pFilp, unsigned int uCmd, unsigned long ulArg)757 static long vgdrvLinuxIOCtl(struct file *pFilp, unsigned int uCmd, unsigned long ulArg) 751 758 #else 752 static int v boxguestLinuxIOCtl(struct inode *pInode, struct file *pFilp, unsigned int uCmd, unsigned long ulArg)759 static int vgdrvLinuxIOCtl(struct inode *pInode, struct file *pFilp, unsigned int uCmd, unsigned long ulArg) 753 760 #endif 754 761 { … … 760 767 uint64_t au64Buf[32/sizeof(uint64_t)]; 761 768 762 Log6(("v boxguestLinuxIOCtl: pFilp=%p uCmd=%#x ulArg=%p pid=%d/%d\n", pFilp, uCmd, (void *)ulArg, RTProcSelf(), current->pid));769 Log6(("vgdrvLinuxIOCtl: pFilp=%p uCmd=%#x ulArg=%p pid=%d/%d\n", pFilp, uCmd, (void *)ulArg, RTProcSelf(), current->pid)); 763 770 764 771 /* … … 810 817 else 811 818 { 812 Log(("v boxguestLinuxIOCtl: pFilp=%p uCmd=%#x ulArg=%p failed, rc=%d\n", pFilp, uCmd, (void *)ulArg, rc));819 Log(("vgdrvLinuxIOCtl: pFilp=%p uCmd=%#x ulArg=%p failed, rc=%d\n", pFilp, uCmd, (void *)ulArg, rc)); 813 820 rc = -rc; Assert(rc > 0); /* Positive returns == negated VBox error status codes. */ 814 821 } … … 822 829 RTMemFree(pvBufFree); 823 830 824 Log6(("v boxguestLinuxIOCtl: returns %d (pid=%d/%d)\n", rc, RTProcSelf(), current->pid));831 Log6(("vgdrvLinuxIOCtl: returns %d (pid=%d/%d)\n", rc, RTProcSelf(), current->pid)); 825 832 return rc; 826 833 } … … 836 843 * @param fOn On/off indicator. 837 844 */ 838 static int v boxguestFAsync(int fd, struct file *pFile, int fOn)845 static int vgdrvLinuxFAsync(int fd, struct file *pFile, int fOn) 839 846 { 840 847 return fasync_helper(fd, pFile, fOn, &g_pFAsyncQueue); … … 856 863 * interface instead. 857 864 */ 858 static unsigned int v boxguestPoll(struct file *pFile, poll_table *pPt)865 static unsigned int vgdrvLinuxPoll(struct file *pFile, poll_table *pPt) 859 866 { 860 867 PVBOXGUESTSESSION pSession = (PVBOXGUESTSESSION)pFile->private_data; … … 880 887 * @remarks This is probably not really used as X11 lets the driver do its own 881 888 * event reading. The poll condition is therefore also cleared when we 882 * see VMMDevReq_GetMouseStatus in VbgdCommonIoCtl_VMMRequest.883 */ 884 static ssize_t v boxguestRead(struct file *pFile, char *pbBuf, size_t cbRead, loff_t *poff)889 * see VMMDevReq_GetMouseStatus in vgdrvIoCtl_VMMRequest. 890 */ 891 static ssize_t vgdrvLinuxRead(struct file *pFile, char *pbBuf, size_t cbRead, loff_t *poff) 885 892 { 886 893 PVBOXGUESTSESSION pSession = (PVBOXGUESTSESSION)pFile->private_data; … … 951 958 952 959 /** log and dbg_log parameter setter. */ 953 static int v boxguestLinuxParamLogGrpSet(const char *pszValue, struct kernel_param *pParam)960 static int vgdrvLinuxParamLogGrpSet(const char *pszValue, struct kernel_param *pParam) 954 961 { 955 962 if (g_fLoggerCreated) … … 966 973 967 974 /** log and dbg_log parameter getter. */ 968 static int v boxguestLinuxParamLogGrpGet(char *pszBuf, struct kernel_param *pParam)975 static int vgdrvLinuxParamLogGrpGet(char *pszBuf, struct kernel_param *pParam) 969 976 { 970 977 PRTLOGGER pLogger = pParam->name[0] == 'd' ? RTLogDefaultInstance() : RTLogRelGetDefaultInstance(); … … 977 984 978 985 /** log and dbg_log_flags parameter setter. */ 979 static int v boxguestLinuxParamLogFlagsSet(const char *pszValue, struct kernel_param *pParam)986 static int vgdrvLinuxParamLogFlagsSet(const char *pszValue, struct kernel_param *pParam) 980 987 { 981 988 if (g_fLoggerCreated) … … 991 998 992 999 /** log and dbg_log_flags parameter getter. */ 993 static int v boxguestLinuxParamLogFlagsGet(char *pszBuf, struct kernel_param *pParam)1000 static int vgdrvLinuxParamLogFlagsGet(char *pszBuf, struct kernel_param *pParam) 994 1001 { 995 1002 PRTLOGGER pLogger = pParam->name[0] == 'd' ? RTLogDefaultInstance() : RTLogRelGetDefaultInstance(); … … 1002 1009 1003 1010 /** log and dbg_log_dest parameter setter. */ 1004 static int v boxguestLinuxParamLogDstSet(const char *pszValue, struct kernel_param *pParam)1011 static int vgdrvLinuxParamLogDstSet(const char *pszValue, struct kernel_param *pParam) 1005 1012 { 1006 1013 if (g_fLoggerCreated) … … 1016 1023 1017 1024 /** log and dbg_log_dest parameter getter. */ 1018 static int v boxguestLinuxParamLogDstGet(char *pszBuf, struct kernel_param *pParam)1025 static int vgdrvLinuxParamLogDstGet(char *pszBuf, struct kernel_param *pParam) 1019 1026 { 1020 1027 PRTLOGGER pLogger = pParam->name[0] == 'd' ? RTLogDefaultInstance() : RTLogRelGetDefaultInstance(); … … 1027 1034 1028 1035 /** r3_log_to_host parameter setter. */ 1029 static int v boxguestLinuxParamR3LogToHostSet(const char *pszValue, struct kernel_param *pParam)1036 static int vgdrvLinuxParamR3LogToHostSet(const char *pszValue, struct kernel_param *pParam) 1030 1037 { 1031 1038 if ( pszValue == NULL … … 1045 1052 1046 1053 /** r3_log_to_host parameter getter. */ 1047 static int v boxguestLinuxParamR3LogToHostGet(char *pszBuf, struct kernel_param *pParam)1054 static int vgdrvLinuxParamR3LogToHostGet(char *pszBuf, struct kernel_param *pParam) 1048 1055 { 1049 1056 strcpy(pszBuf, g_DevExt.fLoggingEnabled ? "enabled" : "disabled"); … … 1055 1062 * Define module parameters. 1056 1063 */ 1057 module_param_call(log, v boxguestLinuxParamLogGrpSet, vboxguestLinuxParamLogGrpGet, NULL, 0664);1058 module_param_call(log_flags, v boxguestLinuxParamLogFlagsSet, vboxguestLinuxParamLogFlagsGet, NULL, 0664);1059 module_param_call(log_dest, v boxguestLinuxParamLogDstSet, vboxguestLinuxParamLogDstGet, NULL, 0664);1064 module_param_call(log, vgdrvLinuxParamLogGrpSet, vgdrvLinuxParamLogGrpGet, NULL, 0664); 1065 module_param_call(log_flags, vgdrvLinuxParamLogFlagsSet, vgdrvLinuxParamLogFlagsGet, NULL, 0664); 1066 module_param_call(log_dest, vgdrvLinuxParamLogDstSet, vgdrvLinuxParamLogDstGet, NULL, 0664); 1060 1067 # ifdef LOG_ENABLED 1061 module_param_call(dbg_log, v boxguestLinuxParamLogGrpSet, vboxguestLinuxParamLogGrpGet, NULL, 0664);1062 module_param_call(dbg_log_flags, v boxguestLinuxParamLogFlagsSet, vboxguestLinuxParamLogFlagsGet, NULL, 0664);1063 module_param_call(dbg_log_dest, v boxguestLinuxParamLogDstSet, vboxguestLinuxParamLogDstGet, NULL, 0664);1068 module_param_call(dbg_log, vgdrvLinuxParamLogGrpSet, vgdrvLinuxParamLogGrpGet, NULL, 0664); 1069 module_param_call(dbg_log_flags, vgdrvLinuxParamLogFlagsSet, vgdrvLinuxParamLogFlagsGet, NULL, 0664); 1070 module_param_call(dbg_log_dest, vgdrvLinuxParamLogDstSet, vgdrvLinuxParamLogDstGet, NULL, 0664); 1064 1071 # endif 1065 module_param_call(r3_log_to_host, v boxguestLinuxParamR3LogToHostSet, vboxguestLinuxParamR3LogToHostGet, NULL, 0664);1072 module_param_call(r3_log_to_host, vgdrvLinuxParamR3LogToHostSet, vgdrvLinuxParamR3LogToHostGet, NULL, 0664); 1066 1073 1067 1074 #endif /* 2.6.0 and later */ 1068 1075 1069 1076 1070 module_init(v boxguestLinuxModInit);1071 module_exit(v boxguestLinuxModExit);1077 module_init(vgdrvLinuxModInit); 1078 module_exit(vgdrvLinuxModExit); 1072 1079 1073 1080 MODULE_AUTHOR(VBOX_VENDOR); -
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-os2.cpp
r58089 r58113 109 109 * Internal Functions * 110 110 *********************************************************************************************************************************/ 111 static int v boxGuestOS2MapMemory(void);112 static VBOXOSTYPE v boxGuestOS2DetectVersion(void);111 static int vgdrvOS2MapMemory(void); 112 static VBOXOSTYPE vgdrvOS2DetectVersion(void); 113 113 114 114 /* in VBoxGuestA-os2.asm */ 115 DECLASM(int) VBoxGuestOS2SetIRQ(uint8_t bIRQ);115 DECLASM(int) vgdrvOS2DevHlpSetIRQ(uint8_t bIRQ); 116 116 117 117 … … 124 124 * @param pszArgs Pointer to the device arguments. 125 125 */ 126 DECLASM(int) VBoxGuestOS2Init(const char *pszArgs)127 { 128 Log((" VBoxGuestOS2Init: pszArgs='%s' MMIO=0x%RX32 IOPort=0x%RX16 Int=%#x Bus=%#x Dev=%#x Fun=%d\n",126 DECLASM(int) vgdrvOS2Init(const char *pszArgs) 127 { 128 Log(("vgdrvOS2Init: pszArgs='%s' MMIO=0x%RX32 IOPort=0x%RX16 Int=%#x Bus=%#x Dev=%#x Fun=%d\n", 129 129 pszArgs, g_PhysMMIOBase, g_IOPortBase, g_bInterruptLine, g_bPciBusNo, g_bPciDevFunNo >> 3, g_bPciDevFunNo & 7)); 130 130 … … 143 143 * Map the MMIO memory if found. 144 144 */ 145 rc = v boxGuestOS2MapMemory();145 rc = vgdrvOS2MapMemory(); 146 146 if (RT_SUCCESS(rc)) 147 147 { … … 153 153 RTR0MemObjAddress(g_MemMapMMIO), 154 154 RTR0MemObjSize(g_MemMapMMIO), 155 v boxGuestOS2DetectVersion(),155 vgdrvOS2DetectVersion(), 156 156 0); 157 157 else 158 rc = VGDrvCommonInitDevExt(&g_DevExt, g_IOPortBase, NULL, 0, v boxGuestOS2DetectVersion(), 0);158 rc = VGDrvCommonInitDevExt(&g_DevExt, g_IOPortBase, NULL, 0, vgdrvOS2DetectVersion(), 0); 159 159 if (RT_SUCCESS(rc)) 160 160 { … … 170 170 if (g_bInterruptLine) 171 171 { 172 rc = VBoxGuestOS2SetIRQ(g_bInterruptLine);172 rc = vgdrvOS2DevHlpSetIRQ(g_bInterruptLine); 173 173 if (rc) 174 174 { 175 Log((" VBoxGuestOS2SetIRQ(%d) -> %d\n", g_bInterruptLine, rc));175 Log(("vgdrvOS2DevHlpSetIRQ(%d) -> %d\n", g_bInterruptLine, rc)); 176 176 rc = RTErrConvertFromOS2(rc); 177 177 } … … 190 190 g_cchInitText = strlen(&g_szInitText[0]); 191 191 } 192 Log((" VBoxGuestOS2Init: Successfully loaded\n%s", g_szInitText));192 Log(("vgdrvOS2Init: Successfully loaded\n%s", g_szInitText)); 193 193 return VINF_SUCCESS; 194 194 } … … 202 202 } 203 203 else 204 g_cchInitText = RTStrPrintf(&g_szInitText[0], g_cchInitTextMax, "VBoxGuest.sys: VBoxGuestOS2InitDevExt failed, rc=%Rrc\n", rc);204 g_cchInitText = RTStrPrintf(&g_szInitText[0], g_cchInitTextMax, "VBoxGuest.sys: vgdrvOS2InitDevExt failed, rc=%Rrc\n", rc); 205 205 206 206 int rc2 = RTR0MemObjFree(g_MemObjMMIO, true /* fFreeMappings */); AssertRC(rc2); … … 214 214 g_cchInitText = RTStrPrintf(&g_szInitText[0], g_cchInitTextMax, "VBoxGuest.sys: RTR0Init failed, rc=%Rrc\n", rc); 215 215 216 RTLogBackdoorPrintf(" VBoxGuestOS2Init: failed rc=%Rrc - %s", rc, &g_szInitText[0]);216 RTLogBackdoorPrintf("vgdrvOS2Init: failed rc=%Rrc - %s", rc, &g_szInitText[0]); 217 217 return rc; 218 218 } … … 225 225 * @retval VERR_VERSION_MISMATCH The VMMDev memory didn't meet our expectations. 226 226 */ 227 static int v boxGuestOS2MapMemory(void)227 static int vgdrvOS2MapMemory(void) 228 228 { 229 229 const RTCCPHYS PhysMMIOBase = g_PhysMMIOBase; … … 254 254 if (RT_FAILURE(rc)) 255 255 { 256 Log(("vboxGuestOS2MapMemory: RTR0MemObjEnterPhys(,%RCp,%zx) -> %Rrc\n", 257 PhysMMIOBase, cb, rc)); 256 Log(("vgdrvOS2MapMemory: RTR0MemObjEnterPhys(,%RCp,%zx) -> %Rrc\n", PhysMMIOBase, cb, rc)); 258 257 return rc; 259 258 } … … 267 266 * anyway for normal RAM. 268 267 */ 269 rc = RTR0MemObjMapKernel(&g_MemMapMMIO, g_MemObjMMIO, (void *)-1, 0, 270 RTMEM_PROT_READ | RTMEM_PROT_WRITE); 268 rc = RTR0MemObjMapKernel(&g_MemMapMMIO, g_MemObjMMIO, (void *)-1, 0, RTMEM_PROT_READ | RTMEM_PROT_WRITE); 271 269 if (RT_SUCCESS(rc)) 272 270 { … … 286 284 return VINF_SUCCESS; 287 285 288 Log(("v boxGuestOS2MapMemory: Actual size %#RX32 (tried %#zx)\n", pVMMDev->u32Size, cb));286 Log(("vgdrvOS2MapMemory: Actual size %#RX32 (tried %#zx)\n", pVMMDev->u32Size, cb)); 289 287 cb = RT_ALIGN_32(pVMMDev->u32Size, PAGE_SIZE); 290 288 … … 295 293 if (RT_SUCCESS(rc)) 296 294 { 297 rc = RTR0MemObjMapKernel(&g_MemMapMMIO, g_MemObjMMIO, (void *)-1, 0, 298 RTMEM_PROT_READ | RTMEM_PROT_WRITE); 295 rc = RTR0MemObjMapKernel(&g_MemMapMMIO, g_MemObjMMIO, (void *)-1, 0, RTMEM_PROT_READ | RTMEM_PROT_WRITE); 299 296 if (RT_SUCCESS(rc)) 300 297 return VINF_SUCCESS; 301 298 302 Log(("vboxGuestOS2MapMemory: RTR0MemObjMapKernel [%RCp,%zx] -> %Rrc (2nd)\n", 303 PhysMMIOBase, cb, rc)); 299 Log(("vgdrvOS2MapMemory: RTR0MemObjMapKernel [%RCp,%zx] -> %Rrc (2nd)\n", PhysMMIOBase, cb, rc)); 304 300 } 305 301 else 306 Log(("vboxGuestOS2MapMemory: RTR0MemObjEnterPhys(,%RCp,%zx) -> %Rrc (2nd)\n", 307 PhysMMIOBase, cb, rc)); 302 Log(("vgdrvOS2MapMemory: RTR0MemObjEnterPhys(,%RCp,%zx) -> %Rrc (2nd)\n", PhysMMIOBase, cb, rc)); 308 303 } 309 304 else 310 305 { 311 306 rc = VERR_VERSION_MISMATCH; 312 LogRel(("v boxGuestOS2MapMemory: Bogus VMMDev memory; u32Version=%RX32 (expected %RX32) u32Size=%RX32\n",307 LogRel(("vgdrvOS2MapMemory: Bogus VMMDev memory; u32Version=%RX32 (expected %RX32) u32Size=%RX32\n", 313 308 pVMMDev->u32Version, VMMDEV_MEMORY_VERSION, pVMMDev->u32Size)); 314 309 } 315 310 } 316 311 else 317 Log(("vboxGuestOS2MapMemory: RTR0MemObjMapKernel [%RCp,%zx] -> %Rrc\n", 318 PhysMMIOBase, cb, rc)); 312 Log(("vgdrvOS2MapMemory: RTR0MemObjMapKernel [%RCp,%zx] -> %Rrc\n", PhysMMIOBase, cb, rc)); 319 313 320 314 int rc2 = RTR0MemObjFree(g_MemObjMMIO, true /* fFreeMappings */); AssertRC(rc2); … … 325 319 326 320 /** 327 * Called fromn VBoxGuestOS2Init to determine which OS/2 version this is.321 * Called fromn vgdrvOS2Init to determine which OS/2 version this is. 328 322 * 329 323 * @returns VBox OS/2 type. 330 324 */ 331 static VBOXOSTYPE v boxGuestOS2DetectVersion(void)325 static VBOXOSTYPE vgdrvOS2DetectVersion(void) 332 326 { 333 327 VBOXOSTYPE enmOSType = VBOXOSTYPE_OS2; … … 349 343 350 344 351 DECLASM(int) VBoxGuestOS2Open(uint16_t sfn)345 DECLASM(int) vgdrvOS2Open(uint16_t sfn) 352 346 { 353 347 int rc; … … 372 366 } 373 367 374 Log((" VBoxGuestOS2Open: g_DevExt=%p pSession=%p rc=%d pid=%d\n", &g_DevExt, pSession, rc, (int)RTProcSelf()));368 Log(("vgdrvOS2Open: g_DevExt=%p pSession=%p rc=%d pid=%d\n", &g_DevExt, pSession, rc, (int)RTProcSelf())); 375 369 return rc; 376 370 } 377 371 378 372 379 DECLASM(int) VBoxGuestOS2Close(uint16_t sfn)380 { 381 Log((" VBoxGuestOS2Close: pid=%d sfn=%d\n", (int)RTProcSelf(), sfn));373 DECLASM(int) vgdrvOS2Close(uint16_t sfn) 374 { 375 Log(("vgdrvOS2Close: pid=%d sfn=%d\n", (int)RTProcSelf(), sfn)); 382 376 383 377 /* … … 433 427 434 428 435 DECLASM(int) VBoxGuestOS2IOCtlFast(uint16_t sfn, uint8_t iFunction, int32_t *prc)429 DECLASM(int) vgdrvOS2IOCtlFast(uint16_t sfn, uint8_t iFunction, int32_t *prc) 436 430 { 437 431 /* … … 482 476 * @remark This is called from the 16-bit thunker as well as directly from the 32-bit clients. 483 477 */ 484 DECLASM(int) V BoxGuestOS2IDCService(uint32_t u32Session, unsigned iFunction, void *pvData, size_t cbData, size_t *pcbDataReturned)478 DECLASM(int) VGDrvOS2IDCService(uint32_t u32Session, unsigned iFunction, void *pvData, size_t cbData, size_t *pcbDataReturned) 485 479 { 486 480 PVBOXGUESTSESSION pSession = (PVBOXGUESTSESSION)u32Session; … … 511 505 * @returns Pointer to the session. 512 506 */ 513 DECLASM(PVBOXGUESTSESSION) VBoxGuestOS2IDCConnect(void)507 DECLASM(PVBOXGUESTSESSION) vgdrvOS2IDCConnect(void) 514 508 { 515 509 PVBOXGUESTSESSION pSession; … … 524 518 525 519 526 DECLASM(int) VBoxGuestOS2IOCtl(uint16_t sfn, uint8_t iCat, uint8_t iFunction, void *pvParm, void *pvData, uint16_t *pcbParm, uint16_t *pcbData) 520 DECLASM(int) vgdrvOS2IOCtl(uint16_t sfn, uint8_t iCat, uint8_t iFunction, void *pvParm, void *pvData, 521 uint16_t *pcbParm, uint16_t *pcbData) 527 522 { 528 523 /* … … 560 555 if (RT_LIKELY(iCat == VBOXGUEST_IOCTL_CATEGORY)) 561 556 { 562 Log((" VBoxGuestOS2IOCtl: pSession=%p iFunction=%#x pvParm=%p pvData=%p *pcbParm=%d *pcbData=%d\n", pSession, iFunction, pvParm, pvData, *pcbParm, *pcbData));557 Log(("vgdrvOS2IOCtl: pSession=%p iFunction=%#x pvParm=%p pvData=%p *pcbParm=%d *pcbData=%d\n", pSession, iFunction, pvParm, pvData, *pcbParm, *pcbData)); 563 558 Assert(pvParm || !*pcbData); 564 559 Assert(pvData); … … 619 614 #endif 620 615 621 Log2((" VBoxGuestOS2IOCtl: returns VINF_SUCCESS / %d\n", rc));616 Log2(("vgdrvOS2IOCtl: returns VINF_SUCCESS / %d\n", rc)); 622 617 return VINF_SUCCESS; 623 618 } … … 631 626 * @returns true if it's our interrupt, false it isn't. 632 627 */ 633 DECLASM(bool) VBoxGuestOS2ISR(void)634 { 635 Log((" VBoxGuestOS2ISR\n"));628 DECLASM(bool) vgdrvOS2ISR(void) 629 { 630 Log(("vgdrvOS2ISR\n")); 636 631 637 632 return VGDrvCommonISR(&g_DevExt); … … 656 651 * @param cbChars Number of bytes in the character array pointed to by pachChars. 657 652 */ 658 static DECLCALLBACK(size_t) v boxGuestNativeLogOutput(void *pvArg, const char *pachChars, size_t cbChars)653 static DECLCALLBACK(size_t) vgdrvOS2LogOutput(void *pvArg, const char *pachChars, size_t cbChars) 659 654 { 660 655 size_t cchWritten = 0; … … 684 679 685 680 va_start(va, pszFormat); 686 int cch = RTLogFormatV(v boxGuestNativeLogOutput, NULL, pszFormat, va);681 int cch = RTLogFormatV(vgdrvOS2LogOutput, NULL, pszFormat, va); 687 682 va_end(va); 688 683 -
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-solaris.c
r58053 r58113 65 65 * Internal Functions * 66 66 *********************************************************************************************************************************/ 67 static int VBoxGuestSolarisOpen(dev_t *pDev, int fFlag, int fType, cred_t *pCred);68 static int VBoxGuestSolarisClose(dev_t Dev, int fFlag, int fType, cred_t *pCred);69 static int VBoxGuestSolarisRead(dev_t Dev, struct uio *pUio, cred_t *pCred);70 static int VBoxGuestSolarisWrite(dev_t Dev, struct uio *pUio, cred_t *pCred);71 static int VBoxGuestSolarisIOCtl(dev_t Dev, int Cmd, intptr_t pArg, int Mode, cred_t *pCred, int *pVal);72 static int VBoxGuestSolarisPoll(dev_t Dev, short fEvents, int fAnyYet, short *pReqEvents, struct pollhead **ppPollHead);73 74 static int VBoxGuestSolarisGetInfo(dev_info_t *pDip, ddi_info_cmd_t enmCmd, void *pArg, void **ppResult);75 static int VBoxGuestSolarisAttach(dev_info_t *pDip, ddi_attach_cmd_t enmCmd);76 static int VBoxGuestSolarisDetach(dev_info_t *pDip, ddi_detach_cmd_t enmCmd);77 static int VBoxGuestSolarisQuiesce(dev_info_t *pDip);78 79 static int VBoxGuestSolarisAddIRQ(dev_info_t *pDip);80 static void VBoxGuestSolarisRemoveIRQ(dev_info_t *pDip);81 static uint_t VBoxGuestSolarisISR(caddr_t Arg);67 static int vgdrvSolarisOpen(dev_t *pDev, int fFlag, int fType, cred_t *pCred); 68 static int vgdrvSolarisClose(dev_t Dev, int fFlag, int fType, cred_t *pCred); 69 static int vgdrvSolarisRead(dev_t Dev, struct uio *pUio, cred_t *pCred); 70 static int vgdrvSolarisWrite(dev_t Dev, struct uio *pUio, cred_t *pCred); 71 static int vgdrvSolarisIOCtl(dev_t Dev, int Cmd, intptr_t pArg, int Mode, cred_t *pCred, int *pVal); 72 static int vgdrvSolarisPoll(dev_t Dev, short fEvents, int fAnyYet, short *pReqEvents, struct pollhead **ppPollHead); 73 74 static int vgdrvSolarisGetInfo(dev_info_t *pDip, ddi_info_cmd_t enmCmd, void *pArg, void **ppResult); 75 static int vgdrvSolarisAttach(dev_info_t *pDip, ddi_attach_cmd_t enmCmd); 76 static int vgdrvSolarisDetach(dev_info_t *pDip, ddi_detach_cmd_t enmCmd); 77 static int vgdrvSolarisQuiesce(dev_info_t *pDip); 78 79 static int vgdrvSolarisAddIRQ(dev_info_t *pDip); 80 static void vgdrvSolarisRemoveIRQ(dev_info_t *pDip); 81 static uint_t vgdrvSolarisISR(caddr_t Arg); 82 82 83 83 … … 88 88 * cb_ops: for drivers that support char/block entry points 89 89 */ 90 static struct cb_ops g_ VBoxGuestSolarisCbOps =91 { 92 VBoxGuestSolarisOpen,93 VBoxGuestSolarisClose,90 static struct cb_ops g_vgdrvSolarisCbOps = 91 { 92 vgdrvSolarisOpen, 93 vgdrvSolarisClose, 94 94 nodev, /* b strategy */ 95 95 nodev, /* b dump */ 96 96 nodev, /* b print */ 97 VBoxGuestSolarisRead,98 VBoxGuestSolarisWrite,99 VBoxGuestSolarisIOCtl,97 vgdrvSolarisRead, 98 vgdrvSolarisWrite, 99 vgdrvSolarisIOCtl, 100 100 nodev, /* c devmap */ 101 101 nodev, /* c mmap */ 102 102 nodev, /* c segmap */ 103 VBoxGuestSolarisPoll,103 vgdrvSolarisPoll, 104 104 ddi_prop_op, /* property ops */ 105 105 NULL, /* streamtab */ … … 111 111 * dev_ops: for driver device operations 112 112 */ 113 static struct dev_ops g_ VBoxGuestSolarisDevOps =113 static struct dev_ops g_vgdrvSolarisDevOps = 114 114 { 115 115 DEVO_REV, /* driver build revision */ 116 116 0, /* ref count */ 117 VBoxGuestSolarisGetInfo,117 vgdrvSolarisGetInfo, 118 118 nulldev, /* identify */ 119 119 nulldev, /* probe */ 120 VBoxGuestSolarisAttach,121 VBoxGuestSolarisDetach,120 vgdrvSolarisAttach, 121 vgdrvSolarisDetach, 122 122 nodev, /* reset */ 123 &g_ VBoxGuestSolarisCbOps,123 &g_vgdrvSolarisCbOps, 124 124 (struct bus_ops *)0, 125 125 nodev, /* power */ 126 VBoxGuestSolarisQuiesce126 vgdrvSolarisQuiesce 127 127 }; 128 128 … … 130 130 * modldrv: export driver specifics to the kernel 131 131 */ 132 static struct modldrv g_ VBoxGuestSolarisModule =132 static struct modldrv g_vgdrvSolarisModule = 133 133 { 134 134 &mod_driverops, /* extern from kernel */ 135 135 DEVICE_DESC " " VBOX_VERSION_STRING "r" RT_XSTR(VBOX_SVN_REV), 136 &g_ VBoxGuestSolarisDevOps136 &g_vgdrvSolarisDevOps 137 137 }; 138 138 … … 140 140 * modlinkage: export install/remove/info to the kernel 141 141 */ 142 static struct modlinkage g_ VBoxGuestSolarisModLinkage =142 static struct modlinkage g_vgdrvSolarisModLinkage = 143 143 { 144 144 MODREV_1, /* loadable module system revision */ 145 &g_ VBoxGuestSolarisModule,145 &g_vgdrvSolarisModule, 146 146 NULL /* terminate array of linkage structures */ 147 147 }; … … 165 165 static dev_info_t *g_pDip = NULL; 166 166 /** Opaque pointer to file-descriptor states */ 167 static void *g_p VBoxGuestSolarisState = NULL;167 static void *g_pvgdrvSolarisState = NULL; 168 168 /** Device extention & session data association structure. */ 169 169 static VBOXGUESTDEVEXT g_DevExt; … … 219 219 * Prevent module autounloading. 220 220 */ 221 modctl_t *pModCtl = mod_getctl(&g_ VBoxGuestSolarisModLinkage);221 modctl_t *pModCtl = mod_getctl(&g_vgdrvSolarisModLinkage); 222 222 if (pModCtl) 223 223 pModCtl->mod_loadflags |= MOD_NOAUTOUNLOAD; 224 224 else 225 LogRel((DEVICE_NAME ": failed to disable autounloading!\n"));226 227 rc = ddi_soft_state_init(&g_p VBoxGuestSolarisState, sizeof(vboxguest_state_t), 1);225 LogRel((DEVICE_NAME ": failed to disable autounloading!\n")); 226 227 rc = ddi_soft_state_init(&g_pvgdrvSolarisState, sizeof(vboxguest_state_t), 1); 228 228 if (!rc) 229 229 { 230 rc = mod_install(&g_ VBoxGuestSolarisModLinkage);230 rc = mod_install(&g_vgdrvSolarisModLinkage); 231 231 if (rc) 232 ddi_soft_state_fini(&g_p VBoxGuestSolarisState);232 ddi_soft_state_fini(&g_pvgdrvSolarisState); 233 233 } 234 234 } … … 246 246 { 247 247 LogFlow((DEVICE_NAME ":_fini\n")); 248 int rc = mod_remove(&g_ VBoxGuestSolarisModLinkage);248 int rc = mod_remove(&g_vgdrvSolarisModLinkage); 249 249 if (!rc) 250 ddi_soft_state_fini(&g_p VBoxGuestSolarisState);250 ddi_soft_state_fini(&g_pvgdrvSolarisState); 251 251 252 252 RTLogDestroy(RTLogRelSetDefaultInstance(NULL)); … … 265 265 { 266 266 LogFlow((DEVICE_NAME ":_info\n")); 267 return mod_info(&g_ VBoxGuestSolarisModLinkage, pModInfo);267 return mod_info(&g_vgdrvSolarisModLinkage, pModInfo); 268 268 } 269 269 … … 277 277 * @return corresponding solaris error code. 278 278 */ 279 static int VBoxGuestSolarisAttach(dev_info_t *pDip, ddi_attach_cmd_t enmCmd)280 { 281 LogFlow(( DEVICE_NAME "::Attach\n"));279 static int vgdrvSolarisAttach(dev_info_t *pDip, ddi_attach_cmd_t enmCmd) 280 { 281 LogFlow(("vgdrvSolarisAttach:\n")); 282 282 switch (enmCmd) 283 283 { … … 286 286 if (g_pDip) 287 287 { 288 LogRel(( DEVICE_NAME "::Attach: Only one instance supported.\n"));288 LogRel(("vgdrvSolarisAttach: Only one instance supported.\n")); 289 289 return DDI_FAILURE; 290 290 } … … 325 325 * Add IRQ of VMMDev. 326 326 */ 327 rc = VBoxGuestSolarisAddIRQ(pDip);327 rc = vgdrvSolarisAddIRQ(pDip); 328 328 if (rc == DDI_SUCCESS) 329 329 { … … 352 352 } 353 353 else 354 LogRel((DEVICE_NAME "::Attach: V bgdCommonInitDevExt failed.\n"));355 VBoxGuestSolarisRemoveIRQ(pDip);354 LogRel((DEVICE_NAME "::Attach: VGDrvCommonInitDevExt failed.\n")); 355 vgdrvSolarisRemoveIRQ(pDip); 356 356 } 357 357 else 358 LogRel((DEVICE_NAME "::Attach: VBoxGuestSolarisAddIRQ failed.\n"));358 LogRel((DEVICE_NAME "::Attach: vgdrvSolarisAddIRQ failed.\n")); 359 359 ddi_regs_map_free(&g_PciMMIOHandle); 360 360 } … … 395 395 * @return corresponding solaris error code. 396 396 */ 397 static int VBoxGuestSolarisDetach(dev_info_t *pDip, ddi_detach_cmd_t enmCmd)398 { 399 LogFlow(( DEVICE_NAME "::Detach\n"));397 static int vgdrvSolarisDetach(dev_info_t *pDip, ddi_detach_cmd_t enmCmd) 398 { 399 LogFlow(("vgdrvSolarisDetach:\n")); 400 400 switch (enmCmd) 401 401 { 402 402 case DDI_DETACH: 403 403 { 404 VBoxGuestSolarisRemoveIRQ(pDip);404 vgdrvSolarisRemoveIRQ(pDip); 405 405 ddi_regs_map_free(&g_PciIOHandle); 406 406 ddi_regs_map_free(&g_PciMMIOHandle); … … 431 431 * @return corresponding solaris error code. 432 432 */ 433 static int VBoxGuestSolarisQuiesce(dev_info_t *pDip)433 static int vgdrvSolarisQuiesce(dev_info_t *pDip) 434 434 { 435 435 for (int i = 0; i < g_cIntrAllocated; i++) … … 456 456 * @return corresponding solaris error code. 457 457 */ 458 static int VBoxGuestSolarisGetInfo(dev_info_t *pDip, ddi_info_cmd_t enmCmd, void *pvArg, void **ppvResult)459 { 460 LogFlow(( DEVICE_NAME "::GetInfo\n"));458 static int vgdrvSolarisGetInfo(dev_info_t *pDip, ddi_info_cmd_t enmCmd, void *pvArg, void **ppvResult) 459 { 460 LogFlow(("vgdrvSolarisGetInfo:\n")); 461 461 462 462 int rc = DDI_SUCCESS; … … 484 484 * User context entry points 485 485 */ 486 static int VBoxGuestSolarisOpen(dev_t *pDev, int fFlag, int fType, cred_t *pCred)486 static int vgdrvSolarisOpen(dev_t *pDev, int fFlag, int fType, cred_t *pCred) 487 487 { 488 488 int rc; 489 489 PVBOXGUESTSESSION pSession = NULL; 490 490 491 LogFlow(( DEVICE_NAME "::Open\n"));491 LogFlow(("vgdrvSolarisOpen:\n")); 492 492 493 493 /* … … 501 501 for (iOpenInstance = 0; iOpenInstance < 4096; iOpenInstance++) 502 502 { 503 if ( !ddi_get_soft_state(g_p VBoxGuestSolarisState, iOpenInstance) /* faster */504 && ddi_soft_state_zalloc(g_p VBoxGuestSolarisState, iOpenInstance) == DDI_SUCCESS)505 { 506 pState = ddi_get_soft_state(g_p VBoxGuestSolarisState, iOpenInstance);503 if ( !ddi_get_soft_state(g_pvgdrvSolarisState, iOpenInstance) /* faster */ 504 && ddi_soft_state_zalloc(g_pvgdrvSolarisState, iOpenInstance) == DDI_SUCCESS) 505 { 506 pState = ddi_get_soft_state(g_pvgdrvSolarisState, iOpenInstance); 507 507 break; 508 508 } … … 510 510 if (!pState) 511 511 { 512 Log(( DEVICE_NAME "::Open: too many open instances."));512 Log(("vgdrvSolarisOpen: too many open instances.")); 513 513 return ENXIO; 514 514 } … … 523 523 pState->pSession = pSession; 524 524 *pDev = makedevice(getmajor(*pDev), iOpenInstance); 525 Log(( DEVICE_NAME "::Open: pSession=%p pState=%p pid=%d\n", pSession, pState, (int)RTProcSelf()));525 Log(("vgdrvSolarisOpen: pSession=%p pState=%p pid=%d\n", pSession, pState, (int)RTProcSelf())); 526 526 return 0; 527 527 } 528 528 529 529 /* Failed, clean up. */ 530 ddi_soft_state_free(g_p VBoxGuestSolarisState, iOpenInstance);531 532 LogRel((DEVICE_NAME "::Open: V bgdCommonCreateUserSession failed. rc=%d\n", rc));530 ddi_soft_state_free(g_pvgdrvSolarisState, iOpenInstance); 531 532 LogRel((DEVICE_NAME "::Open: VGDrvCommonCreateUserSession failed. rc=%d\n", rc)); 533 533 return EFAULT; 534 534 } 535 535 536 536 537 static int VBoxGuestSolarisClose(dev_t Dev, int flag, int fType, cred_t *pCred)538 { 539 LogFlow(( DEVICE_NAME "::Closepid=%d\n", (int)RTProcSelf()));537 static int vgdrvSolarisClose(dev_t Dev, int flag, int fType, cred_t *pCred) 538 { 539 LogFlow(("vgdrvSolarisClose: pid=%d\n", (int)RTProcSelf())); 540 540 541 541 PVBOXGUESTSESSION pSession = NULL; 542 vboxguest_state_t *pState = ddi_get_soft_state(g_p VBoxGuestSolarisState, getminor(Dev));542 vboxguest_state_t *pState = ddi_get_soft_state(g_pvgdrvSolarisState, getminor(Dev)); 543 543 if (!pState) 544 544 { 545 Log(( DEVICE_NAME "::Close: failed to get pState.\n"));545 Log(("vgdrvSolarisClose: failed to get pState.\n")); 546 546 return EFAULT; 547 547 } … … 550 550 pSession = pState->pSession; 551 551 pState->pSession = NULL; 552 Log(( DEVICE_NAME "::Close: pSession=%p pState=%p\n", pSession, pState));553 ddi_soft_state_free(g_p VBoxGuestSolarisState, getminor(Dev));552 Log(("vgdrvSolarisClose: pSession=%p pState=%p\n", pSession, pState)); 553 ddi_soft_state_free(g_pvgdrvSolarisState, getminor(Dev)); 554 554 if (!pSession) 555 555 { 556 Log(( DEVICE_NAME "::Close: failed to get pSession.\n"));556 Log(("vgdrvSolarisClose: failed to get pSession.\n")); 557 557 return EFAULT; 558 558 } … … 566 566 567 567 568 static int VBoxGuestSolarisRead(dev_t Dev, struct uio *pUio, cred_t *pCred)568 static int vgdrvSolarisRead(dev_t Dev, struct uio *pUio, cred_t *pCred) 569 569 { 570 570 LogFlow((DEVICE_NAME "::Read\n")); 571 571 572 vboxguest_state_t *pState = ddi_get_soft_state(g_p VBoxGuestSolarisState, getminor(Dev));572 vboxguest_state_t *pState = ddi_get_soft_state(g_pvgdrvSolarisState, getminor(Dev)); 573 573 if (!pState) 574 574 { … … 586 586 587 587 588 static int VBoxGuestSolarisWrite(dev_t Dev, struct uio *pUio, cred_t *pCred)589 { 590 LogFlow(( DEVICE_NAME "::Write\n"));588 static int vgdrvSolarisWrite(dev_t Dev, struct uio *pUio, cred_t *pCred) 589 { 590 LogFlow(("vgdrvSolarisWrite:\n")); 591 591 return 0; 592 592 } … … 614 614 * @return corresponding solaris error code. 615 615 */ 616 static int VBoxGuestSolarisIOCtl(dev_t Dev, int Cmd, intptr_t pArg, int Mode, cred_t *pCred, int *pVal)617 { 618 LogFlow(( DEVICE_NAME ":VBoxGuestSolarisIOCtl\n"));616 static int vgdrvSolarisIOCtl(dev_t Dev, int Cmd, intptr_t pArg, int Mode, cred_t *pCred, int *pVal) 617 { 618 LogFlow(("vgdrvSolarisIOCtl: iCmd=%#x\n", Cmd)); 619 619 620 620 /* 621 621 * Get the session from the soft state item. 622 622 */ 623 vboxguest_state_t *pState = ddi_get_soft_state(g_p VBoxGuestSolarisState, getminor(Dev));623 vboxguest_state_t *pState = ddi_get_soft_state(g_pvgdrvSolarisState, getminor(Dev)); 624 624 if (!pState) 625 625 { … … 690 690 } 691 691 } 692 Log(( DEVICE_NAME "::IOCtl: pSession=%p pid=%d.\n", pSession, (int)RTProcSelf()));692 Log(("vgdrvSolarisIOCtl: pSession=%p pid=%d.\n", pSession, (int)RTProcSelf())); 693 693 694 694 /* … … 723 723 * which are not really failures that require logging. 724 724 */ 725 Log(( DEVICE_NAME "::IOCtl: VbgdCommonIoCtl failed. Cmd=%#x rc=%d\n", Cmd, rc));725 Log(("vgdrvSolarisIOCtl: VGDrvCommonIoCtl failed. Cmd=%#x rc=%d\n", Cmd, rc)); 726 726 if (rc == VERR_PERMISSION_DENIED) /* RTErrConvertToErrno() below will ring-0 debug assert if we don't do this. */ 727 727 rc = VERR_ACCESS_DENIED; … … 735 735 736 736 737 static int VBoxGuestSolarisPoll(dev_t Dev, short fEvents, int fAnyYet, short *pReqEvents, struct pollhead **ppPollHead)738 { 739 LogFlow(( DEVICE_NAME "::Poll: fEvents=%d fAnyYet=%d\n", fEvents, fAnyYet));740 741 vboxguest_state_t *pState = ddi_get_soft_state(g_p VBoxGuestSolarisState, getminor(Dev));737 static int vgdrvSolarisPoll(dev_t Dev, short fEvents, int fAnyYet, short *pReqEvents, struct pollhead **ppPollHead) 738 { 739 LogFlow(("vgdrvSolarisPoll: fEvents=%d fAnyYet=%d\n", fEvents, fAnyYet)); 740 741 vboxguest_state_t *pState = ddi_get_soft_state(g_pvgdrvSolarisState, getminor(Dev)); 742 742 if (RT_LIKELY(pState)) 743 743 { … … 760 760 else 761 761 { 762 Log(( DEVICE_NAME "::Poll: no state data for %d\n", getminor(Dev)));762 Log(("vgdrvSolarisPoll: no state data for %d\n", getminor(Dev))); 763 763 return EINVAL; 764 764 } … … 772 772 * @param pDip Pointer to the device info structure. 773 773 */ 774 static int VBoxGuestSolarisAddIRQ(dev_info_t *pDip)775 { 776 LogFlow(( DEVICE_NAME "::AddIRQ: pDip=%p\n", pDip));774 static int vgdrvSolarisAddIRQ(dev_info_t *pDip) 775 { 776 LogFlow(("vgdrvSolarisAddIRQ: pDip=%p\n", pDip)); 777 777 778 778 int IntrType = 0; … … 813 813 for (int i = 0; i < IntrAllocated; i++) 814 814 { 815 rc = ddi_intr_add_handler(g_pIntr[i], (ddi_intr_handler_t *) VBoxGuestSolarisISR,815 rc = ddi_intr_add_handler(g_pIntr[i], (ddi_intr_handler_t *)vgdrvSolarisISR, 816 816 NULL /* pvArg1 */, NULL /* pvArg2 */); 817 817 if (rc == DDI_SUCCESS) … … 867 867 * @param pDip Pointer to the device info structure. 868 868 */ 869 static void VBoxGuestSolarisRemoveIRQ(dev_info_t *pDip)870 { 871 LogFlow(( DEVICE_NAME "::RemoveIRQ:\n"));869 static void vgdrvSolarisRemoveIRQ(dev_info_t *pDip) 870 { 871 LogFlow(("vgdrvSolarisRemoveIRQ:\n")); 872 872 873 873 for (int i = 0; i < g_cIntrAllocated; i++) … … 893 893 * @returns DDI_INTR_CLAIMED if it's our interrupt, DDI_INTR_UNCLAIMED if it isn't. 894 894 */ 895 static uint_t VBoxGuestSolarisISR(caddr_t Arg)896 { 897 LogFlow(( DEVICE_NAME "::ISR:\n"));895 static uint_t vgdrvSolarisISR(caddr_t Arg) 896 { 897 LogFlow(("vgdrvSolarisISR:\n")); 898 898 899 899 mutex_enter(&g_IrqMtx); … … 907 907 void VGDrvNativeISRMousePollEvent(PVBOXGUESTDEVEXT pDevExt) 908 908 { 909 LogFlow(( DEVICE_NAME "::VGDrvNativeISRMousePollEvent:\n"));909 LogFlow(("VGDrvNativeISRMousePollEvent:\n")); 910 910 911 911 /* -
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-win-legacy.cpp
r57358 r58113 41 41 *********************************************************************************************************************************/ 42 42 RT_C_DECLS_BEGIN 43 static NTSTATUS v bgdNt4FindPciDevice(PULONG pulBusNumber, PPCI_SLOT_NUMBER pSlotNumber);43 static NTSTATUS vgdrvNt4FindPciDevice(PULONG pulBusNumber, PPCI_SLOT_NUMBER pSlotNumber); 44 44 RT_C_DECLS_END 45 45 46 46 #ifdef ALLOC_PRAGMA 47 # pragma alloc_text(INIT, v bgdNt4CreateDevice)48 # pragma alloc_text(INIT, v bgdNt4FindPciDevice)47 # pragma alloc_text(INIT, vgdrvNt4CreateDevice) 48 # pragma alloc_text(INIT, vgdrvNt4FindPciDevice) 49 49 #endif 50 50 … … 59 59 * @param pRegPath The driver registry path. 60 60 */ 61 NTSTATUS v bgdNt4CreateDevice(PDRIVER_OBJECT pDrvObj, PDEVICE_OBJECT pDevObj, PUNICODE_STRING pRegPath)61 NTSTATUS vgdrvNt4CreateDevice(PDRIVER_OBJECT pDrvObj, PDEVICE_OBJECT pDevObj, PUNICODE_STRING pRegPath) 62 62 { 63 Log((" VBoxGuest::vbgdNt4CreateDevice: pDrvObj=%p, pDevObj=%p, pRegPath=%p\n", pDrvObj, pDevObj, pRegPath));63 Log(("vgdrvNt4CreateDevice: pDrvObj=%p, pDevObj=%p, pRegPath=%p\n", pDrvObj, pDevObj, pRegPath)); 64 64 65 65 /* … … 68 68 ULONG uBusNumber; 69 69 PCI_SLOT_NUMBER SlotNumber; 70 NTSTATUS rc = v bgdNt4FindPciDevice(&uBusNumber, &SlotNumber);70 NTSTATUS rc = vgdrvNt4FindPciDevice(&uBusNumber, &SlotNumber); 71 71 if (NT_ERROR(rc)) 72 72 { 73 Log((" VBoxGuest::vbgdNt4CreateDevice: Device not found!\n"));73 Log(("vgdrvNt4CreateDevice: Device not found!\n")); 74 74 return rc; 75 75 } … … 84 84 if (NT_SUCCESS(rc)) 85 85 { 86 Log((" VBoxGuest::vbgdNt4CreateDevice: Device created\n"));86 Log(("vgdrvNt4CreateDevice: Device created\n")); 87 87 88 88 UNICODE_STRING DosName; … … 91 91 if (NT_SUCCESS(rc)) 92 92 { 93 Log((" VBoxGuest::vbgdNt4CreateDevice: Symlink created\n"));93 Log(("vgdrvNt4CreateDevice: Symlink created\n")); 94 94 95 95 /* 96 96 * Setup the device extension. 97 97 */ 98 Log((" VBoxGuest::vbgdNt4CreateDevice: Setting up device extension ...\n"));98 Log(("vgdrvNt4CreateDevice: Setting up device extension ...\n")); 99 99 100 100 PVBOXGUESTDEVEXTWIN pDevExt = (PVBOXGUESTDEVEXTWIN)pDeviceObject->DeviceExtension; 101 101 RT_ZERO(*pDevExt); 102 102 103 Log((" VBoxGuest::vbgdNt4CreateDevice: Device extension created\n"));103 Log(("vgdrvNt4CreateDevice: Device extension created\n")); 104 104 105 105 /* Store a reference to ourself. */ … … 117 117 if (NT_SUCCESS(rc)) 118 118 { 119 rc = v bgdNtInit(pDrvObj, pDeviceObject, pRegPath);119 rc = vgdrvNtInit(pDrvObj, pDeviceObject, pRegPath); 120 120 if (NT_SUCCESS(rc)) 121 121 { 122 Log((" VBoxGuest::vbgdNt4CreateDevice: Returning rc = 0x%x (succcess)\n", rc));122 Log(("vgdrvNt4CreateDevice: Returning rc = 0x%x (succcess)\n", rc)); 123 123 return rc; 124 124 } … … 129 129 } 130 130 else 131 Log((" VBoxGuest::vbgdNt4CreateDevice: IoCreateSymbolicLink failed with rc = %#x\n", rc));131 Log(("vgdrvNt4CreateDevice: IoCreateSymbolicLink failed with rc = %#x\n", rc)); 132 132 IoDeleteDevice(pDeviceObject); 133 133 } 134 134 else 135 Log((" VBoxGuest::vbgdNt4CreateDevice: IoCreateDevice failed with rc = %#x\n", rc));136 Log((" VBoxGuest::vbgdNt4CreateDevice: Returning rc = 0x%x\n", rc));135 Log(("vgdrvNt4CreateDevice: IoCreateDevice failed with rc = %#x\n", rc)); 136 Log(("vgdrvNt4CreateDevice: Returning rc = 0x%x\n", rc)); 137 137 return rc; 138 138 } … … 147 147 * @param pSlotNumber Where to return the slot number on success. 148 148 */ 149 static NTSTATUS v bgdNt4FindPciDevice(PULONG pulBusNumber, PPCI_SLOT_NUMBER pSlotNumber)149 static NTSTATUS vgdrvNt4FindPciDevice(PULONG pulBusNumber, PPCI_SLOT_NUMBER pSlotNumber) 150 150 { 151 Log((" VBoxGuest::vbgdNt4FindPciDevice\n"));151 Log(("vgdrvNt4FindPciDevice\n")); 152 152 153 153 PCI_SLOT_NUMBER SlotNumber; … … 186 186 187 187 /* Hooray, we've found it! */ 188 Log((" VBoxGuest::vbgdNt4FindPciDevice: Device found!\n"));188 Log(("vgdrvNt4FindPciDevice: Device found!\n")); 189 189 190 190 *pulBusNumber = ulBusNumber; -
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-win-pnp.cpp
r58053 r58113 32 32 *********************************************************************************************************************************/ 33 33 RT_C_DECLS_BEGIN 34 static NTSTATUS v bgdNtSendIrpSynchronously(PDEVICE_OBJECT pDevObj, PIRP pIrp, BOOLEAN fStrict);35 static NTSTATUS v bgdNtPnPIrpComplete(PDEVICE_OBJECT pDevObj, PIRP pIrp, PKEVENT pEvent);36 static VOID v bgdNtShowDeviceResources(PCM_PARTIAL_RESOURCE_LIST pResourceList);34 static NTSTATUS vgdrvNtSendIrpSynchronously(PDEVICE_OBJECT pDevObj, PIRP pIrp, BOOLEAN fStrict); 35 static NTSTATUS vgdrvNtPnPIrpComplete(PDEVICE_OBJECT pDevObj, PIRP pIrp, PKEVENT pEvent); 36 static VOID vgdrvNtShowDeviceResources(PCM_PARTIAL_RESOURCE_LIST pResourceList); 37 37 RT_C_DECLS_END 38 38 39 39 #ifdef ALLOC_PRAGMA 40 # pragma alloc_text(PAGE, v bgdNtPnP)41 # pragma alloc_text(PAGE, v bgdNtPower)42 # pragma alloc_text(PAGE, v bgdNtSendIrpSynchronously)43 # pragma alloc_text(PAGE, v bgdNtShowDeviceResources)40 # pragma alloc_text(PAGE, vgdrvNtPnP) 41 # pragma alloc_text(PAGE, vgdrvNtPower) 42 # pragma alloc_text(PAGE, vgdrvNtSendIrpSynchronously) 43 # pragma alloc_text(PAGE, vgdrvNtShowDeviceResources) 44 44 #endif 45 45 … … 48 48 * Irp completion routine for PnP Irps we send. 49 49 * 50 * @returns NT status code. 50 51 * @param pDevObj Device object. 51 52 * @param pIrp Request packet. 52 53 * @param pEvent Semaphore. 53 * @return NT status code 54 */ 55 static NTSTATUS vbgdNtPnpIrpComplete(PDEVICE_OBJECT pDevObj, PIRP pIrp, PKEVENT pEvent) 54 */ 55 static NTSTATUS vgdrvNtPnpIrpComplete(PDEVICE_OBJECT pDevObj, PIRP pIrp, PKEVENT pEvent) 56 56 { 57 57 KeSetEvent(pEvent, 0, FALSE); … … 63 63 * Helper to send a PnP IRP and wait until it's done. 64 64 * 65 * @returns NT status code. 65 66 * @param pDevObj Device object. 66 67 * @param pIrp Request packet. 67 68 * @param fStrict When set, returns an error if the IRP gives an error. 68 * @return NT status code 69 */ 70 static NTSTATUS vbgdNtSendIrpSynchronously(PDEVICE_OBJECT pDevObj, PIRP pIrp, BOOLEAN fStrict) 69 */ 70 static NTSTATUS vgdrvNtSendIrpSynchronously(PDEVICE_OBJECT pDevObj, PIRP pIrp, BOOLEAN fStrict) 71 71 { 72 72 KEVENT Event; … … 75 75 76 76 IoCopyCurrentIrpStackLocationToNext(pIrp); 77 IoSetCompletionRoutine(pIrp, (PIO_COMPLETION_ROUTINE)vbgdNtPnpIrpComplete, 78 &Event, TRUE, TRUE, TRUE); 77 IoSetCompletionRoutine(pIrp, (PIO_COMPLETION_ROUTINE)vgdrvNtPnpIrpComplete, &Event, TRUE, TRUE, TRUE); 79 78 80 79 NTSTATUS rc = IoCallDriver(pDevObj, pIrp); … … 86 85 } 87 86 88 if ( !fStrict87 if ( !fStrict 89 88 && (rc == STATUS_NOT_SUPPORTED || rc == STATUS_INVALID_DEVICE_REQUEST)) 90 89 { … … 92 91 } 93 92 94 Log((" VBoxGuest::vbgdNtSendIrpSynchronously: Returning 0x%x\n", rc));93 Log(("vgdrvNtSendIrpSynchronously: Returning 0x%x\n", rc)); 95 94 return rc; 96 95 } … … 103 102 * @param pIrp Request packet. 104 103 */ 105 NTSTATUS v bgdNtPnP(PDEVICE_OBJECT pDevObj, PIRP pIrp)104 NTSTATUS vgdrvNtPnP(PDEVICE_OBJECT pDevObj, PIRP pIrp) 106 105 { 107 106 PVBOXGUESTDEVEXTWIN pDevExt = (PVBOXGUESTDEVEXTWIN)pDevObj->DeviceExtension; … … 136 135 "IRP_MN_SURPRISE_REMOVAL", 137 136 }; 138 Log((" VBoxGuest::vbgdNtGuestPnp: MinorFunction: %s\n",137 Log(("vgdrvNtPnP: MinorFunction: %s\n", 139 138 pStack->MinorFunction < RT_ELEMENTS(s_apszFnctName) ? s_apszFnctName[pStack->MinorFunction] : "Unknown")); 140 139 #endif … … 145 144 case IRP_MN_START_DEVICE: 146 145 { 147 Log((" VBoxGuest::vbgdNtVBoxGuestPnP: START_DEVICE\n"));146 Log(("vgdrvNtPnP: START_DEVICE\n")); 148 147 149 148 /* This must be handled first by the lower driver. */ 150 rc = v bgdNtSendIrpSynchronously(pDevExt->pNextLowerDriver, pIrp, TRUE);149 rc = vgdrvNtSendIrpSynchronously(pDevExt->pNextLowerDriver, pIrp, TRUE); 151 150 152 151 if ( NT_SUCCESS(rc) 153 152 && NT_SUCCESS(pIrp->IoStatus.Status)) 154 153 { 155 Log((" VBoxGuest::vbgdNtVBoxGuestPnP: START_DEVICE: pStack->Parameters.StartDevice.AllocatedResources = %p\n",154 Log(("vgdrvNtPnP: START_DEVICE: pStack->Parameters.StartDevice.AllocatedResources = %p\n", 156 155 pStack->Parameters.StartDevice.AllocatedResources)); 157 156 158 if (!pStack->Parameters.StartDevice.AllocatedResources) 157 if (pStack->Parameters.StartDevice.AllocatedResources) 158 rc = vgdrvNtInit(pDevObj, pIrp); 159 else 159 160 { 160 Log((" VBoxGuest::vbgdNtVBoxGuestPnP: START_DEVICE: No resources, pDevExt = %p, nextLowerDriver = %p!\n",161 Log(("vgdrvNtPnP: START_DEVICE: No resources, pDevExt = %p, nextLowerDriver = %p!\n", 161 162 pDevExt, pDevExt ? pDevExt->pNextLowerDriver : NULL)); 162 163 rc = STATUS_UNSUCCESSFUL; 163 164 } 164 else165 {166 rc = vbgdNtInit(pDevObj, pIrp);167 }168 165 } 169 166 170 167 if (NT_ERROR(rc)) 171 168 { 172 Log((" VBoxGuest::vbgdNtGuestPnp: START_DEVICE: Error: rc = 0x%x\n", rc));169 Log(("vgdrvNtPnP: START_DEVICE: Error: rc = 0x%x\n", rc)); 173 170 174 171 /* Need to unmap memory in case of errors ... */ 175 vbgdNtUnmapVMMDevMemory(pDevExt); 172 /** @todo r=bird: vgdrvNtInit maps it and is responsible for cleaning up its own friggin mess... 173 * Fix it instead of kind of working around things there!! */ 174 vgdrvNtUnmapVMMDevMemory(pDevExt); 176 175 } 177 176 break; … … 180 179 case IRP_MN_CANCEL_REMOVE_DEVICE: 181 180 { 182 Log((" VBoxGuest::vbgdNtVBoxGuestPnP: CANCEL_REMOVE_DEVICE\n"));181 Log(("vgdrvNtPnP: CANCEL_REMOVE_DEVICE\n")); 183 182 184 183 /* This must be handled first by the lower driver. */ 185 rc = v bgdNtSendIrpSynchronously(pDevExt->pNextLowerDriver, pIrp, TRUE);186 187 if (NT_SUCCESS(rc) && pDevExt-> devState ==PENDINGREMOVE)184 rc = vgdrvNtSendIrpSynchronously(pDevExt->pNextLowerDriver, pIrp, TRUE); 185 186 if (NT_SUCCESS(rc) && pDevExt->enmDevState == VGDRVNTDEVSTATE_PENDINGREMOVE) 188 187 { 189 188 /* Return to the state prior to receiving the IRP_MN_QUERY_REMOVE_DEVICE request. */ 190 pDevExt-> devState = pDevExt->prevDevState;189 pDevExt->enmDevState = pDevExt->enmPrevDevState; 191 190 } 192 191 … … 197 196 case IRP_MN_SURPRISE_REMOVAL: 198 197 { 199 Log((" VBoxGuest::vbgdNtVBoxGuestPnP: IRP_MN_SURPRISE_REMOVAL\n"));200 201 VBOXGUEST_UPDATE_DEVSTATE(pDevExt, SURPRISEREMOVED);198 Log(("vgdrvNtPnP: IRP_MN_SURPRISE_REMOVAL\n")); 199 200 VBOXGUEST_UPDATE_DEVSTATE(pDevExt, VGDRVNTDEVSTATE_SURPRISEREMOVED); 202 201 203 202 /* Do nothing here actually. Cleanup is done in IRP_MN_REMOVE_DEVICE. … … 219 218 case IRP_MN_QUERY_REMOVE_DEVICE: 220 219 { 221 Log((" VBoxGuest::vbgdNtVBoxGuestPnP: QUERY_REMOVE_DEVICE\n"));220 Log(("vgdrvNtPnP: QUERY_REMOVE_DEVICE\n")); 222 221 223 222 #ifdef VBOX_REBOOT_ON_UNINSTALL 224 Log((" VBoxGuest::vbgdNtGuestPnp: QUERY_REMOVE_DEVICE: Device cannot be removed without a reboot.\n"));223 Log(("vgdrvNtPnP: QUERY_REMOVE_DEVICE: Device cannot be removed without a reboot.\n")); 225 224 rc = STATUS_UNSUCCESSFUL; 226 225 #endif … … 228 227 if (NT_SUCCESS(rc)) 229 228 { 230 VBOXGUEST_UPDATE_DEVSTATE(pDevExt, PENDINGREMOVE);229 VBOXGUEST_UPDATE_DEVSTATE(pDevExt, VGDRVNTDEVSTATE_PENDINGREMOVE); 231 230 232 231 /* This IRP passed down to lower driver. */ … … 236 235 237 236 rc = IoCallDriver(pDevExt->pNextLowerDriver, pIrp); 238 Log((" VBoxGuest::vbgdNtGuestPnp: QUERY_REMOVE_DEVICE: Next lower driver replied rc = 0x%x\n", rc));237 Log(("vgdrvNtPnP: QUERY_REMOVE_DEVICE: Next lower driver replied rc = 0x%x\n", rc)); 239 238 240 239 /* we must not do anything the IRP after doing IoSkip & CallDriver … … 250 249 case IRP_MN_REMOVE_DEVICE: 251 250 { 252 Log((" VBoxGuest::vbgdNtVBoxGuestPnP: REMOVE_DEVICE\n"));253 254 VBOXGUEST_UPDATE_DEVSTATE(pDevExt, REMOVED);251 Log(("vgdrvNtPnP: REMOVE_DEVICE\n")); 252 253 VBOXGUEST_UPDATE_DEVSTATE(pDevExt, VGDRVNTDEVSTATE_REMOVED); 255 254 256 255 /* Free hardware resources. */ 257 256 /** @todo this should actually free I/O ports, interrupts, etc. 258 * Update/bird: v bgdNtCleanup actually does that... So, what's there to do? */259 rc = v bgdNtCleanup(pDevObj);260 Log((" VBoxGuest::vbgdNtGuestPnp: REMOVE_DEVICE: vbgdNtCleanup rc = 0x%08X\n", rc));257 * Update/bird: vgdrvNtCleanup actually does that... So, what's there to do? */ 258 rc = vgdrvNtCleanup(pDevObj); 259 Log(("vgdrvNtPnP: REMOVE_DEVICE: vgdrvNtCleanup rc = 0x%08X\n", rc)); 261 260 262 261 /* … … 270 269 271 270 rc = IoCallDriver(pDevExt->pNextLowerDriver, pIrp); 272 Log((" VBoxGuest::vbgdNtGuestPnp: REMOVE_DEVICE: Next lower driver replied rc = 0x%x\n", rc));271 Log(("vgdrvNtPnP: REMOVE_DEVICE: Next lower driver replied rc = 0x%x\n", rc)); 273 272 274 273 IoDetachDevice(pDevExt->pNextLowerDriver); 275 274 276 Log((" VBoxGuest::vbgdNtGuestPnp: REMOVE_DEVICE: Removing device ...\n"));275 Log(("vgdrvNtPnP: REMOVE_DEVICE: Removing device ...\n")); 277 276 278 277 /* Destroy device extension and clean up everything else. */ … … 284 283 IoDeleteSymbolicLink(&win32Name); 285 284 286 Log((" VBoxGuest::vbgdNtGuestPnp: REMOVE_DEVICE: Deleting device ...\n"));285 Log(("vgdrvNtPnP: REMOVE_DEVICE: Deleting device ...\n")); 287 286 288 287 /* Last action: Delete our device! pDevObj is *not* failed … … 290 289 IoDeleteDevice(pDevObj); 291 290 292 Log((" VBoxGuest::vbgdNtGuestPnp: REMOVE_DEVICE: Device removed!\n"));291 Log(("vgdrvNtPnP: REMOVE_DEVICE: Device removed!\n")); 293 292 294 293 /* Propagating rc from IoCallDriver. */ … … 298 297 case IRP_MN_CANCEL_STOP_DEVICE: 299 298 { 300 Log((" VBoxGuest::vbgdNtVBoxGuestPnP: CANCEL_STOP_DEVICE\n"));299 Log(("vgdrvNtPnP: CANCEL_STOP_DEVICE\n")); 301 300 302 301 /* This must be handled first by the lower driver. */ 303 rc = v bgdNtSendIrpSynchronously(pDevExt->pNextLowerDriver, pIrp, TRUE);304 305 if (NT_SUCCESS(rc) && pDevExt-> devState ==PENDINGSTOP)302 rc = vgdrvNtSendIrpSynchronously(pDevExt->pNextLowerDriver, pIrp, TRUE); 303 304 if (NT_SUCCESS(rc) && pDevExt->enmDevState == VGDRVNTDEVSTATE_PENDINGSTOP) 306 305 { 307 306 /* Return to the state prior to receiving the IRP_MN_QUERY_STOP_DEVICE request. */ 308 pDevExt-> devState = pDevExt->prevDevState;307 pDevExt->enmDevState = pDevExt->enmPrevDevState; 309 308 } 310 309 … … 315 314 case IRP_MN_QUERY_STOP_DEVICE: 316 315 { 317 Log((" VBoxGuest::vbgdNtVBoxGuestPnP: QUERY_STOP_DEVICE\n"));316 Log(("vgdrvNtPnP: QUERY_STOP_DEVICE\n")); 318 317 319 318 #ifdef VBOX_REBOOT_ON_UNINSTALL 320 Log((" VBoxGuest::vbgdNtGuestPnp: QUERY_STOP_DEVICE: Device cannot be stopped without a reboot!\n"));319 Log(("vgdrvNtPnP: QUERY_STOP_DEVICE: Device cannot be stopped without a reboot!\n")); 321 320 pIrp->IoStatus.Status = STATUS_UNSUCCESSFUL; 322 321 #endif … … 324 323 if (NT_SUCCESS(rc)) 325 324 { 326 VBOXGUEST_UPDATE_DEVSTATE(pDevExt, PENDINGSTOP);325 VBOXGUEST_UPDATE_DEVSTATE(pDevExt, VGDRVNTDEVSTATE_PENDINGSTOP); 327 326 328 327 /* This IRP passed down to lower driver. */ … … 332 331 333 332 rc = IoCallDriver(pDevExt->pNextLowerDriver, pIrp); 334 Log((" VBoxGuest::vbgdNtGuestPnp: QUERY_STOP_DEVICE: Next lower driver replied rc = 0x%x\n", rc));333 Log(("vgdrvNtPnP: QUERY_STOP_DEVICE: Next lower driver replied rc = 0x%x\n", rc)); 335 334 336 335 /* we must not do anything with the IRP after doing IoSkip & CallDriver … … 346 345 case IRP_MN_STOP_DEVICE: 347 346 { 348 Log((" VBoxGuest::vbgdNtVBoxGuestPnP: STOP_DEVICE\n"));349 350 VBOXGUEST_UPDATE_DEVSTATE(pDevExt, STOPPED);347 Log(("vgdrvNtPnP: STOP_DEVICE\n")); 348 349 VBOXGUEST_UPDATE_DEVSTATE(pDevExt, VGDRVNTDEVSTATE_STOPPED); 351 350 352 351 /* Free hardware resources. */ 353 352 /** @todo this should actually free I/O ports, interrupts, etc. 354 * Update/bird: v bgdNtCleanup actually does that... So, what's there to do? */355 rc = v bgdNtCleanup(pDevObj);356 Log((" VBoxGuest::vbgdNtGuestPnp: STOP_DEVICE: cleaning up, rc = 0x%x\n", rc));353 * Update/bird: vgdrvNtCleanup actually does that... So, what's there to do? */ 354 rc = vgdrvNtCleanup(pDevObj); 355 Log(("vgdrvNtPnP: STOP_DEVICE: cleaning up, rc = 0x%x\n", rc)); 357 356 358 357 /* Pass to the lower driver. */ … … 362 361 363 362 rc = IoCallDriver(pDevExt->pNextLowerDriver, pIrp); 364 Log((" VBoxGuest::vbgdNtGuestPnp: STOP_DEVICE: Next lower driver replied rc = 0x%x\n", rc));363 Log(("vgdrvNtPnP: STOP_DEVICE: Next lower driver replied rc = 0x%x\n", rc)); 365 364 366 365 return rc; … … 378 377 IoCompleteRequest(pIrp, IO_NO_INCREMENT); 379 378 380 Log((" VBoxGuest::vbgdNtGuestPnp: Returning with rc = 0x%x\n", rc));379 Log(("vgdrvNtPnP: Returning with rc = 0x%x\n", rc)); 381 380 return rc; 382 381 } … … 391 390 * @param pContext Context value passed to IoSetCompletionRoutine in VBoxGuestPower. 392 391 */ 393 static NTSTATUS v bgdNtPowerComplete(IN PDEVICE_OBJECT pDevObj, IN PIRP pIrp, IN PVOID pContext)392 static NTSTATUS vgdrvNtPowerComplete(IN PDEVICE_OBJECT pDevObj, IN PIRP pIrp, IN PVOID pContext) 394 393 { 395 394 #ifdef VBOX_STRICT … … 407 406 { 408 407 case IRP_MN_SET_POWER: 409 410 408 switch (pIrpSp->Parameters.Power.Type) 411 409 { … … 435 433 * @param pIrp IRP 436 434 */ 437 NTSTATUS v bgdNtPower(PDEVICE_OBJECT pDevObj, PIRP pIrp)435 NTSTATUS vgdrvNtPower(PDEVICE_OBJECT pDevObj, PIRP pIrp) 438 436 { 439 437 PIO_STACK_LOCATION pStack = IoGetCurrentIrpStackLocation(pIrp); … … 443 441 POWER_ACTION enmPowerAction = pStack->Parameters.Power.ShutdownType; 444 442 445 Log((" VBoxGuest::vbgdNtGuestPower\n"));443 Log(("vgdrvNtPower:\n")); 446 444 447 445 switch (pStack->MinorFunction) … … 449 447 case IRP_MN_SET_POWER: 450 448 { 451 Log((" VBoxGuest::vbgdNtGuestPower: IRP_MN_SET_POWER, type= %d\n", enmPowerType));449 Log(("vgdrvNtPower: IRP_MN_SET_POWER, type= %d\n", enmPowerType)); 452 450 switch (enmPowerType) 453 451 { 454 452 case SystemPowerState: 455 453 { 456 Log((" VBoxGuest::vbgdNtGuestPower: SystemPowerState, action = %d, state = %d/%d\n",454 Log(("vgdrvNtPower: SystemPowerState, action = %d, state = %d/%d\n", 457 455 enmPowerAction, PowerState.SystemState, PowerState.DeviceState)); 458 456 … … 467 465 && pDevExt->LastSystemPowerAction == PowerActionHibernate) 468 466 { 469 Log((" VBoxGuest::vbgdNtGuestPower: Returning from hibernation!\n"));467 Log(("vgdrvNtPower: Returning from hibernation!\n")); 470 468 int rc = VGDrvCommonReinitDevExtAfterHibernation(&pDevExt->Core, 471 v bgdNtVersionToOSType(g_enmVbgdNtVer));469 vgdrvNtVersionToOSType(g_enmVGDrvNtVer)); 472 470 if (RT_FAILURE(rc)) 473 Log((" VBoxGuest::vbgdNtGuestPower: Cannot re-init VMMDev chain, rc = %d!\n", rc));471 Log(("vgdrvNtPower: Cannot re-init VMMDev chain, rc = %d!\n", rc)); 474 472 } 475 473 } … … 478 476 case PowerActionShutdownReset: 479 477 { 480 Log((" VBoxGuest::vbgdNtGuestPower: Power action reset!\n"));478 Log(("vgdrvNtPower: Power action reset!\n")); 481 479 482 480 /* Tell the VMM that we no longer support mouse pointer integration. */ … … 493 491 if (RT_FAILURE(vrc)) 494 492 { 495 Log((" VBoxGuest::PowerStateRequest: error communicating new power status to VMMDev. vrc = %Rrc\n", vrc));493 Log(("vgdrvNtPower: error communicating new power status to VMMDev. vrc = %Rrc\n", vrc)); 496 494 } 497 495 … … 507 505 case PowerActionShutdownOff: 508 506 { 509 Log((" VBoxGuest::vbgdNtGuestPower: Power action shutdown!\n"));507 Log(("vgdrvNtPower: Power action shutdown!\n")); 510 508 if (PowerState.SystemState >= PowerSystemShutdown) 511 509 { 512 Log((" VBoxGuest::vbgdNtGuestPower: Telling the VMMDev to close the VM ...\n"));510 Log(("vgdrvNtPower: Telling the VMMDev to close the VM ...\n")); 513 511 514 512 VMMDevPowerStateRequest *pReq = pDevExt->pPowerStateRequest; … … 522 520 } 523 521 if (RT_FAILURE(vrc)) 524 Log((" VBoxGuest::PowerStateRequest: Error communicating new power status to VMMDev. vrc = %Rrc\n", vrc));522 Log(("vgdrvNtPower: Error communicating new power status to VMMDev. vrc = %Rrc\n", vrc)); 525 523 526 524 /* No need to do cleanup here; at this point we should've been … … 532 530 case PowerActionHibernate: 533 531 534 Log((" VBoxGuest::vbgdNtGuestPower: Power action hibernate!\n"));532 Log(("vgdrvNtPower: Power action hibernate!\n")); 535 533 break; 536 534 } … … 566 564 IoCopyCurrentIrpStackLocationToNext(pIrp); 567 565 IoSetCompletionRoutine(pIrp, 568 v bgdNtPowerComplete,566 vgdrvNtPowerComplete, 569 567 (PVOID)pDevExt, 570 568 TRUE, -
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-win.cpp
r58089 r58113 45 45 *********************************************************************************************************************************/ 46 46 RT_C_DECLS_BEGIN 47 static NTSTATUS vbgdNtAddDevice(PDRIVER_OBJECT pDrvObj, PDEVICE_OBJECT pDevObj); 48 static void vbgdNtUnload(PDRIVER_OBJECT pDrvObj); 49 static NTSTATUS vbgdNtCreate(PDEVICE_OBJECT pDevObj, PIRP pIrp); 50 static NTSTATUS vbgdNtClose(PDEVICE_OBJECT pDevObj, PIRP pIrp); 51 static NTSTATUS vbgdNtIOCtl(PDEVICE_OBJECT pDevObj, PIRP pIrp); 52 static NTSTATUS vbgdNtInternalIOCtl(PDEVICE_OBJECT pDevObj, PIRP pIrp); 53 static NTSTATUS vbgdNtRegistryReadDWORD(ULONG ulRoot, PCWSTR pwszPath, PWSTR pwszName, PULONG puValue); 54 static NTSTATUS vbgdNtSystemControl(PDEVICE_OBJECT pDevObj, PIRP pIrp); 55 static NTSTATUS vbgdNtShutdown(PDEVICE_OBJECT pDevObj, PIRP pIrp); 56 static NTSTATUS vbgdNtNotSupportedStub(PDEVICE_OBJECT pDevObj, PIRP pIrp); 57 #ifdef DEBUG 58 static void vbgdNtDoTests(void); 59 #endif 47 static NTSTATUS vgdrvNtAddDevice(PDRIVER_OBJECT pDrvObj, PDEVICE_OBJECT pDevObj); 48 static void vgdrvNtUnload(PDRIVER_OBJECT pDrvObj); 49 static NTSTATUS vgdrvNtCreate(PDEVICE_OBJECT pDevObj, PIRP pIrp); 50 static NTSTATUS vgdrvNtClose(PDEVICE_OBJECT pDevObj, PIRP pIrp); 51 static NTSTATUS vgdrvNtIOCtl(PDEVICE_OBJECT pDevObj, PIRP pIrp); 52 static NTSTATUS vgdrvNtInternalIOCtl(PDEVICE_OBJECT pDevObj, PIRP pIrp); 53 static NTSTATUS vgdrvNtRegistryReadDWORD(ULONG ulRoot, PCWSTR pwszPath, PWSTR pwszName, PULONG puValue); 54 static NTSTATUS vgdrvNtSystemControl(PDEVICE_OBJECT pDevObj, PIRP pIrp); 55 static NTSTATUS vgdrvNtShutdown(PDEVICE_OBJECT pDevObj, PIRP pIrp); 56 static NTSTATUS vgdrvNtNotSupportedStub(PDEVICE_OBJECT pDevObj, PIRP pIrp); 57 #ifdef VBOX_STRICT 58 static void vgdrvNtDoTests(void); 59 #endif 60 static VOID vgdrvNtDpcHandler(PKDPC pDPC, PDEVICE_OBJECT pDevObj, PIRP pIrp, PVOID pContext); 61 static BOOLEAN vgdrvNtIsrHandler(PKINTERRUPT interrupt, PVOID serviceContext); 62 static NTSTATUS vgdrvNtScanPCIResourceList(PCM_RESOURCE_LIST pResList, PVBOXGUESTDEVEXTWIN pDevExt); 63 static NTSTATUS vgdrvNtMapVMMDevMemory(PVBOXGUESTDEVEXTWIN pDevExt, PHYSICAL_ADDRESS PhysAddr, ULONG cbToMap, 64 void **ppvMMIOBase, uint32_t *pcbMMIO); 60 65 RT_C_DECLS_END 61 66 … … 70 75 #ifdef ALLOC_PRAGMA 71 76 # pragma alloc_text(INIT, DriverEntry) 72 # pragma alloc_text(PAGE, v bgdNtAddDevice)73 # pragma alloc_text(PAGE, v bgdNtUnload)74 # pragma alloc_text(PAGE, v bgdNtCreate)75 # pragma alloc_text(PAGE, v bgdNtClose)76 # pragma alloc_text(PAGE, v bgdNtShutdown)77 # pragma alloc_text(PAGE, v bgdNtNotSupportedStub)78 # pragma alloc_text(PAGE, v bgdNtScanPCIResourceList)77 # pragma alloc_text(PAGE, vgdrvNtAddDevice) 78 # pragma alloc_text(PAGE, vgdrvNtUnload) 79 # pragma alloc_text(PAGE, vgdrvNtCreate) 80 # pragma alloc_text(PAGE, vgdrvNtClose) 81 # pragma alloc_text(PAGE, vgdrvNtShutdown) 82 # pragma alloc_text(PAGE, vgdrvNtNotSupportedStub) 83 # pragma alloc_text(PAGE, vgdrvNtScanPCIResourceList) 79 84 #endif 80 85 … … 84 89 *********************************************************************************************************************************/ 85 90 /** The detected NT (windows) version. */ 86 V BGDNTVER g_enmVbgdNtVer = VBGDNTVER_INVALID;91 VGDRVNTVER g_enmVGDrvNtVer = VGDRVNTVER_INVALID; 87 92 88 93 … … 103 108 /* 104 109 * Check if the the NT version is supported and initializing 105 * g_enmV bgdNtVer in the process.110 * g_enmVGDrvNtVer in the process. 106 111 */ 107 112 ULONG ulMajorVer; … … 115 120 RTLogBackdoorPrintf("VBoxGuest: Windows checked build\n"); 116 121 117 #ifdef DEBUG118 v bgdNtDoTests();122 #ifdef VBOX_STRICT 123 vgdrvNtDoTests(); 119 124 #endif 120 125 switch (ulMajorVer) … … 127 132 default: 128 133 /* Also everything newer. */ 129 g_enmV bgdNtVer = VBGDNTVER_WIN10;134 g_enmVGDrvNtVer = VGDRVNTVER_WIN10; 130 135 break; 131 136 } … … 135 140 { 136 141 case 0: /* Note: Also could be Windows 2008 Server! */ 137 g_enmV bgdNtVer = VBGDNTVER_WINVISTA;142 g_enmVGDrvNtVer = VGDRVNTVER_WINVISTA; 138 143 break; 139 144 case 1: /* Note: Also could be Windows 2008 Server R2! */ 140 g_enmV bgdNtVer = VBGDNTVER_WIN7;145 g_enmVGDrvNtVer = VGDRVNTVER_WIN7; 141 146 break; 142 147 case 2: 143 g_enmV bgdNtVer = VBGDNTVER_WIN8;148 g_enmVGDrvNtVer = VGDRVNTVER_WIN8; 144 149 break; 145 150 case 3: 146 g_enmV bgdNtVer = VBGDNTVER_WIN81;151 g_enmVGDrvNtVer = VGDRVNTVER_WIN81; 147 152 break; 148 153 case 4: … … 150 155 default: 151 156 /* Also everything newer. */ 152 g_enmV bgdNtVer = VBGDNTVER_WIN10;157 g_enmVGDrvNtVer = VGDRVNTVER_WIN10; 153 158 break; 154 159 } … … 159 164 default: 160 165 case 2: 161 g_enmV bgdNtVer = VBGDNTVER_WIN2K3;166 g_enmVGDrvNtVer = VGDRVNTVER_WIN2K3; 162 167 break; 163 168 case 1: 164 g_enmV bgdNtVer = VBGDNTVER_WINXP;169 g_enmVGDrvNtVer = VGDRVNTVER_WINXP; 165 170 break; 166 171 case 0: 167 g_enmV bgdNtVer = VBGDNTVER_WIN2K;172 g_enmVGDrvNtVer = VGDRVNTVER_WIN2K; 168 173 break; 169 174 } 170 175 break; 171 176 case 4: 172 g_enmV bgdNtVer = VBGDNTVER_WINNT4;177 g_enmVGDrvNtVer = VGDRVNTVER_WINNT4; 173 178 break; 174 179 default: … … 176 181 { 177 182 /* "Windows 10 mode" for Windows 8.1+. */ 178 g_enmV bgdNtVer = VBGDNTVER_WIN10;183 g_enmVGDrvNtVer = VGDRVNTVER_WIN10; 179 184 } 180 185 else … … 194 199 * Setup the driver entry points in pDrvObj. 195 200 */ 196 pDrvObj->DriverUnload = v bgdNtUnload;197 pDrvObj->MajorFunction[IRP_MJ_CREATE] = v bgdNtCreate;198 pDrvObj->MajorFunction[IRP_MJ_CLOSE] = v bgdNtClose;199 pDrvObj->MajorFunction[IRP_MJ_DEVICE_CONTROL] = v bgdNtIOCtl;200 pDrvObj->MajorFunction[IRP_MJ_INTERNAL_DEVICE_CONTROL] = v bgdNtInternalIOCtl;201 pDrvObj->MajorFunction[IRP_MJ_SHUTDOWN] = v bgdNtShutdown;202 pDrvObj->MajorFunction[IRP_MJ_READ] = v bgdNtNotSupportedStub;203 pDrvObj->MajorFunction[IRP_MJ_WRITE] = v bgdNtNotSupportedStub;201 pDrvObj->DriverUnload = vgdrvNtUnload; 202 pDrvObj->MajorFunction[IRP_MJ_CREATE] = vgdrvNtCreate; 203 pDrvObj->MajorFunction[IRP_MJ_CLOSE] = vgdrvNtClose; 204 pDrvObj->MajorFunction[IRP_MJ_DEVICE_CONTROL] = vgdrvNtIOCtl; 205 pDrvObj->MajorFunction[IRP_MJ_INTERNAL_DEVICE_CONTROL] = vgdrvNtInternalIOCtl; 206 pDrvObj->MajorFunction[IRP_MJ_SHUTDOWN] = vgdrvNtShutdown; 207 pDrvObj->MajorFunction[IRP_MJ_READ] = vgdrvNtNotSupportedStub; 208 pDrvObj->MajorFunction[IRP_MJ_WRITE] = vgdrvNtNotSupportedStub; 204 209 #ifdef TARGET_NT4 205 rc = v bgdNt4CreateDevice(pDrvObj, NULL /* pDevObj */, pRegPath);210 rc = vgdrvNt4CreateDevice(pDrvObj, NULL /* pDevObj */, pRegPath); 206 211 #else 207 pDrvObj->MajorFunction[IRP_MJ_PNP] = v bgdNtPnP;208 pDrvObj->MajorFunction[IRP_MJ_POWER] = v bgdNtPower;209 pDrvObj->MajorFunction[IRP_MJ_SYSTEM_CONTROL] = v bgdNtSystemControl;210 pDrvObj->DriverExtension->AddDevice = (PDRIVER_ADD_DEVICE)v bgdNtAddDevice;212 pDrvObj->MajorFunction[IRP_MJ_PNP] = vgdrvNtPnP; 213 pDrvObj->MajorFunction[IRP_MJ_POWER] = vgdrvNtPower; 214 pDrvObj->MajorFunction[IRP_MJ_SYSTEM_CONTROL] = vgdrvNtSystemControl; 215 pDrvObj->DriverExtension->AddDevice = (PDRIVER_ADD_DEVICE)vgdrvNtAddDevice; 211 216 #endif 212 217 } … … 222 227 * 223 228 * @returns NT status code 224 * @param pDrvObj Driver object 225 * @param pDevObj Device object 226 */ 227 static NTSTATUS vbgdNtAddDevice(PDRIVER_OBJECT pDrvObj, PDEVICE_OBJECT pDevObj) 229 * @param pDrvObj Driver object 230 * @param pDevObj Device object 231 * 232 * @remarks Parts of this is duplicated in VBoxGuest-win-legacy.cpp. 233 */ 234 static NTSTATUS vgdrvNtAddDevice(PDRIVER_OBJECT pDrvObj, PDEVICE_OBJECT pDevObj) 228 235 { 229 236 NTSTATUS rc; … … 255 262 KeInitializeSpinLock(&pDevExt->MouseEventAccessLock); 256 263 257 pDevExt->pDeviceObject = pDeviceObject;258 pDevExt-> prevDevState =STOPPED;259 pDevExt-> devState =STOPPED;264 pDevExt->pDeviceObject = pDeviceObject; 265 pDevExt->enmPrevDevState = VGDRVNTDEVSTATE_STOPPED; 266 pDevExt->enmDevState = VGDRVNTDEVSTATE_STOPPED; 260 267 261 268 pDevExt->pNextLowerDriver = IoAttachDeviceToDeviceStack(pDeviceObject, pDevObj); … … 267 274 */ 268 275 #ifdef VBOX_WITH_GUEST_BUGCHECK_DETECTION 269 v bgdNtBugCheckCallback(pDevExt); /* Ignore failure! */276 vgdrvNtBugCheckCallback(pDevExt); /* Ignore failure! */ 270 277 #endif 271 278 if (NT_SUCCESS(rc)) … … 276 283 /* Driver is ready now. */ 277 284 pDeviceObject->Flags &= ~DO_DEVICE_INITIALIZING; 278 LogFlowFunc(("Returning with rc= 0x%x (success)\n", rc));285 LogFlowFunc(("Returning with rc=%#x (success)\n", rc)); 279 286 return rc; 280 287 } … … 298 305 LogFunc(("IoCreateDevice failed with rc=%#x!\n", rc)); 299 306 300 LogFunc(("Returning with rc= 0x%x\n", rc));307 LogFunc(("Returning with rc=%#x\n", rc)); 301 308 return rc; 302 309 } 303 #endif 304 305 310 #endif /* TARGET_NT4 */ 311 312 313 #ifdef LOG_ENABLED 306 314 /** 307 315 * Debug helper to dump a device resource list. … … 309 317 * @param pResourceList list of device resources. 310 318 */ 311 static void vbgdNtShowDeviceResources(PCM_PARTIAL_RESOURCE_LIST pResourceList) 312 { 313 #ifdef LOG_ENABLED 319 static void vgdrvNtShowDeviceResources(PCM_PARTIAL_RESOURCE_LIST pResourceList) 320 { 314 321 PCM_PARTIAL_RESOURCE_DESCRIPTOR pResource = pResourceList->PartialDescriptors; 315 322 ULONG cResources = pResourceList->Count; … … 339 346 case CmResourceTypeMemory: 340 347 LogFunc(("Start %8X%8.8lX, length=%X\n", 341 pResource->u.Port.Start.HighPart, pResource->u.Port.Start.LowPart, 342 pResource->u.Port.Length)); 348 pResource->u.Port.Start.HighPart, pResource->u.Port.Start.LowPart, pResource->u.Port.Length)); 343 349 break; 344 350 345 351 case CmResourceTypeInterrupt: 346 352 LogFunc(("Level=%X, vector=%X, affinity=%X\n", 347 pResource->u.Interrupt.Level, pResource->u.Interrupt.Vector, 348 pResource->u.Interrupt.Affinity)); 353 pResource->u.Interrupt.Level, pResource->u.Interrupt.Vector, pResource->u.Interrupt.Affinity)); 349 354 break; 350 355 351 356 case CmResourceTypeDma: 352 LogFunc(("Channel %d, Port %X\n", 353 pResource->u.Dma.Channel, pResource->u.Dma.Port)); 357 LogFunc(("Channel %d, Port %X\n", pResource->u.Dma.Channel, pResource->u.Dma.Port)); 354 358 break; 355 359 … … 359 363 } 360 364 } 361 #endif 362 } 365 } 366 #endif /* LOG_ENABLED */ 363 367 364 368 … … 370 374 */ 371 375 #ifndef TARGET_NT4 372 NTSTATUS v bgdNtInit(PDEVICE_OBJECT pDevObj, PIRP pIrp)376 NTSTATUS vgdrvNtInit(PDEVICE_OBJECT pDevObj, PIRP pIrp) 373 377 #else 374 NTSTATUS v bgdNtInit(PDRIVER_OBJECT pDrvObj, PDEVICE_OBJECT pDevObj, PUNICODE_STRING pRegPath)378 NTSTATUS vgdrvNtInit(PDRIVER_OBJECT pDrvObj, PDEVICE_OBJECT pDevObj, PUNICODE_STRING pRegPath) 375 379 #endif 376 380 { … … 382 386 LogFlowFuncEnter(); 383 387 384 int rc = STATUS_SUCCESS; /** @todo r=bird: s/rc/rcNt/ and s/int/NTSTATUS/. gee. */388 NTSTATUS rcNt; 385 389 #ifdef TARGET_NT4 386 390 /* … … 393 397 UNICODE_STRING classNameString; 394 398 RtlInitUnicodeString(&classNameString, L"VBoxGuestAdapter"); 395 rc = HalAssignSlotResources(pRegPath, &classNameString, 396 pDrvObj, pDevObj, 397 PCIBus, pDevExt->busNumber, pDevExt->slotNumber, 398 &pResourceList); 399 rcNt = HalAssignSlotResources(pRegPath, &classNameString, pDrvObj, pDevObj, 400 PCIBus, pDevExt->busNumber, pDevExt->slotNumber, &pResourceList); 401 # ifdef LOG_ENABLED 399 402 if (pResourceList && pResourceList->Count > 0) 400 vbgdNtShowDeviceResources(&pResourceList->List[0].PartialResourceList); 401 if (NT_SUCCESS(rc)) 402 rc = vbgdNtScanPCIResourceList(pResourceList, pDevExt); 403 vgdrvNtShowDeviceResources(&pResourceList->List[0].PartialResourceList); 404 # endif 405 if (NT_SUCCESS(rcNt)) 406 rcNt = vgdrvNtScanPCIResourceList(pResourceList, pDevExt); 403 407 #else 408 # ifdef LOG_ENABLED 404 409 if (pStack->Parameters.StartDevice.AllocatedResources->Count > 0) 405 v bgdNtShowDeviceResources(&pStack->Parameters.StartDevice.AllocatedResources->List[0].PartialResourceList);406 if (NT_SUCCESS(rc)) 407 rc = vbgdNtScanPCIResourceList(pStack->Parameters.StartDevice.AllocatedResourcesTranslated, pDevExt);408 #endif 409 if (NT_SUCCESS(rc ))410 vgdrvNtShowDeviceResources(&pStack->Parameters.StartDevice.AllocatedResources->List[0].PartialResourceList); 411 # endif 412 rcNt = vgdrvNtScanPCIResourceList(pStack->Parameters.StartDevice.AllocatedResourcesTranslated, pDevExt); 413 #endif 414 if (NT_SUCCESS(rcNt)) 410 415 { 411 416 /* … … 415 420 void *pvMMIOBase = NULL; 416 421 uint32_t cbMMIO = 0; 417 rc = vbgdNtMapVMMDevMemory(pDevExt,418 pDevExt->vmmDevPhysMemoryAddress,419 pDevExt->vmmDevPhysMemoryLength,420 &pvMMIOBase,421 &cbMMIO);422 if (NT_SUCCESS(rc ))422 rcNt = vgdrvNtMapVMMDevMemory(pDevExt, 423 pDevExt->vmmDevPhysMemoryAddress, 424 pDevExt->vmmDevPhysMemoryLength, 425 &pvMMIOBase, 426 &cbMMIO); 427 if (NT_SUCCESS(rcNt)) 423 428 { 424 429 pDevExt->Core.pVMMDevMemory = (VMMDevMemory *)pvMMIOBase; … … 430 435 pDevExt->Core.IOPortBase, 431 436 pvMMIOBase, cbMMIO, 432 v bgdNtVersionToOSType(g_enmVbgdNtVer),437 vgdrvNtVersionToOSType(g_enmVGDrvNtVer), 433 438 VMMDEV_EVENT_MOUSE_POSITION_CHANGED); 434 439 if (RT_FAILURE(vrc)) 435 440 { 436 LogFunc(("Could not init device extension, rc=%Rrc\n", vrc));437 rc = STATUS_DEVICE_CONFIGURATION_ERROR;441 LogFunc(("Could not init device extension, vrc=%Rrc\n", vrc)); 442 rcNt = STATUS_DEVICE_CONFIGURATION_ERROR; 438 443 } 439 444 } 440 445 else 441 LogFunc(("Could not map physical address of VMMDev, rc =0x%x\n", rc));442 } 443 444 if (NT_SUCCESS(rc ))446 LogFunc(("Could not map physical address of VMMDev, rcNt=%#x\n", rcNt)); 447 } 448 449 if (NT_SUCCESS(rcNt)) 445 450 { 446 451 int vrc = VbglGRAlloc((VMMDevRequestHeader **)&pDevExt->pPowerStateRequest, … … 448 453 if (RT_FAILURE(vrc)) 449 454 { 450 LogFunc(("Alloc for pPowerStateRequest failed, rc=%Rrc\n", vrc));451 rc = STATUS_UNSUCCESSFUL;455 LogFunc(("Alloc for pPowerStateRequest failed, vrc=%Rrc\n", vrc)); 456 rcNt = STATUS_UNSUCCESSFUL; 452 457 } 453 458 } 454 459 455 if (NT_SUCCESS(rc ))460 if (NT_SUCCESS(rcNt)) 456 461 { 457 462 /* … … 460 465 LogFlowFunc(("Initializing DPC/ISR ...\n")); 461 466 462 IoInitializeDpcRequest(pDevExt->pDeviceObject, v bgdNtDpcHandler);467 IoInitializeDpcRequest(pDevExt->pDeviceObject, vgdrvNtDpcHandler); 463 468 #ifdef TARGET_NT4 464 469 ULONG uInterruptVector; … … 489 494 LogFlowFunc(("Connecting interrupt ...\n")); 490 495 491 rc = IoConnectInterrupt(&pDevExt->pInterruptObject, /* Out: interrupt object. */492 (PKSERVICE_ROUTINE)vbgdNtIsrHandler, /* Our ISR handler. */493 pDevExt, /* Device context. */494 NULL, /* Optional spinlock. */496 rcNt = IoConnectInterrupt(&pDevExt->pInterruptObject, /* Out: interrupt object. */ 497 (PKSERVICE_ROUTINE)vgdrvNtIsrHandler, /* Our ISR handler. */ 498 pDevExt, /* Device context. */ 499 NULL, /* Optional spinlock. */ 495 500 #ifdef TARGET_NT4 496 uInterruptVector, /* Interrupt vector. */497 irqLevel, /* Interrupt level. */498 irqLevel, /* Interrupt level. */501 uInterruptVector, /* Interrupt vector. */ 502 irqLevel, /* Interrupt level. */ 503 irqLevel, /* Interrupt level. */ 499 504 #else 500 pDevExt->interruptVector, /* Interrupt vector. */501 (KIRQL)pDevExt->interruptLevel, /* Interrupt level. */502 (KIRQL)pDevExt->interruptLevel, /* Interrupt level. */503 #endif 504 pDevExt->interruptMode, /* LevelSensitive or Latched. */505 TRUE, /* Shareable interrupt. */506 pDevExt->interruptAffinity, /* CPU affinity. */507 FALSE); /* Don't save FPU stack. */508 if (NT_ERROR(rc ))509 LogFunc(("Could not connect interrupt, rc =0x%x\n", rc));505 pDevExt->interruptVector, /* Interrupt vector. */ 506 (KIRQL)pDevExt->interruptLevel, /* Interrupt level. */ 507 (KIRQL)pDevExt->interruptLevel, /* Interrupt level. */ 508 #endif 509 pDevExt->interruptMode, /* LevelSensitive or Latched. */ 510 TRUE, /* Shareable interrupt. */ 511 pDevExt->interruptAffinity, /* CPU affinity. */ 512 FALSE); /* Don't save FPU stack. */ 513 if (NT_ERROR(rcNt)) 514 LogFunc(("Could not connect interrupt, rcNt=%#x\n", rcNt)); 510 515 } 511 516 else … … 519 524 if (RT_FAILURE(vrc)) 520 525 { 521 LogFunc(("Failed to allocated kernel session data, rc=%Rrc\n", rc)); 522 rc = STATUS_UNSUCCESSFUL; 523 } 524 #endif 525 526 if (RT_SUCCESS(rc)) 527 { 528 ULONG ulValue = 0; 529 NTSTATUS rcNt = vbgdNtRegistryReadDWORD(RTL_REGISTRY_SERVICES, 530 L"VBoxGuest", L"LoggingEnabled", &ulValue); 531 if (NT_SUCCESS(rcNt)) 526 LogFunc(("Failed to allocated kernel session data, vrc=%Rrc\n", vrc)); 527 rcNt = STATUS_UNSUCCESSFUL; 528 } 529 #endif 530 531 if (RT_SUCCESS(rcNt)) 532 { 533 ULONG uValue = 0; 534 NTSTATUS rcNt2 = vgdrvNtRegistryReadDWORD(RTL_REGISTRY_SERVICES, L"VBoxGuest", L"LoggingEnabled", &uValue); 535 if (NT_SUCCESS(rcNt2)) 532 536 { 533 pDevExt->Core.fLoggingEnabled = u lValue >= 0xFF;537 pDevExt->Core.fLoggingEnabled = uValue >= 0xFF; 534 538 if (pDevExt->Core.fLoggingEnabled) 535 LogRelFunc(("Logging to host log enabled ( 0x%x)", ulValue));539 LogRelFunc(("Logging to host log enabled (%#x)", uValue)); 536 540 } 537 541 538 542 /* Ready to rumble! */ 539 543 LogRelFunc(("Device is ready!\n")); 540 VBOXGUEST_UPDATE_DEVSTATE(pDevExt, WORKING);544 VBOXGUEST_UPDATE_DEVSTATE(pDevExt, VGDRVNTDEVSTATE_WORKING); 541 545 } 542 546 else … … 546 550 * whole bunch of things... */ 547 551 548 LogFunc(("Returned with rc =0x%x\n", rc));549 return rc ;552 LogFunc(("Returned with rcNt=%#x\n", rcNt)); 553 return rcNt; 550 554 } 551 555 … … 557 561 * @param pDevObj Device object. 558 562 */ 559 NTSTATUS v bgdNtCleanup(PDEVICE_OBJECT pDevObj)563 NTSTATUS vgdrvNtCleanup(PDEVICE_OBJECT pDevObj) 560 564 { 561 565 LogFlowFuncEnter(); … … 565 569 { 566 570 567 #if 0 /* @todo:test & enable cleaning global session data */571 #if 0 /** @todo test & enable cleaning global session data */ 568 572 #ifdef VBOX_WITH_HGCM 569 573 if (pDevExt->pKernelSession) 570 574 { 571 V bgdCommonCloseSession(pDevExt, pDevExt->pKernelSession);575 VGDrvCommonCloseSession(pDevExt, pDevExt->pKernelSession); 572 576 pDevExt->pKernelSession = NULL; 573 577 } … … 581 585 } 582 586 583 /** @todo :cleanup the rest stuff */587 /** @todo cleanup the rest stuff */ 584 588 585 589 … … 588 592 #endif 589 593 /* According to MSDN we have to unmap previously mapped memory. */ 590 v bgdNtUnmapVMMDevMemory(pDevExt);594 vgdrvNtUnmapVMMDevMemory(pDevExt); 591 595 } 592 596 … … 600 604 * @param pDrvObj Driver object. 601 605 */ 602 static void v bgdNtUnload(PDRIVER_OBJECT pDrvObj)606 static void vgdrvNtUnload(PDRIVER_OBJECT pDrvObj) 603 607 { 604 608 LogFlowFuncEnter(); 605 609 606 610 #ifdef TARGET_NT4 607 v bgdNtCleanup(pDrvObj->DeviceObject);611 vgdrvNtCleanup(pDrvObj->DeviceObject); 608 612 609 613 /* Destroy device extension and clean up everything else. */ … … 636 640 * @param pIrp Request packet. 637 641 */ 638 static NTSTATUS v bgdNtCreate(PDEVICE_OBJECT pDevObj, PIRP pIrp)642 static NTSTATUS vgdrvNtCreate(PDEVICE_OBJECT pDevObj, PIRP pIrp) 639 643 { 640 644 /** @todo AssertPtrReturn(pIrp); */ … … 645 649 NTSTATUS rc = STATUS_SUCCESS; 646 650 647 if (pDevExt-> devState !=WORKING)648 { 649 LogFunc(("Device is not working currently, state=%d\n", pDevExt-> devState));651 if (pDevExt->enmDevState != VGDRVNTDEVSTATE_WORKING) 652 { 653 LogFunc(("Device is not working currently, state=%d\n", pDevExt->enmDevState)); 650 654 rc = STATUS_UNSUCCESSFUL; 651 655 } … … 692 696 IoCompleteRequest(pIrp, IO_NO_INCREMENT); 693 697 694 LogFlowFunc(("Returning rc= 0x%x\n", rc));698 LogFlowFunc(("Returning rc=%#x\n", rc)); 695 699 return rc; 696 700 } … … 703 707 * @param pIrp Request packet. 704 708 */ 705 static NTSTATUS v bgdNtClose(PDEVICE_OBJECT pDevObj, PIRP pIrp)709 static NTSTATUS vgdrvNtClose(PDEVICE_OBJECT pDevObj, PIRP pIrp) 706 710 { 707 711 PVBOXGUESTDEVEXTWIN pDevExt = (PVBOXGUESTDEVEXTWIN)pDevObj->DeviceExtension; … … 709 713 PFILE_OBJECT pFileObj = pStack->FileObject; 710 714 711 LogFlowFunc(("pDevExt=0x%p, pFileObj=0x%p, FsContext=0x%p\n", 712 pDevExt, pFileObj, pFileObj->FsContext)); 715 LogFlowFunc(("pDevExt=0x%p, pFileObj=0x%p, FsContext=0x%p\n", pDevExt, pFileObj, pFileObj->FsContext)); 713 716 714 717 #ifdef VBOX_WITH_HGCM … … 734 737 * @param pIrp Request packet. 735 738 */ 736 static NTSTATUS v bgdNtIOCtl(PDEVICE_OBJECT pDevObj, PIRP pIrp)739 static NTSTATUS vgdrvNtIOCtl(PDEVICE_OBJECT pDevObj, PIRP pIrp) 737 740 { 738 741 NTSTATUS Status = STATUS_SUCCESS; … … 751 754 pSession = (PVBOXGUESTSESSION)pFileObj->FsContext; 752 755 753 LogFlowFunc(("uCmd=%u, pDevExt=0x%p, pSession=0x%p\n", 754 uCmd, pDevExt, pSession)); 756 LogFlowFunc(("uCmd=%u, pDevExt=0x%p, pSession=0x%p\n", uCmd, pDevExt, pSession)); 755 757 756 758 /* We don't have a session associated with the file object? So this seems … … 823 825 * @param pIrp Request packet. 824 826 */ 825 static NTSTATUS v bgdNtInternalIOCtl(PDEVICE_OBJECT pDevObj, PIRP pIrp)827 static NTSTATUS vgdrvNtInternalIOCtl(PDEVICE_OBJECT pDevObj, PIRP pIrp) 826 828 { 827 829 NTSTATUS Status = STATUS_SUCCESS; … … 877 879 * No override, go to common code. 878 880 */ 879 return v bgdNtIOCtl(pDevObj, pIrp);881 return vgdrvNtIOCtl(pDevObj, pIrp); 880 882 } 881 883 … … 888 890 * @param pIrp IRP. 889 891 */ 890 NTSTATUS vbgdNtSystemControl(PDEVICE_OBJECT pDevObj, PIRP pIrp)892 static NTSTATUS vgdrvNtSystemControl(PDEVICE_OBJECT pDevObj, PIRP pIrp) 891 893 { 892 894 PVBOXGUESTDEVEXTWIN pDevExt = (PVBOXGUESTDEVEXTWIN)pDevObj->DeviceExtension; … … 908 910 * @param pIrp IRP. 909 911 */ 910 NTSTATUS vbgdNtShutdown(PDEVICE_OBJECT pDevObj, PIRP pIrp)912 static NTSTATUS vgdrvNtShutdown(PDEVICE_OBJECT pDevObj, PIRP pIrp) 911 913 { 912 914 PVBOXGUESTDEVEXTWIN pDevExt = (PVBOXGUESTDEVEXTWIN)pDevObj->DeviceExtension; … … 936 938 * @param pIrp IRP. 937 939 */ 938 NTSTATUS vbgdNtNotSupportedStub(PDEVICE_OBJECT pDevObj, PIRP pIrp)940 static NTSTATUS vgdrvNtNotSupportedStub(PDEVICE_OBJECT pDevObj, PIRP pIrp) 939 941 { 940 942 LogFlowFuncEnter(); … … 956 958 * @param pContext Context specific pointer. 957 959 */ 958 void vbgdNtDpcHandler(PKDPC pDPC, PDEVICE_OBJECT pDevObj, PIRP pIrp, PVOID pContext)960 static void vgdrvNtDpcHandler(PKDPC pDPC, PDEVICE_OBJECT pDevObj, PIRP pIrp, PVOID pContext) 959 961 { 960 962 PVBOXGUESTDEVEXTWIN pDevExt = (PVBOXGUESTDEVEXTWIN)pDevObj->DeviceExtension; … … 976 978 977 979 /* Process the wake-up list we were asked by the scheduling a DPC 978 * in v bgdNtIsrHandler(). */980 * in vgdrvNtIsrHandler(). */ 979 981 VGDrvCommonWaitDoWakeUps(&pDevExt->Core); 980 982 } … … 988 990 * @param pServiceContext Context specific pointer. 989 991 */ 990 BOOLEAN vbgdNtIsrHandler(PKINTERRUPT pInterrupt, PVOID pServiceContext)992 static BOOLEAN vgdrvNtIsrHandler(PKINTERRUPT pInterrupt, PVOID pServiceContext) 991 993 { 992 994 PVBOXGUESTDEVEXTWIN pDevExt = (PVBOXGUESTDEVEXTWIN)pServiceContext; … … 1040 1042 * registry value if found. 1041 1043 */ 1042 NTSTATUS vbgdNtRegistryReadDWORD(ULONG ulRoot, PCWSTR pwszPath, PWSTR pwszName, PULONG puValue)1044 static NTSTATUS vgdrvNtRegistryReadDWORD(ULONG ulRoot, PCWSTR pwszPath, PWSTR pwszName, PULONG puValue) 1043 1045 { 1044 1046 if (!pwszPath || !pwszName || !puValue) … … 1071 1073 * @param pDevExt Device extension 1072 1074 */ 1073 NTSTATUS vbgdNtScanPCIResourceList(PCM_RESOURCE_LIST pResList, PVBOXGUESTDEVEXTWIN pDevExt)1075 static NTSTATUS vgdrvNtScanPCIResourceList(PCM_RESOURCE_LIST pResList, PVBOXGUESTDEVEXTWIN pDevExt) 1074 1076 { 1075 1077 /* Enumerate the resource list. */ … … 1203 1205 * @param pcbMMIO Length of mapped I/O base. 1204 1206 */ 1205 NTSTATUS vbgdNtMapVMMDevMemory(PVBOXGUESTDEVEXTWIN pDevExt, PHYSICAL_ADDRESS PhysAddr, ULONG cbToMap,1206 void **ppvMMIOBase, uint32_t *pcbMMIO)1207 static NTSTATUS vgdrvNtMapVMMDevMemory(PVBOXGUESTDEVEXTWIN pDevExt, PHYSICAL_ADDRESS PhysAddr, ULONG cbToMap, 1208 void **ppvMMIOBase, uint32_t *pcbMMIO) 1207 1209 { 1208 1210 AssertPtrReturn(pDevExt, VERR_INVALID_POINTER); … … 1214 1216 { 1215 1217 VMMDevMemory *pVMMDevMemory = (VMMDevMemory *)MmMapIoSpace(PhysAddr, cbToMap, MmNonCached); 1216 LogFlowFunc(("pVMMDevMemory = 0x%x\n", pVMMDevMemory));1218 LogFlowFunc(("pVMMDevMemory = %#x\n", pVMMDevMemory)); 1217 1219 if (pVMMDevMemory) 1218 1220 { 1219 LogFunc(("VMMDevMemory: Version = 0x%x, Size = %d\n", pVMMDevMemory->u32Version, pVMMDevMemory->u32Size));1221 LogFunc(("VMMDevMemory: Version = %#x, Size = %d\n", pVMMDevMemory->u32Version, pVMMDevMemory->u32Size)); 1220 1222 1221 1223 /* Check version of the structure; do we have the right memory version? */ … … 1234 1236 LogFunc(("Wrong version (%u), refusing operation!\n", pVMMDevMemory->u32Version)); 1235 1237 1236 v bgdNtUnmapVMMDevMemory(pDevExt);1238 vgdrvNtUnmapVMMDevMemory(pDevExt); 1237 1239 rc = STATUS_UNSUCCESSFUL; 1238 1240 } … … 1250 1252 * @param pDevExt The device extension. 1251 1253 */ 1252 void v bgdNtUnmapVMMDevMemory(PVBOXGUESTDEVEXTWIN pDevExt)1253 { 1254 LogFlowFunc(("pVMMDevMemory = 0x%x\n", pDevExt->Core.pVMMDevMemory));1254 void vgdrvNtUnmapVMMDevMemory(PVBOXGUESTDEVEXTWIN pDevExt) 1255 { 1256 LogFlowFunc(("pVMMDevMemory = %#x\n", pDevExt->Core.pVMMDevMemory)); 1255 1257 if (pDevExt->Core.pVMMDevMemory) 1256 1258 { … … 1264 1266 1265 1267 1266 VBOXOSTYPE vbgdNtVersionToOSType(VBGDNTVER enmNtVer) 1268 /** 1269 * Translates NT version to VBox OS. 1270 * 1271 * @returns VBox OS type. 1272 * @param enmNtVer The NT version. 1273 */ 1274 VBOXOSTYPE vgdrvNtVersionToOSType(VGDRVNTVER enmNtVer) 1267 1275 { 1268 1276 VBOXOSTYPE enmOsType; 1269 1277 switch (enmNtVer) 1270 1278 { 1271 case V BGDNTVER_WINNT4:1279 case VGDRVNTVER_WINNT4: 1272 1280 enmOsType = VBOXOSTYPE_WinNT4; 1273 1281 break; 1274 1282 1275 case V BGDNTVER_WIN2K:1283 case VGDRVNTVER_WIN2K: 1276 1284 enmOsType = VBOXOSTYPE_Win2k; 1277 1285 break; 1278 1286 1279 case V BGDNTVER_WINXP:1287 case VGDRVNTVER_WINXP: 1280 1288 #if ARCH_BITS == 64 1281 1289 enmOsType = VBOXOSTYPE_WinXP_x64; … … 1285 1293 break; 1286 1294 1287 case V BGDNTVER_WIN2K3:1295 case VGDRVNTVER_WIN2K3: 1288 1296 #if ARCH_BITS == 64 1289 1297 enmOsType = VBOXOSTYPE_Win2k3_x64; … … 1293 1301 break; 1294 1302 1295 case V BGDNTVER_WINVISTA:1303 case VGDRVNTVER_WINVISTA: 1296 1304 #if ARCH_BITS == 64 1297 1305 enmOsType = VBOXOSTYPE_WinVista_x64; … … 1301 1309 break; 1302 1310 1303 case V BGDNTVER_WIN7:1311 case VGDRVNTVER_WIN7: 1304 1312 #if ARCH_BITS == 64 1305 1313 enmOsType = VBOXOSTYPE_Win7_x64; … … 1309 1317 break; 1310 1318 1311 case V BGDNTVER_WIN8:1319 case VGDRVNTVER_WIN8: 1312 1320 #if ARCH_BITS == 64 1313 1321 enmOsType = VBOXOSTYPE_Win8_x64; … … 1317 1325 break; 1318 1326 1319 case V BGDNTVER_WIN81:1327 case VGDRVNTVER_WIN81: 1320 1328 #if ARCH_BITS == 64 1321 1329 enmOsType = VBOXOSTYPE_Win81_x64; … … 1325 1333 break; 1326 1334 1327 case V BGDNTVER_WIN10:1335 case VGDRVNTVER_WIN10: 1328 1336 #if ARCH_BITS == 64 1329 1337 enmOsType = VBOXOSTYPE_Win10_x64; … … 1341 1349 } 1342 1350 1343 #ifdef DEBUG1351 #ifdef VBOX_STRICT 1344 1352 1345 1353 /** 1346 1354 * A quick implementation of AtomicTestAndClear for uint32_t and multiple bits. 1347 1355 */ 1348 static uint32_t v boxugestwinAtomicBitsTestAndClear(void *pu32Bits, uint32_t u32Mask)1356 static uint32_t vgdrvNtAtomicBitsTestAndClear(void *pu32Bits, uint32_t u32Mask) 1349 1357 { 1350 1358 AssertPtrReturn(pu32Bits, 0); 1351 LogFlowFunc(("*pu32Bits= 0x%x, u32Mask=0x%x\n", *(uint32_t *)pu32Bits, u32Mask));1359 LogFlowFunc(("*pu32Bits=%#x, u32Mask=%#x\n", *(uint32_t *)pu32Bits, u32Mask)); 1352 1360 uint32_t u32Result = 0; 1353 1361 uint32_t u32WorkingMask = u32Mask; … … 1362 1370 iBitOffset = ASMBitFirstSetU32 (u32WorkingMask); 1363 1371 } 1364 LogFlowFunc(("Returning 0x%x\n", u32Result));1372 LogFlowFunc(("Returning %#x\n", u32Result)); 1365 1373 return u32Result; 1366 1374 } 1367 1375 1368 1376 1369 static void v bgdNtTestAtomicTestAndClearBitsU32(uint32_t u32Mask, uint32_t u32Bits, uint32_t u32Exp)1377 static void vgdrvNtTestAtomicTestAndClearBitsU32(uint32_t u32Mask, uint32_t u32Bits, uint32_t u32Exp) 1370 1378 { 1371 1379 ULONG u32Bits2 = u32Bits; 1372 uint32_t u32Result = v boxugestwinAtomicBitsTestAndClear(&u32Bits2, u32Mask);1380 uint32_t u32Result = vgdrvNtAtomicBitsTestAndClear(&u32Bits2, u32Mask); 1373 1381 if ( u32Result != u32Exp 1374 1382 || (u32Bits2 & u32Mask) … … 1376 1384 || ((u32Bits2 | u32Result) != u32Bits) 1377 1385 ) 1378 AssertLogRelMsgFailed(("%s: TEST FAILED: u32Mask=0x%x, u32Bits (before)=0x%x, u32Bits (after)=0x%x, u32Result=0x%x, u32Exp=ox%x\n", 1379 __PRETTY_FUNCTION__, u32Mask, u32Bits, u32Bits2, 1380 u32Result)); 1381 } 1382 1383 1384 static void vbgdNtDoTests(void) 1385 { 1386 vbgdNtTestAtomicTestAndClearBitsU32(0x00, 0x23, 0); 1387 vbgdNtTestAtomicTestAndClearBitsU32(0x11, 0, 0); 1388 vbgdNtTestAtomicTestAndClearBitsU32(0x11, 0x22, 0); 1389 vbgdNtTestAtomicTestAndClearBitsU32(0x11, 0x23, 0x1); 1390 vbgdNtTestAtomicTestAndClearBitsU32(0x11, 0x32, 0x10); 1391 vbgdNtTestAtomicTestAndClearBitsU32(0x22, 0x23, 0x22); 1392 } 1393 1394 #endif /* DEBUG */ 1386 AssertLogRelMsgFailed(("TEST FAILED: u32Mask=%#x, u32Bits (before)=%#x, u32Bits (after)=%#x, u32Result=%#x, u32Exp=%#x\n", 1387 u32Mask, u32Bits, u32Bits2, u32Result)); 1388 } 1389 1390 1391 static void vgdrvNtDoTests(void) 1392 { 1393 vgdrvNtTestAtomicTestAndClearBitsU32(0x00, 0x23, 0); 1394 vgdrvNtTestAtomicTestAndClearBitsU32(0x11, 0, 0); 1395 vgdrvNtTestAtomicTestAndClearBitsU32(0x11, 0x22, 0); 1396 vgdrvNtTestAtomicTestAndClearBitsU32(0x11, 0x23, 0x1); 1397 vgdrvNtTestAtomicTestAndClearBitsU32(0x11, 0x32, 0x10); 1398 vgdrvNtTestAtomicTestAndClearBitsU32(0x22, 0x23, 0x22); 1399 } 1400 1401 #endif /* VBOX_STRICT */ 1395 1402 1396 1403 #ifdef VBOX_WITH_DPC_LATENCY_CHECKER … … 1451 1458 * @param SystemArgument2 System use, ignored. 1452 1459 */ 1453 static VOID v bgdNtDpcLatencyCallback(PKDPC pDpc, PVOID pvDeferredContext, PVOID SystemArgument1, PVOID SystemArgument2)1460 static VOID vgdrvNtDpcLatencyCallback(PKDPC pDpc, PVOID pvDeferredContext, PVOID SystemArgument1, PVOID SystemArgument2) 1454 1461 { 1455 1462 DPCDATA *pData = (DPCDATA *)pvDeferredContext; … … 1496 1503 * Initialize the data. 1497 1504 */ 1498 KeInitializeDpc(&pData->Dpc, v bgdNtDpcLatencyCallback, pData);1505 KeInitializeDpc(&pData->Dpc, vgdrvNtDpcLatencyCallback, pData); 1499 1506 KeInitializeTimer(&pData->Timer); 1500 1507 KeInitializeSpinLock(&pData->SpinLock); -
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-win.h
r54608 r58113 42 42 43 43 /** Possible device states for our state machine. */ 44 enumDEVSTATE44 typedef enum VGDRVNTDEVSTATE 45 45 { 46 STOPPED,47 WORKING,48 PENDINGSTOP,49 PENDINGREMOVE,50 SURPRISEREMOVED,51 REMOVED52 } ;46 VGDRVNTDEVSTATE_STOPPED, 47 VGDRVNTDEVSTATE_WORKING, 48 VGDRVNTDEVSTATE_PENDINGSTOP, 49 VGDRVNTDEVSTATE_PENDINGREMOVE, 50 VGDRVNTDEVSTATE_SURPRISEREMOVED, 51 VGDRVNTDEVSTATE_REMOVED 52 } VGDRVNTDEVSTATE; 53 53 54 54 typedef struct VBOXGUESTWINBASEADDRESS … … 105 105 106 106 /** Device state. */ 107 DEVSTATE devState; 108 DEVSTATE prevDevState; 107 VGDRVNTDEVSTATE enmDevState; 108 /** The previous device state. */ 109 VGDRVNTDEVSTATE enmPrevDevState; 109 110 110 111 /** Last system power action set (see VBoxGuestPower). */ … … 126 127 127 128 /** NT (windows) version identifier. */ 128 typedef enum V BGDNTVER129 typedef enum VGDRVNTVER 129 130 { 130 V BGDNTVER_INVALID = 0,131 V BGDNTVER_WINNT4,132 V BGDNTVER_WIN2K,133 V BGDNTVER_WINXP,134 V BGDNTVER_WIN2K3,135 V BGDNTVER_WINVISTA,136 V BGDNTVER_WIN7,137 V BGDNTVER_WIN8,138 V BGDNTVER_WIN81,139 V BGDNTVER_WIN10140 } V BGDNTVER;141 extern V BGDNTVER g_enmVbgdNtVer;131 VGDRVNTVER_INVALID = 0, 132 VGDRVNTVER_WINNT4, 133 VGDRVNTVER_WIN2K, 134 VGDRVNTVER_WINXP, 135 VGDRVNTVER_WIN2K3, 136 VGDRVNTVER_WINVISTA, 137 VGDRVNTVER_WIN7, 138 VGDRVNTVER_WIN8, 139 VGDRVNTVER_WIN81, 140 VGDRVNTVER_WIN10 141 } VGDRVNTVER; 142 extern VGDRVNTVER g_enmVGDrvNtVer; 142 143 143 144 144 #define VBOXGUEST_UPDATE_DEVSTATE(a_pDevExt, a_ newDevState) \145 #define VBOXGUEST_UPDATE_DEVSTATE(a_pDevExt, a_enmNewDevState) \ 145 146 do { \ 146 (a_pDevExt)-> prevDevState = (a_pDevExt)->devState; \147 (a_pDevExt)-> devState = (a_newDevState); \147 (a_pDevExt)->enmPrevDevState = (a_pDevExt)->enmDevState; \ 148 (a_pDevExt)->enmDevState = (a_enmNewDevState); \ 148 149 } while (0) 149 150 … … 155 156 156 157 #ifdef TARGET_NT4 157 NTSTATUS v bgdNt4CreateDevice(PDRIVER_OBJECT pDrvObj, PDEVICE_OBJECT pDevObj, PUNICODE_STRING pRegPath);158 NTSTATUS vgdrvNt4CreateDevice(PDRIVER_OBJECT pDrvObj, PDEVICE_OBJECT pDevObj, PUNICODE_STRING pRegPath); 158 159 #else 159 NTSTATUS vbgdNtInit(PDEVICE_OBJECT pDevObj, PIRP pIrp); 160 NTSTATUS vbgdNtPnP(PDEVICE_OBJECT pDevObj, PIRP pIrp); 161 NTSTATUS vbgdNtPower(PDEVICE_OBJECT pDevObj, PIRP pIrp); 160 NTSTATUS vgdrvNtPnP(PDEVICE_OBJECT pDevObj, PIRP pIrp); 161 NTSTATUS vgdrvNtPower(PDEVICE_OBJECT pDevObj, PIRP pIrp); 162 162 #endif 163 163 … … 166 166 */ 167 167 #ifdef TARGET_NT4 168 NTSTATUS v bgdNtInit(PDRIVER_OBJECT pDrvObj, PDEVICE_OBJECT pDevObj, PUNICODE_STRING pRegPath);168 NTSTATUS vgdrvNtInit(PDRIVER_OBJECT pDrvObj, PDEVICE_OBJECT pDevObj, PUNICODE_STRING pRegPath); 169 169 #else 170 NTSTATUS v bgdNtInit(PDEVICE_OBJECT pDevObj, PIRP pIrp);170 NTSTATUS vgdrvNtInit(PDEVICE_OBJECT pDevObj, PIRP pIrp); 171 171 #endif 172 NTSTATUS vbgdNtCleanup(PDEVICE_OBJECT pDevObj); 173 VOID vbgdNtDpcHandler(PKDPC pDPC, PDEVICE_OBJECT pDevObj, PIRP pIrp, PVOID pContext); 174 BOOLEAN vbgdNtIsrHandler(PKINTERRUPT interrupt, PVOID serviceContext); 175 NTSTATUS vbgdNtScanPCIResourceList(PCM_RESOURCE_LIST pResList, PVBOXGUESTDEVEXTWIN pDevExt); 176 NTSTATUS vbgdNtMapVMMDevMemory(PVBOXGUESTDEVEXTWIN pDevExt, PHYSICAL_ADDRESS PhysAddr, ULONG cbToMap, 177 void **ppvMMIOBase, uint32_t *pcbMMIO); 178 void vbgdNtUnmapVMMDevMemory(PVBOXGUESTDEVEXTWIN pDevExt); 179 VBOXOSTYPE vbgdNtVersionToOSType(VBGDNTVER enmNtVer); 172 NTSTATUS vgdrvNtCleanup(PDEVICE_OBJECT pDevObj); 173 void vgdrvNtUnmapVMMDevMemory(PVBOXGUESTDEVEXTWIN pDevExt); /**< @todo make static once buggy vgdrvNtInit is fixed. */ 174 VBOXOSTYPE vgdrvNtVersionToOSType(VGDRVNTVER enmNtVer); 180 175 /** @} */ 181 176 -
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuestA-os2.asm
r54608 r58113 221 221 extern KernThunkStackTo16 222 222 223 extern NAME( VBoxGuestOS2Init)224 extern NAME( VBoxGuestOS2Open)225 extern NAME( VBoxGuestOS2Close)226 extern NAME( VBoxGuestOS2IOCtl)227 extern NAME( VBoxGuestOS2IOCtlFast)228 extern NAME( VBoxGuestOS2IDCConnect)229 extern NAME(V BoxGuestOS2IDCService)230 extern NAME( VBoxGuestOS2ISR)223 extern NAME(vgdrvOS2Init) 224 extern NAME(vgdrvOS2Open) 225 extern NAME(vgdrvOS2Close) 226 extern NAME(vgdrvOS2IOCtl) 227 extern NAME(vgdrvOS2IOCtlFast) 228 extern NAME(vgdrvOS2IDCConnect) 229 extern NAME(VGDrvOS2IDCService) 230 extern NAME(vgdrvOS2ISR) 231 231 232 232 … … 240 240 dw DATA16 ; NextHeader.sel 241 241 dw DEVLEV_3 | DEV_30 | DEV_CHAR_DEV | DEV_IOCTL; SDevAtt 242 dw NAME(V BoxGuestOS2EP) wrt CODE16; StrategyEP243 dw NAME(V BoxGuestOS2IDC) wrt CODE16; IDCEP242 dw NAME(VGDrvOS2Entrypoint) wrt CODE16 ; StrategyEP 243 dw NAME(VGDrvOS2IDC) wrt CODE16 ; IDCEP 244 244 db 'vboxgst$' ; DevName 245 245 dw 0 ; SDevProtCS … … 253 253 dd 0ffffffffh ; NextHeader (NIL) 254 254 dw DEVLEV_3 | DEV_30 | DEV_CHAR_DEV ; SDevAtt 255 dw NAME( VBoxGuestOS2InitEP) wrt CODE16; StrategyEP255 dw NAME(vgdrvOS2InitEntrypoint) wrt CODE16 ; StrategyEP 256 256 dw 0 ; IDCEP 257 257 db 'vboxgs1$' ; DevName … … 276 276 277 277 278 ;; VBoxGuestFindAdapter Output278 ;; vgdrvFindAdapter Output 279 279 ; @{ 280 280 … … 381 381 ; Can clobber any registers it likes except SP. 382 382 ; 383 BEGINPROC V BoxGuestOS2EP383 BEGINPROC VGDrvOS2Entrypoint 384 384 push ebp 385 385 mov ebp, esp … … 392 392 ; 393 393 cmp byte [es:bx + PKTHDR.cmd], 10h ; Generic IOCtl 394 jne near VBoxGuestOS2EP_NotGenIOCtl394 jne near vgdrvOS2EP_NotGenIOCtl 395 395 396 396 … … 398 398 ; Generic I/O Control Request. 399 399 ; 400 VBoxGuestOS2EP_GenIOCtl:400 vgdrvOS2EP_GenIOCtl: 401 401 402 402 ; Fast IOCtl? 403 403 cmp byte [es:bx + PKTIOCTL.cat], VBOXGUEST_IOCTL_CATEGORY_FAST 404 jne VBoxGuestOS2EP_GenIOCtl_Other404 jne vgdrvOS2EP_GenIOCtl_Other 405 405 406 406 ; 407 407 ; Fast IOCtl. 408 ; DECLASM(int) VBoxGuestOS2IOCtlFast(uint16_t sfn, uint8_t iFunction, uint16_t *pcbParm)409 ; 410 VBoxGuestOS2EP_GenIOCtl_Fast:408 ; DECLASM(int) vgdrvOS2IOCtlFast(uint16_t sfn, uint8_t iFunction, uint16_t *pcbParm) 409 ; 410 vgdrvOS2EP_GenIOCtl_Fast: 411 411 mov ax, [es:bx + PKTIOCTL.pData + 2] ; LDT selector to flat address. 412 412 shr ax, 3 … … 423 423 push eax ; 00h 424 424 425 JMP16TO32 VBoxGuestOS2EP_GenIOCtl_Fast_32425 JMP16TO32 vgdrvOS2EP_GenIOCtl_Fast_32 426 426 segment TEXT32 427 GLOBALNAME VBoxGuestOS2EP_GenIOCtl_Fast_32427 GLOBALNAME vgdrvOS2EP_GenIOCtl_Fast_32 428 428 429 429 ; switch stack to 32-bit. … … 434 434 435 435 ; call the C code (don't cleanup the stack). 436 call NAME( VBoxGuestOS2IOCtlFast)436 call NAME(vgdrvOS2IOCtlFast) 437 437 438 438 ; switch back the stack. … … 441 441 pop eax 442 442 443 JMP32TO16 VBoxGuestOS2EP_GenIOCtl_Fast_32443 JMP32TO16 vgdrvOS2EP_GenIOCtl_Fast_32 444 444 segment CODE16 445 GLOBALNAME VBoxGuestOS2EP_GenIOCtl_Fast_16445 GLOBALNAME vgdrvOS2EP_GenIOCtl_Fast_16 446 446 447 447 les bx, [bp - 4] ; Reload the packet pointer. 448 448 or eax, eax 449 jnz near VBoxGuestOS2EP_GeneralFailure449 jnz near vgdrvOS2EP_GeneralFailure 450 450 451 451 ; setup output stuff. … … 462 462 ; Other IOCtl (slow) 463 463 ; 464 VBoxGuestOS2EP_GenIOCtl_Other:464 vgdrvOS2EP_GenIOCtl_Other: 465 465 mov eax, [es:bx + PKTIOCTL.cbParm] ; Load cbParm and cbData 466 466 push eax ; 1eh - in/out data size. … … 476 476 mov dl, DevHlp_VirtToLin 477 477 call far [NAME(g_fpfnDevHlp)] 478 jc near VBoxGuestOS2EP_GeneralFailure478 jc near vgdrvOS2EP_GeneralFailure 479 479 jmp .finish_data 480 480 .no_data: … … 490 490 mov dl, DevHlp_VirtToLin 491 491 call far [NAME(g_fpfnDevHlp)] 492 jc near VBoxGuestOS2EP_GeneralFailure492 jc near vgdrvOS2EP_GeneralFailure 493 493 jmp .finish_parm 494 494 .no_parm: … … 509 509 push eax ; 00h 510 510 511 JMP16TO32 VBoxGuestOS2EP_GenIOCtl_Other_32511 JMP16TO32 vgdrvOS2EP_GenIOCtl_Other_32 512 512 segment TEXT32 513 GLOBALNAME VBoxGuestOS2EP_GenIOCtl_Other_32513 GLOBALNAME vgdrvOS2EP_GenIOCtl_Other_32 514 514 515 515 ; switch stack to 32-bit. … … 526 526 527 527 ; call the C code (don't cleanup the stack). 528 call NAME( VBoxGuestOS2IOCtl)528 call NAME(vgdrvOS2IOCtl) 529 529 530 530 ; switch back the stack. … … 533 533 pop eax 534 534 535 JMP32TO16 VBoxGuestOS2EP_GenIOCtl_Other_16535 JMP32TO16 vgdrvOS2EP_GenIOCtl_Other_16 536 536 segment CODE16 537 GLOBALNAME VBoxGuestOS2EP_GenIOCtl_Other_16537 GLOBALNAME vgdrvOS2EP_GenIOCtl_Other_16 538 538 539 539 les bx, [bp - 4] ; Reload the packet pointer. 540 540 or eax, eax 541 jnz near VBoxGuestOS2EP_GeneralFailure541 jnz near vgdrvOS2EP_GeneralFailure 542 542 543 543 ; setup output stuff. … … 555 555 ; Less Performance Critical Requests. 556 556 ; 557 VBoxGuestOS2EP_NotGenIOCtl:557 vgdrvOS2EP_NotGenIOCtl: 558 558 cmp byte [es:bx + PKTHDR.cmd], 0dh ; Open 559 je VBoxGuestOS2EP_Open559 je vgdrvOS2EP_Open 560 560 cmp byte [es:bx + PKTHDR.cmd], 0eh ; Close 561 je VBoxGuestOS2EP_Close561 je vgdrvOS2EP_Close 562 562 cmp byte [es:bx + PKTHDR.cmd], 00h ; Init 563 je VBoxGuestOS2EP_Init563 je vgdrvOS2EP_Init 564 564 %ifdef DEBUG_READ 565 565 cmp byte [es:bx + PKTHDR.cmd], 04h ; Read 566 je near VBoxGuestOS2EP_Read566 je near vgdrvOS2EP_Read 567 567 %endif 568 jmp near VBoxGuestOS2EP_NotSupported568 jmp near vgdrvOS2EP_NotSupported 569 569 570 570 … … 572 572 ; Open Request. w/ ring-0 init. 573 573 ; 574 VBoxGuestOS2EP_Open:574 vgdrvOS2EP_Open: 575 575 cmp byte [NAME(g_fInitialized)], 1 576 jne VBoxGuestOS2EP_OpenOther576 jne vgdrvOS2EP_OpenOther 577 577 578 578 ; First argument, the system file number. … … 580 580 push eax 581 581 582 JMP16TO32 VBoxGuestOS2EP_Open_32582 JMP16TO32 vgdrvOS2EP_Open_32 583 583 segment TEXT32 584 GLOBALNAME VBoxGuestOS2EP_Open_32584 GLOBALNAME vgdrvOS2EP_Open_32 585 585 586 586 ; switch stack to 32-bit. … … 591 591 592 592 ; call the C code. 593 call NAME( VBoxGuestOS2Open)593 call NAME(vgdrvOS2Open) 594 594 595 595 ; switch back the stack. … … 598 598 pop eax 599 599 600 JMP32TO16 VBoxGuestOS2EP_Open_16600 JMP32TO16 vgdrvOS2EP_Open_16 601 601 segment CODE16 602 GLOBALNAME VBoxGuestOS2EP_Open_16602 GLOBALNAME vgdrvOS2EP_Open_16 603 603 604 604 les bx, [bp - 4] ; Reload the packet pointer. 605 605 or eax, eax 606 jnz near VBoxGuestOS2EP_GeneralFailure606 jnz near vgdrvOS2EP_GeneralFailure 607 607 mov word [es:bx + PKTHDR.status], 00100h ; done, ok. 608 jmp near VBoxGuestOS2EP_Done608 jmp near vgdrvOS2EP_Done 609 609 610 610 ; Initializing or failed init? 611 VBoxGuestOS2EP_OpenOther:611 vgdrvOS2EP_OpenOther: 612 612 cmp byte [NAME(g_fInitialized)], 0 613 jne VBoxGuestOS2EP_OpenFailed613 jne vgdrvOS2EP_OpenFailed 614 614 615 615 mov byte [NAME(g_fInitialized)], -1 616 call NAME( VBoxGuestRing0Init)616 call NAME(vgdrvRing0Init) 617 617 cmp byte [NAME(g_fInitialized)], 1 618 je VBoxGuestOS2EP_Open619 620 VBoxGuestOS2EP_OpenFailed:618 je vgdrvOS2EP_Open 619 620 vgdrvOS2EP_OpenFailed: 621 621 mov word [es:bx + PKTHDR.status], 0810fh ; error, done, init failed. 622 jmp near VBoxGuestOS2EP_Done622 jmp near vgdrvOS2EP_Done 623 623 624 624 … … 626 626 ; Close Request. 627 627 ; 628 VBoxGuestOS2EP_Close:628 vgdrvOS2EP_Close: 629 629 ; First argument, the system file number. 630 630 movzx eax, word [es:bx + PKTOPEN.sfn] 631 631 push eax 632 632 633 JMP16TO32 VBoxGuestOS2EP_Close_32633 JMP16TO32 vgdrvOS2EP_Close_32 634 634 segment TEXT32 635 GLOBALNAME VBoxGuestOS2EP_Close_32635 GLOBALNAME vgdrvOS2EP_Close_32 636 636 637 637 ; switch stack to 32-bit. … … 642 642 643 643 ; call the C code. 644 call NAME( VBoxGuestOS2Close)644 call NAME(vgdrvOS2Close) 645 645 646 646 ; switch back the stack. … … 649 649 pop eax 650 650 651 JMP32TO16 VBoxGuestOS2EP_Close_16651 JMP32TO16 vgdrvOS2EP_Close_16 652 652 segment CODE16 653 GLOBALNAME VBoxGuestOS2EP_Close_16653 GLOBALNAME vgdrvOS2EP_Close_16 654 654 655 655 les bx, [bp - 4] ; Reload the packet pointer. 656 656 or eax, eax 657 jnz near VBoxGuestOS2EP_GeneralFailure657 jnz near vgdrvOS2EP_GeneralFailure 658 658 mov word [es:bx + PKTHDR.status], 00100h ; done, ok. 659 jmp near VBoxGuestOS2EP_Done659 jmp near vgdrvOS2EP_Done 660 660 661 661 … … 664 664 ; Find the VMMDev adapter so we can unload the driver (and avoid trouble) if not found. 665 665 ; 666 VBoxGuestOS2EP_Init:667 call NAME( VBoxGuestFindAdapter)666 vgdrvOS2EP_Init: 667 call NAME(vgdrvFindAdapter) 668 668 test ax, ax 669 669 jz .ok 670 670 mov word [es:bx + PKTHDR.status], 0810fh ; error, done, init failed. 671 call NAME( VBoxGuestOS2InitFlushText)671 call NAME(vgdrvOS2InitFlushText) 672 672 jmp .next 673 673 .ok: … … 678 678 mov word [es:bx + PKTINITOUT.cbData16], NAME(g_InitDataStart) wrt DATA16 679 679 mov dword [es:bx + PKTINITOUT.fpaBPBs], 0 680 jmp near VBoxGuestOS2EP_Done680 jmp near vgdrvOS2EP_Done 681 681 682 682 … … 686 686 ; Return log data. 687 687 ; 688 VBoxGuestOS2EP_Read:688 vgdrvOS2EP_Read: 689 689 ; Any log data available? 690 690 xor dx, dx … … 735 735 mov word [es:bx + PKTRW.cbTrans], dx 736 736 mov word [es:bx + PKTHDR.status], 00100h ; done, ok. 737 jmp near VBoxGuestOS2EP_Done737 jmp near vgdrvOS2EP_Done 738 738 739 739 .log_phystovirt_failed: 740 740 les bx, [bp - 4] ; Reload the packet pointer. 741 jmp VBoxGuestOS2EP_GeneralFailure741 jmp vgdrvOS2EP_GeneralFailure 742 742 %endif ; DEBUG_READ 743 743 … … 746 746 ; Return 'unknown command' error. 747 747 ; 748 VBoxGuestOS2EP_NotSupported:748 vgdrvOS2EP_NotSupported: 749 749 mov word [es:bx + PKTHDR.status], 08103h ; error, done, unknown command. 750 jmp VBoxGuestOS2EP_Done750 jmp vgdrvOS2EP_Done 751 751 752 752 ; 753 753 ; Return 'general failure' error. 754 754 ; 755 VBoxGuestOS2EP_GeneralFailure:755 vgdrvOS2EP_GeneralFailure: 756 756 mov word [es:bx + PKTHDR.status], 0810ch ; error, done, general failure. 757 jmp VBoxGuestOS2EP_Done757 jmp vgdrvOS2EP_Done 758 758 759 759 ; 760 760 ; Non-optimized return path. 761 761 ; 762 VBoxGuestOS2EP_Done:762 vgdrvOS2EP_Done: 763 763 mov sp, bp 764 764 pop ebp 765 765 retf 766 ENDPROC V BoxGuestOS2EP766 ENDPROC VGDrvOS2Entrypoint 767 767 768 768 … … 773 773 ; do ring-3 init and report failures. 774 774 ; 775 GLOBALNAME VBoxGuestOS2InitEP775 GLOBALNAME vgdrvOS2InitEntryPoint 776 776 ; The only request we're servicing is the 'init' one. 777 777 cmp word [es:bx + PKTHDR.cmd], 0 778 je near NAME( VBoxGuestOS2InitEPServiceInitReq)778 je near NAME(vgdrvOS2InitEntryPointServiceInitReq) 779 779 780 780 ; Ok, it's not the init request, just fail it. … … 789 789 ; will provide the entry points that we'll be using. 790 790 ; 791 ; @cproto void far __cdecl V BoxGuestOS2IDC(VBOXGUESTOS2IDCCONNECT far *fpConnectInfo);791 ; @cproto void far __cdecl VGDrvOS2IDC(VBOXGUESTOS2IDCCONNECT far *fpConnectInfo); 792 792 ; 793 793 ; @param fpConnectInfo [bp + 8] Pointer to an VBOXGUESTOS2IDCCONNECT structure. 794 794 ; 795 GLOBALNAME V BoxGuestOS2IDC795 GLOBALNAME VGDrvOS2IDC 796 796 push ebp ; bp - 0h 797 797 mov ebp, esp … … 805 805 and sp, 0fffch 806 806 807 JMP16TO32 V BoxGuestOS2IDC_32807 JMP16TO32 VGDrvOS2IDC_32 808 808 segment TEXT32 809 GLOBALNAME V BoxGuestOS2IDC_32809 GLOBALNAME VGDrvOS2IDC_32 810 810 811 811 ; switch stack to 32-bit. … … 816 816 817 817 ; call the C code. 818 call NAME( VBoxGuestOS2IDCConnect)818 call NAME(vgdrvOS2IDCConnect) 819 819 820 820 ; … … 828 828 mov dword [ebx + VBGOS2IDC.u32Version ], VMMDEV_VERSION 829 829 mov dword [ebx + VBGOS2IDC.u32Session ], eax 830 mov dword [ebx + VBGOS2IDC.pfnServiceEP ], NAME(V BoxGuestOS2IDCService)831 mov word [ebx + VBGOS2IDC.fpfnServiceEP ], NAME(V BoxGuestOs2IDCService16) wrt CODE16830 mov dword [ebx + VBGOS2IDC.pfnServiceEP ], NAME(VGDrvOS2IDCService) 831 mov word [ebx + VBGOS2IDC.fpfnServiceEP ], NAME(VGDrvOS2IDCService16) wrt CODE16 832 832 mov word [ebx + VBGOS2IDC.fpfnServiceEP + 2], CODE16 833 mov word [ebx + VBGOS2IDC.fpfnServiceAsmEP ], NAME(V BoxGuestOs2IDCService16Asm) wrt CODE16833 mov word [ebx + VBGOS2IDC.fpfnServiceAsmEP ], NAME(VGDrvOS2IDCService16Asm) wrt CODE16 834 834 mov word [ebx + VBGOS2IDC.fpfnServiceAsmEP+2],CODE16 835 835 … … 840 840 call KernThunkStackTo16 841 841 842 JMP32TO16 V BoxGuestOS2IDC_16842 JMP32TO16 VGDrvOS2IDC_16 843 843 segment CODE16 844 GLOBALNAME V BoxGuestOS2IDC_16844 GLOBALNAME VGDrvOS2IDC_16 845 845 846 846 ; restore. … … 854 854 pop ebp 855 855 retf 856 ENDPROC V BoxGuestOS2IDC856 ENDPROC VGDrvOS2IDC 857 857 858 858 … … 875 875 ; This can be NULL if pvData is NULL. 876 876 ; 877 ; @cproto long far __cdecl V BoxGuestOs2IDCService16(uint32_t u32Session, uint16_t iFunction, void far *fpvData, uint16_t cbData, uint16_t far *pcbDataReturned);878 ; 879 GLOBALNAME V BoxGuestOs2IDCService16877 ; @cproto long far __cdecl VGDrvOS2IDCService16(uint32_t u32Session, uint16_t iFunction, void far *fpvData, uint16_t cbData, uint16_t far *pcbDataReturned); 878 ; 879 GLOBALNAME VGDrvOS2IDCService16 880 880 push ebp ; bp - 0h 881 881 mov ebp, esp … … 908 908 mov dl, DevHlp_VirtToLin 909 909 call far [NAME(g_fpfnDevHlp)] 910 jc near V BoxGuestOs2IDCService16_InvalidPointer910 jc near VGDrvOS2IDCService16_InvalidPointer 911 911 jmp .finish_data 912 912 .no_data: … … 919 919 push ecx ; esp + 00h: u32Session 920 920 921 JMP16TO32 V BoxGuestOs2IDCService16_32921 JMP16TO32 VGDrvOS2IDCService16_32 922 922 segment TEXT32 923 GLOBALNAME V BoxGuestOs2IDCService16_32923 GLOBALNAME VGDrvOS2IDCService16_32 924 924 925 925 ; switch stack to 32-bit. … … 934 934 935 935 ; call the C code (don't cleanup the stack). 936 call NAME(V BoxGuestOS2IDCService)936 call NAME(VGDrvOS2IDCService) 937 937 938 938 ; switch back the stack. … … 941 941 pop eax 942 942 943 JMP32TO16 V BoxGuestOs2IDCService16_16943 JMP32TO16 VGDrvOS2IDCService16_16 944 944 segment CODE16 945 GLOBALNAME V BoxGuestOs2IDCService16_16945 GLOBALNAME VGDrvOS2IDCService16_16 946 946 947 947 ; Set *pcbDataReturned. … … 955 955 .no_pcbDataReturned: 956 956 957 V BoxGuestOs2IDCService16_Done:957 VGDrvOS2IDCService16_Done: 958 958 lea sp, [bp - 10h] 959 959 pop esi … … 965 965 retf 966 966 967 V BoxGuestOs2IDCService16_InvalidPointer:967 VGDrvOS2IDCService16_InvalidPointer: 968 968 mov ax, VERR_INVALID_POINTER 969 jmp V BoxGuestOs2IDCService16_Done970 ENDPROC V BoxGuestOs2IDCService16969 jmp VGDrvOS2IDCService16_Done 970 ENDPROC VGDrvOS2IDCService16 971 971 972 972 … … 974 974 ; The 16-bit IDC entry point, register based. 975 975 ; 976 ; This is just a wrapper around V BoxGuestOs2IDCService16 to simplify976 ; This is just a wrapper around VGDrvOS2IDCService16 to simplify 977 977 ; calls from 16-bit assembly code. 978 978 ; … … 984 984 ; @param cbData cx - The size of the data buffer. 985 985 ; 986 GLOBALNAME V BoxGuestOs2IDCService16Asm986 GLOBALNAME VGDrvOS2IDCService16Asm 987 987 push ebp ; bp - 0h 988 988 mov ebp, esp … … 1005 1005 mov [bp - 18h], eax ; bp - 18h (dd): u32Session 1006 1006 1007 call NAME(V BoxGuestOs2IDCService16)1007 call NAME(VGDrvOS2IDCService16) 1008 1008 1009 1009 mov cx, [bp - 08h] ; cbDataReturned. … … 1013 1013 pop ebp 1014 1014 retf 1015 ENDPROC V BoxGuestOs2IDCService16Asm1015 ENDPROC VGDrvOS2IDCService16Asm 1016 1016 1017 1017 … … 1027 1027 ; 1028 1028 ; 1029 GLOBALNAME VBoxGuestOS2ISR161029 GLOBALNAME vgdrvOS2ISR16 1030 1030 push ebp 1031 1031 mov ebp, esp … … 1043 1043 and sp, 0fff0h ; align the stack (16-bytes make GCC extremely happy). 1044 1044 1045 JMP16TO32 VBoxGuestOS2ISR16_321045 JMP16TO32 vgdrvOS2ISR16_32 1046 1046 segment TEXT32 1047 GLOBALNAME VBoxGuestOS2ISR16_321047 GLOBALNAME vgdrvOS2ISR16_32 1048 1048 1049 1049 mov ax, DATA32 wrt FLAT … … 1053 1053 call KernThunkStackTo32 1054 1054 1055 call NAME( VBoxGuestOS2ISR)1055 call NAME(vgdrvOS2ISR) 1056 1056 mov ebx, eax 1057 1057 1058 1058 call KernThunkStackTo16 1059 1059 1060 JMP32TO16 VBoxGuestOS2ISR16_161060 JMP32TO16 vgdrvOS2ISR16_16 1061 1061 segment CODE16 1062 GLOBALNAME VBoxGuestOS2ISR16_161062 GLOBALNAME vgdrvOS2ISR16_16 1063 1063 1064 1064 lea sp, [bp - 1eh] … … 1093 1093 clc 1094 1094 retf 1095 ENDPROC VBoxGuestOS2ISR161095 ENDPROC vgdrvOS2ISR16 1096 1096 1097 1097 … … 1110 1110 ; @param bIrq [ebp + 8] The IRQ number. (uint8_t) 1111 1111 ; 1112 GLOBALNAME VBoxGuestOS2SetIRQ1112 GLOBALNAME vgdrvOS2DevHlpSetIRQ 1113 1113 push ebp 1114 1114 mov ebp, esp … … 1120 1120 movzx ebx, byte [ebp + 8] ; load bIrq into BX. 1121 1121 1122 JMP32TO16 VBoxGuestOS2SetIRQ_161122 JMP32TO16 vgdrvOS2DevHlpSetIRQ_16 1123 1123 segment CODE16 1124 GLOBALNAME VBoxGuestOS2SetIRQ_161124 GLOBALNAME vgdrvOS2DevHlpSetIRQ_16 1125 1125 1126 1126 mov ax, DATA16 ; for g_fpfnDevHlp. 1127 1127 mov ds, ax 1128 mov ax, NAME( VBoxGuestOS2ISR16); The devhlp assume it's relative to DS.1128 mov ax, NAME(vgdrvOS2ISR16) ; The devhlp assume it's relative to DS. 1129 1129 mov dh, 1 ; 1 = shared 1130 1130 mov dl, DevHlp_SetIRQ … … 1140 1140 1141 1141 .go_back: 1142 JMP16TO32 VBoxGuestOS2SetIRQ_321142 JMP16TO32 vgdrvOS2DevHlpSetIRQ_32 1143 1143 segment TEXT32 1144 GLOBALNAME VBoxGuestOS2SetIRQ_321144 GLOBALNAME vgdrvOS2DevHlpSetIRQ_32 1145 1145 1146 1146 pop ds ; KernThunkStackTo32 ASSUMES flat DS and ES. … … 1153 1153 pop ebp 1154 1154 ret 1155 ENDPROC VBoxGuestOS2SetIRQ1155 ENDPROC vgdrvOS2DevHlpSetIRQ 1156 1156 1157 1157 … … 1179 1179 ; The Ring-3 init code. 1180 1180 ; 1181 BEGINPROC VBoxGuestOS2InitEPServiceInitReq1181 BEGINPROC vgdrvOS2InitEntryPointServiceInitReq 1182 1182 push ebp 1183 1183 mov ebp, esp … … 1227 1227 1228 1228 push ax ; Quickly flush any text. 1229 call NAME( VBoxGuestOS2InitFlushText)1229 call NAME(vgdrvOS2InitFlushText) 1230 1230 pop ax 1231 1231 … … 1275 1275 pop ebp 1276 1276 retf 1277 ENDPROC VBoxGuestOS2InitEPServiceInitReq1277 ENDPROC vgdrvOS2InitEntryPointServiceInitReq 1278 1278 1279 1279 … … 1281 1281 ; The Ring-0 init code. 1282 1282 ; 1283 BEGINPROC VBoxGuestRing0Init1283 BEGINPROC vgdrvRing0Init 1284 1284 push es 1285 1285 push esi … … 1295 1295 mov dl, DevHlp_VirtToLin 1296 1296 call far [NAME(g_fpfnDevHlp)] 1297 jc near VBoxGuestRing0Init_done; eax is non-zero on failure (can't happen)1298 push eax ; 00h - pszArgs (for VBoxGuestOS2Init).1297 jc near vgdrvRing0Init_done ; eax is non-zero on failure (can't happen) 1298 push eax ; 00h - pszArgs (for vgdrvOS2Init). 1299 1299 1300 1300 ; … … 1306 1306 ; Do 32-bit init 1307 1307 ; 1308 JMP16TO32 VBoxGuestRing0Init_321308 JMP16TO32 vgdrvRing0Init_32 1309 1309 segment TEXT32 1310 GLOBALNAME VBoxGuestRing0Init_321310 GLOBALNAME vgdrvRing0Init_32 1311 1311 1312 1312 ; switch stack to 32-bit. … … 1317 1317 1318 1318 ; call the C code. 1319 call NAME( VBoxGuestOS2Init)1319 call NAME(vgdrvOS2Init) 1320 1320 1321 1321 ; switch back the stack and reload ds. … … 1327 1327 mov ds, dx 1328 1328 1329 JMP32TO16 VBoxGuestRing0Init_161329 JMP32TO16 vgdrvRing0Init_16 1330 1330 segment CODE16_INIT 1331 GLOBALNAME VBoxGuestRing0Init_161331 GLOBALNAME vgdrvRing0Init_16 1332 1332 1333 1333 ; check the result and set g_fInitialized on success. 1334 1334 or eax, eax 1335 jnz VBoxGuestRing0Init_done1335 jnz vgdrvRing0Init_done 1336 1336 mov byte [NAME(g_fInitialized)], 1 1337 1337 1338 VBoxGuestRing0Init_done:1338 vgdrvRing0Init_done: 1339 1339 mov sp, bp 1340 1340 pop ebp … … 1342 1342 pop es 1343 1343 ret 1344 ENDPROC VBoxGuestRing0Init1344 ENDPROC vgdrvRing0Init 1345 1345 1346 1346 … … 1348 1348 ; Flush any text in the text buffer. 1349 1349 ; 1350 BEGINPROC VBoxGuestOS2InitFlushText1350 BEGINPROC vgdrvOS2InitFlushText 1351 1351 push bp 1352 1352 mov bp, sp … … 1407 1407 pop bp 1408 1408 ret 1409 ENDPROC VBoxGuestOS2InitFlushText1409 ENDPROC vgdrvOS2InitFlushText 1410 1410 1411 1411 … … 1427 1427 ; @uses nothing. 1428 1428 ; 1429 BEGINPROC VBoxGuestFindAdapter1429 BEGINPROC vgdrvFindAdapter 1430 1430 push ebx 1431 1431 push ecx … … 1601 1601 1602 1602 ; 1603 ; Return to VBoxGuestOS2EP_Init.1603 ; Return to vgdrvOS2EP_Init. 1604 1604 ; 1605 1605 .done: … … 1647 1647 ; 1648 1648 ; Nested function which reads a PCI config register. 1649 ; (This operates on the VBoxGuestFindAdapter stack frame.)1649 ; (This operates on the vgdrvFindAdapter stack frame.) 1650 1650 ; 1651 1651 ; Input: … … 1679 1679 ret 1680 1680 1681 ENDPROC VBoxGuestFindAdapter1681 ENDPROC vgdrvFindAdapter 1682 1682 1683 1683 -
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuestIDC-unix.c.h
r58089 r58113 89 89 #endif 90 90 91 LogRel(("VBoxGuestIDCOpen: V bgdCommonCreateKernelSession failed. rc=%d\n", rc));91 LogRel(("VBoxGuestIDCOpen: VGDrvCommonCreateKernelSession failed. rc=%d\n", rc)); 92 92 return NULL; 93 93 } … … 103 103 { 104 104 PVBOXGUESTSESSION pSession = (PVBOXGUESTSESSION)pvSession; 105 LogFlow(("VBoxGuestIDCClose: \n"));105 LogFlow(("VBoxGuestIDCClose: pvSession=%p\n", pvSession)); 106 106 107 107 AssertPtrReturn(pSession, VERR_INVALID_POINTER); … … 141 141 142 142 AssertPtrReturn(pSession, VERR_INVALID_POINTER); 143 AssertMsgReturn(pSession->pDevExt == &g_DevExt, 144 ("SC: %p != %p\n", pSession->pDevExt, &g_DevExt), VERR_INVALID_HANDLE); 143 AssertMsgReturn(pSession->pDevExt == &g_DevExt, ("SC: %p != %p\n", pSession->pDevExt, &g_DevExt), VERR_INVALID_HANDLE); 145 144 146 145 return VGDrvCommonIoCtl(iCmd, &g_DevExt, pSession, pvData, cbData, pcbDataReturned); -
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuestInternal.h
r58089 r58113 1 1 /* $Id$ */ 2 2 /** @file 3 * VBoxGuest - Guest Additions Driver .3 * VBoxGuest - Guest Additions Driver, Internal Header. 4 4 */ 5 5 … … 65 65 uint32_t volatile fResEvents; 66 66 #ifdef VBOXGUEST_USE_DEFERRED_WAKE_UP 67 /** Set by V bgdCommonWaitDoWakeUps before leaving the spinlock to call67 /** Set by VGDrvCommonWaitDoWakeUps before leaving the spinlock to call 68 68 * RTSemEventMultiSignal. */ 69 69 bool volatile fPendingWakeUp; 70 70 /** Set by the requestor thread if it got the spinlock before the 71 * signaller. Deals with the race in V bgdCommonWaitDoWakeUps. */71 * signaller. Deals with the race in VGDrvCommonWaitDoWakeUps. */ 72 72 bool volatile fFreeMe; 73 73 #endif
Note:
See TracChangeset
for help on using the changeset viewer.