Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/sommerfeld_i386mp_1]: src/sys/arch/i386/stand sweep of errx/warnx, remov...
details: https://anonhg.NetBSD.org/src/rev/d02300b60b2b
branches: sommerfeld_i386mp_1
changeset: 482567:d02300b60b2b
user: grant <grant%NetBSD.org@localhost>
date: Sat Jul 20 08:36:19 2002 +0000
description:
sweep of errx/warnx, remove unnecessary trailing \n
diffstat:
sys/arch/i386/stand/genprom/genprom.c | 69 +++
sys/arch/i386/stand/installboot/installboot.c | 590 ++++++++++++++++++++++++++
2 files changed, 659 insertions(+), 0 deletions(-)
diffs (truncated from 667 to 300 lines):
diff -r af5f5026214a -r d02300b60b2b sys/arch/i386/stand/genprom/genprom.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/i386/stand/genprom/genprom.c Sat Jul 20 08:36:19 2002 +0000
@@ -0,0 +1,69 @@
+/* $NetBSD: genprom.c,v 1.4.2.2 2002/07/20 08:36:19 grant Exp $ */
+
+/*
+ * mainly from netbsd:sys/arch/i386/netboot/genprom.c
+ */
+
+/*
+ * Read a binary image of a bios extension, generate the
+ * appropriate block count and checksum and write them
+ * into the rom image (replacing 2nd and 5th bytes)
+ * The binary image should be sized before being filtered
+ * through this routine.
+ */
+
+#include <stdio.h>
+#include <err.h>
+#include <string.h>
+
+#define PROM_SIZE 0x10000 /* max */
+
+int
+main(argc, argv)
+ int argc;
+ char **argv;
+{
+ char w[PROM_SIZE];
+ int i, sum;
+ int romsize;
+ unsigned short ck16;
+
+ if (argc > 1) {
+ if (sscanf(argv[1], "%d", &romsize) != 1) {
+ errx(1, "bad arg");
+ }
+ } else {
+ errx(1, "arg: romsize / bytes");
+ }
+
+ memset(w, 0x0, PROM_SIZE);
+ i = fread(w, 1, PROM_SIZE, stdin);
+
+ fprintf(stderr, "bios extension size: %d (0x%x), read %d bytes\n",
+ romsize, romsize, i);
+
+ if (i > romsize)
+ errx(1, "read longer than expected");
+
+ w[2] = romsize / 512; /* BIOS extension size */
+
+ i = w[0x18] + (w[0x19] << 8); /* if this is a PCI ROM, this is the
+ * offset to the "PCI data structure" */
+ if ((i < romsize - 0x18) && (w[i] == 'P') && (w[i + 1] == 'C')
+ && (w[i + 2] == 'I') && (w[i + 3] == 'R')) {
+ fprintf(stderr, "PCI Data Structure found\n");
+ w[i + 0x10] = romsize / 512; /* BIOS extension size again */
+ }
+ for (sum = 0, i = 0; i < romsize; i++) {
+ sum += w[i];
+ }
+ w[5] = -sum; /* left free for checksum adjustment */
+
+ /* calculate CRC as used by PROM programmers */
+ for (ck16 = 0, i = 0; i < romsize; i++)
+ ck16 += (unsigned char) w[i];
+ fprintf(stderr, "ROM CRC: 0x%04x\n", ck16);
+
+ fwrite(w, 1, romsize, stdout);
+ return (0);
+}
diff -r af5f5026214a -r d02300b60b2b sys/arch/i386/stand/installboot/installboot.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/i386/stand/installboot/installboot.c Sat Jul 20 08:36:19 2002 +0000
@@ -0,0 +1,590 @@
+/* $NetBSD: installboot.c,v 1.16.2.2 2002/07/20 08:36:19 grant Exp $ */
+
+/*
+ * Copyright (c) 1994 Paul Kranenburg
+ * All rights reserved.
+ * Copyright (c) 1996, 1997
+ * Matthias Drochner. All rights reserved.
+ * Copyright (c) 1996, 1997
+ * Perry E. Metzger. 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.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Paul Kranenburg.
+ * This product includes software developed for the NetBSD Project
+ * by Matthias Drochner.
+ * This product includes software developed for the NetBSD Project
+ * by Perry E. Metzger.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission
+ *
+ * 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 <sys/param.h>
+#include <sys/disklabel.h>
+#include <sys/dkio.h>
+#include <ufs/ufs/dinode.h>
+#include <ufs/ufs/dir.h>
+#include <ufs/ffs/fs.h>
+#include <err.h>
+#include <a.out.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <nlist.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <md5.h>
+#include <sys/ioctl.h>
+
+#include "loadfile.h"
+#include "installboot.h"
+
+#include "bbinfo.h"
+
+#define DEFBBLKNAME "boot"
+
+char *loadprotoblocks __P((char *, size_t *));
+static int devread __P((int, void *, daddr_t, size_t, char *));
+static int add_fsblk __P((struct fs *, daddr_t, int));
+int setup_ffs_blks __P((char *, ino_t));
+int setup_contig_blocks __P((char *, int, char *, unsigned int));
+int save_contig_sec_boot __P((char *, int, char *, unsigned int));
+ino_t save_ffs __P((char *, char *, char *, unsigned int));
+ino_t save_passthru __P((char *, char *, char *, unsigned int));
+static void usage __P((void));
+int main __P((int, char **));
+
+struct fraglist *fraglist;
+
+struct nlist nl[] = {
+#define X_fraglist 0
+#define X_boottimeout 1
+#define X_bootpasswd 2
+#ifdef __ELF__
+ {{"fraglist"}},
+ {{"boottimeout"}},
+ {{"bootpasswd"}},
+#else
+ {{"_fraglist"}},
+ {{"_boottimeout"}},
+ {{"_bootpasswd"}},
+#endif
+ {{NULL}}
+};
+
+int verbose = 0;
+int conblockmode, conblockstart;
+
+
+char *
+loadprotoblocks(fname, size)
+ char *fname;
+ size_t *size;
+{
+ int fd;
+ u_long marks[MARK_MAX], bp;
+
+ fd = -1;
+
+ /* Locate block number array in proto file */
+ if (nlist(fname, nl) < 0) {
+ warn("nlist: %s", fname);
+ return NULL;
+ }
+
+ if (nl[X_fraglist].n_value == 0) {
+ /* fraglist is mandatory, other stuff is optional */
+ warnx("nlist: no fraglist");
+ return NULL;
+ }
+
+ marks[MARK_START] = 0;
+ if ((fd = loadfile(fname, marks, COUNT_TEXT|COUNT_DATA)) == -1)
+ return NULL;
+ (void)close(fd);
+
+ *size = roundup(marks[MARK_END], DEV_BSIZE);
+ bp = marks[MARK_START] = (u_long)malloc(*size);
+ if ((fd = loadfile(fname, marks, LOAD_TEXT|LOAD_DATA)) == -1)
+ return NULL;
+ (void)close(fd);
+
+ /* NOSTRICT */
+ fraglist = (struct fraglist *) (bp + nl[X_fraglist].n_value);
+
+ if (fraglist->magic != FRAGLISTMAGIC) {
+ warnx("invalid bootblock version");
+ goto bad;
+ }
+ if (verbose) {
+ (void) fprintf(stderr, "%s: entry point %#lx\n", fname,
+ marks[MARK_ENTRY]);
+ (void) fprintf(stderr, "proto bootblock size %ld\n",
+ (long)*size);
+ (void) fprintf(stderr, "room for %d filesystem blocks"
+ " at %#lx\n", fraglist->maxentries,
+ nl[X_fraglist].n_value);
+ }
+ return (char *) bp;
+bad:
+ if (bp)
+ free((void *)bp);
+ return NULL;
+}
+
+static int
+devread(fd, buf, blk, size, msg)
+ int fd;
+ void *buf;
+ daddr_t blk;
+ size_t size;
+ char *msg;
+{
+ if (lseek(fd, (off_t)dbtob(blk), SEEK_SET) != dbtob(blk)) {
+ warn("%s: devread: lseek", msg);
+ return (1);
+ }
+ if (read(fd, buf, size) != size) {
+ warn("%s: devread: read", msg);
+ return (1);
+ }
+ return (0);
+}
+
+/* add file system blocks to fraglist */
+static int
+add_fsblk(fs, blk, blcnt)
+ struct fs *fs;
+ daddr_t blk;
+ int blcnt;
+{
+ int nblk;
+
+ /* convert to disk blocks */
+ blk = fsbtodb(fs, blk);
+ nblk = fs->fs_bsize / DEV_BSIZE;
+ if (nblk > blcnt)
+ nblk = blcnt;
+
+ if (verbose)
+ (void) fprintf(stderr, "dblk: %d, num: %d\n", blk, nblk);
+
+ /* start new entry or append to previous? */
+ if (!fraglist->numentries ||
+ (fraglist->entries[fraglist->numentries - 1].offset
+ + fraglist->entries[fraglist->numentries - 1].num != blk)) {
+
+ /* need new entry */
+ if (fraglist->numentries > fraglist->maxentries - 1) {
+ errx(1, "not enough fragment space in bootcode");
+ return (-1);
+ }
+
+ fraglist->entries[fraglist->numentries].offset = blk;
+ fraglist->entries[fraglist->numentries++].num = 0;
+ }
+ fraglist->entries[fraglist->numentries - 1].num += nblk;
+
+ return (blcnt - nblk);
+}
+
+static union {
+ char c[SBSIZE];
+ struct fs s;
+} sblock;
+
+int
+setup_ffs_blks(diskdev, inode)
+ char *diskdev;
+ ino_t inode;
+{
+ int devfd = -1;
+ struct fs *fs;
+ char *buf = 0;
Home |
Main Index |
Thread Index |
Old Index