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 Add bootinfo support for loading symbol...



details:   https://anonhg.NetBSD.org/src/rev/0b31985cd82f
branches:  trunk
changeset: 472474:0b31985cd82f
user:      christos <christos%NetBSD.org@localhost>
date:      Fri Apr 30 09:26:16 1999 +0000

description:
Add bootinfo support for loading symbol tables.

diffstat:

 sys/arch/sparc/sparc/autoconf.c |  44 ++++++++++++++++++++++++++++++--
 sys/arch/sparc/sparc/locore.s   |  56 ++++++++++++++++++++++++++++++----------
 2 files changed, 83 insertions(+), 17 deletions(-)

diffs (188 lines):

diff -r c2543864ae9e -r 0b31985cd82f sys/arch/sparc/sparc/autoconf.c
--- a/sys/arch/sparc/sparc/autoconf.c   Fri Apr 30 09:21:54 1999 +0000
+++ b/sys/arch/sparc/sparc/autoconf.c   Fri Apr 30 09:26:16 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: autoconf.c,v 1.117 1999/04/14 09:16:11 pk Exp $ */
+/*     $NetBSD: autoconf.c,v 1.118 1999/04/30 09:26:16 christos Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -76,6 +76,7 @@
 #include <machine/promlib.h>
 #include <machine/openfirm.h>
 #include <machine/autoconf.h>
+#include <machine/bootinfo.h>
 
 #include <machine/oldmon.h>
 #include <machine/idprom.h>
@@ -107,6 +108,7 @@
 #ifdef KGDB
 extern int kgdb_debug_panic;
 #endif
+extern void *bootinfo;
 
 static char *str2hex __P((char *, int *));
 static int mbprint __P((void *, const char *));
@@ -197,7 +199,9 @@
 bootstrap()
 {
        extern struct user *proc0paddr;
-
+#ifdef DDB
+       struct btinfo_symtab *bi_sym;
+#endif
        prom_init();
 
        /* Attach user structure to proc0 */
@@ -213,7 +217,15 @@
        /* Moved zs_kgdb_init() to dev/zs.c:consinit(). */
 #ifdef DDB
        db_machine_init();
-       {
+       if ((bi_sym = lookup_bootinfo(BTINFO_SYMTAB)) != NULL) {
+               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;
 
@@ -1760,3 +1772,29 @@
        }
 
 }
+
+/*
+ * lookup_bootinfo:
+ * Look up information in bootinfo of boot loader.
+ */
+void *
+lookup_bootinfo(type)
+       int type;
+{
+       struct btinfo_common *bt;
+       char *help = bootinfo;
+
+       /* Check for a bootinfo record first. */
+       if (help == NULL)
+               return (NULL);
+
+       do {
+               bt = (struct btinfo_common *)help;
+               if (bt->type == type)
+                       return ((void *)help);
+               help += bt->next;
+       } while (bt->next != 0 &&
+               (size_t)help < (size_t)bootinfo + BOOTINFO_SIZE);
+
+       return (NULL);
+}
diff -r c2543864ae9e -r 0b31985cd82f sys/arch/sparc/sparc/locore.s
--- a/sys/arch/sparc/sparc/locore.s     Fri Apr 30 09:21:54 1999 +0000
+++ b/sys/arch/sparc/sparc/locore.s     Fri Apr 30 09:26:16 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: locore.s,v 1.116 1999/04/29 16:37:32 christos Exp $    */
+/*     $NetBSD: locore.s,v 1.117 1999/04/30 09:26:17 christos Exp $    */
 
 /*
  * Copyright (c) 1996 Paul Kranenburg
@@ -3358,7 +3358,13 @@
 
 #ifdef DDB
        /*
-        * First, check for DDB arguments. The loader passes `esym' in %o4.
+        * 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].
+        *
+        * 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.
         * Note: we don't touch %o1-%o3; SunOS bootloaders seem to use them
@@ -3374,25 +3380,42 @@
         * distinguish bootblock versions.
         */
        mov     %g0, %l4
-       set     0x44444231, %l3
-       cmp     %o5, %l3                ! chk magic
-       be      1f
-
-       set     0x44444230, %l3
-       cmp     %o5, %l3                ! chk compat magic
-       bne     2f
-
-       set     KERNBASE, %l4           ! compat magic found
+       set     KERNBASE, %l4
+
+       set     0x44444232, %l3         ! bootinfo magic
+       cmp     %o5, %l3
+       bne     1f
+       !       1st word is esym
+       ld      [%o4], %l3
+       add     %l3, %l4, %o5           ! relocate
+       sethi   %hi(_C_LABEL(esym) - KERNBASE), %l3     ! store esym
+       st      %o5, [%l3 + %lo(_C_LABEL(esym) - KERNBASE)]
+       add     %o4, 4, %o4
+       !       2nd word is bootinfo
+       ld      [%o4], %l3
+       add     %l3, %l4, %o5           ! relocate
+       sethi   %hi(_C_LABEL(bootinfo) - KERNBASE), %l3 ! store bootinfo
+       st      %o5, [%l3 + %lo(_C_LABEL(bootinfo) - KERNBASE)]
+       b       3f
+
+       set     0x44444231, %l3         ! ddb magic
+       cmp     %o5, %l3
+       be      2f
+
+       set     0x44444230, %l3         ! compat magic
+       cmp     %o5, %l3
+       bne     3f
+
        set     0xf8000000, %l5         ! compute correction term:
        sub     %l5, %l4, %l4           !  old KERNBASE (0xf8000000 ) - KERNBASE
 
-1:
+2:
        tst     %o4                     ! do we have the symbols?
-       bz      2f
+       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)]
-2:
+3:
 #endif
        /*
         * Sun4 passes in the `load address'.  Although possible, its highly
@@ -3753,6 +3776,7 @@
        sethi   %hi(_C_LABEL(trapbase)), %o0
        st      %g6, [%o0+%lo(_C_LABEL(trapbase))]
 
+#ifdef notdef
        /*
         * Step 2: clear BSS.  This may just be paranoia; the boot
         * loader might already do it for us; but what the hell.
@@ -3761,6 +3785,7 @@
        set     _end, %o1
        call    _C_LABEL(bzero)
         sub    %o1, %o0, %o1
+#endif
 
        /*
         * Stash prom vectors now, after bzero, as it lives in bss
@@ -6319,6 +6344,9 @@
        .globl  _C_LABEL(esym)
 _C_LABEL(esym):
        .word   0
+       .globl  _C_LABEL(bootinfo)
+_C_LABEL(bootinfo):
+       .word   0
 #endif
        .globl  _C_LABEL(cold)
 _C_LABEL(cold):



Home | Main Index | Thread Index | Old Index