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:
Ciro Santilli 六四事件 法轮功
2018-10-10 00:00:00 +00:00
parent c1d5d7d166
commit dae60aa248
97 changed files with 216 additions and 175 deletions

View File

@@ -1,5 +0,0 @@
config BR2_PACKAGE_KERNEL_MODULES
bool "kernel_modules"
depends on BR2_LINUX_KERNEL
help
Linux Kernel Module Cheat.

View File

@@ -1 +0,0 @@
name: KERNEL_MODULES

View File

@@ -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
View 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.

View File

@@ -0,0 +1 @@
name: LKMC

View File

@@ -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

View File

@@ -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

View File

@@ -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;

View File

@@ -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 */

View File

@@ -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;

View File

@@ -6,7 +6,7 @@
#include <linux/skbuff.h>
#include <net/sock.h>
#include "netlink.h"
#include "../netlink.h"
struct sock *nl_sk = NULL;

View File

@@ -3,7 +3,7 @@
#include <linux/module.h>
#include <linux/kernel.h>
#include "ring0.h"
#include "../ring0.h"
static int myinit(void)
{