Stefan Reinauer | 1c795ad1 | 2011-10-14 12:49:41 -0700 | [diff] [blame] | 1 | /* |
| 2 | * ifdtool - dump Intel Firmware Descriptor information |
| 3 | * |
| 4 | * Copyright (C) 2011 The ChromiumOS Authors. All rights reserved. |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; version 2 of the License. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
Stefan Reinauer | 1c795ad1 | 2011-10-14 12:49:41 -0700 | [diff] [blame] | 14 | */ |
| 15 | |
| 16 | #include <stdint.h> |
Duncan Laurie | 1f7fd72 | 2015-06-22 11:14:48 -0700 | [diff] [blame] | 17 | #define IFDTOOL_VERSION "1.2" |
| 18 | |
| 19 | enum ifd_version { |
| 20 | IFD_VERSION_1, |
| 21 | IFD_VERSION_2, |
| 22 | }; |
Stefan Reinauer | 1c795ad1 | 2011-10-14 12:49:41 -0700 | [diff] [blame] | 23 | |
Andrey Petrov | 96ecb77 | 2016-10-31 19:31:54 -0700 | [diff] [blame] | 24 | enum platform { |
Furquan Shaikh | c0257dd | 2018-05-02 23:29:04 -0700 | [diff] [blame] | 25 | PLATFORM_APL, |
| 26 | PLATFORM_CNL, |
| 27 | PLATFORM_GLK, |
Furquan Shaikh | 088b6e8 | 2018-03-21 10:42:37 -0700 | [diff] [blame] | 28 | PLATFORM_SKLKBL, |
Andrey Petrov | 96ecb77 | 2016-10-31 19:31:54 -0700 | [diff] [blame] | 29 | }; |
| 30 | |
Chris Douglass | 03ce014 | 2014-02-26 13:30:13 -0500 | [diff] [blame] | 31 | #define LAYOUT_LINELEN 80 |
| 32 | |
Stefan Reinauer | 1c795ad1 | 2011-10-14 12:49:41 -0700 | [diff] [blame] | 33 | enum spi_frequency { |
| 34 | SPI_FREQUENCY_20MHZ = 0, |
| 35 | SPI_FREQUENCY_33MHZ = 1, |
Duncan Laurie | 1f7fd72 | 2015-06-22 11:14:48 -0700 | [diff] [blame] | 36 | SPI_FREQUENCY_48MHZ = 2, |
| 37 | SPI_FREQUENCY_50MHZ_30MHZ = 4, |
| 38 | SPI_FREQUENCY_17MHZ = 6, |
Stefan Reinauer | 1c795ad1 | 2011-10-14 12:49:41 -0700 | [diff] [blame] | 39 | }; |
| 40 | |
Stefan Reinauer | 1b1309f | 2012-05-11 15:53:43 -0700 | [diff] [blame] | 41 | enum component_density { |
| 42 | COMPONENT_DENSITY_512KB = 0, |
| 43 | COMPONENT_DENSITY_1MB = 1, |
| 44 | COMPONENT_DENSITY_2MB = 2, |
| 45 | COMPONENT_DENSITY_4MB = 3, |
| 46 | COMPONENT_DENSITY_8MB = 4, |
| 47 | COMPONENT_DENSITY_16MB = 5, |
Duncan Laurie | 1f7fd72 | 2015-06-22 11:14:48 -0700 | [diff] [blame] | 48 | COMPONENT_DENSITY_32MB = 6, |
| 49 | COMPONENT_DENSITY_64MB = 7, |
| 50 | COMPONENT_DENSITY_UNUSED = 0xf |
Stefan Reinauer | 1b1309f | 2012-05-11 15:53:43 -0700 | [diff] [blame] | 51 | }; |
| 52 | |
Stefan Reinauer | 1c795ad1 | 2011-10-14 12:49:41 -0700 | [diff] [blame] | 53 | // flash descriptor |
| 54 | typedef struct { |
| 55 | uint32_t flvalsig; |
| 56 | uint32_t flmap0; |
| 57 | uint32_t flmap1; |
| 58 | uint32_t flmap2; |
Stefan Reinauer | 1c795ad1 | 2011-10-14 12:49:41 -0700 | [diff] [blame] | 59 | } __attribute__((packed)) fdbar_t; |
| 60 | |
| 61 | // regions |
Duncan Laurie | 1f7fd72 | 2015-06-22 11:14:48 -0700 | [diff] [blame] | 62 | #define MAX_REGIONS 9 |
| 63 | #define MAX_REGIONS_OLD 5 |
Bill XIE | 4651d45 | 2017-09-12 11:54:48 +0800 | [diff] [blame] | 64 | |
Stefan Reinauer | 1c795ad1 | 2011-10-14 12:49:41 -0700 | [diff] [blame] | 65 | typedef struct { |
Bill XIE | 4651d45 | 2017-09-12 11:54:48 +0800 | [diff] [blame] | 66 | uint32_t flreg[MAX_REGIONS]; |
Stefan Reinauer | 1c795ad1 | 2011-10-14 12:49:41 -0700 | [diff] [blame] | 67 | } __attribute__((packed)) frba_t; |
| 68 | |
| 69 | // component section |
| 70 | typedef struct { |
| 71 | uint32_t flcomp; |
| 72 | uint32_t flill; |
| 73 | uint32_t flpb; |
| 74 | } __attribute__((packed)) fcba_t; |
| 75 | |
| 76 | // pch strap |
Bill XIE | 4651d45 | 2017-09-12 11:54:48 +0800 | [diff] [blame] | 77 | #define MAX_PCHSTRP 18 |
| 78 | |
Stefan Reinauer | 1c795ad1 | 2011-10-14 12:49:41 -0700 | [diff] [blame] | 79 | typedef struct { |
Bill XIE | 4651d45 | 2017-09-12 11:54:48 +0800 | [diff] [blame] | 80 | uint32_t pchstrp[MAX_PCHSTRP]; |
Stefan Reinauer | 1c795ad1 | 2011-10-14 12:49:41 -0700 | [diff] [blame] | 81 | } __attribute__((packed)) fpsba_t; |
| 82 | |
Shawn Nematbakhsh | d2cb118 | 2015-09-10 19:07:13 -0700 | [diff] [blame] | 83 | /* |
| 84 | * WR / RD bits start at different locations within the flmstr regs, but |
| 85 | * otherwise have identical meaning. |
| 86 | */ |
| 87 | #define FLMSTR_WR_SHIFT_V1 24 |
| 88 | #define FLMSTR_WR_SHIFT_V2 20 |
| 89 | #define FLMSTR_RD_SHIFT_V1 16 |
| 90 | #define FLMSTR_RD_SHIFT_V2 8 |
| 91 | |
Stefan Reinauer | 1c795ad1 | 2011-10-14 12:49:41 -0700 | [diff] [blame] | 92 | // master |
| 93 | typedef struct { |
| 94 | uint32_t flmstr1; |
| 95 | uint32_t flmstr2; |
| 96 | uint32_t flmstr3; |
Duncan Laurie | 1f7fd72 | 2015-06-22 11:14:48 -0700 | [diff] [blame] | 97 | uint32_t flmstr4; |
| 98 | uint32_t flmstr5; |
Stefan Reinauer | 1c795ad1 | 2011-10-14 12:49:41 -0700 | [diff] [blame] | 99 | } __attribute__((packed)) fmba_t; |
| 100 | |
| 101 | // processor strap |
| 102 | typedef struct { |
| 103 | uint32_t data[8]; |
| 104 | } __attribute__((packed)) fmsba_t; |
| 105 | |
Stefan Reinauer | 4a17d29 | 2012-09-27 12:42:15 -0700 | [diff] [blame] | 106 | // ME VSCC |
| 107 | typedef struct { |
| 108 | uint32_t jid; |
| 109 | uint32_t vscc; |
| 110 | } vscc_t; |
Stefan Reinauer | 1c795ad1 | 2011-10-14 12:49:41 -0700 | [diff] [blame] | 111 | |
Stefan Reinauer | 4a17d29 | 2012-09-27 12:42:15 -0700 | [diff] [blame] | 112 | typedef struct { |
| 113 | // Actual number of entries specified in vtl |
Stefan Tauner | 0d22614 | 2018-08-05 18:56:53 +0200 | [diff] [blame^] | 114 | /* FIXME: Rationale for the limit of 8. |
| 115 | * AFAICT it's 127, cf. flashrom's ich_descriptors_tool). */ |
Stefan Reinauer | 4a17d29 | 2012-09-27 12:42:15 -0700 | [diff] [blame] | 116 | vscc_t entry[8]; |
| 117 | } vtba_t; |
| 118 | |
| 119 | typedef struct { |
| 120 | int base, limit, size; |
| 121 | } region_t; |
Chris Douglass | 03ce014 | 2014-02-26 13:30:13 -0500 | [diff] [blame] | 122 | |
| 123 | struct region_name { |
Bill XIE | fa5f994 | 2017-09-12 11:22:29 +0800 | [diff] [blame] | 124 | const char *pretty; |
| 125 | const char *terse; |
Bill XIE | 1bf6506 | 2017-09-12 11:31:37 +0800 | [diff] [blame] | 126 | const char *filename; |
Chris Douglass | 03ce014 | 2014-02-26 13:30:13 -0500 | [diff] [blame] | 127 | }; |