📄 pas16.c
字号:
/* Now see if it looks like a PAS16 board */ board_rev = inb(io_port + PCB_CONFIG); if (board_rev == 0xff) return 0; tmp = board_rev ^ 0xe0; outb(tmp, io_port + PCB_CONFIG); tmp = inb(io_port + PCB_CONFIG); outb(board_rev, io_port + PCB_CONFIG); if (board_rev != tmp) /* Not a PAS-16 */ return 0; if ((inb(io_port + OPERATION_MODE_1) & 0x03) != 0x03) return 0; /* return if no SCSI interface found */ /* Mediavision has some new model boards that return ID bits * that indicate a SCSI interface, but they're not (LMS). We'll * put in an additional test to try to weed them out. */ outb(0x01, io_port + WAIT_STATE); /* 1 Wait state */ NCR5380_write(MODE_REG, 0x20); /* Is it really SCSI? */ if (NCR5380_read(MODE_REG) != 0x20) /* Write to a reg. */ return 0; /* and try to read */ NCR5380_write(MODE_REG, 0x00); /* it back. */ if (NCR5380_read(MODE_REG) != 0x00) return 0; return 1;}/** * pas16_setup - parse command line * @str: command line block * * LILO command line initialization of the overrides array from * the passed in pas16= options */int __init pas16_setup(char *str, int *ints){ static int commandline_current = 0; int i; int ints[10]; get_options(str, sizeof(ints) / sizeof(int), ints); if (ints[0] != 2) printk(KERN_ERR "pas16_setup : usage pas16=io_port,irq\n"); else if (commandline_current < NO_OVERRIDES) { overrides[commandline_current].io_port = (unsigned short) ints[1]; overrides[commandline_current].irq = ints[2]; for (i = 0; i < NO_BASES; ++i) if (bases[i].io_port == (unsigned short) ints[1]) { bases[i].noauto = 1; break; } ++commandline_current; } return 1;}__setup("pas16=", pas16_setup);/** * pas16_detect - detect and configure a pas16 * @tpnt: template * * Detects and initializes PAS16 controllers that were autoprobed, * overridden on the LILO command line, or specified at compile time. */int __init pas16_detect(Scsi_Host_Template * tpnt){ static int current_override = 0; static unsigned short current_base = 0; struct Scsi_Host *instance; unsigned short io_port; int count; tpnt->proc_name = "pas16"; tpnt->proc_info = &pas16_proc_info; if (pas16_addr != 0) { overrides[0].io_port = pas16_addr; /* * This is how we avoid seeing more than * one host adapter at the same I/O port. * Cribbed shamelessly from pas16_setup(). */ for (count = 0; count < NO_BASES; ++count) if (bases[count].io_port == pas16_addr) { bases[count].noauto = 1; break; } } if (pas16_irq != 0) overrides[0].irq = pas16_irq; for (count = 0; current_override < NO_OVERRIDES; ++current_override) { io_port = 0; if (overrides[current_override].io_port) { io_port = overrides[current_override].io_port; enable_board(current_override, io_port); init_board(io_port, overrides[current_override].irq, 1); } else { for (; !io_port && (current_base < NO_BASES); ++current_base) { if (!bases[current_base].noauto && pas16_hw_detect(current_base)) { io_port = bases[current_base].io_port; init_board(io_port, default_irqs[current_base], 0); } } } if (!io_port) break; instance = scsi_register(tpnt, sizeof(struct NCR5380_hostdata)); if (instance == NULL) break; instance->io_port = io_port; NCR5380_init(instance, 0); if (overrides[current_override].irq != IRQ_AUTO) instance->irq = overrides[current_override].irq; else instance->irq = NCR5380_probe_irq(instance, PAS16_IRQS); if (instance->irq != IRQ_NONE) if (request_irq(instance->irq, do_pas16_intr, SA_INTERRUPT, "pas16", NULL)) { printk(KERN_WARNING "scsi%d : IRQ%d not free, interrupts disabled\n", instance->host_no, instance->irq); instance->irq = IRQ_NONE; } if (instance->irq == IRQ_NONE) { printk(KERN_INFO "scsi%d : interrupts not enabled. for better interactive performance,\n", instance->host_no); printk(KERN_INFO "scsi%d : please jumper the board for a free IRQ.\n", instance->host_no); /* Disable 5380 interrupts, leave drive params the same */ outb(0x4d, io_port + SYS_CONFIG_4); outb((inb(io_port + IO_CONFIG_3) & 0x0f), io_port + IO_CONFIG_3); } printk(KERN_INFO "scsi%d : at 0x%04x", instance->host_no, (int) instance->io_port); if (instance->irq == IRQ_NONE) printk(" interrupts disabled"); else printk(" irq %d", instance->irq); printk(" options CAN_QUEUE=%d CMD_PER_LUN=%d release=%d", CAN_QUEUE, CMD_PER_LUN, PAS16_PUBLIC_RELEASE); NCR5380_print_options(instance); printk("\n"); ++current_override; ++count; } return count;}/** * pas16_biosparam - generate C/H/S data * @disk: Disk to set up * @dev: device ident of disk * @ip: array to return C/H/S mapping * * Generates a BIOS / DOS compatible H-C-S mapping for * the specified device / size. */int pas16_biosparam(Disk * disk, kdev_t dev, int *ip){ int size = disk->capacity; ip[0] = 64; ip[1] = 32; ip[2] = size >> 11; /* I think I have it as /(32*64) */ if (ip[2] > 1024) { /* yes, >, not >= */ ip[0] = 255; ip[1] = 63; ip[2] = size / (63 * 255); if (ip[2] > 1023) /* yes >1023... */ ip[2] = 1023; } return 0;}/** * NCR5380_pread - pseudo DMA read * @instance: board to read from * @dst: destination for data * @len: expected/max block length * * Fast 5380 pseudo-dma read function, transfers len bytes to * dst. Unlike most boards the PAS has IRQs enabled here, which * helps no end. */static inline int NCR5380_pread(struct Scsi_Host *instance, unsigned char *dst, int len){ unsigned char *d = dst; unsigned short reg = (unsigned short) (instance->io_port + P_DATA_REG_OFFSET); int i = len; int ii = 0; while (!(inb(instance->io_port + P_STATUS_REG_OFFSET) & P_ST_RDY)) ++ii; insb(reg, d, i); if (inb(instance->io_port + P_TIMEOUT_STATUS_REG_OFFSET) & P_TS_TIM) { outb(P_TS_CT, instance->io_port + P_TIMEOUT_STATUS_REG_OFFSET); printk(KERN_ERR "scsi%d : watchdog timer fired in NCR5380_pread()\n", instance->host_no); return -1; } if (ii > pas_maxi) pas_maxi = ii; return 0;}/** * NCR5380_pwrite - pseudo DMA write * @instance: board to write to * @src: source for data * @len: expected/max block length * * Fast 5380 pseudo-dma write function, transfers len bytes from * src. Unlike most boards the PAS has IRQs enabled here, which * helps no end. */static inline int NCR5380_pwrite(struct Scsi_Host *instance, unsigned char *src, int len){ unsigned char *s = src; unsigned short reg = (instance->io_port + P_DATA_REG_OFFSET); int i = len; int ii = 0; while (!((inb(instance->io_port + P_STATUS_REG_OFFSET)) & P_ST_RDY)) ++ii; outsb(reg, s, i); if (inb(instance->io_port + P_TIMEOUT_STATUS_REG_OFFSET) & P_TS_TIM) { outb(P_TS_CT, instance->io_port + P_TIMEOUT_STATUS_REG_OFFSET); printk(KERN_ERR "scsi%d : watchdog timer fired in NCR5380_pwrite()\n", instance->host_no); return -1; } if (ii > pas_maxi) pas_wmaxi = ii; return 0;}#include "NCR5380.c"/* Eventually this will go into an include file, but this will be later */static Scsi_Host_Template driver_template = MV_PAS16;#include "scsi_module.c"#ifdef MODULEMODULE_PARM(pas16_addr, "h");MODULE_PARM(pas16_irq, "i");#endifMODULE_LICENSE("GPL");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -