diff options
author | Michael Shalayeff <mickey@cvs.openbsd.org> | 1998-09-29 07:31:00 +0000 |
---|---|---|
committer | Michael Shalayeff <mickey@cvs.openbsd.org> | 1998-09-29 07:31:00 +0000 |
commit | 3888db5b76ec0c80dae00e944842b3cef9d743f5 (patch) | |
tree | 39fdb040b0a37d61891e86dc656f6f50e2c10a0d /sys/arch/hppa | |
parent | 881d5adf35bf89f15ff9b00e08d0135373bc9668 (diff) |
sync; fixes; cleanup
get rid of those obscuring commands
use device finger/mapper, thus rewrite devopen
Diffstat (limited to 'sys/arch/hppa')
-rw-r--r-- | sys/arch/hppa/stand/libsa/dev_hppa.c | 62 | ||||
-rw-r--r-- | sys/arch/hppa/stand/libsa/dev_hppa.h | 59 |
2 files changed, 78 insertions, 43 deletions
diff --git a/sys/arch/hppa/stand/libsa/dev_hppa.c b/sys/arch/hppa/stand/libsa/dev_hppa.c index 8f7583bb257..faee0acd16b 100644 --- a/sys/arch/hppa/stand/libsa/dev_hppa.c +++ b/sys/arch/hppa/stand/libsa/dev_hppa.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dev_hppa.c,v 1.1 1998/06/23 18:46:42 mickey Exp $ */ +/* $OpenBSD: dev_hppa.c,v 1.2 1998/09/29 07:30:59 mickey Exp $ */ /* $NOWHERE: dev_hppa.c,v 2.1 1998/06/17 20:51:54 mickey Exp $ */ /* @@ -39,9 +39,9 @@ #include <sys/reboot.h> #include <dev/cons.h> -#include "dev_hppa.h" +#include <machine/iomod.h> -struct pz_device ctdev; /* cartridge tape (boot) device path */ +#include "dev_hppa.h" extern int debug; @@ -56,11 +56,12 @@ const struct pdc_devs { int dev_type; } pdc_devs[] = { { "ct", 0 }, + { "sd", 1 }, + { "lf", 2 }, { "", -1 }, { "rd", -1 }, { "sw", -1 }, - { "fl", 1 }, - { "sd", 1 }, + { "fl", -1 }, }; /* pass dev_t to the open routines */ @@ -73,37 +74,70 @@ devopen(f, fname, file) register const struct pdc_devs *dp = pdc_devs; register int rc = 1; - *file = (char *)fname; + if (!(*file = strchr(fname, ':'))) + return ENODEV; + else + (*file)++; #ifdef DEBUG if (debug) - printf("devopen:"); + printf("devopen: "); #endif for (dp = pdc_devs; dp < &pdc_devs[NENTS(pdc_devs)]; dp++) - if (strncmp(fname, dp->name, sizeof(dp->name)-1)) + if (!strncmp(fname, dp->name, sizeof(dp->name)-1)) break; if (dp >= &pdc_devs[NENTS(pdc_devs)] || dp->dev_type < 0) return ENODEV; +#ifdef DEBUG + if (debug) + printf("%s\n", dp->name); +#endif if ((rc = (*devsw[dp->dev_type].dv_open)(f, file)) == 0) { f->f_dev = &devsw[dp->dev_type]; return 0; } - if ((f->f_flags & F_NODEV) == 0) + if (!(f->f_flags & F_NODEV)) f->f_dev = &devsw[dp->dev_type]; + if (!f->f_devdata) + *file = NULL; + return rc; } void -devboot(bootdev, p) - dev_t bootdev; +devboot(dev, p) + dev_t dev; char *p; { register const char *q; + if (!dev) { + int type, unit; + + switch (PAGE0->mem_boot.pz_class) { + case PCL_RANDOM: + type = 0; + unit = PAGE0->mem_boot.pz_layers[0]; + break; + case PCL_SEQU: + type = 1; + unit = PAGE0->mem_boot.pz_layers[0]; + break; + case PCL_NET_MASK|PCL_SEQU: + type = 2; + unit = 0; + break; + default: + type = 0; + unit = 0; + break; + } + dev = bootdev = MAKEBOOTDEV(type, 0, 0, unit, 0); + } #ifdef _TEST *p++ = '/'; *p++ = 'd'; @@ -113,9 +147,9 @@ devboot(bootdev, p) *p++ = 'r'; #endif /* quick copy device name */ - for (q = pdc_devs[B_TYPE(bootdev)].name; (*p++ = *q++);); - *p++ = '0' + B_UNIT(bootdev); - *p++ = 'a' + B_PARTITION(bootdev); + for (q = pdc_devs[B_TYPE(dev)].name; (*p++ = *q++);); + p[-1] = '0' + B_UNIT(dev); + *p++ = 'a' + B_PARTITION(dev); *p = '\0'; } diff --git a/sys/arch/hppa/stand/libsa/dev_hppa.h b/sys/arch/hppa/stand/libsa/dev_hppa.h index d7dd2ec23dd..99e59722734 100644 --- a/sys/arch/hppa/stand/libsa/dev_hppa.h +++ b/sys/arch/hppa/stand/libsa/dev_hppa.h @@ -1,41 +1,42 @@ -/* $OpenBSD: dev_hppa.h,v 1.1 1998/06/23 18:46:42 mickey Exp $ */ +/* $OpenBSD: dev_hppa.h,v 1.2 1998/09/29 07:30:59 mickey Exp $ */ -struct hppa_dev { - dev_t bootdev; - - struct disklabel label; -}; - -#define CN_HPA PAGE0->mem_cons.pz_hpa -#define CN_SPA PAGE0->mem_cons.pz_spa -#define CN_LAYER PAGE0->mem_cons.pz_layers -#define CN_IODC PAGE0->mem_cons.pz_iodc_io -#define CN_CLASS PAGE0->mem_cons.pz_class - -#define KY_HPA PAGE0->mem_kbd.pz_hpa -#define KY_SPA PAGE0->mem_kbd.pz_spa -#define KY_LAYER PAGE0->mem_kbd.pz_layers -#define KY_IODC PAGE0->mem_kbd.pz_iodc_io -#define KY_CLASS PAGE0->mem_kbd.pz_class - -#define BT_HPA PAGE0->mem_boot.pz_hpa -#define BT_SPA PAGE0->mem_boot.pz_spa -#define BT_LAYER PAGE0->mem_boot.pz_layers -#define BT_IODC PAGE0->mem_boot.pz_iodc_io -#define BT_CLASS PAGE0->mem_boot.pz_class #define MINIOSIZ 64 /* minimum buffer size for IODC call */ #define MAXIOSIZ (64 * 1024) /* maximum buffer size for IODC call */ -#define BTIOSIZ (8 * 1024) /* size of boot device I/O buffer */ - #define IONBPG (2 * 1024) /* page alignment for I/O buffers */ #define IOPGSHIFT 11 /* LOG2(IONBPG) */ #define IOPGOFSET (IONBPG-1) /* byte offset into I/O buffer */ +#define BTIOSIZ (8 * 1024) /* size of boot device I/O buffer */ -#define ANYSLOT (-1) -#define NOSLOT (-2) +struct disklabel; +struct hppa_dev { + dev_t bootdev; + struct pz_device *pz_dev; /* device descriptor */ + daddr_t last_blk; /* byte offset for last read blk */ + size_t last_read; /* amount read last time */ + char buf[BTIOSIZ+MINIOSIZ]; /* will be used for unaligned io */ + + struct disklabel *label; +}; -extern char btbuf[]; +#ifdef PDCDEBUG +#define DEVPATH_PRINT(dp) \ + printf("%x, %d.%d.%d.%d.%d.%d, 0x%x, %x.%x.%x.%x.%x.%x\n", \ + (dp)->dp_flags, (dp)->dp_bc[0], (dp)->dp_bc[1], (dp)->dp_bc[2], \ + (dp)->dp_bc[3], (dp)->dp_bc[4], (dp)->dp_bc[5], (dp)->dp_mod, \ + (dp)->dp_layers[0], (dp)->dp_layers[1], (dp)->dp_layers[2], \ + (dp)->dp_layers[3], (dp)->dp_layers[4], (dp)->dp_layers[5]); +#define PZDEV_PRINT(dp) \ + printf("devpath={%x, %d.%d.%d.%d.%d.%d, 0x%x, %x.%x.%x.%x.%x.%x}," \ + "\n\thpa=%p, spa=%p, io=%p, class=%u\n", \ + (dp)->pz_flags, (dp)->pz_bc[0], (dp)->pz_bc[1], (dp)->pz_bc[2], \ + (dp)->pz_bc[3], (dp)->pz_bc[4], (dp)->pz_bc[5], (dp)->pz_mod, \ + (dp)->pz_layers[0], (dp)->pz_layers[1], (dp)->pz_layers[2], \ + (dp)->pz_layers[3], (dp)->pz_layers[4], (dp)->pz_layers[5], \ + (dp)->pz_hpa, (dp)->pz_spa, (dp)->pz_iodc_io, (dp)->pz_class); +#endif + +extern pdcio_t pdc; extern int pdcbuf[]; /* PDC returns, pdc.c */ extern struct pz_device ctdev; /* cartridge tape (boot) device path */ |