]> git.saurik.com Git - apple/xnu.git/blob - iokit/IOKit/IOPlatformExpert.h
xnu-3789.51.2.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 };
63 extern int (*PE_halt_restart)(unsigned int type);
64 extern int PEHaltRestart(unsigned int type);
65
66 // Save the Panic Info. Returns the number of bytes saved.
67 extern UInt32 PESavePanicInfo(UInt8 *buffer, UInt32 length);
68
69 extern long PEGetGMTTimeOfDay( void );
70 extern void PESetGMTTimeOfDay( long secs );
71 extern void PEGetUTCTimeOfDay( clock_sec_t * secs, clock_usec_t * usecs );
72 extern void PESetUTCTimeOfDay( clock_sec_t secs, clock_usec_t usecs );
73
74 /* unless it's a "well-known" property, these will read/write out the value as raw data */
75
76 extern boolean_t PEWriteNVRAMBooleanProperty(const char *symbol, boolean_t value);
77 extern boolean_t PEWriteNVRAMProperty(const char *symbol, const void *value, const unsigned int len);
78
79 extern boolean_t PEReadNVRAMProperty(const char *symbol, void *value, unsigned int *len);
80
81 extern boolean_t PERemoveNVRAMProperty(const char *symbol);
82
83 #ifdef __cplusplus
84 } /* extern "C" */
85
86 #define kIOPlatformMapperPresentKey "IOPlatformMapperPresent"
87
88
89 extern OSSymbol * gPlatformInterruptControllerName;
90
91 extern const OSSymbol * gIOPlatformSleepActionKey;
92 extern const OSSymbol * gIOPlatformWakeActionKey;
93 extern const OSSymbol * gIOPlatformQuiesceActionKey;
94 extern const OSSymbol * gIOPlatformActiveActionKey;
95 extern const OSSymbol * gIOPlatformHaltRestartActionKey;
96 extern const OSSymbol * gIOPlatformPanicActionKey;
97
98 class IORangeAllocator;
99 class IONVRAMController;
100 class IOPMrootDomain;
101
102 class IOPlatformExpert : public IOService
103 {
104 OSDeclareDefaultStructors(IOPlatformExpert);
105
106 private:
107 long _peBootROMType;
108 long _peChipSetType;
109 long _peMachineType;
110
111 protected:
112 IOPMrootDomain * root;
113 int _pePMFeatures;
114 int _pePrivPMFeatures;
115 int _peNumBatteriesSupported;
116 OSArray * thePowerTree;
117
118 bool searchingForAdditionalParents;
119 OSNumber * multipleParentKeyValue;
120 int numInstancesRegistered;
121
122 struct ExpansionData { };
123 ExpansionData *reserved;
124
125 virtual void setBootROMType(long peBootROMType);
126 virtual void setChipSetType(long peChipSetType);
127 virtual void setMachineType(long peMachineType);
128
129 virtual bool CheckSubTree (OSArray * inSubTree, IOService * theNub, IOService * theDevice, OSDictionary * theParent);
130 virtual bool RegisterServiceInTree (IOService * theService, OSDictionary * theTreeNode, OSDictionary * theTreeParentNode, IOService * theProvider);
131
132 virtual void PMInstantiatePowerDomains ( void );
133
134 public:
135 virtual bool attach( IOService * provider ) APPLE_KEXT_OVERRIDE;
136 virtual bool start( IOService * provider ) APPLE_KEXT_OVERRIDE;
137 virtual bool configure( IOService * provider );
138 virtual IOService * createNub( OSDictionary * from );
139
140 virtual bool compareNubName( const IOService * nub, OSString * name,
141 OSString ** matched = 0 ) const;
142 virtual IOReturn getNubResources( IOService * nub );
143
144 virtual long getBootROMType(void);
145 virtual long getChipSetType(void);
146 virtual long getMachineType(void);
147
148 virtual bool getModelName( char * name, int maxLength );
149 virtual bool getMachineName( char * name, int maxLength );
150
151 virtual int haltRestart(unsigned int type);
152 virtual void sleepKernel(void);
153
154 virtual long getGMTTimeOfDay( void );
155 virtual void setGMTTimeOfDay( long secs );
156
157 virtual IOReturn getConsoleInfo( PE_Video * consoleInfo );
158 virtual IOReturn setConsoleInfo( PE_Video * consoleInfo, unsigned int op );
159
160 virtual void registerNVRAMController( IONVRAMController * nvram );
161
162 virtual IOReturn registerInterruptController(OSSymbol *name, IOInterruptController *interruptController);
163 virtual IOInterruptController *lookUpInterruptController(OSSymbol *name);
164 virtual void setCPUInterruptProperties(IOService *service);
165 virtual bool atInterruptLevel(void);
166
167 virtual IOReturn callPlatformFunction(const OSSymbol *functionName,
168 bool waitForFunction,
169 void *param1, void *param2,
170 void *param3, void *param4) APPLE_KEXT_OVERRIDE;
171
172 virtual IORangeAllocator * getPhysicalRangeAllocator(void);
173
174 virtual bool platformAdjustService(IOService *service);
175
176 virtual void PMRegisterDevice(IOService * theNub, IOService * theDevice);
177 virtual void PMLog ( const char *,unsigned long, unsigned long, unsigned long );
178
179 virtual bool hasPMFeature (unsigned long featureMask);
180 virtual bool hasPrivPMFeature (unsigned long privFeatureMask);
181 virtual int numBatteriesSupported (void);
182
183 virtual IOByteCount savePanicInfo(UInt8 *buffer, IOByteCount length);
184
185 virtual OSString* createSystemSerialNumberString(OSData* myProperty);
186
187 virtual IOReturn deregisterInterruptController(OSSymbol *name);
188
189 virtual void getUTCTimeOfDay( clock_sec_t * secs, clock_nsec_t * nsecs );
190 virtual void setUTCTimeOfDay( clock_sec_t secs, clock_nsec_t nsecs );
191
192 OSMetaClassDeclareReservedUsed(IOPlatformExpert, 0);
193 OSMetaClassDeclareReservedUsed(IOPlatformExpert, 1);
194 OSMetaClassDeclareReservedUsed(IOPlatformExpert, 2);
195 OSMetaClassDeclareReservedUsed(IOPlatformExpert, 3);
196 OSMetaClassDeclareReservedUsed(IOPlatformExpert, 4);
197 OSMetaClassDeclareReservedUnused(IOPlatformExpert, 5);
198 OSMetaClassDeclareReservedUnused(IOPlatformExpert, 6);
199 OSMetaClassDeclareReservedUnused(IOPlatformExpert, 7);
200 OSMetaClassDeclareReservedUnused(IOPlatformExpert, 8);
201 OSMetaClassDeclareReservedUnused(IOPlatformExpert, 9);
202 OSMetaClassDeclareReservedUnused(IOPlatformExpert, 10);
203 OSMetaClassDeclareReservedUnused(IOPlatformExpert, 11);
204 };
205
206 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
207
208 class IODTNVRAM;
209
210 class IODTPlatformExpert : public IOPlatformExpert
211 {
212 OSDeclareAbstractStructors(IODTPlatformExpert);
213
214 private:
215 IODTNVRAM *dtNVRAM;
216
217 struct ExpansionData { };
218 ExpansionData *reserved;
219
220 public:
221 virtual IOService * probe( IOService * provider,
222 SInt32 * score ) APPLE_KEXT_OVERRIDE;
223 virtual bool configure( IOService * provider ) APPLE_KEXT_OVERRIDE;
224
225 virtual void processTopLevel( IORegistryEntry * root );
226 virtual const char * deleteList( void ) = 0;
227 virtual const char * excludeList( void ) = 0;
228 virtual IOService * createNub( IORegistryEntry * from );
229 virtual bool createNubs( IOService * parent, OSIterator * iter );
230
231 virtual bool compareNubName( const IOService * nub, OSString * name,
232 OSString ** matched = 0 ) const APPLE_KEXT_OVERRIDE;
233
234 virtual IOReturn getNubResources( IOService * nub ) APPLE_KEXT_OVERRIDE;
235
236 virtual bool getModelName( char * name, int maxLength ) APPLE_KEXT_OVERRIDE;
237 virtual bool getMachineName( char * name, int maxLength ) APPLE_KEXT_OVERRIDE;
238
239 virtual void registerNVRAMController( IONVRAMController * nvram ) APPLE_KEXT_OVERRIDE;
240
241 virtual int haltRestart(unsigned int type) APPLE_KEXT_OVERRIDE;
242
243 /* virtual */ IOReturn readXPRAM(IOByteCount offset, UInt8 * buffer,
244 IOByteCount length);
245
246 /* virtual */ IOReturn writeXPRAM(IOByteCount offset, UInt8 * buffer,
247 IOByteCount length);
248
249 virtual IOReturn readNVRAMProperty(
250 IORegistryEntry * entry,
251 const OSSymbol ** name, OSData ** value );
252
253 virtual IOReturn writeNVRAMProperty(
254 IORegistryEntry * entry,
255 const OSSymbol * name, OSData * value );
256
257 // This returns a dictionary describing all the NVRAM partitions.
258 // The keys will be the partitionIDs of the form "0x52,nvram".
259 // The values will be OSNumbers of the partition's byte count.
260 /* virtual */ OSDictionary *getNVRAMPartitions(void);
261
262 /* virtual */ IOReturn readNVRAMPartition(const OSSymbol * partitionID,
263 IOByteCount offset, UInt8 * buffer,
264 IOByteCount length);
265
266 /* virtual */ IOReturn writeNVRAMPartition(const OSSymbol * partitionID,
267 IOByteCount offset, UInt8 * buffer,
268 IOByteCount length);
269
270 virtual IOByteCount savePanicInfo(UInt8 *buffer, IOByteCount length) APPLE_KEXT_OVERRIDE;
271 virtual OSString* createSystemSerialNumberString(OSData* myProperty) APPLE_KEXT_OVERRIDE;
272
273 OSMetaClassDeclareReservedUnused(IODTPlatformExpert, 0);
274 OSMetaClassDeclareReservedUnused(IODTPlatformExpert, 1);
275 OSMetaClassDeclareReservedUnused(IODTPlatformExpert, 2);
276 OSMetaClassDeclareReservedUnused(IODTPlatformExpert, 3);
277 OSMetaClassDeclareReservedUnused(IODTPlatformExpert, 4);
278 OSMetaClassDeclareReservedUnused(IODTPlatformExpert, 5);
279 OSMetaClassDeclareReservedUnused(IODTPlatformExpert, 6);
280 OSMetaClassDeclareReservedUnused(IODTPlatformExpert, 7);
281 };
282
283 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
284
285 /* generic root nub of service tree */
286
287 class IOPlatformExpertDevice : public IOService
288 {
289 OSDeclareDefaultStructors(IOPlatformExpertDevice)
290
291 private:
292 IOWorkLoop *workLoop;
293
294 struct ExpansionData { };
295 ExpansionData *reserved;
296
297 public:
298 virtual bool initWithArgs( void * p1, void * p2,
299 void * p3, void *p4 );
300 virtual bool compareName( OSString * name, OSString ** matched = 0 ) const APPLE_KEXT_OVERRIDE;
301
302 virtual IOWorkLoop *getWorkLoop() const APPLE_KEXT_OVERRIDE;
303 virtual IOReturn setProperties( OSObject * properties ) APPLE_KEXT_OVERRIDE;
304
305 virtual void free() APPLE_KEXT_OVERRIDE;
306
307 virtual IOReturn newUserClient( task_t owningTask, void * securityID,
308 UInt32 type, OSDictionary * properties,
309 IOUserClient ** handler) APPLE_KEXT_OVERRIDE;
310
311
312 OSMetaClassDeclareReservedUnused(IOPlatformExpertDevice, 0);
313 OSMetaClassDeclareReservedUnused(IOPlatformExpertDevice, 1);
314 OSMetaClassDeclareReservedUnused(IOPlatformExpertDevice, 2);
315 OSMetaClassDeclareReservedUnused(IOPlatformExpertDevice, 3);
316 };
317
318 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
319
320 /* generic nub for motherboard devices */
321
322 class IOPlatformDevice : public IOService
323 {
324 OSDeclareDefaultStructors(IOPlatformDevice)
325
326 struct ExpansionData { };
327 ExpansionData *reserved;
328
329 public:
330 virtual bool compareName( OSString * name, OSString ** matched = 0 ) const APPLE_KEXT_OVERRIDE;
331 virtual IOService * matchLocation( IOService * client ) APPLE_KEXT_OVERRIDE;
332 virtual IOReturn getResources( void ) APPLE_KEXT_OVERRIDE;
333
334 OSMetaClassDeclareReservedUnused(IOPlatformDevice, 0);
335 OSMetaClassDeclareReservedUnused(IOPlatformDevice, 1);
336 OSMetaClassDeclareReservedUnused(IOPlatformDevice, 2);
337 OSMetaClassDeclareReservedUnused(IOPlatformDevice, 3);
338 };
339
340 #endif /* __cplusplus */
341
342 #endif /* ! _IOKIT_IOPLATFORMEXPERT_H */