Add example kernel module
This commit is contained in:
parent
0e03daf21c
commit
97842d8753
14
examples/kernel-module/.gitignore
vendored
Normal file
14
examples/kernel-module/.gitignore
vendored
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
.*.cmd
|
||||||
|
.tmp_versions
|
||||||
|
Module.symvers
|
||||||
|
*.ko
|
||||||
|
*.mod.c
|
||||||
|
*.o.d
|
||||||
|
*.o
|
||||||
|
modules.order
|
||||||
|
*.gcno
|
||||||
|
.#*
|
||||||
|
GPATH
|
||||||
|
GRTAGS
|
||||||
|
GTAGS
|
||||||
|
.cache.mk
|
17
examples/kernel-module/.out-of-tree.toml
Normal file
17
examples/kernel-module/.out-of-tree.toml
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
# out-of-tree configuration file
|
||||||
|
# docs at https://out-of-tree.io
|
||||||
|
name = "out-of-tree module example"
|
||||||
|
type = "module"
|
||||||
|
|
||||||
|
[[supported_kernels]]
|
||||||
|
# Can be Ubuntu/CentOS/Debian/etc.
|
||||||
|
distro_type = "Ubuntu"
|
||||||
|
# regex for `uname -r`
|
||||||
|
# See also: regex-golang.appspot.com
|
||||||
|
release_mask = "4.4.0-70-.*"
|
||||||
|
|
||||||
|
# [[supported_kernels]] may be defined unlimited number of times
|
||||||
|
[[supported_kernels]]
|
||||||
|
distro_type = "Ubuntu"
|
||||||
|
# Also you can use only one kernel
|
||||||
|
release_mask = "4.15.0-29-generic"
|
15
examples/kernel-module/Makefile
Normal file
15
examples/kernel-module/Makefile
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
# out-of-tree called make with two arguments -- kernel headers path and name
|
||||||
|
# of target binary that MUST be produced by makefile
|
||||||
|
# e.g.:
|
||||||
|
# make KERNEL=/lib/modules/4.8.0-58-generic/build TARGET=hello-world.ko
|
||||||
|
KERNEL := /lib/modules/$(shell uname -r)/build
|
||||||
|
TARGET := out-of-tree-module-example
|
||||||
|
|
||||||
|
obj-m += $(TARGET).o
|
||||||
|
$(TARGET)-objs = module.o
|
||||||
|
|
||||||
|
all:
|
||||||
|
make -C $(KERNEL) M=$(PWD) modules
|
||||||
|
|
||||||
|
clean:
|
||||||
|
make -C $(KERNEL) M=$(PWD) clean
|
3
examples/kernel-module/README.md
Normal file
3
examples/kernel-module/README.md
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# out-of-tree kernel module example
|
||||||
|
|
||||||
|
See .out-of-tree.toml
|
13
examples/kernel-module/module.c
Normal file
13
examples/kernel-module/module.c
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#include <linux/module.h>
|
||||||
|
#include <linux/kernel.h>
|
||||||
|
|
||||||
|
int init_module(void)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void cleanup_module(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
MODULE_LICENSE("GPL");
|
Loading…
Reference in New Issue
Block a user