📄 sym53c8xx.c
字号:
/*---------------------------------------------------------------- ** Control of tagged command queuing. ** Tags allocation is performed using a circular buffer. ** This avoids using a loop for tag allocation. **---------------------------------------------------------------- */ u_short ia_tag; /* Tag allocation index */ u_short if_tag; /* Tag release index */ u_char *cb_tags; /* Circular tags buffer */ u_char inq_byte7; /* Store unit CmdQ capability */ u_char usetags; /* Command queuing is active */ u_char to_clear; /* User wants to clear all tasks*/ u_short maxtags; /* Max NR of tags asked by user */ u_short numtags; /* Current number of tags */ /*---------------------------------------------------------------- ** QUEUE FULL and ORDERED tag control. **---------------------------------------------------------------- */ u_short num_good; /* Nr of GOOD since QUEUE FULL */ u_short tags_sum[2]; /* Tags sum counters */ u_char tags_si; /* Current index to tags sum */ u_long tags_stime; /* Last time we switch tags_sum */};/*========================================================================**** Declaration of structs: actions for a task.****========================================================================**** It is part of the CCB and is called by the scripts processor to ** start or restart the data structure (nexus).****------------------------------------------------------------------------*/struct action { u_int32 start; u_int32 restart;};/*========================================================================**** Declaration of structs: Phase mismatch context.****========================================================================**** It is part of the CCB and is used as parameters for the DATA ** pointer. We need two contexts to handle correctly the SAVED ** DATA POINTER.****------------------------------------------------------------------------*/struct pm_ctx { struct scr_tblmove sg; /* Updated interrupted SG block */ u_int32 ret; /* SCRIPT return address */};/*========================================================================**** Declaration of structs: global HEADER.****========================================================================**** In earlier driver versions, this substructure was copied from the ** ccb to a global address after selection (or reselection) and copied ** back before disconnect. Since we are now using LOAD/STORE DSA ** RELATIVE instructions, the script is able to access directly these ** fields, and so, this header is no more copied.****------------------------------------------------------------------------*/struct head { /*---------------------------------------------------------------- ** Start and restart SCRIPTS addresses (must be at 0). **---------------------------------------------------------------- */ struct action go; /*---------------------------------------------------------------- ** Saved data pointer. ** Points to the position in the script responsible for the ** actual transfer of data. ** It's written after reception of a SAVE_DATA_POINTER message. ** The goalpointer points after the last transfer command. **---------------------------------------------------------------- */ u_int32 savep; u_int32 lastp; u_int32 goalp; /*---------------------------------------------------------------- ** Alternate data pointer. ** They are copied back to savep/lastp/goalp by the SCRIPTS ** when the direction is unknown and the device claims data out. **---------------------------------------------------------------- */ u_int32 wlastp; u_int32 wgoalp; /*---------------------------------------------------------------- ** Status fields. **---------------------------------------------------------------- */ u_char scr_st[4]; /* script status */ u_char status[4]; /* host status */};/*** LUN control block lookup.** We use a direct pointer for LUN #0, and a table of pointers ** which is only allocated for devices that support LUN(s) > 0.*/#if MAX_LUN <= 1#define ncr_lp(np, tp, lun) (!lun) ? (tp)->l0p : 0#else#define ncr_lp(np, tp, lun) \ (!lun) ? (tp)->l0p : (tp)->lmp ? (tp)->lmp[(lun)] : 0#endif/*** The status bytes are used by the host and the script processor.**** The last four bytes (status[4]) are copied to the scratchb register** (declared as scr0..scr3 in ncr_reg.h) just after the select/reselect,** and copied back just after disconnecting.** Inside the script the XX_REG are used.**** The first four bytes (scr_st[4]) are used inside the script by ** "LOAD/STORE" commands.** Because source and destination must have the same alignment** in a DWORD, the fields HAVE to be at the choosen offsets.** xerr_st 0 (0x34) scratcha** sync_st 1 (0x05) sxfer** wide_st 3 (0x03) scntl3*//*** Last four bytes (script)*/#define QU_REG scr0#define HS_REG scr1#define HS_PRT nc_scr1#define SS_REG scr2#define SS_PRT nc_scr2#define HF_REG scr3#define HF_PRT nc_scr3/*** Last four bytes (host)*/#define actualquirks phys.header.status[0]#define host_status phys.header.status[1]#define scsi_status phys.header.status[2]#define host_flags phys.header.status[3]/*** Host flags*/#define HF_IN_PM0 1u#define HF_IN_PM1 (1u<<1)#define HF_ACT_PM (1u<<2)#define HF_DP_SAVED (1u<<3)#define HF_AUTO_SENSE (1u<<4)#define HF_DATA_IN (1u<<5)#define HF_PM_TO_C (1u<<6)#define HF_EXT_ERR (1u<<7)#ifdef SCSI_NCR_IARB_SUPPORT#define HF_HINT_IARB (1u<<7)#endif/*** This one is stolen from QU_REG.:)*/#define HF_DATA_ST (1u<<7)/*** 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/*==========================================================**** 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-changable 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 smsg_ext ; struct scr_tblmove cmd ; struct scr_tblmove sense ; struct scr_tblmove wresid; struct scr_tblmove data [MAX_SCATTER]; /* ** Phase mismatch contexts. ** We need two to handle correctly the ** SAVED DATA POINTER. */ struct pm_ctx pm0; struct pm_ctx pm1; /* ** Extra bytes count transferred ** in case of data overrun. */ u_int32 extra_bytes;#ifdef SCSI_NCR_PROFILE_SUPPORT /* ** Disconnection counter */ u_int32 num_disc;#endif};/*========================================================================**** 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. **---------------------------------------------------------------- */ struct dsb phys; /*---------------------------------------------------------------- ** 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 */ int segments; /* Number of SG segments */ /*---------------------------------------------------------------- ** Message areas. ** We prepare a message to be sent after selection. ** We may use a second one if the command is rescheduled ** due to CHECK_CONDITION or QUEUE FULL status. ** 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]; /*---------------------------------------------------------------- ** Saved info for auto-sense **---------------------------------------------------------------- */ u_char sv_scsi_status; u_char sv_xerr_status; /*---------------------------------------------------------------- ** Other fields. **---------------------------------------------------------------- */ u_long p_ccb; /* BUS address of this CCB */ u_char sensecmd[6]; /* Sense command */ u_char to_abort; /* This CCB is to be aborted */ u_short tag; /* Tag for this transfer */ /* NO_TAG means no tag */ u_char tags_si; /* Lun tags sum index (0,1) */ u_char target; u_char lun; u_short queued; ccb_p link_ccb; /* Host adapter CCB chain */ ccb_p link_ccbh; /* Host adapter CCB hash chain */ XPT_QUEHEAD link_ccbq; /* Link to unit CCB queue */ u_int32 startp; /* Initial data pointer */ u_int32 lastp0; /* Initial 'lastp' */ int ext_sg; /* Extreme data pointer, used */ int ext_ofs; /* to calculate the residual. */ int resid;};#define CCB_PHYS(cp,lbl) (cp->p_ccb + offsetof(struct ccb, lbl))/*========================================================================**** Declaration of structs: NCR device descriptor****========================================================================*/struct ncb { /*---------------------------------------------------------------- ** Idle task and invalid task actions and their bus ** addresses. **---------------------------------------------------------------- */ struct action idletask; struct action notask; struct action bad_i_t_l; struct action bad_i_t_l_q; u_long p_idletask; u_long p_notask; u_long p_bad_i_t_l; u_long p_bad_i_t_l_q; /*---------------------------------------------------------------- ** Dummy lun table to protect us against target returning bad ** lun number on reselection. **---------------------------------------------------------------- */ u_int32 *badluntbl; /* Table physical address */ u_int32 resel_badlun; /* SCRIPT handler BUS address */ /*---------------------------------------------------------------- ** Bit 32-63 of the on-chip RAM bus address in LE format. ** The START_RAM64 script loads the MMRS and MMWS from this ** field. **---------------------------------------------------------------- */ u_int32 scr_ram_seg; /*---------------------------------------------------------------- ** 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, sv_stest1, sv_scntl4; /*---------------------------------------------------------------- ** 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, rv_ccntl0, rv_ccntl1, rv_scntl4; /*---------------------------------------------------------------- ** Target data. ** Target control block bus address array used by the SCRIPT ** on reselection. **---------------------------------------------------------------- */ struct tcb target[MAX_TARGET]; u_int32 *targtbl; /*---------------------------------------------------------------- ** Virtual and physical bus addresses of the chip. **---------------------------------------------------------------- */#ifndef SCSI_NCR_PCI_MEM_NOT_SUPPORTED u_long base_va; /* MMIO base virtual address */ u_long base2_va; /* On-chip RAM virtual address */#endif u_long base_ba; /* MMIO base bus address */ u_long base_io; /* IO space base address */ u_long base_ws; /* (MM)IO window size */ u_long base2_ba; /* On-chip RAM bus address */ u_long base2_ws; /* On-chip RAM window size */ u_int irq; /* IRQ number */ 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 for all chips except the ** 53C895A and 53C896 that provide 8K on-chip RAM. **---------------------------------------------------------------- */ struct script *script0; /* Copies of script and scripth */ struct scripth *scripth0; /* relocated for this ncb. */ u_long p_script; /* Actual script and scripth */ u_long p_scripth; /* bus addresses. */ u_long p_scripth0; /*---------------------------------------------------------------- ** 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_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 */ u_int features; /* Chip features map */ /*---------------------------------------------------------------- ** Range for the PCI clock frequency measurement result ** that ensures the algorithm used by the driver can be ** trusted for the SCSI clock frequency measurement. ** (Assuming a PCI clock frequency of 33 MHz). **---------------------------------------------------------------- */ u_int pciclock_min; u_int pciclock_max; /*---------------------------------------------------------------- ** Start queue management. ** It is filled up by the host processor and accessed by the ** SCRIPTS processor in order to start SCSI commands. **-------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -