diff options
author | Leah Woods <info@minifree.org> | 2015-07-18 19:31:16 (EDT) |
---|---|---|
committer | Leah Woods <info@minifree.org> | 2016-05-18 10:15:26 (EDT) |
commit | 12e695ec7b160b1cc62831838244454b7edd03d3 (patch) | |
tree | 7821900fe16ece180a021957371a7c0b798922dd /resources/utilities/ich9deblob/src/descriptor | |
parent | 919af0e6b7cbff2171d370a0b830f2b9d740410b (diff) | |
download | libreboot-12e695ec7b160b1cc62831838244454b7edd03d3.zip libreboot-12e695ec7b160b1cc62831838244454b7edd03d3.tar.gz libreboot-12e695ec7b160b1cc62831838244454b7edd03d3.tar.bz2 |
New board: ThinkPad R500 (experimental)r500-experimental
The ich9deblob and ich9gen utilities were modified, so that they
support reading and/or writing descriptor images where the GbE
region is not defined. These utilities were also re-factored
and tidied up a bit.
A quick was noticed during the course of this work, in that
Compenent 1 Density was being set to 8MiB constantly, even
on systems with 4MiB flash chips. Component 2 Density was
set statically to 2MiB. ich9gen now sets both to 4MiB or 8MiB,
depending on whether building the descriptor for a 4MiB or
8MiB ROM image.
There are still some ACPI bugs (see docs/hcl/r500.html), which
will have to be fixed upstream. TODO: get hw reg dumps from
a factory R500, and compare with the X200 or T400 dumps.
Diffstat (limited to 'resources/utilities/ich9deblob/src/descriptor')
-rw-r--r-- | resources/utilities/ich9deblob/src/descriptor/descriptor.c | 243 | ||||
-rw-r--r-- | resources/utilities/ich9deblob/src/descriptor/descriptor.h | 22 |
2 files changed, 176 insertions, 89 deletions
diff --git a/resources/utilities/ich9deblob/src/descriptor/descriptor.c b/resources/utilities/ich9deblob/src/descriptor/descriptor.c index c627afa..5a89813 100644 --- a/resources/utilities/ich9deblob/src/descriptor/descriptor.c +++ b/resources/utilities/ich9deblob/src/descriptor/descriptor.c @@ -28,14 +28,13 @@ /* * --------------------------------------------------------------------- - * Descriptor functions + * Descriptor related functions * --------------------------------------------------------------------- */ /* Set the Host CPU / BIOS region to have read-write access on all regions */ struct DESCRIPTORREGIONRECORD descriptorHostRegionsUnlocked(struct DESCRIPTORREGIONRECORD descriptorStruct) -{ - /* FLMSTR1 (Host CPU / BIOS) */ +{ descriptorStruct.masterAccessSection.flMstr1.fdRegionReadAccess = 0x1; descriptorStruct.masterAccessSection.flMstr1.biosRegionReadAccess = 0x1; descriptorStruct.masterAccessSection.flMstr1.meRegionReadAccess = 0x1; @@ -46,14 +45,13 @@ struct DESCRIPTORREGIONRECORD descriptorHostRegionsUnlocked(struct DESCRIPTORREG descriptorStruct.masterAccessSection.flMstr1.meRegionWriteAccess = 0x1; descriptorStruct.masterAccessSection.flMstr1.gbeRegionWriteAccess = 0x1; descriptorStruct.masterAccessSection.flMstr1.pdRegionWriteAccess = 0x1; - + return descriptorStruct; } /* Set the ME to have *no* read-write access on any region */ struct DESCRIPTORREGIONRECORD descriptorMeRegionsForbidden(struct DESCRIPTORREGIONRECORD descriptorStruct) -{ - /* FLMSTR2 (ME) */ +{ descriptorStruct.masterAccessSection.flMstr2.fdRegionReadAccess = 0x0; descriptorStruct.masterAccessSection.flMstr2.biosRegionReadAccess = 0x0; descriptorStruct.masterAccessSection.flMstr2.meRegionReadAccess = 0x0; @@ -64,92 +62,84 @@ struct DESCRIPTORREGIONRECORD descriptorMeRegionsForbidden(struct DESCRIPTORREGI descriptorStruct.masterAccessSection.flMstr2.meRegionWriteAccess = 0x0; descriptorStruct.masterAccessSection.flMstr2.gbeRegionWriteAccess = 0x0; descriptorStruct.masterAccessSection.flMstr2.pdRegionWriteAccess = 0x0; - + return descriptorStruct; } - -struct DESCRIPTORREGIONRECORD descriptorMePlatformRegionsRemoved(struct DESCRIPTORREGIONRECORD descriptorStruct) + +/* Disable (delete) the ME region */ +struct DESCRIPTORREGIONRECORD descriptorMeRegionRemoved(struct DESCRIPTORREGIONRECORD descriptorStruct) { - /* - * set number of regions from 4 -> 2 (0 based, so 4 means 5 and 2 - * means 3. We want 3 regions: descriptor, gbe and bios, in that order) - */ - descriptorStruct.flMaps.flMap0.NR = 2; - - /* - * There are 5 regions. Since we set the number now to 3, that means - * we need to disable 2 regions. ME and Platform will be disabled! - * - * To disable a region, set the BASE to 1FFF. Shifted by FLREGIONBITSHIFT, - * this puts the beginning of that region well outside the ROM image. - * Also set the LIMIT to 0. - */ - /* Disable (delete) the ME region */ descriptorStruct.regionSection.flReg2.BASE = 0x1FFF; descriptorStruct.regionSection.flReg2.LIMIT = 0; - /* Disable (delete) the Platform region */ + + return descriptorStruct; +} + +/* Disable (delete) the Platform region */ +struct DESCRIPTORREGIONRECORD descriptorPlatformRegionRemoved(struct DESCRIPTORREGIONRECORD descriptorStruct) +{ descriptorStruct.regionSection.flReg4.BASE = 0x1FFF; descriptorStruct.regionSection.flReg4.LIMIT = 0; return descriptorStruct; } -struct DESCRIPTORREGIONRECORD descriptorDisableMeTpm(struct DESCRIPTORREGIONRECORD descriptorStruct) +/* Disable the ME in ICHSTRAP0 and MCHSTRAP0 */ +struct DESCRIPTORREGIONRECORD descriptorDisableMe(struct DESCRIPTORREGIONRECORD descriptorStruct) +{ + descriptorStruct.ichStraps.ichStrap0.meDisable = 1; + descriptorStruct.mchStraps.mchStrap0.meDisable = 1; + + return descriptorStruct; +} + +/* Disable the TPM in MCHSTRAP0 */ +struct DESCRIPTORREGIONRECORD descriptorDisableTpm(struct DESCRIPTORREGIONRECORD descriptorStruct) { - descriptorStruct.ichStraps.ichStrap0.meDisable = 1; /* Disable the ME in ICHSTRAP0 */ - descriptorStruct.mchStraps.mchStrap0.meDisable = 1; /* Disable the ME in MCHSTRAP0 */ - descriptorStruct.mchStraps.mchStrap0.tpmDisable = 1; /* Disable the TPM in MCHSTRAP0 */ + descriptorStruct.mchStraps.mchStrap0.tpmDisable = 1; return descriptorStruct; } +/* Relocate the Gbe region to begin at 4KiB (immediately after the flash descriptor) */ struct DESCRIPTORREGIONRECORD descriptorMoveGbeToStart(struct DESCRIPTORREGIONRECORD descriptorStruct) { - /* Relocate the Gbe region to begin at 4KiB (immediately after the flash descriptor) */ descriptorStruct.regionSection.flReg3.BASE = DESCRIPTORREGIONSIZE >> FLREGIONBITSHIFT; descriptorStruct.regionSection.flReg3.LIMIT = GBEREGIONSIZE_8K >> FLREGIONBITSHIFT; return descriptorStruct; } +/* Disable (delete) the GbE region */ +struct DESCRIPTORREGIONRECORD descriptorGbeRegionRemoved(struct DESCRIPTORREGIONRECORD descriptorStruct) +{ + descriptorStruct.regionSection.flReg3.BASE = 0x1FFF; + descriptorStruct.regionSection.flReg3.LIMIT = 0; + + return descriptorStruct; +} + +/* BIOS Region begin after descriptor+gbe at first 12KiB, fills the rest of the image */ struct DESCRIPTORREGIONRECORD descriptorBiosRegionFillImageAfterGbe(struct DESCRIPTORREGIONRECORD descriptorStruct, unsigned int romSize) { - /* BIOS Region begin after descriptor+gbe at first 12KiB, fills the rest of the image */ descriptorStruct.regionSection.flReg1.BASE = (DESCRIPTORREGIONSIZE + GBEREGIONSIZE_8K) >> FLREGIONBITSHIFT; descriptorStruct.regionSection.flReg1.LIMIT = (romSize >> FLREGIONBITSHIFT) - 1; return descriptorStruct; } - -struct DESCRIPTORREGIONRECORD deblobbedDescriptorStructFromFactory(struct DESCRIPTORREGIONRECORD descriptorStruct, unsigned int romSize) + +/* BIOS Region begin after descriptor at first 4KiB, fills the rest of the image */ +struct DESCRIPTORREGIONRECORD descriptorBiosRegionFillImageAfterDescriptor(struct DESCRIPTORREGIONRECORD descriptorStruct, unsigned int romSize) +{ + descriptorStruct.regionSection.flReg1.BASE = DESCRIPTORREGIONSIZE >> FLREGIONBITSHIFT; + descriptorStruct.regionSection.flReg1.LIMIT = (romSize >> FLREGIONBITSHIFT) - 1; + + return descriptorStruct; +} + +/* Set OEM string to "LIBERATE" */ +struct DESCRIPTORREGIONRECORD descriptorOemString(struct DESCRIPTORREGIONRECORD descriptorStruct) { - // Disable the ME/TPM and remove the ME/Platform regions: - descriptorStruct = descriptorMePlatformRegionsRemoved(descriptorStruct); - descriptorStruct = descriptorDisableMeTpm(descriptorStruct); - - // Move GbE region to the start of the image (after the descriptor) - descriptorStruct = descriptorMoveGbeToStart(descriptorStruct); - - /* BIOS region fills the remaining space */ - descriptorStruct = descriptorBiosRegionFillImageAfterGbe(descriptorStruct, romSize); - - /* - * Set region read/write access - * ------------- - */ - - /* Host/CPU is allowed to read/write all regions. */ - descriptorStruct = descriptorHostRegionsUnlocked(descriptorStruct); - /* The ME is disallowed read-write access to all regions - * (this is probably redundant, since the ME is already removed from libreboot) */ - descriptorStruct = descriptorMeRegionsForbidden(descriptorStruct); - - /* - * Miscellaneous - * ------------- - */ - - /* Set OEM string to "LIBERATE" */ descriptorStruct.oemSection.magicString[0] = 0x4C; descriptorStruct.oemSection.magicString[1] = 0x49; descriptorStruct.oemSection.magicString[2] = 0x42; @@ -158,6 +148,100 @@ struct DESCRIPTORREGIONRECORD deblobbedDescriptorStructFromFactory(struct DESCRI descriptorStruct.oemSection.magicString[5] = 0x41; descriptorStruct.oemSection.magicString[6] = 0x54; descriptorStruct.oemSection.magicString[7] = 0x45; + + return descriptorStruct; +} + +/* Check whether a GbE region is defined by this descriptor. + * Not thorough, but should work in most cases */ +int descriptorDefinesGbeRegion(struct DESCRIPTORREGIONRECORD descriptorStruct) +{ + if ( + (descriptorStruct.regionSection.flReg3.BASE == 0x1FFF || descriptorStruct.regionSection.flReg3.BASE == 0xFFF) + && + (descriptorStruct.regionSection.flReg3.LIMIT == 0) + ) + return 0; /* has no GbE region */ + else if ( + descriptorStruct.ichStraps.ichStrap0.integratedGbe == 0 + || + descriptorStruct.ichStraps.ichStrap0.lanPhy == 0 + ) + return 0; /* has no GbE region */ + else + return 1; /* has a GbE region */ +} + +/* Configure the BIOS and GbE regions, as required by libreboot. + * Enable or disable the GbE region, based on what's in the descriptor */ +struct DESCRIPTORREGIONRECORD librebootSetGbeBiosDescriptorRegions(struct DESCRIPTORREGIONRECORD descriptorStruct, unsigned int romSize) +{ + if (descriptorDefinesGbeRegion(descriptorStruct)) + { + /* + * set number of regions from 4 -> 2 (0 based, so 4 means 5 and 2 + * means 3. We want 3 regions: descriptor, gbe and bios, in that order) + */ + descriptorStruct.flMaps.flMap0.NR = 2; + /* Move GbE region to the start of the image (after the descriptor) */ + descriptorStruct = descriptorMoveGbeToStart(descriptorStruct); + /* BIOS region fills the remaining space */ + descriptorStruct = descriptorBiosRegionFillImageAfterGbe(descriptorStruct, romSize); + + /* GbE region means that an Intel NIC is to be present */ + descriptorStruct.ichStraps.ichStrap0.integratedGbe = 0x1; + descriptorStruct.ichStraps.ichStrap0.lanPhy = 0x1; + } + else { + /* + * set number of regions from 4 -> 2 (0 based, so 4 means 5 and 1 + * means 2. We want 2 regions: descriptor and bios, in that order) + */ + descriptorStruct.flMaps.flMap0.NR = 1; + /* Disable the GbE region */ + descriptorStruct = descriptorGbeRegionRemoved(descriptorStruct); + /* BIOS region fills the remaining space, after the descriptor */ + descriptorStruct = descriptorBiosRegionFillImageAfterDescriptor(descriptorStruct, romSize); + + /* No GbE region means that an onboard NIC is still used, but it's discrete (eg Broadcom) */ + descriptorStruct.ichStraps.ichStrap0.integratedGbe = 0x0; + descriptorStruct.ichStraps.ichStrap0.lanPhy = 0x0; + } + + return descriptorStruct; +} + +uint8_t componentDensity(unsigned int romSizeInBytes) +{ + /* component density, see Component Section Record. page 848 in the datasheet */ + switch (romSizeInBytes) + { + case ROMSIZE_512KB: return 0; + case ROMSIZE_1MB: return 1; + case ROMSIZE_2MB: return 2; + case ROMSIZE_4MB: return 3; + case ROMSIZE_8MB: return 4; + case ROMSIZE_16MB: return 5; + default: return 0x7; /* reserved value */ + } +} + +/* From a factory.rom image, create a modified descriptor region, suitable + * for use by the libreboot project */ +struct DESCRIPTORREGIONRECORD librebootDescriptorStructFromFactory(struct DESCRIPTORREGIONRECORD descriptorStruct, unsigned int romSize) +{ + /* Enable or disable the GbE region, from what's in the descriptor */ + descriptorStruct = librebootSetGbeBiosDescriptorRegions(descriptorStruct, romSize); + + /* Disable the ME/TPM and remove the ME/Platform regions: */ + descriptorStruct = descriptorMeRegionRemoved(descriptorStruct); + /* Disable the ME/TPM and remove the ME/Platform regions: */ + descriptorStruct = descriptorPlatformRegionRemoved(descriptorStruct); + + /* Disable the ME itself, so that it doesn't try to start when this descriptor is in use */ + descriptorStruct = descriptorDisableMe(descriptorStruct); + /* Also disable the TPM, by default */ + descriptorStruct = descriptorDisableTpm(descriptorStruct); return descriptorStruct; } @@ -192,13 +276,7 @@ int notCreatedHFileForDescriptorCFile(char* outFileName, char* cFileName) fprintf(fp, "#include <string.h>\n"); fprintf(fp, "#include \"../descriptor/descriptor.h\"\n\n"); - fprintf(fp, "/* ROM image sizes in bytes */\n"); - fprintf(fp, "#define ROMSIZE_4MB 0x400000\n"); - fprintf(fp, "#define ROMSIZE_8MB 0x800000\n\n"); - - fprintf(fp, "struct DESCRIPTORREGIONRECORD generatedDescriptorStruct(unsigned int romSize);\n"); - fprintf(fp, "struct DESCRIPTORREGIONRECORD generatedDescriptorStructRom4M();\n"); - fprintf(fp, "struct DESCRIPTORREGIONRECORD generatedDescriptorStructRom8M();\n"); + fprintf(fp, "struct DESCRIPTORREGIONRECORD generatedDescriptorStruct(unsigned int romSize, int hasGbe);\n"); fprintf(fp, "#endif\n"); @@ -234,7 +312,7 @@ int notCreatedCFileFromDescriptorStruct(struct DESCRIPTORREGIONRECORD descriptor fprintf(fp, "/* Generate a 4KiB Descriptor struct, with default values. */\n"); fprintf(fp, "/* Read ../descriptor/descriptor.h for an explanation of the default values used here */\n\n"); - fprintf(fp, "struct DESCRIPTORREGIONRECORD generatedDescriptorStruct(unsigned int romSize)\n"); + fprintf(fp, "struct DESCRIPTORREGIONRECORD generatedDescriptorStruct(unsigned int romSize, int hasGbe)\n"); fprintf(fp, "{\n"); fprintf(fp, " int i;\n"); fprintf(fp, " struct DESCRIPTORREGIONRECORD descriptorStruct;\n"); @@ -250,7 +328,8 @@ int notCreatedCFileFromDescriptorStruct(struct DESCRIPTORREGIONRECORD descriptor fprintf(fp, " descriptorStruct.flMaps.flMap0.NC = 0x%01x;\n", descriptorStruct.flMaps.flMap0.NC); fprintf(fp, " descriptorStruct.flMaps.flMap0.reserved1 = 0x%02x;\n", descriptorStruct.flMaps.flMap0.reserved1); fprintf(fp, " descriptorStruct.flMaps.flMap0.FRBA = 0x%02x;\n", descriptorStruct.flMaps.flMap0.FRBA); - fprintf(fp, " descriptorStruct.flMaps.flMap0.NR = 0x%01x; /* see ../descriptor/descriptor.c */\n", descriptorStruct.flMaps.flMap0.NR); + fprintf(fp, " /* descriptorStruct.flMaps.flMap0.NR = 0x%01x; */ /* see ../descriptor/descriptor.c */\n", descriptorStruct.flMaps.flMap0.NR); + fprintf(fp, " descriptorStruct.flMaps.flMap0.NR = hasGbe ? 0x2 : 0x1; /* see ../descriptor/descriptor.c */\n"); fprintf(fp, " descriptorStruct.flMaps.flMap0.reserved2 = 0x%02x;\n", descriptorStruct.flMaps.flMap0.reserved2); fprintf(fp, " /* FLMAP1 */\n"); fprintf(fp, " descriptorStruct.flMaps.flMap1.FMBA = 0x%02x;\n", descriptorStruct.flMaps.flMap1.FMBA); @@ -266,8 +345,10 @@ int notCreatedCFileFromDescriptorStruct(struct DESCRIPTORREGIONRECORD descriptor /* Component Section Record */ fprintf(fp, " /* Component Section Record */\n"); fprintf(fp, " /* FLCOMP */\n"); - fprintf(fp, " descriptorStruct.componentSection.flcomp.component1Density = 0x%01x;\n", descriptorStruct.componentSection.flcomp.component1Density); - fprintf(fp, " descriptorStruct.componentSection.flcomp.component2Density = 0x%01x;\n", descriptorStruct.componentSection.flcomp.component2Density); + fprintf(fp, " /* descriptorStruct.componentSection.flcomp.component1Density = 0x%01x; */\n", descriptorStruct.componentSection.flcomp.component1Density); + fprintf(fp, " /* descriptorStruct.componentSection.flcomp.component2Density = 0x%01x; */\n", descriptorStruct.componentSection.flcomp.component2Density); + fprintf(fp, " descriptorStruct.componentSection.flcomp.component1Density = componentDensity(romSize);\n"); + fprintf(fp, " descriptorStruct.componentSection.flcomp.component2Density = componentDensity(romSize);\n"); fprintf(fp, " descriptorStruct.componentSection.flcomp.reserved1 = 0x%01x;\n", descriptorStruct.componentSection.flcomp.reserved1); fprintf(fp, " descriptorStruct.componentSection.flcomp.reserved2 = 0x%02x;\n", descriptorStruct.componentSection.flcomp.reserved2); fprintf(fp, " descriptorStruct.componentSection.flcomp.reserved3 = 0x%01x;\n", descriptorStruct.componentSection.flcomp.reserved3); @@ -305,7 +386,7 @@ int notCreatedCFileFromDescriptorStruct(struct DESCRIPTORREGIONRECORD descriptor fprintf(fp, " descriptorStruct.regionSection.flReg0.reserved2 = 0x%01x;\n", descriptorStruct.regionSection.flReg0.reserved2); fprintf(fp, " /* FLREG1 (BIOS) */\n"); fprintf(fp, " /* descriptorStruct.regionSection.flReg1.BASE = 0x%04x; */\n", descriptorStruct.regionSection.flReg1.BASE); - fprintf(fp, " descriptorStruct.regionSection.flReg1.BASE = (DESCRIPTORREGIONSIZE + GBEREGIONSIZE_8K) >> FLREGIONBITSHIFT; /* see ../descriptor/descriptor.c */\n"); + fprintf(fp, " descriptorStruct.regionSection.flReg1.BASE = (DESCRIPTORREGIONSIZE + (hasGbe ? GBEREGIONSIZE_8K : 0)) >> FLREGIONBITSHIFT; /* see ../descriptor/descriptor.c */\n"); fprintf(fp, " descriptorStruct.regionSection.flReg1.reserved1 = 0x%01x;\n", descriptorStruct.regionSection.flReg1.reserved1); fprintf(fp, " /* descriptorStruct.regionSection.flReg1.LIMIT = 0x%04x; */\n", descriptorStruct.regionSection.flReg1.LIMIT); fprintf(fp, " descriptorStruct.regionSection.flReg1.LIMIT = ((romSize >> FLREGIONBITSHIFT) - 1); /* see ../descriptor/descriptor.c */\n"); @@ -317,10 +398,10 @@ int notCreatedCFileFromDescriptorStruct(struct DESCRIPTORREGIONRECORD descriptor fprintf(fp, " descriptorStruct.regionSection.flReg2.reserved2 = 0x%01x;\n", descriptorStruct.regionSection.flReg2.reserved2); fprintf(fp, " /* FLREG3 (Gbe) */\n"); fprintf(fp, " /* descriptorStruct.regionSection.flReg3.BASE = 0x%04x; */\n", descriptorStruct.regionSection.flReg3.BASE); - fprintf(fp, " descriptorStruct.regionSection.flReg3.BASE = DESCRIPTORREGIONSIZE >> FLREGIONBITSHIFT; /* see ../descriptor/descriptor.c */\n"); + fprintf(fp, " descriptorStruct.regionSection.flReg3.BASE = hasGbe ? (DESCRIPTORREGIONSIZE >> FLREGIONBITSHIFT) : 0x1fff; /* see ../descriptor/descriptor.c */\n"); fprintf(fp, " descriptorStruct.regionSection.flReg3.reserved1 = 0x%01x;\n", descriptorStruct.regionSection.flReg3.reserved1); fprintf(fp, " /* descriptorStruct.regionSection.flReg3.LIMIT = 0x%04x; */\n", descriptorStruct.regionSection.flReg3.LIMIT); - fprintf(fp, " descriptorStruct.regionSection.flReg3.LIMIT = GBEREGIONSIZE_8K >> FLREGIONBITSHIFT; /* see ../descriptor/descriptor.c */\n"); + fprintf(fp, " descriptorStruct.regionSection.flReg3.LIMIT = hasGbe ? (GBEREGIONSIZE_8K >> FLREGIONBITSHIFT) : 0x0000; /* see ../descriptor/descriptor.c */\n"); fprintf(fp, " descriptorStruct.regionSection.flReg3.reserved2 = 0x%01x;\n", descriptorStruct.regionSection.flReg3.reserved2); fprintf(fp, " /* FLREG4 (Platform) */\n"); fprintf(fp, " descriptorStruct.regionSection.flReg4.BASE = 0x%04x; /* see ../descriptor/descriptor.c */\n", descriptorStruct.regionSection.flReg4.BASE); @@ -411,8 +492,8 @@ int notCreatedCFileFromDescriptorStruct(struct DESCRIPTORREGIONRECORD descriptor fprintf(fp, " descriptorStruct.ichStraps.ichStrap0.bmcMode = 0x%01x;\n", descriptorStruct.ichStraps.ichStrap0.bmcMode); fprintf(fp, " descriptorStruct.ichStraps.ichStrap0.tripPointSelect = 0x%01x;\n", descriptorStruct.ichStraps.ichStrap0.tripPointSelect); fprintf(fp, " descriptorStruct.ichStraps.ichStrap0.reserved2 = 0x%01x;\n", descriptorStruct.ichStraps.ichStrap0.reserved2); - fprintf(fp, " descriptorStruct.ichStraps.ichStrap0.integratedGbe = 0x%01x;\n", descriptorStruct.ichStraps.ichStrap0.integratedGbe); - fprintf(fp, " descriptorStruct.ichStraps.ichStrap0.lanPhy = 0x%01x;\n", descriptorStruct.ichStraps.ichStrap0.lanPhy); + fprintf(fp, " descriptorStruct.ichStraps.ichStrap0.integratedGbe = hasGbe ? 0x1 : 0x0;\n"); + fprintf(fp, " descriptorStruct.ichStraps.ichStrap0.lanPhy = hasGbe ? 0x1 : 0x0;\n"); fprintf(fp, " descriptorStruct.ichStraps.ichStrap0.reserved3 = 0x%01x;\n", descriptorStruct.ichStraps.ichStrap0.reserved3); fprintf(fp, " descriptorStruct.ichStraps.ichStrap0.dmiRequesterId = 0x%01x;\n", descriptorStruct.ichStraps.ichStrap0.dmiRequesterId); fprintf(fp, " descriptorStruct.ichStraps.ichStrap0.smBus2Address = 0x%02x;\n", descriptorStruct.ichStraps.ichStrap0.smBus2Address); @@ -520,16 +601,6 @@ int notCreatedCFileFromDescriptorStruct(struct DESCRIPTORREGIONRECORD descriptor fprintf(fp, " return descriptorStruct;\n"); fprintf(fp, "}\n\n"); - fprintf(fp, "struct DESCRIPTORREGIONRECORD generatedDescriptorStructRom4M()\n"); - fprintf(fp, "{\n"); - fprintf(fp, " return generatedDescriptorStruct(ROMSIZE_4MB);\n"); - fprintf(fp, "}\n\n"); - - fprintf(fp, "struct DESCRIPTORREGIONRECORD generatedDescriptorStructRom8M()\n"); - fprintf(fp, "{\n"); - fprintf(fp, " return generatedDescriptorStruct(ROMSIZE_8MB);\n"); - fprintf(fp, "}\n\n"); - /* ------------------------------ */ fclose(fp); /* Always close the file when done. */ diff --git a/resources/utilities/ich9deblob/src/descriptor/descriptor.h b/resources/utilities/ich9deblob/src/descriptor/descriptor.h index 47a619c..64e381c 100644 --- a/resources/utilities/ich9deblob/src/descriptor/descriptor.h +++ b/resources/utilities/ich9deblob/src/descriptor/descriptor.h @@ -46,6 +46,14 @@ /* size of the descriptor in bytes */ #define DESCRIPTORREGIONSIZE 0x1000 +/* ROM image sizes in bytes */ +#define ROMSIZE_512KB 0x80000 +#define ROMSIZE_1MB 0x100000 +#define ROMSIZE_2MB 0x200000 +#define ROMSIZE_4MB 0x400000 +#define ROMSIZE_8MB 0x800000 +#define ROMSIZE_16MB 0x1000000 + /* * Related to the flash descriptor * bits 12(0xC)-24(0x18) are represented for words found in the flash descriptor @@ -305,11 +313,19 @@ struct DESCRIPTORREGIONRECORD struct DESCRIPTORREGIONRECORD descriptorHostRegionsUnlocked(struct DESCRIPTORREGIONRECORD descriptorStruct); struct DESCRIPTORREGIONRECORD descriptorMeRegionsForbidden(struct DESCRIPTORREGIONRECORD descriptorStruct); -struct DESCRIPTORREGIONRECORD descriptorMePlatformRegionsRemoved(struct DESCRIPTORREGIONRECORD descriptorStruct); -struct DESCRIPTORREGIONRECORD descriptorDisableMeTpm(struct DESCRIPTORREGIONRECORD descriptorStruct); +struct DESCRIPTORREGIONRECORD descriptorMeRegionRemoved(struct DESCRIPTORREGIONRECORD descriptorStruct); +struct DESCRIPTORREGIONRECORD descriptorPlatformRegionRemoved(struct DESCRIPTORREGIONRECORD descriptorStruct); +struct DESCRIPTORREGIONRECORD descriptorDisableMe(struct DESCRIPTORREGIONRECORD descriptorStruct); +struct DESCRIPTORREGIONRECORD descriptorDisableTpm(struct DESCRIPTORREGIONRECORD descriptorStruct); struct DESCRIPTORREGIONRECORD descriptorMoveGbeToStart(struct DESCRIPTORREGIONRECORD descriptorStruct); +struct DESCRIPTORREGIONRECORD descriptorGbeRegionRemoved(struct DESCRIPTORREGIONRECORD descriptorStruct); struct DESCRIPTORREGIONRECORD descriptorBiosRegionFillImageAfterGbe(struct DESCRIPTORREGIONRECORD descriptorStruct, unsigned int romSize); -struct DESCRIPTORREGIONRECORD deblobbedDescriptorStructFromFactory(struct DESCRIPTORREGIONRECORD descriptorStruct, unsigned int romSize); +struct DESCRIPTORREGIONRECORD descriptorBiosRegionFillImageAfterDescriptor(struct DESCRIPTORREGIONRECORD descriptorStruct, unsigned int romSize); +struct DESCRIPTORREGIONRECORD descriptorOemString(struct DESCRIPTORREGIONRECORD descriptorStruct); +int descriptorDefinesGbeRegion(struct DESCRIPTORREGIONRECORD descriptorStruct); +struct DESCRIPTORREGIONRECORD librebootSetGbeBiosDescriptorRegions(struct DESCRIPTORREGIONRECORD descriptorStruct, unsigned int romSize); +uint8_t componentDensity(unsigned int romSizeInBytes); +struct DESCRIPTORREGIONRECORD librebootDescriptorStructFromFactory(struct DESCRIPTORREGIONRECORD descriptorStruct, unsigned int romSize); int notCreatedHFileForDescriptorCFile(char* outFileName, char* cFileName); int notCreatedCFileFromDescriptorStruct(struct DESCRIPTORREGIONRECORD descriptorStruct, char* outFileName, char* headerFileName); void printDescriptorRegionLocations(struct DESCRIPTORREGIONRECORD descriptorStruct, char* romName); |