- Timestamp:
- Jun 30, 2009 2:23:40 PM (16 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 7 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/VBoxGuest.h
r20374 r21069 62 62 #endif 63 63 64 #if defined(RT_OS_LINUX) 64 #if defined(RT_OS_LINUX) && !defined(VBOX_WITH_COMMON_VBOXGUEST_ON_LINUX) 65 65 /** The support device name. */ 66 66 # define VBOXGUEST_DEVICE_NAME "/dev/vboxadd" … … 73 73 /** The support device name of the user accessible device node. */ 74 74 # define VBOXGUEST_USER_DEVICE_NAME "\\Dev\\VBoxGst$" 75 76 #elif defined(RT_OS_SOLARIS)77 /** The support device name. */78 # define VBOXGUEST_DEVICE_NAME "/dev/vboxguest"79 /** The support device name of the user accessible device node. */80 # define VBOXGUEST_USER_DEVICE_NAME "/dev/vboxguest"81 75 82 76 #elif defined(RT_OS_WINDOWS) … … 94 88 # define VBOXGUEST_DEVICE_NAME_DOS L"\\DosDevices\\VBoxGuest" 95 89 96 #el if defined(RT_OS_FREEBSD)90 #else /* PORTME */ 97 91 /** The support device name. */ 98 92 # define VBOXGUEST_DEVICE_NAME "/dev/vboxguest" 99 93 /** The support device name of the user accessible device node. */ 100 # define VBOXGUEST_USER_DEVICE_NAME "/dev/vboxguest" 101 102 #else 103 /* PORTME */ 94 # ifdef defined(RT_OS_LINUX) 95 # define VBOXGUEST_USER_DEVICE_NAME "/dev/vboxuser" 96 # else 97 # define VBOXGUEST_USER_DEVICE_NAME "/dev/vboxguest" 98 # endif 99 104 100 #endif 105 101 -
trunk/src/VBox/Additions/common/VBoxGuest/Makefile.kmk
r16013 r21069 28 28 $(if $(defined VBOX_WITH_OS2_ADDITIONS),os2,) \ 29 29 $(if $(defined VBOX_WITH_ADDITION_DRIVERS),linux,) \ 30 solaris) # linux is not yet using this code, just for syntax checking changes.30 solaris) 31 31 # 32 32 # VBoxGuest - The Guest Additions Driver (mixed case). … … 43 43 VBoxGuest_INCS = . 44 44 VBoxGuest_INCS.freebsd = $(PATH_VBoxGuest) 45 VBoxGuest_INCS.linux = ../../../Runtime/r0drv/linux 45 46 ifneq ($(KBUILD_TARGET),os2) 46 47 ifn1of ($(KBUILD_TARGET), linux freebsd solaris) -
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-freebsd.c
r8250 r21069 131 131 static eventhandler_tag g_VBoxGuestFreeBSDEHTag; 132 132 133 /**134 * VBoxGuest Common ioctl wrapper from VBoxGuestLib.135 *136 * @returns VBox error code.137 * @param pvSession Opaque pointer to the session.138 * @param uCmd Requested function.139 * @param pvData IO data buffer.140 * @param cbData Size of the data buffer.141 * @param pcbDataReturned Where to store the amount of returned data.142 */143 DECLVBGL(int) VBoxGuestFreeBSDServiceCall(void *pvSession, unsigned uCmd, void *pvData, size_t cbData, size_t *pcbDataReturned)144 {145 LogFlow((DEVICE_NAME ":VBoxGuestFreeBSDServiceCall %pvSesssion=%p uCmd=%u pvData=%p cbData=%d\n", pvSession, uCmd, pvData, cbData));146 147 PVBOXGUESTSESSION pSession = (PVBOXGUESTSESSION)pvSession;148 AssertPtrReturn(pSession, VERR_INVALID_POINTER);149 AssertMsgReturn(pSession->pDevExt == &g_DevExt,150 ("SC: %p != %p\n", pSession->pDevExt, &g_DevExt), VERR_INVALID_HANDLE);151 152 return VBoxGuestCommonIOCtl(uCmd, &g_DevExt, pSession, pvData, cbData, pcbDataReturned);153 }154 155 156 /**157 * FreeBSD Guest service open.158 *159 * @returns Opaque pointer to session object.160 * @param pu32Version Where to store VMMDev version.161 */162 DECLVBGL(void *) VBoxGuestFreeBSDServiceOpen(uint32_t *pu32Version)163 {164 LogFlow((DEVICE_NAME ":VBoxGuestFreeBSDServiceOpen\n"));165 166 AssertPtrReturn(pu32Version, NULL);167 PVBOXGUESTSESSION pSession;168 int rc = VBoxGuestCreateKernelSession(&g_DevExt, &pSession);169 if (RT_SUCCESS(rc))170 {171 *pu32Version = VMMDEV_VERSION;172 return pSession;173 }174 LogRel((DEVICE_NAME ":VBoxGuestCreateKernelSession failed. rc=%d\n", rc));175 return NULL;176 }177 178 179 /**180 * FreeBSD Guest service close.181 *182 * @returns VBox error code.183 * @param pvState Opaque pointer to the session object.184 */185 DECLVBGL(int) VBoxGuestFreeBSDServiceClose(void *pvSession)186 {187 LogFlow((DEVICE_NAME ":VBoxGuestFreeBSDServiceClose\n"));188 189 PVBOXGUESTSESSION pSession = (PVBOXGUESTSESSION)pvSession;190 AssertPtrReturn(pSession, VERR_INVALID_POINTER);191 if (pSession)192 {193 VBoxGuestCloseSession(&g_DevExt, pSession);194 return VINF_SUCCESS;195 }196 LogRel((DEVICE_NAME ":Invalid pSession.\n"));197 return VERR_INVALID_HANDLE;198 }199 133 200 134 /** … … 629 563 MODULE_VERSION(vboxguest, 1); 630 564 565 #if 0/** @todo This shouldn't be needed. if it is, that means exceptions hasn't been disabled correctly. */ 631 566 int __gxx_personality_v0 = 0xdeadbeef; 632 567 #endif 568 569 570 /* Common code that depend on g_DevExt. */ 571 #include "VBoxGuestIDC-unix.c.h" 572 -
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-linux.c
r21065 r21069 1 1 /* $Rev$ */ 2 2 /** @file 3 * VBoxDrv - The VirtualBox Support Driver - Linux specifics. 3 * VBoxGuest - Linux specifics. 4 * 5 * Note. Unfortunately, the difference between this and SUPDrv-linux.c is 6 * a little bit too big to be helpful. 4 7 */ 5 8 6 9 /* 7 * Copyright (C) 2006-200 7Sun Microsystems, Inc.10 * Copyright (C) 2006-2009 Sun Microsystems, Inc. 8 11 * 9 12 * This file is part of VirtualBox Open Source Edition (OSE), as … … 35 38 *******************************************************************************/ 36 39 #define LOG_GROUP LOG_GROUP_SUP_DRV 37 #include " ../SUPDrvInternal.h"40 #include "VBoxGuestInternal.h" 38 41 #include "the-linux-kernel.h" 42 #include <linux/miscdevice.h> 39 43 #include "version-generated.h" 40 44 … … 48 52 #include <VBox/log.h> 49 53 #include <iprt/mp.h> 50 51 /** @todo figure out the exact version number */52 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 16)53 # include <iprt/power.h>54 # define VBOX_WITH_SUSPEND_NOTIFICATION55 #endif56 57 #include <linux/sched.h>58 #ifdef CONFIG_DEVFS_FS59 # include <linux/devfs_fs_kernel.h>60 #endif61 #ifdef CONFIG_VBOXDRV_AS_MISC62 # include <linux/miscdevice.h>63 #endif64 #ifdef CONFIG_X86_LOCAL_APIC65 # include <asm/apic.h>66 # include <asm/nmi.h>67 #endif68 #ifdef VBOX_WITH_SUSPEND_NOTIFICATION69 # include <linux/platform_device.h>70 #endif71 72 54 #include <iprt/mem.h> 73 55 74 75 /* devfs defines */76 #if defined(CONFIG_DEVFS_FS) && !defined(CONFIG_VBOXDRV_AS_MISC)77 # ifdef VBOX_WITH_HARDENING78 # define VBOX_DEV_FMASK (S_IWUSR | S_IRUSR)79 # else80 # define VBOX_DEV_FMASK (S_IRUGO | S_IWUGO)81 # endif82 #endif /* CONFIG_DEV_FS && !CONFIG_VBOXDEV_AS_MISC */83 84 #ifdef CONFIG_X86_HIGH_ENTRY85 # error "CONFIG_X86_HIGH_ENTRY is not supported by VBoxDrv at this time."86 #endif87 88 #ifdef CONFIG_X86_LOCAL_APIC89 90 /* If an NMI occurs while we are inside the world switcher the machine will91 * crash. The Linux NMI watchdog generates periodic NMIs increasing a counter92 * which is compared with another counter increased in the timer interrupt93 * handler. We disable the NMI watchdog.94 *95 * - Linux >= 2.6.21: The watchdog is disabled by default on i386 and x86_64.96 * - Linux < 2.6.21: The watchdog is normally enabled by default on x86_6497 * and disabled on i386.98 */99 # if defined(RT_ARCH_AMD64)100 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 21) && !defined(VBOX_REDHAT_KABI)101 # define DO_DISABLE_NMI 1102 # endif103 # endif104 105 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19)106 extern int nmi_active;107 # define nmi_atomic_read(P) *(P)108 # define nmi_atomic_set(P, V) *(P) = (V)109 # define nmi_atomic_dec(P) nmi_atomic_set(P, 0)110 # else111 # define nmi_atomic_read(P) atomic_read(P)112 # define nmi_atomic_set(P, V) atomic_set(P, V)113 # define nmi_atomic_dec(P) atomic_dec(P)114 # endif115 116 # ifndef X86_FEATURE_ARCH_PERFMON117 # define X86_FEATURE_ARCH_PERFMON (3*32+9) /* Intel Architectural PerfMon */118 # endif119 # ifndef MSR_ARCH_PERFMON_EVENTSEL0120 # define MSR_ARCH_PERFMON_EVENTSEL0 0x186121 # endif122 # ifndef ARCH_PERFMON_UNHALTED_CORE_CYCLES_PRESENT123 # define ARCH_PERFMON_UNHALTED_CORE_CYCLES_PRESENT (1 << 0)124 # endif125 126 #endif /* CONFIG_X86_LOCAL_APIC */127 56 128 57 #define xstr(s) str(s) 129 58 #define str(s) #s 59 60 /** The device name. */ 61 #define DEVICE_NAME "vboxguest" 62 /** The device name for the device node open to everyone.. */ 63 #define DEVICE_NAME_USER "vboxuser" 64 65 66 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20) 67 # define PCI_DEV_GET(v,d,p) pci_get_device(v,d,p) 68 # define PCI_DEV_PUT(x) pci_dev_put(x) 69 #else 70 # define PCI_DEV_GET(v,d,p) pci_find_device(v,d,p) 71 # define PCI_DEV_PUT(x) do {} while(0) 72 #endif 73 74 /* 2.4.x compatability macros that may or may not be defined. */ 75 #ifndef IRQ_RETVAL 76 # define irqreturn_t void 77 # define IRQ_RETVAL(n) 78 #endif 79 80 81 /******************************************************************************* 82 * Internal Functions * 83 *******************************************************************************/ 84 static int vboxguestLinuxModInit(void); 85 static void vboxguestLinuxModExit(void); 86 static int vboxguestLinuxOpen(struct inode *pInode, struct file *pFilp); 87 static int vboxguestLinuxRelease(struct inode *pInode, struct file *pFilp); 88 #ifdef HAVE_UNLOCKED_IOCTL 89 static long vboxguestLinuxIOCtl(struct file *pFilp, unsigned int uCmd, unsigned long ulArg); 90 #else 91 static int vboxguestLinuxIOCtl(struct inode *pInode, struct file *pFilp, unsigned int uCmd, unsigned long ulArg); 92 #endif 130 93 131 94 … … 136 99 * Device extention & session data association structure. 137 100 */ 138 static SUPDRVDEVEXT g_DevExt; 139 140 #ifndef CONFIG_VBOXDRV_AS_MISC 141 /** Module major number */ 142 #define DEVICE_MAJOR 234 143 /** Saved major device number */ 144 static int g_iModuleMajor; 145 #endif /* !CONFIG_VBOXDRV_AS_MISC */ 146 147 /** Module parameter. 148 * Not prefixed because the name is used by macros and the end of this file. */ 149 static int force_async_tsc = 0; 150 151 /** The module name. */ 152 #define DEVICE_NAME "vboxdrv" 153 154 #ifdef RT_ARCH_AMD64 155 /** 156 * Memory for the executable memory heap (in IPRT). 157 */ 158 extern uint8_t g_abExecMemory[1572864]; /* 1.5 MB */ 159 __asm__(".section execmemory, \"awx\", @progbits\n\t" 160 ".align 32\n\t" 161 ".globl g_abExecMemory\n" 162 "g_abExecMemory:\n\t" 163 ".zero 1572864\n\t" 164 ".type g_abExecMemory, @object\n\t" 165 ".size g_abExecMemory, 1572864\n\t" 166 ".text\n\t"); 167 #endif 168 169 170 /******************************************************************************* 171 * Internal Functions * 172 *******************************************************************************/ 173 static int VBoxDrvLinuxInit(void); 174 static void VBoxDrvLinuxUnload(void); 175 static int VBoxDrvLinuxCreate(struct inode *pInode, struct file *pFilp); 176 static int VBoxDrvLinuxClose(struct inode *pInode, struct file *pFilp); 101 static VBOXGUESTDEVEXT g_DevExt; 102 /** The PCI device. */ 103 static struct pci_dev *g_pPciDev; 104 /** The base of the I/O port range. */ 105 static RTIOPORT g_IOPortBase; 106 /** The base of the MMIO range. */ 107 static RTHCPHYS g_MMIOPhysAddr = NIL_RTHCPHYS; 108 /** The size of the MMIO range as seen by PCI. */ 109 static uint32_t g_cbMMIO; 110 /** The pointer to the mapping of the MMIO range. */ 111 static void *g_pvMMIOBase; 112 113 /** Our file node major id. 114 * Either set dynamically at run time or statically at compile time. */ 115 #ifdef CONFIG_VBOXADD_MAJOR 116 static unsigned int g_iModuleMajor = CONFIG_VBOXADD_MAJOR; 117 #else 118 static unsigned int g_iModuleMajor = 0; 119 #endif 120 121 122 /** The file_operations structure. */ 123 static struct file_operations g_FileOps = 124 { 125 owner: THIS_MODULE, 126 open: vboxguestLinuxOpen, 127 release: vboxguestLinuxRelease, 177 128 #ifdef HAVE_UNLOCKED_IOCTL 178 static long VBoxDrvLinuxIOCtl(struct file *pFilp, unsigned int uCmd, unsigned long ulArg); 179 #else 180 static int VBoxDrvLinuxIOCtl(struct inode *pInode, struct file *pFilp, unsigned int uCmd, unsigned long ulArg); 181 #endif 182 static int VBoxDrvLinuxIOCtlSlow(struct file *pFilp, unsigned int uCmd, unsigned long ulArg); 183 static int VBoxDrvLinuxErr2LinuxErr(int); 184 #ifdef VBOX_WITH_SUSPEND_NOTIFICATION 185 static int VBoxDrvProbe(struct platform_device *pDev); 186 static int VBoxDrvSuspend(struct platform_device *pDev, pm_message_t State); 187 static int VBoxDrvResume(struct platform_device *pDev); 188 static void VBoxDevRelease(struct device *pDev); 189 #endif 190 191 /** The file_operations structure. */ 192 static struct file_operations gFileOpsVBoxDrv = 193 { 194 owner: THIS_MODULE, 195 open: VBoxDrvLinuxCreate, 196 release: VBoxDrvLinuxClose, 129 unlocked_ioctl: vboxguestLinuxIOCtl, 130 #else 131 ioctl: vboxguestLinuxIOCtl, 132 #endif 133 }; 134 135 /** The miscdevice structure. */ 136 static struct miscdevice g_MiscDevice = 137 { 138 minor: MISC_DYNAMIC_MINOR, 139 name: DEVICE_NAME, 140 fops: &g_FileOps, 141 #if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 17) 142 devfs_name: DEVICE_NAME, 143 #endif 144 }; 145 146 /** The file_operations structure for the user device. 147 * @remarks For the time being we'll be using the same implementation as 148 * /dev/vboxguest here. */ 149 static struct file_operations g_FileOpsUser = 150 { 151 owner: THIS_MODULE, 152 open: vboxguestLinuxOpen, 153 release: vboxguestLinuxRelease, 197 154 #ifdef HAVE_UNLOCKED_IOCTL 198 unlocked_ioctl: VBoxDrvLinuxIOCtl,199 #else 200 ioctl: VBoxDrvLinuxIOCtl,155 unlocked_ioctl: vboxguestLinuxIOCtl, 156 #else 157 ioctl: vboxguestLinuxIOCtl, 201 158 #endif 202 159 }; 203 160 204 #ifdef CONFIG_VBOXDRV_AS_MISC 205 /** The miscdevice structure. */ 206 static struct miscdevice gMiscDevice = 207 { 208 minor: MISC_DYNAMIC_MINOR, 209 name: DEVICE_NAME, 210 fops: &gFileOpsVBoxDrv, 211 # if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 17) 212 devfs_name: DEVICE_NAME, 213 # endif 161 /** The miscdevice structure for the user device. */ 162 static struct miscdevice g_MiscDeviceUser = 163 { 164 minor: MISC_DYNAMIC_MINOR, 165 name: DEVICE_NAME_USER, 166 fops: &g_FileOpsUser, 167 #if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 17) 168 devfs_name: DEVICE_NAME_USER, 169 #endif 214 170 }; 215 #endif 216 217 218 #ifdef VBOX_WITH_SUSPEND_NOTIFICATION 219 static struct platform_driver gPlatformDriver = 220 { 221 .probe = VBoxDrvProbe, 222 .suspend = VBoxDrvSuspend, 223 .resume = VBoxDrvResume, 224 /** @todo .shutdown? */ 225 .driver = 226 { 227 .name = "vboxdrv" 171 172 173 /** PCI hotplug structure. */ 174 static const struct pci_device_id __devinitdata g_VBoxGuestPciId[] = 175 { 176 { 177 vendor: VMMDEV_VENDORID, 178 device: VMMDEV_DEVICEID 179 }, 180 { 181 /* empty entry */ 228 182 } 229 183 }; 230 231 static struct platform_device gPlatformDevice = 232 { 233 .name = "vboxdrv", 234 .dev = 235 { 236 .release = VBoxDevRelease 237 } 238 }; 239 #endif /* VBOX_WITH_SUSPEND_NOTIFICATION */ 240 241 242 #ifdef CONFIG_X86_LOCAL_APIC 243 # ifdef DO_DISABLE_NMI 244 /** Stop AMD NMI watchdog (x86_64 only). */ 245 static int vboxdrvStopK7Watchdog(void) 246 { 247 wrmsr(MSR_K7_EVNTSEL0, 0, 0); 248 return 1; 249 } 250 251 /** Stop Intel P4 NMI watchdog (x86_64 only). */ 252 static int vboxdrvStopP4Watchdog(void) 253 { 254 wrmsr(MSR_P4_IQ_CCCR0, 0, 0); 255 wrmsr(MSR_P4_IQ_CCCR1, 0, 0); 256 wrmsr(MSR_P4_CRU_ESCR0, 0, 0); 257 return 1; 258 } 259 260 /** The new method of detecting the event counter */ 261 static int vboxdrvStopIntelArchWatchdog(void) 262 { 263 unsigned ebx; 264 265 ebx = cpuid_ebx(10); 266 if (!(ebx & ARCH_PERFMON_UNHALTED_CORE_CYCLES_PRESENT)) 267 wrmsr(MSR_ARCH_PERFMON_EVENTSEL0, 0, 0); 268 return 1; 269 } 270 271 /** Stop NMI watchdog. */ 272 static void vboxdrvStopApicNmiWatchdog(void *unused) 273 { 274 int stopped = 0; 275 276 /* only support LOCAL and IO APICs for now */ 277 if ((nmi_watchdog != NMI_LOCAL_APIC) && 278 (nmi_watchdog != NMI_IO_APIC)) 279 return; 280 281 if (nmi_watchdog == NMI_LOCAL_APIC) 282 { 283 switch (boot_cpu_data.x86_vendor) 184 MODULE_DEVICE_TABLE(pci, g_VBoxGuestPciId); 185 186 187 /** 188 * Converts a VBox status code to a linux error code. 189 * 190 * @returns corresponding negative linux error code. 191 * @param rc supdrv error code (SUPDRV_ERR_* defines). 192 */ 193 static int vboxguestLinuxConvertToNegErrno(int rc) 194 { 195 if ( rc > -1000 196 && rc < 1000) 197 return -RTErrConvertToErrno(rc); 198 switch (rc) 199 { 200 case VERR_HGCM_SERVICE_NOT_FOUND: return -ESRCH; 201 case VINF_HGCM_CLIENT_REJECTED: return 0; 202 case VERR_HGCM_INVALID_CMD_ADDRESS: return -EFAULT; 203 case VINF_HGCM_ASYNC_EXECUTE: return 0; 204 case VERR_HGCM_INTERNAL: return -EPROTO; 205 case VERR_HGCM_INVALID_CLIENT_ID: return -EINVAL; 206 case VINF_HGCM_SAVE_STATE: return 0; 207 /* No reason to return this to a guest */ 208 // case VERR_HGCM_SERVICE_EXISTS: return -EEXIST; 209 default: 210 AssertMsgFailed(("Unhandled error code %Rrc\n", rc)); 211 return -EPROTO; 212 } 213 } 214 215 216 217 /** 218 * Does the PCI detection and init of the device. 219 * 220 * @returns 0 on success, negated errno on failure. 221 */ 222 static int __init vboxguestLinuxInitPci(void) 223 { 224 struct pci_dev *pPciDev; 225 int rc; 226 227 pPciDev = PCI_DEV_GET(VMMDEV_VENDORID, VMMDEV_DEVICEID, NULL); 228 if (pPciDev) 229 { 230 rc = pci_enable_device(pPciDev); 231 if (rc >= 0) 284 232 { 285 case X86_VENDOR_AMD: 286 if (strstr(boot_cpu_data.x86_model_id, "Screwdriver")) 287 return; 288 stopped = vboxdrvStopK7Watchdog(); 289 break; 290 case X86_VENDOR_INTEL: 291 if (cpu_has(&boot_cpu_data, X86_FEATURE_ARCH_PERFMON)) 233 /* I/O Ports are mandatory, the MMIO bit is not. */ 234 if (pci_resource_start(pPciDev, 0) != 0) 292 235 { 293 stopped = vboxdrvStopIntelArchWatchdog(); 294 break; 236 /* 237 * Map the register address space. 238 */ 239 g_MMIOPhysAddr = pci_resource_start(pPciDev, 1); 240 g_cbMMIO = pci_resource_len(pPciDev, 1); 241 g_IOPortBase = pci_resource_start(pPciDev, 0); 242 if (request_mem_region(g_MMIOPhysAddr, g_cbMMIO, DEVICE_NAME) != NULL) 243 { 244 g_pvMMIOBase = ioremap(g_MMIOPhysAddr, g_cbMMIO); 245 if (g_DevExt.pVMMDevMemory) 246 { 247 /** @todo why aren't we requesting ownership of the I/O ports as well? */ 248 g_pPciDev = pPciDev; 249 return 0; 250 } 251 252 /* failure cleanup path */ 253 LogRel((DEVICE_NAME ": ioremap failed\n")); 254 rc = -ENOMEM; 255 release_mem_region(g_MMIOPhysAddr, g_cbMMIO); 256 } 257 else 258 { 259 LogRel((DEVICE_NAME ": failed to obtain adapter memory\n")); 260 rc = -EBUSY; 261 } 262 g_MMIOPhysAddr = NIL_RTHCPHYS; 263 g_cbMMIO = 0; 264 g_IOPortBase = 0; 295 265 } 296 stopped = vboxdrvStopP4Watchdog(); 297 break; 298 default: 299 return; 300 } 301 } 302 303 if (stopped) 304 nmi_atomic_dec(&nmi_active); 305 } 306 307 /** Disable LAPIC NMI watchdog. */ 308 static void DisableLapicNmiWatchdog(void) 309 { 310 BUG_ON(nmi_watchdog != NMI_LOCAL_APIC); 311 312 if (nmi_atomic_read(&nmi_active) <= 0) 313 return; 314 315 on_each_cpu(vboxdrvStopApicNmiWatchdog, NULL, 1, 1); 316 317 BUG_ON(nmi_atomic_read(&nmi_active) != 0); 318 319 /* tell do_nmi() and others that we're not active any more */ 320 nmi_watchdog = NMI_NONE; 321 } 322 323 /** Shutdown NMI. */ 324 static void vboxdrvNmiCpuShutdown(void * dummy) 325 { 326 unsigned int vERR, vPC; 327 328 vPC = apic_read(APIC_LVTPC); 329 330 if ((GET_APIC_DELIVERY_MODE(vPC) == APIC_MODE_NMI) && !(vPC & APIC_LVT_MASKED)) 331 { 332 vERR = apic_read(APIC_LVTERR); 333 apic_write(APIC_LVTERR, vERR | APIC_LVT_MASKED); 334 apic_write(APIC_LVTPC, vPC | APIC_LVT_MASKED); 335 apic_write(APIC_LVTERR, vERR); 336 } 337 } 338 339 static void vboxdrvNmiShutdown(void) 340 { 341 on_each_cpu(vboxdrvNmiCpuShutdown, NULL, 0, 1); 342 } 343 # endif /* DO_DISABLE_NMI */ 344 #endif /* CONFIG_X86_LOCAL_APIC */ 345 346 347 DECLINLINE(RTUID) vboxdrvLinuxUid(void) 348 { 349 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) 350 return current->cred->uid; 351 #else 352 return current->uid; 353 #endif 354 } 355 356 DECLINLINE(RTGID) vboxdrvLinuxGid(void) 357 { 358 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) 359 return current->cred->gid; 360 #else 361 return current->gid; 362 #endif 363 } 364 365 DECLINLINE(RTUID) vboxdrvLinuxEuid(void) 366 { 367 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) 368 return current->cred->euid; 369 #else 370 return current->euid; 371 #endif 372 } 373 374 /** 375 * Initialize module. 376 * 377 * @returns appropriate status code. 378 */ 379 static int __init VBoxDrvLinuxInit(void) 380 { 381 int rc; 382 383 dprintf(("VBoxDrv::ModuleInit\n")); 384 385 #ifdef CONFIG_X86_LOCAL_APIC 386 /* 387 * If an NMI occurs while we are inside the world switcher the macine will crash. 388 * The Linux NMI watchdog generates periodic NMIs increasing a counter which is 389 * compared with another counter increased in the timer interrupt handler. Therefore 390 * we don't allow to setup an NMI watchdog. 391 */ 392 # if !defined(VBOX_REDHAT_KABI) 393 /* 394 * First test: NMI actiated? Works only works with Linux 2.6 -- 2.4 does not export 395 * the nmi_watchdog variable. 396 */ 397 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19) || defined CONFIG_X86_64 398 # ifdef DO_DISABLE_NMI 399 if (nmi_atomic_read(&nmi_active) > 0) 400 { 401 printk(KERN_DEBUG DEVICE_NAME ": Trying to deactivate the NMI watchdog...\n"); 402 403 switch (nmi_watchdog) 404 { 405 case NMI_LOCAL_APIC: 406 DisableLapicNmiWatchdog(); 407 break; 408 case NMI_NONE: 409 nmi_atomic_dec(&nmi_active); 410 break; 411 } 412 413 if (nmi_atomic_read(&nmi_active) == 0) 414 { 415 vboxdrvNmiShutdown(); 416 printk(KERN_DEBUG DEVICE_NAME ": Successfully done.\n"); 266 else 267 { 268 LogRel((DEVICE_NAME ": did not find expected hardware resources\n")); 269 rc = -ENXIO; 270 } 271 pci_disable_device(pPciDev); 417 272 } 418 273 else 419 printk(KERN_DEBUG DEVICE_NAME ": Failed!\n"); 420 } 421 # endif /* DO_DISABLE_NMI */ 274 LogRel((DEVICE_NAME ": could not enable device: %d\n", rc)); 275 PCI_DEV_PUT(pPciDev); 276 } 277 else 278 { 279 printk(KERN_ERR DEVICE_NAME ": VirtualBox Guest PCI device not found.\n"); 280 rc = -ENODEV; 281 } 282 return rc; 283 } 284 285 286 /** 287 * Clean up the usage of the PCI device. 288 */ 289 static void __exit vboxguestLinuxTermPci(void) 290 { 291 struct pci_dev *pPciDev = g_pPciDev; 292 g_pPciDev = NULL; 293 if (pPciDev) 294 { 295 iounmap(g_pvMMIOBase); 296 g_pvMMIOBase = NULL; 297 298 release_mem_region(g_MMIOPhysAddr, g_cbMMIO); 299 g_MMIOPhysAddr = NIL_RTHCPHYS; 300 g_cbMMIO = 0; 301 302 pci_disable_device(pPciDev); 303 } 304 } 305 306 307 /** 308 * Interrupt service routine. 309 * 310 * @returns In 2.4 it returns void. 311 * In 2.6 we indicate whether we've handled the IRQ or not. 312 * 313 * @param iIrq The IRQ number. 314 * @param pvDevId The device ID, a pointer to g_DevExt. 315 * @param pvRegs Register set. Removed in 2.6.19. 316 */ 317 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19) 318 static irqreturn_t vboxguestLinuxISR(int iIrrq, void *pvDevId) 319 #else 320 static irqreturn_t vboxguestLinuxISR(int iIrrq, void *pvDevId, struct pt_regs *pRegs) 321 #endif 322 { 323 bool fTaken = VBoxGuestCommonISR(&g_DevExt); 324 /** @todo if (vboxDev->irqAckRequest->events & 325 * VMMDEV_EVENT_MOUSE_POSITION_CHANGED) 326 * kill_fasync(&vboxDev->async_queue, SIGIO, POLL_IN); 327 */ 328 return IRQ_RETVAL(fTaken); 329 } 330 331 332 /** 333 * Registers the ISR. 334 */ 335 static int __init vboxguestLinuxInitISR(void) 336 { 337 int rc; 338 339 rc = request_irq(g_pPciDev->irq, 340 vboxguestLinuxISR, 341 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20) 342 IRQF_SHARED, 343 #else 344 SA_SHIRQ, 345 #endif 346 DEVICE_NAME, 347 &g_DevExt); 348 if (rc) 349 { 350 LogRel((DEVICE_NAME ": could not request IRQ %d: err=%d\n", g_pPciDev->irq, rc)); 351 return rc; 352 } 353 return 0; 354 } 355 356 357 /** 358 * Deregisters the ISR. 359 */ 360 static void __exit vboxguestLinuxTermISR(void) 361 { 362 free_irq(g_pPciDev->irq, &g_DevExt); 363 } 364 365 366 /** 367 * Creates the device nodes. 368 * 369 * @returns 0 on success, negated errno on failure. 370 */ 371 static int __init vboxguestLinuxInitDeviceNodes(void) 372 { 373 int rc; 422 374 423 375 /* 424 * Permanent IO_APIC mode active? No way to handle this! 425 */ 426 if (nmi_watchdog == NMI_IO_APIC) 427 { 428 printk(KERN_ERR DEVICE_NAME 429 ": NMI watchdog in IO_APIC mode active -- refused to load the kernel module!\n" 430 DEVICE_NAME 431 ": Please disable the NMI watchdog by specifying 'nmi_watchdog=0' at kernel\n" 432 DEVICE_NAME 433 ": command line.\n"); 376 * The full feature device node. 377 */ 378 if (g_iModuleMajor > 0) 379 { 380 rc = register_chrdev(g_iModuleMajor, DEVICE_NAME, &g_FileOps); 381 if (rc < 0) 382 { 383 LogRel((DEVICE_NAME ": register_chrdev failed: g_iModuleMajor: %d, rc: %d\n", g_iModuleMajor, rc)); 384 return rc; 385 } 386 } 387 else 388 { 389 rc = misc_register(&g_MiscDevice); 390 if (rc) 391 { 392 LogRel((DEVICE_NAME ": misc_register failed for %s (rc=%d)\n", DEVICE_NAME, rc)); 393 return rc; 394 } 395 } 396 397 /* 398 * The device node intended to be accessible by all users. 399 */ 400 rc = misc_register(&g_MiscDeviceUser); 401 if (rc) 402 { 403 LogRel((DEVICE_NAME ": misc_register failed for %s (rc=%d)\n", DEVICE_NAME_USER, rc)); 404 if (g_iModuleMajor > 0) 405 unregister_chrdev(g_iModuleMajor, DEVICE_NAME); 406 else 407 misc_deregister(&g_MiscDevice); 408 return rc; 409 } 410 411 return 0; 412 } 413 414 415 /** 416 * Deregisters the device nodes. 417 */ 418 static void __exit vboxguestLinuxTermDeviceNodes(void) 419 { 420 if (g_iModuleMajor > 0) 421 unregister_chrdev(g_iModuleMajor, DEVICE_NAME); 422 else 423 misc_deregister(&g_MiscDevice); 424 misc_deregister(&g_MiscDeviceUser); 425 } 426 427 428 429 /** 430 * Initialize module. 431 * 432 * @returns appropriate status code. 433 */ 434 static int __init vboxguestLinuxModInit(void) 435 { 436 int rc; 437 438 /* 439 * Initialize IPRT first. 440 */ 441 rc = RTR0Init(0); 442 if (RT_FAILURE(rc)) 443 { 444 Log((DEVICE_NAME ": RTR0Init failed.\n")); 434 445 return -EINVAL; 435 446 } 436 447 437 448 /* 438 * See arch/i386/kernel/nmi.c on >= 2.6.19: -1 means it can never enabled again 439 */ 440 nmi_atomic_set(&nmi_active, -1); 441 printk(KERN_DEBUG DEVICE_NAME ": Trying to deactivate the NMI watchdog permanently...\n"); 442 443 /* 444 * Now fall through and see if it actually was enabled before. If so, fail 445 * as we cannot deactivate it cleanly from here. 446 */ 447 # else /* < 2.6.19 */ 448 /* 449 * Older 2.6 kernels: nmi_watchdog is not initalized by default 450 */ 451 if (nmi_watchdog != NMI_NONE) 452 goto nmi_activated; 453 # endif 454 # endif /* >= 2.6.0 && !defined(VBOX_REDHAT_KABI) */ 455 456 /* 457 * Second test: Interrupt generated by performance counter not masked and can 458 * generate an NMI. Works also with Linux 2.4. 459 */ 460 { 461 unsigned int v, ver, maxlvt; 462 463 v = apic_read(APIC_LVR); 464 ver = GET_APIC_VERSION(v); 465 /* 82489DXs do not report # of LVT entries. */ 466 maxlvt = APIC_INTEGRATED(ver) ? GET_APIC_MAXLVT(v) : 2; 467 if (maxlvt >= 4) 449 * Locate and initialize the PCI device. 450 */ 451 rc = vboxguestLinuxInitPci(); 452 if (rc >= 0) 453 { 454 /* 455 * Register the interrupt service routine for it. 456 */ 457 rc = vboxguestLinuxInitISR(); 458 if (rc >= 0) 468 459 { 469 /* Read status of performance counter IRQ vector */470 v = apic_read(APIC_LVTPC);471 472 /* performance counter generates NMI and is not masked? */473 if ((GET_APIC_DELIVERY_MODE(v) == APIC_MODE_NMI) && !(v & APIC_LVT_MASKED))474 {475 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19) || defined CONFIG_X86_64476 printk(KERN_ERR DEVICE_NAME477 ": NMI watchdog either active or at least initialized. Please disable the NMI\n"478 DEVICE_NAME479 ": watchdog by specifying 'nmi_watchdog=0' at kernel command line.\n");480 return -EINVAL;481 # else /* < 2.6.19 */482 # if !defined(VBOX_REDHAT_KABI)483 nmi_activated:484 # endif485 printk(KERN_ERR DEVICE_NAME486 ": NMI watchdog active -- refused to load the kernel module! Please disable\n"487 DEVICE_NAME488 ": the NMI watchdog by specifying 'nmi_watchdog=0' at kernel command line.\n");489 return -EINVAL;490 # endif /* >= 2.6.19 */491 }492 }493 }494 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19)495 printk(KERN_DEBUG DEVICE_NAME ": Successfully done.\n");496 # endif /* >= 2.6.19 */497 #endif /* CONFIG_X86_LOCAL_APIC */498 499 /*500 * Check for synchronous/asynchronous TSC mode.501 */502 printk(KERN_DEBUG DEVICE_NAME ": Found %u processor cores.\n", (unsigned)RTMpGetOnlineCount());503 #ifdef CONFIG_VBOXDRV_AS_MISC504 rc = misc_register(&gMiscDevice);505 if (rc)506 {507 printk(KERN_ERR DEVICE_NAME ": Can't register misc device! rc=%d\n", rc);508 return rc;509 }510 #else /* !CONFIG_VBOXDRV_AS_MISC */511 /*512 * Register character device.513 */514 g_iModuleMajor = DEVICE_MAJOR;515 rc = register_chrdev((dev_t)g_iModuleMajor, DEVICE_NAME, &gFileOpsVBoxDrv);516 if (rc < 0)517 {518 dprintf(("register_chrdev() failed with rc=%#x!\n", rc));519 return rc;520 }521 522 /*523 * Save returned module major number524 */525 if (DEVICE_MAJOR != 0)526 g_iModuleMajor = DEVICE_MAJOR;527 else528 g_iModuleMajor = rc;529 rc = 0;530 531 # ifdef CONFIG_DEVFS_FS532 /*533 * Register a device entry534 */535 if (devfs_mk_cdev(MKDEV(DEVICE_MAJOR, 0), S_IFCHR | VBOX_DEV_FMASK, DEVICE_NAME) != 0)536 {537 dprintf(("devfs_register failed!\n"));538 rc = -EINVAL;539 }540 # endif541 #endif /* !CONFIG_VBOXDRV_AS_MISC */542 if (!rc)543 {544 /*545 * Initialize the runtime.546 * On AMD64 we'll have to donate the high rwx memory block to the exec allocator.547 */548 rc = RTR0Init(0);549 if (RT_SUCCESS(rc))550 {551 #ifdef RT_ARCH_AMD64552 rc = RTR0MemExecDonate(&g_abExecMemory[0], sizeof(g_abExecMemory));553 printk("VBoxDrv: dbg - g_abExecMemory=%p\n", (void *)&g_abExecMemory[0]);554 #endif555 460 /* 556 * Initialize the device extension.461 * Call the common device extension initializer. 557 462 */ 558 if (RT_SUCCESS(rc)) 559 rc = supdrvInitDevExt(&g_DevExt); 463 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0) && defined(RT_ARCH_X86) 464 VBOXOSTYPE enmOSType = VBOXOSTYPE_Linux26; 465 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0) && defined(RT_ARCH_AMD64) 466 VBOXOSTYPE enmOSType = VBOXOSTYPE_Linux26_x64; 467 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 0) && defined(RT_ARCH_X86) 468 VBOXOSTYPE enmOSType = VBOXOSTYPE_Linux24; 469 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 0) && defined(RT_ARCH_AMD64) 470 VBOXOSTYPE enmOSType = VBOXOSTYPE_Linux24_x64; 471 #else 472 # warning "huh? which arch + version is this?" 473 VBOXOSTYPE enmOsType = VBOXOSTYPE_Linux; 474 #endif 475 rc = VBoxGuestInitDevExt(&g_DevExt, 476 g_IOPortBase, 477 g_pvMMIOBase, 478 g_cbMMIO, 479 enmOSType); 560 480 if (RT_SUCCESS(rc)) 561 481 { 562 #ifdef VBOX_WITH_SUSPEND_NOTIFICATION 563 rc = platform_driver_register(&gPlatformDriver); 564 if (rc == 0) 482 /* 483 * Finally, create the device nodes. 484 */ 485 rc = vboxguestLinuxInitDeviceNodes(); 486 if (rc >= 0) 565 487 { 566 rc = platform_device_register(&gPlatformDevice); 567 if (rc == 0) 568 #endif 569 { 570 printk(KERN_INFO DEVICE_NAME ": TSC mode is %s, kernel timer mode is " 571 #ifdef VBOX_HRTIMER 572 "'high-res'" 573 #else 574 "'normal'" 575 #endif 576 ".\n", 577 g_DevExt.pGip->u32Mode == SUPGIPMODE_SYNC_TSC ? "'synchronous'" : "'asynchronous'"); 578 LogFlow(("VBoxDrv::ModuleInit returning %#x\n", rc)); 579 printk(KERN_DEBUG DEVICE_NAME ": Successfully loaded version " 580 VBOX_VERSION_STRING " (interface " xstr(SUPDRV_IOC_VERSION) ").\n"); 581 return rc; 582 } 583 #ifdef VBOX_WITH_SUSPEND_NOTIFICATION 584 else 585 platform_driver_unregister(&gPlatformDriver); 488 /* some useful information for the user but don't show this on the console */ 489 LogRel(("VirtualBox device settings: major %d, IRQ %d, I/O port 0x%x, MMIO at 0x%x (size 0x%x)\n", 490 g_iModuleMajor, g_pPciDev->irq, g_IOPortBase, g_MMIOPhysAddr, g_cbMMIO)); 491 printk(KERN_DEBUG DEVICE_NAME ": Successfully loaded version " 492 VBOX_VERSION_STRING " (interface " xstr(VMMDEV_VERSION) ")\n"); 493 return rc; 586 494 } 587 #endif 495 496 /* bail out */ 497 VBoxGuestDeleteDevExt(&g_DevExt); 588 498 } 589 590 rc = -EINVAL; 591 RTR0Term(); 499 else 500 { 501 LogRel(( DEVICE_NAME ": VBoxGuestInitDevExt failed with rc=%Rrc\n", rc)); 502 rc = RTErrConvertFromErrno(rc); 503 } 504 vboxguestLinuxTermISR(); 592 505 } 593 else 594 rc = -EINVAL; 595 596 /* 597 * Failed, cleanup and return the error code. 598 */ 599 #if defined(CONFIG_DEVFS_FS) && !defined(CONFIG_VBOXDRV_AS_MISC) 600 devfs_remove(DEVICE_NAME); 601 #endif 602 } 603 #ifdef CONFIG_VBOXDRV_AS_MISC 604 misc_deregister(&gMiscDevice); 605 dprintf(("VBoxDrv::ModuleInit returning %#x (minor:%d)\n", rc, gMiscDevice.minor)); 606 #else 607 unregister_chrdev(g_iModuleMajor, DEVICE_NAME); 608 dprintf(("VBoxDrv::ModuleInit returning %#x (major:%d)\n", rc, g_iModuleMajor)); 609 #endif 506 vboxguestLinuxTermPci(); 507 } 508 RTR0Term(); 610 509 return rc; 611 510 } … … 615 514 * Unload the module. 616 515 */ 617 static void __exit VBoxDrvLinuxUnload(void) 618 { 619 int rc; 620 dprintf(("VBoxDrvLinuxUnload\n")); 621 NOREF(rc); 622 623 #ifdef VBOX_WITH_SUSPEND_NOTIFICATION 624 platform_device_unregister(&gPlatformDevice); 625 platform_driver_unregister(&gPlatformDriver); 626 #endif 627 516 static void __exit vboxguestLinuxModExit(void) 517 { 628 518 /* 629 * I Don't think it's possible to unload a driver which processes have 630 * opened, at least we'll blindly assume that here. 631 */ 632 #ifdef CONFIG_VBOXDRV_AS_MISC 633 rc = misc_deregister(&gMiscDevice); 634 if (rc < 0) 635 { 636 dprintf(("misc_deregister failed with rc=%#x\n", rc)); 637 } 638 #else /* !CONFIG_VBOXDRV_AS_MISC */ 639 # ifdef CONFIG_DEVFS_FS 640 /* 641 * Unregister a device entry 642 */ 643 devfs_remove(DEVICE_NAME); 644 # endif /* devfs */ 645 unregister_chrdev(g_iModuleMajor, DEVICE_NAME); 646 #endif /* !CONFIG_VBOXDRV_AS_MISC */ 647 648 /* 649 * Destroy GIP, delete the device extension and terminate IPRT. 650 */ 651 supdrvDeleteDevExt(&g_DevExt); 519 * Inverse order of init. 520 */ 521 vboxguestLinuxTermDeviceNodes(); 522 VBoxGuestDeleteDevExt(&g_DevExt); 523 vboxguestLinuxTermISR(); 524 vboxguestLinuxTermPci(); 652 525 RTR0Term(); 653 526 } … … 660 533 * @param pFilp Associated file pointer. 661 534 */ 662 static int VBoxDrvLinuxCreate(struct inode *pInode, struct file *pFilp)535 static int vboxguestLinuxOpen(struct inode *pInode, struct file *pFilp) 663 536 { 664 537 int rc; 665 PSUPDRVSESSION pSession; 666 Log(("VBoxDrvLinuxCreate: pFilp=%p pid=%d/%d %s\n", pFilp, RTProcSelf(), current->pid, current->comm)); 667 668 #ifdef VBOX_WITH_HARDENING 538 PVBOXGUESTSESSION pSession; 539 Log((DEVICE_NAME ": pFilp=%p pid=%d/%d %s\n", pFilp, RTProcSelf(), current->pid, current->comm)); 540 669 541 /* 670 * Only root is allowed to access the device, enforce it! 671 */ 672 if (vboxdrvLinuxEuid() != 0 /* root */ ) 673 { 674 Log(("VBoxDrvLinuxCreate: euid=%d, expected 0 (root)\n", vboxdrvLinuxEuid())); 675 return -EPERM; 676 } 677 #endif /* VBOX_WITH_HARDENING */ 678 679 /* 680 * Call common code for the rest. 681 */ 682 rc = supdrvCreateSession(&g_DevExt, true /* fUser */, (PSUPDRVSESSION *)&pSession); 683 if (!rc) 684 { 685 pSession->Uid = vboxdrvLinuxUid(); 686 pSession->Gid = vboxdrvLinuxGid(); 687 } 688 689 pFilp->private_data = pSession; 690 691 Log(("VBoxDrvLinuxCreate: g_DevExt=%p pSession=%p rc=%d/%d (pid=%d/%d %s)\n", 692 &g_DevExt, pSession, rc, VBoxDrvLinuxErr2LinuxErr(rc), 542 * Call common code to create the user session. Associate it with 543 * the file so we can access it in the other methods. 544 */ 545 rc = VBoxGuestCreateUserSession(&g_DevExt, &pSession); 546 if (RT_SUCCESS(rc)) 547 pFilp->private_data = pSession; 548 549 Log(("vboxguestLinuxOpen: g_DevExt=%p pSession=%p rc=%d/%d (pid=%d/%d %s)\n", 550 &g_DevExt, pSession, rc, vboxguestLinuxConvertToNegErrno(rc), 693 551 RTProcSelf(), current->pid, current->comm)); 694 return VBoxDrvLinuxErr2LinuxErr(rc);552 return vboxguestLinuxConvertToNegErrno(rc); 695 553 } 696 554 … … 702 560 * @param pFilp Associated file pointer. 703 561 */ 704 static int VBoxDrvLinuxClose(struct inode *pInode, struct file *pFilp)705 { 706 Log((" VBoxDrvLinuxClose: pFilp=%p pSession=%p pid=%d/%d %s\n",562 static int vboxguestLinuxRelease(struct inode *pInode, struct file *pFilp) 563 { 564 Log(("vboxguestLinuxRelease: pFilp=%p pSession=%p pid=%d/%d %s\n", 707 565 pFilp, pFilp->private_data, RTProcSelf(), current->pid, current->comm)); 708 supdrvCloseSession(&g_DevExt, (PSUPDRVSESSION)pFilp->private_data); 566 567 VBoxGuestCloseSession(&g_DevExt, (PVBOXGUESTSESSION)pFilp->private_data); 709 568 pFilp->private_data = NULL; 710 569 return 0; 711 570 } 712 713 714 #ifdef VBOX_WITH_SUSPEND_NOTIFICATION715 /**716 * Dummy device release function. We have to provide this function,717 * otherwise the kernel will complain.718 *719 * @param pDev Pointer to the platform device.720 */721 static void VBoxDevRelease(struct device *pDev)722 {723 }724 725 /**726 * Dummy probe function.727 *728 * @param pDev Pointer to the platform device.729 */730 static int VBoxDrvProbe(struct platform_device *pDev)731 {732 return 0;733 }734 735 /**736 * Suspend callback.737 * @param pDev Pointer to the platform device.738 * @param State message type, see Documentation/power/devices.txt.739 */740 static int VBoxDrvSuspend(struct platform_device *pDev, pm_message_t State)741 {742 RTPowerSignalEvent(RTPOWEREVENT_SUSPEND);743 return 0;744 }745 746 /**747 * Resume callback.748 *749 * @param pDev Pointer to the platform device.750 */751 static int VBoxDrvResume(struct platform_device *pDev)752 {753 RTPowerSignalEvent(RTPOWEREVENT_RESUME);754 return 0;755 }756 #endif /* VBOX_WITH_SUSPEND_NOTIFICATION */757 571 758 572 … … 765 579 */ 766 580 #ifdef HAVE_UNLOCKED_IOCTL 767 static long VBoxDrvLinuxIOCtl(struct file *pFilp, unsigned int uCmd, unsigned long ulArg) 768 #else 769 static int VBoxDrvLinuxIOCtl(struct inode *pInode, struct file *pFilp, unsigned int uCmd, unsigned long ulArg) 770 #endif 771 { 772 /* 773 * Deal with the two high-speed IOCtl that takes it's arguments from 774 * the session and iCmd, and only returns a VBox status code. 775 */ 776 #ifdef HAVE_UNLOCKED_IOCTL 777 if (RT_LIKELY( uCmd == SUP_IOCTL_FAST_DO_RAW_RUN 778 || uCmd == SUP_IOCTL_FAST_DO_HWACC_RUN 779 || uCmd == SUP_IOCTL_FAST_DO_NOP)) 780 return supdrvIOCtlFast(uCmd, ulArg, &g_DevExt, (PSUPDRVSESSION)pFilp->private_data); 781 return VBoxDrvLinuxIOCtlSlow(pFilp, uCmd, ulArg); 782 783 #else /* !HAVE_UNLOCKED_IOCTL */ 784 785 int rc; 786 unlock_kernel(); 787 if (RT_LIKELY( uCmd == SUP_IOCTL_FAST_DO_RAW_RUN 788 || uCmd == SUP_IOCTL_FAST_DO_HWACC_RUN 789 || uCmd == SUP_IOCTL_FAST_DO_NOP)) 790 rc = supdrvIOCtlFast(uCmd, ulArg, &g_DevExt, (PSUPDRVSESSION)pFilp->private_data); 791 else 792 rc = VBoxDrvLinuxIOCtlSlow(pFilp, uCmd, ulArg); 793 lock_kernel(); 794 return rc; 795 #endif /* !HAVE_UNLOCKED_IOCTL */ 796 } 797 798 799 /** 800 * Device I/O Control entry point. 801 * 802 * @param pFilp Associated file pointer. 803 * @param uCmd The function specified to ioctl(). 804 * @param ulArg The argument specified to ioctl(). 805 */ 806 static int VBoxDrvLinuxIOCtlSlow(struct file *pFilp, unsigned int uCmd, unsigned long ulArg) 807 { 581 static long vboxguestLinuxIOCtl(struct file *pFilp, unsigned int uCmd, unsigned long ulArg) 582 #else 583 static int vboxguestLinuxIOCtl(struct inode *pInode, struct file *pFilp, unsigned int uCmd, unsigned long ulArg) 584 #endif 585 { 586 PVBOXGUESTSESSION pSession = (PVBOXGUESTSESSION)pFilp->private_data; 587 uint32_t cbData = _IOC_SIZE(uCmd); 588 void *pvBufFree; 589 void *pvBuf; 808 590 int rc; 809 SUPREQHDR Hdr; 810 PSUPREQHDR pHdr; 811 uint32_t cbBuf; 812 813 Log6(("VBoxDrvLinuxIOCtl: pFilp=%p uCmd=%#x ulArg=%p pid=%d/%d\n", pFilp, uCmd, (void *)ulArg, RTProcSelf(), current->pid)); 814 815 /* 816 * Read the header. 817 */ 818 if (RT_UNLIKELY(copy_from_user(&Hdr, (void *)ulArg, sizeof(Hdr)))) 819 { 820 Log(("VBoxDrvLinuxIOCtl: copy_from_user(,%#lx,) failed; uCmd=%#x.\n", ulArg, uCmd)); 821 return -EFAULT; 822 } 823 if (RT_UNLIKELY((Hdr.fFlags & SUPREQHDR_FLAGS_MAGIC_MASK) != SUPREQHDR_FLAGS_MAGIC)) 824 { 825 Log(("VBoxDrvLinuxIOCtl: bad header magic %#x; uCmd=%#x\n", Hdr.fFlags & SUPREQHDR_FLAGS_MAGIC_MASK, uCmd)); 826 return -EINVAL; 827 } 591 uint64_t au64Buf[32/sizeof(uint64_t)]; 592 593 Log6(("vboxguestLinuxIOCtl: pFilp=%p uCmd=%#x ulArg=%p pid=%d/%d\n", pFilp, uCmd, (void *)ulArg, RTProcSelf(), current->pid)); 828 594 829 595 /* 830 596 * Buffer the request. 831 597 */ 832 cbBuf = RT_MAX(Hdr.cbIn, Hdr.cbOut); 833 if (RT_UNLIKELY(cbBuf > _1M*16)) 834 { 835 Log(("VBoxDrvLinuxIOCtl: too big cbBuf=%#x; uCmd=%#x\n", cbBuf, uCmd)); 836 return -E2BIG; 837 } 838 if (RT_UNLIKELY(cbBuf != _IOC_SIZE(uCmd) && _IOC_SIZE(uCmd))) 839 { 840 Log(("VBoxDrvLinuxIOCtl: bad ioctl cbBuf=%#x _IOC_SIZE=%#x; uCmd=%#x.\n", cbBuf, _IOC_SIZE(uCmd), uCmd)); 841 return -EINVAL; 842 } 843 pHdr = RTMemAlloc(cbBuf); 844 if (RT_UNLIKELY(!pHdr)) 845 { 846 OSDBGPRINT(("VBoxDrvLinuxIOCtl: failed to allocate buffer of %d bytes for uCmd=%#x.\n", cbBuf, uCmd)); 847 return -ENOMEM; 848 } 849 if (RT_UNLIKELY(copy_from_user(pHdr, (void *)ulArg, Hdr.cbIn))) 850 { 851 Log(("VBoxDrvLinuxIOCtl: copy_from_user(,%#lx, %#x) failed; uCmd=%#x.\n", ulArg, Hdr.cbIn, uCmd)); 852 RTMemFree(pHdr); 853 return -EFAULT; 854 } 855 856 /* 857 * Process the IOCtl. 858 */ 859 rc = supdrvIOCtl(uCmd, &g_DevExt, (PSUPDRVSESSION)pFilp->private_data, pHdr); 860 861 /* 862 * Copy ioctl data and output buffer back to user space. 863 */ 864 if (RT_LIKELY(!rc)) 865 { 866 uint32_t cbOut = pHdr->cbOut; 867 if (RT_UNLIKELY(cbOut > cbBuf)) 598 if (cbData <= sizeof(au64Buf)) 599 { 600 pvBufFree = NULL; 601 pvBuf = &au64Buf[0]; 602 } 603 else 604 { 605 pvBufFree = pvBuf = RTMemTmpAlloc(cbData); 606 if (RT_UNLIKELY(!pvBuf)) 868 607 { 869 OSDBGPRINT(("VBoxDrvLinuxIOCtl: too much output! %#x > %#x; uCmd=%#x!\n", cbOut, cbBuf, uCmd));870 cbOut = cbBuf;608 LogRel((DEVICE_NAME "::IOCtl: RTMemTmpAlloc failed to alloc %u bytes.\n", cbData)); 609 return -ENOMEM; 871 610 } 872 if (RT_UNLIKELY(copy_to_user((void *)ulArg, pHdr, cbOut))) 611 } 612 if (RT_LIKELY(copy_from_user(pvBuf, (void *)ulArg, cbData))) 613 { 614 /* 615 * Process the IOCtl. 616 */ 617 size_t cbDataReturned; 618 rc = VBoxGuestCommonIOCtl(uCmd, &g_DevExt, pSession, pvBuf, cbData, &cbDataReturned); 619 620 /* 621 * Copy ioctl data and output buffer back to user space. 622 */ 623 if (RT_LIKELY(!rc)) 873 624 { 874 /* this is really bad! */ 875 OSDBGPRINT(("VBoxDrvLinuxIOCtl: copy_to_user(%#lx,,%#x); uCmd=%#x!\n", ulArg, cbOut, uCmd)); 876 rc = -EFAULT; 625 rc = 0; 626 if (RT_UNLIKELY(cbDataReturned > cbData)) 627 { 628 LogRel((DEVICE_NAME "::IOCtl: too much output data %u expected %u\n", cbDataReturned, cbData)); 629 cbDataReturned = cbData; 630 } 631 if (cbDataReturned > 0) 632 { 633 if (RT_UNLIKELY(copy_to_user((void *)ulArg, pvBuf, cbDataReturned))) 634 { 635 LogRel((DEVICE_NAME "::IOCtl: copy_to_user failed; pvBuf=%p ulArg=%p cbDataReturned=%u uCmd=%d\n", 636 pvBuf, (void *)ulArg, cbDataReturned, uCmd, rc)); 637 rc = -EFAULT; 638 } 639 } 877 640 } 641 else 642 { 643 Log(("vboxguestLinuxIOCtl: pFilp=%p uCmd=%#x ulArg=%p failed, rc=%d\n", pFilp, uCmd, (void *)ulArg, rc)); 644 rc = vboxguestLinuxConvertToNegErrno(rc); 645 } 878 646 } 879 647 else 880 648 { 881 Log(("VBoxDrvLinuxIOCtl: pFilp=%p uCmd=%#x ulArg=%p failed, rc=%d\n", pFilp, uCmd, (void *)ulArg, rc)); 882 rc = -EINVAL; 883 } 884 RTMemFree(pHdr); 885 886 Log6(("VBoxDrvLinuxIOCtl: returns %d (pid=%d/%d)\n", rc, RTProcSelf(), current->pid)); 649 Log((DEVICE_NAME "::IOCtl: copy_from_user(,%#lx, %#x) failed; uCmd=%#x.\n", ulArg, cbData, uCmd)); 650 rc = -EFAULT; 651 } 652 if (pvBufFree) 653 RTMemFree(pvBufFree); 654 655 Log6(("vboxguestLinuxIOCtl: returns %d (pid=%d/%d)\n", rc, RTProcSelf(), current->pid)); 887 656 return rc; 888 657 } 889 658 890 891 /** 892 * The SUPDRV IDC entry point. 893 * 894 * @returns VBox status code, see supdrvIDC. 895 * @param iReq The request code. 896 * @param pReq The request. 897 */ 898 int VBOXCALL SUPDrvLinuxIDC(uint32_t uReq, PSUPDRVIDCREQHDR pReq) 899 { 900 PSUPDRVSESSION pSession; 901 902 /* 903 * Some quick validations. 904 */ 905 if (RT_UNLIKELY(!VALID_PTR(pReq))) 906 return VERR_INVALID_POINTER; 907 908 pSession = pReq->pSession; 909 if (pSession) 910 { 911 if (RT_UNLIKELY(!VALID_PTR(pSession))) 912 return VERR_INVALID_PARAMETER; 913 if (RT_UNLIKELY(pSession->pDevExt != &g_DevExt)) 914 return VERR_INVALID_PARAMETER; 915 } 916 else if (RT_UNLIKELY(uReq != SUPDRV_IDC_REQ_CONNECT)) 917 return VERR_INVALID_PARAMETER; 918 919 /* 920 * Do the job. 921 */ 922 return supdrvIDC(uReq, &g_DevExt, pSession, pReq); 923 } 924 925 EXPORT_SYMBOL(SUPDrvLinuxIDC); 926 927 928 /** 929 * Initializes any OS specific object creator fields. 930 */ 931 void VBOXCALL supdrvOSObjInitCreator(PSUPDRVOBJ pObj, PSUPDRVSESSION pSession) 932 { 933 NOREF(pObj); 934 NOREF(pSession); 935 } 936 937 938 /** 939 * Checks if the session can access the object. 940 * 941 * @returns true if a decision has been made. 942 * @returns false if the default access policy should be applied. 943 * 944 * @param pObj The object in question. 945 * @param pSession The session wanting to access the object. 946 * @param pszObjName The object name, can be NULL. 947 * @param prc Where to store the result when returning true. 948 */ 949 bool VBOXCALL supdrvOSObjCanAccess(PSUPDRVOBJ pObj, PSUPDRVSESSION pSession, const char *pszObjName, int *prc) 950 { 951 NOREF(pObj); 952 NOREF(pSession); 953 NOREF(pszObjName); 954 NOREF(prc); 955 return false; 956 } 957 958 959 bool VBOXCALL supdrvOSGetForcedAsyncTscMode(PSUPDRVDEVEXT pDevExt) 960 { 961 return force_async_tsc != 0; 962 } 963 964 965 /** 966 * Converts a supdrv error code to an linux error code. 967 * 968 * @returns corresponding linux error code. 969 * @param rc supdrv error code (SUPDRV_ERR_* defines). 970 */ 971 static int VBoxDrvLinuxErr2LinuxErr(int rc) 972 { 973 switch (rc) 974 { 975 case 0: return 0; 976 case SUPDRV_ERR_GENERAL_FAILURE: return -EACCES; 977 case SUPDRV_ERR_INVALID_PARAM: return -EINVAL; 978 case SUPDRV_ERR_INVALID_MAGIC: return -EILSEQ; 979 case SUPDRV_ERR_INVALID_HANDLE: return -ENXIO; 980 case SUPDRV_ERR_INVALID_POINTER: return -EFAULT; 981 case SUPDRV_ERR_LOCK_FAILED: return -ENOLCK; 982 case SUPDRV_ERR_ALREADY_LOADED: return -EEXIST; 983 case SUPDRV_ERR_PERMISSION_DENIED: return -EPERM; 984 case SUPDRV_ERR_VERSION_MISMATCH: return -ENOSYS; 985 case SUPDRV_ERR_IDT_FAILED: return -1000; 986 } 987 988 return -EPERM; 989 } 990 991 992 RTDECL(int) SUPR0Printf(const char *pszFormat, ...) 993 { 994 #if 1 995 va_list args; 996 char szMsg[512]; 997 998 va_start(args, pszFormat); 999 vsnprintf(szMsg, sizeof(szMsg) - 1, pszFormat, args); 1000 szMsg[sizeof(szMsg) - 1] = '\0'; 1001 printk("%s", szMsg); 1002 va_end(args); 1003 #else 1004 /* forward to printf - needs some more GCC hacking to fix ebp... */ 1005 __asm__ __volatile__ ("mov %0, %esp\n\t" 1006 "jmp %1\n\t", 1007 :: "r" ((uintptr_t)&pszFormat - 4), 1008 "m" (printk)); 1009 #endif 1010 return 0; 1011 } 1012 1013 module_init(VBoxDrvLinuxInit); 1014 module_exit(VBoxDrvLinuxUnload); 659 /* Common code that depend on g_DevExt. */ 660 #include "VBoxGuestIDC-unix.c.h" 661 662 EXPORT_SYMBOL(VBoxGuestIDCOpen); 663 EXPORT_SYMBOL(VBoxGuestIDCClose); 664 EXPORT_SYMBOL(VBoxGuestIDCCall); 665 666 module_init(vboxguestLinuxModInit); 667 module_exit(vboxguestLinuxModExit); 1015 668 1016 669 MODULE_AUTHOR("Sun Microsystems, Inc."); 1017 MODULE_DESCRIPTION("VirtualBox Support Driver");670 MODULE_DESCRIPTION("VirtualBox Guest Additions for Linux Module"); 1018 671 MODULE_LICENSE("GPL"); 1019 672 #ifdef MODULE_VERSION … … 1021 674 #endif 1022 675 1023 module_param(force_async_tsc, int, 0444);1024 MODULE_PARM_DESC(force_async_tsc, "force the asynchronous TSC mode");1025 -
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-solaris.c
r14203 r21069 71 71 static void VBoxGuestSolarisRemoveIRQ(dev_info_t *pDip, void *pvState); 72 72 static uint_t VBoxGuestSolarisISR(caddr_t Arg); 73 74 DECLVBGL(int) VBoxGuestSolarisServiceCall(void *pvSession, unsigned iCmd, void *pvData, size_t cbData, size_t *pcbDataReturned);75 DECLVBGL(void *) VBoxGuestSolarisServiceOpen(uint32_t *pu32Version);76 DECLVBGL(int) VBoxGuestSolarisServiceClose(void *pvSession);77 73 78 74 … … 195 191 #endif /* USE_SESSION_HASH */ 196 192 193 #if 0/** @todo This shouldn't be needed. if it is, that means exceptions hasn't been disabled correctly. */ 197 194 /** GCC C++ hack. */ 198 195 unsigned __gxx_personality_v0 = 0xdecea5ed; 196 #endif 199 197 200 198 /** … … 242 240 static int VBoxGuestSolarisAttach(dev_info_t *pDip, ddi_attach_cmd_t enmCmd) 243 241 { 244 LogFlow((DEVICE_NAME ": VBoxGuestSolarisAttach\n"));242 LogFlow((DEVICE_NAME "::Attach\n")); 245 243 switch (enmCmd) 246 244 { … … 332 330 */ 333 331 rc = VBoxGuestInitDevExt(&g_DevExt, pState->uIOPortBase, pState->pMMIOBase, 334 pState->cbMMIO, VBOXOSTYPE_Solaris);332 pState->cbMMIO, VBOXOSTYPE_Solaris); 335 333 if (RT_SUCCESS(rc)) 336 334 { … … 345 343 } 346 344 347 LogRel((DEVICE_NAME ":ddi_create_minor_node failed.\n")); 345 LogRel((DEVICE_NAME ": ddi_create_minor_node failed.\n")); 346 VBoxGuestDeleteDevExt(&g_DevExt); 348 347 } 349 348 else 350 LogRel((DEVICE_NAME ": VBoxGuestInitDevExt failed.\n"));349 LogRel((DEVICE_NAME ": VBoxGuestInitDevExt failed.\n")); 351 350 VBoxGuestSolarisRemoveIRQ(pDip, pState); 352 351 } 353 352 else 354 LogRel((DEVICE_NAME ": VBoxGuestSolarisAddIRQ failed.\n"));353 LogRel((DEVICE_NAME ": VBoxGuestSolarisAddIRQ failed.\n")); 355 354 ddi_regs_map_free(&pState->PciMMIOHandle); 356 355 } 357 356 else 358 LogRel((DEVICE_NAME ": ddi_regs_map_setup for MMIO region failed.\n"));357 LogRel((DEVICE_NAME ": ddi_regs_map_setup for MMIO region failed.\n")); 359 358 } 360 359 else 361 LogRel((DEVICE_NAME ": ddi_dev_regsize for MMIO region failed.\n"));360 LogRel((DEVICE_NAME ": ddi_dev_regsize for MMIO region failed.\n")); 362 361 ddi_regs_map_free(&pState->PciIOHandle); 363 362 } 364 363 else 365 LogRel((DEVICE_NAME ": ddi_regs_map_setup for IOport failed.\n"));364 LogRel((DEVICE_NAME ": ddi_regs_map_setup for IOport failed.\n")); 366 365 pci_config_teardown(&PciHandle); 367 366 } 368 367 else 369 LogRel((DEVICE_NAME ": pci_config_setup failed rc=%d.\n", rc));368 LogRel((DEVICE_NAME ": pci_config_setup failed rc=%d.\n", rc)); 370 369 RTSpinlockDestroy(g_Spinlock); 371 370 g_Spinlock = NIL_RTSPINLOCK; 372 371 } 373 372 else 374 LogRel((DEVICE_NAME ": RTSpinlockCreate failed.\n"));373 LogRel((DEVICE_NAME ": RTSpinlockCreate failed.\n")); 375 374 376 375 RTR0Term(); … … 400 399 static int VBoxGuestSolarisDetach(dev_info_t *pDip, ddi_detach_cmd_t enmCmd) 401 400 { 402 LogFlow((DEVICE_NAME ": VBoxGuestSolarisDetach\n"));401 LogFlow((DEVICE_NAME "::Detach\n")); 403 402 switch (enmCmd) 404 403 { … … 459 458 static int VBoxGuestSolarisGetInfo(dev_info_t *pDip, ddi_info_cmd_t enmCmd, void *pvArg, void **ppvResult) 460 459 { 461 LogFlow((DEVICE_NAME ": VBoxGuestSolarisGetInfo\n"));460 LogFlow((DEVICE_NAME "::GetInfo\n")); 462 461 463 462 int rc = DDI_SUCCESS; … … 490 489 PVBOXGUESTSESSION pSession; 491 490 492 LogFlow((DEVICE_NAME ": VBoxGuestSolarisOpen\n"));491 LogFlow((DEVICE_NAME "::Open\n")); 493 492 494 493 /* … … 512 511 if (!pState) 513 512 { 514 Log((DEVICE_NAME ": VBoxGuestSolarisOpen: too many open instances."));513 Log((DEVICE_NAME "::Open: too many open instances.")); 515 514 return ENXIO; 516 515 } … … 524 523 pState->pSession = pSession; 525 524 *pDev = makedevice(getmajor(*pDev), iOpenInstance); 526 Log((DEVICE_NAME " VBoxGuestSolarisOpen: pSession=%p pState=%p pid=%d\n", pSession, pState, (int)RTProcSelf()));525 Log((DEVICE_NAME "::Open: pSession=%p pState=%p pid=%d\n", pSession, pState, (int)RTProcSelf())); 527 526 return 0; 528 527 } … … 556 555 if (instance >= 4096) 557 556 { 558 Log((DEVICE_NAME ": VBoxGuestSolarisOpen: All instances exhausted\n"));557 Log((DEVICE_NAME "::Open: All instances exhausted\n")); 559 558 return ENXIO; 560 559 } 561 560 *pDev = makedevice(getmajor(*pDev), instance); 562 Log((DEVICE_NAME ": VBoxGuestSolarisOpen success: g_DevExt=%p pSession=%p rc=%d pid=%d\n", &g_DevExt, pSession, rc, (int)RTProcSelf()));561 Log((DEVICE_NAME "::Open success: g_DevExt=%p pSession=%p rc=%d pid=%d\n", &g_DevExt, pSession, rc, (int)RTProcSelf())); 563 562 return 0; 564 563 } 565 564 #endif 566 LogRel((DEVICE_NAME ": VBoxGuestSolarisOpen: VBoxGuestCreateUserSession failed. rc=%d\n", rc));565 LogRel((DEVICE_NAME "::Open: VBoxGuestCreateUserSession failed. rc=%d\n", rc)); 567 566 return EFAULT; 568 567 } … … 571 570 static int VBoxGuestSolarisClose(dev_t Dev, int flag, int fType, cred_t *pCred) 572 571 { 573 LogFlow((DEVICE_NAME ": VBoxGuestSolarisClose pid=%d\n", (int)RTProcSelf()));572 LogFlow((DEVICE_NAME "::Close pid=%d\n", (int)RTProcSelf())); 574 573 575 574 #ifndef USE_SESSION_HASH … … 578 577 if (!pState) 579 578 { 580 Log((DEVICE_NAME ": VBoxGuestSolarisClose: failed to get pState.\n"));579 Log((DEVICE_NAME "::Close: failed to get pState.\n")); 581 580 return EFAULT; 582 581 } … … 584 583 pSession = pState->pSession; 585 584 pState->pSession = NULL; 586 Log((DEVICE_NAME ": VBoxGuestSolarisClose: pSession=%p pState=%p\n", pSession, pState));585 Log((DEVICE_NAME "::Close: pSession=%p pState=%p\n", pSession, pState)); 587 586 ddi_soft_state_free(g_pVBoxGuestSolarisState, getminor(Dev)); 588 587 if (!pSession) 589 588 { 590 Log((DEVICE_NAME ": VBoxGuestSolarisClose: failed to get pSession.\n"));589 Log((DEVICE_NAME "::Close: failed to get pSession.\n")); 591 590 return EFAULT; 592 591 } … … 632 631 if (!pSession) 633 632 { 634 Log((DEVICE_NAME ": VBoxGuestSolarisClose: WHUT?!? pSession == NULL! This must be a mistake... pid=%d", (int)Process));633 Log((DEVICE_NAME "::Close: WHUT?!? pSession == NULL! This must be a mistake... pid=%d", (int)Process)); 635 634 return EFAULT; 636 635 } 637 Log((DEVICE_NAME ": VBoxGuestSolarisClose: pid=%d\n", (int)Process));636 Log((DEVICE_NAME "::Close: pid=%d\n", (int)Process)); 638 637 #endif /* USE_SESSION_HASH */ 639 638 … … 648 647 static int VBoxGuestSolarisRead(dev_t Dev, struct uio *pUio, cred_t *pCred) 649 648 { 650 LogFlow((DEVICE_NAME ": VBoxGuestSolarisRead\n"));649 LogFlow((DEVICE_NAME "::Read\n")); 651 650 return 0; 652 651 } … … 655 654 static int VBoxGuestSolarisWrite(dev_t Dev, struct uio *pUio, cred_t *pCred) 656 655 { 657 LogFlow((DEVICE_NAME ": VBoxGuestSolarisWrite\n"));656 LogFlow((DEVICE_NAME "::Write\n")); 658 657 return 0; 659 658 } … … 692 691 if (!pState) 693 692 { 694 Log((DEVICE_NAME ": VBoxGuestSolarisIOCtl: no state data for %d\n", getminor(Dev)));693 Log((DEVICE_NAME "::IOCtl: no state data for %d\n", getminor(Dev))); 695 694 return EINVAL; 696 695 } … … 699 698 if (!pSession) 700 699 { 701 Log((DEVICE_NAME ": VBoxGuestSolarisIOCtl: no session data for %d\n", getminor(Dev)));700 Log((DEVICE_NAME "::IOCtl: no session data for %d\n", getminor(Dev))); 702 701 return EINVAL; 703 702 } … … 722 721 if (!pSession) 723 722 { 724 Log((DEVICE_NAME ": VBoxGuestSolarisIOCtl: WHAT?!? pSession == NULL! This must be a mistake... pid=%d iCmd=%#x\n", (int)Process, Cmd));723 Log((DEVICE_NAME "::IOCtl: WHAT?!? pSession == NULL! This must be a mistake... pid=%d iCmd=%#x\n", (int)Process, Cmd)); 725 724 return EINVAL; 726 725 } … … 733 732 if (IOCPARM_LEN(Cmd) != sizeof(ReqWrap)) 734 733 { 735 LogRel((DEVICE_NAME ": VBoxGuestSolarisIOCtl: bad request %#x size=%d expected=%d\n", Cmd, IOCPARM_LEN(Cmd), sizeof(ReqWrap)));734 LogRel((DEVICE_NAME "::IOCtl: bad request %#x size=%d expected=%d\n", Cmd, IOCPARM_LEN(Cmd), sizeof(ReqWrap))); 736 735 return ENOTTY; 737 736 } … … 740 739 if (RT_UNLIKELY(rc)) 741 740 { 742 LogRel((DEVICE_NAME ": VBoxGuestSolarisIOCtl: ddi_copyin failed to read header pArg=%p Cmd=%d. rc=%d.\n", pArg, Cmd, rc));741 LogRel((DEVICE_NAME "::IOCtl: ddi_copyin failed to read header pArg=%p Cmd=%d. rc=%d.\n", pArg, Cmd, rc)); 743 742 return EINVAL; 744 743 } … … 746 745 if (ReqWrap.u32Magic != VBGLBIGREQ_MAGIC) 747 746 { 748 LogRel((DEVICE_NAME ": VBoxGuestSolarisIOCtl: bad magic %#x; pArg=%p Cmd=%d.\n", ReqWrap.u32Magic, pArg, Cmd));747 LogRel((DEVICE_NAME "::IOCtl: bad magic %#x; pArg=%p Cmd=%d.\n", ReqWrap.u32Magic, pArg, Cmd)); 749 748 return EINVAL; 750 749 } … … 752 751 || ReqWrap.cbData > _1M*16)) 753 752 { 754 Log((DEVICE_NAME ": VBoxGuestSolarisIOCtl: bad size %#x; pArg=%p Cmd=%d.\n", ReqWrap.cbData, pArg, Cmd));753 Log((DEVICE_NAME "::IOCtl: bad size %#x; pArg=%p Cmd=%d.\n", ReqWrap.cbData, pArg, Cmd)); 755 754 return EINVAL; 756 755 } … … 762 761 if (RT_UNLIKELY(!pvBuf)) 763 762 { 764 LogRel((DEVICE_NAME ": VBoxGuestSolarisIOCtl: RTMemTmpAlloc failed to alloc %d bytes.\n", ReqWrap.cbData));763 LogRel((DEVICE_NAME "::IOCtl: RTMemTmpAlloc failed to alloc %d bytes.\n", ReqWrap.cbData)); 765 764 return ENOMEM; 766 765 } … … 770 769 { 771 770 RTMemTmpFree(pvBuf); 772 LogRel((DEVICE_NAME ": VBoxGuestSolarisIOCtl: ddi_copyin failed; pvBuf=%p pArg=%p Cmd=%d. rc=%d\n", pvBuf, pArg, Cmd, rc));771 LogRel((DEVICE_NAME "::IOCtl: ddi_copyin failed; pvBuf=%p pArg=%p Cmd=%d. rc=%d\n", pvBuf, pArg, Cmd, rc)); 773 772 return EFAULT; 774 773 } … … 777 776 { 778 777 RTMemTmpFree(pvBuf); 779 LogRel((DEVICE_NAME ": VBoxGuestSolarisIOCtl: pvBuf invalid pointer %p\n", pvBuf));778 LogRel((DEVICE_NAME "::IOCtl: pvBuf invalid pointer %p\n", pvBuf)); 780 779 return EINVAL; 781 780 } 782 Log((DEVICE_NAME ": VBoxGuestSolarisIOCtl: pSession=%p pid=%d.\n", pSession, (int)RTProcSelf()));781 Log((DEVICE_NAME "::IOCtl: pSession=%p pid=%d.\n", pSession, (int)RTProcSelf())); 783 782 784 783 /* … … 792 791 if (RT_UNLIKELY(cbDataReturned > ReqWrap.cbData)) 793 792 { 794 LogRel((DEVICE_NAME ": VBoxGuestSolarisIOCtl: too much output data %d expected %d\n", cbDataReturned, ReqWrap.cbData));793 LogRel((DEVICE_NAME "::IOCtl: too much output data %d expected %d\n", cbDataReturned, ReqWrap.cbData)); 795 794 cbDataReturned = ReqWrap.cbData; 796 795 } … … 800 799 if (RT_UNLIKELY(rc)) 801 800 { 802 LogRel((DEVICE_NAME ":VBoxGuestSolarisIOCtl: ddi_copyout failed; pvBuf=%p pArg=%p Cmd=%d. rc=%d\n", pvBuf, pArg, Cmd, rc)); 801 LogRel((DEVICE_NAME "::IOCtl: ddi_copyout failed; pvBuf=%p pArg=%p cbDataReturned=%u Cmd=%d. rc=%d\n", 802 pvBuf, pArg, cbDataReturned, Cmd, rc)); 803 803 rc = EFAULT; 804 804 } … … 807 807 else 808 808 { 809 LogRel((DEVICE_NAME ": VBoxGuestSolarisIOCtl: VBoxGuestCommonIOCtl failed. rc=%d\n", rc));809 LogRel((DEVICE_NAME "::IOCtl: VBoxGuestCommonIOCtl failed. rc=%d\n", rc)); 810 810 rc = RTErrConvertToErrno(rc); 811 811 } … … 825 825 static int VBoxGuestSolarisAddIRQ(dev_info_t *pDip, void *pvState) 826 826 { 827 LogFlow((DEVICE_NAME ": VBoxGuestSolarisAddIRQ%p\n", pvState));827 LogFlow((DEVICE_NAME "::AddIRQ: %p\n", pvState)); 828 828 829 829 vboxguest_state_t *pState = (vboxguest_state_t *)pvState; … … 903 903 } 904 904 else 905 LogRel((DEVICE_NAME ": VBoxGuestSolarisAddIRQ: failed to get priority of interrupt. rc=%d\n", rc));905 LogRel((DEVICE_NAME "::AddIRQ: failed to get priority of interrupt. rc=%d\n", rc)); 906 906 907 907 /* Remove allocated IRQs, too bad we can free only one handle at a time. */ … … 910 910 } 911 911 else 912 LogRel((DEVICE_NAME ": VBoxGuestSolarisAddIRQ: failed to allocated IRQs. count=%d\n", IntrCount));912 LogRel((DEVICE_NAME "::AddIRQ: failed to allocated IRQs. count=%d\n", IntrCount)); 913 913 RTMemFree(pState->pIntr); 914 914 } 915 915 else 916 LogRel((DEVICE_NAME ": VBoxGuestSolarisAddIRQ: failed to allocated IRQs. count=%d\n", IntrCount));916 LogRel((DEVICE_NAME "::AddIRQ: failed to allocated IRQs. count=%d\n", IntrCount)); 917 917 } 918 918 else 919 LogRel((DEVICE_NAME ": VBoxGuestSolarisAddIRQ: failed to get or insufficient available IRQs. rc=%d IntrAvail=%d\n", rc, IntrAvail));919 LogRel((DEVICE_NAME "::AddIRQ: failed to get or insufficient available IRQs. rc=%d IntrAvail=%d\n", rc, IntrAvail)); 920 920 } 921 921 else 922 LogRel((DEVICE_NAME ": VBoxGuestSolarisAddIRQ: failed to get or insufficient number of IRQs. rc=%d IntrCount=%d\n", rc, IntrCount));922 LogRel((DEVICE_NAME "::AddIRQ: failed to get or insufficient number of IRQs. rc=%d IntrCount=%d\n", rc, IntrCount)); 923 923 } 924 924 else 925 LogRel((DEVICE_NAME ": VBoxGuestSolarisAddIRQ: invalid irq type. IntrType=%#x\n", IntrType));925 LogRel((DEVICE_NAME "::AddIRQ: invalid irq type. IntrType=%#x\n", IntrType)); 926 926 } 927 927 else 928 LogRel((DEVICE_NAME ": VBoxGuestSolarisAddIRQ: failed to get supported interrupt types\n"));928 LogRel((DEVICE_NAME "::AddIRQ: failed to get supported interrupt types\n")); 929 929 return rc; 930 930 #endif … … 941 941 { 942 942 vboxguest_state_t *pState = (vboxguest_state_t *)pvState; 943 LogFlow((DEVICE_NAME ": VBoxGuestSolarisRemoveIRQpvState=%p\n"));943 LogFlow((DEVICE_NAME "::RemoveIRQ: pvState=%p\n")); 944 944 945 945 #if 0 … … 970 970 static uint_t VBoxGuestSolarisISR(caddr_t Arg) 971 971 { 972 LogFlow((DEVICE_NAME ": VBoxGuestSolarisISRArg=%p\n", Arg));972 LogFlow((DEVICE_NAME "::ISR: Arg=%p\n", Arg)); 973 973 974 974 vboxguest_state_t *pState = (vboxguest_state_t *)Arg; … … 981 981 982 982 983 /** 984 * VBoxGuest Common ioctl wrapper from VBoxGuestLib. 985 * 986 * @returns VBox error code. 987 * @param pvSession Opaque pointer to the session. 988 * @param iCmd Requested function. 989 * @param pvData IO data buffer. 990 * @param cbData Size of the data buffer. 991 * @param pcbDataReturned Where to store the amount of returned data. 992 */ 993 DECLVBGL(int) VBoxGuestSolarisServiceCall(void *pvSession, unsigned iCmd, void *pvData, size_t cbData, size_t *pcbDataReturned) 994 { 995 LogFlow((DEVICE_NAME ":VBoxGuestSolarisServiceCall %pvSesssion=%p Cmd=%u pvData=%p cbData=%d\n", pvSession, iCmd, pvData, cbData)); 996 997 PVBOXGUESTSESSION pSession = (PVBOXGUESTSESSION)pvSession; 998 AssertPtrReturn(pSession, VERR_INVALID_POINTER); 999 AssertMsgReturn(pSession->pDevExt == &g_DevExt, 1000 ("SC: %p != %p\n", pSession->pDevExt, &g_DevExt), VERR_INVALID_HANDLE); 1001 1002 return VBoxGuestCommonIOCtl(iCmd, &g_DevExt, pSession, pvData, cbData, pcbDataReturned); 1003 } 1004 1005 1006 /** 1007 * Solaris Guest service open. 1008 * 1009 * @returns Opaque pointer to session object. 1010 * @param pu32Version Where to store VMMDev version. 1011 */ 1012 DECLVBGL(void *) VBoxGuestSolarisServiceOpen(uint32_t *pu32Version) 1013 { 1014 LogFlow((DEVICE_NAME ":VBoxGuestSolarisServiceOpen\n")); 1015 1016 AssertPtrReturn(pu32Version, NULL); 1017 PVBOXGUESTSESSION pSession; 1018 int rc = VBoxGuestCreateKernelSession(&g_DevExt, &pSession); 1019 if (RT_SUCCESS(rc)) 1020 { 1021 *pu32Version = VMMDEV_VERSION; 1022 return pSession; 1023 } 1024 LogRel((DEVICE_NAME ":VBoxGuestCreateKernelSession failed. rc=%d\n", rc)); 1025 return NULL; 1026 } 1027 1028 1029 /** 1030 * Solaris Guest service close. 1031 * 1032 * @returns VBox error code. 1033 * @param pvState Opaque pointer to the session object. 1034 */ 1035 DECLVBGL(int) VBoxGuestSolarisServiceClose(void *pvSession) 1036 { 1037 LogFlow((DEVICE_NAME ":VBoxGuestSolarisServiceClose\n")); 1038 1039 PVBOXGUESTSESSION pSession = (PVBOXGUESTSESSION)pvSession; 1040 AssertPtrReturn(pSession, VERR_INVALID_POINTER); 1041 if (pSession) 1042 { 1043 VBoxGuestCloseSession(&g_DevExt, pSession); 1044 return VINF_SUCCESS; 1045 } 1046 LogRel((DEVICE_NAME ":Invalid pSession.\n")); 1047 return VERR_INVALID_HANDLE; 1048 } 1049 983 /* Common code that depend on g_DevExt. */ 984 #include "VBoxGuestIDC-unix.c.h" 985 -
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest.cpp
r21023 r21069 1451 1451 } 1452 1452 1453 -
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuestInternal.h
r20374 r21069 162 162 void *pvData, size_t cbData, size_t *pcbDataReturned); 163 163 164 #if defined(RT_OS_SOLARIS) \ 165 || defined(RT_OS_FREEBSD) \ 166 || defined(RT_OS_LINUX) 167 DECLVBGL(void *) VBoxGuestNativeServiceOpen(uint32_t *pu32Version); 168 DECLVBGL(void) VBoxGuestNativeServiceClose(void *pvOpaque); 169 DECLVBGL(int) VBoxGuestNativeServiceCall(void *pvOpaque, unsigned int iCmd, void *pvData, size_t cbSize, size_t *pcbReturn); 170 #endif 171 164 172 RT_C_DECLS_END 165 173 -
trunk/src/VBox/Additions/common/VBoxGuestLib/SysHlp.cpp
r20374 r21069 1 /* $Revision$ */ 1 2 /** @file 2 * 3 * VBoxGuestLib - A support library for VirtualBox guest additions: 4 * Physical memory heap 3 * VBoxGuestLib - IDC with VBoxGuest and HGCM helpers. 5 4 */ 6 5 7 6 /* 8 * Copyright (C) 2006-200 7Sun Microsystems, Inc.7 * Copyright (C) 2006-2009 Sun Microsystems, Inc. 9 8 * 10 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 20 19 * additional information or have any questions. 21 20 */ 21 22 22 #define LOG_GROUP LOG_GROUP_HGCM 23 23 #include <VBox/log.h> … … 27 27 28 28 #include <iprt/assert.h> 29 #if !defined(RT_OS_WINDOWS) && !defined(RT_OS_LINUX) 30 #include <iprt/memobj.h> 29 #if !defined (RT_OS_WINDOWS) \ 30 && (!defined (RT_OS_LINUX) || defined (VBOX_WITH_COMMON_VBOXGUEST_ON_LINUX)) 31 # include <iprt/memobj.h> 31 32 #endif 32 33 … … 74 75 } 75 76 76 #elif defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD) 77 /** @todo r=bird: I don't think FreeBSD shouldn't go here, solaris and OS/2 doesn't 78 * That said, the assumption below might be wrong for in kernel calls... */ 79 77 #elif defined (RT_OS_LINUX) && !defined (VBOX_WITH_COMMON_VBOXGUEST_ON_LINUX) 80 78 /** @todo r=frank: Linux: pv is at least in some cases, e.g. with VBoxMapFolder, 81 79 * an R0 address -- the memory was allocated with kmalloc(). I don't know … … 120 118 } 121 119 122 #elif defined (RT_OS_LINUX) || defined(RT_OS_FREEBSD)120 #elif defined (RT_OS_LINUX) && !defined (VBOX_WITH_COMMON_VBOXGUEST_ON_LINUX) 123 121 NOREF(pvCtx); 124 122 … … 134 132 #ifndef VBGL_VBOXGUEST 135 133 136 # if defined (RT_OS_LINUX) && !defined (__KERNEL__)137 # include <unistd.h>138 # include <errno.h>139 # include <sys/fcntl.h>140 # include <sys/ioctl.h>141 # endif142 143 # ifdef RT_OS_LINUX134 # if defined (RT_OS_LINUX) && !defined (__KERNEL__) /** @todo r=bird: What is this for?????? */ 135 # include <unistd.h> 136 # include <errno.h> 137 # include <sys/fcntl.h> 138 # include <sys/ioctl.h> 139 # endif 140 141 # if defined (RT_OS_LINUX) && !defined (VBOX_WITH_COMMON_VBOXGUEST_ON_LINUX) 144 142 RT_C_DECLS_BEGIN 145 143 extern DECLVBGL(void *) vboxadd_cmc_open (void); … … 147 145 extern DECLVBGL(int) vboxadd_cmc_call (void *opaque, uint32_t func, void *data); 148 146 RT_C_DECLS_END 149 # endif /* RT_OS_LINUX */150 151 # ifdef RT_OS_OS2147 # endif /* RT_OS_LINUX */ 148 149 # ifdef RT_OS_OS2 152 150 RT_C_DECLS_BEGIN 153 151 /* … … 158 156 extern VBOXGUESTOS2IDCCONNECT g_VBoxGuestIDC; 159 157 RT_C_DECLS_END 160 #endif 161 162 #ifdef RT_OS_SOLARIS 158 # endif 159 160 # if !defined(RT_OS_OS2) \ 161 && !defined(RT_OS_WINDOWS) \ 162 && (!defined (RT_OS_LINUX) || defined (VBOX_WITH_COMMON_VBOXGUEST_ON_LINUX)) 163 163 RT_C_DECLS_BEGIN 164 extern DECLVBGL(void *) VBoxGuest SolarisServiceOpen (uint32_t *pu32Version);165 extern DECLVBGL(void) VBoxGuestSolarisServiceClose (void *pvOpaque);166 extern DECLVBGL(int) VBoxGuestSolarisServiceCall (void *pvOpaque, unsigned int iCmd, void *pvData, size_t cbSize, size_t *pcbReturn);164 extern DECLVBGL(void *) VBoxGuestIDCOpen (uint32_t *pu32Version); 165 extern DECLVBGL(void) VBoxGuestIDCClose (void *pvOpaque); 166 extern DECLVBGL(int) VBoxGuestIDCCall (void *pvOpaque, unsigned int iCmd, void *pvData, size_t cbSize, size_t *pcbReturn); 167 167 RT_C_DECLS_END 168 169 #elif defined (RT_OS_FREEBSD) 170 RT_C_DECLS_BEGIN 171 extern DECLVBGL(void *) VBoxGuestFreeBSDServiceOpen (uint32_t *pu32Version); 172 extern DECLVBGL(void) VBoxGuestFreeBSDServiceClose (void *pvOpaque); 173 extern DECLVBGL(int) VBoxGuestFreeBSDServiceCall (void *pvOpaque, unsigned int iCmd, void *pvData, size_t cbSize, size_t *pcbReturn); 174 RT_C_DECLS_END 175 176 #endif 168 # endif 177 169 178 170 int vbglDriverOpen (VBGLDRIVER *pDriver) 179 171 { 180 # ifdef RT_OS_WINDOWS172 # ifdef RT_OS_WINDOWS 181 173 UNICODE_STRING uszDeviceName; 182 174 RtlInitUnicodeString (&uszDeviceName, L"\\Device\\VBoxGuest"); … … 199 191 return rc; 200 192 201 #elif defined (RT_OS_LINUX) 193 # elif defined (RT_OS_LINUX) && !defined (VBOX_WITH_COMMON_VBOXGUEST_ON_LINUX) 194 202 195 void *opaque; 203 196 … … 210 203 return VINF_SUCCESS; 211 204 212 # elif defined (RT_OS_OS2)205 # elif defined (RT_OS_OS2) 213 206 /* 214 207 * Just check whether the connection was made or not. … … 225 218 return VERR_FILE_NOT_FOUND; 226 219 227 # elif defined (RT_OS_SOLARIS)220 # else 228 221 uint32_t u32VMMDevVersion; 229 pDriver->pvOpaque = VBoxGuest SolarisServiceOpen(&u32VMMDevVersion);222 pDriver->pvOpaque = VBoxGuestIDCOpen (&u32VMMDevVersion); 230 223 if ( pDriver->pvOpaque 231 224 && u32VMMDevVersion == VMMDEV_VERSION) … … 234 227 Log(("vbglDriverOpen: failed\n")); 235 228 return VERR_FILE_NOT_FOUND; 236 237 #elif defined (RT_OS_FREEBSD) 238 uint32_t u32VMMDevVersion; 239 pDriver->pvOpaque = VBoxGuestFreeBSDServiceOpen(&u32VMMDevVersion); 240 if (pDriver->pvOpaque && (u32VMMDevVersion == VMMDEV_VERSION)) 241 return VINF_SUCCESS; 242 243 Log(("vbglDriverOpen: failed\n")); 244 return VERR_FILE_NOT_FOUND; 245 246 #else 247 # error "Port me" 248 #endif 249 } 250 251 #ifdef RT_OS_WINDOWS 229 # endif 230 } 231 232 # ifdef RT_OS_WINDOWS 252 233 static NTSTATUS vbglDriverIOCtlCompletion (IN PDEVICE_OBJECT DeviceObject, 253 234 IN PIRP Irp, … … 261 242 return STATUS_MORE_PROCESSING_REQUIRED; 262 243 } 263 # endif244 # endif 264 245 265 246 int vbglDriverIOCtl (VBGLDRIVER *pDriver, uint32_t u32Function, void *pvData, uint32_t cbData) … … 267 248 Log(("vbglDriverIOCtl: pDriver: %p, Func: %x, pvData: %p, cbData: %d\n", pDriver, u32Function, pvData, cbData)); 268 249 269 # ifdef RT_OS_WINDOWS250 # ifdef RT_OS_WINDOWS 270 251 KEVENT Event; 271 252 … … 330 311 return NT_SUCCESS(rc)? VINF_SUCCESS: VERR_VBGL_IOCTL_FAILED; 331 312 332 # elif defined (RT_OS_LINUX)313 # elif defined (RT_OS_LINUX) && !defined (VBOX_WITH_COMMON_VBOXGUEST_ON_LINUX) 333 314 return vboxadd_cmc_call (pDriver->opaque, u32Function, pvData); 334 315 335 # elif defined (RT_OS_OS2)316 # elif defined (RT_OS_OS2) 336 317 if ( pDriver->u32Session 337 318 && pDriver->u32Session == g_VBoxGuestIDC.u32Session) … … 341 322 return VERR_WRONG_ORDER; 342 323 343 #elif defined (RT_OS_SOLARIS) 344 return VBoxGuestSolarisServiceCall(pDriver->pvOpaque, u32Function, pvData, cbData, NULL); 345 346 #elif defined (RT_OS_FREEBSD) 347 return VBoxGuestFreeBSDServiceCall(pDriver->pvOpaque, u32Function, pvData, cbData, NULL); 348 349 #else 350 # error "Port me" 351 #endif 324 # else 325 return VBoxGuestIDCCall(pDriver->pvOpaque, u32Function, pvData, cbData, NULL); 326 # endif 352 327 } 353 328 354 329 void vbglDriverClose (VBGLDRIVER *pDriver) 355 330 { 356 # ifdef RT_OS_WINDOWS331 # ifdef RT_OS_WINDOWS 357 332 Log(("vbglDriverClose pDeviceObject=%x\n", pDriver->pDeviceObject)); 358 333 ObDereferenceObject (pDriver->pFileObject); 359 334 360 # elif defined (RT_OS_LINUX)335 # elif defined (RT_OS_LINUX) && !defined (VBOX_WITH_COMMON_VBOXGUEST_ON_LINUX) 361 336 vboxadd_cmc_close (pDriver->opaque); 362 337 363 # elif defined (RT_OS_OS2)338 # elif defined (RT_OS_OS2) 364 339 pDriver->u32Session = 0; 365 340 366 #elif defined (RT_OS_SOLARIS) 367 VBoxGuestSolarisServiceClose (pDriver->pvOpaque); 368 369 #elif defined (RT_OS_FREEBSD) 370 VBoxGuestFreeBSDServiceClose(pDriver->pvOpaque); 371 372 #else 373 # error "Port me" 374 #endif 341 # else 342 VBoxGuestIDCClose (pDriver->pvOpaque); 343 # endif 375 344 } 376 345
Note:
See TracChangeset
for help on using the changeset viewer.