From 89ca6cc5f69efd903a3b369bd97e3b0c35024785 Mon Sep 17 00:00:00 2001 From: jameszow Date: Wed, 13 Sep 2023 11:33:41 +0800 Subject: [PATCH] fix rb file i.to_s and code style --- .githooks/pre-commit | 4 +- 01_wait_forever/Makefile | 64 +++++----- 02_runtime_init/Makefile | 64 +++++----- 02_runtime_init/README.md | 4 +- 03_hacky_hello_world/Makefile | 72 +++++------ 03_hacky_hello_world/README.md | 12 +- 04_safe_globals/Makefile | 72 +++++------ 05_drivers_gpio_uart/Makefile | 76 +++++------ 05_drivers_gpio_uart/README.md | 16 +-- 06_uart_chainloader/Makefile | 76 +++++------ 06_uart_chainloader/README.md | 20 +-- 06_uart_chainloader/tests/chainboot_test.rb | 4 +- 07_timestamps/Makefile | 76 +++++------ 07_timestamps/README.md | 16 +-- 08_hw_debug_JTAG/Makefile | 92 +++++++------- 08_hw_debug_JTAG/README.md | 20 +-- 09_privilege_level/Makefile | 92 +++++++------- .../Makefile | 92 +++++++------- 11_exceptions_part1_groundwork/Makefile | 92 +++++++------- 12_integrated_testing/Makefile | 104 +++++++-------- 12_integrated_testing/README.md | 8 +- .../kernel/tests/00_console_sanity.rb | 4 +- .../tests/03_exception_restore_sanity.rb | 4 +- 13_exceptions_part2_peripheral_IRQs/Makefile | 104 +++++++-------- .../kernel/tests/00_console_sanity.rb | 4 +- .../tests/03_exception_restore_sanity.rb | 4 +- 14_virtual_mem_part2_mmio_remap/Makefile | 104 +++++++-------- .../kernel/tests/00_console_sanity.rb | 4 +- .../tests/03_exception_restore_sanity.rb | 4 +- .../Makefile | 112 ++++++++-------- .../README.md | 32 ++--- .../kernel/Cargo.toml | 8 +- .../kernel/tests/00_console_sanity.rb | 4 +- .../tests/03_exception_restore_sanity.rb | 4 +- .../tools/translation_table_tool/generic.rb | 2 +- .../Makefile | 112 ++++++++-------- .../kernel/tests/00_console_sanity.rb | 4 +- .../tests/03_exception_restore_sanity.rb | 4 +- .../tools/translation_table_tool/generic.rb | 2 +- 17_kernel_symbols/Makefile | 120 +++++++++--------- 17_kernel_symbols/README.md | 40 +++--- .../kernel/tests/00_console_sanity.rb | 4 +- .../tests/03_exception_restore_sanity.rb | 4 +- 17_kernel_symbols/kernel_symbols.mk | 20 +-- .../tools/translation_table_tool/generic.rb | 2 +- 18_backtrace/Makefile | 120 +++++++++--------- 18_backtrace/README.md | 16 +-- .../kernel/tests/00_console_sanity.rb | 4 +- .../tests/03_exception_restore_sanity.rb | 4 +- .../kernel/tests/05_backtrace_sanity.rb | 4 +- .../tests/06_backtrace_invalid_frame.rb | 4 +- .../kernel/tests/07_backtrace_invalid_link.rb | 4 +- 18_backtrace/kernel_symbols.mk | 20 +-- .../tools/translation_table_tool/generic.rb | 2 +- 19_kernel_heap/Makefile | 120 +++++++++--------- 19_kernel_heap/README.md | 2 +- .../kernel/tests/00_console_sanity.rb | 4 +- .../tests/03_exception_restore_sanity.rb | 4 +- .../kernel/tests/05_backtrace_sanity.rb | 4 +- .../tests/06_backtrace_invalid_frame.rb | 4 +- .../kernel/tests/07_backtrace_invalid_link.rb | 4 +- 19_kernel_heap/kernel_symbols.mk | 20 +-- .../tools/translation_table_tool/generic.rb | 2 +- 20_timer_callbacks/Makefile | 120 +++++++++--------- 20_timer_callbacks/kernel/Cargo.toml | 8 +- .../kernel/tests/00_console_sanity.rb | 4 +- .../tests/03_exception_restore_sanity.rb | 4 +- .../kernel/tests/05_backtrace_sanity.rb | 4 +- .../tests/06_backtrace_invalid_frame.rb | 4 +- .../kernel/tests/07_backtrace_invalid_link.rb | 4 +- 20_timer_callbacks/kernel_symbols.mk | 20 +-- .../tools/translation_table_tool/generic.rb | 2 +- X1_JTAG_boot/Cargo.toml | 4 +- X1_JTAG_boot/Makefile | 76 +++++------ common/serial/minipush.rb | 4 +- common/serial/miniterm.rb | 4 +- utils/devtool.rb | 4 +- 77 files changed, 1193 insertions(+), 1193 deletions(-) diff --git a/.githooks/pre-commit b/.githooks/pre-commit index 22f859b4..2a9e5cc7 100755 --- a/.githooks/pre-commit +++ b/.githooks/pre-commit @@ -23,9 +23,9 @@ def copyright_check(staged_files) copyright_check_files(staged_files) end -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Execution starts here -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- staged_files = `git --no-pager diff --name-only --cached --diff-filter=d`.split(/\n/) root_dir = `git rev-parse --show-toplevel`.strip diff --git a/01_wait_forever/Makefile b/01_wait_forever/Makefile index 51c128f7..a7c8160c 100644 --- a/01_wait_forever/Makefile +++ b/01_wait_forever/Makefile @@ -6,18 +6,18 @@ include ../common/docker.mk include ../common/format.mk include ../common/operating_system.mk -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Optional, user-provided configuration values -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- # Default to the RPi3. BSP ?= rpi3 -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## BSP-specific configuration values -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- QEMU_MISSING_STRING = "This board is not yet supported for QEMU." ifeq ($(BSP),rpi3) @@ -49,9 +49,9 @@ export LD_SCRIPT_PATH -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Targets and Prerequisites -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- KERNEL_MANIFEST = Cargo.toml KERNEL_LINKER_SCRIPT = kernel.ld LAST_BUILD_CONFIG = target/$(BSP).build_config @@ -63,9 +63,9 @@ KERNEL_ELF_DEPS = $(filter-out %: ,$(file < $(KERNEL_ELF).d)) $(KERNEL_MANIFEST) -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Command building blocks -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- RUSTFLAGS = $(RUSTC_MISC_ARGS) \ -C link-arg=--library-path=$(LD_SCRIPT_PATH) \ -C link-arg=--script=$(KERNEL_LINKER_SCRIPT) @@ -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 @@ -100,31 +100,31 @@ DOCKER_TOOLS = $(DOCKER_CMD) $(DOCKER_IMAGE) -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Targets -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- .PHONY: all doc qemu clippy clean readelf objdump nm check 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 893564e2..8109e314 100644 --- a/02_runtime_init/Makefile +++ b/02_runtime_init/Makefile @@ -6,18 +6,18 @@ include ../common/docker.mk include ../common/format.mk include ../common/operating_system.mk -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Optional, user-provided configuration values -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- # Default to the RPi3. BSP ?= rpi3 -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## BSP-specific configuration values -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- QEMU_MISSING_STRING = "This board is not yet supported for QEMU." ifeq ($(BSP),rpi3) @@ -49,9 +49,9 @@ export LD_SCRIPT_PATH -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Targets and Prerequisites -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- KERNEL_MANIFEST = Cargo.toml KERNEL_LINKER_SCRIPT = kernel.ld LAST_BUILD_CONFIG = target/$(BSP).build_config @@ -63,9 +63,9 @@ KERNEL_ELF_DEPS = $(filter-out %: ,$(file < $(KERNEL_ELF).d)) $(KERNEL_MANIFEST) -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Command building blocks -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- RUSTFLAGS = $(RUSTC_MISC_ARGS) \ -C link-arg=--library-path=$(LD_SCRIPT_PATH) \ -C link-arg=--script=$(KERNEL_LINKER_SCRIPT) @@ -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 @@ -100,31 +100,31 @@ DOCKER_TOOLS = $(DOCKER_CMD) $(DOCKER_IMAGE) -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Targets -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- .PHONY: all doc qemu clippy clean readelf objdump nm check 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 2bec27ac..f9453519 100644 --- a/02_runtime_init/README.md +++ b/02_runtime_init/README.md @@ -41,7 +41,7 @@ diff -uNr 01_wait_forever/Cargo.toml 02_runtime_init/Cargo.toml edition = "2021" @@ -21,3 +21,7 @@ - ##-------------------------------------------------------------------------------------------------- + ## -------------------------------------------------------------------------------------------------- [dependencies] + @@ -59,7 +59,7 @@ diff -uNr 01_wait_forever/Makefile 02_runtime_init/Makefile + --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 ce5aff09..85e44f50 100644 --- a/03_hacky_hello_world/Makefile +++ b/03_hacky_hello_world/Makefile @@ -6,18 +6,18 @@ include ../common/docker.mk include ../common/format.mk include ../common/operating_system.mk -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Optional, user-provided configuration values -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- # Default to the RPi3. BSP ?= rpi3 -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## BSP-specific configuration values -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- QEMU_MISSING_STRING = "This board is not yet supported for QEMU." ifeq ($(BSP),rpi3) @@ -49,9 +49,9 @@ export LD_SCRIPT_PATH -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Targets and Prerequisites -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- KERNEL_MANIFEST = Cargo.toml KERNEL_LINKER_SCRIPT = kernel.ld LAST_BUILD_CONFIG = target/$(BSP).build_config @@ -63,9 +63,9 @@ KERNEL_ELF_DEPS = $(filter-out %: ,$(file < $(KERNEL_ELF).d)) $(KERNEL_MANIFEST) -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Command building blocks -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- RUSTFLAGS = $(RUSTC_MISC_ARGS) \ -C link-arg=--library-path=$(LD_SCRIPT_PATH) \ -C link-arg=--script=$(KERNEL_LINKER_SCRIPT) @@ -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 @@ -103,31 +103,31 @@ DOCKER_TEST = $(DOCKER_CMD) $(DOCKER_ARG_DIR_COMMON) $(DOCKER_IMAGE) -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Targets -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- .PHONY: all doc qemu clippy clean readelf objdump nm check 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,18 +187,18 @@ 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 -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Testing targets -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- .PHONY: test test_boot ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. @@ -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 07bf4503..0f772e1e 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 @@ -101,9 +101,9 @@ diff -uNr 02_runtime_init/Makefile 03_hacky_hello_world/Makefile + + -+##-------------------------------------------------------------------------------------------------- ++## -------------------------------------------------------------------------------------------------- +## Testing targets -+##-------------------------------------------------------------------------------------------------- ++## -------------------------------------------------------------------------------------------------- +.PHONY: test test_boot + +ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. @@ -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 ce5aff09..85e44f50 100644 --- a/04_safe_globals/Makefile +++ b/04_safe_globals/Makefile @@ -6,18 +6,18 @@ include ../common/docker.mk include ../common/format.mk include ../common/operating_system.mk -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Optional, user-provided configuration values -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- # Default to the RPi3. BSP ?= rpi3 -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## BSP-specific configuration values -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- QEMU_MISSING_STRING = "This board is not yet supported for QEMU." ifeq ($(BSP),rpi3) @@ -49,9 +49,9 @@ export LD_SCRIPT_PATH -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Targets and Prerequisites -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- KERNEL_MANIFEST = Cargo.toml KERNEL_LINKER_SCRIPT = kernel.ld LAST_BUILD_CONFIG = target/$(BSP).build_config @@ -63,9 +63,9 @@ KERNEL_ELF_DEPS = $(filter-out %: ,$(file < $(KERNEL_ELF).d)) $(KERNEL_MANIFEST) -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Command building blocks -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- RUSTFLAGS = $(RUSTC_MISC_ARGS) \ -C link-arg=--library-path=$(LD_SCRIPT_PATH) \ -C link-arg=--script=$(KERNEL_LINKER_SCRIPT) @@ -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 @@ -103,31 +103,31 @@ DOCKER_TEST = $(DOCKER_CMD) $(DOCKER_ARG_DIR_COMMON) $(DOCKER_IMAGE) -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Targets -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- .PHONY: all doc qemu clippy clean readelf objdump nm check 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,18 +187,18 @@ 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 -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Testing targets -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- .PHONY: test test_boot ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. @@ -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 35953578..399e9481 100644 --- a/05_drivers_gpio_uart/Makefile +++ b/05_drivers_gpio_uart/Makefile @@ -6,9 +6,9 @@ include ../common/docker.mk include ../common/format.mk include ../common/operating_system.mk -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Optional, user-provided configuration values -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- # Default to the RPi3. BSP ?= rpi3 @@ -18,9 +18,9 @@ DEV_SERIAL ?= /dev/ttyUSB0 -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## BSP-specific configuration values -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- QEMU_MISSING_STRING = "This board is not yet supported for QEMU." ifeq ($(BSP),rpi3) @@ -52,9 +52,9 @@ export LD_SCRIPT_PATH -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Targets and Prerequisites -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- KERNEL_MANIFEST = Cargo.toml KERNEL_LINKER_SCRIPT = kernel.ld LAST_BUILD_CONFIG = target/$(BSP).build_config @@ -66,9 +66,9 @@ KERNEL_ELF_DEPS = $(filter-out %: ,$(file < $(KERNEL_ELF).d)) $(KERNEL_MANIFEST) -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Command building blocks -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- RUSTFLAGS = $(RUSTC_MISC_ARGS) \ -C link-arg=--library-path=$(LD_SCRIPT_PATH) \ -C link-arg=--script=$(KERNEL_LINKER_SCRIPT) @@ -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 @@ -115,31 +115,31 @@ endif -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Targets -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- .PHONY: all doc qemu miniterm clippy clean readelf objdump nm check 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,18 +206,18 @@ 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 -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Testing targets -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- .PHONY: test test_boot ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. @@ -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 e6e5dd64..dba6bfda 100644 --- a/05_drivers_gpio_uart/README.md +++ b/05_drivers_gpio_uart/README.md @@ -195,14 +195,14 @@ diff -uNr 04_safe_globals/Makefile 05_drivers_gpio_uart/Makefile + - ##-------------------------------------------------------------------------------------------------- + ## -------------------------------------------------------------------------------------------------- @@ -88,6 +91,7 @@ EXEC_QEMU = $(QEMU_BINARY) -M $(QEMU_MACHINE_TYPE) 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 @@ -224,9 +224,9 @@ diff -uNr 04_safe_globals/Makefile 05_drivers_gpio_uart/Makefile + - ##-------------------------------------------------------------------------------------------------- + ## -------------------------------------------------------------------------------------------------- ## Targets - ##-------------------------------------------------------------------------------------------------- + ## -------------------------------------------------------------------------------------------------- -.PHONY: all doc qemu clippy clean readelf objdump nm check +.PHONY: all doc qemu miniterm clippy clean readelf objdump nm check @@ -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 3366de31..6f6c41f5 100644 --- a/06_uart_chainloader/Makefile +++ b/06_uart_chainloader/Makefile @@ -6,9 +6,9 @@ include ../common/docker.mk include ../common/format.mk include ../common/operating_system.mk -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Optional, user-provided configuration values -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- # Default to the RPi3. BSP ?= rpi3 @@ -18,9 +18,9 @@ DEV_SERIAL ?= /dev/ttyUSB0 -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## BSP-specific configuration values -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- QEMU_MISSING_STRING = "This board is not yet supported for QEMU." ifeq ($(BSP),rpi3) @@ -54,9 +54,9 @@ export LD_SCRIPT_PATH -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Targets and Prerequisites -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- KERNEL_MANIFEST = Cargo.toml KERNEL_LINKER_SCRIPT = kernel.ld LAST_BUILD_CONFIG = target/$(BSP).build_config @@ -68,9 +68,9 @@ KERNEL_ELF_DEPS = $(filter-out %: ,$(file < $(KERNEL_ELF).d)) $(KERNEL_MANIFEST) -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Command building blocks -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- RUSTFLAGS = $(RUSTC_MISC_ARGS) \ -C link-arg=--library-path=$(LD_SCRIPT_PATH) \ -C link-arg=--script=$(KERNEL_LINKER_SCRIPT) @@ -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 @@ -117,31 +117,31 @@ endif -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Targets -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- .PHONY: all doc qemu chainboot clippy clean readelf objdump nm check 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,18 +212,18 @@ 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 -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Testing targets -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- .PHONY: test test_boot ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. @@ -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 c0df6c13..a60c5cb5 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) @@ -211,16 +211,16 @@ diff -uNr 05_drivers_gpio_uart/Makefile 06_uart_chainloader/Makefile @@ -118,7 +120,7 @@ - ##-------------------------------------------------------------------------------------------------- + ## -------------------------------------------------------------------------------------------------- ## Targets - ##-------------------------------------------------------------------------------------------------- + ## -------------------------------------------------------------------------------------------------- -.PHONY: all doc qemu miniterm clippy clean readelf objdump nm check +.PHONY: all doc qemu chainboot clippy clean readelf objdump nm check all: $(KERNEL_BIN) @@ -160,7 +162,7 @@ - ##------------------------------------------------------------------------------ + ## ------------------------------------------------------------------------------ ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. -qemu: @@ -238,19 +238,19 @@ diff -uNr 05_drivers_gpio_uart/Makefile 06_uart_chainloader/Makefile + 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) @@ -647,9 +647,9 @@ diff -uNr 05_drivers_gpio_uart/tests/chainboot_test.rb 06_uart_chainloader/tests + end +end + -+##-------------------------------------------------------------------------------------------------- ++## -------------------------------------------------------------------------------------------------- +## Execution starts here -+##-------------------------------------------------------------------------------------------------- ++## -------------------------------------------------------------------------------------------------- +payload_path = ARGV.pop +qemu_cmd = ARGV.join(' ') + diff --git a/06_uart_chainloader/tests/chainboot_test.rb b/06_uart_chainloader/tests/chainboot_test.rb index af55bd6a..436f5e24 100644 --- a/06_uart_chainloader/tests/chainboot_test.rb +++ b/06_uart_chainloader/tests/chainboot_test.rb @@ -69,9 +69,9 @@ class ChainbootTest < BootTest end end -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Execution starts here -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- payload_path = ARGV.pop qemu_cmd = ARGV.join(' ') diff --git a/07_timestamps/Makefile b/07_timestamps/Makefile index b13f0dfb..40d7b259 100644 --- a/07_timestamps/Makefile +++ b/07_timestamps/Makefile @@ -6,9 +6,9 @@ include ../common/docker.mk include ../common/format.mk include ../common/operating_system.mk -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Optional, user-provided configuration values -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- # Default to the RPi3. BSP ?= rpi3 @@ -18,9 +18,9 @@ DEV_SERIAL ?= /dev/ttyUSB0 -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## BSP-specific configuration values -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- QEMU_MISSING_STRING = "This board is not yet supported for QEMU." ifeq ($(BSP),rpi3) @@ -52,9 +52,9 @@ export LD_SCRIPT_PATH -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Targets and Prerequisites -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- KERNEL_MANIFEST = Cargo.toml KERNEL_LINKER_SCRIPT = kernel.ld LAST_BUILD_CONFIG = target/$(BSP).build_config @@ -66,9 +66,9 @@ KERNEL_ELF_DEPS = $(filter-out %: ,$(file < $(KERNEL_ELF).d)) $(KERNEL_MANIFEST) -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Command building blocks -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- RUSTFLAGS = $(RUSTC_MISC_ARGS) \ -C link-arg=--library-path=$(LD_SCRIPT_PATH) \ -C link-arg=--script=$(KERNEL_LINKER_SCRIPT) @@ -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 @@ -115,31 +115,31 @@ endif -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Targets -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- .PHONY: all doc qemu chainboot clippy clean readelf objdump nm check 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,18 +206,18 @@ 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 -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Testing targets -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- .PHONY: test test_boot ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. @@ -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 af44e8cc..98427725 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) \ @@ -961,9 +961,9 @@ diff -uNr 06_uart_chainloader/tests/chainboot_test.rb 07_timestamps/tests/chainb - end -end - --##-------------------------------------------------------------------------------------------------- +-## -------------------------------------------------------------------------------------------------- -## Execution starts here --##-------------------------------------------------------------------------------------------------- +-## -------------------------------------------------------------------------------------------------- -payload_path = ARGV.pop -qemu_cmd = ARGV.join(' ') - diff --git a/08_hw_debug_JTAG/Makefile b/08_hw_debug_JTAG/Makefile index 9549f092..cc233afd 100644 --- a/08_hw_debug_JTAG/Makefile +++ b/08_hw_debug_JTAG/Makefile @@ -6,9 +6,9 @@ include ../common/docker.mk include ../common/format.mk include ../common/operating_system.mk -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Optional, user-provided configuration values -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- # Default to the RPi3. BSP ?= rpi3 @@ -18,9 +18,9 @@ DEV_SERIAL ?= /dev/ttyUSB0 -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## BSP-specific configuration values -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- QEMU_MISSING_STRING = "This board is not yet supported for QEMU." ifeq ($(BSP),rpi3) @@ -56,9 +56,9 @@ export LD_SCRIPT_PATH -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Targets and Prerequisites -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- KERNEL_MANIFEST = Cargo.toml KERNEL_LINKER_SCRIPT = kernel.ld LAST_BUILD_CONFIG = target/$(BSP).build_config @@ -70,9 +70,9 @@ KERNEL_ELF_DEPS = $(filter-out %: ,$(file < $(KERNEL_ELF).d)) $(KERNEL_MANIFEST) -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Command building blocks -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- RUSTFLAGS = $(RUSTC_MISC_ARGS) \ -C link-arg=--library-path=$(LD_SCRIPT_PATH) \ -C link-arg=--script=$(KERNEL_LINKER_SCRIPT) @@ -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 @@ -126,31 +126,31 @@ endif -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Targets -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- .PHONY: all doc qemu chainboot clippy clean readelf objdump nm check 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,36 +217,36 @@ 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 -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Debugging targets -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- .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) @@ -255,9 +255,9 @@ gdb gdb-opt0: $(KERNEL_ELF) -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Testing targets -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- .PHONY: test test_boot ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. @@ -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 14928253..679496f4 100644 --- a/08_hw_debug_JTAG/README.md +++ b/08_hw_debug_JTAG/README.md @@ -368,27 +368,27 @@ diff -uNr 07_timestamps/Makefile 08_hw_debug_JTAG/Makefile -+##-------------------------------------------------------------------------------------------------- ++## -------------------------------------------------------------------------------------------------- +## Debugging targets -+##-------------------------------------------------------------------------------------------------- ++## -------------------------------------------------------------------------------------------------- +.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) @@ -397,9 +397,9 @@ diff -uNr 07_timestamps/Makefile 08_hw_debug_JTAG/Makefile + + + - ##-------------------------------------------------------------------------------------------------- + ## -------------------------------------------------------------------------------------------------- ## Testing targets - ##-------------------------------------------------------------------------------------------------- + ## -------------------------------------------------------------------------------------------------- diff -uNr 07_timestamps/src/bsp/raspberrypi/driver.rs 08_hw_debug_JTAG/src/bsp/raspberrypi/driver.rs --- 07_timestamps/src/bsp/raspberrypi/driver.rs diff --git a/09_privilege_level/Makefile b/09_privilege_level/Makefile index 9549f092..cc233afd 100644 --- a/09_privilege_level/Makefile +++ b/09_privilege_level/Makefile @@ -6,9 +6,9 @@ include ../common/docker.mk include ../common/format.mk include ../common/operating_system.mk -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Optional, user-provided configuration values -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- # Default to the RPi3. BSP ?= rpi3 @@ -18,9 +18,9 @@ DEV_SERIAL ?= /dev/ttyUSB0 -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## BSP-specific configuration values -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- QEMU_MISSING_STRING = "This board is not yet supported for QEMU." ifeq ($(BSP),rpi3) @@ -56,9 +56,9 @@ export LD_SCRIPT_PATH -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Targets and Prerequisites -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- KERNEL_MANIFEST = Cargo.toml KERNEL_LINKER_SCRIPT = kernel.ld LAST_BUILD_CONFIG = target/$(BSP).build_config @@ -70,9 +70,9 @@ KERNEL_ELF_DEPS = $(filter-out %: ,$(file < $(KERNEL_ELF).d)) $(KERNEL_MANIFEST) -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Command building blocks -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- RUSTFLAGS = $(RUSTC_MISC_ARGS) \ -C link-arg=--library-path=$(LD_SCRIPT_PATH) \ -C link-arg=--script=$(KERNEL_LINKER_SCRIPT) @@ -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 @@ -126,31 +126,31 @@ endif -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Targets -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- .PHONY: all doc qemu chainboot clippy clean readelf objdump nm check 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,36 +217,36 @@ 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 -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Debugging targets -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- .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) @@ -255,9 +255,9 @@ gdb gdb-opt0: $(KERNEL_ELF) -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Testing targets -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- .PHONY: test test_boot ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. @@ -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 9549f092..cc233afd 100644 --- a/10_virtual_mem_part1_identity_mapping/Makefile +++ b/10_virtual_mem_part1_identity_mapping/Makefile @@ -6,9 +6,9 @@ include ../common/docker.mk include ../common/format.mk include ../common/operating_system.mk -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Optional, user-provided configuration values -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- # Default to the RPi3. BSP ?= rpi3 @@ -18,9 +18,9 @@ DEV_SERIAL ?= /dev/ttyUSB0 -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## BSP-specific configuration values -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- QEMU_MISSING_STRING = "This board is not yet supported for QEMU." ifeq ($(BSP),rpi3) @@ -56,9 +56,9 @@ export LD_SCRIPT_PATH -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Targets and Prerequisites -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- KERNEL_MANIFEST = Cargo.toml KERNEL_LINKER_SCRIPT = kernel.ld LAST_BUILD_CONFIG = target/$(BSP).build_config @@ -70,9 +70,9 @@ KERNEL_ELF_DEPS = $(filter-out %: ,$(file < $(KERNEL_ELF).d)) $(KERNEL_MANIFEST) -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Command building blocks -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- RUSTFLAGS = $(RUSTC_MISC_ARGS) \ -C link-arg=--library-path=$(LD_SCRIPT_PATH) \ -C link-arg=--script=$(KERNEL_LINKER_SCRIPT) @@ -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 @@ -126,31 +126,31 @@ endif -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Targets -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- .PHONY: all doc qemu chainboot clippy clean readelf objdump nm check 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,36 +217,36 @@ 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 -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Debugging targets -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- .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) @@ -255,9 +255,9 @@ gdb gdb-opt0: $(KERNEL_ELF) -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Testing targets -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- .PHONY: test test_boot ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. @@ -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 9549f092..cc233afd 100644 --- a/11_exceptions_part1_groundwork/Makefile +++ b/11_exceptions_part1_groundwork/Makefile @@ -6,9 +6,9 @@ include ../common/docker.mk include ../common/format.mk include ../common/operating_system.mk -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Optional, user-provided configuration values -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- # Default to the RPi3. BSP ?= rpi3 @@ -18,9 +18,9 @@ DEV_SERIAL ?= /dev/ttyUSB0 -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## BSP-specific configuration values -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- QEMU_MISSING_STRING = "This board is not yet supported for QEMU." ifeq ($(BSP),rpi3) @@ -56,9 +56,9 @@ export LD_SCRIPT_PATH -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Targets and Prerequisites -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- KERNEL_MANIFEST = Cargo.toml KERNEL_LINKER_SCRIPT = kernel.ld LAST_BUILD_CONFIG = target/$(BSP).build_config @@ -70,9 +70,9 @@ KERNEL_ELF_DEPS = $(filter-out %: ,$(file < $(KERNEL_ELF).d)) $(KERNEL_MANIFEST) -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Command building blocks -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- RUSTFLAGS = $(RUSTC_MISC_ARGS) \ -C link-arg=--library-path=$(LD_SCRIPT_PATH) \ -C link-arg=--script=$(KERNEL_LINKER_SCRIPT) @@ -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 @@ -126,31 +126,31 @@ endif -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Targets -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- .PHONY: all doc qemu chainboot clippy clean readelf objdump nm check 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,36 +217,36 @@ 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 -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Debugging targets -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- .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) @@ -255,9 +255,9 @@ gdb gdb-opt0: $(KERNEL_ELF) -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Testing targets -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- .PHONY: test test_boot ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. @@ -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 4e2efeff..a1e7c4f7 100644 --- a/12_integrated_testing/Makefile +++ b/12_integrated_testing/Makefile @@ -6,9 +6,9 @@ include ../common/docker.mk include ../common/format.mk include ../common/operating_system.mk -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Optional, user-provided configuration values -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- # Default to the RPi3. BSP ?= rpi3 @@ -25,9 +25,9 @@ endif -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## BSP-specific configuration values -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- QEMU_MISSING_STRING = "This board is not yet supported for QEMU." ifeq ($(BSP),rpi3) @@ -65,9 +65,9 @@ export LD_SCRIPT_PATH -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Targets and Prerequisites -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- KERNEL_MANIFEST = kernel/Cargo.toml KERNEL_LINKER_SCRIPT = kernel.ld LAST_BUILD_CONFIG = target/$(BSP).build_config @@ -79,9 +79,9 @@ KERNEL_ELF_DEPS = $(filter-out %: ,$(file < $(KERNEL_ELF).d)) $(KERNEL_MANIFEST) -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Command building blocks -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- RUSTFLAGS = $(RUSTC_MISC_ARGS) \ -C link-arg=--library-path=$(LD_SCRIPT_PATH) \ -C link-arg=--script=$(KERNEL_LINKER_SCRIPT) @@ -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 @@ -136,31 +136,31 @@ endif -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Targets -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- .PHONY: all doc qemu chainboot clippy clean readelf objdump nm check 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,36 +229,36 @@ 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 -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Debugging targets -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- .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 @@ gdb gdb-opt0: $(KERNEL_ELF) -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Testing targets -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- .PHONY: test test_boot test_unit test_integration test_unit test_integration: FEATURES += --features test_build @@ -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 ae68d269..634727fd 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/12_integrated_testing/kernel/tests/00_console_sanity.rb b/12_integrated_testing/kernel/tests/00_console_sanity.rb index 1a516c19..c8d9167b 100644 --- a/12_integrated_testing/kernel/tests/00_console_sanity.rb +++ b/12_integrated_testing/kernel/tests/00_console_sanity.rb @@ -40,9 +40,9 @@ class RxStatisticsTest < SubtestBase end end -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Test registration -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- def subtest_collection [TxRxHandshakeTest.new, TxStatisticsTest.new, RxStatisticsTest.new] end diff --git a/12_integrated_testing/kernel/tests/03_exception_restore_sanity.rb b/12_integrated_testing/kernel/tests/03_exception_restore_sanity.rb index 5f18cbdd..136e4392 100644 --- a/12_integrated_testing/kernel/tests/03_exception_restore_sanity.rb +++ b/12_integrated_testing/kernel/tests/03_exception_restore_sanity.rb @@ -17,9 +17,9 @@ class ExceptionRestoreTest < SubtestBase end end -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Test registration -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- def subtest_collection [ExceptionRestoreTest.new] end diff --git a/13_exceptions_part2_peripheral_IRQs/Makefile b/13_exceptions_part2_peripheral_IRQs/Makefile index 4e2efeff..a1e7c4f7 100644 --- a/13_exceptions_part2_peripheral_IRQs/Makefile +++ b/13_exceptions_part2_peripheral_IRQs/Makefile @@ -6,9 +6,9 @@ include ../common/docker.mk include ../common/format.mk include ../common/operating_system.mk -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Optional, user-provided configuration values -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- # Default to the RPi3. BSP ?= rpi3 @@ -25,9 +25,9 @@ endif -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## BSP-specific configuration values -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- QEMU_MISSING_STRING = "This board is not yet supported for QEMU." ifeq ($(BSP),rpi3) @@ -65,9 +65,9 @@ export LD_SCRIPT_PATH -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Targets and Prerequisites -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- KERNEL_MANIFEST = kernel/Cargo.toml KERNEL_LINKER_SCRIPT = kernel.ld LAST_BUILD_CONFIG = target/$(BSP).build_config @@ -79,9 +79,9 @@ KERNEL_ELF_DEPS = $(filter-out %: ,$(file < $(KERNEL_ELF).d)) $(KERNEL_MANIFEST) -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Command building blocks -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- RUSTFLAGS = $(RUSTC_MISC_ARGS) \ -C link-arg=--library-path=$(LD_SCRIPT_PATH) \ -C link-arg=--script=$(KERNEL_LINKER_SCRIPT) @@ -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 @@ -136,31 +136,31 @@ endif -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Targets -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- .PHONY: all doc qemu chainboot clippy clean readelf objdump nm check 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,36 +229,36 @@ 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 -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Debugging targets -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- .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 @@ gdb gdb-opt0: $(KERNEL_ELF) -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Testing targets -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- .PHONY: test test_boot test_unit test_integration test_unit test_integration: FEATURES += --features test_build @@ -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/13_exceptions_part2_peripheral_IRQs/kernel/tests/00_console_sanity.rb b/13_exceptions_part2_peripheral_IRQs/kernel/tests/00_console_sanity.rb index 1a516c19..c8d9167b 100644 --- a/13_exceptions_part2_peripheral_IRQs/kernel/tests/00_console_sanity.rb +++ b/13_exceptions_part2_peripheral_IRQs/kernel/tests/00_console_sanity.rb @@ -40,9 +40,9 @@ class RxStatisticsTest < SubtestBase end end -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Test registration -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- def subtest_collection [TxRxHandshakeTest.new, TxStatisticsTest.new, RxStatisticsTest.new] end diff --git a/13_exceptions_part2_peripheral_IRQs/kernel/tests/03_exception_restore_sanity.rb b/13_exceptions_part2_peripheral_IRQs/kernel/tests/03_exception_restore_sanity.rb index 5f18cbdd..136e4392 100644 --- a/13_exceptions_part2_peripheral_IRQs/kernel/tests/03_exception_restore_sanity.rb +++ b/13_exceptions_part2_peripheral_IRQs/kernel/tests/03_exception_restore_sanity.rb @@ -17,9 +17,9 @@ class ExceptionRestoreTest < SubtestBase end end -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Test registration -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- def subtest_collection [ExceptionRestoreTest.new] end diff --git a/14_virtual_mem_part2_mmio_remap/Makefile b/14_virtual_mem_part2_mmio_remap/Makefile index 4e2efeff..a1e7c4f7 100644 --- a/14_virtual_mem_part2_mmio_remap/Makefile +++ b/14_virtual_mem_part2_mmio_remap/Makefile @@ -6,9 +6,9 @@ include ../common/docker.mk include ../common/format.mk include ../common/operating_system.mk -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Optional, user-provided configuration values -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- # Default to the RPi3. BSP ?= rpi3 @@ -25,9 +25,9 @@ endif -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## BSP-specific configuration values -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- QEMU_MISSING_STRING = "This board is not yet supported for QEMU." ifeq ($(BSP),rpi3) @@ -65,9 +65,9 @@ export LD_SCRIPT_PATH -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Targets and Prerequisites -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- KERNEL_MANIFEST = kernel/Cargo.toml KERNEL_LINKER_SCRIPT = kernel.ld LAST_BUILD_CONFIG = target/$(BSP).build_config @@ -79,9 +79,9 @@ KERNEL_ELF_DEPS = $(filter-out %: ,$(file < $(KERNEL_ELF).d)) $(KERNEL_MANIFEST) -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Command building blocks -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- RUSTFLAGS = $(RUSTC_MISC_ARGS) \ -C link-arg=--library-path=$(LD_SCRIPT_PATH) \ -C link-arg=--script=$(KERNEL_LINKER_SCRIPT) @@ -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 @@ -136,31 +136,31 @@ endif -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Targets -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- .PHONY: all doc qemu chainboot clippy clean readelf objdump nm check 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,36 +229,36 @@ 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 -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Debugging targets -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- .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 @@ gdb gdb-opt0: $(KERNEL_ELF) -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Testing targets -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- .PHONY: test test_boot test_unit test_integration test_unit test_integration: FEATURES += --features test_build @@ -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/kernel/tests/00_console_sanity.rb b/14_virtual_mem_part2_mmio_remap/kernel/tests/00_console_sanity.rb index 1a516c19..c8d9167b 100644 --- a/14_virtual_mem_part2_mmio_remap/kernel/tests/00_console_sanity.rb +++ b/14_virtual_mem_part2_mmio_remap/kernel/tests/00_console_sanity.rb @@ -40,9 +40,9 @@ class RxStatisticsTest < SubtestBase end end -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Test registration -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- def subtest_collection [TxRxHandshakeTest.new, TxStatisticsTest.new, RxStatisticsTest.new] end diff --git a/14_virtual_mem_part2_mmio_remap/kernel/tests/03_exception_restore_sanity.rb b/14_virtual_mem_part2_mmio_remap/kernel/tests/03_exception_restore_sanity.rb index 5f18cbdd..136e4392 100644 --- a/14_virtual_mem_part2_mmio_remap/kernel/tests/03_exception_restore_sanity.rb +++ b/14_virtual_mem_part2_mmio_remap/kernel/tests/03_exception_restore_sanity.rb @@ -17,9 +17,9 @@ class ExceptionRestoreTest < SubtestBase end end -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Test registration -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- def subtest_collection [ExceptionRestoreTest.new] end diff --git a/15_virtual_mem_part3_precomputed_tables/Makefile b/15_virtual_mem_part3_precomputed_tables/Makefile index bc23270d..fc21c7be 100644 --- a/15_virtual_mem_part3_precomputed_tables/Makefile +++ b/15_virtual_mem_part3_precomputed_tables/Makefile @@ -6,9 +6,9 @@ include ../common/docker.mk include ../common/format.mk include ../common/operating_system.mk -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Optional, user-provided configuration values -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- # Default to the RPi3. BSP ?= rpi3 @@ -25,9 +25,9 @@ endif -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## BSP-specific configuration values -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- QEMU_MISSING_STRING = "This board is not yet supported for QEMU." ifeq ($(BSP),rpi3) @@ -65,9 +65,9 @@ export LD_SCRIPT_PATH -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Targets and Prerequisites -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- KERNEL_MANIFEST = kernel/Cargo.toml KERNEL_LINKER_SCRIPT = kernel.ld LAST_BUILD_CONFIG = target/$(BSP).build_config @@ -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 @@ -89,9 +89,9 @@ KERNEL_ELF = $(KERNEL_ELF_TTABLES) -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Command building blocks -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- RUSTFLAGS = $(RUSTC_MISC_ARGS) \ -C link-arg=--library-path=$(LD_SCRIPT_PATH) \ -C link-arg=--script=$(KERNEL_LINKER_SCRIPT) @@ -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 @@ -147,39 +147,39 @@ endif -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Targets -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- .PHONY: all doc qemu chainboot clippy clean readelf objdump nm check 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,36 +248,36 @@ 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 -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Debugging targets -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- .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) @@ -286,9 +286,9 @@ gdb gdb-opt0: $(KERNEL_ELF) -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Testing targets -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- .PHONY: test test_boot test_unit test_integration test_unit test_integration: FEATURES += --features test_build @@ -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 883ad371..81bff257 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) @@ -637,7 +637,7 @@ def kernel_map_binary mapping_descriptors.each do |i| print 'Generating'.rjust(12).green.bold print ' ' - puts i.to_s + puts i TRANSLATION_TABLES.map_at(i.virt_region, i.phys_region, i.attributes) end @@ -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") @@ -2444,7 +2444,7 @@ diff -uNr 14_virtual_mem_part2_mmio_remap/tools/translation_table_tool/generic.r + mapping_descriptors.each do |i| + print 'Generating'.rjust(12).green.bold + print ' ' -+ puts i.to_s ++ puts i + + TRANSLATION_TABLES.map_at(i.virt_region, i.phys_region, i.attributes) + end diff --git a/15_virtual_mem_part3_precomputed_tables/kernel/Cargo.toml b/15_virtual_mem_part3_precomputed_tables/kernel/Cargo.toml index 73b6feef..43126486 100644 --- a/15_virtual_mem_part3_precomputed_tables/kernel/Cargo.toml +++ b/15_virtual_mem_part3_precomputed_tables/kernel/Cargo.toml @@ -10,9 +10,9 @@ bsp_rpi3 = ["tock-registers"] bsp_rpi4 = ["tock-registers"] test_build = ["qemu-exit"] -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Dependencies -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- [dependencies] test-types = { path = "../libraries/test-types" } @@ -25,9 +25,9 @@ qemu-exit = { version = "3.x.x", optional = true } [target.'cfg(target_arch = "aarch64")'.dependencies] aarch64-cpu = { version = "9.x.x" } -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Testing -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- [dev-dependencies] test-macros = { path = "../libraries/test-macros" } diff --git a/15_virtual_mem_part3_precomputed_tables/kernel/tests/00_console_sanity.rb b/15_virtual_mem_part3_precomputed_tables/kernel/tests/00_console_sanity.rb index 1a516c19..c8d9167b 100644 --- a/15_virtual_mem_part3_precomputed_tables/kernel/tests/00_console_sanity.rb +++ b/15_virtual_mem_part3_precomputed_tables/kernel/tests/00_console_sanity.rb @@ -40,9 +40,9 @@ class RxStatisticsTest < SubtestBase end end -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Test registration -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- def subtest_collection [TxRxHandshakeTest.new, TxStatisticsTest.new, RxStatisticsTest.new] end diff --git a/15_virtual_mem_part3_precomputed_tables/kernel/tests/03_exception_restore_sanity.rb b/15_virtual_mem_part3_precomputed_tables/kernel/tests/03_exception_restore_sanity.rb index 5f18cbdd..136e4392 100644 --- a/15_virtual_mem_part3_precomputed_tables/kernel/tests/03_exception_restore_sanity.rb +++ b/15_virtual_mem_part3_precomputed_tables/kernel/tests/03_exception_restore_sanity.rb @@ -17,9 +17,9 @@ class ExceptionRestoreTest < SubtestBase end end -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Test registration -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- def subtest_collection [ExceptionRestoreTest.new] end diff --git a/15_virtual_mem_part3_precomputed_tables/tools/translation_table_tool/generic.rb b/15_virtual_mem_part3_precomputed_tables/tools/translation_table_tool/generic.rb index 4a00ca00..743840e0 100644 --- a/15_virtual_mem_part3_precomputed_tables/tools/translation_table_tool/generic.rb +++ b/15_virtual_mem_part3_precomputed_tables/tools/translation_table_tool/generic.rb @@ -151,7 +151,7 @@ def kernel_map_binary mapping_descriptors.each do |i| print 'Generating'.rjust(12).green.bold print ' ' - puts i.to_s + puts i TRANSLATION_TABLES.map_at(i.virt_region, i.phys_region, i.attributes) end diff --git a/16_virtual_mem_part4_higher_half_kernel/Makefile b/16_virtual_mem_part4_higher_half_kernel/Makefile index bc23270d..fc21c7be 100644 --- a/16_virtual_mem_part4_higher_half_kernel/Makefile +++ b/16_virtual_mem_part4_higher_half_kernel/Makefile @@ -6,9 +6,9 @@ include ../common/docker.mk include ../common/format.mk include ../common/operating_system.mk -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Optional, user-provided configuration values -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- # Default to the RPi3. BSP ?= rpi3 @@ -25,9 +25,9 @@ endif -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## BSP-specific configuration values -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- QEMU_MISSING_STRING = "This board is not yet supported for QEMU." ifeq ($(BSP),rpi3) @@ -65,9 +65,9 @@ export LD_SCRIPT_PATH -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Targets and Prerequisites -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- KERNEL_MANIFEST = kernel/Cargo.toml KERNEL_LINKER_SCRIPT = kernel.ld LAST_BUILD_CONFIG = target/$(BSP).build_config @@ -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 @@ -89,9 +89,9 @@ KERNEL_ELF = $(KERNEL_ELF_TTABLES) -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Command building blocks -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- RUSTFLAGS = $(RUSTC_MISC_ARGS) \ -C link-arg=--library-path=$(LD_SCRIPT_PATH) \ -C link-arg=--script=$(KERNEL_LINKER_SCRIPT) @@ -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 @@ -147,39 +147,39 @@ endif -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Targets -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- .PHONY: all doc qemu chainboot clippy clean readelf objdump nm check 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,36 +248,36 @@ 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 -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Debugging targets -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- .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) @@ -286,9 +286,9 @@ gdb gdb-opt0: $(KERNEL_ELF) -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Testing targets -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- .PHONY: test test_boot test_unit test_integration test_unit test_integration: FEATURES += --features test_build @@ -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/16_virtual_mem_part4_higher_half_kernel/kernel/tests/00_console_sanity.rb b/16_virtual_mem_part4_higher_half_kernel/kernel/tests/00_console_sanity.rb index 1a516c19..c8d9167b 100644 --- a/16_virtual_mem_part4_higher_half_kernel/kernel/tests/00_console_sanity.rb +++ b/16_virtual_mem_part4_higher_half_kernel/kernel/tests/00_console_sanity.rb @@ -40,9 +40,9 @@ class RxStatisticsTest < SubtestBase end end -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Test registration -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- def subtest_collection [TxRxHandshakeTest.new, TxStatisticsTest.new, RxStatisticsTest.new] end diff --git a/16_virtual_mem_part4_higher_half_kernel/kernel/tests/03_exception_restore_sanity.rb b/16_virtual_mem_part4_higher_half_kernel/kernel/tests/03_exception_restore_sanity.rb index 5f18cbdd..136e4392 100644 --- a/16_virtual_mem_part4_higher_half_kernel/kernel/tests/03_exception_restore_sanity.rb +++ b/16_virtual_mem_part4_higher_half_kernel/kernel/tests/03_exception_restore_sanity.rb @@ -17,9 +17,9 @@ class ExceptionRestoreTest < SubtestBase end end -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Test registration -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- def subtest_collection [ExceptionRestoreTest.new] end diff --git a/16_virtual_mem_part4_higher_half_kernel/tools/translation_table_tool/generic.rb b/16_virtual_mem_part4_higher_half_kernel/tools/translation_table_tool/generic.rb index 4a00ca00..743840e0 100644 --- a/16_virtual_mem_part4_higher_half_kernel/tools/translation_table_tool/generic.rb +++ b/16_virtual_mem_part4_higher_half_kernel/tools/translation_table_tool/generic.rb @@ -151,7 +151,7 @@ def kernel_map_binary mapping_descriptors.each do |i| print 'Generating'.rjust(12).green.bold print ' ' - puts i.to_s + puts i TRANSLATION_TABLES.map_at(i.virt_region, i.phys_region, i.attributes) end diff --git a/17_kernel_symbols/Makefile b/17_kernel_symbols/Makefile index 3c33cd66..dc625f27 100644 --- a/17_kernel_symbols/Makefile +++ b/17_kernel_symbols/Makefile @@ -6,9 +6,9 @@ include ../common/docker.mk include ../common/format.mk include ../common/operating_system.mk -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Optional, user-provided configuration values -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- # Default to the RPi3. BSP ?= rpi3 @@ -25,9 +25,9 @@ endif -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## BSP-specific configuration values -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- QEMU_MISSING_STRING = "This board is not yet supported for QEMU." ifeq ($(BSP),rpi3) @@ -65,9 +65,9 @@ export LD_SCRIPT_PATH -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Targets and Prerequisites -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- KERNEL_MANIFEST = kernel/Cargo.toml KERNEL_LINKER_SCRIPT = kernel.ld LAST_BUILD_CONFIG = target/$(BSP).build_config @@ -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 @@ -106,9 +106,9 @@ KERNEL_ELF = $(KERNEL_ELF_TTABLES_SYMS) -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Command building blocks -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- RUSTFLAGS = $(RUSTC_MISC_ARGS) \ -C link-arg=--library-path=$(LD_SCRIPT_PATH) \ -C link-arg=--script=$(KERNEL_LINKER_SCRIPT) @@ -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 @@ -164,46 +164,46 @@ endif -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Targets -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- .PHONY: all doc qemu chainboot clippy clean readelf objdump nm check 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,36 +272,36 @@ 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 -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Debugging targets -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- .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) @@ -310,9 +310,9 @@ gdb gdb-opt0: $(KERNEL_ELF) -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Testing targets -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- .PHONY: test test_boot test_unit test_integration test_unit test_integration: FEATURES += --features test_build @@ -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 78962bd8..5dc778ff 100644 --- a/17_kernel_symbols/README.md +++ b/17_kernel_symbols/README.md @@ -465,9 +465,9 @@ diff -uNr 16_virtual_mem_part4_higher_half_kernel/kernel_symbols/Cargo.toml 17_k +default = [] +generated_symbols_available = [] + -+##-------------------------------------------------------------------------------------------------- ++## -------------------------------------------------------------------------------------------------- +## Dependencies -+##-------------------------------------------------------------------------------------------------- ++## -------------------------------------------------------------------------------------------------- + +[dependencies] +debug-symbol-types = { path = "../libraries/debug-symbol-types" } @@ -524,9 +524,9 @@ diff -uNr 16_virtual_mem_part4_higher_half_kernel/kernel_symbols.mk 17_kernel_sy +include ../common/format.mk +include ../common/docker.mk + -+##-------------------------------------------------------------------------------------------------- ++## -------------------------------------------------------------------------------------------------- +## Check for input variables that need be exported by the calling Makefile -+##-------------------------------------------------------------------------------------------------- ++## -------------------------------------------------------------------------------------------------- +ifndef KERNEL_SYMBOLS_TOOL_PATH +$(error KERNEL_SYMBOLS_TOOL_PATH is not set) +endif @@ -545,9 +545,9 @@ diff -uNr 16_virtual_mem_part4_higher_half_kernel/kernel_symbols.mk 17_kernel_sy + + + -+##-------------------------------------------------------------------------------------------------- ++## -------------------------------------------------------------------------------------------------- +## Targets and Prerequisites -+##-------------------------------------------------------------------------------------------------- ++## -------------------------------------------------------------------------------------------------- +KERNEL_SYMBOLS_MANIFEST = kernel_symbols/Cargo.toml +KERNEL_SYMBOLS_LINKER_SCRIPT = kernel_symbols/kernel_symbols.ld + @@ -562,9 +562,9 @@ diff -uNr 16_virtual_mem_part4_higher_half_kernel/kernel_symbols.mk 17_kernel_sy + + + -+##-------------------------------------------------------------------------------------------------- ++## -------------------------------------------------------------------------------------------------- +## Command building blocks -+##-------------------------------------------------------------------------------------------------- ++## -------------------------------------------------------------------------------------------------- +GET_SYMBOLS_SECTION_VIRT_ADDR = $(DOCKER_TOOLS) $(EXEC_SYMBOLS_TOOL) \ + --get_symbols_section_virt_addr $(KERNEL_SYMBOLS_OUTPUT_ELF) + @@ -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). @@ -595,9 +595,9 @@ diff -uNr 16_virtual_mem_part4_higher_half_kernel/kernel_symbols.mk 17_kernel_sy + + + -+##-------------------------------------------------------------------------------------------------- ++## -------------------------------------------------------------------------------------------------- +## Targets -+##-------------------------------------------------------------------------------------------------- ++## -------------------------------------------------------------------------------------------------- +.PHONY: all symbols measure_time_start measure_time_finish + +all: measure_time_start symbols measure_time_finish @@ -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/tests/00_console_sanity.rb b/17_kernel_symbols/kernel/tests/00_console_sanity.rb index 1a516c19..c8d9167b 100644 --- a/17_kernel_symbols/kernel/tests/00_console_sanity.rb +++ b/17_kernel_symbols/kernel/tests/00_console_sanity.rb @@ -40,9 +40,9 @@ class RxStatisticsTest < SubtestBase end end -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Test registration -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- def subtest_collection [TxRxHandshakeTest.new, TxStatisticsTest.new, RxStatisticsTest.new] end diff --git a/17_kernel_symbols/kernel/tests/03_exception_restore_sanity.rb b/17_kernel_symbols/kernel/tests/03_exception_restore_sanity.rb index 5f18cbdd..136e4392 100644 --- a/17_kernel_symbols/kernel/tests/03_exception_restore_sanity.rb +++ b/17_kernel_symbols/kernel/tests/03_exception_restore_sanity.rb @@ -17,9 +17,9 @@ class ExceptionRestoreTest < SubtestBase end end -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Test registration -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- def subtest_collection [ExceptionRestoreTest.new] end diff --git a/17_kernel_symbols/kernel_symbols.mk b/17_kernel_symbols/kernel_symbols.mk index d38b7785..fe05e569 100644 --- a/17_kernel_symbols/kernel_symbols.mk +++ b/17_kernel_symbols/kernel_symbols.mk @@ -5,9 +5,9 @@ include ../common/format.mk include ../common/docker.mk -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Check for input variables that need be exported by the calling Makefile -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ifndef KERNEL_SYMBOLS_TOOL_PATH $(error KERNEL_SYMBOLS_TOOL_PATH is not set) endif @@ -26,9 +26,9 @@ endif -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Targets and Prerequisites -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- KERNEL_SYMBOLS_MANIFEST = kernel_symbols/Cargo.toml KERNEL_SYMBOLS_LINKER_SCRIPT = kernel_symbols/kernel_symbols.ld @@ -43,9 +43,9 @@ export KERNEL_SYMBOLS_DEMANGLED_RS -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Command building blocks -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- GET_SYMBOLS_SECTION_VIRT_ADDR = $(DOCKER_TOOLS) $(EXEC_SYMBOLS_TOOL) \ --get_symbols_section_virt_addr $(KERNEL_SYMBOLS_OUTPUT_ELF) @@ -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). @@ -76,9 +76,9 @@ DOCKER_TOOLS = $(DOCKER_CMD) $(DOCKER_IMAGE) -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Targets -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- .PHONY: all symbols measure_time_start measure_time_finish all: measure_time_start symbols measure_time_finish diff --git a/17_kernel_symbols/tools/translation_table_tool/generic.rb b/17_kernel_symbols/tools/translation_table_tool/generic.rb index 4a00ca00..743840e0 100644 --- a/17_kernel_symbols/tools/translation_table_tool/generic.rb +++ b/17_kernel_symbols/tools/translation_table_tool/generic.rb @@ -151,7 +151,7 @@ def kernel_map_binary mapping_descriptors.each do |i| print 'Generating'.rjust(12).green.bold print ' ' - puts i.to_s + puts i TRANSLATION_TABLES.map_at(i.virt_region, i.phys_region, i.attributes) end diff --git a/18_backtrace/Makefile b/18_backtrace/Makefile index 7edf4edf..1731f85c 100644 --- a/18_backtrace/Makefile +++ b/18_backtrace/Makefile @@ -6,9 +6,9 @@ include ../common/docker.mk include ../common/format.mk include ../common/operating_system.mk -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Optional, user-provided configuration values -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- # Default to the RPi3. BSP ?= rpi3 @@ -25,9 +25,9 @@ endif -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## BSP-specific configuration values -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- QEMU_MISSING_STRING = "This board is not yet supported for QEMU." ifeq ($(BSP),rpi3) @@ -65,9 +65,9 @@ export LD_SCRIPT_PATH -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Targets and Prerequisites -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- KERNEL_MANIFEST = kernel/Cargo.toml KERNEL_LINKER_SCRIPT = kernel.ld LAST_BUILD_CONFIG = target/$(BSP).build_config @@ -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 @@ -106,9 +106,9 @@ KERNEL_ELF = $(KERNEL_ELF_TTABLES_SYMS) -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Command building blocks -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- RUSTFLAGS = $(RUSTC_MISC_ARGS) \ -C link-arg=--library-path=$(LD_SCRIPT_PATH) \ -C link-arg=--script=$(KERNEL_LINKER_SCRIPT) @@ -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 @@ -166,46 +166,46 @@ endif -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Targets -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- .PHONY: all doc qemu chainboot clippy clean readelf objdump nm check 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,36 +274,36 @@ 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 -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Debugging targets -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- .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") @@ -311,9 +311,9 @@ gdb gdb-opt0: $(KERNEL_ELF) -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Testing targets -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- .PHONY: test test_boot test_unit test_integration test_unit test_integration: FEATURES += --features test_build @@ -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 00a156d7..767b1f83 100644 --- a/18_backtrace/README.md +++ b/18_backtrace/README.md @@ -1039,9 +1039,9 @@ diff -uNr 17_kernel_symbols/kernel/tests/05_backtrace_sanity.rb 18_backtrace/ker + end +end + -+##-------------------------------------------------------------------------------------------------- ++## -------------------------------------------------------------------------------------------------- +## Test registration -+##-------------------------------------------------------------------------------------------------- ++## -------------------------------------------------------------------------------------------------- +def subtest_collection + [PanicBacktraceTest.new, BacktraceCorrectnessTest.new] +end @@ -1106,9 +1106,9 @@ diff -uNr 17_kernel_symbols/kernel/tests/06_backtrace_invalid_frame.rb 18_backtr + end +end + -+##-------------------------------------------------------------------------------------------------- ++## -------------------------------------------------------------------------------------------------- +## Test registration -+##-------------------------------------------------------------------------------------------------- ++## -------------------------------------------------------------------------------------------------- +def subtest_collection + [InvalidFramePointerTest.new] +end @@ -1174,9 +1174,9 @@ diff -uNr 17_kernel_symbols/kernel/tests/07_backtrace_invalid_link.rb 18_backtra + end +end + -+##-------------------------------------------------------------------------------------------------- ++## -------------------------------------------------------------------------------------------------- +## Test registration -+##-------------------------------------------------------------------------------------------------- ++## -------------------------------------------------------------------------------------------------- +def subtest_collection + [InvalidLinkTest.new] +end @@ -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/tests/00_console_sanity.rb b/18_backtrace/kernel/tests/00_console_sanity.rb index 1a516c19..c8d9167b 100644 --- a/18_backtrace/kernel/tests/00_console_sanity.rb +++ b/18_backtrace/kernel/tests/00_console_sanity.rb @@ -40,9 +40,9 @@ class RxStatisticsTest < SubtestBase end end -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Test registration -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- def subtest_collection [TxRxHandshakeTest.new, TxStatisticsTest.new, RxStatisticsTest.new] end diff --git a/18_backtrace/kernel/tests/03_exception_restore_sanity.rb b/18_backtrace/kernel/tests/03_exception_restore_sanity.rb index 5f18cbdd..136e4392 100644 --- a/18_backtrace/kernel/tests/03_exception_restore_sanity.rb +++ b/18_backtrace/kernel/tests/03_exception_restore_sanity.rb @@ -17,9 +17,9 @@ class ExceptionRestoreTest < SubtestBase end end -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Test registration -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- def subtest_collection [ExceptionRestoreTest.new] end diff --git a/18_backtrace/kernel/tests/05_backtrace_sanity.rb b/18_backtrace/kernel/tests/05_backtrace_sanity.rb index cc64346a..057db3f3 100644 --- a/18_backtrace/kernel/tests/05_backtrace_sanity.rb +++ b/18_backtrace/kernel/tests/05_backtrace_sanity.rb @@ -31,9 +31,9 @@ class BacktraceCorrectnessTest < SubtestBase end end -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Test registration -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- def subtest_collection [PanicBacktraceTest.new, BacktraceCorrectnessTest.new] end diff --git a/18_backtrace/kernel/tests/06_backtrace_invalid_frame.rb b/18_backtrace/kernel/tests/06_backtrace_invalid_frame.rb index 2331351c..918a5229 100644 --- a/18_backtrace/kernel/tests/06_backtrace_invalid_frame.rb +++ b/18_backtrace/kernel/tests/06_backtrace_invalid_frame.rb @@ -18,9 +18,9 @@ class InvalidFramePointerTest < SubtestBase end end -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Test registration -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- def subtest_collection [InvalidFramePointerTest.new] end diff --git a/18_backtrace/kernel/tests/07_backtrace_invalid_link.rb b/18_backtrace/kernel/tests/07_backtrace_invalid_link.rb index 9dc3b72a..2a9e6a1b 100644 --- a/18_backtrace/kernel/tests/07_backtrace_invalid_link.rb +++ b/18_backtrace/kernel/tests/07_backtrace_invalid_link.rb @@ -17,9 +17,9 @@ class InvalidLinkTest < SubtestBase end end -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Test registration -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- def subtest_collection [InvalidLinkTest.new] end diff --git a/18_backtrace/kernel_symbols.mk b/18_backtrace/kernel_symbols.mk index d38b7785..fe05e569 100644 --- a/18_backtrace/kernel_symbols.mk +++ b/18_backtrace/kernel_symbols.mk @@ -5,9 +5,9 @@ include ../common/format.mk include ../common/docker.mk -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Check for input variables that need be exported by the calling Makefile -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ifndef KERNEL_SYMBOLS_TOOL_PATH $(error KERNEL_SYMBOLS_TOOL_PATH is not set) endif @@ -26,9 +26,9 @@ endif -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Targets and Prerequisites -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- KERNEL_SYMBOLS_MANIFEST = kernel_symbols/Cargo.toml KERNEL_SYMBOLS_LINKER_SCRIPT = kernel_symbols/kernel_symbols.ld @@ -43,9 +43,9 @@ export KERNEL_SYMBOLS_DEMANGLED_RS -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Command building blocks -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- GET_SYMBOLS_SECTION_VIRT_ADDR = $(DOCKER_TOOLS) $(EXEC_SYMBOLS_TOOL) \ --get_symbols_section_virt_addr $(KERNEL_SYMBOLS_OUTPUT_ELF) @@ -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). @@ -76,9 +76,9 @@ DOCKER_TOOLS = $(DOCKER_CMD) $(DOCKER_IMAGE) -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Targets -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- .PHONY: all symbols measure_time_start measure_time_finish all: measure_time_start symbols measure_time_finish diff --git a/18_backtrace/tools/translation_table_tool/generic.rb b/18_backtrace/tools/translation_table_tool/generic.rb index 7460498f..941e2226 100644 --- a/18_backtrace/tools/translation_table_tool/generic.rb +++ b/18_backtrace/tools/translation_table_tool/generic.rb @@ -161,7 +161,7 @@ def kernel_map_binary mapping_descriptors.each do |i| print 'Generating'.rjust(12).green.bold print ' ' - puts i.to_s + puts i TRANSLATION_TABLES.map_at(i.virt_region, i.phys_region, i.attributes) end diff --git a/19_kernel_heap/Makefile b/19_kernel_heap/Makefile index f9704a44..23c7cfaa 100644 --- a/19_kernel_heap/Makefile +++ b/19_kernel_heap/Makefile @@ -6,9 +6,9 @@ include ../common/docker.mk include ../common/format.mk include ../common/operating_system.mk -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Optional, user-provided configuration values -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- # Default to the RPi3. BSP ?= rpi3 @@ -30,9 +30,9 @@ endif -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## BSP-specific configuration values -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- QEMU_MISSING_STRING = "This board is not yet supported for QEMU." ifeq ($(BSP),rpi3) @@ -70,9 +70,9 @@ export LD_SCRIPT_PATH -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Targets and Prerequisites -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- KERNEL_MANIFEST = kernel/Cargo.toml KERNEL_LINKER_SCRIPT = kernel.ld LAST_BUILD_CONFIG = target/$(BSP)_$(DEBUG_PRINTS).build_config @@ -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 @@ -111,9 +111,9 @@ KERNEL_ELF = $(KERNEL_ELF_TTABLES_SYMS) -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Command building blocks -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- RUSTFLAGS = $(RUSTC_MISC_ARGS) \ -C link-arg=--library-path=$(LD_SCRIPT_PATH) \ -C link-arg=--script=$(KERNEL_LINKER_SCRIPT) @@ -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 @@ -171,46 +171,46 @@ endif -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Targets -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- .PHONY: all doc qemu chainboot clippy clean readelf objdump nm check 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,36 +279,36 @@ 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 -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Debugging targets -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- .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") @@ -316,9 +316,9 @@ gdb gdb-opt0: $(KERNEL_ELF) -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Testing targets -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- .PHONY: test test_boot test_unit test_integration test_unit test_integration: FEATURES += --features test_build @@ -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/README.md b/19_kernel_heap/README.md index eedf82c7..8126a238 100644 --- a/19_kernel_heap/README.md +++ b/19_kernel_heap/README.md @@ -1439,7 +1439,7 @@ diff -uNr 18_backtrace/Makefile 19_kernel_heap/Makefile ifdef TEST TEST_ARG = --test $(TEST) @@ -70,7 +75,7 @@ - ##-------------------------------------------------------------------------------------------------- + ## -------------------------------------------------------------------------------------------------- KERNEL_MANIFEST = kernel/Cargo.toml KERNEL_LINKER_SCRIPT = kernel.ld -LAST_BUILD_CONFIG = target/$(BSP).build_config diff --git a/19_kernel_heap/kernel/tests/00_console_sanity.rb b/19_kernel_heap/kernel/tests/00_console_sanity.rb index 1a516c19..c8d9167b 100644 --- a/19_kernel_heap/kernel/tests/00_console_sanity.rb +++ b/19_kernel_heap/kernel/tests/00_console_sanity.rb @@ -40,9 +40,9 @@ class RxStatisticsTest < SubtestBase end end -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Test registration -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- def subtest_collection [TxRxHandshakeTest.new, TxStatisticsTest.new, RxStatisticsTest.new] end diff --git a/19_kernel_heap/kernel/tests/03_exception_restore_sanity.rb b/19_kernel_heap/kernel/tests/03_exception_restore_sanity.rb index 5f18cbdd..136e4392 100644 --- a/19_kernel_heap/kernel/tests/03_exception_restore_sanity.rb +++ b/19_kernel_heap/kernel/tests/03_exception_restore_sanity.rb @@ -17,9 +17,9 @@ class ExceptionRestoreTest < SubtestBase end end -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Test registration -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- def subtest_collection [ExceptionRestoreTest.new] end diff --git a/19_kernel_heap/kernel/tests/05_backtrace_sanity.rb b/19_kernel_heap/kernel/tests/05_backtrace_sanity.rb index cc64346a..057db3f3 100644 --- a/19_kernel_heap/kernel/tests/05_backtrace_sanity.rb +++ b/19_kernel_heap/kernel/tests/05_backtrace_sanity.rb @@ -31,9 +31,9 @@ class BacktraceCorrectnessTest < SubtestBase end end -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Test registration -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- def subtest_collection [PanicBacktraceTest.new, BacktraceCorrectnessTest.new] end diff --git a/19_kernel_heap/kernel/tests/06_backtrace_invalid_frame.rb b/19_kernel_heap/kernel/tests/06_backtrace_invalid_frame.rb index 2331351c..918a5229 100644 --- a/19_kernel_heap/kernel/tests/06_backtrace_invalid_frame.rb +++ b/19_kernel_heap/kernel/tests/06_backtrace_invalid_frame.rb @@ -18,9 +18,9 @@ class InvalidFramePointerTest < SubtestBase end end -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Test registration -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- def subtest_collection [InvalidFramePointerTest.new] end diff --git a/19_kernel_heap/kernel/tests/07_backtrace_invalid_link.rb b/19_kernel_heap/kernel/tests/07_backtrace_invalid_link.rb index 9dc3b72a..2a9e6a1b 100644 --- a/19_kernel_heap/kernel/tests/07_backtrace_invalid_link.rb +++ b/19_kernel_heap/kernel/tests/07_backtrace_invalid_link.rb @@ -17,9 +17,9 @@ class InvalidLinkTest < SubtestBase end end -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Test registration -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- def subtest_collection [InvalidLinkTest.new] end diff --git a/19_kernel_heap/kernel_symbols.mk b/19_kernel_heap/kernel_symbols.mk index d38b7785..fe05e569 100644 --- a/19_kernel_heap/kernel_symbols.mk +++ b/19_kernel_heap/kernel_symbols.mk @@ -5,9 +5,9 @@ include ../common/format.mk include ../common/docker.mk -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Check for input variables that need be exported by the calling Makefile -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ifndef KERNEL_SYMBOLS_TOOL_PATH $(error KERNEL_SYMBOLS_TOOL_PATH is not set) endif @@ -26,9 +26,9 @@ endif -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Targets and Prerequisites -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- KERNEL_SYMBOLS_MANIFEST = kernel_symbols/Cargo.toml KERNEL_SYMBOLS_LINKER_SCRIPT = kernel_symbols/kernel_symbols.ld @@ -43,9 +43,9 @@ export KERNEL_SYMBOLS_DEMANGLED_RS -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Command building blocks -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- GET_SYMBOLS_SECTION_VIRT_ADDR = $(DOCKER_TOOLS) $(EXEC_SYMBOLS_TOOL) \ --get_symbols_section_virt_addr $(KERNEL_SYMBOLS_OUTPUT_ELF) @@ -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). @@ -76,9 +76,9 @@ DOCKER_TOOLS = $(DOCKER_CMD) $(DOCKER_IMAGE) -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Targets -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- .PHONY: all symbols measure_time_start measure_time_finish all: measure_time_start symbols measure_time_finish diff --git a/19_kernel_heap/tools/translation_table_tool/generic.rb b/19_kernel_heap/tools/translation_table_tool/generic.rb index 7460498f..941e2226 100644 --- a/19_kernel_heap/tools/translation_table_tool/generic.rb +++ b/19_kernel_heap/tools/translation_table_tool/generic.rb @@ -161,7 +161,7 @@ def kernel_map_binary mapping_descriptors.each do |i| print 'Generating'.rjust(12).green.bold print ' ' - puts i.to_s + puts i TRANSLATION_TABLES.map_at(i.virt_region, i.phys_region, i.attributes) end diff --git a/20_timer_callbacks/Makefile b/20_timer_callbacks/Makefile index f9704a44..23c7cfaa 100644 --- a/20_timer_callbacks/Makefile +++ b/20_timer_callbacks/Makefile @@ -6,9 +6,9 @@ include ../common/docker.mk include ../common/format.mk include ../common/operating_system.mk -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Optional, user-provided configuration values -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- # Default to the RPi3. BSP ?= rpi3 @@ -30,9 +30,9 @@ endif -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## BSP-specific configuration values -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- QEMU_MISSING_STRING = "This board is not yet supported for QEMU." ifeq ($(BSP),rpi3) @@ -70,9 +70,9 @@ export LD_SCRIPT_PATH -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Targets and Prerequisites -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- KERNEL_MANIFEST = kernel/Cargo.toml KERNEL_LINKER_SCRIPT = kernel.ld LAST_BUILD_CONFIG = target/$(BSP)_$(DEBUG_PRINTS).build_config @@ -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 @@ -111,9 +111,9 @@ KERNEL_ELF = $(KERNEL_ELF_TTABLES_SYMS) -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Command building blocks -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- RUSTFLAGS = $(RUSTC_MISC_ARGS) \ -C link-arg=--library-path=$(LD_SCRIPT_PATH) \ -C link-arg=--script=$(KERNEL_LINKER_SCRIPT) @@ -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 @@ -171,46 +171,46 @@ endif -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Targets -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- .PHONY: all doc qemu chainboot clippy clean readelf objdump nm check 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,36 +279,36 @@ 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 -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Debugging targets -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- .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") @@ -316,9 +316,9 @@ gdb gdb-opt0: $(KERNEL_ELF) -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Testing targets -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- .PHONY: test test_boot test_unit test_integration test_unit test_integration: FEATURES += --features test_build @@ -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/Cargo.toml b/20_timer_callbacks/kernel/Cargo.toml index 87c9cbb6..ec76d782 100644 --- a/20_timer_callbacks/kernel/Cargo.toml +++ b/20_timer_callbacks/kernel/Cargo.toml @@ -11,9 +11,9 @@ bsp_rpi3 = ["tock-registers"] bsp_rpi4 = ["tock-registers"] test_build = ["qemu-exit"] -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Dependencies -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- [dependencies] test-types = { path = "../libraries/test-types" } @@ -28,9 +28,9 @@ qemu-exit = { version = "3.x.x", optional = true } [target.'cfg(target_arch = "aarch64")'.dependencies] aarch64-cpu = { version = "9.x.x" } -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Testing -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- [dev-dependencies] test-macros = { path = "../libraries/test-macros" } diff --git a/20_timer_callbacks/kernel/tests/00_console_sanity.rb b/20_timer_callbacks/kernel/tests/00_console_sanity.rb index 1a516c19..c8d9167b 100644 --- a/20_timer_callbacks/kernel/tests/00_console_sanity.rb +++ b/20_timer_callbacks/kernel/tests/00_console_sanity.rb @@ -40,9 +40,9 @@ class RxStatisticsTest < SubtestBase end end -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Test registration -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- def subtest_collection [TxRxHandshakeTest.new, TxStatisticsTest.new, RxStatisticsTest.new] end diff --git a/20_timer_callbacks/kernel/tests/03_exception_restore_sanity.rb b/20_timer_callbacks/kernel/tests/03_exception_restore_sanity.rb index 5f18cbdd..136e4392 100644 --- a/20_timer_callbacks/kernel/tests/03_exception_restore_sanity.rb +++ b/20_timer_callbacks/kernel/tests/03_exception_restore_sanity.rb @@ -17,9 +17,9 @@ class ExceptionRestoreTest < SubtestBase end end -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Test registration -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- def subtest_collection [ExceptionRestoreTest.new] end diff --git a/20_timer_callbacks/kernel/tests/05_backtrace_sanity.rb b/20_timer_callbacks/kernel/tests/05_backtrace_sanity.rb index cc64346a..057db3f3 100644 --- a/20_timer_callbacks/kernel/tests/05_backtrace_sanity.rb +++ b/20_timer_callbacks/kernel/tests/05_backtrace_sanity.rb @@ -31,9 +31,9 @@ class BacktraceCorrectnessTest < SubtestBase end end -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Test registration -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- def subtest_collection [PanicBacktraceTest.new, BacktraceCorrectnessTest.new] end diff --git a/20_timer_callbacks/kernel/tests/06_backtrace_invalid_frame.rb b/20_timer_callbacks/kernel/tests/06_backtrace_invalid_frame.rb index 2331351c..918a5229 100644 --- a/20_timer_callbacks/kernel/tests/06_backtrace_invalid_frame.rb +++ b/20_timer_callbacks/kernel/tests/06_backtrace_invalid_frame.rb @@ -18,9 +18,9 @@ class InvalidFramePointerTest < SubtestBase end end -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Test registration -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- def subtest_collection [InvalidFramePointerTest.new] end diff --git a/20_timer_callbacks/kernel/tests/07_backtrace_invalid_link.rb b/20_timer_callbacks/kernel/tests/07_backtrace_invalid_link.rb index 9dc3b72a..2a9e6a1b 100644 --- a/20_timer_callbacks/kernel/tests/07_backtrace_invalid_link.rb +++ b/20_timer_callbacks/kernel/tests/07_backtrace_invalid_link.rb @@ -17,9 +17,9 @@ class InvalidLinkTest < SubtestBase end end -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Test registration -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- def subtest_collection [InvalidLinkTest.new] end diff --git a/20_timer_callbacks/kernel_symbols.mk b/20_timer_callbacks/kernel_symbols.mk index d38b7785..fe05e569 100644 --- a/20_timer_callbacks/kernel_symbols.mk +++ b/20_timer_callbacks/kernel_symbols.mk @@ -5,9 +5,9 @@ include ../common/format.mk include ../common/docker.mk -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Check for input variables that need be exported by the calling Makefile -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ifndef KERNEL_SYMBOLS_TOOL_PATH $(error KERNEL_SYMBOLS_TOOL_PATH is not set) endif @@ -26,9 +26,9 @@ endif -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Targets and Prerequisites -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- KERNEL_SYMBOLS_MANIFEST = kernel_symbols/Cargo.toml KERNEL_SYMBOLS_LINKER_SCRIPT = kernel_symbols/kernel_symbols.ld @@ -43,9 +43,9 @@ export KERNEL_SYMBOLS_DEMANGLED_RS -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Command building blocks -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- GET_SYMBOLS_SECTION_VIRT_ADDR = $(DOCKER_TOOLS) $(EXEC_SYMBOLS_TOOL) \ --get_symbols_section_virt_addr $(KERNEL_SYMBOLS_OUTPUT_ELF) @@ -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). @@ -76,9 +76,9 @@ DOCKER_TOOLS = $(DOCKER_CMD) $(DOCKER_IMAGE) -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Targets -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- .PHONY: all symbols measure_time_start measure_time_finish all: measure_time_start symbols measure_time_finish diff --git a/20_timer_callbacks/tools/translation_table_tool/generic.rb b/20_timer_callbacks/tools/translation_table_tool/generic.rb index 7460498f..941e2226 100644 --- a/20_timer_callbacks/tools/translation_table_tool/generic.rb +++ b/20_timer_callbacks/tools/translation_table_tool/generic.rb @@ -161,7 +161,7 @@ def kernel_map_binary mapping_descriptors.each do |i| print 'Generating'.rjust(12).green.bold print ' ' - puts i.to_s + puts i TRANSLATION_TABLES.map_at(i.virt_region, i.phys_region, i.attributes) end diff --git a/X1_JTAG_boot/Cargo.toml b/X1_JTAG_boot/Cargo.toml index e310c371..e0b0590f 100644 --- a/X1_JTAG_boot/Cargo.toml +++ b/X1_JTAG_boot/Cargo.toml @@ -16,9 +16,9 @@ bsp_rpi4 = ["tock-registers"] name = "kernel" path = "src/main.rs" -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Dependencies -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- [dependencies] diff --git a/X1_JTAG_boot/Makefile b/X1_JTAG_boot/Makefile index b13f0dfb..40d7b259 100644 --- a/X1_JTAG_boot/Makefile +++ b/X1_JTAG_boot/Makefile @@ -6,9 +6,9 @@ include ../common/docker.mk include ../common/format.mk include ../common/operating_system.mk -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Optional, user-provided configuration values -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- # Default to the RPi3. BSP ?= rpi3 @@ -18,9 +18,9 @@ DEV_SERIAL ?= /dev/ttyUSB0 -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## BSP-specific configuration values -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- QEMU_MISSING_STRING = "This board is not yet supported for QEMU." ifeq ($(BSP),rpi3) @@ -52,9 +52,9 @@ export LD_SCRIPT_PATH -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Targets and Prerequisites -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- KERNEL_MANIFEST = Cargo.toml KERNEL_LINKER_SCRIPT = kernel.ld LAST_BUILD_CONFIG = target/$(BSP).build_config @@ -66,9 +66,9 @@ KERNEL_ELF_DEPS = $(filter-out %: ,$(file < $(KERNEL_ELF).d)) $(KERNEL_MANIFEST) -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Command building blocks -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- RUSTFLAGS = $(RUSTC_MISC_ARGS) \ -C link-arg=--library-path=$(LD_SCRIPT_PATH) \ -C link-arg=--script=$(KERNEL_LINKER_SCRIPT) @@ -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 @@ -115,31 +115,31 @@ endif -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Targets -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- .PHONY: all doc qemu chainboot clippy clean readelf objdump nm check 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,18 +206,18 @@ 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 -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Testing targets -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- .PHONY: test test_boot ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. @@ -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/common/serial/minipush.rb b/common/serial/minipush.rb index cc78c801..08c4760d 100755 --- a/common/serial/minipush.rb +++ b/common/serial/minipush.rb @@ -113,9 +113,9 @@ class MiniPush < MiniTerm end end -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Execution starts here -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- if __FILE__ == $PROGRAM_NAME puts puts 'Minipush 1.0'.cyan diff --git a/common/serial/miniterm.rb b/common/serial/miniterm.rb index b0ba8525..b3ffb59a 100755 --- a/common/serial/miniterm.rb +++ b/common/serial/miniterm.rb @@ -126,9 +126,9 @@ class MiniTerm end end -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Execution starts here -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- if __FILE__ == $PROGRAM_NAME puts puts 'Miniterm 1.0'.cyan diff --git a/utils/devtool.rb b/utils/devtool.rb index 70f94d43..cdd37210 100755 --- a/utils/devtool.rb +++ b/utils/devtool.rb @@ -329,9 +329,9 @@ class DevTool end end -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- ## Execution starts here -##-------------------------------------------------------------------------------------------------- +## -------------------------------------------------------------------------------------------------- tool = DevTool.new cmd = ARGV[0] commands = tool.public_methods(false).sort