LogSinkBuf.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019-2024, Texas Instruments Incorporated - https://www.ti.com
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 /*
34  * ======== LogSinkBuf.h ========
35  */
36 
37 #ifndef ti_loggers_utils_LogSinkBuf__include
38 #define ti_loggers_utils_LogSinkBuf__include
39 
40 #include <ti/log/Log.h>
41 #include <stdint.h>
42 
43 #if defined(__cplusplus)
44 extern "C" {
45 #endif
46 
47 #define Log_TI_LOG_SINK_BUF_VERSION 0.2.0
48 
49 #define LogSinkBuf_Type_LINEAR (1)
50 #define LogSinkBuf_Type_CIRCULAR (2)
51 #define LogSinkBuf_WORDS_PER_RECORD (5)
52 #define LogSinkBuf_BUF_HEADER_SIZE sizeof(LogSinkBuf_RecordType) + sizeof(uint32_t)
53 #define LogSinkBuf_SIZEOF_RECORD (sizeof(uint32_t) * LogSinkBuf_WORDS_PER_RECORD)
54 
55 typedef enum
56 {
62 
63 /*
64  * ======== LogSinkBuf_Rec ========
65  */
66 typedef struct LogSinkBuf_Rec
67 {
68  uint32_t serial;
69  uint32_t timestampHigh; /* Upper 32 bits of timestamp */
70  uint32_t timestampLow; /* Lower 32 bits of timestamp */
74 
75 /*
76  * ======== LogSinkBuf_Instance ========
77  */
78 typedef struct LogSinkBuf_Instance
79 {
80  uint8_t bufType;
81  int8_t advance;
82  uint16_t numEntries;
83  uint32_t serial;
85  LogSinkBuf_Rec *curEntry; /* next record to write */
88 
89 /*
90  * ======== LogSinkBuf_Handle ========
91  */
93 
125 extern void LogSinkBuf_printfSingleton(const Log_Module *handle,
126  uint32_t header,
127  uint32_t index,
128  uint32_t numArgs,
129  ...);
130 
131 extern void LogSinkBuf_printfSingleton0(const Log_Module *handle, uint32_t header, uint32_t index, ...);
132 
133 extern void LogSinkBuf_printfSingleton1(const Log_Module *handle, uint32_t header, uint32_t index, ...);
134 
135 extern void LogSinkBuf_printfSingleton2(const Log_Module *handle, uint32_t header, uint32_t index, ...);
136 
137 extern void LogSinkBuf_printfSingleton3(const Log_Module *handle, uint32_t header, uint32_t index, ...);
166 extern void LogSinkBuf_printfDepInjection(const Log_Module *handle,
167  uint32_t header,
168  uint32_t index,
169  uint32_t numArgs,
170  ...);
171 
172 extern void LogSinkBuf_printfDepInjection0(const Log_Module *handle, uint32_t header, uint32_t index, ...);
173 
174 extern void LogSinkBuf_printfDepInjection1(const Log_Module *handle, uint32_t header, uint32_t index, ...);
175 
176 extern void LogSinkBuf_printfDepInjection2(const Log_Module *handle, uint32_t header, uint32_t index, ...);
177 
178 extern void LogSinkBuf_printfDepInjection3(const Log_Module *handle, uint32_t header, uint32_t index, ...);
206 extern void LogSinkBuf_bufDepInjection(const Log_Module *handle,
207  uint32_t header,
208  uint32_t index,
209  uint8_t *data,
210  size_t size);
213 /*
214  * Helpers to define/use instance.
215  */
216 #define Log_SINK_BUF_DEFINE(name, type, num_entries) \
217  static LogSinkBuf_Rec logSinkBuf_##name##_buffer[num_entries]; \
218  LogSinkBuf_Instance LogSinkBuf_##name##_config = {.serial = 0, \
219  .bufType = type, \
220  .advance = type, \
221  .numEntries = num_entries, \
222  .buffer = logSinkBuf_##name##_buffer, \
223  .curEntry = logSinkBuf_##name##_buffer, \
224  .endEntry = logSinkBuf_##name##_buffer + (num_entries - 1)}
225 #define Log_SINK_BUF_USE(name) extern LogSinkBuf_Instance LogSinkBuf_##name##_config
226 #define Log_MODULE_INIT_SINK_BUF(name, _levels, printfDelegate, bufDelegate, _dynamicLevelsPtr) \
227  { \
228  .sinkConfig = &LogSinkBuf_##name##_config, .printf = printfDelegate, .printf0 = printfDelegate##0, \
229  .printf1 = printfDelegate##1, .printf2 = printfDelegate##2, .printf3 = printfDelegate##3, .buf = bufDelegate, \
230  .levels = _levels, .dynamicLevelsPtr = _dynamicLevelsPtr, \
231  }
232 
234 
235 #if defined(__cplusplus)
236 }
237 #endif
238 
239 #endif /* ti_loggers_utils_LogSinkBuf__include */
uint32_t timestampLow
Definition: LogSinkBuf.h:70
LogSinkBuf_Rec * buffer
Definition: LogSinkBuf.h:84
#define LogSinkBuf_WORDS_PER_RECORD
Definition: LogSinkBuf.h:51
Definition: LogSinkBuf.h:59
Definition: LogSinkBuf.h:58
uint32_t serial
Definition: LogSinkBuf.h:83
LogSinkBuf_Rec * curEntry
Definition: LogSinkBuf.h:85
LogSinkBuf_RecordType
Definition: LogSinkBuf.h:55
LogSinkBuf_Rec * endEntry
Definition: LogSinkBuf.h:86
struct LogSinkBuf_Instance LogSinkBuf_Instance
int8_t advance
Definition: LogSinkBuf.h:81
Definition: LogSinkBuf.h:66
_Log_DEFINE_LOG_VERSION(LogSinkBuf, 0.2.0)
LogSinkBuf_RecordType type
Definition: LogSinkBuf.h:71
uint32_t data[(5)]
Definition: LogSinkBuf.h:72
struct LogSinkBuf_Rec LogSinkBuf_Rec
Definition: LogSinkBuf.h:57
uint32_t serial
Definition: LogSinkBuf.h:68
Definition: LogSinkBuf.h:60
#define Log_TI_LOG_SINK_BUF_VERSION
Definition: LogSinkBuf.h:47
uint16_t numEntries
Definition: LogSinkBuf.h:82
LogSinkBuf_Instance * LogSinkBuf_Handle
Definition: LogSinkBuf.h:92
uint32_t timestampHigh
Definition: LogSinkBuf.h:69
Definition: LogSinkBuf.h:78
uint8_t bufType
Definition: LogSinkBuf.h:80
© Copyright 1995-2025, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale