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

📄 sym_glue.h

📁 内核linux2.4.20,可跟rtlinux3.2打补丁 组成实时linux系统,编译内核
💻 H
📖 第 1 页 / 共 2 页
字号:
/* * 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#if 0#define SYM_CONF_DMA_ADDRESSING_MODE 2#endif#define LinuxVersionCode(v, p, s) (((v)<<16)+((p)<<8)+(s))#include <linux/version.h>#if	LINUX_VERSION_CODE < LinuxVersionCode(2, 2, 0)#error	"This driver requires a kernel version not lower than 2.2.0"#endif#include <asm/dma.h>#include <asm/io.h>#include <asm/system.h>#if LINUX_VERSION_CODE >= LinuxVersionCode(2,3,17)#include <linux/spinlock.h>#else#include <asm/spinlock.h>#endif#include <linux/delay.h>#include <linux/signal.h>#include <linux/sched.h>#include <linux/errno.h>#include <linux/pci.h>#include <linux/string.h>#include <linux/mm.h>#include <linux/ioport.h>#include <linux/time.h>#include <linux/timer.h>#include <linux/stat.h>#include <linux/blk.h>#ifdef __sparc__#  include <asm/irq.h>#endif#include <linux/init.h>#ifndef	__init#define	__init#endif#ifndef	__initdata#define	__initdata#endif#include "../scsi.h"#include "../hosts.h"#include "../constants.h"#include "../sd.h"#include <linux/types.h>/* *  Define BITS_PER_LONG for earlier linux versions. */#ifndef	BITS_PER_LONG#if (~0UL) == 0xffffffffUL#define	BITS_PER_LONG	32#else#define	BITS_PER_LONG	64#endif#endiftypedef	u_long	vm_offset_t;#ifndef bcopy#define bcopy(s, d, n)	memcpy((d), (s), (n))#endif#ifndef bzero#define bzero(d, n)	memset((d), 0, (n))#endif#ifndef bcmp#define bcmp(a, b, n)	memcmp((a), (b), (n))#endif/* *  General driver includes. */#include "sym53c8xx.h"#include "sym_misc.h"#include "sym_conf.h"#include "sym_defs.h"/* * Configuration addendum for Linux. */#if	LINUX_VERSION_CODE >= LinuxVersionCode(2,3,47)#define	SYM_LINUX_DYNAMIC_DMA_MAPPING#endif#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_SNIFF_INQUIRY#define SYM_OPT_LIMIT_COMMAND_REORDERING#define	SYM_OPT_ANNOUNCE_TRANSFER_RATE#ifdef	SYM_LINUX_DYNAMIC_DMA_MAPPING#define	SYM_OPT_BUS_DMA_ABSTRACTION#endif/* *  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. */void sym_udelay(int us);void sym_mdelay(int ms);/* *  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;typedef struct sym_stcb *stcb_p;typedef struct sym_slcb *slcb_p;typedef struct sym_sccb *sccb_p;typedef struct sym_shcb *shcb_p;/* *  Define a reference to the O/S dependant IO request. */typedef Scsi_Cmnd *cam_ccb_p;	/* Generic */typedef 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 */#if defined(__i386__)	/* i386 implements full FLAT memory/MMIO model */#define	inw_raw		inw#define	inl_raw		inl#define	outw_raw	outw#define	outl_raw	outl#define readb_raw(a)	(*(volatile unsigned char *) (a))#define readw_raw(a)	(*(volatile unsigned short *) (a))#define readl_raw(a)	(*(volatile unsigned int *) (a))#define writeb_raw(b,a)	((*(volatile unsigned char *) (a)) = (b))#define writew_raw(b,a)	((*(volatile unsigned short *) (a)) = (b))#define writel_raw(b,a)	((*(volatile unsigned int *) (a)) = (b))#else	/* Other 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#endif#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 adressing, *  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 adressing, *  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))

⌨️ 快捷键说明

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