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 | const char * vobj_type[] = |
---|
22 | { |
---|
23 | "ELF", // binary code generated by GCC |
---|
24 | "BLOB", // binary code generated by GCC |
---|
25 | "PTAB", // page table |
---|
26 | "PERI", // hardware component |
---|
27 | "MWMR", // MWMR channel |
---|
28 | "LOCK", // Spin-Lock |
---|
29 | "BUFFER", // Any "no intialiasation needed" objects (stacks...) |
---|
30 | "BARRIER", // Barrier |
---|
31 | "CONST", // Constant |
---|
32 | "MEMSPACE", // Memspace |
---|
33 | "SCHED", // Scheduler |
---|
34 | }; |
---|
35 | |
---|
36 | const char * pseg_type[] = |
---|
37 | { |
---|
38 | "RAM", |
---|
39 | "ROM", |
---|
40 | "PERI", |
---|
41 | }; |
---|
42 | |
---|
43 | const char * irq_type[] = |
---|
44 | { |
---|
45 | "HARD", |
---|
46 | "SOFT", |
---|
47 | "TIME", |
---|
48 | }; |
---|
49 | |
---|
50 | const char * isr_type[] = |
---|
51 | { |
---|
52 | "ISR_DEFAULT", |
---|
53 | "ISR_SWITCH", |
---|
54 | "ISR_TTY", |
---|
55 | "ISR_DMA", |
---|
56 | "ISR_IOC", |
---|
57 | "ISR_TIMER", |
---|
58 | }; |
---|
59 | |
---|
60 | const char * periph_type[] = |
---|
61 | { |
---|
62 | "CMA", |
---|
63 | "DMA", |
---|
64 | "FBF", |
---|
65 | "ICU", |
---|
66 | "IOB", |
---|
67 | "IOC", |
---|
68 | "MMC", |
---|
69 | "MWR", |
---|
70 | "NIC", |
---|
71 | "ROM", |
---|
72 | "SIM", |
---|
73 | "TIM", |
---|
74 | "TTY", |
---|
75 | "XCU", |
---|
76 | }; |
---|
77 | |
---|
78 | const char * periph_subtype[] = |
---|
79 | { |
---|
80 | "BDV", |
---|
81 | "HBA", |
---|
82 | "SPI", |
---|
83 | }; |
---|
84 | |
---|
85 | const char * port_direction[] = |
---|
86 | { |
---|
87 | "TO_COPROC", |
---|
88 | "FROM_COPROC", |
---|
89 | }; |
---|
90 | |
---|
91 | const char * mode_str[] = |
---|
92 | { |
---|
93 | "____", |
---|
94 | "___U", |
---|
95 | "__W_", |
---|
96 | "__WU", |
---|
97 | "_X__", |
---|
98 | "_X_U", |
---|
99 | "_XW_", |
---|
100 | "_XWU", |
---|
101 | "C___", |
---|
102 | "C__U", |
---|
103 | "C_W_", |
---|
104 | "C_WU", |
---|
105 | "CX__", |
---|
106 | "CX_U", |
---|
107 | "CXW_", |
---|
108 | "CXWU", |
---|
109 | }; |
---|
110 | |
---|
111 | unsigned int vspace_id; |
---|
112 | unsigned int cluster_id; |
---|
113 | unsigned int pseg_id; |
---|
114 | unsigned int vseg_id; |
---|
115 | unsigned int vobj_id; |
---|
116 | unsigned int task_id; |
---|
117 | unsigned int proc_id; |
---|
118 | unsigned int irq_id; |
---|
119 | unsigned int coproc_id; |
---|
120 | unsigned int port_id; |
---|
121 | unsigned int periph_id; |
---|
122 | |
---|
123 | mapping_cluster_t * cluster; |
---|
124 | mapping_pseg_t * pseg; |
---|
125 | mapping_vspace_t * vspace; |
---|
126 | mapping_vseg_t * vseg; |
---|
127 | mapping_vobj_t * vobj; |
---|
128 | mapping_task_t * task; |
---|
129 | mapping_proc_t * proc; |
---|
130 | mapping_irq_t * irq; |
---|
131 | mapping_coproc_t * coproc; |
---|
132 | mapping_cp_port_t * cp_port; |
---|
133 | mapping_periph_t * periph; |
---|
134 | |
---|
135 | // computes the base adresss for clusters array, |
---|
136 | cluster = (mapping_cluster_t *)((char *) header + |
---|
137 | MAPPING_HEADER_SIZE); |
---|
138 | |
---|
139 | // computes the base adresss for psegs array, |
---|
140 | pseg = (mapping_pseg_t *) ((char *) header + |
---|
141 | MAPPING_HEADER_SIZE + |
---|
142 | MAPPING_CLUSTER_SIZE * header->x_size * header->y_size); |
---|
143 | |
---|
144 | // computes the base adresss for vspaces array, |
---|
145 | vspace = (mapping_vspace_t *) ((char *) header + |
---|
146 | MAPPING_HEADER_SIZE + |
---|
147 | MAPPING_CLUSTER_SIZE * header->x_size * header->y_size + |
---|
148 | MAPPING_PSEG_SIZE * header->psegs); |
---|
149 | |
---|
150 | // computes the base adresss for vsegs array, |
---|
151 | vseg = (mapping_vseg_t *) ((char *) header + |
---|
152 | MAPPING_HEADER_SIZE + |
---|
153 | MAPPING_CLUSTER_SIZE * header->x_size * header->y_size + |
---|
154 | MAPPING_PSEG_SIZE * header->psegs + |
---|
155 | MAPPING_VSPACE_SIZE * header->vspaces); |
---|
156 | |
---|
157 | // computes the base adresss for vobjs array, |
---|
158 | vobj = (mapping_vobj_t *) ((char *) header + |
---|
159 | MAPPING_HEADER_SIZE + |
---|
160 | MAPPING_CLUSTER_SIZE * header->x_size * header->y_size + |
---|
161 | MAPPING_PSEG_SIZE * header->psegs + |
---|
162 | MAPPING_VSPACE_SIZE * header->vspaces + |
---|
163 | MAPPING_VSEG_SIZE * header->vsegs); |
---|
164 | |
---|
165 | // computes the base address for tasks array |
---|
166 | task = (mapping_task_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_VOBJ_SIZE * header->vobjs + |
---|
172 | MAPPING_VSEG_SIZE * header->vsegs); |
---|
173 | |
---|
174 | // computes the base address for procs array |
---|
175 | proc = (mapping_proc_t *) ((char *) header + |
---|
176 | MAPPING_HEADER_SIZE + |
---|
177 | MAPPING_CLUSTER_SIZE * header->x_size * header->y_size + |
---|
178 | MAPPING_PSEG_SIZE * header->psegs + |
---|
179 | MAPPING_VSPACE_SIZE * header->vspaces + |
---|
180 | MAPPING_VOBJ_SIZE * header->vobjs + |
---|
181 | MAPPING_VSEG_SIZE * header->vsegs + |
---|
182 | MAPPING_TASK_SIZE * header->tasks); |
---|
183 | |
---|
184 | // computes the base address for irqs array |
---|
185 | irq = (mapping_irq_t *) ((char *) header + |
---|
186 | MAPPING_HEADER_SIZE + |
---|
187 | MAPPING_CLUSTER_SIZE * header->x_size * header->y_size + |
---|
188 | MAPPING_PSEG_SIZE * header->psegs + |
---|
189 | MAPPING_VSPACE_SIZE * header->vspaces + |
---|
190 | MAPPING_VOBJ_SIZE * header->vobjs + |
---|
191 | MAPPING_VSEG_SIZE * header->vsegs + |
---|
192 | MAPPING_TASK_SIZE * header->tasks + |
---|
193 | MAPPING_PROC_SIZE * header->procs); |
---|
194 | |
---|
195 | // computes the base address for coprocs array |
---|
196 | coproc = (mapping_coproc_t *) ((char *) header + |
---|
197 | MAPPING_HEADER_SIZE + |
---|
198 | MAPPING_CLUSTER_SIZE * header->x_size * header->y_size + |
---|
199 | MAPPING_PSEG_SIZE * header->psegs + |
---|
200 | MAPPING_VSPACE_SIZE * header->vspaces + |
---|
201 | MAPPING_VOBJ_SIZE * header->vobjs + |
---|
202 | MAPPING_VSEG_SIZE * header->vsegs + |
---|
203 | MAPPING_TASK_SIZE * header->tasks + |
---|
204 | MAPPING_PROC_SIZE * header->procs + |
---|
205 | MAPPING_IRQ_SIZE * header->irqs); |
---|
206 | |
---|
207 | // computes the base address for cp_ports array |
---|
208 | cp_port = (mapping_cp_port_t *) ((char *) header + |
---|
209 | MAPPING_HEADER_SIZE + |
---|
210 | MAPPING_CLUSTER_SIZE * header->x_size * header->y_size + |
---|
211 | MAPPING_PSEG_SIZE * header->psegs + |
---|
212 | MAPPING_VSPACE_SIZE * header->vspaces + |
---|
213 | MAPPING_VOBJ_SIZE * header->vobjs + |
---|
214 | MAPPING_VSEG_SIZE * header->vsegs + |
---|
215 | MAPPING_TASK_SIZE * header->tasks + |
---|
216 | MAPPING_PROC_SIZE * header->procs + |
---|
217 | MAPPING_IRQ_SIZE * header->irqs + |
---|
218 | MAPPING_COPROC_SIZE * header->coprocs); |
---|
219 | |
---|
220 | // computes the base address for periphs array |
---|
221 | periph = (mapping_periph_t *) ((char *) header + |
---|
222 | MAPPING_HEADER_SIZE + |
---|
223 | MAPPING_CLUSTER_SIZE * header->x_size * header->y_size + |
---|
224 | MAPPING_PSEG_SIZE * header->psegs + |
---|
225 | MAPPING_VSPACE_SIZE * header->vspaces + |
---|
226 | MAPPING_VOBJ_SIZE * header->vobjs + |
---|
227 | MAPPING_VSEG_SIZE * header->vsegs + |
---|
228 | MAPPING_TASK_SIZE * header->tasks + |
---|
229 | MAPPING_PROC_SIZE * header->procs + |
---|
230 | MAPPING_IRQ_SIZE * header->irqs + |
---|
231 | MAPPING_COPROC_SIZE * header->coprocs + |
---|
232 | MAPPING_CP_PORT_SIZE * header->cp_ports); |
---|
233 | |
---|
234 | ///////////////////////// header ///////////////////////////////////////////// |
---|
235 | |
---|
236 | fprintf(fpout, "<?xml version = \"1.0\"?>\n\n"); |
---|
237 | |
---|
238 | fprintf(fpout, "<mapping_info signature = \"0x%x\" \n" , header->signature); |
---|
239 | fprintf(fpout, " name = \"%s\" \n" , header->name); |
---|
240 | fprintf(fpout, " x_size = \"%d\" \n" , header->x_size); |
---|
241 | fprintf(fpout, " y_size = \"%d\" \n" , header->y_size); |
---|
242 | fprintf(fpout, " x_width = \"%d\" \n" , header->x_width); |
---|
243 | fprintf(fpout, " y_width = \"%d\" \n" , header->y_width); |
---|
244 | fprintf(fpout, " vspaces = \"%d\" \n" , header->vspaces); |
---|
245 | fprintf(fpout, " increment = \"%d\" \n" , header->vspaces); |
---|
246 | fprintf(fpout, " irq_per_proc = \"%d\" >\n\n", header->irq_per_proc); |
---|
247 | |
---|
248 | ///////////////////// clusters /////////////////////////////////////////////// |
---|
249 | |
---|
250 | fprintf( fpout, " <clusterset>\n"); |
---|
251 | for (cluster_id = 0; cluster_id < (header->x_size * header->y_size); cluster_id++) |
---|
252 | { |
---|
253 | fprintf(fpout, " <cluster x = \"%d\" y = \"%d\" >\n", |
---|
254 | cluster[cluster_id].x, cluster[cluster_id].y ); |
---|
255 | |
---|
256 | ///////////////////// psegs //////////////////////////////////////////////// |
---|
257 | |
---|
258 | for (pseg_id = cluster[cluster_id].pseg_offset; |
---|
259 | pseg_id < cluster[cluster_id].pseg_offset + cluster[cluster_id].psegs; |
---|
260 | pseg_id++) |
---|
261 | { |
---|
262 | fprintf(fpout, " <pseg name = \"%s\" ", pseg[pseg_id].name); |
---|
263 | fprintf(fpout, "type = \"%s\" ", pseg_type[pseg[pseg_id].type]); |
---|
264 | fprintf(fpout, "base = \"0x%llx\" ", pseg[pseg_id].base); |
---|
265 | fprintf(fpout, "length = \"0x%llx\" />\n", pseg[pseg_id].length); |
---|
266 | } |
---|
267 | |
---|
268 | ///////////////////// processors ///////////////////////////////////////////// |
---|
269 | |
---|
270 | unsigned int proc_index = 0; |
---|
271 | for (proc_id = cluster[cluster_id].proc_offset; |
---|
272 | proc_id < cluster[cluster_id].proc_offset + cluster[cluster_id].procs; |
---|
273 | proc_id++) |
---|
274 | { |
---|
275 | fprintf(fpout, " <proc index = \"%d\" >\n", proc_index); |
---|
276 | for (irq_id = proc[proc_id].irq_offset; |
---|
277 | irq_id < proc[proc_id].irq_offset + proc[proc_id].irqs; |
---|
278 | irq_id++) |
---|
279 | { |
---|
280 | fprintf(fpout, " <irq type = \"%s\" ", irq_type[irq[irq_id].type]); |
---|
281 | fprintf(fpout, " icuid = \"0x%x\" ", irq[irq_id].icuid); |
---|
282 | fprintf(fpout, " isr = \"%s\" ", isr_type[irq[irq_id].isr]); |
---|
283 | fprintf(fpout, " channel = \"0x%x\" />\n", irq[irq_id].channel); |
---|
284 | } |
---|
285 | fprintf(fpout, " </proc>\n" ); |
---|
286 | } |
---|
287 | |
---|
288 | |
---|
289 | ///////////////////// coprocessors /////////////////////////////////////////// |
---|
290 | |
---|
291 | for (coproc_id = cluster[cluster_id].coproc_offset; |
---|
292 | coproc_id < cluster[cluster_id].coproc_offset + cluster[cluster_id].coprocs; |
---|
293 | coproc_id++) |
---|
294 | { |
---|
295 | fprintf(fpout, " <coproc name = \"%s\" ", coproc[coproc_id].name); |
---|
296 | fprintf(fpout, " psegname = \"%s\" >\n", pseg[coproc[coproc_id].psegid].name); |
---|
297 | for (port_id = coproc[coproc_id].port_offset; |
---|
298 | port_id < coproc[coproc_id].port_offset + coproc[coproc_id].ports; |
---|
299 | port_id++) |
---|
300 | { |
---|
301 | unsigned int vobj_id = cp_port[port_id].mwmr_vobjid + vspace[cp_port[port_id].vspaceid].vobj_offset; |
---|
302 | fprintf(fpout, " <port direction = \"%s\" ", port_direction[cp_port[port_id].direction]); |
---|
303 | fprintf(fpout, " vspacename = \"%s\" ", vspace[cp_port[port_id].vspaceid].name); |
---|
304 | fprintf(fpout, " vobjname = \"%s\" />\n", vobj[vobj_id].name); |
---|
305 | } |
---|
306 | fprintf(fpout, " </coproc>\n" ); |
---|
307 | } |
---|
308 | |
---|
309 | ///////////////////// periphs /////////////////////////////////////////////// |
---|
310 | |
---|
311 | for (periph_id = cluster[cluster_id].periph_offset; |
---|
312 | periph_id < cluster[cluster_id].periph_offset + cluster[cluster_id].periphs; |
---|
313 | periph_id++) |
---|
314 | { |
---|
315 | fprintf(fpout, " <periph type = \"%s\" ", periph_type[periph[periph_id].type]); |
---|
316 | |
---|
317 | if (periph[periph_id].subtype < PERIPH_SUBTYPE_MAX_VALUE) |
---|
318 | fprintf(fpout, " subtype = \"%s\" ", periph_subtype[periph[periph_id].subtype]); |
---|
319 | |
---|
320 | fprintf(fpout, " psegname = \"%s\" ", pseg[periph[periph_id].psegid].name); |
---|
321 | fprintf(fpout, " channels = \"%d\" />\n", periph[periph_id].channels); |
---|
322 | } |
---|
323 | fprintf(fpout, " </cluster>\n" ); |
---|
324 | } |
---|
325 | fprintf(fpout, " </clusterset>\n\n" ); |
---|
326 | |
---|
327 | /////////////////// globals ///////////////////////////////////////////////// |
---|
328 | |
---|
329 | fprintf(fpout, " <globalset>\n" ); |
---|
330 | for (vseg_id = 0; vseg_id < header->globals; vseg_id++) |
---|
331 | { |
---|
332 | unsigned int pseg_id = vseg[vseg_id].psegid; |
---|
333 | |
---|
334 | fprintf(fpout, " <vseg name = \"%s\" ", vseg[vseg_id].name); |
---|
335 | fprintf(fpout, "vbase = \"0x%x\" ", vseg[vseg_id].vbase); |
---|
336 | fprintf(fpout, "mode = \"%s\" ", mode_str[vseg[vseg_id].mode]); |
---|
337 | fprintf(fpout, "clusterid = \"%d\" ", pseg[pseg_id].clusterid); |
---|
338 | fprintf(fpout, "psegname = \"%s\" ", pseg[pseg_id].name); |
---|
339 | fprintf(fpout, "ident = \"%d\" >\n", vseg[vseg_id].ident); |
---|
340 | for (vobj_id = vseg[vseg_id].vobj_offset; |
---|
341 | vobj_id < (vseg[vseg_id].vobj_offset + vseg[vseg_id].vobjs); |
---|
342 | vobj_id++) |
---|
343 | { |
---|
344 | fprintf(fpout, " <vobj name = \"%s\" ", vobj[vobj_id].name); |
---|
345 | fprintf(fpout, "type = \"%s\" ", vobj_type[vobj[vobj_id].type]); |
---|
346 | fprintf(fpout, "length = \"0x%x\" ", vobj[vobj_id].length); |
---|
347 | fprintf(fpout, "align = \"%d\" ", vobj[vobj_id].align); |
---|
348 | fprintf(fpout, "init = \"%d\" ", vobj[vobj_id].init); |
---|
349 | fprintf(fpout, "binpath = \"%s\" />\n", vobj[vobj_id].binpath); |
---|
350 | } |
---|
351 | fprintf(fpout, " </vseg>\n"); |
---|
352 | } |
---|
353 | fprintf(fpout, " </globalset>\n" ); |
---|
354 | |
---|
355 | //////////////////// vspaces //////////////////////////////////////////////// |
---|
356 | |
---|
357 | fprintf( fpout, "\n <vspaceset>\n\n" ); |
---|
358 | for (vspace_id = 0; vspace_id < header->vspaces; vspace_id++) |
---|
359 | { |
---|
360 | unsigned int func_id = vspace[vspace_id].vobj_offset + vspace[vspace_id].start_offset; |
---|
361 | fprintf(fpout, " <vspace name = \"%s\" ", vspace[vspace_id].name); |
---|
362 | fprintf(fpout, " startname = \"%s\" >\n", vobj[func_id].name); |
---|
363 | |
---|
364 | //////////////////// vsegs ////////////////////////////////////////////// |
---|
365 | |
---|
366 | for (vseg_id = vspace[vspace_id].vseg_offset; |
---|
367 | vseg_id < (vspace[vspace_id].vseg_offset + vspace[vspace_id].vsegs); |
---|
368 | vseg_id++) |
---|
369 | { |
---|
370 | unsigned int pseg_id = vseg[vseg_id].psegid; |
---|
371 | unsigned int cluster_id = pseg[pseg_id].clusterid; |
---|
372 | unsigned int x = cluster_id >> header->y_width; |
---|
373 | unsigned int y = cluster_id & ((1<<header->y_width)-1); |
---|
374 | |
---|
375 | fprintf(fpout, " <vseg name = \"%s\" ", vseg[vseg_id].name); |
---|
376 | fprintf(fpout, "vbase = \"0x%x\" ", vseg[vseg_id].vbase); |
---|
377 | fprintf(fpout, "mode = \"%s\" ", mode_str[vseg[vseg_id].mode]); |
---|
378 | fprintf(fpout, "x = \"%d\" ", x); |
---|
379 | fprintf(fpout, "y = \"%d\" ", y); |
---|
380 | fprintf(fpout, "psegname = \"%s\" ", pseg[pseg_id].name); |
---|
381 | fprintf(fpout, "ident = \"%d\" >\n", vseg[vseg_id].ident); |
---|
382 | |
---|
383 | for (vobj_id = vseg[vseg_id].vobj_offset; |
---|
384 | vobj_id < (vseg[vseg_id].vobj_offset + vseg[vseg_id].vobjs); |
---|
385 | vobj_id++) |
---|
386 | { |
---|
387 | fprintf(fpout, " <vobj name = \"%s\" ", vobj[vobj_id].name); |
---|
388 | fprintf(fpout, "type = \"%s\" ", vobj_type[vobj[vobj_id].type]); |
---|
389 | fprintf(fpout, "length = \"0x%x\" ", vobj[vobj_id].length); |
---|
390 | fprintf(fpout, "align = \"%d\" ", vobj[vobj_id].align); |
---|
391 | fprintf(fpout, "init = \"%d\" ", vobj[vobj_id].init); |
---|
392 | fprintf(fpout, "binpath = \"%s\" />\n", vobj[vobj_id].binpath); |
---|
393 | } |
---|
394 | fprintf(fpout, " </vseg>\n\n"); |
---|
395 | } |
---|
396 | |
---|
397 | //////////////////// tasks ////////////////////////////////////////////// |
---|
398 | |
---|
399 | for (task_id = vspace[vspace_id].task_offset; |
---|
400 | task_id < (vspace[vspace_id].task_offset + vspace[vspace_id].tasks); |
---|
401 | task_id++) |
---|
402 | { |
---|
403 | unsigned int stack_vobj_id = task[task_id].stack_vobjid + vspace[vspace_id].vobj_offset; |
---|
404 | unsigned int heap_vobj_id = task[task_id].heap_vobjid + vspace[vspace_id].vobj_offset; |
---|
405 | unsigned int cluster_id = task[task_id].clusterid; |
---|
406 | unsigned int x = cluster_id >> header->y_width; |
---|
407 | unsigned int y = cluster_id & ((1<<header->y_width)-1); |
---|
408 | |
---|
409 | fprintf(fpout, " <task name = \"%s\" ", task[task_id].name); |
---|
410 | fprintf(fpout, "x = \"%d\" ", x); |
---|
411 | fprintf(fpout, "y = \"%d\" ", y); |
---|
412 | fprintf(fpout, "proclocid = \"%d\" ", task[task_id].proclocid); |
---|
413 | fprintf(fpout, "stackname = \"%s\" ", vobj[stack_vobj_id].name); |
---|
414 | if (heap_vobj_id != -1) |
---|
415 | { |
---|
416 | fprintf(fpout, "heapname = \"%s\" ", vobj[heap_vobj_id].name); |
---|
417 | } |
---|
418 | fprintf(fpout, "startid = \"%d\" ", task[task_id].startid); |
---|
419 | fprintf(fpout, "usetty = \"%d\" ", task[task_id].use_tty); |
---|
420 | fprintf(fpout, "usenic = \"%d\" ", task[task_id].use_nic); |
---|
421 | fprintf(fpout, "usecma = \"%d\" ", task[task_id].use_cma); |
---|
422 | fprintf(fpout, "usetim = \"%d\" ", task[task_id].use_tim); |
---|
423 | fprintf(fpout, "usehba = \"%d\" />\n", task[task_id].use_hba); |
---|
424 | } |
---|
425 | fprintf(fpout, " </vspace>\n\n"); |
---|
426 | } |
---|
427 | fprintf(fpout, " </vspaceset>\n"); |
---|
428 | fprintf(fpout, "</mapping_info>\n"); |
---|
429 | } // end buildXml() |
---|
430 | |
---|
431 | |
---|
432 | ///////////////////////////////////// |
---|
433 | int main(int argc, char * argv[]) { |
---|
434 | if (argc < 2) { |
---|
435 | printf("Usage: bin2xml <input_file_path> <output_file_path>\n"); |
---|
436 | return 1; |
---|
437 | } |
---|
438 | |
---|
439 | unsigned int bin[0x10000]; // 64 K int = 256 Kbytes |
---|
440 | |
---|
441 | int fdin = open(argv[1], O_RDONLY); |
---|
442 | if (fdin < 0) { |
---|
443 | perror("open"); |
---|
444 | exit(1); |
---|
445 | } |
---|
446 | |
---|
447 | FILE * fpout = fopen( argv[2], "w"); |
---|
448 | if (fpout == NULL) { |
---|
449 | perror("open"); |
---|
450 | exit(1); |
---|
451 | } |
---|
452 | |
---|
453 | unsigned int length = read(fdin, bin, 0x40000); |
---|
454 | |
---|
455 | if (length <= 0) { |
---|
456 | perror("read"); |
---|
457 | exit(1); |
---|
458 | } |
---|
459 | |
---|
460 | if (bin[0] == IN_MAPPING_SIGNATURE) { |
---|
461 | buildXml((mapping_header_t *) bin, fpout); |
---|
462 | } |
---|
463 | else { |
---|
464 | printf("[ERROR] Wrong file format\n"); |
---|
465 | exit(1); |
---|
466 | } |
---|
467 | return 0; |
---|
468 | } // end main() |
---|
469 | |
---|
470 | |
---|
471 | |
---|
472 | // Local Variables: |
---|
473 | // tab-width: 4 |
---|
474 | // c-basic-offset: 4 |
---|
475 | // c-file-offsets:((innamespace . 0)(inline-open . 0)) |
---|
476 | // indent-tabs-mode: nil |
---|
477 | // End: |
---|
478 | // vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 |
---|
479 | |
---|