spss_utils.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */
  2. /*
  3. * Copyright (c) 2019-2020, The Linux Foundation. All rights reserved.
  4. * Copyright (c) 2021 Qualcomm Innovation Center, Inc. All rights reserved.
  5. */
  6. #ifndef _UAPI_SPSS_UTILS_H_
  7. #define _UAPI_SPSS_UTILS_H_
  8. #include <linux/types.h> /* __u32, _Bool */
  9. #include <linux/ioctl.h> /* ioctl() */
  10. /**
  11. * @brief - Secure Processor Utilities interface to user space
  12. *
  13. * The kernel spss_utils driver interface to user space via IOCTL
  14. * and SYSFS (device attributes).
  15. */
  16. #define SPSS_IOC_MAGIC 'S'
  17. /* ---------- set fw cmac --------------------------------- */
  18. #define OLD_NUM_SPU_UEFI_APPS 3 /* Obsolete */
  19. #define CMAC_SIZE_IN_WORDS 4
  20. /* Obsolete struct, keep for backward compatible */
  21. struct spss_ioc_set_fw_cmac {
  22. __u32 cmac[CMAC_SIZE_IN_WORDS];
  23. __u32 apps_cmac[OLD_NUM_SPU_UEFI_APPS][CMAC_SIZE_IN_WORDS];
  24. } __packed;
  25. #define SPSS_IOC_SET_FW_CMAC \
  26. _IOWR(SPSS_IOC_MAGIC, 1, struct spss_ioc_set_fw_cmac)
  27. /* ---------- wait for event ------------------------------ */
  28. enum spss_event_id {
  29. /* signaled from user */
  30. SPSS_EVENT_ID_PIL_CALLED = 0,
  31. SPSS_EVENT_ID_NVM_READY = 1,
  32. SPSS_EVENT_ID_SPU_READY = 2,
  33. SPSS_NUM_USER_EVENTS,
  34. /* signaled from kernel */
  35. SPSS_EVENT_ID_SPU_POWER_DOWN = 6,
  36. SPSS_EVENT_ID_SPU_POWER_UP = 7,
  37. SPSS_NUM_EVENTS,
  38. };
  39. enum spss_event_status {
  40. EVENT_STATUS_SIGNALED = 0xAAAA,
  41. EVENT_STATUS_NOT_SIGNALED = 0xFFFF,
  42. EVENT_STATUS_TIMEOUT = 0xEEE1,
  43. EVENT_STATUS_ABORTED = 0xEEE2,
  44. };
  45. struct spss_ioc_wait_for_event {
  46. __u32 event_id; /* input */
  47. __u32 timeout_sec; /* input */
  48. __u32 status; /* output */
  49. } __packed;
  50. #define SPSS_IOC_WAIT_FOR_EVENT \
  51. _IOWR(SPSS_IOC_MAGIC, 2, struct spss_ioc_wait_for_event)
  52. /* ---------- signal event ------------------------------ */
  53. struct spss_ioc_signal_event {
  54. __u32 event_id; /* input */
  55. __u32 status; /* output */
  56. } __packed;
  57. #define SPSS_IOC_SIGNAL_EVENT \
  58. _IOWR(SPSS_IOC_MAGIC, 3, struct spss_ioc_signal_event)
  59. /* ---------- is event signaled ------------------------------ */
  60. struct spss_ioc_is_signaled {
  61. __u32 event_id; /* input */
  62. __u32 status; /* output */
  63. } __attribute__((packed));
  64. #define SPSS_IOC_IS_EVENT_SIGNALED \
  65. _IOWR(SPSS_IOC_MAGIC, 4, struct spss_ioc_is_signaled)
  66. /* ---------- set ssr state ------------------------------ */
  67. #define SPSS_IOC_SET_SSR_STATE \
  68. _IOWR(SPSS_IOC_MAGIC, 5, __u32)
  69. /* ---------- set fw and apps cmac --------------------------------- */
  70. /* Asym , Crypt , Keym + 3rd party uefi apps */
  71. #define MAX_SPU_UEFI_APPS 8
  72. /** use variable-size-array for future growth */
  73. struct spss_ioc_set_fw_and_apps_cmac {
  74. __u64 cmac_buf_ptr;
  75. /*
  76. * expected cmac_buf_size is:
  77. * (1+MAX_SPU_UEFI_APPS)*CMAC_SIZE_IN_WORDS*sizeof(uint32_t)
  78. */
  79. __u32 cmac_buf_size;
  80. __u32 num_of_cmacs;
  81. } __attribute__((packed));
  82. #define SPSS_IOC_SET_FW_AND_APPS_CMAC \
  83. _IOWR(SPSS_IOC_MAGIC, 6, struct spss_ioc_set_fw_and_apps_cmac)
  84. #endif /* _UAPI_SPSS_UTILS_H_ */