xref: /openbmc/linux/include/uapi/linux/pfrut.h (revision b0013e03)
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 };
93 
94 enum pfru_dsm_status {
95 	DSM_SUCCEED = 0,
96 	DSM_FUNC_NOT_SUPPORT = 1,
97 	DSM_INVAL_INPUT = 2,
98 	DSM_HARDWARE_ERR = 3,
99 	DSM_RETRY_SUGGESTED = 4,
100 	DSM_UNKNOWN = 5,
101 	DSM_FUNC_SPEC_ERR = 6,
102 };
103 
104 /**
105  * struct pfru_update_cap_info - Runtime update capability information.
106  *
107  * @status: Indicator of whether this query succeed.
108  * @update_cap: Bitmap to indicate whether the feature is supported.
109  * @code_type: A buffer containing an image type GUID.
110  * @fw_version: Platform firmware version.
111  * @code_rt_version: Code injection runtime version for anti-rollback.
112  * @drv_type: A buffer containing an image type GUID.
113  * @drv_rt_version: The version of the driver update runtime code.
114  * @drv_svn: The secure version number(SVN) of the driver update runtime code.
115  * @platform_id: A buffer containing a platform ID GUID.
116  * @oem_id: A buffer containing an OEM ID GUID.
117  * @oem_info_len: Length of the buffer containing the vendor specific information.
118  */
119 struct pfru_update_cap_info {
120 	__u32 status;
121 	__u32 update_cap;
122 
123 	__u8 code_type[16];
124 	__u32 fw_version;
125 	__u32 code_rt_version;
126 
127 	__u8 drv_type[16];
128 	__u32 drv_rt_version;
129 	__u32 drv_svn;
130 
131 	__u8 platform_id[16];
132 	__u8 oem_id[16];
133 
134 	__u32 oem_info_len;
135 };
136 
137 /**
138  * struct pfru_com_buf_info - Communication buffer information.
139  *
140  * @status: Indicator of whether this query succeed.
141  * @ext_status: Implementation specific query result.
142  * @addr_lo: Low 32bit physical address of the communication buffer to hold
143  *           a runtime update package.
144  * @addr_hi: High 32bit physical address of the communication buffer to hold
145  *           a runtime update package.
146  * @buf_size: Maximum size in bytes of the communication buffer.
147  */
148 struct pfru_com_buf_info {
149 	__u32 status;
150 	__u32 ext_status;
151 	__u64 addr_lo;
152 	__u64 addr_hi;
153 	__u32 buf_size;
154 };
155 
156 /**
157  * struct pfru_updated_result - Platform firmware runtime update result information.
158  * @status: Indicator of whether this update succeed.
159  * @ext_status: Implementation specific update result.
160  * @low_auth_time: Low 32bit value of image authentication time in nanosecond.
161  * @high_auth_time: High 32bit value of image authentication time in nanosecond.
162  * @low_exec_time: Low 32bit value of image execution time in nanosecond.
163  * @high_exec_time: High 32bit value of image execution time in nanosecond.
164  */
165 struct pfru_updated_result {
166 	__u32 status;
167 	__u32 ext_status;
168 	__u64 low_auth_time;
169 	__u64 high_auth_time;
170 	__u64 low_exec_time;
171 	__u64 high_exec_time;
172 };
173 
174 /**
175  * struct pfrt_log_data_info - Log Data from telemetry service.
176  * @status: Indicator of whether this update succeed.
177  * @ext_status: Implementation specific update result.
178  * @chunk1_addr_lo: Low 32bit physical address of the telemetry data chunk1
179  *                  starting address.
180  * @chunk1_addr_hi: High 32bit physical address of the telemetry data chunk1
181  *                  starting address.
182  * @chunk2_addr_lo: Low 32bit physical address of the telemetry data chunk2
183  *                  starting address.
184  * @chunk2_addr_hi: High 32bit physical address of the telemetry data chunk2
185  *                  starting address.
186  * @max_data_size: Maximum supported size of data of all data chunks combined.
187  * @chunk1_size: Data size in bytes of the telemetry data chunk1 buffer.
188  * @chunk2_size: Data size in bytes of the telemetry data chunk2 buffer.
189  * @rollover_cnt: Number of times telemetry data buffer is overwritten
190  *                since telemetry buffer reset.
191  * @reset_cnt: Number of times telemetry services resets that results in
192  *             rollover count and data chunk buffers are reset.
193  */
194 struct pfrt_log_data_info {
195 	__u32 status;
196 	__u32 ext_status;
197 	__u64 chunk1_addr_lo;
198 	__u64 chunk1_addr_hi;
199 	__u64 chunk2_addr_lo;
200 	__u64 chunk2_addr_hi;
201 	__u32 max_data_size;
202 	__u32 chunk1_size;
203 	__u32 chunk2_size;
204 	__u32 rollover_cnt;
205 	__u32 reset_cnt;
206 };
207 
208 /**
209  * struct pfrt_log_info - Telemetry log information.
210  * @log_level: The telemetry log level.
211  * @log_type: The telemetry log type(history and execution).
212  * @log_revid: The telemetry log revision id.
213  */
214 struct pfrt_log_info {
215 	__u32 log_level;
216 	__u32 log_type;
217 	__u32 log_revid;
218 };
219 
220 /**
221  * PFRT_LOG_IOC_SET_INFO - _IOW(PFRUT_IOCTL_MAGIC, 0x06,
222  *				struct pfrt_log_info)
223  *
224  * Return:
225  * * 0			- success
226  * * -EFAULT		- fail to get the setting parameter
227  * * -EINVAL		- fail to set the log level
228  *
229  * Set the PFRT log level and log type. The input information is
230  * a struct pfrt_log_info.
231  */
232 #define PFRT_LOG_IOC_SET_INFO _IOW(PFRUT_IOCTL_MAGIC, 0x06, struct pfrt_log_info)
233 
234 /**
235  * PFRT_LOG_IOC_GET_INFO - _IOR(PFRUT_IOCTL_MAGIC, 0x07,
236  *				struct pfrt_log_info)
237  *
238  * Return:
239  * * 0			- success
240  * * -EINVAL		- fail to get the log level
241  * * -EFAULT		- fail to copy the result back to userspace
242  *
243  * Retrieve log level and log type of the telemetry. The information is
244  * a struct pfrt_log_info.
245  */
246 #define PFRT_LOG_IOC_GET_INFO _IOR(PFRUT_IOCTL_MAGIC, 0x07, struct pfrt_log_info)
247 
248 /**
249  * PFRT_LOG_IOC_GET_DATA_INFO - _IOR(PFRUT_IOCTL_MAGIC, 0x08,
250  *				     struct pfrt_log_data_info)
251  *
252  * Return:
253  * * 0			- success
254  * * -EINVAL		- fail to get the log buffer information
255  * * -EFAULT		- fail to copy the log buffer information to userspace
256  *
257  * Retrieve data information about the telemetry. The information
258  * is a struct pfrt_log_data_info.
259  */
260 #define PFRT_LOG_IOC_GET_DATA_INFO _IOR(PFRUT_IOCTL_MAGIC, 0x08, struct pfrt_log_data_info)
261 
262 #endif /* __PFRUT_H__ */
263