Loading...
--- xnu/xnu-792/iokit/Kernel/IOPMrootDomain.cpp
+++ xnu/xnu-792.6.22/iokit/Kernel/IOPMrootDomain.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1998-2005 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
@@ -33,40 +33,11 @@
#include "IOKit/pwr_mgt/IOPowerConnection.h"
#include "IOPMPowerStateQueue.h"
#include <IOKit/IOCatalogue.h>
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-
-
-#include <IOKit/IOPolledInterface.h>
-
-OSDefineMetaClassAndAbstractStructors(IOPolledInterface, OSObject);
-
-OSMetaClassDefineReservedUnused(IOPolledInterface, 0);
-OSMetaClassDefineReservedUnused(IOPolledInterface, 1);
-OSMetaClassDefineReservedUnused(IOPolledInterface, 2);
-OSMetaClassDefineReservedUnused(IOPolledInterface, 3);
-OSMetaClassDefineReservedUnused(IOPolledInterface, 4);
-OSMetaClassDefineReservedUnused(IOPolledInterface, 5);
-OSMetaClassDefineReservedUnused(IOPolledInterface, 6);
-OSMetaClassDefineReservedUnused(IOPolledInterface, 7);
-OSMetaClassDefineReservedUnused(IOPolledInterface, 8);
-OSMetaClassDefineReservedUnused(IOPolledInterface, 9);
-OSMetaClassDefineReservedUnused(IOPolledInterface, 10);
-OSMetaClassDefineReservedUnused(IOPolledInterface, 11);
-OSMetaClassDefineReservedUnused(IOPolledInterface, 12);
-OSMetaClassDefineReservedUnused(IOPolledInterface, 13);
-OSMetaClassDefineReservedUnused(IOPolledInterface, 14);
-OSMetaClassDefineReservedUnused(IOPolledInterface, 15);
-
-IOReturn
-IOPolledInterface::checkAllForWork(void)
-{
- return (kIOReturnSuccess);
-}
-
-
-/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-
+#include <IOKit/IOHibernatePrivate.h>
+
+#ifdef __ppc__
+#include <ppc/pms.h>
+#endif
extern "C" void kprintf(const char *, ...);
@@ -217,6 +188,7 @@
IOService *rootDomain = (IOService *) p0;
unsigned long pmRef = (unsigned long) p1;
+ IOHibernateSystemSleep();
sync_internal();
rootDomain->allowPowerChange(pmRef);
}
@@ -314,6 +286,7 @@
temp_entry->release();
}
+ IOHibernateSystemInit(this);
registerService(); // let clients find us
@@ -353,6 +326,10 @@
const OSSymbol *fileserver_string = OSSymbol::withCString("AutoRestartOnPowerLoss");
const OSSymbol *wakeonlid_string = OSSymbol::withCString("WakeOnLid");
const OSSymbol *wakeonac_string = OSSymbol::withCString("WakeOnACChange");
+ const OSSymbol *hibernatemode_string = OSSymbol::withCString(kIOHibernateModeKey);
+ const OSSymbol *hibernatefile_string = OSSymbol::withCString(kIOHibernateFileKey);
+ const OSSymbol *hibernatefreeratio_string = OSSymbol::withCString(kIOHibernateFreeRatioKey);
+ const OSSymbol *hibernatefreetime_string = OSSymbol::withCString(kIOHibernateFreeTimeKey);
const OSSymbol *timezone_string = OSSymbol::withCString("TimeZoneOffsetSeconds");
if(!dict)
@@ -381,6 +358,26 @@
setProperty(stall_halt_string, b);
}
+ if ( hibernatemode_string
+ && (n = OSDynamicCast(OSNumber, dict->getObject(hibernatemode_string))))
+ {
+ setProperty(hibernatemode_string, n);
+ }
+ if ( hibernatefreeratio_string
+ && (n = OSDynamicCast(OSNumber, dict->getObject(hibernatefreeratio_string))))
+ {
+ setProperty(hibernatefreeratio_string, n);
+ }
+ if ( hibernatefreetime_string
+ && (n = OSDynamicCast(OSNumber, dict->getObject(hibernatefreetime_string))))
+ {
+ setProperty(hibernatefreetime_string, n);
+ }
+ if ( hibernatefile_string
+ && (str = OSDynamicCast(OSString, dict->getObject(hibernatefile_string))))
+ {
+ setProperty(hibernatefile_string, str);
+ }
// Relay AutoWake setting to its controller
if( auto_wake_string
@@ -582,8 +579,24 @@
// same thread.
//*********************************************************************************
+static int pmsallsetup = 0;
+
IOReturn IOPMrootDomain::setAggressiveness ( unsigned long type, unsigned long newLevel )
{
+#ifdef __ppc__
+ if(pmsExperimental & 3) kprintf("setAggressiveness: type = %08X, newlevel = %08X\n", type, newLevel);
+ if(pmsExperimental & 1) { /* Is experimental mode enabled? */
+ if(pmsInstalled && (type == kPMSetProcessorSpeed)) { /* We want to look at all processor speed changes if stepper is installed */
+ if(pmsallsetup) return kIOReturnSuccess; /* If already running, just eat this */
+ kprintf("setAggressiveness: starting stepper...\n");
+ pmsallsetup = 1; /* Remember we did this */
+ pmsPark();
+ pmsStart(); /* Get it all started up... */
+ return kIOReturnSuccess; /* Leave now... */
+ }
+ }
+#endif
+
if ( pm_vars->PMcommandGate ) {
pm_vars->PMcommandGate->runAction(broadcast_aggressiveness,(void *)type,(void *)newLevel);
}
@@ -659,13 +672,17 @@
// re-enable this timer for next sleep
idleSleepPending = false;
- IOLog("System Sleep\n");
+ IOLog("System %sSleep\n", gIOHibernateState ? "Safe" : "");
+
+ IOHibernateSystemHasSlept();
+
pm_vars->thePlatform->sleepKernel();
// The CPU(s) are off at this point. When they're awakened by CPU interrupt,
// code will resume execution here.
// Now we're waking...
+ IOHibernateSystemWake();
// stay awake for at least 30 seconds
clock_interval_to_deadline(30, kSecondScale, &deadline);
@@ -690,7 +707,7 @@
tellClients(kIOMessageSystemWillPowerOn);
// tell the tree we're waking
- IOLog("System Wake\n");
+ IOLog("System %sWake\n", gIOHibernateState ? "SafeSleep " : "");
systemWake();
// Allow drivers to request extra processing time before clamshell
@@ -1118,6 +1135,7 @@
{
if ( stateNum == ON_STATE )
{
+ IOHibernateSystemPostWake();
return tellClients(kIOMessageSystemHasPoweredOn);
}
}
@@ -1217,6 +1235,8 @@
// We will ack within 20 seconds
params->returnValue = 20 * 1000 * 1000;
+ if (gIOHibernateState)
+ params->returnValue += gIOHibernateFreeTime * 1000; //add in time we could spend freeing pages
if ( ! OSCompareAndSwap( 0, 1, &gSleepOrShutdownPending ) )
{