Changeset 370 for soft/giet_vm/giet_common
- Timestamp:
- Jul 31, 2014, 9:11:26 PM (10 years ago)
- Location:
- soft/giet_vm/giet_common
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/giet_common/utils.c
r351 r370 375 375 : 376 376 : "r" (value), "r" (lsb), "r" (msb) 377 : "$2", "$3" ); 378 379 _it_restore(&sr); 380 } 381 382 //////////////////////////////////////////////////////////////////////////// 383 // This function makes a physical read access to a 64 bits word in memory, 384 // after a temporary DTLB de-activation and paddr extension. 385 //////////////////////////////////////////////////////////////////////////// 386 inline unsigned long long _physical_read_ull( unsigned long long paddr ) 387 { 388 unsigned int data_lsb; 389 unsigned int data_msb; 390 unsigned int addr_lsb = (unsigned int) paddr; 391 unsigned int addr_msb = (unsigned int) (paddr >> 32); 392 unsigned int sr; 393 394 _it_disable(&sr); 395 396 asm volatile( "mfc2 $2, $1 \n" /* $2 <= MMU_MODE */ 397 "andi $3, $2, 0xb \n" 398 "mtc2 $3, $1 \n" /* DTLB off */ 399 400 "mtc2 %3, $24 \n" /* PADDR_EXT <= msb */ 401 "lw %0, 0(%2) \n" /* data_lsb <= *paddr */ 402 "lw %1, 4(%2) \n" /* data_msb <= *paddr+4 */ 403 "mtc2 $0, $24 \n" /* PADDR_EXT <= 0 */ 404 405 "mtc2 $2, $1 \n" /* restore MMU_MODE */ 406 : "=r" (data_lsb), "=r"(data_msb) 407 : "r" (addr_lsb), "r" (addr_msb) 408 : "$2", "$3" ); 409 410 _it_restore(&sr); 411 412 return ( (((unsigned long long)data_msb)<<32) + 413 (((unsigned long long)data_lsb)) ); 414 } 415 416 //////////////////////////////////////////////////////////////////////////// 417 // This function makes a physical write access to a 64 bits word in memory, 418 // after a temporary DTLB de-activation and paddr extension. 419 //////////////////////////////////////////////////////////////////////////// 420 inline void _physical_write_ull( unsigned long long paddr, 421 unsigned long long value ) 422 { 423 unsigned int addr_lsb = (unsigned int)paddr; 424 unsigned int addr_msb = (unsigned int)(paddr >> 32); 425 unsigned int data_lsb = (unsigned int)value; 426 unsigned int data_msb = (unsigned int)(value >> 32); 427 unsigned int sr; 428 429 _it_disable(&sr); 430 431 asm volatile( "mfc2 $2, $1 \n" /* $2 <= MMU_MODE */ 432 "andi $3, $2, 0xb \n" 433 "mtc2 $3, $1 \n" /* DTLB off */ 434 435 "mtc2 %3, $24 \n" /* PADDR_EXT <= msb */ 436 "sw %0, 0(%2) \n" /* *paddr <= value */ 437 "sw %1, 4(%2) \n" /* *paddr+4 <= value */ 438 "mtc2 $0, $24 \n" /* PADDR_EXT <= 0 */ 439 440 "mtc2 $2, $1 \n" /* restore MMU_MODE */ 441 "sync \n" 442 : 443 : "r" (data_lsb), "r" (data_msb), "r" (addr_lsb), "r" (addr_msb) 377 444 : "$2", "$3" ); 378 445 … … 933 1000 934 1001 /////////////////////////////////////////////////////////////////////////////////// 935 // This function returns the information associated to a heap : size and vaddr. 1002 // This function returns the information associated to a heap : vaddr and length. 1003 // - If (x < X_SIZE) and (y < Y_SIZE), it return the heap associated to any task 1004 // running in cluster(x,y). 1005 // - Else, it return the heap associated to the calling task. 936 1006 // It uses the global task index (CTX_GTID_ID, unique for each giet task) and the 937 // vspace index (CTX_VSID_ID) defined in the task context. 1007 // vspace index (CTX_VSID_ID), that are defined in the calling task context 1008 // to find the vobj_id containing the heap. 1009 // Return 0 if success. Return non zero if not found. 938 1010 /////////////////////////////////////////////////////////////////////////////////// 939 1011 unsigned int _heap_info( unsigned int* vaddr, 940 unsigned int* size ) 1012 unsigned int* length, 1013 unsigned int x, 1014 unsigned int y ) 941 1015 { 942 1016 mapping_header_t * header = (mapping_header_t *)SEG_BOOT_MAPPING_BASE; 943 mapping_task_t * tasks = _get_task_base(header); 944 mapping_vobj_t * vobjs = _get_vobj_base(header); 945 946 unsigned int taskid = _get_context_slot(CTX_GTID_ID); 947 948 int vobj_id = tasks[taskid].heap_vobj_id; 949 if (vobj_id != -1) 950 { 951 *vaddr = vobjs[vobj_id].vaddr; 952 *size = vobjs[vobj_id].length; 1017 mapping_task_t * tasks = _get_task_base(header); 1018 mapping_vobj_t * vobjs = _get_vobj_base(header); 1019 mapping_vspace_t * vspaces = _get_vspace_base(header); 1020 1021 unsigned int task_id; 1022 unsigned int vspace_id; 1023 unsigned int vobj_id = 0xFFFFFFFF; 1024 1025 // searching the heap vobj_id 1026 if ( (x < X_SIZE) && (y < Y_SIZE) ) // searching a task in cluster(x,y) 1027 { 1028 // get vspace global index 1029 vspace_id = _get_context_slot(CTX_VSID_ID); 1030 1031 // scan all tasks in vspace 1032 unsigned int min = vspaces[vspace_id].task_offset ; 1033 unsigned int max = min + vspaces[vspace_id].tasks ; 1034 for ( task_id = min ; task_id < max ; task_id++ ) 1035 { 1036 if ( tasks[task_id].clusterid == (x * Y_SIZE + y) ) 1037 { 1038 vobj_id = tasks[task_id].heap_vobj_id; 1039 if ( vobj_id != 0xFFFFFFFF ) break; 1040 } 1041 } 1042 } 1043 else // searching in the calling task 1044 { 1045 task_id = _get_context_slot(CTX_GTID_ID); 1046 vobj_id = tasks[task_id].heap_vobj_id; 1047 } 1048 1049 // analysing the vobj_id 1050 if ( vobj_id != 0xFFFFFFFF ) 1051 { 1052 *vaddr = vobjs[vobj_id].vaddr; 1053 *length = vobjs[vobj_id].length; 1054 return 0; 953 1055 } 954 1056 else 955 1057 { 956 1058 *vaddr = 0; 957 * size= 0;958 }959 return 0;960 } 1059 *length = 0; 1060 return 1; 1061 } 1062 } // end _heap_info() 961 1063 962 1064 ///////////////////////////////////////////////////////////////////////////// -
soft/giet_vm/giet_common/utils.h
r351 r370 107 107 unsigned int value ); 108 108 109 extern unsigned long long _physical_read_ull( unsigned long long paddr ); 110 111 extern void _physical_write_ull( unsigned long long paddr, 112 unsigned long long value ); 113 109 114 extern void _physical_memcpy( unsigned long long dst_paddr, 110 115 unsigned long long src_paddr, … … 176 181 177 182 extern unsigned int _heap_info( unsigned int* vaddr, 178 unsigned int* size ); 183 unsigned int* length, 184 unsigned int x, 185 unsigned int y ); 179 186 180 187 ///////////////////////////////////////////////////////////////////////////////////
Note: See TracChangeset
for help on using the changeset viewer.