Module Name: src Committed By: msaitoh Date: Wed Jun 12 06:05:52 UTC 2013
Modified Files: src/sys/arch/vax/boot/xxboot [netbsd-5]: start.S src/sys/sys [netbsd-5]: bootblock.h disklabel.h src/usr.sbin/installboot/arch [netbsd-5]: vax.c Log Message: Pull up following revision(s) (requested by martin in ticket #1856): sys/arch/vax/boot/xxboot/start.S: revision 1.5 sys/sys/bootblock.h: revision 1.55 sys/sys/disklabel.h: revision 1.113 usr.sbin/installboot/arch/vax.c: revision 1.14-1.15 Rearrange primary bootstrap slightly to free up all space between the disk label and the uVAX rom boot parameter block. Calculate the disklabel size (for asm code) dynamically based on MAXPARTITIONS. Adapt to new vax primary bootstrap layout. Fix installboot for VAX, as discussed on port-vax. Problem pointed out by Jonny Billquist, thanks to Marl Pizzolato for patiently explaining the various ways of booting a vax to me. Now VAX 780 can boot directly from VMB.EXE again. Provide an empty __CTASSERT() for toolbuilds To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.4.88.1 src/sys/arch/vax/boot/xxboot/start.S cvs rdiff -u -r1.45 -r1.45.10.1 src/sys/sys/bootblock.h cvs rdiff -u -r1.102 -r1.102.4.1 src/sys/sys/disklabel.h cvs rdiff -u -r1.12 -r1.12.6.1 src/usr.sbin/installboot/arch/vax.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/vax/boot/xxboot/start.S diff -u src/sys/arch/vax/boot/xxboot/start.S:1.4 src/sys/arch/vax/boot/xxboot/start.S:1.4.88.1 --- src/sys/arch/vax/boot/xxboot/start.S:1.4 Sun Dec 11 12:19:34 2005 +++ src/sys/arch/vax/boot/xxboot/start.S Wed Jun 12 06:05:52 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: start.S,v 1.4 2005/12/11 12:19:34 christos Exp $ */ +/* $NetBSD: start.S,v 1.4.88.1 2013/06/12 06:05:52 msaitoh Exp $ */ /* * Copyright (c) 1995 Ludd, University of Lule}, Sweden. * All rights reserved. @@ -38,6 +38,7 @@ #define _LOCORE +#define __HAVE_OLD_DISKLABEL /* not automatically added due to _LOCORE */ #define OMIT_DKTYPENUMS #define OMIT_FSTYPENUMS #include "sys/disklabel.h" @@ -55,8 +56,12 @@ _C_LABEL(start): .org 0x00 # uVAX booted from TK50 starts here brb from_0x00 # continue behind dispatch-block +# At offset 0x02 we have a dual used area: VMB.EXE starts execution here, +# and uVAX-ROM looks for a pointer to a parameter block. We arrange for +# the parameter block offset to disassmble as a CASEL instructions which +# falls through to 0x08. .org 0x02 # information used by uVAX-ROM - .byte 0xcf # offset in words to identification area + .byte 0xcf # offset in words to identification area .byte 1 # this byte must be 1 .word 0 # logical block number (word swapped) .word 0 # of the secondary image @@ -74,20 +79,6 @@ from_0x00: # uVAX from TK50 from_0x08: # Any machine from VMB movzbl $4,_C_LABEL(from) # Booted from full VMB - brw start_vmb - -# the complete area reserved for label -# must be empty (i.e. filled with zeroes). -# disklabel(8) checks that before installing -# the bootblocks over existing label. - -.org LABELOFFSET - .globl _C_LABEL(romlabel) -_C_LABEL(romlabel): - .long 0 - -.org LABELOFFSET + d_end_ -start_vmb: /* * Read in block 1-15. */ @@ -102,6 +93,20 @@ start_vmb: calls $6, (%r6) # call the qio-routine brw start_uvax +# the complete area reserved for label +# must be empty (i.e. filled with zeroes). +# disklabel(8) checks that before installing +# the bootblocks over existing label. + +.org LABELOFFSET + .globl _C_LABEL(romlabel) +_C_LABEL(romlabel): + .long 0 + +.org LABELOFFSET + d_end_ +# Make sure the parameter block is past the disklabel. +# If not, the next .org would try to move backwards. + /* * Parameter block for uVAX boot. */ @@ -110,7 +115,7 @@ start_vmb: #define SILOAD 0 /* load offset (usually 0) from the default */ #define SIOFF 0x200 /* byte offset into secondary image */ -.org 0x19e +.org 0x19e # do not move, see comment earlier about CASEL .byte 0x18 # must be 0x18 .byte 0x00 # must be 0x00 (MBZ) .byte 0x00 # any value Index: src/sys/sys/bootblock.h diff -u src/sys/sys/bootblock.h:1.45 src/sys/sys/bootblock.h:1.45.10.1 --- src/sys/sys/bootblock.h:1.45 Mon Apr 28 20:24:10 2008 +++ src/sys/sys/bootblock.h Wed Jun 12 06:05:52 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: bootblock.h,v 1.45 2008/04/28 20:24:10 martin Exp $ */ +/* $NetBSD: bootblock.h,v 1.45.10.1 2013/06/12 06:05:52 msaitoh Exp $ */ /*- * Copyright (c) 2002-2004 The NetBSD Foundation, Inc. @@ -1380,7 +1380,8 @@ struct vax_boot_block { uint8_t bb_mbone; /* must be one */ uint16_t bb_lbn_hi; /* lbn (hi word) of bootstrap */ uint16_t bb_lbn_low; /* lbn (low word) of bootstrap */ - uint8_t pad1[332]; + uint8_t pad1[460]; + /* disklabel offset is 64 from base, or 56 from start of pad1 */ /* The rest of these fields are identification area and describe * the secondary block for uVAX VMB. @@ -1402,7 +1403,7 @@ struct vax_boot_block { /* The rest is unused. */ - uint8_t pad2[148]; + uint8_t pad2[20]; } __packed; #define VAX_BOOT_MAGIC1 0x18 /* size of BB info? */ Index: src/sys/sys/disklabel.h diff -u src/sys/sys/disklabel.h:1.102 src/sys/sys/disklabel.h:1.102.4.1 --- src/sys/sys/disklabel.h:1.102 Tue Aug 19 12:16:49 2008 +++ src/sys/sys/disklabel.h Wed Jun 12 06:05:52 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: disklabel.h,v 1.102 2008/08/19 12:16:49 haad Exp $ */ +/* $NetBSD: disklabel.h,v 1.102.4.1 2013/06/12 06:05:52 msaitoh Exp $ */ /* * Copyright (c) 1987, 1988, 1993 @@ -266,7 +266,7 @@ struct olddisklabel { .set d_ncylinders,52 .set d_secpercyl,56 .set d_secperunit,60 - .set d_end_,276 /* size of disk label */ + .set d_end_,148+(MAXPARTITIONS*16) #endif /* _LOCORE */ /* Index: src/usr.sbin/installboot/arch/vax.c diff -u src/usr.sbin/installboot/arch/vax.c:1.12 src/usr.sbin/installboot/arch/vax.c:1.12.6.1 --- src/usr.sbin/installboot/arch/vax.c:1.12 Mon Apr 28 20:24:16 2008 +++ src/usr.sbin/installboot/arch/vax.c Wed Jun 12 06:05:52 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: vax.c,v 1.12 2008/04/28 20:24:16 martin Exp $ */ +/* $NetBSD: vax.c,v 1.12.6.1 2013/06/12 06:05:52 msaitoh Exp $ */ /*- * Copyright (c) 1999, 2002 The NetBSD Foundation, Inc. @@ -68,20 +68,26 @@ #include <sys/cdefs.h> #if !defined(__lint) -__RCSID("$NetBSD: vax.c,v 1.12 2008/04/28 20:24:16 martin Exp $"); +__RCSID("$NetBSD: vax.c,v 1.12.6.1 2013/06/12 06:05:52 msaitoh Exp $"); #endif /* !__lint */ #include <sys/param.h> +#include <sys/disklabel.h> #include <assert.h> #include <err.h> #include <stddef.h> #include <stdio.h> #include <stdlib.h> +#include <string.h> #include <unistd.h> #include "installboot.h" +#ifndef __CTASSERT +#define __CTASSERT(X) +#endif + static int load_bootstrap(ib_params *, char **, uint32_t *, uint32_t *, size_t *); @@ -101,7 +107,7 @@ vax_clearboot(ib_params *params) assert(params != NULL); assert(params->fsfd != -1); assert(params->filesystem != NULL); - assert(sizeof(struct vax_boot_block) == VAX_BOOT_BLOCK_BLOCKSIZE); + __CTASSERT(sizeof(bb)==VAX_BOOT_BLOCK_BLOCKSIZE); rv = pread(params->fsfd, &bb, sizeof(bb), VAX_BOOT_BLOCK_OFFSET); if (rv == -1) { @@ -112,7 +118,7 @@ vax_clearboot(ib_params *params) return (0); } - if (bb.bb_id_offset * 2 != offsetof(struct vax_boot_block, bb_magic1) + if (bb.bb_id_offset*2 >= VAX_BOOT_BLOCK_BLOCKSIZE || bb.bb_magic1 != VAX_BOOT_MAGIC1) { warnx( "Old boot block magic number invalid; boot block invalid"); @@ -154,10 +160,10 @@ static int vax_setboot(ib_params *params) { struct stat bootstrapsb; - struct vax_boot_block bb; + struct vax_boot_block *bb; uint32_t startblock; int retval; - char *bootstrapbuf; + char *bootstrapbuf, oldbb[VAX_BOOT_BLOCK_BLOCKSIZE]; size_t bootstrapsize; uint32_t bootstrapload, bootstrapexec; ssize_t rv; @@ -167,8 +173,12 @@ vax_setboot(ib_params *params) assert(params->filesystem != NULL); assert(params->s1fd != -1); assert(params->stage1 != NULL); - assert(sizeof(struct vax_boot_block) == VAX_BOOT_BLOCK_BLOCKSIZE); + /* see sys/arch/vax/boot/xxboot/start.S for explanation */ + __CTASSERT(offsetof(struct vax_boot_block,bb_magic1) == 0x19e); + __CTASSERT(sizeof(struct vax_boot_block) == VAX_BOOT_BLOCK_BLOCKSIZE); + + startblock = 0; retval = 0; bootstrapbuf = NULL; @@ -184,16 +194,29 @@ vax_setboot(ib_params *params) &bootstrapexec, &bootstrapsize)) goto done; - rv = pread(params->fsfd, &bb, sizeof(bb), VAX_BOOT_BLOCK_OFFSET); + /* read old boot block */ + rv = pread(params->fsfd, oldbb, sizeof(oldbb), VAX_BOOT_BLOCK_OFFSET); if (rv == -1) { warn("Reading `%s'", params->filesystem); goto done; - } else if (rv != sizeof(bb)) { + } else if (rv != sizeof(oldbb)) { warnx("Reading `%s': short read", params->filesystem); goto done; } - /* fill in the updated boot block fields */ + /* + * Copy disklabel from old boot block to new. + * Assume everything between LABELOFFSET and the start of + * the param block is scratch area and can be copied over. + */ + memcpy(bootstrapbuf+LABELOFFSET, + oldbb+LABELOFFSET, + offsetof(struct vax_boot_block,bb_magic1)-LABELOFFSET); + + /* point to bootblock at begining of bootstrap */ + bb = (struct vax_boot_block*)bootstrapbuf; + + /* fill in the updated boot block fields */ if (params->flags & IB_APPEND) { struct stat filesyssb; @@ -209,46 +232,21 @@ vax_setboot(ib_params *params) } startblock = howmany(filesyssb.st_size, VAX_BOOT_BLOCK_BLOCKSIZE); - } else if (params->flags & IB_STAGE1START) { - startblock = params->s1start; - } else { - startblock = VAX_BOOT_BLOCK_OFFSET / VAX_BOOT_BLOCK_BLOCKSIZE - + 1; + bb->bb_lbn_hi = htole16((uint16_t) (startblock >> 16)); + bb->bb_lbn_low = htole16((uint16_t) (startblock >> 0)); } - bb.bb_id_offset = offsetof(struct vax_boot_block, bb_magic1) / 2; - bb.bb_mbone = 1; - bb.bb_lbn_hi = htole16((uint16_t) (startblock >> 16)); - bb.bb_lbn_low = htole16((uint16_t) (startblock >> 0)); - /* - * Now the identification block - */ - bb.bb_magic1 = VAX_BOOT_MAGIC1; - bb.bb_mbz1 = 0; - bb.bb_sum1 = ~(bb.bb_magic1 + bb.bb_mbz1 + bb.bb_pad1); - - bb.bb_mbz2 = 0; - bb.bb_volinfo = VAX_BOOT_VOLINFO_NONE; - bb.bb_pad2a = 0; - bb.bb_pad2b = 0; - - bb.bb_size = htole32(bootstrapsize / VAX_BOOT_BLOCK_BLOCKSIZE); - bb.bb_load = htole32(VAX_BOOT_LOAD); - bb.bb_entry = htole32(VAX_BOOT_ENTRY); - bb.bb_sum3 = htole32(le32toh(bb.bb_size) + le32toh(bb.bb_load) \ - + le32toh(bb.bb_entry)); - if (params->flags & IB_SUNSUM) { uint16_t sum; - sum = compute_sunsum((uint16_t *)&bb); - if (! set_sunsum(params, (uint16_t *)&bb, sum)) + sum = compute_sunsum((uint16_t *)bb); + if (! set_sunsum(params, (uint16_t *)bb, sum)) goto done; } if (params->flags & IB_VERBOSE) { printf("Bootstrap start sector: %u\n", startblock); - printf("Bootstrap sector count: %u\n", le32toh(bb.bb_size)); + printf("Bootstrap sector count: %u\n", le32toh(bb->bb_size)); printf("%sriting bootstrap\n", (params->flags & IB_NOWRITE) ? "Not w" : "W"); } @@ -256,8 +254,7 @@ vax_setboot(ib_params *params) retval = 1; goto done; } - rv = pwrite(params->fsfd, bootstrapbuf, bootstrapsize, - startblock * VAX_BOOT_BLOCK_BLOCKSIZE); + rv = pwrite(params->fsfd, bootstrapbuf, bootstrapsize, 0); if (rv == -1) { warn("Writing `%s'", params->filesystem); goto done; @@ -265,19 +262,7 @@ vax_setboot(ib_params *params) warnx("Writing `%s': short write", params->filesystem); goto done; } - - if (params->flags & IB_VERBOSE) - printf("Writing boot block\n"); - rv = pwrite(params->fsfd, &bb, sizeof(bb), VAX_BOOT_BLOCK_OFFSET); - if (rv == -1) { - warn("Writing `%s'", params->filesystem); - goto done; - } else if (rv != sizeof(bb)) { - warnx("Writing `%s': short write", params->filesystem); - goto done; - } else { - retval = 1; - } + retval = 1; done: if (bootstrapbuf)