Snitch Runtime
Loading...
Searching...
No Matches
start.h
1// Copyright 2024 ETH Zurich and University of Bologna.
2// Licensed under the Apache License, Version 2.0, see LICENSE for details.
3// SPDX-License-Identifier: Apache-2.0
4
5#ifdef OPENOCD_SEMIHOSTING
6#include "openocd.h"
7#endif
8
9#ifdef SNRT_CRT0_EXIT
10inline void snrt_exit_default(int exit_code) {
11 exit_code = snrt_global_all_to_all_reduction(exit_code);
12#ifdef OPENOCD_SEMIHOSTING
13 if (snrt_global_core_idx() == 0) __ocd_semihost_exit(exit_code);
14#else
15 if (snrt_global_core_idx() == 0)
16 *(snrt_exit_code_destination()) = (exit_code << 1) | 1;
17#endif
18}
19#ifndef SNRT_CRT0_ALTERNATE_EXIT
20inline void snrt_exit(int exit_code) { snrt_exit_default(exit_code); }
21#endif
22#endif
23
24#ifdef SNRT_INIT_CLS
25inline uint32_t snrt_cls_base_addr() {
26 extern volatile uint32_t __cdata_start, __cdata_end;
27 extern volatile uint32_t __cbss_start, __cbss_end;
28 uint32_t cdata_size = ((uint32_t)&__cdata_end) - ((uint32_t)&__cdata_start);
29 uint32_t cbss_size = ((uint32_t)&__cbss_end) - ((uint32_t)&__cbss_start);
30 uint32_t l1_end_addr = SNRT_TCDM_START_ADDR +
31 snrt_cluster_idx() * SNRT_CLUSTER_OFFSET +
32 SNRT_TCDM_SIZE;
33 return l1_end_addr - cdata_size - cbss_size;
34}
35#endif