xref: /rk3399_ARM-atf/plat/arm/board/fvp/fvp_sync_traps.c (revision e7e231d39c68083e870cdaaa89ecc4e5045fdd64)
1 /*
2  * Copyright (c) 2022-2026, Arm Limited. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  *
6  * This file just contains demonstration code, to "handle" RNG traps.
7  */
8 
9 #include <stdbool.h>
10 
11 #include <arch.h>
12 #include <arch_helpers.h>
13 #include <bl31/sync_handle.h>
14 #include <context.h>
15 
16 /*
17  * This emulation code here is not very meaningful: enabling the RNG
18  * trap typically happens for a reason, so just calling the actual
19  * hardware instructions might not be useful or even possible.
20  */
21 #if ENABLE_FEAT_RNG_TRAP
plat_handle_rng_trap(uint8_t rt,bool rndrrs,cpu_context_t * ctx)22 int plat_handle_rng_trap(uint8_t rt, bool rndrrs, cpu_context_t *ctx)
23 {
24 	if (rndrrs) {
25 		ctx->gpregs_ctx.ctx_regs[rt] = read_rndrrs();
26 	} else {
27 		ctx->gpregs_ctx.ctx_regs[rt] = read_rndr();
28 	}
29 
30 	return TRAP_RET_CONTINUE;
31 }
32 #endif
33