[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 | ////////////////////////////////////////////////////// |
---|
| 20 | void buildXml(mapping_header_t * header, FILE * fpout) { |
---|
| 21 | const char * vobj_type[] = |
---|
| 22 | { |
---|
| 23 | "ELF", // binary code generated by GCC |
---|
| 24 | "BLOB", // binary code generated by GCC |
---|
| 25 | "PTAB", // page table |
---|
| 26 | "PERI", // hardware component |
---|
| 27 | "MWMR", // MWMR channel |
---|
| 28 | "LOCK", // Spin-Lock |
---|
| 29 | "BUFFER", // Any "no intialiasation needed" objects (stacks...) |
---|
| 30 | "BARRIER", // Barrier |
---|
| 31 | "CONST", // Constant |
---|
| 32 | "MEMSPACE", // Memspace |
---|
| 33 | "SCHED", // Scheduler |
---|
| 34 | }; |
---|
| 35 | |
---|
| 36 | const char * pseg_type[] = |
---|
| 37 | { |
---|
| 38 | "RAM", |
---|
| 39 | "ROM", |
---|
| 40 | "PERI", |
---|
| 41 | }; |
---|
| 42 | |
---|
| 43 | const char * irq_type[] = |
---|
| 44 | { |
---|
| 45 | "HARD", |
---|
| 46 | "SOFT", |
---|
[287] | 47 | "TIME", |
---|
[258] | 48 | }; |
---|
| 49 | |
---|
| 50 | const char * isr_type[] = |
---|
| 51 | { |
---|
| 52 | "ISR_DEFAULT", |
---|
| 53 | "ISR_SWITCH", |
---|
| 54 | "ISR_TTY", |
---|
| 55 | "ISR_DMA", |
---|
| 56 | "ISR_IOC", |
---|
| 57 | "ISR_TIMER", |
---|
| 58 | }; |
---|
| 59 | |
---|
| 60 | const char * periph_type[] = |
---|
| 61 | { |
---|
| 62 | "CMA", |
---|
| 63 | "DMA", |
---|
| 64 | "FBF", |
---|
| 65 | "HBA", |
---|
| 66 | "ICU", |
---|
| 67 | "IOB", |
---|
| 68 | "IOC", |
---|
| 69 | "MMC", |
---|
| 70 | "MWR", |
---|
| 71 | "NIC", |
---|
| 72 | "ROM", |
---|
| 73 | "SIM", |
---|
| 74 | "TIM", |
---|
| 75 | "TTY", |
---|
| 76 | "XCU", |
---|
| 77 | }; |
---|
| 78 | |
---|
| 79 | const char * port_direction[] = |
---|
| 80 | { |
---|
| 81 | "TO_COPROC", |
---|
| 82 | "FROM_COPROC", |
---|
| 83 | }; |
---|
| 84 | |
---|
| 85 | const char * mode_str[] = |
---|
| 86 | { |
---|
| 87 | "____", |
---|
| 88 | "___U", |
---|
| 89 | "__W_", |
---|
| 90 | "__WU", |
---|
| 91 | "_X__", |
---|
| 92 | "_X_U", |
---|
| 93 | "_XW_", |
---|
| 94 | "_XWU", |
---|
| 95 | "C___", |
---|
| 96 | "C__U", |
---|
| 97 | "C_W_", |
---|
| 98 | "C_WU", |
---|
| 99 | "CX__", |
---|
| 100 | "CX_U", |
---|
| 101 | "CXW_", |
---|
| 102 | "CXWU", |
---|
| 103 | }; |
---|
| 104 | |
---|
| 105 | unsigned int vspace_id; |
---|
| 106 | unsigned int cluster_id; |
---|
| 107 | unsigned int pseg_id; |
---|
| 108 | unsigned int vseg_id; |
---|
| 109 | unsigned int vobj_id; |
---|
| 110 | unsigned int task_id; |
---|
| 111 | unsigned int proc_id; |
---|
| 112 | unsigned int irq_id; |
---|
| 113 | unsigned int coproc_id; |
---|
| 114 | unsigned int port_id; |
---|
| 115 | unsigned int periph_id; |
---|
| 116 | |
---|
| 117 | mapping_cluster_t * cluster; |
---|
| 118 | mapping_pseg_t * pseg; |
---|
| 119 | mapping_vspace_t * vspace; |
---|
| 120 | mapping_vseg_t * vseg; |
---|
| 121 | mapping_vobj_t * vobj; |
---|
| 122 | mapping_task_t * task; |
---|
| 123 | mapping_proc_t * proc; |
---|
| 124 | mapping_irq_t * irq; |
---|
| 125 | mapping_coproc_t * coproc; |
---|
| 126 | mapping_cp_port_t * cp_port; |
---|
| 127 | mapping_periph_t * periph; |
---|
| 128 | |
---|
| 129 | // computes the base adresss for clusters array, |
---|
| 130 | cluster = (mapping_cluster_t *)((char *) header + |
---|
| 131 | MAPPING_HEADER_SIZE); |
---|
| 132 | |
---|
| 133 | // computes the base adresss for psegs array, |
---|
| 134 | pseg = (mapping_pseg_t *) ((char *) header + |
---|
| 135 | MAPPING_HEADER_SIZE + |
---|
[263] | 136 | MAPPING_CLUSTER_SIZE * header->x_size * header->y_size); |
---|
[258] | 137 | |
---|
| 138 | // computes the base adresss for vspaces array, |
---|
| 139 | vspace = (mapping_vspace_t *) ((char *) header + |
---|
| 140 | MAPPING_HEADER_SIZE + |
---|
[263] | 141 | MAPPING_CLUSTER_SIZE * header->x_size * header->y_size + |
---|
[258] | 142 | MAPPING_PSEG_SIZE * header->psegs); |
---|
| 143 | |
---|
| 144 | // computes the base adresss for vsegs array, |
---|
| 145 | vseg = (mapping_vseg_t *) ((char *) header + |
---|
| 146 | MAPPING_HEADER_SIZE + |
---|
[263] | 147 | MAPPING_CLUSTER_SIZE * header->x_size * header->y_size + |
---|
[258] | 148 | MAPPING_PSEG_SIZE * header->psegs + |
---|
| 149 | MAPPING_VSPACE_SIZE * header->vspaces); |
---|
| 150 | |
---|
| 151 | // computes the base adresss for vobjs array, |
---|
| 152 | vobj = (mapping_vobj_t *) ((char *) header + |
---|
| 153 | MAPPING_HEADER_SIZE + |
---|
[263] | 154 | MAPPING_CLUSTER_SIZE * header->x_size * header->y_size + |
---|
[258] | 155 | MAPPING_PSEG_SIZE * header->psegs + |
---|
| 156 | MAPPING_VSPACE_SIZE * header->vspaces + |
---|
| 157 | MAPPING_VSEG_SIZE * header->vsegs); |
---|
| 158 | |
---|
| 159 | // computes the base address for tasks array |
---|
| 160 | task = (mapping_task_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 | MAPPING_VSPACE_SIZE * header->vspaces + |
---|
| 165 | MAPPING_VOBJ_SIZE * header->vobjs + |
---|
| 166 | MAPPING_VSEG_SIZE * header->vsegs); |
---|
| 167 | |
---|
| 168 | // computes the base address for procs array |
---|
| 169 | proc = (mapping_proc_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_VOBJ_SIZE * header->vobjs + |
---|
| 175 | MAPPING_VSEG_SIZE * header->vsegs + |
---|
| 176 | MAPPING_TASK_SIZE * header->tasks); |
---|
| 177 | |
---|
| 178 | // computes the base address for irqs array |
---|
| 179 | irq = (mapping_irq_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_VOBJ_SIZE * header->vobjs + |
---|
| 185 | MAPPING_VSEG_SIZE * header->vsegs + |
---|
| 186 | MAPPING_TASK_SIZE * header->tasks + |
---|
| 187 | MAPPING_PROC_SIZE * header->procs); |
---|
| 188 | |
---|
| 189 | // computes the base address for coprocs array |
---|
| 190 | coproc = (mapping_coproc_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 | MAPPING_PROC_SIZE * header->procs + |
---|
| 199 | MAPPING_IRQ_SIZE * header->irqs); |
---|
| 200 | |
---|
| 201 | // computes the base address for cp_ports array |
---|
| 202 | cp_port = (mapping_cp_port_t *) ((char *) header + |
---|
| 203 | MAPPING_HEADER_SIZE + |
---|
[263] | 204 | MAPPING_CLUSTER_SIZE * header->x_size * header->y_size + |
---|
[258] | 205 | MAPPING_PSEG_SIZE * header->psegs + |
---|
| 206 | MAPPING_VSPACE_SIZE * header->vspaces + |
---|
| 207 | MAPPING_VOBJ_SIZE * header->vobjs + |
---|
| 208 | MAPPING_VSEG_SIZE * header->vsegs + |
---|
| 209 | MAPPING_TASK_SIZE * header->tasks + |
---|
| 210 | MAPPING_PROC_SIZE * header->procs + |
---|
| 211 | MAPPING_IRQ_SIZE * header->irqs + |
---|
| 212 | MAPPING_COPROC_SIZE * header->coprocs); |
---|
| 213 | |
---|
| 214 | // computes the base address for periphs array |
---|
| 215 | periph = (mapping_periph_t *) ((char *) header + |
---|
| 216 | MAPPING_HEADER_SIZE + |
---|
[263] | 217 | MAPPING_CLUSTER_SIZE * header->x_size * header->y_size + |
---|
[258] | 218 | MAPPING_PSEG_SIZE * header->psegs + |
---|
| 219 | MAPPING_VSPACE_SIZE * header->vspaces + |
---|
| 220 | MAPPING_VOBJ_SIZE * header->vobjs + |
---|
| 221 | MAPPING_VSEG_SIZE * header->vsegs + |
---|
| 222 | MAPPING_TASK_SIZE * header->tasks + |
---|
| 223 | MAPPING_PROC_SIZE * header->procs + |
---|
| 224 | MAPPING_IRQ_SIZE * header->irqs + |
---|
| 225 | MAPPING_COPROC_SIZE * header->coprocs + |
---|
| 226 | MAPPING_CP_PORT_SIZE * header->cp_ports); |
---|
| 227 | |
---|
| 228 | ///////////////////////// header ///////////////////////////////////////////// |
---|
| 229 | |
---|
| 230 | fprintf(fpout, "<?xml version = \"1.0\"?>\n\n"); |
---|
| 231 | |
---|
[287] | 232 | fprintf(fpout, "<mapping_info signature = \"0x%x\" \n" , header->signature); |
---|
| 233 | fprintf(fpout, " name = \"%s\" \n" , header->name); |
---|
| 234 | fprintf(fpout, " x_size = \"%d\" \n" , header->x_size); |
---|
| 235 | fprintf(fpout, " y_size = \"%d\" \n" , header->y_size); |
---|
| 236 | fprintf(fpout, " x_width = \"%d\" \n" , header->x_width); |
---|
| 237 | fprintf(fpout, " y_width = \"%d\" \n" , header->y_width); |
---|
| 238 | fprintf(fpout, " vspaces = \"%d\" \n" , header->vspaces); |
---|
| 239 | fprintf(fpout, " increment = \"%d\" \n" , header->vspaces); |
---|
| 240 | fprintf(fpout, " irq_per_proc = \"%d\" >\n\n", header->irq_per_proc); |
---|
[258] | 241 | |
---|
| 242 | ///////////////////// clusters /////////////////////////////////////////////// |
---|
| 243 | |
---|
| 244 | fprintf( fpout, " <clusterset>\n"); |
---|
[263] | 245 | for (cluster_id = 0; cluster_id < (header->x_size * header->y_size); cluster_id++) |
---|
[258] | 246 | { |
---|
[263] | 247 | fprintf(fpout, " <cluster x = \"%d\" y = \"%d\" >\n", |
---|
| 248 | cluster[cluster_id].x, cluster[cluster_id].y ); |
---|
| 249 | |
---|
| 250 | ///////////////////// psegs //////////////////////////////////////////////// |
---|
| 251 | |
---|
[258] | 252 | for (pseg_id = cluster[cluster_id].pseg_offset; |
---|
| 253 | pseg_id < cluster[cluster_id].pseg_offset + cluster[cluster_id].psegs; |
---|
| 254 | pseg_id++) |
---|
| 255 | { |
---|
| 256 | fprintf(fpout, " <pseg name = \"%s\" ", pseg[pseg_id].name); |
---|
[263] | 257 | fprintf(fpout, "type = \"%s\" ", pseg_type[pseg[pseg_id].type]); |
---|
| 258 | fprintf(fpout, "base = \"0x%llx\" ", pseg[pseg_id].base); |
---|
| 259 | fprintf(fpout, "length = \"0x%llx\" />\n", pseg[pseg_id].length); |
---|
[258] | 260 | } |
---|
| 261 | |
---|
| 262 | ///////////////////// processors ///////////////////////////////////////////// |
---|
| 263 | |
---|
| 264 | unsigned int proc_index = 0; |
---|
| 265 | for (proc_id = cluster[cluster_id].proc_offset; |
---|
| 266 | proc_id < cluster[cluster_id].proc_offset + cluster[cluster_id].procs; |
---|
| 267 | proc_id++) |
---|
| 268 | { |
---|
| 269 | fprintf(fpout, " <proc index = \"%d\" >\n", proc_index); |
---|
| 270 | for (irq_id = proc[proc_id].irq_offset; |
---|
| 271 | irq_id < proc[proc_id].irq_offset + proc[proc_id].irqs; |
---|
| 272 | irq_id++) |
---|
| 273 | { |
---|
| 274 | fprintf(fpout, " <irq type = \"%s\" ", irq_type[irq[irq_id].type]); |
---|
| 275 | fprintf(fpout, " icuid = \"0x%x\" ", irq[irq_id].icuid); |
---|
| 276 | fprintf(fpout, " isr = \"%s\" ", isr_type[irq[irq_id].isr]); |
---|
| 277 | fprintf(fpout, " channel = \"0x%x\" />\n", irq[irq_id].channel); |
---|
| 278 | } |
---|
| 279 | fprintf(fpout, " </proc>\n" ); |
---|
| 280 | } |
---|
| 281 | |
---|
| 282 | |
---|
| 283 | ///////////////////// coprocessors /////////////////////////////////////////// |
---|
| 284 | |
---|
| 285 | for (coproc_id = cluster[cluster_id].coproc_offset; |
---|
| 286 | coproc_id < cluster[cluster_id].coproc_offset + cluster[cluster_id].coprocs; |
---|
| 287 | coproc_id++) |
---|
| 288 | { |
---|
| 289 | fprintf(fpout, " <coproc name = \"%s\" ", coproc[coproc_id].name); |
---|
| 290 | fprintf(fpout, " psegname = \"%s\" >\n", pseg[coproc[coproc_id].psegid].name); |
---|
| 291 | for (port_id = coproc[coproc_id].port_offset; |
---|
| 292 | port_id < coproc[coproc_id].port_offset + coproc[coproc_id].ports; |
---|
| 293 | port_id++) |
---|
| 294 | { |
---|
| 295 | unsigned int vobj_id = cp_port[port_id].mwmr_vobjid + vspace[cp_port[port_id].vspaceid].vobj_offset; |
---|
| 296 | fprintf(fpout, " <port direction = \"%s\" ", port_direction[cp_port[port_id].direction]); |
---|
| 297 | fprintf(fpout, " vspacename = \"%s\" ", vspace[cp_port[port_id].vspaceid].name); |
---|
| 298 | fprintf(fpout, " vobjname = \"%s\" />\n", vobj[vobj_id].name); |
---|
| 299 | } |
---|
| 300 | fprintf(fpout, " </coproc>\n" ); |
---|
| 301 | } |
---|
| 302 | |
---|
| 303 | ///////////////////// periphs /////////////////////////////////////////////// |
---|
| 304 | |
---|
| 305 | for (periph_id = cluster[cluster_id].periph_offset; |
---|
| 306 | periph_id < cluster[cluster_id].periph_offset + cluster[cluster_id].periphs; |
---|
| 307 | periph_id++) |
---|
| 308 | { |
---|
| 309 | fprintf(fpout, " <periph type = \"%s\" ", periph_type[periph[periph_id].type]); |
---|
| 310 | fprintf(fpout, " psegname = \"%s\" ", pseg[periph[periph_id].psegid].name); |
---|
| 311 | fprintf(fpout, " channels = \"%d\" />\n", periph[periph_id].channels); |
---|
| 312 | } |
---|
| 313 | fprintf(fpout, " </cluster>\n" ); |
---|
| 314 | } |
---|
| 315 | fprintf(fpout, " </clusterset>\n\n" ); |
---|
| 316 | |
---|
| 317 | /////////////////// globals ///////////////////////////////////////////////// |
---|
| 318 | |
---|
| 319 | fprintf(fpout, " <globalset>\n" ); |
---|
| 320 | for (vseg_id = 0; vseg_id < header->globals; vseg_id++) |
---|
| 321 | { |
---|
| 322 | unsigned int pseg_id = vseg[vseg_id].psegid; |
---|
| 323 | |
---|
| 324 | fprintf(fpout, " <vseg name = \"%s\" ", vseg[vseg_id].name); |
---|
| 325 | fprintf(fpout, "vbase = \"0x%x\" ", vseg[vseg_id].vbase); |
---|
| 326 | fprintf(fpout, "mode = \"%s\" ", mode_str[vseg[vseg_id].mode]); |
---|
[263] | 327 | fprintf(fpout, "clusterid = \"%d\" ", pseg[pseg_id].clusterid); |
---|
[258] | 328 | fprintf(fpout, "psegname = \"%s\" ", pseg[pseg_id].name); |
---|
| 329 | fprintf(fpout, "ident = \"%d\" >\n", vseg[vseg_id].ident); |
---|
| 330 | for (vobj_id = vseg[vseg_id].vobj_offset; |
---|
| 331 | vobj_id < (vseg[vseg_id].vobj_offset + vseg[vseg_id].vobjs); |
---|
| 332 | vobj_id++) |
---|
| 333 | { |
---|
| 334 | fprintf(fpout, " <vobj name = \"%s\" ", vobj[vobj_id].name); |
---|
| 335 | fprintf(fpout, "type = \"%s\" ", vobj_type[vobj[vobj_id].type]); |
---|
| 336 | fprintf(fpout, "length = \"0x%x\" ", vobj[vobj_id].length); |
---|
| 337 | fprintf(fpout, "align = \"%d\" ", vobj[vobj_id].align); |
---|
| 338 | fprintf(fpout, "init = \"%d\" ", vobj[vobj_id].init); |
---|
| 339 | fprintf(fpout, "binpath = \"%s\" />\n", vobj[vobj_id].binpath); |
---|
| 340 | } |
---|
| 341 | fprintf(fpout, " </vseg>\n"); |
---|
| 342 | } |
---|
| 343 | fprintf(fpout, " </globalset>\n" ); |
---|
| 344 | |
---|
| 345 | //////////////////// vspaces //////////////////////////////////////////////// |
---|
| 346 | |
---|
| 347 | fprintf( fpout, "\n <vspaceset>\n\n" ); |
---|
| 348 | for (vspace_id = 0; vspace_id < header->vspaces; vspace_id++) |
---|
| 349 | { |
---|
| 350 | unsigned int func_id = vspace[vspace_id].vobj_offset + vspace[vspace_id].start_offset; |
---|
| 351 | fprintf(fpout, " <vspace name = \"%s\" ", vspace[vspace_id].name); |
---|
| 352 | fprintf(fpout, " startname = \"%s\" >\n", vobj[func_id].name); |
---|
| 353 | |
---|
[263] | 354 | //////////////////// vsegs ////////////////////////////////////////////// |
---|
| 355 | |
---|
[258] | 356 | for (vseg_id = vspace[vspace_id].vseg_offset; |
---|
| 357 | vseg_id < (vspace[vspace_id].vseg_offset + vspace[vspace_id].vsegs); |
---|
| 358 | vseg_id++) |
---|
| 359 | { |
---|
[263] | 360 | unsigned int pseg_id = vseg[vseg_id].psegid; |
---|
| 361 | unsigned int cluster_id = pseg[pseg_id].clusterid; |
---|
| 362 | unsigned int x = cluster_id >> header->y_width; |
---|
| 363 | unsigned int y = cluster_id & ((1<<header->y_width)-1); |
---|
[258] | 364 | |
---|
| 365 | fprintf(fpout, " <vseg name = \"%s\" ", vseg[vseg_id].name); |
---|
| 366 | fprintf(fpout, "vbase = \"0x%x\" ", vseg[vseg_id].vbase); |
---|
[263] | 367 | fprintf(fpout, "mode = \"%s\" ", mode_str[vseg[vseg_id].mode]); |
---|
| 368 | fprintf(fpout, "x = \"%d\" ", x); |
---|
| 369 | fprintf(fpout, "y = \"%d\" ", y); |
---|
[258] | 370 | fprintf(fpout, "psegname = \"%s\" ", pseg[pseg_id].name); |
---|
| 371 | fprintf(fpout, "ident = \"%d\" >\n", vseg[vseg_id].ident); |
---|
| 372 | |
---|
| 373 | for (vobj_id = vseg[vseg_id].vobj_offset; |
---|
| 374 | vobj_id < (vseg[vseg_id].vobj_offset + vseg[vseg_id].vobjs); |
---|
| 375 | vobj_id++) |
---|
| 376 | { |
---|
| 377 | fprintf(fpout, " <vobj name = \"%s\" ", vobj[vobj_id].name); |
---|
| 378 | fprintf(fpout, "type = \"%s\" ", vobj_type[vobj[vobj_id].type]); |
---|
| 379 | fprintf(fpout, "length = \"0x%x\" ", vobj[vobj_id].length); |
---|
| 380 | fprintf(fpout, "align = \"%d\" ", vobj[vobj_id].align); |
---|
| 381 | fprintf(fpout, "init = \"%d\" ", vobj[vobj_id].init); |
---|
| 382 | fprintf(fpout, "binpath = \"%s\" />\n", vobj[vobj_id].binpath); |
---|
| 383 | } |
---|
| 384 | fprintf(fpout, " </vseg>\n\n"); |
---|
| 385 | } |
---|
[263] | 386 | |
---|
| 387 | //////////////////// tasks ////////////////////////////////////////////// |
---|
| 388 | |
---|
[258] | 389 | for (task_id = vspace[vspace_id].task_offset; |
---|
| 390 | task_id < (vspace[vspace_id].task_offset + vspace[vspace_id].tasks); |
---|
| 391 | task_id++) |
---|
| 392 | { |
---|
| 393 | unsigned int stack_vobj_id = task[task_id].stack_vobjid + vspace[vspace_id].vobj_offset; |
---|
| 394 | unsigned int heap_vobj_id = task[task_id].heap_vobjid + vspace[vspace_id].vobj_offset; |
---|
[263] | 395 | unsigned int cluster_id = task[task_id].clusterid; |
---|
| 396 | unsigned int x = cluster_id >> header->y_width; |
---|
| 397 | unsigned int y = cluster_id & ((1<<header->y_width)-1); |
---|
[258] | 398 | |
---|
| 399 | fprintf(fpout, " <task name = \"%s\" ", task[task_id].name); |
---|
[263] | 400 | fprintf(fpout, "x = \"%d\" ", x); |
---|
| 401 | fprintf(fpout, "y = \"%d\" ", y); |
---|
[258] | 402 | fprintf(fpout, "proclocid = \"%d\" ", task[task_id].proclocid); |
---|
| 403 | fprintf(fpout, "stackname = \"%s\" ", vobj[stack_vobj_id].name); |
---|
| 404 | if (heap_vobj_id != -1) |
---|
| 405 | { |
---|
| 406 | fprintf(fpout, "heapname = \"%s\" ", vobj[heap_vobj_id].name); |
---|
| 407 | } |
---|
| 408 | fprintf(fpout, "startid = \"%d\" ", task[task_id].startid); |
---|
| 409 | fprintf(fpout, "usetty = \"%d\" ", task[task_id].use_tty); |
---|
| 410 | fprintf(fpout, "usenic = \"%d\" ", task[task_id].use_nic); |
---|
| 411 | fprintf(fpout, "usecma = \"%d\" ", task[task_id].use_cma); |
---|
| 412 | fprintf(fpout, "usetim = \"%d\" ", task[task_id].use_tim); |
---|
| 413 | fprintf(fpout, "usehba = \"%d\" />\n", task[task_id].use_hba); |
---|
| 414 | } |
---|
| 415 | fprintf(fpout, " </vspace>\n\n"); |
---|
| 416 | } |
---|
| 417 | fprintf(fpout, " </vspaceset>\n"); |
---|
| 418 | fprintf(fpout, "</mapping_info>\n"); |
---|
| 419 | } // end buildXml() |
---|
| 420 | |
---|
| 421 | |
---|
| 422 | ///////////////////////////////////// |
---|
| 423 | int main(int argc, char * argv[]) { |
---|
| 424 | if (argc < 2) { |
---|
| 425 | printf("Usage: bin2xml <input_file_path> <output_file_path>\n"); |
---|
| 426 | return 1; |
---|
| 427 | } |
---|
| 428 | |
---|
| 429 | unsigned int bin[0x10000]; // 64 K int = 256 Kbytes |
---|
| 430 | |
---|
| 431 | int fdin = open(argv[1], O_RDONLY); |
---|
| 432 | if (fdin < 0) { |
---|
| 433 | perror("open"); |
---|
| 434 | exit(1); |
---|
| 435 | } |
---|
| 436 | |
---|
| 437 | FILE * fpout = fopen( argv[2], "w"); |
---|
| 438 | if (fpout == NULL) { |
---|
| 439 | perror("open"); |
---|
| 440 | exit(1); |
---|
| 441 | } |
---|
| 442 | |
---|
| 443 | unsigned int length = read(fdin, bin, 0x40000); |
---|
| 444 | |
---|
| 445 | if (length <= 0) { |
---|
| 446 | perror("read"); |
---|
| 447 | exit(1); |
---|
| 448 | } |
---|
| 449 | |
---|
| 450 | if (bin[0] == IN_MAPPING_SIGNATURE) { |
---|
| 451 | buildXml((mapping_header_t *) bin, fpout); |
---|
| 452 | } |
---|
| 453 | else { |
---|
| 454 | printf("[ERROR] Wrong file format\n"); |
---|
| 455 | exit(1); |
---|
| 456 | } |
---|
| 457 | return 0; |
---|
| 458 | } // end main() |
---|
| 459 | |
---|
| 460 | |
---|
| 461 | |
---|
| 462 | // Local Variables: |
---|
| 463 | // tab-width: 4 |
---|
| 464 | // c-basic-offset: 4 |
---|
| 465 | // c-file-offsets:((innamespace . 0)(inline-open . 0)) |
---|
| 466 | // indent-tabs-mode: nil |
---|
| 467 | // End: |
---|
| 468 | // vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 |
---|
| 469 | |
---|