source: rtems/cpukit/libmisc/capture/rtems-trace-buffer-vars.c @ 9761b98d

Last change on this file since 9761b98d was 9761b98d, checked in by Joel Sherrill <joel@…>, on Jun 12, 2017 at 4:49:10 PM

capture/rtems-trace-buffer-vars.c: Fix duplicate const warning

  • Property mode set to 100644
File size: 4.3 KB
Line 
1/*
2 *  Copyright (c) 2015 Chris Johns <chrisj@rtems.org>
3 *
4 *  The license and distribution terms for this file may be
5 *  found in the file LICENSE in this distribution or at
6 *  http://www.rtems.org/license/LICENSE.
7 */
8
9#include <rtems.h>
10
11#include <rtems/trace/rtems-trace-buffer-vars.h>
12
13/**
14 * External Trace Linker and TBG data. We provide weak versions to allow us to
15 * link and be present in an application that has not been trace linked.
16 */
17
18/*
19 * Trace linker data.
20 */
21uint32_t __rtld_trace_names_size __attribute__ ((weak));
22const char *const __rtld_trace_names[1] __attribute__ ((weak));
23uint32_t __rtld_trace_enables_size __attribute__ ((weak));
24const uint32_t __rtld_trace_enables[1] __attribute__ ((weak));
25uint32_t __rtld_trace_triggers_size __attribute__ ((weak));
26const uint32_t __rtld_trace_triggers[1] __attribute__ ((weak));
27const __rtld_trace_sig __rtld_trace_signatures[1] __attribute__ ((weak));
28
29/*
30 * Trace buffer generator data.
31 */
32const bool __rtld_tbg_present __attribute__ ((weak));
33const uint32_t __rtld_tbg_mode __attribute__ ((weak));
34const uint32_t __rtld_tbg_buffer_size __attribute__ ((weak));
35uint32_t __rtld_tbg_buffer[1] __attribute__ ((weak));
36volatile uint32_t __rtld_tbg_buffer_in __attribute__ ((weak));
37volatile bool __rtld_tbg_finished __attribute__ ((weak));
38volatile bool __rtld_tbg_triggered __attribute__ ((weak));
39
40ISR_LOCK_DEFINE (static, __rtld_tbg_lock, "RTLD TBG")
41
42uint32_t
43rtems_trace_names_size (void)
44{
45  return __rtld_trace_names_size;
46}
47
48const char*
49rtems_trace_names (const uint32_t index)
50{
51  return __rtld_trace_names[index];
52}
53
54uint32_t
55rtems_trace_enables_size (void)
56{
57  return __rtld_trace_enables_size;
58}
59
60uint32_t
61rtems_trace_enables (const uint32_t index)
62{
63  return __rtld_trace_enables[index];
64}
65
66uint32_t
67rtems_trace_triggers_size (void)
68{
69  return __rtld_trace_triggers_size;
70}
71
72uint32_t
73rtems_trace_triggers (const uint32_t index)
74{
75  return __rtld_trace_triggers[index];
76}
77
78const rtems_trace_sig*
79rtems_trace_signatures (const uint32_t index)
80{
81  return &__rtld_trace_signatures[index];
82}
83
84bool
85rtems_trace_enable_set(const uint32_t index)
86{
87  return (__rtld_trace_enables[index / 32] & (1 << (index & (32 - 1)))) != 0 ? true : false;
88}
89
90bool
91rtems_trace_trigger_set(const uint32_t index)
92{
93  return (__rtld_trace_triggers[index / 32] & (1 << (index & (32 - 1)))) != 0 ? true : false;
94}
95
96bool
97rtems_trace_buffering_present (void)
98{
99  return __rtld_tbg_present;
100}
101
102uint32_t
103rtems_trace_buffering_mode (void)
104{
105  return __rtld_tbg_mode;
106}
107
108uint32_t
109rtems_trace_buffering_buffer_size (void)
110{
111  return __rtld_tbg_buffer_size;
112}
113
114uint32_t*
115rtems_trace_buffering_buffer (void)
116{
117  return &__rtld_tbg_buffer[0];
118}
119
120uint32_t
121rtems_trace_buffering_buffer_in (void)
122{
123  rtems_interrupt_lock_context lcontext;
124  uint32_t                     in;
125  rtems_interrupt_lock_acquire(&__rtld_tbg_lock, &lcontext);
126  in = __rtld_tbg_buffer_in;
127  rtems_interrupt_lock_release(&__rtld_tbg_lock, &lcontext);
128  return in;
129}
130
131bool
132rtems_trace_buffering_finished (void)
133{
134  rtems_interrupt_lock_context lcontext;
135  bool                         finished;
136  rtems_interrupt_lock_acquire(&__rtld_tbg_lock, &lcontext);
137  finished = __rtld_tbg_finished;
138  rtems_interrupt_lock_release(&__rtld_tbg_lock, &lcontext);
139  return finished;
140}
141
142bool
143rtems_trace_buffering_triggered (void)
144{
145  rtems_interrupt_lock_context lcontext;
146  bool                         triggered;
147  rtems_interrupt_lock_acquire(&__rtld_tbg_lock, &lcontext);
148  triggered = __rtld_tbg_triggered;
149  rtems_interrupt_lock_release(&__rtld_tbg_lock, &lcontext);
150  return triggered;
151}
152
153void
154rtems_trace_buffering_start (void)
155{
156  rtems_interrupt_lock_context lcontext;
157  rtems_interrupt_lock_acquire(&__rtld_tbg_lock, &lcontext);
158  __rtld_tbg_triggered = false;
159  __rtld_tbg_buffer_in = 0;
160  __rtld_tbg_finished = false;
161  rtems_interrupt_lock_release(&__rtld_tbg_lock, &lcontext);
162}
163
164void
165rtems_trace_buffering_stop (void)
166{
167  rtems_interrupt_lock_context lcontext;
168  rtems_interrupt_lock_acquire(&__rtld_tbg_lock, &lcontext);
169  __rtld_tbg_finished = true;
170  rtems_interrupt_lock_release(&__rtld_tbg_lock, &lcontext);
171}
172
173void
174rtems_trace_buffering_resume (void)
175{
176  rtems_interrupt_lock_context lcontext;
177  rtems_interrupt_lock_acquire(&__rtld_tbg_lock, &lcontext);
178  __rtld_tbg_finished = false;
179  rtems_interrupt_lock_release(&__rtld_tbg_lock, &lcontext);
180}
Note: See TracBrowser for help on using the repository browser.