diff --git a/sw/snRuntime/src/platforms/rtl/start_snitch.S.in b/sw/snRuntime/src/platforms/rtl/start_snitch.S.in new file mode 100644 index 00000000..86c49546 --- /dev/null +++ b/sw/snRuntime/src/platforms/rtl/start_snitch.S.in @@ -0,0 +1,57 @@ +# Copyright 2020 ETH Zurich and University of Bologna. +# Licensed under the Apache License, Version 2.0, see LICENSE for details. +# SPDX-License-Identifier: Apache-2.0 + +#include "../shared/start_snitch.S" + +#include + +//.global BOOTDATA + +# Function to terminate execution. +# +# Expecting: +# - a0: exit code +# - a1: device tree ptr +_snrt_exit: + .globl _snrt_exit + # Determine global core index. + addi sp, sp, -8 + sw a0, 0(sp) + sw ra, 4(sp) + call snrt_global_core_idx + # reload exit code into t0 + lw t0, 0(sp) + lw ra, 4(sp) + addi sp, sp, 8 + + # Only first core triggers exit. + # - a0: global core index + # - t0: exit code + bnez a0, 1f + slli t0, t0, 1 + ori t0, t0, 1 + + # Load the start address and size of the TCDM + li t1, @MEM_TCDM_ORIGIN@ + li t2, @MEM_TCDM_SIZE@ + + # Final address of the TCDM + add t1, t1, t2 + + # Address of the EOC register + addi t1, t1, SPATZ_CLUSTER_PERIPHERAL_CLUSTER_EOC_EXIT_REG_OFFSET + + # Return to EOC register + sw t0, 0(t1) + + # Return to HTIF + la t1, tohost + sw t0, 0(t1) +1: ret + +# HTIF sections +.pushsection .htif,"aw",@progbits; +.align 6; .global tohost; tohost: .dword 0; +.align 6; .global fromhost; fromhost: .dword 0; + diff --git a/sw/snRuntime/src/platforms/standalone/start_snitch.S b/sw/snRuntime/src/platforms/standalone/start_snitch.S index e40332a1..47be6baf 100644 --- a/sw/snRuntime/src/platforms/standalone/start_snitch.S +++ b/sw/snRuntime/src/platforms/standalone/start_snitch.S @@ -4,10 +4,6 @@ #include "../shared/start_snitch.S" -#include - -//.global BOOTDATA - # Function to terminate execution. # # Expecting: @@ -31,21 +27,6 @@ _snrt_exit: bnez a0, 1f slli t0, t0, 1 ori t0, t0, 1 - - # Load the start address and size of the TCDM - li t1, @MEM_TCDM_ORIGIN@ - li t2, @MEM_TCDM_SIZE@ - - # Final address of the TCDM - add t1, t1, t2 - - # Address of the EOC register - addi t1, t1, SPATZ_CLUSTER_PERIPHERAL_CLUSTER_EOC_EXIT_REG_OFFSET - - # Return to EOC register - sw t0, 0(t1) - - # Return to HTIF la t1, tohost sw t0, 0(t1) 1: ret