1 /* 2 * Copyright (c) 2025-2026, Arm Limited and Contributors. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #include <assert.h> 8 9 #include <bl31/sync_handle.h> 10 #include <context.h> 11 #include <plat/common/plat_trng.h> 12 plat_handle_rng_trap(uint8_t rt,bool rndrrs,cpu_context_t * ctx)13int plat_handle_rng_trap(uint8_t rt, bool rndrrs, cpu_context_t *ctx) 14 { 15 uint64_t entropy; 16 17 if (!plat_get_entropy(&entropy)) { 18 ERROR("Failed to get entropy\n"); 19 panic(); 20 } 21 22 /* Emulate RNDR and RNDRRS */ 23 gp_regs_t *gpregs = get_gpregs_ctx(ctx); 24 25 gpregs->ctx_regs[rt] = entropy; 26 27 return TRAP_RET_CONTINUE; 28 } 29