changeset 33:60a59bf708df

merge
author Thomas Sanchez <thomas.sanchz@gmail.com>
date Sun, 08 Jan 2012 00:39:56 +0100
parents c7c59cebab85
children 62fba8b9db06
files e1000_rework_without_explicit_call.patch ethernet_rework_without_explicit_call.patch pci_rework_without_explicit_call.patch series
diffstat 4 files changed, 414 insertions(+), 0 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 00:39:56 2012 +0100
@@ -0,0 +1,108 @@
+# HG changeset patch
+# Parent c3265ca219d51aa493db9639444eba7d72812e69
+rathaxes: initialize the e1000 sepcific code in an elegant implicit way
+
+diff -r c3265ca219d5 -r 5c8bb469d5a5 rathaxes/samples/lkm/e1000.blt
+--- a/rathaxes/samples/lkm/e1000.blt	Sun Jan 08 00:13:22 2012 +0100
++++ b/rathaxes/samples/lkm/e1000.blt	Sun Jan 08 00:35:30 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,11 +54,15 @@
+                 ${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.
+@@ -67,5 +71,9 @@
+             pci_release_selected_regions(pdev, rtx_ether_ctx->hw_ctx.bars);
+             pci_release_region(pdev, 0);
+         }
++
++        chunk   ::CALL
++        {
++        }
+     }
+ }
+diff -r c3265ca219d5 -r 5c8bb469d5a5 rathaxes/samples/lkm/e1000.rti
+--- a/rathaxes/samples/lkm/e1000.rti	Sun Jan 08 00:13:22 2012 +0100
++++ b/rathaxes/samples/lkm/e1000.rti	Sun Jan 08 00:35:30 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 c3265ca219d5 -r 5c8bb469d5a5 rathaxes/samples/lkm/ethernet.blt
+--- a/rathaxes/samples/lkm/ethernet.blt	Sun Jan 08 00:13:22 2012 +0100
++++ b/rathaxes/samples/lkm/ethernet.blt	Sun Jan 08 00:35:30 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 c3265ca219d5 -r 5c8bb469d5a5 rathaxes/samples/lkm/ethernet.rti
+--- a/rathaxes/samples/lkm/ethernet.rti	Sun Jan 08 00:13:22 2012 +0100
++++ b/rathaxes/samples/lkm/ethernet.rti	Sun Jan 08 00:35:30 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;
+     }
+ }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ethernet_rework_without_explicit_call.patch	Sun Jan 08 00:39:56 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 00:39:56 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/series	Sat Jan 07 23:56:11 2012 +0100
+++ b/series	Sun Jan 08 00:39:56 2012 +0100
@@ -4,3 +4,6 @@
 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