* with ECC handling and bad block forwarding.
* Also supports header io operations and
* commands to write check header and data.
#include "../vaxmba/hpreg.h"
#include "../vaxmba/mbareg.h"
#define MASKREG(reg) ((reg)&0xffff)
#define SECTSIZ 512 /* sector size in bytes */
#define HDRSIZ 4 /* number of bytes in sector header */
#define MAXECC 5 /* the maximum number of bad bits accepted in
* an ecc error when F_ECCLM is set */
char hp_type
[MAXNMBA
*8] = { 0 };
/* THIS SHOULD BE READ IN OFF THE PACK, PER DRIVE */
short hp6_off
[8] = { 0, 38, 0, -1, -1, -1, 118, -1 };
short rm3_off
[8] = { 0, 100, 0, -1, -1, -1, 310, -1 };
short rm5_off
[8] = { 0, 27, 0, 562, 589, 681, 562, 82 };
short rm80_off
[8] = { 0, 37, 0, -1, -1, -1, 115, 305 };
short hp7_off
[8] = { 0, 10, 0, 330, 340, 500, 330, 50 };
short ml_off
[8] = { 0, -1, -1, -1, -1, -1, -1, -1 };
short si9775_off
[8] = { 0, 13, 0, -1, -1, -1, 40, 441 };
short si9730_off
[8] = { 0, 50, 0, -1, -1, -1, -1, 155 };
short hpam_off
[8] = { 0, 32, 0, 668, 723, 778, 668, 98 };
short hpfj_off
[8] = { 0, 19, 0, -1, -1, -1, 398, 59 };
/* END SHOULD BE READ IN */
MBDT_RM03
, MBDT_RM05
, MBDT_RP06
, MBDT_RM80
,
MBDT_RP05
, MBDT_RP07
, MBDT_ML11A
, MBDT_ML11B
,
-1 /*9755*/, -1 /*9730*/, -1 /*Cap*/, -1 /* Eagle */,
-1 /* Eagle */, MBDT_RM02
, 0
#define RP06 (hptypes[hp_type[unit]] <= MBDT_RP06)
#define ML11 (hptypes[hp_type[unit]] == MBDT_ML11A)
#define RM80 (hptypes[hp_type[unit]] == MBDT_RM80)
HPOF_P400
, HPOF_M400
, HPOF_P400
, HPOF_M400
,
HPOF_P800
, HPOF_M800
, HPOF_P800
, HPOF_M800
,
HPOF_P1200
, HPOF_M1200
, HPOF_P1200
, HPOF_M1200
,
32, 5, 32*5, 823, rm3_off
, /* RM03 */
32, 19, 32*19, 823, rm5_off
, /* RM05 */
22, 19, 22*19, 815, hp6_off
, /* RP06 */
31, 14, 31*14, 559, rm80_off
, /* RM80 */
22, 19, 22*19, 411, hp6_off
, /* RP06 */
50, 32, 50*32, 630, hp7_off
, /* RP07 */
1, 1, 1, 1, ml_off
, /* ML11A */
1, 1, 1, 1, ml_off
, /* ML11B */
32, 40, 32*40, 843, si9775_off
, /* 9775 */
32, 10, 32*10, 823, si9730_off
, /* 9730 */
32, 16, 32*16, 1024, hpam_off
, /* capricorn */
43, 20, 43*20, 842, hpfj_off
, /* Eagle */
48, 20, 48*20, 842, hpfj_off
, /* modif. eagle */
1, 1, 1, 1, 0, /* rm02 - not used */
struct dkbad hpbad
[MAXNMBA
*8];
* When awaiting command completion, don't
* hang on to the status register since
* this ties up the controller.
#define HPWAIT(addr) while ((((addr)->hpds)&HPDS_DRY)==0) DELAY(500);
register unit
= io
->i_unit
;
struct hpdevice
*hpaddr
= (struct hpdevice
*)mbadrv(unit
);
mbainit(UNITTOMBA(unit
));
if (hp_type
[unit
] == 0) {
register type
= hpaddr
->hpdt
& MBDT_TYPE
;
for (i
= 0; hptypes
[i
]; i
++)
_stop("unknown drive type");
hpaddr
->hpcs1
= HP_DCLR
|HP_GO
; /* init drive */
hpaddr
->hpcs1
= HP_PRESET
|HP_GO
;
hpaddr
->hpof
= HPOF_FMT22
;
hp_type
[unit
] = hpmaptype(hpaddr
, i
, unit
);
* Read in the bad sector table:
* copy the contents of the io structure
* to tio for use during the bb pointer
tio
.i_bn
= st
->nspc
* st
->ncyl
- st
->nsect
;
tio
.i_ma
= (char *)&hpbad
[unit
];
tio
.i_cc
= sizeof (struct dkbad
);
for (i
= 0; i
< 5; i
++) {
if (hpstrategy(&tio
, READ
) == sizeof (struct dkbad
))
printf("Unable to read bad sector table\n");
for (i
= 0; i
< MAXBADDESC
; i
++) {
hpbad
[unit
].bt_bad
[i
].bt_cyl
= -1;
hpbad
[unit
].bt_bad
[i
].bt_trksec
= -1;
if (io
->i_boff
< 0 || io
->i_boff
> 7 ||
st
->off
[io
->i_boff
]== -1)
io
->i_boff
= st
->off
[io
->i_boff
] * st
->nspc
;
hpmaptype(hpaddr
, type
, unit
)
register struct hpdevice
*hpaddr
;
* Handle SI model byte stuff when
* we think it's an RM03 or RM05.
if (type
== 0 || type
== 1) {
if ((hpsn
& SIMB_LU
) != unit
)
switch ((hpsn
& SIMB_MB
) &~ (SIMB_S6
|SIRM03
|SIRM05
)) {
hpaddr
->hpcs1
= HP_RECAL
|HP_GO
;
* RM03: EMULEX controller. Map to correct
* drive type by checking the holding
* register for the disk geometry.
hpaddr
->hphr
= HPHR_MAXTRAK
;
ntracks
= MASKREG(hpaddr
->hphr
) + 1;
return (10); /* AMPEX capricorn */
hpaddr
->hphr
= HPHR_MAXSECT
;
ntracks
= MASKREG(hpaddr
->hphr
) + 1;
return (12); /* 48 sector Eagle */
return (11); /* 43 sector Eagle */
printf("RM02 with %d sectors/track?\n", ntracks
);
* ML11's all map to the same type.
if (type
== 6 || type
== 7)
int ssect
; /* set to 1 if we are on a track with skip sectors */
register unit
= io
->i_unit
;
struct mba_regs
*mba
= mbamba(unit
);
struct hpdevice
*hpaddr
= (struct hpdevice
*)mbadrv(unit
);
struct st
*st
= &hpst
[hp_type
[unit
]];
int cn
, tn
, sn
, bytecnt
, bytesleft
;
if ((io
->i_flgs
& (F_HDR
|F_HCHECK
)) != 0)
if ((hpaddr
->hpds
& HPDS_VV
) == 0) {
hpaddr
->hpcs1
= HP_DCLR
|HP_GO
;
hpaddr
->hpcs1
= HP_PRESET
|HP_GO
;
hpaddr
->hpof
= HPOF_FMT22
;
sn
= sn
%st
->nsect
+ ssect
;
hpaddr
->hpda
= (tn
<< 8) + sn
;
if (mbastart(io
, func
) != 0) /* start transfer */
if ((hpaddr
->hpds
&HPDS_ERR
) == 0 && (mba
->mba_sr
&MBSR_EBITS
) == 0)
/* ------- error handling ------- */
if (bytesleft
= MASKREG(mba
->mba_bcr
>>16))
bytesleft
|= 0xffff0000; /* sign ext */
bn
= io
->i_bn
+ (io
->i_cc
+ bytesleft
)/sectsiz
;
er1
= MASKREG(hpaddr
->hper1
);
er2
= MASKREG(hpaddr
->hper2
);
printf("hp error: (cyl,trk,sec)=(%d,%d,%d) ds=%b \n",
cn
, tn
, sn
, MASKREG(hpaddr
->hpds
), HPDS_BITS
);
printf("er1=%b er2=%b", er1
, HPER1_BITS
, er2
, HPER2_BITS
);
printf("\nbytes left: %d, of 0x%x, da 0x%x",-bytesleft
,
hpaddr
->hpof
, hpaddr
->hpda
);
er1
&= ~(HPER1_HCE
|HPER1_FER
);
printf("hp%d: write locked\n", unit
);
if (MASKREG(er1
) == HPER1_FER
&& RP06
)
if (++io
->i_errcnt
> 27 || (er1
& HPER1_HARD
) ||
(!ML11
&& (er2
& HPER2_HARD
))) {
if (mba
->mba_sr
& (MBSR_WCKUP
|MBSR_WCKLWR
))
io
->i_errblk
= bn
+ ssect
;
printf("hp error: (cyl,trk,sec)=(%d,%d,%d) ds=%b \n",
cn
, tn
, sn
, MASKREG(hpaddr
->hpds
), HPDS_BITS
);
printf("er1=%b er2=%b", er1
, HPER1_BITS
, er2
, HPER2_BITS
);
printf(" mr1=%o", MASKREG(hpaddr
->hpmr
));
printf(" mr2=%o", MASKREG(hpaddr
->hpmr2
));
printf("dc: %d, da: 0x%x",MASKREG(hpaddr
->hpdc
),
hpaddr
->hpcs1
= HP_DCLR
|HP_GO
;
if ((er2
& HPER2_BSE
) && !ML11
) {
if (!ssect
&& (er2
&HPER2_SSE
))
if (io
->i_flgs
& F_NBSF
) {
if (RM80
&& er2
&HPER2_SSE
) {
if ((er1
& (HPER1_DCK
|HPER1_ECH
)) == HPER1_DCK
) {
if (ML11
&& (io
->i_errcnt
>= 16))
hpaddr
->hpcs1
= HP_DCLR
|HP_GO
;
if (((io
->i_errcnt
&07) == 4) ) {
hpaddr
->hpcs1
= HP_RECAL
|HP_GO
;
hpaddr
->hpcs1
= HP_SEEK
|HP_GO
;
if (io
->i_errcnt
< 16 || (io
->i_flgs
& F_READ
) == 0)
hpaddr
->hpof
= hp_offset
[io
->i_errcnt
& 017]|HPOF_FMT22
;
hpaddr
->hpcs1
= HP_OFFSET
|HP_GO
;
if (io
->i_errcnt
>= 16) {
hpaddr
->hpcs1
= HP_RTC
|HP_GO
;
while (hpaddr
->hpds
& HPDS_PIP
)
success
: /* continue with the next block */
if ((bn
-startblock
) * sectsiz
< bytecnt
) {
again
: /* re-read same block */
io
->i_ma
= membase
+ (io
->i_bn
- startblock
)*sectsiz
;
io
->i_cc
= bytecnt
- (io
->i_bn
- startblock
)*sectsiz
;
printf("restart: bl %d, byte %d, mem 0x%x hprecal %d\n",
io
->i_bn
, io
->i_cc
, io
->i_ma
, hprecal
);
register unit
= io
->i_unit
;
register struct mba_regs
*mbp
= mbamba(unit
);
register struct hpdevice
*rp
= (struct hpdevice
*)mbadrv(unit
);
register struct st
*st
= &hpst
[hp_type
[unit
]];
int npf
, bn
, cn
, tn
, sn
, bcr
;
if (bcr
= MASKREG(mbp
->mba_bcr
>>16))
bcr
|= 0xffff0000; /* sxt */
npf
= (bcr
+ io
->i_cc
) / sectsiz
; /* # sectors read */
bn
= io
->i_bn
+ npf
+ ssect
; /* physical block #*/
int bit
, byte
, mask
, ecccnt
= 0;
printf("hp%d: soft ecc sn%d\n", unit
, bn
);
mask
= MASKREG(rp
->hpec2
);
i
= MASKREG(rp
->hpec1
) - 1; /* -1 makes 0 origin */
rp
->hpcs1
= HP_DCLR
| HP_GO
;
while (i
<sectsiz
&& npf
*sectsiz
+ i
< io
->i_cc
&& bit
> -11) {
addr
= io
->i_ma
+ (npf
*sectsiz
) + byte
;
printf("addr %x old:%x ",addr
, (*addr
&0xff));
if ((io
->i_flgs
& (F_CHECK
|F_HCHECK
)) == 0)
*addr
^= (mask
<< bit
); /* don't 'correct' mem-
printf("new:%x\n",(*addr
&0xff));
if ((io
->i_flgs
& F_ECCLM
) && ecccnt
++ >= MAXECC
)
* Set skip-sector-inhibit and
rp
->hpcs1
= HP_DCLR
| HP_GO
;
rp
->hpcs1
= HP_DCLR
| HP_GO
;
printf("hpecc: BSE @ bn %d\n", bn
);
if ((bbn
= isbad(&hpbad
[unit
], cn
, tn
, sn
)) < 0)
bbn
= st
->ncyl
*st
->nspc
- st
->nsect
- 1 - bbn
;
printf("revector to cn %d tn %d sn %d mem: 0x%x\n",
rp
->hpof
&= ~HPOF_SSEI
; /* clear skip sector inhibit if set */
io
->i_errcnt
= 0; /* error has been corrected */
return (rp
->hpds
&HPDS_ERR
);
printf("hpecc: flag=%d\n", flag
);
register unit
= io
->i_unit
;
struct st
*st
= &hpst
[hp_type
[unit
]], *tmp
;
struct mba_drv
*drv
= mbadrv(unit
);
if ((drv
->mbd_dt
&MBDT_TAP
) == 0) {
case SAIOSSI
: /* skip-sector-inhibit */
if (drv
->mbd_dt
&MBDT_TAP
)
if ((io
->i_flgs
&F_SSI
) == 0) {
/* make sure this is done once only */
case SAIONOSSI
: /* remove skip-sector-inhibit */
if (io
->i_flgs
& F_SSI
) {
drv
->mbd_of
&= ~HPOF_SSEI
;
case SAIOSSDEV
: /* drive have skip sector? */
return (RM80
? 0 : ECMD
);