From 4d6eb4efb8603cf2d3f732b7ea90e657f003355d Mon Sep 17 00:00:00 2001 From: Pawel Dziepak Date: Wed, 19 Nov 2008 21:49:51 +0100 Subject: [PATCH] minor changes in ne2k_pci and pci drivers --- arch/x86/ne2k_pci.cpp | 42 +++++++++++++++++++++--------------------- arch/x86/pci.cpp | 4 +++- 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/arch/x86/ne2k_pci.cpp b/arch/x86/ne2k_pci.cpp index 4e9810e..8dcd7aa 100644 --- a/arch/x86/ne2k_pci.cpp +++ b/arch/x86/ne2k_pci.cpp @@ -8,23 +8,23 @@ using namespace arch; enum ne2k_registers { - ne2k_command, - ne2k_pstart, + ne2k_command = 0, + ne2k_pstart = 1, ne2k_paddr = 1, - ne2k_pstop, - ne2k_bnry, + ne2k_pstop = 2, + ne2k_bnry = 3, ne2k_int_status = 7, ne2k_curr = 7, - ne2k_rsar0, + ne2k_rsar0 = 8, ne2k_maddr = 8, - ne2k_rsar1, - ne2k_rbcr0, - ne2k_rbcr1, - ne2k_recv_conf, - ne2k_trans_conf, - ne2k_data_conf, - ne2k_int_mask, - ne2k_dataport + ne2k_rsar1 = 9, + ne2k_rbcr0 = 0xa, + ne2k_rbcr1 = 0xb, + ne2k_recv_conf = 0xc, + ne2k_trans_conf = 0xd, + ne2k_data_conf = 0xe, + ne2k_int_mask = 0xf, + ne2k_dataport = 0x10 }; pci_address ne2k; @@ -90,7 +90,7 @@ void ne2k_pci_read(pci_address pciaddr, u16 addr, u8 *buffer, u16 len) { } /* Clear ISR */ - outb(pciaddr.ioport + ne2k_int_status, 0xff); + outb(pciaddr.ioport + ne2k_int_status, 0x40); } void ne2k_pci_write(pci_address pciaddr, u16 addr, u8 *buffer, u16 len) { @@ -113,7 +113,7 @@ void ne2k_pci_write(pci_address pciaddr, u16 addr, u8 *buffer, u16 len) { } /* Clear ISR */ - outb(pciaddr.ioport + ne2k_int_status, 0xff); + outb(pciaddr.ioport + ne2k_int_status, 0x40); } void ne2k_pci_send_packet(pci_address pciaddr, u8 *buffer, u16 len) { @@ -182,12 +182,9 @@ void ne2k_pci_init(pci_address pciaddr) { outb(pciaddr.ioport + ne2k_int_status, 0xff); /* IRQ on data received and completed DMA transmission */ - outb(pciaddr.ioport + ne2k_int_mask, 0x41); + //outb(pciaddr.ioport + ne2k_int_mask, 0x41); outb(pciaddr.ioport + ne2k_int_mask, 0xb); - /* No loopback */ - //outb(pciaddr.ioport + ne2k_trans_conf, 0); - /* Launch device */ outb(pciaddr.ioport + ne2k_command, CR_START | CR_DMA_ABORT | CR_PAGE0); @@ -196,7 +193,7 @@ void ne2k_pci_init(pci_address pciaddr) { get_mac_addr(mac); /* Turn to page 1 */ - outb(pciaddr.ioport + ne2k_command, 0x61); + outb(pciaddr.ioport + ne2k_command, CR_STOP | CR_DMA_ABORT | CR_PAGE1); /* current page */ outb(pciaddr.ioport + ne2k_curr, 0x26); @@ -211,7 +208,10 @@ void ne2k_pci_init(pci_address pciaddr) { outb(pciaddr.ioport + i + ne2k_maddr, 0); /* Turn to page 0 */ - outb(pciaddr.ioport + ne2k_command, CR_STOP| CR_DMA_ABORT | CR_PAGE0); + outb(pciaddr.ioport + ne2k_command, CR_START | CR_DMA_ABORT | CR_PAGE0); + + /* No loopback */ + outb(pciaddr.ioport + ne2k_trans_conf, 0); delegate eth_isr; eth_isr.function(ne2k_pci_irq); diff --git a/arch/x86/pci.cpp b/arch/x86/pci.cpp index 83e7f29..fdb95f4 100644 --- a/arch/x86/pci.cpp +++ b/arch/x86/pci.cpp @@ -94,9 +94,11 @@ pci_address get_address(u32 bus, u32 dev, u32 func) { paddr.function = func; /* Get IRQ line */ - set_pci_conf(bus, dev, func, 15, (get_pci_conf(bus, dev, func, 15) & ~0xff) | allocate_pci_irq()); + //set_pci_conf(bus, dev, func, 15, (get_pci_conf(bus, dev, func, 15) & ~0xff) | allocate_pci_irq()); paddr.irq = get_pci_conf(bus, dev, func, 15) & 0xff; + set_pci_conf(bus, dev, func, 1, get_pci_conf(bus, dev, func, 1) | 3); + /* Set IO address space */ for (int i = 0; i < 5; i++) { set_pci_conf(bus, dev, func, 4 + i, 0xffffffff); -- 2.11.4.GIT