Use the exec header left by the boot program to validate the
symbol table size, and then preserve symbols for ddb.
This commit is contained in:
parent
3fda1f293a
commit
788562b9ed
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: locore.s,v 1.29 1995/05/30 15:32:37 gwr Exp $ */
|
||||
/* $NetBSD: locore.s,v 1.30 1995/06/02 16:46:18 gwr Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995 Gordon W. Ross
|
||||
@ -48,16 +48,6 @@
|
||||
|
||||
| Remember this is a fun project. (Thanks, Adam. I try! 8^)
|
||||
|
||||
| Define some addresses, mostly so DDB can print useful info.
|
||||
.set _kernbase,KERNBASE
|
||||
.globl _kernbase
|
||||
.set _dvma_base,DVMA_SPACE_START
|
||||
.globl _dvma_base
|
||||
.set _prom_start,MONSTART
|
||||
.globl _prom_start
|
||||
.set _prom_base,PROM_BASE
|
||||
.globl _prom_base
|
||||
|
||||
| This is for kvm_mkdb, and should be the address of the beginning
|
||||
| of the kernel text segment (not necessarily the same as kernbase).
|
||||
.text
|
||||
@ -111,7 +101,11 @@ L_high_code:
|
||||
| we are no longer restricted to position-independent code.
|
||||
|
||||
| Do bootstrap stuff needed before main() gets called.
|
||||
lea tmpstk, sp
|
||||
| Our boot loader leaves a copy of the kernel's exec header
|
||||
| just before the start of the kernel text segment, so the
|
||||
| kernel can sanity-check the DDB symbols at [end...esym].
|
||||
| Pass the struct exec at tmpstk-32 to sun3_bootstrap().
|
||||
lea tmpstk-32, sp
|
||||
jsr _sun3_bootstrap
|
||||
|
||||
| Now that sun3_bootstrap is done using the PROM setcxsegmap
|
||||
@ -1054,8 +1048,6 @@ Lswnofpsave:
|
||||
pea a0@ | push pmap
|
||||
jbsr _pmap_activate | pmap_activate(pmap, pcb)
|
||||
addql #8,sp
|
||||
|
||||
| XXX lea tmpstk,sp | goto a tmp stack for NMI ?
|
||||
movl _curpcb,a1 | restore p_addr
|
||||
|
||||
| XXX - Should do this in pmap_activeate only if context reg changed.
|
||||
@ -1420,3 +1412,15 @@ _delay2us:
|
||||
nop ; nop
|
||||
Lrts: rts
|
||||
|
||||
|
||||
| Define some addresses, mostly so DDB can print useful info.
|
||||
.globl _kernbase
|
||||
.set _kernbase,KERNBASE
|
||||
.globl _dvma_base
|
||||
.set _dvma_base,DVMA_SPACE_START
|
||||
.globl _prom_start
|
||||
.set _prom_start,MONSTART
|
||||
.globl _prom_base
|
||||
.set _prom_base,PROM_BASE
|
||||
|
||||
|The end!
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: locore2.c,v 1.41 1995/05/24 21:08:42 gwr Exp $ */
|
||||
/* $NetBSD: locore2.c,v 1.42 1995/06/02 16:46:22 gwr Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994 Gordon W. Ross
|
||||
@ -36,6 +36,7 @@
|
||||
#include <sys/proc.h>
|
||||
#include <sys/reboot.h>
|
||||
#include <sys/user.h>
|
||||
#include <sys/exec_aout.h>
|
||||
|
||||
#include <vm/vm.h>
|
||||
|
||||
@ -58,6 +59,7 @@ extern char kernel_text[];
|
||||
|
||||
/* These are defined by the linker */
|
||||
extern char etext[], edata[], end[];
|
||||
char *esym; /* DDB */
|
||||
|
||||
/*
|
||||
* Globals shared with the pmap code.
|
||||
@ -251,6 +253,68 @@ int keep; /* true: steal, false: clear */
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DDB
|
||||
/*
|
||||
* Preserve DDB symbols and strings by setting esym.
|
||||
*/
|
||||
sun3_save_symtab(kehp)
|
||||
struct exec *kehp; /* kernel exec header */
|
||||
{
|
||||
int *symsz, *strsz;
|
||||
char *endp;
|
||||
|
||||
/*
|
||||
* First, sanity-check the exec header.
|
||||
*/
|
||||
mon_printf("sun3_save_symtab: ");
|
||||
if ((kehp->a_midmag & 0xFFF0) != 0x100) {
|
||||
mon_printf("bad magic\n");
|
||||
return;
|
||||
}
|
||||
if (kehp->a_text != ((etext+4) - kernel_text)) {
|
||||
mon_printf("bad a_text\n");
|
||||
return;
|
||||
}
|
||||
if (kehp->a_data != (edata - (etext+4))) {
|
||||
mon_printf("bad a_data\n");
|
||||
return;
|
||||
}
|
||||
if (kehp->a_bss != (end - edata)) {
|
||||
mon_printf("bad a_bss\n");
|
||||
return;
|
||||
}
|
||||
if (kehp->a_entry != (int)kernel_text) {
|
||||
mon_printf("bad a_entry\n");
|
||||
return;
|
||||
}
|
||||
if (kehp->a_trsize || kehp->a_drsize) {
|
||||
mon_printf("bad a_Xrsize\n");
|
||||
return;
|
||||
}
|
||||
/* The exec header looks OK... */
|
||||
|
||||
/* Check the symtab length word. */
|
||||
endp = end;
|
||||
symsz = (int*)endp;
|
||||
if (kehp->a_syms != *symsz) {
|
||||
mon_printf("bad a_syms\n");
|
||||
return;
|
||||
}
|
||||
endp += sizeof(int); /* past length word */
|
||||
endp += *symsz; /* past nlist array */
|
||||
|
||||
/* Check the string table length. */
|
||||
strsz = (int*)endp;
|
||||
if ((*strsz < 4) || (*strsz > 0x80000)) {
|
||||
mon_printf("bad strsz\n");
|
||||
return;
|
||||
}
|
||||
endp += *strsz; /* past strings */
|
||||
esym = endp;
|
||||
|
||||
mon_printf(" %d + %d\n", *symsz, *strsz);
|
||||
}
|
||||
#endif /* DDB */
|
||||
|
||||
/*
|
||||
* This is called just before pmap_bootstrap()
|
||||
@ -263,22 +327,24 @@ int keep; /* true: steal, false: clear */
|
||||
* between [ KERNBASE .. virtual_avail ] and this is
|
||||
* checked in trap.c for kernel-mode MMU faults.
|
||||
*/
|
||||
void sun3_vm_init()
|
||||
void sun3_vm_init(kehp)
|
||||
struct exec *kehp; /* kernel exec header */
|
||||
{
|
||||
vm_offset_t va, eva, sva, pte, temp_seg;
|
||||
vm_offset_t u_area_va;
|
||||
unsigned int sme;
|
||||
|
||||
/*
|
||||
* XXX - Reserve DDB symbols and strings?
|
||||
*/
|
||||
|
||||
/*
|
||||
* Determine the range of kernel virtual space available.
|
||||
* This is just page-aligned for now, so we can allocate
|
||||
* some special-purpose pages before rounding to a segment.
|
||||
*/
|
||||
virtual_avail = sun3_round_page(end);
|
||||
esym = end;
|
||||
#ifdef DDB
|
||||
/* This will advance esym past the symbols. */
|
||||
sun3_save_symtab(kehp);
|
||||
#endif
|
||||
virtual_avail = sun3_round_page(esym);
|
||||
virtual_end = VM_MAX_KERNEL_ADDRESS;
|
||||
|
||||
/*
|
||||
@ -753,7 +819,8 @@ void internal_configure()
|
||||
* to its proper address, but before the call to main().
|
||||
*/
|
||||
void
|
||||
sun3_bootstrap()
|
||||
sun3_bootstrap(keh)
|
||||
struct exec keh; /* kernel exec header */
|
||||
{
|
||||
int i;
|
||||
extern int cold;
|
||||
@ -767,7 +834,7 @@ sun3_bootstrap()
|
||||
|
||||
sun3_verify_hardware(); /* get CPU type, etc. */
|
||||
|
||||
sun3_vm_init(); /* handle kernel mapping problems, etc */
|
||||
sun3_vm_init(&keh); /* handle kernel mapping, etc. */
|
||||
|
||||
pmap_bootstrap(); /* bootstrap pmap module */
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: sun3_startup.c,v 1.41 1995/05/24 21:08:42 gwr Exp $ */
|
||||
/* $NetBSD: sun3_startup.c,v 1.42 1995/06/02 16:46:22 gwr Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994 Gordon W. Ross
|
||||
@ -36,6 +36,7 @@
|
||||
#include <sys/proc.h>
|
||||
#include <sys/reboot.h>
|
||||
#include <sys/user.h>
|
||||
#include <sys/exec_aout.h>
|
||||
|
||||
#include <vm/vm.h>
|
||||
|
||||
@ -58,6 +59,7 @@ extern char kernel_text[];
|
||||
|
||||
/* These are defined by the linker */
|
||||
extern char etext[], edata[], end[];
|
||||
char *esym; /* DDB */
|
||||
|
||||
/*
|
||||
* Globals shared with the pmap code.
|
||||
@ -251,6 +253,68 @@ int keep; /* true: steal, false: clear */
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DDB
|
||||
/*
|
||||
* Preserve DDB symbols and strings by setting esym.
|
||||
*/
|
||||
sun3_save_symtab(kehp)
|
||||
struct exec *kehp; /* kernel exec header */
|
||||
{
|
||||
int *symsz, *strsz;
|
||||
char *endp;
|
||||
|
||||
/*
|
||||
* First, sanity-check the exec header.
|
||||
*/
|
||||
mon_printf("sun3_save_symtab: ");
|
||||
if ((kehp->a_midmag & 0xFFF0) != 0x100) {
|
||||
mon_printf("bad magic\n");
|
||||
return;
|
||||
}
|
||||
if (kehp->a_text != ((etext+4) - kernel_text)) {
|
||||
mon_printf("bad a_text\n");
|
||||
return;
|
||||
}
|
||||
if (kehp->a_data != (edata - (etext+4))) {
|
||||
mon_printf("bad a_data\n");
|
||||
return;
|
||||
}
|
||||
if (kehp->a_bss != (end - edata)) {
|
||||
mon_printf("bad a_bss\n");
|
||||
return;
|
||||
}
|
||||
if (kehp->a_entry != (int)kernel_text) {
|
||||
mon_printf("bad a_entry\n");
|
||||
return;
|
||||
}
|
||||
if (kehp->a_trsize || kehp->a_drsize) {
|
||||
mon_printf("bad a_Xrsize\n");
|
||||
return;
|
||||
}
|
||||
/* The exec header looks OK... */
|
||||
|
||||
/* Check the symtab length word. */
|
||||
endp = end;
|
||||
symsz = (int*)endp;
|
||||
if (kehp->a_syms != *symsz) {
|
||||
mon_printf("bad a_syms\n");
|
||||
return;
|
||||
}
|
||||
endp += sizeof(int); /* past length word */
|
||||
endp += *symsz; /* past nlist array */
|
||||
|
||||
/* Check the string table length. */
|
||||
strsz = (int*)endp;
|
||||
if ((*strsz < 4) || (*strsz > 0x80000)) {
|
||||
mon_printf("bad strsz\n");
|
||||
return;
|
||||
}
|
||||
endp += *strsz; /* past strings */
|
||||
esym = endp;
|
||||
|
||||
mon_printf(" %d + %d\n", *symsz, *strsz);
|
||||
}
|
||||
#endif /* DDB */
|
||||
|
||||
/*
|
||||
* This is called just before pmap_bootstrap()
|
||||
@ -263,22 +327,24 @@ int keep; /* true: steal, false: clear */
|
||||
* between [ KERNBASE .. virtual_avail ] and this is
|
||||
* checked in trap.c for kernel-mode MMU faults.
|
||||
*/
|
||||
void sun3_vm_init()
|
||||
void sun3_vm_init(kehp)
|
||||
struct exec *kehp; /* kernel exec header */
|
||||
{
|
||||
vm_offset_t va, eva, sva, pte, temp_seg;
|
||||
vm_offset_t u_area_va;
|
||||
unsigned int sme;
|
||||
|
||||
/*
|
||||
* XXX - Reserve DDB symbols and strings?
|
||||
*/
|
||||
|
||||
/*
|
||||
* Determine the range of kernel virtual space available.
|
||||
* This is just page-aligned for now, so we can allocate
|
||||
* some special-purpose pages before rounding to a segment.
|
||||
*/
|
||||
virtual_avail = sun3_round_page(end);
|
||||
esym = end;
|
||||
#ifdef DDB
|
||||
/* This will advance esym past the symbols. */
|
||||
sun3_save_symtab(kehp);
|
||||
#endif
|
||||
virtual_avail = sun3_round_page(esym);
|
||||
virtual_end = VM_MAX_KERNEL_ADDRESS;
|
||||
|
||||
/*
|
||||
@ -753,7 +819,8 @@ void internal_configure()
|
||||
* to its proper address, but before the call to main().
|
||||
*/
|
||||
void
|
||||
sun3_bootstrap()
|
||||
sun3_bootstrap(keh)
|
||||
struct exec keh; /* kernel exec header */
|
||||
{
|
||||
int i;
|
||||
extern int cold;
|
||||
@ -767,7 +834,7 @@ sun3_bootstrap()
|
||||
|
||||
sun3_verify_hardware(); /* get CPU type, etc. */
|
||||
|
||||
sun3_vm_init(); /* handle kernel mapping problems, etc */
|
||||
sun3_vm_init(&keh); /* handle kernel mapping, etc. */
|
||||
|
||||
pmap_bootstrap(); /* bootstrap pmap module */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user