Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev For a new command, use the id in the command table a...
details: https://anonhg.NetBSD.org/src/rev/ef683326e027
branches: trunk
changeset: 526051:ef683326e027
user: bouyer <bouyer%NetBSD.org@localhost>
date: Wed Apr 24 09:43:14 2002 +0000
description:
For a new command, use the id in the command table and get rid of the ID in the
scheduler slot. This costs a few more instructions but divide the size of the
scheduler ring by 2, saving 1k of onboard RAM (a bus with 15 devices would
overflow the on-board RAM by 128 bytes).
diffstat:
sys/dev/ic/esiop.c | 71 +++++++++-------------------------------
sys/dev/ic/esiopvar.h | 6 ++-
sys/dev/microcode/siop/esiop.ss | 35 +++++++++++++------
3 files changed, 43 insertions(+), 69 deletions(-)
diffs (truncated from 302 to 300 lines):
diff -r fd679be374d7 -r ef683326e027 sys/dev/ic/esiop.c
--- a/sys/dev/ic/esiop.c Wed Apr 24 08:58:33 2002 +0000
+++ b/sys/dev/ic/esiop.c Wed Apr 24 09:43:14 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: esiop.c,v 1.7 2002/04/23 20:41:16 bouyer Exp $ */
+/* $NetBSD: esiop.c,v 1.8 2002/04/24 09:43:14 bouyer Exp $ */
/*
* Copyright (c) 2002 Manuel Bouyer.
@@ -33,7 +33,7 @@
/* SYM53c7/8xx PCI-SCSI I/O Processors driver */
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: esiop.c,v 1.7 2002/04/23 20:41:16 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: esiop.c,v 1.8 2002/04/24 09:43:14 bouyer Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -94,8 +94,6 @@
void esiop_morecbd __P((struct esiop_softc *));
void esiop_moretagtbl __P((struct esiop_softc *));
void siop_add_reselsw __P((struct esiop_softc *, int));
-void esiop_update_scntl3 __P((struct esiop_softc *,
- struct siop_common_target *));
struct esiop_cmd * esiop_cmd_find __P((struct esiop_softc *, int, u_int32_t));
void esiop_target_register __P((struct esiop_softc *, u_int32_t));
@@ -210,7 +208,7 @@
sc->sc_free_offset += 2;
/* then we have the scheduler ring */
sc->sc_shedoffset = sc->sc_free_offset;
- sc->sc_free_offset += A_ncmd_slots * 2;
+ sc->sc_free_offset += A_ncmd_slots * CMD_SLOTSIZE;
/* then the targets DSA table */
sc->sc_target_table_offset = sc->sc_free_offset;
sc->sc_free_offset += sc->sc_c.sc_chan.chan_ntargets;
@@ -287,8 +285,8 @@
addr = sc->sc_c.sc_scriptaddr + sc->sc_shedoffset * sizeof(u_int32_t);
/* init scheduler */
for (i = 0; i < A_ncmd_slots; i++) {
- esiop_script_write(sc, sc->sc_shedoffset + i * 2, A_f_cmd_free);
- esiop_script_write(sc, sc->sc_shedoffset + i * 2 + 1, 0);
+ esiop_script_write(sc,
+ sc->sc_shedoffset + i * CMD_SLOTSIZE, A_f_cmd_free);
}
sc->sc_currschedslot = 0;
bus_space_write_1(sc->sc_c.sc_rt, sc->sc_c.sc_rh, SIOP_SCRATCHE, 0);
@@ -607,23 +605,23 @@
sc->sc_c.sc_rh, SIOP_SCRATCHE);
esiop_script_sync(sc,
BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);
- target = esiop_script_read(sc,
- sc->sc_shedoffset + slot * 2 + 1) & 0x00ff0000;
- target = (target >> 16) & 0xff;
+ target = bus_space_read_1(sc->sc_c.sc_rt,
+ sc->sc_c.sc_rh, SIOP_SDID);
esiop_cmd = esiop_cmd_find(sc, target,
esiop_script_read(sc,
- sc->sc_shedoffset + slot * 2) & ~0x3);
+ sc->sc_shedoffset + slot * CMD_SLOTSIZE) & ~0x3);
/*
* mark this slot as free, and advance to next slot
*/
- esiop_script_write(sc, sc->sc_shedoffset + slot * 2,
+ esiop_script_write(sc,
+ sc->sc_shedoffset + slot * CMD_SLOTSIZE,
A_f_cmd_free);
addr = bus_space_read_4(sc->sc_c.sc_rt,
sc->sc_c.sc_rh, SIOP_SCRATCHD);
if (slot < (A_ncmd_slots - 1)) {
bus_space_write_1(sc->sc_c.sc_rt,
sc->sc_c.sc_rh, SIOP_SCRATCHE, slot + 1);
- addr = addr + 8;
+ addr = addr + sizeof(struct esiop_slot);
} else {
bus_space_write_1(sc->sc_c.sc_rt,
sc->sc_c.sc_rh, SIOP_SCRATCHE, 0);
@@ -901,16 +899,12 @@
if (esiop_cmd->cmd_tables->msg_in[2] == MSG_EXT_PPR) {
switch (siop_ppr_neg(&esiop_cmd->cmd_c)) {
case SIOP_NEG_MSGOUT:
- esiop_update_scntl3(sc,
- esiop_cmd->cmd_c.siop_target);
esiop_table_sync(esiop_cmd,
BUS_DMASYNC_PREREAD |
BUS_DMASYNC_PREWRITE);
CALL_SCRIPT(Ent_send_msgout);
return(1);
case SIOP_NEG_ACK:
- esiop_update_scntl3(sc,
- esiop_cmd->cmd_c.siop_target);
CALL_SCRIPT(Ent_msgin_ack);
return(1);
default:
@@ -922,16 +916,12 @@
if (esiop_cmd->cmd_tables->msg_in[2] == MSG_EXT_WDTR) {
switch (siop_wdtr_neg(&esiop_cmd->cmd_c)) {
case SIOP_NEG_MSGOUT:
- esiop_update_scntl3(sc,
- esiop_cmd->cmd_c.siop_target);
esiop_table_sync(esiop_cmd,
BUS_DMASYNC_PREREAD |
BUS_DMASYNC_PREWRITE);
CALL_SCRIPT(Ent_send_msgout);
return(1);
case SIOP_NEG_ACK:
- esiop_update_scntl3(sc,
- esiop_cmd->cmd_c.siop_target);
CALL_SCRIPT(Ent_msgin_ack);
return(1);
default:
@@ -943,16 +933,12 @@
if (esiop_cmd->cmd_tables->msg_in[2] == MSG_EXT_SDTR) {
switch (siop_sdtr_neg(&esiop_cmd->cmd_c)) {
case SIOP_NEG_MSGOUT:
- esiop_update_scntl3(sc,
- esiop_cmd->cmd_c.siop_target);
esiop_table_sync(esiop_cmd,
BUS_DMASYNC_PREREAD |
BUS_DMASYNC_PREWRITE);
CALL_SCRIPT(Ent_send_msgout);
return(1);
case SIOP_NEG_ACK:
- esiop_update_scntl3(sc,
- esiop_cmd->cmd_c.siop_target);
CALL_SCRIPT(Ent_msgin_ack);
return(1);
default:
@@ -1194,7 +1180,7 @@
esiop_cmd = esiop_lun->tactive[tag];
for (slot = 0; slot < A_ncmd_slots; slot++) {
slotdsa = esiop_script_read(sc,
- sc->sc_shedoffset + slot * 2);
+ sc->sc_shedoffset + slot * CMD_SLOTSIZE);
if (slotdsa & A_f_cmd_free)
continue;
if ((slotdsa & ~A_f_cmd_free) == esiop_cmd->cmd_c.dsa)
@@ -1203,7 +1189,7 @@
if (slot > ESIOP_NTAG)
continue; /* didn't find it */
/* Mark this slot as ignore */
- esiop_script_write(sc, sc->sc_shedoffset + slot * 2,
+ esiop_script_write(sc, sc->sc_shedoffset + slot * CMD_SLOTSIZE,
esiop_cmd->cmd_c.dsa | A_f_cmd_ignore);
/* ask to requeue */
esiop_cmd->cmd_c.xs->error = XS_REQUEUE;
@@ -1547,7 +1533,7 @@
* free slot, unless we have filled the queue. Check this.
*/
slot = sc->sc_currschedslot;
- if ((esiop_script_read(sc, sc->sc_shedoffset + slot * 2) &
+ if ((esiop_script_read(sc, sc->sc_shedoffset + slot * CMD_SLOTSIZE) &
A_f_cmd_free) == 0) {
/*
* no more free slot, no need to continue. freeze the queue
@@ -1615,10 +1601,8 @@
esiop_lun->lun_flags &= ~LUNF_TAGTABLE;
}
- /* scheduler slot: ID, then DSA */
- esiop_script_write(sc, sc->sc_shedoffset + slot * 2 + 1,
- sc->sc_c.targets[target]->id);
- esiop_script_write(sc, sc->sc_shedoffset + slot * 2,
+ /* scheduler slot: DSA */
+ esiop_script_write(sc, sc->sc_shedoffset + slot * CMD_SLOTSIZE,
esiop_cmd->cmd_c.dsa);
/* handle timeout */
if ((esiop_cmd->cmd_c.xs->xs_control & XS_CTL_POLL) == 0) {
@@ -1908,29 +1892,6 @@
}
void
-esiop_update_scntl3(sc, _siop_target)
- struct esiop_softc *sc;
- struct siop_common_target *_siop_target;
-{
- int slot;
- u_int32_t slotid, id;
-
- struct esiop_target *esiop_target = (struct esiop_target *)_siop_target;
- esiop_script_write(sc, esiop_target->lun_table_offset,
- esiop_target->target_c.id);
- id = esiop_target->target_c.id & 0x00ff0000;
- /* There may be other commands waiting in the scheduler. handle them */
- for (slot = 0; slot < A_ncmd_slots; slot++) {
- slotid =
- esiop_script_read(sc, sc->sc_shedoffset + slot * 2 + 1);
- if ((slotid & 0x00ff0000) == id)
- esiop_script_write(sc, sc->sc_shedoffset + slot * 2 + 1,
- esiop_target->target_c.id);
- }
- esiop_script_sync(sc, BUS_DMASYNC_PREWRITE);
-}
-
-void
esiop_add_dev(sc, target, lun)
struct esiop_softc *sc;
int target;
diff -r fd679be374d7 -r ef683326e027 sys/dev/ic/esiopvar.h
--- a/sys/dev/ic/esiopvar.h Wed Apr 24 08:58:33 2002 +0000
+++ b/sys/dev/ic/esiopvar.h Wed Apr 24 09:43:14 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: esiopvar.h,v 1.3 2002/04/23 20:41:16 bouyer Exp $ */
+/* $NetBSD: esiopvar.h,v 1.4 2002/04/24 09:43:14 bouyer Exp $ */
/*
* Copyright (c) 2002 Manuel Bouyer.
@@ -41,12 +41,14 @@
*/
struct esiop_slot {
u_int32_t dsa; /* DSA of the xfer. The first 2 bits holds flags */
- u_int32_t id; /* for SELECT */
} __attribute__((__packed__));
+#define CMD_SLOTSIZE (sizeof(struct esiop_slot) / sizeof(u_int32_t))
+
/*
* xfer description of the script: tables and reselect script
* In struct siop_common_cmd siop_xfer will point to this.
+ * If you change this don't forget to update o_cmd_* and cmd_slot_size in script
*/
struct esiop_xfer {
struct siop_common_xfer siop_tables;
diff -r fd679be374d7 -r ef683326e027 sys/dev/microcode/siop/esiop.ss
--- a/sys/dev/microcode/siop/esiop.ss Wed Apr 24 08:58:33 2002 +0000
+++ b/sys/dev/microcode/siop/esiop.ss Wed Apr 24 09:43:14 2002 +0000
@@ -1,4 +1,4 @@
-; $NetBSD: esiop.ss,v 1.8 2002/04/24 08:00:08 bouyer Exp $
+; $NetBSD: esiop.ss,v 1.9 2002/04/24 09:43:14 bouyer Exp $
;
; Copyright (c) 2002 Manuel Bouyer.
@@ -81,7 +81,8 @@
ABSOLUTE f_cmd_ignore = 0x02 ; this slot is not free but don't start it
; offsets in a cmd slot
ABSOLUTE o_cmd_dsa = 0; also holds f_cmd_*
-ABSOLUTE o_cmd_id = 4;
+; size of a cmd slot (for DSA increments)
+ABSOLUTE cmd_slot_size = 4;
; SCRATCHE1: last status
@@ -192,21 +193,31 @@
MOVE SFBR to DSA2;
MOVE SCRATCHD3 to SFBR;
MOVE SFBR to DSA3;
- LOAD SCRATCHA0,4, from o_cmd_dsa; /* get flags */
- MOVE SCRATCHA0 & f_cmd_free to SFBR;
+ LOAD DSA0,4, from o_cmd_dsa; get DSA and flags for this slot
+ MOVE DSA0 to SFBR; to avoid another load later
+ MOVE SFBR to SCRATCHA0; to avoid another load later
+ MOVE DSA0 & f_cmd_free to SFBR; check flags
JUMP REL(no_cmd), IF NOT 0x0;
- MOVE SCRATCHA0 & f_cmd_ignore to SFBR;
+ MOVE DSA0 & f_cmd_ignore to SFBR;
JUMP REL(ignore_cmd), IF NOT 0x0;
; this slot is busy, attempt to exec command
- SELECT ATN FROM o_cmd_id, REL(reselect);
+ SELECT ATN FROM t_id, REL(reselect);
; select either succeeded or timed out.
; if timed out the STO interrupt will be posted at the first SCSI bus access
; waiting for a valid phase, so we have to do it now. If not a MSG_OUT phase,
; this is an error anyway (we selected with ATN)
INT int_err, WHEN NOT MSG_OUT;
+ MOVE SCRATCHD0 to SFBR; restore scheduler DSA
+ MOVE SFBR to DSA0;
+ MOVE SCRATCHD1 to SFBR;
+ MOVE SFBR to DSA1;
+ MOVE SCRATCHD2 to SFBR;
+ MOVE SFBR to DSA2;
+ MOVE SCRATCHD3 to SFBR;
+ MOVE SFBR to DSA3;
ignore_cmd:
MOVE SCRATCHE0 + 1 to SCRATCHE0;
- MOVE SCRATCHD0 + 8 to SCRATCHD0; sizeof (esiop_cmd_slot)
+ MOVE SCRATCHD0 + cmd_slot_size to SCRATCHD0;
MOVE SCRATCHD1 + 0 to SCRATCHD1 WITH CARRY;
MOVE SCRATCHD2 + 0 to SCRATCHD2 WITH CARRY;
MOVE SCRATCHD3 + 0 to SCRATCHD3 WITH CARRY;
@@ -223,17 +234,17 @@
MOVE 0xff to SCRATCHD3;
MOVE 0x00 to SCRATCHE0;
handle_cmd:
- MOVE SCRATCHA0 | f_cmd_free to SCRATCHA0;
- STORE noflush SCRATCHA0, 4, FROM o_cmd_dsa;
+ MOVE SCRATCHA0 | f_cmd_free to SCRATCHA0; mark slot as free
+ STORE noflush SCRATCHA0, 1, FROM o_cmd_dsa;
MOVE SCRATCHA0 & f_cmd_ignore to SFBR;
- JUMP REL(script_sched), IF NOT 0x00; /* next command if ignore */
+ JUMP REL(script_sched), IF NOT 0x00; next command if ignore
; a NOP by default; patched with MOVE GPREG & 0xfe to GPREG on compile-time
; option "SIOP_SYMLED"
led_on1:
NOP;
- LOAD DSA0, 4, FROM o_cmd_dsa; /* load new DSA */
- MOVE DSA0 & 0xfe to DSA0; /* clear f_cmd_free */
+ LOAD DSA0, 4, FROM o_cmd_dsa; reload DSA for this command
+ MOVE DSA0 & 0xfe to DSA0; clear f_cmd_free
MOVE 0x00 TO SCRATCHA1;
Home |
Main Index |
Thread Index |
Old Index