ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
ra8_fs_fat_protos_a_internal.h
Go to the documentation of this file.
1
20
21#pragma once
22
23#include "ra8_attributes.h"
25
26/* ===========================================================================
27 * Cross-TU helper prototypes. Each is defined `static`-free in exactly one
28 * FAT/exFAT translation unit and called from at least one other.
29 * ===========================================================================
30 */
31
57void priv_83_to_str(const uint8_t* in11, uint8_t ntres, char* out13);
58
92ra8_err_t priv_alloc_cluster(const ra8_fs_mount_t* m, uint32_t* out_cluster);
93
118ra8_err_t priv_alloc_eoc_cluster(const ra8_fs_mount_t* m, uint32_t* out_c);
119
140
157char priv_ascii_upper(char c);
158
180void priv_byte_copy(uint8_t* dst, const uint8_t* src, uint32_t n);
181
205uint8_t priv_byte_equal(const uint8_t* a, const uint8_t* b, uint32_t n);
206
242RA8_EXPECTS_LOCK("ra8_fs_lock")
244
266uint64_t priv_cluster_to_lba(const ra8_fs_mount_t* m, uint32_t cluster);
267
298 const dir_loc_t* loc,
299 const uint8_t* name83,
300 uint64_t* out_lba,
301 uint32_t* out_entry_off,
302 uint8_t out_entry[k_ra8_fs_dir_entry_bytes]);
303
340 const dir_loc_t* loc,
341 const char* want,
342 uint64_t* out_lba,
343 uint32_t* out_entry_off,
344 uint8_t out_entry[k_ra8_fs_dir_entry_bytes]);
345
368void priv_dir_walk_init_loc(const ra8_fs_mount_t* m, const dir_loc_t* loc, dir_walk_t* w);
369
396ra8_err_t priv_dir_walk_next_sector(const ra8_fs_mount_t* m, dir_walk_t* w, uint8_t* out_eod);
397
419uint32_t priv_entry_first_cluster(const uint8_t* entry);
420
441void priv_entry_set_cluster_size(uint8_t* entry, uint32_t cluster, uint32_t size);
465uint32_t priv_eoc_write(const ra8_fs_mount_t* m);
466
488priv_exfat_bmp_switch(const ra8_fs_mount_t* m, uint64_t lba, uint64_t* loaded, uint8_t* sec);
489
511uint32_t priv_exfat_csum32(uint32_t cs, const uint8_t* buf, uint32_t len);
512
547 const exfat_dir_t* dir,
548 const char* path,
549 uint8_t* out_strm,
550 uint8_t* out_attr);
551
572ra8_err_t priv_exfat_find_bitmap(const ra8_fs_mount_t* m, uint32_t* out_clus, uint32_t* out_len);
573
614 uint64_t total_sectors,
615 uint32_t bps,
616 const char* label);
617
643 const exfat_dir_t* dir,
645 void* ctx);
664 exfat_cursor_t* cur,
665 ra8_fs_dirent_t* out,
666 bool* out_entry);
694uint8_t
695priv_exfat_name_chunk_eq(const uint8_t* entry, const uint16_t* name, uint32_t pos, uint32_t nlen);
696
721uint16_t priv_exfat_name_hash(const uint16_t* name, uint32_t nlen);
722
750 const char* path,
751 uint16_t* out,
752 uint32_t* out_units);
753
781 const char* name,
782 uint16_t* out,
783 uint32_t* out_units,
784 ra8_err_t too_long);
785
808
836 const char* path,
837 ra8_fs_mode_t mode,
838 ra8_fs_file_t** out_file);
839
873ra8_err_t priv_exfat_rename(const ra8_fs_mount_t* m, const char* old_path, const char* new_path);
874
891uint16_t priv_exfat_set_checksum(const uint8_t* set, uint32_t bytes);
892
917ra8_err_t priv_exfat_unlink(const ra8_fs_mount_t* m, const char* path);
918
948uint16_t priv_exfat_upcase_unit(uint16_t unit);
949
968uint32_t priv_exfat_upcase_checksum(void);
969
Annotation-attribute framework macros for ra8-firmware.
#define RA8_PRIV
Module-private helper: shared across TUs but only inside one library.
#define RA8_EXPECTS_LOCK(name)
The function expects the named thread/IRQ lock to be held on entry.
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Definition ra8_err.h:546
uint64_t priv_cluster_to_lba(const ra8_fs_mount_t *m, uint32_t cluster)
Convert a cluster number into its first data-region LBA.
Definition ra8_fs_fat.c:541
uint32_t priv_eoc_write(const ra8_fs_mount_t *m)
End-of-chain value to write for this FAT type.
Definition ra8_fs_fat.c:526
uint32_t priv_exfat_csum32(uint32_t cs, const uint8_t *buf, uint32_t len)
exFAT 32-bit rotate-right-add checksum (boot region + up-case table).
ra8_err_t priv_exfat_format(const ra8_fs_backend_t *backend, uint64_t total_sectors, uint32_t bps, const char *label)
Format the backend as a PC-standard partitioned exFAT volume (#102).
ra8_err_t priv_exfat_listdir(const ra8_fs_mount_t *m, const exfat_dir_t *dir, ra8_fs_listdir_cb_t cb, void *ctx)
Enumerate ONE directory of an exFAT volume.
ra8_err_t priv_exfat_unlink(const ra8_fs_mount_t *m, const char *path)
Delete a file on an exFAT volume, at any depth.
ra8_err_t priv_exfat_dir_next(const ra8_fs_mount_t *m, exfat_cursor_t *cur, ra8_fs_dirent_t *out, bool *out_entry)
Copy the next visible exFAT directory entry from an existing cursor.
ra8_err_t priv_exfat_rename(const ra8_fs_mount_t *m, const char *old_path, const char *new_path)
Rename a root-level file on an exFAT volume, at any storable length.
ra8_err_t priv_exfat_name_to_units(const ra8_fs_mount_t *m, const char *path, uint16_t *out, uint32_t *out_units)
Convert a caller's exFAT name to code units, refusing what will not fold.
ra8_err_t priv_exfat_open(ra8_fs_mount_t *handle, const char *path, ra8_fs_mode_t mode, ra8_fs_file_t **out_file)
Open a file (read-only) on a mounted exFAT volume.
ra8_err_t priv_exfat_next_entry(const ra8_fs_mount_t *m, exfat_cursor_t *cur, uint8_t *out)
Fetch the next 32-byte directory entry, following the cluster chain.
uint8_t priv_exfat_name_chunk_eq(const uint8_t *entry, const uint16_t *name, uint32_t pos, uint32_t nlen)
Compare one file-name entry's 15 UTF-16 units against a needle.
void priv_exfat_upcase_verify(ra8_fs_mount_t *m)
Decide whether this build's fold matches the mounted volume's table.
ra8_err_t priv_exfat_needle_units(const ra8_fs_mount_t *m, const char *name, uint16_t *out, uint32_t *out_units, ra8_err_t too_long)
Convert a leaf name to code units, mapping over-long to too_long.
ra8_err_t priv_exfat_find(const ra8_fs_mount_t *m, const exfat_dir_t *dir, const char *path, uint8_t *out_strm, uint8_t *out_attr)
Find a name in ONE exFAT directory.
uint16_t priv_exfat_upcase_unit(uint16_t unit)
Fold a UTF-16 code unit through the canonical exFAT up-case table.
uint32_t priv_exfat_upcase_checksum(void)
Rotate-add checksum of the up-case table this build embeds.
uint16_t priv_exfat_set_checksum(const uint8_t *set, uint32_t bytes)
Compute the SetChecksum over a built directory entry set.
uint16_t priv_exfat_name_hash(const uint16_t *name, uint32_t nlen)
Compute the exFAT NameHash for a name in UTF-16 code units.
ra8_err_t priv_exfat_bmp_switch(const ra8_fs_mount_t *m, uint64_t lba, uint64_t *loaded, uint8_t *sec)
Flush the cached bitmap sector and load lba if it changed.
ra8_err_t priv_exfat_find_bitmap(const ra8_fs_mount_t *m, uint32_t *out_clus, uint32_t *out_len)
Locate the allocation-bitmap entry in the exFAT root directory.
ra8_err_t priv_close_locked(ra8_fs_file_t *file)
Close an open file – the guarded body of ra8_fs_close().
uint32_t priv_entry_first_cluster(const uint8_t *entry)
Read the first cluster from a 32-byte directory entry.
void priv_entry_set_cluster_size(uint8_t *entry, uint32_t cluster, uint32_t size)
Patch first-cluster + size back into a 32-byte directory entry.
ra8_err_t priv_dir_find_long(const ra8_fs_mount_t *m, const dir_loc_t *loc, const char *want, uint64_t *out_lba, uint32_t *out_entry_off, uint8_t out_entry[k_ra8_fs_dir_entry_bytes])
Find a directory entry by its VFAT long name (case-insensitive).
void priv_dir_walk_init_loc(const ra8_fs_mount_t *m, const dir_loc_t *loc, dir_walk_t *w)
Initialise a directory walker for an arbitrary directory location.
ra8_err_t priv_dir_find(const ra8_fs_mount_t *m, const dir_loc_t *loc, const uint8_t *name83, uint64_t *out_lba, uint32_t *out_entry_off, uint8_t out_entry[k_ra8_fs_dir_entry_bytes])
Find a directory entry by 8.3 name within a given directory.
ra8_err_t priv_dir_walk_next_sector(const ra8_fs_mount_t *m, dir_walk_t *w, uint8_t *out_eod)
Advance the walker to the next sector.
ra8_fs_file_t * priv_alloc_file_slot(void)
Allocate a free entry from the file table; returns NULL if full.
uint8_t priv_byte_equal(const uint8_t *a, const uint8_t *b, uint32_t n)
Compare two byte buffers for equality (length n).
Definition ra8_fs_fat.c:118
ra8_err_t priv_alloc_cluster(const ra8_fs_mount_t *m, uint32_t *out_cluster)
Free-cluster scan from the next-free hint, wrapping exactly once.
Definition ra8_fs_fat.c:591
ra8_err_t priv_alloc_eoc_cluster(const ra8_fs_mount_t *m, uint32_t *out_c)
Allocate a fresh cluster, mark it EOC, and return its number.
char priv_ascii_upper(char c)
Uppercase an ASCII character (others returned unchanged).
void priv_byte_copy(uint8_t *dst, const uint8_t *src, uint32_t n)
Length-checked byte copy used in place of memcpy().
Definition ra8_fs_fat.c:110
void priv_83_to_str(const uint8_t *in11, uint8_t ntres, char *out13)
Unpack on-disk 11-byte 8.3 name into NUL-terminated "NAME.EXT".
Cross-TU on-disk-layout enums and typedefs for the FAT/exFAT adapter.
ra8_fs_mode_t
File-open modes accepted by ra8_fs_open().
void(* ra8_fs_listdir_cb_t)(const char *name, uint8_t attr, uint64_t size, void *ctx)
Callback invoked once per directory entry by ra8_fs_listdir().
@ k_ra8_fs_dir_entry_bytes
MS FAT spec sec 6 "Directory Entry".
Identifies the directory a lookup/scan should operate in.
Internal cursor used by the directory iterator.
Linear cursor over a directory's 32-byte entries.
Identifies the exFAT directory a lookup, scan or link operates in.
Block-device interface that ra8_fs runs on top of.
Stable directory-entry value copied by ra8_fs_dir_next.
Open-file state.
Cached parse of one mounted FAT volume.