Annotation of kernel/kern/power.h, revision 1.1

1.1     ! root        1: /*
        !             2:  * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
        !             3:  *
        !             4:  * @APPLE_LICENSE_HEADER_START@
        !             5:  * 
        !             6:  * Portions Copyright (c) 1999 Apple Computer, Inc.  All Rights
        !             7:  * Reserved.  This file contains Original Code and/or Modifications of
        !             8:  * Original Code as defined in and that are subject to the Apple Public
        !             9:  * Source License Version 1.1 (the "License").  You may not use this file
        !            10:  * except in compliance with the License.  Please obtain a copy of the
        !            11:  * License at http://www.apple.com/publicsource and read it before using
        !            12:  * this file.
        !            13:  * 
        !            14:  * The Original Code and all software distributed under the License are
        !            15:  * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
        !            16:  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
        !            17:  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
        !            18:  * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
        !            19:  * License for the specific language governing rights and limitations
        !            20:  * under the License.
        !            21:  * 
        !            22:  * @APPLE_LICENSE_HEADER_END@
        !            23:  */
        !            24: 
        !            25: /*
        !            26:  * Copyright 1994 NeXT Computer, Inc.
        !            27:  * All rights reserved.
        !            28:  */
        !            29: 
        !            30: #import <mach/mach_types.h>
        !            31: #import <mach/error.h>
        !            32: 
        !            33: /*
        !            34:  * Power Management (PM) kernel interface.
        !            35:  */
        !            36: 
        !            37: #define        pm_err(errno)           (err_kern|err_sub(4000)|errno)
        !            38: 
        !            39: typedef enum {
        !            40:     PM_R_SUCCESS       = 0x00,
        !            41:     PM_R_DISABLED      = pm_err(0x01),  // power management disabled
        !            42:     PM_R_CONNECTED     = pm_err(0x02),  // interface already connected
        !            43:     PM_R_NOT_CONNECTED         = pm_err(0x03),  // interface not connected
        !            44:     PM_R_BAD_ID                = pm_err(0x09),  // unrecognized device ID
        !            45:     PM_R_BAD_VALUE     = pm_err(0x0a),  // parameter value out of range
        !            46:     PM_R_BAD_STATE     = pm_err(0x60),  // can't enter requested state
        !            47:     PM_R_NO_EVENT      = pm_err(0x80),  // no power events pending
        !            48:     PM_R_NO_PM         = pm_err(0x86),  // PM not present
        !            49:     PM_R_UNSUPPORTED   = pm_err(0x100), // unsupported function call
        !            50:     PM_R_UNKNOWN       = pm_err(0x101)  // unknown error from hardware
        !            51: } PMReturn;
        !            52: 
        !            53: typedef enum {
        !            54:     PM_CPU_IDLE,
        !            55:     PM_CPU_BUSY
        !            56: } PMCpuState;
        !            57: 
        !            58: typedef enum {
        !            59:     PM_READY           = 0x00,         // PM enabled, full power
        !            60:     PM_STANDBY         = 0x01,         // Standby mode
        !            61:     PM_SUSPENDED       = 0x02,         // Suspend mode
        !            62:     PM_OFF             = 0x03          // Off completely
        !            63: } PMPowerState;
        !            64: 
        !            65: typedef enum {
        !            66:     PM_SYSTEM          = 0x00,
        !            67:     PM_DISPLAY         = 0x01,
        !            68:     PM_STORAGE         = 0x02,
        !            69:     PM_PARALLEL                = 0x03,
        !            70:     PM_SERIAL          = 0x04,
        !            71:     PM_NETWORK         = 0x05,
        !            72:     PM_PCMCIA          = 0x06
        !            73: } PMDeviceType;
        !            74: 
        !            75: typedef struct {
        !            76:     unsigned int       deviceNumber    :16;
        !            77:     PMDeviceType       deviceType      :16;
        !            78: } PMDeviceID;
        !            79: 
        !            80: /*
        !            81:  * Note: the entire computer is referred to as device type PM_SYSTEM,
        !            82:  * device number 1.
        !            83:  */
        !            84: #define PM_SYSTEM_DEVICE ((PMDeviceID){1, PM_SYSTEM})
        !            85: 
        !            86: typedef enum {
        !            87:     PM_STANDBY_REQUEST         = 0x01,
        !            88:     PM_SUSPEND_REQUEST         = 0x02,
        !            89:     PM_NORMAL_RESUME           = 0x03,
        !            90:     PM_CRITICAL_RESUME         = 0x04,
        !            91:     PM_BATTERY_LOW             = 0x05,
        !            92:     PM_POWER_STATUS_CHANGE     = 0x06,
        !            93:     PM_UPDATE_TIME             = 0x07,
        !            94:     PM_CRITICAL_SUSPEND                = 0x08,
        !            95:     PM_USER_STANDBY_REQUEST    = 0x09,
        !            96:     PM_USER_SUSPEND_REQUEST    = 0x0a,
        !            97:     PM_STANDBY_RESUME          = 0x0b
        !            98: } PMPowerEvent;
        !            99: 
        !           100: typedef enum {
        !           101:     PM_LINE_OFFLINE    = 0x00,
        !           102:     PM_LINE_ONLINE     = 0x01,
        !           103:     PM_LINE_BACKUP     = 0x02,
        !           104:     PM_LINE_UNKNOWN    = 0xFF
        !           105: } PMLineStatus;
        !           106: 
        !           107: typedef enum {
        !           108:     PM_BATT_HIGH       = 0x00,
        !           109:     PM_BATT_LOW                = 0x01,
        !           110:     PM_BATT_CRITICAL   = 0x02,
        !           111:     PM_BATT_CHARGING   = 0x03,
        !           112:     PM_BATT_UNKNOWN    = 0xFF
        !           113: } PMBatteryStatus;
        !           114: 
        !           115: typedef struct {
        !           116:     PMLineStatus       lineStatus;
        !           117:     PMBatteryStatus    batteryStatus;
        !           118:     int                        batteryLife;
        !           119: } PMPowerStatus;
        !           120: 
        !           121: typedef enum {
        !           122:     PM_DISABLED,
        !           123:     PM_ENABLED
        !           124: } PMPowerManagementState;
        !           125: 
        !           126: 
        !           127: #ifdef KERNEL
        !           128: 
        !           129: #define MARK_CPU_IDLE(mycpu)   PMSetCpuState(PM_CPU_IDLE)
        !           130: #define MARK_CPU_ACTIVE(mycpu) PMSetCpuState(PM_CPU_BUSY)
        !           131: 
        !           132: /*
        !           133:  * Initialize PM support.  Returns TRUE if PM is available.
        !           134:  */
        !           135: PMReturn PMConnect(void);
        !           136: 
        !           137: /*
        !           138:  * Return PM control to previous user (probably the BIOS).
        !           139:  * Normally this will never be called.
        !           140:  */
        !           141: PMReturn PMDisconnect(void);
        !           142: 
        !           143: /*
        !           144:  * Inform PM of the CPU state.  If the CPU is idle, PM may
        !           145:  * put the CPU in a power-saving state until the next system event
        !           146:  * (typically an interrupt).  Marking the CPU busy will ensure
        !           147:  * that the CPU is running at full speed.
        !           148:  */
        !           149: PMReturn PMSetCpuState(PMCpuState state);
        !           150: 
        !           151: /*
        !           152:  * Update current kernel clock from real-time clock.
        !           153:  */
        !           154: void PMUpdateClock(void);
        !           155: 
        !           156: /*
        !           157:  * Set the power state of a device or the entire computer.
        !           158:  */
        !           159: PMReturn PMSetPowerState(PMDeviceID device, PMPowerState state);
        !           160: 
        !           161: /*
        !           162:  * Get a power event from PM, if one has occurred.
        !           163:  */
        !           164: PMReturn PMGetPowerEvent(PMPowerEvent *event);
        !           165: 
        !           166: /*
        !           167:  * Get the power state of the computer.
        !           168:  */
        !           169: PMReturn PMGetPowerStatus(PMPowerStatus *status);
        !           170: 
        !           171: /*
        !           172:  * Enable or disable power management by the computer.
        !           173:  * If enable == PM_ENABLED, the computer can take power saving steps
        !           174:  * when the CPU state is idle.  If enable == PM_DISABLED, no automatic
        !           175:  * power saving steps will be taken and power management functions
        !           176:  * will be disabled.
        !           177:  */
        !           178: PMReturn PMSetPowerManagement(PMDeviceID device,
        !           179:                                PMPowerManagementState state);
        !           180: 
        !           181: /*
        !           182:  * Restores the default settings for all power management settings.
        !           183:  */
        !           184: PMReturn PMRestoreDefaults(void);
        !           185: 
        !           186: #else  /* KERNEL */
        !           187: 
        !           188: /*
        !           189:  * Set the power state of a device or the entire computer.
        !           190:  */
        !           191: kern_return_t _PMSetPowerState(
        !           192:     host_t             host,
        !           193:     PMDeviceID                 device,
        !           194:     PMPowerState       state);
        !           195: 
        !           196: /*
        !           197:  * Get a power event from PM, if one has occurred.
        !           198:  */
        !           199: kern_return_t _PMGetPowerEvent(
        !           200:     host_t             host,
        !           201:     PMPowerEvent       *event);
        !           202: 
        !           203: /*
        !           204:  * Get the power state of the computer.
        !           205:  */
        !           206: kern_return_t _PMGetPowerStatus(
        !           207:     host_t             host,
        !           208:     PMPowerStatus      *status);
        !           209: 
        !           210: /*
        !           211:  * Enable or disable power management by the computer.
        !           212:  * If enable == PM_ENABLED, the computer can take power saving steps
        !           213:  * when the CPU state is idle.  If enable == PM_DISABLED, no automatic
        !           214:  * power saving steps will be taken and power management functions
        !           215:  * will be disabled.
        !           216:  */
        !           217: kern_return_t _PMSetPowerManagement(
        !           218:     host_t             host,
        !           219:     PMDeviceID                 device,
        !           220:     PMPowerManagementState state);
        !           221: 
        !           222: /*
        !           223:  * Restores the default settings for all power management settings.
        !           224:  */
        !           225: kern_return_t _PMRestoreDefaults(
        !           226:     host_t             host);
        !           227: 
        !           228: 
        !           229: #endif /* KERNEL */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.