2 * Copyright (c) 1998-2019 Apple 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>
44 #include <libkern/c++/OSPtr.h>
48 #include <kern/clock.h>
51 #include <libkern/OSTypes.h>
54 kCoprocessorVersionNone
= 0x00000000,
55 kCoprocessorVersion1
= 0x00010000,
56 kCoprocessorVersion2
= 0x00020000,
61 * PEGetMachineName() and PEGetModelName() are inconsistent across
62 * architectures, and considered deprecated.
63 * PEGetTargetName() and PEGetProductName() instead.
65 extern boolean_t
PEGetMachineName( char * name
, int maxLength
);
66 extern boolean_t
PEGetModelName( char * name
, int maxLength
);
68 extern boolean_t
PEGetTargetName( char * name
, int maxLength
);
69 extern boolean_t
PEGetProductName( char * name
, int maxLength
);
70 extern int PEGetPlatformEpoch( void );
82 kPEPanicRestartCPUNoCallouts
,
83 kPEPanicDiagnosticsDone
,
86 /* Bitmask of details related to panic callouts */
87 #define kPanicDetailsForcePowerOff 0x1
89 extern int (*PE_halt_restart
)(unsigned int type
);
90 extern int PEHaltRestart(unsigned int type
);
92 #ifdef XNU_KERNEL_PRIVATE
94 extern int PEHaltRestartInternal(unsigned int type
, uint32_t details
);
97 kIOSystemShutdownNotificationStageProcessExit
= 0,
98 kIOSystemShutdownNotificationStageRootUnmount
= 1,
99 kIOSystemShutdownNotificationTerminateDEXTs
= 2,
101 extern void IOSystemShutdownNotification(int stage
);
103 extern uint32_t gEnforceQuiesceSafety
;
104 #endif /* XNU_KERNEL_PRIVATE */
106 #ifdef KERNEL_PRIVATE
107 extern boolean_t
IOPMRootDomainGetWillShutdown(void);
108 extern void PEInitiatePanic(void);
109 #endif /* KERNEL_PRIVATE */
111 // Save the Panic Info. Returns the number of bytes saved.
112 extern UInt32
PESavePanicInfo(UInt8
*buffer
, UInt32 length
);
113 extern void PESavePanicInfoAction(void *buffer
, UInt32 offset
, UInt32 length
);
116 * SMC requires that all data is flushed in multiples of 16 bytes at 16 byte
119 #define PANIC_FLUSH_BOUNDARY 16
121 extern long PEGetGMTTimeOfDay( void );
122 extern void PESetGMTTimeOfDay( long secs
);
123 extern void PEGetUTCTimeOfDay( clock_sec_t
* secs
, clock_usec_t
* usecs
);
124 extern void PESetUTCTimeOfDay( clock_sec_t secs
, clock_usec_t usecs
);
126 /* unless it's a "well-known" property, these will read/write out the value as raw data */
128 extern boolean_t
PEWriteNVRAMBooleanProperty(const char *symbol
, boolean_t value
);
129 extern boolean_t
PEWriteNVRAMProperty(const char *symbol
, const void *value
, const unsigned int len
);
130 extern boolean_t
PEWriteNVRAMPropertyWithCopy(const char *symbol
, const void *value
, const unsigned int len
);
132 extern boolean_t
PEReadNVRAMProperty(const char *symbol
, void *value
, unsigned int *len
);
134 extern boolean_t
PERemoveNVRAMProperty(const char *symbol
);
136 extern coprocessor_type_t
PEGetCoprocessorVersion( void );
141 #define kIOPlatformMapperPresentKey "IOPlatformMapperPresent"
146 extern OSSymbol
* gPlatformInterruptControllerName
;
149 * IOPlatformSleepAction
151 * Sleep is called after power management has finished all of the power plane
152 * driver power management notifications and state transitions and has
153 * committed to sleep, but before the other CPUs are powered off.
154 * The scheduler is still active.
156 extern const OSSymbol
*gIOPlatformSleepActionKey
;
159 * IOPlatformWakeAction
161 * Wake is called with the scheduler enabled, but before
162 * powering on other CPUs, so try to minimize work done in this path to speed
165 extern const OSSymbol
*gIOPlatformWakeActionKey
;
168 * IOPlatformQuiesceAction
170 * Quiesce is called after all CPUs are off, scheduling is disabled,
171 * and the boot CPU is about to pull the plug.
172 * Mutexes and blocking are disallowed in this context and will panic.
173 * Do not pass this action to super() (incl. IOService, IOPlatformExpert)
175 extern const OSSymbol
*gIOPlatformQuiesceActionKey
;
178 * IOPlatformActiveAction
180 * Active is called very early in the wake path before enabling the scheduler
182 * Mutexes and blocking are disallowed in this context and will panic.
183 * Do not pass this action to super() (incl. IOService, IOPlatformExpert)
185 extern const OSSymbol
*gIOPlatformActiveActionKey
;
188 * IOPlatformHaltRestartAction
190 * Halt/Restart is called after the kernel finishes shutting down the
191 * system and is ready to power off or reboot.
193 * It is not guaranteed to be called in non-graceful shutdown scenarios.
195 extern const OSSymbol
*gIOPlatformHaltRestartActionKey
;
198 * IOPlatformPanicAction
200 * Panic is called when the system is panicking before it records a core file
201 * (if it is configured to do so)
203 * It can be called at any time, in any context, in any state. Don't depend
204 * on anything being powered on in a useful state.
206 * Mutexes and blocking are disallowed in this context and will fail.
208 * If you hang or panic again in this callout, the panic log may not be recorded,
209 * leading to the loss of field reports about customer issues.
211 extern const OSSymbol
*gIOPlatformPanicActionKey
;
213 class IORangeAllocator
;
214 class IONVRAMController
;
215 class IOPMrootDomain
;
217 class IOPlatformExpert
: public IOService
219 OSDeclareDefaultStructors(IOPlatformExpert
);
227 IOPMrootDomain
* root
;
229 int _pePrivPMFeatures
;
230 int _peNumBatteriesSupported
;
231 OSArray
* thePowerTree
;
233 bool searchingForAdditionalParents
;
234 OSNumber
* multipleParentKeyValue
;
235 int numInstancesRegistered
;
237 struct ExpansionData
{ };
238 ExpansionData
*iope_reserved __unused
;
240 virtual void setBootROMType(long peBootROMType
);
241 virtual void setChipSetType(long peChipSetType
);
242 virtual void setMachineType(long peMachineType
);
244 virtual bool CheckSubTree(OSArray
* inSubTree
, IOService
* theNub
, IOService
* theDevice
, OSDictionary
* theParent
);
245 virtual bool RegisterServiceInTree(IOService
* theService
, OSDictionary
* theTreeNode
, OSDictionary
* theTreeParentNode
, IOService
* theProvider
);
247 virtual void PMInstantiatePowerDomains( void );
250 virtual bool attach( IOService
* provider
) APPLE_KEXT_OVERRIDE
;
251 virtual bool start( IOService
* provider
) APPLE_KEXT_OVERRIDE
;
252 virtual bool configure( IOService
* provider
);
253 virtual IOService
* createNub( OSDictionary
* from
);
255 virtual bool compareNubName( const IOService
* nub
, OSString
* name
,
256 OSString
** matched
= NULL
) const;
257 bool compareNubName( const IOService
* nub
, OSString
* name
,
258 OSSharedPtr
<OSString
>& matched
) const;
259 virtual IOReturn
getNubResources( IOService
* nub
);
261 virtual long getBootROMType(void);
262 virtual long getChipSetType(void);
263 virtual long getMachineType(void);
266 * getModelName() and getMachineName() are deprecated for direct
267 * use. Use getTargetName() and getProductName() instead.
269 virtual bool getModelName( char * name
, int maxLength
);
270 virtual bool getMachineName( char * name
, int maxLength
);
272 virtual int haltRestart(unsigned int type
);
273 virtual void sleepKernel(void);
275 virtual long getGMTTimeOfDay( void );
276 virtual void setGMTTimeOfDay( long secs
);
278 virtual IOReturn
getConsoleInfo( PE_Video
* consoleInfo
);
279 virtual IOReturn
setConsoleInfo( PE_Video
* consoleInfo
, unsigned int op
);
281 virtual void registerNVRAMController( IONVRAMController
* nvram
);
283 virtual IOReturn
registerInterruptController(OSSymbol
*name
, IOInterruptController
*interruptController
);
284 virtual LIBKERN_RETURNS_NOT_RETAINED IOInterruptController
*
285 lookUpInterruptController(OSSymbol
*name
);
287 virtual void setCPUInterruptProperties(IOService
*service
);
288 virtual bool atInterruptLevel(void);
290 virtual IOReturn
callPlatformFunction(const OSSymbol
*functionName
,
291 bool waitForFunction
,
292 void *param1
, void *param2
,
293 void *param3
, void *param4
) APPLE_KEXT_OVERRIDE
;
295 virtual IORangeAllocator
* getPhysicalRangeAllocator(void);
297 virtual bool platformAdjustService(IOService
*service
);
299 virtual void PMRegisterDevice(IOService
* theNub
, IOService
* theDevice
);
300 virtual void PMLog( const char *, unsigned long, unsigned long, unsigned long );
302 virtual bool hasPMFeature(unsigned long featureMask
);
303 virtual bool hasPrivPMFeature(unsigned long privFeatureMask
);
304 virtual int numBatteriesSupported(void);
306 virtual IOByteCount
savePanicInfo(UInt8
*buffer
, IOByteCount length
);
308 virtual OSString
* createSystemSerialNumberString(OSData
* myProperty
);
310 virtual IOReturn
deregisterInterruptController(OSSymbol
*name
);
312 virtual void getUTCTimeOfDay( clock_sec_t
* secs
, clock_nsec_t
* nsecs
);
313 virtual void setUTCTimeOfDay( clock_sec_t secs
, clock_nsec_t nsecs
);
314 void publishPlatformUUIDAndSerial( void );
315 void publishNVRAM( void );
317 virtual bool getTargetName( char * name
, int maxLength
);
318 virtual bool getProductName( char * name
, int maxLength
);
320 OSMetaClassDeclareReservedUsedX86(IOPlatformExpert
, 0);
321 OSMetaClassDeclareReservedUsedX86(IOPlatformExpert
, 1);
322 OSMetaClassDeclareReservedUsedX86(IOPlatformExpert
, 2);
323 OSMetaClassDeclareReservedUsedX86(IOPlatformExpert
, 3);
324 OSMetaClassDeclareReservedUsedX86(IOPlatformExpert
, 4);
325 OSMetaClassDeclareReservedUsedX86(IOPlatformExpert
, 5);
326 OSMetaClassDeclareReservedUsedX86(IOPlatformExpert
, 6);
328 OSMetaClassDeclareReservedUnused(IOPlatformExpert
, 7);
329 OSMetaClassDeclareReservedUnused(IOPlatformExpert
, 8);
330 OSMetaClassDeclareReservedUnused(IOPlatformExpert
, 9);
331 OSMetaClassDeclareReservedUnused(IOPlatformExpert
, 10);
332 OSMetaClassDeclareReservedUnused(IOPlatformExpert
, 11);
335 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
339 class IODTPlatformExpert
: public IOPlatformExpert
341 OSDeclareAbstractStructors(IODTPlatformExpert
);
346 struct ExpansionData
{ };
347 ExpansionData
*iodtpe_reserved
;
350 virtual IOService
* probe( IOService
* provider
,
351 SInt32
* score
) APPLE_KEXT_OVERRIDE
;
352 virtual bool configure( IOService
* provider
) APPLE_KEXT_OVERRIDE
;
354 virtual void processTopLevel( IORegistryEntry
* root
);
355 virtual const char * deleteList( void ) = 0;
356 virtual const char * excludeList( void ) = 0;
357 virtual IOService
* createNub( IORegistryEntry
* from
);
358 virtual bool createNubs( IOService
* parent
, LIBKERN_CONSUMED OSIterator
* iter
);
360 virtual bool compareNubName( const IOService
* nub
, OSString
* name
,
361 OSString
** matched
= NULL
) const APPLE_KEXT_OVERRIDE
;
363 virtual IOReturn
getNubResources( IOService
* nub
) APPLE_KEXT_OVERRIDE
;
366 * getModelName() and getMachineName() are deprecated. Use
367 * getTargetName() and getProductName() instead.
369 virtual bool getModelName( char * name
, int maxLength
) APPLE_KEXT_OVERRIDE
;
370 virtual bool getMachineName( char * name
, int maxLength
) APPLE_KEXT_OVERRIDE
;
372 virtual bool getTargetName( char * name
, int maxLength
) APPLE_KEXT_OVERRIDE
;
373 virtual bool getProductName( char * name
, int maxLength
) APPLE_KEXT_OVERRIDE
;
375 virtual void registerNVRAMController( IONVRAMController
* nvram
) APPLE_KEXT_OVERRIDE
;
377 virtual int haltRestart(unsigned int type
) APPLE_KEXT_OVERRIDE
;
379 /* virtual */ IOReturn
readXPRAM(IOByteCount offset
, UInt8
* buffer
,
382 /* virtual */ IOReturn
writeXPRAM(IOByteCount offset
, UInt8
* buffer
,
385 virtual IOReturn
readNVRAMProperty(
386 IORegistryEntry
* entry
,
387 const OSSymbol
** name
, OSData
** value
);
389 IOReturn
readNVRAMProperty(
390 IORegistryEntry
* entry
,
391 OSSharedPtr
<const OSSymbol
>& name
, OSSharedPtr
<OSData
>& value
);
393 virtual IOReturn
writeNVRAMProperty(
394 IORegistryEntry
* entry
,
395 const OSSymbol
* name
, OSData
* value
);
397 // This returns a dictionary describing all the NVRAM partitions.
398 // The keys will be the partitionIDs of the form "0x52,nvram".
399 // The values will be OSNumbers of the partition's byte count.
400 /* virtual */ OSDictionary
*getNVRAMPartitions(void);
402 /* virtual */ IOReturn
readNVRAMPartition(const OSSymbol
* partitionID
,
403 IOByteCount offset
, UInt8
* buffer
,
406 /* virtual */ IOReturn
writeNVRAMPartition(const OSSymbol
* partitionID
,
407 IOByteCount offset
, UInt8
* buffer
,
410 virtual IOByteCount
savePanicInfo(UInt8
*buffer
, IOByteCount length
) APPLE_KEXT_OVERRIDE
;
411 virtual OSString
* createSystemSerialNumberString(OSData
* myProperty
) APPLE_KEXT_OVERRIDE
;
413 OSMetaClassDeclareReservedUnused(IODTPlatformExpert
, 0);
414 OSMetaClassDeclareReservedUnused(IODTPlatformExpert
, 1);
415 OSMetaClassDeclareReservedUnused(IODTPlatformExpert
, 2);
416 OSMetaClassDeclareReservedUnused(IODTPlatformExpert
, 3);
417 OSMetaClassDeclareReservedUnused(IODTPlatformExpert
, 4);
418 OSMetaClassDeclareReservedUnused(IODTPlatformExpert
, 5);
419 OSMetaClassDeclareReservedUnused(IODTPlatformExpert
, 6);
420 OSMetaClassDeclareReservedUnused(IODTPlatformExpert
, 7);
423 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
425 /* generic root nub of service tree */
427 class IOPlatformExpertDevice
: public IOService
429 OSDeclareDefaultStructors(IOPlatformExpertDevice
);
432 IOWorkLoop
*workLoop
;
434 struct ExpansionData
{ };
435 ExpansionData
*ioped_reserved __unused
;
438 virtual bool init(void *dtRoot
);
439 virtual bool compareName( OSString
* name
, OSString
** matched
= NULL
) const APPLE_KEXT_OVERRIDE
;
441 virtual IOWorkLoop
*getWorkLoop() const APPLE_KEXT_OVERRIDE
;
442 virtual IOReturn
setProperties( OSObject
* properties
) APPLE_KEXT_OVERRIDE
;
444 virtual void free() APPLE_KEXT_OVERRIDE
;
446 virtual IOReturn
newUserClient( task_t owningTask
, void * securityID
,
447 UInt32 type
, OSDictionary
* properties
,
448 IOUserClient
** handler
) APPLE_KEXT_OVERRIDE
;
450 bool startIOServiceMatching(void);
451 void createNVRAM(void);
452 void generatePlatformUUID(void);
453 void configureDefaults(void);
455 OSMetaClassDeclareReservedUnused(IOPlatformExpertDevice
, 0);
456 OSMetaClassDeclareReservedUnused(IOPlatformExpertDevice
, 1);
457 OSMetaClassDeclareReservedUnused(IOPlatformExpertDevice
, 2);
458 OSMetaClassDeclareReservedUnused(IOPlatformExpertDevice
, 3);
461 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
463 /* generic nub for motherboard devices */
465 class IOPlatformDevice
: public IOService
467 OSDeclareDefaultStructors(IOPlatformDevice
);
469 struct ExpansionData
{ };
470 ExpansionData
*iopd_reserved
;
473 virtual bool compareName( OSString
* name
, OSString
** matched
= NULL
) const APPLE_KEXT_OVERRIDE
;
474 virtual IOService
* matchLocation( IOService
* client
) APPLE_KEXT_OVERRIDE
;
475 virtual IOReturn
getResources( void ) APPLE_KEXT_OVERRIDE
;
477 OSMetaClassDeclareReservedUnused(IOPlatformDevice
, 0);
478 OSMetaClassDeclareReservedUnused(IOPlatformDevice
, 1);
479 OSMetaClassDeclareReservedUnused(IOPlatformDevice
, 2);
480 OSMetaClassDeclareReservedUnused(IOPlatformDevice
, 3);
483 #endif /* __cplusplus */
485 #endif /* ! _IOKIT_IOPLATFORMEXPERT_H */