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