/*
- * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1998-2012 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
#include <IOKit/IOBufferMemoryDescriptor.h>
#include "RootDomainUserClient.h"
#include <IOKit/pwr_mgt/IOPMLibDefs.h>
+#include <IOKit/pwr_mgt/IOPMPrivate.h>
+#include <sys/proc.h>
#define super IOUserClient
IOReturn RootDomainUserClient::secureSleepSystemOptions(
const void *inOptions,
- IOByteCount inOptionsSize __unused,
+ IOByteCount inOptionsSize,
uint32_t *returnCode)
{
if (inOptions)
{
unserializedOptions = OSDynamicCast( OSDictionary,
- OSUnserializeXML((const char *)inOptions, &unserializeErrorString));
+ OSUnserializeXML((const char *)inOptions, inOptionsSize, &unserializeErrorString));
if (!unserializedOptions) {
IOLog("IOPMRootDomain SleepSystem unserialization failure: %s\n",
}
}
- if ( (local_priv || admin_priv)
- && fOwner )
+ if ( (local_priv || admin_priv) && fOwner )
{
+ proc_t p;
+ p = (proc_t)get_bsdtask_info(fOwningTask);
+ if (p) {
+ fOwner->setProperty("SleepRequestedByPID", proc_pid(p), 32);
+ }
+
if (unserializedOptions)
{
// Publish Sleep Options in registry under root_domain
return kIOReturnSuccess;
}
+IOReturn RootDomainUserClient::secureGetSystemSleepType(
+ uint32_t *outSleepType)
+{
+ int admin_priv = 0;
+ IOReturn ret;
+
+ ret = clientHasPrivilege(fOwningTask, kIOClientPrivilegeAdministrator);
+ admin_priv = (kIOReturnSuccess == ret);
+
+ if (admin_priv && fOwner) {
+ ret = fOwner->getSystemSleepType(outSleepType);
+ } else {
+ ret = kIOReturnNotPrivileged;
+ }
+ return ret;
+}
+
IOReturn RootDomainUserClient::clientClose( void )
{
detach(fOwner);
break;
case kPMActivityTickle:
- fOwner->reportUserInput( );
+ if ( fOwner->checkSystemCanSustainFullWake() )
+ {
+ fOwner->reportUserInput( );
+ fOwner->setProperty(kIOPMRootDomainWakeTypeKey, "UserActivity Assertion");
+ }
ret = kIOReturnSuccess;
break;
-
+
+ case kPMSetClamshellSleepState:
+ fOwner->setDisableClamShellSleep(arguments->scalarInput[0] ? true : false);
+ ret = kIOReturnSuccess;
+ break;
+
+ case kPMGetSystemSleepType:
+ if (1 == arguments->scalarOutputCount)
+ {
+ ret = this->secureGetSystemSleepType(
+ (uint32_t *) &arguments->scalarOutput[0]);
+ }
+ break;
+
+ case kPMSleepWakeWatchdogEnable:
+ ret = clientHasPrivilege(fOwningTask, kIOClientPrivilegeAdministrator);
+ if (ret == kIOReturnSuccess)
+ fOwner->sleepWakeDebugEnableWdog();
+ break;
+
+
+ case kPMSleepWakeDebugTrig:
+ ret = clientHasPrivilege(fOwningTask, kIOClientPrivilegeAdministrator);
+ if (ret == kIOReturnSuccess)
+ fOwner->sleepWakeDebugTrig(false);
+ break;
+
+ case kPMSetDisplayPowerOn:
+ if (1 == arguments->scalarInputCount)
+ {
+ ret = clientHasPrivilege(fOwningTask, kIOClientPrivilegeAdministrator);
+ if (ret == kIOReturnSuccess)
+ fOwner->setDisplayPowerOn((uint32_t)arguments->scalarInput[0]);
+ }
+ break;
/*
case kPMMethodCopySystemTimeline:
// intentional fallthrough