* Copyright (c) 1982, 1990 The Regents of the University of California.
* %sccs.include.redist.c%
* @(#)ct.c 8.1 (Berkeley) %G%
#include <hp300/dev/ctreg.h>
#include <stand.att/saio.h>
#include <hp300/stand/samachdep.h>
struct ct_ssmcmd ct_ssmc
;
int nctinfo
= sizeof(ctinfo
) / sizeof(ctinfo
[0]);
register struct ct_softc
*rs
= &ct_softc
[ctlr
][unit
];
if (hpibrecv(ctlr
, unit
, C_QSTAT
, &stat
, 1) != 1 || stat
)
if (ctident(ctlr
, unit
) < 0)
ct_ssmc
.unit
= C_SUNIT(rs
->sc_punit
);
hpibsend(ctlr
, unit
, C_CMD
, &ct_ssmc
, sizeof(ct_ssmc
));
hpibrecv(ctlr
, unit
, C_QSTAT
, &stat
, 1);
for (i
= 0; i
< nctinfo
; i
++)
if (id
== ctinfo
[i
].hwid
)
ct_softc
[ctlr
][unit
].sc_punit
= ctinfo
[i
].punit
;
* Collect device description.
* Right now we only need this to differentiate 7945 from 7946.
* Note that we always issue the describe command to unit 0.
hpibsend(ctlr
, unit
, C_CMD
, cmd
, sizeof(cmd
));
hpibrecv(ctlr
, unit
, C_EXEC
, &desc
, 37);
hpibrecv(ctlr
, unit
, C_QSTAT
, &stat
, sizeof(stat
));
bzero(name
, sizeof(name
));
register int n
= desc
.d_name
;
for (i
= 5; i
>= 0; i
--) {
name
[i
] = (n
& 0xf) + '0';
switch (ctinfo
[id
].hwid
) {
if (bcmp(name
, "079450", 6) == 0)
id
= -1; /* not really a 7946 */
register struct ct_softc
*rs
;
if (ctlr
>= NHPIB
|| hpibalive(ctlr
) == 0)
if (ctinit(ctlr
, unit
) == 0)
register int ctlr
= io
->i_adapt
;
register int unit
= io
->i_ctlr
;
register struct ct_softc
*rs
= &ct_softc
[ctlr
][unit
];
if (io
->i_cc
== 0 && (func
== F_READ
|| func
== F_WRITE
))
ct_ioc
.unit
= C_SUNIT(rs
->sc_punit
);
ct_ioc
.addr
= rs
->sc_blkno
;
else if (func
== F_WRITE
) {
ct_ioc
.addr
= rs
->sc_blkno
;
else if (func
== MTFSF
) {
ct_ioc
.addr
= rs
->sc_blkno
;
ct_ioc
.len
= io
->i_cc
= MAXBSIZE
;
hpibsend(ctlr
, unit
, C_CMD
, &ct_ioc
, sizeof(ct_ioc
));
hpibgo(ctlr
, unit
, C_EXEC
, io
->i_ma
, io
->i_cc
,
func
!= F_WRITE
? F_READ
: F_WRITE
);
while (hpibswait(ctlr
, unit
) < 0)
hpibrecv(ctlr
, unit
, C_QSTAT
, &stat
, 1);
stat
= cterror(ctlr
, unit
);
if (++rs
->sc_retry
> CTRETRY
)
rs
->sc_blkno
+= CTBTOK(io
->i_cc
);
register struct ct_softc
*rs
= &ct_softc
[ctlr
][unit
];
ct_rsc
.unit
= C_SUNIT(rs
->sc_punit
);
hpibsend(ctlr
, unit
, C_CMD
, &ct_rsc
, sizeof(ct_rsc
));
hpibrecv(ctlr
, unit
, C_EXEC
, &ct_stat
, sizeof(ct_stat
));
hpibrecv(ctlr
, unit
, C_QSTAT
, &stat
, 1);
printf("ct%d: request status fail %d\n", unit
, stat
);
if (ct_stat
.c_aef
& AEF_EOF
) {
/* 9145 drives don't increment block number at EOF */
if ((ct_stat
.c_blk
- rs
->sc_blkno
) == 0)
rs
->sc_blkno
= ct_stat
.c_blk
;
printf("ct%d err: vu 0x%x, pend 0x%x, bn%d", unit
,
ct_stat
.c_vu
, ct_stat
.c_pend
, ct_stat
.c_blk
);
printf(", R 0x%x F 0x%x A 0x%x I 0x%x\n", ct_stat
.c_ref
,
ct_stat
.c_fef
, ct_stat
.c_aef
, ct_stat
.c_ief
);