kernel/arch/timer: implement for riscv64
Change-Id: Ia854b0048a86b1427e975f482325ed4d4df1a12a Reviewed-on: https://review.haiku-os.org/c/haiku/+/4061 Reviewed-by: Alex von Gluck IV <[email protected]>
This commit is contained in:
@@ -13,8 +13,7 @@
|
|||||||
|
|
||||||
struct arch_real_time_data {
|
struct arch_real_time_data {
|
||||||
bigtime_t system_time_offset;
|
bigtime_t system_time_offset;
|
||||||
uint32 system_time_conversion_factor;
|
uint64 system_time_conversion_factor;
|
||||||
uint32 _padding;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* _KERNEL_ARCH_REAL_TIME_DATA_H */
|
#endif /* _KERNEL_ARCH_REAL_TIME_DATA_H */
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2019, Haiku Inc. All rights reserved.
|
* Copyright 2019-2021, Haiku Inc. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -7,21 +7,54 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <kernel.h>
|
#include <arch_cpu_defs.h>
|
||||||
#include <debug.h>
|
#include <arch_int.h>
|
||||||
#include <timer.h>
|
|
||||||
#include <arch/timer.h>
|
#include <arch/timer.h>
|
||||||
|
#include <boot/kernel_args.h>
|
||||||
|
#include <debug.h>
|
||||||
|
#include <kernel.h>
|
||||||
|
#include <platform/sbi/sbi_syscalls.h>
|
||||||
|
#include <timer.h>
|
||||||
|
#include <Clint.h>
|
||||||
|
|
||||||
|
|
||||||
|
extern uint32 gPlatform1;
|
||||||
|
extern uint32 gPlatform2;
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
arch_timer_set_hardware_timer(bigtime_t timeout)
|
arch_timer_set_hardware_timer(bigtime_t timeout)
|
||||||
{
|
{
|
||||||
|
// TODO: Read timer frequency from FDT
|
||||||
|
switch (gPlatform1) {
|
||||||
|
case kPlatform1Riscv:
|
||||||
|
MSyscall(kMSyscallSetTimer, true,
|
||||||
|
gClintRegs->mtime + timeout * 10);
|
||||||
|
break;
|
||||||
|
case kPlatform1Sbi: {
|
||||||
|
sbi_set_timer(CpuTime() + timeout);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
arch_timer_clear_hardware_timer()
|
arch_timer_clear_hardware_timer()
|
||||||
{
|
{
|
||||||
|
switch (gPlatform1) {
|
||||||
|
case kPlatform1Riscv:
|
||||||
|
MSyscall(kMSyscallSetTimer, false);
|
||||||
|
break;
|
||||||
|
case kPlatform1Sbi: {
|
||||||
|
sbi_set_timer(CpuTime() + (uint64)10000000 * 3600);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -30,11 +63,3 @@ arch_init_timer(kernel_args *args)
|
|||||||
{
|
{
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bigtime_t
|
|
||||||
system_time(void)
|
|
||||||
{
|
|
||||||
// TODO
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ SEARCH_SOURCE += [ FDirName $(librootSources) os arch generic ] ;
|
|||||||
|
|
||||||
KernelMergeObject kernel_os_arch_$(TARGET_ARCH).o :
|
KernelMergeObject kernel_os_arch_$(TARGET_ARCH).o :
|
||||||
byteorder.S
|
byteorder.S
|
||||||
|
system_time.cpp
|
||||||
|
|
||||||
generic_atomic.cpp
|
generic_atomic.cpp
|
||||||
generic_system_time_nsecs.cpp
|
generic_system_time_nsecs.cpp
|
||||||
|
|||||||
Reference in New Issue
Block a user