changeset 41:87704b867fb0

First attempt at loading the mac address
author Louis Opter <louis@lse.epitech.net>
date Sun, 08 Jan 2012 16:49:38 +0100
parents 0ff39df29c46
children e0cd016d4fc5
files rathaxes_add_lkm_ethernet_sample.patch
diffstat 1 files changed, 21 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/rathaxes_add_lkm_ethernet_sample.patch	Sun Jan 08 15:52:18 2012 +0100
+++ b/rathaxes_add_lkm_ethernet_sample.patch	Sun Jan 08 16:49:38 2012 +0100
@@ -37,7 +37,7 @@
 new file mode 100644
 --- /dev/null
 +++ b/rathaxes/samples/lkm/e1000.blt
-@@ -0,0 +1,267 @@
+@@ -0,0 +1,284 @@
 +with e1000, Ethernet, Socket, PCI, LKM, Log
 +{
 +    template type   e1000::Context()
@@ -189,12 +189,29 @@
 +                ${Log::info("e1000::create: pci_ioremap_bar failed")};
 +            }
 +
++            /* Reset the card */
 +            rtx_e1000_print_status(&rtx_ether_ctx->hw_ctx);
-+            /* Reset the card */
-+            rtx_e1000_register_write32(&rtx_ether_ctx->hw_ctx, E1000_CTRL, E1000_CMD_RST);
-+            rtx_e1000_print_status(&rtx_ether_ctx->hw_ctx);
++            udelay(10);
 +
 +            /* Now we can load its mac address */
++            int i = 0;
++            for (i = 0 /* < this is not generated! */; i < 3; ++i)
++            {
++                rtx_e1000_register_write32(&rtx_ether_ctx->hw_ctx, E1000_EEPROM_READ, (i << 8) | 1);
++
++                int value;
++                /* Should be a do { } while(); but the compiler doesn't do { } while(); yet. */
++                value = rtx_e1000_register_read32(&rtx_ether_ctx->hw_ctx, E1000_EEPROM_READ);
++                while ((value & (1 << 4)) == 0)
++                    value = rtx_e1000_register_read32(&rtx_ether_ctx->hw_ctx, E1000_EEPROM_READ);
++
++                rtx_ether_ctx->net_dev->dev_addr[i * 2] = value & 0xff;
++                rtx_ether_ctx->net_dev->dev_addr[i * 2 + 1] = (value >> 8) & 0xff;
++            }
++
++            memcpy(rtx_ether_ctx->net_dev->perm_addr,
++                   rtx_ether_ctx->net_dev->dev_addr,
++                   rtx_ether_ctx->net_dev->addr_len);
 +        }
 +
 +        chunk ::CALL