* Copyright (c) 1988 Regents of the University of California.
* Redistribution and use in source and binary forms are permitted
* provided that the above copyright notice and this paragraph are
* duplicated in all such forms and that any documentation,
* advertising materials, and other materials related to such
* distribution and use acknowledge that the software was developed
* by the University of California, Berkeley. The name of the
* University may not be used to endorse or promote products derived
* from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
* @(#)kdb.c 7.3 (Berkeley) %G%
* KDB50/RAxx disk device driver
#include "../machine/pte.h"
#define NKRA 8 /* max unit number on ctlr */
#define SECTSIZ 512 /* sector size in bytes */
* Parameters for the communications area
#include "../vaxbi/bireg.h"
#include "../vaxbi/kdbreg.h"
char kratype
[MAXNKDB
* NKRA
];
struct disklabel kralabel
[MAXNUBA
* NKRA
];
register struct mscp
*mp
;
register struct kdb_regs
*kr
;
register struct disklabel
*lp
;
if ((i
= io
->i_unit
) >= nkdb
)
kr
= (struct kdb_regs
*)kdbaddr
[i
];
kr
->kdb_bi
.bi_csr
|= BICSR_NRST
;
/* clear any bus errors */
kr
->kdb_bi
.bi_ber
= ~(BIBER_MBZ
|BIBER_NMR
|BIBER_UPEN
);
while ((kr
->kdb_sa
& KDB_STEP1
) == 0)
kr
->kdb_bi
.bi_bcicsr
|= BCI_STOPEN
| BCI_IDENTEN
;
while ((kr
->kdb_sa
& KDB_STEP2
) == 0)
kr
->kdb_sw
= (int)&kdb
.kdb_ca
.ca_rspdsc
[0];
while ((kr
->kdb_sa
& KDB_STEP3
) == 0)
kr
->kdb_sw
= (int)&kdb
.kdb_ca
.ca_rspdsc
[0] >> 16;
while ((kr
->kdb_sa
& KDB_STEP4
) == 0)
kdb
.kdb_ca
.ca_rspdsc
[0] = (long)&kdb
.kdb_rsp
.mscp_cmdref
;
kdb
.kdb_ca
.ca_cmddsc
[0] = (long)&kdb
.kdb_cmd
.mscp_cmdref
;
if (kdbcmd(kr
, M_OP_SETCTLRC
)) {
printf("open error, SETCTLRC");
if (kratype
[unit
] == 0) {
kdb
.kdb_cmd
.mscp_unit
= UNITTODRIVE(unit
);
if (kdbcmd(kr
, M_OP_ONLINE
)) {
printf("open error, ONLINE");
kratype
[unit
] = kdb
.kdb_rsp
.mscp_onle
.onle_drivetype
;
if (krastrategy(&tio
, READ
) != SECTSIZ
)
*lp
= *(struct disklabel
*)(lbuf
+ LABELOFFSET
);
if (lp
->d_magic
!= DISKMAGIC
|| lp
->d_magic2
!= DISKMAGIC
)
printf("kra%d: unlabeled\n", unit
);
if ((unsigned)io
->i_part
>= lp
->d_npartitions
||
(io
->i_boff
= lp
->d_partitions
[io
->i_part
].p_offset
) == -1)
register struct kdb
*k
= &kdb
;
register struct mscp
*mp
;
k
->kdb_cmd
.mscp_opcode
= op
;
k
->kdb_rsp
.mscp_msglen
= MSCP_MSGLEN
;
k
->kdb_cmd
.mscp_msglen
= MSCP_MSGLEN
;
k
->kdb_ca
.ca_rspdsc
[0] |= MSCP_OWN
| MSCP_INT
;
k
->kdb_ca
.ca_cmddsc
[0] |= MSCP_OWN
| MSCP_INT
;
if (k
->kdb_ca
.ca_rspint
== 0)
if (mp
->mscp_opcode
== (op
| M_OP_END
))
printf("unexpected rsp type %x op %x ignored\n",
MSCP_MSGTYPE(mp
->mscp_msgtc
), mp
->mscp_opcode
);
if ((mp
->mscp_status
& M_ST_MASK
) != M_ST_SUCCESS
)
register struct mscp
*mp
;
mp
->mscp_unit
= io
->i_unit
& 7;
mp
->mscp_seq
.seq_lbn
= io
->i_bn
;
mp
->mscp_seq
.seq_bytecount
= io
->i_cc
;
mp
->mscp_seq
.seq_buffer
= (long)io
->i_ma
| KDB_PHYS
;
if (kdbcmd((struct kdb_regs
*)kdbaddr
[io
->i_unit
>> 3],
func
== READ
? M_OP_READ
: M_OP_WRITE
)) {
printf("kra: I/O error\n");
u_long kra25_off
[] = { 0, 15884, 0, -1, -1, -1, 25916, -1 };
u_long kra60_off
[] = { 0, 15884, 0, 49324, 131404, 49324, 242606, 49324 };
u_long kra80_off
[] = { 0, 15884, 0, -1, 49324, 49324, 49910, 131404 };
u_long kra81_off
[] = { 0, 15884, 0, 131404, 49324, 498790, 563050, 131404 };
kra80_off
, /* 1 = ra80 */
kra25_off
, /* 2 = rc25-r */
kra25_off
, /* 3 = rc25-r */
kra60_off
, /* 4 = ra60 */
kra81_off
, /* 5 = ra81 */
#define NOFFS (sizeof(kra_off) / sizeof(kra_off[0]))
register struct disklabel
*lp
;
register struct partition
*pp
;
if ((i
= kratype
[io
->i_unit
]) >= NOFFS
|| (off
= kra_off
[i
]) == 0) {
printf("kra%d: type %d unsupported\n", io
->i_unit
, i
);
for (pp
= lp
->d_partitions
, i
= 0; i
< 8; pp
++, i
++)