From: David van Moolenbroek Date: Mon, 5 Mar 2012 11:58:33 +0000 (+0100) Subject: e1000: add support for 82545EM X-Git-Tag: v3.2.1~685 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/zpipe.c?a=commitdiff_plain;h=831450aaccfe2bff6c0e981d92c52e4900dd3fb0;p=minix.git e1000: add support for 82545EM Tested on VirtualBox and VMware. --- diff --git a/drivers/e1000/e1000.c b/drivers/e1000/e1000.c index 1de3a2a77..c8e2aa927 100644 --- a/drivers/e1000/e1000.c +++ b/drivers/e1000/e1000.c @@ -21,17 +21,6 @@ #include "e1000_reg.h" #include "e1000_pci.h" -PRIVATE u16_t pcitab_e1000[] = -{ - E1000_DEV_ID_82540EM, - E1000_DEV_ID_82541GI_LF, - E1000_DEV_ID_ICH10_D_BM_LM, - E1000_DEV_ID_ICH10_R_BM_LF, - E1000_DEV_ID_82574L, - E1000_DEV_ID_82571EB_COPPER, - 0, -}; - PRIVATE int e1000_instance; PRIVATE e1000_t e1000_state; @@ -236,9 +225,10 @@ PRIVATE void e1000_init_pci() *===========================================================================*/ PRIVATE int e1000_probe(e1000_t *e, int skip) { - int i, r, devind; - u16_t vid, did; + int r, devind, ioflag; + u16_t vid, did, cr; u32_t status[2]; + u32_t base, size; u32_t gfpreg, sector_base_addr; char *dname; @@ -256,24 +246,11 @@ PRIVATE int e1000_probe(e1000_t *e, int skip) { E1000_DEBUG(3, ("%s: probe() devind %d vid 0x%x did 0x%x\n", e->name, devind, vid, did)); - if (vid != 0x8086) - goto get_next; - for (i = 0; pcitab_e1000[i] != 0; i++) - { - if (did != pcitab_e1000[i]) - continue; - else + if (!skip) break; - } - if (pcitab_e1000[i] != 0) - { - if (!skip) - break; - skip--; - } + skip--; -get_next: if (!(r = pci_next_dev(&devind, &vid, &did))) { return FALSE; @@ -296,6 +273,7 @@ get_next: break; case E1000_DEV_ID_82540EM: + case E1000_DEV_ID_82545EM: e->eeprom_done_bit = (1 << 4); e->eeprom_addr_off = 8; break; @@ -322,15 +300,26 @@ get_next: } /* Read PCI configuration. */ e->irq = pci_attr_r8(devind, PCI_ILR); - e->regs = vm_map_phys(SELF, (void *) pci_attr_r32(devind, PCI_BAR), - 0x20000); - - /* Verify mapped registers. */ + + if ((r = pci_get_bar(devind, PCI_BAR, &base, &size, &ioflag)) != OK) + panic("failed to get PCI BAR (%d)", r); + if (ioflag) panic("PCI BAR is not for memory"); + + e->regs = vm_map_phys(SELF, (void *) base, size); if (e->regs == (u8_t *) -1) { panic("failed to map hardware registers from PCI"); } + + /* FIXME: enable DMA bus mastering if necessary. This is disabled by + * default on VMware. Eventually, the PCI driver should deal with this. + */ + cr = pci_attr_r16(devind, PCI_CR); + if (!(cr & PCI_CR_MAST_EN)) + pci_attr_w16(devind, PCI_CR, cr | PCI_CR_MAST_EN); + /* Optionally map flash memory. */ if (did != E1000_DEV_ID_82540EM && + did != E1000_DEV_ID_82545EM && did != E1000_DEV_ID_82540EP && pci_attr_r32(devind, PCI_BAR_2)) { @@ -556,7 +545,7 @@ e1000_t *e; panic("failed to allocate TX buffers"); } /* Setup transmit descriptors. */ - for (i = 0; i < E1000_RXDESC_NR; i++) + for (i = 0; i < E1000_TXDESC_NR; i++) { e->tx_desc[i].buffer = tx_buff_p + (i * E1000_IOBUF_SIZE); } diff --git a/drivers/e1000/e1000.conf b/drivers/e1000/e1000.conf index 583f47525..20e561992 100644 --- a/drivers/e1000/e1000.conf +++ b/drivers/e1000/e1000.conf @@ -8,6 +8,7 @@ service e1000 DEVIO # 21 ; pci device 8086/100e; + pci device 8086/100f; pci device 8086/107c; pci device 8086/10cd; pci device 8086/10d3; diff --git a/drivers/e1000/e1000_pci.h b/drivers/e1000/e1000_pci.h index 344c8b9eb..0cfcbcecc 100644 --- a/drivers/e1000/e1000_pci.h +++ b/drivers/e1000/e1000_pci.h @@ -31,6 +31,7 @@ #define E1000_DEV_ID_82544GC_COPPER 0x100C #define E1000_DEV_ID_82544GC_LOM 0x100D #define E1000_DEV_ID_82540EM 0x100E +#define E1000_DEV_ID_82545EM 0x100F #define E1000_DEV_ID_82540EM_LOM 0x1015 #define E1000_DEV_ID_82540EP_LOM 0x1016 #define E1000_DEV_ID_82540EP 0x1017 diff --git a/drivers/pci/pci_table.c b/drivers/pci/pci_table.c index 06cbbb0e2..348e0b856 100644 --- a/drivers/pci/pci_table.c +++ b/drivers/pci/pci_table.c @@ -133,6 +133,7 @@ struct pci_device pci_device_table[]= { 0x5333, 0x8a01, "S3 Virge/DX or /GX" }, { 0x8086, 0x1004, "Intel 82543GC Gigabit Ethernet Controller" }, { 0x8086, 0x100E, "Intel PRO/1000 MT Desktop Adapter" }, + { 0x8086, 0x100F, "Intel PRO/1000 MT 82545EM" }, { 0x8086, 0x1029, "Intel EtherExpressPro100 ID1029" }, { 0x8086, 0x1030, "Intel Corporation 82559 InBusiness 10/100" }, { 0x8086, 0x1031, "Intel Corporation 82801CAM PRO/100 VE" },