Changeset 215 for soft/giet_vm
- Timestamp:
- Sep 17, 2012, 10:47:46 AM (12 years ago)
- Location:
- soft/giet_vm
- Files:
-
- 1 deleted
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/Makefile
r214 r215 44 44 TRASH= /dev/null||true 45 45 46 all: soft.elf46 all: map.bin soft.elf 47 47 48 48 ## merge all *.elf and map.bin to soft.elf … … 53 53 build/pgcd/pgcd.elf \ 54 54 build/hello/hello.elf \ 55 map.bin55 56 56 $(MAKE) -C memo 57 57 memo/memo.x map.bin … … 61 61 map.bin: $(MAP_XML) 62 62 $(MAKE) -C xml 63 xml/xml2bin $< $@63 xml/xml2bin $< . 64 64 65 65 ### system compilation … … 130 130 ### clean 131 131 clean: 132 rm -f *.o *.elf *.bin *.txt core *~2>$(TRASH)132 rm -f *.o *.elf *.bin *.txt core giet_vsegs.ld hard_config.h *~ 2>$(TRASH) 133 133 $(MAKE) -s clean -C xml 2>$(TRASH) 134 134 $(MAKE) -s clean -C memo 2>$(TRASH) -
soft/giet_vm/boot/boot_init.c
r210 r215 187 187 : "$26" ); 188 188 } 189 190 ////////////////////////////////////////////////////////////////////////////// 191 // boot_scheduler_get_itvector() 192 // This function get an interrupt vector slot in a scheduler, after a temporary 193 // desactivation of the DTLB (because we use the scheduler physical address). 194 // - gpid : global processor/scheduler index 195 // - slotid : context slot index 196 // - return the content of the slot 197 ////////////////////////////////////////////////////////////////////////////// 198 unsigned int boot_scheduler_get_itvector( unsigned int gpid, 199 unsigned int slotid) 200 { 201 unsigned int value; 202 203 // get scheduler physical address 204 static_scheduler_t* psched = boot_schedulers_paddr[gpid]; 205 206 // get slot physical address 207 unsigned int* pslot = &(psched->interrupt_vector[slotid]); 208 209 asm volatile ( "li $26, 0xB \n" 210 "mtc2 $26, $1 \n" /* desactivate DTLB */ 211 "lw %0, 0(%1) \n" /* *pslot <= value */ 212 "li $26, 0xF \n" 213 "mtc2 $26, $1 \n" /* activate DTLB */ 214 : "=r"(value) 215 : "r"(pslot) 216 : "$26" ); 217 return value; 218 } 219 189 220 ////////////////////////////////////////////////////////////////////////////// 190 221 // boot_scheduler_get_tasks() … … 286 317 void boot_puts(const char *buffer) 287 318 { 288 unsigned int* tty_address = (unsigned int*)( (char*)&seg_tty_base + 289 (CLUSTER_IO_ID * (unsigned)CLUSTER_SIZE) ); 319 unsigned int* tty_address = (unsigned int*) &seg_tty_base; 290 320 unsigned int n; 291 321 … … 915 945 if ( periph[periph_id].type == PERIPH_TYPE_TIM ) 916 946 { 917 if ( periph[periph_id].channels != (NB_PROCS_MAX + NB_TIMERS_MAX))947 if ( periph[periph_id].channels > NB_TIMERS_MAX ) 918 948 { 919 949 boot_puts("\n[BOOT ERROR] Too much user timers in cluster "); … … 1312 1342 1313 1343 //////// vci_io_bridge component 1314 else if ( (type == PERIPH_TYPE_IOB) && GIET_IOMMU_ACTIVE )1344 else if ( (type == PERIPH_TYPE_IOB) && IOMMU_ACTIVE ) 1315 1345 { 1316 1346 // get the iommu page table physical address … … 1435 1465 { 1436 1466 alloc_fbdma_channel[cluster_id] = 0; 1437 alloc_timer_channel[cluster_id] = NB_PROCS_MAX;1467 alloc_timer_channel[cluster_id] = 0; 1438 1468 } 1439 1469 … … 1560 1590 unsigned int ctx_ptpr = (unsigned int)boot_ptabs_paddr[vspace_id] >> 13; 1561 1591 1592 // compute gpid = global processor index 1593 unsigned int gpid = task[task_id].clusterid*NB_PROCS_MAX + 1594 task[task_id].proclocid; 1595 1562 1596 // ctx_ptab : page_table virtual base address 1563 1597 unsigned int ctx_ptab = (unsigned int)boot_ptabs_vaddr[vspace_id]; … … 1602 1636 { 1603 1637 unsigned int cluster_id = task[task_id].clusterid; 1604 if ( alloc_timer_channel[cluster_id] >= NB_TIMERS_MAX ) 1638 unsigned int allocated = alloc_timer_channel[cluster_id]; 1639 1640 if ( allocated >= NB_TIMERS_MAX ) 1605 1641 { 1606 1642 boot_puts("\n[BOOT ERROR] local TIMER index too large for task "); … … 1611 1647 boot_exit(); 1612 1648 } 1613 ctx_timer = cluster_id*NB_TIMERS_MAX + alloc_timer_channel[cluster_id]; 1614 alloc_timer_channel[cluster_id]++; 1649 1650 //assert(allocated >= 0); 1651 char found = 0; 1652 for( irq_id = 0; irq_id < 32; irq_id++)//look at the isr_timer isr channel 1653 { 1654 unsigned int isr = boot_scheduler_get_itvector(gpid, irq_id) && 0x000000FF; 1655 if(isr == ISR_TIMER) 1656 { 1657 if(allocated == 0) 1658 { 1659 found = 1; 1660 alloc_timer_channel[cluster_id]++; 1661 ctx_timer = cluster_id*NB_TIMERS_MAX + alloc_timer_channel[cluster_id]; 1662 break; 1663 }else 1664 allocated--; 1665 } 1666 } 1667 1668 if(!found) 1669 { 1670 boot_puts("\n[BOOT ERROR] No user timer available for task "); 1671 boot_puts( task[task_id].name ); 1672 boot_puts(" in vspace "); 1673 boot_puts( vspace[vspace_id].name ); 1674 boot_puts("\n"); 1675 boot_exit(); 1676 } 1677 1615 1678 } 1616 1679 … … 1642 1705 unsigned int vobj_id = task[task_id].vobjlocid + vspace[vspace_id].vobj_offset; 1643 1706 unsigned int ctx_sp = vobj[vobj_id].vaddr + vobj[vobj_id].length; 1644 1645 // compute gpid = global processor index1646 unsigned int gpid = task[task_id].clusterid*NB_PROCS_MAX +1647 task[task_id].proclocid;1648 1707 1649 1708 // In the code below, we access the scheduler with specific access -
soft/giet_vm/giet_config.h
r207 r215 10 10 #define _CONFIG_H 11 11 12 /* hardware parameters */ 13 #include "hard_config.h" 14 15 12 16 /* Debug parameters */ 13 17 … … 15 19 #define BOOT_DEBUG_PT 0 /* trace page tables initialisation on TTY0 */ 16 20 #define BOOT_DEBUG_VOBJS 0 /* trace vobjs initialisation on TTY0 */ 17 #define BOOT_DEBUG_SCHED 0/* trace schedulers initialisation on TTY0 */21 #define BOOT_DEBUG_SCHED 1 /* trace schedulers initialisation on TTY0 */ 18 22 19 23 #define GIET_DEBUG_INIT 0 /* trace parallel kernel initialisation on TTY0 */ 20 24 #define GIET_DEBUG_SWITCH 0 /* trace context switchs on TTY0 */ 21 25 22 23 26 #define CONFIG_SRL_VERBOSITY TRACE 24 25 /* hardware parameters */26 27 #define NB_CLUSTERS 4 /* number of clusters */28 #define CLUSTER_SIZE 0x40000000 /* address increment between clusters */29 #define CLUSTER_IO_ID 2 /* cluster containing non replicated peripherals */30 31 #define NB_PROCS_MAX 1 /* max number of processors per cluster */32 #define NB_TIMERS_MAX 0 /* max number of user timers per cluster */33 #define NB_DMAS_MAX 1 /* max number of DMA channels per cluster*/34 #define NB_TTYS 8 /* total number of TTY channels */35 #define NB_IOCS 1 /* total number of IOC channels */36 #define NB_NICS 8 /* total number of NIC channels */37 27 38 28 /* software parameters */ 39 29 40 #define GIET_NB_VSPACE_MAX 4 /* max number of virtual spaces */30 #define GIET_NB_VSPACE_MAX 64 /* max number of virtual spaces */ 41 31 #define GIET_TICK_VALUE 0x4000 /* context switch period (number of cycles) */ 42 #define GIET_IOMMU_ACTIVE 0 /* The IOMMU vspace is defined */43 #define GIET_USE_XICU 1 /* Use the XICU interrupt controler */44 32 45 33 #endif -
soft/giet_vm/libs/libsrl/srl_args.h
r213 r215 11 11 12 12 13 # define SRL_GET_VBASE(task_name, port, type) 14 ({ 13 # define SRL_GET_VBASE(task_name, port, type) \ 14 ({ \ 15 15 unsigned int vbase; \ 16 if( giet_vobj_get_vbase( APP_NAME , alias_##task_name.port, type, &vbase ) ) 17 { 18 srl_log_printf( NONE, "\n[ERROR] in "#task_name" task :\n"); 19 srl_log_printf( NONE, " undefined port <"#port"> for channel(%s): %d\n", 20 alias_##task_name.port,vbase); 21 srl_log_printf( TRACE, "*** &"#port" = %x\n\n", vbase ); 22 srl_exit(); 23 }else 24 srl_log_printf( TRACE, "%s:%d: arg of %s for %s,from %s; &"#port" = %x\n\n", 25 __FILE__, __LINE__, APP_NAME, #task_name,#port, vbase ); 16 if( giet_vobj_get_vbase( APP_NAME , alias_##task_name.port, type, &vbase ) ) \ 17 { \ 18 srl_log_printf( NONE, "\n[ERROR] in "#task_name" task :\n"); \ 19 srl_log_printf( NONE, " undefined port <"#port"> for channel(%s): %d\n", \ 20 alias_##task_name.port,vbase); \ 21 srl_log_printf( TRACE, "*** &"#port" = %x\n\n", vbase ); \ 22 srl_exit(); \ 23 }else \ 24 srl_log_printf( TRACE, "%s:%d: arg of %s for %s,from %s; &"#port" = %x\n\n", \ 25 __FILE__, __LINE__, APP_NAME, #task_name,#port, vbase ); \ 26 26 vbase;\ 27 27 }) -
soft/giet_vm/mappings/1c_4p_four.xml
r214 r215 1 1 <?xml version="1.0"?> 2 2 3 <mapping_info signature = "0xdeadbeef" name = "1c_4p_four" cluster s= "1" vspaces = "4" >3 <mapping_info signature = "0xdeadbeef" name = "1c_4p_four" cluster_x = "1" cluster_y = "1" vspaces = "4" > 4 4 5 5 *** This section describes an instance of the "caba_vgsb_xicu_mmu" generic architecture … … 71 71 <periph type = "TTY" psegname = "PSEG_TTY" channels = "8" /> 72 72 <periph type = "DMA" psegname = "PSEG_DMA" channels = "1" /> 73 <periph type = "TIM" psegname = "PSEG_TIM" channels = "4" /> 74 <periph type = "XICU" psegname = "PSEG_ICU" channels = "5" /> 73 75 <periph type = "FBF" psegname = "PSEG_FBF" /> 74 76 -
soft/giet_vm/mappings/4c_1p_four.xml
r214 r215 1 1 <?xml version="1.0"?> 2 2 3 <mapping_info signature = "0xdeadbeef" name = "C4_P1_FOUR" cluster s = "4" vspaces = "4" >3 <mapping_info signature = "0xdeadbeef" name = "C4_P1_FOUR" cluster_x = "2" cluster_y = "2" vspaces = "4" > 4 4 5 5 <clusterset> … … 8 8 9 9 <pseg name = "PSEG_RAM" type = "RAM" base = "0x00000000" length = "0x00C00000" /> 10 <pseg name = "PSEG_ ICU" type = "PERI" base = "0x00F00000" length = "0x00001000" />10 <pseg name = "PSEG_XICU" type = "PERI" base = "0x00F00000" length = "0x00002000" /> 11 11 <pseg name = "PSEG_DMA" type = "PERI" base = "0x00F30000" length = "0x00008000" /> 12 12 … … 17 17 18 18 <periph type = "DMA" psegname = "PSEG_DMA" channels = "1" /> 19 <periph type = "XICU" psegname = "PSEG_XICU" channels = "2" /> 19 20 20 21 </cluster> … … 22 23 23 24 <pseg name = "PSEG_RAM" type = "RAM" base = "0x40000000" length = "0x00C00000" /> 24 <pseg name = "PSEG_ ICU" type = "PERI" base = "0x40F00000" length = "0x00001000" />25 <pseg name = "PSEG_XICU" type = "PERI" base = "0x40F00000" length = "0x00002000" /> 25 26 <pseg name = "PSEG_DMA" type = "PERI" base = "0x40F30000" length = "0x00008000" /> 26 27 … … 31 32 32 33 <periph type = "DMA" psegname = "PSEG_DMA" channels = "1" /> 34 <periph type = "XICU" psegname = "PSEG_XICU" channels = "2" /> 33 35 34 36 </cluster> … … 36 38 37 39 <pseg name = "PSEG_RAM" type = "RAM" base = "0x80000000" length = "0x00C00000" /> 38 <pseg name = "PSEG_ ICU" type = "PERI" base = "0x80F00000" length = "0x00001000" />40 <pseg name = "PSEG_XICU" type = "PERI" base = "0x80F00000" length = "0x00002000" /> 39 41 <pseg name = "PSEG_DMA" type = "PERI" base = "0x80F30000" length = "0x00008000" /> 40 42 … … 69 71 70 72 <periph type = "DMA" psegname = "PSEG_DMA" channels = "1" /> 73 <periph type = "XICU" psegname = "PSEG_XICU" channels = "18" /> 71 74 <periph type = "IOC" psegname = "PSEG_IOC" channels = "1" /> 72 75 <periph type = "TTY" psegname = "PSEG_TTY" channels = "8" /> … … 78 81 79 82 <pseg name = "PSEG_RAM" type = "RAM" base = "0xC0000000" length = "0x00C00000" /> 80 <pseg name = "PSEG_ ICU" type = "PERI" base = "0xC0F00000" length = "0x00001000" />83 <pseg name = "PSEG_XICU" type = "PERI" base = "0xC0F00000" length = "0x00001000" /> 81 84 <pseg name = "PSEG_DMA" type = "PERI" base = "0xC0F30000" length = "0x00008000" /> 82 85 … … 87 90 88 91 <periph type = "DMA" psegname = "PSEG_DMA" channels = "1" /> 92 <periph type = "XICU" psegname = "PSEG_XICU" channels = "2" /> 89 93 </cluster> 90 94 </clusterset> … … 135 139 *** On peut aussi définir un vseg factorisé en introduisant le CLUSTER_SIZE... 136 140 137 <vseg name = "seg_icu_0" vbase = "0x00F00000" mode = "__W_" clusterid = "0" psegname = "PSEG_ ICU" >141 <vseg name = "seg_icu_0" vbase = "0x00F00000" mode = "__W_" clusterid = "0" psegname = "PSEG_XICU" > 138 142 <vobj name = "icu_0" type = "PERI" length = "0x00001000" /> 139 143 </vseg> 140 <vseg name = "seg_icu_1" vbase = "0x40F00000" mode = "__W_" clusterid = "1" psegname = "PSEG_ ICU" >144 <vseg name = "seg_icu_1" vbase = "0x40F00000" mode = "__W_" clusterid = "1" psegname = "PSEG_XICU" > 141 145 <vobj name = "icu_1" type = "PERI" length = "0x00001000" /> 142 146 </vseg> 143 <vseg name = "seg_icu_2" vbase = "0x80F00000" mode = "__W_" clusterid = "2" psegname = "PSEG_ ICU" >147 <vseg name = "seg_icu_2" vbase = "0x80F00000" mode = "__W_" clusterid = "2" psegname = "PSEG_XICU" > 144 148 <vobj name = "icu_2" type = "PERI" length = "0x00001000" /> 145 149 </vseg> 146 <vseg name = "seg_icu_3" vbase = "0xC0F00000" mode = "__W_" clusterid = "3" psegname = "PSEG_ ICU" >150 <vseg name = "seg_icu_3" vbase = "0xC0F00000" mode = "__W_" clusterid = "3" psegname = "PSEG_XICU" > 147 151 <vobj name = "icu_3" type = "PERI" length = "0x00001000" /> 148 152 </vseg> -
soft/giet_vm/mappings/exemple.xml
r214 r215 3 3 <mapping_info signature = "0xdeadbeef" 4 4 name = "1C_4P_FOUR" 5 clusters = "1" 6 vspaces = "4" > 5 vspaces = "4" 6 cluster_x = "1" 7 cluster_y = "1" > 7 8 8 9 <clusterset> … … 212 213 channels = "8" /> 213 214 215 <periph type = "ICU" 216 psegname = "PSEG_ICU" 217 channels = "8" /> 218 214 219 <periph type = "FBF" 215 220 psegname = "PSEG_FBF" /> -
soft/giet_vm/memo/src/memo.cpp
r212 r215 39 39 #include "memo.h" 40 40 41 //#define MOVER_DEBUG 41 //#define MOVER_DEBUG 42 42 43 43 MeMo::MeMo( const std::string &filename, … … 258 258 std::cout << std::hex << "mapping_info" << std::dec << std::endl 259 259 << " + signature = " << header->signature << std::endl 260 << " + name = " << header->name << std::endl260 << " + name = " << (char*)header->name << std::endl 261 261 << " + clusters = " << header->clusters << std::endl 262 262 << " + psegs = " << header->psegs << std::endl … … 279 279 { 280 280 std::cout << std::endl; 281 //std::cout << vseg[vseg_id].psegid << std::endl; 281 282 std::cout << "global vseg " << vseg[vseg_id].name << std::hex << std::endl 282 283 << " + vbase = " << vseg[vseg_id].vbase << std::endl -
soft/giet_vm/sys/common.c
r207 r215 158 158 void _puts(char* buffer) 159 159 { 160 unsigned int* tty_address = (unsigned int*)( (char*)&seg_tty_base + 161 (CLUSTER_IO_ID * (unsigned)CLUSTER_SIZE) ); 160 unsigned int* tty_address = (unsigned int*) &seg_tty_base; 162 161 unsigned int n; 163 162 -
soft/giet_vm/sys/drivers.c
r213 r215 17 17 // 18 18 // The following global parameters must be defined in the giet_config.h file: 19 // - CLUSTER_IO_ID20 19 // - CLUSTER_SIZE 21 20 // - NB_CLUSTERS … … 48 47 49 48 #if !defined(NB_CLUSTERS) 50 # error: You must define NB_CLUSTERS in 'giet_config.h'file49 # error: You must define NB_CLUSTERS in the configs file 51 50 #endif 52 51 53 52 #if !defined(NB_PROCS_MAX) 54 # error: You must define NB_PROCS_MAX in 'giet_config.h'file53 # error: You must define NB_PROCS_MAX in the configs file 55 54 #endif 56 55 … … 60 59 61 60 #if !defined(CLUSTER_SIZE) 62 # error: You must define CLUSTER_SIZE in 'giet_config.h'file61 # error: You must define CLUSTER_SIZE in the configs file 63 62 #endif 64 63 65 64 #if !defined(NB_TTYS) 66 # error: You must define NB_TTYS in 'giet_config.h'file65 # error: You must define NB_TTYS in the configs file 67 66 #endif 68 67 … … 84 83 85 84 #if !defined(NB_IOCS) 86 # error: You must define NB_IOCS in 'giet_config.h'file85 # error: You must define NB_IOCS in the configs file 87 86 #endif 88 87 89 88 #if ( NB_IOCS > 1 ) 90 89 # error: NB_IOCS cannot be larger than 1 90 #endif 91 92 #if !defined( USE_XICU ) 93 # error: You must define USE_XICU in the configs file 94 #endif 95 96 #if !defined( IOMMU_ACTIVE ) 97 # error: You must define IOMMU_ACTIVE in the configs file 91 98 #endif 92 99 … … 98 105 ////////////////////////////////////////////////////////////////////////////// 99 106 // The timers can be implemented in a vci_timer component or in a vci_xicu 100 // component (depending on the GIET_USE_XICU parameter).107 // component (depending on the USE_XICU parameter). 101 108 // There is one timer (or xicu) component per cluster. 102 109 // There is two types of timers: … … 132 139 if ( local_id >= NB_TIMERS_MAX + NB_PROCS_MAX ) return 1; 133 140 134 #if GIET_USE_XICU141 #if USE_XICU 135 142 unsigned int* timer_address = (unsigned int*)((char*)&seg_icu_base + 136 143 (cluster_id * CLUSTER_SIZE) ); … … 160 167 if ( local_id >= NB_TIMERS_MAX + NB_PROCS_MAX ) return 1; 161 168 162 #if GIET_USE_XICU169 #if USE_XICU 163 170 unsigned int* timer_address = (unsigned int*)((char*)&seg_icu_base + 164 171 (cluster_id * CLUSTER_SIZE) ); … … 189 196 if ( local_id >= NB_TIMERS_MAX + NB_PROCS_MAX ) return 1; 190 197 191 #if GIET_USE_XICU198 #if USE_XICU 192 199 unsigned int* timer_address = (unsigned int*)((char*)&seg_icu_base + 193 200 (cluster_id * (unsigned)CLUSTER_SIZE) ); … … 260 267 } 261 268 262 unsigned int* tty_address = (unsigned int*)( (char*)&seg_tty_base + 263 (CLUSTER_IO_ID * (unsigned)CLUSTER_SIZE) ); 269 unsigned int* tty_address = (unsigned int*) &seg_tty_base; 264 270 265 271 for (nwritten = 0; nwritten < length; nwritten++) … … 322 328 323 329 // compute terminal base address 324 unsigned int *tty_address = (unsigned int*)( (char*)&seg_tty_base + 325 (CLUSTER_IO_ID * (unsigned)CLUSTER_SIZE) ); 330 unsigned int *tty_address = (unsigned int*) &seg_tty_base; 326 331 327 332 *buffer = (unsigned char)tty_address[tty_id*TTY_SPAN + TTY_READ]; … … 355 360 unsigned int* icu_address = (unsigned int*)( (char*)&seg_icu_base + 356 361 (cluster_id * (unsigned)CLUSTER_SIZE) ); 357 #if GIET_USE_XICU362 #if USE_XICU 358 363 if ( is_timer ) icu_address[XICU_REG(XICU_MSK_PTI_ENABLE, proc_id)] = value; 359 364 else icu_address[XICU_REG(XICU_MSK_HWI_ENABLE, proc_id)] = value; … … 381 386 unsigned int* icu_address = (unsigned int*)( (char*)&seg_icu_base + 382 387 (cluster_id * (unsigned)CLUSTER_SIZE) ); 383 #if GIET_USE_XICU388 #if USE_XICU 384 389 unsigned int prio = icu_address[XICU_REG(XICU_PRIO, proc_id)]; 385 390 unsigned int pti_ok = (prio & 0x00000001); … … 420 425 return 1; 421 426 422 unsigned int* gcd_address = (unsigned int*)( (char*)&seg_gcd_base + 423 (CLUSTER_IO_ID * (unsigned)CLUSTER_SIZE) ); 427 unsigned int* gcd_address = (unsigned int*) &seg_gcd_base; 424 428 425 429 gcd_address[register_index] = value; // write word … … 438 442 return 1; 439 443 440 unsigned int* gcd_address = (unsigned int*)( (char*)&seg_gcd_base + 441 (CLUSTER_IO_ID * (unsigned)CLUSTER_SIZE) ); 444 unsigned int* gcd_address = (unsigned int*) &seg_gcd_base; 442 445 443 446 *buffer = gcd_address[register_index]; // read word … … 530 533 if ( (unsigned int)user_vaddr & 0x3 ) return 1; 531 534 532 unsigned int* ioc_address = (unsigned int*)( (char*)&seg_ioc_base + 533 (CLUSTER_IO_ID * (unsigned)CLUSTER_SIZE) ); 535 unsigned int* ioc_address = (unsigned int*) &seg_ioc_base ; 534 536 535 537 unsigned int block_size = ioc_address[BLOCK_DEVICE_BLOCK_SIZE]; … … 561 563 if ( ix2 == 0 ) ppn_first = ppn; 562 564 563 if ( GIET_IOMMU_ACTIVE ) // the user buffer must be remapped in the I/0 space565 if ( IOMMU_ACTIVE ) // the user buffer must be remapped in the I/0 space 564 566 { 565 567 // check buffer length < 2 Mbytes … … 588 590 589 591 // compute buffer base address for IOC depending on IOMMU activation 590 if ( GIET_IOMMU_ACTIVE ) addr = (_ioc_iommu_ix1) << 21 | (user_vaddr & 0xFFF);592 if ( IOMMU_ACTIVE ) addr = (_ioc_iommu_ix1) << 21 | (user_vaddr & 0xFFF); 591 593 else addr = (ppn_first << 12) | (user_vaddr & 0xFFF); 592 594 … … 622 624 623 625 // unmap the buffer from IOMMU page table if IOMMU is activated 624 if ( GIET_IOMMU_ACTIVE ) 625 { 626 unsigned int* iob_address = (unsigned int*)( (char*)&seg_iob_base + 627 (CLUSTER_IO_ID * (unsigned)CLUSTER_SIZE) ); 626 if ( IOMMU_ACTIVE ) 627 { 628 unsigned int* iob_address = (unsigned int*) &seg_iob_base; 628 629 629 630 for ( ix2 = 0 ; ix2 < _ioc_iommu_npages ; ix2++ ) … … 691 692 { 692 693 // get IOC base address 693 unsigned int* ioc_address = (unsigned int*)( (char*)&seg_ioc_base + 694 (CLUSTER_IO_ID * (unsigned)CLUSTER_SIZE) ); 694 unsigned int* ioc_address = (unsigned int*) &seg_ioc_base; 695 695 696 696 *status = ioc_address[BLOCK_DEVICE_STATUS]; // read status & reset IRQ … … 891 891 892 892 // compute frame buffer pbase address 893 unsigned int fb_vaddr = (unsigned int)&seg_fbf_base + 894 (CLUSTER_IO_ID * (unsigned int)CLUSTER_SIZE) + offset; 893 unsigned int fb_vaddr = (unsigned int)&seg_fbf_base + offset; 895 894 896 895 ko = _v2p_translate( (page_table_t*)user_ptab, … … 962 961 if ( ix2 == 0 ) ppn_first = ppn; 963 962 964 if ( GIET_IOMMU_ACTIVE ) // the user buffer must be remapped in the I/0 space963 if ( IOMMU_ACTIVE ) // the user buffer must be remapped in the I/0 space 965 964 { 966 965 // check buffer length < 2 Mbytes … … 1071 1070 1072 1071 // unmap the buffer from IOMMU page table if IOMMU is activated 1073 if ( GIET_IOMMU_ACTIVE ) 1074 { 1075 unsigned int* iob_address = (unsigned int*)( (char*)&seg_iob_base + 1076 (CLUSTER_IO_ID * (unsigned)CLUSTER_SIZE) ); 1072 if ( IOMMU_ACTIVE ) 1073 { 1074 unsigned int* iob_address = (unsigned int*) &seg_iob_base; 1077 1075 1078 1076 unsigned int ix1 = _dma_iommu_ix1 + dma_id; -
soft/giet_vm/sys/irq_handler.c
r213 r215 18 18 #include <ctx_handler.h> 19 19 #include <hwr_mapping.h> 20 21 #if NB_TIMERS_MAX 22 extern volatile unsigned char _user_timer_event[NB_CLUSTERS*NB_TIMERS_MAX] ; 23 #endif 20 24 21 25 /////////////////////////////////////////////////////////////////////////////////// -
soft/giet_vm/sys/kernel_init.c
r207 r215 48 48 unsigned int _idle_stack[NB_CLUSTERS*NB_PROCS_MAX*64]; 49 49 50 void _sys_exit() 51 { 52 while(1); 53 } 54 50 55 ////////////////////////////////////////////////////////////////////////////////// 51 56 // This function is the entry point for the last step of the boot sequence. … … 127 132 unsigned int pti_mask = 0; 128 133 134 unsigned int isr_switch_channel = 0xFFFFFFFF; 135 129 136 for ( irq_id = 0 ; irq_id < 32 ; irq_id++ ) 130 137 { … … 136 143 hwi_mask = hwi_mask | 0x1<< irq_id; 137 144 } 138 else if ( (isr == ISR_SWITCH) || (isr == ISR_TIMER))145 else if ( (isr == ISR_SWITCH) ) 139 146 { 147 pti_mask = pti_mask | 0x1<< irq_id; 148 isr_switch_channel = irq_id; 149 } 150 else if ( (isr == ISR_TIMER) ) 151 { 140 152 pti_mask = pti_mask | 0x1<< irq_id; 141 153 } … … 159 171 if ( tasks > 1 ) 160 172 { 173 if(isr_switch_channel == 0xFFFFFFFF) 174 { 175 _puts("\n[GIET ERROR] ISR_SWITCH not found on proc "); 176 _putd( proc_id); 177 _puts("\n"); 178 _sys_exit(); 179 } 161 180 _timer_start( cluster_id, 162 proc_id,181 isr_switch_channel, 163 182 GIET_TICK_VALUE ); 164 183 -
soft/giet_vm/sys/sys_handler.c
r207 r215 139 139 } 140 140 141 ///////////////////////////////////////////////////////////////////////////// 142 // _vobj_get_vbase() 143 // This function writes in vobj_buffer the virtual base address of a vobj 144 // identified by the (vspace_name / vobj_name ) couple. 145 // The vobj_type argument is redundant, and for checking purpose. 146 // returns 0: success, else: failed. 147 ///////////////////////////////////////////////////////////////////////////// 148 unsigned int _vobj_get_vbase( char* vspace_name, 149 char* vobj_name, 150 unsigned int vobj_type, 151 unsigned int* vobj_vaddr ) 141 int _get_vobj( char* vspace_name, char* vobj_name, unsigned int vobj_type, mapping_vobj_t** res_vobj) 152 142 { 153 143 mapping_header_t* header = (mapping_header_t*)&seg_mapping_base; … … 175 165 return -1; //wrong type 176 166 177 *vobj_vaddr = (unsigned int)vobj[vobj_id].vaddr; 167 *res_vobj = &vobj[vobj_id]; 168 178 169 return 0; 179 170 } … … 182 173 } 183 174 return -2; //not found 184 } 185 175 176 } 177 ///////////////////////////////////////////////////////////////////////////// 178 // _vobj_get_vbase() 179 // This function writes in vobj_vaddr the virtual base address of a vobj 180 // identified by the (vspace_name / vobj_name ) couple. 181 // The vobj_type argument is here only for the purpose of checking . 182 // returns 0: success, else: failed. 183 ///////////////////////////////////////////////////////////////////////////// 184 unsigned int _vobj_get_vbase( char* vspace_name, 185 char* vobj_name, 186 unsigned int vobj_type, 187 unsigned int* vobj_vaddr ) 188 { 189 mapping_vobj_t* res_vobj; 190 unsigned int ret; 191 if( (ret = _get_vobj(vspace_name, vobj_name, vobj_type, &res_vobj)) ) 192 { 193 return ret; 194 } 195 196 *vobj_vaddr = res_vobj->vaddr; 197 198 return 0; 199 } 200 201 ///////////////////////////////////////////////////////////////////////////// 202 // _vobj_get_length() 203 // This function writes in vobj_length the virtual base address of a vobj 204 // identified by the (vspace_name / vobj_name ) couple. 205 // The vobj_type argument is here only for the purpose of checking . 206 // returns 0: success, else: failed. 207 ///////////////////////////////////////////////////////////////////////////// 208 unsigned int _vobj_get_length(char* vspace_name, 209 char* vobj_name, 210 unsigned int vobj_type, 211 unsigned int* vobj_length ) 212 { 213 214 mapping_vobj_t* res_vobj; 215 unsigned int ret; 216 if( (ret = _get_vobj(vspace_name, vobj_name, vobj_type, &res_vobj)) ) 217 { 218 return ret; 219 } 220 221 *vobj_length = res_vobj->length; 222 223 return 0; 224 } -
soft/giet_vm/xml/mapping_info.h
r200 r215 71 71 enum periphType 72 72 { 73 PERIPH_TYPE_I OC= 0,74 PERIPH_TYPE_T TY= 1,75 PERIPH_TYPE_ TIM= 2,73 PERIPH_TYPE_ICU = 0, 74 PERIPH_TYPE_TIM = 1, 75 PERIPH_TYPE_XICU = 2, 76 76 PERIPH_TYPE_DMA = 3, 77 PERIPH_TYPE_FBF = 4, 78 PERIPH_TYPE_NIC = 5, 79 PERIPH_TYPE_IOB = 6, 77 PERIPH_TYPE_IOC = 4, 78 PERIPH_TYPE_TTY = 5, 79 PERIPH_TYPE_FBF = 6, 80 PERIPH_TYPE_NIC = 7, 81 PERIPH_TYPE_IOB = 8, 80 82 }; 81 83 … … 92 94 unsigned int signature; // must contain MAPPING_SIGNATURE 93 95 unsigned int clusters; // number of clusters 96 unsigned int cluster_x; // number of cluster on the abcsisse axe 97 unsigned int cluster_y; // number of cluster on the ordinate axe 94 98 unsigned int globals; // number of vsegs mapped in all vspaces 95 99 unsigned int vspaces; // number of virtual spaces -
soft/giet_vm/xml/xml_driver.c
r204 r215 57 57 const char* periph_type[] = 58 58 { 59 "ICU", 60 "TIM", 61 "XICU", 62 "DMA", 59 63 "IOC", 60 64 "TTY", 61 "TIM",62 "DMA",63 65 "FBF", 64 66 "NIC", … … 220 222 fprintf( fpout, "<mapping_info signature = \"0x%x\" ", header->signature); 221 223 fprintf( fpout, " name = \"%s\" ", header->name); 222 fprintf( fpout, " clusters = \"%d\" ", header->clusters); 224 fprintf( fpout, " cluster_x = \"%d\" ", header->cluster_x); 225 fprintf( fpout, " cluster_y = \"%d\" ", header->cluster_y); 223 226 fprintf( fpout, " vspaces = \"%d\" >\n\n", header->vspaces); 224 227 … … 241 244 ///////////////////// processors ///////////////////////////////////////////// 242 245 246 unsigned int proc_index = 0; 243 247 for ( proc_id = cluster[cluster_id].proc_offset ; 244 248 proc_id < cluster[cluster_id].proc_offset + cluster[cluster_id].procs ; 245 249 proc_id++ ) 246 250 { 247 fprintf( fpout, " <proc index = \"%d\" >\n", proc_i d);251 fprintf( fpout, " <proc index = \"%d\" >\n", proc_index); 248 252 for ( irq_id = proc[proc_id].irq_offset ; 249 253 irq_id < proc[proc_id].irq_offset + proc[proc_id].irqs ; -
soft/giet_vm/xml/xml_parser.c
r206 r215 86 86 unsigned int vobj_count = 0; 87 87 88 /////////////////////////////////////////////////////////////////////// 88 89 ///////////////////////// 90 // found peripheral 91 ///////////////////////// 92 char found_timer = 0; 93 char found_icu = 0; 94 char found_xicu = 0; 95 char found_dma = 0; 96 97 98 ////////////////////////////////// 99 //needed to generate map_config.ld 100 ////////////////////////////////// 101 unsigned int cluster_y = 0; 102 unsigned int cluster_x = 0; 103 unsigned int nb_proc_max = 0; // max number of processors per cluster 104 unsigned int nb_timer_channel_max = 0; // max number of user timer 105 unsigned int nb_dma_channel_max = 0; 106 unsigned int nb_tty_channel = 0; 107 unsigned int nb_ioc_channel = 0; 108 unsigned int nb_nic_channel = 0; 109 unsigned int io_mmu_active = 0; 110 unsigned int use_xicu = 0xFFFFFFFF; 111 112 113 ////////////////////////////////// 114 //needed to generate giet_vseg.ld 115 ////////////////////////////////// 116 117 //kernel and boot code 118 unsigned int kernel_code_base = 0x80000000; /* kernel code */ 119 unsigned int kernel_data_base = 0x80010000; /* system cacheable data */ 120 unsigned int kernel_uncdata_base = 0x80080000; /* system uncacheable data */ 121 unsigned int kernel_init_base = 0x80090000; /* system init entry */ 122 123 unsigned int boot_code_base = 0xBFC00000; /* boot code */ 124 unsigned int boot_stack_base = 0xBFC08000; /* boot temporary stack */ 125 unsigned int boot_mapping_base = 0xBFC0C000; /* mapping_info blob */ 126 127 //periphs 128 unsigned int tim_base_offset = 0xFFFFFFFF; 129 unsigned int tty_base_offset = 0xFFFFFFFF; 130 unsigned int dma_base_offset = 0xFFFFFFFF; 131 unsigned int ioc_base_offset = 0xFFFFFFFF; 132 unsigned int fbf_base_offset = 0xFFFFFFFF; 133 unsigned int icu_base_offset = 0xFFFFFFFF; 134 unsigned int gcd_base_offset = 0xFFFFFFFF; 135 unsigned int iob_base_offset = 0xFFFFFFFF; 136 137 138 ////////////////////////////////////////////////////////////////////// 89 139 // This arrray is useful to build a temporary list of vobj references. 90 140 // The struct vobj_ref_s is formed by a vspace_name and a vobj_name. 91 141 // This array is used to set the attribute vobj_id of a cp_port 92 142 // once all the vspace have been parsed. 93 143 ///////////////////////////////////////////////////////////////////// 94 144 typedef struct vobj_ref_s 95 145 { … … 159 209 char* string = (char*)xmlTextReaderGetAttribute(reader, (const xmlChar*)attributeName); 160 210 211 161 212 if ( string == NULL ) // missing argument 162 213 { … … 166 217 else 167 218 { 219 //we read only string smaller than 32 byte 220 if(strlen(string) > 32) 221 { 222 printf("[XML ERROR] all strings must be less than 32 bytes\n"); 223 exit(1); 224 } 225 168 226 *ok = 1; 169 227 return string; … … 181 239 for ( pseg_id = pseg_min ; pseg_id < pseg_max ; pseg_id++ ) 182 240 { 183 if ( strcmp(pseg[pseg_id]->name, pseg_name) == 0 ) return pseg_id; 241 if ( strcmp(pseg[pseg_id]->name, pseg_name) == 0 ) 242 { 243 return pseg_id; 244 } 184 245 } 185 246 return -1; … … 219 280 return -1; 220 281 } 221 222 ///////////////////////////////////////////223 void cpPortNode ( xmlTextReaderPtr reader )224 ///////////////////////////////////////////225 {226 char* str;227 unsigned int ok;228 229 if ( xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT ) return;230 231 if ( cp_port_index >= MAX_CP_PORTS )232 {233 printf("[XML ERROR] The number of ports (for coprocs) is larger than %d\n", MAX_CP_PORTS);234 }235 236 #if XML_PARSER_DEBUG237 printf("\n port %d\n", cp_port_index);238 #endif239 240 cp_port[cp_port_index] = (mapping_cp_port_t*)malloc(sizeof(mapping_cp_port_t));241 cp_port_vobj_ref[cp_port_index] = (vobj_ref_t*)malloc(sizeof(vobj_ref_t));242 243 244 245 ///////// get direction attribute246 str = getStringValue( reader, "direction", &ok );247 if ( ok )248 {249 #if XML_PARSER_DEBUG250 printf(" direction = %s\n", str);251 #endif252 if ( strcmp(str, "TO_COPROC") == 0 ) cp_port[cp_port_index]->direction = PORT_TO_COPROC;253 else if ( strcmp(str, "FROM_COPROC") == 0 ) cp_port[cp_port_index]->direction = PORT_FROM_COPROC;254 else255 {256 printf("[XML ERROR] illegal <direction> for cp_port %d in cluster %d\n",257 cp_port_index, cluster_index);258 exit(1);259 }260 }261 else262 {263 printf("[XML ERROR] missing <direction> for cp_port %d in cluster %d\n",264 cp_port_index, cluster_index);265 exit(1);266 }267 268 /////////// get vspacename attribute269 str = getStringValue( reader, "vspacename", &ok );270 #if XML_PARSER_DEBUG271 printf(" vspacename = %s\n", str);272 #endif273 if ( ok )274 {275 strncpy(cp_port_vobj_ref[cp_port_index]->vspace_name, str, 31);276 }277 else278 {279 printf("[XML ERROR] missing <vspacename> for cp_port %d in cluster %d\n",280 cp_port_index, cluster_index);281 exit(1);282 }283 284 /////////// get vobjname attribute285 str = getStringValue( reader, "vobjname", &ok );286 #if XML_PARSER_DEBUG287 printf(" vobjname = %s\n", str);288 #endif289 if ( ok )290 {291 strncpy(cp_port_vobj_ref[cp_port_index]->vobj_name, str, 31);292 }293 else294 {295 printf("[XML ERROR] missing <vobjname> for cp_port %d in cluster %d\n",296 cp_port_index, cluster_index);297 exit(1);298 }299 300 cp_port_index++;301 cp_port_loc_index++;302 303 } // end cpPortNode()304 305 ///////////////////////////////////////////306 void periphNode ( xmlTextReaderPtr reader )307 ///////////////////////////////////////////308 {309 char* str;310 unsigned int value;311 unsigned int ok;312 313 if ( xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT ) return;314 315 if ( periph_index >= MAX_PERIPHS )316 {317 printf("[XML ERROR] The number of periphs is larger than %d\n", MAX_PERIPHS);318 }319 320 #if XML_PARSER_DEBUG321 printf("\n periph %d\n", periph_index);322 #endif323 324 periph[periph_index] = (mapping_periph_t*)malloc(sizeof(mapping_periph_t));325 326 /////////// get type attribute327 str = getStringValue( reader, "type", &ok );328 if ( ok )329 {330 #if XML_PARSER_DEBUG331 printf(" type = %s\n", str);332 #endif333 unsigned int error = 0;334 335 // The TTY, IOC, NIC, FBF and IOB peripherals cannot be replicated336 if ( strcmp( str, "IOC" ) == 0 )337 {338 periph[periph_index]->type = PERIPH_TYPE_IOC;339 if ( header->ioc_clusterid == 0xFFFFFFFF) header->ioc_clusterid = cluster_index;340 else error = 1;341 }342 else if ( strcmp( str, "TTY" ) == 0 )343 {344 periph[periph_index]->type = PERIPH_TYPE_TTY;345 if ( header->ioc_clusterid == 0xFFFFFFFF) header->ioc_clusterid = cluster_index;346 else error = 1;347 }348 else if ( strcmp( str, "FBF" ) == 0 )349 {350 periph[periph_index]->type = PERIPH_TYPE_FBF;351 if ( header->ioc_clusterid == 0xFFFFFFFF) header->ioc_clusterid = cluster_index;352 else error = 1;353 }354 else if ( strcmp( str, "NIC" ) == 0 )355 {356 periph[periph_index]->type = PERIPH_TYPE_NIC;357 if ( header->ioc_clusterid == 0xFFFFFFFF) header->ioc_clusterid = cluster_index;358 else error = 1;359 }360 // The TIM, DMA and IOB peripherals can be replicated in several clusters361 else if ( strcmp( str, "TIM" ) == 0 )362 {363 periph[periph_index]->type = PERIPH_TYPE_TIM;364 }365 else if ( strcmp( str, "DMA" ) == 0 )366 {367 periph[periph_index]->type = PERIPH_TYPE_DMA;368 }369 else if ( strcmp( str, "IOB" ) == 0 )370 {371 periph[periph_index]->type = PERIPH_TYPE_IOB;372 }373 else374 {375 printf("[XML ERROR] illegal <type> for peripheral %d in cluster %d\n",376 periph_loc_index, cluster_index);377 exit(1);378 }379 }380 else381 {382 printf("[XML ERROR] missing <type> for peripheral %d in cluster %d\n",383 periph_loc_index, cluster_index);384 exit(1);385 }386 387 ///////// get channels attribute (optionnal : 1 if missing)388 value = getIntValue( reader, "channels", &ok );389 if ( ok )390 {391 #if XML_PARSER_DEBUG392 printf(" channels = %d\n", value);393 #endif394 periph[periph_index]->channels = value;395 }396 else397 {398 periph[periph_index]->channels = 1;399 }400 401 /////////// get psegname attribute402 str = getStringValue(reader,"psegname", &ok);403 if ( ok == 0 )404 {405 printf("[XML ERROR] illegal or missing <psegname> for coproc %d in cluster %d\n",406 coproc_index, cluster_index);407 exit(1);408 }409 410 /////////// set psegid attribute411 int index = getPsegId( cluster_index, str );412 if ( index >= 0 )413 {414 #if XML_PARSER_DEBUG415 printf(" clusterid = %d\n", cluster_index);416 printf(" psegname = %s\n", str);417 printf(" psegid = %d\n", index);418 #endif419 periph[periph_index]->psegid = index;420 assert(pseg[index]->type == PSEG_TYPE_PERI &&421 "peripheral psegname attribute must refer to a pseg of type PERI" );422 }423 else424 {425 printf("[XML ERROR] pseg not found for periph %d / clusterid = %d / psegname = %s\n",426 periph_loc_index, cluster_index, str );427 exit(1);428 }429 430 periph_index++;431 periph_loc_index++;432 433 } // end periphNode434 435 /////////////////////////////////////////436 void coprocNode ( xmlTextReaderPtr reader )437 /////////////////////////////////////////438 {439 char* str;440 unsigned int ok;441 442 cp_port_loc_index = 0;443 444 if ( xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT ) return;445 446 if ( coproc_index >= MAX_COPROCS )447 {448 printf("[XML ERROR] The number of coprocs is larger than %d\n", MAX_COPROCS);449 }450 451 #if XML_PARSER_DEBUG452 printf("\n coproc %d\n", coproc_index);453 #endif454 455 coproc[coproc_index] = (mapping_coproc_t*)malloc(sizeof(mapping_coproc_t));456 457 /////////// get name attribute458 str = getStringValue( reader, "name", &ok );459 if ( ok )460 {461 #if XML_PARSER_DEBUG462 printf(" name = %s\n", str);463 #endif464 strncpy(coproc[coproc_index]->name, str, 31);465 }466 else467 {468 printf("[XML ERROR] illegal or missing <name> for coproc %d in cluster %d\n",469 coproc_index, cluster_index);470 exit(1);471 }472 473 /////////// get psegname attribute474 str = getStringValue(reader,"psegname", &ok);475 if ( ok == 0 )476 {477 printf("[XML ERROR] illegal or missing <psegname> for coproc %d in cluster %d\n",478 coproc_index, cluster_index);479 exit(1);480 }481 482 /////////// set psegid attribute483 int index = getPsegId( cluster_index, str );484 if ( index >= 0 )485 {486 #if XML_PARSER_DEBUG487 printf(" clusterid = %d\n", cluster_index);488 printf(" psegname = %s\n", str);489 printf(" psegid = %d\n", index);490 #endif491 coproc[coproc_index]->psegid = index;492 assert(pseg[index]->type == PSEG_TYPE_PERI && "coproc psegname attribute must refer to a pseg of type PERI" );493 }494 else495 {496 printf("[XML ERROR] pseg not found for coproc %d / clusterid = %d / psegname = %s\n",497 coproc_index, cluster_index, str );498 exit(1);499 }500 501 ////////// set port_offset502 coproc[coproc_index]->port_offset = cp_port_index;503 504 #if XML_PARSER_DEBUG505 printf(" port_offset = %d\n", cp_port_index);506 #endif507 508 int status = xmlTextReaderRead(reader);509 while ( status == 1 )510 {511 const char* tag = (const char*)xmlTextReaderConstName(reader);512 513 if ( strcmp(tag, "port") == 0 ) cpPortNode(reader);514 else if ( strcmp(tag, "#text") == 0 ) { }515 else if ( strcmp(tag, "#comment") == 0 ) { }516 else if ( strcmp(tag, "coproc") == 0 )517 {518 coproc[coproc_index]->ports = cp_port_loc_index;519 coproc_loc_index++;520 coproc_index++;521 return;522 }523 else524 {525 printf("[XML ERROR] Unknown tag %s",tag);526 exit(1);527 }528 status = xmlTextReaderRead ( reader );529 }530 } // end coprocNode()531 532 ///////////////////////////////////////533 void irqNode( xmlTextReaderPtr reader )534 ///////////////////////////////////////535 {536 unsigned int ok;537 unsigned int value;538 char* str;539 540 if ( xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT ) return;541 542 if ( irq_index >= MAX_IRQS )543 {544 printf("[XML ERROR] The number of irqs is larger than %d\n", MAX_IRQS);545 }546 547 #if XML_PARSER_DEBUG548 printf(" irq %d\n", irq_loc_index);549 #endif550 551 irq[irq_index] = (mapping_irq_t*)malloc(sizeof(mapping_irq_t));552 553 ///////// get type attribute554 str = getStringValue(reader,"type", &ok);555 if ( ok )556 {557 #if XML_PARSER_DEBUG558 printf(" type = %s\n", str);559 #endif560 if ( strcmp(str, "HARD") == 0 ) irq[irq_index]->type = 0;561 else if ( strcmp(str, "SOFT") == 0 ) irq[irq_index]->type = 1;562 else563 {564 printf("[XML ERROR] undefined IRQ <type> for processor %d in cluster %d\n",565 cluster_index, proc_loc_index );566 exit(1);567 }568 }569 else570 {571 printf("[XML ERROR] missing IRQ <type> for processor %d in cluster %d\n",572 cluster_index, proc_loc_index );573 exit(1);574 }575 576 ///////// get icuid attribute577 value = getIntValue(reader, "icuid", &ok);578 if ( ok )579 {580 #if XML_PARSER_DEBUG581 printf(" icuid = %d\n", value);582 #endif583 irq[irq_index]->icuid = value;584 if ( value >= 32 )585 {586 printf("[XML ERROR] IRQ <icuid> too large for processor %d in cluster %d\n",587 cluster_index, proc_loc_index );588 exit(1);589 }590 }591 else592 {593 printf("[XML ERROR] missing IRQ <icuid> for processor %d in cluster %d\n",594 cluster_index, proc_loc_index );595 exit(1);596 }597 598 ///////// get isr attribute599 str = getStringValue(reader,"isr", &ok);600 if ( ok )601 {602 #if XML_PARSER_DEBUG603 printf(" isr = %s\n", str);604 #endif605 if ( strcmp(str, "ISR_SWITCH" ) == 0 ) irq[irq_index]->isr = ISR_SWITCH;606 else if ( strcmp(str, "ISR_IOC" ) == 0 ) irq[irq_index]->isr = ISR_IOC;607 else if ( strcmp(str, "ISR_DMA" ) == 0 ) irq[irq_index]->isr = ISR_DMA;608 else if ( strcmp(str, "ISR_TTY" ) == 0 ) irq[irq_index]->isr = ISR_TTY;609 else if ( strcmp(str, "ISR_TIMER" ) == 0 ) irq[irq_index]->isr = ISR_TIMER;610 else611 {612 printf("[XML ERROR] illegal IRQ <isr> for processor %d in cluster %d\n",613 cluster_index, proc_loc_index );614 exit(1);615 }616 #if XML_PARSER_DEBUG617 printf(" isrnum = %d\n", irq[irq_index]->isr);618 #endif619 }620 else621 {622 printf("[XML ERROR] missing IRQ <isr> for processor %d in cluster %d\n",623 cluster_index, proc_loc_index );624 exit(1);625 }626 627 ///////// get channel attribute (optionnal : 0 if missing)628 value = getIntValue(reader, "channel", &ok);629 if ( ok )630 {631 #if XML_PARSER_DEBUG632 printf(" channel = %d\n", value);633 #endif634 irq[irq_index]->channel = value;635 }636 else637 {638 irq[irq_index]->channel = 0;639 }640 641 irq_index++;642 irq_loc_index++;643 644 } // end irqNode645 646 /////////////////////////////////////////647 void procNode ( xmlTextReaderPtr reader )648 /////////////////////////////////////////649 {650 unsigned int ok;651 unsigned int value;652 653 irq_loc_index = 0;654 655 if ( xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT ) return;656 657 if ( proc_index >= MAX_PROCS )658 {659 printf("[XML ERROR] The number of procs is larger than %d\n", MAX_PROCS);660 }661 662 #if XML_PARSER_DEBUG663 printf("\n proc %d\n", proc_index);664 #endif665 666 proc[proc_index] = (mapping_proc_t*)malloc(sizeof(mapping_proc_t));667 668 669 /////////// get index attribute (optional)670 value = getIntValue(reader,"index",&ok);671 if ( ok && (value != proc_loc_index) )672 {673 printf("[XML ERROR] wrong proc index / expected value is %d",674 proc_loc_index);675 exit(1);676 }677 678 ////////// set irq_offset attribute679 proc[proc_index]->irq_offset = irq_index;680 681 #if XML_PARSER_DEBUG682 printf(" irq_offset = %d\n", irq_index);683 #endif684 685 int status = xmlTextReaderRead(reader);686 while ( status == 1 )687 {688 const char* tag = (const char*)xmlTextReaderConstName(reader);689 690 if ( strcmp(tag, "irq") == 0 ) irqNode(reader);691 else if ( strcmp(tag, "#text") == 0 ) { }692 else if ( strcmp(tag, "#comment") == 0 ) { }693 else if ( strcmp(tag, "proc") == 0 )694 {695 proc[proc_index]->irqs = irq_loc_index;696 proc_loc_index++;697 proc_index++;698 return;699 }700 else701 {702 printf("[XML ERROR] Unknown tag %s",tag);703 exit(1);704 }705 status = xmlTextReaderRead ( reader );706 }707 } // end procNode()708 709 282 710 283 ///////////////////////////////////////// … … 1321 894 } // end vspaceNode() 1322 895 896 /////////////////////////////////////////// 897 void cpPortNode ( xmlTextReaderPtr reader ) 898 /////////////////////////////////////////// 899 { 900 char* str; 901 unsigned int ok; 902 903 if ( xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT ) return; 904 905 if ( cp_port_index >= MAX_CP_PORTS ) 906 { 907 printf("[XML ERROR] The number of ports (for coprocs) is larger than %d\n", MAX_CP_PORTS); 908 } 909 910 #if XML_PARSER_DEBUG 911 printf("\n port %d\n", cp_port_index); 912 #endif 913 914 cp_port[cp_port_index] = (mapping_cp_port_t*)malloc(sizeof(mapping_cp_port_t)); 915 cp_port_vobj_ref[cp_port_index] = (vobj_ref_t*)malloc(sizeof(vobj_ref_t)); 916 917 918 919 ///////// get direction attribute 920 str = getStringValue( reader, "direction", &ok ); 921 if ( ok ) 922 { 923 #if XML_PARSER_DEBUG 924 printf(" direction = %s\n", str); 925 #endif 926 if ( strcmp(str, "TO_COPROC") == 0 ) cp_port[cp_port_index]->direction = PORT_TO_COPROC; 927 else if ( strcmp(str, "FROM_COPROC") == 0 ) cp_port[cp_port_index]->direction = PORT_FROM_COPROC; 928 else 929 { 930 printf("[XML ERROR] illegal <direction> for cp_port %d in cluster %d\n", 931 cp_port_index, cluster_index); 932 exit(1); 933 } 934 } 935 else 936 { 937 printf("[XML ERROR] missing <direction> for cp_port %d in cluster %d\n", 938 cp_port_index, cluster_index); 939 exit(1); 940 } 941 942 /////////// get vspacename attribute 943 str = getStringValue( reader, "vspacename", &ok ); 944 #if XML_PARSER_DEBUG 945 printf(" vspacename = %s\n", str); 946 #endif 947 if ( ok ) 948 { 949 strncpy(cp_port_vobj_ref[cp_port_index]->vspace_name, str, 31); 950 } 951 else 952 { 953 printf("[XML ERROR] missing <vspacename> for cp_port %d in cluster %d\n", 954 cp_port_index, cluster_index); 955 exit(1); 956 } 957 958 /////////// get vobjname attribute 959 str = getStringValue( reader, "vobjname", &ok ); 960 #if XML_PARSER_DEBUG 961 printf(" vobjname = %s\n", str); 962 #endif 963 if ( ok ) 964 { 965 strncpy(cp_port_vobj_ref[cp_port_index]->vobj_name, str, 31); 966 } 967 else 968 { 969 printf("[XML ERROR] missing <vobjname> for cp_port %d in cluster %d\n", 970 cp_port_index, cluster_index); 971 exit(1); 972 } 973 974 cp_port_index++; 975 cp_port_loc_index++; 976 977 } // end cpPortNode() 978 979 /////////////////////////////////////////// 980 void periphNode ( xmlTextReaderPtr reader ) 981 /////////////////////////////////////////// 982 { 983 char* str; 984 unsigned int value; 985 unsigned int ok; 986 987 if ( xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT ) return; 988 989 if ( periph_index >= MAX_PERIPHS ) 990 { 991 printf("[XML ERROR] The number of periphs is larger than %d\n", MAX_PERIPHS); 992 } 993 994 #if XML_PARSER_DEBUG 995 printf("\n periph %d\n", periph_index); 996 #endif 997 998 periph[periph_index] = (mapping_periph_t*)malloc(sizeof(mapping_periph_t)); 999 1000 1001 ///////// get channels attribute (optionnal : 1 if missing) 1002 value = getIntValue( reader, "channels", &ok ); 1003 if ( ok ) 1004 { 1005 #if XML_PARSER_DEBUG 1006 printf(" channels = %d\n", value); 1007 #endif 1008 periph[periph_index]->channels = value; 1009 } 1010 else 1011 { 1012 periph[periph_index]->channels = 1; 1013 } 1014 1015 /////////// get psegname attribute 1016 str = getStringValue(reader,"psegname", &ok); 1017 if ( ok == 0 ) 1018 { 1019 printf("[XML ERROR] illegal or missing <psegname> for coproc %d in cluster %d\n", 1020 coproc_index, cluster_index); 1021 exit(1); 1022 } 1023 1024 /////////// set psegid attribute 1025 int index = getPsegId( cluster_index, str ); 1026 if ( index >= 0 ) 1027 { 1028 #if XML_PARSER_DEBUG 1029 printf(" clusterid = %d\n", cluster_index); 1030 printf(" psegname = %s\n", str); 1031 printf(" psegid = %d\n", index); 1032 #endif 1033 periph[periph_index]->psegid = index; 1034 assert(pseg[index]->type == PSEG_TYPE_PERI && 1035 "peripheral psegname attribute must refer to a pseg of type PERI" ); 1036 } 1037 else 1038 { 1039 printf("[XML ERROR] pseg not found for periph %d / clusterid = %d / psegname = %s\n", 1040 periph_loc_index, cluster_index, str ); 1041 exit(1); 1042 } 1043 1044 1045 /////////// get type attribute 1046 str = getStringValue( reader, "type", &ok ); 1047 if ( ok ) 1048 { 1049 #if XML_PARSER_DEBUG 1050 printf(" type = %s\n", str); 1051 #endif 1052 unsigned int error = 0; 1053 1054 // The TTY, IOC, NIC, FBF and IOB peripherals cannot be replicated 1055 // one per architecture 1056 if ( strcmp( str, "IOC" ) == 0 ) 1057 { 1058 periph[periph_index]->type = PERIPH_TYPE_IOC; 1059 if ( header->ioc_clusterid == 0xFFFFFFFF) header->ioc_clusterid = cluster_index; 1060 else error = 1; 1061 1062 ioc_base_offset = pseg[ periph[periph_index]->psegid ]->base; 1063 nb_ioc_channel = periph[periph_index]->channels; 1064 } 1065 else if ( strcmp( str, "TTY" ) == 0 ) 1066 { 1067 periph[periph_index]->type = PERIPH_TYPE_TTY; 1068 if ( header->tty_clusterid == 0xFFFFFFFF) header->tty_clusterid = cluster_index; 1069 else error = 1; 1070 1071 tty_base_offset = pseg[ periph[periph_index]->psegid ]->base; 1072 nb_tty_channel = periph[periph_index]->channels; 1073 } 1074 else if ( strcmp( str, "FBF" ) == 0 ) 1075 { 1076 periph[periph_index]->type = PERIPH_TYPE_FBF; 1077 if ( header->fbf_clusterid == 0xFFFFFFFF) header->fbf_clusterid = cluster_index; 1078 else error = 1; 1079 1080 fbf_base_offset = pseg[ periph[periph_index]->psegid ]->base; 1081 } 1082 else if ( strcmp( str, "NIC" ) == 0 ) 1083 { 1084 periph[periph_index]->type = PERIPH_TYPE_NIC; 1085 if ( header->nic_clusterid == 0xFFFFFFFF) header->nic_clusterid = cluster_index; 1086 else error = 1; 1087 1088 //nic_base_offset = pseg[ periph[periph_index]->psegid ]->base; 1089 nb_nic_channel = periph[periph_index]->channels; 1090 } 1091 else if ( strcmp( str, "IOB" ) == 0 ) 1092 { 1093 periph[periph_index]->type = PERIPH_TYPE_IOB; 1094 iob_base_offset = pseg[ periph[periph_index]->psegid ]->base; 1095 1096 if(io_mmu_active) error = 1; 1097 io_mmu_active = 1; 1098 } 1099 // The TIM, ICU, XICU, DMA and IOB peripherals can be replicated in several clusters 1100 // one per cluster 1101 else if ( strcmp( str, "TIM" ) == 0 ) 1102 { 1103 periph[periph_index]->type = PERIPH_TYPE_TIM; 1104 if(found_timer) error = 1; 1105 found_timer = 1; 1106 1107 if(tim_base_offset == 0xFFFFFFFF) 1108 tim_base_offset = pseg[ periph[periph_index]->psegid ]->base; 1109 1110 if(nb_timer_channel_max < periph[periph_index]->channels) 1111 nb_timer_channel_max = periph[periph_index]->channels; 1112 } 1113 else if ( strcmp( str, "ICU" ) == 0 ) 1114 { 1115 periph[periph_index]->type = PERIPH_TYPE_ICU; 1116 if(found_icu) error = 1; 1117 found_icu = 1; 1118 1119 if(icu_base_offset == 0xFFFFFFFF) 1120 icu_base_offset = pseg[ periph[periph_index]->psegid ]->base; 1121 } 1122 else if ( strcmp( str, "XICU" ) == 0 ) 1123 { 1124 periph[periph_index]->type = PERIPH_TYPE_XICU; 1125 if(found_xicu) error = 1; 1126 found_xicu = 1; 1127 1128 //'icu' since we can't have both xicu and icu in an arch 1129 if(icu_base_offset == 0xFFFFFFFF) 1130 icu_base_offset = pseg[ periph[periph_index]->psegid ]->base; 1131 } 1132 else if ( strcmp( str, "DMA" ) == 0 ) 1133 { 1134 periph[periph_index]->type = PERIPH_TYPE_DMA; 1135 if(found_dma) error = 1; 1136 found_dma = 1; 1137 1138 if(dma_base_offset == 0xFFFFFFFF) 1139 dma_base_offset = pseg[ periph[periph_index]->psegid ]->base; 1140 if(nb_dma_channel_max < periph[periph_index]->channels) 1141 nb_dma_channel_max = periph[periph_index]->channels; 1142 } 1143 else 1144 { 1145 printf("[XML ERROR] illegal <type> for peripheral %d in cluster %d\n", 1146 periph_loc_index, cluster_index); 1147 exit(1); 1148 } 1149 1150 if(error) 1151 { 1152 printf("[XML ERROR] illegal <type> for peripheral %d in cluster %d\n", 1153 periph_loc_index, cluster_index); 1154 exit(1); 1155 } 1156 } 1157 else 1158 { 1159 printf("[XML ERROR] missing <type> for peripheral %d in cluster %d\n", 1160 periph_loc_index, cluster_index); 1161 exit(1); 1162 } 1163 1164 1165 periph_index++; 1166 periph_loc_index++; 1167 cluster[cluster_index]->periphs++; 1168 1169 } // end periphNode 1170 1171 ///////////////////////////////////////// 1172 void coprocNode ( xmlTextReaderPtr reader ) 1173 ///////////////////////////////////////// 1174 { 1175 char* str; 1176 unsigned int ok; 1177 1178 cp_port_loc_index = 0; 1179 1180 if ( xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT ) return; 1181 1182 if ( coproc_index >= MAX_COPROCS ) 1183 { 1184 printf("[XML ERROR] The number of coprocs is larger than %d\n", MAX_COPROCS); 1185 } 1186 1187 #if XML_PARSER_DEBUG 1188 printf("\n coproc %d\n", coproc_index); 1189 #endif 1190 1191 coproc[coproc_index] = (mapping_coproc_t*)malloc(sizeof(mapping_coproc_t)); 1192 1193 /////////// get name attribute 1194 str = getStringValue( reader, "name", &ok ); 1195 if ( ok ) 1196 { 1197 #if XML_PARSER_DEBUG 1198 printf(" name = %s\n", str); 1199 #endif 1200 strncpy(coproc[coproc_index]->name, str, 31); 1201 } 1202 else 1203 { 1204 printf("[XML ERROR] illegal or missing <name> for coproc %d in cluster %d\n", 1205 coproc_index, cluster_index); 1206 exit(1); 1207 } 1208 1209 /////////// get psegname attribute 1210 str = getStringValue(reader,"psegname", &ok); 1211 if ( ok == 0 ) 1212 { 1213 printf("[XML ERROR] illegal or missing <psegname> for coproc %d in cluster %d\n", 1214 coproc_index, cluster_index); 1215 exit(1); 1216 } 1217 1218 /////////// set psegid attribute 1219 int index = getPsegId( cluster_index, str ); 1220 if ( index >= 0 ) 1221 { 1222 #if XML_PARSER_DEBUG 1223 printf(" clusterid = %d\n", cluster_index); 1224 printf(" psegname = %s\n", str); 1225 printf(" psegid = %d\n", index); 1226 #endif 1227 coproc[coproc_index]->psegid = index; 1228 assert(pseg[index]->type == PSEG_TYPE_PERI && "coproc psegname attribute must refer to a pseg of type PERI" ); 1229 } 1230 else 1231 { 1232 printf("[XML ERROR] pseg not found for coproc %d / clusterid = %d / psegname = %s\n", 1233 coproc_index, cluster_index, str ); 1234 exit(1); 1235 } 1236 1237 ////////// set port_offset 1238 coproc[coproc_index]->port_offset = cp_port_index; 1239 1240 #if XML_PARSER_DEBUG 1241 printf(" port_offset = %d\n", cp_port_index); 1242 #endif 1243 1244 int status = xmlTextReaderRead(reader); 1245 while ( status == 1 ) 1246 { 1247 const char* tag = (const char*)xmlTextReaderConstName(reader); 1248 1249 if ( strcmp(tag, "port") == 0 ) cpPortNode(reader); 1250 else if ( strcmp(tag, "#text") == 0 ) { } 1251 else if ( strcmp(tag, "#comment") == 0 ) { } 1252 else if ( strcmp(tag, "coproc") == 0 ) 1253 { 1254 coproc[coproc_index]->ports = cp_port_loc_index; 1255 cluster[cluster_index]->coprocs++; 1256 coproc_loc_index++; 1257 coproc_index++; 1258 return; 1259 } 1260 else 1261 { 1262 printf("[XML ERROR] Unknown tag %s",tag); 1263 exit(1); 1264 } 1265 status = xmlTextReaderRead ( reader ); 1266 } 1267 } // end coprocNode() 1268 1269 /////////////////////////////////////// 1270 void irqNode( xmlTextReaderPtr reader ) 1271 /////////////////////////////////////// 1272 { 1273 unsigned int ok; 1274 unsigned int value; 1275 char* str; 1276 1277 if ( xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT ) return; 1278 1279 if ( irq_index >= MAX_IRQS ) 1280 { 1281 printf("[XML ERROR] The number of irqs is larger than %d\n", MAX_IRQS); 1282 } 1283 1284 #if XML_PARSER_DEBUG 1285 printf(" irq %d\n", irq_loc_index); 1286 #endif 1287 1288 irq[irq_index] = (mapping_irq_t*)malloc(sizeof(mapping_irq_t)); 1289 1290 ///////// get type attribute 1291 str = getStringValue(reader,"type", &ok); 1292 if ( ok ) 1293 { 1294 #if XML_PARSER_DEBUG 1295 printf(" type = %s\n", str); 1296 #endif 1297 if ( strcmp(str, "HARD") == 0 ) irq[irq_index]->type = 0; 1298 else if ( strcmp(str, "SOFT") == 0 ) irq[irq_index]->type = 1; 1299 else 1300 { 1301 printf("[XML ERROR] undefined IRQ <type> for processor %d in cluster %d\n", 1302 cluster_index, proc_loc_index ); 1303 exit(1); 1304 } 1305 } 1306 else 1307 { 1308 printf("[XML ERROR] missing IRQ <type> for processor %d in cluster %d\n", 1309 cluster_index, proc_loc_index ); 1310 exit(1); 1311 } 1312 1313 ///////// get icuid attribute 1314 value = getIntValue(reader, "icuid", &ok); 1315 if ( ok ) 1316 { 1317 #if XML_PARSER_DEBUG 1318 printf(" icuid = %d\n", value); 1319 #endif 1320 irq[irq_index]->icuid = value; 1321 if ( value >= 32 ) 1322 { 1323 printf("[XML ERROR] IRQ <icuid> too large for processor %d in cluster %d\n", 1324 cluster_index, proc_loc_index ); 1325 exit(1); 1326 } 1327 } 1328 else 1329 { 1330 printf("[XML ERROR] missing IRQ <icuid> for processor %d in cluster %d\n", 1331 cluster_index, proc_loc_index ); 1332 exit(1); 1333 } 1334 1335 ///////// get isr attribute 1336 str = getStringValue(reader,"isr", &ok); 1337 if ( ok ) 1338 { 1339 #if XML_PARSER_DEBUG 1340 printf(" isr = %s\n", str); 1341 #endif 1342 if ( strcmp(str, "ISR_SWITCH" ) == 0 ) irq[irq_index]->isr = ISR_SWITCH; 1343 else if ( strcmp(str, "ISR_IOC" ) == 0 ) irq[irq_index]->isr = ISR_IOC; 1344 else if ( strcmp(str, "ISR_DMA" ) == 0 ) irq[irq_index]->isr = ISR_DMA; 1345 else if ( strcmp(str, "ISR_TTY" ) == 0 ) irq[irq_index]->isr = ISR_TTY; 1346 else if ( strcmp(str, "ISR_TIMER" ) == 0 ) irq[irq_index]->isr = ISR_TIMER; 1347 else 1348 { 1349 printf("[XML ERROR] illegal IRQ <isr> for processor %d in cluster %d\n", 1350 cluster_index, proc_loc_index ); 1351 exit(1); 1352 } 1353 #if XML_PARSER_DEBUG 1354 printf(" isrnum = %d\n", irq[irq_index]->isr); 1355 #endif 1356 } 1357 else 1358 { 1359 printf("[XML ERROR] missing IRQ <isr> for processor %d in cluster %d\n", 1360 cluster_index, proc_loc_index ); 1361 exit(1); 1362 } 1363 1364 ///////// get channel attribute (optionnal : 0 if missing) 1365 value = getIntValue(reader, "channel", &ok); 1366 if ( ok ) 1367 { 1368 #if XML_PARSER_DEBUG 1369 printf(" channel = %d\n", value); 1370 #endif 1371 irq[irq_index]->channel = value; 1372 } 1373 else 1374 { 1375 irq[irq_index]->channel = 0; 1376 } 1377 1378 irq_index++; 1379 irq_loc_index++; 1380 1381 } // end irqNode 1382 1383 ///////////////////////////////////////// 1384 void procNode ( xmlTextReaderPtr reader ) 1385 ///////////////////////////////////////// 1386 { 1387 unsigned int ok; 1388 unsigned int value; 1389 1390 irq_loc_index = 0; 1391 1392 if ( xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT ) return; 1393 1394 if ( proc_index >= MAX_PROCS ) 1395 { 1396 printf("[XML ERROR] The number of procs is larger than %d\n", MAX_PROCS); 1397 } 1398 1399 #if XML_PARSER_DEBUG 1400 printf("\n proc %d\n", proc_index); 1401 #endif 1402 1403 proc[proc_index] = (mapping_proc_t*)malloc(sizeof(mapping_proc_t)); 1404 1405 1406 /////////// get index attribute (optional) 1407 value = getIntValue(reader,"index",&ok); 1408 if ( ok && (value != proc_loc_index) ) 1409 { 1410 printf("[XML ERROR] wrong proc index / expected value is %d", 1411 proc_loc_index); 1412 exit(1); 1413 } 1414 1415 ////////// set irq_offset attribute 1416 proc[proc_index]->irq_offset = irq_index; 1417 1418 #if XML_PARSER_DEBUG 1419 printf(" irq_offset = %d\n", irq_index); 1420 #endif 1421 1422 int status = xmlTextReaderRead(reader); 1423 while ( status == 1 ) 1424 { 1425 const char* tag = (const char*)xmlTextReaderConstName(reader); 1426 1427 if ( strcmp(tag, "irq") == 0 ) irqNode(reader); 1428 else if ( strcmp(tag, "#text") == 0 ) { } 1429 else if ( strcmp(tag, "#comment") == 0 ) { } 1430 else if ( strcmp(tag, "proc") == 0 ) 1431 { 1432 proc[proc_index]->irqs = irq_loc_index; 1433 cluster[cluster_index]->procs++; 1434 proc_loc_index++; 1435 proc_index++; 1436 return; 1437 } 1438 else 1439 { 1440 printf("[XML ERROR] Unknown tag %s",tag); 1441 exit(1); 1442 } 1443 status = xmlTextReaderRead ( reader ); 1444 } 1445 } // end procNode() 1446 1447 1323 1448 ////////////////////////////////////////// 1324 1449 void psegNode ( xmlTextReaderPtr reader ) … … 1420 1545 unsigned int value; 1421 1546 1547 cluster[cluster_index] = (mapping_cluster_t*)malloc(sizeof(mapping_cluster_t)); 1548 1549 //initialise all variables 1550 //they will be incremented by *Node() functions 1551 //FIXME: calloc? 1552 cluster[cluster_index]->psegs = 0; 1553 cluster[cluster_index]->procs = 0; 1554 cluster[cluster_index]->coprocs = 0; 1555 cluster[cluster_index]->periphs = 0; 1556 1557 1558 //initialise global variables 1559 //TODO: delete those three 1422 1560 proc_loc_index = 0; 1423 1561 coproc_loc_index = 0; 1424 1562 periph_loc_index = 0; 1425 1563 1564 // for replicated periph 1565 found_timer = 0; 1566 found_icu = 0; 1567 found_xicu = 0; 1568 found_dma = 0; 1569 1426 1570 if ( xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT ) return; 1427 1571 … … 1437 1581 #endif 1438 1582 1439 cluster[cluster_index] = (mapping_cluster_t*)malloc(sizeof(mapping_cluster_t));1440 1441 //initialise the number of pseg1442 //it will be incremented by PsegNode1443 cluster[cluster_index]->psegs = 0;1444 1583 1445 1584 /////////// check cluster index attribute (optional) … … 1480 1619 else if ( strcmp(tag, "cluster") == 0 ) 1481 1620 { 1482 cluster[cluster_index]->procs = proc_loc_index; 1483 cluster[cluster_index]->coprocs = coproc_loc_index; 1484 cluster[cluster_index]->periphs = periph_loc_index; 1485 1486 // cluster[cluster_index]psegs update is done in psegNode(), 1487 // because the coprocNode() call to getPsegId() need it 1621 1622 if(use_xicu == 0xFFFFFFFF) 1623 use_xicu = found_xicu; 1624 1625 ////////////////// peripherals checks //////////////////// 1626 if( (found_timer && use_xicu) || (!found_timer && !use_xicu) ) 1627 { 1628 printf("[XML ERROR] illegal or missing timer peripheral in cluster %d\n", cluster_index); 1629 exit(1); 1630 } 1631 1632 if( (found_icu && use_xicu) || (!found_icu && !use_xicu) ) 1633 { 1634 printf("[XML ERROR] illegal or missing icu peripheral in cluster %d\n", cluster_index); 1635 exit(1); 1636 } 1637 1638 if( !found_xicu && use_xicu) 1639 { 1640 printf("[XML ERROR] illegal or missing dma peripheral in cluster %d\n", cluster_index); 1641 exit(1); 1642 } 1643 1644 if(!found_dma) 1645 { 1646 printf("[XML ERROR] illegal or missing dma peripheral in cluster %d\n", cluster_index); 1647 exit(1); 1648 } 1649 1650 1651 if(nb_proc_max < cluster[cluster_index]->procs) 1652 nb_proc_max = cluster[cluster_index]->procs; 1488 1653 1489 1654 #if XML_PARSER_DEBUG … … 1492 1657 printf(" coprocs = %d\n", cluster[cluster_index]->coprocs); 1493 1658 printf(" periphs = %d\n", cluster[cluster_index]->periphs); 1494 printf(" end cluster %d\n", cluster_index);1659 printf(" end cluster %d\n", cluster_index); 1495 1660 #endif 1496 1661 cluster_index++; … … 1527 1692 exit(1); 1528 1693 } 1529 else 1694 1695 if(header->tty_clusterid == 0xFFFFFFFF) 1530 1696 { 1697 printf("[XML ERROR] illegal or missing tty peripheral"); 1698 exit(1); 1699 } 1700 1531 1701 #if XML_PARSER_DEBUG 1532 1702 printf(" end cluster set\n\n"); 1533 1703 #endif 1534 header->psegs = pseg_index; 1535 header->procs = proc_index; 1536 header->irqs = irq_index; 1537 header->coprocs = coproc_index; 1538 header->cp_ports = cp_port_index; 1539 return; 1540 } 1704 header->psegs = pseg_index; 1705 header->procs = proc_index; 1706 header->irqs = irq_index; 1707 header->coprocs = coproc_index; 1708 header->cp_ports = cp_port_index; 1709 return; 1541 1710 } 1542 1711 else … … 1659 1828 } 1660 1829 1661 /////////// get clusters attribute 1662 value = getIntValue(reader, "clusters", &ok); 1663 if ( ok ) 1664 { 1665 if ( value >= MAX_CLUSTERS ) 1666 { 1667 printf("[XML ERROR] The number of clusters is larger than %d\n", MAX_CLUSTERS); 1668 exit(1); 1669 } 1830 /////////// get cluster_x attribute 1831 cluster_x = getIntValue(reader, "cluster_x", &ok); 1832 if ( ok ) 1833 { 1834 #if XML_PARSER_DEBUG 1835 printf(" cluster_x = %d\n", cluster_x); 1836 #endif 1837 header->cluster_x = cluster_x; 1838 } 1839 else 1840 { 1841 printf("[XML ERROR] illegal or missing <cluster_x> attribute in header\n"); 1842 exit(1); 1843 } 1844 1845 /////////// get cluster_y attribute 1846 cluster_y = getIntValue(reader, "cluster_y", &ok); 1847 if ( ok ) 1848 { 1849 #if XML_PARSER_DEBUG 1850 printf(" cluster_y = %d\n", cluster_y); 1851 #endif 1852 header->cluster_y = cluster_y; 1853 } 1854 else 1855 { 1856 printf("[XML ERROR] illegal or missing <cluster_y> attribute in header\n"); 1857 exit(1); 1858 } 1859 1860 //check the number of cluster 1861 value = cluster_x*cluster_y; 1862 if ( value >= MAX_CLUSTERS ) 1863 { 1864 printf("[XML ERROR] The number of clusters is larger than %d\n", MAX_CLUSTERS); 1865 exit(1); 1866 } 1867 1868 header->clusters = value; 1869 1670 1870 #if XML_PARSER_DEBUG 1671 1871 printf(" clusters = %d\n", value); 1672 1872 #endif 1673 header->clusters = value;1674 }1675 else1676 {1677 printf("[XML ERROR] illegal or missing <clusters> attribute in header\n");1678 exit(1);1679 }1680 1873 1681 1874 ///////// get vspaces attribute … … 1743 1936 { 1744 1937 unsigned int i; 1745 unsigned int length;1746 1938 // write element 1747 1939 for ( i = 0 ; i < nb_elem ; i++ ) 1748 1940 { 1749 length = write(fdout, table[i], elem_size); 1750 1941 if(elem_size != write(fdout, table[i], elem_size)) 1942 { 1943 printf("function %s: %s(%d) write error \n", __FUNCTION__, type, i); 1944 exit(1); 1945 } 1946 1751 1947 #if XML_PARSER_DEBUG 1752 1948 printf("Building binary: writing %s %d\n", type, i); 1753 1949 #endif 1754 1755 if ( length != elem_size )1756 {1757 printf("type: %s\n", type);1758 perror("error writing");1759 exit(1);1760 }1761 1950 } 1762 1951 } 1763 1952 1953 int open_file(const char* file_path) 1954 { 1955 1956 //open file 1957 int fdout = open( file_path, (O_CREAT | O_RDWR), (S_IWUSR | S_IRUSR) ); 1958 if ( fdout < 0) 1959 { 1960 perror("open"); 1961 exit(1); 1962 } 1963 1964 //reinitialise the file 1965 if( ftruncate(fdout, 0) ) 1966 { 1967 perror("truncate"); 1968 exit(1); 1969 } 1970 1971 //#if XML_PARSER_DEBUG 1972 printf("%s\n",file_path); 1973 //#endif 1974 1975 return fdout; 1976 } 1977 1978 1764 1979 /////////////////////////// 1765 void buildBin( int fdout)1980 void buildBin( const char* file_path ) 1766 1981 /////////////////////////// 1767 1982 { 1768 unsigned int vspace_id;1769 unsigned int vobj_id;1770 1983 unsigned int length; 1984 1985 int fdout = open_file(file_path); 1771 1986 1772 1987 // write header to binary file 1773 1988 length = write(fdout, (char*)header, sizeof(mapping_header_t)); 1774 1775 #if XML_PARSER_DEBUG1776 printf("\n*** write header\n");1777 #endif1778 1779 1989 if ( length != sizeof(mapping_header_t) ) 1780 1990 { … … 1785 1995 // write clusters 1786 1996 BuildTable(fdout, "cluster", cluster_index, sizeof(mapping_cluster_t), (char**) cluster); 1787 1788 1997 // write psegs 1789 1998 BuildTable(fdout, "pseg", pseg_index, sizeof(mapping_pseg_t), (char**) pseg); 1790 1791 1999 // write vspaces 1792 for ( vspace_id = 0 ; vspace_id < header->vspaces ; vspace_id++ ) 1793 { 1794 length = write(fdout, (char*)vspace[vspace_id], sizeof(mapping_vspace_t)); 1795 1796 #if XML_PARSER_DEBUG 1797 printf("write vspace %d\n", vspace_id); 1798 printf("vspace->vobj_offset: %d\n", vspace[vspace_id]->vobj_offset); 1799 printf("vspace->vobjs: %d\n", vspace[vspace_id]->vobjs); 1800 printf("header->vobjs: %d\n", header->vobjs); 1801 #endif 1802 1803 if ( length != sizeof(mapping_vspace_t) ) 1804 { 1805 perror("write vspace"); 1806 exit(1); 1807 } 1808 } 1809 2000 BuildTable(fdout, "vspace", vspace_index, sizeof(mapping_vspace_t), (char**) vspace); 1810 2001 // write vsegs 1811 2002 BuildTable(fdout, "vseg", vseg_index, sizeof(mapping_vseg_t), (char**) vseg); 1812 1813 2003 // write vobjs 1814 for ( vobj_id = 0 ; vobj_id < header->vobjs ; vobj_id++ ) 1815 { 1816 length = write(fdout, (char*)vobj[vobj_id], sizeof(mapping_vobj_t)); 1817 1818 #if XML_PARSER_DEBUG 1819 printf("write vobj %d\n", vobj_id); 1820 printf("write vobj name %s\n", vobj[vobj_id]->name); 1821 printf("write vobj length %x\n", vobj[vobj_id]->length); 1822 printf("write vobj type %d\n", vobj[vobj_id]->type); 1823 #endif 1824 1825 if ( length != sizeof(mapping_vobj_t) ) 1826 { 1827 perror("write vobj"); 1828 exit(1); 1829 } 1830 } 1831 2004 BuildTable(fdout, "vobj", vobj_index, sizeof(mapping_vobj_t), (char**) vobj); 1832 2005 // write tasks array 1833 2006 BuildTable(fdout, "task", task_index, sizeof(mapping_task_t), (char**) task); … … 1842 2015 //building periphs array 1843 2016 BuildTable(fdout, "periph", periph_index, sizeof(mapping_periph_t), (char**)periph); 2017 2018 close(fdout); 1844 2019 1845 2020 } // end buildBin() … … 1889 2064 } 1890 2065 2066 2067 void file_write(int fdout, char* towrite) 2068 { 2069 unsigned int size = strlen(towrite); 2070 if(size != write(fdout, towrite, size)) 2071 { 2072 printf("file_write error"); 2073 exit(1); 2074 } 2075 } 2076 2077 void def_int_write(int fdout, char* def, int num) 2078 { 2079 char buf[64]; 2080 sprintf(buf, "#define\t %s %d\n", def, num); 2081 file_write(fdout, buf); 2082 2083 } 2084 2085 void def_hex_write(int fdout, char* def, int num) 2086 { 2087 char buf[64]; 2088 sprintf(buf, "#define\t %s 0x%x\n", def, num); 2089 file_write(fdout, buf); 2090 } 2091 2092 /////////////////////////// 2093 void genHd( const char* file_path ) 2094 /////////////////////////// 2095 { 2096 int fdout = open_file(file_path); 2097 2098 char* prol = " /* AUTO GENRATED FILE */\n\n#ifndef _HD_CONFIG_H\n#define _HD_CONFIG_H\n\n"; 2099 file_write(fdout, prol); 2100 2101 def_int_write(fdout, "CLUSTER_X" , cluster_x); 2102 def_int_write(fdout, "CLUSTER_Y" , cluster_y); 2103 def_int_write(fdout, "NB_CLUSTERS" , cluster_index); 2104 def_hex_write(fdout, "CLUSTER_SIZE" , ( ((unsigned long)1) << 32)/cluster_index); 2105 def_int_write(fdout, "NB_PROCS_MAX" , nb_proc_max); 2106 def_int_write(fdout, "NB_TIMERS_MAX" , nb_timer_channel_max); 2107 def_int_write(fdout, "NB_DMAS_MAX" , nb_dma_channel_max); 2108 def_int_write(fdout, "NB_TTYS" , nb_tty_channel); 2109 def_int_write(fdout, "NB_IOCS" , nb_ioc_channel); 2110 def_int_write(fdout, "NB_NICS" , nb_nic_channel); 2111 2112 file_write(fdout, "\n"); 2113 def_int_write(fdout, "USE_XICU" , use_xicu); 2114 def_int_write(fdout, "IOMMU_ACTIVE " , io_mmu_active); 2115 2116 char* epil = "\n#endif //_HD_CONFIG_H"; 2117 file_write(fdout, epil); 2118 2119 close(fdout); 2120 } 2121 2122 void ld_write(int fdout, char* seg, unsigned int addr) 2123 { 2124 char buf[64]; 2125 sprintf(buf, "%s = 0x%x;\n", seg, addr); 2126 file_write(fdout, buf); 2127 2128 } 2129 2130 /////////////////////////// 2131 void genLd( const char* file_path ) 2132 /////////////////////////// 2133 { 2134 int fdout = open_file(file_path); 2135 2136 char* prol = "/* AUTO GENRATED FILE */\n\n"; 2137 file_write(fdout, prol); 2138 2139 //boot 2140 ld_write(fdout, "seg_boot_code_base" , boot_code_base); 2141 ld_write(fdout, "seg_boot_stack_base" , boot_stack_base); 2142 ld_write(fdout, "seg_mapping_base" , boot_mapping_base ); 2143 2144 //kernel 2145 ld_write(fdout, "\nseg_kernel_code_base" , kernel_code_base); 2146 ld_write(fdout, "seg_kernel_data_base" , kernel_data_base); 2147 ld_write(fdout, "seg_kernel_uncdata_base" , kernel_uncdata_base); 2148 ld_write(fdout, "seg_kernel_init_base" , kernel_init_base); 2149 2150 //peripherals 2151 ld_write(fdout, "\nseg_fbf_base" , fbf_base_offset); 2152 ld_write(fdout, "seg_icu_base" , icu_base_offset); 2153 ld_write(fdout, "seg_ioc_base" , ioc_base_offset); 2154 ld_write(fdout, "seg_tty_base" , tty_base_offset); 2155 ld_write(fdout, "seg_dma_base" , dma_base_offset); 2156 ld_write(fdout, "seg_tim_base" , tim_base_offset); 2157 ld_write(fdout, "seg_gcd_base" , gcd_base_offset); 2158 ld_write(fdout, "seg_iob_base" , iob_base_offset); 2159 2160 close(fdout); 2161 } 2162 2163 char* buildPath(const char* path, const char*name) 2164 { 2165 char *res = calloc(strlen(path) + strlen(name) + 1, 1); 2166 strcat(res, path); 2167 strcat(res, "/"); 2168 strcat(res, name); 2169 return res; 2170 } 2171 1891 2172 ///////////////////////////////////// 1892 2173 int main ( int argc, char* argv[] ) … … 1895 2176 if ( argc < 3 ) 1896 2177 { 1897 printf("Usage: xml2bin <input_file_path> <output_ file_path>\n");2178 printf("Usage: xml2bin <input_file_path> <output_path>\n"); 1898 2179 return 1; 1899 2180 } 1900 2181 1901 int fdout = open( argv[2], (O_CREAT | O_RDWR), S_IRWXU ); 1902 if ( fdout < 0) 1903 { 1904 perror("open"); 1905 exit(1); 1906 } 2182 struct stat dir_st; 2183 if(stat( argv[2], &dir_st )) 2184 { 2185 perror("bad path"); 2186 exit(1); 2187 } 2188 2189 if((dir_st.st_mode & S_IFDIR) == 0) 2190 { 2191 printf("path is not a dir: %s", argv[2] ); 2192 exit(1); 2193 } 2194 1907 2195 2196 char *map_path = buildPath(argv[2], "map.bin"); 2197 char *ld_path = buildPath(argv[2], "giet_vsegs.ld"); 2198 char *hd_path = buildPath(argv[2], "hard_config.h"); 2199 1908 2200 LIBXML_TEST_VERSION; 1909 2201 … … 1922 2214 headerNode( reader ); 1923 2215 prepareBuild(); 1924 buildBin( fdout ); 2216 buildBin( map_path ); 2217 genHd(hd_path); 2218 genLd(ld_path); 1925 2219 } 1926 2220 else
Note: See TracChangeset
for help on using the changeset viewer.