This Technote discusses addenda to the Inside Macintosh: Devices, Power Manager Chapter
This Note is intended for Macintosh developers who are using the Power Manager Dispatch routines.
PMFeatures
Startup Time Structure
GetStartupTimer
SetStartupTimer
State Change Notification Queue Structure
PMgrStateQInstall
PMgrStateQRemove
State Change Queue Notification Function
UpdateSystemActivity
GetLastActivity
DelaySystemIdle
hasStartupTimer,hasSetSoundPwr have been added to
the possible PMFeature return values:
| Bit name | Bit number | Description |
|---|---|---|
hasStartupTimer | 10 | The startup timer is supported |
hasSetSoundPwr | 11 | The computer supports sound hardware control |
GetStartupTimer and SetStartupTimer functions
is defined in by the StartupTime data type.
typedef struct StartupTime {
unsigned long startTime; /* startup time as number of seconds since
midnight, January 1, 1904 */
Boolean startEnabled; /* 1=enable timer, 0=disable timer */
SInt8 filler;
} StartupTime;
GetStartupTimer function to find out when the computer will start up from power off mode.
void GetStartupTimer(StartupTime *theTime);
| theTime | A pointer to a StartupTime structure, which specifies whether the timer is enabled or disabled and the time at which the startup timer is set to startup the computer. |
_PowerManagerDispatch ($A09E). The selector value is for GetStartupTimer is 38 ($26) in the low word of register D0. The pointer to StartupTime is passed in register A0.
SetStartupTimerfunction to set the time when the computer will start up from power off mode.
void SetStartupTimer(StartupTime *theTime);
| theTime | A pointer to a StartupTime structure, which specifies whether to enable or disable the timer, and the time at which the startup timer is set to startup the computer. |
_PowerManagerDispatch ($A09E). The selector value is for SetStartupTimer is 39 ($27) in the low word of register D0. The pointer to StartupTime is passed in register A0.
State Change Notification Queue Structure
#define PMgrStateQType 'PM'
struct PMgrQueueElement {
Ptr *pmQLink; /* pointer to next queue element */
short pmQType; /* queue type (must be PMgrStateQType) */
short pmFlags; /* reserved */
long pmNotifyBits; /* bitmap of desired notifications */
StateNotifyProc pmProc; /*pointer to routine to call */
long pmUser; /* user-defined private storage, */
} PMgrQueueElement;
The values of the bits in the pmFlags field are as follows:
| Bit name | Bit number | Description |
|---|---|---|
sleepTimeout | 0 | The sleep timer value has changed. |
sleepEnable | 1 | Sleep control has been enabled/disabled |
hardDiskTimeout | 2 | The hard disk timer has changed. |
hardDiskSpindown | 3 | The hard disk spindown state has changed. |
dimmingTimeout | 4 | The screen dimming timer has changed. |
dimmingEnable | 5 | Screen dimming has been enabled or disabled |
diskModeAddress | 6 | The SCSI disk mode address has changed |
processorCycling | 7 | Processor cycling has been enabled or disabled |
processorSpeed | 8 | The processor speed has changed |
wakeupTimer | 9 | The wakeup timer has changed. |
startupTimer | 10 | The startup timer has changed. |
hdPowerRemoved | 11 | The hard disk power has been removed by the user. |
OSErr PMgrStateQInstall(PMgrStateQElement *theElement);
| theElement | A pointer to an element for the state change notification queue. |
When a requested configuration parameter has changed, the software calls the routine pointed to by the pmProc field so that it can do any special processing. The routine is passed a pointer to its queue element do that, for example, the routine can reference its variables.
Before calling PMgrStateQInstall, the calling program must set the pmQType field to PmgrStateQtype or the queue element wont be added to the queue and PMgrStateQInstall will return an error.
_PowerManagerDispatch ($A09E). The selector value is for PMgrStateQInstall is 34 ($22) in the low word of register D0. The pointer to PMgrStateQElement is passed in register A0. The result code is returned in the low word of register D0.
noErr 0 No error
The application-defined state change notification function is described in "State Change Notification Function"
OSErr PMgrStateQRemove(PMgrStateQElement *theElement);
| theElement | A pointer to the element for the state change notification queue that you wish to remove |
_PowerManagerDispatch ($A09E).The selector value is for PMgrStateQRemove is 35 ($23) in the low word of register D0. The pointer to PMgrStateQElement is passed in register A0. The result code is returned in the low word of register D0.
noErr 0 No error
The application-defined state change notification function is described in "State Change Notification Function"
State Change Notification Function
pascal void MyStateNotificationProc (PMgrStateQElement *theElement);
| theElement | A pointer to the element in the configuration change queue that was used to install this function. |
The PMgrStateQInstall function and the PMgrStateQRemove function.
void UpdateSystemActivity(short activityType);
| activityType | A value indicating the type of activity that has occurred. See the description below for the meaning of this field. |
This function is slightly different from DelaySystemIdle, which should be used to prevent sleep or idle during a critical section. UpdateSystemActivity simply updates the tick count for the activity type selected. Conversely, DelaySystemIdle actually moves the counter to some number of ticks into the future, which allows the caller to go off and do somethingwithout fear of idling.
The valid types of activity are:
| Value name | Value | Description |
|---|---|---|
OverallAct | 0 | general type of activity |
UsrActivity | 1 | User activity (i.e.keyboard or mouse) |
NetActivity | 2 | Interaction with network(s). |
HDActivity | 3 | Hard disk or storage device in use. |
If a device driver registers with the power manager state change queue and implements its own power management timing facilities, it does not need to call UpdateSystemActivity. For example, a media bay hard disk on a PowerBook should register for sleeptimeout, sleepenabled, spindownenabled, and hdtimeout change notificiations. It then can maintain its own timer. This allows the internal hard disk and the media bay hard disk to spin down independently. By not calling UpdateSystemActivity, it wonÕt unnecessarily keep the internal drive powered. It should also be installed in the sleep queue so it can refuse sleep requests if activity is occurring on its associated device.
_PowerManagerDispatch ($A09E). The selector value is for UpdateSystemActivity is 36 ($24) in the low word of register D0. The activityType is passed in the high word of D0.
OSErr GetLastActivity(ActivityInfo *theActivity();
| activityType | A pointer to a ActivityInfo structure, which specifies for a type of activity when that activity last occurred |
struct ActivityInfo {
short activityType; /* same selectors as UpdateSystemActivity */
unsigned long activityTime; /* time of last event of selected type as
number of seconds since midnight,
January 1, 1904 */
} ActivityInfo;
_PowerManagerDispatch ($A09E). The selector value is for GetLastActivity is 40 ($28) in the low word of register D0. The pointer to the ActivityInfo structure is passed in register A0.
void DelaySystemIdle();
_PowerManagerDispatch ($A09E). The selector value is for DelaySystemIdle is 37 ($25) in the low word of register D0.