all: ${KERNLIB} ${SALIB} _SUBDIRUSE
libdep:
- @echo ${.OBJDIR}/${KERNLIB} ${.OBJDIR}/${SALIB}
+ @echo ${KERNLIB} ${.OBJDIR}/${SALIB}
sadep:
@echo ${.OBJDIR}/${SALIB}
kernlibdir:
- @echo ${.OBJDIR}/${KERNDST}
+ @echo ${KERNDST}
salibdir:
@echo ${.OBJDIR}/${SADST}
BINDIR=/usr/mdec
afterinstall:
- install -c -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
+ ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
${.CURDIR}/binstall.sh ${DESTDIR}${BINDIR}/binstall
.include <bsd.subdir.mk>
#!/bin/sh
-# $OpenBSD: binstall.sh,v 1.4 1996/08/11 09:13:21 downsj Exp $
+# $OpenBSD: binstall.sh,v 1.5 1996/12/12 08:42:44 deraadt Exp $
# $NetBSD: binstall.sh,v 1.3 1996/04/07 20:00:12 thorpej Exp $
#
WHAT=$1
DEST=$2
-if [ "`sysctl -n hw.model | cut -b1-5`" = "SUN-4" ]; then
- KARCH=sun4
-else
- KARCH=sun4c
-fi
-vecho "Kernel architecture: $KARCH"
-
if [ ! -d $DEST ]; then
echo "$DEST: not a directory"
Usage
fi
-if [ $KARCH = sun4 ]; then SKIP=1; else SKIP=0; fi
-
+SKIP=0
case $WHAT in
"ffs")
TARGET=$DEST/boot
vecho Boot device: $DEV
vecho Target: $TARGET
- $DOIT dd if=${MDEC}/boot of=$TARGET skip=$SKIP bs=32
+ $DOIT dd if=${MDEC}/boot of=$TARGET bs=32 skip=$SKIP
sync; sync; sync
vecho installboot ${VERBOSE:+-v} $TARGET ${MDEC}/bootxx $DEV
$DOIT installboot ${VERBOSE:+-v} $TARGET ${MDEC}/bootxx $DEV
;;
"net")
- TARGET=$DEST/boot.sparc.openbsd.$KARCH
+ TARGET=$DEST/boot.sparc.openbsd
+ TMP=/tmp/boot.$$
vecho Target: $TARGET
- $DOIT dd if=${MDEC}/boot of=$TARGET skip=$SKIP bs=32
+ vecho Copying to temporary file.
+ cp ${MDEC}/boot $TMP; chmod +w $TMP
+ vecho Stripping $TMP
+ strip $TMP
+ vecho Creating header magic.
+ printf '\01\03\01\07\060\200\0\07' | dd of=$TARGET bs=32 conv=sync
+ vecho Concatenating boot code.
+ dd if=$TMP of=$TARGET bs=32 skip=1 seek=1
+ rm $TMP
;;
*)
.Sh SYNOPSIS
.Nm installboot
.Op Fl nvh
+.Op Fl a Ar karch
.Ar boot
.Ar bootxx
.Ar device
.Pa /usr/mdec/binstall
can be used to properly copy the a second-stage bootprogram to its
destination. This script takes care of post-processing that is required
-on non-
-.Tn Openboot
+on
+.Pf non- Tn Openboot
machines.
.Pp
The options are as follows:
.Bl -tag -width flag
-.It Fl n
-Do not actually write anything on the disk.
-.It Fl v
-Verbose mode.
-.It Fl h
-Leave the
-.Xr a.out 5
-header on the installed
-.Ar bootxx
-program.
+.It Fl a Ar karch
+Set the machine architecture. The argument
+.Ar karch
+can be one of
+.Dq sun4 ,
+.Dq sun4c
+or
+.Dq sun4m .
Sun 4c models with
.Tn Openboot
PROMs need the header to be present, while Sun 4 systems with the
interface require the header to be stripped off. This is normally taken
care of by
.Nm
-automatically.
+automatically, but it's useful when preparing a bootable filesystem for
+another system.
+.It Fl h
+Leave the
+.Xr a.out 5
+header on the installed
+.Ar bootxx
+program. This option has been superseded by the
+.Fl a Ar karch
+option.
+.It Fl n
+Do not actually write anything on the disk.
+.It Fl v
+Verbose mode.
.El
.Pp
The arguments are:
int32_t *block_size_p; /* filesystem block size */
int32_t max_block_count;
+char *karch;
char cpumodel[100];
usage()
{
fprintf(stderr,
- "usage: installboot [-n] [-v] [-h] <boot> <proto> <device>\n");
+ "usage: installboot [-n] [-v] [-h] [-a <karch>] <boot> <proto> <device>\n");
exit(1);
}
int mib[2];
size_t size;
- while ((c = getopt(argc, argv, "vnh")) != EOF) {
+ while ((c = getopt(argc, argv, "a:vnh")) != EOF) {
switch (c) {
- case 'h':
+ case 'a':
+ karch = optarg;
+ break;
+ case 'h': /* Note: for backwards compatibility */
/* Don't strip a.out header */
hflag = 1;
break;
proto = argv[optind + 1];
dev = argv[optind + 2];
+ if (karch == NULL) {
+ mib[0] = CTL_HW;
+ mib[1] = HW_MODEL;
+ size = sizeof(cpumodel);
+ if (sysctl(mib, 2, cpumodel, &size, NULL, 0) == -1)
+ err(1, "sysctl");
+
+ if (size < 5 || strncmp(cpumodel, "SUN-4", 5) != 0) /*XXX*/
+ /* Assume a sun4c/sun4m */
+ karch = "sun4c";
+ else
+ karch = "sun4";
+ }
+
if (verbose) {
printf("boot: %s\n", boot);
printf("proto: %s\n", proto);
printf("device: %s\n", dev);
+ printf("architecture: %s\n", karch);
}
- mib[0] = CTL_HW;
- mib[1] = HW_MODEL;
- size = sizeof(cpumodel);
- if (sysctl(mib, 2, cpumodel, &size, NULL, 0) == -1)
- err(1, "sysctl");
-
- if (size < 5 || strncmp(cpumodel, "SUN-4", 5) != 0) /*XXX*/
- /* Assume a sun4c/sun4m */
+ if (strcmp(karch, "sun4") == 0) {
+ hflag = 1;
+ } else if (strcmp(karch, "sun4c") == 0) {
hflag = 1;
+ } else if (strcmp(karch, "sun4m") == 0) {
+ hflag = 1;
+ } else
+ errx(1, "Unsupported architecture");
/* Load proto blocks into core */
if ((protostore = loadprotoblocks(proto, &protosize)) == NULL)
max_block_count, nl[X_BLOCKTABLE].n_value);
}
+ /*
+ * We convert the a.out header in-vitro into something that
+ * Sun PROMs understand.
+ * Old-style (sun4) ROMs do not expect a header at all, so
+ * we turn the first two words into code that gets us past
+ * the 32-byte header where the actual code begins. In assembly
+ * speak:
+ * .word MAGIC ! a NOP
+ * ba,a start !
+ * .skip 24 ! pad
+ * start:
+ */
+
+#define SUN_MAGIC 0x01030107
+#define SUN4_BASTART 0x30800007 /* i.e.: ba,a `start' */
+ *((int *)bp) = SUN_MAGIC;
+ *((int *)bp + 1) = SUN4_BASTART;
+
*size = sz;
return (hflag ? bp : (bp + sizeof(struct exec)));
}
call _bzero
sub %o1, %o0, %o1
-#if 0
/*
- * Enable interrupts above level 11. This enables "L1-A", but
- * avoids spurious interrupt bites from most other devices
+ * Enable interrupts, but only above level 11. This enables "L1-A",
+ * but avoids spurious interrupt bites from most other devices.
*/
rd %psr, %o0
andn %o0, PSR_PIL, %o0
wr %o0, 0xb00, %psr ! (11 << 8)
nop; nop; nop
-#endif
/*
* Set CPU type that we are running on.
* 1.4 add oldmon support and network support.
*/
-char *version = "$Revision: 1.2 $";
+char *version = "$Revision: 1.3 $";