xilkernel : added namespace for all HSI TCL commands.

Signed-off-by: Nava kishore Manne <navam@xilinx.com>
This commit is contained in:
Nava kishore Manne 2015-04-09 15:04:21 +05:30
parent 2ddc06574e
commit febf5d437d

View file

@ -36,20 +36,20 @@
###############################################################################
proc kernel_drc {os_handle} {
set sw_proc_handle [get_sw_processor]
set hw_proc_handle [get_cells [get_property HW_INSTANCE $sw_proc_handle]]
set sw_proc_handle [hsi::get_sw_processor]
set hw_proc_handle [hsi::get_cells [get_property HW_INSTANCE $sw_proc_handle]]
set proctype [get_property IP_NAME $hw_proc_handle]
set compiler [get_property CONFIG.compiler $sw_proc_handle]
# System timer frequency must be specified
set systmr_spec [get_property CONFIG.systmr_spec $os_handle]
if { $systmr_spec == "false" } {
error "ERROR: Xilkernel requires some or all of the parameters in the systmr_spec category to be defined. Please configure this categry as 'true'." "" "mdt_error"
}
}
set stacksiz [get_property CONFIG.pthread_stack_size $os_handle]
switch -regexp $proctype {
"microblaze" {
"microblaze" {
if { [string first "mb-gcc" $compiler] == 0 && [string first "mb-g++" $compiler] == 0} {
error "ERROR: Wrong compiler requested. Xilkernel can be compiled only with the GNU compiler for MicroBlaze." "" "mdt_error"
}
@ -58,7 +58,7 @@ proc kernel_drc {os_handle} {
if { $systmr_dev == "none" } {
error "ERROR: Xilkernel for Microblaze requires a system timer device to be specified. Please choose a valid peripheral instance in the systmr_dev parameter." "" "mdt_error"
}
set systmr_handle [get_cells $systmr_dev]
set systmr_handle [hsi::get_cells $systmr_dev]
set systmr_type [get_property IP_NAME $systmr_handle]
if { $systmr_type != "fit_timer" && $systmr_type != "opb_timer" && $systmr_type != "xps_timer" && $systmr_type != "axi_timer" } {
error "ERROR: Xilkernel for Microblaze can work only with an axi_timer, xps_timer, opb_timer or fit_timer. Please choose a valid device as the system timer with the parameter systmr_dev." "" "mdt_error"
@ -67,7 +67,7 @@ proc kernel_drc {os_handle} {
if { [expr $stacksiz % 4] != 0 } {
error "ERROR: pthread_stack_size must be a multiple of 4."
}
set procver [get_property CONFIG.HW_VER $hw_proc_handle]
}
ppc* {
@ -89,14 +89,14 @@ proc kernel_drc {os_handle} {
error "ERROR: System timer frequency not specified." "" "mdt_error"
}
set systmr_interval_ms [get_property CONFIG.systmr_interval $os_handle]
set systmr_interval_ms [get_property CONFIG.systmr_interval $os_handle]
if { $systmr_interval_ms <= 0 } {
error "ERROR: Invalid value for parameter systmr_interval specified. Please specify a positive value." "" "mdt_error"
}
set config_bufmalloc [get_property CONFIG.config_bufmalloc $os_handle]
set config_bufmalloc [get_property CONFIG.config_bufmalloc $os_handle]
if { $config_bufmalloc == "true" } {
set memtable_handle [get_arrays mem_table -of_objects $os_handle]
set memtable_handle [hsi::get_arrays mem_table -of_objects $os_handle]
#set memtable_elements [xget_handle $memtable_handle "ELEMENTS" "*"]
set memtable_elements [llength [get_property PARAM.mem_nblks $memtable_handle]]
foreach ele $memtable_elements {
@ -122,14 +122,14 @@ proc kernel_drc {os_handle} {
proc generate {os_handle} {
variable standalone_version
set sw_proc_handle [get_sw_processor]
set hw_proc_handle [get_cells [get_property HW_INSTANCE $sw_proc_handle]]
set sw_proc_handle [hsi::get_sw_processor]
set hw_proc_handle [hsi::get_cells [get_property HW_INSTANCE $sw_proc_handle]]
set proctype [get_property IP_NAME $hw_proc_handle]
set procver [get_property CONFIG.HW_VER $hw_proc_handle]
set need_config_file "false"
# proctype should be "microblaze"
# proctype should be "microblaze"
set mbsrcdir "../standalone/src/microblaze"
set ppcsrcdir "../standalone/src/ppc405"
set ppc440srcdir "../standalone/src/ppc440"
@ -139,12 +139,12 @@ proc generate {os_handle} {
foreach entry [glob -nocomplain [file join $commondir *]] {
file copy -force $entry [file join ".." "standalone" "src"]
}
# proctype should be "microblaze"
switch -regexp $proctype {
"microblaze" {
file copy -force "./src/Makefile_mb.sh" "./src/Makefile"
# proctype should be "microblaze"
switch -regexp $proctype {
"microblaze" {
file copy -force "./src/Makefile_mb.sh" "./src/Makefile"
foreach entry [glob -nocomplain [file join $mbsrcdir *]] {
if { [string first "hw_exception_handler" $entry] == -1 } { ;# Do not copy over the Standalone BSP exception handler
file copy -force $entry [file join ".." "standalone" "src"]
@ -157,12 +157,12 @@ proc generate {os_handle} {
file copy -force "./src/Makefile_ppc.sh" "./src/Makefile"
# Write the arch.make file
set makecpu [open "./src/cpu.make" w]
::hsm::utils::write_tcl_header $makecpu "Configuration parameters for PPC Xilkernel Makefile"
set makecpu [open "./src/cpu.make" w]
::hsi::utils::write_tcl_header $makecpu "Configuration parameters for PPC Xilkernel Makefile"
if { [string match -nocase ppc440* $proctype] } {
puts $makecpu "CPU_TYPE=440"
} else {
puts $makecpu "CPU_TYPE=405"
puts $makecpu "CPU_TYPE=405"
}
close $makecpu
@ -172,7 +172,7 @@ proc generate {os_handle} {
foreach entry [glob -nocomplain [file join $ppcsrcdir *]] {
if { [string first "xvectors" $entry] == -1 } { ;# Do not copy xvectors.S. Xilkernel provides its own.
file copy -force $entry [file join ".." "standalone" "src"]
file copy -force $entry [file join ".." "standalone" "src"]
}
}
}
@ -180,8 +180,8 @@ proc generate {os_handle} {
}
# Write the config.make file
set makeconfig [open "../standalone/src/config.make" w]
#::hsm::utils::write_tcl_header $makeconfig "Configuration parameters for Standalone Makefile"
set makeconfig [open "../standalone/src/config.make" w]
#::hsi::utils::write_tcl_header $makeconfig "Configuration parameters for Standalone Makefile"
if { $proctype == "microblaze" } {
if { [mb_has_exceptions $hw_proc_handle] } {
@ -192,15 +192,15 @@ proc generate {os_handle} {
}
puts $makeconfig "LIBS = standalone_libs"
close $makeconfig
# Remove microblaze directories...
file delete -force $mbsrcdir
file delete -force $ppcsrcdir
file delete -force $datadir
# Handle stdin and stdout
::hsm::utils::handle_stdin $os_handle
::hsm::utils::handle_stdout $os_handle
::hsi::utils::handle_stdin $os_handle
::hsi::utils::handle_stdout $os_handle
# Modify Makefile based on whether inbyte.c and outbyte.c been created
if {[file exists "./src/inbyte.c"] && [file exists "./src/inbyte.c"]} {
@ -224,7 +224,7 @@ proc generate {os_handle} {
puts $destination $line
}
}
close $destination
file delete "./src/Makefile"
@ -238,19 +238,19 @@ proc generate {os_handle} {
# Create config files for Microblaze exception handling
if { $proctype == "microblaze" && [mb_has_exceptions $hw_proc_handle] } {
xcreate_mb_exc_config_file
xcreate_mb_exc_config_file
}
# Create bspconfig file
set bspcfg_fn [file join ".." "standalone" "src" "bspconfig.h"]
set bspcfg_fn [file join ".." "standalone" "src" "bspconfig.h"]
file delete $bspcfg_fn
set bspcfg_fh [open $bspcfg_fn w]
::hsm::utils::write_c_header $bspcfg_fh "Configurations for Standalone BSP"
::hsi::utils::write_c_header $bspcfg_fh "Configurations for Standalone BSP"
if { $proctype == "microblaze" && [mb_has_pvr $hw_proc_handle] } {
set pvr [get_property CONFIG.C_PVR $hw_proc_handle]
switch $pvr {
"0" {
puts $bspcfg_fh "#define MICROBLAZE_PVR_NONE"
@ -264,19 +264,19 @@ proc generate {os_handle} {
"default" {
puts $bspcfg_fh "#define MICROBLAZE_PVR_NONE"
}
}
}
}
close $bspcfg_fh
set config_file [xopen_new_include_file "./src/include/os_config.h" "XilKernel Configuration parameters"]
set init_file [xopen_new_include_file "./src/include/config/config_init.h" "XilKernel Configuration parameters"]
::hsm::utils::write_c_header $init_file "LibXilKernel Initialization structures"
::hsi::utils::write_c_header $init_file "LibXilKernel Initialization structures"
puts $init_file "\#include <sys/init.h>"
puts $init_file "\#include <os_config.h>\n\n"
switch -regexp $proctype {
"microblaze" {
"microblaze" {
xput_define $config_file "MB_XILKERNEL" ""
if {[mb_has_exceptions $hw_proc_handle] } {
xput_define $config_file "CONFIG_HARDWARE_EXCEPTIONS" ""
@ -299,7 +299,7 @@ proc generate {os_handle} {
}
}
}
# Create defines and struct initializations
set config_debug_support [get_property CONFIG.config_debug_support $os_handle]
@ -321,7 +321,7 @@ proc generate {os_handle} {
if { $config_kill == "true" } {
xadd_define $config_file $os_handle "config_kill"
}
set config_yield [get_property CONFIG.config_yield $os_handle]
if { $config_yield == "true" } {
xadd_define $config_file $os_handle "config_yield"
@ -332,30 +332,30 @@ proc generate {os_handle} {
if { $config_elf_process == "true" } {
xadd_define $config_file $os_handle "config_elf_process"
xadd_define $config_file $os_handle "max_procs"
# Get the Entry Point address, priority for static ELF processes table
set static_elf_process_table_handle [get_arrays -of_objects $os_handle "static_elf_process_table"]
set static_elf_process_table_handle [hsi::get_arrays -of_objects $os_handle "static_elf_process_table"]
if { $static_elf_process_table_handle != "" } {
#SRI FIX THIS
set n_init_process [get_property SIZE $static_elf_process_table_handle]
set n_init_process [get_property SIZE $static_elf_process_table_handle]
xput_define $config_file "n_init_process" $n_init_process
xadd_define $config_file $os_handle "config_static_elf_process_support"
xadd_struct $init_file $os_handle "_process_init" "se_process_table" "static_elf_process_table" "process_start_addr" "process_prio"
}
}
}
}
set config_pthread [get_property CONFIG.config_pthread_support $os_handle]
if { $config_pthread == "true" } {
xadd_define $config_file $os_handle "config_pthread_support"
xadd_define $config_file $os_handle "max_pthreads"
xadd_define $config_file $os_handle "pthread_stack_size"
set static_pthread_table_handle [get_arrays static_pthread_table -of_objects $os_handle]
set static_pthread_table_handle [hsi::get_arrays static_pthread_table -of_objects $os_handle]
if { $static_pthread_table_handle != "" } {
#set n_init_self_pthreads [llength $static_pthread_table_handle]
set n_init_self_pthreads [llength [get_property PARAM.pthread_prio [get_arrays $static_pthread_table_handle -of_objects $os_handle]]]
set n_init_self_pthreads [llength [get_property PARAM.pthread_prio [hsi::get_arrays $static_pthread_table_handle -of_objects $os_handle]]]
#set n_init_self_pthreads [get_property CONFIG.static_pthread_table $os_handle]
if {$n_init_self_pthreads != "" } {
if {$n_init_self_pthreads != "" } {
xput_define $config_file "config_static_pthread_support" "true"
xput_define $config_file "n_init_self_pthreads" $n_init_self_pthreads
xadd_extern_fname $init_file $os_handle "static_pthread_table" "pthread_start_func"
@ -374,10 +374,10 @@ proc generate {os_handle} {
# System timer configuration (Microblaze only. kernel DRC ensures this)
set systmr_spec [get_property CONFIG.systmr_spec $os_handle]
if { $proctype == "microblaze" } {
if { $proctype == "microblaze" } {
set systmr_dev [get_property CONFIG.systmr_dev $os_handle]
set systmr_handle [get_cells $systmr_dev]
set systmr_type [get_property IP_NAME $systmr_handle]
set systmr_handle [hsi::get_cells $systmr_dev]
set systmr_type [get_property IP_NAME $systmr_handle]
}
if { $proctype == "microblaze" } {
@ -403,27 +403,27 @@ proc generate {os_handle} {
xput_define $config_file "SYSTMR_INTERVAL" $systmr_interval
xput_define $config_file "SYSTMR_CLK_FREQ" $systmr_freq
xput_define $config_file "SYSTMR_CLK_FREQ_KHZ" [expr $systmr_freq / 1000]
# Interrupt controller configuration
set sysintc_spec [get_property CONFIG.sysintc_spec $os_handle]
if { $sysintc_spec != "none" } {
xput_define $config_file "CONFIG_INTC" "true"
set sysintc_dev_handle [get_cells $sysintc_spec]
set sysintc_baseaddr [::hsm::utils::get_ip_param_name $sysintc_dev_handle "C_BASEADDR"]
set sysintc_device_id [::hsm::utils::get_ip_param_name $sysintc_dev_handle "DEVICE_ID"]
set sysintc_dev_handle [hsi::get_cells $sysintc_spec]
set sysintc_baseaddr [::hsi::utils::get_ip_param_name $sysintc_dev_handle "C_BASEADDR"]
set sysintc_device_id [::hsi::utils::get_ip_param_name $sysintc_dev_handle "DEVICE_ID"]
xput_define $config_file "sysintc_baseaddr" $sysintc_baseaddr
xput_define $config_file "sysintc_device_id" $sysintc_device_id
# Additionally for microblaze, figure out which interrupt
# Additionally for microblaze, figure out which interrupt
# input is the system timer interrupt and define its ID
if { $proctype == "microblaze" } {
set systmr_intr [get_pins -of_objects [get_cells $systmr_handle] Interrupt]
set systmr_intr [hsi::get_pins -of_objects [hsi::get_cells $systmr_handle] Interrupt]
#set systmr_intr [xget_value $systmr_handle "PORT" "Interrupt"]
if { [string compare -nocase $systmr_intr ""] == 0 } {
error "ERROR: System Timer Interrupt PORT is not specified" "" "mdt_error"
}
#set mhs_handle [get_cells -of_object $systmr_handle]
set intr_ports [::hsm::utils::get_sink_pins [get_pins -of_objects [get_cells $systmr_intr] INTERRUPT]]
#set mhs_handle [hsi::get_cells -of_object $systmr_handle]
set intr_ports [::hsi::utils::get_sink_pins [hsi::get_pins -of_objects [hsi::get_cells $systmr_intr] INTERRUPT]]
#set intr_ports [xget_connected_ports_handle $mhs_handle $systmr_intr "sink"]
foreach intr_port $intr_ports {
set intr_port_type [get_property TYPE $intr_port]
@ -431,20 +431,20 @@ proc generate {os_handle} {
continue
}
set intc_handle [get_cells -of_object $intr_port]
set intc_handle [hsi::get_cells -of_object $intr_port]
set intc_name [get_property NAME $intc_handle]
set proc_intc_handle [get_cells $intc_name]
set proc_intc_handle [hsi::get_cells $intc_name]
if { [string compare -nocase $sysintc_dev_handle $intc_handle] == 0 } {
continue
}
set systmr_intrpin [get_pins -of_objects [get_cells $systmr_handle] -filter "TYPE == INTERRUPT"]
set intr_id [::hsm::utils::get_port_intr_id $systmr_handle $systmr_intrpin]
set systmr_intrpin [hsi::get_pins -of_objects [hsi::get_cells $systmr_handle] -filter "TYPE == INTERRUPT"]
set intr_id [::hsi::utils::get_port_intr_id $systmr_handle $systmr_intrpin]
puts $config_file "#define SYSTMR_INTR_ID $intr_id\n"
}
}
}
set config_sched [get_property CONFIG.config_sched $os_handle]
if { $config_sched == "true" } {
xadd_define $config_file $os_handle "config_sched"
@ -458,7 +458,7 @@ proc generate {os_handle} {
}
xadd_define $config_file $os_handle "max_readyq"
}
set config_sema [get_property CONFIG.config_sema $os_handle]
if { $config_sema == "true" } {
xadd_define $config_file $os_handle "config_sema"
@ -482,16 +482,16 @@ proc generate {os_handle} {
xput_define $config_file "config_enhanced_msgq" "true"
xput_define $config_file "use_malloc" "true"
}
}
}
set config_shm [get_property CONFIG.config_shm $os_handle]
if { $config_shm == "true" } {
xadd_define $config_file $os_handle "config_shm"
set shm_handle [get_arrays -of_objects $os_handle "shm_table"]
set shm_handle [hsi::get_arrays -of_objects $os_handle "shm_table"]
if { $shm_handle == "" } {
error "ERROR: SHM configuration needs shm_table specification." "" "mdt_error"
}
set n_shm [llength [get_arrays $shm_handle -of_objects $os_handle]]
set n_shm [llength [hsi::get_arrays $shm_handle -of_objects $os_handle]]
xput_define $config_file "n_shm" $n_shm
set shm_msize [get_field_sum $os_handle "shm_table" "shm_size"]
xput_define $config_file "shm_msize" $shm_msize
@ -500,9 +500,9 @@ proc generate {os_handle} {
set config_bufmalloc [get_property CONFIG.config_bufmalloc $os_handle]
if { $config_bufmalloc == "true" } {
xadd_define $config_file $os_handle "config_bufmalloc"
xadd_define $config_file $os_handle "config_bufmalloc"
#set memtable_handle [xget_handle $os_handle "ARRAY" "mem_table"]
set memtable_elements [get_arrays -of_objects $os_handle "mem_table"]
set memtable_elements [hsi::get_arrays -of_objects $os_handle "mem_table"]
set n_static_bufs [llength $memtable_elements]
set max_bufs [get_property CONFIG.max_bufs $os_handle]
@ -512,22 +512,22 @@ proc generate {os_handle} {
xput_define $config_file "n_mbufs" [expr $max_bufs + $n_static_bufs]
xput_define $config_file "n_static_bufs" $n_static_bufs
xadd_struct $init_file $os_handle "bufmalloc_init_s" "bufmalloc_cfg" "mem_table" "mem_bsize" "mem_nblks"
}
}
set config_time [get_property CONFIG.config_time $os_handle]
if { $config_time == "true" } {
xadd_define $config_file $os_handle "config_time"
xadd_define $config_file $os_handle "config_time"
xadd_define $config_file $os_handle "max_tmrs"
}
#set config_stats [xget_value $os_handle "PARAMETER" "config_stats"]
#if { $config_stats == "true" } {
#if { $config_stats == "true" } {
# xadd_define $config_file $os_handle "config_stats"
#}
# Handle I/O ranges for MicroBlaze MPU here
if { $proctype == "microblaze" } {
#set mhs_handle [get_cells -of_object $hw_proc_handle]
#set mhs_handle [hsi::get_cells -of_object $hw_proc_handle]
set mmu [get_property CONFIG.C_USE_MMU $hw_proc_handle]
if { $mmu >= 2 } {
@ -540,36 +540,36 @@ proc generate {os_handle} {
} else {
set dbus_if_name "M_AXI_DP"
}
set dbus_name [::hsm::utils::get_intfnet_name $hw_proc_handle $dbus_if_name]
set dbus_handle [get_cells $dbus_name]
set dbus_name [::hsi::utils::get_intfnet_name $hw_proc_handle $dbus_if_name]
set dbus_handle [hsi::get_cells $dbus_name]
if { $interconnect == 2 } {
set dcachelink_handle [get_cells "DXCL"]
set dcachelink_handle [hsi::get_cells "DXCL"]
} else {
set dcachelink_handle [get_cells "M_AXI_DC"]
set dcachelink_handle [hsi::get_cells "M_AXI_DC"]
}
#set addrlist [xget_hw_bus_slave_addrpairs $dbus_handle]
set addrlists [get_mem_ranges -of_objects [get_cells $sw_proc_handle]]
set addrlists [hsi::get_mem_ranges -of_objects [hsi::get_cells $sw_proc_handle]]
set addrlist [list]
foreach addrist $addrlists {
set ip_name [get_property IP_NAME [get_cells $addrist]]
set ip_name [get_property IP_NAME [hsi::get_cells $addrist]]
if { $ip_name == "axi_emc" || $ip_name == "mig_7series" } {
set mem [lindex [get_mem_ranges $addrist] 0]
set mem [lindex [hsi::get_mem_ranges $addrist] 0]
set mc_base [get_property BASE_VALUE $mem]
set mc_high [get_property HIGH_VALUE $mem]
lappend addrlist $mc_base $mc_high
} else {
set mem [hsm::utils::get_ip_mem_ranges $addrist]
set mem [hsi::utils::get_ip_mem_ranges $addrist]
set mc_base [get_property BASE_VALUE $mem]
set mc_high [get_property HIGH_VALUE $mem]
lappend addrlist $mc_base $mc_high
}
}
if { $dcachelink_handle != "" } {
#set xcl_addrlist [xget_hw_bus_slave_addrpairs $dcachelink_handle]
set xcl_addrlist [get_mem_ranges -of_objects [get_cells $sw_proc_handle]]
set xcl_addrlist [hsi::get_mem_ranges -of_objects [hsi::get_cells $sw_proc_handle]]
set addrlist [concat addrlist xcl_addrlist]
}
@ -577,23 +577,23 @@ proc generate {os_handle} {
# Get the list of memory controllers in the mhs. We want to filter
# "memories" from the above addrlist
set memcon_handles [xget_memory_controller_handles [get_cells $sw_proc_handle]]
#set memcon_handles [get_mem_ranges -of_objects [get_cells $sw_proc_handle]]
set memcon_handles [xget_memory_controller_handles [hsi::get_cells $sw_proc_handle]]
#set memcon_handles [hsi::get_mem_ranges -of_objects [hsi::get_cells $sw_proc_handle]]
set n_ioranges 0
foreach {base high} $addrlist {
foreach {base high} $addrlist {
set skip 0
foreach {memcon_handle} $memcon_handles {
set memcon_addrlist [::hsm::utils::get_ip_mem_ranges $memcon_handle]
set memcon_addrlist [::hsi::utils::get_ip_mem_ranges $memcon_handle]
foreach mem_range $memcon_addrlist {
set mc_base [get_property BASE_VALUE $mem_range]
set mc_high [get_property HIGH_VALUE $mem_range]
if {$mc_base == $base && $mc_high == $high} {
set skip 1
}
}
}
if { $skip == 0 } {
# Don't add duplicates
set io_skip 0
@ -609,10 +609,10 @@ proc generate {os_handle} {
}
}
}
puts $config_file "#define XILKERNEL_IO_NRANGES $n_ioranges"
puts $init_file "xilkernel_io_range_t system_io_range\[XILKERNEL_IO_NRANGES\] = \{"
set count 0
foreach {base high} $io_addrlist {
set base [format "0x%X" $base]
@ -628,7 +628,7 @@ proc generate {os_handle} {
puts $init_file "\}\;"
}
}
# complete the header protectors
puts $config_file "\#endif"
close $config_file
@ -638,7 +638,7 @@ proc generate {os_handle} {
proc xopen_new_include_file { filename description } {
set inc_file [open $filename w]
::hsm::utils::write_c_header $inc_file $description
::hsi::utils::write_c_header $inc_file $description
set newfname [string map {. _} [lindex [split $filename {\/}] end]]
puts $inc_file "\#ifndef _[string toupper $newfname]"
puts $inc_file "\#define _[string toupper $newfname]\n\n"
@ -660,8 +660,8 @@ proc xput_define { config_file parameter param_value } {
# args field of the array
proc xadd_extern_fname {initfile oshandle arrayname arg} {
set arrahandle [get_arrays $arrayname -of_objects $oshandle]
proc xadd_extern_fname {initfile oshandle arrayname arg} {
set arrahandle [hsi::get_arrays $arrayname -of_objects $oshandle]
set elements [llength [get_property PARAM.$arg $arrahandle]]
foreach ele $elements {
set thread_names [get_property PARAM.$arg $arrahandle]
@ -669,18 +669,18 @@ proc xadd_extern_fname {initfile oshandle arrayname arg} {
puts $initfile "extern void $thread_name\(void\)\;"
}
}
puts $initfile ""
puts $initfile ""
}
# args is variable no - fields of the array
proc xadd_struct {initfile oshandle structtype structname arrayname args} {
proc xadd_struct {initfile oshandle structtype structname arrayname args} {
#set arrhandle [get_arrays $arrayname -of_objects $oshandle]
set arrhandle [get_arrays $arrayname -of_objects $oshandle]
#set arrhandle [hsi::get_arrays $arrayname -of_objects $oshandle]
set arrhandle [hsi::get_arrays $arrayname -of_objects $oshandle]
foreach arg $args {
set max_count [llength [get_property PARAM.$arg $arrhandle]]
}
#set elements [xget_handle $arrhandle "ELEMENTS" "*"]
set count 0
#set max_count [llength $elements]
@ -717,14 +717,14 @@ proc xadd_struct {initfile oshandle structtype structname arrayname args} {
# return the sum of all the arg field values in arrayname
proc get_field_sum {oshandle arrayname arg} {
proc get_field_sum {oshandle arrayname arg} {
#set arrhandle [get_arrays -of_objects $oshandle $arrayname]
set elements [get_arrays -of_objects $oshandle $arrayname]
#set arrhandle [hsi::get_arrays -of_objects $oshandle $arrayname]
set elements [hsi::get_arrays -of_objects $oshandle $arrayname]
#set elements [xget_handle $arrhandle "ELEMENTS" "*"]
set count 0
set max_count [llength $elements]
foreach ele $elements {
set field_value [get_property CONFIG.$arg $ele]
set count [expr $field_value+$count]
@ -733,16 +733,16 @@ proc get_field_sum {oshandle arrayname arg} {
}
# return the sum of the product of field values in arrayname
proc get_field_product_sum {oshandle arrayname field1 field2} {
proc get_field_product_sum {oshandle arrayname field1 field2} {
#set arrhandle [get_arrays -of_objects $oshandle $arrayname]
set elements [get_arrays -of_objects $oshandle $arrayname]
#set arrhandle [hsi::get_arrays -of_objects $oshandle $arrayname]
set elements [hsi::get_arrays -of_objects $oshandle $arrayname]
#set elements [xget_handle $arrhandle "ELEMENTS" "*"]
set count 0
set max_count [llength $elements]
set field1_list ""
set field2_list ""
foreach ele $elements {
#set field_value [get_property PARAM.$field $ele]
set field1_value [get_property PARAM.$field1 $ele]
@ -750,8 +750,8 @@ proc get_field_product_sum {oshandle arrayname field1 field2} {
set field2_value [get_property PARAM.$field2 $ele]
set field2_list $field2_value
}
for {set i 0} {$i < [llength $field1_value]} {incr i} {
for {set i 0} {$i < [llength $field1_value]} {incr i} {
set field1_valuee [lindex $field1_list $i]
set field2_valuee [lindex $field2_list $i]
set incr_value [expr $field1_valuee*$field2_valuee]
@ -767,27 +767,27 @@ proc xhandle_mb_interrupts {} {
set source_interrupt_handler $default_interrupt_handler
set source_handler_arg $default_arg
# Handle the interrupt pin
set sw_proc_handle [get_sw_processor]
set periph [get_cells [get_property HW_INSTANCE $sw_proc_handle]]
set source_ports [::hsm::utils::get_interrupt_sources $periph]
set sw_proc_handle [hsi::get_sw_processor]
set periph [hsi::get_cells [get_property HW_INSTANCE $sw_proc_handle]]
set source_ports [::hsi::utils::get_interrupt_sources $periph]
if {[llength $source_ports] > 1} {
error "ERROR: Too many interrupting ports on the MicroBlaze. Should only find 1" "" "hsm_error"
error "ERROR: Too many interrupting ports on the MicroBlaze. Should only find 1" "" "hsi_error"
return
}
if {[llength $source_ports] == 1} {
set source_port [lindex $source_ports 0]
if {[llength $source_port] != 0} {
set source_port_name [get_property NAME $source_port]
set source_periph [get_cells -of_object $source_port]
set source_periph [hsi::get_cells -of_object $source_port]
set source_name [get_property NAME $source_periph]
set source_driver [get_drivers $source_name]
set source_driver [hsi::get_drivers $source_name]
if {[string compare -nocase $source_driver ""] != 0} {
#set int_array [get_arrays interrupt_handler -of_objects $source_driver]
set int_array_elems [get_arrays interrupt_handler -of_objects $source_driver]
#set int_array [hsi::get_arrays interrupt_handler -of_objects $source_driver]
set int_array_elems [hsi::get_arrays interrupt_handler -of_objects $source_driver]
#if {[llength $int_array] != 0} {
#set int_array_elems [xget_handle $int_array "ELEMENTS" "*"]
if {[llength $int_array_elems] != 0} {
@ -798,12 +798,12 @@ proc xhandle_mb_interrupts {} {
set source_interrupt_handler [get_property CONFIG.int_handler $int_array_elem]
set source_handler_arg [get_property CONFIG.int_handler_arg $int_array_elem]
if {[string compare -nocase $source_handler_arg DEVICE_ID] == 0 } {
set source_handler_arg [::hsm::utils::get_ip_param_name $source_periph "DEVICE_ID"]
set source_handler_arg [::hsi::utils::get_ip_param_name $source_periph "DEVICE_ID"]
} else {
if {[string compare -nocase "global" [get_property TYPE $source_port]] == 0} {
set source_handler_arg $default_arg
} else {
set source_handler_arg [::hsm::utils::get_ip_param_name $source_periph "C_BASEADDR"]
set source_handler_arg [::hsi::utils::get_ip_param_name $source_periph "C_BASEADDR"]
}
}
break
@ -815,24 +815,24 @@ proc xhandle_mb_interrupts {} {
}
}
}
# Generate microblaze_interrupts_g.c file...
xcreate_mb_intr_config_file $source_interrupt_handler $source_handler_arg
}
proc xcreate_mb_intr_config_file {handler arg} {
variable standalone_version
set mb_table "MB_InterruptVectorTable"
set filename [file join "../standalone/src" "microblaze_interrupts_g.c"]
set filename [file join "../standalone/src" "microblaze_interrupts_g.c"]
file delete $filename
set config_file [open $filename w]
::hsm::utils::write_c_header $config_file "Interrupt Handler Table for MicroBlaze Processor"
::hsi::utils::write_c_header $config_file "Interrupt Handler Table for MicroBlaze Processor"
puts $config_file "#include \"microblaze_interrupts_i.h\""
puts $config_file "#include \"xparameters.h\""
puts $config_file "\n"
@ -854,24 +854,24 @@ proc xcreate_mb_intr_config_file {handler arg} {
# Tcl procedure xcreate_mb_exc_config file
# -------------------------------------------
proc xcreate_mb_exc_config_file { } {
set hfilename [file join "src" "include" "microblaze_exceptions_g.h"]
set hfilename [file join "src" "include" "microblaze_exceptions_g.h"]
file delete $hfilename
set hconfig_file [open $hfilename w]
::hsm::utils::write_c_header $hconfig_file "Exception Handling Header for MicroBlaze Processor"
::hsi::utils::write_c_header $hconfig_file "Exception Handling Header for MicroBlaze Processor"
puts $hconfig_file "\n"
set sw_proc_handle [get_sw_processor]
set hw_proc_handle [get_cells [get_property HW_INSTANCE $sw_proc_handle]]
set sw_proc_handle [hsi::get_sw_processor]
set hw_proc_handle [hsi::get_cells [get_property HW_INSTANCE $sw_proc_handle]]
set procver [get_property CONFIG.HW_VER $hw_proc_handle]
if { ![mb_has_exceptions $hw_proc_handle]} { ;# NO exceptions are enabled
close $hconfig_file ;# Do not generate any info in either the header or the C file
return
}
puts $hconfig_file "\#define MICROBLAZE_EXCEPTIONS_ENABLED 1"
if { [mb_can_handle_exceptions_in_delay_slots $procver] } {
puts $hconfig_file "#define MICROBLAZE_CAN_HANDLE_EXCEPTIONS_IN_DELAY_SLOTS"
@ -882,18 +882,18 @@ proc xcreate_mb_exc_config_file { } {
# --------------------------------------
# Tcl procedure post_generate
# This proc removes from libxil.a the basic
# and standalone BSP versions of
# This proc removes from libxil.a the basic
# and standalone BSP versions of
# _interrupt_handler and _hw_exception_handler
# routines
# --------------------------------------
proc post_generate {os_handle} {
set sw_proc_handle [get_sw_processor]
set hw_proc_handle [get_cells [get_property HW_INSTANCE $sw_proc_handle]]
set sw_proc_handle [hsi::get_sw_processor]
set hw_proc_handle [hsi::get_cells [get_property HW_INSTANCE $sw_proc_handle]]
set proctype [get_property IP_NAME $hw_proc_handle]
set procname [get_property NAME $hw_proc_handle]
set procdrv [get_sw_processor]
set procdrv [hsi::get_sw_processor]
set archiver [get_property CONFIG.archiver $procdrv]
if {[string compare -nocase $proctype "microblaze"] == 0 } {
@ -904,10 +904,10 @@ proc post_generate {os_handle} {
}
exec $archiver -d $libgloss_a _interrupt_handler.o
# We have linkage problems due to how these platforms are defined. Can't do this right now.
# We have linkage problems due to how these platforms are defined. Can't do this right now.
# # Remove _exception_handler.o from libxil.a for Xilkernel
# exec bash -c "$archiver -d ../../lib/libxil.a _exception_handler.o"
# Remove _hw_exception_handler.o from libxil.a for microblaze cores with exception support
# if {[mb_has_exceptions $hw_proc_handle]} {
# exec bash -c "$archiver -d ../../lib/libxil.a _hw_exception_handler.o"
@ -916,11 +916,11 @@ proc post_generate {os_handle} {
}
# --------------------------------------
# Return true if this MB has
# Return true if this MB has
# exception handling support
# --------------------------------------
proc mb_has_exceptions { hw_proc_handle } {
# Check if the following parameters exist on this MicroBlaze's MPD
set ee [get_property CONFIG.C_UNALIGNED_EXCEPTIONS $hw_proc_handle]
if { $ee != "" } {
@ -945,37 +945,37 @@ proc mb_has_exceptions { hw_proc_handle } {
set ee [get_property CONFIG.C_DIV_BY_ZERO_EXCEPTION $hw_proc_handle]
if { $ee != "" } {
return true
}
}
set ee [get_property CONFIG.C_DIV_ZERO_EXCEPTION $hw_proc_handle]
if { $ee != "" } {
return true
}
}
set ee [get_property CONFIG.C_FPU_EXCEPTION $hw_proc_handle]
if { $ee != "" } {
return true
}
}
set ee [get_property CONFIG.C_USE_MMU $hw_proc_handle]
if { $ee != "" && $ee != 0 } {
return true
}
}
return false
}
# --------------------------------------
# Return true if this MB has
# Return true if this MB has
# FPU exception handling support
# --------------------------------------
proc mb_has_fpu_exceptions { hw_proc_handle } {
# Check if the following parameters exist on this MicroBlaze's MPD
set ee [get_property CONFIG.C_FPU_EXCEPTION $hw_proc_handle]
if { $ee != "" } {
return true
}
}
return false
}
@ -984,23 +984,23 @@ proc mb_has_fpu_exceptions { hw_proc_handle } {
# Return true if this MB has PVR support
# --------------------------------------
proc mb_has_pvr { hw_proc_handle } {
# Check if the following parameters exist on this MicroBlaze's MPD
set pvr [get_property CONFIG.C_PVR $hw_proc_handle]
if { $pvr != "" } {
return true
}
}
return false
}
# --------------------------------------
# Return true if MB ver 'procver' has
# support for handling exceptions in
# Return true if MB ver 'procver' has
# support for handling exceptions in
# delay slots
# --------------------------------------
proc mb_can_handle_exceptions_in_delay_slots { procver } {
if { [string compare -nocase $procver "5.00.a"] >= 0 } {
return true
} else {
@ -1017,14 +1017,14 @@ proc xget_memory_controller_handles { mhs } {
set ret_list ""
# Gets all MhsInsts in the system
set mhsinsts [get_cells *]
set mhsinsts [hsi::get_cells *]
# Loop thru each MhsInst and determine if have "ADDR_TYPE = MEMORY" in
# the parameters.
foreach mhsinst $mhsinsts {
# Gets all parameters of the component
set mem_ranges [::hsm::utils::get_ip_mem_ranges $mhsinst]
set mem_ranges [::hsi::utils::get_ip_mem_ranges $mhsinst]
# Loop thru each param and find tag "ADDR_TYPE = MEMORY"
foreach mem_range $mem_ranges {
@ -1036,11 +1036,10 @@ proc xget_memory_controller_handles { mhs } {
lappend ret_list $mhsinst
break;
}
}
}
return $ret_list
}