Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/newsmips/stand/boot news5000 support.



details:   https://anonhg.NetBSD.org/src/rev/d8744cd89c7d
branches:  trunk
changeset: 479815:d8744cd89c7d
user:      tsubai <tsubai%NetBSD.org@localhost>
date:      Wed Dec 22 05:54:41 1999 +0000

description:
news5000 support.

diffstat:

 sys/arch/newsmips/stand/boot/Makefile     |   10 +-
 sys/arch/newsmips/stand/boot/boot.c       |  144 ++++++++++++++---
 sys/arch/newsmips/stand/boot/devopen.c    |   57 +++++-
 sys/arch/newsmips/stand/boot/locore.S     |   31 +++-
 sys/arch/newsmips/stand/boot/net.c        |  168 ++++++++++++++++++++
 sys/arch/newsmips/stand/boot/netif_news.c |  241 ++++++++++++++++++++++++++++++
 sys/arch/newsmips/stand/boot/promdev.h    |   12 +
 7 files changed, 618 insertions(+), 45 deletions(-)

diffs (truncated from 857 to 300 lines):

diff -r 07366cdd58c2 -r d8744cd89c7d sys/arch/newsmips/stand/boot/Makefile
--- a/sys/arch/newsmips/stand/boot/Makefile     Wed Dec 22 05:54:18 1999 +0000
+++ b/sys/arch/newsmips/stand/boot/Makefile     Wed Dec 22 05:54:41 1999 +0000
@@ -1,9 +1,9 @@
-#      $NetBSD: Makefile,v 1.3 1999/12/18 08:02:05 tsubai Exp $
+#      $NetBSD: Makefile,v 1.4 1999/12/22 05:54:41 tsubai Exp $
 
 S= ${.CURDIR}/../../../..
 
 PROG= boot
-SRCS= locore.S boot.c bootinfo.c devopen.c
+SRCS= locore.S boot.c bootinfo.c devopen.c net.c netif_news.c
 MKMAN= no
 STRIPFLAG=
 BINMODE= 444
@@ -19,8 +19,9 @@
 LDFLAGS= -x -N -Ttext a0700000 -e _start
 CFLAGS= -Os -G 0 -mno-abicalls -Wall
 
-CPPFLAGS+= -D_STANDALONE #-DBOOT_DEBUG
-CPPFLAGS+= -I${COMMON} -I${S}
+CPPFLAGS+= -DSUN_BOOTPARAMS
+CPPFLAGS+= -D_STANDALONE -DBOOT_DEBUG
+CPPFLAGS+= -I${.CURDIR} -I${COMMON} -I${S}
 
 AFLAGS= -D_LOCORE
 
@@ -36,5 +37,6 @@
        tail -c +177 ${PROG} > ${PROG}.tmp
        mv ${PROG}.tmp ${PROG}
 #      ${OBJCOPY} -O binary ${PROG}.elf ${PROG}        # XXX
+       cp boot /tftpboot
 
 .include <bsd.prog.mk>
diff -r 07366cdd58c2 -r d8744cd89c7d sys/arch/newsmips/stand/boot/boot.c
--- a/sys/arch/newsmips/stand/boot/boot.c       Wed Dec 22 05:54:18 1999 +0000
+++ b/sys/arch/newsmips/stand/boot/boot.c       Wed Dec 22 05:54:41 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: boot.c,v 1.2 1999/12/18 08:02:05 tsubai Exp $  */
+/*     $NetBSD: boot.c,v 1.3 1999/12/22 05:54:41 tsubai Exp $  */
 
 /*-
  * Copyright (C) 1999 Tsubai Masanari.  All rights reserved.
@@ -30,12 +30,17 @@
 #include <lib/libsa/stand.h>
 #include <lib/libsa/loadfile.h>
 
+#include <machine/apcall.h>
 #include <machine/bootinfo.h>
+#include <machine/cpu.h>
 #include <machine/romcall.h>
 
-void flushicache __P((void *, int));
+void mips1_flushicache __P((void *, int));
 extern char _edata[], _end[];
 
+struct apbus_sysinfo *_sip;
+int apbus;
+
 char *devs[] = { "sd", "fh", "fd", NULL, NULL, "rd", "st" };
 char *kernels[] = { "/netbsd", "/netbsd.gz", NULL };
 
@@ -47,47 +52,96 @@
 
 void
 boot(a0, a1, a2, a3, a4, a5)
-       int a0, a1, a2, a3, a4, a5;
+       u_int a0, a1, a2, a3, a4, a5;
 {
        int fd, i;
-       int ctlr, unit, part, type;
-       int bootdev = a1;
-       char *netbsd = (char *)a2;
+       char *netbsd = "";
+       int maxmem;
        u_long marks[MARK_MAX];
        char devname[32], file[32];
        void (*entry)();
        struct btinfo_symtab bi_sym;
+       struct btinfo_bootarg bi_arg;
+       struct btinfo_bootpath bi_bpath;
+       struct btinfo_systype bi_sys;
 
        /* Clear BSS. */
        bzero(_edata, _end - _edata);
 
+       /*
+        * XXX a3 contains:
+        *     maxmem (nws-3xxx)
+        *     argv   (apbus-based machine)
+        */
+       if (a3 >= 0x80000000)
+               apbus = 1;
+       else
+               apbus = 0;
+
+       if (apbus)
+               _sip = (void *)a4;
+
        printf("\n");
        printf("NetBSD/newsmips Secondary Boot\n");
 
-       bi_init(BOOTINFO_ADDR);
+       if (apbus) {
+               char *bootdev = (char *)a1;
+               int argc = a2;
+               char **argv = (char **)a3;
+
+               DPRINTF("APbus-based system\n");
 
-       /* bootname is "/boot" by default. */
-       if (netbsd == NULL || strcmp(netbsd, "/boot") == 0)
-               netbsd = "";
+               DPRINTF("argc = %d\n", argc);
+               for (i = 0; i < argc; i++) {
+                       DPRINTF("argv[%d] = %s\n", i, argv[i]);
+                       if (argv[i][0] != '-' && *netbsd == 0)
+                               netbsd = argv[i];
+               }
+               maxmem = _sip->apbsi_memsize;
+               maxmem -= 0x100000;     /* reserve 1MB for ROM monitor */
 
-       DPRINTF("howto = 0x%x\n", a0);
-       DPRINTF("bootdev = 0x%x\n", bootdev);
-       DPRINTF("bootname = %s\n", netbsd);
-       DPRINTF("maxmem = 0x%x\n", a3);
+               DPRINTF("howto = 0x%x\n", a0);
+               DPRINTF("bootdev = %s\n", (char *)a1);
+               DPRINTF("bootname = %s\n", netbsd);
+               DPRINTF("maxmem = 0x%x\n", maxmem);
+
+               /* XXX use "sonic()" instead of "tftp()" */
+               if (strncmp(bootdev, "tftp", 4) == 0)
+                       bootdev = "sonic";
 
-       ctlr = BOOTDEV_CTLR(bootdev);
-       unit = BOOTDEV_UNIT(bootdev);
-       part = BOOTDEV_PART(bootdev);
-       type = BOOTDEV_TYPE(bootdev);
+               strcpy(devname, bootdev);
+               if (strchr(devname, '(') == NULL)
+                       strcat(devname, "()");
+       } else {
+               int bootdev = a1;
+               char *bootname = (char *)a2;
+               int ctlr, unit, part, type;
+
+               DPRINTF("HB system.\n");
+
+               /* bootname is "/boot" by default on HB system. */
+               if (bootname && strcmp(bootname, "/boot") != 0)
+                       netbsd = bootname;
+               maxmem = a3;
 
-       marks[MARK_START] = 0;
+               DPRINTF("howto = 0x%x\n", a0);
+               DPRINTF("bootdev = 0x%x\n", a1);
+               DPRINTF("bootname = %s\n", netbsd);
+               DPRINTF("maxmem = 0x%x\n", maxmem);
 
-       if (devs[type] == NULL) {
-               printf("unknown bootdev (0x%x)\n", bootdev);
-               return;
+               ctlr = BOOTDEV_CTLR(bootdev);
+               unit = BOOTDEV_UNIT(bootdev);
+               part = BOOTDEV_PART(bootdev);
+               type = BOOTDEV_TYPE(bootdev);
+
+               if (devs[type] == NULL) {
+                       printf("unknown bootdev (0x%x)\n", bootdev);
+                       _rtt();
+               }
+
+               sprintf(devname, "%s(%d,%d,%d)", devs[type], ctlr, unit, part);
        }
 
-       sprintf(devname, "%s(%d,%d,%d)", devs[type], ctlr, unit, part);
        printf("Booting %s%s\n", devname, netbsd);
 
        /* use user specified kernel name if exists */
@@ -96,27 +150,47 @@
                kernels[1] = NULL;
        }
 
+       marks[MARK_START] = 0;
+
        for (i = 0; kernels[i]; i++) {
                sprintf(file, "%s%s", devname, kernels[i]);
                DPRINTF("trying %s...\n", file);
-               fd = loadfile(file, marks, LOAD_ALL);
+               fd = loadfile(file, marks, LOAD_KERNEL);
                if (fd != -1)
                        break;
        }
        if (fd == -1)
-               return;
+               _rtt();
 
        DPRINTF("entry = 0x%x\n", (int)marks[MARK_ENTRY]);
        DPRINTF("ssym = 0x%x\n", (int)marks[MARK_SYM]);
        DPRINTF("esym = 0x%x\n", (int)marks[MARK_END]);
 
+       bi_init(BOOTINFO_ADDR);
+
        bi_sym.nsym = marks[MARK_NSYM];
        bi_sym.ssym = marks[MARK_SYM];
        bi_sym.esym = marks[MARK_END];
        bi_add(&bi_sym, BTINFO_SYMTAB, sizeof(bi_sym));
 
+       bi_arg.howto = a0;
+       bi_arg.bootdev = a1;
+       bi_arg.maxmem = maxmem;
+       bi_arg.sip = (int)_sip;
+       bi_add(&bi_arg, BTINFO_BOOTARG, sizeof(bi_arg));
+
+       strcpy(bi_bpath.bootpath, file);
+       bi_add(&bi_bpath, BTINFO_BOOTPATH, sizeof(bi_bpath));
+
+       bi_sys.type = apbus ? NEWS5000 : NEWS3400;              /* XXX */
+       bi_add(&bi_sys, BTINFO_SYSTYPE, sizeof(bi_sys));
+
        entry = (void *)marks[MARK_ENTRY];
-       flushicache(entry, marks[MARK_SYM] - marks[MARK_ENTRY]);
+
+       if (apbus)
+               apcall_flush_cache();
+       else
+               mips1_flushicache(entry, marks[MARK_SYM] - marks[MARK_ENTRY]);
 
        printf("\n");
        (*entry)(a0, a1, a2, a3, a4, a5);
@@ -128,5 +202,21 @@
 {
        char c = x;
 
-       rom_write(1, &c, 1);
+       if (apbus)
+               apcall_write(1, &c, 1);
+       else
+               rom_write(1, &c, 1);
 }
+
+void halt __P((void));
+
+void
+_rtt()
+{
+       if (apbus)
+               apcall_exit(8);
+       else
+               halt();
+
+       for (;;);
+}
diff -r 07366cdd58c2 -r d8744cd89c7d sys/arch/newsmips/stand/boot/devopen.c
--- a/sys/arch/newsmips/stand/boot/devopen.c    Wed Dec 22 05:54:18 1999 +0000
+++ b/sys/arch/newsmips/stand/boot/devopen.c    Wed Dec 22 05:54:41 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: devopen.c,v 1.1 1999/07/08 11:48:05 tsubai Exp $       */
+/*     $NetBSD: devopen.c,v 1.2 1999/12/22 05:54:41 tsubai Exp $       */
 
 /*-
  * Copyright (C) 1999 Tsubai Masanari.  All rights reserved.
@@ -29,8 +29,12 @@
 #include <lib/libkern/libkern.h>
 #include <lib/libsa/stand.h>
 #include <lib/libsa/ufs.h>
+#include <netinet/in.h>
+#include <lib/libsa/nfs.h>
 
+#include <machine/apcall.h>
 #include <machine/romcall.h>
+#include <promdev.h>
 
 #ifdef BOOT_DEBUG
 # define DPRINTF printf
@@ -47,14 +51,18 @@
 };
 int ndevs = sizeof(devsw) / sizeof(devsw[0]);
 
-struct fs_ops file_system[] = {
+struct fs_ops file_system_ufs[] = {
        { ufs_open, ufs_close, ufs_read, ufs_write, ufs_seek, ufs_stat }
 };
+struct fs_ops file_system_nfs[] = {
+       { nfs_open, nfs_close, nfs_read, nfs_write, nfs_seek, nfs_stat },
+};
+struct fs_ops file_system[1];
 int nfsys = sizeof(file_system) / sizeof(file_system[0]);
 
-struct romdev {
-       int fd;
-} romdev;
+struct romdev romdev;
+
+extern int apbus;
 
 int
 devopen(f, fname, file)
@@ -65,24 +73,44 @@



Home | Main Index | Thread Index | Old Index