From 2cdf38c47e7d23770161767dd5314ba52b0386b1 Mon Sep 17 00:00:00 2001 From: "Dobrowolski, PawelX" Date: Tue, 4 Jul 2023 14:01:34 +0200 Subject: [PATCH] module_adapter: native_system_agent: Introduce call and interface This is part of fw which helps loaded module in communication with adsp Also it provides basic operations for creation of component driver Common part for native loadable modules and iadk is put together and remade into native API. That way system services are using generic methods defined in native system service. Signed-off-by: Dobrowolski, PawelX --- .../module_adapter/iadk/system_agent.cpp | 39 ++-- .../library/native_system_agent.c | 40 ++++ .../native_system_service.c} | 59 ++--- .../sof/audio/module_adapter/iadk/logger.h | 3 +- .../module_adapter/iadk/system_service.h | 206 +----------------- .../library/native_system_agent.h | 27 +++ .../library/native_system_service.h | 114 ++++++++++ .../sof/audio/module_adapter/module/generic.h | 3 + zephyr/CMakeLists.txt | 6 +- 9 files changed, 244 insertions(+), 253 deletions(-) create mode 100644 src/audio/module_adapter/library/native_system_agent.c rename src/audio/module_adapter/{iadk/system_service.c => library/native_system_service.c} (55%) create mode 100644 src/include/sof/audio/module_adapter/library/native_system_agent.h create mode 100644 src/include/sof/audio/module_adapter/library/native_system_service.h diff --git a/src/audio/module_adapter/iadk/system_agent.cpp b/src/audio/module_adapter/iadk/system_agent.cpp index 6e03a065d49f..6a6057890fcb 100644 --- a/src/audio/module_adapter/iadk/system_agent.cpp +++ b/src/audio/module_adapter/iadk/system_agent.cpp @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include #include #include @@ -32,29 +32,28 @@ void* operator new(size_t size, intel_adsp::ModuleHandle *placeholder) throw() } extern "C" { + void native_system_service_log_message (AdspLogPriority log_priority, uint32_t log_entry, + AdspLogHandle const* log_handle, uint32_t param1, + uint32_t param2, uint32_t param3, uint32_t param4); - void SystemServiceLogMessage (AdspLogPriority log_priority, uint32_t log_entry, - AdspLogHandle const* log_handle, uint32_t param1, - uint32_t param2, uint32_t param3, uint32_t param4); - - AdspErrorCode SystemServiceSafeMemcpy(void *RESTRICT dst, size_t maxlen, + AdspErrorCode native_system_service_safe_memcpy(void *RESTRICT dst, size_t maxlen, const void *RESTRICT src, size_t len); - AdspErrorCode SystemServiceSafeMemmove(void *dst, size_t maxlen, + AdspErrorCode native_system_service_safe_memmove(void *dst, size_t maxlen, const void *src, size_t len); - void* SystemServiceVecMemset(void *dst, int c, size_t len); + void *native_system_service_vec_memset(void *dst, int c, size_t len); - AdspErrorCode SystemServiceCreateNotification(NotificationParams *params, + AdspErrorCode native_system_service_create_notification(notification_params *params, uint8_t *notification_buffer, uint32_t notification_buffer_size, - AdspNotificationHandle *handle); + adsp_notification_handle *handle); - AdspErrorCode SystemServiceSendNotificationMessage(NotificationTarget notification_target, - AdspNotificationHandle message, + AdspErrorCode native_system_service_send_notif_msg(adsp_notification_target notification_target, + adsp_notification_handle message, uint32_t actual_payload_size); - AdspErrorCode SystemServiceGetInterface(AdspIfaceId id, SystemServiceIface **iface); + AdspErrorCode native_system_service_get_interface(adsp_iface_id id, system_service_iface **iface); } namespace intel_adsp @@ -64,13 +63,13 @@ namespace system /* Structure storing handles to system service operations */ AdspSystemService SystemAgent::system_service_ = { - SystemServiceLogMessage, - SystemServiceSafeMemcpy, - SystemServiceSafeMemmove, - SystemServiceVecMemset, - SystemServiceCreateNotification, - SystemServiceSendNotificationMessage, - SystemServiceGetInterface, + native_system_service_log_message, + native_system_service_safe_memcpy, + native_system_service_safe_memmove, + native_system_service_vec_memset, + native_system_service_create_notification, + native_system_service_send_notif_msg, + native_system_service_get_interface, }; SystemAgent::SystemAgent(uint32_t module_id, diff --git a/src/audio/module_adapter/library/native_system_agent.c b/src/audio/module_adapter/library/native_system_agent.c new file mode 100644 index 000000000000..b2d798c14238 --- /dev/null +++ b/src/audio/module_adapter/library/native_system_agent.c @@ -0,0 +1,40 @@ +// SPDX-License-Identifier: BSD-3-Clause +/* + * Copyright(c) 2023 Intel Corporation. All rights reserved. + * + * Author: Pawel Dobrowolski + */ + +#include +#include +#include +#include + +/* The create_instance_f is a function call type known in module. The module entry_point + * points to this type of function which starts module creation. + */ + +typedef void* (*native_create_instance_f)(void *mod_cfg, void *parent_ppl, + void **mod_ptr); + +struct native_system_agent native_sys_agent; + +void *native_system_agent_start(uint32_t *sys_service, + uint32_t entry_point, uint32_t module_id, + uint32_t instance_id, uint32_t core_id, uint32_t log_handle, + void *mod_cfg) +{ + native_sys_agent.module_id = module_id; + native_sys_agent.instance_id = instance_id; + native_sys_agent.core_id = core_id; + native_sys_agent.log_handle = log_handle; + + void *system_agent_p = &native_sys_agent; + uint32_t **sys_service_p = &sys_service; + + *sys_service_p = (uint32_t *)(&native_sys_agent.system_service); + + native_create_instance_f ci = (native_create_instance_f)entry_point; + + return ci(mod_cfg, NULL, &system_agent_p); +} diff --git a/src/audio/module_adapter/iadk/system_service.c b/src/audio/module_adapter/library/native_system_service.c similarity index 55% rename from src/audio/module_adapter/iadk/system_service.c rename to src/audio/module_adapter/library/native_system_service.c index 7a441219eca9..cc8496ea0733 100644 --- a/src/audio/module_adapter/iadk/system_service.c +++ b/src/audio/module_adapter/library/native_system_service.c @@ -1,30 +1,28 @@ // SPDX-License-Identifier: BSD-3-Clause -// -// Copyright(c) 2020 Intel Corporation. All rights reserved. -// -// Author: Jaroslaw Stelter - /* - * System Service interface for ADSP loadable library. + * Copyright(c) 2020 Intel Corporation. All rights reserved. + * + * Author: Jaroslaw Stelter + */ +/* + * Native System Service interface for ADSP loadable library. */ #include #include -#include #include #include #include #include #include -#include -#include +#include #include #define RSIZE_MAX 0x7FFFFFFF -void SystemServiceLogMessage(AdspLogPriority log_priority, uint32_t log_entry, - AdspLogHandle const *log_handle, uint32_t param1, uint32_t param2, - uint32_t param3, uint32_t param4) +void native_system_service_log_message(AdspLogPriority log_priority, uint32_t log_entry, + AdspLogHandle const *log_handle, uint32_t param1, + uint32_t param2, uint32_t param3, uint32_t param4) { uint32_t argc = (log_entry & 0x7); /* TODO: Need to call here function like _log_sofdict, since we do not have format */ @@ -49,13 +47,15 @@ void SystemServiceLogMessage(AdspLogPriority log_priority, uint32_t log_entry, } } -AdspErrorCode SystemServiceSafeMemcpy(void *RESTRICT dst, size_t maxlen, const void *RESTRICT src, - size_t len) +AdspErrorCode native_system_service_safe_memcpy(void *RESTRICT dst, size_t maxlen, + const void *RESTRICT src, + size_t len) { return (AdspErrorCode) memcpy_s(dst, maxlen, src, len); } -AdspErrorCode SystemServiceSafeMemmove(void *dst, size_t maxlen, const void *src, size_t len) +AdspErrorCode native_system_service_safe_memmove(void *dst, size_t maxlen, const void *src, + size_t len) { if (dst == NULL || maxlen > RSIZE_MAX) return ADSP_INVALID_PARAMETERS; @@ -75,24 +75,22 @@ AdspErrorCode SystemServiceSafeMemmove(void *dst, size_t maxlen, const void *src return ADSP_NO_ERROR; } -void *SystemServiceVecMemset(void *dst, int c, size_t len) +void *native_system_service_vec_memset(void *dst, int c, size_t len) { /* TODO: Currently simple memset. Should be changed. */ memset(dst, c, len); return dst; } -AdspErrorCode SystemServiceCreateNotification(NotificationParams *params, - uint8_t *notification_buffer, - uint32_t notification_buffer_size, - AdspNotificationHandle *handle) +AdspErrorCode native_system_service_create_notification(notification_params *params, + uint8_t *notification_buffer, + uint32_t notification_buffer_size, + adsp_notification_handle *handle) { if ((params == NULL) || (notification_buffer == NULL) || (notification_buffer_size <= 0) || (handle == NULL)) return ADSP_INVALID_PARAMETERS; - /* TODO: IPC header setup */ - /* https://github.com/thesofproject/sof/pull/5720 needed for completion. */ union ipc4_notification_header header; header.r.notif_type = params->type; @@ -103,15 +101,15 @@ AdspErrorCode SystemServiceCreateNotification(NotificationParams *params, struct ipc_msg *msg = lib_notif_msg_init((uint32_t)header.dat, notification_buffer_size); if (msg) { - *handle = (AdspNotificationHandle)msg; + *handle = (adsp_notification_handle)msg; params->payload = msg->tx_data; } return ADSP_NO_ERROR; } -AdspErrorCode SystemServiceSendNotificationMessage(NotificationTarget notification_target, - AdspNotificationHandle message, +AdspErrorCode native_system_service_send_notif_msg(adsp_notification_target notification_target, + adsp_notification_handle message, uint32_t actual_payload_size) { if ((message == NULL) || (actual_payload_size == 0)) @@ -123,10 +121,19 @@ AdspErrorCode SystemServiceSendNotificationMessage(NotificationTarget notificati return ADSP_NO_ERROR; } -AdspErrorCode SystemServiceGetInterface(AdspIfaceId id, SystemServiceIface **iface) +AdspErrorCode native_system_service_get_interface(adsp_iface_id id, system_service_iface **iface) { if (id < 0) return ADSP_INVALID_PARAMETERS; return ADSP_NO_ERROR; } +struct native_system_service_api native_system_service = { + .log_message = native_system_service_log_message, + .safe_memcpy = native_system_service_safe_memcpy, + .safe_memmove = native_system_service_safe_memmove, + .vec_memset = native_system_service_vec_memset, + .notification_create = native_system_service_create_notification, + .notification_send = native_system_service_send_notif_msg, + .get_interface = native_system_service_get_interface +}; diff --git a/src/include/sof/audio/module_adapter/iadk/logger.h b/src/include/sof/audio/module_adapter/iadk/logger.h index dc97f321ae06..d447eb07a514 100644 --- a/src/include/sof/audio/module_adapter/iadk/logger.h +++ b/src/include/sof/audio/module_adapter/iadk/logger.h @@ -32,7 +32,7 @@ class Logger uint32_t param2 = 0, uint32_t param3 = 0, uint32_t param4 = 0) { (void)_ignored; - system_service_.LogMessage(LOG_LEVEL, log_entry, &log_handle_, + system_service_.log_message(LOG_LEVEL, log_entry, &log_handle_, param1, param2, param3, param4); } @@ -41,7 +41,6 @@ class Logger AdspSystemService const &system_service_; AdspLogHandle const &log_handle_; }; - } /* namespace intel_adsp */ #endif /* #ifdef __cplusplus */ diff --git a/src/include/sof/audio/module_adapter/iadk/system_service.h b/src/include/sof/audio/module_adapter/iadk/system_service.h index 63cf84913612..54b15c0ab275 100644 --- a/src/include/sof/audio/module_adapter/iadk/system_service.h +++ b/src/include/sof/audio/module_adapter/iadk/system_service.h @@ -10,7 +10,7 @@ #include "logger.h" #include "adsp_stddef.h" #include "adsp_error_code.h" - +#include "native_system_service.h" #include #ifdef __clang__ @@ -22,210 +22,10 @@ extern "C" { #endif -/*! \brief This struct defines the obfuscating type for notifications. */ -typedef struct _AdspNotificationHandle {} *AdspNotificationHandle; - -/*! \brief Defines parameters used by ADSP system during notification creation. */ -typedef struct _NotificationParams { - uint32_t type; /*!< Notification type */ - uint16_t user_val_1; /*!< 16 bits user value available directly in IPC header - * for some notifications - */ - uint32_t user_val_2; /*!< 30 bits user value available directly in IPC header - * for some notifications - */ - uint32_t max_payload_size; /*!< Data size of payload (NotificationCreate updates this - * value to max possible payload size) - */ - uint8_t *payload; /*!< Pointer on the payload */ -} NotificationParams; - -/*! \brief Defines parameters used by ADSP system during Module Event notification creation. */ -typedef struct _ModuleEventNotification { - uint32_t module_instance_id; /*!< Module ID (MS word) + Module Instance ID (LS word) */ - uint32_t event_id; /*!< Module specific event ID. */ - uint32_t event_data_size; /*!< Size of event_data array in bytes. May be set to 0 - * in case there is no data. - */ - uint32_t event_data[]; /*!< Optional event data (size set to 0 as it is optional - * data) - */ -} ModuleEventNotification; - -/*! \brief Defines notification targets supported by ADSP system */ -typedef enum _NotificationTarget { - DSP_TO_HOST = 1, /*!< Notification target is HOST */ - DSP_TO_ISH = 2 /*!< Notification target is ISH */ -} NotificationTarget; - -/*! \brief Defines notification types supported by ADSP system */ -typedef enum _NotificationType { - VOICE_COMMAND_NOTIFICATION = 4, /*!< intel_adsp define corresponding to PHRASE_DETECTED - * notification - */ - AUDIO_CLASSIFIER_RESULTS = 9, /*!< intel_adsp define corresponding to FW_AUD_CLASS_RESULT - * notification - */ - MODULE_EVENT_NOTIFICATION = 12, /*!< intel_adsp define corresponding to MODULE_NOTIFICATION - * notification - */ -} NotificationType; - -/*! \brief Defines prototype of the "LogMessage" function - * - * \param log_priority define the log priority for the message to be sent. - * The ADSP System may have been configured by the host to filter log message below - * a given priority. - * \param log_entry provides information on log sender and log point location. - * \param log_handle \copybrief AdspLogHandle - * \param param1 some uint32_t value to include in the log message. - * \param param2 some uint32_t value to include in the log message. - * \param param3 some uint32_t value to include in the log message. - * \param param4 some uint32_t value to include in the log message. - * - * \see LOG_MESSAGE - */ -typedef void (*SystemServiceLogMessageFct) (AdspLogPriority log_priority, uint32_t log_entry, - AdspLogHandle const *log_handle, uint32_t param1, - uint32_t param2, uint32_t param3, uint32_t param4); - -/*! \brief Defines prototype of the "SafeMemcpy" function - * - * \param dst define the address of destination buffer - * \param maxlen define the size of destination buffer - * \param src define the address of source buffer - * \param len define the number of bytes - * \return zero if success, error code otherwise - */ -typedef AdspErrorCode (*SystemServiceSafeMemcpyFct) (void *RESTRICT dst, size_t maxlen, - const void *RESTRICT src, size_t len); - -/*! \brief Defines prototype of the "SafeMemmove" function - * - * \param dst define the address of destination buffer - * \param maxlen define the size of destination buffer - * \param src define the address of source buffer - * \param len define the number of bytes - * \return zero if success, error code otherwise - */ -typedef AdspErrorCode (*SystemServiceSafeMemmoveFct) (void *dst, size_t maxlen, - const void *src, size_t len); - -/*! \brief Defines prototype of the "VecMemset" function - * - * \param dst define the address of destination buffer - * \param c define the fill byte - * \param len define the number of bytes - * \return pointer to dst - */ -typedef void* (*SystemServiceVecMemsetFct) (void *dst, int c, size_t len); - -/*! \brief Defines prototype of the "NotificationCreate" function - * - * \param params pointer on NotificationParams input structure - * \param notification_buffer pointer on the notification buffer declared in module - * \param notification_buffer_size size of the notification buffer declared in module - * \param handle pointer on AdspNotificationHandle structure - * \return error if notification_buffer is too small or NULL - */ -typedef AdspErrorCode (*SystemServiceCreateNotificationFct) (NotificationParams *params, - uint8_t *notification_buffer, - uint32_t notification_buffer_size, - AdspNotificationHandle *handle); - -/*! \brief Defines prototype of the "NotificationSend" function - * - * \param notification_target notification target is HOST or ISH - * \param message the AdspNotificationHandle structure used for notification - * \param actual_payload_size size of the notification data (excluding notification header) - * \return error if invalid target - */ -typedef AdspErrorCode (*SystemServiceSendNotificationMessageFct) ( - NotificationTarget notification_target, - AdspNotificationHandle message, - uint32_t actual_payload_size); - -typedef enum _AdspIfaceId { - IfaceIdGNA = 0x1000, /*!< Reserved for ADSP system */ - IfaceIdInferenceService = 0x1001, /*!< See InferenceServiceInterface */ - IfaceIdSDCA = 0x1002, /*!< See SdcaInterface */ - IfaceIdAsyncMessageService = 0x1003, /*!< See AsyncMessageInterface */ - IfaceIdAMService = 0x1005, /*!< Reserved for ADSP system */ - IfaceIdKpbService = 0x1006 /*!< See KpbInterface */ -} AdspIfaceId; - -/*! \brief sub interface definition. - * This type may contain generic interface properties like id or struct size if needed. - */ -typedef struct _SystemServiceIface {} SystemServiceIface; - -/*! \brief Defines prototype of the "GetInterface" function - * - * \param id service id - * \param iface pointer to retrieved interface - * \return error if service not supported - */ -typedef AdspErrorCode (*SystemServiceGetInterfaceFct) (AdspIfaceId id, SystemServiceIface **iface); - -/*! \brief The AdspSystemService is actually a set of C-function pointers gathered in a C-struct - * which brings some basic functionalities to module in runtime. - * - * The system service can be retrieved with help of either the - * intel_adsp::ProcessingModuleFactory::GetSystemService() method - * or the intel_adsp::ProcessingModule::GetSysstemService() method. - */ -typedef struct AdspSystemService { - /*! The SystemService::LogMessage function provides capability to send some log message to - * the host for debugging purposes. This log can be caught by the FDK Tools and displayed - * in the Debug window. The prototype of this function is given by the - * \ref SystemServiceLogMessageFct typedef. - * - * \remarks This service function is not expected to be called directly by the user code. - * Instead, the LOG_MESSAGE should be invoked for this purpose. - */ - const SystemServiceLogMessageFct LogMessage; - - /*! The SystemService::SafeMemcpy function provides capability to use SafeMemcpy function - * provided by ADSP System. - * The prototype of this function is given by the \ref SystemServiceSafeMemcpyFct typedef. - */ - const SystemServiceSafeMemcpyFct SafeMemcpy; - - /*! The SystemService::SafeMemmove function provides capability to use SafeMemmove function - * provided by ADSP System. - * The prototype of this function is given by the \ref SystemServiceSafeMemmoveFct typedef. - */ - const SystemServiceSafeMemmoveFct SafeMemmove; - - /*! The SystemService::VecMemset function provides capability to use VecMemset function - * provided by ADSP System. - * The prototype of this function is given by the \ref SystemServiceVecMemsetFct typedef. - */ - const SystemServiceVecMemsetFct VecMemset; - - /*! The SystemService::NotificationCreate function provides capability to use - * NotificationCreate function provided by ADSP System. - * The prototype of this function is given by the - * \ref SystemServiceCreateNotificationFct typedef. - */ - const SystemServiceCreateNotificationFct NotificationCreate; - - /*! The SystemService::NotificationSend function provides capability to use - * NotificationSend function provided by ADSP System. - * The prototype of this function is given by the \ref - * SystemServiceSendNotificationMessageFct typedef. - */ - const SystemServiceSendNotificationMessageFct NotificationSend; - - /*! The SystemService::GetInterface function provides capability to retrieve additional - * services provided by ADSP System. The prototype of this function is given by the \ref - * SystemServiceGetInterfaceFct typedef. - */ - const SystemServiceGetInterfaceFct GetInterface; - -} AdspSystemService; +typedef struct native_system_service_api AdspSystemService; #ifdef __cplusplus + namespace intel_adsp { /*! \brief Alias type of AdspSystemService which can be used in C++. diff --git a/src/include/sof/audio/module_adapter/library/native_system_agent.h b/src/include/sof/audio/module_adapter/library/native_system_agent.h new file mode 100644 index 000000000000..58def6ec67b6 --- /dev/null +++ b/src/include/sof/audio/module_adapter/library/native_system_agent.h @@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: BSD-3-Clause */ +/* + * Copyright(c) 2023 Intel Corporation. All rights reserved. + * + * Author: Pawel Dobrowolski + */ + +#ifndef __NATIVE_SYSTEM_AGENT_H__ +#define __NATIVE_SYSTEM_AGENT_H__ + +#include +#include + +struct native_system_agent { + struct native_system_service_api system_service; + uint32_t log_handle; + uint32_t core_id; + uint32_t module_id; + uint32_t instance_id; + uint32_t module_size; +}; + +void *native_system_agent_start(uint32_t *sys_service, + uint32_t entry_point, uint32_t module_id, uint32_t instance_id, + uint32_t core_id, uint32_t log_handle, void *mod_cfg); + +#endif /* __NATIVE_SYSTEM_AGENT_H__ */ diff --git a/src/include/sof/audio/module_adapter/library/native_system_service.h b/src/include/sof/audio/module_adapter/library/native_system_service.h new file mode 100644 index 000000000000..6007770e208f --- /dev/null +++ b/src/include/sof/audio/module_adapter/library/native_system_service.h @@ -0,0 +1,114 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * + * Copyright(c) 2023 Intel Corporation. All rights reserved. + */ +/*! \file native_system_service.h */ +#ifndef NATIVE_SYSTEM_SERVICE_H +#define NATIVE_SYSTEM_SERVICE_H +#include "logger.h" +#include "adsp_stddef.h" +#include "adsp_error_code.h" +#include + +/*! \brief This struct defines the obfuscating type for notifications. */ +typedef struct _adsp_notification_handle {} *adsp_notification_handle; + +/*! \brief Defines parameters used by ADSP system during notification creation. */ +typedef struct _notification_params { + uint32_t type; /*!< Notification type */ + uint16_t user_val_1; /*!< 16 bits user value available directly in IPC header + * for some notifications + */ + uint32_t user_val_2; /*!< 30 bits user value available directly in IPC header + * for some notifications + */ + uint32_t max_payload_size; /*!< Data size of payload (NotificationCreate updates this + * value to max possible payload size) + */ + uint8_t *payload; /*!< Pointer on the payload */ +} notification_params; + +/*! \brief Defines parameters used by ADSP system during Module Event notification creation. */ +typedef struct _module_event_notification { + uint32_t module_instance_id; /*!< Module ID (MS word) + Module Instance ID (LS word) */ + uint32_t event_id; /*!< Module specific event ID. */ + uint32_t event_data_size; /*!< Size of event_data array in bytes. May be set to 0 + * in case there is no data. + */ + uint32_t event_data[]; /*!< Optional event data (size set to 0 as it is optional + * data) + */ +} module_event_notification; + +/*! \brief Defines notification targets supported by ADSP system + * Legacy FW defines only two notification targets, HOST and ISH (Integrated Sensor Hub). + */ +typedef enum _notification_target { + NOTIFICATION_TARGET_DSP_TO_HOST = 1, /*!< Notification target is HOST */ + NOTIFICATION_TARGET_DSP_TO_ISH = 2 /*!< Notification target is ISH */ +} adsp_notification_target; + +/*! \brief Defines notification types supported by ADSP system + * Legacy FW uses reserves first 20 positions descibing types of notifications. + */ +typedef enum _notification_type { + NOTIFICATION_TYPE_VOICE_COMMAND_NOTIFICATION = 4, /*!< intel_adsp define + * corresponding to PHRASE_DETECTED + * notification + */ + NOTIFICATION_TYPE_AUDIO_CLASSIFIER_RESULTS = 9, /*!< intel_adsp define + * corresponding to + * FW_AUD_CLASS_RESULT notification + */ + NOTIFICATION_TYPE_MODULE_EVENT_NOTIFICATION = 12, /*!< intel_adsp define + * corresponding to + * MODULE_NOTIFICATION notification + */ +} notification_type; + +/*! \brief Defines extended interfaces for IADK modules*/ +typedef enum _adsp_iface_id { + INTERFACE_ID_GNA = 0x1000, /*!< Reserved for ADSP system */ + INTERFACE_ID_INFERENCE_SERVICE = 0x1001, /*!< See InferenceServiceInterface */ + INTERFACE_ID_SDCA = 0x1002, /*!< See SdcaInterface */ + INTERFACE_ID_ASYNC_MESSAGE_SERVICE = 0x1003, /*!< See AsyncMessageInterface */ + INTERFACE_ID_AM_SERVICE = 0x1005, /*!< Reserved for ADSP system */ + INTERFACE_ID_KPB_SERVICE = 0x1006 /*!< See KpbInterface */ +} adsp_iface_id; + +/*! \brief sub interface definition. + * This type may contain generic interface properties like id or struct size if needed. + */ +typedef struct _system_service_iface {} system_service_iface; + +/*! \brief Defines prototype of the "GetInterface" function + * + * \param id service id + * \param iface pointer to retrieved interface + * \return error if service not supported + */ + +struct native_system_service_api { + void (*log_message)(AdspLogPriority log_priority, uint32_t log_entry, + AdspLogHandle const *log_handle, uint32_t param1, + uint32_t param2, uint32_t param3, uint32_t param4); + + AdspErrorCode (*safe_memcpy)(void *RESTRICT dst, size_t maxlen, + const void *RESTRICT src, size_t len); + + AdspErrorCode (*safe_memmove)(void *dst, size_t maxlen, + const void *src, size_t len); + + void* (*vec_memset)(void *dst, int c, size_t len); + + AdspErrorCode (*notification_create)(notification_params *params, + uint8_t *notification_buffer, + uint32_t notification_buffer_size, + adsp_notification_handle *handle); + AdspErrorCode (*notification_send)(adsp_notification_target notification_target, + adsp_notification_handle message, + uint32_t actual_payload_size); + + AdspErrorCode (*get_interface)(adsp_iface_id id, system_service_iface **iface); +}; +#endif /*NATIVE_SYSTEM_SERVICE_H*/ diff --git a/src/include/sof/audio/module_adapter/module/generic.h b/src/include/sof/audio/module_adapter/module/generic.h index e6d89738e1e6..54c8172c4263 100644 --- a/src/include/sof/audio/module_adapter/module/generic.h +++ b/src/include/sof/audio/module_adapter/module/generic.h @@ -212,6 +212,9 @@ struct processing_module { */ bool stream_copy_single_to_single; + /* pointer to system services for loadable modules */ + uint32_t *sys_service; + /* table containing the list of connected sources */ struct module_source_info *source_info; diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt index ce81697cb89f..6b991b4728d5 100644 --- a/zephyr/CMakeLists.txt +++ b/zephyr/CMakeLists.txt @@ -586,14 +586,16 @@ zephyr_library_sources_ifdef(CONFIG_LIBRARY_MANAGER zephyr_include_directories_ifdef(CONFIG_INTEL_MODULES ${SOF_SRC_PATH}/include/sof/audio/module_adapter/iadk/ + ${SOF_SRC_PATH}/include/sof/audio/module_adapter/library/ ) zephyr_library_sources_ifdef(CONFIG_INTEL_MODULES - ${SOF_AUDIO_PATH}/module_adapter/module/iadk_modules.c - ${SOF_AUDIO_PATH}/module_adapter/iadk/system_service.c + ${SOF_AUDIO_PATH}/module_adapter/module/modules.c ${SOF_AUDIO_PATH}/module_adapter/iadk/module_initial_settings_concrete.cpp ${SOF_AUDIO_PATH}/module_adapter/iadk/iadk_module_adapter.cpp ${SOF_AUDIO_PATH}/module_adapter/iadk/system_agent.cpp + ${SOF_AUDIO_PATH}/module_adapter/library/native_system_agent.c + ${SOF_AUDIO_PATH}/module_adapter/library/native_system_service.c ) if (CONFIG_COMP_MODULE_ADAPTER)