Andrey Petrov (andrey.petrov@intel.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/17202
-gerrit
commit 2fa932ecfd2a3d49e872f4f75760adc3a0ba1e0e Author: Andrey Petrov andrey.petrov@intel.com Date: Mon Oct 31 19:31:54 2016 -0700
ifdtool: Add option to specify platform (-p) quirks
Apollo Lake uses yet another descriptor format where only two masters are used: CPU/BIOS and CSE/TXE. CSE stores data in a region number 5 that has not been used previously and CPU must not write it. Add quirk (-p aplk) that locks descriptor according to recommended values.
BUG=chrome-os-partner:58974 TEST=ifdtool -p aplk -l bios.bin; ifdtool -d bios.bin.new. Make sure FLMSTR1 and FLMSTR2 are set correctly. unlock with -l and make sure FLMSTRs are restored.
Change-Id: I3f33372bef3ff75d0e34030694c79cd07d5540de Signed-off-by: Andrey Petrov andrey.petrov@intel.com --- util/ifdtool/ifdtool.c | 51 +++++++++++++++++++++++++++++++++++++------------- util/ifdtool/ifdtool.h | 4 ++++ 2 files changed, 42 insertions(+), 13 deletions(-)
diff --git a/util/ifdtool/ifdtool.c b/util/ifdtool/ifdtool.c index 74588e1..c858fee 100644 --- a/util/ifdtool/ifdtool.c +++ b/util/ifdtool/ifdtool.c @@ -30,6 +30,7 @@ static int ifd_version; static int max_regions = 0; static int selected_chip = 0; +static int platform = -1;
static const struct region_name region_names[MAX_REGIONS] = { { "Flash Descriptor", "fd" }, @@ -832,18 +833,31 @@ static void lock_descriptor(char *filename, char *image, int size) fmba->flmstr3 = 0x118; }
- /* CPU/BIOS can read descriptor, BIOS, and GbE. */ - fmba->flmstr1 |= 0xb << rd_shift; - /* CPU/BIOS can write BIOS and GbE. */ - fmba->flmstr1 |= 0xa << wr_shift; - /* ME can read descriptor, ME, and GbE. */ - fmba->flmstr2 |= 0xd << rd_shift; - /* ME can write ME and GbE. */ - fmba->flmstr2 |= 0xc << wr_shift; - /* GbE can write only GbE. */ - fmba->flmstr3 |= 0x8 << rd_shift; - /* GbE can read only GbE. */ - fmba->flmstr3 |= 0x8 << wr_shift; + switch (platform) { + case PLATFORM_APOLLOLAKE: + /* CPU/BIOS can read descriptor and BIOS */ + fmba->flmstr1 |= 0x3 << rd_shift; + /* CPU/BIOS can write BIOS */ + fmba->flmstr1 |= 0x2 << wr_shift; + /* TXE can read descriptor, BIOS and Device Expansion */ + fmba->flmstr2 |= 0x23 << rd_shift; + /* TXE can only write Device Expansion */ + fmba->flmstr2 |= 0x20 << wr_shift; + break; + default: + /* CPU/BIOS can read descriptor, BIOS, and GbE. */ + fmba->flmstr1 |= 0xb << rd_shift; + /* CPU/BIOS can write BIOS and GbE. */ + fmba->flmstr1 |= 0xa << wr_shift; + /* ME can read descriptor, ME, and GbE. */ + fmba->flmstr2 |= 0xd << rd_shift; + /* ME can write ME and GbE. */ + fmba->flmstr2 |= 0xc << wr_shift; + /* GbE can write only GbE. */ + fmba->flmstr3 |= 0x8 << rd_shift; + /* GbE can read only GbE. */ + fmba->flmstr3 |= 0x8 << wr_shift; + }
write_image(filename, image, size); } @@ -1140,6 +1154,8 @@ static void print_usage(const char *name) " Dual Output Fast Read Support\n" " -l | --lock Lock firmware descriptor and ME region\n" " -u | --unlock Unlock firmware descriptor and ME region\n" + " -p | --platform Add platform-specific quirks\n" + " aplk - Apollo Lake\n" " -v | --version: print the version\n" " -h | --help: print this help\n\n" "<region> is one of Descriptor, BIOS, ME, GbE, Platform\n" @@ -1171,10 +1187,11 @@ int main(int argc, char *argv[]) {"unlock", 0, NULL, 'u'}, {"version", 0, NULL, 'v'}, {"help", 0, NULL, 'h'}, + {"platform", 0, NULL, 'p'}, {0, 0, 0, 0} };
- while ((opt = getopt_long(argc, argv, "df:D:C:xi:n:s:eluvh?", + while ((opt = getopt_long(argc, argv, "df:D:C:xi:n:s:p:eluvh?", long_options, &option_index)) != EOF) { switch (opt) { case 'd': @@ -1325,6 +1342,14 @@ int main(int argc, char *argv[]) exit(EXIT_FAILURE); } break; + case 'p': + if (!strcmp(optarg, "aplk")) { + platform = PLATFORM_APOLLOLAKE; + } else { + fprintf(stderr, "Unknown platform: %s\n", optarg); + exit(EXIT_FAILURE); + } + break; case 'v': print_version(); exit(EXIT_SUCCESS); diff --git a/util/ifdtool/ifdtool.h b/util/ifdtool/ifdtool.h index 7878712..fe98d6a 100644 --- a/util/ifdtool/ifdtool.h +++ b/util/ifdtool/ifdtool.h @@ -21,6 +21,10 @@ enum ifd_version { IFD_VERSION_2, };
+enum platform { + PLATFORM_APOLLOLAKE +}; + #define LAYOUT_LINELEN 80
enum spi_frequency {