1 <?xml version=
"1.0" encoding=
"ISO-8859-1"?>
3 <!--=========================================================================##
6 * GTF script to generate the file: mlt_nios2.h.gtf
8 *=============================================================================
9 *###ECOSGPLCOPYRIGHTBEGIN####
11 * This file is part of eCos, the Embedded Configurable Operating System.
13 * eCos is free software; you can redistribute it and/or modify it under
14 * the terms of the GNU General Public License as published by the Free
15 * Software Foundation; either version 2 or (at your option) any later version.
17 * eCos is distributed in the hope that it will be useful, but WITHOUT ANY
18 * WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 * You should have received a copy of the GNU General Public License along
23 * with eCos; if not, write to the Free Software Foundation, Inc.,
24 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
26 * As a special exception, if other files instantiate templates or use macros
27 * or inline functions from this file, or you compile this file and link it
28 * with other works to produce a work based on this file, this file does not
29 * by itself cause the resulting work to be covered by the GNU General Public
30 * License. However the source code for this file must still be made available
31 * in accordance with section (3) of the GNU General Public License.
33 * This exception does not invalidate any other reasons why a work based on
34 * this file might be covered by the GNU General Public License.
36 *###ECOSGPLCOPYRIGHTEND####
37 *==========================================================================-->
39 <!-- This GTF script is used to generate the Nios II memory layout header file,
40 mlt_nios2.h. This header file is constructed to match the memory
41 configuration of the associated the SOPC builder project. -->
43 <template name=
"mlt_nios2.h">
45 <!-- After calling this script, the variable GTF_DIR will be reset to point
46 to the gtf directory of the Nios2 kit. The original value can be
47 obtained using the variable ECOS_GTF_DIR. This allows us to reuse
48 some of the scripts supplied with the Nios II kit. -->
50 <call gtf=
"%GTF_DIR%/ECOS_GTF_DIR.gtf"/>
52 <call gtf=
"%GTF_DIR%/check_version.gtf"/>
54 <call gtf=
"%GTF_DIR%/CPU.gtf"/>
56 <call gtf=
"%GTF_DIR%/RESET_ADDRESS.gtf"/>
58 <call gtf=
"%GTF_DIR%/EXC_ADDRESS.gtf"/>
60 <set_variable variable=
"MEMORY_MODULES_ONLY" to=
"1"/>
61 <export variable=
"MEMORY_MODULES_ONLY"/>
62 <call gtf=
"%GTF_DIR%/MODULE_lists.gtf"/>
64 <set_variable variable=
"RESET_ROUTINE_SIZE" to=
"32"/>
68 * Machine generated for a CPU named
"%CPU%" as defined in:
71 * Generated: %TIMESTAMP%
77 <include source=
"%GTF_DIR%/warning.h"/>
79 <include source=
"%GTF_DIR%/license.h"/>
83 <![CDATA[#include
<cyg/infra/cyg_type.h
>
84 #include
<stddef.h
>]]
>
88 <!-- define for each memory partition... -->
91 <![CDATA[#define HAL_NIOS2_PARTITION_BASE_reset]]
> %RESET_ADDRESS%
92 <![CDATA[#define HAL_NIOS2_PARTITION_LEN_reset]]
> %RESET_ROUTINE_SIZE%
93 </text> <!-- ...always one for the reset address -->
95 <!-- ...and one for each MODULE/SLAVE -->
97 <set_variable variable=
"MEMORY_RANGE_LIST" to=
"()"/> <!-- while we're looking at all the memories, might as well create these lists to use below -->
98 <set_variable variable=
"PARTITION_ADDRESS_LIST" to=
""/>
100 <for_each variable=
"MODULE_SLAVE" index_variable=
"MODULE_SLAVE_LIST_INDEX" list=
"%MODULE_SLAVE_LIST%">
101 <export variable=
"MODULE_SLAVE"/>
102 <call gtf=
"%GTF_DIR%/BASE_ADDRESS_and_ADDRESS_SPAN.gtf"/>
104 <set_variable variable=
"MODULE_SLAVE_NAME" to=
"list_get( %MODULE_SLAVE_NAME_LIST%, %MODULE_SLAVE_LIST_INDEX% )"/>
107 <!-- if the base address for this MODULE/SLAVE is the same as the reset address, then make room for the reset handler -->
108 <if condition=
"eq( %BASE_ADDRESS%, %RESET_ADDRESS% )">
109 <set_variable variable=
"BASE_ADDRESS" to=
"add( %BASE_ADDRESS%, %RESET_ROUTINE_SIZE% )"/>
110 <set_variable variable=
"ADDRESS_SPAN" to=
"sub( %ADDRESS_SPAN%, %RESET_ROUTINE_SIZE% )"/>
114 <!-- if the reset address is in the address range of this MODULE/SLAVE, then we split the segment in two... -->
115 <if condition=
"and( gt( %RESET_ADDRESS%, %BASE_ADDRESS% ), lt( %RESET_ADDRESS%, add( %BASE_ADDRESS%, %ADDRESS_SPAN% ) ) )">
116 <!-- ...everything less than the reset address is unused -->
117 <set_variable variable=
"NEW_SEGMENT_ADDRESS_SPAN" to=
"radix( sub( %RESET_ADDRESS%, %BASE_ADDRESS% ), 10 )"/>
118 <!-- ...and start the usable segment after the reset handler -->
119 <set_variable variable=
"BASE_ADDRESS" to=
"add( %RESET_ADDRESS%, %RESET_ROUTINE_SIZE% )"/>
120 <set_variable variable=
"ADDRESS_SPAN" to=
"sub( %ADDRESS_SPAN%, %NEW_SEGMENT_ADDRESS_SPAN%, %RESET_ROUTINE_SIZE% )"/>
124 <!-- ASSUME that the exception address is always higher than the reset address (if they're in the same memory) -->
127 <!-- if the exception address is the same as the base address (for this MODULE/SLAVE), then the exception section is at the start of this segment -->
128 <if condition=
"eq( %EXC_ADDRESS%, %BASE_ADDRESS% )">
129 <set_variable variable=
"EXCEPTIONS_SEGMENT" to=
"%MODULE_SLAVE_NAME%"/>
132 <!-- if the exception address is in the address range of this MODULE/SLAVE, then we split the segment in two... -->
133 <if condition=
"and( gt( %EXC_ADDRESS%, %BASE_ADDRESS% ), lt( %EXC_ADDRESS%, add( %BASE_ADDRESS%, %ADDRESS_SPAN% ) ) )">
134 <!-- ...everything less than the exception address is unused -->
135 <set_variable variable=
"NEW_SEGMENT_ADDRESS_SPAN" to=
"radix( sub( %EXC_ADDRESS%, %BASE_ADDRESS% ), 10 )"/>
136 <!-- ...and start the usable segment at the exception address -->
137 <set_variable variable=
"BASE_ADDRESS" to=
"%EXC_ADDRESS%"/>
138 <set_variable variable=
"ADDRESS_SPAN" to=
"sub( %ADDRESS_SPAN%, %NEW_SEGMENT_ADDRESS_SPAN% )"/>
139 <set_variable variable=
"EXCEPTIONS_SEGMENT" to=
"%MODULE_SLAVE_NAME%"/>
143 <set_variable variable=
"PHYSICAL_END"
144 to=
"add( %BASE_ADDRESS%, %ADDRESS_SPAN% )"/>
145 <set_variable variable=
"PARTITION_ADDRESS_LIST"
146 to='list_add( %PARTITION_ADDRESS_LIST%, %PHYSICAL_END% )'
/>
147 <set_variable variable=
"MEMORY_RANGE_LIST"
148 to='list_add( %MEMORY_RANGE_LIST%,
"(%BASE_ADDRESS%,%PHYSICAL_END%)" )'
/>
151 <![CDATA[#define HAL_NIOS2_PARTITION_BASE_]]
>%MODULE_SLAVE_NAME% %BASE_ADDRESS%
152 <![CDATA[#define HAL_NIOS2_PARTITION_LEN_]]
>%MODULE_SLAVE_NAME% %ADDRESS_SPAN%
157 #define _HAL_NIOS2_PARTITION_BASE(p) HAL_NIOS2_PARTITION_BASE_##p
158 #define HAL_NIOS2_PARTITION_BASE(p) _HAL_NIOS2_PARTITION_BASE(p)
159 #define _HAL_NIOS2_PARTITION_LEN(p) HAL_NIOS2_PARTITION_LEN_##p
160 #define HAL_NIOS2_PARTITION_LEN(p) _HAL_NIOS2_PARTITION_LEN(p)
162 #define CYGMEM_REGION_ram HAL_NIOS2_PARTITION_BASE(CYGHWR_HAL_NIOS2_RWDATA_REGION)
163 #define CYGMEM_REGION_ram_SIZE HAL_NIOS2_PARTITION_LEN(CYGHWR_HAL_NIOS2_RWDATA_REGION)
164 #define CYGMEM_REGION_ram_ATTR (CYGMEM_REGION_ATTR_R | CYGMEM_REGION_ATTR_W)
165 #ifndef __ASSEMBLER__
166 extern char CYG_LABEL_NAME (__heap1) [];
168 #define CYGMEM_SECTION_heap1 (CYG_LABEL_NAME (__heap1))
169 #define CYGMEM_SECTION_heap1_SIZE (CYGMEM_REGION_ram + CYGMEM_REGION_ram_SIZE - CYGNUM_HAL_COMMON_INTERRUPTS_STACK_SIZE - (size_t) CYG_LABEL_NAME (__heap1))