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>
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 );
72 kPEPanicRestartCPUNoPanicEndCallouts
,
73 kPEPanicRestartCPUNoCallouts
75 extern int (*PE_halt_restart
)(unsigned int type
);
76 extern int PEHaltRestart(unsigned int type
);
78 #ifdef XNU_KERNEL_PRIVATE
80 kIOSystemShutdownNotificationStageProcessExit
= 0,
81 kIOSystemShutdownNotificationStageRootUnmount
= 1,
83 extern void IOSystemShutdownNotification(int stage
);
85 extern uint32_t gEnforceQuiesceSafety
;
86 #endif /* XNU_KERNEL_PRIVATE */
89 extern boolean_t
IOPMRootDomainGetWillShutdown(void);
90 #endif /* KERNEL_PRIVATE */
92 // Save the Panic Info. Returns the number of bytes saved.
93 extern UInt32
PESavePanicInfo(UInt8
*buffer
, UInt32 length
);
94 extern void PESavePanicInfoAction(void *buffer
, UInt32 offset
, UInt32 length
);
97 * SMC requires that all data is flushed in multiples of 16 bytes at 16 byte
100 #define PANIC_FLUSH_BOUNDARY 16
102 extern long PEGetGMTTimeOfDay( void );
103 extern void PESetGMTTimeOfDay( long secs
);
104 extern void PEGetUTCTimeOfDay( clock_sec_t
* secs
, clock_usec_t
* usecs
);
105 extern void PESetUTCTimeOfDay( clock_sec_t secs
, clock_usec_t usecs
);
107 /* unless it's a "well-known" property, these will read/write out the value as raw data */
109 extern boolean_t
PEWriteNVRAMBooleanProperty(const char *symbol
, boolean_t value
);
110 extern boolean_t
PEWriteNVRAMProperty(const char *symbol
, const void *value
, const unsigned int len
);
111 extern boolean_t
PEWriteNVRAMPropertyWithCopy(const char *symbol
, const void *value
, const unsigned int len
);
113 extern boolean_t
PEReadNVRAMProperty(const char *symbol
, void *value
, unsigned int *len
);
115 extern boolean_t
PERemoveNVRAMProperty(const char *symbol
);
117 extern coprocessor_type_t
PEGetCoprocessorVersion( void );
122 #define kIOPlatformMapperPresentKey "IOPlatformMapperPresent"
127 extern OSSymbol
* gPlatformInterruptControllerName
;
130 * IOPlatformSleepAction
132 * Sleep is called after power management has finished all of the power plane
133 * driver power management notifications and state transitions and has
134 * committed to sleep, but before the other CPUs are powered off.
135 * The scheduler is still active.
137 extern const OSSymbol
*gIOPlatformSleepActionKey
;
140 * IOPlatformWakeAction
142 * Wake is called with the scheduler enabled, but before
143 * powering on other CPUs, so try to minimize work done in this path to speed
146 extern const OSSymbol
*gIOPlatformWakeActionKey
;
149 * IOPlatformQuiesceAction
151 * Quiesce is called after all CPUs are off, scheduling is disabled,
152 * and the boot CPU is about to pull the plug.
153 * Mutexes and blocking are disallowed in this context and will panic.
154 * Do not pass this action to super() (incl. IOService, IOPlatformExpert)
156 extern const OSSymbol
*gIOPlatformQuiesceActionKey
;
159 * IOPlatformActiveAction
161 * Active is called very early in the wake path before enabling the scheduler
163 * Mutexes and blocking are disallowed in this context and will panic.
164 * Do not pass this action to super() (incl. IOService, IOPlatformExpert)
166 extern const OSSymbol
*gIOPlatformActiveActionKey
;
169 * IOPlatformHaltRestartAction
171 * Halt/Restart is called after the kernel finishes shutting down the
172 * system and is ready to power off or reboot.
174 * It is not guaranteed to be called in non-graceful shutdown scenarios.
176 extern const OSSymbol
*gIOPlatformHaltRestartActionKey
;
179 * IOPlatformPanicAction
181 * Panic is called when the system is panicking before it records a core file
182 * (if it is configured to do so)
184 * It can be called at any time, in any context, in any state. Don't depend
185 * on anything being powered on in a useful state.
187 * Mutexes and blocking are disallowed in this context and will fail.
189 * If you hang or panic again in this callout, the panic log may not be recorded,
190 * leading to the loss of field reports about customer issues.
192 extern const OSSymbol
*gIOPlatformPanicActionKey
;
194 class IORangeAllocator
;
195 class IONVRAMController
;
196 class IOPMrootDomain
;
198 class IOPlatformExpert
: public IOService
200 OSDeclareDefaultStructors(IOPlatformExpert
);
208 IOPMrootDomain
* root
;
210 int _pePrivPMFeatures
;
211 int _peNumBatteriesSupported
;
212 OSArray
* thePowerTree
;
214 bool searchingForAdditionalParents
;
215 OSNumber
* multipleParentKeyValue
;
216 int numInstancesRegistered
;
218 struct ExpansionData
{ };
219 ExpansionData
*iope_reserved __unused
;
221 virtual void setBootROMType(long peBootROMType
);
222 virtual void setChipSetType(long peChipSetType
);
223 virtual void setMachineType(long peMachineType
);
225 virtual bool CheckSubTree(OSArray
* inSubTree
, IOService
* theNub
, IOService
* theDevice
, OSDictionary
* theParent
);
226 virtual bool RegisterServiceInTree(IOService
* theService
, OSDictionary
* theTreeNode
, OSDictionary
* theTreeParentNode
, IOService
* theProvider
);
228 virtual void PMInstantiatePowerDomains( void );
231 virtual bool attach( IOService
* provider
) APPLE_KEXT_OVERRIDE
;
232 virtual bool start( IOService
* provider
) APPLE_KEXT_OVERRIDE
;
233 virtual bool configure( IOService
* provider
);
234 virtual IOService
* createNub( OSDictionary
* from
);
236 virtual bool compareNubName( const IOService
* nub
, OSString
* name
,
237 OSString
** matched
= NULL
) const;
238 virtual IOReturn
getNubResources( IOService
* nub
);
240 virtual long getBootROMType(void);
241 virtual long getChipSetType(void);
242 virtual long getMachineType(void);
244 virtual bool getModelName( char * name
, int maxLength
);
245 virtual bool getMachineName( char * name
, int maxLength
);
247 virtual int haltRestart(unsigned int type
);
248 virtual void sleepKernel(void);
250 virtual long getGMTTimeOfDay( void );
251 virtual void setGMTTimeOfDay( long secs
);
253 virtual IOReturn
getConsoleInfo( PE_Video
* consoleInfo
);
254 virtual IOReturn
setConsoleInfo( PE_Video
* consoleInfo
, unsigned int op
);
256 virtual void registerNVRAMController( IONVRAMController
* nvram
);
258 virtual IOReturn
registerInterruptController(OSSymbol
*name
, IOInterruptController
*interruptController
);
259 virtual LIBKERN_RETURNS_NOT_RETAINED IOInterruptController
*
260 lookUpInterruptController(OSSymbol
*name
);
262 virtual void setCPUInterruptProperties(IOService
*service
);
263 virtual bool atInterruptLevel(void);
265 virtual IOReturn
callPlatformFunction(const OSSymbol
*functionName
,
266 bool waitForFunction
,
267 void *param1
, void *param2
,
268 void *param3
, void *param4
) APPLE_KEXT_OVERRIDE
;
270 virtual IORangeAllocator
* getPhysicalRangeAllocator(void);
272 virtual bool platformAdjustService(IOService
*service
);
274 virtual void PMRegisterDevice(IOService
* theNub
, IOService
* theDevice
);
275 virtual void PMLog( const char *, unsigned long, unsigned long, unsigned long );
277 virtual bool hasPMFeature(unsigned long featureMask
);
278 virtual bool hasPrivPMFeature(unsigned long privFeatureMask
);
279 virtual int numBatteriesSupported(void);
281 virtual IOByteCount
savePanicInfo(UInt8
*buffer
, IOByteCount length
);
283 virtual OSString
* createSystemSerialNumberString(OSData
* myProperty
);
285 virtual IOReturn
deregisterInterruptController(OSSymbol
*name
);
287 virtual void getUTCTimeOfDay( clock_sec_t
* secs
, clock_nsec_t
* nsecs
);
288 virtual void setUTCTimeOfDay( clock_sec_t secs
, clock_nsec_t nsecs
);
290 OSMetaClassDeclareReservedUsed(IOPlatformExpert
, 0);
291 OSMetaClassDeclareReservedUsed(IOPlatformExpert
, 1);
292 OSMetaClassDeclareReservedUsed(IOPlatformExpert
, 2);
293 OSMetaClassDeclareReservedUsed(IOPlatformExpert
, 3);
294 OSMetaClassDeclareReservedUsed(IOPlatformExpert
, 4);
295 OSMetaClassDeclareReservedUnused(IOPlatformExpert
, 5);
296 OSMetaClassDeclareReservedUnused(IOPlatformExpert
, 6);
297 OSMetaClassDeclareReservedUnused(IOPlatformExpert
, 7);
298 OSMetaClassDeclareReservedUnused(IOPlatformExpert
, 8);
299 OSMetaClassDeclareReservedUnused(IOPlatformExpert
, 9);
300 OSMetaClassDeclareReservedUnused(IOPlatformExpert
, 10);
301 OSMetaClassDeclareReservedUnused(IOPlatformExpert
, 11);
304 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
308 class IODTPlatformExpert
: public IOPlatformExpert
310 OSDeclareAbstractStructors(IODTPlatformExpert
);
315 struct ExpansionData
{ };
316 ExpansionData
*iodtpe_reserved
;
319 virtual IOService
* probe( IOService
* provider
,
320 SInt32
* score
) APPLE_KEXT_OVERRIDE
;
321 virtual bool configure( IOService
* provider
) APPLE_KEXT_OVERRIDE
;
323 virtual void processTopLevel( IORegistryEntry
* root
);
324 virtual const char * deleteList( void ) = 0;
325 virtual const char * excludeList( void ) = 0;
326 virtual IOService
* createNub( IORegistryEntry
* from
);
327 virtual bool createNubs( IOService
* parent
, LIBKERN_CONSUMED OSIterator
* iter
);
329 virtual bool compareNubName( const IOService
* nub
, OSString
* name
,
330 OSString
** matched
= NULL
) const APPLE_KEXT_OVERRIDE
;
332 virtual IOReturn
getNubResources( IOService
* nub
) APPLE_KEXT_OVERRIDE
;
334 virtual bool getModelName( char * name
, int maxLength
) APPLE_KEXT_OVERRIDE
;
335 virtual bool getMachineName( char * name
, int maxLength
) APPLE_KEXT_OVERRIDE
;
337 virtual void registerNVRAMController( IONVRAMController
* nvram
) APPLE_KEXT_OVERRIDE
;
339 virtual int haltRestart(unsigned int type
) APPLE_KEXT_OVERRIDE
;
341 /* virtual */ IOReturn
readXPRAM(IOByteCount offset
, UInt8
* buffer
,
344 /* virtual */ IOReturn
writeXPRAM(IOByteCount offset
, UInt8
* buffer
,
347 virtual IOReturn
readNVRAMProperty(
348 IORegistryEntry
* entry
,
349 const OSSymbol
** name
, OSData
** value
);
351 virtual IOReturn
writeNVRAMProperty(
352 IORegistryEntry
* entry
,
353 const OSSymbol
* name
, OSData
* value
);
355 // This returns a dictionary describing all the NVRAM partitions.
356 // The keys will be the partitionIDs of the form "0x52,nvram".
357 // The values will be OSNumbers of the partition's byte count.
358 /* virtual */ OSDictionary
*getNVRAMPartitions(void);
360 /* virtual */ IOReturn
readNVRAMPartition(const OSSymbol
* partitionID
,
361 IOByteCount offset
, UInt8
* buffer
,
364 /* virtual */ IOReturn
writeNVRAMPartition(const OSSymbol
* partitionID
,
365 IOByteCount offset
, UInt8
* buffer
,
368 virtual IOByteCount
savePanicInfo(UInt8
*buffer
, IOByteCount length
) APPLE_KEXT_OVERRIDE
;
369 virtual OSString
* createSystemSerialNumberString(OSData
* myProperty
) APPLE_KEXT_OVERRIDE
;
371 OSMetaClassDeclareReservedUnused(IODTPlatformExpert
, 0);
372 OSMetaClassDeclareReservedUnused(IODTPlatformExpert
, 1);
373 OSMetaClassDeclareReservedUnused(IODTPlatformExpert
, 2);
374 OSMetaClassDeclareReservedUnused(IODTPlatformExpert
, 3);
375 OSMetaClassDeclareReservedUnused(IODTPlatformExpert
, 4);
376 OSMetaClassDeclareReservedUnused(IODTPlatformExpert
, 5);
377 OSMetaClassDeclareReservedUnused(IODTPlatformExpert
, 6);
378 OSMetaClassDeclareReservedUnused(IODTPlatformExpert
, 7);
381 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
383 /* generic root nub of service tree */
385 class IOPlatformExpertDevice
: public IOService
387 OSDeclareDefaultStructors(IOPlatformExpertDevice
);
390 IOWorkLoop
*workLoop
;
392 struct ExpansionData
{ };
393 ExpansionData
*ioped_reserved __unused
;
396 virtual bool initWithArgs( void * p1
, void * p2
,
397 void * p3
, void *p4
);
398 virtual bool compareName( OSString
* name
, OSString
** matched
= NULL
) const APPLE_KEXT_OVERRIDE
;
400 virtual IOWorkLoop
*getWorkLoop() const APPLE_KEXT_OVERRIDE
;
401 virtual IOReturn
setProperties( OSObject
* properties
) APPLE_KEXT_OVERRIDE
;
403 virtual void free() APPLE_KEXT_OVERRIDE
;
405 virtual IOReturn
newUserClient( task_t owningTask
, void * securityID
,
406 UInt32 type
, OSDictionary
* properties
,
407 IOUserClient
** handler
) APPLE_KEXT_OVERRIDE
;
410 OSMetaClassDeclareReservedUnused(IOPlatformExpertDevice
, 0);
411 OSMetaClassDeclareReservedUnused(IOPlatformExpertDevice
, 1);
412 OSMetaClassDeclareReservedUnused(IOPlatformExpertDevice
, 2);
413 OSMetaClassDeclareReservedUnused(IOPlatformExpertDevice
, 3);
416 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
418 /* generic nub for motherboard devices */
420 class IOPlatformDevice
: public IOService
422 OSDeclareDefaultStructors(IOPlatformDevice
);
424 struct ExpansionData
{ };
425 ExpansionData
*iopd_reserved
;
428 virtual bool compareName( OSString
* name
, OSString
** matched
= NULL
) const APPLE_KEXT_OVERRIDE
;
429 virtual IOService
* matchLocation( IOService
* client
) APPLE_KEXT_OVERRIDE
;
430 virtual IOReturn
getResources( void ) APPLE_KEXT_OVERRIDE
;
432 OSMetaClassDeclareReservedUnused(IOPlatformDevice
, 0);
433 OSMetaClassDeclareReservedUnused(IOPlatformDevice
, 1);
434 OSMetaClassDeclareReservedUnused(IOPlatformDevice
, 2);
435 OSMetaClassDeclareReservedUnused(IOPlatformDevice
, 3);
438 #endif /* __cplusplus */
440 #endif /* ! _IOKIT_IOPLATFORMEXPERT_H */