diff options
author | Michael Shalayeff <mickey@cvs.openbsd.org> | 1997-08-13 03:23:40 +0000 |
---|---|---|
committer | Michael Shalayeff <mickey@cvs.openbsd.org> | 1997-08-13 03:23:40 +0000 |
commit | daf90fcb1ba193cf77c6980ede34ed072cf2d3b9 (patch) | |
tree | b680b1f1336cca2860cfe312a66d032d77702d2a /sys/arch | |
parent | 4556f693eb048e1494ecd07503270a3ad5191df1 (diff) |
inline calls
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/i386/stand/libsa/apm_init.S | 130 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/machdep.c | 152 |
2 files changed, 102 insertions, 180 deletions
diff --git a/sys/arch/i386/stand/libsa/apm_init.S b/sys/arch/i386/stand/libsa/apm_init.S deleted file mode 100644 index d86872e39a4..00000000000 --- a/sys/arch/i386/stand/libsa/apm_init.S +++ /dev/null @@ -1,130 +0,0 @@ -/* $OpenBSD: apm_init.S,v 1.4 1997/07/30 19:40:53 flipk Exp $ */ - -/* - * Copyright (c) 1997 Michael Shalayeff - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Michael Shalayeff. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - */ - -/* - * LP (Laptop Package) - * - * Copyright (C) 1994 by HOSOKAWA, Tatsumi <hosokawa@mt.cs.keio.ac.jp> - * - * This software may be used, modified, copied, and distributed, in - * both source and binary form provided that the above copyright and - * these terms are retained. Under no circumstances is the author - * responsible for the proper functioning of this software, nor does - * the author assume any responsibility for damages incurred with its - * use. - * - * Sep., 1994 Implemented on FreeBSD 1.1.5.1R (Toshiba AVS001WD) - * Oct., 1994 NetBSD port (1.0 BETA 10/2) by ukai - */ - -/* - * If you want to know the specification of APM BIOS, see the following - * documentations, - * - * [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 - * Management (APM) BIOS Interface Specification Revision 1.1", - * Sep.,1993, Intel Order Number: 241704-001, Microsoft Part - * Number: 781-110-X01 - * - * or contact - * - * APM Support Desk (Intel Corporation, US) - * TEL: (800)628-8686 - * FAX: (916)356-6100. - */ - - .file "apm_init.S" - -#include <machine/asm.h> -#define _LOCORE -#include <machine/biosvar.h> -#include <machine/apmvar.h> -#undef _LOCORE -#include <assym.h> - - .globl _C_LABEL(BIOS_regs) - .text -ENTRY(apm_init) - pushl %ebx - - /* - * APM installation check - */ - movb $(APM_BIOS), %ah - movb $(APM_INSTCHECK), %al - movl $(PMDV_APMBIOS), %ebx - DOINT(SYSTEM_BIOS) /* call system BIOS */ - jnc 1f /* if found, goto 1f */ - - movl $(APMINI_CANTFIND), %eax - jmp 5f /* can't find APM BIOS */ -1: - shll $16, %eax - orw %cx, %ax - rorl $16, %eax - movl _C_LABEL(BIOS_regs)+biosr_bx, %ebx - cmpb $'P', %bh - jne 1f - cmpb $'M', %bl - je 2f - -1: movl $(APMINI_BADVER), %eax - jmp 5f /* can't find APM BIOS */ - -2: testl $(APM_32BIT_SUPPORT), %ecx - jnz 1f /* supports 32bit connection? */ - - movl $(APMINI_NOT32BIT), %eax - jmp 5f /* don't support 32bit connection */ -1: - pushl %eax - /* - * APM Protected Mode 32-bit Interface Connect - */ - movb $(APM_BIOS), %ah - movb $(APM_DISCONNECT), %al /* just in case bootloader connected*/ - movl $(PMDV_APMBIOS), %ebx - DOINT(SYSTEM_BIOS) - movb $(APM_BIOS), %ah - movb $(APM_PROT32CONNECT), %al - movl $(PMDV_APMBIOS), %ebx - DOINT(SYSTEM_BIOS) - popl %eax - jnc 5f /* if successed, go to 1f */ - movl $(APMINI_CONNECTERR), %eax -5: popl %ebx - ret diff --git a/sys/arch/i386/stand/libsa/machdep.c b/sys/arch/i386/stand/libsa/machdep.c index 8adffedd699..a2e9d907eae 100644 --- a/sys/arch/i386/stand/libsa/machdep.c +++ b/sys/arch/i386/stand/libsa/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.8 1997/08/12 21:51:30 mickey Exp $ */ +/* $OpenBSD: machdep.c,v 1.9 1997/08/13 03:23:39 mickey Exp $ */ /* * Copyright (c) 1997 Michael Shalayeff @@ -32,69 +32,120 @@ * */ +/* + * If you want to know the specification of APM BIOS, see the following + * documentations, + * + * [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 + * Management (APM) BIOS Interface Specification Revision 1.1", + * Sep.,1993, Intel Order Number: 241704-001, Microsoft Part + * Number: 781-110-X01 + * + * or contact + * + * APM Support Desk (Intel Corporation, US) + * TEL: (800)628-8686 + * FAX: (916)356-6100. + */ + #include "libsa.h" -#include <machine/biosvar.h> #include <machine/apmvar.h> +#undef APM_DISCONNECT /* XXX temp hack */ +#include <machine/biosvar.h> #include "debug.h" struct apm_connect_info apminfo; -void -machdep() -{ #ifdef DEBUG - *(u_int16_t*)0xb8148 = 0x4730; +#define CKPT(c) (*(u_int16_t*)0xb8148 = 0x4700 + (c)) +#else +#define CKPT(c) /* c */ #endif - gateA20(1); + +#ifdef BOOT_APM +static u_int +apm_init() +{ + u_int detail; + u_int8_t f; + __asm __volatile(DOINT(0x15) "\n\t" + "setc %b0\n\t" + "shll $16, %%ecx\n\t" + "movzwl %%ax, %1\n\t" + "orl %%ecx, %1" + : "=d" (f), "=a" (detail) + : "1" (APM_INSTCHECK), "b" (PMDV_APMBIOS) + : "%ecx", "cc"); + if (f || BIOS_regs.biosr_bx != 0x504d /* "PM" */ ) { #ifdef DEBUG - *(u_int16_t*)0xb8148 = 0x4731; + printf("apm_init: %x, %x, %x\n", f, BIOS_regs.biosr_bx, detail); #endif - debug_init(); -#ifdef DEBUG - *(u_int16_t*)0xb8148 = 0x4732; + return 0; + } else + return detail; +} + +static __inline int +apm_disconnect() { + register u_int16_t rv; + __asm __volatile(DOINT(0x15) "\n\t" + "setc %b0" + : "=a" (rv) + : "a" (APM_DISCONNECT), "b" (PMDV_APMBIOS) + : "%ecx", "%edx", "cc"); + return (rv & 0xff)? rv >> 8 : 0; +} + +static __inline int +apm_connect(struct apm_connect_info *apminfo) +{ + register u_int16_t f; + __asm __volatile (DOINT(0x15) "\n\t" + "setc %b0\n\t" + "movb %%ah, %h0\n\t" + "movzwl %%ax, %%eax\n\tshll $4, %1\n\t" + "movzwl %%cx, %%ecx\n\tshll $4, %2\n\t" + "movzwl %%dx, %%edx\n\tshll $4, %3\n\t" + : "=b" (f), + "=a" (apminfo->apm_code32_seg_base), + "=c" (apminfo->apm_code16_seg_base), + "=d" (apminfo->apm_data_seg_base) + : "a" (APM_PROT32CONNECT), "b" (PMDV_APMBIOS) + : "cc"); + apminfo->apm_entrypt = BIOS_regs.biosr_bx; +#if 0 + apminfo->apm_code32_seg_len = BIOS_regs.biosr_si & 0xffff; + apminfo->apm_data_seg_len = BIOS_regs.biosr_di & 0xffff; +#else + apminfo->apm_code32_seg_len = 0x10000; + apminfo->apm_data_seg_len = 0x10000; #endif - cninit(); /* call console init before doing any io */ -#ifdef DEBUG - *(u_int16_t*)0xb8148 = 0x4733; + return (f & 0xff)? f >> 8 : 0; +} #endif + +void +machdep() +{ + /* here */ CKPT('0'); + gateA20(1); CKPT('1'); + debug_init(); CKPT('2'); + /* call console init before doing any io */ + cninit(); CKPT('3'); #ifndef _TEST - memprobe(); + memprobe(); CKPT('4'); #endif -#ifdef DEBUG - *(u_int16_t*)0xb8148 = 0x4f34; -#endif -#ifdef BOOT_APM - printf("apm_init: "); - switch(apminfo.apm_detail = apm_init()) { - case APMINI_CANTFIND: - printf("not supported"); - break; - - case APMINI_NOT32BIT: - printf("no 32 bit interface"); - break; - - case APMINI_CONNECTERR: - printf("connect error"); - break; - case APMINI_BADVER: - printf("bad version"); - break; +#ifdef BOOT_APM + if ((apminfo.apm_detail = apm_init())) { - default: - /* valid: detail, dx, bx */ - apminfo.apm_code32_seg_base = (BIOS_regs.biosr_ax & 0xffff)<< 4; - apminfo.apm_code16_seg_base = (BIOS_regs.biosr_cx & 0xffff)<< 4; - apminfo.apm_data_seg_base = (BIOS_regs.biosr_dx & 0xffff)<< 4; -#if 0 - apminfo.apm_code32_seg_len = BIOS_regs.biosr_si & 0xffff; - apminfo.apm_data_seg_len = BIOS_regs.biosr_di & 0xffff; -#else - apminfo.apm_code32_seg_len = 0x10000; - apminfo.apm_data_seg_len = 0x10000; -#endif - apminfo.apm_entrypt = BIOS_regs.biosr_bx; + printf("apm: "); + apm_disconnect(); + if (apm_connect(&apminfo) != 0) + printf("connect error\n"); #ifdef DEBUG printf("%x text=%x/%x[%x] data=%x[%x] @ %x", apminfo.apm_detail, @@ -105,9 +156,10 @@ machdep() apminfo.apm_data_seg_len, apminfo.apm_entrypt); #else - printf("APM detected"); + printf("present"); #endif + putchar('\n'); } - putchar('\n'); #endif + CKPT('9'); } |