[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 |
---|
[511] | 23 | const char * vseg_type[] = |
---|
[258] | 24 | { |
---|
[548] | 25 | "ELF", // From a .elf file |
---|
| 26 | "BLOB", // Raw Binary |
---|
| 27 | "PTAB", // Page Table |
---|
| 28 | "PERI", // Hardware Component |
---|
| 29 | "BUFFER", // No intialisation needed (stacks...) |
---|
[258] | 30 | "SCHED", // Scheduler |
---|
[472] | 31 | "HEAP", // Heap |
---|
[258] | 32 | }; |
---|
| 33 | |
---|
[295] | 34 | // mnemonics defined in mapping_info.h |
---|
[258] | 35 | const char * pseg_type[] = |
---|
| 36 | { |
---|
| 37 | "RAM", |
---|
| 38 | "PERI", |
---|
| 39 | }; |
---|
| 40 | |
---|
[295] | 41 | // mnemonics defined in mapping_info.h |
---|
[258] | 42 | const char * irq_type[] = |
---|
| 43 | { |
---|
[295] | 44 | "HWI", |
---|
| 45 | "WTI", |
---|
| 46 | "PTI", |
---|
[258] | 47 | }; |
---|
| 48 | |
---|
[522] | 49 | // These mnemonics must be consistent with values in |
---|
| 50 | // irq_handler.h / irq_handler.c / mapping.py |
---|
[258] | 51 | const char * isr_type[] = |
---|
| 52 | { |
---|
[295] | 53 | "ISR_DEFAULT", |
---|
| 54 | "ISR_TICK", |
---|
| 55 | "ISR_TTY_RX", |
---|
| 56 | "ISR_TTY_TX", |
---|
| 57 | "ISR_BDV", |
---|
[258] | 58 | "ISR_TIMER", |
---|
[295] | 59 | "ISR_WAKUP", |
---|
| 60 | "ISR_NIC_RX", |
---|
| 61 | "ISR_NIC_TX", |
---|
| 62 | "ISR_CMA", |
---|
[323] | 63 | "ISR_MMC", |
---|
| 64 | "ISR_DMA", |
---|
[548] | 65 | "ISR_SDC", |
---|
[522] | 66 | "ISR_MWR", |
---|
[531] | 67 | "ISR_HBA", |
---|
[258] | 68 | }; |
---|
| 69 | |
---|
[522] | 70 | const char * mwr_subtype[] = |
---|
| 71 | { |
---|
| 72 | "GCD", |
---|
| 73 | "DCT", |
---|
[559] | 74 | "CPY", |
---|
[522] | 75 | }; |
---|
| 76 | |
---|
[258] | 77 | const char * periph_type[] = |
---|
| 78 | { |
---|
| 79 | "CMA", |
---|
| 80 | "DMA", |
---|
| 81 | "FBF", |
---|
| 82 | "IOB", |
---|
| 83 | "IOC", |
---|
| 84 | "MMC", |
---|
| 85 | "MWR", |
---|
| 86 | "NIC", |
---|
| 87 | "ROM", |
---|
| 88 | "SIM", |
---|
| 89 | "TIM", |
---|
| 90 | "TTY", |
---|
| 91 | "XCU", |
---|
[295] | 92 | "PIC", |
---|
[491] | 93 | "DROM", |
---|
[258] | 94 | }; |
---|
| 95 | |
---|
[295] | 96 | const char * ioc_subtype[] = |
---|
[289] | 97 | { |
---|
| 98 | "BDV", |
---|
| 99 | "HBA", |
---|
[548] | 100 | "SDC", |
---|
[567] | 101 | "SPI", |
---|
[289] | 102 | }; |
---|
| 103 | |
---|
[258] | 104 | const char * mode_str[] = |
---|
| 105 | { |
---|
| 106 | "____", |
---|
| 107 | "___U", |
---|
| 108 | "__W_", |
---|
| 109 | "__WU", |
---|
| 110 | "_X__", |
---|
| 111 | "_X_U", |
---|
| 112 | "_XW_", |
---|
| 113 | "_XWU", |
---|
| 114 | "C___", |
---|
| 115 | "C__U", |
---|
| 116 | "C_W_", |
---|
| 117 | "C_WU", |
---|
| 118 | "CX__", |
---|
| 119 | "CX_U", |
---|
| 120 | "CXW_", |
---|
| 121 | "CXWU", |
---|
| 122 | }; |
---|
| 123 | |
---|
| 124 | unsigned int vspace_id; |
---|
| 125 | unsigned int cluster_id; |
---|
| 126 | unsigned int pseg_id; |
---|
| 127 | unsigned int vseg_id; |
---|
| 128 | unsigned int task_id; |
---|
| 129 | unsigned int proc_id; |
---|
| 130 | unsigned int irq_id; |
---|
| 131 | unsigned int periph_id; |
---|
| 132 | |
---|
| 133 | mapping_cluster_t * cluster; |
---|
| 134 | mapping_pseg_t * pseg; |
---|
| 135 | mapping_vspace_t * vspace; |
---|
| 136 | mapping_vseg_t * vseg; |
---|
| 137 | mapping_task_t * task; |
---|
| 138 | mapping_proc_t * proc; |
---|
| 139 | mapping_irq_t * irq; |
---|
| 140 | mapping_periph_t * periph; |
---|
| 141 | |
---|
| 142 | // computes the base adresss for clusters array, |
---|
| 143 | cluster = (mapping_cluster_t *)((char *) header + |
---|
| 144 | MAPPING_HEADER_SIZE); |
---|
| 145 | |
---|
| 146 | // computes the base adresss for psegs array, |
---|
| 147 | pseg = (mapping_pseg_t *) ((char *) header + |
---|
| 148 | MAPPING_HEADER_SIZE + |
---|
[263] | 149 | MAPPING_CLUSTER_SIZE * header->x_size * header->y_size); |
---|
[258] | 150 | |
---|
| 151 | // computes the base adresss for vspaces array, |
---|
| 152 | vspace = (mapping_vspace_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 | |
---|
| 157 | // computes the base adresss for vsegs array, |
---|
| 158 | vseg = (mapping_vseg_t *) ((char *) header + |
---|
| 159 | MAPPING_HEADER_SIZE + |
---|
[263] | 160 | MAPPING_CLUSTER_SIZE * header->x_size * header->y_size + |
---|
[258] | 161 | MAPPING_PSEG_SIZE * header->psegs + |
---|
| 162 | MAPPING_VSPACE_SIZE * header->vspaces); |
---|
| 163 | |
---|
| 164 | // computes the base address for tasks array |
---|
| 165 | task = (mapping_task_t *) ((char *) header + |
---|
| 166 | MAPPING_HEADER_SIZE + |
---|
[263] | 167 | MAPPING_CLUSTER_SIZE * header->x_size * header->y_size + |
---|
[258] | 168 | MAPPING_PSEG_SIZE * header->psegs + |
---|
| 169 | MAPPING_VSPACE_SIZE * header->vspaces + |
---|
| 170 | MAPPING_VSEG_SIZE * header->vsegs); |
---|
| 171 | |
---|
| 172 | // computes the base address for procs array |
---|
| 173 | proc = (mapping_proc_t *) ((char *) header + |
---|
| 174 | MAPPING_HEADER_SIZE + |
---|
[263] | 175 | MAPPING_CLUSTER_SIZE * header->x_size * header->y_size + |
---|
[258] | 176 | MAPPING_PSEG_SIZE * header->psegs + |
---|
| 177 | MAPPING_VSPACE_SIZE * header->vspaces + |
---|
| 178 | MAPPING_VSEG_SIZE * header->vsegs + |
---|
| 179 | MAPPING_TASK_SIZE * header->tasks); |
---|
| 180 | |
---|
| 181 | // computes the base address for irqs array |
---|
| 182 | irq = (mapping_irq_t *) ((char *) header + |
---|
| 183 | MAPPING_HEADER_SIZE + |
---|
[263] | 184 | MAPPING_CLUSTER_SIZE * header->x_size * header->y_size + |
---|
[258] | 185 | MAPPING_PSEG_SIZE * header->psegs + |
---|
| 186 | MAPPING_VSPACE_SIZE * header->vspaces + |
---|
| 187 | MAPPING_VSEG_SIZE * header->vsegs + |
---|
| 188 | MAPPING_TASK_SIZE * header->tasks + |
---|
| 189 | MAPPING_PROC_SIZE * header->procs); |
---|
| 190 | |
---|
| 191 | // computes the base address for periphs array |
---|
| 192 | periph = (mapping_periph_t *) ((char *) header + |
---|
| 193 | MAPPING_HEADER_SIZE + |
---|
[263] | 194 | MAPPING_CLUSTER_SIZE * header->x_size * header->y_size + |
---|
[258] | 195 | MAPPING_PSEG_SIZE * header->psegs + |
---|
| 196 | MAPPING_VSPACE_SIZE * header->vspaces + |
---|
| 197 | MAPPING_VSEG_SIZE * header->vsegs + |
---|
| 198 | MAPPING_TASK_SIZE * header->tasks + |
---|
| 199 | MAPPING_PROC_SIZE * header->procs + |
---|
[522] | 200 | MAPPING_IRQ_SIZE * header->irqs); |
---|
[258] | 201 | |
---|
| 202 | ///////////////////////// header ///////////////////////////////////////////// |
---|
| 203 | |
---|
| 204 | fprintf(fpout, "<?xml version = \"1.0\"?>\n\n"); |
---|
| 205 | |
---|
[287] | 206 | fprintf(fpout, "<mapping_info signature = \"0x%x\" \n" , header->signature); |
---|
| 207 | fprintf(fpout, " name = \"%s\" \n" , header->name); |
---|
| 208 | fprintf(fpout, " x_size = \"%d\" \n" , header->x_size); |
---|
| 209 | fprintf(fpout, " y_size = \"%d\" \n" , header->y_size); |
---|
| 210 | fprintf(fpout, " x_width = \"%d\" \n" , header->x_width); |
---|
| 211 | fprintf(fpout, " y_width = \"%d\" \n" , header->y_width); |
---|
[295] | 212 | fprintf(fpout, " irq_per_proc = \"%d\" \n" , header->irq_per_proc); |
---|
[306] | 213 | fprintf(fpout, " use_ram_disk = \"%d\" \n" , header->use_ram_disk); |
---|
[295] | 214 | fprintf(fpout, " x_io = \"%d\" \n" , header->x_io); |
---|
| 215 | fprintf(fpout, " y_io = \"%d\" >\n\n", header->y_io); |
---|
[258] | 216 | |
---|
| 217 | ///////////////////// clusters /////////////////////////////////////////////// |
---|
| 218 | |
---|
| 219 | fprintf( fpout, " <clusterset>\n"); |
---|
[263] | 220 | for (cluster_id = 0; cluster_id < (header->x_size * header->y_size); cluster_id++) |
---|
[258] | 221 | { |
---|
[306] | 222 | fprintf(fpout, " <cluster x=\"%d\" y=\"%d\" >\n", |
---|
[263] | 223 | cluster[cluster_id].x, cluster[cluster_id].y ); |
---|
| 224 | |
---|
| 225 | ///////////////////// psegs //////////////////////////////////////////////// |
---|
| 226 | |
---|
[258] | 227 | for (pseg_id = cluster[cluster_id].pseg_offset; |
---|
| 228 | pseg_id < cluster[cluster_id].pseg_offset + cluster[cluster_id].psegs; |
---|
| 229 | pseg_id++) |
---|
| 230 | { |
---|
[306] | 231 | fprintf(fpout, " <pseg name=\"%s\"", pseg[pseg_id].name); |
---|
| 232 | fprintf(fpout, " type=\"%s\"", pseg_type[pseg[pseg_id].type]); |
---|
| 233 | fprintf(fpout, " base=\"0x%llx\"", pseg[pseg_id].base); |
---|
| 234 | fprintf(fpout, " length=\"0x%llx\" />\n", pseg[pseg_id].length); |
---|
[258] | 235 | } |
---|
| 236 | |
---|
| 237 | ///////////////////// processors ///////////////////////////////////////////// |
---|
| 238 | |
---|
| 239 | unsigned int proc_index = 0; |
---|
| 240 | for (proc_id = cluster[cluster_id].proc_offset; |
---|
| 241 | proc_id < cluster[cluster_id].proc_offset + cluster[cluster_id].procs; |
---|
[295] | 242 | proc_id++, proc_index++) |
---|
[258] | 243 | { |
---|
[306] | 244 | fprintf(fpout, " <proc index=\"%d\" />\n", proc_index); |
---|
[258] | 245 | } |
---|
| 246 | |
---|
| 247 | ///////////////////// periphs /////////////////////////////////////////////// |
---|
| 248 | |
---|
| 249 | for (periph_id = cluster[cluster_id].periph_offset; |
---|
| 250 | periph_id < cluster[cluster_id].periph_offset + cluster[cluster_id].periphs; |
---|
| 251 | periph_id++) |
---|
| 252 | { |
---|
[306] | 253 | fprintf(fpout, " <periph type=\"%s\"", periph_type[periph[periph_id].type]); |
---|
[289] | 254 | |
---|
[306] | 255 | if (periph[periph_id].type == PERIPH_TYPE_IOC) |
---|
| 256 | fprintf(fpout, " subtype=\"%s\"", ioc_subtype[periph[periph_id].subtype]); |
---|
[289] | 257 | |
---|
[522] | 258 | if (periph[periph_id].type == PERIPH_TYPE_MWR) |
---|
| 259 | fprintf(fpout, " subtype=\"%s\"", mwr_subtype[periph[periph_id].subtype]); |
---|
| 260 | |
---|
[306] | 261 | fprintf(fpout, " psegname=\"%s\"", pseg[periph[periph_id].psegid].name); |
---|
[323] | 262 | fprintf(fpout, " channels=\"%d\"", periph[periph_id].channels); |
---|
[522] | 263 | fprintf(fpout, " arg0=\"%d\" >\n", periph[periph_id].arg0); |
---|
| 264 | fprintf(fpout, " arg1=\"%d\" >\n", periph[periph_id].arg1); |
---|
| 265 | fprintf(fpout, " arg2=\"%d\" >\n", periph[periph_id].arg2); |
---|
| 266 | fprintf(fpout, " arg3=\"%d\" >\n", periph[periph_id].arg3); |
---|
[323] | 267 | if ( (periph[periph_id].type == PERIPH_TYPE_PIC) || |
---|
[439] | 268 | (periph[periph_id].type == PERIPH_TYPE_XCU) ) |
---|
[295] | 269 | { |
---|
[306] | 270 | for (irq_id = periph[periph_id].irq_offset; |
---|
| 271 | irq_id < periph[periph_id].irq_offset + periph[periph_id].irqs; |
---|
| 272 | irq_id++) |
---|
| 273 | { |
---|
| 274 | fprintf(fpout, " <irq srctype=\"%s\"", irq_type[irq[irq_id].srctype]); |
---|
| 275 | fprintf(fpout, " srcid=\"%d\"", irq[irq_id].srcid); |
---|
| 276 | fprintf(fpout, " isr=\"%s\"", isr_type[irq[irq_id].isr]); |
---|
[323] | 277 | fprintf(fpout, " channel=\"%d\" />\n", irq[irq_id].channel); |
---|
[306] | 278 | } |
---|
| 279 | } |
---|
[295] | 280 | fprintf(fpout, " </periph>\n"); |
---|
[258] | 281 | } |
---|
| 282 | fprintf(fpout, " </cluster>\n" ); |
---|
| 283 | } |
---|
| 284 | fprintf(fpout, " </clusterset>\n\n" ); |
---|
| 285 | |
---|
| 286 | /////////////////// globals ///////////////////////////////////////////////// |
---|
| 287 | |
---|
| 288 | fprintf(fpout, " <globalset>\n" ); |
---|
| 289 | for (vseg_id = 0; vseg_id < header->globals; vseg_id++) |
---|
| 290 | { |
---|
[306] | 291 | unsigned int pseg_id = vseg[vseg_id].psegid; |
---|
| 292 | unsigned int cluster_id = pseg[pseg_id].clusterid; |
---|
[258] | 293 | |
---|
[306] | 294 | fprintf(fpout, " <vseg name=\"%s\"", vseg[vseg_id].name); |
---|
| 295 | fprintf(fpout, " vbase=\"0x%x\"", vseg[vseg_id].vbase); |
---|
[511] | 296 | fprintf(fpout, " length=\"0x%x\"", vseg[vseg_id].length); |
---|
| 297 | fprintf(fpout, " type=\"%s\"", vseg_type[vseg[vseg_id].type]); |
---|
[306] | 298 | fprintf(fpout, " mode=\"%s\"", mode_str[vseg[vseg_id].mode]); |
---|
[511] | 299 | fprintf(fpout, "\n "); |
---|
[306] | 300 | fprintf(fpout, " x=\"%d\"", cluster[cluster_id].x); |
---|
| 301 | fprintf(fpout, " y=\"%d\"", cluster[cluster_id].y); |
---|
| 302 | fprintf(fpout, " psegname=\"%s\"", pseg[pseg_id].name); |
---|
[511] | 303 | if( vseg[vseg_id].ident ) |
---|
| 304 | fprintf(fpout, " ident=\"1\""); |
---|
| 305 | if( vseg[vseg_id].local ) |
---|
| 306 | fprintf(fpout, " local=\"1\""); |
---|
| 307 | if( vseg[vseg_id].big ) |
---|
| 308 | fprintf(fpout, " big=\"1\""); |
---|
| 309 | if( vseg[vseg_id].binpath[0] != 0 ) |
---|
| 310 | fprintf(fpout, " binpath=\"%s\"", vseg[vseg_id].binpath); |
---|
[306] | 311 | fprintf(fpout, " >\n"); |
---|
[258] | 312 | } |
---|
| 313 | fprintf(fpout, " </globalset>\n" ); |
---|
| 314 | |
---|
| 315 | //////////////////// vspaces //////////////////////////////////////////////// |
---|
| 316 | |
---|
| 317 | fprintf( fpout, "\n <vspaceset>\n\n" ); |
---|
| 318 | for (vspace_id = 0; vspace_id < header->vspaces; vspace_id++) |
---|
| 319 | { |
---|
[511] | 320 | unsigned int vseg_id = vspace[vspace_id].start_vseg_id; |
---|
[258] | 321 | fprintf(fpout, " <vspace name = \"%s\" ", vspace[vspace_id].name); |
---|
[511] | 322 | fprintf(fpout, " startname = \"%s\" >\n", vseg[vseg_id].name); |
---|
[258] | 323 | |
---|
[263] | 324 | //////////////////// vsegs ////////////////////////////////////////////// |
---|
| 325 | |
---|
[258] | 326 | for (vseg_id = vspace[vspace_id].vseg_offset; |
---|
| 327 | vseg_id < (vspace[vspace_id].vseg_offset + vspace[vspace_id].vsegs); |
---|
| 328 | vseg_id++) |
---|
| 329 | { |
---|
[263] | 330 | unsigned int pseg_id = vseg[vseg_id].psegid; |
---|
| 331 | unsigned int cluster_id = pseg[pseg_id].clusterid; |
---|
[258] | 332 | |
---|
[306] | 333 | fprintf(fpout, " <vseg name=\"%s\"", vseg[vseg_id].name); |
---|
| 334 | fprintf(fpout, " vbase=\"0x%x\"", vseg[vseg_id].vbase); |
---|
[511] | 335 | fprintf(fpout, " length=\"0x%x\"", vseg[vseg_id].length); |
---|
| 336 | fprintf(fpout, " type=\"%s\"", vseg_type[vseg[vseg_id].type]); |
---|
[306] | 337 | fprintf(fpout, " mode=\"%s\"", mode_str[vseg[vseg_id].mode]); |
---|
[511] | 338 | fprintf(fpout, "\n "); |
---|
[306] | 339 | fprintf(fpout, " x=\"%d\"", cluster[cluster_id].x); |
---|
| 340 | fprintf(fpout, " y=\"%d\"", cluster[cluster_id].y); |
---|
| 341 | fprintf(fpout, " psegname=\"%s\"", pseg[pseg_id].name); |
---|
[511] | 342 | if( vseg[vseg_id].ident ) |
---|
| 343 | fprintf(fpout, " ident=\"1\""); |
---|
| 344 | if( vseg[vseg_id].local ) |
---|
| 345 | fprintf(fpout, " local=\"1\""); |
---|
| 346 | if( vseg[vseg_id].big ) |
---|
| 347 | fprintf(fpout, " big=\"1\""); |
---|
| 348 | if( vseg[vseg_id].binpath[0] != 0 ) |
---|
| 349 | fprintf(fpout, " binpath=\"%s\"", vseg[vseg_id].binpath); |
---|
[306] | 350 | fprintf(fpout, " >\n"); |
---|
[258] | 351 | } |
---|
[263] | 352 | |
---|
| 353 | //////////////////// tasks ////////////////////////////////////////////// |
---|
| 354 | |
---|
[258] | 355 | for (task_id = vspace[vspace_id].task_offset; |
---|
| 356 | task_id < (vspace[vspace_id].task_offset + vspace[vspace_id].tasks); |
---|
| 357 | task_id++) |
---|
| 358 | { |
---|
[511] | 359 | unsigned int stack_vseg_id = task[task_id].stack_vseg_id; |
---|
| 360 | unsigned int heap_vseg_id = task[task_id].heap_vseg_id; |
---|
[323] | 361 | unsigned int cluster_id = task[task_id].clusterid; |
---|
[258] | 362 | |
---|
[306] | 363 | fprintf(fpout, " <task name=\"%s\"", task[task_id].name); |
---|
| 364 | fprintf(fpout, " trdid=\"%d\"", task[task_id].trdid); |
---|
| 365 | fprintf(fpout, " x=\"%d\"", cluster[cluster_id].x); |
---|
| 366 | fprintf(fpout, " y=\"%d\"", cluster[cluster_id].y); |
---|
| 367 | fprintf(fpout, " p=\"%d\"", task[task_id].proclocid); |
---|
[511] | 368 | fprintf(fpout, "\n "); |
---|
| 369 | fprintf(fpout, " stackname=\"%s\"", vseg[stack_vseg_id].name); |
---|
| 370 | if (heap_vseg_id != -1) |
---|
| 371 | fprintf(fpout, " heapname=\"%s\"", vseg[heap_vseg_id].name); |
---|
[306] | 372 | fprintf(fpout, " startid = \"%d\"", task[task_id].startid); |
---|
| 373 | fprintf(fpout, " />\n"); |
---|
[258] | 374 | } |
---|
| 375 | fprintf(fpout, " </vspace>\n\n"); |
---|
| 376 | } |
---|
| 377 | fprintf(fpout, " </vspaceset>\n"); |
---|
| 378 | fprintf(fpout, "</mapping_info>\n"); |
---|
| 379 | } // end buildXml() |
---|
| 380 | |
---|
| 381 | |
---|
| 382 | ///////////////////////////////////// |
---|
[306] | 383 | int main(int argc, char * argv[]) |
---|
| 384 | { |
---|
| 385 | if (argc < 2) |
---|
| 386 | { |
---|
[258] | 387 | printf("Usage: bin2xml <input_file_path> <output_file_path>\n"); |
---|
| 388 | return 1; |
---|
| 389 | } |
---|
| 390 | |
---|
| 391 | unsigned int bin[0x10000]; // 64 K int = 256 Kbytes |
---|
| 392 | |
---|
| 393 | int fdin = open(argv[1], O_RDONLY); |
---|
[306] | 394 | if (fdin < 0) |
---|
| 395 | { |
---|
[258] | 396 | perror("open"); |
---|
| 397 | exit(1); |
---|
| 398 | } |
---|
| 399 | |
---|
| 400 | FILE * fpout = fopen( argv[2], "w"); |
---|
[306] | 401 | if (fpout == NULL) |
---|
| 402 | { |
---|
[258] | 403 | perror("open"); |
---|
| 404 | exit(1); |
---|
| 405 | } |
---|
| 406 | |
---|
| 407 | unsigned int length = read(fdin, bin, 0x40000); |
---|
| 408 | |
---|
[306] | 409 | if (length <= 0) |
---|
| 410 | { |
---|
[258] | 411 | perror("read"); |
---|
| 412 | exit(1); |
---|
| 413 | } |
---|
| 414 | |
---|
[306] | 415 | if (bin[0] == IN_MAPPING_SIGNATURE) |
---|
| 416 | { |
---|
[258] | 417 | buildXml((mapping_header_t *) bin, fpout); |
---|
| 418 | } |
---|
[306] | 419 | else |
---|
| 420 | { |
---|
[258] | 421 | printf("[ERROR] Wrong file format\n"); |
---|
| 422 | exit(1); |
---|
| 423 | } |
---|
| 424 | return 0; |
---|
| 425 | } // end main() |
---|
| 426 | |
---|
| 427 | |
---|
| 428 | |
---|
| 429 | // Local Variables: |
---|
| 430 | // tab-width: 4 |
---|
| 431 | // c-basic-offset: 4 |
---|
| 432 | // c-file-offsets:((innamespace . 0)(inline-open . 0)) |
---|
| 433 | // indent-tabs-mode: nil |
---|
| 434 | // End: |
---|
| 435 | // vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 |
---|
| 436 | |
---|