mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-25 19:21:35 +01:00
modules: rename packages/kernel_modules to packages/lkmc
Then inside, split packages/lkmc into kernel_modules and userland, to keep userland out of the kernel_modules parent path, which makes no sense. Copy built modules and userland to the output rootfs overlay. Document Linux distro tradeoffs.
This commit is contained in:
@@ -1,5 +0,0 @@
|
||||
config BR2_PACKAGE_KERNEL_MODULES
|
||||
bool "kernel_modules"
|
||||
depends on BR2_LINUX_KERNEL
|
||||
help
|
||||
Linux Kernel Module Cheat.
|
||||
@@ -1 +0,0 @@
|
||||
name: KERNEL_MODULES
|
||||
@@ -1,34 +0,0 @@
|
||||
################################################################################
|
||||
#
|
||||
# kernel_modules
|
||||
#
|
||||
################################################################################
|
||||
|
||||
KERNEL_MODULES_VERSION = 1.0
|
||||
KERNEL_MODULES_SITE = $(BR2_EXTERNAL_KERNEL_MODULES_PATH)
|
||||
KERNEL_MODULES_SITE_METHOD = local
|
||||
|
||||
ifeq ($(BR2_PACKAGE_EIGEN),y)
|
||||
KERNEL_MODULES_DEPENDENCIES += eigen
|
||||
endif
|
||||
ifeq ($(BR2_PACKAGE_LIBDRM),y)
|
||||
KERNEL_MODULES_DEPENDENCIES += libdrm
|
||||
endif
|
||||
ifeq ($(BR2_PACKAGE_OPENBLAS),y)
|
||||
KERNEL_MODULES_DEPENDENCIES += openblas
|
||||
endif
|
||||
|
||||
define KERNEL_MODULES_BUILD_CMDS
|
||||
$(MAKE) -C '$(@D)' $(TARGET_CONFIGURE_OPTS) \
|
||||
BR2_PACKAGE_EIGEN="$(BR2_PACKAGE_EIGEN)" \
|
||||
BR2_PACKAGE_LIBDRM="$(BR2_PACKAGE_LIBDRM)" \
|
||||
BR2_PACKAGE_OPENBLAS="$(BR2_PACKAGE_OPENBLAS)" \
|
||||
;
|
||||
endef
|
||||
|
||||
define KERNEL_MODULES_INSTALL_TARGET_CMDS
|
||||
$(INSTALL) -D -m 0755 $(@D)/*.out '$(TARGET_DIR)'
|
||||
endef
|
||||
|
||||
$(eval $(kernel-module))
|
||||
$(eval $(generic-package))
|
||||
5
packages/lkmc/Config.in
Normal file
5
packages/lkmc/Config.in
Normal file
@@ -0,0 +1,5 @@
|
||||
config BR2_PACKAGE_LKMC
|
||||
bool "lkmc"
|
||||
depends on BR2_LINUX_KERNEL
|
||||
help
|
||||
Linux Kernel Module Cheat kernel modules and compiled userland examples.
|
||||
1
packages/lkmc/external.desc
Normal file
1
packages/lkmc/external.desc
Normal file
@@ -0,0 +1 @@
|
||||
name: LKMC
|
||||
@@ -4,21 +4,22 @@
|
||||
#
|
||||
################################################################################
|
||||
|
||||
KERNEL_MODULES_VERSION = 1.0
|
||||
KERNEL_MODULES_SITE = $(BR2_EXTERNAL_KERNEL_MODULES_PATH)
|
||||
KERNEL_MODULES_SITE_METHOD = local
|
||||
LKMC_VERSION = 1.0
|
||||
LKMC_SITE = $(BR2_EXTERNAL_LKMC_PATH)
|
||||
LKMC_SITE_METHOD = local
|
||||
LKMC_MODULE_SUBDIRS = kernel_modules
|
||||
|
||||
ifeq ($(BR2_PACKAGE_EIGEN),y)
|
||||
KERNEL_MODULES_DEPENDENCIES += eigen
|
||||
LKMC_DEPENDENCIES += eigen
|
||||
endif
|
||||
ifeq ($(BR2_PACKAGE_LIBDRM),y)
|
||||
KERNEL_MODULES_DEPENDENCIES += libdrm
|
||||
LKMC_DEPENDENCIES += libdrm
|
||||
endif
|
||||
ifeq ($(BR2_PACKAGE_OPENBLAS),y)
|
||||
KERNEL_MODULES_DEPENDENCIES += openblas
|
||||
LKMC_DEPENDENCIES += openblas
|
||||
endif
|
||||
|
||||
define KERNEL_MODULES_BUILD_CMDS
|
||||
define LKMC_BUILD_CMDS
|
||||
$(MAKE) -C '$(@D)/userland' $(TARGET_CONFIGURE_OPTS) \
|
||||
HAS_EIGEN="$(BR2_PACKAGE_EIGEN)" \
|
||||
HAS_LIBDRM="$(BR2_PACKAGE_LIBDRM)" \
|
||||
@@ -26,13 +27,12 @@ define KERNEL_MODULES_BUILD_CMDS
|
||||
;
|
||||
endef
|
||||
|
||||
define KERNEL_MODULES_INSTALL_TARGET_CMDS
|
||||
define LKMC_INSTALL_TARGET_CMDS
|
||||
# The modules are already installed by the kernel-module package type
|
||||
# under /lib/modules/**, but let's also copy the modules to the root
|
||||
# for insmod convenience.
|
||||
#
|
||||
# Modules can be still be easily inserted with "modprobe module" however.
|
||||
$(INSTALL) -D -m 0655 $(@D)/*.ko '$(TARGET_DIR)'
|
||||
$(INSTALL) -D -m 0755 $(@D)/userland/*.out '$(TARGET_DIR)'
|
||||
endef
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
ifeq ($(OBJECT_FILES),)
|
||||
obj-m += $(addsuffix .o, $(notdir $(basename $(filter-out %.mod.c, $(wildcard $(BR2_EXTERNAL_KERNEL_MODULES_PATH)/*.c)))))
|
||||
# Hardcoding LKMC_MODULE_SUBDIRS here because is not defined.
|
||||
obj-m += $(addsuffix .o, $(notdir $(basename $(filter-out %.mod.c, $(wildcard $(BR2_EXTERNAL_LKMC_PATH)/kernel_modules/*.c)))))
|
||||
else
|
||||
# Trying to do:
|
||||
# $(MAKE) -C '$(LINUX_DIR)' M='$(M)' hello.ko hello2.ko
|
||||
@@ -9,7 +9,7 @@
|
||||
#include <linux/printk.h> /* printk */
|
||||
#include <linux/uaccess.h> /* copy_from_user */
|
||||
|
||||
#include "anonymous_inode.h"
|
||||
#include "../anonymous_inode.h"
|
||||
|
||||
static struct dentry *debugfs_file;
|
||||
static u32 myval = 1;
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
static int myinit(void)
|
||||
{
|
||||
pr_info("hello init\n");
|
||||
pr_info("hello init 2\n");
|
||||
/* 0 for success, any negative value means failure,
|
||||
* E* consts if you want to specify failure cause.
|
||||
* https://www.linux.com/learn/kernel-newbie-corner-loadable-kernel-modules-coming-and-going */
|
||||
@@ -5,7 +5,7 @@
|
||||
#include <linux/printk.h> /* printk */
|
||||
#include <linux/uaccess.h> /* copy_from_user, copy_to_user */
|
||||
|
||||
#include "ioctl.h"
|
||||
#include "../ioctl.h"
|
||||
|
||||
static struct dentry *debugfs_file;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include <linux/skbuff.h>
|
||||
#include <net/sock.h>
|
||||
|
||||
#include "netlink.h"
|
||||
#include "../netlink.h"
|
||||
|
||||
struct sock *nl_sk = NULL;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include <linux/module.h>
|
||||
#include <linux/kernel.h>
|
||||
|
||||
#include "ring0.h"
|
||||
#include "../ring0.h"
|
||||
|
||||
static int myinit(void)
|
||||
{
|
||||
Reference in New Issue
Block a user