Changeset 614 for trunk/kernel/mm
- Timestamp:
- Jan 15, 2019, 1:59:32 PM (6 years ago)
- Location:
- trunk/kernel/mm
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/mm/mapper.c
r611 r614 28 28 #include <hal_uspace.h> 29 29 #include <grdxt.h> 30 #include <string.h> 30 31 #include <rwlock.h> 31 32 #include <printk.h> … … 41 42 #include <vfs.h> 42 43 #include <mapper.h> 44 #include <dev_ioc.h> 43 45 44 46 … … 302 304 303 305 // launch I/O operation to load page from device to mapper 304 error = vfs_fs_move_page( XPTR( local_cxy , page ) , true);306 error = vfs_fs_move_page( XPTR( local_cxy , page ) , IOC_SYNC_READ ); 305 307 306 308 if( error ) … … 647 649 error_t mapper_display_page( xptr_t mapper_xp, 648 650 uint32_t page_id, 649 uint32_t nbytes, 650 char * string ) 651 { 652 xptr_t page_xp; // extended pointer on page descriptor 653 xptr_t base_xp; // extended pointer on page base 654 char buffer[4096]; // local buffer 655 uint32_t * tab; // pointer on uint32_t to scan the buffer 656 uint32_t line; // line index 657 uint32_t word; // word index 651 uint32_t nbytes ) 652 { 653 xptr_t page_xp; // extended pointer on page descriptor 654 xptr_t base_xp; // extended pointer on page base 655 char buffer[4096]; // local buffer 656 uint32_t * tabi; // pointer on uint32_t to scan buffer 657 char * tabc; // pointer on char to scan buffer 658 uint32_t line; // line index 659 uint32_t word; // word index 660 uint32_t n; // char index 661 cxy_t mapper_cxy; // mapper cluster identifier 662 mapper_t * mapper_ptr; // mapper local pointer 663 vfs_inode_t * inode_ptr; // inode local pointer 664 665 char name[CONFIG_VFS_MAX_NAME_LENGTH]; 658 666 659 667 if( nbytes > 4096) … … 674 682 } 675 683 684 // get cluster and local pointer 685 mapper_cxy = GET_CXY( mapper_xp ); 686 mapper_ptr = GET_PTR( mapper_xp ); 687 688 // get inode 689 inode_ptr = hal_remote_lpt( XPTR( mapper_cxy , &mapper_ptr->inode ) ); 690 691 // get inode name 692 if( inode_ptr == NULL ) strcpy( name , "fat" ); 693 else vfs_inode_get_name( XPTR( mapper_cxy , inode_ptr ) , name ); 694 676 695 // get extended pointer on page base 677 696 base_xp = ppm_page2base( page_xp ); … … 681 700 682 701 // display 8 words per line 683 tab = (uint32_t *)buffer; 684 printk("\n***** %s : first %d bytes of page %d *****\n", string, nbytes, page_id ); 702 tabi = (uint32_t *)buffer; 703 tabc = (char *)buffer; 704 printk("\n***** <%s> first %d bytes of page %d *****\n", name, nbytes, page_id ); 685 705 for( line = 0 ; line < (nbytes >> 5) ; line++ ) 686 706 { 687 707 printk("%X : ", line ); 688 for( word = 0 ; word < 8 ; word++ ) printk("%X ", tab[(line<<3) + word] ); 708 for( word = 0 ; word < 8 ; word++ ) printk("%X ", tabi[(line<<3) + word] ); 709 printk(" | "); 710 for( n = 0 ; n < 32 ; n++ ) printk("%c", tabc[(line<<5) + n] ); 689 711 printk("\n"); 690 712 } -
trunk/kernel/mm/mapper.h
r612 r614 38 38 39 39 /******************************************************************************************* 40 * Th e mapperimplements the kernel cache for a given VFS file or directory.40 * This mapper_t object implements the kernel cache for a given VFS file or directory. 41 41 * There is one mapper per file/dir. It is implemented as a three levels radix tree, 42 42 * entirely stored in the same cluster as the inode representing the file/dir. … … 63 63 * 64 64 * TODO : the mapper being only used to implement the VFS cache(s), the mapper.c 65 * and mapper.h file should be errotrandfered to the vfs directory.65 * and mapper.h file should be trandfered to the vfs directory. 66 66 ******************************************************************************************/ 67 67 … … 85 85 86 86 /******************************************************************************************* 87 * This structure defines a "fragment". It is used to move data between the kernel mapper,88 * and an user buffer, that can be split in several distributed physical pages located89 * in different clusters. A fragment is a set of contiguous bytes in the file.90 * - It can be stored in one single physical page in the user buffer.91 * - It can spread two successive physical pages in the kernel mapper.92 ******************************************************************************************/93 94 typedef struct fragment_s95 {96 uint32_t file_offset; /*! offset of fragment in file (i.e. in mapper) */97 uint32_t size; /*! number of bytes in fragment */98 cxy_t buf_cxy; /*! user buffer cluster identifier */99 void * buf_ptr; /*! local pointer on first byte in user buffer */100 }101 fragment_t;102 103 /*******************************************************************************************104 87 * This function allocates physical memory for a mapper descriptor, and initializes it 105 88 * (refcount <= 0) / inode <= NULL). … … 158 141 * returns O if success / returns -1 if error. 159 142 ******************************************************************************************/ 160 error_t mapper_move_user( xptr_t mappe _xp,143 error_t mapper_move_user( xptr_t mapper_xp, 161 144 bool_t to_buffer, 162 145 uint32_t file_offset, … … 258 241 * @ page_id : [in] page index in file. 259 242 * @ nbytes : [in] value to be written. 260 * @ string : [in] string printed in header.261 243 * @ returns 0 if success / return -1 if error. 262 244 ******************************************************************************************/ 263 245 error_t mapper_display_page( xptr_t mapper_xp, 264 246 uint32_t page_id, 265 uint32_t nbytes, 266 char * string ); 247 uint32_t nbytes ); 267 248 268 249 -
trunk/kernel/mm/vmm.c
r611 r614 64 64 intptr_t base; 65 65 intptr_t size; 66 uint32_t i; 66 67 67 68 #if DEBUG_VMM_INIT … … 69 70 uint32_t cycle = (uint32_t)hal_get_cycles(); 70 71 if( DEBUG_VMM_INIT ) 71 printk("\n[%s] thread[%x,%x] enter for process %x / cycle %d\n",72 __FUNCTION__ , this->process->pid, this->trdid, process->pid 72 printk("\n[%s] thread[%x,%x] enter for process %x in cluster %x / cycle %d\n", 73 __FUNCTION__ , this->process->pid, this->trdid, process->pid, local_cxy, cycle ); 73 74 #endif 74 75 … … 183 184 vmm->mmap_mgr.first_free_vpn = CONFIG_VMM_HEAP_BASE; 184 185 busylock_init( &vmm->mmap_mgr.lock , LOCK_VMM_MMAP ); 185 186 uint32_t i;187 186 for( i = 0 ; i < 32 ; i++ ) list_root_init( &vmm->mmap_mgr.zombi_list[i] ); 188 187 … … 195 194 cycle = (uint32_t)hal_get_cycles(); 196 195 if( DEBUG_VMM_INIT ) 197 printk("\n[%s] thread[%x,%x] exit / process %x / entry_point%x / cycle %d\n",198 __FUNCTION__, this->process->pid, this->trdid, process->pid, process->vmm.entry_point, cycle );196 printk("\n[%s] thread[%x,%x] exit for process %x in cluster %x / cycle %d\n", 197 __FUNCTION__, this->process->pid, this->trdid, process->pid, local_cxy, cycle ); 199 198 #endif 200 199 … … 944 943 vpn_t free; 945 944 946 // mmap vseg size must be power of 2 945 #if DEBUG_VMM_MMAP_ALLOC 946 thread_t * this = CURRENT_THREAD; 947 uint32_t cycle = (uint32_t)hal_get_cycles(); 948 if( DEBUG_VMM_MMAP_ALLOC < cycle ) 949 printk("\n[%s] thread[%x,%x] enter / cycle %d\n", 950 __FUNCTION__, this->process->pid, this->trdid, cycle ); 951 #endif 952 953 // vseg size must be power of 2 947 954 // compute actual size and index in zombi_list array 948 955 size = POW2_ROUNDUP( npages ); … … 952 959 mmap_mgr_t * mgr = &vmm->mmap_mgr; 953 960 961 printk("\n@@@ in %s : size = %d / index = %d / first = %d / empty = %d\n", 962 __FUNCTION__, size, index, mgr->vpn_size, list_is_empty(&mgr->zombi_list[index]) ); 963 954 964 // get lock on mmap allocator 955 965 busylock_acquire( &mgr->lock ); … … 958 968 if( list_is_empty( &mgr->zombi_list[index] ) ) // from mmap zone 959 969 { 970 971 printk("\n@@@ from mmap zone\n" ); 972 960 973 // check overflow 961 974 free = mgr->first_free_vpn; 962 if( (free + size) > mgr->vpn_size ) return ENOMEM;963 964 // update STACKallocator975 if( (free + size) > mgr->vpn_size ) return -1; 976 977 // update MMAP allocator 965 978 mgr->first_free_vpn += size; 966 979 … … 970 983 else // from zombi_list 971 984 { 985 986 printk("\n@@@ from zombi_list\n" ); 987 972 988 // get pointer on zombi vseg from zombi_list 973 989 vseg = LIST_FIRST( &mgr->zombi_list[index] , vseg_t , zlist ); … … 982 998 // release lock on mmap allocator 983 999 busylock_release( &mgr->lock ); 1000 1001 #if DEBUG_VMM_MMAP_ALLOC 1002 cycle = (uint32_t)hal_get_cycles(); 1003 if( DEBUG_VMM_DESTROY < cycle ) 1004 printk("\n[%s] thread[%x,%x] exit / vpn_base %x / vpn_size %x / cycle %d\n", 1005 __FUNCTION__, this->process->pid, this->trdid, base, size, cycle ); 1006 #endif 984 1007 985 1008 // returns vpn_base, vpn_size … … 1009 1032 uint32_t cycle = (uint32_t)hal_get_cycles(); 1010 1033 if( DEBUG_VMM_CREATE_VSEG < cycle ) 1011 printk("\n[%s] thread[%x,%x] enter / %s / cxy %x / cycle %d\n",1012 __FUNCTION__, this->process->pid, this->trdid, vseg_type_str(type), cxy, cycle );1034 printk("\n[%s] thread[%x,%x] enter for process %x / %s / cxy %x / cycle %d\n", 1035 __FUNCTION__, this->process->pid, this->trdid, process->pid, vseg_type_str(type), cxy, cycle ); 1013 1036 #endif 1014 1037 … … 1092 1115 if( vseg != NULL ) 1093 1116 { 1094 printk("\n[ERROR] in %s for process %x : new vseg [vpn_base = %x / vpn_size =%x]\n"1095 " overlap existing vseg [vpn_base = %x / vpn_size =%x]\n",1117 printk("\n[ERROR] in %s for process %x : new vseg [vpn_base %x / vpn_size %x]\n" 1118 " overlap existing vseg [vpn_base %x / vpn_size %x]\n", 1096 1119 __FUNCTION__ , process->pid, vpn_base, vpn_size, vseg->vpn_base, vseg->vpn_size ); 1097 1120 return NULL; … … 1106 1129 return NULL; 1107 1130 } 1131 1132 #if DEBUG_VMM_CREATE_VSEG 1133 if( DEBUG_VMM_CREATE_VSEG < cycle ) 1134 printk("\n[%s] thread[%x,%x] : base %x / size %x / vpn_base %x / vpn_size %x\n", 1135 __FUNCTION__, this->process->pid, this->trdid, base, size, vpn_base, vpn_size ); 1136 #endif 1108 1137 1109 1138 // initialize vseg descriptor -
trunk/kernel/mm/vmm.h
r611 r614 138 138 * - It initializes the generic page table, calling the HAL specific hal_gpt_init() function. 139 139 * - For TSAR it map all pages for the "kentry" vseg, that must be identity mapping. 140 * Note: 140 ******************************************************a************************************** 141 * Implementation notes: 141 142 * - The "code" and "data" vsegs are registered by the elf_load_process() function. 142 143 * - The "stack" vsegs are dynamically created by the thread_user_create() function.
Note: See TracChangeset
for help on using the changeset viewer.