From 5da21a5fe31a6f180bb3fb97f5a8e61541ab7b2e Mon Sep 17 00:00:00 2001 From: jameszow Date: Fri, 15 Sep 2023 16:47:33 +0800 Subject: [PATCH] update makefile and readme file space --- 01_wait_forever/Makefile | 44 ++++----- 02_runtime_init/Makefile | 44 ++++----- 02_runtime_init/README.md | 3 +- 03_hacky_hello_world/Makefile | 48 +++++----- 03_hacky_hello_world/README.md | 8 +- 04_safe_globals/Makefile | 48 +++++----- 05_drivers_gpio_uart/Makefile | 52 +++++------ 05_drivers_gpio_uart/README.md | 10 +- 06_uart_chainloader/Makefile | 52 +++++------ 06_uart_chainloader/README.md | 13 ++- 07_timestamps/Makefile | 52 +++++------ 07_timestamps/README.md | 12 +-- 08_hw_debug_JTAG/Makefile | 64 ++++++------- 08_hw_debug_JTAG/README.md | 12 +-- 09_privilege_level/Makefile | 64 ++++++------- .../Makefile | 64 ++++++------- 11_exceptions_part1_groundwork/Makefile | 64 ++++++------- 12_integrated_testing/Makefile | 76 +++++++-------- 12_integrated_testing/README.md | 8 +- 13_exceptions_part2_peripheral_IRQs/Makefile | 76 +++++++-------- 14_virtual_mem_part2_mmio_remap/Makefile | 76 +++++++-------- .../Makefile | 84 ++++++++--------- .../README.md | 28 +++--- .../Makefile | 84 ++++++++--------- 17_kernel_symbols/Makefile | 92 +++++++++---------- 17_kernel_symbols/README.md | 20 ++-- 17_kernel_symbols/kernel_symbols.mk | 4 +- 18_backtrace/Makefile | 92 +++++++++---------- 18_backtrace/README.md | 4 +- 18_backtrace/kernel_symbols.mk | 4 +- 19_kernel_heap/Makefile | 92 +++++++++---------- 19_kernel_heap/kernel_symbols.mk | 4 +- 20_timer_callbacks/Makefile | 92 +++++++++---------- 20_timer_callbacks/kernel_symbols.mk | 4 +- X1_JTAG_boot/Makefile | 52 +++++------ 35 files changed, 772 insertions(+), 774 deletions(-) diff --git a/01_wait_forever/Makefile b/01_wait_forever/Makefile index cd5079d7..51c128f7 100644 --- a/01_wait_forever/Makefile +++ b/01_wait_forever/Makefile @@ -88,9 +88,9 @@ OBJCOPY_CMD = rust-objcopy \ EXEC_QEMU = $(QEMU_BINARY) -M $(QEMU_MACHINE_TYPE) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Dockerization -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i @@ -107,24 +107,24 @@ DOCKER_TOOLS = $(DOCKER_CMD) $(DOCKER_IMAGE) all: $(KERNEL_BIN) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Save the configuration as a file, so make understands if it changed. -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ $(LAST_BUILD_CONFIG): @rm -f target/*.build_config @mkdir -p target @touch $(LAST_BUILD_CONFIG) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Compile the kernel ELF -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ $(KERNEL_ELF): $(KERNEL_ELF_DEPS) $(call color_header, "Compiling kernel ELF - $(BSP)") @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Generate the stripped kernel binary -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ $(KERNEL_BIN): $(KERNEL_ELF) $(call color_header, "Generating stripped binary") @$(OBJCOPY_CMD) $(KERNEL_ELF) $(KERNEL_BIN) @@ -133,16 +133,16 @@ $(KERNEL_BIN): $(KERNEL_ELF) $(call color_progress_prefix, "Size") $(call disk_usage_KiB, $(KERNEL_BIN)) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Generate the documentation -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ doc: $(call color_header, "Generating docs") @$(DOC_CMD) --document-private-items --open -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run the kernel in QEMU -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. qemu: @@ -155,37 +155,37 @@ qemu: $(KERNEL_BIN) @$(DOCKER_QEMU) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN) endif -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run clippy -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ clippy: @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Clean -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ clean: rm -rf target $(KERNEL_BIN) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run readelf -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ readelf: $(KERNEL_ELF) $(call color_header, "Launching readelf") @$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run objdump -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ objdump: $(KERNEL_ELF) $(call color_header, "Launching objdump") @$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \ --section .text \ $(KERNEL_ELF) | rustfilt -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run nm -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ nm: $(KERNEL_ELF) $(call color_header, "Launching nm") @$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt diff --git a/02_runtime_init/Makefile b/02_runtime_init/Makefile index 6a62f276..893564e2 100644 --- a/02_runtime_init/Makefile +++ b/02_runtime_init/Makefile @@ -88,9 +88,9 @@ OBJCOPY_CMD = rust-objcopy \ EXEC_QEMU = $(QEMU_BINARY) -M $(QEMU_MACHINE_TYPE) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Dockerization -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i @@ -107,24 +107,24 @@ DOCKER_TOOLS = $(DOCKER_CMD) $(DOCKER_IMAGE) all: $(KERNEL_BIN) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Save the configuration as a file, so make understands if it changed. -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ $(LAST_BUILD_CONFIG): @rm -f target/*.build_config @mkdir -p target @touch $(LAST_BUILD_CONFIG) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Compile the kernel ELF -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ $(KERNEL_ELF): $(KERNEL_ELF_DEPS) $(call color_header, "Compiling kernel ELF - $(BSP)") @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Generate the stripped kernel binary -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ $(KERNEL_BIN): $(KERNEL_ELF) $(call color_header, "Generating stripped binary") @$(OBJCOPY_CMD) $(KERNEL_ELF) $(KERNEL_BIN) @@ -133,16 +133,16 @@ $(KERNEL_BIN): $(KERNEL_ELF) $(call color_progress_prefix, "Size") $(call disk_usage_KiB, $(KERNEL_BIN)) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Generate the documentation -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ doc: $(call color_header, "Generating docs") @$(DOC_CMD) --document-private-items --open -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run the kernel in QEMU -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. qemu: @@ -155,28 +155,28 @@ qemu: $(KERNEL_BIN) @$(DOCKER_QEMU) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN) endif -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run clippy -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ clippy: @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Clean -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ clean: rm -rf target $(KERNEL_BIN) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run readelf -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ readelf: $(KERNEL_ELF) $(call color_header, "Launching readelf") @$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run objdump -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ objdump: $(KERNEL_ELF) $(call color_header, "Launching objdump") @$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \ @@ -184,9 +184,9 @@ objdump: $(KERNEL_ELF) --section .rodata \ $(KERNEL_ELF) | rustfilt -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run nm -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ nm: $(KERNEL_ELF) $(call color_header, "Launching nm") @$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt diff --git a/02_runtime_init/README.md b/02_runtime_init/README.md index 05ef98ba..1082f18c 100644 --- a/02_runtime_init/README.md +++ b/02_runtime_init/README.md @@ -58,8 +58,7 @@ diff -uNr 01_wait_forever/Makefile 02_runtime_init/Makefile --section .text \ + --section .rodata \ $(KERNEL_ELF) | rustfilt - - ## ------------------------------------------------------------------------------ + ##------------------------------------------------------------------------------ diff -uNr 01_wait_forever/src/_arch/aarch64/cpu/boot.rs 02_runtime_init/src/_arch/aarch64/cpu/boot.rs --- 01_wait_forever/src/_arch/aarch64/cpu/boot.rs diff --git a/03_hacky_hello_world/Makefile b/03_hacky_hello_world/Makefile index 3912b1bf..ce5aff09 100644 --- a/03_hacky_hello_world/Makefile +++ b/03_hacky_hello_world/Makefile @@ -89,9 +89,9 @@ OBJCOPY_CMD = rust-objcopy \ EXEC_QEMU = $(QEMU_BINARY) -M $(QEMU_MACHINE_TYPE) EXEC_TEST_DISPATCH = ruby ../common/tests/dispatch.rb -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Dockerization -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i DOCKER_ARG_DIR_COMMON = -v $(shell pwd)/../common:/work/common @@ -110,24 +110,24 @@ DOCKER_TEST = $(DOCKER_CMD) $(DOCKER_ARG_DIR_COMMON) $(DOCKER_IMAGE) all: $(KERNEL_BIN) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Save the configuration as a file, so make understands if it changed. -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ $(LAST_BUILD_CONFIG): @rm -f target/*.build_config @mkdir -p target @touch $(LAST_BUILD_CONFIG) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Compile the kernel ELF -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ $(KERNEL_ELF): $(KERNEL_ELF_DEPS) $(call color_header, "Compiling kernel ELF - $(BSP)") @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Generate the stripped kernel binary -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ $(KERNEL_BIN): $(KERNEL_ELF) $(call color_header, "Generating stripped binary") @$(OBJCOPY_CMD) $(KERNEL_ELF) $(KERNEL_BIN) @@ -136,16 +136,16 @@ $(KERNEL_BIN): $(KERNEL_ELF) $(call color_progress_prefix, "Size") $(call disk_usage_KiB, $(KERNEL_BIN)) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Generate the documentation -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ doc: $(call color_header, "Generating docs") @$(DOC_CMD) --document-private-items --open -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run the kernel in QEMU -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. qemu: @@ -158,28 +158,28 @@ qemu: $(KERNEL_BIN) @$(DOCKER_QEMU) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN) endif -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run clippy -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ clippy: @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Clean -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ clean: rm -rf target $(KERNEL_BIN) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run readelf -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ readelf: $(KERNEL_ELF) $(call color_header, "Launching readelf") @$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run objdump -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ objdump: $(KERNEL_ELF) $(call color_header, "Launching objdump") @$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \ @@ -187,9 +187,9 @@ objdump: $(KERNEL_ELF) --section .rodata \ $(KERNEL_ELF) | rustfilt -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run nm -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ nm: $(KERNEL_ELF) $(call color_header, "Launching nm") @$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt @@ -208,9 +208,9 @@ test_boot test: else # QEMU is supported. -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run boot test -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ test_boot: $(KERNEL_BIN) $(call color_header, "Boot test - $(BSP)") @$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN) diff --git a/03_hacky_hello_world/README.md b/03_hacky_hello_world/README.md index 7aa5cbb7..07bf4503 100644 --- a/03_hacky_hello_world/README.md +++ b/03_hacky_hello_world/README.md @@ -79,9 +79,9 @@ diff -uNr 02_runtime_init/Makefile 03_hacky_hello_world/Makefile +EXEC_QEMU = $(QEMU_BINARY) -M $(QEMU_MACHINE_TYPE) +EXEC_TEST_DISPATCH = ruby ../common/tests/dispatch.rb - ## ------------------------------------------------------------------------------ + ##------------------------------------------------------------------------------ ## Dockerization - ## ------------------------------------------------------------------------------ + ##------------------------------------------------------------------------------ -DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial -DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i +DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial @@ -113,9 +113,9 @@ diff -uNr 02_runtime_init/Makefile 03_hacky_hello_world/Makefile + +else # QEMU is supported. + -+## ------------------------------------------------------------------------------ ++##------------------------------------------------------------------------------ +## Run boot test -+## ------------------------------------------------------------------------------ ++##------------------------------------------------------------------------------ +test_boot: $(KERNEL_BIN) + $(call color_header, "Boot test - $(BSP)") + @$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN) diff --git a/04_safe_globals/Makefile b/04_safe_globals/Makefile index 3912b1bf..ce5aff09 100644 --- a/04_safe_globals/Makefile +++ b/04_safe_globals/Makefile @@ -89,9 +89,9 @@ OBJCOPY_CMD = rust-objcopy \ EXEC_QEMU = $(QEMU_BINARY) -M $(QEMU_MACHINE_TYPE) EXEC_TEST_DISPATCH = ruby ../common/tests/dispatch.rb -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Dockerization -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i DOCKER_ARG_DIR_COMMON = -v $(shell pwd)/../common:/work/common @@ -110,24 +110,24 @@ DOCKER_TEST = $(DOCKER_CMD) $(DOCKER_ARG_DIR_COMMON) $(DOCKER_IMAGE) all: $(KERNEL_BIN) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Save the configuration as a file, so make understands if it changed. -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ $(LAST_BUILD_CONFIG): @rm -f target/*.build_config @mkdir -p target @touch $(LAST_BUILD_CONFIG) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Compile the kernel ELF -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ $(KERNEL_ELF): $(KERNEL_ELF_DEPS) $(call color_header, "Compiling kernel ELF - $(BSP)") @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Generate the stripped kernel binary -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ $(KERNEL_BIN): $(KERNEL_ELF) $(call color_header, "Generating stripped binary") @$(OBJCOPY_CMD) $(KERNEL_ELF) $(KERNEL_BIN) @@ -136,16 +136,16 @@ $(KERNEL_BIN): $(KERNEL_ELF) $(call color_progress_prefix, "Size") $(call disk_usage_KiB, $(KERNEL_BIN)) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Generate the documentation -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ doc: $(call color_header, "Generating docs") @$(DOC_CMD) --document-private-items --open -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run the kernel in QEMU -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. qemu: @@ -158,28 +158,28 @@ qemu: $(KERNEL_BIN) @$(DOCKER_QEMU) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN) endif -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run clippy -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ clippy: @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Clean -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ clean: rm -rf target $(KERNEL_BIN) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run readelf -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ readelf: $(KERNEL_ELF) $(call color_header, "Launching readelf") @$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run objdump -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ objdump: $(KERNEL_ELF) $(call color_header, "Launching objdump") @$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \ @@ -187,9 +187,9 @@ objdump: $(KERNEL_ELF) --section .rodata \ $(KERNEL_ELF) | rustfilt -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run nm -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ nm: $(KERNEL_ELF) $(call color_header, "Launching nm") @$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt @@ -208,9 +208,9 @@ test_boot test: else # QEMU is supported. -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run boot test -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ test_boot: $(KERNEL_BIN) $(call color_header, "Boot test - $(BSP)") @$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN) diff --git a/05_drivers_gpio_uart/Makefile b/05_drivers_gpio_uart/Makefile index ae15cc88..f5135d1e 100644 --- a/05_drivers_gpio_uart/Makefile +++ b/05_drivers_gpio_uart/Makefile @@ -93,9 +93,9 @@ EXEC_QEMU = $(QEMU_BINARY) -M $(QEMU_MACHINE_TYPE) EXEC_TEST_DISPATCH = ruby ../common/tests/dispatch.rb EXEC_MINITERM = ruby ../common/serial/miniterm.rb -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Dockerization -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i DOCKER_ARG_DIR_COMMON = -v $(shell pwd)/../common:/work/common @@ -122,24 +122,24 @@ endif all: $(KERNEL_BIN) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Save the configuration as a file, so make understands if it changed. -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ $(LAST_BUILD_CONFIG): @rm -f target/*.build_config @mkdir -p target @touch $(LAST_BUILD_CONFIG) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Compile the kernel ELF -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ $(KERNEL_ELF): $(KERNEL_ELF_DEPS) $(call color_header, "Compiling kernel ELF - $(BSP)") @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Generate the stripped kernel binary -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ $(KERNEL_BIN): $(KERNEL_ELF) $(call color_header, "Generating stripped binary") @$(OBJCOPY_CMD) $(KERNEL_ELF) $(KERNEL_BIN) @@ -148,16 +148,16 @@ $(KERNEL_BIN): $(KERNEL_ELF) $(call color_progress_prefix, "Size") $(call disk_usage_KiB, $(KERNEL_BIN)) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Generate the documentation -## ------------------------------------------------------------------------------ +##----------------------------------------------------------------------------- doc: $(call color_header, "Generating docs") @$(DOC_CMD) --document-private-items --open -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run the kernel in QEMU -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. qemu: @@ -171,34 +171,34 @@ qemu: $(KERNEL_BIN) endif -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Connect to the target's serial -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ miniterm: @$(DOCKER_MINITERM) $(EXEC_MINITERM) $(DEV_SERIAL) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run clippy -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ clippy: @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Clean -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ clean: rm -rf target $(KERNEL_BIN) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run readelf -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ readelf: $(KERNEL_ELF) $(call color_header, "Launching readelf") @$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run objdump -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ objdump: $(KERNEL_ELF) $(call color_header, "Launching objdump") @$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \ @@ -206,9 +206,9 @@ objdump: $(KERNEL_ELF) --section .rodata \ $(KERNEL_ELF) | rustfilt -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run nm -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ nm: $(KERNEL_ELF) $(call color_header, "Launching nm") @$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt @@ -227,9 +227,9 @@ test_boot test: else # QEMU is supported. -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run boot test -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ test_boot: $(KERNEL_BIN) $(call color_header, "Boot test - $(BSP)") @$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN) diff --git a/05_drivers_gpio_uart/README.md b/05_drivers_gpio_uart/README.md index 358bc256..e6e5dd64 100644 --- a/05_drivers_gpio_uart/README.md +++ b/05_drivers_gpio_uart/README.md @@ -202,7 +202,7 @@ diff -uNr 04_safe_globals/Makefile 05_drivers_gpio_uart/Makefile EXEC_TEST_DISPATCH = ruby ../common/tests/dispatch.rb +EXEC_MINITERM = ruby ../common/serial/miniterm.rb - ## ------------------------------------------------------------------------------ + ##------------------------------------------------------------------------------ ## Dockerization @@ -95,18 +99,26 @@ DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial @@ -239,15 +239,15 @@ diff -uNr 04_safe_globals/Makefile 05_drivers_gpio_uart/Makefile + endif - ## ------------------------------------------------------------------------------ + ##------------------------------------------------------------------------------ +## Connect to the target's serial -+## ------------------------------------------------------------------------------ ++##------------------------------------------------------------------------------ +miniterm: + @$(DOCKER_MINITERM) $(EXEC_MINITERM) $(DEV_SERIAL) + -+## ------------------------------------------------------------------------------ ++##------------------------------------------------------------------------------ ## Run clippy - ## ------------------------------------------------------------------------------ + ##------------------------------------------------------------------------------ clippy: diff -uNr 04_safe_globals/src/_arch/aarch64/cpu.rs 05_drivers_gpio_uart/src/_arch/aarch64/cpu.rs diff --git a/06_uart_chainloader/Makefile b/06_uart_chainloader/Makefile index 705835cc..3366de31 100644 --- a/06_uart_chainloader/Makefile +++ b/06_uart_chainloader/Makefile @@ -95,9 +95,9 @@ EXEC_QEMU = $(QEMU_BINARY) -M $(QEMU_MACHINE_TYPE) EXEC_TEST_MINIPUSH = ruby tests/chainboot_test.rb EXEC_MINIPUSH = ruby ../common/serial/minipush.rb -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Dockerization -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i DOCKER_ARG_DIR_COMMON = -v $(shell pwd)/../common:/work/common @@ -124,24 +124,24 @@ endif all: $(KERNEL_BIN) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Save the configuration as a file, so make understands if it changed. -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ $(LAST_BUILD_CONFIG): @rm -f target/*.build_config @mkdir -p target @touch $(LAST_BUILD_CONFIG) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Compile the kernel ELF -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ $(KERNEL_ELF): $(KERNEL_ELF_DEPS) $(call color_header, "Compiling kernel ELF - $(BSP)") @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Generate the stripped kernel binary -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ $(KERNEL_BIN): $(KERNEL_ELF) $(call color_header, "Generating stripped binary") @$(OBJCOPY_CMD) $(KERNEL_ELF) $(KERNEL_BIN) @@ -150,16 +150,16 @@ $(KERNEL_BIN): $(KERNEL_ELF) $(call color_progress_prefix, "Size") $(call disk_usage_KiB, $(KERNEL_BIN)) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Generate the documentation -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ doc: $(call color_header, "Generating docs") @$(DOC_CMD) --document-private-items --open -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run the kernel in QEMU -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. qemu qemuasm: @@ -177,34 +177,34 @@ qemuasm: $(KERNEL_BIN) endif -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Push the kernel to the real HW target -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ chainboot: $(KERNEL_BIN) @$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(CHAINBOOT_DEMO_PAYLOAD) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run clippy -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ clippy: @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Clean -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ clean: rm -rf target $(KERNEL_BIN) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run readelf -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ readelf: $(KERNEL_ELF) $(call color_header, "Launching readelf") @$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run objdump -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ objdump: $(KERNEL_ELF) $(call color_header, "Launching objdump") @$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \ @@ -212,9 +212,9 @@ objdump: $(KERNEL_ELF) --section .rodata \ $(KERNEL_ELF) | rustfilt -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run nm -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ nm: $(KERNEL_ELF) $(call color_header, "Launching nm") @$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt @@ -233,9 +233,9 @@ test_boot test: else # QEMU is supported. -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run boot test -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ test_boot: $(KERNEL_BIN) $(call color_header, "Boot test - $(BSP)") @$(DOCKER_TEST) $(EXEC_TEST_MINIPUSH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) \ diff --git a/06_uart_chainloader/README.md b/06_uart_chainloader/README.md index 75b9da9b..5e4efe25 100644 --- a/06_uart_chainloader/README.md +++ b/06_uart_chainloader/README.md @@ -199,7 +199,7 @@ diff -uNr 05_drivers_gpio_uart/Makefile 06_uart_chainloader/Makefile +EXEC_TEST_MINIPUSH = ruby tests/chainboot_test.rb +EXEC_MINIPUSH = ruby ../common/serial/minipush.rb - ## ------------------------------------------------------------------------------ + ##------------------------------------------------------------------------------ ## Dockerization @@ -110,7 +112,7 @@ ifeq ($(shell uname -s),Linux) @@ -220,7 +220,7 @@ diff -uNr 05_drivers_gpio_uart/Makefile 06_uart_chainloader/Makefile all: $(KERNEL_BIN) @@ -160,7 +162,7 @@ - ## ------------------------------------------------------------------------------ + ##------------------------------------------------------------------------------ ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. -qemu: @@ -237,20 +237,19 @@ diff -uNr 05_drivers_gpio_uart/Makefile 06_uart_chainloader/Makefile + @$(DOCKER_QEMU) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN) -d in_asm + endif - - ## ------------------------------------------------------------------------------ + ##------------------------------------------------------------------------------ -## Connect to the target's serial +## Push the kernel to the real HW target - ## ------------------------------------------------------------------------------ + ##------------------------------------------------------------------------------ -miniterm: - @$(DOCKER_MINITERM) $(EXEC_MINITERM) $(DEV_SERIAL) +chainboot: $(KERNEL_BIN) + @$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(CHAINBOOT_DEMO_PAYLOAD) - ## ------------------------------------------------------------------------------ + ##------------------------------------------------------------------------------ ## Run clippy @@ -232,7 +238,8 @@ - ## ------------------------------------------------------------------------------ + ##------------------------------------------------------------------------------ test_boot: $(KERNEL_BIN) $(call color_header, "Boot test - $(BSP)") - @$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN) diff --git a/07_timestamps/Makefile b/07_timestamps/Makefile index 85f709a0..b13f0dfb 100644 --- a/07_timestamps/Makefile +++ b/07_timestamps/Makefile @@ -93,9 +93,9 @@ EXEC_QEMU = $(QEMU_BINARY) -M $(QEMU_MACHINE_TYPE) EXEC_TEST_DISPATCH = ruby ../common/tests/dispatch.rb EXEC_MINIPUSH = ruby ../common/serial/minipush.rb -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Dockerization -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i DOCKER_ARG_DIR_COMMON = -v $(shell pwd)/../common:/work/common @@ -122,24 +122,24 @@ endif all: $(KERNEL_BIN) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Save the configuration as a file, so make understands if it changed. -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ $(LAST_BUILD_CONFIG): @rm -f target/*.build_config @mkdir -p target @touch $(LAST_BUILD_CONFIG) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Compile the kernel ELF -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ $(KERNEL_ELF): $(KERNEL_ELF_DEPS) $(call color_header, "Compiling kernel ELF - $(BSP)") @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Generate the stripped kernel binary -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ $(KERNEL_BIN): $(KERNEL_ELF) $(call color_header, "Generating stripped binary") @$(OBJCOPY_CMD) $(KERNEL_ELF) $(KERNEL_BIN) @@ -148,16 +148,16 @@ $(KERNEL_BIN): $(KERNEL_ELF) $(call color_progress_prefix, "Size") $(call disk_usage_KiB, $(KERNEL_BIN)) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Generate the documentation -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ doc: $(call color_header, "Generating docs") @$(DOC_CMD) --document-private-items --open -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run the kernel in QEMU -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. qemu: @@ -171,34 +171,34 @@ qemu: $(KERNEL_BIN) endif -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Push the kernel to the real HW target -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ chainboot: $(KERNEL_BIN) @$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(KERNEL_BIN) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run clippy -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ clippy: @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Clean -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ clean: rm -rf target $(KERNEL_BIN) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run readelf -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ readelf: $(KERNEL_ELF) $(call color_header, "Launching readelf") @$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run objdump -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ objdump: $(KERNEL_ELF) $(call color_header, "Launching objdump") @$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \ @@ -206,9 +206,9 @@ objdump: $(KERNEL_ELF) --section .rodata \ $(KERNEL_ELF) | rustfilt -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run nm -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ nm: $(KERNEL_ELF) $(call color_header, "Launching nm") @$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt @@ -227,9 +227,9 @@ test_boot test: else # QEMU is supported. -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run boot test -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ test_boot: $(KERNEL_BIN) $(call color_header, "Boot test - $(BSP)") @$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN) diff --git a/07_timestamps/README.md b/07_timestamps/README.md index e2880214..af44e8cc 100644 --- a/07_timestamps/README.md +++ b/07_timestamps/README.md @@ -121,9 +121,9 @@ diff -uNr 06_uart_chainloader/Makefile 07_timestamps/Makefile +EXEC_TEST_DISPATCH = ruby ../common/tests/dispatch.rb EXEC_MINIPUSH = ruby ../common/serial/minipush.rb - ## ------------------------------------------------------------------------------ + ##------------------------------------------------------------------------------ @@ -162,7 +160,7 @@ - ## ------------------------------------------------------------------------------ + ##------------------------------------------------------------------------------ ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. -qemu qemuasm: @@ -141,17 +141,17 @@ diff -uNr 06_uart_chainloader/Makefile 07_timestamps/Makefile - endif - ## ------------------------------------------------------------------------------ + ##------------------------------------------------------------------------------ ## Push the kernel to the real HW target - ## ------------------------------------------------------------------------------ + ##------------------------------------------------------------------------------ chainboot: $(KERNEL_BIN) - @$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(CHAINBOOT_DEMO_PAYLOAD) + @$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(KERNEL_BIN) - ## ------------------------------------------------------------------------------ + ##------------------------------------------------------------------------------ ## Run clippy @@ -238,8 +232,7 @@ - ## ------------------------------------------------------------------------------ + ##------------------------------------------------------------------------------ test_boot: $(KERNEL_BIN) $(call color_header, "Boot test - $(BSP)") - @$(DOCKER_TEST) $(EXEC_TEST_MINIPUSH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) \ diff --git a/08_hw_debug_JTAG/Makefile b/08_hw_debug_JTAG/Makefile index 7c8eef4c..9549f092 100644 --- a/08_hw_debug_JTAG/Makefile +++ b/08_hw_debug_JTAG/Makefile @@ -97,9 +97,9 @@ EXEC_QEMU = $(QEMU_BINARY) -M $(QEMU_MACHINE_TYPE) EXEC_TEST_DISPATCH = ruby ../common/tests/dispatch.rb EXEC_MINIPUSH = ruby ../common/serial/minipush.rb -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Dockerization -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i DOCKER_ARG_DIR_COMMON = -v $(shell pwd)/../common:/work/common @@ -133,24 +133,24 @@ endif all: $(KERNEL_BIN) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Save the configuration as a file, so make understands if it changed. -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ $(LAST_BUILD_CONFIG): @rm -f target/*.build_config @mkdir -p target @touch $(LAST_BUILD_CONFIG) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Compile the kernel ELF -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ $(KERNEL_ELF): $(KERNEL_ELF_DEPS) $(call color_header, "Compiling kernel ELF - $(BSP)") @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Generate the stripped kernel binary -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ $(KERNEL_BIN): $(KERNEL_ELF) $(call color_header, "Generating stripped binary") @$(OBJCOPY_CMD) $(KERNEL_ELF) $(KERNEL_BIN) @@ -159,16 +159,16 @@ $(KERNEL_BIN): $(KERNEL_ELF) $(call color_progress_prefix, "Size") $(call disk_usage_KiB, $(KERNEL_BIN)) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Generate the documentation -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ doc: $(call color_header, "Generating docs") @$(DOC_CMD) --document-private-items --open -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run the kernel in QEMU -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. qemu: @@ -182,34 +182,34 @@ qemu: $(KERNEL_BIN) endif -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Push the kernel to the real HW target -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ chainboot: $(KERNEL_BIN) @$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(KERNEL_BIN) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run clippy -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ clippy: @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Clean -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ clean: rm -rf target $(KERNEL_BIN) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run readelf -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ readelf: $(KERNEL_ELF) $(call color_header, "Launching readelf") @$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run objdump -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ objdump: $(KERNEL_ELF) $(call color_header, "Launching objdump") @$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \ @@ -217,9 +217,9 @@ objdump: $(KERNEL_ELF) --section .rodata \ $(KERNEL_ELF) | rustfilt -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run nm -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ nm: $(KERNEL_ELF) $(call color_header, "Launching nm") @$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt @@ -231,22 +231,22 @@ nm: $(KERNEL_ELF) ##-------------------------------------------------------------------------------------------------- .PHONY: jtagboot openocd gdb gdb-opt0 -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Push the JTAG boot image to the real HW target -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ jtagboot: @$(DOCKER_JTAGBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(JTAG_BOOT_IMAGE) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Start OpenOCD session -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ openocd: $(call color_header, "Launching OpenOCD") @$(DOCKER_OPENOCD) openocd $(OPENOCD_ARG) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Start GDB session -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ gdb: RUSTC_MISC_ARGS += -C debuginfo=2 gdb-opt0: RUSTC_MISC_ARGS += -C debuginfo=2 -C opt-level=0 gdb gdb-opt0: $(KERNEL_ELF) @@ -267,9 +267,9 @@ test_boot test: else # QEMU is supported. -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run boot test -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ test_boot: $(KERNEL_BIN) $(call color_header, "Boot test - $(BSP)") @$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN) diff --git a/08_hw_debug_JTAG/README.md b/08_hw_debug_JTAG/README.md index b9c2c6cc..14928253 100644 --- a/08_hw_debug_JTAG/README.md +++ b/08_hw_debug_JTAG/README.md @@ -373,22 +373,22 @@ diff -uNr 07_timestamps/Makefile 08_hw_debug_JTAG/Makefile +##-------------------------------------------------------------------------------------------------- +.PHONY: jtagboot openocd gdb gdb-opt0 + -+## ------------------------------------------------------------------------------ ++##------------------------------------------------------------------------------ +## Push the JTAG boot image to the real HW target -+## ------------------------------------------------------------------------------ ++##------------------------------------------------------------------------------ +jtagboot: + @$(DOCKER_JTAGBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(JTAG_BOOT_IMAGE) + -+## ------------------------------------------------------------------------------ ++##------------------------------------------------------------------------------ +## Start OpenOCD session -+## ------------------------------------------------------------------------------ ++##------------------------------------------------------------------------------ +openocd: + $(call color_header, "Launching OpenOCD") + @$(DOCKER_OPENOCD) openocd $(OPENOCD_ARG) + -+## ------------------------------------------------------------------------------ ++##------------------------------------------------------------------------------ +## Start GDB session -+## ------------------------------------------------------------------------------ ++##------------------------------------------------------------------------------ +gdb: RUSTC_MISC_ARGS += -C debuginfo=2 +gdb-opt0: RUSTC_MISC_ARGS += -C debuginfo=2 -C opt-level=0 +gdb gdb-opt0: $(KERNEL_ELF) diff --git a/09_privilege_level/Makefile b/09_privilege_level/Makefile index 7c8eef4c..9549f092 100644 --- a/09_privilege_level/Makefile +++ b/09_privilege_level/Makefile @@ -97,9 +97,9 @@ EXEC_QEMU = $(QEMU_BINARY) -M $(QEMU_MACHINE_TYPE) EXEC_TEST_DISPATCH = ruby ../common/tests/dispatch.rb EXEC_MINIPUSH = ruby ../common/serial/minipush.rb -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Dockerization -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i DOCKER_ARG_DIR_COMMON = -v $(shell pwd)/../common:/work/common @@ -133,24 +133,24 @@ endif all: $(KERNEL_BIN) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Save the configuration as a file, so make understands if it changed. -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ $(LAST_BUILD_CONFIG): @rm -f target/*.build_config @mkdir -p target @touch $(LAST_BUILD_CONFIG) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Compile the kernel ELF -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ $(KERNEL_ELF): $(KERNEL_ELF_DEPS) $(call color_header, "Compiling kernel ELF - $(BSP)") @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Generate the stripped kernel binary -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ $(KERNEL_BIN): $(KERNEL_ELF) $(call color_header, "Generating stripped binary") @$(OBJCOPY_CMD) $(KERNEL_ELF) $(KERNEL_BIN) @@ -159,16 +159,16 @@ $(KERNEL_BIN): $(KERNEL_ELF) $(call color_progress_prefix, "Size") $(call disk_usage_KiB, $(KERNEL_BIN)) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Generate the documentation -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ doc: $(call color_header, "Generating docs") @$(DOC_CMD) --document-private-items --open -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run the kernel in QEMU -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. qemu: @@ -182,34 +182,34 @@ qemu: $(KERNEL_BIN) endif -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Push the kernel to the real HW target -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ chainboot: $(KERNEL_BIN) @$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(KERNEL_BIN) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run clippy -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ clippy: @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Clean -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ clean: rm -rf target $(KERNEL_BIN) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run readelf -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ readelf: $(KERNEL_ELF) $(call color_header, "Launching readelf") @$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run objdump -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ objdump: $(KERNEL_ELF) $(call color_header, "Launching objdump") @$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \ @@ -217,9 +217,9 @@ objdump: $(KERNEL_ELF) --section .rodata \ $(KERNEL_ELF) | rustfilt -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run nm -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ nm: $(KERNEL_ELF) $(call color_header, "Launching nm") @$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt @@ -231,22 +231,22 @@ nm: $(KERNEL_ELF) ##-------------------------------------------------------------------------------------------------- .PHONY: jtagboot openocd gdb gdb-opt0 -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Push the JTAG boot image to the real HW target -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ jtagboot: @$(DOCKER_JTAGBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(JTAG_BOOT_IMAGE) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Start OpenOCD session -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ openocd: $(call color_header, "Launching OpenOCD") @$(DOCKER_OPENOCD) openocd $(OPENOCD_ARG) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Start GDB session -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ gdb: RUSTC_MISC_ARGS += -C debuginfo=2 gdb-opt0: RUSTC_MISC_ARGS += -C debuginfo=2 -C opt-level=0 gdb gdb-opt0: $(KERNEL_ELF) @@ -267,9 +267,9 @@ test_boot test: else # QEMU is supported. -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run boot test -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ test_boot: $(KERNEL_BIN) $(call color_header, "Boot test - $(BSP)") @$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN) diff --git a/10_virtual_mem_part1_identity_mapping/Makefile b/10_virtual_mem_part1_identity_mapping/Makefile index 7c8eef4c..9549f092 100644 --- a/10_virtual_mem_part1_identity_mapping/Makefile +++ b/10_virtual_mem_part1_identity_mapping/Makefile @@ -97,9 +97,9 @@ EXEC_QEMU = $(QEMU_BINARY) -M $(QEMU_MACHINE_TYPE) EXEC_TEST_DISPATCH = ruby ../common/tests/dispatch.rb EXEC_MINIPUSH = ruby ../common/serial/minipush.rb -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Dockerization -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i DOCKER_ARG_DIR_COMMON = -v $(shell pwd)/../common:/work/common @@ -133,24 +133,24 @@ endif all: $(KERNEL_BIN) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Save the configuration as a file, so make understands if it changed. -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ $(LAST_BUILD_CONFIG): @rm -f target/*.build_config @mkdir -p target @touch $(LAST_BUILD_CONFIG) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Compile the kernel ELF -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ $(KERNEL_ELF): $(KERNEL_ELF_DEPS) $(call color_header, "Compiling kernel ELF - $(BSP)") @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Generate the stripped kernel binary -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ $(KERNEL_BIN): $(KERNEL_ELF) $(call color_header, "Generating stripped binary") @$(OBJCOPY_CMD) $(KERNEL_ELF) $(KERNEL_BIN) @@ -159,16 +159,16 @@ $(KERNEL_BIN): $(KERNEL_ELF) $(call color_progress_prefix, "Size") $(call disk_usage_KiB, $(KERNEL_BIN)) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Generate the documentation -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ doc: $(call color_header, "Generating docs") @$(DOC_CMD) --document-private-items --open -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run the kernel in QEMU -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. qemu: @@ -182,34 +182,34 @@ qemu: $(KERNEL_BIN) endif -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Push the kernel to the real HW target -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ chainboot: $(KERNEL_BIN) @$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(KERNEL_BIN) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run clippy -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ clippy: @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Clean -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ clean: rm -rf target $(KERNEL_BIN) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run readelf -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ readelf: $(KERNEL_ELF) $(call color_header, "Launching readelf") @$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run objdump -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ objdump: $(KERNEL_ELF) $(call color_header, "Launching objdump") @$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \ @@ -217,9 +217,9 @@ objdump: $(KERNEL_ELF) --section .rodata \ $(KERNEL_ELF) | rustfilt -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run nm -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ nm: $(KERNEL_ELF) $(call color_header, "Launching nm") @$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt @@ -231,22 +231,22 @@ nm: $(KERNEL_ELF) ##-------------------------------------------------------------------------------------------------- .PHONY: jtagboot openocd gdb gdb-opt0 -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Push the JTAG boot image to the real HW target -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ jtagboot: @$(DOCKER_JTAGBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(JTAG_BOOT_IMAGE) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Start OpenOCD session -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ openocd: $(call color_header, "Launching OpenOCD") @$(DOCKER_OPENOCD) openocd $(OPENOCD_ARG) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Start GDB session -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ gdb: RUSTC_MISC_ARGS += -C debuginfo=2 gdb-opt0: RUSTC_MISC_ARGS += -C debuginfo=2 -C opt-level=0 gdb gdb-opt0: $(KERNEL_ELF) @@ -267,9 +267,9 @@ test_boot test: else # QEMU is supported. -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run boot test -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ test_boot: $(KERNEL_BIN) $(call color_header, "Boot test - $(BSP)") @$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN) diff --git a/11_exceptions_part1_groundwork/Makefile b/11_exceptions_part1_groundwork/Makefile index 7c8eef4c..9549f092 100644 --- a/11_exceptions_part1_groundwork/Makefile +++ b/11_exceptions_part1_groundwork/Makefile @@ -97,9 +97,9 @@ EXEC_QEMU = $(QEMU_BINARY) -M $(QEMU_MACHINE_TYPE) EXEC_TEST_DISPATCH = ruby ../common/tests/dispatch.rb EXEC_MINIPUSH = ruby ../common/serial/minipush.rb -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Dockerization -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i DOCKER_ARG_DIR_COMMON = -v $(shell pwd)/../common:/work/common @@ -133,24 +133,24 @@ endif all: $(KERNEL_BIN) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Save the configuration as a file, so make understands if it changed. -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ $(LAST_BUILD_CONFIG): @rm -f target/*.build_config @mkdir -p target @touch $(LAST_BUILD_CONFIG) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Compile the kernel ELF -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ $(KERNEL_ELF): $(KERNEL_ELF_DEPS) $(call color_header, "Compiling kernel ELF - $(BSP)") @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Generate the stripped kernel binary -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ $(KERNEL_BIN): $(KERNEL_ELF) $(call color_header, "Generating stripped binary") @$(OBJCOPY_CMD) $(KERNEL_ELF) $(KERNEL_BIN) @@ -159,16 +159,16 @@ $(KERNEL_BIN): $(KERNEL_ELF) $(call color_progress_prefix, "Size") $(call disk_usage_KiB, $(KERNEL_BIN)) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Generate the documentation -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ doc: $(call color_header, "Generating docs") @$(DOC_CMD) --document-private-items --open -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run the kernel in QEMU -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. qemu: @@ -182,34 +182,34 @@ qemu: $(KERNEL_BIN) endif -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Push the kernel to the real HW target -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ chainboot: $(KERNEL_BIN) @$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(KERNEL_BIN) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run clippy -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ clippy: @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Clean -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ clean: rm -rf target $(KERNEL_BIN) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run readelf -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ readelf: $(KERNEL_ELF) $(call color_header, "Launching readelf") @$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run objdump -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ objdump: $(KERNEL_ELF) $(call color_header, "Launching objdump") @$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \ @@ -217,9 +217,9 @@ objdump: $(KERNEL_ELF) --section .rodata \ $(KERNEL_ELF) | rustfilt -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run nm -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ nm: $(KERNEL_ELF) $(call color_header, "Launching nm") @$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt @@ -231,22 +231,22 @@ nm: $(KERNEL_ELF) ##-------------------------------------------------------------------------------------------------- .PHONY: jtagboot openocd gdb gdb-opt0 -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Push the JTAG boot image to the real HW target -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ jtagboot: @$(DOCKER_JTAGBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(JTAG_BOOT_IMAGE) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Start OpenOCD session -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ openocd: $(call color_header, "Launching OpenOCD") @$(DOCKER_OPENOCD) openocd $(OPENOCD_ARG) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Start GDB session -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ gdb: RUSTC_MISC_ARGS += -C debuginfo=2 gdb-opt0: RUSTC_MISC_ARGS += -C debuginfo=2 -C opt-level=0 gdb gdb-opt0: $(KERNEL_ELF) @@ -267,9 +267,9 @@ test_boot test: else # QEMU is supported. -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run boot test -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ test_boot: $(KERNEL_BIN) $(call color_header, "Boot test - $(BSP)") @$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN) diff --git a/12_integrated_testing/Makefile b/12_integrated_testing/Makefile index 4e352123..4e2efeff 100644 --- a/12_integrated_testing/Makefile +++ b/12_integrated_testing/Makefile @@ -107,9 +107,9 @@ EXEC_QEMU = $(QEMU_BINARY) -M $(QEMU_MACHINE_TYPE) EXEC_TEST_DISPATCH = ruby ../common/tests/dispatch.rb EXEC_MINIPUSH = ruby ../common/serial/minipush.rb -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Dockerization -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i DOCKER_ARG_DIR_COMMON = -v $(shell pwd)/../common:/work/common @@ -143,24 +143,24 @@ endif all: $(KERNEL_BIN) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Save the configuration as a file, so make understands if it changed. -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ $(LAST_BUILD_CONFIG): @rm -f target/*.build_config @mkdir -p target @touch $(LAST_BUILD_CONFIG) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Compile the kernel ELF -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ $(KERNEL_ELF): $(KERNEL_ELF_DEPS) $(call color_header, "Compiling kernel ELF - $(BSP)") @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Generate the stripped kernel binary -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ $(KERNEL_BIN): $(KERNEL_ELF) $(call color_header, "Generating stripped binary") @$(OBJCOPY_CMD) $(KERNEL_ELF) $(KERNEL_BIN) @@ -169,16 +169,16 @@ $(KERNEL_BIN): $(KERNEL_ELF) $(call color_progress_prefix, "Size") $(call disk_usage_KiB, $(KERNEL_BIN)) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Generate the documentation -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ doc: $(call color_header, "Generating docs") @$(DOC_CMD) --document-private-items --open -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run the kernel in QEMU -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. qemu: @@ -192,36 +192,36 @@ qemu: $(KERNEL_BIN) endif -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Push the kernel to the real HW target -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ chainboot: $(KERNEL_BIN) @$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(KERNEL_BIN) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run clippy -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ clippy: @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) --features test_build --tests \ --manifest-path $(KERNEL_MANIFEST) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Clean -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ clean: rm -rf target $(KERNEL_BIN) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run readelf -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ readelf: $(KERNEL_ELF) $(call color_header, "Launching readelf") @$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run objdump -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ objdump: $(KERNEL_ELF) $(call color_header, "Launching objdump") @$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \ @@ -229,9 +229,9 @@ objdump: $(KERNEL_ELF) --section .rodata \ $(KERNEL_ELF) | rustfilt -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run nm -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ nm: $(KERNEL_ELF) $(call color_header, "Launching nm") @$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt @@ -243,22 +243,22 @@ nm: $(KERNEL_ELF) ##-------------------------------------------------------------------------------------------------- .PHONY: jtagboot openocd gdb gdb-opt0 -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Push the JTAG boot image to the real HW target -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ jtagboot: @$(DOCKER_JTAGBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(JTAG_BOOT_IMAGE) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Start OpenOCD session -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ openocd: $(call color_header, "Launching OpenOCD") @$(DOCKER_OPENOCD) openocd $(OPENOCD_ARG) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Start GDB session -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ gdb: RUSTC_MISC_ARGS += -C debuginfo=2 gdb-opt0: RUSTC_MISC_ARGS += -C debuginfo=2 -C opt-level=0 gdb gdb-opt0: $(KERNEL_ELF) @@ -281,16 +281,16 @@ test_boot test_unit test_integration test: else # QEMU is supported. -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run boot test -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ test_boot: $(KERNEL_BIN) $(call color_header, "Boot test - $(BSP)") @$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Helpers for unit and integration test targets -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ define KERNEL_TEST_RUNNER #!/usr/bin/env bash @@ -313,17 +313,17 @@ define test_prepare @chmod +x target/kernel_test_runner.sh endef -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run unit test(s) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ test_unit: $(call color_header, "Compiling unit test(s) - $(BSP)") $(call test_prepare) @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(TEST_CMD) --lib -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run integration test(s) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ test_integration: $(call color_header, "Compiling integration test(s) - $(BSP)") $(call test_prepare) diff --git a/12_integrated_testing/README.md b/12_integrated_testing/README.md index 634727fd..ae68d269 100644 --- a/12_integrated_testing/README.md +++ b/12_integrated_testing/README.md @@ -409,9 +409,9 @@ The file `kernel_test_runner.sh` does not exist by default. We generate it on de `make test_*` targets is called: ```Makefile -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Helpers for unit and integration test targets -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ define KERNEL_TEST_RUNNER #!/usr/bin/env bash @@ -434,9 +434,9 @@ define test_prepare @chmod +x target/kernel_test_runner.sh endef -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run unit test(s) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ test_unit: $(call color_header, "Compiling unit test(s) - $(BSP)") $(call test_prepare) diff --git a/13_exceptions_part2_peripheral_IRQs/Makefile b/13_exceptions_part2_peripheral_IRQs/Makefile index 4e352123..4e2efeff 100644 --- a/13_exceptions_part2_peripheral_IRQs/Makefile +++ b/13_exceptions_part2_peripheral_IRQs/Makefile @@ -107,9 +107,9 @@ EXEC_QEMU = $(QEMU_BINARY) -M $(QEMU_MACHINE_TYPE) EXEC_TEST_DISPATCH = ruby ../common/tests/dispatch.rb EXEC_MINIPUSH = ruby ../common/serial/minipush.rb -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Dockerization -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i DOCKER_ARG_DIR_COMMON = -v $(shell pwd)/../common:/work/common @@ -143,24 +143,24 @@ endif all: $(KERNEL_BIN) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Save the configuration as a file, so make understands if it changed. -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ $(LAST_BUILD_CONFIG): @rm -f target/*.build_config @mkdir -p target @touch $(LAST_BUILD_CONFIG) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Compile the kernel ELF -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ $(KERNEL_ELF): $(KERNEL_ELF_DEPS) $(call color_header, "Compiling kernel ELF - $(BSP)") @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Generate the stripped kernel binary -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ $(KERNEL_BIN): $(KERNEL_ELF) $(call color_header, "Generating stripped binary") @$(OBJCOPY_CMD) $(KERNEL_ELF) $(KERNEL_BIN) @@ -169,16 +169,16 @@ $(KERNEL_BIN): $(KERNEL_ELF) $(call color_progress_prefix, "Size") $(call disk_usage_KiB, $(KERNEL_BIN)) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Generate the documentation -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ doc: $(call color_header, "Generating docs") @$(DOC_CMD) --document-private-items --open -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run the kernel in QEMU -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. qemu: @@ -192,36 +192,36 @@ qemu: $(KERNEL_BIN) endif -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Push the kernel to the real HW target -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ chainboot: $(KERNEL_BIN) @$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(KERNEL_BIN) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run clippy -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ clippy: @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) --features test_build --tests \ --manifest-path $(KERNEL_MANIFEST) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Clean -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ clean: rm -rf target $(KERNEL_BIN) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run readelf -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ readelf: $(KERNEL_ELF) $(call color_header, "Launching readelf") @$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run objdump -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ objdump: $(KERNEL_ELF) $(call color_header, "Launching objdump") @$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \ @@ -229,9 +229,9 @@ objdump: $(KERNEL_ELF) --section .rodata \ $(KERNEL_ELF) | rustfilt -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run nm -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ nm: $(KERNEL_ELF) $(call color_header, "Launching nm") @$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt @@ -243,22 +243,22 @@ nm: $(KERNEL_ELF) ##-------------------------------------------------------------------------------------------------- .PHONY: jtagboot openocd gdb gdb-opt0 -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Push the JTAG boot image to the real HW target -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ jtagboot: @$(DOCKER_JTAGBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(JTAG_BOOT_IMAGE) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Start OpenOCD session -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ openocd: $(call color_header, "Launching OpenOCD") @$(DOCKER_OPENOCD) openocd $(OPENOCD_ARG) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Start GDB session -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ gdb: RUSTC_MISC_ARGS += -C debuginfo=2 gdb-opt0: RUSTC_MISC_ARGS += -C debuginfo=2 -C opt-level=0 gdb gdb-opt0: $(KERNEL_ELF) @@ -281,16 +281,16 @@ test_boot test_unit test_integration test: else # QEMU is supported. -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run boot test -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ test_boot: $(KERNEL_BIN) $(call color_header, "Boot test - $(BSP)") @$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Helpers for unit and integration test targets -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ define KERNEL_TEST_RUNNER #!/usr/bin/env bash @@ -313,17 +313,17 @@ define test_prepare @chmod +x target/kernel_test_runner.sh endef -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run unit test(s) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ test_unit: $(call color_header, "Compiling unit test(s) - $(BSP)") $(call test_prepare) @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(TEST_CMD) --lib -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run integration test(s) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ test_integration: $(call color_header, "Compiling integration test(s) - $(BSP)") $(call test_prepare) diff --git a/14_virtual_mem_part2_mmio_remap/Makefile b/14_virtual_mem_part2_mmio_remap/Makefile index 4e352123..4e2efeff 100644 --- a/14_virtual_mem_part2_mmio_remap/Makefile +++ b/14_virtual_mem_part2_mmio_remap/Makefile @@ -107,9 +107,9 @@ EXEC_QEMU = $(QEMU_BINARY) -M $(QEMU_MACHINE_TYPE) EXEC_TEST_DISPATCH = ruby ../common/tests/dispatch.rb EXEC_MINIPUSH = ruby ../common/serial/minipush.rb -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Dockerization -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i DOCKER_ARG_DIR_COMMON = -v $(shell pwd)/../common:/work/common @@ -143,24 +143,24 @@ endif all: $(KERNEL_BIN) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Save the configuration as a file, so make understands if it changed. -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ $(LAST_BUILD_CONFIG): @rm -f target/*.build_config @mkdir -p target @touch $(LAST_BUILD_CONFIG) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Compile the kernel ELF -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ $(KERNEL_ELF): $(KERNEL_ELF_DEPS) $(call color_header, "Compiling kernel ELF - $(BSP)") @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Generate the stripped kernel binary -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ $(KERNEL_BIN): $(KERNEL_ELF) $(call color_header, "Generating stripped binary") @$(OBJCOPY_CMD) $(KERNEL_ELF) $(KERNEL_BIN) @@ -169,16 +169,16 @@ $(KERNEL_BIN): $(KERNEL_ELF) $(call color_progress_prefix, "Size") $(call disk_usage_KiB, $(KERNEL_BIN)) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Generate the documentation -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ doc: $(call color_header, "Generating docs") @$(DOC_CMD) --document-private-items --open -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run the kernel in QEMU -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. qemu: @@ -192,36 +192,36 @@ qemu: $(KERNEL_BIN) endif -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Push the kernel to the real HW target -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ chainboot: $(KERNEL_BIN) @$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(KERNEL_BIN) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run clippy -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ clippy: @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) --features test_build --tests \ --manifest-path $(KERNEL_MANIFEST) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Clean -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ clean: rm -rf target $(KERNEL_BIN) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run readelf -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ readelf: $(KERNEL_ELF) $(call color_header, "Launching readelf") @$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run objdump -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ objdump: $(KERNEL_ELF) $(call color_header, "Launching objdump") @$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \ @@ -229,9 +229,9 @@ objdump: $(KERNEL_ELF) --section .rodata \ $(KERNEL_ELF) | rustfilt -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run nm -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ nm: $(KERNEL_ELF) $(call color_header, "Launching nm") @$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt @@ -243,22 +243,22 @@ nm: $(KERNEL_ELF) ##-------------------------------------------------------------------------------------------------- .PHONY: jtagboot openocd gdb gdb-opt0 -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Push the JTAG boot image to the real HW target -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ jtagboot: @$(DOCKER_JTAGBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(JTAG_BOOT_IMAGE) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Start OpenOCD session -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ openocd: $(call color_header, "Launching OpenOCD") @$(DOCKER_OPENOCD) openocd $(OPENOCD_ARG) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Start GDB session -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ gdb: RUSTC_MISC_ARGS += -C debuginfo=2 gdb-opt0: RUSTC_MISC_ARGS += -C debuginfo=2 -C opt-level=0 gdb gdb-opt0: $(KERNEL_ELF) @@ -281,16 +281,16 @@ test_boot test_unit test_integration test: else # QEMU is supported. -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run boot test -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ test_boot: $(KERNEL_BIN) $(call color_header, "Boot test - $(BSP)") @$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Helpers for unit and integration test targets -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ define KERNEL_TEST_RUNNER #!/usr/bin/env bash @@ -313,17 +313,17 @@ define test_prepare @chmod +x target/kernel_test_runner.sh endef -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run unit test(s) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ test_unit: $(call color_header, "Compiling unit test(s) - $(BSP)") $(call test_prepare) @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(TEST_CMD) --lib -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run integration test(s) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ test_integration: $(call color_header, "Compiling integration test(s) - $(BSP)") $(call test_prepare) diff --git a/15_virtual_mem_part3_precomputed_tables/Makefile b/15_virtual_mem_part3_precomputed_tables/Makefile index f2b79fbe..bc23270d 100644 --- a/15_virtual_mem_part3_precomputed_tables/Makefile +++ b/15_virtual_mem_part3_precomputed_tables/Makefile @@ -77,9 +77,9 @@ KERNEL_ELF_RAW = target/$(TARGET)/release/kernel # https://doc.rust-lang.org/cargo/guide/build-cache.html#dep-info-files KERNEL_ELF_RAW_DEPS = $(filter-out %: ,$(file < $(KERNEL_ELF_RAW).d)) $(KERNEL_MANIFEST) $(LAST_BUILD_CONFIG) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Translation tables -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ TT_TOOL_PATH = tools/translation_table_tool KERNEL_ELF_TTABLES = target/$(TARGET)/release/kernel+ttables @@ -118,9 +118,9 @@ EXEC_TT_TOOL = ruby $(TT_TOOL_PATH)/main.rb EXEC_TEST_DISPATCH = ruby ../common/tests/dispatch.rb EXEC_MINIPUSH = ruby ../common/serial/minipush.rb -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Dockerization -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i DOCKER_ARG_DIR_COMMON = -v $(shell pwd)/../common:/work/common @@ -154,32 +154,32 @@ endif all: $(KERNEL_BIN) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Save the configuration as a file, so make understands if it changed. -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ $(LAST_BUILD_CONFIG): @rm -f target/*.build_config @mkdir -p target @touch $(LAST_BUILD_CONFIG) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Compile the kernel ELF -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ $(KERNEL_ELF_RAW): $(KERNEL_ELF_RAW_DEPS) $(call color_header, "Compiling kernel ELF - $(BSP)") @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Precompute the kernel translation tables and patch them into the kernel ELF -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ $(KERNEL_ELF_TTABLES): $(KERNEL_ELF_TTABLES_DEPS) $(call color_header, "Precomputing kernel translation tables and patching kernel ELF") @cp $(KERNEL_ELF_RAW) $(KERNEL_ELF_TTABLES) @$(DOCKER_TOOLS) $(EXEC_TT_TOOL) $(BSP) $(KERNEL_ELF_TTABLES) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Generate the stripped kernel binary -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ $(KERNEL_BIN): $(KERNEL_ELF_TTABLES) $(call color_header, "Generating stripped binary") @$(OBJCOPY_CMD) $(KERNEL_ELF_TTABLES) $(KERNEL_BIN) @@ -188,16 +188,16 @@ $(KERNEL_BIN): $(KERNEL_ELF_TTABLES) $(call color_progress_prefix, "Size") $(call disk_usage_KiB, $(KERNEL_BIN)) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Generate the documentation -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ doc: $(call color_header, "Generating docs") @$(DOC_CMD) --document-private-items --open -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run the kernel in QEMU -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. qemu: @@ -211,36 +211,36 @@ qemu: $(KERNEL_BIN) endif -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Push the kernel to the real HW target -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ chainboot: $(KERNEL_BIN) @$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(KERNEL_BIN) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run clippy -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ clippy: @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) --features test_build --tests \ --manifest-path $(KERNEL_MANIFEST) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Clean -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ clean: rm -rf target $(KERNEL_BIN) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run readelf -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ readelf: $(KERNEL_ELF) $(call color_header, "Launching readelf") @$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run objdump -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ objdump: $(KERNEL_ELF) $(call color_header, "Launching objdump") @$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \ @@ -248,9 +248,9 @@ objdump: $(KERNEL_ELF) --section .rodata \ $(KERNEL_ELF) | rustfilt -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run nm -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ nm: $(KERNEL_ELF) $(call color_header, "Launching nm") @$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt @@ -262,22 +262,22 @@ nm: $(KERNEL_ELF) ##-------------------------------------------------------------------------------------------------- .PHONY: jtagboot openocd gdb gdb-opt0 -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Push the JTAG boot image to the real HW target -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ jtagboot: @$(DOCKER_JTAGBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(JTAG_BOOT_IMAGE) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Start OpenOCD session -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ openocd: $(call color_header, "Launching OpenOCD") @$(DOCKER_OPENOCD) openocd $(OPENOCD_ARG) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Start GDB session -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ gdb: RUSTC_MISC_ARGS += -C debuginfo=2 gdb-opt0: RUSTC_MISC_ARGS += -C debuginfo=2 -C opt-level=0 gdb gdb-opt0: $(KERNEL_ELF) @@ -300,16 +300,16 @@ test_boot test_unit test_integration test: else # QEMU is supported. -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run boot test -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ test_boot: $(KERNEL_BIN) $(call color_header, "Boot test - $(BSP)") @$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Helpers for unit and integration test targets -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ define KERNEL_TEST_RUNNER #!/usr/bin/env bash @@ -333,17 +333,17 @@ define test_prepare @chmod +x target/kernel_test_runner.sh endef -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run unit test(s) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ test_unit: $(call color_header, "Compiling unit test(s) - $(BSP)") $(call test_prepare) @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(TEST_CMD) --lib -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run integration test(s) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ test_integration: $(call color_header, "Compiling integration test(s) - $(BSP)") $(call test_prepare) diff --git a/15_virtual_mem_part3_precomputed_tables/README.md b/15_virtual_mem_part3_precomputed_tables/README.md index 81bff257..3fdc2385 100644 --- a/15_virtual_mem_part3_precomputed_tables/README.md +++ b/15_virtual_mem_part3_precomputed_tables/README.md @@ -579,24 +579,24 @@ KERNEL_ELF_TTABLES = target/$(TARGET)/release/kernel+ttables EXEC_TT_TOOL = ruby $(TT_TOOL_PATH)/main.rb # [...] -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Compile the kernel ELF -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ $(KERNEL_ELF_RAW): $(KERNEL_ELF_RAW_DEPS) $(call color_header, "Compiling kernel ELF - $(BSP)") @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Precompute the kernel translation tables and patch them into the kernel ELF -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ $(KERNEL_ELF_TTABLES): $(KERNEL_ELF_TTABLES_DEPS) $(call color_header, "Precomputing kernel translation tables and patching kernel ELF") @cp $(KERNEL_ELF_RAW) $(KERNEL_ELF_TTABLES) @$(DOCKER_TOOLS) $(EXEC_TT_TOOL) $(TARGET) $(BSP) $(KERNEL_ELF_TTABLES) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Generate the stripped kernel binary -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ $(KERNEL_BIN): $(KERNEL_ELF_TTABLES) $(call color_header, "Generating stripped binary") @$(OBJCOPY_CMD) $(KERNEL_ELF_TTABLES) $(KERNEL_BIN) @@ -1859,9 +1859,9 @@ diff -uNr 14_virtual_mem_part2_mmio_remap/Makefile 15_virtual_mem_part3_precompu -KERNEL_ELF_DEPS = $(filter-out modulo: ,$(file < $(KERNEL_ELF).d)) $(KERNEL_MANIFEST) $(LAST_BUILD_CONFIG) +KERNEL_ELF_RAW_DEPS = $(filter-out modulo: ,$(file < $(KERNEL_ELF_RAW).d)) $(KERNEL_MANIFEST) $(LAST_BUILD_CONFIG) + -+## ------------------------------------------------------------------------------ ++##------------------------------------------------------------------------------ +## Translation tables -+## ------------------------------------------------------------------------------ ++##------------------------------------------------------------------------------ +TT_TOOL_PATH = tools/translation_table_tool + +KERNEL_ELF_TTABLES = target/$(TARGET)/release/kernel+ttables @@ -1880,25 +1880,25 @@ diff -uNr 14_virtual_mem_part2_mmio_remap/Makefile 15_virtual_mem_part3_precompu EXEC_MINIPUSH = ruby ../common/serial/minipush.rb @@ -154,16 +165,24 @@ - ## ------------------------------------------------------------------------------ + ##------------------------------------------------------------------------------ ## Compile the kernel ELF - ## ------------------------------------------------------------------------------ + ##------------------------------------------------------------------------------ -$(KERNEL_ELF): $(KERNEL_ELF_DEPS) +$(KERNEL_ELF_RAW): $(KERNEL_ELF_RAW_DEPS) $(call color_header, "Compiling kernel ELF - $(BSP)") @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD) - ## ------------------------------------------------------------------------------ + ##------------------------------------------------------------------------------ +## Precompute the kernel translation tables and patch them into the kernel ELF -+## ------------------------------------------------------------------------------ ++##------------------------------------------------------------------------------ +$(KERNEL_ELF_TTABLES): $(KERNEL_ELF_TTABLES_DEPS) + $(call color_header, "Precomputing kernel translation tables and patching kernel ELF") + @cp $(KERNEL_ELF_RAW) $(KERNEL_ELF_TTABLES) + @$(DOCKER_TOOLS) $(EXEC_TT_TOOL) $(BSP) $(KERNEL_ELF_TTABLES) + -+## ------------------------------------------------------------------------------ ++##------------------------------------------------------------------------------ ## Generate the stripped kernel binary - ## ------------------------------------------------------------------------------ + ##------------------------------------------------------------------------------ -$(KERNEL_BIN): $(KERNEL_ELF) +$(KERNEL_BIN): $(KERNEL_ELF_TTABLES) $(call color_header, "Generating stripped binary") diff --git a/16_virtual_mem_part4_higher_half_kernel/Makefile b/16_virtual_mem_part4_higher_half_kernel/Makefile index f2b79fbe..bc23270d 100644 --- a/16_virtual_mem_part4_higher_half_kernel/Makefile +++ b/16_virtual_mem_part4_higher_half_kernel/Makefile @@ -77,9 +77,9 @@ KERNEL_ELF_RAW = target/$(TARGET)/release/kernel # https://doc.rust-lang.org/cargo/guide/build-cache.html#dep-info-files KERNEL_ELF_RAW_DEPS = $(filter-out %: ,$(file < $(KERNEL_ELF_RAW).d)) $(KERNEL_MANIFEST) $(LAST_BUILD_CONFIG) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Translation tables -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ TT_TOOL_PATH = tools/translation_table_tool KERNEL_ELF_TTABLES = target/$(TARGET)/release/kernel+ttables @@ -118,9 +118,9 @@ EXEC_TT_TOOL = ruby $(TT_TOOL_PATH)/main.rb EXEC_TEST_DISPATCH = ruby ../common/tests/dispatch.rb EXEC_MINIPUSH = ruby ../common/serial/minipush.rb -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Dockerization -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i DOCKER_ARG_DIR_COMMON = -v $(shell pwd)/../common:/work/common @@ -154,32 +154,32 @@ endif all: $(KERNEL_BIN) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Save the configuration as a file, so make understands if it changed. -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ $(LAST_BUILD_CONFIG): @rm -f target/*.build_config @mkdir -p target @touch $(LAST_BUILD_CONFIG) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Compile the kernel ELF -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ $(KERNEL_ELF_RAW): $(KERNEL_ELF_RAW_DEPS) $(call color_header, "Compiling kernel ELF - $(BSP)") @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Precompute the kernel translation tables and patch them into the kernel ELF -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ $(KERNEL_ELF_TTABLES): $(KERNEL_ELF_TTABLES_DEPS) $(call color_header, "Precomputing kernel translation tables and patching kernel ELF") @cp $(KERNEL_ELF_RAW) $(KERNEL_ELF_TTABLES) @$(DOCKER_TOOLS) $(EXEC_TT_TOOL) $(BSP) $(KERNEL_ELF_TTABLES) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Generate the stripped kernel binary -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ $(KERNEL_BIN): $(KERNEL_ELF_TTABLES) $(call color_header, "Generating stripped binary") @$(OBJCOPY_CMD) $(KERNEL_ELF_TTABLES) $(KERNEL_BIN) @@ -188,16 +188,16 @@ $(KERNEL_BIN): $(KERNEL_ELF_TTABLES) $(call color_progress_prefix, "Size") $(call disk_usage_KiB, $(KERNEL_BIN)) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Generate the documentation -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ doc: $(call color_header, "Generating docs") @$(DOC_CMD) --document-private-items --open -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run the kernel in QEMU -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. qemu: @@ -211,36 +211,36 @@ qemu: $(KERNEL_BIN) endif -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Push the kernel to the real HW target -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ chainboot: $(KERNEL_BIN) @$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(KERNEL_BIN) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run clippy -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ clippy: @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) --features test_build --tests \ --manifest-path $(KERNEL_MANIFEST) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Clean -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ clean: rm -rf target $(KERNEL_BIN) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run readelf -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ readelf: $(KERNEL_ELF) $(call color_header, "Launching readelf") @$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run objdump -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ objdump: $(KERNEL_ELF) $(call color_header, "Launching objdump") @$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \ @@ -248,9 +248,9 @@ objdump: $(KERNEL_ELF) --section .rodata \ $(KERNEL_ELF) | rustfilt -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run nm -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ nm: $(KERNEL_ELF) $(call color_header, "Launching nm") @$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt @@ -262,22 +262,22 @@ nm: $(KERNEL_ELF) ##-------------------------------------------------------------------------------------------------- .PHONY: jtagboot openocd gdb gdb-opt0 -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Push the JTAG boot image to the real HW target -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ jtagboot: @$(DOCKER_JTAGBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(JTAG_BOOT_IMAGE) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Start OpenOCD session -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ openocd: $(call color_header, "Launching OpenOCD") @$(DOCKER_OPENOCD) openocd $(OPENOCD_ARG) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Start GDB session -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ gdb: RUSTC_MISC_ARGS += -C debuginfo=2 gdb-opt0: RUSTC_MISC_ARGS += -C debuginfo=2 -C opt-level=0 gdb gdb-opt0: $(KERNEL_ELF) @@ -300,16 +300,16 @@ test_boot test_unit test_integration test: else # QEMU is supported. -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run boot test -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ test_boot: $(KERNEL_BIN) $(call color_header, "Boot test - $(BSP)") @$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Helpers for unit and integration test targets -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ define KERNEL_TEST_RUNNER #!/usr/bin/env bash @@ -333,17 +333,17 @@ define test_prepare @chmod +x target/kernel_test_runner.sh endef -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run unit test(s) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ test_unit: $(call color_header, "Compiling unit test(s) - $(BSP)") $(call test_prepare) @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(TEST_CMD) --lib -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run integration test(s) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ test_integration: $(call color_header, "Compiling integration test(s) - $(BSP)") $(call test_prepare) diff --git a/17_kernel_symbols/Makefile b/17_kernel_symbols/Makefile index 4c97eb9a..3c33cd66 100644 --- a/17_kernel_symbols/Makefile +++ b/17_kernel_symbols/Makefile @@ -77,17 +77,17 @@ KERNEL_ELF_RAW = target/$(TARGET)/release/kernel # https://doc.rust-lang.org/cargo/guide/build-cache.html#dep-info-files KERNEL_ELF_RAW_DEPS = $(filter-out %: ,$(file < $(KERNEL_ELF_RAW).d)) $(KERNEL_MANIFEST) $(LAST_BUILD_CONFIG) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Translation tables -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ TT_TOOL_PATH = tools/translation_table_tool KERNEL_ELF_TTABLES = target/$(TARGET)/release/kernel+ttables KERNEL_ELF_TTABLES_DEPS = $(KERNEL_ELF_RAW) $(wildcard $(TT_TOOL_PATH)/*) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Kernel symbols -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ export KERNEL_SYMBOLS_TOOL_PATH = tools/kernel_symbols_tool KERNEL_ELF_TTABLES_SYMS = target/$(TARGET)/release/kernel+ttables+symbols @@ -135,9 +135,9 @@ EXEC_TT_TOOL = ruby $(TT_TOOL_PATH)/main.rb EXEC_TEST_DISPATCH = ruby ../common/tests/dispatch.rb EXEC_MINIPUSH = ruby ../common/serial/minipush.rb -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Dockerization -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i DOCKER_ARG_DIR_COMMON = -v $(shell pwd)/../common:/work/common @@ -171,39 +171,39 @@ endif all: $(KERNEL_BIN) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Save the configuration as a file, so make understands if it changed. -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ $(LAST_BUILD_CONFIG): @rm -f target/*.build_config @mkdir -p target @touch $(LAST_BUILD_CONFIG) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Compile the kernel ELF -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ $(KERNEL_ELF_RAW): $(KERNEL_ELF_RAW_DEPS) $(call color_header, "Compiling kernel ELF - $(BSP)") @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Precompute the kernel translation tables and patch them into the kernel ELF -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ $(KERNEL_ELF_TTABLES): $(KERNEL_ELF_TTABLES_DEPS) $(call color_header, "Precomputing kernel translation tables and patching kernel ELF") @cp $(KERNEL_ELF_RAW) $(KERNEL_ELF_TTABLES) @$(DOCKER_TOOLS) $(EXEC_TT_TOOL) $(BSP) $(KERNEL_ELF_TTABLES) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Generate kernel symbols and patch them into the kernel ELF -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ $(KERNEL_ELF_TTABLES_SYMS): $(KERNEL_ELF_TTABLES_SYMS_DEPS) $(call color_header, "Generating kernel symbols and patching kernel ELF") @$(MAKE) --no-print-directory -f kernel_symbols.mk -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Generate the stripped kernel binary -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ $(KERNEL_BIN): $(KERNEL_ELF_TTABLES_SYMS) $(call color_header, "Generating stripped binary") @$(OBJCOPY_CMD) $(KERNEL_ELF_TTABLES_SYMS) $(KERNEL_BIN) @@ -212,16 +212,16 @@ $(KERNEL_BIN): $(KERNEL_ELF_TTABLES_SYMS) $(call color_progress_prefix, "Size") $(call disk_usage_KiB, $(KERNEL_BIN)) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Generate the documentation -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ doc: clean $(call color_header, "Generating docs") @$(DOC_CMD) --document-private-items --open -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run the kernel in QEMU -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. qemu: @@ -235,36 +235,36 @@ qemu: $(KERNEL_BIN) endif -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Push the kernel to the real HW target -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ chainboot: $(KERNEL_BIN) @$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(KERNEL_BIN) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run clippy -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ clippy: @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) --features test_build --tests \ --manifest-path $(KERNEL_MANIFEST) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Clean -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ clean: rm -rf target $(KERNEL_BIN) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run readelf -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ readelf: $(KERNEL_ELF) $(call color_header, "Launching readelf") @$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run objdump -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ objdump: $(KERNEL_ELF) $(call color_header, "Launching objdump") @$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \ @@ -272,9 +272,9 @@ objdump: $(KERNEL_ELF) --section .rodata \ $(KERNEL_ELF) | rustfilt -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run nm -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ nm: $(KERNEL_ELF) $(call color_header, "Launching nm") @$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt @@ -286,22 +286,22 @@ nm: $(KERNEL_ELF) ##-------------------------------------------------------------------------------------------------- .PHONY: jtagboot openocd gdb gdb-opt0 -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Push the JTAG boot image to the real HW target -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ jtagboot: @$(DOCKER_JTAGBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(JTAG_BOOT_IMAGE) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Start OpenOCD session -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ openocd: $(call color_header, "Launching OpenOCD") @$(DOCKER_OPENOCD) openocd $(OPENOCD_ARG) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Start GDB session -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ gdb: RUSTC_MISC_ARGS += -C debuginfo=2 gdb-opt0: RUSTC_MISC_ARGS += -C debuginfo=2 -C opt-level=0 gdb gdb-opt0: $(KERNEL_ELF) @@ -324,16 +324,16 @@ test_boot test_unit test_integration test: else # QEMU is supported. -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run boot test -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ test_boot: $(KERNEL_BIN) $(call color_header, "Boot test - $(BSP)") @$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Helpers for unit and integration test targets -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ define KERNEL_TEST_RUNNER #!/usr/bin/env bash @@ -366,17 +366,17 @@ define test_prepare @chmod +x target/kernel_test_runner.sh endef -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run unit test(s) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ test_unit: $(call color_header, "Compiling unit test(s) - $(BSP)") $(call test_prepare) @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(TEST_CMD) --lib -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run integration test(s) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ test_integration: $(call color_header, "Compiling integration test(s) - $(BSP)") $(call test_prepare) diff --git a/17_kernel_symbols/README.md b/17_kernel_symbols/README.md index 04828703..78962bd8 100644 --- a/17_kernel_symbols/README.md +++ b/17_kernel_symbols/README.md @@ -585,9 +585,9 @@ diff -uNr 16_virtual_mem_part4_higher_half_kernel/kernel_symbols.mk 17_kernel_sy + +EXEC_SYMBOLS_TOOL = ruby $(KERNEL_SYMBOLS_TOOL_PATH)/main.rb + -+## ------------------------------------------------------------------------------ ++##------------------------------------------------------------------------------ +## Dockerization -+## ------------------------------------------------------------------------------ ++##------------------------------------------------------------------------------ +DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial + +# DOCKER_IMAGE defined in include file (see top of this file). @@ -702,9 +702,9 @@ diff -uNr 16_virtual_mem_part4_higher_half_kernel/Makefile 17_kernel_symbols/Mak KERNEL_ELF_TTABLES_DEPS = $(KERNEL_ELF_RAW) $(wildcard $(TT_TOOL_PATH)/*) -KERNEL_ELF = $(KERNEL_ELF_TTABLES) -+## ------------------------------------------------------------------------------ ++##------------------------------------------------------------------------------ +## Kernel symbols -+## ------------------------------------------------------------------------------ ++##------------------------------------------------------------------------------ +export KERNEL_SYMBOLS_TOOL_PATH = tools/kernel_symbols_tool + +KERNEL_ELF_TTABLES_SYMS = target/$(TARGET)/release/kernel+ttables+symbols @@ -726,16 +726,16 @@ diff -uNr 16_virtual_mem_part4_higher_half_kernel/Makefile 17_kernel_symbols/Mak @@ -178,11 +195,18 @@ @$(DOCKER_TOOLS) $(EXEC_TT_TOOL) $(BSP) $(KERNEL_ELF_TTABLES) - ## ------------------------------------------------------------------------------ + ##------------------------------------------------------------------------------ +## Generate kernel symbols and patch them into the kernel ELF -+## ------------------------------------------------------------------------------ ++##------------------------------------------------------------------------------ +$(KERNEL_ELF_TTABLES_SYMS): $(KERNEL_ELF_TTABLES_SYMS_DEPS) + $(call color_header, "Generating kernel symbols and patching kernel ELF") + @$(MAKE) --no-print-directory -f kernel_symbols.mk + -+## ------------------------------------------------------------------------------ ++##------------------------------------------------------------------------------ ## Generate the stripped kernel binary - ## ------------------------------------------------------------------------------ + ##------------------------------------------------------------------------------ -$(KERNEL_BIN): $(KERNEL_ELF_TTABLES) +$(KERNEL_BIN): $(KERNEL_ELF_TTABLES_SYMS) $(call color_header, "Generating stripped binary") @@ -745,9 +745,9 @@ diff -uNr 16_virtual_mem_part4_higher_half_kernel/Makefile 17_kernel_symbols/Mak @echo $(KERNEL_BIN) $(call color_progress_prefix, "Size") @@ -191,7 +215,7 @@ - ## ------------------------------------------------------------------------------ + ##------------------------------------------------------------------------------ ## Generate the documentation - ## ------------------------------------------------------------------------------ + ##------------------------------------------------------------------------------ -doc: +doc: clean $(call color_header, "Generating docs") diff --git a/17_kernel_symbols/kernel_symbols.mk b/17_kernel_symbols/kernel_symbols.mk index 4f3647c5..d38b7785 100644 --- a/17_kernel_symbols/kernel_symbols.mk +++ b/17_kernel_symbols/kernel_symbols.mk @@ -66,9 +66,9 @@ OBJCOPY_CMD = rust-objcopy \ EXEC_SYMBOLS_TOOL = ruby $(KERNEL_SYMBOLS_TOOL_PATH)/main.rb -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Dockerization -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial # DOCKER_IMAGE defined in include file (see top of this file). diff --git a/18_backtrace/Makefile b/18_backtrace/Makefile index 7fb52907..7edf4edf 100644 --- a/18_backtrace/Makefile +++ b/18_backtrace/Makefile @@ -77,17 +77,17 @@ KERNEL_ELF_RAW = target/$(TARGET)/release/kernel # https://doc.rust-lang.org/cargo/guide/build-cache.html#dep-info-files KERNEL_ELF_RAW_DEPS = $(filter-out %: ,$(file < $(KERNEL_ELF_RAW).d)) $(KERNEL_MANIFEST) $(LAST_BUILD_CONFIG) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Translation tables -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ TT_TOOL_PATH = tools/translation_table_tool KERNEL_ELF_TTABLES = target/$(TARGET)/release/kernel+ttables KERNEL_ELF_TTABLES_DEPS = $(KERNEL_ELF_RAW) $(wildcard $(TT_TOOL_PATH)/*) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Kernel symbols -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ export KERNEL_SYMBOLS_TOOL_PATH = tools/kernel_symbols_tool KERNEL_ELF_TTABLES_SYMS = target/$(TARGET)/release/kernel+ttables+symbols @@ -137,9 +137,9 @@ EXEC_TT_TOOL = ruby $(TT_TOOL_PATH)/main.rb EXEC_TEST_DISPATCH = ruby ../common/tests/dispatch.rb EXEC_MINIPUSH = ruby ../common/serial/minipush.rb -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Dockerization -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i DOCKER_ARG_DIR_COMMON = -v $(shell pwd)/../common:/work/common @@ -173,39 +173,39 @@ endif all: $(KERNEL_BIN) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Save the configuration as a file, so make understands if it changed. -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ $(LAST_BUILD_CONFIG): @rm -f target/*.build_config @mkdir -p target @touch $(LAST_BUILD_CONFIG) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Compile the kernel ELF -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ $(KERNEL_ELF_RAW): $(KERNEL_ELF_RAW_DEPS) $(call color_header, "Compiling kernel ELF - $(BSP)") @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Precompute the kernel translation tables and patch them into the kernel ELF -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ $(KERNEL_ELF_TTABLES): $(KERNEL_ELF_TTABLES_DEPS) $(call color_header, "Precomputing kernel translation tables and patching kernel ELF") @cp $(KERNEL_ELF_RAW) $(KERNEL_ELF_TTABLES) @$(DOCKER_TOOLS) $(EXEC_TT_TOOL) $(BSP) $(KERNEL_ELF_TTABLES) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Generate kernel symbols and patch them into the kernel ELF -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ $(KERNEL_ELF_TTABLES_SYMS): $(KERNEL_ELF_TTABLES_SYMS_DEPS) $(call color_header, "Generating kernel symbols and patching kernel ELF") @$(MAKE) --no-print-directory -f kernel_symbols.mk -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Generate the stripped kernel binary -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ $(KERNEL_BIN): $(KERNEL_ELF_TTABLES_SYMS) $(call color_header, "Generating stripped binary") @$(OBJCOPY_CMD) $(KERNEL_ELF_TTABLES_SYMS) $(KERNEL_BIN) @@ -214,16 +214,16 @@ $(KERNEL_BIN): $(KERNEL_ELF_TTABLES_SYMS) $(call color_progress_prefix, "Size") $(call disk_usage_KiB, $(KERNEL_BIN)) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Generate the documentation -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ doc: clean $(call color_header, "Generating docs") @$(DOC_CMD) --document-private-items --open -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run the kernel in QEMU -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. qemu: @@ -237,36 +237,36 @@ qemu: $(KERNEL_BIN) endif -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Push the kernel to the real HW target -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ chainboot: $(KERNEL_BIN) @$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(KERNEL_BIN) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run clippy -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ clippy: @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) --features test_build --tests \ --manifest-path $(KERNEL_MANIFEST) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Clean -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ clean: rm -rf target $(KERNEL_BIN) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run readelf -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ readelf: $(KERNEL_ELF) $(call color_header, "Launching readelf") @$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run objdump -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ objdump: $(KERNEL_ELF) $(call color_header, "Launching objdump") @$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \ @@ -274,9 +274,9 @@ objdump: $(KERNEL_ELF) --section .rodata \ $(KERNEL_ELF) | rustfilt -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run nm -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ nm: $(KERNEL_ELF) $(call color_header, "Launching nm") @$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt @@ -288,22 +288,22 @@ nm: $(KERNEL_ELF) ##-------------------------------------------------------------------------------------------------- .PHONY: jtagboot openocd gdb gdb-opt0 -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Push the JTAG boot image to the real HW target -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ jtagboot: @$(DOCKER_JTAGBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(JTAG_BOOT_IMAGE) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Start OpenOCD session -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ openocd: $(call color_header, "Launching OpenOCD") @$(DOCKER_OPENOCD) openocd $(OPENOCD_ARG) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Start GDB session -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ gdb-opt0: RUSTC_MISC_ARGS += -C opt-level=0 gdb gdb-opt0: $(KERNEL_ELF) $(call color_header, "Launching GDB") @@ -325,16 +325,16 @@ test_boot test_unit test_integration test: else # QEMU is supported. -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run boot test -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ test_boot: $(KERNEL_BIN) $(call color_header, "Boot test - $(BSP)") @$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Helpers for unit and integration test targets -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ define KERNEL_TEST_RUNNER #!/usr/bin/env bash @@ -367,17 +367,17 @@ define test_prepare @chmod +x target/kernel_test_runner.sh endef -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run unit test(s) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ test_unit: $(call color_header, "Compiling unit test(s) - $(BSP)") $(call test_prepare) @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(TEST_CMD) --lib -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run integration test(s) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ test_integration: $(call color_header, "Compiling integration test(s) - $(BSP)") $(call test_prepare) diff --git a/18_backtrace/README.md b/18_backtrace/README.md index 6c3fda77..00a156d7 100644 --- a/18_backtrace/README.md +++ b/18_backtrace/README.md @@ -1261,9 +1261,9 @@ diff -uNr 17_kernel_symbols/Makefile 18_backtrace/Makefile --strip-all \ -O binary @@ -302,8 +304,7 @@ - ## ------------------------------------------------------------------------------ + ##------------------------------------------------------------------------------ ## Start GDB session - ## ------------------------------------------------------------------------------ + ##------------------------------------------------------------------------------ -gdb: RUSTC_MISC_ARGS += -C debuginfo=2 -gdb-opt0: RUSTC_MISC_ARGS += -C debuginfo=2 -C opt-level=0 +gdb-opt0: RUSTC_MISC_ARGS += -C opt-level=0 diff --git a/18_backtrace/kernel_symbols.mk b/18_backtrace/kernel_symbols.mk index 4f3647c5..d38b7785 100644 --- a/18_backtrace/kernel_symbols.mk +++ b/18_backtrace/kernel_symbols.mk @@ -66,9 +66,9 @@ OBJCOPY_CMD = rust-objcopy \ EXEC_SYMBOLS_TOOL = ruby $(KERNEL_SYMBOLS_TOOL_PATH)/main.rb -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Dockerization -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial # DOCKER_IMAGE defined in include file (see top of this file). diff --git a/19_kernel_heap/Makefile b/19_kernel_heap/Makefile index e97e3fbb..f9704a44 100644 --- a/19_kernel_heap/Makefile +++ b/19_kernel_heap/Makefile @@ -82,17 +82,17 @@ KERNEL_ELF_RAW = target/$(TARGET)/release/kernel # https://doc.rust-lang.org/cargo/guide/build-cache.html#dep-info-files KERNEL_ELF_RAW_DEPS = $(filter-out %: ,$(file < $(KERNEL_ELF_RAW).d)) $(KERNEL_MANIFEST) $(LAST_BUILD_CONFIG) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Translation tables -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ TT_TOOL_PATH = tools/translation_table_tool KERNEL_ELF_TTABLES = target/$(TARGET)/release/kernel+ttables KERNEL_ELF_TTABLES_DEPS = $(KERNEL_ELF_RAW) $(wildcard $(TT_TOOL_PATH)/*) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Kernel symbols -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ export KERNEL_SYMBOLS_TOOL_PATH = tools/kernel_symbols_tool KERNEL_ELF_TTABLES_SYMS = target/$(TARGET)/release/kernel+ttables+symbols @@ -142,9 +142,9 @@ EXEC_TT_TOOL = ruby $(TT_TOOL_PATH)/main.rb EXEC_TEST_DISPATCH = ruby ../common/tests/dispatch.rb EXEC_MINIPUSH = ruby ../common/serial/minipush.rb -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Dockerization -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i DOCKER_ARG_DIR_COMMON = -v $(shell pwd)/../common:/work/common @@ -178,39 +178,39 @@ endif all: $(KERNEL_BIN) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Save the configuration as a file, so make understands if it changed. -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ $(LAST_BUILD_CONFIG): @rm -f target/*.build_config @mkdir -p target @touch $(LAST_BUILD_CONFIG) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Compile the kernel ELF -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ $(KERNEL_ELF_RAW): $(KERNEL_ELF_RAW_DEPS) $(call color_header, "Compiling kernel ELF - $(BSP)") @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Precompute the kernel translation tables and patch them into the kernel ELF -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ $(KERNEL_ELF_TTABLES): $(KERNEL_ELF_TTABLES_DEPS) $(call color_header, "Precomputing kernel translation tables and patching kernel ELF") @cp $(KERNEL_ELF_RAW) $(KERNEL_ELF_TTABLES) @$(DOCKER_TOOLS) $(EXEC_TT_TOOL) $(BSP) $(KERNEL_ELF_TTABLES) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Generate kernel symbols and patch them into the kernel ELF -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ $(KERNEL_ELF_TTABLES_SYMS): $(KERNEL_ELF_TTABLES_SYMS_DEPS) $(call color_header, "Generating kernel symbols and patching kernel ELF") @$(MAKE) --no-print-directory -f kernel_symbols.mk -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Generate the stripped kernel binary -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ $(KERNEL_BIN): $(KERNEL_ELF_TTABLES_SYMS) $(call color_header, "Generating stripped binary") @$(OBJCOPY_CMD) $(KERNEL_ELF_TTABLES_SYMS) $(KERNEL_BIN) @@ -219,16 +219,16 @@ $(KERNEL_BIN): $(KERNEL_ELF_TTABLES_SYMS) $(call color_progress_prefix, "Size") $(call disk_usage_KiB, $(KERNEL_BIN)) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Generate the documentation -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ doc: clean $(call color_header, "Generating docs") @$(DOC_CMD) --document-private-items --open -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run the kernel in QEMU -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. qemu: @@ -242,36 +242,36 @@ qemu: $(KERNEL_BIN) endif -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Push the kernel to the real HW target -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ chainboot: $(KERNEL_BIN) @$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(KERNEL_BIN) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run clippy -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ clippy: @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) --features test_build --tests \ --manifest-path $(KERNEL_MANIFEST) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Clean -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ clean: rm -rf target $(KERNEL_BIN) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run readelf -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ readelf: $(KERNEL_ELF) $(call color_header, "Launching readelf") @$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run objdump -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ objdump: $(KERNEL_ELF) $(call color_header, "Launching objdump") @$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \ @@ -279,9 +279,9 @@ objdump: $(KERNEL_ELF) --section .rodata \ $(KERNEL_ELF) | rustfilt -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run nm -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ nm: $(KERNEL_ELF) $(call color_header, "Launching nm") @$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt @@ -293,22 +293,22 @@ nm: $(KERNEL_ELF) ##-------------------------------------------------------------------------------------------------- .PHONY: jtagboot openocd gdb gdb-opt0 -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Push the JTAG boot image to the real HW target -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ jtagboot: @$(DOCKER_JTAGBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(JTAG_BOOT_IMAGE) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Start OpenOCD session -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ openocd: $(call color_header, "Launching OpenOCD") @$(DOCKER_OPENOCD) openocd $(OPENOCD_ARG) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Start GDB session -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ gdb-opt0: RUSTC_MISC_ARGS += -C opt-level=0 gdb gdb-opt0: $(KERNEL_ELF) $(call color_header, "Launching GDB") @@ -330,16 +330,16 @@ test_boot test_unit test_integration test: else # QEMU is supported. -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run boot test -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ test_boot: $(KERNEL_BIN) $(call color_header, "Boot test - $(BSP)") @$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Helpers for unit and integration test targets -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ define KERNEL_TEST_RUNNER #!/usr/bin/env bash @@ -372,17 +372,17 @@ define test_prepare @chmod +x target/kernel_test_runner.sh endef -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run unit test(s) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ test_unit: $(call color_header, "Compiling unit test(s) - $(BSP)") $(call test_prepare) @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(TEST_CMD) --lib -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run integration test(s) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ test_integration: $(call color_header, "Compiling integration test(s) - $(BSP)") $(call test_prepare) diff --git a/19_kernel_heap/kernel_symbols.mk b/19_kernel_heap/kernel_symbols.mk index 4f3647c5..d38b7785 100644 --- a/19_kernel_heap/kernel_symbols.mk +++ b/19_kernel_heap/kernel_symbols.mk @@ -66,9 +66,9 @@ OBJCOPY_CMD = rust-objcopy \ EXEC_SYMBOLS_TOOL = ruby $(KERNEL_SYMBOLS_TOOL_PATH)/main.rb -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Dockerization -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial # DOCKER_IMAGE defined in include file (see top of this file). diff --git a/20_timer_callbacks/Makefile b/20_timer_callbacks/Makefile index e97e3fbb..f9704a44 100644 --- a/20_timer_callbacks/Makefile +++ b/20_timer_callbacks/Makefile @@ -82,17 +82,17 @@ KERNEL_ELF_RAW = target/$(TARGET)/release/kernel # https://doc.rust-lang.org/cargo/guide/build-cache.html#dep-info-files KERNEL_ELF_RAW_DEPS = $(filter-out %: ,$(file < $(KERNEL_ELF_RAW).d)) $(KERNEL_MANIFEST) $(LAST_BUILD_CONFIG) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Translation tables -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ TT_TOOL_PATH = tools/translation_table_tool KERNEL_ELF_TTABLES = target/$(TARGET)/release/kernel+ttables KERNEL_ELF_TTABLES_DEPS = $(KERNEL_ELF_RAW) $(wildcard $(TT_TOOL_PATH)/*) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Kernel symbols -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ export KERNEL_SYMBOLS_TOOL_PATH = tools/kernel_symbols_tool KERNEL_ELF_TTABLES_SYMS = target/$(TARGET)/release/kernel+ttables+symbols @@ -142,9 +142,9 @@ EXEC_TT_TOOL = ruby $(TT_TOOL_PATH)/main.rb EXEC_TEST_DISPATCH = ruby ../common/tests/dispatch.rb EXEC_MINIPUSH = ruby ../common/serial/minipush.rb -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Dockerization -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i DOCKER_ARG_DIR_COMMON = -v $(shell pwd)/../common:/work/common @@ -178,39 +178,39 @@ endif all: $(KERNEL_BIN) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Save the configuration as a file, so make understands if it changed. -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ $(LAST_BUILD_CONFIG): @rm -f target/*.build_config @mkdir -p target @touch $(LAST_BUILD_CONFIG) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Compile the kernel ELF -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ $(KERNEL_ELF_RAW): $(KERNEL_ELF_RAW_DEPS) $(call color_header, "Compiling kernel ELF - $(BSP)") @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Precompute the kernel translation tables and patch them into the kernel ELF -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ $(KERNEL_ELF_TTABLES): $(KERNEL_ELF_TTABLES_DEPS) $(call color_header, "Precomputing kernel translation tables and patching kernel ELF") @cp $(KERNEL_ELF_RAW) $(KERNEL_ELF_TTABLES) @$(DOCKER_TOOLS) $(EXEC_TT_TOOL) $(BSP) $(KERNEL_ELF_TTABLES) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Generate kernel symbols and patch them into the kernel ELF -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ $(KERNEL_ELF_TTABLES_SYMS): $(KERNEL_ELF_TTABLES_SYMS_DEPS) $(call color_header, "Generating kernel symbols and patching kernel ELF") @$(MAKE) --no-print-directory -f kernel_symbols.mk -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Generate the stripped kernel binary -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ $(KERNEL_BIN): $(KERNEL_ELF_TTABLES_SYMS) $(call color_header, "Generating stripped binary") @$(OBJCOPY_CMD) $(KERNEL_ELF_TTABLES_SYMS) $(KERNEL_BIN) @@ -219,16 +219,16 @@ $(KERNEL_BIN): $(KERNEL_ELF_TTABLES_SYMS) $(call color_progress_prefix, "Size") $(call disk_usage_KiB, $(KERNEL_BIN)) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Generate the documentation -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ doc: clean $(call color_header, "Generating docs") @$(DOC_CMD) --document-private-items --open -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run the kernel in QEMU -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. qemu: @@ -242,36 +242,36 @@ qemu: $(KERNEL_BIN) endif -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Push the kernel to the real HW target -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ chainboot: $(KERNEL_BIN) @$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(KERNEL_BIN) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run clippy -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ clippy: @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) --features test_build --tests \ --manifest-path $(KERNEL_MANIFEST) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Clean -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ clean: rm -rf target $(KERNEL_BIN) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run readelf -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ readelf: $(KERNEL_ELF) $(call color_header, "Launching readelf") @$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run objdump -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ objdump: $(KERNEL_ELF) $(call color_header, "Launching objdump") @$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \ @@ -279,9 +279,9 @@ objdump: $(KERNEL_ELF) --section .rodata \ $(KERNEL_ELF) | rustfilt -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run nm -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ nm: $(KERNEL_ELF) $(call color_header, "Launching nm") @$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt @@ -293,22 +293,22 @@ nm: $(KERNEL_ELF) ##-------------------------------------------------------------------------------------------------- .PHONY: jtagboot openocd gdb gdb-opt0 -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Push the JTAG boot image to the real HW target -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ jtagboot: @$(DOCKER_JTAGBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(JTAG_BOOT_IMAGE) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Start OpenOCD session -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ openocd: $(call color_header, "Launching OpenOCD") @$(DOCKER_OPENOCD) openocd $(OPENOCD_ARG) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Start GDB session -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ gdb-opt0: RUSTC_MISC_ARGS += -C opt-level=0 gdb gdb-opt0: $(KERNEL_ELF) $(call color_header, "Launching GDB") @@ -330,16 +330,16 @@ test_boot test_unit test_integration test: else # QEMU is supported. -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run boot test -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ test_boot: $(KERNEL_BIN) $(call color_header, "Boot test - $(BSP)") @$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Helpers for unit and integration test targets -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ define KERNEL_TEST_RUNNER #!/usr/bin/env bash @@ -372,17 +372,17 @@ define test_prepare @chmod +x target/kernel_test_runner.sh endef -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run unit test(s) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ test_unit: $(call color_header, "Compiling unit test(s) - $(BSP)") $(call test_prepare) @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(TEST_CMD) --lib -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run integration test(s) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ test_integration: $(call color_header, "Compiling integration test(s) - $(BSP)") $(call test_prepare) diff --git a/20_timer_callbacks/kernel_symbols.mk b/20_timer_callbacks/kernel_symbols.mk index 4f3647c5..d38b7785 100644 --- a/20_timer_callbacks/kernel_symbols.mk +++ b/20_timer_callbacks/kernel_symbols.mk @@ -66,9 +66,9 @@ OBJCOPY_CMD = rust-objcopy \ EXEC_SYMBOLS_TOOL = ruby $(KERNEL_SYMBOLS_TOOL_PATH)/main.rb -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Dockerization -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial # DOCKER_IMAGE defined in include file (see top of this file). diff --git a/X1_JTAG_boot/Makefile b/X1_JTAG_boot/Makefile index 85f709a0..b13f0dfb 100644 --- a/X1_JTAG_boot/Makefile +++ b/X1_JTAG_boot/Makefile @@ -93,9 +93,9 @@ EXEC_QEMU = $(QEMU_BINARY) -M $(QEMU_MACHINE_TYPE) EXEC_TEST_DISPATCH = ruby ../common/tests/dispatch.rb EXEC_MINIPUSH = ruby ../common/serial/minipush.rb -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Dockerization -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i DOCKER_ARG_DIR_COMMON = -v $(shell pwd)/../common:/work/common @@ -122,24 +122,24 @@ endif all: $(KERNEL_BIN) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Save the configuration as a file, so make understands if it changed. -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ $(LAST_BUILD_CONFIG): @rm -f target/*.build_config @mkdir -p target @touch $(LAST_BUILD_CONFIG) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Compile the kernel ELF -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ $(KERNEL_ELF): $(KERNEL_ELF_DEPS) $(call color_header, "Compiling kernel ELF - $(BSP)") @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Generate the stripped kernel binary -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ $(KERNEL_BIN): $(KERNEL_ELF) $(call color_header, "Generating stripped binary") @$(OBJCOPY_CMD) $(KERNEL_ELF) $(KERNEL_BIN) @@ -148,16 +148,16 @@ $(KERNEL_BIN): $(KERNEL_ELF) $(call color_progress_prefix, "Size") $(call disk_usage_KiB, $(KERNEL_BIN)) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Generate the documentation -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ doc: $(call color_header, "Generating docs") @$(DOC_CMD) --document-private-items --open -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run the kernel in QEMU -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. qemu: @@ -171,34 +171,34 @@ qemu: $(KERNEL_BIN) endif -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Push the kernel to the real HW target -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ chainboot: $(KERNEL_BIN) @$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(KERNEL_BIN) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run clippy -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ clippy: @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Clean -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ clean: rm -rf target $(KERNEL_BIN) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run readelf -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ readelf: $(KERNEL_ELF) $(call color_header, "Launching readelf") @$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF) -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run objdump -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ objdump: $(KERNEL_ELF) $(call color_header, "Launching objdump") @$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \ @@ -206,9 +206,9 @@ objdump: $(KERNEL_ELF) --section .rodata \ $(KERNEL_ELF) | rustfilt -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run nm -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ nm: $(KERNEL_ELF) $(call color_header, "Launching nm") @$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt @@ -227,9 +227,9 @@ test_boot test: else # QEMU is supported. -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ ## Run boot test -## ------------------------------------------------------------------------------ +##------------------------------------------------------------------------------ test_boot: $(KERNEL_BIN) $(call color_header, "Boot test - $(BSP)") @$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN)