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

📄 adwlib.h

📁 基于组件方式开发操作系统的OSKIT源代码
💻 H
📖 第 1 页 / 共 2 页
字号:
/* * Definitions for low level routines and data structures * for the Advanced Systems Inc. SCSI controllers chips. * * Copyright (c) 1998 Justin T. Gibbs. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright *    notice, this list of conditions, and the following disclaimer, *    without modification, immediately at the beginning of the file. * 2. Redistributions in binary form must reproduce the above copyright *    notice, this list of conditions and the following disclaimer in the *    documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products *    derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * *      $Id: adwlib.h,v 1.1 1998/10/07 03:20:46 gibbs Exp $ *//* * Ported from: * advansys.c - Linux Host Driver for AdvanSys SCSI Adapters *      * Copyright (c) 1995-1998 Advanced System Products, Inc. * All Rights Reserved. *    * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that redistributions of source * code retain the above copyright notice and this comment without * modification. */#ifndef _ADWLIB_H_#define _ADWLIB_H_#include "opt_adw.h"#include <stddef.h>	/* for offsetof */#include <dev/advansys/adwmcode.h>#define ADW_DEF_MAX_HOST_QNG	253#define ADW_DEF_MIN_HOST_QNG	16#define ADW_DEF_MAX_DVC_QNG	63#define ADW_DEF_MIN_DVC_QNG	4#define ADW_MAX_TID		15#define ADW_MAX_LUN		7/* * Board Register offsets. */#define ADW_INTR_STATUS_REG			0x0000#define		ADW_INTR_STATUS_INTRA		0x01#define		ADW_INTR_STATUS_INTRB		0x02#define		ADW_INTR_STATUS_INTRC		0x04#define ADW_SIGNATURE_WORD			0x0000#define		 ADW_CHIP_ID_WORD		0x04C1#define	ADW_SIGNATURE_BYTE			0x0001#define		 ADW_CHIP_ID_BYTE		0x25	#define	ADW_INTR_ENABLES			0x0002	/*8 bit */#define		ADW_INTR_ENABLE_HOST_INTR	0x01#define		ADW_INTR_ENABLE_SEL_INTR	0x02#define		ADW_INTR_ENABLE_DPR_INTR	0x04#define		ADW_INTR_ENABLE_RTA_INTR	0x08#define		ADW_INTR_ENABLE_RMA_INTR	0x10#define		ADW_INTR_ENABLE_RST_INTR	0x20#define		ADW_INTR_ENABLE_DPE_INTR	0x40#define		ADW_INTR_ENABLE_GLOBAL_INTR	0x80#define ADW_CTRL_REG				0x0002  /*16 bit*/#define		ADW_CTRL_REG_HOST_INTR		0x0100#define		ADW_CTRL_REG_SEL_INTR		0x0200#define		ADW_CTRL_REG_DPR_INTR		0x0400#define		ADW_CTRL_REG_RTA_INTR		0x0800#define		ADW_CTRL_REG_RMA_INTR		0x1000#define		ADW_CTRL_REG_RES_BIT14		0x2000#define		ADW_CTRL_REG_DPE_INTR		0x4000#define		ADW_CTRL_REG_POWER_DONE		0x8000#define		ADW_CTRL_REG_ANY_INTR		0xFF00#define		ADW_CTRL_REG_CMD_RESET		0x00C6#define		ADW_CTRL_REG_CMD_WR_IO_REG	0x00C5#define		ADW_CTRL_REG_CMD_RD_IO_REG	0x00C4#define		ADW_CTRL_REG_CMD_WR_PCI_CFG	0x00C3#define		ADW_CTRL_REG_CMD_RD_PCI_CFG	0x00C2#define ADW_RAM_ADDR				0x0004#define ADW_RAM_DATA				0x0006#define ADW_RISC_CSR				0x000A#define		ADW_RISC_CSR_STOP		0x0000#define		ADW_RISC_TEST_COND		0x2000#define		ADW_RISC_CSR_RUN		0x4000#define		ADW_RISC_CSR_SINGLE_STEP	0x8000#define ADW_SCSI_CFG0				0x000C#define		ADW_SCSI_CFG0_TIMER_MODEAB	0xC000  /*							 * Watchdog, Second,							 * and Selto timer CFG							 */#define		ADW_SCSI_CFG0_PARITY_EN		0x2000#define		ADW_SCSI_CFG0_EVEN_PARITY	0x1000#define		ADW_SCSI_CFG0_WD_LONG		0x0800  /*							 * Watchdog Interval,							 * 1: 57 min, 0: 13 sec							 */#define		ADW_SCSI_CFG0_QUEUE_128		0x0400  /*							 * Queue Size,							 * 1: 128 byte,							 * 0: 64 byte							 */#define		ADW_SCSI_CFG0_PRIM_MODE		0x0100#define		ADW_SCSI_CFG0_SCAM_EN		0x0080#define		ADW_SCSI_CFG0_SEL_TMO_LONG	0x0040  /*							 * Sel/Resel Timeout,							 * 1: 400 ms,							 * 0: 1.6 ms							 */#define		ADW_SCSI_CFG0_CFRM_ID		0x0020  /* SCAM id sel. */#define		ADW_SCSI_CFG0_OUR_ID_EN		0x0010#define		ADW_SCSI_CFG0_OUR_ID		0x000F#define ADW_SCSI_CFG1				0x000E#define		ADW_SCSI_CFG1_BIG_ENDIAN	0x8000#define		ADW_SCSI_CFG1_TERM_POL		0x2000#define		ADW_SCSI_CFG1_SLEW_RATE		0x1000#define		ADW_SCSI_CFG1_FILTER_MASK	0x0C00#define		ADW_SCSI_CFG1_FLTR_DISABLE	0x0000#define		ADW_SCSI_CFG1_FLTR_11_TO_20NS	0x0800#define		ADW_SCSI_CFG1_FLTR_21_TO_39NS	0x0C00#define		ADW_SCSI_CFG1_DIS_ACTIVE_NEG	0x0200#define		ADW_SCSI_CFG1_DIFF_MODE		0x0100#define		ADW_SCSI_CFG1_DIFF_SENSE	0x0080#define		ADW_SCSI_CFG1_TERM_CTL_MANUAL	0x0040  /* Global Term Switch */#define		ADW_SCSI_CFG1_TERM_CTL_MASK	0x0030#define		ADW_SCSI_CFG1_TERM_CTL_H	0x0020  /* Enable SCSI-H */#define		ADW_SCSI_CFG1_TERM_CTL_L	0x0010  /* Enable SCSI-L */#define		ADW_SCSI_CFG1_CABLE_DETECT	0x000F#define		ADW_SCSI_CFG1_EXT16_MASK	0x0008	/* Ext16 cable pres */#define		ADW_SCSI_CFG1_EXT8_MASK		0x0004	/* Ext8 cable pres */#define		ADW_SCSI_CFG1_INT8_MASK		0x0002	/* Int8 cable pres */#define		ADW_SCSI_CFG1_INT16_MASK	0x0001	/* Int16 cable pres */#define		ADW_SCSI_CFG1_ILLEGAL_CABLE_CONF_A_MASK	\(ADW_SCSI_CFG1_EXT16_MASK|ADW_SCSI_CFG1_INT8_MASK|ADW_SCSI_CFG1_INT16_MASK)#define		ADW_SCSI_CFG1_ILLEGAL_CABLE_CONF_B_MASK	\(ADW_SCSI_CFG1_EXT8_MASK|ADW_SCSI_CFG1_INT8_MASK|ADW_SCSI_CFG1_INT16_MASK)#define ADW_MEM_CFG				0x0010#define 	ADW_MEM_CFG_BIOS_EN		0x40#define		ADW_MEM_CFG_FAST_EE_CLK		0x20	/* Diagnostic Bit */#define		ADW_MEM_CFG_RAM_SZ_MASK		0x1C	/* RISC RAM Size */#define		ADW_MEM_CFG_RAM_SZ_2KB		0x00#define		ADW_MEM_CFG_RAM_SZ_4KB		0x04#define		ADW_MEM_CFG_RAM_SZ_8KB		0x08#define		ADW_MEM_CFG_RAM_SZ_16KB		0x0C#define		ADW_MEM_CFG_RAM_SZ_32KB		0x10#define		ADW_MEM_CFG_RAM_SZ_64KB		0x14#define ADW_EEP_CMD				0x001A#define		ADW_EEP_CMD_READ		0x0080	/* or in address */#define		ADW_EEP_CMD_WRITE		0x0040	/* or in address */#define		ADW_EEP_CMD_WRITE_ABLE		0x0030#define		ADW_EEP_CMD_WRITE_DISABLE	0x0000#define		ADW_EEP_CMD_DONE		0x0200#define		ADW_EEP_CMD_DONE_ERR		0x0001#define		ADW_EEP_DELAY_MS                100#define ADW_EEP_DATA				0x001C#define ADW_DMA_CFG0				0x0020#define		ADW_DMA_CFG0_BC_THRESH_ENB	0x80#define		ADW_DMA_CFG0_FIFO_THRESH	0x70#define		ADW_DMA_CFG0_FIFO_THRESH_16B	0x00#define		ADW_DMA_CFG0_FIFO_THRESH_32B	0x20#define		ADW_DMA_CFG0_IFO_THRESH_48B	0x30#define		ADW_DMA_CFG0_IFO_THRESH_64B	0x40#define		ADW_DMA_CFG0_IFO_THRESH_80B	0x50#define		ADW_DMA_CFG0_IFO_THRESH_96B	0x60#define		ADW_DMA_CFG0_IFO_THRESH_112B	0x70#define		ADW_DMA_CFG0_START_CTL_MASK	0x0C#define		ADW_DMA_CFG0_START_CTL_TH	0x00 /* Start on thresh */#define		ADW_DMA_CFG0_START_CTL_IDLE	0x04 /* Start when idle */#define		ADW_DMA_CFG0_START_CTL_TH_IDLE	0x08 /* Either */#define		ADW_DMA_CFG0_START_CTL_EM_FU	0x0C /* Start on full/empty */#define		ADW_DMA_CFG0_READ_CMD_MASK	0x03#define		ADW_DMA_CFG0_READ_CMD_MR	0x00#define		ADW_DMA_CFG0_READ_CMD_MRL	0x02#define		ADW_DMA_CFG0_READ_CMD_MRM	0x03/* Program Counter */#define ADW_PC					0x2A#define ADW_SCSI_CTRL				0x0034#define		ADW_SCSI_CTRL_RSTOUT		0x2000#define	ADW_SCSI_RESET_HOLD_TIME_US		60/* LRAM Constants */#define ADW_CONDOR_MEMSIZE	0x2000 /* 8 KB Internal Memory */#define ADW_MC_BIOSMEM		0x0040 /* BIOS RISC Memory Start */#define ADW_MC_BIOSLEN		0x0050 /* BIOS RISC Memory Length *//* ====================== SCSI Request Structures =========================== */#define ADW_NO_OF_SG_PER_BLOCK	15/* * Although the adapter can deal with S/G lists of indefinite size, * we limit the list to 30 to conserve space as the kernel can only send * us buffers of at most 64KB currently. */#define ADW_SG_BLOCKCNT		2#define ADW_SGSIZE		(ADW_NO_OF_SG_PER_BLOCK * ADW_SG_BLOCKCNT)struct adw_sg_elm {	u_int32_t sg_addr;	u_int32_t sg_count;};/* sg block structure used by the microcode */struct adw_sg_block {   	u_int8_t  reserved1;	u_int8_t  reserved2;	u_int8_t  first_entry_no;  /* starting entry number */	u_int8_t  last_entry_no;   /* last entry number */	u_int32_t sg_busaddr_next; /* link to the next sg block */	struct	  adw_sg_elm sg_list[ADW_NO_OF_SG_PER_BLOCK];};/* Structure representing a single allocation block of adw sg blocks */struct sg_map_node {	bus_dmamap_t		 sg_dmamap;	bus_addr_t		 sg_physaddr;	struct adw_sg_block*	 sg_vaddr;	SLIST_ENTRY(sg_map_node) links;};typedef enum {	QHSTA_NO_ERROR		    = 0x00,	QHSTA_M_SEL_TIMEOUT	    = 0x11,	QHSTA_M_DATA_OVER_RUN	    = 0x12,	QHSTA_M_UNEXPECTED_BUS_FREE = 0x13,	QHSTA_M_QUEUE_ABORTED	    = 0x15,	QHSTA_M_SXFR_SDMA_ERR	    = 0x16, /* SCSI DMA Error */	QHSTA_M_SXFR_SXFR_PERR	    = 0x17, /* SCSI Bus Parity Error */	QHSTA_M_RDMA_PERR	    = 0x18, /* RISC PCI DMA parity error */	QHSTA_M_SXFR_OFF_UFLW	    = 0x19, /* Offset Underflow */	QHSTA_M_SXFR_OFF_OFLW	    = 0x20, /* Offset Overflow */	QHSTA_M_SXFR_WD_TMO	    = 0x21, /* Watchdog Timeout */	QHSTA_M_SXFR_DESELECTED	    = 0x22, /* Deselected */	QHSTA_M_SXFR_XFR_PH_ERR	    = 0x24, /* Transfer Phase Error */	QHSTA_M_SXFR_UNKNOWN_ERROR  = 0x25, /* SXFR_STATUS Unknown Error */	QHSTA_M_WTM_TIMEOUT	    = 0x41,	QHSTA_M_BAD_CMPL_STATUS_IN  = 0x42,	QHSTA_M_NO_AUTO_REQ_SENSE   = 0x43,	QHSTA_M_AUTO_REQ_SENSE_FAIL = 0x44,	QHSTA_M_INVALID_DEVICE	    = 0x45 /* Bad target ID */} host_status_t;typedef enum {	QD_NO_STATUS	   = 0x00, /* Request not completed yet. */	QD_NO_ERROR	   = 0x01,	QD_ABORTED_BY_HOST = 0x02,	QD_WITH_ERROR	   = 0x04} done_status_t;/* * Microcode request structure * * All fields in this structure are used by the microcode so their * size and ordering cannot be changed. */struct adw_scsi_req_q {	u_int8_t  cntl;		  /* Ucode flags and state. */	u_int8_t  sg_entry_cnt;	  /* SG element count. Zero for no SG. */	u_int8_t  target_id;	  /* Device target identifier. */	u_int8_t  target_lun;	  /* Device target logical unit number. */	u_int32_t data_addr;	  /* Data buffer physical address. */	u_int32_t data_cnt;	  /* Data count. Ucode sets to residual. */	u_int32_t sense_addr;	  /* Sense buffer physical address. */	u_int32_t srb_ptr;	  /* Driver request pointer. */	u_int8_t  a_flag;	  /* Adv Library flag field. */	u_int8_t  sense_len;	  /* Auto-sense length. Residual on complete. */	u_int8_t  cdb_len;	  /* SCSI CDB length. */

⌨️ 快捷键说明

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