![]() Acrobat file (198K) |
![]() ClarisWorks 4 file (48K) |
![]() not available yet |
Technote 1046 | MAY 1996 |
This Note is intended for Macintosh developers who are using the Power
Manager Dispatch routines.
Contents
Bit Name Bit Number Description hasStartupTimer 10 The startup timer is supported.
typedef struct StartupTime { unsigned long startTime; /* startup time as number of seconds since midnight, January 1, 1904*/ Boolean startEnabled; /* 1=enable startup timer, 0=disable timer*/ SInt8 filler; } StartupTime;
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 start up the computer.
If the computer doesn't support the startup timer, GetStartupTimer returns a value of 0.
The trap is _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.
The StartupTime structure is described in Startup Time Structure.
SetStartupTimer
You can use the SetStartupTimer function 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 start up the computer.
The SetStartupTimer function sets the time when the computer will start up from a power off mode and enables or disables the timer. On a computer that doesn't support the startup timer, SetStartupTimer does nothing.
The trap is _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.
The StartupTime structure is described in Startup Time Structure.
State Change Notification Queue Structure
The state change notification queue structure used by the PMgrStateQInstall
and PMgrStateQInstall functions is defined by the PMgrQueueElement data type.
#define PMgrStateQType 'PM' struct PMgrQueueElement { Ptr *pmQLink; /* pointer to next queue element*/ short pmQType; /* queue type (must be PMgrStateQType)*/ short pmFlags; /* as defined below */ 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 so 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 won't be added to the queue and PMgrStateQInstall will return an error.
noErr 0 No error
The application-defined state change notification function is described in State Change Notification Function.
PMgrStateQRemove
You can use the PMgrStateQRemove function to discontinue notification of your
software when Power Manager state configuration parameters have changed.
OSErr PMgrStateQRemove(PMgrStateQElement *theElement); theElement A pointer to the element for the state change notification queue that you wish to remove.
noErr 0 No error
The application-defined state change notification function is described in State Change Notification Function.
State Change Notification Function
A state change notification function can perform any operation that you require
when certain Power Manager state configuration parameters have changed .
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.
UpdateSystemActivity
You can use the UpdateSystemActivity function to notify the Power Manager that
activity has taken place .
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.
GetLastActivity
You can use the GetLastActivity function to find out when the last time a
particular activity took place.
OSErr GetLastActivity(ActivityInfo *theActivity(); theActivity A pointer to an ActivityInfo structure, which specifies the type of activity and 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;
DelaySystemIdle
You can use the DelaySystemIdle function to control power cycling.
void DelaySystemIdle();
Main | Top of Section | What's New | Apple Computer, Inc. | Find It | Feedback | Help