Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/zaurus/stand/zboot Support to read the kernel from ...



details:   https://anonhg.NetBSD.org/src/rev/333a1cc1ed2a
branches:  trunk
changeset: 772860:333a1cc1ed2a
user:      nonaka <nonaka%NetBSD.org@localhost>
date:      Wed Jan 18 23:12:21 2012 +0000

description:
Support to read the kernel from local file system.

ex. boot path:/mnt/card/netbsd

diffstat:

 sys/arch/zaurus/stand/zboot/Makefile    |    7 +-
 sys/arch/zaurus/stand/zboot/boot.c      |   13 ++-
 sys/arch/zaurus/stand/zboot/boot.h      |    3 +-
 sys/arch/zaurus/stand/zboot/bootmenu.c  |    5 +-
 sys/arch/zaurus/stand/zboot/conf.c      |   11 +-
 sys/arch/zaurus/stand/zboot/devopen.c   |    9 +-
 sys/arch/zaurus/stand/zboot/diskprobe.c |   28 ++++---
 sys/arch/zaurus/stand/zboot/pathfs.c    |  114 ++++++++++++++++++++++++++++++++
 sys/arch/zaurus/stand/zboot/pathfs.h    |   28 +++++++
 sys/arch/zaurus/stand/zboot/pathnames.h |    4 +-
 sys/arch/zaurus/stand/zboot/unixdev.c   |   49 ++++++++++++-
 sys/arch/zaurus/stand/zboot/unixdev.h   |    3 +-
 sys/arch/zaurus/stand/zboot/version     |    3 +-
 13 files changed, 240 insertions(+), 37 deletions(-)

diffs (truncated from 551 to 300 lines):

diff -r ffdb3bd15776 -r 333a1cc1ed2a sys/arch/zaurus/stand/zboot/Makefile
--- a/sys/arch/zaurus/stand/zboot/Makefile      Wed Jan 18 21:34:38 2012 +0000
+++ b/sys/arch/zaurus/stand/zboot/Makefile      Wed Jan 18 23:12:21 2012 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.7 2011/12/25 06:09:10 tsutsui Exp $
+#      $NetBSD: Makefile,v 1.8 2012/01/18 23:12:21 nonaka Exp $
 
 PROG=          zboot
 
@@ -8,6 +8,7 @@
 SRCS+=         boot.c bootinfo.c bootmenu.c conf.c devopen.c diskprobe.c
 SRCS+=         loadfile_zboot.c
 SRCS+=         getsecs.c termios.c unixcons.c unixdev.c unixsys.S
+SRCS+=         pathfs.c
 
 NOMAN=         # defined
 
@@ -33,7 +34,7 @@
 VERSIONFILE?=  ${.CURDIR}/version
 
 ### find out what to use for libkern
-KERN_AS=               library
+KERN_AS=       library
 .include "${S}/lib/libkern/Makefile.inc"
 LIBKERN=       ${KERNLIB}
 
@@ -48,7 +49,7 @@
 .include "${S}/lib/libsa/Makefile.inc"
 LIBSA=         ${SALIB}
 
-${PROG}: ${OBJS} ${LIBSA} ${LIBZ} ${LIBKERN}
+${PROG}: ${OBJS} ${LIBSA} ${LIBZ} ${LIBKERN} ${VERSIONFILE}
        ${HOST_SH} ${S}/conf/newvers_stand.sh ${${MKREPRO} == "yes" :?:-D} \
            ${VERSIONFILE} ${MACHINE} ${NEWVERSWHAT}
        ${CC} -c vers.c
diff -r ffdb3bd15776 -r 333a1cc1ed2a sys/arch/zaurus/stand/zboot/boot.c
--- a/sys/arch/zaurus/stand/zboot/boot.c        Wed Jan 18 21:34:38 2012 +0000
+++ b/sys/arch/zaurus/stand/zboot/boot.c        Wed Jan 18 23:12:21 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: boot.c,v 1.4 2011/12/25 06:09:10 tsutsui Exp $ */
+/*     $NetBSD: boot.c,v 1.5 2012/01/18 23:12:21 nonaka Exp $  */
 
 /*
  * Copyright (c) 2009 NONAKA Kimihiro <nonaka%netbsd.org@localhost>
@@ -53,6 +53,7 @@
 int default_timeout = 5;
 
 static char probed_disks[256];
+static char bootconfpath[1024];
 
 static void bootcmd_help(char *);
 static void bootcmd_ls(char *);
@@ -196,7 +197,10 @@
 
        diskprobe(probed_disks, sizeof(probed_disks));
 
-       parsebootconf(_PATH_BOOTCONF);
+       snprintf(bootconfpath, sizeof(bootconfpath), "%s%d%c:%s",
+           default_devname, default_unit, 'a' + default_partition,
+           _PATH_BOOTCONF);
+       parsebootconf(bootconfpath);
 
 #ifdef SUPPORT_CONSDEV
        /*
@@ -296,8 +300,9 @@
 {
 
        printf("commands are:\n"
-           "boot [xdNx:][filename] [-acdqsv]\n"
-           "     (ex. \"hd0a:netbsd.old -s\"\n"
+           "boot [xdNx:][filename] [-1acdqsv]\n"
+           "     (ex. \"boot hd0a:netbsd.old -s\")\n"
+           "     (ex. \"boot path:/mnt/card/netbsd -1\")\n"
            "ls [path]\n"
 #ifdef SUPPORT_CONSDEV
            "consdev {glass|com [speed]}\n"
diff -r ffdb3bd15776 -r 333a1cc1ed2a sys/arch/zaurus/stand/zboot/boot.h
--- a/sys/arch/zaurus/stand/zboot/boot.h        Wed Jan 18 21:34:38 2012 +0000
+++ b/sys/arch/zaurus/stand/zboot/boot.h        Wed Jan 18 23:12:21 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: boot.h,v 1.1 2009/03/02 09:33:02 nonaka Exp $  */
+/*     $NetBSD: boot.h,v 1.2 2012/01/18 23:12:21 nonaka Exp $  */
 
 /*
  * Copyright (c) 2009 NONAKA Kimihiro
@@ -52,6 +52,7 @@
 /* conf.c */
 extern char devname_hd[];
 extern char devname_mmcd[];
+extern char devname_path[];
 
 /* loadfile_zboot.c */
 int loadfile_zboot(const char *fname, u_long *marks, int flags);
diff -r ffdb3bd15776 -r 333a1cc1ed2a sys/arch/zaurus/stand/zboot/bootmenu.c
--- a/sys/arch/zaurus/stand/zboot/bootmenu.c    Wed Jan 18 21:34:38 2012 +0000
+++ b/sys/arch/zaurus/stand/zboot/bootmenu.c    Wed Jan 18 23:12:21 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bootmenu.c,v 1.1 2009/03/02 09:33:02 nonaka Exp $      */
+/*     $NetBSD: bootmenu.c,v 1.2 2012/01/18 23:12:21 nonaka Exp $      */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -105,7 +105,7 @@
        /* automatically switch between letter and numbers on menu */
        bootconf.menuformat = MENUFORMAT_AUTO;
 
-       fd = open(_PATH_BOOTCONF, 0);
+       fd = open(conf, 0);
        if (fd < 0)
                return;
 
@@ -118,6 +118,7 @@
        bc = alloc(st.st_size + 1);
        if (bc == NULL) {
                printf("Could not allocate memory for boot configuration\n");
+               close(fd);
                return;
        }
 
diff -r ffdb3bd15776 -r 333a1cc1ed2a sys/arch/zaurus/stand/zboot/conf.c
--- a/sys/arch/zaurus/stand/zboot/conf.c        Wed Jan 18 21:34:38 2012 +0000
+++ b/sys/arch/zaurus/stand/zboot/conf.c        Wed Jan 18 23:12:21 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: conf.c,v 1.1 2009/03/02 09:33:02 nonaka Exp $  */
+/*     $NetBSD: conf.c,v 1.2 2012/01/18 23:12:21 nonaka Exp $  */
 
 /*
  * Copyright (c) 2009 NONAKA Kimihiro <nonaka%netbsd.org@localhost>
@@ -30,20 +30,23 @@
 
 #include <lib/libsa/ufs.h>
 #include <lib/libsa/ext2fs.h>
+#include "pathfs.h"
 
 char devname_hd[] = "hd";
 char devname_mmcd[] = "mmcd";
+char devname_path[] = "path";
 
 struct devsw devsw[] = {
-    { devname_hd, unixstrategy, unixopen, unixclose, unixioctl},
-    { devname_mmcd, unixstrategy, unixopen, unixclose, unixioctl},
+    { devname_hd, unixstrategy, unixopen, unixclose, unixioctl },
+    { devname_mmcd, unixstrategy, unixopen, unixclose, unixioctl },
+    { devname_path, unixstrategy, unixpathopen, unixclose, unixioctl },
 };
 int ndevs = __arraycount(devsw);
 
 struct fs_ops file_system[] = {
-    FS_OPS(ufs),
     FS_OPS(ffsv1),
     FS_OPS(ffsv2),
     FS_OPS(ext2fs),
+    FS_OPS(pathfs),
 };
 int nfsys = __arraycount(file_system);
diff -r ffdb3bd15776 -r 333a1cc1ed2a sys/arch/zaurus/stand/zboot/devopen.c
--- a/sys/arch/zaurus/stand/zboot/devopen.c     Wed Jan 18 21:34:38 2012 +0000
+++ b/sys/arch/zaurus/stand/zboot/devopen.c     Wed Jan 18 23:12:21 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: devopen.c,v 1.1 2009/03/02 09:33:02 nonaka Exp $       */
+/*     $NetBSD: devopen.c,v 1.2 2012/01/18 23:12:21 nonaka Exp $       */
 
 /*-
  *  Copyright (c) 1993 John Brezak
@@ -80,7 +80,7 @@
 {
        struct devsw *dp;
        char *fsname, *devname;
-       unsigned int dev, ctlr, unit, partition;
+       u_int dev, unit, partition;
        int biosdev;
        int error;
 
@@ -88,7 +88,6 @@
        printf("devopen: fname = %s\n", fname ? fname : "(null)");
 #endif
 
-       ctlr = 0;
        if ((error = parsebootfile(fname, &fsname, &devname, &unit, &partition,
            (const char **)file)) != 0) {
                return error;
@@ -118,13 +117,13 @@
 #if defined(UNIX_DEBUG)
                printf("devopen: bios disk\n");
 #endif
-               return (unixopen(f, biosdev, devname, unit, partition, *file));
+               return unixopen(f, devname, unit, partition, *file);
        }
 
 #if defined(UNIX_DEBUG)
        printf("devopen: dev->dv_open()\n");
 #endif
-       if ((error = (*dp->dv_open)(f, ctlr, unit, partition)) == 0) {
+       if ((error = (*dp->dv_open)(f, devname, unit, partition, *file)) == 0) {
 #if defined(UNIX_DEBUG)
                printf("devopen: dev->dv_open() opened\n");
 #endif
diff -r ffdb3bd15776 -r 333a1cc1ed2a sys/arch/zaurus/stand/zboot/diskprobe.c
--- a/sys/arch/zaurus/stand/zboot/diskprobe.c   Wed Jan 18 21:34:38 2012 +0000
+++ b/sys/arch/zaurus/stand/zboot/diskprobe.c   Wed Jan 18 23:12:21 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: diskprobe.c,v 1.2 2011/06/20 12:39:21 nonaka Exp $     */
+/*     $NetBSD: diskprobe.c,v 1.3 2012/01/18 23:12:21 nonaka Exp $     */
 /*     $OpenBSD: diskprobe.c,v 1.3 2006/10/13 00:00:55 krw Exp $       */
 
 /*
@@ -69,7 +69,6 @@
        static const int order[] = { 0x80, 0x82, 0x00 };
        char devname[MAXDEVNAME];
        struct diskinfo *dip;
-       u_int disk = 0;
        u_int hd_disk = 0;
        u_int mmcd_disk = 0;
        uint unit = 0;
@@ -90,16 +89,13 @@
 
                bios_devname(order[i], devname, sizeof(devname));
                if (order[i] & 0x80) {
-                       unit = hd_disk;
-                       snprintf(dip->devname, sizeof(dip->devname), "%s%d",
-                           devname, hd_disk++);
+                       unit = hd_disk++;
                } else {
-                       unit = mmcd_disk;
-                       snprintf(dip->devname, sizeof(dip->devname), "%s%d",
-                           devname, mmcd_disk++);
+                       unit = mmcd_disk++;
                }
+               snprintf(dip->devname, sizeof(dip->devname), "%s%d", devname,
+                   unit);
                strlcat(buf, dip->devname, bufsiz);
-               disk++;
 
                /* Try to find the label, to figure out device type. */
                if (bios_getdisklabel(&dip->bios_info, &dip->disklabel)
@@ -111,6 +107,7 @@
                                    sizeof(disk_devname));
                                default_devname = disk_devname;
                                default_unit = unit;
+                               default_partition = 0;
                        }
                } else {
                        /* Best guess */
@@ -131,8 +128,17 @@
 
                strlcat(buf, " ", bufsiz);
        }
-       if (disk == 0)
-               strlcat(buf, "none...", bufsiz);
+
+       /* path */
+       strlcat(buf, devname_path, bufsiz);
+       strlcat(buf, "*", bufsiz);
+       if (first) {
+               first = 0;
+               strlcpy(disk_devname, devname_path, sizeof(disk_devname));
+               default_devname = disk_devname;
+               default_unit = 0;
+               default_partition = 0;
+       }
 }
 
 static void
diff -r ffdb3bd15776 -r 333a1cc1ed2a sys/arch/zaurus/stand/zboot/pathfs.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/zaurus/stand/zboot/pathfs.c      Wed Jan 18 23:12:21 2012 +0000
@@ -0,0 +1,114 @@
+/*     $NetBSD: pathfs.c,v 1.1 2012/01/18 23:12:21 nonaka Exp $        */
+
+/*-
+ * Copyright (C) 2012 NONAKA Kimihiro <nonaka%netbsd.org@localhost>
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 "boot.h"
+#include "pathfs.h"
+#include "unixdev.h"
+#include "compat_linux.h"
+
+__compactcall int



Home | Main Index | Thread Index | Old Index