⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 aiclib.h

📁 h内核
💻 H
📖 第 1 页 / 共 2 页
字号:
#define	T_ENCLOSURE	0x0d#define	T_RBC		0x0e#define	T_OCRW		0x0f#define T_NODEVICE	0x1F#define	T_ANY		0xFF	/* Used in Quirk table matches */#define T_REMOV		1#define	T_FIXED		0/* * This length is the initial inquiry length used by the probe code, as     * well as the legnth necessary for aic_print_inquiry() to function  * correctly.  If either use requires a different length in the future,  * the two values should be de-coupled. */#define	SHORT_INQUIRY_LENGTH	36struct scsi_inquiry_data{	uint8_t device;#define	SID_TYPE(inq_data) ((inq_data)->device & 0x1f)#define	SID_QUAL(inq_data) (((inq_data)->device & 0xE0) >> 5)#define	SID_QUAL_LU_CONNECTED	0x00	/*					 * The specified peripheral device					 * type is currently connected to					 * logical unit.  If the target cannot					 * determine whether or not a physical					 * device is currently connected, it					 * shall also use this peripheral					 * qualifier when returning the INQUIRY					 * data.  This peripheral qualifier					 * does not mean that the device is					 * ready for access by the initiator.					 */#define	SID_QUAL_LU_OFFLINE	0x01	/*					 * The target is capable of supporting					 * the specified peripheral device type					 * on this logical unit; however, the					 * physical device is not currently					 * connected to this logical unit.					 */#define SID_QUAL_RSVD		0x02#define	SID_QUAL_BAD_LU		0x03	/*					 * The target is not capable of					 * supporting a physical device on					 * this logical unit. For this					 * peripheral qualifier the peripheral					 * device type shall be set to 1Fh to					 * provide compatibility with previous					 * versions of SCSI. All other					 * peripheral device type values are					 * reserved for this peripheral					 * qualifier.					 */#define	SID_QUAL_IS_VENDOR_UNIQUE(inq_data) ((SID_QUAL(inq_data) & 0x08) != 0)	uint8_t dev_qual2;#define	SID_QUAL2	0x7F#define	SID_IS_REMOVABLE(inq_data) (((inq_data)->dev_qual2 & 0x80) != 0)	uint8_t version;#define SID_ANSI_REV(inq_data) ((inq_data)->version & 0x07)#define		SCSI_REV_0		0#define		SCSI_REV_CCS		1#define		SCSI_REV_2		2#define		SCSI_REV_SPC		3#define		SCSI_REV_SPC2		4#define SID_ECMA	0x38#define SID_ISO		0xC0	uint8_t response_format;#define SID_AENC	0x80#define SID_TrmIOP	0x40	uint8_t additional_length;	uint8_t reserved[2];	uint8_t flags;#define	SID_SftRe	0x01#define	SID_CmdQue	0x02#define	SID_Linked	0x08#define	SID_Sync	0x10#define	SID_WBus16	0x20#define	SID_WBus32	0x40#define	SID_RelAdr	0x80#define SID_VENDOR_SIZE   8	char	 vendor[SID_VENDOR_SIZE];#define SID_PRODUCT_SIZE  16	char	 product[SID_PRODUCT_SIZE];#define SID_REVISION_SIZE 4	char	 revision[SID_REVISION_SIZE];	/*	 * The following fields were taken from SCSI Primary Commands - 2	 * (SPC-2) Revision 14, Dated 11 November 1999	 */#define	SID_VENDOR_SPECIFIC_0_SIZE	20	uint8_t vendor_specific0[SID_VENDOR_SPECIFIC_0_SIZE];	/*	 * An extension of SCSI Parallel Specific Values	 */#define	SID_SPI_IUS		0x01#define	SID_SPI_QAS		0x02#define	SID_SPI_CLOCK_ST	0x00#define	SID_SPI_CLOCK_DT	0x04#define	SID_SPI_CLOCK_DT_ST	0x0C#define	SID_SPI_MASK		0x0F	uint8_t spi3data;	uint8_t reserved2;	/*	 * Version Descriptors, stored 2 byte values.	 */	uint8_t version1[2];	uint8_t version2[2];	uint8_t version3[2];	uint8_t version4[2];	uint8_t version5[2];	uint8_t version6[2];	uint8_t version7[2];	uint8_t version8[2];	uint8_t reserved3[22];#define	SID_VENDOR_SPECIFIC_1_SIZE	160	uint8_t vendor_specific1[SID_VENDOR_SPECIFIC_1_SIZE];};struct scsi_vpd_unit_serial_number{	uint8_t device;	uint8_t page_code;#define SVPD_UNIT_SERIAL_NUMBER	0x80	uint8_t reserved;	uint8_t length; /* serial number length */#define SVPD_SERIAL_NUM_SIZE 251	uint8_t serial_num[SVPD_SERIAL_NUM_SIZE];};struct scsi_read_capacity{	uint8_t opcode;	uint8_t byte2;	uint8_t addr[4];	uint8_t unused[3];	uint8_t control;};struct scsi_read_capacity_data{	uint8_t addr[4];	uint8_t length[4];};struct scsi_report_luns{	uint8_t opcode;	uint8_t byte2;	uint8_t unused[3];	uint8_t addr[4];	uint8_t control;};struct scsi_report_luns_data {	uint8_t length[4];	/* length of LUN inventory, in bytes */	uint8_t reserved[4];	/* unused */	/*	 * LUN inventory- we only support the type zero form for now.	 */	struct {		uint8_t lundata[8];	} luns[1];};#define	RPL_LUNDATA_ATYP_MASK	0xc0	/* MBZ for type 0 lun */#define	RPL_LUNDATA_T0LUN	1	/* @ lundata[1] */struct scsi_sense_data{	uint8_t error_code;#define	SSD_ERRCODE			0x7F#define		SSD_CURRENT_ERROR	0x70#define		SSD_DEFERRED_ERROR	0x71#define	SSD_ERRCODE_VALID	0x80		uint8_t segment;	uint8_t flags;#define	SSD_KEY				0x0F#define		SSD_KEY_NO_SENSE	0x00#define		SSD_KEY_RECOVERED_ERROR	0x01#define		SSD_KEY_NOT_READY	0x02#define		SSD_KEY_MEDIUM_ERROR	0x03#define		SSD_KEY_HARDWARE_ERROR	0x04#define		SSD_KEY_ILLEGAL_REQUEST	0x05#define		SSD_KEY_UNIT_ATTENTION	0x06#define		SSD_KEY_DATA_PROTECT	0x07#define		SSD_KEY_BLANK_CHECK	0x08#define		SSD_KEY_Vendor_Specific	0x09#define		SSD_KEY_COPY_ABORTED	0x0a#define		SSD_KEY_ABORTED_COMMAND	0x0b		#define		SSD_KEY_EQUAL		0x0c#define		SSD_KEY_VOLUME_OVERFLOW	0x0d#define		SSD_KEY_MISCOMPARE	0x0e#define		SSD_KEY_RESERVED	0x0f			#define	SSD_ILI		0x20#define	SSD_EOM		0x40#define	SSD_FILEMARK	0x80	uint8_t info[4];	uint8_t extra_len;	uint8_t cmd_spec_info[4];	uint8_t add_sense_code;	uint8_t add_sense_code_qual;	uint8_t fru;	uint8_t sense_key_spec[3];#define	SSD_SCS_VALID		0x80#define SSD_FIELDPTR_CMD	0x40#define SSD_BITPTR_VALID	0x08#define SSD_BITPTR_VALUE	0x07#define SSD_MIN_SIZE 18	uint8_t extra_bytes[14];#define SSD_FULL_SIZE sizeof(struct scsi_sense_data)};struct scsi_mode_header_6{	uint8_t data_length;	/* Sense data length */	uint8_t medium_type;	uint8_t dev_spec;	uint8_t blk_desc_len;};struct scsi_mode_header_10{	uint8_t data_length[2];/* Sense data length */	uint8_t medium_type;	uint8_t dev_spec;	uint8_t unused[2];	uint8_t blk_desc_len[2];};struct scsi_mode_page_header{	uint8_t page_code;	uint8_t page_length;};struct scsi_mode_blk_desc{	uint8_t density;	uint8_t nblocks[3];	uint8_t reserved;	uint8_t blklen[3];};#define	SCSI_DEFAULT_DENSITY	0x00	/* use 'default' density */#define	SCSI_SAME_DENSITY	0x7f	/* use 'same' density- >= SCSI-2 only *//* * Status Byte */#define	SCSI_STATUS_OK			0x00#define	SCSI_STATUS_CHECK_COND		0x02#define	SCSI_STATUS_COND_MET		0x04#define	SCSI_STATUS_BUSY		0x08#define SCSI_STATUS_INTERMED		0x10#define SCSI_STATUS_INTERMED_COND_MET	0x14#define SCSI_STATUS_RESERV_CONFLICT	0x18#define SCSI_STATUS_CMD_TERMINATED	0x22	/* Obsolete in SAM-2 */#define SCSI_STATUS_QUEUE_FULL		0x28#define SCSI_STATUS_ACA_ACTIVE		0x30#define SCSI_STATUS_TASK_ABORTED	0x40struct scsi_inquiry_pattern {	uint8_t   type;	uint8_t   media_type;#define	SIP_MEDIA_REMOVABLE	0x01#define	SIP_MEDIA_FIXED		0x02	const char *vendor;	const char *product;	const char *revision;}; struct scsi_static_inquiry_pattern {	uint8_t   type;	uint8_t   media_type;	char       vendor[SID_VENDOR_SIZE+1];	char       product[SID_PRODUCT_SIZE+1];	char       revision[SID_REVISION_SIZE+1];};struct scsi_sense_quirk_entry {	struct scsi_inquiry_pattern	inq_pat;	int				num_sense_keys;	int				num_ascs;	struct sense_key_table_entry	*sense_key_info;	struct asc_table_entry		*asc_info;};struct sense_key_table_entry {	uint8_t    sense_key;	uint32_t   action;	const char *desc;};struct asc_table_entry {	uint8_t    asc;	uint8_t    ascq;	uint32_t   action;	const char *desc;};struct op_table_entry {	uint8_t    opcode;	uint16_t   opmask;	const char  *desc;};struct scsi_op_quirk_entry {	struct scsi_inquiry_pattern	inq_pat;	int				num_ops;	struct op_table_entry		*op_table;};typedef enum {	SSS_FLAG_NONE		= 0x00,	SSS_FLAG_PRINT_COMMAND	= 0x01} scsi_sense_string_flags;extern const char *scsi_sense_key_text[];/************************* Large Disk Handling ********************************/#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)static __inline int aic_sector_div(u_long capacity, int heads, int sectors);static __inline intaic_sector_div(u_long capacity, int heads, int sectors){	return (capacity / (heads * sectors));}#elsestatic __inline int aic_sector_div(sector_t capacity, int heads, int sectors);static __inline intaic_sector_div(sector_t capacity, int heads, int sectors){	/* ugly, ugly sector_div calling convention.. */	sector_div(capacity, (heads * sectors));	return (int)capacity;}#endif/**************************** Module Library Hack *****************************//* * What we'd like to do is have a single "scsi library" module that both the * aic7xxx and aic79xx drivers could load and depend on.  A cursory examination * of implementing module dependencies in Linux (handling the install and * initrd cases) does not look promissing.  For now, we just duplicate this * code in both drivers using a simple symbol renaming scheme that hides this * hack from the drivers. */#define AIC_LIB_ENTRY_CONCAT(x, prefix)	prefix ## x#define	AIC_LIB_ENTRY_EXPAND(x, prefix) AIC_LIB_ENTRY_CONCAT(x, prefix)#define AIC_LIB_ENTRY(x)		AIC_LIB_ENTRY_EXPAND(x, AIC_LIB_PREFIX)#define	aic_sense_desc			AIC_LIB_ENTRY(_sense_desc)#define	aic_sense_error_action		AIC_LIB_ENTRY(_sense_error_action)#define	aic_error_action		AIC_LIB_ENTRY(_error_action)#define	aic_op_desc			AIC_LIB_ENTRY(_op_desc)#define	aic_cdb_string			AIC_LIB_ENTRY(_cdb_string)#define aic_print_inquiry		AIC_LIB_ENTRY(_print_inquiry)#define aic_calc_syncsrate		AIC_LIB_ENTRY(_calc_syncrate)#define	aic_calc_syncparam		AIC_LIB_ENTRY(_calc_syncparam)#define	aic_calc_speed			AIC_LIB_ENTRY(_calc_speed)#define	aic_inquiry_match		AIC_LIB_ENTRY(_inquiry_match)#define	aic_static_inquiry_match	AIC_LIB_ENTRY(_static_inquiry_match)#define	aic_parse_brace_option		AIC_LIB_ENTRY(_parse_brace_option)/******************************************************************************/void			aic_sense_desc(int /*sense_key*/, int /*asc*/,				       int /*ascq*/, struct scsi_inquiry_data*,				       const char** /*sense_key_desc*/,				       const char** /*asc_desc*/);aic_sense_action	aic_sense_error_action(struct scsi_sense_data*,					       struct scsi_inquiry_data*,					       uint32_t /*sense_flags*/);uint32_t		aic_error_action(struct scsi_cmnd *,					 struct scsi_inquiry_data *,					 cam_status, u_int);#define	SF_RETRY_UA	0x01#define SF_NO_PRINT	0x02#define SF_QUIET_IR	0x04	/* Be quiet about Illegal Request reponses */#define SF_PRINT_ALWAYS	0x08const char *	aic_op_desc(uint16_t /*opcode*/, struct scsi_inquiry_data*);char *		aic_cdb_string(uint8_t* /*cdb_ptr*/, char* /*cdb_string*/,			       size_t /*len*/);void		aic_print_inquiry(struct scsi_inquiry_data*);u_int		aic_calc_syncsrate(u_int /*period_factor*/);u_int		aic_calc_syncparam(u_int /*period*/);u_int		aic_calc_speed(u_int width, u_int period, u_int offset,			       u_int min_rate);	int		aic_inquiry_match(caddr_t /*inqbuffer*/,				  caddr_t /*table_entry*/);int		aic_static_inquiry_match(caddr_t /*inqbuffer*/,					 caddr_t /*table_entry*/);typedef void aic_option_callback_t(u_long, int, int, int32_t);char *		aic_parse_brace_option(char *opt_name, char *opt_arg,				       char *end, int depth,				       aic_option_callback_t *, u_long);static __inline void	 scsi_extract_sense(struct scsi_sense_data *sense,					    int *error_code, int *sense_key,					    int *asc, int *ascq);static __inline void	 scsi_ulto2b(uint32_t val, uint8_t *bytes);static __inline void	 scsi_ulto3b(uint32_t val, uint8_t *bytes);static __inline void	 scsi_ulto4b(uint32_t val, uint8_t *bytes);static __inline uint32_t scsi_2btoul(uint8_t *bytes);static __inline uint32_t scsi_3btoul(uint8_t *bytes);static __inline int32_t	 scsi_3btol(uint8_t *bytes);static __inline uint32_t scsi_4btoul(uint8_t *bytes);static __inline void scsi_extract_sense(struct scsi_sense_data *sense,				       int *error_code, int *sense_key,				       int *asc, int *ascq){	*error_code = sense->error_code & SSD_ERRCODE;	*sense_key = sense->flags & SSD_KEY;	*asc = (sense->extra_len >= 5) ? sense->add_sense_code : 0;	*ascq = (sense->extra_len >= 6) ? sense->add_sense_code_qual : 0;}static __inline voidscsi_ulto2b(uint32_t val, uint8_t *bytes){	bytes[0] = (val >> 8) & 0xff;	bytes[1] = val & 0xff;}static __inline voidscsi_ulto3b(uint32_t val, uint8_t *bytes){	bytes[0] = (val >> 16) & 0xff;	bytes[1] = (val >> 8) & 0xff;	bytes[2] = val & 0xff;}static __inline voidscsi_ulto4b(uint32_t val, uint8_t *bytes){	bytes[0] = (val >> 24) & 0xff;	bytes[1] = (val >> 16) & 0xff;	bytes[2] = (val >> 8) & 0xff;	bytes[3] = val & 0xff;}static __inline uint32_tscsi_2btoul(uint8_t *bytes){	uint32_t rv;	rv = (bytes[0] << 8) |	     bytes[1];	return (rv);}static __inline uint32_tscsi_3btoul(uint8_t *bytes){	uint32_t rv;	rv = (bytes[0] << 16) |	     (bytes[1] << 8) |	     bytes[2];	return (rv);}static __inline int32_t scsi_3btol(uint8_t *bytes){	uint32_t rc = scsi_3btoul(bytes); 	if (rc & 0x00800000)		rc |= 0xff000000;	return (int32_t) rc;}static __inline uint32_tscsi_4btoul(uint8_t *bytes){	uint32_t rv;	rv = (bytes[0] << 24) |	     (bytes[1] << 16) |	     (bytes[2] << 8) |	     bytes[3];	return (rv);}/* Macros for generating the elements of the PCI ID tables. */#define GETID(v, s) (unsigned)(((v) >> (s)) & 0xFFFF ?: PCI_ANY_ID)#define ID_C(x, c)						\{								\	GETID(x,32), GETID(x,48), GETID(x,0), GETID(x,16),	\	(c) << 8, 0xFFFF00, 0					\}#define ID2C(x)                          \	ID_C(x, PCI_CLASS_STORAGE_SCSI), \	ID_C(x, PCI_CLASS_STORAGE_RAID)#define IDIROC(x)  ((x) | ~ID_ALL_IROC_MASK)/* Generate IDs for all 16 possibilites. * The argument has already masked out * the 4 least significant bits of the device id. * (e.g., mask: ID_9005_GENERIC_MASK). */#define ID16(x)                          \	ID(x),                           \	ID((x) | 0x0001000000000000ull), \	ID((x) | 0x0002000000000000ull), \	ID((x) | 0x0003000000000000ull), \	ID((x) | 0x0004000000000000ull), \	ID((x) | 0x0005000000000000ull), \	ID((x) | 0x0006000000000000ull), \	ID((x) | 0x0007000000000000ull), \	ID((x) | 0x0008000000000000ull), \	ID((x) | 0x0009000000000000ull), \	ID((x) | 0x000A000000000000ull), \	ID((x) | 0x000B000000000000ull), \	ID((x) | 0x000C000000000000ull), \	ID((x) | 0x000D000000000000ull), \	ID((x) | 0x000E000000000000ull), \	ID((x) | 0x000F000000000000ull)#endif /*_AICLIB_H */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -