From e7abbfc4e1aedd7e9f930a1302ccb4297fb07b23 Mon Sep 17 00:00:00 2001 From: Moritz Scherer Date: Fri, 23 Aug 2024 10:29:45 +0200 Subject: [PATCH] Bump from chimera/sw --- CMakeLists.txt | 3 +++ targets/chimera-open/common.ldh | 2 +- targets/chimera-open/include/soc_addr_map.h | 20 ++++++++++++++++++++ targets/chimera-open/src/soc_ctrl.c | 12 +++++++++++- 4 files changed, 35 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b36aecb..732452b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,6 +11,9 @@ set(CMAKE_C_STANDARD 99) # SCHEREMO: Needed to skip compiler test, which doesn't support baremetal targets set(CMAKE_C_COMPILER_WORKS 1) +# SCHEREMO: Help most IDE's LSPs find definitions +set(CMAKE_EXPORT_COMPILE_COMMANDS 1) + # SCHEREMO: This toolchain file is only used for test compilation! set(CMAKE_TOOLCHAIN_FILE cmake/toolchain_gcc.cmake) diff --git a/targets/chimera-open/common.ldh b/targets/chimera-open/common.ldh index 7c94fff..cb5d6f8 100644 --- a/targets/chimera-open/common.ldh +++ b/targets/chimera-open/common.ldh @@ -28,7 +28,7 @@ SECTIONS { /* Global and stack pointer */ /* By default, keep the calling context (boot ROM) stack pointer */ __global_pointer$ = ADDR(.misc) + SIZEOF(.misc) / 2; - __stack_pointer$ = 0; + __stack_pointer$ = ORIGIN(memisl) + LENGTH(memisl); /* Further addresses */ __base_dma = 0x01000000; diff --git a/targets/chimera-open/include/soc_addr_map.h b/targets/chimera-open/include/soc_addr_map.h index b748a0e..8141c6f 100644 --- a/targets/chimera-open/include/soc_addr_map.h +++ b/targets/chimera-open/include/soc_addr_map.h @@ -4,6 +4,11 @@ // // Moritz Scherer +#ifndef _SOC_ADDR_MAP_INCLUDE_GUARD_ +#define _SOC_ADDR_MAP_INCLUDE_GUARD_ + +#include + #define CLINT_CTRL_BASE 0x02040000 #define SOC_CTRL_BASE 0x30001000 @@ -13,3 +18,18 @@ #define CLUSTER_2_BASE 0x40400000 #define CLUSTER_3_BASE 0x40600000 #define CLUSTER_4_BASE 0x40800000 + +#define CLUSTER_0_NUMCORES 9 +#define CLUSTER_1_NUMCORES 9 +#define CLUSTER_2_NUMCORES 9 +#define CLUSTER_3_NUMCORES 9 +#define CLUSTER_4_NUMCORES 9 + +static uint8_t _chimera_numCores[] = {CLUSTER_0_NUMCORES, CLUSTER_1_NUMCORES, CLUSTER_2_NUMCORES, + CLUSTER_3_NUMCORES, CLUSTER_4_NUMCORES}; +#define _chimera_numClusters 5 + +#define CHIMERA_PADFRAME_BASE_ADDRESS 0x30002000 +#define FLL_BASE_ADDR 0x30003000 + +#endif diff --git a/targets/chimera-open/src/soc_ctrl.c b/targets/chimera-open/src/soc_ctrl.c index 45a8335..9190d1b 100644 --- a/targets/chimera-open/src/soc_ctrl.c +++ b/targets/chimera-open/src/soc_ctrl.c @@ -6,6 +6,7 @@ #include "regs/soc_ctrl.h" #include "soc_addr_map.h" +#include "soc_ctrl.h" #include void setupInterruptHandler(void *handler) { @@ -32,6 +33,12 @@ void waitClusterBusy(uint8_t clusterId) { while (*busy_ptr == 1) { } + // TODO: temporary race condition fix + for (int i = 0; i < 1000; i++) { + // NOP + asm volatile("addi x0, x0, 0\n" :::); + } + return; } @@ -43,7 +50,10 @@ void offloadToCluster(void *function, uint8_t clusterId) { *snitchBootAddr = function; - uint32_t hartId = clusterId * 9 + 1; + uint32_t hartId = 1; + for (uint32_t i = 0; i < clusterId; i++) { + hartId += _chimera_numCores[i]; + } volatile uint32_t *interruptTarget = ((uint32_t *)CLINT_CTRL_BASE) + hartId; waitClusterBusy(clusterId);