📄 53c8xx_d.h
字号:
/* DO NOT EDIT - Generated automatically by script_asm.pl */static u32 SCRIPT[] = {/*; 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.;ABSOLUTE 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_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);;; ; Define DSA structure used for mailboxesENTRY dsa_code_templatedsa_code_template:ENTRY dsa_code_begindsa_code_begin: MOVE dmode_memory_to_ncr TO DMODEat 0x00000000 : */ 0x78380000,0x00000000,/* MOVE MEMORY 4, dsa_temp_addr_dsa_value, addr_scratchat 0x00000002 : */ 0xc0000004,0x00000000,0x00000000,/* MOVE dmode_memory_to_memory TO DMODEat 0x00000005 : */ 0x78380000,0x00000000,/* CALL scratch_to_dsaat 0x00000007 : */ 0x88080000,0x00000980,/* CALL selectat 0x00000009 : */ 0x88080000,0x000001fc,/*; 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 ATNat 0x0000000b : */ 0x60000008,0x00000000,/* CLEAR ACKat 0x0000000d : */ 0x60000040,0x00000000,/*; 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, 0at 0x0000000f : */ 0xc0000004,0x00000000,0x00000000,/* JUMP select_doneat 0x00000012 : */ 0x80080000,0x00000224,/*; wrong_dsa loads the DSA register with the value of the dsa_next; field.;wrong_dsa:; 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 + 8at 0x00000014 : */ 0xc0000004,0x00000000,0x00000758,/* MOVE dmode_memory_to_ncr TO DMODE at 0x00000017 : */ 0x78380000,0x00000000,/*;; 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_scratchat 0x00000019 : */ 0xc0000004,0x00000000,0x00000000,/* MOVE dmode_memory_to_memory TO DMODEat 0x0000001c : */ 0x78380000,0x00000000,/* CALL scratch_to_dsaat 0x0000001e : */ 0x88080000,0x00000980,/* JUMP reselected_check_nextat 0x00000020 : */ 0x80080000,0x000006a4,/*ABSOLUTE dsa_save_data_pointer = 0ENTRY dsa_code_save_data_pointerdsa_code_save_data_pointer: MOVE dmode_ncr_to_memory TO DMODEat 0x00000022 : */ 0x78380000,0x00000000,/* MOVE MEMORY 4, addr_temp, dsa_temp_addr_saved_pointerat 0x00000024 : */ 0xc0000004,0x00000000,0x00000000,/* MOVE dmode_memory_to_memory TO DMODEat 0x00000027 : */ 0x78380000,0x00000000,/*; HARD CODED : 24 bytes needs to agree with 53c7,8xx.h MOVE MEMORY 24, dsa_temp_addr_residual, dsa_temp_addr_saved_residualat 0x00000029 : */ 0xc0000018,0x00000000,0x00000000,/* CLEAR ACKat 0x0000002c : */ 0x60000040,0x00000000,/* RETURNat 0x0000002e : */ 0x90080000,0x00000000,/*ABSOLUTE dsa_restore_pointers = 0ENTRY dsa_code_restore_pointersdsa_code_restore_pointers: MOVE dmode_memory_to_ncr TO DMODEat 0x00000030 : */ 0x78380000,0x00000000,/* MOVE MEMORY 4, dsa_temp_addr_saved_pointer, addr_tempat 0x00000032 : */ 0xc0000004,0x00000000,0x00000000,/* MOVE dmode_memory_to_memory TO DMODEat 0x00000035 : */ 0x78380000,0x00000000,/*; HARD CODED : 24 bytes needs to agree with 53c7,8xx.h MOVE MEMORY 24, dsa_temp_addr_saved_residual, dsa_temp_addr_residualat 0x00000037 : */ 0xc0000018,0x00000000,0x00000000,/* CLEAR ACKat 0x0000003a : */ 0x60000040,0x00000000,/* RETURNat 0x0000003c : */ 0x90080000,0x00000000,/*ABSOLUTE 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: MOVE SSID TO SFBR ; SSID contains 3 bit target IDat 0x0000003e : */ 0x720a0000,0x00000000,/*; 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 0xf8at 0x00000040 : */ 0x8084f800,0x00ffff48,/*;; Hack - move to scratch first, since SFBR is not writeable; via the CPU and hence a MOVE MEMORY instruction.; MOVE dmode_memory_to_ncr TO DMODEat 0x00000042 : */ 0x78380000,0x00000000,/* MOVE MEMORY 1, reselected_identify, addr_scratchat 0x00000044 : */ 0xc0000001,0x00000000,0x00000000,/* MOVE dmode_memory_to_memory TO DMODEat 0x00000047 : */ 0x78380000,0x00000000,/* MOVE SCRATCH0 TO SFBRat 0x00000049 : */ 0x72340000,0x00000000,/*; FIXME : we need to accommodate bit fielded and binary here for '7xx/'8xx chips JUMP REL (wrong_dsa), IF NOT dsa_temp_lun, AND MASK 0xf8at 0x0000004b : */ 0x8084f800,0x00ffff1c,/*; 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 + 4at 0x0000004d : */ 0xc0000004,0x00000000,0x00000754,/* CALL reselected_okat 0x00000050 : */ 0x88080000,0x00000750,/* CALL dsa_temp_sync at 0x00000052 : */ 0x88080000,0x00000000,/*; Release ACK on the IDENTIFY message _after_ we've set the synchronous ; transfer parameters! CLEAR ACKat 0x00000054 : */ 0x60000040,0x00000000,/*; Implicitly restore pointers on reselection, so a RETURN; will transfer control back to the right spot. CALL REL (dsa_code_restore_pointers)at 0x00000056 : */ 0x88880000,0x00ffff60,/* RETURNat 0x00000058 : */ 0x90080000,0x00000000,/*ENTRY 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; Interrupts - ; MSB indicates type; 0 handle error condition; 1 handle message ; 2 handle normal condition; 3 debugging interrupt; 4 testing interrupt ; Next byte indicates specific error; XXX not yet implemented, I'm not sure if I want to - ; Next byte indicates the routine the error occurred in; The LSB indicates the specific place the error occurred ABSOLUTE int_err_unexpected_phase = 0x00000000 ; Unexpected phase encounteredABSOLUTE int_err_selected = 0x00010000 ; SELECTED (nee RESELECTED)ABSOLUTE int_err_unexpected_reselect = 0x00020000 ABSOLUTE int_err_check_condition = 0x00030000 ABSOLUTE int_err_no_phase = 0x00040000ABSOLUTE int_msg_wdtr = 0x01000000 ; WDTR message receivedABSOLUTE int_msg_sdtr = 0x01010000 ; SDTR receivedABSOLUTE int_msg_1 = 0x01020000 ; single byte special message ; receivedABSOLUTE int_norm_select_complete = 0x02000000 ; Select complete, reprogram ; registers.ABSOLUTE int_norm_reselect_complete = 0x02010000 ; Nexus establishedABSOLUTE int_norm_command_complete = 0x02020000 ; Command completeABSOLUTE int_norm_disconnected = 0x02030000 ; Disconnected ABSOLUTE int_norm_aborted =0x02040000 ; Aborted *dsaABSOLUTE int_norm_reset = 0x02050000 ; Generated BUS reset.ABSOLUTE int_debug_break = 0x03000000 ; Break pointABSOLUTE int_debug_panic = 0x030b0000 ; Panic driverABSOLUTE int_test_1 = 0x04000000 ; Test 1 completeABSOLUTE int_test_2 = 0x04010000 ; Test 2 completeABSOLUTE int_test_3 = 0x04020000 ; Test 3 complete; These should start with 0x05000000, with low bits incrementing for ; each one. ABSOLUTE NCR53c7xx_msg_abort = 0 ; Pointer to abort messageABSOLUTE NCR53c7xx_msg_reject = 0 ; Pointer to reject messageABSOLUTE NCR53c7xx_zero = 0 ; long with zero in it, use for sourceABSOLUTE NCR53c7xx_sink = 0 ; long to dump worthless data inABSOLUTE NOP_insn = 0 ; NOP instruction; Pointer to message, potentially multi-byteABSOLUTE msg_buf = 0; Pointer to holding area for reselection informationABSOLUTE reselected_identify = 0ABSOLUTE reselected_tag = 0; Request sense command pointer, it's a 6 byte command, should; be constant for all commands since we always want 16 bytes of ; sense and we don't need to change any fields as we did under ; SCSI-I when we actually cared about the LUN field.;EXTERNAL NCR53c7xx_sense ; Request sense command; dsa_schedule ; PURPOSE : after a DISCONNECT message has been received, and pointers; saved, insert the current DSA structure at the head of the ; disconnected queue and fall through to the scheduler.;; CALLS : OK;; INPUTS : dsa - current DSA structure, reconnect_dsa_head - list; of disconnected commands;; MODIFIES : SCRATCH, reconnect_dsa_head; ; EXITS : always passes control to scheduleENTRY dsa_scheduledsa_schedule:;; Calculate the address of the next pointer within the DSA ; structure of the command that is currently disconnecting; CALL dsa_to_scratchat 0x0000005a : */ 0x88080000,0x00000938,/* MOVE SCRATCH0 + dsa_next TO SCRATCH0at 0x0000005c : */ 0x7e343000,0x00000000,/* MOVE SCRATCH1 + 0 TO SCRATCH1 WITH CARRYat 0x0000005e : */ 0x7f350000,0x00000000,/* MOVE SCRATCH2 + 0 TO SCRATCH2 WITH CARRYat 0x00000060 : */ 0x7f360000,0x00000000,/* MOVE SCRATCH3 + 0 TO SCRATCH3 WITH CARRYat 0x00000062 : */ 0x7f370000,0x00000000,/*; Point the next field of this DSA structure at the current disconnected ; list MOVE dmode_ncr_to_memory TO DMODEat 0x00000064 : */ 0x78380000,0x00000000,/* MOVE MEMORY 4, addr_scratch, dsa_schedule_insert + 8at 0x00000066 : */ 0xc0000004,0x00000000,0x000001b4,/* MOVE dmode_memory_to_memory TO DMODEat 0x00000069 : */ 0x78380000,0x00000000,/*dsa_schedule_insert: MOVE MEMORY 4, reconnect_dsa_head, 0 at 0x0000006b : */ 0xc0000004,0x00000000,0x00000000,/*; And update the head pointer. CALL dsa_to_scratchat 0x0000006e : */ 0x88080000,0x00000938,/* MOVE dmode_ncr_to_memory TO DMODE at 0x00000070 : */ 0x78380000,0x00000000,/* MOVE MEMORY 4, addr_scratch, reconnect_dsa_headat 0x00000072 : */ 0xc0000004,0x00000000,0x00000000,/* MOVE dmode_memory_to_memory TO DMODEat 0x00000075 : */ 0x78380000,0x00000000,/* MOVE SCNTL2 & 0x7f TO SCNTL2at 0x00000077 : */ 0x7c027f00,0x00000000,/* CLEAR ACKat 0x00000079 : */ 0x60000040,0x00000000,/* WAIT DISCONNECTat 0x0000007b : */ 0x48000000,0x00000000,/* JUMP scheduleat 0x0000007d : */ 0x80080000,0x00000000,/*;; select;; PURPOSE : establish a nexus for the SCSI command referenced by DSA.; On success, the current DSA structure is removed from the issue ; queue. Usually, this is entered as a fall-through from schedule,; although the contingent allegiance handling code will write; the select entry address to the DSP to restart a command as a ; REQUEST SENSE. A message is sent (usually IDENTIFY, although; additional SDTR or WDTR messages may be sent). COMMAND OUT; is handled.;; INPUTS : DSA - SCSI command, issue_dsa_head;; CALLS : NOT OK;; MODIFIES : SCRATCH, issue_dsa_head;; EXITS : on reselection or selection, go to select_failed; otherwise, RETURN so control is passed back to ; dsa_begin.;ENTRY selectselect: CLEAR TARGETat 0x0000007f : */ 0x60000200,0x00000000,/*; XXX;; In effect, SELECTION operations are backgrounded, with execution; continuing until code which waits for REQ or a fatal interrupt is ; encountered.;; So, for more performance, we could overlap the code which removes ; the command from the NCRs issue queue with the selection, but ; at this point I don't want to deal with the error recovery.; SELECT ATN FROM dsa_select, select_failedat 0x00000081 : */ 0x4300003c,0x000007a4,/* JUMP select_msgout, WHEN MSG_OUTat 0x00000083 : */ 0x860b0000,0x00000214,/*ENTRY select_msgoutselect_msgout: MOVE FROM dsa_msgout, WHEN MSG_OUTat 0x00000085 : */ 0x1e000000,0x00000040,/*
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -