blob: 1fbcd31be8f067be99bf999a4856c4743fc5ae50 [file] [log] [blame]
Zelalem Aweke77c27752021-07-09 14:20:03 -05001/*
Sona Mathew2132c702025-03-14 01:27:11 -05002 * Copyright (c) 2021-2025, Arm Limited and Contributors. All rights reserved.
Zelalem Aweke77c27752021-07-09 14:20:03 -05003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#ifndef RMMD_PRIVATE_H
8#define RMMD_PRIVATE_H
9
10#include <context.h>
Sona Mathew2132c702025-03-14 01:27:11 -050011#include <services/rmmd_svc.h>
Zelalem Aweke77c27752021-07-09 14:20:03 -050012
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>
Zelalem Aweke77c27752021-07-09 14:20:03 -050035
Zelalem Aweke77c27752021-07-09 14:20:03 -050036/*
37 * Data structure used by the RMM dispatcher (RMMD) in EL3 to track context of
38 * the RMM at R-EL2.
39 */
40typedef struct rmmd_rmm_context {
41 uint64_t c_rt_ctx;
42 cpu_context_t cpu_ctx;
Zelalem Aweke77c27752021-07-09 14:20:03 -050043} rmmd_rmm_context_t;
44
45/* Functions used to enter/exit the RMM synchronously */
46uint64_t rmmd_rmm_sync_entry(rmmd_rmm_context_t *ctx);
47__dead2 void rmmd_rmm_sync_exit(uint64_t rc);
48
Soby Mathew0f9159b2022-03-22 16:19:39 +000049/* Functions implementing attestation utilities for RMM */
Javier Almansa Sobrinodc65ae42022-04-13 17:57:35 +010050int rmmd_attest_get_platform_token(uint64_t buf_pa, uint64_t *buf_size,
Juan Pablo Conde42cf6022024-07-10 14:33:42 -050051 uint64_t c_size,
52 uint64_t *remaining_len);
Javier Almansa Sobrinodc65ae42022-04-13 17:57:35 +010053int rmmd_attest_get_signing_key(uint64_t buf_pa, uint64_t *buf_size,
54 uint64_t ecc_curve);
Raghu Krishnamurthy6a88ec82024-06-03 19:02:29 -070055uint64_t rmmd_el3_token_sign(void *handle, uint64_t x1, uint64_t x2,
56 uint64_t x3, uint64_t x4);
Soby Mathew0f9159b2022-03-22 16:19:39 +000057
Sona Mathew2132c702025-03-14 01:27:11 -050058/* Functions implementing IDE KM programming */
59int 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);
62int 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);
64int 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);
66int 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
Zelalem Aweke77c27752021-07-09 14:20:03 -050069/* Assembly helpers */
70uint64_t rmmd_rmm_enter(uint64_t *c_rt_ctx);
71void __dead2 rmmd_rmm_exit(uint64_t c_rt_ctx, uint64_t ret);
72
73/* Reference to PM ops for the RMMD */
74extern const spd_pm_ops_t rmmd_pm;
75
76#endif /* __ASSEMBLER__ */
77
78#endif /* RMMD_PRIVATE_H */