Changeset 614 for trunk/kernel/libk/user_dir.c
- Timestamp:
- Jan 15, 2019, 1:59:32 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/libk/user_dir.c
r613 r614 80 80 } // end user_dir_from_ident() 81 81 82 /////////////////////////////////////////////////// 83 user_dir_t * user_dir_create( vfs_inode_t * inode ) 82 ////////////////////////////////////////////////// 83 user_dir_t * user_dir_create( vfs_inode_t * inode, 84 xptr_t ref_xp ) 84 85 { 85 86 user_dir_t * dir; // local pointer on created user_dir_t 86 87 vseg_t * vseg; // local pointer on dirent array vseg 87 88 uint32_t vseg_size; // size of vseg in bytes 88 process_t * process; // local pointer on calling process89 xptr_t ref_xp; // extended pointer on reference process90 89 process_t * ref_ptr; // local pointer on reference process 91 90 cxy_t ref_cxy; // reference process cluster identifier 91 pid_t ref_pid; // reference process PID 92 92 xptr_t gpt_xp; // extended pointer on reference process GPT 93 93 uint32_t gpt_attributes; // attributes for all mapped gpt entries … … 109 109 error_t error; 110 110 111 // get pointer on local process descriptor 112 process = CURRENT_THREAD->process; 111 // get cluster, local pointer, and pid of reference user process 112 ref_cxy = GET_CXY( ref_xp ); 113 ref_ptr = GET_PTR( ref_xp ); 114 ref_pid = hal_remote_l32( XPTR( ref_cxy , &ref_ptr->pid ) ); 113 115 114 116 #if DEBUG_USER_DIR … … 116 118 thread_t * this = CURRENT_THREAD; 117 119 if( cycle > DEBUG_USER_DIR ) 118 printk("\n[%s] thread[%x,%x] enter for inode (%x,%x) / cycle %d\n",119 __FUNCTION__, process->pid, this->trdid, local_cxy, inode, cycle );120 printk("\n[%s] thread[%x,%x] enter for inode (%x,%x) and process %x / cycle %d\n", 121 __FUNCTION__, this->process->pid, this->trdid, local_cxy, inode, ref_pid, cycle ); 120 122 #endif 121 123 … … 128 130 // initialise temporary list of pages 129 131 list_root_init( &root ); 130 131 // get pointers on reference process132 ref_xp = process->ref_xp;133 ref_cxy = GET_CXY( ref_xp );134 ref_ptr = GET_PTR( ref_xp );135 132 136 133 // allocate memory for a local user_dir descriptor … … 207 204 } // end while 208 205 206 #if DEBUG_USER_DIR 207 if( cycle > DEBUG_USER_DIR ) 208 printk("\n[%s] thread[%x,%x] initialised dirent array / %d entries\n", 209 __FUNCTION__, this->process->pid, this->trdid, total_dirents, cycle ); 210 #endif 211 209 212 // compute required vseg size for a 64 bytes dirent 210 213 vseg_size = total_dirents << 6; … … 213 216 if( local_cxy == ref_cxy ) 214 217 { 215 vseg = vmm_create_vseg( process,218 vseg = vmm_create_vseg( ref_ptr, 216 219 VSEG_TYPE_ANON, 217 220 0, // vseg base (unused) … … 220 223 0, // file_size (unused) 221 224 XPTR_NULL, // mapper (unused) 222 ref_cxy );225 local_cxy ); 223 226 } 224 227 else … … 232 235 0, // file size (unused) 233 236 XPTR_NULL, // mapper (unused) 234 ref_cxy,237 local_cxy, 235 238 &vseg ); 236 239 } 240 237 241 if( vseg == NULL ) 238 242 { 239 printk("\n[ERROR] in %s : cannot create vseg for DIRin cluster %x\n",243 printk("\n[ERROR] in %s : cannot create vseg for user_dir in cluster %x\n", 240 244 __FUNCTION__, ref_cxy); 241 245 goto user_dir_create_failure; 242 246 } 243 247 244 #if (DEBUG_USER_DIR & 1)248 #if DEBUG_USER_DIR 245 249 if( cycle > DEBUG_USER_DIR ) 246 250 printk("\n[%s] thread[%x,%x] allocated vseg ANON / base %x / size %x\n", 247 __FUNCTION__, process->pid, this->trdid, vseg->min, vseg->max - vseg->min );251 __FUNCTION__, this->process->pid, this->trdid, vseg->min, vseg->max - vseg->min ); 248 252 #endif 249 253 … … 289 293 desc.lid = CURRENT_THREAD->core->lid; 290 294 desc.blocking = true; 291 desc.args[0] = process->pid;295 desc.args[0] = ref_pid; 292 296 desc.args[1] = vpn << CONFIG_PPM_PAGE_SHIFT; 293 297 rpc_vmm_delete_vseg_client( ref_cxy , &desc ); … … 299 303 } 300 304 301 #if (DEBUG_USER_DIR & 1)305 #if DEBUG_USER_DIR 302 306 if( cycle > DEBUG_USER_DIR ) 303 307 printk("\n[%s] thread[%x,%x] mapped vpn %x to ppn %x\n", 304 __FUNCTION__, process->pid, this->trdid, vpn + page_id, ppn );308 __FUNCTION__, this->process->pid, this->trdid, vpn + page_id, ppn ); 305 309 #endif 306 310 … … 340 344 if( cycle > DEBUG_USER_DIR ) 341 345 printk("\n[%s] thread[%x,%x] created user_dir (%x,%x) / %d entries / cycle %d\n", 342 __FUNCTION__, process->pid, this->trdid, local_cxy, dir, total_dirents, cycle );346 __FUNCTION__, this->process->pid, this->trdid, local_cxy, dir, total_dirents, cycle ); 343 347 #endif 344 348 … … 365 369 } // end user_dir_create() 366 370 367 ///////////////////////////////////////// 368 void user_dir_destroy( user_dir_t * dir ) 371 //////////////////////////////////////// 372 void user_dir_destroy( user_dir_t * dir, 373 xptr_t ref_xp ) 369 374 { 370 process_t * process; // local pointer on client process371 thread_t * this; // local pointer on client thread375 thread_t * this; // local pointer on calling thread 376 process_t * process; // local pointer on calling process 372 377 cluster_t * cluster; // local pointer on local cluster 373 378 intptr_t ident; // user pointer on dirent array 374 xptr_t ref_ xp; // extended pointer on reference process379 xptr_t ref_pid; // reference process PID 375 380 cxy_t ref_cxy; // reference process cluster identifier 376 381 process_t * ref_ptr; // local pointer on reference process … … 379 384 xptr_t iter_xp; // iteratot in xlist 380 385 reg_t save_sr; // for critical section 381 pid_t pid; // process descriptor382 386 cxy_t owner_cxy; // owner process cluster 383 387 lpid_t lpid; // process local index 384 388 rpc_desc_t rpc; // rpc descriptor 385 389 386 // get pointers on c lientprocess & thread390 // get pointers on calling process & thread 387 391 this = CURRENT_THREAD; 388 392 process = this->process; 389 393 cluster = LOCAL_CLUSTER; 390 394 395 // get cluster, local pointer, and PID of reference user process 396 ref_cxy = GET_CXY( ref_xp ); 397 ref_ptr = GET_PTR( ref_xp ); 398 ref_pid = hal_remote_l32( XPTR( ref_cxy , &ref_ptr->pid ) ); 399 391 400 #if DEBUG_USER_DIR 392 401 uint32_t cycle = (uint32_t)hal_get_cycles(); 393 402 if( cycle > DEBUG_USER_DIR ) 394 printk("\n[%s] thread[%x,%x] enter for user_dir (%x,%x) / cycle %d\n",395 __FUNCTION__, process->pid, this->trdid, local_cxy, dir, cycle );403 printk("\n[%s] thread[%x,%x] enter for user_dir (%x,%x) and process %x / cycle %d\n", 404 __FUNCTION__, process->pid, this->trdid, local_cxy, dir, ref_pid, cycle ); 396 405 #endif 397 406 398 407 // get user pointer on dirent array 399 408 ident = dir->ident; 400 401 // get pointers on reference process402 ref_xp = process->ref_xp;403 ref_cxy = GET_CXY( ref_xp );404 ref_ptr = GET_PTR( ref_xp );405 409 406 410 // build extended pointer on lock protecting open directories list … … 424 428 425 429 // get owner cluster identifier and process lpid 426 pid = process->pid; 427 owner_cxy = CXY_FROM_PID( pid ); 428 lpid = LPID_FROM_PID( pid ); 430 owner_cxy = CXY_FROM_PID( ref_pid ); 431 lpid = LPID_FROM_PID( ref_pid ); 429 432 430 433 // get root of list of copies and lock from owner cluster … … 444 447 rpc.thread = this; 445 448 rpc.lid = this->core->lid; 446 rpc.args[0] = process->pid;449 rpc.args[0] = ref_pid; 447 450 rpc.args[1] = ident; 448 451
Note: See TracChangeset
for help on using the changeset viewer.