sym_glue.h

来自「Linux Kernel 2.6.9 for OMAP1710」· C头文件 代码 · 共 580 行 · 第 1/2 页

H
580
字号
/* * Device driver for the SYMBIOS/LSILOGIC 53C8XX and 53C1010 family  * of PCI-SCSI IO processors. * * Copyright (C) 1999-2001  Gerard Roudier <groudier@free.fr> * * This driver is derived from the Linux sym53c8xx driver. * Copyright (C) 1998-2000  Gerard Roudier * * The sym53c8xx driver is derived from the ncr53c8xx driver that had been  * a port of the FreeBSD ncr driver to Linux-1.2.13. * * The original ncr driver has been written for 386bsd and FreeBSD by *         Wolfgang Stanglmeier        <wolf@cologne.de> *         Stefan Esser                <se@mi.Uni-Koeln.de> * Copyright (C) 1994  Wolfgang Stanglmeier * * Other major contributions: * * NVRAM detection and reading. * Copyright (C) 1997 Richard Waltham <dormouse@farsrobt.demon.co.uk> * *----------------------------------------------------------------------------- * * 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. * 2. The name of the author may not be used to endorse or promote products *    derived from this software without specific prior written permission. * * Where this Software is combined with software released under the terms of  * the GNU Public License ("GPL") and the terms of the GPL would require the  * combined work to also be released under the terms of the GPL, the terms * and conditions of this License will apply in addition to those of the * GPL with the exception of any terms or conditions of this License that * conflict with, or are expressly prohibited by, the GPL. * * THIS SOFTWARE IS PROVIDED BY THE AUTHORS 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. */#ifndef SYM_GLUE_H#define SYM_GLUE_H#include <linux/config.h>#include <linux/delay.h>#include <linux/ioport.h>#include <linux/pci.h>#include <linux/string.h>#include <linux/timer.h>#include <linux/types.h>#include <asm/io.h>#ifdef __sparc__#  include <asm/irq.h>#endif#include <scsi/scsi.h>#include <scsi/scsi_cmnd.h>#include <scsi/scsi_device.h>#include <scsi/scsi_host.h>#ifndef bzero#define bzero(d, n)	memset((d), 0, (n))#endif/* *  General driver includes. */#include "sym_conf.h"#include "sym_defs.h"#include "sym_misc.h"/* * Configuration addendum for Linux. */#define	SYM_CONF_TIMER_INTERVAL		((HZ+1)/2)#define SYM_OPT_HANDLE_DIR_UNKNOWN#define SYM_OPT_HANDLE_DEVICE_QUEUEING#define SYM_OPT_NVRAM_PRE_READ#define SYM_OPT_LIMIT_COMMAND_REORDERING#define	SYM_OPT_ANNOUNCE_TRANSFER_RATE/* *  Print a message with severity. */#define printf_emerg(args...)	printk(KERN_EMERG args)#define	printf_alert(args...)	printk(KERN_ALERT args)#define	printf_crit(args...)	printk(KERN_CRIT args)#define	printf_err(args...)	printk(KERN_ERR	args)#define	printf_warning(args...)	printk(KERN_WARNING args)#define	printf_notice(args...)	printk(KERN_NOTICE args)#define	printf_info(args...)	printk(KERN_INFO args)#define	printf_debug(args...)	printk(KERN_DEBUG args)#define	printf(args...)		printk(args)/* *  Insert a delay in micro-seconds and milli-seconds. */#define sym_udelay(us)	udelay(us)#define sym_mdelay(ms)	mdelay(ms)/* *  A 'read barrier' flushes any data that have been prefetched  *  by the processor due to out of order execution. Such a barrier  *  must notably be inserted prior to looking at data that have  *  been DMAed, assuming that program does memory READs in proper  *  order and that the device ensured proper ordering of WRITEs. * *  A 'write barrier' prevents any previous WRITEs to pass further  *  WRITEs. Such barriers must be inserted each time another agent  *  relies on ordering of WRITEs. * *  Note that, due to posting of PCI memory writes, we also must  *  insert dummy PCI read transactions when some ordering involving  *  both directions over the PCI does matter. PCI transactions are  *  fully ordered in each direction. */#define MEMORY_READ_BARRIER()	rmb()#define MEMORY_WRITE_BARRIER()	wmb()/* *  Let the compiler know about driver data structure names. */typedef struct sym_tcb *tcb_p;typedef struct sym_lcb *lcb_p;typedef struct sym_ccb *ccb_p;typedef struct sym_hcb *hcb_p;/* *  Define a reference to the O/S dependent IO request. */typedef struct scsi_cmnd *cam_ccb_p;	/* Generic */typedef struct scsi_cmnd *cam_scsiio_p;/* SCSI I/O *//* *  IO functions definition for big/little endian CPU support. *  For now, PCI chips are only supported in little endian addressing mode,  */#ifdef	__BIG_ENDIAN#define	inw_l2b		inw#define	inl_l2b		inl#define	outw_b2l	outw#define	outl_b2l	outl#define	readw_l2b	readw#define	readl_l2b	readl#define	writew_b2l	writew#define	writel_b2l	writel#else	/* little endian */#define	inw_raw		inw#define	inl_raw		inl#define	outw_raw	outw#define	outl_raw	outl#define	readw_raw	readw#define	readl_raw	readl#define	writew_raw	writew#define	writel_raw	writel#endif /* endian */#ifdef	SYM_CONF_CHIP_BIG_ENDIAN#error	"Chips in BIG ENDIAN addressing mode are not (yet) supported"#endif/* *  If the chip uses big endian addressing mode over the  *  PCI, actual io register addresses for byte and word  *  accesses must be changed according to lane routing. *  Btw, sym_offb() and sym_offw() macros only apply to  *  constants and so donnot generate bloated code. */#if	defined(SYM_CONF_CHIP_BIG_ENDIAN)#define sym_offb(o)	(((o)&~3)+((~((o)&3))&3))#define sym_offw(o)	(((o)&~3)+((~((o)&3))&2))#else#define sym_offb(o)	(o)#define sym_offw(o)	(o)#endif/* *  If the CPU and the chip use same endian-ness addressing, *  no byte reordering is needed for script patching. *  Macro cpu_to_scr() is to be used for script patching. *  Macro scr_to_cpu() is to be used for getting a DWORD  *  from the script. */#if	defined(__BIG_ENDIAN) && !defined(SYM_CONF_CHIP_BIG_ENDIAN)#define cpu_to_scr(dw)	cpu_to_le32(dw)#define scr_to_cpu(dw)	le32_to_cpu(dw)#elif	defined(__LITTLE_ENDIAN) && defined(SYM_CONF_CHIP_BIG_ENDIAN)#define cpu_to_scr(dw)	cpu_to_be32(dw)#define scr_to_cpu(dw)	be32_to_cpu(dw)#else#define cpu_to_scr(dw)	(dw)#define scr_to_cpu(dw)	(dw)#endif/* *  Access to the controller chip. * *  If SYM_CONF_IOMAPPED is defined, the driver will use  *  normal IOs instead of the MEMORY MAPPED IO method   *  recommended by PCI specifications. *  If all PCI bridges, host brigdes and architectures  *  would have been correctly designed for PCI, this  *  option would be useless. * *  If the CPU and the chip use same endian-ness addressing, *  no byte reordering is needed for accessing chip io  *  registers. Functions suffixed by '_raw' are assumed  *  to access the chip over the PCI without doing byte  *  reordering. Functions suffixed by '_l2b' are  *  assumed to perform little-endian to big-endian byte  *  reordering, those suffixed by '_b2l' blah, blah, *  blah, ... */#if defined(SYM_CONF_IOMAPPED)/* *  IO mapped only input / ouput */#define	INB_OFF(o)        inb (np->s.io_port + sym_offb(o))#define	OUTB_OFF(o, val)  outb ((val), np->s.io_port + sym_offb(o))#if	defined(__BIG_ENDIAN) && !defined(SYM_CONF_CHIP_BIG_ENDIAN)#define	INW_OFF(o)        inw_l2b (np->s.io_port + sym_offw(o))#define	INL_OFF(o)        inl_l2b (np->s.io_port + (o))#define	OUTW_OFF(o, val)  outw_b2l ((val), np->s.io_port + sym_offw(o))#define	OUTL_OFF(o, val)  outl_b2l ((val), np->s.io_port + (o))#elif	defined(__LITTLE_ENDIAN) && defined(SYM_CONF_CHIP_BIG_ENDIAN)#define	INW_OFF(o)        inw_b2l (np->s.io_port + sym_offw(o))#define	INL_OFF(o)        inl_b2l (np->s.io_port + (o))#define	OUTW_OFF(o, val)  outw_l2b ((val), np->s.io_port + sym_offw(o))#define	OUTL_OFF(o, val)  outl_l2b ((val), np->s.io_port + (o))#else#define	INW_OFF(o)        inw_raw (np->s.io_port + sym_offw(o))#define	INL_OFF(o)        inl_raw (np->s.io_port + (o))#define	OUTW_OFF(o, val)  outw_raw ((val), np->s.io_port + sym_offw(o))#define	OUTL_OFF(o, val)  outl_raw ((val), np->s.io_port + (o))#endif	/* ENDIANs */#else	/* defined SYM_CONF_IOMAPPED *//* *  MEMORY mapped IO input / output */

⌨️ 快捷键说明

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