summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey Petrov <andrey.petrov@intel.com>2016-10-31 19:31:54 -0700
committerMartin Roth <martinroth@google.com>2016-11-08 23:11:29 +0100
commit96ecb7790587e458d8991d7c091c87ef53f2b67e (patch)
tree3a31c39d4175c67a9afd7195af25ef57d31c9646
parent8a3514d0aebd0839ab848d45618db3b4a253e1ab (diff)
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> Reviewed-on: https://review.coreboot.org/17202 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin <adurbin@chromium.org>
-rw-r--r--util/ifdtool/ifdtool.c52
-rw-r--r--util/ifdtool/ifdtool.h4
2 files changed, 43 insertions, 13 deletions
diff --git a/util/ifdtool/ifdtool.c b/util/ifdtool/ifdtool.c
index 74588e12a3..45dd97cd42 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,32 @@ 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;
+ break;
+ }
write_image(filename, image, size);
}
@@ -1140,6 +1155,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 +1188,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 +1343,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 78787126ea..fe98d6a856 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 {