VirtualBox

Changeset 15041 in vbox


Ignore:
Timestamp:
Dec 5, 2008 1:30:33 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
40420
Message:

SUPDrv-OSX: added ring 0 sleep notification

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/Support/darwin/SUPDrv-darwin.cpp

    r15003 r15041  
    5454#include <iprt/process.h>
    5555#include <iprt/alloc.h>
     56#include <iprt/power.h>
    5657#include <VBox/err.h>
    5758#include <VBox/log.h>
     
    6667#include <IOKit/IOService.h>
    6768#include <IOKit/IOUserclient.h>
     69#include <IOKit/pwr_mgt/RootDomain.h>
    6870
    6971
     
    9092
    9193static int              VBoxDrvDarwinErr2DarwinErr(int rc);
     94
     95static IOReturn         VBoxDrvDarwinSleepHandler(void *pvTarget, void *pvRefCon, UInt32 uMessageType, IOService *pProvider, void *pvMessageArgument, vm_size_t argSize);
    9296__END_DECLS
    9397
     
    202206/** The number of open sessions. */
    203207static int32_t volatile g_cSessions = 0;
     208/** The notifier handle for the sleep callback handler. */
     209static IONotifier *g_pSleepNotifier = NULL;
    204210
    205211
     
    251257                        LogRel(("VBoxDrv: version " VBOX_VERSION_STRING " r%d; IOCtl version %#x; IDC version %#x; dev major=%d\n",
    252258                                VBOX_SVN_REV, SUPDRV_IOC_VERSION, SUPDRV_IDC_VERSION, g_iMajorDeviceNo));
     259
     260/* Bird: please acknowledge! */
     261#if 0
     262                        /* Register a sleep/wakeup notification callback */
     263                        void *pvData = NULL;
     264                        g_pSleepNotifier = registerPrioritySleepWakeInterest(&VBoxDrvDarwinSleepHandler, pvData, NULL);
     265                        if (g_pSleepNotifier == NULL)
     266                            LogRel(("VBoxDrv: register for sleep/wakeup events failed\n"));
     267#endif
     268
    253269                        return KMOD_RETURN_SUCCESS;
    254270                    }
     
    293309     * Undo the work done during start (in reverse order).
    294310     */
     311    if (g_pSleepNotifier)
     312    {
     313        g_pSleepNotifier->remove();
     314        g_pSleepNotifier = NULL;
     315    }
     316
    295317    devfs_remove(g_hDevFsDevice);
    296318    g_hDevFsDevice = NULL;
     
    658680    NOREF(prc);
    659681    return false;
     682}
     683
     684IOReturn VBoxDrvDarwinSleepHandler(void * /* pvTarget */, void *pvRefCon, UInt32 uMessageType, IOService * /* pProvider */, void * /* pvMessageArgument */, vm_size_t /* argSize */)
     685{
     686    /* IOLog("VBoxDrv: Got sleep/wake notice. Message type was %X\n", (uint)uMessageType); */
     687
     688    if (uMessageType == kIOMessageSystemWillSleep)
     689        RTPowerSignalEvent(RTPOWEREVENT_SUSPEND);
     690    else if (uMessageType == kIOMessageSystemHasPoweredOn)
     691        RTPowerSignalEvent(RTPOWEREVENT_RESUME);
     692
     693    acknowledgeSleepWakeNotification(pvRefCon);
     694
     695    return 0;
    660696}
    661697
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette