|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Bridge from the esp-hosted logging surface onto ra8_log. More...
#include <stdarg.h>#include <stddef.h>#include <stdint.h>#include "esp_log.h"#include "ra8_attributes.h"#include "ra8_esp_hosted_fmt_internal.h"#include "ra8_esp_hosted_log_internal.h"#include "ra8_esp_hosted_port.h"#include "ra8_esp_hosted_rtos_internal.h"#include "ra8_log.h"Go to the source code of this file.
Enumerations | |
| enum | ra8_esp_hosted_log_bound_t : uint16_t { k_ra8_esp_hosted_log_line_max = 160U , k_ra8_esp_hosted_log_dump_bytes = 32U , k_ra8_esp_hosted_log_dump_cost = 3U } |
| Fixed sizes the log bridge works within. More... | |
Functions | |
| static void | internal_emit (int level, const char *tag, const char *line) |
| Hand a finished line to the project logger at the mapped level. | |
| bool | priv_ra8_esp_hosted_log_accepts (int level) |
| Implementation of priv_ra8_esp_hosted_log_accepts() – the single runtime level decision, promoted so its two conditions are testable. | |
| void | priv_ra8_esp_hosted_log_vwrite (int level, const char *tag, const char *fmt, va_list ap) |
| Implementation of priv_ra8_esp_hosted_log_vwrite() – formats onto a bounded stack line, so it allocates nothing and is reentrant. | |
| void | ra8_esp_hosted_log_write (int level, const char *tag, const char *fmt,...) |
| Implementation of ra8_esp_hosted_log_write() – the varargs face of priv_ra8_esp_hosted_log_vwrite(). | |
| void | ra8_esp_hosted_log_hexdump (int level, const char *tag, const void *buf, uint32_t len) |
| Implementation of ra8_esp_hosted_log_hexdump() – renders at most k_ra8_esp_hosted_log_dump_bytes bytes onto one bounded line. | |
| void | ra8_esp_hosted_log_level_set (const char *tag, int level) |
| Implementation of ra8_esp_hosted_log_level_set() – one global threshold rather than the per-tag table ESP-IDF keeps; see the file header for why. | |
| int | priv_ra8_esp_hosted_log_level_get (void) |
| Implementation of priv_ra8_esp_hosted_log_level_get() – reads the threshold the setter last clamped. | |
| void | ra8_esp_hosted_log_fatal (const char *tag, const char *expr, int code) |
| Implementation of ra8_esp_hosted_log_fatal() – reports and parks; the caller's check already proved the state is unrecoverable. | |
| void | ra8_esp_hosted_mem_dump (const char *label) |
| Implementation of ra8_esp_hosted_mem_dump() – reads the live ThreadX byte-pool statistics, so the numbers are real. | |
| void | ra8_esp_hosted_alloc_failed (const char *func, size_t bytes) |
| Implementation of ra8_esp_hosted_alloc_failed() – names the requester and the size, which together size the pool without guesswork. | |
Variables | |
| static int | s_ra8_esp_hosted_log_level = (int)ESP_LOG_INFO |
| Runtime verbosity threshold for the esp-hosted bridge. | |
| static const char *const | s_ra8_esp_hosted_log_tag = "C6LINK" |
| Fallback tag used when a caller passes none. | |
Bridge from the esp-hosted logging surface onto ra8_log.
Implements the four entry points declared in port/esp-hosted/inc/idf_compat/esp_log.h plus the two allocator reporting hooks declared in ra8_esp_hosted_port.h.
The vendored core logs with printf-style calls; this project's logger takes a plain message and, optionally, one integer. The bridge closes that gap by formatting into a stack line through priv_ra8_esp_hosted_fmt_vformat – a bounded, allocation-free formatter – and handing the finished string to the matching ra8_log_* macro. Nothing here allocates, and the only module state is the runtime level threshold, which is read but never written on a logging path.
Definition in file ra8_esp_hosted_log.c.
| enum ra8_esp_hosted_log_bound_t : uint16_t |
Fixed sizes the log bridge works within.
One stack line and one hexdump line, both bounded so a format string or a co-processor-supplied buffer cannot decide how much stack the logger uses. The line budget is the dominant term in this module's stack frame, which the project's -Wstack-usage build measures.
Definition at line 71 of file ra8_esp_hosted_log.c.
|
static |
Hand a finished line to the project logger at the mapped level.
ESP-IDF has five levels and ra8_log has four, so verbose folds into debug. That is the only lossy step and it is stated here rather than spread across the call sites.
| [in] | level | ESP-IDF level of the line. |
| [in] | tag | Tag to attribute the line to. Must be non-null. |
| [in] | line | Formatted text. Must be non-null. |
Definition at line 128 of file ra8_esp_hosted_log.c.
References ESP_LOG_ERROR, ESP_LOG_INFO, ESP_LOG_WARN, ra8_log_debug, ra8_log_error, ra8_log_info, and ra8_log_warn.
Referenced by priv_ra8_esp_hosted_log_vwrite(), and ra8_esp_hosted_log_hexdump().
|
nodiscard |
Implementation of priv_ra8_esp_hosted_log_accepts() – the single runtime level decision, promoted so its two conditions are testable.
Decide whether a line at this level reaches the sink.
Definition at line 144 of file ra8_esp_hosted_log.c.
References ESP_LOG_NONE, and s_ra8_esp_hosted_log_level.
Referenced by priv_ra8_esp_hosted_log_vwrite(), and ra8_esp_hosted_log_hexdump().
|
nodiscard |
Implementation of priv_ra8_esp_hosted_log_level_get() – reads the threshold the setter last clamped.
Report the current runtime verbosity threshold.
Definition at line 233 of file ra8_esp_hosted_log.c.
References s_ra8_esp_hosted_log_level.
| void priv_ra8_esp_hosted_log_vwrite | ( | int | level, |
| const char * | tag, | ||
| const char * | fmt, | ||
| va_list | ap ) |
Implementation of priv_ra8_esp_hosted_log_vwrite() – formats onto a bounded stack line, so it allocates nothing and is reentrant.
Emit one formatted line from an already-started argument list.
Definition at line 152 of file ra8_esp_hosted_log.c.
References internal_emit(), k_ra8_esp_hosted_log_line_max, priv_ra8_esp_hosted_fmt_vformat(), priv_ra8_esp_hosted_log_accepts(), and s_ra8_esp_hosted_log_tag.
Referenced by internal_printf(), and ra8_esp_hosted_log_write().
| void ra8_esp_hosted_alloc_failed | ( | const char * | func, |
| size_t | bytes ) |
Implementation of ra8_esp_hosted_alloc_failed() – names the requester and the size, which together size the pool without guesswork.
Record that an allocation through the vtable could not be served.
Definition at line 275 of file ra8_esp_hosted_log.c.
References ESP_LOG_ERROR, ra8_esp_hosted_log_write(), and s_ra8_esp_hosted_log_tag.
| void ra8_esp_hosted_log_fatal | ( | const char * | tag, |
| const char * | expr, | ||
| int | code ) |
Implementation of ra8_esp_hosted_log_fatal() – reports and parks; the caller's check already proved the state is unrecoverable.
Report a failed ESP_ERROR_CHECK and stop.
Definition at line 240 of file ra8_esp_hosted_log.c.
References ESP_LOG_ERROR, ra8_esp_hosted_log_write(), and s_ra8_esp_hosted_log_tag.
| void ra8_esp_hosted_log_hexdump | ( | int | level, |
| const char * | tag, | ||
| const void * | buf, | ||
| uint32_t | len ) |
Implementation of ra8_esp_hosted_log_hexdump() – renders at most k_ra8_esp_hosted_log_dump_bytes bytes onto one bounded line.
Emit a hex dump of a buffer at a given severity.
Definition at line 175 of file ra8_esp_hosted_log.c.
References internal_emit(), k_ra8_esp_hosted_fmt_digits_max, k_ra8_esp_hosted_log_dump_bytes, k_ra8_esp_hosted_log_dump_cost, k_ra8_esp_hosted_log_dump_nibbles, k_ra8_esp_hosted_log_dump_radix, k_ra8_esp_hosted_log_line_max, priv_ra8_esp_hosted_fmt_utoa(), priv_ra8_esp_hosted_log_accepts(), and s_ra8_esp_hosted_log_tag.
| void ra8_esp_hosted_log_level_set | ( | const char * | tag, |
| int | level ) |
Implementation of ra8_esp_hosted_log_level_set() – one global threshold rather than the per-tag table ESP-IDF keeps; see the file header for why.
Raise the console threshold for one module at run time.
Definition at line 217 of file ra8_esp_hosted_log.c.
References ESP_LOG_NONE, ESP_LOG_VERBOSE, and s_ra8_esp_hosted_log_level.
| void ra8_esp_hosted_log_write | ( | int | level, |
| const char * | tag, | ||
| const char * | fmt, | ||
| ... ) |
Implementation of ra8_esp_hosted_log_write() – the varargs face of priv_ra8_esp_hosted_log_vwrite().
Emit one formatted esp-hosted log line.
Definition at line 165 of file ra8_esp_hosted_log.c.
References priv_ra8_esp_hosted_log_vwrite().
Referenced by ra8_esp_hosted_alloc_failed(), ra8_esp_hosted_log_fatal(), and ra8_esp_hosted_mem_dump().
| void ra8_esp_hosted_mem_dump | ( | const char * | label | ) |
Implementation of ra8_esp_hosted_mem_dump() – reads the live ThreadX byte-pool statistics, so the numbers are real.
Report transport pool occupancy at a named point.
Definition at line 260 of file ra8_esp_hosted_log.c.
References ESP_LOG_INFO, priv_ra8_esp_hosted_rtos_pool_stats(), ra8_esp_hosted_log_write(), and s_ra8_esp_hosted_log_tag.
Referenced by c6_fwver_worker_entry(), c6_hosted_worker_entry(), c6_wifi_worker_entry(), and internal_init_hook().
|
static |
Runtime verbosity threshold for the esp-hosted bridge.
Lines at a level numerically greater than this are dropped. Starts at the informational level so a default build reports link life-cycle events without per-frame noise.
Definition at line 91 of file ra8_esp_hosted_log.c.
Referenced by priv_ra8_esp_hosted_log_accepts(), priv_ra8_esp_hosted_log_level_get(), and ra8_esp_hosted_log_level_set().
|
static |
Fallback tag used when a caller passes none.
Keeps a null tag from reaching ra8_log_*, which would dereference it.
Definition at line 102 of file ra8_esp_hosted_log.c.
Referenced by priv_ra8_esp_hosted_log_vwrite(), ra8_esp_hosted_alloc_failed(), ra8_esp_hosted_log_fatal(), ra8_esp_hosted_log_hexdump(), and ra8_esp_hosted_mem_dump().