1 /* SPDX-License-Identifier: MIT */ 2 /* 3 * Copyright © 2019 Intel Corporation 4 */ 5 6 #ifndef _INTEL_UC_FW_ABI_H 7 #define _INTEL_UC_FW_ABI_H 8 9 #include <linux/types.h> 10 #include <linux/build_bug.h> 11 12 /** 13 * DOC: Firmware Layout 14 * 15 * The GuC/HuC firmware layout looks like this:: 16 * 17 * +======================================================================+ 18 * | Firmware blob | 19 * +===============+===============+============+============+============+ 20 * | CSS header | uCode | RSA key | modulus | exponent | 21 * +===============+===============+============+============+============+ 22 * <-header size-> <---header size continued -----------> 23 * <--- size -----------------------------------------------------------> 24 * <-key size-> 25 * <-mod size-> 26 * <-exp size-> 27 * 28 * The firmware may or may not have modulus key and exponent data. The header, 29 * uCode and RSA signature are must-have components that will be used by driver. 30 * Length of each components, which is all in dwords, can be found in header. 31 * In the case that modulus and exponent are not present in fw, a.k.a truncated 32 * image, the length value still appears in header. 33 * 34 * Driver will do some basic fw size validation based on the following rules: 35 * 36 * 1. Header, uCode and RSA are must-have components. 37 * 2. All firmware components, if they present, are in the sequence illustrated 38 * in the layout table above. 39 * 3. Length info of each component can be found in header, in dwords. 40 * 4. Modulus and exponent key are not required by driver. They may not appear 41 * in fw. So driver will load a truncated firmware in this case. 42 * 43 * Starting from DG2, the HuC is loaded by the GSC instead of i915. The GSC 44 * firmware performs all the required integrity checks, we just need to check 45 * the version. Note that the header for GSC-managed blobs is different from the 46 * CSS used for dma-loaded firmwares. 47 */ 48 49 struct uc_css_header { 50 u32 module_type; 51 /* 52 * header_size includes all non-uCode bits, including css_header, rsa 53 * key, modulus key and exponent data. 54 */ 55 u32 header_size_dw; 56 u32 header_version; 57 u32 module_id; 58 u32 module_vendor; 59 u32 date; 60 #define CSS_DATE_DAY (0xFF << 0) 61 #define CSS_DATE_MONTH (0xFF << 8) 62 #define CSS_DATE_YEAR (0xFFFF << 16) 63 u32 size_dw; /* uCode plus header_size_dw */ 64 u32 key_size_dw; 65 u32 modulus_size_dw; 66 u32 exponent_size_dw; 67 u32 time; 68 #define CSS_TIME_HOUR (0xFF << 0) 69 #define CSS_DATE_MIN (0xFF << 8) 70 #define CSS_DATE_SEC (0xFFFF << 16) 71 char username[8]; 72 char buildnumber[12]; 73 u32 sw_version; 74 #define CSS_SW_VERSION_UC_MAJOR (0xFF << 16) 75 #define CSS_SW_VERSION_UC_MINOR (0xFF << 8) 76 #define CSS_SW_VERSION_UC_PATCH (0xFF << 0) 77 u32 reserved0[13]; 78 union { 79 u32 private_data_size; /* only applies to GuC */ 80 u32 reserved1; 81 }; 82 u32 header_info; 83 } __packed; 84 static_assert(sizeof(struct uc_css_header) == 128); 85 86 #define HUC_GSC_VERSION_HI_DW 44 87 #define HUC_GSC_MAJOR_VER_HI_MASK (0xFF << 0) 88 #define HUC_GSC_MINOR_VER_HI_MASK (0xFF << 16) 89 #define HUC_GSC_VERSION_LO_DW 45 90 #define HUC_GSC_PATCH_VER_LO_MASK (0xFF << 0) 91 92 #endif /* _INTEL_UC_FW_ABI_H */ 93