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

📄 serverworks.c

📁 Linux环境下java编程的经典书籍
💻 C
📖 第 1 页 / 共 2 页
字号:
/* * linux/drivers/ide/serverworks.c		Version 0.2	17 Oct 2000 * *  Copyright (C) 2000 Cobalt Networks, Inc. <asun@cobalt.com> *  May be copied or modified under the terms of the GNU General Public License * *  interface borrowed from alim15x3.c: *  Copyright (C) 1998-2000 Michel Aubry, Maintainer *  Copyright (C) 1998-2000 Andrzej Krzysztofowicz, Maintainer * *  Copyright (C) 1998-2000 Andre Hedrick <andre@linux-ide.org> * *  IDE support for the ServerWorks OSB4 IDE chipset * * here's the default lspci: * * 00:0f.1 IDE interface: ServerWorks: Unknown device 0211 (prog-if 8a [Master SecP PriP]) *	Control: I/O+ Mem- BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR+ FastB2B- *	Status: Cap- 66Mhz- UDF- FastB2B- ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- *	Latency: 255 *	Region 4: I/O ports at c200 * 00: 66 11 11 02 05 01 00 02 00 8a 01 01 00 ff 80 00 * 10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 * 20: 01 c2 00 00 00 00 00 00 00 00 00 00 00 00 00 00 * 30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 * 40: 99 99 99 99 ff ff ff ff 0c 0c 00 00 00 00 00 00 * 50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 * 60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 * 70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 * 80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 * 90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 * a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 * b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 * c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 * d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 * e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 * f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 * * 00:0f.1 IDE interface: ServerWorks: Unknown device 0212 (rev 92) (prog-if 8a [Master SecP PriP]) *         Subsystem: ServerWorks: Unknown device 0212 *         Control: I/O+ Mem- BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- *         Status: Cap- 66Mhz- UDF- FastB2B- ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- *         Latency: 64, cache line size 08 *         Region 0: I/O ports at 01f0 *         Region 1: I/O ports at 03f4 *         Region 2: I/O ports at 0170 *         Region 3: I/O ports at 0374 *         Region 4: I/O ports at 08b0 *         Region 5: I/O ports at 1000 * * 00:0f.1 IDE interface: ServerWorks: Unknown device 0212 (rev 92) * 00: 66 11 12 02 05 00 00 02 92 8a 01 01 08 40 80 00 * 10: f1 01 00 00 f5 03 00 00 71 01 00 00 75 03 00 00 * 20: b1 08 00 00 01 10 00 00 00 00 00 00 66 11 12 02 * 30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 * 40: 4f 4f 4f 4f 20 ff ff ff f0 50 44 44 00 00 00 00 * 50: 00 00 00 00 07 00 44 02 0f 04 03 00 00 00 00 00 * 60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 * 70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 * 80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 * 90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 * a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 * b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 * c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 * d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 * e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 * f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 * * */#include <linux/config.h>#include <linux/types.h>#include <linux/kernel.h>#include <linux/ioport.h>#include <linux/pci.h>#include <linux/hdreg.h>#include <linux/ide.h>#include <linux/init.h>#include <linux/delay.h>#include <asm/io.h>#include "ide_modes.h"#define SVWKS_DEBUG_DRIVE_INFO		0#define DISPLAY_SVWKS_TIMINGS#if defined(DISPLAY_SVWKS_TIMINGS) && defined(CONFIG_PROC_FS)#include <linux/stat.h>#include <linux/proc_fs.h>static struct pci_dev *bmide_dev;static int svwks_get_info(char *, char **, off_t, int);extern int (*svwks_display_info)(char *, char **, off_t, int); /* ide-proc.c */extern char *ide_media_verbose(ide_drive_t *);static int svwks_get_info (char *buffer, char **addr, off_t offset, int count){	char *p = buffer;	u32 bibma = pci_resource_start(bmide_dev, 4);	u32 reg40, reg44;	u16 reg48, reg56;	u8  c0 = 0, c1 = 0, reg54;	pci_read_config_dword(bmide_dev, 0x40, &reg40);	pci_read_config_dword(bmide_dev, 0x44, &reg44);	pci_read_config_word(bmide_dev, 0x48, &reg48);	pci_read_config_byte(bmide_dev, 0x54, &reg54);	pci_read_config_word(bmide_dev, 0x56, &reg56);        /*         * at that point bibma+0x2 et bibma+0xa are byte registers         * to investigate:         */	c0 = inb_p((unsigned short)bibma + 0x02);	c1 = inb_p((unsigned short)bibma + 0x0a);	switch(bmide_dev->device) {		case PCI_DEVICE_ID_SERVERWORKS_CSB5IDE:			p += sprintf(p, "\n                                ServerWorks CSB5 Chipset.\n");			break;		case PCI_DEVICE_ID_SERVERWORKS_OSB4:			p += sprintf(p, "\n                                ServerWorks OSB4 Chipset.\n");			break;		default:			p += sprintf(p, "\n                                ServerWorks 0x%04x Chipset.\n", bmide_dev->device);			break;	}	p += sprintf(p, "------------------------------- General Status ---------------------------------\n");#if 0	p += sprintf(p, "                                     : %s\n", "str");#endif	p += sprintf(p, "--------------- Primary Channel ---------------- Secondary Channel -------------\n");	p += sprintf(p, "                %sabled                         %sabled\n",			(c0&0x80) ? "dis" : " en",			(c1&0x80) ? "dis" : " en");	p += sprintf(p, "--------------- drive0 --------- drive1 -------- drive0 ---------- drive1 ------\n");	p += sprintf(p, "DMA enabled:    %s              %s             %s               %s\n",			(c0&0x20) ? "yes" : "no ",			(c0&0x40) ? "yes" : "no ",			(c1&0x20) ? "yes" : "no ",			(c1&0x40) ? "yes" : "no " );	p += sprintf(p, "UDMA enabled:   %s              %s             %s               %s\n",			(reg54 & 0x01) ? "yes" : "no ",			(reg54 & 0x02) ? "yes" : "no ",			(reg54 & 0x04) ? "yes" : "no ",			(reg54 & 0x08) ? "yes" : "no " );	p += sprintf(p, "UDMA enabled:   %s                %s               %s                 %s\n",			((reg56&0x0005)==0x0005)?"5":				((reg56&0x0004)==0x0004)?"4":				((reg56&0x0003)==0x0003)?"3":				((reg56&0x0002)==0x0002)?"2":				((reg56&0x0001)==0x0001)?"1":				((reg56&0x000F))?"?":"0",			((reg56&0x0050)==0x0050)?"5":				((reg56&0x0040)==0x0040)?"4":				((reg56&0x0030)==0x0030)?"3":				((reg56&0x0020)==0x0020)?"2":				((reg56&0x0010)==0x0010)?"1":				((reg56&0x00F0))?"?":"0",			((reg56&0x0500)==0x0500)?"5":				((reg56&0x0400)==0x0400)?"4":				((reg56&0x0300)==0x0300)?"3":				((reg56&0x0200)==0x0200)?"2":				((reg56&0x0100)==0x0100)?"1":				((reg56&0x0F00))?"?":"0",			((reg56&0x5000)==0x5000)?"5":				((reg56&0x4000)==0x4000)?"4":				((reg56&0x3000)==0x3000)?"3":				((reg56&0x2000)==0x2000)?"2":				((reg56&0x1000)==0x1000)?"1":				((reg56&0xF000))?"?":"0");	p += sprintf(p, "DMA enabled:    %s                %s               %s                 %s\n",			((reg44&0x00002000)==0x00002000)?"2":				((reg44&0x00002100)==0x00002100)?"1":				((reg44&0x00007700)==0x00007700)?"0":				((reg44&0x0000FF00)==0x0000FF00)?"X":"?",			((reg44&0x00000020)==0x00000020)?"2":				((reg44&0x00000021)==0x00000021)?"1":				((reg44&0x00000077)==0x00000077)?"0":				((reg44&0x000000FF)==0x000000FF)?"X":"?",			((reg44&0x20000000)==0x20000000)?"2":				((reg44&0x21000000)==0x21000000)?"1":				((reg44&0x77000000)==0x77000000)?"0":				((reg44&0xFF000000)==0xFF000000)?"X":"?",			((reg44&0x00200000)==0x00200000)?"2":				((reg44&0x00210000)==0x00210000)?"1":				((reg44&0x00770000)==0x00770000)?"0":				((reg44&0x00FF0000)==0x00FF0000)?"X":"?");#if 0	if (bmide_dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB5IDE)		p += sprintf(p, "PIO  enabled:   %s                %s               %s                 %s\n",	if (bmide_dev->device == PCI_DEVICE_ID_SERVERWORKS_OSB4)#endif		p += sprintf(p, "PIO  enabled:   %s                %s               %s                 %s\n",			((reg40&0x00002000)==0x00002000)?"4":				((reg40&0x00002200)==0x00002200)?"3":				((reg40&0x00003400)==0x00003400)?"2":				((reg40&0x00004700)==0x00004700)?"1":				((reg40&0x00005D00)==0x00005D00)?"0":"?",			((reg40&0x00000020)==0x00000020)?"4":				((reg40&0x00000022)==0x00000022)?"3":				((reg40&0x00000034)==0x00000034)?"2":				((reg40&0x00000047)==0x00000047)?"1":				((reg40&0x0000005D)==0x0000005D)?"0":"?",			((reg40&0x20000000)==0x20000000)?"4":				((reg40&0x22000000)==0x22000000)?"3":				((reg40&0x34000000)==0x34000000)?"2":				((reg40&0x47000000)==0x47000000)?"1":				((reg40&0x5D000000)==0x5D000000)?"0":"?",			((reg40&0x00200000)==0x00200000)?"4":				((reg40&0x00220000)==0x00220000)?"3":				((reg40&0x00340000)==0x00340000)?"2":				((reg40&0x00470000)==0x00470000)?"1":				((reg40&0x005D0000)==0x005D0000)?"0":"?");	return p-buffer;	 /* => must be less than 4k! */}#endif  /* defined(DISPLAY_SVWKS_TIMINGS) && defined(CONFIG_PROC_FS) */static byte svwks_revision = 0;byte svwks_proc = 0;extern char *ide_xfer_verbose (byte xfer_rate);static struct pci_dev *isa_dev;static int svwks_tune_chipset (ide_drive_t *drive, byte speed){	byte udma_modes[]	= { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05 };	byte dma_modes[]	= { 0x77, 0x21, 0x20 };	byte pio_modes[]	= { 0x5d, 0x47, 0x34, 0x22, 0x20 };	ide_hwif_t *hwif	= HWIF(drive);	struct pci_dev *dev	= hwif->pci_dev;	byte unit		= (drive->select.b.unit & 0x01);	byte csb5		= (dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB5IDE) ? 1 : 0;#ifdef CONFIG_BLK_DEV_IDEDMA	unsigned long dma_base	= hwif->dma_base;#endif /* CONFIG_BLK_DEV_IDEDMA */	int err;	byte drive_pci		= 0x00;	byte drive_pci2		= 0x00;	byte drive_pci3		= hwif->channel ? 0x57 : 0x56;	byte ultra_enable	= 0x00;	byte ultra_timing	= 0x00;	byte dma_timing		= 0x00;	byte pio_timing		= 0x00;	unsigned short csb5_pio	= 0x00;	byte pio	= ide_get_best_pio_mode(drive, 255, 5, NULL);        switch (drive->dn) {		case 0: drive_pci = 0x41; drive_pci2 = 0x45; break;		case 1: drive_pci = 0x40; drive_pci2 = 0x44; break;		case 2: drive_pci = 0x43; drive_pci2 = 0x47; break;		case 3: drive_pci = 0x42; drive_pci2 = 0x46; break;		default:			return -1;	}	pci_read_config_byte(dev, drive_pci, &pio_timing);	pci_read_config_byte(dev, drive_pci2, &dma_timing);	pci_read_config_byte(dev, drive_pci3, &ultra_timing);	pci_read_config_word(dev, 0x4A, &csb5_pio);	pci_read_config_byte(dev, 0x54, &ultra_enable);#ifdef DEBUG	printk("%s: UDMA 0x%02x DMAPIO 0x%02x PIO 0x%02x ",		drive->name, ultra_timing, dma_timing, pio_timing);#endif	pio_timing	&= ~0xFF;	dma_timing	&= ~0xFF;	ultra_timing	&= ~(0x0F << (4*unit));	ultra_enable	&= ~(0x01 << drive->dn);	csb5_pio	&= ~(0x0F << (4*drive->dn));	switch(speed) {		case XFER_PIO_4:		case XFER_PIO_3:		case XFER_PIO_2:		case XFER_PIO_1:		case XFER_PIO_0:			pio_timing |= pio_modes[speed - XFER_PIO_0];			csb5_pio   |= ((speed - XFER_PIO_0) << (4*drive->dn));			break;#ifdef CONFIG_BLK_DEV_IDEDMA		case XFER_MW_DMA_2:		case XFER_MW_DMA_1:		case XFER_MW_DMA_0:			pio_timing |= pio_modes[pio];			csb5_pio   |= (pio << (4*drive->dn));			dma_timing |= dma_modes[speed - XFER_MW_DMA_0];			break;

⌨️ 快捷键说明

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