Debian Codegraph @

tools/devdescr.xsl

raw symbols SCIP
1 <?xml version="1.0" encoding='ISO-8859-1' ?>
2 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
3 <!--
4 * Copyright (c) 2006 Joerg Wunsch
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 *
20 * $Id: devdescr.xsl 300 2012-11-02 21:25:57Z joerg_wunsch $
21 -->
22 <!--
23 * Extract all the data needed for the JTAG ICE mkII device decriptor
24 * from the XML, and format it the way src/devdescr.cc needs it.
25 *
26 * This file will *only* generate JTAG ICE mkII entries.
27 *
28 * Run this file together with the respective AVR's XML file through
29 * an XSLT processor (xsltproc, saxon), and capture the output for
30 * inclusion into src/devdescr.cc.
31 -->
32 <xsl:output method="text"/>
33 <xsl:template match="/">
34 <!-- Extract everything we need out of the XML. -->
35 <xsl:variable name="devname"
36 select="translate(/AVRPART/ADMIN/PART_NAME,
37 'abcdefghijklmnopqrstuvwxyz',
38 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')" />
39 <xsl:variable name="devname_lower"
40 select="translate(/AVRPART/ADMIN/PART_NAME,
41 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
42 'abcdefghijklmnopqrstuvwxyz')" />
43 <xsl:variable name="sig"
44 select="concat(substring(/AVRPART/ADMIN/SIGNATURE/ADDR001, 2),
45 substring(/AVRPART/ADMIN/SIGNATURE/ADDR002, 2))" />
46 <xsl:variable name="flashsize"
47 select="/AVRPART/MEMORY/PROG_FLASH" />
48 <xsl:variable name="eepromsize"
49 select="/AVRPART/MEMORY/EEPROM" />
50 <xsl:variable name="flashpagesize"
51 select="/AVRPART/PROGRAMMING/FlashPageSize" />
52 <xsl:variable name="eeprompagesize">
53 <xsl:choose>
54 <xsl:when test="/AVRPART/PROGRAMMING/EepromPageSize = 0">
55 <xsl:text>1</xsl:text>
56 </xsl:when>
57 <xsl:otherwise>
58 <xsl:value-of select="/AVRPART/PROGRAMMING/EepromPageSize" />
59 </xsl:otherwise>
60 </xsl:choose>
61 </xsl:variable>
62 <xsl:variable name="nmb_vectors"
63 select="/AVRPART/INTERRUPT_VECTOR/NMB_VECTORS" />
64 <xsl:variable name="sramstart"
65 select="/AVRPART/MEMORY/INT_SRAM/START_ADDR" />
66 <xsl:variable name="SPH"
67 select="/AVRPART/MEMORY/IO_MEMORY/SPH/IO_ADDR" />
68 <xsl:variable name="SPL"
69 select="/AVRPART/MEMORY/IO_MEMORY/SPL/IO_ADDR" />
70 <xsl:variable name="RAMPZ"
71 select="/AVRPART/MEMORY/IO_MEMORY/RAMPZ/IO_ADDR" />
72 <xsl:variable name="EIND"
73 select="/AVRPART/MEMORY/IO_MEMORY/EIND/IO_ADDR" />
74 <xsl:variable name="EECR"
75 select="/AVRPART/MEMORY/IO_MEMORY/EECR/IO_ADDR" />
76 <xsl:variable name="ucRead"
77 select="//AVRPART/ICE_SETTINGS/JTAGICEmkII/ucRead" />
78 <xsl:variable name="ucWrite"
79 select="//AVRPART/ICE_SETTINGS/JTAGICEmkII/ucWrite" />
80 <xsl:variable name="ucReadShadow"
81 select="//AVRPART/ICE_SETTINGS/JTAGICEmkII/ucReadShadow" />
82 <xsl:variable name="ucWriteShadow"
83 select="//AVRPART/ICE_SETTINGS/JTAGICEmkII/ucWriteShadow" />
84 <xsl:variable name="ucExtRead"
85 select="//AVRPART/ICE_SETTINGS/JTAGICEmkII/ucExtRead" />
86 <xsl:variable name="ucExtWrite"
87 select="//AVRPART/ICE_SETTINGS/JTAGICEmkII/ucExtWrite" />
88 <xsl:variable name="ucExtReadShadow"
89 select="//AVRPART/ICE_SETTINGS/JTAGICEmkII/ucExtReadShadow" />
90 <xsl:variable name="ucExtWriteShadow"
91 select="//AVRPART/ICE_SETTINGS/JTAGICEmkII/ucExtWriteShadow" />
92 <xsl:variable name="ucIDRAddress"
93 select="//AVRPART/ICE_SETTINGS/JTAGICEmkII/ucIDRAddress" />
94 <xsl:variable name="ucSPMCAddress"
95 select="//AVRPART/ICE_SETTINGS/JTAGICEmkII/ucSPMCAddress" />
96 <xsl:variable name="ulBootAddress"
97 select="//AVRPART/ICE_SETTINGS/JTAGICEmkII/ulBootAddress" />
98 <xsl:variable name="ucUpperExtIOLoc"
99 select="//AVRPART/ICE_SETTINGS/JTAGICEmkII/ucUpperExtIOLoc" />
100 <xsl:variable name="ucEepromInst"
101 select="//AVRPART/ICE_SETTINGS/JTAGICEmkII/ucEepromInst" />
102 <xsl:variable name="ucFlashInst"
103 select="//AVRPART/ICE_SETTINGS/JTAGICEmkII/ucFlashInst" />
104 <xsl:variable name="ucSPHaddr"
105 select="//AVRPART/ICE_SETTINGS/JTAGICEmkII/ucSPHaddr" />
106 <xsl:variable name="ucSPLaddr"
107 select="//AVRPART/ICE_SETTINGS/JTAGICEmkII/ucSPLaddr" />
108 <xsl:variable name="DWdatareg"
109 select="//AVRPART/ICE_SETTINGS/JTAGICEmkII/DWdatareg" />
110 <xsl:variable name="DWbasePC"
111 select="//AVRPART/ICE_SETTINGS/JTAGICEmkII/DWbasePC" />
112 <xsl:variable name="ucAllowFullPageBitstream"
113 select="//AVRPART/ICE_SETTINGS/JTAGICEmkII/ucAllowFullPageBitstream" />
114 <xsl:variable name="uiStartSmallestBootLoaderSection"
115 select="//AVRPART/ICE_SETTINGS/JTAGICEmkII/uiStartSmallestBootLoaderSection" />
116 <xsl:variable name="CacheType"
117 select="//AVRPART/ICE_SETTINGS/JTAGICEmkII/CacheType" />
118 <xsl:variable name="ResetType"
119 select="//AVRPART/ICE_SETTINGS/JTAGICEmkII/ResetType" />
120 <xsl:variable name="PCMaskExtended"
121 select="//AVRPART/ICE_SETTINGS/JTAGICEmkII/PCMaskExtended" />
122 <xsl:variable name="PCMaskHigh"
123 select="//AVRPART/ICE_SETTINGS/JTAGICEmkII/PCMaskHigh" />
124
125 <!-- If there's a JTAGICEmkII node at all, emit the descriptor. -->
126 <xsl:if test='//AVRPART/ICE_SETTINGS/JTAGICEmkII'>
127
128 <!-- start of new entry -->
129 <xsl:text> // DEV_</xsl:text>
130 <xsl:value-of select="$devname" />
131 <xsl:text>&#010; {&#010;&#009;&quot;</xsl:text>
132 <xsl:value-of select="$devname_lower" />
133 <xsl:text>&quot;,&#010;&#009;0x</xsl:text>
134
135 <!-- signature -->
136 <xsl:value-of select="$sig" />
137 <xsl:text>,&#010;</xsl:text>
138
139 <!-- flash page size and size -->
140 <xsl:text>&#009;</xsl:text>
141 <xsl:value-of select="$flashpagesize" />
142 <xsl:text>, </xsl:text>
143 <xsl:value-of select="$flashsize div $flashpagesize" />
144 <xsl:text>,&#009;// </xsl:text>
145 <xsl:value-of select="$flashsize" />
146 <xsl:text> bytes flash&#010;</xsl:text>
147
148 <!-- EEPROM page size and size -->
149 <xsl:text>&#009;</xsl:text>
150 <xsl:value-of select="$eeprompagesize" />
151 <xsl:text>, </xsl:text>
152 <xsl:value-of select="$eepromsize div $eeprompagesize" />
153 <xsl:text>,&#009;// </xsl:text>
154 <xsl:value-of select="$eepromsize" />
155 <xsl:text> bytes EEPROM&#010;</xsl:text>
156
157 <!-- interrupt vector size -->
158 <xsl:text>&#009;</xsl:text>
159 <xsl:value-of select="$nmb_vectors" />
160 <xsl:text> * </xsl:text>
161 <xsl:choose>
162 <xsl:when test="$flashsize &gt; 8192">
163 <xsl:text>4</xsl:text>
164 </xsl:when>
165 <xsl:otherwise>
166 <xsl:text>2</xsl:text>
167 </xsl:otherwise>
168 </xsl:choose>
169 <xsl:text>,&#009;// </xsl:text>
170 <xsl:value-of select="$nmb_vectors" />
171 <xsl:text> interrupt vectors&#010;</xsl:text>
172
173 <!-- static stuff -->
174 <xsl:text>&#009;DEVFL_MKII_ONLY,&#010;</xsl:text>
175 <xsl:text>&#009;NULL,&#009;// registers not yet defined&#010;</xsl:text>
176
177 <!-- Xmega? -->
178 <xsl:text>&#009;</xsl:text>
179 <xsl:choose>
180 <xsl:when test="substring(//AVRPART/ICE_SETTINGS/JTAGICEmkII/Interface,1,5) = 'Xmega'">
181 <xsl:text>true</xsl:text>
182 </xsl:when>
183 <xsl:otherwise> <!-- i.e., JTAG -->
184 <xsl:text>false</xsl:text>
185 </xsl:otherwise>
186 </xsl:choose>
187 <xsl:text>,&#010;</xsl:text>
188
189 <!-- XXX -->
190 <xsl:text>&#009;</xsl:text>
191 <xsl:text>0x00, 0x0000, // fuses</xsl:text>
192 <xsl:text>&#010;</xsl:text>
193
194 <!-- more static stuff -->
195 <xsl:text>&#009;{&#010;&#009; 0&#009;// no mkI support&#010;</xsl:text>
196 <xsl:text>&#009;},&#010;&#009;{&#010;&#009;</xsl:text>
197 <xsl:text> CMND_SET_DEVICE_DESCRIPTOR,&#010;</xsl:text>
198
199 <!-- IO register read and write bit definitions -->
200 <xsl:text>&#009; { </xsl:text>
201 <xsl:value-of select="$ucRead" />
202 <xsl:text> }, // ucReadIO&#010;</xsl:text>
203 <xsl:text>&#009; { </xsl:text>
204 <xsl:value-of select="$ucReadShadow" />
205 <xsl:text> }, // ucReadIOShadow&#010;</xsl:text>
206 <xsl:text>&#009; { </xsl:text>
207 <xsl:value-of select="$ucWrite" />
208 <xsl:text> }, // ucWriteIO&#010;</xsl:text>
209 <xsl:text>&#009; { </xsl:text>
210 <xsl:value-of select="$ucWriteShadow" />
211 <xsl:text> }, // ucWriteIOShadow&#010;</xsl:text>
212 <xsl:text>&#009; { </xsl:text>
213 <!-- The extIO strings are long, so use format-hex. -->
214 <xsl:call-template name="format-hex">
215 <xsl:with-param name="arg" select="$ucExtRead" />
216 <xsl:with-param name="count" select="0" />
217 </xsl:call-template>
218 <xsl:text> }, // ucReadExtIO&#010;</xsl:text>
219 <xsl:text>&#009; { </xsl:text>
220 <xsl:call-template name="format-hex">
221 <xsl:with-param name="arg" select="$ucExtReadShadow" />
222 <xsl:with-param name="count" select="0" />
223 </xsl:call-template>
224 <xsl:text> }, // ucReadIOExtShadow&#010;</xsl:text>
225 <xsl:text>&#009; { </xsl:text>
226 <xsl:call-template name="format-hex">
227 <xsl:with-param name="arg" select="$ucExtWrite" />
228 <xsl:with-param name="count" select="0" />
229 </xsl:call-template>
230 <xsl:text> }, // ucWriteExtIO&#010;</xsl:text>
231 <xsl:text>&#009; { </xsl:text>
232 <xsl:call-template name="format-hex">
233 <xsl:with-param name="arg" select="$ucExtWriteShadow" />
234 <xsl:with-param name="count" select="0" />
235 </xsl:call-template>
236 <xsl:text> }, // ucWriteIOExtShadow&#010;</xsl:text>
237
238 <!-- miscellaneous -->
239 <xsl:text>&#009; </xsl:text>
240 <xsl:value-of select="$ucIDRAddress" />
241 <xsl:text>,&#009;// ucIDRAddress&#010;</xsl:text>
242
243 <xsl:text>&#009; </xsl:text>
244 <xsl:value-of select="$ucSPMCAddress" />
245 <xsl:text>,&#009;// ucSPMCRAddress&#010;</xsl:text>
246
247 <xsl:text>&#009; </xsl:text>
248 <xsl:call-template name="dollar-to-0x">
249 <xsl:with-param name="arg" select="$RAMPZ" />
250 </xsl:call-template>
251 <xsl:text>,&#009;// ucRAMPZAddress&#010;</xsl:text>
252
253 <xsl:text>&#009; fill_b2(</xsl:text>
254 <xsl:value-of select="$flashpagesize" />
255 <xsl:text>),&#009;// uiFlashPageSize&#010;</xsl:text>
256
257 <xsl:text>&#009; </xsl:text>
258 <xsl:value-of select="$eeprompagesize" />
259 <xsl:text>,&#009;// ucEepromPageSize&#010;</xsl:text>
260
261 <xsl:text>&#009; fill_b4(</xsl:text>
262 <xsl:value-of select="$ulBootAddress" />
263 <xsl:text>),&#009;// ulBootAddress&#010;</xsl:text>
264
265 <xsl:text>&#009; fill_b2(</xsl:text>
266 <xsl:value-of select="$ucUpperExtIOLoc" />
267 <xsl:text>),&#009;// uiUpperExtIOLoc&#010;</xsl:text>
268
269 <xsl:text>&#009; fill_b4(</xsl:text>
270 <xsl:value-of select="$flashsize" />
271 <xsl:text>),&#009;// ulFlashSize&#010;</xsl:text>
272
273 <xsl:text>&#009; { </xsl:text>
274 <xsl:call-template name="format-hex">
275 <xsl:with-param name="arg" select="$ucEepromInst" />
276 <xsl:with-param name="count" select="0" />
277 </xsl:call-template>
278 <xsl:text> },&#009;// ucEepromInst&#010;</xsl:text>
279
280 <xsl:text>&#009; { </xsl:text>
281 <xsl:call-template name="format-hex">
282 <xsl:with-param name="arg" select="$ucFlashInst" />
283 <xsl:with-param name="count" select="0" />
284 </xsl:call-template>
285 <xsl:text> },&#009;// ucFlashInst&#010;</xsl:text>
286
287 <xsl:text>&#009; </xsl:text>
288 <xsl:call-template name="dollar-to-0x">
289 <xsl:with-param name="arg" select="$SPH" />
290 </xsl:call-template>
291
292 <xsl:text>,&#009;// ucSPHaddr&#010;</xsl:text>
293 <xsl:text>&#009; </xsl:text>
294 <xsl:call-template name="dollar-to-0x">
295 <xsl:with-param name="arg" select="$SPL" />
296 </xsl:call-template>
297 <xsl:text>,&#009;// ucSPLaddr&#010;</xsl:text>
298
299 <xsl:text>&#009; fill_b2(</xsl:text>
300 <xsl:value-of select="$flashsize" />
301 <xsl:text> / </xsl:text>
302 <xsl:value-of select="$flashpagesize" />
303 <xsl:text>),&#009;// uiFlashpages&#010;</xsl:text>
304
305 <xsl:text>&#009; </xsl:text>
306 <xsl:value-of select="$DWdatareg" />
307 <xsl:text>,&#009;// ucDWDRAddress&#010;</xsl:text>
308
309 <xsl:text>&#009; </xsl:text>
310 <xsl:value-of select="$DWbasePC" />
311 <xsl:text>,&#009;// ucDWBasePC&#010;</xsl:text>
312
313 <xsl:text>&#009; </xsl:text>
314 <xsl:value-of select="$ucAllowFullPageBitstream" />
315 <xsl:text>,&#009;// ucAllowFullPageBitstream&#010;</xsl:text>
316
317 <xsl:text>&#009; fill_b2(</xsl:text>
318 <xsl:value-of select="$uiStartSmallestBootLoaderSection" />
319 <xsl:text>),&#009;// uiStartSmallestBootLoaderSection&#010;</xsl:text>
320
321 <!-- EnablePageProgramming is not always given in the XML files. -->
322 <!-- All our target processors are organized in pages though. -->
323 <xsl:text>&#009; 1,&#009;// EnablePageProgramming&#010;</xsl:text>
324
325 <xsl:text>&#009; </xsl:text>
326 <xsl:call-template name="maybezero">
327 <xsl:with-param name="arg" select="$CacheType" />
328 </xsl:call-template>
329 <xsl:text>,&#009;// ucCacheType&#010;</xsl:text>
330
331 <xsl:text>&#009; fill_b2(</xsl:text>
332 <xsl:call-template name="dollar-to-0x">
333 <xsl:with-param name="arg" select="$sramstart" />
334 </xsl:call-template>
335 <xsl:text>),&#009;// uiSramStartAddr&#010;</xsl:text>
336
337 <xsl:text>&#009; </xsl:text>
338 <xsl:call-template name="maybezero">
339 <xsl:with-param name="arg" select="$ResetType" />
340 </xsl:call-template>
341 <xsl:text>,&#009;// ucResetType&#010;</xsl:text>
342
343 <xsl:text>&#009; </xsl:text>
344 <xsl:call-template name="maybezero">
345 <xsl:with-param name="arg" select="$PCMaskExtended" />
346 </xsl:call-template>
347 <xsl:text>,&#009;// ucPCMaskExtended&#010;</xsl:text>
348
349 <xsl:text>&#009; </xsl:text>
350 <xsl:call-template name="maybezero">
351 <xsl:with-param name="arg" select="$PCMaskHigh" />
352 </xsl:call-template>
353 <xsl:text>,&#009;// ucPCMaskHigh&#010;</xsl:text>
354
355 <xsl:text>&#009; </xsl:text>
356 <xsl:call-template name="dollar-to-0x">
357 <xsl:with-param name="arg" select="$EIND" />
358 </xsl:call-template>
359 <xsl:text>,&#009;// ucEindAddress&#010;</xsl:text>
360
361 <xsl:text>&#009; fill_b2(</xsl:text>
362 <xsl:call-template name="dollar-to-0x">
363 <xsl:with-param name="arg" select="$EECR" />
364 </xsl:call-template>
365 <xsl:text>),&#009;// EECRAddress&#010;</xsl:text>
366
367 <xsl:text>&#009;},&#010;</xsl:text>
368
369 <!-- XXX -->
370 <xsl:text>&#009;</xsl:text>
371 <xsl:text>{ 0 },&#009;&#009;// Xmega device descr.</xsl:text>
372 <xsl:text>&#010;</xsl:text>
373
374 <!-- trailer -->
375 <xsl:text> },&#010;</xsl:text>
376
377 </xsl:if> <!-- JTAGICEmkII is present -->
378
379 </xsl:template>
380
381 <xsl:template name="toupper">
382 </xsl:template>
383
384 <!-- return argument $arg if non-empty, 0 otherwise -->
385 <xsl:template name="maybezero">
386 <xsl:param name="arg" />
387 <xsl:choose>
388 <xsl:when test="string-length($arg) = 0"><xsl:text>0</xsl:text></xsl:when>
389 <xsl:otherwise><xsl:value-of select="$arg" /></xsl:otherwise>
390 </xsl:choose>
391 </xsl:template> <!-- maybezero -->
392
393 <!-- convert $XX hex number in $arg (if any) into 0xXX; -->
394 <!-- return 0 if $arg is empty -->
395 <xsl:template name="dollar-to-0x">
396 <xsl:param name="arg" />
397 <xsl:choose>
398 <xsl:when test="string-length($arg) = 0">
399 <xsl:text>0</xsl:text>
400 </xsl:when>
401 <xsl:when test="substring($arg, 1, 1) = '&#036;'">
402 <xsl:text>0x</xsl:text>
403 <xsl:value-of select="substring($arg, 2)" />
404 </xsl:when>
405 <xsl:otherwise>
406 <xsl:value-of select="$arg" />
407 </xsl:otherwise>
408 </xsl:choose>
409 </xsl:template> <!-- dollar-to-0x -->
410
411 <!-- Format a string of 0xXX numbers: start a new line -->
412 <!-- after each 8 hex numbers -->
413 <!-- call with parameter $count = 0, calls itself -->
414 <!-- recursively then until everything has been done -->
415 <xsl:template name="format-hex">
416 <xsl:param name="arg" />
417 <xsl:param name="count" />
418 <xsl:choose>
419 <xsl:when test="string-length($arg) &lt;= 4">
420 <!-- Last element, print it, and leave template. -->
421 <xsl:value-of select="$arg" />
422 </xsl:when>
423 <xsl:otherwise>
424 <!--
425 * More arguments follow, print first value,
426 * followed by a comma, decide whether a space
427 * or a newline needs to be emitted, and recurse
428 * with the remaining part of $arg.
429 -->
430 <xsl:value-of select="substring($arg, 1, 4)" />
431 <xsl:choose>
432 <xsl:when test="$count mod 8 = 7">
433 <xsl:text>,&#010;&#009; </xsl:text>
434 </xsl:when>
435 <xsl:otherwise>
436 <xsl:text>,</xsl:text>
437 </xsl:otherwise>
438 </xsl:choose>
439 <xsl:variable name="newarg">
440 <!-- see whether there is a space after comma -->
441 <xsl:choose>
442 <xsl:when test="substring($arg, 6, 1) = ' '">
443 <xsl:value-of select="substring($arg, 7)" />
444 </xsl:when>
445 <xsl:otherwise>
446 <xsl:value-of select="substring($arg, 6)" />
447 </xsl:otherwise>
448 </xsl:choose>
449 </xsl:variable>
450 <xsl:call-template name="format-hex">
451 <xsl:with-param name="arg" select="$newarg" />
452 <xsl:with-param name="count" select="$count + 1" />
453 </xsl:call-template>
454 </xsl:otherwise>
455 </xsl:choose>
456 </xsl:template>
457
458 </xsl:stylesheet>