ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
c6_hosted_report.c File Reference

Banner, resolved pin map and side-band reporting for the bring-up. More...

#include <stddef.h>
#include <stdint.h>
#include "c6_hosted.h"
#include "esp_hosted_os_abstraction.h"
#include "port_esp_hosted_host_config.h"
#include "ra8_board_ek_ra8d2.h"
#include "ra8_esp_hosted_pins.h"
#include "ra8_spi.h"
Include dependency graph for c6_hosted_report.c:

Go to the source code of this file.

Functions

static void c6_hosted_print_route (const char *label, ra8_esp_hosted_pin_t pin)
 Print the interrupt path the port takes for one side-band pin.
static void c6_hosted_read_sideband (const char *label, void *gpio_port, int32_t gpio_pin, int32_t active)
 Sample one side-band input through the OS-abstraction vtable.
void c6_hosted_print_banner (uint32_t cpuclk_hz, uint32_t pclka_hz)
 Print the port identity, the clocks and the SPI parameters.
void c6_hosted_print_pin_map (void)
 Print the resolved pin map, bus pins and side-band alike.
void c6_hosted_report_sideband (void)
 Sample both side-band lines through the vtable and report them.
void c6_hosted_on_event (void *ctx, const char *base, int32_t event_id, const void *data, size_t data_len)
 Report an event the port delivered from the vendored core.
uint32_t c6_hosted_event_count (void)
 Report how many events c6_hosted_on_event has seen.

Variables

static volatile uint32_t s_c6_hosted_events
 Number of events c6_hosted_on_event has been handed.

Detailed Description

Banner, resolved pin map and side-band reporting for the bring-up.

Tag
[Ring 6 / APP] {World: S}

Everything the application states about the link before it clocks a single bit: the port identity and SPI parameters, the pin map the port resolved, the interrupt path each side-band net actually gets, and the live level of both side-band lines read through the OS-abstraction vtable. The event handler lives here too, since what it does is report.

Where the facts come from
Nothing here is asserted from memory. The bus pins come from ra8_esp_hosted_pin_t; the side-band pair and the reset pin are printed in the exact H_GPIO_*_Port / H_GPIO_*_Pin encoding the vendored driver consumes; the interrupt routing comes from ra8_esp_hosted_pin_irq_num, a pure table lookup, so a pin with no ICU channel is reported as taking the port's software edge detector rather than being assumed to raise an edge.
Reading through the vtable
c6_hosted_report_sideband deliberately calls _h_read_gpio rather than the GPIO HAL: that is the seam the vendored SPI driver uses, so a level printed here is the level the driver would act on.
Since
0.1.0

Definition in file c6_hosted_report.c.

Function Documentation

◆ c6_hosted_event_count()

uint32_t c6_hosted_event_count ( void )

Report how many events c6_hosted_on_event has seen.

Returns
The running count, which starts at zero and never resets.
Return values
0The co-processor has never announced anything.
Precondition
None; safe to call before any event has arrived.
The caller tolerates a value a concurrent post may stale.
Postcondition
No application state is modified.
The returned value reflects the counter at the moment of the read.
Note
Diagnostic only; a single aligned load, not an atomic read.
See also
c6_hosted_on_event
Since
0.1.0

Definition at line 182 of file c6_hosted_report.c.

References s_c6_hosted_events.

Referenced by c6_hosted_heartbeat().

◆ c6_hosted_on_event()

void c6_hosted_on_event ( void * ctx,
const char * base,
int32_t event_id,
const void * data,
size_t data_len )

Report an event the port delivered from the vendored core.

Parameters
[in]ctxRegistered context; unused, the counter is file-scope.
[in]baseEvent namespace; never null per the port contract.
[in]event_idIdentifier within that namespace.
[in]dataPayload, or null; not decoded here.
[in]data_lenPayload length in bytes.
Returns
Nothing.
Precondition
The console is up.
The port has been told about this handler.
Postcondition
The event counter was incremented.
One line naming the base and the identifier was emitted.
Note
Runs on the posting thread, so it only formats: it never blocks and never calls back into the transport.
See also
c6_hosted_event_count
Since
0.1.0

Definition at line 164 of file c6_hosted_report.c.

References c6_hosted_put_i32(), c6_hosted_put_u32(), c6_hosted_puts(), and s_c6_hosted_events.

Referenced by tx_application_define().

◆ c6_hosted_print_banner()

void c6_hosted_print_banner ( uint32_t cpuclk_hz,
uint32_t pclka_hz )

Print the port identity, the clocks and the SPI parameters.

Parameters
[in]cpuclk_hzLive CPUCLK0 rate in hertz.
[in]pclka_hzLive PCLKA rate in hertz, the SCI baud-clock source.
Returns
Nothing.
Precondition
The console is up.
Both rates were read from the CGC rather than assumed.
Postcondition
Three banner lines were emitted.
No application state is modified.
Note
The SPI mode printed is the co-processor's: the C6 image in coprocessor/esp32c6/ is built with CONFIG_ESP_SPI_MODE=3 and the port opens the bus to match.
See also
c6_hosted_print_pin_map
Since
0.1.0

Definition at line 118 of file c6_hosted_report.c.

References c6_hosted_put_u32(), c6_hosted_puts(), k_c6_hosted_sck_hz, k_ra8_board_pmod1_sci_channel, and k_ra8_spi_mode_3.

Referenced by main().

◆ c6_hosted_print_pin_map()

void c6_hosted_print_pin_map ( void )

Print the resolved pin map, bus pins and side-band alike.

Returns
Nothing.
Precondition
The console is up.
ra8_esp_hosted_pins.h describes the harness currently fitted.
Postcondition
Four lines were emitted: bus pins, the driver's view of the side-band pair and the reset pin, then one route line per side-band signal.
No application state is modified.
Note
Every value is decoded from the port's own headers at run time, so a harness change shows up here with no edit to this application.
See also
c6_hosted_print_banner
Since
0.1.0

Definition at line 136 of file c6_hosted_report.c.

References c6_hosted_print_gpio(), c6_hosted_print_pin(), c6_hosted_print_route(), c6_hosted_puts(), H_GPIO_DATA_READY_Pin, H_GPIO_DATA_READY_Port, H_GPIO_HANDSHAKE_Pin, H_GPIO_HANDSHAKE_Port, H_GPIO_PIN_RESET, H_GPIO_PORT_RESET, k_ra8_esp_hosted_pin_chip_select, k_ra8_esp_hosted_pin_cipo, k_ra8_esp_hosted_pin_copi, k_ra8_esp_hosted_pin_data_ready, k_ra8_esp_hosted_pin_handshake, and k_ra8_esp_hosted_pin_sck.

Referenced by main().

◆ c6_hosted_print_route()

void c6_hosted_print_route ( const char * label,
ra8_esp_hosted_pin_t pin )
static

Print the interrupt path the port takes for one side-band pin.

Parameters
[in]labelSignal name, printed verbatim.
[in]pinPacked side-band pin from the port's pin table.
Returns
Nothing.
Precondition
The console is up.
pin is one of the link's side-band nets.
Postcondition
One line naming either the ICU channel or the software edge detector was emitted.
No application state is modified.
Note
The lookup is pure, so this reports the routing the port really uses rather than an assumption about the package.
Since
0.1.0

Definition at line 70 of file c6_hosted_report.c.

References c6_hosted_print_pin(), c6_hosted_put_u32(), c6_hosted_puts(), k_c6_hosted_edge_poll_ms, k_ra8_esp_hosted_irq_none, pin, and ra8_esp_hosted_pin_irq_num().

Referenced by c6_hosted_print_pin_map().

◆ c6_hosted_read_sideband()

void c6_hosted_read_sideband ( const char * label,
void * gpio_port,
int32_t gpio_pin,
int32_t active )
static

Sample one side-band input through the OS-abstraction vtable.

Parameters
[in]labelSignal name, printed verbatim.
[in]gpio_portOpaque port handle from the matching macro pair.
[in]gpio_pinPin index from the same pair, negative if unwired.
[in]activeLevel that means "asserted" for this signal.
Returns
Nothing.
Precondition
g_h.funcs is populated, so the port came up.
gpio_port and gpio_pin are the two halves of one macro pair.
Postcondition
One line giving the level and whether it is asserted was emitted.
No application state is modified.
Note
An unwired signal is said to be unwired rather than read, since a negative pin index would convert to a nonsense unsigned argument.
Since
0.1.0

Definition at line 102 of file c6_hosted_report.c.

References c6_hosted_put_i32(), c6_hosted_puts(), and g_h.

Referenced by c6_hosted_report_sideband().

◆ c6_hosted_report_sideband()

void c6_hosted_report_sideband ( void )

Sample both side-band lines through the vtable and report them.

Returns
Nothing.
Precondition
ra8_esp_hosted_port_init returned k_ra8_ok, so g_h.funcs is populated.
The console is up.
Postcondition
One line per side-band signal was emitted.
No application state is modified.
Note
Each level is compared against the active level the port config derives, so the line says "asserted" rather than leaving the reader to recall the polarity.
See also
c6_hosted_print_pin_map
Since
0.1.0

Definition at line 152 of file c6_hosted_report.c.

References c6_hosted_read_sideband(), H_DR_VAL_ACTIVE, H_GPIO_DATA_READY_Pin, H_GPIO_DATA_READY_Port, H_GPIO_HANDSHAKE_Pin, H_GPIO_HANDSHAKE_Port, and H_HS_VAL_ACTIVE.

Referenced by c6_hosted_heartbeat(), and c6_hosted_worker_entry().

Variable Documentation

◆ s_c6_hosted_events

volatile uint32_t s_c6_hosted_events
static

Number of events c6_hosted_on_event has been handed.

Surfaced through c6_hosted_event_count and printed on every heartbeat, so a scope-less bench can still see whether the co-processor ever announced itself.

Note
Incremented on the posting thread; a single 32-bit store.
Warning
Diagnostic only, not an atomic counter.
Since
0.1.0

Definition at line 54 of file c6_hosted_report.c.

Referenced by c6_hosted_event_count(), and c6_hosted_on_event().