comparison rathaxes_correctly_use_chunk_and_template_sequences_parameters_in_e1000.patch @ 65:e77a4126576c

WIP e1000 sample
author Louis Opter <louis@lse.epitech.net>
date Sat, 18 Feb 2012 15:25:42 +0100
parents 8dc1a3bf372a
children b916396fc577
comparison
equal deleted inserted replaced
64:8dc1a3bf372a 65:e77a4126576c
148 + iounmap(${rtx_ether_ctx}->hw_ctx.ioaddr); 148 + iounmap(${rtx_ether_ctx}->hw_ctx.ioaddr);
149 + pci_release_selected_regions(${pdev}, ${rtx_ether_ctx}->hw_ctx.bars); 149 + pci_release_selected_regions(${pdev}, ${rtx_ether_ctx}->hw_ctx.bars);
150 } 150 }
151 151
152 chunk ::CALL 152 chunk ::CALL
153 @@ -227,7 +244,7 @@
154 static void rtx_e1000_print_status(struct rtx_e1000_ctx *ctx)
155 {
156 unsigned int status = rtx_e1000_register_read32(ctx, E1000_STATUS);
157 - pr_info("rtx_e1000 status: \n");
158 + pr_info("card status: \n");
159 pr_info("\tRegister value: 0x%x\n", status);
160 pr_info("\tMode: %s\n", (status & 1) ? "Full": "Half");
161 pr_info("\tLink: %s\n", (status & 2) ? "Up" : "Down");
153 @@ -275,7 +292,7 @@ 162 @@ -275,7 +292,7 @@
154 163
155 chunk ::CALL() 164 chunk ::CALL()
156 { 165 {
157 - rtx_e1000_register_read32(&${ctx}, ${reg_offset}); 166 - rtx_e1000_register_read32(&${ctx}, ${reg_offset});
175 - template sequence e1000::setup_interrupt_handler() 184 - template sequence e1000::setup_interrupt_handler()
176 + template sequence e1000::setup_interrupt_handler(Ethernet::Device ctx) 185 + template sequence e1000::setup_interrupt_handler(Ethernet::Device ctx)
177 { 186 {
178 chunk LKM::includes() 187 chunk LKM::includes()
179 { 188 {
180 @@ -352,13 +369,13 @@ 189 @@ -345,20 +362,20 @@
190
191 if (error)
192 {
193 - ${Log::info("Cannot register the interruption")};
194 + ${Log::info("cannot register the interrupt handler")};
195 }
196
197 return error;
181 } 198 }
182 } 199 }
183 200
184 - chunk ::CALL() 201 - chunk ::CALL()
185 + chunk ::CALL 202 + chunk ::CALL
191 - error = e1000_setup_interrupt_handler(rtx_ether_dev); 208 - error = e1000_setup_interrupt_handler(rtx_ether_dev);
192 + error = e1000_setup_interrupt_handler(${ctx}); 209 + error = e1000_setup_interrupt_handler(${ctx});
193 if (error) 210 if (error)
194 { 211 {
195 return error; 212 return error;
213 @@ -423,7 +440,7 @@
214 intr = rtx_e1000_register_read32(ctx, E1000_ICR);
215 if (intr & E1000_INTR_LSC)
216 {
217 - ${Log::info("Link status changed")};
218 + ${Log::info("cable link status changed")};
219 }
220
221 if (intr)
196 diff --git a/rathaxes/samples/e1000/e1000.rti b/rathaxes/samples/e1000/e1000.rti 222 diff --git a/rathaxes/samples/e1000/e1000.rti b/rathaxes/samples/e1000/e1000.rti
197 --- a/rathaxes/samples/e1000/e1000.rti 223 --- a/rathaxes/samples/e1000/e1000.rti
198 +++ b/rathaxes/samples/e1000/e1000.rti 224 +++ b/rathaxes/samples/e1000/e1000.rti
199 @@ -1,25 +1,22 @@ 225 @@ -1,25 +1,22 @@
200 interface e1000 : Socket, Ethernet, PCI, LKM 226 interface e1000 : Socket, Ethernet, PCI, LKM
311 - template sequence Ethernet::init(PCI::Device pdev) 337 - template sequence Ethernet::init(PCI::Device pdev)
312 + template sequence Ethernet::init() 338 + template sequence Ethernet::init()
313 { 339 {
314 chunk LKM::data() 340 chunk LKM::data()
315 { 341 {
316 @@ -133,18 +151,20 @@ 342 @@ -133,83 +151,75 @@
317 }; 343 };
318 } 344 }
319 345
320 - chunk PCI::pci_probe_hook() 346 - chunk PCI::pci_probe_hook()
321 + /* For now the type is not handled, so we just omit it (see #17) */ 347 + /* For now the type is not handled, so we just omit it (see #17) */
336 - error = 0; 362 - error = 0;
337 + /* Initialize the net_device structure */ 363 + /* Initialize the net_device structure */
338 net_dev = alloc_etherdev(sizeof(*rtx_ether_ctx)); 364 net_dev = alloc_etherdev(sizeof(*rtx_ether_ctx));
339 if (net_dev == 0) 365 if (net_dev == 0)
340 { 366 {
341 @@ -152,64 +172,54 @@ 367 - ${Log::info("Cannot allocate memory")};
368 + ${Log::info("cannot allocate memory")};
342 /* 369 /*
343 * Again, the error should be "raised" in the parent context. 370 * Again, the error should be "raised" in the parent context.
344 * 371 *
345 - * Here we know that we should return ENOMEM because *we* wrote 372 - * Here we know that we should return ENOMEM because *we* wrote
346 + * Here we know that we can return ENOMEM because *we* wrote 373 + * Here we know that we can return ENOMEM because *we* wrote
372 - net_dev->netdev_ops = &rtx_ether_ops; 399 - net_dev->netdev_ops = &rtx_ether_ops;
373 - if ((error = register_netdev(net_dev))) 400 - if ((error = register_netdev(net_dev)))
374 + error = register_netdev(net_dev); 401 + error = register_netdev(net_dev);
375 + if (error) 402 + if (error)
376 { 403 {
377 ${Log::info("Cannot register the driver")}; 404 - ${Log::info("Cannot register the driver")};
405 + ${Log::info("cannot register the driver in the net subsystem")};
378 return error; 406 return error;
379 } 407 }
380 408
381 - /* same problem as above with ${pdev} */ 409 - /* same problem as above with ${pdev} */
382 - //pci_set_drvdata(${pdev}, net_dev); 410 - //pci_set_drvdata(${pdev}, net_dev);
452 provided pointcut Ethernet::destroy_device; 480 provided pointcut Ethernet::destroy_device;
453 } 481 }
454 diff --git a/rathaxes/samples/e1000/lkm.rtx b/rathaxes/samples/e1000/lkm.rtx 482 diff --git a/rathaxes/samples/e1000/lkm.rtx b/rathaxes/samples/e1000/lkm.rtx
455 --- a/rathaxes/samples/e1000/lkm.rtx 483 --- a/rathaxes/samples/e1000/lkm.rtx
456 +++ b/rathaxes/samples/e1000/lkm.rtx 484 +++ b/rathaxes/samples/e1000/lkm.rtx
457 @@ -3,7 +3,7 @@ 485 @@ -2,44 +2,44 @@
486 {
458 Ethernet::open(Ethernet::Device dev) 487 Ethernet::open(Ethernet::Device dev)
459 { 488 {
460 Log::info("Open the device"); 489 - Log::info("Open the device");
461 - e1000::setup_interrupt_handler(); 490 - e1000::setup_interrupt_handler();
491 - Log::info("Interrupt handler installed");
492 + Log::info("open the device");
462 + e1000::setup_interrupt_handler(dev); 493 + e1000::setup_interrupt_handler(dev);
463 Log::info("Interrupt handler installed"); 494 + Log::info("interrupt handler installed");
464 e1000::set_up_device(); 495 e1000::set_up_device();
465 e1000::activate_device_interruption(); 496 e1000::activate_device_interruption();
497 }
498
499 Ethernet::close(Ethernet::Device dev)
500 {
501 - Log::info("Close the device");
502 + Log::info("close the device");
503 e1000::free_interrupt_handler();
504 }
505
506 Ethernet::interrupt_handler(Ethernet::Device dev)
507 {
508 - Log::info("Got an interruption");
509 + Log::info("got an interruption");
510 e1000::handle_intr();
511 }
512
513 Ethernet::send(Ethernet::Device dev, Socket::SKBuff skb)
514 {
515 - Log::info("We have one packet to transmit!");
516 + Log::info("we have one packet to transmit!");
517 }
518
519 LKM::init()
520 {
521 - Log::info("Hello this is LKM");
522 + Log::info("loading module");
523 }
524
525 LKM::exit()
526 {
527 - Log::info("Good bye this was LKM");
528 + Log::info("unloading module");
529 }
530 }
531
532 configuration
533 {
534 - LKM::name = "hello";
535 + LKM::name = "rtx_e1k";
536 LKM::author = "Rathaxes";
537 LKM::description = "Hello World Loadable Kernel Module (LKM)";
538 LKM::license = "GPL";
539 diff --git a/rathaxes/samples/e1000/log.blt b/rathaxes/samples/e1000/log.blt
540 --- a/rathaxes/samples/e1000/log.blt
541 +++ b/rathaxes/samples/e1000/log.blt
542 @@ -4,7 +4,7 @@
543 {
544 chunk ::CALL
545 {
546 - pr_info("%s\n", ${msg});
547 + pr_info("%s: %s\n", ${config.name}, ${msg});
548 }
549 }
550 }
466 diff --git a/rathaxes/samples/e1000/pci.blt b/rathaxes/samples/e1000/pci.blt 551 diff --git a/rathaxes/samples/e1000/pci.blt b/rathaxes/samples/e1000/pci.blt
467 --- a/rathaxes/samples/e1000/pci.blt 552 --- a/rathaxes/samples/e1000/pci.blt
468 +++ b/rathaxes/samples/e1000/pci.blt 553 +++ b/rathaxes/samples/e1000/pci.blt
469 @@ -22,7 +22,7 @@ 554 @@ -22,7 +22,7 @@
470 } 555 }