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

📄 qlogicisp.c

📁 GNU Mach 微内核源代码, 基于美国卡内基美隆大学的 Mach 研究项目
💻 C
📖 第 1 页 / 共 4 页
字号:
/* * QLogic ISP1020 Intelligent SCSI Processor Driver (PCI) * Written by Erik H. Moe, ehm@cris.com * Copyright 1995, Erik H. Moe * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2, or (at your option) any * later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU * General Public License for more details. *//* Renamed and updated to 1.3.x by Michael Griffith <grif@cs.ucr.edu> *//* * $Date: 2005/01/22 02:29:18 $ * $Revision: 1.1.4.1 $ * * $Log: qlogicisp.c,v $ * Revision 1.1.4.1  2005/01/22 02:29:18  marcus * 2005-01-22  Guillem Jover  <guillem@hadrons.org> * * 	* linux/src/drivers/scsi/qlogicisp_asm.c: Remove file with binary * 	only firmware. * 	* linux/src/drivers/scsi/qlogicisp.c: Do not include "qlogicisp_asm.c". * 	(RELOAD_FIRMWARE): Set to 0. * 	(risc_code_addr01): New variable from qlogicisp_asm.c. * 	* linux/Files: Remove linux/src/drivers/scsi/qlogicisp_asm.c. * * Revision 1.1  1999/04/26 05:54:52  tb * 1998-11-30  OKUJI Yoshinori  <okuji@kuicr.kyoto-u.ac.jp> * * 	Clean up linux emulation code to make it architecture-independent * 	as much as possible. * * 	* linux: Renamed from linuxdev. * 	* Makefile.in (objfiles): Add linux.o instead of linuxdev.o. * 	(MAKE): New variable. Used for the linux.o target. * 	* configure.in: Add AC_CHECK_TOOL(MAKE, make). * 	* i386/i386/spl.h: Include <i386/ipl.h>, for compatibility with * 	OSF Mach 3.0. Suggested by Elgin Lee <ehl@funghi.com>. * 	* linux/src: Renamed from linux/linux. * 	* linux/dev: Renamed from linux/mach. * 	* linux/Drivers.in (AC_INIT): Use dev/include/linux/autoconf.h, * 	instead of mach/include/linux/autoconf.h. * 	* Makefile.in (all): Target ../linux.o instead of ../linuxdev.o. * 	* linux/dev/drivers/block/genhd.c: Include <machine/spl.h> instead * 	of <i386/ipl.h>. * 	* linux/dev/drivers/net/auto_irq.c: Remove unneeded header files, * 	<i386/ipl.h> and <i386/pic.h>. * 	* linux/dev/init/main.c: Many i386-dependent codes moved to ... * 	* linux/dev/arch/i386/irq.c: ... here. * 	* linux/dev/arch/i386/setup.c: New file. * 	* linux/dev/arch/i386/linux_emul.h: Likewise. * 	* linux/dev/arch/i386/glue/timer.c: Merged into sched.c. * 	* linux/dev/arch/i386/glue/sched.c: Include <machine/spl.h> instead * 	of <i386/ipl.h>, and moved to ... * 	* linux/dev/kernel/sched.c: ... here. * 	* linux/dev/arch/i386/glue/block.c: Include <machine/spl.h> and * 	<linux_emul.h>, instead of i386-dependent header files, and * 	moved to ... * 	* linux/dev/glue/blocl.c: ... here. * 	* linux/dev/arch/i386/glue/net.c: Include <machine/spl.h> and * 	<linux_emul.h>, instead of i386-dependent header files, and * 	moved to ... * 	* linux/dev/glue/net.c: ... here. * 	* linux/dev/arch/i386/glue/misc.c: Remove `x86' and moved to ... * 	* linux/dev/glue/misc.c: ... here. * 	* linux/dev/arch/i386/glue/kmem.c: Moved to ... * 	* linux/dev/glue/kmem.c: ... here. * * Revision 0.5  1995/09/22  02:23:15  root * do auto request sense * * Revision 0.4  1995/08/07  04:44:33  root * supply firmware with driver. * numerous bug fixes/general cleanup of code. * * Revision 0.3  1995/07/16  16:15:39  root * added reset/abort code. * * Revision 0.2  1995/06/29  03:14:19  root * fixed biosparam. * added queue protocol. * * Revision 0.1  1995/06/25  01:55:45  root * Initial release. * */#include <linux/blk.h>#include <linux/kernel.h>#include <linux/string.h>#include <linux/ioport.h>#include <linux/sched.h>#include <linux/types.h>#include <linux/bios32.h>#include <linux/pci.h>#include <linux/delay.h>#include <linux/unistd.h>#include <asm/io.h>#include <asm/irq.h>#include "sd.h"#include "hosts.h"#include "qlogicisp.h"/* Configuration section *****************************************************//* Set the following macro to 1 to reload the ISP1020's firmware.  This is   the latest firmware provided by QLogic.  This may be an earlier/later   revision than supplied by your board. */#define RELOAD_FIRMWARE		0/* Set the following macro to 1 to reload the ISP1020's defaults from nvram.   If you are not sure of your settings, leave this alone, the driver will   use a set of 'safe' defaults */#define USE_NVRAM_DEFAULTS	0/*  Macros used for debugging */#define DEBUG_ISP1020		0#define DEBUG_ISP1020_INT	0#define DEBUG_ISP1020_SETUP	0#define TRACE_ISP		0#define DEFAULT_LOOP_COUNT	1000000/* End Configuration section *************************************************/#include <linux/module.h>#if TRACE_ISP# define TRACE_BUF_LEN	(32*1024)struct {	u_long		next;	struct {		u_long		time;		u_int		index;		u_int		addr;		u_char *	name;	} buf[TRACE_BUF_LEN];} trace;#define TRACE(w, i, a)						\{								\	unsigned long flags;					\								\	save_flags(flags);					\	cli();							\	trace.buf[trace.next].name  = (w);			\	trace.buf[trace.next].time  = jiffies;			\	trace.buf[trace.next].index = (i);			\	trace.buf[trace.next].addr  = (long) (a);		\	trace.next = (trace.next + 1) & (TRACE_BUF_LEN - 1);	\	restore_flags(flags);					\}#else# define TRACE(w, i, a)#endif#if DEBUG_ISP1020#define ENTER(x)	printk("isp1020 : entering %s()\n", x);#define LEAVE(x)	printk("isp1020 : leaving %s()\n", x);#define DEBUG(x)	x#else#define ENTER(x)#define LEAVE(x)#define DEBUG(x)#endif /* DEBUG_ISP1020 */#if DEBUG_ISP1020_INTR#define ENTER_INTR(x)	printk("isp1020 : entering %s()\n", x);#define LEAVE_INTR(x)	printk("isp1020 : leaving %s()\n", x);#define DEBUG_INTR(x)	x#else#define ENTER_INTR(x)#define LEAVE_INTR(x)#define DEBUG_INTR(x)#endif /* DEBUG ISP1020_INTR */#define ISP1020_REV_ID	1#define MAX_TARGETS	16#define MAX_LUNS	8/* host configuration and control registers */#define HOST_HCCR	0xc0	/* host command and control *//* pci bus interface registers */#define PCI_ID_LOW	0x00	/* vendor id */#define PCI_ID_HIGH	0x02	/* device id */#define ISP_CFG0	0x04	/* configuration register #0 */#define ISP_CFG1	0x06	/* configuration register #1 */#define PCI_INTF_CTL	0x08	/* pci interface control */#define PCI_INTF_STS	0x0a	/* pci interface status */#define PCI_SEMAPHORE	0x0c	/* pci semaphore */#define PCI_NVRAM	0x0e	/* pci nvram interface *//* mailbox registers */#define MBOX0		0x70	/* mailbox 0 */#define MBOX1		0x72	/* mailbox 1 */#define MBOX2		0x74	/* mailbox 2 */#define MBOX3		0x76	/* mailbox 3 */#define MBOX4		0x78	/* mailbox 4 */#define MBOX5		0x7a	/* mailbox 5 *//* mailbox command complete status codes */#define MBOX_COMMAND_COMPLETE		0x4000#define INVALID_COMMAND			0x4001#define HOST_INTERFACE_ERROR		0x4002#define TEST_FAILED			0x4003#define COMMAND_ERROR			0x4005#define COMMAND_PARAM_ERROR		0x4006/* async event status codes */#define ASYNC_SCSI_BUS_RESET		0x8001#define SYSTEM_ERROR			0x8002#define REQUEST_TRANSFER_ERROR		0x8003#define RESPONSE_TRANSFER_ERROR		0x8004#define REQUEST_QUEUE_WAKEUP		0x8005#define EXECUTION_TIMEOUT_RESET		0x8006struct Entry_header {	u_char	entry_type;	u_char	entry_cnt;	u_char	sys_def_1;	u_char	flags;};/* entry header type commands */#define ENTRY_COMMAND		1#define ENTRY_CONTINUATION	2#define ENTRY_STATUS		3#define ENTRY_MARKER		4#define ENTRY_EXTENDED_COMMAND	5/* entry header flag definitions */#define EFLAG_CONTINUATION	1#define EFLAG_BUSY		2#define EFLAG_BAD_HEADER	4#define EFLAG_BAD_PAYLOAD	8struct dataseg {	u_int			d_base;	u_int			d_count;};struct Command_Entry {	struct Entry_header	hdr;	u_int			handle;	u_char			target_lun;	u_char			target_id;	u_short			cdb_length;	u_short			control_flags;	u_short			rsvd;	u_short			time_out;	u_short			segment_cnt;	u_char			cdb[12];	struct dataseg		dataseg[4];};/* command entry control flag definitions */#define CFLAG_NODISC		0x01#define CFLAG_HEAD_TAG		0x02#define CFLAG_ORDERED_TAG	0x04#define CFLAG_SIMPLE_TAG	0x08#define CFLAG_TAR_RTN		0x10#define CFLAG_READ		0x20#define CFLAG_WRITE		0x40struct Ext_Command_Entry {	struct Entry_header	hdr;	u_int			handle;	u_char			target_lun;	u_char			target_id;	u_short			cdb_length;	u_short			control_flags;	u_short			rsvd;	u_short			time_out;	u_short			segment_cnt;	u_char			cdb[44];};struct Continuation_Entry {	struct Entry_header	hdr;	u_int			reserved;	struct dataseg		dataseg[7];};struct Marker_Entry {	struct Entry_header	hdr;	u_int			reserved;	u_char			target_lun;	u_char			target_id;	u_char			modifier;	u_char			rsvd;	u_char			rsvds[52];};/* marker entry modifier definitions */#define SYNC_DEVICE	0#define SYNC_TARGET	1#define SYNC_ALL	2struct Status_Entry {	struct Entry_header	hdr;	u_int			handle;	u_short			scsi_status;	u_short			completion_status;	u_short			state_flags;	u_short			status_flags;	u_short			time;	u_short			req_sense_len;	u_int			residual;	u_char			rsvd[8];	u_char			req_sense_data[32];};/* status entry completion status definitions */#define CS_COMPLETE			0x0000#define CS_INCOMPLETE			0x0001#define CS_DMA_ERROR			0x0002#define CS_TRANSPORT_ERROR		0x0003#define CS_RESET_OCCURRED		0x0004#define CS_ABORTED			0x0005#define CS_TIMEOUT			0x0006#define CS_DATA_OVERRUN			0x0007#define CS_COMMAND_OVERRUN		0x0008#define CS_STATUS_OVERRUN		0x0009#define CS_BAD_MESSAGE			0x000a#define CS_NO_MESSAGE_OUT		0x000b#define CS_EXT_ID_FAILED		0x000c#define CS_IDE_MSG_FAILED		0x000d#define CS_ABORT_MSG_FAILED		0x000e#define CS_REJECT_MSG_FAILED		0x000f#define CS_NOP_MSG_FAILED		0x0010#define CS_PARITY_ERROR_MSG_FAILED	0x0011#define CS_DEVICE_RESET_MSG_FAILED	0x0012#define CS_ID_MSG_FAILED		0x0013#define CS_UNEXP_BUS_FREE		0x0014/* as per app note #83120-514-06a: */#define CS_DATA_UNDERRUN		0x0015#define CS_INVALID_ENTRY_TYPE		0x001b#define CS_DEVICE_QUEUE_FULL		0x001c#define CS_SCSI_PHASE_SKIPPED		0x001d#define CS_ARS_FAILED			0x001e	/* auto Req. Sense failed *//* status entry state flag definitions */#define SF_GOT_BUS			0x0100#define SF_GOT_TARGET			0x0200#define SF_SENT_CDB			0x0400#define SF_TRANSFERRED_DATA		0x0800#define SF_GOT_STATUS			0x1000#define SF_GOT_SENSE			0x2000/* status entry status flag definitions */#define STF_DISCONNECT			0x0001#define STF_SYNCHRONOUS			0x0002#define STF_PARITY_ERROR		0x0004#define STF_BUS_RESET			0x0008#define STF_DEVICE_RESET		0x0010#define STF_ABORTED			0x0020#define STF_TIMEOUT			0x0040#define STF_NEGOTIATION			0x0080/* interface control commands */#define ISP_RESET			0x0001#define ISP_EN_INT			0x0002#define ISP_EN_RISC			0x0004/* host control commands */#define HCCR_NOP			0x0000#define HCCR_RESET			0x1000#define HCCR_PAUSE			0x2000#define HCCR_RELEASE			0x3000#define HCCR_SINGLE_STEP		0x4000#define HCCR_SET_HOST_INTR		0x5000#define HCCR_CLEAR_HOST_INTR		0x6000#define HCCR_CLEAR_RISC_INTR		0x7000#define HCCR_BP_ENABLE			0x8000#define HCCR_BIOS_DISABLE		0x9000#define HCCR_TEST_MODE			0xf000#define RISC_BUSY			0x0004/* mailbox commands */#define MBOX_NO_OP			0x0000#define MBOX_LOAD_RAM			0x0001#define MBOX_EXEC_FIRMWARE		0x0002#define MBOX_DUMP_RAM			0x0003#define MBOX_WRITE_RAM_WORD		0x0004#define MBOX_READ_RAM_WORD		0x0005#define MBOX_MAILBOX_REG_TEST		0x0006#define MBOX_VERIFY_CHECKSUM		0x0007#define MBOX_ABOUT_FIRMWARE		0x0008#define MBOX_CHECK_FIRMWARE		0x000e#define MBOX_INIT_REQ_QUEUE		0x0010#define MBOX_INIT_RES_QUEUE		0x0011#define MBOX_EXECUTE_IOCB		0x0012#define MBOX_WAKE_UP			0x0013#define MBOX_STOP_FIRMWARE		0x0014#define MBOX_ABORT			0x0015#define MBOX_ABORT_DEVICE		0x0016#define MBOX_ABORT_TARGET		0x0017#define MBOX_BUS_RESET			0x0018#define MBOX_STOP_QUEUE			0x0019#define MBOX_START_QUEUE		0x001a#define MBOX_SINGLE_STEP_QUEUE		0x001b#define MBOX_ABORT_QUEUE		0x001c#define MBOX_GET_DEV_QUEUE_STATUS	0x001d#define MBOX_GET_FIRMWARE_STATUS	0x001f#define MBOX_GET_INIT_SCSI_ID		0x0020#define MBOX_GET_SELECT_TIMEOUT		0x0021#define MBOX_GET_RETRY_COUNT		0x0022#define MBOX_GET_TAG_AGE_LIMIT		0x0023#define MBOX_GET_CLOCK_RATE		0x0024#define MBOX_GET_ACT_NEG_STATE		0x0025#define MBOX_GET_ASYNC_DATA_SETUP_TIME	0x0026#define MBOX_GET_PCI_PARAMS		0x0027#define MBOX_GET_TARGET_PARAMS		0x0028#define MBOX_GET_DEV_QUEUE_PARAMS	0x0029#define MBOX_SET_INIT_SCSI_ID		0x0030#define MBOX_SET_SELECT_TIMEOUT		0x0031#define MBOX_SET_RETRY_COUNT		0x0032#define MBOX_SET_TAG_AGE_LIMIT		0x0033#define MBOX_SET_CLOCK_RATE		0x0034#define MBOX_SET_ACTIVE_NEG_STATE	0x0035#define MBOX_SET_ASYNC_DATA_SETUP_TIME	0x0036#define MBOX_SET_PCI_CONTROL_PARAMS	0x0037#define MBOX_SET_TARGET_PARAMS		0x0038#define MBOX_SET_DEV_QUEUE_PARAMS	0x0039#define MBOX_RETURN_BIOS_BLOCK_ADDR	0x0040#define MBOX_WRITE_FOUR_RAM_WORDS	0x0041#define MBOX_EXEC_BIOS_IOCB		0x0042unsigned short risc_code_addr01 = 0x1000 ;#define PACKB(a, b)			(((a)<<4)|(b))const u_char mbox_param[] = {	PACKB(1, 1),	/* MBOX_NO_OP */	PACKB(5, 5),	/* MBOX_LOAD_RAM */	PACKB(2, 0),	/* MBOX_EXEC_FIRMWARE */	PACKB(5, 5),	/* MBOX_DUMP_RAM */	PACKB(3, 3),	/* MBOX_WRITE_RAM_WORD */	PACKB(2, 3),	/* MBOX_READ_RAM_WORD */

⌨️ 快捷键说明

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