1*18411Skarels /* hp.c 6.7 85/03/19 */ 23706Sroot 33706Sroot #ifdef HPDEBUG 43289Swnj int hpdebug; 53706Sroot #endif 63706Sroot #ifdef HPBDEBUG 73706Sroot int hpbdebug; 83706Sroot #endif 921Sbill 101939Swnj #include "hp.h" 111565Sbill #if NHP > 0 1221Sbill /* 135726Sroot * HP disk driver for RP0x+RMxx+ML11 142827Swnj * 152827Swnj * TODO: 163706Sroot * check RM80 skip sector handling when ECC's occur later 173093Swnj * check offset recovery handling 183706Sroot * see if DCLR and/or RELEASE set attention status 193706Sroot * print bits of mr && mr2 symbolically 2021Sbill */ 219786Ssam #include "../machine/pte.h" 2221Sbill 2317120Sbloom #include "param.h" 2417120Sbloom #include "systm.h" 2517120Sbloom #include "dk.h" 2617120Sbloom #include "buf.h" 2717120Sbloom #include "conf.h" 2817120Sbloom #include "dir.h" 2917120Sbloom #include "user.h" 3017120Sbloom #include "map.h" 318468Sroot #include "../vax/mtpr.h" 3217120Sbloom #include "vm.h" 3317120Sbloom #include "cmap.h" 3417120Sbloom #include "dkbad.h" 3517120Sbloom #include "ioctl.h" 3617120Sbloom #include "uio.h" 37*18411Skarels #include "syslog.h" 3821Sbill 398988Sroot #include "../vax/dkio.h" 4017120Sbloom #include "mbareg.h" 4117120Sbloom #include "mbavar.h" 4217120Sbloom #include "hpreg.h" 4321Sbill 442383Swnj /* THIS SHOULD BE READ OFF THE PACK, PER DRIVE */ 452383Swnj struct size { 4621Sbill daddr_t nblocks; 4721Sbill int cyloff; 4811212Ssam } rp06_sizes[8] = { 49886Sbill 15884, 0, /* A=cyl 0 thru 37 */ 50886Sbill 33440, 38, /* B=cyl 38 thru 117 */ 51886Sbill 340670, 0, /* C=cyl 0 thru 814 */ 5211212Ssam 15884, 118, /* D=cyl 118 thru 155 */ 5311212Ssam 55936, 156, /* E=cyl 156 thru 289 */ 5411212Ssam 219384, 290, /* F=cyl 290 thru 814 */ 5511212Ssam 291280, 118, /* G=cyl 118 thru 814 */ 5621Sbill 0, 0, 5711212Ssam }, rp05_sizes[8] = { 5811212Ssam 15884, 0, /* A=cyl 0 thru 37 */ 5911212Ssam 33440, 38, /* B=cyl 38 thru 117 */ 6011212Ssam 171798, 0, /* C=cyl 0 thru 410 */ 6111212Ssam 15884, 118, /* D=cyl 118 thru 155 */ 6211212Ssam 55936, 156, /* E=cyl 156 thru 289 */ 6311212Ssam 50512, 290, /* F=cyl 290 thru 410 */ 6411212Ssam 122408, 118, /* G=cyl 118 thru 410 */ 6521Sbill 0, 0, 6611212Ssam }, rm03_sizes[8] = { 67886Sbill 15884, 0, /* A=cyl 0 thru 99 */ 6811212Ssam 33440, 100, /* B=cyl 100 thru 308 */ 69886Sbill 131680, 0, /* C=cyl 0 thru 822 */ 7011212Ssam 15884, 309, /* D=cyl 309 thru 408 */ 7111212Ssam 55936, 409, /* E=cyl 409 thru 758 */ 7211212Ssam 10144, 759, /* F=cyl 759 thru 822 */ 7311212Ssam 82144, 309, /* G=cyl 309 thru 822 */ 7421Sbill 0, 0, 7511212Ssam }, rm05_sizes[8] = { 76886Sbill 15884, 0, /* A=cyl 0 thru 26 */ 77886Sbill 33440, 27, /* B=cyl 27 thru 81 */ 783271Swnj 500384, 0, /* C=cyl 0 thru 822 */ 79886Sbill 15884, 562, /* D=cyl 562 thru 588 */ 80886Sbill 55936, 589, /* E=cyl 589 thru 680 */ 813729Sroot 86240, 681, /* F=cyl 681 thru 822 */ 823729Sroot 158592, 562, /* G=cyl 562 thru 822 */ 83886Sbill 291346, 82, /* H=cyl 82 thru 561 */ 842383Swnj }, rm80_sizes[8] = { 852383Swnj 15884, 0, /* A=cyl 0 thru 36 */ 862383Swnj 33440, 37, /* B=cyl 37 thru 114 */ 872383Swnj 242606, 0, /* C=cyl 0 thru 558 */ 8811212Ssam 15884, 115, /* D=cyl 115 thru 151 */ 8911212Ssam 55936, 152, /* E=cyl 152 thru 280 */ 9011212Ssam 120559, 281, /* F=cyl 281 thru 558 */ 9111212Ssam 192603, 115, /* G=cyl 115 thru 558 */ 922383Swnj 0, 0, 9311212Ssam }, rp07_sizes[8] = { 946927Ssam 15884, 0, /* A=cyl 0 thru 9 */ 9511212Ssam 66880, 10, /* B=cyl 10 thru 51 */ 9611212Ssam 1008000, 0, /* C=cyl 0 thru 629 */ 9711212Ssam 15884, 235, /* D=cyl 235 thru 244 */ 9811212Ssam 307200, 245, /* E=cyl 245 thru 436 */ 9911212Ssam 308650, 437, /* F=cyl 437 thru 629 */ 10011212Ssam 631850, 235, /* G=cyl 235 thru 629 */ 10111212Ssam 291346, 52, /* H=cyl 52 thru 234 */ 10211212Ssam }, cdc9775_sizes[8] = { 10311212Ssam 15884, 0, /* A=cyl 0 thru 12 */ 10411212Ssam 66880, 13, /* B=cyl 13 thru 65 */ 10515101Skarels 1077760, 0, /* C=cyl 0 thru 841 */ 10611212Ssam 15884, 294, /* D=cyl 294 thru 306 */ 10711212Ssam 307200, 307, /* E=cyl 307 thru 546 */ 10815101Skarels 377440, 547, /* F=cyl 547 thru 841 */ 10915101Skarels 701280, 294, /* G=cyl 294 thru 841 */ 11011212Ssam 291346, 66, /* H=cyl 66 thru 293 */ 11111212Ssam }, cdc9730_sizes[8] = { 1126927Ssam 15884, 0, /* A=cyl 0 thru 49 */ 1136927Ssam 33440, 50, /* B=cyl 50 thru 154 */ 1146927Ssam 263360, 0, /* C=cyl 0 thru 822 */ 11511212Ssam 15884, 155, /* D=cyl 155 thru 204 */ 11611212Ssam 55936, 205, /* E=cyl 205 thru 379 */ 11711212Ssam 141664, 380, /* F=cyl 380 thru 822 */ 11811212Ssam 213664, 155, /* G=cyl 155 thru 822 */ 1196927Ssam 0, 0, 12011212Ssam }, capricorn_sizes[8] = { 1216927Ssam 15884, 0, /* A=cyl 0 thru 31 */ 1226927Ssam 33440, 32, /* B=cyl 32 thru 97 */ 1236927Ssam 524288, 0, /* C=cyl 0 thru 1023 */ 12411212Ssam 15884, 668, /* D=cyl 668 thru 699 */ 12511212Ssam 55936, 700, /* E=cyl 700 thru 809 */ 12611212Ssam 109472, 810, /* F=cyl 810 thru 1023 */ 12711212Ssam 182176, 668, /* G=cyl 668 thru 1023 */ 1286927Ssam 291346, 98, /* H=cyl 98 thru 667 */ 12911212Ssam }, eagle_sizes[8] = { 13010734Ssam 15884, 0, /* A=cyl 0 thru 16 */ 13111212Ssam 66880, 17, /* B=cyl 17 thru 86 */ 13211629Ssam 808320, 0, /* C=cyl 0 thru 841 */ 13311212Ssam 15884, 391, /* D=cyl 391 thru 407 */ 13411212Ssam 307200, 408, /* E=cyl 408 thru 727 */ 13511629Ssam 109296, 728, /* F=cyl 728 thru 841 */ 13611629Ssam 432816, 391, /* G=cyl 391 thru 841 */ 13711212Ssam 291346, 87, /* H=cyl 87 thru 390 */ 13813202Sroot }, ampex_sizes[8] = { 13911281Ssam 15884, 0, /* A=cyl 0 thru 26 */ 14011281Ssam 33440, 27, /* B=cyl 27 thru 81 */ 14113184Shelge 495520, 0, /* C=cyl 0 thru 814 */ 14211281Ssam 15884, 562, /* D=cyl 562 thru 588 */ 14311281Ssam 55936, 589, /* E=cyl 589 thru 680 */ 14413184Shelge 81312, 681, /* F=cyl 681 thru 814 */ 14513184Shelge 153664, 562, /* G=cyl 562 thru 814 */ 14611281Ssam 291346, 82, /* H=cyl 82 thru 561 */ 14721Sbill }; 1482383Swnj /* END OF STUFF WHICH SHOULD BE READ IN PER DISK */ 14921Sbill 1506927Ssam /* 1516927Ssam * Table for converting Massbus drive types into 1526927Ssam * indices into the partition tables. Slots are 1536927Ssam * left for those drives devined from other means 1546927Ssam * (e.g. SI, AMPEX, etc.). 1556927Ssam */ 1566927Ssam short hptypes[] = { 1576927Ssam #define HPDT_RM03 0 1586927Ssam MBDT_RM03, 1596927Ssam #define HPDT_RM05 1 1606927Ssam MBDT_RM05, 1616927Ssam #define HPDT_RP06 2 1626927Ssam MBDT_RP06, 1636927Ssam #define HPDT_RM80 3 1646927Ssam MBDT_RM80, 16513157Ssam #define HPDT_RP04 4 16613157Ssam MBDT_RP04, 16713157Ssam #define HPDT_RP05 5 1686927Ssam MBDT_RP05, 16913157Ssam #define HPDT_RP07 6 1706927Ssam MBDT_RP07, 17113157Ssam #define HPDT_ML11A 7 1726927Ssam MBDT_ML11A, 17313157Ssam #define HPDT_ML11B 8 1746927Ssam MBDT_ML11B, 17513157Ssam #define HPDT_9775 9 1766927Ssam -1, 17713157Ssam #define HPDT_9730 10 1786927Ssam -1, 17913157Ssam #define HPDT_CAPRICORN 11 1806927Ssam -1, 18113157Ssam #define HPDT_EAGLE 12 1829175Ssam -1, 18313157Ssam #define HPDT_9300 13 18411281Ssam -1, 18513157Ssam #define HPDT_RM02 14 1869175Ssam MBDT_RM02, /* beware, actually capricorn or eagle */ 1876927Ssam 0 1886927Ssam }; 1892978Swnj struct mba_device *hpinfo[NHP]; 19014145Shelge int hpattach(),hpustart(),hpstart(),hpdtint(); 1912383Swnj struct mba_driver hpdriver = 1922978Swnj { hpattach, 0, hpustart, hpstart, hpdtint, 0, 1932978Swnj hptypes, "hp", 0, hpinfo }; 1942383Swnj 19512836Ssam /* 19616225Skarels * These variable are all measured in sectors. 19716225Skarels * Sdist is how much to "lead" in the search for a desired sector 19816225Skarels * (i.e. if want N, search for N-sdist.) 19916225Skarels * Maxdist and mindist define the region right before our desired sector within 20016225Skarels * which we don't bother searching. We don't search when we are already less 20116225Skarels * then maxdist and more than mindist sectors "before" our desired sector. 20216225Skarels * Maxdist should be >= sdist. 20316225Skarels * 20416225Skarels * Beware, sdist, mindist and maxdist are not well tuned 20512836Ssam * for many of the drives listed in this table. 20612836Ssam * Try patching things with something i/o intensive 20712836Ssam * running and watch iostat. 20812836Ssam */ 2092383Swnj struct hpst { 21012836Ssam short nsect; /* # sectors/track */ 21112836Ssam short ntrak; /* # tracks/cylinder */ 21212836Ssam short nspc; /* # sector/cylinders */ 21312836Ssam short ncyl; /* # cylinders */ 21412836Ssam struct size *sizes; /* partition tables */ 21512836Ssam short sdist; /* seek distance metric */ 21616225Skarels short maxdist; /* boundaries of non-searched area */ 21716225Skarels short mindist; /* preceding the target sector */ 2182383Swnj } hpst[] = { 21916225Skarels { 32, 5, 32*5, 823, rm03_sizes, 7, 4, 1 }, /* RM03 */ 22016225Skarels { 32, 19, 32*19, 823, rm05_sizes, 7, 4, 1 }, /* RM05 */ 22116225Skarels { 22,19, 22*19, 815, rp06_sizes, 7, 4, 1 }, /* RP06 */ 22216225Skarels { 31, 14, 31*14, 559, rm80_sizes, 7, 4, 1 }, /* RM80 */ 22316225Skarels { 22, 19, 22*19, 411, rp05_sizes, 7, 4, 1 }, /* RP04 */ 22416225Skarels { 22, 19, 22*19, 411, rp05_sizes, 7, 4, 1 }, /* RP05 */ 22516225Skarels { 50, 32, 50*32, 630, rp07_sizes, 15, 8, 3 }, /* RP07 */ 22616225Skarels { 1, 1, 1, 1, 0, 0, 0, 0 }, /* ML11A */ 22716225Skarels { 1, 1, 1, 1, 0, 0, 0, 0 }, /* ML11B */ 22816225Skarels { 32, 40, 32*40, 843, cdc9775_sizes, 7, 4, 1 }, /* 9775 */ 22916225Skarels { 32, 10, 32*10, 823, cdc9730_sizes, 7, 4, 1 }, /* 9730 */ 23016225Skarels { 32, 16, 32*16, 1024, capricorn_sizes,10,4, 3 }, /* Capricorn */ 23116225Skarels { 48, 20, 48*20, 842, eagle_sizes, 15, 8, 3 }, /* EAGLE */ 23216225Skarels { 32, 19, 32*19, 815, ampex_sizes, 7, 4, 1 }, /* 9300 */ 2332383Swnj }; 2342383Swnj 2352624Swnj u_char hp_offset[16] = { 2363093Swnj HPOF_P400, HPOF_M400, HPOF_P400, HPOF_M400, 2373093Swnj HPOF_P800, HPOF_M800, HPOF_P800, HPOF_M800, 2383093Swnj HPOF_P1200, HPOF_M1200, HPOF_P1200, HPOF_M1200, 2393093Swnj 0, 0, 0, 0, 24021Sbill }; 24121Sbill 2422624Swnj struct buf rhpbuf[NHP]; 2433706Sroot struct buf bhpbuf[NHP]; 2443706Sroot struct dkbad hpbad[NHP]; 24521Sbill 24610857Ssam struct hpsoftc { 24710857Ssam u_char sc_hpinit; /* drive initialized */ 24810857Ssam u_char sc_recal; /* recalibrate state */ 24910857Ssam u_char sc_hdr; /* next i/o includes header */ 25010857Ssam u_char sc_doseeks; /* perform explicit seeks */ 25110857Ssam daddr_t sc_mlsize; /* ML11 size */ 25217071Sralph int sc_pgdone; /* amount sucessfully transfered */ 25317071Sralph daddr_t sc_badbn; /* replacement block number */ 25410857Ssam } hpsoftc[NHP]; 25510857Ssam 25621Sbill #define b_cylin b_resid 25721Sbill 2585726Sroot /* #define ML11 0 to remove ML11 support */ 2595726Sroot #define ML11 (hptypes[mi->mi_type] == MBDT_ML11A) 2605726Sroot #define RP06 (hptypes[mi->mi_type] <= MBDT_RP06) 2615726Sroot #define RM80 (hptypes[mi->mi_type] == MBDT_RM80) 2625726Sroot 26311202Ssam #define MASKREG(reg) ((reg)&0xffff) 264*18411Skarels #define HPWAIT(mi, addr) (((addr)->hpds & HPDS_DRY) || hpwait(mi)) 26511202Ssam 26621Sbill #ifdef INTRLVE 26721Sbill daddr_t dkblock(); 26821Sbill #endif 2692604Swnj 2702978Swnj /*ARGSUSED*/ 2712978Swnj hpattach(mi, slave) 27210734Ssam register struct mba_device *mi; 2732604Swnj { 27410734Ssam 27510734Ssam mi->mi_type = hpmaptype(mi); 27610734Ssam if (!ML11 && mi->mi_dk >= 0) { 27710734Ssam struct hpst *st = &hpst[mi->mi_type]; 27810734Ssam 27910734Ssam dk_mspw[mi->mi_dk] = 1.0 / 60 / (st->nsect * 256); 28010734Ssam } 28110734Ssam } 28210734Ssam 28310734Ssam /* 28410734Ssam * Map apparent MASSBUS drive type into manufacturer 28510734Ssam * specific configuration. For SI controllers this is done 28610734Ssam * based on codes in the serial number register. For 28710734Ssam * EMULEX controllers, the track and sector attributes are 28810734Ssam * used when the drive type is an RM02 (not supported by DEC). 28910734Ssam */ 29010734Ssam hpmaptype(mi) 29110734Ssam register struct mba_device *mi; 29210734Ssam { 2936927Ssam register struct hpdevice *hpaddr = (struct hpdevice *)mi->mi_drv; 29410734Ssam register int type = mi->mi_type; 2956927Ssam 2966927Ssam /* 29711281Ssam * Model-byte processing for SI controllers. 2986927Ssam * NB: Only deals with RM03 and RM05 emulations. 2996927Ssam */ 30010734Ssam if (type == HPDT_RM03 || type == HPDT_RM05) { 30110734Ssam int hpsn = hpaddr->hpsn; 3026927Ssam 3036927Ssam if ((hpsn & SIMB_LU) != mi->mi_drive) 30410734Ssam return (type); 3056927Ssam switch ((hpsn & SIMB_MB) & ~(SIMB_S6|SIRM03|SIRM05)) { 3066927Ssam 3076927Ssam case SI9775D: 30811281Ssam printf("hp%d: 9775 (direct)\n", mi->mi_unit); 30910734Ssam type = HPDT_9775; 3106927Ssam break; 3116927Ssam 3126927Ssam case SI9730D: 31311281Ssam printf("hp%d: 9730 (direct)\n", mi->mi_unit); 31410734Ssam type = HPDT_9730; 3156927Ssam break; 3166927Ssam 3177035Swnj /* 31811281Ssam * Beware, since the only SI controller we 31911281Ssam * have has a 9300 instead of a 9766, we map the 32011281Ssam * drive type into the 9300. This means that 32111281Ssam * on a 9766 you lose the last 8 cylinders (argh). 3227035Swnj */ 3236927Ssam case SI9766: 32411281Ssam printf("hp%d: 9300\n", mi->mi_unit); 32511281Ssam type = HPDT_9300; 3266927Ssam break; 3276927Ssam 3286927Ssam case SI9762: 3296927Ssam printf("hp%d: 9762\n", mi->mi_unit); 33010734Ssam type = HPDT_RM03; 3316927Ssam break; 33211281Ssam 33311281Ssam case SICAPD: 33411281Ssam printf("hp%d: capricorn\n", mi->mi_unit); 33511281Ssam type = HPDT_CAPRICORN; 33611281Ssam break; 33711281Ssam 33811281Ssam case SI9751D: 33911281Ssam printf("hp%d: eagle\n", mi->mi_unit); 34011281Ssam type = HPDT_EAGLE; 34111281Ssam break; 3426927Ssam } 34310734Ssam return (type); 34410734Ssam } 3456927Ssam 3466927Ssam /* 34710734Ssam * EMULEX SC750 or SC780. Poke the holding register. 3486927Ssam */ 34910734Ssam if (type == HPDT_RM02) { 35010734Ssam int ntracks, nsectors; 35110734Ssam 35211315Ssam hpaddr->hpof = HPOF_FMT22; 35311315Ssam mbclrattn(mi); 3546927Ssam hpaddr->hpcs1 = HP_NOP; 3556927Ssam hpaddr->hphr = HPHR_MAXTRAK; 35611202Ssam ntracks = MASKREG(hpaddr->hphr) + 1; 35710055Ssam if (ntracks == 16) { 3586927Ssam printf("hp%d: capricorn\n", mi->mi_unit); 35910734Ssam type = HPDT_CAPRICORN; 36010734Ssam goto done; 36110734Ssam } 36213157Ssam if (ntracks == 19) { 36313157Ssam printf("hp%d: 9300\n", mi->mi_unit); 36413157Ssam type = HPDT_9300; 36513157Ssam goto done; 36613157Ssam } 36710734Ssam hpaddr->hpcs1 = HP_NOP; 36810734Ssam hpaddr->hphr = HPHR_MAXSECT; 36911202Ssam nsectors = MASKREG(hpaddr->hphr) + 1; 37011315Ssam if (ntracks == 20 && nsectors == 48) { 37110734Ssam type = HPDT_EAGLE; 37211212Ssam printf("hp%d: eagle\n", mi->mi_unit); 37311315Ssam goto done; 37410734Ssam } 37511315Ssam printf("hp%d: ntracks %d, nsectors %d: unknown device\n", 37613157Ssam mi->mi_unit, ntracks, nsectors); 37710734Ssam done: 3786927Ssam hpaddr->hpcs1 = HP_DCLR|HP_GO; 37911315Ssam mbclrattn(mi); /* conservative */ 38010734Ssam return (type); 38110734Ssam } 3826927Ssam 38310734Ssam /* 38410734Ssam * Map all ML11's to the same type. Also calculate 38510734Ssam * transfer rates based on device characteristics. 38610734Ssam */ 38710734Ssam if (type == HPDT_ML11A || type == HPDT_ML11B) { 38810857Ssam register struct hpsoftc *sc = &hpsoftc[mi->mi_unit]; 38910857Ssam register int trt; 3902604Swnj 39110857Ssam sc->sc_mlsize = hpaddr->hpmr & HPMR_SZ; 3925726Sroot if ((hpaddr->hpmr & HPMR_ARRTYP) == 0) 39310857Ssam sc->sc_mlsize >>= 2; 3945726Sroot if (mi->mi_dk >= 0) { 3955726Sroot trt = (hpaddr->hpmr & HPMR_TRT) >> 8; 3965726Sroot dk_mspw[mi->mi_dk] = 1.0 / (1<<(20-trt)); 3975726Sroot } 39810734Ssam type = HPDT_ML11A; 3996927Ssam } 40010734Ssam return (type); 4012604Swnj } 4022604Swnj 4038579Sroot hpopen(dev) 4048579Sroot dev_t dev; 4058579Sroot { 4068579Sroot register int unit = minor(dev) >> 3; 4078579Sroot register struct mba_device *mi; 4088579Sroot 4098579Sroot if (unit >= NHP || (mi = hpinfo[unit]) == 0 || mi->mi_alive == 0) 4108579Sroot return (ENXIO); 4118579Sroot return (0); 4128579Sroot } 4138579Sroot 41421Sbill hpstrategy(bp) 4152383Swnj register struct buf *bp; 41621Sbill { 4172978Swnj register struct mba_device *mi; 4182383Swnj register struct hpst *st; 4192383Swnj register int unit; 42021Sbill long sz, bn; 4212383Swnj int xunit = minor(bp->b_dev) & 07; 4225432Sroot int s; 42321Sbill 42421Sbill sz = bp->b_bcount; 42521Sbill sz = (sz+511) >> 9; 42621Sbill unit = dkunit(bp); 4272383Swnj if (unit >= NHP) 4282383Swnj goto bad; 4292383Swnj mi = hpinfo[unit]; 4302395Swnj if (mi == 0 || mi->mi_alive == 0) 4312383Swnj goto bad; 4322383Swnj st = &hpst[mi->mi_type]; 4335726Sroot if (ML11) { 43410857Ssam struct hpsoftc *sc = &hpsoftc[unit]; 43510857Ssam 4365726Sroot if (bp->b_blkno < 0 || 43710857Ssam dkblock(bp)+sz > sc->sc_mlsize) 4385726Sroot goto bad; 4395726Sroot bp->b_cylin = 0; 4405726Sroot } else { 4415726Sroot if (bp->b_blkno < 0 || 4425726Sroot (bn = dkblock(bp))+sz > st->sizes[xunit].nblocks) 4435726Sroot goto bad; 4445726Sroot bp->b_cylin = bn/st->nspc + st->sizes[xunit].cyloff; 4455726Sroot } 4465432Sroot s = spl5(); 4472383Swnj disksort(&mi->mi_tab, bp); 4482383Swnj if (mi->mi_tab.b_active == 0) 4492383Swnj mbustart(mi); 4505432Sroot splx(s); 4512383Swnj return; 4522383Swnj 4532383Swnj bad: 4542383Swnj bp->b_flags |= B_ERROR; 4552383Swnj iodone(bp); 4562383Swnj return; 45721Sbill } 45821Sbill 4592383Swnj hpustart(mi) 4602978Swnj register struct mba_device *mi; 46121Sbill { 4622624Swnj register struct hpdevice *hpaddr = (struct hpdevice *)mi->mi_drv; 4632383Swnj register struct buf *bp = mi->mi_tab.b_actf; 46411315Ssam register struct hpst *st; 46510857Ssam struct hpsoftc *sc = &hpsoftc[mi->mi_unit]; 46621Sbill daddr_t bn; 46716791Skarels int sn, tn, dist; 46821Sbill 46911315Ssam st = &hpst[mi->mi_type]; 4703706Sroot hpaddr->hpcs1 = 0; 4712624Swnj if ((hpaddr->hpcs1&HP_DVA) == 0) 4722383Swnj return (MBU_BUSY); 47310857Ssam if ((hpaddr->hpds & HPDS_VV) == 0 || !sc->sc_hpinit) { 4743706Sroot struct buf *bbp = &bhpbuf[mi->mi_unit]; 4753706Sroot 47610857Ssam sc->sc_hpinit = 1; 4772624Swnj hpaddr->hpcs1 = HP_DCLR|HP_GO; 4783140Swnj if (mi->mi_mba->mba_drv[0].mbd_as & (1<<mi->mi_drive)) 4793140Swnj printf("DCLR attn\n"); 4802624Swnj hpaddr->hpcs1 = HP_PRESET|HP_GO; 4815726Sroot if (!ML11) 4825726Sroot hpaddr->hpof = HPOF_FMT22; 4833140Swnj mbclrattn(mi); 4845726Sroot if (!ML11) { 4855726Sroot bbp->b_flags = B_READ|B_BUSY; 4865726Sroot bbp->b_dev = bp->b_dev; 4875726Sroot bbp->b_bcount = 512; 4885726Sroot bbp->b_un.b_addr = (caddr_t)&hpbad[mi->mi_unit]; 4895726Sroot bbp->b_blkno = st->ncyl*st->nspc - st->nsect; 4905726Sroot bbp->b_cylin = st->ncyl - 1; 4915726Sroot mi->mi_tab.b_actf = bbp; 4925726Sroot bbp->av_forw = bp; 4935726Sroot bp = bbp; 4945726Sroot } 49521Sbill } 4962604Swnj if (mi->mi_tab.b_active || mi->mi_hd->mh_ndrive == 1) 4972383Swnj return (MBU_DODATA); 4985726Sroot if (ML11) 4995726Sroot return (MBU_DODATA); 5003093Swnj if ((hpaddr->hpds & HPDS_DREADY) != HPDS_DREADY) 5012383Swnj return (MBU_DODATA); 5022395Swnj bn = dkblock(bp); 50316791Skarels sn = bn % st->nspc; 50416791Skarels tn = sn / st->nsect; 50516791Skarels sn = sn % st->nsect; 50611202Ssam if (bp->b_cylin == MASKREG(hpaddr->hpdc)) { 50710908Ssam if (sc->sc_doseeks) 5082383Swnj return (MBU_DODATA); 50916225Skarels dist = sn - (MASKREG(hpaddr->hpla) >> 6) - 1; 5102383Swnj if (dist < 0) 5112383Swnj dist += st->nsect; 51216225Skarels if (dist > st->maxdist || dist < st->mindist) 5132383Swnj return (MBU_DODATA); 5142614Swnj } else 5152614Swnj hpaddr->hpdc = bp->b_cylin; 51610908Ssam if (sc->sc_doseeks) 5172624Swnj hpaddr->hpcs1 = HP_SEEK|HP_GO; 518305Sbill else { 51916225Skarels sn = (sn + st->nsect - st->sdist) % st->nsect; 52016791Skarels hpaddr->hpda = (tn << 8) + sn; 5212624Swnj hpaddr->hpcs1 = HP_SEARCH|HP_GO; 522305Sbill } 5232383Swnj return (MBU_STARTED); 52421Sbill } 52521Sbill 5262383Swnj hpstart(mi) 5272978Swnj register struct mba_device *mi; 52821Sbill { 5292624Swnj register struct hpdevice *hpaddr = (struct hpdevice *)mi->mi_drv; 5302383Swnj register struct buf *bp = mi->mi_tab.b_actf; 5312383Swnj register struct hpst *st = &hpst[mi->mi_type]; 53210857Ssam struct hpsoftc *sc = &hpsoftc[mi->mi_unit]; 53321Sbill daddr_t bn; 5342383Swnj int sn, tn; 53521Sbill 53617071Sralph if (bp->b_flags & B_BAD) 53717071Sralph bn = sc->sc_badbn; 53817071Sralph else 53917071Sralph bn = dkblock(bp) + sc->sc_pgdone; 5405726Sroot if (ML11) 5415726Sroot hpaddr->hpda = bn; 5425726Sroot else { 5435726Sroot sn = bn%st->nspc; 5445726Sroot tn = sn/st->nsect; 5455726Sroot sn %= st->nsect; 5465726Sroot hpaddr->hpdc = bp->b_cylin; 5475726Sroot hpaddr->hpda = (tn << 8) + sn; 5485726Sroot } 54910857Ssam if (sc->sc_hdr) { 5505726Sroot if (bp->b_flags & B_READ) 5515726Sroot return (HP_RHDR|HP_GO); 5525726Sroot else 5535726Sroot return (HP_WHDR|HP_GO); 5545726Sroot } 5555726Sroot return (0); 55621Sbill } 55721Sbill 5583102Swnj hpdtint(mi, mbsr) 5592978Swnj register struct mba_device *mi; 5603102Swnj int mbsr; 56121Sbill { 5622624Swnj register struct hpdevice *hpaddr = (struct hpdevice *)mi->mi_drv; 5632383Swnj register struct buf *bp = mi->mi_tab.b_actf; 56411315Ssam register struct hpst *st; 5655893Swnj register int er1, er2; 56610857Ssam struct hpsoftc *sc = &hpsoftc[mi->mi_unit]; 567*18411Skarels int retry = 0, i; 56821Sbill 56911315Ssam st = &hpst[mi->mi_type]; 5703102Swnj if (hpaddr->hpds&HPDS_ERR || mbsr&MBSR_EBITS) { 57114145Shelge er1 = hpaddr->hper1; 57214145Shelge er2 = hpaddr->hper2; 573*18411Skarels if (HPWAIT(mi, hpaddr) == 0) 574*18411Skarels goto hard; 5753706Sroot #ifdef HPDEBUG 5763289Swnj if (hpdebug) { 5773706Sroot int dc = hpaddr->hpdc, da = hpaddr->hpda; 5783706Sroot 579*18411Skarels printf("hperr: bp %x cyl %d blk %d pgdone %d as %o ", 580*18411Skarels bp, bp->b_cylin, bp->b_blkno, sc->sc_pgdone, 5813706Sroot hpaddr->hpas&0xff); 58211202Ssam printf("dc %x da %x\n",MASKREG(dc), MASKREG(da)); 5833289Swnj printf("errcnt %d ", mi->mi_tab.b_errcnt); 5843289Swnj printf("mbsr=%b ", mbsr, mbsr_bits); 58514145Shelge printf("er1=%b er2=%b\n", MASKREG(er1), HPER1_BITS, 58614145Shelge MASKREG(er2), HPER2_BITS); 5873289Swnj DELAY(1000000); 5883289Swnj } 5893706Sroot #endif 5905893Swnj if (er1 & HPER1_HCRC) { 5915858Swnj er1 &= ~(HPER1_HCE|HPER1_FER); 5925893Swnj er2 &= ~HPER2_BSE; 5935893Swnj } 59416791Skarels if (er1 & HPER1_WLE) { 595*18411Skarels log(KERN_RECOV, "hp%d: write locked\n", dkunit(bp)); 5962826Swnj bp->b_flags |= B_ERROR; 59716791Skarels } else if (sc->sc_hdr) { 59816791Skarels goto hard; 59917071Sralph } else if (RM80 && er2&HPER2_SSE) { 60017071Sralph (void) hpecc(mi, SSE); 60117071Sralph return (MBD_RESTARTED); 60216791Skarels } else if ((er2 & HPER2_BSE) && !ML11) { 6035726Sroot if (hpecc(mi, BSE)) 60411202Ssam return (MBD_RESTARTED); 60511202Ssam goto hard; 60616791Skarels } else if (MASKREG(er1) == HPER1_FER && RP06) { 60716791Skarels if (hpecc(mi, BSE)) 60816791Skarels return (MBD_RESTARTED); 60916791Skarels goto hard; 61017071Sralph } else if ((er1 & (HPER1_DCK | HPER1_ECH)) == HPER1_DCK && 61117071Sralph mi->mi_tab.b_errcnt > 7) { 61216791Skarels if (hpecc(mi, ECC)) 61316791Skarels return (MBD_RESTARTED); 61416791Skarels /* else done */ 6152826Swnj } else if (++mi->mi_tab.b_errcnt > 27 || 61616791Skarels (ML11 && mi->mi_tab.b_errcnt > 15) || 6173102Swnj mbsr & MBSR_HARD || 6185858Swnj er1 & HPER1_HARD || 6195893Swnj (!ML11 && (er2 & HPER2_HARD))) { 62010886Shelge /* 62114134Shelge * HCRC means the header is screwed up and the sector 62214134Shelge * might well exist in the bad sector table, 62314134Shelge * better check.... 62410886Shelge */ 62516791Skarels if ((er1 & HPER1_HCRC) && !ML11 && hpecc(mi, BSE)) 62611202Ssam return (MBD_RESTARTED); 6273706Sroot hard: 62817071Sralph if (bp->b_flags & B_BAD) 62917071Sralph bp->b_blkno = sc->sc_badbn; 630*18411Skarels else { 631*18411Skarels bp->b_blkno = dkblock(bp) + btop(bp->b_bcount - 632*18411Skarels MASKREG(-mi->mi_mba->mba_bcr)); 633*18411Skarels if (er1 & (HPER1_DCK | HPER1_ECH)) 634*18411Skarels bp->b_blkno--; 635*18411Skarels } 6362925Swnj harderr(bp, "hp"); 6373271Swnj if (mbsr & (MBSR_EBITS &~ (MBSR_DTABT|MBSR_MBEXC))) 6383271Swnj printf("mbsr=%b ", mbsr, mbsr_bits); 6393706Sroot printf("er1=%b er2=%b", 64014145Shelge MASKREG(hpaddr->hper1), HPER1_BITS, 64114145Shelge MASKREG(hpaddr->hper2), HPER2_BITS); 6423706Sroot if (hpaddr->hpmr) 64311202Ssam printf(" mr=%o", MASKREG(hpaddr->hpmr)); 6443706Sroot if (hpaddr->hpmr2) 64511202Ssam printf(" mr2=%o", MASKREG(hpaddr->hpmr2)); 64614134Shelge if (sc->sc_hdr) 64714134Shelge printf(" (hdr i/o)"); 6483706Sroot printf("\n"); 6492826Swnj bp->b_flags |= B_ERROR; 65017071Sralph bp->b_flags &= ~B_BAD; 6512826Swnj } else 6522826Swnj retry = 1; 6532826Swnj hpaddr->hpcs1 = HP_DCLR|HP_GO; 65416791Skarels if ((mi->mi_tab.b_errcnt & 07) == 4) { 6552826Swnj hpaddr->hpcs1 = HP_RECAL|HP_GO; 65610857Ssam sc->sc_recal = 1; 65711202Ssam return (MBD_RESTARTED); 65821Sbill } 6592826Swnj } 6603706Sroot #ifdef HPDEBUG 6613289Swnj else 66210857Ssam if (hpdebug && sc->sc_recal) { 66310857Ssam printf("recal %d ", sc->sc_recal); 6643289Swnj printf("errcnt %d\n", mi->mi_tab.b_errcnt); 6653289Swnj printf("mbsr=%b ", mbsr, mbsr_bits); 6663289Swnj printf("er1=%b er2=%b\n", 6673289Swnj hpaddr->hper1, HPER1_BITS, 6683289Swnj hpaddr->hper2, HPER2_BITS); 6693289Swnj } 6703706Sroot #endif 671*18411Skarels HPWAIT(mi, hpaddr); 67210857Ssam switch (sc->sc_recal) { 6733093Swnj 6743093Swnj case 1: 6753093Swnj hpaddr->hpdc = bp->b_cylin; 6763093Swnj hpaddr->hpcs1 = HP_SEEK|HP_GO; 67710857Ssam sc->sc_recal++; 6783706Sroot return (MBD_RESTARTED); 6793093Swnj case 2: 68016791Skarels retry = 1; 68116791Skarels break; 68216791Skarels } 68316791Skarels sc->sc_recal = 0; 68416791Skarels if (retry) { 68516791Skarels if (mi->mi_tab.b_errcnt >= 16 && (bp->b_flags & B_READ)) { 68616791Skarels hpaddr->hpof = 68716791Skarels hp_offset[mi->mi_tab.b_errcnt & 017]|HPOF_FMT22; 68816791Skarels hpaddr->hpcs1 = HP_OFFSET|HP_GO; 689*18411Skarels HPWAIT(mi, hpaddr); 69016791Skarels mbclrattn(mi); 69116791Skarels } 6922892Swnj return (MBD_RETRY); 6932892Swnj } 6943640Swnj if (mi->mi_tab.b_errcnt >= 16) { 6953093Swnj /* 6963093Swnj * This is fast and occurs rarely; we don't 6973093Swnj * bother with interrupts. 6983093Swnj */ 6992624Swnj hpaddr->hpcs1 = HP_RTC|HP_GO; 700*18411Skarels HPWAIT(mi, hpaddr); 7012383Swnj mbclrattn(mi); 70221Sbill } 70317071Sralph if ((bp->b_flags & B_BAD) && hpecc(mi, CONT)) 70417071Sralph return (MBD_RESTARTED); 70517071Sralph sc->sc_hdr = 0; 70617071Sralph sc->sc_pgdone = 0; 70717071Sralph bp->b_resid = MASKREG(-mi->mi_mba->mba_bcr); 7085726Sroot if (!ML11) { 7095726Sroot hpaddr->hpof = HPOF_FMT22; 7105726Sroot hpaddr->hpcs1 = HP_RELEASE|HP_GO; 7115726Sroot } 7122383Swnj return (MBD_DONE); 71321Sbill } 71421Sbill 715*18411Skarels /* 716*18411Skarels * Wait (for a bit) for a drive to come ready; 717*18411Skarels * returns nonzero on success. 718*18411Skarels */ 719*18411Skarels hpwait(mi) 720*18411Skarels register struct mba_device *mi; 721*18411Skarels { 722*18411Skarels register struct hpdevice *hpaddr = (struct hpdevice *)mi->mi_drv; 723*18411Skarels register i = 100000; 724*18411Skarels 725*18411Skarels while ((hpaddr->hpds & HPDS_DRY) == 0 && --i) 726*18411Skarels DELAY(10); 727*18411Skarels if (i == 0) 728*18411Skarels printf("hp%d: intr, not ready\n", mi->mi_unit); 729*18411Skarels return (i); 730*18411Skarels } 731*18411Skarels 7327738Sroot hpread(dev, uio) 7332624Swnj dev_t dev; 7347738Sroot struct uio *uio; 73521Sbill { 7362624Swnj register int unit = minor(dev) >> 3; 73721Sbill 7382624Swnj if (unit >= NHP) 7398156Sroot return (ENXIO); 7408156Sroot return (physio(hpstrategy, &rhpbuf[unit], dev, B_READ, minphys, uio)); 74121Sbill } 74221Sbill 7437831Sroot hpwrite(dev, uio) 7442624Swnj dev_t dev; 7457831Sroot struct uio *uio; 74621Sbill { 7472624Swnj register int unit = minor(dev) >> 3; 74821Sbill 7492624Swnj if (unit >= NHP) 7508156Sroot return (ENXIO); 7518156Sroot return (physio(hpstrategy, &rhpbuf[unit], dev, B_WRITE, minphys, uio)); 75221Sbill } 75321Sbill 7545726Sroot /*ARGSUSED*/ 7557635Ssam hpioctl(dev, cmd, data, flag) 7565726Sroot dev_t dev; 7575726Sroot int cmd; 7587635Ssam caddr_t data; 7595726Sroot int flag; 7605726Sroot { 7615726Sroot 7625726Sroot switch (cmd) { 7637635Ssam 7645726Sroot case DKIOCHDR: /* do header read/write */ 76510857Ssam hpsoftc[minor(dev) >> 3].sc_hdr = 1; 7668579Sroot return (0); 7675726Sroot 7685726Sroot default: 7698579Sroot return (ENXIO); 7705726Sroot } 7715726Sroot } 7725726Sroot 7733706Sroot hpecc(mi, flag) 7742978Swnj register struct mba_device *mi; 7753706Sroot int flag; 77621Sbill { 7772383Swnj register struct mba_regs *mbp = mi->mi_mba; 7782624Swnj register struct hpdevice *rp = (struct hpdevice *)mi->mi_drv; 7792383Swnj register struct buf *bp = mi->mi_tab.b_actf; 7803706Sroot register struct hpst *st = &hpst[mi->mi_type]; 78117071Sralph struct hpsoftc *sc = &hpsoftc[mi->mi_unit]; 7823706Sroot int npf, o; 7832383Swnj int bn, cn, tn, sn; 784914Sbill int bcr; 78521Sbill 786*18411Skarels bcr = MASKREG(-mbp->mba_bcr); 78717071Sralph if (bp->b_flags & B_BAD) 7883706Sroot npf = bp->b_error; 7893706Sroot else 790*18411Skarels npf = btop(bp->b_bcount - bcr); 791420Sbill o = (int)bp->b_un.b_addr & PGOFSET; 792*18411Skarels bn = dkblock(bp); 793420Sbill cn = bp->b_cylin; 794*18411Skarels sn = bn%(st->nspc) + npf; 7952383Swnj tn = sn/st->nsect; 7962383Swnj sn %= st->nsect; 7972383Swnj cn += tn/st->ntrak; 7982383Swnj tn %= st->ntrak; 7993706Sroot switch (flag) { 80010856Ssam case ECC: { 8013706Sroot register int i; 8023706Sroot caddr_t addr; 8033706Sroot struct pte mpte; 8043706Sroot int bit, byte, mask; 8053706Sroot 8063706Sroot npf--; /* because block in error is previous block */ 807*18411Skarels bn--; 80817071Sralph if (bp->b_flags & B_BAD) 80917071Sralph bn = sc->sc_badbn; 810*18411Skarels log(KERN_RECOV, "hp%d%c: soft ecc sn%d\n", dkunit(bp), 81117071Sralph 'a'+(minor(bp->b_dev)&07), bn); 81211202Ssam mask = MASKREG(rp->hpec2); 81311202Ssam i = MASKREG(rp->hpec1) - 1; /* -1 makes 0 origin */ 8143706Sroot bit = i&07; 8153706Sroot i = (i&~07)>>3; 8163706Sroot byte = i + o; 8173706Sroot while (i < 512 && (int)ptob(npf)+i < bp->b_bcount && bit > -11) { 8183706Sroot mpte = mbp->mba_map[npf+btop(byte)]; 8193706Sroot addr = ptob(mpte.pg_pfnum) + (byte & PGOFSET); 8203706Sroot putmemc(addr, getmemc(addr)^(mask<<bit)); 8213706Sroot byte++; 8223706Sroot i++; 8233706Sroot bit -= 8; 8243706Sroot } 825*18411Skarels if (bcr == 0) 8263706Sroot return (0); 8273847Sroot npf++; 8283706Sroot break; 8293706Sroot } 8303706Sroot 8313706Sroot case SSE: 8323706Sroot rp->hpof |= HPOF_SSEI; 83317071Sralph if (bp->b_flags & B_BAD) { 83417071Sralph bn = sc->sc_badbn; 83517071Sralph goto fixregs; 83617071Sralph } 8373706Sroot mbp->mba_bcr = -(bp->b_bcount - (int)ptob(npf)); 8383706Sroot break; 8393706Sroot 8403706Sroot case BSE: 84117071Sralph if (rp->hpof & HPOF_SSEI) 84217071Sralph sn++; 8433706Sroot #ifdef HPBDEBUG 8443706Sroot if (hpbdebug) 8453706Sroot printf("hpecc, BSE: bn %d cn %d tn %d sn %d\n", bn, cn, tn, sn); 8463706Sroot #endif 84717071Sralph if (bp->b_flags & B_BAD) 84817071Sralph return (0); 8493706Sroot if ((bn = isbad(&hpbad[mi->mi_unit], cn, tn, sn)) < 0) 85011202Ssam return (0); 8513706Sroot bp->b_flags |= B_BAD; 8523706Sroot bp->b_error = npf + 1; 85317071Sralph rp->hpof &= ~HPOF_SSEI; 8543706Sroot bn = st->ncyl*st->nspc - st->nsect - 1 - bn; 85517071Sralph sc->sc_badbn = bn; 85617071Sralph fixregs: 8573706Sroot cn = bn/st->nspc; 8583706Sroot sn = bn%st->nspc; 8593706Sroot tn = sn/st->nsect; 8603706Sroot sn %= st->nsect; 8613706Sroot mbp->mba_bcr = -512; 8623706Sroot #ifdef HPBDEBUG 8633706Sroot if (hpbdebug) 8643706Sroot printf("revector to cn %d tn %d sn %d\n", cn, tn, sn); 8653706Sroot #endif 8663706Sroot break; 8673706Sroot 8683706Sroot case CONT: 8693706Sroot #ifdef HPBDEBUG 8703706Sroot if (hpbdebug) 8713706Sroot printf("hpecc, CONT: bn %d cn %d tn %d sn %d\n", bn,cn,tn,sn); 8723706Sroot #endif 8733706Sroot bp->b_flags &= ~B_BAD; 8743706Sroot mbp->mba_bcr = -(bp->b_bcount - (int)ptob(npf)); 87511202Ssam if (MASKREG(mbp->mba_bcr) == 0) 87611202Ssam return (0); 8773706Sroot break; 8783706Sroot } 8793706Sroot rp->hpcs1 = HP_DCLR|HP_GO; 88017071Sralph if (rp->hpof & HPOF_SSEI) 8812883Swnj sn++; 882420Sbill rp->hpdc = cn; 883420Sbill rp->hpda = (tn<<8) + sn; 884420Sbill mbp->mba_sr = -1; 8853706Sroot mbp->mba_var = (int)ptob(npf) + o; 8863706Sroot rp->hpcs1 = bp->b_flags&B_READ ? HP_RCOM|HP_GO : HP_WCOM|HP_GO; 8873706Sroot mi->mi_tab.b_errcnt = 0; /* error has been corrected */ 88817071Sralph sc->sc_pgdone = npf; 889420Sbill return (1); 89021Sbill } 8912362Swnj 8922362Swnj #define DBSIZE 20 8932362Swnj 8942362Swnj hpdump(dev) 8952362Swnj dev_t dev; 8962362Swnj { 8972978Swnj register struct mba_device *mi; 8982383Swnj register struct mba_regs *mba; 8992624Swnj struct hpdevice *hpaddr; 9002362Swnj char *start; 9012383Swnj int num, unit; 9022383Swnj register struct hpst *st; 9032362Swnj 9042362Swnj num = maxfree; 9052362Swnj start = 0; 9062362Swnj unit = minor(dev) >> 3; 9072827Swnj if (unit >= NHP) 9082827Swnj return (ENXIO); 9092383Swnj #define phys(a,b) ((b)((int)(a)&0x7fffffff)) 9102978Swnj mi = phys(hpinfo[unit],struct mba_device *); 9112827Swnj if (mi == 0 || mi->mi_alive == 0) 9122827Swnj return (ENXIO); 9132383Swnj mba = phys(mi->mi_hd, struct mba_hd *)->mh_physmba; 9143102Swnj mba->mba_cr = MBCR_INIT; 9152624Swnj hpaddr = (struct hpdevice *)&mba->mba_drv[mi->mi_drive]; 9163093Swnj if ((hpaddr->hpds & HPDS_VV) == 0) { 9172624Swnj hpaddr->hpcs1 = HP_DCLR|HP_GO; 9182624Swnj hpaddr->hpcs1 = HP_PRESET|HP_GO; 9193093Swnj hpaddr->hpof = HPOF_FMT22; 9202362Swnj } 9212383Swnj st = &hpst[mi->mi_type]; 9222827Swnj if (dumplo < 0 || dumplo + num >= st->sizes[minor(dev)&07].nblocks) 9232827Swnj return (EINVAL); 9242362Swnj while (num > 0) { 9252383Swnj register struct pte *hpte = mba->mba_map; 9262362Swnj register int i; 9272383Swnj int blk, cn, sn, tn; 9282362Swnj daddr_t bn; 9292362Swnj 9302362Swnj blk = num > DBSIZE ? DBSIZE : num; 9312362Swnj bn = dumplo + btop(start); 9322383Swnj cn = bn/st->nspc + st->sizes[minor(dev)&07].cyloff; 9332383Swnj sn = bn%st->nspc; 9342383Swnj tn = sn/st->nsect; 9352383Swnj sn = sn%st->nsect; 9362362Swnj hpaddr->hpdc = cn; 9372362Swnj hpaddr->hpda = (tn << 8) + sn; 9382362Swnj for (i = 0; i < blk; i++) 9392362Swnj *(int *)hpte++ = (btop(start)+i) | PG_V; 9402383Swnj mba->mba_sr = -1; 9412383Swnj mba->mba_bcr = -(blk*NBPG); 9422383Swnj mba->mba_var = 0; 9432624Swnj hpaddr->hpcs1 = HP_WCOM | HP_GO; 9443093Swnj while ((hpaddr->hpds & HPDS_DRY) == 0) 94516791Skarels DELAY(10); 9463093Swnj if (hpaddr->hpds&HPDS_ERR) 9472827Swnj return (EIO); 9482362Swnj start += blk*NBPG; 9492362Swnj num -= blk; 9502362Swnj } 9512362Swnj return (0); 9522362Swnj } 95312506Ssam 95412506Ssam hpsize(dev) 95512506Ssam dev_t dev; 95612506Ssam { 95712506Ssam int unit = minor(dev) >> 3; 95812506Ssam struct mba_device *mi; 95912506Ssam struct hpst *st; 96012506Ssam 96112506Ssam if (unit >= NHP || (mi = hpinfo[unit]) == 0 || mi->mi_alive == 0) 96212506Ssam return (-1); 96312506Ssam st = &hpst[mi->mi_type]; 96412506Ssam return ((int)st->sizes[minor(dev) & 07].nblocks); 96512506Ssam } 9661565Sbill #endif 967