mirror of
https://github.com/tillitis/tillitis-key1.git
synced 2025-08-07 14:12:34 -04:00
Add API for syscall
Add a register to store an address to a syscall function defined in firmware. Set the reset value to an illegal address, to make sure a call to an unset address will halt the CPU. Co-authored-by: Mikael Ågren <mikael@tillitis.se>
This commit is contained in:
parent
07dec8b8dc
commit
31708a39d3
2 changed files with 25 additions and 0 deletions
|
@ -80,6 +80,7 @@ module tk1 #(
|
|||
localparam ADDR_APP_SIZE = 8'h0d;
|
||||
|
||||
localparam ADDR_BLAKE2S = 8'h10;
|
||||
localparam ADDR_SYSCALL = 8'h12;
|
||||
|
||||
localparam ADDR_CDI_FIRST = 8'h20;
|
||||
localparam ADDR_CDI_LAST = 8'h27;
|
||||
|
@ -108,6 +109,10 @@ module tk1 #(
|
|||
localparam FW_RAM_LAST = 32'hd00007ff;
|
||||
|
||||
|
||||
// ILLEGAL_ADDR is outside of the physical memory, and will trap in
|
||||
// the security monitor if accessed.
|
||||
localparam ILLEGAL_ADDR = 32'h4f000000;
|
||||
|
||||
//----------------------------------------------------------------
|
||||
// Registers including update variables and write enable.
|
||||
//----------------------------------------------------------------
|
||||
|
@ -136,6 +141,9 @@ module tk1 #(
|
|||
reg [31 : 0] blake2s_addr_reg;
|
||||
reg blake2s_addr_we;
|
||||
|
||||
reg [31 : 0] syscall_addr_reg;
|
||||
reg syscall_addr_we;
|
||||
|
||||
reg [23 : 0] cpu_trap_ctr_reg;
|
||||
reg [23 : 0] cpu_trap_ctr_new;
|
||||
reg [ 2 : 0] cpu_trap_led_reg;
|
||||
|
@ -259,6 +267,7 @@ module tk1 #(
|
|||
app_start_reg <= 32'h0;
|
||||
app_size_reg <= APP_SIZE;
|
||||
blake2s_addr_reg <= 32'h0;
|
||||
syscall_addr_reg <= ILLEGAL_ADDR;
|
||||
cdi_mem[0] <= 32'h0;
|
||||
cdi_mem[1] <= 32'h0;
|
||||
cdi_mem[2] <= 32'h0;
|
||||
|
@ -317,6 +326,10 @@ module tk1 #(
|
|||
blake2s_addr_reg <= write_data;
|
||||
end
|
||||
|
||||
if (syscall_addr_we) begin
|
||||
syscall_addr_reg <= write_data;
|
||||
end
|
||||
|
||||
if (cdi_mem_we) begin
|
||||
cdi_mem[address[2 : 0]] <= write_data;
|
||||
end
|
||||
|
@ -423,6 +436,7 @@ module tk1 #(
|
|||
app_start_we = 1'h0;
|
||||
app_size_we = 1'h0;
|
||||
blake2s_addr_we = 1'h0;
|
||||
syscall_addr_we = 1'h0;
|
||||
cdi_mem_we = 1'h0;
|
||||
ram_addr_rand_we = 1'h0;
|
||||
ram_data_rand_we = 1'h0;
|
||||
|
@ -478,6 +492,12 @@ module tk1 #(
|
|||
end
|
||||
end
|
||||
|
||||
if (address == ADDR_SYSCALL) begin
|
||||
if (!system_mode_reg) begin
|
||||
syscall_addr_we = 1'h1;
|
||||
end
|
||||
end
|
||||
|
||||
if ((address >= ADDR_CDI_FIRST) && (address <= ADDR_CDI_LAST)) begin
|
||||
if (!system_mode_reg) begin
|
||||
cdi_mem_we = 1'h1;
|
||||
|
@ -562,6 +582,10 @@ module tk1 #(
|
|||
tmp_read_data = blake2s_addr_reg;
|
||||
end
|
||||
|
||||
if (address == ADDR_SYSCALL) begin
|
||||
tmp_read_data = syscall_addr_reg;
|
||||
end
|
||||
|
||||
if ((address >= ADDR_CDI_FIRST) && (address <= ADDR_CDI_LAST)) begin
|
||||
tmp_read_data = cdi_mem[address[2 : 0]];
|
||||
end
|
||||
|
|
|
@ -125,6 +125,7 @@
|
|||
#define TK1_MMIO_TK1_APP_SIZE 0xff000034
|
||||
|
||||
#define TK1_MMIO_TK1_BLAKE2S 0xff000040
|
||||
#define TK1_MMIO_TK1_SYSCALL 0xff000048
|
||||
|
||||
#define TK1_MMIO_TK1_CDI_FIRST 0xff000080
|
||||
#define TK1_MMIO_TK1_CDI_LAST 0xff00009c
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue