diff options
author | Michael Shalayeff <mickey@cvs.openbsd.org> | 1997-04-05 18:56:29 +0000 |
---|---|---|
committer | Michael Shalayeff <mickey@cvs.openbsd.org> | 1997-04-05 18:56:29 +0000 |
commit | c3434a52deeea17992db2aeb2f67aac615858469 (patch) | |
tree | eca63b219429fb380e4b8ffb232a02c8d02d11a6 /sys | |
parent | eb163fa3768eab110c936707c961febde79f570f (diff) |
put gdt & idt in the separate file.
print trapno in dump_regs.
no more NO_IDTR.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/i386/stand/Makefile.inc | 3 | ||||
-rw-r--r-- | sys/arch/i386/stand/boot/srt0.S | 40 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/Makefile | 5 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/debug.c | 6 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/debug_i386.S | 162 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/gidt.S | 166 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/real_prot.S | 9 |
7 files changed, 212 insertions, 179 deletions
diff --git a/sys/arch/i386/stand/Makefile.inc b/sys/arch/i386/stand/Makefile.inc index 07fe7bc875a..c9c7d202f1b 100644 --- a/sys/arch/i386/stand/Makefile.inc +++ b/sys/arch/i386/stand/Makefile.inc @@ -1,10 +1,9 @@ -# $OpenBSD: Makefile.inc,v 1.4 1997/04/04 04:47:44 mickey Exp $ +# $OpenBSD: Makefile.inc,v 1.5 1997/04/05 18:56:14 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+=-DSAVE_MEMORY CPPFLAGS+=-DDEBUG # CPPFLAGS+=-DBIOS_DEBUG diff --git a/sys/arch/i386/stand/boot/srt0.S b/sys/arch/i386/stand/boot/srt0.S index a947e076954..1ffdc191a87 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.3 1997/04/04 04:47:46 mickey Exp $ */ +/* $OpenBSD: srt0.S,v 1.4 1997/04/05 18:56:19 mickey Exp $ */ /* $NetBSD: srt0.c,v 1.3 1994/10/27 04:21:59 cgd Exp $ */ /*- @@ -49,9 +49,7 @@ .globl _boot .globl __rtt .globl _Gdtr -#ifndef NO_IDTR .globl _Idtr_prot -#endif .globl _codeseg .text @@ -71,10 +69,8 @@ start_boot: movl %ax, %es movl %ax, %fs movl %ax, %gs -#ifndef NO_IDTR - /* load idtr for debugger */ + /* load idtr for interrupts */ lidt _Idtr_prot -#endif #ifdef DEBUG movl $0xb80a4, %ebx @@ -111,35 +107,3 @@ __rtt: movl $0, %esp # segment violation ret - .data - - .align 3 -gdt: -null: /* 0x00 : null */ - .space 8 - /* 0x08 : flat code */ - .word 0xFFFF # lolimit - .word 0 # lobase - .byte 0 # midbase - .byte SDT_MEMERAC | 0 | 0x80 # RWXAC, dpl = 0, present - .byte 0xf | 0 | 0x40 | 0x80 # hilimit, xx, 32bit, 4k granularity - .byte 0 # hibase - /* 0x10 : flat data */ - .word 0xFFFF # lolimit - .word 0 # lobase - .byte 0 # midbase - .byte SDT_MEMRWA | 0 | 0x80 # RWA, dpl = 0, present - .byte 0xf | 0 | 0x40 | 0x80 # hilimit, xx, 32bit, 4k granularity - .byte 0 # hibase - /* 0x18 : 16 bit code */ - .word 0xFFFF # lolimit - .word 0 # lobase - .byte 0 # midbase - .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 - 1 - .long gdt - .word 0 - -_codeseg: .long 0 diff --git a/sys/arch/i386/stand/libsa/Makefile b/sys/arch/i386/stand/libsa/Makefile index 87ff92e9159..d6cfd1f3151 100644 --- a/sys/arch/i386/stand/libsa/Makefile +++ b/sys/arch/i386/stand/libsa/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.5 1997/04/01 04:52:44 mickey Exp $ +# $OpenBSD: Makefile,v 1.6 1997/04/05 18:56:22 mickey Exp $ LIB= sa @@ -39,7 +39,8 @@ SRCS+= debug.c debug_aout.c debug_i386.S # i386 stuff SRCS+= asm.S bioscom.S biosdev.c biosdisk.S bioskbd.S biostime.S biosmem.S \ - dev_i386.c gateA20.c memprobe.c real_prot.S unixsys.S exec_i386.S + dev_i386.c gateA20.c memprobe.c real_prot.S unixsys.S exec_i386.S \ + gidt.S NOPROFILE=noprofile NOPIC=nopic diff --git a/sys/arch/i386/stand/libsa/debug.c b/sys/arch/i386/stand/libsa/debug.c index 9ecd8468190..d1ec26d31d5 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.1 1997/04/01 04:52:45 mickey Exp $ */ +/* $OpenBSD: debug.c,v 1.2 1997/04/05 18:56:24 mickey Exp $ */ /* * Copyright (c) 1997 Michael Shalayeff @@ -47,10 +47,12 @@ debug_init() } void -dump_regs() +dump_regs(trapno) + int trapno; { int i; + printf("trap: %u\n", trapno); for (i = 0; i < nreg; putchar((++i % 4)?' ':'\n')) printf ("%s=0x%x", reg_names[i], *reg_values[i]); if (i % 4) diff --git a/sys/arch/i386/stand/libsa/debug_i386.S b/sys/arch/i386/stand/libsa/debug_i386.S index fdd4b1b38f2..8c1db5c5b01 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.2 1997/04/04 04:47:47 mickey Exp $ */ +/* $OpenBSD: debug_i386.S,v 1.3 1997/04/05 18:56:25 mickey Exp $ */ /* * Copyright (c) 1997 Michael Shalayeff @@ -41,163 +41,69 @@ #undef _LOCORE .data -#ifndef NO_IDTR - - .globl _Idtr_real - .align 3 -_Idtr_real: - .word 1023 - .long 0 - - .globl _Idtr_prot - - .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) + .globl alltraps alltraps: + pushal + pushl %ds + pushl %es #ifdef DEBUG movl $0xb8280, %edi - movl $0x47304731, (%edi) + movl $0x47314730, (%edi) #endif - /* lcall is busted */ - pushl $0x8 - pushl $1f - ljmp $0x8, $_check_regs + call _check_regs 1: - addl $0x8, %esp #ifdef DEBUG movl $0xb8290, %edi - movl $0x47384739, (%edi) + movl $0x47394738, (%edi) #endif + popl %es + popl %ds + popal + addl $0x8, %esp iret -#endif - .text ENTRY(check_regs) #ifdef DEBUG movl $0xb8284, %edi - movl $0x47324733, (%edi) + movl $0x47334732, (%edi) #endif - pushal # 8 ones - pushl %ds - pushl %es - pushl %fs - pushl %gs movl $0x10, %eax movl %ax, %ds movl $_reg, %edi cld - 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 0x0a(%esp,4), %eax; stosl # %eax + movl 0x09(%esp,4), %eax; stosl # %ecx + movl 0x08(%esp,4), %eax; stosl # %edx + movl 0x07(%esp,4), %eax; stosl # %ebx + movl 0x06(%esp,4), %eax; stosl # %esp + movl 0x05(%esp,4), %eax; stosl # %ebp + movl 0x04(%esp,4), %eax; stosl # %esi + movl 0x03(%esp,4), %eax; stosl # %edi + movl 0x0d(%esp,4), %eax; stosl # %eip + movl 0x0f(%esp,4), %eax; stosl # %eflags + movl 0x0e(%esp,4), %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 + movl 0x02(%esp,4), %eax; stosl # %ds + movl 0x01(%esp,4), %eax; stosl # %es + movl %fs, %eax; stosl # %fs + movl %gs, %eax; stosl # %gs #ifdef DEBUG movl $0xb8288, %edi - movl $0x47344735, (%edi) + movl $0x47354734, (%edi) #endif + movl 0x0b(%esp,4), %eax # trapno + pushl %eax call _C_LABEL(dump_regs) + popl %eax #ifdef DEBUG movl $0xb828c, %edi - movl $0x47364737, (%edi) + movl $0x47374736, (%edi) #endif - popl %gs - popl %fs - popl %es - popl %ds - popal - lret + ret diff --git a/sys/arch/i386/stand/libsa/gidt.S b/sys/arch/i386/stand/libsa/gidt.S new file mode 100644 index 00000000000..f6fc305f224 --- /dev/null +++ b/sys/arch/i386/stand/libsa/gidt.S @@ -0,0 +1,166 @@ +/* $OpenBSD: gidt.S,v 1.1 1997/04/05 18:56:27 mickey 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. + * + */ +#include <machine/asm.h> +#include <machine/psl.h> +#define _LOCORE +#include <machine/segments.h> +#include <machine/trap.h> +#include <debug_md.h> +#undef _LOCORE + + + .data + .globl _Gdtr + .globl _codeseg + + .align 3 +gdt: + /* 0x00 : null */ + .space 8 + /* 0x08 : flat code */ + .word 0xFFFF # lolimit + .word 0 # lobase + .byte 0 # midbase + .byte SDT_MEMERA | 0 | 0x80 # RWXA, dpl = 0, present + .byte 0xf | 0 | 0x40 | 0x80 # hilimit, xx, 32bit, 4k granularity + .byte 0 # hibase + /* 0x10 : flat data */ + .word 0xFFFF # lolimit + .word 0 # lobase + .byte 0 # midbase + .byte SDT_MEMRWA | 0 | 0x80 # RWA, dpl = 0, present + .byte 0xf | 0 | 0x40 | 0x80 # hilimit, xx, 32bit, 4k granularity + .byte 0 # hibase + /* 0x18 : 16 bit code */ + .word 0xFFFF # lolimit + .word 0 # lobase + .byte 0 # midbase + .byte SDT_MEMERA | 0 | 0x80 # RWXA, dpl = 0, present + .byte 0xf | 0 | 0 | 0 # hilimit, xx, 16bit, byte granularity + .byte 0 # hibase +_Gdtr: .word . - gdt - 1 + .long gdt + .word 0 + +_codeseg: .long 0 + + .globl _Idtr_real + .align 3 +_Idtr_real: + .word 1023 + .long 0 + + .globl _Idtr_prot + + .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 + .globl alltraps + +#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) + diff --git a/sys/arch/i386/stand/libsa/real_prot.S b/sys/arch/i386/stand/libsa/real_prot.S index ff7b4beaa6d..04737039640 100644 --- a/sys/arch/i386/stand/libsa/real_prot.S +++ b/sys/arch/i386/stand/libsa/real_prot.S @@ -1,4 +1,4 @@ -/* $OpenBSD: real_prot.S,v 1.3 1997/03/31 23:06:31 mickey Exp $ */ +/* $OpenBSD: real_prot.S,v 1.4 1997/04/05 18:56:28 mickey Exp $ */ /* * Mach Operating System @@ -63,10 +63,8 @@ WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .globl _codeseg .globl _Gdtr -#ifndef NO_IDTR .globl _Idtr_prot .globl _Idtr_real -#endif .text @@ -109,10 +107,8 @@ ENTRY(real_to_prot) movl %ax, %fs movl %ax, %gs -#ifndef NO_IDTR /* load idtr so we can debug */ lidt _Idtr_prot -#endif ret /* @@ -149,12 +145,11 @@ ENTRY(prot_to_real) movl %ax, %es movl %ax, %fs movl %ax, %gs -#ifndef NO_IDTR /* load idtr so we can debug */ addr32 data32 lidt _Idtr_real -#endif + sti data32 ret |