Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/sparc/sparc Rename `esym' to `kernel_top' and alway...
details: https://anonhg.NetBSD.org/src/rev/0eeb1c3b56b8
branches: trunk
changeset: 521726:0eeb1c3b56b8
user: pk <pk%NetBSD.org@localhost>
date: Mon Feb 04 08:36:36 2002 +0000
description:
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.
diffstat:
sys/arch/sparc/sparc/autoconf.c | 92 ++++++++++++++++++++++++++++++++++++----
sys/arch/sparc/sparc/locore.s | 91 +++++++++++++++++++++------------------
sys/arch/sparc/sparc/pmap.c | 26 ++--------
3 files changed, 137 insertions(+), 72 deletions(-)
diffs (truncated from 375 to 300 lines):
diff -r 99d305e7e484 -r 0eeb1c3b56b8 sys/arch/sparc/sparc/autoconf.c
--- a/sys/arch/sparc/sparc/autoconf.c Mon Feb 04 08:35:27 2002 +0000
+++ b/sys/arch/sparc/sparc/autoconf.c Mon Feb 04 08:36:36 2002 +0000
@@ -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 @@
#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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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
diff -r 99d305e7e484 -r 0eeb1c3b56b8 sys/arch/sparc/sparc/locore.s
--- a/sys/arch/sparc/sparc/locore.s Mon Feb 04 08:35:27 2002 +0000
+++ b/sys/arch/sparc/sparc/locore.s Mon Feb 04 08:36:36 2002 +0000
@@ -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 @@
* 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 @@
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,11 +3471,22 @@
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 @@
*/
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 @@
mov %g6, %o0
Home |
Main Index |
Thread Index |
Old Index