changeset 14:4aac69287060

Fixes + comment in the Ethernet part
author Louis Opter <louis@lse.epitech.net>
date Fri, 06 Jan 2012 19:09:16 +0100
parents d00a5829811d
children 74d9d18d4732
files rathaxes_start_to_implement_the_ethernet_subsystem_in_the_lkm.patch
diffstat 1 files changed, 71 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/rathaxes_start_to_implement_the_ethernet_subsystem_in_the_lkm.patch	Fri Jan 06 18:08:41 2012 +0100
+++ b/rathaxes_start_to_implement_the_ethernet_subsystem_in_the_lkm.patch	Fri Jan 06 19:09:16 2012 +0100
@@ -1,10 +1,10 @@
 # HG changeset patch
-# Parent 6d15ec109487b733721b6dbe84c27841f441e196
+# Parent 93035f60f6725e2e0f25dcb5276c45d3a44d12fa
 rathaxes: start to implement the Ethernet subsystem in linux LKM sample
 
-diff -r 6d15ec109487 rathaxes/samples/lkm/CMakeLists.txt
---- a/rathaxes/samples/lkm/CMakeLists.txt	Fri Jan 06 17:34:47 2012 +0100
-+++ b/rathaxes/samples/lkm/CMakeLists.txt	Fri Jan 06 18:06:48 2012 +0100
+diff --git a/rathaxes/samples/lkm/CMakeLists.txt b/rathaxes/samples/lkm/CMakeLists.txt
+--- a/rathaxes/samples/lkm/CMakeLists.txt
++++ b/rathaxes/samples/lkm/CMakeLists.txt
 @@ -1,6 +1,6 @@
  ADD_RATHAXES_SOURCES(lkm lkm.rtx
 -                     RTI log.rti lkm.rti pci.rti
@@ -14,10 +14,11 @@
  
  # We can't name lkm since it's already used as the target name to generate the
  # source (with ADD_RATHAXES_SOURCES).
-diff -r 6d15ec109487 rathaxes/samples/lkm/ethernet.blt
---- /dev/null	Thu Jan 01 00:00:00 1970 +0000
-+++ b/rathaxes/samples/lkm/ethernet.blt	Fri Jan 06 18:06:48 2012 +0100
-@@ -0,0 +1,135 @@
+diff --git a/rathaxes/samples/lkm/ethernet.blt b/rathaxes/samples/lkm/ethernet.blt
+new file mode 100644
+--- /dev/null
++++ b/rathaxes/samples/lkm/ethernet.blt
+@@ -0,0 +1,144 @@
 +with Ethernet, PCI, LKM
 +{
 +    template type   Ethernet::Device()
@@ -57,6 +58,8 @@
 +            static int  rtx_ethernet_open(struct net_device *dev)
 +            {
 +                ${pointcut ::IMPLEMENTATION};
++
++                return 0;
 +            }
 +        }
 +    }
@@ -65,14 +68,16 @@
 +    {
 +        chunk LKM::prototypes()
 +        {
-+            static int  rtx_ethernet_close(struct net_device );
++            static int  rtx_ethernet_close(struct net_device *);
 +        }
 +
 +        chunk LKM::code()
 +        {
-+            static int  rtx_ethernet_close(struct net_device dev)
++            static int  rtx_ethernet_close(struct net_device *dev)
 +            {
 +                ${pointcut ::IMPLEMENTATION};
++
++                return 0;
 +            }
 +        }
 +    }
@@ -94,6 +99,8 @@
 +            static enum irqreturn   rtx_ethernet_interrupt_handler(int irq, void *dev_id)
 +            {
 +                ${pointcut ::IMPLEMENTATION};
++
++                return IRQ_NONE;
 +            }
 +        }
 +    }
@@ -108,11 +115,12 @@
 +             */
 +            typedef int ${Ethernet::Device};
 +
-+            static ${Ethernet::Device} *rtx_net_dev = NULL;
-+            static const struct net_device_ops rtx_ether_ops= {
++            static ${Ethernet::Device}          *rtx_net_dev = NULL;
++            static const struct net_device_ops  rtx_ether_ops =
++            {
 +                .ndo_open = rtx_ethernet_open,
 +                .ndo_stop = rtx_ethernet_close,
-+                .ndo_start_xmit = NULL, // XXX: 
++                .ndo_start_xmit = NULL,
 +            };
 +
 +        }
@@ -120,7 +128,7 @@
 +        chunk ::CALL
 +        {
 +            /*
-+             * int should be replaced by the sizeof an hypothetic "context"
++             * int should be replaced by the sizeof of an hypothetic "context"
 +             * structure defined in the front-end.
 +             */
 +            rtx_net_dev = alloc_etherdev(sizeof(int));
@@ -132,11 +140,13 @@
 +             */
 +
 +            /*
-+             * Does not work atm
++             * The substitution of ${dev} fails here. I also tried to add a
++             * "substitute method" to the PCI::Device that was just doing
++             * "${self}" but it didn't work either (it was subsituted by a
++             * placeholder, e.g: _1).
 +             */
-+            // -> this is the problem, dev cannot be resolved ${dev} = 0;
-+            // SET_NETDEV_DEV(rtx_net_dev, &${dev}->dev);
-+            rtx_net_dev->netdev_ops = rtx_ether_ops;
++            //SET_NETDEV_DEV(rtx_net_dev, &${dev}->dev);
++            rtx_net_dev->netdev_ops = &rtx_ether_ops;
 +
 +            /* if (*/register_netdev(rtx_net_dev);/*)*/
 +            /* {
@@ -153,9 +163,10 @@
 +        }
 +    }
 +}
-diff -r 6d15ec109487 rathaxes/samples/lkm/ethernet.rti
---- /dev/null	Thu Jan 01 00:00:00 1970 +0000
-+++ b/rathaxes/samples/lkm/ethernet.rti	Fri Jan 06 18:06:48 2012 +0100
+diff --git a/rathaxes/samples/lkm/ethernet.rti b/rathaxes/samples/lkm/ethernet.rti
+new file mode 100644
+--- /dev/null
++++ b/rathaxes/samples/lkm/ethernet.rti
 @@ -0,0 +1,33 @@
 +interface Ethernet : PCI, LKM
 +{
@@ -190,9 +201,9 @@
 +        provided chunk  ::CALL;
 +    }
 +}
-diff -r 6d15ec109487 rathaxes/samples/lkm/lkm.rtx
---- a/rathaxes/samples/lkm/lkm.rtx	Fri Jan 06 17:34:47 2012 +0100
-+++ b/rathaxes/samples/lkm/lkm.rtx	Fri Jan 06 18:06:48 2012 +0100
+diff --git a/rathaxes/samples/lkm/lkm.rtx b/rathaxes/samples/lkm/lkm.rtx
+--- a/rathaxes/samples/lkm/lkm.rtx
++++ b/rathaxes/samples/lkm/lkm.rtx
 @@ -1,13 +1,24 @@
  device LKM use LKM, PCI, Log
  {
@@ -220,9 +231,9 @@
      }
  
      LKM::init()
-diff -r 6d15ec109487 rathaxes/samples/lkm/pci.blt
---- a/rathaxes/samples/lkm/pci.blt	Fri Jan 06 17:34:47 2012 +0100
-+++ b/rathaxes/samples/lkm/pci.blt	Fri Jan 06 18:06:48 2012 +0100
+diff --git a/rathaxes/samples/lkm/pci.blt b/rathaxes/samples/lkm/pci.blt
+--- a/rathaxes/samples/lkm/pci.blt
++++ b/rathaxes/samples/lkm/pci.blt
 @@ -11,15 +11,12 @@
  
          chunk   ::decl()
@@ -241,7 +252,24 @@
          }
  
          map
-@@ -40,11 +37,7 @@
+@@ -27,6 +24,16 @@
+         }
+     }
+ 
++    /*
++     * The PCI::probe sequence is a "required" sequence which means that its
++     * implementation will be done in the .rtx. Here we just define the context
++     * were this implementation will be inserted. The implementation should be
++     * able to access to the struct pci_dev (here marked as the "argument"
++     * PCI::Device). How do we bind this PCI::Device argument with the pdev
++     * struct pci_dev pointer defined in the LKM::code chunk?
++     *
++     * The only thing I can imagine is: ${pointcut ::IMPLEMENTATION(pdev)};
++     */
+     template sequence   PCI::probe(PCI::Device dev)
+     {
+         chunk LKM::prototypes()
+@@ -40,11 +47,7 @@
              static int /* __devinit */  rtx_pci_probe(struct pci_dev *pdev,
                                                        const struct pci_device_id *pdev_id)
              {
@@ -253,7 +281,7 @@
  
                  err = pci_enable_device(pdev);
  //              if (err < 0) /* `if' doesn't work */
-@@ -52,8 +45,6 @@
+@@ -52,8 +55,6 @@
  
                  ${pointcut ::IMPLEMENTATION};
  
@@ -262,3 +290,17 @@
                  return 0;
  
                  fail:
+@@ -88,9 +89,10 @@
+              * CNorm doesn't seem to like "dynamic" arrays (i.e: you always
+              * have to specify the exact size).
+              */
+-            static struct pci_device_id	rtx_pci_device_table[2] = {
+-                { ${config.vendor_id}, ${config.product_id}, 0, PCI_ANY_ID, PCI_ANY_ID },
+-                { 0, }
++            static struct pci_device_id	rtx_pci_device_table[2] =
++            {
++                { ${config.vendor_id}, ${config.product_id}, PCI_ANY_ID, PCI_ANY_ID },
++                { 0, } /* Doesn't work with just { } */
+             };
+ 
+             static struct pci_driver rtx_pci_driver = {