summaryrefslogtreecommitdiff
path: root/tests/projects/linux/driver/hello_custom/src
diff options
context:
space:
mode:
authorruki <[email protected]>2021-12-22 22:40:40 +0800
committerruki <[email protected]>2021-12-22 22:40:40 +0800
commitaf1618680f6ed2f90accafc534ffdfc7caf2f078 (patch)
treea2f8325aae688e37eed340713cbc5f46f87143db /tests/projects/linux/driver/hello_custom/src
parent4ec129f7b917c222c4c20838acef80315eb85adf (diff)
add linux driver test for custom
Diffstat (limited to 'tests/projects/linux/driver/hello_custom/src')
-rw-r--r--tests/projects/linux/driver/hello_custom/src/add.c3
-rw-r--r--tests/projects/linux/driver/hello_custom/src/hello.c23
2 files changed, 26 insertions, 0 deletions
diff --git a/tests/projects/linux/driver/hello_custom/src/add.c b/tests/projects/linux/driver/hello_custom/src/add.c
new file mode 100644
index 000000000..59aab4983
--- /dev/null
+++ b/tests/projects/linux/driver/hello_custom/src/add.c
@@ -0,0 +1,3 @@
+int add(int a, int b) {
+ return a + b;
+}
diff --git a/tests/projects/linux/driver/hello_custom/src/hello.c b/tests/projects/linux/driver/hello_custom/src/hello.c
new file mode 100644
index 000000000..414a03bb2
--- /dev/null
+++ b/tests/projects/linux/driver/hello_custom/src/hello.c
@@ -0,0 +1,23 @@
+#include <linux/init.h>
+#include <linux/module.h>
+
+MODULE_LICENSE("Dual BSD/GPL");
+MODULE_AUTHOR("Ruki");
+MODULE_DESCRIPTION("A simple Hello World Module");
+MODULE_ALIAS("a simplest module");
+
+int add(int a, int b);
+
+int hello_init(void)
+{
+ printk(KERN_INFO "Hello World: %d\n", add(1, 2));
+ return 0;
+}
+
+void hello_exit(void)
+{
+ printk(KERN_INFO "Goodbye World\n");
+}
+
+module_init(hello_init);
+module_exit(hello_exit);