35#ifndef SKIP_STATIC_ASSERTS
37 "fs_entry_t unexpected size");
89 if ((name == NULL) || (out == NULL) || (name[0] ==
'\0')) {
111 out->
slot = (uint8_t)slot;
125 if ((name == NULL) || (out == NULL) || (name[0] ==
'\0')) {
133 out->
slot = (uint8_t)slot;
147 if ((f == NULL) || (!f->
valid) || (data == NULL) || (len == 0u)) {
151 uint8_t slot = f->
slot;
161 (void)memcpy(&
fs_data[slot][current], data, len);
177 if ((f == NULL) || (!f->
valid) || (buf == NULL) || (len == 0u)) {
181 uint8_t slot = f->
slot;
187 if (offset >= file_size) {
191 uint16_t available = (uint16_t)(file_size - offset);
192 uint16_t to_read = (len < available) ? len : available;
194 (void)memcpy(buf, &
fs_data[slot][offset], to_read);
206 if ((name == NULL) || (name[0] ==
'\0')) {
228 if ((out == NULL) || (max == 0u)) {
233 for (uint8_t i = 0u; (i < (uint8_t)
FS_MAX_FILES) && (count < max); i++) {
279 __asm__
volatile (
"svc %0\n" : :
"I" (
SVC_FS_INIT));
301 :
"r" ((uint32_t)(uintptr_t)name),
"r" ((uint32_t)(uintptr_t)out),
327 :
"r" ((uint32_t)(uintptr_t)name),
"r" ((uint32_t)(uintptr_t)out),
355 :
"r" ((uint32_t)(uintptr_t)f),
"r" ((uint32_t)(uintptr_t)data),
384 :
"r" ((uint32_t)(uintptr_t)f),
"r" ((uint32_t)(uintptr_t)buf),
385 "r" ((uint32_t)len),
"r" ((uint32_t)offset),
387 :
"r0",
"r1",
"r2",
"r3"
389 return (uint16_t)result;
433 :
"r" ((uint32_t)(uintptr_t)out),
"r" ((uint32_t)max),
437 return (uint8_t)result;
bool __fs_write(fs_file_t *f, const uint8_t *data, uint16_t len)
Privileged implementation of fs_write().
bool fs_write(fs_file_t *f, const uint8_t *data, uint16_t len)
Append data to an open file via SVC gate.
bool fs_create(const char *name, fs_file_t *out)
Create a new file via SVC gate.
bool fs_delete(const char *name)
Delete a file by name via SVC gate.
void __fs_init(void)
Privileged implementation of fs_init().
static int16_t fs_free_slot(void)
Find first free slot, or -1 if full.
uint8_t __fs_list(fs_file_info_t *out, uint8_t max)
Privileged implementation of fs_list().
bool __fs_open(const char *name, fs_file_t *out)
Privileged implementation of fs_open().
uint16_t fs_read(fs_file_t *f, uint8_t *buf, uint16_t len, uint16_t offset)
Read bytes from an open file at a given offset via SVC gate.
bool __fs_create(const char *name, fs_file_t *out)
Privileged implementation of fs_create().
void fs_stats(fs_stats_t *out)
Return aggregate filesystem statistics via SVC gate.
uint8_t fs_list(fs_file_info_t *out, uint8_t max)
Enumerate all files via SVC gate.
static fs_entry_t fs_table[16]
bool fs_open(const char *name, fs_file_t *out)
Open an existing file by name via SVC gate.
void fs_init(void)
Clear all file table entries and zero the data store via SVC gate.
void __fs_stats(fs_stats_t *out)
Privileged implementation of fs_stats().
static uint8_t fs_data[16][2048]
static int16_t fs_find(const char *name)
Find slot index for name, or -1 if not found.
uint16_t __fs_read(fs_file_t *f, uint8_t *buf, uint16_t len, uint16_t offset)
Privileged implementation of fs_read().
bool __fs_delete(const char *name)
Privileged implementation of fs_delete().
ICARUS OS - Main API Header.
bool used
Slot is occupied.
char name[12]
Null-terminated file name.
uint16_t size
Bytes written so far.
Per-file metadata returned by fs_list().
uint16_t size
Current number of bytes written.
char name[12]
Null-terminated file name.
Opaque file handle — callers hold one of these per open file.
uint8_t slot
Index into internal file table (0-based).
bool valid
True if handle references a live file entry.
Aggregate filesystem statistics.
uint32_t free_bytes
Bytes available for new data.
uint32_t used_bytes
Bytes occupied by all file data.
uint32_t total_bytes
Total storage capacity in bytes.
uint8_t file_count
Number of files currently stored.
ICARUS Supervisor Call (SVC) Definitions.