Changeset 265 for trunk/kernel/mm
- Timestamp:
- Jul 21, 2017, 7:36:08 AM (7 years ago)
- Location:
- trunk/kernel/mm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/mm/mapper.c
r246 r265 169 169 if ( page == NULL ) // missing page => create it and load it from file system 170 170 { 171 mapper_dmsg("\n[INFO] %s : missing page => load from FS\n", __FUNCTION__ );171 mapper_dmsg("\n[INFO] %s : missing page => load from device\n", __FUNCTION__ ); 172 172 173 173 // allocate one page from PPM … … 298 298 } // end mapper_release_page() 299 299 300 ///////////////////////////////////////// 301 error_t mapper_move( mapper_t * mapper, 302 bool_t to_buffer, 303 uint32_t file_offset, 304 void * buffer, 305 uint32_t size ) 300 //////////////////////////////////////////////// 301 error_t mapper_move_buffer( mapper_t * mapper, 302 bool_t to_buffer, 303 bool_t is_user, 304 uint32_t file_offset, 305 void * buffer, 306 uint32_t size ) 306 307 { 307 308 uint32_t page_offset; // first byte to move to/from a mapper page … … 313 314 uint8_t * buf_ptr; // current buffer address 314 315 315 mapper_dmsg("\n[INFO] %s : enter / to_buf = %d / buffer = %x\n",316 mapper_dmsg("\n[INFO] %s : enters / to_buf = %d / buffer = %x\n", 316 317 __FUNCTION__ , to_buffer , buffer ); 317 318 … … 339 340 else page_count = CONFIG_PPM_PAGE_SIZE; 340 341 342 mapper_dmsg("\n[INFO] %s : index = %d / offset = %d / count = %d\n", 343 __FUNCTION__ , index , page_offset , page_count ); 344 341 345 // get page descriptor 342 346 page = mapper_get_page( mapper , index ); … … 350 354 buf_ptr = (uint8_t *)buffer + done; 351 355 356 mapper_dmsg("\n[INFO] %s : index = %d / buf_ptr = %x / map_ptr = %x\n", 357 __FUNCTION__ , index , buf_ptr , map_ptr ); 358 352 359 // move fragment 353 360 if( to_buffer ) 354 361 { 355 hal_copy_to_uspace( buf_ptr , map_ptr , page_count ); 356 } 357 else 362 if( is_user ) hal_copy_to_uspace( buf_ptr , map_ptr , page_count ); 363 else memcpy( buf_ptr , map_ptr , page_count ); 364 } 365 else 358 366 { 359 367 page_do_dirty( page ); 360 hal_copy_from_uspace( map_ptr , buf_ptr , page_count ); 368 if( is_user ) hal_copy_from_uspace( map_ptr , buf_ptr , page_count ); 369 else memcpy( map_ptr , buf_ptr , page_count ); 361 370 } 362 371 … … 369 378 return 0; 370 379 371 } // end mapper_move ()372 380 } // end mapper_move_buffer() 381 -
trunk/kernel/mm/mapper.h
r246 r265 51 51 * - The mapper_get_page() function that return a page descriptor pointer from a page 52 52 * index in file is in charge of handling the miss on the mapper cache. 53 * - The vfs_mapper_move_page() function is used to handle miss on one specific page,53 * - The vfs_mapper_move_page() function access the file system to handle a mapper miss, 54 54 * or update a dirty page on device. 55 * - The vfs_mapper_load_all() functions is used to load all pages of a given directory56 * into the mapper.57 * - the mapper_move () function is used to move data to or from an user buffer.55 * - The vfs_mapper_load_all() functions is used to load all pages of a given file 56 * or directory into the mapper. 57 * - the mapper_move_user() function is used to move data to or from an user buffer. 58 58 * This user space buffer can be physically distributed in several clusters. 59 59 * - In the present implementation the cache size for a given file increases on demand, … … 117 117 118 118 /******************************************************************************************* 119 * This function move data between a kernel mapper and an userbuffer.119 * This function move data between a mapper and an user or kernel buffer. 120 120 * It must be called by a thread running in the cluster containing the mapper. 121 * It split the data in fragments : one fragment is a set of contiguous bytes 122 * stored in the same mapper page. 123 * It uses "hal_uspace" accesses to move fragments to/from the user buffer. 121 * - A kernel buffer must be entirely contained in the same cluster as the mapper. 122 * - An user buffer can be physically distributed in several clusters. 123 * In both cases, the data transfer is split in "fragments": one fragment contains 124 * contiguous bytes in the same mapper page. 125 * - It uses "hal_uspace" accesses to move a fragment to/from the user buffer. 126 * - It uses a simple memcpy" access to move a fragment to/from a kernel buffer. 124 127 * In case of write, the dirty bit is set for all pages written in the mapper. 125 128 * The offset in the file descriptor is not modified by this function. 126 129 ******************************************************************************************* 127 * @ mapper : local pointer on local mapper. 128 * @ to_buffer : move data from mapper to buffer if true. 130 * @ mapper : local pointer on mapper. 131 * @ to_buffer : mapper -> buffer if true / buffer -> mapper if false. 132 * @ is_user : user space buffer if true / kernel local buffer if false. 129 133 * @ file_offset : first byte to move in file. 130 * @ buffer : bufferaddress in user space.134 * @ buffer : pointer on buffer (local kernel buffer or user spaceaddress in user space. 131 135 * @ size : number of bytes to move. 132 136 * returns O if success / returns EINVAL if error. 133 137 ******************************************************************************************/ 134 error_t mapper_move( mapper_t * mapper, 135 bool_t to_buffer, 136 uint32_t file_offset, 137 void * buffer, 138 uint32_t size ); 138 error_t mapper_move_buffer( mapper_t * mapper, 139 bool_t to_buffer, 140 bool_t is_user, 141 uint32_t file_offset, 142 void * buffer, 143 uint32_t size ); 139 144 140 145 /*******************************************************************************************
Note: See TracChangeset
for help on using the changeset viewer.