Files
littlefs/bd/lfs3_rambd.h
T
Christopher Haster 7b330d67eb Renamed config -> cfg
Note this includes both the lfs3_config -> lfs3_cfg structs as well as
the LFS3_CONFIG -> LFS3_CFG include define:

- LFS3_CONFIG -> LFS3_CFG
- struct lfs3_config -> struct lfs3_cfg
- struct lfs3_file_config -> struct lfs3_file_cfg
- struct lfs3_*bd_config -> struct lfs3_*bd_cfg
- cfg -> cfg

We were already using cfg as the variable name everywhere. The fact that
these names were different was an inconsistency that should be fixed
since we're committing to an API break.

LFS3_CFG is already out-of-date from upstream, and there's plans for a
config rework, but I figured I'd go ahead and change it as well to lower
the chances it gets overlooked.

---

Note this does _not_ affect LFS3_TAG_CONFIG. Having the on-disk vs
driver-level config take slightly different names is not a bad thing.
2025-07-18 18:29:41 -05:00

66 lines
1.6 KiB
C

/*
* Block device emulated in RAM
*
* Copyright (c) 2022, The littlefs authors.
* Copyright (c) 2017, Arm Limited. All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef LFS3_RAMBD_H
#define LFS3_RAMBD_H
#include "lfs3.h"
#include "lfs3_util.h"
// Block device specific tracing
#ifndef LFS3_RAMBD_TRACE
#ifdef LFS3_RAMBD_YES_TRACE
#define LFS3_RAMBD_TRACE(...) LFS3_TRACE(__VA_ARGS__)
#else
#define LFS3_RAMBD_TRACE(...)
#endif
#endif
// rambd config (optional)
struct lfs3_rambd_cfg {
// Optional statically allocated buffer for the block device.
void *buffer;
};
// rambd state
typedef struct lfs3_rambd {
uint8_t *buffer;
const struct lfs3_rambd_cfg *cfg;
} lfs3_rambd_t;
// Create a RAM block device using the geometry in lfs3_cfg
int lfs3_rambd_create(const struct lfs3_cfg *cfg);
int lfs3_rambd_createcfg(const struct lfs3_cfg *cfg,
const struct lfs3_rambd_cfg *bdcfg);
// Clean up memory associated with block device
int lfs3_rambd_destroy(const struct lfs3_cfg *cfg);
// Read a block
int lfs3_rambd_read(const struct lfs3_cfg *cfg, lfs3_block_t block,
lfs3_off_t off, void *buffer, lfs3_size_t size);
// Program a block
//
// The block must have previously been erased.
int lfs3_rambd_prog(const struct lfs3_cfg *cfg, lfs3_block_t block,
lfs3_off_t off, const void *buffer, lfs3_size_t size);
// Erase a block
//
// A block must be erased before being programmed. The
// state of an erased block is undefined.
int lfs3_rambd_erase(const struct lfs3_cfg *cfg, lfs3_block_t block);
// Sync the block device
int lfs3_rambd_sync(const struct lfs3_cfg *cfg);
#endif