Permalink
Browse files

Booting from ufs works now.

  • Loading branch information...
1 parent e853da0 commit 51ca3c3dada054b076437a3b826c8d4860c2e0a0 gwr committed Jun 1, 1995
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.1.1.1 1995/02/14 22:56:36 gwr Exp $
+# $NetBSD: Makefile,v 1.1.1.2 1995/06/01 20:37:44 gwr Exp $
SUBDIR= libsa boot bootxx installboot
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.inc,v 1.1.1.1 1995/02/14 22:56:36 gwr Exp $
+# $NetBSD: Makefile.inc,v 1.1.1.2 1995/06/01 20:37:46 gwr Exp $
.if defined(SA_PROG)
View
@@ -1,4 +1,4 @@
-/* $NetBSD: README,v 1.1.1.1 1995/02/14 22:56:36 gwr Exp $ */
+/* $NetBSD: README,v 1.1.1.2 1995/06/01 20:37:47 gwr Exp $ */
The sun bootblocks are split into two parts: a small 1st-level program that
gets written right after the superblock in a partition (and is hence limited
@@ -18,4 +18,25 @@ Use the following command to install the 1st-level bootblocks in the
root filesystem (on `sd0a') using the file `/boot' as the second level
boot program:
- installboot /boot bootxx /dev/rsd0a
+ mount /dev/sd0a /mnt
+ installboot /mnt/boot bootxx /dev/rsd0a
+
+The above only works with securelevel <= 0 (see init.8 manual).
+
+Status:
+
+bootxx, installboot are tested and working. It would be nice if
+installboot would find the inumber for the 2nd stage boot program
+without having the filesystem mounted so this command can work
+with securelevel==1 (the default). Doing this requies adding
+code to read and do a directory lookup in the root...
+
+netboot does not work yet... (netif_sun stuff in libsa not done)
+
+Note:
+Before installation, the second stage boot programs (ufsboot, ...)
+need the a.out header stripped off. For now I do this by hand
+using the following command. This needs to be automated...
+
+dd ibs=32 skip=1 if=a.out.file | dd conv=sync of=no.header.file
+
@@ -1,5 +1,6 @@
-# $NetBSD: Makefile,v 1.1.1.1 1995/02/14 22:56:36 gwr Exp $
+# $NetBSD: Makefile,v 1.1.1.2 1995/06/01 20:37:49 gwr Exp $
SA_PROG= bootxx
+SRCS= bootxx.c conf.c
.include <bsd.prog.mk>
@@ -1,4 +1,4 @@
-/* $NetBSD: bootxx.c,v 1.1.1.1 1995/02/14 22:56:36 gwr Exp $ */
+/* $NetBSD: bootxx.c,v 1.1.1.2 1995/06/01 20:37:50 gwr Exp $ */
/*
* Copyright (c) 1994 Paul Kranenburg
@@ -30,11 +30,19 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+/*
+ * This is a generic "first-stage" boot program.
+ *
+ * Note that this program has absolutely no filesystem knowledge!
+ *
+ * Instead, this uses a table of disk block numbers that are
+ * filled in by the installboot program such that this program
+ * can load the "second-stage" boot program.
+ */
+
#include <sys/param.h>
#include <sys/time.h>
-#include <a.out.h>
-#include <ufs/ufs/dinode.h>
-#include <ufs/ffs/fs.h>
+#include <sys/exec.h>
#include <machine/mon.h>
#include "stand.h"
@@ -47,37 +55,34 @@ int netif_debug;
*/
#define LOADADDR 0x4000
struct open_file io;
-char sblock[SBSIZE];
-struct fs *fs;
-#if 0
-#define MAXBLOCKNUM MINBSIZE / sizeof(daddr_t)
-#else
-#define MAXBLOCKNUM 512
-#endif
-int maxblocknum = MAXBLOCKNUM;
-daddr_t blocknum[MAXBLOCKNUM] = { 0 };
+/* This determines the largest boot program we can load. */
+#define MAXBLOCKNUM 64
+
+/*
+ * These three names are known by installboot.
+ * The block_table contains starting block numbers,
+ * in terms of 512-byte blocks. Each non-zero value
+ * will result in a read of block_size bytes.
+ */
+int block_size = 512; /* default */
+int block_count = MAXBLOCKNUM; /* length of table */
+daddr_t block_table[MAXBLOCKNUM] = { 0 };
+
-main(argc, argv)
- int argc;
- char **argv;
+main()
{
char *dummy;
int n;
+#ifdef DEBUG
+ printf("bootxx: open...\n");
+#endif
io.f_flags = F_RAW;
if (devopen(&io, 0, &dummy)) {
- printf("Can't open device\n");
- exit();
- }
-
- if ((io.f_dev->dv_strategy)(io.f_devdata, F_READ,
- btodb(SBOFF), SBSIZE,
- sblock, &n) || n != SBSIZE) {
- printf("Can't read superblock\n");
+ printf("bootxx: open failed\n");
exit();
}
- fs = (struct fs *)sblock;
(void)copyboot(&io, LOADADDR);
exit();
@@ -88,33 +93,41 @@ copyboot(f, addr)
register struct open_file *f;
register char *addr;
{
- int n, i;
+ int n, i, bsize;
daddr_t blk;
void (*entry)() = (void (*)())addr;
+#ifdef sparc
+ /*
+ * On the sparc, the 2nd stage boot has an a.out header.
+ * On the sun3, (by tradition) the 2nd stage boot programs
+ * have the a.out header stripped off. (1st stage boot
+ * programs have the header stripped by installboot.)
+ */
+ /* XXX - This assumes OMAGIC format! */
addr -= sizeof(struct exec); /* XXX */
+#endif
+
+ for (i = 0; i < block_count; i++) {
- for (i = 0; i < MAXBLOCKNUM; i++) {
- if ((blk = blocknum[i]) == 0)
+ /* XXX - This is FS knowledge, actually. */
+ if ((blk = block_table[i]) == 0)
break;
+
#ifdef DEBUG
printf("bootxx: block # %d = %d\n", i, blk);
#endif
if ((f->f_dev->dv_strategy)(f->f_devdata, F_READ,
- fsbtodb(fs, blk), fs->fs_bsize,
- addr, &n)) {
- printf("Read failure\n");
+ blk, block_size, addr, &n))
+ {
+ printf("bootxx: read failed\n");
return -1;
}
- if (n != fs->fs_bsize) {
- printf("Short read\n");
+ if (n != block_size) {
+ printf("bootxx: short read\n");
return -1;
}
- addr += fs->fs_bsize;
- }
- if (blk != 0) {
- printf("File too long\n");
- return -1;
+ addr += block_size;
}
#ifdef DEBUG
@@ -124,4 +137,3 @@ copyboot(f, addr)
return 0;
}
-twiddle() {}
@@ -1,6 +1,8 @@
-# $NetBSD: Makefile,v 1.1.1.1 1995/02/14 22:56:36 gwr Exp $
+# $NetBSD: Makefile,v 1.1.1.2 1995/06/01 20:37:52 gwr Exp $
PROG= installboot
MAN8=
+CFLAGS=-g
+
.include <bsd.prog.mk>
Oops, something went wrong.

0 comments on commit 51ca3c3

Please sign in to comment.