📄 53c7xx.scr
字号:
#undef DEBUG#undef EVENTS#undef NO_SELECTION_TIMEOUT#define BIG_ENDIAN; 53c710 driver. Modified from Drew Eckhardts driver; for 53c810 by Richard Hirst [richard@sleepie.demon.co.uk];; I have left the script for the 53c8xx family in here, as it is likely; to be useful to see what I changed when bug hunting.; NCR 53c810 driver, main script; Sponsored by ; iX Multiuser Multitasking Magazine; hm@ix.de;; Copyright 1993, 1994, 1995 Drew Eckhardt; Visionary Computing ; (Unix and Linux consulting and custom programming); drew@PoohSticks.ORG; +1 (303) 786-7975;; TolerANT and SCSI SCRIPTS are registered trademarks of NCR Corporation.;; PRE-ALPHA;; For more information, please consult ;; NCR 53C810; PCI-SCSI I/O Processor; Data Manual;; NCR 53C710 ; SCSI I/O Processor; Programmers Guide;; NCR Microelectronics; 1635 Aeroplaza Drive; Colorado Springs, CO 80916; 1+ (719) 578-3400;; Toll free literature number; +1 (800) 334-5454;; IMPORTANT : This code is self modifying due to the limitations of ; the NCR53c7,8xx series chips. Persons debugging this code with; the remote debugger should take this into account, and NOT set; breakpoints in modified instructions.;; Design:; The NCR53c7,8xx family of SCSI chips are busmasters with an onboard ; microcontroller using a simple instruction set. ;; So, to minimize the effects of interrupt latency, and to maximize ; throughput, this driver offloads the practical maximum amount ; of processing to the SCSI chip while still maintaining a common; structure.;; Where tradeoffs were needed between efficiency on the older; chips and the newer NCR53c800 series, the NCR53c800 series ; was chosen.;; While the NCR53c700 and NCR53c700-66 lacked the facilities to fully; automate SCSI transfers without host processor intervention, this ; isn't the case with the NCR53c710 and newer chips which allow ;; - reads and writes to the internal registers from within the SCSI; scripts, allowing the SCSI SCRIPTS(tm) code to save processor; state so that multiple threads of execution are possible, and also; provide an ALU for loop control, etc.; ; - table indirect addressing for some instructions. This allows ; pointers to be located relative to the DSA ((Data Structure; Address) register.;; These features make it possible to implement a mailbox style interface,; where the same piece of code is run to handle I/O for multiple threads; at once minimizing our need to relocate code. Since the NCR53c700/; NCR53c800 series have a unique combination of features, making a ; a standard ingoing/outgoing mailbox system, costly, I've modified it.;; - Mailboxes are a mixture of code and data. This lets us greatly; simplify the NCR53c810 code and do things that would otherwise; not be possible.;; The saved data pointer is now implemented as follows :;; Control flow has been architected such that if control reaches; munge_save_data_pointer, on a restore pointers message or ; reconnection, a jump to the address formerly in the TEMP register; will allow the SCSI command to resume execution.;;; Note : the DSA structures must be aligned on 32 bit boundaries,; since the source and destination of MOVE MEMORY instructions ; must share the same alignment and this is the alignment of the; NCR registers.;; For some systems (MVME166, for example) dmode is always the same, so don't; waste time writing it#if 1#define DMODE_MEMORY_TO_NCR#define DMODE_MEMORY_TO_MEMORY#define DMODE_NCR_TO_MEMORY#else#define DMODE_MEMORY_TO_NCR MOVE dmode_memory_to_ncr TO DMODE#define DMODE_MEMORY_TO_MEMORY MOVE dmode_memory_to_memory TO DMODE#define DMODE_NCR_TO_MEMORY MOVE dmode_ncr_to_memory TO DMODE#endifABSOLUTE dsa_temp_lun = 0 ; Patch to lun for current dsaABSOLUTE dsa_temp_next = 0 ; Patch to dsa next for current dsaABSOLUTE dsa_temp_addr_next = 0 ; Patch to address of dsa next address ; for current dsaABSOLUTE dsa_temp_sync = 0 ; Patch to address of per-target ; sync routineABSOLUTE dsa_sscf_710 = 0 ; Patch to address of per-target ; sscf value (53c710)ABSOLUTE dsa_temp_target = 0 ; Patch to id for current dsaABSOLUTE dsa_temp_addr_saved_pointer = 0; Patch to address of per-command ; saved data pointerABSOLUTE dsa_temp_addr_residual = 0 ; Patch to address of per-command ; current residual codeABSOLUTE dsa_temp_addr_saved_residual = 0; Patch to address of per-command ; saved residual codeABSOLUTE dsa_temp_addr_new_value = 0 ; Address of value for JUMP operandABSOLUTE dsa_temp_addr_array_value = 0 ; Address to copy toABSOLUTE dsa_temp_addr_dsa_value = 0 ; Address of this DSA value;; Once a device has initiated reselection, we need to compare it ; against the singly linked list of commands which have disconnected; and are pending reselection. These commands are maintained in ; an unordered singly linked list of DSA structures, through the; DSA pointers at their 'centers' headed by the reconnect_dsa_head; pointer.; ; To avoid complications in removing commands from the list,; I minimize the amount of expensive (at eight operations per; addition @ 500-600ns each) pointer operations which must; be done in the NCR driver by precomputing them on the ; host processor during dsa structure generation.;; The fixed-up per DSA code knows how to recognize the nexus; associated with the corresponding SCSI command, and modifies; the source and destination pointers for the MOVE MEMORY ; instruction which is executed when reselected_ok is called; to remove the command from the list. Similarly, DSA is ; loaded with the address of the next DSA structure and; reselected_check_next is called if a failure occurs.;; Perhaps more concisely, the net effect of the mess is ;; for (dsa = reconnect_dsa_head, dest = &reconnect_dsa_head, ; src = NULL; dsa; dest = &dsa->next, dsa = dsa->next) {; src = &dsa->next;; if (target_id == dsa->id && target_lun == dsa->lun) {; *dest = *src;; break;; } ; };; if (!dsa); error (int_err_unexpected_reselect);; else ; longjmp (dsa->jump_resume, 0);;; #if (CHIP != 700) && (CHIP != 70066); Define DSA structure used for mailboxesENTRY dsa_code_templatedsa_code_template:ENTRY dsa_code_begindsa_code_begin:; RGH: Don't care about TEMP and DSA here DMODE_MEMORY_TO_NCR MOVE MEMORY 4, dsa_temp_addr_dsa_value, addr_scratch DMODE_MEMORY_TO_MEMORY#if (CHIP == 710) MOVE MEMORY 4, addr_scratch, saved_dsa ; We are about to go and select the device, so must set SSCF bits MOVE MEMORY 4, dsa_sscf_710, addr_scratch#ifdef BIG_ENDIAN MOVE SCRATCH3 TO SFBR#else MOVE SCRATCH0 TO SFBR#endif MOVE SFBR TO SBCL MOVE MEMORY 4, saved_dsa, addr_dsa#else CALL scratch_to_dsa#endif CALL select; Handle the phase mismatch which may have resulted from the ; MOVE FROM dsa_msgout if we returned here. The CLEAR ATN ; may or may not be necessary, and we should update script_asm.pl; to handle multiple pieces. CLEAR ATN CLEAR ACK; Replace second operand with address of JUMP instruction dest operand; in schedule table for this DSA. Becomes dsa_jump_dest in 53c7,8xx.c.ENTRY dsa_code_fix_jumpdsa_code_fix_jump: MOVE MEMORY 4, NOP_insn, 0 JUMP select_done; wrong_dsa loads the DSA register with the value of the dsa_next; field.;wrong_dsa:#if (CHIP == 710); NOTE DSA is corrupt when we arrive here!#endif; Patch the MOVE MEMORY INSTRUCTION such that ; the destination address is the address of the OLD ; next pointer.; MOVE MEMORY 4, dsa_temp_addr_next, reselected_ok_patch + 8 DMODE_MEMORY_TO_NCR;; Move the _contents_ of the next pointer into the DSA register as ; the next I_T_L or I_T_L_Q tupple to check against the established; nexus.; MOVE MEMORY 4, dsa_temp_next, addr_scratch DMODE_MEMORY_TO_MEMORY#if (CHIP == 710) MOVE MEMORY 4, addr_scratch, saved_dsa MOVE MEMORY 4, saved_dsa, addr_dsa#else CALL scratch_to_dsa#endif JUMP reselected_check_nextABSOLUTE dsa_save_data_pointer = 0ENTRY dsa_code_save_data_pointerdsa_code_save_data_pointer:#if (CHIP == 710) ; When we get here, TEMP has been saved in jump_temp+4, DSA is corrupt ; We MUST return with DSA correct MOVE MEMORY 4, jump_temp+4, dsa_temp_addr_saved_pointer; HARD CODED : 24 bytes needs to agree with 53c7,8xx.h MOVE MEMORY 24, dsa_temp_addr_residual, dsa_temp_addr_saved_residual CLEAR ACK#ifdef DEBUG INT int_debug_saved#endif MOVE MEMORY 4, saved_dsa, addr_dsa JUMP jump_temp#else DMODE_NCR_TO_MEMORY MOVE MEMORY 4, addr_temp, dsa_temp_addr_saved_pointer DMODE_MEMORY_TO_MEMORY; HARD CODED : 24 bytes needs to agree with 53c7,8xx.h MOVE MEMORY 24, dsa_temp_addr_residual, dsa_temp_addr_saved_residual CLEAR ACK#ifdef DEBUG INT int_debug_saved#endif RETURN#endifABSOLUTE dsa_restore_pointers = 0ENTRY dsa_code_restore_pointersdsa_code_restore_pointers:#if (CHIP == 710) ; TEMP and DSA are corrupt when we get here, but who cares! MOVE MEMORY 4, dsa_temp_addr_saved_pointer, jump_temp + 4; HARD CODED : 24 bytes needs to agree with 53c7,8xx.h MOVE MEMORY 24, dsa_temp_addr_saved_residual, dsa_temp_addr_residual CLEAR ACK ; Restore DSA, note we don't care about TEMP MOVE MEMORY 4, saved_dsa, addr_dsa#ifdef DEBUG INT int_debug_restored#endif JUMP jump_temp#else DMODE_MEMORY_TO_NCR MOVE MEMORY 4, dsa_temp_addr_saved_pointer, addr_temp DMODE_MEMORY_TO_MEMORY; HARD CODED : 24 bytes needs to agree with 53c7,8xx.h MOVE MEMORY 24, dsa_temp_addr_saved_residual, dsa_temp_addr_residual CLEAR ACK#ifdef DEBUG INT int_debug_restored#endif RETURN#endifABSOLUTE dsa_check_reselect = 0; dsa_check_reselect determines whether or not the current target and; lun match the current DSAENTRY dsa_code_check_reselectdsa_code_check_reselect:#if (CHIP == 710) /* Arrives here with DSA correct */ /* Assumes we are always ID 7 */ MOVE LCRC TO SFBR ; LCRC has our ID and his ID bits set JUMP REL (wrong_dsa), IF NOT dsa_temp_target, AND MASK 0x80#else MOVE SSID TO SFBR ; SSID contains 3 bit target ID; FIXME : we need to accommodate bit fielded and binary here for '7xx/'8xx chips JUMP REL (wrong_dsa), IF NOT dsa_temp_target, AND MASK 0xf8#endif;; Hack - move to scratch first, since SFBR is not writeable; via the CPU and hence a MOVE MEMORY instruction.; DMODE_MEMORY_TO_NCR MOVE MEMORY 1, reselected_identify, addr_scratch DMODE_MEMORY_TO_MEMORY#ifdef BIG_ENDIAN ; BIG ENDIAN ON MVME16x MOVE SCRATCH3 TO SFBR#else MOVE SCRATCH0 TO SFBR#endif; FIXME : we need to accommodate bit fielded and binary here for '7xx/'8xx chips; Are you sure about that? richard@sleepie.demon.co.uk JUMP REL (wrong_dsa), IF NOT dsa_temp_lun, AND MASK 0xf8; Patch the MOVE MEMORY INSTRUCTION such that; the source address is the address of this dsa's; next pointer. MOVE MEMORY 4, dsa_temp_addr_next, reselected_ok_patch + 4 CALL reselected_ok#if (CHIP == 710); Restore DSA following memory moves in reselected_ok; dsa_temp_sync doesn't really care about DSA, but it has an; optional debug INT so a valid DSA is a good idea. MOVE MEMORY 4, saved_dsa, addr_dsa#endif CALL dsa_temp_sync ; Release ACK on the IDENTIFY message _after_ we've set the synchronous ; transfer parameters! CLEAR ACK; Implicitly restore pointers on reselection, so a RETURN; will transfer control back to the right spot. CALL REL (dsa_code_restore_pointers) RETURNENTRY dsa_zerodsa_zero:ENTRY dsa_code_template_enddsa_code_template_end:; Perform sanity check for dsa_fields_start == dsa_code_template_end - ; dsa_zero, puke.ABSOLUTE dsa_fields_start = 0 ; Sanity marker ; pad 48 bytes (fix this RSN)ABSOLUTE dsa_next = 48 ; len 4 Next DSA ; del 4 Previous DSA addressABSOLUTE dsa_cmnd = 56 ; len 4 Scsi_Cmnd * for this thread.ABSOLUTE dsa_select = 60 ; len 4 Device ID, Period, Offset for ; table indirect selectABSOLUTE dsa_msgout = 64 ; len 8 table indirect move parameter for ; select messageABSOLUTE dsa_cmdout = 72 ; len 8 table indirect move parameter for ; commandABSOLUTE dsa_dataout = 80 ; len 4 code pointer for dataoutABSOLUTE dsa_datain = 84 ; len 4 code pointer for datainABSOLUTE dsa_msgin = 88 ; len 8 table indirect move for msginABSOLUTE dsa_status = 96 ; len 8 table indirect move for status byteABSOLUTE dsa_msgout_other = 104 ; len 8 table indirect for normal message out ; (Synchronous transfer negotiation, etc).ABSOLUTE dsa_end = 112ABSOLUTE schedule = 0 ; Array of JUMP dsa_begin or JUMP (next), ; terminated by a call to JUMP wait_reselect; Linked lists of DSA structuresABSOLUTE reconnect_dsa_head = 0 ; Link list of DSAs which can reconnectABSOLUTE addr_reconnect_dsa_head = 0 ; Address of variable containing ; address of reconnect_dsa_head; These select the source and destination of a MOVE MEMORY instructionABSOLUTE dmode_memory_to_memory = 0x0ABSOLUTE dmode_memory_to_ncr = 0x0ABSOLUTE dmode_ncr_to_memory = 0x0ABSOLUTE addr_scratch = 0x0ABSOLUTE addr_temp = 0x0#if (CHIP == 710)ABSOLUTE saved_dsa = 0x0ABSOLUTE emulfly = 0x0ABSOLUTE addr_dsa = 0x0#endif#endif /* CHIP != 700 && CHIP != 70066 */; Interrupts - ; MSB indicates type; 0 handle error condition; 1 handle message ; 2 handle normal condition
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -