GeMRTOS
callbacks.tcl
Go to the documentation of this file.
1 #
2 # callbacks.tcl
3 #
4 # This script is set as a callback in the components _sw.tcl file.
5 # It is set using the command: 'set_sw_property callback_source_file callbacks.tcl'
6 #
7 
8 
9 # Query number of shadows register sets for the CPU
10 set cpu_name [get_cpu_name]
11 
12 
13 ## ---------------------------------
14 #| * callback *
15 #| This is a callback proc set in the _sw.tcl file.
16 #| The callback is called from a context that maintains a reference to an
17 #| individual SOPC module instance, that uses the software element defined in
18 #| the _sw.tcl.
19 #| It is set using the command: 'set_sw_property initialization_callback initialize'
20 #|
21 #| Initialize the default value for the following settings (per VIC instance):
22 #| - VEC_SIZE
23 #| - VEC_TBL_BASE
24 #|
25 #| args 0 : module instance name
26 #|
27 proc initialize { args } {
28 
29 }
30 
31 ## ---------------------------------
32 #| * callback *
33 #| This is a callback proc set in the _sw.tcl file.
34 #| The callback is called from a context that maintains a reference to an
35 #| individual SOPC module instance, that uses the software element defined in
36 #| the _sw.tcl.
37 #| It is set using the command: 'set_sw_property initialization_callback generate'
38 #|
39 #|
40 #|
41 #| args 0 : module instance name
42 #| args 1 : path to the BSP directory
43 #| args 2 : driver sub directory
44 #|
45 proc generate { args } {
46 
47  if {[llength $args] < 3} {
48  error "Insufficient arguments for generate callback proc (expected 3, received [llength $args])."
49  }
50 
51  set module_name [get_module_name]
52  set NPROCESSORS [ get_module_assignment "embeddedsw.CMacro.NPROCESSORS" ]
53 
54  # #########################
55  add_module_systemh_line $module_name [ get_module_assignment "embeddedsw.CMacro.NPROCESSORS" ]
56  add_module_systemh_line $module_name [ get_module_assignment "embeddedsw.CMacro.PRESCALE" ]
57  add_module_systemh_line $module_name [ get_module_assignment "embeddedsw.CMacro.GRTOSFREQUENCY" ]
58  add_module_systemh_line $module_name [ get_module_assignment "embeddedsw.CMacro.GRTOSINTERRUPTS" ]
59  add_module_systemh_line $module_name [ get_module_assignment "embeddedsw.CMacro.GRTOSGENERATIONID" ]
60  add_module_systemh_line $module_name \"[ get_module_assignment "embeddedsw.CMacro.PROCESSOR_TYPE" ]\"
61  add_module_systemh_line $module_name \"[ get_module_assignment "embeddedsw.CMacro.INSTRUCTION_CACHE_SIZE" ]\"
62  add_module_systemh_line $module_name \"[ get_module_assignment "embeddedsw.CMacro.INSTRUCTION_CACHE_BURST" ]\"
63  add_module_systemh_line $module_name \"[ get_module_assignment "embeddedsw.CMacro.ENABLE_HPS_MAP_ACCESS" ]\"
64  add_module_systemh_line $module_name [ get_module_assignment "embeddedsw.CMacro.NIOS_CLOCK_FREQUENCY" ]
65  add_module_systemh_line $module_name [ get_module_assignment "embeddedsw.CMacro.BUS_CLOCK_FREQUENCY" ]
66  add_module_systemh_line $module_name [ get_module_assignment "embeddedsw.CMacro.BUS_WIDTH" ]
67  add_module_systemh_line $module_name [ get_module_assignment "embeddedsw.CMacro.EXTERNAL_MEMORY_SPAN" ]
68  add_module_systemh_line $module_name \"[ get_module_assignment "embeddedsw.CMacro.EXTERNAL_MEMORY_UNIT" ]\"
69 
70  add_class_systemh_line [ string toupper "NPROCESSORS" ] [ get_module_assignment "embeddedsw.CMacro.NPROCESSORS" ]
71  add_class_systemh_line [ string toupper "PRESCALE" ] [ get_module_assignment "embeddedsw.CMacro.PRESCALE" ]
72  add_class_systemh_line [ string toupper "GRTOSFREQUENCY" ] [ get_module_assignment "embeddedsw.CMacro.GRTOSFREQUENCY" ]
73  add_class_systemh_line [ string toupper "GRTOSINTERRUPTS" ] [ get_module_assignment "embeddedsw.CMacro.GRTOSINTERRUPTS" ]
74  add_class_systemh_line [ string toupper "GRTOSGENERATIONID" ] [ get_module_assignment "embeddedsw.CMacro.GRTOSGENERATIONID" ]
75  add_class_systemh_line [ string toupper "PROCESSOR_TYPE" ] \"[ get_module_assignment "embeddedsw.CMacro.PROCESSOR_TYPE" ]\"
76  add_class_systemh_line [ string toupper "INSTRUCTION_CACHE_SIZE" ] \"[ get_module_assignment "embeddedsw.CMacro.INSTRUCTION_CACHE_SIZE" ]\"
77  add_class_systemh_line [ string toupper "INSTRUCTION_CACHE_BURST" ] \"[ get_module_assignment "embeddedsw.CMacro.INSTRUCTION_CACHE_BURST" ]\"
78  add_class_systemh_line [ string toupper "ENABLE_HPS_MAP_ACCESS" ] \"[ get_module_assignment "embeddedsw.CMacro.ENABLE_HPS_MAP_ACCESS" ]\"
79  add_class_systemh_line [ string toupper "NIOS_CLOCK_FREQUENCY" ] [ get_module_assignment "embeddedsw.CMacro.NIOS_CLOCK_FREQUENCY" ]
80  add_class_systemh_line [ string toupper "BUS_CLOCK_FREQUENCY" ] [ get_module_assignment "embeddedsw.CMacro.BUS_CLOCK_FREQUENCY" ]
81  add_class_systemh_line [ string toupper "BUS_WIDTH" ] [ get_module_assignment "embeddedsw.CMacro.BUS_WIDTH" ]
82  add_class_systemh_line [ string toupper "EXTERNAL_MEMORY_SPAN" ] [ get_module_assignment "embeddedsw.CMacro.EXTERNAL_MEMORY_SPAN" ]
83  add_class_systemh_line [ string toupper "EXTERNAL_MEMORY_UNIT" ] \"[ get_module_assignment "embeddedsw.CMacro.EXTERNAL_MEMORY_UNIT" ]\"
84  # #########################
85 
86  set grtos_system_name [string map {_grtos_0 ""} $module_name]
87  set grtos_on_chip_memory1 ${grtos_system_name}_onchip_memory2_0
88 
89  add_class_systemh_line SYSTEM_NAME \"${grtos_system_name}\"
90 
91  add_class_systemh_line GRTOS_BASE [ string toupper ${grtos_system_name}_GRTOS_0_S_GLOBAL_BASE ]
92 
93  add_class_systemh_line GRTOS_MONITOR_BASE [ string toupper ${grtos_system_name}_GRTOS_0_S_PROCESSOR_MONITOR_BASE ]
94  add_class_systemh_line GRTOS_S_PROCESSOR1_IRQ_INTERRUPT_CONTROLLER_ID [ string toupper ${grtos_system_name}_GRTOS_0_S_PROCESSOR1_IRQ_INTERRUPT_CONTROLLER_ID ]
95  add_class_systemh_line GRTOS_S_PROCESSOR1_IRQ [ string toupper ${grtos_system_name}_GRTOS_0_S_PROCESSOR1_IRQ ]
96 
97 
98  for {set i 1} {$i <= $NPROCESSORS} {incr i} {
99  add_class_systemh_line GRTOS_PROCESSOR_BASE${i} [ string toupper ${grtos_system_name}_GRTOS_0_S_PROCESSOR${i}_BASE ]
100  }
101 
102  set list (int*)[ string toupper ${grtos_system_name}_GRTOS_0_S_PROCESSOR1_BASE ]
103  for {set i 2} {$i <= $NPROCESSORS} {incr i} {
104  set list ${list},(int*)[ string toupper ${grtos_system_name}_GRTOS_0_S_PROCESSOR${i}_BASE ]
105  }
106  add_class_systemh_line GRTOS_PROCESSOR_BASE (int*\[\])\{${list}\}
107 
108 
109  # Get BSP generate directory path
110  set bsp_dir [lindex $args 1]
111  set bsp_subdir [lindex $args 2]
112 
113 }
114 
115 ## ---------------------------------
116 #| * callback *
117 #| This is a callback proc set in the _sw.tcl file.
118 #| The callback is called from a context that maintains a reference to an
119 #| individual SOPC module instance, that uses the software element defined in
120 #| the _sw.tcl.
121 #| It is set using the command: 'set_sw_property initialization_callback validate'
122 #|
123 #| This callback validates the vector size, RIL, RRS and RNMI
124 #|
125 #| args 0 : module instance name
126 #|
127 proc validate { args } {
128 
129 }
130 
131 # Validate VEC_SIZE has one of these allowed values: 16, 32, 64, 128, 256, 512
132 proc sub_validate_vec_size { module_name } {
133 
134 }
135 
136 
137 
138 
139 # Add warning and lincense agreement to vector table file.
140 proc add_file_header { fp } {
141 
142  # Add warning
143  puts $fp "/*
144  * DO NOT MODIFY THIS FILE
145  *
146  * Changing this file will have subtle consequences
147  * which will almost certainly lead to a nonfunctioning
148  * system. If you do modify this file, be aware that your
149  * changes will be overwritten and lost when this file
150  * is generated again.
151  *
152  * DO NOT MODIFY THIS FILE
153  */"
154 
155  puts $fp "\n"
156 
157  # Add license agreement
158  puts $fp "/*
159  * License Agreement
160  *
161  * Copyright (c) 2009
162  * Altera Corporation, San Jose, California, USA.
163  * All rights reserved.
164  *
165  * Permission is hereby granted, free of charge, to any person obtaining a
166  * copy of this software and associated documentation files (the \"Software\"),
167  * to deal in the Software without restriction, including without limitation
168  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
169  * and/or sell copies of the Software, and to permit persons to whom the
170  * Software is furnished to do so, subject to the following conditions:
171  *
172  * The above copyright notice and this permission notice shall be included in
173  * all copies or substantial portions of the Software.
174  *
175  * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
176  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
177  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
178  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
179  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
180  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
181  * DEALINGS IN THE SOFTWARE.
182  *
183  * This agreement shall be governed in all respects by the laws of the State
184  * of California and by the laws of the United States of America.
185  */"
186 
187  puts $fp "\n"
188 }
189 
190 # ------------------------------------------------------------------------------
191 # VIC class callbacks
192 # ------------------------------------------------------------------------------
193 
194 #| * Callback *
195 #| This is a callback proc set in the _sw.tcl file.
196 #| This is a callback for the driver class defined by a _sw.tcl file for the driver element
197 #|
198 proc class_initialize { args } {
199 
200 }
201 
202 #| * Callback *
203 #| This is a callback proc set in the _sw.tcl file.
204 #| This is a callback for the driver class defined by a _sw.tcl file for the driver element
205 #|
206 proc class_validate { args } {
207 
208 }
209 
210 
211 # Validate RIL value in the allowed range, (RIL > 0) and
212 # (RIL <= ((1 << RIL_WIDTH) - 1))
213 proc sub_class_validate_ril { driver_name } {
214 
215 }
216 
217 
218 # Validate RRS value less than NUM_OF_SHADOW_REG_SETS and greater than 0
219 proc sub_class_validate_rrs { driver_name } {
220 
221 }
222 
223 # Validate RNMI across all the VIC instances:
224 # 1. If the particular interrupt sets as non-maskable interrupt (RNMI=1),
225 # no sharing register set with normal interrupts (interrupts with RNMI=0),
226 # but multiple NMIs can share same shadow register set.
227 # 2. Issue warning if any interrupt with NMI enabled is
228 # not the highest priority (RIL).
229 proc sub_class_validate_rnmi { driver_name module_list } {
230 
231 }
232 
233 # Validate "linker_section" is a valid linker section.
234 # Validate linker section's memory device is connected to data and instruction master.
235 # Validate linker section's memory device is writeable.
236 proc sub_class_validate_linker_section { driver_name } {
237 
238 }
239 
240 # Validate preemption
241 proc sub_class_validate_preemption { driver_name } {
242 
243 }
244 
245 # This proc returns a list of module instance name with specified driver name.
246 proc get_module_instance_list { driver_name } {
247 
248 }
249 
250 # Return 0 if any peripheral doesn't support preemption, else otherwise.
251 proc get_default_peripheral_preemption { driver_name } {
252 
253 }
254 
255 # Sort VIC list in controller ID order (ID 0 in first element).
256 proc sort_vic_order { vic_list } {
257 
258 }
259 
260 # Initialize default setting for RIL, RRS and RNMI for each interrupt in each VIC.
261 # 1. For each VIC, examining their RIL width, and then using the minimum RIL
262 # width of all VICs as maximum RIL value.
263 # 2. Priority order: IRQ port 0 on the VIC connected to the CPU (i.e: VIC 0) is
264 # highest priority, IRQ port (max) on VIC 0 is higher priority than IRQ 0 on
265 # VIC 1, and so on.
266 # 3. Decrement the RIL value (start with RIL max) after being assigned to each
267 # interrupt until you reach RIL = 1.
268 # 4. Uses the RIL values to assign shadow register sets, so that interrupts with
269 # same RIL have same register set number.
270 proc initialize_default_per_intr_settings { driver_name } {
271 
272 }
273 
274 # Get minimum and maximum RIL assigned to each register set.
275 proc get_ril_min_max_list { driver_name module_list } {
276 
277 }
278 
279 # Validate RILs assigned to each register set do not overlap with any other
280 # register set.
281 proc sub_class_validate_rrs_ril { driver_name module_list } {
282 
283 }
284 
285 # Examine the minimum RIL_WIDTH of all VICs and return the maximum RIL of this RIL_WIDTH.
286 proc get_ril_max { vic_list } {
287 
288 }
289 # End of file