* 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.4 (Berkeley) %G%
* KDB50/RAxx disk device driver
#include "../machine/pte.h"
* N.B.: on KDB50, controller == adapter
* here we just use the controller number
#define NKRA 8 /* max drive number */
#define SECTSIZ 512 /* sector size in bytes */
* Parameters for the communications area:
* command and response rings both one entry.
#include "../vaxbi/bireg.h"
#include "../vaxbi/kdbreg.h"
struct disklabel kralabel
[MAXNKDB
][NKRA
];
u_long kramedia
[MAXNKDB
][NKRA
];
register struct kdb_regs
*kr
;
register struct disklabel
*lp
;
if ((u_int
)(ctlr
= io
->i_ctlr
) >= nkdb
)
if ((u_int
)(unit
= io
->i_unit
) >= NKRA
)
kr
= (struct kdb_regs
*)kdbaddr
[ctlr
];
if (kdbinit
[ctlr
] == 0) {
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(M_OP_SETCTLRC
, io
)) {
printf("kra: open error, SETCTLRC\n");
lp
= &kralabel
[ctlr
][unit
];
if (kramedia
[ctlr
][unit
] == 0) {
kdb
.kdb_cmd
.mscp_unit
= unit
;
if (kdbcmd(M_OP_ONLINE
, io
)) {
printf("kra: open error, ONLINE\n");
kramedia
[ctlr
][unit
] = kdb
.kdb_rsp
.mscp_onle
.onle_mediaid
;
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 ((u_int
)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
;
i
= ((struct kdb_regs
*)kdbaddr
[io
->i_ctlr
])->kdb_ip
;
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
);
k
->kdb_ca
.ca_rspdsc
[0] |= MSCP_OWN
| MSCP_INT
;
if ((mp
->mscp_status
& M_ST_MASK
) != M_ST_SUCCESS
)
register struct mscp
*mp
;
mp
->mscp_unit
= io
->i_unit
;
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(func
== READ
? M_OP_READ
: M_OP_WRITE
, io
)) {
printf("kra: I/O error\n");
u_long kra60_off
[] = { 0, 15884, 0, 49324, 131404, 49324, 242606, 49324 };
#define kra70_off kra60_off
u_long kra80_off
[] = { 0, 15884, 0, -1, 49324, 49324, 49910, 131404 };
u_long kra81_off
[] = { 0, 15884, 0, 131404, 49324, 498790, 563050, 131404 };
u_long kra82_off
[] = { 0, 15884, 0, 375345, 391590, 699390, 375345, 83790 };
u_long id
; /* media ID */
u_long
*off
; /* offsets */
{ MSCP_MKDRIVE2('R', 'A', 60), kra60_off
},
{ MSCP_MKDRIVE2('R', 'A', 70), kra70_off
},
{ MSCP_MKDRIVE2('R', 'A', 80), kra80_off
},
{ MSCP_MKDRIVE2('R', 'A', 81), kra81_off
},
{ MSCP_MKDRIVE2('R', 'A', 82), kra82_off
},
register struct disklabel
*lp
;
register struct partition
*pp
;
register struct mediamap
*map
;
i
= MSCP_MEDIA_DRIVE(kramedia
[io
->i_ctlr
][io
->i_unit
]);
for (map
= kra_map
; map
->id
!= 0; map
++) {
for (pp
= lp
->d_partitions
, i
= 0; i
< 8; pp
++, i
++)
pp
->p_offset
= map
->off
[i
];
printf("kra%d: media type 0x%x unsupported\n", io
->i_unit
, i
);