[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; |
---|
[709] | 128 | unsigned int thread_id; |
---|
[258] | 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; |
---|
[709] | 137 | mapping_thread_t * thread; |
---|
[258] | 138 | mapping_irq_t * irq; |
---|
| 139 | mapping_periph_t * periph; |
---|
| 140 | |
---|
| 141 | // computes the base adresss for clusters array, |
---|
| 142 | cluster = (mapping_cluster_t *)((char *) header + |
---|
| 143 | MAPPING_HEADER_SIZE); |
---|
| 144 | |
---|
| 145 | // computes the base adresss for psegs array, |
---|
| 146 | pseg = (mapping_pseg_t *) ((char *) header + |
---|
| 147 | MAPPING_HEADER_SIZE + |
---|
[263] | 148 | MAPPING_CLUSTER_SIZE * header->x_size * header->y_size); |
---|
[258] | 149 | |
---|
| 150 | // computes the base adresss for vspaces array, |
---|
| 151 | vspace = (mapping_vspace_t *) ((char *) header + |
---|
| 152 | MAPPING_HEADER_SIZE + |
---|
[263] | 153 | MAPPING_CLUSTER_SIZE * header->x_size * header->y_size + |
---|
[258] | 154 | MAPPING_PSEG_SIZE * header->psegs); |
---|
| 155 | |
---|
| 156 | // computes the base adresss for vsegs array, |
---|
| 157 | vseg = (mapping_vseg_t *) ((char *) header + |
---|
| 158 | MAPPING_HEADER_SIZE + |
---|
[263] | 159 | MAPPING_CLUSTER_SIZE * header->x_size * header->y_size + |
---|
[258] | 160 | MAPPING_PSEG_SIZE * header->psegs + |
---|
| 161 | MAPPING_VSPACE_SIZE * header->vspaces); |
---|
| 162 | |
---|
[709] | 163 | // computes the base address for threads array |
---|
| 164 | thread = (mapping_thread_t *) ((char *) header + |
---|
[258] | 165 | MAPPING_HEADER_SIZE + |
---|
[263] | 166 | MAPPING_CLUSTER_SIZE * header->x_size * header->y_size + |
---|
[258] | 167 | MAPPING_PSEG_SIZE * header->psegs + |
---|
| 168 | MAPPING_VSPACE_SIZE * header->vspaces + |
---|
| 169 | MAPPING_VSEG_SIZE * header->vsegs); |
---|
| 170 | |
---|
| 171 | // computes the base address for irqs array |
---|
| 172 | irq = (mapping_irq_t *) ((char *) header + |
---|
| 173 | MAPPING_HEADER_SIZE + |
---|
[263] | 174 | MAPPING_CLUSTER_SIZE * header->x_size * header->y_size + |
---|
[258] | 175 | MAPPING_PSEG_SIZE * header->psegs + |
---|
| 176 | MAPPING_VSPACE_SIZE * header->vspaces + |
---|
| 177 | MAPPING_VSEG_SIZE * header->vsegs + |
---|
[709] | 178 | MAPPING_THREAD_SIZE * header->threads + |
---|
[258] | 179 | MAPPING_PROC_SIZE * header->procs); |
---|
| 180 | |
---|
| 181 | // computes the base address for periphs array |
---|
| 182 | periph = (mapping_periph_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 + |
---|
[709] | 188 | MAPPING_THREAD_SIZE * header->threads + |
---|
[258] | 189 | MAPPING_PROC_SIZE * header->procs + |
---|
[522] | 190 | MAPPING_IRQ_SIZE * header->irqs); |
---|
[258] | 191 | |
---|
| 192 | ///////////////////////// header ///////////////////////////////////////////// |
---|
| 193 | |
---|
| 194 | fprintf(fpout, "<?xml version = \"1.0\"?>\n\n"); |
---|
| 195 | |
---|
[287] | 196 | fprintf(fpout, "<mapping_info signature = \"0x%x\" \n" , header->signature); |
---|
| 197 | fprintf(fpout, " name = \"%s\" \n" , header->name); |
---|
| 198 | fprintf(fpout, " x_size = \"%d\" \n" , header->x_size); |
---|
| 199 | fprintf(fpout, " y_size = \"%d\" \n" , header->y_size); |
---|
| 200 | fprintf(fpout, " x_width = \"%d\" \n" , header->x_width); |
---|
| 201 | fprintf(fpout, " y_width = \"%d\" \n" , header->y_width); |
---|
[295] | 202 | fprintf(fpout, " irq_per_proc = \"%d\" \n" , header->irq_per_proc); |
---|
[306] | 203 | fprintf(fpout, " use_ram_disk = \"%d\" \n" , header->use_ram_disk); |
---|
[295] | 204 | fprintf(fpout, " x_io = \"%d\" \n" , header->x_io); |
---|
| 205 | fprintf(fpout, " y_io = \"%d\" >\n\n", header->y_io); |
---|
[258] | 206 | |
---|
| 207 | ///////////////////// clusters /////////////////////////////////////////////// |
---|
| 208 | |
---|
| 209 | fprintf( fpout, " <clusterset>\n"); |
---|
[263] | 210 | for (cluster_id = 0; cluster_id < (header->x_size * header->y_size); cluster_id++) |
---|
[258] | 211 | { |
---|
[306] | 212 | fprintf(fpout, " <cluster x=\"%d\" y=\"%d\" >\n", |
---|
[263] | 213 | cluster[cluster_id].x, cluster[cluster_id].y ); |
---|
| 214 | |
---|
| 215 | ///////////////////// psegs //////////////////////////////////////////////// |
---|
| 216 | |
---|
[258] | 217 | for (pseg_id = cluster[cluster_id].pseg_offset; |
---|
| 218 | pseg_id < cluster[cluster_id].pseg_offset + cluster[cluster_id].psegs; |
---|
| 219 | pseg_id++) |
---|
| 220 | { |
---|
[306] | 221 | fprintf(fpout, " <pseg name=\"%s\"", pseg[pseg_id].name); |
---|
| 222 | fprintf(fpout, " type=\"%s\"", pseg_type[pseg[pseg_id].type]); |
---|
| 223 | fprintf(fpout, " base=\"0x%llx\"", pseg[pseg_id].base); |
---|
| 224 | fprintf(fpout, " length=\"0x%llx\" />\n", pseg[pseg_id].length); |
---|
[258] | 225 | } |
---|
| 226 | |
---|
| 227 | ///////////////////// processors ///////////////////////////////////////////// |
---|
| 228 | |
---|
| 229 | unsigned int proc_index = 0; |
---|
| 230 | for (proc_id = cluster[cluster_id].proc_offset; |
---|
| 231 | proc_id < cluster[cluster_id].proc_offset + cluster[cluster_id].procs; |
---|
[295] | 232 | proc_id++, proc_index++) |
---|
[258] | 233 | { |
---|
[306] | 234 | fprintf(fpout, " <proc index=\"%d\" />\n", proc_index); |
---|
[258] | 235 | } |
---|
| 236 | |
---|
| 237 | ///////////////////// periphs /////////////////////////////////////////////// |
---|
| 238 | |
---|
| 239 | for (periph_id = cluster[cluster_id].periph_offset; |
---|
| 240 | periph_id < cluster[cluster_id].periph_offset + cluster[cluster_id].periphs; |
---|
| 241 | periph_id++) |
---|
| 242 | { |
---|
[306] | 243 | fprintf(fpout, " <periph type=\"%s\"", periph_type[periph[periph_id].type]); |
---|
[289] | 244 | |
---|
[306] | 245 | if (periph[periph_id].type == PERIPH_TYPE_IOC) |
---|
| 246 | fprintf(fpout, " subtype=\"%s\"", ioc_subtype[periph[periph_id].subtype]); |
---|
[289] | 247 | |
---|
[522] | 248 | if (periph[periph_id].type == PERIPH_TYPE_MWR) |
---|
| 249 | fprintf(fpout, " subtype=\"%s\"", mwr_subtype[periph[periph_id].subtype]); |
---|
| 250 | |
---|
[306] | 251 | fprintf(fpout, " psegname=\"%s\"", pseg[periph[periph_id].psegid].name); |
---|
[323] | 252 | fprintf(fpout, " channels=\"%d\"", periph[periph_id].channels); |
---|
[627] | 253 | fprintf(fpout, " arg0=\"%d\"", periph[periph_id].arg0); |
---|
| 254 | fprintf(fpout, " arg1=\"%d\"", periph[periph_id].arg1); |
---|
| 255 | fprintf(fpout, " arg2=\"%d\"", periph[periph_id].arg2); |
---|
[522] | 256 | fprintf(fpout, " arg3=\"%d\" >\n", periph[periph_id].arg3); |
---|
[323] | 257 | if ( (periph[periph_id].type == PERIPH_TYPE_PIC) || |
---|
[439] | 258 | (periph[periph_id].type == PERIPH_TYPE_XCU) ) |
---|
[295] | 259 | { |
---|
[306] | 260 | for (irq_id = periph[periph_id].irq_offset; |
---|
| 261 | irq_id < periph[periph_id].irq_offset + periph[periph_id].irqs; |
---|
| 262 | irq_id++) |
---|
| 263 | { |
---|
| 264 | fprintf(fpout, " <irq srctype=\"%s\"", irq_type[irq[irq_id].srctype]); |
---|
| 265 | fprintf(fpout, " srcid=\"%d\"", irq[irq_id].srcid); |
---|
| 266 | fprintf(fpout, " isr=\"%s\"", isr_type[irq[irq_id].isr]); |
---|
[323] | 267 | fprintf(fpout, " channel=\"%d\" />\n", irq[irq_id].channel); |
---|
[306] | 268 | } |
---|
| 269 | } |
---|
[295] | 270 | fprintf(fpout, " </periph>\n"); |
---|
[258] | 271 | } |
---|
| 272 | fprintf(fpout, " </cluster>\n" ); |
---|
| 273 | } |
---|
| 274 | fprintf(fpout, " </clusterset>\n\n" ); |
---|
| 275 | |
---|
| 276 | /////////////////// globals ///////////////////////////////////////////////// |
---|
| 277 | |
---|
| 278 | fprintf(fpout, " <globalset>\n" ); |
---|
| 279 | for (vseg_id = 0; vseg_id < header->globals; vseg_id++) |
---|
| 280 | { |
---|
[306] | 281 | unsigned int pseg_id = vseg[vseg_id].psegid; |
---|
| 282 | unsigned int cluster_id = pseg[pseg_id].clusterid; |
---|
[258] | 283 | |
---|
[306] | 284 | fprintf(fpout, " <vseg name=\"%s\"", vseg[vseg_id].name); |
---|
| 285 | fprintf(fpout, " vbase=\"0x%x\"", vseg[vseg_id].vbase); |
---|
[511] | 286 | fprintf(fpout, " length=\"0x%x\"", vseg[vseg_id].length); |
---|
| 287 | fprintf(fpout, " type=\"%s\"", vseg_type[vseg[vseg_id].type]); |
---|
[306] | 288 | fprintf(fpout, " mode=\"%s\"", mode_str[vseg[vseg_id].mode]); |
---|
[511] | 289 | fprintf(fpout, "\n "); |
---|
[306] | 290 | fprintf(fpout, " x=\"%d\"", cluster[cluster_id].x); |
---|
| 291 | fprintf(fpout, " y=\"%d\"", cluster[cluster_id].y); |
---|
| 292 | fprintf(fpout, " psegname=\"%s\"", pseg[pseg_id].name); |
---|
[511] | 293 | if( vseg[vseg_id].ident ) |
---|
| 294 | fprintf(fpout, " ident=\"1\""); |
---|
| 295 | if( vseg[vseg_id].local ) |
---|
| 296 | fprintf(fpout, " local=\"1\""); |
---|
| 297 | if( vseg[vseg_id].big ) |
---|
| 298 | fprintf(fpout, " big=\"1\""); |
---|
| 299 | if( vseg[vseg_id].binpath[0] != 0 ) |
---|
| 300 | fprintf(fpout, " binpath=\"%s\"", vseg[vseg_id].binpath); |
---|
[306] | 301 | fprintf(fpout, " >\n"); |
---|
[258] | 302 | } |
---|
| 303 | fprintf(fpout, " </globalset>\n" ); |
---|
| 304 | |
---|
| 305 | //////////////////// vspaces //////////////////////////////////////////////// |
---|
| 306 | |
---|
| 307 | fprintf( fpout, "\n <vspaceset>\n\n" ); |
---|
| 308 | for (vspace_id = 0; vspace_id < header->vspaces; vspace_id++) |
---|
| 309 | { |
---|
[511] | 310 | unsigned int vseg_id = vspace[vspace_id].start_vseg_id; |
---|
[645] | 311 | fprintf(fpout, " <vspace name=\"%s\"", vspace[vspace_id].name); |
---|
| 312 | fprintf(fpout, " startname=\"%s\"", vseg[vseg_id].name); |
---|
| 313 | fprintf(fpout, " active=\"%d\" >\n", vspace[vspace_id].active); |
---|
[258] | 314 | |
---|
[263] | 315 | //////////////////// vsegs ////////////////////////////////////////////// |
---|
| 316 | |
---|
[258] | 317 | for (vseg_id = vspace[vspace_id].vseg_offset; |
---|
| 318 | vseg_id < (vspace[vspace_id].vseg_offset + vspace[vspace_id].vsegs); |
---|
| 319 | vseg_id++) |
---|
| 320 | { |
---|
[263] | 321 | unsigned int pseg_id = vseg[vseg_id].psegid; |
---|
| 322 | unsigned int cluster_id = pseg[pseg_id].clusterid; |
---|
[258] | 323 | |
---|
[306] | 324 | fprintf(fpout, " <vseg name=\"%s\"", vseg[vseg_id].name); |
---|
| 325 | fprintf(fpout, " vbase=\"0x%x\"", vseg[vseg_id].vbase); |
---|
[511] | 326 | fprintf(fpout, " length=\"0x%x\"", vseg[vseg_id].length); |
---|
| 327 | fprintf(fpout, " type=\"%s\"", vseg_type[vseg[vseg_id].type]); |
---|
[306] | 328 | fprintf(fpout, " mode=\"%s\"", mode_str[vseg[vseg_id].mode]); |
---|
[511] | 329 | fprintf(fpout, "\n "); |
---|
[306] | 330 | fprintf(fpout, " x=\"%d\"", cluster[cluster_id].x); |
---|
| 331 | fprintf(fpout, " y=\"%d\"", cluster[cluster_id].y); |
---|
| 332 | fprintf(fpout, " psegname=\"%s\"", pseg[pseg_id].name); |
---|
[511] | 333 | if( vseg[vseg_id].ident ) |
---|
| 334 | fprintf(fpout, " ident=\"1\""); |
---|
| 335 | if( vseg[vseg_id].local ) |
---|
| 336 | fprintf(fpout, " local=\"1\""); |
---|
| 337 | if( vseg[vseg_id].big ) |
---|
| 338 | fprintf(fpout, " big=\"1\""); |
---|
| 339 | if( vseg[vseg_id].binpath[0] != 0 ) |
---|
| 340 | fprintf(fpout, " binpath=\"%s\"", vseg[vseg_id].binpath); |
---|
[306] | 341 | fprintf(fpout, " >\n"); |
---|
[258] | 342 | } |
---|
[263] | 343 | |
---|
[709] | 344 | //////////////////// threads ////////////////////////////////////////////// |
---|
[263] | 345 | |
---|
[709] | 346 | for (thread_id = vspace[vspace_id].thread_offset; |
---|
| 347 | thread_id < (vspace[vspace_id].thread_offset + vspace[vspace_id].threads); |
---|
| 348 | thread_id++) |
---|
[258] | 349 | { |
---|
[709] | 350 | unsigned int stack_vseg_id = thread[thread_id].stack_vseg_id; |
---|
| 351 | unsigned int heap_vseg_id = thread[thread_id].heap_vseg_id; |
---|
| 352 | unsigned int cluster_id = thread[thread_id].clusterid; |
---|
[258] | 353 | |
---|
[709] | 354 | fprintf(fpout, " <thread name=\"%s\"", thread[thread_id].name); |
---|
| 355 | fprintf(fpout, " trdid=\"%d\"", thread[thread_id].trdid); |
---|
[306] | 356 | fprintf(fpout, " x=\"%d\"", cluster[cluster_id].x); |
---|
| 357 | fprintf(fpout, " y=\"%d\"", cluster[cluster_id].y); |
---|
[709] | 358 | fprintf(fpout, " p=\"%d\"", thread[thread_id].proclocid); |
---|
[511] | 359 | fprintf(fpout, "\n "); |
---|
| 360 | fprintf(fpout, " stackname=\"%s\"", vseg[stack_vseg_id].name); |
---|
| 361 | if (heap_vseg_id != -1) |
---|
| 362 | fprintf(fpout, " heapname=\"%s\"", vseg[heap_vseg_id].name); |
---|
[709] | 363 | fprintf(fpout, " startid = \"%d\"", thread[thread_id].startid); |
---|
[306] | 364 | fprintf(fpout, " />\n"); |
---|
[258] | 365 | } |
---|
| 366 | fprintf(fpout, " </vspace>\n\n"); |
---|
| 367 | } |
---|
| 368 | fprintf(fpout, " </vspaceset>\n"); |
---|
| 369 | fprintf(fpout, "</mapping_info>\n"); |
---|
| 370 | } // end buildXml() |
---|
| 371 | |
---|
| 372 | |
---|
| 373 | ///////////////////////////////////// |
---|
[306] | 374 | int main(int argc, char * argv[]) |
---|
| 375 | { |
---|
| 376 | if (argc < 2) |
---|
| 377 | { |
---|
[258] | 378 | printf("Usage: bin2xml <input_file_path> <output_file_path>\n"); |
---|
| 379 | return 1; |
---|
| 380 | } |
---|
| 381 | |
---|
| 382 | unsigned int bin[0x10000]; // 64 K int = 256 Kbytes |
---|
| 383 | |
---|
| 384 | int fdin = open(argv[1], O_RDONLY); |
---|
[306] | 385 | if (fdin < 0) |
---|
| 386 | { |
---|
[258] | 387 | perror("open"); |
---|
| 388 | exit(1); |
---|
| 389 | } |
---|
| 390 | |
---|
| 391 | FILE * fpout = fopen( argv[2], "w"); |
---|
[306] | 392 | if (fpout == NULL) |
---|
| 393 | { |
---|
[258] | 394 | perror("open"); |
---|
| 395 | exit(1); |
---|
| 396 | } |
---|
| 397 | |
---|
| 398 | unsigned int length = read(fdin, bin, 0x40000); |
---|
| 399 | |
---|
[306] | 400 | if (length <= 0) |
---|
| 401 | { |
---|
[258] | 402 | perror("read"); |
---|
| 403 | exit(1); |
---|
| 404 | } |
---|
| 405 | |
---|
[306] | 406 | if (bin[0] == IN_MAPPING_SIGNATURE) |
---|
| 407 | { |
---|
[258] | 408 | buildXml((mapping_header_t *) bin, fpout); |
---|
| 409 | } |
---|
[306] | 410 | else |
---|
| 411 | { |
---|
[258] | 412 | printf("[ERROR] Wrong file format\n"); |
---|
| 413 | exit(1); |
---|
| 414 | } |
---|
| 415 | return 0; |
---|
| 416 | } // end main() |
---|
| 417 | |
---|
| 418 | |
---|
| 419 | |
---|
| 420 | // Local Variables: |
---|
| 421 | // tab-width: 4 |
---|
| 422 | // c-basic-offset: 4 |
---|
| 423 | // c-file-offsets:((innamespace . 0)(inline-open . 0)) |
---|
| 424 | // indent-tabs-mode: nil |
---|
| 425 | // End: |
---|
| 426 | // vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 |
---|
| 427 | |
---|