changeset 36:791c7fa1f055

Merge
author Louis Opter <louis@lse.epitech.net>
date Sun, 08 Jan 2012 01:10:20 +0100
parents 29c22fa5ec20 (current diff) 62fba8b9db06 (diff)
children 9433dec37a52
files rathaxes_add_a_patch_to_illustrate_issue_8.patch series
diffstat 5 files changed, 449 insertions(+), 86 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/e1000_rework_without_explicit_call.patch	Sun Jan 08 01:10:20 2012 +0100
@@ -0,0 +1,143 @@
+# HG changeset patch
+# Parent 1cfa6a46c673fae191ce982e2ebd471f9a53ee90
+rathaxes: initialize the e1000 sepcific code in an elegant implicit way
+
+diff -r 1cfa6a46c673 rathaxes/samples/lkm/e1000.blt
+--- a/rathaxes/samples/lkm/e1000.blt	Sun Jan 08 01:01:14 2012 +0100
++++ b/rathaxes/samples/lkm/e1000.blt	Sun Jan 08 01:02:13 2012 +0100
+@@ -27,9 +27,9 @@
+         }
+     }
+ 
+-    template sequence   e1000::create()
++    template sequence   e1000::create_device()
+     {
+-        chunk ::CALL
++        chunk Ethernet::create_device()
+         {
+             rtx_ether_ctx->hw_ctx.bars = pci_select_bars(pdev, IORESOURCE_MEM);
+             if (pci_enable_device_mem(pdev))
+@@ -54,18 +54,25 @@
+                 ${Log::info("e1000::create: pci_ioremap_bar failed")};
+             }
+         }
++
++        chunk ::CALL
++        {
++        }
+     }
+ 
+-    template sequence   e1000::destroy()
++    template sequence   e1000::destroy_device()
+     {
+-        chunk ::CALL
++        chunk   Ethernet::destroy_device
+         {
+             // XXX: add a check in order to avoid freeing none allocated
+             // resources.
+             struct rtx_ethernet_dev* rtx_ether_ctx = netdev_priv(net_dev);
+             iounmap(rtx_ether_ctx->hw_ctx.ioaddr);
+             pci_release_selected_regions(pdev, rtx_ether_ctx->hw_ctx.bars);
+-            pci_release_region(pdev, 0);
++        }
++
++        chunk   ::CALL
++        {
+         }
+     }
+ }
+diff -r 1cfa6a46c673 rathaxes/samples/lkm/e1000.rti
+--- a/rathaxes/samples/lkm/e1000.rti	Sun Jan 08 01:01:14 2012 +0100
++++ b/rathaxes/samples/lkm/e1000.rti	Sun Jan 08 01:02:13 2012 +0100
+@@ -3,13 +3,15 @@
+     provided type   e1000::Context;
+ 
+     /* Not sure if we need the argument */
+-    provided sequence   e1000::create()
++    provided sequence   e1000::create_device()
+     {
++        provided chunk  Ethernet::create_device;
+         provided chunk  ::CALL;
+     }
+ 
+-    provided sequence   e1000::destroy()
++    provided sequence   e1000::destroy_device()
+     {
++        provided chunk  Ethernet::destroy_device;
+         provided chunk  ::CALL;
+     }
+ }
+diff -r 1cfa6a46c673 rathaxes/samples/lkm/ethernet.blt
+--- a/rathaxes/samples/lkm/ethernet.blt	Sun Jan 08 01:01:14 2012 +0100
++++ b/rathaxes/samples/lkm/ethernet.blt	Sun Jan 08 01:02:13 2012 +0100
+@@ -173,6 +173,7 @@
+             /* same problem as above with ${pdev} */
+             //pci_set_drvdata(${pdev}, net_dev);
+             pci_set_drvdata(pdev, net_dev);
++            ${pointcut Ethernet::create_device};
+         }
+ 
+         chunk   ::CALL
+@@ -186,6 +187,8 @@
+         {
+             struct net_device *net_dev = pci_get_drvdata(pdev);
+ 
++            ${pointcut Ethernet::destroy_device};
++
+             unregister_netdev(net_dev);
+             /*
+              * If we had some cleanup todo with struct rtx_ether_ctx we would
+diff -r 1cfa6a46c673 rathaxes/samples/lkm/ethernet.rti
+--- a/rathaxes/samples/lkm/ethernet.rti	Sun Jan 08 01:01:14 2012 +0100
++++ b/rathaxes/samples/lkm/ethernet.rti	Sun Jan 08 01:02:13 2012 +0100
+@@ -33,6 +33,8 @@
+         provided chunk  LKM::data;
+         provided chunk  PCI::pci_probe_hook;
+         provided chunk  ::CALL;
++
++        provided pointcut   Ethernet::create_device;
+     }
+ 
+     /* Likely extends PCI::remove */
+@@ -40,5 +42,7 @@
+     {
+         provided chunk  ::CALL;
+         provided chunk  PCI::pci_remove_hook;
++
++        provided pointcut   Ethernet::destroy_device;
+     }
+ }
+diff -r 1cfa6a46c673 rathaxes/samples/lkm/lkm.rtx
+--- a/rathaxes/samples/lkm/lkm.rtx	Sun Jan 08 01:01:14 2012 +0100
++++ b/rathaxes/samples/lkm/lkm.rtx	Sun Jan 08 01:02:13 2012 +0100
+@@ -20,30 +20,14 @@
+         Log::info("We have one packet to transmit!");
+     }
+ 
+-//    PCI::probe(PCI::Device dev)
+-//    {
+-//        Log::info("Probe the device");
+-//        Ethernet::init(dev);
+-//        e1000::create();
+-//    }
+-
+-//    PCI::remove(PCI::Device dev)
+-//    {
+-//        Log::info("Remove the pci device");
+-//        e1000::destroy();
+-//        Ethernet::exit(dev);
+-//    }
+-
+     LKM::init()
+     {
+         Log::info("Hello this is LKM");
+-        // PCI::register();
+     }
+ 
+     LKM::exit()
+     {
+         Log::info("Good bye this was LKM");
+-        // PCI::unregister();
+     }
+ }
+ 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ethernet_rework_without_explicit_call.patch	Sun Jan 08 01:10:20 2012 +0100
@@ -0,0 +1,180 @@
+# HG changeset patch
+# Parent 4920b3a97ad6f031437c63ca3ae756678fde92a3
+rathaxes: initialize the ethernet subsystem in an elegant implicit way
+
+diff -r 4920b3a97ad6 -r c3265ca219d5 rathaxes/samples/lkm/e1000.blt
+--- a/rathaxes/samples/lkm/e1000.blt	Sat Jan 07 23:09:24 2012 +0100
++++ b/rathaxes/samples/lkm/e1000.blt	Sun Jan 08 00:13:22 2012 +0100
+@@ -62,7 +62,6 @@
+         {
+             // XXX: add a check in order to avoid freeing none allocated
+             // resources.
+-            struct net_device *net_dev = pci_get_drvdata(pdev);
+             struct rtx_ethernet_dev* rtx_ether_ctx = netdev_priv(net_dev);
+             iounmap(rtx_ether_ctx->hw_ctx.ioaddr);
+             pci_release_selected_regions(pdev, rtx_ether_ctx->hw_ctx.bars);
+diff -r 4920b3a97ad6 -r c3265ca219d5 rathaxes/samples/lkm/ethernet.blt
+--- a/rathaxes/samples/lkm/ethernet.blt	Sat Jan 07 23:09:24 2012 +0100
++++ b/rathaxes/samples/lkm/ethernet.blt	Sun Jan 08 00:13:22 2012 +0100
+@@ -125,7 +125,7 @@
+             };
+         }
+ 
+-        chunk ::CALL
++        chunk PCI::pci_probe_hook()
+         {
+             /*
+              * This typedef is needed to workaround a bug in CNorm __std__
+@@ -174,12 +174,18 @@
+             //pci_set_drvdata(${pdev}, net_dev);
+             pci_set_drvdata(pdev, net_dev);
+         }
++
++        chunk   ::CALL
++        {
++        }
+     }
+ 
+     template sequence   Ethernet::exit(PCI::Device pdev)
+     {
+-        chunk ::CALL
++        chunk   PCI::pci_remove_hook()
+         {
++            struct net_device *net_dev = pci_get_drvdata(pdev);
++
+             unregister_netdev(net_dev);
+             /*
+              * If we had some cleanup todo with struct rtx_ether_ctx we would
+@@ -187,5 +193,10 @@
+              */
+             free_netdev(net_dev);
+         }
++
++        chunk ::CALL
++        {
++        }
+     }
+ }
++
+diff -r 4920b3a97ad6 -r c3265ca219d5 rathaxes/samples/lkm/ethernet.rti
+--- a/rathaxes/samples/lkm/ethernet.rti	Sat Jan 07 23:09:24 2012 +0100
++++ b/rathaxes/samples/lkm/ethernet.rti	Sun Jan 08 00:13:22 2012 +0100
+@@ -28,10 +28,10 @@
+         provided chunk  LKM::code;
+     }
+ 
+-    /* Kinda extends PCI::probe */
+     provided sequence   Ethernet::init(PCI::Device)
+     {
+         provided chunk  LKM::data;
++        provided chunk  PCI::pci_probe_hook;
+         provided chunk  ::CALL;
+     }
+ 
+@@ -39,5 +39,6 @@
+     provided sequence   Ethernet::exit(PCI::Device)
+     {
+         provided chunk  ::CALL;
++        provided chunk  PCI::pci_remove_hook;
+     }
+ }
+diff -r 4920b3a97ad6 -r c3265ca219d5 rathaxes/samples/lkm/lkm.rtx
+--- a/rathaxes/samples/lkm/lkm.rtx	Sat Jan 07 23:09:24 2012 +0100
++++ b/rathaxes/samples/lkm/lkm.rtx	Sun Jan 08 00:13:22 2012 +0100
+@@ -20,19 +20,19 @@
+         Log::info("We have one packet to transmit!");
+     }
+ 
+-    PCI::probe(PCI::Device dev)
+-    {
+-        Log::info("Probe the device");
+-        Ethernet::init(dev);
+-        e1000::create();
+-    }
++//    PCI::probe(PCI::Device dev)
++//    {
++//        Log::info("Probe the device");
++//        Ethernet::init(dev);
++//        e1000::create();
++//    }
+ 
+-    PCI::remove(PCI::Device dev)
+-    {
+-        Log::info("Remove the pci device");
+-        e1000::destroy();
+-        Ethernet::exit(dev);
+-    }
++//    PCI::remove(PCI::Device dev)
++//    {
++//        Log::info("Remove the pci device");
++//        e1000::destroy();
++//        Ethernet::exit(dev);
++//    }
+ 
+     LKM::init()
+     {
+diff -r 4920b3a97ad6 -r c3265ca219d5 rathaxes/samples/lkm/pci.blt
+--- a/rathaxes/samples/lkm/pci.blt	Sat Jan 07 23:09:24 2012 +0100
++++ b/rathaxes/samples/lkm/pci.blt	Sun Jan 08 00:13:22 2012 +0100
+@@ -53,7 +53,7 @@
+                 if (err < 0)
+                     goto fail;
+ 
+-                ${pointcut ::IMPLEMENTATION};
++                ${pointcut PCI::pci_probe_hook};
+ 
+                 return 0;
+ 
+@@ -61,6 +61,10 @@
+                     return err;
+             }
+         }
++
++        chunk   ::CALL
++        {
++        }
+     }
+ 
+     template sequence   PCI::remove(PCI::Device pdev)
+@@ -74,11 +78,15 @@
+         {
+             static void rtx_pci_remove(struct pci_dev *pdev)
+             {
+-                ${pointcut ::IMPLEMENTATION};
++                ${pointcut PCI::pci_remove_hook};
+ 
+                 pci_disable_device(pdev);
+             }
+         }
++
++        chunk   ::CALL()
++        {
++        }
+     }
+ 
+     template sequence   PCI::register()
+diff -r 4920b3a97ad6 -r c3265ca219d5 rathaxes/samples/lkm/pci.rti
+--- a/rathaxes/samples/lkm/pci.rti	Sat Jan 07 23:09:24 2012 +0100
++++ b/rathaxes/samples/lkm/pci.rti	Sun Jan 08 00:13:22 2012 +0100
+@@ -23,15 +23,19 @@
+         provided chunk  LKM::deinit_bus_hook;
+     }
+ 
+-    required sequence   PCI::probe(PCI::Device)
++    provided sequence   PCI::probe(PCI::Device)
+     {
+         provided chunk  LKM::prototypes;
+         provided chunk  LKM::code;
++
++        provided pointcut   PCI::pci_probe_hook;
+     }
+ 
+-    required sequence   PCI::remove(PCI::Device)
++    provided sequence   PCI::remove(PCI::Device)
+     {
+         provided chunk  LKM::prototypes;
+         provided chunk  LKM::code;
++
++        provided pointcut   PCI::pci_remove_hook;
+     }
+ }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pci_rework_without_explicit_call.patch	Sun Jan 08 01:10:20 2012 +0100
@@ -0,0 +1,123 @@
+# HG changeset patch
+# Parent c5c98e265bb4cf5c3a9d775e56d6599ca73a4c73
+rathaxes: initialize the pci bus in an elegant implicit way
+
+diff -r c5c98e265bb4 -r 4920b3a97ad6 rathaxes/samples/lkm/lkm.blt
+--- a/rathaxes/samples/lkm/lkm.blt	Sat Jan 07 22:45:07 2012 +0100
++++ b/rathaxes/samples/lkm/lkm.blt	Sat Jan 07 23:09:24 2012 +0100
+@@ -33,6 +33,7 @@
+             static int __attribute__((__section__(".init.text")))  rtx_module_init(void)
+             {
+                 ${pointcut ::IMPLEMENTATION};
++                ${pointcut LKM::init_bus_hook};
+ 
+                 return 0;
+             }
+@@ -48,6 +49,7 @@
+             static void __attribute__((__section__(".exit.text")))   rtx_module_exit(void)
+             {
+                 ${pointcut ::IMPLEMENTATION};
++                ${pointcut LKM::deinit_bus_hook};
+             }
+ 
+             module_exit(rtx_module_exit);
+diff -r c5c98e265bb4 -r 4920b3a97ad6 rathaxes/samples/lkm/lkm.rti
+--- a/rathaxes/samples/lkm/lkm.rti	Sat Jan 07 22:45:07 2012 +0100
++++ b/rathaxes/samples/lkm/lkm.rti	Sat Jan 07 23:09:24 2012 +0100
+@@ -12,12 +12,14 @@
+ 
+     required sequence   LKM::init()
+     {
+-        provided chunk  LKM::includes;
+-        provided chunk  LKM::code;
++        provided chunk      LKM::includes;
++        provided chunk      LKM::code;
++        provided pointcut   LKM::init_bus_hook;
+     }
+ 
+     required sequence   LKM::exit()
+     {
+-        provided chunk  LKM::code;
++        provided chunk      LKM::code;
++        provided pointcut   LKM::deinit_bus_hook;
+     }
+ }
+diff -r c5c98e265bb4 -r 4920b3a97ad6 rathaxes/samples/lkm/lkm.rtx
+--- a/rathaxes/samples/lkm/lkm.rtx	Sat Jan 07 22:45:07 2012 +0100
++++ b/rathaxes/samples/lkm/lkm.rtx	Sat Jan 07 23:09:24 2012 +0100
+@@ -37,13 +37,13 @@
+     LKM::init()
+     {
+         Log::info("Hello this is LKM");
+-        PCI::register();
++        // PCI::register();
+     }
+ 
+     LKM::exit()
+     {
+         Log::info("Good bye this was LKM");
+-        PCI::unregister();
++        // PCI::unregister();
+     }
+ }
+ 
+diff -r c5c98e265bb4 -r 4920b3a97ad6 rathaxes/samples/lkm/pci.blt
+--- a/rathaxes/samples/lkm/pci.blt	Sat Jan 07 22:45:07 2012 +0100
++++ b/rathaxes/samples/lkm/pci.blt	Sat Jan 07 23:09:24 2012 +0100
+@@ -102,7 +102,7 @@
+             };
+         }
+ 
+-        chunk ::CALL
++        chunk LKM::init_bus_hook()
+         {
+             /*
+              * So how do we use the return value in the parent context?
+@@ -116,13 +116,22 @@
+                  return error;
+             }
+         }
++
++        chunk ::CALL()
++        {
++            // no implementation, we just need to instrument the lkm::bus_hook
++        }
+     }
+ 
+     template sequence   PCI::unregister()
+     {
+-        chunk ::CALL
++        chunk   LKM::deinit_bus_hook()
+         {
+             pci_unregister_driver(&rtx_pci_driver);
+         }
++
++        chunk ::CALL
++        {
++        }
+     }
+ }
+diff -r c5c98e265bb4 -r 4920b3a97ad6 rathaxes/samples/lkm/pci.rti
+--- a/rathaxes/samples/lkm/pci.rti	Sat Jan 07 22:45:07 2012 +0100
++++ b/rathaxes/samples/lkm/pci.rti	Sat Jan 07 23:09:24 2012 +0100
+@@ -7,13 +7,20 @@
+ 
+     provided sequence   PCI::register()
+     {
++        // it is impossible to provide a "dummy" sequence
++        // which just hook itself. The PCI:register juste
++        // inject its code in the module_init function
++        // in order to load the pci driver.
++        // Everything is done with the configuration.
+         provided chunk  ::CALL;
+         provided chunk  LKM::data;
++        provided chunk  LKM::init_bus_hook;
+     }
+ 
+     provided sequence   PCI::unregister()
+     {
+         provided chunk  ::CALL;
++        provided chunk  LKM::deinit_bus_hook;
+     }
+ 
+     required sequence   PCI::probe(PCI::Device)
--- a/rathaxes_add_a_patch_to_illustrate_issue_8.patch	Sun Jan 08 01:09:59 2012 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,85 +0,0 @@
-# HG changeset patch
-# Parent f91d274916763989466df5f948ee32a48930b028
-Add a patch to illustrate pointcuts in type definition to illustrate #8
-
-diff --git a/rathaxes/samples/lkm/e1000.blt b/rathaxes/samples/lkm/e1000.blt
---- a/rathaxes/samples/lkm/e1000.blt
-+++ b/rathaxes/samples/lkm/e1000.blt
-@@ -2,25 +2,20 @@
- {
-     template type   e1000::Context()
-     {
--        chunk   LKM::includes()
-+        chunk   Ethernet::Context()
-         {
--            /*
--             * Force the generation of the structure in the "headers part, we
--             * have to do this since we do not use the structure in this blt
--             * (we hacked a bit and used it in ethernet.blt directly).
--             */
--            typedef int ${e1000::Context}; /* CNorm __std__ workaround */
--            ${e1000::Context} force_declaration_in_includes;
-+            struct
-+            {
-+                int                         bars;
-+                unsigned char /* __iomem */ *ioaddr;
-+            }   rtx_e1000_ctx;
-         }
- 
--        chunk   ::decl()
--        {
--            struct rtx_e1000_ctx
--            {
--                int                             bars;
--                unsigned char /* __iomem */     *ioaddr;
--            };
--        }
-+        /*
-+         * Not sure about how chunk ::init will look in that case maybe we
-+         * would need a second pointcut that would insert code in chunk ::init
-+         * in Ethernet::Context? (and this chunk would be implemented here).
-+         */
- 
-         map
-         {
-diff --git a/rathaxes/samples/lkm/e1000.rti b/rathaxes/samples/lkm/e1000.rti
---- a/rathaxes/samples/lkm/e1000.rti
-+++ b/rathaxes/samples/lkm/e1000.rti
-@@ -1,6 +1,9 @@
- interface e1000 : Socket, Ethernet, PCI, LKM
- {
--    provided type   e1000::Context;
-+    provided type   e1000::Context
-+    {
-+        provided chunk  Ethernet::Context;
-+    }
- 
-     /* Not sure if we need the argument */
-     provided sequence   e1000::create()
-diff --git a/rathaxes/samples/lkm/ethernet.blt b/rathaxes/samples/lkm/ethernet.blt
---- a/rathaxes/samples/lkm/ethernet.blt
-+++ b/rathaxes/samples/lkm/ethernet.blt
-@@ -22,7 +22,8 @@
-                 struct net_device       *net_dev;
- 
-                 /* while waiting on issue #8 */
--                struct rtx_e1000_ctx    hw_ctx;
-+                /* struct rtx_e1000_ctx    hw_ctx; */
-+                ${pointcut  Ethernet::Context};
-             };
-         }
- 
-diff --git a/rathaxes/samples/lkm/ethernet.rti b/rathaxes/samples/lkm/ethernet.rti
---- a/rathaxes/samples/lkm/ethernet.rti
-+++ b/rathaxes/samples/lkm/ethernet.rti
-@@ -1,6 +1,9 @@
- interface Ethernet : Socket, PCI, LKM
- {
--    provided type       Ethernet::Device;
-+    provided type       Ethernet::Device
-+    {
-+        provided pointcut   Ethernet::Context;
-+    }
- 
-     required variable ::string  Ethernet::ifname;
- 
--- a/series	Sun Jan 08 01:09:59 2012 +0100
+++ b/series	Sun Jan 08 01:10:20 2012 +0100
@@ -4,4 +4,6 @@
 rathaxes_start_to_implement_pci_stuff_in_the_lkm.patch
 rathaxes_start_to_implement_the_ethernet_subsystem_in_the_lkm.patch
 rathaxes_start_to_implement_sk_buff_in_the_lkm.patch
-rathaxes_add_a_patch_to_illustrate_issue_8.patch
+pci_rework_without_explicit_call.patch
+ethernet_rework_without_explicit_call.patch
+e1000_rework_without_explicit_call.patch