source: trunk/kernel/fs/fatfs.h @ 662

Last change on this file since 662 was 657, checked in by alain, 5 years ago

Introduce remote_buf.c/.h & socket.c/.h files.
Update dev_nic.c/.h files.

File size: 29.5 KB
Line 
1/*
2 * fatfs.h - FATFS file system API definition.
3 *
4 * Author    Alain Greiner (2016,2017,2018,2019,2020)
5 *
6 * Copyright (c) UPMC Sorbonne Universites
7 *
8 * This file is part of ALMOS-MKH.
9 *
10 * ALMOS-MKH is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; version 2.0 of the License.
13 *
14 * ALMOS-MKH is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with ALMOS-MKH; if not, write to the Free Software Foundation,
21 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23
24#ifndef _FATFS_H_
25#define _FATFS_H_
26
27#include <hal_kernel_types.h>
28#include <remote_rwlock.h>
29#include <vfs.h>
30#include <dev_ioc.h>
31
32
33/******************************************************************************************
34 * The FATFS File System implements a FAT32 read/write file system.
35 *
36 * The FATFS specific extensions to the generic VFS are the following:
37 * 1) The vfs_ctx_t "extend" field contains a local pointer on the local
38 *    fatfs_ctx_t structure.
39 *
40 * 2) The vfs_inode_t "extend" contains, for each inode,
41 *    the first FATFS cluster_id (after cast to intptr).
42 *
43 * 3) The vfs_dentry_t "extend" field contains a local pointer on the local
44 *    FATFS directory entry (32 bytes) in the directory mapper.
45 *
46 * In the FAT32 File System, the File Allocation Table is is actually an array
47 * of uint32_t slots. Each slot in this array contains the index (called cluster_id)
48 * of another slot in this array, to form one linked list for each file stored on
49 * device in the FAT32 File System. This index in the FAT array is also the index of
50 * the FATFS cluster on the device. One FATFS cluster is supposed to contain one PPM page.
51 * For a given file, the entry point in the FAT is the cluster_id of the FATFS cluster
52 * containing the first page of the file, but it can be any cluster_id already allocated
53 * to the file.
54 *****************************************************************************************/
55 
56/*************** Partition Boot Sector Format **********************************/
57//                                     offset |  length
58#define BS_JMPBOOT                          0 ,  3
59#define BS_OEMNAME                          3 ,  8
60#define BPB_BYTSPERSEC                     11 ,  2
61#define BPB_SECPERCLUS                     13 ,  1
62#define BPB_RSVDSECCNT                     14 ,  2
63#define BPB_NUMFATS                        16 ,  1
64#define BPB_ROOTENTCNT                     17 ,  2
65#define BPB_TOTSEC16                       19 ,  2
66#define BPB_MEDIA                          21 ,  1
67#define BPB_FATSZ16                        22 ,  2
68#define BPB_SECPERTRK                      24 ,  2
69#define BPB_NUMHEADS                       26 ,  2
70#define BPB_HIDDSEC                        28 ,  4
71#define BPB_TOTSEC32                       32 ,  4
72#define BPB_PARTITION_TABLE               446 , 64
73
74// FAT 32
75#define BPB_FAT32_FATSZ32                  36 ,  4
76#define BPB_FAT32_EXTFLAGS                 40 ,  2
77#define BPB_FAT32_FSVER                    42 ,  2
78#define BPB_FAT32_ROOTCLUS                 44 ,  4
79#define BPB_FAT32_FSINFO                   48 ,  2
80#define BPB_FAT32_BKBOOTSEC                50 ,  2
81#define BS_FAT32_DRVNUM                    64 ,  1
82#define BS_FAT32_BOOTSIG                   66 ,  1
83#define BS_FAT32_VOLID                     67 ,  4
84#define BS_FAT32_VOLLAB                    71 , 11
85#define BS_FAT32_FILSYSTYPE                82 ,  8
86
87// Partitions
88#define FIRST_PARTITION_ACTIVE            446 ,  8
89#define FIRST_PARTITION_BEGIN_LBA         454 ,  4
90#define FIRST_PARTITION_SIZE              458 ,  4
91#define SECOND_PARTITION_ACTIVE           462 ,  8
92#define SECOND_PARTITION_BEGIN_LBA        470 ,  4
93#define SECOND_PARTITION_SIZE             474 ,  4
94#define THIRD_PARTITION_ACTIVE            478 ,  8
95#define THIRD_PARTITION_BEGIN_LBA         486 ,  4
96#define THIRD_PARTITION_SIZE              490 ,  4
97#define FOURTH_PARTITION_ACTIVE           494 ,  8
98#define FOURTH_PARTITION_BEGIN_LBA        502 ,  4
99#define FOURTH_PARTITION_SIZE             506 ,  4   
100/*******************************************************************************/
101
102#define MBR_SIGNATURE_POSITION            510 , 2
103#define MBR_SIGNATURE_VALUE               0xAA55 
104
105/************** FAT_FS_INFO SECTOR  ********************************************/
106#define FS_SIGNATURE_VALUE_1              0x52526141
107#define FS_SIGNATURE_VALUE_2              0x72724161
108#define FS_SIGNATURE_VALUE_3              0x000055AA 
109#define FS_SIGNATURE_POSITION_1           0   , 4 
110#define FS_SIGNATURE_POSITION_2           484 , 4
111#define FS_SIGNATURE_POSITION_3           508 , 4 
112#define FS_FREE_CLUSTERS                  488 , 4
113#define FS_FREE_CLUSTER_HINT              492 , 4
114/*******************************************************************************/
115
116#define DIR_ENTRY_SIZE          32
117                   
118#define NAME_MAX_SIZE           31
119
120/******* SFN Directory Entry Structure (32 bytes) ******************************/
121//                            offset | length
122#define DIR_NAME                   0 , 11   // dir_entry name
123#define DIR_ATTR                  11 ,  1   // attributes
124#define DIR_NTRES                 12 ,  1   // reserved for the OS       
125#define DIR_CRT_TIMES_TENTH       13 ,  1
126#define DIR_FST_CLUS_HI           20 ,  2   // cluster index 16 MSB bits
127#define DIR_WRT_TIME              22 ,  2   // time of last write
128#define DIR_WRT_DATE              24 ,  2   // date of last write
129#define DIR_FST_CLUS_LO           26 ,  2   // cluster index 16 LSB bit
130#define DIR_FILE_SIZE             28 ,  4   // dir_entry size (up to 4 Gbytes)
131/*******************************************************************************/
132
133/******* LFN Directory Entry Structure  (32 bytes) *****************************/
134//                            offset | length
135#define LDIR_ORD                   0 ,  1   // Sequence number (from 0x01 to 0x0f)   
136#define LDIR_NAME_1                1 , 10   // name broken into 3 parts
137#define LDIR_ATTR                 11 ,  1   // attributes (must be 0x0F)
138#define LDIR_TYPE                 12 ,  1   // directory type (must be 0x00)
139#define LDIR_CHKSUM               13 ,  1   // checksum of name in short dir 
140#define LDIR_NAME_2               14 , 12
141#define LDIR_RSVD                 26 ,  2   // artifact of previous fat (must be 0)
142#define LDIR_NAME_3               28 ,  4   
143/*******************************************************************************/
144
145/***********************  DIR_ATTR values  (attributes) ************************/
146#define ATTR_READ_ONLY            0x01
147#define ATTR_HIDDEN               0x02
148#define ATTR_SYSTEM               0x04
149#define ATTR_VOLUME_ID            0x08
150#define ATTR_DIRECTORY            0x10
151#define ATTR_ARCHIVE              0x20
152#define ATTR_LONG_NAME_MASK       0x0f      // READ_ONLY|HIDDEN|SYSTEM|VOLUME_ID
153/*******************************************************************************/
154
155/********************* DIR_ORD special values **********************************/
156#define FREE_ENTRY                0xE5     // this entry is free in the directory
157#define NO_MORE_ENTRY             0x00     // no more entry in the directory
158/*******************************************************************************/
159
160/******************** CLuster Index Special Values *****************************/
161#define FREE_CLUSTER              0x00000000
162#define RESERVED_CLUSTER          0x00000001
163#define BAD_CLUSTER               0x0FFFFFF7
164#define END_OF_CHAIN_CLUSTER_MIN  0x0ffffff8
165#define END_OF_CHAIN_CLUSTER_MAX  0x0fffffff
166/*******************************************************************************/
167
168/****  Forward declarations  ****/
169
170struct mapper_s;
171struct page_s;
172struct vfs_ctx_s;
173struct vfs_inode_s;
174struct vfs_dentry_s;
175
176/*****************************************************************************************
177 * This structure defines a FATFS specific context extension to the VFS context.
178 * This fatfs context is replicated in all clusters.
179 * It contains read-only informations such as the total number of sectors in FAT region,
180 * the number of bytes per sector, the number of sectors per cluster, the lba of FAT,
181 * the lba of data region, the cluster_id for the root directory, and an extended
182 * pointer on the FAT mapper.
183 *
184 * WARNING 1 : All access to the FAT are protected by a remote_rwlock.
185 * - it is taken in READ mode by the fatfs_get_cluster() function to scan the
186 *   linked list associated to a given inode.
187 * - it is taken in WRITE mode by the fatfs_cluster_alloc() and fatfs_release_inode()
188 *   functions to modify the FAT in both the FAT mapper and on IOC device.
189 *
190 * WARNING 2 : Most fields are constant values, but <free_cluster_hint>, <free_clusters>,
191 * <lock>, and the buffer pointed by the <fs_info_xp> are shared variables, that can
192 * modified by any thread running in any cluster. The <fs_info_buffer>  contains
193 * a copy of the FS_INFO sector, and is only allocated in the FAT cluster.
194 * It is used to synchronously update the free clusters info on IOC device.
195 *  => For all these variables, only the values stored in the FAT cluster must be used.
196 ****************************************************************************************/
197
198typedef struct fatfs_ctx_s
199{
200    /* read-only constants replicated in all clusters                                   */
201    uint32_t            fat_sectors_count;     /*! number of sectors in FAT region      */
202    uint32_t            bytes_per_sector;      /*! number of bytes per sector           */
203    uint32_t            sectors_per_cluster;   /*! number of sectors per cluster        */
204    uint32_t            fat_begin_lba;         /*! lba of FAT region                    */
205    uint32_t            cluster_begin_lba;     /*! lba of data region                   */
206    uint32_t            fs_info_lba;           /*! lba of FS_INFO sector                */
207    uint32_t            root_dir_cluster;      /*! cluster index for  root directory    */
208    struct mapper_s   * fat_mapper;            /*! local pointer on FAT mapper          */
209
210    /* shared variables (only the copy in FAT cluster must be used)                     */
211    uint32_t            free_cluster_hint;     /*! free_cluster_hint + 1 is first free  */
212    uint32_t            free_clusters;         /*! number of free clusters              */
213    remote_rwlock_t     lock;                  /*! exclusive access to FAT              */
214    uint8_t           * fs_info_buffer;        /*! local pointer on FS_INFO buffer      */
215}
216fatfs_ctx_t;
217
218//////////////////////////////////////////////////////////////////////////////////////////
219//              FATFS specific extern functions 
220//////////////////////////////////////////////////////////////////////////////////////////
221
222/*****************************************************************************************
223 * This debug function display the content of the FATFS context copy in cluster
224 * identified by the <cxy> argument.
225 * This function can be called by any thread running in any cluster.
226 *****************************************************************************************
227 * @ cxy       :  target cluster identifier.
228 ****************************************************************************************/
229void fatfs_display_ctx( cxy_t cxy );
230
231/*****************************************************************************************
232 * This debug function access the FAT mapper to display the current FAT state,
233 * as defined by the <min_slot>, and <nb_slots> arguments.
234 * It display as many lines (8 slots par line) as required to display <nb_slots>,
235 * starting from the <min_slot>. The displayed slots can spread on several FAT mapper
236 * pages. It loads the missing pages from IOC to mapper if required.
237 * This function can be called by any thread running in any cluster.
238 *****************************************************************************************
239 * @ min_slot   : first FATFS cluster index.
240 * @ nb_slots   : number of slots (one slot is 4 bytes.
241 ****************************************************************************************/
242void fatfs_display_fat( uint32_t  min_slot,
243                        uint32_t  nb_slots );
244
245/*****************************************************************************************
246 * This function checks the current values of the "free_clusters" and "free_cluster_hint"
247 * variables in the FS_INFO sector on IOC, versus the values stored in the fatfs context.
248 * As these values are synchronously updated on IOC device at each modification,
249 * it does nothing if the values are equal. It updates the FS_INFO sector on IOC device,
250 * and displays a warning message on TXT0 if they are not equal.
251 * This function can be called by any thread running in any cluster.
252 *****************************************************************************************
253 * @ return 0 if success / return -1 if failure during IOC device access.
254 ****************************************************************************************/
255error_t fatfs_check_free_info( void );
256
257//////////////////////////////////////////////////////////////////////////////////////////
258// Generic API: These functions are called by the kernel VFS,
259//              and must be implemented by all File Systems.
260//////////////////////////////////////////////////////////////////////////////////////////
261
262/*****************************************************************************************
263 * This fuction allocates memory for a FATFS context descriptor in a cluster
264 * identified by the <cxy> argument.
265 *****************************************************************************************
266 * @ cxy   : target cluster identifier.
267 * @ return an extended pointer on the created context / return XPTR_NULL if failure.
268 ****************************************************************************************/
269xptr_t  fatfs_ctx_alloc( cxy_t  cxy );
270
271/*****************************************************************************************
272 * This fuction initialize a fatfs context identified by the <fatfs_ctx_xp> argument
273 * from informations found in the IOC device boot record. This initialisation includes
274 * allocation of the FS_INFO buffer and creation of the FAT mapper in the same cluster.
275 *****************************************************************************************
276 * @ fatfs_ctx_xp   : extended pointer on fatfs context.
277 * @ return 0 if success / return -1 if failure.
278 ****************************************************************************************/
279error_t  fatfs_ctx_init( xptr_t  fatfs_ctx_xp );
280
281/*****************************************************************************************
282 * This function releases memory dynamically allocated for the FATFS context.
283 *****************************************************************************************
284 * @ vfs_ctx_xp   : extended pointer on FATFS context.
285 ****************************************************************************************/
286void fatfs_ctx_destroy( xptr_t  fatfs_ctx_xp );
287
288/*****************************************************************************************
289 * This function implements the generic vfs_fs_add_dentry() function for the FATFS.
290 *****************************************************************************************
291 * This function introduces in a directory mapper identified by the <parent_inode_xp>
292 * argument a new directory entry identified by the <dentry_ptr> argument.
293 * The dentry descriptor and the associated inode descriptor must have been previously
294 * allocated, initialized, and registered in the Inode Tree.
295 * The dentry descriptor defines the "name" field.
296 * The inode descriptor defines the "type", "size", and "cluster_id" fields.
297 * The "extension field" in dentry descriptor is set : index in the FAT32 directory.
298 * All modified pages in the directory mapper are synchronously updated on IOC device.
299 * This function can be called by any thread running in any cluster.
300 *
301 * Implementation note : this function works in two steps:
302 * - It scan the set of 32 bytes FATFS directry entries, using two embedded loops 
303 *   to find the end of directory (NO_MORE_ENTRY marker).
304 * - Then it writes 3, 4, or 5 directory entries (depending on the name length), using
305 *   a 5 steps FSM (one state per entry to be written), and updates on IOC device the
306 *   modified pages.
307 *****************************************************************************************
308 * @ parent_inode_xp : [in]  extended pointer on parent directory inode.
309 * @ dentry_ptr      : [in]  local pointer on dentry (in parent directory cluster).
310 * @ index           : [out] index of the new entry in the FAT32 directory.
311 * @ return 0 if success / return -1 if failure.
312 ****************************************************************************************/
313error_t fatfs_add_dentry( xptr_t                parent_inode_xp,
314                          struct vfs_dentry_s * dentry_ptr );
315
316/*****************************************************************************************
317 * This function implements the generic vfs_fs_remove_dentry() function for the FATFS.
318 *****************************************************************************************
319 * This function updates a directory identified by the <parent_inode_xp> argument
320 * to remove a directory entry identified by the <dentry_ptr> argument.
321 * All modified pages in directory mapper are synchronously updated on IOC device.
322 * This function can be called by any thread running in any cluster.
323 *
324 * Implementation note: this function uses the dentry extension to directly access
325 * the NORMAL directory entry and invalidate all involved LFN entries. Then it
326 * updates the modified pages on IOC device.
327 *****************************************************************************************
328 * @ parent_inode_xp   : [in] extended pointer on parent directory inode.
329 * @ dentry_ptr        : [in] local pointer on dentry (in parent directory cluster).
330 * @ return 0 if success / return -1 if failure.
331 ****************************************************************************************/
332error_t fatfs_remove_dentry( xptr_t                parent_inode_xp,
333                             struct vfs_dentry_s * dentry_ptr );
334
335/*****************************************************************************************
336 * This function implements the generic vfs_fs_new_dentry_from_mapper() for the FATFS.
337 *****************************************************************************************
338 * It scan a parent directory mapper, identified by the <parent_inode_xp> argument
339 * to find a directory entry name defined by the <dentry_ptr> argument, and completes
340 * the initialization of the dentry and the associated child_inode descriptors,
341 * from informations found in the parent directory mapper :
342 * - It set the "type", "size", and "extend" fields in the child inode descriptor.
343 * - It set the " extend" field in the dentry descriptor.
344 * The child inode descriptor, and the dentry descriptor must have been previously
345 * allocated and introduced in the Inode Tree.
346 * This function can be called by any thread running in any cluster.
347 *****************************************************************************************
348 * @ parent_inode_xp : extended pointer on parent inode (directory).
349 * @ dentry_ptr      : local pointer on new dentry (in parent inode cluster).
350 * @ return 0 if success / return -1 if failure.
351 ****************************************************************************************/
352error_t fatfs_new_dentry_from_mapper( xptr_t                parent_inode_xp,
353                                      struct vfs_dentry_s * dentry_ptr );
354
355/*****************************************************************************************
356 * This function implements the generic vfs_fs_new_dentry_to_mapper() for the FATFS.
357 *****************************************************************************************
358 * This function  introduces a brand new dentry identified by the <dentry_ptr> argument
359 * in the mapper of a directory identified by the <parent_inode_xp> argument.
360 * It is called by the vfs_lookup() function.
361 * The child inode descriptor, and the dentry descriptor must have been previously
362 * allocated and introduced in the Inode Tree. The dentry descriptor contains the name.
363 * 1. It allocates a new FATFS cluster_id,
364 * 2. It registers the allocated cluster_id in the child inode extension,
365 * 3. It add a new entry (32 bytes) in the directory mapper,
366 * This function can be called by any thread running in any cluster.
367 *****************************************************************************************
368 * @ parent_inode_xp : [in]  extended pointer on parent inode (directory).
369 * @ dentry_ptr      : [in]  local pointer on dentry (in parent inode cluster).
370 * @ return 0 if success / return -1 if failure.
371 ****************************************************************************************/
372error_t fatfs_new_dentry_to_mapper( xptr_t                parent_inode_xp,
373                                    struct vfs_dentry_s * dentry_ptr );
374
375/*****************************************************************************************
376 * This function implements the generic vfs_fs_update_dentry() function for the FATFS.
377 *****************************************************************************************
378 * It update the "size" of a directory entry identified by the <dentry_ptr> argument in
379 * the mapper of a directory identified by the <parent_inode_xp> argument, from the
380 * value registered in the inode descriptor.
381 * It scan the directory mapper to find the entry such as name == dentry_ptr->name.
382 * It set the "size" field in the directory mapper, and updates the modified directory
383 * page on the IOC device.
384 * This function can be called by any thread running in any cluster.
385 *
386 * TODO the current implementation uses the fatfs_scan_directory to access the
387 * FAT32 directory by name. We can access directly this directory entry if we use
388 * the dentry "extend" field...
389 *****************************************************************************************
390 * @ parent_inode_xp : extended pointer on inode (directory).
391 * @ dentry_ptr      : local pointer on dentry (in parent directory cluster).
392 * @ return 0 if success / return -1 if child not found.
393 ****************************************************************************************/
394error_t fatfs_update_dentry( xptr_t                parent_inode_xp,
395                             struct vfs_dentry_s * dentry_ptr );
396
397/*****************************************************************************************
398 * This function implements the generic vfs_fs_get_user_dir() function for the FATFS.
399 *****************************************************************************************
400 * It is called by the remote_dir_create() function to scan the mapper of a directory
401 * identified by the <inode> argument, and copy up to <max_dirent> valid dentries to a
402 * local dirent array, defined by the <array> argument. The <min_dentry> argument defines
403 * the index of the first dentry to be copied to the target dirent array.
404 * This function returns in the <entries> buffer the number of dentries actually written,
405 * and signals in the <done> buffer when the last valid entry has been found.
406 * If the <detailed> argument is true, a dentry/inode couple that does not exist in
407 * the Inode Tree is dynamically created, and all dirent fields are documented in the
408 * dirent array. Otherwise, only the dentry name is documented.
409 *
410 * WARNING : It must be called by a thread running in the cluster containing the
411 * target directory inode.
412 *****************************************************************************************
413 * @ parent_inode_xp  : [in]  extended pointer on directory inode.
414 * @ array      : [in]  local pointer on array of dirents.
415 * @ max_dirent : [in]  max number of slots in dirent array.
416 * @ min_dentry : [in]  index of first dentry to be copied into array.
417 * @ detailed   : [in]  dynamic inode creation if true.
418 * @ entries    : [out] number of dentries actually copied into array.
419 * @ done       : [out] Boolean true when last entry found.
420 * @ return 0 if success / return -1 if failure.
421 ****************************************************************************************/
422error_t fatfs_get_user_dir( struct vfs_inode_s * inode,
423                            struct dirent      * array, 
424                            uint32_t             max_dirent,
425                            uint32_t             min_dentry,
426                            bool_t               detailed,
427                            uint32_t           * entries,
428                            bool_t             * done );
429
430/*****************************************************************************************
431 * This function implements the generic vfs_fs_sync_inode() function for the FATFS.
432 *****************************************************************************************
433 * It updates the FATFS on the IOC device for a given inode identified by
434 * the <inode_xp> argument. It scan all pages registered in the associated mapper,
435 * and copies from mapper to device each page marked as dirty.
436 * WARNING : The target <inode> cannot be a directory, because all modifications in a
437 * directory are synchronously done on the IOC device by the two fatfs_add_dentry()
438 * and fatfs_remove_dentry() functions.
439 * This function can be called by any thread running in any cluster.
440 *****************************************************************************************
441 * @ inode_xp   : extended pointer on inode.
442 * @ return 0 if success / return -1 if failure.
443 ****************************************************************************************/
444error_t fatfs_sync_inode( xptr_t  inode_xp );
445
446/*****************************************************************************************
447 * This function implements the generic vfs_fs_sync_fat() function for the FATFS.
448 *****************************************************************************************
449 * It updates the FAT on the IOC device for the FAT itself.
450 * It scan all clusters registered in the FAT mapper, and copies from mapper to device
451 * each page marked as dirty.
452 * This function can be called by any thread running in any cluster.
453 *
454 * Implementation note : this function uses the grdxt_remote_get_first() function
455 * to test only the pages actually registered in the FAT mapper.
456 *****************************************************************************************
457 * @ return 0 if success / return -1 if failure during IOC device access.
458 ****************************************************************************************/
459error_t fatfs_sync_fat( void );
460
461/*****************************************************************************************
462 * This function implements the generic vfs_fs_release_inode() function for the FATFS.
463 *****************************************************************************************
464 * This function is used to remove a given file or directory from the FATFS file system.
465 * It releases all clusters allocated to a file/directory identified by the <inode_xp>
466 * argument. All released clusters are marked FREE_CLUSTER in the FAT mapper.
467 * This function calls the recursive function fatfs_cluster_release() to release
468 * the clusters in reverse order of the linked list (from last to first).
469 * When the FAT mapper has been updated, it calls the fatfs_sync_fat() function to
470 * synchronously update all modified pages in the FAT mapper to the IOC device.
471 * Finally the FS-INFO sector on the IOC device is updated.
472 * This function can be called by any thread running in any cluster.
473 *****************************************************************************************
474 * @ inode_xp   : extended pointer on inode.
475 * @ return 0 if success / return EIO if failure during device access.
476 ****************************************************************************************/
477error_t fatfs_release_inode( xptr_t inode_xp );
478
479/*****************************************************************************************
480 * This function implements the generic vfs_fs_move_page() function for the FATFS.
481 *****************************************************************************************
482 * This function moves a page from/to the mapper to/from the FATFS file system on device.
483 * The page must have been previously allocated and registered in the mapper.   
484 * The pointer on the mapper and the page index in file are found in the page descriptor.
485 * It is used for both a regular file/directory mapper, and the FAT mapper.
486 * - For the FAT mapper, it read/write the FAT region on IOC device.
487 * - For a regular file, it scan the FAT mapper to get the cluster_id on IOC device,
488 *   and read/write this cluster.
489 * This function can be called by any thread running in any cluster.
490 *
491 * WARNING : For the FAT mapper, the inode field in the mapper MUST be NULL, as this
492 *           is used to indicate that the corresponding mapper is the FAT mapper.
493 *****************************************************************************************
494 * @ page_xp   : extended pointer on page descriptor.
495 * @ cmd_type  : IOC_READ / IOC_WRITE / IOC_SYNC_READ / IOC_SYNC_WRITE
496 * @ return 0 if success / return EIO if error during device access.
497 ****************************************************************************************/
498error_t fatfs_move_page( xptr_t          page_xp,
499                         ioc_cmd_type_t  cmd_type );
500
501
502
503
504
505
506#endif  /* _FATFS_H_ */
Note: See TracBrowser for help on using the repository browser.