1/* 2 * Copyright 2012-2020, Haiku, Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Ithamar R. Adema <ithamar@upgrade-android.com> 7 */ 8 9#include <OS.h> 10#include <boot/platform.h> 11#include <boot/stdio.h> 12#include <boot/kernel_args.h> 13#include <boot/stage2.h> 14#include <arch/cpu.h> 15#include <arch_cpu_defs.h> 16#include <arch_kernel.h> 17#include <arch_system_info.h> 18#include <string.h> 19 20 21#define TRACE_CPU 22#ifdef TRACE_CPU 23# define TRACE(x) dprintf x 24#else 25# define TRACE(x) ; 26#endif 27 28 29/*! Detect RISCV core extensions. 30*/ 31static status_t 32check_cpu_features() 33{ 34 // only seems possible from bootloader openfirmware or FDT? 35 return B_OK; 36} 37 38 39extern "C" status_t 40boot_arch_cpu_init(void) 41{ 42 status_t err = check_cpu_features(); 43 if (err != B_OK) { 44 panic("It's RISCY business trying to boot Haiku on the wrong CPU!\n"); 45 return err; 46 } 47 48 return B_OK; 49} 50 51 52extern "C" void 53arch_ucode_load(BootVolume& volume) 54{ 55 // NOP on riscv currently 56} 57 58 59extern "C" bigtime_t 60system_time() 61{ 62 // TODO: units conversion 63 return CpuTime(); 64} 65 66 67extern "C" void 68spin(bigtime_t microseconds) 69{ 70 bigtime_t time = system_time(); 71 while ((system_time() - time) < microseconds) 72 asm volatile ("nop;"); 73} 74