35typedef enum : uint64_t {
48typedef enum : uint64_t {
63typedef enum : uint32_t {
68typedef enum : uint32_t {
77typedef enum : uint32_t {
93typedef enum : uint16_t {
122typedef enum : uint32_t {
204 a->
reload = (uint16_t)value;
206 a->
cmpa = (uint16_t)value;
208 a->
cmpb = (uint16_t)value;
212 const uint8_t status_keep =
215 a->
cr = (uint8_t)(start | (start != 0U ? (uint8_t)
k_agtcr_tcstf : 0U) | status_keep);
217 a->
mr1 = (uint8_t)value;
243 const uint32_t span = (uint32_t)a->
reload + 1U;
244 const uint32_t deficit = step - a->
counter;
245 a->
counter = (uint16_t)(a->
reload - ((deficit - 1U) % span));
353 if ((value & 1U) != 0U) {
357 if ((value & 1U) != 0U) {
361 if ((value & 1U) != 0U) {
389 if ((g->
cnt + step) <= period) {
394 g->
cnt = (uint32_t)((g->
cnt + step) - period - 1U);
462 for (uint32_t ch = 0U; ch < (uint32_t)
k_agt_count; ch++) {
465 for (uint32_t ch = 0U; ch < (uint32_t)
k_gpt_count; ch++) {
480 for (uint32_t i = 0U; i < (uint32_t)
k_agt_count; i++) {
483 for (uint32_t i = 0U; i < (uint32_t)
k_gpt_count; i++) {
498 for (uint32_t ch = 0U; ch < (uint32_t)
k_agt_count; ch++) {
499 if (
s_agt[ch].underflows > 0U) {
500 (void)
priv_emu_io_errf(
" AGT%u : counter=0x%04X underflows=%u (running=%s)\n",
503 s_agt[ch].underflows,
507 for (uint32_t ch = 0U; ch < (uint32_t)
k_gpt_count; ch++) {
508 if (
s_gpt[ch].overflows > 0U) {
513 s_gpt[ch].overflows);
Decentralized peripheral-block registry for the board emulator core.
void board_periph_icu_raise_event(uc_engine *uc, uint16_t event)
Raise a peripheral ELC event through the core's ICU -> NVIC path.
void board_periph_register_block(const board_periph_block_t *block)
Register a peripheral block's descriptor with the core registry.
@ k_block_order_timer
GPT + AGT timers.
static RA8_INTERNAL void internal_board_periph_timer_register(void)
Self-register both timer windows before main runs (decentralized).
static RA8_INTERNAL uint64_t internal_gpt_reg_read(uint32_t ch, uint64_t off)
Dispatch a GPT register read for channel ch at byte offset off.
static gpt_state_t s_gpt[k_gpt_count]
static RA8_INTERNAL void internal_agt_tick_channel(uc_engine *uc, uint32_t ch)
Advance one running AGT channel by one chunk; raise events on wrap.
elc_event_t
Canonical ELC event numbers the timer models emit (FSP ra8d2 bsp_elc).
@ k_event_gpt0_ovf
GPT0 GTCIV counter-overflow event.
@ k_event_agt0_int
AGT0 AGTI combined interrupt event.
static RA8_INTERNAL void internal_gpt_tick_channel(uc_engine *uc, uint32_t ch)
Advance one running GPT channel by one chunk; raise overflow events.
static RA8_INTERNAL void internal_agt_reg_write(uint32_t ch, uint64_t off, uint32_t value)
Dispatch an AGT register write; AGTCR.TSTART arms / status is RW1C.
static RA8_INTERNAL void internal_timer_tick(uc_engine *uc)
Advance every running AGT channel, then every running GPT channel.
static RA8_INTERNAL uint64_t internal_agt_read(uc_engine *uc, uint64_t addr, unsigned size)
MMIO read inside the AGT window: route to the addressed channel.
static RA8_INTERNAL uint64_t internal_gpt_read(uc_engine *uc, uint64_t addr, unsigned size)
MMIO read inside the GPT window: route to the addressed channel.
static RA8_INTERNAL void internal_agt_write(uc_engine *uc, uint64_t addr, unsigned size, uint64_t value)
MMIO write inside the AGT window: route to the addressed channel.
static RA8_INTERNAL void internal_gpt_reg_write(uint32_t ch, uint64_t off, uint32_t value)
Dispatch a GPT register write; GTSTR/GTSTP gate the counter.
gpt_bit_t
GPT GTCR / GTST bits – ra8_gpt register notes.
@ k_gtst_tcfa
GTST.TCFA compare-match A.
@ k_gtst_tcfpo
GTST.TCFPO overflow.
@ k_gtcr_cst
GTCR.CST count-start.
@ k_gtst_tcfpu
GTST.TCFPU underflow.
static RA8_INTERNAL uint64_t internal_agt_reg_read(uint32_t ch, uint64_t off)
Dispatch an AGT register read for channel ch at byte offset off.
agtcr_bit_t
AGTCR (control/status) bits – ra8_agt_agtcr_bits_t.
@ k_agtcr_tundf
TUNDF underflow flag (RW1C).
@ k_agtcr_tcmaf
TCMAF compare-match A flag (RW1C).
@ k_agtcr_tstart
TSTART start request.
@ k_agtcr_tcmbf
TCMBF compare-match B flag (RW1C).
@ k_agtcr_tcstf
TCSTF count-status flag (RO).
agt_map_t
AGT block geometry (ra8_agt_regs.h, 16-bit view).
@ k_agt_off_cmb
AGTCMB compare-match B.
@ k_agt_off_agt
AGT counter (16-bit down).
@ k_agt_stride
Bytes per AGT channel.
@ k_agt_off_cma
AGTCMA compare-match A.
@ k_agt_off_mr1
AGTMR1 mode 1 (8-bit).
@ k_agt_off_cr
AGTCR control/status (8-bit).
gpt_map_t
GPT block geometry (ra8_gpt_regs.h, 32-bit channels).
@ k_gpt_off_gtpr
GTPR period.
@ k_gpt_off_gtstp
GTSTP software stop.
@ k_gpt_off_gtclr
GTCLR software clear.
@ k_gpt_off_gtst
GTST status.
@ k_gpt_stride
Bytes per GPT channel.
@ k_gpt_off_gtstr
GTSTR software start.
@ k_gpt_off_gtcr
GTCR control (CST bit0).
@ k_gpt_count
GPT0..GPT13.
@ k_gpt_off_gtcnt
GTCNT counter (32-bit up).
static const board_periph_block_t s_k_agt_block
AGT register window + the combined timer tick / reset / report.
static const board_periph_block_t s_k_gpt_block
GPT register window (tick / reset / report handled by the AGT block).
static RA8_INTERNAL void internal_gpt_write(uc_engine *uc, uint64_t addr, unsigned size, uint64_t value)
MMIO write inside the GPT window: route to the addressed channel.
timer_field_t
16-bit counter wrap value (also the GPT default period).
@ k_u16_max
16-bit counter wrap value.
timer_tune_t
Per-chunk advance for the modelled counters (one chunk == 1 tick).
@ k_agt_step_per_chunk
AGT down-count per chunk.
@ k_gpt_step_per_chunk
GPT up-count per chunk; odd (.
static RA8_INTERNAL void internal_timer_report(void)
Print one line per AGT / GPT channel that raised any event.
static RA8_INTERNAL void internal_timer_reset(void)
Clear all AGT + GPT channel state.
static agt_state_t s_agt[k_agt_count]
Bounded raw-descriptor I/O seam for the RA8 emulator.
emu_io_result_t priv_emu_io_errf(const char *format,...)
Format bounded text and write it to the injected error descriptor.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
One AGT channel: a 16-bit reloading down-counter + status.
uint32_t underflows
Underflow event count.
uint16_t cmpa
AGTCMA compare-match A.
uint16_t cmpb
AGTCMB compare-match B.
uint16_t reload
Value last written to AGT.
uint8_t mr1
AGTMR1 mode 1.
uint8_t cr
AGTCR control/status.
uint16_t counter
Live AGT count.
A modelled peripheral block's self-description for the core registry.
One GPT channel: a 32-bit saw up-counter + status.
uint32_t st
GTST status flags.
uint32_t cnt
GTCNT live count.
uint32_t period
GTPR period.
uint32_t overflows
Overflow event count.
uint32_t cr
GTCR (CST in bit0).