| 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 | ////////////////////////////////////////////////////// |
|---|
| 20 | void buildXml(mapping_header_t * header, FILE * fpout) |
|---|
| 21 | { |
|---|
| 22 | // mnemonics defined in mapping_info.h |
|---|
| 23 | const char * vseg_type[] = |
|---|
| 24 | { |
|---|
| 25 | "ELF", // From a .elf file |
|---|
| 26 | "BLOB", // Raw Binary |
|---|
| 27 | "PTAB", // Page Table |
|---|
| 28 | "PERI", // Hardware Component |
|---|
| 29 | "BUFFER", // No intialisation needed (stacks...) |
|---|
| 30 | "SCHED", // Scheduler |
|---|
| 31 | "HEAP", // Heap |
|---|
| 32 | "MMAP", // Mmap (dynamic mapping) |
|---|
| 33 | |
|---|
| 34 | }; |
|---|
| 35 | |
|---|
| 36 | // mnemonics defined in mapping_info.h |
|---|
| 37 | const char * pseg_type[] = |
|---|
| 38 | { |
|---|
| 39 | "RAM", |
|---|
| 40 | "PERI", |
|---|
| 41 | }; |
|---|
| 42 | |
|---|
| 43 | // mnemonics defined in mapping_info.h |
|---|
| 44 | const char * irq_type[] = |
|---|
| 45 | { |
|---|
| 46 | "HWI", |
|---|
| 47 | "WTI", |
|---|
| 48 | "PTI", |
|---|
| 49 | }; |
|---|
| 50 | |
|---|
| 51 | // These mnemonics must be consistent with values in |
|---|
| 52 | // irq_handler.h / irq_handler.c / mapping.py |
|---|
| 53 | const char * isr_type[] = |
|---|
| 54 | { |
|---|
| 55 | "ISR_DEFAULT", |
|---|
| 56 | "ISR_TICK", |
|---|
| 57 | "ISR_TTY_RX", |
|---|
| 58 | "ISR_TTY_TX", |
|---|
| 59 | "ISR_BDV", |
|---|
| 60 | "ISR_TIMER", |
|---|
| 61 | "ISR_WAKUP", |
|---|
| 62 | "ISR_NIC_RX", |
|---|
| 63 | "ISR_NIC_TX", |
|---|
| 64 | "ISR_CMA", |
|---|
| 65 | "ISR_MMC", |
|---|
| 66 | "ISR_DMA", |
|---|
| 67 | "ISR_SDC", |
|---|
| 68 | "ISR_MWR", |
|---|
| 69 | "ISR_HBA", |
|---|
| 70 | }; |
|---|
| 71 | |
|---|
| 72 | const char * mwr_subtype[] = |
|---|
| 73 | { |
|---|
| 74 | "CPY", |
|---|
| 75 | "GCD", |
|---|
| 76 | "DCT", |
|---|
| 77 | }; |
|---|
| 78 | |
|---|
| 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", |
|---|
| 94 | "PIC", |
|---|
| 95 | "DROM", |
|---|
| 96 | }; |
|---|
| 97 | |
|---|
| 98 | const char * ioc_subtype[] = |
|---|
| 99 | { |
|---|
| 100 | "BDV", |
|---|
| 101 | "HBA", |
|---|
| 102 | "SDC", |
|---|
| 103 | "SPI", |
|---|
| 104 | }; |
|---|
| 105 | |
|---|
| 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; |
|---|
| 130 | unsigned int thread_id; |
|---|
| 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; |
|---|
| 139 | mapping_thread_t * thread; |
|---|
| 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 + |
|---|
| 150 | MAPPING_CLUSTER_SIZE * header->x_size * header->y_size); |
|---|
| 151 | |
|---|
| 152 | // computes the base adresss for vspaces array, |
|---|
| 153 | vspace = (mapping_vspace_t *) ((char *) header + |
|---|
| 154 | MAPPING_HEADER_SIZE + |
|---|
| 155 | MAPPING_CLUSTER_SIZE * header->x_size * header->y_size + |
|---|
| 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 + |
|---|
| 161 | MAPPING_CLUSTER_SIZE * header->x_size * header->y_size + |
|---|
| 162 | MAPPING_PSEG_SIZE * header->psegs + |
|---|
| 163 | MAPPING_VSPACE_SIZE * header->vspaces); |
|---|
| 164 | |
|---|
| 165 | // computes the base address for threads array |
|---|
| 166 | thread = (mapping_thread_t *) ((char *) header + |
|---|
| 167 | MAPPING_HEADER_SIZE + |
|---|
| 168 | MAPPING_CLUSTER_SIZE * header->x_size * header->y_size + |
|---|
| 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 + |
|---|
| 176 | MAPPING_CLUSTER_SIZE * header->x_size * header->y_size + |
|---|
| 177 | MAPPING_PSEG_SIZE * header->psegs + |
|---|
| 178 | MAPPING_VSPACE_SIZE * header->vspaces + |
|---|
| 179 | MAPPING_VSEG_SIZE * header->vsegs + |
|---|
| 180 | MAPPING_THREAD_SIZE * header->threads + |
|---|
| 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 + |
|---|
| 186 | MAPPING_CLUSTER_SIZE * header->x_size * header->y_size + |
|---|
| 187 | MAPPING_PSEG_SIZE * header->psegs + |
|---|
| 188 | MAPPING_VSPACE_SIZE * header->vspaces + |
|---|
| 189 | MAPPING_VSEG_SIZE * header->vsegs + |
|---|
| 190 | MAPPING_THREAD_SIZE * header->threads + |
|---|
| 191 | MAPPING_PROC_SIZE * header->procs + |
|---|
| 192 | MAPPING_IRQ_SIZE * header->irqs); |
|---|
| 193 | |
|---|
| 194 | ///////////////////////// header ///////////////////////////////////////////// |
|---|
| 195 | |
|---|
| 196 | fprintf(fpout, "<?xml version = \"1.0\"?>\n\n"); |
|---|
| 197 | |
|---|
| 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); |
|---|
| 204 | fprintf(fpout, " irq_per_proc = \"%d\" \n" , header->irq_per_proc); |
|---|
| 205 | fprintf(fpout, " use_ram_disk = \"%d\" \n" , header->use_ram_disk); |
|---|
| 206 | fprintf(fpout, " x_io = \"%d\" \n" , header->x_io); |
|---|
| 207 | fprintf(fpout, " y_io = \"%d\" >\n\n", header->y_io); |
|---|
| 208 | |
|---|
| 209 | ///////////////////// clusters /////////////////////////////////////////////// |
|---|
| 210 | |
|---|
| 211 | fprintf( fpout, " <clusterset>\n"); |
|---|
| 212 | for (cluster_id = 0; cluster_id < (header->x_size * header->y_size); cluster_id++) |
|---|
| 213 | { |
|---|
| 214 | fprintf(fpout, " <cluster x=\"%d\" y=\"%d\" >\n", |
|---|
| 215 | cluster[cluster_id].x, cluster[cluster_id].y ); |
|---|
| 216 | |
|---|
| 217 | ///////////////////// psegs //////////////////////////////////////////////// |
|---|
| 218 | |
|---|
| 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 | { |
|---|
| 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); |
|---|
| 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; |
|---|
| 234 | proc_id++, proc_index++) |
|---|
| 235 | { |
|---|
| 236 | fprintf(fpout, " <proc index=\"%d\" />\n", proc_index); |
|---|
| 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 | { |
|---|
| 245 | fprintf(fpout, " <periph type=\"%s\"", periph_type[periph[periph_id].type]); |
|---|
| 246 | |
|---|
| 247 | if (periph[periph_id].type == PERIPH_TYPE_IOC) |
|---|
| 248 | fprintf(fpout, " subtype=\"%s\"", ioc_subtype[periph[periph_id].subtype]); |
|---|
| 249 | |
|---|
| 250 | if (periph[periph_id].type == PERIPH_TYPE_MWR) |
|---|
| 251 | fprintf(fpout, " subtype=\"%s\"", mwr_subtype[periph[periph_id].subtype]); |
|---|
| 252 | |
|---|
| 253 | fprintf(fpout, " psegname=\"%s\"", pseg[periph[periph_id].psegid].name); |
|---|
| 254 | fprintf(fpout, " channels=\"%d\"", periph[periph_id].channels); |
|---|
| 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); |
|---|
| 258 | fprintf(fpout, " arg3=\"%d\" >\n", periph[periph_id].arg3); |
|---|
| 259 | if ( (periph[periph_id].type == PERIPH_TYPE_PIC) || |
|---|
| 260 | (periph[periph_id].type == PERIPH_TYPE_XCU) ) |
|---|
| 261 | { |
|---|
| 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]); |
|---|
| 269 | fprintf(fpout, " channel=\"%d\" />\n", irq[irq_id].channel); |
|---|
| 270 | } |
|---|
| 271 | } |
|---|
| 272 | fprintf(fpout, " </periph>\n"); |
|---|
| 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 | { |
|---|
| 283 | unsigned int pseg_id = vseg[vseg_id].psegid; |
|---|
| 284 | unsigned int cluster_id = pseg[pseg_id].clusterid; |
|---|
| 285 | |
|---|
| 286 | fprintf(fpout, " <vseg name=\"%s\"", vseg[vseg_id].name); |
|---|
| 287 | fprintf(fpout, " vbase=\"0x%x\"", vseg[vseg_id].vbase); |
|---|
| 288 | fprintf(fpout, " length=\"0x%x\"", vseg[vseg_id].length); |
|---|
| 289 | fprintf(fpout, " type=\"%s\"", vseg_type[vseg[vseg_id].type]); |
|---|
| 290 | fprintf(fpout, " mode=\"%s\"", mode_str[vseg[vseg_id].mode]); |
|---|
| 291 | fprintf(fpout, "\n "); |
|---|
| 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); |
|---|
| 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); |
|---|
| 303 | fprintf(fpout, " >\n"); |
|---|
| 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 | { |
|---|
| 312 | unsigned int vseg_id = vspace[vspace_id].start_vseg_id; |
|---|
| 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); |
|---|
| 316 | |
|---|
| 317 | //////////////////// vsegs ////////////////////////////////////////////// |
|---|
| 318 | |
|---|
| 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 | { |
|---|
| 323 | unsigned int pseg_id = vseg[vseg_id].psegid; |
|---|
| 324 | unsigned int cluster_id = pseg[pseg_id].clusterid; |
|---|
| 325 | |
|---|
| 326 | fprintf(fpout, " <vseg name=\"%s\"", vseg[vseg_id].name); |
|---|
| 327 | fprintf(fpout, " vbase=\"0x%x\"", vseg[vseg_id].vbase); |
|---|
| 328 | fprintf(fpout, " length=\"0x%x\"", vseg[vseg_id].length); |
|---|
| 329 | fprintf(fpout, " type=\"%s\"", vseg_type[vseg[vseg_id].type]); |
|---|
| 330 | fprintf(fpout, " mode=\"%s\"", mode_str[vseg[vseg_id].mode]); |
|---|
| 331 | fprintf(fpout, "\n "); |
|---|
| 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); |
|---|
| 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); |
|---|
| 343 | fprintf(fpout, " >\n"); |
|---|
| 344 | } |
|---|
| 345 | |
|---|
| 346 | //////////////////// threads ////////////////////////////////////////////// |
|---|
| 347 | |
|---|
| 348 | for (thread_id = vspace[vspace_id].thread_offset; |
|---|
| 349 | thread_id < (vspace[vspace_id].thread_offset + vspace[vspace_id].threads); |
|---|
| 350 | thread_id++) |
|---|
| 351 | { |
|---|
| 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; |
|---|
| 355 | |
|---|
| 356 | fprintf(fpout, " <thread name=\"%s\"", thread[thread_id].name); |
|---|
| 357 | fprintf(fpout, " trdid=\"%d\"", thread[thread_id].trdid); |
|---|
| 358 | fprintf(fpout, " x=\"%d\"", cluster[cluster_id].x); |
|---|
| 359 | fprintf(fpout, " y=\"%d\"", cluster[cluster_id].y); |
|---|
| 360 | fprintf(fpout, " p=\"%d\"", thread[thread_id].proclocid); |
|---|
| 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); |
|---|
| 365 | fprintf(fpout, " startid = \"%d\"", thread[thread_id].startid); |
|---|
| 366 | fprintf(fpout, " />\n"); |
|---|
| 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 | ///////////////////////////////////// |
|---|
| 376 | int main(int argc, char * argv[]) |
|---|
| 377 | { |
|---|
| 378 | if (argc < 2) |
|---|
| 379 | { |
|---|
| 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); |
|---|
| 387 | if (fdin < 0) |
|---|
| 388 | { |
|---|
| 389 | perror("open"); |
|---|
| 390 | exit(1); |
|---|
| 391 | } |
|---|
| 392 | |
|---|
| 393 | FILE * fpout = fopen( argv[2], "w"); |
|---|
| 394 | if (fpout == NULL) |
|---|
| 395 | { |
|---|
| 396 | perror("open"); |
|---|
| 397 | exit(1); |
|---|
| 398 | } |
|---|
| 399 | |
|---|
| 400 | unsigned int length = read(fdin, bin, 0x40000); |
|---|
| 401 | |
|---|
| 402 | if (length <= 0) |
|---|
| 403 | { |
|---|
| 404 | perror("read"); |
|---|
| 405 | exit(1); |
|---|
| 406 | } |
|---|
| 407 | |
|---|
| 408 | if (bin[0] == IN_MAPPING_SIGNATURE) |
|---|
| 409 | { |
|---|
| 410 | buildXml((mapping_header_t *) bin, fpout); |
|---|
| 411 | } |
|---|
| 412 | else |
|---|
| 413 | { |
|---|
| 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 | |
|---|