trng_svc.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * Copyright (c) 2021-2022, ARM Limited. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #ifndef TRNG_SVC_H
  7. #define TRNG_SVC_H
  8. #include <stdbool.h>
  9. #include <stdint.h>
  10. #include <lib/smccc.h>
  11. /* SMC function IDs for TRNG queries */
  12. #define ARM_TRNG_VERSION U(0x84000050)
  13. #define ARM_TRNG_FEATURES U(0x84000051)
  14. #define ARM_TRNG_GET_UUID U(0x84000052)
  15. #define ARM_TRNG_RND32 U(0x84000053)
  16. #define ARM_TRNG_RND64 U(0xC4000053)
  17. /* TRNG version numbers */
  18. #define TRNG_VERSION_MAJOR (0x1)
  19. #define TRNG_VERSION_MINOR (0x0)
  20. /* TRNG Error Numbers */
  21. #define TRNG_E_SUCCESS (0)
  22. #define TRNG_E_NOT_SUPPORTED (-1)
  23. #define TRNG_E_INVALID_PARAMS (-2)
  24. #define TRNG_E_NO_ENTROPY (-3)
  25. #define TRNG_E_NOT_IMPLEMENTED (-4)
  26. /* TRNG Entropy Bit Numbers */
  27. #define TRNG_RND32_ENTROPY_MAXBITS (96U)
  28. #define TRNG_RND64_ENTROPY_MAXBITS (192U)
  29. /* Public API to perform the initial TRNG entropy setup */
  30. void trng_setup(void);
  31. /* Public API to verify function id is part of TRNG */
  32. bool is_trng_fid(uint32_t smc_fid);
  33. /* Handler to be called to handle TRNG smc calls */
  34. uintptr_t trng_smc_handler(
  35. uint32_t smc_fid,
  36. u_register_t x1,
  37. u_register_t x2,
  38. u_register_t x3,
  39. u_register_t x4,
  40. void *cookie,
  41. void *handle,
  42. u_register_t flags
  43. );
  44. #endif /* TRNG_SVC_H */