arm64: Add timekeeping
Change-Id: Idc64a00e4dcc787e35afc560acd06a606a6a6964 Reviewed-on: https://review.haiku-os.org/c/haiku/+/10606 Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
committed by
waddlesplash
parent
1b4044fde1
commit
e78a97d381
@@ -8,14 +8,8 @@
|
||||
#include <StorageDefs.h>
|
||||
#include <SupportDefs.h>
|
||||
|
||||
struct arm64_real_time_data {
|
||||
vint64 system_time_offset;
|
||||
};
|
||||
|
||||
struct arch_real_time_data {
|
||||
struct arm64_real_time_data data[2];
|
||||
vint32 system_time_conversion_factor;
|
||||
vint32 version;
|
||||
bigtime_t system_time_offset;
|
||||
};
|
||||
|
||||
#endif /* _KERNEL_ARCH_REAL_TIME_DATA_H */
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <boot/stage2.h>
|
||||
#include <boot/stdio.h>
|
||||
|
||||
#include "arm_registers.h"
|
||||
#include "efi_platform.h"
|
||||
#include "generic_mmu.h"
|
||||
#include "mmu.h"
|
||||
@@ -183,6 +184,7 @@ arch_start_kernel(addr_t kernelEntry)
|
||||
// EL2 without E2H enabled does not, so we need to drop to EL1
|
||||
if (el == 1 || e2h) {
|
||||
arch_mmu_setup_EL1(READ_SPECIALREG(TCR_EL1));
|
||||
WRITE_SPECIALREG(CNTKCTL_EL1, 0b11);
|
||||
} else {
|
||||
arch_mmu_setup_EL1(READ_SPECIALREG(TCR_EL2));
|
||||
arch_cache_disable();
|
||||
|
||||
@@ -32,11 +32,12 @@ arch_rtc_set_hw_time(uint64 seconds)
|
||||
void
|
||||
arch_rtc_set_system_time_offset(struct real_time_data *data, bigtime_t offset)
|
||||
{
|
||||
atomic_set64(&data->arch_data.system_time_offset, offset);
|
||||
}
|
||||
|
||||
|
||||
bigtime_t
|
||||
arch_rtc_get_system_time_offset(struct real_time_data *data)
|
||||
{
|
||||
return 0;
|
||||
return atomic_get64(&data->arch_data.system_time_offset);
|
||||
}
|
||||
|
||||
@@ -12,5 +12,9 @@
|
||||
bigtime_t
|
||||
system_time(void)
|
||||
{
|
||||
return 0;
|
||||
uint64 ticks;
|
||||
uint64 freq;
|
||||
asm volatile("mrs %0, CNTPCT_EL0": "=r" (ticks));
|
||||
asm volatile("mrs %0, CNTFRQ_EL0": "=r" (freq));
|
||||
return (ticks * 1000000) / freq;
|
||||
}
|
||||
|
||||
@@ -19,5 +19,5 @@ __arch_init_time(struct real_time_data *data, bool setDefaults)
|
||||
bigtime_t
|
||||
__arch_get_system_time_offset(struct real_time_data *data)
|
||||
{
|
||||
return 0;
|
||||
return data->arch_data.system_time_offset;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user