VirtualBox

Changeset 13939

Show
Ignore:
Timestamp:
11/06/08 22:24:12 (2 months ago)
Author:
vboxsync
Message:

siwtch to the older R0 notification mechanism

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/VBox/HostDrivers/Support/linux/SUPDrv-linux.c

    r13934 r13939  
    4949#include <iprt/mp.h> 
    5050 
     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 
    5157#include <linux/sched.h> 
    5258#ifdef CONFIG_DEVFS_FS 
     
    6167#  include <asm/nmi.h> 
    6268# endif 
     69#endif 
     70#ifdef VBOX_WITH_SUSPEND_NOTIFICATION 
     71# include <linux/platform_device.h> 
    6372#endif 
    6473 
     
    218227*   Internal Functions                                                         * 
    219228*******************************************************************************/ 
    220 static int      VBoxDrvLinuxInit(void); 
    221 static void     VBoxDrvLinuxUnload(void); 
    222 static int      VBoxDrvLinuxCreate(struct inode *pInode, struct file *pFilp); 
    223 static int      VBoxDrvLinuxClose(struct inode *pInode, struct file *pFilp); 
     229static int  VBoxDrvLinuxInit(void); 
     230static void VBoxDrvLinuxUnload(void); 
     231static int  VBoxDrvLinuxCreate(struct inode *pInode, struct file *pFilp); 
     232static int  VBoxDrvLinuxClose(struct inode *pInode, struct file *pFilp); 
    224233#ifdef HAVE_UNLOCKED_IOCTL 
    225 static long     VBoxDrvLinuxIOCtl(struct file *pFilp, unsigned int uCmd, unsigned long ulArg); 
     234static long VBoxDrvLinuxIOCtl(struct file *pFilp, unsigned int uCmd, unsigned long ulArg); 
    226235#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  
     236static int  VBoxDrvLinuxIOCtl(struct inode *pInode, struct file *pFilp, unsigned int uCmd, unsigned long ulArg); 
     237#endif 
     238static int  VBoxDrvLinuxIOCtlSlow(struct file *pFilp, unsigned int uCmd, unsigned long ulArg); 
     239static int  VBoxDrvLinuxErr2LinuxErr(int); 
     240#ifdef VBOX_WITH_SUSPEND_NOTIFICATION 
     241static int  VBoxDrvProbe(struct platform_device *pDev); 
     242static int  VBoxDrvSuspend(struct platform_device *pDev, pm_message_t State); 
     243static int  VBoxDrvResume(struct platform_device *pDev); 
     244static void VBoxDevRelease(struct device *pDev); 
     245#endif 
    232246 
    233247/** The file_operations structure. */ 
     
    259273 
    260274 
     275#ifdef VBOX_WITH_SUSPEND_NOTIFICATION 
     276static 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 
     288static struct platform_device gPlatformDevice = 
     289{ 
     290    .name = "vboxdrv", 
     291    .dev = 
     292    { 
     293        .release = VBoxDevRelease 
     294    } 
     295}; 
     296#endif /* VBOX_WITH_SUSPEND_NOTIFICATION */ 
    261297 
    262298 
     
    556592            if (RT_SUCCESS(rc)) 
    557593                rc = supdrvInitDevExt(&g_DevExt); 
    558             if (!rc
     594            if (RT_SUCCESS(rc)
    559595            { 
    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 " 
    561605#ifdef VBOX_HRTIMER 
    562                        "'high-res'" 
     606                               "'high-res'" 
    563607#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 
    572622            } 
    573623 
     
    605655    NOREF(rc); 
    606656 
     657#ifdef VBOX_WITH_SUSPEND_NOTIFICATION 
     658    platform_device_unregister(&gPlatformDevice); 
     659    platform_driver_unregister(&gPlatformDriver); 
     660#endif 
     661 
    607662    /* 
    608663     * I Don't think it's possible to unload a driver which processes have 
     
    689744    return 0; 
    690745} 
     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 */ 
     755static void VBoxDevRelease(struct device *pDev) 
     756{ 
     757} 
     758 
     759/** 
     760 * Dummy probe function. 
     761 * 
     762 * @param   pDev        Pointer to the platform device. 
     763 */ 
     764static 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 */ 
     774static 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 */ 
     785static int VBoxDrvResume(struct platform_device *pDev) 
     786{ 
     787    RTPowerSignalEvent(RTPOWEREVENT_RESUME); 
     788    return 0; 
     789} 
     790#endif /* VBOX_WITH_SUSPEND_NOTIFICATION */ 
    691791 
    692792 

© 2008 Sun Microsystems, Inc.
ContactPrivacy policy