|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
ra8_io caching block device demo (Phase 5, #160). More...
#include <stdint.h>#include <string.h>#include "ra8_attributes.h"#include "ra8_board_ek_ra8d2.h"#include "ra8_board_ek_ra8d2_console_stream.h"#include "ra8_boot_entry.h"#include "ra8_cgc.h"#include "ra8_check.h"#include "ra8_err.h"#include "ra8_fs.h"#include "ra8_io.h"#include "ra8_io_blockdev_cache.h"#include "ra8_log.h"#include "ra8_time.h"Go to the source code of this file.
Enumerations | |
| enum | demo_const_t : uint32_t { k_demo_uart_baud = 115200U , k_demo_disk_blocks = 512U , k_demo_cache_slots = 32U , k_demo_payload = 128U , k_demo_reads = 8U , k_demo_seed_mul = 7U } |
| Console + volume + cache knobs (no magic numbers). More... | |
Functions | |
| static void | internal_demo_print (const char *msg) |
| Print a NUL-terminated string on the UART stream. | |
| static void | internal_demo_setup_or_halt (void) |
| Bring up CGC, SysTick, and the board console; halt on failure. | |
| static ra8_err_t | internal_demo_mount (ra8_fs_mount_t **out_mnt) |
| Bridge the cached device to ra8_fs, format FAT12, and register the VFS. | |
| static ra8_err_t | internal_demo_read_once (const uint8_t *expect) |
Read ram:/HELLO.TXT once and compare it against expect. | |
| static ra8_err_t | internal_demo_run (uint32_t *out_hits, uint32_t *out_misses) |
| Write the file once and re-read it repeatedly through the cache. | |
| void | main (void) |
| Firmware entry point. | |
Variables | |
| static uint8_t | s_disk [(size_t) k_demo_disk_blocks *(size_t) k_ra8_io_block_size_bytes] |
| 256 KiB RAM-disk backing buffer for the slow backend (in SRAM .bss). | |
| static ra8_io_blockdev_t | s_under |
| Slow backend block-device handle + its RAM backend state. | |
| static ra8_io_blockdev_ram_state_t | s_ustate |
| static ra8_io_blockdev_t | s_cached |
| Caching decorator over the backend + its caller-owned cache storage. | |
| static ra8_io_blockdev_cache_state_t | s_cstate |
| static uint8_t | s_cache_data [(size_t) k_demo_cache_slots *(size_t) k_ra8_io_block_size_bytes] |
| static ra8_io_blockdev_cache_slot_t | s_cache_slots [(size_t) k_demo_cache_slots] |
| static ra8_fs_backend_t | s_be |
| ra8_fs backend bridged onto the cached block device. | |
| static ra8_io_stream_t | s_uart |
| Console output stream; the board owns the sink behind it. | |
| static const char *const | s_tag = "ra8_io_cache_demo" |
| Module log tag. | |
ra8_io caching block device demo (Phase 5, #160).
Exercises the caching block device – an LRU sector cache decorator that wraps any backend so repeated reads of the same blocks (filesystem metadata, a re-read page) skip the slow medium. The cache sits between the filesystem/VFS and the media:
The ra8_emulator captures the SCI8 console, so the PASS line and the hit/miss counts are observable headlessly: a successful run prints ra8_io_cache_demo: re-read x8 hits=H misses=M ram:/HELLO.TXT PASS.
Definition in file main.c.
| enum demo_const_t : uint32_t |
Console + volume + cache knobs (no magic numbers).
|
static |
Bridge the cached device to ra8_fs, format FAT12, and register the VFS.
Constructs the RAM backend and cache decorator in caller-owned storage, formats a FAT12 volume, mounts it, and registers the ram prefix.
| [out] | out_mnt | Receives the mounted FAT filesystem on success. |
| k_ra8_ok | The cached FAT12 volume was mounted and registered. |
out_mnt addresses writable pointer storage. out_mnt identifies the VFS-registered mount. Definition at line 142 of file main.c.
References k_demo_cache_slots, k_demo_disk_blocks, k_ra8_fs_type_fat12, k_ra8_ok, ra8_fs_format_opts_t::label, RA8_CHECK_NULL_PTR, ra8_fs_format(), ra8_fs_mount(), RA8_INTERNAL, ra8_io_blockdev_as_fs_backend(), ra8_io_blockdev_cache_init(), ra8_io_blockdev_ram_init(), ra8_io_vfs_mount(), RA8_RETURN_ON_ERROR, s_be, s_cache_data, s_cache_slots, s_cached, s_cstate, s_disk, s_tag, s_under, s_ustate, and ra8_fs_format_opts_t::type.
|
static |
Print a NUL-terminated string on the UART stream.
Delegates bounded string emission to the initialized stream and intentionally ignores diagnostic-output errors in this terminal demo.
| [in] | msg | NUL-terminated message to emit. |
msg is non-NULL and readable through its terminator. Definition at line 92 of file main.c.
References RA8_INTERNAL, ra8_io_stream_puts(), and s_uart.
|
static |
Read ram:/HELLO.TXT once and compare it against expect.
Opens the file through VFS, reads exactly the configured payload, closes the handle, then validates both length and contents.
| [in] | expect | Expected payload bytes for the comparison. |
| k_ra8_ok | The complete payload matched expect. |
| k_ra8_err_invalid_size | The file length differed from the payload size. |
| k_ra8_err_checksum_mismatch | At least one byte differed. |
expect addresses at least k_demo_payload readable bytes. Definition at line 185 of file main.c.
References k_demo_payload, k_ra8_err_checksum_mismatch, k_ra8_err_invalid_size, k_ra8_fs_mode_read, k_ra8_ok, memcmp(), RA8_CHECK_NULL_PTR, ra8_fs_close(), ra8_fs_read(), RA8_INTERNAL, ra8_io_vfs_open(), RA8_RETURN_ON_ERROR, and s_tag.
Referenced by internal_demo_run().
|
static |
Write the file once and re-read it repeatedly through the cache.
Mounts the cached volume, creates a deterministic payload, writes it, verifies every configured read pass, and returns cache hit/miss counters.
| [out] | out_hits | Receives the cache-hit count. |
| [out] | out_misses | Receives the cache-miss count. |
| k_ra8_ok | Every read matched and at least one cache hit was observed. |
| k_ra8_err_checksum_mismatch | Data differed or no hit was recorded. |
Definition at line 221 of file main.c.
References internal_demo_mount(), internal_demo_read_once(), k_demo_payload, k_demo_reads, k_demo_seed_mul, k_ra8_err_checksum_mismatch, k_ra8_ok, RA8_CHECK_NULL_PTR, ra8_fs_write_file(), RA8_INTERNAL, ra8_io_blockdev_cache_stats(), RA8_RETURN_ON_ERROR, s_cstate, and s_tag.
|
static |
Bring up CGC, SysTick, and the board console; halt on failure.
Resolves CPUCLK0, initializes the time base, then hands the console over to the BSP – which owns the channel, the PD02 / PD03 routing and the live-PCLKA bit-rate solve – and binds it as an ra8_io stream.
Definition at line 113 of file main.c.
References k_demo_uart_baud, k_ra8_clock_id_cpuclk0, k_ra8_ok, ra8_board_console_stream(), ra8_board_uart_console_init(), ra8_cgc_get_clock_hz(), ra8_cgc_init(), RA8_INTERNAL, ra8_time_init(), and s_uart.
| void main | ( | void | ) |
Firmware entry point.
The application entry point Reset_Handler hands control to.
Definition at line 252 of file main.c.
References internal_demo_print(), internal_demo_run(), internal_demo_setup_or_halt(), k_ra8_ok, ra8_board_uart_console_flush(), ra8_io_log_attach(), ra8_io_stream_put_u32(), ra8_log_init(), and s_uart.
|
static |
ra8_fs backend bridged onto the cached block device.
Definition at line 71 of file main.c.
Referenced by demo_run(), demo_run(), internal_demo_mount(), internal_demo_probe_fat(), internal_demo_run(), internal_sd_demo_roundtrip(), internal_swap_run_one(), and sdhi_demo_mount_via_io().
|
static |
Definition at line 68 of file main.c.
Referenced by internal_demo_mount().
|
static |
Definition at line 69 of file main.c.
Referenced by internal_demo_mount().
|
static |
Caching decorator over the backend + its caller-owned cache storage.
Definition at line 66 of file main.c.
Referenced by internal_demo_mount().
|
static |
Definition at line 67 of file main.c.
Referenced by internal_demo_mount(), and internal_demo_run().
|
static |
|
static |
|
static |
|
static |
Slow backend block-device handle + its RAM backend state.
Definition at line 63 of file main.c.
Referenced by internal_demo_mount().
|
static |
Definition at line 64 of file main.c.
Referenced by internal_demo_mount().