diff --git a/src/kernel/CMakeLists.txt b/src/kernel/CMakeLists.txt new file mode 100644 index 000000000000..0b6846d11494 --- /dev/null +++ b/src/kernel/CMakeLists.txt @@ -0,0 +1,13 @@ +# SPDX-License-Identifier: BSD-3-Clause + +# Code that only runs in kernel mode, see scripts/kernel_user_partition.txt. + +is_zephyr(zephyr) +if(zephyr) + # Build everything below into the sof_kernel library created in + # zephyr/CMakeLists.txt instead of modules_sof. This only sets the + # variable for this directory and its subdirectories. + set(ZEPHYR_CURRENT_LIBRARY sof_kernel) +endif() + +add_subdirectory(init) diff --git a/src/init/CMakeLists.txt b/src/kernel/init/CMakeLists.txt similarity index 100% rename from src/init/CMakeLists.txt rename to src/kernel/init/CMakeLists.txt diff --git a/src/init/README.md b/src/kernel/init/README.md similarity index 93% rename from src/init/README.md rename to src/kernel/init/README.md index 58528af0a4d8..b20d490550f2 100644 --- a/src/init/README.md +++ b/src/kernel/init/README.md @@ -1,10 +1,10 @@ -# DSP Initialization (`src/init`) +# DSP Initialization (`src/kernel/init`) > **Runs in:** Kernel-only — boot and bring-up code runs in supervisor context; no path here > executes directly in a user thread. See -> [User/kernel split](../include/sof/userspace/README.md). +> [User/kernel split](../../include/sof/userspace/README.md). -The `src/init` directory contains the generic digital signal processor (DSP) initialization code and firmware metadata structures for Sound Open Firmware (SOF). It acts as the bridge between the underlying RTOS (Zephyr) boot phase and the SOF-specific task scheduling and processing pipelines. +The `src/kernel/init` directory contains the generic digital signal processor (DSP) initialization code and firmware metadata structures for Sound Open Firmware (SOF). It acts as the bridge between the underlying RTOS (Zephyr) boot phase and the SOF-specific task scheduling and processing pipelines. ## Architecture and Boot Flow @@ -19,7 +19,7 @@ The primary entry point for SOF system initialization is `sof_init()`, registere ```mermaid sequenceDiagram participant Zephyr as Zephyr RTOS - participant sof_init as sof_init (src/init.c) + participant sof_init as sof_init (src/kernel/init/init.c) participant primary_core as primary_core_init participant trace as trace_init participant notify as init_system_notify diff --git a/src/init/ext_manifest.c b/src/kernel/init/ext_manifest.c similarity index 100% rename from src/init/ext_manifest.c rename to src/kernel/init/ext_manifest.c diff --git a/src/init/init.c b/src/kernel/init/init.c similarity index 100% rename from src/init/init.c rename to src/kernel/init/init.c diff --git a/test/ztest/unit/common/sof_context.c b/test/ztest/unit/common/sof_context.c index 91d20c644572..87aa6832f299 100644 --- a/test/ztest/unit/common/sof_context.c +++ b/test/ztest/unit/common/sof_context.c @@ -7,9 +7,9 @@ // // Minimal SOF context for standalone ztest applications that link SOF code // calling sof_get(), for example src/audio/component.c, but do not link -// src/init/init.c. The context is created on first use and only its component -// driver list is initialised, which is what buffer_new() and the component -// infrastructure need. +// src/kernel/init/init.c. The context is created on first use and only its +// component driver list is initialised, which is what buffer_new() and the +// component infrastructure need. #include #include diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt index 0e5e9749b26b..47dcaca6cf4c 100644 --- a/zephyr/CMakeLists.txt +++ b/zephyr/CMakeLists.txt @@ -174,6 +174,13 @@ target_include_directories(SOF INTERFACE ${SOF_SRC_PATH}/arch/${ARCH}/include) target_include_directories(SOF INTERFACE ${sof_top_dir}/third_party/include) target_include_directories(SOF INTERFACE ${sof_top_dir}/zephyr/include) +# Code that only runs in kernel mode, from src/kernel. It is built as a +# library of its own so that it can later be given kernel-only include +# directories. Created before modules_sof so that modules_sof stays the +# current library here; src/kernel/CMakeLists.txt switches to this one. +zephyr_library_named(sof_kernel) +zephyr_library_link_libraries(SOF) + # SOF module init zephyr_library_named(modules_sof) @@ -231,8 +238,8 @@ add_subdirectory(../src/math/ math_unused_install/) add_subdirectory(../src/audio/ audio_unused_install/) add_subdirectory(../src/debug/ debug_unused_install/) add_subdirectory(../src/idc/ idc_unused_install/) -add_subdirectory(../src/init/ init_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/) @@ -665,5 +672,6 @@ include(../scripts/cmake/uuid-registry.cmake) # Create Trace realtive file paths sof_append_relative_path_definitions(modules_sof) +sof_append_relative_path_definitions(sof_kernel) endif() # CONFIG_SOF_FULL_ZEPHYR_APPLICATION