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