]> git.saurik.com Git - apple/xnu.git/blob - iokit/Drivers/platform/drvAppleRootDomain/RootDomainUserClient.cpp
598cbaf9a58c3d697695db11cc0a69621104bbbd
[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 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
11 *
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
18 * under the License.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22 /*
23 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
24 *
25 */
26
27 #include <IOKit/assert.h>
28 #include <IOKit/IOLib.h>
29 #include <IOKit/IOBufferMemoryDescriptor.h>
30 #include "RootDomainUserClient.h"
31 #include <IOKit/pwr_mgt/IOPMLibDefs.h>
32
33 #define super IOUserClient
34
35 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
36
37 OSDefineMetaClassAndStructors(RootDomainUserClient, IOUserClient)
38
39 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
40
41 RootDomainUserClient *RootDomainUserClient::withTask(task_t owningTask)
42 {
43 RootDomainUserClient *me;
44
45 me = new RootDomainUserClient;
46 if(me) {
47 if(!me->init()) {
48 me->release();
49 return NULL;
50 }
51 me->fTask = owningTask;
52 }
53 return me;
54 }
55
56 bool RootDomainUserClient::start( IOService * provider )
57 {
58 assert(OSDynamicCast(IOPMrootDomain, provider));
59 if(!super::start(provider))
60 return false;
61 fOwner = (IOPMrootDomain *)provider;
62
63 // Got the owner, so initialize the call structures
64 fMethods[kPMSetAggressiveness].object = provider; // 0
65 fMethods[kPMSetAggressiveness].func = (IOMethod)&IOPMrootDomain::setAggressiveness;
66 fMethods[kPMSetAggressiveness].count0 = 2;
67 fMethods[kPMSetAggressiveness].count1 = 0;
68 fMethods[kPMSetAggressiveness].flags = kIOUCScalarIScalarO;
69
70 fMethods[kPMGetAggressiveness].object = provider; // 1
71 fMethods[kPMGetAggressiveness].func = (IOMethod)&IOPMrootDomain::getAggressiveness;
72 fMethods[kPMGetAggressiveness].count0 = 1;
73 fMethods[kPMGetAggressiveness].count1 = 1;
74 fMethods[kPMGetAggressiveness].flags = kIOUCScalarIScalarO;
75
76 fMethods[kPMSleepSystem].object = provider; // 2
77 fMethods[kPMSleepSystem].func = (IOMethod)&IOPMrootDomain::sleepSystem;
78 fMethods[kPMSleepSystem].count0 = 0;
79 fMethods[kPMSleepSystem].count1 = 0;
80 fMethods[kPMSleepSystem].flags = kIOUCScalarIScalarO;
81
82 fMethods[kPMAllowPowerChange].object = provider; // 3
83 fMethods[kPMAllowPowerChange].func = (IOMethod)&IOPMrootDomain::allowPowerChange;
84 fMethods[kPMAllowPowerChange].count0 = 1;
85 fMethods[kPMAllowPowerChange].count1 = 0;
86 fMethods[kPMAllowPowerChange].flags = kIOUCScalarIScalarO;
87
88 fMethods[kPMCancelPowerChange].object = provider; // 4
89 fMethods[kPMCancelPowerChange].func = (IOMethod)&IOPMrootDomain::cancelPowerChange;
90 fMethods[kPMCancelPowerChange].count0 = 1;
91 fMethods[kPMCancelPowerChange].count1 = 0;
92 fMethods[kPMCancelPowerChange].flags = kIOUCScalarIScalarO;
93
94 return true;
95 }
96
97
98 IOReturn RootDomainUserClient::clientClose( void )
99 {
100 detach( fOwner);
101
102 return kIOReturnSuccess;
103 }
104
105 IOReturn RootDomainUserClient::clientDied( void )
106 {
107 return( clientClose());
108 }
109
110 IOExternalMethod *
111 RootDomainUserClient::getExternalMethodForIndex( UInt32 index )
112 {
113 if(index >= kNumPMMethods)
114 return NULL;
115 else
116 return &fMethods[index];
117 }
118
119 IOReturn
120 RootDomainUserClient::registerNotificationPort(
121 mach_port_t port, UInt32 type )
122 {
123 return kIOReturnUnsupported;
124 }
125