Changeset 628 for trunk/kernel/mm
- Timestamp:
- May 6, 2019, 1:28:01 PM (6 years ago)
- Location:
- trunk/kernel/mm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/mm/mapper.c
r626 r628 395 395 { 396 396 uint32_t page_offset; // first byte to move to/from a mapper page 397 uint32_t page_ count; // number of bytes to move to/from a mapper page397 uint32_t page_bytes; // number of bytes to move to/from a mapper page 398 398 uint32_t page_id; // current mapper page index 399 399 uint32_t done; // number of moved bytes … … 420 420 #endif 421 421 422 // compute offsets of first and last bytes in file422 // compute indexes of first and last bytes in file 423 423 uint32_t min_byte = file_offset; 424 424 uint32_t max_byte = file_offset + size - 1; … … 444 444 445 445 // compute number of bytes in page 446 if ( first == last ) page_ count= size;447 else if ( page_id == first ) page_ count= CONFIG_PPM_PAGE_SIZE - page_offset;448 else if ( page_id == last ) page_ count= (max_byte & CONFIG_PPM_PAGE_MASK) + 1;449 else page_ count= CONFIG_PPM_PAGE_SIZE;446 if ( first == last ) page_bytes = size; 447 else if ( page_id == first ) page_bytes = CONFIG_PPM_PAGE_SIZE - page_offset; 448 else if ( page_id == last ) page_bytes = (max_byte & CONFIG_PPM_PAGE_MASK) + 1; 449 else page_bytes = CONFIG_PPM_PAGE_SIZE; 450 450 451 451 #if (DEBUG_MAPPER_MOVE_USER & 1) 452 452 if( DEBUG_MAPPER_MOVE_USER < cycle ) 453 453 printk("\n[%s] thread[%x,%x] : page_id %d / page_offset %d / bytes %d\n", 454 __FUNCTION__, this->process->pid, this->trdid, page_id , page_offset , page_ count);455 #endif 456 457 // get extended pointer on page descriptor 454 __FUNCTION__, this->process->pid, this->trdid, page_id , page_offset , page_bytes ); 455 #endif 456 457 // get extended pointer on page descriptor in mapper 458 458 page_xp = mapper_remote_get_page( mapper_xp , page_id ); 459 459 … … 476 476 if( to_buffer ) 477 477 { 478 hal_copy_to_uspace( map_cxy , map_ptr , buf_ptr , page_count);478 hal_copy_to_uspace( map_cxy , map_ptr + page_offset , buf_ptr , page_bytes ); 479 479 480 480 #if DEBUG_MAPPER_MOVE_USER & 1 481 481 if( DEBUG_MAPPER_MOVE_USER < cycle ) 482 482 printk("\n[%s] thread[%x,%x] moved %d bytes / mapper %s (%x,%x) -> user buffer(%x,%x)\n", 483 __FUNCTION__, this->process->pid, this->trdid, page_ count,484 name, map_cxy, map_ptr , local_cxy, buf_ptr );483 __FUNCTION__, this->process->pid, this->trdid, page_bytes, 484 name, map_cxy, map_ptr + page_offset, local_cxy, buf_ptr ); 485 485 #endif 486 486 … … 489 489 { 490 490 ppm_page_do_dirty( page_xp ); 491 hal_copy_from_uspace( map_cxy , map_ptr , buf_ptr , page_count);491 hal_copy_from_uspace( map_cxy , map_ptr + page_offset , buf_ptr , page_bytes ); 492 492 493 493 #if DEBUG_MAPPER_MOVE_USER & 1 494 494 if( DEBUG_MAPPER_MOVE_USER < cycle ) 495 495 printk("\n[%s] thread[%x,%x] moved %d bytes / user buffer(%x,%x) -> mapper %s (%x,%x)\n", 496 __FUNCTION__, this->process->pid, this->trdid, page_ count,497 local_cxy, buf_ptr, name, map_cxy, map_ptr );496 __FUNCTION__, this->process->pid, this->trdid, page_bytes, 497 local_cxy, buf_ptr, name, map_cxy, map_ptr + page_offset ); 498 498 mapper_display_page( mapper_xp , page_id, 128 ); 499 499 #endif … … 501 501 } 502 502 503 done += page_ count;503 done += page_bytes; 504 504 } 505 505 … … 529 529 { 530 530 uint32_t page_offset; // first byte to move to/from a mapper page 531 uint32_t page_ count; // number of bytes to move to/from a mapper page531 uint32_t page_bytes; // number of bytes to move to/from a mapper page 532 532 uint32_t page_id; // current mapper page index 533 533 uint32_t done; // number of moved bytes … … 588 588 589 589 // compute number of bytes to move in page 590 if ( first == last ) page_ count= size;591 else if ( page_id == first ) page_ count= CONFIG_PPM_PAGE_SIZE - page_offset;592 else if ( page_id == last ) page_ count= (max_byte & CONFIG_PPM_PAGE_MASK) + 1;593 else page_ count= CONFIG_PPM_PAGE_SIZE;590 if ( first == last ) page_bytes = size; 591 else if ( page_id == first ) page_bytes = CONFIG_PPM_PAGE_SIZE - page_offset; 592 else if ( page_id == last ) page_bytes = (max_byte & CONFIG_PPM_PAGE_MASK) + 1; 593 else page_bytes = CONFIG_PPM_PAGE_SIZE; 594 594 595 595 // get extended pointer on page descriptor … … 621 621 if( to_buffer ) 622 622 printk("\n[%s] mapper <%s> page %d => buffer(%x,%x) / %d bytes\n", 623 __FUNCTION__, name, page_id, dst_cxy, dst_ptr, page_ count);623 __FUNCTION__, name, page_id, dst_cxy, dst_ptr, page_bytes ); 624 624 else 625 625 printk("\n[%s] buffer(%x,%x) => mapper <%s> page %d / %d bytes\n", 626 __FUNCTION__, src_cxy, src_ptr, name, page_id, page_ count);626 __FUNCTION__, src_cxy, src_ptr, name, page_id, page_bytes ); 627 627 } 628 628 #endif 629 629 630 630 // move fragment 631 hal_remote_memcpy( XPTR( dst_cxy , dst_ptr ), XPTR( src_cxy , src_ptr ), page_ count);632 633 done += page_ count;631 hal_remote_memcpy( XPTR( dst_cxy , dst_ptr ), XPTR( src_cxy , src_ptr ), page_bytes ); 632 633 done += page_bytes; 634 634 } 635 635 … … 647 647 /////////////////////////////////////////////////// 648 648 error_t mapper_remote_get_32( xptr_t mapper_xp, 649 uint32_t page_id, 649 650 uint32_t word_id, 650 uint32_t * p_value ) 651 { 652 uint32_t page_id; // page index in file 653 uint32_t local_id; // word index in page 651 uint32_t * value ) 652 { 654 653 xptr_t page_xp; // extended pointer on searched page descriptor 655 654 xptr_t base_xp; // extended pointer on searched page base 656 657 655 658 // get page index and local word index659 page_id = word_id >> 10;660 local_id = word_id & 0x3FF;661 662 656 // get page containing the searched word 663 657 page_xp = mapper_remote_get_page( mapper_xp , page_id ); … … 669 663 670 664 // get the value from mapper 671 * p_value = hal_remote_l32( base_xp + (local_id<<2) );665 *value = hal_remote_l32( base_xp + (word_id<<2) ); 672 666 673 667 return 0; … … 677 671 /////////////////////////////////////////////////// 678 672 error_t mapper_remote_set_32( xptr_t mapper_xp, 673 uint32_t page_id, 679 674 uint32_t word_id, 680 675 uint32_t value ) 681 676 { 682 683 uint32_t page_id; // page index in file684 uint32_t local_id; // word index in page685 677 xptr_t page_xp; // extended pointer on searched page descriptor 686 678 xptr_t base_xp; // extended pointer on searched page base 687 679 688 // get page index and local vord index689 page_id = word_id >> 10;690 local_id = word_id & 0x3FF;691 692 680 // get page containing the searched word 693 681 page_xp = mapper_remote_get_page( mapper_xp , page_id ); … … 699 687 700 688 // set value to mapper 701 hal_remote_s32( (base_xp + ( local_id << 2)) , value );702 703 // set the dirty flag 689 hal_remote_s32( (base_xp + (word_id << 2)) , value ); 690 691 // set the dirty flag in page descriptor 704 692 ppm_page_do_dirty( page_xp ); 705 693 -
trunk/kernel/mm/mapper.h
r626 r628 206 206 ******************************************************************************************* 207 207 * @ mapper_xp : [in] extended pointer on the mapper. 208 * @ word_id : [in] 32 bits word index in file. 209 * @ p_value : [out] local pointer on destination buffer. 208 * @ page_id : [in] page index in mapper. 209 * @ word_id : [in] 32 bits word index in page. 210 * @ value : [out] local pointer on destination buffer. 210 211 * @ returns 0 if success / return -1 if error. 211 212 ******************************************************************************************/ 212 213 error_t mapper_remote_get_32( xptr_t mapper_xp, 214 uint32_t page_id, 213 215 uint32_t word_id, 214 uint32_t * p_value );216 uint32_t * value ); 215 217 216 218 /******************************************************************************************* … … 220 222 * In case of miss, it takes the mapper lock in WRITE_MODE, load the missing 221 223 * page from device to mapper, and release the mapper lock. 224 * It does not update the FAT on IOC device. 222 225 ******************************************************************************************* 223 226 * @ mapper_xp : [in] extended pointer on the mapper. 224 * @ word_id : [in] 32 bits word index in file. 227 * @ page_id : [in] page index in mapper. 228 * @ word_id : [in] 32 bits word index in page. 225 229 * @ value : [in] value to be written. 226 230 * @ returns 0 if success / return -1 if error. 227 231 ******************************************************************************************/ 228 232 error_t mapper_remote_set_32( xptr_t mapper_xp, 233 uint32_t page_id, 229 234 uint32_t word_id, 230 235 uint32_t value );
Note: See TracChangeset
for help on using the changeset viewer.