From d568c7bb99f55023be982abc0d702bb8016bcf9f Mon Sep 17 00:00:00 2001 From: jonay2000 Date: Mon, 9 Mar 2020 10:23:37 +0100 Subject: [PATCH] hopefully fixed CI by building qemu ourselves Co-authored-by: Victor Roest --- .github/workflows/os_test.yml | 13 ++++++++++++- Makefile | 8 +++++++- config.mk | 4 +--- kernel/Makefile | 2 +- kernel/src/common/include/interrupt.h | 2 +- kernel/src/common/interrupt.c | 10 ++-------- kernel/src/common/start.c | 5 ++--- kernel/src/klibc/klibc.c | 4 ++-- qemu/build.sh | 4 ++-- 9 files changed, 30 insertions(+), 22 deletions(-) diff --git a/.github/workflows/os_test.yml b/.github/workflows/os_test.yml index 4f0ed217..87714358 100644 --- a/.github/workflows/os_test.yml +++ b/.github/workflows/os_test.yml @@ -15,15 +15,26 @@ jobs: path: toolchain key: toolchain + - name: Cache Qemu + id: cache-qemu + uses: actions/cache@v1 + with: + path: toolchain + key: toolchain + - name: Install Dependencies run: | sudo apt-get update && sudo apt-get install build-essential qemu-system-arm python3 wget texinfo zlib1g-dev -y - - name: Install Toolchain + - name: Build Toolchain if: steps.cache-toolchain.outputs.cache-hit != 'true' run: rm -rf toolchain/arm-none-eabi/ && make toolchain + - name: Build Qemu + if: steps.cache-qemu.outputs.cache-hit != 'true' + run: rm -rf qemu/qemu* && make qemu + - name: Compile run: make build diff --git a/Makefile b/Makefile index 486eb04e..05ead509 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,15 @@ -all: toolchain kernel +all: requirements kernel toolchain: cd ./toolchain && ./build.sh .PHONY: toolchain +qemu: + cd ./qemu && ./build.sh +.PHONY: qemu + +requirements: toolchain qemu + libc: $(MAKE) -C user/libc diff --git a/config.mk b/config.mk index 1cb1f7d0..0ff9e2e6 100644 --- a/config.mk +++ b/config.mk @@ -3,9 +3,7 @@ TOOLCHAIN_DIR=toolchain BARE_METAL_TUPLE=arm-none-eabi BARE_METAL_TARGET:=$(BARE_METAL_TUPLE) -QEMU=qemu-system-arm - -UBOOT_VERSION=2014.10 +QEMU=./qemu/qemu/bin/qemu-system-arm #CFLAGS = -mcpu=arm1136j-s CFLAGS = -mcpu=arm1176jz-s diff --git a/kernel/Makefile b/kernel/Makefile index 5cdacf31..414b16a1 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -26,8 +26,8 @@ CC:=$(TOOLCHAIN_PATH)/$(BARE_METAL_TUPLE)-gcc AS:=$(TOOLCHAIN_PATH)/$(BARE_METAL_TUPLE)-as LD:=$(TOOLCHAIN_PATH)/$(BARE_METAL_TUPLE)-gcc OBJCOPY:=$(TOOLCHAIN_PATH)/$(BARE_METAL_TUPLE)-objcopy -MKIMAGE:=$(CURDIR)/../u-boot/u-boot-$(UBOOT_VERSION)/tools/mkimage GDB:=$(TOOLCHAIN_PATH)/$(BARE_METAL_TUPLE)-gdb +QEMU := $(CURDIR)/../${QEMU} DIRS = $(shell find $(SOURCEDIR)/ -type d -print) C_SOURCE_FILES := $(foreach dir,$(DIRS),$(wildcard $(dir)/*.c)) $(TEST_MAIN_FILE) diff --git a/kernel/src/common/include/interrupt.h b/kernel/src/common/include/interrupt.h index 9c9fb7ad..75286816 100644 --- a/kernel/src/common/include/interrupt.h +++ b/kernel/src/common/include/interrupt.h @@ -92,7 +92,7 @@ enum SemihostingSWI { void SemihostingCall(enum SemihostingSWI mode); -void SemihostingOSExit(int code) __attribute__ ((noreturn));; +void SemihostingOSExit(uint8_t code) __attribute__ ((noreturn));; typedef enum { IRQ, // (this is bit 0x8 on the CPSR) diff --git a/kernel/src/common/interrupt.c b/kernel/src/common/interrupt.c index 409f459f..8861cc13 100644 --- a/kernel/src/common/interrupt.c +++ b/kernel/src/common/interrupt.c @@ -270,14 +270,8 @@ void __attribute__((always_inline)) inline SemihostingCall(enum SemihostingSWI m /// Uses the ExtendedExit Semihosting call /// ARM Docs: https://developer.arm.com/docs/100863/0200/semihosting-operations/sys_exit_extended-0x20 -void __attribute__((always_inline)) inline SemihostingOSExit(int code) { - struct { - uint32_t field1; - uint32_t field2; - } parameters; - - parameters.field1 = ApplicationExit; - parameters.field2 = code; +void __attribute__((always_inline)) inline SemihostingOSExit(uint8_t code) { + struct {uint32_t f1; uint32_t f2;} parameters = {ApplicationExit, code }; asm volatile ( "MOV r0, #0x20\n" diff --git a/kernel/src/common/start.c b/kernel/src/common/start.c index 4d1ae2f7..4421288a 100644 --- a/kernel/src/common/start.c +++ b/kernel/src/common/start.c @@ -58,14 +58,13 @@ void start(uint32_t *p_bootargs) { // After this point kmalloc and kfree can be used for dynamic memory management. init_heap(); - + // Splash screen splash(); - // Turn on interrupts enable_interrupt(BOTH); - // Call the chipset again to do post-interrupt-enable initialization + // Call the chipset again to do any initialization after enabling interrupts and the heap. chipset.late_init(); diff --git a/kernel/src/klibc/klibc.c b/kernel/src/klibc/klibc.c index 9e7296db..9f3d49c2 100644 --- a/kernel/src/klibc/klibc.c +++ b/kernel/src/klibc/klibc.c @@ -41,9 +41,9 @@ * panic() added - Currrently states the panic and stalls the machine */ -void panic() { +void inline panic() { disable_interrupt(BOTH); - kprintf("Kernel panic!\n"); + WARN("Kernel panic!\n"); kprintf("\n ) ( \n"); kprintf(" ( /( ( )\\ ) \n"); kprintf(" )\\()) ( ( ( )\\ (()/( ) ( \n"); diff --git a/qemu/build.sh b/qemu/build.sh index a9cce93b..e0e9543c 100755 --- a/qemu/build.sh +++ b/qemu/build.sh @@ -1,8 +1,8 @@ #!/bin/bash -QEMU_VERSION=2.4.1 +QEMU_VERSION=4.2.0 -qemu-system-arm --version || { +{ if [ ! -e qemu-${QEMU_VERSION}.tar.bz2 ]; then wget http://wiki.qemu-project.org/download/qemu-${QEMU_VERSION}.tar.bz2