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