comparison rathaxes_add_lkm_ethernet_sample.patch @ 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
comparison
equal deleted inserted replaced
40:0ff39df29c46 41:87704b867fb0
35 +ADD_RATHAXES_LKM(lkm lkm_src) 35 +ADD_RATHAXES_LKM(lkm lkm_src)
36 diff --git a/rathaxes/samples/lkm/e1000.blt b/rathaxes/samples/lkm/e1000.blt 36 diff --git a/rathaxes/samples/lkm/e1000.blt b/rathaxes/samples/lkm/e1000.blt
37 new file mode 100644 37 new file mode 100644
38 --- /dev/null 38 --- /dev/null
39 +++ b/rathaxes/samples/lkm/e1000.blt 39 +++ b/rathaxes/samples/lkm/e1000.blt
40 @@ -0,0 +1,267 @@ 40 @@ -0,0 +1,284 @@
41 +with e1000, Ethernet, Socket, PCI, LKM, Log 41 +with e1000, Ethernet, Socket, PCI, LKM, Log
42 +{ 42 +{
43 + template type e1000::Context() 43 + template type e1000::Context()
44 + { 44 + {
45 + chunk LKM::includes() 45 + chunk LKM::includes()
187 + if (!rtx_ether_ctx->hw_ctx.ioaddr) 187 + if (!rtx_ether_ctx->hw_ctx.ioaddr)
188 + { 188 + {
189 + ${Log::info("e1000::create: pci_ioremap_bar failed")}; 189 + ${Log::info("e1000::create: pci_ioremap_bar failed")};
190 + } 190 + }
191 + 191 +
192 + /* Reset the card */
192 + rtx_e1000_print_status(&rtx_ether_ctx->hw_ctx); 193 + rtx_e1000_print_status(&rtx_ether_ctx->hw_ctx);
193 + /* Reset the card */ 194 + udelay(10);
194 + rtx_e1000_register_write32(&rtx_ether_ctx->hw_ctx, E1000_CTRL, E1000_CMD_RST);
195 + rtx_e1000_print_status(&rtx_ether_ctx->hw_ctx);
196 + 195 +
197 + /* Now we can load its mac address */ 196 + /* Now we can load its mac address */
197 + int i = 0;
198 + for (i = 0 /* < this is not generated! */; i < 3; ++i)
199 + {
200 + rtx_e1000_register_write32(&rtx_ether_ctx->hw_ctx, E1000_EEPROM_READ, (i << 8) | 1);
201 +
202 + int value;
203 + /* Should be a do { } while(); but the compiler doesn't do { } while(); yet. */
204 + value = rtx_e1000_register_read32(&rtx_ether_ctx->hw_ctx, E1000_EEPROM_READ);
205 + while ((value & (1 << 4)) == 0)
206 + value = rtx_e1000_register_read32(&rtx_ether_ctx->hw_ctx, E1000_EEPROM_READ);
207 +
208 + rtx_ether_ctx->net_dev->dev_addr[i * 2] = value & 0xff;
209 + rtx_ether_ctx->net_dev->dev_addr[i * 2 + 1] = (value >> 8) & 0xff;
210 + }
211 +
212 + memcpy(rtx_ether_ctx->net_dev->perm_addr,
213 + rtx_ether_ctx->net_dev->dev_addr,
214 + rtx_ether_ctx->net_dev->addr_len);
198 + } 215 + }
199 + 216 +
200 + chunk ::CALL 217 + chunk ::CALL
201 + { 218 + {
202 + } 219 + }