VSF Documented
vsf_fatfs.h
Go to the documentation of this file.
1/*****************************************************************************
2 * Copyright(C)2009-2022 by VSF Team *
3 * *
4 * Licensed under the Apache License, Version 2.0 (the "License"); *
5 * you may not use this file except in compliance with the License. *
6 * You may obtain a copy of the License at *
7 * *
8 * http://www.apache.org/licenses/LICENSE-2.0 *
9 * *
10 * Unless required by applicable law or agreed to in writing, software *
11 * distributed under the License is distributed on an "AS IS" BASIS, *
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
13 * See the License for the specific language governing permissions and *
14 * limitations under the License. *
15 * *
16 ****************************************************************************/
17
18#ifndef __VSF_FATFS_H__
19#define __VSF_FATFS_H__
20
21/*============================ INCLUDES ======================================*/
22
23#include "../../vsf_fs_cfg.h"
24
25#if VSF_USE_FS == ENABLED && (VSF_FS_USE_FATFS == ENABLED || VSF_FS_USE_EXFATFS == ENABLED)
26
27#include "../malfs/vsf_malfs.h"
28
29#if defined(__VSF_FATFS_CLASS_IMPLEMENT)
30# undef __VSF_FATFS_CLASS_IMPLEMENT
31# define __VSF_CLASS_IMPLEMENT__
32#endif
33
34#include "utilities/ooc_class.h"
35
36#ifdef __cplusplus
37extern "C" {
38#endif
39
40/*============================ MACROS ========================================*/
41
42#define implement_fatfs_info(__block_size, __cache_num) \
43 implement(__vk_fatfs_info_t) \
44 __implement_malfs_cache(__block_size, __cache_num)
45
46#define init_fatfs_info_ex(__info, __block_size, __cache_num, __fatinfo) \
47 do { \
48 __fatinfo->block_size = __block_size; \
49 __fatinfo->cache.number = __cache_num; \
50 __fatinfo->cache.nodes = __info->__cache_nodes; \
51 } while (0)
52
53#define init_fatfs_info(__info, __block_size, __cache_num) \
54 .block_size = __block_size, \
55 .cache = { \
56 .number = __cache_num, \
57 .nodes = __info.__cache_nodes, \
58 },
59
60/*============================ MACROFIED FUNCTIONS ===========================*/
61/*============================ TYPES =========================================*/
62
65
66#if VSF_FS_USE_EXFATFS == ENABLED
68#else
70#endif
71
79
85
116
122
124 public_member(
125 implement(__vk_malfs_file_t)
126 )
127
128 private_member(
129 uint32_t first_cluster;
131 struct {
132 vk_fat_sector_type_t sector0;
133 vk_fat_sector_type_t sector1;
134 uint8_t entry_num;
135 uint8_t entry_offset_in_sector0;
136
137 // vital sector/entry_offset is the entry containing first_cluster/size
138 // for fat, should be the last entry
139 // for exfat, should be the stream entry
140 uint8_t vital_sector;
141 uint8_t vital_entry_offset;
142#if VSF_FS_USE_EXFATFS == ENABLED
143 // root 0/entry_offset is the entry for Critical Primary Directory Entries of exfat
144 uint8_t root_entry_offset;
145 uint8_t stream_flags;
146 uint64_t data_length;
147#endif
148 } dentry;
150};
151
152// memory layout:
153// |-----------------------|
154// | __vk_fatfs_info_t: |<-|
155// | |-------------------| | |
156// | | ... | | |
157// | |-------------------| | |
158// | ||__vk_malfs_info_t|| | |
159// | ||-----------------|| | |
160// | || total_cb ||-|--- if __vk_fatfs_info_t is dynamically allocated,
161// | ||-----------------|| | total_cb in __vk_malfs_info_t points to the __vk_fatfs_info_t.
162// |-----------------------| so in __vk_malfs_unmount, can free total_cb
163// | vk_malfs_cache_t[num] |
164// |-----------------------|
165// | cache_buffer[num] |
166// |-----------------------|
168 private_member(
169 vk_fatfs_file_t root;
171#if VSF_FS_USE_EXFATFS == ENABLED
172 char fat_volume_name[24];
173#else
174 char fat_volume_name[12];
175#endif
176
177 // fat parameters, will not change after mount
178#if VSF_FS_USE_EXFATFS == ENABLED
179 uint32_t bitmap_sector;
180 uint32_t bitmap_size;
181#endif
182 uint32_t root_sector;
183 uint32_t root_size;
184 uint32_t fat_sector;
185 uint32_t fat_size;
186 uint32_t data_sector;
187 uint32_t cluster_num;
188 uint16_t fsinfo_sector;
189 uint8_t sector_size_bits;
190 uint8_t cluster_size_bits;
191 uint8_t fat_num;
192 )
193
194 // vk_malfs_info_t must be the last in vk_fatfs_info_t
195 public_member(
196 implement(__vk_malfs_info_t)
197 )
198};
199
200/*============================ GLOBAL VARIABLES ==============================*/
201
202extern const vk_fs_op_t vk_fatfs_op;
203
204/*============================ PROTOTYPES ====================================*/
205
206extern bool vk_fatfs_is_lfn(char *name);
208
209#ifdef __cplusplus
210}
211#endif
212
213#endif // VSF_USE_FS && VSF_FS_USE_FATFS
214#endif // __VSF_FATFS_H__
Definition vsf_fatfs.h:167
Definition vsf_malfs.h:83
Definition vsf_malfs.h:98
Definition vsf_fatfs.h:123
Definition vsf_fs.h:92
#define vsf_dcl_class
Definition ooc_class.h:50
#define vsf_class(__name)
Definition ooc_class.h:52
short int16_t
Definition stdint.h:6
unsigned short uint16_t
Definition stdint.h:7
unsigned uint32_t
Definition stdint.h:9
unsigned long long uint64_t
Definition stdint.h:11
unsigned char uint8_t
Definition stdint.h:5
Definition vsf_fatfs.h:86
char * filename
Definition vsf_fatfs.h:88
uint8_t stream_flags
Definition vsf_fatfs.h:110
struct vk_fatfs_dentry_parser_t::@33::@36 exfat
uint8_t lfn
Definition vsf_fatfs.h:102
bool is_unicode
Definition vsf_fatfs.h:94
uint32_t zero_before_first_call
Definition vsf_fatfs.h:113
int16_t vital_entry_num
Definition vsf_fatfs.h:91
uint16_t node_parsed_num
Definition vsf_fatfs.h:90
int16_t entry_num
Definition vsf_fatfs.h:89
uint8_t namelen
Definition vsf_fatfs.h:106
struct vk_fatfs_dentry_parser_t::@33::@35 fat
uint8_t entry_num
Definition vsf_fatfs.h:108
uint8_t attr
Definition vsf_fatfs.h:95
uint64_t size
Definition vsf_fatfs.h:97
uint64_t data_length
Definition vsf_fatfs.h:98
uint8_t * entry
Definition vsf_fatfs.h:87
uint32_t first_cluster
Definition vsf_fatfs.h:96
int16_t root_entry_num
Definition vsf_fatfs.h:109
uint8_t namepos
Definition vsf_fatfs.h:107
Definition vsf_fatfs.h:117
uint32_t sector_offset_in_cluster
Definition vsf_fatfs.h:119
uint32_t cluster
Definition vsf_fatfs.h:118
uint32_t offset_in_sector
Definition vsf_fatfs.h:120
vk_av_control_type_t type
Definition vsf_audio.h:170
struct vk_fatfs_dentry_parser_t vk_fatfs_dentry_parser_t
struct vk_fatfs_file_pos_t vk_fatfs_file_pos_t
bool vk_fatfs_parse_dentry_fat(vk_fatfs_dentry_parser_t *parser)
Definition vsf_fatfs.c:855
bool vk_fatfs_is_lfn(char *name)
Definition vsf_fatfs.c:401
vk_fat_type_t
Definition vsf_fatfs.h:72
@ VSF_FAT_32
Definition vsf_fatfs.h:76
@ VSF_FAT_12
Definition vsf_fatfs.h:74
@ VSF_FAT_EX
Definition vsf_fatfs.h:77
@ VSF_FAT_NONE
Definition vsf_fatfs.h:73
@ VSF_FAT_16
Definition vsf_fatfs.h:75
uint64_t vk_fat_sector_type_t
Definition vsf_fatfs.h:67
const vk_fs_op_t vk_fatfs_op
vk_fat_file_attr_t
Definition vsf_fatfs.h:80
@ VSF_FAT_FILE_ATTR_SYSTEM
Definition vsf_fatfs.h:82
@ VSF_FAT_FILE_ATTR_ARCHIVE
Definition vsf_fatfs.h:83
@ VSF_FAT_FILE_ATTR_VOLUMID
Definition vsf_fatfs.h:81
@ VSF_FILE_ATTR_EXT
Definition vsf_fs_cfg.h:108
Generated from commit: vsfteam/vsf@c46986d