fix rb file i.to_s and code style

pull/195/head
jameszow 9 months ago
parent 56ced1a575
commit 89ca6cc5f6

@ -23,9 +23,9 @@ def copyright_check(staged_files)
copyright_check_files(staged_files) copyright_check_files(staged_files)
end end
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Execution starts here ## Execution starts here
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
staged_files = `git --no-pager diff --name-only --cached --diff-filter=d`.split(/\n/) staged_files = `git --no-pager diff --name-only --cached --diff-filter=d`.split(/\n/)
root_dir = `git rev-parse --show-toplevel`.strip root_dir = `git rev-parse --show-toplevel`.strip

@ -6,18 +6,18 @@ include ../common/docker.mk
include ../common/format.mk include ../common/format.mk
include ../common/operating_system.mk include ../common/operating_system.mk
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Optional, user-provided configuration values ## Optional, user-provided configuration values
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
# Default to the RPi3. # Default to the RPi3.
BSP ?= rpi3 BSP ?= rpi3
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## BSP-specific configuration values ## BSP-specific configuration values
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
QEMU_MISSING_STRING = "This board is not yet supported for QEMU." QEMU_MISSING_STRING = "This board is not yet supported for QEMU."
ifeq ($(BSP),rpi3) ifeq ($(BSP),rpi3)
@ -49,9 +49,9 @@ export LD_SCRIPT_PATH
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Targets and Prerequisites ## Targets and Prerequisites
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
KERNEL_MANIFEST = Cargo.toml KERNEL_MANIFEST = Cargo.toml
KERNEL_LINKER_SCRIPT = kernel.ld KERNEL_LINKER_SCRIPT = kernel.ld
LAST_BUILD_CONFIG = target/$(BSP).build_config 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 ## Command building blocks
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
RUSTFLAGS = $(RUSTC_MISC_ARGS) \ RUSTFLAGS = $(RUSTC_MISC_ARGS) \
-C link-arg=--library-path=$(LD_SCRIPT_PATH) \ -C link-arg=--library-path=$(LD_SCRIPT_PATH) \
-C link-arg=--script=$(KERNEL_LINKER_SCRIPT) -C link-arg=--script=$(KERNEL_LINKER_SCRIPT)
@ -88,9 +88,9 @@ OBJCOPY_CMD = rust-objcopy \
EXEC_QEMU = $(QEMU_BINARY) -M $(QEMU_MACHINE_TYPE) EXEC_QEMU = $(QEMU_BINARY) -M $(QEMU_MACHINE_TYPE)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Dockerization ## Dockerization
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial
DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i
@ -100,31 +100,31 @@ DOCKER_TOOLS = $(DOCKER_CMD) $(DOCKER_IMAGE)
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Targets ## Targets
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
.PHONY: all doc qemu clippy clean readelf objdump nm check .PHONY: all doc qemu clippy clean readelf objdump nm check
all: $(KERNEL_BIN) all: $(KERNEL_BIN)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Save the configuration as a file, so make understands if it changed. ## Save the configuration as a file, so make understands if it changed.
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
$(LAST_BUILD_CONFIG): $(LAST_BUILD_CONFIG):
@rm -f target/*.build_config @rm -f target/*.build_config
@mkdir -p target @mkdir -p target
@touch $(LAST_BUILD_CONFIG) @touch $(LAST_BUILD_CONFIG)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Compile the kernel ELF ## Compile the kernel ELF
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
$(KERNEL_ELF): $(KERNEL_ELF_DEPS) $(KERNEL_ELF): $(KERNEL_ELF_DEPS)
$(call color_header, "Compiling kernel ELF - $(BSP)") $(call color_header, "Compiling kernel ELF - $(BSP)")
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD) @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Generate the stripped kernel binary ## Generate the stripped kernel binary
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
$(KERNEL_BIN): $(KERNEL_ELF) $(KERNEL_BIN): $(KERNEL_ELF)
$(call color_header, "Generating stripped binary") $(call color_header, "Generating stripped binary")
@$(OBJCOPY_CMD) $(KERNEL_ELF) $(KERNEL_BIN) @$(OBJCOPY_CMD) $(KERNEL_ELF) $(KERNEL_BIN)
@ -133,16 +133,16 @@ $(KERNEL_BIN): $(KERNEL_ELF)
$(call color_progress_prefix, "Size") $(call color_progress_prefix, "Size")
$(call disk_usage_KiB, $(KERNEL_BIN)) $(call disk_usage_KiB, $(KERNEL_BIN))
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Generate the documentation ## Generate the documentation
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
doc: doc:
$(call color_header, "Generating docs") $(call color_header, "Generating docs")
@$(DOC_CMD) --document-private-items --open @$(DOC_CMD) --document-private-items --open
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run the kernel in QEMU ## Run the kernel in QEMU
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board.
qemu: qemu:
@ -155,37 +155,37 @@ qemu: $(KERNEL_BIN)
@$(DOCKER_QEMU) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN) @$(DOCKER_QEMU) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN)
endif endif
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run clippy ## Run clippy
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
clippy: clippy:
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Clean ## Clean
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
clean: clean:
rm -rf target $(KERNEL_BIN) rm -rf target $(KERNEL_BIN)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run readelf ## Run readelf
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
readelf: $(KERNEL_ELF) readelf: $(KERNEL_ELF)
$(call color_header, "Launching readelf") $(call color_header, "Launching readelf")
@$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF) @$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run objdump ## Run objdump
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
objdump: $(KERNEL_ELF) objdump: $(KERNEL_ELF)
$(call color_header, "Launching objdump") $(call color_header, "Launching objdump")
@$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \ @$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \
--section .text \ --section .text \
$(KERNEL_ELF) | rustfilt $(KERNEL_ELF) | rustfilt
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run nm ## Run nm
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
nm: $(KERNEL_ELF) nm: $(KERNEL_ELF)
$(call color_header, "Launching nm") $(call color_header, "Launching nm")
@$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt @$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt

@ -6,18 +6,18 @@ include ../common/docker.mk
include ../common/format.mk include ../common/format.mk
include ../common/operating_system.mk include ../common/operating_system.mk
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Optional, user-provided configuration values ## Optional, user-provided configuration values
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
# Default to the RPi3. # Default to the RPi3.
BSP ?= rpi3 BSP ?= rpi3
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## BSP-specific configuration values ## BSP-specific configuration values
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
QEMU_MISSING_STRING = "This board is not yet supported for QEMU." QEMU_MISSING_STRING = "This board is not yet supported for QEMU."
ifeq ($(BSP),rpi3) ifeq ($(BSP),rpi3)
@ -49,9 +49,9 @@ export LD_SCRIPT_PATH
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Targets and Prerequisites ## Targets and Prerequisites
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
KERNEL_MANIFEST = Cargo.toml KERNEL_MANIFEST = Cargo.toml
KERNEL_LINKER_SCRIPT = kernel.ld KERNEL_LINKER_SCRIPT = kernel.ld
LAST_BUILD_CONFIG = target/$(BSP).build_config 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 ## Command building blocks
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
RUSTFLAGS = $(RUSTC_MISC_ARGS) \ RUSTFLAGS = $(RUSTC_MISC_ARGS) \
-C link-arg=--library-path=$(LD_SCRIPT_PATH) \ -C link-arg=--library-path=$(LD_SCRIPT_PATH) \
-C link-arg=--script=$(KERNEL_LINKER_SCRIPT) -C link-arg=--script=$(KERNEL_LINKER_SCRIPT)
@ -88,9 +88,9 @@ OBJCOPY_CMD = rust-objcopy \
EXEC_QEMU = $(QEMU_BINARY) -M $(QEMU_MACHINE_TYPE) EXEC_QEMU = $(QEMU_BINARY) -M $(QEMU_MACHINE_TYPE)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Dockerization ## Dockerization
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial
DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i
@ -100,31 +100,31 @@ DOCKER_TOOLS = $(DOCKER_CMD) $(DOCKER_IMAGE)
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Targets ## Targets
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
.PHONY: all doc qemu clippy clean readelf objdump nm check .PHONY: all doc qemu clippy clean readelf objdump nm check
all: $(KERNEL_BIN) all: $(KERNEL_BIN)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Save the configuration as a file, so make understands if it changed. ## Save the configuration as a file, so make understands if it changed.
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
$(LAST_BUILD_CONFIG): $(LAST_BUILD_CONFIG):
@rm -f target/*.build_config @rm -f target/*.build_config
@mkdir -p target @mkdir -p target
@touch $(LAST_BUILD_CONFIG) @touch $(LAST_BUILD_CONFIG)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Compile the kernel ELF ## Compile the kernel ELF
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
$(KERNEL_ELF): $(KERNEL_ELF_DEPS) $(KERNEL_ELF): $(KERNEL_ELF_DEPS)
$(call color_header, "Compiling kernel ELF - $(BSP)") $(call color_header, "Compiling kernel ELF - $(BSP)")
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD) @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Generate the stripped kernel binary ## Generate the stripped kernel binary
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
$(KERNEL_BIN): $(KERNEL_ELF) $(KERNEL_BIN): $(KERNEL_ELF)
$(call color_header, "Generating stripped binary") $(call color_header, "Generating stripped binary")
@$(OBJCOPY_CMD) $(KERNEL_ELF) $(KERNEL_BIN) @$(OBJCOPY_CMD) $(KERNEL_ELF) $(KERNEL_BIN)
@ -133,16 +133,16 @@ $(KERNEL_BIN): $(KERNEL_ELF)
$(call color_progress_prefix, "Size") $(call color_progress_prefix, "Size")
$(call disk_usage_KiB, $(KERNEL_BIN)) $(call disk_usage_KiB, $(KERNEL_BIN))
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Generate the documentation ## Generate the documentation
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
doc: doc:
$(call color_header, "Generating docs") $(call color_header, "Generating docs")
@$(DOC_CMD) --document-private-items --open @$(DOC_CMD) --document-private-items --open
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run the kernel in QEMU ## Run the kernel in QEMU
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board.
qemu: qemu:
@ -155,28 +155,28 @@ qemu: $(KERNEL_BIN)
@$(DOCKER_QEMU) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN) @$(DOCKER_QEMU) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN)
endif endif
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run clippy ## Run clippy
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
clippy: clippy:
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Clean ## Clean
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
clean: clean:
rm -rf target $(KERNEL_BIN) rm -rf target $(KERNEL_BIN)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run readelf ## Run readelf
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
readelf: $(KERNEL_ELF) readelf: $(KERNEL_ELF)
$(call color_header, "Launching readelf") $(call color_header, "Launching readelf")
@$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF) @$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run objdump ## Run objdump
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
objdump: $(KERNEL_ELF) objdump: $(KERNEL_ELF)
$(call color_header, "Launching objdump") $(call color_header, "Launching objdump")
@$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \ @$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \
@ -184,9 +184,9 @@ objdump: $(KERNEL_ELF)
--section .rodata \ --section .rodata \
$(KERNEL_ELF) | rustfilt $(KERNEL_ELF) | rustfilt
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run nm ## Run nm
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
nm: $(KERNEL_ELF) nm: $(KERNEL_ELF)
$(call color_header, "Launching nm") $(call color_header, "Launching nm")
@$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt @$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt

@ -41,7 +41,7 @@ diff -uNr 01_wait_forever/Cargo.toml 02_runtime_init/Cargo.toml
edition = "2021" edition = "2021"
@@ -21,3 +21,7 @@ @@ -21,3 +21,7 @@
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
[dependencies] [dependencies]
+ +
@ -59,7 +59,7 @@ diff -uNr 01_wait_forever/Makefile 02_runtime_init/Makefile
+ --section .rodata \ + --section .rodata \
$(KERNEL_ELF) | rustfilt $(KERNEL_ELF) | rustfilt
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
diff -uNr 01_wait_forever/src/_arch/aarch64/cpu/boot.rs 02_runtime_init/src/_arch/aarch64/cpu/boot.rs 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 --- 01_wait_forever/src/_arch/aarch64/cpu/boot.rs

@ -6,18 +6,18 @@ include ../common/docker.mk
include ../common/format.mk include ../common/format.mk
include ../common/operating_system.mk include ../common/operating_system.mk
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Optional, user-provided configuration values ## Optional, user-provided configuration values
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
# Default to the RPi3. # Default to the RPi3.
BSP ?= rpi3 BSP ?= rpi3
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## BSP-specific configuration values ## BSP-specific configuration values
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
QEMU_MISSING_STRING = "This board is not yet supported for QEMU." QEMU_MISSING_STRING = "This board is not yet supported for QEMU."
ifeq ($(BSP),rpi3) ifeq ($(BSP),rpi3)
@ -49,9 +49,9 @@ export LD_SCRIPT_PATH
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Targets and Prerequisites ## Targets and Prerequisites
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
KERNEL_MANIFEST = Cargo.toml KERNEL_MANIFEST = Cargo.toml
KERNEL_LINKER_SCRIPT = kernel.ld KERNEL_LINKER_SCRIPT = kernel.ld
LAST_BUILD_CONFIG = target/$(BSP).build_config 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 ## Command building blocks
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
RUSTFLAGS = $(RUSTC_MISC_ARGS) \ RUSTFLAGS = $(RUSTC_MISC_ARGS) \
-C link-arg=--library-path=$(LD_SCRIPT_PATH) \ -C link-arg=--library-path=$(LD_SCRIPT_PATH) \
-C link-arg=--script=$(KERNEL_LINKER_SCRIPT) -C link-arg=--script=$(KERNEL_LINKER_SCRIPT)
@ -89,9 +89,9 @@ OBJCOPY_CMD = rust-objcopy \
EXEC_QEMU = $(QEMU_BINARY) -M $(QEMU_MACHINE_TYPE) EXEC_QEMU = $(QEMU_BINARY) -M $(QEMU_MACHINE_TYPE)
EXEC_TEST_DISPATCH = ruby ../common/tests/dispatch.rb EXEC_TEST_DISPATCH = ruby ../common/tests/dispatch.rb
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Dockerization ## Dockerization
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial
DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i
DOCKER_ARG_DIR_COMMON = -v $(shell pwd)/../common:/work/common 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 ## Targets
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
.PHONY: all doc qemu clippy clean readelf objdump nm check .PHONY: all doc qemu clippy clean readelf objdump nm check
all: $(KERNEL_BIN) all: $(KERNEL_BIN)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Save the configuration as a file, so make understands if it changed. ## Save the configuration as a file, so make understands if it changed.
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
$(LAST_BUILD_CONFIG): $(LAST_BUILD_CONFIG):
@rm -f target/*.build_config @rm -f target/*.build_config
@mkdir -p target @mkdir -p target
@touch $(LAST_BUILD_CONFIG) @touch $(LAST_BUILD_CONFIG)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Compile the kernel ELF ## Compile the kernel ELF
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
$(KERNEL_ELF): $(KERNEL_ELF_DEPS) $(KERNEL_ELF): $(KERNEL_ELF_DEPS)
$(call color_header, "Compiling kernel ELF - $(BSP)") $(call color_header, "Compiling kernel ELF - $(BSP)")
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD) @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Generate the stripped kernel binary ## Generate the stripped kernel binary
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
$(KERNEL_BIN): $(KERNEL_ELF) $(KERNEL_BIN): $(KERNEL_ELF)
$(call color_header, "Generating stripped binary") $(call color_header, "Generating stripped binary")
@$(OBJCOPY_CMD) $(KERNEL_ELF) $(KERNEL_BIN) @$(OBJCOPY_CMD) $(KERNEL_ELF) $(KERNEL_BIN)
@ -136,16 +136,16 @@ $(KERNEL_BIN): $(KERNEL_ELF)
$(call color_progress_prefix, "Size") $(call color_progress_prefix, "Size")
$(call disk_usage_KiB, $(KERNEL_BIN)) $(call disk_usage_KiB, $(KERNEL_BIN))
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Generate the documentation ## Generate the documentation
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
doc: doc:
$(call color_header, "Generating docs") $(call color_header, "Generating docs")
@$(DOC_CMD) --document-private-items --open @$(DOC_CMD) --document-private-items --open
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run the kernel in QEMU ## Run the kernel in QEMU
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board.
qemu: qemu:
@ -158,28 +158,28 @@ qemu: $(KERNEL_BIN)
@$(DOCKER_QEMU) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN) @$(DOCKER_QEMU) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN)
endif endif
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run clippy ## Run clippy
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
clippy: clippy:
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Clean ## Clean
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
clean: clean:
rm -rf target $(KERNEL_BIN) rm -rf target $(KERNEL_BIN)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run readelf ## Run readelf
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
readelf: $(KERNEL_ELF) readelf: $(KERNEL_ELF)
$(call color_header, "Launching readelf") $(call color_header, "Launching readelf")
@$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF) @$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run objdump ## Run objdump
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
objdump: $(KERNEL_ELF) objdump: $(KERNEL_ELF)
$(call color_header, "Launching objdump") $(call color_header, "Launching objdump")
@$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \ @$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \
@ -187,18 +187,18 @@ objdump: $(KERNEL_ELF)
--section .rodata \ --section .rodata \
$(KERNEL_ELF) | rustfilt $(KERNEL_ELF) | rustfilt
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run nm ## Run nm
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
nm: $(KERNEL_ELF) nm: $(KERNEL_ELF)
$(call color_header, "Launching nm") $(call color_header, "Launching nm")
@$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt @$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Testing targets ## Testing targets
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
.PHONY: test test_boot .PHONY: test test_boot
ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board.
@ -208,9 +208,9 @@ test_boot test:
else # QEMU is supported. else # QEMU is supported.
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run boot test ## Run boot test
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
test_boot: $(KERNEL_BIN) test_boot: $(KERNEL_BIN)
$(call color_header, "Boot test - $(BSP)") $(call color_header, "Boot test - $(BSP)")
@$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN) @$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN)

@ -79,9 +79,9 @@ diff -uNr 02_runtime_init/Makefile 03_hacky_hello_world/Makefile
+EXEC_QEMU = $(QEMU_BINARY) -M $(QEMU_MACHINE_TYPE) +EXEC_QEMU = $(QEMU_BINARY) -M $(QEMU_MACHINE_TYPE)
+EXEC_TEST_DISPATCH = ruby ../common/tests/dispatch.rb +EXEC_TEST_DISPATCH = ruby ../common/tests/dispatch.rb
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Dockerization ## Dockerization
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
-DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial -DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial
-DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i -DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i
+DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial +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 +## Testing targets
+##-------------------------------------------------------------------------------------------------- +## --------------------------------------------------------------------------------------------------
+.PHONY: test test_boot +.PHONY: test test_boot
+ +
+ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. +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. +else # QEMU is supported.
+ +
+##------------------------------------------------------------------------------ +## ------------------------------------------------------------------------------
+## Run boot test +## Run boot test
+##------------------------------------------------------------------------------ +## ------------------------------------------------------------------------------
+test_boot: $(KERNEL_BIN) +test_boot: $(KERNEL_BIN)
+ $(call color_header, "Boot test - $(BSP)") + $(call color_header, "Boot test - $(BSP)")
+ @$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN) + @$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN)

@ -6,18 +6,18 @@ include ../common/docker.mk
include ../common/format.mk include ../common/format.mk
include ../common/operating_system.mk include ../common/operating_system.mk
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Optional, user-provided configuration values ## Optional, user-provided configuration values
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
# Default to the RPi3. # Default to the RPi3.
BSP ?= rpi3 BSP ?= rpi3
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## BSP-specific configuration values ## BSP-specific configuration values
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
QEMU_MISSING_STRING = "This board is not yet supported for QEMU." QEMU_MISSING_STRING = "This board is not yet supported for QEMU."
ifeq ($(BSP),rpi3) ifeq ($(BSP),rpi3)
@ -49,9 +49,9 @@ export LD_SCRIPT_PATH
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Targets and Prerequisites ## Targets and Prerequisites
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
KERNEL_MANIFEST = Cargo.toml KERNEL_MANIFEST = Cargo.toml
KERNEL_LINKER_SCRIPT = kernel.ld KERNEL_LINKER_SCRIPT = kernel.ld
LAST_BUILD_CONFIG = target/$(BSP).build_config 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 ## Command building blocks
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
RUSTFLAGS = $(RUSTC_MISC_ARGS) \ RUSTFLAGS = $(RUSTC_MISC_ARGS) \
-C link-arg=--library-path=$(LD_SCRIPT_PATH) \ -C link-arg=--library-path=$(LD_SCRIPT_PATH) \
-C link-arg=--script=$(KERNEL_LINKER_SCRIPT) -C link-arg=--script=$(KERNEL_LINKER_SCRIPT)
@ -89,9 +89,9 @@ OBJCOPY_CMD = rust-objcopy \
EXEC_QEMU = $(QEMU_BINARY) -M $(QEMU_MACHINE_TYPE) EXEC_QEMU = $(QEMU_BINARY) -M $(QEMU_MACHINE_TYPE)
EXEC_TEST_DISPATCH = ruby ../common/tests/dispatch.rb EXEC_TEST_DISPATCH = ruby ../common/tests/dispatch.rb
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Dockerization ## Dockerization
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial
DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i
DOCKER_ARG_DIR_COMMON = -v $(shell pwd)/../common:/work/common 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 ## Targets
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
.PHONY: all doc qemu clippy clean readelf objdump nm check .PHONY: all doc qemu clippy clean readelf objdump nm check
all: $(KERNEL_BIN) all: $(KERNEL_BIN)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Save the configuration as a file, so make understands if it changed. ## Save the configuration as a file, so make understands if it changed.
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
$(LAST_BUILD_CONFIG): $(LAST_BUILD_CONFIG):
@rm -f target/*.build_config @rm -f target/*.build_config
@mkdir -p target @mkdir -p target
@touch $(LAST_BUILD_CONFIG) @touch $(LAST_BUILD_CONFIG)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Compile the kernel ELF ## Compile the kernel ELF
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
$(KERNEL_ELF): $(KERNEL_ELF_DEPS) $(KERNEL_ELF): $(KERNEL_ELF_DEPS)
$(call color_header, "Compiling kernel ELF - $(BSP)") $(call color_header, "Compiling kernel ELF - $(BSP)")
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD) @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Generate the stripped kernel binary ## Generate the stripped kernel binary
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
$(KERNEL_BIN): $(KERNEL_ELF) $(KERNEL_BIN): $(KERNEL_ELF)
$(call color_header, "Generating stripped binary") $(call color_header, "Generating stripped binary")
@$(OBJCOPY_CMD) $(KERNEL_ELF) $(KERNEL_BIN) @$(OBJCOPY_CMD) $(KERNEL_ELF) $(KERNEL_BIN)
@ -136,16 +136,16 @@ $(KERNEL_BIN): $(KERNEL_ELF)
$(call color_progress_prefix, "Size") $(call color_progress_prefix, "Size")
$(call disk_usage_KiB, $(KERNEL_BIN)) $(call disk_usage_KiB, $(KERNEL_BIN))
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Generate the documentation ## Generate the documentation
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
doc: doc:
$(call color_header, "Generating docs") $(call color_header, "Generating docs")
@$(DOC_CMD) --document-private-items --open @$(DOC_CMD) --document-private-items --open
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run the kernel in QEMU ## Run the kernel in QEMU
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board.
qemu: qemu:
@ -158,28 +158,28 @@ qemu: $(KERNEL_BIN)
@$(DOCKER_QEMU) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN) @$(DOCKER_QEMU) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN)
endif endif
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run clippy ## Run clippy
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
clippy: clippy:
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Clean ## Clean
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
clean: clean:
rm -rf target $(KERNEL_BIN) rm -rf target $(KERNEL_BIN)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run readelf ## Run readelf
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
readelf: $(KERNEL_ELF) readelf: $(KERNEL_ELF)
$(call color_header, "Launching readelf") $(call color_header, "Launching readelf")
@$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF) @$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run objdump ## Run objdump
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
objdump: $(KERNEL_ELF) objdump: $(KERNEL_ELF)
$(call color_header, "Launching objdump") $(call color_header, "Launching objdump")
@$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \ @$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \
@ -187,18 +187,18 @@ objdump: $(KERNEL_ELF)
--section .rodata \ --section .rodata \
$(KERNEL_ELF) | rustfilt $(KERNEL_ELF) | rustfilt
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run nm ## Run nm
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
nm: $(KERNEL_ELF) nm: $(KERNEL_ELF)
$(call color_header, "Launching nm") $(call color_header, "Launching nm")
@$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt @$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Testing targets ## Testing targets
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
.PHONY: test test_boot .PHONY: test test_boot
ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board.
@ -208,9 +208,9 @@ test_boot test:
else # QEMU is supported. else # QEMU is supported.
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run boot test ## Run boot test
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
test_boot: $(KERNEL_BIN) test_boot: $(KERNEL_BIN)
$(call color_header, "Boot test - $(BSP)") $(call color_header, "Boot test - $(BSP)")
@$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN) @$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN)

@ -6,9 +6,9 @@ include ../common/docker.mk
include ../common/format.mk include ../common/format.mk
include ../common/operating_system.mk include ../common/operating_system.mk
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Optional, user-provided configuration values ## Optional, user-provided configuration values
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
# Default to the RPi3. # Default to the RPi3.
BSP ?= rpi3 BSP ?= rpi3
@ -18,9 +18,9 @@ DEV_SERIAL ?= /dev/ttyUSB0
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## BSP-specific configuration values ## BSP-specific configuration values
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
QEMU_MISSING_STRING = "This board is not yet supported for QEMU." QEMU_MISSING_STRING = "This board is not yet supported for QEMU."
ifeq ($(BSP),rpi3) ifeq ($(BSP),rpi3)
@ -52,9 +52,9 @@ export LD_SCRIPT_PATH
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Targets and Prerequisites ## Targets and Prerequisites
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
KERNEL_MANIFEST = Cargo.toml KERNEL_MANIFEST = Cargo.toml
KERNEL_LINKER_SCRIPT = kernel.ld KERNEL_LINKER_SCRIPT = kernel.ld
LAST_BUILD_CONFIG = target/$(BSP).build_config 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 ## Command building blocks
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
RUSTFLAGS = $(RUSTC_MISC_ARGS) \ RUSTFLAGS = $(RUSTC_MISC_ARGS) \
-C link-arg=--library-path=$(LD_SCRIPT_PATH) \ -C link-arg=--library-path=$(LD_SCRIPT_PATH) \
-C link-arg=--script=$(KERNEL_LINKER_SCRIPT) -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_TEST_DISPATCH = ruby ../common/tests/dispatch.rb
EXEC_MINITERM = ruby ../common/serial/miniterm.rb EXEC_MINITERM = ruby ../common/serial/miniterm.rb
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Dockerization ## Dockerization
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial
DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i
DOCKER_ARG_DIR_COMMON = -v $(shell pwd)/../common:/work/common DOCKER_ARG_DIR_COMMON = -v $(shell pwd)/../common:/work/common
@ -115,31 +115,31 @@ endif
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Targets ## Targets
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
.PHONY: all doc qemu miniterm clippy clean readelf objdump nm check .PHONY: all doc qemu miniterm clippy clean readelf objdump nm check
all: $(KERNEL_BIN) all: $(KERNEL_BIN)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Save the configuration as a file, so make understands if it changed. ## Save the configuration as a file, so make understands if it changed.
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
$(LAST_BUILD_CONFIG): $(LAST_BUILD_CONFIG):
@rm -f target/*.build_config @rm -f target/*.build_config
@mkdir -p target @mkdir -p target
@touch $(LAST_BUILD_CONFIG) @touch $(LAST_BUILD_CONFIG)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Compile the kernel ELF ## Compile the kernel ELF
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
$(KERNEL_ELF): $(KERNEL_ELF_DEPS) $(KERNEL_ELF): $(KERNEL_ELF_DEPS)
$(call color_header, "Compiling kernel ELF - $(BSP)") $(call color_header, "Compiling kernel ELF - $(BSP)")
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD) @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Generate the stripped kernel binary ## Generate the stripped kernel binary
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
$(KERNEL_BIN): $(KERNEL_ELF) $(KERNEL_BIN): $(KERNEL_ELF)
$(call color_header, "Generating stripped binary") $(call color_header, "Generating stripped binary")
@$(OBJCOPY_CMD) $(KERNEL_ELF) $(KERNEL_BIN) @$(OBJCOPY_CMD) $(KERNEL_ELF) $(KERNEL_BIN)
@ -148,16 +148,16 @@ $(KERNEL_BIN): $(KERNEL_ELF)
$(call color_progress_prefix, "Size") $(call color_progress_prefix, "Size")
$(call disk_usage_KiB, $(KERNEL_BIN)) $(call disk_usage_KiB, $(KERNEL_BIN))
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Generate the documentation ## Generate the documentation
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
doc: doc:
$(call color_header, "Generating docs") $(call color_header, "Generating docs")
@$(DOC_CMD) --document-private-items --open @$(DOC_CMD) --document-private-items --open
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run the kernel in QEMU ## Run the kernel in QEMU
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board.
qemu: qemu:
@ -171,34 +171,34 @@ qemu: $(KERNEL_BIN)
endif endif
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Connect to the target's serial ## Connect to the target's serial
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
miniterm: miniterm:
@$(DOCKER_MINITERM) $(EXEC_MINITERM) $(DEV_SERIAL) @$(DOCKER_MINITERM) $(EXEC_MINITERM) $(DEV_SERIAL)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run clippy ## Run clippy
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
clippy: clippy:
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Clean ## Clean
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
clean: clean:
rm -rf target $(KERNEL_BIN) rm -rf target $(KERNEL_BIN)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run readelf ## Run readelf
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
readelf: $(KERNEL_ELF) readelf: $(KERNEL_ELF)
$(call color_header, "Launching readelf") $(call color_header, "Launching readelf")
@$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF) @$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run objdump ## Run objdump
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
objdump: $(KERNEL_ELF) objdump: $(KERNEL_ELF)
$(call color_header, "Launching objdump") $(call color_header, "Launching objdump")
@$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \ @$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \
@ -206,18 +206,18 @@ objdump: $(KERNEL_ELF)
--section .rodata \ --section .rodata \
$(KERNEL_ELF) | rustfilt $(KERNEL_ELF) | rustfilt
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run nm ## Run nm
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
nm: $(KERNEL_ELF) nm: $(KERNEL_ELF)
$(call color_header, "Launching nm") $(call color_header, "Launching nm")
@$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt @$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Testing targets ## Testing targets
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
.PHONY: test test_boot .PHONY: test test_boot
ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board.
@ -227,9 +227,9 @@ test_boot test:
else # QEMU is supported. else # QEMU is supported.
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run boot test ## Run boot test
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
test_boot: $(KERNEL_BIN) test_boot: $(KERNEL_BIN)
$(call color_header, "Boot test - $(BSP)") $(call color_header, "Boot test - $(BSP)")
@$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN) @$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN)

@ -195,14 +195,14 @@ diff -uNr 04_safe_globals/Makefile 05_drivers_gpio_uart/Makefile
+ +
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
@@ -88,6 +91,7 @@ @@ -88,6 +91,7 @@
EXEC_QEMU = $(QEMU_BINARY) -M $(QEMU_MACHINE_TYPE) EXEC_QEMU = $(QEMU_BINARY) -M $(QEMU_MACHINE_TYPE)
EXEC_TEST_DISPATCH = ruby ../common/tests/dispatch.rb EXEC_TEST_DISPATCH = ruby ../common/tests/dispatch.rb
+EXEC_MINITERM = ruby ../common/serial/miniterm.rb +EXEC_MINITERM = ruby ../common/serial/miniterm.rb
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Dockerization ## Dockerization
@@ -95,18 +99,26 @@ @@ -95,18 +99,26 @@
DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial 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 ## Targets
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
-.PHONY: all doc qemu clippy clean readelf objdump nm check -.PHONY: all doc qemu clippy clean readelf objdump nm check
+.PHONY: all doc qemu miniterm 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 endif
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
+## Connect to the target's serial +## Connect to the target's serial
+##------------------------------------------------------------------------------ +## ------------------------------------------------------------------------------
+miniterm: +miniterm:
+ @$(DOCKER_MINITERM) $(EXEC_MINITERM) $(DEV_SERIAL) + @$(DOCKER_MINITERM) $(EXEC_MINITERM) $(DEV_SERIAL)
+ +
+##------------------------------------------------------------------------------ +## ------------------------------------------------------------------------------
## Run clippy ## Run clippy
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
clippy: clippy:
diff -uNr 04_safe_globals/src/_arch/aarch64/cpu.rs 05_drivers_gpio_uart/src/_arch/aarch64/cpu.rs diff -uNr 04_safe_globals/src/_arch/aarch64/cpu.rs 05_drivers_gpio_uart/src/_arch/aarch64/cpu.rs

@ -6,9 +6,9 @@ include ../common/docker.mk
include ../common/format.mk include ../common/format.mk
include ../common/operating_system.mk include ../common/operating_system.mk
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Optional, user-provided configuration values ## Optional, user-provided configuration values
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
# Default to the RPi3. # Default to the RPi3.
BSP ?= rpi3 BSP ?= rpi3
@ -18,9 +18,9 @@ DEV_SERIAL ?= /dev/ttyUSB0
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## BSP-specific configuration values ## BSP-specific configuration values
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
QEMU_MISSING_STRING = "This board is not yet supported for QEMU." QEMU_MISSING_STRING = "This board is not yet supported for QEMU."
ifeq ($(BSP),rpi3) ifeq ($(BSP),rpi3)
@ -54,9 +54,9 @@ export LD_SCRIPT_PATH
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Targets and Prerequisites ## Targets and Prerequisites
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
KERNEL_MANIFEST = Cargo.toml KERNEL_MANIFEST = Cargo.toml
KERNEL_LINKER_SCRIPT = kernel.ld KERNEL_LINKER_SCRIPT = kernel.ld
LAST_BUILD_CONFIG = target/$(BSP).build_config 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 ## Command building blocks
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
RUSTFLAGS = $(RUSTC_MISC_ARGS) \ RUSTFLAGS = $(RUSTC_MISC_ARGS) \
-C link-arg=--library-path=$(LD_SCRIPT_PATH) \ -C link-arg=--library-path=$(LD_SCRIPT_PATH) \
-C link-arg=--script=$(KERNEL_LINKER_SCRIPT) -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_TEST_MINIPUSH = ruby tests/chainboot_test.rb
EXEC_MINIPUSH = ruby ../common/serial/minipush.rb EXEC_MINIPUSH = ruby ../common/serial/minipush.rb
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Dockerization ## Dockerization
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial
DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i
DOCKER_ARG_DIR_COMMON = -v $(shell pwd)/../common:/work/common DOCKER_ARG_DIR_COMMON = -v $(shell pwd)/../common:/work/common
@ -117,31 +117,31 @@ endif
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Targets ## Targets
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
.PHONY: all doc qemu chainboot clippy clean readelf objdump nm check .PHONY: all doc qemu chainboot clippy clean readelf objdump nm check
all: $(KERNEL_BIN) all: $(KERNEL_BIN)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Save the configuration as a file, so make understands if it changed. ## Save the configuration as a file, so make understands if it changed.
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
$(LAST_BUILD_CONFIG): $(LAST_BUILD_CONFIG):
@rm -f target/*.build_config @rm -f target/*.build_config
@mkdir -p target @mkdir -p target
@touch $(LAST_BUILD_CONFIG) @touch $(LAST_BUILD_CONFIG)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Compile the kernel ELF ## Compile the kernel ELF
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
$(KERNEL_ELF): $(KERNEL_ELF_DEPS) $(KERNEL_ELF): $(KERNEL_ELF_DEPS)
$(call color_header, "Compiling kernel ELF - $(BSP)") $(call color_header, "Compiling kernel ELF - $(BSP)")
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD) @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Generate the stripped kernel binary ## Generate the stripped kernel binary
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
$(KERNEL_BIN): $(KERNEL_ELF) $(KERNEL_BIN): $(KERNEL_ELF)
$(call color_header, "Generating stripped binary") $(call color_header, "Generating stripped binary")
@$(OBJCOPY_CMD) $(KERNEL_ELF) $(KERNEL_BIN) @$(OBJCOPY_CMD) $(KERNEL_ELF) $(KERNEL_BIN)
@ -150,16 +150,16 @@ $(KERNEL_BIN): $(KERNEL_ELF)
$(call color_progress_prefix, "Size") $(call color_progress_prefix, "Size")
$(call disk_usage_KiB, $(KERNEL_BIN)) $(call disk_usage_KiB, $(KERNEL_BIN))
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Generate the documentation ## Generate the documentation
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
doc: doc:
$(call color_header, "Generating docs") $(call color_header, "Generating docs")
@$(DOC_CMD) --document-private-items --open @$(DOC_CMD) --document-private-items --open
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run the kernel in QEMU ## Run the kernel in QEMU
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board.
qemu qemuasm: qemu qemuasm:
@ -177,34 +177,34 @@ qemuasm: $(KERNEL_BIN)
endif endif
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Push the kernel to the real HW target ## Push the kernel to the real HW target
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
chainboot: $(KERNEL_BIN) chainboot: $(KERNEL_BIN)
@$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(CHAINBOOT_DEMO_PAYLOAD) @$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(CHAINBOOT_DEMO_PAYLOAD)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run clippy ## Run clippy
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
clippy: clippy:
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Clean ## Clean
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
clean: clean:
rm -rf target $(KERNEL_BIN) rm -rf target $(KERNEL_BIN)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run readelf ## Run readelf
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
readelf: $(KERNEL_ELF) readelf: $(KERNEL_ELF)
$(call color_header, "Launching readelf") $(call color_header, "Launching readelf")
@$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF) @$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run objdump ## Run objdump
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
objdump: $(KERNEL_ELF) objdump: $(KERNEL_ELF)
$(call color_header, "Launching objdump") $(call color_header, "Launching objdump")
@$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \ @$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \
@ -212,18 +212,18 @@ objdump: $(KERNEL_ELF)
--section .rodata \ --section .rodata \
$(KERNEL_ELF) | rustfilt $(KERNEL_ELF) | rustfilt
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run nm ## Run nm
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
nm: $(KERNEL_ELF) nm: $(KERNEL_ELF)
$(call color_header, "Launching nm") $(call color_header, "Launching nm")
@$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt @$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Testing targets ## Testing targets
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
.PHONY: test test_boot .PHONY: test test_boot
ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board.
@ -233,9 +233,9 @@ test_boot test:
else # QEMU is supported. else # QEMU is supported.
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run boot test ## Run boot test
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
test_boot: $(KERNEL_BIN) test_boot: $(KERNEL_BIN)
$(call color_header, "Boot test - $(BSP)") $(call color_header, "Boot test - $(BSP)")
@$(DOCKER_TEST) $(EXEC_TEST_MINIPUSH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) \ @$(DOCKER_TEST) $(EXEC_TEST_MINIPUSH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) \

@ -199,7 +199,7 @@ diff -uNr 05_drivers_gpio_uart/Makefile 06_uart_chainloader/Makefile
+EXEC_TEST_MINIPUSH = ruby tests/chainboot_test.rb +EXEC_TEST_MINIPUSH = ruby tests/chainboot_test.rb
+EXEC_MINIPUSH = ruby ../common/serial/minipush.rb +EXEC_MINIPUSH = ruby ../common/serial/minipush.rb
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Dockerization ## Dockerization
@@ -110,7 +112,7 @@ @@ -110,7 +112,7 @@
ifeq ($(shell uname -s),Linux) ifeq ($(shell uname -s),Linux)
@ -211,16 +211,16 @@ diff -uNr 05_drivers_gpio_uart/Makefile 06_uart_chainloader/Makefile
@@ -118,7 +120,7 @@ @@ -118,7 +120,7 @@
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Targets ## Targets
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
-.PHONY: all doc qemu miniterm clippy clean readelf objdump nm check -.PHONY: all doc qemu miniterm clippy clean readelf objdump nm check
+.PHONY: all doc qemu chainboot clippy clean readelf objdump nm check +.PHONY: all doc qemu chainboot clippy clean readelf objdump nm check
all: $(KERNEL_BIN) all: $(KERNEL_BIN)
@@ -160,7 +162,7 @@ @@ -160,7 +162,7 @@
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board.
-qemu: -qemu:
@ -238,19 +238,19 @@ diff -uNr 05_drivers_gpio_uart/Makefile 06_uart_chainloader/Makefile
+ +
endif endif
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
-## Connect to the target's serial -## Connect to the target's serial
+## Push the kernel to the real HW target +## Push the kernel to the real HW target
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
-miniterm: -miniterm:
- @$(DOCKER_MINITERM) $(EXEC_MINITERM) $(DEV_SERIAL) - @$(DOCKER_MINITERM) $(EXEC_MINITERM) $(DEV_SERIAL)
+chainboot: $(KERNEL_BIN) +chainboot: $(KERNEL_BIN)
+ @$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(CHAINBOOT_DEMO_PAYLOAD) + @$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(CHAINBOOT_DEMO_PAYLOAD)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run clippy ## Run clippy
@@ -232,7 +238,8 @@ @@ -232,7 +238,8 @@
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
test_boot: $(KERNEL_BIN) test_boot: $(KERNEL_BIN)
$(call color_header, "Boot test - $(BSP)") $(call color_header, "Boot test - $(BSP)")
- @$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN) - @$(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
+end +end
+ +
+##-------------------------------------------------------------------------------------------------- +## --------------------------------------------------------------------------------------------------
+## Execution starts here +## Execution starts here
+##-------------------------------------------------------------------------------------------------- +## --------------------------------------------------------------------------------------------------
+payload_path = ARGV.pop +payload_path = ARGV.pop
+qemu_cmd = ARGV.join(' ') +qemu_cmd = ARGV.join(' ')
+ +

@ -69,9 +69,9 @@ class ChainbootTest < BootTest
end end
end end
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Execution starts here ## Execution starts here
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
payload_path = ARGV.pop payload_path = ARGV.pop
qemu_cmd = ARGV.join(' ') qemu_cmd = ARGV.join(' ')

@ -6,9 +6,9 @@ include ../common/docker.mk
include ../common/format.mk include ../common/format.mk
include ../common/operating_system.mk include ../common/operating_system.mk
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Optional, user-provided configuration values ## Optional, user-provided configuration values
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
# Default to the RPi3. # Default to the RPi3.
BSP ?= rpi3 BSP ?= rpi3
@ -18,9 +18,9 @@ DEV_SERIAL ?= /dev/ttyUSB0
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## BSP-specific configuration values ## BSP-specific configuration values
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
QEMU_MISSING_STRING = "This board is not yet supported for QEMU." QEMU_MISSING_STRING = "This board is not yet supported for QEMU."
ifeq ($(BSP),rpi3) ifeq ($(BSP),rpi3)
@ -52,9 +52,9 @@ export LD_SCRIPT_PATH
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Targets and Prerequisites ## Targets and Prerequisites
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
KERNEL_MANIFEST = Cargo.toml KERNEL_MANIFEST = Cargo.toml
KERNEL_LINKER_SCRIPT = kernel.ld KERNEL_LINKER_SCRIPT = kernel.ld
LAST_BUILD_CONFIG = target/$(BSP).build_config 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 ## Command building blocks
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
RUSTFLAGS = $(RUSTC_MISC_ARGS) \ RUSTFLAGS = $(RUSTC_MISC_ARGS) \
-C link-arg=--library-path=$(LD_SCRIPT_PATH) \ -C link-arg=--library-path=$(LD_SCRIPT_PATH) \
-C link-arg=--script=$(KERNEL_LINKER_SCRIPT) -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_TEST_DISPATCH = ruby ../common/tests/dispatch.rb
EXEC_MINIPUSH = ruby ../common/serial/minipush.rb EXEC_MINIPUSH = ruby ../common/serial/minipush.rb
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Dockerization ## Dockerization
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial
DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i
DOCKER_ARG_DIR_COMMON = -v $(shell pwd)/../common:/work/common DOCKER_ARG_DIR_COMMON = -v $(shell pwd)/../common:/work/common
@ -115,31 +115,31 @@ endif
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Targets ## Targets
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
.PHONY: all doc qemu chainboot clippy clean readelf objdump nm check .PHONY: all doc qemu chainboot clippy clean readelf objdump nm check
all: $(KERNEL_BIN) all: $(KERNEL_BIN)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Save the configuration as a file, so make understands if it changed. ## Save the configuration as a file, so make understands if it changed.
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
$(LAST_BUILD_CONFIG): $(LAST_BUILD_CONFIG):
@rm -f target/*.build_config @rm -f target/*.build_config
@mkdir -p target @mkdir -p target
@touch $(LAST_BUILD_CONFIG) @touch $(LAST_BUILD_CONFIG)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Compile the kernel ELF ## Compile the kernel ELF
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
$(KERNEL_ELF): $(KERNEL_ELF_DEPS) $(KERNEL_ELF): $(KERNEL_ELF_DEPS)
$(call color_header, "Compiling kernel ELF - $(BSP)") $(call color_header, "Compiling kernel ELF - $(BSP)")
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD) @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Generate the stripped kernel binary ## Generate the stripped kernel binary
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
$(KERNEL_BIN): $(KERNEL_ELF) $(KERNEL_BIN): $(KERNEL_ELF)
$(call color_header, "Generating stripped binary") $(call color_header, "Generating stripped binary")
@$(OBJCOPY_CMD) $(KERNEL_ELF) $(KERNEL_BIN) @$(OBJCOPY_CMD) $(KERNEL_ELF) $(KERNEL_BIN)
@ -148,16 +148,16 @@ $(KERNEL_BIN): $(KERNEL_ELF)
$(call color_progress_prefix, "Size") $(call color_progress_prefix, "Size")
$(call disk_usage_KiB, $(KERNEL_BIN)) $(call disk_usage_KiB, $(KERNEL_BIN))
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Generate the documentation ## Generate the documentation
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
doc: doc:
$(call color_header, "Generating docs") $(call color_header, "Generating docs")
@$(DOC_CMD) --document-private-items --open @$(DOC_CMD) --document-private-items --open
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run the kernel in QEMU ## Run the kernel in QEMU
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board.
qemu: qemu:
@ -171,34 +171,34 @@ qemu: $(KERNEL_BIN)
endif endif
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Push the kernel to the real HW target ## Push the kernel to the real HW target
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
chainboot: $(KERNEL_BIN) chainboot: $(KERNEL_BIN)
@$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(KERNEL_BIN) @$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(KERNEL_BIN)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run clippy ## Run clippy
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
clippy: clippy:
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Clean ## Clean
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
clean: clean:
rm -rf target $(KERNEL_BIN) rm -rf target $(KERNEL_BIN)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run readelf ## Run readelf
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
readelf: $(KERNEL_ELF) readelf: $(KERNEL_ELF)
$(call color_header, "Launching readelf") $(call color_header, "Launching readelf")
@$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF) @$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run objdump ## Run objdump
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
objdump: $(KERNEL_ELF) objdump: $(KERNEL_ELF)
$(call color_header, "Launching objdump") $(call color_header, "Launching objdump")
@$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \ @$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \
@ -206,18 +206,18 @@ objdump: $(KERNEL_ELF)
--section .rodata \ --section .rodata \
$(KERNEL_ELF) | rustfilt $(KERNEL_ELF) | rustfilt
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run nm ## Run nm
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
nm: $(KERNEL_ELF) nm: $(KERNEL_ELF)
$(call color_header, "Launching nm") $(call color_header, "Launching nm")
@$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt @$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Testing targets ## Testing targets
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
.PHONY: test test_boot .PHONY: test test_boot
ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board.
@ -227,9 +227,9 @@ test_boot test:
else # QEMU is supported. else # QEMU is supported.
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run boot test ## Run boot test
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
test_boot: $(KERNEL_BIN) test_boot: $(KERNEL_BIN)
$(call color_header, "Boot test - $(BSP)") $(call color_header, "Boot test - $(BSP)")
@$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN) @$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN)

@ -121,9 +121,9 @@ diff -uNr 06_uart_chainloader/Makefile 07_timestamps/Makefile
+EXEC_TEST_DISPATCH = ruby ../common/tests/dispatch.rb +EXEC_TEST_DISPATCH = ruby ../common/tests/dispatch.rb
EXEC_MINIPUSH = ruby ../common/serial/minipush.rb EXEC_MINIPUSH = ruby ../common/serial/minipush.rb
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
@@ -162,7 +160,7 @@ @@ -162,7 +160,7 @@
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board.
-qemu qemuasm: -qemu qemuasm:
@ -141,17 +141,17 @@ diff -uNr 06_uart_chainloader/Makefile 07_timestamps/Makefile
- -
endif endif
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Push the kernel to the real HW target ## Push the kernel to the real HW target
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
chainboot: $(KERNEL_BIN) chainboot: $(KERNEL_BIN)
- @$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(CHAINBOOT_DEMO_PAYLOAD) - @$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(CHAINBOOT_DEMO_PAYLOAD)
+ @$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(KERNEL_BIN) + @$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(KERNEL_BIN)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run clippy ## Run clippy
@@ -238,8 +232,7 @@ @@ -238,8 +232,7 @@
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
test_boot: $(KERNEL_BIN) test_boot: $(KERNEL_BIN)
$(call color_header, "Boot test - $(BSP)") $(call color_header, "Boot test - $(BSP)")
- @$(DOCKER_TEST) $(EXEC_TEST_MINIPUSH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) \ - @$(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
-end -end
- -
-##-------------------------------------------------------------------------------------------------- -## --------------------------------------------------------------------------------------------------
-## Execution starts here -## Execution starts here
-##-------------------------------------------------------------------------------------------------- -## --------------------------------------------------------------------------------------------------
-payload_path = ARGV.pop -payload_path = ARGV.pop
-qemu_cmd = ARGV.join(' ') -qemu_cmd = ARGV.join(' ')
- -

@ -6,9 +6,9 @@ include ../common/docker.mk
include ../common/format.mk include ../common/format.mk
include ../common/operating_system.mk include ../common/operating_system.mk
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Optional, user-provided configuration values ## Optional, user-provided configuration values
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
# Default to the RPi3. # Default to the RPi3.
BSP ?= rpi3 BSP ?= rpi3
@ -18,9 +18,9 @@ DEV_SERIAL ?= /dev/ttyUSB0
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## BSP-specific configuration values ## BSP-specific configuration values
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
QEMU_MISSING_STRING = "This board is not yet supported for QEMU." QEMU_MISSING_STRING = "This board is not yet supported for QEMU."
ifeq ($(BSP),rpi3) ifeq ($(BSP),rpi3)
@ -56,9 +56,9 @@ export LD_SCRIPT_PATH
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Targets and Prerequisites ## Targets and Prerequisites
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
KERNEL_MANIFEST = Cargo.toml KERNEL_MANIFEST = Cargo.toml
KERNEL_LINKER_SCRIPT = kernel.ld KERNEL_LINKER_SCRIPT = kernel.ld
LAST_BUILD_CONFIG = target/$(BSP).build_config 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 ## Command building blocks
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
RUSTFLAGS = $(RUSTC_MISC_ARGS) \ RUSTFLAGS = $(RUSTC_MISC_ARGS) \
-C link-arg=--library-path=$(LD_SCRIPT_PATH) \ -C link-arg=--library-path=$(LD_SCRIPT_PATH) \
-C link-arg=--script=$(KERNEL_LINKER_SCRIPT) -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_TEST_DISPATCH = ruby ../common/tests/dispatch.rb
EXEC_MINIPUSH = ruby ../common/serial/minipush.rb EXEC_MINIPUSH = ruby ../common/serial/minipush.rb
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Dockerization ## Dockerization
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial
DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i
DOCKER_ARG_DIR_COMMON = -v $(shell pwd)/../common:/work/common DOCKER_ARG_DIR_COMMON = -v $(shell pwd)/../common:/work/common
@ -126,31 +126,31 @@ endif
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Targets ## Targets
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
.PHONY: all doc qemu chainboot clippy clean readelf objdump nm check .PHONY: all doc qemu chainboot clippy clean readelf objdump nm check
all: $(KERNEL_BIN) all: $(KERNEL_BIN)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Save the configuration as a file, so make understands if it changed. ## Save the configuration as a file, so make understands if it changed.
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
$(LAST_BUILD_CONFIG): $(LAST_BUILD_CONFIG):
@rm -f target/*.build_config @rm -f target/*.build_config
@mkdir -p target @mkdir -p target
@touch $(LAST_BUILD_CONFIG) @touch $(LAST_BUILD_CONFIG)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Compile the kernel ELF ## Compile the kernel ELF
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
$(KERNEL_ELF): $(KERNEL_ELF_DEPS) $(KERNEL_ELF): $(KERNEL_ELF_DEPS)
$(call color_header, "Compiling kernel ELF - $(BSP)") $(call color_header, "Compiling kernel ELF - $(BSP)")
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD) @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Generate the stripped kernel binary ## Generate the stripped kernel binary
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
$(KERNEL_BIN): $(KERNEL_ELF) $(KERNEL_BIN): $(KERNEL_ELF)
$(call color_header, "Generating stripped binary") $(call color_header, "Generating stripped binary")
@$(OBJCOPY_CMD) $(KERNEL_ELF) $(KERNEL_BIN) @$(OBJCOPY_CMD) $(KERNEL_ELF) $(KERNEL_BIN)
@ -159,16 +159,16 @@ $(KERNEL_BIN): $(KERNEL_ELF)
$(call color_progress_prefix, "Size") $(call color_progress_prefix, "Size")
$(call disk_usage_KiB, $(KERNEL_BIN)) $(call disk_usage_KiB, $(KERNEL_BIN))
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Generate the documentation ## Generate the documentation
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
doc: doc:
$(call color_header, "Generating docs") $(call color_header, "Generating docs")
@$(DOC_CMD) --document-private-items --open @$(DOC_CMD) --document-private-items --open
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run the kernel in QEMU ## Run the kernel in QEMU
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board.
qemu: qemu:
@ -182,34 +182,34 @@ qemu: $(KERNEL_BIN)
endif endif
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Push the kernel to the real HW target ## Push the kernel to the real HW target
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
chainboot: $(KERNEL_BIN) chainboot: $(KERNEL_BIN)
@$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(KERNEL_BIN) @$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(KERNEL_BIN)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run clippy ## Run clippy
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
clippy: clippy:
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Clean ## Clean
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
clean: clean:
rm -rf target $(KERNEL_BIN) rm -rf target $(KERNEL_BIN)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run readelf ## Run readelf
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
readelf: $(KERNEL_ELF) readelf: $(KERNEL_ELF)
$(call color_header, "Launching readelf") $(call color_header, "Launching readelf")
@$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF) @$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run objdump ## Run objdump
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
objdump: $(KERNEL_ELF) objdump: $(KERNEL_ELF)
$(call color_header, "Launching objdump") $(call color_header, "Launching objdump")
@$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \ @$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \
@ -217,36 +217,36 @@ objdump: $(KERNEL_ELF)
--section .rodata \ --section .rodata \
$(KERNEL_ELF) | rustfilt $(KERNEL_ELF) | rustfilt
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run nm ## Run nm
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
nm: $(KERNEL_ELF) nm: $(KERNEL_ELF)
$(call color_header, "Launching nm") $(call color_header, "Launching nm")
@$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt @$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Debugging targets ## Debugging targets
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
.PHONY: jtagboot openocd gdb gdb-opt0 .PHONY: jtagboot openocd gdb gdb-opt0
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Push the JTAG boot image to the real HW target ## Push the JTAG boot image to the real HW target
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
jtagboot: jtagboot:
@$(DOCKER_JTAGBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(JTAG_BOOT_IMAGE) @$(DOCKER_JTAGBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(JTAG_BOOT_IMAGE)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Start OpenOCD session ## Start OpenOCD session
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
openocd: openocd:
$(call color_header, "Launching OpenOCD") $(call color_header, "Launching OpenOCD")
@$(DOCKER_OPENOCD) openocd $(OPENOCD_ARG) @$(DOCKER_OPENOCD) openocd $(OPENOCD_ARG)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Start GDB session ## Start GDB session
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
gdb: RUSTC_MISC_ARGS += -C debuginfo=2 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 debuginfo=2 -C opt-level=0
gdb gdb-opt0: $(KERNEL_ELF) gdb gdb-opt0: $(KERNEL_ELF)
@ -255,9 +255,9 @@ gdb gdb-opt0: $(KERNEL_ELF)
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Testing targets ## Testing targets
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
.PHONY: test test_boot .PHONY: test test_boot
ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board.
@ -267,9 +267,9 @@ test_boot test:
else # QEMU is supported. else # QEMU is supported.
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run boot test ## Run boot test
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
test_boot: $(KERNEL_BIN) test_boot: $(KERNEL_BIN)
$(call color_header, "Boot test - $(BSP)") $(call color_header, "Boot test - $(BSP)")
@$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN) @$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN)

@ -368,27 +368,27 @@ diff -uNr 07_timestamps/Makefile 08_hw_debug_JTAG/Makefile
+##-------------------------------------------------------------------------------------------------- +## --------------------------------------------------------------------------------------------------
+## Debugging targets +## Debugging targets
+##-------------------------------------------------------------------------------------------------- +## --------------------------------------------------------------------------------------------------
+.PHONY: jtagboot openocd gdb gdb-opt0 +.PHONY: jtagboot openocd gdb gdb-opt0
+ +
+##------------------------------------------------------------------------------ +## ------------------------------------------------------------------------------
+## Push the JTAG boot image to the real HW target +## Push the JTAG boot image to the real HW target
+##------------------------------------------------------------------------------ +## ------------------------------------------------------------------------------
+jtagboot: +jtagboot:
+ @$(DOCKER_JTAGBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(JTAG_BOOT_IMAGE) + @$(DOCKER_JTAGBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(JTAG_BOOT_IMAGE)
+ +
+##------------------------------------------------------------------------------ +## ------------------------------------------------------------------------------
+## Start OpenOCD session +## Start OpenOCD session
+##------------------------------------------------------------------------------ +## ------------------------------------------------------------------------------
+openocd: +openocd:
+ $(call color_header, "Launching OpenOCD") + $(call color_header, "Launching OpenOCD")
+ @$(DOCKER_OPENOCD) openocd $(OPENOCD_ARG) + @$(DOCKER_OPENOCD) openocd $(OPENOCD_ARG)
+ +
+##------------------------------------------------------------------------------ +## ------------------------------------------------------------------------------
+## Start GDB session +## Start GDB session
+##------------------------------------------------------------------------------ +## ------------------------------------------------------------------------------
+gdb: RUSTC_MISC_ARGS += -C debuginfo=2 +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 debuginfo=2 -C opt-level=0
+gdb gdb-opt0: $(KERNEL_ELF) +gdb gdb-opt0: $(KERNEL_ELF)
@ -397,9 +397,9 @@ diff -uNr 07_timestamps/Makefile 08_hw_debug_JTAG/Makefile
+ +
+ +
+ +
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Testing targets ## Testing targets
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
diff -uNr 07_timestamps/src/bsp/raspberrypi/driver.rs 08_hw_debug_JTAG/src/bsp/raspberrypi/driver.rs 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 --- 07_timestamps/src/bsp/raspberrypi/driver.rs

@ -6,9 +6,9 @@ include ../common/docker.mk
include ../common/format.mk include ../common/format.mk
include ../common/operating_system.mk include ../common/operating_system.mk
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Optional, user-provided configuration values ## Optional, user-provided configuration values
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
# Default to the RPi3. # Default to the RPi3.
BSP ?= rpi3 BSP ?= rpi3
@ -18,9 +18,9 @@ DEV_SERIAL ?= /dev/ttyUSB0
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## BSP-specific configuration values ## BSP-specific configuration values
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
QEMU_MISSING_STRING = "This board is not yet supported for QEMU." QEMU_MISSING_STRING = "This board is not yet supported for QEMU."
ifeq ($(BSP),rpi3) ifeq ($(BSP),rpi3)
@ -56,9 +56,9 @@ export LD_SCRIPT_PATH
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Targets and Prerequisites ## Targets and Prerequisites
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
KERNEL_MANIFEST = Cargo.toml KERNEL_MANIFEST = Cargo.toml
KERNEL_LINKER_SCRIPT = kernel.ld KERNEL_LINKER_SCRIPT = kernel.ld
LAST_BUILD_CONFIG = target/$(BSP).build_config 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 ## Command building blocks
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
RUSTFLAGS = $(RUSTC_MISC_ARGS) \ RUSTFLAGS = $(RUSTC_MISC_ARGS) \
-C link-arg=--library-path=$(LD_SCRIPT_PATH) \ -C link-arg=--library-path=$(LD_SCRIPT_PATH) \
-C link-arg=--script=$(KERNEL_LINKER_SCRIPT) -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_TEST_DISPATCH = ruby ../common/tests/dispatch.rb
EXEC_MINIPUSH = ruby ../common/serial/minipush.rb EXEC_MINIPUSH = ruby ../common/serial/minipush.rb
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Dockerization ## Dockerization
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial
DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i
DOCKER_ARG_DIR_COMMON = -v $(shell pwd)/../common:/work/common DOCKER_ARG_DIR_COMMON = -v $(shell pwd)/../common:/work/common
@ -126,31 +126,31 @@ endif
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Targets ## Targets
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
.PHONY: all doc qemu chainboot clippy clean readelf objdump nm check .PHONY: all doc qemu chainboot clippy clean readelf objdump nm check
all: $(KERNEL_BIN) all: $(KERNEL_BIN)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Save the configuration as a file, so make understands if it changed. ## Save the configuration as a file, so make understands if it changed.
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
$(LAST_BUILD_CONFIG): $(LAST_BUILD_CONFIG):
@rm -f target/*.build_config @rm -f target/*.build_config
@mkdir -p target @mkdir -p target
@touch $(LAST_BUILD_CONFIG) @touch $(LAST_BUILD_CONFIG)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Compile the kernel ELF ## Compile the kernel ELF
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
$(KERNEL_ELF): $(KERNEL_ELF_DEPS) $(KERNEL_ELF): $(KERNEL_ELF_DEPS)
$(call color_header, "Compiling kernel ELF - $(BSP)") $(call color_header, "Compiling kernel ELF - $(BSP)")
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD) @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Generate the stripped kernel binary ## Generate the stripped kernel binary
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
$(KERNEL_BIN): $(KERNEL_ELF) $(KERNEL_BIN): $(KERNEL_ELF)
$(call color_header, "Generating stripped binary") $(call color_header, "Generating stripped binary")
@$(OBJCOPY_CMD) $(KERNEL_ELF) $(KERNEL_BIN) @$(OBJCOPY_CMD) $(KERNEL_ELF) $(KERNEL_BIN)
@ -159,16 +159,16 @@ $(KERNEL_BIN): $(KERNEL_ELF)
$(call color_progress_prefix, "Size") $(call color_progress_prefix, "Size")
$(call disk_usage_KiB, $(KERNEL_BIN)) $(call disk_usage_KiB, $(KERNEL_BIN))
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Generate the documentation ## Generate the documentation
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
doc: doc:
$(call color_header, "Generating docs") $(call color_header, "Generating docs")
@$(DOC_CMD) --document-private-items --open @$(DOC_CMD) --document-private-items --open
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run the kernel in QEMU ## Run the kernel in QEMU
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board.
qemu: qemu:
@ -182,34 +182,34 @@ qemu: $(KERNEL_BIN)
endif endif
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Push the kernel to the real HW target ## Push the kernel to the real HW target
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
chainboot: $(KERNEL_BIN) chainboot: $(KERNEL_BIN)
@$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(KERNEL_BIN) @$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(KERNEL_BIN)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run clippy ## Run clippy
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
clippy: clippy:
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Clean ## Clean
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
clean: clean:
rm -rf target $(KERNEL_BIN) rm -rf target $(KERNEL_BIN)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run readelf ## Run readelf
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
readelf: $(KERNEL_ELF) readelf: $(KERNEL_ELF)
$(call color_header, "Launching readelf") $(call color_header, "Launching readelf")
@$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF) @$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run objdump ## Run objdump
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
objdump: $(KERNEL_ELF) objdump: $(KERNEL_ELF)
$(call color_header, "Launching objdump") $(call color_header, "Launching objdump")
@$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \ @$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \
@ -217,36 +217,36 @@ objdump: $(KERNEL_ELF)
--section .rodata \ --section .rodata \
$(KERNEL_ELF) | rustfilt $(KERNEL_ELF) | rustfilt
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run nm ## Run nm
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
nm: $(KERNEL_ELF) nm: $(KERNEL_ELF)
$(call color_header, "Launching nm") $(call color_header, "Launching nm")
@$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt @$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Debugging targets ## Debugging targets
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
.PHONY: jtagboot openocd gdb gdb-opt0 .PHONY: jtagboot openocd gdb gdb-opt0
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Push the JTAG boot image to the real HW target ## Push the JTAG boot image to the real HW target
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
jtagboot: jtagboot:
@$(DOCKER_JTAGBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(JTAG_BOOT_IMAGE) @$(DOCKER_JTAGBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(JTAG_BOOT_IMAGE)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Start OpenOCD session ## Start OpenOCD session
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
openocd: openocd:
$(call color_header, "Launching OpenOCD") $(call color_header, "Launching OpenOCD")
@$(DOCKER_OPENOCD) openocd $(OPENOCD_ARG) @$(DOCKER_OPENOCD) openocd $(OPENOCD_ARG)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Start GDB session ## Start GDB session
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
gdb: RUSTC_MISC_ARGS += -C debuginfo=2 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 debuginfo=2 -C opt-level=0
gdb gdb-opt0: $(KERNEL_ELF) gdb gdb-opt0: $(KERNEL_ELF)
@ -255,9 +255,9 @@ gdb gdb-opt0: $(KERNEL_ELF)
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Testing targets ## Testing targets
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
.PHONY: test test_boot .PHONY: test test_boot
ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board.
@ -267,9 +267,9 @@ test_boot test:
else # QEMU is supported. else # QEMU is supported.
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run boot test ## Run boot test
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
test_boot: $(KERNEL_BIN) test_boot: $(KERNEL_BIN)
$(call color_header, "Boot test - $(BSP)") $(call color_header, "Boot test - $(BSP)")
@$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN) @$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN)

@ -6,9 +6,9 @@ include ../common/docker.mk
include ../common/format.mk include ../common/format.mk
include ../common/operating_system.mk include ../common/operating_system.mk
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Optional, user-provided configuration values ## Optional, user-provided configuration values
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
# Default to the RPi3. # Default to the RPi3.
BSP ?= rpi3 BSP ?= rpi3
@ -18,9 +18,9 @@ DEV_SERIAL ?= /dev/ttyUSB0
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## BSP-specific configuration values ## BSP-specific configuration values
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
QEMU_MISSING_STRING = "This board is not yet supported for QEMU." QEMU_MISSING_STRING = "This board is not yet supported for QEMU."
ifeq ($(BSP),rpi3) ifeq ($(BSP),rpi3)
@ -56,9 +56,9 @@ export LD_SCRIPT_PATH
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Targets and Prerequisites ## Targets and Prerequisites
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
KERNEL_MANIFEST = Cargo.toml KERNEL_MANIFEST = Cargo.toml
KERNEL_LINKER_SCRIPT = kernel.ld KERNEL_LINKER_SCRIPT = kernel.ld
LAST_BUILD_CONFIG = target/$(BSP).build_config 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 ## Command building blocks
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
RUSTFLAGS = $(RUSTC_MISC_ARGS) \ RUSTFLAGS = $(RUSTC_MISC_ARGS) \
-C link-arg=--library-path=$(LD_SCRIPT_PATH) \ -C link-arg=--library-path=$(LD_SCRIPT_PATH) \
-C link-arg=--script=$(KERNEL_LINKER_SCRIPT) -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_TEST_DISPATCH = ruby ../common/tests/dispatch.rb
EXEC_MINIPUSH = ruby ../common/serial/minipush.rb EXEC_MINIPUSH = ruby ../common/serial/minipush.rb
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Dockerization ## Dockerization
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial
DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i
DOCKER_ARG_DIR_COMMON = -v $(shell pwd)/../common:/work/common DOCKER_ARG_DIR_COMMON = -v $(shell pwd)/../common:/work/common
@ -126,31 +126,31 @@ endif
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Targets ## Targets
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
.PHONY: all doc qemu chainboot clippy clean readelf objdump nm check .PHONY: all doc qemu chainboot clippy clean readelf objdump nm check
all: $(KERNEL_BIN) all: $(KERNEL_BIN)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Save the configuration as a file, so make understands if it changed. ## Save the configuration as a file, so make understands if it changed.
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
$(LAST_BUILD_CONFIG): $(LAST_BUILD_CONFIG):
@rm -f target/*.build_config @rm -f target/*.build_config
@mkdir -p target @mkdir -p target
@touch $(LAST_BUILD_CONFIG) @touch $(LAST_BUILD_CONFIG)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Compile the kernel ELF ## Compile the kernel ELF
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
$(KERNEL_ELF): $(KERNEL_ELF_DEPS) $(KERNEL_ELF): $(KERNEL_ELF_DEPS)
$(call color_header, "Compiling kernel ELF - $(BSP)") $(call color_header, "Compiling kernel ELF - $(BSP)")
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD) @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Generate the stripped kernel binary ## Generate the stripped kernel binary
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
$(KERNEL_BIN): $(KERNEL_ELF) $(KERNEL_BIN): $(KERNEL_ELF)
$(call color_header, "Generating stripped binary") $(call color_header, "Generating stripped binary")
@$(OBJCOPY_CMD) $(KERNEL_ELF) $(KERNEL_BIN) @$(OBJCOPY_CMD) $(KERNEL_ELF) $(KERNEL_BIN)
@ -159,16 +159,16 @@ $(KERNEL_BIN): $(KERNEL_ELF)
$(call color_progress_prefix, "Size") $(call color_progress_prefix, "Size")
$(call disk_usage_KiB, $(KERNEL_BIN)) $(call disk_usage_KiB, $(KERNEL_BIN))
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Generate the documentation ## Generate the documentation
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
doc: doc:
$(call color_header, "Generating docs") $(call color_header, "Generating docs")
@$(DOC_CMD) --document-private-items --open @$(DOC_CMD) --document-private-items --open
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run the kernel in QEMU ## Run the kernel in QEMU
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board.
qemu: qemu:
@ -182,34 +182,34 @@ qemu: $(KERNEL_BIN)
endif endif
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Push the kernel to the real HW target ## Push the kernel to the real HW target
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
chainboot: $(KERNEL_BIN) chainboot: $(KERNEL_BIN)
@$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(KERNEL_BIN) @$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(KERNEL_BIN)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run clippy ## Run clippy
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
clippy: clippy:
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Clean ## Clean
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
clean: clean:
rm -rf target $(KERNEL_BIN) rm -rf target $(KERNEL_BIN)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run readelf ## Run readelf
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
readelf: $(KERNEL_ELF) readelf: $(KERNEL_ELF)
$(call color_header, "Launching readelf") $(call color_header, "Launching readelf")
@$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF) @$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run objdump ## Run objdump
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
objdump: $(KERNEL_ELF) objdump: $(KERNEL_ELF)
$(call color_header, "Launching objdump") $(call color_header, "Launching objdump")
@$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \ @$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \
@ -217,36 +217,36 @@ objdump: $(KERNEL_ELF)
--section .rodata \ --section .rodata \
$(KERNEL_ELF) | rustfilt $(KERNEL_ELF) | rustfilt
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run nm ## Run nm
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
nm: $(KERNEL_ELF) nm: $(KERNEL_ELF)
$(call color_header, "Launching nm") $(call color_header, "Launching nm")
@$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt @$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Debugging targets ## Debugging targets
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
.PHONY: jtagboot openocd gdb gdb-opt0 .PHONY: jtagboot openocd gdb gdb-opt0
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Push the JTAG boot image to the real HW target ## Push the JTAG boot image to the real HW target
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
jtagboot: jtagboot:
@$(DOCKER_JTAGBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(JTAG_BOOT_IMAGE) @$(DOCKER_JTAGBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(JTAG_BOOT_IMAGE)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Start OpenOCD session ## Start OpenOCD session
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
openocd: openocd:
$(call color_header, "Launching OpenOCD") $(call color_header, "Launching OpenOCD")
@$(DOCKER_OPENOCD) openocd $(OPENOCD_ARG) @$(DOCKER_OPENOCD) openocd $(OPENOCD_ARG)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Start GDB session ## Start GDB session
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
gdb: RUSTC_MISC_ARGS += -C debuginfo=2 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 debuginfo=2 -C opt-level=0
gdb gdb-opt0: $(KERNEL_ELF) gdb gdb-opt0: $(KERNEL_ELF)
@ -255,9 +255,9 @@ gdb gdb-opt0: $(KERNEL_ELF)
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Testing targets ## Testing targets
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
.PHONY: test test_boot .PHONY: test test_boot
ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board.
@ -267,9 +267,9 @@ test_boot test:
else # QEMU is supported. else # QEMU is supported.
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run boot test ## Run boot test
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
test_boot: $(KERNEL_BIN) test_boot: $(KERNEL_BIN)
$(call color_header, "Boot test - $(BSP)") $(call color_header, "Boot test - $(BSP)")
@$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN) @$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN)

@ -6,9 +6,9 @@ include ../common/docker.mk
include ../common/format.mk include ../common/format.mk
include ../common/operating_system.mk include ../common/operating_system.mk
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Optional, user-provided configuration values ## Optional, user-provided configuration values
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
# Default to the RPi3. # Default to the RPi3.
BSP ?= rpi3 BSP ?= rpi3
@ -18,9 +18,9 @@ DEV_SERIAL ?= /dev/ttyUSB0
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## BSP-specific configuration values ## BSP-specific configuration values
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
QEMU_MISSING_STRING = "This board is not yet supported for QEMU." QEMU_MISSING_STRING = "This board is not yet supported for QEMU."
ifeq ($(BSP),rpi3) ifeq ($(BSP),rpi3)
@ -56,9 +56,9 @@ export LD_SCRIPT_PATH
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Targets and Prerequisites ## Targets and Prerequisites
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
KERNEL_MANIFEST = Cargo.toml KERNEL_MANIFEST = Cargo.toml
KERNEL_LINKER_SCRIPT = kernel.ld KERNEL_LINKER_SCRIPT = kernel.ld
LAST_BUILD_CONFIG = target/$(BSP).build_config 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 ## Command building blocks
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
RUSTFLAGS = $(RUSTC_MISC_ARGS) \ RUSTFLAGS = $(RUSTC_MISC_ARGS) \
-C link-arg=--library-path=$(LD_SCRIPT_PATH) \ -C link-arg=--library-path=$(LD_SCRIPT_PATH) \
-C link-arg=--script=$(KERNEL_LINKER_SCRIPT) -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_TEST_DISPATCH = ruby ../common/tests/dispatch.rb
EXEC_MINIPUSH = ruby ../common/serial/minipush.rb EXEC_MINIPUSH = ruby ../common/serial/minipush.rb
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Dockerization ## Dockerization
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial
DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i
DOCKER_ARG_DIR_COMMON = -v $(shell pwd)/../common:/work/common DOCKER_ARG_DIR_COMMON = -v $(shell pwd)/../common:/work/common
@ -126,31 +126,31 @@ endif
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Targets ## Targets
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
.PHONY: all doc qemu chainboot clippy clean readelf objdump nm check .PHONY: all doc qemu chainboot clippy clean readelf objdump nm check
all: $(KERNEL_BIN) all: $(KERNEL_BIN)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Save the configuration as a file, so make understands if it changed. ## Save the configuration as a file, so make understands if it changed.
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
$(LAST_BUILD_CONFIG): $(LAST_BUILD_CONFIG):
@rm -f target/*.build_config @rm -f target/*.build_config
@mkdir -p target @mkdir -p target
@touch $(LAST_BUILD_CONFIG) @touch $(LAST_BUILD_CONFIG)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Compile the kernel ELF ## Compile the kernel ELF
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
$(KERNEL_ELF): $(KERNEL_ELF_DEPS) $(KERNEL_ELF): $(KERNEL_ELF_DEPS)
$(call color_header, "Compiling kernel ELF - $(BSP)") $(call color_header, "Compiling kernel ELF - $(BSP)")
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD) @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Generate the stripped kernel binary ## Generate the stripped kernel binary
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
$(KERNEL_BIN): $(KERNEL_ELF) $(KERNEL_BIN): $(KERNEL_ELF)
$(call color_header, "Generating stripped binary") $(call color_header, "Generating stripped binary")
@$(OBJCOPY_CMD) $(KERNEL_ELF) $(KERNEL_BIN) @$(OBJCOPY_CMD) $(KERNEL_ELF) $(KERNEL_BIN)
@ -159,16 +159,16 @@ $(KERNEL_BIN): $(KERNEL_ELF)
$(call color_progress_prefix, "Size") $(call color_progress_prefix, "Size")
$(call disk_usage_KiB, $(KERNEL_BIN)) $(call disk_usage_KiB, $(KERNEL_BIN))
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Generate the documentation ## Generate the documentation
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
doc: doc:
$(call color_header, "Generating docs") $(call color_header, "Generating docs")
@$(DOC_CMD) --document-private-items --open @$(DOC_CMD) --document-private-items --open
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run the kernel in QEMU ## Run the kernel in QEMU
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board.
qemu: qemu:
@ -182,34 +182,34 @@ qemu: $(KERNEL_BIN)
endif endif
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Push the kernel to the real HW target ## Push the kernel to the real HW target
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
chainboot: $(KERNEL_BIN) chainboot: $(KERNEL_BIN)
@$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(KERNEL_BIN) @$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(KERNEL_BIN)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run clippy ## Run clippy
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
clippy: clippy:
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Clean ## Clean
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
clean: clean:
rm -rf target $(KERNEL_BIN) rm -rf target $(KERNEL_BIN)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run readelf ## Run readelf
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
readelf: $(KERNEL_ELF) readelf: $(KERNEL_ELF)
$(call color_header, "Launching readelf") $(call color_header, "Launching readelf")
@$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF) @$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run objdump ## Run objdump
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
objdump: $(KERNEL_ELF) objdump: $(KERNEL_ELF)
$(call color_header, "Launching objdump") $(call color_header, "Launching objdump")
@$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \ @$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \
@ -217,36 +217,36 @@ objdump: $(KERNEL_ELF)
--section .rodata \ --section .rodata \
$(KERNEL_ELF) | rustfilt $(KERNEL_ELF) | rustfilt
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run nm ## Run nm
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
nm: $(KERNEL_ELF) nm: $(KERNEL_ELF)
$(call color_header, "Launching nm") $(call color_header, "Launching nm")
@$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt @$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Debugging targets ## Debugging targets
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
.PHONY: jtagboot openocd gdb gdb-opt0 .PHONY: jtagboot openocd gdb gdb-opt0
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Push the JTAG boot image to the real HW target ## Push the JTAG boot image to the real HW target
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
jtagboot: jtagboot:
@$(DOCKER_JTAGBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(JTAG_BOOT_IMAGE) @$(DOCKER_JTAGBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(JTAG_BOOT_IMAGE)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Start OpenOCD session ## Start OpenOCD session
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
openocd: openocd:
$(call color_header, "Launching OpenOCD") $(call color_header, "Launching OpenOCD")
@$(DOCKER_OPENOCD) openocd $(OPENOCD_ARG) @$(DOCKER_OPENOCD) openocd $(OPENOCD_ARG)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Start GDB session ## Start GDB session
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
gdb: RUSTC_MISC_ARGS += -C debuginfo=2 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 debuginfo=2 -C opt-level=0
gdb gdb-opt0: $(KERNEL_ELF) gdb gdb-opt0: $(KERNEL_ELF)
@ -255,9 +255,9 @@ gdb gdb-opt0: $(KERNEL_ELF)
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Testing targets ## Testing targets
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
.PHONY: test test_boot .PHONY: test test_boot
ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board.
@ -267,9 +267,9 @@ test_boot test:
else # QEMU is supported. else # QEMU is supported.
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run boot test ## Run boot test
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
test_boot: $(KERNEL_BIN) test_boot: $(KERNEL_BIN)
$(call color_header, "Boot test - $(BSP)") $(call color_header, "Boot test - $(BSP)")
@$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN) @$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN)

@ -6,9 +6,9 @@ include ../common/docker.mk
include ../common/format.mk include ../common/format.mk
include ../common/operating_system.mk include ../common/operating_system.mk
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Optional, user-provided configuration values ## Optional, user-provided configuration values
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
# Default to the RPi3. # Default to the RPi3.
BSP ?= rpi3 BSP ?= rpi3
@ -25,9 +25,9 @@ endif
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## BSP-specific configuration values ## BSP-specific configuration values
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
QEMU_MISSING_STRING = "This board is not yet supported for QEMU." QEMU_MISSING_STRING = "This board is not yet supported for QEMU."
ifeq ($(BSP),rpi3) ifeq ($(BSP),rpi3)
@ -65,9 +65,9 @@ export LD_SCRIPT_PATH
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Targets and Prerequisites ## Targets and Prerequisites
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
KERNEL_MANIFEST = kernel/Cargo.toml KERNEL_MANIFEST = kernel/Cargo.toml
KERNEL_LINKER_SCRIPT = kernel.ld KERNEL_LINKER_SCRIPT = kernel.ld
LAST_BUILD_CONFIG = target/$(BSP).build_config 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 ## Command building blocks
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
RUSTFLAGS = $(RUSTC_MISC_ARGS) \ RUSTFLAGS = $(RUSTC_MISC_ARGS) \
-C link-arg=--library-path=$(LD_SCRIPT_PATH) \ -C link-arg=--library-path=$(LD_SCRIPT_PATH) \
-C link-arg=--script=$(KERNEL_LINKER_SCRIPT) -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_TEST_DISPATCH = ruby ../common/tests/dispatch.rb
EXEC_MINIPUSH = ruby ../common/serial/minipush.rb EXEC_MINIPUSH = ruby ../common/serial/minipush.rb
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Dockerization ## Dockerization
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial
DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i
DOCKER_ARG_DIR_COMMON = -v $(shell pwd)/../common:/work/common DOCKER_ARG_DIR_COMMON = -v $(shell pwd)/../common:/work/common
@ -136,31 +136,31 @@ endif
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Targets ## Targets
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
.PHONY: all doc qemu chainboot clippy clean readelf objdump nm check .PHONY: all doc qemu chainboot clippy clean readelf objdump nm check
all: $(KERNEL_BIN) all: $(KERNEL_BIN)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Save the configuration as a file, so make understands if it changed. ## Save the configuration as a file, so make understands if it changed.
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
$(LAST_BUILD_CONFIG): $(LAST_BUILD_CONFIG):
@rm -f target/*.build_config @rm -f target/*.build_config
@mkdir -p target @mkdir -p target
@touch $(LAST_BUILD_CONFIG) @touch $(LAST_BUILD_CONFIG)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Compile the kernel ELF ## Compile the kernel ELF
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
$(KERNEL_ELF): $(KERNEL_ELF_DEPS) $(KERNEL_ELF): $(KERNEL_ELF_DEPS)
$(call color_header, "Compiling kernel ELF - $(BSP)") $(call color_header, "Compiling kernel ELF - $(BSP)")
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD) @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Generate the stripped kernel binary ## Generate the stripped kernel binary
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
$(KERNEL_BIN): $(KERNEL_ELF) $(KERNEL_BIN): $(KERNEL_ELF)
$(call color_header, "Generating stripped binary") $(call color_header, "Generating stripped binary")
@$(OBJCOPY_CMD) $(KERNEL_ELF) $(KERNEL_BIN) @$(OBJCOPY_CMD) $(KERNEL_ELF) $(KERNEL_BIN)
@ -169,16 +169,16 @@ $(KERNEL_BIN): $(KERNEL_ELF)
$(call color_progress_prefix, "Size") $(call color_progress_prefix, "Size")
$(call disk_usage_KiB, $(KERNEL_BIN)) $(call disk_usage_KiB, $(KERNEL_BIN))
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Generate the documentation ## Generate the documentation
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
doc: doc:
$(call color_header, "Generating docs") $(call color_header, "Generating docs")
@$(DOC_CMD) --document-private-items --open @$(DOC_CMD) --document-private-items --open
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run the kernel in QEMU ## Run the kernel in QEMU
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board.
qemu: qemu:
@ -192,36 +192,36 @@ qemu: $(KERNEL_BIN)
endif endif
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Push the kernel to the real HW target ## Push the kernel to the real HW target
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
chainboot: $(KERNEL_BIN) chainboot: $(KERNEL_BIN)
@$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(KERNEL_BIN) @$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(KERNEL_BIN)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run clippy ## Run clippy
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
clippy: clippy:
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD)
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) --features test_build --tests \ @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) --features test_build --tests \
--manifest-path $(KERNEL_MANIFEST) --manifest-path $(KERNEL_MANIFEST)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Clean ## Clean
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
clean: clean:
rm -rf target $(KERNEL_BIN) rm -rf target $(KERNEL_BIN)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run readelf ## Run readelf
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
readelf: $(KERNEL_ELF) readelf: $(KERNEL_ELF)
$(call color_header, "Launching readelf") $(call color_header, "Launching readelf")
@$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF) @$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run objdump ## Run objdump
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
objdump: $(KERNEL_ELF) objdump: $(KERNEL_ELF)
$(call color_header, "Launching objdump") $(call color_header, "Launching objdump")
@$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \ @$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \
@ -229,36 +229,36 @@ objdump: $(KERNEL_ELF)
--section .rodata \ --section .rodata \
$(KERNEL_ELF) | rustfilt $(KERNEL_ELF) | rustfilt
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run nm ## Run nm
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
nm: $(KERNEL_ELF) nm: $(KERNEL_ELF)
$(call color_header, "Launching nm") $(call color_header, "Launching nm")
@$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt @$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Debugging targets ## Debugging targets
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
.PHONY: jtagboot openocd gdb gdb-opt0 .PHONY: jtagboot openocd gdb gdb-opt0
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Push the JTAG boot image to the real HW target ## Push the JTAG boot image to the real HW target
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
jtagboot: jtagboot:
@$(DOCKER_JTAGBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(JTAG_BOOT_IMAGE) @$(DOCKER_JTAGBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(JTAG_BOOT_IMAGE)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Start OpenOCD session ## Start OpenOCD session
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
openocd: openocd:
$(call color_header, "Launching OpenOCD") $(call color_header, "Launching OpenOCD")
@$(DOCKER_OPENOCD) openocd $(OPENOCD_ARG) @$(DOCKER_OPENOCD) openocd $(OPENOCD_ARG)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Start GDB session ## Start GDB session
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
gdb: RUSTC_MISC_ARGS += -C debuginfo=2 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 debuginfo=2 -C opt-level=0
gdb gdb-opt0: $(KERNEL_ELF) gdb gdb-opt0: $(KERNEL_ELF)
@ -267,9 +267,9 @@ gdb gdb-opt0: $(KERNEL_ELF)
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Testing targets ## Testing targets
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
.PHONY: test test_boot test_unit test_integration .PHONY: test test_boot test_unit test_integration
test_unit test_integration: FEATURES += --features test_build test_unit test_integration: FEATURES += --features test_build
@ -281,16 +281,16 @@ test_boot test_unit test_integration test:
else # QEMU is supported. else # QEMU is supported.
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run boot test ## Run boot test
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
test_boot: $(KERNEL_BIN) test_boot: $(KERNEL_BIN)
$(call color_header, "Boot test - $(BSP)") $(call color_header, "Boot test - $(BSP)")
@$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN) @$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Helpers for unit and integration test targets ## Helpers for unit and integration test targets
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
define KERNEL_TEST_RUNNER define KERNEL_TEST_RUNNER
#!/usr/bin/env bash #!/usr/bin/env bash
@ -313,17 +313,17 @@ define test_prepare
@chmod +x target/kernel_test_runner.sh @chmod +x target/kernel_test_runner.sh
endef endef
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run unit test(s) ## Run unit test(s)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
test_unit: test_unit:
$(call color_header, "Compiling unit test(s) - $(BSP)") $(call color_header, "Compiling unit test(s) - $(BSP)")
$(call test_prepare) $(call test_prepare)
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(TEST_CMD) --lib @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(TEST_CMD) --lib
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run integration test(s) ## Run integration test(s)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
test_integration: test_integration:
$(call color_header, "Compiling integration test(s) - $(BSP)") $(call color_header, "Compiling integration test(s) - $(BSP)")
$(call test_prepare) $(call test_prepare)

@ -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: `make test_*` targets is called:
```Makefile ```Makefile
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Helpers for unit and integration test targets ## Helpers for unit and integration test targets
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
define KERNEL_TEST_RUNNER define KERNEL_TEST_RUNNER
#!/usr/bin/env bash #!/usr/bin/env bash
@ -434,9 +434,9 @@ define test_prepare
@chmod +x target/kernel_test_runner.sh @chmod +x target/kernel_test_runner.sh
endef endef
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run unit test(s) ## Run unit test(s)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
test_unit: test_unit:
$(call color_header, "Compiling unit test(s) - $(BSP)") $(call color_header, "Compiling unit test(s) - $(BSP)")
$(call test_prepare) $(call test_prepare)

@ -40,9 +40,9 @@ class RxStatisticsTest < SubtestBase
end end
end end
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Test registration ## Test registration
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
def subtest_collection def subtest_collection
[TxRxHandshakeTest.new, TxStatisticsTest.new, RxStatisticsTest.new] [TxRxHandshakeTest.new, TxStatisticsTest.new, RxStatisticsTest.new]
end end

@ -17,9 +17,9 @@ class ExceptionRestoreTest < SubtestBase
end end
end end
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Test registration ## Test registration
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
def subtest_collection def subtest_collection
[ExceptionRestoreTest.new] [ExceptionRestoreTest.new]
end end

@ -6,9 +6,9 @@ include ../common/docker.mk
include ../common/format.mk include ../common/format.mk
include ../common/operating_system.mk include ../common/operating_system.mk
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Optional, user-provided configuration values ## Optional, user-provided configuration values
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
# Default to the RPi3. # Default to the RPi3.
BSP ?= rpi3 BSP ?= rpi3
@ -25,9 +25,9 @@ endif
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## BSP-specific configuration values ## BSP-specific configuration values
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
QEMU_MISSING_STRING = "This board is not yet supported for QEMU." QEMU_MISSING_STRING = "This board is not yet supported for QEMU."
ifeq ($(BSP),rpi3) ifeq ($(BSP),rpi3)
@ -65,9 +65,9 @@ export LD_SCRIPT_PATH
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Targets and Prerequisites ## Targets and Prerequisites
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
KERNEL_MANIFEST = kernel/Cargo.toml KERNEL_MANIFEST = kernel/Cargo.toml
KERNEL_LINKER_SCRIPT = kernel.ld KERNEL_LINKER_SCRIPT = kernel.ld
LAST_BUILD_CONFIG = target/$(BSP).build_config 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 ## Command building blocks
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
RUSTFLAGS = $(RUSTC_MISC_ARGS) \ RUSTFLAGS = $(RUSTC_MISC_ARGS) \
-C link-arg=--library-path=$(LD_SCRIPT_PATH) \ -C link-arg=--library-path=$(LD_SCRIPT_PATH) \
-C link-arg=--script=$(KERNEL_LINKER_SCRIPT) -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_TEST_DISPATCH = ruby ../common/tests/dispatch.rb
EXEC_MINIPUSH = ruby ../common/serial/minipush.rb EXEC_MINIPUSH = ruby ../common/serial/minipush.rb
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Dockerization ## Dockerization
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial
DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i
DOCKER_ARG_DIR_COMMON = -v $(shell pwd)/../common:/work/common DOCKER_ARG_DIR_COMMON = -v $(shell pwd)/../common:/work/common
@ -136,31 +136,31 @@ endif
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Targets ## Targets
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
.PHONY: all doc qemu chainboot clippy clean readelf objdump nm check .PHONY: all doc qemu chainboot clippy clean readelf objdump nm check
all: $(KERNEL_BIN) all: $(KERNEL_BIN)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Save the configuration as a file, so make understands if it changed. ## Save the configuration as a file, so make understands if it changed.
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
$(LAST_BUILD_CONFIG): $(LAST_BUILD_CONFIG):
@rm -f target/*.build_config @rm -f target/*.build_config
@mkdir -p target @mkdir -p target
@touch $(LAST_BUILD_CONFIG) @touch $(LAST_BUILD_CONFIG)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Compile the kernel ELF ## Compile the kernel ELF
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
$(KERNEL_ELF): $(KERNEL_ELF_DEPS) $(KERNEL_ELF): $(KERNEL_ELF_DEPS)
$(call color_header, "Compiling kernel ELF - $(BSP)") $(call color_header, "Compiling kernel ELF - $(BSP)")
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD) @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Generate the stripped kernel binary ## Generate the stripped kernel binary
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
$(KERNEL_BIN): $(KERNEL_ELF) $(KERNEL_BIN): $(KERNEL_ELF)
$(call color_header, "Generating stripped binary") $(call color_header, "Generating stripped binary")
@$(OBJCOPY_CMD) $(KERNEL_ELF) $(KERNEL_BIN) @$(OBJCOPY_CMD) $(KERNEL_ELF) $(KERNEL_BIN)
@ -169,16 +169,16 @@ $(KERNEL_BIN): $(KERNEL_ELF)
$(call color_progress_prefix, "Size") $(call color_progress_prefix, "Size")
$(call disk_usage_KiB, $(KERNEL_BIN)) $(call disk_usage_KiB, $(KERNEL_BIN))
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Generate the documentation ## Generate the documentation
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
doc: doc:
$(call color_header, "Generating docs") $(call color_header, "Generating docs")
@$(DOC_CMD) --document-private-items --open @$(DOC_CMD) --document-private-items --open
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run the kernel in QEMU ## Run the kernel in QEMU
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board.
qemu: qemu:
@ -192,36 +192,36 @@ qemu: $(KERNEL_BIN)
endif endif
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Push the kernel to the real HW target ## Push the kernel to the real HW target
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
chainboot: $(KERNEL_BIN) chainboot: $(KERNEL_BIN)
@$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(KERNEL_BIN) @$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(KERNEL_BIN)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run clippy ## Run clippy
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
clippy: clippy:
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD)
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) --features test_build --tests \ @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) --features test_build --tests \
--manifest-path $(KERNEL_MANIFEST) --manifest-path $(KERNEL_MANIFEST)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Clean ## Clean
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
clean: clean:
rm -rf target $(KERNEL_BIN) rm -rf target $(KERNEL_BIN)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run readelf ## Run readelf
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
readelf: $(KERNEL_ELF) readelf: $(KERNEL_ELF)
$(call color_header, "Launching readelf") $(call color_header, "Launching readelf")
@$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF) @$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run objdump ## Run objdump
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
objdump: $(KERNEL_ELF) objdump: $(KERNEL_ELF)
$(call color_header, "Launching objdump") $(call color_header, "Launching objdump")
@$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \ @$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \
@ -229,36 +229,36 @@ objdump: $(KERNEL_ELF)
--section .rodata \ --section .rodata \
$(KERNEL_ELF) | rustfilt $(KERNEL_ELF) | rustfilt
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run nm ## Run nm
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
nm: $(KERNEL_ELF) nm: $(KERNEL_ELF)
$(call color_header, "Launching nm") $(call color_header, "Launching nm")
@$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt @$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Debugging targets ## Debugging targets
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
.PHONY: jtagboot openocd gdb gdb-opt0 .PHONY: jtagboot openocd gdb gdb-opt0
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Push the JTAG boot image to the real HW target ## Push the JTAG boot image to the real HW target
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
jtagboot: jtagboot:
@$(DOCKER_JTAGBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(JTAG_BOOT_IMAGE) @$(DOCKER_JTAGBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(JTAG_BOOT_IMAGE)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Start OpenOCD session ## Start OpenOCD session
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
openocd: openocd:
$(call color_header, "Launching OpenOCD") $(call color_header, "Launching OpenOCD")
@$(DOCKER_OPENOCD) openocd $(OPENOCD_ARG) @$(DOCKER_OPENOCD) openocd $(OPENOCD_ARG)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Start GDB session ## Start GDB session
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
gdb: RUSTC_MISC_ARGS += -C debuginfo=2 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 debuginfo=2 -C opt-level=0
gdb gdb-opt0: $(KERNEL_ELF) gdb gdb-opt0: $(KERNEL_ELF)
@ -267,9 +267,9 @@ gdb gdb-opt0: $(KERNEL_ELF)
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Testing targets ## Testing targets
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
.PHONY: test test_boot test_unit test_integration .PHONY: test test_boot test_unit test_integration
test_unit test_integration: FEATURES += --features test_build test_unit test_integration: FEATURES += --features test_build
@ -281,16 +281,16 @@ test_boot test_unit test_integration test:
else # QEMU is supported. else # QEMU is supported.
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run boot test ## Run boot test
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
test_boot: $(KERNEL_BIN) test_boot: $(KERNEL_BIN)
$(call color_header, "Boot test - $(BSP)") $(call color_header, "Boot test - $(BSP)")
@$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN) @$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Helpers for unit and integration test targets ## Helpers for unit and integration test targets
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
define KERNEL_TEST_RUNNER define KERNEL_TEST_RUNNER
#!/usr/bin/env bash #!/usr/bin/env bash
@ -313,17 +313,17 @@ define test_prepare
@chmod +x target/kernel_test_runner.sh @chmod +x target/kernel_test_runner.sh
endef endef
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run unit test(s) ## Run unit test(s)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
test_unit: test_unit:
$(call color_header, "Compiling unit test(s) - $(BSP)") $(call color_header, "Compiling unit test(s) - $(BSP)")
$(call test_prepare) $(call test_prepare)
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(TEST_CMD) --lib @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(TEST_CMD) --lib
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run integration test(s) ## Run integration test(s)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
test_integration: test_integration:
$(call color_header, "Compiling integration test(s) - $(BSP)") $(call color_header, "Compiling integration test(s) - $(BSP)")
$(call test_prepare) $(call test_prepare)

@ -40,9 +40,9 @@ class RxStatisticsTest < SubtestBase
end end
end end
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Test registration ## Test registration
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
def subtest_collection def subtest_collection
[TxRxHandshakeTest.new, TxStatisticsTest.new, RxStatisticsTest.new] [TxRxHandshakeTest.new, TxStatisticsTest.new, RxStatisticsTest.new]
end end

@ -17,9 +17,9 @@ class ExceptionRestoreTest < SubtestBase
end end
end end
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Test registration ## Test registration
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
def subtest_collection def subtest_collection
[ExceptionRestoreTest.new] [ExceptionRestoreTest.new]
end end

@ -6,9 +6,9 @@ include ../common/docker.mk
include ../common/format.mk include ../common/format.mk
include ../common/operating_system.mk include ../common/operating_system.mk
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Optional, user-provided configuration values ## Optional, user-provided configuration values
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
# Default to the RPi3. # Default to the RPi3.
BSP ?= rpi3 BSP ?= rpi3
@ -25,9 +25,9 @@ endif
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## BSP-specific configuration values ## BSP-specific configuration values
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
QEMU_MISSING_STRING = "This board is not yet supported for QEMU." QEMU_MISSING_STRING = "This board is not yet supported for QEMU."
ifeq ($(BSP),rpi3) ifeq ($(BSP),rpi3)
@ -65,9 +65,9 @@ export LD_SCRIPT_PATH
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Targets and Prerequisites ## Targets and Prerequisites
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
KERNEL_MANIFEST = kernel/Cargo.toml KERNEL_MANIFEST = kernel/Cargo.toml
KERNEL_LINKER_SCRIPT = kernel.ld KERNEL_LINKER_SCRIPT = kernel.ld
LAST_BUILD_CONFIG = target/$(BSP).build_config 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 ## Command building blocks
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
RUSTFLAGS = $(RUSTC_MISC_ARGS) \ RUSTFLAGS = $(RUSTC_MISC_ARGS) \
-C link-arg=--library-path=$(LD_SCRIPT_PATH) \ -C link-arg=--library-path=$(LD_SCRIPT_PATH) \
-C link-arg=--script=$(KERNEL_LINKER_SCRIPT) -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_TEST_DISPATCH = ruby ../common/tests/dispatch.rb
EXEC_MINIPUSH = ruby ../common/serial/minipush.rb EXEC_MINIPUSH = ruby ../common/serial/minipush.rb
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Dockerization ## Dockerization
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial
DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i
DOCKER_ARG_DIR_COMMON = -v $(shell pwd)/../common:/work/common DOCKER_ARG_DIR_COMMON = -v $(shell pwd)/../common:/work/common
@ -136,31 +136,31 @@ endif
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Targets ## Targets
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
.PHONY: all doc qemu chainboot clippy clean readelf objdump nm check .PHONY: all doc qemu chainboot clippy clean readelf objdump nm check
all: $(KERNEL_BIN) all: $(KERNEL_BIN)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Save the configuration as a file, so make understands if it changed. ## Save the configuration as a file, so make understands if it changed.
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
$(LAST_BUILD_CONFIG): $(LAST_BUILD_CONFIG):
@rm -f target/*.build_config @rm -f target/*.build_config
@mkdir -p target @mkdir -p target
@touch $(LAST_BUILD_CONFIG) @touch $(LAST_BUILD_CONFIG)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Compile the kernel ELF ## Compile the kernel ELF
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
$(KERNEL_ELF): $(KERNEL_ELF_DEPS) $(KERNEL_ELF): $(KERNEL_ELF_DEPS)
$(call color_header, "Compiling kernel ELF - $(BSP)") $(call color_header, "Compiling kernel ELF - $(BSP)")
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD) @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Generate the stripped kernel binary ## Generate the stripped kernel binary
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
$(KERNEL_BIN): $(KERNEL_ELF) $(KERNEL_BIN): $(KERNEL_ELF)
$(call color_header, "Generating stripped binary") $(call color_header, "Generating stripped binary")
@$(OBJCOPY_CMD) $(KERNEL_ELF) $(KERNEL_BIN) @$(OBJCOPY_CMD) $(KERNEL_ELF) $(KERNEL_BIN)
@ -169,16 +169,16 @@ $(KERNEL_BIN): $(KERNEL_ELF)
$(call color_progress_prefix, "Size") $(call color_progress_prefix, "Size")
$(call disk_usage_KiB, $(KERNEL_BIN)) $(call disk_usage_KiB, $(KERNEL_BIN))
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Generate the documentation ## Generate the documentation
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
doc: doc:
$(call color_header, "Generating docs") $(call color_header, "Generating docs")
@$(DOC_CMD) --document-private-items --open @$(DOC_CMD) --document-private-items --open
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run the kernel in QEMU ## Run the kernel in QEMU
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board.
qemu: qemu:
@ -192,36 +192,36 @@ qemu: $(KERNEL_BIN)
endif endif
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Push the kernel to the real HW target ## Push the kernel to the real HW target
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
chainboot: $(KERNEL_BIN) chainboot: $(KERNEL_BIN)
@$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(KERNEL_BIN) @$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(KERNEL_BIN)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run clippy ## Run clippy
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
clippy: clippy:
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD)
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) --features test_build --tests \ @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) --features test_build --tests \
--manifest-path $(KERNEL_MANIFEST) --manifest-path $(KERNEL_MANIFEST)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Clean ## Clean
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
clean: clean:
rm -rf target $(KERNEL_BIN) rm -rf target $(KERNEL_BIN)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run readelf ## Run readelf
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
readelf: $(KERNEL_ELF) readelf: $(KERNEL_ELF)
$(call color_header, "Launching readelf") $(call color_header, "Launching readelf")
@$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF) @$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run objdump ## Run objdump
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
objdump: $(KERNEL_ELF) objdump: $(KERNEL_ELF)
$(call color_header, "Launching objdump") $(call color_header, "Launching objdump")
@$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \ @$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \
@ -229,36 +229,36 @@ objdump: $(KERNEL_ELF)
--section .rodata \ --section .rodata \
$(KERNEL_ELF) | rustfilt $(KERNEL_ELF) | rustfilt
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run nm ## Run nm
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
nm: $(KERNEL_ELF) nm: $(KERNEL_ELF)
$(call color_header, "Launching nm") $(call color_header, "Launching nm")
@$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt @$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Debugging targets ## Debugging targets
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
.PHONY: jtagboot openocd gdb gdb-opt0 .PHONY: jtagboot openocd gdb gdb-opt0
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Push the JTAG boot image to the real HW target ## Push the JTAG boot image to the real HW target
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
jtagboot: jtagboot:
@$(DOCKER_JTAGBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(JTAG_BOOT_IMAGE) @$(DOCKER_JTAGBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(JTAG_BOOT_IMAGE)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Start OpenOCD session ## Start OpenOCD session
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
openocd: openocd:
$(call color_header, "Launching OpenOCD") $(call color_header, "Launching OpenOCD")
@$(DOCKER_OPENOCD) openocd $(OPENOCD_ARG) @$(DOCKER_OPENOCD) openocd $(OPENOCD_ARG)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Start GDB session ## Start GDB session
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
gdb: RUSTC_MISC_ARGS += -C debuginfo=2 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 debuginfo=2 -C opt-level=0
gdb gdb-opt0: $(KERNEL_ELF) gdb gdb-opt0: $(KERNEL_ELF)
@ -267,9 +267,9 @@ gdb gdb-opt0: $(KERNEL_ELF)
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Testing targets ## Testing targets
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
.PHONY: test test_boot test_unit test_integration .PHONY: test test_boot test_unit test_integration
test_unit test_integration: FEATURES += --features test_build test_unit test_integration: FEATURES += --features test_build
@ -281,16 +281,16 @@ test_boot test_unit test_integration test:
else # QEMU is supported. else # QEMU is supported.
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run boot test ## Run boot test
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
test_boot: $(KERNEL_BIN) test_boot: $(KERNEL_BIN)
$(call color_header, "Boot test - $(BSP)") $(call color_header, "Boot test - $(BSP)")
@$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN) @$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Helpers for unit and integration test targets ## Helpers for unit and integration test targets
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
define KERNEL_TEST_RUNNER define KERNEL_TEST_RUNNER
#!/usr/bin/env bash #!/usr/bin/env bash
@ -313,17 +313,17 @@ define test_prepare
@chmod +x target/kernel_test_runner.sh @chmod +x target/kernel_test_runner.sh
endef endef
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run unit test(s) ## Run unit test(s)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
test_unit: test_unit:
$(call color_header, "Compiling unit test(s) - $(BSP)") $(call color_header, "Compiling unit test(s) - $(BSP)")
$(call test_prepare) $(call test_prepare)
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(TEST_CMD) --lib @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(TEST_CMD) --lib
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run integration test(s) ## Run integration test(s)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
test_integration: test_integration:
$(call color_header, "Compiling integration test(s) - $(BSP)") $(call color_header, "Compiling integration test(s) - $(BSP)")
$(call test_prepare) $(call test_prepare)

@ -40,9 +40,9 @@ class RxStatisticsTest < SubtestBase
end end
end end
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Test registration ## Test registration
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
def subtest_collection def subtest_collection
[TxRxHandshakeTest.new, TxStatisticsTest.new, RxStatisticsTest.new] [TxRxHandshakeTest.new, TxStatisticsTest.new, RxStatisticsTest.new]
end end

@ -17,9 +17,9 @@ class ExceptionRestoreTest < SubtestBase
end end
end end
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Test registration ## Test registration
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
def subtest_collection def subtest_collection
[ExceptionRestoreTest.new] [ExceptionRestoreTest.new]
end end

@ -6,9 +6,9 @@ include ../common/docker.mk
include ../common/format.mk include ../common/format.mk
include ../common/operating_system.mk include ../common/operating_system.mk
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Optional, user-provided configuration values ## Optional, user-provided configuration values
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
# Default to the RPi3. # Default to the RPi3.
BSP ?= rpi3 BSP ?= rpi3
@ -25,9 +25,9 @@ endif
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## BSP-specific configuration values ## BSP-specific configuration values
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
QEMU_MISSING_STRING = "This board is not yet supported for QEMU." QEMU_MISSING_STRING = "This board is not yet supported for QEMU."
ifeq ($(BSP),rpi3) ifeq ($(BSP),rpi3)
@ -65,9 +65,9 @@ export LD_SCRIPT_PATH
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Targets and Prerequisites ## Targets and Prerequisites
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
KERNEL_MANIFEST = kernel/Cargo.toml KERNEL_MANIFEST = kernel/Cargo.toml
KERNEL_LINKER_SCRIPT = kernel.ld KERNEL_LINKER_SCRIPT = kernel.ld
LAST_BUILD_CONFIG = target/$(BSP).build_config 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 # 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) KERNEL_ELF_RAW_DEPS = $(filter-out %: ,$(file < $(KERNEL_ELF_RAW).d)) $(KERNEL_MANIFEST) $(LAST_BUILD_CONFIG)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Translation tables ## Translation tables
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
TT_TOOL_PATH = tools/translation_table_tool TT_TOOL_PATH = tools/translation_table_tool
KERNEL_ELF_TTABLES = target/$(TARGET)/release/kernel+ttables KERNEL_ELF_TTABLES = target/$(TARGET)/release/kernel+ttables
@ -89,9 +89,9 @@ KERNEL_ELF = $(KERNEL_ELF_TTABLES)
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Command building blocks ## Command building blocks
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
RUSTFLAGS = $(RUSTC_MISC_ARGS) \ RUSTFLAGS = $(RUSTC_MISC_ARGS) \
-C link-arg=--library-path=$(LD_SCRIPT_PATH) \ -C link-arg=--library-path=$(LD_SCRIPT_PATH) \
-C link-arg=--script=$(KERNEL_LINKER_SCRIPT) -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_TEST_DISPATCH = ruby ../common/tests/dispatch.rb
EXEC_MINIPUSH = ruby ../common/serial/minipush.rb EXEC_MINIPUSH = ruby ../common/serial/minipush.rb
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Dockerization ## Dockerization
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial
DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i
DOCKER_ARG_DIR_COMMON = -v $(shell pwd)/../common:/work/common DOCKER_ARG_DIR_COMMON = -v $(shell pwd)/../common:/work/common
@ -147,39 +147,39 @@ endif
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Targets ## Targets
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
.PHONY: all doc qemu chainboot clippy clean readelf objdump nm check .PHONY: all doc qemu chainboot clippy clean readelf objdump nm check
all: $(KERNEL_BIN) all: $(KERNEL_BIN)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Save the configuration as a file, so make understands if it changed. ## Save the configuration as a file, so make understands if it changed.
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
$(LAST_BUILD_CONFIG): $(LAST_BUILD_CONFIG):
@rm -f target/*.build_config @rm -f target/*.build_config
@mkdir -p target @mkdir -p target
@touch $(LAST_BUILD_CONFIG) @touch $(LAST_BUILD_CONFIG)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Compile the kernel ELF ## Compile the kernel ELF
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
$(KERNEL_ELF_RAW): $(KERNEL_ELF_RAW_DEPS) $(KERNEL_ELF_RAW): $(KERNEL_ELF_RAW_DEPS)
$(call color_header, "Compiling kernel ELF - $(BSP)") $(call color_header, "Compiling kernel ELF - $(BSP)")
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD) @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Precompute the kernel translation tables and patch them into the kernel ELF ## Precompute the kernel translation tables and patch them into the kernel ELF
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
$(KERNEL_ELF_TTABLES): $(KERNEL_ELF_TTABLES_DEPS) $(KERNEL_ELF_TTABLES): $(KERNEL_ELF_TTABLES_DEPS)
$(call color_header, "Precomputing kernel translation tables and patching kernel ELF") $(call color_header, "Precomputing kernel translation tables and patching kernel ELF")
@cp $(KERNEL_ELF_RAW) $(KERNEL_ELF_TTABLES) @cp $(KERNEL_ELF_RAW) $(KERNEL_ELF_TTABLES)
@$(DOCKER_TOOLS) $(EXEC_TT_TOOL) $(BSP) $(KERNEL_ELF_TTABLES) @$(DOCKER_TOOLS) $(EXEC_TT_TOOL) $(BSP) $(KERNEL_ELF_TTABLES)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Generate the stripped kernel binary ## Generate the stripped kernel binary
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
$(KERNEL_BIN): $(KERNEL_ELF_TTABLES) $(KERNEL_BIN): $(KERNEL_ELF_TTABLES)
$(call color_header, "Generating stripped binary") $(call color_header, "Generating stripped binary")
@$(OBJCOPY_CMD) $(KERNEL_ELF_TTABLES) $(KERNEL_BIN) @$(OBJCOPY_CMD) $(KERNEL_ELF_TTABLES) $(KERNEL_BIN)
@ -188,16 +188,16 @@ $(KERNEL_BIN): $(KERNEL_ELF_TTABLES)
$(call color_progress_prefix, "Size") $(call color_progress_prefix, "Size")
$(call disk_usage_KiB, $(KERNEL_BIN)) $(call disk_usage_KiB, $(KERNEL_BIN))
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Generate the documentation ## Generate the documentation
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
doc: doc:
$(call color_header, "Generating docs") $(call color_header, "Generating docs")
@$(DOC_CMD) --document-private-items --open @$(DOC_CMD) --document-private-items --open
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run the kernel in QEMU ## Run the kernel in QEMU
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board.
qemu: qemu:
@ -211,36 +211,36 @@ qemu: $(KERNEL_BIN)
endif endif
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Push the kernel to the real HW target ## Push the kernel to the real HW target
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
chainboot: $(KERNEL_BIN) chainboot: $(KERNEL_BIN)
@$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(KERNEL_BIN) @$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(KERNEL_BIN)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run clippy ## Run clippy
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
clippy: clippy:
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD)
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) --features test_build --tests \ @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) --features test_build --tests \
--manifest-path $(KERNEL_MANIFEST) --manifest-path $(KERNEL_MANIFEST)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Clean ## Clean
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
clean: clean:
rm -rf target $(KERNEL_BIN) rm -rf target $(KERNEL_BIN)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run readelf ## Run readelf
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
readelf: $(KERNEL_ELF) readelf: $(KERNEL_ELF)
$(call color_header, "Launching readelf") $(call color_header, "Launching readelf")
@$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF) @$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run objdump ## Run objdump
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
objdump: $(KERNEL_ELF) objdump: $(KERNEL_ELF)
$(call color_header, "Launching objdump") $(call color_header, "Launching objdump")
@$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \ @$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \
@ -248,36 +248,36 @@ objdump: $(KERNEL_ELF)
--section .rodata \ --section .rodata \
$(KERNEL_ELF) | rustfilt $(KERNEL_ELF) | rustfilt
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run nm ## Run nm
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
nm: $(KERNEL_ELF) nm: $(KERNEL_ELF)
$(call color_header, "Launching nm") $(call color_header, "Launching nm")
@$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt @$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Debugging targets ## Debugging targets
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
.PHONY: jtagboot openocd gdb gdb-opt0 .PHONY: jtagboot openocd gdb gdb-opt0
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Push the JTAG boot image to the real HW target ## Push the JTAG boot image to the real HW target
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
jtagboot: jtagboot:
@$(DOCKER_JTAGBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(JTAG_BOOT_IMAGE) @$(DOCKER_JTAGBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(JTAG_BOOT_IMAGE)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Start OpenOCD session ## Start OpenOCD session
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
openocd: openocd:
$(call color_header, "Launching OpenOCD") $(call color_header, "Launching OpenOCD")
@$(DOCKER_OPENOCD) openocd $(OPENOCD_ARG) @$(DOCKER_OPENOCD) openocd $(OPENOCD_ARG)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Start GDB session ## Start GDB session
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
gdb: RUSTC_MISC_ARGS += -C debuginfo=2 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 debuginfo=2 -C opt-level=0
gdb gdb-opt0: $(KERNEL_ELF) gdb gdb-opt0: $(KERNEL_ELF)
@ -286,9 +286,9 @@ gdb gdb-opt0: $(KERNEL_ELF)
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Testing targets ## Testing targets
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
.PHONY: test test_boot test_unit test_integration .PHONY: test test_boot test_unit test_integration
test_unit test_integration: FEATURES += --features test_build test_unit test_integration: FEATURES += --features test_build
@ -300,16 +300,16 @@ test_boot test_unit test_integration test:
else # QEMU is supported. else # QEMU is supported.
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run boot test ## Run boot test
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
test_boot: $(KERNEL_BIN) test_boot: $(KERNEL_BIN)
$(call color_header, "Boot test - $(BSP)") $(call color_header, "Boot test - $(BSP)")
@$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN) @$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Helpers for unit and integration test targets ## Helpers for unit and integration test targets
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
define KERNEL_TEST_RUNNER define KERNEL_TEST_RUNNER
#!/usr/bin/env bash #!/usr/bin/env bash
@ -333,17 +333,17 @@ define test_prepare
@chmod +x target/kernel_test_runner.sh @chmod +x target/kernel_test_runner.sh
endef endef
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run unit test(s) ## Run unit test(s)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
test_unit: test_unit:
$(call color_header, "Compiling unit test(s) - $(BSP)") $(call color_header, "Compiling unit test(s) - $(BSP)")
$(call test_prepare) $(call test_prepare)
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(TEST_CMD) --lib @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(TEST_CMD) --lib
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run integration test(s) ## Run integration test(s)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
test_integration: test_integration:
$(call color_header, "Compiling integration test(s) - $(BSP)") $(call color_header, "Compiling integration test(s) - $(BSP)")
$(call test_prepare) $(call test_prepare)

@ -579,24 +579,24 @@ KERNEL_ELF_TTABLES = target/$(TARGET)/release/kernel+ttables
EXEC_TT_TOOL = ruby $(TT_TOOL_PATH)/main.rb EXEC_TT_TOOL = ruby $(TT_TOOL_PATH)/main.rb
# [...] # [...]
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Compile the kernel ELF ## Compile the kernel ELF
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
$(KERNEL_ELF_RAW): $(KERNEL_ELF_RAW_DEPS) $(KERNEL_ELF_RAW): $(KERNEL_ELF_RAW_DEPS)
$(call color_header, "Compiling kernel ELF - $(BSP)") $(call color_header, "Compiling kernel ELF - $(BSP)")
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD) @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Precompute the kernel translation tables and patch them into the kernel ELF ## Precompute the kernel translation tables and patch them into the kernel ELF
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
$(KERNEL_ELF_TTABLES): $(KERNEL_ELF_TTABLES_DEPS) $(KERNEL_ELF_TTABLES): $(KERNEL_ELF_TTABLES_DEPS)
$(call color_header, "Precomputing kernel translation tables and patching kernel ELF") $(call color_header, "Precomputing kernel translation tables and patching kernel ELF")
@cp $(KERNEL_ELF_RAW) $(KERNEL_ELF_TTABLES) @cp $(KERNEL_ELF_RAW) $(KERNEL_ELF_TTABLES)
@$(DOCKER_TOOLS) $(EXEC_TT_TOOL) $(TARGET) $(BSP) $(KERNEL_ELF_TTABLES) @$(DOCKER_TOOLS) $(EXEC_TT_TOOL) $(TARGET) $(BSP) $(KERNEL_ELF_TTABLES)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Generate the stripped kernel binary ## Generate the stripped kernel binary
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
$(KERNEL_BIN): $(KERNEL_ELF_TTABLES) $(KERNEL_BIN): $(KERNEL_ELF_TTABLES)
$(call color_header, "Generating stripped binary") $(call color_header, "Generating stripped binary")
@$(OBJCOPY_CMD) $(KERNEL_ELF_TTABLES) $(KERNEL_BIN) @$(OBJCOPY_CMD) $(KERNEL_ELF_TTABLES) $(KERNEL_BIN)
@ -637,7 +637,7 @@ def kernel_map_binary
mapping_descriptors.each do |i| mapping_descriptors.each do |i|
print 'Generating'.rjust(12).green.bold print 'Generating'.rjust(12).green.bold
print ' ' print ' '
puts i.to_s puts i
TRANSLATION_TABLES.map_at(i.virt_region, i.phys_region, i.attributes) TRANSLATION_TABLES.map_at(i.virt_region, i.phys_region, i.attributes)
end 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_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) +KERNEL_ELF_RAW_DEPS = $(filter-out modulo: ,$(file < $(KERNEL_ELF_RAW).d)) $(KERNEL_MANIFEST) $(LAST_BUILD_CONFIG)
+ +
+##------------------------------------------------------------------------------ +## ------------------------------------------------------------------------------
+## Translation tables +## Translation tables
+##------------------------------------------------------------------------------ +## ------------------------------------------------------------------------------
+TT_TOOL_PATH = tools/translation_table_tool +TT_TOOL_PATH = tools/translation_table_tool
+ +
+KERNEL_ELF_TTABLES = target/$(TARGET)/release/kernel+ttables +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 EXEC_MINIPUSH = ruby ../common/serial/minipush.rb
@@ -154,16 +165,24 @@ @@ -154,16 +165,24 @@
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Compile the kernel ELF ## Compile the kernel ELF
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
-$(KERNEL_ELF): $(KERNEL_ELF_DEPS) -$(KERNEL_ELF): $(KERNEL_ELF_DEPS)
+$(KERNEL_ELF_RAW): $(KERNEL_ELF_RAW_DEPS) +$(KERNEL_ELF_RAW): $(KERNEL_ELF_RAW_DEPS)
$(call color_header, "Compiling kernel ELF - $(BSP)") $(call color_header, "Compiling kernel ELF - $(BSP)")
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD) @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
+## Precompute the kernel translation tables and patch them into the kernel ELF +## Precompute the kernel translation tables and patch them into the kernel ELF
+##------------------------------------------------------------------------------ +## ------------------------------------------------------------------------------
+$(KERNEL_ELF_TTABLES): $(KERNEL_ELF_TTABLES_DEPS) +$(KERNEL_ELF_TTABLES): $(KERNEL_ELF_TTABLES_DEPS)
+ $(call color_header, "Precomputing kernel translation tables and patching kernel ELF") + $(call color_header, "Precomputing kernel translation tables and patching kernel ELF")
+ @cp $(KERNEL_ELF_RAW) $(KERNEL_ELF_TTABLES) + @cp $(KERNEL_ELF_RAW) $(KERNEL_ELF_TTABLES)
+ @$(DOCKER_TOOLS) $(EXEC_TT_TOOL) $(BSP) $(KERNEL_ELF_TTABLES) + @$(DOCKER_TOOLS) $(EXEC_TT_TOOL) $(BSP) $(KERNEL_ELF_TTABLES)
+ +
+##------------------------------------------------------------------------------ +## ------------------------------------------------------------------------------
## Generate the stripped kernel binary ## Generate the stripped kernel binary
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
-$(KERNEL_BIN): $(KERNEL_ELF) -$(KERNEL_BIN): $(KERNEL_ELF)
+$(KERNEL_BIN): $(KERNEL_ELF_TTABLES) +$(KERNEL_BIN): $(KERNEL_ELF_TTABLES)
$(call color_header, "Generating stripped binary") $(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| + mapping_descriptors.each do |i|
+ print 'Generating'.rjust(12).green.bold + print 'Generating'.rjust(12).green.bold
+ print ' ' + print ' '
+ puts i.to_s + puts i
+ +
+ TRANSLATION_TABLES.map_at(i.virt_region, i.phys_region, i.attributes) + TRANSLATION_TABLES.map_at(i.virt_region, i.phys_region, i.attributes)
+ end + end

@ -10,9 +10,9 @@ bsp_rpi3 = ["tock-registers"]
bsp_rpi4 = ["tock-registers"] bsp_rpi4 = ["tock-registers"]
test_build = ["qemu-exit"] test_build = ["qemu-exit"]
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Dependencies ## Dependencies
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
[dependencies] [dependencies]
test-types = { path = "../libraries/test-types" } test-types = { path = "../libraries/test-types" }
@ -25,9 +25,9 @@ qemu-exit = { version = "3.x.x", optional = true }
[target.'cfg(target_arch = "aarch64")'.dependencies] [target.'cfg(target_arch = "aarch64")'.dependencies]
aarch64-cpu = { version = "9.x.x" } aarch64-cpu = { version = "9.x.x" }
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Testing ## Testing
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
[dev-dependencies] [dev-dependencies]
test-macros = { path = "../libraries/test-macros" } test-macros = { path = "../libraries/test-macros" }

@ -40,9 +40,9 @@ class RxStatisticsTest < SubtestBase
end end
end end
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Test registration ## Test registration
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
def subtest_collection def subtest_collection
[TxRxHandshakeTest.new, TxStatisticsTest.new, RxStatisticsTest.new] [TxRxHandshakeTest.new, TxStatisticsTest.new, RxStatisticsTest.new]
end end

@ -17,9 +17,9 @@ class ExceptionRestoreTest < SubtestBase
end end
end end
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Test registration ## Test registration
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
def subtest_collection def subtest_collection
[ExceptionRestoreTest.new] [ExceptionRestoreTest.new]
end end

@ -151,7 +151,7 @@ def kernel_map_binary
mapping_descriptors.each do |i| mapping_descriptors.each do |i|
print 'Generating'.rjust(12).green.bold print 'Generating'.rjust(12).green.bold
print ' ' print ' '
puts i.to_s puts i
TRANSLATION_TABLES.map_at(i.virt_region, i.phys_region, i.attributes) TRANSLATION_TABLES.map_at(i.virt_region, i.phys_region, i.attributes)
end end

@ -6,9 +6,9 @@ include ../common/docker.mk
include ../common/format.mk include ../common/format.mk
include ../common/operating_system.mk include ../common/operating_system.mk
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Optional, user-provided configuration values ## Optional, user-provided configuration values
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
# Default to the RPi3. # Default to the RPi3.
BSP ?= rpi3 BSP ?= rpi3
@ -25,9 +25,9 @@ endif
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## BSP-specific configuration values ## BSP-specific configuration values
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
QEMU_MISSING_STRING = "This board is not yet supported for QEMU." QEMU_MISSING_STRING = "This board is not yet supported for QEMU."
ifeq ($(BSP),rpi3) ifeq ($(BSP),rpi3)
@ -65,9 +65,9 @@ export LD_SCRIPT_PATH
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Targets and Prerequisites ## Targets and Prerequisites
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
KERNEL_MANIFEST = kernel/Cargo.toml KERNEL_MANIFEST = kernel/Cargo.toml
KERNEL_LINKER_SCRIPT = kernel.ld KERNEL_LINKER_SCRIPT = kernel.ld
LAST_BUILD_CONFIG = target/$(BSP).build_config 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 # 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) KERNEL_ELF_RAW_DEPS = $(filter-out %: ,$(file < $(KERNEL_ELF_RAW).d)) $(KERNEL_MANIFEST) $(LAST_BUILD_CONFIG)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Translation tables ## Translation tables
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
TT_TOOL_PATH = tools/translation_table_tool TT_TOOL_PATH = tools/translation_table_tool
KERNEL_ELF_TTABLES = target/$(TARGET)/release/kernel+ttables KERNEL_ELF_TTABLES = target/$(TARGET)/release/kernel+ttables
@ -89,9 +89,9 @@ KERNEL_ELF = $(KERNEL_ELF_TTABLES)
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Command building blocks ## Command building blocks
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
RUSTFLAGS = $(RUSTC_MISC_ARGS) \ RUSTFLAGS = $(RUSTC_MISC_ARGS) \
-C link-arg=--library-path=$(LD_SCRIPT_PATH) \ -C link-arg=--library-path=$(LD_SCRIPT_PATH) \
-C link-arg=--script=$(KERNEL_LINKER_SCRIPT) -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_TEST_DISPATCH = ruby ../common/tests/dispatch.rb
EXEC_MINIPUSH = ruby ../common/serial/minipush.rb EXEC_MINIPUSH = ruby ../common/serial/minipush.rb
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Dockerization ## Dockerization
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial
DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i
DOCKER_ARG_DIR_COMMON = -v $(shell pwd)/../common:/work/common DOCKER_ARG_DIR_COMMON = -v $(shell pwd)/../common:/work/common
@ -147,39 +147,39 @@ endif
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Targets ## Targets
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
.PHONY: all doc qemu chainboot clippy clean readelf objdump nm check .PHONY: all doc qemu chainboot clippy clean readelf objdump nm check
all: $(KERNEL_BIN) all: $(KERNEL_BIN)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Save the configuration as a file, so make understands if it changed. ## Save the configuration as a file, so make understands if it changed.
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
$(LAST_BUILD_CONFIG): $(LAST_BUILD_CONFIG):
@rm -f target/*.build_config @rm -f target/*.build_config
@mkdir -p target @mkdir -p target
@touch $(LAST_BUILD_CONFIG) @touch $(LAST_BUILD_CONFIG)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Compile the kernel ELF ## Compile the kernel ELF
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
$(KERNEL_ELF_RAW): $(KERNEL_ELF_RAW_DEPS) $(KERNEL_ELF_RAW): $(KERNEL_ELF_RAW_DEPS)
$(call color_header, "Compiling kernel ELF - $(BSP)") $(call color_header, "Compiling kernel ELF - $(BSP)")
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD) @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Precompute the kernel translation tables and patch them into the kernel ELF ## Precompute the kernel translation tables and patch them into the kernel ELF
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
$(KERNEL_ELF_TTABLES): $(KERNEL_ELF_TTABLES_DEPS) $(KERNEL_ELF_TTABLES): $(KERNEL_ELF_TTABLES_DEPS)
$(call color_header, "Precomputing kernel translation tables and patching kernel ELF") $(call color_header, "Precomputing kernel translation tables and patching kernel ELF")
@cp $(KERNEL_ELF_RAW) $(KERNEL_ELF_TTABLES) @cp $(KERNEL_ELF_RAW) $(KERNEL_ELF_TTABLES)
@$(DOCKER_TOOLS) $(EXEC_TT_TOOL) $(BSP) $(KERNEL_ELF_TTABLES) @$(DOCKER_TOOLS) $(EXEC_TT_TOOL) $(BSP) $(KERNEL_ELF_TTABLES)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Generate the stripped kernel binary ## Generate the stripped kernel binary
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
$(KERNEL_BIN): $(KERNEL_ELF_TTABLES) $(KERNEL_BIN): $(KERNEL_ELF_TTABLES)
$(call color_header, "Generating stripped binary") $(call color_header, "Generating stripped binary")
@$(OBJCOPY_CMD) $(KERNEL_ELF_TTABLES) $(KERNEL_BIN) @$(OBJCOPY_CMD) $(KERNEL_ELF_TTABLES) $(KERNEL_BIN)
@ -188,16 +188,16 @@ $(KERNEL_BIN): $(KERNEL_ELF_TTABLES)
$(call color_progress_prefix, "Size") $(call color_progress_prefix, "Size")
$(call disk_usage_KiB, $(KERNEL_BIN)) $(call disk_usage_KiB, $(KERNEL_BIN))
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Generate the documentation ## Generate the documentation
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
doc: doc:
$(call color_header, "Generating docs") $(call color_header, "Generating docs")
@$(DOC_CMD) --document-private-items --open @$(DOC_CMD) --document-private-items --open
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run the kernel in QEMU ## Run the kernel in QEMU
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board.
qemu: qemu:
@ -211,36 +211,36 @@ qemu: $(KERNEL_BIN)
endif endif
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Push the kernel to the real HW target ## Push the kernel to the real HW target
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
chainboot: $(KERNEL_BIN) chainboot: $(KERNEL_BIN)
@$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(KERNEL_BIN) @$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(KERNEL_BIN)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run clippy ## Run clippy
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
clippy: clippy:
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD)
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) --features test_build --tests \ @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) --features test_build --tests \
--manifest-path $(KERNEL_MANIFEST) --manifest-path $(KERNEL_MANIFEST)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Clean ## Clean
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
clean: clean:
rm -rf target $(KERNEL_BIN) rm -rf target $(KERNEL_BIN)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run readelf ## Run readelf
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
readelf: $(KERNEL_ELF) readelf: $(KERNEL_ELF)
$(call color_header, "Launching readelf") $(call color_header, "Launching readelf")
@$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF) @$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run objdump ## Run objdump
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
objdump: $(KERNEL_ELF) objdump: $(KERNEL_ELF)
$(call color_header, "Launching objdump") $(call color_header, "Launching objdump")
@$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \ @$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \
@ -248,36 +248,36 @@ objdump: $(KERNEL_ELF)
--section .rodata \ --section .rodata \
$(KERNEL_ELF) | rustfilt $(KERNEL_ELF) | rustfilt
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run nm ## Run nm
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
nm: $(KERNEL_ELF) nm: $(KERNEL_ELF)
$(call color_header, "Launching nm") $(call color_header, "Launching nm")
@$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt @$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Debugging targets ## Debugging targets
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
.PHONY: jtagboot openocd gdb gdb-opt0 .PHONY: jtagboot openocd gdb gdb-opt0
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Push the JTAG boot image to the real HW target ## Push the JTAG boot image to the real HW target
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
jtagboot: jtagboot:
@$(DOCKER_JTAGBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(JTAG_BOOT_IMAGE) @$(DOCKER_JTAGBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(JTAG_BOOT_IMAGE)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Start OpenOCD session ## Start OpenOCD session
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
openocd: openocd:
$(call color_header, "Launching OpenOCD") $(call color_header, "Launching OpenOCD")
@$(DOCKER_OPENOCD) openocd $(OPENOCD_ARG) @$(DOCKER_OPENOCD) openocd $(OPENOCD_ARG)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Start GDB session ## Start GDB session
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
gdb: RUSTC_MISC_ARGS += -C debuginfo=2 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 debuginfo=2 -C opt-level=0
gdb gdb-opt0: $(KERNEL_ELF) gdb gdb-opt0: $(KERNEL_ELF)
@ -286,9 +286,9 @@ gdb gdb-opt0: $(KERNEL_ELF)
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Testing targets ## Testing targets
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
.PHONY: test test_boot test_unit test_integration .PHONY: test test_boot test_unit test_integration
test_unit test_integration: FEATURES += --features test_build test_unit test_integration: FEATURES += --features test_build
@ -300,16 +300,16 @@ test_boot test_unit test_integration test:
else # QEMU is supported. else # QEMU is supported.
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run boot test ## Run boot test
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
test_boot: $(KERNEL_BIN) test_boot: $(KERNEL_BIN)
$(call color_header, "Boot test - $(BSP)") $(call color_header, "Boot test - $(BSP)")
@$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN) @$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Helpers for unit and integration test targets ## Helpers for unit and integration test targets
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
define KERNEL_TEST_RUNNER define KERNEL_TEST_RUNNER
#!/usr/bin/env bash #!/usr/bin/env bash
@ -333,17 +333,17 @@ define test_prepare
@chmod +x target/kernel_test_runner.sh @chmod +x target/kernel_test_runner.sh
endef endef
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run unit test(s) ## Run unit test(s)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
test_unit: test_unit:
$(call color_header, "Compiling unit test(s) - $(BSP)") $(call color_header, "Compiling unit test(s) - $(BSP)")
$(call test_prepare) $(call test_prepare)
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(TEST_CMD) --lib @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(TEST_CMD) --lib
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run integration test(s) ## Run integration test(s)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
test_integration: test_integration:
$(call color_header, "Compiling integration test(s) - $(BSP)") $(call color_header, "Compiling integration test(s) - $(BSP)")
$(call test_prepare) $(call test_prepare)

@ -40,9 +40,9 @@ class RxStatisticsTest < SubtestBase
end end
end end
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Test registration ## Test registration
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
def subtest_collection def subtest_collection
[TxRxHandshakeTest.new, TxStatisticsTest.new, RxStatisticsTest.new] [TxRxHandshakeTest.new, TxStatisticsTest.new, RxStatisticsTest.new]
end end

@ -17,9 +17,9 @@ class ExceptionRestoreTest < SubtestBase
end end
end end
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Test registration ## Test registration
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
def subtest_collection def subtest_collection
[ExceptionRestoreTest.new] [ExceptionRestoreTest.new]
end end

@ -151,7 +151,7 @@ def kernel_map_binary
mapping_descriptors.each do |i| mapping_descriptors.each do |i|
print 'Generating'.rjust(12).green.bold print 'Generating'.rjust(12).green.bold
print ' ' print ' '
puts i.to_s puts i
TRANSLATION_TABLES.map_at(i.virt_region, i.phys_region, i.attributes) TRANSLATION_TABLES.map_at(i.virt_region, i.phys_region, i.attributes)
end end

@ -6,9 +6,9 @@ include ../common/docker.mk
include ../common/format.mk include ../common/format.mk
include ../common/operating_system.mk include ../common/operating_system.mk
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Optional, user-provided configuration values ## Optional, user-provided configuration values
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
# Default to the RPi3. # Default to the RPi3.
BSP ?= rpi3 BSP ?= rpi3
@ -25,9 +25,9 @@ endif
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## BSP-specific configuration values ## BSP-specific configuration values
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
QEMU_MISSING_STRING = "This board is not yet supported for QEMU." QEMU_MISSING_STRING = "This board is not yet supported for QEMU."
ifeq ($(BSP),rpi3) ifeq ($(BSP),rpi3)
@ -65,9 +65,9 @@ export LD_SCRIPT_PATH
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Targets and Prerequisites ## Targets and Prerequisites
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
KERNEL_MANIFEST = kernel/Cargo.toml KERNEL_MANIFEST = kernel/Cargo.toml
KERNEL_LINKER_SCRIPT = kernel.ld KERNEL_LINKER_SCRIPT = kernel.ld
LAST_BUILD_CONFIG = target/$(BSP).build_config 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 # 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) KERNEL_ELF_RAW_DEPS = $(filter-out %: ,$(file < $(KERNEL_ELF_RAW).d)) $(KERNEL_MANIFEST) $(LAST_BUILD_CONFIG)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Translation tables ## Translation tables
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
TT_TOOL_PATH = tools/translation_table_tool TT_TOOL_PATH = tools/translation_table_tool
KERNEL_ELF_TTABLES = target/$(TARGET)/release/kernel+ttables KERNEL_ELF_TTABLES = target/$(TARGET)/release/kernel+ttables
KERNEL_ELF_TTABLES_DEPS = $(KERNEL_ELF_RAW) $(wildcard $(TT_TOOL_PATH)/*) KERNEL_ELF_TTABLES_DEPS = $(KERNEL_ELF_RAW) $(wildcard $(TT_TOOL_PATH)/*)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Kernel symbols ## Kernel symbols
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
export KERNEL_SYMBOLS_TOOL_PATH = tools/kernel_symbols_tool export KERNEL_SYMBOLS_TOOL_PATH = tools/kernel_symbols_tool
KERNEL_ELF_TTABLES_SYMS = target/$(TARGET)/release/kernel+ttables+symbols KERNEL_ELF_TTABLES_SYMS = target/$(TARGET)/release/kernel+ttables+symbols
@ -106,9 +106,9 @@ KERNEL_ELF = $(KERNEL_ELF_TTABLES_SYMS)
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Command building blocks ## Command building blocks
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
RUSTFLAGS = $(RUSTC_MISC_ARGS) \ RUSTFLAGS = $(RUSTC_MISC_ARGS) \
-C link-arg=--library-path=$(LD_SCRIPT_PATH) \ -C link-arg=--library-path=$(LD_SCRIPT_PATH) \
-C link-arg=--script=$(KERNEL_LINKER_SCRIPT) -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_TEST_DISPATCH = ruby ../common/tests/dispatch.rb
EXEC_MINIPUSH = ruby ../common/serial/minipush.rb EXEC_MINIPUSH = ruby ../common/serial/minipush.rb
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Dockerization ## Dockerization
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial
DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i
DOCKER_ARG_DIR_COMMON = -v $(shell pwd)/../common:/work/common DOCKER_ARG_DIR_COMMON = -v $(shell pwd)/../common:/work/common
@ -164,46 +164,46 @@ endif
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Targets ## Targets
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
.PHONY: all doc qemu chainboot clippy clean readelf objdump nm check .PHONY: all doc qemu chainboot clippy clean readelf objdump nm check
all: $(KERNEL_BIN) all: $(KERNEL_BIN)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Save the configuration as a file, so make understands if it changed. ## Save the configuration as a file, so make understands if it changed.
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
$(LAST_BUILD_CONFIG): $(LAST_BUILD_CONFIG):
@rm -f target/*.build_config @rm -f target/*.build_config
@mkdir -p target @mkdir -p target
@touch $(LAST_BUILD_CONFIG) @touch $(LAST_BUILD_CONFIG)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Compile the kernel ELF ## Compile the kernel ELF
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
$(KERNEL_ELF_RAW): $(KERNEL_ELF_RAW_DEPS) $(KERNEL_ELF_RAW): $(KERNEL_ELF_RAW_DEPS)
$(call color_header, "Compiling kernel ELF - $(BSP)") $(call color_header, "Compiling kernel ELF - $(BSP)")
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD) @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Precompute the kernel translation tables and patch them into the kernel ELF ## Precompute the kernel translation tables and patch them into the kernel ELF
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
$(KERNEL_ELF_TTABLES): $(KERNEL_ELF_TTABLES_DEPS) $(KERNEL_ELF_TTABLES): $(KERNEL_ELF_TTABLES_DEPS)
$(call color_header, "Precomputing kernel translation tables and patching kernel ELF") $(call color_header, "Precomputing kernel translation tables and patching kernel ELF")
@cp $(KERNEL_ELF_RAW) $(KERNEL_ELF_TTABLES) @cp $(KERNEL_ELF_RAW) $(KERNEL_ELF_TTABLES)
@$(DOCKER_TOOLS) $(EXEC_TT_TOOL) $(BSP) $(KERNEL_ELF_TTABLES) @$(DOCKER_TOOLS) $(EXEC_TT_TOOL) $(BSP) $(KERNEL_ELF_TTABLES)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Generate kernel symbols and patch them into the kernel ELF ## Generate kernel symbols and patch them into the kernel ELF
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
$(KERNEL_ELF_TTABLES_SYMS): $(KERNEL_ELF_TTABLES_SYMS_DEPS) $(KERNEL_ELF_TTABLES_SYMS): $(KERNEL_ELF_TTABLES_SYMS_DEPS)
$(call color_header, "Generating kernel symbols and patching kernel ELF") $(call color_header, "Generating kernel symbols and patching kernel ELF")
@$(MAKE) --no-print-directory -f kernel_symbols.mk @$(MAKE) --no-print-directory -f kernel_symbols.mk
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Generate the stripped kernel binary ## Generate the stripped kernel binary
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
$(KERNEL_BIN): $(KERNEL_ELF_TTABLES_SYMS) $(KERNEL_BIN): $(KERNEL_ELF_TTABLES_SYMS)
$(call color_header, "Generating stripped binary") $(call color_header, "Generating stripped binary")
@$(OBJCOPY_CMD) $(KERNEL_ELF_TTABLES_SYMS) $(KERNEL_BIN) @$(OBJCOPY_CMD) $(KERNEL_ELF_TTABLES_SYMS) $(KERNEL_BIN)
@ -212,16 +212,16 @@ $(KERNEL_BIN): $(KERNEL_ELF_TTABLES_SYMS)
$(call color_progress_prefix, "Size") $(call color_progress_prefix, "Size")
$(call disk_usage_KiB, $(KERNEL_BIN)) $(call disk_usage_KiB, $(KERNEL_BIN))
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Generate the documentation ## Generate the documentation
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
doc: clean doc: clean
$(call color_header, "Generating docs") $(call color_header, "Generating docs")
@$(DOC_CMD) --document-private-items --open @$(DOC_CMD) --document-private-items --open
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run the kernel in QEMU ## Run the kernel in QEMU
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board.
qemu: qemu:
@ -235,36 +235,36 @@ qemu: $(KERNEL_BIN)
endif endif
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Push the kernel to the real HW target ## Push the kernel to the real HW target
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
chainboot: $(KERNEL_BIN) chainboot: $(KERNEL_BIN)
@$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(KERNEL_BIN) @$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(KERNEL_BIN)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run clippy ## Run clippy
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
clippy: clippy:
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD)
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) --features test_build --tests \ @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) --features test_build --tests \
--manifest-path $(KERNEL_MANIFEST) --manifest-path $(KERNEL_MANIFEST)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Clean ## Clean
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
clean: clean:
rm -rf target $(KERNEL_BIN) rm -rf target $(KERNEL_BIN)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run readelf ## Run readelf
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
readelf: $(KERNEL_ELF) readelf: $(KERNEL_ELF)
$(call color_header, "Launching readelf") $(call color_header, "Launching readelf")
@$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF) @$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run objdump ## Run objdump
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
objdump: $(KERNEL_ELF) objdump: $(KERNEL_ELF)
$(call color_header, "Launching objdump") $(call color_header, "Launching objdump")
@$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \ @$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \
@ -272,36 +272,36 @@ objdump: $(KERNEL_ELF)
--section .rodata \ --section .rodata \
$(KERNEL_ELF) | rustfilt $(KERNEL_ELF) | rustfilt
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run nm ## Run nm
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
nm: $(KERNEL_ELF) nm: $(KERNEL_ELF)
$(call color_header, "Launching nm") $(call color_header, "Launching nm")
@$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt @$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Debugging targets ## Debugging targets
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
.PHONY: jtagboot openocd gdb gdb-opt0 .PHONY: jtagboot openocd gdb gdb-opt0
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Push the JTAG boot image to the real HW target ## Push the JTAG boot image to the real HW target
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
jtagboot: jtagboot:
@$(DOCKER_JTAGBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(JTAG_BOOT_IMAGE) @$(DOCKER_JTAGBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(JTAG_BOOT_IMAGE)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Start OpenOCD session ## Start OpenOCD session
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
openocd: openocd:
$(call color_header, "Launching OpenOCD") $(call color_header, "Launching OpenOCD")
@$(DOCKER_OPENOCD) openocd $(OPENOCD_ARG) @$(DOCKER_OPENOCD) openocd $(OPENOCD_ARG)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Start GDB session ## Start GDB session
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
gdb: RUSTC_MISC_ARGS += -C debuginfo=2 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 debuginfo=2 -C opt-level=0
gdb gdb-opt0: $(KERNEL_ELF) gdb gdb-opt0: $(KERNEL_ELF)
@ -310,9 +310,9 @@ gdb gdb-opt0: $(KERNEL_ELF)
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Testing targets ## Testing targets
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
.PHONY: test test_boot test_unit test_integration .PHONY: test test_boot test_unit test_integration
test_unit test_integration: FEATURES += --features test_build test_unit test_integration: FEATURES += --features test_build
@ -324,16 +324,16 @@ test_boot test_unit test_integration test:
else # QEMU is supported. else # QEMU is supported.
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run boot test ## Run boot test
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
test_boot: $(KERNEL_BIN) test_boot: $(KERNEL_BIN)
$(call color_header, "Boot test - $(BSP)") $(call color_header, "Boot test - $(BSP)")
@$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN) @$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Helpers for unit and integration test targets ## Helpers for unit and integration test targets
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
define KERNEL_TEST_RUNNER define KERNEL_TEST_RUNNER
#!/usr/bin/env bash #!/usr/bin/env bash
@ -366,17 +366,17 @@ define test_prepare
@chmod +x target/kernel_test_runner.sh @chmod +x target/kernel_test_runner.sh
endef endef
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run unit test(s) ## Run unit test(s)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
test_unit: test_unit:
$(call color_header, "Compiling unit test(s) - $(BSP)") $(call color_header, "Compiling unit test(s) - $(BSP)")
$(call test_prepare) $(call test_prepare)
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(TEST_CMD) --lib @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(TEST_CMD) --lib
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run integration test(s) ## Run integration test(s)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
test_integration: test_integration:
$(call color_header, "Compiling integration test(s) - $(BSP)") $(call color_header, "Compiling integration test(s) - $(BSP)")
$(call test_prepare) $(call test_prepare)

@ -465,9 +465,9 @@ diff -uNr 16_virtual_mem_part4_higher_half_kernel/kernel_symbols/Cargo.toml 17_k
+default = [] +default = []
+generated_symbols_available = [] +generated_symbols_available = []
+ +
+##-------------------------------------------------------------------------------------------------- +## --------------------------------------------------------------------------------------------------
+## Dependencies +## Dependencies
+##-------------------------------------------------------------------------------------------------- +## --------------------------------------------------------------------------------------------------
+ +
+[dependencies] +[dependencies]
+debug-symbol-types = { path = "../libraries/debug-symbol-types" } +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/format.mk
+include ../common/docker.mk +include ../common/docker.mk
+ +
+##-------------------------------------------------------------------------------------------------- +## --------------------------------------------------------------------------------------------------
+## Check for input variables that need be exported by the calling Makefile +## Check for input variables that need be exported by the calling Makefile
+##-------------------------------------------------------------------------------------------------- +## --------------------------------------------------------------------------------------------------
+ifndef KERNEL_SYMBOLS_TOOL_PATH +ifndef KERNEL_SYMBOLS_TOOL_PATH
+$(error KERNEL_SYMBOLS_TOOL_PATH is not set) +$(error KERNEL_SYMBOLS_TOOL_PATH is not set)
+endif +endif
@ -545,9 +545,9 @@ diff -uNr 16_virtual_mem_part4_higher_half_kernel/kernel_symbols.mk 17_kernel_sy
+ +
+ +
+ +
+##-------------------------------------------------------------------------------------------------- +## --------------------------------------------------------------------------------------------------
+## Targets and Prerequisites +## Targets and Prerequisites
+##-------------------------------------------------------------------------------------------------- +## --------------------------------------------------------------------------------------------------
+KERNEL_SYMBOLS_MANIFEST = kernel_symbols/Cargo.toml +KERNEL_SYMBOLS_MANIFEST = kernel_symbols/Cargo.toml
+KERNEL_SYMBOLS_LINKER_SCRIPT = kernel_symbols/kernel_symbols.ld +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 +## Command building blocks
+##-------------------------------------------------------------------------------------------------- +## --------------------------------------------------------------------------------------------------
+GET_SYMBOLS_SECTION_VIRT_ADDR = $(DOCKER_TOOLS) $(EXEC_SYMBOLS_TOOL) \ +GET_SYMBOLS_SECTION_VIRT_ADDR = $(DOCKER_TOOLS) $(EXEC_SYMBOLS_TOOL) \
+ --get_symbols_section_virt_addr $(KERNEL_SYMBOLS_OUTPUT_ELF) + --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 +EXEC_SYMBOLS_TOOL = ruby $(KERNEL_SYMBOLS_TOOL_PATH)/main.rb
+ +
+##------------------------------------------------------------------------------ +## ------------------------------------------------------------------------------
+## Dockerization +## Dockerization
+##------------------------------------------------------------------------------ +## ------------------------------------------------------------------------------
+DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial +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). +# 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 +## Targets
+##-------------------------------------------------------------------------------------------------- +## --------------------------------------------------------------------------------------------------
+.PHONY: all symbols measure_time_start measure_time_finish +.PHONY: all symbols measure_time_start measure_time_finish
+ +
+all: measure_time_start symbols 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_TTABLES_DEPS = $(KERNEL_ELF_RAW) $(wildcard $(TT_TOOL_PATH)/*)
-KERNEL_ELF = $(KERNEL_ELF_TTABLES) -KERNEL_ELF = $(KERNEL_ELF_TTABLES)
+##------------------------------------------------------------------------------ +## ------------------------------------------------------------------------------
+## Kernel symbols +## Kernel symbols
+##------------------------------------------------------------------------------ +## ------------------------------------------------------------------------------
+export KERNEL_SYMBOLS_TOOL_PATH = tools/kernel_symbols_tool +export KERNEL_SYMBOLS_TOOL_PATH = tools/kernel_symbols_tool
+ +
+KERNEL_ELF_TTABLES_SYMS = target/$(TARGET)/release/kernel+ttables+symbols +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 @@ @@ -178,11 +195,18 @@
@$(DOCKER_TOOLS) $(EXEC_TT_TOOL) $(BSP) $(KERNEL_ELF_TTABLES) @$(DOCKER_TOOLS) $(EXEC_TT_TOOL) $(BSP) $(KERNEL_ELF_TTABLES)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
+## Generate kernel symbols and patch them into the kernel ELF +## Generate kernel symbols and patch them into the kernel ELF
+##------------------------------------------------------------------------------ +## ------------------------------------------------------------------------------
+$(KERNEL_ELF_TTABLES_SYMS): $(KERNEL_ELF_TTABLES_SYMS_DEPS) +$(KERNEL_ELF_TTABLES_SYMS): $(KERNEL_ELF_TTABLES_SYMS_DEPS)
+ $(call color_header, "Generating kernel symbols and patching kernel ELF") + $(call color_header, "Generating kernel symbols and patching kernel ELF")
+ @$(MAKE) --no-print-directory -f kernel_symbols.mk + @$(MAKE) --no-print-directory -f kernel_symbols.mk
+ +
+##------------------------------------------------------------------------------ +## ------------------------------------------------------------------------------
## Generate the stripped kernel binary ## Generate the stripped kernel binary
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
-$(KERNEL_BIN): $(KERNEL_ELF_TTABLES) -$(KERNEL_BIN): $(KERNEL_ELF_TTABLES)
+$(KERNEL_BIN): $(KERNEL_ELF_TTABLES_SYMS) +$(KERNEL_BIN): $(KERNEL_ELF_TTABLES_SYMS)
$(call color_header, "Generating stripped binary") $(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) @echo $(KERNEL_BIN)
$(call color_progress_prefix, "Size") $(call color_progress_prefix, "Size")
@@ -191,7 +215,7 @@ @@ -191,7 +215,7 @@
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Generate the documentation ## Generate the documentation
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
-doc: -doc:
+doc: clean +doc: clean
$(call color_header, "Generating docs") $(call color_header, "Generating docs")

@ -40,9 +40,9 @@ class RxStatisticsTest < SubtestBase
end end
end end
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Test registration ## Test registration
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
def subtest_collection def subtest_collection
[TxRxHandshakeTest.new, TxStatisticsTest.new, RxStatisticsTest.new] [TxRxHandshakeTest.new, TxStatisticsTest.new, RxStatisticsTest.new]
end end

@ -17,9 +17,9 @@ class ExceptionRestoreTest < SubtestBase
end end
end end
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Test registration ## Test registration
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
def subtest_collection def subtest_collection
[ExceptionRestoreTest.new] [ExceptionRestoreTest.new]
end end

@ -5,9 +5,9 @@
include ../common/format.mk include ../common/format.mk
include ../common/docker.mk include ../common/docker.mk
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Check for input variables that need be exported by the calling Makefile ## Check for input variables that need be exported by the calling Makefile
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
ifndef KERNEL_SYMBOLS_TOOL_PATH ifndef KERNEL_SYMBOLS_TOOL_PATH
$(error KERNEL_SYMBOLS_TOOL_PATH is not set) $(error KERNEL_SYMBOLS_TOOL_PATH is not set)
endif endif
@ -26,9 +26,9 @@ endif
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Targets and Prerequisites ## Targets and Prerequisites
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
KERNEL_SYMBOLS_MANIFEST = kernel_symbols/Cargo.toml KERNEL_SYMBOLS_MANIFEST = kernel_symbols/Cargo.toml
KERNEL_SYMBOLS_LINKER_SCRIPT = kernel_symbols/kernel_symbols.ld KERNEL_SYMBOLS_LINKER_SCRIPT = kernel_symbols/kernel_symbols.ld
@ -43,9 +43,9 @@ export KERNEL_SYMBOLS_DEMANGLED_RS
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Command building blocks ## Command building blocks
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
GET_SYMBOLS_SECTION_VIRT_ADDR = $(DOCKER_TOOLS) $(EXEC_SYMBOLS_TOOL) \ GET_SYMBOLS_SECTION_VIRT_ADDR = $(DOCKER_TOOLS) $(EXEC_SYMBOLS_TOOL) \
--get_symbols_section_virt_addr $(KERNEL_SYMBOLS_OUTPUT_ELF) --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 EXEC_SYMBOLS_TOOL = ruby $(KERNEL_SYMBOLS_TOOL_PATH)/main.rb
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Dockerization ## Dockerization
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial 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). # DOCKER_IMAGE defined in include file (see top of this file).
@ -76,9 +76,9 @@ DOCKER_TOOLS = $(DOCKER_CMD) $(DOCKER_IMAGE)
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Targets ## Targets
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
.PHONY: all symbols measure_time_start measure_time_finish .PHONY: all symbols measure_time_start measure_time_finish
all: measure_time_start symbols measure_time_finish all: measure_time_start symbols measure_time_finish

@ -151,7 +151,7 @@ def kernel_map_binary
mapping_descriptors.each do |i| mapping_descriptors.each do |i|
print 'Generating'.rjust(12).green.bold print 'Generating'.rjust(12).green.bold
print ' ' print ' '
puts i.to_s puts i
TRANSLATION_TABLES.map_at(i.virt_region, i.phys_region, i.attributes) TRANSLATION_TABLES.map_at(i.virt_region, i.phys_region, i.attributes)
end end

@ -6,9 +6,9 @@ include ../common/docker.mk
include ../common/format.mk include ../common/format.mk
include ../common/operating_system.mk include ../common/operating_system.mk
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Optional, user-provided configuration values ## Optional, user-provided configuration values
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
# Default to the RPi3. # Default to the RPi3.
BSP ?= rpi3 BSP ?= rpi3
@ -25,9 +25,9 @@ endif
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## BSP-specific configuration values ## BSP-specific configuration values
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
QEMU_MISSING_STRING = "This board is not yet supported for QEMU." QEMU_MISSING_STRING = "This board is not yet supported for QEMU."
ifeq ($(BSP),rpi3) ifeq ($(BSP),rpi3)
@ -65,9 +65,9 @@ export LD_SCRIPT_PATH
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Targets and Prerequisites ## Targets and Prerequisites
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
KERNEL_MANIFEST = kernel/Cargo.toml KERNEL_MANIFEST = kernel/Cargo.toml
KERNEL_LINKER_SCRIPT = kernel.ld KERNEL_LINKER_SCRIPT = kernel.ld
LAST_BUILD_CONFIG = target/$(BSP).build_config 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 # 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) KERNEL_ELF_RAW_DEPS = $(filter-out %: ,$(file < $(KERNEL_ELF_RAW).d)) $(KERNEL_MANIFEST) $(LAST_BUILD_CONFIG)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Translation tables ## Translation tables
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
TT_TOOL_PATH = tools/translation_table_tool TT_TOOL_PATH = tools/translation_table_tool
KERNEL_ELF_TTABLES = target/$(TARGET)/release/kernel+ttables KERNEL_ELF_TTABLES = target/$(TARGET)/release/kernel+ttables
KERNEL_ELF_TTABLES_DEPS = $(KERNEL_ELF_RAW) $(wildcard $(TT_TOOL_PATH)/*) KERNEL_ELF_TTABLES_DEPS = $(KERNEL_ELF_RAW) $(wildcard $(TT_TOOL_PATH)/*)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Kernel symbols ## Kernel symbols
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
export KERNEL_SYMBOLS_TOOL_PATH = tools/kernel_symbols_tool export KERNEL_SYMBOLS_TOOL_PATH = tools/kernel_symbols_tool
KERNEL_ELF_TTABLES_SYMS = target/$(TARGET)/release/kernel+ttables+symbols KERNEL_ELF_TTABLES_SYMS = target/$(TARGET)/release/kernel+ttables+symbols
@ -106,9 +106,9 @@ KERNEL_ELF = $(KERNEL_ELF_TTABLES_SYMS)
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Command building blocks ## Command building blocks
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
RUSTFLAGS = $(RUSTC_MISC_ARGS) \ RUSTFLAGS = $(RUSTC_MISC_ARGS) \
-C link-arg=--library-path=$(LD_SCRIPT_PATH) \ -C link-arg=--library-path=$(LD_SCRIPT_PATH) \
-C link-arg=--script=$(KERNEL_LINKER_SCRIPT) -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_TEST_DISPATCH = ruby ../common/tests/dispatch.rb
EXEC_MINIPUSH = ruby ../common/serial/minipush.rb EXEC_MINIPUSH = ruby ../common/serial/minipush.rb
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Dockerization ## Dockerization
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial
DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i
DOCKER_ARG_DIR_COMMON = -v $(shell pwd)/../common:/work/common DOCKER_ARG_DIR_COMMON = -v $(shell pwd)/../common:/work/common
@ -166,46 +166,46 @@ endif
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Targets ## Targets
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
.PHONY: all doc qemu chainboot clippy clean readelf objdump nm check .PHONY: all doc qemu chainboot clippy clean readelf objdump nm check
all: $(KERNEL_BIN) all: $(KERNEL_BIN)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Save the configuration as a file, so make understands if it changed. ## Save the configuration as a file, so make understands if it changed.
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
$(LAST_BUILD_CONFIG): $(LAST_BUILD_CONFIG):
@rm -f target/*.build_config @rm -f target/*.build_config
@mkdir -p target @mkdir -p target
@touch $(LAST_BUILD_CONFIG) @touch $(LAST_BUILD_CONFIG)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Compile the kernel ELF ## Compile the kernel ELF
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
$(KERNEL_ELF_RAW): $(KERNEL_ELF_RAW_DEPS) $(KERNEL_ELF_RAW): $(KERNEL_ELF_RAW_DEPS)
$(call color_header, "Compiling kernel ELF - $(BSP)") $(call color_header, "Compiling kernel ELF - $(BSP)")
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD) @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Precompute the kernel translation tables and patch them into the kernel ELF ## Precompute the kernel translation tables and patch them into the kernel ELF
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
$(KERNEL_ELF_TTABLES): $(KERNEL_ELF_TTABLES_DEPS) $(KERNEL_ELF_TTABLES): $(KERNEL_ELF_TTABLES_DEPS)
$(call color_header, "Precomputing kernel translation tables and patching kernel ELF") $(call color_header, "Precomputing kernel translation tables and patching kernel ELF")
@cp $(KERNEL_ELF_RAW) $(KERNEL_ELF_TTABLES) @cp $(KERNEL_ELF_RAW) $(KERNEL_ELF_TTABLES)
@$(DOCKER_TOOLS) $(EXEC_TT_TOOL) $(BSP) $(KERNEL_ELF_TTABLES) @$(DOCKER_TOOLS) $(EXEC_TT_TOOL) $(BSP) $(KERNEL_ELF_TTABLES)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Generate kernel symbols and patch them into the kernel ELF ## Generate kernel symbols and patch them into the kernel ELF
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
$(KERNEL_ELF_TTABLES_SYMS): $(KERNEL_ELF_TTABLES_SYMS_DEPS) $(KERNEL_ELF_TTABLES_SYMS): $(KERNEL_ELF_TTABLES_SYMS_DEPS)
$(call color_header, "Generating kernel symbols and patching kernel ELF") $(call color_header, "Generating kernel symbols and patching kernel ELF")
@$(MAKE) --no-print-directory -f kernel_symbols.mk @$(MAKE) --no-print-directory -f kernel_symbols.mk
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Generate the stripped kernel binary ## Generate the stripped kernel binary
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
$(KERNEL_BIN): $(KERNEL_ELF_TTABLES_SYMS) $(KERNEL_BIN): $(KERNEL_ELF_TTABLES_SYMS)
$(call color_header, "Generating stripped binary") $(call color_header, "Generating stripped binary")
@$(OBJCOPY_CMD) $(KERNEL_ELF_TTABLES_SYMS) $(KERNEL_BIN) @$(OBJCOPY_CMD) $(KERNEL_ELF_TTABLES_SYMS) $(KERNEL_BIN)
@ -214,16 +214,16 @@ $(KERNEL_BIN): $(KERNEL_ELF_TTABLES_SYMS)
$(call color_progress_prefix, "Size") $(call color_progress_prefix, "Size")
$(call disk_usage_KiB, $(KERNEL_BIN)) $(call disk_usage_KiB, $(KERNEL_BIN))
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Generate the documentation ## Generate the documentation
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
doc: clean doc: clean
$(call color_header, "Generating docs") $(call color_header, "Generating docs")
@$(DOC_CMD) --document-private-items --open @$(DOC_CMD) --document-private-items --open
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run the kernel in QEMU ## Run the kernel in QEMU
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board.
qemu: qemu:
@ -237,36 +237,36 @@ qemu: $(KERNEL_BIN)
endif endif
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Push the kernel to the real HW target ## Push the kernel to the real HW target
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
chainboot: $(KERNEL_BIN) chainboot: $(KERNEL_BIN)
@$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(KERNEL_BIN) @$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(KERNEL_BIN)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run clippy ## Run clippy
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
clippy: clippy:
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD)
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) --features test_build --tests \ @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) --features test_build --tests \
--manifest-path $(KERNEL_MANIFEST) --manifest-path $(KERNEL_MANIFEST)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Clean ## Clean
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
clean: clean:
rm -rf target $(KERNEL_BIN) rm -rf target $(KERNEL_BIN)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run readelf ## Run readelf
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
readelf: $(KERNEL_ELF) readelf: $(KERNEL_ELF)
$(call color_header, "Launching readelf") $(call color_header, "Launching readelf")
@$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF) @$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run objdump ## Run objdump
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
objdump: $(KERNEL_ELF) objdump: $(KERNEL_ELF)
$(call color_header, "Launching objdump") $(call color_header, "Launching objdump")
@$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \ @$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \
@ -274,36 +274,36 @@ objdump: $(KERNEL_ELF)
--section .rodata \ --section .rodata \
$(KERNEL_ELF) | rustfilt $(KERNEL_ELF) | rustfilt
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run nm ## Run nm
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
nm: $(KERNEL_ELF) nm: $(KERNEL_ELF)
$(call color_header, "Launching nm") $(call color_header, "Launching nm")
@$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt @$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Debugging targets ## Debugging targets
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
.PHONY: jtagboot openocd gdb gdb-opt0 .PHONY: jtagboot openocd gdb gdb-opt0
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Push the JTAG boot image to the real HW target ## Push the JTAG boot image to the real HW target
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
jtagboot: jtagboot:
@$(DOCKER_JTAGBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(JTAG_BOOT_IMAGE) @$(DOCKER_JTAGBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(JTAG_BOOT_IMAGE)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Start OpenOCD session ## Start OpenOCD session
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
openocd: openocd:
$(call color_header, "Launching OpenOCD") $(call color_header, "Launching OpenOCD")
@$(DOCKER_OPENOCD) openocd $(OPENOCD_ARG) @$(DOCKER_OPENOCD) openocd $(OPENOCD_ARG)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Start GDB session ## Start GDB session
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
gdb-opt0: RUSTC_MISC_ARGS += -C opt-level=0 gdb-opt0: RUSTC_MISC_ARGS += -C opt-level=0
gdb gdb-opt0: $(KERNEL_ELF) gdb gdb-opt0: $(KERNEL_ELF)
$(call color_header, "Launching GDB") $(call color_header, "Launching GDB")
@ -311,9 +311,9 @@ gdb gdb-opt0: $(KERNEL_ELF)
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Testing targets ## Testing targets
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
.PHONY: test test_boot test_unit test_integration .PHONY: test test_boot test_unit test_integration
test_unit test_integration: FEATURES += --features test_build test_unit test_integration: FEATURES += --features test_build
@ -325,16 +325,16 @@ test_boot test_unit test_integration test:
else # QEMU is supported. else # QEMU is supported.
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run boot test ## Run boot test
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
test_boot: $(KERNEL_BIN) test_boot: $(KERNEL_BIN)
$(call color_header, "Boot test - $(BSP)") $(call color_header, "Boot test - $(BSP)")
@$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN) @$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Helpers for unit and integration test targets ## Helpers for unit and integration test targets
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
define KERNEL_TEST_RUNNER define KERNEL_TEST_RUNNER
#!/usr/bin/env bash #!/usr/bin/env bash
@ -367,17 +367,17 @@ define test_prepare
@chmod +x target/kernel_test_runner.sh @chmod +x target/kernel_test_runner.sh
endef endef
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run unit test(s) ## Run unit test(s)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
test_unit: test_unit:
$(call color_header, "Compiling unit test(s) - $(BSP)") $(call color_header, "Compiling unit test(s) - $(BSP)")
$(call test_prepare) $(call test_prepare)
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(TEST_CMD) --lib @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(TEST_CMD) --lib
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run integration test(s) ## Run integration test(s)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
test_integration: test_integration:
$(call color_header, "Compiling integration test(s) - $(BSP)") $(call color_header, "Compiling integration test(s) - $(BSP)")
$(call test_prepare) $(call test_prepare)

@ -1039,9 +1039,9 @@ diff -uNr 17_kernel_symbols/kernel/tests/05_backtrace_sanity.rb 18_backtrace/ker
+ end + end
+end +end
+ +
+##-------------------------------------------------------------------------------------------------- +## --------------------------------------------------------------------------------------------------
+## Test registration +## Test registration
+##-------------------------------------------------------------------------------------------------- +## --------------------------------------------------------------------------------------------------
+def subtest_collection +def subtest_collection
+ [PanicBacktraceTest.new, BacktraceCorrectnessTest.new] + [PanicBacktraceTest.new, BacktraceCorrectnessTest.new]
+end +end
@ -1106,9 +1106,9 @@ diff -uNr 17_kernel_symbols/kernel/tests/06_backtrace_invalid_frame.rb 18_backtr
+ end + end
+end +end
+ +
+##-------------------------------------------------------------------------------------------------- +## --------------------------------------------------------------------------------------------------
+## Test registration +## Test registration
+##-------------------------------------------------------------------------------------------------- +## --------------------------------------------------------------------------------------------------
+def subtest_collection +def subtest_collection
+ [InvalidFramePointerTest.new] + [InvalidFramePointerTest.new]
+end +end
@ -1174,9 +1174,9 @@ diff -uNr 17_kernel_symbols/kernel/tests/07_backtrace_invalid_link.rb 18_backtra
+ end + end
+end +end
+ +
+##-------------------------------------------------------------------------------------------------- +## --------------------------------------------------------------------------------------------------
+## Test registration +## Test registration
+##-------------------------------------------------------------------------------------------------- +## --------------------------------------------------------------------------------------------------
+def subtest_collection +def subtest_collection
+ [InvalidLinkTest.new] + [InvalidLinkTest.new]
+end +end
@ -1261,9 +1261,9 @@ diff -uNr 17_kernel_symbols/Makefile 18_backtrace/Makefile
--strip-all \ --strip-all \
-O binary -O binary
@@ -302,8 +304,7 @@ @@ -302,8 +304,7 @@
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Start GDB session ## Start GDB session
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
-gdb: RUSTC_MISC_ARGS += -C debuginfo=2 -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 debuginfo=2 -C opt-level=0
+gdb-opt0: RUSTC_MISC_ARGS += -C opt-level=0 +gdb-opt0: RUSTC_MISC_ARGS += -C opt-level=0

@ -40,9 +40,9 @@ class RxStatisticsTest < SubtestBase
end end
end end
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Test registration ## Test registration
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
def subtest_collection def subtest_collection
[TxRxHandshakeTest.new, TxStatisticsTest.new, RxStatisticsTest.new] [TxRxHandshakeTest.new, TxStatisticsTest.new, RxStatisticsTest.new]
end end

@ -17,9 +17,9 @@ class ExceptionRestoreTest < SubtestBase
end end
end end
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Test registration ## Test registration
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
def subtest_collection def subtest_collection
[ExceptionRestoreTest.new] [ExceptionRestoreTest.new]
end end

@ -31,9 +31,9 @@ class BacktraceCorrectnessTest < SubtestBase
end end
end end
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Test registration ## Test registration
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
def subtest_collection def subtest_collection
[PanicBacktraceTest.new, BacktraceCorrectnessTest.new] [PanicBacktraceTest.new, BacktraceCorrectnessTest.new]
end end

@ -18,9 +18,9 @@ class InvalidFramePointerTest < SubtestBase
end end
end end
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Test registration ## Test registration
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
def subtest_collection def subtest_collection
[InvalidFramePointerTest.new] [InvalidFramePointerTest.new]
end end

@ -17,9 +17,9 @@ class InvalidLinkTest < SubtestBase
end end
end end
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Test registration ## Test registration
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
def subtest_collection def subtest_collection
[InvalidLinkTest.new] [InvalidLinkTest.new]
end end

@ -5,9 +5,9 @@
include ../common/format.mk include ../common/format.mk
include ../common/docker.mk include ../common/docker.mk
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Check for input variables that need be exported by the calling Makefile ## Check for input variables that need be exported by the calling Makefile
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
ifndef KERNEL_SYMBOLS_TOOL_PATH ifndef KERNEL_SYMBOLS_TOOL_PATH
$(error KERNEL_SYMBOLS_TOOL_PATH is not set) $(error KERNEL_SYMBOLS_TOOL_PATH is not set)
endif endif
@ -26,9 +26,9 @@ endif
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Targets and Prerequisites ## Targets and Prerequisites
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
KERNEL_SYMBOLS_MANIFEST = kernel_symbols/Cargo.toml KERNEL_SYMBOLS_MANIFEST = kernel_symbols/Cargo.toml
KERNEL_SYMBOLS_LINKER_SCRIPT = kernel_symbols/kernel_symbols.ld KERNEL_SYMBOLS_LINKER_SCRIPT = kernel_symbols/kernel_symbols.ld
@ -43,9 +43,9 @@ export KERNEL_SYMBOLS_DEMANGLED_RS
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Command building blocks ## Command building blocks
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
GET_SYMBOLS_SECTION_VIRT_ADDR = $(DOCKER_TOOLS) $(EXEC_SYMBOLS_TOOL) \ GET_SYMBOLS_SECTION_VIRT_ADDR = $(DOCKER_TOOLS) $(EXEC_SYMBOLS_TOOL) \
--get_symbols_section_virt_addr $(KERNEL_SYMBOLS_OUTPUT_ELF) --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 EXEC_SYMBOLS_TOOL = ruby $(KERNEL_SYMBOLS_TOOL_PATH)/main.rb
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Dockerization ## Dockerization
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial 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). # DOCKER_IMAGE defined in include file (see top of this file).
@ -76,9 +76,9 @@ DOCKER_TOOLS = $(DOCKER_CMD) $(DOCKER_IMAGE)
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Targets ## Targets
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
.PHONY: all symbols measure_time_start measure_time_finish .PHONY: all symbols measure_time_start measure_time_finish
all: measure_time_start symbols measure_time_finish all: measure_time_start symbols measure_time_finish

@ -161,7 +161,7 @@ def kernel_map_binary
mapping_descriptors.each do |i| mapping_descriptors.each do |i|
print 'Generating'.rjust(12).green.bold print 'Generating'.rjust(12).green.bold
print ' ' print ' '
puts i.to_s puts i
TRANSLATION_TABLES.map_at(i.virt_region, i.phys_region, i.attributes) TRANSLATION_TABLES.map_at(i.virt_region, i.phys_region, i.attributes)
end end

@ -6,9 +6,9 @@ include ../common/docker.mk
include ../common/format.mk include ../common/format.mk
include ../common/operating_system.mk include ../common/operating_system.mk
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Optional, user-provided configuration values ## Optional, user-provided configuration values
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
# Default to the RPi3. # Default to the RPi3.
BSP ?= rpi3 BSP ?= rpi3
@ -30,9 +30,9 @@ endif
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## BSP-specific configuration values ## BSP-specific configuration values
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
QEMU_MISSING_STRING = "This board is not yet supported for QEMU." QEMU_MISSING_STRING = "This board is not yet supported for QEMU."
ifeq ($(BSP),rpi3) ifeq ($(BSP),rpi3)
@ -70,9 +70,9 @@ export LD_SCRIPT_PATH
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Targets and Prerequisites ## Targets and Prerequisites
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
KERNEL_MANIFEST = kernel/Cargo.toml KERNEL_MANIFEST = kernel/Cargo.toml
KERNEL_LINKER_SCRIPT = kernel.ld KERNEL_LINKER_SCRIPT = kernel.ld
LAST_BUILD_CONFIG = target/$(BSP)_$(DEBUG_PRINTS).build_config 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 # 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) KERNEL_ELF_RAW_DEPS = $(filter-out %: ,$(file < $(KERNEL_ELF_RAW).d)) $(KERNEL_MANIFEST) $(LAST_BUILD_CONFIG)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Translation tables ## Translation tables
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
TT_TOOL_PATH = tools/translation_table_tool TT_TOOL_PATH = tools/translation_table_tool
KERNEL_ELF_TTABLES = target/$(TARGET)/release/kernel+ttables KERNEL_ELF_TTABLES = target/$(TARGET)/release/kernel+ttables
KERNEL_ELF_TTABLES_DEPS = $(KERNEL_ELF_RAW) $(wildcard $(TT_TOOL_PATH)/*) KERNEL_ELF_TTABLES_DEPS = $(KERNEL_ELF_RAW) $(wildcard $(TT_TOOL_PATH)/*)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Kernel symbols ## Kernel symbols
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
export KERNEL_SYMBOLS_TOOL_PATH = tools/kernel_symbols_tool export KERNEL_SYMBOLS_TOOL_PATH = tools/kernel_symbols_tool
KERNEL_ELF_TTABLES_SYMS = target/$(TARGET)/release/kernel+ttables+symbols KERNEL_ELF_TTABLES_SYMS = target/$(TARGET)/release/kernel+ttables+symbols
@ -111,9 +111,9 @@ KERNEL_ELF = $(KERNEL_ELF_TTABLES_SYMS)
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Command building blocks ## Command building blocks
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
RUSTFLAGS = $(RUSTC_MISC_ARGS) \ RUSTFLAGS = $(RUSTC_MISC_ARGS) \
-C link-arg=--library-path=$(LD_SCRIPT_PATH) \ -C link-arg=--library-path=$(LD_SCRIPT_PATH) \
-C link-arg=--script=$(KERNEL_LINKER_SCRIPT) -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_TEST_DISPATCH = ruby ../common/tests/dispatch.rb
EXEC_MINIPUSH = ruby ../common/serial/minipush.rb EXEC_MINIPUSH = ruby ../common/serial/minipush.rb
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Dockerization ## Dockerization
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial
DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i
DOCKER_ARG_DIR_COMMON = -v $(shell pwd)/../common:/work/common DOCKER_ARG_DIR_COMMON = -v $(shell pwd)/../common:/work/common
@ -171,46 +171,46 @@ endif
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Targets ## Targets
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
.PHONY: all doc qemu chainboot clippy clean readelf objdump nm check .PHONY: all doc qemu chainboot clippy clean readelf objdump nm check
all: $(KERNEL_BIN) all: $(KERNEL_BIN)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Save the configuration as a file, so make understands if it changed. ## Save the configuration as a file, so make understands if it changed.
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
$(LAST_BUILD_CONFIG): $(LAST_BUILD_CONFIG):
@rm -f target/*.build_config @rm -f target/*.build_config
@mkdir -p target @mkdir -p target
@touch $(LAST_BUILD_CONFIG) @touch $(LAST_BUILD_CONFIG)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Compile the kernel ELF ## Compile the kernel ELF
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
$(KERNEL_ELF_RAW): $(KERNEL_ELF_RAW_DEPS) $(KERNEL_ELF_RAW): $(KERNEL_ELF_RAW_DEPS)
$(call color_header, "Compiling kernel ELF - $(BSP)") $(call color_header, "Compiling kernel ELF - $(BSP)")
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD) @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Precompute the kernel translation tables and patch them into the kernel ELF ## Precompute the kernel translation tables and patch them into the kernel ELF
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
$(KERNEL_ELF_TTABLES): $(KERNEL_ELF_TTABLES_DEPS) $(KERNEL_ELF_TTABLES): $(KERNEL_ELF_TTABLES_DEPS)
$(call color_header, "Precomputing kernel translation tables and patching kernel ELF") $(call color_header, "Precomputing kernel translation tables and patching kernel ELF")
@cp $(KERNEL_ELF_RAW) $(KERNEL_ELF_TTABLES) @cp $(KERNEL_ELF_RAW) $(KERNEL_ELF_TTABLES)
@$(DOCKER_TOOLS) $(EXEC_TT_TOOL) $(BSP) $(KERNEL_ELF_TTABLES) @$(DOCKER_TOOLS) $(EXEC_TT_TOOL) $(BSP) $(KERNEL_ELF_TTABLES)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Generate kernel symbols and patch them into the kernel ELF ## Generate kernel symbols and patch them into the kernel ELF
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
$(KERNEL_ELF_TTABLES_SYMS): $(KERNEL_ELF_TTABLES_SYMS_DEPS) $(KERNEL_ELF_TTABLES_SYMS): $(KERNEL_ELF_TTABLES_SYMS_DEPS)
$(call color_header, "Generating kernel symbols and patching kernel ELF") $(call color_header, "Generating kernel symbols and patching kernel ELF")
@$(MAKE) --no-print-directory -f kernel_symbols.mk @$(MAKE) --no-print-directory -f kernel_symbols.mk
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Generate the stripped kernel binary ## Generate the stripped kernel binary
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
$(KERNEL_BIN): $(KERNEL_ELF_TTABLES_SYMS) $(KERNEL_BIN): $(KERNEL_ELF_TTABLES_SYMS)
$(call color_header, "Generating stripped binary") $(call color_header, "Generating stripped binary")
@$(OBJCOPY_CMD) $(KERNEL_ELF_TTABLES_SYMS) $(KERNEL_BIN) @$(OBJCOPY_CMD) $(KERNEL_ELF_TTABLES_SYMS) $(KERNEL_BIN)
@ -219,16 +219,16 @@ $(KERNEL_BIN): $(KERNEL_ELF_TTABLES_SYMS)
$(call color_progress_prefix, "Size") $(call color_progress_prefix, "Size")
$(call disk_usage_KiB, $(KERNEL_BIN)) $(call disk_usage_KiB, $(KERNEL_BIN))
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Generate the documentation ## Generate the documentation
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
doc: clean doc: clean
$(call color_header, "Generating docs") $(call color_header, "Generating docs")
@$(DOC_CMD) --document-private-items --open @$(DOC_CMD) --document-private-items --open
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run the kernel in QEMU ## Run the kernel in QEMU
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board.
qemu: qemu:
@ -242,36 +242,36 @@ qemu: $(KERNEL_BIN)
endif endif
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Push the kernel to the real HW target ## Push the kernel to the real HW target
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
chainboot: $(KERNEL_BIN) chainboot: $(KERNEL_BIN)
@$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(KERNEL_BIN) @$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(KERNEL_BIN)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run clippy ## Run clippy
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
clippy: clippy:
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD)
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) --features test_build --tests \ @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) --features test_build --tests \
--manifest-path $(KERNEL_MANIFEST) --manifest-path $(KERNEL_MANIFEST)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Clean ## Clean
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
clean: clean:
rm -rf target $(KERNEL_BIN) rm -rf target $(KERNEL_BIN)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run readelf ## Run readelf
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
readelf: $(KERNEL_ELF) readelf: $(KERNEL_ELF)
$(call color_header, "Launching readelf") $(call color_header, "Launching readelf")
@$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF) @$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run objdump ## Run objdump
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
objdump: $(KERNEL_ELF) objdump: $(KERNEL_ELF)
$(call color_header, "Launching objdump") $(call color_header, "Launching objdump")
@$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \ @$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \
@ -279,36 +279,36 @@ objdump: $(KERNEL_ELF)
--section .rodata \ --section .rodata \
$(KERNEL_ELF) | rustfilt $(KERNEL_ELF) | rustfilt
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run nm ## Run nm
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
nm: $(KERNEL_ELF) nm: $(KERNEL_ELF)
$(call color_header, "Launching nm") $(call color_header, "Launching nm")
@$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt @$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Debugging targets ## Debugging targets
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
.PHONY: jtagboot openocd gdb gdb-opt0 .PHONY: jtagboot openocd gdb gdb-opt0
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Push the JTAG boot image to the real HW target ## Push the JTAG boot image to the real HW target
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
jtagboot: jtagboot:
@$(DOCKER_JTAGBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(JTAG_BOOT_IMAGE) @$(DOCKER_JTAGBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(JTAG_BOOT_IMAGE)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Start OpenOCD session ## Start OpenOCD session
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
openocd: openocd:
$(call color_header, "Launching OpenOCD") $(call color_header, "Launching OpenOCD")
@$(DOCKER_OPENOCD) openocd $(OPENOCD_ARG) @$(DOCKER_OPENOCD) openocd $(OPENOCD_ARG)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Start GDB session ## Start GDB session
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
gdb-opt0: RUSTC_MISC_ARGS += -C opt-level=0 gdb-opt0: RUSTC_MISC_ARGS += -C opt-level=0
gdb gdb-opt0: $(KERNEL_ELF) gdb gdb-opt0: $(KERNEL_ELF)
$(call color_header, "Launching GDB") $(call color_header, "Launching GDB")
@ -316,9 +316,9 @@ gdb gdb-opt0: $(KERNEL_ELF)
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Testing targets ## Testing targets
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
.PHONY: test test_boot test_unit test_integration .PHONY: test test_boot test_unit test_integration
test_unit test_integration: FEATURES += --features test_build test_unit test_integration: FEATURES += --features test_build
@ -330,16 +330,16 @@ test_boot test_unit test_integration test:
else # QEMU is supported. else # QEMU is supported.
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run boot test ## Run boot test
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
test_boot: $(KERNEL_BIN) test_boot: $(KERNEL_BIN)
$(call color_header, "Boot test - $(BSP)") $(call color_header, "Boot test - $(BSP)")
@$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN) @$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Helpers for unit and integration test targets ## Helpers for unit and integration test targets
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
define KERNEL_TEST_RUNNER define KERNEL_TEST_RUNNER
#!/usr/bin/env bash #!/usr/bin/env bash
@ -372,17 +372,17 @@ define test_prepare
@chmod +x target/kernel_test_runner.sh @chmod +x target/kernel_test_runner.sh
endef endef
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run unit test(s) ## Run unit test(s)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
test_unit: test_unit:
$(call color_header, "Compiling unit test(s) - $(BSP)") $(call color_header, "Compiling unit test(s) - $(BSP)")
$(call test_prepare) $(call test_prepare)
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(TEST_CMD) --lib @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(TEST_CMD) --lib
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run integration test(s) ## Run integration test(s)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
test_integration: test_integration:
$(call color_header, "Compiling integration test(s) - $(BSP)") $(call color_header, "Compiling integration test(s) - $(BSP)")
$(call test_prepare) $(call test_prepare)

@ -1439,7 +1439,7 @@ diff -uNr 18_backtrace/Makefile 19_kernel_heap/Makefile
ifdef TEST ifdef TEST
TEST_ARG = --test $(TEST) TEST_ARG = --test $(TEST)
@@ -70,7 +75,7 @@ @@ -70,7 +75,7 @@
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
KERNEL_MANIFEST = kernel/Cargo.toml KERNEL_MANIFEST = kernel/Cargo.toml
KERNEL_LINKER_SCRIPT = kernel.ld KERNEL_LINKER_SCRIPT = kernel.ld
-LAST_BUILD_CONFIG = target/$(BSP).build_config -LAST_BUILD_CONFIG = target/$(BSP).build_config

@ -40,9 +40,9 @@ class RxStatisticsTest < SubtestBase
end end
end end
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Test registration ## Test registration
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
def subtest_collection def subtest_collection
[TxRxHandshakeTest.new, TxStatisticsTest.new, RxStatisticsTest.new] [TxRxHandshakeTest.new, TxStatisticsTest.new, RxStatisticsTest.new]
end end

@ -17,9 +17,9 @@ class ExceptionRestoreTest < SubtestBase
end end
end end
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Test registration ## Test registration
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
def subtest_collection def subtest_collection
[ExceptionRestoreTest.new] [ExceptionRestoreTest.new]
end end

@ -31,9 +31,9 @@ class BacktraceCorrectnessTest < SubtestBase
end end
end end
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Test registration ## Test registration
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
def subtest_collection def subtest_collection
[PanicBacktraceTest.new, BacktraceCorrectnessTest.new] [PanicBacktraceTest.new, BacktraceCorrectnessTest.new]
end end

@ -18,9 +18,9 @@ class InvalidFramePointerTest < SubtestBase
end end
end end
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Test registration ## Test registration
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
def subtest_collection def subtest_collection
[InvalidFramePointerTest.new] [InvalidFramePointerTest.new]
end end

@ -17,9 +17,9 @@ class InvalidLinkTest < SubtestBase
end end
end end
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Test registration ## Test registration
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
def subtest_collection def subtest_collection
[InvalidLinkTest.new] [InvalidLinkTest.new]
end end

@ -5,9 +5,9 @@
include ../common/format.mk include ../common/format.mk
include ../common/docker.mk include ../common/docker.mk
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Check for input variables that need be exported by the calling Makefile ## Check for input variables that need be exported by the calling Makefile
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
ifndef KERNEL_SYMBOLS_TOOL_PATH ifndef KERNEL_SYMBOLS_TOOL_PATH
$(error KERNEL_SYMBOLS_TOOL_PATH is not set) $(error KERNEL_SYMBOLS_TOOL_PATH is not set)
endif endif
@ -26,9 +26,9 @@ endif
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Targets and Prerequisites ## Targets and Prerequisites
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
KERNEL_SYMBOLS_MANIFEST = kernel_symbols/Cargo.toml KERNEL_SYMBOLS_MANIFEST = kernel_symbols/Cargo.toml
KERNEL_SYMBOLS_LINKER_SCRIPT = kernel_symbols/kernel_symbols.ld KERNEL_SYMBOLS_LINKER_SCRIPT = kernel_symbols/kernel_symbols.ld
@ -43,9 +43,9 @@ export KERNEL_SYMBOLS_DEMANGLED_RS
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Command building blocks ## Command building blocks
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
GET_SYMBOLS_SECTION_VIRT_ADDR = $(DOCKER_TOOLS) $(EXEC_SYMBOLS_TOOL) \ GET_SYMBOLS_SECTION_VIRT_ADDR = $(DOCKER_TOOLS) $(EXEC_SYMBOLS_TOOL) \
--get_symbols_section_virt_addr $(KERNEL_SYMBOLS_OUTPUT_ELF) --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 EXEC_SYMBOLS_TOOL = ruby $(KERNEL_SYMBOLS_TOOL_PATH)/main.rb
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Dockerization ## Dockerization
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial 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). # DOCKER_IMAGE defined in include file (see top of this file).
@ -76,9 +76,9 @@ DOCKER_TOOLS = $(DOCKER_CMD) $(DOCKER_IMAGE)
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Targets ## Targets
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
.PHONY: all symbols measure_time_start measure_time_finish .PHONY: all symbols measure_time_start measure_time_finish
all: measure_time_start symbols measure_time_finish all: measure_time_start symbols measure_time_finish

@ -161,7 +161,7 @@ def kernel_map_binary
mapping_descriptors.each do |i| mapping_descriptors.each do |i|
print 'Generating'.rjust(12).green.bold print 'Generating'.rjust(12).green.bold
print ' ' print ' '
puts i.to_s puts i
TRANSLATION_TABLES.map_at(i.virt_region, i.phys_region, i.attributes) TRANSLATION_TABLES.map_at(i.virt_region, i.phys_region, i.attributes)
end end

@ -6,9 +6,9 @@ include ../common/docker.mk
include ../common/format.mk include ../common/format.mk
include ../common/operating_system.mk include ../common/operating_system.mk
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Optional, user-provided configuration values ## Optional, user-provided configuration values
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
# Default to the RPi3. # Default to the RPi3.
BSP ?= rpi3 BSP ?= rpi3
@ -30,9 +30,9 @@ endif
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## BSP-specific configuration values ## BSP-specific configuration values
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
QEMU_MISSING_STRING = "This board is not yet supported for QEMU." QEMU_MISSING_STRING = "This board is not yet supported for QEMU."
ifeq ($(BSP),rpi3) ifeq ($(BSP),rpi3)
@ -70,9 +70,9 @@ export LD_SCRIPT_PATH
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Targets and Prerequisites ## Targets and Prerequisites
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
KERNEL_MANIFEST = kernel/Cargo.toml KERNEL_MANIFEST = kernel/Cargo.toml
KERNEL_LINKER_SCRIPT = kernel.ld KERNEL_LINKER_SCRIPT = kernel.ld
LAST_BUILD_CONFIG = target/$(BSP)_$(DEBUG_PRINTS).build_config 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 # 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) KERNEL_ELF_RAW_DEPS = $(filter-out %: ,$(file < $(KERNEL_ELF_RAW).d)) $(KERNEL_MANIFEST) $(LAST_BUILD_CONFIG)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Translation tables ## Translation tables
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
TT_TOOL_PATH = tools/translation_table_tool TT_TOOL_PATH = tools/translation_table_tool
KERNEL_ELF_TTABLES = target/$(TARGET)/release/kernel+ttables KERNEL_ELF_TTABLES = target/$(TARGET)/release/kernel+ttables
KERNEL_ELF_TTABLES_DEPS = $(KERNEL_ELF_RAW) $(wildcard $(TT_TOOL_PATH)/*) KERNEL_ELF_TTABLES_DEPS = $(KERNEL_ELF_RAW) $(wildcard $(TT_TOOL_PATH)/*)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Kernel symbols ## Kernel symbols
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
export KERNEL_SYMBOLS_TOOL_PATH = tools/kernel_symbols_tool export KERNEL_SYMBOLS_TOOL_PATH = tools/kernel_symbols_tool
KERNEL_ELF_TTABLES_SYMS = target/$(TARGET)/release/kernel+ttables+symbols KERNEL_ELF_TTABLES_SYMS = target/$(TARGET)/release/kernel+ttables+symbols
@ -111,9 +111,9 @@ KERNEL_ELF = $(KERNEL_ELF_TTABLES_SYMS)
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Command building blocks ## Command building blocks
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
RUSTFLAGS = $(RUSTC_MISC_ARGS) \ RUSTFLAGS = $(RUSTC_MISC_ARGS) \
-C link-arg=--library-path=$(LD_SCRIPT_PATH) \ -C link-arg=--library-path=$(LD_SCRIPT_PATH) \
-C link-arg=--script=$(KERNEL_LINKER_SCRIPT) -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_TEST_DISPATCH = ruby ../common/tests/dispatch.rb
EXEC_MINIPUSH = ruby ../common/serial/minipush.rb EXEC_MINIPUSH = ruby ../common/serial/minipush.rb
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Dockerization ## Dockerization
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial
DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i
DOCKER_ARG_DIR_COMMON = -v $(shell pwd)/../common:/work/common DOCKER_ARG_DIR_COMMON = -v $(shell pwd)/../common:/work/common
@ -171,46 +171,46 @@ endif
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Targets ## Targets
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
.PHONY: all doc qemu chainboot clippy clean readelf objdump nm check .PHONY: all doc qemu chainboot clippy clean readelf objdump nm check
all: $(KERNEL_BIN) all: $(KERNEL_BIN)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Save the configuration as a file, so make understands if it changed. ## Save the configuration as a file, so make understands if it changed.
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
$(LAST_BUILD_CONFIG): $(LAST_BUILD_CONFIG):
@rm -f target/*.build_config @rm -f target/*.build_config
@mkdir -p target @mkdir -p target
@touch $(LAST_BUILD_CONFIG) @touch $(LAST_BUILD_CONFIG)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Compile the kernel ELF ## Compile the kernel ELF
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
$(KERNEL_ELF_RAW): $(KERNEL_ELF_RAW_DEPS) $(KERNEL_ELF_RAW): $(KERNEL_ELF_RAW_DEPS)
$(call color_header, "Compiling kernel ELF - $(BSP)") $(call color_header, "Compiling kernel ELF - $(BSP)")
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD) @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Precompute the kernel translation tables and patch them into the kernel ELF ## Precompute the kernel translation tables and patch them into the kernel ELF
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
$(KERNEL_ELF_TTABLES): $(KERNEL_ELF_TTABLES_DEPS) $(KERNEL_ELF_TTABLES): $(KERNEL_ELF_TTABLES_DEPS)
$(call color_header, "Precomputing kernel translation tables and patching kernel ELF") $(call color_header, "Precomputing kernel translation tables and patching kernel ELF")
@cp $(KERNEL_ELF_RAW) $(KERNEL_ELF_TTABLES) @cp $(KERNEL_ELF_RAW) $(KERNEL_ELF_TTABLES)
@$(DOCKER_TOOLS) $(EXEC_TT_TOOL) $(BSP) $(KERNEL_ELF_TTABLES) @$(DOCKER_TOOLS) $(EXEC_TT_TOOL) $(BSP) $(KERNEL_ELF_TTABLES)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Generate kernel symbols and patch them into the kernel ELF ## Generate kernel symbols and patch them into the kernel ELF
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
$(KERNEL_ELF_TTABLES_SYMS): $(KERNEL_ELF_TTABLES_SYMS_DEPS) $(KERNEL_ELF_TTABLES_SYMS): $(KERNEL_ELF_TTABLES_SYMS_DEPS)
$(call color_header, "Generating kernel symbols and patching kernel ELF") $(call color_header, "Generating kernel symbols and patching kernel ELF")
@$(MAKE) --no-print-directory -f kernel_symbols.mk @$(MAKE) --no-print-directory -f kernel_symbols.mk
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Generate the stripped kernel binary ## Generate the stripped kernel binary
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
$(KERNEL_BIN): $(KERNEL_ELF_TTABLES_SYMS) $(KERNEL_BIN): $(KERNEL_ELF_TTABLES_SYMS)
$(call color_header, "Generating stripped binary") $(call color_header, "Generating stripped binary")
@$(OBJCOPY_CMD) $(KERNEL_ELF_TTABLES_SYMS) $(KERNEL_BIN) @$(OBJCOPY_CMD) $(KERNEL_ELF_TTABLES_SYMS) $(KERNEL_BIN)
@ -219,16 +219,16 @@ $(KERNEL_BIN): $(KERNEL_ELF_TTABLES_SYMS)
$(call color_progress_prefix, "Size") $(call color_progress_prefix, "Size")
$(call disk_usage_KiB, $(KERNEL_BIN)) $(call disk_usage_KiB, $(KERNEL_BIN))
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Generate the documentation ## Generate the documentation
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
doc: clean doc: clean
$(call color_header, "Generating docs") $(call color_header, "Generating docs")
@$(DOC_CMD) --document-private-items --open @$(DOC_CMD) --document-private-items --open
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run the kernel in QEMU ## Run the kernel in QEMU
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board.
qemu: qemu:
@ -242,36 +242,36 @@ qemu: $(KERNEL_BIN)
endif endif
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Push the kernel to the real HW target ## Push the kernel to the real HW target
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
chainboot: $(KERNEL_BIN) chainboot: $(KERNEL_BIN)
@$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(KERNEL_BIN) @$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(KERNEL_BIN)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run clippy ## Run clippy
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
clippy: clippy:
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD)
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) --features test_build --tests \ @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) --features test_build --tests \
--manifest-path $(KERNEL_MANIFEST) --manifest-path $(KERNEL_MANIFEST)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Clean ## Clean
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
clean: clean:
rm -rf target $(KERNEL_BIN) rm -rf target $(KERNEL_BIN)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run readelf ## Run readelf
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
readelf: $(KERNEL_ELF) readelf: $(KERNEL_ELF)
$(call color_header, "Launching readelf") $(call color_header, "Launching readelf")
@$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF) @$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run objdump ## Run objdump
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
objdump: $(KERNEL_ELF) objdump: $(KERNEL_ELF)
$(call color_header, "Launching objdump") $(call color_header, "Launching objdump")
@$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \ @$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \
@ -279,36 +279,36 @@ objdump: $(KERNEL_ELF)
--section .rodata \ --section .rodata \
$(KERNEL_ELF) | rustfilt $(KERNEL_ELF) | rustfilt
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run nm ## Run nm
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
nm: $(KERNEL_ELF) nm: $(KERNEL_ELF)
$(call color_header, "Launching nm") $(call color_header, "Launching nm")
@$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt @$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Debugging targets ## Debugging targets
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
.PHONY: jtagboot openocd gdb gdb-opt0 .PHONY: jtagboot openocd gdb gdb-opt0
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Push the JTAG boot image to the real HW target ## Push the JTAG boot image to the real HW target
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
jtagboot: jtagboot:
@$(DOCKER_JTAGBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(JTAG_BOOT_IMAGE) @$(DOCKER_JTAGBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(JTAG_BOOT_IMAGE)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Start OpenOCD session ## Start OpenOCD session
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
openocd: openocd:
$(call color_header, "Launching OpenOCD") $(call color_header, "Launching OpenOCD")
@$(DOCKER_OPENOCD) openocd $(OPENOCD_ARG) @$(DOCKER_OPENOCD) openocd $(OPENOCD_ARG)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Start GDB session ## Start GDB session
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
gdb-opt0: RUSTC_MISC_ARGS += -C opt-level=0 gdb-opt0: RUSTC_MISC_ARGS += -C opt-level=0
gdb gdb-opt0: $(KERNEL_ELF) gdb gdb-opt0: $(KERNEL_ELF)
$(call color_header, "Launching GDB") $(call color_header, "Launching GDB")
@ -316,9 +316,9 @@ gdb gdb-opt0: $(KERNEL_ELF)
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Testing targets ## Testing targets
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
.PHONY: test test_boot test_unit test_integration .PHONY: test test_boot test_unit test_integration
test_unit test_integration: FEATURES += --features test_build test_unit test_integration: FEATURES += --features test_build
@ -330,16 +330,16 @@ test_boot test_unit test_integration test:
else # QEMU is supported. else # QEMU is supported.
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run boot test ## Run boot test
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
test_boot: $(KERNEL_BIN) test_boot: $(KERNEL_BIN)
$(call color_header, "Boot test - $(BSP)") $(call color_header, "Boot test - $(BSP)")
@$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN) @$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Helpers for unit and integration test targets ## Helpers for unit and integration test targets
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
define KERNEL_TEST_RUNNER define KERNEL_TEST_RUNNER
#!/usr/bin/env bash #!/usr/bin/env bash
@ -372,17 +372,17 @@ define test_prepare
@chmod +x target/kernel_test_runner.sh @chmod +x target/kernel_test_runner.sh
endef endef
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run unit test(s) ## Run unit test(s)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
test_unit: test_unit:
$(call color_header, "Compiling unit test(s) - $(BSP)") $(call color_header, "Compiling unit test(s) - $(BSP)")
$(call test_prepare) $(call test_prepare)
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(TEST_CMD) --lib @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(TEST_CMD) --lib
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run integration test(s) ## Run integration test(s)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
test_integration: test_integration:
$(call color_header, "Compiling integration test(s) - $(BSP)") $(call color_header, "Compiling integration test(s) - $(BSP)")
$(call test_prepare) $(call test_prepare)

@ -11,9 +11,9 @@ bsp_rpi3 = ["tock-registers"]
bsp_rpi4 = ["tock-registers"] bsp_rpi4 = ["tock-registers"]
test_build = ["qemu-exit"] test_build = ["qemu-exit"]
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Dependencies ## Dependencies
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
[dependencies] [dependencies]
test-types = { path = "../libraries/test-types" } test-types = { path = "../libraries/test-types" }
@ -28,9 +28,9 @@ qemu-exit = { version = "3.x.x", optional = true }
[target.'cfg(target_arch = "aarch64")'.dependencies] [target.'cfg(target_arch = "aarch64")'.dependencies]
aarch64-cpu = { version = "9.x.x" } aarch64-cpu = { version = "9.x.x" }
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Testing ## Testing
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
[dev-dependencies] [dev-dependencies]
test-macros = { path = "../libraries/test-macros" } test-macros = { path = "../libraries/test-macros" }

@ -40,9 +40,9 @@ class RxStatisticsTest < SubtestBase
end end
end end
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Test registration ## Test registration
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
def subtest_collection def subtest_collection
[TxRxHandshakeTest.new, TxStatisticsTest.new, RxStatisticsTest.new] [TxRxHandshakeTest.new, TxStatisticsTest.new, RxStatisticsTest.new]
end end

@ -17,9 +17,9 @@ class ExceptionRestoreTest < SubtestBase
end end
end end
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Test registration ## Test registration
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
def subtest_collection def subtest_collection
[ExceptionRestoreTest.new] [ExceptionRestoreTest.new]
end end

@ -31,9 +31,9 @@ class BacktraceCorrectnessTest < SubtestBase
end end
end end
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Test registration ## Test registration
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
def subtest_collection def subtest_collection
[PanicBacktraceTest.new, BacktraceCorrectnessTest.new] [PanicBacktraceTest.new, BacktraceCorrectnessTest.new]
end end

@ -18,9 +18,9 @@ class InvalidFramePointerTest < SubtestBase
end end
end end
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Test registration ## Test registration
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
def subtest_collection def subtest_collection
[InvalidFramePointerTest.new] [InvalidFramePointerTest.new]
end end

@ -17,9 +17,9 @@ class InvalidLinkTest < SubtestBase
end end
end end
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Test registration ## Test registration
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
def subtest_collection def subtest_collection
[InvalidLinkTest.new] [InvalidLinkTest.new]
end end

@ -5,9 +5,9 @@
include ../common/format.mk include ../common/format.mk
include ../common/docker.mk include ../common/docker.mk
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Check for input variables that need be exported by the calling Makefile ## Check for input variables that need be exported by the calling Makefile
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
ifndef KERNEL_SYMBOLS_TOOL_PATH ifndef KERNEL_SYMBOLS_TOOL_PATH
$(error KERNEL_SYMBOLS_TOOL_PATH is not set) $(error KERNEL_SYMBOLS_TOOL_PATH is not set)
endif endif
@ -26,9 +26,9 @@ endif
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Targets and Prerequisites ## Targets and Prerequisites
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
KERNEL_SYMBOLS_MANIFEST = kernel_symbols/Cargo.toml KERNEL_SYMBOLS_MANIFEST = kernel_symbols/Cargo.toml
KERNEL_SYMBOLS_LINKER_SCRIPT = kernel_symbols/kernel_symbols.ld KERNEL_SYMBOLS_LINKER_SCRIPT = kernel_symbols/kernel_symbols.ld
@ -43,9 +43,9 @@ export KERNEL_SYMBOLS_DEMANGLED_RS
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Command building blocks ## Command building blocks
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
GET_SYMBOLS_SECTION_VIRT_ADDR = $(DOCKER_TOOLS) $(EXEC_SYMBOLS_TOOL) \ GET_SYMBOLS_SECTION_VIRT_ADDR = $(DOCKER_TOOLS) $(EXEC_SYMBOLS_TOOL) \
--get_symbols_section_virt_addr $(KERNEL_SYMBOLS_OUTPUT_ELF) --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 EXEC_SYMBOLS_TOOL = ruby $(KERNEL_SYMBOLS_TOOL_PATH)/main.rb
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Dockerization ## Dockerization
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial 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). # DOCKER_IMAGE defined in include file (see top of this file).
@ -76,9 +76,9 @@ DOCKER_TOOLS = $(DOCKER_CMD) $(DOCKER_IMAGE)
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Targets ## Targets
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
.PHONY: all symbols measure_time_start measure_time_finish .PHONY: all symbols measure_time_start measure_time_finish
all: measure_time_start symbols measure_time_finish all: measure_time_start symbols measure_time_finish

@ -161,7 +161,7 @@ def kernel_map_binary
mapping_descriptors.each do |i| mapping_descriptors.each do |i|
print 'Generating'.rjust(12).green.bold print 'Generating'.rjust(12).green.bold
print ' ' print ' '
puts i.to_s puts i
TRANSLATION_TABLES.map_at(i.virt_region, i.phys_region, i.attributes) TRANSLATION_TABLES.map_at(i.virt_region, i.phys_region, i.attributes)
end end

@ -16,9 +16,9 @@ bsp_rpi4 = ["tock-registers"]
name = "kernel" name = "kernel"
path = "src/main.rs" path = "src/main.rs"
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Dependencies ## Dependencies
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
[dependencies] [dependencies]

@ -6,9 +6,9 @@ include ../common/docker.mk
include ../common/format.mk include ../common/format.mk
include ../common/operating_system.mk include ../common/operating_system.mk
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Optional, user-provided configuration values ## Optional, user-provided configuration values
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
# Default to the RPi3. # Default to the RPi3.
BSP ?= rpi3 BSP ?= rpi3
@ -18,9 +18,9 @@ DEV_SERIAL ?= /dev/ttyUSB0
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## BSP-specific configuration values ## BSP-specific configuration values
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
QEMU_MISSING_STRING = "This board is not yet supported for QEMU." QEMU_MISSING_STRING = "This board is not yet supported for QEMU."
ifeq ($(BSP),rpi3) ifeq ($(BSP),rpi3)
@ -52,9 +52,9 @@ export LD_SCRIPT_PATH
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Targets and Prerequisites ## Targets and Prerequisites
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
KERNEL_MANIFEST = Cargo.toml KERNEL_MANIFEST = Cargo.toml
KERNEL_LINKER_SCRIPT = kernel.ld KERNEL_LINKER_SCRIPT = kernel.ld
LAST_BUILD_CONFIG = target/$(BSP).build_config 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 ## Command building blocks
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
RUSTFLAGS = $(RUSTC_MISC_ARGS) \ RUSTFLAGS = $(RUSTC_MISC_ARGS) \
-C link-arg=--library-path=$(LD_SCRIPT_PATH) \ -C link-arg=--library-path=$(LD_SCRIPT_PATH) \
-C link-arg=--script=$(KERNEL_LINKER_SCRIPT) -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_TEST_DISPATCH = ruby ../common/tests/dispatch.rb
EXEC_MINIPUSH = ruby ../common/serial/minipush.rb EXEC_MINIPUSH = ruby ../common/serial/minipush.rb
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Dockerization ## Dockerization
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial
DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i
DOCKER_ARG_DIR_COMMON = -v $(shell pwd)/../common:/work/common DOCKER_ARG_DIR_COMMON = -v $(shell pwd)/../common:/work/common
@ -115,31 +115,31 @@ endif
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Targets ## Targets
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
.PHONY: all doc qemu chainboot clippy clean readelf objdump nm check .PHONY: all doc qemu chainboot clippy clean readelf objdump nm check
all: $(KERNEL_BIN) all: $(KERNEL_BIN)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Save the configuration as a file, so make understands if it changed. ## Save the configuration as a file, so make understands if it changed.
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
$(LAST_BUILD_CONFIG): $(LAST_BUILD_CONFIG):
@rm -f target/*.build_config @rm -f target/*.build_config
@mkdir -p target @mkdir -p target
@touch $(LAST_BUILD_CONFIG) @touch $(LAST_BUILD_CONFIG)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Compile the kernel ELF ## Compile the kernel ELF
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
$(KERNEL_ELF): $(KERNEL_ELF_DEPS) $(KERNEL_ELF): $(KERNEL_ELF_DEPS)
$(call color_header, "Compiling kernel ELF - $(BSP)") $(call color_header, "Compiling kernel ELF - $(BSP)")
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD) @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Generate the stripped kernel binary ## Generate the stripped kernel binary
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
$(KERNEL_BIN): $(KERNEL_ELF) $(KERNEL_BIN): $(KERNEL_ELF)
$(call color_header, "Generating stripped binary") $(call color_header, "Generating stripped binary")
@$(OBJCOPY_CMD) $(KERNEL_ELF) $(KERNEL_BIN) @$(OBJCOPY_CMD) $(KERNEL_ELF) $(KERNEL_BIN)
@ -148,16 +148,16 @@ $(KERNEL_BIN): $(KERNEL_ELF)
$(call color_progress_prefix, "Size") $(call color_progress_prefix, "Size")
$(call disk_usage_KiB, $(KERNEL_BIN)) $(call disk_usage_KiB, $(KERNEL_BIN))
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Generate the documentation ## Generate the documentation
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
doc: doc:
$(call color_header, "Generating docs") $(call color_header, "Generating docs")
@$(DOC_CMD) --document-private-items --open @$(DOC_CMD) --document-private-items --open
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run the kernel in QEMU ## Run the kernel in QEMU
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board.
qemu: qemu:
@ -171,34 +171,34 @@ qemu: $(KERNEL_BIN)
endif endif
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Push the kernel to the real HW target ## Push the kernel to the real HW target
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
chainboot: $(KERNEL_BIN) chainboot: $(KERNEL_BIN)
@$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(KERNEL_BIN) @$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(KERNEL_BIN)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run clippy ## Run clippy
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
clippy: clippy:
@RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) @RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Clean ## Clean
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
clean: clean:
rm -rf target $(KERNEL_BIN) rm -rf target $(KERNEL_BIN)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run readelf ## Run readelf
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
readelf: $(KERNEL_ELF) readelf: $(KERNEL_ELF)
$(call color_header, "Launching readelf") $(call color_header, "Launching readelf")
@$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF) @$(DOCKER_TOOLS) $(READELF_BINARY) --headers $(KERNEL_ELF)
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run objdump ## Run objdump
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
objdump: $(KERNEL_ELF) objdump: $(KERNEL_ELF)
$(call color_header, "Launching objdump") $(call color_header, "Launching objdump")
@$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \ @$(DOCKER_TOOLS) $(OBJDUMP_BINARY) --disassemble --demangle \
@ -206,18 +206,18 @@ objdump: $(KERNEL_ELF)
--section .rodata \ --section .rodata \
$(KERNEL_ELF) | rustfilt $(KERNEL_ELF) | rustfilt
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run nm ## Run nm
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
nm: $(KERNEL_ELF) nm: $(KERNEL_ELF)
$(call color_header, "Launching nm") $(call color_header, "Launching nm")
@$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt @$(DOCKER_TOOLS) $(NM_BINARY) --demangle --print-size $(KERNEL_ELF) | sort | rustfilt
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Testing targets ## Testing targets
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
.PHONY: test test_boot .PHONY: test test_boot
ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board. ifeq ($(QEMU_MACHINE_TYPE),) # QEMU is not supported for the board.
@ -227,9 +227,9 @@ test_boot test:
else # QEMU is supported. else # QEMU is supported.
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
## Run boot test ## Run boot test
##------------------------------------------------------------------------------ ## ------------------------------------------------------------------------------
test_boot: $(KERNEL_BIN) test_boot: $(KERNEL_BIN)
$(call color_header, "Boot test - $(BSP)") $(call color_header, "Boot test - $(BSP)")
@$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN) @$(DOCKER_TEST) $(EXEC_TEST_DISPATCH) $(EXEC_QEMU) $(QEMU_RELEASE_ARGS) -kernel $(KERNEL_BIN)

@ -113,9 +113,9 @@ class MiniPush < MiniTerm
end end
end end
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Execution starts here ## Execution starts here
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
if __FILE__ == $PROGRAM_NAME if __FILE__ == $PROGRAM_NAME
puts puts
puts 'Minipush 1.0'.cyan puts 'Minipush 1.0'.cyan

@ -126,9 +126,9 @@ class MiniTerm
end end
end end
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Execution starts here ## Execution starts here
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
if __FILE__ == $PROGRAM_NAME if __FILE__ == $PROGRAM_NAME
puts puts
puts 'Miniterm 1.0'.cyan puts 'Miniterm 1.0'.cyan

@ -329,9 +329,9 @@ class DevTool
end end
end end
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
## Execution starts here ## Execution starts here
##-------------------------------------------------------------------------------------------------- ## --------------------------------------------------------------------------------------------------
tool = DevTool.new tool = DevTool.new
cmd = ARGV[0] cmd = ARGV[0]
commands = tool.public_methods(false).sort commands = tool.public_methods(false).sort

Loading…
Cancel
Save