📄 ncr53c8xx.c
字号:
*/ 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. **---------------------------------------------------------------- */ 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; ccb_p link_ccb; /* Host adapter CCB chain */ XPT_QUEHEAD link_ccbq; /* Link to unit CCB queue */ u_int32 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. **---------------------------------------------------------------- */ Scsi_Cmnd *waiting_list; /* Commands waiting for a CCB */ /* when lcb is not allocated. */ Scsi_Cmnd *done_list; /* Commands waiting for done() */ /* callback to be invoked. */ #if LINUX_VERSION_CODE >= LinuxVersionCode(2,1,93) spinlock_t smp_lock; /* Lock for SMP threading */#endif /*---------------------------------------------------------------- ** Chip and controller indentification. **---------------------------------------------------------------- */ int unit; /* Unit number */ char chip_name[8]; /* Chip name */ 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_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_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. **---------------------------------------------------------------- */ vm_offset_t vaddr; /* Virtual and bus address of */ vm_offset_t paddr; /* chip's IO registers. */ vm_offset_t paddr2; /* On-chip RAM bus address. */ volatile /* Pointer to volatile for */ struct ncr_reg *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. **---------------------------------------------------------------- */ pcidev_t pdev; u_short device_id; /* PCI device id */ u_char revision_id; /* PCI device revision id */ u_char bus; /* PCI BUS number */ u_char device_fn; /* PCI BUS device and function */ u_long base_io; /* IO space base address */ u_int irq; /* IRQ level */ u_int 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. **---------------------------------------------------------------- */ u_short squeueput; /* Next free slot of the queue */ u_short actccbs; /* Number of allocated CCBs */ u_short queuedccbs; /* Number of CCBs in start queue*/ u_short 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 */#ifdef SCSI_NCR_PROFILE_SUPPORT struct profile profile; /* Profiling data */ u_int disc_phys; /* Disconnection counters */ u_int disc_ref;#endif /*---------------------------------------------------------------- ** 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 */ u_int32 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. **---------------------------------------------------------------- */#ifdef SCSI_NCR_PROFILE_SUPPORT u_long ktime; /* Copy of kernel time */#endif struct ccb *ccb; /* Global CCB */ struct usrcmd user; /* Command from user */ u_char release_stage; /* Synchronisation stage on release */#ifdef SCSI_NCR_INTEGRITY_CHECKING /*---------------------------------------------------------------- ** Fields that are used for integrity check **---------------------------------------------------------------- */ unsigned char check_integrity; /* Enable midlayer integ.check on * bus scan. */ unsigned char check_integ_par; /* Set if par or Init. Det. error * used only during integ check */#endif};#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!****----------------------------------------------------------*//*** 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]; ncrcmd loadpos [ 4]; ncrcmd send_ident [ 9]; ncrcmd prepare [ 6]; ncrcmd prepare2 [ 7];#ifdef SCSI_NCR_PROFILE_SUPPORT ncrcmd command [ 9];#else ncrcmd command [ 6];#endif ncrcmd dispatch [ 32]; ncrcmd clrack [ 4]; ncrcmd no_data [ 17];#ifdef SCSI_NCR_PROFILE_SUPPORT ncrcmd status [ 11];#else ncrcmd status [ 8];#endif 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]; 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];#ifdef SCSI_NCR_PROFILE_SUPPORT ncrcmd disconnect [ 28];#else ncrcmd disconnect [ 17];#endif ncrcmd msg_out [ 9]; ncrcmd msg_out_done [ 7]; ncrcmd idle [ 2]; ncrcmd reselect [ 8]; ncrcmd reselected [ 8]; ncrcmd resel_dsa [ 6];#ifdef SCSI_NCR_PROFILE_SUPPORT ncrcmd loadpos1 [ 7];#else ncrcmd loadpos1 [ 4];#endif ncrcmd resel_lun [ 6]; ncrcmd resel_tag [ 6]; ncrcmd jump_to_nexus [ 4]; 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]; 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]; ncrcmd start_ram0 [ 4]; ncrcmd sto_restart [ 5]; ncrcmd snooptest [ 9]; ncrcmd snoopend [ 2];};/*==========================================================****** Function headers.******==========================================================*/static void ncr_alloc_ccb (ncb_p np, u_char tn, u_char ln);static void ncr_complete (ncb_p np, ccb_p cp);static void ncr_exception (ncb_p np);static void ncr_free_ccb (ncb_p np, ccb_p cp);static void ncr_init_ccb (ncb_p np, ccb_p cp);static void ncr_init_tcb (ncb_p np, u_char tn);static lcb_p ncr_alloc_lcb (ncb_p np, u_char tn, u_char ln);static lcb_p ncr_setup_lcb (ncb_p np, u_char tn, u_char ln, u_char *inq_data);static void ncr_getclock (ncb_p np, int mult);static void ncr_selectclock (ncb_p np, u_char scntl3);static ccb_p ncr_get_ccb (ncb_p np, u_char tn, u_char ln);static void ncr_init (ncb_p np, int reset, char * msg, u_long code);static int ncr_int_sbmc (ncb_p np);static int ncr_int_par (ncb_p np);static void ncr_int_ma (ncb_p np);static void ncr_int_sir (ncb_p np);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -