Source-Changes-HG archive

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

[src/nathanw_sa]: src/sys/arch/mipsco/stand change b*() -> mem*()



details:   https://anonhg.NetBSD.org/src/rev/f4c074b05cd7
branches:  nathanw_sa
changeset: 504822:f4c074b05cd7
user:      wdk <wdk%NetBSD.org@localhost>
date:      Sun Jul 08 04:25:38 2001 +0000

description:
change b*() -> mem*()

diffstat:

 sys/arch/mipsco/stand/common/bootxx.c           |  180 ++++++++++++
 sys/arch/mipsco/stand/installboot/installboot.c |  348 ++++++++++++++++++++++++
 2 files changed, 528 insertions(+), 0 deletions(-)

diffs (truncated from 536 to 300 lines):

diff -r 49688447c1d9 -r f4c074b05cd7 sys/arch/mipsco/stand/common/bootxx.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/mipsco/stand/common/bootxx.c     Sun Jul 08 04:25:38 2001 +0000
@@ -0,0 +1,180 @@
+/*     $NetBSD: bootxx.c,v 1.3.8.2 2001/07/08 04:25:38 wdk Exp $       */
+
+/*-
+ * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jonathan Stone, Michael Hitch, Simon Burge and Wayne Knowles.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *        This product includes software developed by the NetBSD
+ *        Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Copyright (c) 1992, 1993
+ *     The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Ralph Campbell.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *     @(#)boot.c      8.1 (Berkeley) 6/10/93
+ */
+
+#include <sys/param.h>
+#include <sys/exec_elf.h>
+#include <lib/libsa/stand.h>
+#include <machine/prom.h>
+
+typedef void (*entrypt) __P((int, char **, int, const void *));
+
+int main __P((int, char **));
+entrypt loadfile __P((char *path, char *name));
+
+/*
+ * This gets arguments from the PROM, calls other routines to open
+ * and load the secondary boot loader called boot, and then transfers
+ * execution to that program.
+ */
+int
+main(argc, argv)
+       int argc;
+       char **argv;
+{
+       entrypt entry;
+       char *cp;
+       extern void prom_init __P((void));
+
+       prom_init();
+
+       cp = *argv;
+
+        printf("\nNetBSD/mipsco " NETBSD_VERS " " BOOTXX_FS_NAME " Primary Bootstrap\n");
+
+       entry = loadfile(cp, "/boot");
+       if ((int)entry != -1)
+               goto goodload;
+
+       entry = loadfile(cp, "/boot.mipsco");
+       if ((int)entry != -1)
+               goto goodload;
+
+       goto bad;
+
+ goodload:
+       MIPS_PROM(flushcache)();
+       entry(argc, argv, 0, 0);
+
+ bad:
+       return (1);
+}
+
+/*
+ * Open 'filename', read in program and return the entry point or -1 if error.
+ */
+entrypt
+loadfile(path, name)
+       char *path, *name;
+{
+       int fd, i;
+       char *src, *dst, bootfname[64];
+       Elf32_Ehdr ehdr;
+       Elf32_Phdr phdr;
+
+       dst = bootfname;
+       for (src = path; *src;/**/)
+               if ((*dst++ = *src++) == ')')
+                       break;
+       for (src = name; *src;/**/)
+               *dst++ = *src++;
+       *dst = (char) 0;
+
+       if ((fd = open(bootfname, 0)) < 0) {
+               printf("open %s: %d\n", bootfname, errno);
+               goto err;
+       }
+
+       /* read the exec header */
+       i = read(fd, (char *)&ehdr, sizeof(ehdr));
+       if ((i != sizeof(ehdr)) ||
+           (memcmp(ehdr.e_ident, ELFMAG, SELFMAG) != 0) ||
+           (ehdr.e_ident[EI_CLASS] != ELFCLASS32)) {
+               printf("%s: No ELF header\n", bootfname);
+               goto cerr;
+       }
+
+       for (i = 0; i < ehdr.e_phnum; i++) {
+               if (lseek(fd, (off_t) ehdr.e_phoff + i * sizeof(phdr), 0) < 0)
+                       goto cerr;
+               if (read(fd, &phdr, sizeof(phdr)) != sizeof(phdr))
+                       goto cerr;
+               if (phdr.p_type != PT_LOAD)
+                       continue;
+               if (lseek(fd, (off_t)phdr.p_offset, 0) < 0)
+                       goto cerr;
+               if (read(fd, (char *)phdr.p_paddr, phdr.p_filesz) != phdr.p_filesz)
+                       goto cerr;
+       }
+       return ((entrypt)ehdr.e_entry);
+
+ cerr:
+#ifndef LIBSA_NO_FS_CLOSE
+       (void) close(fd);
+#endif
+ err:
+       printf("Can't load '%s'\n", bootfname);
+       return ((entrypt)-1);
+}
diff -r 49688447c1d9 -r f4c074b05cd7 sys/arch/mipsco/stand/installboot/installboot.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/mipsco/stand/installboot/installboot.c   Sun Jul 08 04:25:38 2001 +0000
@@ -0,0 +1,348 @@
+/*     $NetBSD: installboot.c,v 1.3.8.2 2001/07/08 04:25:38 wdk Exp $  */
+
+/*
+ * Copyright (c) 2000 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Wayne Knowles
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *        This product includes software developed by the NetBSD
+ *        Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <assert.h>
+#include <err.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <sys/param.h>
+#include <sys/stat.h>
+#include <sys/disklabel.h>
+
+
+#define        VERBOSE(msg)    if (verbose)                            \
+                               fprintf(stderr, msg)
+#define        FATAL(a1,a2)    errx(EXIT_FAILURE, a1, a2)
+#define        FATALIO(a1,a2)  err(EXIT_FAILURE, a1, a2)
+
+#define BOOTBLOCK_NUMBER       2
+#define        BOOTBLOCK_OFFSET        BOOTBLOCK_NUMBER*DEV_BSIZE
+#define        DEFAULT_BOOTFILE        "boot"
+
+static void    usage __P((void));
+static void    do_list __P((const char *));
+static void    do_remove __P((const char *, const char *));
+static void    do_install __P((const char *, const char *, const char *));
+static int     mipsvh_cksum __P((struct mips_volheader *));
+static void    read_volheader __P((const char *, struct mips_volheader *));
+static void    write_volheader __P((const char *, struct mips_volheader *));
+static struct mips_voldir *voldir_findfile __P((struct mips_volheader *, 
+                                               const char *, int));
+
+int verbose, nowrite;
+
+static void
+usage()
+{
+
+       fprintf(stderr, "usage:\n");
+       fprintf(stderr, "\t%s [-nv] disk bootstrap [name]\n", getprogname());
+       fprintf(stderr, "\t%s -r [-nv] disk [name]\n", getprogname());
+       fprintf(stderr, "\t%s -l [-nv] disk\n", getprogname());
+       exit(EXIT_FAILURE);
+}
+
+int
+main(int argc, char *argv[])
+{
+       const char *disk;
+       int c, rflag, lflag;
+
+       rflag = lflag = verbose = nowrite = 0;
+
+       while ((c = getopt(argc, argv, "lnrv")) != -1) {
+               switch (c) {
+               case 'l':
+                       /* List volume directory contents */
+                       lflag = 1;
+                       break;
+               case 'n':
+                       /* Disable write of boot sectors */
+                       nowrite = 1;
+                       break;
+               case 'r':
+                       /* Clear any existing boot block */
+                       rflag = 1;
+                       break;
+               case 'v':
+                       /* Verbose output */
+                       verbose = 1;
+                       break;
+               default:
+                       usage();
+               }



Home | Main Index | Thread Index | Old Index