[258] | 1 | //////////////////////////////////////////////////////////////////////////// |
---|
| 2 | // File : xml_driver.c |
---|
| 3 | // Date : 04/04/2012 |
---|
| 4 | // Author : alain greiner |
---|
| 5 | // Copyright (c) UPMC-LIP6 |
---|
| 6 | //////////////////////////////////////////////////////////////////////////// |
---|
| 7 | // This program translate a binary file containing a MAPPING_INFO |
---|
| 8 | // data structure to an xml file. |
---|
| 9 | //////////////////////////////////////////////////////////////////////////// |
---|
| 10 | |
---|
| 11 | #include <stdlib.h> |
---|
| 12 | #include <fcntl.h> |
---|
| 13 | #include <unistd.h> |
---|
| 14 | #include <stdio.h> |
---|
| 15 | #include <string.h> |
---|
| 16 | #include <stdint.h> |
---|
| 17 | #include <mapping_info.h> |
---|
| 18 | |
---|
| 19 | ////////////////////////////////////////////////////// |
---|
[295] | 20 | void buildXml(mapping_header_t * header, FILE * fpout) |
---|
| 21 | { |
---|
| 22 | // mnemonics defined in mapping_info.h |
---|
[258] | 23 | const char * vobj_type[] = |
---|
| 24 | { |
---|
| 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 |
---|
[295] | 31 | "BUFFER", // Any "no intialiasation needed" object (stacks...) |
---|
[258] | 32 | "BARRIER", // Barrier |
---|
| 33 | "CONST", // Constant |
---|
| 34 | "MEMSPACE", // Memspace |
---|
| 35 | "SCHED", // Scheduler |
---|
[472] | 36 | "HEAP", // Heap |
---|
[258] | 37 | }; |
---|
| 38 | |
---|
[295] | 39 | // mnemonics defined in mapping_info.h |
---|
[258] | 40 | const char * pseg_type[] = |
---|
| 41 | { |
---|
| 42 | "RAM", |
---|
[295] | 43 | "ROM", // deprecated => use PERI |
---|
[258] | 44 | "PERI", |
---|
| 45 | }; |
---|
| 46 | |
---|
[295] | 47 | // mnemonics defined in mapping_info.h |
---|
[258] | 48 | const char * irq_type[] = |
---|
| 49 | { |
---|
[295] | 50 | "HWI", |
---|
| 51 | "WTI", |
---|
| 52 | "PTI", |
---|
[258] | 53 | }; |
---|
| 54 | |
---|
[295] | 55 | // mnemonics defined in irq_handler.h |
---|
[258] | 56 | const char * isr_type[] = |
---|
| 57 | { |
---|
[295] | 58 | "ISR_DEFAULT", |
---|
| 59 | "ISR_TICK", |
---|
| 60 | "ISR_TTY_RX", |
---|
| 61 | "ISR_TTY_TX", |
---|
| 62 | "ISR_BDV", |
---|
[258] | 63 | "ISR_TIMER", |
---|
[295] | 64 | "ISR_WAKUP", |
---|
| 65 | "ISR_NIC_RX", |
---|
| 66 | "ISR_NIC_TX", |
---|
| 67 | "ISR_CMA", |
---|
[323] | 68 | "ISR_MMC", |
---|
| 69 | "ISR_DMA", |
---|
| 70 | "ISR_SPI", |
---|
[258] | 71 | }; |
---|
| 72 | |
---|
[295] | 73 | // mnemonics defined in mapping_info.h |
---|
[258] | 74 | const char * periph_type[] = |
---|
| 75 | { |
---|
| 76 | "CMA", |
---|
| 77 | "DMA", |
---|
| 78 | "FBF", |
---|
| 79 | "IOB", |
---|
| 80 | "IOC", |
---|
| 81 | "MMC", |
---|
| 82 | "MWR", |
---|
| 83 | "NIC", |
---|
| 84 | "ROM", |
---|
| 85 | "SIM", |
---|
| 86 | "TIM", |
---|
| 87 | "TTY", |
---|
| 88 | "XCU", |
---|
[295] | 89 | "PIC", |
---|
[258] | 90 | }; |
---|
| 91 | |
---|
[295] | 92 | const char * ioc_subtype[] = |
---|
[289] | 93 | { |
---|
| 94 | "BDV", |
---|
| 95 | "HBA", |
---|
| 96 | "SPI", |
---|
[323] | 97 | "NONE", |
---|
[289] | 98 | }; |
---|
| 99 | |
---|
[258] | 100 | const char * port_direction[] = |
---|
| 101 | { |
---|
| 102 | "TO_COPROC", |
---|
| 103 | "FROM_COPROC", |
---|
| 104 | }; |
---|
| 105 | |
---|
| 106 | const char * mode_str[] = |
---|
| 107 | { |
---|
| 108 | "____", |
---|
| 109 | "___U", |
---|
| 110 | "__W_", |
---|
| 111 | "__WU", |
---|
| 112 | "_X__", |
---|
| 113 | "_X_U", |
---|
| 114 | "_XW_", |
---|
| 115 | "_XWU", |
---|
| 116 | "C___", |
---|
| 117 | "C__U", |
---|
| 118 | "C_W_", |
---|
| 119 | "C_WU", |
---|
| 120 | "CX__", |
---|
| 121 | "CX_U", |
---|
| 122 | "CXW_", |
---|
| 123 | "CXWU", |
---|
| 124 | }; |
---|
| 125 | |
---|
| 126 | unsigned int vspace_id; |
---|
| 127 | unsigned int cluster_id; |
---|
| 128 | unsigned int pseg_id; |
---|
| 129 | unsigned int vseg_id; |
---|
| 130 | unsigned int vobj_id; |
---|
| 131 | unsigned int task_id; |
---|
| 132 | unsigned int proc_id; |
---|
| 133 | unsigned int irq_id; |
---|
| 134 | unsigned int coproc_id; |
---|
| 135 | unsigned int port_id; |
---|
| 136 | unsigned int periph_id; |
---|
| 137 | |
---|
| 138 | mapping_cluster_t * cluster; |
---|
| 139 | mapping_pseg_t * pseg; |
---|
| 140 | mapping_vspace_t * vspace; |
---|
| 141 | mapping_vseg_t * vseg; |
---|
| 142 | mapping_vobj_t * vobj; |
---|
| 143 | mapping_task_t * task; |
---|
| 144 | mapping_proc_t * proc; |
---|
| 145 | mapping_irq_t * irq; |
---|
| 146 | mapping_coproc_t * coproc; |
---|
| 147 | mapping_cp_port_t * cp_port; |
---|
| 148 | mapping_periph_t * periph; |
---|
| 149 | |
---|
| 150 | // computes the base adresss for clusters array, |
---|
| 151 | cluster = (mapping_cluster_t *)((char *) header + |
---|
| 152 | MAPPING_HEADER_SIZE); |
---|
| 153 | |
---|
| 154 | // computes the base adresss for psegs array, |
---|
| 155 | pseg = (mapping_pseg_t *) ((char *) header + |
---|
| 156 | MAPPING_HEADER_SIZE + |
---|
[263] | 157 | MAPPING_CLUSTER_SIZE * header->x_size * header->y_size); |
---|
[258] | 158 | |
---|
| 159 | // computes the base adresss for vspaces array, |
---|
| 160 | vspace = (mapping_vspace_t *) ((char *) header + |
---|
| 161 | MAPPING_HEADER_SIZE + |
---|
[263] | 162 | MAPPING_CLUSTER_SIZE * header->x_size * header->y_size + |
---|
[258] | 163 | MAPPING_PSEG_SIZE * header->psegs); |
---|
| 164 | |
---|
| 165 | // computes the base adresss for vsegs array, |
---|
| 166 | vseg = (mapping_vseg_t *) ((char *) header + |
---|
| 167 | MAPPING_HEADER_SIZE + |
---|
[263] | 168 | MAPPING_CLUSTER_SIZE * header->x_size * header->y_size + |
---|
[258] | 169 | MAPPING_PSEG_SIZE * header->psegs + |
---|
| 170 | MAPPING_VSPACE_SIZE * header->vspaces); |
---|
| 171 | |
---|
| 172 | // computes the base adresss for vobjs array, |
---|
| 173 | vobj = (mapping_vobj_t *) ((char *) header + |
---|
| 174 | MAPPING_HEADER_SIZE + |
---|
[263] | 175 | MAPPING_CLUSTER_SIZE * header->x_size * header->y_size + |
---|
[258] | 176 | MAPPING_PSEG_SIZE * header->psegs + |
---|
| 177 | MAPPING_VSPACE_SIZE * header->vspaces + |
---|
| 178 | MAPPING_VSEG_SIZE * header->vsegs); |
---|
| 179 | |
---|
| 180 | // computes the base address for tasks array |
---|
| 181 | task = (mapping_task_t *) ((char *) header + |
---|
| 182 | MAPPING_HEADER_SIZE + |
---|
[263] | 183 | MAPPING_CLUSTER_SIZE * header->x_size * header->y_size + |
---|
[258] | 184 | MAPPING_PSEG_SIZE * header->psegs + |
---|
| 185 | MAPPING_VSPACE_SIZE * header->vspaces + |
---|
| 186 | MAPPING_VOBJ_SIZE * header->vobjs + |
---|
| 187 | MAPPING_VSEG_SIZE * header->vsegs); |
---|
| 188 | |
---|
| 189 | // computes the base address for procs array |
---|
| 190 | proc = (mapping_proc_t *) ((char *) header + |
---|
| 191 | MAPPING_HEADER_SIZE + |
---|
[263] | 192 | MAPPING_CLUSTER_SIZE * header->x_size * header->y_size + |
---|
[258] | 193 | MAPPING_PSEG_SIZE * header->psegs + |
---|
| 194 | MAPPING_VSPACE_SIZE * header->vspaces + |
---|
| 195 | MAPPING_VOBJ_SIZE * header->vobjs + |
---|
| 196 | MAPPING_VSEG_SIZE * header->vsegs + |
---|
| 197 | MAPPING_TASK_SIZE * header->tasks); |
---|
| 198 | |
---|
| 199 | // computes the base address for irqs array |
---|
| 200 | irq = (mapping_irq_t *) ((char *) header + |
---|
| 201 | MAPPING_HEADER_SIZE + |
---|
[263] | 202 | MAPPING_CLUSTER_SIZE * header->x_size * header->y_size + |
---|
[258] | 203 | MAPPING_PSEG_SIZE * header->psegs + |
---|
| 204 | MAPPING_VSPACE_SIZE * header->vspaces + |
---|
| 205 | MAPPING_VOBJ_SIZE * header->vobjs + |
---|
| 206 | MAPPING_VSEG_SIZE * header->vsegs + |
---|
| 207 | MAPPING_TASK_SIZE * header->tasks + |
---|
| 208 | MAPPING_PROC_SIZE * header->procs); |
---|
| 209 | |
---|
| 210 | // computes the base address for coprocs array |
---|
| 211 | coproc = (mapping_coproc_t *) ((char *) header + |
---|
| 212 | MAPPING_HEADER_SIZE + |
---|
[263] | 213 | MAPPING_CLUSTER_SIZE * header->x_size * header->y_size + |
---|
[258] | 214 | MAPPING_PSEG_SIZE * header->psegs + |
---|
| 215 | MAPPING_VSPACE_SIZE * header->vspaces + |
---|
| 216 | MAPPING_VOBJ_SIZE * header->vobjs + |
---|
| 217 | MAPPING_VSEG_SIZE * header->vsegs + |
---|
| 218 | MAPPING_TASK_SIZE * header->tasks + |
---|
| 219 | MAPPING_PROC_SIZE * header->procs + |
---|
| 220 | MAPPING_IRQ_SIZE * header->irqs); |
---|
| 221 | |
---|
| 222 | // computes the base address for cp_ports array |
---|
| 223 | cp_port = (mapping_cp_port_t *) ((char *) header + |
---|
| 224 | MAPPING_HEADER_SIZE + |
---|
[263] | 225 | MAPPING_CLUSTER_SIZE * header->x_size * header->y_size + |
---|
[258] | 226 | MAPPING_PSEG_SIZE * header->psegs + |
---|
| 227 | MAPPING_VSPACE_SIZE * header->vspaces + |
---|
| 228 | MAPPING_VOBJ_SIZE * header->vobjs + |
---|
| 229 | MAPPING_VSEG_SIZE * header->vsegs + |
---|
| 230 | MAPPING_TASK_SIZE * header->tasks + |
---|
| 231 | MAPPING_PROC_SIZE * header->procs + |
---|
| 232 | MAPPING_IRQ_SIZE * header->irqs + |
---|
| 233 | MAPPING_COPROC_SIZE * header->coprocs); |
---|
| 234 | |
---|
| 235 | // computes the base address for periphs array |
---|
| 236 | periph = (mapping_periph_t *) ((char *) header + |
---|
| 237 | MAPPING_HEADER_SIZE + |
---|
[263] | 238 | MAPPING_CLUSTER_SIZE * header->x_size * header->y_size + |
---|
[258] | 239 | MAPPING_PSEG_SIZE * header->psegs + |
---|
| 240 | MAPPING_VSPACE_SIZE * header->vspaces + |
---|
| 241 | MAPPING_VOBJ_SIZE * header->vobjs + |
---|
| 242 | MAPPING_VSEG_SIZE * header->vsegs + |
---|
| 243 | MAPPING_TASK_SIZE * header->tasks + |
---|
| 244 | MAPPING_PROC_SIZE * header->procs + |
---|
| 245 | MAPPING_IRQ_SIZE * header->irqs + |
---|
| 246 | MAPPING_COPROC_SIZE * header->coprocs + |
---|
| 247 | MAPPING_CP_PORT_SIZE * header->cp_ports); |
---|
| 248 | |
---|
| 249 | ///////////////////////// header ///////////////////////////////////////////// |
---|
| 250 | |
---|
| 251 | fprintf(fpout, "<?xml version = \"1.0\"?>\n\n"); |
---|
| 252 | |
---|
[287] | 253 | fprintf(fpout, "<mapping_info signature = \"0x%x\" \n" , header->signature); |
---|
| 254 | fprintf(fpout, " name = \"%s\" \n" , header->name); |
---|
| 255 | fprintf(fpout, " x_size = \"%d\" \n" , header->x_size); |
---|
| 256 | fprintf(fpout, " y_size = \"%d\" \n" , header->y_size); |
---|
| 257 | fprintf(fpout, " x_width = \"%d\" \n" , header->x_width); |
---|
| 258 | fprintf(fpout, " y_width = \"%d\" \n" , header->y_width); |
---|
[295] | 259 | fprintf(fpout, " irq_per_proc = \"%d\" \n" , header->irq_per_proc); |
---|
[306] | 260 | fprintf(fpout, " use_ram_disk = \"%d\" \n" , header->use_ram_disk); |
---|
[295] | 261 | fprintf(fpout, " x_io = \"%d\" \n" , header->x_io); |
---|
| 262 | fprintf(fpout, " y_io = \"%d\" >\n\n", header->y_io); |
---|
[258] | 263 | |
---|
| 264 | ///////////////////// clusters /////////////////////////////////////////////// |
---|
| 265 | |
---|
| 266 | fprintf( fpout, " <clusterset>\n"); |
---|
[263] | 267 | for (cluster_id = 0; cluster_id < (header->x_size * header->y_size); cluster_id++) |
---|
[258] | 268 | { |
---|
[306] | 269 | fprintf(fpout, " <cluster x=\"%d\" y=\"%d\" >\n", |
---|
[263] | 270 | cluster[cluster_id].x, cluster[cluster_id].y ); |
---|
| 271 | |
---|
| 272 | ///////////////////// psegs //////////////////////////////////////////////// |
---|
| 273 | |
---|
[258] | 274 | for (pseg_id = cluster[cluster_id].pseg_offset; |
---|
| 275 | pseg_id < cluster[cluster_id].pseg_offset + cluster[cluster_id].psegs; |
---|
| 276 | pseg_id++) |
---|
| 277 | { |
---|
[306] | 278 | fprintf(fpout, " <pseg name=\"%s\"", pseg[pseg_id].name); |
---|
| 279 | fprintf(fpout, " type=\"%s\"", pseg_type[pseg[pseg_id].type]); |
---|
| 280 | fprintf(fpout, " base=\"0x%llx\"", pseg[pseg_id].base); |
---|
| 281 | fprintf(fpout, " length=\"0x%llx\" />\n", pseg[pseg_id].length); |
---|
[258] | 282 | } |
---|
| 283 | |
---|
| 284 | ///////////////////// processors ///////////////////////////////////////////// |
---|
| 285 | |
---|
| 286 | unsigned int proc_index = 0; |
---|
| 287 | for (proc_id = cluster[cluster_id].proc_offset; |
---|
| 288 | proc_id < cluster[cluster_id].proc_offset + cluster[cluster_id].procs; |
---|
[295] | 289 | proc_id++, proc_index++) |
---|
[258] | 290 | { |
---|
[306] | 291 | fprintf(fpout, " <proc index=\"%d\" />\n", proc_index); |
---|
[258] | 292 | } |
---|
| 293 | |
---|
| 294 | ///////////////////// coprocessors /////////////////////////////////////////// |
---|
| 295 | |
---|
| 296 | for (coproc_id = cluster[cluster_id].coproc_offset; |
---|
| 297 | coproc_id < cluster[cluster_id].coproc_offset + cluster[cluster_id].coprocs; |
---|
| 298 | coproc_id++) |
---|
| 299 | { |
---|
[306] | 300 | fprintf(fpout, " <coproc name=\"%s\"", coproc[coproc_id].name); |
---|
| 301 | fprintf(fpout, " psegname=\"%s\" >\n", pseg[coproc[coproc_id].psegid].name); |
---|
[258] | 302 | for (port_id = coproc[coproc_id].port_offset; |
---|
| 303 | port_id < coproc[coproc_id].port_offset + coproc[coproc_id].ports; |
---|
| 304 | port_id++) |
---|
| 305 | { |
---|
[323] | 306 | unsigned int vobj_id = cp_port[port_id].mwmr_vobj_id; |
---|
| 307 | fprintf(fpout, " <port direction=\"%s\"", port_direction[cp_port[port_id].direction]); |
---|
[306] | 308 | fprintf(fpout, " vspacename=\"%s\"", vspace[cp_port[port_id].vspaceid].name); |
---|
| 309 | fprintf(fpout, " vobjname=\"%s\" />\n", vobj[vobj_id].name); |
---|
[258] | 310 | } |
---|
| 311 | fprintf(fpout, " </coproc>\n" ); |
---|
| 312 | } |
---|
| 313 | |
---|
| 314 | ///////////////////// periphs /////////////////////////////////////////////// |
---|
| 315 | |
---|
| 316 | for (periph_id = cluster[cluster_id].periph_offset; |
---|
| 317 | periph_id < cluster[cluster_id].periph_offset + cluster[cluster_id].periphs; |
---|
| 318 | periph_id++) |
---|
| 319 | { |
---|
[306] | 320 | fprintf(fpout, " <periph type=\"%s\"", periph_type[periph[periph_id].type]); |
---|
[289] | 321 | |
---|
[306] | 322 | if (periph[periph_id].type == PERIPH_TYPE_IOC) |
---|
| 323 | fprintf(fpout, " subtype=\"%s\"", ioc_subtype[periph[periph_id].subtype]); |
---|
[289] | 324 | |
---|
[306] | 325 | fprintf(fpout, " psegname=\"%s\"", pseg[periph[periph_id].psegid].name); |
---|
[323] | 326 | fprintf(fpout, " channels=\"%d\"", periph[periph_id].channels); |
---|
| 327 | fprintf(fpout, " arg=\"%d\" >\n", periph[periph_id].arg); |
---|
| 328 | if ( (periph[periph_id].type == PERIPH_TYPE_PIC) || |
---|
[439] | 329 | (periph[periph_id].type == PERIPH_TYPE_XCU) ) |
---|
[295] | 330 | { |
---|
[306] | 331 | for (irq_id = periph[periph_id].irq_offset; |
---|
| 332 | irq_id < periph[periph_id].irq_offset + periph[periph_id].irqs; |
---|
| 333 | irq_id++) |
---|
| 334 | { |
---|
| 335 | fprintf(fpout, " <irq srctype=\"%s\"", irq_type[irq[irq_id].srctype]); |
---|
| 336 | fprintf(fpout, " srcid=\"%d\"", irq[irq_id].srcid); |
---|
| 337 | fprintf(fpout, " isr=\"%s\"", isr_type[irq[irq_id].isr]); |
---|
[323] | 338 | fprintf(fpout, " channel=\"%d\" />\n", irq[irq_id].channel); |
---|
[306] | 339 | } |
---|
| 340 | } |
---|
[295] | 341 | fprintf(fpout, " </periph>\n"); |
---|
[258] | 342 | } |
---|
| 343 | fprintf(fpout, " </cluster>\n" ); |
---|
| 344 | } |
---|
| 345 | fprintf(fpout, " </clusterset>\n\n" ); |
---|
| 346 | |
---|
| 347 | /////////////////// globals ///////////////////////////////////////////////// |
---|
| 348 | |
---|
| 349 | fprintf(fpout, " <globalset>\n" ); |
---|
| 350 | for (vseg_id = 0; vseg_id < header->globals; vseg_id++) |
---|
| 351 | { |
---|
[306] | 352 | unsigned int pseg_id = vseg[vseg_id].psegid; |
---|
| 353 | unsigned int cluster_id = pseg[pseg_id].clusterid; |
---|
[258] | 354 | |
---|
[306] | 355 | fprintf(fpout, " <vseg name=\"%s\"", vseg[vseg_id].name); |
---|
| 356 | fprintf(fpout, " vbase=\"0x%x\"", vseg[vseg_id].vbase); |
---|
| 357 | fprintf(fpout, " mode=\"%s\"", mode_str[vseg[vseg_id].mode]); |
---|
| 358 | fprintf(fpout, " x=\"%d\"", cluster[cluster_id].x); |
---|
| 359 | fprintf(fpout, " y=\"%d\"", cluster[cluster_id].y); |
---|
| 360 | fprintf(fpout, " psegname=\"%s\"", pseg[pseg_id].name); |
---|
| 361 | if( vseg[vseg_id].ident ) fprintf(fpout, " ident=\"1\""); |
---|
[349] | 362 | if( vseg[vseg_id].local ) fprintf(fpout, " local=\"1\""); |
---|
[306] | 363 | fprintf(fpout, " >\n"); |
---|
| 364 | |
---|
[258] | 365 | for (vobj_id = vseg[vseg_id].vobj_offset; |
---|
| 366 | vobj_id < (vseg[vseg_id].vobj_offset + vseg[vseg_id].vobjs); |
---|
| 367 | vobj_id++) |
---|
| 368 | { |
---|
[306] | 369 | fprintf(fpout, " <vobj name=\"%s\"", vobj[vobj_id].name); |
---|
| 370 | fprintf(fpout, " type=\"%s\"", vobj_type[vobj[vobj_id].type]); |
---|
| 371 | fprintf(fpout, " length=\"0x%x\"", vobj[vobj_id].length); |
---|
| 372 | if( vobj[vobj_id].align ) |
---|
| 373 | fprintf(fpout, " align=\"%d\"", vobj[vobj_id].align); |
---|
| 374 | if( vobj[vobj_id].binpath[0] != 0 ) |
---|
| 375 | fprintf(fpout, " binpath=\"%s\"", vobj[vobj_id].binpath); |
---|
| 376 | if( (vobj[vobj_id].type == VOBJ_TYPE_BARRIER) || |
---|
| 377 | (vobj[vobj_id].type == VOBJ_TYPE_MWMR ) || |
---|
| 378 | (vobj[vobj_id].type == VOBJ_TYPE_CONST ) ) |
---|
| 379 | fprintf(fpout, " init=\"%d\"", vobj[vobj_id].init); |
---|
| 380 | fprintf(fpout, " />\n"); |
---|
[258] | 381 | } |
---|
| 382 | fprintf(fpout, " </vseg>\n"); |
---|
| 383 | } |
---|
| 384 | fprintf(fpout, " </globalset>\n" ); |
---|
| 385 | |
---|
| 386 | //////////////////// vspaces //////////////////////////////////////////////// |
---|
| 387 | |
---|
| 388 | fprintf( fpout, "\n <vspaceset>\n\n" ); |
---|
| 389 | for (vspace_id = 0; vspace_id < header->vspaces; vspace_id++) |
---|
| 390 | { |
---|
[323] | 391 | unsigned int vobj_id = vspace[vspace_id].start_vobj_id; |
---|
[258] | 392 | fprintf(fpout, " <vspace name = \"%s\" ", vspace[vspace_id].name); |
---|
[323] | 393 | fprintf(fpout, " startname = \"%s\" >\n", vobj[vobj_id].name); |
---|
[258] | 394 | |
---|
[263] | 395 | //////////////////// vsegs ////////////////////////////////////////////// |
---|
| 396 | |
---|
[258] | 397 | for (vseg_id = vspace[vspace_id].vseg_offset; |
---|
| 398 | vseg_id < (vspace[vspace_id].vseg_offset + vspace[vspace_id].vsegs); |
---|
| 399 | vseg_id++) |
---|
| 400 | { |
---|
[263] | 401 | unsigned int pseg_id = vseg[vseg_id].psegid; |
---|
| 402 | unsigned int cluster_id = pseg[pseg_id].clusterid; |
---|
[258] | 403 | |
---|
[306] | 404 | fprintf(fpout, " <vseg name=\"%s\"", vseg[vseg_id].name); |
---|
| 405 | fprintf(fpout, " vbase=\"0x%x\"", vseg[vseg_id].vbase); |
---|
| 406 | fprintf(fpout, " mode=\"%s\"", mode_str[vseg[vseg_id].mode]); |
---|
| 407 | fprintf(fpout, " x=\"%d\"", cluster[cluster_id].x); |
---|
| 408 | fprintf(fpout, " y=\"%d\"", cluster[cluster_id].y); |
---|
| 409 | fprintf(fpout, " psegname=\"%s\"", pseg[pseg_id].name); |
---|
| 410 | if( vseg[vseg_id].ident ) fprintf(fpout, " ident=\"1\""); |
---|
[349] | 411 | if( vseg[vseg_id].local ) fprintf(fpout, " local=\"1\""); |
---|
[306] | 412 | fprintf(fpout, " >\n"); |
---|
[258] | 413 | |
---|
| 414 | for (vobj_id = vseg[vseg_id].vobj_offset; |
---|
| 415 | vobj_id < (vseg[vseg_id].vobj_offset + vseg[vseg_id].vobjs); |
---|
| 416 | vobj_id++) |
---|
| 417 | { |
---|
[306] | 418 | fprintf(fpout, " <vobj name=\"%s\"", vobj[vobj_id].name); |
---|
| 419 | fprintf(fpout, " type=\"%s\"", vobj_type[vobj[vobj_id].type]); |
---|
| 420 | fprintf(fpout, " length=\"0x%x\"", vobj[vobj_id].length); |
---|
| 421 | if( vobj[vobj_id].align ) |
---|
| 422 | fprintf(fpout, " align=\"%d\"", vobj[vobj_id].align); |
---|
| 423 | if( vobj[vobj_id].binpath[0] != 0 ) |
---|
| 424 | fprintf(fpout, " binpath=\"%s\"", vobj[vobj_id].binpath); |
---|
| 425 | if( (vobj[vobj_id].type == VOBJ_TYPE_BARRIER) || |
---|
| 426 | (vobj[vobj_id].type == VOBJ_TYPE_MWMR ) || |
---|
| 427 | (vobj[vobj_id].type == VOBJ_TYPE_CONST ) ) |
---|
| 428 | fprintf(fpout, " init=\"%d\"", vobj[vobj_id].init); |
---|
| 429 | fprintf(fpout, " />\n"); |
---|
[258] | 430 | } |
---|
| 431 | fprintf(fpout, " </vseg>\n\n"); |
---|
| 432 | } |
---|
[263] | 433 | |
---|
| 434 | //////////////////// tasks ////////////////////////////////////////////// |
---|
| 435 | |
---|
[258] | 436 | for (task_id = vspace[vspace_id].task_offset; |
---|
| 437 | task_id < (vspace[vspace_id].task_offset + vspace[vspace_id].tasks); |
---|
| 438 | task_id++) |
---|
| 439 | { |
---|
[323] | 440 | unsigned int stack_vobj_id = task[task_id].stack_vobj_id; |
---|
| 441 | unsigned int heap_vobj_id = task[task_id].heap_vobj_id; |
---|
| 442 | unsigned int cluster_id = task[task_id].clusterid; |
---|
[258] | 443 | |
---|
[306] | 444 | fprintf(fpout, " <task name=\"%s\"", task[task_id].name); |
---|
| 445 | fprintf(fpout, " trdid=\"%d\"", task[task_id].trdid); |
---|
| 446 | fprintf(fpout, " x=\"%d\"", cluster[cluster_id].x); |
---|
| 447 | fprintf(fpout, " y=\"%d\"", cluster[cluster_id].y); |
---|
| 448 | fprintf(fpout, " p=\"%d\"", task[task_id].proclocid); |
---|
| 449 | fprintf(fpout, " stackname=\"%s\"", vobj[stack_vobj_id].name); |
---|
[258] | 450 | if (heap_vobj_id != -1) |
---|
| 451 | { |
---|
[306] | 452 | fprintf(fpout, " heapname=\"%s\"", vobj[heap_vobj_id].name); |
---|
[258] | 453 | } |
---|
[306] | 454 | fprintf(fpout, " startid = \"%d\"", task[task_id].startid); |
---|
| 455 | fprintf(fpout, " />\n"); |
---|
[258] | 456 | } |
---|
| 457 | fprintf(fpout, " </vspace>\n\n"); |
---|
| 458 | } |
---|
| 459 | fprintf(fpout, " </vspaceset>\n"); |
---|
| 460 | fprintf(fpout, "</mapping_info>\n"); |
---|
| 461 | } // end buildXml() |
---|
| 462 | |
---|
| 463 | |
---|
| 464 | ///////////////////////////////////// |
---|
[306] | 465 | int main(int argc, char * argv[]) |
---|
| 466 | { |
---|
| 467 | if (argc < 2) |
---|
| 468 | { |
---|
[258] | 469 | printf("Usage: bin2xml <input_file_path> <output_file_path>\n"); |
---|
| 470 | return 1; |
---|
| 471 | } |
---|
| 472 | |
---|
| 473 | unsigned int bin[0x10000]; // 64 K int = 256 Kbytes |
---|
| 474 | |
---|
| 475 | int fdin = open(argv[1], O_RDONLY); |
---|
[306] | 476 | if (fdin < 0) |
---|
| 477 | { |
---|
[258] | 478 | perror("open"); |
---|
| 479 | exit(1); |
---|
| 480 | } |
---|
| 481 | |
---|
| 482 | FILE * fpout = fopen( argv[2], "w"); |
---|
[306] | 483 | if (fpout == NULL) |
---|
| 484 | { |
---|
[258] | 485 | perror("open"); |
---|
| 486 | exit(1); |
---|
| 487 | } |
---|
| 488 | |
---|
| 489 | unsigned int length = read(fdin, bin, 0x40000); |
---|
| 490 | |
---|
[306] | 491 | if (length <= 0) |
---|
| 492 | { |
---|
[258] | 493 | perror("read"); |
---|
| 494 | exit(1); |
---|
| 495 | } |
---|
| 496 | |
---|
[306] | 497 | if (bin[0] == IN_MAPPING_SIGNATURE) |
---|
| 498 | { |
---|
[258] | 499 | buildXml((mapping_header_t *) bin, fpout); |
---|
| 500 | } |
---|
[306] | 501 | else |
---|
| 502 | { |
---|
[258] | 503 | printf("[ERROR] Wrong file format\n"); |
---|
| 504 | exit(1); |
---|
| 505 | } |
---|
| 506 | return 0; |
---|
| 507 | } // end main() |
---|
| 508 | |
---|
| 509 | |
---|
| 510 | |
---|
| 511 | // Local Variables: |
---|
| 512 | // tab-width: 4 |
---|
| 513 | // c-basic-offset: 4 |
---|
| 514 | // c-file-offsets:((innamespace . 0)(inline-open . 0)) |
---|
| 515 | // indent-tabs-mode: nil |
---|
| 516 | // End: |
---|
| 517 | // vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 |
---|
| 518 | |
---|