forked from thesofproject/sof
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlib_manager.h
More file actions
193 lines (175 loc) · 8.54 KB
/
lib_manager.h
File metadata and controls
193 lines (175 loc) · 8.54 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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
/* SPDX-License-Identifier: BSD-3-Clause
*
* Copyright(c) 2022 Intel Corporation. All rights reserved.
*
* Author: Jaroslaw Stelter <jaroslaw.stelter@intel.com>
* Pawel Dobrowolski <pawelx.dobrowolski@intel.com>
*/
/*
* Library manager implementation for SOF is using module adapter API for
* loadable native and external libraries. Depends of information received from
* it manages memory and locate accordingly to available space.
*
* Driver IPC4 Library MEMORY ENTITY
* Handler Manager VERIF.
* | | | | |
* | IPC4_GLB_LOAD_LIBRARY | | | |
* | --------------------> | lib_manager_load_library() | | |
* | | -------------------------> | Prepare DMA transfer | |
* | | | ------- | |
* | | | | | |
* | | | <------ | |
* | | | -----------------------> | |
* | | | | |
* | | | (IF AUTH_API_ENABLED) | |
* | | | Verify Manifest | |
* | | | -------------------------|-------> |
* | | | results | |
* | | | <------------------------|-------- |
* | | | (IF AUTH_API_ENABLED) | |
* | | | | |
* | | | Parse Manifest | |
* | | | Prepare Storage Memory | |
* | | | ------- | |
* | | | | | |
* | | | <------ | |
* | | | | |
* | | | Copy Library Data | |
* | | | -----------------------> | |
* | | | | |
* | | | (IF AUTH_API_ENABLED) | |
* | | | Verify Manifest | |
* | | | -------------------------|-------> |
* | | | results | |
* | | | <------------------------|-------- |
* | | | (IF AUTH_API_ENABLED) | |
* | | | | |
* | | | Update Library | |
* | | | descriptors table | |
* | | | ------- | |
* | | | | | |
* | | | <------ | |
* | | return status | | |
* | | <------------------------- | | |
* | Complete IPC request | | | |
* | <------------------- | | | |
*
* Driver IPC4 Library MEMORY ENTITY
* Handler Manager VERIF.
*/
#ifndef __SOF_LIB_MANAGER_H__
#define __SOF_LIB_MANAGER_H__
#include <stdint.h>
#include <rimage/manifest.h>
#define LIB_MANAGER_MAX_LIBS 16
#define LIB_MANAGER_LIB_ID_SHIFT 12
#define LIB_MANAGER_LIB_NOTIX_MAX_COUNT 4
#define LIB_MANAGER_GET_LIB_ID(module_id) ((module_id) >> LIB_MANAGER_LIB_ID_SHIFT)
#define LIB_MANAGER_GET_MODULE_INDEX(module_id) ((module_id) & 0xFFF)
#ifdef CONFIG_LIBRARY_MANAGER
struct ipc_lib_msg {
struct ipc_msg *msg;
struct list_item list;
};
struct ext_library {
struct k_spinlock lock; /* last locking CPU record */
struct sof_man_fw_desc *desc[LIB_MANAGER_MAX_LIBS];
uint32_t mods_exec_load_cnt;
struct ipc_lib_msg *lib_notif_pool;
uint32_t lib_notif_count;
};
/* lib manager context, used by lib_notification */
extern struct tr_ctx lib_manager_tr;
static inline struct ext_library *ext_lib_get(void)
{
return sof_get()->ext_library;
}
#endif
/*
* \brief Initialize library manager
*/
void lib_manager_init(void);
/*
* \brief Register module on driver list
*
* param[in] desc - library manifest descriptor
* param[in] module_id - used to get manifest offset for module
*
* Creates new comp_driver_info and initialize it for module from library
* Adds new module to sof_get()->comp_drivers list
*/
int lib_manager_register_module(struct sof_man_fw_desc *desc, int module_id);
/*
* \brief Get library module manifest descriptor
*
* param[in] module_id - used to get text manifest offset
*
* Gets firmware manifest descriptor using module_id to locate it
*/
struct sof_man_fw_desc *lib_manager_get_library_module_desc(int module_id);
/*
* \brief Allocate module
*
* param[in] drv - component driver
* param[in] ipc_config - audio component base configuration from IPC at creation
* param[in] ipc_specific_config - ipc4 base configuration
*
* Function is responsible to allocate module in available free memory and assigning proper address.
* (WIP) These feature will contain module validation and proper memory management.
*/
uint32_t lib_manager_allocate_module(const struct comp_driver *drv,
struct comp_ipc_config *ipc_config,
const void *ipc_specific_config);
/*
* \brief Free module
*
* param[in] drv - component driver
* param[in] ipc_config - audio component base configuration from IPC at creation
* param[in] ipc_specific_config - ipc4 base configuration
*
* Function is responsible to free module resources in HP memory.
*/
int lib_manager_free_module(const struct comp_driver *drv,
struct comp_ipc_config *ipc_config);
/*
* \brief Load library
*
* param[in] dma_id - channel used to transfer binary from host
* param[in] lib_id
*
* Function will load library manifest into temporary buffer.
* Then it will read library parameters, allocate memory for library and load it into
* destination memory region.
*/
int lib_manager_load_library(uint32_t dma_id, uint32_t lib_id);
/*
* \brief Initialize message
*
* param[in] header - IPC header provided by caller
* param[in] size - size of data buffer for messege to be send
*
* Function search lib_notif_pool for free message handler.
* If not found allocates new message handle and returns it to
* caller.
*/
struct ipc_msg *lib_notif_msg_init(uint32_t header, uint32_t size);
/*
* \brief Send message
*
* param[in] msg - IPC message handler
*
* Function sends IPC message and calls lib_notif_msg_clean() to
* free unused message handlers. Only single message handle will
* be kept in list while at least one loadable module is loaded.
*/
void lib_notif_msg_send(struct ipc_msg *msg);
/*
* \brief Clean unused message handles
*
* param[in] leave_one_handle - remove all unused or keep one
*
* Function search lib_notif_pool list for unused message handles.
* Remove them keeping one if leave_one_handle == true.
*/
void lib_notif_msg_clean(bool leave_one_handle);
#endif /* __SOF_LIB_MANAGER_H__ */