[PATCH v1 1/1] Tools/FitGen: Fix microcode alignment support


Aaron Li
 

BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2971

This patch is to fix a issue that "-A" option would only support
2^n Byte alignment of microcode.

Signed-off-by: Aaron Li <aaron.li@intel.com>
Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
---
Silicon/Intel/Tools/FitGen/FitGen.c | 2 +-
Silicon/Intel/Tools/FitGen/FitGen.h | 4 +++-
2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/Silicon/Intel/Tools/FitGen/FitGen.c b/Silicon/Intel/Tools/FitG=
en/FitGen.c
index c4006e69c822..4caaf70ee018 100644
--- a/Silicon/Intel/Tools/FitGen/FitGen.c
+++ b/Silicon/Intel/Tools/FitGen/FitGen.c
@@ -1176,7 +1176,7 @@ Returns:
// MCU might be put at 2KB alignment, if so, we need to ad=
just the size as 2KB alignment.=0D
//=0D
if (gFitTableContext.MicrocodeIsAligned) {=0D
- MicrocodeSize =3D (*(UINT32 *)(MicrocodeBuffer + 32) + (=
gFitTableContext.MicrocodeAlignValue - 1)) & ~(gFitTableContext.MicrocodeAl=
ignValue - 1);=0D
+ MicrocodeSize =3D ROUNDUP (*(UINT32 *)(MicrocodeBuffer +=
32), gFitTableContext.MicrocodeAlignValue);=0D
} else {=0D
MicrocodeSize =3D (*(UINT32 *)(MicrocodeBuffer + 32));=0D
}=0D
diff --git a/Silicon/Intel/Tools/FitGen/FitGen.h b/Silicon/Intel/Tools/FitG=
en/FitGen.h
index abad2d8799c8..435fc26209da 100644
--- a/Silicon/Intel/Tools/FitGen/FitGen.h
+++ b/Silicon/Intel/Tools/FitGen/FitGen.h
@@ -31,7 +31,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
// Utility version information=0D
//=0D
#define UTILITY_MAJOR_VERSION 0=0D
-#define UTILITY_MINOR_VERSION 62=0D
+#define UTILITY_MINOR_VERSION 63=0D
#define UTILITY_DATE __DATE__=0D
=0D
//=0D
@@ -45,4 +45,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
(ActualSize) + (((Alignment) - ((ActualSize) & ((Alignment) - 1))) & ((A=
lignment) - 1))=0D
;=0D
=0D
+#define ROUNDUP(Size, Alignment) (((Size) + (Alignment) - 1) / (Alignment)=
* (Alignment))=0D
+=0D
#endif=0D
--=20
2.23.0.windows.1

Join devel@edk2.groups.io to automatically receive all group messages.