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