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