Home | History | Annotate | Line # | Download | only in include
apmvar.h revision 1.9.2.1
      1  1.9.2.1    bouyer /*	$NetBSD: apmvar.h,v 1.9.2.1 2001/01/18 09:22:36 bouyer Exp $	*/
      2      1.8       jtk /*-
      3      1.8       jtk  * Copyright (c) 1995 The NetBSD Foundation, Inc.
      4      1.8       jtk  * All rights reserved.
      5      1.8       jtk  *
      6      1.8       jtk  * This code is derived from software contributed to The NetBSD Foundation
      7      1.8       jtk  * by John Kohl.
      8      1.8       jtk  *
      9      1.8       jtk  * Redistribution and use in source and binary forms, with or without
     10      1.8       jtk  * modification, are permitted provided that the following conditions
     11      1.8       jtk  * are met:
     12      1.8       jtk  * 1. Redistributions of source code must retain the above copyright
     13      1.8       jtk  *    notice, this list of conditions and the following disclaimer.
     14      1.8       jtk  * 2. Redistributions in binary form must reproduce the above copyright
     15      1.8       jtk  *    notice, this list of conditions and the following disclaimer in the
     16      1.8       jtk  *    documentation and/or other materials provided with the distribution.
     17      1.8       jtk  * 3. All advertising materials mentioning features or use of this software
     18      1.8       jtk  *    must display the following acknowledgement:
     19      1.8       jtk  *        This product includes software developed by the NetBSD
     20      1.8       jtk  *        Foundation, Inc. and its contributors.
     21      1.8       jtk  * 4. Neither the name of The NetBSD Foundation nor the names of its
     22      1.8       jtk  *    contributors may be used to endorse or promote products derived
     23      1.8       jtk  *    from this software without specific prior written permission.
     24      1.8       jtk  *
     25      1.8       jtk  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     26      1.8       jtk  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     27      1.8       jtk  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     28      1.8       jtk  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     29      1.8       jtk  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     30      1.8       jtk  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     31      1.8       jtk  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     32      1.8       jtk  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     33      1.8       jtk  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     34      1.8       jtk  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     35      1.1       jtk  * POSSIBILITY OF SUCH DAMAGE.
     36      1.1       jtk  */
     37      1.1       jtk #ifndef __I386_APM_H__
     38      1.1       jtk #define __I386_APM_H__
     39      1.1       jtk 
     40      1.1       jtk /* Advanced Power Management (v1.0 and v1.1 specification)
     41      1.1       jtk  * functions/defines/etc.
     42      1.1       jtk  */
     43      1.1       jtk #define APM_BIOS_FNCODE	(0x53)
     44      1.1       jtk #define APM_SYSTEM_BIOS	(0x15)
     45      1.1       jtk #define APM_BIOS_FN(x)	((APM_BIOS_FNCODE<<8)|(x))
     46      1.2       jtk 
     47      1.1       jtk /*
     48      1.2       jtk  * APM info bits from BIOS
     49      1.1       jtk  */
     50      1.2       jtk #define APM_16BIT_SUPPORT	0x01
     51      1.2       jtk #define APM_32BIT_SUPPORT	0x02
     52      1.2       jtk #define APM_CPUIDLE_SLOW	0x04
     53      1.2       jtk #define APM_DISABLED		0x08
     54      1.2       jtk #define APM_DISENGAGED		0x10
     55      1.1       jtk 
     56      1.7       jtk #define	APM_ERR_CODE(regs)	(((regs)->AX & 0xff00) >> 8)
     57      1.1       jtk #define	APM_ERR_PM_DISABLED	0x01
     58      1.1       jtk #define	APM_ERR_REALALREADY	0x02
     59      1.1       jtk #define	APM_ERR_NOTCONN		0x03
     60      1.1       jtk #define	APM_ERR_16ALREADY	0x05
     61      1.1       jtk #define	APM_ERR_16NOTSUPP	0x06
     62      1.1       jtk #define	APM_ERR_32ALREADY	0x07
     63      1.1       jtk #define	APM_ERR_32NOTSUPP	0x08
     64      1.1       jtk #define	APM_ERR_UNRECOG_DEV	0x09
     65      1.1       jtk #define	APM_ERR_ERANGE		0x0A
     66      1.1       jtk #define	APM_ERR_NOTENGAGED	0x0B
     67      1.7       jtk #define	APM_ERR_EOPNOTSUPP	0x0C
     68      1.7       jtk #define	APM_ERR_RTIMER_DISABLED	0x0D
     69      1.1       jtk #define APM_ERR_UNABLE		0x60
     70      1.1       jtk #define APM_ERR_NOEVENTS	0x80
     71      1.1       jtk #define	APM_ERR_NOT_PRESENT	0x86
     72      1.1       jtk 
     73      1.1       jtk #define APM_DEV_APM_BIOS	0x0000
     74      1.1       jtk #define APM_DEV_ALLDEVS		0x0001
     75      1.1       jtk /* device classes are high byte; device IDs go in low byte */
     76      1.1       jtk #define		APM_DEV_DISPLAY(x)	(0x0100|((x)&0xff))
     77      1.1       jtk #define		APM_DEV_DISK(x)		(0x0200|((x)&0xff))
     78      1.1       jtk #define		APM_DEV_PARALLEL(x)	(0x0300|((x)&0xff))
     79      1.1       jtk #define		APM_DEV_SERIAL(x)	(0x0400|((x)&0xff))
     80      1.1       jtk #define		APM_DEV_NETWORK(x)	(0x0500|((x)&0xff))
     81      1.1       jtk #define		APM_DEV_PCMCIA(x)	(0x0600|((x)&0xff))
     82      1.9  drochner #define		APM_DEV_BATTERY(x)	(0x8000|((x)&0xff))	/* V1.2 */
     83      1.1       jtk #define		APM_DEV_ALLUNITS	0xff
     84      1.1       jtk 
     85      1.1       jtk #define	APM_INSTALLATION_CHECK	0x00	/* int15 only */
     86      1.3       jtk #define		APM_INSTALL_SIGNATURE	0x504d	/* %bh = 'P', %bl = 'M' */
     87      1.1       jtk #define	APM_REALMODE_CONNECT	0x01	/* int15 only */
     88      1.1       jtk #define	APM_16BIT_CONNECT	0x02	/* int15 only */
     89      1.1       jtk #define	APM_32BIT_CONNECT	0x03	/* int15 only */
     90      1.1       jtk #define APM_DISCONNECT		0x04	/* %bx = APM_DEV_APM_BIOS */
     91      1.1       jtk #define APM_CPU_IDLE		0x05
     92      1.1       jtk #define APM_CPU_BUSY		0x06
     93      1.1       jtk #define APM_SET_PWR_STATE	0x07
     94      1.1       jtk #define		APM_SYS_READY	0x0000	/* %cx */
     95      1.1       jtk #define		APM_SYS_STANDBY	0x0001
     96      1.1       jtk #define		APM_SYS_SUSPEND	0x0002
     97      1.1       jtk #define		APM_SYS_OFF	0x0003
     98      1.1       jtk #define		APM_LASTREQ_INPROG	0x0004
     99      1.1       jtk #define		APM_LASTREQ_REJECTED	0x0005
    100      1.1       jtk 
    101      1.1       jtk /* system standby is device ID (%bx) 0x0001, APM_SYS_STANDBY */
    102      1.1       jtk /* system suspend is device ID (%bx) 0x0001, APM_SYS_SUSPEND */
    103      1.1       jtk 
    104      1.1       jtk #define APM_PWR_MGT_ENABLE	0x08
    105      1.1       jtk #define		APM_MGT_ALL	0xffff	/* %bx */
    106      1.1       jtk #define		APM_MGT_DISABLE	0x0	/* %cx */
    107      1.1       jtk #define		APM_MGT_ENABLE	0x1
    108      1.1       jtk 
    109      1.1       jtk #define APM_SYSTEM_DEFAULTS	0x09
    110      1.1       jtk #define		APM_DEFAULTS_ALL	0xffff	/* %bx */
    111      1.7       jtk #define		APM_DEFAULTS_ALL_V12	0x0001	/* %bx */
    112      1.1       jtk 
    113      1.1       jtk #define APM_POWER_STATUS	0x0a
    114      1.1       jtk #define		APM_AC_OFF		0x00
    115      1.1       jtk #define		APM_AC_ON		0x01
    116      1.1       jtk #define		APM_AC_BACKUP		0x02
    117      1.1       jtk #define		APM_AC_UNKNOWN		0xff
    118      1.2       jtk /* the first set of battery constants is 1.0 style values;
    119      1.2       jtk    the second set is 1.1 style bit definitions */
    120      1.1       jtk #define		APM_BATT_HIGH		0x00
    121      1.1       jtk #define		APM_BATT_LOW		0x01
    122      1.1       jtk #define		APM_BATT_CRITICAL	0x02
    123      1.1       jtk #define		APM_BATT_CHARGING	0x03
    124      1.2       jtk #define		APM_BATT_ABSENT		0x04 /* Software only--not in spec! */
    125      1.1       jtk #define		APM_BATT_UNKNOWN	0xff
    126      1.2       jtk 
    127      1.1       jtk #define		APM_BATT_FLAG_HIGH	0x01
    128      1.1       jtk #define		APM_BATT_FLAG_LOW	0x02
    129      1.1       jtk #define		APM_BATT_FLAG_CRITICAL	0x04
    130      1.1       jtk #define		APM_BATT_FLAG_CHARGING	0x08
    131      1.7       jtk #define		APM_BATT_FLAG_NOBATTERY	0x10
    132      1.7       jtk #define		APM_BATT_FLAG_NO_SYSTEM_BATTERY	0x80
    133      1.7       jtk #define		APM_BATT_FLAG_UNKNOWN	0xff
    134      1.2       jtk 
    135      1.1       jtk #define		APM_BATT_LIFE_UNKNOWN	0xff
    136      1.7       jtk #define		APM_BATT_STATE(regp) ((regp)->BX & 0xff)
    137      1.7       jtk #define		APM_BATT_FLAGS(regp) (((regp)->CX & 0xff00) >> 8)
    138      1.7       jtk #define		APM_AC_STATE(regp) (((regp)->BX & 0xff00) >> 8)
    139      1.7       jtk #define		APM_BATT_LIFE(regp) ((regp)->CX & 0xff) /* in % */
    140      1.1       jtk /* BATT_REMAINING returns minutes remaining */
    141      1.7       jtk #define		APM_BATT_REMAINING(regp) (((regp)->DX & 0x8000) ? \
    142      1.7       jtk 					  ((regp)->DX & 0x7fff) : \
    143      1.7       jtk 					  ((regp)->DX & 0x7fff)/60)
    144      1.7       jtk #define		APM_BATT_REM_VALID(regp) (((regp)->DX & 0xffff) != 0xffff)
    145      1.7       jtk #define		APM_BATTERY_COUNT(regp) ((regp)->SI)
    146      1.7       jtk 
    147      1.1       jtk #define	APM_GET_PM_EVENT	0x0b
    148      1.1       jtk #define		APM_STANDBY_REQ		0x0001 /* %bx on return */
    149      1.1       jtk #define		APM_SUSPEND_REQ		0x0002
    150      1.1       jtk #define		APM_NORMAL_RESUME	0x0003
    151      1.1       jtk #define		APM_CRIT_RESUME		0x0004 /* suspend/resume happened
    152      1.1       jtk 						  without us */
    153      1.7       jtk      /* If set, the pccard sockets were powered off in the
    154      1.7       jtk 	suspend/standby state (V1.2 only) */
    155      1.7       jtk #define		APM_PCCARD_POWEREDOFF(regp) ((regp)->CX & 0x0001)
    156      1.7       jtk 
    157      1.1       jtk #define		APM_BATTERY_LOW		0x0005
    158      1.1       jtk #define		APM_POWER_CHANGE	0x0006
    159      1.1       jtk #define		APM_UPDATE_TIME		0x0007
    160      1.1       jtk #define		APM_CRIT_SUSPEND_REQ	0x0008
    161      1.1       jtk #define		APM_USER_STANDBY_REQ	0x0009
    162      1.1       jtk #define		APM_USER_SUSPEND_REQ	0x000A
    163      1.1       jtk #define		APM_SYS_STANDBY_RESUME	0x000B
    164      1.9  drochner #define		APM_CAP_CHANGE		0x000C	/* V1.2 */
    165      1.1       jtk 
    166      1.1       jtk #define	APM_GET_POWER_STATE	0x0c
    167      1.7       jtk      /* device to query in %bx */
    168      1.7       jtk      /* returns power states in %cx */
    169      1.1       jtk #define	APM_DEVICE_MGMT_ENABLE	0x0d
    170      1.7       jtk      /* device to enable/disable in %bx */
    171      1.1       jtk 
    172      1.1       jtk #define	APM_DRIVER_VERSION	0x0e
    173      1.1       jtk /* %bx should be DEV value (APM_DEV_APM_BIOS)
    174      1.1       jtk    %ch = driver major vno
    175      1.1       jtk    %cl = driver minor vno
    176      1.1       jtk    return: %ah = conn major; %al = conn minor
    177      1.1       jtk    */
    178      1.7       jtk #define		APM_CONN_MINOR(regp) ((regp)->AX & 0xff)
    179      1.7       jtk #define		APM_CONN_MAJOR(regp) (((regp)->AX & 0xff00) >> 8)
    180      1.1       jtk 
    181      1.1       jtk #define APM_PWR_MGT_ENGAGE	0x0F
    182      1.7       jtk      /* device in %bx */
    183      1.1       jtk #define		APM_MGT_DISENGAGE	0x0	/* %cx */
    184      1.1       jtk #define		APM_MGT_ENGAGE		0x1
    185      1.1       jtk 
    186      1.7       jtk #define APM_GET_CAPABILITIES	0x10
    187      1.7       jtk      /* device in %bx (APM_DEV_APM_BIOS) */
    188      1.7       jtk      /* %bl: number of batteries */
    189      1.7       jtk #define		APM_NBATTERIES(regp) ((regp)->BX & 0xff)
    190      1.7       jtk      /* %cx capabilities */
    191      1.7       jtk #define		APM_GLOBAL_STANDBY	0x0001
    192      1.7       jtk #define		APM_GLOBAL_SUSPEND	0x0002
    193      1.7       jtk #define		APM_RTIMER_STANDBY	0x0004 /* resume timer wakes standby */
    194      1.7       jtk #define		APM_RTIMER_SUSPEND	0x0008 /* resume timer wakes suspend */
    195      1.7       jtk #define		APM_IRRING_SUSPEND	0x0010 /* internal ring wakes suspend */
    196      1.7       jtk #define		APM_IRRING_STANDBY	0x0020 /* internal ring wakes standby */
    197      1.7       jtk #define		APM_PCRING_SUSPEND	0x0040 /* pccard ring wakes suspend */
    198      1.7       jtk #define		APM_PCRING_STANDBY	0x0080 /* pccard ring wakes standby */
    199      1.7       jtk 
    200      1.7       jtk #define	APM_RESUME_TIMER_CTL	0x11	/* get/set/disable resume timer */
    201      1.7       jtk      /* device in %bx (APM_DEV_APM_BIOS) */
    202      1.7       jtk      /* function code in %cl */
    203      1.7       jtk #define		APM_RTIMER_DISABLE	0x00
    204      1.7       jtk #define		APM_RTIMER_GET		0x01
    205      1.7       jtk #define		APM_RTIMER_SET		0x02
    206      1.7       jtk      /* if %cl = set, or %cl = get, then: */
    207      1.7       jtk      /* %ch: seconds */
    208      1.7       jtk      /* %dh: hours */
    209      1.7       jtk      /* %dl: minutes */
    210      1.7       jtk      /* %sih: month (bcd), %sil: day (bcd) */
    211      1.7       jtk      /* %di: year (bcd, 4 digits) */
    212      1.7       jtk #define APM_RESUME_RING_CTL		0x12
    213      1.7       jtk      /* device in %bx (APM_DEV_APM_BIOS) */
    214      1.7       jtk      /* %cx: function code */
    215      1.7       jtk #define		APM_RRING_DISABLE	0x0000
    216      1.7       jtk #define		APM_RRING_ENABLE	0x0001
    217      1.7       jtk #define		APM_RRING_GET		0x0002
    218      1.7       jtk      /* returns state in %cx */
    219      1.7       jtk #define		APM_RRING_DISABLED	0x0000
    220      1.7       jtk #define		APM_RRING_ENABLED	0x0001
    221      1.7       jtk 
    222      1.7       jtk #define APM_TIMER_REQS_CTL	0x13
    223      1.7       jtk      /* device in %bx (APM_DEV_APM_BIOS) */
    224      1.7       jtk      /* %cx: function code */
    225      1.7       jtk #define		APM_TIMER_REQS_DISABLE	0x0000
    226      1.7       jtk #define		APM_TIMER_REQS_ENABLE	0x0001
    227      1.7       jtk #define		APM_TIMER_REQS_GET	0x0002
    228      1.7       jtk      /* returns state in %cx */
    229      1.7       jtk #define		APM_TIMER_REQS_DISABLED	0x0000
    230      1.7       jtk #define		APM_TIEMR_REQS_ENABLED	0x0001
    231      1.7       jtk 
    232      1.1       jtk #define APM_OEM			0x80
    233      1.1       jtk 
    234      1.2       jtk /*
    235      1.2       jtk  * APM info word from the real-mode handler is adjusted to put
    236      1.2       jtk  * major/minor version in low half and support bits in upper half.
    237      1.2       jtk  */
    238      1.2       jtk #define	APM_MAJOR_VERS(info) (((info)&0xff00)>>8)
    239      1.2       jtk #define	APM_MINOR_VERS(info) ((info)&0xff)
    240      1.2       jtk 
    241      1.2       jtk #define APM_16BIT_SUPPORTED	(APM_16BIT_SUPPORT << 16)
    242      1.2       jtk #define APM_32BIT_SUPPORTED	(APM_32BIT_SUPPORT << 16)
    243      1.2       jtk #define APM_IDLE_SLOWS		(APM_CPUIDLE_SLOW << 16)
    244      1.2       jtk #define APM_BIOS_PM_DISABLED	(APM_DISABLED << 16)
    245      1.2       jtk #define APM_BIOS_PM_DISENGAGED	(APM_DISENGAGED << 16)
    246      1.2       jtk 
    247      1.1       jtk /*
    248      1.3       jtk  * virtual & physical address of the trampoline
    249      1.3       jtk  * that we use: page 1.
    250      1.1       jtk  */
    251      1.3       jtk #define APM_BIOSTRAMP	NBPG
    252      1.1       jtk 
    253      1.1       jtk 
    254      1.3       jtk #ifndef _LOCORE
    255      1.1       jtk 
    256      1.1       jtk /* filled in by apmcall */
    257      1.1       jtk 
    258      1.1       jtk struct apm_connect_info {
    259      1.1       jtk 	u_int apm_code32_seg_base;	/* real-mode style segment selector */
    260      1.1       jtk 	u_int apm_code16_seg_base;
    261      1.1       jtk 	u_int apm_data_seg_base;
    262      1.1       jtk 	u_int apm_entrypt;
    263      1.1       jtk 	u_short	apm_segsel;		/* segment selector for APM */
    264      1.1       jtk 	u_short _pad1;
    265      1.1       jtk 	u_int apm_code32_seg_len;
    266      1.7       jtk 	u_int apm_code16_seg_len;
    267      1.1       jtk 	u_int apm_data_seg_len;
    268      1.1       jtk 	u_int apm_detail;
    269      1.1       jtk };
    270      1.1       jtk 
    271      1.1       jtk struct apm_event_info {
    272      1.1       jtk 	u_int type;
    273      1.1       jtk 	u_int index;
    274      1.1       jtk 	u_int spare[8];
    275      1.1       jtk };
    276      1.1       jtk 
    277      1.1       jtk struct apm_power_info {
    278      1.1       jtk 	u_char battery_state;
    279      1.1       jtk 	u_char ac_state;
    280      1.1       jtk 	u_char battery_life;
    281      1.1       jtk 	u_char spare1;
    282      1.1       jtk 	u_int minutes_left;		/* estimate */
    283      1.1       jtk 	u_int spare2[6];
    284      1.1       jtk };
    285      1.1       jtk 
    286      1.1       jtk struct apm_ctl {
    287      1.1       jtk 	u_int dev;
    288      1.1       jtk 	u_int mode;
    289      1.1       jtk };
    290      1.1       jtk 
    291      1.1       jtk #define	APM_IOC_REJECT	_IOW('A', 0, struct apm_event_info) /* reject request # */
    292      1.1       jtk #define	APM_IOC_STANDBY	_IO('A', 1)	/* put system into standby */
    293      1.1       jtk #define	APM_IOC_SUSPEND	_IO('A', 2)	/* put system into suspend */
    294      1.1       jtk #define	APM_IOC_GETPOWER _IOR('A', 3, struct apm_power_info) /* fetch battery state */
    295      1.1       jtk #define	APM_IOC_NEXTEVENT _IOR('A', 4, struct apm_event_info) /* fetch event */
    296      1.1       jtk #define	APM_IOC_DEV_CTL	_IOW('A', 5, struct apm_ctl) /* put device into mode */
    297      1.1       jtk 
    298      1.1       jtk struct apm_attach_args {
    299      1.1       jtk 	char *aaa_busname;
    300      1.1       jtk };
    301      1.1       jtk 
    302      1.1       jtk #ifdef _KERNEL
    303      1.1       jtk extern struct apm_connect_info apminfo;	/* in locore */
    304      1.1       jtk extern int apmpresent;
    305      1.6       jtk extern int apmcall __P((int function, struct bioscallregs *regs));
    306      1.6       jtk extern void bioscall __P((int function, struct bioscallregs *regs));
    307      1.1       jtk extern void apm_cpu_busy __P((void));
    308      1.1       jtk extern void apm_cpu_idle __P((void));
    309      1.1       jtk extern void apminit __P((void));
    310      1.1       jtk int apm_set_powstate __P((u_int devid, u_int powstate));
    311      1.5       jtk extern int apm_busprobe __P((void));
    312      1.1       jtk #endif /* _KERNEL */
    313      1.1       jtk #endif /* _LOCORE */
    314      1.1       jtk #endif /* __i386_apm_h__ */
    315