Skip to content

Commit

Permalink
sw: Fix start snich bootstrap code
Browse files Browse the repository at this point in the history
  • Loading branch information
alex96295 committed Oct 10, 2023
1 parent d0f7bd4 commit 5184bb3
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 19 deletions.
57 changes: 57 additions & 0 deletions sw/snRuntime/src/platforms/rtl/start_snitch.S.in
Original file line number Diff line number Diff line change
@@ -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 <spatz_cluster_peripheral.h>

//.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;

19 changes: 0 additions & 19 deletions sw/snRuntime/src/platforms/standalone/start_snitch.S
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@

#include "../shared/start_snitch.S"

#include <spatz_cluster_peripheral.h>

//.global BOOTDATA

# Function to terminate execution.
#
# Expecting:
Expand All @@ -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
Expand Down

0 comments on commit 5184bb3

Please sign in to comment.