1 /* 2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved. 3 * 4 * @APPLE_LICENSE_HEADER_START@ 5 * 6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. 7 * 8 * This file contains Original Code and/or Modifications of Original Code 9 * as defined in and that are subject to the Apple Public Source License 10 * Version 2.0 (the 'License'). You may not use this file except in 11 * compliance with the License. Please obtain a copy of the License at 12 * http://www.opensource.apple.com/apsl/ and read it before using this 13 * file. 14 * 15 * The Original Code and all software distributed under the License are 16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 20 * Please see the License for the specific language governing rights and 21 * limitations under the License. 22 * 23 * @APPLE_LICENSE_HEADER_END@ 24 */ 25 /* 26 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. 27 * 28 */ 29 30 #include <IOKit/assert.h> 31 #include <IOKit/IOLib.h> 32 #include <IOKit/IOBufferMemoryDescriptor.h> 33 #include "RootDomainUserClient.h" 34 #include <IOKit/pwr_mgt/IOPMLibDefs.h> 35 36 #define super IOUserClient 37 38 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 39 40 OSDefineMetaClassAndStructors(RootDomainUserClient, IOUserClient) 41 42 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 43 44 bool RootDomainUserClient::start( IOService * provider ) 45 { 46 assert(OSDynamicCast(IOPMrootDomain, provider)); 47 if(!super::start(provider)) 48 return false; 49 fOwner = (IOPMrootDomain *)provider; 50 51 52 return true; 53 } 54 55 56 IOReturn RootDomainUserClient::clientClose( void ) 57 { 58 detach(fOwner); 59 return kIOReturnSuccess; 60 } 61 62 IOExternalMethod * 63 RootDomainUserClient::getTargetAndMethodForIndex( IOService ** targetP, UInt32 index ) 64 { 65 static IOExternalMethod sMethods[] = { 66 { // kPMSetAggressiveness, 0 67 0, (IOMethod)&IOPMrootDomain::setAggressiveness, kIOUCScalarIScalarO, 2, 0 68 }, 69 { // kPMGetAggressiveness, 1 70 0, (IOMethod)&IOPMrootDomain::getAggressiveness, kIOUCScalarIScalarO, 1, 1 71 }, 72 { // kPMSleepSystem, 2 73 0, (IOMethod)&IOPMrootDomain::sleepSystem, kIOUCScalarIScalarO, 0, 0 74 }, 75 { // kPMAllowPowerChange, 3 76 0, (IOMethod)&IOPMrootDomain::allowPowerChange, kIOUCScalarIScalarO, 1, 0 77 }, 78 { // kPMCancelPowerChange, 4 79 0, (IOMethod)&IOPMrootDomain::cancelPowerChange, kIOUCScalarIScalarO, 1, 0 80 }, 81 { // kPMShutdownSystem, 5 82 0, (IOMethod)&IOPMrootDomain::shutdownSystem, kIOUCScalarIScalarO, 0, 0 83 }, 84 { // kPMRestartSystem, 6 85 0, (IOMethod)&IOPMrootDomain::restartSystem, kIOUCScalarIScalarO, 0, 0 86 }, 87 { // kPMSetPreventative, 7 88 1, (IOMethod) &RootDomainUserClient::setPreventative, kIOUCScalarIScalarO, 2, 0 89 }, 90 }; 91 92 if(index >= kNumPMMethods) 93 return NULL; 94 else { 95 if (sMethods[index].object) 96 *targetP = this; 97 else 98 *targetP = fOwner; 99 100 return &sMethods[index]; 101 } 102 } 103 104 void 105 RootDomainUserClient::setPreventative(UInt32 on_off, UInt32 types_of_sleep) 106 { 107 return; 108 } 109 110