1 ##############################################################################
\r
3 # (c) Copyright 2011 Xilinx, Inc. All rights reserved.
\r
5 # This file contains confidential and proprietary information of Xilinx, Inc.
\r
6 # and is protected under U.S. and international copyright and other
\r
7 # intellectual property laws.
\r
10 # This disclaimer is not a license and does not grant any rights to the
\r
11 # materials distributed herewith. Except as otherwise provided in a valid
\r
12 # license issued to you by Xilinx, and to the maximum extent permitted by
\r
13 # applicable law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND WITH ALL
\r
14 # FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, EXPRESS,
\r
15 # IMPLIED, OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF
\r
16 # MERCHANTABILITY, NON-INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE;
\r
17 # and (2) Xilinx shall not be liable (whether in contract or tort, including
\r
18 # negligence, or under any other theory of liability) for any loss or damage
\r
19 # of any kind or nature related to, arising under or in connection with these
\r
20 # materials, including for any direct, or any indirect, special, incidental,
\r
21 # or consequential loss or damage (including loss of data, profits, goodwill,
\r
22 # or any type of loss or damage suffered as a result of any action brought by
\r
23 # a third party) even if such damage or loss was reasonably foreseeable or
\r
24 # Xilinx had been advised of the possibility of the same.
\r
26 # CRITICAL APPLICATIONS
\r
27 # Xilinx products are not designed or intended to be fail-safe, or for use in
\r
28 # any application requiring fail-safe performance, such as life-support or
\r
29 # safety devices or systems, Class III medical devices, nuclear facilities,
\r
30 # applications related to the deployment of airbags, or any other applications
\r
31 # that could lead to death, personal injury, or severe property or
\r
32 # environmental damage (individually and collectively, "Critical
\r
33 # Applications"). Customer assumes the sole risk and liability of any use of
\r
34 # Xilinx products in Critical Applications, subject only to applicable laws
\r
35 # and regulations governing limitations on product liability.
\r
37 # THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS PART OF THIS FILE
\r
40 # This file is part of FreeRTOS.
\r
42 # $Id: freertos_v2_1_0.tcl,v 1.1.2.8 2010/12/10 07:27:08 svemula Exp $
\r
43 ###############################################################################
\r
45 # standalone bsp version. set this to the latest "ACTIVE" version.
\r
46 set standalone_version standalone_v3_01_a
\r
48 proc kernel_drc {os_handle} {
\r
49 set sw_proc_handle [xget_libgen_proc_handle]
\r
50 set hw_proc_handle [xget_handle $sw_proc_handle "IPINST"]
\r
51 set proctype [xget_value $hw_proc_handle "OPTION" "IPNAME"]
\r
52 set compiler [xget_value $sw_proc_handle "PARAMETER" "COMPILER"]
\r
54 # check for valid compiler
\r
55 if { [string first "mb-gcc" $compiler] == 0 && [string first "mb-g++" $compiler] == 0} {
\r
56 error "Wrong compiler requested. FreeRTOS can be compiled only with the GNU compiler for MicroBlaze." "" "mdt_error"
\r
59 # check for valid stdio parameters
\r
60 set stdin [xget_value $os_handle "PARAMETER" "STDIN"]
\r
61 set stdout [xget_value $os_handle "PARAMETER" "STDOUT"]
\r
62 if { $stdin == "none" || $stdout == "none" } {
\r
63 error "The STDIN/STDOUT parameters are not set. FreeRTOS requires stdin/stdout to be set." "" "mdt_error"
\r
66 # check if the design has a intc
\r
67 set intr_port [xget_value $hw_proc_handle "PORT" "Interrupt"]
\r
68 if { [llength $intr_port] == 0 } {
\r
69 error "CPU has no connection to Interrupt controller." "" "mdt_error"
\r
72 # support only AXI/PLB
\r
73 set interconnect [xget_value $hw_proc_handle "PARAMETER" "C_INTERCONNECT"]
\r
74 if { $interconnect == 1 } {
\r
75 set bus_name [xget_hw_busif_value $hw_proc_handle "DPLB"]
\r
76 } elseif { $interconnect == 2 } {
\r
77 set bus_name [xget_hw_busif_value $hw_proc_handle "M_AXI_DP"]
\r
79 error "FreeRTOS supports Microblaze with only a AXI or PLB interconnect" "" "mdt_error"
\r
82 # obtain handles to all the peripherals in the design
\r
83 set mhs_handle [xget_hw_parent_handle $hw_proc_handle]
\r
84 set slave_ifs [xget_hw_connected_busifs_handle $mhs_handle $bus_name "slave"]
\r
86 set timer_has_intr 0
\r
88 # check for a valid timer
\r
89 foreach if $slave_ifs {
\r
90 set ip_handle [xget_hw_parent_handle $if]
\r
92 if {$ip_handle != $hw_proc_handle} {
\r
93 set type [xget_hw_value $ip_handle]
\r
94 if { $type == "xps_timer" || $type == "axi_timer" } {
\r
97 # check if the timer interrupts are enabled
\r
98 set intr_port [xget_value $ip_handle "PORT" "Interrupt"]
\r
99 if { [llength $intr_port] != 0 } {
\r
100 set timer_has_intr 1
\r
106 if { $timer_count == 0 } {
\r
107 error "FreeRTOS for Microblaze requires an axi_timer or xps_timer. The HW platform doesn't have a valid timer." "" "mdt_error"
\r
110 if { $timer_has_intr == 0 } {
\r
111 error "FreeRTOS for Microblaze requires interrupts enabled for a timer." "" "mdt_error"
\r
114 set systmr_interval_ms [xget_value $os_handle "PARAMETER" "systmr_interval"]
\r
115 if { $systmr_interval_ms <= 0 } {
\r
116 error "Invalid value for parameter systmr_interval specified. Please specify a positive value." "" "mdt_error"
\r
119 ### ToDo: Add DRC specific to FreeRTOS
\r
122 proc generate {os_handle} {
\r
124 variable standalone_version
\r
126 set sw_proc_handle [xget_libgen_proc_handle]
\r
127 set hw_proc_handle [xget_handle $sw_proc_handle "IPINST"]
\r
128 set proctype [xget_value $hw_proc_handle "OPTION" "IPNAME"]
\r
129 set procver [xget_value $hw_proc_handle "PARAMETER" "HW_VER"]
\r
131 set need_config_file "false"
\r
133 # proctype should be "microblaze"
\r
134 set mbsrcdir "../${standalone_version}/src/microblaze"
\r
135 set commondir "../${standalone_version}/src/common"
\r
136 set datadir "../${standalone_version}/data"
\r
138 foreach entry [glob -nocomplain [file join $commondir *]] {
\r
139 file copy -force $entry [file join ".." "${standalone_version}" "src"]
\r
142 # proctype should be "microblaze"
\r
143 switch -regexp $proctype {
\r
146 foreach entry [glob -nocomplain [file join $mbsrcdir *]] {
\r
147 if { [string first "microblaze_interrupt_handler" $entry] == -1 } { ;# Do not copy over the Standalone BSP exception handler
\r
148 file copy -force $entry [file join ".." "${standalone_version}" "src"]
\r
151 set need_config_file "true"
\r
153 "default" {puts "unknown processor type $proctype\n"}
\r
156 # Write the config.make file
\r
157 set makeconfig [open "../standalone_v3_01_a/src/config.make" w]
\r
158 xprint_generated_header_tcl $makeconfig "Configuration parameters for Standalone Makefile"
\r
160 if { $proctype == "microblaze" } {
\r
161 if { [mb_has_exceptions $hw_proc_handle] } {
\r
162 puts $makeconfig "LIBSOURCES = *.s *.c *.S"
\r
164 puts $makeconfig "LIBSOURCES = *.s *.c"
\r
168 puts $makeconfig "LIBS = standalone_libs"
\r
171 # Remove microblaze directories...
\r
172 file delete -force $mbsrcdir
\r
174 # copy required files to the main src directory
\r
175 file copy -force [file join src Source tasks.c] src
\r
176 file copy -force [file join src Source queue.c] src
\r
177 file copy -force [file join src Source list.c] src
\r
178 file copy -force [file join src Source timers.c] src
\r
179 file copy -force [file join src Source portable MemMang heap_3.c] src
\r
180 file copy -force [file join src Source portable GCC MicroBlazeV8 port.c] src
\r
181 file copy -force [file join src Source portable GCC MicroBlazeV8 port_exceptions.c] src
\r
182 file copy -force [file join src Source portable GCC MicroBlazeV8 portasm.S] src
\r
183 file copy -force [file join src Source portable GCC MicroBlazeV8 portmacro.h] src
\r
184 set headers [glob -join ./src/Source/include *.\[h\]]
\r
185 foreach header $headers {
\r
186 file copy -force $header src
\r
189 file delete -force [file join src Source]
\r
190 file delete -force [file join src Source]
\r
192 # Handle stdin and stdout
\r
193 xhandle_stdin $os_handle
\r
194 xhandle_stdout $os_handle
\r
196 # Create config file for microblaze interrupt handling
\r
197 if {[string compare -nocase $need_config_file "true"] == 0} {
\r
198 xhandle_mb_interrupts
\r
201 # Create config files for Microblaze exception handling
\r
202 if { $proctype == "microblaze" && [mb_has_exceptions $hw_proc_handle] } {
\r
203 xcreate_mb_exc_config_file
\r
206 # Create bspconfig file
\r
207 set bspcfg_fn [file join ".." "${standalone_version}" "src" "bspconfig.h"]
\r
208 file delete $bspcfg_fn
\r
209 set bspcfg_fh [open $bspcfg_fn w]
\r
210 xprint_generated_header $bspcfg_fh "Configurations for Standalone BSP"
\r
212 if { $proctype == "microblaze" && [mb_has_pvr $hw_proc_handle] } {
\r
214 set pvr [xget_value $hw_proc_handle "PARAMETER" "C_PVR"]
\r
218 puts $bspcfg_fh "#define MICROBLAZE_PVR_NONE"
\r
221 puts $bspcfg_fh "#define MICROBLAZE_PVR_BASIC"
\r
224 puts $bspcfg_fh "#define MICROBLAZE_PVR_FULL"
\r
227 puts $bspcfg_fh "#define MICROBLAZE_PVR_NONE"
\r
234 # ToDO: FreeRTOS does not handle the following, refer xilkernel TCL script
\r
237 set config_file [xopen_new_include_file "./src/FreeRTOSConfig.h" "FreeRTOS Configuration parameters"]
\r
238 puts $config_file "\#include \"xparameters.h\" \n"
\r
240 set val [xget_value $os_handle "PARAMETER" "use_preemption"]
\r
241 if {$val == "false"} {
\r
242 xput_define $config_file "configUSE_PREEMPTION" "0"
\r
244 xput_define $config_file "configUSE_PREEMPTION" "1"
\r
247 set val [xget_value $os_handle "PARAMETER" "use_mutexes"]
\r
248 if {$val == "false"} {
\r
249 xput_define $config_file "configUSE_MUTEXES" "0"
\r
251 xput_define $config_file "configUSE_MUTEXES" "1"
\r
254 set val [xget_value $os_handle "PARAMETER" "use_recursive_mutexes"]
\r
255 if {$val == "false"} {
\r
256 xput_define $config_file "configUSE_RECURSIVE_MUTEXES" "0"
\r
258 xput_define $config_file "configUSE_RECURSIVE_MUTEXES" "1"
\r
261 set val [xget_value $os_handle "PARAMETER" "use_counting_semaphores"]
\r
262 if {$val == "false"} {
\r
263 xput_define $config_file "configUSE_COUNTING_SEMAPHORES" "0"
\r
265 xput_define $config_file "configUSE_COUNTING_SEMAPHORES" "1"
\r
268 set val [xget_value $os_handle "PARAMETER" "use_timers"]
\r
269 if {$val == "false"} {
\r
270 xput_define $config_file "configUSE_TIMERS" "0"
\r
272 xput_define $config_file "configUSE_TIMERS" "1"
\r
275 set val [xget_value $os_handle "PARAMETER" "use_idle_hook"]
\r
276 if {$val == "false"} {
\r
277 xput_define $config_file "configUSE_IDLE_HOOK" "0"
\r
279 xput_define $config_file "configUSE_IDLE_HOOK" "1"
\r
282 set val [xget_value $os_handle "PARAMETER" "use_tick_hook"]
\r
283 if {$val == "false"} {
\r
284 xput_define $config_file "configUSE_TICK_HOOK" "0"
\r
286 xput_define $config_file "configUSE_TICK_HOOK" "1"
\r
289 set val [xget_value $os_handle "PARAMETER" "use_malloc_failed_hook"]
\r
290 if {$val == "false"} {
\r
291 xput_define $config_file "configUSE_MALLOC_FAILED_HOOK" "0"
\r
293 xput_define $config_file "configUSE_MALLOC_FAILED_HOOK" "1"
\r
296 set val [xget_value $os_handle "PARAMETER" "use_trace_facility"]
\r
297 if {$val == "false"} {
\r
298 xput_define $config_file "configUSE_TRACE_FACILITY" "0"
\r
300 xput_define $config_file "configUSE_TRACE_FACILITY" "1"
\r
303 xput_define $config_file "configUSE_16_BIT_TICKS" "0"
\r
304 xput_define $config_file "configUSE_APPLICATION_TASK_TAG" "0"
\r
305 xput_define $config_file "configUSE_CO_ROUTINES" "0"
\r
307 # System timer tick rate (Microblaze only. kernel DRC ensures this)
\r
308 set systmr_interval [xget_value $os_handle "PARAMETER" "systmr_interval"]
\r
309 xput_define $config_file "configTICK_RATE_HZ" $systmr_interval
\r
311 set max_priorities [xget_value $os_handle "PARAMETER" "max_priorities"]
\r
312 xput_define $config_file "configMAX_PRIORITIES" $max_priorities
\r
313 xput_define $config_file "configMAX_CO_ROUTINE_PRIORITIES" "2"
\r
315 set min_stack [xget_value $os_handle "PARAMETER" "minimal_stack_size"]
\r
316 set min_stack [expr [expr $min_stack + 3] & 0xFFFFFFFC]
\r
317 xput_define $config_file "configMINIMAL_STACK_SIZE" $min_stack
\r
319 set total_heap_size [xget_value $os_handle "PARAMETER" "total_heap_size"]
\r
320 set total_heap_size [expr [expr $total_heap_size + 3] & 0xFFFFFFFC]
\r
321 xput_define $config_file "configTOTAL_HEAP_SIZE" $total_heap_size
\r
323 set max_task_name_len [xget_value $os_handle "PARAMETER" "max_task_name_len"]
\r
324 xput_define $config_file "configMAX_TASK_NAME_LEN" $max_task_name_len
\r
326 set val [xget_value $os_handle "PARAMETER" "idle_yield"]
\r
327 if {$val == "false"} {
\r
328 xput_define $config_file "configIDLE_SHOULD_YIELD" "0"
\r
330 xput_define $config_file "configIDLE_SHOULD_YIELD" "1"
\r
333 set val [xget_value $os_handle "PARAMETER" "check_for_stack_overflow"]
\r
334 if {$val == "false"} {
\r
335 xput_define $config_file "configCHECK_FOR_STACK_OVERFLOW" "0"
\r
337 xput_define $config_file "configCHECK_FOR_STACK_OVERFLOW" "2"
\r
340 set val [xget_value $os_handle "PARAMETER" "queue_registry_size"]
\r
341 if {$val == "false"} {
\r
342 xput_define $config_file "configQUEUE_REGISTRY_SIZE" "0"
\r
344 xput_define $config_file "configQUEUE_REGISTRY_SIZE" "10"
\r
347 xput_define $config_file "configGENERATE_RUN_TIME_STATS" "0"
\r
349 set val [xget_value $os_handle "PARAMETER" "timer_task_priority"]
\r
350 if {$val == "false"} {
\r
351 xput_define $config_file "configTIMER_TASK_PRIORITY" "0"
\r
353 xput_define $config_file "configTIMER_TASK_PRIORITY" "10"
\r
356 set val [xget_value $os_handle "PARAMETER" "timer_command_queue_length"]
\r
357 if {$val == "false"} {
\r
358 xput_define $config_file "configTIMER_QUEUE_LENGTH" "0"
\r
360 xput_define $config_file "configTIMER_QUEUE_LENGTH" "10"
\r
363 set val [xget_value $os_handle "PARAMETER" "timer_task_stack_depth"]
\r
364 if {$val == "false"} {
\r
365 xput_define $config_file "configTIMER_TASK_STACK_DEPTH" "0"
\r
367 xput_define $config_file "configTIMER_TASK_STACK_DEPTH" $min_stack
\r
370 if { [mb_has_exceptions $hw_proc_handle] } {
\r
371 xput_define $config_file "configINSTALL_EXCEPTION_HANDLERS" "1"
\r
373 xput_define $config_file "configINSTALL_EXCEPTION_HANDLERS" "0"
\r
376 xput_define $config_file "configINTERRUPT_CONTROLLER_TO_USE" "XPAR_INTC_SINGLE_DEVICE_ID"
\r
378 xput_define $config_file "INCLUDE_vTaskCleanUpResources" "0"
\r
379 xput_define $config_file "INCLUDE_vTaskDelay" "1"
\r
380 xput_define $config_file "INCLUDE_vTaskDelayUntil" "1"
\r
381 xput_define $config_file "INCLUDE_vTaskDelete" "1"
\r
382 xput_define $config_file "INCLUDE_xTaskGetCurrentTaskHandle" "1"
\r
383 xput_define $config_file "INCLUDE_xTaskGetIdleTaskHandle" "1"
\r
384 xput_define $config_file "INCLUDE_xTaskGetSchedulerState" "1"
\r
385 xput_define $config_file "INCLUDE_xTimerGetTimerDaemonTaskHandle" "1"
\r
386 xput_define $config_file "INCLUDE_uxTaskGetStackHighWaterMark" "1"
\r
387 xput_define $config_file "INCLUDE_uxTaskPriorityGet" "1"
\r
388 xput_define $config_file "INCLUDE_vTaskPrioritySet" "1"
\r
389 xput_define $config_file "INCLUDE_xTaskResumeFromISR" "1"
\r
390 xput_define $config_file "INCLUDE_vTaskSuspend" "1"
\r
391 xput_define $config_file "INCLUDE_pcTaskGetTaskName" "1"
\r
392 xput_define $config_file "INCLUDE_xTaskGetIdleTaskHandle" "1"
\r
393 xput_define $config_file "INCLUDE_xTimerGetTimerDaemonTaskHandle" "1"
\r
395 # complete the header protectors
\r
396 puts $config_file "\#endif"
\r
400 proc xopen_new_include_file { filename description } {
\r
401 set inc_file [open $filename w]
\r
402 xprint_generated_header $inc_file $description
\r
403 set newfname [string map {. _} [lindex [split $filename {\/}] end]]
\r
404 puts $inc_file "\#ifndef _[string toupper $newfname]"
\r
405 puts $inc_file "\#define _[string toupper $newfname]\n\n"
\r
409 proc xadd_define { config_file os_handle parameter } {
\r
410 set param_value [xget_value $os_handle "PARAMETER" $parameter]
\r
411 puts $config_file "#define [string toupper $parameter] $param_value\n"
\r
413 # puts "creating #define [string toupper $parameter] $param_value\n"
\r
416 proc xput_define { config_file parameter param_value } {
\r
417 puts $config_file "#define $parameter $param_value\n"
\r
419 # puts "creating #define [string toupper $parameter] $param_value\n"
\r
422 # args field of the array
\r
423 proc xadd_extern_fname {initfile oshandle arrayname arg} {
\r
425 set arrhandle [xget_handle $oshandle "ARRAY" $arrayname]
\r
426 set elements [xget_handle $arrhandle "ELEMENTS" "*"]
\r
428 set max_count [llength $elements]
\r
430 foreach ele $elements {
\r
432 set arg_value [xget_value $ele "PARAMETER" $arg]
\r
433 puts $initfile "extern void $arg_value\(\)\;"
\r
438 # args is variable no - fields of the array
\r
439 proc xadd_struct {initfile oshandle structtype structname arrayname args} {
\r
441 set arrhandle [xget_handle $oshandle "ARRAY" $arrayname]
\r
442 set elements [xget_handle $arrhandle "ELEMENTS" "*"]
\r
444 set max_count [llength $elements]
\r
445 puts $initfile "struct $structtype $structname\[$max_count\] = \{"
\r
447 foreach ele $elements {
\r
449 puts -nonewline $initfile "\t\{"
\r
450 foreach field $args {
\r
451 set field_value [xget_value $ele "PARAMETER" $field]
\r
452 # puts "$arrayname ( $count )->$field is $field_value"
\r
453 puts -nonewline $initfile "$field_value"
\r
454 if { $field != [lindex $args end] } {
\r
455 puts -nonewline $initfile ","
\r
458 if {$count < $max_count} {
\r
459 puts $initfile "\},"
\r
461 puts $initfile "\}"
\r
464 puts $initfile "\}\;"
\r
467 # return the sum of all the arg field values in arrayname
\r
468 proc get_field_sum {oshandle arrayname arg} {
\r
470 set arrhandle [xget_handle $oshandle "ARRAY" $arrayname]
\r
471 set elements [xget_handle $arrhandle "ELEMENTS" "*"]
\r
473 set max_count [llength $elements]
\r
475 foreach ele $elements {
\r
476 set field_value [xget_value $ele "PARAMETER" $arg]
\r
477 set count [expr $field_value+$count]
\r
482 # return the sum of the product of field values in arrayname
\r
483 proc get_field_product_sum {oshandle arrayname field1 field2} {
\r
485 set arrhandle [xget_handle $oshandle "ARRAY" $arrayname]
\r
486 set elements [xget_handle $arrhandle "ELEMENTS" "*"]
\r
488 set max_count [llength $elements]
\r
490 foreach ele $elements {
\r
491 set field1_value [xget_value $ele "PARAMETER" $field1]
\r
492 set field2_value [xget_value $ele "PARAMETER" $field2]
\r
493 set incr_value [expr $field1_value*$field2_value]
\r
494 set count [expr $count+$incr_value]
\r
499 proc xhandle_mb_interrupts {} {
\r
501 set default_interrupt_handler "XNullHandler"
\r
502 set default_arg "XNULL"
\r
504 set source_interrupt_handler $default_interrupt_handler
\r
505 set source_handler_arg $default_arg
\r
507 # Handle the interrupt pin
\r
508 set sw_proc_handle [xget_libgen_proc_handle]
\r
509 set periph [xget_handle $sw_proc_handle "IPINST"]
\r
510 set source_ports [xget_interrupt_sources $periph]
\r
511 if {[llength $source_ports] > 1} {
\r
512 error "Too many interrupting ports on the MicroBlaze. Should only find 1" "" "libgen_error"
\r
516 if {[llength $source_ports] == 1} {
\r
517 set source_port [lindex $source_ports 0]
\r
518 if {[llength $source_port] != 0} {
\r
519 set source_port_name [xget_value $source_port "VALUE"]
\r
520 set source_periph [xget_handle $source_port "PARENT"]
\r
521 set source_name [xget_value $source_periph "NAME"]
\r
522 set source_driver [xget_sw_driver_handle_for_ipinst $sw_proc_handle $source_name]
\r
524 if {[string compare -nocase $source_driver ""] != 0} {
\r
525 set int_array [xget_handle $source_driver "ARRAY" "interrupt_handler"]
\r
526 if {[llength $int_array] != 0} {
\r
527 set int_array_elems [xget_handle $int_array "ELEMENTS" "*"]
\r
528 if {[llength $int_array_elems] != 0} {
\r
529 foreach int_array_elem $int_array_elems {
\r
530 set int_port [xget_value $int_array_elem "PARAMETER" "int_port"]
\r
531 if {[llength $int_port] != 0} {
\r
532 if {[string compare -nocase $int_port $source_port_name] == 0 } {
\r
533 set source_interrupt_handler [xget_value $int_array_elem "PARAMETER" "int_handler"]
\r
534 set source_handler_arg [xget_value $int_array_elem "PARAMETER" "int_handler_arg"]
\r
535 if {[string compare -nocase $source_handler_arg DEVICE_ID] == 0 } {
\r
536 set source_handler_arg [xget_name $source_periph "DEVICE_ID"]
\r
538 if {[string compare -nocase "global" [xget_port_type $source_port]] == 0} {
\r
539 set source_handler_arg $default_arg
\r
541 set source_handler_arg [xget_name $source_periph "C_BASEADDR"]
\r
554 # Generate microblaze_interrupts_g.c file...
\r
555 xcreate_mb_intr_config_file $source_interrupt_handler $source_handler_arg
\r
560 proc xcreate_mb_intr_config_file {handler arg} {
\r
562 set mb_table "MB_InterruptVectorTable"
\r
564 set filename [file join "../standalone_v3_01_a/src" "microblaze_interrupts_g.c"]
\r
565 file delete $filename
\r
566 set config_file [open $filename w]
\r
568 xprint_generated_header $config_file "Interrupt Handler Table for MicroBlaze Processor"
\r
570 puts $config_file "#include \"microblaze_interrupts_i.h\""
\r
571 puts $config_file "#include \"xparameters.h\""
\r
572 puts $config_file "\n"
\r
573 puts $config_file [format "extern void %s (void *);" $handler]
\r
574 puts $config_file "\n/*"
\r
575 puts $config_file "* The interrupt handler table for microblaze processor"
\r
576 puts $config_file "*/\n"
\r
577 puts $config_file [format "%sEntry %s\[\] =" $mb_table $mb_table]
\r
578 puts $config_file "\{"
\r
579 puts -nonewline $config_file [format "\{\t%s" $handler]
\r
580 puts -nonewline $config_file [format ",\n\t(void*) %s\}" $arg]
\r
581 puts -nonewline $config_file "\n\};"
\r
582 puts $config_file "\n"
\r
587 # -------------------------------------------
\r
588 # Tcl procedure xcreate_mb_exc_config file
\r
589 # -------------------------------------------
\r
590 proc xcreate_mb_exc_config_file { } {
\r
592 set hfilename [file join "src" "microblaze_exceptions_g.h"]
\r
593 file delete $hfilename
\r
594 set hconfig_file [open $hfilename w]
\r
596 xprint_generated_header $hconfig_file "Exception Handling Header for MicroBlaze Processor"
\r
598 puts $hconfig_file "\n"
\r
600 set sw_proc_handle [xget_libgen_proc_handle]
\r
601 set hw_proc_handle [xget_handle $sw_proc_handle "IPINST"]
\r
602 set procver [xget_value $hw_proc_handle "PARAMETER" "HW_VER"]
\r
604 if { ![mb_has_exceptions $hw_proc_handle]} { ;# NO exceptions are enabled
\r
605 close $hconfig_file ;# Do not generate any info in either the header or the C file
\r
609 puts $hconfig_file "\#define MICROBLAZE_EXCEPTIONS_ENABLED 1"
\r
610 if { [mb_can_handle_exceptions_in_delay_slots $procver] } {
\r
611 puts $hconfig_file "#define MICROBLAZE_CAN_HANDLE_EXCEPTIONS_IN_DELAY_SLOTS"
\r
614 close $hconfig_file
\r
617 # --------------------------------------
\r
618 # Tcl procedure post_generate
\r
619 # This proc removes from libxil.a the basic
\r
620 # and standalone BSP versions of
\r
621 # _interrupt_handler and _hw_exception_handler
\r
623 # --------------------------------------
\r
624 proc post_generate {os_handle} {
\r
625 set sw_proc_handle [xget_libgen_proc_handle]
\r
626 set hw_proc_handle [xget_handle $sw_proc_handle "IPINST"]
\r
627 set proctype [xget_value $hw_proc_handle "OPTION" "IPNAME"]
\r
628 set procname [xget_value $hw_proc_handle "NAME"]
\r
630 set procdrv [xget_sw_driver_handle_for_ipinst $sw_proc_handle $procname]
\r
631 set archiver [xget_value $procdrv "PARAMETER" "archiver"]
\r
633 if {[string compare -nocase $proctype "microblaze"] == 0 } {
\r
634 # Remove _interrupt_handler.o from libxil.a for FreeRTOS
\r
635 set libxil_a [file join .. .. lib libxil.a]
\r
636 exec $archiver -d $libxil_a _interrupt_handler.o
\r
638 # We have linkage problems due to how these platforms are defined. Can't do this right now.
\r
639 # # Remove _exception_handler.o from libxil.a for FreeRTOS
\r
640 # exec bash -c "$archiver -d ../../lib/libxil.a _exception_handler.o"
\r
642 # Remove _hw_exception_handler.o from libxil.a for microblaze cores with exception support
\r
643 if {[mb_has_exceptions $hw_proc_handle]} {
\r
644 exec $archiver -d ../../lib/libxil.a _hw_exception_handler.o
\r
649 # --------------------------------------
\r
650 # Tcl procedure execs_generate
\r
651 # This proc removes from libxil.a all
\r
652 # the stuff that we are overriding
\r
654 # We currently override,
\r
656 # - Dummy _interrupt_hander and _hw_exception_handler
\r
657 # (in post_generate)
\r
659 # - xvectors.o; sleep.o (IF config_time is true)
\r
660 # Common to all processors
\r
662 # --------------------------------------
\r
663 proc execs_generate {os_handle} {
\r
664 set sw_proc_handle [xget_libgen_proc_handle]
\r
665 set hw_proc_handle [xget_handle $sw_proc_handle "IPINST"]
\r
666 set proctype [xget_value $hw_proc_handle "OPTION" "IPNAME"]
\r
667 set procname [xget_value $hw_proc_handle "NAME"]
\r
669 set procdrv [xget_sw_driver_handle_for_ipinst $sw_proc_handle $procname]
\r
670 # Remove _interrupt_handler.o from libxil.a for mb-gcc
\r
671 set archiver [xget_value $procdrv "PARAMETER" "archiver"]
\r
673 set libxil_a [file join .. .. lib libxil.a]
\r
674 # exec $archiver -d $libxil_a errno.o
\r
676 # We have linkage problems due to how these platforms are defined. Can't do this right now.
\r
677 # exec "$archiver -d $libxil_a microblaze_interrupt_handler.o"
\r
680 # --------------------------------------
\r
681 # Return true if this MB has
\r
682 # exception handling support
\r
683 # --------------------------------------
\r
684 proc mb_has_exceptions { hw_proc_handle } {
\r
686 # Check if the following parameters exist on this MicroBlaze's MPD
\r
687 set ee [xget_value $hw_proc_handle "PARAMETER" "C_UNALIGNED_EXCEPTIONS"]
\r
692 set ee [xget_value $hw_proc_handle "PARAMETER" "C_ILL_OPCODE_EXCEPTION"]
\r
697 set ee [xget_value $hw_proc_handle "PARAMETER" "C_IOPB_BUS_EXCEPTION"]
\r
702 set ee [xget_value $hw_proc_handle "PARAMETER" "C_DOPB_BUS_EXCEPTION"]
\r
707 set ee [xget_value $hw_proc_handle "PARAMETER" "C_DIV_BY_ZERO_EXCEPTION"]
\r
712 set ee [xget_value $hw_proc_handle "PARAMETER" "C_DIV_ZERO_EXCEPTION"]
\r
717 set ee [xget_value $hw_proc_handle "PARAMETER" "C_FPU_EXCEPTION"]
\r
722 set ee [xget_value $hw_proc_handle "PARAMETER" "C_USE_MMU"]
\r
723 if { $ee != "" && $ee != 0 } {
\r
730 # --------------------------------------
\r
731 # Return true if this MB has
\r
732 # FPU exception handling support
\r
733 # --------------------------------------
\r
734 proc mb_has_fpu_exceptions { hw_proc_handle } {
\r
736 # Check if the following parameters exist on this MicroBlaze's MPD
\r
737 set ee [xget_value $hw_proc_handle "PARAMETER" "C_FPU_EXCEPTION"]
\r
745 # --------------------------------------
\r
746 # Return true if this MB has PVR support
\r
747 # --------------------------------------
\r
748 proc mb_has_pvr { hw_proc_handle } {
\r
750 # Check if the following parameters exist on this MicroBlaze's MPD
\r
751 set pvr [xget_value $hw_proc_handle "PARAMETER" "C_PVR"]
\r
752 if { $pvr != "" } {
\r
759 # --------------------------------------
\r
760 # Return true if MB ver 'procver' has
\r
761 # support for handling exceptions in
\r
763 # --------------------------------------
\r
764 proc mb_can_handle_exceptions_in_delay_slots { procver } {
\r
766 if { [string compare -nocase $procver "5.00.a"] >= 0 } {
\r
773 # --------------------------------------------------------------------------
\r
774 # Gets all the handles that are memory controller cores.
\r
775 # --------------------------------------------------------------------------
\r
776 proc xget_memory_controller_handles { mhs } {
\r
779 # Gets all MhsInsts in the system
\r
780 set mhsinsts [xget_hw_ipinst_handle $mhs "*"]
\r
782 # Loop thru each MhsInst and determine if have "ADDR_TYPE = MEMORY" in
\r
784 foreach mhsinst $mhsinsts {
\r
785 # Gets all parameters of the component
\r
786 set params [xget_hw_parameter_handle $mhsinst "*"]
\r
788 # Loop thru each param and find tag "ADDR_TYPE = MEMORY"
\r
789 foreach param $params {
\r
792 } elseif {$param == ""} {
\r
795 set addrTypeValue [ xget_hw_subproperty_value $param "ADDR_TYPE" ]
\r
797 # Found tag! Add MhsInst to list and break to go to next MhsInst
\r
798 if {[string compare -nocase $addrTypeValue "MEMORY"] == 0} {
\r
799 lappend ret_list $mhsinst
\r