Loading...
Searching...
No Matches
mtd_emulated.h
1/*
2 * Copyright (C) 2023 Gunar Schorcht
3 *
4 * This file is subject to the terms and conditions of the GNU Lesser
5 * General Public License v2.1. See the file LICENSE in the top level
6 * directory for more details.
7 */
8
19#ifndef MTD_EMULATED_H
20#define MTD_EMULATED_H
21
22#include <stdbool.h>
23
24#include "board.h"
25#include "macros/utils.h"
26#include "mtd.h"
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
50#define MTD_EMULATED_DEV(n, sc, pps, ps) \
51 uint8_t _mtd_emulated_memory ## n[sc * pps * ps]; \
52 \
53 mtd_emulated_t mtd_emulated_dev ## n = { \
54 .base = { \
55 .driver = &_mtd_emulated_driver, \
56 .sector_count = sc, \
57 .pages_per_sector = pps, \
58 .page_size = ps, \
59 .write_size = 1, \
60 }, \
61 .size = sc * pps * ps, \
62 .memory = _mtd_emulated_memory ## n, \
63 .init_done = false, \
64 }; \
65 \
66 XFA_CONST(mtd_dev_t, mtd_dev_xfa, 99) CONCAT(*mtd_emulated, n) = (mtd_dev_t *)&mtd_emulated_dev ## n
67
68#if MODULE_VFS_AUTO_MOUNT || DOXYGEN
83#define MTD_EMULATED_DEV_FS(n, m, fs) \
84 VFS_AUTO_MOUNT(fs, VFS_MTD(mtd_emulated_dev ## n), "/mtde" # n, m)
85
86#endif /* MODULE_VFS || DOXYGEN */
87
91typedef struct {
93 size_t size;
94 uint8_t *memory;
95 bool init_done;
97
102
103#ifdef __cplusplus
104}
105#endif
106
107#endif /* MTD_EMULATED_H */
Various helper macros.
const mtd_desc_t _mtd_emulated_driver
Emulated MTD device operations table for mtd.
MTD driver interface.
Definition mtd.h:204
MTD device descriptor.
Definition mtd.h:112
Device descriptor for a MTD device that is emulated in RAM.
bool init_done
indicates whether initialization is already done
mtd_dev_t base
inherit from mtd_dev_t object
size_t size
total size of the MTD device in bytes
uint8_t * memory
RAM that is used for the emulated MTD device.