-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
40 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,40 @@ | ||
// 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 | ||
// | ||
// Paul Scheffler <[email protected]> | ||
// | ||
// Simple test for iDMA. This is intended *only for execution from SPM*. | ||
|
||
#include "util.h" | ||
#include "dif/clint.h" | ||
#include "dif/dma.h" | ||
|
||
int main(void) { | ||
volatile char src_cached[] = "This is a DMA test"; | ||
volatile char gold[] = "This ishis is is is as is a DMA test!"; | ||
|
||
// Allocate destination memory in SPM | ||
volatile char dst_cached[sizeof(gold)]; | ||
|
||
// Get pointer to uncached SPM source and destination | ||
volatile char *src = src_cached + 0x04000000; | ||
volatile char *dst = dst_cached + 0x04000000; | ||
|
||
// Copy from cached to uncached source to ensure it is DMA-accessible | ||
for (unsigned i = 0; i < sizeof(src_cached); ++i) src[i] = src_cached[i]; | ||
|
||
// Pre-write finishing "!\0" to guard against overlength transfers | ||
dst[sizeof(gold) - 2] = '!'; | ||
dst[sizeof(gold) - 1] = '\0'; | ||
|
||
// Issue blocking 2D memcpy (exclude null terminator from source) | ||
sys_dma_2d_blk_memcpy((uintptr_t)(void *)dst, (uintptr_t)(void *)src, sizeof(src_cached) - 4, 7, | ||
1, 4); | ||
|
||
// Check destination string | ||
int errors = sizeof(gold); | ||
for (unsigned i = 0; i < sizeof(gold); ++i) errors -= (dst[i] == gold[i]); | ||
|
||
return errors; | ||
} |