Implement storedevs, prepare to port littlefs

This commit is contained in:
2025-08-16 12:34:36 +02:00
parent c936910199
commit 2b0566c56f
91 changed files with 54963 additions and 37 deletions

View File

@ -0,0 +1,44 @@
#ifndef STOREDEV_STOREDEV_H_
#define STOREDEV_STOREDEV_H_
#include <stdint.h>
#include <stddef.h>
#include "spinlock/spinlock.h"
#include "ramsd.h"
enum {
STOREDEV_RAMSD,
};
static const char *storedev_strings[] = {
"RAMSD",
};
typedef struct StoreDev {
struct StoreDev *next;
int32_t sdtype;
int32_t (*init)(struct StoreDev *sd, void *extra);
int32_t (*read)(struct StoreDev *sd, uint8_t *const buffer, size_t n, size_t off);
int32_t (*write)(struct StoreDev *sd, const uint8_t *const buffer, size_t n, size_t off);
int32_t (*cleanup)(struct StoreDev *sd);
union {
RamSd ramsd;
} sd;
SpinLock spinlock;
} StoreDev;
typedef struct {
StoreDev *head;
SpinLock spinlock;
} StoreDevList;
extern StoreDevList STOREDEV_LIST;
void storedev_init(void);
StoreDev *storedev_create(int32_t sdtype, void *extra);
int32_t storedev_delete(StoreDev *sd);
#endif // STOREDEV_STOREDEV_H_