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