]> git.saurik.com Git - apple/xnu.git/blobdiff - iokit/Kernel/IOPMrootDomain.cpp
xnu-3248.60.10.tar.gz
[apple/xnu.git] / iokit / Kernel / IOPMrootDomain.cpp
index a2762212863f3bb29974ac0314f860bbeaa61131..9a5ccd20bc70603c99d5d5892f873b2582dc82ef 100644 (file)
@@ -664,8 +664,19 @@ IOPMrootDomain * IOPMrootDomain::construct( void )
 //******************************************************************************
 
 static void updateConsoleUsersCallout(thread_call_param_t p0, thread_call_param_t p1)
+{
+    IOPMrootDomain * rootDomain = (IOPMrootDomain *) p0;
+    rootDomain->updateConsoleUsers();
+}
+
+void IOPMrootDomain::updateConsoleUsers(void)
 {
     IOService::updateConsoleUsers(NULL, kIOMessageSystemHasPoweredOn);
+    if (tasksSuspended)
+    {
+        tasksSuspended = FALSE;
+        tasks_system_suspend(tasksSuspended);
+    }
 }
 
 //******************************************************************************
@@ -824,12 +835,12 @@ static int
 sysctl_consoleoptions
 (__unused struct sysctl_oid *oidp, __unused void *arg1, __unused int arg2, struct sysctl_req *req)
 {
-    int error;
-    int new_value, changed;
+    int error, changed;
+    uint32_t new_value;
 
-    error = sysctl_io_number(req, vc_user_options, sizeof(int), &new_value, &changed);
+    error = sysctl_io_number(req, vc_user_options.options, sizeof(uint32_t), &new_value, &changed);
 
-    if (changed) vc_set_options(new_value);
+    if (changed) vc_user_options.options = new_value;
 
     return (error);
 }
@@ -838,6 +849,18 @@ static SYSCTL_PROC(_kern, OID_AUTO, consoleoptions,
         CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NOAUTO | CTLFLAG_KERN | CTLFLAG_LOCKED,
         0, 0, sysctl_consoleoptions, "I", "");
 
+
+static int
+sysctl_progressoptions SYSCTL_HANDLER_ARGS
+{
+    return sysctl_io_opaque(req, &vc_user_options, sizeof(vc_user_options), NULL);
+}
+
+static SYSCTL_PROC(_kern, OID_AUTO, progressoptions,
+        CTLTYPE_STRUCT | CTLFLAG_RW | CTLFLAG_NOAUTO | CTLFLAG_KERN | CTLFLAG_LOCKED | CTLFLAG_ANYBODY,
+        NULL, 0, sysctl_progressoptions, "S,vc_progress_user_options", "");
+
+
 static int
 sysctl_wakereason SYSCTL_HANDLER_ARGS
 {
@@ -1150,6 +1173,7 @@ bool IOPMrootDomain::start( IOService * nub )
     sysctl_register_oid(&sysctl__kern_progressmeter);
     sysctl_register_oid(&sysctl__kern_wakereason);
     sysctl_register_oid(&sysctl__kern_consoleoptions);
+    sysctl_register_oid(&sysctl__kern_progressoptions);
 
 #if HIBERNATION
     IOHibernateSystemInit(this);
@@ -3077,6 +3101,16 @@ void IOPMrootDomain::willNotifyPowerChildren( IOPMPowerStateIndex newPowerState
 
     if (SLEEP_STATE == newPowerState)
     {
+        if (!tasksSuspended)
+        {
+           AbsoluteTime deadline;
+           tasksSuspended = TRUE;
+           tasks_system_suspend(tasksSuspended);
+
+           clock_interval_to_deadline(10, kSecondScale, &deadline);
+           vm_pageout_wait(AbsoluteTime_to_scalar(&deadline));
+        }
+
 #if HIBERNATION
         IOHibernateSystemSleep();
         IOHibernateIOKitSleep();
@@ -5437,6 +5471,8 @@ IONotifier * IOPMrootDomain::registerInterest(
     if (rc != kIOReturnSuccess) {
         notifier->release();
         notifier = 0;
+
+        return NULL;
     }
     if (pmPowerStateQueue)
     {