Patrick Georgi | ea063cb | 2020-05-08 19:28:13 +0200 | [diff] [blame] | 1 | /* ifdtool - dump Intel Firmware Descriptor information */ |
Patrick Georgi | 7333a11 | 2020-05-08 20:48:04 +0200 | [diff] [blame] | 2 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Stefan Reinauer | 1c795ad1 | 2011-10-14 12:49:41 -0700 | [diff] [blame] | 3 | |
| 4 | #include <stdint.h> |
Bill XIE | b3e15a2 | 2017-09-07 18:34:50 +0800 | [diff] [blame] | 5 | #include <stdbool.h> |
Duncan Laurie | 1f7fd72 | 2015-06-22 11:14:48 -0700 | [diff] [blame] | 6 | #define IFDTOOL_VERSION "1.2" |
| 7 | |
| 8 | enum ifd_version { |
| 9 | IFD_VERSION_1, |
| 10 | IFD_VERSION_2, |
| 11 | }; |
Stefan Reinauer | 1c795ad1 | 2011-10-14 12:49:41 -0700 | [diff] [blame] | 12 | |
Bill XIE | b3e15a2 | 2017-09-07 18:34:50 +0800 | [diff] [blame] | 13 | /* port from flashrom */ |
| 14 | enum ich_chipset { |
| 15 | CHIPSET_ICH_UNKNOWN, |
| 16 | CHIPSET_ICH, |
| 17 | CHIPSET_ICH2345, |
| 18 | CHIPSET_ICH6, |
| 19 | CHIPSET_POULSBO, /* SCH U* */ |
| 20 | CHIPSET_TUNNEL_CREEK, /* Atom E6xx */ |
| 21 | CHIPSET_CENTERTON, /* Atom S1220 S1240 S1260 */ |
| 22 | CHIPSET_ICH7, |
| 23 | CHIPSET_ICH8, |
| 24 | CHIPSET_ICH9, |
| 25 | CHIPSET_ICH10, |
Subrata Banik | 89db225 | 2020-08-26 14:49:17 +0530 | [diff] [blame] | 26 | CHIPSET_PCH_UNKNOWN, |
Bill XIE | b3e15a2 | 2017-09-07 18:34:50 +0800 | [diff] [blame] | 27 | CHIPSET_5_SERIES_IBEX_PEAK, |
| 28 | CHIPSET_6_SERIES_COUGAR_POINT, |
| 29 | CHIPSET_7_SERIES_PANTHER_POINT, |
| 30 | CHIPSET_8_SERIES_LYNX_POINT, |
| 31 | CHIPSET_BAYTRAIL, /* Actually all with Silvermont architecture: |
| 32 | * Bay Trail, Avoton/Rangeley |
| 33 | */ |
| 34 | CHIPSET_8_SERIES_LYNX_POINT_LP, |
| 35 | CHIPSET_8_SERIES_WELLSBURG, |
| 36 | CHIPSET_9_SERIES_WILDCAT_POINT, |
| 37 | CHIPSET_9_SERIES_WILDCAT_POINT_LP, |
Subrata Banik | 89db225 | 2020-08-26 14:49:17 +0530 | [diff] [blame] | 38 | CHIPSET_N_J_SERIES, /* Gemini Lake: N5xxx, J5xxx, N4xxx, J4xxx */ |
| 39 | CHIPSET_100_200_SERIES_SUNRISE_POINT, /* 6th-7th gen Core i/o (LP) variants */ |
| 40 | CHIPSET_300_400_SERIES_CANNON_ICE_POINT, /* 8th-10th gen Core i/o (LP) variants */ |
Subrata Banik | a5f4781 | 2020-09-29 11:43:01 +0530 | [diff] [blame] | 41 | CHIPSET_500_600_SERIES_TIGER_ALDER_POINT, /* 11th-12th gen Core i/o (LP) |
| 42 | * variants onwards */ |
Bill XIE | b3e15a2 | 2017-09-07 18:34:50 +0800 | [diff] [blame] | 43 | CHIPSET_C620_SERIES_LEWISBURG, |
| 44 | }; |
| 45 | |
Andrey Petrov | 96ecb77 | 2016-10-31 19:31:54 -0700 | [diff] [blame] | 46 | enum platform { |
Furquan Shaikh | c0257dd | 2018-05-02 23:29:04 -0700 | [diff] [blame] | 47 | PLATFORM_APL, |
| 48 | PLATFORM_CNL, |
| 49 | PLATFORM_GLK, |
Aamir Bohra | 1018be2 | 2018-06-29 15:08:50 +0530 | [diff] [blame] | 50 | PLATFORM_ICL, |
rkanabar | d64b046 | 2019-08-30 11:40:08 +0530 | [diff] [blame] | 51 | PLATFORM_JSL, |
Furquan Shaikh | 088b6e8 | 2018-03-21 10:42:37 -0700 | [diff] [blame] | 52 | PLATFORM_SKLKBL, |
Ravi Sarawadi | 7d9d63b | 2019-10-22 13:45:36 -0700 | [diff] [blame] | 53 | PLATFORM_TGL, |
Subrata Banik | 46f8073 | 2020-03-14 15:01:42 +0530 | [diff] [blame] | 54 | PLATFORM_ADL, |
Andrey Petrov | 96ecb77 | 2016-10-31 19:31:54 -0700 | [diff] [blame] | 55 | }; |
| 56 | |
Chris Douglass | 03ce014 | 2014-02-26 13:30:13 -0500 | [diff] [blame] | 57 | #define LAYOUT_LINELEN 80 |
| 58 | |
Stefan Reinauer | 1c795ad1 | 2011-10-14 12:49:41 -0700 | [diff] [blame] | 59 | enum spi_frequency { |
| 60 | SPI_FREQUENCY_20MHZ = 0, |
| 61 | SPI_FREQUENCY_33MHZ = 1, |
Duncan Laurie | 1f7fd72 | 2015-06-22 11:14:48 -0700 | [diff] [blame] | 62 | SPI_FREQUENCY_48MHZ = 2, |
| 63 | SPI_FREQUENCY_50MHZ_30MHZ = 4, |
| 64 | SPI_FREQUENCY_17MHZ = 6, |
Stefan Reinauer | 1c795ad1 | 2011-10-14 12:49:41 -0700 | [diff] [blame] | 65 | }; |
| 66 | |
Subrata Banik | d16ef4d | 2020-08-26 15:53:00 +0530 | [diff] [blame] | 67 | enum spi_frequency_500_series { |
| 68 | SPI_FREQUENCY_100MHZ = 0, |
| 69 | SPI_FREQUENCY_50MHZ = 1, |
| 70 | SPI_FREQUENCY_500SERIES_33MHZ = 3, |
| 71 | SPI_FREQUENCY_25MHZ = 4, |
| 72 | SPI_FREQUENCY_14MHZ = 6, |
| 73 | }; |
| 74 | |
Subrata Banik | e5d3992 | 2020-08-26 16:01:42 +0530 | [diff] [blame] | 75 | enum espi_frequency { |
| 76 | ESPI_FREQUENCY_20MHZ = 0, |
| 77 | ESPI_FREQUENCY_24MHZ = 1, |
| 78 | ESPI_FREQUENCY_30MHZ = 2, |
| 79 | ESPI_FREQUENCY_48MHZ = 3, |
| 80 | ESPI_FREQUENCY_60MHZ = 4, |
| 81 | ESPI_FREQUENCY_17MHZ = 6, |
| 82 | }; |
| 83 | |
| 84 | enum espi_frequency_500_series { |
| 85 | ESPI_FREQUENCY_500SERIES_20MHZ = 0, |
| 86 | ESPI_FREQUENCY_500SERIES_24MHZ = 1, |
| 87 | ESPI_FREQUENCY_500SERIES_25MHZ = 2, |
| 88 | ESPI_FREQUENCY_500SERIES_48MHZ = 3, |
| 89 | ESPI_FREQUENCY_500SERIES_60MHZ = 4, |
| 90 | }; |
| 91 | |
Stefan Reinauer | 1b1309f | 2012-05-11 15:53:43 -0700 | [diff] [blame] | 92 | enum component_density { |
| 93 | COMPONENT_DENSITY_512KB = 0, |
| 94 | COMPONENT_DENSITY_1MB = 1, |
| 95 | COMPONENT_DENSITY_2MB = 2, |
| 96 | COMPONENT_DENSITY_4MB = 3, |
| 97 | COMPONENT_DENSITY_8MB = 4, |
| 98 | COMPONENT_DENSITY_16MB = 5, |
Duncan Laurie | 1f7fd72 | 2015-06-22 11:14:48 -0700 | [diff] [blame] | 99 | COMPONENT_DENSITY_32MB = 6, |
| 100 | COMPONENT_DENSITY_64MB = 7, |
| 101 | COMPONENT_DENSITY_UNUSED = 0xf |
Stefan Reinauer | 1b1309f | 2012-05-11 15:53:43 -0700 | [diff] [blame] | 102 | }; |
| 103 | |
Stefan Reinauer | 1c795ad1 | 2011-10-14 12:49:41 -0700 | [diff] [blame] | 104 | // flash descriptor |
| 105 | typedef struct { |
| 106 | uint32_t flvalsig; |
| 107 | uint32_t flmap0; |
| 108 | uint32_t flmap1; |
| 109 | uint32_t flmap2; |
Subrata Banik | bd2da5a | 2020-08-26 15:43:51 +0530 | [diff] [blame] | 110 | uint32_t flmap3; // Exist for 500 series onwards |
Stefan Reinauer | 1c795ad1 | 2011-10-14 12:49:41 -0700 | [diff] [blame] | 111 | } __attribute__((packed)) fdbar_t; |
| 112 | |
| 113 | // regions |
Duncan Laurie | 1f7fd72 | 2015-06-22 11:14:48 -0700 | [diff] [blame] | 114 | #define MAX_REGIONS 9 |
| 115 | #define MAX_REGIONS_OLD 5 |
Bill XIE | 4651d45 | 2017-09-12 11:54:48 +0800 | [diff] [blame] | 116 | |
Duncan Laurie | 7775d67 | 2019-06-06 13:39:26 -0700 | [diff] [blame] | 117 | enum flash_regions { |
| 118 | REGION_DESC, |
| 119 | REGION_BIOS, |
| 120 | REGION_ME, |
| 121 | REGION_GBE, |
| 122 | REGION_PDR, |
| 123 | REGION_EC = 8, |
| 124 | }; |
| 125 | |
Stefan Reinauer | 1c795ad1 | 2011-10-14 12:49:41 -0700 | [diff] [blame] | 126 | typedef struct { |
Bill XIE | 4651d45 | 2017-09-12 11:54:48 +0800 | [diff] [blame] | 127 | uint32_t flreg[MAX_REGIONS]; |
Stefan Reinauer | 1c795ad1 | 2011-10-14 12:49:41 -0700 | [diff] [blame] | 128 | } __attribute__((packed)) frba_t; |
| 129 | |
| 130 | // component section |
| 131 | typedef struct { |
| 132 | uint32_t flcomp; |
| 133 | uint32_t flill; |
| 134 | uint32_t flpb; |
| 135 | } __attribute__((packed)) fcba_t; |
| 136 | |
| 137 | // pch strap |
Patrick Rudolph | 802cbee | 2020-05-25 12:18:11 +0200 | [diff] [blame] | 138 | #define MAX_PCHSTRP 1024 |
Bill XIE | 4651d45 | 2017-09-12 11:54:48 +0800 | [diff] [blame] | 139 | |
Stefan Reinauer | 1c795ad1 | 2011-10-14 12:49:41 -0700 | [diff] [blame] | 140 | typedef struct { |
Bill XIE | 4651d45 | 2017-09-12 11:54:48 +0800 | [diff] [blame] | 141 | uint32_t pchstrp[MAX_PCHSTRP]; |
Stefan Reinauer | 1c795ad1 | 2011-10-14 12:49:41 -0700 | [diff] [blame] | 142 | } __attribute__((packed)) fpsba_t; |
| 143 | |
Shawn Nematbakhsh | d2cb118 | 2015-09-10 19:07:13 -0700 | [diff] [blame] | 144 | /* |
| 145 | * WR / RD bits start at different locations within the flmstr regs, but |
| 146 | * otherwise have identical meaning. |
| 147 | */ |
| 148 | #define FLMSTR_WR_SHIFT_V1 24 |
| 149 | #define FLMSTR_WR_SHIFT_V2 20 |
| 150 | #define FLMSTR_RD_SHIFT_V1 16 |
| 151 | #define FLMSTR_RD_SHIFT_V2 8 |
| 152 | |
Stefan Reinauer | 1c795ad1 | 2011-10-14 12:49:41 -0700 | [diff] [blame] | 153 | // master |
| 154 | typedef struct { |
| 155 | uint32_t flmstr1; |
| 156 | uint32_t flmstr2; |
| 157 | uint32_t flmstr3; |
Duncan Laurie | 1f7fd72 | 2015-06-22 11:14:48 -0700 | [diff] [blame] | 158 | uint32_t flmstr4; |
| 159 | uint32_t flmstr5; |
Stefan Reinauer | 1c795ad1 | 2011-10-14 12:49:41 -0700 | [diff] [blame] | 160 | } __attribute__((packed)) fmba_t; |
| 161 | |
| 162 | // processor strap |
| 163 | typedef struct { |
| 164 | uint32_t data[8]; |
| 165 | } __attribute__((packed)) fmsba_t; |
| 166 | |
Stefan Reinauer | 4a17d29 | 2012-09-27 12:42:15 -0700 | [diff] [blame] | 167 | // ME VSCC |
| 168 | typedef struct { |
| 169 | uint32_t jid; |
| 170 | uint32_t vscc; |
| 171 | } vscc_t; |
Stefan Reinauer | 1c795ad1 | 2011-10-14 12:49:41 -0700 | [diff] [blame] | 172 | |
Stefan Reinauer | 4a17d29 | 2012-09-27 12:42:15 -0700 | [diff] [blame] | 173 | typedef struct { |
| 174 | // Actual number of entries specified in vtl |
Stefan Tauner | 0d22614 | 2018-08-05 18:56:53 +0200 | [diff] [blame] | 175 | /* FIXME: Rationale for the limit of 8. |
| 176 | * AFAICT it's 127, cf. flashrom's ich_descriptors_tool). */ |
Stefan Reinauer | 4a17d29 | 2012-09-27 12:42:15 -0700 | [diff] [blame] | 177 | vscc_t entry[8]; |
| 178 | } vtba_t; |
| 179 | |
| 180 | typedef struct { |
| 181 | int base, limit, size; |
| 182 | } region_t; |
Chris Douglass | 03ce014 | 2014-02-26 13:30:13 -0500 | [diff] [blame] | 183 | |
| 184 | struct region_name { |
Bill XIE | fa5f994 | 2017-09-12 11:22:29 +0800 | [diff] [blame] | 185 | const char *pretty; |
| 186 | const char *terse; |
Bill XIE | 1bf6506 | 2017-09-12 11:31:37 +0800 | [diff] [blame] | 187 | const char *filename; |
Mathew King | c7ddc99 | 2019-08-08 14:59:25 -0600 | [diff] [blame] | 188 | const char *fmapname; |
Chris Douglass | 03ce014 | 2014-02-26 13:30:13 -0500 | [diff] [blame] | 189 | }; |