summaryrefslogtreecommitdiff
path: root/sys/arch/i386/stand/libsa
diff options
context:
space:
mode:
authorMichael Shalayeff <mickey@cvs.openbsd.org>1997-04-04 04:47:48 +0000
committerMichael Shalayeff <mickey@cvs.openbsd.org>1997-04-04 04:47:48 +0000
commitea0c1a875ff2a5356db9fe00060f2ddd2f1a964c (patch)
tree84a5b17b7ed1b6041dc4f1c06a755a02b0213f4e /sys/arch/i386/stand/libsa
parent4bb1ee5415bfd5219eaf941d40b3eacc24630896 (diff)
dump regs w/ NMI (int 2)
more debugging is on the way
Diffstat (limited to 'sys/arch/i386/stand/libsa')
-rw-r--r--sys/arch/i386/stand/libsa/debug.h5
-rw-r--r--sys/arch/i386/stand/libsa/debug_i386.S152
-rw-r--r--sys/arch/i386/stand/libsa/debug_md.h6
3 files changed, 134 insertions, 29 deletions
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