亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? wd.c

?? 內核是系統的心臟
?? C
字號:
/* wd.c: A WD80x3 ethernet driver for linux. */
/*
	Written 1993 by Donald Becker.
	Copyright 1993 United States Government as represented by the
	Director, National Security Agency.	 This software may be used and
	distributed according to the terms of the GNU Public License,
	incorporated herein by reference.
	
	This is a driver for WD8003 and WD8013 "compatible" ethercards.

	The Author may be reached as becker@super.org or
	C/O Supercomputing Research Ctr., 17100 Science Dr., Bowie MD 20715

	Thanks to Russ Nelson (nelson@crnwyr.com) for loaning me a WD8013.
*/

static char *version =
	"wd.c:v0.99-14 11/21/93 Donald Becker (becker@super.org)\n";

#include <linux/config.h>
#include <linux/kernel.h>
#include <linux/sched.h>
#include <linux/errno.h>
#include <linux/string.h>
#include <asm/io.h>
#include <asm/system.h>

#include "dev.h"
#include "8390.h"

/* Compatibility definitions for earlier kernel versions. */
#ifndef HAVE_PORTRESERVE
#define check_region(ioaddr, size)		0
#define snarf_region(ioaddr, size)		do ; while (0)
#endif

int wd_probe(struct device *dev);
int wdprobe1(int ioaddr, struct device *dev);

static int wd_open(struct device *dev);
static void wd_reset_8390(struct device *dev);
static int wd_block_input(struct device *dev, int count,
						  char *buf, int ring_offset);
static void wd_block_output(struct device *dev, int count,
							const unsigned char *buf, const start_page);
static int wd_close_card(struct device *dev);


#define WD_START_PG		0x00	/* First page of TX buffer */
#define WD03_STOP_PG	0x20	/* Last page +1 of RX ring */
#define WD13_STOP_PG	0x40	/* Last page +1 of RX ring */

#define WD_CMDREG		0		/* Offset to ASIC command register. */
#define	 WD_RESET		0x80	/* Board reset, in WD_CMDREG. */
#define	 WD_MEMENB		0x40	/* Enable the shared memory. */
#define WD_CMDREG5		5		/* Offset to 16-bit-only ASIC register 5. */
#define	 ISA16			0x80	/* Enable 16 bit access from the ISA bus. */
#define	 NIC16			0x40	/* Enable 16 bit access from the 8390. */
#define WD_NIC_OFFSET	16		/* Offset to the 8390 NIC from the base_addr. */

/*	Probe for the WD8003 and WD8013.  These cards have the station
	address PROM at I/O ports <base>+8 to <base>+13, with a checksum
	following. A Soundblaster can have the same checksum as an WDethercard,
	so we have an extra exclusionary check for it.

	The wdprobe1() routine initializes the card and fills the
	station address field. */

int wd_probe(struct device *dev)
{
	int *port, ports[] = {0x300, 0x280, 0x380, 0x240, 0};
	short ioaddr = dev->base_addr;

	if (ioaddr < 0)
		return ENXIO;			/* Don't probe at all. */
	if (ioaddr > 0x100)
		return ! wdprobe1(ioaddr, dev);

	for (port = &ports[0]; *port; port++) {
		if (check_region(*port, 32))
			continue;
		if (inb(*port + 8) != 0xff
			&& inb(*port + 9) != 0xff /* Extra check to avoid soundcard. */
			&& wdprobe1(*port, dev))
			return 0;
	}
	dev->base_addr = ioaddr;
	return ENODEV;
}

int wdprobe1(int ioaddr, struct device *dev)
{
	int i;
	unsigned char *station_addr = dev->dev_addr;
	int checksum = 0;
	int ancient = 0;			/* An old card without config registers. */
	int word16 = 0;				/* 0 = 8 bit, 1 = 16 bit */
	char *model_name;
	
	for (i = 0; i < 8; i++)
		checksum += inb(ioaddr + 8 + i);
	if ((checksum & 0xff) != 0xFF)
		return 0;
	
	printk("%s: WD80x3 at %#3x, ", dev->name, ioaddr);
	for (i = 0; i < 6; i++)
		printk(" %2.2X", station_addr[i] = inb(ioaddr + 8 + i));
	
	/* The following PureData probe code was contributed by
	   Mike Jagdis <jaggy@purplet.demon.co.uk>. Puredata does software
	   configuration differently from others so we have to check for them.
	   This detects an 8 bit, 16 bit or dumb (Toshiba, jumpered) card.
	   */
	if (inb(ioaddr+0) == 'P' && inb(ioaddr+1) == 'D') {
		unsigned char reg5 = inb(ioaddr+5);
		
		switch (inb(ioaddr+2)) {
		case 0x03: word16 = 0; model_name = "PDI8023-8";	break;
		case 0x05: word16 = 0; model_name = "PDUC8023";	break;
		case 0x0a: word16 = 1; model_name = "PDI8023-16"; break;
			/* Either 0x01 (dumb) or they've released a new version. */
		default:	 word16 = 0; model_name = "PDI8023";	break;
		}
		dev->mem_start = ((reg5 & 0x1c) + 0xc0) << 12;
		dev->irq = (reg5 & 0xe0) == 0xe0 ? 10 : (reg5 >> 5) + 1;
	} else {								/* End of PureData probe */
		/* This method of checking for a 16-bit board is borrowed from the
		   we.c driver.  A simpler method is just to look in ASIC reg. 0x03.
		   I'm comparing the two method in alpha test to make certain they
		   return the same result. */
		/* Check for the old 8 bit board - it has register 0/8 aliasing.
		   Do NOT check i>=6 here -- it hangs the old 8003 boards! */
		for (i = 0; i < 6; i++)
			if (inb(ioaddr+i) != inb(ioaddr+8+i))
				break;
		if (i >= 6) {
			ancient = 1;
			model_name = "WD8003-old";
			word16 = 0;
		} else {
			int tmp = inb(ioaddr+1); /* fiddle with 16bit bit */
			outb( tmp ^ 0x01, ioaddr+1 ); /* attempt to clear 16bit bit */
			if (((inb( ioaddr+1) & 0x01) == 0x01) /* A 16 bit card */
				&& (tmp & 0x01) == 0x01	) {				/* In a 16 slot. */
				int asic_reg5 = inb(ioaddr+WD_CMDREG5);
				/* Magic to set ASIC to word-wide mode. */
				outb( NIC16 | (asic_reg5&0x1f), ioaddr+WD_CMDREG5);
				outb(tmp, ioaddr+1);
				model_name = "WD8013";
				word16 = 1;		/* We have a 16bit board here! */
			} else {
				model_name = "WD8003";
				word16 = 0;
			}
			outb(tmp, ioaddr+1);			/* Restore original reg1 value. */
		}
#ifndef final_version
		if ( !ancient && (inb(ioaddr+1) & 0x01) != (word16 & 0x01))
			printk("\nWD80?3: Bus width conflict, %d (probe) != %d (reg report).",
				   word16 ? 16 : 8, (inb(ioaddr+1) & 0x01) ? 16 : 8);
#endif
	}
	
#if defined(WD_SHMEM) && WD_SHMEM > 0x80000
	/* Allow a compile-time override.	 */
	dev->mem_start = WD_SHMEM;
#else
	if (dev->mem_start == 0) {
		/* Sanity and old 8003 check */
		int reg0 = inb(ioaddr);
		if (reg0 == 0xff || reg0 == 0) {
			/* Future plan: this could check a few likely locations first. */
			dev->mem_start = 0xd0000;
			printk(" assigning address %#lx", dev->mem_start);
		} else {
			int high_addr_bits = inb(ioaddr+WD_CMDREG5) & 0x1f;
			/* Some boards don't have the register 5 -- it returns 0xff. */
			if (high_addr_bits == 0x1f || word16 == 0)
				high_addr_bits = 0x01;
			dev->mem_start = ((reg0&0x3f) << 13) + (high_addr_bits << 19);
		}
	}
#endif
	
	/* The 8390 isn't at the base address -- the ASIC regs are there! */
	dev->base_addr = ioaddr+WD_NIC_OFFSET;
	
	if (dev->irq < 2) {
		int irqmap[] = {9,3,5,7,10,11,15,4};
		int reg1 = inb(ioaddr+1);
		int reg4 = inb(ioaddr+4);
		if (ancient || reg1 == 0xff) {	/* Ack!! No way to read the IRQ! */
			short nic_addr = ioaddr+WD_NIC_OFFSET;
			
			/* We have an old-style ethercard that doesn't report its IRQ
			   line.  Do autoirq to find the IRQ line. Note that this IS NOT
			   a reliable way to trigger an interrupt. */
			outb_p(E8390_NODMA + E8390_STOP, nic_addr);
			outb(0x00, nic_addr+EN0_IMR);	/* Disable all intrs. */
			autoirq_setup(0);
			outb_p(0xff, nic_addr + EN0_IMR);	/* Enable all interrupts. */
			outb_p(0x00, nic_addr + EN0_RCNTLO);
			outb_p(0x00, nic_addr + EN0_RCNTHI);
			outb(E8390_RREAD+E8390_START, nic_addr); /* Trigger it... */
			dev->irq = autoirq_report(2);
			outb_p(0x00, nic_addr+EN0_IMR);	/* Mask all intrs. again. */
			
			if (ei_debug > 2)
				printk(" autoirq is %d", dev->irq);
			if (dev->irq < 2)
				dev->irq = word16 ? 10 : 5;
		} else
			dev->irq = irqmap[((reg4 >> 5) & 0x03) + (reg1 & 0x04)];
	} else if (dev->irq == 2)		/* Fixup bogosity: IRQ2 is really IRQ9 */
		dev->irq = 9;
	
	/* Snarf the interrupt now.  There's no point in waiting since we cannot
	   share and the board will usually be enabled. */
	if (irqaction (dev->irq, &ei_sigaction)) {
		printk (" unable to get IRQ %d.\n", dev->irq);
		return 0;
	}
	
	/* OK, were are certain this is going to work.  Setup the device. */
	snarf_region(ioaddr, 32);
	ethdev_init(dev);
	
	ei_status.name = model_name;
	ei_status.word16 = word16;
	ei_status.tx_start_page = WD_START_PG;
	ei_status.rx_start_page = WD_START_PG + TX_PAGES;
	ei_status.stop_page = word16 ? WD13_STOP_PG : WD03_STOP_PG;
	
	/* Don't map in the shared memory until the board is actually opened. */
	dev->rmem_start = dev->mem_start + TX_PAGES*256;
	dev->mem_end = dev->rmem_end
		= dev->mem_start + (ei_status.stop_page - WD_START_PG)*256;
	
	printk(" %s, IRQ %d, shared memory at %#lx-%#lx.\n",
		   model_name, dev->irq, dev->mem_start, dev->mem_end-1);
	if (ei_debug > 0)
		printk(version);
	
	ei_status.reset_8390 = &wd_reset_8390;
	ei_status.block_input = &wd_block_input;
	ei_status.block_output = &wd_block_output;
	dev->open = &wd_open;
	dev->stop = &wd_close_card;
	NS8390_init(dev, 0);
	
	return dev->base_addr;
}

static int
wd_open(struct device *dev)
{
  int ioaddr = dev->base_addr - WD_NIC_OFFSET; /* WD_CMDREG */

  /* Map in the shared memory. Always set register 0 last to remain
	 compatible with very old boards. */
  ei_status.reg0 = ((dev->mem_start>>13) & 0x3f) | WD_MEMENB;
  ei_status.reg5 = ((dev->mem_start>>19) & 0x1f) | NIC16;

  if (ei_status.word16)
	  outb(ei_status.reg5, ioaddr+WD_CMDREG5);
  outb(ei_status.reg0, ioaddr); /* WD_CMDREG */

  return ei_open(dev);
}

static void
wd_reset_8390(struct device *dev)
{
	int wd_cmd_port = dev->base_addr - WD_NIC_OFFSET; /* WD_CMDREG */

	outb(WD_RESET, wd_cmd_port);
	if (ei_debug > 1) printk("resetting the WD80x3 t=%lu...", jiffies);
	ei_status.txing = 0;

	/* Set up the ASIC registers, just in case something changed them. */
	outb((((dev->mem_start>>13) & 0x3f)|WD_MEMENB), wd_cmd_port);
	if (ei_status.word16)
		outb(NIC16 | ((dev->mem_start>>19) & 0x1f), wd_cmd_port+WD_CMDREG5);

	if (ei_debug > 1) printk("reset done\n");
	return;
}

/* Block input and output are easy on shared memory ethercards, and trivial
   on the Western digital card where there is no choice of how to do it.
   The only complications are that the ring buffer wraps, and need to map
   switch between 8- and 16-bit modes. */

static int
wd_block_input(struct device *dev, int count, char *buf, int ring_offset)
{
	int wd_cmdreg = dev->base_addr - WD_NIC_OFFSET; /* WD_CMDREG */
	long xfer_start = dev->mem_start + ring_offset - (WD_START_PG<<8);

	/* We'll always get a 4 byte header read followed by a packet read, so
	   we enable 16 bit mode before the header, and disable after the body. */
	if (count == 4) {
		if (ei_status.word16)
			outb(ISA16 | ei_status.reg5, wd_cmdreg+WD_CMDREG5);
		((int*)buf)[0] = ((int*)xfer_start)[0];
		return 0;
	}

	if (xfer_start + count > dev->rmem_end) {
		/* We must wrap the input move. */
		int semi_count = dev->rmem_end - xfer_start;
		memcpy(buf, (char *)xfer_start, semi_count);
		count -= semi_count;
		memcpy(buf + semi_count, (char *)dev->rmem_start, count);
	} else
		memcpy(buf, (char *)xfer_start, count);

	/* Turn off 16 bit access so that reboot works.	 ISA brain-damage */
	if (ei_status.word16)
		outb(ei_status.reg5, wd_cmdreg+WD_CMDREG5);

	return 0;
}

static void
wd_block_output(struct device *dev, int count, const unsigned char *buf,
				int start_page)
{
	int wd_cmdreg = dev->base_addr - WD_NIC_OFFSET; /* WD_CMDREG */
	long shmem = dev->mem_start + ((start_page - WD_START_PG)<<8);


	if (ei_status.word16) {
		/* Turn on and off 16 bit access so that reboot works. */
		outb(ISA16 | ei_status.reg5, wd_cmdreg+WD_CMDREG5);
		memcpy((char *)shmem, buf, count);
		outb(ei_status.reg5, wd_cmdreg+WD_CMDREG5);
	} else
		memcpy((char *)shmem, buf, count);
}


static int
wd_close_card(struct device *dev)
{
	int wd_cmdreg = dev->base_addr - WD_NIC_OFFSET; /* WD_CMDREG */

	if (ei_debug > 1)
		printk("%s: Shutting down ethercard.\n", dev->name);
	NS8390_init(dev, 0);

	/* Change from 16-bit to 8-bit shared memory so reboot works. */
	outb(ei_status.reg5, wd_cmdreg + WD_CMDREG5 );

	/* And disable the shared memory. */
	outb(ei_status.reg0 & ~WD_MEMENB, wd_cmdreg);

	return 0;
}


/*
 * Local variables:
 *  compile-command: "gcc -D__KERNEL__ -I/usr/src/linux/net/inet -Wall -Wstrict-prototypes -O6 -m486 -c wd.c"
 *  version-control: t
 *  tab-width: 4
 *  kept-new-versions: 5
 * End:
 */

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美日韩一二三区| 国内成人自拍视频| 成人av动漫网站| 亚洲丶国产丶欧美一区二区三区| 在线观看日韩一区| 9i看片成人免费高清| 国产乱子伦一区二区三区国色天香 | 日韩一级片网址| 欧美日韩在线一区二区| 欧美日韩美少妇| 欧美精品一区二区三区四区| 欧美一区二区成人| 精品国产乱码久久久久久老虎 | 亚洲欧美日韩中文播放| 一区二区三区在线观看欧美| 亚洲一区在线免费观看| 午夜精彩视频在线观看不卡| 美腿丝袜亚洲综合| 国产高清在线精品| 欧美午夜一区二区三区| 久久亚洲一区二区三区明星换脸| 91麻豆精品国产91久久久久久久久| 欧美区在线观看| 国产欧美综合在线观看第十页| 国产精品天美传媒| 中文字幕av资源一区| 国产精品网站在线观看| 亚洲午夜久久久久| 99综合电影在线视频| 日韩视频永久免费| 午夜精品久久久久久久| 免费高清在线一区| 一本一道波多野结衣一区二区| 国模娜娜一区二区三区| 色综合咪咪久久| 精品日韩av一区二区| 亚洲免费伊人电影| 国产一区二区在线视频| 欧美亚洲国产一区在线观看网站 | 九九视频精品免费| 国产乱子伦一区二区三区国色天香 | 亚洲一区av在线| 国产伦精品一区二区三区免费| 99久久精品情趣| 久久先锋影音av鲁色资源| 日韩高清不卡在线| 成人黄色av电影| 日韩片之四级片| 日韩av一区二区三区四区| 99精品在线免费| 国产精品国产自产拍在线| 视频在线观看国产精品| 国产成人自拍高清视频在线免费播放| 成人精品免费视频| 久久综合狠狠综合久久综合88| 亚洲成人中文在线| 99在线精品观看| 中文字幕不卡的av| 久久99国产精品久久| 欧美高清精品3d| 捆绑紧缚一区二区三区视频| 91麻豆免费看片| 亚洲免费看黄网站| 色婷婷综合久久久久中文 | 国产色综合一区| 国内成人免费视频| 国产精品麻豆欧美日韩ww| 成人精品视频.| 国产精品灌醉下药二区| 色8久久精品久久久久久蜜| 亚洲综合色区另类av| 欧美一二三四在线| 国产一区二区视频在线播放| 欧美国产一区二区在线观看| www.66久久| 精品一二三四区| 国产精品第13页| 国产精品1区二区.| 亚洲国产综合人成综合网站| 91精品午夜视频| 国产福利一区二区三区视频在线| 日本一区二区不卡视频| 风间由美中文字幕在线看视频国产欧美 | 26uuu亚洲| 在线视频你懂得一区二区三区| 一区二区三区中文字幕电影| 精品少妇一区二区三区免费观看 | 国产成人在线免费| 天天综合色天天综合色h| 国产精品久久久久久久久动漫| 日韩免费性生活视频播放| 成人午夜又粗又硬又大| 成人少妇影院yyyy| 成人免费毛片片v| 国产老肥熟一区二区三区| 狠狠色狠狠色综合日日91app| 亚洲成人免费电影| 亚洲午夜精品17c| 天天影视涩香欲综合网| 中文字幕一区av| 中日韩av电影| 亚洲精品一二三| 亚洲国产你懂的| 亚洲丝袜制服诱惑| 精品国产乱码久久久久久久| 欧美亚洲国产一区二区三区| 欧美精品18+| 99re66热这里只有精品3直播 | 不卡一区中文字幕| 94-欧美-setu| 7777精品伊人久久久大香线蕉| 777亚洲妇女| 国产精品成人网| 国产精品免费av| 婷婷开心久久网| 国产精品99久久久久| 久久激情综合网| 亚洲一区二区免费视频| 亚洲一区二区三区精品在线| 免费一级片91| 国产一区二区三区电影在线观看| 国产乱码精品一品二品| 色婷婷综合久久久中文一区二区| 欧美一卡二卡在线| 国产日韩精品一区二区三区在线| 亚洲欧洲日产国码二区| 午夜av电影一区| 一本大道久久a久久精品综合| 99久久精品免费看国产| 日韩一本二本av| 国产精品高潮呻吟久久| 精品一区二区国语对白| 懂色av一区二区在线播放| 欧美中文一区二区三区| 国产精品视频麻豆| 免费一级片91| 欧美一区二区三区在线| 9191久久久久久久久久久| 亚洲精品少妇30p| 99riav久久精品riav| 国产欧美视频一区二区三区| 国产精品不卡一区| 国产精品香蕉一区二区三区| 日韩精品一区国产麻豆| 亚洲18色成人| 色婷婷综合视频在线观看| 国产精品国产成人国产三级| 97精品久久久久中文字幕| 欧美日韩精品免费观看视频| 亚洲六月丁香色婷婷综合久久| 色婷婷综合久久| 最新热久久免费视频| 国产精品1区二区.| 精品欧美乱码久久久久久 | 国产精品国产三级国产aⅴ中文| 国产精品自拍毛片| 中文字幕一区二区三中文字幕| 色综合天天做天天爱| 午夜精品久久久久久久久久久| 91福利国产精品| 午夜电影一区二区三区| 日本乱码高清不卡字幕| 中文字幕一区在线| 91论坛在线播放| 久久免费国产精品| 国产精品毛片高清在线完整版| 日韩精品一级中文字幕精品视频免费观看 | 奇米影视一区二区三区| 色婷婷久久综合| 亚洲综合一区在线| 欧美zozozo| 色嗨嗨av一区二区三区| 亚洲欧美国产高清| 欧美不卡123| 5858s免费视频成人| 国产综合久久久久影院| 亚洲成av人片观看| 久久网站最新地址| 日本韩国视频一区二区| 国产综合色在线视频区| 天天操天天色综合| 欧美精品一区二区三区四区| 欧美在线观看一区| 99久久久国产精品| 国产中文字幕精品| 亚洲欧美日韩系列| 一区二区三区四区不卡视频| 欧美大度的电影原声| 欧美性大战久久久久久久| 国产成人a级片| 国产成人精品在线看| 国产精品小仙女| 极品少妇xxxx偷拍精品少妇| 蜜桃视频第一区免费观看| 亚洲国产美女搞黄色| 亚洲综合视频网| 免费亚洲电影在线| 国产精华液一区二区三区| 精品一区二区三区久久| 久久99精品国产91久久来源|