Index: trunk/kernel/mm/mapper.h
===================================================================
--- trunk/kernel/mm/mapper.h	(revision 18)
+++ trunk/kernel/mm/mapper.h	(revision 23)
@@ -39,5 +39,5 @@
 /*******************************************************************************************
  * The mapper implements the kernel cache for a given file or directory.
- * There is one mapper per file. It is implemented as a three levels radix tree,
+ * There is one mapper per file/dir. It is implemented as a three levels radix tree,
  * entirely stored in the same cluster as the inode representing the file/dir.
  * - The fast retrieval key is the page index in the file.
@@ -49,12 +49,12 @@
  * - The mapper is protected by a blocking "rwlock", to support several simultaneous
  *   readers, and only one writer. This lock implement a busy waiting policy.
- * - The two functions mapper_sync_page() and mapper_updt_page() define the generic API
- *   used to move pages to or from the relevant file system on IOC device.
- * - the mapper_move fragments() function is used to move data to or from a distributed
- *   user buffer.
+ * - The two functions vfs_move_page_to_mapper() and vfs_move_page_from_mapper() define 
+ *   the generic API used to move pages to or from the relevant file system on IOC device.
+ * - the mapper_move() function is used to move data to or from a, possibly distributed
+ *   user buffer in user space. 
  * - The mapper_get_page() function that return a page descriptor pointer from a page
  *   index in file is in charge of handling the miss on the mapper cache.
  * - In the present implementation the cache size increases on demand, and the
- *   allocated memory is only released when the mapper is destroyed.
+ *   allocated memory is only released when the mapper/inode is destroyed.
  ******************************************************************************************/
 
@@ -66,5 +66,5 @@
 typedef struct mapper_s
 {
-	struct vfs_inode_s * inode;	      /*! owner file inode                                */
+	struct vfs_inode_s * inode;	      /*! owner inode                                     */
 	grdxt_t	             radix;	      /*! pages cache implemented as a radix tree         */
 	rwlock_t             lock;        /*! several readers / only one writer               */
@@ -89,5 +89,5 @@
     uint32_t    size;                /*! number of bytes in fragment                      */
     cxy_t       buf_cxy;             /*! user buffer cluster identifier                   */
-    uint8_t   * buf_ptr;             /*! local pointer on first byte in user buffer       */
+    void      * buf_ptr;             /*! local pointer on first byte in user buffer       */
 }
 fragment_t;
@@ -114,28 +114,24 @@
 
 /*******************************************************************************************
- * This function moves all fragments covering a distributed user buffer between
- * a mapper (associated to a local inode), and the user buffer.
- * [See the fragment definition in the mapper.h file]
- * It must be executed by a thread running in the cluster containing the mapper.
- * The lock protecting the mapper must have been taken in WRITE_MODE or READ_MODE
- * by the caller thread, depending on the transfer direction.
+ * This function move data between a kernel mapper and an user buffer.
+ * It must be called by a thread running in the cluster containing the mapper.
+ * It split the data in fragments : one fragment is a set of contiguous bytes
+ * stored in the same mapper page.  
+ * It uses "hal_uspace" accesses to move fragments to/from the user buffer.
  * In case of write, the dirty bit is set for all pages written in the mapper.
  * The offset in the file descriptor is not modified by this function.
- * Implementation note:
- * For each fragment, this function makes ONE hal_remote_memcpy() when the fragment is
- * fully contained in one single page of the mapper. It makes TWO hal_remote_memcpy()
- * if the fragment spread on two contiguous pages in the mapper.
  *******************************************************************************************
- * @ mapper    : local pointer on the local mapper.
- * @ to_buffer : mapper to buffer if true / buffer to mapper if false.
- * @ nb_frags  : number of fragments covering the user buffer (one per page).
- * @ frags_xp  : extended pointer on array of fragments.
-FAT * returns O if success / returns EINVAL if error.
+ * @ mapper       : extended pointer on local mapper.
+ * @ to_buffer    : move data from mapper to buffer if true.
+ * @ file_offset  : first byte to move in file.
+ * @ buffer       : buffer address in user space.
+ * @ size         : number of bytes to move.
+ * returns O if success / returns EINVAL if error.
  ******************************************************************************************/
-error_t mapper_move_fragments( mapper_t * mapper,
-                               bool_t     to_buffer,
-                               uint32_t   nb_frags,
-                               xptr_t     frags_xp );
-
+error_t mapper_move( mapper_t * mapper,
+                     bool_t     to_buffer,
+                     uint32_t   file_offset,
+                     void     * buffer,
+                     uint32_t   size );
 
 /*******************************************************************************************
@@ -146,10 +142,8 @@
  *******************************************************************************************
  * @ mapper	: local pointer on the mapper.
- * @ index	: page index in file
  * @ page	: pointer on page to remove.
  * @ return 0 if success / return EIO if a dirty page cannot be copied to FS.
  ******************************************************************************************/
 error_t mapper_release_page( mapper_t      * mapper,
-                             uint32_t        index,
                              struct page_s * page );
 
@@ -167,34 +161,5 @@
                                  uint32_t   index );
 
-/*******************************************************************************************
- * This function makes an I/O operation to move one page from FS to mapper.
- * Depending on the file system type, it calls the proper, FS specific function.
- * It must be executed by a thread running in the cluster containing the mapper.
- *******************************************************************************************
- * @ mapper	: local pointer on the mapper.
- * @ index	: page index in file.
- * @ page   : local pointer on the page descriptor in mapper.
- * @ returns 0 if success / return EINVAL if it cannot access the device.
- ******************************************************************************************/
-error_t mapper_updt_page( mapper_t      * mapper,
-                          uint32_t        index,
-                          struct page_s * page );
-
-/*******************************************************************************************
- * This function makes an I/0 operation to move one page from mapper to FS.
- * Depending on the file system type, it calls the proper, FS specific function.
- * It must be executed by a thread running in the cluster containing the mapper.
- * It does nothing if the page is not dirty. If the page is dirty, it takes
- * the page lock before launching the IO operation, clear the page dirty bit,
- * and remove the page from the PPM dirty list. It does nothing if the page is not dirty.
- *******************************************************************************************
- * @ mapper	: local pointer on the mapper.
- * @ index	: page index in file.
- * @ page   : local pointer on the page descriptor in mapper.
- * @ returns 0 if success / return EINVAL if it cannot access the device.
- ******************************************************************************************/
-error_t mapper_sync_page( mapper_t      * mapper,
-                          uint32_t        index,
-                          struct page_s * page );
+ 
 
 #endif /* _MAPPER_H_ */
