diff --git a/Cargo.toml b/Cargo.toml index 440df504..ae26d14d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,6 +24,7 @@ log-panic = ["log-serial"] integration_tests = [] coreboot = [] efi-var = [] +debug = [] [dependencies] bitflags = "2.2.1" diff --git a/src/arch/aarch64/ram64.s b/src/arch/aarch64/ram64.s index 93e28e63..0f6226f1 100644 --- a/src/arch/aarch64/ram64.s +++ b/src/arch/aarch64/ram64.s @@ -3,6 +3,7 @@ .section .text.boot, "ax" .global ram64_start +.global debug_point ram64_start: /* @@ -26,6 +27,8 @@ ram64_start: .align 3 jump_to_rust: + bl debug_point + /* x0 typically points to device tree at entry */ ldr x0, ={FDT_START} @@ -34,4 +37,4 @@ jump_to_rust: mov sp, x30 /* x0: pointer to device tree */ - b rust64_start \ No newline at end of file + b rust64_start diff --git a/src/main.rs b/src/main.rs index 53fb2dc2..fae986fd 100644 --- a/src/main.rs +++ b/src/main.rs @@ -27,6 +27,10 @@ use core::panic::PanicInfo; #[cfg(target_arch = "x86_64")] use x86_64::instructions::hlt; +#[cfg(target_arch = "aarch64")] +#[cfg(feature = "debug")] +use core::arch::asm; + #[macro_use] mod serial; @@ -144,6 +148,19 @@ fn boot_from_device(device: &mut block::VirtioBlockDevice, info: &dyn bootinfo:: }; log!("Executable loaded"); + + // mark here as the end of firmware and put stub here + #[cfg(target_arch = "aarch64")] + #[cfg(feature = "debug")] + unsafe { + asm! {" + movz x7, 0x0900, lsl 16 + add x7, x7, 0xf00 + mov x8, 0x02 + str w8, [x7]" + } + } + efi::efi_exec(entry_addr, load_addr, size, info, &f, device); true } @@ -165,6 +182,25 @@ pub extern "C" fn rust64_start(#[cfg(not(feature = "coreboot"))] pvh_info: &pvh: main(info) } +#[cfg(target_arch = "aarch64")] +#[cfg(feature = "debug")] +#[no_mangle] +pub extern "C" fn debug_point() { + unsafe { + asm! {" + movz x7, 0x0900, lsl 16 + add x7, x7, 0xf00 + mov x8, 0x01 + str w8, [x7]" + } + } +} + +#[cfg(target_arch = "aarch64")] +#[cfg(not(feature = "debug"))] +#[no_mangle] +pub extern "C" fn debug_point() {} + #[cfg(target_arch = "aarch64")] #[no_mangle] pub extern "C" fn rust64_start(x0: *const u8) -> ! {