Skip to content

Commit

Permalink
Bump from chimera/sw
Browse files Browse the repository at this point in the history
  • Loading branch information
Scheremo committed Aug 23, 2024
1 parent 0d3a7fc commit e7abbfc
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion targets/chimera-open/common.ldh
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
20 changes: 20 additions & 0 deletions targets/chimera-open/include/soc_addr_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
//
// Moritz Scherer <[email protected]>

#ifndef _SOC_ADDR_MAP_INCLUDE_GUARD_
#define _SOC_ADDR_MAP_INCLUDE_GUARD_

#include <stdint.h>

#define CLINT_CTRL_BASE 0x02040000

#define SOC_CTRL_BASE 0x30001000
Expand All @@ -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
12 changes: 11 additions & 1 deletion targets/chimera-open/src/soc_ctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include "regs/soc_ctrl.h"
#include "soc_addr_map.h"
#include "soc_ctrl.h"
#include <stdint.h>

void setupInterruptHandler(void *handler) {
Expand All @@ -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;
}

Expand All @@ -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);
Expand Down

0 comments on commit e7abbfc

Please sign in to comment.