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