diff options
| author | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2025-04-02 09:52:34 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-02 09:52:34 +0200 |
| commit | f42ce43556475acb576fa926f685128d1dccf64b (patch) | |
| tree | fe73e12f9b1bbee1c561a52a78a262bc60c90792 /src/arm64 | |
| parent | c78e5763d8f5e471d043e6ed2752e245dbcaf047 (diff) | |
| parent | 74f329a38884e3d3468ad6abad43a4fbd7afa970 (diff) | |
Merge pull request #1 from amlel-el-mahrouss/dev
arm64: fix: a fully arm64 firmware + important fixes and patches.
Diffstat (limited to 'src/arm64')
| -rw-r--r-- | src/arm64/arm64-boot.S | 15 | ||||
| -rw-r--r-- | src/arm64/arm64-start-context.S | 3 | ||||
| -rw-r--r-- | src/arm64/arm64-uart.c | 3 | ||||
| -rw-r--r-- | src/arm64/ci.make | 70 | ||||
| -rw-r--r-- | src/arm64/makefile | 23 | ||||
| -rw-r--r-- | src/arm64/script.lds | 18 |
6 files changed, 100 insertions, 32 deletions
diff --git a/src/arm64/arm64-boot.S b/src/arm64/arm64-boot.S index bcbec0e..4fbd3f8 100644 --- a/src/arm64/arm64-boot.S +++ b/src/arm64/arm64-boot.S @@ -1,15 +1,14 @@ /* ------------------------------------------- - Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved. + Copyright (C) 2024-2025, Amlal EL Mahrouss, all rights reserved. ------------------------------------------- */ -.text - -.balign 4 +.section .text .global cb_reset_vector - cb_reset_vector: - ldr sp, =__cb_stack_end - /* don't care about page_zero, it's gonna be a raw binary */ - b cb_start_exec + ldr x0, =0x40080000 + mov sp, x0 + b cb_start_exec + + diff --git a/src/arm64/arm64-start-context.S b/src/arm64/arm64-start-context.S index 5db92d0..5a2539b 100644 --- a/src/arm64/arm64-start-context.S +++ b/src/arm64/arm64-start-context.S @@ -11,7 +11,6 @@ cb_start_context: bl cb_start_context - ldr pc, [lr] cb_boot_processor_ready: - ldr pc, [lr] + bl cb_boot_processor_ready diff --git a/src/arm64/arm64-uart.c b/src/arm64/arm64-uart.c index 362fc24..7455626 100644 --- a/src/arm64/arm64-uart.c +++ b/src/arm64/arm64-uart.c @@ -21,12 +21,11 @@ static boolean cb_locked_put_char = no; /// @brief Retrieve character from cb_uart_ptr utf_char_t cb_get_char(void) { - // check if ready. while ((ARM64_MMIO_REG(0x018) & (1 << 4))) { } - return (utf_char_t)ARM64_MMIO_REG(0x0); + return (utf_char_t)ARM64_MMIO_REG(0x0) & 0xFF; } void cb_put_char(utf_char_t ch) diff --git a/src/arm64/ci.make b/src/arm64/ci.make new file mode 100644 index 0000000..169d7f7 --- /dev/null +++ b/src/arm64/ci.make @@ -0,0 +1,70 @@ + # + # ======================================================== + # + # CoreBoot + # Date Added: 08/11/2023 + # Copyright 2024, ZKA Technologies, all rights reserved. + # + # ======================================================== + # + +CC=aarch64-linux-gnu-gcc +AS=aarch64-linux-gnu-as + +COREBOOT=core-boot.elf +FIRMWARE=boot.rom +STAGE2=bootstg2.rom + +FLAGS=-c -D__COMPILE_ARM64__ -I../../ -Wall -c -nostdlib -ffreestanding -fno-builtin \ + -D__BSTRICT__ -D__BDEBUG__ + +C_SRC=$(wildcard *.c) $(wildcard ../*.c) -c + +AS_FLAGS= -c -I../../ + +LD=aarch64-linux-gnu-ld +OBJ=*.o +FLAGS_LD= --script=script.lds -o core-boot.elf -nostdlib +OBJCOPY=aarch64-linux-gnu-objcopy + +EMU=qemu-system-aarch64 +EMU_FLAGS=-M virt -cpu cortex-a57 -bios $(FIRMWARE) -m 256M -d int -smp 2 + +WAIT=sleep 1 + +.PHONY: all +all: firmware-link + @echo "[CoreBoot] build done." + +.PHONY: firmware-link +firmware-link: firmware-compile + $(LD) $(OBJ) $(FLAGS_LD) + +.PHONY: rom +rom: + qemu-img create -f qcow2 epm.img 256M + qemu-img create -f raw bootstg2.rom 64M + $(OBJCOPY) --strip-all -O binary $(COREBOOT) $(FIRMWARE) + +# compile firmware +.PHONY: firmware-compile +firmware-compile: + $(CC) $(FLAGS) $(C_SRC) + $(AS) arm64-start-context.S -o arm64-start-context.o + $(AS) arm64-boot.S -o arm64-boot.o + + +# launch qemu rule +.PHONY: run +run: + $(EMU) $(EMU_FLAGS) + +# launch qemu with attached debugger +.PHONY: run-dbg +run-dbg: + $(EMU) -s -S $(EMU_FLAGS) + +# remove object files +.PHONY: clean +clean: + rm -f $(wildcard *.o) $(wildcard *.elf) $(wildcard *.rom) $(wildcard *.epm) diff --git a/src/arm64/makefile b/src/arm64/makefile index 19f88f5..7aa0ae4 100644 --- a/src/arm64/makefile +++ b/src/arm64/makefile @@ -8,10 +8,12 @@ # ======================================================== # -CC=arm-none-eabi-gcc -AS=arm-none-eabi-as +CC=aarch64-elf-gcc +AS=aarch64-elf-as +COREBOOT=core-boot.elf FIRMWARE=boot.rom +STAGE2=bootstg2.rom FLAGS=-c -D__COMPILE_ARM64__ -I../../ -Wall -c -nostdlib -ffreestanding -fno-builtin \ -D__BSTRICT__ -D__BDEBUG__ @@ -20,13 +22,13 @@ C_SRC=$(wildcard *.c) $(wildcard ../*.c) -c AS_FLAGS= -c -I../../ -LD=arm-none-eabi-ld +LD=aarch64-elf-ld OBJ=*.o FLAGS_LD= --script=script.lds -o core-boot.elf -nostdlib +OBJCOPY=aarch64-elf-objcopy -EMU=qemu-system-arm -EMU_FLAGS=-M virt -cpu cortex-a15 -kernel $(FIRMWARE) -s \ - -drive file=bootstg2.rom,format=raw +EMU=qemu-system-aarch64 +EMU_FLAGS=-M virt -cpu cortex-a57 -bios $(FIRMWARE) -m 256M -d int -smp 2 WAIT=sleep 1 @@ -41,16 +43,15 @@ firmware-link: firmware-compile .PHONY: rom rom: qemu-img create -f qcow2 epm.img 256M - qemu-img create -f raw boot.rom 512K qemu-img create -f raw bootstg2.rom 64M - dd if=core-boot.elf of=boot.rom bs=1 seek=0 conv=notrunc + $(OBJCOPY) --strip-all -O binary $(COREBOOT) $(FIRMWARE) # compile firmware .PHONY: firmware-compile firmware-compile: $(CC) $(FLAGS) $(C_SRC) - $(AS) -march=armv7-a -mcpu=cortex-a15 arm64-start-context.S -o arm64-start-context.o - $(AS) -march=armv7-a -mcpu=cortex-a15 arm64-boot.S -o arm64-boot.o + $(AS) arm64-start-context.S -o arm64-start-context.o + $(AS) arm64-boot.S -o arm64-boot.o # launch qemu rule @@ -61,7 +62,7 @@ run: # launch qemu with attached debugger .PHONY: run-dbg run-dbg: - $(EMU) $(EMU_FLAGS) + $(EMU) -s -S $(EMU_FLAGS) # remove object files .PHONY: clean diff --git a/src/arm64/script.lds b/src/arm64/script.lds index b8a0d11..6daad64 100644 --- a/src/arm64/script.lds +++ b/src/arm64/script.lds @@ -1,14 +1,14 @@ ENTRY(cb_reset_vector) + SECTIONS { - . = 0x40100000; + . = 0x00000000; - .text : { *(.text) } - .data : { *(.data) } - .bss : { *(.bss COMMON) } - . = ALIGN(8); - . = . + 0x1000; /* 4kB of stack memory */ - __cb_stack_end = .; + .text : { + *(.text*) + } - PROVIDE(cb_memory_end = .); -} + .bss : { + *(.bss*) + } +}
\ No newline at end of file |
