From 9bbc0e19a1a30a3554ebbaa29502cc682bdcd081 Mon Sep 17 00:00:00 2001 From: able Date: Fri, 14 Jul 2023 19:38:13 -0500 Subject: [PATCH] ARM: it compiles but does not yet run :V --- kernel/lds/aarch64-qemu.ld | 14 +++++++++++++ kernel/src/arch/aarch64/mod.rs | 27 +++++++++++++++++++++++-- kernel/targets/aarch64-virt-ableos.json | 2 +- repbuild/src/main.rs | 3 ++- 4 files changed, 42 insertions(+), 4 deletions(-) create mode 100644 kernel/lds/aarch64-qemu.ld diff --git a/kernel/lds/aarch64-qemu.ld b/kernel/lds/aarch64-qemu.ld new file mode 100644 index 0000000..e3a62a2 --- /dev/null +++ b/kernel/lds/aarch64-qemu.ld @@ -0,0 +1,14 @@ +ENTRY(_start) +SECTIONS +{ + . = 0x40080000; + .text.boot : { *(.text.boot) } + .text : { *(.text) } + .data : { *(.data) } + .rodata : { *(.rodata) } + .bss : { *(.bss) } + + . = ALIGN(8); + . = . + 0x4000; + LD_STACK_PTR = .; +} \ No newline at end of file diff --git a/kernel/src/arch/aarch64/mod.rs b/kernel/src/arch/aarch64/mod.rs index 68328c1..825d19c 100644 --- a/kernel/src/arch/aarch64/mod.rs +++ b/kernel/src/arch/aarch64/mod.rs @@ -1,4 +1,27 @@ //! - +use core::ptr; #[no_mangle] -unsafe extern "C" fn _kernel_start() -> ! {} +unsafe extern "C" fn _kernel_start() -> ! { + const UART0: *mut u8 = 0x0900_0000 as *mut u8; + let out_str = b"AArch64 Bare Metal"; + for byte in out_str { + unsafe { + ptr::write_volatile(UART0, *byte); + } + } + + loop {} +} + +pub fn log(_args: core::fmt::Arguments<'_>) -> core::fmt::Result { + panic!() +} + +pub fn sloop() -> ! { + loop {} +} +pub fn hardware_random_u64() -> u64 { + 0 +} + +pub const PAGE_SIZE: usize = 10; diff --git a/kernel/targets/aarch64-virt-ableos.json b/kernel/targets/aarch64-virt-ableos.json index dfb116a..fcb14d0 100644 --- a/kernel/targets/aarch64-virt-ableos.json +++ b/kernel/targets/aarch64-virt-ableos.json @@ -10,7 +10,7 @@ "linker-is-gnu": true, "pre-link-args": { "ld.lld": [ - "-Taarch64-qemu.ld" + "-Tkernel/lds/aarch64-qemu.ld" ] }, "llvm-target": "aarch64-unknown-none", diff --git a/repbuild/src/main.rs b/repbuild/src/main.rs index 0af1659..d7d688e 100644 --- a/repbuild/src/main.rs +++ b/repbuild/src/main.rs @@ -225,7 +225,8 @@ fn run(release: bool, target: Target) -> Result<(), Error> { if target == Target::Aarch64 { com.args([ "-M", "virt", "-m", // - "128M", "-serial", "stdio", + "128M", + // "-serial", "stdio", ]); }