Rename `esym' to `kernel_top' and always initialize it in locore from
the information provided by the loader if possible (defaulting to `end'). If the DDB symbols aren't needed, `kernel_top' is adjusted in autoconf:bootstrap() before calling pmap_bootstrap(). It will also preserve the bootinfo data (if passed by the loader) for non-DDB kernels.
This commit is contained in:
parent
0cc39d8d8a
commit
3ae8fa4104
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: autoconf.c,v 1.160 2001/12/14 06:06:26 chs Exp $ */
|
||||
/* $NetBSD: autoconf.c,v 1.161 2002/02/04 08:36:36 pk Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996
|
||||
|
@ -116,6 +116,10 @@ extern int kgdb_debug_panic;
|
|||
#endif
|
||||
extern void *bootinfo;
|
||||
|
||||
#ifndef DDB
|
||||
void bootinfo_relocate(void *);
|
||||
#endif
|
||||
|
||||
static char *str2hex __P((char *, int *));
|
||||
static int mbprint __P((void *, const char *));
|
||||
static void crazymap __P((char *, int *));
|
||||
|
@ -224,9 +228,11 @@ void
|
|||
bootstrap()
|
||||
{
|
||||
extern struct user *proc0paddr;
|
||||
extern int end[];
|
||||
#ifdef DDB
|
||||
struct btinfo_symtab *bi_sym;
|
||||
#endif
|
||||
|
||||
prom_init();
|
||||
|
||||
/* Find the number of CPUs as early as possible */
|
||||
|
@ -238,6 +244,17 @@ bootstrap()
|
|||
cpuinfo.master = 1;
|
||||
getcpuinfo(&cpuinfo, 0);
|
||||
|
||||
#ifndef DDB
|
||||
/*
|
||||
* We want to reuse the memory where the symbols were stored
|
||||
* by the loader. Relocate the bootinfo array which is loaded
|
||||
* above the symbols (we assume) to the start of BSS. Then
|
||||
* adjust kernel_top accordingly.
|
||||
*/
|
||||
|
||||
bootinfo_relocate((void *)ALIGN((u_int)end));
|
||||
#endif
|
||||
|
||||
pmap_bootstrap(cpuinfo.mmu_ncontext,
|
||||
cpuinfo.mmu_nregion,
|
||||
cpuinfo.mmu_nsegment);
|
||||
|
@ -253,21 +270,18 @@ bootstrap()
|
|||
initmsgbuf((caddr_t)KERNBASE, 8192);
|
||||
#endif
|
||||
|
||||
/* Moved zs_kgdb_init() to dev/zs.c:consinit(). */
|
||||
#ifdef DDB
|
||||
if ((bi_sym = lookup_bootinfo(BTINFO_SYMTAB)) != NULL) {
|
||||
bi_sym->ssym += KERNBASE;
|
||||
bi_sym->esym += KERNBASE;
|
||||
bi_sym->ssym += KERNBASE;
|
||||
bi_sym->esym += KERNBASE;
|
||||
ddb_init(bi_sym->nsym, (int *)bi_sym->ssym,
|
||||
(int *)bi_sym->esym);
|
||||
} else {
|
||||
/*
|
||||
* Compatibility, will go away.
|
||||
*/
|
||||
extern int end;
|
||||
extern int *esym;
|
||||
|
||||
ddb_init(*(int *)&end, ((int *)&end) + 1, esym);
|
||||
extern char *kernel_top;
|
||||
ddb_init(*(int *)end, ((int *)end) + 1, (int *)kernel_top);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -943,7 +957,7 @@ cpu_rootconf()
|
|||
int bootpartition;
|
||||
|
||||
bp = nbootpath == 0 ? NULL : &bootpath[nbootpath-1];
|
||||
if (bp == NULL)
|
||||
if (bp == NULL)
|
||||
bootpartition = 0;
|
||||
else if (booted_device != bp->dev)
|
||||
bootpartition = 0;
|
||||
|
@ -1015,7 +1029,7 @@ mainbus_match(parent, cf, aux)
|
|||
return (1);
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* Helper routines to get some of the more common properties. These
|
||||
* only get the first item in case the property value is an array.
|
||||
* Drivers that "need to know it all" can call PROM_getprop() directly.
|
||||
|
@ -1974,3 +1988,61 @@ lookup_bootinfo(type)
|
|||
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
#ifndef DDB
|
||||
/*
|
||||
* Move bootinfo from the current kernel top to the proposed
|
||||
* location. As a side-effect, `kernel_top' is adjusted to point
|
||||
* at the first free location after the relocated bootinfo array.
|
||||
*/
|
||||
void
|
||||
bootinfo_relocate(newloc)
|
||||
void *newloc;
|
||||
{
|
||||
int bi_size;
|
||||
struct btinfo_common *bt;
|
||||
char *cp, *dp;
|
||||
extern char *kernel_top;
|
||||
|
||||
if (bootinfo == NULL) {
|
||||
kernel_top = newloc;
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Find total size of bootinfo array
|
||||
*/
|
||||
bi_size = 0;
|
||||
cp = bootinfo;
|
||||
do {
|
||||
bt = (struct btinfo_common *)cp;
|
||||
bi_size += bt->next;
|
||||
cp += bt->next;
|
||||
} while (bt->next != 0 &&
|
||||
(size_t)cp < (size_t)bootinfo + BOOTINFO_SIZE);
|
||||
|
||||
/*
|
||||
* Check propective gains.
|
||||
*/
|
||||
if ((int)bootinfo - (int)newloc < bi_size)
|
||||
/* Don't bother */
|
||||
return;
|
||||
|
||||
/*
|
||||
* Relocate the bits
|
||||
*/
|
||||
cp = bootinfo;
|
||||
dp = newloc;
|
||||
do {
|
||||
bt = (struct btinfo_common *)cp;
|
||||
memcpy(dp, cp, bt->next);
|
||||
cp += bt->next;
|
||||
dp += bt->next;
|
||||
} while (bt->next != 0 &&
|
||||
(size_t)cp < (size_t)bootinfo + BOOTINFO_SIZE);
|
||||
|
||||
/* Set new bootinfo location and adjust kernel_top */
|
||||
bootinfo = newloc;
|
||||
kernel_top = (char *)newloc + ALIGN(bi_size);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: locore.s,v 1.152 2002/01/23 15:46:03 pk Exp $ */
|
||||
/* $NetBSD: locore.s,v 1.153 2002/02/04 08:36:36 pk Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996 Paul Kranenburg
|
||||
|
@ -3407,28 +3407,30 @@ dostart:
|
|||
* we have to be sure to use only pc-relative addressing.
|
||||
*/
|
||||
|
||||
#ifdef DDB
|
||||
/*
|
||||
* We now use the bootinfo method to pass arguments, and the new
|
||||
* magic number indicates that. A pointer to esym is passed in
|
||||
* %o4[0] and the bootinfo structure is passed in %o4[1].
|
||||
* magic number indicates that. A pointer to the kernel top, i.e.
|
||||
* the first address after the load kernel image (including DDB
|
||||
* symbols, if any) is passed in %o4[0] and the bootinfo structure
|
||||
* is passed in %o4[1].
|
||||
*
|
||||
* A magic number is passed in %o5 to allow for bootloaders
|
||||
* that know nothing about the bootinfo structure or previous
|
||||
* DDB symbol loading conventions.
|
||||
*
|
||||
* For compatibility with older versions, we check for DDB arguments
|
||||
* if the older magic number is there. The loader passes `esym' in
|
||||
* %o4.
|
||||
* A DDB magic number is passed in %o5 to allow for bootloaders
|
||||
* that know nothing about DDB symbol loading conventions.
|
||||
* if the older magic number is there. The loader passes `kernel_top'
|
||||
* (previously known as `esym') in %o4.
|
||||
*
|
||||
* Note: we don't touch %o1-%o3; SunOS bootloaders seem to use them
|
||||
* for their own mirky business.
|
||||
*
|
||||
* Pre-NetBSD 1.3 bootblocks had KERNBASE compiled in, and used
|
||||
* it to compute the value of `esym'. In order to successfully
|
||||
* boot a kernel built with a different value for KERNBASE using
|
||||
* old bootblocks, we fixup `esym' here by the difference between
|
||||
* KERNBASE and the old value (known to be 0xf8000000) compiled
|
||||
* into pre-1.3 bootblocks.
|
||||
* We use the magic number passed as the sixth argument to
|
||||
* distinguish bootblock versions.
|
||||
* Pre-NetBSD 1.3 bootblocks had KERNBASE compiled in, and used it
|
||||
* to compute the value of `kernel_top' (previously known as `esym').
|
||||
* In order to successfully boot a kernel built with a different value
|
||||
* for KERNBASE using old bootblocks, we fixup `kernel_top' here by
|
||||
* the difference between KERNBASE and the old value (known to be
|
||||
* 0xf8000000) compiled into pre-1.3 bootblocks.
|
||||
*/
|
||||
set KERNBASE, %l4
|
||||
|
||||
|
@ -3438,27 +3440,28 @@ dostart:
|
|||
nop
|
||||
|
||||
/* The loader has passed to us a `bootinfo' structure */
|
||||
ld [%o4], %l3 ! 1st word is esym
|
||||
add %l3, %l4, %o5 ! relocate
|
||||
sethi %hi(_C_LABEL(esym) - KERNBASE), %l3 ! store esym
|
||||
st %o5, [%l3 + %lo(_C_LABEL(esym) - KERNBASE)]
|
||||
ld [%o4], %l3 ! 1st word is kernel_top
|
||||
add %l3, %l4, %o5 ! relocate: + KERNBASE
|
||||
sethi %hi(_C_LABEL(kernel_top) - KERNBASE), %l3 ! and store it
|
||||
st %o5, [%l3 + %lo(_C_LABEL(kernel_top) - KERNBASE)]
|
||||
|
||||
ld [%o4 + 4], %l3 ! 2nd word is bootinfo
|
||||
add %l3, %l4, %o5 ! relocate
|
||||
sethi %hi(_C_LABEL(bootinfo) - KERNBASE), %l3 ! store bootinfo
|
||||
st %o5, [%l3 + %lo(_C_LABEL(bootinfo) - KERNBASE)]
|
||||
b,a 3f
|
||||
b,a 4f
|
||||
|
||||
1:
|
||||
#ifdef DDB
|
||||
/* Check for old-style DDB loader magic */
|
||||
set 0x44444231, %l3 ! ddb magic
|
||||
set 0x44444231, %l3 ! Is it DDB_MAGIC1?
|
||||
cmp %o5, %l3
|
||||
be,a 2f
|
||||
clr %l4 ! if DDB_MAGIC1, clear %l4
|
||||
|
||||
set 0x44444230, %l3 ! compat magic
|
||||
cmp %o5, %l3
|
||||
bne 3f
|
||||
set 0x44444230, %l3 ! Is it DDB_MAGIC0?
|
||||
cmp %o5, %l3 ! if so, need to relocate %o4
|
||||
bne 3f ! if not, there's no bootloader info
|
||||
|
||||
! note: %l4 set to KERNBASE above.
|
||||
set 0xf8000000, %l5 ! compute correction term:
|
||||
|
@ -3468,10 +3471,21 @@ dostart:
|
|||
tst %o4 ! do we have the symbols?
|
||||
bz 3f
|
||||
sub %o4, %l4, %o4 ! apply compat correction
|
||||
sethi %hi(_C_LABEL(esym) - KERNBASE), %l3 ! store esym
|
||||
st %o4, [%l3 + %lo(_C_LABEL(esym) - KERNBASE)]
|
||||
sethi %hi(_C_LABEL(kernel_top) - KERNBASE), %l3 ! and store it
|
||||
st %o4, [%l3 + %lo(_C_LABEL(kernel_top) - KERNBASE)]
|
||||
b,a 4f
|
||||
3:
|
||||
#endif
|
||||
/*
|
||||
* The boot loader did not pass in a value for `kernel_top';
|
||||
* let it default to `end'.
|
||||
*/
|
||||
set end, %o4
|
||||
sethi %hi(_C_LABEL(kernel_top) - KERNBASE), %l3 ! store kernel_top
|
||||
st %o4, [%l3 + %lo(_C_LABEL(kernel_top) - KERNBASE)]
|
||||
|
||||
4:
|
||||
|
||||
/*
|
||||
* Sun4 passes in the `load address'. Although possible, its highly
|
||||
* unlikely that OpenBoot would place the prom vector there.
|
||||
|
@ -3621,17 +3635,12 @@ start_havetype:
|
|||
*/
|
||||
clr %l0 ! lowva
|
||||
set KERNBASE, %l1 ! highva
|
||||
set _end + (2 << 18), %l2 ! last va that must be remapped
|
||||
#ifdef DDB
|
||||
sethi %hi(_C_LABEL(esym) - KERNBASE), %o1
|
||||
ld [%o1+%lo(_C_LABEL(esym) - KERNBASE)], %o1
|
||||
tst %o1
|
||||
bz 1f
|
||||
nop
|
||||
set (2 << 18), %l2
|
||||
add %l2, %o1, %l2 ! last va that must be remapped
|
||||
1:
|
||||
#endif
|
||||
|
||||
sethi %hi(_C_LABEL(kernel_top) - KERNBASE), %o0
|
||||
ld [%o0 + %lo(_C_LABEL(kernel_top) - KERNBASE)], %o1
|
||||
set (2 << 18), %o2 ! add slack for sun4c MMU
|
||||
add %o1, %o2, %l2 ! last va that must be remapped
|
||||
|
||||
/*
|
||||
* Need different initial mapping functions for different
|
||||
* types of machines.
|
||||
|
@ -6203,11 +6212,9 @@ Llongjmpbotch:
|
|||
mov %g6, %o0
|
||||
|
||||
.data
|
||||
#ifdef DDB
|
||||
.globl _C_LABEL(esym)
|
||||
_C_LABEL(esym):
|
||||
.globl _C_LABEL(kernel_top)
|
||||
_C_LABEL(kernel_top):
|
||||
.word 0
|
||||
#endif
|
||||
.globl _C_LABEL(bootinfo)
|
||||
_C_LABEL(bootinfo):
|
||||
.word 0
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: pmap.c,v 1.203 2002/01/25 17:50:33 pk Exp $ */
|
||||
/* $NetBSD: pmap.c,v 1.204 2002/02/04 08:36:37 pk Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996
|
||||
|
@ -2909,10 +2909,7 @@ pmap_bootstrap4_4c(nctx, nregion, nsegment)
|
|||
caddr_t p;
|
||||
int lastpage;
|
||||
vaddr_t va;
|
||||
extern char end[];
|
||||
#ifdef DDB
|
||||
extern char *esym;
|
||||
#endif
|
||||
extern char *kernel_top;
|
||||
|
||||
ncontext = nctx;
|
||||
|
||||
|
@ -3014,11 +3011,8 @@ pmap_bootstrap4_4c(nctx, nregion, nsegment)
|
|||
/*
|
||||
* Allocate and clear mmu entries and context structures.
|
||||
*/
|
||||
p = end;
|
||||
#ifdef DDB
|
||||
if (esym != 0)
|
||||
p = esym;
|
||||
#endif
|
||||
p = kernel_top;
|
||||
|
||||
#if defined(SUN4_MMU3L)
|
||||
mmuregions = mmureg = (struct mmuentry *)p;
|
||||
p += nregion * sizeof(struct mmuentry);
|
||||
|
@ -3286,12 +3280,9 @@ pmap_bootstrap4m(void)
|
|||
unsigned int ctxtblsize;
|
||||
caddr_t pagetables_start, pagetables_end;
|
||||
paddr_t pagetables_start_pa;
|
||||
extern char end[];
|
||||
extern char *kernel_top;
|
||||
extern char etext[];
|
||||
extern caddr_t reserve_dumppages(caddr_t);
|
||||
#ifdef DDB
|
||||
extern char *esym;
|
||||
#endif
|
||||
|
||||
ncontext = cpuinfo.mmu_ncontext;
|
||||
|
||||
|
@ -3314,12 +3305,7 @@ pmap_bootstrap4m(void)
|
|||
/*
|
||||
* p points to top of kernel mem
|
||||
*/
|
||||
p = end;
|
||||
#ifdef DDB
|
||||
/* Skip over DDB symbols */
|
||||
if (esym != 0)
|
||||
p = esym;
|
||||
#endif
|
||||
p = kernel_top;
|
||||
|
||||
/*
|
||||
* Intialize the kernel pmap.
|
||||
|
|
Loading…
Reference in New Issue