fix ultrasparc support.

This commit is contained in:
mrg 2000-08-20 14:56:28 +00:00
parent b74059e5cf
commit 9bea0e1a52
2 changed files with 21 additions and 13 deletions

View File

@ -1,5 +1,5 @@
#!/bin/sh #!/bin/sh
# $NetBSD: binstall.sh,v 1.6 2000/08/10 13:34:39 mrg Exp $ # $NetBSD: binstall.sh,v 1.7 2000/08/20 14:56:28 mrg Exp $
# #
vecho () { vecho () {
@ -11,7 +11,7 @@ vecho () {
} }
Usage () { Usage () {
echo "Usage: $0 [-hvt] [-m<path>] net|ffs directory" echo "Usage: $0 [-hvtuU] [-m<path>] net|ffs directory"
exit 1 exit 1
} }
@ -25,6 +25,7 @@ Help () {
echo "Options:" echo "Options:"
echo " -h - display this message" echo " -h - display this message"
echo " -u - install sparc64 (UltraSPARC) boot block" echo " -u - install sparc64 (UltraSPARC) boot block"
echo " -U - install sparc boot block"
echo " -b<bootprog> - second-stage boot program to install" echo " -b<bootprog> - second-stage boot program to install"
echo " -m<path> - Look for boot programs in <path> (default: /usr/mdec)" echo " -m<path> - Look for boot programs in <path> (default: /usr/mdec)"
echo " -v - verbose mode" echo " -v - verbose mode"
@ -42,7 +43,7 @@ PATH=/bin:/usr/bin:/sbin:/usr/sbin
MDEC=${MDEC:-/usr/mdec} MDEC=${MDEC:-/usr/mdec}
BOOTPROG=${BOOTPROG:-boot} BOOTPROG=${BOOTPROG:-boot}
OFWBOOT=${OFWBOOTBLK:-ofwboot} OFWBOOT=${OFWBOOTBLK:-ofwboot}
if [ "`uname -m`" = sparc64 ]; then if [ "`sysctl -n hw.machine`" = sparc64 ]; then
ULTRASPARC=1 ULTRASPARC=1
else else
ULTRASPARC=0 ULTRASPARC=0
@ -52,7 +53,7 @@ if [ "`sysctl -n kern.securelevel`" -gt 0 ]; then
Secure Secure
fi fi
set -- `getopt "b:hm:tv" "$@"` set -- `getopt "b:hm:tvuU" "$@"`
if [ $? -gt 0 ]; then if [ $? -gt 0 ]; then
Usage Usage
fi fi
@ -62,9 +63,9 @@ do
case $1 in case $1 in
-h) Help; shift ;; -h) Help; shift ;;
-u) ULTRASPARC=1; shift ;; -u) ULTRASPARC=1; shift ;;
-U) ULTRASPARC=0; shift ;;
-b) BOOTPROG=$2; OFWBOOT=$2; shift 2 ;; -b) BOOTPROG=$2; OFWBOOT=$2; shift 2 ;;
-m) MDEC=$2; shift 2 ;; -m) MDEC=$2; shift 2 ;;
-o) OFWBOOT=$2; shift 2 ;;
-t) TEST=1; VERBOSE=1; shift ;; -t) TEST=1; VERBOSE=1; shift ;;
-v) VERBOSE=1; shift ;; -v) VERBOSE=1; shift ;;
--) shift; break ;; --) shift; break ;;

View File

@ -1,4 +1,4 @@
/* $NetBSD: installboot.c,v 1.6 2000/08/10 13:29:40 mrg Exp $ */ /* $NetBSD: installboot.c,v 1.7 2000/08/20 14:56:30 mrg Exp $ */
/*- /*-
* Copyright (c) 1998 The NetBSD Foundation, Inc. * Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -85,7 +85,7 @@ int32_t *block_count_p; /* size of this array */
int32_t *block_size_p; /* filesystem block size */ int32_t *block_size_p; /* filesystem block size */
int32_t max_block_count; int32_t max_block_count;
char *loadprotoblocks __P((char *, long *)); char *loadprotoblocks __P((char *, size_t *));
int loadblocknums __P((char *, int)); int loadblocknums __P((char *, int));
static void devread __P((int, void *, daddr_t, size_t, char *)); static void devread __P((int, void *, daddr_t, size_t, char *));
static void usage __P((void)); static void usage __P((void));
@ -117,7 +117,7 @@ main(argc, argv)
int c; int c;
int devfd; int devfd;
char *protostore; char *protostore;
long protosize; size_t protosize;
struct utsname utsname; struct utsname utsname;
/* /*
@ -194,17 +194,24 @@ main(argc, argv)
} else { } else {
struct stat sb; struct stat sb;
int protofd; int protofd;
size_t blanklen;
if ((protofd = open(dev, O_RDONLY)) < 0) if ((protofd = open(proto, O_RDONLY)) < 0)
err(1, "open: %s", proto); err(1, "open: %s", proto);
if (fstat(protofd, &sb) < 0) if (fstat(protofd, &sb) < 0)
err(1, "fstat: %s", proto); err(1, "fstat: %s", proto);
protosize = sb.st_size; /* there must be a better way */
if ((protostore = mmap(0, (size_t)protosize, PROT_READ, blanklen = DEV_BSIZE - ((sb.st_size + DEV_BSIZE) & (DEV_BSIZE - 1));
MAP_SHARED, protofd, 0)) == MAP_FAILED) protosize = sb.st_size + blanklen;
if ((protostore = mmap(0, (size_t)protosize,
PROT_READ|PROT_WRITE, MAP_PRIVATE,
protofd, 0)) == MAP_FAILED)
err(1, "mmap: %s", proto); err(1, "mmap: %s", proto);
/* and provide the rest of the block */
if (blanklen)
memset(protostore + sb.st_size, 0, blanklen);
} }
if (nowrite) if (nowrite)
@ -232,7 +239,7 @@ main(argc, argv)
char * char *
loadprotoblocks(fname, size) loadprotoblocks(fname, size)
char *fname; char *fname;
long *size; size_t *size;
{ {
int fd, sz; int fd, sz;
u_long ap, bp, st, en; u_long ap, bp, st, en;