Index: trunk/kernel/vfs/fatfs.h
===================================================================
--- trunk/kernel/vfs/fatfs.h	(revision 23)
+++ trunk/kernel/vfs/fatfs.h	(revision 188)
@@ -160,11 +160,10 @@
 typedef struct fatfs_ctx_s
 {
+    uint32_t          fat_sectors_count;     /*! number of sectors in FAT region        */
+    uint32_t          bytes_per_sector;      /*! number of bytes per sector             */
+    uint32_t          sectors_per_cluster;   /*! number of sectors per cluster          */
     uint32_t          fat_begin_lba;         /*! lba of FAT region                      */
-    uint32_t          fat_sectors_count;     /*! number of sectors in FAT region        */
-    uint32_t          bytes_per_sector;      /*!                                        */
-    uint32_t          bytes_per_cluster;     /*!                                        */
     uint32_t          cluster_begin_lba;     /*! lba of data region                     */
-    uint32_t          sectors_per_cluster;   /*! cluster index for root directory       */
-    uint32_t          root_dir_cluster;      /*!                                        */
+    uint32_t          root_dir_cluster;      /*! cluster index for the root directory   */
     uint32_t          last_allocated_sector; /*! TODO ???                               */
     uint32_t          last_allocated_index;  /*! TODO ???                               */
@@ -173,31 +172,52 @@
 fatfs_ctx_t;
 
-/*****************************************************************************************
- * This structure defines the FATFS specific inode (extension to VFS inode).
- ****************************************************************************************/
-
-typedef struct fatfs_inode_s
-{
-	uint32_t          first_cluster;         /*! first cluster for this file/dir        */ 
-}
-fatfs_inode_t;
-
-
-
-
 //////////////////////////////////////////////////////////////////////////////////////////
-// These functions are specific to the FATFS, and cannot be called by the VFS.
+// Generic API: These functions are called by the kernel,
+//              and must be implemented by all File Systems.
 //////////////////////////////////////////////////////////////////////////////////////////
 
-/*****************************************************************************************
- * This function returns the LBA of the first sector of a FAT cluster.
- * This function can be called by any thread running in any cluster.
- *****************************************************************************************
- * @ ctx	  :	pointer on FATFS context.
- * @ cluster  :	cluster index in FATFS.
- * @ return the lba value.
- ****************************************************************************************/
-inline uint32_t fatfs_lba_from_cluster( fatfs_ctx_t * ctx,
-                                        uint32_t      cluster );
+/******************************************************************************************
+ * This fuction allocates memory from local cluster for a FATFS context descriptor.
+ ******************************************************************************************
+ * @ return a pointer on the created context / return NULL if failure.
+ *****************************************************************************************/
+fatfs_ctx_t * fatfs_ctx_alloc();
+
+/*****************************************************************************************
+ * This function access the external boot device, and initialises it
+ * from informations contained in the boot record. 
+ *****************************************************************************************
+ * @ vfs_ctx   : local pointer on VFS context for FATFS.
+ ****************************************************************************************/
+void fatfs_ctx_init( fatfs_ctx_t * fatfs_ctx );
+
+/*****************************************************************************************
+ * This function releases memory dynamically allocated for the FATFS context extension.
+ *****************************************************************************************
+ * @ vfs_ctx   : local pointer on VFS context.
+ ****************************************************************************************/
+void fatfs_ctx_destroy( fatfs_ctx_t * fatfs_ctx );
+
+/*****************************************************************************************
+ * This function moves a page from the mapper to the FATFS file system on device.
+ * It must be called by a thread running in cluster containing the mapper.
+ * The pointer on the mapper and the page index in file are registered
+ * in the page descriptor. 
+ *****************************************************************************************
+ * @ page    : local pointer on page descriptor.
+ * @ return 0 if success / return EIO if error. 
+ ****************************************************************************************/
+error_t fatfs_write_page( struct page_s * page );
+
+/*****************************************************************************************
+ * This function moves a page from the FATFS file system on device to the mapper.
+ * It must be called by a thread running in cluster containing the mapper.
+ * The pointer on the mapper and the page index in file are registered
+ * in the page descriptor. 
+ *****************************************************************************************
+ * @ page    : local pointer on page descriptor.
+ * @ return 0 if success / return EIO if error. 
+ ****************************************************************************************/
+error_t fatfs_read_page( struct page_s * page );
 
 /*****************************************************************************************
@@ -214,8 +234,8 @@
  * automatically updates the FAT mapper from informations stored on device in case of miss.
  *****************************************************************************************
- * @ mapper	 : local pointer on the FAT mapper.
- * @ first	 : index of the first FATFS cluster allocated to the file.
- * @ page    : index of searched page in the file.
- * @ cluster : [out] pointer on buffer for the found FATFS cluster index.
+ * @ mapper	         : local pointer on the FAT mapper.
+ * @ first_cluster	 : index of the first FATFS cluster allocated to the file.
+ * @ searched_page   : index of searched page in the file.
+ * @ cluster         : [out] pointer on buffer for the found FATFS cluster index.
  * @ return 0 if success / return EIO if FAT mapper miss cannot be solved.
  ****************************************************************************************/
@@ -223,106 +243,5 @@
                            uint32_t          first_cluster,
                            uint32_t          searched_page,
-                           uint32_t        * cluster );
-
-
-
-
-//////////////////////////////////////////////////////////////////////////////////////////
-// These functions are called by the VFS, and must be implemented by all File Systems.
-//////////////////////////////////////////////////////////////////////////////////////////
-
-/******************************************************************************************
- * This function initializes the FATFS file system as the root FS.
- * It is executed cooperatively during kernel init by all CP0s in all clusters.
- * The initilisation is made in three phases, separated by synchronisation barrier:     
- * - phase 1 : all CP0s in all clusters allocate memory for the local copy of
- *   the FATFS context.
- * - phase 2 : cluster_0 only creates the root inode descriptor, access the external
- *   device to get information stored on the boot record, and initialises both 
- *   the VFS context, and the FATFS context.
- * - phase 3 : all other clusters initialize their local VFS context and FATFS context
- *   from values contained in cluster_0, using hal_remote_memcpy().
- ******************************************************************************************
- * @ return an extended pointer on the created root inode / return XPTR_NULL if failure.
- *****************************************************************************************/
-xptr_t fatfs_init();
-
-/******************************************************************************************
- * This function mount the FATFS on the root FS.
- * TODO not implemented [AG]
- ******************************************************************************************
- * @ parent_inode_xp : extended pointer on the parent inode.
- *****************************************************************************************/
-error_t fatfs_mount( xptr_t parent_inode_xp );
-
-
-/*****************************************************************************************
- * This function  initializes both the VFS context and the FATFS context.
- * Both the VFS context and the FATFS context must have been previously allocated.
- * It access the device to read the boot record, and is supposed to be called only 
- * in cluster_0 (in other clusters these contexts are replicated from values 
- * contained in cluster_0).
- *****************************************************************************************
- * @ vfs_ctx        : local pointer on VFS context for FATFS.
- * @ fatfs_ctx      : local pointer on specific FATFS context.
- * @ root_inode_xp  : extended pointer on VFS root inode.
- ****************************************************************************************/
-error_t fatfs_ctx_init( struct vfs_ctx_s   * vfs_ctx,
-                        struct fatfs_ctx_s * fatfs_ctx,
-                        xptr_t               root_inode_xp );
-
-/*****************************************************************************************
- * This function releases memory dynamically allocated for the FATFS context extension.
- *****************************************************************************************
- * @ vfs_ctx   : local pointer on VFS context.
- ****************************************************************************************/
-void fatfs_ctx_destroy( struct vfs_ctx_s * vfs_ctx );
-
-
-
-/*****************************************************************************************
- * This function allocates memory for a FATFS inode, initializes it,
- * and link it to the VFS inode.
- *****************************************************************************************
- * @ inode         : local pointer on the VFS inode.
- * @ first_cluster : first cluster index in the FAT32.
- * @ return 0 if success / return ENOMEM if error. 
- ****************************************************************************************/
-error_t fatfs_inode_create( struct vfs_inode_s * inode,
-                            uint32_t             first_cluster);
-
-/*****************************************************************************************
- * This function releases memory allocated for a FATFS inode.
- *****************************************************************************************
- * @ inode   : local pointer on vfs_inode.
- ****************************************************************************************/
-void fatfs_inode_destroy( struct vfs_inode_s * inode );
-
-
-
-/*****************************************************************************************
- * This function moves a page from the mapper to the FATFS file system on device.
- * It must be called by a thread running in cluster containing the mapper.
- * The pointer on the mapper and the page index in file are registered
- * in the page descriptor. 
- *****************************************************************************************
- * @ page    : local pointer on page descriptor.
- * @ return 0 if success / return EIO if error. 
- ****************************************************************************************/
-error_t fatfs_write_page( struct page_s * page );
-
-/*****************************************************************************************
- * This function moves a page from the FATFS file system on device to the mapper.
- * It must be called by a thread running in cluster containing the mapper.
- * The pointer on the mapper and the page index in file are registered
- * in the page descriptor. 
- *****************************************************************************************
- * @ page    : local pointer on page descriptor.
- * @ return 0 if success / return EIO if error. 
- ****************************************************************************************/
-error_t fatfs_read_page( struct page_s * page );
-
-
-
+                           uint32_t *        cluster );
 
 #endif	/* _FATFS_H_ */
