Zephyr API Documentation  2.7.0-rc2
A Scalable Open Source RTOS
timing.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020 Intel Corporation.
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#ifndef ZEPHYR_INCLUDE_TIMING_TIMING_H_
8#define ZEPHYR_INCLUDE_TIMING_TIMING_H_
9
10#include <sys/arch_interface.h>
11#include <timing/types.h>
12
13void soc_timing_init(void);
15void soc_timing_stop(void);
18 volatile timing_t *const end);
23
29 volatile timing_t *const end);
34
35
42#ifdef CONFIG_TIMING_FUNCTIONS
43
49void timing_init(void);
50
57void timing_start(void);
58
65void timing_stop(void);
66
72static inline timing_t timing_counter_get(void)
73{
74#if defined(CONFIG_BOARD_HAS_TIMING_FUNCTIONS)
76#elif defined(CONFIG_SOC_HAS_TIMING_FUNCTIONS)
78#else
80#endif
81}
82
93static inline uint64_t timing_cycles_get(volatile timing_t *const start,
94 volatile timing_t *const end)
95{
96#if defined(CONFIG_BOARD_HAS_TIMING_FUNCTIONS)
97 return board_timing_cycles_get(start, end);
98#elif defined(CONFIG_SOC_HAS_TIMING_FUNCTIONS)
99 return soc_timing_cycles_get(start, end);
100#else
101 return arch_timing_cycles_get(start, end);
102#endif
103}
104
110static inline uint64_t timing_freq_get(void)
111{
112#if defined(CONFIG_BOARD_HAS_TIMING_FUNCTIONS)
113 return board_timing_freq_get();
114#elif defined(CONFIG_SOC_HAS_TIMING_FUNCTIONS)
115 return soc_timing_freq_get();
116#else
117 return arch_timing_freq_get();
118#endif
119}
120
128{
129#if defined(CONFIG_BOARD_HAS_TIMING_FUNCTIONS)
130 return board_timing_cycles_to_ns(cycles);
131#elif defined(CONFIG_SOC_HAS_TIMING_FUNCTIONS)
132 return soc_timing_cycles_to_ns(cycles);
133#else
134 return arch_timing_cycles_to_ns(cycles);
135#endif
136}
137
146{
147#if defined(CONFIG_BOARD_HAS_TIMING_FUNCTIONS)
148 return board_timing_cycles_to_ns_avg(cycles, count);
149#elif defined(CONFIG_SOC_HAS_TIMING_FUNCTIONS)
150 return soc_timing_cycles_to_ns_avg(cycles, count);
151#else
152 return arch_timing_cycles_to_ns_avg(cycles, count);
153#endif
154}
155
161static inline uint32_t timing_freq_get_mhz(void)
162{
163#if defined(CONFIG_BOARD_HAS_TIMING_FUNCTIONS)
165#elif defined(CONFIG_SOC_HAS_TIMING_FUNCTIONS)
167#else
169#endif
170}
171
172#endif /* CONFIG_TIMING_FUNCTIONS */
173
178#endif /* ZEPHYR_INCLUDE_TIMING_TIMING_H_ */
ZTEST_BMEM int count
Definition: main.c:33
uint64_t arch_timing_freq_get(void)
Get frequency of counter used (in Hz).
uint32_t arch_timing_freq_get_mhz(void)
Get frequency of counter used (in MHz).
uint64_t arch_timing_cycles_get(volatile timing_t *const start, volatile timing_t *const end)
Get number of cycles between start and end.
uint64_t arch_timing_cycles_to_ns(uint64_t cycles)
Convert number of cycles into nanoseconds.
uint64_t arch_timing_cycles_to_ns_avg(uint64_t cycles, uint32_t count)
Convert number of cycles into nanoseconds with averaging.
timing_t arch_timing_counter_get(void)
Return timing counter.
static uint64_t timing_cycles_to_ns(uint64_t cycles)
Convert number of cycles into nanoseconds.
Definition: timing.h:127
static uint64_t timing_cycles_to_ns_avg(uint64_t cycles, uint32_t count)
Convert number of cycles into nanoseconds with averaging.
Definition: timing.h:145
void timing_start(void)
Signal the start of the timing information gathering.
void timing_init(void)
Initialize the timing subsystem.
static uint32_t timing_freq_get_mhz(void)
Get frequency of counter used (in MHz).
Definition: timing.h:161
static uint64_t timing_cycles_get(volatile timing_t *const start, volatile timing_t *const end)
Get number of cycles between start and end.
Definition: timing.h:93
static timing_t timing_counter_get(void)
Return timing counter.
Definition: timing.h:72
static uint64_t timing_freq_get(void)
Get frequency of counter used (in Hz).
Definition: timing.h:110
void timing_stop(void)
Signal the end of the timing information gathering.
uint64_t timing_t
Definition: types.h:10
__UINT32_TYPE__ uint32_t
Definition: stdint.h:60
__UINT64_TYPE__ uint64_t
Definition: stdint.h:61
uint64_t board_timing_cycles_to_ns(uint64_t cycles)
uint64_t board_timing_cycles_get(volatile timing_t *const start, volatile timing_t *const end)
void soc_timing_stop(void)
void soc_timing_start(void)
void soc_timing_init(void)
uint64_t soc_timing_cycles_to_ns_avg(uint64_t cycles, uint32_t count)
timing_t soc_timing_counter_get(void)
void board_timing_stop(void)
uint64_t board_timing_cycles_to_ns_avg(uint64_t cycles, uint32_t count)
void board_timing_init(void)
uint32_t soc_timing_freq_get_mhz(void)
uint64_t board_timing_freq_get(void)
uint64_t soc_timing_cycles_get(volatile timing_t *const start, volatile timing_t *const end)
uint64_t soc_timing_cycles_to_ns(uint64_t cycles)
uint32_t board_timing_freq_get_mhz(void)
void board_timing_start(void)
uint64_t soc_timing_freq_get(void)
timing_t board_timing_counter_get(void)