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

Module Stop Control (MSTPCRA..E) register block for ra8_emulator. More...

#include <stdint.h>
#include <stdio.h>
#include "board_periph_block.h"
#include "board_periph_mstp_internal.h"
#include "emu_host_io_internal.h"
#include "ra8_attributes.h"
Include dependency graph for board_periph_mstp.c:

Go to the source code of this file.

Enumerations

enum  mstp_order_t : uint32_t { k_mstp_block_order = 168U }
 Per-tick order slot for the MSTP block (just before SYSC-PRCR). More...

Functions

static uint64_t internal_mstp_read (uc_engine *uc, uint64_t addr, unsigned size)
 MMIO read of MSTPCRA..E: answer from the tracked shadow.
static void internal_mstp_write (uc_engine *uc, uint64_t addr, unsigned size, uint64_t value)
 MMIO write of MSTPCRA..E: fold into the shadow (ungate/re-gate).
static void internal_mstp_report (void)
 End-of-run section: make any access to an unclocked block LOUD.
static void internal_mstp_block_register (void)
 Register the MSTP block before main (host constructor).

Variables

static const board_periph_block_t s_k_mstp_block
 MSTP block descriptor (owns MSTPCRA..E; self-registered).

Detailed Description

Module Stop Control (MSTPCRA..E) register block for ra8_emulator.

The board_periph block that owns the R_MSTP window (0x4020_3000, HUM Ch 11.2.6..11.2.10 p 443-450): it answers firmware reads/writes of MSTPCRA..MSTPCRE from the tracked shadow in board_periph_mstp_model.c, so the mandated read-back after an ungate settles deterministically and the shadow the address->bit gate table consults stays current.

The gate ENFORCEMENT lives in the board_periph core: before dispatching an MMIO access to any owning block, board_periph.c calls priv_board_mstp_addr_stopped and – when the peripheral is module-stopped – reads 0 / drops the write, matching the silicon (a stopped module is unclocked and does not respond). This file is only the register window plus the reset hook and the end-of-run "you touched an unclocked peripheral" report; the model half is engine-free so it can be unit-tested on the host.

Splitting the model out of this file is what lets the gate table be tested without Unicorn (tests/misc/src/test_ra8_emulator_mstp_gate.c); this glue is the thin part that the core registry needs and that pulls in board_periph_block.h.

Since
0.1.0

Definition in file board_periph_mstp.c.

Enumeration Type Documentation

◆ mstp_order_t

enum mstp_order_t : uint32_t

Per-tick order slot for the MSTP block (just before SYSC-PRCR).

Enumerator
k_mstp_block_order 

Groups with the PRCR / power-domain blocks.

Definition at line 38 of file board_periph_mstp.c.

Function Documentation

◆ internal_mstp_block_register()

void internal_mstp_block_register ( void )
static

Register the MSTP block before main (host constructor).

Definition at line 118 of file board_periph_mstp.c.

References board_periph_register_block(), priv_board_mstp_reset(), RA8_INTERNAL, and s_k_mstp_block.

◆ internal_mstp_read()

uint64_t internal_mstp_read ( uc_engine * uc,
uint64_t addr,
unsigned size )
static

MMIO read of MSTPCRA..E: answer from the tracked shadow.

MMIO read of mstpcra..e: answer from the tracked shadow; this step is contained within the board periph module-stop 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 module-stop read result produced by the board periph module-stop model.
Return values
valueThe operation-specific module-stop read value.
Precondition
Arguments satisfy the ranges documented for module-stop read.
The call executes on the emulator's single owning thread.
Postcondition
State changes remain confined to the board periph module-stop 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 55 of file board_periph_mstp.c.

References k_board_mstp_win_base, priv_board_mstp_read_reg(), and RA8_INTERNAL.

◆ internal_mstp_report()

void internal_mstp_report ( void )
static

End-of-run section: make any access to an unclocked block LOUD.

End-of-run section: make any access to an unclocked block loud; this step is contained within the board periph module-stop model and uses bounded caller or module-owned storage.

Precondition
Arguments satisfy the ranges documented for module-stop report.
The call executes on the emulator's single owning thread.
Postcondition
State changes remain confined to the board periph module-stop 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 88 of file board_periph_mstp.c.

References priv_board_mstp_gated_read_count(), priv_board_mstp_gated_write_count(), priv_board_mstp_last_gated_name(), priv_emu_io_errf(), and RA8_INTERNAL.

◆ internal_mstp_write()

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

MMIO write of MSTPCRA..E: fold into the shadow (ungate/re-gate).

MMIO write of mstpcra..e: fold into the shadow (ungate/re-gate); this step is contained within the board periph module-stop 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 module-stop write.
The call executes on the emulator's single owning thread.
Postcondition
State changes remain confined to the board periph module-stop 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 74 of file board_periph_mstp.c.

References k_board_mstp_win_base, and priv_board_mstp_apply_write().

Variable Documentation

◆ s_k_mstp_block

const board_periph_block_t s_k_mstp_block
static
Initial value:
= {
.base = (uint64_t)k_board_mstp_win_base,
.span = (uint64_t)k_board_mstp_win_span,
.order = (uint32_t)k_mstp_block_order,
.tick = nullptr,
.name = "MSTP",
}
static uint64_t internal_mstp_read(uc_engine *uc, uint64_t addr, unsigned size)
MMIO read of MSTPCRA..E: answer from the tracked shadow.
@ k_mstp_block_order
Groups with the PRCR / power-domain blocks.
static void internal_mstp_write(uc_engine *uc, uint64_t addr, unsigned size, uint64_t value)
MMIO write of MSTPCRA..E: fold into the shadow (ungate/re-gate).
static void internal_mstp_report(void)
End-of-run section: make any access to an unclocked block LOUD.
@ k_board_mstp_win_span
MSTPCRA..E = 5 x uint32 = 20 B.
@ k_board_mstp_win_base
R_MSTP base (Secure alias).
void priv_board_mstp_reset(void)
Restore MSTPCRA..MSTPCRE to their all-stopped reset values.
-proof

MSTP block descriptor (owns MSTPCRA..E; self-registered).

Definition at line 105 of file board_periph_mstp.c.

Referenced by internal_mstp_block_register().