diff options
-rw-r--r-- | sys/arch/i386/stand/Makefile.inc | 4 | ||||
-rw-r--r-- | sys/arch/i386/stand/boot/boot.c | 4 | ||||
-rw-r--r-- | sys/arch/i386/stand/boot/srt0.S | 15 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/debug.h | 5 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/debug_i386.S | 152 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/debug_md.h | 6 | ||||
-rw-r--r-- | sys/stand/boot/boot.c | 4 |
7 files changed, 152 insertions, 38 deletions
diff --git a/sys/arch/i386/stand/Makefile.inc b/sys/arch/i386/stand/Makefile.inc index ef05b0586aa..07fe7bc875a 100644 --- a/sys/arch/i386/stand/Makefile.inc +++ b/sys/arch/i386/stand/Makefile.inc @@ -1,10 +1,10 @@ -# $OpenBSD: Makefile.inc,v 1.3 1997/03/31 23:06:03 mickey Exp $ +# $OpenBSD: Makefile.inc,v 1.4 1997/04/04 04:47:44 mickey Exp $ #CPPFLAGS+=-nostdinc -I/sys CPPFLAGS+=-Wall -Werror -I. -Imachine SACFLAGS+=-Wa,-R -fno-common -fpack-struct -fno-builtin -fomit-frame-pointer CPPFLAGS+=-D_STANDALONE -CPPFLAGS+=-DNO_IDTR +# CPPFLAGS+=-DNO_IDTR CPPFLAGS+=-DSAVE_MEMORY CPPFLAGS+=-DDEBUG # CPPFLAGS+=-DBIOS_DEBUG diff --git a/sys/arch/i386/stand/boot/boot.c b/sys/arch/i386/stand/boot/boot.c index 91d43db5f87..337c57498f2 100644 --- a/sys/arch/i386/stand/boot/boot.c +++ b/sys/arch/i386/stand/boot/boot.c @@ -1,4 +1,4 @@ -/* $OpenBSD: boot.c,v 1.3 1997/03/31 23:06:20 mickey Exp $ */ +/* $OpenBSD: boot.c,v 1.4 1997/04/04 04:47:45 mickey Exp $ */ /* * Copyright (c) 1997 Michael Shalayeff @@ -36,6 +36,7 @@ #include <sys/reboot.h> #include <sys/stat.h> #include <libsa.h> +#include <debug.h> #include "cmd.h" char *kernels[] = { "bsd", "bsd.gz", @@ -68,6 +69,7 @@ boot(bootdev) *(u_int16_t*)0xb8148 = 0x4f31; #endif cons_probe(); + debug_init(); printf("\n>> OpenBSD BOOT: %u/%u k [%s]\n", cnvmem, extmem, version); diff --git a/sys/arch/i386/stand/boot/srt0.S b/sys/arch/i386/stand/boot/srt0.S index 14fff7d82e5..a947e076954 100644 --- a/sys/arch/i386/stand/boot/srt0.S +++ b/sys/arch/i386/stand/boot/srt0.S @@ -1,4 +1,4 @@ -/* $OpenBSD: srt0.S,v 1.2 1997/03/31 23:06:23 mickey Exp $ */ +/* $OpenBSD: srt0.S,v 1.3 1997/04/04 04:47:46 mickey Exp $ */ /* $NetBSD: srt0.c,v 1.3 1994/10/27 04:21:59 cgd Exp $ */ /*- @@ -61,7 +61,7 @@ start_boot: movl $0xb80a0, %ebx movl $0x07420742, (%ebx) #endif - + /* reload new gdt */ lgdt _Gdtr ljmp $8, $1f 1: @@ -71,6 +71,10 @@ start_boot: movl %ax, %es movl %ax, %fs movl %ax, %gs +#ifndef NO_IDTR + /* load idtr for debugger */ + lidt _Idtr_prot +#endif #ifdef DEBUG movl $0xb80a4, %ebx @@ -110,8 +114,9 @@ __rtt: .data .align 3 -gdt: /* 0x00 : null */ - .long 0, 0 +gdt: +null: /* 0x00 : null */ + .space 8 /* 0x08 : flat code */ .word 0xFFFF # lolimit .word 0 # lobase @@ -133,7 +138,7 @@ gdt: /* 0x00 : null */ .byte SDT_MEMERAC | 0 | 0x80 # RWXAC, dpl = 0, present .byte 0xf | 0 | 0 | 0 # hilimit, xx, 16bit, byte granularity .byte 0 # hibase -_Gdtr: .word . - gdt +_Gdtr: .word . - gdt - 1 .long gdt .word 0 diff --git a/sys/arch/i386/stand/libsa/debug.h b/sys/arch/i386/stand/libsa/debug.h index d14e17b4da3..c3bfc5ec808 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.1 1997/04/01 04:52:45 mickey Exp $ */ +/* $OpenBSD: debug.h,v 1.2 1997/04/04 04:47:46 mickey Exp $ */ /* * Copyright (c) 1997 Michael Shalayeff @@ -37,3 +37,6 @@ extern const char *reg_names[]; extern const size_t nregs; + +int debug_init __P((void)); + diff --git a/sys/arch/i386/stand/libsa/debug_i386.S b/sys/arch/i386/stand/libsa/debug_i386.S index a111e24fa84..fdd4b1b38f2 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.1 1997/04/01 04:52:46 mickey Exp $ */ +/* $OpenBSD: debug_i386.S,v 1.2 1997/04/04 04:47:47 mickey Exp $ */ /* * Copyright (c) 1997 Michael Shalayeff @@ -36,60 +36,163 @@ #include <machine/psl.h> #define _LOCORE #include <machine/segments.h> +#include <machine/trap.h> #include <debug_md.h> #undef _LOCORE .data #ifndef NO_IDTR - .align 3 + .globl _Idtr_real + .align 3 _Idtr_real: - .word 1024 + .word 1023 .long 0 - .align 3 .globl _Idtr_prot -idt: - .long 0, 0 + + .align 3 +idt: /* + * We beleive that all the boot code fits into + * 64k, so no need for high 16 bit of procedure address (; + * + */ +#define IPROC(n) X/**/n +#define IDTENTRY(proc) \ + .word IPROC(proc) /* lo offset handler */ ; \ + .word 0x8 /* handler %cs */ ; \ + .byte 0 /* reserved */ ; \ + .byte 0x80 | SDT_SYS386TGT /* present, dpl=0, 32bit trap gate */ ; \ + .word 0 /* hi offset handler */ + + IDTENTRY(de) /* #DE divide by zero */ + IDTENTRY(db) /* #DB debug */ + IDTENTRY(nmi) /* NMI */ + IDTENTRY(bp) /* #BP breakpoint */ + IDTENTRY(of) /* #OF overflow */ + IDTENTRY(br) /* #BR BOUND range exceeded */ + IDTENTRY(ud) /* #UD invalid opcode */ + IDTENTRY(nm) /* #NM device not available */ + IDTENTRY(df) /* #DF double fault */ + IDTENTRY(fo) /* #FO coprocessor segment overrun */ + IDTENTRY(ts) /* #TS innvalid TSS */ + IDTENTRY(np) /* #NP segmant not present */ + IDTENTRY(ss) /* #SS stack fault */ + IDTENTRY(gp) /* #GP general protection */ + IDTENTRY(pf) /* #PF page fault */ + IDTENTRY(xx) /* Intel reserved */ + IDTENTRY(mf) /* #MF floating point error */ + IDTENTRY(ac) /* #AC alignment check */ + IDTENTRY(mc) /* #MC machine check */ + /* Intel reserved (19-31) */ + IDTENTRY(xx); IDTENTRY(xx); IDTENTRY(xx); IDTENTRY(xx) + IDTENTRY(xx); IDTENTRY(xx); IDTENTRY(xx); IDTENTRY(xx) + IDTENTRY(xx); IDTENTRY(xx); IDTENTRY(xx); IDTENTRY(xx) + IDTENTRY(xx) + /* Maskable interrupts(32-255) */ _Idtr_prot: .word . - idt .long idt + + .text + +#define IENTRY(name,type) \ +IPROC(name): \ + pushl $type ; \ + jmp alltraps +#define IENTRY_ERR(name,err,type) \ +IPROC(name): \ + pushl $err ; \ + pushl $type ; \ + jmp alltraps + +IPROC(xx): + pushl $1 + pushl $256 + jmp alltraps + +IENTRY_ERR(de,0,T_DIVIDE) +IENTRY_ERR(db,0,T_TRCTRAP) +IENTRY_ERR(nmi,0,T_NMI) +IENTRY_ERR(bp,0,T_BPTFLT) +IENTRY_ERR(of,0,T_OFLOW) +IENTRY_ERR(br,0,T_BOUND) +IENTRY_ERR(ud,0,T_PRIVINFLT) +IENTRY_ERR(nm,0,T_DNA) +IENTRY(df,T_DOUBLEFLT) +IENTRY_ERR(fo,0,T_FPOPFLT) +IENTRY(ts,T_TSSFLT) +IENTRY(np,T_SEGNPFLT) +IENTRY(ss,T_STKFLT) +IENTRY(gp,T_PROTFLT) +IENTRY(pf,T_PAGEFLT) +IENTRY_ERR(mf,0,T_ARITHTRAP) +IENTRY(ac,T_ALIGNFLT) +IENTRY(mc,T_MACHK) + +alltraps: +#ifdef DEBUG + movl $0xb8280, %edi + movl $0x47304731, (%edi) +#endif + /* lcall is busted */ + pushl $0x8 + pushl $1f + ljmp $0x8, $_check_regs +1: + addl $0x8, %esp +#ifdef DEBUG + movl $0xb8290, %edi + movl $0x47384739, (%edi) +#endif + iret + #endif .text ENTRY(check_regs) +#ifdef DEBUG + movl $0xb8284, %edi + movl $0x47324733, (%edi) +#endif pushal # 8 ones pushl %ds pushl %es pushl %fs pushl %gs - pushfl movl $0x10, %eax movl %ax, %ds movl $_reg, %edi cld - movl 0xc*4(%esp), %eax; stosl # %eax - movl 0xb*4(%esp), %eax; stosl # %ecx - movl 0xa*4(%esp), %eax; stosl # %edx - movl 0x9*4(%esp), %eax; stosl # %ebx - movl 0x8*4(%esp), %eax; stosl # %esp - movl 0x7*4(%esp), %eax; stosl # %ebp - movl 0x6*4(%esp), %eax; stosl # %esi - movl 0x5*4(%esp), %eax; stosl # %edi - movl 0xd*4(%esp), %eax; stosl # %eip - movl 0x0*4(%esp), %eax; stosl # %eflags - movl 0xe*4(%esp), %eax; stosl # %cs - movl %ss, %eax; stosl # %ss - movl 0x4*4(%esp), %eax; stosl # %ds - movl 0x3*4(%esp), %eax; stosl # %es - movl 0x2*4(%esp), %eax; stosl # %fs - movl 0x1*4(%esp), %eax; stosl # %gs + movl 0x0b*4(%esp), %eax; stosl # %eax + movl 0x0a*4(%esp), %eax; stosl # %ecx + movl 0x09*4(%esp), %eax; stosl # %edx + movl 0x08*4(%esp), %eax; stosl # %ebx + movl 0x07*4(%esp), %eax; stosl # %esp + movl 0x06*4(%esp), %eax; stosl # %ebp + movl 0x05*4(%esp), %eax; stosl # %esi + movl 0x04*4(%esp), %eax; stosl # %edi + movl 0x10*4(%esp), %eax; stosl # %eip + movl 0x12*4(%esp), %eax; stosl # %eflags + movl 0x11*4(%esp), %eax; stosl # %cs + movl %ss, %eax; stosl # %ss + movl 0x03*4(%esp), %eax; stosl # %ds + movl 0x02*4(%esp), %eax; stosl # %es + movl 0x01*4(%esp), %eax; stosl # %fs + movl 0x00*4(%esp), %eax; stosl # %gs +#ifdef DEBUG + movl $0xb8288, %edi + movl $0x47344735, (%edi) +#endif call _C_LABEL(dump_regs) - popfl +#ifdef DEBUG + movl $0xb828c, %edi + movl $0x47364737, (%edi) +#endif popl %gs popl %fs popl %es @@ -98,4 +201,3 @@ ENTRY(check_regs) lret - diff --git a/sys/arch/i386/stand/libsa/debug_md.h b/sys/arch/i386/stand/libsa/debug_md.h index 3d2cc9283b7..014839f1978 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.1 1997/04/01 04:52:47 mickey Exp $ */ +/* $OpenBSD: debug_md.h,v 1.2 1997/04/04 04:47:47 mickey Exp $ */ /* * Copyright (c) 1997 Michael Shalayeff @@ -43,9 +43,9 @@ #ifdef _LOCORE .globl _reg -#define DUMP_REGS pushl %cs; call _check_regs +#define DUMP_REGS int $2 #else -#define DUMP_REGS __asm("pushl %cs; call _check_regs") +#define DUMP_REGS __asm("int $2") extern struct reg reg; #endif diff --git a/sys/stand/boot/boot.c b/sys/stand/boot/boot.c index 91d43db5f87..337c57498f2 100644 --- a/sys/stand/boot/boot.c +++ b/sys/stand/boot/boot.c @@ -1,4 +1,4 @@ -/* $OpenBSD: boot.c,v 1.3 1997/03/31 23:06:20 mickey Exp $ */ +/* $OpenBSD: boot.c,v 1.4 1997/04/04 04:47:45 mickey Exp $ */ /* * Copyright (c) 1997 Michael Shalayeff @@ -36,6 +36,7 @@ #include <sys/reboot.h> #include <sys/stat.h> #include <libsa.h> +#include <debug.h> #include "cmd.h" char *kernels[] = { "bsd", "bsd.gz", @@ -68,6 +69,7 @@ boot(bootdev) *(u_int16_t*)0xb8148 = 0x4f31; #endif cons_probe(); + debug_init(); printf("\n>> OpenBSD BOOT: %u/%u k [%s]\n", cnvmem, extmem, version); |