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