apm_bios.h revision 139790
1139790Simp/*- 26512Sphk * APM (Advanced Power Management) BIOS Device Driver 33263Sdg * 46512Sphk * Copyright (c) 1994-1995 by HOSOKAWA, Tatsumi <hosokawa@mt.cs.keio.ac.jp> 56512Sphk * 63263Sdg * This software may be used, modified, copied, and distributed, in 73263Sdg * both source and binary form provided that the above copyright and 88876Srgrimes * these terms are retained. Under no circumstances is the author 98876Srgrimes * responsible for the proper functioning of this software, nor does 108876Srgrimes * the author assume any responsibility for damages incurred with its 113263Sdg * use. 123263Sdg * 133263Sdg * Aug, 1994 Implemented on FreeBSD 1.1.5.1R (Toshiba AVS001WD) 143264Sdg * 1550477Speter * $FreeBSD: head/sys/i386/include/apm_bios.h 139790 2005-01-06 22:18:23Z imp $ 163263Sdg */ 173263Sdg 1818444Sbde#ifndef _MACHINE_APM_BIOS_H_ 1918444Sbde#define _MACHINE_APM_BIOS_H_ 203263Sdg 2155205Speter#ifndef _KERNEL 2218444Sbde#include <sys/types.h> 2318444Sbde#endif 2418444Sbde#include <sys/ioccom.h> 2518444Sbde 263263Sdg/* BIOS id */ 2718265Sasami#ifdef PC98 2818265Sasami#define APM_BIOS 0x9a 2949197Smsmith#define APM_INT 0x1f 3018265Sasami#else 313263Sdg#define APM_BIOS 0x53 3249197Smsmith#define APM_INT 0x15 3318265Sasami#endif 343263Sdg 353263Sdg/* APM flags */ 363263Sdg#define APM_16BIT_SUPPORT 0x01 373263Sdg#define APM_32BIT_SUPPORT 0x02 383263Sdg#define APM_CPUIDLE_SLOW 0x04 393263Sdg#define APM_DISABLED 0x08 403263Sdg#define APM_DISENGAGED 0x10 413263Sdg 423263Sdg/* APM initializer physical address */ 433263Sdg#define APM_OURADDR 0x00080000 443263Sdg 453263Sdg/* APM functions */ 463263Sdg#define APM_INSTCHECK 0x00 473263Sdg#define APM_REALCONNECT 0x01 483263Sdg#define APM_PROT16CONNECT 0x02 493263Sdg#define APM_PROT32CONNECT 0x03 503263Sdg#define APM_DISCONNECT 0x04 513263Sdg#define APM_CPUIDLE 0x05 523263Sdg#define APM_CPUBUSY 0x06 533263Sdg#define APM_SETPWSTATE 0x07 543263Sdg#define APM_ENABLEDISABLEPM 0x08 553263Sdg#define APM_RESTOREDEFAULT 0x09 5623580Skato#ifdef PC98 5723580Skato#define APM_GETPWSTATUS 0x3a 5823580Skato#else 593263Sdg#define APM_GETPWSTATUS 0x0a 6023580Skato#endif 613263Sdg#define APM_GETPMEVENT 0x0b 623263Sdg#define APM_GETPWSTATE 0x0c 633263Sdg#define APM_ENABLEDISABLEDPM 0x0d 6423580Skato#ifdef PC98 6523580Skato#define APM_DRVVERSION 0x3e 6623580Skato#else 673263Sdg#define APM_DRVVERSION 0x0e 6823580Skato#endif 693263Sdg#define APM_ENGAGEDISENGAGEPM 0x0f 7037414Simp#define APM_GETCAPABILITIES 0x10 7137414Simp#define APM_RESUMETIMER 0x11 7237414Simp#define APM_RESUMEONRING 0x12 7337414Simp#define APM_TIMERREQUESTS 0x13 743263Sdg#define APM_OEMFUNC 0x80 753263Sdg 763263Sdg/* error code */ 773263Sdg#define APME_OK 0x00 783263Sdg#define APME_PMDISABLED 0x01 793263Sdg#define APME_REALESTABLISHED 0x02 803263Sdg#define APME_NOTCONNECTED 0x03 813263Sdg#define APME_PROT16ESTABLISHED 0x05 823263Sdg#define APME_PROT16NOTSUPPORTED 0x06 833263Sdg#define APME_PROT32ESTABLISHED 0x07 843263Sdg#define APME_PROT32NOTDUPPORTED 0x08 853263Sdg#define APME_UNKNOWNDEVICEID 0x09 863263Sdg#define APME_OUTOFRANGE 0x0a 873263Sdg#define APME_NOTENGAGED 0x0b 883263Sdg#define APME_CANTENTERSTATE 0x60 893263Sdg#define APME_NOPMEVENT 0x80 903263Sdg#define APME_NOAPMPRESENT 0x86 913263Sdg 923263Sdg 933263Sdg/* device code */ 943263Sdg#define PMDV_APMBIOS 0x0000 953263Sdg#define PMDV_ALLDEV 0x0001 963263Sdg#define PMDV_DISP0 0x0100 973263Sdg#define PMDV_DISP1 0x0101 9864251Siwasaki#define PMDV_DISPALL 0x01ff 993263Sdg#define PMDV_2NDSTORAGE0 0x0200 1003263Sdg#define PMDV_2NDSTORAGE1 0x0201 1013263Sdg#define PMDV_2NDSTORAGE2 0x0202 1023263Sdg#define PMDV_2NDSTORAGE3 0x0203 1033263Sdg#define PMDV_PARALLEL0 0x0300 1043263Sdg#define PMDV_PARALLEL1 0x0301 1053263Sdg#define PMDV_SERIAL0 0x0400 1063263Sdg#define PMDV_SERIAL1 0x0401 1073263Sdg#define PMDV_SERIAL2 0x0402 1083263Sdg#define PMDV_SERIAL3 0x0403 1093263Sdg#define PMDV_SERIAL4 0x0404 1103263Sdg#define PMDV_SERIAL5 0x0405 1113263Sdg#define PMDV_SERIAL6 0x0406 1123263Sdg#define PMDV_SERIAL7 0x0407 1133263Sdg#define PMDV_NET0 0x0500 1143263Sdg#define PMDV_NET1 0x0501 1153263Sdg#define PMDV_NET2 0x0502 1163263Sdg#define PMDV_NET3 0x0503 1173263Sdg#define PMDV_PCMCIA0 0x0600 1183263Sdg#define PMDV_PCMCIA1 0x0601 1193263Sdg#define PMDV_PCMCIA2 0x0602 1203263Sdg#define PMDV_PCMCIA3 0x0603 12164615Sume/* 0x0700 - 0x7fff Reserved */ 12264615Sume#define PMDV_BATT_BASE 0x8000 12364615Sume#define PMDV_BATT0 0x8001 12464615Sume#define PMDV_BATT1 0x8002 12564615Sume#define PMDV_BATT_ALL 0x80ff 12664615Sume/* 0x8100 - 0xdfff Reserved */ 1273263Sdg/* 0xe000 - 0xefff OEM-defined power device IDs */ 1283263Sdg/* 0xf000 - 0xffff Reserved */ 1293263Sdg 1303263Sdg/* Power state */ 1313263Sdg#define PMST_APMENABLED 0x0000 1323263Sdg#define PMST_STANDBY 0x0001 1333263Sdg#define PMST_SUSPEND 0x0002 1343263Sdg#define PMST_OFF 0x0003 1353263Sdg#define PMST_LASTREQNOTIFY 0x0004 1363263Sdg#define PMST_LASTREQREJECT 0x0005 1373263Sdg/* 0x0006 - 0x001f Reserved system states */ 1383263Sdg/* 0x0020 - 0x003f OEM-defined system states */ 1393263Sdg/* 0x0040 - 0x007f OEM-defined device states */ 1403263Sdg/* 0x0080 - 0xffff Reserved device states */ 1413263Sdg 1426512Sphk#if !defined(ASSEMBLER) && !defined(INITIALIZER) 1433263Sdg 1443263Sdg/* C definitions */ 1456512Sphkstruct apmhook { 1466512Sphk struct apmhook *ah_next; 14792761Salfred int (*ah_fun)(void *ah_arg); 1486512Sphk void *ah_arg; 1496512Sphk const char *ah_name; 1506512Sphk int ah_order; 1516512Sphk}; 1526512Sphk#define APM_HOOK_NONE (-1) 1536512Sphk#define APM_HOOK_SUSPEND 0 1546512Sphk#define APM_HOOK_RESUME 1 1556512Sphk#define NAPM_HOOK 2 1563263Sdg 15755205Speter#ifdef _KERNEL 15837414Simp 15937414Simpvoid apm_suspend(int state); 1606512Sphkstruct apmhook *apm_hook_establish (int apmh, struct apmhook *); 1616512Sphkvoid apm_hook_disestablish (int apmh, struct apmhook *); 1623263Sdgvoid apm_cpu_idle(void); 1633263Sdgvoid apm_cpu_busy(void); 1643263Sdg 16555205Speter#endif 16637414Simp 1676512Sphk#endif /* !ASSEMBLER && !INITIALIZER */ 1683263Sdg 1693263Sdg#define APM_MIN_ORDER 0x00 1703263Sdg#define APM_MID_ORDER 0x80 1713263Sdg#define APM_MAX_ORDER 0xff 1723263Sdg 1733263Sdg/* power management event code */ 1743263Sdg#define PMEV_NOEVENT 0x0000 1753263Sdg#define PMEV_STANDBYREQ 0x0001 1763263Sdg#define PMEV_SUSPENDREQ 0x0002 1773263Sdg#define PMEV_NORMRESUME 0x0003 1783263Sdg#define PMEV_CRITRESUME 0x0004 1793263Sdg#define PMEV_BATTERYLOW 0x0005 1803263Sdg#define PMEV_POWERSTATECHANGE 0x0006 1813263Sdg#define PMEV_UPDATETIME 0x0007 1823263Sdg#define PMEV_CRITSUSPEND 0x0008 1833263Sdg#define PMEV_USERSTANDBYREQ 0x0009 1843263Sdg#define PMEV_USERSUSPENDREQ 0x000a 1853263Sdg#define PMEV_STANDBYRESUME 0x000b 18637414Simp#define PMEV_CAPABILITIESCHANGE 0x000c 18737414Simp/* 0x000d - 0x00ff Reserved system events */ 1883263Sdg/* 0x0100 - 0x01ff Reserved device events */ 1893263Sdg/* 0x0200 - 0x02ff OEM-defined APM events */ 1903263Sdg/* 0x0300 - 0xffff Reserved */ 1913263Sdg#define PMEV_DEFAULT 0xffffffff /* used for customization */ 1923263Sdg 1936512Sphk#if !defined(ASSEMBLER) && !defined(INITIALIZER) 1943263Sdg 19531126Sjdp/* 19631126Sjdp * Old apm_info structure, returned by the APMIO_GETINFO_OLD ioctl. This 19731126Sjdp * is for backward compatibility with old executables. 19831126Sjdp */ 19931126Sjdptypedef struct apm_info_old { 2003263Sdg u_int ai_major; /* APM major version */ 2013263Sdg u_int ai_minor; /* APM minor version */ 2023263Sdg u_int ai_acline; /* AC line status */ 2033263Sdg u_int ai_batt_stat; /* Battery status */ 2043263Sdg u_int ai_batt_life; /* Remaining battery life */ 20514608Snate u_int ai_status; /* Status of APM support (enabled/disabled) */ 20631126Sjdp} *apm_info_old_t; 20731126Sjdp 20831126Sjdp/* 20931126Sjdp * Structure returned by the APMIO_GETINFO ioctl. 21031126Sjdp * 21131126Sjdp * In the comments below, the parenthesized numbers indicate the minimum 21231126Sjdp * value of ai_infoversion for which each field is valid. 21331126Sjdp */ 21431126Sjdptypedef struct apm_info { 21531126Sjdp u_int ai_infoversion; /* Indicates which fields are valid */ 21631126Sjdp u_int ai_major; /* APM major version (0) */ 21731126Sjdp u_int ai_minor; /* APM minor version (0) */ 21831126Sjdp u_int ai_acline; /* AC line status (0) */ 21931126Sjdp u_int ai_batt_stat; /* Battery status (0) */ 22031126Sjdp u_int ai_batt_life; /* Remaining battery life in percent (0) */ 22131126Sjdp int ai_batt_time; /* Remaining battery time in seconds (0) */ 22231126Sjdp u_int ai_status; /* True if enabled (0) */ 22337414Simp u_int ai_batteries; /* Number of batteries (1) */ 22437414Simp u_int ai_capabilities;/* APM Capabilities (1) */ 22537414Simp u_int ai_spare[6]; /* For future expansion */ 2263263Sdg} *apm_info_t; 2273263Sdg 22864615Sume/* Battery flag */ 22964615Sume#define APM_BATT_HIGH 0x01 23064615Sume#define APM_BATT_LOW 0x02 23164615Sume#define APM_BATT_CRITICAL 0x04 23264615Sume#define APM_BATT_CHARGING 0x08 23364615Sume#define APM_BATT_NOT_PRESENT 0x10 23464615Sume#define APM_BATT_NO_SYSTEM 0x80 23564615Sume 23664615Sumetypedef struct apm_pwstatus { 23764615Sume u_int ap_device; /* Device code of battery */ 23864615Sume u_int ap_acline; /* AC line status (0) */ 23964615Sume u_int ap_batt_stat; /* Battery status (0) */ 24064615Sume u_int ap_batt_flag; /* Battery flag (0) */ 24164615Sume u_int ap_batt_life; /* Remaining battery life in percent (0) */ 24264615Sume int ap_batt_time; /* Remaining battery time in seconds (0) */ 24364615Sume} *apm_pwstatus_t; 24464615Sume 24549292Smsmithstruct apm_bios_arg { 24649292Smsmith u_long eax; 24749292Smsmith u_long ebx; 24849292Smsmith u_long ecx; 24949292Smsmith u_long edx; 25049292Smsmith u_long esi; 25149292Smsmith u_long edi; 25249292Smsmith}; 25349292Smsmith 25449197Smsmithstruct apm_event_info { 25549197Smsmith u_int type; 25648735Siwasaki u_int index; 25748735Siwasaki u_int spare[8]; 25848735Siwasaki}; 25948735Siwasaki 2603263Sdg#define APMIO_SUSPEND _IO('P', 1) 26131126Sjdp#define APMIO_GETINFO_OLD _IOR('P', 2, struct apm_info_old) 2623263Sdg#define APMIO_ENABLE _IO('P', 5) 2633263Sdg#define APMIO_DISABLE _IO('P', 6) 2643263Sdg#define APMIO_HALTCPU _IO('P', 7) 2653263Sdg#define APMIO_NOTHALTCPU _IO('P', 8) 26621362Snate#define APMIO_DISPLAY _IOW('P', 9, int) 26749292Smsmith#define APMIO_BIOS _IOWR('P', 10, struct apm_bios_arg) 26831126Sjdp#define APMIO_GETINFO _IOR('P', 11, struct apm_info) 26937414Simp#define APMIO_STANDBY _IO('P', 12) 27064615Sume#define APMIO_GETPWSTATUS _IOWR('P', 13, struct apm_pwstatus) 27148735Siwasaki/* for /dev/apmctl */ 27248735Siwasaki#define APMIO_NEXTEVENT _IOR('A', 100, struct apm_event_info) 27348735Siwasaki#define APMIO_REJECTLASTREQ _IO('P', 101) 2743263Sdg 2756512Sphk#endif /* !ASSEMBLER && !INITIALIZER */ 2763263Sdg 27718444Sbde#endif /* !_MACHINE_APM_BIOS_H_ */ 278