Placing a Routine in the Sleep Queue
If you want your routine to be notified before the Power Manager puts the Macintosh Portable into the sleep state or returns it to the operating state, you
must put an entry in the sleep queue. If you do place an entry in the sleep queue,
remember to remove it before your device driver or application terminates.
The sleep queue is a standard operating-system queue. See QElem for more information.
The sleepQLink field contains a pointer to the next element in the queue. This pointer is maintained by the Power Manager; your application should not modify this field.
The sleepQType field indicates the type of the queue, which must be the constant slpQType (16).
The sleepQProc field contains a pointer to the routine that you provide. The sleepQFlags field is reserved for use by Apple.
To add an entry to the sleep queue, fill in the sleepQType and sleepQProc, and
sleepQFlags fields of a sleep queue record and then execute the SleepQInstall procedure. The SleepQInstall procedure takes one parameter, a pointer to your sleep queue record. The following example adds an entry to the sleep
queue.
Adding an entry to the sleep queue
// Assuming Inclusion of MacHeaders
#include <Power.h>
// Prototype addition routine like this prior to calling it
void MyAddEntrytoSleepQ(void);
void MyAddEntrytoSleepQ()
{
// prototype for your SleepRtn, it is typically written in Assembly since
// it needs to access D0 directly
long MySleepRtn(void);
// set up the record before installing onto the sleep queue
myRec.sleepQLink = 0;
myRec.sleepQType = slpQType; // sleep queue type, 16 myRec.sleepQProc = &MySleepRtn; // address of some sleep routine
myRec.sleepQFlags = 0; [TOKEN:12079] reserved field
}
To remove your routine from the sleep queue, use the SleepQRemove procedure. This procedure also takes as its one parameter a pointer to your
sleep queue record.