76typedef enum : uint64_t {
82typedef enum : uint32_t {
104typedef enum : uint64_t {
119typedef enum : uint32_t {
185 for (
unsigned i = 0U; (i < size) && ((off + (uint64_t)i) < (uint64_t)
k_gptp_win_span); ++i) {
204 for (
unsigned i = 0U; (i < size) && ((off + (uint64_t)i) < (uint64_t)
k_gptp_win_span); ++i) {
294 uint64_t total_nsec = (uint64_t)u->
off_nsec + (uint64_t)free_ns;
295 uint64_t carry_sec = 0U;
301 *out_sec = total_sec;
338 const uint64_t whole = u->
acc_fixed / one_sec_fixed;
361 if ((value & (1UL << t)) != 0U) {
362 s_gptp.timer[t].enabled =
true;
382 if ((value & (1UL << t)) != 0U) {
383 s_gptp.timer[t].enabled =
false;
384 s_gptp.timer[t].acc_sec = 0U;
385 s_gptp.timer[t].acc_fixed = 0U;
404 if (
s_gptp.timer[t].enabled) {
430 const uint64_t base =
434 const uint64_t ovcu =
438 const uint64_t ovcm =
442 const uint64_t ovcl =
501 *out = (uint32_t)avtp;
553 return (uint64_t)val;
650 " GPTP timer%u : gPTP=%llu.%09u s (ESWCLK %llu MHz free-run)\n",
652 (
unsigned long long)sec,
Decentralized peripheral-block registry for the board emulator core.
void board_periph_register_block(const board_periph_block_t *block)
Register a peripheral block's descriptor with the core registry.
gptp_access_const_t
Byte / word access constants for the flat config shadow.
@ k_gptp_reg32_bytes
One 32-bit register.
@ k_gptp_byte_mask
Low 8 bits of a value.
@ k_gptp_shift_byte
One-byte shift.
static bool internal_gptp_read_monitor(uint32_t t, uint64_t inoff, uint32_t *out)
Serve a read of a per-timer monitoring register, or report "not one".
static uint32_t internal_gptp_shadow_u32(uint64_t off)
Read a 32-bit shadow register at window offset off.
static void internal_gptp_apply_tmdc(uint32_t value)
Apply a PTPTMDC write: stop and clear each unit whose bit is set.
static uint64_t internal_gptp_shadow_read(uint64_t off, unsigned size)
Read size bytes little-endian from the config shadow at off.
static void internal_gptp_write(uc_engine *uc, uint64_t addr, unsigned size, uint64_t value)
MMIO write handler for the GPTP window.
static void internal_gptp_tick(uc_engine *uc)
Per-tick advance for every running timer unit.
static void internal_gptp_reset(void)
Reset the GPTP model to its power-on state.
static void internal_gptp_apply_tmec(uint32_t value)
Apply a PTPTMEC write: start each unit whose bit is set.
static const board_periph_block_t s_k_gptp_block
GPTP block descriptor.
static gptp_state_t s_gptp
Singleton GPTP model state.
static void internal_gptp_shadow_write(uint64_t off, unsigned size, uint64_t value)
Write size bytes little-endian into the config shadow at off.
gptp_order_t
Per-tick order slot: right after the R-Switch cluster (58).
@ k_gptp_block_order
Tick / reset / report order (just after ETH).
static uint32_t internal_gptp_read_tmec(void)
Read PTPTMEC back as the live enable bitmask across the units.
static void internal_gptp_report(void)
End-of-run GPTP section: report any unit that advanced.
gptp_time_const_t
Clock rate, fixed-point scale and field widths of the GPTP time.
@ k_gptp_ipv_reset
PTPIPV read-only reset (HUM 35.3.1.1).
@ k_gptp_mask_sec_48
48-bit seconds field.
@ k_gptp_clk_per_tick
ESWCLK cycles per emulator tick.
@ k_gptp_hz_per_mhz
Hz per MHz, for the report line.
@ k_gptp_eswclk_hz
ESWCLK = PLL1P/4 (HUM 9.10.23 p 398).
@ k_gptp_tick_hz
Ticks/s: one tick = one SysTick 1 ms.
gptp_win_geom_t
Absolute window the block owns.
@ k_gptp_win_span
Whole GPTP aperture length.
@ k_gptp_win_base
GPTP window base (0x403E_0000).
static void internal_gptp_commit_offset(uint32_t t)
Commit one unit's 78-bit offset from the staged PTPTOVCt registers.
static void internal_gptp_tick_timer(uint32_t t)
Advance one running unit's free-running accumulator by one tick.
static void internal_gptp_block_register(void)
Self-register the GPTP window before main runs (decentralized).
static uint64_t internal_gptp_read(uc_engine *uc, uint64_t addr, unsigned size)
MMIO read handler for the GPTP window.
static bool internal_gptp_decode_timer(uint64_t off, uint32_t *out_timer, uint64_t *out_inoff)
Resolve a window offset to a timer unit and its in-block offset.
static void internal_gptp_time_now(uint32_t t, uint64_t *out_sec, uint32_t *out_nsec)
Compute one unit's current GPTP time (offset + free-running counter).
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.
@ k_gptp_ns_per_sec
Nanoseconds in one second.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
@ k_gptp_subns_shift
5.27 fixed-point scale of TIV.
@ k_gptp_mask_nsec
Mask for GPTPL / TOVL [29:0].
@ k_gptp_shift_sec_u
Seconds upper part starts at 2^32.
@ k_gptp_mask_sec_u
Mask for GPTPU / TOVU [15:0].
Ethernet controller base addresses for the Renesas RA8D2.
@ k_ra8_gptp_timer_count
Number of timer units on this part.
@ k_ra8_gptp_off_ptptmdc
PTPTMDC Timer Disable Cfg.
@ k_ra8_gptp_off_t_ptpgptptmu
PTPGPTPTMtU in-block offset.
@ k_ra8_gptp_off_t_ptptovcl
PTPTOVCtL in-block offset.
@ k_ra8_gptp_off_timer0
First per-timer block.
@ k_ra8_gptp_off_t_ptpgptptmm
PTPGPTPTMtM in-block offset.
@ k_ra8_gptp_off_t_ptpavtptmu
PTPAVTPTMtU in-block offset.
@ k_ra8_gptp_off_t_ptptivc
PTPTIVCt in-block offset.
@ k_ra8_gptp_off_t_ptpgptptml
PTPGPTPTMtL in-block offset.
@ k_ra8_gptp_off_t_ptpavtptml
PTPAVTPTMtL in-block offset.
@ k_ra8_gptp_off_ptpipv
PTPIPV IP Version.
@ k_ra8_gptp_off_t_ptptovcm
PTPTOVCtM in-block offset.
@ k_ra8_gptp_off_t_ptptovcu
PTPTOVCtU in-block offset.
@ k_ra8_gptp_timer_stride
Per-timer block stride (0x40 x t).
@ k_ra8_gptp_off_ptptmec
PTPTMEC Timer Enable Cfg.
@ k_ra8_gptp_base_addr
RA8 gptp base address.
A modelled peripheral block's self-description for the core registry.
gptp_timer_t timer[k_ra8_gptp_timer_count]
Per-unit derived state.
uint8_t win[k_gptp_win_span]
Flat config-reflect shadow.
Runtime state of one GPTP timer unit.
uint64_t off_sec
Committed offset seconds (48-bit).
uint32_t latch_gptp_u
PTPGPTPTMtU latched on the L read.
bool enabled
PTPTMEC.TEq: unit is counting.
uint64_t acc_sec
Free-running whole seconds.
uint64_t acc_fixed
Free-running sub-second, 5.27 fixed-point ns.
uint32_t off_nsec
Committed offset nanoseconds (below 1e9).
uint32_t latch_gptp_m
PTPGPTPTMtM latched on the L read.
uint32_t latch_avtp_u
PTPAVTPTMtU latched on the L read.