Ignore:
Timestamp:
Jun 18, 2017, 10:06:41 PM (5 years ago)
Author:
alain
Message:

Introduce syscalls.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/mm/mapper.h

    r18 r23  
    3939/*******************************************************************************************
    4040 * The mapper implements the kernel cache for a given file or directory.
    41  * There is one mapper per file. It is implemented as a three levels radix tree,
     41 * There is one mapper per file/dir. It is implemented as a three levels radix tree,
    4242 * entirely stored in the same cluster as the inode representing the file/dir.
    4343 * - The fast retrieval key is the page index in the file.
     
    4949 * - The mapper is protected by a blocking "rwlock", to support several simultaneous
    5050 *   readers, and only one writer. This lock implement a busy waiting policy.
    51  * - The two functions mapper_sync_page() and mapper_updt_page() define the generic API
    52  *   used to move pages to or from the relevant file system on IOC device.
    53  * - the mapper_move fragments() function is used to move data to or from a distributed
    54  *   user buffer.
     51 * - The two functions vfs_move_page_to_mapper() and vfs_move_page_from_mapper() define
     52 *   the generic API used to move pages to or from the relevant file system on IOC device.
     53 * - the mapper_move() function is used to move data to or from a, possibly distributed
     54 *   user buffer in user space.
    5555 * - The mapper_get_page() function that return a page descriptor pointer from a page
    5656 *   index in file is in charge of handling the miss on the mapper cache.
    5757 * - In the present implementation the cache size increases on demand, and the
    58  *   allocated memory is only released when the mapper is destroyed.
     58 *   allocated memory is only released when the mapper/inode is destroyed.
    5959 ******************************************************************************************/
    6060
     
    6666typedef struct mapper_s
    6767{
    68         struct vfs_inode_s * inode;           /*! owner file inode                                */
     68        struct vfs_inode_s * inode;           /*! owner inode                                     */
    6969        grdxt_t              radix;           /*! pages cache implemented as a radix tree         */
    7070        rwlock_t             lock;        /*! several readers / only one writer               */
     
    8989    uint32_t    size;                /*! number of bytes in fragment                      */
    9090    cxy_t       buf_cxy;             /*! user buffer cluster identifier                   */
    91     uint8_t   * buf_ptr;             /*! local pointer on first byte in user buffer       */
     91    void      * buf_ptr;             /*! local pointer on first byte in user buffer       */
    9292}
    9393fragment_t;
     
    114114
    115115/*******************************************************************************************
    116  * This function moves all fragments covering a distributed user buffer between
    117  * a mapper (associated to a local inode), and the user buffer.
    118  * [See the fragment definition in the mapper.h file]
    119  * It must be executed by a thread running in the cluster containing the mapper.
    120  * The lock protecting the mapper must have been taken in WRITE_MODE or READ_MODE
    121  * by the caller thread, depending on the transfer direction.
     116 * This function move data between a kernel mapper and an user buffer.
     117 * It must be called by a thread running in the cluster containing the mapper.
     118 * It split the data in fragments : one fragment is a set of contiguous bytes
     119 * stored in the same mapper page. 
     120 * It uses "hal_uspace" accesses to move fragments to/from the user buffer.
    122121 * In case of write, the dirty bit is set for all pages written in the mapper.
    123122 * The offset in the file descriptor is not modified by this function.
    124  * Implementation note:
    125  * For each fragment, this function makes ONE hal_remote_memcpy() when the fragment is
    126  * fully contained in one single page of the mapper. It makes TWO hal_remote_memcpy()
    127  * if the fragment spread on two contiguous pages in the mapper.
    128123 *******************************************************************************************
    129  * @ mapper    : local pointer on the local mapper.
    130  * @ to_buffer : mapper to buffer if true / buffer to mapper if false.
    131  * @ nb_frags  : number of fragments covering the user buffer (one per page).
    132  * @ frags_xp  : extended pointer on array of fragments.
    133 FAT * returns O if success / returns EINVAL if error.
     124 * @ mapper       : extended pointer on local mapper.
     125 * @ to_buffer    : move data from mapper to buffer if true.
     126 * @ file_offset  : first byte to move in file.
     127 * @ buffer       : buffer address in user space.
     128 * @ size         : number of bytes to move.
     129 * returns O if success / returns EINVAL if error.
    134130 ******************************************************************************************/
    135 error_t mapper_move_fragments( mapper_t * mapper,
    136                                bool_t     to_buffer,
    137                                uint32_t   nb_frags,
    138                                xptr_t     frags_xp );
    139 
     131error_t mapper_move( mapper_t * mapper,
     132                     bool_t     to_buffer,
     133                     uint32_t   file_offset,
     134                     void     * buffer,
     135                     uint32_t   size );
    140136
    141137/*******************************************************************************************
     
    146142 *******************************************************************************************
    147143 * @ mapper     : local pointer on the mapper.
    148  * @ index      : page index in file
    149144 * @ page       : pointer on page to remove.
    150145 * @ return 0 if success / return EIO if a dirty page cannot be copied to FS.
    151146 ******************************************************************************************/
    152147error_t mapper_release_page( mapper_t      * mapper,
    153                              uint32_t        index,
    154148                             struct page_s * page );
    155149
     
    167161                                 uint32_t   index );
    168162
    169 /*******************************************************************************************
    170  * This function makes an I/O operation to move one page from FS to mapper.
    171  * Depending on the file system type, it calls the proper, FS specific function.
    172  * It must be executed by a thread running in the cluster containing the mapper.
    173  *******************************************************************************************
    174  * @ mapper     : local pointer on the mapper.
    175  * @ index      : page index in file.
    176  * @ page   : local pointer on the page descriptor in mapper.
    177  * @ returns 0 if success / return EINVAL if it cannot access the device.
    178  ******************************************************************************************/
    179 error_t mapper_updt_page( mapper_t      * mapper,
    180                           uint32_t        index,
    181                           struct page_s * page );
    182 
    183 /*******************************************************************************************
    184  * This function makes an I/0 operation to move one page from mapper to FS.
    185  * Depending on the file system type, it calls the proper, FS specific function.
    186  * It must be executed by a thread running in the cluster containing the mapper.
    187  * It does nothing if the page is not dirty. If the page is dirty, it takes
    188  * the page lock before launching the IO operation, clear the page dirty bit,
    189  * and remove the page from the PPM dirty list. It does nothing if the page is not dirty.
    190  *******************************************************************************************
    191  * @ mapper     : local pointer on the mapper.
    192  * @ index      : page index in file.
    193  * @ page   : local pointer on the page descriptor in mapper.
    194  * @ returns 0 if success / return EINVAL if it cannot access the device.
    195  ******************************************************************************************/
    196 error_t mapper_sync_page( mapper_t      * mapper,
    197                           uint32_t        index,
    198                           struct page_s * page );
     163 
    199164
    200165#endif /* _MAPPER_H_ */
Note: See TracChangeset for help on using the changeset viewer.