1/* 2 * Copyright 2018, Data61 3 * Commonwealth Scientific and Industrial Research Organisation (CSIRO) 4 * ABN 41 687 119 230. 5 * 6 * This software may be distributed and modified according to the terms of 7 * the BSD 2-Clause license. Note that NO WARRANTY is provided. 8 * See "LICENSE_BSD2.txt" for details. 9 * 10 * @TAG(DATA61_BSD) 11 */ 12 13#include <sel4/kernel.h> 14 15#include <utils/util.h> 16#include <platsupport/timer.h> 17#include <bmk-core/core.h> 18#include <bmk-core/platform.h> 19#include <bmk-core/printf.h> 20#include <sel4/helpers.h> 21#include <stdio.h> 22 23/* RTC wall time offset at monotonic time base. */ 24static bmk_time_t rtc_epochoffset; 25 26int 27arch_init_clocks(env_t env) 28{ 29 /* 30 * For now, we are using the ltimer implementation in libplatsupport 31 * and don't have a clock like the TSC on ARM 32 */ 33 return 0; 34} 35 36 37bmk_time_t 38arch_cpu_clock_monotonic(void) 39{ 40 bmk_time_t now = 0; 41 42 timer_config_t *simple_timer_config = &env.custom_simple.timer_config; 43 if (simple_timer_config->timer == TIMER_INTERFACE) { 44 now = simple_timer_config->interface.time(); 45 } else { 46 UNUSED int err = ltimer_get_time(&simple_timer_config->ltimer.ltimer, (uint64_t *) &now); 47 } 48 49 return now; 50} 51 52bmk_time_t 53arch_cpu_clock_epochoffset(void) 54{ 55 return rtc_epochoffset; 56} 57