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 * Get APM BIOS information
20 int query_apm_bios(void)
22 u16 ax
, bx
, cx
, dx
, di
;
26 /* APM BIOS installation check */
29 asm volatile("pushl %%ebp ; int $0x15 ; popl %%ebp ; setc %0"
30 : "=d" (err
), "+a" (ax
), "+b" (bx
), "+c" (cx
)
34 return -1; /* No APM BIOS */
36 if (bx
!= 0x504d) /* "PM" signature */
39 if (!(cx
& 0x02)) /* 32 bits supported? */
42 /* Disconnect first, just in case */
45 asm volatile("pushl %%ebp ; int $0x15 ; popl %%ebp"
46 : "+a" (ax
), "+b" (bx
)
47 : : "ecx", "edx", "esi", "edi");
54 asm volatile("pushl %%ebp ; int $0x15 ; popl %%ebp ; setc %6"
55 : "=a" (ax
), "+b" (ebx
), "+c" (cx
), "+d" (dx
),
56 "+S" (esi
), "+D" (di
), "=m" (err
)
59 boot_params
.apm_bios_info
.cseg
= ax
;
60 boot_params
.apm_bios_info
.offset
= ebx
;
61 boot_params
.apm_bios_info
.cseg_16
= cx
;
62 boot_params
.apm_bios_info
.dseg
= dx
;
63 boot_params
.apm_bios_info
.cseg_len
= (u16
)esi
;
64 boot_params
.apm_bios_info
.cseg_16_len
= esi
>> 16;
65 boot_params
.apm_bios_info
.dseg_len
= di
;
70 /* Redo the installation check as the 32-bit connect;
71 some BIOSes return different flags this way... */
75 asm volatile("pushl %%ebp ; int $0x15 ; popl %%ebp ; setc %0"
76 : "=d" (err
), "+a" (ax
), "+b" (bx
), "+c" (cx
)
79 if (err
|| bx
!= 0x504d) {
80 /* Failure with 32-bit connect, try to disconect and ignore */
83 asm volatile("pushl %%ebp ; int $0x15 ; popl %%ebp"
84 : "+a" (ax
), "+b" (bx
)
85 : : "ecx", "edx", "esi", "edi");
89 boot_params
.apm_bios_info
.version
= ax
;
90 boot_params
.apm_bios_info
.flags
= cx
;