Previous Book Contents Book Index Next

Inside Macintosh: Devices /

Chapter 6 - Power Manager

This chapter describes the Power Manager, the part of the Macintosh Operating System that controls power to the internal hardware devices of battery-powered Macintosh computers (such as the Macintosh Portable, the Macintosh PowerBook computers, and the Macintosh Duo computers)

The Power Manager automatically shuts off power to internal devices to conserve power whenever the computer has not been used for a predetermined amount of time. In addition, the Power Manager allows your application or other software to

Most applications do not need to know whether they are executing on a battery-powered Macintosh computer because the transition between power states is largely invisible. As a result, most applications do not need to use Power Manager routines. You need the information in this chapter only if you are writing a program--such as a device driver--that must control power to some subsystem of a battery-powered Macintosh computer or that might be affected by the idle or sleep state. See "About the Power Manager," beginning on page 6-4, for a complete description of these power conservation states.

The Power Manager is available only in system software version 6.0.4 and later versions. You should use the Gestalt function to determine whether the Power Manager is available before calling it. See "Determining Whether the Power Manager Is Present," on page 6-14, for more information.

To use this chapter, you might need to be familiar with techniques for accessing information in your application's A5 world. The chapter "Introduction to Memory Management" in Inside Macintosh: Memory describes the A5 world and the routines you can use to manipulate the A5 register. This chapter provides complete code samples that illustrate how to access your application's A5 world in a sleep procedure. If you wish to display a dialog box from a sleep procedure, you also need to know about the Dialog Manager. See the chapter "Dialog Manager" in Inside Macintosh: Macintosh Toolbox Essentials.

This chapter begins with a preliminary description of the power conservation states controlled by the Power Manager and of the relationship between the power management hardware and software in portable Macintosh computers. It then discusses the power conservation states and the sleep queue in greater detail. The section "Using the Power Manager," beginning on page 6-13, describes how to use Power Manager routines to control the power conservation states and how to write and install sleep procedures.

The reference section is divided into three sections. The first section describes the data structures used by Power Manager routines. The second section, "Power Manager Routines," beginning on page 6-28, describes low-level Power Manager routines that you can use to control a variety of Power Manager functions. The third section, "Power Manager Dispatch Routines," beginning on page 6-40, describes high-level Power Manager routines that isolate you from the need to read or write directly to the Power Manager's private data structures and to parameter RAM. The Power Manager dispatch routines provide access to most of the Power Manager's internal parameters. Where a Power Manager dispatch routine duplicates the function of another Power Manager routine, the dispatch routine provides the preferred interface.

Whereas the Pascal programming language interface is used to describe the Power Manager routines in "Power Manager Routines," the C language interface is used for the newer routines described in "Power Manager Dispatch Routines." The section "Summary of the Power Manager," beginning on page 6-67, includes both Pascal and C interfaces for both sets of routines.

Chapter Contents
About the Power Manager
The Power-Saver State
The Idle State
The Sleep State
The Sleep Queue
Sleep Requests
Sleep Demands
Wakeup Demands
Sleep-Request Revocations
Power Manager Dispatch
Using the Power Manager
Determining Whether the Power Manager Is Present
Determining Whether the Power Manager Dispatch Routines are Present
Enabling or Disabling the Idle State
Setting, Disabling, and Reading the Wakeup Timer
Installing a Sleep Procedure
Using Application Global Variables in Sleep Procedures
Writing a Sleep Procedure
Switching Serial Power On and Off
Monitoring the Battery and Battery Charger
Power Manager Reference
Data Structures
Sleep Queue Record
Hard Disk Queue Structure
Wakeup Time Structure
Battery Information Structure
Battery Time Structure
Power Manager Routines
Controlling the Idle State
Controlling and Reading the Wakeup Timer
Controlling the Sleep Queue
Controlling Serial Power
Reading the Status of the Internal Modem
Reading the Status of the Battery and the Battery Charger
Power Manager Dispatch Routines
Determining the Power Manager Features Available
Controlling the Sleep and Wakeup Timers
Controlling the Dimming Timer
Controlling the Hard Disk
Getting Information About the Internal Batteries
Controlling the Internal Modem
Controlling the Processor
Getting and Setting the SCSI ID
Application-Defined Routines
Sleep Procedures
Hard Disk Spindown Function
Summary of the Power Manager
Pascal Summary
Data Types
Power Manager Routines
Power Manager Dispatch Routines
Application-Defined Routines
C Summary
Constants and Data Types
Power Manager Functions
Power Manager Dispatch Functions
Application-Defined Functions
Assembly-Language Summary
Data Structures
Trap Macros
Result Codes

Previous Book Contents Book Index Next

© Apple Computer, Inc.
3 JUL 1996