Skip to content

Commit

Permalink
AArch64: print timestamp for benchmarking
Browse files Browse the repository at this point in the history
Provide timestamp at the initial phase and the end of the rust firmware for
benchmarking.

Signed-off-by: Jianyong Wu <[email protected]>
  • Loading branch information
jongwu committed May 12, 2023
1 parent c74662d commit d73060a
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ log-panic = ["log-serial"]
integration_tests = []
coreboot = []
efi-var = []
debug = []

[dependencies]
bitflags = "2.2.1"
Expand Down
5 changes: 4 additions & 1 deletion src/arch/aarch64/ram64.s
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

.section .text.boot, "ax"
.global ram64_start
.global debug_point

ram64_start:
/*
Expand All @@ -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}

Expand All @@ -34,4 +37,4 @@ jump_to_rust:
mov sp, x30

/* x0: pointer to device tree */
b rust64_start
b rust64_start
36 changes: 36 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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
}
Expand All @@ -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) -> ! {
Expand Down

0 comments on commit d73060a

Please sign in to comment.