From b8b8de326e167adf8cb645f88ec4c22c27253cbc Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Mon, 16 Nov 2026 18:36:12 +0000 Subject: [PATCH 01/15] lib: dma: do not include sof/lib/io.h and the memory map sof/lib/dma.h uses neither the register access helpers of sof/lib/io.h nor the platform memory map, but it brings both into the user-space host, DAI, copier, chain DMA, ASRC and pipeline sources that use the DMA API. Drop the includes. Three kernel sources got them through this header, so they include what they use: zephyr/wrapper.c the register helpers and the memory map, which it included as platform/lib/memory.h instead of through sof/lib/memory.h, zephyr/lib/cpu.c and ipc3/host-page-table.c the memory map. So does dma-legacy.h, which sof/lib/dma.h includes for the builds without the Zephyr native drivers: it uses the register helpers. No functional change. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Liam Girdwood --- src/kernel/ipc/ipc3/host-page-table.c | 1 + zephyr/include/sof/lib/dma-legacy.h | 2 ++ zephyr/include/sof/lib/dma.h | 2 -- zephyr/lib/cpu.c | 1 + zephyr/wrapper.c | 3 ++- 5 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/kernel/ipc/ipc3/host-page-table.c b/src/kernel/ipc/ipc3/host-page-table.c index 4e42b21ac825..56b2335a3a76 100644 --- a/src/kernel/ipc/ipc3/host-page-table.c +++ b/src/kernel/ipc/ipc3/host-page-table.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include diff --git a/zephyr/include/sof/lib/dma-legacy.h b/zephyr/include/sof/lib/dma-legacy.h index cb381ce03363..592ffc87b665 100644 --- a/zephyr/include/sof/lib/dma-legacy.h +++ b/zephyr/include/sof/lib/dma-legacy.h @@ -6,6 +6,8 @@ #ifndef __SOF_LIB_DMA_LEGACY_H__ #define __SOF_LIB_DMA_LEGACY_H__ +#include + /* DMA attributes */ #define DMA_ATTR_BUFFER_ALIGNMENT 0 #define DMA_ATTR_COPY_ALIGNMENT 1 diff --git a/zephyr/include/sof/lib/dma.h b/zephyr/include/sof/lib/dma.h index 261abe8cacea..145478db30f3 100644 --- a/zephyr/include/sof/lib/dma.h +++ b/zephyr/include/sof/lib/dma.h @@ -21,8 +21,6 @@ #include #include #include -#include -#include #include #include #include diff --git a/zephyr/lib/cpu.c b/zephyr/lib/cpu.c index ea407a45a554..7978d6cc2454 100644 --- a/zephyr/lib/cpu.c +++ b/zephyr/lib/cpu.c @@ -19,6 +19,7 @@ static uint32_t mic_disable_status; #endif /* CONFIG_INTEL_ADSP_MIC_PRIVACY */ #include #include +#include #include #include #include diff --git a/zephyr/wrapper.c b/zephyr/wrapper.c index afdc5b54a2e9..d866c7305824 100644 --- a/zephyr/wrapper.c +++ b/zephyr/wrapper.c @@ -13,7 +13,8 @@ #include #include #include -#include +#include +#include #include #include #include From 22ab945d4d0b81850cbae4a10012c5b54a00a5b0 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Mon, 16 Nov 2026 18:36:12 +0000 Subject: [PATCH 02/15] rtos: timer: do not include sof/platform.h rtos/timer.h uses nothing from sof/platform.h, which brings the platform definitions and clock headers into every user-space source that reads the cycle counter or the stream timestamps. Drop the include. base_fw_intel.c, zephyr/lib/alloc.c and zephyr/lib/cpu.c used HOST_PAGE_SIZE and platform_boot_complete() through this header, so they include sof/platform.h. dai-zephyr.c got the memory map through this header too, and it uses local_to_host() from it. It defines local_to_host() as a no-op if the platform doesn't, so without the include the code still built but lost the imx8ulp address translation. Include sof/lib/memory.h there. No functional change. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Liam Girdwood --- src/audio/dai-zephyr.c | 1 + src/kernel/audio/base_fw_intel.c | 1 + zephyr/include/rtos/timer.h | 1 - zephyr/lib/alloc.c | 1 + zephyr/lib/cpu.c | 1 + 5 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/audio/dai-zephyr.c b/src/audio/dai-zephyr.c index 40d0a9f4902a..2cbdfe998a2c 100644 --- a/src/audio/dai-zephyr.c +++ b/src/audio/dai-zephyr.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include diff --git a/src/kernel/audio/base_fw_intel.c b/src/kernel/audio/base_fw_intel.c index 3d25f89dbd18..43ba7d0011dc 100644 --- a/src/kernel/audio/base_fw_intel.c +++ b/src/kernel/audio/base_fw_intel.c @@ -24,6 +24,7 @@ #include #include +#include #include #include diff --git a/zephyr/include/rtos/timer.h b/zephyr/include/rtos/timer.h index fef53389faac..c430859823bb 100644 --- a/zephyr/include/rtos/timer.h +++ b/zephyr/include/rtos/timer.h @@ -16,7 +16,6 @@ #include #include #include -#include struct comp_dev; struct sof_ipc_stream_posn; diff --git a/zephyr/lib/alloc.c b/zephyr/lib/alloc.c index 87d0fa9d945d..f1148a0e6771 100644 --- a/zephyr/lib/alloc.c +++ b/zephyr/lib/alloc.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include /* for zephyr_ll_user_heap() */ diff --git a/zephyr/lib/cpu.c b/zephyr/lib/cpu.c index 7978d6cc2454..ec5217823f8a 100644 --- a/zephyr/lib/cpu.c +++ b/zephyr/lib/cpu.c @@ -21,6 +21,7 @@ static uint32_t mic_disable_status; #include #include #include +#include #include #include #include From 76bc5ff6263a7171d8f8fdabec481492561cc846 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Mon, 16 Nov 2026 18:36:12 +0000 Subject: [PATCH 03/15] schedule: ll_schedule_domain: include rtos/clk.h only for the host domain_init() only uses clock_ms_to_ticks() from rtos/clk.h in the builds without Zephyr. The Zephyr builds compute the ticks with k_ms_to_cyc_ceil64(), but still include the clock header, and with it the platform clock headers, into the user-space scheduler and IPC sources. Only include it when not building for Zephyr. The native_sim platform code used the clock definitions through this header, so it includes rtos/clk.h. No functional change. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Liam Girdwood --- src/include/sof/schedule/ll_schedule_domain.h | 3 +++ src/kernel/platform/posix/posix.c | 1 + 2 files changed, 4 insertions(+) diff --git a/src/include/sof/schedule/ll_schedule_domain.h b/src/include/sof/schedule/ll_schedule_domain.h index 1ef47c005589..c86e37e8b1a5 100644 --- a/src/include/sof/schedule/ll_schedule_domain.h +++ b/src/include/sof/schedule/ll_schedule_domain.h @@ -18,7 +18,10 @@ #include #include #include +#ifndef __ZEPHYR__ +/* for clock_ms_to_ticks() in domain_init() */ #include +#endif #include #include #include diff --git a/src/kernel/platform/posix/posix.c b/src/kernel/platform/posix/posix.c index cea923d91ef1..eb5a55274eb7 100644 --- a/src/kernel/platform/posix/posix.c +++ b/src/kernel/platform/posix/posix.c @@ -2,6 +2,7 @@ // Copyright(c) 2022 Google LLC. All rights reserved. // Author: Andy Ross #include +#include #include #include #include From 076a319b7019f1689a2912af5b16a5c3ef334fd9 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Mon, 16 Nov 2026 18:36:12 +0000 Subject: [PATCH 04/15] scripts: kernel_user_partition: allow zephyr/drivers/dma.h The sof_dma_*() system calls in sof/lib/sof_dma.h take Zephyr's struct dma_config and struct dma_status, and their callers use the Zephyr DMA constants, so user-space code needs zephyr/drivers/dma.h. The header has no system calls itself, and Zephyr's own header cannot be split. Remove it from the kernel-only headers, with a note that user-space code must not call its dma_*() driver functions directly, which the include check cannot catch. None does today: the user-space DMA code only uses the sof_dma_*() calls. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Liam Girdwood --- scripts/kernel_user_partition.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/kernel_user_partition.txt b/scripts/kernel_user_partition.txt index 35229aecb7e7..d042068ce196 100644 --- a/scripts/kernel_user_partition.txt +++ b/scripts/kernel_user_partition.txt @@ -55,9 +55,12 @@ zephyr/include/sof/lib/vpage.h # Zephyr headers that only kernel code may include: kernel internals and # driver APIs that are not system calls. +# Not listed on purpose: zephyr/drivers/dma.h. Its types and constants are +# the arguments of the sof_dma_*() system calls in sof/lib/sof_dma.h, so +# user-space code needs them. User-space code must not call its dma_*() +# driver functions directly, which this include check cannot catch. [zephyr-kernel-headers] kernel/include/* -include/zephyr/drivers/dma.h include/zephyr/pm/device_runtime.h # User-space sources that still include kernel-only headers, removed one From 3caff134522bcc5026aa710db1b127fd05be2d53 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Mon, 16 Nov 2026 18:36:29 +0000 Subject: [PATCH 05/15] scripts: kernel_user_partition: drop clean sources from the baseline Ten sources no longer include kernel-only headers in any configuration: the ASRC, chain DMA, copier DAI and gain, UAOL, DMA and DAI library sources, the user-space IPC code and the DP scheduler thread and application code. Remove them from the leak baseline. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Liam Girdwood --- scripts/kernel_user_partition.txt | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/scripts/kernel_user_partition.txt b/scripts/kernel_user_partition.txt index d042068ce196..2bf6401a1be7 100644 --- a/scripts/kernel_user_partition.txt +++ b/scripts/kernel_user_partition.txt @@ -68,18 +68,13 @@ include/zephyr/pm/device_runtime.h # other user-space source is an error, so this list must only shrink. # It covers the CI build configurations and the user-space overlays. [leak-baseline] -src/audio/asrc/asrc.c -src/audio/chain_dma.c src/audio/component.c src/audio/copier/copier.c -src/audio/copier/copier_dai.c -src/audio/copier/copier_gain.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/intel_uaol.c src/audio/kpb.c src/audio/module_adapter/iadk/kpb_service.cpp src/audio/module_adapter/iadk/system_agent.cpp @@ -93,17 +88,12 @@ 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-common.c src/ipc/ipc-helper.c src/ipc/ipc4/dai.c src/ipc/ipc4/handler-user.c src/ipc/ipc4/helper.c -src/lib/dai.c -src/lib/dma.c src/lib/notifier.c src/samples/audio/detect_test.c src/schedule/zephyr_domain.c src/schedule/zephyr_dp_schedule.c -src/schedule/zephyr_dp_schedule_application.c -src/schedule/zephyr_dp_schedule_thread.c src/schedule/zephyr_ll.c From bbd88f5ca852f38c2213eda94520d3e0a398df37 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Mon, 16 Nov 2026 21:22:20 +0000 Subject: [PATCH 06/15] 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 bc7f4998aef91da65500c432cf8a137f46e95f3c Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Mon, 16 Nov 2026 21:22:20 +0000 Subject: [PATCH 07/15] 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 ffd6c50b310ad52f9d319923f97a7516ef19ff18 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Mon, 16 Nov 2026 21:22:32 +0000 Subject: [PATCH 08/15] 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 7fbced4259b1316dbc77f0d564682074087f11a0 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Mon, 16 Nov 2026 21:22:46 +0000 Subject: [PATCH 09/15] 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 2533f617ee6a117da9b46fe435403b72a321e55a Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Mon, 16 Nov 2026 21:22:46 +0000 Subject: [PATCH 10/15] 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 14acf0c1fd18ab27778a73322039728a4e5ce2c4 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Mon, 16 Nov 2026 21:22:46 +0000 Subject: [PATCH 11/15] 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/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 + 20 files changed, 88 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/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 d09c724d80af..fc78e1c41845 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 # Reference test vectors are #included in place from the CMocka tree # rather than copied, so both frameworks share identical data. diff --git a/test/ztest/unit/math/dct/CMakeLists.txt b/test/ztest/unit/math/dct/CMakeLists.txt index 3bddbf06e6ea..b0b4963eb202 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 # Reference test vectors are #included in place from the CMocka tree # rather than copied, so both frameworks share identical data. diff --git a/test/ztest/unit/math/fft/CMakeLists.txt b/test/ztest/unit/math/fft/CMakeLists.txt index 0c7a8f13783f..825d918a92c2 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 3287559f3050..f7e38b1b5c04 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 # Reference test vectors are #included in place from the CMocka tree diff --git a/test/ztest/unit/math/matrix/CMakeLists.txt b/test/ztest/unit/math/matrix/CMakeLists.txt index 1dbfea88a08a..5b29b752752f 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 # Reference test vectors are #included in place from the CMocka tree # rather than copied, so both frameworks share identical data. 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 f00195f8c5bd9cf229cde373727e27659da4d37d Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Mon, 16 Nov 2026 21:23:00 +0000 Subject: [PATCH 12/15] 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 f4040441d8ad47e1b7d37f376787de46dd593c7e Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Mon, 16 Nov 2026 21:23:09 +0000 Subject: [PATCH 13/15] 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 6db0af43db403cb8a87dd64a2dca62e44b097dbc Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Mon, 16 Nov 2026 21:23:09 +0000 Subject: [PATCH 14/15] 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 7109d673f3591115ee18d27ae74c040abfead499 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Mon, 16 Nov 2026 21:23:19 +0000 Subject: [PATCH 15/15] 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