File System Component  Version 6.3
MDK-Professional Middleware for Devices with Flash File System
 All Data Structures Files Functions Variables Enumerations Enumerator Macros Groups Pages
rl_fs.h
Go to the documentation of this file.
1 /*------------------------------------------------------------------------------
2  * MDK Middleware - Component ::File System
3  * Copyright (c) 2004-2015 ARM Germany GmbH. All rights reserved.
4  *------------------------------------------------------------------------------
5  * Name: rl_fs.h
6  * Purpose: File System API
7  * Rev.: V6.3
8  *----------------------------------------------------------------------------*/
9 
10 #ifndef __RL_FS_H
11 #define __RL_FS_H
12 
13 #include <stdint.h>
14 #include <stdbool.h>
15 
16 // ==== Enumeration, structures, defines ====
17 
19 #define FS_FAT_ATTR_READ_ONLY 0x01
20 #define FS_FAT_ATTR_HIDDEN 0x02
21 #define FS_FAT_ATTR_SYSTEM 0x04
22 #define FS_FAT_ATTR_VOLUME_ID 0x08
23 #define FS_FAT_ATTR_DIRECTORY 0x10
24 #define FS_FAT_ATTR_ARCHIVE 0x20
25 
26 
27 #define FS_MEDIA_INSERTED 0x01
28 #define FS_MEDIA_PROTECTED 0x02
29 #define FS_MEDIA_INITIALIZED 0x04
30 #define FS_MEDIA_NOCHKMEDIA 0x80
31 
32 
33 #define FS_CONTROL_MEDIA_INIT 0x00
34 #define FS_CONTROL_EMMC_SLEEP 0x01
35 #define FS_CONTROL_EMMC_AWAKE 0x02
36 
37 
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
43 typedef enum {
44  fsOK = 0,
60 } fsStatus;
61 
63 typedef enum _fsType {
64  fsTypeNone = 0,
70 } fsType;
71 
73 typedef enum _fsDevCtrlCode {
80 
82 typedef struct _fsMediaInfo {
83  uint32_t block_cnt;
84  uint16_t read_blen;
85  uint16_t write_blen;
86 } fsMediaInfo;
87 
89 typedef struct _fsIOC_Cache {
90  uint8_t *buffer;
91  uint32_t size;
92 } fsIOC_Cache;
93 
95 typedef struct _fsCID_Register {
96  uint32_t PSN;
97  uint16_t OID;
98  uint8_t MID;
99  uint8_t PRV;
100  uint16_t MDT;
101  uint8_t PNM[6];
103 
105 typedef struct _fsTime {
106  uint8_t hr;
107  uint8_t min;
108  uint8_t sec;
109  uint8_t day;
110  uint8_t mon;
111  uint16_t year;
112 } fsTime;
113 
115 typedef struct _fsFileInfo {
116  char name[256];
117  uint32_t size;
118  uint16_t fileID;
119  uint8_t attrib;
121 } fsFileInfo;
122 
124 typedef struct _fsDriveInfo {
126  uint64_t capacity;
127 } fsDriveInfo;
128 
129 
130 // ==== System Routines ====
131 
139 extern fsStatus finit (const char *drive);
140 
147 extern fsStatus funinit (const char *drive);
148 
160 extern fsStatus fmount (const char *drive);
161 
168 extern fsStatus funmount (const char *drive);
169 
170 
171 // ==== File Maintenance Routines ====
172 
177 #ifdef MW_FILESYSTEM_FDELETE_LEGACY
178 extern fsStatus fdelete (const char *path);
179 #else
180 extern fsStatus fdelete (const char *path, const char *options);
181 #endif
182 
183 
193 extern fsStatus ffind (const char *pattern, fsFileInfo *info);
194 
199 extern fsStatus frename (const char *path, const char *newname);
200 
213 extern fsStatus fattrib (const char *path, const char *attr);
214 
215 
216 // ==== Directory Maintenance Routines ====
217 
223 extern fsStatus fpwd (const char *drive, char *buf, uint32_t len);
224 
228 extern fsStatus fchdir (const char *path);
229 
233 extern fsStatus fmkdir (const char *path);
234 
239 extern fsStatus frmdir (const char *path, const char *options);
240 
241 
242 // ==== Utility Routines ====
243 
247 extern fsStatus fchdrive (const char *drive);
248 
254 extern int64_t ffree (const char *drive);
255 
260 extern fsStatus fformat (const char *drive, const char *options);
261 
268 extern int32_t fanalyse (const char *drive);
269 
278 extern fsStatus fcheck (const char *drive);
279 
288 extern fsStatus fdefrag (const char *drive);
289 
297 extern fsStatus fmedia (const char *drive);
298 
306 extern fsStatus finfo (const char *drive, fsDriveInfo *info);
307 
321 extern fsStatus fvol (const char *drive, char *label, uint32_t *serial);
322 
323 
324 // ==== File Time Support Routines ====
325 
332 extern fsStatus fs_get_time (fsTime *time);
333 
334 
335 // ==== Media Support Routines ====
336 
341 extern int32_t fs_mc_read_cd (uint32_t drive_num);
342 
347 extern int32_t fs_mc_read_wp (uint32_t drive_num);
348 
356 extern int32_t fs_mc_spi_control_ss (uint32_t drive_num, uint32_t ss);
357 
358 
359 // ==== I/O Control Interface Routines ====
360 
366 extern int32_t fs_ioc_get_id (const char *drive);
367 
374 extern fsStatus fs_ioc_lock (int32_t drv_id);
375 
382 extern fsStatus fs_ioc_unlock (int32_t drv_id);
383 
392 extern fsStatus fs_ioc_get_cache (int32_t drv_id, fsIOC_Cache *cache_info);
393 
405 extern fsStatus fs_ioc_read_sector (int32_t drv_id, uint32_t sect, uint8_t *buf, uint32_t cnt);
406 
418 extern fsStatus fs_ioc_write_sector (int32_t drv_id, uint32_t sect, const uint8_t *buf, uint32_t cnt);
419 
429 extern fsStatus fs_ioc_read_info (int32_t drv_id, fsMediaInfo *info);
430 
436 extern fsStatus fs_ioc_device_ctrl (int32_t drv_id, fsDevCtrlCode code, void *p);
437 
438 #ifdef __cplusplus
439 }
440 #endif
441 
442 #endif /* __RL_FS_H */