summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2007-08-05 19:05:10 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2007-08-05 19:05:10 +0000
commit9909f500d5c88e7e356ce340ff0103350b2607ed (patch)
tree3762107997d32a686700984270fc65fe80b5761d /sys
parent5ad64e242e3fda6dbfa861b5c0ba5693c8a594dd (diff)
Add support for the (non-pci) NCR 53c720/770 in big-endian mode.
ok martin@, krw@, deraadt@
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/ic/siop.c155
-rw-r--r--sys/dev/ic/siop_common.c49
-rw-r--r--sys/dev/ic/siopreg.h7
-rw-r--r--sys/dev/ic/siopvar_common.h9
4 files changed, 125 insertions, 95 deletions
diff --git a/sys/dev/ic/siop.c b/sys/dev/ic/siop.c
index 55adcad34d9..2ae298a12fe 100644
--- a/sys/dev/ic/siop.c
+++ b/sys/dev/ic/siop.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: siop.c,v 1.47 2007/05/08 03:16:16 deraadt Exp $ */
+/* $OpenBSD: siop.c,v 1.48 2007/08/05 19:05:09 kettenis Exp $ */
/* $NetBSD: siop.c,v 1.79 2005/11/18 23:10:32 bouyer Exp $ */
/*
@@ -164,7 +164,7 @@ siop_script_read(sc, offset)
return bus_space_read_4(sc->sc_c.sc_ramt, sc->sc_c.sc_ramh,
offset * 4);
} else {
- return letoh32(sc->sc_c.sc_script[offset]);
+ return siop_ctoh32(&sc->sc_c, sc->sc_c.sc_script[offset]);
}
}
@@ -178,7 +178,7 @@ siop_script_write(sc, offset, val)
bus_space_write_4(sc->sc_c.sc_ramt, sc->sc_c.sc_ramh,
offset * 4, val);
} else {
- sc->sc_c.sc_script[offset] = htole32(val);
+ sc->sc_c.sc_script[offset] = siop_htoc32(&sc->sc_c, val);
}
}
@@ -263,30 +263,32 @@ siop_reset(sc)
} else {
for (j = 0;
j < (sizeof(siop_script) / sizeof(siop_script[0])); j++) {
- sc->sc_c.sc_script[j] = htole32(siop_script[j]);
+ sc->sc_c.sc_script[j] =
+ siop_htoc32(&sc->sc_c, siop_script[j]);
}
for (j = 0; j <
(sizeof(E_abs_msgin_Used) / sizeof(E_abs_msgin_Used[0]));
j++) {
sc->sc_c.sc_script[E_abs_msgin_Used[j]] =
- htole32(sc->sc_c.sc_scriptaddr + Ent_msgin_space);
+ siop_htoc32(&sc->sc_c,
+ sc->sc_c.sc_scriptaddr + Ent_msgin_space);
}
if (sc->sc_c.features & SF_CHIP_LED0) {
for (j = 0; j < (sizeof(siop_led_on) /
sizeof(siop_led_on[0])); j++)
sc->sc_c.sc_script[
Ent_led_on1 / sizeof(siop_led_on[0]) + j
- ] = htole32(siop_led_on[j]);
+ ] = siop_htoc32(&sc->sc_c, siop_led_on[j]);
for (j = 0; j < (sizeof(siop_led_on) /
sizeof(siop_led_on[0])); j++)
sc->sc_c.sc_script[
Ent_led_on2 / sizeof(siop_led_on[0]) + j
- ] = htole32(siop_led_on[j]);
+ ] = siop_htoc32(&sc->sc_c, siop_led_on[j]);
for (j = 0; j < (sizeof(siop_led_off) /
sizeof(siop_led_off[0])); j++)
sc->sc_c.sc_script[
Ent_led_off / sizeof(siop_led_off[0]) + j
- ] = htole32(siop_led_off[j]);
+ ] = siop_htoc32(&sc->sc_c, siop_led_off[j]);
}
}
sc->script_free_lo = sizeof(siop_script) / sizeof(siop_script[0]);
@@ -470,7 +472,8 @@ siop_intr(v)
if (siop_cmd)
printf("last msg_in=0x%x status=0x%x\n",
siop_cmd->cmd_tables->msg_in[0],
- letoh32(siop_cmd->cmd_tables->status));
+ siop_ctoh32(&sc->sc_c,
+ siop_cmd->cmd_tables->status));
else
printf("current DSA invalid\n");
need_reset = 1;
@@ -595,7 +598,7 @@ siop_intr(v)
*/
if (siop_cmd) {
siop_cmd->cmd_tables->status =
- htole32(SCSI_CHECK);
+ siop_htoc32(&sc->sc_c, SCSI_CHECK);
goto end;
}
printf("%s: unexpected disconnect without "
@@ -830,7 +833,7 @@ scintr:
if (msgin == MSG_IGN_WIDE_RESIDUE) {
/* use the extmsgdata table to get the second byte */
siop_cmd->cmd_tables->t_extmsgdata.count =
- htole32(1);
+ siop_htoc32(&sc->sc_c, 1);
siop_table_sync(siop_cmd,
BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
CALL_SCRIPT(Ent_get_extmsgdata);
@@ -843,7 +846,8 @@ scintr:
printf("unhandled message 0x%x\n",
siop_cmd->cmd_tables->msg_in[0]);
siop_cmd->cmd_tables->msg_out[0] = MSG_MESSAGE_REJECT;
- siop_cmd->cmd_tables->t_msgout.count= htole32(1);
+ siop_cmd->cmd_tables->t_msgout.count =
+ siop_htoc32(&sc->sc_c, 1);
siop_table_sync(siop_cmd,
BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
CALL_SCRIPT(Ent_send_msgout);
@@ -861,7 +865,8 @@ scintr:
sc->sc_c.sc_dev.dv_xname,
siop_cmd->cmd_tables->msg_in[1]);
siop_cmd->cmd_tables->t_extmsgdata.count =
- htole32(siop_cmd->cmd_tables->msg_in[1] - 1);
+ siop_htoc32(&sc->sc_c,
+ siop_cmd->cmd_tables->msg_in[1] - 1);
siop_table_sync(siop_cmd,
BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
CALL_SCRIPT(Ent_get_extmsgdata);
@@ -967,7 +972,8 @@ scintr:
}
/* send a message reject */
siop_cmd->cmd_tables->msg_out[0] = MSG_MESSAGE_REJECT;
- siop_cmd->cmd_tables->t_msgout.count = htole32(1);
+ siop_cmd->cmd_tables->t_msgout.count =
+ siop_htoc32(&sc->sc_c, 1);
siop_table_sync(siop_cmd,
BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
CALL_SCRIPT(Ent_send_msgout);
@@ -1015,9 +1021,10 @@ scintr:
#ifdef SIOP_DEBUG_INTR
printf("done, DSA=0x%lx target id 0x%x last msg "
"in=0x%x status=0x%x\n", (u_long)siop_cmd->cmd_c.dsa,
- letoh32(siop_cmd->cmd_tables->id),
+ siop_ctoh32(&sc->sc_c, siop_cmd->cmd_tables->id),
siop_cmd->cmd_tables->msg_in[0],
- letoh32(siop_cmd->cmd_tables->status));
+ siop_ctoh32(&sc->sc_c,
+ siop_cmd->cmd_tables->status));
#endif
INCSTAT(siop_stat_intr_done);
/* update resid. */
@@ -1063,7 +1070,7 @@ end:
* Otherwise wait for siop_scsicmd_end(), we may need to cleanup the
* queue
*/
- xs->status = letoh32(siop_cmd->cmd_tables->status);
+ xs->status = siop_ctoh32(&sc->sc_c, siop_cmd->cmd_tables->status);
if (xs->status == SCSI_OK)
CALL_SCRIPT(Ent_script_sched);
else
@@ -1161,7 +1168,7 @@ siop_scsicmd_end(siop_cmd)
int error;
bzero(cmd, sizeof(*cmd));
siop_cmd->cmd_c.siop_tables->cmd.count =
- htole32(sizeof(struct scsi_sense));
+ siop_htoc32(&sc->sc_c, sizeof(struct scsi_sense));
cmd->opcode = REQUEST_SENSE;
cmd->byte2 = xs->sc_link->lun << 5;
cmd->unused[0] = cmd->unused[1] = 0;
@@ -1438,7 +1445,8 @@ siop_scsicmd(xs)
bzero(&siop_cmd->cmd_c.siop_tables->xscmd,
sizeof(siop_cmd->cmd_c.siop_tables->xscmd));
bcopy(xs->cmd, &siop_cmd->cmd_c.siop_tables->xscmd, xs->cmdlen);
- siop_cmd->cmd_c.siop_tables->cmd.count = htole32(xs->cmdlen);
+ siop_cmd->cmd_c.siop_tables->cmd.count =
+ siop_htoc32(&sc->sc_c, xs->cmdlen);
/* load the DMA maps */
if (xs->flags & (SCSI_DATA_IN | SCSI_DATA_OUT)) {
@@ -1635,8 +1643,8 @@ again:
/* Ok, we can add the tag message */
if (tag > 0) {
#ifdef DIAGNOSTIC
- int msgcount =
- letoh32(siop_cmd->cmd_tables->t_msgout.count);
+ int msgcount = siop_ctoh32(&sc->sc_c,
+ siop_cmd->cmd_tables->t_msgout.count);
if (msgcount != 1)
printf("%s:%d:%d: tag %d with msgcount %d\n",
sc->sc_c.sc_dev.dv_xname, target, lun, tag,
@@ -1650,7 +1658,8 @@ again:
siop_cmd->cmd_tables->msg_out[1] =
MSG_ORDERED_Q_TAG;
siop_cmd->cmd_tables->msg_out[2] = tag;
- siop_cmd->cmd_tables->t_msgout.count = htole32(3);
+ siop_cmd->cmd_tables->t_msgout.count =
+ siop_htoc32(&sc->sc_c, 3);
}
/* note that we started a new command */
newcmd = 1;
@@ -1677,7 +1686,8 @@ again:
/* CMD script: MOVE MEMORY addr */
siop_xfer = (struct siop_xfer*)siop_cmd->cmd_tables;
siop_xfer->resel[E_ldsa_abs_slot_Used[0]] =
- htole32(sc->sc_c.sc_scriptaddr + Ent_script_sched_slot0 + slot * 8);
+ siop_htoc32(&sc->sc_c, sc->sc_c.sc_scriptaddr +
+ Ent_script_sched_slot0 + slot * 8);
siop_table_sync(siop_cmd, BUS_DMASYNC_PREWRITE);
/* scheduler slot: JUMP ldsa_select */
siop_script_write(sc,
@@ -1758,12 +1768,13 @@ siop_dump_script(sc)
int i;
for (i = 0; i < PAGE_SIZE / 4; i += 2) {
printf("0x%04x: 0x%08x 0x%08x", i * 4,
- letoh32(sc->sc_c.sc_script[i]),
- letoh32(sc->sc_c.sc_script[i+1]));
- if ((letoh32(sc->sc_c.sc_script[i]) & 0xe0000000) ==
- 0xc0000000) {
+ siop_ctoh32(&sc->sc_c, sc->sc_c.sc_script[i]),
+ siop_ctoh32(&sc->sc_c, sc->sc_c.sc_script[i+1]));
+ if ((siop_ctoh32(&sc->sc_c,
+ sc->sc_c.sc_script[i]) & 0xe0000000) == 0xc0000000) {
i++;
- printf(" 0x%08x", letoh32(sc->sc_c.sc_script[i+1]));
+ printf(" 0x%08x", siop_ctoh32(&sc->sc_c,
+ sc->sc_c.sc_script[i+1]));
}
printf("\n");
}
@@ -1774,7 +1785,7 @@ void
siop_morecbd(sc)
struct siop_softc *sc;
{
- int error, i, j, s;
+ int error, off, i, j, s;
bus_dma_segment_t seg;
int rseg;
struct siop_cbd *newcbd;
@@ -1845,6 +1856,7 @@ siop_morecbd(sc)
}
/* Use two loops since bailing out above releases allocated memory */
+ off = (sc->sc_c.features & SF_CHIP_BE) ? 3 : 0;
for (i = 0; i < SIOP_NCMDPB; i++) {
newcbd->cmds[i].cmd_c.siop_sc = &sc->sc_c;
newcbd->cmds[i].siop_cbdp = newcbd;
@@ -1855,58 +1867,60 @@ siop_morecbd(sc)
i * sizeof(struct siop_xfer);
newcbd->cmds[i].cmd_c.dsa = dsa;
newcbd->cmds[i].cmd_c.status = CMDST_FREE;
- xfer->siop_tables.t_msgout.count= htole32(1);
- xfer->siop_tables.t_msgout.addr = htole32(dsa);
- xfer->siop_tables.t_msgin.count= htole32(1);
- xfer->siop_tables.t_msgin.addr = htole32(dsa +
- offsetof(struct siop_common_xfer, msg_in));
- xfer->siop_tables.t_extmsgin.count= htole32(2);
- xfer->siop_tables.t_extmsgin.addr = htole32(dsa +
- offsetof(struct siop_common_xfer, msg_in) + 1);
- xfer->siop_tables.t_extmsgdata.addr = htole32(dsa +
- offsetof(struct siop_common_xfer, msg_in) + 3);
- xfer->siop_tables.t_status.count= htole32(1);
- xfer->siop_tables.t_status.addr = htole32(dsa +
- offsetof(struct siop_common_xfer, status));
- xfer->siop_tables.cmd.count= htole32(0);
- xfer->siop_tables.cmd.addr = htole32(dsa +
- offsetof(struct siop_common_xfer, xscmd));
+ xfer->siop_tables.t_msgout.count= siop_htoc32(&sc->sc_c, 1);
+ xfer->siop_tables.t_msgout.addr = siop_htoc32(&sc->sc_c, dsa);
+ xfer->siop_tables.t_msgin.count= siop_htoc32(&sc->sc_c, 1);
+ xfer->siop_tables.t_msgin.addr = siop_htoc32(&sc->sc_c,
+ dsa + offsetof(struct siop_common_xfer, msg_in));
+ xfer->siop_tables.t_extmsgin.count= siop_htoc32(&sc->sc_c, 2);
+ xfer->siop_tables.t_extmsgin.addr = siop_htoc32(&sc->sc_c,
+ dsa + offsetof(struct siop_common_xfer, msg_in) + 1);
+ xfer->siop_tables.t_extmsgdata.addr = siop_htoc32(&sc->sc_c,
+ dsa + offsetof(struct siop_common_xfer, msg_in) + 3);
+ xfer->siop_tables.t_status.count= siop_htoc32(&sc->sc_c, 1);
+ xfer->siop_tables.t_status.addr = siop_htoc32(&sc->sc_c,
+ dsa + offsetof(struct siop_common_xfer, status) + off);
+ xfer->siop_tables.cmd.count = siop_htoc32(&sc->sc_c, 0);
+ xfer->siop_tables.cmd.addr = siop_htoc32(&sc->sc_c,
+ dsa + offsetof(struct siop_common_xfer, xscmd));
/* The select/reselect script */
scr = &xfer->resel[0];
for (j = 0; j < sizeof(load_dsa) / sizeof(load_dsa[0]); j++)
- scr[j] = htole32(load_dsa[j]);
+ scr[j] = siop_htoc32(&sc->sc_c, load_dsa[j]);
/*
* 0x78000000 is a 'move data8 to reg'. data8 is the second
* octet, reg offset is the third.
*/
- scr[Ent_rdsa0 / 4] =
- htole32(0x78100000 | ((dsa & 0x000000ff) << 8));
- scr[Ent_rdsa1 / 4] =
- htole32(0x78110000 | ( dsa & 0x0000ff00 ));
- scr[Ent_rdsa2 / 4] =
- htole32(0x78120000 | ((dsa & 0x00ff0000) >> 8));
- scr[Ent_rdsa3 / 4] =
- htole32(0x78130000 | ((dsa & 0xff000000) >> 16));
- scr[E_ldsa_abs_reselected_Used[0]] =
- htole32(sc->sc_c.sc_scriptaddr + Ent_reselected);
- scr[E_ldsa_abs_reselect_Used[0]] =
- htole32(sc->sc_c.sc_scriptaddr + Ent_reselect);
- scr[E_ldsa_abs_selected_Used[0]] =
- htole32(sc->sc_c.sc_scriptaddr + Ent_selected);
- scr[E_ldsa_abs_data_Used[0]] =
- htole32(dsa + sizeof(struct siop_common_xfer) +
- Ent_ldsa_data);
+ scr[Ent_rdsa0 / 4] = siop_htoc32(&sc->sc_c,
+ 0x78100000 | ((dsa & 0x000000ff) << 8));
+ scr[Ent_rdsa1 / 4] = siop_htoc32(&sc->sc_c,
+ 0x78110000 | ( dsa & 0x0000ff00 ));
+ scr[Ent_rdsa2 / 4] = siop_htoc32(&sc->sc_c,
+ 0x78120000 | ((dsa & 0x00ff0000) >> 8));
+ scr[Ent_rdsa3 / 4] = siop_htoc32(&sc->sc_c,
+ 0x78130000 | ((dsa & 0xff000000) >> 16));
+ scr[E_ldsa_abs_reselected_Used[0]] = siop_htoc32(&sc->sc_c,
+ sc->sc_c.sc_scriptaddr + Ent_reselected);
+ scr[E_ldsa_abs_reselect_Used[0]] = siop_htoc32(&sc->sc_c,
+ sc->sc_c.sc_scriptaddr + Ent_reselect);
+ scr[E_ldsa_abs_selected_Used[0]] = siop_htoc32(&sc->sc_c,
+ sc->sc_c.sc_scriptaddr + Ent_selected);
+ scr[E_ldsa_abs_data_Used[0]] = siop_htoc32(&sc->sc_c,
+ dsa + sizeof(struct siop_common_xfer) + Ent_ldsa_data);
/* JUMP foo, IF FALSE - used by MOVE MEMORY to clear the slot */
- scr[Ent_ldsa_data / 4] = htole32(0x80000000);
+ scr[Ent_ldsa_data / 4] = siop_htoc32(&sc->sc_c, 0x80000000);
s = splbio();
TAILQ_INSERT_TAIL(&sc->free_list, &newcbd->cmds[i], next);
splx(s);
#ifdef SIOP_DEBUG
printf("tables[%d]: in=0x%x out=0x%x status=0x%x "
"offset=0x%x\n", i,
- letoh32(newcbd->cmds[i].cmd_tables->t_msgin.addr),
- letoh32(newcbd->cmds[i].cmd_tables->t_msgout.addr),
- letoh32(newcbd->cmds[i].cmd_tables->t_status.addr));
+ siop_ctoh32(&sc->sc_c,
+ newcbd->cmds[i].cmd_tables->t_msgin.addr),
+ siop_ctoh32(&sc->sc_c,
+ newcbd->cmds[i].cmd_tables->t_msgout.addr),
+ siop_ctoh32(&sc->sc_c,
+ newcbd->cmds[i].cmd_tables->t_status.addr));
#endif
}
s = splbio();
@@ -1962,10 +1976,11 @@ siop_get_lunsw(sc)
for (i = 0; i < sizeof(lun_switch) / sizeof(lun_switch[0]);
i++)
sc->sc_c.sc_script[sc->script_free_lo + i] =
- htole32(lun_switch[i]);
+ siop_htoc32(&sc->sc_c, lun_switch[i]);
sc->sc_c.sc_script[
sc->script_free_lo + E_abs_lunsw_return_Used[0]] =
- htole32(sc->sc_c.sc_scriptaddr + Ent_lunsw_return);
+ siop_htoc32(&sc->sc_c,
+ sc->sc_c.sc_scriptaddr + Ent_lunsw_return);
}
lunsw->lunsw_off = sc->script_free_lo;
lunsw->lunsw_size = sizeof(lun_switch) / sizeof(lun_switch[0]);
@@ -2120,7 +2135,7 @@ siop_add_dev(sc, target, lun)
i < sizeof(tag_switch) / sizeof(tag_switch[0]);
i++) {
sc->sc_c.sc_script[sc->script_free_hi + i] =
- htole32(tag_switch[i]);
+ siop_htoc32(&sc->sc_c, tag_switch[i]);
}
}
siop_script_write(sc,
diff --git a/sys/dev/ic/siop_common.c b/sys/dev/ic/siop_common.c
index e4058bf0b86..dfc99fc02a0 100644
--- a/sys/dev/ic/siop_common.c
+++ b/sys/dev/ic/siop_common.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: siop_common.c,v 1.29 2006/03/16 22:11:24 miod Exp $ */
+/* $OpenBSD: siop_common.c,v 1.30 2007/08/05 19:05:09 kettenis Exp $ */
/* $NetBSD: siop_common.c,v 1.37 2005/02/27 00:27:02 perry Exp $ */
/*
@@ -248,7 +248,7 @@ siop_setuptables(siop_cmd)
int *targ_flags = &sc->targets[target]->flags;
int quirks;
- siop_cmd->siop_tables->id = htole32(sc->targets[target]->id);
+ siop_cmd->siop_tables->id = siop_htoc32(sc, sc->targets[target]->id);
memset(siop_cmd->siop_tables->msg_out, 0,
sizeof(siop_cmd->siop_tables->msg_out));
/* request sense doesn't disconnect */
@@ -267,7 +267,7 @@ siop_setuptables(siop_cmd)
siop_cmd->siop_tables->msg_out[0] = MSG_IDENTIFY(lun, 0);
else
siop_cmd->siop_tables->msg_out[0] = MSG_IDENTIFY(lun, 1);
- siop_cmd->siop_tables->t_msgout.count= htole32(msgoffset);
+ siop_cmd->siop_tables->t_msgout.count = siop_htoc32(sc, msgoffset);
if (sc->targets[target]->status == TARST_ASYNC) {
*targ_flags &= TARF_DT; /* Save TARF_DT 'cuz we don't set it here */
quirks = xs->sc_link->quirks;
@@ -314,7 +314,7 @@ siop_setuptables(siop_cmd)
siop_cmd->flags |= CMDFL_TAG;
}
siop_cmd->siop_tables->status =
- htole32(SCSI_SIOP_NOSTATUS); /* set invalid status */
+ siop_htoc32(sc, SCSI_SIOP_NOSTATUS); /* set invalid status */
if ((xs->flags & (SCSI_DATA_IN | SCSI_DATA_OUT)) ||
siop_cmd->status == CMDST_SENSE) {
@@ -322,9 +322,11 @@ siop_setuptables(siop_cmd)
sizeof(siop_cmd->siop_tables->data));
for (i = 0; i < siop_cmd->dmamap_data->dm_nsegs; i++) {
siop_cmd->siop_tables->data[i].count =
- htole32(siop_cmd->dmamap_data->dm_segs[i].ds_len);
+ siop_htoc32(sc,
+ siop_cmd->dmamap_data->dm_segs[i].ds_len);
siop_cmd->siop_tables->data[i].addr =
- htole32(siop_cmd->dmamap_data->dm_segs[i].ds_addr);
+ siop_htoc32(sc,
+ siop_cmd->dmamap_data->dm_segs[i].ds_addr);
}
}
}
@@ -364,11 +366,11 @@ siop_wdtr_neg(siop_cmd)
printf("%s: rejecting invalid wide negotiation from "
"target %d (%d)\n", sc->sc_dev.dv_xname, target,
tables->msg_in[3]);
- tables->t_msgout.count= htole32(1);
+ tables->t_msgout.count = siop_htoc32(sc, 1);
tables->msg_out[0] = MSG_MESSAGE_REJECT;
return SIOP_NEG_MSGOUT;
}
- tables->id = htole32(sc->targets[target]->id);
+ tables->id = siop_htoc32(sc, sc->targets[target]->id);
bus_space_write_1(sc->sc_rt, sc->sc_rh,
SIOP_SCNTL3,
(sc->targets[target]->id >> 24) & 0xff);
@@ -393,7 +395,7 @@ siop_wdtr_neg(siop_cmd)
siop_target->flags &= ~TARF_ISWIDE;
sc->targets[target]->id &= ~(SCNTL3_EWS << 24);
}
- tables->id = htole32(sc->targets[target]->id);
+ tables->id = siop_htoc32(sc, sc->targets[target]->id);
bus_space_write_1(sc->sc_rt, sc->sc_rh, SIOP_SCNTL3,
(sc->targets[target]->id >> 24) & 0xff);
/*
@@ -517,7 +519,7 @@ siop_ppr_neg(siop_cmd)
printf("%s: rejecting invalid PPR negotiation from "
"target %d\n", sc->sc_dev.dv_xname, target);
reject:
- tables->t_msgout.count= htole32(1);
+ tables->t_msgout.count = siop_htoc32(sc, 1);
tables->msg_out[0] = MSG_MESSAGE_REJECT;
return SIOP_NEG_MSGOUT;
}
@@ -582,7 +584,7 @@ siop_sdtr_neg(siop_cmd)
*/
reject:
send_msgout = 1;
- tables->t_msgout.count= htole32(1);
+ tables->t_msgout.count = siop_htoc32(sc, 1);
tables->msg_out[0] = MSG_MESSAGE_REJECT;
sc->targets[target]->id &= ~(SCNTL3_SCF_MASK << 24);
sc->targets[target]->id &= ~(SCNTL3_ULTRA << 24);
@@ -645,7 +647,7 @@ end:
#ifdef DEBUG
printf("id now 0x%x\n", sc->targets[target]->id);
#endif
- tables->id = htole32(sc->targets[target]->id);
+ tables->id = siop_htoc32(sc, sc->targets[target]->id);
bus_space_write_1(sc->sc_rt, sc->sc_rh, SIOP_SCNTL3,
(sc->targets[target]->id >> 24) & 0xff);
bus_space_write_1(sc->sc_rt, sc->sc_rh, SIOP_SXFER,
@@ -669,7 +671,7 @@ siop_sdtr_msg(siop_cmd, offset, ssync, soff)
siop_cmd->siop_tables->msg_out[offset + 3] = ssync;
siop_cmd->siop_tables->msg_out[offset + 4] = soff;
siop_cmd->siop_tables->t_msgout.count =
- htole32(offset + MSG_EXT_SDTR_LEN + 2);
+ siop_htoc32(siop_cmd->siop_sc, offset + MSG_EXT_SDTR_LEN + 2);
}
void
@@ -683,7 +685,7 @@ siop_wdtr_msg(siop_cmd, offset, wide)
siop_cmd->siop_tables->msg_out[offset + 2] = MSG_EXT_WDTR;
siop_cmd->siop_tables->msg_out[offset + 3] = wide;
siop_cmd->siop_tables->t_msgout.count =
- htole32(offset + MSG_EXT_WDTR_LEN + 2);
+ siop_htoc32(siop_cmd->siop_sc, offset + MSG_EXT_WDTR_LEN + 2);
}
void
@@ -701,7 +703,7 @@ siop_ppr_msg(siop_cmd, offset, ssync, soff)
siop_cmd->siop_tables->msg_out[offset + 6] = 1; /* wide */
siop_cmd->siop_tables->msg_out[offset + 7] = MSG_EXT_PPR_PROT_DT;
siop_cmd->siop_tables->t_msgout.count =
- htole32(offset + MSG_EXT_PPR_LEN + 2);
+ siop_htoc32(siop_cmd->siop_sc, offset + MSG_EXT_PPR_LEN + 2);
}
void
@@ -786,6 +788,7 @@ siop_sdp(siop_cmd, offset)
struct siop_common_cmd *siop_cmd;
int offset;
{
+ struct siop_common_softc *sc = siop_cmd->siop_sc;
scr_table_t *table;
if ((siop_cmd->xs->flags & (SCSI_DATA_OUT | SCSI_DATA_IN))
@@ -827,9 +830,9 @@ siop_sdp(siop_cmd, offset)
table = &siop_cmd->siop_tables->data[offset];
/* "cut" already transfered data from this table */
table->addr =
- htole32(letoh32(table->addr) +
- letoh32(table->count) - siop_cmd->resid);
- table->count = htole32(siop_cmd->resid);
+ siop_htoc32(sc, siop_ctoh32(sc, table->addr) +
+ siop_ctoh32(sc, table->count) - siop_cmd->resid);
+ table->count = siop_htoc32(sc, siop_cmd->resid);
}
/*
@@ -847,6 +850,7 @@ siop_update_resid(siop_cmd, offset)
struct siop_common_cmd *siop_cmd;
int offset;
{
+ struct siop_common_softc *sc = siop_cmd->siop_sc;
scr_table_t *table;
int i;
@@ -860,7 +864,7 @@ siop_update_resid(siop_cmd, offset)
*/
for (i = 0; i < offset; i++)
siop_cmd->xs->resid -=
- letoh32(siop_cmd->siop_tables->data[i].count);
+ siop_ctoh32(sc, siop_cmd->siop_tables->data[i].count);
/*
* if CMDFL_RESID is set, the last table (pointed by offset) is a
* partial transfers. If not, offset points to the entry folloing
@@ -868,7 +872,8 @@ siop_update_resid(siop_cmd, offset)
*/
if (siop_cmd->flags & CMDFL_RESID) {
table = &siop_cmd->siop_tables->data[offset];
- siop_cmd->xs->resid -= letoh32(table->count) - siop_cmd->resid;
+ siop_cmd->xs->resid -=
+ siop_ctoh32(sc, table->count) - siop_cmd->resid;
}
}
@@ -883,7 +888,7 @@ siop_iwr(siop_cmd)
/* if target isn't wide, reject */
if ((siop_cmd->siop_target->flags & TARF_ISWIDE) == 0) {
- siop_cmd->siop_tables->t_msgout.count= htole32(1);
+ siop_cmd->siop_tables->t_msgout.count = siop_htoc32(sc, 1);
siop_cmd->siop_tables->msg_out[0] = MSG_MESSAGE_REJECT;
return SIOP_NEG_MSGOUT;
}
@@ -898,7 +903,7 @@ siop_iwr(siop_cmd)
table = &siop_cmd->siop_tables->data[offset];
if ((siop_cmd->flags & CMDFL_RESID) == 0) {
- if (letoh32(table->count) & 1) {
+ if (siop_ctoh32(sc, table->count) & 1) {
/* we really got the number of bytes we expected */
return SIOP_NEG_ACK;
} else {
diff --git a/sys/dev/ic/siopreg.h b/sys/dev/ic/siopreg.h
index ad138f756d7..da4d747e6f4 100644
--- a/sys/dev/ic/siopreg.h
+++ b/sys/dev/ic/siopreg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: siopreg.h,v 1.10 2006/03/16 22:11:24 miod Exp $ */
+/* $OpenBSD: siopreg.h,v 1.11 2007/08/05 19:05:09 kettenis Exp $ */
/* $NetBSD: siopreg.h,v 1.16 2005/02/27 00:27:02 perry Exp $ */
/*
@@ -198,6 +198,7 @@ static const struct scf_period dt_scf_period[] = {
#define ISTAT_DIP 0x01
#define SIOP_CTEST0 0x18 /* Chip test 0, R/W */
+#define CTEST0_EHP 0x04 /* 720/770 */
#define SIOP_CTEST1 0x19 /* Chip test 1, R/W */
@@ -215,6 +216,7 @@ static const struct scf_period dt_scf_period[] = {
#define SIOP_DFIFO 0x20 /* DMA FIFO */
#define SIOP_CTEST4 0x21 /* Chip test 4, R/W */
+#define CTEST4_MUX 0x80 /* 720/770 */
#define CTEST4_BDIS 0x80
#define CTEST_ZMOD 0x40
#define CTEST_ZSD 0x20
@@ -266,7 +268,8 @@ static const struct scf_period dt_scf_period[] = {
#define SIOP_DCNTL 0x3B /* DMA control, R/W */
#define DCNTL_CLSE 0x80
#define DCNTL_PFF 0x40
-#define DCNTL_PFEN 0x20
+#define DCNTL_EA 0x20 /* 720/770 */
+#define DCNTL_PFEN 0x20 /* 8xx */
#define DCNTL_SSM 0x10
#define DCNTL_IRQM 0x08
#define DCNTL_STD 0x04
diff --git a/sys/dev/ic/siopvar_common.h b/sys/dev/ic/siopvar_common.h
index 226fa7dffcb..d395689e2f3 100644
--- a/sys/dev/ic/siopvar_common.h
+++ b/sys/dev/ic/siopvar_common.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: siopvar_common.h,v 1.24 2007/04/13 18:16:17 krw Exp $ */
+/* $OpenBSD: siopvar_common.h,v 1.25 2007/08/05 19:05:09 kettenis Exp $ */
/* $NetBSD: siopvar_common.h,v 1.33 2005/11/18 23:10:32 bouyer Exp $ */
/*
@@ -178,6 +178,7 @@ struct siop_common_softc {
#define SF_CHIP_DT 0x00040000 /* DT clocking */
#define SF_CHIP_GEBUG 0x00080000 /* SCSI gross error bug */
#define SF_CHIP_AAIP 0x00100000 /* Always generate AIP regardless of SNCTL4*/
+#define SF_CHIP_BE 0x00200000 /* big-endian */
#define SF_PCI_RL 0x01000000 /* PCI read line */
#define SF_PCI_RM 0x02000000 /* PCI read multiple */
@@ -209,3 +210,9 @@ void siop_sdp(struct siop_common_cmd *, int);
void siop_update_resid(struct siop_common_cmd *, int);
void siop_clearfifo(struct siop_common_softc *);
void siop_resetbus(struct siop_common_softc *);
+
+#define siop_htoc32(sc, x) \
+ (((sc)->features & SF_CHIP_BE) ? htobe32((x)) : htole32((x)))
+
+#define siop_ctoh32(sc, x) \
+ (((sc)->features & SF_CHIP_BE) ? betoh32((x)) : letoh32((x)))