Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:18

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /*
0004  *  Copyright (c) 2015 Chris Johns <chrisj@rtems.org>
0005  *
0006  * Redistribution and use in source and binary forms, with or without
0007  * modification, are permitted provided that the following conditions
0008  * are met:
0009  * 1. Redistributions of source code must retain the above copyright
0010  *    notice, this list of conditions and the following disclaimer.
0011  * 2. Redistributions in binary form must reproduce the above copyright
0012  *    notice, this list of conditions and the following disclaimer in the
0013  *    documentation and/or other materials provided with the distribution.
0014  *
0015  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0016  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0017  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0018  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0019  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0020  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0021  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0022  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0023  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0024  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0025  * POSSIBILITY OF SUCH DAMAGE.
0026  */
0027 
0028 #include <rtems/trace/rtems-trace-buffer-vars.h>
0029 
0030 #include <rtems.h>
0031 
0032 #if ISR_LOCK_NEEDS_OBJECT
0033 static ISR_lock_Control __rtld_tbg_lock = ISR_LOCK_INITIALIZER ("RTLD TBG");
0034 #endif
0035 
0036 uint32_t
0037 rtems_trace_names_size (void)
0038 {
0039   return __rtld_trace_names_size;
0040 }
0041 
0042 const char*
0043 rtems_trace_names (const uint32_t index)
0044 {
0045   return __rtld_trace_names[index];
0046 }
0047 
0048 uint32_t
0049 rtems_trace_enables_size (void)
0050 {
0051   return __rtld_trace_enables_size;
0052 }
0053 
0054 uint32_t
0055 rtems_trace_enables (const uint32_t index)
0056 {
0057   return __rtld_trace_enables[index];
0058 }
0059 
0060 uint32_t
0061 rtems_trace_triggers_size (void)
0062 {
0063   return __rtld_trace_triggers_size;
0064 }
0065 
0066 uint32_t
0067 rtems_trace_triggers (const uint32_t index)
0068 {
0069   return __rtld_trace_triggers[index];
0070 }
0071 
0072 const rtems_trace_sig*
0073 rtems_trace_signatures (const uint32_t index)
0074 {
0075   return &__rtld_trace_signatures[index];
0076 }
0077 
0078 bool
0079 rtems_trace_enable_set(const uint32_t index)
0080 {
0081   return (__rtld_trace_enables[index / 32] & (1 << (index & (32 - 1)))) != 0 ? true : false;
0082 }
0083 
0084 bool
0085 rtems_trace_trigger_set(const uint32_t index)
0086 {
0087   return (__rtld_trace_triggers[index / 32] & (1 << (index & (32 - 1)))) != 0 ? true : false;
0088 }
0089 
0090 bool
0091 rtems_trace_buffering_present (void)
0092 {
0093   return __rtld_tbg_present;
0094 }
0095 
0096 uint32_t
0097 rtems_trace_buffering_mode (void)
0098 {
0099   return __rtld_tbg_mode;
0100 }
0101 
0102 uint32_t
0103 rtems_trace_buffering_buffer_size (void)
0104 {
0105   return __rtld_tbg_buffer_size;
0106 }
0107 
0108 uint32_t*
0109 rtems_trace_buffering_buffer (void)
0110 {
0111   return &__rtld_tbg_buffer[0];
0112 }
0113 
0114 uint32_t
0115 rtems_trace_buffering_buffer_in (void)
0116 {
0117   rtems_interrupt_lock_context lcontext;
0118   uint32_t                     in;
0119   rtems_interrupt_lock_acquire(&__rtld_tbg_lock, &lcontext);
0120   in = __rtld_tbg_buffer_in;
0121   rtems_interrupt_lock_release(&__rtld_tbg_lock, &lcontext);
0122   return in;
0123 }
0124 
0125 bool
0126 rtems_trace_buffering_finished (void)
0127 {
0128   rtems_interrupt_lock_context lcontext;
0129   bool                         finished;
0130   rtems_interrupt_lock_acquire(&__rtld_tbg_lock, &lcontext);
0131   finished = __rtld_tbg_finished;
0132   rtems_interrupt_lock_release(&__rtld_tbg_lock, &lcontext);
0133   return finished;
0134 }
0135 
0136 bool
0137 rtems_trace_buffering_triggered (void)
0138 {
0139   rtems_interrupt_lock_context lcontext;
0140   bool                         triggered;
0141   rtems_interrupt_lock_acquire(&__rtld_tbg_lock, &lcontext);
0142   triggered = __rtld_tbg_triggered;
0143   rtems_interrupt_lock_release(&__rtld_tbg_lock, &lcontext);
0144   return triggered;
0145 }
0146 
0147 void
0148 rtems_trace_buffering_start (void)
0149 {
0150   rtems_interrupt_lock_context lcontext;
0151   rtems_interrupt_lock_acquire(&__rtld_tbg_lock, &lcontext);
0152   __rtld_tbg_triggered = false;
0153   __rtld_tbg_buffer_in = 0;
0154   __rtld_tbg_finished = false;
0155   rtems_interrupt_lock_release(&__rtld_tbg_lock, &lcontext);
0156 }
0157 
0158 void
0159 rtems_trace_buffering_stop (void)
0160 {
0161   rtems_interrupt_lock_context lcontext;
0162   rtems_interrupt_lock_acquire(&__rtld_tbg_lock, &lcontext);
0163   __rtld_tbg_finished = true;
0164   rtems_interrupt_lock_release(&__rtld_tbg_lock, &lcontext);
0165 }
0166 
0167 void
0168 rtems_trace_buffering_resume (void)
0169 {
0170   rtems_interrupt_lock_context lcontext;
0171   rtems_interrupt_lock_acquire(&__rtld_tbg_lock, &lcontext);
0172   __rtld_tbg_finished = false;
0173   rtems_interrupt_lock_release(&__rtld_tbg_lock, &lcontext);
0174 }