Patrick Georgi | ea063cb | 2020-05-08 19:28:13 +0200 | [diff] [blame^] | 1 | /* ifdtool - dump Intel Firmware Descriptor information */ |
Stefan Reinauer | 1c795ad1 | 2011-10-14 12:49:41 -0700 | [diff] [blame] | 2 | /* |
Stefan Reinauer | 1c795ad1 | 2011-10-14 12:49:41 -0700 | [diff] [blame] | 3 | * This program is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License as published by |
| 5 | * the Free Software Foundation; version 2 of the License. |
| 6 | * |
| 7 | * This program is distributed in the hope that it will be useful, |
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | * GNU General Public License for more details. |
Stefan Reinauer | 1c795ad1 | 2011-10-14 12:49:41 -0700 | [diff] [blame] | 11 | */ |
| 12 | |
| 13 | #include <stdint.h> |
Bill XIE | b3e15a2 | 2017-09-07 18:34:50 +0800 | [diff] [blame] | 14 | #include <stdbool.h> |
Duncan Laurie | 1f7fd72 | 2015-06-22 11:14:48 -0700 | [diff] [blame] | 15 | #define IFDTOOL_VERSION "1.2" |
| 16 | |
| 17 | enum ifd_version { |
| 18 | IFD_VERSION_1, |
| 19 | IFD_VERSION_2, |
| 20 | }; |
Stefan Reinauer | 1c795ad1 | 2011-10-14 12:49:41 -0700 | [diff] [blame] | 21 | |
Bill XIE | b3e15a2 | 2017-09-07 18:34:50 +0800 | [diff] [blame] | 22 | /* port from flashrom */ |
| 23 | enum ich_chipset { |
| 24 | CHIPSET_ICH_UNKNOWN, |
| 25 | CHIPSET_ICH, |
| 26 | CHIPSET_ICH2345, |
| 27 | CHIPSET_ICH6, |
| 28 | CHIPSET_POULSBO, /* SCH U* */ |
| 29 | CHIPSET_TUNNEL_CREEK, /* Atom E6xx */ |
| 30 | CHIPSET_CENTERTON, /* Atom S1220 S1240 S1260 */ |
| 31 | CHIPSET_ICH7, |
| 32 | CHIPSET_ICH8, |
| 33 | CHIPSET_ICH9, |
| 34 | CHIPSET_ICH10, |
| 35 | CHIPSET_5_SERIES_IBEX_PEAK, |
| 36 | CHIPSET_6_SERIES_COUGAR_POINT, |
| 37 | CHIPSET_7_SERIES_PANTHER_POINT, |
| 38 | CHIPSET_8_SERIES_LYNX_POINT, |
| 39 | CHIPSET_BAYTRAIL, /* Actually all with Silvermont architecture: |
| 40 | * Bay Trail, Avoton/Rangeley |
| 41 | */ |
| 42 | CHIPSET_8_SERIES_LYNX_POINT_LP, |
| 43 | CHIPSET_8_SERIES_WELLSBURG, |
| 44 | CHIPSET_9_SERIES_WILDCAT_POINT, |
| 45 | CHIPSET_9_SERIES_WILDCAT_POINT_LP, |
| 46 | CHIPSET_100_SERIES_SUNRISE_POINT, /* also 6th/7th gen Core i/o (LP) |
| 47 | * variants |
| 48 | */ |
| 49 | CHIPSET_C620_SERIES_LEWISBURG, |
| 50 | }; |
| 51 | |
Andrey Petrov | 96ecb77 | 2016-10-31 19:31:54 -0700 | [diff] [blame] | 52 | enum platform { |
Furquan Shaikh | c0257dd | 2018-05-02 23:29:04 -0700 | [diff] [blame] | 53 | PLATFORM_APL, |
| 54 | PLATFORM_CNL, |
| 55 | PLATFORM_GLK, |
Aamir Bohra | 1018be2 | 2018-06-29 15:08:50 +0530 | [diff] [blame] | 56 | PLATFORM_ICL, |
rkanabar | d64b046 | 2019-08-30 11:40:08 +0530 | [diff] [blame] | 57 | PLATFORM_JSL, |
Furquan Shaikh | 088b6e8 | 2018-03-21 10:42:37 -0700 | [diff] [blame] | 58 | PLATFORM_SKLKBL, |
Ravi Sarawadi | 7d9d63b | 2019-10-22 13:45:36 -0700 | [diff] [blame] | 59 | PLATFORM_TGL, |
Andrey Petrov | 96ecb77 | 2016-10-31 19:31:54 -0700 | [diff] [blame] | 60 | }; |
| 61 | |
Chris Douglass | 03ce014 | 2014-02-26 13:30:13 -0500 | [diff] [blame] | 62 | #define LAYOUT_LINELEN 80 |
| 63 | |
Stefan Reinauer | 1c795ad1 | 2011-10-14 12:49:41 -0700 | [diff] [blame] | 64 | enum spi_frequency { |
| 65 | SPI_FREQUENCY_20MHZ = 0, |
| 66 | SPI_FREQUENCY_33MHZ = 1, |
Duncan Laurie | 1f7fd72 | 2015-06-22 11:14:48 -0700 | [diff] [blame] | 67 | SPI_FREQUENCY_48MHZ = 2, |
| 68 | SPI_FREQUENCY_50MHZ_30MHZ = 4, |
| 69 | SPI_FREQUENCY_17MHZ = 6, |
Stefan Reinauer | 1c795ad1 | 2011-10-14 12:49:41 -0700 | [diff] [blame] | 70 | }; |
| 71 | |
Stefan Reinauer | 1b1309f | 2012-05-11 15:53:43 -0700 | [diff] [blame] | 72 | enum component_density { |
| 73 | COMPONENT_DENSITY_512KB = 0, |
| 74 | COMPONENT_DENSITY_1MB = 1, |
| 75 | COMPONENT_DENSITY_2MB = 2, |
| 76 | COMPONENT_DENSITY_4MB = 3, |
| 77 | COMPONENT_DENSITY_8MB = 4, |
| 78 | COMPONENT_DENSITY_16MB = 5, |
Duncan Laurie | 1f7fd72 | 2015-06-22 11:14:48 -0700 | [diff] [blame] | 79 | COMPONENT_DENSITY_32MB = 6, |
| 80 | COMPONENT_DENSITY_64MB = 7, |
| 81 | COMPONENT_DENSITY_UNUSED = 0xf |
Stefan Reinauer | 1b1309f | 2012-05-11 15:53:43 -0700 | [diff] [blame] | 82 | }; |
| 83 | |
Stefan Reinauer | 1c795ad1 | 2011-10-14 12:49:41 -0700 | [diff] [blame] | 84 | // flash descriptor |
| 85 | typedef struct { |
| 86 | uint32_t flvalsig; |
| 87 | uint32_t flmap0; |
| 88 | uint32_t flmap1; |
| 89 | uint32_t flmap2; |
Stefan Reinauer | 1c795ad1 | 2011-10-14 12:49:41 -0700 | [diff] [blame] | 90 | } __attribute__((packed)) fdbar_t; |
| 91 | |
| 92 | // regions |
Duncan Laurie | 1f7fd72 | 2015-06-22 11:14:48 -0700 | [diff] [blame] | 93 | #define MAX_REGIONS 9 |
| 94 | #define MAX_REGIONS_OLD 5 |
Bill XIE | 4651d45 | 2017-09-12 11:54:48 +0800 | [diff] [blame] | 95 | |
Duncan Laurie | 7775d67 | 2019-06-06 13:39:26 -0700 | [diff] [blame] | 96 | enum flash_regions { |
| 97 | REGION_DESC, |
| 98 | REGION_BIOS, |
| 99 | REGION_ME, |
| 100 | REGION_GBE, |
| 101 | REGION_PDR, |
| 102 | REGION_EC = 8, |
| 103 | }; |
| 104 | |
Stefan Reinauer | 1c795ad1 | 2011-10-14 12:49:41 -0700 | [diff] [blame] | 105 | typedef struct { |
Bill XIE | 4651d45 | 2017-09-12 11:54:48 +0800 | [diff] [blame] | 106 | uint32_t flreg[MAX_REGIONS]; |
Stefan Reinauer | 1c795ad1 | 2011-10-14 12:49:41 -0700 | [diff] [blame] | 107 | } __attribute__((packed)) frba_t; |
| 108 | |
| 109 | // component section |
| 110 | typedef struct { |
| 111 | uint32_t flcomp; |
| 112 | uint32_t flill; |
| 113 | uint32_t flpb; |
| 114 | } __attribute__((packed)) fcba_t; |
| 115 | |
| 116 | // pch strap |
Bill XIE | 4651d45 | 2017-09-12 11:54:48 +0800 | [diff] [blame] | 117 | #define MAX_PCHSTRP 18 |
| 118 | |
Stefan Reinauer | 1c795ad1 | 2011-10-14 12:49:41 -0700 | [diff] [blame] | 119 | typedef struct { |
Bill XIE | 4651d45 | 2017-09-12 11:54:48 +0800 | [diff] [blame] | 120 | uint32_t pchstrp[MAX_PCHSTRP]; |
Stefan Reinauer | 1c795ad1 | 2011-10-14 12:49:41 -0700 | [diff] [blame] | 121 | } __attribute__((packed)) fpsba_t; |
| 122 | |
Shawn Nematbakhsh | d2cb118 | 2015-09-10 19:07:13 -0700 | [diff] [blame] | 123 | /* |
| 124 | * WR / RD bits start at different locations within the flmstr regs, but |
| 125 | * otherwise have identical meaning. |
| 126 | */ |
| 127 | #define FLMSTR_WR_SHIFT_V1 24 |
| 128 | #define FLMSTR_WR_SHIFT_V2 20 |
| 129 | #define FLMSTR_RD_SHIFT_V1 16 |
| 130 | #define FLMSTR_RD_SHIFT_V2 8 |
| 131 | |
Stefan Reinauer | 1c795ad1 | 2011-10-14 12:49:41 -0700 | [diff] [blame] | 132 | // master |
| 133 | typedef struct { |
| 134 | uint32_t flmstr1; |
| 135 | uint32_t flmstr2; |
| 136 | uint32_t flmstr3; |
Duncan Laurie | 1f7fd72 | 2015-06-22 11:14:48 -0700 | [diff] [blame] | 137 | uint32_t flmstr4; |
| 138 | uint32_t flmstr5; |
Stefan Reinauer | 1c795ad1 | 2011-10-14 12:49:41 -0700 | [diff] [blame] | 139 | } __attribute__((packed)) fmba_t; |
| 140 | |
| 141 | // processor strap |
| 142 | typedef struct { |
| 143 | uint32_t data[8]; |
| 144 | } __attribute__((packed)) fmsba_t; |
| 145 | |
Stefan Reinauer | 4a17d29 | 2012-09-27 12:42:15 -0700 | [diff] [blame] | 146 | // ME VSCC |
| 147 | typedef struct { |
| 148 | uint32_t jid; |
| 149 | uint32_t vscc; |
| 150 | } vscc_t; |
Stefan Reinauer | 1c795ad1 | 2011-10-14 12:49:41 -0700 | [diff] [blame] | 151 | |
Stefan Reinauer | 4a17d29 | 2012-09-27 12:42:15 -0700 | [diff] [blame] | 152 | typedef struct { |
| 153 | // Actual number of entries specified in vtl |
Stefan Tauner | 0d22614 | 2018-08-05 18:56:53 +0200 | [diff] [blame] | 154 | /* FIXME: Rationale for the limit of 8. |
| 155 | * AFAICT it's 127, cf. flashrom's ich_descriptors_tool). */ |
Stefan Reinauer | 4a17d29 | 2012-09-27 12:42:15 -0700 | [diff] [blame] | 156 | vscc_t entry[8]; |
| 157 | } vtba_t; |
| 158 | |
| 159 | typedef struct { |
| 160 | int base, limit, size; |
| 161 | } region_t; |
Chris Douglass | 03ce014 | 2014-02-26 13:30:13 -0500 | [diff] [blame] | 162 | |
| 163 | struct region_name { |
Bill XIE | fa5f994 | 2017-09-12 11:22:29 +0800 | [diff] [blame] | 164 | const char *pretty; |
| 165 | const char *terse; |
Bill XIE | 1bf6506 | 2017-09-12 11:31:37 +0800 | [diff] [blame] | 166 | const char *filename; |
Mathew King | c7ddc99 | 2019-08-08 14:59:25 -0600 | [diff] [blame] | 167 | const char *fmapname; |
Chris Douglass | 03ce014 | 2014-02-26 13:30:13 -0500 | [diff] [blame] | 168 | }; |