1/* 2 * Copyright 2021 Haiku, Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 6#include <arch/real_time_clock.h> 7#include <boot/kernel_args.h> 8 9#include <real_time_clock.h> 10#include <real_time_data.h> 11 12#include <Htif.h> 13 14 15status_t 16arch_rtc_init(kernel_args *args, struct real_time_data *data) 17{ 18 data->arch_data.system_time_conversion_factor 19 = (1LL << 32) * 1000000LL / args->arch_args.timerFrequency; 20 dprintf("timerFrequency: %" B_PRIu64 "\n", 21 args->arch_args.timerFrequency); 22 dprintf("system_time_conversion_factor: %" B_PRIu64 "\n", 23 data->arch_data.system_time_conversion_factor); 24 return B_OK; 25} 26 27 28uint32 29arch_rtc_get_hw_time(void) 30{ 31 return (uint32)(HtifCmd(2, 0, 0) / 1000000); 32} 33 34 35void 36arch_rtc_set_hw_time(uint32 seconds) 37{ 38} 39 40 41void 42arch_rtc_set_system_time_offset(struct real_time_data *data, bigtime_t offset) 43{ 44 atomic_set64(&data->arch_data.system_time_offset, offset); 45} 46 47 48bigtime_t 49arch_rtc_get_system_time_offset(struct real_time_data *data) 50{ 51 return atomic_get64(&data->arch_data.system_time_offset); 52} 53