Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion scripts/kernel_user_partition.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ src/lib/objpool.c
[not-user-sources]
src/audio/dai-legacy.c
src/audio/host-legacy.c
src/audio/intel_uaol.c

# SOF headers that only kernel code may include.
# Not listed on purpose: rtos/init.h, which only provides the
Expand Down
66 changes: 4 additions & 62 deletions src/audio/intel_uaol.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,74 +14,16 @@

LOG_MODULE_REGISTER(uaol, CONFIG_SOF_LOG_LEVEL);

struct ipc4_uaol_link_capabilities {
uint32_t input_streams_supported : 4;
uint32_t output_streams_supported : 4;
uint32_t bidirectional_streams_supported : 5;
uint32_t rsvd : 19;
uint32_t max_tx_fifo_size;
uint32_t max_rx_fifo_size;
} __packed __aligned(4);

struct ipc4_uaol_capabilities {
uint32_t link_count;
struct ipc4_uaol_link_capabilities link_caps[];
} __packed __aligned(4);
/* The UAOL capabilities and stream mapping queries of the base firmware, which run in
* kernel mode, are in src/kernel/audio/intel_uaol-kernel.c
*/

#define DEV_AND_COMMA(node) DEVICE_DT_GET(node),
/* const pointers keep the array in rodata, readable by the user-space LL thread */
static const struct device *const uaol_devs[] = {
const struct device *const uaol_devs[] = {
DT_FOREACH_STATUS_OKAY(intel_adsp_uaol, DEV_AND_COMMA)
};

#if !CONFIG_SOF_OS_LINUX_COMPAT_PRIORITY
__cold void tlv_value_set_uaol_caps(struct sof_tlv *tuple, uint32_t type)
{
const size_t dev_count = ARRAY_SIZE(uaol_devs);
struct uaol_capabilities dev_cap;
struct ipc4_uaol_capabilities *caps = (struct ipc4_uaol_capabilities *)tuple->value;
size_t caps_size = offsetof(struct ipc4_uaol_capabilities, link_caps[dev_count]);
size_t i;
int ret;

assert_can_be_cold();

memset(caps, 0, caps_size);

caps->link_count = dev_count;
for (i = 0; i < dev_count; i++) {
ret = uaol_get_capabilities(uaol_devs[i], &dev_cap);
if (ret)
continue;

caps->link_caps[i].input_streams_supported = dev_cap.input_streams;
caps->link_caps[i].output_streams_supported = dev_cap.output_streams;
caps->link_caps[i].bidirectional_streams_supported = dev_cap.bidirectional_streams;
caps->link_caps[i].max_tx_fifo_size = dev_cap.max_tx_fifo_size;
caps->link_caps[i].max_rx_fifo_size = dev_cap.max_rx_fifo_size;
}

tlv_value_set(tuple, type, caps_size, caps);
}
#endif /* !CONFIG_SOF_OS_LINUX_COMPAT_PRIORITY */

__cold int uaol_stream_id_to_hda_link_stream_id(int uaol_stream_id)
{
size_t dev_count = ARRAY_SIZE(uaol_devs);
size_t i;

assert_can_be_cold();

for (i = 0; i < dev_count; i++) {
int hda_link_stream_id = uaol_get_mapped_hda_link_stream_id(uaol_devs[i],
uaol_stream_id);
if (hda_link_stream_id >= 0)
return hda_link_stream_id;
}

return -1;
}

const struct device *get_uaol_zdevice(int uaol_link_id)
{
/* uaol_link_id is just an index for the device tree device */
Expand Down
6 changes: 6 additions & 0 deletions src/include/sof/audio/intel_uaol.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include <stdint.h>
#include <sof/lib/memory.h>
#include <zephyr/devicetree.h>

struct sof_tlv;
struct device;
Expand All @@ -20,6 +21,11 @@ __cold int uaol_stream_id_to_hda_link_stream_id(int uaol_stream_id);

const struct device *get_uaol_zdevice(int uaol_link_id);

#if CONFIG_UAOL_INTEL_ADSP
/* UAOL devices, defined in intel_uaol.c. In rodata, readable from user space. */
extern const struct device *const uaol_devs[DT_NUM_INST_STATUS_OKAY(intel_adsp_uaol)];
#endif

/* these are called from dai-zephyr.c */

struct dai;
Expand Down
12 changes: 6 additions & 6 deletions src/include/sof/userspace/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,13 @@ Classification is grep-verifiable — see [Verifying the taxonomy](#verifying-th
> collects the validating half of several syscalls in one place — `zephyr/syscall/alloc.c`,
> `cpu.c`, `vregion.c`, `dai.c`, `sof_dma.c` each hold the `z_vrfy_*` wrappers for their
> subsystem, physically separated from the `z_impl_*` logic (in `zephyr/lib/*.c` and
> `src/lib/*.c`). This is exactly the boundary-tier separation this document promotes; the
> `src/kernel/lib/*.c`). This is exactly the boundary-tier separation this document promotes; the
> migration opportunity is to move the *still-scattered* validators (IPC, module management,
> library manager, scheduling, debug) toward the same convention.

> Borderline cases (e.g. parts of `lib/` that host syscall *implementations* such as `dma.c`
> and `dai.c`) behave as boundary code even though the directory is mostly shared-library. When
> a single directory genuinely mixes tiers, its README states the exception explicitly.
> Mixed files are split: the syscall *implementations* of `lib/dma.c` and `lib/dai.c`, for
> example, are in `kernel/lib/dma-kernel.c` and `dai-kernel.c`. When a single directory
> genuinely mixes tiers, its README states the exception explicitly.

## The boundary is the syscall set

Expand All @@ -119,8 +119,8 @@ syscall by subsystem:
| IPC | `ipc_msg_send`, `ipc_msg_list_remove`, `ipc_msg_reply`, `ipc_compound_pre_start`, `ipc_compound_post_start`, `ipc_wait_for_compound_msg`, `send_resource_notif` | `sof/ipc/msg.h`, `sof/ipc/ipc_reply.h`, `ipc4/handler.h`, `ipc4/notification.h` | scattered: `ipc/ipc-common.c`, `kernel/ipc/ipc3/helper.c`, `kernel/ipc/ipc4/handler-kernel.c`, `kernel/ipc/ipc4/notification.c` |
| Heap alloc | `sof_heap_alloc`, `sof_heap_free` | `rtos/alloc.h` | `zephyr/syscall/alloc.c` / `zephyr/lib/alloc.c` |
| Virtual regions | `vregion_create_map`, `vregion_set_interim`, `vregion_get`, `vregion_put`, `vregion_alloc_align`, `vregion_alloc_coherent_align`, `vregion_free` | `sof/lib/vregion.h` | `zephyr/syscall/vregion.c` / `zephyr/lib/vregion.c` |
| DMA | `sof_dma_get`, `sof_dma_put`, `sof_dma_get_attribute`, `sof_dma_request_channel`, `sof_dma_release_channel`, `sof_dma_config`, `sof_dma_start`, `sof_dma_stop`, `sof_dma_get_status`, `sof_dma_reload`, `sof_dma_suspend`, `sof_dma_resume` | `sof/lib/sof_dma.h` | `zephyr/syscall/sof_dma.c` / `lib/dma.c` (get/put); remaining 10 are `static inline z_impl_*` in `sof/lib/sof_dma.h` |
| DAI | `dai_get_device` | `sof/lib/dai-zephyr.h` | `zephyr/syscall/dai.c` / `lib/dai.c` |
| DMA | `sof_dma_get`, `sof_dma_put`, `sof_dma_get_attribute`, `sof_dma_request_channel`, `sof_dma_release_channel`, `sof_dma_config`, `sof_dma_start`, `sof_dma_stop`, `sof_dma_get_status`, `sof_dma_reload`, `sof_dma_suspend`, `sof_dma_resume` | `sof/lib/sof_dma.h` | `zephyr/syscall/sof_dma.c` / `kernel/lib/dma-kernel.c` (get/put); remaining 10 are `static inline z_impl_*` in `sof/lib/sof_dma.h` |
| DAI | `dai_get_device` | `sof/lib/dai-zephyr.h` | `zephyr/syscall/dai.c` / `kernel/lib/dai-kernel.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_data_blob_set`, `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: `kernel/library_manager/lib_manager.c` |
Expand Down
2 changes: 2 additions & 0 deletions src/kernel/audio/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ 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)
# The kernel part of src/audio/intel_uaol.c, built with it
add_local_sources_ifdef(CONFIG_UAOL_INTEL_ADSP sof intel_uaol-kernel.c)
if(CONFIG_INTEL_ADSP_MIC_PRIVACY)
add_subdirectory(mic_privacy_manager)
endif()
Expand Down
79 changes: 79 additions & 0 deletions src/kernel/audio/intel_uaol-kernel.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/* SPDX-License-Identifier: BSD-3-Clause
*
* Copyright 2026 Intel Corporation. All rights reserved.
*/

#include <zephyr/drivers/uaol.h>
#include <zephyr/logging/log.h>
#include <rtos/alloc.h>
#include <rtos/string.h>
#include <sof/tlv.h>
#include <sof/lib/dai-zephyr.h>
#include <sof/audio/intel_uaol.h>

/* Kernel part of the UAOL support: the UAOL capabilities and stream mapping queries of
* the base firmware. The UAOL device table, its lookup and the UAOL feedback and rate
* adjustment, which run in the LL thread, are in src/audio/intel_uaol.c
*/

struct ipc4_uaol_link_capabilities {
uint32_t input_streams_supported : 4;
uint32_t output_streams_supported : 4;
uint32_t bidirectional_streams_supported : 5;
uint32_t rsvd : 19;
uint32_t max_tx_fifo_size;
uint32_t max_rx_fifo_size;
} __packed __aligned(4);

struct ipc4_uaol_capabilities {
uint32_t link_count;
struct ipc4_uaol_link_capabilities link_caps[];
} __packed __aligned(4);

#if !CONFIG_SOF_OS_LINUX_COMPAT_PRIORITY
__cold void tlv_value_set_uaol_caps(struct sof_tlv *tuple, uint32_t type)
{
const size_t dev_count = ARRAY_SIZE(uaol_devs);
struct uaol_capabilities dev_cap;
struct ipc4_uaol_capabilities *caps = (struct ipc4_uaol_capabilities *)tuple->value;
size_t caps_size = offsetof(struct ipc4_uaol_capabilities, link_caps[dev_count]);
size_t i;
int ret;

assert_can_be_cold();

memset(caps, 0, caps_size);

caps->link_count = dev_count;
for (i = 0; i < dev_count; i++) {
ret = uaol_get_capabilities(uaol_devs[i], &dev_cap);
if (ret)
continue;

caps->link_caps[i].input_streams_supported = dev_cap.input_streams;
caps->link_caps[i].output_streams_supported = dev_cap.output_streams;
caps->link_caps[i].bidirectional_streams_supported = dev_cap.bidirectional_streams;
caps->link_caps[i].max_tx_fifo_size = dev_cap.max_tx_fifo_size;
caps->link_caps[i].max_rx_fifo_size = dev_cap.max_rx_fifo_size;
}

tlv_value_set(tuple, type, caps_size, caps);
}
#endif /* !CONFIG_SOF_OS_LINUX_COMPAT_PRIORITY */

__cold int uaol_stream_id_to_hda_link_stream_id(int uaol_stream_id)
{
size_t dev_count = ARRAY_SIZE(uaol_devs);
size_t i;

assert_can_be_cold();

for (i = 0; i < dev_count; i++) {
int hda_link_stream_id = uaol_get_mapped_hda_link_stream_id(uaol_devs[i],
uaol_stream_id);
if (hda_link_stream_id >= 0)
return hda_link_stream_id;
}

return -1;
}
7 changes: 6 additions & 1 deletion src/kernel/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
# SPDX-License-Identifier: BSD-3-Clause

# The kernel parts of src/lib/dma.c and dai.c, built with them
set(common_files dma-kernel.c dai-kernel.c)

if(CONFIG_LIBRARY)
add_local_sources(sof agent.c)
add_local_sources(sof agent.c ${common_files})
return()
endif()

add_local_sources(sof ${common_files})

if(CONFIG_HAVE_AGENT)
add_local_sources(sof agent.c)
endif()
Expand Down
Loading
Loading