Zelalem Aweke | 13dc8f1 | 2021-07-09 14:20:03 -0500 | [diff] [blame] | 1 | /* |
Soby Mathew | 68ea954 | 2022-03-22 13:58:52 +0000 | [diff] [blame] | 2 | * Copyright (c) 2021-2022, ARM Limited and Contributors. All rights reserved. |
Zelalem Aweke | 13dc8f1 | 2021-07-09 14:20:03 -0500 | [diff] [blame] | 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 | |
| 12 | /******************************************************************************* |
| 13 | * Constants that allow assembler code to preserve callee-saved registers of the |
| 14 | * C runtime context while performing a security state switch. |
| 15 | ******************************************************************************/ |
| 16 | #define RMMD_C_RT_CTX_X19 0x0 |
| 17 | #define RMMD_C_RT_CTX_X20 0x8 |
| 18 | #define RMMD_C_RT_CTX_X21 0x10 |
| 19 | #define RMMD_C_RT_CTX_X22 0x18 |
| 20 | #define RMMD_C_RT_CTX_X23 0x20 |
| 21 | #define RMMD_C_RT_CTX_X24 0x28 |
| 22 | #define RMMD_C_RT_CTX_X25 0x30 |
| 23 | #define RMMD_C_RT_CTX_X26 0x38 |
| 24 | #define RMMD_C_RT_CTX_X27 0x40 |
| 25 | #define RMMD_C_RT_CTX_X28 0x48 |
| 26 | #define RMMD_C_RT_CTX_X29 0x50 |
| 27 | #define RMMD_C_RT_CTX_X30 0x58 |
| 28 | |
| 29 | #define RMMD_C_RT_CTX_SIZE 0x60 |
| 30 | #define RMMD_C_RT_CTX_ENTRIES (RMMD_C_RT_CTX_SIZE >> DWORD_SHIFT) |
| 31 | |
| 32 | #ifndef __ASSEMBLER__ |
| 33 | #include <stdint.h> |
Zelalem Aweke | 13dc8f1 | 2021-07-09 14:20:03 -0500 | [diff] [blame] | 34 | |
| 35 | typedef enum rmm_state { |
| 36 | RMM_STATE_RESET = 0, |
| 37 | RMM_STATE_IDLE |
| 38 | } rmm_state_t; |
| 39 | |
| 40 | /* |
| 41 | * Data structure used by the RMM dispatcher (RMMD) in EL3 to track context of |
| 42 | * the RMM at R-EL2. |
| 43 | */ |
| 44 | typedef struct rmmd_rmm_context { |
| 45 | uint64_t c_rt_ctx; |
| 46 | cpu_context_t cpu_ctx; |
| 47 | rmm_state_t state; |
| 48 | } rmmd_rmm_context_t; |
| 49 | |
| 50 | /* Functions used to enter/exit the RMM synchronously */ |
| 51 | uint64_t rmmd_rmm_sync_entry(rmmd_rmm_context_t *ctx); |
| 52 | __dead2 void rmmd_rmm_sync_exit(uint64_t rc); |
| 53 | |
Soby Mathew | 294e1cf | 2022-03-22 16:19:39 +0000 | [diff] [blame] | 54 | /* Functions implementing attestation utilities for RMM */ |
| 55 | int rmmd_attest_get_platform_token(uint64_t buf_pa, uint64_t *buf_len, |
| 56 | uint64_t challenge_hash_len); |
Soby Mathew | f05d93a | 2022-03-22 16:21:19 +0000 | [diff] [blame] | 57 | int rmmd_attest_get_signing_key(uint64_t buf_pa, uint64_t *buf_len, |
| 58 | uint64_t ecc_curve); |
Soby Mathew | 294e1cf | 2022-03-22 16:19:39 +0000 | [diff] [blame] | 59 | |
Zelalem Aweke | 13dc8f1 | 2021-07-09 14:20:03 -0500 | [diff] [blame] | 60 | /* Assembly helpers */ |
| 61 | uint64_t rmmd_rmm_enter(uint64_t *c_rt_ctx); |
| 62 | void __dead2 rmmd_rmm_exit(uint64_t c_rt_ctx, uint64_t ret); |
| 63 | |
| 64 | /* Reference to PM ops for the RMMD */ |
| 65 | extern const spd_pm_ops_t rmmd_pm; |
| 66 | |
| 67 | #endif /* __ASSEMBLER__ */ |
| 68 | |
| 69 | #endif /* RMMD_PRIVATE_H */ |