Abstract:
A system for managing power consumption in a personal computer. To date most techniques for managing power consumption in personal computers have been for the purpose of extending battery life of portable computers whose usual source of power is a battery. By providing techniques for managing power consumption in desktop computers as well, whose usual source of power is a 120 volt, 60 Hz. wall connection, substantial savings in electric power consumption are possible due to the large number of computers which are left on for extended periods of time, even when not being actively used. The present invention providing a software and hardware architecture and mechanisms for managing the power consumption of peripheral devices through their device drivers, a global event messaging scheme and power management coordination software.

Description:
BRIEF SUMMARY OF THE INVENTION 
     The present invention is a system for managing power consumption in a personal computer, specifically peripheral devices including the display and other external devices such as disk drives, CD-ROM drives, modems and the like using a power management coordinator. While to date most techniques for managing power consumption in personal computers have been for the purpose of extending battery life of portable computers whose usual source of power is a battery, by providing techniques for managing power consumption in desktop computers as well, whose usual source of power is a 120 volt, 60 Hz. wall connection, substantial savings in electric power consumption are possible due to the large number of computers which are left on for extended periods of time, even when not being actively used. 
     Power consumption management systems, whether present in a portable computer or desktop computer, traditionally rely upon hardware timers which, upon expiration, turn off or reduce power to various system components without informing the operating system which controls the computer. For example, such prior art systems, upon expiration of the hardware timer, generate a system management interrupt (SMI), which shuts down a specific subsystem. The subsystem could even be the processor itself which, once it is turned off, can only be awakened by another hardware generated signal. If the computer is connected to a network, such processor shutdown would result in a loss of the network connection. By utilizing hardware generated events as a power consumption management tool, the operating system is not made aware of such shutdowns. As a result, when the subsystem is awakened, the operating system, being unaware of the shutdown, interacts with the subsystem as if there were no shutdown which can result in inconsistent operation. Additionally, when devices are being turned on and off asynchronously, without coordination, if several devices attempt to power off or on simultaneously, there could be large voltages spikes or sags that adversely impact system reliability. These potential problems are mitigated in portable computer systems where the number of subsystems is limited and known by the system designer who can include necessary safeguards in the system firmware which has intimate knowledge of the hardware under its control. However, in a desktop system, where there may be numerous add-on subsystems such as network cards, CD-ROM controller cards, graphics cards and the like, it is extremely difficult or sometimes impossible to fully provide for power consumption management of all subsystems without providing suitable notification to the operating system which can then coordinate these activities. 
     The present invention addresses these problems by providing a software and hardware architecture for managing the power consumption of peripheral devices through their device drivers, a global event messaging scheme and power management coordination software. 
    
    
     BRIEF DESCRIPTION OF THE DRAWINGS 
     FIG. 1 is a block diagram showing the overall architecture of the invented system. 
     FIG. 2a is a flow diagram showing the flow of the processing performed by an event manager for User --  Idle/User --  Active power events. 
     FIG. 2b is a flow diagram showing the flow of the processing performed by an event manager for Sleep/Wakeup power events. 
     FIG. 2c is a flow diagram showing the flow of the processing performed by an event manager for the OS --  Idle power event. 
     FIG. 3 is a flow diagram showing the flow of a User --  Idle/User --  Active PM handler within a device driver. 
     FIG. 4a is a device state model representing distinct device states and transitions needed by an add-in device/device driver combination to effectively manage power levels. 
     FIG. 4b is a device state model representing distinct device states and transitions needed by an add-in device/device driver combination to effectively manage power levels for a device having self-management capability. 
     FIG. 5a is a flowchart of a PM Coordinator for a power down request. 
     FIG. 5b is a flowchart of a PM Coordinator for a power up request. 
    
    
     DETAILED DESCRIPTION OF THE INVENTION 
     The present invention utilizes the fact that in a computer system, each device driver has the best knowledge for how and when to power its associated device down or up. By defining a set of power events and delivering them to device drivers, each driver can make the decision as to whether that power event should affect its coupled device&#39;s power state. 
     Power events are generated under the following conditions: 
     
         ______________________________________Power Event      Condition______________________________________User.sub.-- Idle      No keyboard or mouse activity for a user      configurable period of timeUser.sub.-- Active      Keyboard or mouse activitySleep      A predefined user input occurs, at a user      configurable timer expiration and/or by a network      generated commandWakeup     A predefined user input, at a user configurable      timer expiration and/or by a network generated      commandOS.sub.-- Idle      CPU cycling in an operating system idle loop______________________________________ 
    
     Device power states and the conditions under which each is active are as follows: 
     
         ______________________________________Power State    Active Condition______________________________________PM.sub.-- Enabled    Device is in use and may be operating at a reduced    power level in a manner which is transparent to the    device userSuspend  Device is not in use and power can be removed without    causing adverse effect on other devicesNormal   Device is in use and operating at full powerStandby  Device is not in use and is operating at a reduced    power levelOff      Power has been removed from device______________________________________ 
    
     Once a driver has determined that a change should be made to its associated device&#39;s power state, the present invention utilizes a coordinating piece of software that decides if it should allow the transition. For example, in the case where the device is on a bus that is powered down, and the device driver is issuing a request to be allowed to power up its associated device, the bus must first be powered-up through the device driver (in this case, a bus driver), before allowing the device to power up. A central power management coordinator (hereinafter PM Coordinator) is used in connection with power sequencing to prevent large power spikes/sags when multiple devices need to power up/down based on the same event. FIG. 1 is an illustration of an architecture for personal computer power management according to the present invention including the PM Coordinator. 
     Power events can be generated by any software running on the system. In most cases they are generated by a device driver on the system board. As previously noted, examples of power events are: User --  Idle, User --  Active, Sleep, Wakeup, and OS --  Idle. The first two are based on keyboard/mouse input. The next two might be created by a sleep button being pushed, a timer being preprogrammed to power down the machine at night, or perhaps by a network broadcast and the last by the operating system itself upon entering an idle loop. Power events are shown in FIG. 1 as being created as a result of more specific system events (e.g., keyboard input, mouse movement, button press, network broadcast, timer expiration) which are input to an event filter 11. Event filter 11 processes these inputs to generate a corresponding power event. The power events generated from event filter 11 are input to event manager 13 which passes the generated power events to device drivers 15. The details of suitable mechanisms for the software generation of the OS --  Idle, User --  Idle, User --  Active, Sleep, and Wakeup power events should be readily apparent to persons skilled in the field of the invention. The event manager 13 is responsible for receiving and passing on power events to each device driver 15. The event manager 13 is a piece of software that is responsible for globally broadcasting certain power events to all device drivers. The event manager acts as a conduit for events, tracking and distributing events to proper destinations as needed. FIGS. 2a-2c are flowcharts which show the processing performed by an event manager 13 according to the present invention for User --  Idle/User --  Active power events (FIG. 2a), Sleep/Wakeup power events (FIG. 2b) and OS --  Idle (FIG. 2c). 
     All device drivers 15 register a callback entry point with event manager 13 for receiving power events from the event manager. This entry point is a PM handler 17 within each device driver that processes the events. 
     The processing performed by each PM handler 17 for User --  Idle/User --  Active power events is shown in FIG. 3. The processing performed by a PM handler for Sleep/Wakeup power events would be essentially the same except that for User --  Idle and User --  Active, an idle/sleep timer is set to a user configurable amount of time, while for the Sleep and Wakeup power events no timer is used. Instead, the Wakeup power event causes the device to wake up immediately, and the Sleep power event causes the device to be put into a lower power state when the device is no longer in use and there are no pending device access requests. 
     It is the responsibility of each PM handler 17 of each device driver 15 to determine if the power event received should affect its coupled device&#39;s power state. Most device drivers use power events such as Sleep and Wakeup to instigate power transitions. Other device drivers, such as video drivers, would also use the User --  Idle and User --  Active events to turn off user output. Once the device driver has determined that the event affects its coupled device&#39;s power state, and that it is safe to start the power transition (i.e. the device is not busy), it requests permission to transition from PM Coordinator 21. 
     PM Coordinator 21 is implemented as software which decides if state transitions for devices which have been requested by their device drivers can be safely initiated, and that they occur in the correct sequence. If, for example, the only device on a bus issues a request to enter the suspend power state, the PM Coordinator might approve the transition, and then tell the bus driver that it can power its bus down. The converse is also true. If a device driver issues a request to power up, there might be another device (such as a bus) that should be powered up first. It is the PM Coordinator&#39;s responsibility to make sure that power transitions occur in the correct sequence, and also that devices do not power up simultaneously, causing voltage spikes/drops. The PM Coordinator is responsible for approving power transition requests from device drivers. The PM Coordinator bases its approval on recovery delays of each device. This delay is provided by the device driver as part of the power change request. The PM Coordinator uses this delay to prevent multiple devices from simultaneously transitioning. The device driver also relays information about the new power level to the PM Coordinator. If the new power state is Suspend, the PM Coordinator may decide to suspend parents of that device such as its expansion bus. Conversely, if a device driver requests a power change, and the parents of that device are suspended, then the PM Coordinator must turn them on first before the device driver can access its associated device. In order for the PM Coordinator to be able to turn off buses, there must be a database tree of power management dependencies which is built by the operating system. The operating system may build this tree by having device drivers of devices to be power managed register their power and child power relationships (i.e., specify all devices who should not have power applied to them until the parent device has had power supplied to it) with the PM coordinator as part of their initialization sequence. 
     Power Management of External Devices 
     Device Driver Modifications For Power Management 
     In addition to providing power management of the CPU, on-board system devices and the display, the details of which may be found in co-pending application Ser. Nos. 08/318,052 and 08/317,912 filed Oct. 4, 1994 both abandoned to achieve maximum power savings, it is also desirable to manage the power of external devices which interface to the system via expansion boards. Such devices include modems, disk drives, CD-ROM drives, tape drives and the like. In general, inasmuch as the CPU, devices on the system board and the display must be fully powered up when the user is actively using the system, power management of these devices is relatively straight forward as compared with external devices which may or may not be in use as a function of user activity. The present invention provides a mechanism for managing the power of these external devices by a centralized decision making software. While such power management can be performed solely at the device driver level, and device drivers are in the best position to know if their associated device is active or ready to change state, there may be some dependencies of that device on another device. There might be a sequence of events that must transpire before the device can change its power state. There could also be issues with several devices simultaneously changing power state which could result in voltage spikes or sags. A centralized decision making component would address these issues, but without more information, such centralized component has no knowledge of the activity of any particular device. The present invention uses an enhanced device driver, i.e., a device driver with a PM handler, to manage the power of its connected device, and the PM Coordinator 21 is used to acknowledge and approve a device driver&#39;s request for a power change. 
     The PM handler 17 is an interface used to pass information to the device driver from the event manager and to/from each device driver 15 and the PM Coordinator 21. This information can be broken into two classes as follows: (1) Event Notifications, and (2) Device Control Command Interface: 
     (1) Event Notifications: 
     Power management according to the invention requires that device drivers be notified about events that may affect its coupled device&#39;s power state. It is the responsibility of the device driver to decide if these events should actually cause it to change the device&#39;s power consumption level. Examples of power events that might be of interest to a device driver are: 
     a) User --  Idle and User --  Active: The User --  Idle and User --  Active power events are passed to the PM handler 17 of a device driver 15 which performs the processing shown in FIG. 3 to determine whether or not to power-up the device, or enter the low power state. 
     b) Sleep: The Sleep power event is used to initiate a global power down. The source of this might be a power button being pushed. Power management aware drivers use this event to transition their devices to a low-power state as soon as possible. 
     c) Wakeup: The Wakeup power event is used to initiate a global power up. The source of this event might be a power button being pushed. Power management-aware device drivers should use this to transition their devices to full-power state as soon as possible. 
     It should be noted that the OS --  Idle power event is not used for power management of external devices as explained below. 
     (2) Device Control Command Interface: 
     Each device driver has an interface for controlling power state changes, getting the device driver&#39;s power management capabilities, and for configuring the coupled device&#39;s capabilities. Once the device driver has determined from a power event that it should change power state, it issues a request to change its device&#39;s power state which is sent to the PM Coordinator. The PM Coordinator calls the device driver through the control command interface/PM handler and grants permission to change the device&#39;s power state. Functions included in the device control command interface or PM handler are as follows: 
     Power Events Broadcast By Event Manager 
     Process Event(): The PM handler associated with each device must have a mechanism for receiving power events from the event manager, i.e., event type (i.e., User --  Idle, User --  Active, Sleep, Wakeup or OS --  Idle). 
     PM Coordinator Calls To PM Handler 
     To process requests from a PM Coordinator, the PM handler must also have the following functionality. 
     GetDeviceCapabilities(): This function is used to determine the capabilities of the device/device driver. This includes information about the device&#39;s auto power management capabilities, power states supported, power consumption in the different states and latency of these states. 
     SetDeviceCapabilities(): This is used to enable/disable any auto power management, set any timeout parameters, and set the lowest power state that the device should transition to. 
     GetPowerState(): This function is used to determine what state the device is currently in. 
     SetPowerState(): This function is used to explicitly set the power state of the device, as well as allow the device to change state per its own request. 
     Driver Call To PM Coordinator 
     To request permission to initiate a change state from a PM Coordinator, the PM handler must initiate the following call. 
     RequestPowerChange(): Once a device driver 15 has determined that its coupled devices power state may be changed as a result of a power event having been sent to its PM handler 17, if a PM Coordinator is in use, the device driver initiates a RequestPowerChange() to the PM Coordinator. 
     To take full advantage of the power management functionality provided by a PM Coordinator, device drivers must have the following features: 
     1) Receive Power Events: All device drivers 15 must register its PM handler 17 callback with the event manager 13 to receive power event messages from the event manager through the Process Event() mechanism. 
     2) Track System Power State: Each device driver must be kept informed of the desired system power state by transmission of power events by the event manager so that it can transparently power its coupled device on and off as needed to complete system accesses and then return to the desired power level of the system. 
     3) Determine Device State change requirements: Once a power event has been received, the device driver must determine if a device power state change is required. If a state change is required (other than transparent transition--i.e. those having little or no transient impact to the system power supply), the device driver must request a power state change from the PM Coordinator it registered with at initialization time. This request should only happen once the device driver has determined that the device is not in use, or that the state change will be transparent to its current usage level. 
     4) Implement Power State Changes: Once permission has been granted by the PM Coordinator, the device driver implements the appropriate state change as configured by the user (see configurability discussion below). 
     5) Auto State Change by Access: If an access to the device is required that would effect the current power state of the device (e.g., an access to a powered-down device), the device driver must request a power state change (similar to steps 3 and 4), effect the state change grant in the coupled device, complete the access and then return to its coupled device&#39;s quiescent state until an external event is received which alters the power state for the system. 
     Each device driver, through its PM handler, provides configurability of its coupled device&#39;s power state. This is the state that the device goes to when a Sleep or User --  Idle event has been received. There can be a different power state configuration for the User --  Idle event than the Sleep event if the user has determined that the latencies for the Sleep event are too large. This difference may be configured by the user based on the power-up latencies which have been determined to be acceptable. There are two options for setting the low power state. 
     a) Set Device Low Power State: The user can select among the externally visible power states that are set forth below, i.e., ON, PM ENABLED, STANDBY, SUSPEND, OFF. FIG. 4a shows the relationships between these power states as power decreases and response latency increases. 
     b) Set Power Up Latency: If the user has determined that a maximum power-up latency is needed based on some time value, the device driver can determine its lowest acceptable power state that still meets the requirements of the user. 
     Most devices support a subset of the above-defined device power states (i.e., SUSPEND, ON, STANDBY and OFF). Some devices also support the PM Enabled power state. 
     ON: On is the fully functional state that requires no software support. This is the normal operating state of the device. 
     PM ENABLED: When a device has auto power management capabilities and these abilities are enabled, it is in the PM Enabled state. In this state, the device and/or device driver can change power levels without any external control. Power transitions within this state are transparent to external software and require no external events. 
     STANDBY: Standby for Auto PM Enabled devices is the lowest power state that the device can auto transition to. An auto PM device is one that is self-managed and can transistion between various power levels as shown in FIG. 4b. Devices (both auto and non-auto PM devices) can also enter this state by receiving an external event such as User --  Idle or Sleep. 
     SUSPEND: In this state, any internal device specific data has been preserved and power can be received from the device. The device can assume that the operating system is not running in a normal fashion and that the device will not be accessed. 
     OFF: In this state the device is non-functional. 
     FIG. 3 is a flowchart showing the processing performed by a device driver modified by including a PM handler to take advantage of the power management techniques of the present invention for User --  Idle/User --  Active power events. The box labeled Process Access Request represents the functionality of the device driver, with the remaining portions of FIG. 3 representing the added functionality of the PM handler for processing a User --  Idle power event. A flowchart for Sleep/Wakeup power events would be similar except that, as noted above, for User --  Idle and User --  Active, an idle/sleep timer is set to a user configurable amount of time, while for the Sleep and Wakeup power events no timer is used. Instead, the Wakeup power event causes the device to wake up immediately, and the Sleep power event causes the device to be put into a lower power state when the device is no longer in use and there are no pending device access requests. (The OS --  Idle power event is not applicable for power management of external devices because the OS --  Idle power event occurs too frequently for external devices to be able to keep up with it in a manner which would be useful for power management.) The details for modifying an existing device driver to include the above-described functions should be readily apparent to persons skilled in the field of the invention from this description and FIG. 3. 
     Power Management Coordinator 
     Power management of expansion devices, i.e., peripherals other than the display monitor such as disk drive controllers, modem cards, LAN cards and other controller cards which plug into expansion slots of a personal computer can be accomplished by requiring that all devices request power transitions through the PM Coordinator which is responsible for receiving these requests and determining when the requested transition can take place. The PM Coordinator has the following responsibilities: a) receive device power management change requests; b) determine power-up sequencing based on hardware hierarchy; c) determine power-up sequencing based on transient power sink/recovery time; d) determine power down sequencing based on hardware hierarchy; e) determine power down sequencing based on transient power sink/recovery time; f) send device power management state change grants. 
     A. Receive Device Power Management Change Requests (RequestPowerChange()) 
     The PM Coordinator receives all power state change requests from device driver&#39;s associated PM handler. All device drivers must request permission to change their associated device&#39;s power state if the state change is determined to have a significant transient power supply impact. These requests are sent through the PM Coordinator&#39;s API (application program interface) callback provided to the device drivers when they register with the PM coordinator at system initialization. 
     The PM Coordinator decides whether or not to allow the requested state change depending on the requirements of the device. If the requested state change is to the ON state, the PM Coordinator checks all devices which must have power supplied to them in order for the requesting device to operate. The devices which must be checked are determined by a power management hardware tree that is a hierarchical data structure built-up by the operating system at system initialization time. Each device in the hierarchical tree above the requesting device is checked until a device which is in the ON state is reached. At this point, if enough power is available to turn all the necessary devices to the ON state, the request is granted by calling the SetPowerState() function in the PM handler for the device. If the requested change is to the OFF state or other less than full power state, the device below the requesting device in the hierarchical tree is checked to see if it needs power. If it does need power, since that power would be removed if power to the requesting device is turned off, the request is denied, otherwise the request is granted. The power state of only one device below the requesting device needs to be checked since if it is ON, power to the requesting device must be maintained for that device and if it is OFF, all devices lower in the hierarchical chain must also be in the OFF power state. 
     The hardware hierarchy tree contains Bus ID, Device ID, Device Type for each device. The specifics of how the device hierarchy tree is built is known to persons skilled in the art since device hierarchy trees are built by existing operating systems such as Windows NT. 
     B. Determine Power Up Sequencing Based On Hardware Hierarchy 
     Before allowing any device to power up, the PM Coordinator must determine that the device is currently accessible by hardware. The PM Coordinator makes this determination by looking at the power management hierarchy tree. If the PM Coordinator determines that the governing power and/or clocks to the device in question are themselves stopped or powered down, such as a bus directly in front of the device, then the PM Coordinator interrogates the hierarchy tree from the top down to the device telling each to wake up until the device in question is reached. 
     C. Determine Power Up Sequencing Based On Transient Power Sink/Recovery Time 
     If several devices issue a request to power up simultaneously, voltage sags can occur that could create problems for the system. Therefore, the PM Coordinator must know several things about the devices it is controlling. The PM Coordinator must know the power sink change that will occur by the transition, and the time period in which power change effects will dampen out. This information is obtained from the PM handler by the GetDeviceCapabilities() function. If the PM Coordinator calculates that the power change exceeds a threshold determined by the system power supply, then it will delay by the power time period provided by the device before allowing other devices to also transition. 
     D. Determine Power Down Sequencing Based On Hardware Hierarchy 
     When the PM Coordinator receives a power down request from a device driver, it grants permission to that driver subject to any power drop sequencing requirements. Once permission has been granted, the PM Coordinator can go up the power management hardware tree to determine if the next higher device can also be powered down. The PM Coordinator determines if there are any devices still dependent on this device and if it is safe to power it down. Each higher branch must have a list of the resources that it provides to the lower branches. Also each lower branch must maintain data on what resources it requires. Once it has been determined that certain resources are not required by any lower branches, they can be selectively turned off. 
     E. Determine Power Down Sequencing Based On Transient Power Sink/Recovery Time 
     If several devices issue requests to power down simultaneously, voltage spikes can occur that could create problems for the system. Therefore, the PM Coordinator must know several things about the device it is controlling. The PM Coordinator must know the power surge change that will occur by the transition, and the time period in which power change&#39;s effects will dampen out. This information is obtained from the PM handler by the GetDeviceCapabilities() function. If the PM Coordinator calculates that the power change exceeds a threshold determined by the system power supply, then it will delay by the power time period provided by the device before allowing other devices to also transition. 
     F. Send Device Power Management State Change Grants (SetPowerState()) 
     Once the PM Coordinator has determined that a device should be allowed to change its power state, it sends permission through the device driver&#39;s PM handler described above. 
     FIG. 5a is a flowchart of a PM Coordinator for handling a power down request as described above. FIG. 5b is a flowchart of a PM Coordinator for handling a power-up request as described above. Based upon the foregoing descriptions and requirements, a person skilled in the field of the invention can easily create a suitable PM Coordinator program for any given personal computer system based on the description provided herein.