blob: ed4d557ca5458982a8522ec77c0b368c0584c0d4 [file] [log] [blame]
Jimmy Brisson26c5b5c2020-06-22 14:18:42 -05001/*
2 * Copyright (c) 2021, ARM Limited. All rights reserved.
3 *
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)
20#define ARM_TRNG_RND64 U(0xc4000053)
21
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
33#if TRNG_SUPPORT
34void trng_setup(void);
35bool is_trng_fid(uint32_t smc_fid);
36#else
37static inline void trng_setup(void)
38{
39}
40
41static inline bool is_trng_fid(uint32_t smc_fid)
42{
43 return false;
44}
45#endif
46uintptr_t trng_smc_handler(
47 uint32_t smc_fid,
48 u_register_t x1,
49 u_register_t x2,
50 u_register_t x3,
51 u_register_t x4,
52 void *cookie,
53 void *handle,
54 u_register_t flags
55);
56
57#endif /* TRNG_SVC_H */