|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
L3 Ethernet switch / frame-forwarding config demo (ra8_eth_mfwd + ra8_layer3_switch). More...
#include <stddef.h>#include <stdint.h>#include "ra8_board_ek_ra8d2.h"#include "ra8_boot_entry.h"#include "ra8_cgc.h"#include "ra8_err.h"#include "ra8_eth_mfwd.h"#include "ra8_isr.h"#include "ra8_layer3_switch.h"#include "ra8_mstp.h"#include "ra8_time.h"Go to the source code of this file.
Enumerations | |
| enum | l3_const_t : uint32_t { k_l3_baud = 115200U , k_l3_period_ms = 1000U , k_l3_route_ip = 0xC0A80100U , k_l3_route_mask = 0xFFFFFF00U } |
| Demo tunables (illustrative route). More... | |
| enum | l3_mtu_t : uint16_t { k_l3_mtu_bytes = 1500U } |
| L3-switch facade MTU. More... | |
| enum | l3_fmt_t : uint8_t { k_l3_radix = 10U , k_l3_dec_u32_max = 10U , k_l3_mask_entries = 3U , k_l3_fwd_mask_all = 0x7FU , k_l3_src_port = 0U , k_l3_rx_queue = 0U , k_l3_egress_port = 1U , k_l3_port_count = 2U , k_l3_promisc_off = 0U } |
| Formatting, indices, and small fields. More... | |
Functions | |
| static void | l3_panic_halt (void) |
| Park forever after a fatal init error. | |
| static void | l3_write (const uint8_t *data, uint32_t len) |
| Write a byte span to the SCI8 console, discarding the status. | |
| static uint32_t | l3_u32_to_dec (uint8_t *buf, uint32_t val) |
| Serialise an unsigned 32-bit value into decimal ASCII. | |
| static void | l3_write_u32 (uint32_t val) |
| Log one unsigned 32-bit value as decimal ASCII. | |
| static bool | l3_program_forwarding (void) |
| Program the real MFWD forwarding path and read its status. | |
| static bool | l3_run_facade (void) |
| Exercise the FSP-shaped L3-switch facade lifecycle. | |
| static bool | l3_run_cycle (void) |
| Run one cycle: MFWD forwarding config + L3-switch facade lifecycle. | |
| static void | l3_setup_or_halt (void) |
| Core bring-up: CGC -> MSTP -> TIME -> console + LED. | |
| static ra8_err_t | l3_arm (void) |
| Bring up the MFWD forwarding engine. | |
| void | main (void) |
| The application entry point Reset_Handler hands control to. | |
Variables | |
| static const uint8_t | k_l3_fwd_prefix [] = "l3sw: fwd_sts=0x" |
| static const uint8_t | k_l3_open_prefix [] = "l3sw: l3_open=" |
| static const uint8_t | k_l3_promisc_sep [] = " promisc=" |
| static const uint8_t | k_l3_route_prefix [] = "l3sw: route_add=" |
| static const uint8_t | k_l3_route_sfx [] = " (placeholder)\r\n" |
| static const uint8_t | k_l3_crlf [] = "\r\n" |
| static const uint8_t | k_l3_verdict_pass [] = "l3sw: forward PASS\r\n" |
| static const uint8_t | k_l3_verdict_fail [] = "l3sw: forward FAIL\r\n" |
L3 Ethernet switch / frame-forwarding config demo (ra8_eth_mfwd + ra8_layer3_switch).
Configures the RA8D2 Ethernet frame-forwarding path that no other example referenced (recon gap #135). Two drivers, honestly separated:
The fixed verdict "l3sw: forward PASS" prints only when every real operation (MFWD program + status, L3 open / status / close) returned k_ra8_ok. The route_add placeholder code is logged but never fails the verdict.
hw_pending: tools/ra8_emulator has no Ethernet / MFWD peripheral model, and the EK-RA8D2 Ethernet wire is marginal (#21), so this is compile-gated and bench-only – matching the driver-gap example wave (#182-188). Proving a frame is actually forwarded to the right egress port needs a multi-port topology (two links + a traffic source, bench wiring #89).
Definition in file main.c.
| enum l3_const_t : uint32_t |
| enum l3_fmt_t : uint8_t |
Formatting, indices, and small fields.
| enum l3_mtu_t : uint16_t |
|
staticnodiscard |
Bring up the MFWD forwarding engine.
ra8_eth_mfwd_init ungates the shared Ethernet switch MSTP gate and resets the MFWD registers so the per-port forwarding masks and queue routing can be programmed by the run cycle.
| k_ra8_ok | MFWD engine is up. |
| Other | Forwarded from ra8_eth_mfwd_init. |
Definition at line 347 of file main.c.
References ra8_eth_mfwd_init().
Referenced by main().
|
static |
Park forever after a fatal init error.
Definition at line 101 of file main.c.
Referenced by l3_setup_or_halt(), and main().
|
static |
Program the real MFWD forwarding path and read its status.
Sets the permissive per-port forwarding masks (0x7F -> all destinations on ports 0, 1 and the host/GWCA port), routes GMAC port-0 ingress into GWCA RX queue 0, and logs the MFWD status word.
Definition at line 191 of file main.c.
References k_l3_crlf, k_l3_fwd_mask_all, k_l3_fwd_prefix, k_l3_mask_entries, k_l3_rx_queue, k_l3_src_port, k_ra8_ok, l3_write(), l3_write_u32(), ra8_eth_mfwd_get_status(), ra8_eth_mfwd_route_queue(), and ra8_eth_mfwd_set_forwarding_masks().
Referenced by l3_run_cycle().
|
static |
Run one cycle: MFWD forwarding config + L3-switch facade lifecycle.
Definition at line 285 of file main.c.
References l3_program_forwarding(), and l3_run_facade().
Referenced by main().
|
static |
Exercise the FSP-shaped L3-switch facade lifecycle.
Opens the facade (2 ports, 1500-byte MTU, non-promiscuous), reads back the open / promiscuous flags, and closes it. Between open and close it calls ra8_layer3_switch_route_add once and logs the returned code: on this silicon the L3 route table is a documented placeholder that returns k_ra8_err_not_supported, so that code is logged (never failing the verdict) to make the placeholder explicit.
Definition at line 235 of file main.c.
References k_l3_crlf, k_l3_egress_port, k_l3_mtu_bytes, k_l3_open_prefix, k_l3_port_count, k_l3_promisc_off, k_l3_promisc_sep, k_l3_route_ip, k_l3_route_mask, k_l3_route_prefix, k_l3_route_sfx, k_ra8_ok, l3_write(), l3_write_u32(), ra8_layer3_switch_close(), ra8_layer3_switch_open(), ra8_layer3_switch_route_add(), and ra8_layer3_switch_status_get().
Referenced by l3_run_cycle().
|
static |
Core bring-up: CGC -> MSTP -> TIME -> console + LED.
Definition at line 306 of file main.c.
References k_l3_baud, k_ra8_board_led1, k_ra8_clock_id_cpuclk0, k_ra8_ok, l3_panic_halt(), ra8_board_led_init(), ra8_board_uart_console_init(), ra8_cgc_get_clock_hz(), ra8_cgc_init(), ra8_mstp_init(), and ra8_time_init().
Referenced by main().
|
static |
Serialise an unsigned 32-bit value into decimal ASCII.
| [out] | buf | Destination, at least k_l3_dec_u32_max bytes. |
| [in] | val | Value to serialise. |
Definition at line 138 of file main.c.
References k_l3_dec_u32_max, and k_l3_radix.
Referenced by l3_write_u32().
|
static |
Write a byte span to the SCI8 console, discarding the status.
| [in] | data | Non-NULL byte span to transmit. |
| [in] | len | Byte count (0 is a no-op). |
Definition at line 119 of file main.c.
References ra8_board_uart_console_write().
Referenced by l3_program_forwarding(), l3_run_facade(), l3_write_u32(), and main().
|
static |
Log one unsigned 32-bit value as decimal ASCII.
| [in] | val | Value to print. |
Definition at line 168 of file main.c.
References k_l3_dec_u32_max, l3_u32_to_dec(), and l3_write().
Referenced by l3_program_forwarding(), and l3_run_facade().
| void main | ( | void | ) |
The application entry point Reset_Handler hands control to.
Returns void, not int. This is a freestanding image: there is no hosted C environment, no process and nothing to report an exit status to. ISO C fixes main at int only for a hosted implementation; for a freestanding one (C23 5.1.2.1) the startup function's name and type are implementation-defined, and this is that definition. Reset_Handler discards no value because there is none to discard, and if main ever does return, startup halts the CPU rather than resuming anything.
The firmware lane is compiled -ffreestanding (see cmake/ra8_add_app.cmake) and the flag and this signature travel together: without it both GCC and clang reject a non-int main (-Wmain / -Wmain-return-type). Do not remove one without the other.
That coupling is why the declaration sits behind __STDC_HOSTED__ == 0, which -ffreestanding sets and a hosted build does not. The guard is not defensive dressing: this header is reachable from host builds (the unit tests compile ra8_core natively), and an unguarded void main(void); makes every hosted translation unit that includes it fail with conflicting types for 'main' against its own ISO int main. The declaration therefore exists exactly where its contract does.
Hosted first-party code – everything under tests/ and tools/ – uses the ISO int main(...) contract instead, because it genuinely does run under an OS that reads the exit status. scripts/checks/check_entry_points.py holds each domain to its own contract (#707).
Declared here, once, for the same reason SystemInit is: every vector_table.c used to restate it as a local extern int32_t main(void);, sixteen copies that no compiler ever compared against the definition – and roughly thirty of them had silently drifted out of agreement with the main they called.
The application entry point Reset_Handler hands control to.
Brings up CGC + BSP audio then plays blocks.
The application entry point Reset_Handler hands control to.
Brings up CGC + GPT triple, runs sweep.
The application entry point Reset_Handler hands control to.
Brings up clocks + UART + RMII pins, then ThreadX.
The application entry point Reset_Handler hands control to.
Brings up clocks + UART, then enters ThreadX.
The application entry point Reset_Handler hands control to.
Brings up LED, console, SDHI pins, then ThreadX.
The application entry point Reset_Handler hands control to.
Brings up CGC + USB-FS + UAC1, then enters the iso-IN feed loop forever.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
See file header.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
Profiles power modes once a second.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
Brings up the clocks, console, SPI, and SD card, then runs the shared ra8_io VFS round-trip over the SD-over-SPI block device. On success it prints the exact PASS banner the HIL runner and ra8_emulator smoke gate scrape for; on any failure it prints FAIL and parks the core.
The application entry point Reset_Handler hands control to.
Initialises logging and the console, brings up the OSPI NOR volume, runs the erase-before-write round-trip, and prints a single PASS/FAIL verdict line over SCI8 before parking in an infinite loop.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
Both USB controllers' clocks and pins come up before the kernel so the workers only deal with stack bring-up.
The application entry point Reset_Handler hands control to.
Brings up logging and the clock tree, releases the Cortex-M33 (which then blinks LED1 via ra8_pcntr_set_output()), and idles. See the file header.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
Brings up logging, the clock tree, and the VCOM console, runs the cacheable-SRAM round-trip with the D-cache that SystemInit() enabled through ra8_cache_dcache_enable(), emits the matching PASS / FAIL banner over the console and ra8_log, then parks in WFI. Every byte the self-test touches runs with the L1 caches + MPU enabled by the shared boot (RA8_BOOT_ENABLE_CACHE_MPU + RA8_BOOT_CACHE_VIA_HAL).
The application entry point Reset_Handler hands control to.
Publishes the mailbox, releases the Cortex-M33 into the emitter, yields until it signals done, validates the blob the M33 built, then logs the PASS/FAIL verdict and the chapter count read back from the blob. See the file header for the offload narrative.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
Publishes the mailbox, arms the IPC0 wake and configures the LPM block, releases the Cortex-M33 into the reader, waits for the first held page, logs the page-0 verdict, then runs the #150 mode-switch cycle – parking in low-power WFI and waking on the M33's page-turn pokes – before logging the handoff verdict and parking for good. See the file header for the narrative.
The application entry point Reset_Handler hands control to.
Definition at line 352 of file main.c.
References k_l3_period_ms, k_l3_verdict_fail, k_l3_verdict_pass, k_ra8_board_led1, k_ra8_ok, l3_arm(), l3_panic_halt(), l3_run_cycle(), l3_setup_or_halt(), l3_write(), ra8_board_led_toggle(), ra8_delay_ms(), and ra8_isr_globals_enable().
|
static |
Definition at line 90 of file main.c.
Referenced by l3_program_forwarding(), and l3_run_facade().
|
static |
Definition at line 85 of file main.c.
Referenced by l3_program_forwarding().
|
static |
Definition at line 86 of file main.c.
Referenced by l3_run_facade().
|
static |
Definition at line 87 of file main.c.
Referenced by l3_run_facade().
|
static |
Definition at line 88 of file main.c.
Referenced by l3_run_facade().
|
static |
Definition at line 89 of file main.c.
Referenced by l3_run_facade().
|
static |