]>
Commit | Line | Data |
---|---|---|
1c79356b A |
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 | ||
0b4e3aa0 A |
94 | fMethods[kPMShutdownSystem].object = provider; // 5 |
95 | fMethods[kPMShutdownSystem].func = (IOMethod)&IOPMrootDomain::shutdownSystem; | |
96 | fMethods[kPMShutdownSystem].count0 = 0; | |
97 | fMethods[kPMShutdownSystem].count1 = 0; | |
98 | fMethods[kPMShutdownSystem].flags = kIOUCScalarIScalarO; | |
99 | ||
100 | fMethods[kPMRestartSystem].object = provider; // 6 | |
101 | fMethods[kPMRestartSystem].func = (IOMethod)&IOPMrootDomain::restartSystem; | |
102 | fMethods[kPMRestartSystem].count0 = 0; | |
103 | fMethods[kPMRestartSystem].count1 = 0; | |
104 | fMethods[kPMRestartSystem].flags = kIOUCScalarIScalarO; | |
105 | ||
1c79356b A |
106 | return true; |
107 | } | |
108 | ||
109 | ||
110 | IOReturn RootDomainUserClient::clientClose( void ) | |
111 | { | |
112 | detach( fOwner); | |
113 | ||
114 | return kIOReturnSuccess; | |
115 | } | |
116 | ||
117 | IOReturn RootDomainUserClient::clientDied( void ) | |
118 | { | |
119 | return( clientClose()); | |
120 | } | |
121 | ||
122 | IOExternalMethod * | |
123 | RootDomainUserClient::getExternalMethodForIndex( UInt32 index ) | |
124 | { | |
125 | if(index >= kNumPMMethods) | |
126 | return NULL; | |
127 | else | |
128 | return &fMethods[index]; | |
129 | } | |
130 | ||
131 | IOReturn | |
132 | RootDomainUserClient::registerNotificationPort( | |
133 | mach_port_t port, UInt32 type ) | |
134 | { | |
135 | return kIOReturnUnsupported; | |
136 | } | |
137 |