// SPDX-License-Identifier: GPL-2.0-only /* * linux/drivers/acorn/scsi/acornscsi.c * * Acorn SCSI 3 driver * By R.M.King. * * Abandoned using the Select and Transfer command since there were * some nasty races between our software and the target devices that * were not easy to solve, and the device errata had a lot of entries * for this command, some of them quite nasty... * * Changelog: * 26-Sep-1997 RMK Re-jigged to use the queue module. * Re-coded state machine to be based on driver * state not scsi state. Should be easier to debug. * Added acornscsi_release to clean up properly. * Updated proc/scsi reporting. * 05-Oct-1997 RMK Implemented writing to SCSI devices. * 06-Oct-1997 RMK Corrected small (non-serious) bug with the connect/ * reconnect race condition causing a warning message. * 12-Oct-1997 RMK Added catch for re-entering interrupt routine. * 15-Oct-1997 RMK Improved handling of commands. * 27-Jun-1998 RMK Changed asm/delay.h to linux/delay.h. * 13-Dec-1998 RMK Better abort code and command handling. Extra state * transitions added to allow dodgy devices to work.
*/ #define DEBUG_NO_WRITE 1 #define DEBUG_QUEUES 2 #define DEBUG_DMA 4 #define DEBUG_ABORT 8 #define DEBUG_DISCON 16 #define DEBUG_CONNECT 32 #define DEBUG_PHASES 64 #define DEBUG_WRITE 128 #define DEBUG_LINK 256 #define DEBUG_MESSAGES 512 #define DEBUG_RESET 1024 #define DEBUG_ALL (DEBUG_RESET|DEBUG_MESSAGES|DEBUG_LINK|DEBUG_WRITE|\
DEBUG_PHASES|DEBUG_CONNECT|DEBUG_DISCON|DEBUG_ABORT|\
DEBUG_DMA|DEBUG_QUEUES)
/* DRIVER CONFIGURATION * * SCSI-II Tagged queue support. * * I don't have any SCSI devices that support it, so it is totally untested * (except to make sure that it doesn't interfere with any non-tagging * devices). It is not fully implemented either - what happens when a * tagging device reconnects??? * * You can tell if you have a device that supports tagged queueing my * cating (eg) /proc/scsi/acornscsi/0 and see if the SCSI revision is reported * as '2 TAG'.
*/
/* * SCSI-II Synchronous transfer support. * * Tried and tested... * * SDTR_SIZE - maximum number of un-acknowledged bytes (0 = off, 12 = max) * SDTR_PERIOD - period of REQ signal (min=125, max=1020) * DEFAULT_PERIOD - default REQ period.
*/ #define SDTR_SIZE 12 #define SDTR_PERIOD 125 #define DEFAULT_PERIOD 500
/* * Debugging information * * DEBUG - bit mask from list above * DEBUG_TARGET - is defined to the target number if you want to debug * a specific target. [only recon/write/dma].
*/ #define DEBUG (DEBUG_RESET|DEBUG_WRITE|DEBUG_NO_WRITE) /* only allow writing to SCSI device 0 */ #define NO_WRITE 0xFE /*#define DEBUG_TARGET 2*/ /* * Select timeout time (in 10ms units) * * This is the timeout used between the start of selection and the WD33C93 * chip deciding that the device isn't responding.
*/ #define TIMEOUT_TIME 10 /* * Define this if you want to have verbose explanation of SCSI * status/messages.
*/ #undef CONFIG_ACORNSCSI_CONSTANTS /* * Define this if you want to use the on board DMAC [don't remove this option] * If not set, then use PIO mode (not currently supported).
*/ #define USE_DMAC
/* * Prototype: cmdtype_t acornscsi_cmdtype(int command) * Purpose : differentiate READ from WRITE from other commands * Params : command - command to interpret * Returns : CMD_READ - command reads data, * CMD_WRITE - command writes data, * CMD_MISC - everything else
*/ staticinline
cmdtype_t acornscsi_cmdtype(int command)
{ switch (command) { case WRITE_6: case WRITE_10: case WRITE_12: return CMD_WRITE; case READ_6: case READ_10: case READ_12: return CMD_READ; default: return CMD_MISC;
}
}
/* * Prototype: int acornscsi_datadirection(int command) * Purpose : differentiate between commands that have a DATA IN phase * and a DATA OUT phase * Params : command - command to interpret * Returns : DATADIR_OUT - data out phase expected * DATADIR_IN - data in phase expected
*/ static
datadir_t acornscsi_datadirection(int command)
{ switch (command) { case CHANGE_DEFINITION: case COMPARE: case COPY: case COPY_VERIFY: case LOG_SELECT: case MODE_SELECT: case MODE_SELECT_10: case SEND_DIAGNOSTIC: case WRITE_BUFFER: case FORMAT_UNIT: case REASSIGN_BLOCKS: case RESERVE_6: case SEARCH_EQUAL: case SEARCH_HIGH: case SEARCH_LOW: case WRITE_6: case WRITE_10: case WRITE_VERIFY: case UPDATE_BLOCK: case WRITE_LONG: case WRITE_SAME: case SEARCH_HIGH_12: case SEARCH_EQUAL_12: case SEARCH_LOW_12: case WRITE_12: case WRITE_VERIFY_12: case SET_WINDOW: case MEDIUM_SCAN: case SEND_VOLUME_TAG: case 0xea: return DATADIR_OUT; default: return DATADIR_IN;
}
}
/* * Purpose : provide values for synchronous transfers with 33C93. * Copyright: Copyright (c) 1996 John Shifflett, GeoLog Consulting * Modified by Russell King for 8MHz WD33C93A
*/ staticstruct sync_xfer_tbl { unsignedint period_ns; unsignedchar reg_value;
} sync_xfer_table[] = {
{ 1, 0x20 }, { 249, 0x20 }, { 374, 0x30 },
{ 499, 0x40 }, { 624, 0x50 }, { 749, 0x60 },
{ 874, 0x70 }, { 999, 0x00 }, { 0, 0 }
};
/* * Prototype: int acornscsi_getperiod(unsigned char syncxfer) * Purpose : period for the synchronous transfer setting * Params : syncxfer SYNCXFER register value * Returns : period in ns.
*/ static int acornscsi_getperiod(unsignedchar syncxfer)
{ int i;
syncxfer &= 0xf0; if (syncxfer == 0x10)
syncxfer = 0;
for (i = 1; sync_xfer_table[i].period_ns; i++) if (syncxfer == sync_xfer_table[i].reg_value) return sync_xfer_table[i].period_ns; return 0;
}
/* * Prototype: int round_period(unsigned int period) * Purpose : return index into above table for a required REQ period * Params : period - time (ns) for REQ * Returns : table index * Copyright: Copyright (c) 1996 John Shifflett, GeoLog Consulting
*/ staticinline int round_period(unsignedint period)
{ int i;
for (i = 1; sync_xfer_table[i].period_ns; i++) { if ((period <= sync_xfer_table[i].period_ns) &&
(period > sync_xfer_table[i - 1].period_ns)) return i;
} return 7;
}
/* * Prototype: unsigned char calc_sync_xfer(unsigned int period, unsigned int offset) * Purpose : calculate value for 33c93s SYNC register * Params : period - time (ns) for REQ * offset - offset in bytes between REQ/ACK * Returns : value for SYNC register * Copyright: Copyright (c) 1996 John Shifflett, GeoLog Consulting
*/ static unsignedchar __maybe_unused calc_sync_xfer(unsignedint period, unsignedint offset)
{ return sync_xfer_table[round_period(period)].reg_value |
((offset < SDTR_SIZE) ? offset : SDTR_SIZE);
}
/* ==================================================================================== * Command functions
*/ /* * Function: acornscsi_kick(AS_Host *host) * Purpose : kick next command to interface * Params : host - host to send command to * Returns : INTR_IDLE if idle, otherwise INTR_PROCESSING * Notes : interrupts are always disabled!
*/ static
intr_ret_t acornscsi_kick(AS_Host *host)
{ int from_queue = 0; struct scsi_cmnd *SCpnt;
/* first check to see if a command is waiting to be executed */
SCpnt = host->origSCpnt;
host->origSCpnt = NULL;
/* retrieve next command */ if (!SCpnt) {
SCpnt = queue_remove_exclude(&host->queues.issue, host->busyluns); if (!SCpnt) return INTR_IDLE;
from_queue = 1;
}
if (host->scsi.disconnectable && host->SCpnt) {
queue_add_cmd_tail(&host->queues.disconnected, host->SCpnt);
host->scsi.disconnectable = 0; #if (DEBUG & (DEBUG_QUEUES|DEBUG_DISCON))
DBG(host->SCpnt, printk("scsi%d.%c: moved command to disconnected queue\n",
host->host->host_no, acornscsi_target(host))); #endif
host->SCpnt = NULL;
}
/* * If we have an interrupt pending, then we may have been reselected. * In this case, we don't want to write to the registers
*/ if (!(sbic_arm_read(host, SBIC_ASR) & (ASR_INT|ASR_BSY|ASR_CIP))) {
sbic_arm_write(host, SBIC_DESTID, SCpnt->device->id);
sbic_arm_write(host, SBIC_CMND, CMND_SELWITHATN);
}
/* * claim host busy - all of these must happen atomically wrt * our interrupt routine. Failure means command loss.
*/
host->scsi.phase = PHASE_CONNECTING;
host->SCpnt = SCpnt;
host->scsi.SCp = *arm_scsi_pointer(SCpnt);
host->dma.xfer_setup = 0;
host->dma.xfer_required = 0;
host->dma.xfer_done = 0;
switch (acornscsi_cmdtype(SCpnt->cmnd[0])) { case CMD_WRITE:
host->stats.writes += 1; break; case CMD_READ:
host->stats.reads += 1; break; case CMD_MISC:
host->stats.miscs += 1; break;
}
}
return INTR_PROCESSING;
}
/* * Function: void acornscsi_done(AS_Host *host, struct scsi_cmnd **SCpntp, unsigned int result) * Purpose : complete processing for command * Params : host - interface that completed * result - driver byte of result
*/ staticvoid acornscsi_done(AS_Host *host, struct scsi_cmnd **SCpntp, unsignedint result)
{ struct scsi_cmnd *SCpnt = *SCpntp;
/* clean up */
sbic_arm_write(host, SBIC_SOURCEID, SOURCEID_ER | SOURCEID_DSP);
host->stats.fins += 1;
if (SCpnt) {
*SCpntp = NULL;
acornscsi_dma_cleanup(host);
set_host_byte(SCpnt, result); if (result == DID_OK)
scsi_msg_to_host_byte(SCpnt, host->scsi.SCp.Message);
set_status_byte(SCpnt, host->scsi.SCp.Status);
/* * In theory, this should not happen. In practice, it seems to. * Only trigger an error if the device attempts to report all happy * but with untransferred buffers... If we don't do something, then * data loss will occur. Should we check SCpnt->underflow here? * It doesn't appear to be set to something meaningful by the higher * levels all the time.
*/ if (result == DID_OK) { int xfer_warn = 0;
if (SCpnt->underflow == 0) { if (host->scsi.SCp.ptr &&
acornscsi_cmdtype(SCpnt->cmnd[0]) != CMD_MISC)
xfer_warn = 1;
} else { if (host->scsi.SCp.scsi_xferred < SCpnt->underflow ||
host->scsi.SCp.scsi_xferred != host->dma.transferred)
xfer_warn = 1;
}
/* ANSI standard says: (SCSI-2 Rev 10c Sect 5.6.6) * Targets which break data transfers into multiple * connections shall end each successful connection * (except possibly the last) with a SAVE DATA * POINTER - DISCONNECT message sequence. * * This makes it difficult to ensure that a transfer has * completed. If we reach the end of a transfer during * the command, then we can only have finished the transfer. * therefore, if we seem to have some data remaining, this * is not a problem.
*/ if (host->dma.xfer_done)
xfer_warn = 0;
if (xfer_warn) { switch (get_status_byte(SCpnt)) { case SAM_STAT_CHECK_CONDITION: case SAM_STAT_COMMAND_TERMINATED: case SAM_STAT_BUSY: case SAM_STAT_TASK_SET_FULL: case SAM_STAT_RESERVATION_CONFLICT: break;
default:
scmd_printk(KERN_ERR, SCpnt, "incomplete data transfer detected: " "result=%08X", SCpnt->result);
scsi_print_command(SCpnt);
acornscsi_dumpdma(host, "done");
acornscsi_dumplog(host, SCpnt->device->id);
set_host_byte(SCpnt, DID_ERROR);
}
}
}
/* * Prototype: void acornscsi_data_read(AS_Host *host, char *ptr, * unsigned int start_addr, unsigned int length) * Purpose : read data from DMA RAM * Params : host - host to transfer from * ptr - DRAM address * start_addr - host mem address * length - number of bytes to transfer * Notes : this will only be one SG entry or less
*/ static void acornscsi_data_read(AS_Host *host, char *ptr, unsignedint start_addr, unsignedint length)
{ externvoid __acornscsi_in(void __iomem *, char *buf, int len); unsignedint page, offset, len = length;
/* * Prototype: void acornscsi_data_write(AS_Host *host, char *ptr, * unsigned int start_addr, unsigned int length) * Purpose : write data to DMA RAM * Params : host - host to transfer from * ptr - DRAM address * start_addr - host mem address * length - number of bytes to transfer * Notes : this will only be one SG entry or less
*/ static void acornscsi_data_write(AS_Host *host, char *ptr, unsignedint start_addr, unsignedint length)
{ externvoid __acornscsi_out(void __iomem *, char *buf, int len); unsignedint page, offset, len = length;
/* ========================================================================================= * On-board DMA routines
*/ #ifdef USE_DMAC /* * Prototype: void acornscsi_dmastop(AS_Host *host) * Purpose : stop all DMA * Params : host - host on which to stop DMA * Notes : This is called when leaving DATA IN/OUT phase, * or when interface is RESET
*/ staticinline void acornscsi_dma_stop(AS_Host *host)
{
dmac_write(host, DMAC_MASKREG, MASK_ON);
dmac_clearintr(host);
/* * Function: void acornscsi_dma_setup(AS_Host *host, dmadir_t direction) * Purpose : setup DMA controller for data transfer * Params : host - host to setup * direction - data transfer direction * Notes : This is called when entering DATA I/O phase, not * while we're in a DATA I/O phase
*/ static void acornscsi_dma_setup(AS_Host *host, dmadir_t direction)
{ unsignedint address, length, mode;
/* * Function: void acornscsi_dma_cleanup(AS_Host *host) * Purpose : ensure that all DMA transfers are up-to-date & host->scsi.SCp is correct * Params : host - host to finish * Notes : This is called when a command is: * terminating, RESTORE_POINTERS, SAVE_POINTERS, DISCONNECT * : This must not return until all transfers are completed.
*/ static void acornscsi_dma_cleanup(AS_Host *host)
{
dmac_write(host, DMAC_MASKREG, MASK_ON);
dmac_clearintr(host);
/* * Check for a pending transfer
*/ if (host->dma.xfer_required) {
host->dma.xfer_required = 0; if (host->dma.direction == DMA_IN)
acornscsi_data_read(host, host->dma.xfer_ptr,
host->dma.xfer_start, host->dma.xfer_length);
}
/* * Has a transfer been setup?
*/ if (host->dma.xfer_setup) { unsignedint transferred;
/* * Function: void acornscsi_dmacintr(AS_Host *host) * Purpose : handle interrupts from DMAC device * Params : host - host to process * Notes : If reading, we schedule the read to main memory & * allow the transfer to continue. * : If writing, we fill the onboard DMA memory from main * memory. * : Called whenever DMAC finished it's current transfer.
*/ static void acornscsi_dma_intr(AS_Host *host)
{ unsignedint address, length, transferred;
#if (DEBUG & DEBUG_DMA)
DBG(host->SCpnt, acornscsi_dumpdma(host, "into")); #endif
} else {
host->dma.xfer_setup = 0; #if 0 /* * If the interface still wants more, then this is an error. * We give it another byte, but we also attempt to raise an * attention condition. We continue giving one byte until * the device recognises the attention.
*/ if (dmac_read(host, DMAC_STATUS) & STATUS_RQ0) {
acornscsi_abortcmd(host);
default: /* * ANSI standard says: (SCSI-2 Rev 10c Sect 5.6.14) * 'When a target sends this (MESSAGE_REJECT) message, it * shall change to MESSAGE IN phase and send this message * prior to requesting additional message bytes from the * initiator. This provides an interlock so that the * initiator can determine which message byte is rejected.
*/
sbic_arm_write(host, SBIC_TRANSCNTH, 0);
sbic_arm_writenext(host, 0);
sbic_arm_writenext(host, message_length);
acornscsi_sbic_issuecmd(host, CMND_XFERINFO);
msgnr = 0; while ((msg = msgqueue_getmsg(&host->scsi.msgs, msgnr++)) != NULL) { unsignedint i; #if (DEBUG & DEBUG_MESSAGES)
spi_print_msg(msg); #endif
i = 0; if (acornscsi_write_pio(host, msg->msg, &i, msg->length, 1000000))
printk("scsi%d: timeout while sending message\n", host->host->host_no);
if (host->scsi.phase == PHASE_RECONNECTED) { /* * ANSI standard says: (Section SCSI-2 Rev. 10c Sect 5.6.17) * 'Whenever a target reconnects to an initiator to continue * a tagged I/O process, the SIMPLE QUEUE TAG message shall * be sent immediately following the IDENTIFY message...'
*/ if (message[0] == SIMPLE_QUEUE_TAG)
host->scsi.reconnected.tag = message[1]; if (acornscsi_reconnect_finish(host))
host->scsi.phase = PHASE_MSGIN;
}
switch (message[0]) { case ABORT_TASK_SET: case ABORT_TASK: case COMMAND_COMPLETE: if (host->scsi.phase != PHASE_STATUSIN) {
printk(KERN_ERR "scsi%d.%c: command complete following non-status in phase?\n",
host->host->host_no, acornscsi_target(host));
acornscsi_dumplog(host, host->SCpnt->device->id);
}
host->scsi.phase = PHASE_DONE;
host->scsi.SCp.Message = message[0]; break;
case SAVE_POINTERS: /* * ANSI standard says: (Section SCSI-2 Rev. 10c Sect 5.6.20) * 'The SAVE DATA POINTER message is sent from a target to * direct the initiator to copy the active data pointer to * the saved data pointer for the current I/O process.
*/
acornscsi_dma_cleanup(host);
scsi_pointer = arm_scsi_pointer(host->SCpnt);
*scsi_pointer = host->scsi.SCp;
scsi_pointer->sent_command = 0;
host->scsi.phase = PHASE_MSGIN; break;
case RESTORE_POINTERS: /* * ANSI standard says: (Section SCSI-2 Rev. 10c Sect 5.6.19) * 'The RESTORE POINTERS message is sent from a target to * direct the initiator to copy the most recently saved * command, data, and status pointers for the I/O process * to the corresponding active pointers. The command and * status pointers shall be restored to the beginning of * the present command and status areas.'
*/
acornscsi_dma_cleanup(host);
host->scsi.SCp = *arm_scsi_pointer(host->SCpnt);
host->scsi.phase = PHASE_MSGIN; break;
case DISCONNECT: /* * ANSI standard says: (Section SCSI-2 Rev. 10c Sect 6.4.2) * 'On those occasions when an error or exception condition occurs * and the target elects to repeat the information transfer, the * target may repeat the transfer either issuing a RESTORE POINTERS * message or by disconnecting without issuing a SAVE POINTERS * message. When reconnection is completed, the most recent * saved pointer values are restored.'
*/
acornscsi_dma_cleanup(host);
host->scsi.phase = PHASE_DISCONNECT; break;
case MESSAGE_REJECT: #if 0 /* this isn't needed any more */ /* * If we were negociating sync transfer, we don't yet know if * this REJECT is for the sync transfer or for the tagged queue/wide * transfer. Re-initiate sync transfer negotiation now, and if * we got a REJECT in response to SDTR, then it'll be set to DONE.
*/ if (host->device[host->SCpnt->device->id].sync_state == SYNC_SENT_REQUEST)
host->device[host->SCpnt->device->id].sync_state = SYNC_NEGOCIATE; #endif
/* * If we have any messages waiting to go out, then assert ATN now
*/ if (msgqueue_msglength(&host->scsi.msgs))
acornscsi_sbic_issuecmd(host, CMND_ASSERTATN);
case SIMPLE_QUEUE_TAG: /* tag queue reconnect... message[1] = queue tag. Print something to indicate something happened! */
printk("scsi%d.%c: reconnect queue tag %02X\n",
host->host->host_no, acornscsi_target(host),
message[1]); break;
case EXTENDED_MESSAGE: switch (message[2]) { #ifdef CONFIG_SCSI_ACORNSCSI_SYNC case EXTENDED_SDTR: if (host->device[host->SCpnt->device->id].sync_state == SYNC_SENT_REQUEST) { /* * We requested synchronous transfers. This isn't quite right... * We can only say if this succeeded if we proceed on to execute the * command from this message. If we get a MESSAGE PARITY ERROR, * and the target retries fail, then we fallback to asynchronous mode
*/
host->device[host->SCpnt->device->id].sync_state = SYNC_COMPLETED;
printk(KERN_NOTICE "scsi%d.%c: Using synchronous transfer, offset %d, %d ns\n",
host->host->host_no, acornscsi_target(host),
message[4], message[3] * 4);
host->device[host->SCpnt->device->id].sync_xfer =
calc_sync_xfer(message[3] * 4, message[4]);
} else { unsignedchar period, length; /* * Target requested synchronous transfers. The agreement is only * to be in operation AFTER the target leaves message out phase.
*/
acornscsi_sbic_issuecmd(host, CMND_ASSERTATN);
period = max_t(unsignedint, message[3], sdtr_period / 4);
length = min_t(unsignedint, message[4], sdtr_size);
msgqueue_addmsg(&host->scsi.msgs, 5, EXTENDED_MESSAGE, 3,
EXTENDED_SDTR, period, length);
host->device[host->SCpnt->device->id].sync_xfer =
calc_sync_xfer(period * 4, length);
}
sbic_arm_write(host, SBIC_SYNCHTRANSFER, host->device[host->SCpnt->device->id].sync_xfer); break; #else /* We do not accept synchronous transfers. Respond with a * MESSAGE_REJECT.
*/ #endif
case EXTENDED_WDTR: /* The WD33C93A is only 8-bit. We respond with a MESSAGE_REJECT * to a wide data transfer request.
*/ default:
acornscsi_sbic_issuecmd(host, CMND_ASSERTATN);
msgqueue_flush(&host->scsi.msgs);
msgqueue_addmsg(&host->scsi.msgs, 1, MESSAGE_REJECT); break;
} break;
/* * Function: int acornscsi_buildmessages(AS_Host *host) * Purpose : build the connection messages for a host * Params : host - host to add messages to
*/ static void acornscsi_buildmessages(AS_Host *host)
{ #if 0 /* does the device need resetting? */ if (cmd_reset) {
msgqueue_addmsg(&host->scsi.msgs, 1, BUS_DEVICE_RESET); return;
} #endif
/* * Function: int acornscsi_starttransfer(AS_Host *host) * Purpose : transfer data to/from connected target * Params : host - host to which target is connected * Returns : 0 if failure
*/ static int acornscsi_starttransfer(AS_Host *host)
{ int residual;
if (!host->scsi.SCp.ptr /*&& host->scsi.SCp.this_residual*/) {
printk(KERN_ERR "scsi%d.%c: null buffer passed to acornscsi_starttransfer\n",
host->host->host_no, acornscsi_target(host)); return 0;
}
/* ========================================================================================= * Connection & Disconnection
*/ /* * Function : acornscsi_reconnect(AS_Host *host) * Purpose : reconnect a previously disconnected command * Params : host - host specific data * Remarks : SCSI spec says: * 'The set of active pointers is restored from the set * of saved pointers upon reconnection of the I/O process'
*/ static int acornscsi_reconnect(AS_Host *host)
{ unsignedint target, lun, ok = 0;
target = sbic_arm_read(host, SBIC_SOURCEID);
if (!(target & 8))
printk(KERN_ERR "scsi%d: invalid source id after reselection " "- device fault?\n",
host->host->host_no);
target &= 7;
if (host->SCpnt && !host->scsi.disconnectable) {
printk(KERN_ERR "scsi%d.%d: reconnected while command in " "progress to target %d?\n",
host->host->host_no, target, host->SCpnt->device->id);
host->SCpnt = NULL;
}
/* ========================================================================================== * Interrupt routines.
*/ /* * Function: int acornscsi_sbicintr(AS_Host *host) * Purpose : handle interrupts from SCSI device * Params : host - host to process * Returns : INTR_PROCESS if expecting another SBIC interrupt * INTR_IDLE if no interrupt * INTR_NEXT_COMMAND if we have finished processing the command
*/ static
intr_ret_t acornscsi_sbicintr(AS_Host *host, int in_irq)
{ unsignedint asr, ssr;
asr = sbic_arm_read(host, SBIC_ASR); if (!(asr & ASR_INT)) return INTR_IDLE;
case PHASE_MSGOUT: /* STATE: connected & sent IDENTIFY message */ /* * SCSI standard says that MESSAGE OUT phases can be followed by a * DATA phase, STATUS phase, MESSAGE IN phase or COMMAND phase
*/ switch (ssr) { case 0x8a: /* -> PHASE_COMMAND, PHASE_COMMANDPAUSED */ case 0x1a: /* -> PHASE_COMMAND, PHASE_COMMANDPAUSED */ /* MESSAGE OUT -> COMMAND */
acornscsi_sendcommand(host); break;
case 0x8b: /* -> PHASE_STATUS */ case 0x1b: /* -> PHASE_STATUS */ /* MESSAGE OUT -> STATUS */
acornscsi_readstatusbyte(host);
host->scsi.phase = PHASE_STATUSIN; break;
case 0x8e: /* -> PHASE_MSGOUT */ /* MESSAGE_OUT(MESSAGE_IN) ->MESSAGE OUT */
acornscsi_sendmessage(host); break;
case 0x4f: /* -> PHASE_MSGIN, PHASE_DISCONNECT */ case 0x1f: /* -> PHASE_MSGIN, PHASE_DISCONNECT */ /* MESSAGE OUT -> MESSAGE IN */
acornscsi_message(host); break;
case PHASE_IDLE: /* STATE: disconnected */ if (ssr == 0x81) /* -> PHASE_RECONNECTED or PHASE_ABORTED */
acornscsi_reconnect(host); else {
printk(KERN_ERR "scsi%d.%c: PHASE_IDLE, SSR %02X while idle?\n",
host->host->host_no, acornscsi_target(host), ssr);
acornscsi_dumplog(host, host->SCpnt ? host->SCpnt->device->id : 8);
} return INTR_PROCESSING;
case PHASE_RECONNECTED: /* STATE: device reconnected to initiator */ /* * Command reconnected - if MESGIN, get message - it may be * the tag. If not, get command out of disconnected queue
*/ /* * If we reconnected and we're not in MESSAGE IN phase after IDENTIFY, * reconnect I_T_L command
*/ if (ssr != 0x8f && !acornscsi_reconnect_finish(host)) return INTR_IDLE;
ADD_STATUS(host->SCpnt->device->id, ssr, host->scsi.phase, in_irq); switch (ssr) { case 0x88: /* data out phase */ /* -> PHASE_DATAOUT */ /* MESSAGE IN -> DATA OUT */
acornscsi_dma_setup(host, DMA_OUT); if (!acornscsi_starttransfer(host))
acornscsi_abortcmd(host);
host->scsi.phase = PHASE_DATAOUT; return INTR_IDLE;
case 0x89: /* data in phase */ /* -> PHASE_DATAIN */ /* MESSAGE IN -> DATA IN */
acornscsi_dma_setup(host, DMA_IN); if (!acornscsi_starttransfer(host))
acornscsi_abortcmd(host);
host->scsi.phase = PHASE_DATAIN; return INTR_IDLE;
case 0x8a: /* command out */ /* MESSAGE IN -> COMMAND */
acornscsi_sendcommand(host);/* -> PHASE_COMMAND, PHASE_COMMANDPAUSED */ break;
case 0x8b: /* status in */ /* -> PHASE_STATUSIN */ /* MESSAGE IN -> STATUS */
acornscsi_readstatusbyte(host);
host->scsi.phase = PHASE_STATUSIN; break;
case 0x8e: /* message out */ /* -> PHASE_MSGOUT */ /* MESSAGE IN -> MESSAGE OUT */
acornscsi_sendmessage(host); break;
case 0x8f: /* message in */
acornscsi_message(host); /* -> PHASE_MSGIN, PHASE_DISCONNECT */ break;
default:
printk(KERN_ERR "scsi%d.%c: PHASE_RECONNECTED, SSR %02X after reconnect?\n",
host->host->host_no, acornscsi_target(host), ssr);
acornscsi_dumplog(host, host->SCpnt ? host->SCpnt->device->id : 8);
} return INTR_PROCESSING;
case PHASE_DATAIN: /* STATE: transferred data in */ /* * This is simple - if we disconnect then the DMA address & count is * correct.
*/ switch (ssr) { case 0x19: /* -> PHASE_DATAIN */ case 0x89: /* -> PHASE_DATAIN */
acornscsi_abortcmd(host); return INTR_IDLE;
case 0x1b: /* -> PHASE_STATUSIN */ case 0x4b: /* -> PHASE_STATUSIN */ case 0x8b: /* -> PHASE_STATUSIN */ /* DATA IN -> STATUS */
host->scsi.SCp.scsi_xferred = scsi_bufflen(host->SCpnt) -
acornscsi_sbic_xfcount(host);
acornscsi_dma_stop(host);
acornscsi_readstatusbyte(host);
host->scsi.phase = PHASE_STATUSIN; break;
case 0x1e: /* -> PHASE_MSGOUT */ case 0x4e: /* -> PHASE_MSGOUT */ case 0x8e: /* -> PHASE_MSGOUT */ /* DATA IN -> MESSAGE OUT */
host->scsi.SCp.scsi_xferred = scsi_bufflen(host->SCpnt) -
acornscsi_sbic_xfcount(host);
acornscsi_dma_stop(host);
acornscsi_sendmessage(host); break;
case 0x1f: /* message in */ case 0x4f: /* message in */ case 0x8f: /* message in */ /* DATA IN -> MESSAGE IN */
host->scsi.SCp.scsi_xferred = scsi_bufflen(host->SCpnt) -
acornscsi_sbic_xfcount(host);
acornscsi_dma_stop(host);
acornscsi_message(host); /* -> PHASE_MSGIN, PHASE_DISCONNECT */ break;
case PHASE_DATAOUT: /* STATE: transferred data out */ /* * This is more complicated - if we disconnect, the DMA could be 12 * bytes ahead of us. We need to correct this.
*/ switch (ssr) { case 0x18: /* -> PHASE_DATAOUT */ case 0x88: /* -> PHASE_DATAOUT */
acornscsi_abortcmd(host); return INTR_IDLE;
case 0x1b: /* -> PHASE_STATUSIN */ case 0x4b: /* -> PHASE_STATUSIN */ case 0x8b: /* -> PHASE_STATUSIN */ /* DATA OUT -> STATUS */
host->scsi.SCp.scsi_xferred = scsi_bufflen(host->SCpnt) -
acornscsi_sbic_xfcount(host);
acornscsi_dma_stop(host);
acornscsi_dma_adjust(host);
acornscsi_readstatusbyte(host);
host->scsi.phase = PHASE_STATUSIN; break;
case 0x1e: /* -> PHASE_MSGOUT */ case 0x4e: /* -> PHASE_MSGOUT */ case 0x8e: /* -> PHASE_MSGOUT */ /* DATA OUT -> MESSAGE OUT */
host->scsi.SCp.scsi_xferred = scsi_bufflen(host->SCpnt) -
acornscsi_sbic_xfcount(host);
acornscsi_dma_stop(host);
acornscsi_dma_adjust(host);
acornscsi_sendmessage(host); break;
case 0x1f: /* message in */ case 0x4f: /* message in */ case 0x8f: /* message in */ /* DATA OUT -> MESSAGE IN */
host->scsi.SCp.scsi_xferred = scsi_bufflen(host->SCpnt) -
acornscsi_sbic_xfcount(host);
acornscsi_dma_stop(host);
acornscsi_dma_adjust(host);
acornscsi_message(host); /* -> PHASE_MSGIN, PHASE_DISCONNECT */ break;
case PHASE_STATUSIN: /* STATE: status in complete */ switch (ssr) { case 0x1f: /* -> PHASE_MSGIN, PHASE_DONE, PHASE_DISCONNECT */ case 0x8f: /* -> PHASE_MSGIN, PHASE_DONE, PHASE_DISCONNECT */ /* STATUS -> MESSAGE IN */
acornscsi_message(host); break;
case 0x1e: /* -> PHASE_MSGOUT */
--> --------------------
--> maximum size reached
--> --------------------
Messung V0.5
¤ Dauer der Verarbeitung: 0.25 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.