hc
2024-11-01 2f529f9b558ca1c1bd74be7437a84e4711743404
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
 * SPDX-License-Identifier: GPL-2.0
 */
 
#ifndef _COBALT_KERNEL_DOVETAIL_CLOCK_H
#define _COBALT_KERNEL_DOVETAIL_CLOCK_H
 
#include <cobalt/uapi/kernel/types.h>
#include <cobalt/kernel/assert.h>
#include <linux/ktime.h>
#include <linux/errno.h>
 
struct timespec64;
 
static inline u64 pipeline_read_cycle_counter(void)
{
   /*
    * With Dovetail, our idea of time is directly based on a
    * refined count of nanoseconds since the epoch, the hardware
    * time counter is transparent to us. For this reason,
    * xnclock_ticks_to_ns() and xnclock_ns_to_ticks() are
    * idempotent when building for Dovetail.
    */
   return ktime_get_mono_fast_ns();
}
 
static inline xnticks_t pipeline_read_wallclock(void)
{
   return ktime_get_real_fast_ns();
}
 
static inline int pipeline_set_wallclock(xnticks_t epoch_ns)
{
   return -EOPNOTSUPP;
}
 
void pipeline_set_timer_shot(unsigned long cycles);
 
const char *pipeline_timer_name(void);
 
static inline const char *pipeline_clock_name(void)
{
   return "<Linux clocksource>";
}
 
static inline int pipeline_get_host_time(struct timespec64 *tp)
{
   /* Convert ktime_get_real_fast_ns() to timespec. */
   *tp = ktime_to_timespec64(ktime_get_real_fast_ns());
 
   return 0;
}
 
static inline void pipeline_init_clock(void)
{
   /* N/A */
}
 
static inline xnsticks_t xnclock_core_ticks_to_ns(xnsticks_t ticks)
{
   return ticks;
}
 
static inline xnsticks_t xnclock_core_ticks_to_ns_rounded(xnsticks_t ticks)
{
   return ticks;
}
 
static inline xnsticks_t xnclock_core_ns_to_ticks(xnsticks_t ns)
{
   return ns;
}
 
#endif /* !_COBALT_KERNEL_DOVETAIL_CLOCK_H */