summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNico Huber <nico.h@gmx.de>2021-06-17 21:23:29 +0200
committerNico Huber <nico.h@gmx.de>2021-06-19 11:54:15 +0000
commit763784000e0620b35184a65aaf552f327244db22 (patch)
tree7043d64ebd8d66eb37ba92494a74bcf5e52f0ac2
parent4bcf4add1167bcfc9ced8510d20535ce111d4b49 (diff)
downloadflashrom-763784000e0620b35184a65aaf552f327244db22.tar.gz
flashrom-763784000e0620b35184a65aaf552f327244db22.tar.bz2
flashrom-763784000e0620b35184a65aaf552f327244db22.zip
ich_descriptors: Refactor read_ich_descriptors_from_dump()
Process the "upper map" early as it doesn't depend on the descriptor generation. This way, we can use it to guess the generation. Change-Id: Ia2786b762ccefdce31b63397119bd89879e887ff Signed-off-by: Nico Huber <nico.h@gmx.de> Reviewed-on: https://review.coreboot.org/c/flashrom/+/55646 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Angel Pons <th3fanbus@gmail.com>
-rw-r--r--ich_descriptors.c34
1 files changed, 17 insertions, 17 deletions
diff --git a/ich_descriptors.c b/ich_descriptors.c
index bf47ec09b..4ae3a1b87 100644
--- a/ich_descriptors.c
+++ b/ich_descriptors.c
@@ -1037,6 +1037,23 @@ int read_ich_descriptors_from_dump(const uint32_t *const dump, const size_t len,
desc->component.FLILL = dump[(getFCBA(&desc->content) >> 2) + 1];
desc->component.FLPB = dump[(getFCBA(&desc->content) >> 2) + 2];
+ /* upper map */
+ desc->upper.FLUMAP1 = dump[(UPPER_MAP_OFFSET >> 2) + 0];
+
+ /* VTL is 8 bits long. Quote from the Ibex Peak SPI programming guide:
+ * "Identifies the 1s based number of DWORDS contained in the VSCC
+ * Table. Each SPI component entry in the table is 2 DWORDS long." So
+ * the maximum of 255 gives us 127.5 SPI components(!?) 8 bytes each. A
+ * check ensures that the maximum offset actually accessed is available.
+ */
+ if (len < getVTBA(&desc->upper) + (desc->upper.VTL / 2 * 8))
+ return ICH_RET_OOB;
+
+ for (i = 0; i < desc->upper.VTL/2; i++) {
+ desc->upper.vscc_table[i].JID = dump[(getVTBA(&desc->upper) >> 2) + i * 2 + 0];
+ desc->upper.vscc_table[i].VSCC = dump[(getVTBA(&desc->upper) >> 2) + i * 2 + 1];
+ }
+
if (*cs == CHIPSET_ICH_UNKNOWN) {
*cs = guess_ich_chipset(&desc->content, &desc->component);
prettyprint_ich_chipset(*cs);
@@ -1056,23 +1073,6 @@ int read_ich_descriptors_from_dump(const uint32_t *const dump, const size_t len,
for (i = 0; i < nm; i++)
desc->master.FLMSTRs[i] = dump[(getFMBA(&desc->content) >> 2) + i];
- /* upper map */
- desc->upper.FLUMAP1 = dump[(UPPER_MAP_OFFSET >> 2) + 0];
-
- /* VTL is 8 bits long. Quote from the Ibex Peak SPI programming guide:
- * "Identifies the 1s based number of DWORDS contained in the VSCC
- * Table. Each SPI component entry in the table is 2 DWORDS long." So
- * the maximum of 255 gives us 127.5 SPI components(!?) 8 bytes each. A
- * check ensures that the maximum offset actually accessed is available.
- */
- if (len < getVTBA(&desc->upper) + (desc->upper.VTL / 2 * 8))
- return ICH_RET_OOB;
-
- for (i = 0; i < desc->upper.VTL/2; i++) {
- desc->upper.vscc_table[i].JID = dump[(getVTBA(&desc->upper) >> 2) + i * 2 + 0];
- desc->upper.vscc_table[i].VSCC = dump[(getVTBA(&desc->upper) >> 2) + i * 2 + 1];
- }
-
/* MCH/PROC (aka. North) straps */
if (len < getFMSBA(&desc->content) + desc->content.MSL * 4)
return ICH_RET_OOB;