apm_bios.h revision 3264
1130331Sanholt/* 2145132Sanholt * Advanced Power Management (APM) BIOS driver for laptop PCs. 3145132Sanholt * 4145132Sanholt * Copyright (c) 1994 by HOSOKAWA Tatsumi <hosokawa@mt.cs.keio.ac.jp> 5130331Sanholt * 6130331Sanholt * This software may be used, modified, copied, and distributed, in 7130331Sanholt * both source and binary form provided that the above copyright and 8130331Sanholt * these terms are retained. Under no circumstances is the author 9182080Srnoland * responsible for the proper functioning of this software, nor does 10182080Srnoland * the author assume any responsibility for damages incurred with its 11182080Srnoland * use. 12182080Srnoland * 13182080Srnoland * Aug, 1994 Implemented on FreeBSD 1.1.5.1R (Toshiba AVS001WD) 14182080Srnoland * 15182080Srnoland * $Id$ 16157617Sanholt */ 17145132Sanholt 18157617Sanholt#ifndef _MACHINE_APM_BIOS_H_ 19157617Sanholt#define _MACHINE_APM_BIOS_H_ 1 20157617Sanholt 21157617Sanholt#ifdef KERNEL 22157617Sanholt 23157617Sanholt/* BIOS id */ 24145132Sanholt#define APM_BIOS 0x53 25157617Sanholt#define SYSTEM_BIOS 0x15 26157617Sanholt 27157617Sanholt/* APM flags */ 28145132Sanholt#define APM_16BIT_SUPPORT 0x01 29157617Sanholt#define APM_32BIT_SUPPORT 0x02 30157617Sanholt#define APM_CPUIDLE_SLOW 0x04 31182080Srnoland#define APM_DISABLED 0x08 32145132Sanholt#define APM_DISENGAGED 0x10 33145132Sanholt 34182080Srnoland/* APM initializer physical address */ 35182080Srnoland#define APM_OURADDR 0x00080000 36182080Srnoland 37157617Sanholt/* Error code of APM initializer */ 38157617Sanholt#define APMINI_CANTFIND 0xffffffff 39182080Srnoland#define APMINI_NOT32BIT 0xfffffffe 40182080Srnoland#define APMINI_CONNECTERR 0xfffffffd 41182080Srnoland 42182080Srnoland/* APM functions */ 43182080Srnoland#define APM_INSTCHECK 0x00 44182080Srnoland#define APM_REALCONNECT 0x01 45182080Srnoland#define APM_PROT16CONNECT 0x02 46182080Srnoland#define APM_PROT32CONNECT 0x03 47182080Srnoland#define APM_DISCONNECT 0x04 48182080Srnoland#define APM_CPUIDLE 0x05 49182080Srnoland#define APM_CPUBUSY 0x06 50182080Srnoland#define APM_SETPWSTATE 0x07 51182080Srnoland#define APM_ENABLEDISABLEPM 0x08 52182080Srnoland#define APM_RESTOREDEFAULT 0x09 53182080Srnoland#define APM_GETPWSTATUS 0x0a 54182080Srnoland#define APM_GETPMEVENT 0x0b 55182080Srnoland#define APM_GETPWSTATE 0x0c 56182080Srnoland#define APM_ENABLEDISABLEDPM 0x0d 57182080Srnoland#define APM_DRVVERSION 0x0e 58157617Sanholt#define APM_ENGAGEDISENGAGEPM 0x0f 59182080Srnoland#define APM_OEMFUNC 0x80 60148211Sanholt 61157617Sanholt/* error code */ 62157617Sanholt#define APME_OK 0x00 63148211Sanholt#define APME_PMDISABLED 0x01 64148211Sanholt#define APME_REALESTABLISHED 0x02 65148211Sanholt#define APME_NOTCONNECTED 0x03 66157617Sanholt#define APME_PROT16ESTABLISHED 0x05 67157617Sanholt#define APME_PROT16NOTSUPPORTED 0x06 68182080Srnoland#define APME_PROT32ESTABLISHED 0x07 69182080Srnoland#define APME_PROT32NOTDUPPORTED 0x08 70182080Srnoland#define APME_UNKNOWNDEVICEID 0x09 71182080Srnoland#define APME_OUTOFRANGE 0x0a 72182080Srnoland#define APME_NOTENGAGED 0x0b 73182080Srnoland#define APME_CANTENTERSTATE 0x60 74182080Srnoland#define APME_NOPMEVENT 0x80 75182080Srnoland#define APME_NOAPMPRESENT 0x86 76182080Srnoland 77182080Srnoland 78145132Sanholt/* device code */ 79145132Sanholt#define PMDV_APMBIOS 0x0000 80145132Sanholt#define PMDV_ALLDEV 0x0001 81145132Sanholt#define PMDV_DISP0 0x0100 82145132Sanholt#define PMDV_DISP1 0x0101 83145132Sanholt#define PMDV_2NDSTORAGE0 0x0200 84145132Sanholt#define PMDV_2NDSTORAGE1 0x0201 85152909Sanholt#define PMDV_2NDSTORAGE2 0x0202 86182080Srnoland#define PMDV_2NDSTORAGE3 0x0203 87182080Srnoland#define PMDV_PARALLEL0 0x0300 88182080Srnoland#define PMDV_PARALLEL1 0x0301 89182080Srnoland#define PMDV_SERIAL0 0x0400 90182080Srnoland#define PMDV_SERIAL1 0x0401 91182080Srnoland#define PMDV_SERIAL2 0x0402 92182080Srnoland#define PMDV_SERIAL3 0x0403 93182080Srnoland#define PMDV_SERIAL4 0x0404 94182080Srnoland#define PMDV_SERIAL5 0x0405 95182080Srnoland#define PMDV_SERIAL6 0x0406 96182080Srnoland#define PMDV_SERIAL7 0x0407 97182080Srnoland#define PMDV_NET0 0x0500 98182080Srnoland#define PMDV_NET1 0x0501 99182080Srnoland#define PMDV_NET2 0x0502 100182080Srnoland#define PMDV_NET3 0x0503 101182080Srnoland#define PMDV_PCMCIA0 0x0600 102182080Srnoland#define PMDV_PCMCIA1 0x0601 103182080Srnoland#define PMDV_PCMCIA2 0x0602 104182080Srnoland#define PMDV_PCMCIA3 0x0603 105182080Srnoland/* 0x0700 - 0xdfff Reserved */ 106182080Srnoland/* 0xe000 - 0xefff OEM-defined power device IDs */ 107182080Srnoland/* 0xf000 - 0xffff Reserved */ 108182080Srnoland 109182080Srnoland/* Power state */ 110182080Srnoland#define PMST_APMENABLED 0x0000 111182080Srnoland#define PMST_STANDBY 0x0001 112182080Srnoland#define PMST_SUSPEND 0x0002 113157617Sanholt#define PMST_OFF 0x0003 114157617Sanholt#define PMST_LASTREQNOTIFY 0x0004 115145132Sanholt#define PMST_LASTREQREJECT 0x0005 116145132Sanholt/* 0x0006 - 0x001f Reserved system states */ 117157617Sanholt/* 0x0020 - 0x003f OEM-defined system states */ 118145132Sanholt/* 0x0040 - 0x007f OEM-defined device states */ 119182080Srnoland/* 0x0080 - 0xffff Reserved device states */ 120182080Srnoland 121182080Srnoland#if !defined(ASM) && !defined(INITIALIZER) 122182080Srnoland 123182080Srnoland/* C definitions */ 124182080Srnolandtypedef struct apm_hook_func { 125182080Srnoland struct apm_hook_func *next; /* Linked list */ 126182080Srnoland int (*func)(void); 127182080Srnoland const char *name; 128182080Srnoland int order; 129182080Srnoland} *apm_hook_func_t; 130182080Srnoland 131182080Srnolandapm_hook_func_t apm_resume_hook_init(int (*func)(void), char *name, int order); 132182080Srnolandvoid apm_resume_hook_delete(apm_hook_func_t delete_func); 133182080Srnolandapm_hook_func_t apm_suspend_hook_init(int (*func)(void), char *name, int order); 134182080Srnolandvoid apm_suspend_hook_delete(apm_hook_func_t delete_func); 135182080Srnolandvoid apm_suspend_resume(void); 136182080Srnolandvoid apm_cpu_idle(void); 137182080Srnolandvoid apm_cpu_busy(void); 138182080Srnoland 139182080Srnoland#endif /* !ASM && !INITIALIZER */ 140182080Srnoland 141182080Srnoland#define APM_MIN_ORDER 0x00 142182080Srnoland#define APM_MID_ORDER 0x80 143182080Srnoland#define APM_MAX_ORDER 0xff 144182080Srnoland 145182080Srnoland#endif /* KERNEL */ 146182080Srnoland 147182080Srnoland/* power management event code */ 148182080Srnoland#define PMEV_NOEVENT 0x0000 149182080Srnoland#define PMEV_STANDBYREQ 0x0001 150182080Srnoland#define PMEV_SUSPENDREQ 0x0002 151182080Srnoland#define PMEV_NORMRESUME 0x0003 152182080Srnoland#define PMEV_CRITRESUME 0x0004 153182080Srnoland#define PMEV_BATTERYLOW 0x0005 154182080Srnoland#define PMEV_POWERSTATECHANGE 0x0006 155182080Srnoland#define PMEV_UPDATETIME 0x0007 156182080Srnoland#define PMEV_CRITSUSPEND 0x0008 157182080Srnoland#define PMEV_USERSTANDBYREQ 0x0009 158182080Srnoland#define PMEV_USERSUSPENDREQ 0x000a 159182080Srnoland#define PMEV_STANDBYRESUME 0x000b 160182080Srnoland/* 0x000c - 0x00ff Reserved system events */ 161182080Srnoland/* 0x0100 - 0x01ff Reserved device events */ 162182080Srnoland/* 0x0200 - 0x02ff OEM-defined APM events */ 163182080Srnoland/* 0x0300 - 0xffff Reserved */ 164182080Srnoland#define PMEV_DEFAULT 0xffffffff /* used for customization */ 165182080Srnoland 166182080Srnoland#if !defined(ASM) && !defined(INITIALIZER) 167182080Srnoland 168182080Srnolandtypedef struct apm_info { 169182080Srnoland u_int ai_major; /* APM major version */ 170182080Srnoland u_int ai_minor; /* APM minor version */ 171182080Srnoland u_int ai_acline; /* AC line status */ 172182080Srnoland u_int ai_batt_stat; /* Battery status */ 173182080Srnoland u_int ai_batt_life; /* Remaining battery life */ 174182080Srnoland} *apm_info_t; 175182080Srnoland 176182080Srnolandtypedef struct apm_eqv_event { 177182080Srnoland u_int aee_event; /* Event ID */ 178182080Srnoland u_int aee_equiv; /* Equivalent event ID */ 179182080Srnoland u_int aee_resume; /* Equivalent event ID when system resumes */ 180182080Srnoland} *apm_eqv_event_t; 181182080Srnoland 182182080Srnoland#define APMIO_SUSPEND _IO('P', 1) 183182080Srnoland#define APMIO_GETINFO _IOR('P', 2, struct apm_info) 184182080Srnoland#define APMIO_DEFEQV _IOW('P', 3, struct apm_eqv_event) 185182080Srnoland#define APMIO_FLUSHEQV _IO('P', 4) 186182080Srnoland#define APMIO_ENABLE _IO('P', 5) 187182080Srnoland#define APMIO_DISABLE _IO('P', 6) 188182080Srnoland#define APMIO_HALTCPU _IO('P', 7) 189182080Srnoland#define APMIO_NOTHALTCPU _IO('P', 8) 190182080Srnoland 191182080Srnoland#define APM_MAX_EQUIV_EVENTS 16 192182080Srnoland 193182080Srnoland#endif /* !ASM && !INITIALIZER */ 194182080Srnoland 195182080Srnoland#endif /* _MACHINE_APM_BIOS_H_ */ 196182080Srnoland