Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/ofppc Support for reading disklabels from RDB parti...



details:   https://anonhg.NetBSD.org/src/rev/d514f436db5b
branches:  trunk
changeset: 760238:d514f436db5b
user:      phx <phx%NetBSD.org@localhost>
date:      Fri Dec 31 21:50:27 2010 +0000

description:
Support for reading disklabels from RDB partitions in the kernel.
The code will check for a raw disklabel first, then tries to find the
disklabel in an MBR partition and finally constructs it from RDB
partitions.
RDB is probably only needed for the Pegasos platform, so it can be
disabled in the config file (RDB_PART).

diffstat:

 sys/arch/ofppc/conf/GENERIC        |    5 +-
 sys/arch/ofppc/conf/GENERIC.MP     |    5 +-
 sys/arch/ofppc/conf/files.ofppc    |   20 +-
 sys/arch/ofppc/include/disklabel.h |   38 +-
 sys/arch/ofppc/ofppc/disksubr.c    |  893 +++++++++++++++++++++++++++++++++++++
 5 files changed, 932 insertions(+), 29 deletions(-)

diffs (truncated from 1044 to 300 lines):

diff -r 29fbcf148aa1 -r d514f436db5b sys/arch/ofppc/conf/GENERIC
--- a/sys/arch/ofppc/conf/GENERIC       Fri Dec 31 18:26:25 2010 +0000
+++ b/sys/arch/ofppc/conf/GENERIC       Fri Dec 31 21:50:27 2010 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.133 2010/12/20 00:14:40 matt Exp $
+# $NetBSD: GENERIC,v 1.134 2010/12/31 21:50:27 phx Exp $
 #
 # GENERIC machine description file
 # 
@@ -22,7 +22,7 @@
 
 options        INCLUDE_CONFIG_FILE     # embed config file in kernel binary
 
-#ident                 "GENERIC-$Revision: 1.133 $"
+#ident                 "GENERIC-$Revision: 1.134 $"
 
 maxusers       32
 
@@ -48,6 +48,7 @@
 options        USERCONF        # userconf(4) support
 #options       PIPE_SOCKETPAIR # smaller, but slower pipe(2)
 options        SYSCTL_INCLUDE_DESCR    # Include sysctl descriptions in kernel
+options        RDB_PART        # Rigid Disk Block partition support
 
 # Diagnostic/debugging support options
 #options       DIAGNOSTIC      # cheap kernel consistency checks
diff -r 29fbcf148aa1 -r d514f436db5b sys/arch/ofppc/conf/GENERIC.MP
--- a/sys/arch/ofppc/conf/GENERIC.MP    Fri Dec 31 18:26:25 2010 +0000
+++ b/sys/arch/ofppc/conf/GENERIC.MP    Fri Dec 31 21:50:27 2010 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC.MP,v 1.13 2010/12/10 21:27:21 phx Exp $
+# $NetBSD: GENERIC.MP,v 1.14 2010/12/31 21:50:27 phx Exp $
 #
 # GENERIC machine description file
 # 
@@ -22,7 +22,7 @@
 
 options        INCLUDE_CONFIG_FILE     # embed config file in kernel binary
 
-#ident                 "GENERIC-$Revision: 1.13 $"
+#ident                 "GENERIC-$Revision: 1.14 $"
 
 maxusers       32
 
@@ -53,6 +53,7 @@
 options        USERCONF        # userconf(4) support
 #options       PIPE_SOCKETPAIR # smaller, but slower pipe(2)
 options        SYSCTL_INCLUDE_DESCR    # Include sysctl descriptions in kernel
+options        RDB_PART        # Rigid Disk Block partition support
 
 # Diagnostic/debugging support options
 #options       DIAGNOSTIC      # cheap kernel consistency checks
diff -r 29fbcf148aa1 -r d514f436db5b sys/arch/ofppc/conf/files.ofppc
--- a/sys/arch/ofppc/conf/files.ofppc   Fri Dec 31 18:26:25 2010 +0000
+++ b/sys/arch/ofppc/conf/files.ofppc   Fri Dec 31 21:50:27 2010 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.ofppc,v 1.43 2010/06/09 04:44:01 kiyohara Exp $
+#      $NetBSD: files.ofppc,v 1.44 2010/12/31 21:50:27 phx Exp $
 #
 # NetBSD/ofppc configuration info
 #
@@ -8,17 +8,19 @@
 
 maxusers 8 16 64
 
-defflag        akbd.h NO_AKDB_DEVICE
-defflag adbkbd.h NO_ADBKBD_DEVICE
-defflag zsc.h NO_ZSC_DEVICE
-defflag adb.h NO_ADB_DEVICE
-defflag ukbd.h NO_UKBD_DEVICE
-defflag zstty.h NO_ZSTTY_DEVICE
-defflag ofb.h NO_OFB_DEVICE
+defflag        akbd.h          NO_AKDB_DEVICE
+defflag adbkbd.h       NO_ADBKBD_DEVICE
+defflag zsc.h          NO_ZSC_DEVICE
+defflag adb.h          NO_ADB_DEVICE
+defflag ukbd.h         NO_UKBD_DEVICE
+defflag zstty.h                NO_ZSTTY_DEVICE
+defflag ofb.h          NO_OFB_DEVICE
+
+defflag opt_disksubr.h RDB_PART
 
 file   arch/powerpc/oea/ofw_autoconf.c
 file   arch/powerpc/powerpc/clock.c
-file   kern/subr_disk_mbr.c                    disk
+file   arch/ofppc/ofppc/disksubr.c             disk
 file   arch/powerpc/oea/ofwoea_machdep.c
 file   arch/powerpc/oea/ofw_consinit.c
 file   arch/powerpc/oea/ofw_rascons.c
diff -r 29fbcf148aa1 -r d514f436db5b sys/arch/ofppc/include/disklabel.h
--- a/sys/arch/ofppc/include/disklabel.h        Fri Dec 31 18:26:25 2010 +0000
+++ b/sys/arch/ofppc/include/disklabel.h        Fri Dec 31 21:50:27 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: disklabel.h,v 1.8 2009/11/23 13:40:10 pooka Exp $      */
+/*     $NetBSD: disklabel.h,v 1.9 2010/12/31 21:50:28 phx Exp $        */
 
 /*-
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -30,27 +30,33 @@
  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
-
-#ifndef        _MACHINE_DISKLABEL_H_
-#define        _MACHINE_DISKLABEL_H_
+#ifndef _MACHINE_DISKLABEL_H_
+#define _MACHINE_DISKLABEL_H_
 
-#define        LABELSECTOR     1               /* sector containing label */
-#define        LABELOFFSET     0               /* offset of label in sector */
-#define        MAXPARTITIONS   16              /* number of partitions */
-#define        RAW_PART        2               /* raw partition: XX?c */
+#define        LABELSECTOR     0                       /* sector containing label */
+#define        LABELOFFSET     64                      /* offset of label in sector */
+#define MBR_LABELSECTOR 1                      /* label sector in MBR */
+#define MBR_LABELOFFSET 0                      /* label offset in MBR */
+#define        MAXPARTITIONS   16                      /* number of partitions */
+#define        RAW_PART        2                       /* raw partition: xx?c */
 
 #if HAVE_NBTOOL_CONFIG_H
-#include <nbinclude/sys/bootblock.h> /* Pull in MBR partition definitions. */
-#include <nbinclude/sys/dkbad.h>
+#include <nbinclude/sys/bootblock.h>           /* MBR partition definitions */
+#include <nbinclude/sys/disklabel_rdb.h>       /* RDB partition definitions */
 #else
-#include <sys/bootblock.h> /* Pull in MBR partition definitions. */
-#include <sys/dkbad.h>
+#include <sys/bootblock.h>                     /* MBR partition definitions */
+#include <sys/disklabel_rdb.h>                 /* RDB partition definitions */
 #endif /* HAVE_NBTOOL_CONFIG_H */
 
 struct cpu_disklabel {
-       struct mbr_partition dosparts[MBR_PART_COUNT];
-#define __HAVE_DISKLABEL_DKBAD
-       struct dkbad bad;
+       daddr_t cd_start;       /* Offset to NetBSD partition in blocks */
+       daddr_t cd_labelsector; /* label sector offset from cd_start */   
+       int cd_labeloffset;     /* label byte offset within label sector */
+
+       u_long rdblock;                 /* may be RDBNULL which invalidates */
+       u_long pblist[MAXPARTITIONS];   /* partblock number (RDB list order) */
+       int pbindex[MAXPARTITIONS];     /* index of pblock (partition order) */
+       int valid;                      /* essential that this is valid */
 };
 
-#endif /* _MACHINE_DISKLABEL_H_ */
+#endif /* _MACHINE_DISKLABEL_H_ */
diff -r 29fbcf148aa1 -r d514f436db5b sys/arch/ofppc/ofppc/disksubr.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/ofppc/ofppc/disksubr.c   Fri Dec 31 21:50:27 2010 +0000
@@ -0,0 +1,893 @@
+/*     $NetBSD: disksubr.c,v 1.22 2010/12/31 21:50:28 phx Exp $        */
+
+/*-
+ * Copyright (c) 2010 Frank Wille.
+ * All rights reserved.
+ *
+ * Written by Frank Wille for The NetBSD Project.
+ *
+ * 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 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) 1994 Christian E. Hopps
+ *
+ * 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.
+ *
+ *     @(#)ufs_disksubr.c      7.16 (Berkeley) 5/4/91
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.22 2010/12/31 21:50:28 phx Exp $");
+
+#include "opt_disksubr.h"
+
+#include <sys/buf.h>
+#include <sys/disklabel.h>
+#include <sys/bswap.h>
+
+/*
+ * In /usr/src/sys/dev/scsipi/sd.c, routine sdstart() adjusts the
+ * block numbers, it changes from DEV_BSIZE units to physical units:
+ * blkno = bp->b_blkno / (lp->d_secsize / DEV_BSIZE);
+ * As long as media with sector sizes of 512 bytes are used, this
+ * doesn't matter (divide by 1), but for successful usage of media with
+ * greater sector sizes (e.g. 640MB MO-media with 2048 bytes/sector)
+ * we must multiply block numbers with (lp->d_secsize / DEV_BSIZE)
+ * to keep "unchanged" physical block numbers.
+ */
+#define SD_C_ADJUSTS_NR
+
+#define baddr(bp) (void *)((bp)->b_data)
+
+static const char *read_dos_label(dev_t, void (*)(struct buf *),
+    struct disklabel *, struct cpu_disklabel *);
+static int getFreeLabelEntry(struct disklabel *);
+static int read_netbsd_label(dev_t, void (*)(struct buf *), struct disklabel *,
+    struct cpu_disklabel *);
+#ifdef RDB_PART
+static const char *read_rdb_label(dev_t, void (*)(struct buf *),
+    struct disklabel *, struct cpu_disklabel *);
+static u_long rdbchksum(void *);
+static struct adostype getadostype(u_long);
+#endif
+
+/*
+ * Read MBR partition table.
+ *
+ * XXX -
+ * Since FFS is endian sensitive, we pay no effort in attempting to
+ * dig up *BSD/i386 disk labels that may be present on the disk.
+ * Hence anything but DOS partitions is treated as unknown FS type, but
+ * this should suffice to mount_msdos Zip and other removable media.
+ */
+static const char *
+read_dos_label(dev_t dev, void (*strat)(struct buf *), struct disklabel *lp,
+    struct cpu_disklabel *osdep)
+{
+       struct buf *bp;
+       struct mbr_partition *bsdp, *dp;
+       const char *msg = NULL;
+       int i, slot, maxslot = 0;
+       u_int32_t bsdpartoff;
+
+       /* get a buffer and initialize it */
+       bp = geteblk((int)lp->d_secsize);
+       bp->b_dev = dev;
+
+       /* read master boot record */
+       bp->b_blkno = MBR_BBSECTOR;
+       bp->b_bcount = lp->d_secsize;
+       bp->b_flags |= B_READ;
+       bp->b_cylinder = MBR_BBSECTOR / lp->d_secpercyl;
+       (*strat)(bp);
+
+       bsdpartoff = 0;
+
+       /* if successful, wander through dos partition table */
+       if (biowait(bp)) {
+               msg = "dos partition I/O error";
+               goto done;
+       }
+       /* XXX */
+       dp = (struct mbr_partition *)((char *)bp->b_data + MBR_PART_OFFSET);
+       bsdp = NULL;
+       for (i = 0; i < MBR_PART_COUNT; i++, dp++) {
+               switch (dp->mbrp_type) {
+               case MBR_PTYPE_NETBSD:
+                       bsdp = dp;
+                       break;
+               case MBR_PTYPE_OPENBSD:
+               case MBR_PTYPE_386BSD:
+                       if (!bsdp)
+                               bsdp = dp;
+                       break;



Home | Main Index | Thread Index | Old Index