From: Ben Gras Date: Mon, 5 Oct 2009 15:47:23 +0000 (+0000) Subject: really revert endpoint_t -> int X-Git-Tag: v3.1.5~28 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/zlib_tech.html?a=commitdiff_plain;h=24e1e8302866a11597741a9b1ecfdb8f0b29a443;p=minix.git really revert endpoint_t -> int debugging info on panic: decode segment selectors and descriptors, now moved to arch-specific part, prototypes added; sanity checking in debug.h made optional with vmassert(). --- diff --git a/include/minix/type.h b/include/minix/type.h index 1dadb528b..b14a98f13 100755 --- a/include/minix/type.h +++ b/include/minix/type.h @@ -13,7 +13,7 @@ typedef unsigned int vir_clicks; /* virtual addr/length in clicks */ typedef unsigned long phys_bytes; /* physical addr/length in bytes */ typedef unsigned int phys_clicks; /* physical addr/length in clicks */ -typedef u32_t endpoint_t; /* process identifier */ +typedef int endpoint_t; /* process identifier */ #if (_MINIX_CHIP == _CHIP_INTEL) typedef long unsigned int vir_bytes; /* virtual addresses/lengths in bytes */ diff --git a/kernel/Makefile b/kernel/Makefile index 407731a77..b4e9f81ab 100755 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -13,7 +13,7 @@ a = arch/$(ARCH) CC = exec cc CPP = $l/cpp LD = $(CC) -.o -CPPFLAGS=-I$i -I$a/include +CPPFLAGS=-I$i -I$a/include -I$a CFLAGS=$(CPROFILE) $(CPPFLAGS) $(EXTRA_OPTS) LDFLAGS=-i diff --git a/kernel/arch/i386/memory.c b/kernel/arch/i386/memory.c index 013e609db..a875a590b 100644 --- a/kernel/arch/i386/memory.c +++ b/kernel/arch/i386/memory.c @@ -37,6 +37,7 @@ PRIVATE int nfreepdes = 0, freepdes[WANT_FREEPDES], inusepde = NOPDE; FORWARD _PROTOTYPE( u32_t phys_get32, (vir_bytes v) ); FORWARD _PROTOTYPE( void vm_enable_paging, (void) ); +FORWARD _PROTOTYPE( void set_cr3, (void) ); /* *** Internal VM Functions *** */ diff --git a/kernel/arch/i386/proto.h b/kernel/arch/i386/proto.h index dccb92256..bb3390b92 100644 --- a/kernel/arch/i386/proto.h +++ b/kernel/arch/i386/proto.h @@ -84,6 +84,7 @@ _PROTOTYPE( void phys_memset, (phys_bytes ph, u32_t c, phys_bytes bytes) ); /* protect.c */ _PROTOTYPE( void prot_init, (void) ); +_PROTOTYPE( void idt_init, (void) ); _PROTOTYPE( void init_codeseg, (struct segdesc_s *segdp, phys_bytes base, vir_bytes size, int privilege) ); _PROTOTYPE( void init_dataseg, (struct segdesc_s *segdp, phys_bytes base, @@ -91,6 +92,9 @@ _PROTOTYPE( void init_dataseg, (struct segdesc_s *segdp, phys_bytes base, _PROTOTYPE( void enable_iop, (struct proc *pp) ); _PROTOTYPE( int prot_set_kern_seg_limit, (vir_bytes limit) ); _PROTOTYPE( void printseg, (char *banner, int iscs, struct proc *pr, u32_t selector) ); +_PROTOTYPE( u32_t, read_cs(void)); +_PROTOTYPE( u32_t, read_ds(void)); +_PROTOTYPE( u32_t, read_ss(void)); /* prototype of an interrupt vector table entry */ struct gate_table_s { diff --git a/kernel/arch/i386/system.c b/kernel/arch/i386/system.c index 9aef4ea2d..bfdd3f6f1 100644 --- a/kernel/arch/i386/system.c +++ b/kernel/arch/i386/system.c @@ -30,6 +30,17 @@ PUBLIC void arch_shutdown(int how) /* Mask all interrupts, including the clock. */ outb( INT_CTLMASK, ~0); + if(minix_panicing) { + /* We're panicing? Then retrieve and decode currently + * loaded segment selectors. + */ + printseg("cs: ", 1, proc_ptr, read_cs()); + printseg("ds: ", 0, proc_ptr, read_ds()); + if(read_ds() != read_ss()) { + printseg("ss: ", 0, NULL, read_ss()); + } + } + if(how != RBT_RESET) { /* return to boot monitor */ diff --git a/kernel/debug.h b/kernel/debug.h index 978a311bc..24ce893ba 100644 --- a/kernel/debug.h +++ b/kernel/debug.h @@ -25,7 +25,7 @@ #define DEBUG_TIME_LOCKS 1 /* Runtime sanity checking. */ -#define DEBUG_VMASSERT 0 +#define DEBUG_VMASSERT 1 #define DEBUG_SCHED_CHECK 0 #define DEBUG_STACK_CHECK 0 #define DEBUG_TRACE 0 @@ -44,38 +44,23 @@ #define ENTERED 0xBA5E1514 #define NOTENTERED 0x1415BEE1 -#define NOREC_ENTER(varname) \ - static int varname = NOTENTERED; \ - int mustunlock = 0; \ - if(!intr_disabled()) { lock; mustunlock = 1; } \ - if(varname != ENTERED && varname != NOTENTERED) { \ - printf("magictest: 0x%lx local: 0x%lx\n", magictest, varname);\ - minix_panic(#varname " bogus value on enter", varname); \ - } \ - if(magictest != MAGICTEST) { \ - printf("magictest: 0x%lx local: 0x%lx\n", magictest, varname);\ - minix_panic(#varname " magictest failed", __LINE__); \ - } \ - if(varname == ENTERED) { \ - minix_panic(#varname " recursive enter", __LINE__); \ - } \ +#define NOREC_ENTER(varname) \ + static int varname = NOTENTERED; \ + int mustunlock = 0; \ + if(!intr_disabled()) { lock; mustunlock = 1; } \ + vmassert(varname == ENTERED || varname == NOTENTERED); \ + vmassert(magictest == MAGICTEST); \ + vmassert(varname != ENTERED); \ varname = ENTERED; -#define NOREC_RETURN(varname, v) do { \ - if(!intr_disabled()) \ - minix_panic(#varname " interrupts on", __LINE__); \ - if(magictest != MAGICTEST) { \ - printf("magictest: 0x%lx local: 0x%lx\n", magictest, varname);\ - minix_panic(#varname " magictest failed", __LINE__); \ - } \ - if(varname != ENTERED && varname != NOTENTERED) { \ - printf("magictest: 0x%lx local: 0x%lx\n", magictest, varname);\ - minix_panic(#varname " bogus value on return", varname); \ - } \ - varname = NOTENTERED; \ - if(mustunlock) { unlock; } \ - return v; \ - } while(0) +#define NOREC_RETURN(varname, v) do { \ + vmassert(intr_disabled()); \ + vmassert(magictest == MAGICTEST); \ + vmassert(varname == ENTERED || varname == NOTENTERED); \ + varname = NOTENTERED; \ + if(mustunlock) { unlock; } \ + return v; \ +} while(0) #if DEBUG_VMASSERT #define vmassert(t) { \ diff --git a/kernel/start.c b/kernel/start.c index a1a2b5cb8..3580eea7d 100755 --- a/kernel/start.c +++ b/kernel/start.c @@ -6,6 +6,7 @@ #include #include #include +#include FORWARD _PROTOTYPE( char *get_value, (_CONST char *params, _CONST char *key)); /*===========================================================================* diff --git a/kernel/utility.c b/kernel/utility.c index 67a17f338..fa31cf3fe 100755 --- a/kernel/utility.c +++ b/kernel/utility.c @@ -48,12 +48,6 @@ if (minix_panicing++) { kprintf("\n"); } - printseg("cs: ", 1, NULL, read_cs()); - printseg("ds: ", 0, NULL, read_ds()); - if(read_ds() != read_ss()) { - printseg("ss: ", 0, NULL, read_ss()); - } - kprintf("kernel: "); util_stacktrace();