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

📄 eesox.c

📁 内核linux2.4.20,可跟rtlinux3.2打补丁 组成实时linux系统,编译内核
💻 C
📖 第 1 页 / 共 2 页
字号:
/* *  linux/drivers/acorn/scsi/eesox.c * *  Copyright (C) 1997-2000 Russell King * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * *  This driver is based on experimentation.  Hence, it may have made *  assumptions about the particular card that I have available, and *  may not be reliable! * *  Changelog: *   01-10-1997	RMK		Created, READONLY version *   15-02-1998	RMK		READ/WRITE version *				added DMA support and hardware definitions *   14-03-1998	RMK		Updated DMA support *				Added terminator control *   15-04-1998	RMK		Only do PIO if FAS216 will allow it. *   27-06-1998	RMK		Changed asm/delay.h to linux/delay.h *   02-04-2000	RMK	0.0.3	Fixed NO_IRQ/NO_DMA problem, updated for new *				error handling code. */#include <linux/module.h>#include <linux/blk.h>#include <linux/kernel.h>#include <linux/string.h>#include <linux/ioport.h>#include <linux/sched.h>#include <linux/proc_fs.h>#include <linux/unistd.h>#include <linux/stat.h>#include <linux/delay.h>#include <linux/pci.h>#include <linux/init.h>#include <asm/io.h>#include <asm/irq.h>#include <asm/dma.h>#include <asm/ecard.h>#include <asm/pgtable.h>#include "../../scsi/sd.h"#include "../../scsi/hosts.h"#include "fas216.h"#include <scsi/scsicam.h>/* Configuration */#define EESOX_XTALFREQ		40#define EESOX_ASYNC_PERIOD	200#define EESOX_SYNC_DEPTH	7/* * List of devices that the driver will recognise */#define EESOXSCSI_LIST	{ MANU_EESOX, PROD_EESOX_SCSI2 }#define EESOX_FAS216_OFFSET	0xc00#define EESOX_FAS216_SHIFT	3#define EESOX_STATUS		0xa00#define EESOX_STAT_INTR		0x01#define EESOX_STAT_DMA		0x02#define EESOX_CONTROL		0xa00#define EESOX_INTR_ENABLE	0x04#define EESOX_TERM_ENABLE	0x02#define EESOX_RESET		0x01#define EESOX_DMA_OFFSET	0xe00/* * Version */#define VER_MAJOR	0#define VER_MINOR	0#define VER_PATCH	3static struct expansion_card *ecs[MAX_ECARDS];/* * Use term=0,1,0,0,0 to turn terminators on/off */static int term[MAX_ECARDS] = { 1, 1, 1, 1, 1, 1, 1, 1 };#define NR_SG	256struct control {	unsigned int	io_port;	unsigned int	control;};typedef struct {	FAS216_Info info;	struct control control;	unsigned int	dmaarea;	/* Pseudo DMA area	*/	struct scatterlist sg[NR_SG];	/* Scatter DMA list	*/} EESOXScsi_Info;/* Prototype: void eesoxscsi_irqenable(ec, irqnr) * Purpose  : Enable interrupts on EESOX SCSI card * Params   : ec    - expansion card structure *          : irqnr - interrupt number */static voideesoxscsi_irqenable(struct expansion_card *ec, int irqnr){	struct control *control = (struct control *)ec->irq_data;	control->control |= EESOX_INTR_ENABLE;	outb(control->control, control->io_port);}/* Prototype: void eesoxscsi_irqdisable(ec, irqnr) * Purpose  : Disable interrupts on EESOX SCSI card * Params   : ec    - expansion card structure *          : irqnr - interrupt number */static voideesoxscsi_irqdisable(struct expansion_card *ec, int irqnr){	struct control *control = (struct control *)ec->irq_data;	control->control &= ~EESOX_INTR_ENABLE;	outb(control->control, control->io_port);}static const expansioncard_ops_t eesoxscsi_ops = {	eesoxscsi_irqenable,	eesoxscsi_irqdisable,	NULL,	NULL,	NULL,	NULL};/* Prototype: void eesoxscsi_terminator_ctl(*host, on_off) * Purpose  : Turn the EESOX SCSI terminators on or off * Params   : host   - card to turn on/off *          : on_off - !0 to turn on, 0 to turn off */static voideesoxscsi_terminator_ctl(struct Scsi_Host *host, int on_off){	EESOXScsi_Info *info = (EESOXScsi_Info *)host->hostdata;	unsigned long flags;	save_flags_cli(flags);	if (on_off)		info->control.control |= EESOX_TERM_ENABLE;	else		info->control.control &= ~EESOX_TERM_ENABLE;	restore_flags(flags);	outb(info->control.control, info->control.io_port);}/* Prototype: void eesoxscsi_intr(irq, *dev_id, *regs) * Purpose  : handle interrupts from EESOX SCSI card * Params   : irq    - interrupt number *	      dev_id - user-defined (Scsi_Host structure) *	      regs   - processor registers at interrupt */static voideesoxscsi_intr(int irq, void *dev_id, struct pt_regs *regs){	struct Scsi_Host *host = (struct Scsi_Host *)dev_id;	fas216_intr(host);}/* Prototype: fasdmatype_t eesoxscsi_dma_setup(host, SCpnt, direction, min_type) * Purpose  : initialises DMA/PIO * Params   : host      - host *	      SCpnt     - command *	      direction - DMA on to/off of card *	      min_type  - minimum DMA support that we must have for this transfer * Returns  : type of transfer to be performed */static fasdmatype_teesoxscsi_dma_setup(struct Scsi_Host *host, Scsi_Pointer *SCp,		       fasdmadir_t direction, fasdmatype_t min_type){	EESOXScsi_Info *info = (EESOXScsi_Info *)host->hostdata;	int dmach = host->dma_channel;	if (dmach != NO_DMA &&	    (min_type == fasdma_real_all || SCp->this_residual >= 512)) {		int bufs = SCp->buffers_residual;		int pci_dir, dma_dir;		if (bufs)			memcpy(info->sg + 1, SCp->buffer + 1,				sizeof(struct scatterlist) * bufs);		info->sg[0].address = SCp->ptr;		info->sg[0].page    = NULL;		info->sg[0].length  = SCp->this_residual;		if (direction == DMA_OUT)			pci_dir = PCI_DMA_TODEVICE,			dma_dir = DMA_MODE_WRITE;		else			pci_dir = PCI_DMA_FROMDEVICE,			dma_dir = DMA_MODE_READ;		pci_map_sg(NULL, info->sg, bufs + 1, pci_dir);		disable_dma(dmach);		set_dma_sg(dmach, info->sg, bufs + 1);		set_dma_mode(dmach, dma_dir);		enable_dma(dmach);		return fasdma_real_all;	}	/*	 * We don't do DMA, we only do slow PIO	 *	 * Some day, we will do Pseudo DMA	 */	return fasdma_pseudo;}static voideesoxscsi_dma_pseudo(struct Scsi_Host *host, Scsi_Pointer *SCp,		     fasdmadir_t dir, int transfer_size){	EESOXScsi_Info *info = (EESOXScsi_Info *)host->hostdata;	unsigned int status;	unsigned int length = SCp->this_residual;	union {		unsigned char *c;		unsigned short *s;		unsigned long *l;	} buffer;	buffer.c = SCp->ptr;	status = inb(host->io_port + EESOX_STATUS);	if (dir == DMA_IN) {		while (length > 8) {			if (status & EESOX_STAT_DMA) {				unsigned long l1, l2;				l1 = inw(info->dmaarea);				l1 |= inw(info->dmaarea) << 16;				l2 = inw(info->dmaarea);				l2 |= inw(info->dmaarea) << 16;				*buffer.l++ = l1;				*buffer.l++ = l2;				length -= 8;			} else if (status & EESOX_STAT_INTR)				goto end;			status = inb(host->io_port + EESOX_STATUS);		}		while (length > 1) {			if (status & EESOX_STAT_DMA) {				*buffer.s++ = inw(info->dmaarea);				length -= 2;			} else if (status & EESOX_STAT_INTR)				goto end;			status = inb(host->io_port + EESOX_STATUS);		}		while (length > 0) {			if (status & EESOX_STAT_DMA) {				*buffer.c++ = inw(info->dmaarea);				length -= 1;			} else if (status & EESOX_STAT_INTR)				goto end;			status = inb(host->io_port + EESOX_STATUS);		}	} else {		while (length > 8) {			if (status & EESOX_STAT_DMA) {				unsigned long l1, l2;				l1 = *buffer.l++;				l2 = *buffer.l++;				outw(l1, info->dmaarea);				outw(l1 >> 16, info->dmaarea);				outw(l2, info->dmaarea);				outw(l2 >> 16, info->dmaarea);				length -= 8;			} else if (status & EESOX_STAT_INTR)				goto end;			status = inb(host->io_port + EESOX_STATUS);		}		while (length > 1) {			if (status & EESOX_STAT_DMA) {				outw(*buffer.s++, info->dmaarea);				length -= 2;			} else if (status & EESOX_STAT_INTR)				goto end;			status = inb(host->io_port + EESOX_STATUS);		}

⌨️ 快捷键说明

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