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