summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Downs <downsj@cvs.openbsd.org>1997-09-15 06:20:57 +0000
committerJason Downs <downsj@cvs.openbsd.org>1997-09-15 06:20:57 +0000
commited2cd17fc5dd251cd8446755fa186070f480efef (patch)
tree428557dc02138058e00c0cd50320a6876cec253e
parentf1de2c9212b7717eeaeb182ee011044ad4f5a241 (diff)
Add isolif, the last piece of making bootable CDs. Needs some more work.
-rw-r--r--sys/arch/hp300/stand/Makefile4
-rw-r--r--sys/arch/hp300/stand/isolif/Makefile10
-rw-r--r--sys/arch/hp300/stand/isolif/isolif.8109
-rw-r--r--sys/arch/hp300/stand/isolif/isolif.c264
4 files changed, 385 insertions, 2 deletions
diff --git a/sys/arch/hp300/stand/Makefile b/sys/arch/hp300/stand/Makefile
index c3914d4de5d..133eceb9a9a 100644
--- a/sys/arch/hp300/stand/Makefile
+++ b/sys/arch/hp300/stand/Makefile
@@ -1,6 +1,6 @@
-# $OpenBSD: Makefile,v 1.13 1997/09/14 12:54:19 downsj Exp $
+# $OpenBSD: Makefile,v 1.14 1997/09/15 06:20:54 downsj Exp $
# $NetBSD: Makefile,v 1.23 1997/02/04 03:51:37 thorpej Exp $
-SUBDIR= libsa libkern libz common mkboot stripboot uboot installboot
+SUBDIR= libsa libkern libz common mkboot stripboot uboot installboot isolif
.include <bsd.subdir.mk>
diff --git a/sys/arch/hp300/stand/isolif/Makefile b/sys/arch/hp300/stand/isolif/Makefile
new file mode 100644
index 00000000000..6afba2f2b08
--- /dev/null
+++ b/sys/arch/hp300/stand/isolif/Makefile
@@ -0,0 +1,10 @@
+# $OpenBSD: Makefile,v 1.1 1997/09/15 06:20:55 downsj Exp $
+
+PROG= isolif
+MAN= isolif.8
+
+CFLAGS+= -I${.CURDIR}/../include
+
+${OBJS}: ${.CURDIR}/../Makefile.inc
+
+.include <bsd.prog.mk>
diff --git a/sys/arch/hp300/stand/isolif/isolif.8 b/sys/arch/hp300/stand/isolif/isolif.8
new file mode 100644
index 00000000000..ea484a572db
--- /dev/null
+++ b/sys/arch/hp300/stand/isolif/isolif.8
@@ -0,0 +1,109 @@
+.\" $OpenBSD: isolif.8,v 1.1 1997/09/15 06:20:55 downsj Exp $
+.\"
+.\" Copyright (c) 1997, Jason Downs. 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 Jason Downs for the
+.\" OpenBSD system.
+.\" 4. Neither the name(s) of the author(s) nor the name OpenBSD
+.\" may be used to endorse or promote products derived from this software
+.\" without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``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(S) 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.
+.\"
+.Dd September 14, 1997
+.Dt ISOLIF 8
+.Os OpenBSD
+.Sh NAME
+.Nm isolif
+.Nd make an ISO9660 filesystem bootable on an hp300
+.Sh SYNOPSIS
+.Nm /usr/mdec/isolif
+.Op Fl a
+.Fl s Ar isostart
+.Fl e Ar isoend
+.Fl n Ar name
+.Fl r Ar rawfile
+.Fl o Ar output
+.Sh DESCRIPTION
+.Nm isolif
+writes an appriopate LIF header to an ISO9660 filesystem, making it bootable
+an hp300.
+.Pp
+The ISO9660 filesystem must contain a
+.Em raw
+hp300 boot block file; this is normally found in
+.Pa /usr/mdec/uboot.raw .
+The position of that file within the ISO9660 filesystem image is then passed
+to
+.Nm
+and a LIF header is output to a file (which may be the actual ISO9660
+filesystem). When written to a CD or other media, this filesystem is then
+bootable.
+.Sh OPTIONS
+.Bl -tag -width XxXXXXXXXXX
+.It Fl a
+The
+.Fl a
+flag specifies that
+.Nm
+should not truncate it's output file; this allows the output file to be
+the actual ISO9660 filesystem image.
+.It Fl s Ar isostart
+The
+.Fl s
+option specifies the begining block in the ISO9660 filesystem of the
+.Em raw
+bootblock file.
+.It Fl e Ar isoend
+.Fl e
+specifies the ending block number of the boot block file. Both
+.Fl s
+and
+.Fl e
+values are taken from the verbose output of
+.Xr mkisofs 8 .
+.It Fl n Ar name
+The
+.Fl n
+option specifies the name of the boot block within the LIF header; this will
+be displayed by the ROM at boot time, in all capital letters and with
+.Dq SYS_
+prepended.
+.It Fl r Ar rawfile
+The name of the
+.Em raw
+boot file must be specified; data is required from it's header in order to
+build the LIF header.
+.It Fl o Ar outfile
+This specifies the output file name for the LIF header. Normally it is
+created if needed and truncated.
+.El
+.Sh BUGS
+The
+.Fl e
+option is not currently actually used by the program.
+.Sh SEE ALSO
+.Xr mkisofs 8 .
+.Sh HISTORY
+.Nm
+first appeared in OpenBSD 2.2.
diff --git a/sys/arch/hp300/stand/isolif/isolif.c b/sys/arch/hp300/stand/isolif/isolif.c
new file mode 100644
index 00000000000..7f9eb0e6c35
--- /dev/null
+++ b/sys/arch/hp300/stand/isolif/isolif.c
@@ -0,0 +1,264 @@
+/* $OpenBSD: isolif.c,v 1.1 1997/09/15 06:20:56 downsj Exp $ */
+
+/*
+ * Copyright (c) 1997, Jason Downs. 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 Jason Downs for the
+ * OpenBSD system.
+ * 4. Neither the name(s) of the author(s) nor the name OpenBSD
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``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(S) 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) 1990, 1993
+ * The Regents of the University of California. 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 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.
+ *
+ * @(#)mkboot.c 8.1 (Berkeley) 7/15/93
+ */
+
+#ifndef lint
+static char copyright[] =
+"@(#) Copyright (c) 1990, 1993\n\
+ The Regents of the University of California. All rights reserved.\n";
+#endif /* not lint */
+
+#ifndef lint
+#if 0
+static char sccsid[] = "@(#)mkboot.c 7.2 (Berkeley) 12/16/90";
+#endif
+static char rcsid[] = "$OpenBSD: isolif.c,v 1.1 1997/09/15 06:20:56 downsj Exp $";
+#endif /* not lint */
+
+#include <sys/param.h>
+#include <sys/file.h>
+#include <a.out.h>
+
+#include "volhdr.h"
+
+#include <stdio.h>
+#include <string.h>
+#include <ctype.h>
+#include <unistd.h>
+
+#define LIF_NUMDIR 8
+
+#define LIF_VOLSTART 0
+#define LIF_VOLSIZE sizeof(struct lifvol)
+#define LIF_DIRSTART 512
+#define LIF_DIRSIZE (LIF_NUMDIR * sizeof(struct lifdir))
+#define LIF_FILESTART 8192
+
+#define btolifs(b) (((b) + (SECTSIZE - 1)) / SECTSIZE)
+#define lifstob(s) ((s) * SECTSIZE)
+
+#define ISO_BLOCKSIZE 2048
+
+static void usage __P((void));
+static char *lifname __P((char *));
+static void bcddate __P((char *));
+
+int
+main(argc, argv)
+ int argc;
+ char **argv;
+{
+ int ch, isosblk, isoeblk, rfd, to, apply;
+ char *name, *outfile, *rawfile;
+ struct lifvol lifv;
+ struct lifdir lifd[LIF_NUMDIR];
+ struct load ld;
+
+ name = outfile = rawfile = NULL;
+ apply = isosblk = isoeblk = 0;
+ while ((ch = getopt(argc, argv, "as:e:n:r:o:")) != -1) {
+ switch (ch) {
+ case 'a':
+ apply++;
+ break;
+
+ case 's':
+ isosblk = atoi(optarg);
+ break;
+
+ case 'e':
+ isoeblk = atoi(optarg);
+ break;
+
+ case 'n':
+ name = optarg;
+ break;
+
+ case 'r':
+ rawfile = optarg;
+ break;
+
+ case 'o':
+ outfile = optarg;
+ break;
+
+ default:
+ usage();
+ }
+ }
+
+ if ((name == NULL) || (outfile == NULL) || (isosblk == 0) ||
+ (isoeblk == 0))
+ usage();
+
+ /* Need the ROM's header from the rawfile, unfortunately. */
+ rfd = open(rawfile, O_RDONLY, 0600);
+ if (rfd < 0) {
+ perror(rawfile);
+ exit(1);
+ }
+ if (read(rfd, &ld, sizeof(ld)) != sizeof(ld)) {
+ perror("read");
+ exit(1);
+ }
+ close(rfd);
+
+ to = open(outfile, (apply ? O_WRONLY : O_WRONLY | O_TRUNC | O_CREAT),
+ 0644);
+ if (to < 0) {
+ perror(outfile);
+ exit(1);
+ }
+
+ /* clear possibly unused directory entries */
+ strncpy(lifd[1].dir_name, " ", 10);
+ lifd[1].dir_type = -1;
+ lifd[1].dir_addr = 0;
+ lifd[1].dir_length = 0;
+ lifd[1].dir_flag = 0xFF;
+ lifd[1].dir_exec = 0;
+ lifd[7] = lifd[6] = lifd[5] = lifd[4] = lifd[3] = lifd[2] = lifd[1];
+ /* record volume info */
+ lifv.vol_id = VOL_ID;
+ strncpy(lifv.vol_label, "BOOT43", 6);
+ lifv.vol_addr = btolifs(LIF_DIRSTART);
+ lifv.vol_oct = VOL_OCT;
+ lifv.vol_dirsize = btolifs(LIF_DIRSIZE);
+ lifv.vol_version = 1;
+ /* output bootfile one */
+ strcpy(lifd[0].dir_name, lifname(name));
+ lifd[0].dir_type = DIR_TYPE;
+ lifd[0].dir_addr = btolifs(isosblk * ISO_BLOCKSIZE);
+ lifd[0].dir_length = btolifs(ld.count + sizeof(ld));
+ bcddate(lifd[0].dir_toc);
+ lifd[0].dir_flag = DIR_FLAG;
+ lifd[0].dir_exec = ld.address;
+ lifv.vol_length = lifd[0].dir_addr + lifd[0].dir_length;
+ /* output volume/directory header info */
+ lseek(to, LIF_VOLSTART, 0);
+ write(to, &lifv, LIF_VOLSIZE);
+ lseek(to, LIF_DIRSTART, 0);
+ write(to, lifd, LIF_DIRSIZE);
+
+ close(to);
+ exit(0);
+}
+
+static void usage()
+{
+ fprintf(stderr,
+ "usage: isolif [-a] -s isostart -e isoend -n name -r rawfile -o outfile\n");
+ exit(1);
+}
+
+static char *
+lifname(str)
+ char *str;
+{
+ static char lname[10] = "SYS_XXXXX";
+ register int i;
+
+ for (i = 4; i < 9; i++) {
+ if (islower(*str))
+ lname[i] = toupper(*str);
+ else if (isalnum(*str) || *str == '_')
+ lname[i] = *str;
+ else
+ break;
+ str++;
+ }
+ for ( ; i < 10; i++)
+ lname[i] = '\0';
+ return(lname);
+}
+
+#include <sys/stat.h>
+#include <time.h> /* XXX */
+
+static void
+bcddate(toc)
+ char *toc;
+{
+ time_t now;
+ struct tm *tm;
+
+ time(&now);
+ tm = localtime(&now);
+ *toc = ((tm->tm_mon+1) / 10) << 4;
+ *toc++ |= (tm->tm_mon+1) % 10;
+ *toc = (tm->tm_mday / 10) << 4;
+ *toc++ |= tm->tm_mday % 10;
+ *toc = (tm->tm_year / 10) << 4;
+ *toc++ |= tm->tm_year % 10;
+ *toc = (tm->tm_hour / 10) << 4;
+ *toc++ |= tm->tm_hour % 10;
+ *toc = (tm->tm_min / 10) << 4;
+ *toc++ |= tm->tm_min % 10;
+ *toc = (tm->tm_sec / 10) << 4;
+ *toc |= tm->tm_sec % 10;
+}