mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-23 10:15:57 +01:00
Buildroot QEMU works. Nuff said.
This commit is contained in:
1
kernel_module/Config.in
Normal file
1
kernel_module/Config.in
Normal file
@@ -0,0 +1 @@
|
||||
source "$BR2_EXTERNAL_KERNEL_MODULE_PATH/package/kernel_module/Config.in"
|
||||
1
kernel_module/external.desc
Normal file
1
kernel_module/external.desc
Normal file
@@ -0,0 +1 @@
|
||||
name: KERNEL_MODULE
|
||||
1
kernel_module/external.mk
Normal file
1
kernel_module/external.mk
Normal file
@@ -0,0 +1 @@
|
||||
include $(sort $(wildcard $(BR2_EXTERNAL_KERNEL_MODULE_PATH)/package/*/*.mk))
|
||||
5
kernel_module/package/kernel_module/Config.in
Normal file
5
kernel_module/package/kernel_module/Config.in
Normal file
@@ -0,0 +1,5 @@
|
||||
config BR2_PACKAGE_KERNEL_MODULE
|
||||
bool "kernel_module"
|
||||
depends on BR2_LINUX_KERNEL
|
||||
help
|
||||
Linux Kernel Module Cheat.
|
||||
20
kernel_module/package/kernel_module/kernel_module.mk
Normal file
20
kernel_module/package/kernel_module/kernel_module.mk
Normal file
@@ -0,0 +1,20 @@
|
||||
################################################################################
|
||||
#
|
||||
# kernel_module
|
||||
#
|
||||
################################################################################
|
||||
|
||||
KERNEL_MODULE_VERSION = 1.0
|
||||
KERNEL_MODULE_SITE = $(BR2_EXTERNAL_KERNEL_MODULE_PATH)/package/kernel_module/src
|
||||
KERNEL_MODULE_SITE_METHOD = local
|
||||
|
||||
define KERNEL_MODULE_BUILD_CMDS
|
||||
$(MAKE) -C '$(@D)' LINUX_DIR='$(LINUX_DIR)' PWD='$(@D)' CC='$(TARGET_CC)' LD='$(TARGET_LD)'
|
||||
endef
|
||||
|
||||
define KERNEL_MODULE_INSTALL_TARGET_CMDS
|
||||
$(INSTALL) -D -m 0755 $(@D)/*.ko '$(TARGET_DIR)'
|
||||
endef
|
||||
|
||||
$(eval $(kernel-module))
|
||||
$(eval $(generic-package))
|
||||
10
kernel_module/package/kernel_module/src/Makefile
Normal file
10
kernel_module/package/kernel_module/src/Makefile
Normal file
@@ -0,0 +1,10 @@
|
||||
obj-m += hello.o hello2.o
|
||||
ccflags-y := -Wno-declaration-after-statement -std=gnu99
|
||||
|
||||
.PHONY: all clean
|
||||
|
||||
all:
|
||||
$(MAKE) -C '$(LINUX_DIR)' M='$(PWD)' modules
|
||||
|
||||
clean:
|
||||
$(MAKE) -C '$(LINUX_DIR)' M='$(PWD)' clean
|
||||
17
kernel_module/package/kernel_module/src/hello.c
Normal file
17
kernel_module/package/kernel_module/src/hello.c
Normal file
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
Hello world module.
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/kernel.h>
|
||||
|
||||
int init_module(void)
|
||||
{
|
||||
printk(KERN_INFO "hello init\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
void cleanup_module(void)
|
||||
{
|
||||
printk(KERN_INFO "hello cleanup\n");
|
||||
}
|
||||
19
kernel_module/package/kernel_module/src/hello2.c
Normal file
19
kernel_module/package/kernel_module/src/hello2.c
Normal file
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
Hello world module 2.
|
||||
|
||||
Mostly to check that our build infrastructure can handle more than one module!
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/kernel.h>
|
||||
|
||||
int init_module(void)
|
||||
{
|
||||
printk(KERN_INFO "hello2 init\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
void cleanup_module(void)
|
||||
{
|
||||
printk(KERN_INFO "hello2 cleanup\n");
|
||||
}
|
||||
Reference in New Issue
Block a user