Changeset 10263 in vbox for trunk/src/VBox/HostDrivers
- Timestamp:
- Jul 5, 2008 12:26:17 AM (16 years ago)
- Location:
- trunk/src/VBox/HostDrivers/Support
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/Support/Makefile.kmk
r10258 r10263 307 307 vboxdrv_INCS := $(PATH_SUB_CURRENT) 308 308 vboxdrv_LIBS = $(PATH_LIB)/RuntimeR0Drv$(VBOX_SUFF_LIB) 309 vboxdrv_SOURCES 309 vboxdrv_SOURCES := \ 310 310 $(KBUILD_TARGET)/SUPDrv-$(KBUILD_TARGET).c \ 311 SUPDrv.c 311 $(PATH_SUB_CURRENT)/$(KBUILD_TARGET)/SUPDrv-$(KBUILD_TARGET).def \ 312 SUPDrv.c 313 ## @todo the SUPDrv-freebsd.def is most probably gonna break it and require build system hacking... 312 314 endif # freebsd 313 315 -
trunk/src/VBox/HostDrivers/Support/SUPDrv.c
r10255 r10263 1160 1160 1161 1161 /** 1162 * Inter-Driver Communcation (IDC) worker. 1163 * 1164 * @returns 0 on success. 1165 * @returns VERR_INVALID_PARAMETER if the request is invalid. 1166 * 1167 * @param uReq The request (function) code. 1168 * @param pDevExt Device extention. 1169 * @param pSession Session data. 1170 * @param pReqHdr The request header. 1171 */ 1172 int VBOXCALL supdrvIDC(uintptr_t uReq, PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, PSUPDRVIDCREQHDR pReqHdr) 1173 { 1174 return VERR_NOT_IMPLEMENTED; 1175 } 1176 1177 1178 /** 1162 1179 * Register a object for reference counting. 1163 1180 * The object is registered with one reference in the specified session. -
trunk/src/VBox/HostDrivers/Support/SUPDrvInternal.h
r10256 r10263 125 125 126 126 #include "SUPDrvIOC.h" 127 #include "SUPDrvIDC.h" 127 128 128 129 … … 637 638 int VBOXCALL supdrvIOCtl(uintptr_t uIOCtl, PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, PSUPREQHDR pReqHdr); 638 639 int VBOXCALL supdrvIOCtlFast(uintptr_t uIOCtl, PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession); 640 int VBOXCALL supdrvIDC(uintptr_t uIOCtl, PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, PSUPDRVIDCREQHDR pReqHdr); 639 641 int VBOXCALL supdrvInitDevExt(PSUPDRVDEVEXT pDevExt); 640 642 void VBOXCALL supdrvDeleteDevExt(PSUPDRVDEVEXT pDevExt); -
trunk/src/VBox/HostDrivers/Support/darwin/SUPDrv-darwin.cpp
r10254 r10263 44 44 #include <IOKit/IOLib.h> /* Assert as function */ 45 45 46 #include " SUPDrvInternal.h"46 #include "../SUPDrvInternal.h" 47 47 #include <VBox/version.h> 48 48 #include <iprt/initterm.h> … … 611 611 612 612 613 /** 614 * The SUPDRV IDC entry point. 615 * 616 * @returns VBox status code, see supdrvIDC. 617 * @param iReq The request code. 618 * @param pReq The request. 619 */ 620 int VBOXCALL SUPDrvDarwinIDC(uint32_t uReq, PSUPDRVIDCREQHDR pReq) 621 { 622 PSUPDRVSESSION pSession; 623 624 /* 625 * Some quick validations. 626 */ 627 if (RT_UNLIKELY(!VALID_PTR(pReq))) 628 return VERR_INVALID_POINTER; 629 630 pSession = pReq->pSession; 631 if (pSession) 632 { 633 if (RT_UNLIKELY(!VALID_PTR(pSession))) 634 return VERR_INVALID_PARAMETER; 635 if (RT_UNLIKELY(pSession->pDevExt != &g_DevExt)) 636 return VERR_INVALID_PARAMETER; 637 } 638 else if (RT_UNLIKELY(uReq != SUPDRV_IDC_REQ_CONNECT)) 639 return VERR_INVALID_PARAMETER; 640 641 /* 642 * Do the job. 643 */ 644 return supdrvIDC(uReq, &g_DevExt, pSession, pReq); 645 } 646 613 647 614 648 /** -
trunk/src/VBox/HostDrivers/Support/freebsd/SUPDrv-freebsd.c
r10254 r10263 45 45 #include <sys/uio.h> 46 46 47 #include " SUPDrvInternal.h"47 #include "../SUPDrvInternal.h" 48 48 #include <VBox/version.h> 49 49 #include <iprt/initterm.h> … … 514 514 515 515 516 /** 517 * The SUPDRV IDC entry point. 518 * 519 * @returns VBox status code, see supdrvIDC. 520 * @param iReq The request code. 521 * @param pReq The request. 522 */ 523 int VBOXCALL SUPDrvFreeBSDIDC(uint32_t uReq, PSUPDRVIDCREQHDR pReq) 524 { 525 PSUPDRVSESSION pSession; 526 527 /* 528 * Some quick validations. 529 */ 530 if (RT_UNLIKELY(!VALID_PTR(pReq))) 531 return VERR_INVALID_POINTER; 532 533 pSession = pReq->pSession; 534 if (pSession) 535 { 536 if (RT_UNLIKELY(!VALID_PTR(pReq->pSession))) 537 return VERR_INVALID_PARAMETER; 538 if (RT_UNLIKELY(pSession->pDevExt != &g_VBoxDrvFreeBSDModule)) 539 return VERR_INVALID_PARAMETER; 540 } 541 else if (RT_UNLIKELY(uReq != SUPDRV_IDC_REQ_CONNECT)) 542 return VERR_INVALID_PARAMETER; 543 544 /* 545 * Do the job. 546 */ 547 return supdrvIDC(uReq, &g_VBoxDrvFreeBSDModule, pSession, pReq); 548 } 549 516 550 517 551 void VBOXCALL supdrvOSObjInitCreator(PSUPDRVOBJ pObj, PSUPDRVSESSION pSession) -
trunk/src/VBox/HostDrivers/Support/linux/SUPDrv-linux.c
r10254 r10263 34 34 * Header Files * 35 35 *******************************************************************************/ 36 #include " SUPDrvInternal.h"36 #include "../SUPDrvInternal.h" 37 37 #include "the-linux-kernel.h" 38 38 #include "version-generated.h" … … 846 846 847 847 /** 848 * The SUPDRV IDC entry point. 849 * 850 * @returns VBox status code, see supdrvIDC. 851 * @param iReq The request code. 852 * @param pReq The request. 853 */ 854 int VBOXCALL SUPDrvLinuxIDC(uint32_t uReq, PSUPDRVIDCREQHDR pReq) 855 { 856 PSUPDRVSESSION pSession; 857 858 /* 859 * Some quick validations. 860 */ 861 if (RT_UNLIKELY(!VALID_PTR(pReq))) 862 return VERR_INVALID_POINTER; 863 864 pSession = pReq->pSession; 865 if (pSession) 866 { 867 if (RT_UNLIKELY(!VALID_PTR(pSession))) 868 return VERR_INVALID_PARAMETER; 869 if (RT_UNLIKELY(pSession->pDevExt != &g_DevExt)) 870 return VERR_INVALID_PARAMETER; 871 } 872 else if (RT_UNLIKELY(uReq != SUPDRV_IDC_REQ_CONNECT)) 873 return VERR_INVALID_PARAMETER; 874 875 /* 876 * Do the job. 877 */ 878 return supdrvIDC(uReq, &g_DevExt, pSession, pReq); 879 } 880 881 EXPORT_SYMBOL(SUPDrvLinuxIDC); 882 883 884 /** 848 885 * Initializes any OS specific object creator fields. 849 886 */ -
trunk/src/VBox/HostDrivers/Support/solaris/SUPDrv-solaris.c
r10254 r10263 48 48 #undef u /* /usr/include/sys/user.h:249:1 is where this is defined to (curproc->p_user). very cool. */ 49 49 50 #include " SUPDrvInternal.h"50 #include "../SUPDrvInternal.h" 51 51 #include <iprt/semaphore.h> 52 52 #include <iprt/spinlock.h> … … 754 754 755 755 /** 756 * The SUPDRV IDC entry point. 757 * 758 * @returns VBox status code, see supdrvIDC. 759 * @param iReq The request code. 760 * @param pReq The request. 761 */ 762 int VBOXCALL SUPDrvSolarisIDC(uint32_t uReq, PSUPDRVIDCREQHDR pReq) 763 { 764 PSUPDRVSESSION pSession; 765 766 /* 767 * Some quick validations. 768 */ 769 if (RT_UNLIKELY(!VALID_PTR(pReq))) 770 return VERR_INVALID_POINTER; 771 772 pSession = pReq->pSession; 773 if (pSession) 774 { 775 if (RT_UNLIKELY(!VALID_PTR(pSession))) 776 return VERR_INVALID_PARAMETER; 777 if (RT_UNLIKELY(pSession->pDevExt != &g_DevExt)) 778 return VERR_INVALID_PARAMETER; 779 } 780 else if (RT_UNLIKELY(uReq != SUPDRV_IDC_REQ_CONNECT)) 781 return VERR_INVALID_PARAMETER; 782 783 /* 784 * Do the job. 785 */ 786 return supdrvIDC(uReq, &g_DevExt, pSession, pReq); 787 } 788 789 790 /** 756 791 * Converts an supdrv error code to a solaris error code. 757 792 * -
trunk/src/VBox/HostDrivers/Support/win/SUPDrv-win.cpp
r10254 r10263 34 34 * Header Files * 35 35 *******************************************************************************/ 36 #include " SUPDrvInternal.h"36 #include "../SUPDrvInternal.h" 37 37 #include <excpt.h> 38 38 #include <iprt/assert.h> … … 77 77 static NTSTATUS _stdcall VBoxDrvNtDeviceControl(PDEVICE_OBJECT pDevObj, PIRP pIrp); 78 78 static int VBoxDrvNtDeviceControlSlow(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, PIRP pIrp, PIO_STACK_LOCATION pStack); 79 static NTSTATUS _stdcall VBoxDrvNtInternalDeviceControl(PDEVICE_OBJECT pDevObj, PIRP pIrp); 79 80 static NTSTATUS _stdcall VBoxDrvNtNotSupportedStub(PDEVICE_OBJECT pDevObj, PIRP pIrp); 80 81 static NTSTATUS VBoxDrvNtErr2NtStatus(int rc); … … 132 133 * Setup the driver entry points in pDrvObj. 133 134 */ 134 pDrvObj->DriverUnload = VBoxDrvNtUnload; 135 pDrvObj->MajorFunction[IRP_MJ_CREATE] = VBoxDrvNtCreate; 136 pDrvObj->MajorFunction[IRP_MJ_CLOSE] = VBoxDrvNtClose; 137 pDrvObj->MajorFunction[IRP_MJ_DEVICE_CONTROL] = VBoxDrvNtDeviceControl; 138 pDrvObj->MajorFunction[IRP_MJ_READ] = VBoxDrvNtNotSupportedStub; 139 pDrvObj->MajorFunction[IRP_MJ_WRITE] = VBoxDrvNtNotSupportedStub; 135 pDrvObj->DriverUnload = VBoxDrvNtUnload; 136 pDrvObj->MajorFunction[IRP_MJ_CREATE] = VBoxDrvNtCreate; 137 pDrvObj->MajorFunction[IRP_MJ_CLOSE] = VBoxDrvNtClose; 138 pDrvObj->MajorFunction[IRP_MJ_DEVICE_CONTROL] = VBoxDrvNtDeviceControl; 139 #if 0 /** @todo test IDC on windows. */ 140 pDrvObj->MajorFunction[IRP_MJ_INTERNAL_DEVICE_CONTROL] = VBoxDrvNtInternalDeviceControl; 141 #endif 142 pDrvObj->MajorFunction[IRP_MJ_READ] = VBoxDrvNtNotSupportedStub; 143 pDrvObj->MajorFunction[IRP_MJ_WRITE] = VBoxDrvNtNotSupportedStub; 140 144 /* more? */ 141 145 dprintf(("VBoxDrv::DriverEntry returning STATUS_SUCCESS\n")); … … 293 297 int rc; 294 298 295 299 /* Raise the IRQL to DISPATCH_LEVEl to prevent Windows from rescheduling us to another CPU/core. */ 296 300 Assert(KeGetCurrentIrql() <= DISPATCH_LEVEL); 297 301 KeRaiseIrql(DISPATCH_LEVEL, &oldIrql); … … 407 411 408 412 /** 413 * Internal Device I/O Control entry point, used for IDC. 414 * 415 * @param pDevObj Device object. 416 * @param pIrp Request packet. 417 */ 418 NTSTATUS _stdcall VBoxDrvNtInternalDeviceControl(PDEVICE_OBJECT pDevObj, PIRP pIrp) 419 { 420 PSUPDRVDEVEXT pDevExt = (PSUPDRVDEVEXT)pDevObj->DeviceExtension; 421 PIO_STACK_LOCATION pStack = IoGetCurrentIrpStackLocation(pIrp); 422 PFILE_OBJECT pFileObj = pStack ? pStack->FileObject : NULL; 423 PSUPDRVSESSION pSession = pFileObj ? (PSUPDRVSESSION)pFileObj->FsContext : NULL; 424 NTSTATUS rcNt; 425 unsigned cbOut = 0; 426 int rc = 0; 427 dprintf2(("VBoxDrvNtInternalDeviceControl(%p,%p): ioctl=%#x pBuf=%p cbIn=%#x cbOut=%#x pSession=%p\n", 428 pDevExt, pIrp, pStack->Parameters.DeviceIoControl.IoControlCode, 429 pIrp->AssociatedIrp.SystemBuffer, pStack->Parameters.DeviceIoControl.InputBufferLength, 430 pStack->Parameters.DeviceIoControl.OutputBufferLength, pSession)); 431 432 if (pSession) 433 { 434 /* Verify that it's a buffered CTL. */ 435 if ((pStack->Parameters.DeviceIoControl.IoControlCode & 0x3) == METHOD_BUFFERED) 436 { 437 /* Verify that the size in the request header is correct. */ 438 PSUPDRVIDCREQHDR pHdr = (PSUPDRVIDCREQHDR)pIrp->AssociatedIrp.SystemBuffer; 439 if ( pStack->Parameters.DeviceIoControl.InputBufferLength >= sizeof(*pHdr) 440 && pStack->Parameters.DeviceIoControl.InputBufferLength == pHdr->cb 441 && pStack->Parameters.DeviceIoControl.OutputBufferLength == pHdr->cb) 442 { 443 /* 444 * Do the job. 445 */ 446 rc = supdrvIDC(pStack->Parameters.DeviceIoControl.IoControlCode, pDevExt, pSession, pHdr); 447 if (!rc) 448 { 449 rcNt = STATUS_SUCCESS; 450 cbOut = pHdr->cb; 451 } 452 else 453 rcNt = STATUS_INVALID_PARAMETER; 454 dprintf2(("VBoxDrvNtInternalDeviceControl: returns %#x/rc=%#x\n", rcNt, rc)); 455 } 456 else 457 { 458 dprintf(("VBoxDrvNtInternalDeviceControl: Mismatching sizes (%#x) - Hdr=%#lx Irp=%#lx/%#lx!\n", 459 pStack->Parameters.DeviceIoControl.IoControlCode, 460 pStack->Parameters.DeviceIoControl.InputBufferLength >= sizeof(*pHdr) ? pHdr->cb : 0, 461 pStack->Parameters.DeviceIoControl.InputBufferLength, 462 pStack->Parameters.DeviceIoControl.OutputBufferLength)); 463 rcNt = STATUS_INVALID_PARAMETER; 464 } 465 } 466 else 467 { 468 dprintf(("VBoxDrvNtInternalDeviceControl: not buffered request (%#x) - not supported\n", 469 pStack->Parameters.DeviceIoControl.IoControlCode)); 470 rcNt = STATUS_NOT_SUPPORTED; 471 } 472 } 473 474 /* complete the request. */ 475 pIrp->IoStatus.Status = rcNt; 476 pIrp->IoStatus.Information = cbOut; 477 IoCompleteRequest(pIrp, IO_NO_INCREMENT); 478 return rcNt; 479 } 480 481 482 /** 409 483 * Stub function for functions we don't implemented. 410 484 * -
trunk/src/VBox/HostDrivers/Support/win/SUPR0IdcClient-win.c
r10261 r10263 49 49 * @param pDeviceObject The device object to call. 50 50 * @param pFileObject The file object for the connection. 51 * @param iReq The request.51 * @param uReq The request. 52 52 * @param pReq The request packet. 53 53 */ 54 static int supR0IdcNtCallInternal(PDEVICE_OBJECT pDeviceObject, PFILE_OBJECT pFileObject, uint32_t iReq, PSUPDRVIDCREQHDR pReq)54 static int supR0IdcNtCallInternal(PDEVICE_OBJECT pDeviceObject, PFILE_OBJECT pFileObject, uint32_t uReq, PSUPDRVIDCREQHDR pReq) 55 55 { 56 56 int rc; … … 64 64 */ 65 65 KeInitializeEvent(&Event, NotificationEvent, FALSE); 66 pIrp = IoBuildDeviceIoControlRequest( iReq, /* IoControlCode */66 pIrp = IoBuildDeviceIoControlRequest(uReq, /* IoControlCode */ 67 67 pDeviceObject, 68 68 pReq, /* InputBuffer */ … … 99 99 return rc; 100 100 } 101 101 102 102 103 int VBOXCALL supR0IdcNativeOpen(PSUPDRVIDCHANDLE pHandle, PSUPDRVIDCREQCONNECT pReq) … … 153 154 154 155 155 int VBOXCALL supR0IdcNativeCall(PSUPDRVIDCHANDLE pHandle, uint32_t iReq, PSUPDRVIDCREQHDR pReq)156 int VBOXCALL supR0IdcNativeCall(PSUPDRVIDCHANDLE pHandle, uint32_t uReq, PSUPDRVIDCREQHDR pReq) 156 157 { 157 return supR0IdcNtCallInternal(pHandle->s.pDeviceObject, pHandle->s.pFileObject, iReq, pReq);158 return supR0IdcNtCallInternal(pHandle->s.pDeviceObject, pHandle->s.pFileObject, uReq, pReq); 158 159 } 159 160
Note:
See TracChangeset
for help on using the changeset viewer.