changeset 10:44a25ffd5c8c

Reorganize the patch queue a bit: put the cmake patch first then the LKM patch then the PCI part
author Louis Opter <louis@lse.epitech.net>
date Fri, 06 Jan 2012 13:43:06 +0100
parents 7d51609a0ff1
children efee5f0249e2
files rathaxes_add_a_linux_lkm.patch rathaxes_call_pci_register_unregister_in_the_pci_lkm_sample.patch rathaxes_fix_lkm_sample_build.patch rathaxes_start_to_implement_pci_stuff_in_the_lkm.patch series
diffstat 5 files changed, 118 insertions(+), 260 deletions(-) [+]
line wrap: on
line diff
--- a/rathaxes_add_a_linux_lkm.patch	Fri Jan 06 12:55:07 2012 +0100
+++ b/rathaxes_add_a_linux_lkm.patch	Fri Jan 06 13:43:06 2012 +0100
@@ -1,13 +1,14 @@
 # HG changeset patch
-# Parent f5d32f3858ef49412b7113149a74901e8fb91fea
+# Parent 9006ed3c5074b918e2f824b0053b494e2a82dbb8
 rathaxes: add a kernel module sample (for now Linux only)
 
 diff --git a/rathaxes/samples/CMakeLists.txt b/rathaxes/samples/CMakeLists.txt
 --- a/rathaxes/samples/CMakeLists.txt
 +++ b/rathaxes/samples/CMakeLists.txt
-@@ -1,1 +1,2 @@
+@@ -1,2 +1,3 @@
  ADD_SUBDIRECTORY(helloworld)
 +ADD_SUBDIRECTORY(lkm)
+ ADD_SUBDIRECTORY(syntax)
 diff --git a/rathaxes/samples/lkm/CMakeLists.txt b/rathaxes/samples/lkm/CMakeLists.txt
 new file mode 100644
 --- /dev/null
@@ -98,7 +99,7 @@
 new file mode 100644
 --- /dev/null
 +++ b/rathaxes/samples/lkm/lkm.rtx
-@@ -0,0 +1,18 @@
+@@ -0,0 +1,19 @@
 +device LKM use LKM, Log
 +{
 +    LKM::init()
@@ -108,6 +109,7 @@
 +
 +    LKM::exit()
 +    {
++        Log::info("Good bye this was LKM");
 +    }
 +}
 +
--- a/rathaxes_call_pci_register_unregister_in_the_pci_lkm_sample.patch	Fri Jan 06 12:55:07 2012 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,123 +0,0 @@
-# HG changeset patch
-# Parent 6761c243013d320ab7c35a3bf537956eb4c228fa
-rathaxes: add the pci_{register,unregister}_device calls in the PCI LKM sample
-
-diff -r 6761c243013d rathaxes/samples/lkm/lkm.blt
---- a/rathaxes/samples/lkm/lkm.blt	Fri Jan 06 12:49:00 2012 +0100
-+++ b/rathaxes/samples/lkm/lkm.blt	Fri Jan 06 12:54:49 2012 +0100
-@@ -33,6 +33,8 @@
-             static int __attribute__((__section__(".init.text")))  rtx_module_init(void)
-             {
-                 ${pointcut ::IMPLEMENTATION};
-+
-+                return 0;
-             }
- 
-             module_init(rtx_module_init);
-diff -r 6761c243013d rathaxes/samples/lkm/lkm.rtx
---- a/rathaxes/samples/lkm/lkm.rtx	Fri Jan 06 12:49:00 2012 +0100
-+++ b/rathaxes/samples/lkm/lkm.rtx	Fri Jan 06 12:54:49 2012 +0100
-@@ -13,10 +13,12 @@
-     LKM::init()
-     {
-         Log::info("Hello this is LKM");
-+        PCI::register();
-     }
- 
-     LKM::exit()
-     {
-+        PCI::unregister();
-     }
- }
- 
-diff -r 6761c243013d rathaxes/samples/lkm/pci.blt
---- a/rathaxes/samples/lkm/pci.blt	Fri Jan 06 12:49:00 2012 +0100
-+++ b/rathaxes/samples/lkm/pci.blt	Fri Jan 06 12:54:49 2012 +0100
-@@ -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_driver);
-+        }
-+    }
-+
-+    template sequence   PCI::unregister()
-+    {
-+        chunk ::CALL
-+        {
-+            pci_unregister_driver(&rtx_pci_driver);
-+        }
-+    }
- }
-diff -r 6761c243013d rathaxes/samples/lkm/pci.rti
---- a/rathaxes/samples/lkm/pci.rti	Fri Jan 06 12:49:00 2012 +0100
-+++ b/rathaxes/samples/lkm/pci.rti	Fri Jan 06 12:54:49 2012 +0100
-@@ -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/rathaxes_fix_lkm_sample_build.patch	Fri Jan 06 12:55:07 2012 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,91 +0,0 @@
-# HG changeset patch
-# Parent 563beffa32c982c746f6e26be2c89cab7b3608a4
-rathaxes: fix the necessary bits in the LKM sample to build a minimal linux LKM
-
-diff --git a/rathaxes/samples/lkm/lkm.blt b/rathaxes/samples/lkm/lkm.blt
---- a/rathaxes/samples/lkm/lkm.blt
-+++ b/rathaxes/samples/lkm/lkm.blt
-@@ -12,8 +12,13 @@
-         {
-             #include <linux/module.h>
-             #include <linux/kernel.h>
--            typedef int  lkm_headers_include_stamp;
- 
-+            typedef int  include_linux_module_stamp;
-+            typedef int  include_linux_kernel_stamp;
-+        }
-+
-+        chunk   LKM::data()
-+        {
-             MODULE_DESCRIPTION(${config.description});
-             MODULE_AUTHOR(${config.author});
-             MODULE_LICENSE(${config.license});
-@@ -25,7 +30,7 @@
-              * Rathaxes doesn't yet support arbitrary "decorators" like __init
-              * or __exit.
-              */
--            static int __attribute__((__section__(.init.text)))  rtx_module_init(void)
-+            static int __attribute__((__section__(".init.text")))  rtx_module_init(void)
-             {
-                 ${pointcut ::IMPLEMENTATION};
-             }
-@@ -38,12 +43,12 @@
-     {
-         chunk   LKM::code()
-         {
--            static void __attribute((__section__(.exit.text)))   rtx_module_exit(void)
-+            static void __attribute__((__section__(".exit.text")))   rtx_module_exit(void)
-             {
-                 ${pointcut ::IMPLEMENTATION};
-             }
- 
--            module_exit(rtx_module_init);
-+            module_exit(rtx_module_exit);
-         }
-     }
- }
-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
-@@ -27,6 +27,6 @@
-     LKM::description = "Hello World Loadable Kernel Module (LKM)";
-     LKM::license = "BSD";
- 
--    PCI::vendor_id = "0x8080";
--    PCI::product_id = "0x42";
-+    PCI::vendor_id = 0x8080;
-+    PCI::product_id = 0x42;
- }
-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
-@@ -2,14 +2,12 @@
- {
-     template type   PCI::Device()
-     {
--        /*
--         * chunk   LKM::includes()
--         * {
--         *     #include <linux/pci.h>
--         *
--         *     typedef int include_linux_pci_stamp;
--         * }
--         */
-+        chunk   LKM::includes()
-+        {
-+            #include <linux/pci.h>
-+
-+            typedef int include_linux_pci_stamp;
-+        }
- 
-         chunk   ::decl()
-         {
-@@ -65,7 +63,7 @@
-                 typedef int ${PCI::Device};
- 
-                 int             err;
--                ${PCI::Device}  dev = NULL; /* Doesn't work with a pointer */
-+                ${PCI::Device}  *dev = NULL;
- 
-                 err = pci_enable_device(pdev);
- //              if (err < 0) /* `if' doesn't work */
--- a/rathaxes_start_to_implement_pci_stuff_in_the_lkm.patch	Fri Jan 06 12:55:07 2012 +0100
+++ b/rathaxes_start_to_implement_pci_stuff_in_the_lkm.patch	Fri Jan 06 13:43:06 2012 +0100
@@ -1,5 +1,5 @@
 # HG changeset patch
-# Parent 23fc39d03d6679b631adc6c22f312e6cda9aa82f
+# Parent 873b66890128280637d97a24221258bb297a1ac8
 rathaxes: start to implement the PCI registration part in the LKM sample
 
 diff --git a/rathaxes/samples/lkm/CMakeLists.txt b/rathaxes/samples/lkm/CMakeLists.txt
@@ -31,7 +31,20 @@
  
      template sequence   LKM::init()
      {
-@@ -17,7 +19,7 @@
+@@ -10,22 +12,29 @@
+         {
+             #include <linux/module.h>
+             #include <linux/kernel.h>
+-            typedef int  lkm_headers_include_stamp;
+ 
++            typedef int  include_linux_module_stamp;
++            typedef int  include_linux_kernel_stamp;
++        }
++
++        chunk   LKM::data()
++        {
+             MODULE_DESCRIPTION(${config.description});
+             MODULE_AUTHOR(${config.author});
              MODULE_LICENSE(${config.license});
          }
  
@@ -40,15 +53,35 @@
          {
              /*
               * Rathaxes doesn't yet support arbitrary "decorators" like __init
-@@ -34,7 +36,7 @@
+              * or __exit.
+              */
+-            static int __attribute__((__section__(.init.text)))  rtx_module_init(void)
++            static int __attribute__((__section__(".init.text")))  rtx_module_init(void)
+             {
+                 ${pointcut ::IMPLEMENTATION};
++
++                return 0;
+             }
+ 
+             module_init(rtx_module_init);
+@@ -34,14 +43,14 @@
  
      template sequence   LKM::exit()
      {
 -        chunk   LKM::exit
 +        chunk   LKM::code()
          {
-             static void __attribute((__section__(.exit.text)))   rtx_module_exit(void)
+-            static void __attribute((__section__(.exit.text)))   rtx_module_exit(void)
++            static void __attribute__((__section__(".exit.text")))   rtx_module_exit(void)
              {
+                 ${pointcut ::IMPLEMENTATION};
+             }
+ 
+-            module_exit(rtx_module_init);
++            module_exit(rtx_module_exit);
+         }
+     }
+ }
 diff --git a/rathaxes/samples/lkm/lkm.rti b/rathaxes/samples/lkm/lkm.rti
 --- a/rathaxes/samples/lkm/lkm.rti
 +++ b/rathaxes/samples/lkm/lkm.rti
@@ -82,7 +115,7 @@
 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
-@@ -1,5 +1,15 @@
+@@ -1,19 +1,35 @@
 -device LKM use LKM, Log
 +device LKM use LKM, PCI, Log
  {
@@ -99,7 +132,15 @@
      LKM::init()
      {
          Log::info("Hello this is LKM");
-@@ -12,7 +22,11 @@
++        PCI::register();
+     }
+ 
+     LKM::exit()
+     {
+         Log::info("Good bye this was LKM");
++        PCI::unregister();
+     }
+ }
  
  configuration
  {
@@ -108,26 +149,24 @@
      LKM::description = "Hello World Loadable Kernel Module (LKM)";
      LKM::license = "BSD";
 +
-+    PCI::vendor_id = "0x8080";
-+    PCI::product_id = "0x42";
++    PCI::vendor_id = 0x8086;
++    PCI::product_id = 0x100f;
  }
 diff --git a/rathaxes/samples/lkm/pci.blt b/rathaxes/samples/lkm/pci.blt
 new file mode 100644
 --- /dev/null
 +++ b/rathaxes/samples/lkm/pci.blt
-@@ -0,0 +1,103 @@
-+with PCI, LKM
+@@ -0,0 +1,129 @@
++with PCI, LKM, Log
 +{
 +    template type   PCI::Device()
 +    {
-+        /*
-+         * chunk   LKM::includes()
-+         * {
-+         *     #include <linux/pci.h>
-+         *
-+         *     typedef int include_linux_pci_stamp;
-+         * }
-+         */
++        chunk   LKM::includes()
++        {
++            #include <linux/pci.h>
++
++            typedef int include_linux_pci_stamp;
++        }
 +
 +        chunk   ::decl()
 +        {
@@ -155,25 +194,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,
@@ -183,7 +203,7 @@
 +                typedef int ${PCI::Device};
 +
 +                int             err;
-+                ${PCI::Device}  dev = NULL; /* Doesn't work with a pointer */
++                ${PCI::Device}  *dev = NULL;
 +
 +                err = pci_enable_device(pdev);
 +//              if (err < 0) /* `if' doesn't work */
@@ -218,12 +238,59 @@
 +            }
 +        }
 +    }
++
++    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
++        {
++            /*
++             * So how do we use the return value in the parent context?
++             */
++            pci_register_driver(&rtx_pci_driver);
++            /*
++             * if (pci_register_driver(&rtx_pci_driver))
++             * {
++             *     `if' still doesn't work.
++             *
++             *      Also, can I call the Log interface from here?
++             *      ${Log::info("Message")}; doesn't seem to work.
++             * }
++             */
++        }
++    }
++
++    template sequence   PCI::unregister()
++    {
++        chunk ::CALL
++        {
++            pci_unregister_driver(&rtx_pci_driver);
++        }
++    }
 +}
 diff --git a/rathaxes/samples/lkm/pci.rti b/rathaxes/samples/lkm/pci.rti
 new file mode 100644
 --- /dev/null
 +++ b/rathaxes/samples/lkm/pci.rti
-@@ -0,0 +1,25 @@
+@@ -0,0 +1,30 @@
 +interface PCI : LKM
 +{
 +    provided type       PCI::Device;
@@ -234,12 +301,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 12:55:07 2012 +0100
+++ b/series	Fri Jan 06 13:43:06 2012 +0100
@@ -1,5 +1,3 @@
+maintainers_add_add_rathaxes_lkm_in_use_rathaxes_cmake_file.patch
 rathaxes_add_a_linux_lkm.patch
 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