From 5c1ce76b870b032bf8e3170a7376b6edc4b483fd Mon Sep 17 00:00:00 2001 From: Daniel Jobson Date: Fri, 15 Nov 2024 09:28:01 +0100 Subject: [PATCH] ROM only executable in firmware mode, except for address of syscall_addr_reg MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Mikael Ă…gren --- hw/application_fpga/core/tk1/rtl/tk1.v | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/hw/application_fpga/core/tk1/rtl/tk1.v b/hw/application_fpga/core/tk1/rtl/tk1.v index 8e2e145c..f27d56d1 100644 --- a/hw/application_fpga/core/tk1/rtl/tk1.v +++ b/hw/application_fpga/core/tk1/rtl/tk1.v @@ -106,6 +106,7 @@ module tk1 ( localparam FW_RAM_FIRST = 32'hd0000000; localparam FW_RAM_LAST = 32'hd00007ff; + localparam FW_ROM_FIRST = 32'h00000000; localparam FW_ROM_LAST = 32'h00001fff; // ILLEGAL_ADDR is outside of the physical memory, and will trap in @@ -398,6 +399,9 @@ module tk1 ( // // Trying to execute instructions in FW-RAM. // + // Executing instructions in ROM, while not being in firmware + // mode, or at the address set in syscall_addr_reg. + // // Trying to execute code in mem area set to be data access only. // This requires execution monitor to have been setup and // enabled. @@ -415,6 +419,14 @@ module tk1 ( force_trap_set = 1'h1; end + if (system_mode_reg) begin + if (cpu_addr != syscall_addr_reg) begin + if ((cpu_addr >= FW_ROM_FIRST) && (cpu_addr <= FW_ROM_LAST)) begin + force_trap_set = 1'h1; + end + end + end + if (cpu_mon_en_reg) begin if ((cpu_addr >= cpu_mon_first_reg) && (cpu_addr <= cpu_mon_last_reg)) begin force_trap_set = 1'h1;