bug-grub
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

GRUB 0.93 seems to not work with my NIC (patch included)


From: Ivan Shmakov
Subject: GRUB 0.93 seems to not work with my NIC (patch included)
Date: Sun, 04 May 2003 21:48:44 +0700

        I've just built GRUB for first time and decided to test it on
        my Am386-DX40 with 8 MB RAM & some NIC that etherboot-5.0.7
        recognizes as `SMC8416C/BT' (if I'm not mistaken).

        GRUB starts just fine (from 5.25" floppy, there's no hard disk
        on that machine), but the `dhcp' (as well as `bootp') isn't
        work.  It seems to me now that the code generates somewhat bad
        data for my NIC -- tcpdump doesn't show any DHCP/BOOTP packet,
        nor dhcpd gets it.

        After replacing netboot/ns8390.c with one from etherboot-5.0.7
        (with minor hacking) `dhcp' began to fail with ERR_WONT_FIT.
        Then I just recompiled `wd.o' it with `CFLAGS+=-DWD_790_PIO'
        and all works just fine.

        I can send more detailed description of the problem if needed.

        Patch follows.  This is just ns8390.c from etherboot-5.0.7
        except for minor hack at bottom (#if 0 / #endif pair).

--- grub-0.93/netboot/ns8390.c  Thu Jan  3 03:56:40 2002
+++ grub-0.93-net/netboot/ns8390.c      Sat May  3 16:34:24 2003
@@ -1,3 +1,6 @@
+#ifdef ALLMULTI
+#error multicast support is not yet implemented
+#endif
 /**************************************************************************
 ETHERBOOT -  BOOTP/TFTP Bootstrap Program
 
@@ -18,6 +21,8 @@
 3c503 PIO support added by Jim Hague (address@hidden) on 2/17/98
 RX overrun by Klaus Espenlaub (address@hidden) on 3/10/99
   parts taken from the Linux 8390 driver (by Donald Becker and Paul Gortmaker)
+SMC8416 PIO support added by Andrew Bettison (address@hidden) on 4/3/02
+  based on the Linux 8390 driver (by Donald Becker and Paul Gortmaker)
 
 **************************************************************************/
 
@@ -66,6 +71,7 @@
 #endif
 
 #if    defined(INCLUDE_WD)
+#define        ASIC_PIO        WD_IAR
 #define        eth_probe       wd_probe
 #if    defined(INCLUDE_3C503) || defined(INCLUDE_NE) || defined(INCLUDE_NS8390)
 Error you must only define one of INCLUDE_WD, INCLUDE_3C503, INCLUDE_NE, 
INCLUDE_NS8390
@@ -101,13 +107,16 @@
 #endif
 #endif
 
-#if    defined(INCLUDE_NE) || defined(INCLUDE_NS8390) || 
(defined(INCLUDE_3C503) && !defined(T503_SHMEM))
+#if    defined(INCLUDE_NE) || defined(INCLUDE_NS8390) || 
(defined(INCLUDE_3C503) && !defined(T503_SHMEM)) || (defined(INCLUDE_WD) && 
defined(WD_790_PIO))
 /**************************************************************************
 ETH_PIO_READ - Read a frame via Programmed I/O
 **************************************************************************/
 static void eth_pio_read(unsigned int src, unsigned char *dst, unsigned int 
cnt)
 {
-       if (eth_flags & FLAG_16BIT) { ++cnt; cnt &= ~1; }
+#ifdef INCLUDE_WD
+       outb(src & 0xff, eth_asic_base + WD_GP2);
+       outb(src >> 8, eth_asic_base + WD_GP2);
+#else
        outb(D8390_COMMAND_RD2 |
                D8390_COMMAND_STA, eth_nic_base + D8390_P0_COMMAND);
        outb(cnt, eth_nic_base + D8390_P0_RBCR0);
@@ -122,9 +131,10 @@
        outb(src >> 8, eth_asic_base + _3COM_DAMSB);
        outb(t503_output | _3COM_CR_START, eth_asic_base + _3COM_CR);
 #endif
+#endif
 
        if (eth_flags & FLAG_16BIT)
-               cnt >>= 1;
+               cnt = (cnt + 1) >> 1;
 
        while(cnt--) {
 #ifdef INCLUDE_3C503
@@ -153,7 +163,10 @@
 #ifdef COMPEX_RL2000_FIX
        unsigned int x;
 #endif /* COMPEX_RL2000_FIX */
-       if (eth_flags & FLAG_16BIT) { ++cnt; cnt &= ~1; }
+#ifdef INCLUDE_WD
+       outb(dst & 0xff, eth_asic_base + WD_GP2);
+       outb(dst >> 8, eth_asic_base + WD_GP2);
+#else
        outb(D8390_COMMAND_RD2 |
                D8390_COMMAND_STA, eth_nic_base + D8390_P0_COMMAND);
        outb(D8390_ISR_RDC, eth_nic_base + D8390_P0_ISR);
@@ -170,9 +183,10 @@
 
        outb(t503_output | _3COM_CR_DDIR | _3COM_CR_START, eth_asic_base + 
_3COM_CR);
 #endif
+#endif
 
        if (eth_flags & FLAG_16BIT)
-               cnt >>= 1;
+               cnt = (cnt + 1) >> 1;
 
        while(cnt--)
        {
@@ -201,9 +215,11 @@
        if (x >= COMPEX_RL2000_TRIES)
                printf("Warning: Compex RL2000 aborted wait!\n");
 #endif /* COMPEX_RL2000_FIX */
+#ifndef        INCLUDE_WD
        while((inb(eth_nic_base + D8390_P0_ISR) & D8390_ISR_RDC)
                != D8390_ISR_RDC);
 #endif
+#endif
 }
 #else
 /**************************************************************************
@@ -238,7 +254,14 @@
        outb(eth_tx_start, eth_nic_base+D8390_P0_TPSR);
        outb(eth_rx_start, eth_nic_base+D8390_P0_PSTART);
 #ifdef INCLUDE_WD
-       if (eth_flags & FLAG_790) outb(0, eth_nic_base + 0x09);
+       if (eth_flags & FLAG_790) {
+#ifdef WD_790_PIO
+               outb(0x10, eth_asic_base + 0x06); /* disable interrupts, enable 
PIO */
+               outb(0x01, eth_nic_base + 0x09); /* enable ring read auto-wrap 
*/
+#else
+               outb(0, eth_nic_base + 0x09);
+#endif
+       }
 #endif
        outb(eth_memsize, eth_nic_base+D8390_P0_PSTOP);
        outb(eth_memsize - 1, eth_nic_base+D8390_P0_BOUND);
@@ -266,8 +289,8 @@
                outb(D8390_COMMAND_PS0 |
                        D8390_COMMAND_RD2 | D8390_COMMAND_STA, 
eth_nic_base+D8390_P0_COMMAND);
        outb(0xFF, eth_nic_base+D8390_P0_ISR);
-       outb(0, eth_nic_base+D8390_P0_TCR);
-       outb(4, eth_nic_base+D8390_P0_RCR);     /* allow broadcast frames */
+       outb(0, eth_nic_base+D8390_P0_TCR);     /* transmitter on */
+       outb(4, eth_nic_base+D8390_P0_RCR);     /* allow rx broadcast frames */
 
 #ifdef INCLUDE_3C503
         /*
@@ -357,11 +380,12 @@
 #endif
 
 #ifdef INCLUDE_WD
-       /* Memory interface */
        if (eth_flags & FLAG_16BIT) {
                outb(eth_laar | WD_LAAR_M16EN, eth_asic_base + WD_LAAR);
                inb(0x84);
        }
+#ifndef        WD_790_PIO
+       /* Memory interface */
        if (eth_flags & FLAG_790) {
                outb(WD_MSR_MENB, eth_asic_base + WD_MSR);
                inb(0x84);
@@ -378,16 +402,16 @@
                outb(0, eth_asic_base + WD_MSR);
                inb(0x84);
        }
-       if (eth_flags & FLAG_16BIT) {
-               outb(eth_laar & ~WD_LAAR_M16EN, eth_asic_base + WD_LAAR);
-               inb(0x84);
-       }
+#else
+       inb(0x84);
+#endif
 #endif
 
 #if    defined(INCLUDE_3C503)
-       if (eth_flags & FLAG_PIO) {
+       if (eth_flags & FLAG_PIO)
 #endif
-#if    defined(INCLUDE_NE) || defined(INCLUDE_NS8390) || 
(defined(INCLUDE_3C503) && !defined(T503_SHMEM))
+#if    defined(INCLUDE_NE) || defined(INCLUDE_NS8390) || 
(defined(INCLUDE_3C503) && !defined(T503_SHMEM)) || (defined(INCLUDE_WD) && 
defined(WD_790_PIO))
+       {
                /* Programmed I/O */
                unsigned short type;
                type = (t >> 8) | (t << 8);
@@ -398,12 +422,16 @@
                eth_pio_write(p, (eth_tx_start<<8)+ETH_HLEN, s);
                s += ETH_HLEN;
                if (s < ETH_ZLEN) s = ETH_ZLEN;
+       }
 #endif
 #if    defined(INCLUDE_3C503)
-       }
 #endif
 
 #ifdef INCLUDE_WD
+       if (eth_flags & FLAG_16BIT) {
+               outb(eth_laar & ~WD_LAAR_M16EN, eth_asic_base + WD_LAAR);
+               inb(0x84);
+       }
        if (eth_flags & FLAG_790)
                outb(D8390_COMMAND_PS0 |
                        D8390_COMMAND_STA, eth_nic_base+D8390_P0_COMMAND);
@@ -458,10 +486,12 @@
                outb(eth_laar | WD_LAAR_M16EN, eth_asic_base + WD_LAAR);
                inb(0x84);
        }
+#ifndef        WD_790_PIO
        if (eth_flags & FLAG_790) {
                outb(WD_MSR_MENB, eth_asic_base + WD_MSR);
                inb(0x84);
        }
+#endif
        inb(0x84);
 #endif
        pktoff = next << 8;
@@ -499,10 +529,12 @@
                ret = 1;
        }
 #ifdef INCLUDE_WD
+#ifndef        WD_790_PIO
        if (eth_flags & FLAG_790) {
                outb(0, eth_asic_base + WD_MSR);
                inb(0x84);
        }
+#endif
        if (eth_flags & FLAG_16BIT) {
                outb(eth_laar & ~WD_LAAR_M16EN, eth_asic_base + WD_LAAR);
                inb(0x84);
@@ -592,9 +624,15 @@
        for (i=0; i<ETH_ALEN; i++) {
                nic->node_addr[i] = inb(i+eth_asic_base+WD_LAR);
        }
-       printf("\n%s base %#hx, memory %#hx, addr %!\n",
-               brd->name, eth_asic_base, eth_bmem, nic->node_addr);
+       printf("\n%s base %#hx", brd->name, eth_asic_base);
        if (eth_flags & FLAG_790) {
+#ifdef WD_790_PIO
+               printf(", PIO mode, addr %!\n", nic->node_addr);
+               eth_bmem = 0;
+               eth_flags |= FLAG_PIO;          /* force PIO mode */
+               outb(0, eth_asic_base+WD_MSR);
+#else
+               printf(", memory %#hx, addr %!\n", eth_bmem, nic->node_addr);
                outb(WD_MSR_MENB, eth_asic_base+WD_MSR);
                outb((inb(eth_asic_base+0x04) |
                        0x80), eth_asic_base+0x04);
@@ -603,7 +641,9 @@
                        (inb(eth_asic_base+0x0B) & 0xB0), eth_asic_base+0x0B);
                outb((inb(eth_asic_base+0x04) &
                        ~0x80), eth_asic_base+0x04);
+#endif
        } else {
+               printf(", memory %#hx, addr %!\n", eth_bmem, nic->node_addr);
                outb((((unsigned)eth_bmem >> 13) & 0x3F) | 0x40, 
eth_asic_base+WD_MSR);
        }
        if (eth_flags & FLAG_16BIT) {
@@ -824,6 +864,21 @@
        nic->poll = ns8390_poll;
        nic->transmit = ns8390_transmit;
        nic->disable = ns8390_disable;
+        /* Based on PnP ISA map */
+#if 0
+#ifdef INCLUDE_WD
+        nic->devid.vendor_id = htons(GENERIC_ISAPNP_VENDOR);
+        nic->devid.device_id = htons(0x812a);
+#endif
+#ifdef INCLUDE_3C503
+        nic->devid.vendor_id = htons(GENERIC_ISAPNP_VENDOR);
+        nic->devid.device_id = htons(0x80f3);
+#endif
+#ifdef INCLUDE_NE
+        nic->devid.vendor_id = htons(GENERIC_ISAPNP_VENDOR);
+        nic->devid.device_id = htons(0x80d6);
+#endif
+#endif
        return(nic);
 }
 
-- 
Silence.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]