1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @ingroup ScoreProfiling |
---|
5 | * |
---|
6 | * @brief Profiling Support API |
---|
7 | */ |
---|
8 | |
---|
9 | /* |
---|
10 | * Copyright (c) 2014 embedded brains GmbH. All rights reserved. |
---|
11 | * |
---|
12 | * embedded brains GmbH |
---|
13 | * Dornierstr. 4 |
---|
14 | * 82178 Puchheim |
---|
15 | * Germany |
---|
16 | * <rtems@embedded-brains.de> |
---|
17 | * |
---|
18 | * The license and distribution terms for this file may be |
---|
19 | * found in the file LICENSE in this distribution or at |
---|
20 | * http://www.rtems.org/license/LICENSE. |
---|
21 | */ |
---|
22 | |
---|
23 | #ifndef _RTEMS_SCORE_PROFILING |
---|
24 | #define _RTEMS_SCORE_PROFILING |
---|
25 | |
---|
26 | #include <rtems/score/percpu.h> |
---|
27 | |
---|
28 | #ifdef __cplusplus |
---|
29 | extern "C" { |
---|
30 | #endif /* __cplusplus */ |
---|
31 | |
---|
32 | /** |
---|
33 | * @defgroup ScoreProfiling Profiling Support |
---|
34 | * |
---|
35 | * @brief Profiling support. |
---|
36 | * |
---|
37 | * @{ |
---|
38 | */ |
---|
39 | |
---|
40 | static inline void _Profiling_Thread_dispatch_disable( |
---|
41 | Per_CPU_Control *per_cpu, |
---|
42 | uint32_t previous_thread_dispatch_disable_level |
---|
43 | ) |
---|
44 | { |
---|
45 | #if defined( RTEMS_PROFILING ) |
---|
46 | if ( previous_thread_dispatch_disable_level == 0 ) { |
---|
47 | Per_CPU_Stats *stats = &per_cpu->Stats; |
---|
48 | |
---|
49 | stats->thread_dispatch_disabled_instant = _CPU_Counter_read(); |
---|
50 | ++stats->thread_dispatch_disabled_count; |
---|
51 | } |
---|
52 | #else |
---|
53 | (void) per_cpu; |
---|
54 | (void) previous_thread_dispatch_disable_level; |
---|
55 | #endif |
---|
56 | } |
---|
57 | |
---|
58 | static inline void _Profiling_Thread_dispatch_enable( |
---|
59 | Per_CPU_Control *per_cpu, |
---|
60 | uint32_t new_thread_dispatch_disable_level |
---|
61 | ) |
---|
62 | { |
---|
63 | #if defined( RTEMS_PROFILING ) |
---|
64 | if ( new_thread_dispatch_disable_level == 0 ) { |
---|
65 | Per_CPU_Stats *stats = &per_cpu->Stats; |
---|
66 | CPU_Counter_ticks now = _CPU_Counter_read(); |
---|
67 | CPU_Counter_ticks delta = _CPU_Counter_difference( |
---|
68 | now, |
---|
69 | stats->thread_dispatch_disabled_instant |
---|
70 | ); |
---|
71 | |
---|
72 | stats->total_thread_dispatch_disabled_time += delta; |
---|
73 | |
---|
74 | if ( stats->max_thread_dispatch_disabled_time < delta ) { |
---|
75 | stats->max_thread_dispatch_disabled_time = delta; |
---|
76 | } |
---|
77 | } |
---|
78 | #else |
---|
79 | (void) per_cpu; |
---|
80 | (void) new_thread_dispatch_disable_level; |
---|
81 | #endif |
---|
82 | } |
---|
83 | |
---|
84 | static inline void _Profiling_Update_max_interrupt_delay( |
---|
85 | Per_CPU_Control *per_cpu, |
---|
86 | CPU_Counter_ticks interrupt_delay |
---|
87 | ) |
---|
88 | { |
---|
89 | #if defined( RTEMS_PROFILING ) |
---|
90 | Per_CPU_Stats *stats = &per_cpu->Stats; |
---|
91 | |
---|
92 | if ( stats->max_interrupt_delay < interrupt_delay ) { |
---|
93 | stats->max_interrupt_delay = interrupt_delay; |
---|
94 | } |
---|
95 | #else |
---|
96 | (void) per_cpu; |
---|
97 | (void) interrupt_delay; |
---|
98 | #endif |
---|
99 | } |
---|
100 | |
---|
101 | void _Profiling_Outer_most_interrupt_entry_and_exit( |
---|
102 | Per_CPU_Control *per_cpu, |
---|
103 | CPU_Counter_ticks interrupt_entry_instant, |
---|
104 | CPU_Counter_ticks interrupt_exit_instant |
---|
105 | ); |
---|
106 | |
---|
107 | /** @} */ |
---|
108 | |
---|
109 | #ifdef __cplusplus |
---|
110 | } |
---|
111 | #endif /* __cplusplus */ |
---|
112 | |
---|
113 | #endif /* _RTEMS_SCORE_PROFILING */ |
---|