]> git.saurik.com Git - apple/xnu.git/blob - iokit/Drivers/platform/drvAppleCuda/AppleCudaUserClient.cpp
366a04bd4a81e9d0c1f07880a2359d091163039f
[apple/xnu.git] / iokit / Drivers / platform / drvAppleCuda / AppleCudaUserClient.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 #include "AppleCudaUserClient.h"
23
24 #ifndef NULL
25 #define NULL 0
26 #endif
27
28 #define super IOUserClient
29
30 OSDefineMetaClassAndStructors(AppleCudaUserClient, IOUserClient)
31
32 AppleCudaUserClient*
33 AppleCudaUserClient::withTask(task_t owningTask)
34 {
35 AppleCudaUserClient *client;
36
37 client = new AppleCudaUserClient;
38 if (client != NULL) {
39 if (client->init() == false) {
40 client->release();
41 client = NULL;
42 }
43 }
44 if (client != NULL) {
45 client->fTask = owningTask;
46 }
47 return (client);
48 }
49
50 bool
51 AppleCudaUserClient::start(IOService *provider)
52 {
53 bool result = false;
54
55 theInterface = OSDynamicCast(AppleCuda, provider);
56
57 if (theInterface != NULL)
58 result = super::start(provider);
59 else
60 result = false;
61
62 if (result == false) {
63 IOLog("AppleCudaUserClient: provider start failed\n");
64 }
65
66 return (result);
67 }
68
69 IOReturn
70 AppleCudaUserClient::clientClose(void)
71 {
72 detach(theInterface);
73 return (kIOReturnSuccess);
74 }
75
76 IOReturn
77 AppleCudaUserClient::clientDied(void)
78 {
79 return (clientClose());
80 }
81
82 IOReturn
83 AppleCudaUserClient::connectClient(IOUserClient *client)
84 {
85 return (kIOReturnSuccess);
86 }
87
88 IOReturn
89 AppleCudaUserClient::registerNotificationPort(mach_port_t port, UInt32 type)
90 {
91 return (kIOReturnUnsupported);
92 }
93
94 // --------------------------------------------------------------------------
95 // Method: setProperties
96 //
97 // Purpose:
98 // sets the property from the dictionary to the airport properties.
99
100 IOReturn
101 AppleCudaUserClient::setProperties( OSObject * properties )
102 {
103 OSDictionary * dict;
104
105 dict = OSDynamicCast( OSDictionary, properties );
106 if ((dict) && (theInterface != NULL)) {
107 OSData *data;
108
109 // Sets the wake on ring:
110 if( (data = OSDynamicCast( OSData, dict->getObject("WakeOnRing")))) {
111 UInt8 myBool = *((UInt8*)data->getBytesNoCopy());
112 //theInterface->setWakeOnRing(myBool);
113
114 IOLog("AppleCudaUserClient::setProperties WakeOnRing %d\n", myBool);
115
116 // returns success:
117 return kIOReturnSuccess;
118 }
119
120 // Sets the file-server mode:
121 if( (data = OSDynamicCast( OSData, dict->getObject("FileServer")))) {
122 UInt8 myBool = *((UInt8*)data->getBytesNoCopy());
123 theInterface->setFileServerMode(myBool);
124
125 IOLog("AppleCudaUserClient::setProperties FileServer %d\n", myBool != 0);
126
127 // returns success:
128 return kIOReturnSuccess;
129 }
130
131 //Demand sleep immediately:
132 if( (data = OSDynamicCast( OSData, dict->getObject("SleepNow")))) {
133 UInt8 myBool = *((UInt8*)data->getBytesNoCopy());
134
135 if (myBool)
136 {
137 theInterface->demandSleepNow();
138 IOLog("AppleCudaUserClient::setProperties SleepNow\n");
139 }
140 return kIOReturnSuccess;
141 }
142
143 // Sets the self-wake time:
144 if( (data = OSDynamicCast( OSData, dict->getObject("AutoWake")))) {
145 UInt32 newTime;
146 IOByteCount len = data->getLength();
147
148 if (len == 4)
149 newTime = *((UInt32*)data->getBytesNoCopy());
150 else
151 newTime = 0;
152
153 theInterface->setWakeTime(newTime * 1000); //convert to milliseconds
154
155 IOLog("AppleCudaUserClient::setProperties AutoWake 0x%08lx\n", newTime);
156
157 // returns success:
158 return kIOReturnSuccess;
159 }
160
161 // Sets the self-poweron time:
162 if( (data = OSDynamicCast( OSData, dict->getObject("AutoPower")))) {
163 UInt32 newTime;
164 IOByteCount len = data->getLength();
165
166 if (len == 4)
167 newTime = *((UInt32*)data->getBytesNoCopy());
168 else
169 newTime = 0;
170
171 theInterface->setPowerOnTime(newTime);
172
173 IOLog("AppleCudaUserClient::setProperties AutoPower 0x%08lx\n", newTime);
174
175 // returns success:
176 return kIOReturnSuccess;
177 }
178
179 }
180
181 return(kIOReturnBadArgument);
182 }