diff options
| author | ririyeye <[email protected]> | 2026-04-23 10:39:33 +0800 |
|---|---|---|
| committer | ririyeye <[email protected]> | 2026-04-23 10:39:33 +0800 |
| commit | 7b2c43757d8d51997087f14d24716e384db21b1d (patch) | |
| tree | 548f05262f7d51974fd7cd1090dac728d9a3962f /tests/projects/linux/driver/hello_cross/src | |
| parent | c110d46d8cbb7ce929a98c58fc43668431f9fbe8 (diff) | |
test add linux driver cross compile example
Add a minimal platform.linux.module sample that documents custom linux headers/builddir usage for cross toolchains and verifies the new cross-build workflow.
Made-with: Cursor
Diffstat (limited to 'tests/projects/linux/driver/hello_cross/src')
| -rw-r--r-- | tests/projects/linux/driver/hello_cross/src/add.c | 4 | ||||
| -rw-r--r-- | tests/projects/linux/driver/hello_cross/src/add.h | 2 | ||||
| -rw-r--r-- | tests/projects/linux/driver/hello_cross/src/hello.c | 22 |
3 files changed, 28 insertions, 0 deletions
diff --git a/tests/projects/linux/driver/hello_cross/src/add.c b/tests/projects/linux/driver/hello_cross/src/add.c new file mode 100644 index 000000000..72c39a6e4 --- /dev/null +++ b/tests/projects/linux/driver/hello_cross/src/add.c @@ -0,0 +1,4 @@ +#include "add.h" +int add(int a, int b) { + return a + b; +} diff --git a/tests/projects/linux/driver/hello_cross/src/add.h b/tests/projects/linux/driver/hello_cross/src/add.h new file mode 100644 index 000000000..ba2df6926 --- /dev/null +++ b/tests/projects/linux/driver/hello_cross/src/add.h @@ -0,0 +1,2 @@ +#pragma once +int add(int a, int b); diff --git a/tests/projects/linux/driver/hello_cross/src/hello.c b/tests/projects/linux/driver/hello_cross/src/hello.c new file mode 100644 index 000000000..c32e48f61 --- /dev/null +++ b/tests/projects/linux/driver/hello_cross/src/hello.c @@ -0,0 +1,22 @@ +#include <linux/init.h> +#include <linux/module.h> +#include "add.h" + +MODULE_LICENSE("Dual BSD/GPL"); +MODULE_AUTHOR("Ruki"); +MODULE_DESCRIPTION("A simple Hello World Module"); +MODULE_ALIAS("a simplest module"); + +static int hello_init(void) +{ + printk(KERN_INFO "Hello World: %d\n", add(1, 2)); + return 0; +} + +static void hello_exit(void) +{ + printk(KERN_INFO "Goodbye World\n"); +} + +module_init(hello_init); +module_exit(hello_exit); |
