mtd_mapper.h
1 /*
2  * Copyright (C) 2020 Koen Zandberg <koen@bergzand.net>
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 
62 #ifndef MTD_MAPPER_H
63 #define MTD_MAPPER_H
64 
65 #include <stdint.h>
66 #include <stdbool.h>
67 #include "mtd.h"
68 #include "mutex.h"
69 
70 #ifdef __cplusplus
71 extern "C" {
72 #endif
73 
78 #define MTD_PARENT_INIT(_parent) \
79 { \
80  .mtd = _parent, \
81  .lock = MUTEX_INIT, \
82  .init = false, \
83 }
84 
88 typedef struct {
91  bool init;
93 
97 typedef struct {
100  uint32_t sector;
102 
106 extern const mtd_desc_t mtd_mapper_driver;
107 
108 #ifdef __cplusplus
109 }
110 #endif
111 
112 #endif /* MTD_MAPPER_H */
const mtd_desc_t mtd_mapper_driver
Mapper MTD device operations table.
Mutex for thread synchronization.
MTD driver interface.
Definition: mtd.h:204
MTD device descriptor.
Definition: mtd.h:112
MTD mapper backing device context.
Definition: mtd_mapper.h:88
mutex_t lock
Mutex for guarding the backing device access.
Definition: mtd_mapper.h:90
mtd_dev_t * mtd
Parent MTD device.
Definition: mtd_mapper.h:89
bool init
Initialization flag.
Definition: mtd_mapper.h:91
MTD mapped region.
Definition: mtd_mapper.h:97
mtd_mapper_parent_t * parent
MTD mapper parent device
Definition: mtd_mapper.h:99
mtd_dev_t mtd
MTD context
Definition: mtd_mapper.h:98
uint32_t sector
first sector of the region
Definition: mtd_mapper.h:100
Mutex structure.
Definition: mutex.h:146