Skip to content

Commit 5205c3a

Browse files
jackson-cooperdstgloorious
authored andcommitted
LIB: Move tfm_vprintf definition to private header
This function should not be accessed outside of the tfm_log and tfm_log_unpriv libraries and therefore does not need to be exposed in the public header. Add a new private header which is then included by the logging source files. Change-Id: Ic6ca5d4ad753b6e6abaedaf27d0b17b9ebe6f1b3 Signed-off-by: Jackson Cooper-Driver <jackson.cooper-driver@arm.com> (cherry picked from commit ccf42f2) Signed-off-by: Stefan Gloor <stefan.gloor@siemens.com>
1 parent 8070ad9 commit 5205c3a

File tree

5 files changed

+47
-6
lines changed

5 files changed

+47
-6
lines changed

lib/tfm_log/src/tfm_log.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <stdint.h>
1010
#include <stddef.h>
1111

12+
#include "tfm_vprintf_priv.h"
1213
#include "tfm_log.h"
1314
#include "uart_stdout.h"
1415

lib/tfm_log_unpriv/src/tfm_log_unpriv.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <stddef.h>
1111
#include <string.h>
1212

13+
#include "tfm_vprintf_priv.h"
1314
#include "tfm_log_unpriv.h"
1415
#include "tfm_hal_sp_logdev.h"
1516

lib/tfm_vprintf/inc/tfm_vprintf.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,4 @@
4444
#define LOG_MARKER_VERBOSE "\x32" /* 50 */
4545
#define LOG_MARKER_RAW "\x3c" /* 60 */
4646

47-
/* Function called to output a string to the terminal */
48-
typedef void (*tfm_log_output_str)(void *priv, const char *str, uint32_t len);
49-
50-
/* Function to generate formatted string and pass to output_func */
51-
void tfm_vprintf(tfm_log_output_str output_func, void *priv, const char *fmt, va_list args);
52-
5347
#endif /* __TF_M_VPRINTF_H__ */
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* SPDX-FileCopyrightText: Copyright The TrustedFirmware-M Contributors
3+
*
4+
* SPDX-License-Identifier: BSD-3-Clause
5+
*
6+
*/
7+
8+
#ifndef __TF_M_VPRINTF_PRIV_H__
9+
#define __TF_M_VPRINTF_PRIV_H__
10+
11+
#include <stdint.h>
12+
#include <stdarg.h>
13+
14+
/**
15+
* \typedef tfm_log_output_str
16+
* \brief Function pointer type for a custom log output handler.
17+
*
18+
* This type defines a callback function used by the logging subsystem
19+
* to send output strings to a user-defined destination, such as UART
20+
* or a memory buffer.
21+
*
22+
* \param[in] priv Pointer to user-defined context or state.
23+
* \param[in] str Pointer to the character buffer containing the string to output.
24+
* \param[in] len Length of the string (in bytes) to output.
25+
*/
26+
typedef void (*tfm_log_output_str)(void *priv, const char *str, uint32_t len);
27+
28+
/**
29+
* \brief Format a string and send it to a user-defined output handler.
30+
*
31+
* This function is similar to vprintf(), but instead of writing to a
32+
* standard output stream, it sends the formatted output to a callback
33+
* function provided by the user.
34+
*
35+
*
36+
* \param[in] output_func Pointer to the output function that handles the formatted string.
37+
* \param[in] priv Pointer to user-defined context, passed to the output function.
38+
* \param[in] fmt Format string specifying how to format the output. This is expected
39+
* to begin with a MARKER character.
40+
* \param[in] args Variable argument list to match the format string.
41+
*/
42+
void tfm_vprintf(tfm_log_output_str output_func, void *priv, const char *fmt, va_list args);
43+
44+
#endif /* __TF_M_VPRINTF_PRIV_H__ */

lib/tfm_vprintf/src/tfm_vprintf.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <stddef.h>
1515

1616
#include "tfm_vprintf.h"
17+
#include "tfm_vprintf_priv.h"
1718

1819
#define LOG_RAW_VALUE UINT8_C(60)
1920

0 commit comments

Comments
 (0)