-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check in soc_ctrl, CMakeLists, testClusterOffload
- Loading branch information
Showing
4 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
35
tests/chimera-open/testClusterOffload/src/testClusterOffload.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} |