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/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/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 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/)