forked from thesofproject/sof
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsystem_agent.cpp
More file actions
177 lines (147 loc) · 5.49 KB
/
system_agent.cpp
File metadata and controls
177 lines (147 loc) · 5.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
// SPDX-License-Identifier: BSD-3-Clause
//
// Copyright(c) 2020 Intel Corporation. All rights reserved.
//
// Author: Jaroslaw Stelter <jaroslaw.stelter@linux.intel.com>
/*
* SOF System Agent - register IADK Loadable Library in SOF infrastructure.
*/
#include <errno.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <rtos/string.h>
#include <utilities/array.h>
#include <module/iadk/adsp_error_code.h>
#include <logger.h>
#include <native_system_service.h>
#include <system_agent_interface.h>
#include <module_initial_settings_concrete.h>
#include <iadk_module_adapter.h>
#include <system_agent.h>
using namespace intel_adsp;
using namespace intel_adsp::system;
using namespace dsp_fw;
void* operator new(size_t size, intel_adsp::ModuleHandle *placeholder) throw()
{
return placeholder;
}
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);
AdspErrorCode native_system_service_safe_memcpy(void *RESTRICT dst, size_t maxlen,
const void *RESTRICT src, size_t len);
AdspErrorCode native_system_service_safe_memmove(void *dst, size_t maxlen,
const void *src, size_t len);
void *native_system_service_vec_memset(void *dst, int c, size_t len);
AdspErrorCode native_system_service_create_notification(notification_params *params,
uint8_t *notification_buffer,
uint32_t notification_buffer_size,
adsp_notification_handle *handle);
AdspErrorCode native_system_service_send_notif_msg(adsp_notification_target notification_target,
adsp_notification_handle message,
uint32_t actual_payload_size);
AdspErrorCode native_system_service_get_interface(adsp_iface_id id, system_service_iface **iface);
}
namespace intel_adsp
{
namespace system
{
/* Structure storing handles to system service operations */
AdspSystemService SystemAgent::system_service_ = {
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,
uint32_t instance_id,
uint32_t core_id,
uint32_t log_handle) :
log_handle_(log_handle),
core_id_(core_id),
module_id_(module_id),
instance_id_(instance_id),
module_handle_(NULL),
module_size_(0)
{}
void SystemAgent::CheckIn(ProcessingModuleInterface& processing_module,
ModuleHandle &module_handle,
LogHandle *&log_handle)
{
module_handle_ = &module_handle;
/* Initializes the ModuleAdapter into the ModuleHandle */
IadkModuleAdapter* module_adapter =
new (module_handle_)IadkModuleAdapter(processing_module,
NULL,
module_id_,
instance_id_,
core_id_,
module_size_
);
(void)module_adapter;
log_handle = reinterpret_cast<LogHandle*>(log_handle_);
}
int SystemAgent::CheckIn(ProcessingModuleFactoryInterface& module_factory,
ModulePlaceholder *module_placeholder,
size_t processing_module_size,
uint32_t core_id,
const void *obfuscated_mod_cfg,
void *obfuscated_parent_ppl,
void **obfuscated_modinst_p)
{
IoPinsInfo pins_info;
const dsp_fw::DwordArray& cfg_ipc_msg =
*reinterpret_cast<const dsp_fw::DwordArray*>(obfuscated_mod_cfg);
ModuleInitialSettingsConcrete settings(cfg_ipc_msg);
ProcessingModulePrerequisites prerequisites;
module_factory.GetPrerequisites(prerequisites);
/* Note: If module has no output pins, it requires HungryRTSink */
/* to terminate parent Pipeline */
const bool hungry_rt_sink_required = prerequisites.output_pins_count == 0;
if (hungry_rt_sink_required) prerequisites.output_pins_count = 1;
if ((prerequisites.input_pins_count < 1) ||
(prerequisites.input_pins_count > INPUT_PIN_COUNT) ||
(prerequisites.output_pins_count < 1) ||
(prerequisites.output_pins_count > OUTPUT_PIN_COUNT))
return -1;
/* Deduce BaseModuleCfgExt if it was not part of the INIT_INSTANCE IPC message */
settings.DeduceBaseModuleCfgExt(prerequisites.input_pins_count,
prerequisites.output_pins_count);
module_factory.Create(*this, module_placeholder, ModuleInitialSettings(settings), pins_info);
IadkModuleAdapter& module_adapter = *reinterpret_cast<IadkModuleAdapter*>(module_handle_);
*obfuscated_modinst_p = &module_adapter;
reinterpret_cast<intel_adsp::ProcessingModuleInterface*>(module_placeholder)->Init();
return 0;
}
} /* namespace system */
} /* namespace intel_adsp */
#ifdef __cplusplus
extern "C" {
#endif
/* The create_instance_f is a function call type known in IADK module. The module entry_point
* points to this type of function which starts module creation.
*/
typedef int (*create_instance_f)(uint32_t module_id, uint32_t instance_id, uint32_t core_id,
void *mod_cfg, void *parent_ppl, void **mod_ptr);
void* system_agent_start(uint32_t entry_point, uint32_t module_id, uint32_t instance_id,
uint32_t core_id, uint32_t log_handle, void* mod_cfg)
{
uint32_t ret;
SystemAgent system_agent(module_id, instance_id, core_id, log_handle);
void* system_agent_p = reinterpret_cast<void*>(&system_agent);
create_instance_f ci = (create_instance_f)(entry_point);
ret = ci(module_id, instance_id, core_id, mod_cfg, NULL, &system_agent_p);
return system_agent_p;
}
#ifdef __cplusplus
}
#endif
extern "C" void __cxa_pure_virtual() __attribute__((weak));
void __cxa_pure_virtual()
{
}