From 55656ba4f8e6a8c4d758568b9d24615097643db7 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Tue, 3 Nov 2026 20:39:44 +0000 Subject: [PATCH 1/2] idc: move src/idc to src/kernel/idc The inter-core communication code only runs in kernel mode. Move it to src/kernel/idc, where it is built into the sof_kernel library. Add src/kernel/Kconfig for the Kconfig files of the moved directories and source it from src/Kconfig in place of idc/Kconfig. The option values are unchanged. Fix the relative link in the README. Only Zephyr builds the IDC code, so the host builds are not affected. No functional change. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Liam Girdwood --- src/Kconfig | 2 +- src/kernel/CMakeLists.txt | 1 + src/kernel/Kconfig | 5 +++++ src/{ => kernel}/idc/CMakeLists.txt | 0 src/{ => kernel}/idc/Kconfig | 0 src/{ => kernel}/idc/README.md | 4 ++-- src/{ => kernel}/idc/idc.c | 0 src/{ => kernel}/idc/zephyr_idc.c | 0 zephyr/CMakeLists.txt | 1 - 9 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 src/kernel/Kconfig rename src/{ => kernel}/idc/CMakeLists.txt (100%) rename src/{ => kernel}/idc/Kconfig (100%) rename src/{ => kernel}/idc/README.md (76%) rename src/{ => kernel}/idc/idc.c (100%) rename src/{ => kernel}/idc/zephyr_idc.c (100%) diff --git a/src/Kconfig b/src/Kconfig index 0ad749042db8..75abdaa6c096 100644 --- a/src/Kconfig +++ b/src/Kconfig @@ -17,7 +17,7 @@ rsource "samples/Kconfig" rsource "schedule/Kconfig" rsource "schedule/Kconfig.threads_prio" -rsource "idc/Kconfig" +rsource "kernel/Kconfig" rsource "ipc/Kconfig" diff --git a/src/kernel/CMakeLists.txt b/src/kernel/CMakeLists.txt index 0b6846d11494..1cd295617aad 100644 --- a/src/kernel/CMakeLists.txt +++ b/src/kernel/CMakeLists.txt @@ -10,4 +10,5 @@ if(zephyr) set(ZEPHYR_CURRENT_LIBRARY sof_kernel) endif() +add_subdirectory(idc) add_subdirectory(init) diff --git a/src/kernel/Kconfig b/src/kernel/Kconfig new file mode 100644 index 000000000000..4378b4d74d0b --- /dev/null +++ b/src/kernel/Kconfig @@ -0,0 +1,5 @@ +# SPDX-License-Identifier: BSD-3-Clause + +# Code that only runs in kernel mode, see scripts/kernel_user_partition.txt. + +rsource "idc/Kconfig" diff --git a/src/idc/CMakeLists.txt b/src/kernel/idc/CMakeLists.txt similarity index 100% rename from src/idc/CMakeLists.txt rename to src/kernel/idc/CMakeLists.txt diff --git a/src/idc/Kconfig b/src/kernel/idc/Kconfig similarity index 100% rename from src/idc/Kconfig rename to src/kernel/idc/Kconfig diff --git a/src/idc/README.md b/src/kernel/idc/README.md similarity index 76% rename from src/idc/README.md rename to src/kernel/idc/README.md index 401f1daed747..3d5f0082249e 100644 --- a/src/idc/README.md +++ b/src/kernel/idc/README.md @@ -1,9 +1,9 @@ -# Inter-Domain / Inter-Core Communication (`src/idc`) +# Inter-Domain / Inter-Core Communication (`src/kernel/idc`) > **Runs in:** Kernel-only — cross-core messaging (`idc.c`, `zephyr_idc.c`) runs in supervisor > context. User-space audio code triggers cross-core work indirectly through higher-level > subsystems, not by calling IDC directly. See -> [User/kernel split](../include/sof/userspace/README.md). +> [User/kernel split](../../include/sof/userspace/README.md). This directory implements the mechanism cores use to signal and hand work to each other. It is part of the OS-integration layer, not the audio application. diff --git a/src/idc/idc.c b/src/kernel/idc/idc.c similarity index 100% rename from src/idc/idc.c rename to src/kernel/idc/idc.c diff --git a/src/idc/zephyr_idc.c b/src/kernel/idc/zephyr_idc.c similarity index 100% rename from src/idc/zephyr_idc.c rename to src/kernel/idc/zephyr_idc.c diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt index 47dcaca6cf4c..f471aea8e0b7 100644 --- a/zephyr/CMakeLists.txt +++ b/zephyr/CMakeLists.txt @@ -237,7 +237,6 @@ add_subdirectory(../src/math/ math_unused_install/) # remaining directories (in alphabetical order) add_subdirectory(../src/audio/ audio_unused_install/) add_subdirectory(../src/debug/ debug_unused_install/) -add_subdirectory(../src/idc/ idc_unused_install/) add_subdirectory(../src/ipc/ ipc_unused_install/) add_subdirectory(../src/kernel/ kernel_unused_install/) add_subdirectory(../src/lib/ lib_unused_install/) From 70ae5693af1b1953d53ce861bbe693aa7f53b77a Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Tue, 3 Nov 2026 20:40:12 +0000 Subject: [PATCH 2/2] docs: list src/kernel as the kernel-only directory AGENTS.md, the user-space README and the audio README list the kernel-only directories by name and still name src/init and src/idc, which are now under src/kernel. List src/kernel, note that it is built into the sof_kernel library, and keep the directories that have not moved there yet. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Liam Girdwood --- AGENTS.md | 3 ++- src/audio/README.md | 2 +- src/include/sof/userspace/README.md | 6 +++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 0cc4f8a1066f..3b16ba4d7ac1 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -30,7 +30,8 @@ memory-partition markers and Kconfig hierarchy are documented in moving code, follow it: * **Place code in the right tier.** OS/HAL/boot/inter-core → a kernel-only directory - (`arch/`, `drivers/`, `idc/`, `init/`, `platform/`, `probe/`, `logging/`, `trace/`); audio + (`kernel/`, which is built into the `sof_kernel` library, and the directories not yet + moved there: `arch/`, `drivers/`, `platform/`, `probe/`, `logging/`, `trace/`); audio application logic → `audio/`; reusable pure code → a shared-library directory (`lib/`, `math/`, `module/`) kept free of privileged operations. Each top-level directory's `README.md` states its tier in a "Runs in:" banner — keep it accurate. diff --git a/src/audio/README.md b/src/audio/README.md index 5cad0d540b2e..83550a4ca783 100644 --- a/src/audio/README.md +++ b/src/audio/README.md @@ -15,4 +15,4 @@ modules in user context. When adding a component here, keep it inside the application tier: allocate through the module allocation syscalls (`mod_*`), mark any globals shared with the kernel using the partition -markers, and never call kernel-only subsystems (`drivers/`, `platform/`, `idc/`) directly. +markers, and never call kernel-only subsystems (`drivers/`, `platform/`, `kernel/idc/`) directly. diff --git a/src/include/sof/userspace/README.md b/src/include/sof/userspace/README.md index 7106f6b6465c..ac26aa07ab6d 100644 --- a/src/include/sof/userspace/README.md +++ b/src/include/sof/userspace/README.md @@ -74,7 +74,7 @@ its subdirectories span all tiers. | Tier | Meaning | Directories | |------|---------|-------------| -| **Kernel-only** | OS integration, HAL, boot, inter-core. Never executes in a user thread. Must not be reached directly from user code — only via a syscall. | `arch/`, `drivers/`, `idc/`, `init/`, `platform/`, `probe/` *, `logging/` *, `trace/` * | +| **Kernel-only** | OS integration, HAL, boot, inter-core. Never executes in a user thread. Must not be reached directly from user code — only via a syscall. | `kernel/` (`kernel/idc/`, `kernel/init/`), `arch/`, `drivers/`, `platform/`, `probe/` *, `logging/` *, `trace/` * | | **Boundary / bridge** | Owns the syscalls and the thread / memory-domain setup. Split internally: some translation units run kernel-side, some user-side (e.g. `handler-kernel.c` vs `handler-user.c`, `zephyr_ll.c` vs `zephyr_ll_user.c`). | `schedule/`, `ipc/`, `library_manager/` *, `debug/debug_stream/` *, and (in the Zephyr integration tree) `zephyr/syscall/` | | **Application** | Audio pipeline / component logic that runs in user threads under userspace configs. | `audio/` | | **Shared library** | Context-agnostic code linked into whichever context calls it. Must stay "user-safe": no privileged operations (no direct MMIO, no spinlocks held across syscalls, no raw kernel object access) so it is safe when pulled into a user build. | `math/`, `module/` | @@ -82,6 +82,10 @@ its subdirectories span all tiers. Directories marked * do not yet have a "Runs in:" README banner. +Kernel-only code is being moved under `src/kernel/`, which Zephyr builds into a library of its +own, `sof_kernel`, instead of `modules_sof`. The other kernel-only directories in the table +follow one at a time. + Classification is grep-verifiable — see [Verifying the taxonomy](#verifying-the-taxonomy). > **`zephyr/syscall/` is the model to grow toward.** The Zephyr integration tree already