ncr53c8xx.c
来自「linux 内核源代码」· C语言 代码 · 共 2,376 行 · 第 1/5 页
C
2,376 行
#define QU_REG scr0#define HS_REG scr1#define HS_PRT nc_scr1#define SS_REG scr2#define SS_PRT nc_scr2#define PS_REG scr3/*** Last four bytes (host)*/#ifdef SCSI_NCR_BIG_ENDIAN#define actualquirks phys.header.status[3]#define host_status phys.header.status[2]#define scsi_status phys.header.status[1]#define parity_status phys.header.status[0]#else#define actualquirks phys.header.status[0]#define host_status phys.header.status[1]#define scsi_status phys.header.status[2]#define parity_status phys.header.status[3]#endif/*** First four bytes (script)*/#define xerr_st header.scr_st[0]#define sync_st header.scr_st[1]#define nego_st header.scr_st[2]#define wide_st header.scr_st[3]/*** First four bytes (host)*/#define xerr_status phys.xerr_st#define nego_status phys.nego_st#if 0#define sync_status phys.sync_st#define wide_status phys.wide_st#endif/*==========================================================**** Declaration of structs: Data structure block****==========================================================**** During execution of a ccb by the script processor,** the DSA (data structure address) register points** to this substructure of the ccb.** This substructure contains the header with** the script-processor-changeable data and** data blocks for the indirect move commands.****----------------------------------------------------------*/struct dsb { /* ** Header. */ struct head header; /* ** Table data for Script */ struct scr_tblsel select; struct scr_tblmove smsg ; struct scr_tblmove cmd ; struct scr_tblmove sense ; struct scr_tblmove data[MAX_SCATTER];};/*========================================================================**** Declaration of structs: Command control block.****========================================================================*/struct ccb { /*---------------------------------------------------------------- ** This is the data structure which is pointed by the DSA ** register when it is executed by the script processor. ** It must be the first entry because it contains the header ** as first entry that must be cache line aligned. **---------------------------------------------------------------- */ struct dsb phys; /*---------------------------------------------------------------- ** Mini-script used at CCB execution start-up. ** Load the DSA with the data structure address (phys) and ** jump to SELECT. Jump to CANCEL if CCB is to be canceled. **---------------------------------------------------------------- */ struct launch start; /*---------------------------------------------------------------- ** Mini-script used at CCB relection to restart the nexus. ** Load the DSA with the data structure address (phys) and ** jump to RESEL_DSA. Jump to ABORT if CCB is to be aborted. **---------------------------------------------------------------- */ struct launch restart; /*---------------------------------------------------------------- ** If a data transfer phase is terminated too early ** (after reception of a message (i.e. DISCONNECT)), ** we have to prepare a mini script to transfer ** the rest of the data. **---------------------------------------------------------------- */ ncrcmd patch[8]; /*---------------------------------------------------------------- ** The general SCSI driver provides a ** pointer to a control block. **---------------------------------------------------------------- */ struct scsi_cmnd *cmd; /* SCSI command */ u_char cdb_buf[16]; /* Copy of CDB */ u_char sense_buf[64]; int data_len; /* Total data length */ /*---------------------------------------------------------------- ** Message areas. ** We prepare a message to be sent after selection. ** We may use a second one if the command is rescheduled ** due to GETCC or QFULL. ** Contents are IDENTIFY and SIMPLE_TAG. ** While negotiating sync or wide transfer, ** a SDTR or WDTR message is appended. **---------------------------------------------------------------- */ u_char scsi_smsg [8]; u_char scsi_smsg2[8]; /*---------------------------------------------------------------- ** Other fields. **---------------------------------------------------------------- */ u_long p_ccb; /* BUS address of this CCB */ u_char sensecmd[6]; /* Sense command */ u_char tag; /* Tag for this transfer */ /* 255 means no tag */ u_char target; u_char lun; u_char queued; u_char auto_sense; struct ccb * link_ccb; /* Host adapter CCB chain */ struct list_head link_ccbq; /* Link to unit CCB queue */ u32 startp; /* Initial data pointer */ u_long magic; /* Free / busy CCB flag */};#define CCB_PHYS(cp,lbl) (cp->p_ccb + offsetof(struct ccb, lbl))/*========================================================================**** Declaration of structs: NCR device descriptor****========================================================================*/struct ncb { /*---------------------------------------------------------------- ** The global header. ** It is accessible to both the host and the script processor. ** Must be cache line size aligned (32 for x86) in order to ** allow cache line bursting when it is copied to/from CCB. **---------------------------------------------------------------- */ struct head header; /*---------------------------------------------------------------- ** CCBs management queues. **---------------------------------------------------------------- */ struct scsi_cmnd *waiting_list; /* Commands waiting for a CCB */ /* when lcb is not allocated. */ struct scsi_cmnd *done_list; /* Commands waiting for done() */ /* callback to be invoked. */ spinlock_t smp_lock; /* Lock for SMP threading */ /*---------------------------------------------------------------- ** Chip and controller indentification. **---------------------------------------------------------------- */ int unit; /* Unit number */ char inst_name[16]; /* ncb instance name */ /*---------------------------------------------------------------- ** Initial value of some IO register bits. ** These values are assumed to have been set by BIOS, and may ** be used for probing adapter implementation differences. **---------------------------------------------------------------- */ u_char sv_scntl0, sv_scntl3, sv_dmode, sv_dcntl, sv_ctest0, sv_ctest3, sv_ctest4, sv_ctest5, sv_gpcntl, sv_stest2, sv_stest4; /*---------------------------------------------------------------- ** Actual initial value of IO register bits used by the ** driver. They are loaded at initialisation according to ** features that are to be enabled. **---------------------------------------------------------------- */ u_char rv_scntl0, rv_scntl3, rv_dmode, rv_dcntl, rv_ctest0, rv_ctest3, rv_ctest4, rv_ctest5, rv_stest2; /*---------------------------------------------------------------- ** Targets management. ** During reselection the ncr jumps to jump_tcb. ** The SFBR register is loaded with the encoded target id. ** For i = 0 to 3 ** SCR_JUMP ^ IFTRUE(MASK(i, 3)), @(next tcb mod. i) ** ** Recent chips will prefetch the 4 JUMPS using only 1 burst. ** It is kind of hashcoding. **---------------------------------------------------------------- */ struct link jump_tcb[4]; /* JUMPs for reselection */ struct tcb target[MAX_TARGET]; /* Target data */ /*---------------------------------------------------------------- ** Virtual and physical bus addresses of the chip. **---------------------------------------------------------------- */ void __iomem *vaddr; /* Virtual and bus address of */ unsigned long paddr; /* chip's IO registers. */ unsigned long paddr2; /* On-chip RAM bus address. */ volatile /* Pointer to volatile for */ struct ncr_reg __iomem *reg; /* memory mapped IO. */ /*---------------------------------------------------------------- ** SCRIPTS virtual and physical bus addresses. ** 'script' is loaded in the on-chip RAM if present. ** 'scripth' stays in main memory. **---------------------------------------------------------------- */ struct script *script0; /* Copies of script and scripth */ struct scripth *scripth0; /* relocated for this ncb. */ struct scripth *scripth; /* Actual scripth virt. address */ u_long p_script; /* Actual script and scripth */ u_long p_scripth; /* bus addresses. */ /*---------------------------------------------------------------- ** General controller parameters and configuration. **---------------------------------------------------------------- */ struct device *dev; u_char revision_id; /* PCI device revision id */ u32 irq; /* IRQ level */ u32 features; /* Chip features map */ u_char myaddr; /* SCSI id of the adapter */ u_char maxburst; /* log base 2 of dwords burst */ u_char maxwide; /* Maximum transfer width */ u_char minsync; /* Minimum sync period factor */ u_char maxsync; /* Maximum sync period factor */ u_char maxoffs; /* Max scsi offset */ u_char multiplier; /* Clock multiplier (1,2,4) */ u_char clock_divn; /* Number of clock divisors */ u_long clock_khz; /* SCSI clock frequency in KHz */ /*---------------------------------------------------------------- ** Start queue management. ** It is filled up by the host processor and accessed by the ** SCRIPTS processor in order to start SCSI commands. **---------------------------------------------------------------- */ u16 squeueput; /* Next free slot of the queue */ u16 actccbs; /* Number of allocated CCBs */ u16 queuedccbs; /* Number of CCBs in start queue*/ u16 queuedepth; /* Start queue depth */ /*---------------------------------------------------------------- ** Timeout handler. **---------------------------------------------------------------- */ struct timer_list timer; /* Timer handler link header */ u_long lasttime; u_long settle_time; /* Resetting the SCSI BUS */ /*---------------------------------------------------------------- ** Debugging and profiling. **---------------------------------------------------------------- */ struct ncr_reg regdump; /* Register dump */ u_long regtime; /* Time it has been done */ /*---------------------------------------------------------------- ** Miscellaneous buffers accessed by the scripts-processor. ** They shall be DWORD aligned, because they may be read or ** written with a SCR_COPY script command. **---------------------------------------------------------------- */ u_char msgout[8]; /* Buffer for MESSAGE OUT */ u_char msgin [8]; /* Buffer for MESSAGE IN */ u32 lastmsg; /* Last SCSI message sent */ u_char scratch; /* Scratch for SCSI receive */ /*---------------------------------------------------------------- ** Miscellaneous configuration and status parameters. **---------------------------------------------------------------- */ u_char disc; /* Diconnection allowed */ u_char scsi_mode; /* Current SCSI BUS mode */ u_char order; /* Tag order to use */ u_char verbose; /* Verbosity for this controller*/ int ncr_cache; /* Used for cache test at init. */ u_long p_ncb; /* BUS address of this NCB */ /*---------------------------------------------------------------- ** Command completion handling. **---------------------------------------------------------------- */#ifdef SCSI_NCR_CCB_DONE_SUPPORT struct ccb *(ccb_done[MAX_DONE]); int ccb_done_ic;#endif /*---------------------------------------------------------------- ** Fields that should be removed or changed. **---------------------------------------------------------------- */ struct ccb *ccb; /* Global CCB */ struct usrcmd user; /* Command from user */ volatile u_char release_stage; /* Synchronisation stage on release */};#define NCB_SCRIPT_PHYS(np,lbl) (np->p_script + offsetof (struct script, lbl))#define NCB_SCRIPTH_PHYS(np,lbl) (np->p_scripth + offsetof (struct scripth,lbl))/*==========================================================****** Script for NCR-Processor.**** Use ncr_script_fill() to create the variable parts.** Use ncr_script_copy_and_bind() to make a copy and** bind to physical addresses.******==========================================================**** We have to know the offsets of all labels before** we reach them (for forward jumps).** Therefore we declare a struct here.** If you make changes inside the script,** DONT FORGET TO CHANGE THE LENGTHS HERE!****----------------------------------------------------------*//*** For HP Zalon/53c720 systems, the Zalon interface** between CPU and 53c720 does prefetches, which causes** problems with self modifying scripts. The problem** is overcome by calling a dummy subroutine after each** modification, to force a refetch of the script on** return from the subroutine.*/#ifdef CONFIG_NCR53C8XX_PREFETCH#define PREFETCH_FLUSH_CNT 2#define PREFETCH_FLUSH SCR_CALL, PADDRH (wait_dma),#else#define PREFETCH_FLUSH_CNT 0#define PREFETCH_FLUSH#endif/*** Script fragments which are loaded into the on-chip RAM ** of 825A, 875 and 895 chips.*/struct script { ncrcmd start [ 5]; ncrcmd startpos [ 1]; ncrcmd select [ 6]; ncrcmd select2 [ 9 + PREFETCH_FLUSH_CNT]; ncrcmd loadpos [ 4]; ncrcmd send_ident [ 9]; ncrcmd prepare [ 6]; ncrcmd prepare2 [ 7]; ncrcmd command [ 6]; ncrcmd dispatch [ 32]; ncrcmd clrack [ 4]; ncrcmd no_data [ 17]; ncrcmd status [ 8]; ncrcmd msg_in [ 2]; ncrcmd msg_in2 [ 16]; ncrcmd msg_bad [ 4]; ncrcmd setmsg [ 7]; ncrcmd cleanup [ 6]; ncrcmd complete [ 9]; ncrcmd cleanup_ok [ 8 + PREFETCH_FLUSH_CNT]; ncrcmd cleanup0 [ 1];#ifndef SCSI_NCR_CCB_DONE_SUPPORT ncrcmd signal [ 12];#else ncrcmd signal [ 9]; ncrcmd done_pos [ 1]; ncrcmd done_plug [ 2]; ncrcmd done_end [ 7];#endif ncrcmd save_dp [ 7]; ncrcmd restore_dp [ 5]; ncrcmd disconnect [ 10]; ncrcmd msg_out [ 9]; ncrcmd msg_out_done [ 7]; ncrcmd idle [ 2]; ncrcmd reselect [ 8]; ncrcmd reselected [ 8]; ncrcmd resel_dsa [ 6 + PREFETCH_FLUSH_CNT]; ncrcmd loadpos1 [ 4]; ncrcmd resel_lun [ 6]; ncrcmd resel_tag [ 6]; ncrcmd jump_to_nexus [ 4 + PREFETCH_FLUSH_CNT]; ncrcmd nexus_indirect [ 4]; ncrcmd resel_notag [ 4]; ncrcmd data_in [MAX_SCATTERL * 4]; ncrcmd data_in2 [ 4]; ncrcmd data_out [MAX_SCATTERL * 4]; ncrcmd data_out2 [ 4];};/*** Script fragments which stay in main memory for all chips.*/struct scripth { ncrcmd tryloop [MAX_START*2]; ncrcmd tryloop2 [ 2];#ifdef SCSI_NCR_CCB_DONE_SUPPORT ncrcmd done_queue [MAX_DONE*5]; ncrcmd done_queue2 [ 2];#endif ncrcmd select_no_atn [ 8]; ncrcmd cancel [ 4]; ncrcmd skip [ 9 + PREFETCH_FLUSH_CNT]; ncrcmd skip2 [ 19]; ncrcmd par_err_data_in [ 6]; ncrcmd par_err_other [ 4]; ncrcmd msg_reject [ 8]; ncrcmd msg_ign_residue [ 24]; ncrcmd msg_extended [ 10]; ncrcmd msg_ext_2 [ 10]; ncrcmd msg_wdtr [ 14]; ncrcmd send_wdtr [ 7]; ncrcmd msg_ext_3 [ 10]; ncrcmd msg_sdtr [ 14]; ncrcmd send_sdtr [ 7]; ncrcmd nego_bad_phase [ 4]; ncrcmd msg_out_abort [ 10]; ncrcmd hdata_in [MAX_SCATTERH * 4]; ncrcmd hdata_in2 [ 2]; ncrcmd hdata_out [MAX_SCATTERH * 4]; ncrcmd hdata_out2 [ 2]; ncrcmd reset [ 4]; ncrcmd aborttag [ 4]; ncrcmd abort [ 2]; ncrcmd abort_resel [ 20]; ncrcmd resend_ident [ 4]; ncrcmd clratn_go_on [ 3]; ncrcmd nxtdsp_go_on [ 1]; ncrcmd sdata_in [ 8]; ncrcmd data_io [ 18]; ncrcmd bad_identify [ 12]; ncrcmd bad_i_t_l [ 4]; ncrcmd bad_i_t_l_q [ 4]; ncrcmd bad_target [ 8]; ncrcmd bad_status [ 8]; ncrcmd start_ram [ 4 + PREFETCH_FLUSH_CNT]; ncrcmd start_ram0 [ 4]; ncrcmd sto_restart [ 5];
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?