diff ethernet_rework_without_explicit_call.patch @ 33:60a59bf708df

merge
author Thomas Sanchez <thomas.sanchz@gmail.com>
date Sun, 08 Jan 2012 00:39:56 +0100
parents
children
line wrap: on
line diff
--- /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;
+     }
+ }