Changeset 189 for soft/giet_vm/xml/xml_parser.c
- Timestamp:
- Aug 7, 2012, 6:37:49 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/xml/xml_parser.c
r188 r189 20 20 #include <libxml/xmlreader.h> 21 21 #include <mapping_info.h> 22 #include <irq_handler.h> 22 23 23 24 #define MAX_CLUSTERS 1024 … … 32 33 #define MAX_COPROCS 4096 33 34 #define MAX_CP_PORTS 8192 34 #define MAX_ CP_REGS 819235 #define MAX_PERIPHS 8192 35 36 36 37 #define XML_PARSER_DEBUG 0 … … 49 50 mapping_proc_t* proc[MAX_PROCS]; // proc array 50 51 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]; 52 mapping_coproc_t* coproc[MAX_COPROCS]; // coproc array 53 mapping_cp_port_t* cp_port[MAX_CP_PORTS]; // coproc port array 54 mapping_periph_t* periph[MAX_PERIPHS]; // peripheral array 55 56 // Index for the various arrays 66 57 67 58 unsigned int cluster_index = 0; … … 82 73 unsigned int cp_port_loc_index = 0; 83 74 84 unsigned int cp_reg_index = 0;85 unsigned int cp_reg_loc_index = 0;75 unsigned int periph_index = 0; 76 unsigned int periph_loc_index = 0; 86 77 87 78 unsigned int vseg_index = 0; 88 79 unsigned int vseg_loc_index = 0; 80 89 81 unsigned int task_index = 0; 90 82 unsigned int task_loc_index = 0; 83 91 84 unsigned int vobj_index = 0; 92 85 unsigned int vobj_loc_index = 0; 93 86 unsigned int vobj_count = 0; 94 87 95 unsigned int tty_index = 1; 96 unsigned int fb_index = 0; 97 88 /////////////////////////////////////////////////////////////////////// 89 // This arrray is useful to build a temporary list of vobj references. 90 // The struct vobj_ref_s is formed by a vspace_name and a vobj_name. 91 // This array is used to set the attribute vobj_id of a cp_port 92 // once all the vspace have been parsed. 93 94 typedef struct vobj_ref_s 95 { 96 char vspace_name[32]; 97 char vobj_name[32]; 98 }vobj_ref_t; 99 100 vobj_ref_t* cp_port_vobj_ref[MAX_CP_PORTS]; 101 102 98 103 ////////////////////////////////////////////////// 99 104 unsigned int getIntValue( xmlTextReaderPtr reader, … … 183 188 //////////////////////////////////////////// 184 189 int getVspaceId( char* vspace_name) 185 ////////////////////////////////////////////186 190 { 187 191 unsigned int vspace_id; … … 201 205 char* vobj_name, 202 206 unsigned int vspace_max) 203 ////////////////////////////////////////////204 207 { 205 208 unsigned int vobj_id; … … 235 238 #endif 236 239 237 cp_port[cp_port_index] = (mapping_c oproc_port_t*)malloc(sizeof(mapping_coproc_port_t));240 cp_port[cp_port_index] = (mapping_cp_port_t*)malloc(sizeof(mapping_cp_port_t)); 238 241 cp_port_vobj_ref[cp_port_index] = (vobj_ref_t*)malloc(sizeof(vobj_ref_t)); 239 242 … … 251 254 else 252 255 { 253 printf("[XML ERROR] illegal <direction> for c oproc_port %d in cluster %d\n",256 printf("[XML ERROR] illegal <direction> for cp_port %d in cluster %d\n", 254 257 cp_port_index, cluster_index); 255 258 exit(1); … … 258 261 else 259 262 { 260 printf("[XML ERROR] missing <direction> for c oproc_port %d in cluster %d\n",263 printf("[XML ERROR] missing <direction> for cp_port %d in cluster %d\n", 261 264 cp_port_index, cluster_index); 262 265 exit(1); … … 274 277 else 275 278 { 276 printf("[XML ERROR] missing <vspacename> for c oproc_port %d in cluster %d\n",279 printf("[XML ERROR] missing <vspacename> for cp_port %d in cluster %d\n", 277 280 cp_port_index, cluster_index); 278 281 exit(1); … … 290 293 else 291 294 { 292 printf("[XML ERROR] missing <vobjname> for c oproc_port %d in cluster %d\n",295 printf("[XML ERROR] missing <vobjname> for cp_port %d in cluster %d\n", 293 296 cp_port_index, cluster_index); 294 297 exit(1); … … 300 303 } // end cpPortNode() 301 304 302 ///////////////////////////////////////// 303 void cpRegNode ( xmlTextReaderPtr reader )304 ///////////////////////////////////////// 305 /////////////////////////////////////////// 306 void periphNode ( xmlTextReaderPtr reader ) 307 /////////////////////////////////////////// 305 308 { 306 309 char* str; 307 310 unsigned int value; 308 unsigned int 311 unsigned int ok; 309 312 310 313 if ( xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT ) return; 311 314 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 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_DEBUG 321 printf("\n periph %d\n", periph_index); 322 #endif 323 324 periph[periph_index] = (mapping_periph_t*)malloc(sizeof(mapping_periph_t)); 325 326 /////////// get type attribute 327 str = getStringValue( reader, "type", &ok ); 332 328 if ( ok ) 333 329 { 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 } 330 #if XML_PARSER_DEBUG 331 printf(" type = %s\n", str); 332 #endif 333 unsigned int error = 0; 334 335 // The TTY, IOC, NIC, FBF and IOB peripherals cannot be replicated 336 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 clusters 361 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 else 374 { 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 else 381 { 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_DEBUG 392 printf(" channels = %d\n", value); 393 #endif 394 periph[periph_index]->channels = value; 395 } 396 else 397 { 398 periph[periph_index]->channels = 1; 399 } 400 401 /////////// get psegname attribute 402 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 attribute 411 int index = getPsegId( cluster_index, str ); 412 if ( index >= 0 ) 413 { 414 #if XML_PARSER_DEBUG 415 printf(" clusterid = %d\n", cluster_index); 416 printf(" psegname = %s\n", str); 417 printf(" psegid = %d\n", index); 418 #endif 419 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 else 424 { 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 } 342 429 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() 430 periph_index++; 431 periph_loc_index++; 432 433 } // end periphNode 418 434 419 435 ///////////////////////////////////////// … … 425 441 426 442 cp_port_loc_index = 0; 427 cp_reg_loc_index = 0;428 443 429 444 if ( xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT ) return; … … 439 454 440 455 coproc[coproc_index] = (mapping_coproc_t*)malloc(sizeof(mapping_coproc_t)); 441 442 456 443 457 /////////// get name attribute … … 485 499 } 486 500 487 ////////// set port_offset and reg_offset attribute501 ////////// set port_offset 488 502 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); 503 504 #if XML_PARSER_DEBUG 505 printf(" port_offset = %d\n", cp_port_index); 494 506 #endif 495 507 … … 499 511 const char* tag = (const char*)xmlTextReaderConstName(reader); 500 512 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,"#comment") == 0 ); 505 else if ( strcmp(tag,"coproc") == 0 ) 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 ) 506 517 { 507 518 coproc[coproc_index]->ports = cp_port_loc_index; 508 coproc[coproc_index]->regs = cp_reg_loc_index;509 519 coproc_loc_index++; 510 520 coproc_index++; … … 548 558 printf(" type = %s\n", str); 549 559 #endif 550 if ( strcmp(str, "HARD") ) irq[irq_index]->type = IRQ_TYPE_HARD;551 else if ( strcmp(str, "SOFT") ) irq[irq_index]->type = IRQ_TYPE_SOFT;560 if ( strcmp(str, "HARD") == 0 ) irq[irq_index]->type = 0; 561 else if ( strcmp(str, "SOFT") == 0 ) irq[irq_index]->type = 1; 552 562 else 553 563 { … … 564 574 } 565 575 566 ///////// get i rqid attribute576 ///////// get icuid attribute 567 577 value = getIntValue(reader, "icuid", &ok); 568 578 if ( ok ) … … 593 603 printf(" isr = %s\n", str); 594 604 #endif 595 if ( strcmp(str, "ISR_SWITCH") ) irq[irq_index]->isr = ISR_SWITCH; 596 else if ( strcmp(str, "ISR_IOC") ) irq[irq_index]->isr = ISR_IOC; 597 else if ( strcmp(str, "ISR_FBDMA") ) irq[irq_index]->isr = ISR_FBDMA; 598 else if ( strcmp(str, "ISR_TTY") ) irq[irq_index]->isr = ISR_TTY; 605 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; 599 610 else 600 611 { … … 603 614 exit(1); 604 615 } 616 #if XML_PARSER_DEBUG 617 printf(" isrnum = %d\n", irq[irq_index]->isr); 618 #endif 605 619 } 606 620 else … … 664 678 ////////// set irq_offset attribute 665 679 proc[proc_index]->irq_offset = irq_index; 680 666 681 #if XML_PARSER_DEBUG 667 682 printf(" irq_offset = %d\n", irq_index); … … 673 688 const char* tag = (const char*)xmlTextReaderConstName(reader); 674 689 675 if ( strcmp(tag, "irq")== 0 ) irqNode(reader);676 else if ( strcmp(tag, "#text")== 0 ) { }677 else if ( strcmp(tag, "#comment") == 0 );678 else if ( strcmp(tag, "proc")== 0 )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 ) 679 694 { 680 695 proc[proc_index]->irqs = irq_loc_index; … … 817 832 } 818 833 819 /////////// get use _tty attribute (optionnal : 0 if missing)834 /////////// get usetty attribute (optionnal : 0 if missing) 820 835 value = getIntValue(reader,"usetty", &ok); 821 836 if ( ok ) … … 824 839 printf(" usetty = %x\n", value); 825 840 #endif 826 if ( (value != 0) && (tty_index >= header->ttys) )827 {828 printf("[XML ERROR] The tty index is too large for task (%d,%d)\n",829 vspace_index, task_loc_index);830 exit(1);831 }832 841 task[task_index]->use_tty = value; 833 if (value != 0) tty_index++;834 842 } 835 843 else … … 838 846 } 839 847 840 /////////// get use_fb attribute (optionnal : 0 if missing) 841 value = getIntValue(reader,"usefb", &ok); 842 if ( ok ) 843 { 844 #if XML_PARSER_DEBUG 845 printf(" usefb = %x\n", value); 846 #endif 847 if ( (value != 0) && (fb_index >= header->fbs) ) 848 { 849 printf("[XML ERROR] The fb channel index is too large for task (%d,%d)\n", 850 vspace_index, task_loc_index); 851 exit(1); 852 } 853 task[task_index]->use_fb = value; 854 if (value != 0) fb_index++; 848 /////////// get usenic attribute (optionnal : 0 if missing) 849 value = getIntValue(reader,"usenic", &ok); 850 if ( ok ) 851 { 852 #if XML_PARSER_DEBUG 853 printf(" usenic = %x\n", value); 854 #endif 855 task[task_index]->use_nic = value; 855 856 } 856 857 else 857 858 { 858 task[task_index]->use_fb = 0; 859 task[task_index]->use_nic = 0; 860 } 861 862 /////////// get usetimer attribute (optionnal : 0 if missing) 863 value = getIntValue(reader,"usetimer", &ok); 864 if ( ok ) 865 { 866 #if XML_PARSER_DEBUG 867 printf(" usetimer = %x\n", value); 868 #endif 869 task[task_index]->use_timer = value; 870 } 871 else 872 { 873 task[task_index]->use_timer = 0; 874 } 875 876 /////////// get usefbdma attribute (optionnal : 0 if missing) 877 value = getIntValue(reader,"usefbdma", &ok); 878 if ( ok ) 879 { 880 #if XML_PARSER_DEBUG 881 printf(" usefbdma = %x\n", value); 882 #endif 883 task[task_index]->use_fbdma = value; 884 } 885 else 886 { 887 task[task_index]->use_fbdma = 0; 859 888 } 860 889 … … 865 894 ////////////////////////////////////////// 866 895 void vobjNode ( xmlTextReaderPtr reader ) 896 ////////////////////////////////////////// 867 897 { 868 898 unsigned int ok; … … 986 1016 else 987 1017 { 988 if((vobj[vobj_index]->type == VOBJ_TYPE_MWMR || vobj[vobj_index]->type == VOBJ_TYPE_BARRIER )) 1018 if( (vobj[vobj_index]->type == VOBJ_TYPE_MWMR) || 1019 (vobj[vobj_index]->type == VOBJ_TYPE_BARRIER) ) 989 1020 { 990 1021 printf("[XML ERROR] illegal or missing <value> attribute for vobj (%d,%d). \ … … 1003 1034 ////////////////////////////////////////// 1004 1035 void vsegNode ( xmlTextReaderPtr reader ) 1036 ////////////////////////////////////////// 1005 1037 { 1006 1038 unsigned int ok; … … 1144 1176 const char* tag = (const char*)xmlTextReaderConstName(reader); 1145 1177 1146 if ( strcmp(tag,"vobj") == 0 ) vobjNode(reader); 1147 else if ( strcmp(tag,"#text" ) == 0 ) { } 1148 else if ( strcmp(tag,"vseg") == 0 ) 1178 if ( strcmp(tag, "vobj") == 0 ) vobjNode(reader); 1179 else if ( strcmp(tag, "#text" ) == 0 ) { } 1180 else if ( strcmp(tag, "#comment") == 0 ) { } 1181 else if ( strcmp(tag, "vseg") == 0 ) 1149 1182 { 1150 1183 vseg[vseg_index]->vobjs = vobj_count; … … 1164 1197 ////////////////////////////////////////// 1165 1198 void vspaceNode( xmlTextReaderPtr reader ) 1199 ////////////////////////////////////////// 1166 1200 { 1167 1201 char* str; … … 1233 1267 const char* tag = (const char*)xmlTextReaderConstName(reader); 1234 1268 1235 if ( strcmp(tag, "vseg")== 0 ) vsegNode(reader);1236 else if ( strcmp(tag, "task")== 0 ) taskNode(reader);1237 else if ( strcmp(tag, "#text")== 0 ) { }1238 else if ( strcmp(tag, "#comment") == 0 );1239 else if ( strcmp(tag, "vspace")== 0 )1269 if ( strcmp(tag, "vseg") == 0 ) vsegNode(reader); 1270 else if ( strcmp(tag, "task") == 0 ) taskNode(reader); 1271 else if ( strcmp(tag, "#text") == 0 ) { } 1272 else if ( strcmp(tag, "#comment") == 0 ) { } 1273 else if ( strcmp(tag, "vspace") == 0 ) 1240 1274 { 1241 1275 vspace[vspace_index]->vobjs = vobj_loc_index; … … 1288 1322 ////////////////////////////////////////// 1289 1323 void psegNode ( xmlTextReaderPtr reader ) 1324 ////////////////////////////////////////// 1290 1325 { 1291 1326 unsigned int ok; … … 1379 1414 ///////////////////////////////////////////// 1380 1415 void clusterNode ( xmlTextReaderPtr reader ) 1416 ///////////////////////////////////////////// 1381 1417 { 1382 1418 unsigned int ok; … … 1385 1421 proc_loc_index = 0; 1386 1422 coproc_loc_index = 0; 1387 cluster[cluster_index]= 0;1423 periph_loc_index = 0; 1388 1424 1389 1425 if ( xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT ) return; … … 1402 1438 cluster[cluster_index] = (mapping_cluster_t*)malloc(sizeof(mapping_cluster_t)); 1403 1439 1404 /////////// getindex attribute (optional)1440 /////////// check cluster index attribute (optional) 1405 1441 value = getIntValue(reader,"index",&ok); 1406 1442 if ( ok && (value != cluster_index) ) … … 1411 1447 } 1412 1448 1413 1414 ////////// set pseg_offset attribute 1415 cluster[cluster_index]->pseg_offset = pseg_index; 1416 cluster[cluster_index]->proc_offset = proc_index; 1449 ////////// set offsets 1450 cluster[cluster_index]->pseg_offset = pseg_index; 1451 cluster[cluster_index]->proc_offset = proc_index; 1417 1452 cluster[cluster_index]->coproc_offset = coproc_index; 1418 #if XML_PARSER_DEBUG 1419 printf(" pseg_offset = %d\n", pseg_index); 1420 printf(" proc_offset = %d\n", proc_index); 1453 cluster[cluster_index]->periph_offset = periph_index; 1454 1455 #if XML_PARSER_DEBUG 1456 printf(" pseg_offset = %d\n", pseg_index); 1457 printf(" proc_offset = %d\n", proc_index); 1421 1458 printf(" coproc_offset = %d\n", coproc_index); 1422 #endif 1423 1424 ////////// get psegs, coproc and/or procs 1459 printf(" periph_offset = %d\n", coproc_index); 1460 #endif 1461 1462 ////////// get psegs, procs, coprocs and periphs 1425 1463 int status = xmlTextReaderRead(reader); 1426 1464 … … 1429 1467 const char* tag = (const char*)xmlTextReaderConstName(reader); 1430 1468 1431 if ( strcmp(tag, "pseg") == 0 ) psegNode(reader); 1432 else if ( strcmp(tag, "proc") == 0 ) procNode(reader); 1433 else if ( strcmp(tag, "coproc") == 0 ) coprocNode(reader); 1434 else if ( strcmp(tag, "#text") == 0 ) { } 1435 else if ( strcmp(tag,"#comment") == 0 ); 1436 else if ( strcmp(tag, "cluster") == 0 ) 1437 { 1438 #if XML_PARSER_DEBUG 1469 if ( strcmp(tag, "pseg") == 0 ) psegNode(reader); 1470 else if ( strcmp(tag, "proc") == 0 ) procNode(reader); 1471 else if ( strcmp(tag, "coproc") == 0 ) coprocNode(reader); 1472 else if ( strcmp(tag, "periph") == 0 ) periphNode(reader); 1473 else if ( strcmp(tag, "#text") == 0 ) { } 1474 else if ( strcmp(tag, "#comment") == 0 ) { } 1475 else if ( strcmp(tag, "cluster") == 0 ) 1476 { 1477 cluster[cluster_index]->procs = proc_loc_index; 1478 cluster[cluster_index]->coprocs = coproc_loc_index; 1479 cluster[cluster_index]->periphs = periph_loc_index; 1480 1481 // cluster[cluster_index]psegs update is done in psegNode(), 1482 // because the coprocNode() call to getPsegId() need it 1483 1484 #if XML_PARSER_DEBUG 1485 printf(" psegs = %d\n", cluster[cluster_index]->psegs); 1486 printf(" procs = %d\n", cluster[cluster_index]->procs); 1487 printf(" coprocs = %d\n", cluster[cluster_index]->coprocs); 1488 printf(" periphs = %d\n", cluster[cluster_index]->periphs); 1439 1489 printf(" end cluster %d\n", cluster_index); 1440 1490 #endif 1441 cluster[cluster_index]->procs = proc_loc_index;1442 cluster[cluster_index]->coprocs = coproc_loc_index;1443 //psegs = pseg_loc_index is done in psegNode(), so coprocNode() call to getPsegId() success1444 1491 cluster_index++; 1445 1492 return; … … 1451 1498 ////////////////////////////////////////////// 1452 1499 void clusterSetNode( xmlTextReaderPtr reader ) 1500 ////////////////////////////////////////////// 1453 1501 { 1454 1502 if ( xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT ) return; … … 1463 1511 const char* tag = (const char*)xmlTextReaderConstName(reader); 1464 1512 1465 if ( strcmp(tag, "cluster")== 0 ) clusterNode(reader);1466 else if ( strcmp(tag, "#text")== 0 ) { }1467 else if ( strcmp(tag, "#comment") == 0 );1468 else if ( strcmp(tag, "clusterset") == 0 )1513 if ( strcmp(tag, "cluster") == 0 ) clusterNode(reader); 1514 else if ( strcmp(tag, "#text") == 0 ) { } 1515 else if ( strcmp(tag, "#comment") == 0 ) { } 1516 else if ( strcmp(tag, "clusterset") == 0 ) 1469 1517 { 1470 1518 // checking source file consistency … … 1479 1527 printf(" end cluster set\n\n"); 1480 1528 #endif 1481 header->psegs = pseg_index;1482 header->procs = proc_index;1483 header->irqs = irq_index;1484 header->coprocs = coproc_index;1529 header->psegs = pseg_index; 1530 header->procs = proc_index; 1531 header->irqs = irq_index; 1532 header->coprocs = coproc_index; 1485 1533 header->cp_ports = cp_port_index; 1486 header->cp_regs = cp_reg_index;1487 1534 return; 1488 1535 } … … 1499 1546 ///////////////////////////////////////////// 1500 1547 void globalSetNode( xmlTextReaderPtr reader ) 1548 ///////////////////////////////////////////// 1501 1549 { 1502 1550 if ( xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT ) return; … … 1511 1559 const char* tag = (const char*)xmlTextReaderConstName(reader); 1512 1560 1513 if ( strcmp(tag, "vseg") == 0) vsegNode(reader);1514 else if ( strcmp(tag, "#text" )== 0 ) { }1515 else if ( strcmp(tag, "#comment") == 0 );1516 else if ( strcmp(tag, "globalset") == 0)1561 if ( strcmp(tag, "vseg") == 0 ) vsegNode(reader); 1562 else if ( strcmp(tag, "#text" ) == 0 ) { } 1563 else if ( strcmp(tag, "#comment") == 0 ) { } 1564 else if ( strcmp(tag, "globalset") == 0 ) 1517 1565 { 1518 1566 // checking source file consistency … … 1542 1590 ///////////////////////////////////////////// 1543 1591 void vspaceSetNode( xmlTextReaderPtr reader ) 1592 ///////////////////////////////////////////// 1544 1593 { 1545 1594 if ( xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT ) return; … … 1554 1603 const char* tag = (const char*)xmlTextReaderConstName(reader); 1555 1604 1556 if ( strcmp(tag, "vspace") == 0) vspaceNode(reader);1557 else if ( strcmp(tag, "#text") == 0 ) { }1558 else if ( strcmp(tag, "#comment") == 0 );1559 else if ( strcmp(tag, "vspaceset") == 0)1605 if ( strcmp(tag, "vspace" ) == 0 ) vspaceNode(reader); 1606 else if ( strcmp(tag, "#text" ) == 0 ) { } 1607 else if ( strcmp(tag, "#comment" ) == 0 ) { } 1608 else if ( strcmp(tag, "vspaceset") == 0 ) 1560 1609 { 1561 1610 // checking source file consistency … … 1584 1633 ////////////////////////////////////////// 1585 1634 void headerNode(xmlTextReaderPtr reader ) 1635 ////////////////////////////////////////// 1586 1636 { 1587 1637 char* name; … … 1632 1682 } 1633 1683 1634 ///////// get ttys attribute1635 value = getIntValue(reader, "ttys", &ok);1636 if ( ok )1637 {1638 #if XML_PARSER_DEBUG1639 printf(" ttys = %d\n", value);1640 #endif1641 header->ttys = value;1642 }1643 else1644 {1645 printf("[XML ERROR] illegal or missing <ttys> attribute in header\n");1646 exit(1);1647 }1648 1649 ///////// get fbs attribute1650 value = getIntValue(reader, "fbs", &ok);1651 if ( ok )1652 {1653 #if XML_PARSER_DEBUG1654 printf(" fbs = %d\n", value);1655 #endif1656 header->fbs = value;1657 }1658 else1659 {1660 printf("[XML ERROR] illegal or missing <fbs> attribute in header\n");1661 exit(1);1662 }1663 1664 1684 ///////// get vspaces attribute 1665 1685 value = getIntValue(reader, "vspaces", &ok); … … 1702 1722 } 1703 1723 1724 //////// initialise non replicated peripherals cluster_id 1725 header->tty_clusterid = 0xFFFFFFFF; 1726 header->nic_clusterid = 0xFFFFFFFF; 1727 header->ioc_clusterid = 0xFFFFFFFF; 1728 header->fbf_clusterid = 0xFFFFFFFF; 1729 1730 ///////// set signature 1704 1731 header->signature = IN_MAPPING_SIGNATURE; 1705 1732 … … 1709 1736 const char* tag = (const char*)xmlTextReaderConstName(reader); 1710 1737 1711 if ( strcmp(tag, "clusterset") == 0 ) clusterSetNode(reader);1712 else if ( strcmp(tag, "globalset") == 0 ) globalSetNode(reader);1713 else if ( strcmp(tag, "vspaceset") == 0 ) vspaceSetNode(reader);1714 else if ( strcmp(tag, "#text") == 0 ) ;1715 else if ( strcmp(tag, "#comment") == 0 ) ;1716 else if ( strcmp(tag, "mapping_info") == 0 )1738 if ( strcmp(tag, "clusterset") == 0 ) clusterSetNode(reader); 1739 else if ( strcmp(tag, "globalset") == 0 ) globalSetNode(reader); 1740 else if ( strcmp(tag, "vspaceset") == 0 ) vspaceSetNode(reader); 1741 else if ( strcmp(tag, "#text") == 0 ) { } 1742 else if ( strcmp(tag, "#comment") == 0 ) { } 1743 else if ( strcmp(tag, "mapping_info") == 0 ) 1717 1744 { 1718 1745 #if XML_PARSER_DEBUG … … 1730 1757 } // end headerNode() 1731 1758 1759 /////////////////////////////////////// 1732 1760 void BuildTable( int fdout, 1733 1761 const char* type, … … 1735 1763 unsigned int elem_size, 1736 1764 char** table) 1765 //////////////////////////////////////// 1737 1766 { 1738 1767 unsigned int i; … … 1758 1787 /////////////////////////// 1759 1788 void buildBin( int fdout ) 1789 /////////////////////////// 1760 1790 { 1761 1791 unsigned int vspace_id; … … 1823 1853 } 1824 1854 1825 // write tasks 1855 // write tasks array 1826 1856 BuildTable(fdout, "task", task_index, sizeof(mapping_task_t), (char**) task); 1827 //building proc 1857 //building procs array 1828 1858 BuildTable(fdout, "proc", proc_index, sizeof(mapping_proc_t), (char**) proc); 1829 //building irq 1859 //building irqs array 1830 1860 BuildTable(fdout, "irq", irq_index, sizeof(mapping_irq_t), (char**)irq); 1831 //building coproc 1861 //building coprocs array 1832 1862 BuildTable(fdout, "coproc", coproc_index, sizeof(mapping_coproc_t), (char**)coproc); 1833 //building cp_port 1834 BuildTable(fdout, "cp_port", cp_port_index, sizeof(mapping_c oproc_port_t),(char**) cp_port);1835 //building cp_reg1836 BuildTable(fdout, " cp_reg", cp_reg_index, sizeof(mapping_coproc_reg_t), (char**)cp_reg);1863 //building cp_ports array 1864 BuildTable(fdout, "cp_port", cp_port_index, sizeof(mapping_cp_port_t),(char**) cp_port); 1865 //building periphs array 1866 BuildTable(fdout, "periph", periph_index, sizeof(mapping_periph_t), (char**)periph); 1837 1867 1838 1868 } // end buildBin() 1839 1869 1840 ///////////////////////////////////////// 1841 // this function set the value of vobj_id 1842 // of the coproc_ports. 1843 /////////////////// 1870 /////////////////////////////////////////////////////////////////////// 1871 // this function set the value the vobj_id fiels of all cp_ports 1872 /////////////////////////////////////////////////////////////////////// 1844 1873 void prepareBuild() 1845 1874 { … … 1850 1879 if ( vspace_id < 0 ) 1851 1880 { 1852 printf("[XML ERROR] illegal <vspacename> for c oproc_port %d,\n",1881 printf("[XML ERROR] illegal <vspacename> for cp_port %d,\n", 1853 1882 i); 1854 1883 exit(1); … … 1856 1885 cp_port[i]->vspaceid = vspace_id; 1857 1886 1858 int vobj_id = getVobjLocId( vspace_id, cp_port_vobj_ref[i]->vobj_name, vspace[vspace_id]->vobjs ); 1887 int vobj_id = getVobjLocId( vspace_id, 1888 cp_port_vobj_ref[i]->vobj_name, 1889 vspace[vspace_id]->vobjs ); 1859 1890 if ( vobj_id >= 0 ) 1860 1891 { 1861 #if XML_PARSER_DEBUG 1862 printf("coproc_port = %d\n", i); 1892 1893 #if XML_PARSER_DEBUG 1894 printf("\ncp_port = %d\n", i); 1863 1895 printf(" vspace_name = %s\n", cp_port_vobj_ref[i]->vspace_name); 1864 1896 printf(" vobj_name = %s\n", cp_port_vobj_ref[i]->vobj_name); … … 1866 1898 #endif 1867 1899 cp_port[i]->vobjlocid = vobj_id; 1868 assert((vobj[ vspace[vspace_id]->vobj_offset + vobj_id]->type == VOBJ_TYPE_MWMR) && "coproc ports has to refere to a vobj of type MWMR"); 1900 1901 assert((vobj[ vspace[vspace_id]->vobj_offset + vobj_id]->type == VOBJ_TYPE_MWMR) 1902 && "coproc ports has to refere to a vobj of type MWMR"); 1869 1903 } 1870 1904 else 1871 1905 { 1872 printf("[XML ERROR] illegal <vobjname> for c oproc_port %d,\n",1906 printf("[XML ERROR] illegal <vobjname> for cp_port %d,\n", 1873 1907 i); 1874 1908 exit(1); 1875 1909 } 1876 1877 1910 } 1878 1911 } … … 1880 1913 ///////////////////////////////////// 1881 1914 int main ( int argc, char* argv[] ) 1915 ///////////////////////////////////// 1882 1916 { 1883 1917 if ( argc < 3 ) … … 1913 1947 } 1914 1948 else 1915 if ( strcmp(tag,"#comment") == 0 );// a way to skips comment1916 else1917 1949 { 1918 1950 printf("[XML ERROR] Wrong file type: \"%s\"\n", argv[1]);
Note: See TracChangeset
for help on using the changeset viewer.