diff options
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/i386/include/biosvar.h | 9 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/Makefile | 4 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/apmprobe.c | 152 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/cmd_i386.c | 6 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/diskprobe.c | 103 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/libsa.h | 4 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/machdep.c | 108 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/memprobe.c | 36 |
8 files changed, 289 insertions, 133 deletions
diff --git a/sys/arch/i386/include/biosvar.h b/sys/arch/i386/include/biosvar.h index 1aa6add713b..f6876ed487a 100644 --- a/sys/arch/i386/include/biosvar.h +++ b/sys/arch/i386/include/biosvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: biosvar.h,v 1.17 1997/10/17 15:03:15 weingart Exp $ */ +/* $OpenBSD: biosvar.h,v 1.18 1997/10/17 18:47:00 weingart Exp $ */ /* * Copyright (c) 1997 Michael Shalayeff @@ -124,11 +124,11 @@ struct EDD_CB { u_int64_t edd_daddr; /* starting block */ }; -struct BIOS_MAP { +typedef struct _bios_memmap { u_int32_t addr; /* Beginning of block */ u_int32_t size; /* Size of block */ int type; /* Type of block */ -}; +} bios_memmap_t; /* Info about disk from the bios, plus the mapping from * BIOS numbers to BSD major (driver?) number. @@ -147,6 +147,9 @@ typedef struct _bios_diskinfo { /* BSD section */ signed int bsd_major; /* Major number of driver (or -1) */ + + /* Checksum section */ + u_int32_t checksum; /* Checksum for drive */ } bios_diskinfo_t; diff --git a/sys/arch/i386/stand/libsa/Makefile b/sys/arch/i386/stand/libsa/Makefile index dd0e818b045..843a4acf4ce 100644 --- a/sys/arch/i386/stand/libsa/Makefile +++ b/sys/arch/i386/stand/libsa/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.27 1997/10/17 15:03:20 weingart Exp $ +# $OpenBSD: Makefile,v 1.28 1997/10/17 18:46:54 weingart Exp $ LIB= sa @@ -15,7 +15,7 @@ DIR_KERN=$S/lib/libkern # i386 stuff (so, it will possibly load in the same 64k) SRCS= gidt.S debug_i386.S alloca.S \ machdep.c dev_i386.c exec_i386.c cmd_i386.c \ - biosdev.c bioscons.c gateA20.c smpprobe.c \ + biosdev.c bioscons.c gateA20.c apmprobe.c \ memprobe.c diskprobe.c time.c # stand routines diff --git a/sys/arch/i386/stand/libsa/apmprobe.c b/sys/arch/i386/stand/libsa/apmprobe.c new file mode 100644 index 00000000000..772fa478ef8 --- /dev/null +++ b/sys/arch/i386/stand/libsa/apmprobe.c @@ -0,0 +1,152 @@ +/* $OpenBSD: apmprobe.c,v 1.1 1997/10/17 18:46:53 weingart 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. + * + */ +/* + * APM derived from: apm_init.S, LP (Laptop Package) + * wich contained this: + * Copyright (C) 1994 by HOSOKAWA, Tatsumi <hosokawa@mt.cs.keio.ac.jp> + * + */ +/* + * 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/apmvar.h> +#include <machine/biosvar.h> +#include "debug.h" + +extern struct BIOS_vars BIOS_vars; + +static __inline u_int +apm_check() +{ + 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"); + if (f || BIOS_regs.biosr_bx != 0x504d /* "PM" */ ) { +#ifdef DEBUG + printf("apm_check: %x, %x, %x\n", + f, BIOS_regs.biosr_bx, detail); +#endif + 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) + : "0" (APM_DISCONNECT), "b" (APM_DEV_APM_BIOS) + : "%ecx", "%edx", "cc"); + return (rv & 0xff)? rv >> 8 : 0; +} + +static __inline int +apm_connect() +{ + 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" (BIOS_vars.bios_apm_code32_base), + "=b" (f), + "=c" (BIOS_vars.bios_apm_code16_base), + "=d" (BIOS_vars.bios_apm_data_base) + : "0" (APM_PROT32_CONNECT), "1" (APM_DEV_APM_BIOS) + : "cc"); + BIOS_vars.bios_apm_entry = BIOS_regs.biosr_bx; +#if 0 + BIOS_vars.bios_apm_code_len = BIOS_regs.biosr_si & 0xffff; + BIOS_vars.bios_apm_data_len = BIOS_regs.biosr_di & 0xffff; +#else + BIOS_vars.bios_apm_code_len = 0x10000; + BIOS_vars.bios_apm_data_len = 0x10000; +#endif + return (f & 0xff)? f >> 8 : 0; +} + +void +apmprobe() +{ + if ((BIOS_vars.bios_apm_detail = apm_check())) { + + printf("apm0"); + apm_disconnect(); + if (apm_connect() != 0) + printf(": connect error\n"); +#ifdef DEBUG + printf(": %x text=%x/%x[%x] data=%x[%x] @ %x", + BIOS_vars.bios_apm_detail, + BIOS_vars.bios_apm_code32_base, + BIOS_vars.bios_apm_code16_base, + BIOS_vars.bios_apm_code_len, + BIOS_vars.bios_apm_data_base, + BIOS_vars.bios_apm_data_len, + BIOS_vars.bios_apm_entry); +#else + printf(" detected"); +#endif + putchar('\n'); + } +} + diff --git a/sys/arch/i386/stand/libsa/cmd_i386.c b/sys/arch/i386/stand/libsa/cmd_i386.c index 1934e21dff8..9b087eda4ab 100644 --- a/sys/arch/i386/stand/libsa/cmd_i386.c +++ b/sys/arch/i386/stand/libsa/cmd_i386.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd_i386.c,v 1.10 1997/10/17 15:03:23 weingart Exp $ */ +/* $OpenBSD: cmd_i386.c,v 1.11 1997/10/17 18:46:55 weingart Exp $ */ /* * Copyright (c) 1997 Michael Shalayeff, Tobias Weingartner @@ -51,6 +51,8 @@ int bootbuf __P((int, int)); /* From probedisk.c */ extern bios_diskinfo_t bios_diskinfo[]; +/* From probemem.c */ +extern bios_memmap_t *memory_map; const struct cmd_table cmd_machine[] = { { "diskinfo", CMDT_CMD, Xdiskinfo }, @@ -144,7 +146,7 @@ bad: int Xmemory() { - struct BIOS_MAP *tm = memory_map; + bios_memmap_t *tm = memory_map; int count, total = 0; for(count = 0; tm[count].type != BIOS_MAP_END; count++){ diff --git a/sys/arch/i386/stand/libsa/diskprobe.c b/sys/arch/i386/stand/libsa/diskprobe.c new file mode 100644 index 00000000000..4cc947f8d25 --- /dev/null +++ b/sys/arch/i386/stand/libsa/diskprobe.c @@ -0,0 +1,103 @@ +/* $OpenBSD: diskprobe.c,v 1.1 1997/10/17 18:46:56 weingart Exp $ */ + +/* + * Copyright (c) 1997 Tobias Weingartner + * 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 Tobias Weingartner. + * 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. + * + */ + +#include <sys/param.h> +#include <machine/biosvar.h> +#include "biosdev.h" +#include "libsa.h" + + +/* These get passed to kernel */ +bios_diskinfo_t bios_diskinfo[16]; + + +void +diskprobe() +{ + int drive, i = 0; + + printf("Probing disks:"); + + /* Floppies */ + for(drive = 0; drive < 4; drive++){ + u_int32_t p = biosdinfo(drive); + + if(BIOSNSECTS(p) < 2) continue; + if(p){ + u_int32_t t = biosdprobe(drive); + if(t & 0x00FF) continue; + if(!(t & 0xFF00)) continue; + + printf(" fd%d", drive); + + /* Fill out best we can */ + bios_diskinfo[i].bsd_major = 2; /* fd? */ + bios_diskinfo[i].bios_number = drive; + bios_diskinfo[i].bios_cylinders = BIOSNTRACKS(p); + bios_diskinfo[i].bios_heads = BIOSNHEADS(p); + bios_diskinfo[i].bios_sectors = BIOSNSECTS(p); + + i++; + } + } + + /* Hard disks */ + for(drive = 0x80; drive < 0x88; drive++){ + u_int32_t p = biosdinfo(drive); + + if(BIOSNSECTS(p) < 2) continue; + if(p){ + u_int32_t t = biosdprobe(drive); + if(t & 0x00FF) continue; + if(!(t & 0xFF00)) continue; + + printf(" hd%d", drive - 128); + + /* Fill out best we can */ + bios_diskinfo[i].bsd_major = -1; /* XXX - fill in */ + bios_diskinfo[i].bios_number = drive; + bios_diskinfo[i].bios_cylinders = BIOSNTRACKS(p); + bios_diskinfo[i].bios_heads = BIOSNHEADS(p); + bios_diskinfo[i].bios_sectors = BIOSNSECTS(p); + + i++; + } + } + + /* End of list */ + bios_diskinfo[i].bios_number = -1; + + printf("\n"); +} + diff --git a/sys/arch/i386/stand/libsa/libsa.h b/sys/arch/i386/stand/libsa/libsa.h index 15ac5f6d5ca..e423af1810b 100644 --- a/sys/arch/i386/stand/libsa/libsa.h +++ b/sys/arch/i386/stand/libsa/libsa.h @@ -1,4 +1,4 @@ -/* $OpenBSD: libsa.h,v 1.18 1997/10/17 15:03:26 weingart Exp $ */ +/* $OpenBSD: libsa.h,v 1.19 1997/10/17 18:46:57 weingart Exp $ */ /* * Copyright (c) 1996 Michael Shalayeff @@ -38,6 +38,7 @@ void gateA20 __P((int)); void smpprobe __P((void)); void memprobe __P((void)); void diskprobe __P((void)); +void apmprobe __P((void)); void devboot __P((dev_t, char *)); void *alloca __P((size_t)); void machdep __P((void)); @@ -45,7 +46,6 @@ void time_print __P((void)); extern const char bdevs[][4]; extern const int nbdevs; -extern struct BIOS_MAP *memory_map; extern int bootdev; /* XXX pass through the global to exec_i386 */ extern u_int cnvmem, extmem; /* XXX global pass memprobe()->machdep_start() */ diff --git a/sys/arch/i386/stand/libsa/machdep.c b/sys/arch/i386/stand/libsa/machdep.c index 14ee4567561..61dc35f4371 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.18 1997/10/17 15:03:27 weingart Exp $ */ +/* $OpenBSD: machdep.c,v 1.19 1997/10/17 18:46:58 weingart Exp $ */ /* * Copyright (c) 1997 Michael Shalayeff @@ -31,30 +31,6 @@ * SUCH DAMAGE. * */ -/* - * APM derived from: apm_init.S, LP (Laptop Package) - * wich contained this: - * Copyright (C) 1994 by HOSOKAWA, Tatsumi <hosokawa@mt.cs.keio.ac.jp> - * - */ -/* - * 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/apmvar.h> @@ -71,67 +47,6 @@ int bootdev; #define CKPT(c) /* c */ #endif -static __inline u_int -apm_check() -{ - 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"); - if (f || BIOS_regs.biosr_bx != 0x504d /* "PM" */ ) { -#ifdef DEBUG - printf("apm_check: %x, %x, %x\n", - f, BIOS_regs.biosr_bx, detail); -#endif - 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) - : "0" (APM_DISCONNECT), "b" (APM_DEV_APM_BIOS) - : "%ecx", "%edx", "cc"); - return (rv & 0xff)? rv >> 8 : 0; -} - -static __inline int -apm_connect() -{ - 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" (BIOS_vars.bios_apm_code32_base), - "=b" (f), - "=c" (BIOS_vars.bios_apm_code16_base), - "=d" (BIOS_vars.bios_apm_data_base) - : "0" (APM_PROT32_CONNECT), "1" (APM_DEV_APM_BIOS) - : "cc"); - BIOS_vars.bios_apm_entry = BIOS_regs.biosr_bx; -#if 0 - BIOS_vars.bios_apm_code_len = BIOS_regs.biosr_si & 0xffff; - BIOS_vars.bios_apm_data_len = BIOS_regs.biosr_di & 0xffff; -#else - BIOS_vars.bios_apm_code_len = 0x10000; - BIOS_vars.bios_apm_data_len = 0x10000; -#endif - return (f & 0xff)? f >> 8 : 0; -} void machdep() @@ -146,26 +61,7 @@ machdep() diskprobe(); CKPT('6'); #endif - if ((BIOS_vars.bios_apm_detail = apm_check())) { - - printf("apm0"); - apm_disconnect(); - if (apm_connect() != 0) - printf(": connect error\n"); -#ifdef DEBUG - printf(": %x text=%x/%x[%x] data=%x[%x] @ %x", - BIOS_vars.bios_apm_detail, - BIOS_vars.bios_apm_code32_base, - BIOS_vars.bios_apm_code16_base, - BIOS_vars.bios_apm_code_len, - BIOS_vars.bios_apm_data_base, - BIOS_vars.bios_apm_data_len, - BIOS_vars.bios_apm_entry); -#else - printf(" detected"); -#endif - putchar('\n'); - } + apmprobe(); CKPT('7'); CKPT('9'); } diff --git a/sys/arch/i386/stand/libsa/memprobe.c b/sys/arch/i386/stand/libsa/memprobe.c index 64e25790cee..a8c0b51a683 100644 --- a/sys/arch/i386/stand/libsa/memprobe.c +++ b/sys/arch/i386/stand/libsa/memprobe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: memprobe.c,v 1.15 1997/10/17 15:03:28 weingart Exp $ */ +/* $OpenBSD: memprobe.c,v 1.16 1997/10/17 18:46:58 weingart Exp $ */ /* * Copyright (c) 1997 Tobias Weingartner @@ -38,7 +38,7 @@ static int addrprobe __P((u_int)); u_int cnvmem, extmem; /* XXX - remove */ -struct BIOS_MAP *memory_map; +bios_memmap_t *memory_map; struct E820_desc_t { u_int32_t addr_lo; @@ -56,10 +56,10 @@ static struct E820_desc_t Desc; * * This is the "prefered" method. */ -struct BIOS_MAP * +bios_memmap_t * bios_E820() { - static struct BIOS_MAP bm[E820_MAX_MAPENT]; /* This is easier */ + static bios_memmap_t bm[E820_MAX_MAPENT]; /* This is easier */ int E820Present = 0; int eax = 0, count = 0; volatile int ebx = 0; @@ -116,10 +116,10 @@ bios_E820() * Only used if int 15, AX=E820 does not work. * This should work for more than 64MB. */ -struct BIOS_MAP * +bios_memmap_t * bios_E801() { - static struct BIOS_MAP bm[3]; + static bios_memmap_t bm[3]; int eax, edx = 0; /* Test for 0xE801 */ @@ -168,10 +168,10 @@ bios_E801() * Only used if int 15, AX=E801 does not work. * Machines with this are restricted to 64MB. */ -struct BIOS_MAP * +bios_memmap_t * bios_8800() { - static struct BIOS_MAP bm[2]; + static bios_memmap_t bm[2]; int eax, mem; __asm __volatile( @@ -202,10 +202,10 @@ bios_8800() * * Only used if int 15, AX=E820 does not work. */ -struct BIOS_MAP * +bios_memmap_t * bios_int12() { - static struct BIOS_MAP bm[2]; + static bios_memmap_t bm[2]; int mem; printf("int 0x12\n"); @@ -291,10 +291,10 @@ addrprobe(kloc) * XXX - Does not detect aliases memory. * XXX - Could be destructive, as it does write. */ -struct BIOS_MAP * +bios_memmap_t * badprobe() { - static struct BIOS_MAP bm[2]; + static bios_memmap_t bm[2]; int ram; printf("Physical, "); @@ -319,7 +319,7 @@ badprobe() int count(map) - struct BIOS_MAP *map; + bios_memmap_t *map; { int i; @@ -329,18 +329,18 @@ count(map) } -struct BIOS_MAP * +bios_memmap_t * combine(a, b) - struct BIOS_MAP *a, *b; + bios_memmap_t *a, *b; { - struct BIOS_MAP *res; + bios_memmap_t *res; int size, i; /* Sanity checks */ if(!b) return(a); if(!a) return(b); - size = (count(a) + count(b) + 1) * sizeof(struct BIOS_MAP); + size = (count(a) + count(b) + 1) * sizeof(bios_memmap_t); res = alloc(size); /* Again */ @@ -360,7 +360,7 @@ combine(a, b) void memprobe() { - struct BIOS_MAP *tm, *em, *bm; /* total, extended, base */ + bios_memmap_t *tm, *em, *bm; /* total, extended, base */ int count, total = 0; printf("Probing memory: "); |