1*11113Shelge /* hp.c 4.12 83/02/17 */ 210334Shelge 310334Shelge /* 410334Shelge * RP??/RM?? disk driver 510334Shelge * with ECC handling and bad block forwarding. 610334Shelge * Also supports header io operations and 710334Shelge * commands to write check header and data. 810334Shelge */ 910334Shelge 1010334Shelge #include "../h/param.h" 1110334Shelge #include "../h/inode.h" 1210334Shelge #include "../h/fs.h" 1310334Shelge #include "../h/dkbad.h" 1410334Shelge 1510334Shelge #include "../vax/pte.h" 1610334Shelge #include "../vaxmba/hpreg.h" 1710334Shelge #include "../vaxmba/mbareg.h" 1810334Shelge 1910334Shelge #include "saio.h" 2010334Shelge #include "savax.h" 2110334Shelge 2210334Shelge #define MASKREG(reg) ((reg)&0xffff) 2310334Shelge 2410334Shelge #define MAXBADDESC 126 2510334Shelge #define SECTSIZ 512 /* sector size in bytes */ 2610334Shelge #define HDRSIZ 4 /* number of bytes in sector header */ 2710334Shelge #define MAXECC 5 /* the maximum number of bad bits accepted in 2810334Shelge * an ecc error when F_ECCLM is set */ 2910334Shelge 3010334Shelge char hp_type[MAXNMBA*8] = { 0 }; 3110334Shelge 3210334Shelge /* THIS SHOULD BE READ IN OFF THE PACK, PER DRIVE */ 3310334Shelge short hp6_off[8] = { 0, 38, 0, -1, -1, -1, 118, -1 }; 3410334Shelge short rm3_off[8] = { 0, 100, 0, -1, -1, -1, 310, -1 }; 3510334Shelge short rm5_off[8] = { 0, 27, 0, 562, 589, 681, 562, 82 }; 3610334Shelge short rm80_off[8] = { 0, 37, 0, -1, -1, -1, 115, 305 }; 3710334Shelge short hp7_off[8] = { 0, 10, 0, 330, 340, 500, 330, 50 }; 3810334Shelge short ml_off[8] = { 0, -1, -1, -1, -1, -1, -1, -1 }; 3910334Shelge short si9775_off[8] = { 0, 13, 0, -1, -1, -1, 40, 441 }; 4010334Shelge short si9730_off[8] = { 0, 50, 0, -1, -1, -1, -1, 155 }; 4110334Shelge short hpam_off[8] = { 0, 32, 0, 668, 723, 778, 668, 98 }; 4210626Shelge short hpfj_off[8] = { 0, 19, 0, -1, -1, -1, 398, 59 }; 4310334Shelge /* END SHOULD BE READ IN */ 4410334Shelge 4510334Shelge short hptypes[] = 4610334Shelge { MBDT_RM03, MBDT_RM05, MBDT_RP06, MBDT_RM80, MBDT_RP05, MBDT_RP07, 4710626Shelge MBDT_ML11A, MBDT_ML11B, -1/*9755*/, -1/*9730*/, -1/*Capr*/, 4811084Ssam -1/* eagle */, -1/* 48 sect eagle */, MBDT_RM02, 0}; 4910334Shelge 5010626Shelge #define RP06 (hptypes[hp_type[unit]] <= MBDT_RP06) 5110626Shelge #define ML11 (hptypes[hp_type[unit]] == MBDT_ML11A) 5210626Shelge #define RM80 (hptypes[hp_type[unit]] == MBDT_RM80) 5310334Shelge 5410334Shelge u_char hp_offset[16] = { 5510334Shelge HPOF_P400, HPOF_M400, HPOF_P400, HPOF_M400, 5610334Shelge HPOF_P800, HPOF_M800, HPOF_P800, HPOF_M800, 5710334Shelge HPOF_P1200, HPOF_M1200, HPOF_P1200, HPOF_M1200, 5810334Shelge 0, 0, 0, 0, 5910334Shelge }; 6010334Shelge 6110353Shelge struct st hpst[] = { 6210647Shelge 32, 5, 32*5, 823, rm3_off, /* RM03 */ 6310647Shelge 32, 19, 32*19, 823, rm5_off, /* RM05 */ 6410647Shelge 22, 19, 22*19, 815, hp6_off, /* RP06 */ 6510647Shelge 31, 14, 31*14, 559, rm80_off, /* RM80 */ 6610647Shelge 22, 19, 22*19, 411, hp6_off, /* RP06 */ 6710647Shelge 50, 32, 50*32, 630, hp7_off, /* RP07 */ 6810647Shelge 1, 1, 1, 1, ml_off, /* ML11A */ 6910647Shelge 1, 1, 1, 1, ml_off, /* ML11B */ 7010647Shelge 32, 40, 32*40, 843, si9775_off, /* 9775 */ 7110647Shelge 32, 10, 32*10, 823, si9730_off, /* 9730 */ 7210647Shelge 32, 16, 32*16, 1024, hpam_off, /* capricorn */ 7310647Shelge 43, 20, 43*20, 842, hpfj_off, /* Eagle */ 7410693Shelge 48, 20, 48*20, 842, hpfj_off, /* modif. eagle */ 7510647Shelge 1, 1, 1, 1, 0, /* rm02 - not used */ 7610334Shelge }; 7711084Ssam 7810334Shelge struct dkbad hpbad[MAXNMBA*8]; 7910334Shelge int sectsiz; 8010334Shelge 8110864Ssam /* 8210864Ssam * When awaiting command completion, don't 8310864Ssam * hang on to the status register since 8410864Ssam * this ties up the controller. 8510864Ssam */ 8610864Ssam #define HPWAIT(addr) while ((((addr)->hpds)&HPDS_DRY)==0) DELAY(500); 8710864Ssam 8810334Shelge hpopen(io) 8910334Shelge register struct iob *io; 9010334Shelge { 9110334Shelge register unit = io->i_unit; 9210334Shelge struct hpdevice *hpaddr = (struct hpdevice *)mbadrv(unit); 9310353Shelge register struct st *st; 9410334Shelge 9510334Shelge mbainit(UNITTOMBA(unit)); 9610334Shelge if (hp_type[unit] == 0) { 9710334Shelge register type = hpaddr->hpdt & MBDT_TYPE; 9810334Shelge register int i; 9910334Shelge struct iob tio; 10010334Shelge 10110334Shelge for (i = 0; hptypes[i]; i++) 10210334Shelge if (hptypes[i] == type) 10310334Shelge goto found; 10410334Shelge _stop("unknown drive type"); 10510334Shelge found: 10610647Shelge hpaddr->hpcs1 = HP_DCLR|HP_GO; /* init drive */ 10710647Shelge hpaddr->hpcs1 = HP_PRESET|HP_GO; 10810647Shelge if (!ML11) 10910647Shelge hpaddr->hpof = HPOF_FMT22; 110*11113Shelge hp_type[unit] = hpmaptype(hpaddr, i, unit); 11110334Shelge /* 11210334Shelge * Read in the bad sector table: 11310334Shelge * copy the contents of the io structure 11410334Shelge * to tio for use during the bb pointer 11510334Shelge * read operation. 11610334Shelge */ 11710626Shelge st = &hpst[i]; 11810334Shelge tio = *io; 11910334Shelge tio.i_bn = st->nspc * st->ncyl - st->nsect; 12010626Shelge tio.i_ma = (char *)&hpbad[unit]; 12110628Shelge tio.i_cc = sizeof (struct dkbad); 12210334Shelge tio.i_flgs |= F_RDDATA; 12310334Shelge for (i = 0; i < 5; i++) { 12410628Shelge if (hpstrategy(&tio, READ) == sizeof (struct dkbad)) 12510334Shelge break; 12610334Shelge tio.i_bn += 2; 12710334Shelge } 12810334Shelge if (i == 5) { 12910334Shelge printf("Unable to read bad sector table\n"); 13010334Shelge for (i = 0; i < MAXBADDESC; i++) { 13110334Shelge hpbad[unit].bt_bad[i].bt_cyl = -1; 13210334Shelge hpbad[unit].bt_bad[i].bt_trksec = -1; 13310334Shelge } 13410334Shelge } 13510334Shelge } 13610334Shelge if (io->i_boff < 0 || io->i_boff > 7 || 13710334Shelge st->off[io->i_boff]== -1) 13810334Shelge _stop("hp bad minor"); 13910334Shelge io->i_boff = st->off[io->i_boff] * st->nspc; 14010334Shelge } 14110334Shelge 14211084Ssam hpmaptype(hpaddr, type, unit) 14311084Ssam register struct hpdevice *hpaddr; 14411084Ssam unsigned type; 14511084Ssam int unit; 14611084Ssam { 14711084Ssam int ntracks, hpsn; 14811084Ssam 14911084Ssam /* 15011084Ssam * Handle SI model byte stuff when 15111084Ssam * we think it's an RM03 or RM05. 15211084Ssam */ 15311084Ssam if (type == 0 || type == 1) { 15411084Ssam hpsn = hpaddr->hpsn; 15511084Ssam if ((hpsn & SIMB_LU) != unit) 15611084Ssam return (type); 15711084Ssam switch ((hpsn & SIMB_MB) &~ (SIMB_S6|SIRM03|SIRM05)) { 15811084Ssam case SI9775D: 15911084Ssam return (8); 16011084Ssam case SI9730D: 16111084Ssam return (9); 16211084Ssam case SI9766: 16311084Ssam hpaddr->hpcs1 = HP_RECAL|HP_GO; 16411084Ssam DELAY(100000); 16511084Ssam return (1); 16611084Ssam 16711084Ssam case SI9762: 16811084Ssam return (0); 16911084Ssam } 17011084Ssam return (type); 17111084Ssam } 17211084Ssam /* 17311084Ssam * RM03: EMULEX controller. Map to correct 17411084Ssam * drive type by checking the holding 17511084Ssam * register for the disk geometry. 17611084Ssam */ 17711084Ssam if (type == 13) { 17811084Ssam hpaddr->hpcs1 = HP_NOP; 17911084Ssam hpaddr->hphr = HPHR_MAXTRAK; 18011084Ssam ntracks = MASKREG(hpaddr->hphr) + 1; 18111084Ssam if (ntracks == 16) 18211084Ssam return (10); /* AMPEX capricorn */ 18311084Ssam hpaddr->hphr = HPHR_MAXSECT; 184*11113Shelge ntracks = MASKREG(hpaddr->hphr) + 1; 18511084Ssam if (ntracks == 48) 18611084Ssam return (12); /* 48 sector Eagle */ 18711084Ssam if (ntracks == 43) 18811084Ssam return (11); /* 43 sector Eagle */ 18911084Ssam printf("RM02 with %d tracks?\n", ntracks); 19011084Ssam return (type); 19111084Ssam } 19211084Ssam /* 19311084Ssam * ML11's all map to the same type. 19411084Ssam */ 19511084Ssam if (type == 6 || type == 7) 19611084Ssam return (6); 19711084Ssam return (type); 19811084Ssam } 19911084Ssam 20010647Shelge int ssect; /* set to 1 if we are on a track with skip sectors */ 20110647Shelge 20210334Shelge hpstrategy(io, func) 20310334Shelge register struct iob *io; 20410334Shelge { 20510334Shelge register unit = io->i_unit; 20610334Shelge struct mba_regs *mba = mbamba(unit); 20710334Shelge daddr_t bn; 20810334Shelge struct hpdevice *hpaddr = (struct hpdevice *)mbadrv(unit); 20910353Shelge struct st *st = &hpst[hp_type[unit]]; 21010334Shelge int cn, tn, sn, bytecnt, bytesleft; 21110334Shelge daddr_t startblock; 21210334Shelge char *membase; 21310334Shelge int er1, er2, hprecal; 21410334Shelge 21510334Shelge sectsiz = SECTSIZ; 21610334Shelge if ((io->i_flgs & (F_HDR|F_HCHECK)) != 0) 21710334Shelge sectsiz += HDRSIZ; 21810334Shelge if ((hpaddr->hpds & HPDS_VV) == 0) { 21910334Shelge hpaddr->hpcs1 = HP_DCLR|HP_GO; 22010334Shelge hpaddr->hpcs1 = HP_PRESET|HP_GO; 22111084Ssam if (!ML11) 22210334Shelge hpaddr->hpof = HPOF_FMT22; 22310334Shelge } 22410334Shelge io->i_errcnt = 0; 22510647Shelge ssect = 0; 22610334Shelge bytecnt = io->i_cc; 22710334Shelge membase = io->i_ma; 22810334Shelge startblock = io->i_bn; 22910608Ssam hprecal = 0; 23010626Shelge restart: 23110334Shelge bn = io->i_bn; 23210334Shelge cn = bn/st->nspc; 23310334Shelge sn = bn%st->nspc; 23410334Shelge tn = sn/st->nsect; 23510647Shelge sn = sn%st->nsect + ssect; 23610334Shelge 23710864Ssam HPWAIT(hpaddr); 23810626Shelge mba->mba_sr = -1; 23910647Shelge if (ML11) 24010334Shelge hpaddr->hpda = bn; 24110334Shelge else { 24210334Shelge hpaddr->hpdc = cn; 24310334Shelge hpaddr->hpda = (tn << 8) + sn; 24410334Shelge } 24510334Shelge if (mbastart(io, func) != 0) /* start transfer */ 24610334Shelge return (-1); 24710864Ssam HPWAIT(hpaddr); 24811084Ssam if ((hpaddr->hpds&HPDS_ERR) == 0 && (mba->mba_sr&MBSR_EBITS) == 0) 24911084Ssam return (bytecnt); 25010334Shelge 25110334Shelge /* ------- error handling ------- */ 25210334Shelge 25310334Shelge if (bytesleft = MASKREG(mba->mba_bcr>>16)) 25410334Shelge bytesleft |= 0xffff0000; /* sign ext */ 25510334Shelge bn = io->i_bn + (io->i_cc + bytesleft)/sectsiz; 25610334Shelge cn = bn/st->nspc; 25710334Shelge sn = bn%st->nspc; 25810334Shelge tn = sn/st->nsect; 25910334Shelge sn = sn%st->nsect; 26010334Shelge er1 = MASKREG(hpaddr->hper1); 26110334Shelge er2 = MASKREG(hpaddr->hper2); 26210334Shelge #ifdef HPDEBUG 26310334Shelge printf("hp error: (cyl,trk,sec)=(%d,%d,%d) ds=%b \n", 26410334Shelge cn, tn, sn, MASKREG(hpaddr->hpds), HPDS_BITS); 26510626Shelge printf("er1=%b er2=%b", er1, HPER1_BITS, er2, HPER2_BITS); 26610626Shelge printf("\nbytes left: %d, of 0x%x, da 0x%x",-bytesleft, 26710626Shelge hpaddr->hpof, hpaddr->hpda); 26810334Shelge printf("\n"); 26910334Shelge #endif 27010334Shelge if (er1 & HPER1_HCRC) { 27110334Shelge er1 &= ~(HPER1_HCE|HPER1_FER); 27210334Shelge er2 &= ~HPER2_BSE; 27310334Shelge } 27410334Shelge if (er1&HPER1_WLE) { 27510334Shelge printf("hp%d: write locked\n", unit); 27611084Ssam return (-1); 27711084Ssam } 27811084Ssam if (MASKREG(er1) == HPER1_FER && RP06) 27910334Shelge goto badsect; 28011084Ssam if (++io->i_errcnt > 27 || (er1 & HPER1_HARD) || 28111084Ssam (!ML11 && (er2 & HPER2_HARD))) { 28210608Ssam hard0: 28310334Shelge io->i_error = EHER; 28411084Ssam if (mba->mba_sr & (MBSR_WCKUP|MBSR_WCKLWR)) 28510334Shelge io->i_error = EWCK; 28610334Shelge hard: 28710647Shelge io->i_errblk = bn + ssect; 28810334Shelge printf("hp error: (cyl,trk,sec)=(%d,%d,%d) ds=%b \n", 28910334Shelge cn, tn, sn, MASKREG(hpaddr->hpds), HPDS_BITS); 29011084Ssam printf("er1=%b er2=%b", er1, HPER1_BITS, er2, HPER2_BITS); 29110334Shelge if (hpaddr->hpmr) 29210626Shelge printf(" mr1=%o", MASKREG(hpaddr->hpmr)); 29310334Shelge if (hpaddr->hpmr2) 29410626Shelge printf(" mr2=%o", MASKREG(hpaddr->hpmr2)); 29510626Shelge #ifdef HPDEBUG 29610626Shelge printf("dc: %d, da: 0x%x",MASKREG(hpaddr->hpdc), 29711084Ssam MASKREG(hpaddr->hpda)); 29810626Shelge #endif 29910626Shelge hpaddr->hpcs1 = HP_DCLR|HP_GO; 30010334Shelge printf("\n"); 30111084Ssam return (-1); 30210334Shelge 30311084Ssam } 30411084Ssam if ((er2 & HPER2_BSE) && !ML11) { 30510334Shelge badsect: 30610647Shelge if (!ssect && (er2&HPER2_SSE)) 30710647Shelge goto skipsect; 30811084Ssam if (io->i_flgs & F_NBSF) { 30910334Shelge io->i_error = EBSE; 31010334Shelge goto hard; 31110334Shelge } 31210334Shelge if (hpecc(io, BSE) == 0) 31310334Shelge goto success; 31411084Ssam io->i_error = EBSE; 31511084Ssam goto hard; 31611084Ssam } 31711084Ssam if (RM80 && er2&HPER2_SSE) { 31810647Shelge skipsect: 31910334Shelge (void) hpecc(io, SSE); 32011084Ssam ssect = 1; 32110334Shelge goto success; 32211084Ssam } 32311084Ssam if ((er1 & (HPER1_DCK|HPER1_ECH)) == HPER1_DCK) { 32410864Ssam if (hpecc(io, ECC) == 0) 32510334Shelge goto success; 32611084Ssam io->i_error = EECC; 32711084Ssam return (-1); 32810608Ssam } 32910608Ssam if (ML11 && (io->i_errcnt >= 16)) 33011084Ssam goto hard0; 33110608Ssam /* fall thru to retry */ 33210334Shelge hpaddr->hpcs1 = HP_DCLR|HP_GO; 33310864Ssam HPWAIT(hpaddr); 33410608Ssam if (((io->i_errcnt&07) == 4) ) { 33510334Shelge hpaddr->hpcs1 = HP_RECAL|HP_GO; 33610608Ssam hprecal = 1; 33711084Ssam goto again; 33810334Shelge } 33910334Shelge switch (hprecal) { 34010334Shelge 34110334Shelge case 1: 34210334Shelge hpaddr->hpdc = cn; 34310334Shelge hpaddr->hpcs1 = HP_SEEK|HP_GO; 34411084Ssam hprecal = 2; 34511084Ssam goto again; 34610864Ssam 34710334Shelge case 2: 34810608Ssam if (io->i_errcnt < 16 || (io->i_flgs & F_READ) == 0) 34910334Shelge goto donerecal; 35010334Shelge hpaddr->hpof = hp_offset[io->i_errcnt & 017]|HPOF_FMT22; 35110334Shelge hpaddr->hpcs1 = HP_OFFSET|HP_GO; 35211084Ssam hprecal = 3; 35311084Ssam goto again; 35410864Ssam 35511084Ssam case 3: 35610334Shelge donerecal: 35710334Shelge hprecal = 0; 35811084Ssam goto again; 35910334Shelge } 36010608Ssam if (io->i_errcnt >= 16) { 36110608Ssam hpaddr->hpcs1 = HP_RTC|HP_GO; 36210608Ssam while (hpaddr->hpds & HPDS_PIP) 36310608Ssam ; 36410334Shelge } 36511084Ssam goto again; 36611084Ssam 36711084Ssam success: /* continue with the next block */ 36810334Shelge bn++; 36910334Shelge if ((bn-startblock) * sectsiz < bytecnt) { 37011084Ssam again: /* re-read same block */ 37110334Shelge io->i_bn = bn; 37210334Shelge io->i_ma = membase + (io->i_bn - startblock)*sectsiz; 37310334Shelge io->i_cc = bytecnt - (io->i_bn - startblock)*sectsiz; 37410334Shelge #ifdef HPDEBUG 37510608Ssam printf("restart: bl %d, byte %d, mem 0x%x hprecal %d\n", 37610608Ssam io->i_bn, io->i_cc, io->i_ma, hprecal); 37710334Shelge #endif 37810626Shelge goto restart; 37910334Shelge } 38010334Shelge return (bytecnt); 38110334Shelge } 38210864Ssam 38310334Shelge hpecc(io, flag) 38410334Shelge register struct iob *io; 38510334Shelge int flag; 38610334Shelge { 38710334Shelge register unit = io->i_unit; 38810334Shelge register struct mba_regs *mbp = mbamba(unit); 38910334Shelge register struct hpdevice *rp = (struct hpdevice *)mbadrv(unit); 39010353Shelge register struct st *st = &hpst[hp_type[unit]]; 39111084Ssam int npf, bn, cn, tn, sn, bcr; 39210334Shelge 39310334Shelge if (bcr = MASKREG(mbp->mba_bcr>>16)) 39410334Shelge bcr |= 0xffff0000; /* sxt */ 39511084Ssam npf = (bcr + io->i_cc) / sectsiz; /* # sectors read */ 39611084Ssam bn = io->i_bn + npf + ssect; /* physical block #*/ 39710334Shelge switch (flag) { 39811084Ssam 39910864Ssam case ECC: { 40010334Shelge register int i; 40110334Shelge caddr_t addr; 40210334Shelge int bit, byte, mask, ecccnt = 0; 40310334Shelge 40410413Shelge printf("hp%d: soft ecc sn%d\n", unit, bn); 40510334Shelge mask = MASKREG(rp->hpec2); 40611084Ssam i = MASKREG(rp->hpec1) - 1; /* -1 makes 0 origin */ 40710334Shelge bit = i&07; 40810334Shelge i = (i&~07)>>3; 40910334Shelge byte = i; 41010334Shelge rp->hpcs1 = HP_DCLR | HP_GO; 41110334Shelge while (i <sectsiz && npf*sectsiz + i < io->i_cc && bit > -11) { 41210334Shelge addr = io->i_ma + (npf*sectsiz) + byte; 41310334Shelge #ifdef HPECCDEBUG 41410334Shelge printf("addr %x old:%x ",addr, (*addr&0xff)); 41510334Shelge #endif 41610334Shelge if ((io->i_flgs & (F_CHECK|F_HCHECK)) == 0) 41710334Shelge *addr ^= (mask << bit); /* don't 'correct' mem- 41810334Shelge * ory during Wcheck */ 41910334Shelge #ifdef HPECCDEBUG 42010334Shelge printf("new:%x\n",(*addr&0xff)); 42110334Shelge #endif 42210334Shelge byte++; 42310334Shelge i++; 42410334Shelge bit -= 8; 42511109Ssam if ((io->i_flgs & F_ECCLM) && ecccnt++ >= MAXECC) 42611084Ssam return (1); 42710334Shelge } 42810334Shelge return(0); 42911084Ssam } 43010334Shelge 43111084Ssam /* 43211084Ssam * Skip sector error. 43311084Ssam * Set skip-sector-inhibit and 43411084Ssam * read next sector 43511084Ssam */ 43611084Ssam case SSE: 43710334Shelge rp->hpcs1 = HP_DCLR | HP_GO; 43810864Ssam HPWAIT(rp); 43910334Shelge rp->hpof |= HPOF_SSEI; 44011084Ssam return (0); 44110334Shelge 44210864Ssam case BSE: { 44310626Shelge int bbn; 44411084Ssam 44510626Shelge rp->hpcs1 = HP_DCLR | HP_GO; 44610334Shelge #ifdef HPDEBUG 44710334Shelge printf("hpecc: BSE @ bn %d\n", bn); 44810334Shelge #endif 44910334Shelge cn = bn/st->nspc; 45010334Shelge sn = bn%st->nspc; 45110334Shelge tn = sn/st->nsect; 45210626Shelge sn = sn%st->nsect; 45310626Shelge bcr += sectsiz; 45410626Shelge if ((bbn = isbad(&hpbad[unit], cn, tn, sn)) < 0) 45511084Ssam return (1); 45610626Shelge bbn = st->ncyl*st->nspc - st->nsect - 1 - bbn; 45710626Shelge cn = bbn/st->nspc; 45810626Shelge sn = bbn%st->nspc; 45910626Shelge tn = sn/st->nsect; 46010626Shelge sn = sn%st->nsect; 46110626Shelge io->i_cc = sectsiz; 46210626Shelge io->i_ma += npf*sectsiz; 46310626Shelge #ifdef HPDEBUG 46410626Shelge printf("revector to cn %d tn %d sn %d mem: 0x%x\n", 46510626Shelge cn, tn, sn, io->i_ma); 46610626Shelge #endif 46710647Shelge rp->hpof &= ~HPOF_SSEI; /* clear skip sector inhibit if set */ 46810626Shelge mbp->mba_sr = -1; 46910334Shelge rp->hpdc = cn; 47010334Shelge rp->hpda = (tn<<8) + sn; 47110334Shelge mbastart(io,io->i_flgs); 47210334Shelge io->i_errcnt = 0; /* error has been corrected */ 47310864Ssam HPWAIT(rp); 47410864Ssam return (rp->hpds&HPDS_ERR); 47510334Shelge } 47611084Ssam } 47711084Ssam printf("hpecc: flag=%d\n", flag); 47811084Ssam return (1); 47910334Shelge } 48010334Shelge /*ARGSUSED*/ 48110334Shelge hpioctl(io, cmd, arg) 48210334Shelge struct iob *io; 48310334Shelge int cmd; 48410334Shelge caddr_t arg; 48510334Shelge { 48610647Shelge register unit = io->i_unit; 48710647Shelge struct st *st = &hpst[hp_type[unit]], *tmp; 48810647Shelge struct mba_drv *drv = mbadrv(unit); 48910334Shelge 49010334Shelge switch(cmd) { 49110334Shelge 49210334Shelge case SAIODEVDATA: 49310334Shelge if ((drv->mbd_dt&MBDT_TAP) == 0) { 49410353Shelge tmp = (struct st *)arg; 49510353Shelge *tmp = *st; 49611084Ssam return (0); 49710334Shelge } 49811084Ssam return (ECMD); 49910334Shelge 50011084Ssam case SAIOSSI: /* skip-sector-inhibit */ 50111084Ssam if (drv->mbd_dt&MBDT_TAP) 50211084Ssam return (ECMD); 50311084Ssam if ((io->i_flgs&F_SSI) == 0) { 50411084Ssam /* make sure this is done once only */ 50511084Ssam io->i_flgs |= F_SSI; 50611084Ssam st->nsect++; 50711084Ssam st->nspc += st->ntrak; 50810864Ssam } 50911084Ssam return (0); 51010626Shelge 51111084Ssam case SAIONOSSI: /* remove skip-sector-inhibit */ 51210626Shelge if (io->i_flgs & F_SSI) { 51310626Shelge io->i_flgs &= ~F_SSI; 51410626Shelge drv->mbd_of &= ~HPOF_SSEI; 51510626Shelge st->nsect--; 51610626Shelge st->nspc -= st->ntrak; 51710626Shelge } 51810626Shelge return(0); 51910626Shelge 52010864Ssam case SAIOSSDEV: /* drive have skip sector? */ 52111084Ssam return (RM80 ? 0 : ECMD); 52210334Shelge } 52311084Ssam return (ECMD); 52410334Shelge } 525