diff --git a/AGENTS.md b/AGENTS.md index 3b16ba4d7ac1..095ec828115f 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -31,7 +31,7 @@ moving code, follow it: * **Place code in the right tier.** OS/HAL/boot/inter-core → a kernel-only directory (`kernel/`, which is built into the `sof_kernel` library, and the directories not yet - moved there: `arch/`, `drivers/`, `platform/`, `probe/`, `logging/`, `trace/`); audio + moved there: `arch/`, `drivers/`, `platform/`, `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/scripts/kernel_user_partition.txt b/scripts/kernel_user_partition.txt index cf913dd07713..b5d6cda1c33f 100644 --- a/scripts/kernel_user_partition.txt +++ b/scripts/kernel_user_partition.txt @@ -28,13 +28,9 @@ src/lib/objpool.c # Kernel sources inside the directories above. [not-user-sources] -src/audio/base_fw.c -src/audio/base_fw_intel.c src/audio/dai-legacy.c src/audio/host-legacy.c src/audio/intel_uaol.c -src/audio/mic_privacy_manager/* -src/audio/module_adapter/library/userspace_proxy.c # SOF headers that only kernel code may include. # Not listed on purpose: rtos/init.h, which only provides the diff --git a/src/Kconfig b/src/Kconfig index 75abdaa6c096..f7d5dbbb64bc 100644 --- a/src/Kconfig +++ b/src/Kconfig @@ -10,8 +10,6 @@ rsource "audio/Kconfig" rsource "trace/Kconfig" -rsource "probe/Kconfig" - rsource "samples/Kconfig" rsource "schedule/Kconfig" @@ -23,10 +21,6 @@ rsource "ipc/Kconfig" rsource "math/Kconfig" -rsource "library_manager/Kconfig" - -rsource "debug/telemetry/Kconfig" - rsource "debug/debug_stream/Kconfig" rsource "debug/tester/Kconfig" diff --git a/src/audio/CMakeLists.txt b/src/audio/CMakeLists.txt index e975a61c7a06..0ca532950f5c 100644 --- a/src/audio/CMakeLists.txt +++ b/src/audio/CMakeLists.txt @@ -16,11 +16,6 @@ add_subdirectory(buffers) add_subdirectory(pcm_converter) add_subdirectory(pipeline) -if(CONFIG_COMP_BASEFW_IPC4 AND NOT CONFIG_LIBRARY) - add_local_sources(sof base_fw.c) -endif() -add_local_sources_ifdef(CONFIG_IPC4_BASE_FW_INTEL sof base_fw_intel.c) - # directories and files included conditionally (alphabetical order) if(CONFIG_COMP_ARIA) add_subdirectory(aria) @@ -143,9 +138,6 @@ if(CONFIG_COMP_KPB AND NOT CONFIG_LIBRARY) kpb.c ) endif() -if(CONFIG_INTEL_ADSP_MIC_PRIVACY) - add_subdirectory(mic_privacy_manager) -endif() if(CONFIG_COMP_TONE) add_subdirectory(tone) endif() diff --git a/src/audio/module_adapter/CMakeLists.txt b/src/audio/module_adapter/CMakeLists.txt index bc22ae348b6c..50d35c17ea01 100644 --- a/src/audio/module_adapter/CMakeLists.txt +++ b/src/audio/module_adapter/CMakeLists.txt @@ -84,7 +84,6 @@ endif() endif() zephyr_library_sources_ifdef(CONFIG_SOF_USERSPACE_PROXY - library/userspace_proxy.c library/userspace_proxy_user.c ) diff --git a/src/audio/module_adapter/README.md b/src/audio/module_adapter/README.md index 9a58bbf956fc..9bc4f2b01695 100644 --- a/src/audio/module_adapter/README.md +++ b/src/audio/module_adapter/README.md @@ -1,7 +1,8 @@ # Module Adapter Architecture > **Runs in:** Boundary / bridge — the module adapter is the container that runs audio modules -> in **user** threads (DP threads, or the userspace proxy in `library/userspace_proxy.c`) while +> in **user** threads (DP threads, or the userspace proxy in `library/userspace_proxy_user.c`, +> whose kernel half is `src/kernel/audio/module_adapter/library/userspace_proxy.c`) while > being driven from the **kernel** pipeline. It hosts the `mod_*` allocation syscalls and sets > up per-module memory domains and object grants. See > [User/kernel split](../../include/sof/userspace/README.md). diff --git a/src/debug/CMakeLists.txt b/src/debug/CMakeLists.txt index d91bd79234e8..78a2a0c7b22b 100644 --- a/src/debug/CMakeLists.txt +++ b/src/debug/CMakeLists.txt @@ -6,8 +6,5 @@ is_zephyr(zephyr) if(zephyr) ### Zephyr ### add_subdirectory(debug_stream) -add_subdirectory(telemetry) - -zephyr_library_sources_ifdef(CONFIG_COLD_STORE_EXECUTE_DEBUG dram.c) endif() # Zephyr diff --git a/src/include/sof/userspace/README.md b/src/include/sof/userspace/README.md index ac26aa07ab6d..52396658f742 100644 --- a/src/include/sof/userspace/README.md +++ b/src/include/sof/userspace/README.md @@ -74,8 +74,8 @@ 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. | `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/` | +| **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/` (see [its README](../../../kernel/README.md)), `arch/`, `drivers/`, `platform/`, `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`). | `schedule/`, `ipc/`, `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/` | | **Mixed** | A directory whose files span more than one tier; see its own README for per-file classification. | `lib/` | @@ -123,7 +123,7 @@ syscall by subsystem: | DAI | `dai_get_device` | `sof/lib/dai-zephyr.h` | `zephyr/syscall/dai.c` / `lib/dai.c` | | CPU | `cpu_get_id` | `sof/lib/cpu.h` | `zephyr/syscall/cpu.c` / `zephyr/lib/cpu.c` | | Module management | `mod_balloc_align`, `mod_alloc_ext`, `mod_free`, `mod_free_all`, `mod_data_blob_handler_new`, `mod_fast_get` | `sof/audio/module_adapter/module/generic.h` | scattered: `audio/module_adapter/module/generic.c` | -| Library manager | `lib_manager_free_module` | `sof/lib_manager.h` | scattered: `library_manager/lib_manager.c` | +| Library manager | `lib_manager_free_module` | `sof/lib_manager.h` | scattered: `kernel/library_manager/lib_manager.c` | | Scheduling | `zephyr_ll_task_sem_alloc`, `zephyr_ll_task_sem_free`, `scheduler_dp_internal_free`, `scheduler_dp_ll_tick` | `sof/schedule/ll_schedule_domain.h`, `sof/schedule/dp_schedule.h` | scattered: `schedule/zephyr_ll.c`, `schedule/zephyr_dp_schedule*.c` | | Debug | `debug_stream_slot_send_record` | `user/debug_stream_slot.h` | scattered: `debug/debug_stream/debug_stream_slot.c` | @@ -152,7 +152,7 @@ marker at its declaration site.* Conversely, marked data is **user-writable**, s must never trust it — re-validate on every use. DP modules running under `SOF_USERSPACE_APPLICATION` access data through their per-module memory domain set up by the proxy or DP thread infrastructure, not through `APP_TASK_*` / `APP_SYSUSER_*` markers. See -[`schedule/zephyr_ll_user.c`](../../../schedule/zephyr_ll_user.c): `zephyr_ll_user_heap()` +[`kernel/schedule/zephyr_ll_user.c`](../../../kernel/schedule/zephyr_ll_user.c): `zephyr_ll_user_heap()` returns the address of the kernel-only heap object rather than a pointer stored in user-writable memory, and `zephyr_ll_user_heap_verify()` checks the heap pointer that user threads pass to the heap system calls. diff --git a/src/ipc/CMakeLists.txt b/src/ipc/CMakeLists.txt index 15fab54b3c30..47ee898b7be2 100644 --- a/src/ipc/CMakeLists.txt +++ b/src/ipc/CMakeLists.txt @@ -19,12 +19,6 @@ if(zephyr) ### Zephyr ### # dma-copy only used for dma-trace zephyr_library_sources_ifdef(CONFIG_TRACE dma-copy.c) -if (CONFIG_SOC_SERIES_INTEL_CAVS_V25 OR CONFIG_SOC_SERIES_INTEL_ADSP_ACE) - zephyr_library_sources( - ipc-zephyr.c - ) -endif() - else() ### Not Zephyr ### if (CONFIG_TRACE) diff --git a/src/kernel/CMakeLists.txt b/src/kernel/CMakeLists.txt index 1cd295617aad..da1df9328654 100644 --- a/src/kernel/CMakeLists.txt +++ b/src/kernel/CMakeLists.txt @@ -10,5 +10,13 @@ if(zephyr) set(ZEPHYR_CURRENT_LIBRARY sof_kernel) endif() +add_subdirectory(audio) +add_subdirectory(debug) add_subdirectory(idc) add_subdirectory(init) +add_subdirectory(ipc) +add_subdirectory(lib) +add_subdirectory(library_manager) +add_subdirectory(logging) +add_subdirectory(probe) +add_subdirectory(schedule) diff --git a/src/kernel/Kconfig b/src/kernel/Kconfig index 4378b4d74d0b..5a8920dd9b1f 100644 --- a/src/kernel/Kconfig +++ b/src/kernel/Kconfig @@ -2,4 +2,10 @@ # Code that only runs in kernel mode, see scripts/kernel_user_partition.txt. +rsource "debug/telemetry/Kconfig" + rsource "idc/Kconfig" + +rsource "library_manager/Kconfig" + +rsource "probe/Kconfig" diff --git a/src/kernel/README.md b/src/kernel/README.md new file mode 100644 index 000000000000..fd92a6369716 --- /dev/null +++ b/src/kernel/README.md @@ -0,0 +1,28 @@ +# Kernel-only code (`src/kernel`) + +> **Runs in:** Kernel-only — everything here runs in supervisor context and never executes in +> a user thread. User code reaches it only through system calls. See +> [User/kernel split](../include/sof/userspace/README.md). + +This directory collects the SOF code that only runs in kernel mode: OS, hardware and +memory-domain facing code such as boot and initialization, inter-core communication and +module loading. Kernel-only code elsewhere in `src/` moves here one subsystem at a time as part +of the kernel / user-space partition. + +## Layout + +Each subdirectory keeps the path the code had under `src/`, so `src/` moves to +`src/kernel/`. For example `src/audio/base_fw.c` becomes `src/kernel/audio/base_fw.c`. +When only some files of a directory are kernel-only, only those files move, and the rest of +the directory stays where it is. + +## Build + +Zephyr builds everything below this directory into the `sof_kernel` library instead of +`modules_sof`. [`CMakeLists.txt`](CMakeLists.txt) makes `sof_kernel` the current Zephyr +library for this directory tree, so the CMake files of moved directories do not change. Their +Kconfig files are sourced from [`Kconfig`](Kconfig). + +Code here may use kernel-only headers. User-space code must not call into it directly; the +checker in `scripts/check_kernel_includes.py` reports kernel-only includes from user-space +sources. diff --git a/src/kernel/audio/CMakeLists.txt b/src/kernel/audio/CMakeLists.txt new file mode 100644 index 000000000000..e310aa2585a3 --- /dev/null +++ b/src/kernel/audio/CMakeLists.txt @@ -0,0 +1,16 @@ +# SPDX-License-Identifier: BSD-3-Clause + +if(CONFIG_COMP_BASEFW_IPC4 AND NOT CONFIG_LIBRARY) + add_local_sources(sof base_fw.c) +endif() +add_local_sources_ifdef(CONFIG_IPC4_BASE_FW_INTEL sof base_fw_intel.c) +if(CONFIG_INTEL_ADSP_MIC_PRIVACY) + add_subdirectory(mic_privacy_manager) +endif() + +is_zephyr(zephyr) +if(zephyr) + zephyr_library_sources_ifdef(CONFIG_SOF_USERSPACE_PROXY + module_adapter/library/userspace_proxy.c + ) +endif() diff --git a/src/audio/base_fw.c b/src/kernel/audio/base_fw.c similarity index 100% rename from src/audio/base_fw.c rename to src/kernel/audio/base_fw.c diff --git a/src/audio/base_fw_intel.c b/src/kernel/audio/base_fw_intel.c similarity index 99% rename from src/audio/base_fw_intel.c rename to src/kernel/audio/base_fw_intel.c index 0d302e7c3fab..3d25f89dbd18 100644 --- a/src/audio/base_fw_intel.c +++ b/src/kernel/audio/base_fw_intel.c @@ -28,7 +28,7 @@ #include #include #include -#include "copier/copier_gain.h" +#include "../../audio/copier/copier_gain.h" #if CONFIG_INTEL_ADSP_MIC_PRIVACY #include diff --git a/src/audio/mic_privacy_manager/CMakeLists.txt b/src/kernel/audio/mic_privacy_manager/CMakeLists.txt similarity index 100% rename from src/audio/mic_privacy_manager/CMakeLists.txt rename to src/kernel/audio/mic_privacy_manager/CMakeLists.txt diff --git a/src/audio/mic_privacy_manager/README.md b/src/kernel/audio/mic_privacy_manager/README.md similarity index 100% rename from src/audio/mic_privacy_manager/README.md rename to src/kernel/audio/mic_privacy_manager/README.md diff --git a/src/audio/mic_privacy_manager/mic_privacy_manager_intel.c b/src/kernel/audio/mic_privacy_manager/mic_privacy_manager_intel.c similarity index 100% rename from src/audio/mic_privacy_manager/mic_privacy_manager_intel.c rename to src/kernel/audio/mic_privacy_manager/mic_privacy_manager_intel.c diff --git a/src/audio/module_adapter/library/userspace_proxy.c b/src/kernel/audio/module_adapter/library/userspace_proxy.c similarity index 100% rename from src/audio/module_adapter/library/userspace_proxy.c rename to src/kernel/audio/module_adapter/library/userspace_proxy.c diff --git a/src/kernel/debug/CMakeLists.txt b/src/kernel/debug/CMakeLists.txt new file mode 100644 index 000000000000..e364c4233063 --- /dev/null +++ b/src/kernel/debug/CMakeLists.txt @@ -0,0 +1,10 @@ +# SPDX-License-Identifier: BSD-3-Clause + +is_zephyr(zephyr) +if(zephyr) ### Zephyr ### + +add_subdirectory(telemetry) + +zephyr_library_sources_ifdef(CONFIG_COLD_STORE_EXECUTE_DEBUG dram.c) + +endif() # Zephyr diff --git a/src/debug/dram.c b/src/kernel/debug/dram.c similarity index 100% rename from src/debug/dram.c rename to src/kernel/debug/dram.c diff --git a/src/debug/telemetry/CMakeLists.txt b/src/kernel/debug/telemetry/CMakeLists.txt similarity index 100% rename from src/debug/telemetry/CMakeLists.txt rename to src/kernel/debug/telemetry/CMakeLists.txt diff --git a/src/debug/telemetry/Kconfig b/src/kernel/debug/telemetry/Kconfig similarity index 100% rename from src/debug/telemetry/Kconfig rename to src/kernel/debug/telemetry/Kconfig diff --git a/src/debug/telemetry/README.md b/src/kernel/debug/telemetry/README.md similarity index 100% rename from src/debug/telemetry/README.md rename to src/kernel/debug/telemetry/README.md diff --git a/src/debug/telemetry/performance_monitor.c b/src/kernel/debug/telemetry/performance_monitor.c similarity index 100% rename from src/debug/telemetry/performance_monitor.c rename to src/kernel/debug/telemetry/performance_monitor.c diff --git a/src/debug/telemetry/telemetry.c b/src/kernel/debug/telemetry/telemetry.c similarity index 100% rename from src/debug/telemetry/telemetry.c rename to src/kernel/debug/telemetry/telemetry.c diff --git a/src/kernel/ipc/CMakeLists.txt b/src/kernel/ipc/CMakeLists.txt new file mode 100644 index 000000000000..8f22a80cc2f4 --- /dev/null +++ b/src/kernel/ipc/CMakeLists.txt @@ -0,0 +1,8 @@ +# SPDX-License-Identifier: BSD-3-Clause + +is_zephyr(zephyr) +if(zephyr) + if (CONFIG_SOC_SERIES_INTEL_CAVS_V25 OR CONFIG_SOC_SERIES_INTEL_ADSP_ACE) + zephyr_library_sources(ipc-zephyr.c) + endif() +endif() diff --git a/src/ipc/ipc-zephyr.c b/src/kernel/ipc/ipc-zephyr.c similarity index 100% rename from src/ipc/ipc-zephyr.c rename to src/kernel/ipc/ipc-zephyr.c diff --git a/src/kernel/lib/CMakeLists.txt b/src/kernel/lib/CMakeLists.txt new file mode 100644 index 000000000000..6f9861ed59f0 --- /dev/null +++ b/src/kernel/lib/CMakeLists.txt @@ -0,0 +1,18 @@ +# SPDX-License-Identifier: BSD-3-Clause + +if(CONFIG_AMS) + add_local_sources(sof ams.c) +endif() + +if(CONFIG_KCPS_DYNAMIC_CLOCK_CONTROL) + add_local_sources(sof cpu-clk-manager.c) +endif() + +is_zephyr(zephyr) +if(zephyr) ### Zephyr ### + + if(NOT CONFIG_SOF_ZEPHYR_NO_SOF_CLOCK) + add_local_sources(sof clk.c) + endif() + +endif() diff --git a/src/lib/ams.c b/src/kernel/lib/ams.c similarity index 100% rename from src/lib/ams.c rename to src/kernel/lib/ams.c diff --git a/src/lib/clk.c b/src/kernel/lib/clk.c similarity index 100% rename from src/lib/clk.c rename to src/kernel/lib/clk.c diff --git a/src/lib/cpu-clk-manager.c b/src/kernel/lib/cpu-clk-manager.c similarity index 100% rename from src/lib/cpu-clk-manager.c rename to src/kernel/lib/cpu-clk-manager.c diff --git a/src/library_manager/CMakeLists.txt b/src/kernel/library_manager/CMakeLists.txt similarity index 100% rename from src/library_manager/CMakeLists.txt rename to src/kernel/library_manager/CMakeLists.txt diff --git a/src/library_manager/Kconfig b/src/kernel/library_manager/Kconfig similarity index 100% rename from src/library_manager/Kconfig rename to src/kernel/library_manager/Kconfig diff --git a/src/library_manager/lib_manager.c b/src/kernel/library_manager/lib_manager.c similarity index 100% rename from src/library_manager/lib_manager.c rename to src/kernel/library_manager/lib_manager.c diff --git a/src/library_manager/lib_notification.c b/src/kernel/library_manager/lib_notification.c similarity index 100% rename from src/library_manager/lib_notification.c rename to src/kernel/library_manager/lib_notification.c diff --git a/src/library_manager/llext_manager.c b/src/kernel/library_manager/llext_manager.c similarity index 100% rename from src/library_manager/llext_manager.c rename to src/kernel/library_manager/llext_manager.c diff --git a/src/library_manager/llext_manager_dram.c b/src/kernel/library_manager/llext_manager_dram.c similarity index 100% rename from src/library_manager/llext_manager_dram.c rename to src/kernel/library_manager/llext_manager_dram.c diff --git a/src/logging/CMakeLists.txt b/src/kernel/logging/CMakeLists.txt similarity index 100% rename from src/logging/CMakeLists.txt rename to src/kernel/logging/CMakeLists.txt diff --git a/src/logging/log_backend_probe.c b/src/kernel/logging/log_backend_probe.c similarity index 100% rename from src/logging/log_backend_probe.c rename to src/kernel/logging/log_backend_probe.c diff --git a/src/probe/CMakeLists.txt b/src/kernel/probe/CMakeLists.txt similarity index 100% rename from src/probe/CMakeLists.txt rename to src/kernel/probe/CMakeLists.txt diff --git a/src/probe/Kconfig b/src/kernel/probe/Kconfig similarity index 100% rename from src/probe/Kconfig rename to src/kernel/probe/Kconfig diff --git a/src/probe/llext/CMakeLists.txt b/src/kernel/probe/llext/CMakeLists.txt similarity index 100% rename from src/probe/llext/CMakeLists.txt rename to src/kernel/probe/llext/CMakeLists.txt diff --git a/src/probe/llext/llext.toml.h b/src/kernel/probe/llext/llext.toml.h similarity index 100% rename from src/probe/llext/llext.toml.h rename to src/kernel/probe/llext/llext.toml.h diff --git a/src/probe/probe.c b/src/kernel/probe/probe.c similarity index 100% rename from src/probe/probe.c rename to src/kernel/probe/probe.c diff --git a/src/probe/probe.toml b/src/kernel/probe/probe.toml similarity index 100% rename from src/probe/probe.toml rename to src/kernel/probe/probe.toml diff --git a/src/kernel/schedule/CMakeLists.txt b/src/kernel/schedule/CMakeLists.txt new file mode 100644 index 000000000000..277378449165 --- /dev/null +++ b/src/kernel/schedule/CMakeLists.txt @@ -0,0 +1,8 @@ +# SPDX-License-Identifier: BSD-3-Clause + +is_zephyr(zephyr) +if(zephyr) + zephyr_library_sources_ifdef(CONFIG_SOF_USERSPACE_LL + zephyr_ll_user.c + ) +endif() diff --git a/src/schedule/zephyr_ll_user.c b/src/kernel/schedule/zephyr_ll_user.c similarity index 100% rename from src/schedule/zephyr_ll_user.c rename to src/kernel/schedule/zephyr_ll_user.c diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt index 707753635f69..f92e467d970f 100644 --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -15,21 +15,9 @@ if(CONFIG_HAVE_AGENT) add_local_sources(sof agent.c) endif() -if(CONFIG_AMS) - add_local_sources(sof ams.c) -endif() - -if(CONFIG_KCPS_DYNAMIC_CLOCK_CONTROL) - add_local_sources(sof cpu-clk-manager.c) -endif() - is_zephyr(zephyr) if(zephyr) ### Zephyr ### add_local_sources(sof ${common_files}) - if(NOT CONFIG_SOF_ZEPHYR_NO_SOF_CLOCK) - add_local_sources(sof clk.c) - endif() - endif() diff --git a/src/lib/README.md b/src/lib/README.md index 21e76ee840e9..6c986bdffafc 100644 --- a/src/lib/README.md +++ b/src/lib/README.md @@ -3,10 +3,10 @@ > **Runs in:** Mixed — this directory contains code in more than one tier. `dma.c` and `dai.c` > host the kernel-side implementations (`z_impl_sof_dma_get/put`, `z_impl_dai_get_device`) of > syscalls whose validators live in `zephyr/syscall/`; treat them as boundary/kernel code. -> Several other files (`clk.c`, `notifier.c`, `cpu-clk-manager.c`) take Zephyr spinlocks or -> perform privileged platform callbacks and are similarly restricted to kernel context. Truly -> context-agnostic helpers (`lib.c`, `objpool.c`, `ams.c`) can safely be linked into user -> builds. See [User/kernel split](../include/sof/userspace/README.md). +> `notifier.c` takes Zephyr spinlocks and is similarly restricted to kernel context. The clock, +> KCPS and AMS code (`clk.c`, `cpu-clk-manager.c`, `ams.c`) is kernel-only and lives in +> `src/kernel/lib`. Truly context-agnostic helpers (`lib.c`, `objpool.c`) can safely be linked +> into user builds. See [User/kernel split](../include/sof/userspace/README.md). This directory collects cross-cutting helpers that don't belong to a single subsystem. When adding code here, decide first which tier it belongs to: a pure helper (no locks, no diff --git a/src/platform/posix/include/platform/lib/clk.h b/src/platform/posix/include/platform/lib/clk.h index a5d8066a027c..4e246ca29b01 100644 --- a/src/platform/posix/include/platform/lib/clk.h +++ b/src/platform/posix/include/platform/lib/clk.h @@ -7,7 +7,7 @@ #define CPU_LPRO_FREQ_IDX 0 #define CPU_LOWEST_FREQ_IDX CPU_LPRO_FREQ_IDX -/* This is not a platform function, it's defined in src/lib/clk.c. +/* This is not a platform function, it's defined in src/kernel/lib/clk.c. * But the declaration has historically been in the platform layer, so * it's repeated here. */ diff --git a/src/schedule/CMakeLists.txt b/src/schedule/CMakeLists.txt index 622b75e46888..bc14c6ecff46 100644 --- a/src/schedule/CMakeLists.txt +++ b/src/schedule/CMakeLists.txt @@ -54,8 +54,4 @@ zephyr_library_sources_ifdef(CONFIG_ZEPHYR_TWB_SCHEDULER zephyr_twb_schedule.c ) -zephyr_library_sources_ifdef(CONFIG_SOF_USERSPACE_LL - zephyr_ll_user.c -) - endif() diff --git a/src/schedule/README.md b/src/schedule/README.md index 9d53cfd1fdfe..0bef23248837 100644 --- a/src/schedule/README.md +++ b/src/schedule/README.md @@ -1,8 +1,8 @@ # SOF Scheduling Architecture > **Runs in:** Boundary / bridge — this directory owns the LL/DP schedulers and their thread + -> memory-domain setup. `zephyr_ll.c` and `zephyr_domain.c` are kernel-side; `zephyr_ll_user.c` -> sets up the LL user memory domain (kernel-executed) and supports the LL user thread. +> memory-domain setup. `zephyr_ll.c` and `zephyr_domain.c` are kernel-side; the LL user memory +> domain and heap are set up by `src/kernel/schedule/zephyr_ll_user.c`. > `zephyr_dp_schedule_thread.c` is boundary code that can create and manage both kernel and > `K_USER` DP threads depending on configuration; `zephyr_dp_schedule_application.c` is the > DP application-mode path. This directory hosts the `zephyr_ll_task_sem_*` and diff --git a/tools/rimage/config/lnl.toml.h b/tools/rimage/config/lnl.toml.h index 96da2153a5a7..daca48653857 100644 --- a/tools/rimage/config/lnl.toml.h +++ b/tools/rimage/config/lnl.toml.h @@ -75,7 +75,7 @@ #endif #ifdef CONFIG_PROBE -#include +#include #endif #if defined(CONFIG_COMP_MUX) || defined(LLEXT_FORCE_ALL_MODULAR) diff --git a/tools/rimage/config/mtl.toml.h b/tools/rimage/config/mtl.toml.h index 119dbf7ffe6a..c0a0b363bfb4 100644 --- a/tools/rimage/config/mtl.toml.h +++ b/tools/rimage/config/mtl.toml.h @@ -71,7 +71,7 @@ #endif #ifdef CONFIG_PROBE -#include +#include #endif #if defined(CONFIG_COMP_MUX) || defined(LLEXT_FORCE_ALL_MODULAR) diff --git a/tools/rimage/config/nvl.toml.h b/tools/rimage/config/nvl.toml.h index e7ae339bbf81..e1f4ebfb6336 100644 --- a/tools/rimage/config/nvl.toml.h +++ b/tools/rimage/config/nvl.toml.h @@ -75,7 +75,7 @@ index = __COUNTER__ #endif #ifdef CONFIG_PROBE -#include +#include #endif #if defined(CONFIG_COMP_MUX) || defined(LLEXT_FORCE_ALL_MODULAR) diff --git a/tools/rimage/config/ptl.toml.h b/tools/rimage/config/ptl.toml.h index 59a4a8fd4515..88e4a153797e 100644 --- a/tools/rimage/config/ptl.toml.h +++ b/tools/rimage/config/ptl.toml.h @@ -75,7 +75,7 @@ index = __COUNTER__ #endif #ifdef CONFIG_PROBE -#include +#include #endif #if defined(CONFIG_COMP_MUX) || defined(LLEXT_FORCE_ALL_MODULAR) diff --git a/tools/rimage/config/tgl-h.toml.h b/tools/rimage/config/tgl-h.toml.h index e4a717bbe351..6ad16122ca6e 100644 --- a/tools/rimage/config/tgl-h.toml.h +++ b/tools/rimage/config/tgl-h.toml.h @@ -37,7 +37,7 @@ #endif #ifdef CONFIG_PROBE -#include +#include #endif #if defined(CONFIG_COMP_SRC) || defined(LLEXT_FORCE_ALL_MODULAR) diff --git a/tools/rimage/config/tgl.toml.h b/tools/rimage/config/tgl.toml.h index 8c434e8bf5c3..765be13cc1d3 100644 --- a/tools/rimage/config/tgl.toml.h +++ b/tools/rimage/config/tgl.toml.h @@ -37,7 +37,7 @@ #endif #ifdef CONFIG_PROBE -#include +#include #endif #if defined(CONFIG_COMP_SRC) || defined(LLEXT_FORCE_ALL_MODULAR) diff --git a/tools/rimage/config/wcl.toml.h b/tools/rimage/config/wcl.toml.h index 9a715ba4b2d2..dfedda2a6f8c 100644 --- a/tools/rimage/config/wcl.toml.h +++ b/tools/rimage/config/wcl.toml.h @@ -75,7 +75,7 @@ index = __COUNTER__ #endif #ifdef CONFIG_PROBE -#include +#include #endif #if defined(CONFIG_COMP_MUX) || defined(LLEXT_FORCE_ALL_MODULAR) diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt index f471aea8e0b7..ea8f312f435b 100644 --- a/zephyr/CMakeLists.txt +++ b/zephyr/CMakeLists.txt @@ -240,9 +240,6 @@ add_subdirectory(../src/debug/ debug_unused_install/) add_subdirectory(../src/ipc/ ipc_unused_install/) add_subdirectory(../src/kernel/ kernel_unused_install/) add_subdirectory(../src/lib/ lib_unused_install/) -add_subdirectory(../src/library_manager/ library_manager_unused_install/) -add_subdirectory(../src/logging/ logging_unused_install/) -add_subdirectory(../src/probe/ probes_unused_install/) add_subdirectory(../src/samples/ samples_unused_install/) add_subdirectory(../src/schedule/ schedule_unused_install/) add_subdirectory(../src/trace/ trace_unused_install/)