File System Component  Version 6.7
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.0
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 
111 typedef struct {
112  uint8_t const *password;
113  uint8_t length;
114  uint8_t flags;
115 } fsLockUnlock;
116 
118 typedef struct _fsTime {
119  uint8_t hr;
120  uint8_t min;
121  uint8_t sec;
122  uint8_t day;
123  uint8_t mon;
124  uint16_t year;
125 } fsTime;
126 
128 typedef struct _fsFileInfo {
129  char name[256];
130  uint32_t size;
131  uint16_t fileID;
132  uint8_t attrib;
134 } fsFileInfo;
135 
137 typedef struct _fsDriveInfo {
139  uint64_t capacity;
140 } fsDriveInfo;
141 
142 
143 // ==== System Routines ====
144 
152 extern fsStatus finit (const char *drive);
153 
160 extern fsStatus funinit (const char *drive);
161 
173 extern fsStatus fmount (const char *drive);
174 
181 extern fsStatus funmount (const char *drive);
182 
183 
184 // ==== File Maintenance Routines ====
185 
190 #ifdef MW_FILESYSTEM_FDELETE_LEGACY
191 extern fsStatus fdelete (const char *path);
192 #else
193 extern fsStatus fdelete (const char *path, const char *options);
194 #endif
195 
196 
206 extern fsStatus ffind (const char *pattern, fsFileInfo *info);
207 
212 extern fsStatus frename (const char *path, const char *newname);
213 
226 extern fsStatus fattrib (const char *path, const char *attr);
227 
228 
229 // ==== Directory Maintenance Routines ====
230 
236 extern fsStatus fpwd (const char *drive, char *buf, uint32_t len);
237 
241 extern fsStatus fchdir (const char *path);
242 
246 extern fsStatus fmkdir (const char *path);
247 
252 extern fsStatus frmdir (const char *path, const char *options);
253 
254 
255 // ==== Utility Routines ====
256 
260 extern fsStatus fchdrive (const char *drive);
261 
267 extern int64_t ffree (const char *drive);
268 
273 extern fsStatus fformat (const char *drive, const char *options);
274 
281 extern int32_t fanalyse (const char *drive);
282 
291 extern fsStatus fcheck (const char *drive);
292 
301 extern fsStatus fdefrag (const char *drive);
302 
311 extern fsStatus fmedia (const char *drive);
312 
320 extern fsStatus finfo (const char *drive, fsDriveInfo *info);
321 
335 extern fsStatus fvol (const char *drive, char *label, uint32_t *serial);
336 
337 
338 // ==== File Time Support Routines ====
339 
346 extern fsStatus fs_get_time (fsTime *time);
347 
348 
349 // ==== Media Support Routines ====
350 
355 extern int32_t fs_mc_read_cd (uint32_t drive_num);
356 
361 extern int32_t fs_mc_read_wp (uint32_t drive_num);
362 
370 extern int32_t fs_mc_spi_control_ss (uint32_t drive_num, uint32_t ss);
371 
376 extern fsLockUnlock *fs_mc_lock_unlock (uint32_t drive_num);
377 
378 
379 // ==== I/O Control Interface Routines ====
380 
386 extern int32_t fs_ioc_get_id (const char *drive);
387 
394 extern fsStatus fs_ioc_lock (int32_t drv_id);
395 
402 extern fsStatus fs_ioc_unlock (int32_t drv_id);
403 
412 extern fsStatus fs_ioc_get_cache (int32_t drv_id, fsIOC_Cache *cache_info);
413 
425 extern fsStatus fs_ioc_read_sector (int32_t drv_id, uint32_t sect, uint8_t *buf, uint32_t cnt);
426 
438 extern fsStatus fs_ioc_write_sector (int32_t drv_id, uint32_t sect, const uint8_t *buf, uint32_t cnt);
439 
449 extern fsStatus fs_ioc_read_info (int32_t drv_id, fsMediaInfo *info);
450 
456 extern fsStatus fs_ioc_device_ctrl (int32_t drv_id, fsDevCtrlCode code, void *p);
457 
458 #ifdef __cplusplus
459 }
460 #endif
461 
462 #endif /* __RL_FS_H */