Changeset 635 for trunk/hal/tsar_mips32/core/hal_vmm.c
- Timestamp:
- Jun 26, 2019, 11:42:37 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/hal/tsar_mips32/core/hal_vmm.c
r633 r635 44 44 extern process_t process_zero; 45 45 extern chdev_directory_t chdev_dir; 46 extern char * lock_type_str[]; 46 47 47 48 ////////////////////////////////////////////////////////////////////////////////////////// 48 49 // This function is called by the process_zero_init() function during kernel_init. 49 50 // It initializes the VMM of the kernel proces_zero (containing all kernel threads) 50 // in the local cluster: For TSAR, it registers one "kcode" vseg in kernel VSL, 51 // and registers one big page in slot[0] of kernel GPT. 51 // in the local cluster. 52 // For TSAR, it registers one "kcode" vseg in kernel VSL, and registers one big page 53 // in slot[0] of kernel GPT. 52 54 ////////////////////////////////////////////////////////////////////////////////////////// 53 55 error_t hal_vmm_kernel_init( boot_info_t * info ) … … 58 60 gpt_t * gpt = &process_zero.vmm.gpt; 59 61 60 // get cluster identifier 61 cxy_t cxy = local_cxy; 62 #if DEBUG_HAL_VMM 63 thread_t * this = CURRENT_THREAD; 64 printk("\n[%s] thread[%x,%x] enter in cluster %x\n", 65 __FUNCTION__, this->process->pid, this->trdid, local_cxy ); 66 #endif 62 67 63 68 // allocate memory for kernel GPT … … 67 72 { 68 73 printk("\n[PANIC] in %s : cannot allocate kernel GPT in cluster %x\n", 69 __FUNCTION__ , cxy );74 __FUNCTION__ , local_cxy ); 70 75 hal_core_sleep(); 71 76 } 72 77 73 78 #if DEBUG_HAL_VMM 74 thread_t * this = CURRENT_THREAD; 75 printk("\n[%s] thread[%x,%x] enter in cluster %x / gpt %x\n", 79 printk("\n[%s] thread[%x,%x] created GPT PT1 in cluster %x / gpt %x\n", 76 80 __FUNCTION__, this->process->pid, this->trdid, local_cxy, gpt ); 77 81 #endif … … 79 83 // compute attr and ppn for one PTE1 80 84 uint32_t attr = GPT_MAPPED | GPT_READABLE | GPT_CACHABLE | GPT_EXECUTABLE | GPT_GLOBAL; 81 uint32_t ppn = cxy << 20;85 uint32_t ppn = local_cxy << 20; 82 86 83 87 // set PT1[0] 84 hal_gpt_set_pte( XPTR( cxy , gpt ) , 0 , attr , ppn );85 86 #if DEBUG_HAL_VMM 87 printk("\n[%s] thread[%x,%x] created PT1[0]: ppn %x / attr %x\n",88 __FUNCTION__, this->process->pid, this->trdid, ppn, attr );88 hal_gpt_set_pte( XPTR( local_cxy , gpt ) , 0 , attr , ppn ); 89 90 #if DEBUG_HAL_VMM 91 printk("\n[%s] thread[%x,%x] mapped PT1[0] in cluster %d : ppn %x / attr %x\n", 92 __FUNCTION__, this->process->pid, this->trdid, local_cxy, ppn, attr ); 89 93 #endif 90 94 … … 94 98 info->kcode_base, 95 99 info->kcode_size, 96 0, 0, 97 XPTR_NULL, 100 0, 0, // file ofset and file size (unused) 101 XPTR_NULL, // no mapper 98 102 local_cxy ); 99 103 if( vseg == NULL ) 100 104 { 101 105 printk("\n[PANIC] in %s : cannot register vseg to VSL in cluster %x\n", 102 __FUNCTION__ , cxy );106 __FUNCTION__ , local_cxy ); 103 107 hal_core_sleep(); 104 108 } 105 109 106 110 #if DEBUG_HAL_VMM 107 printk("\n[%s] thread[%x,%x] registered kcode vseg[%x,%x] \n",108 __FUNCTION__, this->process->pid, this->trdid, info->kcode_base, info->kcode_size );111 printk("\n[%s] thread[%x,%x] registered kcode vseg[%x,%x] in cluster %x\n", 112 __FUNCTION__, this->process->pid, this->trdid, info->kcode_base, info->kcode_size, local_cxy ); 109 113 hal_vmm_display( &process_zero , true ); 110 114 #endif … … 194 198 195 199 ////////////////////////////////////////// 196 void hal_vmm_display( process_t * process,197 bool_t 200 void hal_vmm_display( xptr_t process_xp, 201 bool_t mapping ) 198 202 { 199 // get pointer on process VMM 200 vmm_t * vmm = &process->vmm; 203 // get target process cluster and local pointer 204 process_t * process_ptr = GET_PTR( process_xp ); 205 cxy_t process_cxy = GET_CXY( process_xp ); 206 207 // get local pointer on target process VMM 208 vmm_t * vmm = &process_ptr->vmm; 201 209 202 210 // get pointers on TXT0 chdev … … 205 213 chdev_t * txt0_ptr = GET_PTR( txt0_xp ); 206 214 207 // build extended pointer on TXT0 lock and VSL lock215 // build extended pointer on TXT0 lock 208 216 xptr_t txt_lock_xp = XPTR( txt0_cxy , &txt0_ptr->wait_lock ); 209 xptr_t vsl_lock_xp = XPTR( local_cxy , &vmm->vsl_lock ); 210 211 // get root of vsegs list212 xptr_t root_xp = XPTR( local_cxy , &vmm->vsegs_root);213 214 // get the locks protecting TXT0 , VSL, and GPT217 218 // build extended pointers on VSL lock and VSL root 219 xptr_t vsl_root_xp = XPTR( process_cxy , &vmm->vsegs_root ); 220 xptr_t vsl_lock_xp = XPTR( process_cxy , &vmm->vsl_lock ); 221 222 // get the locks protecting TXT0 and VSL 215 223 remote_rwlock_rd_acquire( vsl_lock_xp ); 216 224 remote_busylock_acquire( txt_lock_xp ); 217 225 218 nolock_printk("\n***** VSL and GPT for process %x in cluster %x / PT1 = %x\n", 219 process->pid , local_cxy , vmm->gpt.ptr ); 220 221 if( xlist_is_empty( root_xp ) ) 226 // get PID and PT1 values 227 pid_t pid = hal_remote_l32( XPTR( process_cxy , &process_ptr->pid ) ); 228 uint32_t * pt1 = hal_remote_lpt( XPTR( process_cxy , &vmm->gpt.ptr ) ); 229 230 nolock_printk("\n***** VSL and GPT / process %x / cluster %x / PT1 %x / cycle %d\n", 231 pid , process_cxy , pt1 , (uint32_t)hal_get_cycles() ); 232 233 if( xlist_is_empty( vsl_root_xp ) ) 222 234 { 223 235 nolock_printk(" ... no vsegs registered\n"); … … 227 239 xptr_t iter_xp; 228 240 xptr_t vseg_xp; 229 vseg_t * vseg; 230 231 XLIST_FOREACH( root_xp , iter_xp ) 241 vseg_t * vseg_ptr; 242 cxy_t vseg_cxy; 243 intptr_t min; 244 intptr_t max; 245 uint32_t type; 246 intptr_t vpn_base; 247 intptr_t vpn_size; 248 249 XLIST_FOREACH( vsl_root_xp , iter_xp ) 232 250 { 233 vseg_xp = XLIST_ELEMENT( iter_xp , vseg_t , xlist ); 234 vseg = GET_PTR( vseg_xp ); 251 vseg_xp = XLIST_ELEMENT( iter_xp , vseg_t , xlist ); 252 vseg_ptr = GET_PTR( vseg_xp ); 253 vseg_cxy = GET_CXY( vseg_xp ); 254 255 type = hal_remote_l32( XPTR( vseg_cxy , &vseg_ptr->type ) ); 256 min = (intptr_t)hal_remote_lpt( XPTR( vseg_cxy , &vseg_ptr->min ) ); 257 max = (intptr_t)hal_remote_lpt( XPTR( vseg_cxy , &vseg_ptr->max ) ); 258 vpn_size = (intptr_t)hal_remote_lpt( XPTR( vseg_cxy , &vseg_ptr->vpn_size ) ); 259 vpn_base = (intptr_t)hal_remote_lpt( XPTR( vseg_cxy , &vseg_ptr->vpn_base ) ); 235 260 236 261 nolock_printk(" - %s : base = %X / size = %X / npages = %d\n", 237 vseg_type_str( vseg->type), vseg->min, vseg->max - vseg->min, vseg->vpn_size );262 vseg_type_str(type), min, max - min, vpn_size ); 238 263 239 264 if( mapping ) 240 265 { 241 vpn_t vpn = v seg->vpn_base;242 vpn_t vpn_max = vpn + vseg->vpn_size;266 vpn_t vpn = vpn_base; 267 vpn_t vpn_max = vpn_base + vpn_size; 243 268 ppn_t ppn; 244 269 uint32_t attr; … … 246 271 while( vpn < vpn_max ) // scan the PTEs 247 272 { 248 hal_gpt_get_pte( XPTR( local_cxy , &vmm->gpt ) , vpn , &attr , &ppn );273 hal_gpt_get_pte( XPTR( process_cxy , &vmm->gpt ) , vpn , &attr , &ppn ); 249 274 250 275 if( attr & GPT_MAPPED )
Note: See TracChangeset
for help on using the changeset viewer.