summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManuel Bentele2019-07-16 17:13:09 +0200
committerManuel Bentele2019-07-16 17:13:09 +0200
commit5aa4326cbff6e2e8422bc84387b46b1d709ba628 (patch)
tree320a77143191815862cb9c7a402a1ddb341a4eb4
parentAdded Makefile to build all software modules (diff)
downloadkernel-qcow2-5aa4326cbff6e2e8422bc84387b46b1d709ba628.tar.gz
kernel-qcow2-5aa4326cbff6e2e8422bc84387b46b1d709ba628.tar.xz
kernel-qcow2-5aa4326cbff6e2e8422bc84387b46b1d709ba628.zip
Extended Makefile to load kernel modules
Already built kernel modules can be load in an out-of-tree build with the load_modules target into the kernel. The correct loading order of the modules is preserved by this Makefile target. Furthermore, the modules can be unloaded with the target unload_modules later on.
-rw-r--r--Makefile25
m---------implementation/loop0
2 files changed, 24 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index 9ac1860..b009bb6 100644
--- a/Makefile
+++ b/Makefile
@@ -9,6 +9,7 @@
# Global configuration (file paths and config)
#------------------------------------------------------------------------------
KERNEL_SRC_DIR := $(shell pwd)/implementation/loop
+KERNEL_MOD_PATH := drivers/block/loop/
KERNEL_HDR_DIR := /lib/modules/$(shell uname -r)/build
LOSETUP_SRC_DIR := $(shell pwd)/implementation/losetup
KERNEL_MOD_CONFIG := $(shell pwd)/config/kernel-qcow2_x86-64_module.config
@@ -19,7 +20,7 @@ LOCAL_MOD_CONFIG += CONFIG_BLK_DEV_LOOP_FILE_FMT_QCOW=m
BUILD ?= vanilla
KERNEL_DIR ?= $(KERNEL_SRC_DIR)
CONFIG ?= KCONFIG_CONFIG=$(KERNEL_MOD_CONFIG)
-TARGET_PATH_PREFX ?= drivers/block/loop/
+TARGET_PATH_PREFX ?= $(KERNEL_MOD_PATH)
ifeq ($(BUILD),out-of-tree)
PATCH = patch
@@ -73,6 +74,28 @@ clean_losetup:
@cd $(LOSETUP_SRC_DIR) && \
$(MAKE) --no-print-directory clean
+ifeq ($(BUILD),out-of-tree)
+loop.load: loop.ko
+loop_file_fmt_raw.load: loop_file_fmt_raw.ko loop.load
+loop_file_fmt_qcow.load: loop_file_fmt_qcow.ko loop.load
+
+loop.unload: loop_file_fmt_raw.unload loop_file_fmt_qcow.unload
+loop_file_fmt_raw.unload:
+loop_file_fmt_qcow.unload:
+
+load_modules: loop.load loop_file_fmt_raw.load loop_file_fmt_qcow.load
+
+unload_modules: loop_file_fmt_qcow.unload loop_file_fmt_raw.unload loop.unload
+
+%.load:
+ $(call print_heading,"Load kernel module $(basename $@)")
+ sudo insmod $(KERNEL_SRC_DIR)/$(KERNEL_MOD_PATH)$(basename $@).ko
+
+%.unload:
+ $(call print_heading,"Unload kernel module $(basename $@)")
+ sudo rmmod $(basename $@)
+endif
+
#------------------------------------------------------------------------------
# Function definitions
#------------------------------------------------------------------------------
diff --git a/implementation/loop b/implementation/loop
-Subproject 6f5dc67946313ced450de6546fc7f28e0afdf1a
+Subproject b9562e46df0f2ddfbd01b99a44a3c4eaa3f32fe