ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
ra8_fs_fat_bytes_internal.h
Go to the documentation of this file.
1
24
25#pragma once
26
27#include <stdint.h>
28
29#include "ra8_attributes.h"
31
32/* =============================================================================
33 * The sector arena -- four fixed-role bounce buffers (#683)
34 * =============================================================================
35 *
36 * Sector buffers grew from 512 bytes to ::k_ra8_fs_sector_max (4 KiB) when the
37 * sector size became a runtime property, and a 4 KiB frame does not belong on
38 * a firmware stack budgeted in the low kilobytes. The library is serialised by
39 * contract (one lock, no recursion, no reentrancy), so every bounce buffer
40 * lives in a small static arena instead, addressed by ROLE. The roles encode
41 * the only nesting the call graph performs, so two live buffers can never
42 * alias:
43 *
44 * - WALK -- a directory/metadata sector held across a scan or a
45 * read-modify-write of a directory entry. Walk holders may call FAT-entry
46 * helpers (which use FAT/FAT2) and leaf I/O helpers (which use IO), and
47 * never each other while their sector is live.
48 * - FAT -- the sector holding a FAT entry (`priv_fat_get` / the setters).
49 * - FAT2 -- the following sector, live only while a FAT12 entry straddles.
50 * - IO -- leaf data/bitmap sector I/O: loaded, consumed/patched, written,
51 * dead before any other buffer user runs.
52 *
53 * A function taking a buffer must finish with it before calling anything that
54 * takes the same role -- the discipline every converted call site follows and
55 * the reviews on this module enforce.
56 */
57
78uint8_t* priv_sec_walk(void);
79
98uint8_t* priv_sec_fat(void);
99
118uint8_t* priv_sec_fat2(void);
119
138uint8_t* priv_sec_io(void);
139
162void priv_byte_fill(uint8_t* dst, uint8_t value, uint32_t n);
163
174extern const uint8_t k_zero_sector[k_ra8_fs_sector_max];
175
197uint16_t priv_rd16(const uint8_t* p);
198
219uint32_t priv_rd32(const uint8_t* p);
220
242uint64_t priv_rd64(const uint8_t* p);
243
266uint32_t priv_bps(const ra8_fs_mount_t* m);
267
290uint32_t priv_cluster_bytes(const ra8_fs_mount_t* m);
291
313uint32_t priv_dir_eps(const ra8_fs_mount_t* m);
314
333void priv_wr16(uint8_t* p, uint16_t v);
334
353void priv_wr32(uint8_t* p, uint32_t v);
354
375void priv_wr64(uint8_t* p, uint64_t v);
Annotation-attribute framework macros for ra8-firmware.
#define RA8_PRIV
Module-private helper: shared across TUs but only inside one library.
uint32_t priv_rd32(const uint8_t *p)
Decode a little-endian uint32_t from a byte buffer.
Definition ra8_fs_fat.c:48
uint16_t priv_rd16(const uint8_t *p)
Decode a little-endian uint16_t from a byte buffer.
Definition ra8_fs_fat.c:42
void priv_wr64(uint8_t *p, uint64_t v)
Encode a uint64_t into a byte buffer, little-endian.
Definition ra8_fs_fat.c:77
void priv_byte_fill(uint8_t *dst, uint8_t value, uint32_t n)
Fill n bytes of dst with value.
Definition ra8_fs_fat.c:102
uint32_t priv_dir_eps(const ra8_fs_mount_t *m)
Directory entries per sector on one mounted volume.
Definition ra8_fs_fat.c:96
uint32_t priv_bps(const ra8_fs_mount_t *m)
One mounted volume's sector size in bytes.
Definition ra8_fs_fat.c:84
uint8_t * priv_sec_fat2(void)
The FAT2-role sector buffer (the FAT12 straddle's second sector).
void priv_wr32(uint8_t *p, uint32_t v)
Encode a little-endian uint32_t into a byte buffer.
Definition ra8_fs_fat.c:68
uint8_t * priv_sec_io(void)
The IO-role sector buffer (leaf data / bitmap sector transfers).
uint8_t * priv_sec_walk(void)
The WALK-role sector buffer (directory scans and entry RMW).
const uint8_t k_zero_sector[k_ra8_fs_sector_max]
One whole sector of zero bytes, in read-only storage.
uint64_t priv_rd64(const uint8_t *p)
Decode a little-endian uint64_t from a byte buffer.
Definition ra8_fs_fat.c:55
uint8_t * priv_sec_fat(void)
The FAT-role sector buffer (priv_fat_get and the FAT setters).
uint32_t priv_cluster_bytes(const ra8_fs_mount_t *m)
One mounted volume's cluster size in bytes.
Definition ra8_fs_fat.c:90
void priv_wr16(uint8_t *p, uint16_t v)
Encode a little-endian uint16_t into a byte buffer.
Definition ra8_fs_fat.c:61
Cross-TU on-disk-layout enums and typedefs for the FAT/exFAT adapter.
@ k_ra8_fs_sector_max
Largest supported sector size (4Kn).
Cached parse of one mounted FAT volume.