summaryrefslogtreecommitdiffhomepage
path: root/src/arm64
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2025-04-02 09:48:06 +0200
committerAmlal El Mahrouss <amlal@nekernel.org>2025-04-02 09:48:06 +0200
commitb86c34ad45c2a066a9ca86a86b2c49d30697c671 (patch)
treecdf6c3f1c6479e4efd7b6f3597619c3e7b57fcd9 /src/arm64
parentc78e5763d8f5e471d043e6ed2752e245dbcaf047 (diff)
arm64: fix: a fully arm64 firmware + important fixes and patches.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'src/arm64')
-rw-r--r--src/arm64/arm64-boot.S15
-rw-r--r--src/arm64/arm64-start-context.S3
-rw-r--r--src/arm64/arm64-uart.c3
-rw-r--r--src/arm64/makefile23
-rw-r--r--src/arm64/script.lds18
5 files changed, 30 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/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