diff options
author | Hugh Graham <hugh@cvs.openbsd.org> | 2002-06-11 09:36:25 +0000 |
---|---|---|
committer | Hugh Graham <hugh@cvs.openbsd.org> | 2002-06-11 09:36:25 +0000 |
commit | 10ca5e5818bb80e596db244327a2663b6703bb18 (patch) | |
tree | c7ac330b34d73ea4e0c78d17a9eed0a3b6df63aa /sys/arch/vax/stand/boot/hp.c | |
parent | 180b34af9885b092bee0f67c5b2ac8577d972cfe (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/boot/hp.c')
-rw-r--r-- | sys/arch/vax/stand/boot/hp.c | 144 |
1 files changed, 66 insertions, 78 deletions
diff --git a/sys/arch/vax/stand/boot/hp.c b/sys/arch/vax/stand/boot/hp.c index 30f29ae1101..a45e4ae3687 100644 --- a/sys/arch/vax/stand/boot/hp.c +++ b/sys/arch/vax/stand/boot/hp.c @@ -1,5 +1,5 @@ -/* $OpenBSD: hp.c,v 1.1 2000/04/27 02:26:25 bjc Exp $ */ -/* $NetBSD: hp.c,v 1.2 1999/04/01 20:40:07 ragge Exp $ */ +/* $OpenBSD: hp.c,v 1.2 2002/06/11 09:36:23 hugh Exp $ */ +/* $NetBSD: hp.c,v 1.5 2000/07/19 00:58:25 matt Exp $ */ /* * Copyright (c) 1994 Ludd, University of Lule}, Sweden. * All rights reserved. @@ -40,7 +40,11 @@ #include "lib/libsa/stand.h" #include "../include/pte.h" -/*#include "../include/macros.h"*/ +#include "../include/rpb.h" +#include "../include/sid.h" +#define VAX780 1 +struct proc; +#include "../include/ka750.h" #include "../mba/mbareg.h" #include "../mba/hpreg.h" @@ -54,113 +58,97 @@ * But it works :) */ -struct hp_softc { - int adapt; - int ctlr; - int unit; - int part; -}; - -struct disklabel hplabel; -struct hp_softc hp_softc; -char io_buf[DEV_BSIZE]; -daddr_t part_offset; - -hpopen(f, adapt, ctlr, unit, part) - struct open_file *f; - int ctlr, unit, part; +static struct disklabel hplabel; +static char io_buf[DEV_BSIZE]; +static int dpart; +static int adpadr, unitadr; + +#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))) + +int +hpopen(struct open_file *f, int adapt, int ctlr, int unit, int part) { - struct disklabel *lp; - struct hp_softc *hs; - volatile struct mba_regs *mr; - volatile struct hp_drv *hd; char *msg; - int i,err; - - lp = &hplabel; - hs = &hp_softc; - mr = (void *)mbaaddr[ctlr]; - hd = (void *)&mr->mba_md[unit]; - - if (adapt > nsbi) return(EADAPT); - if (ctlr > nmba) return(ECTLR); - if (unit > MAXMBAU) return(EUNIT); - - bzero(lp, sizeof(struct disklabel)); + int err; + size_t i; + + if (askname == 0) { /* Take info from RPB */ + adpadr = bootrpb.adpphy; + unitadr = adpadr + MUREG(bootrpb.unit, 0); + } else { + adpadr = nexaddr; + unitadr = adpadr + MUREG(unit, 0); + bootrpb.adpphy = adpadr; + bootrpb.unit = unit; + } + bzero(&hplabel, sizeof(struct disklabel)); - lp->d_secpercyl = 32; - lp->d_nsectors = 32; - hs->adapt = adapt; - hs->ctlr = ctlr; - hs->unit = unit; - hs->part = part; + hplabel.d_secpercyl = 32; + hplabel.d_nsectors = 32; /* Set volume valid and 16 bit format; only done once */ - mr->mba_cr = MBACR_INIT; - hd->hp_cs1 = HPCS_PA; - hd->hp_of = HPOF_FMT; + MBA_WCSR(MBA_CR, MBACR_INIT); + HP_WCSR(HP_CS1, HPCS_PA); + HP_WCSR(HP_OF, HPOF_FMT); - err = hpstrategy(hs, F_READ, LABELSECTOR, DEV_BSIZE, io_buf, &i); + err = hpstrategy(0, F_READ, LABELSECTOR, DEV_BSIZE, io_buf, &i); if (err) { printf("reading disklabel: %s\n", strerror(err)); return 0; } - msg = getdisklabel(io_buf + LABELOFFSET, lp); + msg = getdisklabel(io_buf + LABELOFFSET, &hplabel); if (msg) printf("getdisklabel: %s\n", msg); - - f->f_devdata = (void *)hs; return 0; } -hpstrategy(hs, func, dblk, size, buf, rsize) - struct hp_softc *hs; - daddr_t dblk; - u_int size, *rsize; - char *buf; - int func; +int +hpstrategy(void *f, int func, daddr_t dblk, + size_t size, void *buf, size_t *rsize) { - volatile struct mba_regs *mr; - volatile struct hp_drv *hd; - struct disklabel *lp; - unsigned int i, pfnum, mapnr, nsize, bn, cn, sn, tn; - - mr = (void *)mbaaddr[hs->ctlr]; - hd = (void *)&mr->mba_md[hs->unit]; - lp = &hplabel; + unsigned int pfnum, mapnr, nsize, bn, cn, sn, tn; pfnum = (u_int)buf >> VAX_PGSHIFT; - for(mapnr = 0, nsize = size; (nsize + VAX_NBPG) > 0; nsize -= VAX_NBPG) - *(int *)&mr->mba_map[mapnr++] = PG_V | pfnum++; + for(mapnr = 0, nsize = size; (nsize + VAX_NBPG) > 0; + nsize -= VAX_NBPG, mapnr++, pfnum++) + MBA_WCSR(MAPREG(mapnr), PG_V | pfnum); - mr->mba_var = ((u_int)buf & VAX_PGOFSET); - mr->mba_bc = (~size) + 1; - bn = dblk + lp->d_partitions[hs->part].p_offset; + MBA_WCSR(MBA_VAR, ((u_int)buf & VAX_PGOFSET)); + MBA_WCSR(MBA_BC, (~size) + 1); + bn = dblk + hplabel.d_partitions[dpart].p_offset; if (bn) { - cn = bn / lp->d_secpercyl; - sn = bn % lp->d_secpercyl; - tn = sn / lp->d_nsectors; - sn = sn % lp->d_nsectors; + cn = bn / hplabel.d_secpercyl; + sn = bn % hplabel.d_secpercyl; + tn = sn / hplabel.d_nsectors; + sn = sn % hplabel.d_nsectors; } else cn = sn = tn = 0; - hd->hp_dc = cn; - hd->hp_da = (tn << 8) | sn; + HP_WCSR(HP_DC, cn); + HP_WCSR(HP_DA, (tn << 8) | sn); +#ifdef notdef if (func == F_WRITE) - hd->hp_cs1 = HPCS_WRITE; + HP_WCSR(HP_CS1, HPCS_WRITE); else - hd->hp_cs1 = HPCS_READ; +#endif + HP_WCSR(HP_CS1, HPCS_READ); - while (mr->mba_sr & MBASR_DTBUSY) + while (MBA_RCSR(MBA_SR) & MBASR_DTBUSY) ; - if (mr->mba_sr & MBACR_ABORT) + if (MBA_RCSR(MBA_SR) & MBACR_ABORT) return 1; - - *rsize = size; + *rsize = size; return 0; } |