blob: 0b81260006ede0f320ea2cc22efde168596fb4e8 [file] [log] [blame]
Patrick Georgiea063cb2020-05-08 19:28:13 +02001/* ifdtool - dump Intel Firmware Descriptor information */
Stefan Reinauer1c795ad12011-10-14 12:49:41 -07002/*
Stefan Reinauer1c795ad12011-10-14 12:49:41 -07003 * 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 Reinauer1c795ad12011-10-14 12:49:41 -070011 */
12
13#include <stdint.h>
Bill XIEb3e15a22017-09-07 18:34:50 +080014#include <stdbool.h>
Duncan Laurie1f7fd722015-06-22 11:14:48 -070015#define IFDTOOL_VERSION "1.2"
16
17enum ifd_version {
18 IFD_VERSION_1,
19 IFD_VERSION_2,
20};
Stefan Reinauer1c795ad12011-10-14 12:49:41 -070021
Bill XIEb3e15a22017-09-07 18:34:50 +080022/* port from flashrom */
23enum 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 Petrov96ecb772016-10-31 19:31:54 -070052enum platform {
Furquan Shaikhc0257dd2018-05-02 23:29:04 -070053 PLATFORM_APL,
54 PLATFORM_CNL,
55 PLATFORM_GLK,
Aamir Bohra1018be22018-06-29 15:08:50 +053056 PLATFORM_ICL,
rkanabard64b0462019-08-30 11:40:08 +053057 PLATFORM_JSL,
Furquan Shaikh088b6e82018-03-21 10:42:37 -070058 PLATFORM_SKLKBL,
Ravi Sarawadi7d9d63b2019-10-22 13:45:36 -070059 PLATFORM_TGL,
Andrey Petrov96ecb772016-10-31 19:31:54 -070060};
61
Chris Douglass03ce0142014-02-26 13:30:13 -050062#define LAYOUT_LINELEN 80
63
Stefan Reinauer1c795ad12011-10-14 12:49:41 -070064enum spi_frequency {
65 SPI_FREQUENCY_20MHZ = 0,
66 SPI_FREQUENCY_33MHZ = 1,
Duncan Laurie1f7fd722015-06-22 11:14:48 -070067 SPI_FREQUENCY_48MHZ = 2,
68 SPI_FREQUENCY_50MHZ_30MHZ = 4,
69 SPI_FREQUENCY_17MHZ = 6,
Stefan Reinauer1c795ad12011-10-14 12:49:41 -070070};
71
Stefan Reinauer1b1309f2012-05-11 15:53:43 -070072enum 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 Laurie1f7fd722015-06-22 11:14:48 -070079 COMPONENT_DENSITY_32MB = 6,
80 COMPONENT_DENSITY_64MB = 7,
81 COMPONENT_DENSITY_UNUSED = 0xf
Stefan Reinauer1b1309f2012-05-11 15:53:43 -070082};
83
Stefan Reinauer1c795ad12011-10-14 12:49:41 -070084// flash descriptor
85typedef struct {
86 uint32_t flvalsig;
87 uint32_t flmap0;
88 uint32_t flmap1;
89 uint32_t flmap2;
Stefan Reinauer1c795ad12011-10-14 12:49:41 -070090} __attribute__((packed)) fdbar_t;
91
92// regions
Duncan Laurie1f7fd722015-06-22 11:14:48 -070093#define MAX_REGIONS 9
94#define MAX_REGIONS_OLD 5
Bill XIE4651d452017-09-12 11:54:48 +080095
Duncan Laurie7775d672019-06-06 13:39:26 -070096enum flash_regions {
97 REGION_DESC,
98 REGION_BIOS,
99 REGION_ME,
100 REGION_GBE,
101 REGION_PDR,
102 REGION_EC = 8,
103};
104
Stefan Reinauer1c795ad12011-10-14 12:49:41 -0700105typedef struct {
Bill XIE4651d452017-09-12 11:54:48 +0800106 uint32_t flreg[MAX_REGIONS];
Stefan Reinauer1c795ad12011-10-14 12:49:41 -0700107} __attribute__((packed)) frba_t;
108
109// component section
110typedef struct {
111 uint32_t flcomp;
112 uint32_t flill;
113 uint32_t flpb;
114} __attribute__((packed)) fcba_t;
115
116// pch strap
Bill XIE4651d452017-09-12 11:54:48 +0800117#define MAX_PCHSTRP 18
118
Stefan Reinauer1c795ad12011-10-14 12:49:41 -0700119typedef struct {
Bill XIE4651d452017-09-12 11:54:48 +0800120 uint32_t pchstrp[MAX_PCHSTRP];
Stefan Reinauer1c795ad12011-10-14 12:49:41 -0700121} __attribute__((packed)) fpsba_t;
122
Shawn Nematbakhshd2cb1182015-09-10 19:07:13 -0700123/*
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 Reinauer1c795ad12011-10-14 12:49:41 -0700132// master
133typedef struct {
134 uint32_t flmstr1;
135 uint32_t flmstr2;
136 uint32_t flmstr3;
Duncan Laurie1f7fd722015-06-22 11:14:48 -0700137 uint32_t flmstr4;
138 uint32_t flmstr5;
Stefan Reinauer1c795ad12011-10-14 12:49:41 -0700139} __attribute__((packed)) fmba_t;
140
141// processor strap
142typedef struct {
143 uint32_t data[8];
144} __attribute__((packed)) fmsba_t;
145
Stefan Reinauer4a17d292012-09-27 12:42:15 -0700146// ME VSCC
147typedef struct {
148 uint32_t jid;
149 uint32_t vscc;
150} vscc_t;
Stefan Reinauer1c795ad12011-10-14 12:49:41 -0700151
Stefan Reinauer4a17d292012-09-27 12:42:15 -0700152typedef struct {
153 // Actual number of entries specified in vtl
Stefan Tauner0d226142018-08-05 18:56:53 +0200154 /* FIXME: Rationale for the limit of 8.
155 * AFAICT it's 127, cf. flashrom's ich_descriptors_tool). */
Stefan Reinauer4a17d292012-09-27 12:42:15 -0700156 vscc_t entry[8];
157} vtba_t;
158
159typedef struct {
160 int base, limit, size;
161} region_t;
Chris Douglass03ce0142014-02-26 13:30:13 -0500162
163struct region_name {
Bill XIEfa5f9942017-09-12 11:22:29 +0800164 const char *pretty;
165 const char *terse;
Bill XIE1bf65062017-09-12 11:31:37 +0800166 const char *filename;
Mathew Kingc7ddc992019-08-08 14:59:25 -0600167 const char *fmapname;
Chris Douglass03ce0142014-02-26 13:30:13 -0500168};