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