diff options
author | Michael Brown | 2005-04-13 02:15:45 +0200 |
---|---|---|
committer | Michael Brown | 2005-04-13 02:15:45 +0200 |
commit | 28590d718bf472570c87014d654a177888e310c9 (patch) | |
tree | 63fee92b52f175a8eefc9d9f7373e2d676219a46 /src/drivers/net | |
parent | Automatically updated using (diff) | |
download | ipxe-28590d718bf472570c87014d654a177888e310c9.tar.gz ipxe-28590d718bf472570c87014d654a177888e310c9.tar.xz ipxe-28590d718bf472570c87014d654a177888e310c9.zip |
Hand-finished
Diffstat (limited to 'src/drivers/net')
-rw-r--r-- | src/drivers/net/rtl8139.c | 57 |
1 files changed, 27 insertions, 30 deletions
diff --git a/src/drivers/net/rtl8139.c b/src/drivers/net/rtl8139.c index b4ae072d..3c1cc739 100644 --- a/src/drivers/net/rtl8139.c +++ b/src/drivers/net/rtl8139.c @@ -180,30 +180,25 @@ static void rtl_transmit(struct nic *nic, const char *destaddr, static int rtl_poll(struct nic *nic, int retrieve); static void rtl_disable(struct nic *nic); static void rtl_irq(struct nic *nic, irq_action_t action); - +static struct nic_operations rtl_operations; +static struct pci_driver rtl8139_driver; static int rtl8139_probe ( struct dev *dev ) { - struct nic *nic = nic_device ( dev ); - struct pci_device *pci = pci_device ( dev ); int i; int speed10, fullduplex; int addr_len; unsigned short *ap = (unsigned short*)nic->node_addr; - /* There are enough "RTL8139" strings on the console already, so - * be brief and concentrate on the interesting pieces of info... */ - printf(" - "); - - /* Mask the bit that says "this is an io addr" */ - nic->ioaddr = pci->ioaddr & ~3; + /* Look for PCI device */ + if ( ! find_pci_device ( pci, &rtl8139_driver ) ) + return 0; - /* Copy IRQ from PCI information */ + /* Copy ioaddr and IRQ from PCI information */ + nic->ioaddr = pci->ioaddr; nic->irqno = pci->irq; - adjust_pci_device(pci); - /* Bring the chip out of low-power mode. */ outb(0x00, nic->ioaddr + Config1); @@ -211,28 +206,14 @@ static int rtl8139_probe ( struct dev *dev ) { for (i = 0; i < 3; i++) *ap++ = read_eeprom(nic,i + 7,addr_len); + rtl_reset(nic); + speed10 = inb(nic->ioaddr + MediaStatus) & MSRSpeed10; + nic->mbps = speed10 ? 10 : 100; fullduplex = inw(nic->ioaddr + MII_BMCR) & BMCRDuplex; - printf("ioaddr %#hX, irq %d, addr %! %sMbps %s-duplex\n", nic->ioaddr, - nic->irqno, nic->node_addr, speed10 ? "10" : "100", - fullduplex ? "full" : "half"); + nic->duplex = fullduplex ? FULL_DUPLEX : HALF_DUPLEX; - rtl_reset(nic); - - if (inb(nic->ioaddr + MediaStatus) & MSRLinkFail) { - printf("Cable not connected or other link failure\n"); - return(0); - } -static struct nic_operations rtl_operations; -static struct nic_operations rtl_operations = { - .connect = dummy_connect, - .poll = rtl_poll, - .transmit = rtl_transmit, - .irq = rtl_irq, - .disable = rtl_disable, -}; nic->nic_op = &rtl_operations; - return 1; } @@ -312,6 +293,14 @@ static void set_rx_mode(struct nic *nic) { outl(mc_filter[0], nic->ioaddr + MAR0 + 0); outl(mc_filter[1], nic->ioaddr + MAR0 + 4); } + +static int rtl_connect ( struct nic *nic ) { + if (inb(nic->ioaddr + MediaStatus) & MSRLinkFail) { + printf("Cable not connected or other link failure\n"); + return 0; + } + return 1; +} static void rtl_reset(struct nic* nic) { @@ -528,6 +517,14 @@ static void rtl_disable ( struct nic *nic ) { /* wait */; } +static struct nic_operations rtl_operations = { + .connect = rtl_connect, + .poll = rtl_poll, + .transmit = rtl_transmit, + .irq = rtl_irq, + .disable = rtl_disable, +}; + static struct pci_id rtl8139_nics[] = { PCI_ROM(0x10ec, 0x8129, "rtl8129", "Realtek 8129"), PCI_ROM(0x10ec, 0x8139, "rtl8139", "Realtek 8139"), |