📄 gdth.c
字号:
ha->ic_all_size = sizeof(dp2_ptr->u); ha->stype= GDT2_ID; ha->brd_phys = bios_adr >> 4; /* special request to controller BIOS */ writel(0x00, &dp2_ptr->u.ic.S_Info[0]); writel(0x00, &dp2_ptr->u.ic.S_Info[1]); writel(0x01, &dp2_ptr->u.ic.S_Info[2]); writel(0x00, &dp2_ptr->u.ic.S_Info[3]); writeb(0xfe, &dp2_ptr->u.ic.S_Cmd_Indx); writeb(0, &dp2_ptr->io.event); retries = INIT_RETRIES; gdth_delay(20); while (readb(&dp2_ptr->u.ic.S_Status) != 0xfe) { if (--retries == 0) { printk("GDT-ISA: Initialization error\n"); gdth_munmap(ha->brd); return 0; } gdth_delay(1); } writeb(0, &dp2_ptr->u.ic.Status); writeb(0xff, &dp2_ptr->io.irqdel); return 1;}__initfunc (static int gdth_init_pci(gdth_pci_str *pcistr,gdth_ha_str *ha)){ register gdt6_dpram_str *dp6_ptr; register gdt6c_dpram_str *dp6c_ptr; register gdt6m_dpram_str *dp6m_ptr; ulong retries; unchar prot_ver; int i, found = FALSE; TRACE(("gdth_init_pci()\n")); ha->brd_phys = (pcistr->bus << 8) | (pcistr->device_fn & 0xf8); ha->stype = (ulong)pcistr->device_id; ha->irq = pcistr->irq; if (ha->stype <= PCI_DEVICE_ID_VORTEX_GDT6000B) { /* GDT6000 or GDT6000B */ TRACE2(("init_pci() dpmem %lx irq %d\n",pcistr->dpmem,ha->irq)); ha->brd = gdth_mmap(pcistr->dpmem, sizeof(gdt6_dpram_str)); if (ha->brd == NULL) { printk("GDT-PCI: Initialization error (DPMEM remap error)\n"); return 0; } dp6_ptr = (gdt6_dpram_str *)ha->brd; /* reset interface area */ memset_io((char *)&dp6_ptr->u,0,sizeof(dp6_ptr->u)); if (readl(&dp6_ptr->u) != 0) { printk("GDT-PCI: Initialization error (DPMEM write error)\n"); gdth_munmap(ha->brd); return 0; } /* disable board interrupts, deinit services */ writeb(0xff, &dp6_ptr->io.irqdel); writeb(0x00, &dp6_ptr->io.irqen);; writeb(0x00, &dp6_ptr->u.ic.S_Status); writeb(0x00, &dp6_ptr->u.ic.Cmd_Index); writel(pcistr->dpmem, &dp6_ptr->u.ic.S_Info[0]); writeb(0xff, &dp6_ptr->u.ic.S_Cmd_Indx); writeb(0, &dp6_ptr->io.event); retries = INIT_RETRIES; gdth_delay(20); while (readb(&dp6_ptr->u.ic.S_Status) != 0xff) { if (--retries == 0) { printk("GDT-PCI: Initialization error (DEINIT failed)\n"); gdth_munmap(ha->brd); return 0; } gdth_delay(1); } prot_ver = (unchar)readl(&dp6_ptr->u.ic.S_Info[0]); writeb(0, &dp6_ptr->u.ic.S_Status); writeb(0xff, &dp6_ptr->io.irqdel); if (prot_ver != PROTOCOL_VERSION) { printk("GDT-PCI: Illegal protocol version\n"); gdth_munmap(ha->brd); return 0; } ha->type = GDT_PCI; ha->ic_all_size = sizeof(dp6_ptr->u); /* special command to controller BIOS */ writel(0x00, &dp6_ptr->u.ic.S_Info[0]); writel(0x00, &dp6_ptr->u.ic.S_Info[1]); writel(0x01, &dp6_ptr->u.ic.S_Info[2]); writel(0x00, &dp6_ptr->u.ic.S_Info[3]); writeb(0xfe, &dp6_ptr->u.ic.S_Cmd_Indx); writeb(0, &dp6_ptr->io.event); retries = INIT_RETRIES; gdth_delay(20); while (readb(&dp6_ptr->u.ic.S_Status) != 0xfe) { if (--retries == 0) { printk("GDT-PCI: Initialization error\n"); gdth_munmap(ha->brd); return 0; } gdth_delay(1); } writeb(0, &dp6_ptr->u.ic.S_Status); writeb(0xff, &dp6_ptr->io.irqdel); } else if (ha->stype <= PCI_DEVICE_ID_VORTEX_GDT6555) { /* GDT6110, GDT6120, .. */ ha->plx = (gdt6c_plx_regs *)pcistr->io; TRACE2(("init_pci_new() dpmem %lx io %lx irq %d\n", pcistr->dpmem,(ulong)ha->plx,ha->irq)); ha->brd = gdth_mmap(pcistr->dpmem, sizeof(gdt6c_dpram_str)); if (ha->brd == NULL) { printk("GDT-PCI: Initialization error (DPMEM remap error)\n"); gdth_munmap(ha->brd); return 0; } dp6c_ptr = (gdt6c_dpram_str *)ha->brd; /* reset interface area */ memset_io((char *)&dp6c_ptr->u,0,sizeof(dp6c_ptr->u)); if (readl(&dp6c_ptr->u) != 0) { printk("GDT-PCI: Initialization error (DPMEM write error)\n"); gdth_munmap(ha->brd); return 0; } /* disable board interrupts, deinit services */ outb(0x00,PTR2USHORT(&ha->plx->control1)); outb(0xff,PTR2USHORT(&ha->plx->edoor_reg)); writeb(0x00, &dp6c_ptr->u.ic.S_Status); writeb(0x00, &dp6c_ptr->u.ic.Cmd_Index); writel(pcistr->dpmem, &dp6c_ptr->u.ic.S_Info[0]); writeb(0xff, &dp6c_ptr->u.ic.S_Cmd_Indx); outb(1,PTR2USHORT(&ha->plx->ldoor_reg)); retries = INIT_RETRIES; gdth_delay(20); while (readb(&dp6c_ptr->u.ic.S_Status) != 0xff) { if (--retries == 0) { printk("GDT-PCI: Initialization error (DEINIT failed)\n"); gdth_munmap(ha->brd); return 0; } gdth_delay(1); } prot_ver = (unchar)readl(&dp6c_ptr->u.ic.S_Info[0]); writeb(0, &dp6c_ptr->u.ic.Status); if (prot_ver != PROTOCOL_VERSION) { printk("GDT-PCI: Illegal protocol version\n"); gdth_munmap(ha->brd); return 0; } ha->type = GDT_PCINEW; ha->ic_all_size = sizeof(dp6c_ptr->u); /* special command to controller BIOS */ writel(0x00, &dp6c_ptr->u.ic.S_Info[0]); writel(0x00, &dp6c_ptr->u.ic.S_Info[1]); writel(0x01, &dp6c_ptr->u.ic.S_Info[2]); writel(0x00, &dp6c_ptr->u.ic.S_Info[3]); writeb(0xfe, &dp6c_ptr->u.ic.S_Cmd_Indx); outb(1,PTR2USHORT(&ha->plx->ldoor_reg)); retries = INIT_RETRIES; gdth_delay(20); while (readb(&dp6c_ptr->u.ic.S_Status) != 0xfe) { if (--retries == 0) { printk("GDT-PCI: Initialization error\n"); gdth_munmap(ha->brd); return 0; } gdth_delay(1); } writeb(0, &dp6c_ptr->u.ic.S_Status); } else { /* MPR */ TRACE2(("init_pci_mpr() dpmem %lx irq %d\n",pcistr->dpmem,ha->irq)); ha->brd = gdth_mmap(pcistr->dpmem, sizeof(gdt6m_dpram_str)); if (ha->brd == NULL) { printk("GDT-PCI: Initialization error (DPMEM remap error)\n"); return 0; } /* check and reset interface area */ dp6m_ptr = (gdt6m_dpram_str *)ha->brd; writel(DPMEM_MAGIC, &dp6m_ptr->u); if (readl(&dp6m_ptr->u) != DPMEM_MAGIC) { printk("GDT-PCI: Cannot access DPMEM at 0x%x (shadowed?)\n", (int)ha->brd); found = FALSE; for (i = 0xC8000; i < 0xE8000; i += 0x4000) { pcibios_write_config_dword( pcistr->bus, pcistr->device_fn, PCI_BASE_ADDRESS_0, i ); gdth_munmap( ha->brd ); ha->brd = gdth_mmap(i, sizeof(gdt6m_dpram_str)); if (ha->brd == NULL) { printk("GDT-PCI: Initialization error (DPMEM remap error)\n"); return 0; } dp6m_ptr = (gdt6m_dpram_str *)ha->brd; writel(DPMEM_MAGIC, &dp6m_ptr->u); if (readl(&dp6m_ptr->u) == DPMEM_MAGIC) { printk("GDT-PCI: Use free address at 0x%x\n", (int)ha->brd); found = TRUE; break; } } if (!found) { printk("GDT-PCI: No free address found!\n"); gdth_munmap( ha->brd ); return 0; } } memset_io((char *)&dp6m_ptr->u,0,sizeof(dp6m_ptr->u)); /* disable board interrupts, deinit services */ writeb(readb(&dp6m_ptr->i960r.edoor_en_reg) | 4, &dp6m_ptr->i960r.edoor_en_reg); writeb(0xff, &dp6m_ptr->i960r.edoor_reg); writeb(0x00, &dp6m_ptr->u.ic.S_Status); writeb(0x00, &dp6m_ptr->u.ic.Cmd_Index); writel(pcistr->dpmem, &dp6m_ptr->u.ic.S_Info[0]); writeb(0xff, &dp6m_ptr->u.ic.S_Cmd_Indx); writeb(1, &dp6m_ptr->i960r.ldoor_reg); retries = INIT_RETRIES; gdth_delay(20); while (readb(&dp6m_ptr->u.ic.S_Status) != 0xff) { if (--retries == 0) { printk("GDT-PCI: Initialization error (DEINIT failed)\n"); gdth_munmap(ha->brd); return 0; } gdth_delay(1); } prot_ver = (unchar)readl(&dp6m_ptr->u.ic.S_Info[0]); writeb(0, &dp6m_ptr->u.ic.S_Status); if (prot_ver != PROTOCOL_VERSION) { printk("GDT-PCI: Illegal protocol version\n"); gdth_munmap(ha->brd); return 0; } ha->type = GDT_PCIMPR; ha->ic_all_size = sizeof(dp6m_ptr->u); /* special command to controller BIOS */ writel(0x00, &dp6m_ptr->u.ic.S_Info[0]); writel(0x00, &dp6m_ptr->u.ic.S_Info[1]); writel(0x01, &dp6m_ptr->u.ic.S_Info[2]); writel(0x00, &dp6m_ptr->u.ic.S_Info[3]); writeb(0xfe, &dp6m_ptr->u.ic.S_Cmd_Indx); writeb(1, &dp6m_ptr->i960r.ldoor_reg); retries = INIT_RETRIES; gdth_delay(20); while (readb(&dp6m_ptr->u.ic.S_Status) != 0xfe) { if (--retries == 0) { printk("GDT-PCI: Initialization error\n"); gdth_munmap(ha->brd); return 0; } gdth_delay(1); } writeb(0, &dp6m_ptr->u.ic.S_Status); } return 1;}/* controller protocol functions */__initfunc (static void gdth_enable_int(int hanum)){ gdth_ha_str *ha; ulong flags; gdt2_dpram_str *dp2_ptr; gdt6_dpram_str *dp6_ptr; gdt6m_dpram_str *dp6m_ptr; TRACE(("gdth_enable_int() hanum %d\n",hanum)); ha = HADATA(gdth_ctr_tab[hanum]); save_flags(flags); cli(); if (ha->type == GDT_EISA) { outb(0xff, ha->bmic + EDOORREG); outb(0xff, ha->bmic + EDENABREG); outb(0x01, ha->bmic + EINTENABREG); } else if (ha->type == GDT_ISA) { dp2_ptr = (gdt2_dpram_str *)ha->brd; writeb(1, &dp2_ptr->io.irqdel); writeb(0, &dp2_ptr->u.ic.Cmd_Index); writeb(1, &dp2_ptr->io.irqen); } else if (ha->type == GDT_PCI) { dp6_ptr = (gdt6_dpram_str *)ha->brd; writeb(1, &dp6_ptr->io.irqdel); writeb(0, &dp6_ptr->u.ic.Cmd_Index); writeb(1, &dp6_ptr->io.irqen); } else if (ha->type == GDT_PCINEW) { outb(0xff, PTR2USHORT(&ha->plx->edoor_reg)); outb(0x03, PTR2USHORT(&ha->plx->control1)); } else if (ha->type == GDT_PCIMPR) { dp6m_ptr = (gdt6m_dpram_str *)ha->brd; writeb(0xff, &dp6m_ptr->i960r.edoor_reg); writeb(readb(&dp6m_ptr->i960r.edoor_en_reg) & ~4, &dp6m_ptr->i960r.edoor_en_reg); } restore_flags(flags);}static int gdth_get_status(unchar *pIStatus,int irq){ register gdth_ha_str *ha; int i; TRACE(("gdth_get_status() irq %d ctr_count %d\n", irq,gdth_ctr_count)); *pIStatus = 0; for (i=0; i<gdth_ctr_count; ++i) { ha = HADATA(gdth_ctr_tab[i]); if (ha->irq != (unchar)irq) /* check IRQ */ continue; if (ha->type == GDT_EISA) *pIStatus = inb((ushort)ha->bmic + EDOORREG); else if (ha->type == GDT_ISA) *pIStatus = readb(&((gdt2_dpram_str *)ha->brd)->u.ic.Cmd_Index); else if (ha->type == GDT_PCI) *pIStatus = readb(&((gdt6_dpram_str *)ha->brd)->u.ic.Cmd_Index); else if (ha->type == GDT_PCINEW) *pIStatus = inb(PTR2USHORT(&ha->plx->edoor_reg)); else if (ha->type == GDT_PCIMPR) *pIStatus = readb(&((gdt6m_dpram_str *)ha->brd)->i960r.edoor_reg); if (*pIStatus) return i; /* board found */ } return -1;} static int gdth_test_busy(int hanum){ register gdth_ha_str *ha; register int gdtsema0 = 0; TRACE(("gdth_test_busy() hanum %d\n",hanum)); ha = HADATA(gdth_ctr_tab[hanum]); if (ha->type == GDT_EISA) gdtsema0 = (int)inb(ha->bmic + SEMA0REG); else if (ha->type == GDT_ISA) gdtsema0 = (int)readb(&((gdt2_dpram_str *)ha->brd)->u.ic.Sema0); else if (ha->type == GDT_PCI) gdtsema0 = (int)readb(&((gdt6_dpram_str *)ha->brd)->u.ic.Sema0); else if (ha->type == GDT_PCINEW) gdtsema0 = (int)inb(PTR2USHORT(&ha->plx->sema0_reg)); else if (ha->type == GDT_PCIMPR) gdtsema0 = (int)readb(&((gdt6m_dpram_str *)ha->brd)->i960r.sema0_reg); return (gdtsema0 & 1);}static int gdth_get_cmd_index(int hanum){ register gdth_ha_str *ha; int i; TRACE(("gdth_get_cmd_index() hanum %d\n",hanum)); ha = HADATA(gdth_ctr_tab[hanum]); for (i=0; i<GDTH_MAXCMDS; ++i) { if (gdth_cmd_tab[i][hanum].cmnd == UNUSED_CMND) { gdth_cmd_tab[i][hanum].cmnd = ha->pccb->RequestBuffer; gdth_cmd_tab[i][hanum].service = ha->pccb->Service;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -