Changeset 306 for soft/giet_vm/giet_xml/xml_driver.c
- Timestamp:
- Apr 21, 2014, 5:14:17 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/giet_xml/xml_driver.c
r295 r306 254 254 fprintf(fpout, " y_width = \"%d\" \n" , header->y_width); 255 255 fprintf(fpout, " irq_per_proc = \"%d\" \n" , header->irq_per_proc); 256 fprintf(fpout, " use_ram disk = \"%d\" \n" , header->use_ramdisk);256 fprintf(fpout, " use_ram_disk = \"%d\" \n" , header->use_ram_disk); 257 257 fprintf(fpout, " x_io = \"%d\" \n" , header->x_io); 258 258 fprintf(fpout, " y_io = \"%d\" >\n\n", header->y_io); … … 263 263 for (cluster_id = 0; cluster_id < (header->x_size * header->y_size); cluster_id++) 264 264 { 265 fprintf(fpout, " <cluster x = \"%d\" y =\"%d\" >\n",265 fprintf(fpout, " <cluster x=\"%d\" y=\"%d\" >\n", 266 266 cluster[cluster_id].x, cluster[cluster_id].y ); 267 267 … … 272 272 pseg_id++) 273 273 { 274 fprintf(fpout, " <pseg name = \"%s\"", pseg[pseg_id].name);275 fprintf(fpout, " type = \"%s\"", pseg_type[pseg[pseg_id].type]);276 fprintf(fpout, " base = \"0x%llx\"", pseg[pseg_id].base);277 fprintf(fpout, " length = \"0x%llx\" />\n",pseg[pseg_id].length);274 fprintf(fpout, " <pseg name=\"%s\"", pseg[pseg_id].name); 275 fprintf(fpout, " type=\"%s\"", pseg_type[pseg[pseg_id].type]); 276 fprintf(fpout, " base=\"0x%llx\"", pseg[pseg_id].base); 277 fprintf(fpout, " length=\"0x%llx\" />\n", pseg[pseg_id].length); 278 278 } 279 279 … … 285 285 proc_id++, proc_index++) 286 286 { 287 fprintf(fpout, " <proc index =\"%d\" />\n", proc_index);287 fprintf(fpout, " <proc index=\"%d\" />\n", proc_index); 288 288 } 289 289 … … 294 294 coproc_id++) 295 295 { 296 fprintf(fpout, " <coproc name = \"%s\"", coproc[coproc_id].name);297 fprintf(fpout, " psegname =\"%s\" >\n", pseg[coproc[coproc_id].psegid].name);296 fprintf(fpout, " <coproc name=\"%s\"", coproc[coproc_id].name); 297 fprintf(fpout, " psegname=\"%s\" >\n", pseg[coproc[coproc_id].psegid].name); 298 298 for (port_id = coproc[coproc_id].port_offset; 299 299 port_id < coproc[coproc_id].port_offset + coproc[coproc_id].ports; … … 301 301 { 302 302 unsigned int vobj_id = cp_port[port_id].mwmr_vobjid + vspace[cp_port[port_id].vspaceid].vobj_offset; 303 fprintf(fpout, " <port direction = \"%s\"", port_direction[cp_port[port_id].direction]);304 fprintf(fpout, " vspacename = \"%s\"", vspace[cp_port[port_id].vspaceid].name);305 fprintf(fpout, " vobjname =\"%s\" />\n", vobj[vobj_id].name);303 fprintf(fpout, " <port direction=\"%s\"", port_direction[cp_port[port_id].direction]); 304 fprintf(fpout, " vspacename=\"%s\"", vspace[cp_port[port_id].vspaceid].name); 305 fprintf(fpout, " vobjname=\"%s\" />\n", vobj[vobj_id].name); 306 306 } 307 307 fprintf(fpout, " </coproc>\n" ); … … 314 314 periph_id++) 315 315 { 316 fprintf(fpout, " <periph type = \"%s\" ", periph_type[periph[periph_id].type]); 317 318 if (periph[periph_id].subtype < PERIPH_SUBTYPE_MAX_VALUE) 319 fprintf(fpout, " subtype = \"%s\" ", ioc_subtype[periph[periph_id].subtype]); 320 321 fprintf(fpout, " psegname = \"%s\" ", pseg[periph[periph_id].psegid].name); 322 fprintf(fpout, " channels = \"%d\" >\n", periph[periph_id].channels); 323 for (irq_id = periph[periph_id].irq_offset; 324 irq_id < periph[periph_id].irq_offset + periph[periph_id].irqs; 325 irq_id++) 316 fprintf(fpout, " <periph type=\"%s\"", periph_type[periph[periph_id].type]); 317 318 if (periph[periph_id].type == PERIPH_TYPE_IOC) 319 fprintf(fpout, " subtype=\"%s\"", ioc_subtype[periph[periph_id].subtype]); 320 321 fprintf(fpout, " psegname=\"%s\"", pseg[periph[periph_id].psegid].name); 322 fprintf(fpout, " channels=\"%d\" >\n", periph[periph_id].channels); 323 if ( periph[periph_id].type == PERIPH_TYPE_PIC ) 326 324 { 327 fprintf(fpout, " <irq srctype = \"%s\" ", irq_type[irq[irq_id].srctype]); 328 fprintf(fpout, " srcid = \"%d\" ", irq[irq_id].srcid); 329 fprintf(fpout, " isr = \"%s\" ", isr_type[irq[irq_id].isr]); 330 fprintf(fpout, " channel = \"%d\" ", irq[irq_id].channel); 331 fprintf(fpout, " dstx = \"%d\" ", irq[irq_id].dstx); 332 fprintf(fpout, " dsty = \"%d\" ", irq[irq_id].dsty); 333 fprintf(fpout, " dstid = \"%d\" />\n", irq[irq_id].dstid); 325 for (irq_id = periph[periph_id].irq_offset; 326 irq_id < periph[periph_id].irq_offset + periph[periph_id].irqs; 327 irq_id++) 328 { 329 fprintf(fpout, " <irq srcid=\"%d\" ", irq[irq_id].srcid); 330 fprintf(fpout, " dstx=\"%d\"", irq[irq_id].dstx); 331 fprintf(fpout, " dsty=\"%d\"", irq[irq_id].dsty); 332 fprintf(fpout, " dstid=\"%d\" />\n", irq[irq_id].dstid); 333 } 334 } 335 if ( (periph[periph_id].type == PERIPH_TYPE_XCU ) || 336 (periph[periph_id].type == PERIPH_TYPE_ICU ) ) 337 { 338 for (irq_id = periph[periph_id].irq_offset; 339 irq_id < periph[periph_id].irq_offset + periph[periph_id].irqs; 340 irq_id++) 341 { 342 fprintf(fpout, " <irq srctype=\"%s\"", irq_type[irq[irq_id].srctype]); 343 fprintf(fpout, " srcid=\"%d\"", irq[irq_id].srcid); 344 fprintf(fpout, " isr=\"%s\"", isr_type[irq[irq_id].isr]); 345 fprintf(fpout, " channel=\"%d\"", irq[irq_id].channel); 346 fprintf(fpout, " dstid=\"%d\" />\n", irq[irq_id].dstid); 347 } 334 348 } 335 349 fprintf(fpout, " </periph>\n"); … … 344 358 for (vseg_id = 0; vseg_id < header->globals; vseg_id++) 345 359 { 346 unsigned int pseg_id = vseg[vseg_id].psegid; 347 348 fprintf(fpout, " <vseg name = \"%s\" ", vseg[vseg_id].name); 349 fprintf(fpout, "vbase = \"0x%x\" ", vseg[vseg_id].vbase); 350 fprintf(fpout, "mode = \"%s\" ", mode_str[vseg[vseg_id].mode]); 351 fprintf(fpout, "clusterid = \"%d\" ", pseg[pseg_id].clusterid); 352 fprintf(fpout, "psegname = \"%s\" ", pseg[pseg_id].name); 353 fprintf(fpout, "ident = \"%d\" >\n", vseg[vseg_id].ident); 360 unsigned int pseg_id = vseg[vseg_id].psegid; 361 unsigned int cluster_id = pseg[pseg_id].clusterid; 362 363 fprintf(fpout, " <vseg name=\"%s\"", vseg[vseg_id].name); 364 fprintf(fpout, " vbase=\"0x%x\"", vseg[vseg_id].vbase); 365 fprintf(fpout, " mode=\"%s\"", mode_str[vseg[vseg_id].mode]); 366 fprintf(fpout, " x=\"%d\"", cluster[cluster_id].x); 367 fprintf(fpout, " y=\"%d\"", cluster[cluster_id].y); 368 fprintf(fpout, " psegname=\"%s\"", pseg[pseg_id].name); 369 if( vseg[vseg_id].ident ) fprintf(fpout, " ident=\"1\""); 370 fprintf(fpout, " >\n"); 371 354 372 for (vobj_id = vseg[vseg_id].vobj_offset; 355 373 vobj_id < (vseg[vseg_id].vobj_offset + vseg[vseg_id].vobjs); 356 374 vobj_id++) 357 375 { 358 fprintf(fpout, " <vobj name = \"%s\" ", vobj[vobj_id].name); 359 fprintf(fpout, "type = \"%s\" ", vobj_type[vobj[vobj_id].type]); 360 fprintf(fpout, "length = \"0x%x\" ", vobj[vobj_id].length); 361 fprintf(fpout, "align = \"%d\" ", vobj[vobj_id].align); 362 fprintf(fpout, "init = \"%d\" ", vobj[vobj_id].init); 363 fprintf(fpout, "binpath = \"%s\" />\n", vobj[vobj_id].binpath); 376 fprintf(fpout, " <vobj name=\"%s\"", vobj[vobj_id].name); 377 fprintf(fpout, " type=\"%s\"", vobj_type[vobj[vobj_id].type]); 378 fprintf(fpout, " length=\"0x%x\"", vobj[vobj_id].length); 379 if( vobj[vobj_id].align ) 380 fprintf(fpout, " align=\"%d\"", vobj[vobj_id].align); 381 if( vobj[vobj_id].binpath[0] != 0 ) 382 fprintf(fpout, " binpath=\"%s\"", vobj[vobj_id].binpath); 383 if( (vobj[vobj_id].type == VOBJ_TYPE_BARRIER) || 384 (vobj[vobj_id].type == VOBJ_TYPE_MWMR ) || 385 (vobj[vobj_id].type == VOBJ_TYPE_CONST ) ) 386 fprintf(fpout, " init=\"%d\"", vobj[vobj_id].init); 387 fprintf(fpout, " />\n"); 364 388 } 365 389 fprintf(fpout, " </vseg>\n"); … … 384 408 unsigned int pseg_id = vseg[vseg_id].psegid; 385 409 unsigned int cluster_id = pseg[pseg_id].clusterid; 386 unsigned int x = cluster_id >> header->y_width; 387 unsigned int y = cluster_id & ((1<<header->y_width)-1); 388 389 fprintf(fpout, " <vseg name = \"%s\" ", vseg[vseg_id].name); 390 fprintf(fpout, "vbase = \"0x%x\" ", vseg[vseg_id].vbase); 391 fprintf(fpout, "mode = \"%s\" ", mode_str[vseg[vseg_id].mode]); 392 fprintf(fpout, "x = \"%d\" ", x); 393 fprintf(fpout, "y = \"%d\" ", y); 394 fprintf(fpout, "psegname = \"%s\" ", pseg[pseg_id].name); 395 fprintf(fpout, "ident = \"%d\" >\n", vseg[vseg_id].ident); 410 411 fprintf(fpout, " <vseg name=\"%s\"", vseg[vseg_id].name); 412 fprintf(fpout, " vbase=\"0x%x\"", vseg[vseg_id].vbase); 413 fprintf(fpout, " mode=\"%s\"", mode_str[vseg[vseg_id].mode]); 414 fprintf(fpout, " x=\"%d\"", cluster[cluster_id].x); 415 fprintf(fpout, " y=\"%d\"", cluster[cluster_id].y); 416 fprintf(fpout, " psegname=\"%s\"", pseg[pseg_id].name); 417 if( vseg[vseg_id].ident ) fprintf(fpout, " ident=\"1\""); 418 fprintf(fpout, " >\n"); 396 419 397 420 for (vobj_id = vseg[vseg_id].vobj_offset; … … 399 422 vobj_id++) 400 423 { 401 fprintf(fpout, " <vobj name = \"%s\" ", vobj[vobj_id].name); 402 fprintf(fpout, "type = \"%s\" ", vobj_type[vobj[vobj_id].type]); 403 fprintf(fpout, "length = \"0x%x\" ", vobj[vobj_id].length); 404 fprintf(fpout, "align = \"%d\" ", vobj[vobj_id].align); 405 fprintf(fpout, "init = \"%d\" ", vobj[vobj_id].init); 406 fprintf(fpout, "binpath = \"%s\" />\n", vobj[vobj_id].binpath); 424 fprintf(fpout, " <vobj name=\"%s\"", vobj[vobj_id].name); 425 fprintf(fpout, " type=\"%s\"", vobj_type[vobj[vobj_id].type]); 426 fprintf(fpout, " length=\"0x%x\"", vobj[vobj_id].length); 427 if( vobj[vobj_id].align ) 428 fprintf(fpout, " align=\"%d\"", vobj[vobj_id].align); 429 if( vobj[vobj_id].binpath[0] != 0 ) 430 fprintf(fpout, " binpath=\"%s\"", vobj[vobj_id].binpath); 431 if( (vobj[vobj_id].type == VOBJ_TYPE_BARRIER) || 432 (vobj[vobj_id].type == VOBJ_TYPE_MWMR ) || 433 (vobj[vobj_id].type == VOBJ_TYPE_CONST ) ) 434 fprintf(fpout, " init=\"%d\"", vobj[vobj_id].init); 435 fprintf(fpout, " />\n"); 407 436 } 408 437 fprintf(fpout, " </vseg>\n\n"); … … 418 447 unsigned int heap_vobj_id = task[task_id].heap_vobjid + vspace[vspace_id].vobj_offset; 419 448 unsigned int cluster_id = task[task_id].clusterid; 420 unsigned int x = cluster_id >> header->y_width; 421 unsigned int y = cluster_id & ((1<<header->y_width)-1); 422 423 fprintf(fpout, " <task name = \"%s\" ", task[task_id].name); 424 fprintf(fpout, "x = \"%d\" ", x); 425 fprintf(fpout, "y = \"%d\" ", y); 426 fprintf(fpout, "proclocid = \"%d\" ", task[task_id].proclocid); 427 fprintf(fpout, "stackname = \"%s\" ", vobj[stack_vobj_id].name); 449 450 fprintf(fpout, " <task name=\"%s\"", task[task_id].name); 451 fprintf(fpout, " trdid=\"%d\"", task[task_id].trdid); 452 fprintf(fpout, " x=\"%d\"", cluster[cluster_id].x); 453 fprintf(fpout, " y=\"%d\"", cluster[cluster_id].y); 454 fprintf(fpout, " p=\"%d\"", task[task_id].proclocid); 455 fprintf(fpout, " stackname=\"%s\"", vobj[stack_vobj_id].name); 428 456 if (heap_vobj_id != -1) 429 457 { 430 fprintf(fpout, " heapname = \"%s\"", vobj[heap_vobj_id].name);458 fprintf(fpout, " heapname=\"%s\"", vobj[heap_vobj_id].name); 431 459 } 432 fprintf(fpout, "startid = \"%d\" ", task[task_id].startid); 433 fprintf(fpout, "usetty = \"%d\" ", task[task_id].use_tty); 434 fprintf(fpout, "usenic = \"%d\" ", task[task_id].use_nic); 435 fprintf(fpout, "usecma = \"%d\" ", task[task_id].use_cma); 436 fprintf(fpout, "usetim = \"%d\" ", task[task_id].use_tim); 437 fprintf(fpout, "usehba = \"%d\" />\n", task[task_id].use_hba); 460 fprintf(fpout, " startid = \"%d\"", task[task_id].startid); 461 if( task[task_id].use_tty ) fprintf(fpout, " usetty=\"1\""); 462 if( task[task_id].use_nic ) fprintf(fpout, " usenic=\"1\""); 463 if( task[task_id].use_cma ) fprintf(fpout, " usecma=\"1\""); 464 if( task[task_id].use_tim ) fprintf(fpout, " usetim=\"1\""); 465 if( task[task_id].use_hba ) fprintf(fpout, " usehba=\"1\""); 466 fprintf(fpout, " />\n"); 438 467 } 439 468 fprintf(fpout, " </vspace>\n\n"); … … 445 474 446 475 ///////////////////////////////////// 447 int main(int argc, char * argv[]) { 448 if (argc < 2) { 476 int main(int argc, char * argv[]) 477 { 478 if (argc < 2) 479 { 449 480 printf("Usage: bin2xml <input_file_path> <output_file_path>\n"); 450 481 return 1; … … 454 485 455 486 int fdin = open(argv[1], O_RDONLY); 456 if (fdin < 0) { 487 if (fdin < 0) 488 { 457 489 perror("open"); 458 490 exit(1); … … 460 492 461 493 FILE * fpout = fopen( argv[2], "w"); 462 if (fpout == NULL) { 494 if (fpout == NULL) 495 { 463 496 perror("open"); 464 497 exit(1); … … 467 500 unsigned int length = read(fdin, bin, 0x40000); 468 501 469 if (length <= 0) { 502 if (length <= 0) 503 { 470 504 perror("read"); 471 505 exit(1); 472 506 } 473 507 474 if (bin[0] == IN_MAPPING_SIGNATURE) { 508 if (bin[0] == IN_MAPPING_SIGNATURE) 509 { 475 510 buildXml((mapping_header_t *) bin, fpout); 476 511 } 477 else { 512 else 513 { 478 514 printf("[ERROR] Wrong file format\n"); 479 515 exit(1);
Note: See TracChangeset
for help on using the changeset viewer.