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

📄 gdth.c

📁 linux和2410结合开发 用他可以生成2410所需的zImage文件
💻 C
📖 第 1 页 / 共 5 页
字号:
            if (irq_found) {                ha->irq = irq[i];                irq[i] = 0;                printk("GDT-EISA: Can not detect controller IRQ,\n");                printk("Use IRQ setting from command line (IRQ = %d)\n",                       ha->irq);            } else {                printk("GDT-EISA: Initialization error (unknown IRQ), Enable\n");                printk("the controller BIOS or use command line parameters\n");                return 0;            }        }    } else {        eisacf = inb(eisa_adr+EISAREG) & 7;        if (eisacf > 4)                         /* level triggered */            eisacf -= 4;        ha->irq = gdth_irq_tab[eisacf];        ha->oem_id = OEM_ID_ICP;        ha->type = GDT_EISA;        ha->stype = id;    }    return 1;}       GDTH_INITFUNC(static int, gdth_init_isa(ulong32 bios_adr,gdth_ha_str *ha)){    register gdt2_dpram_str *dp2_ptr;    int i;    unchar irq_drq,prot_ver;    ulong32 retries;    TRACE(("gdth_init_isa() bios adr. %x\n",bios_adr));    ha->brd = gdth_mmap(bios_adr, sizeof(gdt2_dpram_str));    if (ha->brd == NULL) {        printk("GDT-ISA: Initialization error (DPMEM remap error)\n");        return 0;    }    dp2_ptr = (gdt2_dpram_str *)ha->brd;    gdth_writeb(1, &dp2_ptr->io.memlock); /* switch off write protection */    /* reset interface area */    memset_io((char *)&dp2_ptr->u,0,sizeof(dp2_ptr->u));    if (gdth_readl(&dp2_ptr->u) != 0) {        printk("GDT-PCI: Initialization error (DPMEM write error)\n");        gdth_munmap(ha->brd);        return 0;    }    /* disable board interrupts, read DRQ and IRQ */    gdth_writeb(0xff, &dp2_ptr->io.irqdel);    gdth_writeb(0x00, &dp2_ptr->io.irqen);    gdth_writeb(0x00, &dp2_ptr->u.ic.S_Status);    gdth_writeb(0x00, &dp2_ptr->u.ic.Cmd_Index);    irq_drq = gdth_readb(&dp2_ptr->io.rq);    for (i=0; i<3; ++i) {        if ((irq_drq & 1)==0)            break;        irq_drq >>= 1;    }    ha->drq = gdth_drq_tab[i];    irq_drq = gdth_readb(&dp2_ptr->io.rq) >> 3;    for (i=1; i<5; ++i) {        if ((irq_drq & 1)==0)            break;        irq_drq >>= 1;    }    ha->irq = gdth_irq_tab[i];    /* deinitialize services */    gdth_writel(bios_adr, &dp2_ptr->u.ic.S_Info[0]);    gdth_writeb(0xff, &dp2_ptr->u.ic.S_Cmd_Indx);    gdth_writeb(0, &dp2_ptr->io.event);    retries = INIT_RETRIES;    gdth_delay(20);    while (gdth_readb(&dp2_ptr->u.ic.S_Status) != 0xff) {        if (--retries == 0) {            printk("GDT-ISA: Initialization error (DEINIT failed)\n");            gdth_munmap(ha->brd);            return 0;        }        gdth_delay(1);    }    prot_ver = (unchar)gdth_readl(&dp2_ptr->u.ic.S_Info[0]);    gdth_writeb(0, &dp2_ptr->u.ic.Status);    gdth_writeb(0xff, &dp2_ptr->io.irqdel);    if (prot_ver != PROTOCOL_VERSION) {        printk("GDT-ISA: Illegal protocol version\n");        gdth_munmap(ha->brd);        return 0;    }    ha->oem_id = OEM_ID_ICP;    ha->type = GDT_ISA;    ha->ic_all_size = sizeof(dp2_ptr->u);    ha->stype= GDT2_ID;    ha->brd_phys = bios_adr >> 4;    /* special request to controller BIOS */    gdth_writel(0x00, &dp2_ptr->u.ic.S_Info[0]);    gdth_writel(0x00, &dp2_ptr->u.ic.S_Info[1]);    gdth_writel(0x01, &dp2_ptr->u.ic.S_Info[2]);    gdth_writel(0x00, &dp2_ptr->u.ic.S_Info[3]);    gdth_writeb(0xfe, &dp2_ptr->u.ic.S_Cmd_Indx);    gdth_writeb(0, &dp2_ptr->io.event);    retries = INIT_RETRIES;    gdth_delay(20);    while (gdth_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);    }    gdth_writeb(0, &dp2_ptr->u.ic.Status);    gdth_writeb(0xff, &dp2_ptr->io.irqdel);    return 1;}GDTH_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;    ulong32 retries;    unchar prot_ver;    ushort command;    int i, found = FALSE;#if LINUX_VERSION_CODE < 0x2015C    int rom_addr;#endif    TRACE(("gdth_init_pci()\n"));    if (pcistr->vendor_id == PCI_VENDOR_ID_INTEL)        ha->oem_id = OEM_ID_INTEL;    else        ha->oem_id = OEM_ID_ICP;    ha->brd_phys = (pcistr->bus << 8) | (pcistr->device_fn & 0xf8);    ha->stype = (ulong32)pcistr->device_id;    ha->subdevice_id = pcistr->subdevice_id;    ha->irq = pcistr->irq;        if (ha->stype <= PCI_DEVICE_ID_VORTEX_GDT6000B) {  /* GDT6000/B */        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;        }        /* check and reset interface area */        dp6_ptr = (gdt6_dpram_str *)ha->brd;        gdth_writel(DPMEM_MAGIC, &dp6_ptr->u);        if (gdth_readl(&dp6_ptr->u) != DPMEM_MAGIC) {            printk("GDT-PCI: Cannot access DPMEM at 0x%lx (shadowed?)\n",                    pcistr->dpmem);            found = FALSE;            for (i = 0xC8000; i < 0xE8000; i += 0x4000) {                gdth_munmap(ha->brd);                ha->brd = gdth_mmap(i, sizeof(ushort));                 if (ha->brd == NULL) {                    printk("GDT-PCI: Initialization error (DPMEM remap error)\n");                    return 0;                }                if (gdth_readw(ha->brd) != 0xffff) {                    TRACE2(("init_pci_old() address 0x%x busy\n", i));                    continue;                }                gdth_munmap(ha->brd);#if LINUX_VERSION_CODE >= 0x2015C                pci_write_config_dword(pcistr->pdev,                                        PCI_BASE_ADDRESS_0, i);#else                pcibios_write_config_dword(pcistr->bus, pcistr->device_fn,                                           PCI_BASE_ADDRESS_0, i);#endif                ha->brd = gdth_mmap(i, 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;                gdth_writel(DPMEM_MAGIC, &dp6_ptr->u);                if (gdth_readl(&dp6_ptr->u) == DPMEM_MAGIC) {                    printk("GDT-PCI: Use free address at 0x%x\n", i);                    found = TRUE;                    break;                }            }               if (!found) {                printk("GDT-PCI: No free address found!\n");                gdth_munmap(ha->brd);                return 0;            }        }        memset_io((char *)&dp6_ptr->u,0,sizeof(dp6_ptr->u));        if (gdth_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 */        gdth_writeb(0xff, &dp6_ptr->io.irqdel);        gdth_writeb(0x00, &dp6_ptr->io.irqen);;        gdth_writeb(0x00, &dp6_ptr->u.ic.S_Status);        gdth_writeb(0x00, &dp6_ptr->u.ic.Cmd_Index);        gdth_writel(pcistr->dpmem, &dp6_ptr->u.ic.S_Info[0]);        gdth_writeb(0xff, &dp6_ptr->u.ic.S_Cmd_Indx);        gdth_writeb(0, &dp6_ptr->io.event);        retries = INIT_RETRIES;        gdth_delay(20);        while (gdth_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)gdth_readl(&dp6_ptr->u.ic.S_Info[0]);        gdth_writeb(0, &dp6_ptr->u.ic.S_Status);        gdth_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 */        gdth_writel(0x00, &dp6_ptr->u.ic.S_Info[0]);        gdth_writel(0x00, &dp6_ptr->u.ic.S_Info[1]);        gdth_writel(0x01, &dp6_ptr->u.ic.S_Info[2]);        gdth_writel(0x00, &dp6_ptr->u.ic.S_Info[3]);        gdth_writeb(0xfe, &dp6_ptr->u.ic.S_Cmd_Indx);        gdth_writeb(0, &dp6_ptr->io.event);        retries = INIT_RETRIES;        gdth_delay(20);        while (gdth_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);        }        gdth_writeb(0, &dp6_ptr->u.ic.S_Status);        gdth_writeb(0xff, &dp6_ptr->io.irqdel);    } else if (ha->stype <= PCI_DEVICE_ID_VORTEX_GDT6555) { /* GDT6110, ... */        ha->plx = (gdt6c_plx_regs *)pcistr->io;        TRACE2(("init_pci_new() dpmem %lx irq %d\n",            pcistr->dpmem,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;        }        /* check and reset interface area */        dp6c_ptr = (gdt6c_dpram_str *)ha->brd;        gdth_writel(DPMEM_MAGIC, &dp6c_ptr->u);        if (gdth_readl(&dp6c_ptr->u) != DPMEM_MAGIC) {            printk("GDT-PCI: Cannot access DPMEM at 0x%lx (shadowed?)\n",                    pcistr->dpmem);            found = FALSE;            for (i = 0xC8000; i < 0xE8000; i += 0x4000) {                gdth_munmap(ha->brd);                ha->brd = gdth_mmap(i, sizeof(ushort));                 if (ha->brd == NULL) {                    printk("GDT-PCI: Initialization error (DPMEM remap error)\n");                    return 0;                }                if (gdth_readw(ha->brd) != 0xffff) {                    TRACE2(("init_pci_plx() address 0x%x busy\n", i));                    continue;                }                gdth_munmap(ha->brd);#if LINUX_VERSION_CODE >= 0x2015C                pci_write_config_dword(pcistr->pdev,                                        PCI_BASE_ADDRESS_2, i);#else                pcibios_write_config_dword(pcistr->bus, pcistr->device_fn,                                           PCI_BASE_ADDRESS_2, i);#endif                ha->brd = gdth_mmap(i, sizeof(gdt6c_dpram_str));                 if (ha->brd == NULL) {                    printk("GDT-PCI: Initialization error (DPMEM remap error)\n");                    return 0;                }                dp6c_ptr = (gdt6c_dpram_str *)ha->brd;                gdth_writel(DPMEM_MAGIC, &dp6c_ptr->u);                if (gdth_readl(&dp6c_ptr->u) == DPMEM_MAGIC) {                    printk("GDT-PCI: Use free address at 0x%x\n", i);                    found = TRUE;                    break;                }            }               if (!found) {                printk("GDT-PCI: No free address found!\n");                gdth_munmap(ha->brd);                return 0;            }        }        memset_io((char *)&dp6c_ptr->u,0,sizeof(dp6c_ptr->u));        if (gdth_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));                gdth_writeb(0x00, &dp6c_ptr->u.ic.S_Status);        gdth_writeb(0x00, &dp6c_ptr->u.ic.Cmd_Index);        gdth_writel(pcistr->dpmem, &dp6c_ptr->u.ic.S_Info[0]);        gdth_writeb(0xff, &dp6c_ptr->u.ic.S_Cmd_Indx);        outb(1,PTR2USHORT(&ha->plx->ldoor_reg));        retries = INIT_RETRIES;        gdth_delay(20);        while (gdth_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)gdth_readl(&dp6c_ptr->u.ic.S_Info[0]);        gdth_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 */        gdth_writel(0x00, &dp6c_ptr->u.ic.S_Info[0]);        gdth_writel(0x00, &dp6c_ptr->u.ic.S_Info[1]);        gdth_writel(0x01, &dp6c_ptr->u.ic.S_Info[2]);        gdth_writel(0x00, &dp6c_ptr->u.ic.S_Info[3]);        gdth_writeb(0xfe, &dp6c_ptr->u.ic.S_Cmd_Indx);

⌨️ 快捷键说明

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