Merge "Add binary input support for function sim_kelvin"
diff --git a/platforms/nexus/setup.sh b/platforms/nexus/setup.sh
index 16ed12c..3d03417 100644
--- a/platforms/nexus/setup.sh
+++ b/platforms/nexus/setup.sh
@@ -64,22 +64,38 @@
function sim_kelvin
{
- # check input file to use kelvin_sim or renode wrapper
+ # Run the ELF/Bin program with kelvin_sim
local bin_file=$(realpath $1)
local magic_bytes=$(xxd -p -l 4 "${bin_file}")
+ local -a flags=()
+ local is_elf=false
if [[ ${magic_bytes} == "7f454c46" ]]; then
- local flag=""
- if [[ "$2" == "debug" ]]; then
- flag="-i"
- fi
- ("${OUT}/kelvin/sim/kelvin_sim" "${bin_file}" ${flag})
+ is_elf=true
else
- local command="start;"
- if [[ "$2" == "debug" ]]; then
- command="machine StartGdbServer 3333;"
- fi
- (cd "${ROOTDIR}" && renode -e "\$bin=@${bin_file}; i @sim/config/kelvin.resc; \
- ${command} sysbus.vec_controlblock WriteDoubleWord 0xc 0" \
- --disable-xwt --console)
+ flags+=("--entry_point 0 ")
fi
+
+ if [[ "$2" == "debug" ]]; then
+ flags+=("-i")
+ if [[ "${is_elf}" == false ]]; then
+ echo "debug mode only works on ELF files"
+ return 1
+ fi
+ fi
+
+ ("${OUT}/kelvin/sim/kelvin_sim" "${bin_file}" ${flags[@]})
+}
+
+function sim_kelvin_renode
+{
+ # Run the Bin program with renode
+ local bin_file=$(realpath $1)
+ local command="start;"
+ if [[ "$2" == "debug" ]]; then
+ command="machine StartGdbServer 3333;"
+ fi
+ (cd "${ROOTDIR}" && renode -e "\$bin=@${bin_file}; i @sim/config/kelvin.resc; \
+ ${command} sysbus.vec_controlblock WriteDoubleWord 0xc 0" \
+ --disable-xwt --console)
+
}
diff --git a/platforms/shodan/setup.sh b/platforms/shodan/setup.sh
index ff75fac..02cb66b 100644
--- a/platforms/shodan/setup.sh
+++ b/platforms/shodan/setup.sh
@@ -83,22 +83,38 @@
function sim_kelvin
{
- # check input file to use kelvin_sim or renode wrapper
+ # Run the ELF/Bin program with kelvin_sim
local bin_file=$(realpath $1)
local magic_bytes=$(xxd -p -l 4 "${bin_file}")
+ local -a flags=()
+ local is_elf=false
if [[ ${magic_bytes} == "7f454c46" ]]; then
- local flag=""
- if [[ "$2" == "debug" ]]; then
- flag="-i"
- fi
- ("${OUT}/kelvin/sim/kelvin_sim" "${bin_file}" ${flag})
+ is_elf=true
else
- local command="start;"
- if [[ "$2" == "debug" ]]; then
- command="machine StartGdbServer 3333;"
- fi
- (cd "${ROOTDIR}" && renode -e "\$bin=@${bin_file}; i @sim/config/kelvin.resc; \
- ${command} sysbus.vec_controlblock WriteDoubleWord 0xc 0" \
- --disable-xwt --console)
+ flags+=("--entry_point 0 ")
fi
+
+ if [[ "$2" == "debug" ]]; then
+ flags+=("-i")
+ if [[ "${is_elf}" == false ]]; then
+ echo "debug mode only works on ELF files"
+ return 1
+ fi
+ fi
+
+ ("${OUT}/kelvin/sim/kelvin_sim" "${bin_file}" ${flags[@]})
+}
+
+function sim_kelvin_renode
+{
+ # Run the Bin program with renode
+ local bin_file=$(realpath $1)
+ local command="start;"
+ if [[ "$2" == "debug" ]]; then
+ command="machine StartGdbServer 3333;"
+ fi
+ (cd "${ROOTDIR}" && renode -e "\$bin=@${bin_file}; i @sim/config/kelvin.resc; \
+ ${command} sysbus.vec_controlblock WriteDoubleWord 0xc 0" \
+ --disable-xwt --console)
+
}