]> git.saurik.com Git - apple/xnu.git/blob - iokit/Drivers/platform/drvAppleRootDomain/RootDomainUserClient.cpp
xnu-344.21.74.tar.gz
[apple/xnu.git] / iokit / Drivers / platform / drvAppleRootDomain / RootDomainUserClient.cpp
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 RootDomainUserClient *RootDomainUserClient::withTask(task_t owningTask)
45 {
46 RootDomainUserClient *me;
47
48 me = new RootDomainUserClient;
49 if(me) {
50 if(!me->init()) {
51 me->release();
52 return NULL;
53 }
54 me->fTask = owningTask;
55 }
56 return me;
57 }
58
59 bool RootDomainUserClient::start( IOService * provider )
60 {
61 assert(OSDynamicCast(IOPMrootDomain, provider));
62 if(!super::start(provider))
63 return false;
64 fOwner = (IOPMrootDomain *)provider;
65
66 // Got the owner, so initialize the call structures
67 fMethods[kPMSetAggressiveness].object = provider; // 0
68 fMethods[kPMSetAggressiveness].func = (IOMethod)&IOPMrootDomain::setAggressiveness;
69 fMethods[kPMSetAggressiveness].count0 = 2;
70 fMethods[kPMSetAggressiveness].count1 = 0;
71 fMethods[kPMSetAggressiveness].flags = kIOUCScalarIScalarO;
72
73 fMethods[kPMGetAggressiveness].object = provider; // 1
74 fMethods[kPMGetAggressiveness].func = (IOMethod)&IOPMrootDomain::getAggressiveness;
75 fMethods[kPMGetAggressiveness].count0 = 1;
76 fMethods[kPMGetAggressiveness].count1 = 1;
77 fMethods[kPMGetAggressiveness].flags = kIOUCScalarIScalarO;
78
79 fMethods[kPMSleepSystem].object = provider; // 2
80 fMethods[kPMSleepSystem].func = (IOMethod)&IOPMrootDomain::sleepSystem;
81 fMethods[kPMSleepSystem].count0 = 0;
82 fMethods[kPMSleepSystem].count1 = 0;
83 fMethods[kPMSleepSystem].flags = kIOUCScalarIScalarO;
84
85 fMethods[kPMAllowPowerChange].object = provider; // 3
86 fMethods[kPMAllowPowerChange].func = (IOMethod)&IOPMrootDomain::allowPowerChange;
87 fMethods[kPMAllowPowerChange].count0 = 1;
88 fMethods[kPMAllowPowerChange].count1 = 0;
89 fMethods[kPMAllowPowerChange].flags = kIOUCScalarIScalarO;
90
91 fMethods[kPMCancelPowerChange].object = provider; // 4
92 fMethods[kPMCancelPowerChange].func = (IOMethod)&IOPMrootDomain::cancelPowerChange;
93 fMethods[kPMCancelPowerChange].count0 = 1;
94 fMethods[kPMCancelPowerChange].count1 = 0;
95 fMethods[kPMCancelPowerChange].flags = kIOUCScalarIScalarO;
96
97 fMethods[kPMShutdownSystem].object = provider; // 5
98 fMethods[kPMShutdownSystem].func = (IOMethod)&IOPMrootDomain::shutdownSystem;
99 fMethods[kPMShutdownSystem].count0 = 0;
100 fMethods[kPMShutdownSystem].count1 = 0;
101 fMethods[kPMShutdownSystem].flags = kIOUCScalarIScalarO;
102
103 fMethods[kPMRestartSystem].object = provider; // 6
104 fMethods[kPMRestartSystem].func = (IOMethod)&IOPMrootDomain::restartSystem;
105 fMethods[kPMRestartSystem].count0 = 0;
106 fMethods[kPMRestartSystem].count1 = 0;
107 fMethods[kPMRestartSystem].flags = kIOUCScalarIScalarO;
108
109 return true;
110 }
111
112
113 IOReturn RootDomainUserClient::clientClose( void )
114 {
115 detach( fOwner);
116
117 return kIOReturnSuccess;
118 }
119
120 IOReturn RootDomainUserClient::clientDied( void )
121 {
122 return( clientClose());
123 }
124
125 IOExternalMethod *
126 RootDomainUserClient::getExternalMethodForIndex( UInt32 index )
127 {
128 if(index >= kNumPMMethods)
129 return NULL;
130 else
131 return &fMethods[index];
132 }
133
134 IOReturn
135 RootDomainUserClient::registerNotificationPort(
136 mach_port_t port, UInt32 type )
137 {
138 return kIOReturnUnsupported;
139 }
140