sencha: hack band-aid for mpact sim renode integration
Bug: 333891662
Change-Id: I120f6309c82657be684ea5aad2a3af1af516d566
diff --git a/platforms/sencha/sim.mk b/platforms/sencha/sim.mk
index eac860f..5ff05ee 100644
--- a/platforms/sencha/sim.mk
+++ b/platforms/sencha/sim.mk
@@ -15,6 +15,9 @@
EXT_FLASH_DEBUG=$(CHERIOT_OUT_DEBUG)/ext_flash.tar
EXT_FLASH_RELEASE=$(CHERIOT_OUT_RELEASE)/ext_flash.tar
+CHERIOT_SIM_SRC_DIR := $(ROOTDIR)/sim/cheriot
+CHERIOT_SIM_OUT_DIR := $(OUT)/cheriot/sim
+
TMP_DEBUG=$(CHERIOT_OUT_DEBUG)/tmp
TMP_RELEASE=$(CHERIOT_OUT_RELEASE)/tmp
@@ -66,7 +69,7 @@
#
# This is the default target for the build system, and is generally what you
# need for day-to-day work on the software side of Shodan.
-simulate: renode kelvin_sim multihart_boot_rom ext_flash_release
+simulate: renode cheriot_sim kelvin_sim multihart_boot_rom ext_flash_release
$(RENODE_CMD) -e "\
\$$repl_file = @${SENCHA_REPL}; \
\$$tar = @$(EXT_FLASH_RELEASE); \
@@ -79,7 +82,7 @@
# This top-level target does the same job as `simulate`, but instead of
# unhalting the CPUs and starting the system, this alternate target only unhalts
# cpu0, and uses the debug build of TockOS from the `matcha_tock_debug` target.
-simulate-debug: renode kelvin_sim multihart_boot_rom ext_flash_debug
+simulate-debug: renode cheriot_sim kelvin_sim multihart_boot_rom ext_flash_debug
$(RENODE_CMD) -e "\
\$$repl_file = @${SENCHA_REPL}; \
\$$tar = @$(EXT_FLASH_DEBUG); \
@@ -93,11 +96,41 @@
# unhalting the CPUs and starting the system, this alternate target starts
# renode with no CPUs unhalted, allowing for GDB to be used for early system
# start.
-debug-simulation: renode kelvin_sim multihart_boot_rom ext_flash_debug
+debug-simulation: renode cheriot_sim kelvin_sim multihart_boot_rom ext_flash_debug
$(RENODE_CMD) -e "\
\$$repl_file = @${SENCHA_REPL}; \
\$$tar = @$(EXT_FLASH_DEBUG); \
\$$sc_bin =@$(TMP_DEBUG)/matcha-tock-bundle.bin; \
$(PORT_PRESTART_CMDS) i @${SENCHA_RESC_DEBUG}; start"
+$(CHERIOT_SIM_OUT_DIR):
+ mkdir -p "$(CHERIOT_SIM_OUT_DIR)"
+
+## Build CHERIoT ISS
+#
+# Build mpact-sim-based CHERIoT ISS with bazel, and copy it to out/
+# Use /tmp as the bazel tmpfs to unblock CI
+cheriot_sim_notyet: | $(CHERIOT_SIM_OUT_DIR)
+ cd "$(CHERIOT_SIM_SRC_DIR)" && \
+ bazel build --sandbox_tmpfs_path=/tmp //sim:cheriot_sim \
+ //sim/renode:renode_cheriot
+ cd "$(CHERIOT_SIM_SRC_DIR)/bazel-bin" && \
+ cp -f sim/cheriot_sim "$(CHERIOT_SIM_OUT_DIR)" && \
+ cp -f sim/renode/librenode_mpact_cheriot.so "$(CHERIOT_SIM_OUT_DIR)"
+
+## Clean CHERIoT ISS
+#
+# Clean the CHERIoT ISS
+cheriot_sim_clean_notyet:
+ cd "$(CHERIOT_SIM_SRC_DIR)" && \
+ bazel clean --expunge
+ rm -rf $(CHERIOT_SIM_OUT_DIR)
+
+# TODO(sleffler): temporary hack until the simulator source is integrated
+cheriot_sim: | $(CHERIOT_SIM_OUT_DIR)
+ cp -f ${CACHE}/cheriot-tools/librenode_mpact_cheriot.so "$(CHERIOT_SIM_OUT_DIR)"
+cheriot_sim_clean:
+ rm -rf $(CHERIOT_SIM_OUT_DIR)
+
.PHONY:: sim_configs clean_sim_configs simulate simulate-debug debug-simulation
+.PHONY:: cheriot_sim cheriot_sim_clean