Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
0002 /*
0003  * Platform Firmware Runtime Update header
0004  *
0005  * Copyright(c) 2021 Intel Corporation. All rights reserved.
0006  */
0007 #ifndef __PFRUT_H__
0008 #define __PFRUT_H__
0009 
0010 #include <linux/ioctl.h>
0011 #include <linux/types.h>
0012 
0013 #define PFRUT_IOCTL_MAGIC 0xEE
0014 
0015 /**
0016  * PFRU_IOC_SET_REV - _IOW(PFRUT_IOCTL_MAGIC, 0x01, unsigned int)
0017  *
0018  * Return:
0019  * * 0          - success
0020  * * -EFAULT        - fail to read the revision id
0021  * * -EINVAL        - user provides an invalid revision id
0022  *
0023  * Set the Revision ID for Platform Firmware Runtime Update.
0024  */
0025 #define PFRU_IOC_SET_REV _IOW(PFRUT_IOCTL_MAGIC, 0x01, unsigned int)
0026 
0027 /**
0028  * PFRU_IOC_STAGE - _IOW(PFRUT_IOCTL_MAGIC, 0x02, unsigned int)
0029  *
0030  * Return:
0031  * * 0          - success
0032  * * -EINVAL        - stage phase returns invalid result
0033  *
0034  * Stage a capsule image from communication buffer and perform authentication.
0035  */
0036 #define PFRU_IOC_STAGE _IOW(PFRUT_IOCTL_MAGIC, 0x02, unsigned int)
0037 
0038 /**
0039  * PFRU_IOC_ACTIVATE - _IOW(PFRUT_IOCTL_MAGIC, 0x03, unsigned int)
0040  *
0041  * Return:
0042  * * 0          - success
0043  * * -EINVAL        - activate phase returns invalid result
0044  *
0045  * Activate a previously staged capsule image.
0046  */
0047 #define PFRU_IOC_ACTIVATE _IOW(PFRUT_IOCTL_MAGIC, 0x03, unsigned int)
0048 
0049 /**
0050  * PFRU_IOC_STAGE_ACTIVATE - _IOW(PFRUT_IOCTL_MAGIC, 0x04, unsigned int)
0051  *
0052  * Return:
0053  * * 0          - success
0054  * * -EINVAL        - stage/activate phase returns invalid result.
0055  *
0056  * Perform both stage and activation action.
0057  */
0058 #define PFRU_IOC_STAGE_ACTIVATE _IOW(PFRUT_IOCTL_MAGIC, 0x04, unsigned int)
0059 
0060 /**
0061  * PFRU_IOC_QUERY_CAP - _IOR(PFRUT_IOCTL_MAGIC, 0x05,
0062  *               struct pfru_update_cap_info)
0063  *
0064  * Return:
0065  * * 0          - success
0066  * * -EINVAL        - query phase returns invalid result
0067  * * -EFAULT        - the result fails to be copied to userspace
0068  *
0069  * Retrieve information on the Platform Firmware Runtime Update capability.
0070  * The information is a struct pfru_update_cap_info.
0071  */
0072 #define PFRU_IOC_QUERY_CAP _IOR(PFRUT_IOCTL_MAGIC, 0x05, struct pfru_update_cap_info)
0073 
0074 /**
0075  * struct pfru_payload_hdr - Capsule file payload header.
0076  *
0077  * @sig: Signature of this capsule file.
0078  * @hdr_version: Revision of this header structure.
0079  * @hdr_size: Size of this header, including the OemHeader bytes.
0080  * @hw_ver: The supported firmware version.
0081  * @rt_ver: Version of the code injection image.
0082  * @platform_id: A platform specific GUID to specify the platform what
0083  *               this capsule image support.
0084  */
0085 struct pfru_payload_hdr {
0086     __u32 sig;
0087     __u32 hdr_version;
0088     __u32 hdr_size;
0089     __u32 hw_ver;
0090     __u32 rt_ver;
0091     __u8 platform_id[16];
0092 };
0093 
0094 enum pfru_dsm_status {
0095     DSM_SUCCEED = 0,
0096     DSM_FUNC_NOT_SUPPORT = 1,
0097     DSM_INVAL_INPUT = 2,
0098     DSM_HARDWARE_ERR = 3,
0099     DSM_RETRY_SUGGESTED = 4,
0100     DSM_UNKNOWN = 5,
0101     DSM_FUNC_SPEC_ERR = 6,
0102 };
0103 
0104 /**
0105  * struct pfru_update_cap_info - Runtime update capability information.
0106  *
0107  * @status: Indicator of whether this query succeed.
0108  * @update_cap: Bitmap to indicate whether the feature is supported.
0109  * @code_type: A buffer containing an image type GUID.
0110  * @fw_version: Platform firmware version.
0111  * @code_rt_version: Code injection runtime version for anti-rollback.
0112  * @drv_type: A buffer containing an image type GUID.
0113  * @drv_rt_version: The version of the driver update runtime code.
0114  * @drv_svn: The secure version number(SVN) of the driver update runtime code.
0115  * @platform_id: A buffer containing a platform ID GUID.
0116  * @oem_id: A buffer containing an OEM ID GUID.
0117  * @oem_info_len: Length of the buffer containing the vendor specific information.
0118  */
0119 struct pfru_update_cap_info {
0120     __u32 status;
0121     __u32 update_cap;
0122 
0123     __u8 code_type[16];
0124     __u32 fw_version;
0125     __u32 code_rt_version;
0126 
0127     __u8 drv_type[16];
0128     __u32 drv_rt_version;
0129     __u32 drv_svn;
0130 
0131     __u8 platform_id[16];
0132     __u8 oem_id[16];
0133 
0134     __u32 oem_info_len;
0135 };
0136 
0137 /**
0138  * struct pfru_com_buf_info - Communication buffer information.
0139  *
0140  * @status: Indicator of whether this query succeed.
0141  * @ext_status: Implementation specific query result.
0142  * @addr_lo: Low 32bit physical address of the communication buffer to hold
0143  *           a runtime update package.
0144  * @addr_hi: High 32bit physical address of the communication buffer to hold
0145  *           a runtime update package.
0146  * @buf_size: Maximum size in bytes of the communication buffer.
0147  */
0148 struct pfru_com_buf_info {
0149     __u32 status;
0150     __u32 ext_status;
0151     __u64 addr_lo;
0152     __u64 addr_hi;
0153     __u32 buf_size;
0154 };
0155 
0156 /**
0157  * struct pfru_updated_result - Platform firmware runtime update result information.
0158  * @status: Indicator of whether this update succeed.
0159  * @ext_status: Implementation specific update result.
0160  * @low_auth_time: Low 32bit value of image authentication time in nanosecond.
0161  * @high_auth_time: High 32bit value of image authentication time in nanosecond.
0162  * @low_exec_time: Low 32bit value of image execution time in nanosecond.
0163  * @high_exec_time: High 32bit value of image execution time in nanosecond.
0164  */
0165 struct pfru_updated_result {
0166     __u32 status;
0167     __u32 ext_status;
0168     __u64 low_auth_time;
0169     __u64 high_auth_time;
0170     __u64 low_exec_time;
0171     __u64 high_exec_time;
0172 };
0173 
0174 /**
0175  * struct pfrt_log_data_info - Log Data from telemetry service.
0176  * @status: Indicator of whether this update succeed.
0177  * @ext_status: Implementation specific update result.
0178  * @chunk1_addr_lo: Low 32bit physical address of the telemetry data chunk1
0179  *                  starting address.
0180  * @chunk1_addr_hi: High 32bit physical address of the telemetry data chunk1
0181  *                  starting address.
0182  * @chunk2_addr_lo: Low 32bit physical address of the telemetry data chunk2
0183  *                  starting address.
0184  * @chunk2_addr_hi: High 32bit physical address of the telemetry data chunk2
0185  *                  starting address.
0186  * @max_data_size: Maximum supported size of data of all data chunks combined.
0187  * @chunk1_size: Data size in bytes of the telemetry data chunk1 buffer.
0188  * @chunk2_size: Data size in bytes of the telemetry data chunk2 buffer.
0189  * @rollover_cnt: Number of times telemetry data buffer is overwritten
0190  *                since telemetry buffer reset.
0191  * @reset_cnt: Number of times telemetry services resets that results in
0192  *             rollover count and data chunk buffers are reset.
0193  */
0194 struct pfrt_log_data_info {
0195     __u32 status;
0196     __u32 ext_status;
0197     __u64 chunk1_addr_lo;
0198     __u64 chunk1_addr_hi;
0199     __u64 chunk2_addr_lo;
0200     __u64 chunk2_addr_hi;
0201     __u32 max_data_size;
0202     __u32 chunk1_size;
0203     __u32 chunk2_size;
0204     __u32 rollover_cnt;
0205     __u32 reset_cnt;
0206 };
0207 
0208 /**
0209  * struct pfrt_log_info - Telemetry log information.
0210  * @log_level: The telemetry log level.
0211  * @log_type: The telemetry log type(history and execution).
0212  * @log_revid: The telemetry log revision id.
0213  */
0214 struct pfrt_log_info {
0215     __u32 log_level;
0216     __u32 log_type;
0217     __u32 log_revid;
0218 };
0219 
0220 /**
0221  * PFRT_LOG_IOC_SET_INFO - _IOW(PFRUT_IOCTL_MAGIC, 0x06,
0222  *              struct pfrt_log_info)
0223  *
0224  * Return:
0225  * * 0          - success
0226  * * -EFAULT        - fail to get the setting parameter
0227  * * -EINVAL        - fail to set the log level
0228  *
0229  * Set the PFRT log level and log type. The input information is
0230  * a struct pfrt_log_info.
0231  */
0232 #define PFRT_LOG_IOC_SET_INFO _IOW(PFRUT_IOCTL_MAGIC, 0x06, struct pfrt_log_info)
0233 
0234 /**
0235  * PFRT_LOG_IOC_GET_INFO - _IOR(PFRUT_IOCTL_MAGIC, 0x07,
0236  *              struct pfrt_log_info)
0237  *
0238  * Return:
0239  * * 0          - success
0240  * * -EINVAL        - fail to get the log level
0241  * * -EFAULT        - fail to copy the result back to userspace
0242  *
0243  * Retrieve log level and log type of the telemetry. The information is
0244  * a struct pfrt_log_info.
0245  */
0246 #define PFRT_LOG_IOC_GET_INFO _IOR(PFRUT_IOCTL_MAGIC, 0x07, struct pfrt_log_info)
0247 
0248 /**
0249  * PFRT_LOG_IOC_GET_DATA_INFO - _IOR(PFRUT_IOCTL_MAGIC, 0x08,
0250  *                   struct pfrt_log_data_info)
0251  *
0252  * Return:
0253  * * 0          - success
0254  * * -EINVAL        - fail to get the log buffer information
0255  * * -EFAULT        - fail to copy the log buffer information to userspace
0256  *
0257  * Retrieve data information about the telemetry. The information
0258  * is a struct pfrt_log_data_info.
0259  */
0260 #define PFRT_LOG_IOC_GET_DATA_INFO _IOR(PFRUT_IOCTL_MAGIC, 0x08, struct pfrt_log_data_info)
0261 
0262 #endif /* __PFRUT_H__ */