xref: /rk3399_ARM-atf/services/std_svc/rmmd/rmmd_private.h (revision 06f3c7058c42a9f1a9f7df75ea2de71a000855e8)
1 /*
2  * Copyright (c) 2021-2025, Arm Limited and Contributors. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #ifndef RMMD_PRIVATE_H
8 #define RMMD_PRIVATE_H
9 
10 #include <context.h>
11 #include <services/rmmd_svc.h>
12 
13 /*******************************************************************************
14  * Constants that allow assembler code to preserve callee-saved registers of the
15  * C runtime context while performing a security state switch.
16  ******************************************************************************/
17 #define RMMD_C_RT_CTX_X19		0x0
18 #define RMMD_C_RT_CTX_X20		0x8
19 #define RMMD_C_RT_CTX_X21		0x10
20 #define RMMD_C_RT_CTX_X22		0x18
21 #define RMMD_C_RT_CTX_X23		0x20
22 #define RMMD_C_RT_CTX_X24		0x28
23 #define RMMD_C_RT_CTX_X25		0x30
24 #define RMMD_C_RT_CTX_X26		0x38
25 #define RMMD_C_RT_CTX_X27		0x40
26 #define RMMD_C_RT_CTX_X28		0x48
27 #define RMMD_C_RT_CTX_X29		0x50
28 #define RMMD_C_RT_CTX_X30		0x58
29 
30 #define RMMD_C_RT_CTX_SIZE		0x60
31 #define RMMD_C_RT_CTX_ENTRIES		(RMMD_C_RT_CTX_SIZE >> DWORD_SHIFT)
32 
33 #ifndef __ASSEMBLER__
34 #include <stdint.h>
35 
36 /*
37  * Data structure used by the RMM dispatcher (RMMD) in EL3 to track context of
38  * the RMM at R-EL2.
39  */
40 typedef struct rmmd_rmm_context {
41 	uint64_t c_rt_ctx;
42 	cpu_context_t cpu_ctx;
43 } rmmd_rmm_context_t;
44 
45 /* Functions used to enter/exit the RMM synchronously */
46 uint64_t rmmd_rmm_sync_entry(rmmd_rmm_context_t *ctx);
47 __dead2 void rmmd_rmm_sync_exit(uint64_t rc);
48 
49 /* Functions implementing attestation utilities for RMM */
50 int rmmd_attest_get_platform_token(uint64_t buf_pa, uint64_t *buf_size,
51 				   uint64_t c_size,
52 				   uint64_t *remaining_len);
53 int rmmd_attest_get_signing_key(uint64_t buf_pa, uint64_t *buf_size,
54 				uint64_t ecc_curve);
55 uint64_t rmmd_el3_token_sign(void *handle, uint64_t x1, uint64_t x2,
56 				    uint64_t x3, uint64_t x4);
57 
58 /* Functions implementing IDE KM programming */
59 int rmmd_el3_ide_key_program(uint64_t ecam_address, uint64_t rp_id,
60 			     uint64_t ide_stream_info, rp_ide_key_info_t *ide_key_info_ptr,
61 			     uint64_t request_id, uint64_t cookie);
62 int rmmd_el3_ide_key_set_go(uint64_t ecam_address, uint64_t rp_id, uint64_t ide_stream_info,
63 			    uint64_t request_id, uint64_t cookie);
64 int rmmd_el3_ide_key_set_stop(uint64_t ecam_address, uint64_t rp_id, uint64_t ide_stream_info,
65 			      uint64_t request_id, uint64_t cookie);
66 int rmmd_el3_ide_km_pull_response(uint64_t ecam_address, uint64_t rp_id, uint64_t *req_resp,
67 				  uint64_t *request_id, uint64_t *cookie_ptr);
68 
69 /* Assembly helpers */
70 uint64_t rmmd_rmm_enter(uint64_t *c_rt_ctx);
71 void __dead2 rmmd_rmm_exit(uint64_t c_rt_ctx, uint64_t ret);
72 
73 /* Reference to PM ops for the RMMD */
74 extern const spd_pm_ops_t rmmd_pm;
75 
76 #endif /* __ASSEMBLER__ */
77 
78 #endif /* RMMD_PRIVATE_H */
79