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>
This commit is contained in:
parent
8a3514d0ae
commit
96ecb77905
|
@ -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,6 +833,18 @@ static void lock_descriptor(char *filename, char *image, int size)
|
|||
fmba->flmstr3 = 0x118;
|
||||
}
|
||||
|
||||
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. */
|
||||
|
@ -844,6 +857,8 @@ static void lock_descriptor(char *filename, char *image, int size)
|
|||
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);
|
||||
|
|
|
@ -21,6 +21,10 @@ enum ifd_version {
|
|||
IFD_VERSION_2,
|
||||
};
|
||||
|
||||
enum platform {
|
||||
PLATFORM_APOLLOLAKE
|
||||
};
|
||||
|
||||
#define LAYOUT_LINELEN 80
|
||||
|
||||
enum spi_frequency {
|
||||
|
|
Loading…
Reference in New Issue