1 /* -*- linux-c -*- ------------------------------------------------------- *
3 * Copyright (C) 1991, 1992 Linus Torvalds
4 * Copyright 2007 rPath, Inc. - All Rights Reserved
6 * Original APM BIOS checking by Stephen Rothwell, May 1994
7 * (sfr@canb.auug.org.au)
9 * This file is part of the Linux kernel, and is made available under
10 * the terms of the GNU General Public License version 2.
12 * ----------------------------------------------------------------------- */
15 * arch/i386/boot/apm.c
17 * Get APM BIOS information
22 #if defined(CONFIG_APM) || defined(CONFIG_APM_MODULE)
24 int query_apm_bios(void)
26 u16 ax
, bx
, cx
, dx
, di
;
30 /* APM BIOS installation check */
33 asm volatile("pushl %%ebp ; int $0x15 ; popl %%ebp ; setc %0"
34 : "=d" (err
), "+a" (ax
), "+b" (bx
), "+c" (cx
)
38 return -1; /* No APM BIOS */
40 if (bx
!= 0x504d) /* "PM" signature */
43 if (!(cx
& 0x02)) /* 32 bits supported? */
46 /* Disconnect first, just in case */
49 asm volatile("pushl %%ebp ; int $0x15 ; popl %%ebp"
50 : "+a" (ax
), "+b" (bx
)
51 : : "ecx", "edx", "esi", "edi");
58 asm volatile("pushl %%ebp ; int $0x15 ; popl %%ebp ; setc %6"
59 : "=a" (ax
), "+b" (ebx
), "+c" (cx
), "+d" (dx
),
60 "+S" (esi
), "+D" (di
), "=m" (err
)
63 boot_params
.apm_bios_info
.cseg
= ax
;
64 boot_params
.apm_bios_info
.offset
= ebx
;
65 boot_params
.apm_bios_info
.cseg_16
= cx
;
66 boot_params
.apm_bios_info
.dseg
= dx
;
67 boot_params
.apm_bios_info
.cseg_len
= (u16
)esi
;
68 boot_params
.apm_bios_info
.cseg_16_len
= esi
>> 16;
69 boot_params
.apm_bios_info
.dseg_len
= di
;
74 /* Redo the installation check as the 32-bit connect;
75 some BIOSes return different flags this way... */
79 asm volatile("pushl %%ebp ; int $0x15 ; popl %%ebp ; setc %0"
80 : "=d" (err
), "+a" (ax
), "+b" (bx
), "+c" (cx
)
83 if (err
|| bx
!= 0x504d) {
84 /* Failure with 32-bit connect, try to disconect and ignore */
87 asm volatile("pushl %%ebp ; int $0x15 ; popl %%ebp"
88 : "+a" (ax
), "+b" (bx
)
89 : : "ecx", "edx", "esi", "edi");
93 boot_params
.apm_bios_info
.version
= ax
;
94 boot_params
.apm_bios_info
.flags
= cx
;