spss_utils.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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-2022 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. #define CMAC_SIZE_IN_WORDS_1 4
  21. /* Obsolete struct, keep for backward compatible */
  22. struct spss_ioc_set_fw_cmac {
  23. __u32 cmac[CMAC_SIZE_IN_WORDS];
  24. __u32 apps_cmac[OLD_NUM_SPU_UEFI_APPS][CMAC_SIZE_IN_WORDS];
  25. } __packed;
  26. #define SPSS_IOC_SET_FW_CMAC \
  27. _IOWR(SPSS_IOC_MAGIC, 1, struct spss_ioc_set_fw_cmac)
  28. /* ---------- wait for event ------------------------------ */
  29. enum spss_event_id {
  30. /* signaled from user */
  31. SPSS_EVENT_ID_PIL_CALLED = 0,
  32. SPSS_EVENT_ID_NVM_READY = 1,
  33. SPSS_EVENT_ID_SPU_READY = 2,
  34. SPSS_NUM_USER_EVENTS,
  35. /* signaled from kernel */
  36. SPSS_EVENT_ID_SPU_POWER_DOWN = 6,
  37. SPSS_EVENT_ID_SPU_POWER_UP = 7,
  38. SPSS_NUM_EVENTS,
  39. };
  40. enum spss_event_status {
  41. EVENT_STATUS_SIGNALED = 0xAAAA,
  42. EVENT_STATUS_NOT_SIGNALED = 0xFFFF,
  43. EVENT_STATUS_TIMEOUT = 0xEEE1,
  44. EVENT_STATUS_ABORTED = 0xEEE2,
  45. };
  46. struct spss_ioc_wait_for_event {
  47. __u32 event_id; /* input */
  48. __u32 timeout_sec; /* input */
  49. __u32 status; /* output */
  50. } __packed;
  51. #define SPSS_IOC_WAIT_FOR_EVENT \
  52. _IOWR(SPSS_IOC_MAGIC, 2, struct spss_ioc_wait_for_event)
  53. /* ---------- signal event ------------------------------ */
  54. struct spss_ioc_signal_event {
  55. __u32 event_id; /* input */
  56. __u32 status; /* output */
  57. } __packed;
  58. #define SPSS_IOC_SIGNAL_EVENT \
  59. _IOWR(SPSS_IOC_MAGIC, 3, struct spss_ioc_signal_event)
  60. /* ---------- is event signaled ------------------------------ */
  61. struct spss_ioc_is_signaled {
  62. __u32 event_id; /* input */
  63. __u32 status; /* output */
  64. } __attribute__((packed));
  65. #define SPSS_IOC_IS_EVENT_SIGNALED \
  66. _IOWR(SPSS_IOC_MAGIC, 4, struct spss_ioc_is_signaled)
  67. /* ---------- set ssr state ------------------------------ */
  68. #define SPSS_IOC_SET_SSR_STATE \
  69. _IOWR(SPSS_IOC_MAGIC, 5, __u32)
  70. /* ---------- set fw and apps cmac --------------------------------- */
  71. /* NVM, Asym , Crypt , Keym */
  72. #define NUM_SPU_UEFI_APPS 4
  73. /* Max number of 3rd party UEFI applications */
  74. #define MAX_3RD_PARTY_UEFI_APPS 3
  75. /* Max number of total UEFI applications */
  76. #define MAX_SPU_UEFI_APPS (NUM_SPU_UEFI_APPS + MAX_3RD_PARTY_UEFI_APPS)
  77. /** use variable-size-array for future growth */
  78. struct spss_ioc_set_fw_and_apps_cmac {
  79. __u64 cmac_buf_ptr;
  80. /*
  81. * expected cmac_buf_size is:
  82. * (1+MAX_SPU_UEFI_APPS)*CMAC_SIZE_IN_WORDS*sizeof(uint32_t)
  83. */
  84. __u32 cmac_buf_size;
  85. __u32 num_of_cmacs;
  86. } __attribute__((packed));
  87. #define SPSS_IOC_SET_FW_AND_APPS_CMAC \
  88. _IOWR(SPSS_IOC_MAGIC, 6, struct spss_ioc_set_fw_and_apps_cmac)
  89. #endif /* _UAPI_SPSS_UTILS_H_ */