From d691f1e1816dc5f68824ff8f9ae6895268ef98bd Mon Sep 17 00:00:00 2001 From: Fredrik Holmqvist Date: Mon, 23 Aug 2021 21:19:06 +0200 Subject: [PATCH] WIP arm64 arch_cpu.cpp Still needs work, opted to have arch files in tree to share the burden of the port --- src/system/boot/arch/arm64/arch_cpu.cpp | 58 +++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 src/system/boot/arch/arm64/arch_cpu.cpp diff --git a/src/system/boot/arch/arm64/arch_cpu.cpp b/src/system/boot/arch/arm64/arch_cpu.cpp new file mode 100644 index 0000000000..d2d9a11059 --- /dev/null +++ b/src/system/boot/arch/arm64/arch_cpu.cpp @@ -0,0 +1,58 @@ +/* + * Copyright 2021, Haiku, Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + */ + +#include +#include +/* +#include +#include +#include +#include +#include +#include +#include +*/ + +extern "C" status_t +boot_arch_cpu_init(void) +{ + return B_OK; +} + + +extern "C" void +arch_ucode_load(BootVolume& volume) +{ + // Yes, we have no bananas! +} + + +extern "C" bigtime_t +system_time() +{ + + #warning Implement system_time in ARM64 bootloader! + //https://en.wikipedia.org/wiki/Time_Stamp_Counter + // read system time register: cntpct_el0 / cntvct_el0 + // frequency of the system timer can be discovered by reading cntfrq_el0 + // https://wiki.osdev.org/ARMv7_Generic_Timers#CNTPCT + + uint64_t ticks; + __asm__ volatile("mrs %0, cntpct_el0" : "=r"(ticks)); + //conversion factor stuff + return ticks; + //return u64_mul_u64_fp32_64(ticks, ns_per_cntpct); +} + + +extern "C" void +spin(bigtime_t microseconds) +{ + auto time = system_time(); + + while ((system_time() - time) < microseconds) + asm volatile ("yield;"); +}