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