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

📄 aic79xx_osm.h

📁 这个linux源代码是很全面的~基本完整了~使用c编译的~由于时间问题我没有亲自测试~但就算用来做参考资料也是非常好的
💻 H
📖 第 1 页 / 共 3 页
字号:
/* * Adaptec AIC79xx device driver for Linux. * * Copyright (c) 2000-2001 Adaptec Inc. * 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. * 2. Redistributions in binary form must reproduce at minimum a disclaimer *    substantially similar to the "NO WARRANTY" disclaimer below *    ("Disclaimer") and any redistribution must be conditioned upon *    including a substantially similar Disclaimer requirement for further *    binary redistribution. * 3. Neither the names of the above-listed copyright holders nor the names *    of any contributors may be used to endorse or promote products derived *    from this software without specific prior written permission. * * Alternatively, this software may be distributed under the terms of the * GNU General Public License ("GPL") version 2 as published by the Free * Software Foundation. * * NO WARRANTY * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDERS OR CONTRIBUTORS BE LIABLE FOR 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 DAMAGES. * * $Id: //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_osm.h#35 $ * */#ifndef _AIC79XX_LINUX_H_#define _AIC79XX_LINUX_H_#include <linux/types.h>#include <linux/blk.h>#include <linux/blkdev.h>#include <linux/delay.h>#include <linux/ioport.h>#include <linux/pci.h>#include <linux/version.h>#ifndef AHD_MODVERSION_FILE#define __NO_VERSION__#endif#include <linux/module.h>#include <asm/byteorder.h>#ifndef KERNEL_VERSION#define KERNEL_VERSION(x,y,z) (((x)<<16)+((y)<<8)+(z))#endif#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)#include <linux/interrupt.h> /* For tasklet support. */#include <linux/config.h>#include <linux/slab.h>#else#include <linux/malloc.h>#endif/* Core SCSI definitions */#include "../scsi.h"#include "../hosts.h"/* Name space conflict with BSD queue macros */#ifdef LIST_HEAD#undef LIST_HEAD#endif#include "cam.h"#include "queue.h"#include "scsi_message.h"#include "scsi_iu.h"/*********************************** Debugging ********************************/#ifdef CONFIG_AIC79XX_DEBUG_ENABLE#ifdef CONFIG_AIC79XX_DEBUG_MASK#define AHD_DEBUG CONFIG_AIC79XX_DEBUG_MASK#else/* * Compile in debugging code, but do not enable any printfs. */#define AHD_DEBUG 0#endif#endif/********************************** Misc Macros *******************************/#define	roundup(x, y)   ((((x)+((y)-1))/(y))*(y))#define	powerof2(x)	((((x)-1)&(x))==0)/************************* Forward Declarations *******************************/struct ahd_softc;typedef struct pci_dev *ahd_dev_softc_t;typedef Scsi_Cmnd      *ahd_io_ctx_t;/******************************* Byte Order ***********************************/#define ahd_htobe16(x)	cpu_to_be16(x)#define ahd_htobe32(x)	cpu_to_be32(x)#define ahd_htobe64(x)	cpu_to_be64(x)#define ahd_htole16(x)	cpu_to_le16(x)#define ahd_htole32(x)	cpu_to_le32(x)#define ahd_htole64(x)	cpu_to_le64(x)#define ahd_be16toh(x)	be16_to_cpu(x)#define ahd_be32toh(x)	be32_to_cpu(x)#define ahd_be64toh(x)	be64_to_cpu(x)#define ahd_le16toh(x)	le16_to_cpu(x)#define ahd_le32toh(x)	le32_to_cpu(x)#define ahd_le64toh(x)	le64_to_cpu(x)#ifndef LITTLE_ENDIAN#define LITTLE_ENDIAN 1234#endif#ifndef BIG_ENDIAN#define BIG_ENDIAN 4321#endif#ifndef BYTE_ORDER#if defined(__BIG_ENDIAN)#define BYTE_ORDER BIG_ENDIAN#endif#if defined(__LITTLE_ENDIAN)#define BYTE_ORDER LITTLE_ENDIAN#endif#endif /* BYTE_ORDER *//************************* Configuration Data *********************************/extern int aic79xx_detect_complete;extern Scsi_Host_Template* aic79xx_driver_template;/***************************** Bus Space/DMA **********************************/#if LINUX_VERSION_CODE > KERNEL_VERSION(2,2,17)typedef dma_addr_t bus_addr_t;#elsetypedef uint32_t bus_addr_t;#endiftypedef uint32_t bus_size_t;typedef enum {	BUS_SPACE_MEMIO,	BUS_SPACE_PIO} bus_space_tag_t;typedef union {	u_long		  ioport;	volatile uint8_t *maddr;} bus_space_handle_t;typedef struct bus_dma_segment{	bus_addr_t	ds_addr;	bus_size_t	ds_len;} bus_dma_segment_t;struct ahd_linux_dma_tag{	bus_size_t	alignment;	bus_size_t	boundary;	bus_size_t	maxsize;};typedef struct ahd_linux_dma_tag* bus_dma_tag_t;struct ahd_linux_dmamap{	bus_addr_t	bus_addr;};typedef struct ahd_linux_dmamap* bus_dmamap_t;typedef int bus_dma_filter_t(void*, bus_addr_t);typedef void bus_dmamap_callback_t(void *, bus_dma_segment_t *, int, int);#define BUS_DMA_WAITOK		0x0#define BUS_DMA_NOWAIT		0x1#define BUS_DMA_ALLOCNOW	0x2#define BUS_DMA_LOAD_SEGS	0x4	/*					 * Argument is an S/G list not					 * a single buffer.					 */#define BUS_SPACE_MAXADDR	0xFFFFFFFF#define BUS_SPACE_MAXADDR_32BIT	0xFFFFFFFF#define BUS_SPACE_MAXSIZE_32BIT	0xFFFFFFFFint	ahd_dma_tag_create(struct ahd_softc *, bus_dma_tag_t /*parent*/,			   bus_size_t /*alignment*/, bus_size_t /*boundary*/,			   bus_addr_t /*lowaddr*/, bus_addr_t /*highaddr*/,			   bus_dma_filter_t*/*filter*/, void */*filterarg*/,			   bus_size_t /*maxsize*/, int /*nsegments*/,			   bus_size_t /*maxsegsz*/, int /*flags*/,			   bus_dma_tag_t */*dma_tagp*/);void	ahd_dma_tag_destroy(struct ahd_softc *, bus_dma_tag_t /*tag*/);int	ahd_dmamem_alloc(struct ahd_softc *, bus_dma_tag_t /*dmat*/,			 void** /*vaddr*/, int /*flags*/,			 bus_dmamap_t* /*mapp*/);void	ahd_dmamem_free(struct ahd_softc *, bus_dma_tag_t /*dmat*/,			void* /*vaddr*/, bus_dmamap_t /*map*/);void	ahd_dmamap_destroy(struct ahd_softc *, bus_dma_tag_t /*tag*/,			   bus_dmamap_t /*map*/);int	ahd_dmamap_load(struct ahd_softc *ahd, bus_dma_tag_t /*dmat*/,			bus_dmamap_t /*map*/, void * /*buf*/,			bus_size_t /*buflen*/, bus_dmamap_callback_t *,			void */*callback_arg*/, int /*flags*/);int	ahd_dmamap_unload(struct ahd_softc *, bus_dma_tag_t, bus_dmamap_t);/* * Operations performed by ahd_dmamap_sync(). */#define BUS_DMASYNC_PREREAD	0x01	/* pre-read synchronization */#define BUS_DMASYNC_POSTREAD	0x02	/* post-read synchronization */#define BUS_DMASYNC_PREWRITE	0x04	/* pre-write synchronization */#define BUS_DMASYNC_POSTWRITE	0x08	/* post-write synchronization *//* * XXX * ahd_dmamap_sync is only used on buffers allocated with * the pci_alloc_consistent() API.  Although I'm not sure how * this works on architectures with a write buffer, Linux does * not have an API to sync "coherent" memory.  Perhaps we need * to do an mb()? */#define ahd_dmamap_sync(ahd, dma_tag, dmamap, offset, len, op)/************************** SCSI Constants/Structures *************************/#define SCSI_REV_2 2#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#define SCSI_STATUS_QUEUE_FULL		0x28/* * 6 byte request sense CDB format. */struct scsi_sense{	uint8_t opcode;	uint8_t byte2;	uint8_t unused[2];	uint8_t length;	uint8_t control;};struct scsi_sense_data{	uint8_t	error_code;	uint8_t	segment;	uint8_t	flags;	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];	uint8_t	extra_bytes[14];};struct scsi_inquiry{ 	u_int8_t opcode;	u_int8_t byte2;#define	SI_EVPD 0x01	u_int8_t page_code;	u_int8_t reserved;	u_int8_t length;	u_int8_t control;};struct 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	u_int8_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];};static __inline uint32_t scsi_4btoul(uint8_t *bytes);static __inline uint32_tscsi_4btoul(uint8_t *bytes){	return ((bytes[0] << 24)|(bytes[1] << 16)|(bytes[2] << 8)|bytes[3]);}/************************** Timer DataStructures ******************************/typedef struct timer_list ahd_timer_t;/********************************** Includes **********************************//* Host template and function declarations referenced by the template. */#include "aic79xx_host.h"/* Core driver definitions */#include "aic79xx.h"/***************************** Timer Facilities *******************************/#define ahd_timer_init init_timer#define ahd_timer_stop del_timertypedef void ahd_linux_callback_t (u_long);  static __inline voidahd_timer_reset(ahd_timer_t *timer, int usec, ahd_callback_t *func, void *arg){	struct ahd_softc *ahd;	ahd = (struct ahd_softc *)arg;	del_timer(timer);	timer->data = (u_long)arg;	timer->expires = jiffies + (usec * HZ)/1000000;	timer->function = (ahd_linux_callback_t*)func;	add_timer(timer);

⌨️ 快捷键说明

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