Changeset 13939 in vbox for trunk/src/VBox/HostDrivers/Support/linux/SUPDrv-linux.c
- Timestamp:
- Nov 6, 2008 9:24:12 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/Support/linux/SUPDrv-linux.c
r13934 r13939 49 49 #include <iprt/mp.h> 50 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_NOTIFICATION 55 #endif 56 51 57 #include <linux/sched.h> 52 58 #ifdef CONFIG_DEVFS_FS … … 61 67 # include <asm/nmi.h> 62 68 # endif 69 #endif 70 #ifdef VBOX_WITH_SUSPEND_NOTIFICATION 71 # include <linux/platform_device.h> 63 72 #endif 64 73 … … 218 227 * Internal Functions * 219 228 *******************************************************************************/ 220 static int 221 static void 222 static int 223 static int 229 static int VBoxDrvLinuxInit(void); 230 static void VBoxDrvLinuxUnload(void); 231 static int VBoxDrvLinuxCreate(struct inode *pInode, struct file *pFilp); 232 static int VBoxDrvLinuxClose(struct inode *pInode, struct file *pFilp); 224 233 #ifdef HAVE_UNLOCKED_IOCTL 225 static long 234 static long VBoxDrvLinuxIOCtl(struct file *pFilp, unsigned int uCmd, unsigned long ulArg); 226 235 #else 227 static int VBoxDrvLinuxIOCtl(struct inode *pInode, struct file *pFilp, unsigned int uCmd, unsigned long ulArg); 228 #endif 229 static int VBoxDrvLinuxIOCtlSlow(struct file *pFilp, unsigned int uCmd, unsigned long ulArg); 230 static int VBoxDrvLinuxErr2LinuxErr(int); 231 236 static int VBoxDrvLinuxIOCtl(struct inode *pInode, struct file *pFilp, unsigned int uCmd, unsigned long ulArg); 237 #endif 238 static int VBoxDrvLinuxIOCtlSlow(struct file *pFilp, unsigned int uCmd, unsigned long ulArg); 239 static int VBoxDrvLinuxErr2LinuxErr(int); 240 #ifdef VBOX_WITH_SUSPEND_NOTIFICATION 241 static int VBoxDrvProbe(struct platform_device *pDev); 242 static int VBoxDrvSuspend(struct platform_device *pDev, pm_message_t State); 243 static int VBoxDrvResume(struct platform_device *pDev); 244 static void VBoxDevRelease(struct device *pDev); 245 #endif 232 246 233 247 /** The file_operations structure. */ … … 259 273 260 274 275 #ifdef VBOX_WITH_SUSPEND_NOTIFICATION 276 static struct platform_driver gPlatformDriver = 277 { 278 .probe = VBoxDrvProbe, 279 .suspend = VBoxDrvSuspend, 280 .resume = VBoxDrvResume, 281 /** @todo .shutdown? */ 282 .driver = 283 { 284 .name = "vboxdrv" 285 } 286 }; 287 288 static struct platform_device gPlatformDevice = 289 { 290 .name = "vboxdrv", 291 .dev = 292 { 293 .release = VBoxDevRelease 294 } 295 }; 296 #endif /* VBOX_WITH_SUSPEND_NOTIFICATION */ 261 297 262 298 … … 556 592 if (RT_SUCCESS(rc)) 557 593 rc = supdrvInitDevExt(&g_DevExt); 558 if ( !rc)594 if (RT_SUCCESS(rc)) 559 595 { 560 printk(KERN_INFO DEVICE_NAME ": TSC mode is %s, kernel timer mode is " 596 #ifdef VBOX_WITH_SUSPEND_NOTIFICATION 597 rc = platform_driver_register(&gPlatformDriver); 598 if (rc == 0) 599 { 600 rc = platform_device_register(&gPlatformDevice); 601 if (rc == 0) 602 #endif 603 { 604 printk(KERN_INFO DEVICE_NAME ": TSC mode is %s, kernel timer mode is " 561 605 #ifdef VBOX_HRTIMER 562 "'high-res'"606 "'high-res'" 563 607 #else 564 "'normal'" 565 #endif 566 ".\n", 567 g_DevExt.pGip->u32Mode == SUPGIPMODE_SYNC_TSC ? "'synchronous'" : "'asynchronous'"); 568 LogFlow(("VBoxDrv::ModuleInit returning %#x\n", rc)); 569 printk(KERN_DEBUG DEVICE_NAME ": Successfully loaded version " 570 VBOX_VERSION_STRING " (interface " xstr(SUPDRV_IOC_VERSION) ").\n"); 571 return rc; 608 "'normal'" 609 #endif 610 ".\n", 611 g_DevExt.pGip->u32Mode == SUPGIPMODE_SYNC_TSC ? "'synchronous'" : "'asynchronous'"); 612 LogFlow(("VBoxDrv::ModuleInit returning %#x\n", rc)); 613 printk(KERN_DEBUG DEVICE_NAME ": Successfully loaded version " 614 VBOX_VERSION_STRING " (interface " xstr(SUPDRV_IOC_VERSION) ").\n"); 615 return rc; 616 } 617 #ifdef VBOX_WITH_SUSPEND_NOTIFICATION 618 else 619 platform_driver_unregister(&gPlatformDriver); 620 } 621 #endif 572 622 } 573 623 … … 605 655 NOREF(rc); 606 656 657 #ifdef VBOX_WITH_SUSPEND_NOTIFICATION 658 platform_device_unregister(&gPlatformDevice); 659 platform_driver_unregister(&gPlatformDriver); 660 #endif 661 607 662 /* 608 663 * I Don't think it's possible to unload a driver which processes have … … 689 744 return 0; 690 745 } 746 747 748 #ifdef VBOX_WITH_SUSPEND_NOTIFICATION 749 /** 750 * Dummy device release function. We have to provide this function, 751 * otherwise the kernel will complain. 752 * 753 * @param pDev Pointer to the platform device. 754 */ 755 static void VBoxDevRelease(struct device *pDev) 756 { 757 } 758 759 /** 760 * Dummy probe function. 761 * 762 * @param pDev Pointer to the platform device. 763 */ 764 static int VBoxDrvProbe(struct platform_device *pDev) 765 { 766 return 0; 767 } 768 769 /** 770 * Suspend callback. 771 * @param pDev Pointer to the platform device. 772 * @param State message type, see Documentation/power/devices.txt. 773 */ 774 static int VBoxDrvSuspend(struct platform_device *pDev, pm_message_t State) 775 { 776 RTPowerSignalEvent(RTPOWEREVENT_SUSPEND); 777 return 0; 778 } 779 780 /** 781 * Resume callback. 782 * 783 * @param pDev Pointer to the platform device. 784 */ 785 static int VBoxDrvResume(struct platform_device *pDev) 786 { 787 RTPowerSignalEvent(RTPOWEREVENT_RESUME); 788 return 0; 789 } 790 #endif /* VBOX_WITH_SUSPEND_NOTIFICATION */ 691 791 692 792
Note:
See TracChangeset
for help on using the changeset viewer.