|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Bounded console formatters for the esp-hosted RPC round-trip app. More...
#include <stddef.h>#include <stdint.h>#include "c6_fwver.h"#include "esp_hosted_transport.h"#include "port_esp_hosted_host_os.h"#include "ra8_board_ek_ra8d2.h"Go to the source code of this file.
Enumerations | |
| enum | c6_fwver_ascii_t : uint8_t { k_c6_fwver_ascii_low = 0x20U , k_c6_fwver_ascii_high = 0x7EU , k_c6_fwver_ascii_sub = '.' } |
| Printable-ASCII window used to sanitise co-processor text. More... | |
Functions | |
| void | c6_fwver_puts (const char *text) |
| Write a NUL-terminated string to the board console. | |
| void | c6_fwver_put_u32 (uint32_t value) |
| Implementation of c6_fwver_put_u32() – reversed division loop. | |
| void | c6_fwver_put_i32 (int32_t value) |
| Implementation of c6_fwver_put_i32() – two's-complement magnitude. | |
| void | c6_fwver_put_hex (uint32_t value, uint8_t digits) |
| Emit a value as a fixed-width lower-case hexadecimal field. | |
| void | c6_fwver_put_text (const uint8_t *text, size_t len) |
| Implementation of c6_fwver_put_text() – truncate, then sanitise. | |
| void | c6_fwver_print_banner (uint32_t cpuclk_hz, uint32_t pclka_hz) |
| Print the banner: identity, clocks and SPI parameters. | |
| void | c6_fwver_print_pump (const char *label, const c6_fwver_pump_stats_t *stats) |
| Print what one pump did, as one console line. | |
Bounded console formatters for the esp-hosted RPC round-trip app.
Five tiny serialisers – string, unsigned decimal, signed decimal, hexadecimal and untrusted text – plus the banner and the pump-statistics line. They exist so the application can narrate itself without dragging newlib's printf (and its heap and reentrancy machinery) into a bare-metal image that has no heap at all.
Every loop here is bounded by a constant from c6_fwver.h, which is what satisfies NASA Power of 10 Rule 2. c6_fwver_put_text is the one that matters for more than that: the bytes it prints come off the wire from the co-processor, so it sanitises rather than trusts.
Definition in file c6_fwver_console.c.
| enum c6_fwver_ascii_t : uint8_t |
Printable-ASCII window used to sanitise co-processor text.
A protocol field is evidence; evidence that can reprogram a terminal is not evidence. Anything outside this window is replaced.
| Enumerator | |
|---|---|
| k_c6_fwver_ascii_low | Space: lowest printable code point. |
| k_c6_fwver_ascii_high | Tilde: highest printable code point. |
| k_c6_fwver_ascii_sub | Substitute for anything else. |
Definition at line 47 of file c6_fwver_console.c.
| void c6_fwver_print_banner | ( | uint32_t | cpuclk_hz, |
| uint32_t | pclka_hz ) |
Print the banner: identity, clocks and SPI parameters.
| [in] | cpuclk_hz | Live CPUCLK0 rate in hertz. |
| [in] | pclka_hz | Live PCLKA rate in hertz, the SCI baud-clock source. |
Definition at line 128 of file c6_fwver_console.c.
References c6_fwver_put_u32(), c6_fwver_puts(), k_c6_fwver_frame_bytes, k_c6_fwver_sck_hz, k_ra8_board_pmod1_sci_channel, and MAX_PAYLOAD_SIZE.
Referenced by main().
| void c6_fwver_print_pump | ( | const char * | label, |
| const c6_fwver_pump_stats_t * | stats ) |
Print what one pump did, as one console line.
| [in] | label | Field name printed before the counters; null prints nothing at all rather than being dereferenced. |
| [in] | stats | Counters filled in by c6_fwver_link_pump; null prints nothing. |
stats came from a completed pump. Definition at line 147 of file c6_fwver_console.c.
References c6_fwver_pump_stats::bad_checksum, c6_fwver_pump_stats::bus_error, c6_fwver_put_u32(), c6_fwver_puts(), c6_fwver_pump_stats::frames, c6_fwver_pump_stats::hs_timeouts, c6_fwver_pump_stats::idle, c6_fwver_pump_stats::ifnum_defect, c6_fwver_pump_stats::malformed, c6_fwver_pump_stats::sink_stopped, and c6_fwver_pump_stats::transfers.
Referenced by c6_fwver_phase_caps(), and c6_fwver_phase_request().
| void c6_fwver_put_hex | ( | uint32_t | value, |
| uint8_t | digits ) |
Emit a value as a fixed-width lower-case hexadecimal field.
| [in] | value | Value to print. |
| [in] | digits | Field width, 1..k_c6_fwver_hex_digits; an out-of-range width prints nothing rather than overrunning the output array. |
digits is within 1..k_c6_fwver_hex_digits. digits characters were emitted, or none on a bad width. digits (NASA Rule 2). Definition at line 95 of file c6_fwver_console.c.
References k_c6_fwver_hex_alpha, k_c6_fwver_hex_bits, k_c6_fwver_hex_digits, k_c6_fwver_hex_mask, and ra8_board_uart_console_write().
Referenced by c6_fwver_print_reject(), c6_fwver_priv_consume(), c6_fwver_priv_tlv(), c6_fwver_rpc_print_expectation(), and c6_fwver_rpc_print_response().
| void c6_fwver_put_i32 | ( | int32_t | value | ) |
Implementation of c6_fwver_put_i32() – two's-complement magnitude.
Emit a signed 32-bit value in decimal.
Definition at line 85 of file c6_fwver_console.c.
References c6_fwver_put_u32(), and c6_fwver_puts().
Referenced by c6_fwver_rpc_print_response().
| void c6_fwver_put_text | ( | const uint8_t * | text, |
| size_t | len ) |
Implementation of c6_fwver_put_text() – truncate, then sanitise.
Emit a length-counted byte range as printable text.
Definition at line 112 of file c6_fwver_console.c.
References k_c6_fwver_ascii_high, k_c6_fwver_ascii_low, k_c6_fwver_ascii_sub, k_c6_fwver_text_max, and ra8_board_uart_console_write().
Referenced by c6_fwver_rpc_print_response().
| void c6_fwver_put_u32 | ( | uint32_t | value | ) |
Implementation of c6_fwver_put_u32() – reversed division loop.
Emit an unsigned 32-bit value in decimal.
Definition at line 66 of file c6_fwver_console.c.
References k_c6_fwver_dec_digits, k_c6_fwver_dec_radix, and ra8_board_uart_console_write().
Referenced by c6_fwver_dispatch(), c6_fwver_heartbeat(), c6_fwver_phase_caps(), c6_fwver_phase_request(), c6_fwver_print_banner(), c6_fwver_print_pump(), c6_fwver_print_reject(), c6_fwver_priv_consume(), c6_fwver_priv_tlv(), c6_fwver_put_i32(), c6_fwver_rpc_consume(), c6_fwver_rpc_print_crosscheck(), c6_fwver_rpc_print_expectation(), c6_fwver_rpc_print_response(), and c6_fwver_rpc_report().
| void c6_fwver_puts | ( | const char * | text | ) |
Write a NUL-terminated string to the board console.
| [in] | text | String to emit; null is ignored rather than dereferenced and the length is capped at k_c6_fwver_str_max. |
text is NUL-terminated within k_c6_fwver_str_max bytes. Definition at line 53 of file c6_fwver_console.c.
References k_c6_fwver_str_max, and ra8_board_uart_console_write().
Referenced by c6_fwver_dispatch(), c6_fwver_heartbeat(), c6_fwver_phase_caps(), c6_fwver_phase_request(), c6_fwver_print_banner(), c6_fwver_print_pump(), c6_fwver_print_reject(), c6_fwver_priv_consume(), c6_fwver_priv_tlv(), c6_fwver_put_i32(), c6_fwver_rpc_consume(), c6_fwver_rpc_print_crosscheck(), c6_fwver_rpc_print_expectation(), c6_fwver_rpc_print_response(), c6_fwver_rpc_report(), c6_fwver_rx_dispatch(), c6_fwver_worker_entry(), main(), and tx_application_define().