changeset 8:7089717b63b7

WIP on the PCI LKM
author Louis Opter <louis@lse.epitech.net>
date Fri, 06 Jan 2012 12:48:22 +0100
parents eead270c9bb6
children 7d51609a0ff1
files rathaxes_call_pci_register_unregister_in_the_pci_lkm_sample.patch series
diffstat 2 files changed, 112 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rathaxes_call_pci_register_unregister_in_the_pci_lkm_sample.patch	Fri Jan 06 12:48:22 2012 +0100
@@ -0,0 +1,111 @@
+# HG changeset patch
+# Parent 3c5e2af745189313fab89aa2674afc3153744f7b
+rathaxes: add the pci_{register,unregister}_device calls in the PCI LKM sample
+
+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
+@@ -13,10 +13,12 @@
+     LKM::init()
+     {
+         Log::info("Hello this is LKM");
++        PCI::register();
+     }
+ 
+     LKM::exit()
+     {
++        PCI::unregister();
+     }
+ }
+ 
+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
+@@ -35,25 +35,6 @@
+                                                       const struct pci_device_id *);
+         }
+ 
+-        chunk LKM::data()
+-        {
+-            /*
+-             * 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_driver rtx_pci_driver = {
+-                .name = ${config.name},
+-                .id_table = rtx_pci_device_table,
+-                .probe = rtx_pci_probe,
+-                .remove = rtx_pci_remove
+-            };
+-        }
+-
+         chunk LKM::code()
+         {
+             static int /* __devinit */  rtx_pci_probe(struct pci_dev *pdev,
+@@ -98,4 +79,39 @@
+             }
+         }
+     }
++
++    template sequence   PCI::register()
++    {
++        chunk LKM::data()
++        {
++            /*
++             * 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_driver rtx_pci_driver = {
++                .name = ${config.name},
++                .id_table = rtx_pci_device_table,
++                .probe = rtx_pci_probe,
++                .remove = rtx_pci_remove
++            };
++        }
++
++        chunk ::CALL
++        {
++            pci_register_driver(&rtx_pci_device);
++        }
++    }
++
++    template sequence   PCI::unregister()
++    {
++        chunk ::CALL
++        {
++            pci_unregister_driver(&rtx_pci_device);
++        }
++    }
+ }
+diff --git a/rathaxes/samples/lkm/pci.rti b/rathaxes/samples/lkm/pci.rti
+--- a/rathaxes/samples/lkm/pci.rti
++++ b/rathaxes/samples/lkm/pci.rti
+@@ -8,12 +8,17 @@
+     provided sequence   PCI::register()
+     {
+         provided chunk  ::CALL;
++        provided chunk  LKM::data;
++    }
++
++    provided sequence   PCI::unregister()
++    {
++        provided chunk  ::CALL;
+     }
+ 
+     required sequence   PCI::probe(PCI::Device)
+     {
+         provided chunk  LKM::prototypes;
+-        provided chunk  LKM::data;
+         provided chunk  LKM::code;
+     }
+ 
--- a/series	Fri Jan 06 11:45:25 2012 +0100
+++ b/series	Fri Jan 06 12:48:22 2012 +0100
@@ -2,3 +2,4 @@
 rathaxes_start_to_implement_pci_stuff_in_the_lkm.patch
 maintainers_add_add_rathaxes_lkm_in_use_rathaxes_cmake_file.patch
 rathaxes_fix_lkm_sample_build.patch
+rathaxes_call_pci_register_unregister_in_the_pci_lkm_sample.patch