1 /* 2 * Advanced Power Management (APM) BIOS driver for laptop PCs. 3 * 4 * Copyright (c) 1994 by HOSOKAWA Tatsumi <hosokawa@mt.cs.keio.ac.jp> 5 * 6 * This software may be used, modified, copied, and distributed, in 7 * both source and binary form provided that the above copyright and 8 * these terms are retained. Under no circumstances is the author 9 * responsible for the proper functioning of this software, nor does 10 * the author assume any responsibility for damages incurred with its 11 * use. 12 * 13 * Aug, 1994 Implemented on FreeBSD 1.1.5.1R (Toshiba AVS001WD) 14 * 15 * $Id: apm_bios.h,v 1.2 1994/10/01 05:13:36 davidg Exp $ 16 */ 17 18 #ifndef _MACHINE_APM_BIOS_H_ 19 #define _MACHINE_APM_BIOS_H_ 1 20 21 #ifdef KERNEL 22 23 /* BIOS id */ 24 #define APM_BIOS 0x53 25 #define SYSTEM_BIOS 0x15 26 27 /* APM flags */ 28 #define APM_16BIT_SUPPORT 0x01 29 #define APM_32BIT_SUPPORT 0x02 30 #define APM_CPUIDLE_SLOW 0x04 31 #define APM_DISABLED 0x08 32 #define APM_DISENGAGED 0x10 33 34 /* APM initializer physical address */ 35 #define APM_OURADDR 0x00080000 36 37 /* Error code of APM initializer */ 38 #define APMINI_CANTFIND 0xffffffff 39 #define APMINI_NOT32BIT 0xfffffffe 40 #define APMINI_CONNECTERR 0xfffffffd 41 42 /* APM functions */ 43 #define APM_INSTCHECK 0x00 44 #define APM_REALCONNECT 0x01 45 #define APM_PROT16CONNECT 0x02 46 #define APM_PROT32CONNECT 0x03 47 #define APM_DISCONNECT 0x04 48 #define APM_CPUIDLE 0x05 49 #define APM_CPUBUSY 0x06 50 #define APM_SETPWSTATE 0x07 51 #define APM_ENABLEDISABLEPM 0x08 52 #define APM_RESTOREDEFAULT 0x09 53 #define APM_GETPWSTATUS 0x0a 54 #define APM_GETPMEVENT 0x0b 55 #define APM_GETPWSTATE 0x0c 56 #define APM_ENABLEDISABLEDPM 0x0d 57 #define APM_DRVVERSION 0x0e 58 #define APM_ENGAGEDISENGAGEPM 0x0f 59 #define APM_OEMFUNC 0x80 60 61 /* error code */ 62 #define APME_OK 0x00 63 #define APME_PMDISABLED 0x01 64 #define APME_REALESTABLISHED 0x02 65 #define APME_NOTCONNECTED 0x03 66 #define APME_PROT16ESTABLISHED 0x05 67 #define APME_PROT16NOTSUPPORTED 0x06 68 #define APME_PROT32ESTABLISHED 0x07 69 #define APME_PROT32NOTDUPPORTED 0x08 70 #define APME_UNKNOWNDEVICEID 0x09 71 #define APME_OUTOFRANGE 0x0a 72 #define APME_NOTENGAGED 0x0b 73 #define APME_CANTENTERSTATE 0x60 74 #define APME_NOPMEVENT 0x80 75 #define APME_NOAPMPRESENT 0x86 76 77 78 /* device code */ 79 #define PMDV_APMBIOS 0x0000 80 #define PMDV_ALLDEV 0x0001 81 #define PMDV_DISP0 0x0100 82 #define PMDV_DISP1 0x0101 83 #define PMDV_2NDSTORAGE0 0x0200 84 #define PMDV_2NDSTORAGE1 0x0201 85 #define PMDV_2NDSTORAGE2 0x0202 86 #define PMDV_2NDSTORAGE3 0x0203 87 #define PMDV_PARALLEL0 0x0300 88 #define PMDV_PARALLEL1 0x0301 89 #define PMDV_SERIAL0 0x0400 90 #define PMDV_SERIAL1 0x0401 91 #define PMDV_SERIAL2 0x0402 92 #define PMDV_SERIAL3 0x0403 93 #define PMDV_SERIAL4 0x0404 94 #define PMDV_SERIAL5 0x0405 95 #define PMDV_SERIAL6 0x0406 96 #define PMDV_SERIAL7 0x0407 97 #define PMDV_NET0 0x0500 98 #define PMDV_NET1 0x0501 99 #define PMDV_NET2 0x0502 100 #define PMDV_NET3 0x0503 101 #define PMDV_PCMCIA0 0x0600 102 #define PMDV_PCMCIA1 0x0601 103 #define PMDV_PCMCIA2 0x0602 104 #define PMDV_PCMCIA3 0x0603 105 /* 0x0700 - 0xdfff Reserved */ 106 /* 0xe000 - 0xefff OEM-defined power device IDs */ 107 /* 0xf000 - 0xffff Reserved */ 108 109 /* Power state */ 110 #define PMST_APMENABLED 0x0000 111 #define PMST_STANDBY 0x0001 112 #define PMST_SUSPEND 0x0002 113 #define PMST_OFF 0x0003 114 #define PMST_LASTREQNOTIFY 0x0004 115 #define PMST_LASTREQREJECT 0x0005 116 /* 0x0006 - 0x001f Reserved system states */ 117 /* 0x0020 - 0x003f OEM-defined system states */ 118 /* 0x0040 - 0x007f OEM-defined device states */ 119 /* 0x0080 - 0xffff Reserved device states */ 120 121 #if !defined(ASM) && !defined(INITIALIZER) 122 123 /* C definitions */ 124 typedef struct apm_hook_func { 125 struct apm_hook_func *next; /* Linked list */ 126 int (*func)(void); 127 const char *name; 128 int order; 129 } *apm_hook_func_t; 130 131 apm_hook_func_t apm_resume_hook_init(int (*func)(void), char *name, int order); 132 void apm_resume_hook_delete(apm_hook_func_t delete_func); 133 apm_hook_func_t apm_suspend_hook_init(int (*func)(void), char *name, int order); 134 void apm_suspend_hook_delete(apm_hook_func_t delete_func); 135 void apm_suspend_resume(void); 136 void apm_cpu_idle(void); 137 void apm_cpu_busy(void); 138 139 #endif /* !ASM && !INITIALIZER */ 140 141 #define APM_MIN_ORDER 0x00 142 #define APM_MID_ORDER 0x80 143 #define APM_MAX_ORDER 0xff 144 145 #endif /* KERNEL */ 146 147 /* power management event code */ 148 #define PMEV_NOEVENT 0x0000 149 #define PMEV_STANDBYREQ 0x0001 150 #define PMEV_SUSPENDREQ 0x0002 151 #define PMEV_NORMRESUME 0x0003 152 #define PMEV_CRITRESUME 0x0004 153 #define PMEV_BATTERYLOW 0x0005 154 #define PMEV_POWERSTATECHANGE 0x0006 155 #define PMEV_UPDATETIME 0x0007 156 #define PMEV_CRITSUSPEND 0x0008 157 #define PMEV_USERSTANDBYREQ 0x0009 158 #define PMEV_USERSUSPENDREQ 0x000a 159 #define PMEV_STANDBYRESUME 0x000b 160 /* 0x000c - 0x00ff Reserved system events */ 161 /* 0x0100 - 0x01ff Reserved device events */ 162 /* 0x0200 - 0x02ff OEM-defined APM events */ 163 /* 0x0300 - 0xffff Reserved */ 164 #define PMEV_DEFAULT 0xffffffff /* used for customization */ 165 166 #if !defined(ASM) && !defined(INITIALIZER) 167 168 typedef struct apm_info { 169 u_int ai_major; /* APM major version */ 170 u_int ai_minor; /* APM minor version */ 171 u_int ai_acline; /* AC line status */ 172 u_int ai_batt_stat; /* Battery status */ 173 u_int ai_batt_life; /* Remaining battery life */ 174 } *apm_info_t; 175 176 177 #define APMIO_SUSPEND _IO('P', 1) 178 #define APMIO_GETINFO _IOR('P', 2, struct apm_info) 179 #define APMIO_ENABLE _IO('P', 5) 180 #define APMIO_DISABLE _IO('P', 6) 181 #define APMIO_HALTCPU _IO('P', 7) 182 #define APMIO_NOTHALTCPU _IO('P', 8) 183 184 #endif /* !ASM && !INITIALIZER */ 185 186 #endif /* _MACHINE_APM_BIOS_H_ */ 187