- Timestamp:
- Jul 26, 2012, 5:43:08 PM (12 years ago)
- Location:
- soft/giet_vm
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/map.xml
r175 r181 11 11 12 12 <clusterset> 13 <cluster index = "0" 14 procs = "4" /> 13 <cluster index = "0" > 14 <pseg name = "PSEG_ROM" 15 type = "ROM" 16 base = "0xbfc00000" 17 length = "0x00010000" /> 18 19 <pseg name = "PSEG_RAU" 20 type = "RAM" 21 base = "0x00000000" 22 length = "0x01000000" /> 23 24 <pseg name = "PSEG_RAK" 25 type = "RAM" 26 base = "0x80000000" 27 length = "0x00100000" /> 28 29 <pseg name = "PSEG_TTY" 30 type = "PERI" 31 base = "0x90000000" 32 length = "0x00001000" /> 33 34 <pseg name = "PSEG_TIM" 35 type = "PERI" 36 base = "0x91000000" 37 length = "0x00001000" /> 38 39 <pseg name = "PSEG_IOC" 40 type = "PERI" 41 base = "0x92000000" 42 length = "0x00001000" /> 43 44 <pseg name = "PSEG_DMA" 45 type = "PERI" 46 base = "0x93000000" 47 length = "0x00001000" /> 48 49 <pseg name = "PSEG_FBF" 50 type = "PERI" 51 base = "0x96000000" 52 length = "0x00004000" /> 53 54 <pseg name = "PSEG_ICU" 55 type = "PERI" 56 base = "0x9F000000" 57 length = "0x00001000" /> 58 <proc index = "0" > 59 </proc> 60 <proc index = "1" > 61 </proc> 62 <proc index = "2" > 63 </proc> 64 <proc index = "3" > 65 </proc> 66 </cluster> 15 67 </clusterset> 16 17 <psegset>18 <pseg name = "PSEG_ROM"19 base = "0xbfc00000"20 length = "0x00010000" />21 22 <pseg name = "PSEG_RAU"23 base = "0x00000000"24 length = "0x01000000" />25 26 <pseg name = "PSEG_RAK"27 base = "0x80000000"28 length = "0x00100000" />29 30 <pseg name = "PSEG_TTY"31 base = "0x90000000"32 length = "0x00001000" />33 34 <pseg name = "PSEG_TIM"35 base = "0x91000000"36 length = "0x00001000" />37 38 <pseg name = "PSEG_IOC"39 base = "0x92000000"40 length = "0x00001000" />41 42 <pseg name = "PSEG_DMA"43 base = "0x93000000"44 length = "0x00001000" />45 46 <pseg name = "PSEG_FBF"47 base = "0x96000000"48 length = "0x00004000" />49 50 <pseg name = "PSEG_ICU"51 base = "0x9F000000"52 length = "0x00001000" />53 </psegset>54 68 55 69 <globalset> … … 57 71 vbase = "0xbfc00000" 58 72 mode = "CX__" 73 clusterid = "0" 59 74 psegname = "PSEG_ROM" 60 75 ident = "1" > … … 68 83 vbase = "0xbfc08000" 69 84 mode = "C_W_" 85 clusterid = "0" 70 86 psegname = "PSEG_ROM" 71 87 ident = "1" > … … 78 94 vbase = "0xbfc0c000" 79 95 mode = "C_W_" 96 clusterid = "0" 80 97 psegname = "PSEG_ROM" 81 98 ident = "1" > … … 89 106 vbase = "0x80000000" 90 107 mode = "CX__" 108 clusterid = "0" 91 109 psegname = "PSEG_RAU" 92 110 ident = "0" > … … 101 119 vbase = "0x80010000" 102 120 mode = "C_W_" 121 clusterid = "0" 103 122 psegname = "PSEG_RAU" 104 123 ident = "O" > … … 112 131 vbase = "0x80080000" 113 132 mode = "__W_" 133 clusterid = "0" 114 134 psegname = "PSEG_RAU" 115 135 ident = "0" > … … 123 143 vbase = "0x80090000" 124 144 mode = "CX__" 145 clusterid = "0" 125 146 psegname = "PSEG_RAU" 126 147 ident = "0" > … … 135 156 vbase = "0x90000000" 136 157 mode = "__W_" 158 clusterid = "0" 137 159 psegname = "PSEG_TTY" 138 160 ident = "1" > … … 145 167 vbase = "0x91000000" 146 168 mode = "__W_" 169 clusterid = "0" 147 170 psegname = "PSEG_TIM" 148 171 ident = "1" > … … 155 178 vbase = "0x92000000" 156 179 mode = "__W_" 180 clusterid = "0" 157 181 psegname = "PSEG_IOC" 158 182 ident = "1" > … … 165 189 vbase = "0x93000000" 166 190 mode = "__W_" 191 clusterid = "0" 167 192 psegname = "PSEG_DMA" 168 193 ident = "1" > … … 175 200 vbase = "0x96000000" 176 201 mode = "__W_" 202 clusterid = "0" 177 203 psegname = "PSEG_FBF" 178 204 ident = "1" > … … 185 211 vbase = "0x9F000000" 186 212 mode = "__W_" 213 clusterid = "0" 187 214 psegname = "PSEG_ICU" 188 215 ident = "1" > … … 200 227 vbase = "0x00800000" 201 228 mode = "__WU" 229 clusterid = "0" 202 230 psegname = "PSEG_RAU" > 203 231 <vobj name = "seg_data_router" … … 210 238 vbase = "0x00400000" 211 239 mode = "CX_U" 240 clusterid = "0" 212 241 psegname = "PSEG_RAU" > 213 242 <vobj name = "seg_code_router" … … 220 249 vbase = "0x00300000" 221 250 mode = "C___" 251 clusterid = "0" 222 252 psegname = "PSEG_RAU" > 223 253 <vobj name = "ptab_router" … … 230 260 vbase = "0x00010000" 231 261 mode = "C_WU" 262 clusterid = "0" 232 263 psegname = "PSEG_RAU" > 233 264 <vobj name = "stack_producer" … … 239 270 vbase = "0x00020000" 240 271 mode = "C_WU" 272 clusterid = "0" 241 273 psegname = "PSEG_RAU" > 242 274 <vobj name = "stack_consumer" … … 248 280 vbase = "0x00030000" 249 281 mode = "C_WU" 282 clusterid = "0" 250 283 psegname = "PSEG_RAU" > 251 284 <vobj name = "stack_router_A" … … 257 290 vbase = "0x00040000" 258 291 mode = "C_WU" 292 clusterid = "0" 259 293 psegname = "PSEG_RAU" > 260 294 <vobj name = "stack_router_B" … … 266 300 vbase = "0x00050000" 267 301 mode = "__WU" 302 clusterid = "0" 268 303 psegname = "PSEG_RAU" > 269 304 <vobj name = "mwmr_in" … … 312 347 vbase = "0x00800000" 313 348 mode = "C_WU" 349 clusterid = "0" 314 350 psegname = "PSEG_RAU" > 315 351 <vobj name = "seg_data_hello" … … 322 358 vbase = "0x00400000" 323 359 mode = "CX_U" 360 clusterid = "0" 324 361 psegname = "PSEG_RAU" > 325 362 <vobj name = "seg_code_hello" … … 332 369 vbase = "0x00300000" 333 370 mode = "C___" 371 clusterid = "0" 334 372 psegname = "PSEG_RAU" > 335 373 <vobj name = "ptab" … … 342 380 vbase = "0x00000000" 343 381 mode = "C_WU" 382 clusterid = "0" 344 383 psegname = "PSEG_RAU" > 345 384 <vobj name = "stack" … … 363 402 vbase = "0x00800000" 364 403 mode = "C_WU" 404 clusterid = "0" 365 405 psegname = "PSEG_RAU" > 366 406 <vobj name = "seg_data_pgcd" … … 373 413 vbase = "0x00300000" 374 414 mode = "C___" 415 clusterid = "0" 375 416 psegname = "PSEG_RAU" > 376 417 <vobj name = "ptab" … … 383 424 vbase = "0x00400000" 384 425 mode = "CX_U" 426 clusterid = "0" 385 427 psegname = "PSEG_RAU" > 386 428 <vobj name = "seg_code_pgcd" … … 393 435 vbase = "0x00000000" 394 436 mode = "C_WU" 437 clusterid = "0" 395 438 psegname = "PSEG_RAU" > 396 439 <vobj name = "stack" … … 413 456 vbase = "0x00800000" 414 457 mode = "C_WU" 458 clusterid = "0" 415 459 psegname = "PSEG_RAU" > 416 460 <vobj name = "seg_data_display" … … 423 467 vbase = "0x00300000" 424 468 mode = "C___" 469 clusterid = "0" 425 470 psegname = "PSEG_RAU" > 426 471 <vobj name = "ptab" … … 433 478 vbase = "0x00400000" 434 479 mode = "CX_U" 480 clusterid = "0" 435 481 psegname = "PSEG_RAU" > 436 482 <vobj name = "seg_code_display" … … 443 489 vbase = "0x00000000" 444 490 mode = "C_WU" 491 clusterid = "0" 445 492 psegname = "PSEG_RAU" > 446 493 <vobj name = "stack_display" -
soft/giet_vm/xml/Makefile
r160 r181 3 3 4 4 bin2xml: xml_driver.c mapping_info.h 5 gcc -Wall - I. xml_driver.c -o bin2xml5 gcc -Wall -g -I. xml_driver.c -o bin2xml 6 6 7 7 xml2bin: xml_parser.c mapping_info.h 8 gcc -Wall - I. -I/usr/include/libxml2 xml_parser.c -o xml2bin -lxml28 gcc -Wall -g -I. -I/usr/include/libxml2 xml_parser.c -o xml2bin -lxml2 9 9 10 10 test: -
soft/giet_vm/xml/mapping_info.h
r173 r181 46 46 #define MAPPING_PSEG_SIZE sizeof(mapping_pseg_t) 47 47 #define MAPPING_TASK_SIZE sizeof(mapping_task_t) 48 #define MAPPING_PROC_SIZE sizeof(mapping_proc_t) 49 #define MAPPING_IRQ_SIZE sizeof(mapping_irq_t) 50 #define MAPPING_COPROC_SIZE sizeof(mapping_coproc_t) 51 #define MAPPING_CP_PORT_SIZE sizeof(mapping_coproc_port_t) 52 #define MAPPING_CP_REG_SIZE sizeof(mapping_coproc_reg_t) 48 53 49 54 #define C_MODE_MASK 0b1000 // cacheable … … 67 72 }; 68 73 74 enum 75 { 76 PSEG_TYPE_RAM = 0, 77 PSEG_TYPE_ROM = 1, 78 PSEG_TYPE_PERI = 2, 79 }; 80 81 enum 82 { 83 IRQ_TYPE_HARD = 0, // hardware interrupt (peripheral) 84 IRQ_TYPE_SOFT = 1, // software interrupt (IPI) 85 }; 86 87 enum 88 { 89 ISR_SWITCH = 0, 90 ISR_IOC = 1, 91 ISR_FBDMA = 2, 92 ISR_TTY = 3, 93 }; 94 95 enum 96 { 97 REG_TYPE_STATUS = 0, // status register 98 REG_TYPE_CONFIG = 1, // config register 99 }; 100 101 enum 102 { 103 PORT_TO_COPROC = 0, // status register 104 PORT_FROM_COPROC = 1, // config register 105 }; 69 106 70 107 /////////////////////////////// … … 73 110 unsigned int signature; // must contain MAPPING_SIGNATURE 74 111 unsigned int clusters; // number of clusters 75 unsigned int psegs; // number of psegs76 112 unsigned int ttys; // number of TTY terminals 77 unsigned int fbs; // number of F rame BufferDMA channels113 unsigned int fbs; // number of FBDMA channels 78 114 unsigned int globals; // number of vsegs mapped in all vspaces 79 115 unsigned int vspaces; // number of virtual spaces 116 unsigned int psegs; // total number of physical segments (for all clusters) 80 117 unsigned int vsegs; // total number of virtual segments (for all vspaces) 81 118 unsigned int vobjs; // total number of virtual objects (for all vspaces) 82 119 unsigned int tasks; // total number of tasks (for all vspaces) 120 unsigned int procs; // total number of procs 121 unsigned int irqs; // total number of irqs 122 unsigned int coprocs; // total number of coprocs 123 unsigned int cp_ports; // total number of cp_ports 124 unsigned int cp_regs; // total number of cp_regss 83 125 char name[32]; // mapping name 84 126 } mapping_header_t; … … 88 130 { 89 131 unsigned int procs; // number of processors in cluster 132 unsigned int proc_offset; // index of first proc in proc set 133 unsigned int coprocs; // number of coprocessors in cluster 134 unsigned int coproc_offset; // index of first coproc in coproc set 135 unsigned int psegs; // number of psegs in cluster 136 unsigned int pseg_offset; // index of first pseg in pseg set 90 137 } mapping_cluster_t; 91 138 … … 96 143 unsigned int base; // base address in physical space 97 144 unsigned int length; // size (bytes) 145 unsigned int type; // RAM / ROM / PERI 146 unsigned int cluster; // index of cluster containing pseg 98 147 unsigned int next_base; // first free page base address 99 148 } mapping_pseg_t; … … 119 168 unsigned int pbase; // base address in physical space (hexa) 120 169 unsigned int length; // size (bytes) 121 unsigned int psegid; // physical segment index170 unsigned int psegid; // physical segment global index 122 171 unsigned int mode; // C-X-W-U flags 123 172 unsigned int ident; // identity mapping if non zero … … 148 197 unsigned int vaddr; // virtual base addresse of the vobj 149 198 unsigned int paddr; // physical base addresse of the vobj 150 unsigned int init; // init value ( number of participants for a barrier)199 unsigned int init; // init value (used by barrier or mwmr channel) 151 200 } mapping_vobj_t; 201 202 ///////////////////////////// 203 typedef struct mapping_proc_s 204 { 205 unsigned int irqs; // number of IRQs allocated to processor 206 unsigned int irq_offset; // index of first IRQ allocated to processor 207 } mapping_proc_t; 208 209 ///////////////////////////// 210 typedef struct mapping_irq_s 211 { 212 unsigned int type; // HW_IRQ / SW_IRQ 213 unsigned int icuid; // IRQ Index for the ICU component 214 unsigned int isr; // Interrupt Service Routine Index 215 unsigned int channel; // Channel Index (for multi-cannels peripherals) 216 217 unsigned int cluster_id; // physical cluster index 218 unsigned int proclocid; // processor local index (inside cluster) 219 } mapping_irq_t; 220 221 /////////////////////////////// 222 typedef struct mapping_coproc_s 223 { 224 char name[32]; // coprocessor name 225 unsigned int psegid; // pseg index in cluster 226 unsigned int ports; // number of MWMR ports used by coprocessor 227 unsigned int port_offset; // index of first MWMR port used by coprocessor 228 unsigned int regs; // number of config/status registers 229 unsigned int reg_offset; // index of first register 230 } mapping_coproc_t; 231 232 /////////////////////////////////////// 233 typedef struct mapping_coproc_port_s 234 { 235 unsigned int direction; // TO_COPROC == 0 / FROM_COPROC == 1 236 unsigned int vspaceid; // global index of the vspace containing the MWMR channel 237 unsigned int vobjlocid; // local(to vspace) index of the vobj containing the MWMR channel 238 } mapping_coproc_port_t; 239 240 /////////////////////////////////// 241 typedef struct mapping_coproc_reg_s 242 { 243 char name[32]; // register name 244 unsigned int type; // STATUS = 0 / CONFIG == 1 245 unsigned int loc_id; // register index in coprocessor (word offset) 246 unsigned int channel_id; // channel index in coprocessor (page offset) 247 unsigned int value; // initialisation value 248 } mapping_coproc_reg_t; 152 249 153 250 #endif -
soft/giet_vm/xml/xml_driver.c
r173 r181 21 21 { 22 22 23 const char* 24 vobj_type[] = 23 const char* vobj_type[] = 25 24 { 26 "ELF", 27 "BLOB", 28 "PTAB", //page table 29 "PERI", //hardware component 30 "MWMR", //MWMR channel 31 "LOCK", //Lock 32 "BUFFER", //Any "no intialiasation needed" objects (stacks...) 33 "BARRIER" //Barrier 34 }; 35 const char* mode_str[] = { "____", 36 "___U", 37 "__W_", 38 "__WU", 39 "_X__", 40 "_X_U", 41 "_XW_", 42 "_XWU", 43 "C___", 44 "C__U", 45 "C_W_", 46 "C_WU", 47 "CX__", 48 "CX_U", 49 "CXW_", 50 "CXWU" }; 25 "ELF", // binary code generated by GCC 26 "BLOB", // binary code generated by GCC 27 "PTAB", // page table 28 "PERI", // hardware component 29 "MWMR", // MWMR channel 30 "LOCK", // Spin-Lock 31 "BUFFER", // Any "no intialiasation needed" objects (stacks...) 32 "BARRIER" // Barrier 33 }; 34 35 const char* pseg_type[] = 36 { 37 "RAM", 38 "ROM", 39 "PERI" 40 }; 41 42 const char* irq_type[] = 43 { 44 "HARD", 45 "SOFT" 46 }; 47 48 const char* isr_type[] = 49 { 50 "ISR_IOC", 51 "ISR_FBDMA", 52 "ISR_TTY" 53 }; 54 55 const char* reg_type[] = 56 { 57 "STATUS", 58 "CONFIG" 59 }; 60 61 const char* port_direction[] = 62 { 63 "TO_COPROC", 64 "FROM_COPROC" 65 }; 66 67 const char* mode_str[] = 68 { "____", 69 "___U", 70 "__W_", 71 "__WU", 72 "_X__", 73 "_X_U", 74 "_XW_", 75 "_XWU", 76 "C___", 77 "C__U", 78 "C_W_", 79 "C_WU", 80 "CX__", 81 "CX_U", 82 "CXW_", 83 "CXWU" 84 }; 51 85 52 86 unsigned int vspace_id; … … 56 90 unsigned int vobj_id; 57 91 unsigned int task_id; 58 59 mapping_cluster_t* cluster; 60 mapping_pseg_t* pseg; 61 mapping_vspace_t* vspace; 62 mapping_vseg_t* vseg; 63 mapping_vobj_t* vobj; 64 mapping_task_t* task; 92 unsigned int proc_id; 93 unsigned int irq_id; 94 unsigned int coproc_id; 95 unsigned int port_id; 96 unsigned int reg_id; 97 98 mapping_cluster_t* cluster; 99 mapping_pseg_t* pseg; 100 mapping_vspace_t* vspace; 101 mapping_vseg_t* vseg; 102 mapping_vobj_t* vobj; 103 mapping_task_t* task; 104 mapping_proc_t* proc; 105 mapping_irq_t* irq; 106 mapping_coproc_t* coproc; 107 mapping_coproc_port_t* cp_port; 108 mapping_coproc_reg_t* cp_reg; 65 109 66 110 // computes the base adresss for clusters array, … … 103 147 MAPPING_VSEG_SIZE*header->vsegs ); 104 148 149 // computes the base address the array 150 proc = (mapping_proc_t*) ((char*)header + 151 MAPPING_HEADER_SIZE + 152 MAPPING_CLUSTER_SIZE*header->clusters + 153 MAPPING_PSEG_SIZE*header->psegs + 154 MAPPING_VSPACE_SIZE*header->vspaces + 155 MAPPING_VOBJ_SIZE*header->vobjs + 156 MAPPING_VSEG_SIZE*header->vsegs + 157 MAPPING_TASK_SIZE*header->tasks); 158 159 // computes the base address the array 160 irq = (mapping_irq_t*) ((char*)header + 161 MAPPING_HEADER_SIZE + 162 MAPPING_CLUSTER_SIZE*header->clusters + 163 MAPPING_PSEG_SIZE*header->psegs + 164 MAPPING_VSPACE_SIZE*header->vspaces + 165 MAPPING_VOBJ_SIZE*header->vobjs + 166 MAPPING_VSEG_SIZE*header->vsegs+ 167 MAPPING_TASK_SIZE*header->tasks+ 168 MAPPING_PROC_SIZE*header->procs 169 ); 170 171 // computes the base address the array 172 coproc = (mapping_coproc_t*) ((char*)header + 173 MAPPING_HEADER_SIZE + 174 MAPPING_CLUSTER_SIZE*header->clusters + 175 MAPPING_PSEG_SIZE*header->psegs + 176 MAPPING_VSPACE_SIZE*header->vspaces + 177 MAPPING_VOBJ_SIZE*header->vobjs + 178 MAPPING_VSEG_SIZE*header->vsegs+ 179 MAPPING_TASK_SIZE*header->tasks+ 180 MAPPING_PROC_SIZE*header->procs+ 181 MAPPING_IRQ_SIZE*header->irqs 182 ); 183 184 // computes the base address the array 185 cp_port = (mapping_coproc_port_t*) ((char*)header + 186 MAPPING_HEADER_SIZE + 187 MAPPING_CLUSTER_SIZE*header->clusters + 188 MAPPING_PSEG_SIZE*header->psegs + 189 MAPPING_VSPACE_SIZE*header->vspaces + 190 MAPPING_VOBJ_SIZE*header->vobjs + 191 MAPPING_VSEG_SIZE*header->vsegs+ 192 MAPPING_TASK_SIZE*header->tasks+ 193 MAPPING_PROC_SIZE*header->procs+ 194 MAPPING_IRQ_SIZE*header->irqs+ 195 MAPPING_COPROC_SIZE*header->coprocs 196 ); 197 198 // computes the base address the array 199 cp_reg = (mapping_coproc_reg_t*) ((char*)header + 200 MAPPING_HEADER_SIZE + 201 MAPPING_CLUSTER_SIZE*header->clusters + 202 MAPPING_PSEG_SIZE*header->psegs + 203 MAPPING_VSPACE_SIZE*header->vspaces + 204 MAPPING_VOBJ_SIZE*header->vobjs + 205 MAPPING_VSEG_SIZE*header->vsegs+ 206 MAPPING_TASK_SIZE*header->tasks+ 207 MAPPING_PROC_SIZE*header->procs+ 208 MAPPING_IRQ_SIZE*header->irqs+ 209 MAPPING_COPROC_SIZE*header->coprocs+ 210 MAPPING_CP_PORT_SIZE*header->cp_ports 211 ); 212 105 213 fprintf( fpout, "<?xml version = \"1.0\"?>\n\n"); 106 214 … … 110 218 fprintf( fpout, " name = \"%s\"\n", header->name); 111 219 fprintf( fpout, " clusters = \"%d\"\n", header->clusters); 112 fprintf( fpout, " psegs = \"%d\"\n", header->psegs);113 220 fprintf( fpout, " ttys = \"%d\"\n", header->ttys); 114 221 fprintf( fpout, " fbs = \"%d\"\n", header->fbs); … … 121 228 for ( cluster_id = 0 ; cluster_id < header->clusters ; cluster_id++ ) 122 229 { 123 fprintf( fpout, " <cluster index = \"%d\"\n", cluster_id); 124 fprintf( fpout, " procs = \"%d\" />\n\n", cluster[cluster_id].procs); 125 } 126 fprintf( fpout, " </clusterset>\n" ); 127 128 //////////////////// psegs /////////////////////////////////////////////////// 129 130 fprintf( fpout, " <psegset>\n" ); 131 for ( pseg_id = 0 ; pseg_id < header->psegs ; pseg_id++ ) 132 { 133 fprintf( fpout, " <pseg name = \"%s\"\n", pseg[pseg_id].name); 134 fprintf( fpout, " base = \"0x%x\"\n", pseg[pseg_id].base); 135 fprintf( fpout, " length = \"0x%x\" />\n\n", pseg[pseg_id].length); 136 } 137 fprintf( fpout, " </psegset>\n" ); 138 230 fprintf( fpout, " <cluster index = \"%d\" >\n", cluster_id); 231 for ( pseg_id = cluster[cluster_id].pseg_offset ; 232 pseg_id < cluster[cluster_id].pseg_offset + cluster[cluster_id].psegs ; 233 pseg_id++ ) 234 { 235 fprintf( fpout, " <pseg name = \"%s\"\n", pseg[pseg_id].name); 236 fprintf( fpout, " type = \"%s\"\n", pseg_type[pseg[pseg_id].type]); 237 fprintf( fpout, " base = \"0x%x\"\n", pseg[pseg_id].base); 238 fprintf( fpout, " length = \"0x%x\" />\n", pseg[pseg_id].length); 239 } 240 for ( proc_id = cluster[cluster_id].proc_offset ; 241 proc_id < cluster[cluster_id].proc_offset + cluster[cluster_id].procs ; 242 proc_id++ ) 243 { 244 fprintf( fpout, " <proc index = \"%d\" >\n", proc_id); 245 for ( irq_id = proc[proc_id].irq_offset ; irq_id < proc[proc_id].irq_offset + proc[proc_id].irqs ; irq_id++ ) 246 { 247 fprintf( fpout, " <irq type = \"%s\"\n", irq_type[irq[irq_id].type]); 248 fprintf( fpout, " icuid = \"0x%x\"\n", irq[irq_id].icuid); 249 fprintf( fpout, " isr = \"%s\"\n", isr_type[irq[irq_id].isr]); 250 fprintf( fpout, " channel = \"0x%x\" />\n", irq[irq_id].channel); 251 } 252 fprintf( fpout, " </proc>\n" ); 253 } 254 255 for ( coproc_id = cluster[cluster_id].coproc_offset ; 256 coproc_id < cluster[cluster_id].coproc_offset + cluster[cluster_id].coprocs ; 257 coproc_id++ ) 258 { 259 fprintf( fpout, " <coproc name = \"%s\"\n", coproc[coproc_id].name); 260 fprintf( fpout, " psegname = \"%s\" >\n", pseg[coproc[coproc_id].psegid].name); 261 for ( port_id = coproc[coproc_id].port_offset ; port_id < coproc[coproc_id].port_offset + coproc[coproc_id].ports ; port_id++ ) 262 { 263 unsigned int vobj_id = cp_port[port_id].vobjlocid + vspace[cp_port[port_id].vspaceid].vobj_offset; 264 fprintf( fpout, " <port direction = \"%s\"\n", port_direction[ cp_port[port_id].direction]); 265 fprintf( fpout, " vspacename = \"%s\"\n", vspace[cp_port[port_id].vspaceid].name); 266 fprintf( fpout, " vobjname = \"%s\" />\n", vobj[vobj_id].name); 267 } 268 for ( reg_id = coproc[coproc_id].reg_offset ; 269 reg_id < coproc[coproc_id].reg_offset+coproc[coproc_id].regs ; 270 reg_id++ ) 271 { 272 fprintf( fpout, " <reg name = \"%s\"\n", cp_reg[reg_id].name); 273 fprintf( fpout, " type = \"%s\"\n", reg_type[cp_reg[reg_id].type]); 274 fprintf( fpout, " value = \"0x%x\"\n", cp_reg[reg_id].value); 275 fprintf( fpout, " channel = \"0x%x\"\n", cp_reg[reg_id].channel_id); 276 fprintf( fpout, " index = \"0x%x\" />\n", cp_reg[reg_id].loc_id); 277 } 278 fprintf( fpout, " </coproc>\n" ); 279 } 280 fprintf( fpout, " </cluster>\n" ); 281 } 282 fprintf( fpout, " </clusterset>\n\n" ); 139 283 140 284 /////////////////// globals ///////////////////////////////////////////////// … … 145 289 unsigned int pseg_id = vseg[vseg_id].psegid; 146 290 147 fprintf( fpout, " <vseg name = \"%s\"\n", vseg[vseg_id].name); 148 fprintf( fpout, " vbase = \"0x%x\"\n", vseg[vseg_id].vbase); 149 fprintf( fpout, " mode = \"%s\"\n", mode_str[vseg[vseg_id].mode]); 150 fprintf( fpout, " psegname = \"%s\"\n", pseg[pseg_id].name); 151 fprintf( fpout, " ident = \"%d\" >\n", vseg[vseg_id].ident); 291 fprintf( fpout, " <vseg name = \"%s\"\n", vseg[vseg_id].name); 292 fprintf( fpout, " vbase = \"0x%x\"\n", vseg[vseg_id].vbase); 293 fprintf( fpout, " mode = \"%s\"\n", mode_str[vseg[vseg_id].mode]); 294 fprintf( fpout, " clusterid = \"%d\"\n", pseg[pseg_id].cluster); 295 fprintf( fpout, " psegname = \"%s\"\n", pseg[pseg_id].name); 296 fprintf( fpout, " ident = \"%d\" >\n", vseg[vseg_id].ident); 152 297 for ( vobj_id = vseg[vseg_id].vobj_offset; 153 298 vobj_id < (vseg[vseg_id].vobj_offset + vseg[vseg_id].vobjs); … … 161 306 fprintf( fpout, " binpath = \"%s\" />\n", vobj[vobj_id].binpath); 162 307 } 163 fprintf( fpout, " </vseg>\n \n");308 fprintf( fpout, " </vseg>\n"); 164 309 } 165 310 fprintf( fpout, " </globalset>\n" ); … … 167 312 //////////////////// vspaces //////////////////////////////////////////////// 168 313 169 fprintf( fpout, " <vspaceset>\n" );314 fprintf( fpout, "\n <vspaceset>\n\n" ); 170 315 for ( vspace_id = 0 ; vspace_id < header->vspaces ; vspace_id++ ) 171 316 { … … 182 327 fprintf( fpout, " vbase = \"0x%x\"\n", vseg[vseg_id].vbase); 183 328 fprintf( fpout, " mode = \"%s\"\n", mode_str[vseg[vseg_id].mode]); 329 fprintf( fpout, " clusterid = \"%d\"\n", pseg[pseg_id].cluster); 184 330 fprintf( fpout, " psegname = \"%s\"\n", pseg[pseg_id].name); 185 331 fprintf( fpout, " ident = \"%d\" >\n", vseg[vseg_id].ident); … … 196 342 fprintf( fpout, " binpath = \"%s\" />\n", vobj[vobj_id].binpath); 197 343 } 198 fprintf( fpout, " </vseg>\n \n");344 fprintf( fpout, " </vseg>\n"); 199 345 } 200 346 for ( task_id = vspace[vspace_id].task_offset ; -
soft/giet_vm/xml/xml_parser.c
r175 r181 1 1 /////////////////////////////////////////////////////////////////////////////////////// 2 2 // File : xml_parser.c 3 // Date : 04/04/20123 // Date : 14/04/2012 4 4 // Author : alain greiner 5 5 // Copyright (c) UPMC-LIP6 … … 17 17 #include <stdio.h> 18 18 #include <string.h> 19 #include <assert.h> 19 20 #include <libxml/xmlreader.h> 20 21 #include <mapping_info.h> … … 27 28 #define MAX_VSEGS 4096 28 29 #define MAX_VOBJS 8192 29 30 #define XML_PARSER_DEBUG 0 30 #define MAX_PROCS 1024 31 #define MAX_IRQS 8192 32 #define MAX_COPROCS 4096 33 #define MAX_CP_PORTS 8192 34 #define MAX_CP_REGS 8192 35 36 #define XML_PARSER_DEBUG 1 31 37 32 38 /////////////////////////////////////////////////////////////////////////////////// … … 34 40 /////////////////////////////////////////////////////////////////////////////////// 35 41 36 mapping_header_t* header; 37 mapping_cluster_t* cluster[MAX_CLUSTERS]; // cluster array 38 mapping_pseg_t* pseg[MAX_PSEGS]; // pseg array 39 mapping_vspace_t* vspace[MAX_VSPACES]; // vspace array 40 mapping_vseg_t* vseg[MAX_VSEGS]; // vseg array 41 mapping_vobj_t* vobj[MAX_VOBJS]; // vobj array 42 mapping_task_t* task[MAX_TASKS]; // task array 42 mapping_header_t* header; 43 mapping_cluster_t* cluster[MAX_CLUSTERS]; // cluster array 44 mapping_pseg_t* pseg[MAX_PSEGS]; // pseg array 45 mapping_vspace_t* vspace[MAX_VSPACES]; // vspace array 46 mapping_vseg_t* vseg[MAX_VSEGS]; // vseg array 47 mapping_vobj_t* vobj[MAX_VOBJS]; // vobj array 48 mapping_task_t* task[MAX_TASKS]; // task array 49 mapping_proc_t* proc[MAX_PROCS]; // proc array 50 mapping_irq_t* irq[MAX_IRQS]; // irq array 51 mapping_coproc_t* coproc[MAX_COPROCS]; // coproc array 52 mapping_coproc_port_t* cp_port[MAX_CP_PORTS]; // coproc port array 53 mapping_coproc_reg_t* cp_reg[MAX_CP_REGS]; // coproc reg array 54 55 typedef struct vobj_ref_s 56 { 57 char vspace_name[32]; 58 char vobj_name[32]; 59 }vobj_ref_t; 60 61 // This arrray is useful to temporary save the a vobj referece 62 // formed by a vspace_name and a vobj_name (struct vobj_ref_s). 63 // This arry will be used to set the attribute vobj_id of coproc_port 64 // once all the vspace have been parsed. 65 vobj_ref_t* cp_port_vobj_ref[MAX_CP_PORTS]; 43 66 44 67 unsigned int cluster_index = 0; 45 68 unsigned int vspace_index = 0; 46 69 unsigned int global_index = 0; 47 unsigned int pseg_index = 0; 70 unsigned int pseg_index = 0; 71 72 unsigned int proc_index = 0; 73 unsigned int proc_loc_index = 0; 74 75 unsigned int irq_index = 0; 76 unsigned int irq_loc_index = 0; 77 78 unsigned int coproc_index = 0; 79 unsigned int coproc_loc_index = 0; 80 81 unsigned int cp_port_index = 0; 82 unsigned int cp_port_loc_index = 0; 83 84 unsigned int cp_reg_index = 0; 85 unsigned int cp_reg_loc_index = 0; 86 48 87 unsigned int vseg_index = 0; 49 88 unsigned int vseg_loc_index = 0; … … 127 166 } // end getStringValue() 128 167 129 ////////////////////////// 130 int getPsegId( char* str ) 168 /////////////////////////////////////// 169 int getPsegId( unsigned int cluster_id, 170 char* pseg_name ) 131 171 { 132 172 unsigned int pseg_id; 133 134 for ( pseg_id = 0 ; pseg_id < header->psegs ; pseg_id++ ) 135 { 136 if ( strcmp(pseg[pseg_id]->name, str) == 0 ) return pseg_id; 173 unsigned int pseg_min = cluster[cluster_id]->pseg_offset; 174 unsigned int pseg_max = pseg_min + cluster[cluster_id]->psegs; 175 176 for ( pseg_id = pseg_min ; pseg_id < pseg_max ; pseg_id++ ) 177 { 178 if ( strcmp(pseg[pseg_id]->name, pseg_name) == 0 ) return pseg_id; 137 179 } 138 180 return -1; 139 181 } 140 182 141 ////////////////////////////////////////// 183 //////////////////////////////////////////// 184 int getVspaceId( char* vspace_name) 185 //////////////////////////////////////////// 186 { 187 unsigned int vspace_id; 188 189 for( vspace_id = 0; vspace_id < vspace_index ; vspace_id++) 190 { 191 if( !strcmp(vspace[vspace_id]->name, vspace_name)) 192 { 193 return vspace_id; 194 } 195 } 196 return -1; 197 } 198 199 //////////////////////////////////////////// 142 200 int getVobjLocId( unsigned int vspace_id, 143 char* str ) 201 char* vobj_name, 202 unsigned int vspace_max) 203 //////////////////////////////////////////// 144 204 { 145 205 unsigned int vobj_id; 146 206 unsigned int vobj_min = vspace[vspace_id]->vobj_offset; 147 unsigned int vobj_max = vobj_min + v obj_loc_index;207 unsigned int vobj_max = vobj_min + vspace_max; 148 208 149 209 for ( vobj_id = vobj_min ; vobj_id < vobj_max ; vobj_id++ ) 150 210 { 151 if ( strcmp(vobj[vobj_id]->name, str) == 0 )211 if ( strcmp(vobj[vobj_id]->name, vobj_name) == 0 ) 152 212 { 153 213 return (vobj_id - vobj_min); … … 157 217 } 158 218 159 ////////////////////////////////////////// 160 void taskNode ( xmlTextReaderPtr reader ) 219 /////////////////////////////////////////// 220 void cpPortNode ( xmlTextReaderPtr reader ) 221 /////////////////////////////////////////// 222 { 223 char* str; 224 unsigned int ok; 225 226 if ( xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT ) return; 227 228 if ( cp_port_index >= MAX_CP_PORTS ) 229 { 230 printf("[XML ERROR] The number of ports (for coprocs) is larger than %d\n", MAX_CP_PORTS); 231 } 232 233 #if XML_PARSER_DEBUG 234 printf("\n port %d\n", cp_port_index); 235 #endif 236 237 cp_port[cp_port_index] = (mapping_coproc_port_t*)malloc(sizeof(mapping_coproc_port_t)); 238 cp_port_vobj_ref[cp_port_index] = (vobj_ref_t*)malloc(sizeof(vobj_ref_t)); 239 240 241 242 ///////// get direction attribute 243 str = getStringValue( reader, "direction", &ok ); 244 if ( ok ) 245 { 246 #if XML_PARSER_DEBUG 247 printf(" direction = %s\n", str); 248 #endif 249 if ( strcmp(str, "TO_COPROC") ) cp_port[cp_port_index]->direction = PORT_TO_COPROC; 250 else if ( strcmp(str, "FROM_COPROC") ) cp_port[cp_port_index]->direction = PORT_FROM_COPROC; 251 else 252 { 253 printf("[XML ERROR] illegal <direction> for coproc_port %d in cluster %d\n", 254 cp_port_index, cluster_index); 255 exit(1); 256 } 257 } 258 else 259 { 260 printf("[XML ERROR] missing <direction> for coproc_port %d in cluster %d\n", 261 cp_port_index, cluster_index); 262 exit(1); 263 } 264 265 /////////// get vspacename attribute 266 str = getStringValue( reader, "vspacename", &ok ); 267 #if XML_PARSER_DEBUG 268 printf(" vspacename = %s\n", str); 269 #endif 270 if ( ok ) 271 { 272 strncpy(cp_port_vobj_ref[cp_port_index]->vspace_name, str, 31); 273 } 274 else 275 { 276 printf("[XML ERROR] missing <vspacename> for coproc_port %d in cluster %d\n", 277 cp_port_index, cluster_index); 278 exit(1); 279 } 280 281 /////////// get vobjname attribute 282 str = getStringValue( reader, "vobjname", &ok ); 283 #if XML_PARSER_DEBUG 284 printf(" vobjname = %s\n", str); 285 #endif 286 if ( ok ) 287 { 288 strncpy(cp_port_vobj_ref[cp_port_index]->vobj_name, str, 31); 289 } 290 else 291 { 292 printf("[XML ERROR] missing <vobjname> for coproc_port %d in cluster %d\n", 293 cp_port_index, cluster_index); 294 exit(1); 295 } 296 297 cp_port_index++; 298 cp_port_loc_index++; 299 300 } // end cpPortNode() 301 302 ///////////////////////////////////////// 303 void cpRegNode ( xmlTextReaderPtr reader ) 304 ///////////////////////////////////////// 305 { 306 char* str; 307 unsigned int value; 308 unsigned int ok; 309 310 if ( xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT ) return; 311 312 /* TWO: check source file consistency if possible */ 313 if ( cp_reg_index >= MAX_CP_REGS ) 314 { 315 printf("[XML ERROR] The number of regs (for coprocs) is larger than %d\n", MAX_CP_REGS); 316 } 317 318 #if XML_PARSER_DEBUG 319 printf("\n reg %d\n", cp_reg_index); 320 #endif 321 322 /* THIRD*/ 323 cp_reg[cp_reg_index] = (mapping_coproc_reg_t*)malloc(sizeof(mapping_coproc_reg_t)); 324 325 /* FOURTH: read all attribute*/ 326 327 /////////// get name attribute 328 str = getStringValue( reader, "name", &ok ); 329 #if XML_PARSER_DEBUG 330 printf(" name = %s\n", str); 331 #endif 332 if ( ok ) 333 { 334 strncpy(cp_reg[cp_reg_index]->name, str, 31); 335 } 336 else 337 { 338 printf("[XML ERROR] illegal or missing <name> for coproc_reg %d in cluster %d\n", 339 cp_reg_index, cluster_index); 340 exit(1); 341 } 342 343 ///////// get type attribute 344 str = getStringValue( reader, "type", &ok ); 345 if ( ok ) 346 { 347 #if XML_PARSER_DEBUG 348 printf(" type = %s\n", str); 349 #endif 350 if ( strcmp(str, "STATUS") ) cp_reg[cp_reg_index]->type = REG_TYPE_STATUS; 351 else if ( strcmp(str, "CONFIG") ) cp_reg[cp_reg_index]->type = REG_TYPE_CONFIG; 352 else 353 { 354 printf("[XML ERROR] illegal <type> for coproc_reg %d in cluster %d\n", 355 cp_reg_index, cluster_index); 356 exit(1); 357 } 358 } 359 else 360 { 361 printf("[XML ERROR] missing <type> for coproc_reg %d in cluster %d\n", 362 cp_reg_index, cluster_index); 363 exit(1); 364 } 365 366 ///////// get value attribute 367 value = getIntValue(reader, "value", &ok); 368 if ( ok ) 369 { 370 #if XML_PARSER_DEBUG 371 printf(" value = %d\n", value); 372 #endif 373 cp_reg[cp_reg_index]->value = value; 374 } 375 else 376 { 377 printf("[XML ERROR] illegal or missing <value> for coproc_reg %d in cluster %d\n", 378 cp_reg_index, cluster_index); 379 exit(1); 380 } 381 382 ///////// get channel attribute 383 value = getIntValue(reader, "channel", &ok); 384 if ( ok ) 385 { 386 #if XML_PARSER_DEBUG 387 printf(" channel = %d\n", value); 388 #endif 389 cp_reg[cp_reg_index]->channel_id = value; 390 } 391 else 392 { 393 printf("[XML ERROR] illegal or missing <channel> for coproc_reg %d in cluster %d\n", 394 cp_reg_index, cluster_index); 395 exit(1); 396 } 397 398 ///////// get index attribute 399 value = getIntValue(reader, "index", &ok); 400 if ( ok ) 401 { 402 #if XML_PARSER_DEBUG 403 printf(" index = %d\n", value); 404 #endif 405 cp_reg[cp_reg_index]->loc_id = value; 406 } 407 else 408 { 409 printf("[XML ERROR] illegal or missing <index> for coproc_reg %d in cluster %d\n", 410 cp_reg_index, cluster_index); 411 exit(1); 412 } 413 414 cp_reg_index++; 415 cp_reg_loc_index++; 416 417 } // end cpRegNode() 418 419 ///////////////////////////////////////// 420 void coprocNode ( xmlTextReaderPtr reader ) 421 ///////////////////////////////////////// 422 { 423 char* str; 424 unsigned int ok; 425 426 cp_port_loc_index = 0; 427 cp_reg_loc_index = 0; 428 429 if ( xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT ) return; 430 431 if ( coproc_index >= MAX_COPROCS ) 432 { 433 printf("[XML ERROR] The number of coprocs is larger than %d\n", MAX_COPROCS); 434 } 435 436 #if XML_PARSER_DEBUG 437 printf("\n coproc %d\n", coproc_index); 438 #endif 439 440 coproc[coproc_index] = (mapping_coproc_t*)malloc(sizeof(mapping_coproc_t)); 441 442 443 /////////// get name attribute 444 str = getStringValue( reader, "name", &ok ); 445 if ( ok ) 446 { 447 #if XML_PARSER_DEBUG 448 printf(" name = %s\n", str); 449 #endif 450 strncpy(coproc[coproc_index]->name, str, 31); 451 } 452 else 453 { 454 printf("[XML ERROR] illegal or missing <name> for coproc %d in cluster %d\n", 455 coproc_index, cluster_index); 456 exit(1); 457 } 458 459 /////////// get psegname attribute 460 str = getStringValue(reader,"psegname", &ok); 461 if ( ok == 0 ) 462 { 463 printf("[XML ERROR] illegal or missing <psegname> for coproc %d in cluster %d\n", 464 coproc_index, cluster_index); 465 exit(1); 466 } 467 468 /////////// set psegid attribute 469 int index = getPsegId( cluster_index, str ); 470 if ( index >= 0 ) 471 { 472 #if XML_PARSER_DEBUG 473 printf(" clusterid = %d\n", cluster_index); 474 printf(" psegname = %s\n", str); 475 printf(" psegid = %d\n", index); 476 #endif 477 coproc[coproc_index]->psegid = index; 478 assert(pseg[index]->type == PSEG_TYPE_PERI && "coproc psegname attribute must refer to a pseg of type PERI" ); 479 } 480 else 481 { 482 printf("[XML ERROR] pseg not found for coproc %d / clusterid = %d / psegname = %s\n", 483 coproc_index, cluster_index, str ); 484 exit(1); 485 } 486 487 ////////// set port_offset and reg_offset attribute 488 coproc[coproc_index]->port_offset = cp_port_index; 489 coproc[coproc_index]->reg_offset = cp_reg_index; 490 491 #if XML_PARSER_DEBUG 492 printf(" port_offset = %d\n", cp_port_index); 493 printf(" reg_offset = %d\n", cp_reg_index); 494 #endif 495 496 int status = xmlTextReaderRead(reader); 497 while ( status == 1 ) 498 { 499 const char* tag = (const char*)xmlTextReaderConstName(reader); 500 501 if ( strcmp(tag,"port") == 0 ) cpPortNode(reader); 502 else if ( strcmp(tag,"reg") == 0 ) cpRegNode(reader); 503 else if ( strcmp(tag,"#text") == 0 ) { } 504 else if ( strcmp(tag,"coproc") == 0 ) 505 { 506 coproc[coproc_index]->ports = cp_port_loc_index; 507 coproc[coproc_index]->regs = cp_reg_loc_index; 508 coproc_loc_index++; 509 coproc_index++; 510 return; 511 } 512 else 513 { 514 printf("[XML ERROR] Unknown tag %s",tag); 515 exit(1); 516 } 517 status = xmlTextReaderRead ( reader ); 518 } 519 } // end coprocNode() 520 521 /////////////////////////////////////// 522 void irqNode( xmlTextReaderPtr reader ) 523 /////////////////////////////////////// 161 524 { 162 525 unsigned int ok; … … 166 529 if ( xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT ) return; 167 530 531 if ( irq_index >= MAX_IRQS ) 532 { 533 printf("[XML ERROR] The number of irqs is larger than %d\n", MAX_IRQS); 534 } 535 536 #if XML_PARSER_DEBUG 537 printf(" irq %d\n", irq_loc_index); 538 #endif 539 540 irq[irq_index] = (mapping_irq_t*)malloc(sizeof(mapping_irq_t)); 541 542 ///////// get type attribute 543 str = getStringValue(reader,"type", &ok); 544 if ( ok ) 545 { 546 #if XML_PARSER_DEBUG 547 printf(" type = %s\n", str); 548 #endif 549 if ( strcmp(str, "HARD") ) irq[irq_index]->type = IRQ_TYPE_HARD; 550 else if ( strcmp(str, "SOFT") ) irq[irq_index]->type = IRQ_TYPE_SOFT; 551 else 552 { 553 printf("[XML ERROR] undefined IRQ <type> for processor %d in cluster %d\n", 554 cluster_index, proc_loc_index ); 555 exit(1); 556 } 557 } 558 else 559 { 560 printf("[XML ERROR] missing IRQ <type> for processor %d in cluster %d\n", 561 cluster_index, proc_loc_index ); 562 exit(1); 563 } 564 565 ///////// get irqid attribute 566 value = getIntValue(reader, "icuid", &ok); 567 if ( ok ) 568 { 569 #if XML_PARSER_DEBUG 570 printf(" icuid = %d\n", value); 571 #endif 572 irq[irq_index]->icuid = value; 573 if ( value >= 32 ) 574 { 575 printf("[XML ERROR] IRQ <icuid> too large for processor %d in cluster %d\n", 576 cluster_index, proc_loc_index ); 577 exit(1); 578 } 579 } 580 else 581 { 582 printf("[XML ERROR] missing IRQ <icuid> for processor %d in cluster %d\n", 583 cluster_index, proc_loc_index ); 584 exit(1); 585 } 586 587 ///////// get isr attribute 588 str = getStringValue(reader,"isr", &ok); 589 if ( ok ) 590 { 591 #if XML_PARSER_DEBUG 592 printf(" isr = %s\n", str); 593 #endif 594 if ( strcmp(str, "ISR_SWITCH") ) irq[irq_index]->isr = ISR_SWITCH; 595 else if ( strcmp(str, "ISR_IOC") ) irq[irq_index]->isr = ISR_IOC; 596 else if ( strcmp(str, "ISR_FBDMA") ) irq[irq_index]->isr = ISR_FBDMA; 597 else if ( strcmp(str, "ISR_TTY") ) irq[irq_index]->isr = ISR_TTY; 598 else 599 { 600 printf("[XML ERROR] illegal IRQ <isr> for processor %d in cluster %d\n", 601 cluster_index, proc_loc_index ); 602 exit(1); 603 } 604 } 605 else 606 { 607 printf("[XML ERROR] missing IRQ <isr> for processor %d in cluster %d\n", 608 cluster_index, proc_loc_index ); 609 exit(1); 610 } 611 612 ///////// get channel attribute (optionnal : 0 if missing) 613 value = getIntValue(reader, "channel", &ok); 614 if ( ok ) 615 { 616 #if XML_PARSER_DEBUG 617 printf(" channel = %d\n", value); 618 #endif 619 irq[irq_index]->channel = value; 620 } 621 else 622 { 623 irq[irq_index]->channel = 0; 624 } 625 626 irq_index++; 627 irq_loc_index++; 628 629 } // end irqNode 630 631 ///////////////////////////////////////// 632 void procNode ( xmlTextReaderPtr reader ) 633 ///////////////////////////////////////// 634 { 635 unsigned int ok; 636 unsigned int value; 637 638 irq_loc_index = 0; 639 640 if ( xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT ) return; 641 642 if ( proc_index >= MAX_PROCS ) 643 { 644 printf("[XML ERROR] The number of procs is larger than %d\n", MAX_PROCS); 645 } 646 647 #if XML_PARSER_DEBUG 648 printf("\n proc %d\n", proc_index); 649 #endif 650 651 proc[proc_index] = (mapping_proc_t*)malloc(sizeof(mapping_proc_t)); 652 653 654 /////////// get index attribute (optional) 655 value = getIntValue(reader,"index",&ok); 656 if ( ok && (value != proc_index) ) 657 { 658 printf("[XML ERROR] wrong proc index / expected value is %d", 659 proc_index); 660 exit(1); 661 } 662 663 ////////// set irq_offset attribute 664 proc[proc_index]->irq_offset = irq_index; 665 #if XML_PARSER_DEBUG 666 printf(" irq_offset = %d\n", irq_index); 667 #endif 668 669 int status = xmlTextReaderRead(reader); 670 while ( status == 1 ) 671 { 672 const char* tag = (const char*)xmlTextReaderConstName(reader); 673 674 if ( strcmp(tag,"irq") == 0 ) irqNode(reader); 675 else if ( strcmp(tag,"#text") == 0 ) { } 676 else if ( strcmp(tag,"proc") == 0 ) 677 { 678 proc[proc_index]->irqs = irq_loc_index; 679 proc_loc_index++; 680 proc_index++; 681 return; 682 } 683 else 684 { 685 printf("[XML ERROR] Unknown tag %s",tag); 686 exit(1); 687 } 688 status = xmlTextReaderRead ( reader ); 689 } 690 } // end procNode() 691 692 693 ///////////////////////////////////////// 694 void taskNode ( xmlTextReaderPtr reader ) 695 ///////////////////////////////////////// 696 { 697 unsigned int ok; 698 unsigned int value; 699 char* str; 700 701 if ( xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT ) return; 702 168 703 if ( task_index >= MAX_TASKS ) 169 704 { … … 241 776 if ( ok ) 242 777 { 243 int index = getVobjLocId( vspace_index, str );778 int index = getVobjLocId( vspace_index, str , vobj_loc_index); 244 779 if ( index >= 0 ) 245 780 { … … 380 915 } 381 916 } 382 else if (ok && (strcmp( type_str, "BLOB") == 0)) vobj[vobj_index]->type = VOBJ_TYPE_BLOB;383 else if (ok && (strcmp( type_str, "PTAB") == 0)) vobj[vobj_index]->type = VOBJ_TYPE_PTAB;384 else if (ok && (strcmp( type_str, "PERI") == 0)) vobj[vobj_index]->type = VOBJ_TYPE_PERI;385 else if (ok && (strcmp( type_str, "MWMR") == 0)) vobj[vobj_index]->type = VOBJ_TYPE_MWMR;386 else if (ok && (strcmp( type_str, "LOCK") == 0)) vobj[vobj_index]->type = VOBJ_TYPE_LOCK;387 else if (ok && (strcmp( type_str, "BUFFER") == 0)) vobj[vobj_index]->type = VOBJ_TYPE_BUFFER;388 else if (ok && (strcmp( type_str, "BARRIER") == 0)) vobj[vobj_index]->type = VOBJ_TYPE_BARRIER;917 else if (ok && (strcmp(str, "BLOB") == 0)) vobj[vobj_index]->type = VOBJ_TYPE_BLOB; 918 else if (ok && (strcmp(str, "PTAB") == 0)) vobj[vobj_index]->type = VOBJ_TYPE_PTAB; 919 else if (ok && (strcmp(str, "PERI") == 0)) vobj[vobj_index]->type = VOBJ_TYPE_PERI; 920 else if (ok && (strcmp(str, "MWMR") == 0)) vobj[vobj_index]->type = VOBJ_TYPE_MWMR; 921 else if (ok && (strcmp(str, "LOCK") == 0)) vobj[vobj_index]->type = VOBJ_TYPE_LOCK; 922 else if (ok && (strcmp(str, "BUFFER") == 0)) vobj[vobj_index]->type = VOBJ_TYPE_BUFFER; 923 else if (ok && (strcmp(str, "BARRIER") == 0)) vobj[vobj_index]->type = VOBJ_TYPE_BARRIER; 389 924 else 390 925 { … … 449 984 else 450 985 { 451 if( vobj[vobj_index]->type == VOBJ_TYPE_MWMR || vobj[vobj_index]->type == VOBJ_TYPE_BARRIER)452 { 453 printf("[XML ERROR] illegal or missing <value> attribute for vobj (%d,%d) , of type: %s\n",454 vspace_index, vobj_loc_index, type_str);455 exit(1);456 }457 else458 986 if((vobj[vobj_index]->type == VOBJ_TYPE_MWMR || vobj[vobj_index]->type == VOBJ_TYPE_BARRIER )) 987 { 988 printf("[XML ERROR] illegal or missing <value> attribute for vobj (%d,%d). \ 989 All MWMR or BARRIER vobj must have a init value \n", 990 vspace_index, vobj_loc_index); 991 exit(1); 992 } 993 vobj[vobj_index]->init = 0; 459 994 } 460 995 … … 525 1060 } 526 1061 1062 ////////// get clusterid and psegname attributes 1063 value = getIntValue(reader,"clusterid", &ok); 1064 if ( ok == 0 ) 1065 { 1066 printf("[XML ERROR] illegal or missing <clusterid> for vseg %d\n", 1067 vseg_loc_index); 1068 exit(1); 1069 } 1070 str = getStringValue(reader,"psegname", &ok); 1071 if ( ok == 0 ) 1072 { 1073 printf("[XML ERROR] illegal or missing <psegname> for vseg %d\n", 1074 vseg_loc_index); 1075 exit(1); 1076 } 1077 1078 /////////// set psegid field 1079 int index = getPsegId( value, str ); 1080 if ( index >= 0 ) 1081 { 1082 #if XML_PARSER_DEBUG 1083 printf(" clusterid = %d\n", value); 1084 printf(" psegname = %s\n", str); 1085 printf(" psegid = %d\n", index); 1086 #endif 1087 vseg[vseg_index]->psegid = index; 1088 } 1089 else 1090 { 1091 printf("[XML ERROR] pseg not found for vseg %d / clusterid = %d / psegname = %s\n", 1092 vseg_loc_index, value, str ); 1093 exit(1); 1094 } 1095 527 1096 ////////// get ident attribute (optional : 0 if missing) 528 1097 value = getIntValue(reader,"ident", &ok); … … 537 1106 { 538 1107 vseg[vseg_index]->ident = 0; 539 }540 541 ////////// get psegname attribute542 str = getStringValue(reader,"psegname", &ok);543 if ( ok )544 {545 int index = getPsegId( str );546 if ( index >= 0 )547 {548 #if XML_PARSER_DEBUG549 printf(" psegname = %s\n", str);550 printf(" psegid = %d\n", index);551 #endif552 vseg[vseg_index]->psegid = index;553 }554 else555 {556 printf("[XML ERROR] illegal or missing <psegname> for vseg %d\n",557 vseg_loc_index);558 exit(1);559 }560 }561 else562 {563 printf("[XML ERROR] illegal or missing <psegname> for vseg %d\n",564 vseg_loc_index);565 exit(1);566 1108 } 567 1109 … … 594 1136 } 595 1137 596 ////////// set the length attribute to 0 597 vseg[vseg_index]->length = value; 598 599 ////////// get vobjs 600 int status = xmlTextReaderRead ( reader ); 1138 ////////// get vobjs in vseg 1139 int status = xmlTextReaderRead(reader); 601 1140 while ( status == 1 ) 602 1141 { 603 1142 const char* tag = (const char*)xmlTextReaderConstName(reader); 604 1143 605 if ( strcmp(tag,"vobj") == 0) vobjNode(reader);1144 if ( strcmp(tag,"vobj") == 0 ) vobjNode(reader); 606 1145 else if ( strcmp(tag,"#text" ) == 0 ) { } 607 else if ( strcmp(tag,"vseg") == 0 ) 608 { 609 // checking source file consistency? 1146 else if ( strcmp(tag,"vseg") == 0 ) 1147 { 610 1148 vseg[vseg_index]->vobjs = vobj_count; 611 1149 vseg_index++; … … 688 1226 } 689 1227 690 int status = xmlTextReaderRead ( reader);1228 int status = xmlTextReaderRead(reader); 691 1229 while ( status == 1 ) 692 1230 { 693 1231 const char* tag = (const char*)xmlTextReaderConstName(reader); 694 1232 695 if ( strcmp(tag,"vseg") == 0) vsegNode(reader);696 else if ( strcmp(tag,"task") == 0) taskNode(reader);697 else if ( strcmp(tag,"#text" )== 0 ) { }698 else if ( strcmp(tag,"vspace") == 0)699 { 700 vspace[vspace_index]->vobjs = vobj_loc_index; 1233 if ( strcmp(tag,"vseg") == 0 ) vsegNode(reader); 1234 else if ( strcmp(tag,"task") == 0 ) taskNode(reader); 1235 else if ( strcmp(tag,"#text") == 0 ) { } 1236 else if ( strcmp(tag,"vspace") == 0 ) 1237 { 1238 vspace[vspace_index]->vobjs = vobj_loc_index; 701 1239 vspace[vspace_index]->tasks = task_loc_index ; 702 1240 vspace[vspace_index]->vsegs = vseg_loc_index ; 703 1241 704 1242 // get index of the vobj containing the start vector 705 int index = getVobjLocId( vspace_index, str );1243 int index = getVobjLocId( vspace_index, str , vobj_loc_index ); 706 1244 if(index == -1) 707 1245 { … … 713 1251 vspace[vspace_index]->start_offset = index; 714 1252 #if XML_PARSER_DEBUG 715 printf(" startname = %s\n", str); 716 printf(" startid = %d\n", index); 1253 printf(" startname = %s\n", str); 1254 printf(" startid = %d\n", index); 1255 printf(" end vspace %d\n\n", vspace_index); 717 1256 #endif 718 1257 } … … 765 1304 pseg[pseg_index] = (mapping_pseg_t*)malloc(sizeof(mapping_pseg_t)); 766 1305 767 // get name attribute1306 /////// get name attribute 768 1307 str = getStringValue( reader, "name", &ok ); 769 1308 #if XML_PARSER_DEBUG 770 printf(" name = %s\n", str);1309 printf(" name = %s\n", str); 771 1310 #endif 772 1311 if ( ok ) … … 776 1315 else 777 1316 { 778 printf("[XML ERROR] illegal or missing <name> for pseg %d\n", pseg_index); 779 exit(1); 780 } 781 782 // get base attribute 1317 printf("[XML ERROR] illegal or missing <name> for pseg %d in cluster %d\n", 1318 pseg_index, cluster_index); 1319 exit(1); 1320 } 1321 1322 //////// get type attribute 1323 str = getStringValue(reader, "type", &ok); 1324 #if XML_PARSER_DEBUG 1325 printf(" type = %s\n", str); 1326 #endif 1327 if (ok && (strcmp(str, "RAM" ) == 0)) pseg[pseg_index]->type = PSEG_TYPE_RAM; 1328 else if (ok && (strcmp(str, "ROM" ) == 0)) pseg[pseg_index]->type = PSEG_TYPE_ROM; 1329 else if (ok && (strcmp(str, "PERI") == 0)) pseg[pseg_index]->type = PSEG_TYPE_PERI; 1330 else 1331 { 1332 printf("[XML ERROR] illegal or missing <type> for pseg %s in cluster %d\n", 1333 pseg[pseg_index]->name, cluster_index); 1334 exit(1); 1335 } 1336 1337 //////// get base attribute 783 1338 value = getIntValue( reader, "base", &ok ); 784 1339 #if XML_PARSER_DEBUG 785 printf(" base =%x\n", value);1340 printf(" base = 0x%x\n", value); 786 1341 #endif 787 1342 if ( ok ) … … 791 1346 else 792 1347 { 793 printf("[XML ERROR] illegal or missing <base> for pseg %d\n", pseg_index); 794 exit(1); 795 } 796 797 // get length attribute 1348 printf("[XML ERROR] illegal or missing <base> for pseg %s in cluster %d\n", 1349 pseg[pseg_index]->name, cluster_index); 1350 exit(1); 1351 } 1352 1353 //////// get length attribute 798 1354 value = getIntValue( reader, "length", &ok ); 799 1355 #if XML_PARSER_DEBUG 800 printf(" length = %x\n\n", value);1356 printf(" length = 0x%x\n", value); 801 1357 #endif 802 1358 if ( ok ) … … 806 1362 else 807 1363 { 808 printf("[XML ERROR] illegal or missing <length> for pseg %d\n", pseg_index); 809 exit(1); 810 } 1364 printf("[XML ERROR] illegal or missing <length> for pseg %s in cluster %d\n", 1365 pseg[pseg_index]->name, cluster_index); 1366 exit(1); 1367 } 1368 1369 //////// set cluster attribute 1370 pseg[pseg_index]->cluster = cluster_index; 811 1371 812 1372 pseg_index++; 1373 cluster[cluster_index]->psegs++; 813 1374 } // end psegNode() 814 1375 … … 819 1380 unsigned int value; 820 1381 1382 proc_loc_index = 0; 1383 coproc_loc_index = 0; 1384 cluster[cluster_index] = 0; 1385 821 1386 if ( xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT ) return; 822 1387 … … 829 1394 830 1395 #if XML_PARSER_DEBUG 831 printf(" cluster %d :\n", cluster_index);1396 printf(" cluster %d\n", cluster_index); 832 1397 #endif 833 1398 834 1399 cluster[cluster_index] = (mapping_cluster_t*)malloc(sizeof(mapping_cluster_t)); 835 1400 836 // get index attribute (optional)1401 /////////// get index attribute (optional) 837 1402 value = getIntValue(reader,"index",&ok); 838 #if XML_PARSER_DEBUG839 printf(" index = %d\n", value);840 #endif841 1403 if ( ok && (value != cluster_index) ) 842 1404 { … … 846 1408 } 847 1409 848 // get procs attribute 849 value = getIntValue(reader,"procs",&ok); 850 #if XML_PARSER_DEBUG 851 printf(" procs = %d\n", value); 852 #endif 853 if ( ok ) 854 { 855 cluster[cluster_index]->procs = value; 856 } 857 else 858 { 859 printf("[XML ERROR] illegal or missing <procs> attribute for cluster %d", 860 cluster_index); 861 exit(1); 862 } 863 864 cluster_index++; 1410 1411 ////////// set pseg_offset attribute 1412 cluster[cluster_index]->pseg_offset = pseg_index; 1413 cluster[cluster_index]->proc_offset = proc_index; 1414 cluster[cluster_index]->coproc_offset = coproc_index; 1415 #if XML_PARSER_DEBUG 1416 printf(" pseg_offset = %d\n", pseg_index); 1417 printf(" proc_offset = %d\n", proc_index); 1418 printf(" coproc_offset = %d\n", coproc_index); 1419 #endif 1420 1421 ////////// get psegs, coproc and/or procs 1422 int status = xmlTextReaderRead(reader); 1423 1424 while ( status == 1 ) 1425 { 1426 const char* tag = (const char*)xmlTextReaderConstName(reader); 1427 1428 if ( strcmp(tag, "pseg") == 0 ) psegNode(reader); 1429 else if ( strcmp(tag, "proc") == 0 ) procNode(reader); 1430 else if ( strcmp(tag, "coproc") == 0 ) coprocNode(reader); 1431 else if ( strcmp(tag, "#text") == 0 ) { } 1432 else if ( strcmp(tag, "cluster") == 0 ) 1433 { 1434 #if XML_PARSER_DEBUG 1435 printf(" end cluster %d\n", cluster_index); 1436 #endif 1437 cluster[cluster_index]->procs = proc_loc_index; 1438 cluster[cluster_index]->coprocs = coproc_loc_index; 1439 //psegs = pseg_loc_index is done in psegNode(), so coprocNode() call to getPsegId() success 1440 cluster_index++; 1441 return; 1442 } 1443 status = xmlTextReaderRead(reader); 1444 } 865 1445 } // end clusterNode() 866 1446 … … 874 1454 #endif 875 1455 876 int status = xmlTextReaderRead ( reader);1456 int status = xmlTextReaderRead(reader); 877 1457 while ( status == 1 ) 878 1458 { … … 891 1471 else 892 1472 { 1473 #if XML_PARSER_DEBUG 1474 printf(" end cluster set\n\n"); 1475 #endif 1476 header->psegs = pseg_index; 1477 header->procs = proc_index; 1478 header->irqs = irq_index; 1479 header->coprocs = coproc_index; 1480 header->cp_ports = cp_port_index; 1481 header->cp_regs = cp_reg_index; 893 1482 return; 894 1483 } … … 899 1488 exit(1); 900 1489 } 901 status = xmlTextReaderRead ( reader);1490 status = xmlTextReaderRead(reader); 902 1491 } 903 1492 } // end clusterSetNode() 904 905 ///////////////////////////////////////////906 void psegSetNode( xmlTextReaderPtr reader )907 {908 if ( xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT ) return;909 910 #if XML_PARSER_DEBUG911 printf(" psegs set\n");912 #endif913 914 int status = xmlTextReaderRead ( reader );915 while ( status == 1 )916 {917 const char* tag = (const char*)xmlTextReaderConstName(reader);918 919 if ( strcmp(tag,"pseg") == 0 ) psegNode(reader);920 else if ( strcmp(tag,"#text") == 0 ) { }921 else if ( strcmp(tag,"psegset") == 0 )922 {923 // checking source file consistency924 if ( pseg_index != header->psegs )925 {926 printf("[XML ERROR] Wrong number of psegs\n");927 exit(1);928 }929 else930 {931 return;932 }933 }934 else935 {936 printf("[XML ERROR] Unknown tag in psegset node : %s",tag);937 exit(1);938 }939 status = xmlTextReaderRead ( reader );940 }941 } // end psegSetNode()942 1493 943 1494 ///////////////////////////////////////////// … … 950 1501 #endif 951 1502 952 int status = xmlTextReaderRead ( reader);1503 int status = xmlTextReaderRead(reader); 953 1504 while ( status == 1 ) 954 1505 { … … 967 1518 else 968 1519 { 1520 #if XML_PARSER_DEBUG 1521 printf(" end global set\n\n"); 1522 #endif 969 1523 vseg_loc_index = 0; 970 1524 return; … … 1071 1625 } 1072 1626 1073 ////////// get psegs attribute1074 value = getIntValue(reader, "psegs", &ok);1075 if ( ok )1076 {1077 if ( value >= MAX_PSEGS )1078 {1079 printf("[XML ERROR] The number of psegs is larger than %d\n", MAX_PSEGS);1080 exit(1);1081 }1082 #if XML_PARSER_DEBUG1083 printf(" psegs = %d\n", value);1084 #endif1085 header->psegs = value;1086 }1087 else1088 {1089 printf("[XML ERROR] illegal or missing <psegs> attribute in header\n");1090 exit(1);1091 }1092 1093 1627 ///////// get ttys attribute 1094 1628 value = getIntValue(reader, "ttys", &ok); … … 1163 1697 header->signature = IN_MAPPING_SIGNATURE; 1164 1698 1165 int status = xmlTextReaderRead ( reader);1699 int status = xmlTextReaderRead(reader); 1166 1700 while ( status == 1 ) 1167 1701 { … … 1169 1703 1170 1704 if ( strcmp(tag,"clusterset") == 0 ) clusterSetNode(reader); 1171 else if ( strcmp(tag,"psegset") == 0 ) psegSetNode(reader); 1172 else if ( strcmp(tag,"globalset") == 0 ) globalSetNode(reader); 1705 else if ( strcmp(tag,"globalset") == 0 ) globalSetNode(reader); 1173 1706 else if ( strcmp(tag,"vspaceset") == 0 ) vspaceSetNode(reader); 1174 1707 else if ( strcmp(tag,"#text") == 0 ) { } … … 1185 1718 exit(1); 1186 1719 } 1187 status = xmlTextReaderRead ( reader);1720 status = xmlTextReaderRead(reader); 1188 1721 } 1189 1722 } // end headerNode() 1723 1724 void BuildTable( int fdout, 1725 const char* type, 1726 unsigned int nb_elem, 1727 unsigned int elem_size, 1728 char** table) 1729 { 1730 unsigned int i; 1731 unsigned int length; 1732 // write element 1733 for ( i = 0 ; i < nb_elem ; i++ ) 1734 { 1735 length = write(fdout, table[i], elem_size); 1736 1737 #if XML_PARSER_DEBUG 1738 printf("Building binary: writing %s %d\n", type, i); 1739 #endif 1740 1741 if ( length != elem_size ) 1742 { 1743 printf("type: %s\n", type); 1744 perror("error writing"); 1745 exit(1); 1746 } 1747 } 1748 } 1190 1749 1191 1750 /////////////////////////// 1192 1751 void buildBin( int fdout ) 1193 1752 { 1194 unsigned int cluster_id;1195 unsigned int pseg_id;1196 1753 unsigned int vspace_id; 1197 unsigned int vseg_id;1198 1754 unsigned int vobj_id; 1199 unsigned int task_id;1200 1201 1755 unsigned int length; 1202 1756 … … 1210 1764 if ( length != sizeof(mapping_header_t) ) 1211 1765 { 1212 p error("write header");1766 printf("write header error : length = %d \n", length); 1213 1767 exit(1); 1214 1768 } 1215 1769 1216 1770 // write clusters 1217 for ( cluster_id = 0 ; cluster_id < header->clusters ; cluster_id++ ) 1218 { 1219 length = write(fdout, (char*)cluster[cluster_id], sizeof(mapping_cluster_t)); 1220 1221 #if XML_PARSER_DEBUG 1222 printf("\n*** write cluster %d\n", cluster_id); 1223 #endif 1224 1225 if ( length != sizeof(mapping_cluster_t) ) 1226 { 1227 perror("write cluster"); 1228 exit(1); 1229 } 1230 } 1771 BuildTable(fdout, "cluster", cluster_index, sizeof(mapping_cluster_t), (char**) cluster); 1231 1772 1232 1773 // write psegs 1233 for ( pseg_id = 0 ; pseg_id < header->psegs ; pseg_id++ ) 1234 { 1235 length = write(fdout, (char*)pseg[pseg_id], sizeof(mapping_pseg_t)); 1236 1237 #if XML_PARSER_DEBUG 1238 printf("write pseg %d\n", pseg_id); 1239 #endif 1240 1241 if ( length != sizeof(mapping_pseg_t) ) 1242 { 1243 perror("write pseg"); 1244 exit(1); 1245 } 1246 } 1774 BuildTable(fdout, "pseg", pseg_index, sizeof(mapping_pseg_t), (char**) pseg); 1247 1775 1248 1776 // write vspaces … … 1266 1794 1267 1795 // write vsegs 1268 for ( vseg_id = 0 ; vseg_id < header->vsegs ; vseg_id++ ) 1269 { 1270 length = write(fdout, (char*)vseg[vseg_id], sizeof(mapping_vseg_t)); 1271 1272 #if XML_PARSER_DEBUG 1273 printf("write vseg %d\n", vseg_id); 1274 #endif 1275 1276 if ( length != sizeof(mapping_vseg_t) ) 1277 { 1278 perror("write vseg"); 1279 exit(1); 1280 } 1281 } 1796 BuildTable(fdout, "vseg", vseg_index, sizeof(mapping_vseg_t), (char**) vseg); 1282 1797 1283 1798 // write vobjs … … 1301 1816 1302 1817 // write tasks 1303 for ( task_id = 0 ; task_id < header->tasks ; task_id++ ) 1304 { 1305 length = write(fdout, (char*)task[task_id], sizeof(mapping_task_t)); 1306 1307 #if XML_PARSER_DEBUG 1308 printf("write task %d\n", task_id); 1309 #endif 1310 1311 if ( length != sizeof(mapping_task_t) ) 1312 { 1313 perror("write task"); 1314 exit(1); 1315 } 1316 } 1818 BuildTable(fdout, "task", task_index, sizeof(mapping_task_t), (char**) task); 1819 //building proc 1820 BuildTable(fdout, "proc", proc_index, sizeof(mapping_proc_t), (char**) proc); 1821 //building irq 1822 BuildTable(fdout, "irq", irq_index, sizeof(mapping_irq_t), (char**)irq); 1823 //building coproc 1824 BuildTable(fdout, "coproc", coproc_index, sizeof(mapping_coproc_t), (char**)coproc); 1825 //building cp_port 1826 BuildTable(fdout, "cp_port", cp_port_index, sizeof(mapping_coproc_port_t),(char**) cp_port); 1827 //building cp_reg 1828 BuildTable(fdout, "cp_reg", cp_reg_index, sizeof(mapping_coproc_reg_t), (char**)cp_reg); 1829 1317 1830 } // end buildBin() 1831 1832 ///////////////////////////////////////// 1833 // this function set the value of vobj_id 1834 // of the coproc_ports. 1835 /////////////////// 1836 void prepareBuild() 1837 { 1838 unsigned int i; 1839 for(i=0; i< cp_port_index; i++) 1840 { 1841 int vspace_id = getVspaceId( cp_port_vobj_ref[i]->vspace_name ); 1842 if ( vspace_id < 0 ) 1843 { 1844 printf("[XML ERROR] illegal <vspacename> for coproc_port %d,\n", 1845 i); 1846 exit(1); 1847 } 1848 cp_port[i]->vspaceid = vspace_id; 1849 1850 int vobj_id = getVobjLocId( vspace_id, cp_port_vobj_ref[i]->vobj_name, vspace[vspace_id]->vobjs ); 1851 if ( vobj_id >= 0 ) 1852 { 1853 #if XML_PARSER_DEBUG 1854 printf("coproc_port = %d\n", i); 1855 printf(" vspace_name = %s\n", cp_port_vobj_ref[i]->vspace_name); 1856 printf(" vobj_name = %s\n", cp_port_vobj_ref[i]->vobj_name); 1857 printf(" vobj_index = %d\n", vobj_id); 1858 #endif 1859 cp_port[i]->vobjlocid = vobj_id; 1860 assert((vobj[ vspace[vspace_id]->vobj_offset + vobj_id]->type == VOBJ_TYPE_MWMR) && "coproc ports has to refere to a vobj of type MWMR"); 1861 } 1862 else 1863 { 1864 printf("[XML ERROR] illegal <vobjname> for coproc_port %d,\n", 1865 i); 1866 exit(1); 1867 } 1868 1869 } 1870 } 1318 1871 1319 1872 ///////////////////////////////////// … … 1335 1888 LIBXML_TEST_VERSION; 1336 1889 1337 int 1890 int status; 1338 1891 xmlTextReaderPtr reader = xmlReaderForFile ( argv[1], NULL, 0 ); 1339 1892 … … 1344 1897 { 1345 1898 const char* tag = (const char*)xmlTextReaderConstName(reader); 1899 1346 1900 if ( strcmp(tag,"mapping_info") == 0 ) 1347 1901 { 1348 1902 headerNode( reader ); 1903 prepareBuild(); 1349 1904 buildBin( fdout ); 1350 1905 }
Note: See TracChangeset
for help on using the changeset viewer.