X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/39236c6e673c41db228275375ab7fdb0f837b292..a1c7dba18ef36983396c282fe85292db066e39db:/iokit/Kernel/RootDomainUserClient.cpp diff --git a/iokit/Kernel/RootDomainUserClient.cpp b/iokit/Kernel/RootDomainUserClient.cpp index cfc365b51..ae122f4c1 100644 --- a/iokit/Kernel/RootDomainUserClient.cpp +++ b/iokit/Kernel/RootDomainUserClient.cpp @@ -47,17 +47,17 @@ OSDefineMetaClassAndStructors(RootDomainUserClient, IOUserClient) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -bool RootDomainUserClient::initWithTask(task_t owningTask, void *security_id, - UInt32 type, OSDictionary * properties) +bool RootDomainUserClient::initWithTask(task_t owningTask, void *security_id, + UInt32 type, OSDictionary * properties) { if (properties) - properties->setObject(kIOUserClientCrossEndianCompatibleKey, kOSBooleanTrue); + properties->setObject(kIOUserClientCrossEndianCompatibleKey, kOSBooleanTrue); if (!super::initWithTask(owningTask, security_id, type, properties)) - return false; + return false; fOwningTask = owningTask; - task_reference (fOwningTask); + task_reference (fOwningTask); return true; } @@ -78,8 +78,8 @@ IOReturn RootDomainUserClient::secureSleepSystem( uint32_t *return_code ) return secureSleepSystemOptions(NULL, 0, return_code); } -IOReturn RootDomainUserClient::secureSleepSystemOptions( - const void *inOptions, +IOReturn RootDomainUserClient::secureSleepSystemOptions( + const void *inOptions, IOByteCount inOptionsSize, uint32_t *returnCode) { @@ -92,18 +92,18 @@ IOReturn RootDomainUserClient::secureSleepSystemOptions( ret = clientHasPrivilege(fOwningTask, kIOClientPrivilegeLocalUser); local_priv = (kIOReturnSuccess == ret); - + ret = clientHasPrivilege(fOwningTask, kIOClientPrivilegeAdministrator); admin_priv = (kIOReturnSuccess == ret); - - + + if (inOptions) { unserializedOptions = OSDynamicCast( OSDictionary, OSUnserializeXML((const char *)inOptions, inOptionsSize, &unserializeErrorString)); - + if (!unserializedOptions) { - IOLog("IOPMRootDomain SleepSystem unserialization failure: %s\n", + IOLog("IOPMRootDomain SleepSystem unserialization failure: %s\n", unserializeErrorString ? unserializeErrorString->getCStringNoCopy() : "Unknown"); } } @@ -115,21 +115,21 @@ IOReturn RootDomainUserClient::secureSleepSystemOptions( if (p) { fOwner->setProperty("SleepRequestedByPID", proc_pid(p), 32); } - - if (unserializedOptions) + + if (unserializedOptions) { // Publish Sleep Options in registry under root_domain - fOwner->setProperty( kRootDomainSleepOptionsKey, unserializedOptions); + fOwner->setProperty( kRootDomainSleepOptionsKey, unserializedOptions); *returnCode = fOwner->sleepSystemOptions( unserializedOptions ); - unserializedOptions->release(); + unserializedOptions->release(); } else { // No options // Clear any pre-existing options fOwner->removeProperty( kRootDomainSleepOptionsKey ); - *returnCode = fOwner->sleepSystemOptions( NULL ); + *returnCode = fOwner->sleepSystemOptions( NULL ); } } else { @@ -139,7 +139,7 @@ IOReturn RootDomainUserClient::secureSleepSystemOptions( return kIOReturnSuccess; } -IOReturn RootDomainUserClient::secureSetAggressiveness( +IOReturn RootDomainUserClient::secureSetAggressiveness( unsigned long type, unsigned long newLevel, int *return_code ) @@ -150,7 +150,7 @@ IOReturn RootDomainUserClient::secureSetAggressiveness( ret = clientHasPrivilege(fOwningTask, kIOClientPrivilegeLocalUser); local_priv = (kIOReturnSuccess == ret); - + ret = clientHasPrivilege(fOwningTask, kIOClientPrivilegeAdministrator); admin_priv = (kIOReturnSuccess == ret); @@ -168,7 +168,7 @@ IOReturn RootDomainUserClient::secureSetMaintenanceWakeCalendar( { int admin_priv = 0; IOReturn ret = kIOReturnNotPrivileged; - + ret = clientHasPrivilege(fOwningTask, kIOClientPrivilegeAdministrator); admin_priv = (kIOReturnSuccess == ret); @@ -185,7 +185,7 @@ IOReturn RootDomainUserClient::secureSetUserAssertionLevels( { int admin_priv = 0; IOReturn ret = kIOReturnNotPrivileged; - + ret = clientHasPrivilege(fOwningTask, kIOClientPrivilegeAdministrator); admin_priv = (kIOReturnSuccess == ret); @@ -217,47 +217,24 @@ IOReturn RootDomainUserClient::secureGetSystemSleepType( IOReturn RootDomainUserClient::clientClose( void ) { detach(fOwner); - + if(fOwningTask) { task_deallocate(fOwningTask); fOwningTask = 0; - } - - return kIOReturnSuccess; -} - -IOReturn RootDomainUserClient::clientMemoryForType( - UInt32 type, - IOOptionBits *options, - IOMemoryDescriptor ** memory) -{ - if (!fOwner) - return kIOReturnNotReady; - - if (kPMRootDomainMapTraceBuffer == type) - { - *memory = fOwner->getPMTraceMemoryDescriptor(); - if (*memory) { - (*memory)->retain(); - *options = 0; - return kIOReturnSuccess; - } else { - return kIOReturnNotFound; - } - } - return kIOReturnUnsupported; + + return kIOReturnSuccess; } IOReturn RootDomainUserClient::externalMethod( - uint32_t selector, + uint32_t selector, IOExternalMethodArguments * arguments, - IOExternalMethodDispatch * dispatch __unused, + IOExternalMethodDispatch * dispatch __unused, OSObject * target __unused, void * reference __unused ) { - IOReturn ret = kIOReturnBadArgument; - + IOReturn ret = kIOReturnBadArgument; + switch (selector) { case kPMSetAggressiveness: @@ -270,7 +247,7 @@ IOReturn RootDomainUserClient::externalMethod( (int *)&arguments->scalarOutput[0]); } break; - + case kPMGetAggressiveness: if ((1 == arguments->scalarInputCount) && (1 == arguments->scalarOutputCount)) @@ -280,12 +257,12 @@ IOReturn RootDomainUserClient::externalMethod( (unsigned long *)&arguments->scalarOutput[0]); } break; - + case kPMSleepSystem: if (1 == arguments->scalarOutputCount) { ret = this->secureSleepSystem( - (uint32_t *)&arguments->scalarOutput[0]); + (uint32_t *)&arguments->scalarOutput[0]); } break; @@ -323,16 +300,16 @@ IOReturn RootDomainUserClient::externalMethod( break; case kPMSetMaintenanceWakeCalendar: ret = this->secureSetMaintenanceWakeCalendar( - (IOPMCalendarStruct *)arguments->structureInput, + (IOPMCalendarStruct *)arguments->structureInput, (uint32_t *)&arguments->structureOutput); arguments->structureOutputSize = sizeof(uint32_t); break; - + case kPMSetUserAssertionLevels: ret = this->secureSetUserAssertionLevels( (uint32_t)arguments->scalarInput[0]); break; - + case kPMActivityTickle: if ( fOwner->checkSystemCanSustainFullWake() ) { @@ -355,6 +332,7 @@ IOReturn RootDomainUserClient::externalMethod( } break; +#if defined(__i386__) || defined(__x86_64__) case kPMSleepWakeWatchdogEnable: ret = clientHasPrivilege(fOwningTask, kIOClientPrivilegeAdministrator); if (ret == kIOReturnSuccess) @@ -367,6 +345,7 @@ IOReturn RootDomainUserClient::externalMethod( if (ret == kIOReturnSuccess) fOwner->sleepWakeDebugTrig(false); break; +#endif case kPMSetDisplayPowerOn: if (1 == arguments->scalarInputCount) @@ -376,55 +355,7 @@ IOReturn RootDomainUserClient::externalMethod( fOwner->setDisplayPowerOn((uint32_t)arguments->scalarInput[0]); } break; -/* - case kPMMethodCopySystemTimeline: - // intentional fallthrough - case kPMMethodCopyDetailedTimeline: - if (!arguments->structureOutputDescriptor) - { - // TODO: Force IOKit.framework to always send this data out - // of line; so I don't have to create a MemoryDescriptor here. - mem_size = arguments->structureOutputSize; - mem = IOMemoryDescriptor::withAddressRange( - (mach_vm_address_t)arguments->structureOutput, - (mach_vm_size_t)mem_size, - kIODirectionIn, current_task()); - } else { - mem_size = arguments->structureOutputDescriptorSize; - if (( mem = arguments->structureOutputDescriptor )) - mem->retain(); - } - - if (mem) - { - mem->prepare(kIODirectionNone); - - if (kPMMethodCopySystemTimeline == selector) { - arguments->scalarOutput[0] = fOwner->copySystemTimeline( - mem, &mem_size); - } - else - if (kPMMethodCopyDetailedTimeline == selector) { - arguments->scalarOutput[0] = fOwner->copyDetailedTimeline( - mem, &mem_size); - } - - if (arguments->structureOutputDescriptor) { - arguments->structureOutputDescriptorSize = mem_size; - } else { - arguments->structureOutputSize = mem_size; - } - - mem->release(); - - ret = kIOReturnSuccess; - } else { - ret = kIOReturnCannotWire; - } - - break; -*/ default: // bad selector return kIOReturnBadArgument; @@ -438,7 +369,7 @@ IOReturn RootDomainUserClient::externalMethod( * We maintain getTargetAndExternalMethod since it's an exported symbol, * and only for that reason. */ -IOExternalMethod * RootDomainUserClient::getTargetAndMethodForIndex( +IOExternalMethod * RootDomainUserClient::getTargetAndMethodForIndex( IOService ** targetP, UInt32 index ) { // DO NOT EDIT @@ -448,6 +379,6 @@ IOExternalMethod * RootDomainUserClient::getTargetAndMethodForIndex( /* setPreventative * Does nothing. Exists only for exported symbol compatibility. */ -void +void RootDomainUserClient::setPreventative(UInt32 on_off, UInt32 types_of_sleep) { return; } // DO NOT EDIT