Skip to content

Commit

Permalink
Check in soc_ctrl, CMakeLists, testClusterOffload
Browse files Browse the repository at this point in the history
  • Loading branch information
Scheremo committed Aug 23, 2024
1 parent e7abbfc commit 92947aa
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 0 deletions.
17 changes: 17 additions & 0 deletions targets/chimera-open/include/soc_ctrl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright 2024 ETH Zurich and University of Bologna.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
//
// Moritz Scherer <[email protected]>

#ifndef _OFFLOAD_INCLUDE_GUARD_
#define _OFFLOAD_INCLUDE_GUARD_

#include <stdint.h>

void setupInterruptHandler(void *handler);
void offloadToCluster(void *function, uint8_t clusterId);
void waitClusterBusy(uint8_t clusterId);
uint32_t waitForCluster(uint8_t clusterId);

#endif
7 changes: 7 additions & 0 deletions tests/chimera-open/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Copyright 2024 ETH Zurich and University of Bologna.
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0
#
# Moritz Scherer <[email protected]>

add_subdirectory(testClusterOffload)
18 changes: 18 additions & 0 deletions tests/chimera-open/testClusterOffload/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright 2024 ETH Zurich and University of Bologna.
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0
#
# Moritz Scherer <[email protected]>

project(chimera-sdk-testClusterOffload LANGUAGES C ASM)

file(GLOB_RECURSE TEST_SRCS
"src/testClusterOffload.c"
)

add_chimera_test(
testClusterOffload
${TEST_SRCS}
)

target_link_libraries(testClusterOffload PUBLIC chimera-sdk)
35 changes: 35 additions & 0 deletions tests/chimera-open/testClusterOffload/src/testClusterOffload.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright 2024 ETH Zurich and University of Bologna.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
//
// Moritz Scherer <[email protected]>

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

#define TESTVAL 0x050CCE55

static uint32_t *clintPointer = (uint32_t *)CLINT_CTRL_BASE;

void clusterInterruptHandler() {
uint8_t hartId;
asm("csrr %0, mhartid" : "=r"(hartId)::);

volatile uint32_t *interruptTarget = clintPointer + hartId;
*interruptTarget = 0;
return;
}

int32_t testReturn() {
return TESTVAL;
}

int main() {
setupInterruptHandler(clusterInterruptHandler);
offloadToCluster(testReturn, 0);
uint32_t retVal = waitForCluster(0);

return (retVal != (TESTVAL | 0x000000001));
}

0 comments on commit 92947aa

Please sign in to comment.