microsoft/mu_feature_ffa

Public

mirrored fromhttps://github.com/microsoft/mu_feature_ffaAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
2d8ac10050d373d1c4b45aea63f17d763a4fc3f0

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

FfaFeaturePkg/Include/Library/ArmFfaLibEx.h

475lines · modecode

1/** @file
2 Platform layer for the secure partition interrupt handler using FF-A.
3
4 Copyright (c) 2020 - 2022, Arm Ltd. All rights reserved.<BR>
5 Copyright (c), Microsoft Corporation.
6 SPDX-License-Identifier: BSD-2-Clause-Patent
7
8**/
9
10#ifndef FF_A_HELPER_LIB_H_
11#define FF_A_HELPER_LIB_H_
12
13#include <Base.h>
14
15#if PcdGetBool (PcdFfaLibConduitSmc) == 1
16typedef ARM_SMC_ARGS ARM_SXC_ARGS;
17#else
18typedef ARM_SVC_ARGS ARM_SXC_ARGS;
19#endif
20
21/**
22 * @brief Direct message type
23 */
24typedef struct {
25 UINT32 FunctionId;
26
27 UINT16 SourceId;
28
29 UINT16 DestinationId;
30
31 /// Not applicable for v1
32 EFI_GUID ServiceGuid;
33
34 /// Implementation define argument 0, this will be set to/from x4(v2)
35 UINTN Arg0;
36
37 /// Implementation define argument 1, this will be set to/from x5(v2)
38 UINTN Arg1;
39
40 /// Implementation define argument 2, this will be set to/from x6(v2)
41 UINTN Arg2;
42
43 /// Implementation define argument 3, this will be set to/from x7(v2)
44 UINTN Arg3;
45
46 /// Implementation define argument 4, this will be set to/from x8(v2)
47 UINTN Arg4;
48
49 /// Implementation define argument 5, this will be set to/from x9(v2)
50 UINTN Arg5;
51
52 /// Implementation define argument 6, this will be set to/from x10(v2)
53 UINTN Arg6;
54
55 /// Implementation define argument 7, this will be set to/from x11(v2)
56 UINTN Arg7;
57
58 /// Implementation define argument 8, this will be set to/from x12(v2)
59 UINTN Arg8;
60
61 /// Implementation define argument 9, this will be set to/from x13(v2)
62 UINTN Arg9;
63
64 /// Implementation define argument 10, this will be set to/from x14(v2)
65 UINTN Arg10;
66
67 /// Implementation define argument 11, this will be set to/from x15(v2)
68 UINTN Arg11;
69
70 /// Implementation define argument 12, this will be set to/from x16(v2)
71 UINTN Arg12;
72
73 /// Implementation define argument 13, this will be set to/from x17(v2)
74 UINTN Arg13;
75} DIRECT_MSG_ARGS_EX;
76
77/**
78 * CPU cycle management interfaces
79 */
80
81/**
82 * @brief Blocks the caller until a message is available or until an
83 * interrupt happens. It is also used to indicate the completion of
84 * the boot phase and the end of the interrupt handling.
85 * @note The ffa_interrupt_handler function can be called during the
86 * execution of this function.
87 *
88 * @param[out] msg The incoming message
89 *
90 * @return The FF-A error status code
91 */
92EFI_STATUS
93EFIAPI
94FfaMessageWait (
95 OUT DIRECT_MSG_ARGS_EX *Message
96 );
97
98/** Messaging interfaces */
99
100/**
101 * @brief Sends a 32 bit partition message in parameter registers as a
102 * request and blocks until the response is available.
103 * @note The ffa_interrupt_handler function can be called during the
104 * execution of this function
105 *
106 * @param[in] source Source endpoint ID
107 * @param[in] dest Destination endpoint ID
108 * @param[in] a0,a1,a2,a3,a4 Implementation defined message values
109 * @param[out] msg The response message
110 *
111 * @return The FF-A error status code
112 */
113EFI_STATUS
114EFIAPI
115FfaMessageSendDirectReq2 (
116 IN UINT16 DestPartId,
117 IN EFI_GUID *ServiceGuid OPTIONAL,
118 IN OUT DIRECT_MSG_ARGS_EX *ImpDefArgs
119 );
120
121/**
122 * @brief Sends a 32 bit partition message in parameter registers as a
123 * response and blocks until the response is available.
124 * @note The ffa_interrupt_handler function can be called during the
125 * execution of this function
126 *
127 * @param[in] source Source endpoint ID
128 * @param[in] dest Destination endpoint ID
129 * @param[in] a0,a1,a2,a3,a4 Implementation defined message values
130 * @param[out] msg The response message
131 *
132 * @return The FF-A error status code
133 */
134EFI_STATUS
135EFIAPI
136FfaMessageSendDirectResp32 (
137 DIRECT_MSG_ARGS_EX *req,
138 DIRECT_MSG_ARGS_EX *resp
139 );
140
141/**
142 * @brief Sends a 64 bit partition message in parameter registers as a
143 * response and blocks until the response is available.
144 * @note The ffa_interrupt_handler function can be called during the
145 * execution of this function
146 *
147 * @param[in] source Source endpoint ID
148 * @param[in] dest Destination endpoint ID
149 * @param[in] a0,a1,a2,a3,a4 Implementation defined message values
150 * @param[out] msg The response message
151 *
152 * @return The FF-A error status code
153 */
154EFI_STATUS
155EFIAPI
156FfaMessageSendDirectResp64 (
157 IN DIRECT_MSG_ARGS_EX *Request,
158 OUT DIRECT_MSG_ARGS_EX *Response
159 );
160
161EFI_STATUS
162EFIAPI
163FfaMessageSendDirectResp2 (
164 IN DIRECT_MSG_ARGS_EX *Request,
165 OUT DIRECT_MSG_ARGS_EX *Response
166 );
167
168EFI_STATUS
169EFIAPI
170FfaNotificationSet (
171 IN UINT16 DestinationId,
172 IN UINT64 Flags,
173 IN UINT64 NotificationBitmap
174 );
175
176EFI_STATUS
177EFIAPI
178FfaNotificationGet (
179 IN UINT16 VCpuId,
180 IN UINT64 Flags,
181 IN UINT64 *NotificationBitmap
182 );
183
184EFI_STATUS
185EFIAPI
186FfaPartitionInfoGetRegs (
187 IN EFI_GUID *ServiceGuid,
188 IN UINT16 StartIndex,
189 IN OUT UINT16 *Tag OPTIONAL,
190 IN OUT UINT32 *PartDescCount,
191 OUT EFI_FFA_PART_INFO_DESC *PartDesc OPTIONAL
192 );
193
194EFI_STATUS
195EFIAPI
196FfaNotificationBitmapCreate (
197 IN UINT16 VCpuCount
198 );
199
200EFI_STATUS
201EFIAPI
202FfaNotificationBitmapDestroy (
203 VOID
204 );
205
206EFI_STATUS
207EFIAPI
208FfaNotificationBind (
209 IN UINT16 DestinationId,
210 IN UINT32 Flags,
211 IN UINT64 NotificationBitmap
212 );
213
214EFI_STATUS
215EFIAPI
216FfaNotificationUnbind (
217 IN UINT16 DestinationId,
218 IN UINT64 NotificationBitmap
219 );
220
221/**
222 * Memory management interfaces
223 *
224 * @note Functions with _rxtx suffix use the RX/TX buffers mapped by
225 * ffa_rxtx_map to transmit memory descriptors instead of an distinct buffer
226 * allocated by the owner.
227 */
228
229/**
230 * @brief Starts a transaction to transfer of ownership of a memory region
231 * from a Sender endpoint to a Receiver endpoint.
232 *
233 * @param[in] total_length Total length of the memory transaction
234 * descriptor in bytes
235 * @param[in] fragment_length Length in bytes of the memory transaction
236 * descriptor passed in this ABI invocation
237 * @param[in] buffer_address Base address of a buffer allocated by the Owner
238 * and distinct from the TX buffer
239 * @param[in] page_count Number of 4K pages in the buffer allocated by
240 * the Owner and distinct from the TX buffer
241 * @param[out] handle Globally unique Handle to identify the memory
242 * region upon successful transmission of the
243 * transaction descriptor.
244 *
245 * @return The FF-A error status code
246 */
247EFI_STATUS
248ffa_mem_donate (
249 UINT32 total_length,
250 UINT32 fragment_length,
251 VOID *buffer_address,
252 UINT32 page_count,
253 UINT64 *handle
254 );
255
256EFI_STATUS
257ffa_mem_donate_rxtx (
258 UINT32 total_length,
259 UINT32 fragment_length,
260 UINT64 *handle
261 );
262
263/**
264 * @brief Starts a transaction to transfer an Owner’s access to a memory
265 * region and grant access to it to one or more Borrowers.
266 *
267 * @param[in] total_length Total length of the memory transaction
268 * descriptor in bytes
269 * @param[in] fragment_length Length in bytes of the memory transaction
270 * descriptor passed in this ABI invocation
271 * @param[in] buffer_address Base address of a buffer allocated by the Owner
272 * and distinct from the TX buffer
273 * @param[in] page_count Number of 4K pages in the buffer allocated by
274 * the Owner and distinct from the TX buffer
275 * @param[out] handle Globally unique Handle to identify the memory
276 * region upon successful transmission of the
277 * transaction descriptor.
278 *
279 * @return The FF-A error status code
280 */
281EFI_STATUS
282EFIAPI
283FfaMemLend (
284 UINT32 TotalLength,
285 UINT32 FragmentLength,
286 VOID *BufferAddr,
287 UINT32 PageCount,
288 UINT64 *Handle
289 );
290
291EFI_STATUS
292EFIAPI
293FfaMemLendRxTx (
294 UINT32 TotalLength,
295 UINT32 FragmentLength,
296 UINT64 *Handle
297 );
298
299/**
300 * @brief Starts a transaction to grant access to a memory region to one or
301 * more Borrowers.
302 *
303 * @param[in] total_length Total length of the memory transaction
304 * descriptor in bytes
305 * @param[in] fragment_length Length in bytes of the memory transaction
306 * descriptor passed in this ABI invocation
307 * @param[in] buffer_address Base address of a buffer allocated by the Owner
308 * and distinct from the TX buffer
309 * @param[in] page_count Number of 4K pages in the buffer allocated by
310 * the Owner and distinct from the TX buffer
311 * @param[out] handle Globally unique Handle to identify the memory
312 * region upon successful transmission of the
313 * transaction descriptor.
314 *
315 * @return The FF-A error status code
316 */
317EFI_STATUS
318EFIAPI
319FfaMemShare (
320 UINT32 TotalLength,
321 UINT32 FragmentLength,
322 VOID *BufferAddr,
323 UINT32 PageCount,
324 UINT64 *Handle
325 );
326
327EFI_STATUS
328EFIAPI
329FfaMemShareRxTx (
330 UINT32 TotalLength,
331 UINT32 FragmentLength,
332 UINT64 *Handle
333 );
334
335/**
336 * @brief Requests completion of a donate, lend or share memory management
337 * transaction.
338 *
339 * @param[in] total_length Total length of the memory transaction
340 * descriptor in bytes
341 * @param[in] fragment_length Length in bytes of the memory transaction
342 * descriptor passed in this ABI invocation
343 * @param[in] buffer_address Base address of a buffer allocated by the
344 * Owner and distinct from the TX buffer
345 * @param[in] page_count Number of 4K pages in the buffer allocated
346 * by the Owner and distinct from the TX
347 * buffer
348 * @param[out] resp_total_length Total length of the response memory
349 * transaction descriptor in bytes
350 * @param[out] resp_fragment_length Length in bytes of the response memory
351 * transaction descriptor passed in this ABI
352 * invocation
353 *
354 * @return The FF-A error status code
355 */
356EFI_STATUS
357EFIAPI
358FfaMemRetrieveReq (
359 UINT32 TotalLength,
360 UINT32 FragmentLength,
361 VOID *BufferAddr,
362 UINT32 PageCount,
363 UINT32 *RespTotalLength,
364 UINT32 *RespFragmentLength
365 );
366
367EFI_STATUS
368EFIAPI
369FfaMemRetrieveReqRxTx (
370 UINT32 TotalLength,
371 UINT32 FragmentLength,
372 UINT32 *RespTotalLength,
373 UINT32 *RespFragmentLength
374 );
375
376/**
377 * @brief Starts a transaction to transfer access to a shared or lent
378 * memory region from a Borrower back to its Owner.
379 *
380 * @return The FF-A error status code
381 */
382EFI_STATUS
383EFIAPI
384FfaMemRelinquish (
385 VOID
386 );
387
388/**
389 * @brief Restores exclusive access to a memory region back to its Owner.
390 *
391 * @param[in] handle Globally unique Handle to identify the memory region
392 * @param[in] flags Flags for modifying the reclaim behavior
393 *
394 * @return The FF-A error status code
395 */
396EFI_STATUS
397EFIAPI
398FfaMemReclaim (
399 UINT64 Handle,
400 UINT32 Flags
401 );
402
403/**
404 * @brief Queries the memory attributes of a memory region. This function
405 * can only access the regions of the SP's own translation regine.
406 * Moreover this interface is only available in the boot phase,
407 * i.e. before invoking FFA_MSG_WAIT interface.
408 *
409 * @param[in] base_address Base VA of a translation granule whose
410 * permission attributes must be returned.
411 * @param[out] mem_perm Permission attributes of the memory region
412 *
413 * @return The FF-A error status code
414 */
415EFI_STATUS
416EFIAPI
417FfaMemPermGet (
418 CONST VOID *BaseAddr,
419 UINT32 *MemoryPerm
420 );
421
422/**
423 * @brief Sets the memory attributes of a memory regions. This function
424 * can only access the regions of the SP's own translation regine.
425 * Moreover this interface is only available in the boot phase,
426 * i.e. before invoking FFA_MSG_WAIT interface.
427 *
428 * @param[in] base_address Base VA of a memory region whose permission
429 * attributes must be set.
430 * @param[in] page_count Number of translation granule size pages
431 * starting from the Base address whose permissions
432 * must be set.
433 * @param[in] mem_perm Permission attributes to be set for the memory
434 * region
435 * @return The FF-A error status code
436 */
437EFI_STATUS
438EFIAPI
439FfaMemPermSet (
440 CONST VOID *BaseAddr,
441 UINT32 PageCount,
442 UINT32 MemoryPerm
443 );
444
445/**
446 * @brief Allow an entity to provide debug logging to the console. Uses
447 * 32 bit registers to pass characters.
448 *
449 * @param message Message characters
450 * @param length Message length, max FFA_CONSOLE_LOG_32_MAX_LENGTH
451 * @return The FF-A error status code
452 */
453EFI_STATUS
454EFIAPI
455FfaConsoleLog32 (
456 CONST CHAR8 *Message,
457 UINTN Length
458 );
459
460/**
461 * @brief Allow an entity to provide debug logging to the console. Uses
462 * 64 bit registers to pass characters.
463 *
464 * @param message Message characters
465 * @param length Message length, max FFA_CONSOLE_LOG_64_MAX_LENGTH
466 * @return The FF-A error status code
467 */
468EFI_STATUS
469EFIAPI
470FfaConsoleLog64 (
471 CONST char *Message,
472 UINTN Length
473 );
474
475#endif /* FF_A_HELPER_LIB_H_ */
476