1 /*
2  * Copyright (c) 2019-2023 Intel Corporation
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 #ifndef ZEPHYR_SOC_INTEL_ADSP_COMMON_UTIL_H_
7 #define ZEPHYR_SOC_INTEL_ADSP_COMMON_UTIL_H_
8 
9 #include <zephyr/cache.h>
10 
11 /* memcopy used by boot loader */
bmemcpy(void * dest,void * src,size_t bytes)12 static ALWAYS_INLINE void bmemcpy(void *dest, void *src, size_t bytes)
13 {
14 	volatile uint32_t *d = (uint32_t *)dest;
15 	volatile uint32_t *s = (uint32_t *)src;
16 
17 	sys_cache_data_invd_range(src, bytes);
18 	for (size_t i = 0; i < (bytes >> 2); i++)
19 		d[i] = s[i];
20 
21 	sys_cache_data_flush_range(dest, bytes);
22 }
23 
24 /* bzero used by bootloader */
bbzero(void * dest,size_t bytes)25 static ALWAYS_INLINE void bbzero(void *dest, size_t bytes)
26 {
27 	volatile uint32_t *d = (uint32_t *)dest;
28 
29 	for (size_t i = 0; i < (bytes >> 2); i++)
30 		d[i] = 0;
31 
32 	sys_cache_data_flush_range(dest, bytes);
33 }
34 
35 #endif /* ZEPHYR_SOC_INTEL_ADSP_COMMON_UTIL_H_ */
36