summaryrefslogtreecommitdiff
path: root/sys/arch/i386/stand/libsa/apmprobe.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/arch/i386/stand/libsa/apmprobe.c')
-rw-r--r--sys/arch/i386/stand/libsa/apmprobe.c99
1 files changed, 52 insertions, 47 deletions
diff --git a/sys/arch/i386/stand/libsa/apmprobe.c b/sys/arch/i386/stand/libsa/apmprobe.c
index 4278f2baadb..5069d081d5d 100644
--- a/sys/arch/i386/stand/libsa/apmprobe.c
+++ b/sys/arch/i386/stand/libsa/apmprobe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: apmprobe.c,v 1.11 2003/08/11 06:23:09 deraadt Exp $ */
+/* $OpenBSD: apmprobe.c,v 1.12 2004/03/09 19:12:12 tom Exp $ */
/*
* Copyright (c) 1997-2000 Michael Shalayeff
@@ -35,7 +35,7 @@
* If you want to know the specification of APM BIOS, see the following
* documentations,
*
- * [1] Intel Corporation and Microsoft Corporation, "Advanced Power
+ * [1] Intel Corporation and Microsoft Corporation, "Advanced Power
* Management, The Next Generation, Version 1.0", Feb.,1992.
*
* [2] Intel Corporation and Microsoft Corporation, "Advanced Power
@@ -46,7 +46,7 @@
* or contact
*
* APM Support Desk (Intel Corporation, US)
- * TEL: (800)628-8686
+ * TEL: (800)628-8686
* FAX: (916)356-6100.
*/
@@ -68,14 +68,16 @@ apm_check(void)
{
register u_int detail;
register u_int8_t f;
+
__asm __volatile(DOINT(0x15) "\n\t"
- "setc %b1\n\t"
- "movzwl %%ax, %0\n\t"
- "shll $16, %%ecx\n\t"
- "orl %%ecx, %0"
- : "=a" (detail), "=b" (f)
- : "0" (APM_INSTCHECK), "1" (APM_DEV_APM_BIOS)
- : "%ecx", "cc");
+ "setc %b1\n\t"
+ "movzwl %%ax, %0\n\t"
+ "shll $16, %%ecx\n\t"
+ "orl %%ecx, %0"
+ : "=a" (detail), "=b" (f)
+ : "0" (APM_INSTCHECK), "1" (APM_DEV_APM_BIOS)
+ : "%ecx", "cc");
+
if (f || BIOS_regs.biosr_bx != 0x504d /* "PM" */ ) {
#ifdef DEBUG
if (debug)
@@ -91,32 +93,36 @@ static __inline int
apm_disconnect(void)
{
register u_int16_t rv;
+
__asm __volatile(DOINT(0x15) "\n\t"
- "setc %b0"
- : "=a" (rv)
- : "0" (APM_DISCONNECT), "b" (APM_DEV_APM_BIOS)
- : "%ecx", "%edx", "cc");
- return (rv & 0xff)? rv >> 8 : 0;
+ "setc %b0"
+ : "=a" (rv)
+ : "0" (APM_DISCONNECT), "b" (APM_DEV_APM_BIOS)
+ : "%ecx", "%edx", "cc");
+
+ return ((rv & 0xff)? rv >> 8 : 0);
}
static __inline int
apm_connect(bios_apminfo_t *ai)
{
register u_int16_t f;
+
__asm __volatile (DOINT(0x15) "\n\t"
- "setc %b1\n\t"
- "movb %%ah, %h1\n\t"
- "movzwl %%ax, %%eax\n\tshll $4, %0\n\t"
- "movzwl %%cx, %%ecx\n\tshll $4, %2\n\t"
- "movzwl %%dx, %%edx\n\tshll $4, %3\n\t"
- : "=a" (ai->apm_code32_base),
- "=b" (f),
- "=c" (ai->apm_code16_base),
- "=d" (ai->apm_data_base)
- : "0" (APM_PROT32_CONNECT), "1" (APM_DEV_APM_BIOS)
- : "cc");
+ "setc %b1\n\t"
+ "movb %%ah, %h1\n\t"
+ "movzwl %%ax, %%eax\n\tshll $4, %0\n\t"
+ "movzwl %%cx, %%ecx\n\tshll $4, %2\n\t"
+ "movzwl %%dx, %%edx\n\tshll $4, %3\n\t"
+ : "=a" (ai->apm_code32_base),
+ "=b" (f),
+ "=c" (ai->apm_code16_base),
+ "=d" (ai->apm_data_base)
+ : "0" (APM_PROT32_CONNECT), "1" (APM_DEV_APM_BIOS)
+ : "cc");
+
if (f & 0xff)
- return f >> 8;
+ return (f >> 8);
ai->apm_entry = BIOS_regs.biosr_bx;
#if 0
@@ -129,25 +135,24 @@ apm_connect(bios_apminfo_t *ai)
ai->apm_data_len = 0xffff - (ai->apm_data_base & 0xffff);
#endif
if (ai->apm_data_base < BOOTARG_OFF)
- ai->apm_data_len =
- NBPG - (ai->apm_data_base & PGOFSET) - 1;
+ ai->apm_data_len = NBPG - (ai->apm_data_base & PGOFSET) - 1;
#ifdef DEBUG
if (debug)
- printf ("cs=%x:%x/%x:%x, ds=%x:%x\n",
- ai->apm_code32_base, ai->apm_code_len,
- ai->apm_code16_base, ai->apm_code16_len,
- ai->apm_data_base, ai->apm_data_len);
+ printf("cs=%x:%x/%x:%x, ds=%x:%x\n",
+ ai->apm_code32_base, ai->apm_code_len,
+ ai->apm_code16_base, ai->apm_code16_len,
+ ai->apm_data_base, ai->apm_data_len);
#endif
/* inform apm bios about our driver version */
__asm __volatile (DOINT(0x15) "\n\t"
- "setc %b1\n\t"
- "movb %%ah, %h1"
- : "=b" (f)
- : "a" (APM_DRIVER_VERSION),
- "0" (APM_DEV_APM_BIOS),
- "c" (APM_VERSION)
- : "cc");
+ "setc %b1\n\t"
+ "movb %%ah, %h1"
+ : "=b" (f)
+ : "a" (APM_DRIVER_VERSION),
+ "0" (APM_DEV_APM_BIOS),
+ "c" (APM_VERSION)
+ : "cc");
return 0;
}
@@ -160,16 +165,17 @@ apmprobe(void)
if ((ai.apm_detail = apm_check())) {
apm_disconnect();
+
if (apm_connect(&ai) != 0)
printf(": connect error\n");
#ifdef DEBUG
if (debug)
printf("apm[%x cs=%x[%x]/%x[%x] ds=%x[%x] @ %x]",
- ai.apm_detail,
- ai.apm_code32_base, ai.apm_code_len,
- ai.apm_code16_base, ai.apm_code16_len,
- ai.apm_data_base, ai.apm_data_len,
- ai.apm_entry);
+ ai.apm_detail,
+ ai.apm_code32_base, ai.apm_code_len,
+ ai.apm_code16_base, ai.apm_code16_len,
+ ai.apm_data_base, ai.apm_data_len,
+ ai.apm_entry);
else
printf(" apm");
#else
@@ -187,6 +193,5 @@ apmfixmem(void)
#endif
if (ai.apm_detail)
mem_delete(i386_trunc_page(ai.apm_data_base),
- i386_round_page(ai.apm_data_base + ai.apm_data_len));
+ i386_round_page(ai.apm_data_base + ai.apm_data_len));
}
-