changeset 3:2389c2bc501f

Start to write a queue for the LKM
author Louis Opter <louis@lse.epitech.net>
date Thu, 05 Jan 2012 15:10:21 +0100
parents de4bd4784796
children d102c9be499c
files rathaxes_add_a_linux_lkm.patch series
diffstat 2 files changed, 147 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rathaxes_add_a_linux_lkm.patch	Thu Jan 05 15:10:21 2012 +0100
@@ -0,0 +1,146 @@
+# HG changeset patch
+# Parent f5d32f3858ef49412b7113149a74901e8fb91fea
+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 @@
+ ADD_SUBDIRECTORY(helloworld)
++ADD_SUBDIRECTORY(lkm)
+diff --git a/rathaxes/samples/lkm/CMakeLists.txt b/rathaxes/samples/lkm/CMakeLists.txt
+new file mode 100644
+--- /dev/null
++++ b/rathaxes/samples/lkm/CMakeLists.txt
+@@ -0,0 +1,3 @@
++ADD_RATHAXES_SOURCES(lkm lkm.rtx
++                     RTI log.rti lkm.rti
++                     BLT log.blt lkm.blt)
+diff --git a/rathaxes/samples/lkm/lkm.blt b/rathaxes/samples/lkm/lkm.blt
+new file mode 100644
+--- /dev/null
++++ b/rathaxes/samples/lkm/lkm.blt
+@@ -0,0 +1,47 @@
++with LKM
++{
++    ${pointcut LKM::includes};
++    ${pointcut LKM::init};
++    ${pointcut LKM::exit};
++
++    template sequence   LKM::init()
++    {
++        chunk   LKM::includes()
++        {
++            #include <linux/module.h>
++            #include <linux/kernel.h>
++            typedef int  lkm_headers_include_stamp;
++
++            MODULE_DESCRIPTION(${config.description});
++            MODULE_AUTHOR(${config.author});
++            MODULE_LICENSE(${config.license});
++        }
++
++        chunk   LKM::init()
++        {
++            /*
++             * Rathaxes doesn't yet support arbitrary "decorators" like __init
++             * or __exit.
++             */
++            static int __attribute__((__section__(.init.text)))  rtx_module_init(void)
++            {
++                ${pointcut ::IMPLEMENTATION};
++            }
++
++            module_init(rtx_module_init);
++        }
++    }
++
++    template sequence   LKM::exit()
++    {
++        chunk   LKM::exit
++        {
++            static void __attribute((__section__(.exit.text)))   rtx_module_exit(void)
++            {
++                ${pointcut ::IMPLEMENTATION};
++            }
++
++            module_exit(rtx_module_init);
++        }
++    }
++}
+diff --git a/rathaxes/samples/lkm/lkm.rti b/rathaxes/samples/lkm/lkm.rti
+new file mode 100644
+--- /dev/null
++++ b/rathaxes/samples/lkm/lkm.rti
+@@ -0,0 +1,21 @@
++interface LKM
++{
++    provided pointcut   LKM::includes;
++    provided pointcut   LKM::init;
++    provided pointcut   LKM::exit;
++
++    required variable ::string  LKM::author;
++    required variable ::string  LKM::description;
++    required variable ::string  LKM::license;
++
++    required sequence   LKM::init()
++    {
++        provided chunk  LKM::includes;
++        provided chunk  LKM::init;
++    }
++
++    required sequence   LKM::exit()
++    {
++        provided chunk  LKM::exit;
++    }
++}
+diff --git a/rathaxes/samples/lkm/lkm.rtx b/rathaxes/samples/lkm/lkm.rtx
+new file mode 100644
+--- /dev/null
++++ b/rathaxes/samples/lkm/lkm.rtx
+@@ -0,0 +1,18 @@
++device LKM use LKM, Log
++{
++    LKM::init()
++    {
++        Log::info("Hello this is LKM");
++    }
++
++    LKM::exit()
++    {
++    }
++}
++
++configuration
++{
++    LKM::author = "Rathaxes";
++    LKM::description = "Hello World Loadable Kernel Module (LKM)";
++    LKM::license = "BSD";
++}
+diff --git a/rathaxes/samples/lkm/log.blt b/rathaxes/samples/lkm/log.blt
+new file mode 100644
+--- /dev/null
++++ b/rathaxes/samples/lkm/log.blt
+@@ -0,0 +1,10 @@
++with Log
++{
++    template sequence   Log::info(::string msg)
++    {
++        chunk   ::CALL
++        {
++            pr_info("%s\n", ${msg});
++        }
++    }
++}
+diff --git a/rathaxes/samples/lkm/log.rti b/rathaxes/samples/lkm/log.rti
+new file mode 100644
+--- /dev/null
++++ b/rathaxes/samples/lkm/log.rti
+@@ -0,0 +1,7 @@
++interface Log
++{
++    provided sequence   Log::info(::string)
++    {
++        provided chunk  ::CALL;
++    }
++}
--- a/series	Thu Jan 05 15:08:50 2012 +0100
+++ b/series	Thu Jan 05 15:10:21 2012 +0100
@@ -0,0 +1,1 @@
+rathaxes_add_a_linux_lkm.patch