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

Serial Sound Interface Enhanced (SSIE / I2S) peripheral-block model. More...

#include <stdint.h>
#include <stdio.h>
#include "board_console.h"
#include "board_periph_block.h"
#include "emu_host_io_internal.h"
Include dependency graph for board_periph_ssie.c:

Go to the source code of this file.

Data Structures

struct  ssie_state_t
 One SSIE channel: a flat register shadow + a TX sample tally. More...

Enumerations

enum  ssie_console_t : uint32_t { k_ssie_console_line_cap = 48U }
 Console-tap line buffer capacity for an I2S/SSIE summary. More...
enum  ssie_map_t : uint64_t {
  k_ssie_base = 0x4025D000UL ,
  k_ssie_stride = 0x100UL ,
  k_ssie_count = 2UL ,
  k_ssie_span = 0x100UL * 2UL ,
  k_ssie_regs = 0x40UL
}
 SSIE block geometry (ra8_ssie_regs.h). More...
enum  ssie_off_t : uint64_t {
  k_ssie_off_ssicr = 0x00UL ,
  k_ssie_off_ssisr = 0x04UL ,
  k_ssie_off_ssifcr = 0x10UL ,
  k_ssie_off_ssifsr = 0x14UL ,
  k_ssie_off_ssiftdr = 0x18UL ,
  k_ssie_off_ssifrdr = 0x1CUL
}
 Per-channel register byte offsets (ra8_ssie_regs.h). More...
enum  ssie_field_t : uint32_t {
  k_ssie_ren_ten = 0x00000003U ,
  k_ssie_iirq = 0x02000000U ,
  k_ssie_tde = 0x00010000U
}
 SSICR / SSISR / SSIFSR field masks used by the model. More...
enum  ssie_order_t : uint32_t { k_ssie_block_order = 130U }
 Per-tick order slot for the SSIE block (relative order only). More...

Functions

static RA8_INTERNAL void internal_ssie_reset (void)
 Reset all SSIE channel shadows to power-on (zeroed) state.
static RA8_INTERNAL uint64_t internal_ssie_read (uc_engine *uc, uint64_t addr, unsigned size)
 MMIO read inside the SSIE window: route to the addressed channel.
static RA8_INTERNAL void internal_ssie_write (uc_engine *uc, uint64_t addr, unsigned size, uint64_t value)
 MMIO write inside the SSIE window: route to the addressed channel.
static RA8_INTERNAL void internal_ssie_report (void)
 End-of-run SSIE section: per-channel enable state + TX tally.
static RA8_INTERNAL void internal_ssie_block_register (void)
 Register the SSIE block before main (host constructor).

Variables

static ssie_state_t s_ssie [k_ssie_count]
static const board_periph_block_t s_k_ssie_block
 SSIE block descriptor (self-registered with the core).

Detailed Description

Serial Sound Interface Enhanced (SSIE / I2S) peripheral-block model.

Models the RA8D2 SSIE (ra8_ssie_regs.h, ra8_ssie.c) closely enough that the ssie_audio_loop example runs on the emulator instead of bailing to its panic-halt. Two channels (SSIE0 0x4025D000, SSIE1 0x4025D100, 0x100 stride) are modelled as a per-channel register shadow with two read overrides that the driver's bring-up actually depends on:

  • SSISR.IIRQ (idle, bit 25). ra8_ssie_start refuses to set REN/TEN unless it first reads SSISR with IIRQ asserted (otherwise k_ra8_err_busy). The model returns IIRQ set while the channel is idle (REN and TEN both clear) and clears it once REN/TEN are set, exactly as the real idle flag behaves, so the start sequence proceeds.
  • SSIFSR.TDE (transmit FIFO empty, bit 16). Held set so the transmit path always has room; ra8_ssie_write_sample writes SSIFTDR, which the model drains (counting samples for the end-of-run report) rather than backing up.

Every other register is a faithful write/readback shadow, so a "configure then verify" read returns what was written (SSICR config, SSIFCR FIFO control, SSIRST, SSIOFR audio format). The model does not synthesise audio clocks or the I2S frame – it reproduces the controller handshake the firmware drives, matching the rest of board_periph (it validates "does the firmware program the SSIE correctly", not silicon timing).

Since
0.1.0

Definition in file board_periph_ssie.c.

Enumeration Type Documentation

◆ ssie_console_t

enum ssie_console_t : uint32_t

Console-tap line buffer capacity for an I2S/SSIE summary.

Enumerator
k_ssie_console_line_cap 

Max chars in an "I2S ch.. tx=.." line.

Definition at line 42 of file board_periph_ssie.c.

◆ ssie_field_t

enum ssie_field_t : uint32_t

SSICR / SSISR / SSIFSR field masks used by the model.

Enumerator
k_ssie_ren_ten 

SSICR REN | TEN.

k_ssie_iirq 

SSISR IIRQ idle-mode flag (bit 25).

k_ssie_tde 

SSIFSR TDE transmit-FIFO-empty.

Definition at line 66 of file board_periph_ssie.c.

◆ ssie_map_t

enum ssie_map_t : uint64_t

SSIE block geometry (ra8_ssie_regs.h).

Enumerator
k_ssie_base 

SSIE0 base.

k_ssie_stride 

Bytes per SSIE channel.

k_ssie_count 

SSIE0, SSIE1.

k_ssie_span 

Ssie span.

k_ssie_regs 

Shadowed 32-bit words per channel (0x00..0xFC).

Definition at line 47 of file board_periph_ssie.c.

◆ ssie_off_t

enum ssie_off_t : uint64_t

Per-channel register byte offsets (ra8_ssie_regs.h).

Enumerator
k_ssie_off_ssicr 

Control (REN/TEN, MST, DWL, SWL ...).

k_ssie_off_ssisr 

Status (IIRQ + over/underflow flags).

k_ssie_off_ssifcr 

FIFO control (RFRST/TFRST ...).

k_ssie_off_ssifsr 

FIFO status (RDF, TDE, RDC, TDC).

k_ssie_off_ssiftdr 

Transmit FIFO data.

k_ssie_off_ssifrdr 

Receive FIFO data.

Definition at line 56 of file board_periph_ssie.c.

◆ ssie_order_t

enum ssie_order_t : uint32_t

Per-tick order slot for the SSIE block (relative order only).

Enumerator
k_ssie_block_order 

After the existing blocks; report order.

Definition at line 73 of file board_periph_ssie.c.

Function Documentation

◆ internal_ssie_block_register()

RA8_INTERNAL void internal_ssie_block_register ( void )
static

Register the SSIE block before main (host constructor).

Definition at line 228 of file board_periph_ssie.c.

References board_periph_register_block(), RA8_INTERNAL, and s_k_ssie_block.

◆ internal_ssie_read()

RA8_INTERNAL uint64_t internal_ssie_read ( uc_engine * uc,
uint64_t addr,
unsigned size )
static

MMIO read inside the SSIE window: route to the addressed channel.

MMIO read inside the ssie window: route to the addressed channel; this step is contained within the board periph SSIE model and uses bounded caller or module-owned storage.

Parameters
[in,out]ucUnicorn engine whose emulated state is read or updated.
[in]addrGuest address involved in the operation.
[in]sizeSize of the requested region or access in bytes.
Returns
The SSIE read result produced by the board periph SSIE model.
Return values
valueThe operation-specific SSIE read value.
Precondition
Arguments satisfy the ranges documented for SSIE read.
The call executes on the emulator's single owning thread.
Postcondition
State changes remain confined to the board periph SSIE model and documented output objects.
Ownership of caller-supplied storage is unchanged.
Note
The operation is synchronous and does not transfer heap ownership.
Since
0.1.0

Definition at line 116 of file board_periph_ssie.c.

References k_ssie_base, k_ssie_count, k_ssie_iirq, k_ssie_off_ssicr, k_ssie_off_ssifrdr, k_ssie_off_ssifsr, k_ssie_off_ssisr, k_ssie_regs, k_ssie_ren_ten, k_ssie_stride, k_ssie_tde, RA8_INTERNAL, ssie_state_t::reg, and s_ssie.

◆ internal_ssie_report()

RA8_INTERNAL void internal_ssie_report ( void )
static

End-of-run SSIE section: per-channel enable state + TX tally.

End-of-run ssie section: per-channel enable state + tx tally; this step is contained within the board periph SSIE model and uses bounded caller or module-owned storage.

Precondition
Arguments satisfy the ranges documented for SSIE report.
The call executes on the emulator's single owning thread.
Postcondition
State changes remain confined to the board periph SSIE model and documented output objects.
Ownership of caller-supplied storage is unchanged.
Note
The operation is synchronous and does not transfer heap ownership.
Since
0.1.0

Definition at line 189 of file board_periph_ssie.c.

References board_console_push(), k_board_console_ch_i2s, k_ssie_console_line_cap, k_ssie_count, k_ssie_off_ssicr, priv_emu_io_errf(), RA8_INTERNAL, and s_ssie.

◆ internal_ssie_reset()

RA8_INTERNAL void internal_ssie_reset ( void )
static

Reset all SSIE channel shadows to power-on (zeroed) state.

Reset all ssie channel shadows to power-on (zeroed) state; this step is contained within the board periph SSIE model and uses bounded caller or module-owned storage.

Precondition
Arguments satisfy the ranges documented for SSIE reset.
The call executes on the emulator's single owning thread.
Postcondition
State changes remain confined to the board periph SSIE model and documented output objects.
Ownership of caller-supplied storage is unchanged.
Note
The operation is synchronous and does not transfer heap ownership.
Since
0.1.0

Definition at line 93 of file board_periph_ssie.c.

References k_ssie_count, k_ssie_regs, RA8_INTERNAL, and s_ssie.

◆ internal_ssie_write()

RA8_INTERNAL void internal_ssie_write ( uc_engine * uc,
uint64_t addr,
unsigned size,
uint64_t value )
static

MMIO write inside the SSIE window: route to the addressed channel.

MMIO write inside the ssie window: route to the addressed channel; this step is contained within the board periph SSIE model and uses bounded caller or module-owned storage.

Parameters
[in,out]ucUnicorn engine whose emulated state is read or updated.
[in]addrGuest address involved in the operation.
[in]sizeSize of the requested region or access in bytes.
[in]valueRegister or payload value involved in the operation.
Precondition
Arguments satisfy the ranges documented for SSIE write.
The call executes on the emulator's single owning thread.
Postcondition
State changes remain confined to the board periph SSIE model and documented output objects.
Ownership of caller-supplied storage is unchanged.
Note
The operation is synchronous and does not transfer heap ownership.
Since
0.1.0

Definition at line 158 of file board_periph_ssie.c.

References k_ssie_base, k_ssie_count, k_ssie_off_ssiftdr, k_ssie_regs, k_ssie_stride, ssie_state_t::reg, s_ssie, and ssie_state_t::tx_samples.

Variable Documentation

◆ s_k_ssie_block

const board_periph_block_t s_k_ssie_block
static
Initial value:
= {
.base = (uint32_t)k_ssie_base,
.span = (uint32_t)k_ssie_span,
.order = (uint32_t)k_ssie_block_order,
.tick = nullptr,
.name = "SSIE",
}
@ k_ssie_block_order
After the existing blocks; report order.
static RA8_INTERNAL void internal_ssie_reset(void)
Reset all SSIE channel shadows to power-on (zeroed) state.
static RA8_INTERNAL void internal_ssie_report(void)
End-of-run SSIE section: per-channel enable state + TX tally.
static RA8_INTERNAL void internal_ssie_write(uc_engine *uc, uint64_t addr, unsigned size, uint64_t value)
MMIO write inside the SSIE window: route to the addressed channel.
@ k_ssie_base
SSIE0 base.
@ k_ssie_span
Ssie span.
static RA8_INTERNAL uint64_t internal_ssie_read(uc_engine *uc, uint64_t addr, unsigned size)
MMIO read inside the SSIE window: route to the addressed channel.
-proof

SSIE block descriptor (self-registered with the core).

Definition at line 215 of file board_periph_ssie.c.

Referenced by internal_ssie_block_register().

◆ s_ssie