/*
- * Copyright (c) 1998-2016 Apple Inc. All rights reserved.
+ * Copyright (c) 1998-2019 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
#include <IOKit/pwr_mgt/IOPMpowerState.h>
#include <IOKit/IOServicePM.h>
#include <IOKit/IOReportTypes.h>
+#include <DriverKit/IOService.h>
extern "C" {
#include <kern/thread_call.h>
}
+
#ifndef UINT64_MAX
#define UINT64_MAX 18446744073709551615ULL
#endif
// options for terminate()
kIOServiceRequired = 0x00000001,
kIOServiceTerminate = 0x00000004,
+ kIOServiceTerminateWithRematch = 0x00000010,
// options for registerService() & terminate()
kIOServiceSynchronous = 0x00000002,
extern const OSSymbol * gIOResourcesKey;
extern const OSSymbol * gIOResourceMatchKey;
extern const OSSymbol * gIOResourceMatchedKey;
+extern const OSSymbol * gIOResourceIOKitKey;
+
extern const OSSymbol * gIOProviderClassKey;
extern const OSSymbol * gIONameMatchKey;
extern const OSSymbol * gIONameMatchedKey;
extern const OSSymbol * gIOPropertyMatchKey;
+extern const OSSymbol * gIOPropertyExistsMatchKey;
extern const OSSymbol * gIOLocationMatchKey;
extern const OSSymbol * gIOParentMatchKey;
extern const OSSymbol * gIOPathMatchKey;
extern const OSSymbol * gIOMatchCategoryKey;
extern const OSSymbol * gIODefaultMatchCategoryKey;
extern const OSSymbol * gIOMatchedServiceCountKey;
+extern const OSSymbol * gIOMatchedPersonalityKey;
+extern const OSSymbol * gIORematchPersonalityKey;
+extern const OSSymbol * gIORematchCountKey;
+extern const OSSymbol * gIODEXTMatchCountKey;
extern const OSSymbol * gIOUserClientClassKey;
+
+extern const OSSymbol * gIOUserClassKey;
+extern const OSSymbol * gIOUserServerClassKey;
+extern const OSSymbol * gIOUserServerNameKey;
+extern const OSSymbol * gIOUserServerTagKey;
+extern const OSSymbol * gIOUserServerCDHashKey;
+extern const OSSymbol * gIOUserUserClientKey;
+
extern const OSSymbol * gIOKitDebugKey;
extern const OSSymbol * gIOServiceKey;
extern const OSSymbol * gIOInterruptControllersKey;
extern const OSSymbol * gIOInterruptSpecifiersKey;
+extern const OSSymbol * gIOSupportedPropertiesKey;
+extern const OSSymbol * gIOUserServicePropertiesKey;
+
extern const OSSymbol * gIOBSDKey;
extern const OSSymbol * gIOBSDNameKey;
extern const OSSymbol * gIOBSDMajorKey;
extern const OSSymbol * gIOBSDMinorKey;
extern const OSSymbol * gIOBSDUnitKey;
+extern const OSSymbol * gIODriverKitEntitlementKey;
+extern const OSSymbol * gIOServiceDEXTEntitlementsKey;
+extern const OSSymbol * gIODriverKitUserClientEntitlementsKey;
+extern const OSSymbol * gIODriverKitUserClientEntitlementAllowAnyKey;
+extern const OSSymbol * gIOMatchDeferKey;
+
extern SInt32 IOServiceOrdering( const OSMetaClassBase * inObj1, const OSMetaClassBase * inObj2, void * ref );
typedef void (*IOInterruptAction)( OSObject * target, void * refCon,
struct IOInterruptAccountingData;
struct IOInterruptAccountingReporter;
+struct OSObjectUserVars;
class IOService : public IORegistryEntry
{
- OSDeclareDefaultStructors(IOService)
+ OSDeclareDefaultStructorsWithDispatch(IOService);
+#if XNU_KERNEL_PRIVATE
+public:
+#else
protected:
+#endif /* XNU_KERNEL_PRIVATE */
/*! @struct ExpansionData
* @discussion This structure will be used to expand the capablilties of this class in the future.
*/
IOLock * interruptStatisticsLock;
IOInterruptAccountingReporter * interruptStatisticsArray;
int interruptStatisticsArrayCount;
+
+ OSObjectUserVars * uvars;
};
/*! @var reserved
virtual bool open( IOService * forClient,
IOOptionBits options = 0,
- void * arg = 0 );
+ void * arg = NULL );
/*! @function close
* @abstract Releases active access to a provider.
* @param forClient If non-zero, <code>isOpen</code> returns the open state for that client. If zero is passed, <code>isOpen</code> returns the open state for all clients.
* @result <code>true</code> if the specific, or any, client has the IOService object open. */
- virtual bool isOpen( const IOService * forClient = 0 ) const;
+ virtual bool isOpen( const IOService * forClient = NULL ) const;
/*! @function handleOpen
* @abstract Controls the open / close behavior of an IOService object (overrideable by subclasses).
/*! @function init
* @abstract Initializes generic IOService data structures (expansion data, etc). */
- virtual bool init( OSDictionary * dictionary = 0 ) APPLE_KEXT_OVERRIDE;
+ virtual bool init( OSDictionary * dictionary = NULL ) APPLE_KEXT_OVERRIDE;
/*! @function init
* @abstract Initializes generic IOService data structures (expansion data, etc). */
* @param key An OSSymbol key that globally identifies the object.
* @param value The object to be published. */
- static void publishResource( const OSSymbol * key, OSObject * value = 0 );
+ static void publishResource( const OSSymbol * key, OSObject * value = NULL );
+ static void publishUserResource( const OSSymbol * key, OSObject * value = NULL );
/*! @function publishResource
* @abstract Uses the resource service to publish a property.
* @param key A C string key that globally identifies the object.
* @param value The object to be published. */
- static void publishResource( const char * key, OSObject * value = 0 );
+ static void publishResource( const char * key, OSObject * value = NULL );
virtual bool addNeededResource( const char * key );
/* Notifications */
static IONotifier * addNotification(
const OSSymbol * type, OSDictionary * matching,
IOServiceNotificationHandler handler,
- void * target, void * ref = 0,
+ void * target, void * ref = NULL,
SInt32 priority = 0 )
APPLE_KEXT_DEPRECATED;
static IONotifier * addMatchingNotification(
const OSSymbol * type, OSDictionary * matching,
IOServiceMatchingNotificationHandler handler,
- void * target, void * ref = 0,
+ void * target, void * ref = NULL,
SInt32 priority = 0 );
* @param timeout The maximum time to wait.
* @result A published IOService object matching the supplied dictionary. */
- LIBKERN_RETURNS_NOT_RETAINED
- static IOService * waitForService(
+ static LIBKERN_RETURNS_NOT_RETAINED IOService * waitForService(
LIBKERN_CONSUMED OSDictionary * matching,
- mach_timespec_t * timeout = 0);
+ mach_timespec_t * timeout = NULL);
/*! @function waitForMatchingService
* @abstract Waits for a matching to service to be published.
* @result The matching dictionary created, or passed in, is returned on success, or zero on failure. */
static OSDictionary * serviceMatching( const char * className,
- OSDictionary * table = 0 );
+ OSDictionary * table = NULL );
/*! @function serviceMatching
* @abstract Creates a matching dictionary, or adds matching properties to an existing dictionary, that specify an IOService class match.
* @result The matching dictionary created, or passed in, is returned on success, or zero on failure. */
static OSDictionary * serviceMatching( const OSString * className,
- OSDictionary * table = 0 );
+ OSDictionary * table = NULL );
/*! @function nameMatching
* @abstract Creates a matching dictionary, or adds matching properties to an existing dictionary, that specify an IOService name match.
* @result The matching dictionary created, or passed in, is returned on success, or zero on failure. */
static OSDictionary * nameMatching( const char * name,
- OSDictionary * table = 0 );
+ OSDictionary * table = NULL );
/*! @function nameMatching
* @abstract Creates a matching dictionary, or adds matching properties to an existing dictionary, that specify an IOService name match.
* @result The matching dictionary created, or passed in, is returned on success, or zero on failure. */
static OSDictionary * nameMatching( const OSString* name,
- OSDictionary * table = 0 );
+ OSDictionary * table = NULL );
/*! @function resourceMatching
* @abstract Creates a matching dictionary, or adds matching properties to an existing dictionary, that specify a resource service match.
* @result The matching dictionary created, or passed in, is returned on success, or zero on failure. */
static OSDictionary * resourceMatching( const char * name,
- OSDictionary * table = 0 );
+ OSDictionary * table = NULL );
/*! @function resourceMatching
* @abstract Creates a matching dictionary, or adds matching properties to an existing dictionary, that specify a resource service match.
* @result The matching dictionary created, or passed in, is returned on success, or zero on failure. */
static OSDictionary * resourceMatching( const OSString * name,
- OSDictionary * table = 0 );
+ OSDictionary * table = NULL );
/*! @function propertyMatching
* @result The matching dictionary created, or passed in, is returned on success, or zero on failure. */
static OSDictionary * propertyMatching( const OSSymbol * key, const OSObject * value,
- OSDictionary * table = 0 );
+ OSDictionary * table = NULL );
/*! @function registryEntryIDMatching
* @abstract Creates a matching dictionary, or adds matching properties to an existing dictionary, that specify a IORegistryEntryID match.
* @result The matching dictionary created, or passed in, is returned on success, or zero on failure. */
static OSDictionary * registryEntryIDMatching( uint64_t entryID,
- OSDictionary * table = 0 );
+ OSDictionary * table = NULL );
/*! @function addLocation
virtual IOReturn registerInterrupt(int source, OSObject *target,
IOInterruptAction handler,
- void *refCon = 0);
+ void *refCon = NULL);
#ifdef __BLOCKS__
/*! @function registerInterrupt
* @result An IOReturn code defined by the message type. */
virtual IOReturn message( UInt32 type, IOService * provider,
- void * argument = 0 );
+ void * argument = NULL );
/*! @function messageClient
* @abstract Sends a generic message to an attached client.
* @result The return code from the client message call. */
virtual IOReturn messageClient( UInt32 messageType, OSObject * client,
- void * messageArgument = 0, vm_size_t argSize = 0 );
+ void * messageArgument = NULL, vm_size_t argSize = 0 );
/*! @function messageClients
* @abstract Sends a generic message to all attached clients.
* @result Any non-<code>kIOReturnSuccess</code> return codes returned by the clients, or <code>kIOReturnSuccess</code> if all return <code>kIOReturnSuccess</code>. */
virtual IOReturn messageClients( UInt32 type,
- void * argument = 0, vm_size_t argSize = 0 );
+ void * argument = NULL, vm_size_t argSize = 0 );
virtual IONotifier * registerInterest( const OSSymbol * typeOfInterest,
IOServiceInterestHandler handler,
- void * target, void * ref = 0 );
+ void * target, void * ref = NULL );
#ifdef __BLOCKS__
IONotifier * registerInterest(const OSSymbol * typeOfInterest,
virtual IOReturn newUserClient( task_t owningTask, void * securityID,
UInt32 type, OSDictionary * properties,
- IOUserClient ** handler );
+ LIBKERN_RETURNS_RETAINED IOUserClient ** handler );
virtual IOReturn newUserClient( task_t owningTask, void * securityID,
- UInt32 type, IOUserClient ** handler );
+ UInt32 type,
+ LIBKERN_RETURNS_RETAINED IOUserClient ** handler );
/* Return code utilities */
IOReturn setAuthorizationID( uint64_t authorizationID );
void cpusRunning(void);
void scheduleFinalize(bool now);
+ static void willShutdown();
+ static void startDeferredMatches();
+ static void kextdLaunched();
private:
static IOReturn waitMatchIdle( UInt32 ms );
const OSSymbol * type, OSDictionary * matching,
IOServiceMatchingNotificationHandler handler,
void * target, void * ref,
- SInt32 priority, OSIterator ** existing );
+ SInt32 priority,
+ LIBKERN_RETURNS_RETAINED OSIterator ** existing );
#if !defined(__LP64__)
static IONotifier * installNotification(
const OSSymbol * type, OSDictionary * matching,
IOServiceNotificationHandler handler,
void * target, void * ref,
- SInt32 priority, OSIterator ** existing);
+ SInt32 priority,
+ LIBKERN_RETURNS_RETAINED OSIterator ** existing);
#endif /* !defined(__LP64__) */
#endif
OSArray * copyNotifiers(const OSSymbol * type,
IOOptionBits orNewState, IOOptionBits andNewState);
- bool invokeNotifiers(OSArray ** willSend);
+ bool invokeNotifiers(OSArray * willSend[]);
bool invokeNotifier( class _IOServiceNotifier * notify );
APPLE_KEXT_COMPATIBILITY_VIRTUAL
APPLE_KEXT_COMPATIBILITY_VIRTUAL
IOReturn waitForState( UInt32 mask, UInt32 value,
- mach_timespec_t * timeout = 0 );
+ mach_timespec_t * timeout = NULL );
IOReturn waitForState( UInt32 mask, UInt32 value, uint64_t timeout );
static void __attribute__((__noreturn__)) terminateThread( void * arg, wait_result_t unused );
static void terminateWorker( IOOptionBits options );
static void actionWillTerminate( IOService * victim, IOOptionBits options,
- OSArray * doPhase2List, void*, void * );
+ OSArray * doPhase2List, bool, void * );
static void actionDidTerminate( IOService * victim, IOOptionBits options,
void *, void *, void *);
APPLE_KEXT_COMPATIBILITY_VIRTUAL
IOReturn resolveInterrupt(IOService *nub, int source);
APPLE_KEXT_COMPATIBILITY_VIRTUAL
- IOReturn lookupInterrupt(int source, bool resolve, IOInterruptController **interruptController);
+ IOReturn lookupInterrupt(
+ int source, bool resolve,
+ LIBKERN_RETURNS_NOT_RETAINED IOInterruptController *
+ *interruptController);
#ifdef XNU_KERNEL_PRIVATE
/* end xnu internals */
* Drivers may eliminate the influence of the <code>changePowerStateTo</code> method on power state one of two ways. See @link powerOverrideOnPriv powerOverrideOnPriv@/link to ignore the method's influence, or call <code>changePowerStateTo(0)</code> in the driver's <code>start</code> routine to remove the <code>changePowerStateTo</code> method's power request.
* @param ordinal The number of the desired power state in the power state array.
* @result A return code that can be ignored by the caller. */
-
+public:
IOReturn changePowerStateToPriv( unsigned long ordinal );
/*! @function powerOverrideOnPriv
public:
void idleTimerExpired( void );
void settleTimerExpired( void );
- IOReturn synchronizePowerTree( IOOptionBits options = 0, IOService * notifyRoot = 0 );
- bool assertPMDriverCall( IOPMDriverCallEntry * callEntry, IOOptionBits options = 0, IOPMinformee * inform = 0 );
+ IOReturn synchronizePowerTree( IOOptionBits options = 0, IOService * notifyRoot = NULL );
+ bool assertPMDriverCall( IOPMDriverCallEntry * callEntry, IOOptionBits method, const IOPMinformee * inform = NULL, IOOptionBits options = 0 );
void deassertPMDriverCall( IOPMDriverCallEntry * callEntry );
IOReturn changePowerStateWithOverrideTo( IOPMPowerStateIndex ordinal, IOPMRequestTag tag );
IOReturn changePowerStateForRootDomain( IOPMPowerStateIndex ordinal );
static IOWorkLoop * getIOPMWorkloop( void );
bool getBlockingDriverCall(thread_t *thread, const void **callMethod);
+ void cancelIdlePowerDown(IOService * service);
protected:
bool tellClientsWithResponse( int messageType );
static IOReturn actionSpinDumpTimerExpired(OSObject *, void *, void *, void *, void * );
static IOReturn actionDriverCalloutDone(OSObject *, void *, void *, void *, void * );
- static IOPMRequest * acquirePMRequest( IOService * target, IOOptionBits type, IOPMRequest * active = 0 );
+ static IOPMRequest * acquirePMRequest( IOService * target, IOOptionBits type, IOPMRequest * active = NULL );
static void releasePMRequest( IOPMRequest * request );
static void pmDriverCallout( IOService * from );
static void pmTellAppWithResponse( OSObject * object, void * context );
static void pmTellCapabilityAppWithResponse( OSObject * object, void * arg );
static void pmTellCapabilityClientWithResponse( OSObject * object, void * arg );
static void submitPMRequest(LIBKERN_CONSUMED IOPMRequest * request );
- static void submitPMRequests( IOPMRequest ** request, IOItemCount count );
+ static void submitPMRequests( IOPMRequest * requests[], IOItemCount count );
bool ackTimerTick( void );
void addPowerChild1( IOPMRequest * request );
void addPowerChild2( IOPMRequest * request );
IOReturn updatePowerStatesReport( IOReportConfigureAction action, void *result, void *destination );
IOReturn configureSimplePowerReport(IOReportConfigureAction action, void *result );
IOReturn updateSimplePowerReport( IOReportConfigureAction action, void *result, void *destination );
- void waitForPMDriverCall( IOService * target = 0 );
+ void waitForPMDriverCall( IOService * target = NULL );
#endif /* XNU_KERNEL_PRIVATE */
};