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

–fast-sd whole-block SD serving seam More...

#include <stdio.h>
#include "board_periph_sd.h"
#include "emu_elf.h"
#include "emu_engine.h"
#include "emu_host_io_internal.h"
#include "emu_seams.h"
#include "emu_trace.h"
Include dependency graph for emu_seam_sd.c:

Go to the source code of this file.

Enumerations

enum  fast_sd_const_t : uint16_t { k_fast_sd_block = 512U }
 –fast-sd block-serving constants. More...

Functions

static RA8_INTERNAL void internal_on_sdmmc_read_block (uc_engine *uc, uint64_t address, uint32_t size, void *user)
 Perform on sdmmc read block for the emu seam SD model.
void fast_sd_seam_install (uc_engine *uc, const emu_elf_source_t *elf)
 Install the --fast-sd block-read hook if opted-in and the symbol exists.
void emu_fast_sd_enable (void)
 Implementation of emu_fast_sd_enable() – CLI opt-in latch.

Variables

static bool s_fast_sd
 True once --fast-sd is requested on the command line.

Detailed Description

–fast-sd whole-block SD serving seam

Serves whole 512-byte SD blocks in C instead of clocking 512 SPI bytes each – an opt-in emulation-speed seam whose data path is byte-identical to the CMD17 stream (the FAT parse, inflate and render all still run on the real firmware). Moved verbatim out of the ra8_emulator main translation unit; the full rationale rides with the code below.

Since
0.1.0

Definition in file emu_seam_sd.c.

Enumeration Type Documentation

◆ fast_sd_const_t

enum fast_sd_const_t : uint16_t

–fast-sd block-serving constants.

Enumerator
k_fast_sd_block 

SD block size served per hook entry.

Definition at line 61 of file emu_seam_sd.c.

Function Documentation

◆ emu_fast_sd_enable()

void emu_fast_sd_enable ( void )

Implementation of emu_fast_sd_enable() – CLI opt-in latch.

Opt in to the –fast-sd block-serving seam for this run.

Definition at line 149 of file emu_seam_sd.c.

References s_fast_sd.

Referenced by internal_args_try_mode().

◆ fast_sd_seam_install()

void fast_sd_seam_install ( uc_engine * uc,
const emu_elf_source_t * elf )

Install the --fast-sd block-read hook if opted-in and the symbol exists.

Parameters
[in,out]ucActive Unicorn engine.
[in]elfLoaded ELF image (for symbol resolution).
Precondition
uc is initialised and elf is a validated loaded image.
Postcondition
With s_fast_sd and the symbol present, a UC_HOOK_CODE fires internal_on_sdmmc_read_block at the function entry; otherwise nothing is armed.
Note
A firmware without ra8_sdmmc_spi_read_block (no SD path) is reported once and left on the default per-byte MMIO path.
Since
0.1.0

Definition at line 124 of file emu_seam_sd.c.

References elf_sym_addr(), internal_on_sdmmc_read_block(), priv_emu_io_errf(), and s_fast_sd.

Referenced by internal_main_install_run_seams().

◆ internal_on_sdmmc_read_block()

RA8_INTERNAL void internal_on_sdmmc_read_block ( uc_engine * uc,
uint64_t address,
uint32_t size,
void * user )
static

Perform on sdmmc read block for the emu seam SD model.

Perform on sdmmc read block for the emu seam sd model; this step is contained within the emu seam SD model and uses bounded caller or module-owned storage.

Parameters
[in,out]ucUnicorn engine whose emulated state is read or updated.
[in]addressGuest address involved in the operation.
[in]sizeSize of the requested region or access in bytes.
[in,out]userHook context supplied when the callback was registered.
Precondition
Arguments satisfy the ranges documented for on sdmmc read block.
The call executes on the emulator's single owning thread.
Postcondition
State changes remain confined to the emu seam SD 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 emu_seam_sd.c.

References board_sd_attached(), board_sd_read_block(), emu_mem_write(), emu_seam_request_relaunch(), eth_hook_return(), and k_fast_sd_block.

Referenced by fast_sd_seam_install().

Variable Documentation

◆ s_fast_sd

bool s_fast_sd
static

True once --fast-sd is requested on the command line.

Gates fast_sd_seam_install; when false the hook is never armed and the SD path runs the full faithful per-byte MMIO block protocol.

Warning
Single-threaded run loop only.
Since
0.1.0

Definition at line 73 of file emu_seam_sd.c.

Referenced by emu_fast_sd_enable(), and fast_sd_seam_install().