Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/sparc64/stand/ofwboot Enhance the code that tries t...



details:   https://anonhg.NetBSD.org/src/rev/cd876c61f4a9
branches:  trunk
changeset: 472835:cd876c61f4a9
user:      eeh <eeh%NetBSD.org@localhost>
date:      Sun May 09 18:32:14 1999 +0000

description:
Enhance the code that tries to locate a kernel to search for other possibilities.

diffstat:

 sys/arch/sparc64/stand/ofwboot/boot.c |  133 ++++++++++++++++++++++++++++++++-
 1 files changed, 128 insertions(+), 5 deletions(-)

diffs (184 lines):

diff -r 990a99fe0abd -r cd876c61f4a9 sys/arch/sparc64/stand/ofwboot/boot.c
--- a/sys/arch/sparc64/stand/ofwboot/boot.c     Sun May 09 18:31:21 1999 +0000
+++ b/sys/arch/sparc64/stand/ofwboot/boot.c     Sun May 09 18:32:14 1999 +0000
@@ -1,6 +1,7 @@
-/*     $NetBSD: boot.c,v 1.6 1999/01/17 20:07:52 eeh Exp $     */
+/*     $NetBSD: boot.c,v 1.7 1999/05/09 18:32:14 eeh Exp $     */
 #define DEBUG
 /*
+ * Copyright (c) 1997, 1999 Eduardo E. Horvath.  All rights reserved.
  * Copyright (c) 1997 Jason R. Thorpe.  All rights reserved.
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
  * Copyright (C) 1995, 1996 TooLs GmbH.
@@ -60,7 +61,30 @@
 #include <sparc64/stand/ofwboot/ofdev.h>
 #include <sparc64/stand/ofwboot/openfirm.h>
 
-const char kernelname[] = "netbsd ";
+#include "fcode.h"
+
+/*
+ * Boot device is derived from ROM provided information, or if there is none,
+ * this list is used in sequence, to find a kernel.
+ */
+char *kernels[] = {
+       "netbsd ",
+       "netbsd.gz ",
+       "netbsd.old ",
+       "netbsd.old.gz ",
+       "onetbsd ",
+       "onetbsd.gz ",
+       "vmunix ",
+#ifdef notyet
+       "netbsd.pl ",
+       "netbsd.pl.gz ",
+       "netbsd.el ",
+       "netbsd.el.gz ",
+#endif
+       NULL
+};
+
+char *kernelname = kernels;
 char bootdev[128];
 char bootfile[128];
 int boothowto;
@@ -76,6 +100,10 @@
 int    aout_exec __P((int, struct exec *, u_int64_t *, void **));
 #endif
 
+#ifdef SPARC_BOOT_FCODE
+int    fcode_exec __P((int, struct fcode *, u_int64_t *, void **, void **));
+#endif
+
 static void
 prom2boot(dev)
        char *dev;
@@ -349,6 +377,89 @@
 }
 #endif /* SPARC_BOOT_AOUT */
 
+#ifdef SPARC_BOOT_FCODE
+/*
+ * Boot an FCode file.
+ *
+ * Haven't finished this yet.  Use fakeboot from the Sun developer's
+ * website until then.
+ */
+int
+fcode_exec(fd, hdr, entryp, esymp)
+       int fd;
+       struct exec *hdr;
+       u_int64_t *entryp;
+       void **esymp;
+{
+       void *addr;
+       int n, *paddr;
+
+#ifdef DEBUG
+       printf("fcode_exec: ");
+#endif
+       /* Display the load address (entry point) for a.out. */
+       printf("Booting %s @ 0x%lx\n", opened_name, hdr->a_entry);
+       addr = (void *)(hdr->a_entry);
+
+       /*
+        * Determine memory needed for kernel and allocate it from
+        * the firmware.
+        */
+       n = hdr->a_text + hdr->a_data + hdr->a_bss + hdr->a_syms + sizeof(int);
+       if ((paddr = OF_claim(addr, n, 0)) == (int *)-1)
+               panic("cannot claim memory");
+
+       /* Load text. */
+       lseek(fd, N_TXTOFF(*hdr), SEEK_SET);
+       printf("%lu", hdr->a_text);
+       if (read(fd, paddr, hdr->a_text) != hdr->a_text) {
+               printf("read text: %s\n", strerror(errno));
+               return (1);
+       }
+       syncicache((void *)paddr, hdr->a_text);
+
+       /* Load data. */
+       printf("+%lu", hdr->a_data);
+       if (read(fd, (void *)paddr + hdr->a_text, hdr->a_data) != hdr->a_data) {
+               printf("read data: %s\n", strerror(errno));
+               return (1);
+       }
+
+       /* Zero BSS. */
+       printf("+%lu", hdr->a_bss);
+       bzero((void *)paddr + hdr->a_text + hdr->a_data, hdr->a_bss);
+
+       /* Symbols. */
+       *esymp = paddr;
+       paddr = (int *)((void *)paddr + hdr->a_text + hdr->a_data + hdr->a_bss);
+       *paddr++ = hdr->a_syms;
+       if (hdr->a_syms) {
+               printf(" [%lu", hdr->a_syms);
+               if (read(fd, paddr, hdr->a_syms) != hdr->a_syms) {
+                       printf("read symbols: %s\n", strerror(errno));
+                       return (1);
+               }
+               paddr = (int *)((void *)paddr + hdr->a_syms);
+               if (read(fd, &n, sizeof(int)) != sizeof(int)) {
+                       printf("read symbols: %s\n", strerror(errno));
+                       return (1);
+               }
+               if (OF_claim((void *)paddr, n + sizeof(int), 0) == (void *)-1)
+                       panic("cannot claim memory");
+               *paddr++ = n;
+               if (read(fd, paddr, n - sizeof(int)) != n - sizeof(int)) {
+                       printf("read symbols: %s\n", strerror(errno));
+                       return (1);
+               }
+               printf("+%d]", n - sizeof(int));
+               *esymp = paddr + (n - sizeof(int));
+       }
+
+       *entryp = hdr->a_entry;
+       return (0);
+}
+#endif /* SPARC_BOOT_FCODE */
+
 #ifdef SPARC_BOOT_ELF
 #if 1
 /* New style */
@@ -511,7 +622,7 @@
        int chosen;
        char bootline[512];             /* Should check size? */
        char *cp;
-       int fd;
+       int i, fd;
        
        printf(">> %s, Revision %s\n", bootprog_name, bootprog_rev);
        printf(">> (%s, %s)\n", bootprog_maker, bootprog_date);
@@ -527,7 +638,7 @@
        }
        prom2boot(bootdev);
        parseargs(bootline, &boothowto);
-       for (;;) {
+       for (i=0;;) {
                if (boothowto & RB_ASKNAME) {
                        printf("Boot: ");
                        gets(bootline);
@@ -537,7 +648,19 @@
                        break;
                if (errno)
                        printf("open %s: %s\n", opened_name, strerror(errno));
-               boothowto |= RB_ASKNAME;
+               /*
+                * if we have are not in askname mode, and we aren't using the
+                * prom bootfile, try the next one (if it exits).  otherwise,
+                * go into askname mode.
+                */
+               if ((boothowto & RB_ASKNAME) == 0 &&
+                   i != -1 && kernels[++i]) {
+                       kernelname = kernels[i];
+                       printf(": trying %s...\n", kernelname);
+               } else {
+                       printf("\n");
+                       boothowto |= RB_ASKNAME;
+               }
        }
 #ifdef __notyet__
        OF_setprop(chosen, "bootpath", opened_name, strlen(opened_name) + 1);



Home | Main Index | Thread Index | Old Index