blob: 3b16d4984aa09bdc104d14c51cfb272f11bce953 [file] [log] [blame]
Patrick Georgiea063cb2020-05-08 19:28:13 +02001/* ifdtool - dump Intel Firmware Descriptor information */
Patrick Georgi7333a112020-05-08 20:48:04 +02002/* SPDX-License-Identifier: GPL-2.0-only */
Stefan Reinauer1c795ad12011-10-14 12:49:41 -07003
4#include <stdint.h>
Bill XIEb3e15a22017-09-07 18:34:50 +08005#include <stdbool.h>
Duncan Laurie1f7fd722015-06-22 11:14:48 -07006#define IFDTOOL_VERSION "1.2"
7
8enum ifd_version {
9 IFD_VERSION_1,
10 IFD_VERSION_2,
11};
Stefan Reinauer1c795ad12011-10-14 12:49:41 -070012
Bill XIEb3e15a22017-09-07 18:34:50 +080013/* port from flashrom */
14enum 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,
26 CHIPSET_5_SERIES_IBEX_PEAK,
27 CHIPSET_6_SERIES_COUGAR_POINT,
28 CHIPSET_7_SERIES_PANTHER_POINT,
29 CHIPSET_8_SERIES_LYNX_POINT,
30 CHIPSET_BAYTRAIL, /* Actually all with Silvermont architecture:
31 * Bay Trail, Avoton/Rangeley
32 */
33 CHIPSET_8_SERIES_LYNX_POINT_LP,
34 CHIPSET_8_SERIES_WELLSBURG,
35 CHIPSET_9_SERIES_WILDCAT_POINT,
36 CHIPSET_9_SERIES_WILDCAT_POINT_LP,
37 CHIPSET_100_SERIES_SUNRISE_POINT, /* also 6th/7th gen Core i/o (LP)
38 * variants
39 */
40 CHIPSET_C620_SERIES_LEWISBURG,
41};
42
Andrey Petrov96ecb772016-10-31 19:31:54 -070043enum platform {
Furquan Shaikhc0257dd2018-05-02 23:29:04 -070044 PLATFORM_APL,
45 PLATFORM_CNL,
46 PLATFORM_GLK,
Aamir Bohra1018be22018-06-29 15:08:50 +053047 PLATFORM_ICL,
rkanabard64b0462019-08-30 11:40:08 +053048 PLATFORM_JSL,
Furquan Shaikh088b6e82018-03-21 10:42:37 -070049 PLATFORM_SKLKBL,
Ravi Sarawadi7d9d63b2019-10-22 13:45:36 -070050 PLATFORM_TGL,
Andrey Petrov96ecb772016-10-31 19:31:54 -070051};
52
Chris Douglass03ce0142014-02-26 13:30:13 -050053#define LAYOUT_LINELEN 80
54
Stefan Reinauer1c795ad12011-10-14 12:49:41 -070055enum spi_frequency {
56 SPI_FREQUENCY_20MHZ = 0,
57 SPI_FREQUENCY_33MHZ = 1,
Duncan Laurie1f7fd722015-06-22 11:14:48 -070058 SPI_FREQUENCY_48MHZ = 2,
59 SPI_FREQUENCY_50MHZ_30MHZ = 4,
60 SPI_FREQUENCY_17MHZ = 6,
Stefan Reinauer1c795ad12011-10-14 12:49:41 -070061};
62
Stefan Reinauer1b1309f2012-05-11 15:53:43 -070063enum component_density {
64 COMPONENT_DENSITY_512KB = 0,
65 COMPONENT_DENSITY_1MB = 1,
66 COMPONENT_DENSITY_2MB = 2,
67 COMPONENT_DENSITY_4MB = 3,
68 COMPONENT_DENSITY_8MB = 4,
69 COMPONENT_DENSITY_16MB = 5,
Duncan Laurie1f7fd722015-06-22 11:14:48 -070070 COMPONENT_DENSITY_32MB = 6,
71 COMPONENT_DENSITY_64MB = 7,
72 COMPONENT_DENSITY_UNUSED = 0xf
Stefan Reinauer1b1309f2012-05-11 15:53:43 -070073};
74
Stefan Reinauer1c795ad12011-10-14 12:49:41 -070075// flash descriptor
76typedef struct {
77 uint32_t flvalsig;
78 uint32_t flmap0;
79 uint32_t flmap1;
80 uint32_t flmap2;
Stefan Reinauer1c795ad12011-10-14 12:49:41 -070081} __attribute__((packed)) fdbar_t;
82
83// regions
Duncan Laurie1f7fd722015-06-22 11:14:48 -070084#define MAX_REGIONS 9
85#define MAX_REGIONS_OLD 5
Bill XIE4651d452017-09-12 11:54:48 +080086
Duncan Laurie7775d672019-06-06 13:39:26 -070087enum flash_regions {
88 REGION_DESC,
89 REGION_BIOS,
90 REGION_ME,
91 REGION_GBE,
92 REGION_PDR,
93 REGION_EC = 8,
94};
95
Stefan Reinauer1c795ad12011-10-14 12:49:41 -070096typedef struct {
Bill XIE4651d452017-09-12 11:54:48 +080097 uint32_t flreg[MAX_REGIONS];
Stefan Reinauer1c795ad12011-10-14 12:49:41 -070098} __attribute__((packed)) frba_t;
99
100// component section
101typedef struct {
102 uint32_t flcomp;
103 uint32_t flill;
104 uint32_t flpb;
105} __attribute__((packed)) fcba_t;
106
107// pch strap
Patrick Rudolph802cbee2020-05-25 12:18:11 +0200108#define MAX_PCHSTRP 1024
Bill XIE4651d452017-09-12 11:54:48 +0800109
Stefan Reinauer1c795ad12011-10-14 12:49:41 -0700110typedef struct {
Bill XIE4651d452017-09-12 11:54:48 +0800111 uint32_t pchstrp[MAX_PCHSTRP];
Stefan Reinauer1c795ad12011-10-14 12:49:41 -0700112} __attribute__((packed)) fpsba_t;
113
Shawn Nematbakhshd2cb1182015-09-10 19:07:13 -0700114/*
115 * WR / RD bits start at different locations within the flmstr regs, but
116 * otherwise have identical meaning.
117 */
118#define FLMSTR_WR_SHIFT_V1 24
119#define FLMSTR_WR_SHIFT_V2 20
120#define FLMSTR_RD_SHIFT_V1 16
121#define FLMSTR_RD_SHIFT_V2 8
122
Stefan Reinauer1c795ad12011-10-14 12:49:41 -0700123// master
124typedef struct {
125 uint32_t flmstr1;
126 uint32_t flmstr2;
127 uint32_t flmstr3;
Duncan Laurie1f7fd722015-06-22 11:14:48 -0700128 uint32_t flmstr4;
129 uint32_t flmstr5;
Stefan Reinauer1c795ad12011-10-14 12:49:41 -0700130} __attribute__((packed)) fmba_t;
131
132// processor strap
133typedef struct {
134 uint32_t data[8];
135} __attribute__((packed)) fmsba_t;
136
Stefan Reinauer4a17d292012-09-27 12:42:15 -0700137// ME VSCC
138typedef struct {
139 uint32_t jid;
140 uint32_t vscc;
141} vscc_t;
Stefan Reinauer1c795ad12011-10-14 12:49:41 -0700142
Stefan Reinauer4a17d292012-09-27 12:42:15 -0700143typedef struct {
144 // Actual number of entries specified in vtl
Stefan Tauner0d226142018-08-05 18:56:53 +0200145 /* FIXME: Rationale for the limit of 8.
146 * AFAICT it's 127, cf. flashrom's ich_descriptors_tool). */
Stefan Reinauer4a17d292012-09-27 12:42:15 -0700147 vscc_t entry[8];
148} vtba_t;
149
150typedef struct {
151 int base, limit, size;
152} region_t;
Chris Douglass03ce0142014-02-26 13:30:13 -0500153
154struct region_name {
Bill XIEfa5f9942017-09-12 11:22:29 +0800155 const char *pretty;
156 const char *terse;
Bill XIE1bf65062017-09-12 11:31:37 +0800157 const char *filename;
Mathew Kingc7ddc992019-08-08 14:59:25 -0600158 const char *fmapname;
Chris Douglass03ce0142014-02-26 13:30:13 -0500159};