ProtoCore v1.0.16
Deterministic, zero-heap network stack for embedded targets
Loading...
Searching...
No Matches
mnt_ram.h
Go to the documentation of this file.
1// ProtoCore v1.0.16 - Copyright (C) 2026 Douglas Quigg (dstroy0) <dquigg123@gmail.com>
2// SPDX-License-Identifier: AGPL-3.0-or-later
3
4#ifndef PROTOCORE_MNT_RAM_H
5#define PROTOCORE_MNT_RAM_H
6
7#include "protocore_config.h" // the entry point: protocore_types.h for the widths
8#include "server/storage/mnt/mnt.h" // the complete type a public struct below holds by value
9
11
12/**
13 * @file mnt_ram.h
14 * @brief The built-in RAM filesystem backend (PROTOCORE_ENABLE_MNT).
15 *
16 * A fixed pool of named in-BSS files and a fixed handle table: bounded, zero-heap, and
17 * host-identical, which is what lets the file-transfer servers run under a native test. It
18 * implements the @ref protocore_mnt_backend contract that server/storage/mnt registers, and it is
19 * one of several things that can - a board layer wraps a real fs::FS the same way.
20 *
21 * Directories are a flag on a name-table entry rather than a tree: the table already holds whole
22 * paths, so "what is in this directory" is a prefix scan of names that are already there. A tree
23 * would add nodes, links, and a second lifetime to maintain in order to answer a question the flat
24 * table already answers.
25 *
26 * The module publishes its vtable rather than mounting itself, so the mount stays one decision in
27 * one place:
28 *
29 * MntRam.backend(work);
30 * MntV.args.backend = MntRamV.backend;
31 * Mnt.mount(work);
32 *
33 * Pool dimensions are PROTOCORE_MNT_RAM_FILES, PROTOCORE_MNT_RAM_FILE_SIZE, PROTOCORE_MNT_MAX_OPEN
34 * and PROTOCORE_MNT_NAME_MAX in protocore_config.h.
35 *
36 * @author Douglas Quigg (dstroy0)
37 * @date 2026
38 */
39
40// PROTOCORE_MNT_RAM_BORROW - the bytes this module runs out of - is stated in protocore_config.h, which sums
41// it into its arena. Its size and its offset are each a static_assert, so a feature
42// combination that does not fit fails to compile rather than overrunning at run time.
43
44/** @brief Dispatch table. Addressed by offset, so the layout is asserted below. */
45typedef struct
46{
47 const protocore_mnt_backend *(*backend)(uint8_t *);
48 void (*format)(uint8_t *);
49} MntRamNs;
50PROTOCORE_NS_LAYOUT(MntRamNs, backend, format);
51
52/**
53 * @brief Publish the vtable, for the caller to mount.
54 * @param work PROTOCORE_MNT_RAM_BORROW bytes the caller took. Not held past the call.
55 * @return The const protocore_mnt_backend *.
56 */
58/**
59 * @brief Empty the pool and close every handle.
60 * @param work PROTOCORE_MNT_RAM_BORROW bytes the caller took. Not held past the call.
61 */
62void protocore_mnt_ram_format(uint8_t *work);
63
64/** @brief Module namespace. */
67
69
70#endif // PROTOCORE_MNT_RAM_H
The mount: which store is behind the filesystem, and the vtable it answers through.
void protocore_mnt_ram_format(uint8_t *work)
Empty the pool and close every handle.
const protocore_mnt_backend * protocore_mnt_ram_backend(uint8_t *work)
Publish the vtable, for the caller to mount.
PROTOCORE_NS MntRamNs MntRam PROTOCORE_UNUSED
Module namespace.
Definition mnt_ram.h:65
#define PROTOCORE_NS_LAYOUT(T,...)
Pin every dispatch slot of a table that is nothing but function pointers.
#define PROTOCORE_NS
Storage for a dispatch table. The const is load bearing.
Dispatch table. Addressed by offset, so the layout is asserted below.
Definition mnt_ram.h:46
const protocore_mnt_backend *(* backend)(uint8_t *)
Definition mnt_ram.h:47
A storage backend. Each open call returns a small handle (>= 0) or -1.
Definition mnt.h:88
#define PROTOCORE_BEGIN_DECLS
Give a header's declarations C linkage, so their symbol names carry no parameter types.
Definition types.h:96
#define PROTOCORE_END_DECLS
Definition types.h:97