[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 |
---|
| 36 | }; |
---|
| 37 | |
---|
[295] | 38 | // mnemonics defined in mapping_info.h |
---|
[258] | 39 | const char * pseg_type[] = |
---|
| 40 | { |
---|
| 41 | "RAM", |
---|
[295] | 42 | "ROM", // deprecated => use PERI |
---|
[258] | 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", |
---|
[258] | 67 | }; |
---|
| 68 | |
---|
[295] | 69 | // mnemonics defined in mapping_info.h |
---|
[258] | 70 | const char * periph_type[] = |
---|
| 71 | { |
---|
| 72 | "CMA", |
---|
| 73 | "DMA", |
---|
| 74 | "FBF", |
---|
| 75 | "ICU", |
---|
| 76 | "IOB", |
---|
| 77 | "IOC", |
---|
| 78 | "MMC", |
---|
| 79 | "MWR", |
---|
| 80 | "NIC", |
---|
| 81 | "ROM", |
---|
| 82 | "SIM", |
---|
| 83 | "TIM", |
---|
| 84 | "TTY", |
---|
| 85 | "XCU", |
---|
[295] | 86 | "PIC", |
---|
[258] | 87 | }; |
---|
| 88 | |
---|
[295] | 89 | const char * ioc_subtype[] = |
---|
[289] | 90 | { |
---|
| 91 | "BDV", |
---|
| 92 | "HBA", |
---|
| 93 | "SPI", |
---|
| 94 | }; |
---|
| 95 | |
---|
[258] | 96 | const char * port_direction[] = |
---|
| 97 | { |
---|
| 98 | "TO_COPROC", |
---|
| 99 | "FROM_COPROC", |
---|
| 100 | }; |
---|
| 101 | |
---|
| 102 | const char * mode_str[] = |
---|
| 103 | { |
---|
| 104 | "____", |
---|
| 105 | "___U", |
---|
| 106 | "__W_", |
---|
| 107 | "__WU", |
---|
| 108 | "_X__", |
---|
| 109 | "_X_U", |
---|
| 110 | "_XW_", |
---|
| 111 | "_XWU", |
---|
| 112 | "C___", |
---|
| 113 | "C__U", |
---|
| 114 | "C_W_", |
---|
| 115 | "C_WU", |
---|
| 116 | "CX__", |
---|
| 117 | "CX_U", |
---|
| 118 | "CXW_", |
---|
| 119 | "CXWU", |
---|
| 120 | }; |
---|
| 121 | |
---|
| 122 | unsigned int vspace_id; |
---|
| 123 | unsigned int cluster_id; |
---|
| 124 | unsigned int pseg_id; |
---|
| 125 | unsigned int vseg_id; |
---|
| 126 | unsigned int vobj_id; |
---|
| 127 | unsigned int task_id; |
---|
| 128 | unsigned int proc_id; |
---|
| 129 | unsigned int irq_id; |
---|
| 130 | unsigned int coproc_id; |
---|
| 131 | unsigned int port_id; |
---|
| 132 | unsigned int periph_id; |
---|
| 133 | |
---|
| 134 | mapping_cluster_t * cluster; |
---|
| 135 | mapping_pseg_t * pseg; |
---|
| 136 | mapping_vspace_t * vspace; |
---|
| 137 | mapping_vseg_t * vseg; |
---|
| 138 | mapping_vobj_t * vobj; |
---|
| 139 | mapping_task_t * task; |
---|
| 140 | mapping_proc_t * proc; |
---|
| 141 | mapping_irq_t * irq; |
---|
| 142 | mapping_coproc_t * coproc; |
---|
| 143 | mapping_cp_port_t * cp_port; |
---|
| 144 | mapping_periph_t * periph; |
---|
| 145 | |
---|
| 146 | // computes the base adresss for clusters array, |
---|
| 147 | cluster = (mapping_cluster_t *)((char *) header + |
---|
| 148 | MAPPING_HEADER_SIZE); |
---|
| 149 | |
---|
| 150 | // computes the base adresss for psegs array, |
---|
| 151 | pseg = (mapping_pseg_t *) ((char *) header + |
---|
| 152 | MAPPING_HEADER_SIZE + |
---|
[263] | 153 | MAPPING_CLUSTER_SIZE * header->x_size * header->y_size); |
---|
[258] | 154 | |
---|
| 155 | // computes the base adresss for vspaces array, |
---|
| 156 | vspace = (mapping_vspace_t *) ((char *) header + |
---|
| 157 | MAPPING_HEADER_SIZE + |
---|
[263] | 158 | MAPPING_CLUSTER_SIZE * header->x_size * header->y_size + |
---|
[258] | 159 | MAPPING_PSEG_SIZE * header->psegs); |
---|
| 160 | |
---|
| 161 | // computes the base adresss for vsegs array, |
---|
| 162 | vseg = (mapping_vseg_t *) ((char *) header + |
---|
| 163 | MAPPING_HEADER_SIZE + |
---|
[263] | 164 | MAPPING_CLUSTER_SIZE * header->x_size * header->y_size + |
---|
[258] | 165 | MAPPING_PSEG_SIZE * header->psegs + |
---|
| 166 | MAPPING_VSPACE_SIZE * header->vspaces); |
---|
| 167 | |
---|
| 168 | // computes the base adresss for vobjs array, |
---|
| 169 | vobj = (mapping_vobj_t *) ((char *) header + |
---|
| 170 | MAPPING_HEADER_SIZE + |
---|
[263] | 171 | MAPPING_CLUSTER_SIZE * header->x_size * header->y_size + |
---|
[258] | 172 | MAPPING_PSEG_SIZE * header->psegs + |
---|
| 173 | MAPPING_VSPACE_SIZE * header->vspaces + |
---|
| 174 | MAPPING_VSEG_SIZE * header->vsegs); |
---|
| 175 | |
---|
| 176 | // computes the base address for tasks array |
---|
| 177 | task = (mapping_task_t *) ((char *) header + |
---|
| 178 | MAPPING_HEADER_SIZE + |
---|
[263] | 179 | MAPPING_CLUSTER_SIZE * header->x_size * header->y_size + |
---|
[258] | 180 | MAPPING_PSEG_SIZE * header->psegs + |
---|
| 181 | MAPPING_VSPACE_SIZE * header->vspaces + |
---|
| 182 | MAPPING_VOBJ_SIZE * header->vobjs + |
---|
| 183 | MAPPING_VSEG_SIZE * header->vsegs); |
---|
| 184 | |
---|
| 185 | // computes the base address for procs array |
---|
| 186 | proc = (mapping_proc_t *) ((char *) header + |
---|
| 187 | MAPPING_HEADER_SIZE + |
---|
[263] | 188 | MAPPING_CLUSTER_SIZE * header->x_size * header->y_size + |
---|
[258] | 189 | MAPPING_PSEG_SIZE * header->psegs + |
---|
| 190 | MAPPING_VSPACE_SIZE * header->vspaces + |
---|
| 191 | MAPPING_VOBJ_SIZE * header->vobjs + |
---|
| 192 | MAPPING_VSEG_SIZE * header->vsegs + |
---|
| 193 | MAPPING_TASK_SIZE * header->tasks); |
---|
| 194 | |
---|
| 195 | // computes the base address for irqs array |
---|
| 196 | irq = (mapping_irq_t *) ((char *) header + |
---|
| 197 | MAPPING_HEADER_SIZE + |
---|
[263] | 198 | MAPPING_CLUSTER_SIZE * header->x_size * header->y_size + |
---|
[258] | 199 | MAPPING_PSEG_SIZE * header->psegs + |
---|
| 200 | MAPPING_VSPACE_SIZE * header->vspaces + |
---|
| 201 | MAPPING_VOBJ_SIZE * header->vobjs + |
---|
| 202 | MAPPING_VSEG_SIZE * header->vsegs + |
---|
| 203 | MAPPING_TASK_SIZE * header->tasks + |
---|
| 204 | MAPPING_PROC_SIZE * header->procs); |
---|
| 205 | |
---|
| 206 | // computes the base address for coprocs array |
---|
| 207 | coproc = (mapping_coproc_t *) ((char *) header + |
---|
| 208 | MAPPING_HEADER_SIZE + |
---|
[263] | 209 | MAPPING_CLUSTER_SIZE * header->x_size * header->y_size + |
---|
[258] | 210 | MAPPING_PSEG_SIZE * header->psegs + |
---|
| 211 | MAPPING_VSPACE_SIZE * header->vspaces + |
---|
| 212 | MAPPING_VOBJ_SIZE * header->vobjs + |
---|
| 213 | MAPPING_VSEG_SIZE * header->vsegs + |
---|
| 214 | MAPPING_TASK_SIZE * header->tasks + |
---|
| 215 | MAPPING_PROC_SIZE * header->procs + |
---|
| 216 | MAPPING_IRQ_SIZE * header->irqs); |
---|
| 217 | |
---|
| 218 | // computes the base address for cp_ports array |
---|
| 219 | cp_port = (mapping_cp_port_t *) ((char *) header + |
---|
| 220 | MAPPING_HEADER_SIZE + |
---|
[263] | 221 | MAPPING_CLUSTER_SIZE * header->x_size * header->y_size + |
---|
[258] | 222 | MAPPING_PSEG_SIZE * header->psegs + |
---|
| 223 | MAPPING_VSPACE_SIZE * header->vspaces + |
---|
| 224 | MAPPING_VOBJ_SIZE * header->vobjs + |
---|
| 225 | MAPPING_VSEG_SIZE * header->vsegs + |
---|
| 226 | MAPPING_TASK_SIZE * header->tasks + |
---|
| 227 | MAPPING_PROC_SIZE * header->procs + |
---|
| 228 | MAPPING_IRQ_SIZE * header->irqs + |
---|
| 229 | MAPPING_COPROC_SIZE * header->coprocs); |
---|
| 230 | |
---|
| 231 | // computes the base address for periphs array |
---|
| 232 | periph = (mapping_periph_t *) ((char *) header + |
---|
| 233 | MAPPING_HEADER_SIZE + |
---|
[263] | 234 | MAPPING_CLUSTER_SIZE * header->x_size * header->y_size + |
---|
[258] | 235 | MAPPING_PSEG_SIZE * header->psegs + |
---|
| 236 | MAPPING_VSPACE_SIZE * header->vspaces + |
---|
| 237 | MAPPING_VOBJ_SIZE * header->vobjs + |
---|
| 238 | MAPPING_VSEG_SIZE * header->vsegs + |
---|
| 239 | MAPPING_TASK_SIZE * header->tasks + |
---|
| 240 | MAPPING_PROC_SIZE * header->procs + |
---|
| 241 | MAPPING_IRQ_SIZE * header->irqs + |
---|
| 242 | MAPPING_COPROC_SIZE * header->coprocs + |
---|
| 243 | MAPPING_CP_PORT_SIZE * header->cp_ports); |
---|
| 244 | |
---|
| 245 | ///////////////////////// header ///////////////////////////////////////////// |
---|
| 246 | |
---|
| 247 | fprintf(fpout, "<?xml version = \"1.0\"?>\n\n"); |
---|
| 248 | |
---|
[287] | 249 | fprintf(fpout, "<mapping_info signature = \"0x%x\" \n" , header->signature); |
---|
| 250 | fprintf(fpout, " name = \"%s\" \n" , header->name); |
---|
| 251 | fprintf(fpout, " x_size = \"%d\" \n" , header->x_size); |
---|
| 252 | fprintf(fpout, " y_size = \"%d\" \n" , header->y_size); |
---|
| 253 | fprintf(fpout, " x_width = \"%d\" \n" , header->x_width); |
---|
| 254 | fprintf(fpout, " y_width = \"%d\" \n" , header->y_width); |
---|
[295] | 255 | fprintf(fpout, " irq_per_proc = \"%d\" \n" , header->irq_per_proc); |
---|
| 256 | fprintf(fpout, " use_ramdisk = \"%d\" \n" , header->use_ramdisk); |
---|
| 257 | fprintf(fpout, " x_io = \"%d\" \n" , header->x_io); |
---|
| 258 | fprintf(fpout, " y_io = \"%d\" >\n\n", header->y_io); |
---|
[258] | 259 | |
---|
| 260 | ///////////////////// clusters /////////////////////////////////////////////// |
---|
| 261 | |
---|
| 262 | fprintf( fpout, " <clusterset>\n"); |
---|
[263] | 263 | for (cluster_id = 0; cluster_id < (header->x_size * header->y_size); cluster_id++) |
---|
[258] | 264 | { |
---|
[263] | 265 | fprintf(fpout, " <cluster x = \"%d\" y = \"%d\" >\n", |
---|
| 266 | cluster[cluster_id].x, cluster[cluster_id].y ); |
---|
| 267 | |
---|
| 268 | ///////////////////// psegs //////////////////////////////////////////////// |
---|
| 269 | |
---|
[258] | 270 | for (pseg_id = cluster[cluster_id].pseg_offset; |
---|
| 271 | pseg_id < cluster[cluster_id].pseg_offset + cluster[cluster_id].psegs; |
---|
| 272 | pseg_id++) |
---|
| 273 | { |
---|
| 274 | fprintf(fpout, " <pseg name = \"%s\" ", pseg[pseg_id].name); |
---|
[263] | 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); |
---|
[258] | 278 | } |
---|
| 279 | |
---|
| 280 | ///////////////////// processors ///////////////////////////////////////////// |
---|
| 281 | |
---|
| 282 | unsigned int proc_index = 0; |
---|
| 283 | for (proc_id = cluster[cluster_id].proc_offset; |
---|
| 284 | proc_id < cluster[cluster_id].proc_offset + cluster[cluster_id].procs; |
---|
[295] | 285 | proc_id++, proc_index++) |
---|
[258] | 286 | { |
---|
[295] | 287 | fprintf(fpout, " <proc index = \"%d\" />\n", proc_index); |
---|
[258] | 288 | } |
---|
| 289 | |
---|
| 290 | ///////////////////// coprocessors /////////////////////////////////////////// |
---|
| 291 | |
---|
| 292 | for (coproc_id = cluster[cluster_id].coproc_offset; |
---|
| 293 | coproc_id < cluster[cluster_id].coproc_offset + cluster[cluster_id].coprocs; |
---|
| 294 | coproc_id++) |
---|
| 295 | { |
---|
| 296 | fprintf(fpout, " <coproc name = \"%s\" ", coproc[coproc_id].name); |
---|
| 297 | fprintf(fpout, " psegname = \"%s\" >\n", pseg[coproc[coproc_id].psegid].name); |
---|
| 298 | for (port_id = coproc[coproc_id].port_offset; |
---|
| 299 | port_id < coproc[coproc_id].port_offset + coproc[coproc_id].ports; |
---|
| 300 | port_id++) |
---|
| 301 | { |
---|
| 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); |
---|
| 306 | } |
---|
| 307 | fprintf(fpout, " </coproc>\n" ); |
---|
| 308 | } |
---|
| 309 | |
---|
| 310 | ///////////////////// periphs /////////////////////////////////////////////// |
---|
| 311 | |
---|
| 312 | for (periph_id = cluster[cluster_id].periph_offset; |
---|
| 313 | periph_id < cluster[cluster_id].periph_offset + cluster[cluster_id].periphs; |
---|
| 314 | periph_id++) |
---|
| 315 | { |
---|
| 316 | fprintf(fpout, " <periph type = \"%s\" ", periph_type[periph[periph_id].type]); |
---|
[289] | 317 | |
---|
| 318 | if (periph[periph_id].subtype < PERIPH_SUBTYPE_MAX_VALUE) |
---|
[295] | 319 | fprintf(fpout, " subtype = \"%s\" ", ioc_subtype[periph[periph_id].subtype]); |
---|
[289] | 320 | |
---|
[258] | 321 | fprintf(fpout, " psegname = \"%s\" ", pseg[periph[periph_id].psegid].name); |
---|
[295] | 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++) |
---|
| 326 | { |
---|
| 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); |
---|
| 334 | } |
---|
| 335 | fprintf(fpout, " </periph>\n"); |
---|
[258] | 336 | } |
---|
| 337 | fprintf(fpout, " </cluster>\n" ); |
---|
| 338 | } |
---|
| 339 | fprintf(fpout, " </clusterset>\n\n" ); |
---|
| 340 | |
---|
| 341 | /////////////////// globals ///////////////////////////////////////////////// |
---|
| 342 | |
---|
| 343 | fprintf(fpout, " <globalset>\n" ); |
---|
| 344 | for (vseg_id = 0; vseg_id < header->globals; vseg_id++) |
---|
| 345 | { |
---|
| 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]); |
---|
[263] | 351 | fprintf(fpout, "clusterid = \"%d\" ", pseg[pseg_id].clusterid); |
---|
[258] | 352 | fprintf(fpout, "psegname = \"%s\" ", pseg[pseg_id].name); |
---|
| 353 | fprintf(fpout, "ident = \"%d\" >\n", vseg[vseg_id].ident); |
---|
| 354 | for (vobj_id = vseg[vseg_id].vobj_offset; |
---|
| 355 | vobj_id < (vseg[vseg_id].vobj_offset + vseg[vseg_id].vobjs); |
---|
| 356 | vobj_id++) |
---|
| 357 | { |
---|
| 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); |
---|
| 364 | } |
---|
| 365 | fprintf(fpout, " </vseg>\n"); |
---|
| 366 | } |
---|
| 367 | fprintf(fpout, " </globalset>\n" ); |
---|
| 368 | |
---|
| 369 | //////////////////// vspaces //////////////////////////////////////////////// |
---|
| 370 | |
---|
| 371 | fprintf( fpout, "\n <vspaceset>\n\n" ); |
---|
| 372 | for (vspace_id = 0; vspace_id < header->vspaces; vspace_id++) |
---|
| 373 | { |
---|
| 374 | unsigned int func_id = vspace[vspace_id].vobj_offset + vspace[vspace_id].start_offset; |
---|
| 375 | fprintf(fpout, " <vspace name = \"%s\" ", vspace[vspace_id].name); |
---|
| 376 | fprintf(fpout, " startname = \"%s\" >\n", vobj[func_id].name); |
---|
| 377 | |
---|
[263] | 378 | //////////////////// vsegs ////////////////////////////////////////////// |
---|
| 379 | |
---|
[258] | 380 | for (vseg_id = vspace[vspace_id].vseg_offset; |
---|
| 381 | vseg_id < (vspace[vspace_id].vseg_offset + vspace[vspace_id].vsegs); |
---|
| 382 | vseg_id++) |
---|
| 383 | { |
---|
[263] | 384 | unsigned int pseg_id = vseg[vseg_id].psegid; |
---|
| 385 | 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); |
---|
[258] | 388 | |
---|
| 389 | fprintf(fpout, " <vseg name = \"%s\" ", vseg[vseg_id].name); |
---|
| 390 | fprintf(fpout, "vbase = \"0x%x\" ", vseg[vseg_id].vbase); |
---|
[263] | 391 | fprintf(fpout, "mode = \"%s\" ", mode_str[vseg[vseg_id].mode]); |
---|
| 392 | fprintf(fpout, "x = \"%d\" ", x); |
---|
| 393 | fprintf(fpout, "y = \"%d\" ", y); |
---|
[258] | 394 | fprintf(fpout, "psegname = \"%s\" ", pseg[pseg_id].name); |
---|
| 395 | fprintf(fpout, "ident = \"%d\" >\n", vseg[vseg_id].ident); |
---|
| 396 | |
---|
| 397 | for (vobj_id = vseg[vseg_id].vobj_offset; |
---|
| 398 | vobj_id < (vseg[vseg_id].vobj_offset + vseg[vseg_id].vobjs); |
---|
| 399 | vobj_id++) |
---|
| 400 | { |
---|
| 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); |
---|
| 407 | } |
---|
| 408 | fprintf(fpout, " </vseg>\n\n"); |
---|
| 409 | } |
---|
[263] | 410 | |
---|
| 411 | //////////////////// tasks ////////////////////////////////////////////// |
---|
| 412 | |
---|
[258] | 413 | for (task_id = vspace[vspace_id].task_offset; |
---|
| 414 | task_id < (vspace[vspace_id].task_offset + vspace[vspace_id].tasks); |
---|
| 415 | task_id++) |
---|
| 416 | { |
---|
| 417 | unsigned int stack_vobj_id = task[task_id].stack_vobjid + vspace[vspace_id].vobj_offset; |
---|
| 418 | unsigned int heap_vobj_id = task[task_id].heap_vobjid + vspace[vspace_id].vobj_offset; |
---|
[263] | 419 | 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); |
---|
[258] | 422 | |
---|
| 423 | fprintf(fpout, " <task name = \"%s\" ", task[task_id].name); |
---|
[263] | 424 | fprintf(fpout, "x = \"%d\" ", x); |
---|
| 425 | fprintf(fpout, "y = \"%d\" ", y); |
---|
[258] | 426 | fprintf(fpout, "proclocid = \"%d\" ", task[task_id].proclocid); |
---|
| 427 | fprintf(fpout, "stackname = \"%s\" ", vobj[stack_vobj_id].name); |
---|
| 428 | if (heap_vobj_id != -1) |
---|
| 429 | { |
---|
| 430 | fprintf(fpout, "heapname = \"%s\" ", vobj[heap_vobj_id].name); |
---|
| 431 | } |
---|
| 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); |
---|
| 438 | } |
---|
| 439 | fprintf(fpout, " </vspace>\n\n"); |
---|
| 440 | } |
---|
| 441 | fprintf(fpout, " </vspaceset>\n"); |
---|
| 442 | fprintf(fpout, "</mapping_info>\n"); |
---|
| 443 | } // end buildXml() |
---|
| 444 | |
---|
| 445 | |
---|
| 446 | ///////////////////////////////////// |
---|
| 447 | int main(int argc, char * argv[]) { |
---|
| 448 | if (argc < 2) { |
---|
| 449 | printf("Usage: bin2xml <input_file_path> <output_file_path>\n"); |
---|
| 450 | return 1; |
---|
| 451 | } |
---|
| 452 | |
---|
| 453 | unsigned int bin[0x10000]; // 64 K int = 256 Kbytes |
---|
| 454 | |
---|
| 455 | int fdin = open(argv[1], O_RDONLY); |
---|
| 456 | if (fdin < 0) { |
---|
| 457 | perror("open"); |
---|
| 458 | exit(1); |
---|
| 459 | } |
---|
| 460 | |
---|
| 461 | FILE * fpout = fopen( argv[2], "w"); |
---|
| 462 | if (fpout == NULL) { |
---|
| 463 | perror("open"); |
---|
| 464 | exit(1); |
---|
| 465 | } |
---|
| 466 | |
---|
| 467 | unsigned int length = read(fdin, bin, 0x40000); |
---|
| 468 | |
---|
| 469 | if (length <= 0) { |
---|
| 470 | perror("read"); |
---|
| 471 | exit(1); |
---|
| 472 | } |
---|
| 473 | |
---|
| 474 | if (bin[0] == IN_MAPPING_SIGNATURE) { |
---|
| 475 | buildXml((mapping_header_t *) bin, fpout); |
---|
| 476 | } |
---|
| 477 | else { |
---|
| 478 | printf("[ERROR] Wrong file format\n"); |
---|
| 479 | exit(1); |
---|
| 480 | } |
---|
| 481 | return 0; |
---|
| 482 | } // end main() |
---|
| 483 | |
---|
| 484 | |
---|
| 485 | |
---|
| 486 | // Local Variables: |
---|
| 487 | // tab-width: 4 |
---|
| 488 | // c-basic-offset: 4 |
---|
| 489 | // c-file-offsets:((innamespace . 0)(inline-open . 0)) |
---|
| 490 | // indent-tabs-mode: nil |
---|
| 491 | // End: |
---|
| 492 | // vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 |
---|
| 493 | |
---|