summaryrefslogtreecommitdiff
path: root/sys/arch/vax/stand/xxboot
diff options
context:
space:
mode:
authorHugh Graham <hugh@cvs.openbsd.org>2002-06-11 09:36:25 +0000
committerHugh Graham <hugh@cvs.openbsd.org>2002-06-11 09:36:25 +0000
commit10ca5e5818bb80e596db244327a2663b6703bb18 (patch)
treec7ac330b34d73ea4e0c78d17a9eed0a3b6df63aa /sys/arch/vax/stand/xxboot
parent180b34af9885b092bee0f67c5b2ac8577d972cfe (diff)
New boot code, mostly from ragge's work in NetBSD.
Some header syncing and a couple network drivers came along for the ride. Assembly files have been renamed from .s to .S to facilitate diffs. Kernel is backwards compat - with manual interaction. OpenBSD features have been preserved.
Diffstat (limited to 'sys/arch/vax/stand/xxboot')
-rw-r--r--sys/arch/vax/stand/xxboot/Makefile46
-rw-r--r--sys/arch/vax/stand/xxboot/bootxx.c595
-rw-r--r--sys/arch/vax/stand/xxboot/start.S (renamed from sys/arch/vax/stand/xxboot/start.s)166
3 files changed, 431 insertions, 376 deletions
diff --git a/sys/arch/vax/stand/xxboot/Makefile b/sys/arch/vax/stand/xxboot/Makefile
index 9c69452e26c..d3aac85b173 100644
--- a/sys/arch/vax/stand/xxboot/Makefile
+++ b/sys/arch/vax/stand/xxboot/Makefile
@@ -1,37 +1,57 @@
-# $OpenBSD: Makefile,v 1.3 2002/03/10 06:52:16 hugh Exp $
-# $NetBSD: Makefile,v 1.2 1999/10/23 14:40:39 ragge Exp $
+# $OpenBSD: Makefile,v 1.4 2002/06/11 09:36:24 hugh Exp $
+# $NetBSD: Makefile,v 1.12 2002/02/24 01:04:25 matt Exp $
-S=${.CURDIR}/../../../../
+S= ${.CURDIR}/../../../../
PROG= xxboot
LINKS= ${BINDIR}/xxboot ${BINDIR}/raboot
LINKS+= ${BINDIR}/xxboot ${BINDIR}/hdboot
LINKS+= ${BINDIR}/xxboot ${BINDIR}/sdboot
LINKS+= ${BINDIR}/xxboot ${BINDIR}/hpboot
+WARNS?= 1
-SRCS= start.s bootxx.c romread.s urem.s udiv.s str.s
+SRCS= start.S bootxx.c romread.S str.S urem.s udiv.s
STRIPFLAG=
CPPFLAGS+=-D_STANDALONE -DLIBSA_NO_FD_CHECKING -DLIBSA_NO_RAW_ACCESS \
-DLIBSA_NO_TWIDDLE -DLIBSA_SINGLE_DEVICE=rom \
- -DLIBSA_SINGLE_FILESYSTEM=ufs
+ -DLIBSA_NO_COMPAT_UFS \
+ -DLIBSA_NO_FS_SYMLINK -DLIBSA_NO_FS_CLOSE \
+ -DLIBSA_NO_FS_WRITE -DLIBSA_NO_FS_SEEK \
+ -DNEED_UFS
BINDIR= /usr/mdec
-NOMAN= 1
+NOMAN= # defined
+
+CFLAGS= -Os
SAREL=
SA_AS= library
.include "${S}/lib/libsa/Makefile.inc"
LIBSA= ${SALIB}
-${PROG}: ${OBJS} ${LIBSA}
- ld -N -Ttext 100000 -o a.out ${OBJS} ${LIBSA}
- strip a.out
- size a.out
- dd if=a.out of=${PROG} bs=32 skip=1
-# rm -f a.out
+#KERN_AS=library
+#.include "${S}/lib/libkern/Makefile.inc"
+#LIBKERN=${KERNLIB}
+
+.if ${MACHINE} == "vax"
+.PHONY: machine-links
+beforedepend: machine-links
+machine-links:
+ @[ -h machine ] || ln -s ${S}/arch/${MACHINE}/include machine
+ @[ -h ${MACHINE_ARCH} ] || ln -s ${S}/arch/${MACHINE_ARCH}/include ${MACHINE_ARCH}
+.NOPATH: machine ${MACHINE_ARCH}
+CLEANFILES+= machine ${MACHINE_ARCH}
+.endif
+
+${PROG}: ${OBJS} ${LIBSA} ${LIBZ} ${LIBKERN}
+${PROG}: ${OBJS} ${LIBSA} ${LIBKERN}
+ ${LD} -N -Ttext 100000 -o ${PROG}.out ${OBJS} ${LIBSA} ${LIBKERN}
+ /usr/bin/strip ${PROG}.out
+ /usr/bin/size ${PROG}.out
+ /bin/dd if=${PROG}.out of=${PROG} bs=32 skip=1
clean::
rm -f a.out [Ee]rrs mklog core *.core ${PROG} ${OBJS} ${LOBJS} \
- ${CLEANFILES}
+ ${CLEANFILES}
.include <bsd.prog.mk>
diff --git a/sys/arch/vax/stand/xxboot/bootxx.c b/sys/arch/vax/stand/xxboot/bootxx.c
index 30007379ea1..7c57b7267fa 100644
--- a/sys/arch/vax/stand/xxboot/bootxx.c
+++ b/sys/arch/vax/stand/xxboot/bootxx.c
@@ -1,5 +1,6 @@
-/* $OpenBSD: bootxx.c,v 1.4 2002/03/14 03:16:02 millert Exp $ */
-/* $NetBSD: bootxx.c,v 1.2 1999/10/23 14:40:38 ragge Exp $ */
+/* $OpenBSD: bootxx.c,v 1.5 2002/06/11 09:36:24 hugh Exp $ */
+/* $NetBSD: bootxx.c,v 1.16 2002/03/29 05:45:08 matt Exp $ */
+
/*-
* Copyright (c) 1982, 1986 The Regents of the University of California.
* All rights reserved.
@@ -38,167 +39,149 @@
#include "sys/param.h"
#include "sys/reboot.h"
#include "sys/disklabel.h"
+#include "sys/exec.h"
+#include "sys/exec_elf.h"
#include "lib/libsa/stand.h"
#include "lib/libsa/ufs.h"
+#include "lib/libsa/cd9660.h"
-#include "../include/pte.h"
-#include "../include/sid.h"
-#include "../include/mtpr.h"
-#include "../include/reg.h"
-#include "../include/rpb.h"
+#include "machine/pte.h"
+#include "machine/sid.h"
+#include "machine/mtpr.h"
+#include "machine/reg.h"
+#include "machine/rpb.h"
+#include "../vax/gencons.h"
#include "../mba/mbareg.h"
#include "../mba/hpreg.h"
#define NRSP 1 /* Kludge */
#define NCMD 1 /* Kludge */
+#define LIBSA_TOO_OLD
-#include "../mscp/mscp.h"
-#include "../mscp/mscpreg.h"
-
-#include "vaxstand.h"
+#include "arch/vax/mscp/mscp.h"
+#include "arch/vax/mscp/mscpreg.h"
-struct rom_softc {
- int part;
- int unit;
-} rom_softc;
+#include "../boot/data.h"
-int romstrategy(void *, int, daddr_t, size_t, void *, size_t *);
-int romopen(struct open_file *, int, int, int, int);
-
-struct fs_ops file_system[] = {
- { ufs_open, ufs_close, ufs_read, ufs_write, ufs_seek, ufs_stat }
-};
-int nfsys = (sizeof(file_system) / sizeof(struct fs_ops));
-
-struct devsw devsw[] = {
- SADEV("rom", romstrategy, romopen, nullsys, noioctl),
-};
-int ndevs = (sizeof(devsw)/sizeof(devsw[0]));
-
-int command(int cmd, int arg);
-
-/*
- * Boot program... argume passed in r10 and r11 determine whether boot
- * stops to ask for system name and which device boot comes from.
- */
+#define RF_PROTECTED_SECTORS 64 /* XXX refer to <.../rf_optnames.h> */
-volatile dev_t devtype, bootdev;
-unsigned opendev, boothowto, bootset, memsz;
+void Xmain(void);
+void hoppabort(int);
+void romread_uvax(int lbn, int size, void *buf, struct rpb *rpb);
+void hpread(int block);
+int read750(int block, int *regs);
+int unit_init(int, struct rpb *, int);
struct open_file file;
unsigned *bootregs;
struct rpb *rpb;
+struct bqo *bqo;
int vax_cputype;
+int vax_load_failure;
+struct udadevice {u_short udaip;u_short udasa;};
+volatile struct udadevice *csr;
+static int moved;
+
+extern int from;
+#define FROM750 1
+#define FROMMV 2
+#define FROMVMB 4
/*
* The boot block are used by 11/750, 8200, MicroVAX II/III, VS2000,
* VS3100/??, VS4000 and VAX6000/???, and only when booting from disk.
*/
+void
Xmain()
{
+ union {
+ struct exec aout;
+ Elf32_Ehdr elf;
+ } hdr;
int io;
- char *scbb;
- char *new, *bqo;
- char *hej = "/boot";
+ u_long entry;
vax_cputype = (mfpr(PR_SID) >> 24) & 0xFF;
-
+ moved = 0;
/*
*/
- switch (vax_cputype) {
- case VAX_TYP_UV2:
- case VAX_TYP_CVAX:
- case VAX_TYP_RIGEL:
- case VAX_TYP_NVAX:
- case VAX_TYP_MARIAH:
- case VAX_TYP_SOC:
+ rpb = (void *)0xf0000; /* Safe address right now */
+ bqo = (void *)0xf1000;
+ if (from == FROMMV) {
/*
* now relocate rpb/bqo (which are used by ROM-routines)
*/
- rpb = (void *)XXRPB;
- bcopy ((void *)bootregs[11], rpb, 512);
- rpb->rpb_base = rpb;
- bqo = (void *)(512+(int)rpb);
- bcopy ((void *)rpb->iovec, bqo, rpb->iovecsz);
- rpb->iovec = (int)bqo;
- bootregs[11] = (int)rpb;
- bootdev = rpb->devtyp;
- memsz = rpb->pfncnt << 9;
- break;
- case VAX_8200:
- case VAX_750:
- bootdev = bootregs[10];
- memsz = 0;
- break;
- default:
- asm("halt");
- }
-
- bootset = getbootdev();
- io = open(hej, 0);
-
- read(io, (void *)0x10000, 0x10000);
- bcopy((void *) 0x10000, 0, 0xffff);
- hoppabort(32, XXRPB, bootset);
- asm("halt");
-}
-
-getbootdev()
-{
- int i, adaptor, controller, unit, partition, retval;
-
- adaptor = controller = unit = partition = 0;
-
- switch (vax_cputype) {
- case VAX_TYP_UV2:
- case VAX_TYP_CVAX:
- case VAX_TYP_MARIAH:
- case VAX_TYP_RIGEL:
- if (rpb->devtyp == BDEV_SD || rpb->devtyp == BDEV_SDN) {
- unit = rpb->unit / 100;
- controller = (rpb->csrphy & 0x100 ? 1 : 0);
- } else {
- controller = ((rpb->csrphy & 017777) == 0xDC)?1:0;
- unit = rpb->unit; /* DUC, DUD? */
+ bcopy ((void *)bootregs[11], rpb, sizeof(struct rpb));
+ bcopy ((void*)rpb->iovec, bqo, rpb->iovecsz);
+#if 0
+ if (rpb->devtyp == BDEV_SDN)
+ rpb->devtyp = BDEV_SD; /* XXX until driver fixed */
+#endif
+ } else {
+ bzero(rpb, sizeof(struct rpb));
+ rpb->devtyp = bootregs[0];
+ rpb->unit = bootregs[3];
+ rpb->rpb_bootr5 = bootregs[5];
+ rpb->csrphy = bootregs[2];
+ rpb->adpphy = bootregs[1]; /* BI node on 8200 */
+ if (rpb->devtyp != BDEV_HP && vax_cputype == VAX_TYP_750)
+ rpb->adpphy =
+ (bootregs[1] == 0xffe000 ? 0xf30000 : 0xf32000);
+ }
+ rpb->rpb_base = rpb;
+ rpb->iovec = (int)bqo;
+
+ io = open("/boot.vax", 0);
+ if (io < 0)
+ io = open("/boot", 0);
+ if (io < 0)
+ asm("movl $0xbeef1, r0; halt");
+
+ read(io, (void *)&hdr.aout, sizeof(hdr.aout));
+ if (N_GETMAGIC(hdr.aout) == OMAGIC && N_GETMID(hdr.aout) == MID_VAX) {
+ vax_load_failure++;
+ entry = hdr.aout.a_entry;
+ if (entry < sizeof(hdr.aout))
+ entry = sizeof(hdr.aout);
+ read(io, (void *) entry, hdr.aout.a_text + hdr.aout.a_data);
+ memset((void *) (entry + hdr.aout.a_text + hdr.aout.a_data),
+ 0, hdr.aout.a_bss);
+ } else if (memcmp(hdr.elf.e_ident, ELFMAG, SELFMAG) == 0) {
+ Elf32_Phdr ph;
+ size_t off = sizeof(hdr.elf);
+ vax_load_failure += 2;
+ read(io, (caddr_t)(&hdr.elf) + sizeof(hdr.aout),
+ sizeof(hdr.elf) - sizeof(hdr.aout));
+ if (hdr.elf.e_machine != EM_VAX || hdr.elf.e_type != ET_EXEC
+ || hdr.elf.e_phnum != 1)
+ goto die;
+ vax_load_failure++;
+ entry = hdr.elf.e_entry;
+ if (hdr.elf.e_phoff != sizeof(hdr.elf))
+ goto die;
+ vax_load_failure++;
+ read(io, &ph, sizeof(ph));
+ off += sizeof(ph);
+ if (ph.p_type != PT_LOAD)
+ goto die;
+ vax_load_failure++;
+ while (off < ph.p_offset) {
+ u_int32_t tmp;
+ read(io, &tmp, sizeof(tmp));
+ off += sizeof(tmp);
}
- break;
-
- case VAX_TYP_8SS:
- case VAX_TYP_750:
- controller = bootregs[1];
- unit = bootregs[3];
- break;
+ read(io, (void *) ph.p_paddr, ph.p_filesz);
+ memset((void *) (ph.p_paddr + ph.p_filesz), 0,
+ ph.p_memsz - ph.p_filesz);
+ } else {
+ goto die;
}
-
- switch (B_TYPE(bootdev)) {
- case BDEV_HP: /* massbuss boot */
- adaptor = (bootregs[1] & 0x6000) >> 17;
- break;
-
- case BDEV_UDA: /* UDA50 boot */
- if (vax_cputype == VAX_750)
- adaptor = (bootregs[1] & 0x40000 ? 0 : 1);
- break;
-
- case BDEV_TK: /* TK50 boot */
- case BDEV_CNSL: /* Console storage boot */
- case BDEV_RD: /* RD/RX on HDC9224 (MV2000) */
- case BDEV_ST: /* SCSI-tape on NCR5380 (MV2000) */
- case BDEV_SD: /* SCSI-disk on NCR5380 (3100/76) */
- case BDEV_SDN: /* SCSI disk on NCR53C94 */
- break;
-
- case BDEV_KDB: /* DSA disk on KDB50 (VAXBI VAXen) */
- bootdev = (bootdev & ~B_TYPEMASK) | BDEV_UDA;
- break;
-
- default:
- boothowto |= (RB_SINGLE | RB_ASKNAME);
- }
- return MAKEBOOTDEV(bootdev, adaptor, controller, unit, partition);
+ hoppabort(entry);
+die:
+ asm("movl $0xbeef2, r0; halt");
}
/*
@@ -207,6 +190,51 @@ getbootdev()
* - Can only load file "boot".
* - Must be the first file on tape.
*/
+struct fs_ops file_system[] = {
+#ifdef NEED_UFS
+ { ufs_open, 0, ufs_read, 0, 0, ufs_stat },
+#endif
+#ifdef NEED_CD9660
+ { cd9660_open, 0, cd9660_read, 0, 0, cd9660_stat },
+#endif
+#ifdef NEED_USTARFS
+ { ustarfs_open, 0, ustarfs_read, 0, 0, ustarfs_stat },
+#endif
+};
+
+int nfsys = (sizeof(file_system) / sizeof(struct fs_ops));
+
+#ifdef LIBSA_TOO_OLD
+#include "../boot/vaxstand.h"
+
+struct rom_softc {
+ int part;
+ int unit;
+} rom_softc;
+
+int romstrategy(void *, int, daddr_t, size_t, void *, size_t *);
+int romopen(struct open_file *, int, int, int, int);
+struct devsw devsw[] = {
+ SADEV("rom", romstrategy, romopen, nullsys, noioctl),
+};
+int ndevs = (sizeof(devsw)/sizeof(devsw[0]));
+
+int
+romopen(f, adapt, ctlr, unit, part)
+ struct open_file *f;
+ int adapt, ctlr, unit, part;
+{
+ rom_softc.unit = unit;
+ rom_softc.part = part;
+
+ f->f_devdata = (void *)&rom_softc;
+
+ return 0;
+}
+
+#endif
+
+#if 0
int tar_open(char *path, struct open_file *f);
ssize_t tar_read(struct open_file *f, void *buf, size_t size, size_t *resid);
@@ -233,101 +261,68 @@ tar_read(f, buf, size, resid)
{
romstrategy(0, 0, (8192+512), size, buf, 0);
*resid = size;
+ return 0; /* XXX */
}
+#endif
-struct disklabel lp;
-int part_off = 0; /* offset into partition holding /boot */
-char io_buf[DEV_BSIZE];
-volatile struct uda {
- struct mscp_1ca uda_ca; /* communications area */
- struct mscp uda_rsp; /* response packets */
- struct mscp uda_cmd; /* command packets */
-} uda;
-struct udadevice {u_short udaip;u_short udasa;};
-volatile struct udadevice *csr;
+int
devopen(f, fname, file)
struct open_file *f;
const char *fname;
char **file;
{
- extern char start;
- char *msg;
- int i, err, off;
- char line[64];
- struct devsw *dp;
+#ifdef LIBSA_TOO_OLD
+ int i;
+ struct devsw *dp;
f->f_dev = &devsw[0];
+#endif
*file = (char *)fname;
+ if (from == FROM750)
+ return 0;
/*
- * On uVAX we need to init [T]MSCP ctlr to be able to use it.
+ * Reinit the VMB boot device.
*/
- if (vax_cputype == VAX_TYP_UV2 || vax_cputype == VAX_TYP_CVAX) {
- switch (bootdev) {
- case BDEV_UDA: /* MSCP */
- case BDEV_TK: /* TMSCP */
+ if (bqo->unit_init && (moved++ == 0)) {
+ int initfn;
+
+ initfn = rpb->iovec + bqo->unit_init;
+ if (rpb->devtyp == BDEV_UDA || rpb->devtyp == BDEV_TK) {
+ /*
+ * This reset do not seem to be done in the
+ * ROM routines, so we have to do it manually.
+ */
csr = (struct udadevice *)rpb->csrphy;
-
- csr->udaip = 0; /* Start init */
- while((csr->udasa & MP_STEP1) == 0);
- csr->udasa = 0x8000;
- while((csr->udasa & MP_STEP2) == 0);
- csr->udasa = (short)(((u_int)&uda)&0xffff) + 8;
- while((csr->udasa & MP_STEP3) == 0);
- csr->udasa = 0x10;
- while((csr->udasa & MP_STEP4) == 0);
- csr->udasa = 0x0001;
-
- uda.uda_ca.ca_rspdsc =
- (int) &uda.uda_rsp.mscp_cmdref;
- uda.uda_ca.ca_cmddsc =
- (int) &uda.uda_cmd.mscp_cmdref;
- if (bootdev == BDEV_TK)
- uda.uda_cmd.mscp_vcid = 1;
- command(M_OP_SETCTLRC, 0);
- uda.uda_cmd.mscp_unit = rpb->unit;
- command(M_OP_ONLINE, 0);
+ csr->udaip = 0;
+ while ((csr->udasa & MP_STEP1) == 0)
+ ;
}
+ /*
+ * AP (R12) have a pointer to the VMB argument list,
+ * wanted by bqo->unit_init.
+ */
+ unit_init(initfn, rpb, bootregs[12]);
}
-
- /*
- * the disklabel _shall_ be at address LABELOFFSET + RELOC in
- * phys memory now, no need at all to reread it again.
- * Actually disklabel is only needed when using hp disks,
- * but it doesn't hurt to always get it.
- */
- getdisklabel(LABELOFFSET + &start, &lp);
-
- /* currently only one dev in devsw; this must change if we add more */
- dp = devsw;
- i = 0;
- if(dp != NULL && dp->dv_open != NULL) {
- i = (*dp->dv_open)(f, B_ADAPTOR(bootdev), B_CONTROLLER(bootdev),
- B_UNIT(bootdev), B_PARTITION(bootdev));
- }
-
- return i;
-}
-
-command(cmd, arg)
-{
- volatile int hej;
-
- uda.uda_cmd.mscp_opcode = cmd;
- uda.uda_cmd.mscp_modifier = arg;
-
- uda.uda_cmd.mscp_msglen = MSCP_MSGLEN;
- uda.uda_rsp.mscp_msglen = MSCP_MSGLEN;
- uda.uda_ca.ca_rspdsc |= MSCP_OWN|MSCP_INT;
- uda.uda_ca.ca_cmddsc |= MSCP_OWN|MSCP_INT;
- hej = csr->udaip;
- while (uda.uda_ca.ca_rspdsc < 0);
-
+#ifdef LIBSA_TOO_OLD_FOO
+ /* currently only one dev in devsw; this must change if we add more */
+ dp = devsw;
+ i = 0;
+ if(dp != NULL && dp->dv_open != NULL) {
+ i = (*dp->dv_open)(f, B_ADAPTOR(bootdev), B_CONTROLLER(bootdev),
+ B_UNIT(bootdev), B_PARTITION(bootdev));
+ }
+
+ return i;
+#else
+ return 0;
+#endif
}
-int curblock = 0;
+extern struct disklabel romlabel;
+int
romstrategy(sc, func, dblk, size, buf, rsize)
void *sc;
int func;
@@ -336,77 +331,31 @@ romstrategy(sc, func, dblk, size, buf, rsize)
void *buf;
size_t *rsize;
{
- struct rom_softc *romsc = sc;
- int i;
int block = dblk;
int nsize = size;
- switch (vax_cputype) {
- /*
- * case VAX_TYP_UV2:
- * case VAX_TYP_CVAX:
- * case VAX_TYP_RIGEL:
- */
- default:
- switch (B_TYPE(bootdev)) {
-
- case BDEV_UDA: /* MSCP */
- uda.uda_cmd.mscp_seq.seq_lbn = dblk;
- uda.uda_cmd.mscp_seq.seq_bytecount = size;
- uda.uda_cmd.mscp_seq.seq_buffer = (int)buf;
- uda.uda_cmd.mscp_unit = rpb->unit;
- command(M_OP_READ, 0);
- break;
-
- case BDEV_TK: /* TMSCP */
- if (dblk < curblock) {
- uda.uda_cmd.mscp_seq.seq_bytecount =
- curblock - dblk;
- command(M_OP_POS, 12);
- } else {
- uda.uda_cmd.mscp_seq.seq_bytecount =
- dblk - curblock;
- command(M_OP_POS, 4);
+ if (romlabel.d_magic == DISKMAGIC && romlabel.d_magic2 == DISKMAGIC) {
+ if (romlabel.d_npartitions > 1) {
+ block += romlabel.d_partitions[0].p_offset;
+ if (romlabel.d_partitions[0].p_fstype == FS_RAID) {
+ block += RF_PROTECTED_SECTORS;
}
- curblock = size/512 + dblk;
- for (i = 0 ; i < size/512 ; i++) {
- uda.uda_cmd.mscp_seq.seq_lbn = 1;
- uda.uda_cmd.mscp_seq.seq_bytecount = 512;
- uda.uda_cmd.mscp_seq.seq_buffer =
- (int)buf + i * 512;
- uda.uda_cmd.mscp_unit = rpb->unit;
- command(M_OP_READ, 0);
- }
- break;
-
- case BDEV_SDN: /* XXX others too eventually */
- case BDEV_SD: /* XXX others too eventually */
- if(romsc != NULL)
- block += lp.d_partitions[romsc->part].p_offset;
- case BDEV_RD:
- case BDEV_ST:
-
- default:
- romread_uvax(block, size, buf, bootregs);
- break;
+ }
+ }
+ if (from == FROMMV) {
+ romread_uvax(block, size, buf, rpb);
+ } else /* if (from == FROM750) */ {
+ while (size > 0) {
+ if (rpb->devtyp == BDEV_HP)
+ hpread(block);
+ else
+ read750(block, bootregs);
+ bcopy(0, buf, 512);
+ size -= 512;
+ (char *)buf += 512;
+ block++;
}
- break;
-
- case VAX_8200:
- case VAX_750:
- if (bootdev != BDEV_HP) {
- while (size > 0) {
- while ((read750(block, bootregs) & 0x01) == 0){
- }
- bcopy(0, buf, 512);
- size -= 512;
- buf += 512;
- block++;
- }
- } else
- hpread(block, size, buf);
- break;
}
if (rsize)
@@ -414,50 +363,66 @@ romstrategy(sc, func, dblk, size, buf, rsize)
return 0;
}
-int
-romopen(f, adapt, ctlr, unit, part)
- struct open_file *f;
- int adapt, ctlr, unit, part;
-{
- rom_softc.unit = unit;
- rom_softc.part = part;
-
- f->f_devdata = (void *)&rom_softc;
-
- return 0;
-}
+/*
+ * The 11/750 boot ROM for Massbus disks doesn't seen to have layout info
+ * for all RP disks (not RP07 at least) so therefore a very small and dumb
+ * device driver is used. It assumes that there is a label on the disk
+ * already that has valid layout info. If there is no label, we can't boot
+ * anyway.
+ */
+
+#define MBA_WCSR(reg, val) \
+ ((void)(*(volatile u_int32_t *)((adpadr) + (reg)) = (val)));
+#define MBA_RCSR(reg) \
+ (*(volatile u_int32_t *)((adpadr) + (reg)))
+#define HP_WCSR(reg, val) \
+ ((void)(*(volatile u_int32_t *)((unitadr) + (reg)) = (val)));
+#define HP_RCSR(reg) \
+ (*(volatile u_int32_t *)((unitadr) + (reg)))
-hpread(block, size, buf)
- char *buf;
+void
+hpread(int bn)
{
- volatile struct mba_regs *mr = (void *) bootregs[1];
- volatile struct hp_drv *hd = (void *)&mr->mba_md[bootregs[3]];
- struct disklabel *dp = &lp;
- u_int pfnum, nsize, mapnr, bn, cn, sn, tn;
-
- pfnum = (u_int) buf >> PGSHIFT;
-
- for (mapnr = 0, nsize = size; (nsize + NBPG) > 0; nsize -= NBPG)
- *(int *)&mr->mba_map[mapnr++] = PG_V | pfnum++;
- mr->mba_var = ((u_int) buf & PGOFSET);
- mr->mba_bc = (~size) + 1;
- bn = block;
+ int adpadr = bootregs[1];
+ int unitadr = adpadr + MUREG(bootregs[3], 0);
+ u_int cn, sn, tn;
+ struct disklabel *dp;
+ extern char start;
+
+ dp = (struct disklabel *)(LABELOFFSET + &start);
+ MBA_WCSR(MAPREG(0), PG_V);
+
+ MBA_WCSR(MBA_VAR, 0);
+ MBA_WCSR(MBA_BC, (~512) + 1);
+#ifdef __GNUC__
+ /*
+ * Avoid four subroutine calls by using hardware division.
+ */
+ asm("clrl %r1;"
+ "movl %3,%r0;"
+ "ediv %4,%r0,%0,%1;"
+ "movl %1,%r0;"
+ "ediv %5,%r0,%2,%1"
+ : "=g"(cn),"=g"(sn),"=g"(tn)
+ : "g"(bn),"g"(dp->d_secpercyl),"g"(dp->d_nsectors)
+ : "r0","r1","cc");
+#else
cn = bn / dp->d_secpercyl;
sn = bn % dp->d_secpercyl;
tn = sn / dp->d_nsectors;
sn = sn % dp->d_nsectors;
- hd->hp_dc = cn;
- hd->hp_da = (tn << 8) | sn;
- hd->hp_cs1 = HPCS_READ;
- while (mr->mba_sr & MBASR_DTBUSY);
- if (mr->mba_sr & MBACR_ABORT){
- return 1;
- }
- return 0;
+#endif
+ HP_WCSR(HP_DC, cn);
+ HP_WCSR(HP_DA, (tn << 8) | sn);
+ HP_WCSR(HP_CS1, HPCS_READ);
+
+ while (MBA_RCSR(MBA_SR) & MBASR_DTBUSY)
+ ;
+ return;
}
extern char end[];
-static char *top = (char *)end;
+static char *top = (char*)end;
void *
alloc(size)
@@ -481,3 +446,31 @@ romclose(f)
{
return 0;
}
+
+#ifdef USE_PRINTF
+void
+putchar(int ch)
+{
+ /*
+ * On KA88 we may get C-S/C-Q from the console.
+ * Must obey it.
+ */
+ while (mfpr(PR_RXCS) & GC_DON) {
+ if ((mfpr(PR_RXDB) & 0x7f) == 19) {
+ while (1) {
+ while ((mfpr(PR_RXCS) & GC_DON) == 0)
+ ;
+ if ((mfpr(PR_RXDB) & 0x7f) == 17)
+ break;
+ }
+ }
+ }
+
+ while ((mfpr(PR_TXCS) & GC_RDY) == 0)
+ ;
+ mtpr(0, PR_TXCS);
+ mtpr(ch & 0377, PR_TXDB);
+ if (ch == 10)
+ putchar(13);
+}
+#endif
diff --git a/sys/arch/vax/stand/xxboot/start.s b/sys/arch/vax/stand/xxboot/start.S
index f39ecafab62..309b53f308e 100644
--- a/sys/arch/vax/stand/xxboot/start.s
+++ b/sys/arch/vax/stand/xxboot/start.S
@@ -1,5 +1,5 @@
-/* $OpenBSD: start.s,v 1.3 2000/11/25 21:33:08 hugh Exp $ */
-/* $NetBSD: start.s,v 1.2 1999/10/23 14:40:38 ragge Exp $ */
+/* $OpenBSD: start.S,v 1.1 2002/06/11 09:36:24 hugh Exp $ */
+/* $NetBSD: start.S,v 1.1 2002/02/24 01:04:26 matt Exp $ */
/*
* Copyright (c) 1995 Ludd, University of Lule}, Sweden.
* All rights reserved.
@@ -17,8 +17,8 @@
* 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 at Ludd, University of
- * Lule}, Sweden and its contributors.
+ * This product includes software developed at Ludd, University of
+ * Lule}, Sweden and its contributors.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission
*
@@ -37,15 +37,17 @@
/* All bugs are subject to removal without further notice */
-#define _LOCORE
+#define _LOCORE
#include "sys/disklabel.h"
#include "../include/mtpr.h"
#include "../include/asm.h"
-_start: .globl _start # this is the symbolic name for the start
- # of code to be relocated. We can use this
+_C_LABEL(_start):
+_C_LABEL(start):
+ .globl _C_LABEL(start) # this is the symbolic name for the start
+ .globl _C_LABEL(_start) # of code to be relocated. We can use this
# to get the actual/real adress (pc-rel)
# or to get the relocated address (abs).
@@ -53,7 +55,7 @@ _start: .globl _start # this is the symbolic name for the start
brb from_0x00 # continue behind dispatch-block
.org 0x02 # information used by uVAX-ROM
- .byte (LABELOFFSET + d_end_)/2 # offset in words to identification area
+ .byte 0xff # 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
@@ -61,38 +63,53 @@ _start: .globl _start # this is the symbolic name for the start
.org 0x08 #
brb from_0x08 # skip ...
-.org 0x0A # uVAX booted from disk starts here
- brb from_0x0A # skip ...
-
.org 0x0C # 11/750 & 8200 starts here
+ movzbl $1,_C_LABEL(from)# We booted from "old" rom.
brw cont_750
from_0x00: # uVAX from TK50
-from_0x0A: # uVAX from disk
- brw start_uvax # all(?) uVAXen continue there
-
-from_0x08: # What comes here???
- halt
+ brw start_uvax # all uVAXen continue there
-.org LABELOFFSET - 6
-regmask: .word 0x0fff # using a variable saves 3 bytes !!!
-bootinfo: .long 0x0 # another 3 bytes if within byte-offset
+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.
+ */
+ movl 52(r11), r7 # load iovec/bqo into %r7
+ addl3 (r7), r7, r6 # load qio into %r6
+ pushl r11 # base of rpb
+ pushl $0 # virtual-flag
+ pushl $33 # read-logical-block
+ pushl $1 # lbn to start reading
+ pushl $7680 # number of bytes to read
+ pushab start_uvax # buffer-address
+ calls $6, (r6) # call the qio-routine
+ brw start_uvax
+
/*
* Parameter block for uVAX boot.
*/
-#define VOLINFO 0 /* 1=single-sided 81=double-sided volumes */
-#define SISIZE 16 /* size in blocks of secondary image */
-#define SILOAD 0 /* load offset (usually 0) from the default */
-#define SIOFF 0x0A /* byte offset into secondary image */
+#define VOLINFO 0 /* 1=single-sided 81=double-sided volumes */
+#define SISIZE 16 /* size in blocks of secondary image */
+#define SILOAD 0 /* load offset (usually 0) from the default */
+#define SIOFF 0x260 /* byte offset into secondary image */
-.org LABELOFFSET + d_end_
+.org 0x1fe
.byte 0x18 # must be 0x18
.byte 0x00 # must be 0x00 (MBZ)
.byte 0x00 # any value
@@ -106,15 +123,21 @@ bootinfo: .long 0x0 # another 3 bytes if within byte-offset
.long SISIZE # size in blocks of secondary image
.long SILOAD # load offset (usually 0)
- .long SIOFF # byte offset into secondary image
+ .long SIOFF # byte offset into secondary image
.long (SISIZE + SILOAD + SIOFF) # sum of previous 3
+
+ .align 2
+ .globl _C_LABEL(from)
+_C_LABEL(from):
+ .long 0
+
/*
* After bootblock (LBN0) has been loaded into the first page
* of good memory by 11/750's ROM-code (transfer address
* of bootblock-code is: base of good memory + 0x0C) registers
* are initialized as:
- * R0: type of boot-device
+ * R0: type of boot-device
* 0: Massbus device
* 1: RK06/RK07
* 2: RL02
@@ -123,35 +146,39 @@ bootinfo: .long 0x0 # another 3 bytes if within byte-offset
* 64: TU58
* R1: (UBA) address of UNIBUS I/O-page
* (MBA) address of boot device's adapter
- * R2: (UBA) address of the boot device's CSR
+ * R2: (UBA) address of the boot device's CSR
* (MBA) controller number of boot device
* R6: address of driver subroutine in ROM
*
* cont_750 reads in LBN1-15 for further execution.
*/
- .align 2
cont_750:
- movl r0,r10
- clrl r5
- clrl r4
- movl $_start,sp
-1: incl r4
- movl r4,r8
- addl2 $0x200,r5
- cmpl $16,r4
- beql 2f
- pushl r5
- jsb (r6)
- blbs r0,1b
-2: movl r10, r0
- movl r11, r5
- brw start_all
-
- .org 0x300
+ movl $_C_LABEL(start), sp # move stack to avoid clobbering the code
+ pushr $0x131 # save clobbered registers
+ clrl r4 # %r4 == # of blocks transferred
+ movab _C_LABEL(start),r5 # %r5 have base address for next transfer
+ pushl r5 # ...on stack also (Why?)
+1: incl r4 # increment block count
+ movl r4,r8 # LBN is in %r8 for rom routine
+ addl2 $0x200,r5 # Increase address for next read
+ cmpl $16,r4 # read 15 blocks?
+ beql 2f # Yep
+ movl r5,(sp) # move address to stack also
+ jsb (r6) # read 512 bytes
+ blbs r0,1b # jump if read succeeded
+ halt # otherwise die...
+2: tstl (sp)+ # remove boring arg from stack
+ popr $0x131 # restore clobbered registers
+ brw start_all # Ok, continue...
+
+/* uVAX main entry is at the start of the second disk block. This is
+ * needed for multi-arch CD booting where multiple architecture need
+ * to shove stuff in boot block 0.
+ */
+ .org 0x260 # uVAX booted from disk starts here
start_uvax:
- mtpr $0, $PR_MAPEN # Turn off MM, please.
- movl $_start, sp
+ movzbl $2,_C_LABEL(from) # Booted from subset-VMB
brb start_all
/*
@@ -159,20 +186,23 @@ start_uvax:
* to RELOC and loads boot.
*/
start_all:
+ movl $_C_LABEL(start), sp # move stack to a better
pushr $0x1fff # save all regs, used later.
- subl3 $_start, $_edata, r0 # get size of text+data (w/o bss)
- moval _start, r1 # get actual base-address of code
- subl3 $_start, $_end, r2 # get complete size (incl. bss)
- movl $_start, r3 # get relocated base-address of code
+ subl3 $_C_LABEL(start), $_C_LABEL(edata), r0
+ # get size of text+data (w/o bss)
+ moval _C_LABEL(start), r1 # get actual base-address of code
+ subl3 $_C_LABEL(start), $_C_LABEL(end), r2
+ # get complete size (incl. bss)
+ movl $_C_LABEL(start), r3 # get relocated base-address of code
movc5 r0, (r1), $0, r2, (r3) # copy code to new location
- jsb 1f
-1: movl $relocated, (sp) # return-address on top of stack
- rsb # can be replaced with new address
+ movpsl -(sp)
+ movl $relocated, -(sp) # return-address on top of stack
+ rei # can be replaced with new address
relocated: # now relocation is done !!!
- movl sp, _bootregs
- calls $0, _Xmain # call Xmain (gcc workaround)which is
+ movl sp, _C_LABEL(bootregs)
+ calls $0, _C_LABEL(Xmain) # call Xmain (gcc workaround)which is
halt # not intended to return ...
/*
@@ -180,20 +210,32 @@ relocated: # now relocation is done !!!
*/
ENTRY(hoppabort, 0)
movl 4(ap),r6
- movl 8(ap),r11
- movl 0xc(ap),r10
- movl _memsz, r8
- mnegl $1, ap # Hack to figure out boot device.
- jmp 2(r6)
-# calls $0,(r6)
+ movl _C_LABEL(rpb),r11
+ mnegl $1,ap # Hack to figure out boot device.
+ movpsl -(sp)
+ pushab 2(r6)
+ mnegl $1,_C_LABEL(vax_load_failure)
+ rei
+# calls $0,(r6)
halt
+ENTRY(unit_init, R6|R7|R8|R9|R10|R11)
+ mfpr $17,r7 # Wanted bu KDB
+ movl 4(ap),r0 # init routine address
+ movl 8(ap),r9 # RPB in %r9
+ movl 12(ap),r1 # VMB argument list
+ callg (r1),(r0)
+ ret
+
# A bunch of functions unwanted in boot blocks.
ENTRY(getchar, 0)
halt
+#ifndef USE_PRINTF
ENTRY(putchar, 0)
ret
+#endif
+
ENTRY(panic, 0)
halt