Changeset 709 for soft/giet_vm/giet_common/utils.c
- Timestamp:
- Oct 1, 2015, 4:20:46 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/giet_common/utils.c
r618 r709 16 16 #include <ctx_handler.h> 17 17 18 // This variable is allocated in theboot.c file or in kernel_init.c file19 extern static_scheduler_t* _schedulers[X_SIZE][Y_SIZE][NB_PROCS_MAX];18 // This variable is allocated in boot.c file or in kernel_init.c file 19 extern static_scheduler_t* _schedulers[X_SIZE][Y_SIZE][NB_PROCS_MAX]; 20 20 21 21 /////////////////////////////////////////////////////////////////////////// … … 23 23 /////////////////////////////////////////////////////////////////////////// 24 24 25 ///////////////////////// 26 unsigned int_get_sched()25 //////////////////////////////// 26 static_scheduler_t* _get_sched() 27 27 { 28 28 unsigned int ret; 29 29 asm volatile( "mfc0 %0, $4,2 \n" 30 30 : "=r"(ret) ); 31 return ret; 31 32 return (static_scheduler_t*)ret; 32 33 } 33 34 /////////////////////// … … 411 412 412 413 //////////////////////////////////////////////////////////////////////////// 413 // Scheduler and t asks context access functions414 // Scheduler and threads context access functions 414 415 //////////////////////////////////////////////////////////////////////////// 415 416 416 417 417 /////////////////////////////////// 418 unsigned int _get_current_task_id() 419 { 420 static_scheduler_t * psched = (static_scheduler_t *) _get_sched(); 421 return (unsigned int) (psched->current); 418 /////////////////////////////// 419 unsigned int _get_thread_ltid() 420 { 421 static_scheduler_t* psched = (static_scheduler_t *) _get_sched(); 422 return psched->current; 423 } 424 425 //////////////////////////////// 426 unsigned int _get_thread_trdid() 427 { 428 static_scheduler_t* psched = (static_scheduler_t *) _get_sched(); 429 unsigned int current = psched->current; 430 return psched->context[current].slot[CTX_TRDID_ID]; 431 } 432 433 ////////////////////////////////////////////// 434 unsigned int _get_thread_slot( unsigned int x, 435 unsigned int y, 436 unsigned int p, 437 unsigned int ltid, 438 unsigned int slotid ) 439 { 440 static_scheduler_t* psched = (static_scheduler_t*)_schedulers[x][y][p]; 441 return psched->context[ltid].slot[slotid]; 442 } 443 444 ////////////////////////////////////// 445 void _set_thread_slot( unsigned int x, 446 unsigned int y, 447 unsigned int p, 448 unsigned int ltid, 449 unsigned int slotid, 450 unsigned int value ) 451 { 452 static_scheduler_t* psched = (static_scheduler_t*)_schedulers[x][y][p]; 453 psched->context[ltid].slot[slotid] = value; 454 } 455 456 ///////////////////////////////////////////////////// 457 unsigned int _get_context_slot( unsigned int slotid ) 458 { 459 static_scheduler_t* psched = (static_scheduler_t*)_get_sched(); 460 unsigned int ltid = psched->current; 461 return psched->context[ltid].slot[slotid]; 422 462 } 423 463 424 464 //////////////////////////////////////////// 425 unsigned int _get_task_slot( unsigned int x, 426 unsigned int y, 427 unsigned int p, 428 unsigned int ltid, 429 unsigned int slot ) 430 { 431 static_scheduler_t* psched = (static_scheduler_t*)_schedulers[x][y][p]; 432 return psched->context[ltid][slot]; 433 } 434 435 //////////////////////////////////// 436 void _set_task_slot( unsigned int x, 437 unsigned int y, 438 unsigned int p, 439 unsigned int ltid, 440 unsigned int slot, 441 unsigned int value ) 442 { 443 static_scheduler_t* psched = (static_scheduler_t*)_schedulers[x][y][p]; 444 psched->context[ltid][slot] = value; 445 } 446 447 /////////////////////////////////////////////////// 448 unsigned int _get_context_slot( unsigned int slot ) 465 void _set_context_slot( unsigned int slotid, 466 unsigned int value ) 449 467 { 450 468 static_scheduler_t* psched = (static_scheduler_t*)_get_sched(); 451 unsigned int task_id = psched->current; 452 return psched->context[task_id][slot]; 453 } 454 455 /////////////////////////////////////////// 456 void _set_context_slot( unsigned int slot, 457 unsigned int value ) 458 { 459 static_scheduler_t* psched = (static_scheduler_t*)_get_sched(); 460 unsigned int task_id = psched->current; 461 psched->context[task_id][slot] = value; 469 unsigned int ltid = psched->current; 470 psched->context[ltid].slot[slotid] = value; 462 471 } 463 472 … … 496 505 MAPPING_VSPACE_SIZE * header->vspaces); 497 506 } 498 ////////////////////////////////////////////////////////// 499 mapping_t ask_t * _get_task_base(mapping_header_t * header)500 { 501 return (mapping_t ask_t *) ((char *) header +507 ////////////////////////////////////////////////////////////// 508 mapping_thread_t * _get_thread_base(mapping_header_t * header) 509 { 510 return (mapping_thread_t *) ((char *) header + 502 511 MAPPING_HEADER_SIZE + 503 512 MAPPING_CLUSTER_SIZE * X_SIZE * Y_SIZE + … … 515 524 MAPPING_VSPACE_SIZE * header->vspaces + 516 525 MAPPING_VSEG_SIZE * header->vsegs + 517 MAPPING_T ASK_SIZE * header->tasks);526 MAPPING_THREAD_SIZE * header->threads); 518 527 } 519 528 /////////////////////////////////////////////////////// … … 526 535 MAPPING_VSPACE_SIZE * header->vspaces + 527 536 MAPPING_VSEG_SIZE * header->vsegs + 528 MAPPING_T ASK_SIZE * header->tasks +537 MAPPING_THREAD_SIZE * header->threads + 529 538 MAPPING_PROC_SIZE * header->procs); 530 539 } … … 538 547 MAPPING_VSPACE_SIZE * header->vspaces + 539 548 MAPPING_VSEG_SIZE * header->vsegs + 540 MAPPING_T ASK_SIZE * header->tasks +549 MAPPING_THREAD_SIZE * header->threads + 541 550 MAPPING_PROC_SIZE * header->procs + 542 551 MAPPING_IRQ_SIZE * header->irqs);
Note: See TracChangeset
for help on using the changeset viewer.