Source-Changes-HG archive

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

[src/trunk]: src bootblock.h:



details:   https://anonhg.NetBSD.org/src/rev/9f036478ddfd
branches:  trunk
changeset: 526980:9f036478ddfd
user:      lukem <lukem%NetBSD.org@localhost>
date:      Wed May 15 09:44:54 2002 +0000

description:
bootblock.h:
- unify sparc_bbinfo (1064 bytes, with 256 block entries)
  and sun68k_bbinfo (296 byte, with 64 block entries)
  into shared_bbinfo (512 bytes, with 118 block entries),
  which will be also shared by future bbinfo-using platforms
  (including macppc)
- add datestamp to *_BBINFO_MAGIC strings, to prevent installboot vs
  bootxx version skew.
- add macppc support

*/bootxx.c:
- migrate to new shared_bbinfo structure

installboot:
- add macppc support (still needs applepartmap support and testing)
- improve and add some more warnings & errors to installboot
- implement shared_bbinfo_clearboot() and shared_bbinfo_setboot(), which
  perform the majority of the work for bbinfo-using back-ends
  (rather than replicating that across multiple back-ends).

diffstat:

 sys/arch/sparc/stand/bootxx/bootxx.c  |    6 +-
 sys/arch/sun68k/stand/bootxx/bootxx.c |    6 +-
 sys/sys/bootblock.h                   |   57 ++++----
 usr.sbin/installboot/Makefile         |    6 +-
 usr.sbin/installboot/arch/sparc.c     |  221 ++++-----------------------------
 usr.sbin/installboot/arch/sun68k.c    |  198 ++----------------------------
 usr.sbin/installboot/ffs.c            |   16 +-
 usr.sbin/installboot/fstypes.c        |    4 +-
 usr.sbin/installboot/installboot.h    |   16 ++-
 usr.sbin/installboot/machines.c       |    3 +-
 10 files changed, 113 insertions(+), 420 deletions(-)

diffs (truncated from 801 to 300 lines):

diff -r 74cb9307746d -r 9f036478ddfd sys/arch/sparc/stand/bootxx/bootxx.c
--- a/sys/arch/sparc/stand/bootxx/bootxx.c      Wed May 15 08:53:42 2002 +0000
+++ b/sys/arch/sparc/stand/bootxx/bootxx.c      Wed May 15 09:44:54 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bootxx.c,v 1.10 2002/05/07 12:06:06 lukem Exp $ */
+/*     $NetBSD: bootxx.c,v 1.11 2002/05/15 09:44:54 lukem Exp $ */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -61,10 +61,10 @@
  * (typically `/boot'): filesystem block size, # of filesystem
  * blocks and the block numbers themselves.
  */
-struct sparc_bbinfo bbinfo = {
+struct shared_bbinfo bbinfo = {
        { SPARC_BBINFO_MAGIC },
        0,
-       SPARC_BBINFO_MAXBLOCKS,
+       SHARED_BBINFO_MAXBLOCKS,
        { 0 }
 };
 
diff -r 74cb9307746d -r 9f036478ddfd sys/arch/sun68k/stand/bootxx/bootxx.c
--- a/sys/arch/sun68k/stand/bootxx/bootxx.c     Wed May 15 08:53:42 2002 +0000
+++ b/sys/arch/sun68k/stand/bootxx/bootxx.c     Wed May 15 09:44:54 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bootxx.c,v 1.7 2002/05/15 04:07:42 lukem Exp $ */
+/*     $NetBSD: bootxx.c,v 1.8 2002/05/15 09:44:55 lukem Exp $ */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -64,10 +64,10 @@
  * (typically `/ufsboot'): filesystem block size, # of filesystem
  * blocks and the block numbers themselves.
  */
-struct sun68k_bbinfo bbinfo = {
+struct shared_bbinfo bbinfo = {
        { SUN68K_BBINFO_MAGIC },
        0,
-       SUN68K_BBINFO_MAXBLOCKS,
+       SHARED_BBINFO_MAXBLOCKS,
        { 0 }
 };
 
diff -r 74cb9307746d -r 9f036478ddfd sys/sys/bootblock.h
--- a/sys/sys/bootblock.h       Wed May 15 08:53:42 2002 +0000
+++ b/sys/sys/bootblock.h       Wed May 15 09:44:54 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bootblock.h,v 1.4 2002/05/14 06:34:21 lukem Exp $      */
+/*     $NetBSD: bootblock.h,v 1.5 2002/05/15 09:44:55 lukem Exp $      */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -74,6 +74,23 @@
 #endif
 
 /*
+ * shared --
+ *     definintions shared by many platforms
+ */
+
+       /* Maximum # of blocks in bbi_block_table, each bbi_block_size long */
+#define        SHARED_BBINFO_MAXBLOCKS 118     /* so sizeof(shared_bbinfo) == 512 */
+
+struct shared_bbinfo {
+       uint8_t bbi_magic[32];
+       int32_t bbi_block_size;
+       int32_t bbi_block_count;
+       int32_t bbi_block_table[SHARED_BBINFO_MAXBLOCKS];
+};
+
+
+
+/*
  * alpha --
  *     Alpha (disk, but also tape) Boot Block.
  * 
@@ -112,6 +129,16 @@
 
 
 /*
+ * macppc
+ */
+
+#define MACPPC_BOOT_BLOCK_OFFSET       2048
+#define MACPPC_BOOT_BLOCK_BLOCKSIZE    512
+#define MACPPC_BOOT_BLOCK_MAX_SIZE     (512 * 12)
+       /* Magic string -- 32 bytes long (including the NUL) */
+#define        MACPPC_BBINFO_MAGIC             "NetBSD/macppc bootxx   20020515"
+
+/*
  * pmax --
  *     PMAX (DECstation / MIPS) boot block information
  */
@@ -156,20 +183,8 @@
 #define SPARC_BOOT_BLOCK_OFFSET                512
 #define SPARC_BOOT_BLOCK_BLOCKSIZE     512
 #define SPARC_BOOT_BLOCK_MAX_SIZE      (512 * 15)
-
-       /* Maximum # of blocks in bbi_block_table, each bbi_block_size long */
-#define        SPARC_BBINFO_MAXBLOCKS          256
-
        /* Magic string -- 32 bytes long (including the NUL) */
-#define        SPARC_BBINFO_MAGIC              "NetBSD/sparc bootxx            "
-#define        SPARC_BBINFO_MAGICSIZE          sizeof(SPARC_BBINFO_MAGIC)
-
-struct sparc_bbinfo {
-       uint8_t bbi_magic[SPARC_BBINFO_MAGICSIZE];
-       int32_t bbi_block_size;
-       int32_t bbi_block_count;
-       int32_t bbi_block_table[SPARC_BBINFO_MAXBLOCKS];
-};
+#define        SPARC_BBINFO_MAGIC              "NetBSD/sparc bootxx    20020515"
 
 
 /*
@@ -188,20 +203,8 @@
 #define SUN68K_BOOT_BLOCK_OFFSET       512
 #define SUN68K_BOOT_BLOCK_BLOCKSIZE    512
 #define SUN68K_BOOT_BLOCK_MAX_SIZE     (512 * 15)
-
-       /* Maximum # of blocks in bbi_block_table, each bbi_block_size long */
-#define        SUN68K_BBINFO_MAXBLOCKS         64
-
        /* Magic string -- 32 bytes long (including the NUL) */
-#define        SUN68K_BBINFO_MAGIC             "NetBSD/sun68k bootxx           "
-#define        SUN68K_BBINFO_MAGICSIZE         sizeof(SUN68K_BBINFO_MAGIC)
-
-struct sun68k_bbinfo {
-       uint8_t bbi_magic[SUN68K_BBINFO_MAGICSIZE];
-       int32_t bbi_block_size;
-       int32_t bbi_block_count;
-       int32_t bbi_block_table[SUN68K_BBINFO_MAXBLOCKS];
-};
+#define        SUN68K_BBINFO_MAGIC             "NetBSD/sun68k bootxx   20020515"
 
 
 /*
diff -r 74cb9307746d -r 9f036478ddfd usr.sbin/installboot/Makefile
--- a/usr.sbin/installboot/Makefile     Wed May 15 08:53:42 2002 +0000
+++ b/usr.sbin/installboot/Makefile     Wed May 15 09:44:54 2002 +0000
@@ -1,12 +1,12 @@
-#      $NetBSD: Makefile,v 1.18 2002/05/06 16:24:45 pk Exp $
+#      $NetBSD: Makefile,v 1.19 2002/05/15 09:44:55 lukem Exp $
 #
 
 .include <bsd.own.mk>
 
 PROG=  installboot
 SRCS=  installboot.c sum.c machines.c fstypes.c \
-       ffs.c ffs_bswap.c \
-       alpha.c pmax.c sparc.c sparc64.c sun68k.c vax.c
+       ffs.c ffs_bswap.c bbinfo.c \
+       alpha.c macppc.c pmax.c sparc.c sparc64.c sun68k.c vax.c
 MAN=   installboot.8
 
 WARNS?=        3
diff -r 74cb9307746d -r 9f036478ddfd usr.sbin/installboot/arch/sparc.c
--- a/usr.sbin/installboot/arch/sparc.c Wed May 15 08:53:42 2002 +0000
+++ b/usr.sbin/installboot/arch/sparc.c Wed May 15 09:44:54 2002 +0000
@@ -1,11 +1,11 @@
-/*     $NetBSD: sparc.c,v 1.4 2002/05/15 02:18:23 lukem Exp $ */
+/*     $NetBSD: sparc.c,v 1.5 2002/05/15 09:44:55 lukem Exp $ */
 
 /*-
  * Copyright (c) 1998, 2002 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
- * by Matt Fredette, Paul Kranenburg, and Luke Mewburn.
+ * by Paul Kranenburg and Luke Mewburn.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -38,7 +38,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(__lint)
-__RCSID("$NetBSD: sparc.c,v 1.4 2002/05/15 02:18:23 lukem Exp $");
+__RCSID("$NetBSD: sparc.c,v 1.5 2002/05/15 09:44:55 lukem Exp $");
 #endif /* !__lint */
 
 #if HAVE_CONFIG_H
@@ -57,182 +57,36 @@
 
 #include "installboot.h"
 
+static struct bbinfo_params bbparams = {
+       SPARC_BBINFO_MAGIC,
+       SPARC_BOOT_BLOCK_OFFSET,
+       SPARC_BOOT_BLOCK_BLOCKSIZE,
+       SPARC_BOOT_BLOCK_MAX_SIZE,
+       32,                     /* leave room for a.out header */
+       0,
+};
+
 int
 sparc_clearboot(ib_params *params)
 {
-       char    bb[SPARC_BOOT_BLOCK_MAX_SIZE];
-       ssize_t rv;
 
        assert(params != NULL);
-       assert(params->fsfd != -1);
-       assert(params->filesystem != NULL);
 
-       if (params->flags & IB_STAGE2START) {
-               warnx("Can't use `-B bno' with `-c'");
-               return (0);
-       }
        if (params->flags & IB_STAGE1START) {
                warnx("`-b bno' is not supported for %s",
                    params->machine->name);
                return (0);
        }
-
-       /* first check that it _could_ exist here */
-       rv = pread(params->fsfd, &bb, sizeof(bb), SPARC_BOOT_BLOCK_OFFSET);
-       if (rv == -1) {
-               warn("Reading `%s'", params->filesystem);
-               return (0);
-       } else if (rv != sizeof(bb)) {
-               warnx("Reading `%s': short read", params->filesystem);
-               return (0);
-       }
-
-       /* now clear it out to nothing */
-       memset(&bb, 0, sizeof(bb));
-
-       if (params->flags & IB_VERBOSE)
-               printf("%slearing boot block\n",
-                   (params->flags & IB_NOWRITE) ? "Not c" : "C");
-       if (params->flags & IB_NOWRITE)
-               return (1);
-
-       rv = pwrite(params->fsfd, &bb, sizeof(bb), SPARC_BOOT_BLOCK_OFFSET);
-       if (rv == -1) {
-               warn("Writing `%s'", params->filesystem);
-               return (0);
-       } else if (rv != sizeof(bb)) {
-               warnx("Writing `%s': short write", params->filesystem);
-               return (0);
-       }
-
-       return (1);
+       return (shared_bbinfo_clearboot(params, &bbparams));
 }
 
-int
-sparc_setboot(ib_params *params)
+static int
+sparc_frobheader(ib_params *params, struct bbinfo_params *bb_params, char *bb)
 {
-       char            bb[SPARC_BOOT_BLOCK_MAX_SIZE];
-       int             retval;
-       ssize_t         rv;
-       size_t          bbi;
-       struct sparc_bbinfo     *bbinfop;       /* bbinfo in prototype image */
-       uint32_t        maxblk, nblk, blk_i;
-       ib_block        *blocks;
 
        assert(params != NULL);
-       assert(params->fsfd != -1);
-       assert(params->filesystem != NULL);
-       assert(params->fstype != NULL);
-       assert(params->s1fd != -1);
-       assert(params->stage1 != NULL);
-       assert(SPARC_BBINFO_MAGICSIZE == 32);
-
-#define        SPARC_AOUT_OFFSET       32
-
-       retval = 0;
-       blocks = NULL;
-
-       if (params->stage2 == NULL) {
-               warnx("You must provide the name of the secondary bootstrap");
-               goto done;
-       }
-       if (params->flags & IB_STAGE1START) {
-               warnx("`-b bno' is not supported for %s",
-                   params->machine->name);
-               goto done;
-       }
-
-       if (!S_ISREG(params->s1stat.st_mode)) {
-               warnx("`%s' must be a regular file", params->stage1);
-               goto done;
-       }
-       if (params->s1stat.st_size > sizeof(bb)) {
-               warnx("`%s' cannot be larger than %lu bytes",
-                   params->stage1, (unsigned long)sizeof(bb));
-               goto done;
-       }
-
-       /*
-        * Read 1st stage boot program
-        * Leave room for a 32-byte a.out header.
-        */
-       memset(&bb, 0, sizeof(bb));
-       rv = read(params->s1fd, bb + SPARC_AOUT_OFFSET,



Home | Main Index | Thread Index | Old Index