[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 |
---|
[511] | 23 | const char * vseg_type[] = |
---|
[258] | 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", |
---|
| 43 | "PERI", |
---|
| 44 | }; |
---|
| 45 | |
---|
[295] | 46 | // mnemonics defined in mapping_info.h |
---|
[258] | 47 | const char * irq_type[] = |
---|
| 48 | { |
---|
[295] | 49 | "HWI", |
---|
| 50 | "WTI", |
---|
| 51 | "PTI", |
---|
[258] | 52 | }; |
---|
| 53 | |
---|
[295] | 54 | // mnemonics defined in irq_handler.h |
---|
[258] | 55 | const char * isr_type[] = |
---|
| 56 | { |
---|
[295] | 57 | "ISR_DEFAULT", |
---|
| 58 | "ISR_TICK", |
---|
| 59 | "ISR_TTY_RX", |
---|
| 60 | "ISR_TTY_TX", |
---|
| 61 | "ISR_BDV", |
---|
[258] | 62 | "ISR_TIMER", |
---|
[295] | 63 | "ISR_WAKUP", |
---|
| 64 | "ISR_NIC_RX", |
---|
| 65 | "ISR_NIC_TX", |
---|
| 66 | "ISR_CMA", |
---|
[323] | 67 | "ISR_MMC", |
---|
| 68 | "ISR_DMA", |
---|
| 69 | "ISR_SPI", |
---|
[258] | 70 | }; |
---|
| 71 | |
---|
[295] | 72 | // mnemonics defined in mapping_info.h |
---|
[258] | 73 | const char * periph_type[] = |
---|
| 74 | { |
---|
| 75 | "CMA", |
---|
| 76 | "DMA", |
---|
| 77 | "FBF", |
---|
| 78 | "IOB", |
---|
| 79 | "IOC", |
---|
| 80 | "MMC", |
---|
| 81 | "MWR", |
---|
| 82 | "NIC", |
---|
| 83 | "ROM", |
---|
| 84 | "SIM", |
---|
| 85 | "TIM", |
---|
| 86 | "TTY", |
---|
| 87 | "XCU", |
---|
[295] | 88 | "PIC", |
---|
[491] | 89 | "DROM", |
---|
[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 task_id; |
---|
| 131 | unsigned int proc_id; |
---|
| 132 | unsigned int irq_id; |
---|
| 133 | unsigned int coproc_id; |
---|
| 134 | unsigned int port_id; |
---|
| 135 | unsigned int periph_id; |
---|
| 136 | |
---|
| 137 | mapping_cluster_t * cluster; |
---|
| 138 | mapping_pseg_t * pseg; |
---|
| 139 | mapping_vspace_t * vspace; |
---|
| 140 | mapping_vseg_t * vseg; |
---|
| 141 | mapping_task_t * task; |
---|
| 142 | mapping_proc_t * proc; |
---|
| 143 | mapping_irq_t * irq; |
---|
| 144 | mapping_coproc_t * coproc; |
---|
| 145 | mapping_cp_port_t * cp_port; |
---|
| 146 | mapping_periph_t * periph; |
---|
| 147 | |
---|
| 148 | // computes the base adresss for clusters array, |
---|
| 149 | cluster = (mapping_cluster_t *)((char *) header + |
---|
| 150 | MAPPING_HEADER_SIZE); |
---|
| 151 | |
---|
| 152 | // computes the base adresss for psegs array, |
---|
| 153 | pseg = (mapping_pseg_t *) ((char *) header + |
---|
| 154 | MAPPING_HEADER_SIZE + |
---|
[263] | 155 | MAPPING_CLUSTER_SIZE * header->x_size * header->y_size); |
---|
[258] | 156 | |
---|
| 157 | // computes the base adresss for vspaces array, |
---|
| 158 | vspace = (mapping_vspace_t *) ((char *) header + |
---|
| 159 | MAPPING_HEADER_SIZE + |
---|
[263] | 160 | MAPPING_CLUSTER_SIZE * header->x_size * header->y_size + |
---|
[258] | 161 | MAPPING_PSEG_SIZE * header->psegs); |
---|
| 162 | |
---|
| 163 | // computes the base adresss for vsegs array, |
---|
| 164 | vseg = (mapping_vseg_t *) ((char *) header + |
---|
| 165 | MAPPING_HEADER_SIZE + |
---|
[263] | 166 | MAPPING_CLUSTER_SIZE * header->x_size * header->y_size + |
---|
[258] | 167 | MAPPING_PSEG_SIZE * header->psegs + |
---|
| 168 | MAPPING_VSPACE_SIZE * header->vspaces); |
---|
| 169 | |
---|
| 170 | // computes the base address for tasks array |
---|
| 171 | task = (mapping_task_t *) ((char *) header + |
---|
| 172 | MAPPING_HEADER_SIZE + |
---|
[263] | 173 | MAPPING_CLUSTER_SIZE * header->x_size * header->y_size + |
---|
[258] | 174 | MAPPING_PSEG_SIZE * header->psegs + |
---|
| 175 | MAPPING_VSPACE_SIZE * header->vspaces + |
---|
| 176 | MAPPING_VSEG_SIZE * header->vsegs); |
---|
| 177 | |
---|
| 178 | // computes the base address for procs array |
---|
| 179 | proc = (mapping_proc_t *) ((char *) header + |
---|
| 180 | MAPPING_HEADER_SIZE + |
---|
[263] | 181 | MAPPING_CLUSTER_SIZE * header->x_size * header->y_size + |
---|
[258] | 182 | MAPPING_PSEG_SIZE * header->psegs + |
---|
| 183 | MAPPING_VSPACE_SIZE * header->vspaces + |
---|
| 184 | MAPPING_VSEG_SIZE * header->vsegs + |
---|
| 185 | MAPPING_TASK_SIZE * header->tasks); |
---|
| 186 | |
---|
| 187 | // computes the base address for irqs array |
---|
| 188 | irq = (mapping_irq_t *) ((char *) header + |
---|
| 189 | MAPPING_HEADER_SIZE + |
---|
[263] | 190 | MAPPING_CLUSTER_SIZE * header->x_size * header->y_size + |
---|
[258] | 191 | MAPPING_PSEG_SIZE * header->psegs + |
---|
| 192 | MAPPING_VSPACE_SIZE * header->vspaces + |
---|
| 193 | MAPPING_VSEG_SIZE * header->vsegs + |
---|
| 194 | MAPPING_TASK_SIZE * header->tasks + |
---|
| 195 | MAPPING_PROC_SIZE * header->procs); |
---|
| 196 | |
---|
| 197 | // computes the base address for coprocs array |
---|
| 198 | coproc = (mapping_coproc_t *) ((char *) header + |
---|
| 199 | MAPPING_HEADER_SIZE + |
---|
[263] | 200 | MAPPING_CLUSTER_SIZE * header->x_size * header->y_size + |
---|
[258] | 201 | MAPPING_PSEG_SIZE * header->psegs + |
---|
| 202 | MAPPING_VSPACE_SIZE * header->vspaces + |
---|
| 203 | MAPPING_VSEG_SIZE * header->vsegs + |
---|
| 204 | MAPPING_TASK_SIZE * header->tasks + |
---|
| 205 | MAPPING_PROC_SIZE * header->procs + |
---|
| 206 | MAPPING_IRQ_SIZE * header->irqs); |
---|
| 207 | |
---|
| 208 | // computes the base address for cp_ports array |
---|
| 209 | cp_port = (mapping_cp_port_t *) ((char *) header + |
---|
| 210 | MAPPING_HEADER_SIZE + |
---|
[263] | 211 | MAPPING_CLUSTER_SIZE * header->x_size * header->y_size + |
---|
[258] | 212 | MAPPING_PSEG_SIZE * header->psegs + |
---|
| 213 | MAPPING_VSPACE_SIZE * header->vspaces + |
---|
| 214 | MAPPING_VSEG_SIZE * header->vsegs + |
---|
| 215 | MAPPING_TASK_SIZE * header->tasks + |
---|
| 216 | MAPPING_PROC_SIZE * header->procs + |
---|
| 217 | MAPPING_IRQ_SIZE * header->irqs + |
---|
| 218 | MAPPING_COPROC_SIZE * header->coprocs); |
---|
| 219 | |
---|
| 220 | // computes the base address for periphs array |
---|
| 221 | periph = (mapping_periph_t *) ((char *) header + |
---|
| 222 | MAPPING_HEADER_SIZE + |
---|
[263] | 223 | MAPPING_CLUSTER_SIZE * header->x_size * header->y_size + |
---|
[258] | 224 | MAPPING_PSEG_SIZE * header->psegs + |
---|
| 225 | MAPPING_VSPACE_SIZE * header->vspaces + |
---|
| 226 | MAPPING_VSEG_SIZE * header->vsegs + |
---|
| 227 | MAPPING_TASK_SIZE * header->tasks + |
---|
| 228 | MAPPING_PROC_SIZE * header->procs + |
---|
| 229 | MAPPING_IRQ_SIZE * header->irqs + |
---|
| 230 | MAPPING_COPROC_SIZE * header->coprocs + |
---|
| 231 | MAPPING_CP_PORT_SIZE * header->cp_ports); |
---|
| 232 | |
---|
| 233 | ///////////////////////// header ///////////////////////////////////////////// |
---|
| 234 | |
---|
| 235 | fprintf(fpout, "<?xml version = \"1.0\"?>\n\n"); |
---|
| 236 | |
---|
[287] | 237 | fprintf(fpout, "<mapping_info signature = \"0x%x\" \n" , header->signature); |
---|
| 238 | fprintf(fpout, " name = \"%s\" \n" , header->name); |
---|
| 239 | fprintf(fpout, " x_size = \"%d\" \n" , header->x_size); |
---|
| 240 | fprintf(fpout, " y_size = \"%d\" \n" , header->y_size); |
---|
| 241 | fprintf(fpout, " x_width = \"%d\" \n" , header->x_width); |
---|
| 242 | fprintf(fpout, " y_width = \"%d\" \n" , header->y_width); |
---|
[295] | 243 | fprintf(fpout, " irq_per_proc = \"%d\" \n" , header->irq_per_proc); |
---|
[306] | 244 | fprintf(fpout, " use_ram_disk = \"%d\" \n" , header->use_ram_disk); |
---|
[295] | 245 | fprintf(fpout, " x_io = \"%d\" \n" , header->x_io); |
---|
| 246 | fprintf(fpout, " y_io = \"%d\" >\n\n", header->y_io); |
---|
[258] | 247 | |
---|
| 248 | ///////////////////// clusters /////////////////////////////////////////////// |
---|
| 249 | |
---|
| 250 | fprintf( fpout, " <clusterset>\n"); |
---|
[263] | 251 | for (cluster_id = 0; cluster_id < (header->x_size * header->y_size); cluster_id++) |
---|
[258] | 252 | { |
---|
[306] | 253 | fprintf(fpout, " <cluster x=\"%d\" y=\"%d\" >\n", |
---|
[263] | 254 | cluster[cluster_id].x, cluster[cluster_id].y ); |
---|
| 255 | |
---|
| 256 | ///////////////////// psegs //////////////////////////////////////////////// |
---|
| 257 | |
---|
[258] | 258 | for (pseg_id = cluster[cluster_id].pseg_offset; |
---|
| 259 | pseg_id < cluster[cluster_id].pseg_offset + cluster[cluster_id].psegs; |
---|
| 260 | pseg_id++) |
---|
| 261 | { |
---|
[306] | 262 | fprintf(fpout, " <pseg name=\"%s\"", pseg[pseg_id].name); |
---|
| 263 | fprintf(fpout, " type=\"%s\"", pseg_type[pseg[pseg_id].type]); |
---|
| 264 | fprintf(fpout, " base=\"0x%llx\"", pseg[pseg_id].base); |
---|
| 265 | fprintf(fpout, " length=\"0x%llx\" />\n", pseg[pseg_id].length); |
---|
[258] | 266 | } |
---|
| 267 | |
---|
| 268 | ///////////////////// processors ///////////////////////////////////////////// |
---|
| 269 | |
---|
| 270 | unsigned int proc_index = 0; |
---|
| 271 | for (proc_id = cluster[cluster_id].proc_offset; |
---|
| 272 | proc_id < cluster[cluster_id].proc_offset + cluster[cluster_id].procs; |
---|
[295] | 273 | proc_id++, proc_index++) |
---|
[258] | 274 | { |
---|
[306] | 275 | fprintf(fpout, " <proc index=\"%d\" />\n", proc_index); |
---|
[258] | 276 | } |
---|
| 277 | |
---|
| 278 | ///////////////////// coprocessors /////////////////////////////////////////// |
---|
| 279 | |
---|
| 280 | for (coproc_id = cluster[cluster_id].coproc_offset; |
---|
| 281 | coproc_id < cluster[cluster_id].coproc_offset + cluster[cluster_id].coprocs; |
---|
| 282 | coproc_id++) |
---|
| 283 | { |
---|
[306] | 284 | fprintf(fpout, " <coproc name=\"%s\"", coproc[coproc_id].name); |
---|
| 285 | fprintf(fpout, " psegname=\"%s\" >\n", pseg[coproc[coproc_id].psegid].name); |
---|
[258] | 286 | for (port_id = coproc[coproc_id].port_offset; |
---|
| 287 | port_id < coproc[coproc_id].port_offset + coproc[coproc_id].ports; |
---|
| 288 | port_id++) |
---|
| 289 | { |
---|
[511] | 290 | unsigned int vseg_id = cp_port[port_id].mwmr_vseg_id; |
---|
[323] | 291 | fprintf(fpout, " <port direction=\"%s\"", port_direction[cp_port[port_id].direction]); |
---|
[306] | 292 | fprintf(fpout, " vspacename=\"%s\"", vspace[cp_port[port_id].vspaceid].name); |
---|
[511] | 293 | fprintf(fpout, " vsegname=\"%s\" />\n", vseg[vseg_id].name); |
---|
[258] | 294 | } |
---|
| 295 | fprintf(fpout, " </coproc>\n" ); |
---|
| 296 | } |
---|
| 297 | |
---|
| 298 | ///////////////////// periphs /////////////////////////////////////////////// |
---|
| 299 | |
---|
| 300 | for (periph_id = cluster[cluster_id].periph_offset; |
---|
| 301 | periph_id < cluster[cluster_id].periph_offset + cluster[cluster_id].periphs; |
---|
| 302 | periph_id++) |
---|
| 303 | { |
---|
[306] | 304 | fprintf(fpout, " <periph type=\"%s\"", periph_type[periph[periph_id].type]); |
---|
[289] | 305 | |
---|
[306] | 306 | if (periph[periph_id].type == PERIPH_TYPE_IOC) |
---|
| 307 | fprintf(fpout, " subtype=\"%s\"", ioc_subtype[periph[periph_id].subtype]); |
---|
[289] | 308 | |
---|
[306] | 309 | fprintf(fpout, " psegname=\"%s\"", pseg[periph[periph_id].psegid].name); |
---|
[323] | 310 | fprintf(fpout, " channels=\"%d\"", periph[periph_id].channels); |
---|
| 311 | fprintf(fpout, " arg=\"%d\" >\n", periph[periph_id].arg); |
---|
| 312 | if ( (periph[periph_id].type == PERIPH_TYPE_PIC) || |
---|
[439] | 313 | (periph[periph_id].type == PERIPH_TYPE_XCU) ) |
---|
[295] | 314 | { |
---|
[306] | 315 | for (irq_id = periph[periph_id].irq_offset; |
---|
| 316 | irq_id < periph[periph_id].irq_offset + periph[periph_id].irqs; |
---|
| 317 | irq_id++) |
---|
| 318 | { |
---|
| 319 | fprintf(fpout, " <irq srctype=\"%s\"", irq_type[irq[irq_id].srctype]); |
---|
| 320 | fprintf(fpout, " srcid=\"%d\"", irq[irq_id].srcid); |
---|
| 321 | fprintf(fpout, " isr=\"%s\"", isr_type[irq[irq_id].isr]); |
---|
[323] | 322 | fprintf(fpout, " channel=\"%d\" />\n", irq[irq_id].channel); |
---|
[306] | 323 | } |
---|
| 324 | } |
---|
[295] | 325 | fprintf(fpout, " </periph>\n"); |
---|
[258] | 326 | } |
---|
| 327 | fprintf(fpout, " </cluster>\n" ); |
---|
| 328 | } |
---|
| 329 | fprintf(fpout, " </clusterset>\n\n" ); |
---|
| 330 | |
---|
| 331 | /////////////////// globals ///////////////////////////////////////////////// |
---|
| 332 | |
---|
| 333 | fprintf(fpout, " <globalset>\n" ); |
---|
| 334 | for (vseg_id = 0; vseg_id < header->globals; vseg_id++) |
---|
| 335 | { |
---|
[306] | 336 | unsigned int pseg_id = vseg[vseg_id].psegid; |
---|
| 337 | unsigned int cluster_id = pseg[pseg_id].clusterid; |
---|
[258] | 338 | |
---|
[306] | 339 | fprintf(fpout, " <vseg name=\"%s\"", vseg[vseg_id].name); |
---|
| 340 | fprintf(fpout, " vbase=\"0x%x\"", vseg[vseg_id].vbase); |
---|
[511] | 341 | fprintf(fpout, " length=\"0x%x\"", vseg[vseg_id].length); |
---|
| 342 | fprintf(fpout, " type=\"%s\"", vseg_type[vseg[vseg_id].type]); |
---|
[306] | 343 | fprintf(fpout, " mode=\"%s\"", mode_str[vseg[vseg_id].mode]); |
---|
[511] | 344 | fprintf(fpout, "\n "); |
---|
[306] | 345 | fprintf(fpout, " x=\"%d\"", cluster[cluster_id].x); |
---|
| 346 | fprintf(fpout, " y=\"%d\"", cluster[cluster_id].y); |
---|
| 347 | fprintf(fpout, " psegname=\"%s\"", pseg[pseg_id].name); |
---|
[511] | 348 | if( vseg[vseg_id].ident ) |
---|
| 349 | fprintf(fpout, " ident=\"1\""); |
---|
| 350 | if( vseg[vseg_id].local ) |
---|
| 351 | fprintf(fpout, " local=\"1\""); |
---|
| 352 | if( vseg[vseg_id].big ) |
---|
| 353 | fprintf(fpout, " big=\"1\""); |
---|
| 354 | if( vseg[vseg_id].binpath[0] != 0 ) |
---|
| 355 | fprintf(fpout, " binpath=\"%s\"", vseg[vseg_id].binpath); |
---|
[306] | 356 | fprintf(fpout, " >\n"); |
---|
[258] | 357 | } |
---|
| 358 | fprintf(fpout, " </globalset>\n" ); |
---|
| 359 | |
---|
| 360 | //////////////////// vspaces //////////////////////////////////////////////// |
---|
| 361 | |
---|
| 362 | fprintf( fpout, "\n <vspaceset>\n\n" ); |
---|
| 363 | for (vspace_id = 0; vspace_id < header->vspaces; vspace_id++) |
---|
| 364 | { |
---|
[511] | 365 | unsigned int vseg_id = vspace[vspace_id].start_vseg_id; |
---|
[258] | 366 | fprintf(fpout, " <vspace name = \"%s\" ", vspace[vspace_id].name); |
---|
[511] | 367 | fprintf(fpout, " startname = \"%s\" >\n", vseg[vseg_id].name); |
---|
[258] | 368 | |
---|
[263] | 369 | //////////////////// vsegs ////////////////////////////////////////////// |
---|
| 370 | |
---|
[258] | 371 | for (vseg_id = vspace[vspace_id].vseg_offset; |
---|
| 372 | vseg_id < (vspace[vspace_id].vseg_offset + vspace[vspace_id].vsegs); |
---|
| 373 | vseg_id++) |
---|
| 374 | { |
---|
[263] | 375 | unsigned int pseg_id = vseg[vseg_id].psegid; |
---|
| 376 | unsigned int cluster_id = pseg[pseg_id].clusterid; |
---|
[258] | 377 | |
---|
[306] | 378 | fprintf(fpout, " <vseg name=\"%s\"", vseg[vseg_id].name); |
---|
| 379 | fprintf(fpout, " vbase=\"0x%x\"", vseg[vseg_id].vbase); |
---|
[511] | 380 | fprintf(fpout, " length=\"0x%x\"", vseg[vseg_id].length); |
---|
| 381 | fprintf(fpout, " type=\"%s\"", vseg_type[vseg[vseg_id].type]); |
---|
[306] | 382 | fprintf(fpout, " mode=\"%s\"", mode_str[vseg[vseg_id].mode]); |
---|
[511] | 383 | fprintf(fpout, "\n "); |
---|
[306] | 384 | fprintf(fpout, " x=\"%d\"", cluster[cluster_id].x); |
---|
| 385 | fprintf(fpout, " y=\"%d\"", cluster[cluster_id].y); |
---|
| 386 | fprintf(fpout, " psegname=\"%s\"", pseg[pseg_id].name); |
---|
[511] | 387 | if( vseg[vseg_id].ident ) |
---|
| 388 | fprintf(fpout, " ident=\"1\""); |
---|
| 389 | if( vseg[vseg_id].local ) |
---|
| 390 | fprintf(fpout, " local=\"1\""); |
---|
| 391 | if( vseg[vseg_id].big ) |
---|
| 392 | fprintf(fpout, " big=\"1\""); |
---|
| 393 | if( vseg[vseg_id].binpath[0] != 0 ) |
---|
| 394 | fprintf(fpout, " binpath=\"%s\"", vseg[vseg_id].binpath); |
---|
[306] | 395 | fprintf(fpout, " >\n"); |
---|
[258] | 396 | } |
---|
[263] | 397 | |
---|
| 398 | //////////////////// tasks ////////////////////////////////////////////// |
---|
| 399 | |
---|
[258] | 400 | for (task_id = vspace[vspace_id].task_offset; |
---|
| 401 | task_id < (vspace[vspace_id].task_offset + vspace[vspace_id].tasks); |
---|
| 402 | task_id++) |
---|
| 403 | { |
---|
[511] | 404 | unsigned int stack_vseg_id = task[task_id].stack_vseg_id; |
---|
| 405 | unsigned int heap_vseg_id = task[task_id].heap_vseg_id; |
---|
[323] | 406 | unsigned int cluster_id = task[task_id].clusterid; |
---|
[258] | 407 | |
---|
[306] | 408 | fprintf(fpout, " <task name=\"%s\"", task[task_id].name); |
---|
| 409 | fprintf(fpout, " trdid=\"%d\"", task[task_id].trdid); |
---|
| 410 | fprintf(fpout, " x=\"%d\"", cluster[cluster_id].x); |
---|
| 411 | fprintf(fpout, " y=\"%d\"", cluster[cluster_id].y); |
---|
| 412 | fprintf(fpout, " p=\"%d\"", task[task_id].proclocid); |
---|
[511] | 413 | fprintf(fpout, "\n "); |
---|
| 414 | fprintf(fpout, " stackname=\"%s\"", vseg[stack_vseg_id].name); |
---|
| 415 | if (heap_vseg_id != -1) |
---|
| 416 | fprintf(fpout, " heapname=\"%s\"", vseg[heap_vseg_id].name); |
---|
[306] | 417 | fprintf(fpout, " startid = \"%d\"", task[task_id].startid); |
---|
| 418 | fprintf(fpout, " />\n"); |
---|
[258] | 419 | } |
---|
| 420 | fprintf(fpout, " </vspace>\n\n"); |
---|
| 421 | } |
---|
| 422 | fprintf(fpout, " </vspaceset>\n"); |
---|
| 423 | fprintf(fpout, "</mapping_info>\n"); |
---|
| 424 | } // end buildXml() |
---|
| 425 | |
---|
| 426 | |
---|
| 427 | ///////////////////////////////////// |
---|
[306] | 428 | int main(int argc, char * argv[]) |
---|
| 429 | { |
---|
| 430 | if (argc < 2) |
---|
| 431 | { |
---|
[258] | 432 | printf("Usage: bin2xml <input_file_path> <output_file_path>\n"); |
---|
| 433 | return 1; |
---|
| 434 | } |
---|
| 435 | |
---|
| 436 | unsigned int bin[0x10000]; // 64 K int = 256 Kbytes |
---|
| 437 | |
---|
| 438 | int fdin = open(argv[1], O_RDONLY); |
---|
[306] | 439 | if (fdin < 0) |
---|
| 440 | { |
---|
[258] | 441 | perror("open"); |
---|
| 442 | exit(1); |
---|
| 443 | } |
---|
| 444 | |
---|
| 445 | FILE * fpout = fopen( argv[2], "w"); |
---|
[306] | 446 | if (fpout == NULL) |
---|
| 447 | { |
---|
[258] | 448 | perror("open"); |
---|
| 449 | exit(1); |
---|
| 450 | } |
---|
| 451 | |
---|
| 452 | unsigned int length = read(fdin, bin, 0x40000); |
---|
| 453 | |
---|
[306] | 454 | if (length <= 0) |
---|
| 455 | { |
---|
[258] | 456 | perror("read"); |
---|
| 457 | exit(1); |
---|
| 458 | } |
---|
| 459 | |
---|
[306] | 460 | if (bin[0] == IN_MAPPING_SIGNATURE) |
---|
| 461 | { |
---|
[258] | 462 | buildXml((mapping_header_t *) bin, fpout); |
---|
| 463 | } |
---|
[306] | 464 | else |
---|
| 465 | { |
---|
[258] | 466 | printf("[ERROR] Wrong file format\n"); |
---|
| 467 | exit(1); |
---|
| 468 | } |
---|
| 469 | return 0; |
---|
| 470 | } // end main() |
---|
| 471 | |
---|
| 472 | |
---|
| 473 | |
---|
| 474 | // Local Variables: |
---|
| 475 | // tab-width: 4 |
---|
| 476 | // c-basic-offset: 4 |
---|
| 477 | // c-file-offsets:((innamespace . 0)(inline-open . 0)) |
---|
| 478 | // indent-tabs-mode: nil |
---|
| 479 | // End: |
---|
| 480 | // vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 |
---|
| 481 | |
---|