[sw/silicon_creator] Use SW_FATAL_ERR in shutdown_software_escalate()

Signed-off-by: Alphan Ulusoy <alphan@google.com>
diff --git a/sw/device/silicon_creator/lib/BUILD b/sw/device/silicon_creator/lib/BUILD
index 6f1f34b..025db32 100644
--- a/sw/device/silicon_creator/lib/BUILD
+++ b/sw/device/silicon_creator/lib/BUILD
@@ -283,6 +283,7 @@
         "//hw/ip/keymgr/data:keymgr_regs",
         "//hw/ip/lc_ctrl/data:lc_ctrl_regs",
         "//hw/ip/otp_ctrl/data:otp_ctrl_regs",
+        "//hw/ip/rv_core_ibex/data:rv_core_ibex_regs",
         "//hw/ip/sram_ctrl/data:sram_ctrl_regs",
         "//hw/top_earlgrey/ip/flash_ctrl/data/autogen:flash_ctrl_regs",
         "//hw/top_earlgrey/sw/autogen:top_earlgrey",
@@ -310,6 +311,7 @@
         "//hw/ip/keymgr/data:keymgr_regs",
         "//hw/ip/lc_ctrl/data:lc_ctrl_regs",
         "//hw/ip/otp_ctrl/data:otp_ctrl_regs",
+        "//hw/ip/rv_core_ibex/data:rv_core_ibex_regs",
         "//hw/ip/sram_ctrl/data:sram_ctrl_regs",
         "//hw/top_earlgrey:alert_handler_regs",
         "//hw/top_earlgrey/ip/flash_ctrl/data/autogen:flash_ctrl_regs",
diff --git a/sw/device/silicon_creator/lib/meson.build b/sw/device/silicon_creator/lib/meson.build
index e343629..e6a2e7d 100644
--- a/sw/device/silicon_creator/lib/meson.build
+++ b/sw/device/silicon_creator/lib/meson.build
@@ -106,6 +106,7 @@
       hw_ip_keymgr_reg_h,
       hw_ip_sram_ctrl_reg_h,
       hw_ip_flash_ctrl_reg_h,
+      hw_ip_ibex_reg_h,
       'shutdown.c',
     ],
     dependencies: [
@@ -172,6 +173,7 @@
       hw_ip_keymgr_reg_h,
       hw_ip_sram_ctrl_reg_h,
       hw_ip_flash_ctrl_reg_h,
+      hw_ip_ibex_reg_h,
       'shutdown.c',
       'shutdown_unittest.cc',
     ],
diff --git a/sw/device/silicon_creator/lib/shutdown.c b/sw/device/silicon_creator/lib/shutdown.c
index b932df8..5c9274e 100644
--- a/sw/device/silicon_creator/lib/shutdown.c
+++ b/sw/device/silicon_creator/lib/shutdown.c
@@ -22,6 +22,7 @@
 #include "keymgr_regs.h"
 #include "lc_ctrl_regs.h"
 #include "otp_ctrl_regs.h"
+#include "rv_core_ibex_regs.h"
 #include "sram_ctrl_regs.h"
 
 static_assert(ALERT_HANDLER_ALERT_CLASS_SHADOWED_MULTIREG_COUNT <=
@@ -273,10 +274,10 @@
 }
 
 SHUTDOWN_FUNC(NO_MODIFIERS, shutdown_software_escalate(void)) {
-  // TODO(lowRISC/opentitan#7148): Use a software alert when available.
-  // For now, signal a fatal_intg_error from SRAM.
-  enum { kBase = TOP_EARLGREY_SRAM_CTRL_MAIN_REGS_BASE_ADDR };
-  abs_mmio_write32(kBase + SRAM_CTRL_ALERT_TEST_REG_OFFSET, 1);
+  enum { kBase = TOP_EARLGREY_RV_CORE_IBEX_CFG_BASE_ADDR };
+  //  Setting rv_core_ibex.SW_FATAL_ERR (rw0c) to any value other than
+  // `kMultiBitBool4False` will continuously cause alert events.
+  abs_mmio_write32(kBase + RV_CORE_IBEX_SW_FATAL_ERR_REG_OFFSET, 0);
 }
 
 SHUTDOWN_FUNC(NO_MODIFIERS, shutdown_keymgr_kill(void)) {
diff --git a/sw/device/silicon_creator/lib/shutdown_unittest.cc b/sw/device/silicon_creator/lib/shutdown_unittest.cc
index 19dc487..7068993 100644
--- a/sw/device/silicon_creator/lib/shutdown_unittest.cc
+++ b/sw/device/silicon_creator/lib/shutdown_unittest.cc
@@ -19,6 +19,7 @@
 #include "hw/top_earlgrey/sw/autogen/top_earlgrey.h"
 #include "lc_ctrl_regs.h"
 #include "otp_ctrl_regs.h"
+#include "rv_core_ibex_regs.h"
 
 namespace shutdown_unittest {
 
@@ -67,6 +68,7 @@
 
 // Real implementations of the above mocks.
 extern void unmocked_shutdown_flash_kill(void);
+extern void unmocked_shutdown_software_escalate(void);
 }  // extern "C"
 
 constexpr uint32_t Pack32(uint8_t a, uint8_t b, uint8_t c, uint8_t d) {
@@ -616,5 +618,11 @@
   SHUTDOWN_IF_ERROR(kErrorUnknown);
 }
 
+TEST_F(ShutdownTest, SoftwareEscalate) {
+  EXPECT_ABS_WRITE32(TOP_EARLGREY_RV_CORE_IBEX_CFG_BASE_ADDR +
+                         RV_CORE_IBEX_SW_FATAL_ERR_REG_OFFSET,
+                     0);
+  unmocked_shutdown_software_escalate();
+}
 }  // namespace
 }  // namespace shutdown_unittest