blob: 840d7fe42cbca067db99265140dddd46301039a5 [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,
Subrata Banik46f80732020-03-14 15:01:42 +053051 PLATFORM_ADL,
Andrey Petrov96ecb772016-10-31 19:31:54 -070052};
53
Chris Douglass03ce0142014-02-26 13:30:13 -050054#define LAYOUT_LINELEN 80
55
Stefan Reinauer1c795ad12011-10-14 12:49:41 -070056enum spi_frequency {
57 SPI_FREQUENCY_20MHZ = 0,
58 SPI_FREQUENCY_33MHZ = 1,
Duncan Laurie1f7fd722015-06-22 11:14:48 -070059 SPI_FREQUENCY_48MHZ = 2,
60 SPI_FREQUENCY_50MHZ_30MHZ = 4,
61 SPI_FREQUENCY_17MHZ = 6,
Stefan Reinauer1c795ad12011-10-14 12:49:41 -070062};
63
Stefan Reinauer1b1309f2012-05-11 15:53:43 -070064enum component_density {
65 COMPONENT_DENSITY_512KB = 0,
66 COMPONENT_DENSITY_1MB = 1,
67 COMPONENT_DENSITY_2MB = 2,
68 COMPONENT_DENSITY_4MB = 3,
69 COMPONENT_DENSITY_8MB = 4,
70 COMPONENT_DENSITY_16MB = 5,
Duncan Laurie1f7fd722015-06-22 11:14:48 -070071 COMPONENT_DENSITY_32MB = 6,
72 COMPONENT_DENSITY_64MB = 7,
73 COMPONENT_DENSITY_UNUSED = 0xf
Stefan Reinauer1b1309f2012-05-11 15:53:43 -070074};
75
Stefan Reinauer1c795ad12011-10-14 12:49:41 -070076// flash descriptor
77typedef struct {
78 uint32_t flvalsig;
79 uint32_t flmap0;
80 uint32_t flmap1;
81 uint32_t flmap2;
Stefan Reinauer1c795ad12011-10-14 12:49:41 -070082} __attribute__((packed)) fdbar_t;
83
84// regions
Duncan Laurie1f7fd722015-06-22 11:14:48 -070085#define MAX_REGIONS 9
86#define MAX_REGIONS_OLD 5
Bill XIE4651d452017-09-12 11:54:48 +080087
Duncan Laurie7775d672019-06-06 13:39:26 -070088enum flash_regions {
89 REGION_DESC,
90 REGION_BIOS,
91 REGION_ME,
92 REGION_GBE,
93 REGION_PDR,
94 REGION_EC = 8,
95};
96
Stefan Reinauer1c795ad12011-10-14 12:49:41 -070097typedef struct {
Bill XIE4651d452017-09-12 11:54:48 +080098 uint32_t flreg[MAX_REGIONS];
Stefan Reinauer1c795ad12011-10-14 12:49:41 -070099} __attribute__((packed)) frba_t;
100
101// component section
102typedef struct {
103 uint32_t flcomp;
104 uint32_t flill;
105 uint32_t flpb;
106} __attribute__((packed)) fcba_t;
107
108// pch strap
Patrick Rudolph802cbee2020-05-25 12:18:11 +0200109#define MAX_PCHSTRP 1024
Bill XIE4651d452017-09-12 11:54:48 +0800110
Stefan Reinauer1c795ad12011-10-14 12:49:41 -0700111typedef struct {
Bill XIE4651d452017-09-12 11:54:48 +0800112 uint32_t pchstrp[MAX_PCHSTRP];
Stefan Reinauer1c795ad12011-10-14 12:49:41 -0700113} __attribute__((packed)) fpsba_t;
114
Shawn Nematbakhshd2cb1182015-09-10 19:07:13 -0700115/*
116 * WR / RD bits start at different locations within the flmstr regs, but
117 * otherwise have identical meaning.
118 */
119#define FLMSTR_WR_SHIFT_V1 24
120#define FLMSTR_WR_SHIFT_V2 20
121#define FLMSTR_RD_SHIFT_V1 16
122#define FLMSTR_RD_SHIFT_V2 8
123
Stefan Reinauer1c795ad12011-10-14 12:49:41 -0700124// master
125typedef struct {
126 uint32_t flmstr1;
127 uint32_t flmstr2;
128 uint32_t flmstr3;
Duncan Laurie1f7fd722015-06-22 11:14:48 -0700129 uint32_t flmstr4;
130 uint32_t flmstr5;
Stefan Reinauer1c795ad12011-10-14 12:49:41 -0700131} __attribute__((packed)) fmba_t;
132
133// processor strap
134typedef struct {
135 uint32_t data[8];
136} __attribute__((packed)) fmsba_t;
137
Stefan Reinauer4a17d292012-09-27 12:42:15 -0700138// ME VSCC
139typedef struct {
140 uint32_t jid;
141 uint32_t vscc;
142} vscc_t;
Stefan Reinauer1c795ad12011-10-14 12:49:41 -0700143
Stefan Reinauer4a17d292012-09-27 12:42:15 -0700144typedef struct {
145 // Actual number of entries specified in vtl
Stefan Tauner0d226142018-08-05 18:56:53 +0200146 /* FIXME: Rationale for the limit of 8.
147 * AFAICT it's 127, cf. flashrom's ich_descriptors_tool). */
Stefan Reinauer4a17d292012-09-27 12:42:15 -0700148 vscc_t entry[8];
149} vtba_t;
150
151typedef struct {
152 int base, limit, size;
153} region_t;
Chris Douglass03ce0142014-02-26 13:30:13 -0500154
155struct region_name {
Bill XIEfa5f9942017-09-12 11:22:29 +0800156 const char *pretty;
157 const char *terse;
Bill XIE1bf65062017-09-12 11:31:37 +0800158 const char *filename;
Mathew Kingc7ddc992019-08-08 14:59:25 -0600159 const char *fmapname;
Chris Douglass03ce0142014-02-26 13:30:13 -0500160};