File tree Expand file tree Collapse file tree 3 files changed +63
-0
lines changed Expand file tree Collapse file tree 3 files changed +63
-0
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,7 @@ config X86
45
45
select CPU_HAS_MMU
46
46
select ARCH_MEM_DOMAIN_SYNCHRONOUS_API if USERSPACE
47
47
select ARCH_HAS_GDBSTUB if !X86_64
48
+ select ARCH_HAS_TIMING_FUNCTIONS
48
49
help
49
50
x86 architecture
50
51
@@ -385,6 +386,9 @@ endmenu
385
386
# Architecture Capabilities
386
387
#
387
388
389
+ config ARCH_HAS_TIMING_FUNCTIONS
390
+ bool
391
+
388
392
config ARCH_HAS_TRUSTED_EXECUTION
389
393
bool
390
394
Original file line number Diff line number Diff line change @@ -14,6 +14,12 @@ if(CONFIG_GEN_ISR_TABLES OR CONFIG_EXECUTION_BENCHMARKING)
14
14
)
15
15
endif ()
16
16
17
+ if (NOT CONFIG_ARCH_HAS_TIMING_FUNCTIONS AND
18
+ NOT CONFIG_SOC_HAS_TIMING_FUNCTIONS AND
19
+ NOT CONFIG_BOARD_HAS_TIMING_FUNCTIONS)
20
+ zephyr_library_sources_ifdef(CONFIG_TIMING_FUNCTIONS timing.c)
21
+ endif ()
22
+
17
23
# Put functions and data in their own binary sections so that ld can
18
24
# garbage collect them
19
25
zephyr_cc_option(-ffunction-sections -fdata-sections)
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright (c) 2020 Intel Corporation.
3
+ *
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ #include <kernel.h>
8
+ #include <sys_clock.h>
9
+ #include <timing/timing.h>
10
+
11
+ void timing_init (void )
12
+ {
13
+ }
14
+
15
+ void timing_start (void )
16
+ {
17
+ }
18
+
19
+ void timing_stop (void )
20
+ {
21
+ }
22
+
23
+ timing_t timing_counter_get (void )
24
+ {
25
+ return k_cycle_get_32 ();
26
+ }
27
+
28
+ uint64_t timing_cycles_get (volatile timing_t * const start ,
29
+ volatile timing_t * const end )
30
+ {
31
+ return (* end - * start );
32
+ }
33
+
34
+
35
+ uint64_t timing_freq_get (void )
36
+ {
37
+ return sys_clock_hw_cycles_per_sec ();
38
+ }
39
+
40
+ uint64_t timing_cycles_to_ns (uint64_t cycles )
41
+ {
42
+ return k_cyc_to_ns_floor64 (cycles );
43
+ }
44
+
45
+ uint64_t timing_cycles_to_ns_avg (uint64_t cycles , uint32_t count )
46
+ {
47
+ return timing_cycles_to_ns (cycles ) / count ;
48
+ }
49
+
50
+ uint32_t timing_freq_get_mhz (void )
51
+ {
52
+ return (uint32_t )(timing_freq_get () / 1000000 );
53
+ }
You can’t perform that action at this time.
0 commit comments