File System Component  Version 6.8
MDK 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-2016 ARM Germany GmbH. All rights reserved.
4  *------------------------------------------------------------------------------
5  * Name: rl_fs.h
6  * Purpose: File System API
7  * Rev.: V6.5.1
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 #define FS_DEVICE_SET_PASSWORD 0x01
39 #define FS_DEVICE_CLR_PASSWORD 0x02
40 #define FS_DEVICE_LOCK_UNLOCK 0x04
41 #define FS_DEVICE_ERASE 0x08
42 
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46 
48 typedef enum {
49  fsOK = 0,
65 } fsStatus;
66 
68 typedef enum _fsType {
69  fsTypeNone = 0,
75 } fsType;
76 
78 typedef enum _fsDevCtrlCode {
86 
88 typedef struct _fsMediaInfo {
89  uint32_t block_cnt;
90  uint16_t read_blen;
91  uint16_t write_blen;
92 } fsMediaInfo;
93 
95 typedef struct _fsIOC_Cache {
96  uint8_t *buffer;
97  uint32_t size;
98 } fsIOC_Cache;
99 
101 typedef struct _fsCID_Register {
102  uint32_t PSN;
103  uint16_t OID;
104  uint8_t MID;
105  uint8_t PRV;
106  uint16_t MDT;
107  uint8_t PNM[6];
109 
110 #if defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
111  #pragma clang diagnostic push
112  #pragma clang diagnostic ignored "-Wpadded"
113 #endif
114 
116 typedef struct {
117  uint8_t const *password;
118  uint8_t length;
119  uint8_t flags;
120 } fsLockUnlock;
121 
123 typedef struct _fsTime {
124  uint8_t hr;
125  uint8_t min;
126  uint8_t sec;
127  uint8_t day;
128  uint8_t mon;
129  uint16_t year;
130 } fsTime;
131 
133 typedef struct _fsFileInfo {
134  char name[256];
135  uint32_t size;
136  uint16_t fileID;
137  uint8_t attrib;
139 } fsFileInfo;
140 
142 typedef struct _fsDriveInfo {
144  uint64_t capacity;
145 } fsDriveInfo;
146 
147 #if defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
148  #pragma clang diagnostic pop
149 #endif
150 
151 // ==== System Routines ====
152 
160 extern fsStatus finit (const char *drive);
161 
168 extern fsStatus funinit (const char *drive);
169 
181 extern fsStatus fmount (const char *drive);
182 
189 extern fsStatus funmount (const char *drive);
190 
191 
192 // ==== File Maintenance Routines ====
193 
198 #ifdef MW_FILESYSTEM_FDELETE_LEGACY
199 extern fsStatus fdelete (const char *path);
200 #else
201 extern fsStatus fdelete (const char *path, const char *options);
202 #endif
203 
204 
214 extern fsStatus ffind (const char *pattern, fsFileInfo *info);
215 
220 extern fsStatus frename (const char *path, const char *newname);
221 
234 extern fsStatus fattrib (const char *path, const char *attr);
235 
236 
237 // ==== Directory Maintenance Routines ====
238 
244 extern fsStatus fpwd (const char *drive, char *buf, uint32_t len);
245 
249 extern fsStatus fchdir (const char *path);
250 
254 extern fsStatus fmkdir (const char *path);
255 
260 extern fsStatus frmdir (const char *path, const char *options);
261 
262 
263 // ==== Utility Routines ====
264 
268 extern fsStatus fchdrive (const char *drive);
269 
275 extern int64_t ffree (const char *drive);
276 
281 extern fsStatus fformat (const char *drive, const char *options);
282 
289 extern int32_t fanalyse (const char *drive);
290 
299 extern fsStatus fcheck (const char *drive);
300 
309 extern fsStatus fdefrag (const char *drive);
310 
319 extern fsStatus fmedia (const char *drive);
320 
328 extern fsStatus finfo (const char *drive, fsDriveInfo *info);
329 
343 extern fsStatus fvol (const char *drive, char *label, uint32_t *serial);
344 
345 
346 // ==== File Time Support Routines ====
347 
354 extern fsStatus fs_get_time (fsTime *time);
355 
356 
357 // ==== Media Support Routines ====
358 
363 extern int32_t fs_mc_read_cd (uint32_t drive_num);
364 
369 extern int32_t fs_mc_read_wp (uint32_t drive_num);
370 
378 extern int32_t fs_mc_spi_control_ss (uint32_t drive_num, uint32_t ss);
379 
384 extern fsLockUnlock *fs_mc_lock_unlock (uint32_t drive_num);
385 
386 
387 // ==== I/O Control Interface Routines ====
388 
394 extern int32_t fs_ioc_get_id (const char *drive);
395 
402 extern fsStatus fs_ioc_lock (int32_t drv_id);
403 
410 extern fsStatus fs_ioc_unlock (int32_t drv_id);
411 
420 extern fsStatus fs_ioc_get_cache (int32_t drv_id, fsIOC_Cache *cache_info);
421 
433 extern fsStatus fs_ioc_read_sector (int32_t drv_id, uint32_t sect, uint8_t *buf, uint32_t cnt);
434 
446 extern fsStatus fs_ioc_write_sector (int32_t drv_id, uint32_t sect, const uint8_t *buf, uint32_t cnt);
447 
457 extern fsStatus fs_ioc_read_info (int32_t drv_id, fsMediaInfo *info);
458 
464 extern fsStatus fs_ioc_device_ctrl (int32_t drv_id, fsDevCtrlCode code, void *p);
465 
466 #ifdef __cplusplus
467 }
468 #endif
469 
470 #endif /* __RL_FS_H */