forked from thesofproject/sof
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 <[email protected]>
- Loading branch information
1 parent
e2ad42f
commit 2cdf38c
Showing
9 changed files
with
244 additions
and
253 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
/* | ||
* Copyright(c) 2023 Intel Corporation. All rights reserved. | ||
* | ||
* Author: Pawel Dobrowolski <[email protected]> | ||
*/ | ||
|
||
#include <stdbool.h> | ||
#include <stdint.h> | ||
#include <utilities/array.h> | ||
#include <native_system_agent.h> | ||
|
||
/* 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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,28 @@ | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
// | ||
// Copyright(c) 2020 Intel Corporation. All rights reserved. | ||
// | ||
// Author: Jaroslaw Stelter <[email protected]> | ||
|
||
/* | ||
* System Service interface for ADSP loadable library. | ||
* Copyright(c) 2020 Intel Corporation. All rights reserved. | ||
* | ||
* Author: Jaroslaw Stelter <[email protected]> | ||
*/ | ||
/* | ||
* Native System Service interface for ADSP loadable library. | ||
*/ | ||
|
||
#include <errno.h> | ||
#include <stdbool.h> | ||
#include <stdint.h> | ||
#include <sof/common.h> | ||
#include <rtos/sof.h> | ||
#include <rtos/string.h> | ||
#include <ipc4/notification.h> | ||
#include <sof/ipc/msg.h> | ||
#include <adsp_error_code.h> | ||
#include <system_service.h> | ||
#include <native_system_service.h> | ||
#include <sof/lib_manager.h> | ||
|
||
#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 | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.