From 2e0822413daa0e366c322163de5dd69f984d0b70 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Mon, 16 Nov 2026 21:22:20 +0000 Subject: [PATCH 01/10] zephyr: add src/platform to the include path Platform headers are kernel headers, in src/kernel/platform, but some of them define what user-space code needs, such as the mailbox window layout. Those parts move to src/platform, with the same layout and include names, so that the platform include directories in src/kernel/platform can become kernel-only. Add the platform's directory in src/platform to the include path. No platform has one yet. It is added even when it does not exist, so that existing build directories find it once it does, without running CMake again. No functional change. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Liam Girdwood --- zephyr/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt index 026f64a8679b..72eedc76c943 100644 --- a/zephyr/CMakeLists.txt +++ b/zephyr/CMakeLists.txt @@ -157,6 +157,8 @@ cmake_path(SET sof_top_dir NORMALIZE "${CMAKE_CURRENT_SOURCE_DIR}/..") set(SOF_SRC_PATH "${sof_top_dir}/src") set(SOF_PLATFORM_PATH "${SOF_SRC_PATH}/kernel/platform") +# platform headers that user-space code may include +set(SOF_USER_PLATFORM_PATH "${SOF_SRC_PATH}/platform") set(SOF_DRIVERS_PATH "${SOF_SRC_PATH}/kernel/drivers") set(RIMAGE_TOP ${sof_top_dir}/tools/rimage) @@ -564,6 +566,8 @@ if(NOT DEFINED PLATFORM) message(FATAL_ERROR "PLATFORM is not defined, check your Kconfiguration?") endif() zephyr_include_directories(${SOF_PLATFORM_PATH}/${PLATFORM}/include) +# not every platform has one yet, the compiler skips missing directories +zephyr_include_directories(${SOF_USER_PLATFORM_PATH}/${PLATFORM}/include) if(CONFIG_SOF_USERSPACE_INTERFACE_DMA) zephyr_library_sources(syscall/sof_dma.c) From f6beee869e5f2ae5071985ff661907f4968bd62b Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Mon, 16 Nov 2026 21:22:20 +0000 Subject: [PATCH 02/10] platform: intel: ace: move the mailbox headers to src/platform The mailbox window addresses and software register accessors are used by user-space code through sof/lib/mailbox.h: the software register page and the host box are mapped into the user-space LL and IPC threads. But they come from the platform mailbox headers, which use the window layout in the platform memory map, so every user of the mailbox gets the whole memory map. For the ACE platforms (MTL, LNL, PTL/WCL and NVL), move the shared ace/lib/mailbox.h and the platform mailbox headers to src/platform, and move the window layout out of each memory map into a new platform/lib/mailbox_layout.h there. The memory maps include it, and ace/lib/mailbox.h includes it, and rtos/cache.h for its accessors, instead of the memory map. No functional change. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Liam Girdwood --- .../ace30/include/platform/lib/memory.h | 24 +--------- .../lunarlake/include/platform/lib/memory.h | 24 +--------- .../meteorlake/include/platform/lib/memory.h | 24 +--------- .../novalake/include/platform/lib/memory.h | 24 +--------- .../ace30/include/platform/lib/mailbox.h | 0 .../include/platform/lib/mailbox_layout.h | 45 +++++++++++++++++++ .../intel/ace/include/ace/lib/mailbox.h | 3 +- .../lunarlake/include/platform/lib/mailbox.h | 0 .../include/platform/lib/mailbox_layout.h | 45 +++++++++++++++++++ .../meteorlake/include/platform/lib/mailbox.h | 0 .../include/platform/lib/mailbox_layout.h | 45 +++++++++++++++++++ .../novalake/include/platform/lib/mailbox.h | 0 .../include/platform/lib/mailbox_layout.h | 45 +++++++++++++++++++ test/cmocka/CMakeLists.txt | 1 + zephyr/CMakeLists.txt | 1 + 15 files changed, 188 insertions(+), 93 deletions(-) rename src/{kernel => }/platform/ace30/include/platform/lib/mailbox.h (100%) create mode 100644 src/platform/ace30/include/platform/lib/mailbox_layout.h rename src/{kernel => }/platform/intel/ace/include/ace/lib/mailbox.h (97%) rename src/{kernel => }/platform/lunarlake/include/platform/lib/mailbox.h (100%) create mode 100644 src/platform/lunarlake/include/platform/lib/mailbox_layout.h rename src/{kernel => }/platform/meteorlake/include/platform/lib/mailbox.h (100%) create mode 100644 src/platform/meteorlake/include/platform/lib/mailbox_layout.h rename src/{kernel => }/platform/novalake/include/platform/lib/mailbox.h (100%) create mode 100644 src/platform/novalake/include/platform/lib/mailbox_layout.h diff --git a/src/kernel/platform/ace30/include/platform/lib/memory.h b/src/kernel/platform/ace30/include/platform/lib/memory.h index 5953d6309c57..a66c1aa0cbf1 100644 --- a/src/kernel/platform/ace30/include/platform/lib/memory.h +++ b/src/kernel/platform/ace30/include/platform/lib/memory.h @@ -17,29 +17,7 @@ #include #include -/* HP SRAM windows */ -#define WIN_BASE(n) DT_REG_ADDR(DT_PHANDLE(MEM_WINDOW_NODE(n), memory)) - -/* window 0 */ -#define SRAM_SW_REG_BASE ((uint32_t)(WIN_BASE(0) + WIN0_OFFSET)) -#define SRAM_SW_REG_SIZE 0x1000 - -#define SRAM_OUTBOX_BASE (SRAM_SW_REG_BASE + SRAM_SW_REG_SIZE) -#define SRAM_OUTBOX_SIZE 0x1000 - -/* window 1 */ -#define SRAM_INBOX_BASE ((uint32_t)(WIN_BASE(1) + WIN1_OFFSET)) -#define SRAM_INBOX_SIZE ((uint32_t)WIN_SIZE(1)) - -/* window 2 */ -#define SRAM_DEBUG_BASE ((uint32_t)(WIN_BASE(2) + WIN2_OFFSET)) -#define SRAM_DEBUG_SIZE 0x800 - -#define SRAM_EXCEPT_BASE (SRAM_DEBUG_BASE + SRAM_DEBUG_SIZE) -#define SRAM_EXCEPT_SIZE 0x800 - -#define SRAM_STREAM_BASE (SRAM_EXCEPT_BASE + SRAM_EXCEPT_SIZE) -#define SRAM_STREAM_SIZE 0x1000 +#include /* Stack configuration */ #define SOF_STACK_SIZE 0x1000 diff --git a/src/kernel/platform/lunarlake/include/platform/lib/memory.h b/src/kernel/platform/lunarlake/include/platform/lib/memory.h index 0b954d856940..4cad09d0282c 100644 --- a/src/kernel/platform/lunarlake/include/platform/lib/memory.h +++ b/src/kernel/platform/lunarlake/include/platform/lib/memory.h @@ -19,29 +19,7 @@ #include #include -/* HP SRAM windows */ -#define WIN_BASE(n) DT_REG_ADDR(DT_PHANDLE(MEM_WINDOW_NODE(n), memory)) - -/* window 0 */ -#define SRAM_SW_REG_BASE ((uint32_t)(WIN_BASE(0) + WIN0_OFFSET)) -#define SRAM_SW_REG_SIZE 0x1000 - -#define SRAM_OUTBOX_BASE (SRAM_SW_REG_BASE + SRAM_SW_REG_SIZE) -#define SRAM_OUTBOX_SIZE 0x1000 - -/* window 1 */ -#define SRAM_INBOX_BASE ((uint32_t)(WIN_BASE(1) + WIN1_OFFSET)) -#define SRAM_INBOX_SIZE ((uint32_t)WIN_SIZE(1)) - -/* window 2 */ -#define SRAM_DEBUG_BASE ((uint32_t)(WIN_BASE(2) + WIN2_OFFSET)) -#define SRAM_DEBUG_SIZE 0x800 - -#define SRAM_EXCEPT_BASE (SRAM_DEBUG_BASE + SRAM_DEBUG_SIZE) -#define SRAM_EXCEPT_SIZE 0x800 - -#define SRAM_STREAM_BASE (SRAM_EXCEPT_BASE + SRAM_EXCEPT_SIZE) -#define SRAM_STREAM_SIZE 0x1000 +#include /* Stack configuration */ #define SOF_STACK_SIZE 0x1000 diff --git a/src/kernel/platform/meteorlake/include/platform/lib/memory.h b/src/kernel/platform/meteorlake/include/platform/lib/memory.h index 0dad6d99acc0..e9671d8a0313 100644 --- a/src/kernel/platform/meteorlake/include/platform/lib/memory.h +++ b/src/kernel/platform/meteorlake/include/platform/lib/memory.h @@ -19,29 +19,7 @@ #include #include -/* HP SRAM windows */ -#define WIN_BASE(n) DT_REG_ADDR(DT_PHANDLE(MEM_WINDOW_NODE(n), memory)) - -/* window 0 */ -#define SRAM_SW_REG_BASE ((uint32_t)(WIN_BASE(0) + WIN0_OFFSET)) -#define SRAM_SW_REG_SIZE 0x1000 - -#define SRAM_OUTBOX_BASE (SRAM_SW_REG_BASE + SRAM_SW_REG_SIZE) -#define SRAM_OUTBOX_SIZE 0x1000 - -/* window 1 */ -#define SRAM_INBOX_BASE ((uint32_t)(WIN_BASE(1) + WIN1_OFFSET)) -#define SRAM_INBOX_SIZE ((uint32_t)WIN_SIZE(1)) - -/* window 2 */ -#define SRAM_DEBUG_BASE ((uint32_t)(WIN_BASE(2) + WIN2_OFFSET)) -#define SRAM_DEBUG_SIZE 0x800 - -#define SRAM_EXCEPT_BASE (SRAM_DEBUG_BASE + SRAM_DEBUG_SIZE) -#define SRAM_EXCEPT_SIZE 0x800 - -#define SRAM_STREAM_BASE (SRAM_EXCEPT_BASE + SRAM_EXCEPT_SIZE) -#define SRAM_STREAM_SIZE 0x1000 +#include /* Stack configuration */ #define SOF_STACK_SIZE 0x1000 diff --git a/src/kernel/platform/novalake/include/platform/lib/memory.h b/src/kernel/platform/novalake/include/platform/lib/memory.h index 19ade62dfb2b..752eb0bc9527 100644 --- a/src/kernel/platform/novalake/include/platform/lib/memory.h +++ b/src/kernel/platform/novalake/include/platform/lib/memory.h @@ -17,29 +17,7 @@ #include #include -/* HP SRAM windows */ -#define WIN_BASE(n) DT_REG_ADDR(DT_PHANDLE(MEM_WINDOW_NODE(n), memory)) - -/* window 0 */ -#define SRAM_SW_REG_BASE ((uint32_t)(WIN_BASE(0) + WIN0_OFFSET)) -#define SRAM_SW_REG_SIZE 0x1000 - -#define SRAM_OUTBOX_BASE (SRAM_SW_REG_BASE + SRAM_SW_REG_SIZE) -#define SRAM_OUTBOX_SIZE 0x1000 - -/* window 1 */ -#define SRAM_INBOX_BASE ((uint32_t)(WIN_BASE(1) + WIN1_OFFSET)) -#define SRAM_INBOX_SIZE ((uint32_t)WIN_SIZE(1)) - -/* window 2 */ -#define SRAM_DEBUG_BASE ((uint32_t)(WIN_BASE(2) + WIN2_OFFSET)) -#define SRAM_DEBUG_SIZE 0x800 - -#define SRAM_EXCEPT_BASE (SRAM_DEBUG_BASE + SRAM_DEBUG_SIZE) -#define SRAM_EXCEPT_SIZE 0x800 - -#define SRAM_STREAM_BASE (SRAM_EXCEPT_BASE + SRAM_EXCEPT_SIZE) -#define SRAM_STREAM_SIZE 0x1000 +#include /* Stack configuration */ #define SOF_STACK_SIZE (CONFIG_SOF_STACK_SIZE) diff --git a/src/kernel/platform/ace30/include/platform/lib/mailbox.h b/src/platform/ace30/include/platform/lib/mailbox.h similarity index 100% rename from src/kernel/platform/ace30/include/platform/lib/mailbox.h rename to src/platform/ace30/include/platform/lib/mailbox.h diff --git a/src/platform/ace30/include/platform/lib/mailbox_layout.h b/src/platform/ace30/include/platform/lib/mailbox_layout.h new file mode 100644 index 000000000000..8885666c4f19 --- /dev/null +++ b/src/platform/ace30/include/platform/lib/mailbox_layout.h @@ -0,0 +1,45 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * + * Copyright(c) 2022-2024 Intel Corporation. + */ + +/** + * \file platform/lib/mailbox_layout.h + * \brief Layout of the host memory windows used by the mailbox + * + * User-space code can include this, through sof/lib/mailbox.h. The rest + * of the platform memory map is in platform/lib/memory.h. + */ + +#ifndef __PLATFORM_LIB_MAILBOX_LAYOUT_H__ +#define __PLATFORM_LIB_MAILBOX_LAYOUT_H__ + +#include +#include +#include + +/* HP SRAM windows */ +#define WIN_BASE(n) DT_REG_ADDR(DT_PHANDLE(MEM_WINDOW_NODE(n), memory)) + +/* window 0 */ +#define SRAM_SW_REG_BASE ((uint32_t)(WIN_BASE(0) + WIN0_OFFSET)) +#define SRAM_SW_REG_SIZE 0x1000 + +#define SRAM_OUTBOX_BASE (SRAM_SW_REG_BASE + SRAM_SW_REG_SIZE) +#define SRAM_OUTBOX_SIZE 0x1000 + +/* window 1 */ +#define SRAM_INBOX_BASE ((uint32_t)(WIN_BASE(1) + WIN1_OFFSET)) +#define SRAM_INBOX_SIZE ((uint32_t)WIN_SIZE(1)) + +/* window 2 */ +#define SRAM_DEBUG_BASE ((uint32_t)(WIN_BASE(2) + WIN2_OFFSET)) +#define SRAM_DEBUG_SIZE 0x800 + +#define SRAM_EXCEPT_BASE (SRAM_DEBUG_BASE + SRAM_DEBUG_SIZE) +#define SRAM_EXCEPT_SIZE 0x800 + +#define SRAM_STREAM_BASE (SRAM_EXCEPT_BASE + SRAM_EXCEPT_SIZE) +#define SRAM_STREAM_SIZE 0x1000 + +#endif /* __PLATFORM_LIB_MAILBOX_LAYOUT_H__ */ diff --git a/src/kernel/platform/intel/ace/include/ace/lib/mailbox.h b/src/platform/intel/ace/include/ace/lib/mailbox.h similarity index 97% rename from src/kernel/platform/intel/ace/include/ace/lib/mailbox.h rename to src/platform/intel/ace/include/ace/lib/mailbox.h index b3cccad8c85a..537f042cc57d 100644 --- a/src/kernel/platform/intel/ace/include/ace/lib/mailbox.h +++ b/src/platform/intel/ace/include/ace/lib/mailbox.h @@ -12,7 +12,8 @@ #define __ACE_LIB_MAILBOX_H__ #include -#include +#include +#include #include #include #include diff --git a/src/kernel/platform/lunarlake/include/platform/lib/mailbox.h b/src/platform/lunarlake/include/platform/lib/mailbox.h similarity index 100% rename from src/kernel/platform/lunarlake/include/platform/lib/mailbox.h rename to src/platform/lunarlake/include/platform/lib/mailbox.h diff --git a/src/platform/lunarlake/include/platform/lib/mailbox_layout.h b/src/platform/lunarlake/include/platform/lib/mailbox_layout.h new file mode 100644 index 000000000000..e4c7cbd253d7 --- /dev/null +++ b/src/platform/lunarlake/include/platform/lib/mailbox_layout.h @@ -0,0 +1,45 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * + * Copyright(c) 2023 Intel Corporation. All rights reserved. + */ + +/** + * \file platform/lib/mailbox_layout.h + * \brief Layout of the host memory windows used by the mailbox + * + * User-space code can include this, through sof/lib/mailbox.h. The rest + * of the platform memory map is in platform/lib/memory.h. + */ + +#ifndef __PLATFORM_LIB_MAILBOX_LAYOUT_H__ +#define __PLATFORM_LIB_MAILBOX_LAYOUT_H__ + +#include +#include +#include + +/* HP SRAM windows */ +#define WIN_BASE(n) DT_REG_ADDR(DT_PHANDLE(MEM_WINDOW_NODE(n), memory)) + +/* window 0 */ +#define SRAM_SW_REG_BASE ((uint32_t)(WIN_BASE(0) + WIN0_OFFSET)) +#define SRAM_SW_REG_SIZE 0x1000 + +#define SRAM_OUTBOX_BASE (SRAM_SW_REG_BASE + SRAM_SW_REG_SIZE) +#define SRAM_OUTBOX_SIZE 0x1000 + +/* window 1 */ +#define SRAM_INBOX_BASE ((uint32_t)(WIN_BASE(1) + WIN1_OFFSET)) +#define SRAM_INBOX_SIZE ((uint32_t)WIN_SIZE(1)) + +/* window 2 */ +#define SRAM_DEBUG_BASE ((uint32_t)(WIN_BASE(2) + WIN2_OFFSET)) +#define SRAM_DEBUG_SIZE 0x800 + +#define SRAM_EXCEPT_BASE (SRAM_DEBUG_BASE + SRAM_DEBUG_SIZE) +#define SRAM_EXCEPT_SIZE 0x800 + +#define SRAM_STREAM_BASE (SRAM_EXCEPT_BASE + SRAM_EXCEPT_SIZE) +#define SRAM_STREAM_SIZE 0x1000 + +#endif /* __PLATFORM_LIB_MAILBOX_LAYOUT_H__ */ diff --git a/src/kernel/platform/meteorlake/include/platform/lib/mailbox.h b/src/platform/meteorlake/include/platform/lib/mailbox.h similarity index 100% rename from src/kernel/platform/meteorlake/include/platform/lib/mailbox.h rename to src/platform/meteorlake/include/platform/lib/mailbox.h diff --git a/src/platform/meteorlake/include/platform/lib/mailbox_layout.h b/src/platform/meteorlake/include/platform/lib/mailbox_layout.h new file mode 100644 index 000000000000..5ddba7288eb9 --- /dev/null +++ b/src/platform/meteorlake/include/platform/lib/mailbox_layout.h @@ -0,0 +1,45 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * + * Copyright(c) 2022 Intel Corporation. All rights reserved. + */ + +/** + * \file platform/lib/mailbox_layout.h + * \brief Layout of the host memory windows used by the mailbox + * + * User-space code can include this, through sof/lib/mailbox.h. The rest + * of the platform memory map is in platform/lib/memory.h. + */ + +#ifndef __PLATFORM_LIB_MAILBOX_LAYOUT_H__ +#define __PLATFORM_LIB_MAILBOX_LAYOUT_H__ + +#include +#include +#include + +/* HP SRAM windows */ +#define WIN_BASE(n) DT_REG_ADDR(DT_PHANDLE(MEM_WINDOW_NODE(n), memory)) + +/* window 0 */ +#define SRAM_SW_REG_BASE ((uint32_t)(WIN_BASE(0) + WIN0_OFFSET)) +#define SRAM_SW_REG_SIZE 0x1000 + +#define SRAM_OUTBOX_BASE (SRAM_SW_REG_BASE + SRAM_SW_REG_SIZE) +#define SRAM_OUTBOX_SIZE 0x1000 + +/* window 1 */ +#define SRAM_INBOX_BASE ((uint32_t)(WIN_BASE(1) + WIN1_OFFSET)) +#define SRAM_INBOX_SIZE ((uint32_t)WIN_SIZE(1)) + +/* window 2 */ +#define SRAM_DEBUG_BASE ((uint32_t)(WIN_BASE(2) + WIN2_OFFSET)) +#define SRAM_DEBUG_SIZE 0x800 + +#define SRAM_EXCEPT_BASE (SRAM_DEBUG_BASE + SRAM_DEBUG_SIZE) +#define SRAM_EXCEPT_SIZE 0x800 + +#define SRAM_STREAM_BASE (SRAM_EXCEPT_BASE + SRAM_EXCEPT_SIZE) +#define SRAM_STREAM_SIZE 0x1000 + +#endif /* __PLATFORM_LIB_MAILBOX_LAYOUT_H__ */ diff --git a/src/kernel/platform/novalake/include/platform/lib/mailbox.h b/src/platform/novalake/include/platform/lib/mailbox.h similarity index 100% rename from src/kernel/platform/novalake/include/platform/lib/mailbox.h rename to src/platform/novalake/include/platform/lib/mailbox.h diff --git a/src/platform/novalake/include/platform/lib/mailbox_layout.h b/src/platform/novalake/include/platform/lib/mailbox_layout.h new file mode 100644 index 000000000000..8885666c4f19 --- /dev/null +++ b/src/platform/novalake/include/platform/lib/mailbox_layout.h @@ -0,0 +1,45 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * + * Copyright(c) 2022-2024 Intel Corporation. + */ + +/** + * \file platform/lib/mailbox_layout.h + * \brief Layout of the host memory windows used by the mailbox + * + * User-space code can include this, through sof/lib/mailbox.h. The rest + * of the platform memory map is in platform/lib/memory.h. + */ + +#ifndef __PLATFORM_LIB_MAILBOX_LAYOUT_H__ +#define __PLATFORM_LIB_MAILBOX_LAYOUT_H__ + +#include +#include +#include + +/* HP SRAM windows */ +#define WIN_BASE(n) DT_REG_ADDR(DT_PHANDLE(MEM_WINDOW_NODE(n), memory)) + +/* window 0 */ +#define SRAM_SW_REG_BASE ((uint32_t)(WIN_BASE(0) + WIN0_OFFSET)) +#define SRAM_SW_REG_SIZE 0x1000 + +#define SRAM_OUTBOX_BASE (SRAM_SW_REG_BASE + SRAM_SW_REG_SIZE) +#define SRAM_OUTBOX_SIZE 0x1000 + +/* window 1 */ +#define SRAM_INBOX_BASE ((uint32_t)(WIN_BASE(1) + WIN1_OFFSET)) +#define SRAM_INBOX_SIZE ((uint32_t)WIN_SIZE(1)) + +/* window 2 */ +#define SRAM_DEBUG_BASE ((uint32_t)(WIN_BASE(2) + WIN2_OFFSET)) +#define SRAM_DEBUG_SIZE 0x800 + +#define SRAM_EXCEPT_BASE (SRAM_DEBUG_BASE + SRAM_DEBUG_SIZE) +#define SRAM_EXCEPT_SIZE 0x800 + +#define SRAM_STREAM_BASE (SRAM_EXCEPT_BASE + SRAM_EXCEPT_SIZE) +#define SRAM_STREAM_SIZE 0x1000 + +#endif /* __PLATFORM_LIB_MAILBOX_LAYOUT_H__ */ diff --git a/test/cmocka/CMakeLists.txt b/test/cmocka/CMakeLists.txt index 98a64af7d584..fe6fda486a71 100644 --- a/test/cmocka/CMakeLists.txt +++ b/test/cmocka/CMakeLists.txt @@ -45,6 +45,7 @@ if(CONFIG_CAVS) target_include_directories(sof_options INTERFACE ${PROJECT_SOURCE_DIR}/src/kernel/platform/intel/cavs/include) elseif(CONFIG_ACE) target_include_directories(sof_options INTERFACE ${PROJECT_SOURCE_DIR}/src/kernel/platform/intel/ace/include) + target_include_directories(sof_options INTERFACE ${PROJECT_SOURCE_DIR}/src/platform/intel/ace/include) endif() # linker script, just for log entries diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt index 72eedc76c943..609388ed8b91 100644 --- a/zephyr/CMakeLists.txt +++ b/zephyr/CMakeLists.txt @@ -310,6 +310,7 @@ if (CONFIG_SOC_SERIES_INTEL_ADSP_ACE) endif() zephyr_include_directories(${SOF_PLATFORM_PATH}/intel/ace/include) + zephyr_include_directories(${SOF_USER_PLATFORM_PATH}/intel/ace/include) zephyr_include_directories(${SOF_PLATFORM_PATH}/${PLATFORM}/include) endif() From 508aee4cee887ee719fa4357f7292f79bcbc44e7 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Mon, 16 Nov 2026 21:22:32 +0000 Subject: [PATCH 03/10] platform: intel: cavs: move the mailbox headers to src/platform As for the ACE platforms, move the shared cavs/lib/mailbox.h and the TGL mailbox header to src/platform, and move the window layout out of the TGL memory map into platform/lib/mailbox_layout.h there, with the HP SRAM base address that the windows are at. The memory map includes it, and cavs/lib/mailbox.h includes it, and rtos/cache.h for its accessors, instead of the memory map. No functional change. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Liam Girdwood --- .../tigerlake/include/platform/lib/memory.h | 28 +---------- .../intel/cavs/include/cavs/lib/mailbox.h | 3 +- .../tigerlake/include/platform/lib/mailbox.h | 0 .../include/platform/lib/mailbox_layout.h | 48 +++++++++++++++++++ test/cmocka/CMakeLists.txt | 1 + test/cmocka/src/lib/alloc/CMakeLists.txt | 1 + zephyr/CMakeLists.txt | 1 + 7 files changed, 54 insertions(+), 28 deletions(-) rename src/{kernel => }/platform/intel/cavs/include/cavs/lib/mailbox.h (98%) rename src/{kernel => }/platform/tigerlake/include/platform/lib/mailbox.h (100%) create mode 100644 src/platform/tigerlake/include/platform/lib/mailbox_layout.h diff --git a/src/kernel/platform/tigerlake/include/platform/lib/memory.h b/src/kernel/platform/tigerlake/include/platform/lib/memory.h index bf82e2483b8f..9b81c2f2eb90 100644 --- a/src/kernel/platform/tigerlake/include/platform/lib/memory.h +++ b/src/kernel/platform/tigerlake/include/platform/lib/memory.h @@ -182,33 +182,7 @@ * +--------------------+-------------------------+-----------------------------+ */ -/* HP SRAM */ -#define HP_SRAM_BASE 0xBE000000 - -/* HP SRAM windows */ -/* window 0 */ -#define SRAM_SW_REG_BASE (HP_SRAM_BASE + 0x4000) -#define SRAM_SW_REG_SIZE 0x1000 - -#define SRAM_OUTBOX_BASE (SRAM_SW_REG_BASE + SRAM_SW_REG_SIZE) -#define SRAM_OUTBOX_SIZE 0x1000 - -/* window 1 */ -#define SRAM_INBOX_BASE (SRAM_OUTBOX_BASE + SRAM_OUTBOX_SIZE) -#define SRAM_INBOX_SIZE 0x2000 -/* window 2 */ -#define SRAM_DEBUG_BASE (SRAM_INBOX_BASE + SRAM_INBOX_SIZE) -#define SRAM_DEBUG_SIZE 0x800 - -#define SRAM_EXCEPT_BASE (SRAM_DEBUG_BASE + SRAM_DEBUG_SIZE) -#define SRAM_EXCEPT_SIZE 0x800 - -#define SRAM_STREAM_BASE (SRAM_EXCEPT_BASE + SRAM_EXCEPT_SIZE) -#define SRAM_STREAM_SIZE 0x1000 - -/* window 3 */ -#define SRAM_TRACE_BASE (SRAM_STREAM_BASE + SRAM_STREAM_SIZE) -#define SRAM_TRACE_SIZE 0x0 +#include #define HP_SRAM_WIN0_BASE SRAM_SW_REG_BASE #define HP_SRAM_WIN0_SIZE (SRAM_SW_REG_SIZE + SRAM_OUTBOX_SIZE) diff --git a/src/kernel/platform/intel/cavs/include/cavs/lib/mailbox.h b/src/platform/intel/cavs/include/cavs/lib/mailbox.h similarity index 98% rename from src/kernel/platform/intel/cavs/include/cavs/lib/mailbox.h rename to src/platform/intel/cavs/include/cavs/lib/mailbox.h index 063ccfcf6f3e..7cd18d14c9be 100644 --- a/src/kernel/platform/intel/cavs/include/cavs/lib/mailbox.h +++ b/src/platform/intel/cavs/include/cavs/lib/mailbox.h @@ -12,7 +12,8 @@ #define __CAVS_LIB_MAILBOX_H__ #include -#include +#include +#include #include #include #include diff --git a/src/kernel/platform/tigerlake/include/platform/lib/mailbox.h b/src/platform/tigerlake/include/platform/lib/mailbox.h similarity index 100% rename from src/kernel/platform/tigerlake/include/platform/lib/mailbox.h rename to src/platform/tigerlake/include/platform/lib/mailbox.h diff --git a/src/platform/tigerlake/include/platform/lib/mailbox_layout.h b/src/platform/tigerlake/include/platform/lib/mailbox_layout.h new file mode 100644 index 000000000000..e45946210e1e --- /dev/null +++ b/src/platform/tigerlake/include/platform/lib/mailbox_layout.h @@ -0,0 +1,48 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * + * Copyright(c) 2017 Intel Corporation. All rights reserved. + * + * Keyon Jie + * Rander Wang + */ + +/** + * \file platform/lib/mailbox_layout.h + * \brief Layout of the host memory windows used by the mailbox + * + * User-space code can include this, through sof/lib/mailbox.h. The rest + * of the platform memory map is in platform/lib/memory.h. + */ + +#ifndef __PLATFORM_LIB_MAILBOX_LAYOUT_H__ +#define __PLATFORM_LIB_MAILBOX_LAYOUT_H__ + +/* HP SRAM */ +#define HP_SRAM_BASE 0xBE000000 + +/* HP SRAM windows */ +/* window 0 */ +#define SRAM_SW_REG_BASE (HP_SRAM_BASE + 0x4000) +#define SRAM_SW_REG_SIZE 0x1000 + +#define SRAM_OUTBOX_BASE (SRAM_SW_REG_BASE + SRAM_SW_REG_SIZE) +#define SRAM_OUTBOX_SIZE 0x1000 + +/* window 1 */ +#define SRAM_INBOX_BASE (SRAM_OUTBOX_BASE + SRAM_OUTBOX_SIZE) +#define SRAM_INBOX_SIZE 0x2000 +/* window 2 */ +#define SRAM_DEBUG_BASE (SRAM_INBOX_BASE + SRAM_INBOX_SIZE) +#define SRAM_DEBUG_SIZE 0x800 + +#define SRAM_EXCEPT_BASE (SRAM_DEBUG_BASE + SRAM_DEBUG_SIZE) +#define SRAM_EXCEPT_SIZE 0x800 + +#define SRAM_STREAM_BASE (SRAM_EXCEPT_BASE + SRAM_EXCEPT_SIZE) +#define SRAM_STREAM_SIZE 0x1000 + +/* window 3 */ +#define SRAM_TRACE_BASE (SRAM_STREAM_BASE + SRAM_STREAM_SIZE) +#define SRAM_TRACE_SIZE 0x0 + +#endif /* __PLATFORM_LIB_MAILBOX_LAYOUT_H__ */ diff --git a/test/cmocka/CMakeLists.txt b/test/cmocka/CMakeLists.txt index fe6fda486a71..c3b2dc0e88fc 100644 --- a/test/cmocka/CMakeLists.txt +++ b/test/cmocka/CMakeLists.txt @@ -43,6 +43,7 @@ endif() if(CONFIG_CAVS) target_include_directories(sof_options INTERFACE ${PROJECT_SOURCE_DIR}/src/kernel/platform/intel/cavs/include) + target_include_directories(sof_options INTERFACE ${PROJECT_SOURCE_DIR}/src/platform/intel/cavs/include) elseif(CONFIG_ACE) target_include_directories(sof_options INTERFACE ${PROJECT_SOURCE_DIR}/src/kernel/platform/intel/ace/include) target_include_directories(sof_options INTERFACE ${PROJECT_SOURCE_DIR}/src/platform/intel/ace/include) diff --git a/test/cmocka/src/lib/alloc/CMakeLists.txt b/test/cmocka/src/lib/alloc/CMakeLists.txt index 10bef8205b4b..5e899d3955af 100644 --- a/test/cmocka/src/lib/alloc/CMakeLists.txt +++ b/test/cmocka/src/lib/alloc/CMakeLists.txt @@ -7,3 +7,4 @@ cmocka_test(alloc ) target_include_directories(sof_options INTERFACE ${PROJECT_SOURCE_DIR}/src/kernel/platform/intel/cavs/include) +target_include_directories(sof_options INTERFACE ${PROJECT_SOURCE_DIR}/src/platform/intel/cavs/include) diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt index 609388ed8b91..9e4f19b15d86 100644 --- a/zephyr/CMakeLists.txt +++ b/zephyr/CMakeLists.txt @@ -258,6 +258,7 @@ if (CONFIG_SOC_SERIES_INTEL_CAVS_V25) set(PLATFORM "tigerlake") zephyr_include_directories(${SOF_PLATFORM_PATH}/intel/cavs/include) + zephyr_include_directories(${SOF_USER_PLATFORM_PATH}/intel/cavs/include) endif() # Intel ACE 1.5 and newer platforms From b81952185a29efa179007aa0e291bf139f54be0f Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Mon, 16 Nov 2026 21:22:46 +0000 Subject: [PATCH 04/10] platform: imx: move the mailbox headers to src/platform Move the i.MX mailbox headers to src/platform. On imx8, imx8m and imx8ulp they used the window layout of the memory map: move it to platform/lib/mailbox_layout.h there, with the SDRAM1 base address that the mailbox is at, and include it from the memory map and the mailbox header instead of the memory map. The imx8m_cm7, imx93 and imx95 mailbox headers define the windows themselves. Add src/platform/imx8 to the imx8 code owner entry. No functional change. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Liam Girdwood --- CODEOWNERS | 1 + .../imx8/include/platform/lib/memory.h | 26 +--------- .../imx8m/include/platform/lib/memory.h | 26 +--------- .../imx8ulp/include/platform/lib/memory.h | 26 +--------- .../imx8/include/platform/lib/mailbox.h | 2 +- .../include/platform/lib/mailbox_layout.h | 45 ++++++++++++++++++ .../imx8m/include/platform/lib/mailbox.h | 2 +- .../include/platform/lib/mailbox_layout.h | 45 ++++++++++++++++++ .../imx8m_cm7/include/platform/lib/mailbox.h | 0 .../imx8ulp/include/platform/lib/mailbox.h | 2 +- .../include/platform/lib/mailbox_layout.h | 47 +++++++++++++++++++ .../imx93_a55/include/platform/lib/mailbox.h | 0 .../imx95/include/platform/lib/mailbox.h | 0 13 files changed, 144 insertions(+), 78 deletions(-) rename src/{kernel => }/platform/imx8/include/platform/lib/mailbox.h (98%) create mode 100644 src/platform/imx8/include/platform/lib/mailbox_layout.h rename src/{kernel => }/platform/imx8m/include/platform/lib/mailbox.h (98%) create mode 100644 src/platform/imx8m/include/platform/lib/mailbox_layout.h rename src/{kernel => }/platform/imx8m_cm7/include/platform/lib/mailbox.h (100%) rename src/{kernel => }/platform/imx8ulp/include/platform/lib/mailbox.h (98%) create mode 100644 src/platform/imx8ulp/include/platform/lib/mailbox_layout.h rename src/{kernel => }/platform/imx93_a55/include/platform/lib/mailbox.h (100%) rename src/{kernel => }/platform/imx95/include/platform/lib/mailbox.h (100%) diff --git a/CODEOWNERS b/CODEOWNERS index e06147afb8cb..551110534d13 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -48,6 +48,7 @@ src/audio/google/* @thesofproject/google # platforms src/kernel/platform/imx8/** @dbaluta +src/platform/imx8/** @dbaluta src/kernel/platform/amd/** @bhiregoudar @sunilkumardommati src/kernel/platform/mtk/** @yaochunhung @kuanhsuncheng diff --git a/src/kernel/platform/imx8/include/platform/lib/memory.h b/src/kernel/platform/imx8/include/platform/lib/memory.h index 0388e2481c6b..4127dfe160a2 100644 --- a/src/kernel/platform/imx8/include/platform/lib/memory.h +++ b/src/kernel/platform/imx8/include/platform/lib/memory.h @@ -26,7 +26,6 @@ #define SDRAM0_BASE 0x92400000 #define SDRAM0_SIZE 0x800000 -#define SDRAM1_BASE 0x92C00000 #define SDRAM1_SIZE 0x800000 #define XSHAL_MU13_SIDEB_BYPASS_PADDR 0x5D310000 @@ -72,30 +71,7 @@ * +---------------------+----------------+-----------------------------------+ */ -/* Mailbox configuration */ -#define SRAM_OUTBOX_BASE SDRAM1_BASE -#define SRAM_OUTBOX_SIZE 0x1000 -#define SRAM_OUTBOX_OFFSET 0 - -#define SRAM_INBOX_BASE (SRAM_OUTBOX_BASE + SRAM_OUTBOX_SIZE) -#define SRAM_INBOX_SIZE 0x1000 -#define SRAM_INBOX_OFFSET SRAM_OUTBOX_SIZE - -#define SRAM_DEBUG_BASE (SRAM_INBOX_BASE + SRAM_INBOX_SIZE) -#define SRAM_DEBUG_SIZE 0x800 -#define SRAM_DEBUG_OFFSET (SRAM_INBOX_OFFSET + SRAM_INBOX_SIZE) - -#define SRAM_EXCEPT_BASE (SRAM_DEBUG_BASE + SRAM_DEBUG_SIZE) -#define SRAM_EXCEPT_SIZE 0x800 -#define SRAM_EXCEPT_OFFSET (SRAM_DEBUG_OFFSET + SRAM_DEBUG_SIZE) - -#define SRAM_STREAM_BASE (SRAM_EXCEPT_BASE + SRAM_EXCEPT_SIZE) -#define SRAM_STREAM_SIZE 0x1000 -#define SRAM_STREAM_OFFSET (SRAM_EXCEPT_OFFSET + SRAM_EXCEPT_SIZE) - -#define SRAM_TRACE_BASE (SRAM_STREAM_BASE + SRAM_STREAM_SIZE) -#define SRAM_TRACE_SIZE 0x1000 -#define SRAM_TRACE_OFFSET (SRAM_STREAM_OFFSET + SRAM_STREAM_SIZE) +#include #define SOF_MAILBOX_SIZE (SRAM_INBOX_SIZE + SRAM_OUTBOX_SIZE \ + SRAM_DEBUG_SIZE + SRAM_EXCEPT_SIZE \ diff --git a/src/kernel/platform/imx8m/include/platform/lib/memory.h b/src/kernel/platform/imx8m/include/platform/lib/memory.h index fd0034a7fba3..5408dd847a60 100644 --- a/src/kernel/platform/imx8m/include/platform/lib/memory.h +++ b/src/kernel/platform/imx8m/include/platform/lib/memory.h @@ -26,7 +26,6 @@ #define SDRAM0_BASE 0x92400000 #define SDRAM0_SIZE 0x800000 -#define SDRAM1_BASE 0x92C00000 #define SDRAM1_SIZE 0x800000 #define XSHAL_MU2_SIDEB_BYPASS_PADDR 0x30E70000 @@ -90,30 +89,7 @@ * +---------------------+----------------+-----------------------------------+ */ -/* Mailbox configuration */ -#define SRAM_OUTBOX_BASE SDRAM1_BASE -#define SRAM_OUTBOX_SIZE 0x1000 -#define SRAM_OUTBOX_OFFSET 0 - -#define SRAM_INBOX_BASE (SRAM_OUTBOX_BASE + SRAM_OUTBOX_SIZE) -#define SRAM_INBOX_SIZE 0x1000 -#define SRAM_INBOX_OFFSET SRAM_OUTBOX_SIZE - -#define SRAM_DEBUG_BASE (SRAM_INBOX_BASE + SRAM_INBOX_SIZE) -#define SRAM_DEBUG_SIZE 0x800 -#define SRAM_DEBUG_OFFSET (SRAM_INBOX_OFFSET + SRAM_INBOX_SIZE) - -#define SRAM_EXCEPT_BASE (SRAM_DEBUG_BASE + SRAM_DEBUG_SIZE) -#define SRAM_EXCEPT_SIZE 0x800 -#define SRAM_EXCEPT_OFFSET (SRAM_DEBUG_OFFSET + SRAM_DEBUG_SIZE) - -#define SRAM_STREAM_BASE (SRAM_EXCEPT_BASE + SRAM_EXCEPT_SIZE) -#define SRAM_STREAM_SIZE 0x1000 -#define SRAM_STREAM_OFFSET (SRAM_EXCEPT_OFFSET + SRAM_EXCEPT_SIZE) - -#define SRAM_TRACE_BASE (SRAM_STREAM_BASE + SRAM_STREAM_SIZE) -#define SRAM_TRACE_SIZE 0x1000 -#define SRAM_TRACE_OFFSET (SRAM_STREAM_OFFSET + SRAM_STREAM_SIZE) +#include #define SOF_MAILBOX_SIZE (SRAM_INBOX_SIZE + SRAM_OUTBOX_SIZE \ + SRAM_DEBUG_SIZE + SRAM_EXCEPT_SIZE \ diff --git a/src/kernel/platform/imx8ulp/include/platform/lib/memory.h b/src/kernel/platform/imx8ulp/include/platform/lib/memory.h index e8c18b00c58c..55b8bdf2bd8d 100644 --- a/src/kernel/platform/imx8ulp/include/platform/lib/memory.h +++ b/src/kernel/platform/imx8ulp/include/platform/lib/memory.h @@ -23,7 +23,6 @@ #define SDRAM0_BASE 0x1a000000 #define SDRAM0_SIZE 0x800000 -#define SDRAM1_BASE 0x1a800000 #define SDRAM1_SIZE 0x800000 /* physical address in Arm side */ @@ -74,30 +73,7 @@ * +---------------------+----------------+-----------------------------------+ */ -/* Mailbox configuration */ -#define SRAM_OUTBOX_BASE SDRAM1_BASE -#define SRAM_OUTBOX_SIZE 0x1000 -#define SRAM_OUTBOX_OFFSET 0 - -#define SRAM_INBOX_BASE (SRAM_OUTBOX_BASE + SRAM_OUTBOX_SIZE) -#define SRAM_INBOX_SIZE 0x1000 -#define SRAM_INBOX_OFFSET SRAM_OUTBOX_SIZE - -#define SRAM_DEBUG_BASE (SRAM_INBOX_BASE + SRAM_INBOX_SIZE) -#define SRAM_DEBUG_SIZE 0x2800 -#define SRAM_DEBUG_OFFSET (SRAM_INBOX_OFFSET + SRAM_INBOX_SIZE) - -#define SRAM_EXCEPT_BASE (SRAM_DEBUG_BASE + SRAM_DEBUG_SIZE) -#define SRAM_EXCEPT_SIZE 0x800 -#define SRAM_EXCEPT_OFFSET (SRAM_DEBUG_OFFSET + SRAM_DEBUG_SIZE) - -#define SRAM_STREAM_BASE (SRAM_EXCEPT_BASE + SRAM_EXCEPT_SIZE) -#define SRAM_STREAM_SIZE 0x1000 -#define SRAM_STREAM_OFFSET (SRAM_EXCEPT_OFFSET + SRAM_EXCEPT_SIZE) - -#define SRAM_TRACE_BASE (SRAM_STREAM_BASE + SRAM_STREAM_SIZE) -#define SRAM_TRACE_SIZE 0x1000 -#define SRAM_TRACE_OFFSET (SRAM_STREAM_OFFSET + SRAM_STREAM_SIZE) +#include #define SOF_MAILBOX_SIZE (SRAM_INBOX_SIZE + SRAM_OUTBOX_SIZE \ + SRAM_DEBUG_SIZE + SRAM_EXCEPT_SIZE \ diff --git a/src/kernel/platform/imx8/include/platform/lib/mailbox.h b/src/platform/imx8/include/platform/lib/mailbox.h similarity index 98% rename from src/kernel/platform/imx8/include/platform/lib/mailbox.h rename to src/platform/imx8/include/platform/lib/mailbox.h index 1b7498cf08d6..2c5010b86710 100644 --- a/src/kernel/platform/imx8/include/platform/lib/mailbox.h +++ b/src/platform/imx8/include/platform/lib/mailbox.h @@ -10,7 +10,7 @@ #ifndef __PLATFORM_LIB_MAILBOX_H__ #define __PLATFORM_LIB_MAILBOX_H__ -#include +#include #include #include diff --git a/src/platform/imx8/include/platform/lib/mailbox_layout.h b/src/platform/imx8/include/platform/lib/mailbox_layout.h new file mode 100644 index 000000000000..bb8d235264b3 --- /dev/null +++ b/src/platform/imx8/include/platform/lib/mailbox_layout.h @@ -0,0 +1,45 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * + * Copyright 2019 NXP + */ + +/** + * \file platform/lib/mailbox_layout.h + * \brief Layout of the host memory windows used by the mailbox + * + * User-space code can include this, through sof/lib/mailbox.h. The rest + * of the platform memory map is in platform/lib/memory.h. + */ + +#ifndef __PLATFORM_LIB_MAILBOX_LAYOUT_H__ +#define __PLATFORM_LIB_MAILBOX_LAYOUT_H__ + +/* the mailbox is at the start of SDRAM1 */ +#define SDRAM1_BASE 0x92C00000 + +/* Mailbox configuration */ +#define SRAM_OUTBOX_BASE SDRAM1_BASE +#define SRAM_OUTBOX_SIZE 0x1000 +#define SRAM_OUTBOX_OFFSET 0 + +#define SRAM_INBOX_BASE (SRAM_OUTBOX_BASE + SRAM_OUTBOX_SIZE) +#define SRAM_INBOX_SIZE 0x1000 +#define SRAM_INBOX_OFFSET SRAM_OUTBOX_SIZE + +#define SRAM_DEBUG_BASE (SRAM_INBOX_BASE + SRAM_INBOX_SIZE) +#define SRAM_DEBUG_SIZE 0x800 +#define SRAM_DEBUG_OFFSET (SRAM_INBOX_OFFSET + SRAM_INBOX_SIZE) + +#define SRAM_EXCEPT_BASE (SRAM_DEBUG_BASE + SRAM_DEBUG_SIZE) +#define SRAM_EXCEPT_SIZE 0x800 +#define SRAM_EXCEPT_OFFSET (SRAM_DEBUG_OFFSET + SRAM_DEBUG_SIZE) + +#define SRAM_STREAM_BASE (SRAM_EXCEPT_BASE + SRAM_EXCEPT_SIZE) +#define SRAM_STREAM_SIZE 0x1000 +#define SRAM_STREAM_OFFSET (SRAM_EXCEPT_OFFSET + SRAM_EXCEPT_SIZE) + +#define SRAM_TRACE_BASE (SRAM_STREAM_BASE + SRAM_STREAM_SIZE) +#define SRAM_TRACE_SIZE 0x1000 +#define SRAM_TRACE_OFFSET (SRAM_STREAM_OFFSET + SRAM_STREAM_SIZE) + +#endif /* __PLATFORM_LIB_MAILBOX_LAYOUT_H__ */ diff --git a/src/kernel/platform/imx8m/include/platform/lib/mailbox.h b/src/platform/imx8m/include/platform/lib/mailbox.h similarity index 98% rename from src/kernel/platform/imx8m/include/platform/lib/mailbox.h rename to src/platform/imx8m/include/platform/lib/mailbox.h index 7a7e0d643fd0..fee90e9b7ada 100644 --- a/src/kernel/platform/imx8m/include/platform/lib/mailbox.h +++ b/src/platform/imx8m/include/platform/lib/mailbox.h @@ -10,7 +10,7 @@ #ifndef __PLATFORM_LIB_MAILBOX_H__ #define __PLATFORM_LIB_MAILBOX_H__ -#include +#include #include #include diff --git a/src/platform/imx8m/include/platform/lib/mailbox_layout.h b/src/platform/imx8m/include/platform/lib/mailbox_layout.h new file mode 100644 index 000000000000..61fd3a6db001 --- /dev/null +++ b/src/platform/imx8m/include/platform/lib/mailbox_layout.h @@ -0,0 +1,45 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * + * Copyright 2020 NXP + */ + +/** + * \file platform/lib/mailbox_layout.h + * \brief Layout of the host memory windows used by the mailbox + * + * User-space code can include this, through sof/lib/mailbox.h. The rest + * of the platform memory map is in platform/lib/memory.h. + */ + +#ifndef __PLATFORM_LIB_MAILBOX_LAYOUT_H__ +#define __PLATFORM_LIB_MAILBOX_LAYOUT_H__ + +/* the mailbox is at the start of SDRAM1 */ +#define SDRAM1_BASE 0x92C00000 + +/* Mailbox configuration */ +#define SRAM_OUTBOX_BASE SDRAM1_BASE +#define SRAM_OUTBOX_SIZE 0x1000 +#define SRAM_OUTBOX_OFFSET 0 + +#define SRAM_INBOX_BASE (SRAM_OUTBOX_BASE + SRAM_OUTBOX_SIZE) +#define SRAM_INBOX_SIZE 0x1000 +#define SRAM_INBOX_OFFSET SRAM_OUTBOX_SIZE + +#define SRAM_DEBUG_BASE (SRAM_INBOX_BASE + SRAM_INBOX_SIZE) +#define SRAM_DEBUG_SIZE 0x800 +#define SRAM_DEBUG_OFFSET (SRAM_INBOX_OFFSET + SRAM_INBOX_SIZE) + +#define SRAM_EXCEPT_BASE (SRAM_DEBUG_BASE + SRAM_DEBUG_SIZE) +#define SRAM_EXCEPT_SIZE 0x800 +#define SRAM_EXCEPT_OFFSET (SRAM_DEBUG_OFFSET + SRAM_DEBUG_SIZE) + +#define SRAM_STREAM_BASE (SRAM_EXCEPT_BASE + SRAM_EXCEPT_SIZE) +#define SRAM_STREAM_SIZE 0x1000 +#define SRAM_STREAM_OFFSET (SRAM_EXCEPT_OFFSET + SRAM_EXCEPT_SIZE) + +#define SRAM_TRACE_BASE (SRAM_STREAM_BASE + SRAM_STREAM_SIZE) +#define SRAM_TRACE_SIZE 0x1000 +#define SRAM_TRACE_OFFSET (SRAM_STREAM_OFFSET + SRAM_STREAM_SIZE) + +#endif /* __PLATFORM_LIB_MAILBOX_LAYOUT_H__ */ diff --git a/src/kernel/platform/imx8m_cm7/include/platform/lib/mailbox.h b/src/platform/imx8m_cm7/include/platform/lib/mailbox.h similarity index 100% rename from src/kernel/platform/imx8m_cm7/include/platform/lib/mailbox.h rename to src/platform/imx8m_cm7/include/platform/lib/mailbox.h diff --git a/src/kernel/platform/imx8ulp/include/platform/lib/mailbox.h b/src/platform/imx8ulp/include/platform/lib/mailbox.h similarity index 98% rename from src/kernel/platform/imx8ulp/include/platform/lib/mailbox.h rename to src/platform/imx8ulp/include/platform/lib/mailbox.h index f06560ba41c1..bf6021d58b75 100644 --- a/src/kernel/platform/imx8ulp/include/platform/lib/mailbox.h +++ b/src/platform/imx8ulp/include/platform/lib/mailbox.h @@ -10,7 +10,7 @@ #ifndef __PLATFORM_LIB_MAILBOX_H__ #define __PLATFORM_LIB_MAILBOX_H__ -#include +#include #include #include diff --git a/src/platform/imx8ulp/include/platform/lib/mailbox_layout.h b/src/platform/imx8ulp/include/platform/lib/mailbox_layout.h new file mode 100644 index 000000000000..5d75a7c808eb --- /dev/null +++ b/src/platform/imx8ulp/include/platform/lib/mailbox_layout.h @@ -0,0 +1,47 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * + * Copyright 2021 NXP + * + * Zhang Peng + */ + +/** + * \file platform/lib/mailbox_layout.h + * \brief Layout of the host memory windows used by the mailbox + * + * User-space code can include this, through sof/lib/mailbox.h. The rest + * of the platform memory map is in platform/lib/memory.h. + */ + +#ifndef __PLATFORM_LIB_MAILBOX_LAYOUT_H__ +#define __PLATFORM_LIB_MAILBOX_LAYOUT_H__ + +/* the mailbox is at the start of SDRAM1 */ +#define SDRAM1_BASE 0x1a800000 + +/* Mailbox configuration */ +#define SRAM_OUTBOX_BASE SDRAM1_BASE +#define SRAM_OUTBOX_SIZE 0x1000 +#define SRAM_OUTBOX_OFFSET 0 + +#define SRAM_INBOX_BASE (SRAM_OUTBOX_BASE + SRAM_OUTBOX_SIZE) +#define SRAM_INBOX_SIZE 0x1000 +#define SRAM_INBOX_OFFSET SRAM_OUTBOX_SIZE + +#define SRAM_DEBUG_BASE (SRAM_INBOX_BASE + SRAM_INBOX_SIZE) +#define SRAM_DEBUG_SIZE 0x2800 +#define SRAM_DEBUG_OFFSET (SRAM_INBOX_OFFSET + SRAM_INBOX_SIZE) + +#define SRAM_EXCEPT_BASE (SRAM_DEBUG_BASE + SRAM_DEBUG_SIZE) +#define SRAM_EXCEPT_SIZE 0x800 +#define SRAM_EXCEPT_OFFSET (SRAM_DEBUG_OFFSET + SRAM_DEBUG_SIZE) + +#define SRAM_STREAM_BASE (SRAM_EXCEPT_BASE + SRAM_EXCEPT_SIZE) +#define SRAM_STREAM_SIZE 0x1000 +#define SRAM_STREAM_OFFSET (SRAM_EXCEPT_OFFSET + SRAM_EXCEPT_SIZE) + +#define SRAM_TRACE_BASE (SRAM_STREAM_BASE + SRAM_STREAM_SIZE) +#define SRAM_TRACE_SIZE 0x1000 +#define SRAM_TRACE_OFFSET (SRAM_STREAM_OFFSET + SRAM_STREAM_SIZE) + +#endif /* __PLATFORM_LIB_MAILBOX_LAYOUT_H__ */ diff --git a/src/kernel/platform/imx93_a55/include/platform/lib/mailbox.h b/src/platform/imx93_a55/include/platform/lib/mailbox.h similarity index 100% rename from src/kernel/platform/imx93_a55/include/platform/lib/mailbox.h rename to src/platform/imx93_a55/include/platform/lib/mailbox.h diff --git a/src/kernel/platform/imx95/include/platform/lib/mailbox.h b/src/platform/imx95/include/platform/lib/mailbox.h similarity index 100% rename from src/kernel/platform/imx95/include/platform/lib/mailbox.h rename to src/platform/imx95/include/platform/lib/mailbox.h From 2296c61f775235526dd00741953d4805b7058022 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Mon, 16 Nov 2026 21:22:46 +0000 Subject: [PATCH 05/10] platform: qemu_xtensa: move the mailbox header to src/platform Move the qemu_xtensa mailbox header, which defines its windows and stubs out the software registers, to src/platform. No functional change. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Liam Girdwood --- .../platform/qemu_xtensa/include/platform/lib/mailbox.h | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/{kernel => }/platform/qemu_xtensa/include/platform/lib/mailbox.h (100%) diff --git a/src/kernel/platform/qemu_xtensa/include/platform/lib/mailbox.h b/src/platform/qemu_xtensa/include/platform/lib/mailbox.h similarity index 100% rename from src/kernel/platform/qemu_xtensa/include/platform/lib/mailbox.h rename to src/platform/qemu_xtensa/include/platform/lib/mailbox.h From cc547de9f30803e2ef59a6c94ccd87b52062edc6 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Mon, 16 Nov 2026 21:22:46 +0000 Subject: [PATCH 06/10] platform: posix, library: move the mailbox headers to src/platform Move the mailbox headers of the native_sim (posix) and host library platforms to src/platform, and move the mailbox window definitions out of their memory maps into platform/lib/mailbox_layout.h there. Add the new directories where the host builds, the testbench, the topology parser and the ZTest unit tests add the platform include directories. No functional change. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Liam Girdwood --- src/kernel/arch/host/CMakeLists.txt | 1 + .../library/include/platform/lib/memory.h | 4 +- .../posix/include/platform/lib/memory.h | 28 +---------- .../library/include/platform/lib/mailbox.h | 2 +- .../include/platform/lib/mailbox_layout.h | 23 +++++++++ .../posix/include/platform/lib/mailbox.h | 2 +- .../include/platform/lib/mailbox_layout.h | 47 +++++++++++++++++++ .../ztest/unit/audio/crossover/CMakeLists.txt | 1 + test/ztest/unit/audio/drc/CMakeLists.txt | 1 + test/ztest/unit/audio/selector/CMakeLists.txt | 1 + test/ztest/unit/dsrc/CMakeLists.txt | 1 + test/ztest/unit/fast-get/CMakeLists.txt | 1 + .../math/advanced/functions/CMakeLists.txt | 1 + test/ztest/unit/math/auditory/CMakeLists.txt | 1 + test/ztest/unit/math/dct/CMakeLists.txt | 1 + test/ztest/unit/math/fft/CMakeLists.txt | 1 + test/ztest/unit/math/fft_multi/CMakeLists.txt | 1 + test/ztest/unit/math/matrix/CMakeLists.txt | 1 + test/ztest/unit/objpool/CMakeLists.txt | 1 + tools/testbench/CMakeLists.txt | 1 + tools/tplg_parser/CMakeLists.txt | 1 + 21 files changed, 89 insertions(+), 32 deletions(-) rename src/{kernel => }/platform/library/include/platform/lib/mailbox.h (97%) create mode 100644 src/platform/library/include/platform/lib/mailbox_layout.h rename src/{kernel => }/platform/posix/include/platform/lib/mailbox.h (93%) create mode 100644 src/platform/posix/include/platform/lib/mailbox_layout.h diff --git a/src/kernel/arch/host/CMakeLists.txt b/src/kernel/arch/host/CMakeLists.txt index bc700f509094..4821aefb6019 100644 --- a/src/kernel/arch/host/CMakeLists.txt +++ b/src/kernel/arch/host/CMakeLists.txt @@ -3,6 +3,7 @@ # includes target_include_directories(sof_public_headers INTERFACE ${PROJECT_SOURCE_DIR}/src/kernel/arch/host/include) target_include_directories(sof_public_headers INTERFACE ${PROJECT_SOURCE_DIR}/src/kernel/platform/library/include) +target_include_directories(sof_public_headers INTERFACE ${PROJECT_SOURCE_DIR}/src/platform/library/include) include(CheckCCompilerFlag) if (NOT CONFIG_SOF_ZEPHYR_STRICT_HEADERS) diff --git a/src/kernel/platform/library/include/platform/lib/memory.h b/src/kernel/platform/library/include/platform/lib/memory.h index 512aa643e952..7342da638337 100644 --- a/src/kernel/platform/library/include/platform/lib/memory.h +++ b/src/kernel/platform/library/include/platform/lib/memory.h @@ -24,9 +24,7 @@ struct sof; #define SOF_STACK_SIZE (CONFIG_SOF_STACK_SIZE) -uint8_t *get_library_mailbox(void); - -#define MAILBOX_BASE get_library_mailbox() +#include #define PLATFORM_HEAP_SYSTEM 2 #define PLATFORM_HEAP_SYSTEM_RUNTIME CONFIG_CORE_COUNT diff --git a/src/kernel/platform/posix/include/platform/lib/memory.h b/src/kernel/platform/posix/include/platform/lib/memory.h index 398eeca822c7..9bfb5d9837a4 100644 --- a/src/kernel/platform/posix/include/platform/lib/memory.h +++ b/src/kernel/platform/posix/include/platform/lib/memory.h @@ -8,33 +8,7 @@ #include #include -/* - * Mailbox base macros must yield byte-pointer arithmetic so that the - * generic mailbox API in `sof/src/include/sof/lib/mailbox.h` - * (`MAILBOX_HOSTBOX_BASE + offset`, etc., where `offset` is a byte - * offset) addresses the intended byte. The backing storage is - * declared as `uint32_t[]` only for natural-alignment; addressing is - * done through a `uint8_t *` cast so byte offsets do not get scaled - * by `sizeof(uint32_t)`. Every other SOF platform defines these - * bases as plain byte addresses (integer literals or - * `SRAM_INBOX_BASE`), so the cast keeps POSIX consistent with that - * ABI. - */ -extern uint32_t posix_hostbox[]; -#define MAILBOX_HOSTBOX_SIZE SOF_IPC_MSG_MAX_SIZE -#define MAILBOX_HOSTBOX_BASE ((uint8_t *)&posix_hostbox[0]) - -extern uint32_t posix_dspbox[]; -#define MAILBOX_DSPBOX_SIZE 4096 -#define MAILBOX_DSPBOX_BASE ((uint8_t *)&posix_dspbox[0]) - -extern uint32_t posix_stream[]; -#define MAILBOX_STREAM_SIZE 4096 -#define MAILBOX_STREAM_BASE ((uint8_t *)&posix_stream[0]) - -extern uint32_t posix_trace[]; -#define MAILBOX_TRACE_BASE ((uint8_t *)&posix_trace[0]) -#define MAILBOX_TRACE_SIZE 4096 +#include #define PLATFORM_HEAP_SYSTEM 1 #define PLATFORM_HEAP_SYSTEM_RUNTIME 1 diff --git a/src/kernel/platform/library/include/platform/lib/mailbox.h b/src/platform/library/include/platform/lib/mailbox.h similarity index 97% rename from src/kernel/platform/library/include/platform/lib/mailbox.h rename to src/platform/library/include/platform/lib/mailbox.h index daa858481149..149db9fbb97a 100644 --- a/src/kernel/platform/library/include/platform/lib/mailbox.h +++ b/src/platform/library/include/platform/lib/mailbox.h @@ -10,7 +10,7 @@ #ifndef __PLATFORM_LIB_MAILBOX_H__ #define __PLATFORM_LIB_MAILBOX_H__ -#include +#include #include #include diff --git a/src/platform/library/include/platform/lib/mailbox_layout.h b/src/platform/library/include/platform/lib/mailbox_layout.h new file mode 100644 index 000000000000..8d67ece97679 --- /dev/null +++ b/src/platform/library/include/platform/lib/mailbox_layout.h @@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * + * Copyright(c) 2016 Intel Corporation. All rights reserved. + */ + +/** + * \file platform/lib/mailbox_layout.h + * \brief Layout of the host memory windows used by the mailbox + * + * User-space code can include this, through sof/lib/mailbox.h. The rest + * of the platform memory map is in platform/lib/memory.h. + */ + +#ifndef __PLATFORM_LIB_MAILBOX_LAYOUT_H__ +#define __PLATFORM_LIB_MAILBOX_LAYOUT_H__ + +#include + +uint8_t *get_library_mailbox(void); + +#define MAILBOX_BASE get_library_mailbox() + +#endif /* __PLATFORM_LIB_MAILBOX_LAYOUT_H__ */ diff --git a/src/kernel/platform/posix/include/platform/lib/mailbox.h b/src/platform/posix/include/platform/lib/mailbox.h similarity index 93% rename from src/kernel/platform/posix/include/platform/lib/mailbox.h rename to src/platform/posix/include/platform/lib/mailbox.h index 3a42e93f6ea2..e6a88aff0732 100644 --- a/src/kernel/platform/posix/include/platform/lib/mailbox.h +++ b/src/platform/posix/include/platform/lib/mailbox.h @@ -5,7 +5,7 @@ #ifndef PLATFORM_POSIX_LIB_MAILBOX_H #define PLATFORM_POSIX_LIB_MAILBOX_H -#include +#include static inline uint32_t mailbox_sw_reg_read(size_t offset) { diff --git a/src/platform/posix/include/platform/lib/mailbox_layout.h b/src/platform/posix/include/platform/lib/mailbox_layout.h new file mode 100644 index 000000000000..e0c54bd686f7 --- /dev/null +++ b/src/platform/posix/include/platform/lib/mailbox_layout.h @@ -0,0 +1,47 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2022 Google LLC. All rights reserved. + */ + +/** + * \file platform/lib/mailbox_layout.h + * \brief Layout of the host memory windows used by the mailbox + * + * User-space code can include this, through sof/lib/mailbox.h. The rest + * of the platform memory map is in platform/lib/memory.h. + */ + +#ifndef __PLATFORM_LIB_MAILBOX_LAYOUT_H__ +#define __PLATFORM_LIB_MAILBOX_LAYOUT_H__ + +#include +#include + +/* + * Mailbox base macros must yield byte-pointer arithmetic so that the + * generic mailbox API in `sof/src/include/sof/lib/mailbox.h` + * (`MAILBOX_HOSTBOX_BASE + offset`, etc., where `offset` is a byte + * offset) addresses the intended byte. The backing storage is + * declared as `uint32_t[]` only for natural-alignment; addressing is + * done through a `uint8_t *` cast so byte offsets do not get scaled + * by `sizeof(uint32_t)`. Every other SOF platform defines these + * bases as plain byte addresses (integer literals or + * `SRAM_INBOX_BASE`), so the cast keeps POSIX consistent with that + * ABI. + */ +extern uint32_t posix_hostbox[]; +#define MAILBOX_HOSTBOX_SIZE SOF_IPC_MSG_MAX_SIZE +#define MAILBOX_HOSTBOX_BASE ((uint8_t *)&posix_hostbox[0]) + +extern uint32_t posix_dspbox[]; +#define MAILBOX_DSPBOX_SIZE 4096 +#define MAILBOX_DSPBOX_BASE ((uint8_t *)&posix_dspbox[0]) + +extern uint32_t posix_stream[]; +#define MAILBOX_STREAM_SIZE 4096 +#define MAILBOX_STREAM_BASE ((uint8_t *)&posix_stream[0]) + +extern uint32_t posix_trace[]; +#define MAILBOX_TRACE_BASE ((uint8_t *)&posix_trace[0]) +#define MAILBOX_TRACE_SIZE 4096 + +#endif /* __PLATFORM_LIB_MAILBOX_LAYOUT_H__ */ diff --git a/test/ztest/unit/audio/crossover/CMakeLists.txt b/test/ztest/unit/audio/crossover/CMakeLists.txt index cc599bc4e512..71557a2256b1 100644 --- a/test/ztest/unit/audio/crossover/CMakeLists.txt +++ b/test/ztest/unit/audio/crossover/CMakeLists.txt @@ -13,6 +13,7 @@ target_include_directories(app PRIVATE ${SOF_ROOT}/zephyr/include ${SOF_ROOT}/src/include ${SOF_ROOT}/src/kernel/platform/posix/include + ${SOF_ROOT}/src/platform/posix/include ${SOF_ROOT}/src/audio/crossover ${PROJECT_BINARY_DIR}/include/generated ) diff --git a/test/ztest/unit/audio/drc/CMakeLists.txt b/test/ztest/unit/audio/drc/CMakeLists.txt index 39691eefa371..225ab3fef4dc 100644 --- a/test/ztest/unit/audio/drc/CMakeLists.txt +++ b/test/ztest/unit/audio/drc/CMakeLists.txt @@ -18,6 +18,7 @@ target_include_directories(app PRIVATE ${SOF_ROOT}/zephyr/include ${SOF_ROOT}/src/include ${SOF_ROOT}/src/kernel/platform/posix/include + ${SOF_ROOT}/src/platform/posix/include ${SOF_ROOT}/src/audio ${SOF_ROOT}/test/cmocka/include ${PROJECT_BINARY_DIR}/include/generated diff --git a/test/ztest/unit/audio/selector/CMakeLists.txt b/test/ztest/unit/audio/selector/CMakeLists.txt index 2b61e456377b..c3082f21587f 100644 --- a/test/ztest/unit/audio/selector/CMakeLists.txt +++ b/test/ztest/unit/audio/selector/CMakeLists.txt @@ -17,6 +17,7 @@ target_include_directories(app PRIVATE ${SOF_ROOT}/zephyr/include ${SOF_ROOT}/src/include ${SOF_ROOT}/src/kernel/platform/posix/include + ${SOF_ROOT}/src/platform/posix/include ${SOF_ROOT}/src/audio ${SOF_ROOT}/tools/rimage/src/include ${PROJECT_BINARY_DIR}/include/generated diff --git a/test/ztest/unit/dsrc/CMakeLists.txt b/test/ztest/unit/dsrc/CMakeLists.txt index db31f8a536d8..ef4ce93d443f 100644 --- a/test/ztest/unit/dsrc/CMakeLists.txt +++ b/test/ztest/unit/dsrc/CMakeLists.txt @@ -12,6 +12,7 @@ target_include_directories(app PRIVATE ${SOF_ROOT}/zephyr/include ${SOF_ROOT}/src/include ${SOF_ROOT}/src/kernel/platform/posix/include + ${SOF_ROOT}/src/platform/posix/include ) # Define SOF-specific configurations for unit testing diff --git a/test/ztest/unit/fast-get/CMakeLists.txt b/test/ztest/unit/fast-get/CMakeLists.txt index b58587e15794..4a6040911fff 100644 --- a/test/ztest/unit/fast-get/CMakeLists.txt +++ b/test/ztest/unit/fast-get/CMakeLists.txt @@ -16,6 +16,7 @@ target_include_directories(app PRIVATE ${SOF_ROOT}/zephyr/include ${SOF_ROOT}/src/include ${SOF_ROOT}/src/kernel/platform/posix/include + ${SOF_ROOT}/src/platform/posix/include ${PROJECT_BINARY_DIR}/include/generated # For uuid-registry.h ) diff --git a/test/ztest/unit/math/advanced/functions/CMakeLists.txt b/test/ztest/unit/math/advanced/functions/CMakeLists.txt index 0afee53408b7..797133172e30 100644 --- a/test/ztest/unit/math/advanced/functions/CMakeLists.txt +++ b/test/ztest/unit/math/advanced/functions/CMakeLists.txt @@ -16,6 +16,7 @@ target_include_directories(app PRIVATE ${SOF_ROOT}/zephyr/include ${SOF_ROOT}/src/include ${SOF_ROOT}/src/kernel/platform/posix/include + ${SOF_ROOT}/src/platform/posix/include ${SOF_ROOT}/test/cmocka/include ${PROJECT_BINARY_DIR}/include/generated # For uuid-registry.h ) diff --git a/test/ztest/unit/math/auditory/CMakeLists.txt b/test/ztest/unit/math/auditory/CMakeLists.txt index d2cc165eed3f..ef05f3115861 100644 --- a/test/ztest/unit/math/auditory/CMakeLists.txt +++ b/test/ztest/unit/math/auditory/CMakeLists.txt @@ -17,6 +17,7 @@ target_include_directories(app PRIVATE ${SOF_ROOT}/zephyr/include ${SOF_ROOT}/src/include ${SOF_ROOT}/src/kernel/platform/posix/include + ${SOF_ROOT}/src/platform/posix/include ${SOF_ROOT}/test/ztest/unit/common ${PROJECT_BINARY_DIR}/include/generated ) diff --git a/test/ztest/unit/math/dct/CMakeLists.txt b/test/ztest/unit/math/dct/CMakeLists.txt index 6abe6c1d6e2c..0dba80efaf1c 100644 --- a/test/ztest/unit/math/dct/CMakeLists.txt +++ b/test/ztest/unit/math/dct/CMakeLists.txt @@ -17,6 +17,7 @@ target_include_directories(app PRIVATE ${SOF_ROOT}/zephyr/include ${SOF_ROOT}/src/include ${SOF_ROOT}/src/kernel/platform/posix/include + ${SOF_ROOT}/src/platform/posix/include ${SOF_ROOT}/test/ztest/unit/common ${PROJECT_BINARY_DIR}/include/generated ) diff --git a/test/ztest/unit/math/fft/CMakeLists.txt b/test/ztest/unit/math/fft/CMakeLists.txt index 1cdcd62ef978..85aae340cff5 100644 --- a/test/ztest/unit/math/fft/CMakeLists.txt +++ b/test/ztest/unit/math/fft/CMakeLists.txt @@ -17,6 +17,7 @@ target_include_directories(app PRIVATE ${SOF_ROOT}/zephyr/include ${SOF_ROOT}/src/include ${SOF_ROOT}/src/kernel/platform/posix/include + ${SOF_ROOT}/src/platform/posix/include ${SOF_ROOT}/src/audio ${SOF_ROOT}/test/ztest/unit/common ${SOF_ROOT}/test/cmocka/include diff --git a/test/ztest/unit/math/fft_multi/CMakeLists.txt b/test/ztest/unit/math/fft_multi/CMakeLists.txt index ce7d7d3b2b6e..698bcb7d9dcc 100644 --- a/test/ztest/unit/math/fft_multi/CMakeLists.txt +++ b/test/ztest/unit/math/fft_multi/CMakeLists.txt @@ -17,6 +17,7 @@ target_include_directories(app PRIVATE ${SOF_ROOT}/zephyr/include ${SOF_ROOT}/src/include ${SOF_ROOT}/src/kernel/platform/posix/include + ${SOF_ROOT}/src/platform/posix/include ${SOF_ROOT}/test/ztest/unit/common ${SOF_ROOT}/test/cmocka/include ${PROJECT_BINARY_DIR}/include/generated diff --git a/test/ztest/unit/math/matrix/CMakeLists.txt b/test/ztest/unit/math/matrix/CMakeLists.txt index bfc764066192..a739985ce022 100644 --- a/test/ztest/unit/math/matrix/CMakeLists.txt +++ b/test/ztest/unit/math/matrix/CMakeLists.txt @@ -17,6 +17,7 @@ target_include_directories(app PRIVATE ${SOF_ROOT}/zephyr/include ${SOF_ROOT}/src/include ${SOF_ROOT}/src/kernel/platform/posix/include + ${SOF_ROOT}/src/platform/posix/include ${SOF_ROOT}/test/ztest/unit/common ${PROJECT_BINARY_DIR}/include/generated ) diff --git a/test/ztest/unit/objpool/CMakeLists.txt b/test/ztest/unit/objpool/CMakeLists.txt index f19b8a3e926c..544ce203618b 100644 --- a/test/ztest/unit/objpool/CMakeLists.txt +++ b/test/ztest/unit/objpool/CMakeLists.txt @@ -12,6 +12,7 @@ target_include_directories(app PRIVATE ${SOF_ROOT}/zephyr/include ${SOF_ROOT}/src/include ${SOF_ROOT}/src/kernel/platform/posix/include + ${SOF_ROOT}/src/platform/posix/include ) # Define SOF-specific configurations for unit testing diff --git a/tools/testbench/CMakeLists.txt b/tools/testbench/CMakeLists.txt index ec949fc6ed14..fd1ca8ffbc2f 100644 --- a/tools/testbench/CMakeLists.txt +++ b/tools/testbench/CMakeLists.txt @@ -40,6 +40,7 @@ set(sof_binary_directory "${PROJECT_BINARY_DIR}/sof_ep/build") set(config_h ${sof_binary_directory}/library_autoconfig.h) target_include_directories(${testbench} PRIVATE "${sof_source_directory}/src/kernel/platform/library/include") +target_include_directories(${testbench} PRIVATE "${sof_source_directory}/src/platform/library/include") target_include_directories(${testbench} PRIVATE "${sof_source_directory}/src/audio") # Configuration time, make copy diff --git a/tools/tplg_parser/CMakeLists.txt b/tools/tplg_parser/CMakeLists.txt index 353808a3ef15..9a4d19f3ba64 100644 --- a/tools/tplg_parser/CMakeLists.txt +++ b/tools/tplg_parser/CMakeLists.txt @@ -44,6 +44,7 @@ target_include_directories(sof_tplg_parser PRIVATE ${sof_source_directory}/src/i target_include_directories(sof_tplg_parser PRIVATE ${sof_source_directory}/src/audio) target_include_directories(sof_tplg_parser PRIVATE ${sof_source_directory}/src/kernel/arch/host/include) target_include_directories(sof_tplg_parser PRIVATE ${sof_source_directory}/src/kernel/platform/library/include) +target_include_directories(sof_tplg_parser PRIVATE ${sof_source_directory}/src/platform/library/include) target_include_directories(sof_tplg_parser PRIVATE ${sof_source_directory}/posix/include) # Configuration time, make copy From a2428bd534c1480e9f3398f17cfb3bcac17a4770 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Mon, 16 Nov 2026 21:23:00 +0000 Subject: [PATCH 07/10] lib: mailbox: do not include the memory map The platform mailbox headers now include what they need, the window layout, so sof/lib/mailbox.h no longer needs the platform memory map. Drop the include, which brought the memory map into every user-space source that uses the mailbox. base_fw.c got HOST_PAGE_SIZE through it on qemu_xtensa, so it includes the memory map. No functional change. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Liam Girdwood --- src/include/sof/lib/mailbox.h | 1 - src/kernel/audio/base_fw.c | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/include/sof/lib/mailbox.h b/src/include/sof/lib/mailbox.h index ae667f0d0c4c..5dbf0160332c 100644 --- a/src/include/sof/lib/mailbox.h +++ b/src/include/sof/lib/mailbox.h @@ -14,7 +14,6 @@ #include #include #include -#include #include #include #include diff --git a/src/kernel/audio/base_fw.c b/src/kernel/audio/base_fw.c index 880306a4a03b..0ccf866b036e 100644 --- a/src/kernel/audio/base_fw.c +++ b/src/kernel/audio/base_fw.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include From f831f563fc52d18df7587ed96a214ef96fa3158c Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Mon, 16 Nov 2026 21:23:09 +0000 Subject: [PATCH 08/10] scripts: kernel_user_partition: allow sof/lib/mailbox.h The mailbox windows that user-space code uses, the software registers and the host box or the stream window, are mapped into the user-space LL and IPC threads, and sof/lib/mailbox.h no longer includes any kernel-only header. Remove it from the kernel-only headers. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Liam Girdwood --- scripts/kernel_user_partition.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/kernel_user_partition.txt b/scripts/kernel_user_partition.txt index 2bf6401a1be7..1af69663e111 100644 --- a/scripts/kernel_user_partition.txt +++ b/scripts/kernel_user_partition.txt @@ -27,7 +27,10 @@ src/audio/host-legacy.c # SOF headers that only kernel code may include. # Not listed on purpose: rtos/init.h, which only provides the -# SOF_MODULE_INIT() registration hook used by every module. +# SOF_MODULE_INIT() registration hook used by every module, and +# sof/lib/mailbox.h: the mailbox windows are mapped into the user-space +# LL and IPC threads, and their layout is in the user-space platform +# headers in src/platform. [kernel-headers] src/include/sof/drivers/* src/include/sof/platform.h @@ -35,7 +38,6 @@ src/include/sof/llext_manager.h src/include/sof/ipc/driver.h src/include/sof/lib/agent.h src/include/sof/lib/cpu-clk-manager.h -src/include/sof/lib/mailbox.h src/include/sof/lib/perf_cnt.h src/include/sof/lib/watchdog.h src/kernel/platform/* From 63f59308cec6568ea589c78ba2cba0ca9226cfdb Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Mon, 16 Nov 2026 21:23:09 +0000 Subject: [PATCH 09/10] docs: platform: describe src/platform Add a README for src/platform, which holds the platform headers that user-space code may include, and point to it from the kernel platform README, which no longer has the mailbox. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Liam Girdwood --- src/kernel/platform/README.md | 5 +++-- src/platform/README.md | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 src/platform/README.md diff --git a/src/kernel/platform/README.md b/src/kernel/platform/README.md index b3aa7014290a..77112340a10e 100644 --- a/src/kernel/platform/README.md +++ b/src/kernel/platform/README.md @@ -1,7 +1,8 @@ # Platform Support (`src/kernel/platform`) -> **Runs in:** Kernel-only — platform bring-up, memory maps, interrupt wiring and IPC mailbox -> windows are supervisor-context concerns and never run in a user thread. See +> **Runs in:** Kernel-only — platform bring-up, memory maps and interrupt wiring are +> supervisor-context concerns and never run in a user thread. The mailbox headers, which +> user-space code uses, are in [`src/platform`](../../platform/README.md). See > [User/kernel split](../../include/sof/userspace/README.md). This directory contains SoC/platform-specific integration (e.g. Intel ACE, MediaTek, i.MX), diff --git a/src/platform/README.md b/src/platform/README.md new file mode 100644 index 000000000000..0edad3e9eca8 --- /dev/null +++ b/src/platform/README.md @@ -0,0 +1,21 @@ +# Platform Headers for User-Space Code (`src/platform`) + +> **Runs in:** User-space safe — headers only. The platform code is kernel code, in +> [`src/kernel/platform`](../kernel/platform/README.md). See +> [User/kernel split](../include/sof/userspace/README.md). + +This directory holds the parts of the platform headers that user-space code may include. It +has the same layout as `src/kernel/platform`, and both are on the include path, so the +headers keep their include names. + +Today it has the mailbox: + +- `platform/lib/mailbox.h`, and for Intel `ace/lib/mailbox.h` and `cavs/lib/mailbox.h`: the + mailbox window addresses and the software register accessors, used through + `sof/lib/mailbox.h`. The software register page and the host box (IPC4) or the stream + window (IPC3) are mapped into the user-space LL and IPC threads, see + `user_access_to_mailbox()`. +- `platform/lib/mailbox_layout.h`: the layout of the host memory windows. The platform + memory map in `src/kernel/platform`, which user-space code must not include, includes it. + +The AMD and MediaTek mailbox headers are still in `src/kernel/platform`. From dc2a6c96c4c17fb3a6d86bfab1a97ed67e5559d5 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Mon, 16 Nov 2026 21:23:19 +0000 Subject: [PATCH 10/10] scripts: kernel_user_partition: drop clean sources from the baseline Seven sources that only used the mailbox no longer include kernel-only headers in any configuration: the copier host and IPC gateway code, the data blob helpers, the host component, the IPC4 module adapter and the volume component. Remove them from the leak baseline. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Liam Girdwood --- scripts/kernel_user_partition.txt | 7 ------- 1 file changed, 7 deletions(-) diff --git a/scripts/kernel_user_partition.txt b/scripts/kernel_user_partition.txt index 1af69663e111..94315f02ea51 100644 --- a/scripts/kernel_user_partition.txt +++ b/scripts/kernel_user_partition.txt @@ -72,23 +72,16 @@ include/zephyr/pm/device_runtime.h [leak-baseline] src/audio/component.c src/audio/copier/copier.c -src/audio/copier/copier_host.c -src/audio/copier/copier_ipcgtw.c src/audio/dai-zephyr.c -src/audio/data_blob.c -src/audio/host-zephyr.c src/audio/kpb.c src/audio/module_adapter/iadk/kpb_service.cpp src/audio/module_adapter/iadk/system_agent.cpp src/audio/module_adapter/iadk/timestamping_service_provider.cpp src/audio/module_adapter/library/native_system_service.c -src/audio/module_adapter/module_adapter_ipc4.c src/audio/pipeline/pipeline-graph.c src/audio/pipeline/pipeline-schedule.c src/audio/pipeline/pipeline-stream.c src/audio/pipeline/pipeline-xrun.c -src/audio/volume/volume.c -src/audio/volume/volume_ipc4.c src/debug/tester/tester_simple_dram_test.c src/ipc/ipc-helper.c src/ipc/ipc4/dai.c