blob: 92417c22ddcd848d8088872e36257ab40c0fc502 [file] [log] [blame]
Jimmy Brisson26c5b5c2020-06-22 14:18:42 -05001/*
Jayanth Dodderi Chidanand7c7faff2022-10-11 17:16:07 +01002 * Copyright (c) 2021-2022, ARM Limited. All rights reserved.
Jimmy Brisson26c5b5c2020-06-22 14:18:42 -05003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#ifndef TRNG_SVC_H
8#define TRNG_SVC_H
9
10#include <stdbool.h>
11#include <stdint.h>
12
13#include <lib/smccc.h>
14
15/* SMC function IDs for TRNG queries */
16#define ARM_TRNG_VERSION U(0x84000050)
17#define ARM_TRNG_FEATURES U(0x84000051)
18#define ARM_TRNG_GET_UUID U(0x84000052)
19#define ARM_TRNG_RND32 U(0x84000053)
Jayanth Dodderi Chidanand7c7faff2022-10-11 17:16:07 +010020#define ARM_TRNG_RND64 U(0xC4000053)
Jimmy Brisson26c5b5c2020-06-22 14:18:42 -050021
22/* TRNG version numbers */
23#define TRNG_VERSION_MAJOR (0x1)
24#define TRNG_VERSION_MINOR (0x0)
25
26/* TRNG Error Numbers */
27#define TRNG_E_SUCCESS (0)
28#define TRNG_E_NOT_SUPPORTED (-1)
29#define TRNG_E_INVALID_PARAMS (-2)
30#define TRNG_E_NO_ENTROPY (-3)
31#define TRNG_E_NOT_IMPLEMENTED (-4)
32
Jayanth Dodderi Chidanand7c7faff2022-10-11 17:16:07 +010033/* TRNG Entropy Bit Numbers */
34#define TRNG_RND32_ENTROPY_MAXBITS (96U)
35#define TRNG_RND64_ENTROPY_MAXBITS (192U)
36
37/* Public API to perform the initial TRNG entropy setup */
Jimmy Brisson26c5b5c2020-06-22 14:18:42 -050038void trng_setup(void);
Jayanth Dodderi Chidanand7c7faff2022-10-11 17:16:07 +010039
40/* Public API to verify function id is part of TRNG */
Jimmy Brisson26c5b5c2020-06-22 14:18:42 -050041bool is_trng_fid(uint32_t smc_fid);
Jimmy Brisson26c5b5c2020-06-22 14:18:42 -050042
Jayanth Dodderi Chidanand7c7faff2022-10-11 17:16:07 +010043/* Handler to be called to handle TRNG smc calls */
Jimmy Brisson26c5b5c2020-06-22 14:18:42 -050044uintptr_t trng_smc_handler(
45 uint32_t smc_fid,
46 u_register_t x1,
47 u_register_t x2,
48 u_register_t x3,
49 u_register_t x4,
50 void *cookie,
51 void *handle,
52 u_register_t flags
53);
54
55#endif /* TRNG_SVC_H */