46static const char*
const s_tag =
"lx_fs_be";
61typedef enum : uint32_t {
66static_assert((uint32_t)LX_NOR_SECTOR_SIZE * (uint32_t)
sizeof(
ULONG) ==
68 "LevelX logical sector must be 512 bytes");
113 uint64_t phys_per_block = (uint64_t)nor_flash->lx_nor_flash_physical_sectors_per_block;
114 if (phys_per_block <= 1U) {
117 uint64_t total_blocks = (uint64_t)nor_flash->lx_nor_flash_total_blocks;
118 return total_blocks * (phys_per_block - 1U);
154 LX_NOR_FLASH* nor_flash = ctx;
158 for (uint32_t i = 0U; i < count; i++) {
161 if (rc == (
UINT)LX_SECTOR_NOT_FOUND) {
163 }
else if (rc != (
UINT)LX_SUCCESS) {
204 LX_NOR_FLASH* nor_flash = ctx;
208 for (uint32_t i = 0U; i < count; i++) {
212 if (rc != (
UINT)LX_SUCCESS) {
255 *block_count = usable;
272 out->
ctx = nor_flash;
static ra8_err_t internal_write_block(void *ctx, uint64_t lba, uint32_t count, const uint8_t *buf)
write_block trampoline: byte buffer into LevelX sector writes.
ra8_err_t lx_fs_backend_bind(LX_NOR_FLASH *nor_flash, ra8_fs_backend_t *out)
Implementation of lx_fs_backend_bind() – fills the three trampolines.
static ra8_err_t internal_get_capacity(void *ctx, uint64_t *block_count, uint32_t *block_size)
get_capacity trampoline: report the FAT-usable LevelX window.
static uint64_t internal_usable_sectors(const LX_NOR_FLASH *nor_flash)
FAT-usable 512-byte sector count of an open LevelX partition.
lx_fs_backend_geometry_t
Fixed LevelX <-> ra8_fs sector geometry.
@ k_lx_fsbe_sector_bytes
LevelX logical sector size in bytes.
@ k_lx_fsbe_erased_byte
NOR erased value for unmapped sectors.
static ra8_err_t internal_read_block(void *ctx, uint64_t lba, uint32_t count, uint8_t *buf)
read_block trampoline: LevelX sector reads into a byte buffer.
static ULONG s_lx_fsbe_bounce[LX_NOR_SECTOR_SIZE]
One-sector ULONG-aligned bounce buffer for LevelX transfers.
ra8_fs block-device backend over a LevelX wear-levelled NOR partition
static const char * s_tag
Logging / check tag.
Annotation-attribute framework macros for ra8-firmware.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
Validation and Error-Checking Macros for ra8-firmware.
#define RA8_CHECK_NULL_PTR(ptr, tag, message)
Reject nullptr pointer, returning k_ra8_err_null_ptr.
@ k_ra8_err_hw_init_failed
Hardware peripheral failed to initialise.
@ k_ra8_err_out_of_range
Sensor or peripheral output out of valid range.
@ k_ra8_err_not_initialized
Module not initialized – _init() not yet called successfully.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
void * memset(void *dst, int value, size_t n)
Fill memory with a constant byte value.
void * memcpy(void *dst, const void *src, size_t n)
Copy memory area between non-overlapping regions.
unsigned int UINT
ThreadX-compatible unsigned int (host stub).
unsigned long ULONG
ThreadX-compatible unsigned long (host stub).
Block-device interface that ra8_fs runs on top of.
ra8_err_t(* read_block)(void *ctx, uint64_t lba, uint32_t count, uint8_t *buf)
Read count consecutive blocks starting at lba.
ra8_err_t(* write_block)(void *ctx, uint64_t lba, uint32_t count, const uint8_t *buf)
Write count consecutive blocks starting at lba.
ra8_err_t(* erase_blocks)(void *ctx, uint64_t lba, uint64_t count)
OPTIONAL: bulk-erase count blocks at lba to all-zero bytes.
void * ctx
Caller-owned context passed back into the function pointers.
ra8_err_t(* get_capacity)(void *ctx, uint64_t *block_count, uint32_t *block_size)
Report the device size.