From e1957395655a85c7381101f811b82881de0c52e4 Mon Sep 17 00:00:00 2001 From: Anas Nashif Date: Tue, 28 Mar 2023 14:30:26 +0000 Subject: [PATCH] intel_adsp: move utils to a new header Move utility code into a new header and cleanup soc.h Signed-off-by: Anas Nashif --- drivers/mm/mm_drv_intel_adsp_mtl_tlb.c | 2 +- soc/xtensa/intel_adsp/ace/sram.c | 2 +- soc/xtensa/intel_adsp/cavs/sram.c | 2 +- soc/xtensa/intel_adsp/common/boot.c | 2 +- soc/xtensa/intel_adsp/common/include/soc.h | 25 ------------- .../intel_adsp/common/include/soc_util.h | 35 +++++++++++++++++++ soc/xtensa/intel_adsp/common/mem_window.c | 2 +- 7 files changed, 40 insertions(+), 30 deletions(-) create mode 100644 soc/xtensa/intel_adsp/common/include/soc_util.h diff --git a/drivers/mm/mm_drv_intel_adsp_mtl_tlb.c b/drivers/mm/mm_drv_intel_adsp_mtl_tlb.c index 00a75c35aea..3e083c75123 100644 --- a/drivers/mm/mm_drv_intel_adsp_mtl_tlb.c +++ b/drivers/mm/mm_drv_intel_adsp_mtl_tlb.c @@ -21,7 +21,7 @@ */ #include "mm_drv_intel_adsp.h" - +#include #include #include #include diff --git a/soc/xtensa/intel_adsp/ace/sram.c b/soc/xtensa/intel_adsp/ace/sram.c index e90d3365559..134235f0b55 100644 --- a/soc/xtensa/intel_adsp/ace/sram.c +++ b/soc/xtensa/intel_adsp/ace/sram.c @@ -6,7 +6,7 @@ #include #include -#include +#include #include #include #include diff --git a/soc/xtensa/intel_adsp/cavs/sram.c b/soc/xtensa/intel_adsp/cavs/sram.c index 25e04a4399b..9cedacd12a2 100644 --- a/soc/xtensa/intel_adsp/cavs/sram.c +++ b/soc/xtensa/intel_adsp/cavs/sram.c @@ -6,7 +6,7 @@ #include #include -#include +#include #include #include #include diff --git a/soc/xtensa/intel_adsp/common/boot.c b/soc/xtensa/intel_adsp/common/boot.c index 133e69a0beb..dc185afff37 100644 --- a/soc/xtensa/intel_adsp/common/boot.c +++ b/soc/xtensa/intel_adsp/common/boot.c @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/soc/xtensa/intel_adsp/common/include/soc.h b/soc/xtensa/intel_adsp/common/include/soc.h index 82dd60a805c..6cb9f815561 100644 --- a/soc/xtensa/intel_adsp/common/include/soc.h +++ b/soc/xtensa/intel_adsp/common/include/soc.h @@ -66,29 +66,4 @@ static ALWAYS_INLINE void z_idelay(int n) } } -/* memcopy used by boot loader */ -static ALWAYS_INLINE void bmemcpy(void *dest, void *src, size_t bytes) -{ - volatile uint32_t *d = (uint32_t *)dest; - volatile uint32_t *s = (uint32_t *)src; - - z_xtensa_cache_inv(src, bytes); - for (size_t i = 0; i < (bytes >> 2); i++) - d[i] = s[i]; - - z_xtensa_cache_flush(dest, bytes); -} - -/* bzero used by bootloader */ -static ALWAYS_INLINE void bbzero(void *dest, size_t bytes) -{ - volatile uint32_t *d = (uint32_t *)dest; - - for (size_t i = 0; i < (bytes >> 2); i++) - d[i] = 0; - - z_xtensa_cache_flush(dest, bytes); -} - - #endif /* ZEPHYR_SOC_INTEL_ADSP_COMMON_SOC_H_ */ diff --git a/soc/xtensa/intel_adsp/common/include/soc_util.h b/soc/xtensa/intel_adsp/common/include/soc_util.h new file mode 100644 index 00000000000..19d9a4c97b6 --- /dev/null +++ b/soc/xtensa/intel_adsp/common/include/soc_util.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2019-2023 Intel Corporation + * + * SPDX-License-Identifier: Apache-2.0 + */ +#ifndef ZEPHYR_SOC_INTEL_ADSP_COMMON_UTIL_H_ +#define ZEPHYR_SOC_INTEL_ADSP_COMMON_UTIL_H_ + +#include + +/* memcopy used by boot loader */ +static ALWAYS_INLINE void bmemcpy(void *dest, void *src, size_t bytes) +{ + volatile uint32_t *d = (uint32_t *)dest; + volatile uint32_t *s = (uint32_t *)src; + + sys_cache_data_invd_range(src, bytes); + for (size_t i = 0; i < (bytes >> 2); i++) + d[i] = s[i]; + + sys_cache_data_flush_range(dest, bytes); +} + +/* bzero used by bootloader */ +static ALWAYS_INLINE void bbzero(void *dest, size_t bytes) +{ + volatile uint32_t *d = (uint32_t *)dest; + + for (size_t i = 0; i < (bytes >> 2); i++) + d[i] = 0; + + sys_cache_data_flush_range(dest, bytes); +} + +#endif /* ZEPHYR_SOC_INTEL_ADSP_COMMON_UTIL_H_ */ diff --git a/soc/xtensa/intel_adsp/common/mem_window.c b/soc/xtensa/intel_adsp/common/mem_window.c index 0fb68673696..d4ca4529d84 100644 --- a/soc/xtensa/intel_adsp/common/mem_window.c +++ b/soc/xtensa/intel_adsp/common/mem_window.c @@ -10,7 +10,7 @@ #include #include #include -#include +#include /* host windows */ #define DMWBA(win_base) (win_base + 0x0)