]> git.saurik.com Git - apple/xnu.git/blame - iokit/IOKit/IOPlatformExpert.h
xnu-3789.70.16.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
1c79356b
A
50extern boolean_t PEGetMachineName( char * name, int maxLength );
51extern boolean_t PEGetModelName( char * name, int maxLength );
52extern int PEGetPlatformEpoch( void );
53
54enum {
55 kPEHaltCPU,
9bccf70c 56 kPERestartCPU,
0c530ab8 57 kPEHangCPU,
2d21ac55
A
58 kPEUPSDelayHaltCPU,
59 kPEPanicRestartCPU,
6d2010ae
A
60 kPEPanicSync,
61 kPEPagingOff
1c79356b
A
62};
63extern int (*PE_halt_restart)(unsigned int type);
64extern int PEHaltRestart(unsigned int type);
65
9bccf70c 66// Save the Panic Info. Returns the number of bytes saved.
b0d623f7 67extern UInt32 PESavePanicInfo(UInt8 *buffer, UInt32 length);
9bccf70c 68
1c79356b
A
69extern long PEGetGMTTimeOfDay( void );
70extern void PESetGMTTimeOfDay( long secs );
fe8ab488
A
71extern void PEGetUTCTimeOfDay( clock_sec_t * secs, clock_usec_t * usecs );
72extern void PESetUTCTimeOfDay( clock_sec_t secs, clock_usec_t usecs );
73
6d2010ae
A
74/* unless it's a "well-known" property, these will read/write out the value as raw data */
75
3e170ce0 76extern boolean_t PEWriteNVRAMBooleanProperty(const char *symbol, boolean_t value);
6d2010ae
A
77extern boolean_t PEWriteNVRAMProperty(const char *symbol, const void *value, const unsigned int len);
78
79extern boolean_t PEReadNVRAMProperty(const char *symbol, void *value, unsigned int *len);
80
39236c6e
A
81extern boolean_t PERemoveNVRAMProperty(const char *symbol);
82
1c79356b
A
83#ifdef __cplusplus
84} /* extern "C" */
85
55e303ae
A
86#define kIOPlatformMapperPresentKey "IOPlatformMapperPresent"
87
2d21ac55
A
88
89extern OSSymbol * gPlatformInterruptControllerName;
90
91extern const OSSymbol * gIOPlatformSleepActionKey;
92extern const OSSymbol * gIOPlatformWakeActionKey;
93extern const OSSymbol * gIOPlatformQuiesceActionKey;
94extern const OSSymbol * gIOPlatformActiveActionKey;
fe8ab488 95extern const OSSymbol * gIOPlatformHaltRestartActionKey;
3e170ce0 96extern const OSSymbol * gIOPlatformPanicActionKey;
1c79356b
A
97
98class IORangeAllocator;
99class IONVRAMController;
100class IOPMrootDomain;
101
102class IOPlatformExpert : public IOService
103{
104 OSDeclareDefaultStructors(IOPlatformExpert);
105
106private:
107 long _peBootROMType;
108 long _peChipSetType;
109 long _peMachineType;
110
111protected:
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
134public:
3e170ce0
A
135 virtual bool attach( IOService * provider ) APPLE_KEXT_OVERRIDE;
136 virtual bool start( IOService * provider ) APPLE_KEXT_OVERRIDE;
1c79356b
A
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,
3e170ce0 170 void *param3, void *param4) APPLE_KEXT_OVERRIDE;
1c79356b
A
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
9bccf70c
A
183 virtual IOByteCount savePanicInfo(UInt8 *buffer, IOByteCount length);
184
55e303ae 185 virtual OSString* createSystemSerialNumberString(OSData* myProperty);
fe8ab488
A
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
9bccf70c 192 OSMetaClassDeclareReservedUsed(IOPlatformExpert, 0);
55e303ae 193 OSMetaClassDeclareReservedUsed(IOPlatformExpert, 1);
fe8ab488
A
194 OSMetaClassDeclareReservedUsed(IOPlatformExpert, 2);
195 OSMetaClassDeclareReservedUsed(IOPlatformExpert, 3);
196 OSMetaClassDeclareReservedUsed(IOPlatformExpert, 4);
1c79356b
A
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
208class IODTNVRAM;
209
210class IODTPlatformExpert : public IOPlatformExpert
211{
212 OSDeclareAbstractStructors(IODTPlatformExpert);
213
214private:
215 IODTNVRAM *dtNVRAM;
216
217 struct ExpansionData { };
218 ExpansionData *reserved;
219
220public:
221 virtual IOService * probe( IOService * provider,
3e170ce0
A
222 SInt32 * score ) APPLE_KEXT_OVERRIDE;
223 virtual bool configure( IOService * provider ) APPLE_KEXT_OVERRIDE;
1c79356b
A
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,
3e170ce0 232 OSString ** matched = 0 ) const APPLE_KEXT_OVERRIDE;
1c79356b 233
3e170ce0 234 virtual IOReturn getNubResources( IOService * nub ) APPLE_KEXT_OVERRIDE;
1c79356b 235
3e170ce0
A
236 virtual bool getModelName( char * name, int maxLength ) APPLE_KEXT_OVERRIDE;
237 virtual bool getMachineName( char * name, int maxLength ) APPLE_KEXT_OVERRIDE;
1c79356b 238
3e170ce0 239 virtual void registerNVRAMController( IONVRAMController * nvram ) APPLE_KEXT_OVERRIDE;
1c79356b 240
3e170ce0 241 virtual int haltRestart(unsigned int type) APPLE_KEXT_OVERRIDE;
1c79356b
A
242
243 /* virtual */ IOReturn readXPRAM(IOByteCount offset, UInt8 * buffer,
244 IOByteCount length);
d52fe63f 245
1c79356b
A
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
d52fe63f
A
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);
1c79356b 269
3e170ce0
A
270 virtual IOByteCount savePanicInfo(UInt8 *buffer, IOByteCount length) APPLE_KEXT_OVERRIDE;
271 virtual OSString* createSystemSerialNumberString(OSData* myProperty) APPLE_KEXT_OVERRIDE;
9bccf70c 272
1c79356b
A
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
287class IOPlatformExpertDevice : public IOService
288{
289 OSDeclareDefaultStructors(IOPlatformExpertDevice)
290
291private:
292 IOWorkLoop *workLoop;
293
294 struct ExpansionData { };
295 ExpansionData *reserved;
296
297public:
298 virtual bool initWithArgs( void * p1, void * p2,
299 void * p3, void *p4 );
3e170ce0
A
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;
1c79356b 306
3e170ce0
A
307 virtual IOReturn newUserClient( task_t owningTask, void * securityID,
308 UInt32 type, OSDictionary * properties,
309 IOUserClient ** handler) APPLE_KEXT_OVERRIDE;
1c79356b 310
1c79356b
A
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
322class IOPlatformDevice : public IOService
323{
324 OSDeclareDefaultStructors(IOPlatformDevice)
325
326 struct ExpansionData { };
327 ExpansionData *reserved;
328
329public:
3e170ce0
A
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;
1c79356b
A
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 */