changeset 70:c22a9acf8cd7

wip on e1000 remove even more hardcoded arguments
author Louis Opter <louis@lse.epitech.net>
date Sat, 18 Feb 2012 20:07:34 +0100
parents 8bb53638585b
children 3d37fa01b19c 6e9dcbd120c5
files rathaxes_correctly_use_chunk_and_template_sequences_parameters_in_e1000.patch
diffstat 1 files changed, 176 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/rathaxes_correctly_use_chunk_and_template_sequences_parameters_in_e1000.patch	Sat Feb 18 18:13:36 2012 +0100
+++ b/rathaxes_correctly_use_chunk_and_template_sequences_parameters_in_e1000.patch	Sat Feb 18 20:07:34 2012 +0100
@@ -45,9 +45,9 @@
 +            /*
 +             * PCI init stuff:
 +             *
-+             * Some of that code should be moved in the PCI blts, also at some
-+             * point maybe we could do that completely automatically in the PCI
-+             * blts.
++             * Some of that code should certainly be moved in the PCI/Ethernet
++             * blts, also at some point maybe we could do that completely
++             * automatically in the PCI/Ethernet blts.
 +             */
 +
 +            /*
@@ -150,6 +150,15 @@
          }
  
          chunk   ::CALL
+@@ -215,7 +232,7 @@
+         }
+     }
+ 
+-    template sequence   e1000::print_status()
++    template sequence   e1000::print_status(Ethernet::Device ctx)
+     {
+         chunk   LKM::prototypes()
+         {
 @@ -227,7 +244,7 @@
              static void rtx_e1000_print_status(struct rtx_e1000_ctx *ctx)
              {
@@ -159,7 +168,15 @@
                  pr_info("\tRegister value: 0x%x\n", status);
                  pr_info("\tMode: %s\n", (status & 1) ? "Full": "Half");
                  pr_info("\tLink: %s\n", (status & 2) ? "Up" : "Down");
-@@ -275,7 +292,7 @@
+@@ -238,6 +255,7 @@
+ 
+         chunk   ::CALL
+         {
++            rtx_e1000_print_status(&${ctx}->hw_ctx);
+         }
+     }
+ 
+@@ -275,7 +293,7 @@
  
          chunk   ::CALL()
          {
@@ -168,16 +185,25 @@
          }
      }
  
-@@ -296,7 +313,7 @@
+@@ -294,9 +312,9 @@
+             }
+         }
  
-         chunk   ::CALL()
+-        chunk   ::CALL()
++        chunk   ::CALL
          {
 -            rtx_e1000_register_write32(&${ctx}, ${reg_offset});
 +            rtx_e1000_register_write32(${ctx}, ${reg_offset});
          }
      }
  
-@@ -320,12 +337,13 @@
+@@ -315,17 +333,18 @@
+             }
+         }
+ 
+-        chunk   ::CALL()
++        chunk   ::CALL
+         {
          }
      }
  
@@ -192,7 +218,7 @@
          chunk   LKM::prototypes()
          {
              static int e1000_setup_interrupt_handler(struct rtx_ethernet_dev *);
-@@ -345,20 +363,20 @@
+@@ -345,20 +364,20 @@
  
                  if (error)
                  {
@@ -216,15 +242,87 @@
                  if (error)
                  {
                      return error;
-@@ -423,7 +441,7 @@
-             intr = rtx_e1000_register_read32(ctx, E1000_ICR);
-             if (intr & E1000_INTR_LSC)
+@@ -367,7 +386,7 @@
+         }
+     }
+ 
+-    template sequence   e1000::free_interrupt_handler()
++    template sequence   e1000::free_interrupt_handler(Ethernet::Device ctx)
+     {
+         chunk   LKM::prototypes()
+         {
+@@ -378,22 +397,21 @@
+         {
+             static void e1000_free_interrupt_handler(struct rtx_ethernet_dev *ethernet_ctx)
              {
+-
+                 free_irq(ethernet_ctx->hw_ctx.irq, ethernet_ctx);
+             }
+         }
+ 
+-        chunk ::CALL()
++        chunk ::CALL
+         {
+-            e1000_free_interrupt_handler(rtx_ether_dev);
++            e1000_free_interrupt_handler(${ctx});
+         }
+     }
+ 
+-    template sequence   e1000::activate_device_interruption()
++    template sequence   e1000::activate_device_interruption(Ethernet::Device ctx)
+     {
+-        chunk  ::CALL()
++        chunk  ::CALL
+         {
+-            rtx_e1000_register_write32(ctx, E1000_IMS,
++            rtx_e1000_register_write32(&${ctx}->hw_ctx, E1000_IMS,
+                                        E1000_INTR_TXDW |
+                                        E1000_INTR_TXQE |
+                                        E1000_INTR_LSC  |
+@@ -402,11 +420,11 @@
+         }
+     }
+ 
+-    template sequence   e1000::set_up_device()
++    template sequence   e1000::set_up_device(Ethernet::Device ctx)
+     {
+-        chunk  ::CALL()
++        chunk  ::CALL
+         {
+-            rtx_e1000_register_set32(ctx, E1000_CTRL,
++            rtx_e1000_register_set32(&${ctx}->hw_ctx, E1000_CTRL,
+                                      E1000_CMD_ASDE |
+                                      E1000_CMD_SLU  |
+                                      E1000_CMD_LRST |
+@@ -414,20 +432,20 @@
+         }
+     }
+ 
+-    template sequence   e1000::handle_intr()
++    template sequence   e1000::handle_interrupt(Ethernet::Device ctx)
+     {
+-        chunk   ::CALL()
++        chunk   ::CALL
+         {
+             int intr;
+ 
+-            intr = rtx_e1000_register_read32(ctx, E1000_ICR);
+-            if (intr & E1000_INTR_LSC)
+-            {
 -                ${Log::info("Link status changed")};
-+                ${Log::info("cable link status changed")};
+-            }
+-
++            intr = rtx_e1000_register_read32(&${ctx}->hw_ctx, E1000_ICR);
+             if (intr)
+             {
++                if (intr & E1000_INTR_LSC)
++                {
++                    ${Log::info("cable link status changed")};
++                }
++
+                 return IRQ_HANDLED;
              }
- 
-             if (intr)
+         }
 diff --git a/rathaxes/samples/e1000/e1000.rti b/rathaxes/samples/e1000/e1000.rti
 --- a/rathaxes/samples/e1000/e1000.rti
 +++ b/rathaxes/samples/e1000/e1000.rti
@@ -259,7 +357,15 @@
          provided chunk  Ethernet::destroy_device;
          provided chunk  ::CALL;
      }
-@@ -35,9 +32,9 @@
+@@ -28,44 +25,43 @@
+      * This should take an e1000::Context as the first argument but this was
+      * not working as wished.
+      */
+-    provided sequence   e1000::print_status()
++    provided sequence   e1000::print_status(Ethernet::Device)
+     {
+         provided chunk  LKM::prototypes;
+         provided chunk  LKM::code;
          provided chunk  ::CALL;
      }
  
@@ -271,6 +377,38 @@
          provided chunk  LKM::prototypes;
          provided chunk  LKM::code;
          provided chunk  ::CALL;
+     }
+ 
+-    provided sequence   e1000::free_interrupt_handler()
++    provided sequence   e1000::free_interrupt_handler(Ethernet::Device)
+     {
+         provided chunk  LKM::prototypes;
+         provided chunk  LKM::code;
+         provided chunk  ::CALL;
+     }
+ 
+-    provided sequence   e1000::activate_device_interruption()
++    provided sequence   e1000::activate_device_interruption(Ethernet::Device)
+     {
+         provided chunk  ::CALL;
+     }
+ 
+-    provided sequence   e1000::set_up_device()
++    provided sequence   e1000::set_up_device(Ethernet::Device)
+     {
+         provided chunk  ::CALL;
+     }
+ 
+-    provided sequence   e1000::handle_intr()
++    provided sequence   e1000::handle_interrupt(Ethernet::Device)
+     {
+         provided chunk  ::CALL;
+     }
+ 
+-
+     provided sequence   e1000::register_read32(e1000::Context, e1000::Register)
+     {
+         provided chunk  LKM::prototypes;
 diff --git a/rathaxes/samples/e1000/ethernet.blt b/rathaxes/samples/e1000/ethernet.blt
 --- a/rathaxes/samples/e1000/ethernet.blt
 +++ b/rathaxes/samples/e1000/ethernet.blt
@@ -341,7 +479,7 @@
              static int  rtx_ethernet_xmit(struct sk_buff* skb, struct net_device *dev)
              {
 -                ${pointcut ::IMPLEMENTATION};
-+                ${pointcut ::IMPLEMENTATION(local.skb, local.dev)};
++                ${pointcut ::IMPLEMENTATION(local.dev, local.skb)};
  
                  return 0;
              }
@@ -514,32 +652,47 @@
 diff --git a/rathaxes/samples/e1000/lkm.rtx b/rathaxes/samples/e1000/lkm.rtx
 --- a/rathaxes/samples/e1000/lkm.rtx
 +++ b/rathaxes/samples/e1000/lkm.rtx
-@@ -2,50 +2,50 @@
+@@ -2,50 +2,61 @@
  {
      Ethernet::open(Ethernet::Device dev)
      {
 -        Log::info("Open the device");
 -        e1000::setup_interrupt_handler();
 -        Log::info("Interrupt handler installed");
-+        Log::info("open the device");
+-        e1000::set_up_device();
+-        e1000::activate_device_interruption();
++        Log::info("opening the device");
++
++        /*
++         * Maybe e1000::create_device should be called from here, to be
++         * more coherent.
++         */
++
 +        e1000::setup_interrupt_handler(dev);
 +        Log::info("interrupt handler installed");
-         e1000::set_up_device();
-         e1000::activate_device_interruption();
++
++        e1000::set_up_device(dev);
++        Log::info("device activated");
++
++        e1000::activate_device_interruption(dev);
++
++        e1000::print_status(dev);
      }
  
      Ethernet::close(Ethernet::Device dev)
      {
 -        Log::info("Close the device");
-+        Log::info("close the device");
-         e1000::free_interrupt_handler();
+-        e1000::free_interrupt_handler();
++        Log::info("closing the device");
++        e1000::free_interrupt_handler(dev);
      }
  
      Ethernet::interrupt_handler(Ethernet::Device dev)
      {
 -        Log::info("Got an interruption");
+-        e1000::handle_intr();
 +        Log::info("got an interruption");
-         e1000::handle_intr();
++        e1000::handle_interrupt(dev);
      }
  
      Ethernet::send(Ethernet::Device dev, Socket::SKBuff skb)