# 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();
     }
 }
 
