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 
61 #ifndef MTD_MAPPER_H
62 #define MTD_MAPPER_H
63 
64 #include <stdint.h>
65 #include <stdbool.h>
66 #include "mtd.h"
67 #include "mutex.h"
68 
69 #ifdef __cplusplus
70 extern "C" {
71 #endif
72 
77 #define MTD_PARENT_INIT(_parent) \
78 { \
79  .mtd = _parent, \
80  .lock = MUTEX_INIT, \
81  .init = false, \
82 }
83 
87 typedef struct {
90  bool init;
92 
96 typedef struct {
99  uint32_t sector;
101 
105 extern const mtd_desc_t mtd_mapper_driver;
106 
107 #ifdef __cplusplus
108 }
109 #endif
110 
111 #endif /* MTD_MAPPER_H */
112 
mtd_dev_t
MTD device descriptor.
Definition: mtd.h:58
mtd_mapper_parent_t
MTD mapper backing device context.
Definition: mtd_mapper.h:87
mtd_desc
MTD driver interface.
Definition: mtd.h:75
mtd_mapper_region_t::mtd
mtd_dev_t mtd
MTD context
Definition: mtd_mapper.h:97
mtd_mapper_parent_t::lock
mutex_t lock
Mutex for guarding the backing device access.
Definition: mtd_mapper.h:89
mtd_mapper_parent_t::mtd
mtd_dev_t * mtd
Parent MTD device.
Definition: mtd_mapper.h:88
mtd_mapper_parent_t::init
bool init
Initialization flag.
Definition: mtd_mapper.h:90
mutex.h
Mutex for thread synchronization.
mtd.h
mtd_mapper_region_t::sector
uint32_t sector
first sector of the region
Definition: mtd_mapper.h:99
mtd_mapper_region_t::parent
mtd_mapper_parent_t * parent
MTD mapper parent device
Definition: mtd_mapper.h:98
mtd_mapper_driver
const mtd_desc_t mtd_mapper_driver
Mapper MTD device operations table.
mtd_mapper_region_t
MTD mapped region.
Definition: mtd_mapper.h:96
mutex_t
Mutex structure.
Definition: mutex.h:120