diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1998-04-18 07:40:04 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1998-04-18 07:40:04 +0000 |
commit | 888b63e1743ef4b4277b88169301e0b5c1445e16 (patch) | |
tree | 5b9d1c51879f3e1f909c17e6ec7c2f6050ac92e1 /sys/arch/i386/stand/libsa | |
parent | c2ee71fae9cec63f4a94c921619dc28d1c5b5032 (diff) |
i386 bootblocks that work for 2.3. A tale too long to tell
Diffstat (limited to 'sys/arch/i386/stand/libsa')
-rw-r--r-- | sys/arch/i386/stand/libsa/apmprobe.c | 22 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/bioscons.c | 14 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/biosdev.c | 66 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/debug.c | 85 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/debug.h | 5 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/debug_i386.S | 79 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/debug_md.h | 10 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/dev_i386.c | 25 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/diskprobe.c | 18 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/gidt.S | 42 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/machdep.c | 4 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/memprobe.c | 43 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/smpprobe.c | 76 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/time.c | 10 |
14 files changed, 300 insertions, 199 deletions
diff --git a/sys/arch/i386/stand/libsa/apmprobe.c b/sys/arch/i386/stand/libsa/apmprobe.c index aee1192594c..049c503f8f1 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.4 1998/02/24 22:06:44 weingart Exp $ */ +/* $OpenBSD: apmprobe.c,v 1.5 1998/04/18 07:39:40 deraadt Exp $ */ /* * Copyright (c) 1997 Michael Shalayeff @@ -62,6 +62,8 @@ #include <machine/biosvar.h> #include "debug.h" +extern int debug; + static __inline u_int apm_check() { @@ -77,8 +79,9 @@ apm_check() : "%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); + if (debug) + printf("apm_check: %x, %x, %x\n", + f, BIOS_regs.biosr_bx, detail); #endif return 0; } else @@ -136,11 +139,14 @@ apmprobe() if (apm_connect(&ai) != 0) printf(": connect error\n"); #ifdef DEBUG - printf(": %x text=%x/%x[%x] data=%x[%x] @ %x", - ai.apm_detail, ai.apm_code32_base, - ai.apm_code16_base, ai.apm_code_len, - ai.apm_data_base, ai.apm_data_len, - ai.apm_entry); + if (debug) + printf(": %x text=%x/%x[%x] data=%x[%x] @ %x", + ai.apm_detail, ai.apm_code32_base, + ai.apm_code16_base, ai.apm_code_len, + ai.apm_data_base, ai.apm_data_len, + ai.apm_entry); + else + printf(" apm"); #else printf(" apm"); #endif diff --git a/sys/arch/i386/stand/libsa/bioscons.c b/sys/arch/i386/stand/libsa/bioscons.c index 0055ba62b5a..83b85799f5c 100644 --- a/sys/arch/i386/stand/libsa/bioscons.c +++ b/sys/arch/i386/stand/libsa/bioscons.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bioscons.c,v 1.13 1997/10/24 22:21:15 mickey Exp $ */ +/* $OpenBSD: bioscons.c,v 1.14 1998/04/18 07:39:41 deraadt Exp $ */ /* * Copyright (c) 1997 Michael Shalayeff @@ -42,6 +42,7 @@ #include <i386/isa/nvram.h> #include <dev/cons.h> #include <lib/libsa/stand.h> +#include "debug.h" int comspeed __P((dev_t, int)); @@ -67,6 +68,11 @@ void pc_probe(cn) struct consdev *cn; { + cn->cn_pri = CN_INTERNAL; + cn->cn_dev = makedev(12, 0); + printf("pc%d detected\n", minor(cn->cn_dev)); + +#if 0 outb(IO_RTC, NVRAM_EQUIPMENT); if ((inb(IO_RTC+1) & PRESENT_MASK) == PRESENT_MASK) { cn->cn_pri = CN_INTERNAL; @@ -74,6 +80,7 @@ pc_probe(cn) cn->cn_dev = makedev(12, 0); printf("pc%d detected\n", minor(cn->cn_dev)); } +#endif } void @@ -109,7 +116,7 @@ pc_putc(dev, c) "%ecx", "%edx", "cc" ); } -static const int comports[4] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8 }; +const int comports[4] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8 }; void com_probe(cn) @@ -162,12 +169,12 @@ com_getc(dev) } /* call with sp == 0 to query the current speed */ +int com_speed = 9600; /* default speed is 9600 baud */ int comspeed(dev, sp) dev_t dev; int sp; { - static int com_speed = 9600; /* default speed is 9600 baud */ int i, newsp; int err; @@ -223,3 +230,4 @@ com_putc(dev, c) __asm __volatile(DOINT(0x14) : "=a" (rv) : "d" (minor(dev)), "0" (c | 0x100) : "%ecx", "cc" ); } + diff --git a/sys/arch/i386/stand/libsa/biosdev.c b/sys/arch/i386/stand/libsa/biosdev.c index cb5e4a6599b..899a7dc50e0 100644 --- a/sys/arch/i386/stand/libsa/biosdev.c +++ b/sys/arch/i386/stand/libsa/biosdev.c @@ -1,4 +1,4 @@ -/* $OpenBSD: biosdev.c,v 1.50 1998/02/24 22:06:46 weingart Exp $ */ +/* $OpenBSD: biosdev.c,v 1.51 1998/04/18 07:39:42 deraadt Exp $ */ /* * Copyright (c) 1996 Michael Shalayeff @@ -93,7 +93,8 @@ bios_getdiskinfo(dev, pdi) biosdreset(dev); #ifdef BIOS_DEBUG - printf("getinfo: try #8, %x,%p\n", dev, pdi); + if (debug) + printf("getinfo: try #8, %x,%p\n", dev, pdi); #endif __asm __volatile (DOINT(0x13) "\n\t" "setc %b0; movzbl %h1, %1\n\t" @@ -105,9 +106,11 @@ bios_getdiskinfo(dev, pdi) : "0" (0x0800), "1" (dev) : "cc"); #ifdef BIOS_DEBUG - printf("getinfo: got #8\n"); - printf("disk 0x%x: %d,%d,%d\n", dev, pdi->bios_cylinders, - pdi->bios_heads, pdi->bios_sectors); + if (debug) { + printf("getinfo: got #8\n"); + printf("disk 0x%x: %d,%d,%d\n", dev, pdi->bios_cylinders, + pdi->bios_heads, pdi->bios_sectors); + } #endif if (rv & 0xff) return(1); @@ -264,7 +267,9 @@ biosd_io(rw, dev, cyl, head, sect, nsect, buf) default: /* All other errors */ #ifdef BIOS_DEBUG - printf("\nBIOS error 0x%x (%s)\n", error, biosdisk_err(error)); + if (debug) + printf("\nBIOS error 0x%x (%s)\n", + error, biosdisk_err(error)); #endif biosdreset(dev); break; @@ -455,11 +460,7 @@ biosopen(struct open_file *f, ...) return 0; } -static const char * -biosdisk_err(error) - u_int error; -{ - static const u_char errs[] = +const u_char bidos_errs[] = /* ignored "\x00" "successful completion\0" */ "\x01" "invalid function/parameter\0" "\x02" "address mark not found\0" @@ -494,7 +495,12 @@ biosdisk_err(error) "\xE0" "status register error\0" "\xFF" "sense operation failed\0" "\x00" "\0"; - register const u_char *p = errs; + +static const char * +biosdisk_err(error) + u_int error; +{ + register const u_char *p = bidos_errs; while (*p && *p != error) while(*p++); @@ -502,28 +508,28 @@ biosdisk_err(error) return ++p; } +const struct biosdisk_errors { + u_char error; + u_char errno; +} tab[] = { + { 0x01, EINVAL }, + { 0x03, EROFS }, + { 0x08, EINVAL }, + { 0x09, EINVAL }, + { 0x0A, EBSE }, + { 0x0B, EBSE }, + { 0x0C, ENXIO }, + { 0x0D, EINVAL }, + { 0x10, EECC }, + { 0x20, EHER }, + { 0x31, ENXIO }, + { 0x32, ENXIO }, + { 0x00, EIO } +}; static int biosdisk_errno(error) u_int error; { - static const struct biosdisk_errors { - u_char error; - u_char errno; - } tab[] = { - { 0x01, EINVAL }, - { 0x03, EROFS }, - { 0x08, EINVAL }, - { 0x09, EINVAL }, - { 0x0A, EBSE }, - { 0x0B, EBSE }, - { 0x0C, ENXIO }, - { 0x0D, EINVAL }, - { 0x10, EECC }, - { 0x20, EHER }, - { 0x31, ENXIO }, - { 0x32, ENXIO }, - { 0x00, EIO } - }; register const struct biosdisk_errors *p; if (!error) diff --git a/sys/arch/i386/stand/libsa/debug.c b/sys/arch/i386/stand/libsa/debug.c index ebe06e638bb..8c68fc4afd5 100644 --- a/sys/arch/i386/stand/libsa/debug.c +++ b/sys/arch/i386/stand/libsa/debug.c @@ -1,4 +1,4 @@ -/* $OpenBSD: debug.c,v 1.4 1997/07/17 22:50:01 mickey Exp $ */ +/* $OpenBSD: debug.c,v 1.5 1998/04/18 07:39:44 deraadt Exp $ */ /* * Copyright (c) 1997 Michael Shalayeff @@ -34,6 +34,15 @@ #include <lib/libsa/stand.h> #include <debug.h> +#include <dev/cons.h> + +#ifdef __STDC__ +void dprintf __P((const char *fmt, ...)); +#else +void dprintf (); +#endif + +#define VBASE (0xb8000) char *const reg_names[] = { REG_NAMES }; const int nreg = NENTS(reg_names); @@ -41,27 +50,83 @@ struct reg reg; u_int32_t *const reg_values[] = { REG_VALUES(reg) }; char *const trap_names[] = { TRAP_NAMES }; +void d_putc __P((dev_t, int)); + +#ifdef DEBUG_DEBUG +#define CKPT(c) (*(u_short volatile *)(VBASE+160) = (0x1700 | (c))) +#else +#define CKPT(c) /* c */ +#endif + int debug_init() { return 0; } + void -dump_regs(trapno) - int trapno; +dump_regs(trapno, arg) + u_int trapno, arg; { - int i; + register int i; + /* make it local, so it won't rely on .data/.bss corruption */ + struct consdev d_cons, *save_cons; + + /* init cons mod */ + save_cons = cn_tab; + bzero(&d_cons, sizeof(d_cons)); + d_cons.cn_putc = &d_putc; + cn_tab = &d_cons; + + /* Trap info */ + printf("\ftrap: %u(%0x): %s\ncn_tab=%p\n", + trapno, arg, trap_names[trapno], save_cons); - printf("trap: %s\n", trap_names[trapno]); - for (i = 0; i < nreg; putchar((++i % 4)?' ':'\n')) - printf ("%s=0x%x", reg_names[i], *reg_values[i]); - if (i % 4) - putchar('\n'); + /* Register dump */ + for(i = 1; i <= nreg; i++) + printf("%s\t%0x%c", reg_names[i-1], *reg_values[i-1], + ((i%4)? ' ': '\n')); + + dump_mem("Code dump", (void *)*reg_values[8], 8); + /* %ebx (void*)((*reg_values[3] + 15) & ~0x0F) */ + dump_mem("Memory dump", (void *)0x1a000, 48); + dump_mem("Stack trace", (void *)(*reg_values[4]), 48); + + /* restore the console */ + cn_tab = save_cons; } void -dump_mem() +dump_mem(l, p, n) + char *l; + void *p; + size_t n; { + register int i; + printf("%s [%p]:%s", l, p, (n > 6? "\n":" ")); + for(i = 1; i <= n; i++) + printf("%0x%c", *(u_int32_t *)p++, ((i%8)? ' ': '\n')); + if (n % 8) + printf ("\n"); +} + +u_int d_pos; + +void +d_putc(d, c) + dev_t d; + int c; +{ + switch (c) { + case '\n': d_pos += 80; break; + case '\r': d_pos -= d_pos % 80; break; + case '\b': d_pos--; break; + case '\f': bzero((void *)VBASE, 80*25*2); d_pos = 0; break; + /* print it */ + default: + ((u_int16_t volatile *)VBASE)[d_pos++] = 0x0700 | (u_char)c; + break; + } } diff --git a/sys/arch/i386/stand/libsa/debug.h b/sys/arch/i386/stand/libsa/debug.h index 5f169b8d628..67fc9addb71 100644 --- a/sys/arch/i386/stand/libsa/debug.h +++ b/sys/arch/i386/stand/libsa/debug.h @@ -1,4 +1,4 @@ -/* $OpenBSD: debug.h,v 1.3 1997/07/17 22:50:01 mickey Exp $ */ +/* $OpenBSD: debug.h,v 1.4 1998/04/18 07:39:45 deraadt Exp $ */ /* * Copyright (c) 1997 Michael Shalayeff @@ -39,4 +39,5 @@ extern char *const reg_names[]; extern const size_t nregs; int debug_init __P((void)); - +void dump_regs __P((u_int, u_int)); +void dump_mem __P((char *, void *, size_t)); diff --git a/sys/arch/i386/stand/libsa/debug_i386.S b/sys/arch/i386/stand/libsa/debug_i386.S index 35da12bed59..ffce538bade 100644 --- a/sys/arch/i386/stand/libsa/debug_i386.S +++ b/sys/arch/i386/stand/libsa/debug_i386.S @@ -1,4 +1,4 @@ -/* $OpenBSD: debug_i386.S,v 1.8 1998/02/24 22:06:48 weingart Exp $ */ +/* $OpenBSD: debug_i386.S,v 1.9 1998/04/18 07:39:46 deraadt Exp $ */ /* * Copyright (c) 1997 Michael Shalayeff @@ -40,30 +40,37 @@ #include <debug_md.h> #undef _LOCORE + /* do this way because some cpus (like cyrix 6x86) store garbage + * into high word, instead of zeroes. + */ +#define pushsr(sr) movl sr, %eax; pushl %eax + .text .globl alltraps alltraps: pushal - pushl %ds - pushl %es - pushl %fs - pushl %gs -#ifdef DEBUG + pushsr(%ds) + pushsr(%es) + pushsr(%fs) + pushsr(%gs) + /* muck %cs, see note about pushsr() above */ + movl 0xf*4(%esp), %eax + movzwl %ax, %eax + movl %eax, 0xf*4(%esp) +#ifdef DEBUG_DEBUG movl $0xb8280, %edi - movl 0x0c*4(%esp), %eax # trapno + movl 0x0c*4(%esp), %eax /* trapno */ addb $'0', %al movb $0x17, %ah shll $16, %eax - movb 0x0d*4(%esp), %al # error - addl $'0', %al + movb 0x0d*4(%esp), %al /* error */ + addb $'0', %al movb $0x17, %ah - movl %ax, (%edi) - hlt + movl %eax, (%edi) #endif - call _check_regs -1: -#ifdef DEBUG + call _C_LABEL(check_regs) +#ifdef DEBUG_DEBUG movl $0xb8290, %edi movl $0x47394738, (%edi) #endif @@ -77,41 +84,45 @@ alltraps: iret ENTRY(check_regs) -#ifdef DEBUG +#ifdef DEBUG_DEBUG movl $0xb8284, %edi movl $0x47334732, (%edi) #endif movl $0x10, %eax movl %ax, %ds + movl %ax, %es movl $_reg, %edi cld - movl 0x0c*4(%esp), %eax; stosl # %eax - movl 0x0b*4(%esp), %eax; stosl # %ecx - movl 0x0a*4(%esp), %eax; stosl # %edx - movl 0x09*4(%esp), %eax; stosl # %ebx - movl 0x08*4(%esp), %eax; stosl # %esp - movl 0x07*4(%esp), %eax; stosl # %ebp - movl 0x06*4(%esp), %eax; stosl # %esi - movl 0x05*4(%esp), %eax; stosl # %edi - movl 0x0f*4(%esp), %eax; stosl # %eip - movl 0x11*4(%esp), %eax; stosl # %eflags - movl 0x10*4(%esp), %eax; stosl # %cs - movl %ss, %eax; stosl # %ss - movl 0x04*4(%esp), %eax; stosl # %ds - movl 0x03*4(%esp), %eax; stosl # %es - movl 0x02*4(%esp), %eax; stosl # %fs - movl 0x01*4(%esp), %eax; stosl # %gs + movl 0x0c*4(%esp), %eax; stosl /* %eax */ + movl 0x0b*4(%esp), %eax; stosl /* %ecx */ + movl 0x0a*4(%esp), %eax; stosl /* %edx */ + movl 0x09*4(%esp), %eax; stosl /* %ebx */ + movl 0x08*4(%esp), %eax; stosl /* %esp */ + movl 0x07*4(%esp), %eax; stosl /* %ebp */ + movl 0x06*4(%esp), %eax; stosl /* %esi */ + movl 0x05*4(%esp), %eax; stosl /* %edi */ + movl 0x0f*4(%esp), %eax; stosl /* %eip */ + movl 0x11*4(%esp), %eax; stosl /* %eflags */ + movl 0x10*4(%esp), %eax; stosl /* %cs */ + movl %ss, %ax ; stosl /* %ss */ + movl 0x04*4(%esp), %eax; stosl /* %ds */ + movl 0x03*4(%esp), %eax; stosl /* %es */ + movl 0x02*4(%esp), %eax; stosl /* %fs */ + movl 0x01*4(%esp), %eax; stosl /* %gs */ -#ifdef DEBUG +#ifdef DEBUG_DEBUG movl $0xb8288, %edi movl $0x47354734, (%edi) #endif - movl 0x0d*4(%esp), %eax # trapno + movl 0x0e*4(%esp), %ecx /* error */ + movl 0x0d*4(%esp), %eax /* trapno */ + pushl %ecx pushl %eax call _C_LABEL(dump_regs) popl %eax + popl %eax -#ifdef DEBUG +#ifdef DEBUG_DEBUG movl $0xb828c, %edi movl $0x47374736, (%edi) #endif diff --git a/sys/arch/i386/stand/libsa/debug_md.h b/sys/arch/i386/stand/libsa/debug_md.h index a6b82672440..b88e4ea1bf3 100644 --- a/sys/arch/i386/stand/libsa/debug_md.h +++ b/sys/arch/i386/stand/libsa/debug_md.h @@ -1,4 +1,4 @@ -/* $OpenBSD: debug_md.h,v 1.3 1997/04/09 08:39:34 mickey Exp $ */ +/* $OpenBSD: debug_md.h,v 1.4 1998/04/18 07:39:47 deraadt Exp $ */ /* * Copyright (c) 1997 Michael Shalayeff @@ -33,15 +33,17 @@ */ #define REG_NAMES \ - "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi", \ - "eip", "eflags", "cs", "ss", "ds", "es", "fs", "gs" + "eax", "ecx", "edx", "ebx", "esp", \ + "ebp", "esi", "edi", "eip", "eflags", \ + "cs", "ss", "ds", "es", "fs", \ + "gs" #define REG_VALUES(r) \ &(r).r_eax, &(r).r_ecx, &(r).r_edx, &(r).r_ebx, &(r).r_esp, \ &(r).r_ebp, &(r).r_esi, &(r).r_edi, &(r).r_eip, &(r).r_eflags, \ &(r).r_cs , &(r).r_ss, &(r).r_ds, &(r).r_es, &(r).r_fs, \ &(r).r_gs #define TRAP_NAMES \ - "privileged instruction", "breakpoint trap", "arithmetic trap", \ + "invalid opcode fault", "breakpoint trap", "arithmetic trap", \ "asynchronous system trap", "protection fault", "trace trap", \ "page fault", "alignment fault", "integer divide fault", \ "non-maskable interrupt", "overflow trap", "bounds check fault", \ diff --git a/sys/arch/i386/stand/libsa/dev_i386.c b/sys/arch/i386/stand/libsa/dev_i386.c index 59934b65021..50abdad5277 100644 --- a/sys/arch/i386/stand/libsa/dev_i386.c +++ b/sys/arch/i386/stand/libsa/dev_i386.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dev_i386.c,v 1.19 1997/08/22 00:38:35 mickey Exp $ */ +/* $OpenBSD: dev_i386.c,v 1.20 1998/04/18 07:39:49 deraadt Exp $ */ /* * Copyright (c) 1996 Michael Shalayeff @@ -115,34 +115,34 @@ devboot(bootdev, p) *p = '\0'; } +int pch_pos = 0; + void putchar(c) - register int c; + int c; { - static int pos = 0; - switch(c) { case '\177': /* DEL erases */ cnputc('\b'); cnputc(' '); case '\b': cnputc('\b'); - if (pos) - pos--; + if (pch_pos) + pch_pos--; break; case '\t': do cnputc(' '); - while(++pos % 8); + while(++pch_pos % 8); break; case '\n': case '\r': cnputc(c); - pos=0; + pch_pos=0; break; default: cnputc(c); - pos++; + pch_pos++; break; } } @@ -163,15 +163,14 @@ getchar() return(c); } +char ttyname_buf[8]; char * ttyname(fd) int fd; { - static char buf[8]; - - sprintf(buf, "%s%d", cdevs[major(cn_tab->cn_dev)], + sprintf(ttyname_buf, "%s%d", cdevs[major(cn_tab->cn_dev)], minor(cn_tab->cn_dev)); - return (buf); + return (ttyname_buf); } dev_t diff --git a/sys/arch/i386/stand/libsa/diskprobe.c b/sys/arch/i386/stand/libsa/diskprobe.c index 38ef5db6c4c..0aac07f7be4 100644 --- a/sys/arch/i386/stand/libsa/diskprobe.c +++ b/sys/arch/i386/stand/libsa/diskprobe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: diskprobe.c,v 1.14 1998/02/24 22:06:50 weingart Exp $ */ +/* $OpenBSD: diskprobe.c,v 1.15 1998/04/18 07:39:50 deraadt Exp $ */ /* * Copyright (c) 1997 Tobias Weingartner @@ -52,11 +52,12 @@ static int disksum __P((int)); /* List of disk devices we found/probed */ -static struct disklist_lh disklist; +struct disklist_lh disklist; /* Pointer to boot device */ struct diskinfo *bootdev_dip; +extern int debug; /* Probe for all BIOS floppies */ static void @@ -72,7 +73,8 @@ floppyprobe() if(bios_getdiskinfo(i, &dip->bios_info)) { #ifdef BIOS_DEBUG - printf(" <!fd%u>", i); + if (debug) + printf(" <!fd%u>", i); #endif free(dip, 0); break; @@ -108,7 +110,8 @@ hardprobe() if(bios_getdiskinfo(i, &dip->bios_info)) { #ifdef BIOS_DEBUG - printf(" <!hd%u>", i&0x7f); + if (debug) + printf(" <!hd%u>", i&0x7f); #endif free(dip, 0); break; @@ -155,6 +158,7 @@ hardprobe() /* Probe for all BIOS supported disks */ +u_int32_t bios_cksumlen; void diskprobe() { @@ -163,7 +167,6 @@ diskprobe() /* These get passed to kernel */ bios_diskinfo_t *bios_diskinfo; - static u_int32_t bios_cksumlen; /* Init stuff */ printf("disk:"); @@ -172,7 +175,8 @@ diskprobe() /* Do probes */ floppyprobe(); #ifdef BIOS_DEBUG - printf(";"); + if (debug) + printf(";"); #endif hardprobe(); @@ -256,7 +260,7 @@ bios_dklookup(dev) * Use the adler32() function from libz, * as it is quick, small, and available. */ -static int +int disksum(blk) int blk; { diff --git a/sys/arch/i386/stand/libsa/gidt.S b/sys/arch/i386/stand/libsa/gidt.S index a3413390ce3..cf119f997cc 100644 --- a/sys/arch/i386/stand/libsa/gidt.S +++ b/sys/arch/i386/stand/libsa/gidt.S @@ -1,4 +1,4 @@ -/* $OpenBSD: gidt.S,v 1.20 1998/02/25 12:28:24 mickey Exp $ */ +/* $OpenBSD: gidt.S,v 1.21 1998/04/18 07:39:51 deraadt Exp $ */ /* * Copyright (c) 1997 Michael Shalayeff @@ -53,11 +53,8 @@ #ifdef GIDT_DEBUG #define gidt_debug0 ; \ movl $0xb8000, %eax ; \ - movl $0x47314730, (%eax) ; \ - movw $S16DATA, %ax + movl $0x47314730, (%eax) #define gidt_debug1 ; \ - movl %ax, %ds ; \ - movl %ax, %es ; \ data32 ; \ movl $(0xb8000 - LINKADDR), %eax ; \ data32 ; \ @@ -89,11 +86,14 @@ #define prot2real \ gidt_debug0; \ \ + movl $S16DATA, %ax; \ /* ljmp $S16TEXT, $1f */; \ .byte 0xea; /* Change to 16bit mode */ \ .long 1f - LINKADDR; \ .word S16TEXT; \ 1: \ + movl %ax, %ds; \ + movl %ax, %es; \ gidt_debug1; \ \ movl %cr0, %eax; /* disable pmmm */ \ @@ -106,6 +106,7 @@ .word 1f; \ .word (LINKADDR >> 4); \ 1: \ + data32; \ xorl %eax, %eax; /* setup: %ds, %es, %ss */ \ movl %ax, %ds; \ movl %ax, %es; \ @@ -147,16 +148,16 @@ .globl _C_LABEL(BIOS_regs) .text - .globl pmm_init - .globl __rtt + .globl _ASM_LABEL(pmm_init) + .globl _C_LABEL(_rtt) -__rtt: +ENTRY(_rtt) #ifdef GIDT_DEBUG movl $0xb8000, %ebx movl $0x4f514f51, (%ebx) #endif movw $0x1234, %ax - movw %ax, 0x472 # warm boot + movw %ax, 0x472 /* warm boot */ /* Try to use the KBD to reboot system */ movb $0xfe, %al @@ -183,20 +184,21 @@ __rtt: int $0x8 /* Again... */ - movl $0, %esp # segment violation + movl $0, %esp /* segment violation */ ret + .align 3, 0x90 pmm_init: /* reload new gdt */ lgdt Gdtr - ljmp $8, $1f + ljmp $S32TEXT, $1f 1: - movw $S32DATA, %ax - movl %ax, %ds - movl %ax, %ss - movl %ax, %es - movl %ax, %fs - movl %ax, %gs + movl $S32DATA, %eax + movl %eax, %ds + movl %eax, %ss + movl %eax, %es + movl %eax, %fs + movl %eax, %gs /* load idtr for interrupts */ lidt Idtr @@ -233,12 +235,15 @@ Idtr: .word . - idt - 1 .long idt .word 0 + .align 3 Idtr_real: .word 1023 .long 0 .word 0 + .align 3 Idtr_reset: .long 0, 0 + .align 3 gdt: /* 0x00 : null */ .space 8 @@ -338,7 +343,8 @@ IEMUENT(44); IEMUENT(45); IEMUENT(46); IEMUENT(47) * Return: %eax, %edx, %ecx, %eflags (as returned from BIOS) * */ -.globl EMUh + .globl EMUh + .align 3, 0x90 EMUh: /* save %eax */ movl %eax, 3f diff --git a/sys/arch/i386/stand/libsa/machdep.c b/sys/arch/i386/stand/libsa/machdep.c index 5f4b23ac6a1..50f37b13a12 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.24 1998/03/11 02:12:03 deraadt Exp $ */ +/* $OpenBSD: machdep.c,v 1.25 1998/04/18 07:39:53 deraadt Exp $ */ /* * Copyright (c) 1997 Michael Shalayeff @@ -45,6 +45,8 @@ struct BIOS_regs BIOS_regs; #define CKPT(c) /* c */ #endif +extern int debug; + void machdep() { diff --git a/sys/arch/i386/stand/libsa/memprobe.c b/sys/arch/i386/stand/libsa/memprobe.c index 1deadbe9616..3927bd83f96 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.26 1998/02/24 22:06:56 weingart Exp $ */ +/* $OpenBSD: memprobe.c,v 1.27 1998/04/18 07:39:54 deraadt Exp $ */ /* * Copyright (c) 1997 Tobias Weingartner, Michael Shalayeff @@ -198,41 +198,41 @@ bios_int12(mp) * * XXX - Does not detect aliased memory. */ +const u_int addrprobe_pat[] = { + 0x00000000, 0xFFFFFFFF, + 0x01010101, 0x10101010, + 0x55555555, 0xCCCCCCCC +}; static int addrprobe(kloc) u_int kloc; { __volatile u_int *loc; - static const u_int pat[] = { - 0x00000000, 0xFFFFFFFF, - 0x01010101, 0x10101010, - 0x55555555, 0xCCCCCCCC - }; register u_int i, ret = 0; - u_int save[NENTS(pat)]; + u_int save[NENTS(addrprobe_pat)]; /* Get location */ loc = (int *)(kloc * 1024); save[0] = *loc; /* Probe address */ - for(i = 0; i < NENTS(pat); i++){ - *loc = pat[i]; - if(*loc != pat[i]) + for(i = 0; i < NENTS(addrprobe_pat); i++){ + *loc = addrprobe_pat[i]; + if(*loc != addrprobe_pat[i]) ret++; } *loc = save[0]; if (!ret) { /* Write address */ - for(i = 0; i < NENTS(pat); i++) { + for(i = 0; i < NENTS(addrprobe_pat); i++) { save[i] = loc[i]; - loc[i] = pat[i]; + loc[i] = addrprobe_pat[i]; } /* Read address */ - for(i = 0; i < NENTS(pat); i++) { - if(loc[i] != pat[i]) + for(i = 0; i < NENTS(addrprobe_pat); i++) { + if(loc[i] != addrprobe_pat[i]) ret++; loc[i] = save[i]; } @@ -274,16 +274,16 @@ badprobe(mp) return ++mp; } +bios_memmap_t bios_memmap[32]; /* This is easier */ void memprobe() { - static bios_memmap_t bm[32]; /* This is easier */ - bios_memmap_t *pm = bm, *im; + bios_memmap_t *pm = bios_memmap, *im; #ifdef DEBUG printf("Probing memory: "); #endif - if(!(pm = bios_E820(bm))) { - im = bios_int12(bm); + if(!(pm = bios_E820(bios_memmap))) { + im = bios_int12(bios_memmap); pm = bios_E801(im); if (!pm) pm = bios_8800(im); @@ -299,13 +299,14 @@ memprobe() #endif pm->type = BIOS_MAP_END; /* Register in global var */ - addbootarg(BOOTARG_MEMMAP, (pm - bm + 1) * sizeof(*bm), bm); - memory_map = bm; /* XXX for 'machine mem' command only */ + addbootarg(BOOTARG_MEMMAP, + (pm - bios_memmap + 1) * sizeof(*bios_memmap), bios_memmap); + memory_map = bios_memmap; /* XXX for 'machine mem' command only */ printf("memory:"); /* XXX - Compatibility, remove later */ extmem = cnvmem = 0; - for(im = bm; im->type != BIOS_MAP_END; im++) { + for(im = bios_memmap; im->type != BIOS_MAP_END; im++) { /* Count only "good" memory chunks 4K an up in size */ if ((im->type == BIOS_MAP_FREE) && (im->size >= 4)) { printf(" %luK", (u_long)im->size); diff --git a/sys/arch/i386/stand/libsa/smpprobe.c b/sys/arch/i386/stand/libsa/smpprobe.c index 1659acd6651..bad1ba2aa3e 100644 --- a/sys/arch/i386/stand/libsa/smpprobe.c +++ b/sys/arch/i386/stand/libsa/smpprobe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smpprobe.c,v 1.1 1998/02/24 22:07:46 weingart Exp $ */ +/* $OpenBSD: smpprobe.c,v 1.2 1998/04/18 07:39:55 deraadt Exp $ */ /* * Copyright (c) 1997 Tobias Weingartner @@ -36,9 +36,11 @@ #include <machine/biosvar.h> #include "libsa.h" +extern int debug; + extern u_int cnvmem, extmem; -#define MP_FLOAT_SIG 0x5F504D5F /* _MP_ */ -#define MP_CONF_SIG 0x504D4350 /* PCMP */ +#define MP_FLOAT_SIG 0x5F504D5F /* _MP_ */ +#define MP_CONF_SIG 0x504D4350 /* PCMP */ typedef struct _mp_float { u_int32_t signature; @@ -55,18 +57,16 @@ mp_checksum(ptr, len) u_int8_t *ptr; int len; { - int i, sum = 0; + register int i, sum = 0; #ifdef DEBUG printf("Checksum %p for %d\n", ptr, len); #endif - for(i = 0; i < len; i++){ + for (i = 0; i < len; i++) sum += *(ptr + i); - } - sum &= 0xFF; - return(!sum); + return (!(sum & 0xff)); } @@ -79,7 +79,8 @@ mp_probefloat(ptr, len) int i; #ifdef DEBUG - printf("Checking %p for %d\n", ptr, len); + if (debug) + printf("Checking %p for %d\n", ptr, len); #endif for(i = 0; i < 1024; i++){ mp_float_t *tmp = (mp_float_t*)(ptr + i); @@ -91,62 +92,51 @@ mp_probefloat(ptr, len) } if((tmp->signature == MP_FLOAT_SIG) && mp_checksum(tmp, tmp->length*16)){ - #ifdef DEBUG - printf("Found valid MP signature at: %p\n", ptr); + if (debug) + printf("Found valid MP signature at: %p\n", ptr); #endif mpp = tmp; break; } } - return(mpp); + return (mpp); } void smpprobe() { - u_int32_t *ptr; - u_int16_t *seg; mp_float_t *mp = NULL; /* Check EBDA */ - seg = (void *)((0x40 * 16) + 0x0E); /* 40:0E */ - ptr = (void *)((*seg) * 16); /* Segment => Linear */ - mp = mp_probefloat(ptr, 1024); - - /* Check BIOS ROM 0xE0000 - 0xFFFFF */ - ptr = (void *)(0xE0000); - mp = mp_probefloat(ptr, 0x1FFFF); - if(mp) goto end; - - /* Check last 1K of base RAM */ - ptr = (void *)(cnvmem * 1024); - mp = mp_probefloat(ptr, 1024); - if(mp) goto end; - - /* Check last 1K of extended RAM */ - ptr = (void *)(extmem * 1024 - 1024); /* XXX */ - mp = mp_probefloat(ptr, 1024); - if(mp) goto end; - - /* No valid MP signature found */ + if (!(mp = mp_probefloat((void *)((*((u_int32_t*)0x4e)) * 16), 1024)) && + /* Check BIOS ROM 0xE0000 - 0xFFFFF */ + !(mp = mp_probefloat((void *)(0xE0000), 0x1FFFF)) && + /* Check last 1K of base RAM */ + !(mp = mp_probefloat((void *)(cnvmem * 1024), 1024)) && + /* Check last 1K of extended RAM XXX */ + !(mp = mp_probefloat((void *)(extmem * 1024 - 1024), 1024))) { + /* No valid MP signature found */ #if DEBUG - printf("No valid MP signature found.\n"); + if (debug) + printf("No valid MP signature found.\n"); #endif - return; + return; + } /* Valid MP signature found */ -end: printf(" smp"); #if DEBUG - printf("Floating Structure:\n"); - printf("\tSignature: %x\n", mp->signature); - printf("\tConfig at: %x\n", mp->conf_addr); - printf("\tLength: %d\n", mp->length); - printf("\tRev: 1.%d\n", mp->spec_rev); - printf("\tFeature: %x %x %x %x %x\n", + if (debug) + printf("Floating Structure:\n" + "\tSignature: %x\n" + "\tConfig at: %x\n" + "\tLength: %d\n" + "\tRev: 1.%d\n" + "\tFeature: %x %x %x %x %x\n", + mp->signature, mp->conf_addr, mp->length, mp->spec_rev, mp->feature[0], mp->feature[1], mp->feature[2], mp->feature[3], mp->feature[4]); #endif diff --git a/sys/arch/i386/stand/libsa/time.c b/sys/arch/i386/stand/libsa/time.c index b5d1c49b020..cedc53249ea 100644 --- a/sys/arch/i386/stand/libsa/time.c +++ b/sys/arch/i386/stand/libsa/time.c @@ -1,4 +1,4 @@ -/* $OpenBSD: time.c,v 1.10 1997/10/12 21:04:23 mickey Exp $ */ +/* $OpenBSD: time.c,v 1.11 1998/04/18 07:39:57 deraadt Exp $ */ /* * Copyright (c) 1997 Michael Shalayeff @@ -55,16 +55,16 @@ bcdtoint(c) /* * Quick compute of time in seconds since the Epoch */ +const u_short monthcount[] = { + 0, 0, 31, 59, 90, 120, 151, 181, + 212, 243, 273, 304, 334, 365 +}; static __inline time_t compute(year, month, day, hour, min, sec) int year; u_int8_t month, day, hour, min, sec; { /* Number of days per month */ - static const u_short monthcount[] = { - 0, 0, 31, 59, 90, 120, 151, 181, - 212, 243, 273, 304, 334, 365 - }; register time_t tt; /* Compute days */ |