2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
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.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
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.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
29 * Copyright (c) 1998 Apple Computer, Inc. All rights reserved.
36 #ifndef _IOKIT_IOPLATFORMEXPERT_H
37 #define _IOKIT_IOPLATFORMEXPERT_H
40 #include <IOKit/IOLib.h>
41 #include <IOKit/IOService.h>
42 #include <IOKit/IOInterrupts.h>
43 #include <IOKit/IOInterruptController.h>
48 #include <libkern/OSTypes.h>
51 kCoprocessorVersionNone
= 0x00000000,
52 kCoprocessorVersion1
= 0x00010000,
53 kCoprocessorVersion2
= 0x00020000,
57 extern boolean_t
PEGetMachineName( char * name
, int maxLength
);
58 extern boolean_t
PEGetModelName( char * name
, int maxLength
);
59 extern int PEGetPlatformEpoch( void );
73 extern int (*PE_halt_restart
)(unsigned int type
);
74 extern int PEHaltRestart(unsigned int type
);
76 #ifdef XNU_KERNEL_PRIVATE
78 kIOSystemShutdownNotificationStageProcessExit
= 0,
79 kIOSystemShutdownNotificationStageRootUnmount
= 1,
81 extern void IOSystemShutdownNotification(int stage
);
82 #endif /* XNU_KERNEL_PRIVATE */
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
);
89 * SMC requires that all data is flushed in multiples of 16 bytes at 16 byte
92 #define PANIC_FLUSH_BOUNDARY 16
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
);
99 /* unless it's a "well-known" property, these will read/write out the value as raw data */
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
);
105 extern boolean_t
PEReadNVRAMProperty(const char *symbol
, void *value
, unsigned int *len
);
107 extern boolean_t
PERemoveNVRAMProperty(const char *symbol
);
109 extern coprocessor_type_t
PEGetCoprocessorVersion( void );
114 #define kIOPlatformMapperPresentKey "IOPlatformMapperPresent"
119 extern OSSymbol
* gPlatformInterruptControllerName
;
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
;
128 class IORangeAllocator
;
129 class IONVRAMController
;
130 class IOPMrootDomain
;
132 class IOPlatformExpert
: public IOService
134 OSDeclareDefaultStructors(IOPlatformExpert
);
142 IOPMrootDomain
* root
;
144 int _pePrivPMFeatures
;
145 int _peNumBatteriesSupported
;
146 OSArray
* thePowerTree
;
148 bool searchingForAdditionalParents
;
149 OSNumber
* multipleParentKeyValue
;
150 int numInstancesRegistered
;
152 struct ExpansionData
{ };
153 ExpansionData
*iope_reserved __unused
;
155 virtual void setBootROMType(long peBootROMType
);
156 virtual void setChipSetType(long peChipSetType
);
157 virtual void setMachineType(long peMachineType
);
159 virtual bool CheckSubTree(OSArray
* inSubTree
, IOService
* theNub
, IOService
* theDevice
, OSDictionary
* theParent
);
160 virtual bool RegisterServiceInTree(IOService
* theService
, OSDictionary
* theTreeNode
, OSDictionary
* theTreeParentNode
, IOService
* theProvider
);
162 virtual void PMInstantiatePowerDomains( void );
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
);
170 virtual bool compareNubName( const IOService
* nub
, OSString
* name
,
171 OSString
** matched
= 0 ) const;
172 virtual IOReturn
getNubResources( IOService
* nub
);
174 virtual long getBootROMType(void);
175 virtual long getChipSetType(void);
176 virtual long getMachineType(void);
178 virtual bool getModelName( char * name
, int maxLength
);
179 virtual bool getMachineName( char * name
, int maxLength
);
181 virtual int haltRestart(unsigned int type
);
182 virtual void sleepKernel(void);
184 virtual long getGMTTimeOfDay( void );
185 virtual void setGMTTimeOfDay( long secs
);
187 virtual IOReturn
getConsoleInfo( PE_Video
* consoleInfo
);
188 virtual IOReturn
setConsoleInfo( PE_Video
* consoleInfo
, unsigned int op
);
190 virtual void registerNVRAMController( IONVRAMController
* nvram
);
192 virtual IOReturn
registerInterruptController(OSSymbol
*name
, IOInterruptController
*interruptController
);
193 virtual LIBKERN_RETURNS_NOT_RETAINED IOInterruptController
*
194 lookUpInterruptController(OSSymbol
*name
);
196 virtual void setCPUInterruptProperties(IOService
*service
);
197 virtual bool atInterruptLevel(void);
199 virtual IOReturn
callPlatformFunction(const OSSymbol
*functionName
,
200 bool waitForFunction
,
201 void *param1
, void *param2
,
202 void *param3
, void *param4
) APPLE_KEXT_OVERRIDE
;
204 virtual IORangeAllocator
* getPhysicalRangeAllocator(void);
206 virtual bool platformAdjustService(IOService
*service
);
208 virtual void PMRegisterDevice(IOService
* theNub
, IOService
* theDevice
);
209 virtual void PMLog( const char *, unsigned long, unsigned long, unsigned long );
211 virtual bool hasPMFeature(unsigned long featureMask
);
212 virtual bool hasPrivPMFeature(unsigned long privFeatureMask
);
213 virtual int numBatteriesSupported(void);
215 virtual IOByteCount
savePanicInfo(UInt8
*buffer
, IOByteCount length
);
217 virtual OSString
* createSystemSerialNumberString(OSData
* myProperty
);
219 virtual IOReturn
deregisterInterruptController(OSSymbol
*name
);
221 virtual void getUTCTimeOfDay( clock_sec_t
* secs
, clock_nsec_t
* nsecs
);
222 virtual void setUTCTimeOfDay( clock_sec_t secs
, clock_nsec_t nsecs
);
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);
238 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
242 class IODTPlatformExpert
: public IOPlatformExpert
244 OSDeclareAbstractStructors(IODTPlatformExpert
);
249 struct ExpansionData
{ };
250 ExpansionData
*iodtpe_reserved
;
253 virtual IOService
* probe( IOService
* provider
,
254 SInt32
* score
) APPLE_KEXT_OVERRIDE
;
255 virtual bool configure( IOService
* provider
) APPLE_KEXT_OVERRIDE
;
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
);
263 virtual bool compareNubName( const IOService
* nub
, OSString
* name
,
264 OSString
** matched
= 0 ) const APPLE_KEXT_OVERRIDE
;
266 virtual IOReturn
getNubResources( IOService
* nub
) APPLE_KEXT_OVERRIDE
;
268 virtual bool getModelName( char * name
, int maxLength
) APPLE_KEXT_OVERRIDE
;
269 virtual bool getMachineName( char * name
, int maxLength
) APPLE_KEXT_OVERRIDE
;
271 virtual void registerNVRAMController( IONVRAMController
* nvram
) APPLE_KEXT_OVERRIDE
;
273 virtual int haltRestart(unsigned int type
) APPLE_KEXT_OVERRIDE
;
275 /* virtual */ IOReturn
readXPRAM(IOByteCount offset
, UInt8
* buffer
,
278 /* virtual */ IOReturn
writeXPRAM(IOByteCount offset
, UInt8
* buffer
,
281 virtual IOReturn
readNVRAMProperty(
282 IORegistryEntry
* entry
,
283 const OSSymbol
** name
, OSData
** value
);
285 virtual IOReturn
writeNVRAMProperty(
286 IORegistryEntry
* entry
,
287 const OSSymbol
* name
, OSData
* value
);
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);
294 /* virtual */ IOReturn
readNVRAMPartition(const OSSymbol
* partitionID
,
295 IOByteCount offset
, UInt8
* buffer
,
298 /* virtual */ IOReturn
writeNVRAMPartition(const OSSymbol
* partitionID
,
299 IOByteCount offset
, UInt8
* buffer
,
302 virtual IOByteCount
savePanicInfo(UInt8
*buffer
, IOByteCount length
) APPLE_KEXT_OVERRIDE
;
303 virtual OSString
* createSystemSerialNumberString(OSData
* myProperty
) APPLE_KEXT_OVERRIDE
;
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);
315 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
317 /* generic root nub of service tree */
319 class IOPlatformExpertDevice
: public IOService
321 OSDeclareDefaultStructors(IOPlatformExpertDevice
)
324 IOWorkLoop
*workLoop
;
326 struct ExpansionData
{ };
327 ExpansionData
*ioped_reserved __unused
;
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
;
334 virtual IOWorkLoop
*getWorkLoop() const APPLE_KEXT_OVERRIDE
;
335 virtual IOReturn
setProperties( OSObject
* properties
) APPLE_KEXT_OVERRIDE
;
337 virtual void free() APPLE_KEXT_OVERRIDE
;
339 virtual IOReturn
newUserClient( task_t owningTask
, void * securityID
,
340 UInt32 type
, OSDictionary
* properties
,
341 IOUserClient
** handler
) APPLE_KEXT_OVERRIDE
;
344 OSMetaClassDeclareReservedUnused(IOPlatformExpertDevice
, 0);
345 OSMetaClassDeclareReservedUnused(IOPlatformExpertDevice
, 1);
346 OSMetaClassDeclareReservedUnused(IOPlatformExpertDevice
, 2);
347 OSMetaClassDeclareReservedUnused(IOPlatformExpertDevice
, 3);
350 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
352 /* generic nub for motherboard devices */
354 class IOPlatformDevice
: public IOService
356 OSDeclareDefaultStructors(IOPlatformDevice
)
358 struct ExpansionData
{ };
359 ExpansionData
*iopd_reserved
;
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
;
366 OSMetaClassDeclareReservedUnused(IOPlatformDevice
, 0);
367 OSMetaClassDeclareReservedUnused(IOPlatformDevice
, 1);
368 OSMetaClassDeclareReservedUnused(IOPlatformDevice
, 2);
369 OSMetaClassDeclareReservedUnused(IOPlatformDevice
, 3);
372 #endif /* __cplusplus */
374 #endif /* ! _IOKIT_IOPLATFORMEXPERT_H */