kIOServiceFirstMatchState = 0x00000010
};
-// options for registerService()
enum {
+ // options for registerService()
kIOServiceExclusive = 0x00000001,
- kIOServiceSynchronous = 0x00000002,
-};
-// options for terminate()
-enum {
- kIOServiceRequired = 0x00000001
+ // options for terminate()
+ kIOServiceRequired = 0x00000001,
+ kIOServiceTerminate = 0x00000004,
+
+ // options for registerService() & terminate()
+ kIOServiceSynchronous = 0x00000002,
+ // options for registerService()
+ kIOServiceAsynchronous = 0x00000008
};
// options for open()
extern const OSSymbol * gIONameMatchedKey;
extern const OSSymbol * gIOPropertyMatchKey;
extern const OSSymbol * gIOLocationMatchKey;
+extern const OSSymbol * gIOParentMatchKey;
extern const OSSymbol * gIOPathMatchKey;
extern const OSSymbol * gIOMatchCategoryKey;
extern const OSSymbol * gIODefaultMatchCategoryKey;
extern const OSSymbol * gIOGeneralInterest;
extern const OSSymbol * gIOBusyInterest;
+extern const OSSymbol * gIOOpenInterest;
extern const OSSymbol * gIOAppPowerStateInterest;
+extern const OSSymbol * gIOPriorityPowerStateInterest;
extern const OSSymbol * gIODeviceMemoryKey;
extern const OSSymbol * gIOInterruptControllersKey;
protected:
// TRUE once PMinit has been called
bool initialized;
+
+public:
// pointer to protected instance variables for power management
IOPMprot * pm_vars;
+public:
+ /* methods available in Mac OS X 10.1 or later */
+/*! @function requestTerminate
+ @abstract Passes a termination up the stack.
+ @discussion When an IOService is made inactive the default behaviour is to also make any of its clients that have it as their only provider also inactive, in this way recursing the termination up the driver stack. This method allows an IOService object to override this behaviour. Returning true from this method when passed a just terminated provider will cause the client to also be terminated.
+ @param provider The terminated provider of this object.
+ @param options Options originally passed to terminate, plus kIOServiceRecursing.
+ @result true if this object should be terminated now that its provider as been. */
+
+ virtual bool requestTerminate( IOService * provider, IOOptionBits options );
+
+/*! @function willTerminate
+ @abstract Passes a termination up the stack.
+ @discussion Notification that a provider has been terminated, sent before recursing up the stack, in root-to-leaf order.
+ @param provider The terminated provider of this object.
+ @param options Options originally passed to terminate.
+ @result true return true. */
+
+ virtual bool willTerminate( IOService * provider, IOOptionBits options );
+
+/*! @function didTerminate
+ @abstract Passes a termination up the stack.
+ @discussion Notification that a provider has been terminated, sent after recursing up the stack, in leaf-to-root order.
+ @param provider The terminated provider of this object.
+ @param options Options originally passed to terminate.
+ @param defer If there is pending I/O that requires this object to persist, and the provider is not opened by this object set defer to true and call the IOService::didTerminate() implementation when the I/O completes. Otherwise, leave defer set to its default value of false.
+ @result true return true. */
+
+ virtual bool didTerminate( IOService * provider, IOOptionBits options, bool * defer );
+
+ /* method available in Mac OS X 10.4 or later */
+/*! @function nextIdleTimeout
+ @abstract Allows subclasses to customize idle power management behavior.
+ @discussion Returns the next time that the device should idle into its next lower power state. Subclasses may override for custom idle behavior.
+ @param currentTime The current time
+ @param lastActivity The time of last activity on this device
+ @param powerState The device's current power state.
+ @result Returns the next time the device should idle off (in seconds, relative to the current time). */
+
+ virtual SInt32 nextIdleTimeout(AbsoluteTime currentTime,
+ AbsoluteTime lastActivity, unsigned int powerState);
+
private:
- OSMetaClassDeclareReservedUnused(IOService, 0);
- OSMetaClassDeclareReservedUnused(IOService, 1);
- OSMetaClassDeclareReservedUnused(IOService, 2);
- OSMetaClassDeclareReservedUnused(IOService, 3);
+ OSMetaClassDeclareReservedUsed(IOService, 0);
+ OSMetaClassDeclareReservedUsed(IOService, 1);
+ OSMetaClassDeclareReservedUsed(IOService, 2);
+ OSMetaClassDeclareReservedUsed(IOService, 3);
+
OSMetaClassDeclareReservedUnused(IOService, 4);
OSMetaClassDeclareReservedUnused(IOService, 5);
OSMetaClassDeclareReservedUnused(IOService, 6);
@discussion When an IOService is successfully terminated, it is immediately made inactive, which blocks further attach()es, matching or notifications occuring on the object. It remains inactive until the last client closes, and is then finalized and destroyed.
@result Returns true if the IOService has been terminated. */
- inline bool isInactive( void ) const
- { return( 0 != (kIOServiceInactiveState & getState())); }
+ bool isInactive( void ) const;
/* Stack creation */
virtual bool finalize( IOOptionBits options );
+/*! @function free
+ @discussion Free data structures that were allocated when power management was initialized on this service. */
+
+ virtual void free( void );
+
/*! @function lockForArbitration
@abstract Locks an IOService against changes in state or ownership.
@discussion The registration, termination and open / close functions of IOService use lockForArbtration to single thread access to an IOService. lockForArbitration will grant recursive access to the same thread.
/*! @function adjustBusy
@abstract Adjusts the busyState of an IOService.
- @discussion Applies a delta to an IOService's busyState. A change in the busyState to or from zero will changes the IOService's provider's busyState by one (in the same direction).
+ @discussion Applies a delta to an IOService's busyState. A change in the busyState to or from zero will change the IOService's provider's busyState by one (in the same direction).
@param delta The delta to be applied to the IOService busy state. */
virtual void adjustBusy( SInt32 delta );
static IOPlatformExpert * getPlatform( void );
+/*! @function getPMRootDomain
+ @abstract Returns a pointer to the power management root domain instance for the machine.
+ @discussion This method provides an accessor to the power management root domain instance for the machine.
+ @result A pointer to the power management root domain instance. It should not be released by the caller. */
+
+ static class IOPMrootDomain * getPMRootDomain( void );
+
/*! @function getServiceRoot
@abstract Returns a pointer to the root of the service plane.
@discussion This method provides an accessor to the root of the service plane for the machine.
static IOService * getServiceRoot( void );
+/*! @function getResourceService
+ @abstract Returns a pointer to the IOResources service.
+ @discussion IOService maintains a resource service IOResources that allows objects to be published and found globally in IOKit based on a name, using the standard IOService matching and notification calls.
+ @result A pointer to the IOResources instance. It should not be released by the caller. */
+
+ static IOService * getResourceService( void );
+
/* Allocate resources for a matched service */
/*! @function getResources
virtual bool serializeProperties( OSSerialize * s ) const;
static void setPlatform( IOPlatformExpert * platform);
+ static void setPMRootDomain( class IOPMrootDomain * rootDomain );
static IOReturn catalogNewDrivers( OSOrderedSet * newTables );
+ static IOReturn waitMatchIdle( UInt32 ms );
static IOService * resources( void );
virtual bool checkResources( void );
virtual IOReturn waitForState( UInt32 mask, UInt32 value,
mach_timespec_t * timeout = 0 );
+ UInt32 _adjustBusy( SInt32 delta );
+
+ bool terminatePhase1( IOOptionBits options = 0 );
+ void scheduleTerminatePhase2( IOOptionBits options = 0 );
+ void scheduleStop( IOService * provider );
+ void scheduleFinalize( void );
+ static void terminateThread( void * arg );
+ static void terminateWorker( IOOptionBits options );
+ static void actionWillTerminate( IOService * victim, IOOptionBits options,
+ OSArray * doPhase2List );
+ static void actionDidTerminate( IOService * victim, IOOptionBits options );
+ static void actionFinalize( IOService * victim, IOOptionBits options );
+ static void actionStop( IOService * client, IOService * provider );
+
+ void PMfree( void );
+
virtual IOReturn resolveInterrupt(IOService *nub, int source);
virtual IOReturn lookupInterrupt(int source, bool resolve, IOInterruptController **interruptController);
virtual bool askChangeDown ( unsigned long );
virtual bool tellChangeDown ( unsigned long );
+ bool tellChangeDown1 ( unsigned long );
+ bool tellChangeDown2 ( unsigned long );
virtual void tellNoChangeDown ( unsigned long );
virtual void tellChangeUp ( unsigned long );
virtual IOReturn allowPowerChange ( unsigned long refcon );
subclassed policy-makers, and that is how one finds out that a power change
it initiated is complete
@param stateNumber
- This is the number of the state in the state array that the device has switched to. */
+ This is the number of the state in the state array that the device has switched from. */
virtual void powerChangeDone ( unsigned long );
bool tellClientsWithResponse ( int messageType );
private:
- IOReturn enqueuePowerChange ( unsigned long, unsigned long, unsigned long, IOPowerConnection * );
+ IOReturn enqueuePowerChange ( unsigned long, unsigned long, unsigned long, IOPowerConnection *, unsigned long );
+ void setParentInfo ( IOPMPowerFlags, IOPowerConnection * );
IOReturn notifyAll ( bool is_prechange );
bool notifyChild ( IOPowerConnection * nextObject, bool is_prechange );
bool inform ( IOPMinformee * nextObject, bool is_prechange );
- void our_prechange_03 ( void );
- void our_prechange_05 ( void );
- void our_prechange_1 ( void );
- void our_prechange_2 ( void );
- void our_prechange_3 ( void );
- void our_prechange_4 ( void );
- IOReturn parent_down_0 ( void );
- void parent_down_05 ( void );
- IOReturn parent_down_1 ( void );
- IOReturn parent_down_2 ( void );
- void parent_down_3 ( void );
- void parent_down_4 ( void );
- void parent_down_5 ( void );
- void parent_down_6 ( void );
- void parent_up_0 ( void );
- IOReturn parent_up_1 ( void );
- IOReturn parent_up_2 ( void );
- IOReturn parent_up_3 ( void );
- void parent_up_4 ( void );
- void parent_up_5 ( void );
- void parent_up_6 ( void );
+
+ // Power Management state machine
+ // power change initiated by driver
+ void OurChangeTellClientsPowerDown ( void );
+ void OurChangeTellPriorityClientsPowerDown ( void );
+ void OurChangeNotifyInterestedDriversWillChange ( void );
+ void OurChangeSetPowerState ( void );
+ void OurChangeWaitForPowerSettle ( void );
+ void OurChangeNotifyInterestedDriversDidChange ( void );
+ void OurChangeFinish ( void );
+
+ // downward power change initiated by a power parent
+ IOReturn ParentDownTellPriorityClientsPowerDown_Immediate ( void );
+ IOReturn ParentDownNotifyInterestedDriversWillChange_Immediate ( void );
+ void ParentDownTellPriorityClientsPowerDown_Delayed ( void );
+ void ParentDownNotifyInterestedDriversWillChange_Delayed ( void );
+ IOReturn ParentDownSetPowerState_Immediate ( void );
+ IOReturn ParentDownWaitForPowerSettleAndNotifyDidChange_Immediate ( void );
+ void ParentDownNotifyDidChangeAndAcknowledgeChange_Delayed ( void );
+ void ParentDownSetPowerState_Delayed ( void );
+ void ParentDownWaitForPowerSettle_Delayed ( void );
+ void ParentDownAcknowledgeChange_Delayed ( void );
+
+ // upward power change initiated by a power parent
+ void ParentUpSetPowerState_Delayed ( void );
+ IOReturn ParentUpSetPowerState_Immediate ( void );
+ IOReturn ParentUpWaitForSettleTime_Immediate ( void );
+ IOReturn ParentUpNotifyInterestedDriversDidChange_Immediate ( void );
+ void ParentUpWaitForSettleTime_Delayed ( void );
+ void ParentUpNotifyInterestedDriversDidChange_Delayed ( void );
+ void ParentUpAcknowledgePowerChange_Delayed ( void );
+
void all_done ( void );
void all_acked ( void );
void driver_acked ( void );
bool checkForDone ( void );
bool responseValid ( unsigned long x );
IOReturn allowCancelCommon ( void );
+ void computeDesiredState ( void );
+ void rebuildChildClampBits ( void );
};
#endif /* ! _IOKIT_IOSERVICE_H */