X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/6d2010ae8f7a6078e10b361c6962983bab233e0f..22ba694c5857e62b5a553b1505dcf2e509177f28:/iokit/Kernel/RootDomainUserClient.cpp diff --git a/iokit/Kernel/RootDomainUserClient.cpp b/iokit/Kernel/RootDomainUserClient.cpp index 29c90deef..cfc365b51 100644 --- a/iokit/Kernel/RootDomainUserClient.cpp +++ b/iokit/Kernel/RootDomainUserClient.cpp @@ -1,5 +1,5 @@ /* - * 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@ * @@ -36,6 +36,8 @@ #include #include "RootDomainUserClient.h" #include +#include +#include #define super IOUserClient @@ -78,7 +80,7 @@ IOReturn RootDomainUserClient::secureSleepSystem( uint32_t *return_code ) IOReturn RootDomainUserClient::secureSleepSystemOptions( const void *inOptions, - IOByteCount inOptionsSize __unused, + IOByteCount inOptionsSize, uint32_t *returnCode) { @@ -98,7 +100,7 @@ IOReturn RootDomainUserClient::secureSleepSystemOptions( 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", @@ -106,9 +108,14 @@ IOReturn RootDomainUserClient::secureSleepSystemOptions( } } - 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 @@ -190,6 +197,23 @@ IOReturn RootDomainUserClient::secureSetUserAssertionLevels( 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); @@ -309,6 +333,49 @@ IOReturn RootDomainUserClient::externalMethod( (uint32_t)arguments->scalarInput[0]); break; + case kPMActivityTickle: + 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