1 /*
2  * Copyright (c) 2022, Arm Limited. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  *
6  */
7 
8 #include "stddef.h"
9 
10 #include "dma350_privileged_config.h"
11 #include "dma350_lib.h"
12 #include "device_definition.h"
13 #include "utilities.h"
14 
15 #ifndef RSS_DMA_MIN_SIZE
16 #define RSS_DMA_MIN_SIZE 1024
17 #endif /* RSS_DMA_MIN_SIZE */
18 
spm_dma_memcpy(void * dest,const void * src,size_t n)19 void *spm_dma_memcpy(void *dest, const void *src, size_t n)
20 {
21     enum dma350_error_t err;
22 
23     if (n < RSS_DMA_MIN_SIZE) {
24         return memcpy(dest, src, n);
25     } else {
26         err = dma350_memcpy(&DMA350_DMA0_CH0_DEV_S, (void *)src, dest, n,
27                             DMA350_LIB_EXEC_BLOCKING);
28         if (err != DMA350_ERR_NONE) {
29             /* Memcpy can't return an error, so this the only option */
30             tfm_core_panic();
31         }
32 
33         return dest;
34     }
35 }
36