pfrut.h 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
  2. /*
  3. * Platform Firmware Runtime Update header
  4. *
  5. * Copyright(c) 2021 Intel Corporation. All rights reserved.
  6. */
  7. #ifndef __PFRUT_H__
  8. #define __PFRUT_H__
  9. #include <linux/ioctl.h>
  10. #include <linux/types.h>
  11. #define PFRUT_IOCTL_MAGIC 0xEE
  12. /**
  13. * PFRU_IOC_SET_REV - _IOW(PFRUT_IOCTL_MAGIC, 0x01, unsigned int)
  14. *
  15. * Return:
  16. * * 0 - success
  17. * * -EFAULT - fail to read the revision id
  18. * * -EINVAL - user provides an invalid revision id
  19. *
  20. * Set the Revision ID for Platform Firmware Runtime Update.
  21. */
  22. #define PFRU_IOC_SET_REV _IOW(PFRUT_IOCTL_MAGIC, 0x01, unsigned int)
  23. /**
  24. * PFRU_IOC_STAGE - _IOW(PFRUT_IOCTL_MAGIC, 0x02, unsigned int)
  25. *
  26. * Return:
  27. * * 0 - success
  28. * * -EINVAL - stage phase returns invalid result
  29. *
  30. * Stage a capsule image from communication buffer and perform authentication.
  31. */
  32. #define PFRU_IOC_STAGE _IOW(PFRUT_IOCTL_MAGIC, 0x02, unsigned int)
  33. /**
  34. * PFRU_IOC_ACTIVATE - _IOW(PFRUT_IOCTL_MAGIC, 0x03, unsigned int)
  35. *
  36. * Return:
  37. * * 0 - success
  38. * * -EINVAL - activate phase returns invalid result
  39. *
  40. * Activate a previously staged capsule image.
  41. */
  42. #define PFRU_IOC_ACTIVATE _IOW(PFRUT_IOCTL_MAGIC, 0x03, unsigned int)
  43. /**
  44. * PFRU_IOC_STAGE_ACTIVATE - _IOW(PFRUT_IOCTL_MAGIC, 0x04, unsigned int)
  45. *
  46. * Return:
  47. * * 0 - success
  48. * * -EINVAL - stage/activate phase returns invalid result.
  49. *
  50. * Perform both stage and activation action.
  51. */
  52. #define PFRU_IOC_STAGE_ACTIVATE _IOW(PFRUT_IOCTL_MAGIC, 0x04, unsigned int)
  53. /**
  54. * PFRU_IOC_QUERY_CAP - _IOR(PFRUT_IOCTL_MAGIC, 0x05,
  55. * struct pfru_update_cap_info)
  56. *
  57. * Return:
  58. * * 0 - success
  59. * * -EINVAL - query phase returns invalid result
  60. * * -EFAULT - the result fails to be copied to userspace
  61. *
  62. * Retrieve information on the Platform Firmware Runtime Update capability.
  63. * The information is a struct pfru_update_cap_info.
  64. */
  65. #define PFRU_IOC_QUERY_CAP _IOR(PFRUT_IOCTL_MAGIC, 0x05, struct pfru_update_cap_info)
  66. /**
  67. * struct pfru_payload_hdr - Capsule file payload header.
  68. *
  69. * @sig: Signature of this capsule file.
  70. * @hdr_version: Revision of this header structure.
  71. * @hdr_size: Size of this header, including the OemHeader bytes.
  72. * @hw_ver: The supported firmware version.
  73. * @rt_ver: Version of the code injection image.
  74. * @platform_id: A platform specific GUID to specify the platform what
  75. * this capsule image support.
  76. */
  77. struct pfru_payload_hdr {
  78. __u32 sig;
  79. __u32 hdr_version;
  80. __u32 hdr_size;
  81. __u32 hw_ver;
  82. __u32 rt_ver;
  83. __u8 platform_id[16];
  84. };
  85. enum pfru_dsm_status {
  86. DSM_SUCCEED = 0,
  87. DSM_FUNC_NOT_SUPPORT = 1,
  88. DSM_INVAL_INPUT = 2,
  89. DSM_HARDWARE_ERR = 3,
  90. DSM_RETRY_SUGGESTED = 4,
  91. DSM_UNKNOWN = 5,
  92. DSM_FUNC_SPEC_ERR = 6,
  93. };
  94. /**
  95. * struct pfru_update_cap_info - Runtime update capability information.
  96. *
  97. * @status: Indicator of whether this query succeed.
  98. * @update_cap: Bitmap to indicate whether the feature is supported.
  99. * @code_type: A buffer containing an image type GUID.
  100. * @fw_version: Platform firmware version.
  101. * @code_rt_version: Code injection runtime version for anti-rollback.
  102. * @drv_type: A buffer containing an image type GUID.
  103. * @drv_rt_version: The version of the driver update runtime code.
  104. * @drv_svn: The secure version number(SVN) of the driver update runtime code.
  105. * @platform_id: A buffer containing a platform ID GUID.
  106. * @oem_id: A buffer containing an OEM ID GUID.
  107. * @oem_info_len: Length of the buffer containing the vendor specific information.
  108. */
  109. struct pfru_update_cap_info {
  110. __u32 status;
  111. __u32 update_cap;
  112. __u8 code_type[16];
  113. __u32 fw_version;
  114. __u32 code_rt_version;
  115. __u8 drv_type[16];
  116. __u32 drv_rt_version;
  117. __u32 drv_svn;
  118. __u8 platform_id[16];
  119. __u8 oem_id[16];
  120. __u32 oem_info_len;
  121. };
  122. /**
  123. * struct pfru_com_buf_info - Communication buffer information.
  124. *
  125. * @status: Indicator of whether this query succeed.
  126. * @ext_status: Implementation specific query result.
  127. * @addr_lo: Low 32bit physical address of the communication buffer to hold
  128. * a runtime update package.
  129. * @addr_hi: High 32bit physical address of the communication buffer to hold
  130. * a runtime update package.
  131. * @buf_size: Maximum size in bytes of the communication buffer.
  132. */
  133. struct pfru_com_buf_info {
  134. __u32 status;
  135. __u32 ext_status;
  136. __u64 addr_lo;
  137. __u64 addr_hi;
  138. __u32 buf_size;
  139. };
  140. /**
  141. * struct pfru_updated_result - Platform firmware runtime update result information.
  142. * @status: Indicator of whether this update succeed.
  143. * @ext_status: Implementation specific update result.
  144. * @low_auth_time: Low 32bit value of image authentication time in nanosecond.
  145. * @high_auth_time: High 32bit value of image authentication time in nanosecond.
  146. * @low_exec_time: Low 32bit value of image execution time in nanosecond.
  147. * @high_exec_time: High 32bit value of image execution time in nanosecond.
  148. */
  149. struct pfru_updated_result {
  150. __u32 status;
  151. __u32 ext_status;
  152. __u64 low_auth_time;
  153. __u64 high_auth_time;
  154. __u64 low_exec_time;
  155. __u64 high_exec_time;
  156. };
  157. /**
  158. * struct pfrt_log_data_info - Log Data from telemetry service.
  159. * @status: Indicator of whether this update succeed.
  160. * @ext_status: Implementation specific update result.
  161. * @chunk1_addr_lo: Low 32bit physical address of the telemetry data chunk1
  162. * starting address.
  163. * @chunk1_addr_hi: High 32bit physical address of the telemetry data chunk1
  164. * starting address.
  165. * @chunk2_addr_lo: Low 32bit physical address of the telemetry data chunk2
  166. * starting address.
  167. * @chunk2_addr_hi: High 32bit physical address of the telemetry data chunk2
  168. * starting address.
  169. * @max_data_size: Maximum supported size of data of all data chunks combined.
  170. * @chunk1_size: Data size in bytes of the telemetry data chunk1 buffer.
  171. * @chunk2_size: Data size in bytes of the telemetry data chunk2 buffer.
  172. * @rollover_cnt: Number of times telemetry data buffer is overwritten
  173. * since telemetry buffer reset.
  174. * @reset_cnt: Number of times telemetry services resets that results in
  175. * rollover count and data chunk buffers are reset.
  176. */
  177. struct pfrt_log_data_info {
  178. __u32 status;
  179. __u32 ext_status;
  180. __u64 chunk1_addr_lo;
  181. __u64 chunk1_addr_hi;
  182. __u64 chunk2_addr_lo;
  183. __u64 chunk2_addr_hi;
  184. __u32 max_data_size;
  185. __u32 chunk1_size;
  186. __u32 chunk2_size;
  187. __u32 rollover_cnt;
  188. __u32 reset_cnt;
  189. };
  190. /**
  191. * struct pfrt_log_info - Telemetry log information.
  192. * @log_level: The telemetry log level.
  193. * @log_type: The telemetry log type(history and execution).
  194. * @log_revid: The telemetry log revision id.
  195. */
  196. struct pfrt_log_info {
  197. __u32 log_level;
  198. __u32 log_type;
  199. __u32 log_revid;
  200. };
  201. /**
  202. * PFRT_LOG_IOC_SET_INFO - _IOW(PFRUT_IOCTL_MAGIC, 0x06,
  203. * struct pfrt_log_info)
  204. *
  205. * Return:
  206. * * 0 - success
  207. * * -EFAULT - fail to get the setting parameter
  208. * * -EINVAL - fail to set the log level
  209. *
  210. * Set the PFRT log level and log type. The input information is
  211. * a struct pfrt_log_info.
  212. */
  213. #define PFRT_LOG_IOC_SET_INFO _IOW(PFRUT_IOCTL_MAGIC, 0x06, struct pfrt_log_info)
  214. /**
  215. * PFRT_LOG_IOC_GET_INFO - _IOR(PFRUT_IOCTL_MAGIC, 0x07,
  216. * struct pfrt_log_info)
  217. *
  218. * Return:
  219. * * 0 - success
  220. * * -EINVAL - fail to get the log level
  221. * * -EFAULT - fail to copy the result back to userspace
  222. *
  223. * Retrieve log level and log type of the telemetry. The information is
  224. * a struct pfrt_log_info.
  225. */
  226. #define PFRT_LOG_IOC_GET_INFO _IOR(PFRUT_IOCTL_MAGIC, 0x07, struct pfrt_log_info)
  227. /**
  228. * PFRT_LOG_IOC_GET_DATA_INFO - _IOR(PFRUT_IOCTL_MAGIC, 0x08,
  229. * struct pfrt_log_data_info)
  230. *
  231. * Return:
  232. * * 0 - success
  233. * * -EINVAL - fail to get the log buffer information
  234. * * -EFAULT - fail to copy the log buffer information to userspace
  235. *
  236. * Retrieve data information about the telemetry. The information
  237. * is a struct pfrt_log_data_info.
  238. */
  239. #define PFRT_LOG_IOC_GET_DATA_INFO _IOR(PFRUT_IOCTL_MAGIC, 0x08, struct pfrt_log_data_info)
  240. #endif /* __PFRUT_H__ */