summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/arch/hppa/stand/libsa/ct.c56
-rw-r--r--sys/arch/hppa/stand/libsa/dk.c208
2 files changed, 33 insertions, 231 deletions
diff --git a/sys/arch/hppa/stand/libsa/ct.c b/sys/arch/hppa/stand/libsa/ct.c
index 21751ec8943..8556c36b1dd 100644
--- a/sys/arch/hppa/stand/libsa/ct.c
+++ b/sys/arch/hppa/stand/libsa/ct.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ct.c,v 1.2 1998/07/08 21:34:33 mickey Exp $ */
+/* $OpenBSD: ct.c,v 1.3 1998/09/29 07:20:44 mickey Exp $ */
/* $NOWHERE: ct.c,v 2.2 1998/06/22 18:41:34 mickey Exp $ */
/*
@@ -30,7 +30,6 @@
* (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 1996 1995 by Open Software Foundation, Inc.
* All Rights Reserved
@@ -59,13 +58,14 @@
#include <sys/disklabel.h>
#include <sys/reboot.h>
#include <machine/pdc.h>
-#include <machine/iodc.h>
#include <machine/iomod.h>
#include "dev_hppa.h"
+struct pz_device ctdev;
iodcio_t ctiodc; /* cartridge tape IODC entry point */
int ctcode[IODC_MAXSIZE/sizeof(int)];
+char ctbuf[IODC_MAXSIZE] __attribute__ ((aligned(MINIOSIZ)));
/* hp800-specific comments:
*
@@ -91,8 +91,7 @@ ctopen(f)
struct open_file *f;
#endif
{
- struct hppa_dev *dp = f->f_devdata;
- int i, ret, part = B_PARTITION(dp->bootdev);
+ int ret;
if (ctiodc == 0) {
@@ -105,29 +104,10 @@ ctopen(f)
}
if (ctiodc != NULL)
- if ((ret = (*ctiodc)(ctdev.pz_hpa, IODC_IO_BOOTIN, ctdev.pz_spa,
- ctdev.pz_layers, pdcbuf,0, btbuf,0,0)) < 0)
+ if ((ret = (*ctiodc)(ctdev.pz_hpa, IODC_IO_READ, ctdev.pz_spa,
+ ctdev.pz_layers, pdcbuf,0, ctbuf,0,0)) < 0)
printf("ct: device rewind ret'd %d\n", ret);
- ctbyteno = 0;
- for (i = part; --i >= 0; ) {
- ctworking = 0;
- for (;;) {
- ret = iodc_rw(btbuf, ctbyteno, IONBPG, F_READ, &ctdev);
- ctbyteno += IONBPG;
- if (ret <= 0)
- break;
- ctworking = 1;
- }
- if (ret < 0 && (ret != -4 || !ctworking)) {
- printf("ct: error %d after %d %d-byte records\n",
- ret, ctbyteno >> IOPGSHIFT, IONBPG);
- ctbyteno = 0;
- ctworking = 0;
- return (EIO);
- }
- }
- ctworking = 0;
return (0);
}
@@ -141,27 +121,3 @@ ctclose(f)
return 0;
}
-
-int
-ctstrategy(devdata, rw, dblk, size, buf, rsize)
- void *devdata;
- int rw;
- daddr_t dblk;
- size_t size;
- void *buf;
- size_t *rsize;
-{
- int ret;
-
- if ((ret = iodc_rw(buf, ctbyteno, size, rw, &ctdev)) < 0) {
- if (ret == -4 && ctworking)
- ret = 0;
-
- ctworking = 0;
- } else {
- ctworking = 1;
- ctbyteno += ret;
- }
-
- return (ret);
-}
diff --git a/sys/arch/hppa/stand/libsa/dk.c b/sys/arch/hppa/stand/libsa/dk.c
index 86c48e4066e..c0e2931bbf8 100644
--- a/sys/arch/hppa/stand/libsa/dk.c
+++ b/sys/arch/hppa/stand/libsa/dk.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dk.c,v 1.2 1998/07/08 21:34:34 mickey Exp $ */
+/* $OpenBSD: dk.c,v 1.3 1998/09/29 07:20:45 mickey Exp $ */
/*
* Copyright 1996 1995 by Open Software Foundation, Inc.
@@ -28,157 +28,23 @@
#include <sys/disklabel.h>
#include <sys/reboot.h>
#include <machine/pdc.h>
-#include <machine/iodc.h>
#include <machine/iomod.h>
#include "dev_hppa.h"
-iodcio_t btiodc; /* boot IODC entry point */
-
-char btbuf[BTIOSIZ] __attribute ((aligned (MINIOSIZ)));
-int HP800;
-
-void
-btinit()
-{
- int err;
- static int firstime = 1;
-
- btiodc = (iodcio_t)(PAGE0->mem_free + IODC_MAXSIZE);
-
- if (firstime) {
- /*
- * If we _rtt(), we will call btinit() again.
- * We only want to do ctdev initialization once.
- */
- bcopy((char *)&PAGE0->mem_boot, (char *)&ctdev,
- sizeof(struct pz_device));
- firstime = 0;
- }
-
- /*
- * Initialize "HP800" to boolean value (T=HP800 F=HP700).
- */
- if (!HP800) {
- struct pdc_model model;
- err = (*pdc)(PDC_MODEL, PDC_MODEL_INFO, &model, 0,0,0,0,0);
- if (err < 0) {
- HP800 = 1; /* default: HP800 */
- printf("Proc model info ret'd %d (assuming %s)\n",
- err, HP800? "HP800": "HP700");
- }
- HP800 = (((model.hvers >> 4) & 0xfff) < 0x200);
- }
-}
-
-int
-dkreset(slot, unit)
- int slot, unit;
-{
- struct device_path bootdp;
- int err, srchtype;
-
- /*
- * Save a copy of the previous boot device path.
- */
- bcopy((char *)&PAGE0->mem_boot.pz_dp, (char *)&bootdp,
- sizeof(struct device_path));
-
- /*
- * Read the boot device initialization code into memory.
- */
- err = (*pdc)(PDC_IODC, PDC_IODC_READ, pdcbuf, BT_HPA, IODC_INIT,
- btiodc, IODC_MAXSIZE);
- if (err < 0) {
- printf("Boot module ENTRY_INIT Read ret'd %d\n", err);
- goto bad;
- }
-
- /*
- * Plod over boot devices looking for one with the same unit
- * number as that which is in `unit'.
- */
- srchtype = IODC_INIT_FIRST;
- while (1) {
- err = (*btiodc)(BT_HPA,srchtype,BT_SPA,BT_LAYER,pdcbuf,0,0,0,0);
- if (err < 0) {
- if (err == -9) {
- BT_IODC = 0;
- return(EUNIT);
- }
- printf("Boot module ENTRY_INIT Search ret'd %d\n", err);
- goto bad;
- }
-
- srchtype = IODC_INIT_NEXT; /* for next time... */
-
- if (pdcbuf[1] != PCL_RANDOM) /* only want disks */
- continue;
-
- if (HP800) {
- if (slot != ANYSLOT && slot != BT_LAYER[0])
- continue;
-
- if (BT_LAYER[1] == unit) {
- BT_CLASS = pdcbuf[1];
- break;
- }
- } else {
- if (slot != NOSLOT)
- continue;
-
- if (BT_LAYER[0] == unit) {
- BT_CLASS = pdcbuf[1];
- break;
- }
- }
- }
-
- /*
- * If this is not the "currently initialized" boot device,
- * initialize the new boot device we just found.
- *
- * N.B. We do not need/want to initialize the entire module
- * (e.g. CIO, SCSI), and doing so may blow away our console.
- * if the user specified a boot module other than the
- * console module, we initialize both the module and device.
- */
- if (bcmp((char *)&PAGE0->mem_boot.pz_dp, (char *)&bootdp,
- sizeof(struct device_path)) != 0) {
- err = (*btiodc)(BT_HPA,(!HP800||BT_HPA==CN_HPA||BT_HPA==KY_HPA)?
- IODC_INIT_DEV: IODC_INIT_ALL,
- BT_SPA, BT_LAYER, pdcbuf, 0,0,0,0);
- if (err < 0) {
- printf("Boot module/device IODC Init ret'd %d\n", err);
- goto bad;
- }
- }
-
- err = (*pdc)(PDC_IODC, PDC_IODC_READ, pdcbuf, BT_HPA, IODC_IO,
- btiodc, IODC_MAXSIZE);
- if (err < 0) {
- printf("Boot device ENTRY_IO Read ret'd %d\n", err);
- goto bad;
- }
-
- BT_IODC = btiodc;
- return (0);
-bad:
- BT_IODC = 0;
- return(-1);
-}
+iodcio_t dkiodc; /* boot IODC entry point */
const char *
dk_disklabel(dp, label)
struct hppa_dev *dp;
struct disklabel *label;
{
- char buf[DEV_BSIZE];
+ char buf[IONBPG];
size_t ret;
- if (dkstrategy(dp, F_READ, LABELOFFSET, DEV_BSIZE, buf, &ret) ||
- ret != DEV_BSIZE)
- return "cannot read disklbael";
+ if (iodcstrategy(dp, F_READ, LABELSECTOR, IONBPG, buf, &ret))
+ if (ret != DEV_BSIZE)
+ return "cannot read LIF header";
return (getdisklabel(buf, label));
}
@@ -193,37 +59,36 @@ dkopen(f, va_alist)
{
struct disklabel *lp;
struct hppa_dev *dp;
+ struct pz_device *pzd;
const char *st;
int i;
+#ifdef DEBUG
+ printf("dkopen(%p)\n", f);
+#endif
+
+ if (!(pzd = pdc_findev(-1, PCL_RANDOM)))
+ return ENXIO;
+#ifdef PDCDEBUG
+ else if (debug)
+ PZDEV_PRINT(pzd);
+#endif
+
if (f->f_devdata == 0)
f->f_devdata = alloc(sizeof *dp);
dp = f->f_devdata;
bzero(dp, sizeof *dp);
- {
- int adapt, ctlr, unit, part, type;
- va_list ap;
-
-#ifdef __STDC__
- va_start(ap, f);
-#else
- va_start(ap);
-#endif
- adapt = va_arg(ap, int);
- ctlr = va_arg(ap, int);
- unit = va_arg(ap, int);
- part = va_arg(ap, int);
- type = va_arg(ap, int);
- va_end(ap);
-
- dp->bootdev = MAKEBOOTDEV(type, adapt, ctlr, unit, part);
- }
- lp = &dp->label;
+ dp->bootdev = bootdev;
+ dp->pz_dev = pzd;
+ lp = dp->label;
if ((st = dk_disklabel(dp, lp)) != NULL) {
- printf ("%s\n", st);
+#ifdef DEBUG
+ if (debug)
+ printf ("%s\n", st);
+#endif
return ERDLAB;
}
@@ -237,29 +102,10 @@ dkopen(f, va_alist)
}
int
-dkstrategy(devdata, rw, blk, size, buf, rsize)
- void *devdata;
- int rw;
- daddr_t blk;
- size_t size;
- void *buf;
- size_t *rsize;
-{
- int ret;
-
- ret = iodc_rw(buf, blk, size, rw, &PAGE0->mem_boot);
- if (ret < 0) {
- printf("dk: iodc ret'd %d\n", ret);
- return (-1);
- }
-
- *rsize = ret;
- return (ret);
-}
-
-int
dkclose(f)
struct open_file *f;
{
+ free (f->f_devdata, sizeof(struct hppa_dev));
+ f->f_devdata = NULL;
return 0;
}