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