]> git.saurik.com Git - apple/xnu.git/blob - iokit/IOKit/IOPlatformExpert.h
xnu-4570.1.46.tar.gz
[apple/xnu.git] / iokit / IOKit / IOPlatformExpert.h
1 /*
2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
14 *
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 */
28 /*
29 * Copyright (c) 1998 Apple Computer, Inc. All rights reserved.
30 *
31 * HISTORY
32 *
33 */
34
35
36 #ifndef _IOKIT_IOPLATFORMEXPERT_H
37 #define _IOKIT_IOPLATFORMEXPERT_H
38
39 #ifdef __cplusplus
40 #include <IOKit/IOLib.h>
41 #include <IOKit/IOService.h>
42 #include <IOKit/IOInterrupts.h>
43 #include <IOKit/IOInterruptController.h>
44
45 extern "C" {
46 #endif
47
48 #include <libkern/OSTypes.h>
49
50 extern boolean_t PEGetMachineName( char * name, int maxLength );
51 extern boolean_t PEGetModelName( char * name, int maxLength );
52 extern int PEGetPlatformEpoch( void );
53
54 enum {
55 kPEHaltCPU,
56 kPERestartCPU,
57 kPEHangCPU,
58 kPEUPSDelayHaltCPU,
59 kPEPanicRestartCPU,
60 kPEPanicSync,
61 kPEPagingOff,
62 kPEPanicBegin,
63 kPEPanicEnd
64 };
65 extern int (*PE_halt_restart)(unsigned int type);
66 extern int PEHaltRestart(unsigned int type);
67
68 // Save the Panic Info. Returns the number of bytes saved.
69 extern UInt32 PESavePanicInfo(UInt8 *buffer, UInt32 length);
70 extern void PESavePanicInfoAction(void *buffer, size_t length);
71
72 extern long PEGetGMTTimeOfDay( void );
73 extern void PESetGMTTimeOfDay( long secs );
74 extern void PEGetUTCTimeOfDay( clock_sec_t * secs, clock_usec_t * usecs );
75 extern void PESetUTCTimeOfDay( clock_sec_t secs, clock_usec_t usecs );
76
77 /* unless it's a "well-known" property, these will read/write out the value as raw data */
78
79 extern boolean_t PEWriteNVRAMBooleanProperty(const char *symbol, boolean_t value);
80 extern boolean_t PEWriteNVRAMProperty(const char *symbol, const void *value, const unsigned int len);
81
82 extern boolean_t PEReadNVRAMProperty(const char *symbol, void *value, unsigned int *len);
83
84 extern boolean_t PERemoveNVRAMProperty(const char *symbol);
85
86 #ifdef __cplusplus
87 } /* extern "C" */
88
89 #define kIOPlatformMapperPresentKey "IOPlatformMapperPresent"
90
91
92 extern OSSymbol * gPlatformInterruptControllerName;
93
94 extern const OSSymbol * gIOPlatformSleepActionKey;
95 extern const OSSymbol * gIOPlatformWakeActionKey;
96 extern const OSSymbol * gIOPlatformQuiesceActionKey;
97 extern const OSSymbol * gIOPlatformActiveActionKey;
98 extern const OSSymbol * gIOPlatformHaltRestartActionKey;
99 extern const OSSymbol * gIOPlatformPanicActionKey;
100
101 class IORangeAllocator;
102 class IONVRAMController;
103 class IOPMrootDomain;
104
105 class IOPlatformExpert : public IOService
106 {
107 OSDeclareDefaultStructors(IOPlatformExpert);
108
109 private:
110 long _peBootROMType;
111 long _peChipSetType;
112 long _peMachineType;
113
114 protected:
115 IOPMrootDomain * root;
116 int _pePMFeatures;
117 int _pePrivPMFeatures;
118 int _peNumBatteriesSupported;
119 OSArray * thePowerTree;
120
121 bool searchingForAdditionalParents;
122 OSNumber * multipleParentKeyValue;
123 int numInstancesRegistered;
124
125 struct ExpansionData { };
126 ExpansionData *reserved;
127
128 virtual void setBootROMType(long peBootROMType);
129 virtual void setChipSetType(long peChipSetType);
130 virtual void setMachineType(long peMachineType);
131
132 virtual bool CheckSubTree (OSArray * inSubTree, IOService * theNub, IOService * theDevice, OSDictionary * theParent);
133 virtual bool RegisterServiceInTree (IOService * theService, OSDictionary * theTreeNode, OSDictionary * theTreeParentNode, IOService * theProvider);
134
135 virtual void PMInstantiatePowerDomains ( void );
136
137 public:
138 virtual bool attach( IOService * provider ) APPLE_KEXT_OVERRIDE;
139 virtual bool start( IOService * provider ) APPLE_KEXT_OVERRIDE;
140 virtual bool configure( IOService * provider );
141 virtual IOService * createNub( OSDictionary * from );
142
143 virtual bool compareNubName( const IOService * nub, OSString * name,
144 OSString ** matched = 0 ) const;
145 virtual IOReturn getNubResources( IOService * nub );
146
147 virtual long getBootROMType(void);
148 virtual long getChipSetType(void);
149 virtual long getMachineType(void);
150
151 virtual bool getModelName( char * name, int maxLength );
152 virtual bool getMachineName( char * name, int maxLength );
153
154 virtual int haltRestart(unsigned int type);
155 virtual void sleepKernel(void);
156
157 virtual long getGMTTimeOfDay( void );
158 virtual void setGMTTimeOfDay( long secs );
159
160 virtual IOReturn getConsoleInfo( PE_Video * consoleInfo );
161 virtual IOReturn setConsoleInfo( PE_Video * consoleInfo, unsigned int op );
162
163 virtual void registerNVRAMController( IONVRAMController * nvram );
164
165 virtual IOReturn registerInterruptController(OSSymbol *name, IOInterruptController *interruptController);
166 virtual IOInterruptController *lookUpInterruptController(OSSymbol *name);
167 virtual void setCPUInterruptProperties(IOService *service);
168 virtual bool atInterruptLevel(void);
169
170 virtual IOReturn callPlatformFunction(const OSSymbol *functionName,
171 bool waitForFunction,
172 void *param1, void *param2,
173 void *param3, void *param4) APPLE_KEXT_OVERRIDE;
174
175 virtual IORangeAllocator * getPhysicalRangeAllocator(void);
176
177 virtual bool platformAdjustService(IOService *service);
178
179 virtual void PMRegisterDevice(IOService * theNub, IOService * theDevice);
180 virtual void PMLog ( const char *,unsigned long, unsigned long, unsigned long );
181
182 virtual bool hasPMFeature (unsigned long featureMask);
183 virtual bool hasPrivPMFeature (unsigned long privFeatureMask);
184 virtual int numBatteriesSupported (void);
185
186 virtual IOByteCount savePanicInfo(UInt8 *buffer, IOByteCount length);
187
188 virtual OSString* createSystemSerialNumberString(OSData* myProperty);
189
190 virtual IOReturn deregisterInterruptController(OSSymbol *name);
191
192 virtual void getUTCTimeOfDay( clock_sec_t * secs, clock_nsec_t * nsecs );
193 virtual void setUTCTimeOfDay( clock_sec_t secs, clock_nsec_t nsecs );
194
195 OSMetaClassDeclareReservedUsed(IOPlatformExpert, 0);
196 OSMetaClassDeclareReservedUsed(IOPlatformExpert, 1);
197 OSMetaClassDeclareReservedUsed(IOPlatformExpert, 2);
198 OSMetaClassDeclareReservedUsed(IOPlatformExpert, 3);
199 OSMetaClassDeclareReservedUsed(IOPlatformExpert, 4);
200 OSMetaClassDeclareReservedUnused(IOPlatformExpert, 5);
201 OSMetaClassDeclareReservedUnused(IOPlatformExpert, 6);
202 OSMetaClassDeclareReservedUnused(IOPlatformExpert, 7);
203 OSMetaClassDeclareReservedUnused(IOPlatformExpert, 8);
204 OSMetaClassDeclareReservedUnused(IOPlatformExpert, 9);
205 OSMetaClassDeclareReservedUnused(IOPlatformExpert, 10);
206 OSMetaClassDeclareReservedUnused(IOPlatformExpert, 11);
207 };
208
209 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
210
211 class IODTNVRAM;
212
213 class IODTPlatformExpert : public IOPlatformExpert
214 {
215 OSDeclareAbstractStructors(IODTPlatformExpert);
216
217 private:
218 IODTNVRAM *dtNVRAM;
219
220 struct ExpansionData { };
221 ExpansionData *reserved;
222
223 public:
224 virtual IOService * probe( IOService * provider,
225 SInt32 * score ) APPLE_KEXT_OVERRIDE;
226 virtual bool configure( IOService * provider ) APPLE_KEXT_OVERRIDE;
227
228 virtual void processTopLevel( IORegistryEntry * root );
229 virtual const char * deleteList( void ) = 0;
230 virtual const char * excludeList( void ) = 0;
231 virtual IOService * createNub( IORegistryEntry * from );
232 virtual bool createNubs( IOService * parent, OSIterator * iter );
233
234 virtual bool compareNubName( const IOService * nub, OSString * name,
235 OSString ** matched = 0 ) const APPLE_KEXT_OVERRIDE;
236
237 virtual IOReturn getNubResources( IOService * nub ) APPLE_KEXT_OVERRIDE;
238
239 virtual bool getModelName( char * name, int maxLength ) APPLE_KEXT_OVERRIDE;
240 virtual bool getMachineName( char * name, int maxLength ) APPLE_KEXT_OVERRIDE;
241
242 virtual void registerNVRAMController( IONVRAMController * nvram ) APPLE_KEXT_OVERRIDE;
243
244 virtual int haltRestart(unsigned int type) APPLE_KEXT_OVERRIDE;
245
246 /* virtual */ IOReturn readXPRAM(IOByteCount offset, UInt8 * buffer,
247 IOByteCount length);
248
249 /* virtual */ IOReturn writeXPRAM(IOByteCount offset, UInt8 * buffer,
250 IOByteCount length);
251
252 virtual IOReturn readNVRAMProperty(
253 IORegistryEntry * entry,
254 const OSSymbol ** name, OSData ** value );
255
256 virtual IOReturn writeNVRAMProperty(
257 IORegistryEntry * entry,
258 const OSSymbol * name, OSData * value );
259
260 // This returns a dictionary describing all the NVRAM partitions.
261 // The keys will be the partitionIDs of the form "0x52,nvram".
262 // The values will be OSNumbers of the partition's byte count.
263 /* virtual */ OSDictionary *getNVRAMPartitions(void);
264
265 /* virtual */ IOReturn readNVRAMPartition(const OSSymbol * partitionID,
266 IOByteCount offset, UInt8 * buffer,
267 IOByteCount length);
268
269 /* virtual */ IOReturn writeNVRAMPartition(const OSSymbol * partitionID,
270 IOByteCount offset, UInt8 * buffer,
271 IOByteCount length);
272
273 virtual IOByteCount savePanicInfo(UInt8 *buffer, IOByteCount length) APPLE_KEXT_OVERRIDE;
274 virtual OSString* createSystemSerialNumberString(OSData* myProperty) APPLE_KEXT_OVERRIDE;
275
276 OSMetaClassDeclareReservedUnused(IODTPlatformExpert, 0);
277 OSMetaClassDeclareReservedUnused(IODTPlatformExpert, 1);
278 OSMetaClassDeclareReservedUnused(IODTPlatformExpert, 2);
279 OSMetaClassDeclareReservedUnused(IODTPlatformExpert, 3);
280 OSMetaClassDeclareReservedUnused(IODTPlatformExpert, 4);
281 OSMetaClassDeclareReservedUnused(IODTPlatformExpert, 5);
282 OSMetaClassDeclareReservedUnused(IODTPlatformExpert, 6);
283 OSMetaClassDeclareReservedUnused(IODTPlatformExpert, 7);
284 };
285
286 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
287
288 /* generic root nub of service tree */
289
290 class IOPlatformExpertDevice : public IOService
291 {
292 OSDeclareDefaultStructors(IOPlatformExpertDevice)
293
294 private:
295 IOWorkLoop *workLoop;
296
297 struct ExpansionData { };
298 ExpansionData *reserved;
299
300 public:
301 virtual bool initWithArgs( void * p1, void * p2,
302 void * p3, void *p4 );
303 virtual bool compareName( OSString * name, OSString ** matched = 0 ) const APPLE_KEXT_OVERRIDE;
304
305 virtual IOWorkLoop *getWorkLoop() const APPLE_KEXT_OVERRIDE;
306 virtual IOReturn setProperties( OSObject * properties ) APPLE_KEXT_OVERRIDE;
307
308 virtual void free() APPLE_KEXT_OVERRIDE;
309
310 virtual IOReturn newUserClient( task_t owningTask, void * securityID,
311 UInt32 type, OSDictionary * properties,
312 IOUserClient ** handler) APPLE_KEXT_OVERRIDE;
313
314
315 OSMetaClassDeclareReservedUnused(IOPlatformExpertDevice, 0);
316 OSMetaClassDeclareReservedUnused(IOPlatformExpertDevice, 1);
317 OSMetaClassDeclareReservedUnused(IOPlatformExpertDevice, 2);
318 OSMetaClassDeclareReservedUnused(IOPlatformExpertDevice, 3);
319 };
320
321 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
322
323 /* generic nub for motherboard devices */
324
325 class IOPlatformDevice : public IOService
326 {
327 OSDeclareDefaultStructors(IOPlatformDevice)
328
329 struct ExpansionData { };
330 ExpansionData *reserved;
331
332 public:
333 virtual bool compareName( OSString * name, OSString ** matched = 0 ) const APPLE_KEXT_OVERRIDE;
334 virtual IOService * matchLocation( IOService * client ) APPLE_KEXT_OVERRIDE;
335 virtual IOReturn getResources( void ) APPLE_KEXT_OVERRIDE;
336
337 OSMetaClassDeclareReservedUnused(IOPlatformDevice, 0);
338 OSMetaClassDeclareReservedUnused(IOPlatformDevice, 1);
339 OSMetaClassDeclareReservedUnused(IOPlatformDevice, 2);
340 OSMetaClassDeclareReservedUnused(IOPlatformDevice, 3);
341 };
342
343 #endif /* __cplusplus */
344
345 #endif /* ! _IOKIT_IOPLATFORMEXPERT_H */