diff options
Diffstat (limited to 'MdeModulePkg/Library')
166 files changed, 16317 insertions, 14521 deletions
diff --git a/MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.c b/MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.c index b6922d3dc0..480560b4cf 100644 --- a/MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.c +++ b/MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.c @@ -59,11 +59,11 @@ AuthVariableLibInitialize ( EFI_STATUS
EFIAPI
AuthVariableLibProcessVariable (
- IN CHAR16 *VariableName,
- IN EFI_GUID *VendorGuid,
- IN VOID *Data,
- IN UINTN DataSize,
- IN UINT32 Attributes
+ IN CHAR16 *VariableName,
+ IN EFI_GUID *VendorGuid,
+ IN VOID *Data,
+ IN UINTN DataSize,
+ IN UINT32 Attributes
)
{
ASSERT (FALSE);
diff --git a/MdeModulePkg/Library/BaseBmpSupportLib/BmpSupportLib.c b/MdeModulePkg/Library/BaseBmpSupportLib/BmpSupportLib.c index 3ac31f6723..c5e885d7a6 100644 --- a/MdeModulePkg/Library/BaseBmpSupportLib/BmpSupportLib.c +++ b/MdeModulePkg/Library/BaseBmpSupportLib/BmpSupportLib.c @@ -31,22 +31,22 @@ // BMP Image header for an uncompressed 24-bit per pixel BMP image.
//
const BMP_IMAGE_HEADER mBmpImageHeaderTemplate = {
- 'B', // CharB
- 'M', // CharM
- 0, // Size will be updated at runtime
- {0, 0}, // Reserved
- sizeof (BMP_IMAGE_HEADER), // ImageOffset
+ 'B', // CharB
+ 'M', // CharM
+ 0, // Size will be updated at runtime
+ { 0, 0 }, // Reserved
+ sizeof (BMP_IMAGE_HEADER), // ImageOffset
sizeof (BMP_IMAGE_HEADER) - OFFSET_OF (BMP_IMAGE_HEADER, HeaderSize), // HeaderSize
- 0, // PixelWidth will be updated at runtime
- 0, // PixelHeight will be updated at runtime
- 1, // Planes
- 24, // BitPerPixel
- 0, // CompressionType
- 0, // ImageSize will be updated at runtime
- 0, // XPixelsPerMeter
- 0, // YPixelsPerMeter
- 0, // NumberOfColors
- 0 // ImportantColors
+ 0, // PixelWidth will be updated at runtime
+ 0, // PixelHeight will be updated at runtime
+ 1, // Planes
+ 24, // BitPerPixel
+ 0, // CompressionType
+ 0, // ImageSize will be updated at runtime
+ 0, // XPixelsPerMeter
+ 0, // YPixelsPerMeter
+ 0, // NumberOfColors
+ 0 // ImportantColors
};
/**
@@ -104,10 +104,11 @@ TranslateBmpToGopBlt ( UINT32 DataSize;
UINT32 Temp;
- if (BmpImage == NULL || GopBlt == NULL || GopBltSize == NULL) {
+ if ((BmpImage == NULL) || (GopBlt == NULL) || (GopBltSize == NULL)) {
return RETURN_INVALID_PARAMETER;
}
- if (PixelHeight == NULL || PixelWidth == NULL) {
+
+ if ((PixelHeight == NULL) || (PixelWidth == NULL)) {
return RETURN_INVALID_PARAMETER;
}
@@ -118,7 +119,7 @@ TranslateBmpToGopBlt ( BmpHeader = (BMP_IMAGE_HEADER *)BmpImage;
- if (BmpHeader->CharB != 'B' || BmpHeader->CharM != 'M') {
+ if ((BmpHeader->CharB != 'B') || (BmpHeader->CharM != 'M')) {
DEBUG ((DEBUG_ERROR, "TranslateBmpToGopBlt: BmpHeader->Char fields incorrect\n"));
return RETURN_UNSUPPORTED;
}
@@ -179,17 +180,18 @@ TranslateBmpToGopBlt ( }
DataSizePerLine = (DataSizePerLine >> 3) &(~0x3);
- Status = SafeUint32Mult (
- DataSizePerLine,
- BmpHeader->PixelHeight,
- &BltBufferSize
- );
+ Status = SafeUint32Mult (
+ DataSizePerLine,
+ BmpHeader->PixelHeight,
+ &BltBufferSize
+ );
if (EFI_ERROR (Status)) {
DEBUG ((
DEBUG_ERROR,
"TranslateBmpToGopBlt: invalid BmpImage... DataSizePerLine:0x%x PixelHeight:0x%x\n",
- DataSizePerLine, BmpHeader->PixelHeight
+ DataSizePerLine,
+ BmpHeader->PixelHeight
));
return RETURN_UNSUPPORTED;
@@ -205,7 +207,8 @@ TranslateBmpToGopBlt ( DEBUG ((
DEBUG_ERROR,
"TranslateBmpToGopBlt: invalid BmpImage... PixelHeight:0x%x DataSizePerLine:0x%x\n",
- BmpHeader->PixelHeight, DataSizePerLine
+ BmpHeader->PixelHeight,
+ DataSizePerLine
));
return RETURN_UNSUPPORTED;
@@ -213,8 +216,8 @@ TranslateBmpToGopBlt ( if ((BmpHeader->Size != BmpImageSize) ||
(BmpHeader->Size < BmpHeader->ImageOffset) ||
- (BmpHeader->Size - BmpHeader->ImageOffset != DataSize)) {
-
+ (BmpHeader->Size - BmpHeader->ImageOffset != DataSize))
+ {
DEBUG ((DEBUG_ERROR, "TranslateBmpToGopBlt: invalid BmpImage... \n"));
DEBUG ((DEBUG_ERROR, " BmpHeader->Size: 0x%x\n", BmpHeader->Size));
DEBUG ((DEBUG_ERROR, " BmpHeader->ImageOffset: 0x%x\n", BmpHeader->ImageOffset));
@@ -227,7 +230,7 @@ TranslateBmpToGopBlt ( //
// Calculate Color Map offset in the image.
//
- Image = BmpImage;
+ Image = BmpImage;
BmpColorMap = (BMP_COLOR_MAP *)(Image + sizeof (BMP_IMAGE_HEADER));
if (BmpHeader->ImageOffset < sizeof (BMP_IMAGE_HEADER)) {
return RETURN_UNSUPPORTED;
@@ -235,19 +238,20 @@ TranslateBmpToGopBlt ( if (BmpHeader->ImageOffset > sizeof (BMP_IMAGE_HEADER)) {
switch (BmpHeader->BitPerPixel) {
- case 1:
- ColorMapNum = 2;
- break;
- case 4:
- ColorMapNum = 16;
- break;
- case 8:
- ColorMapNum = 256;
- break;
- default:
- ColorMapNum = 0;
- break;
+ case 1:
+ ColorMapNum = 2;
+ break;
+ case 4:
+ ColorMapNum = 16;
+ break;
+ case 8:
+ ColorMapNum = 256;
+ break;
+ default:
+ ColorMapNum = 0;
+ break;
}
+
//
// BMP file may has padding data between the bmp header section and the
// bmp data section.
@@ -260,7 +264,7 @@ TranslateBmpToGopBlt ( //
// Calculate graphics image data address in the image
//
- Image = ((UINT8 *)BmpImage) + BmpHeader->ImageOffset;
+ Image = ((UINT8 *)BmpImage) + BmpHeader->ImageOffset;
ImageHeader = Image;
//
@@ -276,13 +280,14 @@ TranslateBmpToGopBlt ( DEBUG ((
DEBUG_ERROR,
"TranslateBmpToGopBlt: invalid BltBuffer needed size... PixelWidth:0x%x PixelHeight:0x%x\n",
- BmpHeader->PixelWidth, BmpHeader->PixelHeight
+ BmpHeader->PixelWidth,
+ BmpHeader->PixelHeight
));
return RETURN_UNSUPPORTED;
}
- Temp = BltBufferSize;
+ Temp = BltBufferSize;
Status = SafeUint32Mult (
BltBufferSize,
sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL),
@@ -293,7 +298,8 @@ TranslateBmpToGopBlt ( DEBUG ((
DEBUG_ERROR,
"TranslateBmpToGopBlt: invalid BltBuffer needed size... PixelWidth x PixelHeight:0x%x struct size:0x%x\n",
- Temp, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)
+ Temp,
+ sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)
));
return RETURN_UNSUPPORTED;
@@ -306,7 +312,7 @@ TranslateBmpToGopBlt ( //
DEBUG ((DEBUG_INFO, "Bmp Support: Allocating 0x%X bytes of memory\n", BltBufferSize));
*GopBltSize = (UINTN)BltBufferSize;
- *GopBlt = AllocatePool (*GopBltSize);
+ *GopBlt = AllocatePool (*GopBltSize);
IsAllocated = TRUE;
if (*GopBlt == NULL) {
return RETURN_OUT_OF_RESOURCES;
@@ -336,82 +342,83 @@ TranslateBmpToGopBlt ( //
BltBuffer = *GopBlt;
for (Height = 0; Height < BmpHeader->PixelHeight; Height++) {
- Blt = &BltBuffer[ (BmpHeader->PixelHeight - Height - 1) * BmpHeader->PixelWidth];
+ Blt = &BltBuffer[(BmpHeader->PixelHeight - Height - 1) * BmpHeader->PixelWidth];
for (Width = 0; Width < BmpHeader->PixelWidth; Width++, Image++, Blt++) {
switch (BmpHeader->BitPerPixel) {
- case 1:
- //
- // Translate 1-bit (2 colors) BMP to 24-bit color
- //
- for (Index = 0; Index < 8 && Width < BmpHeader->PixelWidth; Index++) {
- Blt->Red = BmpColorMap[ ((*Image) >> (7 - Index)) & 0x1].Red;
- Blt->Green = BmpColorMap[ ((*Image) >> (7 - Index)) & 0x1].Green;
- Blt->Blue = BmpColorMap[ ((*Image) >> (7 - Index)) & 0x1].Blue;
- Blt++;
- Width++;
- }
-
- Blt--;
- Width--;
- break;
-
- case 4:
- //
- // Translate 4-bit (16 colors) BMP Palette to 24-bit color
- //
- Index = (*Image) >> 4;
- Blt->Red = BmpColorMap[Index].Red;
- Blt->Green = BmpColorMap[Index].Green;
- Blt->Blue = BmpColorMap[Index].Blue;
- if (Width < (BmpHeader->PixelWidth - 1)) {
- Blt++;
- Width++;
- Index = (*Image) & 0x0f;
+ case 1:
+ //
+ // Translate 1-bit (2 colors) BMP to 24-bit color
+ //
+ for (Index = 0; Index < 8 && Width < BmpHeader->PixelWidth; Index++) {
+ Blt->Red = BmpColorMap[((*Image) >> (7 - Index)) & 0x1].Red;
+ Blt->Green = BmpColorMap[((*Image) >> (7 - Index)) & 0x1].Green;
+ Blt->Blue = BmpColorMap[((*Image) >> (7 - Index)) & 0x1].Blue;
+ Blt++;
+ Width++;
+ }
+
+ Blt--;
+ Width--;
+ break;
+
+ case 4:
+ //
+ // Translate 4-bit (16 colors) BMP Palette to 24-bit color
+ //
+ Index = (*Image) >> 4;
Blt->Red = BmpColorMap[Index].Red;
Blt->Green = BmpColorMap[Index].Green;
Blt->Blue = BmpColorMap[Index].Blue;
- }
- break;
-
- case 8:
- //
- // Translate 8-bit (256 colors) BMP Palette to 24-bit color
- //
- Blt->Red = BmpColorMap[*Image].Red;
- Blt->Green = BmpColorMap[*Image].Green;
- Blt->Blue = BmpColorMap[*Image].Blue;
- break;
-
- case 24:
- //
- // It is 24-bit BMP.
- //
- Blt->Blue = *Image++;
- Blt->Green = *Image++;
- Blt->Red = *Image;
- break;
-
- case 32:
- //
- //Conver 32 bit to 24bit bmp - just ignore the final byte of each pixel
- Blt->Blue = *Image++;
- Blt->Green = *Image++;
- Blt->Red = *Image++;
- break;
-
- default:
- //
- // Other bit format BMP is not supported.
- //
- if (IsAllocated) {
- FreePool (*GopBlt);
- *GopBlt = NULL;
- }
- DEBUG ((DEBUG_ERROR, "Bmp Bit format not supported. 0x%X\n", BmpHeader->BitPerPixel));
- return RETURN_UNSUPPORTED;
- break;
- };
-
+ if (Width < (BmpHeader->PixelWidth - 1)) {
+ Blt++;
+ Width++;
+ Index = (*Image) & 0x0f;
+ Blt->Red = BmpColorMap[Index].Red;
+ Blt->Green = BmpColorMap[Index].Green;
+ Blt->Blue = BmpColorMap[Index].Blue;
+ }
+
+ break;
+
+ case 8:
+ //
+ // Translate 8-bit (256 colors) BMP Palette to 24-bit color
+ //
+ Blt->Red = BmpColorMap[*Image].Red;
+ Blt->Green = BmpColorMap[*Image].Green;
+ Blt->Blue = BmpColorMap[*Image].Blue;
+ break;
+
+ case 24:
+ //
+ // It is 24-bit BMP.
+ //
+ Blt->Blue = *Image++;
+ Blt->Green = *Image++;
+ Blt->Red = *Image;
+ break;
+
+ case 32:
+ //
+ // Conver 32 bit to 24bit bmp - just ignore the final byte of each pixel
+ Blt->Blue = *Image++;
+ Blt->Green = *Image++;
+ Blt->Red = *Image++;
+ break;
+
+ default:
+ //
+ // Other bit format BMP is not supported.
+ //
+ if (IsAllocated) {
+ FreePool (*GopBlt);
+ *GopBlt = NULL;
+ }
+
+ DEBUG ((DEBUG_ERROR, "Bmp Bit format not supported. 0x%X\n", BmpHeader->BitPerPixel));
+ return RETURN_UNSUPPORTED;
+ break;
+ }
}
ImageIndex = (UINTN)Image - (UINTN)ImageHeader;
@@ -468,7 +475,7 @@ TranslateGopBltToBmp ( UINTN Row;
EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltPixel;
- if (GopBlt == NULL || BmpImage == NULL || BmpImageSize == NULL) {
+ if ((GopBlt == NULL) || (BmpImage == NULL) || (BmpImageSize == NULL)) {
return RETURN_INVALID_PARAMETER;
}
@@ -494,6 +501,7 @@ TranslateGopBltToBmp ( ));
return RETURN_UNSUPPORTED;
}
+
Status = SafeUint32Add (BmpSize, PaddingSize, &BmpSize);
if (EFI_ERROR (Status)) {
DEBUG ((
@@ -518,6 +526,7 @@ TranslateGopBltToBmp ( ));
return RETURN_UNSUPPORTED;
}
+
Status = SafeUint32Add (BmpSize, sizeof (BMP_IMAGE_HEADER), &BmpSize);
if (EFI_ERROR (Status)) {
DEBUG ((
@@ -538,6 +547,7 @@ TranslateGopBltToBmp ( if (*BmpImage == NULL) {
return EFI_OUT_OF_RESOURCES;
}
+
*BmpImageSize = BmpSize;
} else if (*BmpImageSize < BmpSize) {
*BmpImageSize = BmpSize;
diff --git a/MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.c b/MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.c index 41ff4412ce..4dc73fa282 100644 --- a/MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.c +++ b/MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.c @@ -59,8 +59,8 @@ GetHobList ( VOID *
EFIAPI
GetNextHob (
- IN UINT16 Type,
- IN CONST VOID *HobStart
+ IN UINT16 Type,
+ IN CONST VOID *HobStart
)
{
ASSERT (FALSE);
@@ -83,7 +83,7 @@ GetNextHob ( VOID *
EFIAPI
GetFirstHob (
- IN UINT16 Type
+ IN UINT16 Type
)
{
ASSERT (FALSE);
@@ -115,8 +115,8 @@ GetFirstHob ( VOID *
EFIAPI
GetNextGuidHob (
- IN CONST EFI_GUID *Guid,
- IN CONST VOID *HobStart
+ IN CONST EFI_GUID *Guid,
+ IN CONST VOID *HobStart
)
{
ASSERT (FALSE);
@@ -144,7 +144,7 @@ GetNextGuidHob ( VOID *
EFIAPI
GetFirstGuidHob (
- IN CONST EFI_GUID *Guid
+ IN CONST EFI_GUID *Guid
)
{
ASSERT (FALSE);
@@ -193,10 +193,10 @@ GetBootModeHob ( VOID
EFIAPI
BuildModuleHob (
- IN CONST EFI_GUID *ModuleName,
- IN EFI_PHYSICAL_ADDRESS MemoryAllocationModule,
- IN UINT64 ModuleLength,
- IN EFI_PHYSICAL_ADDRESS EntryPoint
+ IN CONST EFI_GUID *ModuleName,
+ IN EFI_PHYSICAL_ADDRESS MemoryAllocationModule,
+ IN UINT64 ModuleLength,
+ IN EFI_PHYSICAL_ADDRESS EntryPoint
)
{
ASSERT (FALSE);
@@ -283,8 +283,8 @@ BuildResourceDescriptorHob ( VOID *
EFIAPI
BuildGuidHob (
- IN CONST EFI_GUID *Guid,
- IN UINTN DataLength
+ IN CONST EFI_GUID *Guid,
+ IN UINTN DataLength
)
{
ASSERT (FALSE);
@@ -319,9 +319,9 @@ BuildGuidHob ( VOID *
EFIAPI
BuildGuidDataHob (
- IN CONST EFI_GUID *Guid,
- IN VOID *Data,
- IN UINTN DataLength
+ IN CONST EFI_GUID *Guid,
+ IN VOID *Data,
+ IN UINTN DataLength
)
{
ASSERT (FALSE);
@@ -345,8 +345,8 @@ BuildGuidDataHob ( VOID
EFIAPI
BuildFvHob (
- IN EFI_PHYSICAL_ADDRESS BaseAddress,
- IN UINT64 Length
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length
)
{
ASSERT (FALSE);
@@ -371,10 +371,10 @@ BuildFvHob ( VOID
EFIAPI
BuildFv2Hob (
- IN EFI_PHYSICAL_ADDRESS BaseAddress,
- IN UINT64 Length,
- IN CONST EFI_GUID *FvName,
- IN CONST EFI_GUID *FileName
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length,
+ IN CONST EFI_GUID *FvName,
+ IN CONST EFI_GUID *FileName
)
{
ASSERT (FALSE);
@@ -404,12 +404,12 @@ BuildFv2Hob ( VOID
EFIAPI
BuildFv3Hob (
- IN EFI_PHYSICAL_ADDRESS BaseAddress,
- IN UINT64 Length,
- IN UINT32 AuthenticationStatus,
- IN BOOLEAN ExtractedFv,
- IN CONST EFI_GUID *FvName OPTIONAL,
- IN CONST EFI_GUID *FileName OPTIONAL
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length,
+ IN UINT32 AuthenticationStatus,
+ IN BOOLEAN ExtractedFv,
+ IN CONST EFI_GUID *FvName OPTIONAL,
+ IN CONST EFI_GUID *FileName OPTIONAL
)
{
ASSERT (FALSE);
@@ -432,8 +432,8 @@ BuildFv3Hob ( VOID
EFIAPI
BuildCvHob (
- IN EFI_PHYSICAL_ADDRESS BaseAddress,
- IN UINT64 Length
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length
)
{
ASSERT (FALSE);
@@ -455,8 +455,8 @@ BuildCvHob ( VOID
EFIAPI
BuildCpuHob (
- IN UINT8 SizeOfMemorySpace,
- IN UINT8 SizeOfIoSpace
+ IN UINT8 SizeOfMemorySpace,
+ IN UINT8 SizeOfIoSpace
)
{
ASSERT (FALSE);
@@ -478,8 +478,8 @@ BuildCpuHob ( VOID
EFIAPI
BuildStackHob (
- IN EFI_PHYSICAL_ADDRESS BaseAddress,
- IN UINT64 Length
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length
)
{
ASSERT (FALSE);
@@ -502,9 +502,9 @@ BuildStackHob ( VOID
EFIAPI
BuildBspStoreHob (
- IN EFI_PHYSICAL_ADDRESS BaseAddress,
- IN UINT64 Length,
- IN EFI_MEMORY_TYPE MemoryType
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length,
+ IN EFI_MEMORY_TYPE MemoryType
)
{
ASSERT (FALSE);
@@ -527,9 +527,9 @@ BuildBspStoreHob ( VOID
EFIAPI
BuildMemoryAllocationHob (
- IN EFI_PHYSICAL_ADDRESS BaseAddress,
- IN UINT64 Length,
- IN EFI_MEMORY_TYPE MemoryType
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length,
+ IN EFI_MEMORY_TYPE MemoryType
)
{
ASSERT (FALSE);
diff --git a/MdeModulePkg/Library/BaseIpmiLibNull/BaseIpmiLibNull.c b/MdeModulePkg/Library/BaseIpmiLibNull/BaseIpmiLibNull.c index 44ad5ed5b4..68ac802efa 100644 --- a/MdeModulePkg/Library/BaseIpmiLibNull/BaseIpmiLibNull.c +++ b/MdeModulePkg/Library/BaseIpmiLibNull/BaseIpmiLibNull.c @@ -10,7 +10,6 @@ #include <Library/DebugLib.h>
#include <Library/IpmiLib.h>
-
/**
This service enables submitting commands via Ipmi.
@@ -32,12 +31,12 @@ EFI_STATUS
EFIAPI
IpmiSubmitCommand (
- IN UINT8 NetFunction,
- IN UINT8 Command,
- IN UINT8 *RequestData,
- IN UINT32 RequestDataSize,
- OUT UINT8 *ResponseData,
- IN OUT UINT32 *ResponseDataSize
+ IN UINT8 NetFunction,
+ IN UINT8 Command,
+ IN UINT8 *RequestData,
+ IN UINT32 RequestDataSize,
+ OUT UINT8 *ResponseData,
+ IN OUT UINT32 *ResponseDataSize
)
{
//
diff --git a/MdeModulePkg/Library/BaseMemoryAllocationLibNull/BaseMemoryAllocationLibNull.c b/MdeModulePkg/Library/BaseMemoryAllocationLibNull/BaseMemoryAllocationLibNull.c index 4079472e82..3061ec6cd0 100644 --- a/MdeModulePkg/Library/BaseMemoryAllocationLibNull/BaseMemoryAllocationLibNull.c +++ b/MdeModulePkg/Library/BaseMemoryAllocationLibNull/BaseMemoryAllocationLibNull.c @@ -7,13 +7,11 @@ **/
-
#include <Uefi/UefiBaseType.h>
#include <Library/DebugLib.h>
#include <Library/MemoryAllocationLib.h>
-
/**
Allocates one or more 4KB pages of type EfiBootServicesData.
@@ -562,7 +560,7 @@ ReallocateReservedPool ( VOID
EFIAPI
FreePool (
- IN VOID *Buffer
+ IN VOID *Buffer
)
{
ASSERT (FALSE);
diff --git a/MdeModulePkg/Library/BasePlatformHookLibNull/BasePlatformHookLibNull.c b/MdeModulePkg/Library/BasePlatformHookLibNull/BasePlatformHookLibNull.c index a33f1ddd7b..1942031d66 100644 --- a/MdeModulePkg/Library/BasePlatformHookLibNull/BasePlatformHookLibNull.c +++ b/MdeModulePkg/Library/BasePlatformHookLibNull/BasePlatformHookLibNull.c @@ -26,6 +26,5 @@ PlatformHookSerialPortInitialize ( VOID
)
{
- return RETURN_SUCCESS;
+ return RETURN_SUCCESS;
}
-
diff --git a/MdeModulePkg/Library/BaseResetSystemLibNull/BaseResetSystemLibNull.c b/MdeModulePkg/Library/BaseResetSystemLibNull/BaseResetSystemLibNull.c index 33a896bee0..c34a968d9b 100644 --- a/MdeModulePkg/Library/BaseResetSystemLibNull/BaseResetSystemLibNull.c +++ b/MdeModulePkg/Library/BaseResetSystemLibNull/BaseResetSystemLibNull.c @@ -72,8 +72,8 @@ ResetShutdown ( VOID
EFIAPI
ResetPlatformSpecific (
- IN UINTN DataSize,
- IN VOID *ResetData
+ IN UINTN DataSize,
+ IN VOID *ResetData
)
{
ResetCold ();
@@ -94,12 +94,11 @@ ResetPlatformSpecific ( VOID
EFIAPI
ResetSystem (
- IN EFI_RESET_TYPE ResetType,
- IN EFI_STATUS ResetStatus,
- IN UINTN DataSize,
- IN VOID *ResetData OPTIONAL
+ IN EFI_RESET_TYPE ResetType,
+ IN EFI_STATUS ResetStatus,
+ IN UINTN DataSize,
+ IN VOID *ResetData OPTIONAL
)
{
ASSERT (FALSE);
}
-
diff --git a/MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.c b/MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.c index 10e053076a..e413cea4b3 100644 --- a/MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.c +++ b/MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.c @@ -22,41 +22,41 @@ //
// PCI Defintions.
//
-#define PCI_BRIDGE_32_BIT_IO_SPACE 0x01
+#define PCI_BRIDGE_32_BIT_IO_SPACE 0x01
//
// 16550 UART register offsets and bitfields
//
-#define R_UART_RXBUF 0 // LCR_DLAB = 0
-#define R_UART_TXBUF 0 // LCR_DLAB = 0
-#define R_UART_BAUD_LOW 0 // LCR_DLAB = 1
-#define R_UART_BAUD_HIGH 1 // LCR_DLAB = 1
-#define R_UART_IER 1 // LCR_DLAB = 0
-#define R_UART_FCR 2
-#define B_UART_FCR_FIFOE BIT0
-#define B_UART_FCR_FIFO64 BIT5
-#define R_UART_LCR 3
-#define B_UART_LCR_DLAB BIT7
-#define R_UART_MCR 4
-#define B_UART_MCR_DTRC BIT0
-#define B_UART_MCR_RTS BIT1
-#define R_UART_LSR 5
-#define B_UART_LSR_RXRDY BIT0
-#define B_UART_LSR_TXRDY BIT5
-#define B_UART_LSR_TEMT BIT6
-#define R_UART_MSR 6
-#define B_UART_MSR_CTS BIT4
-#define B_UART_MSR_DSR BIT5
-#define B_UART_MSR_RI BIT6
-#define B_UART_MSR_DCD BIT7
+#define R_UART_RXBUF 0 // LCR_DLAB = 0
+#define R_UART_TXBUF 0 // LCR_DLAB = 0
+#define R_UART_BAUD_LOW 0 // LCR_DLAB = 1
+#define R_UART_BAUD_HIGH 1 // LCR_DLAB = 1
+#define R_UART_IER 1 // LCR_DLAB = 0
+#define R_UART_FCR 2
+#define B_UART_FCR_FIFOE BIT0
+#define B_UART_FCR_FIFO64 BIT5
+#define R_UART_LCR 3
+#define B_UART_LCR_DLAB BIT7
+#define R_UART_MCR 4
+#define B_UART_MCR_DTRC BIT0
+#define B_UART_MCR_RTS BIT1
+#define R_UART_LSR 5
+#define B_UART_LSR_RXRDY BIT0
+#define B_UART_LSR_TXRDY BIT5
+#define B_UART_LSR_TEMT BIT6
+#define R_UART_MSR 6
+#define B_UART_MSR_CTS BIT4
+#define B_UART_MSR_DSR BIT5
+#define B_UART_MSR_RI BIT6
+#define B_UART_MSR_DCD BIT7
//
// 4-byte structure for each PCI node in PcdSerialPciDeviceInfo
//
typedef struct {
- UINT8 Device;
- UINT8 Function;
- UINT16 PowerManagementStatusAndControlRegister;
+ UINT8 Device;
+ UINT8 Function;
+ UINT16 PowerManagementStatusAndControlRegister;
} PCI_UART_DEVICE_INFO;
/**
@@ -80,8 +80,9 @@ SerialPortReadRegister ( {
if (PcdGetBool (PcdSerialUseMmio)) {
if (PcdGet8 (PcdSerialRegisterAccessWidth) == 32) {
- return (UINT8) MmioRead32 (Base + Offset * PcdGet32 (PcdSerialRegisterStride));
+ return (UINT8)MmioRead32 (Base + Offset * PcdGet32 (PcdSerialRegisterStride));
}
+
return MmioRead8 (Base + Offset * PcdGet32 (PcdSerialRegisterStride));
} else {
return IoRead8 (Base + Offset * PcdGet32 (PcdSerialRegisterStride));
@@ -111,8 +112,9 @@ SerialPortWriteRegister ( {
if (PcdGetBool (PcdSerialUseMmio)) {
if (PcdGet8 (PcdSerialRegisterAccessWidth) == 32) {
- return (UINT8) MmioWrite32 (Base + Offset * PcdGet32 (PcdSerialRegisterStride), (UINT8)Value);
+ return (UINT8)MmioWrite32 (Base + Offset * PcdGet32 (PcdSerialRegisterStride), (UINT8)Value);
}
+
return MmioWrite8 (Base + Offset * PcdGet32 (PcdSerialRegisterStride), Value);
} else {
return IoWrite8 (Base + Offset * PcdGet32 (PcdSerialRegisterStride), Value);
@@ -145,6 +147,7 @@ SerialPortLibUpdatePciRegister16 ( if (CurrentValue != 0) {
return CurrentValue;
}
+
return PciWrite16 (PciAddress, Value & Mask);
}
@@ -176,6 +179,7 @@ SerialPortLibUpdatePciRegister32 ( if (CurrentValue != 0) {
return CurrentValue;
}
+
return PciWrite32 (PciAddress, Value & Mask);
}
@@ -212,7 +216,7 @@ GetSerialRegisterBase ( //
// Get PCI Device Info
//
- DeviceInfo = (PCI_UART_DEVICE_INFO *) PcdGetPtr (PcdSerialPciDeviceInfo);
+ DeviceInfo = (PCI_UART_DEVICE_INFO *)PcdGetPtr (PcdSerialPciDeviceInfo);
//
// If PCI Device Info is empty, then assume fixed address UART and return PcdSerialRegisterBase
@@ -244,7 +248,7 @@ GetSerialRegisterBase ( //
BusNumber = PciRead8 (PciLibAddress + PCI_BRIDGE_SECONDARY_BUS_REGISTER_OFFSET);
SubordinateBusNumber = PciRead8 (PciLibAddress + PCI_BRIDGE_SUBORDINATE_BUS_REGISTER_OFFSET);
- if (BusNumber == 0 || BusNumber > SubordinateBusNumber) {
+ if ((BusNumber == 0) || (BusNumber > SubordinateBusNumber)) {
return 0;
}
@@ -265,20 +269,22 @@ GetSerialRegisterBase ( //
// If PCI Bridge MMIO window is not in the address range decoded by the parent PCI Bridge, then return 0
//
- if (MemoryBase < ParentMemoryBase || MemoryBase > ParentMemoryLimit || MemoryLimit > ParentMemoryLimit) {
+ if ((MemoryBase < ParentMemoryBase) || (MemoryBase > ParentMemoryLimit) || (MemoryLimit > ParentMemoryLimit)) {
return 0;
}
+
ParentMemoryBase = MemoryBase;
ParentMemoryLimit = MemoryLimit;
} else {
IoLimit = PciRead8 (PciLibAddress + OFFSET_OF (PCI_TYPE01, Bridge.IoLimit));
- if ((IoLimit & PCI_BRIDGE_32_BIT_IO_SPACE ) == 0) {
+ if ((IoLimit & PCI_BRIDGE_32_BIT_IO_SPACE) == 0) {
IoLimit = IoLimit >> 4;
} else {
IoLimit = (PciRead16 (PciLibAddress + OFFSET_OF (PCI_TYPE01, Bridge.IoLimitUpper16)) << 4) | (IoLimit >> 4);
}
+
IoBase = PciRead8 (PciLibAddress + OFFSET_OF (PCI_TYPE01, Bridge.IoBase));
- if ((IoBase & PCI_BRIDGE_32_BIT_IO_SPACE ) == 0) {
+ if ((IoBase & PCI_BRIDGE_32_BIT_IO_SPACE) == 0) {
IoBase = IoBase >> 4;
} else {
IoBase = (PciRead16 (PciLibAddress + OFFSET_OF (PCI_TYPE01, Bridge.IoBaseUpper16)) << 4) | (IoBase >> 4);
@@ -294,9 +300,10 @@ GetSerialRegisterBase ( //
// If PCI Bridge I/O window is not in the address range decoded by the parent PCI Bridge, then return 0
//
- if (IoBase < ParentIoBase || IoBase > ParentIoLimit || IoLimit > ParentIoLimit) {
+ if ((IoBase < ParentIoBase) || (IoBase > ParentIoLimit) || (IoLimit > ParentIoLimit)) {
return 0;
}
+
ParentIoBase = IoBase;
ParentIoLimit = IoLimit;
}
@@ -311,7 +318,7 @@ GetSerialRegisterBase ( // Find the first IO or MMIO BAR
//
RegisterBaseMask = 0xFFFFFFF0;
- for (BarIndex = 0; BarIndex < PCI_MAX_BAR; BarIndex ++) {
+ for (BarIndex = 0; BarIndex < PCI_MAX_BAR; BarIndex++) {
SerialRegisterBase = PciRead32 (PciLibAddress + PCI_BASE_ADDRESSREG_OFFSET + BarIndex * 4);
if (PcdGetBool (PcdSerialUseMmio) && ((SerialRegisterBase & BIT0) == 0)) {
//
@@ -350,11 +357,11 @@ GetSerialRegisterBase ( // Verify that the UART BAR is in the address range decoded by the parent PCI Bridge
//
if (PcdGetBool (PcdSerialUseMmio)) {
- if (((SerialRegisterBase >> 16) & 0xfff0) < ParentMemoryBase || ((SerialRegisterBase >> 16) & 0xfff0) > ParentMemoryLimit) {
+ if ((((SerialRegisterBase >> 16) & 0xfff0) < ParentMemoryBase) || (((SerialRegisterBase >> 16) & 0xfff0) > ParentMemoryLimit)) {
return 0;
}
} else {
- if ((SerialRegisterBase >> 12) < ParentIoBase || (SerialRegisterBase >> 12) > ParentIoLimit) {
+ if (((SerialRegisterBase >> 12) < ParentIoBase) || ((SerialRegisterBase >> 12) > ParentIoLimit)) {
return 0;
}
}
@@ -372,7 +379,7 @@ GetSerialRegisterBase ( //
if (DeviceInfo->PowerManagementStatusAndControlRegister != 0x00) {
if ((PciRead16 (PciLibAddress + DeviceInfo->PowerManagementStatusAndControlRegister) & (BIT0 | BIT1)) != 0x00) {
- PciAnd16 (PciLibAddress + DeviceInfo->PowerManagementStatusAndControlRegister, (UINT16)~(BIT0 | BIT1));
+ PciAnd16 (PciLibAddress + DeviceInfo->PowerManagementStatusAndControlRegister, (UINT16) ~(BIT0 | BIT1));
//
// If PCI UART was not in D0, then make sure FIFOs are enabled, but do not reset FIFOs
//
@@ -383,7 +390,7 @@ GetSerialRegisterBase ( //
// Get PCI Device Info
//
- DeviceInfo = (PCI_UART_DEVICE_INFO *) PcdGetPtr (PcdSerialPciDeviceInfo);
+ DeviceInfo = (PCI_UART_DEVICE_INFO *)PcdGetPtr (PcdSerialPciDeviceInfo);
//
// Enable I/O or MMIO in PCI Bridge
@@ -408,7 +415,7 @@ GetSerialRegisterBase ( //
if (DeviceInfo->PowerManagementStatusAndControlRegister != 0x00) {
if ((PciRead16 (PciLibAddress + DeviceInfo->PowerManagementStatusAndControlRegister) & (BIT0 | BIT1)) != 0x00) {
- PciAnd16 (PciLibAddress + DeviceInfo->PowerManagementStatusAndControlRegister, (UINT16)~(BIT0 | BIT1));
+ PciAnd16 (PciLibAddress + DeviceInfo->PowerManagementStatusAndControlRegister, (UINT16) ~(BIT0 | BIT1));
}
}
@@ -445,7 +452,7 @@ SerialPortWritable ( // 1 0 Cable connected, but not clear to send. Wait
// 1 1 Cable connected, and clear to send. Transmit
//
- return (BOOLEAN) ((SerialPortReadRegister (SerialRegisterBase, R_UART_MSR) & (B_UART_MSR_DSR | B_UART_MSR_CTS)) == (B_UART_MSR_DSR | B_UART_MSR_CTS));
+ return (BOOLEAN)((SerialPortReadRegister (SerialRegisterBase, R_UART_MSR) & (B_UART_MSR_DSR | B_UART_MSR_CTS)) == (B_UART_MSR_DSR | B_UART_MSR_CTS));
} else {
//
// Wait for both DSR and CTS to be set OR for DSR to be clear.
@@ -459,7 +466,7 @@ SerialPortWritable ( // 1 0 Cable connected, but not clear to send. Wait
// 1 1 Cable connected, and clar to send. Transmit
//
- return (BOOLEAN) ((SerialPortReadRegister (SerialRegisterBase, R_UART_MSR) & (B_UART_MSR_DSR | B_UART_MSR_CTS)) != (B_UART_MSR_DSR));
+ return (BOOLEAN)((SerialPortReadRegister (SerialRegisterBase, R_UART_MSR) & (B_UART_MSR_DSR | B_UART_MSR_CTS)) != (B_UART_MSR_DSR));
}
}
@@ -511,7 +518,7 @@ SerialPortInitialize ( // Get the base address of the serial port in either I/O or MMIO space
//
SerialRegisterBase = GetSerialRegisterBase ();
- if (SerialRegisterBase ==0) {
+ if (SerialRegisterBase == 0) {
return RETURN_DEVICE_ERROR;
}
@@ -522,13 +529,15 @@ SerialPortInitialize ( if ((SerialPortReadRegister (SerialRegisterBase, R_UART_LCR) & 0x3F) != (PcdGet8 (PcdSerialLineControl) & 0x3F)) {
Initialized = FALSE;
}
+
SerialPortWriteRegister (SerialRegisterBase, R_UART_LCR, (UINT8)(SerialPortReadRegister (SerialRegisterBase, R_UART_LCR) | B_UART_LCR_DLAB));
- CurrentDivisor = SerialPortReadRegister (SerialRegisterBase, R_UART_BAUD_HIGH) << 8;
- CurrentDivisor |= (UINT32) SerialPortReadRegister (SerialRegisterBase, R_UART_BAUD_LOW);
+ CurrentDivisor = SerialPortReadRegister (SerialRegisterBase, R_UART_BAUD_HIGH) << 8;
+ CurrentDivisor |= (UINT32)SerialPortReadRegister (SerialRegisterBase, R_UART_BAUD_LOW);
SerialPortWriteRegister (SerialRegisterBase, R_UART_LCR, (UINT8)(SerialPortReadRegister (SerialRegisterBase, R_UART_LCR) & ~B_UART_LCR_DLAB));
if (CurrentDivisor != Divisor) {
Initialized = FALSE;
}
+
if (Initialized) {
return RETURN_SUCCESS;
}
@@ -537,14 +546,15 @@ SerialPortInitialize ( // Wait for the serial port to be ready.
// Verify that both the transmit FIFO and the shift register are empty.
//
- while ((SerialPortReadRegister (SerialRegisterBase, R_UART_LSR) & (B_UART_LSR_TEMT | B_UART_LSR_TXRDY)) != (B_UART_LSR_TEMT | B_UART_LSR_TXRDY));
+ while ((SerialPortReadRegister (SerialRegisterBase, R_UART_LSR) & (B_UART_LSR_TEMT | B_UART_LSR_TXRDY)) != (B_UART_LSR_TEMT | B_UART_LSR_TXRDY)) {
+ }
//
// Configure baud rate
//
SerialPortWriteRegister (SerialRegisterBase, R_UART_LCR, B_UART_LCR_DLAB);
- SerialPortWriteRegister (SerialRegisterBase, R_UART_BAUD_HIGH, (UINT8) (Divisor >> 8));
- SerialPortWriteRegister (SerialRegisterBase, R_UART_BAUD_LOW, (UINT8) (Divisor & 0xff));
+ SerialPortWriteRegister (SerialRegisterBase, R_UART_BAUD_HIGH, (UINT8)(Divisor >> 8));
+ SerialPortWriteRegister (SerialRegisterBase, R_UART_BAUD_LOW, (UINT8)(Divisor & 0xff));
//
// Clear DLAB and configure Data Bits, Parity, and Stop Bits.
@@ -594,8 +604,8 @@ SerialPortInitialize ( UINTN
EFIAPI
SerialPortWrite (
- IN UINT8 *Buffer,
- IN UINTN NumberOfBytes
+ IN UINT8 *Buffer,
+ IN UINTN NumberOfBytes
)
{
UINTN SerialRegisterBase;
@@ -608,7 +618,7 @@ SerialPortWrite ( }
SerialRegisterBase = GetSerialRegisterBase ();
- if (SerialRegisterBase ==0) {
+ if (SerialRegisterBase == 0) {
return 0;
}
@@ -620,12 +630,15 @@ SerialPortWrite ( //
// Wait for both the transmit FIFO and shift register empty.
//
- while ((SerialPortReadRegister (SerialRegisterBase, R_UART_LSR) & (B_UART_LSR_TEMT | B_UART_LSR_TXRDY)) != (B_UART_LSR_TEMT | B_UART_LSR_TXRDY));
+ while ((SerialPortReadRegister (SerialRegisterBase, R_UART_LSR) & (B_UART_LSR_TEMT | B_UART_LSR_TXRDY)) != (B_UART_LSR_TEMT | B_UART_LSR_TXRDY)) {
+ }
//
// Wait for the hardware flow control signal
//
- while (!SerialPortWritable (SerialRegisterBase));
+ while (!SerialPortWritable (SerialRegisterBase)) {
+ }
+
return 0;
}
@@ -647,7 +660,8 @@ SerialPortWrite ( // Wait for the serial port to be ready, to make sure both the transmit FIFO
// and shift register empty.
//
- while ((SerialPortReadRegister (SerialRegisterBase, R_UART_LSR) & (B_UART_LSR_TEMT | B_UART_LSR_TXRDY)) != (B_UART_LSR_TEMT | B_UART_LSR_TXRDY));
+ while ((SerialPortReadRegister (SerialRegisterBase, R_UART_LSR) & (B_UART_LSR_TEMT | B_UART_LSR_TXRDY)) != (B_UART_LSR_TEMT | B_UART_LSR_TXRDY)) {
+ }
//
// Fill then entire Tx FIFO
@@ -656,7 +670,8 @@ SerialPortWrite ( //
// Wait for the hardware flow control signal
//
- while (!SerialPortWritable (SerialRegisterBase));
+ while (!SerialPortWritable (SerialRegisterBase)) {
+ }
//
// Write byte to the transmit buffer.
@@ -664,6 +679,7 @@ SerialPortWrite ( SerialPortWriteRegister (SerialRegisterBase, R_UART_TXBUF, *Buffer);
}
}
+
return Result;
}
@@ -681,8 +697,8 @@ SerialPortWrite ( UINTN
EFIAPI
SerialPortRead (
- OUT UINT8 *Buffer,
- IN UINTN NumberOfBytes
+ OUT UINT8 *Buffer,
+ IN UINTN NumberOfBytes
)
{
UINTN SerialRegisterBase;
@@ -694,7 +710,7 @@ SerialPortRead ( }
SerialRegisterBase = GetSerialRegisterBase ();
- if (SerialRegisterBase ==0) {
+ if (SerialRegisterBase == 0) {
return 0;
}
@@ -712,6 +728,7 @@ SerialPortRead ( SerialPortWriteRegister (SerialRegisterBase, R_UART_MCR, (UINT8)(Mcr | B_UART_MCR_RTS));
}
}
+
if (PcdGetBool (PcdSerialUseHardwareFlowControl)) {
//
// Clear RTS to prevent peer from sending data
@@ -728,7 +745,6 @@ SerialPortRead ( return Result;
}
-
/**
Polls a serial device to see if there is any data waiting to be read.
@@ -749,7 +765,7 @@ SerialPortPoll ( UINTN SerialRegisterBase;
SerialRegisterBase = GetSerialRegisterBase ();
- if (SerialRegisterBase ==0) {
+ if (SerialRegisterBase == 0) {
return FALSE;
}
@@ -763,6 +779,7 @@ SerialPortPoll ( //
SerialPortWriteRegister (SerialRegisterBase, R_UART_MCR, (UINT8)(SerialPortReadRegister (SerialRegisterBase, R_UART_MCR) & ~B_UART_MCR_RTS));
}
+
return TRUE;
}
@@ -789,29 +806,30 @@ SerialPortPoll ( RETURN_STATUS
EFIAPI
SerialPortSetControl (
- IN UINT32 Control
+ IN UINT32 Control
)
{
- UINTN SerialRegisterBase;
- UINT8 Mcr;
+ UINTN SerialRegisterBase;
+ UINT8 Mcr;
//
// First determine the parameter is invalid.
//
if ((Control & (~(EFI_SERIAL_REQUEST_TO_SEND | EFI_SERIAL_DATA_TERMINAL_READY |
- EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE))) != 0) {
+ EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE))) != 0)
+ {
return RETURN_UNSUPPORTED;
}
SerialRegisterBase = GetSerialRegisterBase ();
- if (SerialRegisterBase ==0) {
+ if (SerialRegisterBase == 0) {
return RETURN_UNSUPPORTED;
}
//
// Read the Modem Control Register.
//
- Mcr = SerialPortReadRegister (SerialRegisterBase, R_UART_MCR);
+ Mcr = SerialPortReadRegister (SerialRegisterBase, R_UART_MCR);
Mcr &= (~(B_UART_MCR_DTRC | B_UART_MCR_RTS));
if ((Control & EFI_SERIAL_DATA_TERMINAL_READY) == EFI_SERIAL_DATA_TERMINAL_READY) {
@@ -843,16 +861,16 @@ SerialPortSetControl ( RETURN_STATUS
EFIAPI
SerialPortGetControl (
- OUT UINT32 *Control
+ OUT UINT32 *Control
)
{
- UINTN SerialRegisterBase;
- UINT8 Msr;
- UINT8 Mcr;
- UINT8 Lsr;
+ UINTN SerialRegisterBase;
+ UINT8 Msr;
+ UINT8 Mcr;
+ UINT8 Lsr;
SerialRegisterBase = GetSerialRegisterBase ();
- if (SerialRegisterBase ==0) {
+ if (SerialRegisterBase == 0) {
return RETURN_UNSUPPORTED;
}
@@ -948,24 +966,24 @@ SerialPortGetControl ( RETURN_STATUS
EFIAPI
SerialPortSetAttributes (
- IN OUT UINT64 *BaudRate,
- IN OUT UINT32 *ReceiveFifoDepth,
- IN OUT UINT32 *Timeout,
- IN OUT EFI_PARITY_TYPE *Parity,
- IN OUT UINT8 *DataBits,
- IN OUT EFI_STOP_BITS_TYPE *StopBits
+ IN OUT UINT64 *BaudRate,
+ IN OUT UINT32 *ReceiveFifoDepth,
+ IN OUT UINT32 *Timeout,
+ IN OUT EFI_PARITY_TYPE *Parity,
+ IN OUT UINT8 *DataBits,
+ IN OUT EFI_STOP_BITS_TYPE *StopBits
)
{
- UINTN SerialRegisterBase;
- UINT32 SerialBaudRate;
- UINTN Divisor;
- UINT8 Lcr;
- UINT8 LcrData;
- UINT8 LcrParity;
- UINT8 LcrStop;
+ UINTN SerialRegisterBase;
+ UINT32 SerialBaudRate;
+ UINTN Divisor;
+ UINT8 Lcr;
+ UINT8 LcrData;
+ UINT8 LcrParity;
+ UINT8 LcrStop;
SerialRegisterBase = GetSerialRegisterBase ();
- if (SerialRegisterBase ==0) {
+ if (SerialRegisterBase == 0) {
return RETURN_UNSUPPORTED;
}
@@ -975,23 +993,25 @@ SerialPortSetAttributes ( if (*BaudRate == 0) {
*BaudRate = PcdGet32 (PcdSerialBaudRate);
}
- SerialBaudRate = (UINT32) *BaudRate;
+
+ SerialBaudRate = (UINT32)*BaudRate;
if (*DataBits == 0) {
- LcrData = (UINT8) (PcdGet8 (PcdSerialLineControl) & 0x3);
+ LcrData = (UINT8)(PcdGet8 (PcdSerialLineControl) & 0x3);
*DataBits = LcrData + 5;
} else {
if ((*DataBits < 5) || (*DataBits > 8)) {
return RETURN_INVALID_PARAMETER;
}
+
//
// Map 5..8 to 0..3
//
- LcrData = (UINT8) (*DataBits - (UINT8) 5);
+ LcrData = (UINT8)(*DataBits - (UINT8)5);
}
if (*Parity == DefaultParity) {
- LcrParity = (UINT8) ((PcdGet8 (PcdSerialLineControl) >> 3) & 0x7);
+ LcrParity = (UINT8)((PcdGet8 (PcdSerialLineControl) >> 3) & 0x7);
switch (LcrParity) {
case 0:
*Parity = NoParity;
@@ -1044,7 +1064,7 @@ SerialPortSetAttributes ( }
if (*StopBits == DefaultStopBits) {
- LcrStop = (UINT8) ((PcdGet8 (PcdSerialLineControl) >> 2) & 0x1);
+ LcrStop = (UINT8)((PcdGet8 (PcdSerialLineControl) >> 2) & 0x1);
switch (LcrStop) {
case 0:
*StopBits = OneStopBit;
@@ -1056,6 +1076,7 @@ SerialPortSetAttributes ( } else {
*StopBits = TwoStopBits;
}
+
break;
default:
@@ -1090,15 +1111,15 @@ SerialPortSetAttributes ( // Configure baud rate
//
SerialPortWriteRegister (SerialRegisterBase, R_UART_LCR, B_UART_LCR_DLAB);
- SerialPortWriteRegister (SerialRegisterBase, R_UART_BAUD_HIGH, (UINT8) (Divisor >> 8));
- SerialPortWriteRegister (SerialRegisterBase, R_UART_BAUD_LOW, (UINT8) (Divisor & 0xff));
+ SerialPortWriteRegister (SerialRegisterBase, R_UART_BAUD_HIGH, (UINT8)(Divisor >> 8));
+ SerialPortWriteRegister (SerialRegisterBase, R_UART_BAUD_LOW, (UINT8)(Divisor & 0xff));
//
// Clear DLAB and configure Data Bits, Parity, and Stop Bits.
// Strip reserved bits from line control value
//
- Lcr = (UINT8) ((LcrParity << 3) | (LcrStop << 2) | LcrData);
- SerialPortWriteRegister (SerialRegisterBase, R_UART_LCR, (UINT8) (Lcr & 0x3F));
+ Lcr = (UINT8)((LcrParity << 3) | (LcrStop << 2) | LcrData);
+ SerialPortWriteRegister (SerialRegisterBase, R_UART_LCR, (UINT8)(Lcr & 0x3F));
return RETURN_SUCCESS;
}
diff --git a/MdeModulePkg/Library/BaseSortLib/BaseSortLib.c b/MdeModulePkg/Library/BaseSortLib/BaseSortLib.c index 0903943ee4..b5a84e366a 100644 --- a/MdeModulePkg/Library/BaseSortLib/BaseSortLib.c +++ b/MdeModulePkg/Library/BaseSortLib/BaseSortLib.c @@ -34,19 +34,19 @@ VOID
EFIAPI
PerformQuickSort (
- IN OUT VOID *BufferToSort,
- IN CONST UINTN Count,
- IN CONST UINTN ElementSize,
- IN SORT_COMPARE CompareFunction
+ IN OUT VOID *BufferToSort,
+ IN CONST UINTN Count,
+ IN CONST UINTN ElementSize,
+ IN SORT_COMPARE CompareFunction
)
{
VOID *Buffer;
- ASSERT(BufferToSort != NULL);
- ASSERT(CompareFunction != NULL);
+ ASSERT (BufferToSort != NULL);
+ ASSERT (CompareFunction != NULL);
- Buffer = AllocateZeroPool(ElementSize);
- ASSERT(Buffer != NULL);
+ Buffer = AllocateZeroPool (ElementSize);
+ ASSERT (Buffer != NULL);
QuickSort (
BufferToSort,
@@ -56,7 +56,7 @@ PerformQuickSort ( Buffer
);
- FreePool(Buffer);
+ FreePool (Buffer);
return;
}
@@ -71,11 +71,11 @@ PerformQuickSort ( INTN
EFIAPI
DevicePathCompare (
- IN CONST VOID *Buffer1,
- IN CONST VOID *Buffer2
+ IN CONST VOID *Buffer1,
+ IN CONST VOID *Buffer2
)
{
- ASSERT(FALSE);
+ ASSERT (FALSE);
return 0;
}
@@ -90,15 +90,14 @@ DevicePathCompare ( INTN
EFIAPI
StringNoCaseCompare (
- IN CONST VOID *Buffer1,
- IN CONST VOID *Buffer2
+ IN CONST VOID *Buffer1,
+ IN CONST VOID *Buffer2
)
{
- ASSERT(FALSE);
+ ASSERT (FALSE);
return 0;
}
-
/**
Not supported in Base version.
@@ -110,12 +109,10 @@ StringNoCaseCompare ( INTN
EFIAPI
StringCompare (
- IN CONST VOID *Buffer1,
- IN CONST VOID *Buffer2
+ IN CONST VOID *Buffer1,
+ IN CONST VOID *Buffer2
)
{
- ASSERT(FALSE);
+ ASSERT (FALSE);
return 0;
}
-
-
diff --git a/MdeModulePkg/Library/BootDiscoveryPolicyUiLib/BootDiscoveryPolicyUiLib.c b/MdeModulePkg/Library/BootDiscoveryPolicyUiLib/BootDiscoveryPolicyUiLib.c index 615958799c..a17d62a012 100644 --- a/MdeModulePkg/Library/BootDiscoveryPolicyUiLib/BootDiscoveryPolicyUiLib.c +++ b/MdeModulePkg/Library/BootDiscoveryPolicyUiLib/BootDiscoveryPolicyUiLib.c @@ -24,16 +24,16 @@ /// HII specific Vendor Device Path definition.
///
typedef struct {
- VENDOR_DEVICE_PATH VendorDevicePath;
- EFI_DEVICE_PATH_PROTOCOL End;
+ VENDOR_DEVICE_PATH VendorDevicePath;
+ EFI_DEVICE_PATH_PROTOCOL End;
} HII_VENDOR_DEVICE_PATH;
-extern UINT8 BootDiscoveryPolicyUiLibVfrBin[];
+extern UINT8 BootDiscoveryPolicyUiLibVfrBin[];
-EFI_HII_HANDLE mBPHiiHandle = NULL;
+EFI_HII_HANDLE mBPHiiHandle = NULL;
EFI_HANDLE mBPDriverHandle = NULL;
-STATIC HII_VENDOR_DEVICE_PATH mVendorDevicePath = {
+STATIC HII_VENDOR_DEVICE_PATH mVendorDevicePath = {
{
{
HARDWARE_DEVICE_PATH,
@@ -69,15 +69,15 @@ STATIC HII_VENDOR_DEVICE_PATH mVendorDevicePath = { EFI_STATUS
EFIAPI
BootDiscoveryPolicyUiLibConstructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
- UINTN Size;
- UINT32 BootDiscoveryPolicy;
+ EFI_STATUS Status;
+ UINTN Size;
+ UINT32 BootDiscoveryPolicy;
- Size = sizeof (UINT32);
+ Size = sizeof (UINT32);
Status = gRT->GetVariable (
BOOT_DISCOVERY_POLICY_VAR,
&gBootDiscoveryPolicyMgrFormsetGuid,
@@ -141,7 +141,6 @@ BootDiscoveryPolicyUiLibDestructor ( IN EFI_SYSTEM_TABLE *SystemTable
)
{
-
if (mBPDriverHandle != NULL) {
gBS->UninstallProtocolInterface (
mBPDriverHandle,
diff --git a/MdeModulePkg/Library/BootLogoLib/BootLogoLib.c b/MdeModulePkg/Library/BootLogoLib/BootLogoLib.c index 134660f28d..478ec2d40e 100644 --- a/MdeModulePkg/Library/BootLogoLib/BootLogoLib.c +++ b/MdeModulePkg/Library/BootLogoLib/BootLogoLib.c @@ -35,35 +35,35 @@ BootLogoEnableLogo ( VOID
)
{
- EFI_STATUS Status;
- EDKII_PLATFORM_LOGO_PROTOCOL *PlatformLogo;
- EDKII_PLATFORM_LOGO_DISPLAY_ATTRIBUTE Attribute;
- INTN OffsetX;
- INTN OffsetY;
- UINT32 SizeOfX;
- UINT32 SizeOfY;
- INTN DestX;
- INTN DestY;
- UINT32 Instance;
- EFI_IMAGE_INPUT Image;
- EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Blt;
- EFI_UGA_DRAW_PROTOCOL *UgaDraw;
- UINT32 ColorDepth;
- UINT32 RefreshRate;
- EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
- EFI_BOOT_LOGO_PROTOCOL *BootLogo;
- EDKII_BOOT_LOGO2_PROTOCOL *BootLogo2;
- UINTN NumberOfLogos;
- EFI_GRAPHICS_OUTPUT_BLT_PIXEL *LogoBlt;
- UINTN LogoDestX;
- UINTN LogoDestY;
- UINTN LogoHeight;
- UINTN LogoWidth;
- UINTN NewDestX;
- UINTN NewDestY;
- UINTN BufferSize;
-
- Status = gBS->LocateProtocol (&gEdkiiPlatformLogoProtocolGuid, NULL, (VOID **) &PlatformLogo);
+ EFI_STATUS Status;
+ EDKII_PLATFORM_LOGO_PROTOCOL *PlatformLogo;
+ EDKII_PLATFORM_LOGO_DISPLAY_ATTRIBUTE Attribute;
+ INTN OffsetX;
+ INTN OffsetY;
+ UINT32 SizeOfX;
+ UINT32 SizeOfY;
+ INTN DestX;
+ INTN DestY;
+ UINT32 Instance;
+ EFI_IMAGE_INPUT Image;
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Blt;
+ EFI_UGA_DRAW_PROTOCOL *UgaDraw;
+ UINT32 ColorDepth;
+ UINT32 RefreshRate;
+ EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
+ EFI_BOOT_LOGO_PROTOCOL *BootLogo;
+ EDKII_BOOT_LOGO2_PROTOCOL *BootLogo2;
+ UINTN NumberOfLogos;
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL *LogoBlt;
+ UINTN LogoDestX;
+ UINTN LogoDestY;
+ UINTN LogoHeight;
+ UINTN LogoWidth;
+ UINTN NewDestX;
+ UINTN NewDestY;
+ UINTN BufferSize;
+
+ Status = gBS->LocateProtocol (&gEdkiiPlatformLogoProtocolGuid, NULL, (VOID **)&PlatformLogo);
if (EFI_ERROR (Status)) {
return EFI_UNSUPPORTED;
}
@@ -72,17 +72,18 @@ BootLogoEnableLogo ( //
// Try to open GOP first
//
- Status = gBS->HandleProtocol (gST->ConsoleOutHandle, &gEfiGraphicsOutputProtocolGuid, (VOID **) &GraphicsOutput);
+ Status = gBS->HandleProtocol (gST->ConsoleOutHandle, &gEfiGraphicsOutputProtocolGuid, (VOID **)&GraphicsOutput);
if (EFI_ERROR (Status) && FeaturePcdGet (PcdUgaConsumeSupport)) {
GraphicsOutput = NULL;
//
// Open GOP failed, try to open UGA
//
- Status = gBS->HandleProtocol (gST->ConsoleOutHandle, &gEfiUgaDrawProtocolGuid, (VOID **) &UgaDraw);
+ Status = gBS->HandleProtocol (gST->ConsoleOutHandle, &gEfiUgaDrawProtocolGuid, (VOID **)&UgaDraw);
if (EFI_ERROR (Status)) {
UgaDraw = NULL;
}
}
+
if (EFI_ERROR (Status)) {
return EFI_UNSUPPORTED;
}
@@ -90,7 +91,7 @@ BootLogoEnableLogo ( //
// Try to open Boot Logo Protocol.
//
- Status = gBS->LocateProtocol (&gEfiBootLogoProtocolGuid, NULL, (VOID **) &BootLogo);
+ Status = gBS->LocateProtocol (&gEfiBootLogoProtocolGuid, NULL, (VOID **)&BootLogo);
if (EFI_ERROR (Status)) {
BootLogo = NULL;
}
@@ -98,7 +99,7 @@ BootLogoEnableLogo ( //
// Try to open Boot Logo 2 Protocol.
//
- Status = gBS->LocateProtocol (&gEdkiiBootLogo2ProtocolGuid, NULL, (VOID **) &BootLogo2);
+ Status = gBS->LocateProtocol (&gEdkiiBootLogo2ProtocolGuid, NULL, (VOID **)&BootLogo2);
if (EFI_ERROR (Status)) {
BootLogo2 = NULL;
}
@@ -111,7 +112,6 @@ BootLogoEnableLogo ( if (GraphicsOutput != NULL) {
SizeOfX = GraphicsOutput->Mode->Info->HorizontalResolution;
SizeOfY = GraphicsOutput->Mode->Info->VerticalResolution;
-
} else {
ASSERT (UgaDraw != NULL);
Status = UgaDraw->GetMode (UgaDraw, &SizeOfX, &SizeOfY, &ColorDepth, &RefreshRate);
@@ -120,17 +120,17 @@ BootLogoEnableLogo ( }
}
- Blt = NULL;
+ Blt = NULL;
NumberOfLogos = 0;
- LogoDestX = 0;
- LogoDestY = 0;
- LogoHeight = 0;
- LogoWidth = 0;
- NewDestX = 0;
- NewDestY = 0;
- Instance = 0;
- DestX = 0;
- DestY = 0;
+ LogoDestX = 0;
+ LogoDestY = 0;
+ LogoHeight = 0;
+ LogoWidth = 0;
+ NewDestX = 0;
+ NewDestY = 0;
+ Instance = 0;
+ DestX = 0;
+ DestY = 0;
while (TRUE) {
//
// Get image from PlatformLogo protocol.
@@ -150,55 +150,56 @@ BootLogoEnableLogo ( if (Blt != NULL) {
FreePool (Blt);
}
+
Blt = Image.Bitmap;
//
// Calculate the display position according to Attribute.
//
switch (Attribute) {
- case EdkiiPlatformLogoDisplayAttributeLeftTop:
- DestX = 0;
- DestY = 0;
- break;
- case EdkiiPlatformLogoDisplayAttributeCenterTop:
- DestX = (SizeOfX - Image.Width) / 2;
- DestY = 0;
- break;
- case EdkiiPlatformLogoDisplayAttributeRightTop:
- DestX = SizeOfX - Image.Width;
- DestY = 0;
- break;
-
- case EdkiiPlatformLogoDisplayAttributeCenterLeft:
- DestX = 0;
- DestY = (SizeOfY - Image.Height) / 2;
- break;
- case EdkiiPlatformLogoDisplayAttributeCenter:
- DestX = (SizeOfX - Image.Width) / 2;
- DestY = (SizeOfY - Image.Height) / 2;
- break;
- case EdkiiPlatformLogoDisplayAttributeCenterRight:
- DestX = SizeOfX - Image.Width;
- DestY = (SizeOfY - Image.Height) / 2;
- break;
-
- case EdkiiPlatformLogoDisplayAttributeLeftBottom:
- DestX = 0;
- DestY = SizeOfY - Image.Height;
- break;
- case EdkiiPlatformLogoDisplayAttributeCenterBottom:
- DestX = (SizeOfX - Image.Width) / 2;
- DestY = SizeOfY - Image.Height;
- break;
- case EdkiiPlatformLogoDisplayAttributeRightBottom:
- DestX = SizeOfX - Image.Width;
- DestY = SizeOfY - Image.Height;
- break;
-
- default:
- ASSERT (FALSE);
- continue;
- break;
+ case EdkiiPlatformLogoDisplayAttributeLeftTop:
+ DestX = 0;
+ DestY = 0;
+ break;
+ case EdkiiPlatformLogoDisplayAttributeCenterTop:
+ DestX = (SizeOfX - Image.Width) / 2;
+ DestY = 0;
+ break;
+ case EdkiiPlatformLogoDisplayAttributeRightTop:
+ DestX = SizeOfX - Image.Width;
+ DestY = 0;
+ break;
+
+ case EdkiiPlatformLogoDisplayAttributeCenterLeft:
+ DestX = 0;
+ DestY = (SizeOfY - Image.Height) / 2;
+ break;
+ case EdkiiPlatformLogoDisplayAttributeCenter:
+ DestX = (SizeOfX - Image.Width) / 2;
+ DestY = (SizeOfY - Image.Height) / 2;
+ break;
+ case EdkiiPlatformLogoDisplayAttributeCenterRight:
+ DestX = SizeOfX - Image.Width;
+ DestY = (SizeOfY - Image.Height) / 2;
+ break;
+
+ case EdkiiPlatformLogoDisplayAttributeLeftBottom:
+ DestX = 0;
+ DestY = SizeOfY - Image.Height;
+ break;
+ case EdkiiPlatformLogoDisplayAttributeCenterBottom:
+ DestX = (SizeOfX - Image.Width) / 2;
+ DestY = SizeOfY - Image.Height;
+ break;
+ case EdkiiPlatformLogoDisplayAttributeRightBottom:
+ DestX = SizeOfX - Image.Width;
+ DestY = SizeOfY - Image.Height;
+ break;
+
+ default:
+ ASSERT (FALSE);
+ continue;
+ break;
}
DestX += OffsetX;
@@ -212,8 +213,8 @@ BootLogoEnableLogo ( EfiBltBufferToVideo,
0,
0,
- (UINTN) DestX,
- (UINTN) DestY,
+ (UINTN)DestX,
+ (UINTN)DestY,
Image.Width,
Image.Height,
Image.Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)
@@ -222,12 +223,12 @@ BootLogoEnableLogo ( ASSERT (UgaDraw != NULL);
Status = UgaDraw->Blt (
UgaDraw,
- (EFI_UGA_PIXEL *) Blt,
+ (EFI_UGA_PIXEL *)Blt,
EfiUgaBltBufferToVideo,
0,
0,
- (UINTN) DestX,
- (UINTN) DestY,
+ (UINTN)DestX,
+ (UINTN)DestY,
Image.Width,
Image.Height,
Image.Width * sizeof (EFI_UGA_PIXEL)
@@ -244,18 +245,18 @@ BootLogoEnableLogo ( //
// The first Logo.
//
- LogoDestX = (UINTN) DestX;
- LogoDestY = (UINTN) DestY;
- LogoWidth = Image.Width;
+ LogoDestX = (UINTN)DestX;
+ LogoDestY = (UINTN)DestY;
+ LogoWidth = Image.Width;
LogoHeight = Image.Height;
} else {
//
// Merge new logo with old one.
//
- NewDestX = MIN ((UINTN) DestX, LogoDestX);
- NewDestY = MIN ((UINTN) DestY, LogoDestY);
- LogoWidth = MAX ((UINTN) DestX + Image.Width, LogoDestX + LogoWidth) - NewDestX;
- LogoHeight = MAX ((UINTN) DestY + Image.Height, LogoDestY + LogoHeight) - NewDestY;
+ NewDestX = MIN ((UINTN)DestX, LogoDestX);
+ NewDestY = MIN ((UINTN)DestY, LogoDestY);
+ LogoWidth = MAX ((UINTN)DestX + Image.Width, LogoDestX + LogoWidth) - NewDestX;
+ LogoHeight = MAX ((UINTN)DestY + Image.Height, LogoDestY + LogoHeight) - NewDestY;
LogoDestX = NewDestX;
LogoDestY = NewDestY;
@@ -264,7 +265,7 @@ BootLogoEnableLogo ( }
}
- if ((BootLogo == NULL && BootLogo2 == NULL) || NumberOfLogos == 0) {
+ if (((BootLogo == NULL) && (BootLogo2 == NULL)) || (NumberOfLogos == 0)) {
//
// No logo displayed.
//
@@ -283,7 +284,7 @@ BootLogoEnableLogo ( // Only one logo displayed, use its Blt buffer directly for BootLogo protocol.
//
LogoBlt = Blt;
- Status = EFI_SUCCESS;
+ Status = EFI_SUCCESS;
} else {
//
// More than one Logo displayed, get merged BltBuffer using VideoToBuffer operation.
@@ -298,6 +299,7 @@ BootLogoEnableLogo ( if (LogoHeight > MAX_UINTN / LogoWidth / sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)) {
return EFI_UNSUPPORTED;
}
+
BufferSize = LogoWidth * LogoHeight * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL);
LogoBlt = AllocatePool (BufferSize);
@@ -307,21 +309,21 @@ BootLogoEnableLogo ( if (GraphicsOutput != NULL) {
Status = GraphicsOutput->Blt (
- GraphicsOutput,
- LogoBlt,
- EfiBltVideoToBltBuffer,
- LogoDestX,
- LogoDestY,
- 0,
- 0,
- LogoWidth,
- LogoHeight,
- LogoWidth * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)
- );
+ GraphicsOutput,
+ LogoBlt,
+ EfiBltVideoToBltBuffer,
+ LogoDestX,
+ LogoDestY,
+ 0,
+ 0,
+ LogoWidth,
+ LogoHeight,
+ LogoWidth * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)
+ );
} else {
Status = UgaDraw->Blt (
UgaDraw,
- (EFI_UGA_PIXEL *) LogoBlt,
+ (EFI_UGA_PIXEL *)LogoBlt,
EfiUgaVideoToBltBuffer,
LogoDestX,
LogoDestY,
@@ -341,19 +343,22 @@ BootLogoEnableLogo ( if (BootLogo2 != NULL) {
Status = BootLogo2->SetBootLogo (BootLogo2, LogoBlt, LogoDestX, LogoDestY, LogoWidth, LogoHeight);
}
+
//
// If Boot Logo 2 Protocol is not available or registration with Boot Logo 2
// Protocol failed, then attempt to register logo with Boot Logo Protocol
//
- if (EFI_ERROR (Status) && BootLogo != NULL) {
+ if (EFI_ERROR (Status) && (BootLogo != NULL)) {
Status = BootLogo->SetBootLogo (BootLogo, LogoBlt, LogoDestX, LogoDestY, LogoWidth, LogoHeight);
}
+
//
// Status of this function is EFI_SUCCESS even if registration with Boot
// Logo 2 Protocol or Boot Logo Protocol fails.
//
Status = EFI_SUCCESS;
}
+
FreePool (LogoBlt);
return Status;
@@ -372,7 +377,6 @@ BootLogoDisableLogo ( VOID
)
{
-
//
// Enable Cursor on Screen
//
@@ -380,7 +384,6 @@ BootLogoDisableLogo ( return EFI_SUCCESS;
}
-
/**
Update progress bar with title above it. It only works in Graphics mode.
@@ -398,12 +401,12 @@ BootLogoDisableLogo ( EFI_STATUS
EFIAPI
BootLogoUpdateProgress (
- IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL TitleForeground,
- IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL TitleBackground,
- IN CHAR16 *Title,
- IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL ProgressColor,
- IN UINTN Progress,
- IN UINTN PreviousValue
+ IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL TitleForeground,
+ IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL TitleBackground,
+ IN CHAR16 *Title,
+ IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL ProgressColor,
+ IN UINTN Progress,
+ IN UINTN PreviousValue
)
{
EFI_STATUS Status;
@@ -426,15 +429,16 @@ BootLogoUpdateProgress ( }
UgaDraw = NULL;
- Status = gBS->HandleProtocol (gST->ConsoleOutHandle, &gEfiGraphicsOutputProtocolGuid, (VOID **) &GraphicsOutput);
+ Status = gBS->HandleProtocol (gST->ConsoleOutHandle, &gEfiGraphicsOutputProtocolGuid, (VOID **)&GraphicsOutput);
if (EFI_ERROR (Status) && FeaturePcdGet (PcdUgaConsumeSupport)) {
GraphicsOutput = NULL;
- Status = gBS->HandleProtocol (gST->ConsoleOutHandle, &gEfiUgaDrawProtocolGuid, (VOID **) &UgaDraw);
+ Status = gBS->HandleProtocol (gST->ConsoleOutHandle, &gEfiUgaDrawProtocolGuid, (VOID **)&UgaDraw);
if (EFI_ERROR (Status)) {
UgaDraw = NULL;
}
}
+
if (EFI_ERROR (Status)) {
return EFI_UNSUPPORTED;
}
@@ -462,10 +466,10 @@ BootLogoUpdateProgress ( BlockWidth = SizeOfX / 100;
BlockHeight = SizeOfY / 50;
- BlockNum = Progress;
+ BlockNum = Progress;
- PosX = 0;
- PosY = SizeOfY * 48 / 50;
+ PosX = 0;
+ PosY = SizeOfY * 48 / 50;
if (BlockNum == 0) {
//
@@ -475,21 +479,21 @@ BootLogoUpdateProgress ( if (GraphicsOutput != NULL) {
Status = GraphicsOutput->Blt (
- GraphicsOutput,
- &Color,
- EfiBltVideoFill,
- 0,
- 0,
- 0,
- PosY - EFI_GLYPH_HEIGHT - 1,
- SizeOfX,
- SizeOfY - (PosY - EFI_GLYPH_HEIGHT - 1),
- SizeOfX * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)
- );
+ GraphicsOutput,
+ &Color,
+ EfiBltVideoFill,
+ 0,
+ 0,
+ 0,
+ PosY - EFI_GLYPH_HEIGHT - 1,
+ SizeOfX,
+ SizeOfY - (PosY - EFI_GLYPH_HEIGHT - 1),
+ SizeOfX * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)
+ );
} else if (FeaturePcdGet (PcdUgaConsumeSupport)) {
Status = UgaDraw->Blt (
UgaDraw,
- (EFI_UGA_PIXEL *) &Color,
+ (EFI_UGA_PIXEL *)&Color,
EfiUgaVideoFill,
0,
0,
@@ -503,6 +507,7 @@ BootLogoUpdateProgress ( return EFI_UNSUPPORTED;
}
}
+
//
// Show progress by drawing blocks
//
@@ -510,21 +515,21 @@ BootLogoUpdateProgress ( PosX = Index * BlockWidth;
if (GraphicsOutput != NULL) {
Status = GraphicsOutput->Blt (
- GraphicsOutput,
- &ProgressColor,
- EfiBltVideoFill,
- 0,
- 0,
- PosX,
- PosY,
- BlockWidth - 1,
- BlockHeight,
- (BlockWidth) * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)
- );
+ GraphicsOutput,
+ &ProgressColor,
+ EfiBltVideoFill,
+ 0,
+ 0,
+ PosX,
+ PosY,
+ BlockWidth - 1,
+ BlockHeight,
+ (BlockWidth) * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)
+ );
} else if (FeaturePcdGet (PcdUgaConsumeSupport)) {
Status = UgaDraw->Blt (
UgaDraw,
- (EFI_UGA_PIXEL *) &ProgressColor,
+ (EFI_UGA_PIXEL *)&ProgressColor,
EfiUgaVideoFill,
0,
0,
diff --git a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BmLib.c b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BmLib.c index 4a1905a1cd..c2e3bff54c 100644 --- a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BmLib.c +++ b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BmLib.c @@ -23,8 +23,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent **/
EFI_STATUS
EfiLibDeleteVariable (
- IN CHAR16 *VarName,
- IN EFI_GUID *VarGuid
+ IN CHAR16 *VarName,
+ IN EFI_GUID *VarGuid
)
{
return gRT->SetVariable (
@@ -49,11 +49,11 @@ EfiLibDeleteVariable ( **/
UINTN
EfiDevicePathInstanceCount (
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
)
{
- UINTN Count;
- UINTN Size;
+ UINTN Count;
+ UINTN Size;
Count = 0;
while (GetNextDevicePathInstance (&DevicePath, &Size) != NULL) {
@@ -76,7 +76,7 @@ EfiDevicePathInstanceCount ( **/
UINT16 *
EfiLibStrFromDatahub (
- IN EFI_DEVICE_PATH_PROTOCOL *DevPath
+ IN EFI_DEVICE_PATH_PROTOCOL *DevPath
)
{
return NULL;
diff --git a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenance.c b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenance.c index 28592f9f47..19751642a3 100644 --- a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenance.c +++ b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenance.c @@ -8,23 +8,23 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include "BootMaintenanceManager.h"
-#define FRONT_PAGE_KEY_OFFSET 0x4000
+#define FRONT_PAGE_KEY_OFFSET 0x4000
//
// Boot video resolution and text mode.
//
-UINT32 mBmmBootHorizontalResolution = 0;
-UINT32 mBmmBootVerticalResolution = 0;
-UINT32 mBmmBootTextModeColumn = 0;
-UINT32 mBmmBootTextModeRow = 0;
+UINT32 mBmmBootHorizontalResolution = 0;
+UINT32 mBmmBootVerticalResolution = 0;
+UINT32 mBmmBootTextModeColumn = 0;
+UINT32 mBmmBootTextModeRow = 0;
//
// BIOS setup video resolution and text mode.
//
-UINT32 mBmmSetupTextModeColumn = 0;
-UINT32 mBmmSetupTextModeRow = 0;
-UINT32 mBmmSetupHorizontalResolution = 0;
-UINT32 mBmmSetupVerticalResolution = 0;
+UINT32 mBmmSetupTextModeColumn = 0;
+UINT32 mBmmSetupTextModeRow = 0;
+UINT32 mBmmSetupHorizontalResolution = 0;
+UINT32 mBmmSetupVerticalResolution = 0;
-BOOLEAN mBmmModeInitialized = FALSE;
+BOOLEAN mBmmModeInitialized = FALSE;
EFI_DEVICE_PATH_PROTOCOL EndDevicePath[] = {
{
@@ -43,28 +43,29 @@ HII_VENDOR_DEVICE_PATH mBmmHiiVendorDevicePath = { HARDWARE_DEVICE_PATH,
HW_VENDOR_DP,
{
- (UINT8) (sizeof (VENDOR_DEVICE_PATH)),
- (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)
+ (UINT8)(sizeof (VENDOR_DEVICE_PATH)),
+ (UINT8)((sizeof (VENDOR_DEVICE_PATH)) >> 8)
}
},
//
// {165A028F-0BB2-4b5f-8747-77592E3F6499}
//
- { 0x165a028f, 0xbb2, 0x4b5f, { 0x87, 0x47, 0x77, 0x59, 0x2e, 0x3f, 0x64, 0x99 } }
+ { 0x165a028f, 0xbb2, 0x4b5f, { 0x87, 0x47, 0x77, 0x59, 0x2e, 0x3f, 0x64, 0x99 }
+ }
},
{
END_DEVICE_PATH_TYPE,
END_ENTIRE_DEVICE_PATH_SUBTYPE,
{
- (UINT8) (END_DEVICE_PATH_LENGTH),
- (UINT8) ((END_DEVICE_PATH_LENGTH) >> 8)
+ (UINT8)(END_DEVICE_PATH_LENGTH),
+ (UINT8)((END_DEVICE_PATH_LENGTH) >> 8)
}
}
};
-EFI_GUID mBootMaintGuid = BOOT_MAINT_FORMSET_GUID;
+EFI_GUID mBootMaintGuid = BOOT_MAINT_FORMSET_GUID;
-CHAR16 mBootMaintStorageName[] = L"BmmData";
+CHAR16 mBootMaintStorageName[] = L"BmmData";
BMM_CALLBACK_DATA gBootMaintenancePrivate = {
BMM_CALLBACK_DATA_SIGNATURE,
NULL,
@@ -76,9 +77,9 @@ BMM_CALLBACK_DATA gBootMaintenancePrivate = { }
};
-BMM_CALLBACK_DATA *mBmmCallbackInfo = &gBootMaintenancePrivate;
-BOOLEAN mAllMenuInit = FALSE;
-BOOLEAN mFirstEnterBMMForm = FALSE;
+BMM_CALLBACK_DATA *mBmmCallbackInfo = &gBootMaintenancePrivate;
+BOOLEAN mAllMenuInit = FALSE;
+BOOLEAN mFirstEnterBMMForm = FALSE;
/**
Init all memu.
@@ -88,7 +89,7 @@ BOOLEAN mFirstEnterBMMForm = FALSE; **/
VOID
InitAllMenu (
- IN BMM_CALLBACK_DATA *CallbackData
+ IN BMM_CALLBACK_DATA *CallbackData
);
/**
@@ -152,7 +153,7 @@ BmmSetConsoleMode ( Status = gBS->HandleProtocol (
gST->ConsoleOutHandle,
&gEfiGraphicsOutputProtocolGuid,
- (VOID**)&GraphicsOutput
+ (VOID **)&GraphicsOutput
);
if (EFI_ERROR (Status)) {
GraphicsOutput = NULL;
@@ -161,7 +162,7 @@ BmmSetConsoleMode ( Status = gBS->HandleProtocol (
gST->ConsoleOutHandle,
&gEfiSimpleTextOutProtocolGuid,
- (VOID**)&SimpleTextOut
+ (VOID **)&SimpleTextOut
);
if (EFI_ERROR (Status)) {
SimpleTextOut = NULL;
@@ -190,7 +191,7 @@ BmmSetConsoleMode ( }
if (GraphicsOutput != NULL) {
- MaxGopMode = GraphicsOutput->Mode->MaxMode;
+ MaxGopMode = GraphicsOutput->Mode->MaxMode;
}
if (SimpleTextOut != NULL) {
@@ -206,22 +207,24 @@ BmmSetConsoleMode ( //
for (ModeNumber = 0; ModeNumber < MaxGopMode; ModeNumber++) {
Status = GraphicsOutput->QueryMode (
- GraphicsOutput,
- ModeNumber,
- &SizeOfInfo,
- &Info
- );
+ GraphicsOutput,
+ ModeNumber,
+ &SizeOfInfo,
+ &Info
+ );
if (!EFI_ERROR (Status)) {
if ((Info->HorizontalResolution == NewHorizontalResolution) &&
- (Info->VerticalResolution == NewVerticalResolution)) {
+ (Info->VerticalResolution == NewVerticalResolution))
+ {
if ((GraphicsOutput->Mode->Info->HorizontalResolution == NewHorizontalResolution) &&
- (GraphicsOutput->Mode->Info->VerticalResolution == NewVerticalResolution)) {
+ (GraphicsOutput->Mode->Info->VerticalResolution == NewVerticalResolution))
+ {
//
// Current resolution is same with required resolution, check if text mode need be set
//
Status = SimpleTextOut->QueryMode (SimpleTextOut, SimpleTextOut->Mode->Mode, &CurrentColumn, &CurrentRow);
ASSERT_EFI_ERROR (Status);
- if (CurrentColumn == NewColumns && CurrentRow == NewRows) {
+ if ((CurrentColumn == NewColumns) && (CurrentRow == NewRows)) {
//
// If current text mode is same with required text mode. Do nothing
//
@@ -233,7 +236,7 @@ BmmSetConsoleMode ( //
for (Index = 0; Index < MaxTextMode; Index++) {
Status = SimpleTextOut->QueryMode (SimpleTextOut, Index, &CurrentColumn, &CurrentRow);
- if (!EFI_ERROR(Status)) {
+ if (!EFI_ERROR (Status)) {
if ((CurrentColumn == NewColumns) && (CurrentRow == NewRows)) {
//
// Required text mode is supported, set it.
@@ -252,6 +255,7 @@ BmmSetConsoleMode ( }
}
}
+
if (Index == MaxTextMode) {
//
// If required text mode is not supported, return error.
@@ -272,6 +276,7 @@ BmmSetConsoleMode ( }
}
}
+
FreePool (Info);
}
}
@@ -302,19 +307,21 @@ BmmSetConsoleMode ( // Locate all the handles with GOP protocol and reconnect it.
//
Status = gBS->LocateHandleBuffer (
- ByProtocol,
- &gEfiSimpleTextOutProtocolGuid,
- NULL,
- &HandleCount,
- &HandleBuffer
- );
+ ByProtocol,
+ &gEfiSimpleTextOutProtocolGuid,
+ NULL,
+ &HandleCount,
+ &HandleBuffer
+ );
if (!EFI_ERROR (Status)) {
for (Index = 0; Index < HandleCount; Index++) {
gBS->DisconnectController (HandleBuffer[Index], NULL, NULL);
}
+
for (Index = 0; Index < HandleCount; Index++) {
gBS->ConnectController (HandleBuffer[Index], NULL, NULL, TRUE);
}
+
if (HandleBuffer != NULL) {
FreePool (HandleBuffer);
}
@@ -333,12 +340,12 @@ BmmSetConsoleMode ( **/
CHAR16 *
UiDevicePathToStr (
- IN EFI_DEVICE_PATH_PROTOCOL *DevPath
+ IN EFI_DEVICE_PATH_PROTOCOL *DevPath
)
{
- EFI_STATUS Status;
- CHAR16 *ToText;
- EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *DevPathToText;
+ EFI_STATUS Status;
+ CHAR16 *ToText;
+ EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *DevPathToText;
if (DevPath == NULL) {
return NULL;
@@ -347,7 +354,7 @@ UiDevicePathToStr ( Status = gBS->LocateProtocol (
&gEfiDevicePathToTextProtocolGuid,
NULL,
- (VOID **) &DevPathToText
+ (VOID **)&DevPathToText
);
ASSERT_EFI_ERROR (Status);
ToText = DevPathToText->ConvertDevicePathToText (
@@ -370,34 +377,34 @@ UiDevicePathToStr ( **/
CHAR16 *
ExtractFileNameFromDevicePath (
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
)
{
- CHAR16 *String;
- CHAR16 *MatchString;
- CHAR16 *LastMatch;
- CHAR16 *FileName;
- UINTN Length;
+ CHAR16 *String;
+ CHAR16 *MatchString;
+ CHAR16 *LastMatch;
+ CHAR16 *FileName;
+ UINTN Length;
- ASSERT(DevicePath != NULL);
+ ASSERT (DevicePath != NULL);
- String = UiDevicePathToStr(DevicePath);
+ String = UiDevicePathToStr (DevicePath);
MatchString = String;
LastMatch = String;
FileName = NULL;
- while(MatchString != NULL){
+ while (MatchString != NULL) {
LastMatch = MatchString + 1;
- MatchString = StrStr(LastMatch,L"\\");
+ MatchString = StrStr (LastMatch, L"\\");
}
- Length = StrLen(LastMatch);
- FileName = AllocateCopyPool ((Length + 1) * sizeof(CHAR16), LastMatch);
+ Length = StrLen (LastMatch);
+ FileName = AllocateCopyPool ((Length + 1) * sizeof (CHAR16), LastMatch);
if (FileName != NULL) {
*(FileName + Length) = 0;
}
- FreePool(String);
+ FreePool (String);
return FileName;
}
@@ -413,11 +420,11 @@ ExtractFileNameFromDevicePath ( **/
CHAR16 *
BmmExtractDevicePathFromHiiHandle (
- IN EFI_HII_HANDLE Handle
+ IN EFI_HII_HANDLE Handle
)
{
- EFI_STATUS Status;
- EFI_HANDLE DriverHandle;
+ EFI_STATUS Status;
+ EFI_HANDLE DriverHandle;
ASSERT (Handle != NULL);
@@ -433,8 +440,7 @@ BmmExtractDevicePathFromHiiHandle ( //
// Get device path string.
//
- return ConvertDevicePathToText(DevicePathFromHandle (DriverHandle), FALSE, FALSE);
-
+ return ConvertDevicePathToText (DevicePathFromHandle (DriverHandle), FALSE, FALSE);
}
/**
@@ -462,8 +468,8 @@ HiiToLower ( Lower = TRUE;
} else if (*String == L'&') {
Lower = FALSE;
- } else if (Lower && *String >= L'A' && *String <= L'F') {
- *String = (CHAR16) (*String - L'A' + L'a');
+ } else if (Lower && (*String >= L'A') && (*String <= L'F')) {
+ *String = (CHAR16)(*String - L'A' + L'a');
}
}
}
@@ -476,10 +482,10 @@ HiiToLower ( **/
EFI_STRING
-UpdateProgress(
+UpdateProgress (
IN UINTN Offset,
IN EFI_STRING Configuration
-)
+ )
{
UINTN Length;
EFI_STRING StringPtr;
@@ -492,12 +498,12 @@ UpdateProgress( // &OFFSET=XXXX followed by a Null-terminator.
// Length = StrLen (L"&OFFSET=") + 4 + 1
//
- Length = StrLen (L"&OFFSET=") + 4 + 1;
+ Length = StrLen (L"&OFFSET=") + 4 + 1;
StringPtr = AllocateZeroPool (Length * sizeof (CHAR16));
if (StringPtr == NULL) {
- return NULL;
+ return NULL;
}
UnicodeSPrint (
@@ -530,31 +536,31 @@ UpdateProgress( **/
VOID
UpdateTerminalContent (
- IN BMM_FAKE_NV_DATA *BmmData
+ IN BMM_FAKE_NV_DATA *BmmData
)
{
- UINT16 Index;
- BM_TERMINAL_CONTEXT *NewTerminalContext;
- BM_MENU_ENTRY *NewMenuEntry;
+ UINT16 Index;
+ BM_TERMINAL_CONTEXT *NewTerminalContext;
+ BM_MENU_ENTRY *NewMenuEntry;
for (Index = 0; Index < TerminalMenu.MenuNumber; Index++) {
NewMenuEntry = BOpt_GetMenuEntry (&TerminalMenu, Index);
ASSERT (NewMenuEntry != NULL);
- NewTerminalContext = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext;
+ NewTerminalContext = (BM_TERMINAL_CONTEXT *)NewMenuEntry->VariableContext;
NewTerminalContext->BaudRateIndex = BmmData->COMBaudRate[Index];
ASSERT (BmmData->COMBaudRate[Index] < (ARRAY_SIZE (BaudRateList)));
NewTerminalContext->BaudRate = BaudRateList[BmmData->COMBaudRate[Index]].Value;
NewTerminalContext->DataBitsIndex = BmmData->COMDataRate[Index];
ASSERT (BmmData->COMDataRate[Index] < (ARRAY_SIZE (DataBitsList)));
- NewTerminalContext->DataBits = (UINT8) DataBitsList[BmmData->COMDataRate[Index]].Value;
+ NewTerminalContext->DataBits = (UINT8)DataBitsList[BmmData->COMDataRate[Index]].Value;
NewTerminalContext->StopBitsIndex = BmmData->COMStopBits[Index];
ASSERT (BmmData->COMStopBits[Index] < (ARRAY_SIZE (StopBitsList)));
- NewTerminalContext->StopBits = (UINT8) StopBitsList[BmmData->COMStopBits[Index]].Value;
- NewTerminalContext->ParityIndex = BmmData->COMParity[Index];
+ NewTerminalContext->StopBits = (UINT8)StopBitsList[BmmData->COMStopBits[Index]].Value;
+ NewTerminalContext->ParityIndex = BmmData->COMParity[Index];
ASSERT (BmmData->COMParity[Index] < (ARRAY_SIZE (ParityList)));
- NewTerminalContext->Parity = (UINT8) ParityList[BmmData->COMParity[Index]].Value;
- NewTerminalContext->TerminalType = BmmData->COMTerminalType[Index];
- NewTerminalContext->FlowControl = BmmData->COMFlowControl[Index];
+ NewTerminalContext->Parity = (UINT8)ParityList[BmmData->COMParity[Index]].Value;
+ NewTerminalContext->TerminalType = BmmData->COMTerminalType[Index];
+ NewTerminalContext->FlowControl = BmmData->COMFlowControl[Index];
ChangeTerminalDevicePath (
NewTerminalContext->DevicePath,
FALSE
@@ -570,55 +576,59 @@ UpdateTerminalContent ( **/
VOID
-UpdateConsoleContent(
- IN CHAR16 *ConsoleName,
- IN BMM_FAKE_NV_DATA *BmmData
+UpdateConsoleContent (
+ IN CHAR16 *ConsoleName,
+ IN BMM_FAKE_NV_DATA *BmmData
)
{
- UINT16 Index;
- BM_CONSOLE_CONTEXT *NewConsoleContext;
- BM_TERMINAL_CONTEXT *NewTerminalContext;
- BM_MENU_ENTRY *NewMenuEntry;
+ UINT16 Index;
+ BM_CONSOLE_CONTEXT *NewConsoleContext;
+ BM_TERMINAL_CONTEXT *NewTerminalContext;
+ BM_MENU_ENTRY *NewMenuEntry;
if (StrCmp (ConsoleName, L"ConIn") == 0) {
- for (Index = 0; Index < ConsoleInpMenu.MenuNumber; Index++){
- NewMenuEntry = BOpt_GetMenuEntry(&ConsoleInpMenu, Index);
- NewConsoleContext = (BM_CONSOLE_CONTEXT *)NewMenuEntry->VariableContext;
+ for (Index = 0; Index < ConsoleInpMenu.MenuNumber; Index++) {
+ NewMenuEntry = BOpt_GetMenuEntry (&ConsoleInpMenu, Index);
+ NewConsoleContext = (BM_CONSOLE_CONTEXT *)NewMenuEntry->VariableContext;
ASSERT (Index < MAX_MENU_NUMBER);
NewConsoleContext->IsActive = BmmData->ConsoleInCheck[Index];
}
+
for (Index = 0; Index < TerminalMenu.MenuNumber; Index++) {
- NewMenuEntry = BOpt_GetMenuEntry (&TerminalMenu, Index);
- NewTerminalContext = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext;
+ NewMenuEntry = BOpt_GetMenuEntry (&TerminalMenu, Index);
+ NewTerminalContext = (BM_TERMINAL_CONTEXT *)NewMenuEntry->VariableContext;
ASSERT (Index + ConsoleInpMenu.MenuNumber < MAX_MENU_NUMBER);
NewTerminalContext->IsConIn = BmmData->ConsoleInCheck[Index + ConsoleInpMenu.MenuNumber];
}
}
if (StrCmp (ConsoleName, L"ConOut") == 0) {
- for (Index = 0; Index < ConsoleOutMenu.MenuNumber; Index++){
- NewMenuEntry = BOpt_GetMenuEntry(&ConsoleOutMenu, Index);
- NewConsoleContext = (BM_CONSOLE_CONTEXT *)NewMenuEntry->VariableContext;
+ for (Index = 0; Index < ConsoleOutMenu.MenuNumber; Index++) {
+ NewMenuEntry = BOpt_GetMenuEntry (&ConsoleOutMenu, Index);
+ NewConsoleContext = (BM_CONSOLE_CONTEXT *)NewMenuEntry->VariableContext;
ASSERT (Index < MAX_MENU_NUMBER);
NewConsoleContext->IsActive = BmmData->ConsoleOutCheck[Index];
}
+
for (Index = 0; Index < TerminalMenu.MenuNumber; Index++) {
- NewMenuEntry = BOpt_GetMenuEntry (&TerminalMenu, Index);
- NewTerminalContext = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext;
+ NewMenuEntry = BOpt_GetMenuEntry (&TerminalMenu, Index);
+ NewTerminalContext = (BM_TERMINAL_CONTEXT *)NewMenuEntry->VariableContext;
ASSERT (Index + ConsoleOutMenu.MenuNumber < MAX_MENU_NUMBER);
NewTerminalContext->IsConOut = BmmData->ConsoleOutCheck[Index + ConsoleOutMenu.MenuNumber];
}
}
+
if (StrCmp (ConsoleName, L"ErrOut") == 0) {
- for (Index = 0; Index < ConsoleErrMenu.MenuNumber; Index++){
- NewMenuEntry = BOpt_GetMenuEntry(&ConsoleErrMenu, Index);
- NewConsoleContext = (BM_CONSOLE_CONTEXT *)NewMenuEntry->VariableContext;
+ for (Index = 0; Index < ConsoleErrMenu.MenuNumber; Index++) {
+ NewMenuEntry = BOpt_GetMenuEntry (&ConsoleErrMenu, Index);
+ NewConsoleContext = (BM_CONSOLE_CONTEXT *)NewMenuEntry->VariableContext;
ASSERT (Index < MAX_MENU_NUMBER);
NewConsoleContext->IsActive = BmmData->ConsoleErrCheck[Index];
}
+
for (Index = 0; Index < TerminalMenu.MenuNumber; Index++) {
- NewMenuEntry = BOpt_GetMenuEntry (&TerminalMenu, Index);
- NewTerminalContext = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext;
+ NewMenuEntry = BOpt_GetMenuEntry (&TerminalMenu, Index);
+ NewTerminalContext = (BM_TERMINAL_CONTEXT *)NewMenuEntry->VariableContext;
ASSERT (Index + ConsoleErrMenu.MenuNumber < MAX_MENU_NUMBER);
NewTerminalContext->IsStdErr = BmmData->ConsoleErrCheck[Index + ConsoleErrMenu.MenuNumber];
}
@@ -649,21 +659,21 @@ UpdateConsoleContent( EFI_STATUS
EFIAPI
BootMaintExtractConfig (
- IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
- IN CONST EFI_STRING Request,
- OUT EFI_STRING *Progress,
- OUT EFI_STRING *Results
+ IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
+ IN CONST EFI_STRING Request,
+ OUT EFI_STRING *Progress,
+ OUT EFI_STRING *Results
)
{
EFI_STATUS Status;
UINTN BufferSize;
BMM_CALLBACK_DATA *Private;
- EFI_STRING ConfigRequestHdr;
- EFI_STRING ConfigRequest;
- BOOLEAN AllocatedRequest;
- UINTN Size;
+ EFI_STRING ConfigRequestHdr;
+ EFI_STRING ConfigRequest;
+ BOOLEAN AllocatedRequest;
+ UINTN Size;
- if (Progress == NULL || Results == NULL) {
+ if ((Progress == NULL) || (Results == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -681,7 +691,7 @@ BootMaintExtractConfig ( //
// Convert buffer data to <ConfigResp> by helper function BlockToConfig()
//
- BufferSize = sizeof (BMM_FAKE_NV_DATA);
+ BufferSize = sizeof (BMM_FAKE_NV_DATA);
ConfigRequest = Request;
if ((Request == NULL) || (StrStr (Request, L"OFFSET") == NULL)) {
//
@@ -690,8 +700,8 @@ BootMaintExtractConfig ( // followed by "&OFFSET=0&WIDTH=WWWWWWWWWWWWWWWW" followed by a Null-terminator
//
ConfigRequestHdr = HiiConstructConfigHdr (&mBootMaintGuid, mBootMaintStorageName, Private->BmmDriverHandle);
- Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16);
- ConfigRequest = AllocateZeroPool (Size);
+ Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16);
+ ConfigRequest = AllocateZeroPool (Size);
ASSERT (ConfigRequest != NULL);
AllocatedRequest = TRUE;
UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr, (UINT64)BufferSize);
@@ -701,7 +711,7 @@ BootMaintExtractConfig ( Status = gHiiConfigRouting->BlockToConfig (
gHiiConfigRouting,
ConfigRequest,
- (UINT8 *) &Private->BmmFakeNvData,
+ (UINT8 *)&Private->BmmFakeNvData,
BufferSize,
Results,
Progress
@@ -713,6 +723,7 @@ BootMaintExtractConfig ( FreePool (ConfigRequest);
ConfigRequest = NULL;
}
+
//
// Set Progress string to the original request string.
//
@@ -761,26 +772,27 @@ BootMaintExtractConfig ( EFI_STATUS
EFIAPI
BootMaintRouteConfig (
- IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
- IN CONST EFI_STRING Configuration,
- OUT EFI_STRING *Progress
+ IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
+ IN CONST EFI_STRING Configuration,
+ OUT EFI_STRING *Progress
)
{
- EFI_STATUS Status;
- UINTN BufferSize;
- EFI_HII_CONFIG_ROUTING_PROTOCOL *ConfigRouting;
- BMM_FAKE_NV_DATA *NewBmmData;
- BMM_FAKE_NV_DATA *OldBmmData;
- BM_MENU_ENTRY *NewMenuEntry;
- BM_LOAD_CONTEXT *NewLoadContext;
- UINT16 Index;
- BOOLEAN TerminalAttChange;
- BMM_CALLBACK_DATA *Private;
- UINTN Offset;
+ EFI_STATUS Status;
+ UINTN BufferSize;
+ EFI_HII_CONFIG_ROUTING_PROTOCOL *ConfigRouting;
+ BMM_FAKE_NV_DATA *NewBmmData;
+ BMM_FAKE_NV_DATA *OldBmmData;
+ BM_MENU_ENTRY *NewMenuEntry;
+ BM_LOAD_CONTEXT *NewLoadContext;
+ UINT16 Index;
+ BOOLEAN TerminalAttChange;
+ BMM_CALLBACK_DATA *Private;
+ UINTN Offset;
if (Progress == NULL) {
return EFI_INVALID_PARAMETER;
}
+
*Progress = Configuration;
if (Configuration == NULL) {
@@ -818,7 +830,7 @@ BootMaintRouteConfig ( Status = ConfigRouting->ConfigToBlock (
ConfigRouting,
Configuration,
- (UINT8 *) NewBmmData,
+ (UINT8 *)NewBmmData,
&BufferSize,
Progress
);
@@ -845,11 +857,12 @@ BootMaintRouteConfig ( if (CompareMem (NewBmmData->BootOptionDel, OldBmmData->BootOptionDel, sizeof (NewBmmData->BootOptionDel)) != 0) {
for (Index = 0;
((Index < BootOptionMenu.MenuNumber) && (Index < (sizeof (NewBmmData->BootOptionDel) / sizeof (NewBmmData->BootOptionDel[0]))));
- Index ++) {
- NewMenuEntry = BOpt_GetMenuEntry (&BootOptionMenu, Index);
- NewLoadContext = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext;
- NewLoadContext->Deleted = NewBmmData->BootOptionDel[Index];
- NewBmmData->BootOptionDel[Index] = FALSE;
+ Index++)
+ {
+ NewMenuEntry = BOpt_GetMenuEntry (&BootOptionMenu, Index);
+ NewLoadContext = (BM_LOAD_CONTEXT *)NewMenuEntry->VariableContext;
+ NewLoadContext->Deleted = NewBmmData->BootOptionDel[Index];
+ NewBmmData->BootOptionDel[Index] = FALSE;
NewBmmData->BootOptionDelMark[Index] = FALSE;
}
@@ -868,18 +881,19 @@ BootMaintRouteConfig ( }
}
- if (CompareMem (&NewBmmData->BootTimeOut, &OldBmmData->BootTimeOut, sizeof (NewBmmData->BootTimeOut)) != 0){
- Status = gRT->SetVariable(
+ if (CompareMem (&NewBmmData->BootTimeOut, &OldBmmData->BootTimeOut, sizeof (NewBmmData->BootTimeOut)) != 0) {
+ Status = gRT->SetVariable (
L"Timeout",
&gEfiGlobalVariableGuid,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
- sizeof(UINT16),
+ sizeof (UINT16),
&(NewBmmData->BootTimeOut)
);
if (EFI_ERROR (Status)) {
Offset = OFFSET_OF (BMM_FAKE_NV_DATA, BootTimeOut);
goto Exit;
}
+
Private->BmmOldFakeNVData.BootTimeOut = NewBmmData->BootTimeOut;
}
@@ -889,13 +903,15 @@ BootMaintRouteConfig ( if (CompareMem (NewBmmData->DriverOptionDel, OldBmmData->DriverOptionDel, sizeof (NewBmmData->DriverOptionDel)) != 0) {
for (Index = 0;
((Index < DriverOptionMenu.MenuNumber) && (Index < (sizeof (NewBmmData->DriverOptionDel) / sizeof (NewBmmData->DriverOptionDel[0]))));
- Index++) {
- NewMenuEntry = BOpt_GetMenuEntry (&DriverOptionMenu, Index);
- NewLoadContext = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext;
- NewLoadContext->Deleted = NewBmmData->DriverOptionDel[Index];
- NewBmmData->DriverOptionDel[Index] = FALSE;
+ Index++)
+ {
+ NewMenuEntry = BOpt_GetMenuEntry (&DriverOptionMenu, Index);
+ NewLoadContext = (BM_LOAD_CONTEXT *)NewMenuEntry->VariableContext;
+ NewLoadContext->Deleted = NewBmmData->DriverOptionDel[Index];
+ NewBmmData->DriverOptionDel[Index] = FALSE;
NewBmmData->DriverOptionDelMark[Index] = FALSE;
}
+
Status = Var_DelDriverOption ();
if (EFI_ERROR (Status)) {
Offset = OFFSET_OF (BMM_FAKE_NV_DATA, DriverOptionDel);
@@ -911,8 +927,8 @@ BootMaintRouteConfig ( }
}
- if (CompareMem (&NewBmmData->ConsoleOutMode, &OldBmmData->ConsoleOutMode, sizeof (NewBmmData->ConsoleOutMode)) != 0){
- Status = Var_UpdateConMode(Private);
+ if (CompareMem (&NewBmmData->ConsoleOutMode, &OldBmmData->ConsoleOutMode, sizeof (NewBmmData->ConsoleOutMode)) != 0) {
+ Status = Var_UpdateConMode (Private);
if (EFI_ERROR (Status)) {
Offset = OFFSET_OF (BMM_FAKE_NV_DATA, ConsoleOutMode);
goto Exit;
@@ -921,21 +937,22 @@ BootMaintRouteConfig ( TerminalAttChange = FALSE;
for (Index = 0; Index < TerminalMenu.MenuNumber; Index++) {
-
//
// only need update modified items
//
- if (CompareMem (&NewBmmData->COMBaudRate[Index], &OldBmmData->COMBaudRate[Index], sizeof (NewBmmData->COMBaudRate[Index])) == 0 &&
- CompareMem (&NewBmmData->COMDataRate[Index], &OldBmmData->COMDataRate[Index], sizeof (NewBmmData->COMDataRate[Index])) == 0 &&
- CompareMem (&NewBmmData->COMStopBits[Index], &OldBmmData->COMStopBits[Index], sizeof (NewBmmData->COMStopBits[Index])) == 0 &&
- CompareMem (&NewBmmData->COMParity[Index], &OldBmmData->COMParity[Index], sizeof (NewBmmData->COMParity[Index])) == 0 &&
- CompareMem (&NewBmmData->COMTerminalType[Index], &OldBmmData->COMTerminalType[Index], sizeof (NewBmmData->COMTerminalType[Index])) == 0 &&
- CompareMem (&NewBmmData->COMFlowControl[Index], &OldBmmData->COMFlowControl[Index], sizeof (NewBmmData->COMFlowControl[Index])) == 0) {
+ if ((CompareMem (&NewBmmData->COMBaudRate[Index], &OldBmmData->COMBaudRate[Index], sizeof (NewBmmData->COMBaudRate[Index])) == 0) &&
+ (CompareMem (&NewBmmData->COMDataRate[Index], &OldBmmData->COMDataRate[Index], sizeof (NewBmmData->COMDataRate[Index])) == 0) &&
+ (CompareMem (&NewBmmData->COMStopBits[Index], &OldBmmData->COMStopBits[Index], sizeof (NewBmmData->COMStopBits[Index])) == 0) &&
+ (CompareMem (&NewBmmData->COMParity[Index], &OldBmmData->COMParity[Index], sizeof (NewBmmData->COMParity[Index])) == 0) &&
+ (CompareMem (&NewBmmData->COMTerminalType[Index], &OldBmmData->COMTerminalType[Index], sizeof (NewBmmData->COMTerminalType[Index])) == 0) &&
+ (CompareMem (&NewBmmData->COMFlowControl[Index], &OldBmmData->COMFlowControl[Index], sizeof (NewBmmData->COMFlowControl[Index])) == 0))
+ {
continue;
}
TerminalAttChange = TRUE;
}
+
if (TerminalAttChange) {
if (CompareMem (&NewBmmData->COMBaudRate[Index], &OldBmmData->COMBaudRate[Index], sizeof (NewBmmData->COMBaudRate[Index])) != 0) {
Offset = OFFSET_OF (BMM_FAKE_NV_DATA, COMBaudRate);
@@ -950,49 +967,54 @@ BootMaintRouteConfig ( } else if (CompareMem (&NewBmmData->COMFlowControl[Index], &OldBmmData->COMFlowControl[Index], sizeof (NewBmmData->COMFlowControl[Index])) != 0) {
Offset = OFFSET_OF (BMM_FAKE_NV_DATA, COMFlowControl);
}
+
Status = Var_UpdateConsoleInpOption ();
if (EFI_ERROR (Status)) {
goto Exit;
}
+
Status = Var_UpdateConsoleOutOption ();
if (EFI_ERROR (Status)) {
goto Exit;
}
+
Status = Var_UpdateErrorOutOption ();
if (EFI_ERROR (Status)) {
goto Exit;
}
}
+
//
// Check data which located in Console Options Menu and save the settings if need
//
- if (CompareMem (NewBmmData->ConsoleInCheck, OldBmmData->ConsoleInCheck, sizeof (NewBmmData->ConsoleInCheck)) != 0){
- Status = Var_UpdateConsoleInpOption();
+ if (CompareMem (NewBmmData->ConsoleInCheck, OldBmmData->ConsoleInCheck, sizeof (NewBmmData->ConsoleInCheck)) != 0) {
+ Status = Var_UpdateConsoleInpOption ();
if (EFI_ERROR (Status)) {
Offset = OFFSET_OF (BMM_FAKE_NV_DATA, ConsoleInCheck);
goto Exit;
}
}
- if (CompareMem (NewBmmData->ConsoleOutCheck, OldBmmData->ConsoleOutCheck, sizeof (NewBmmData->ConsoleOutCheck)) != 0){
- Status = Var_UpdateConsoleOutOption();
+ if (CompareMem (NewBmmData->ConsoleOutCheck, OldBmmData->ConsoleOutCheck, sizeof (NewBmmData->ConsoleOutCheck)) != 0) {
+ Status = Var_UpdateConsoleOutOption ();
if (EFI_ERROR (Status)) {
Offset = OFFSET_OF (BMM_FAKE_NV_DATA, ConsoleOutCheck);
goto Exit;
}
}
- if (CompareMem (NewBmmData->ConsoleErrCheck, OldBmmData->ConsoleErrCheck, sizeof (NewBmmData->ConsoleErrCheck)) != 0){
- Status = Var_UpdateErrorOutOption();
+ if (CompareMem (NewBmmData->ConsoleErrCheck, OldBmmData->ConsoleErrCheck, sizeof (NewBmmData->ConsoleErrCheck)) != 0) {
+ Status = Var_UpdateErrorOutOption ();
if (EFI_ERROR (Status)) {
Offset = OFFSET_OF (BMM_FAKE_NV_DATA, ConsoleErrCheck);
goto Exit;
}
}
- if (CompareMem (NewBmmData->BootDescriptionData, OldBmmData->BootDescriptionData, sizeof (NewBmmData->BootDescriptionData)) != 0 ||
- CompareMem (NewBmmData->BootOptionalData, OldBmmData->BootOptionalData, sizeof (NewBmmData->BootOptionalData)) != 0) {
- Status = Var_UpdateBootOption (Private);
+ if ((CompareMem (NewBmmData->BootDescriptionData, OldBmmData->BootDescriptionData, sizeof (NewBmmData->BootDescriptionData)) != 0) ||
+ (CompareMem (NewBmmData->BootOptionalData, OldBmmData->BootOptionalData, sizeof (NewBmmData->BootOptionalData)) != 0))
+ {
+ Status = Var_UpdateBootOption (Private);
NewBmmData->BootOptionChanged = FALSE;
if (EFI_ERROR (Status)) {
if (CompareMem (NewBmmData->BootDescriptionData, OldBmmData->BootDescriptionData, sizeof (NewBmmData->BootDescriptionData)) != 0) {
@@ -1000,20 +1022,23 @@ BootMaintRouteConfig ( } else {
Offset = OFFSET_OF (BMM_FAKE_NV_DATA, BootOptionalData);
}
+
goto Exit;
}
+
BOpt_GetBootOptions (Private);
}
- if (CompareMem (NewBmmData->DriverDescriptionData, OldBmmData->DriverDescriptionData, sizeof (NewBmmData->DriverDescriptionData)) != 0 ||
- CompareMem (NewBmmData->DriverOptionalData, OldBmmData->DriverOptionalData, sizeof (NewBmmData->DriverOptionalData)) != 0) {
+ if ((CompareMem (NewBmmData->DriverDescriptionData, OldBmmData->DriverDescriptionData, sizeof (NewBmmData->DriverDescriptionData)) != 0) ||
+ (CompareMem (NewBmmData->DriverOptionalData, OldBmmData->DriverOptionalData, sizeof (NewBmmData->DriverOptionalData)) != 0))
+ {
Status = Var_UpdateDriverOption (
- Private,
- Private->BmmHiiHandle,
- NewBmmData->DriverDescriptionData,
- NewBmmData->DriverOptionalData,
- NewBmmData->ForceReconnect
- );
+ Private,
+ Private->BmmHiiHandle,
+ NewBmmData->DriverDescriptionData,
+ NewBmmData->DriverOptionalData,
+ NewBmmData->ForceReconnect
+ );
NewBmmData->DriverOptionChanged = FALSE;
NewBmmData->ForceReconnect = TRUE;
if (EFI_ERROR (Status)) {
@@ -1022,6 +1047,7 @@ BootMaintRouteConfig ( } else {
Offset = OFFSET_OF (BMM_FAKE_NV_DATA, DriverOptionalData);
}
+
goto Exit;
}
@@ -1068,29 +1094,29 @@ Exit: EFI_STATUS
EFIAPI
BootMaintCallback (
- IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
- IN EFI_BROWSER_ACTION Action,
- IN EFI_QUESTION_ID QuestionId,
- IN UINT8 Type,
- IN EFI_IFR_TYPE_VALUE *Value,
- OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
+ IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
+ IN EFI_BROWSER_ACTION Action,
+ IN EFI_QUESTION_ID QuestionId,
+ IN UINT8 Type,
+ IN EFI_IFR_TYPE_VALUE *Value,
+ OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
)
{
- BMM_CALLBACK_DATA *Private;
- BM_MENU_ENTRY *NewMenuEntry;
- BMM_FAKE_NV_DATA *CurrentFakeNVMap;
- BMM_FAKE_NV_DATA *OldFakeNVMap;
- UINTN Index;
- EFI_DEVICE_PATH_PROTOCOL * File;
-
- if (Action != EFI_BROWSER_ACTION_CHANGING && Action != EFI_BROWSER_ACTION_CHANGED && Action != EFI_BROWSER_ACTION_FORM_OPEN) {
+ BMM_CALLBACK_DATA *Private;
+ BM_MENU_ENTRY *NewMenuEntry;
+ BMM_FAKE_NV_DATA *CurrentFakeNVMap;
+ BMM_FAKE_NV_DATA *OldFakeNVMap;
+ UINTN Index;
+ EFI_DEVICE_PATH_PROTOCOL *File;
+
+ if ((Action != EFI_BROWSER_ACTION_CHANGING) && (Action != EFI_BROWSER_ACTION_CHANGED) && (Action != EFI_BROWSER_ACTION_FORM_OPEN)) {
//
// Do nothing for other UEFI Action. Only do call back when data is changed or the form is open.
//
return EFI_UNSUPPORTED;
}
- Private = BMM_CALLBACK_DATA_FROM_THIS (This);
+ Private = BMM_CALLBACK_DATA_FROM_THIS (This);
if (Action == EFI_BROWSER_ACTION_FORM_OPEN) {
if (QuestionId == KEY_VALUE_TRIGGER_FORM_OPEN_ACTION) {
@@ -1111,12 +1137,13 @@ BootMaintCallback ( }
}
}
+
//
// Retrieve uncommitted data from Form Browser
//
CurrentFakeNVMap = &Private->BmmFakeNvData;
OldFakeNVMap = &Private->BmmOldFakeNVData;
- HiiGetBrowserData (&mBootMaintGuid, mBootMaintStorageName, sizeof (BMM_FAKE_NV_DATA), (UINT8 *) CurrentFakeNVMap);
+ HiiGetBrowserData (&mBootMaintGuid, mBootMaintStorageName, sizeof (BMM_FAKE_NV_DATA), (UINT8 *)CurrentFakeNVMap);
if (Action == EFI_BROWSER_ACTION_CHANGING) {
if (Value == NULL) {
@@ -1128,78 +1155,78 @@ BootMaintCallback ( if (QuestionId < FILE_OPTION_OFFSET) {
if (QuestionId < CONFIG_OPTION_OFFSET) {
switch (QuestionId) {
- case FORM_BOOT_ADD_ID:
- // Leave BMM and enter FileExplorer.
- ChooseFile (NULL, L".efi", CreateBootOptionFromFile, &File);
- break;
+ case FORM_BOOT_ADD_ID:
+ // Leave BMM and enter FileExplorer.
+ ChooseFile (NULL, L".efi", CreateBootOptionFromFile, &File);
+ break;
- case FORM_DRV_ADD_FILE_ID:
- // Leave BMM and enter FileExplorer.
- ChooseFile (NULL, L".efi", CreateDriverOptionFromFile, &File);
- break;
+ case FORM_DRV_ADD_FILE_ID:
+ // Leave BMM and enter FileExplorer.
+ ChooseFile (NULL, L".efi", CreateDriverOptionFromFile, &File);
+ break;
- case FORM_DRV_ADD_HANDLE_ID:
- CleanUpPage (FORM_DRV_ADD_HANDLE_ID, Private);
- UpdateDrvAddHandlePage (Private);
- break;
+ case FORM_DRV_ADD_HANDLE_ID:
+ CleanUpPage (FORM_DRV_ADD_HANDLE_ID, Private);
+ UpdateDrvAddHandlePage (Private);
+ break;
- case FORM_BOOT_DEL_ID:
- CleanUpPage (FORM_BOOT_DEL_ID, Private);
- UpdateBootDelPage (Private);
- break;
+ case FORM_BOOT_DEL_ID:
+ CleanUpPage (FORM_BOOT_DEL_ID, Private);
+ UpdateBootDelPage (Private);
+ break;
- case FORM_BOOT_CHG_ID:
- case FORM_DRV_CHG_ID:
- UpdatePageBody (QuestionId, Private);
- break;
+ case FORM_BOOT_CHG_ID:
+ case FORM_DRV_CHG_ID:
+ UpdatePageBody (QuestionId, Private);
+ break;
- case FORM_DRV_DEL_ID:
- CleanUpPage (FORM_DRV_DEL_ID, Private);
- UpdateDrvDelPage (Private);
- break;
+ case FORM_DRV_DEL_ID:
+ CleanUpPage (FORM_DRV_DEL_ID, Private);
+ UpdateDrvDelPage (Private);
+ break;
- case FORM_CON_IN_ID:
- case FORM_CON_OUT_ID:
- case FORM_CON_ERR_ID:
- UpdatePageBody (QuestionId, Private);
- break;
+ case FORM_CON_IN_ID:
+ case FORM_CON_OUT_ID:
+ case FORM_CON_ERR_ID:
+ UpdatePageBody (QuestionId, Private);
+ break;
- case FORM_CON_MODE_ID:
- CleanUpPage (FORM_CON_MODE_ID, Private);
- UpdateConModePage (Private);
- break;
+ case FORM_CON_MODE_ID:
+ CleanUpPage (FORM_CON_MODE_ID, Private);
+ UpdateConModePage (Private);
+ break;
- case FORM_CON_COM_ID:
- CleanUpPage (FORM_CON_COM_ID, Private);
- UpdateConCOMPage (Private);
- break;
+ case FORM_CON_COM_ID:
+ CleanUpPage (FORM_CON_COM_ID, Private);
+ UpdateConCOMPage (Private);
+ break;
- default:
- break;
+ default:
+ break;
}
} else if ((QuestionId >= TERMINAL_OPTION_OFFSET) && (QuestionId < CONSOLE_OPTION_OFFSET)) {
- Index = (UINT16) (QuestionId - TERMINAL_OPTION_OFFSET);
- Private->CurrentTerminal = Index;
+ Index = (UINT16)(QuestionId - TERMINAL_OPTION_OFFSET);
+ Private->CurrentTerminal = Index;
CleanUpPage (FORM_CON_COM_SETUP_ID, Private);
UpdateTerminalPage (Private);
-
} else if (QuestionId >= HANDLE_OPTION_OFFSET) {
- Index = (UINT16) (QuestionId - HANDLE_OPTION_OFFSET);
+ Index = (UINT16)(QuestionId - HANDLE_OPTION_OFFSET);
- NewMenuEntry = BOpt_GetMenuEntry (&DriverMenu, Index);
+ NewMenuEntry = BOpt_GetMenuEntry (&DriverMenu, Index);
ASSERT (NewMenuEntry != NULL);
- Private->HandleContext = (BM_HANDLE_CONTEXT *) NewMenuEntry->VariableContext;
+ Private->HandleContext = (BM_HANDLE_CONTEXT *)NewMenuEntry->VariableContext;
CleanUpPage (FORM_DRV_ADD_HANDLE_DESC_ID, Private);
- Private->MenuEntry = NewMenuEntry;
- Private->LoadContext->FilePathList = Private->HandleContext->DevicePath;
+ Private->MenuEntry = NewMenuEntry;
+ Private->LoadContext->FilePathList = Private->HandleContext->DevicePath;
UpdateDriverAddHandleDescPage (Private);
}
}
- if (QuestionId == KEY_VALUE_BOOT_FROM_FILE){
+
+ if (QuestionId == KEY_VALUE_BOOT_FROM_FILE) {
// Leave BMM and enter FileExplorer.
ChooseFile (NULL, L".efi", BootFromFile, &File);
}
@@ -1211,11 +1238,11 @@ BootMaintCallback ( if (QuestionId == KEY_VALUE_SAVE_AND_EXIT_BOOT) {
CleanUselessBeforeSubmit (Private);
CurrentFakeNVMap->BootOptionChanged = FALSE;
- *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_SUBMIT_EXIT;
+ *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_SUBMIT_EXIT;
} else if (QuestionId == KEY_VALUE_SAVE_AND_EXIT_DRIVER) {
CleanUselessBeforeSubmit (Private);
CurrentFakeNVMap->DriverOptionChanged = FALSE;
- *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_SUBMIT_EXIT;
+ *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_SUBMIT_EXIT;
} else if (QuestionId == KEY_VALUE_NO_SAVE_AND_EXIT_DRIVER) {
//
// Discard changes and exit formset
@@ -1226,7 +1253,7 @@ BootMaintCallback ( ZeroMem (OldFakeNVMap->DriverDescriptionData, sizeof (OldFakeNVMap->DriverDescriptionData));
CurrentFakeNVMap->DriverOptionChanged = FALSE;
CurrentFakeNVMap->ForceReconnect = TRUE;
- *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD_EXIT;
+ *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD_EXIT;
} else if (QuestionId == KEY_VALUE_NO_SAVE_AND_EXIT_BOOT) {
//
// Discard changes and exit formset
@@ -1236,15 +1263,15 @@ BootMaintCallback ( ZeroMem (OldFakeNVMap->BootOptionalData, sizeof (OldFakeNVMap->BootOptionalData));
ZeroMem (OldFakeNVMap->BootDescriptionData, sizeof (OldFakeNVMap->BootDescriptionData));
CurrentFakeNVMap->BootOptionChanged = FALSE;
- *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD_EXIT;
- } else if (QuestionId == KEY_VALUE_BOOT_DESCRIPTION || QuestionId == KEY_VALUE_BOOT_OPTION) {
+ *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD_EXIT;
+ } else if ((QuestionId == KEY_VALUE_BOOT_DESCRIPTION) || (QuestionId == KEY_VALUE_BOOT_OPTION)) {
CurrentFakeNVMap->BootOptionChanged = TRUE;
- } else if (QuestionId == KEY_VALUE_DRIVER_DESCRIPTION || QuestionId == KEY_VALUE_DRIVER_OPTION) {
+ } else if ((QuestionId == KEY_VALUE_DRIVER_DESCRIPTION) || (QuestionId == KEY_VALUE_DRIVER_OPTION)) {
CurrentFakeNVMap->DriverOptionChanged = TRUE;
}
if ((QuestionId >= BOOT_OPTION_DEL_QUESTION_ID) && (QuestionId < BOOT_OPTION_DEL_QUESTION_ID + MAX_MENU_NUMBER)) {
- if (Value->b){
+ if (Value->b) {
//
// Means user try to delete this boot option but not press F10 or "Commit Changes and Exit" menu.
//
@@ -1256,44 +1283,47 @@ BootMaintCallback ( CurrentFakeNVMap->BootOptionDelMark[QuestionId - BOOT_OPTION_DEL_QUESTION_ID] = FALSE;
}
} else if ((QuestionId >= DRIVER_OPTION_DEL_QUESTION_ID) && (QuestionId < DRIVER_OPTION_DEL_QUESTION_ID + MAX_MENU_NUMBER)) {
- if (Value->b){
+ if (Value->b) {
CurrentFakeNVMap->DriverOptionDelMark[QuestionId - DRIVER_OPTION_DEL_QUESTION_ID] = TRUE;
} else {
CurrentFakeNVMap->DriverOptionDelMark[QuestionId - DRIVER_OPTION_DEL_QUESTION_ID] = FALSE;
}
} else {
switch (QuestionId) {
- case KEY_VALUE_SAVE_AND_EXIT:
- case KEY_VALUE_NO_SAVE_AND_EXIT:
- if (QuestionId == KEY_VALUE_SAVE_AND_EXIT) {
- CleanUselessBeforeSubmit (Private);
- *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_SUBMIT_EXIT;
- } else if (QuestionId == KEY_VALUE_NO_SAVE_AND_EXIT) {
- DiscardChangeHandler (Private, CurrentFakeNVMap);
- *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD_EXIT;
- }
+ case KEY_VALUE_SAVE_AND_EXIT:
+ case KEY_VALUE_NO_SAVE_AND_EXIT:
+ if (QuestionId == KEY_VALUE_SAVE_AND_EXIT) {
+ CleanUselessBeforeSubmit (Private);
+ *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_SUBMIT_EXIT;
+ } else if (QuestionId == KEY_VALUE_NO_SAVE_AND_EXIT) {
+ DiscardChangeHandler (Private, CurrentFakeNVMap);
+ *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD_EXIT;
+ }
- break;
+ break;
- case FORM_RESET:
- gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL);
- return EFI_UNSUPPORTED;
+ case FORM_RESET:
+ gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL);
+ return EFI_UNSUPPORTED;
- default:
- break;
+ default:
+ break;
}
}
+
//
// Update the content in Terminal menu and Console menu here.
//
- if (QuestionId == COM_BAUD_RATE_QUESTION_ID + Private->CurrentTerminal || QuestionId == COM_DATA_RATE_QUESTION_ID + Private->CurrentTerminal ||
- QuestionId == COM_PARITY_QUESTION_ID + Private->CurrentTerminal || QuestionId == COM_STOP_BITS_QUESTION_ID + Private->CurrentTerminal ||
- QuestionId == COM_TERMINAL_QUESTION_ID + Private->CurrentTerminal || QuestionId == COM_FLOWCONTROL_QUESTION_ID + Private->CurrentTerminal
- ) {
- UpdateTerminalContent(CurrentFakeNVMap);
+ if ((QuestionId == COM_BAUD_RATE_QUESTION_ID + Private->CurrentTerminal) || (QuestionId == COM_DATA_RATE_QUESTION_ID + Private->CurrentTerminal) ||
+ (QuestionId == COM_PARITY_QUESTION_ID + Private->CurrentTerminal) || (QuestionId == COM_STOP_BITS_QUESTION_ID + Private->CurrentTerminal) ||
+ (QuestionId == COM_TERMINAL_QUESTION_ID + Private->CurrentTerminal) || (QuestionId == COM_FLOWCONTROL_QUESTION_ID + Private->CurrentTerminal)
+ )
+ {
+ UpdateTerminalContent (CurrentFakeNVMap);
}
+
if ((QuestionId >= CON_IN_DEVICE_QUESTION_ID) && (QuestionId < CON_IN_DEVICE_QUESTION_ID + MAX_MENU_NUMBER)) {
- UpdateConsoleContent (L"ConIn",CurrentFakeNVMap);
+ UpdateConsoleContent (L"ConIn", CurrentFakeNVMap);
} else if ((QuestionId >= CON_OUT_DEVICE_QUESTION_ID) && (QuestionId < CON_OUT_DEVICE_QUESTION_ID + MAX_MENU_NUMBER)) {
UpdateConsoleContent (L"ConOut", CurrentFakeNVMap);
} else if ((QuestionId >= CON_ERR_DEVICE_QUESTION_ID) && (QuestionId < CON_ERR_DEVICE_QUESTION_ID + MAX_MENU_NUMBER)) {
@@ -1304,7 +1334,7 @@ BootMaintCallback ( //
// Pass changed uncommitted data back to Form Browser
//
- HiiSetBrowserData (&mBootMaintGuid, mBootMaintStorageName, sizeof (BMM_FAKE_NV_DATA), (UINT8 *) CurrentFakeNVMap, NULL);
+ HiiSetBrowserData (&mBootMaintGuid, mBootMaintStorageName, sizeof (BMM_FAKE_NV_DATA), (UINT8 *)CurrentFakeNVMap, NULL);
return EFI_SUCCESS;
}
@@ -1319,52 +1349,54 @@ BootMaintCallback ( **/
VOID
DiscardChangeHandler (
- IN BMM_CALLBACK_DATA *Private,
- IN BMM_FAKE_NV_DATA *CurrentFakeNVMap
+ IN BMM_CALLBACK_DATA *Private,
+ IN BMM_FAKE_NV_DATA *CurrentFakeNVMap
)
{
UINT16 Index;
switch (Private->BmmPreviousPageId) {
- case FORM_BOOT_CHG_ID:
- CopyMem (CurrentFakeNVMap->BootOptionOrder, Private->BmmOldFakeNVData.BootOptionOrder, sizeof (CurrentFakeNVMap->BootOptionOrder));
- break;
+ case FORM_BOOT_CHG_ID:
+ CopyMem (CurrentFakeNVMap->BootOptionOrder, Private->BmmOldFakeNVData.BootOptionOrder, sizeof (CurrentFakeNVMap->BootOptionOrder));
+ break;
- case FORM_DRV_CHG_ID:
- CopyMem (CurrentFakeNVMap->DriverOptionOrder, Private->BmmOldFakeNVData.DriverOptionOrder, sizeof (CurrentFakeNVMap->DriverOptionOrder));
- break;
+ case FORM_DRV_CHG_ID:
+ CopyMem (CurrentFakeNVMap->DriverOptionOrder, Private->BmmOldFakeNVData.DriverOptionOrder, sizeof (CurrentFakeNVMap->DriverOptionOrder));
+ break;
- case FORM_BOOT_DEL_ID:
- ASSERT (BootOptionMenu.MenuNumber <= (sizeof (CurrentFakeNVMap->BootOptionDel) / sizeof (CurrentFakeNVMap->BootOptionDel[0])));
- for (Index = 0; Index < BootOptionMenu.MenuNumber; Index++) {
- CurrentFakeNVMap->BootOptionDel[Index] = FALSE;
- }
- break;
+ case FORM_BOOT_DEL_ID:
+ ASSERT (BootOptionMenu.MenuNumber <= (sizeof (CurrentFakeNVMap->BootOptionDel) / sizeof (CurrentFakeNVMap->BootOptionDel[0])));
+ for (Index = 0; Index < BootOptionMenu.MenuNumber; Index++) {
+ CurrentFakeNVMap->BootOptionDel[Index] = FALSE;
+ }
- case FORM_DRV_DEL_ID:
- ASSERT (DriverOptionMenu.MenuNumber <= (sizeof (CurrentFakeNVMap->DriverOptionDel) / sizeof (CurrentFakeNVMap->DriverOptionDel[0])));
- for (Index = 0; Index < DriverOptionMenu.MenuNumber; Index++) {
- CurrentFakeNVMap->DriverOptionDel[Index] = FALSE;
- }
- break;
+ break;
- case FORM_BOOT_NEXT_ID:
- CurrentFakeNVMap->BootNext = Private->BmmOldFakeNVData.BootNext;
- break;
+ case FORM_DRV_DEL_ID:
+ ASSERT (DriverOptionMenu.MenuNumber <= (sizeof (CurrentFakeNVMap->DriverOptionDel) / sizeof (CurrentFakeNVMap->DriverOptionDel[0])));
+ for (Index = 0; Index < DriverOptionMenu.MenuNumber; Index++) {
+ CurrentFakeNVMap->DriverOptionDel[Index] = FALSE;
+ }
- case FORM_TIME_OUT_ID:
- CurrentFakeNVMap->BootTimeOut = Private->BmmOldFakeNVData.BootTimeOut;
- break;
+ break;
- case FORM_DRV_ADD_HANDLE_DESC_ID:
- case FORM_DRV_ADD_FILE_ID:
- case FORM_DRV_ADD_HANDLE_ID:
- CurrentFakeNVMap->DriverAddHandleDesc[0] = 0x0000;
- CurrentFakeNVMap->DriverAddHandleOptionalData[0] = 0x0000;
- break;
+ case FORM_BOOT_NEXT_ID:
+ CurrentFakeNVMap->BootNext = Private->BmmOldFakeNVData.BootNext;
+ break;
+
+ case FORM_TIME_OUT_ID:
+ CurrentFakeNVMap->BootTimeOut = Private->BmmOldFakeNVData.BootTimeOut;
+ break;
- default:
- break;
+ case FORM_DRV_ADD_HANDLE_DESC_ID:
+ case FORM_DRV_ADD_FILE_ID:
+ case FORM_DRV_ADD_HANDLE_ID:
+ CurrentFakeNVMap->DriverAddHandleDesc[0] = 0x0000;
+ CurrentFakeNVMap->DriverAddHandleOptionalData[0] = 0x0000;
+ break;
+
+ default:
+ break;
}
}
@@ -1376,22 +1408,24 @@ DiscardChangeHandler ( **/
VOID
CleanUselessBeforeSubmit (
- IN BMM_CALLBACK_DATA *Private
+ IN BMM_CALLBACK_DATA *Private
)
{
UINT16 Index;
+
if (Private->BmmPreviousPageId != FORM_BOOT_DEL_ID) {
for (Index = 0; Index < BootOptionMenu.MenuNumber; Index++) {
if (Private->BmmFakeNvData.BootOptionDel[Index] && !Private->BmmFakeNvData.BootOptionDelMark[Index]) {
- Private->BmmFakeNvData.BootOptionDel[Index] = FALSE;
+ Private->BmmFakeNvData.BootOptionDel[Index] = FALSE;
Private->BmmOldFakeNVData.BootOptionDel[Index] = FALSE;
}
}
}
+
if (Private->BmmPreviousPageId != FORM_DRV_DEL_ID) {
for (Index = 0; Index < DriverOptionMenu.MenuNumber; Index++) {
if (Private->BmmFakeNvData.DriverOptionDel[Index] && !Private->BmmFakeNvData.DriverOptionDelMark[Index]) {
- Private->BmmFakeNvData.DriverOptionDel[Index] = FALSE;
+ Private->BmmFakeNvData.DriverOptionDel[Index] = FALSE;
Private->BmmOldFakeNVData.DriverOptionDel[Index] = FALSE;
}
}
@@ -1408,10 +1442,10 @@ CustomizeMenus ( VOID
)
{
- VOID *StartOpCodeHandle;
- VOID *EndOpCodeHandle;
- EFI_IFR_GUID_LABEL *StartGuidLabel;
- EFI_IFR_GUID_LABEL *EndGuidLabel;
+ VOID *StartOpCodeHandle;
+ VOID *EndOpCodeHandle;
+ EFI_IFR_GUID_LABEL *StartGuidLabel;
+ EFI_IFR_GUID_LABEL *EndGuidLabel;
//
// Allocate space for creation of UpdateData Buffer
@@ -1424,18 +1458,18 @@ CustomizeMenus ( //
// Create Hii Extend Label OpCode as the start opcode
//
- StartGuidLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (StartOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));
+ StartGuidLabel = (EFI_IFR_GUID_LABEL *)HiiCreateGuidOpCode (StartOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));
StartGuidLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;
StartGuidLabel->Number = LABEL_FORM_MAIN_START;
//
// Create Hii Extend Label OpCode as the end opcode
//
- EndGuidLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (EndOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));
+ EndGuidLabel = (EFI_IFR_GUID_LABEL *)HiiCreateGuidOpCode (EndOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));
EndGuidLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;
EndGuidLabel->Number = LABEL_FORM_MAIN_END;
//
- //Updata Front Page form
+ // Updata Front Page form
//
UiCustomizeBMMPage (
mBmmCallbackInfo->BmmHiiHandle,
@@ -1463,12 +1497,12 @@ CustomizeMenus ( **/
VOID
InitializeBmmConfig (
- IN BMM_CALLBACK_DATA *CallbackData
+ IN BMM_CALLBACK_DATA *CallbackData
)
{
- BM_MENU_ENTRY *NewMenuEntry;
- BM_LOAD_CONTEXT *NewLoadContext;
- UINT16 Index;
+ BM_MENU_ENTRY *NewMenuEntry;
+ BM_LOAD_CONTEXT *NewLoadContext;
+ UINT16 Index;
ASSERT (CallbackData != NULL);
@@ -1477,8 +1511,8 @@ InitializeBmmConfig ( //
CallbackData->BmmFakeNvData.BootNext = NONE_BOOTNEXT_VALUE;
for (Index = 0; Index < BootOptionMenu.MenuNumber; Index++) {
- NewMenuEntry = BOpt_GetMenuEntry (&BootOptionMenu, Index);
- NewLoadContext = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext;
+ NewMenuEntry = BOpt_GetMenuEntry (&BootOptionMenu, Index);
+ NewLoadContext = (BM_LOAD_CONTEXT *)NewMenuEntry->VariableContext;
if (NewLoadContext->IsBootNext) {
CallbackData->BmmFakeNvData.BootNext = Index;
@@ -1523,7 +1557,7 @@ InitializeBmmConfig ( **/
VOID
InitAllMenu (
- IN BMM_CALLBACK_DATA *CallbackData
+ IN BMM_CALLBACK_DATA *CallbackData
)
{
InitializeListHead (&BootOptionMenu.Head);
@@ -1549,9 +1583,10 @@ FreeAllMenu ( VOID
)
{
- if (!mAllMenuInit){
+ if (!mAllMenuInit) {
return;
}
+
BOpt_FreeMenu (&BootOptionMenu);
BOpt_FreeMenu (&DriverOptionMenu);
BOpt_FreeMenu (&DriverMenu);
@@ -1568,11 +1603,11 @@ BmmInitialBootModeInfo ( VOID
)
{
- EFI_STATUS Status;
- EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
- EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *SimpleTextOut;
- UINTN BootTextColumn;
- UINTN BootTextRow;
+ EFI_STATUS Status;
+ EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
+ EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *SimpleTextOut;
+ UINTN BootTextColumn;
+ UINTN BootTextRow;
if (mBmmModeInitialized) {
return;
@@ -1585,7 +1620,7 @@ BmmInitialBootModeInfo ( Status = gBS->HandleProtocol (
gST->ConsoleOutHandle,
&gEfiGraphicsOutputProtocolGuid,
- (VOID**)&GraphicsOutput
+ (VOID **)&GraphicsOutput
);
if (EFI_ERROR (Status)) {
GraphicsOutput = NULL;
@@ -1594,7 +1629,7 @@ BmmInitialBootModeInfo ( Status = gBS->HandleProtocol (
gST->ConsoleOutHandle,
&gEfiSimpleTextOutProtocolGuid,
- (VOID**)&SimpleTextOut
+ (VOID **)&SimpleTextOut
);
if (EFI_ERROR (Status)) {
SimpleTextOut = NULL;
@@ -1627,7 +1662,7 @@ BmmInitialBootModeInfo ( mBmmSetupTextModeColumn = PcdGet32 (PcdSetupConOutColumn);
mBmmSetupTextModeRow = PcdGet32 (PcdSetupConOutRow);
- mBmmModeInitialized = TRUE;
+ mBmmModeInitialized = TRUE;
}
/**
@@ -1644,13 +1679,13 @@ BmmInitialBootModeInfo ( EFI_STATUS
EFIAPI
BootMaintenanceManagerUiLibConstructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
- UINT8 *Ptr;
+ EFI_STATUS Status;
+ UINT8 *Ptr;
Status = EFI_SUCCESS;
@@ -1671,18 +1706,18 @@ BootMaintenanceManagerUiLibConstructor ( // Post our Boot Maint VFR binary to the HII database.
//
mBmmCallbackInfo->BmmHiiHandle = HiiAddPackages (
- &mBootMaintGuid,
- mBmmCallbackInfo->BmmDriverHandle,
- BootMaintenanceManagerBin,
- BootMaintenanceManagerUiLibStrings,
- NULL
- );
+ &mBootMaintGuid,
+ mBmmCallbackInfo->BmmDriverHandle,
+ BootMaintenanceManagerBin,
+ BootMaintenanceManagerUiLibStrings,
+ NULL
+ );
ASSERT (mBmmCallbackInfo->BmmHiiHandle != NULL);
//
// Locate Formbrowser2 protocol
//
- Status = gBS->LocateProtocol (&gEfiFormBrowser2ProtocolGuid, NULL, (VOID **) &mBmmCallbackInfo->FormBrowser2);
+ Status = gBS->LocateProtocol (&gEfiFormBrowser2ProtocolGuid, NULL, (VOID **)&mBmmCallbackInfo->FormBrowser2);
ASSERT_EFI_ERROR (Status);
//
@@ -1694,29 +1729,29 @@ BootMaintenanceManagerUiLibConstructor ( //
// Initialize Bmm callback data.
//
- mBmmCallbackInfo->LoadContext = (BM_LOAD_CONTEXT *) Ptr;
- Ptr += sizeof (BM_LOAD_CONTEXT);
+ mBmmCallbackInfo->LoadContext = (BM_LOAD_CONTEXT *)Ptr;
+ Ptr += sizeof (BM_LOAD_CONTEXT);
- mBmmCallbackInfo->FileContext = (BM_FILE_CONTEXT *) Ptr;
- Ptr += sizeof (BM_FILE_CONTEXT);
+ mBmmCallbackInfo->FileContext = (BM_FILE_CONTEXT *)Ptr;
+ Ptr += sizeof (BM_FILE_CONTEXT);
- mBmmCallbackInfo->HandleContext = (BM_HANDLE_CONTEXT *) Ptr;
- Ptr += sizeof (BM_HANDLE_CONTEXT);
+ mBmmCallbackInfo->HandleContext = (BM_HANDLE_CONTEXT *)Ptr;
+ Ptr += sizeof (BM_HANDLE_CONTEXT);
- mBmmCallbackInfo->MenuEntry = (BM_MENU_ENTRY *) Ptr;
+ mBmmCallbackInfo->MenuEntry = (BM_MENU_ENTRY *)Ptr;
- mBmmCallbackInfo->BmmPreviousPageId = FORM_MAIN_ID;
- mBmmCallbackInfo->BmmCurrentPageId = FORM_MAIN_ID;
+ mBmmCallbackInfo->BmmPreviousPageId = FORM_MAIN_ID;
+ mBmmCallbackInfo->BmmCurrentPageId = FORM_MAIN_ID;
InitAllMenu (mBmmCallbackInfo);
- CreateUpdateData();
+ CreateUpdateData ();
//
// Update boot maintenance manager page
//
- InitializeBmmConfig(mBmmCallbackInfo);
+ InitializeBmmConfig (mBmmCallbackInfo);
- BmmInitialBootModeInfo();
+ BmmInitialBootModeInfo ();
return EFI_SUCCESS;
}
@@ -1733,8 +1768,8 @@ BootMaintenanceManagerUiLibConstructor ( EFI_STATUS
EFIAPI
BootMaintenanceManagerUiLibDestructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
@@ -1767,4 +1802,3 @@ BootMaintenanceManagerUiLibDestructor ( return EFI_SUCCESS;
}
-
diff --git a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManager.h b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManager.h index 67847d8bf3..2e9a70dccb 100644 --- a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManager.h +++ b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManager.h @@ -44,8 +44,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent /// HII specific Vendor Device Path definition.
///
typedef struct {
- VENDOR_DEVICE_PATH VendorDevicePath;
- EFI_DEVICE_PATH_PROTOCOL End;
+ VENDOR_DEVICE_PATH VendorDevicePath;
+ EFI_DEVICE_PATH_PROTOCOL End;
} HII_VENDOR_DEVICE_PATH;
#pragma pack()
@@ -53,19 +53,19 @@ typedef struct { // Constants which are variable names used to access variables
//
-#define VAR_CON_OUT_MODE L"ConOutMode"
+#define VAR_CON_OUT_MODE L"ConOutMode"
//
// Variable created with this flag will be "Efi:...."
//
#define VAR_FLAG EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE
-extern EFI_GUID mBootMaintGuid;
-extern CHAR16 mBootMaintStorageName[];
+extern EFI_GUID mBootMaintGuid;
+extern CHAR16 mBootMaintStorageName[];
//
// These are the VFR compiler generated data representing our VFR data.
//
-extern UINT8 BootMaintenanceManagerBin[];
+extern UINT8 BootMaintenanceManagerBin[];
//
// Below are the number of options in Baudrate, Databits,
@@ -79,7 +79,7 @@ extern UINT8 BootMaintenanceManagerBin[]; //
// Callback function helper
//
-#define BMM_CALLBACK_DATA_SIGNATURE SIGNATURE_32 ('C', 'b', 'c', 'k')
+#define BMM_CALLBACK_DATA_SIGNATURE SIGNATURE_32 ('C', 'b', 'c', 'k')
#define BMM_CALLBACK_DATA_FROM_THIS(a) CR (a, BMM_CALLBACK_DATA, BmmConfigAccess, BMM_CALLBACK_DATA_SIGNATURE)
//
@@ -88,7 +88,7 @@ extern UINT8 BootMaintenanceManagerBin[]; typedef UINT8 BBS_TYPE;
typedef enum _TYPE_OF_TERMINAL {
- TerminalTypePcAnsi = 0,
+ TerminalTypePcAnsi = 0,
TerminalTypeVt100,
TerminalTypeVt100Plus,
TerminalTypeVtUtf8,
@@ -110,20 +110,20 @@ typedef enum _TYPE_OF_TERMINAL { #define BM_TERMINAL_OPTION_SIGNATURE SIGNATURE_32 ('t', 'r', 'm', 'l')
#define BM_MENU_ENTRY_SIGNATURE SIGNATURE_32 ('e', 'n', 't', 'r')
-#define BM_LOAD_CONTEXT_SELECT 0x0
-#define BM_CONSOLE_CONTEXT_SELECT 0x1
-#define BM_FILE_CONTEXT_SELECT 0x2
-#define BM_HANDLE_CONTEXT_SELECT 0x3
-#define BM_TERMINAL_CONTEXT_SELECT 0x5
+#define BM_LOAD_CONTEXT_SELECT 0x0
+#define BM_CONSOLE_CONTEXT_SELECT 0x1
+#define BM_FILE_CONTEXT_SELECT 0x2
+#define BM_HANDLE_CONTEXT_SELECT 0x3
+#define BM_TERMINAL_CONTEXT_SELECT 0x5
-#define BM_CONSOLE_IN_CONTEXT_SELECT 0x6
-#define BM_CONSOLE_OUT_CONTEXT_SELECT 0x7
-#define BM_CONSOLE_ERR_CONTEXT_SELECT 0x8
+#define BM_CONSOLE_IN_CONTEXT_SELECT 0x6
+#define BM_CONSOLE_OUT_CONTEXT_SELECT 0x7
+#define BM_CONSOLE_ERR_CONTEXT_SELECT 0x8
//
// Buffer size for update data
//
-#define UPDATE_DATA_SIZE 0x100000
+#define UPDATE_DATA_SIZE 0x100000
//
// Namespace of callback keys used in display and file system navigation
@@ -148,12 +148,12 @@ typedef enum _TYPE_OF_TERMINAL { // all these values are computed from the structure
// defined below
//
-#define VAR_OFFSET(Field) ((UINT16) ((UINTN) &(((BMM_FAKE_NV_DATA *) 0)->Field)))
+#define VAR_OFFSET(Field) ((UINT16) ((UINTN) &(((BMM_FAKE_NV_DATA *) 0)->Field)))
//
// Question Id of Zero is invalid, so add an offset to it
//
-#define QUESTION_ID(Field) (VAR_OFFSET (Field) + CONFIG_OPTION_OFFSET)
+#define QUESTION_ID(Field) (VAR_OFFSET (Field) + CONFIG_OPTION_OFFSET)
#define BOOT_TIME_OUT_VAR_OFFSET VAR_OFFSET (BootTimeOut)
#define BOOT_NEXT_VAR_OFFSET VAR_OFFSET (BootNext)
@@ -193,47 +193,47 @@ typedef enum _TYPE_OF_TERMINAL { #define COM_TERMINAL_VAR_OFFSET VAR_OFFSET (COMTerminalType)
#define COM_FLOWCONTROL_VAR_OFFSET VAR_OFFSET (COMFlowControl)
-#define BOOT_TIME_OUT_QUESTION_ID QUESTION_ID (BootTimeOut)
-#define BOOT_NEXT_QUESTION_ID QUESTION_ID (BootNext)
-#define COM1_BAUD_RATE_QUESTION_ID QUESTION_ID (COM1BaudRate)
-#define COM1_DATA_RATE_QUESTION_ID QUESTION_ID (COM1DataRate)
-#define COM1_STOP_BITS_QUESTION_ID QUESTION_ID (COM1StopBits)
-#define COM1_PARITY_QUESTION_ID QUESTION_ID (COM1Parity)
-#define COM1_TERMINAL_QUESTION_ID QUESTION_ID (COM2TerminalType)
-#define COM2_BAUD_RATE_QUESTION_ID QUESTION_ID (COM2BaudRate)
-#define COM2_DATA_RATE_QUESTION_ID QUESTION_ID (COM2DataRate)
-#define COM2_STOP_BITS_QUESTION_ID QUESTION_ID (COM2StopBits)
-#define COM2_PARITY_QUESTION_ID QUESTION_ID (COM2Parity)
-#define COM2_TERMINAL_QUESTION_ID QUESTION_ID (COM2TerminalType)
-#define DRV_ADD_HANDLE_DESC_QUESTION_ID QUESTION_ID (DriverAddHandleDesc)
-#define DRV_ADD_ACTIVE_QUESTION_ID QUESTION_ID (DriverAddActive)
-#define DRV_ADD_RECON_QUESTION_ID QUESTION_ID (DriverAddForceReconnect)
-#define CON_IN_COM1_QUESTION_ID QUESTION_ID (ConsoleInputCOM1)
-#define CON_IN_COM2_QUESTION_ID QUESTION_ID (ConsoleInputCOM2)
-#define CON_OUT_COM1_QUESTION_ID QUESTION_ID (ConsoleOutputCOM1)
-#define CON_OUT_COM2_QUESTION_ID QUESTION_ID (ConsoleOutputCOM2)
-#define CON_ERR_COM1_QUESTION_ID QUESTION_ID (ConsoleErrorCOM1)
-#define CON_ERR_COM2_QUESTION_ID QUESTION_ID (ConsoleErrorCOM2)
-#define CON_MODE_QUESTION_ID QUESTION_ID (ConsoleOutMode)
-#define CON_DEVICE_QUESTION_ID QUESTION_ID (ConsoleCheck)
-#define CON_IN_DEVICE_QUESTION_ID QUESTION_ID (ConsoleInCheck)
-#define CON_OUT_DEVICE_QUESTION_ID QUESTION_ID (ConsoleOutCheck)
-#define CON_ERR_DEVICE_QUESTION_ID QUESTION_ID (ConsoleErrCheck)
-#define BOOT_OPTION_ORDER_QUESTION_ID QUESTION_ID (BootOptionOrder)
-#define DRIVER_OPTION_ORDER_QUESTION_ID QUESTION_ID (DriverOptionOrder)
-#define BOOT_OPTION_DEL_QUESTION_ID QUESTION_ID (BootOptionDel)
-#define DRIVER_OPTION_DEL_QUESTION_ID QUESTION_ID (DriverOptionDel)
-#define DRIVER_ADD_OPTION_QUESTION_ID QUESTION_ID (DriverAddHandleOptionalData)
-#define COM_BAUD_RATE_QUESTION_ID QUESTION_ID (COMBaudRate)
-#define COM_DATA_RATE_QUESTION_ID QUESTION_ID (COMDataRate)
-#define COM_STOP_BITS_QUESTION_ID QUESTION_ID (COMStopBits)
-#define COM_PARITY_QUESTION_ID QUESTION_ID (COMParity)
-#define COM_TERMINAL_QUESTION_ID QUESTION_ID (COMTerminalType)
-#define COM_FLOWCONTROL_QUESTION_ID QUESTION_ID (COMFlowControl)
-
-#define STRING_DEPOSITORY_NUMBER 8
-
-#define NONE_BOOTNEXT_VALUE (0xFFFF + 1)
+#define BOOT_TIME_OUT_QUESTION_ID QUESTION_ID (BootTimeOut)
+#define BOOT_NEXT_QUESTION_ID QUESTION_ID (BootNext)
+#define COM1_BAUD_RATE_QUESTION_ID QUESTION_ID (COM1BaudRate)
+#define COM1_DATA_RATE_QUESTION_ID QUESTION_ID (COM1DataRate)
+#define COM1_STOP_BITS_QUESTION_ID QUESTION_ID (COM1StopBits)
+#define COM1_PARITY_QUESTION_ID QUESTION_ID (COM1Parity)
+#define COM1_TERMINAL_QUESTION_ID QUESTION_ID (COM2TerminalType)
+#define COM2_BAUD_RATE_QUESTION_ID QUESTION_ID (COM2BaudRate)
+#define COM2_DATA_RATE_QUESTION_ID QUESTION_ID (COM2DataRate)
+#define COM2_STOP_BITS_QUESTION_ID QUESTION_ID (COM2StopBits)
+#define COM2_PARITY_QUESTION_ID QUESTION_ID (COM2Parity)
+#define COM2_TERMINAL_QUESTION_ID QUESTION_ID (COM2TerminalType)
+#define DRV_ADD_HANDLE_DESC_QUESTION_ID QUESTION_ID (DriverAddHandleDesc)
+#define DRV_ADD_ACTIVE_QUESTION_ID QUESTION_ID (DriverAddActive)
+#define DRV_ADD_RECON_QUESTION_ID QUESTION_ID (DriverAddForceReconnect)
+#define CON_IN_COM1_QUESTION_ID QUESTION_ID (ConsoleInputCOM1)
+#define CON_IN_COM2_QUESTION_ID QUESTION_ID (ConsoleInputCOM2)
+#define CON_OUT_COM1_QUESTION_ID QUESTION_ID (ConsoleOutputCOM1)
+#define CON_OUT_COM2_QUESTION_ID QUESTION_ID (ConsoleOutputCOM2)
+#define CON_ERR_COM1_QUESTION_ID QUESTION_ID (ConsoleErrorCOM1)
+#define CON_ERR_COM2_QUESTION_ID QUESTION_ID (ConsoleErrorCOM2)
+#define CON_MODE_QUESTION_ID QUESTION_ID (ConsoleOutMode)
+#define CON_DEVICE_QUESTION_ID QUESTION_ID (ConsoleCheck)
+#define CON_IN_DEVICE_QUESTION_ID QUESTION_ID (ConsoleInCheck)
+#define CON_OUT_DEVICE_QUESTION_ID QUESTION_ID (ConsoleOutCheck)
+#define CON_ERR_DEVICE_QUESTION_ID QUESTION_ID (ConsoleErrCheck)
+#define BOOT_OPTION_ORDER_QUESTION_ID QUESTION_ID (BootOptionOrder)
+#define DRIVER_OPTION_ORDER_QUESTION_ID QUESTION_ID (DriverOptionOrder)
+#define BOOT_OPTION_DEL_QUESTION_ID QUESTION_ID (BootOptionDel)
+#define DRIVER_OPTION_DEL_QUESTION_ID QUESTION_ID (DriverOptionDel)
+#define DRIVER_ADD_OPTION_QUESTION_ID QUESTION_ID (DriverAddHandleOptionalData)
+#define COM_BAUD_RATE_QUESTION_ID QUESTION_ID (COMBaudRate)
+#define COM_DATA_RATE_QUESTION_ID QUESTION_ID (COMDataRate)
+#define COM_STOP_BITS_QUESTION_ID QUESTION_ID (COMStopBits)
+#define COM_PARITY_QUESTION_ID QUESTION_ID (COMParity)
+#define COM_TERMINAL_QUESTION_ID QUESTION_ID (COMTerminalType)
+#define COM_FLOWCONTROL_QUESTION_ID QUESTION_ID (COMFlowControl)
+
+#define STRING_DEPOSITORY_NUMBER 8
+
+#define NONE_BOOTNEXT_VALUE (0xFFFF + 1)
///
/// Serial Ports attributes, first one is the value for
@@ -241,125 +241,122 @@ typedef enum _TYPE_OF_TERMINAL { /// display the value properly
///
typedef struct {
- UINTN Value;
- UINT16 StringToken;
+ UINTN Value;
+ UINT16 StringToken;
} COM_ATTR;
typedef struct {
- UINT64 BaudRate;
- UINT8 DataBits;
- UINT8 Parity;
- UINT8 StopBits;
+ UINT64 BaudRate;
+ UINT8 DataBits;
+ UINT8 Parity;
+ UINT8 StopBits;
- UINT8 BaudRateIndex;
- UINT8 DataBitsIndex;
- UINT8 ParityIndex;
- UINT8 StopBitsIndex;
+ UINT8 BaudRateIndex;
+ UINT8 DataBitsIndex;
+ UINT8 ParityIndex;
+ UINT8 StopBitsIndex;
- UINT8 FlowControl;
+ UINT8 FlowControl;
- UINT8 IsConIn;
- UINT8 IsConOut;
- UINT8 IsStdErr;
- UINT8 TerminalType;
+ UINT8 IsConIn;
+ UINT8 IsConOut;
+ UINT8 IsStdErr;
+ UINT8 TerminalType;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
} BM_TERMINAL_CONTEXT;
typedef struct {
- BOOLEAN IsBootNext;
- BOOLEAN Deleted;
+ BOOLEAN IsBootNext;
+ BOOLEAN Deleted;
- BOOLEAN IsLegacy;
+ BOOLEAN IsLegacy;
- UINT32 Attributes;
- UINT16 FilePathListLength;
- UINT16 *Description;
- EFI_DEVICE_PATH_PROTOCOL *FilePathList;
- UINT8 *OptionalData;
+ UINT32 Attributes;
+ UINT16 FilePathListLength;
+ UINT16 *Description;
+ EFI_DEVICE_PATH_PROTOCOL *FilePathList;
+ UINT8 *OptionalData;
} BM_LOAD_CONTEXT;
typedef struct {
+ BOOLEAN IsActive;
- BOOLEAN IsActive;
+ BOOLEAN IsTerminal;
- BOOLEAN IsTerminal;
-
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
} BM_CONSOLE_CONTEXT;
typedef struct {
- UINTN Column;
- UINTN Row;
+ UINTN Column;
+ UINTN Row;
} CONSOLE_OUT_MODE;
typedef struct {
- EFI_HANDLE Handle;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- EFI_FILE_HANDLE FHandle;
- UINT16 *FileName;
- EFI_FILE_SYSTEM_VOLUME_LABEL *Info;
-
- BOOLEAN IsRoot;
- BOOLEAN IsDir;
- BOOLEAN IsRemovableMedia;
- BOOLEAN IsLoadFile;
- BOOLEAN IsBootLegacy;
+ EFI_HANDLE Handle;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ EFI_FILE_HANDLE FHandle;
+ UINT16 *FileName;
+ EFI_FILE_SYSTEM_VOLUME_LABEL *Info;
+
+ BOOLEAN IsRoot;
+ BOOLEAN IsDir;
+ BOOLEAN IsRemovableMedia;
+ BOOLEAN IsLoadFile;
+ BOOLEAN IsBootLegacy;
} BM_FILE_CONTEXT;
typedef struct {
- EFI_HANDLE Handle;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ EFI_HANDLE Handle;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
} BM_HANDLE_CONTEXT;
typedef struct {
- UINTN Signature;
- LIST_ENTRY Head;
- UINTN MenuNumber;
+ UINTN Signature;
+ LIST_ENTRY Head;
+ UINTN MenuNumber;
} BM_MENU_OPTION;
typedef struct {
- UINTN Signature;
- LIST_ENTRY Link;
- UINTN OptionNumber;
- UINT16 *DisplayString;
- UINT16 *HelpString;
- EFI_STRING_ID DisplayStringToken;
- EFI_STRING_ID HelpStringToken;
- UINTN ContextSelection;
- VOID *VariableContext;
+ UINTN Signature;
+ LIST_ENTRY Link;
+ UINTN OptionNumber;
+ UINT16 *DisplayString;
+ UINT16 *HelpString;
+ EFI_STRING_ID DisplayStringToken;
+ EFI_STRING_ID HelpStringToken;
+ UINTN ContextSelection;
+ VOID *VariableContext;
} BM_MENU_ENTRY;
typedef struct {
+ UINTN Signature;
- UINTN Signature;
-
- EFI_HII_HANDLE BmmHiiHandle;
- EFI_HANDLE BmmDriverHandle;
+ EFI_HII_HANDLE BmmHiiHandle;
+ EFI_HANDLE BmmDriverHandle;
///
/// Boot Maintenance Manager Produced protocols
///
- EFI_HII_CONFIG_ACCESS_PROTOCOL BmmConfigAccess;
- EFI_FORM_BROWSER2_PROTOCOL *FormBrowser2;
+ EFI_HII_CONFIG_ACCESS_PROTOCOL BmmConfigAccess;
+ EFI_FORM_BROWSER2_PROTOCOL *FormBrowser2;
- BM_MENU_ENTRY *MenuEntry;
- BM_HANDLE_CONTEXT *HandleContext;
- BM_FILE_CONTEXT *FileContext;
- BM_LOAD_CONTEXT *LoadContext;
- BM_TERMINAL_CONTEXT *TerminalContext;
- UINTN CurrentTerminal;
- BBS_TYPE BbsType;
+ BM_MENU_ENTRY *MenuEntry;
+ BM_HANDLE_CONTEXT *HandleContext;
+ BM_FILE_CONTEXT *FileContext;
+ BM_LOAD_CONTEXT *LoadContext;
+ BM_TERMINAL_CONTEXT *TerminalContext;
+ UINTN CurrentTerminal;
+ BBS_TYPE BbsType;
//
// BMM main formset callback data.
//
- EFI_FORM_ID BmmCurrentPageId;
- EFI_FORM_ID BmmPreviousPageId;
- BOOLEAN BmmAskSaveOrNot;
- BMM_FAKE_NV_DATA BmmFakeNvData;
- BMM_FAKE_NV_DATA BmmOldFakeNVData;
-
+ EFI_FORM_ID BmmCurrentPageId;
+ EFI_FORM_ID BmmPreviousPageId;
+ BOOLEAN BmmAskSaveOrNot;
+ BMM_FAKE_NV_DATA BmmFakeNvData;
+ BMM_FAKE_NV_DATA BmmOldFakeNVData;
} BMM_CALLBACK_DATA;
/**
@@ -390,7 +387,7 @@ BOpt_FindDrivers ( **/
EFI_STATUS
BOpt_GetBootOptions (
- IN BMM_CALLBACK_DATA *CallbackData
+ IN BMM_CALLBACK_DATA *CallbackData
);
/**
@@ -406,7 +403,7 @@ BOpt_GetBootOptions ( **/
EFI_STATUS
BOpt_GetDriverOptions (
- IN BMM_CALLBACK_DATA *CallbackData
+ IN BMM_CALLBACK_DATA *CallbackData
);
/**
@@ -417,7 +414,7 @@ BOpt_GetDriverOptions ( **/
VOID
BOpt_FreeMenu (
- BM_MENU_OPTION *FreeMenu
+ BM_MENU_OPTION *FreeMenu
);
/**
@@ -431,7 +428,7 @@ BOpt_FreeMenu ( **/
UINT16
BOpt_GetOptionNumber (
- CHAR16 *Type
+ CHAR16 *Type
);
/**
@@ -470,7 +467,7 @@ BOpt_GetDriverOptionNumber ( **/
BM_MENU_ENTRY *
BOpt_CreateMenuEntry (
- UINTN MenuType
+ UINTN MenuType
);
/**
@@ -481,7 +478,7 @@ BOpt_CreateMenuEntry ( **/
VOID
BOpt_DestroyMenuEntry (
- BM_MENU_ENTRY *MenuEntry
+ BM_MENU_ENTRY *MenuEntry
);
/**
@@ -498,8 +495,8 @@ BOpt_DestroyMenuEntry ( **/
BM_MENU_ENTRY *
BOpt_GetMenuEntry (
- BM_MENU_OPTION *MenuOption,
- UINTN MenuNumber
+ BM_MENU_OPTION *MenuOption,
+ UINTN MenuNumber
);
/**
@@ -510,7 +507,7 @@ BOpt_GetMenuEntry ( **/
VOID
GetBootOrder (
- IN BMM_CALLBACK_DATA *CallbackData
+ IN BMM_CALLBACK_DATA *CallbackData
);
/**
@@ -521,12 +518,13 @@ GetBootOrder ( **/
VOID
GetDriverOrder (
- IN BMM_CALLBACK_DATA *CallbackData
+ IN BMM_CALLBACK_DATA *CallbackData
);
//
// Locate all serial io devices for console
//
+
/**
Build a list containing all serial devices.
@@ -542,6 +540,7 @@ LocateSerialIo ( //
// Initializing Console menu
//
+
/**
Build up ConsoleOutMenu, ConsoleInpMenu and ConsoleErrMenu
@@ -549,13 +548,14 @@ LocateSerialIo ( **/
EFI_STATUS
-GetAllConsoles(
+GetAllConsoles (
VOID
);
//
// Get current mode information
//
+
/**
Get mode number according to column and row
@@ -563,12 +563,13 @@ GetAllConsoles( **/
VOID
GetConsoleOutMode (
- IN BMM_CALLBACK_DATA *CallbackData
+ IN BMM_CALLBACK_DATA *CallbackData
);
//
// Cleaning up console menu
//
+
/**
Free ConsoleOutMenu, ConsoleInpMenu and ConsoleErrMenu
@@ -607,12 +608,13 @@ ChangeVariableDevicePath ( EFI_STATUS
ChangeTerminalDevicePath (
IN OUT EFI_DEVICE_PATH_PROTOCOL *DevicePath,
- IN BOOLEAN ChangeTerminal
+ IN BOOLEAN ChangeTerminal
);
//
// Variable operation by menu selection
//
+
/**
This function create a currently loaded Boot Option from
the BMM. It then appends this Boot Option to the end of
@@ -627,7 +629,7 @@ ChangeTerminalDevicePath ( **/
EFI_STATUS
Var_UpdateBootOption (
- IN BMM_CALLBACK_DATA *CallbackData
+ IN BMM_CALLBACK_DATA *CallbackData
);
/**
@@ -661,11 +663,11 @@ Var_DelBootOption ( **/
EFI_STATUS
Var_UpdateDriverOption (
- IN BMM_CALLBACK_DATA *CallbackData,
- IN EFI_HII_HANDLE HiiHandle,
- IN UINT16 *DescriptionData,
- IN UINT16 *OptionalData,
- IN UINT8 ForceReconnect
+ IN BMM_CALLBACK_DATA *CallbackData,
+ IN EFI_HII_HANDLE HiiHandle,
+ IN UINT16 *DescriptionData,
+ IN UINT16 *OptionalData,
+ IN UINT8 ForceReconnect
);
/**
@@ -725,7 +727,7 @@ Var_UpdateErrorOutOption ( **/
EFI_STATUS
Var_UpdateOutOfBandOption (
- IN UINT16 MenuIndex
+ IN UINT16 MenuIndex
);
/**
@@ -741,7 +743,7 @@ Var_UpdateOutOfBandOption ( **/
EFI_STATUS
Var_UpdateBootNext (
- IN BMM_CALLBACK_DATA *CallbackData
+ IN BMM_CALLBACK_DATA *CallbackData
);
/**
@@ -757,7 +759,7 @@ Var_UpdateBootNext ( **/
EFI_STATUS
Var_UpdateBootOrder (
- IN BMM_CALLBACK_DATA *CallbackData
+ IN BMM_CALLBACK_DATA *CallbackData
);
/**
@@ -774,7 +776,7 @@ Var_UpdateBootOrder ( **/
EFI_STATUS
Var_UpdateDriverOrder (
- IN BMM_CALLBACK_DATA *CallbackData
+ IN BMM_CALLBACK_DATA *CallbackData
);
/**
@@ -788,12 +790,13 @@ Var_UpdateDriverOrder ( **/
EFI_STATUS
Var_UpdateConMode (
- IN BMM_CALLBACK_DATA *CallbackData
+ IN BMM_CALLBACK_DATA *CallbackData
);
//
// Following are page create and refresh functions
//
+
/**
Create the global UpdateData structure.
@@ -823,8 +826,8 @@ RefreshUpdateData ( **/
VOID
CleanUpPage (
- IN UINT16 LabelId,
- IN BMM_CALLBACK_DATA *CallbackData
+ IN UINT16 LabelId,
+ IN BMM_CALLBACK_DATA *CallbackData
);
/**
@@ -836,7 +839,7 @@ CleanUpPage ( **/
VOID
UpdateBootDelPage (
- IN BMM_CALLBACK_DATA *CallbackData
+ IN BMM_CALLBACK_DATA *CallbackData
);
/**
@@ -846,7 +849,7 @@ UpdateBootDelPage ( **/
VOID
UpdateDrvAddHandlePage (
- IN BMM_CALLBACK_DATA *CallbackData
+ IN BMM_CALLBACK_DATA *CallbackData
);
/**
@@ -857,7 +860,7 @@ UpdateDrvAddHandlePage ( **/
VOID
UpdateDrvDelPage (
- IN BMM_CALLBACK_DATA *CallbackData
+ IN BMM_CALLBACK_DATA *CallbackData
);
/**
@@ -867,7 +870,7 @@ UpdateDrvDelPage ( **/
VOID
UpdateDriverAddHandleDescPage (
- IN BMM_CALLBACK_DATA *CallbackData
+ IN BMM_CALLBACK_DATA *CallbackData
);
/**
@@ -878,8 +881,8 @@ UpdateDriverAddHandleDescPage ( **/
VOID
UpdatePageBody (
- IN UINT16 UpdatePageId,
- IN BMM_CALLBACK_DATA *CallbackData
+ IN UINT16 UpdatePageId,
+ IN BMM_CALLBACK_DATA *CallbackData
);
/**
@@ -890,7 +893,7 @@ UpdatePageBody ( **/
VOID
UpdateTerminalPage (
- IN BMM_CALLBACK_DATA *CallbackData
+ IN BMM_CALLBACK_DATA *CallbackData
);
/**
@@ -900,7 +903,7 @@ UpdateTerminalPage ( **/
VOID
UpdateConModePage (
- IN BMM_CALLBACK_DATA *CallbackData
+ IN BMM_CALLBACK_DATA *CallbackData
);
/**
@@ -911,7 +914,7 @@ UpdateConModePage ( **/
VOID
UpdateConCOMPage (
- IN BMM_CALLBACK_DATA *CallbackData
+ IN BMM_CALLBACK_DATA *CallbackData
);
/**
@@ -923,10 +926,10 @@ UpdateConCOMPage ( **/
VOID
-UpdateOptionPage(
- IN BMM_CALLBACK_DATA *CallbackData,
- IN EFI_FORM_ID FormId,
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
+UpdateOptionPage (
+ IN BMM_CALLBACK_DATA *CallbackData,
+ IN EFI_FORM_ID FormId,
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
);
/**
@@ -946,8 +949,8 @@ UpdateOptionPage( **/
EFI_STATUS
EfiLibDeleteVariable (
- IN CHAR16 *VarName,
- IN EFI_GUID *VarGuid
+ IN CHAR16 *VarName,
+ IN EFI_GUID *VarGuid
);
/**
@@ -963,7 +966,7 @@ EfiLibDeleteVariable ( **/
UINTN
EfiDevicePathInstanceCount (
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
);
/**
@@ -979,7 +982,7 @@ EfiDevicePathInstanceCount ( **/
UINT16 *
EfiLibStrFromDatahub (
- IN EFI_DEVICE_PATH_PROTOCOL *DevPath
+ IN EFI_DEVICE_PATH_PROTOCOL *DevPath
);
/**
@@ -994,9 +997,9 @@ EfiLibStrFromDatahub ( **/
VOID *
GetLegacyBootOptionVar (
- IN UINTN DeviceType,
- OUT UINTN *OptionIndex,
- OUT UINTN *OptionSize
+ IN UINTN DeviceType,
+ OUT UINTN *OptionIndex,
+ OUT UINTN *OptionSize
);
/**
@@ -1009,11 +1012,10 @@ GetLegacyBootOptionVar ( **/
VOID
DiscardChangeHandler (
- IN BMM_CALLBACK_DATA *Private,
- IN BMM_FAKE_NV_DATA *CurrentFakeNVMap
+ IN BMM_CALLBACK_DATA *Private,
+ IN BMM_FAKE_NV_DATA *CurrentFakeNVMap
);
-
/**
This function is to clean some useless data before submit changes.
@@ -1022,7 +1024,7 @@ DiscardChangeHandler ( **/
VOID
CleanUselessBeforeSubmit (
- IN BMM_CALLBACK_DATA *Private
+ IN BMM_CALLBACK_DATA *Private
);
/**
@@ -1034,8 +1036,8 @@ CleanUselessBeforeSubmit ( **/
VOID
UpdatePageId (
- BMM_CALLBACK_DATA *Private,
- UINT16 NewPageId
+ BMM_CALLBACK_DATA *Private,
+ UINT16 NewPageId
);
/**
@@ -1043,7 +1045,7 @@ UpdatePageId ( **/
VOID
-FreeBMPackage(
+FreeBMPackage (
VOID
);
@@ -1052,7 +1054,7 @@ FreeBMPackage( **/
VOID
-InitBootMaintenance(
+InitBootMaintenance (
VOID
);
@@ -1066,7 +1068,7 @@ InitBootMaintenance( **/
VOID
GetConsoleInCheck (
- IN BMM_CALLBACK_DATA *CallbackData
+ IN BMM_CALLBACK_DATA *CallbackData
);
/**
@@ -1079,7 +1081,7 @@ GetConsoleInCheck ( **/
VOID
GetConsoleOutCheck (
- IN BMM_CALLBACK_DATA *CallbackData
+ IN BMM_CALLBACK_DATA *CallbackData
);
/**
@@ -1092,7 +1094,7 @@ GetConsoleOutCheck ( **/
VOID
GetConsoleErrCheck (
- IN BMM_CALLBACK_DATA *CallbackData
+ IN BMM_CALLBACK_DATA *CallbackData
);
/**
@@ -1105,7 +1107,7 @@ GetConsoleErrCheck ( **/
VOID
GetTerminalAttribute (
- IN BMM_CALLBACK_DATA *CallbackData
+ IN BMM_CALLBACK_DATA *CallbackData
);
/**
@@ -1123,7 +1125,6 @@ BmmSetConsoleMode ( BOOLEAN IsSetupMode
);
-
/**
This function converts an input device structure to a Unicode string.
@@ -1134,7 +1135,7 @@ BmmSetConsoleMode ( **/
CHAR16 *
UiDevicePathToStr (
- IN EFI_DEVICE_PATH_PROTOCOL *DevPath
+ IN EFI_DEVICE_PATH_PROTOCOL *DevPath
);
/**
@@ -1148,7 +1149,7 @@ UiDevicePathToStr ( **/
CHAR16 *
ExtractFileNameFromDevicePath (
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
);
/**
@@ -1175,10 +1176,10 @@ ExtractFileNameFromDevicePath ( EFI_STATUS
EFIAPI
BootMaintExtractConfig (
- IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
- IN CONST EFI_STRING Request,
- OUT EFI_STRING *Progress,
- OUT EFI_STRING *Results
+ IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
+ IN CONST EFI_STRING Request,
+ OUT EFI_STRING *Progress,
+ OUT EFI_STRING *Results
);
/**
@@ -1217,9 +1218,9 @@ BootMaintExtractConfig ( EFI_STATUS
EFIAPI
BootMaintRouteConfig (
- IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
- IN CONST EFI_STRING Configuration,
- OUT EFI_STRING *Progress
+ IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
+ IN CONST EFI_STRING Configuration,
+ OUT EFI_STRING *Progress
);
/**
@@ -1243,12 +1244,12 @@ BootMaintRouteConfig ( EFI_STATUS
EFIAPI
BootMaintCallback (
- IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
- IN EFI_BROWSER_ACTION Action,
- IN EFI_QUESTION_ID QuestionId,
- IN UINT8 Type,
- IN EFI_IFR_TYPE_VALUE *Value,
- OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
+ IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
+ IN EFI_BROWSER_ACTION Action,
+ IN EFI_QUESTION_ID QuestionId,
+ IN UINT8 Type,
+ IN EFI_IFR_TYPE_VALUE *Value,
+ OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
);
/**
@@ -1263,7 +1264,7 @@ BootMaintCallback ( BOOLEAN
EFIAPI
CreateBootOptionFromFile (
- IN EFI_DEVICE_PATH_PROTOCOL *FilePath
+ IN EFI_DEVICE_PATH_PROTOCOL *FilePath
);
/**
@@ -1277,7 +1278,7 @@ CreateBootOptionFromFile ( BOOLEAN
EFIAPI
CreateDriverOptionFromFile (
- IN EFI_DEVICE_PATH_PROTOCOL *FilePath
+ IN EFI_DEVICE_PATH_PROTOCOL *FilePath
);
/**
@@ -1292,37 +1293,37 @@ CreateDriverOptionFromFile ( BOOLEAN
EFIAPI
BootFromFile (
- IN EFI_DEVICE_PATH_PROTOCOL *FilePath
+ IN EFI_DEVICE_PATH_PROTOCOL *FilePath
);
//
// Global variable in this program (defined in data.c)
//
-extern BM_MENU_OPTION BootOptionMenu;
-extern BM_MENU_OPTION DriverOptionMenu;
-extern BM_MENU_OPTION ConsoleInpMenu;
-extern BM_MENU_OPTION ConsoleOutMenu;
-extern BM_MENU_OPTION ConsoleErrMenu;
-extern BM_MENU_OPTION DriverMenu;
-extern BM_MENU_OPTION TerminalMenu;
-extern UINT16 TerminalType[9];
-extern COM_ATTR BaudRateList[19];
-extern COM_ATTR DataBitsList[4];
-extern COM_ATTR ParityList[5];
-extern COM_ATTR StopBitsList[3];
-extern EFI_GUID TerminalTypeGuid[9];
-extern EFI_DEVICE_PATH_PROTOCOL EndDevicePath[];
-extern UINT16 mFlowControlType[2];
-extern UINT32 mFlowControlValue[2];
+extern BM_MENU_OPTION BootOptionMenu;
+extern BM_MENU_OPTION DriverOptionMenu;
+extern BM_MENU_OPTION ConsoleInpMenu;
+extern BM_MENU_OPTION ConsoleOutMenu;
+extern BM_MENU_OPTION ConsoleErrMenu;
+extern BM_MENU_OPTION DriverMenu;
+extern BM_MENU_OPTION TerminalMenu;
+extern UINT16 TerminalType[9];
+extern COM_ATTR BaudRateList[19];
+extern COM_ATTR DataBitsList[4];
+extern COM_ATTR ParityList[5];
+extern COM_ATTR StopBitsList[3];
+extern EFI_GUID TerminalTypeGuid[9];
+extern EFI_DEVICE_PATH_PROTOCOL EndDevicePath[];
+extern UINT16 mFlowControlType[2];
+extern UINT32 mFlowControlValue[2];
//
// Shared IFR form update data
//
-extern VOID *mStartOpCodeHandle;
-extern VOID *mEndOpCodeHandle;
-extern EFI_IFR_GUID_LABEL *mStartLabel;
-extern EFI_IFR_GUID_LABEL *mEndLabel;
-extern BMM_CALLBACK_DATA gBootMaintenancePrivate;
-extern BMM_CALLBACK_DATA *mBmmCallbackInfo;
+extern VOID *mStartOpCodeHandle;
+extern VOID *mEndOpCodeHandle;
+extern EFI_IFR_GUID_LABEL *mStartLabel;
+extern EFI_IFR_GUID_LABEL *mEndLabel;
+extern BMM_CALLBACK_DATA gBootMaintenancePrivate;
+extern BMM_CALLBACK_DATA *mBmmCallbackInfo;
#endif
diff --git a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManagerCustomizedUi.c b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManagerCustomizedUi.c index ff5e9f8f27..d79212e75c 100644 --- a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManagerCustomizedUi.c +++ b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManagerCustomizedUi.c @@ -27,19 +27,19 @@ UiCustomizeBMMPage ( //
// Create "Boot Option" menu.
//
- BmmCreateBootOptionMenu(HiiHandle, StartOpCodeHandle);
+ BmmCreateBootOptionMenu (HiiHandle, StartOpCodeHandle);
//
// Create "Driver Option" menu.
//
- BmmCreateDriverOptionMenu(HiiHandle, StartOpCodeHandle);
+ BmmCreateDriverOptionMenu (HiiHandle, StartOpCodeHandle);
//
// Create "Com Option" menu.
//
- BmmCreateComOptionMenu(HiiHandle, StartOpCodeHandle);
+ BmmCreateComOptionMenu (HiiHandle, StartOpCodeHandle);
//
// Create "Boot From File" menu.
//
- BmmCreateBootFromFileMenu(HiiHandle, StartOpCodeHandle);
+ BmmCreateBootFromFileMenu (HiiHandle, StartOpCodeHandle);
//
// Find third party drivers which need to be shown in the Bmm page.
@@ -81,12 +81,12 @@ UiCustomizeBMMPage ( **/
EFI_STATUS
UiBMMCallbackHandler (
- IN EFI_HII_HANDLE HiiHandle,
- IN EFI_BROWSER_ACTION Action,
- IN EFI_QUESTION_ID QuestionId,
- IN UINT8 Type,
- IN EFI_IFR_TYPE_VALUE *Value,
- OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
+ IN EFI_HII_HANDLE HiiHandle,
+ IN EFI_BROWSER_ACTION Action,
+ IN EFI_QUESTION_ID QuestionId,
+ IN UINT8 Type,
+ IN EFI_IFR_TYPE_VALUE *Value,
+ OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
)
{
return EFI_UNSUPPORTED;
diff --git a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManagerCustomizedUi.h b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManagerCustomizedUi.h index f1074c3b3d..21cfc5dcdc 100644 --- a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManagerCustomizedUi.h +++ b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManagerCustomizedUi.h @@ -9,7 +9,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #ifndef __CUSTOMIZED_UI_H__
#define __CUSTOMIZED_UI_H__
-
/**
Customize menus in the page.
@@ -43,12 +42,12 @@ UiCustomizeBMMPage ( **/
EFI_STATUS
UiBMMCallbackHandler (
- IN EFI_HII_HANDLE HiiHandle,
- IN EFI_BROWSER_ACTION Action,
- IN EFI_QUESTION_ID QuestionId,
- IN UINT8 Type,
- IN EFI_IFR_TYPE_VALUE *Value,
- OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
+ IN EFI_HII_HANDLE HiiHandle,
+ IN EFI_BROWSER_ACTION Action,
+ IN EFI_QUESTION_ID QuestionId,
+ IN UINT8 Type,
+ IN EFI_IFR_TYPE_VALUE *Value,
+ OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
);
#endif
diff --git a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManagerCustomizedUiSupport.c b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManagerCustomizedUiSupport.c index 656106fc24..e16936041a 100644 --- a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManagerCustomizedUiSupport.c +++ b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManagerCustomizedUiSupport.c @@ -6,22 +6,20 @@ SPDX-License-Identifier: BSD-2-Clause-Patent **/
-
#include "BootMaintenanceManager.h"
#include "BootMaintenanceManagerCustomizedUiSupport.h"
-#define UI_HII_DRIVER_LIST_SIZE 0x8
+#define UI_HII_DRIVER_LIST_SIZE 0x8
typedef struct {
- EFI_STRING_ID PromptId;
- EFI_STRING_ID HelpId;
- EFI_STRING_ID DevicePathId;
- EFI_GUID FormSetGuid;
- BOOLEAN EmptyLineAfter;
+ EFI_STRING_ID PromptId;
+ EFI_STRING_ID HelpId;
+ EFI_STRING_ID DevicePathId;
+ EFI_GUID FormSetGuid;
+ BOOLEAN EmptyLineAfter;
} UI_HII_DRIVER_INSTANCE;
-STATIC UI_HII_DRIVER_INSTANCE *gHiiDriverList;
-
+STATIC UI_HII_DRIVER_INSTANCE *gHiiDriverList;
/**
Create the dynamic item to allow user to set the "BootNext" vaule.
@@ -31,16 +29,16 @@ STATIC UI_HII_DRIVER_INSTANCE *gHiiDriverList; **/
VOID
-BmmCreateBootNextMenu(
- IN EFI_HII_HANDLE HiiHandle,
- IN VOID *StartOpCodeHandle
+BmmCreateBootNextMenu (
+ IN EFI_HII_HANDLE HiiHandle,
+ IN VOID *StartOpCodeHandle
)
{
- BM_MENU_ENTRY *NewMenuEntry;
- BM_LOAD_CONTEXT *NewLoadContext;
- UINT16 Index;
- VOID *OptionsOpCodeHandle;
- UINT32 BootNextIndex;
+ BM_MENU_ENTRY *NewMenuEntry;
+ BM_LOAD_CONTEXT *NewLoadContext;
+ UINT16 Index;
+ VOID *OptionsOpCodeHandle;
+ UINT32 BootNextIndex;
if (BootOptionMenu.MenuNumber == 0) {
return;
@@ -52,8 +50,8 @@ BmmCreateBootNextMenu( ASSERT (OptionsOpCodeHandle != NULL);
for (Index = 0; Index < BootOptionMenu.MenuNumber; Index++) {
- NewMenuEntry = BOpt_GetMenuEntry (&BootOptionMenu, Index);
- NewLoadContext = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext;
+ NewMenuEntry = BOpt_GetMenuEntry (&BootOptionMenu, Index);
+ NewLoadContext = (BM_LOAD_CONTEXT *)NewMenuEntry->VariableContext;
if (NewLoadContext->IsBootNext) {
HiiCreateOneOfOptionOpCode (
@@ -95,7 +93,7 @@ BmmCreateBootNextMenu( HiiCreateOneOfOpCode (
StartOpCodeHandle,
- (EFI_QUESTION_ID) BOOT_NEXT_QUESTION_ID,
+ (EFI_QUESTION_ID)BOOT_NEXT_QUESTION_ID,
VARSTORE_ID_BOOT_MAINT,
BOOT_NEXT_VAR_OFFSET,
STRING_TOKEN (STR_BOOT_NEXT),
@@ -107,7 +105,6 @@ BmmCreateBootNextMenu( );
HiiFreeOpCodeHandle (OptionsOpCodeHandle);
-
}
/**
@@ -119,17 +116,17 @@ BmmCreateBootNextMenu( **/
VOID
BmmCreateTimeOutMenu (
- IN EFI_HII_HANDLE HiiHandle,
- IN VOID *StartOpCodeHandle
+ IN EFI_HII_HANDLE HiiHandle,
+ IN VOID *StartOpCodeHandle
)
{
HiiCreateNumericOpCode (
StartOpCodeHandle,
- (EFI_QUESTION_ID) FORM_TIME_OUT_ID,
+ (EFI_QUESTION_ID)FORM_TIME_OUT_ID,
VARSTORE_ID_BOOT_MAINT,
BOOT_TIME_OUT_VAR_OFFSET,
- STRING_TOKEN(STR_NUM_AUTO_BOOT),
- STRING_TOKEN(STR_HLP_AUTO_BOOT),
+ STRING_TOKEN (STR_NUM_AUTO_BOOT),
+ STRING_TOKEN (STR_HLP_AUTO_BOOT),
EFI_IFR_FLAG_CALLBACK,
EFI_IFR_NUMERIC_SIZE_2 | EFI_IFR_DISPLAY_UINT_DEC,
0,
@@ -148,8 +145,8 @@ BmmCreateTimeOutMenu ( **/
VOID
BmmCreateBootOptionMenu (
- IN EFI_HII_HANDLE HiiHandle,
- IN VOID *StartOpCodeHandle
+ IN EFI_HII_HANDLE HiiHandle,
+ IN VOID *StartOpCodeHandle
)
{
HiiCreateGotoOpCode (
@@ -171,8 +168,8 @@ BmmCreateBootOptionMenu ( **/
VOID
BmmCreateDriverOptionMenu (
- IN EFI_HII_HANDLE HiiHandle,
- IN VOID *StartOpCodeHandle
+ IN EFI_HII_HANDLE HiiHandle,
+ IN VOID *StartOpCodeHandle
)
{
HiiCreateGotoOpCode (
@@ -194,8 +191,8 @@ BmmCreateDriverOptionMenu ( **/
VOID
BmmCreateComOptionMenu (
- IN EFI_HII_HANDLE HiiHandle,
- IN VOID *StartOpCodeHandle
+ IN EFI_HII_HANDLE HiiHandle,
+ IN VOID *StartOpCodeHandle
)
{
HiiCreateGotoOpCode (
@@ -217,8 +214,8 @@ BmmCreateComOptionMenu ( **/
VOID
BmmCreateBootFromFileMenu (
- IN EFI_HII_HANDLE HiiHandle,
- IN VOID *StartOpCodeHandle
+ IN EFI_HII_HANDLE HiiHandle,
+ IN VOID *StartOpCodeHandle
)
{
HiiCreateGotoOpCode (
@@ -240,8 +237,8 @@ BmmCreateBootFromFileMenu ( **/
VOID
BmmCreateEmptyLine (
- IN EFI_HII_HANDLE HiiHandle,
- IN VOID *StartOpCodeHandle
+ IN EFI_HII_HANDLE HiiHandle,
+ IN VOID *StartOpCodeHandle
)
{
HiiCreateSubTitleOpCode (StartOpCodeHandle, STRING_TOKEN (STR_NULL_STRING), 0, 0, 0);
@@ -258,11 +255,11 @@ BmmCreateEmptyLine ( **/
CHAR16 *
ExtractDevicePathFromHandle (
- IN EFI_HII_HANDLE Handle
+ IN EFI_HII_HANDLE Handle
)
{
- EFI_STATUS Status;
- EFI_HANDLE DriverHandle;
+ EFI_STATUS Status;
+ EFI_HANDLE DriverHandle;
ASSERT (Handle != NULL);
@@ -275,7 +272,7 @@ ExtractDevicePathFromHandle ( return NULL;
}
- return ConvertDevicePathToText(DevicePathFromHandle (DriverHandle), FALSE, FALSE);
+ return ConvertDevicePathToText (DevicePathFromHandle (DriverHandle), FALSE, FALSE);
}
/**
@@ -292,49 +289,49 @@ ExtractDevicePathFromHandle ( **/
BOOLEAN
IsRequiredDriver (
- IN EFI_HII_HANDLE HiiHandle,
- IN EFI_GUID *Guid,
- OUT EFI_STRING_ID *PromptId,
- OUT EFI_STRING_ID *HelpId,
- OUT VOID *FormsetGuid
+ IN EFI_HII_HANDLE HiiHandle,
+ IN EFI_GUID *Guid,
+ OUT EFI_STRING_ID *PromptId,
+ OUT EFI_STRING_ID *HelpId,
+ OUT VOID *FormsetGuid
)
{
- EFI_STATUS Status;
- UINT8 ClassGuidNum;
- EFI_GUID *ClassGuid;
- EFI_IFR_FORM_SET *Buffer;
- UINTN BufferSize;
- UINT8 *Ptr;
- UINTN TempSize;
- BOOLEAN RetVal;
-
- Status = HiiGetFormSetFromHiiHandle(HiiHandle, &Buffer,&BufferSize);
+ EFI_STATUS Status;
+ UINT8 ClassGuidNum;
+ EFI_GUID *ClassGuid;
+ EFI_IFR_FORM_SET *Buffer;
+ UINTN BufferSize;
+ UINT8 *Ptr;
+ UINTN TempSize;
+ BOOLEAN RetVal;
+
+ Status = HiiGetFormSetFromHiiHandle (HiiHandle, &Buffer, &BufferSize);
if (EFI_ERROR (Status)) {
return FALSE;
}
- RetVal = FALSE;
+ RetVal = FALSE;
TempSize = 0;
- Ptr = (UINT8 *) Buffer;
- while(TempSize < BufferSize) {
- TempSize += ((EFI_IFR_OP_HEADER *) Ptr)->Length;
+ Ptr = (UINT8 *)Buffer;
+ while (TempSize < BufferSize) {
+ TempSize += ((EFI_IFR_OP_HEADER *)Ptr)->Length;
- if (((EFI_IFR_OP_HEADER *) Ptr)->Length <= OFFSET_OF (EFI_IFR_FORM_SET, Flags)){
- Ptr += ((EFI_IFR_OP_HEADER *) Ptr)->Length;
+ if (((EFI_IFR_OP_HEADER *)Ptr)->Length <= OFFSET_OF (EFI_IFR_FORM_SET, Flags)) {
+ Ptr += ((EFI_IFR_OP_HEADER *)Ptr)->Length;
continue;
}
- ClassGuidNum = (UINT8) (((EFI_IFR_FORM_SET *)Ptr)->Flags & 0x3);
- ClassGuid = (EFI_GUID *) (VOID *)(Ptr + sizeof (EFI_IFR_FORM_SET));
+ ClassGuidNum = (UINT8)(((EFI_IFR_FORM_SET *)Ptr)->Flags & 0x3);
+ ClassGuid = (EFI_GUID *)(VOID *)(Ptr + sizeof (EFI_IFR_FORM_SET));
while (ClassGuidNum-- > 0) {
- if (!CompareGuid (Guid, ClassGuid)){
- ClassGuid ++;
+ if (!CompareGuid (Guid, ClassGuid)) {
+ ClassGuid++;
continue;
}
*PromptId = ((EFI_IFR_FORM_SET *)Ptr)->FormSetTitle;
- *HelpId = ((EFI_IFR_FORM_SET *)Ptr)->Help;
- CopyMem (FormsetGuid, &((EFI_IFR_FORM_SET *) Ptr)->Guid, sizeof (EFI_GUID));
+ *HelpId = ((EFI_IFR_FORM_SET *)Ptr)->Help;
+ CopyMem (FormsetGuid, &((EFI_IFR_FORM_SET *)Ptr)->Guid, sizeof (EFI_GUID));
RetVal = TRUE;
}
}
@@ -358,23 +355,23 @@ IsRequiredDriver ( **/
EFI_STATUS
BmmListThirdPartyDrivers (
- IN EFI_HII_HANDLE HiiHandle,
- IN EFI_GUID *ClassGuid,
- IN DRIVER_SPECIAL_HANDLER SpecialHandlerFn,
- IN VOID *StartOpCodeHandle
+ IN EFI_HII_HANDLE HiiHandle,
+ IN EFI_GUID *ClassGuid,
+ IN DRIVER_SPECIAL_HANDLER SpecialHandlerFn,
+ IN VOID *StartOpCodeHandle
)
{
- UINTN Index;
- EFI_STRING String;
- EFI_STRING_ID Token;
- EFI_STRING_ID TokenHelp;
- EFI_HII_HANDLE *HiiHandles;
- CHAR16 *DevicePathStr;
- UINTN Count;
- UINTN CurrentSize;
- UI_HII_DRIVER_INSTANCE *DriverListPtr;
- EFI_STRING NewName;
- BOOLEAN EmptyLineAfter;
+ UINTN Index;
+ EFI_STRING String;
+ EFI_STRING_ID Token;
+ EFI_STRING_ID TokenHelp;
+ EFI_HII_HANDLE *HiiHandles;
+ CHAR16 *DevicePathStr;
+ UINTN Count;
+ UINTN CurrentSize;
+ UI_HII_DRIVER_INSTANCE *DriverListPtr;
+ EFI_STRING NewName;
+ BOOLEAN EmptyLineAfter;
if (gHiiDriverList != NULL) {
FreePool (gHiiDriverList);
@@ -386,7 +383,7 @@ BmmListThirdPartyDrivers ( gHiiDriverList = AllocateZeroPool (UI_HII_DRIVER_LIST_SIZE * sizeof (UI_HII_DRIVER_INSTANCE));
ASSERT (gHiiDriverList != NULL);
DriverListPtr = gHiiDriverList;
- CurrentSize = UI_HII_DRIVER_LIST_SIZE;
+ CurrentSize = UI_HII_DRIVER_LIST_SIZE;
for (Index = 0, Count = 0; HiiHandles[Index] != NULL; Index++) {
if (!IsRequiredDriver (HiiHandles[Index], ClassGuid, &Token, &TokenHelp, &gHiiDriverList[Count].FormSetGuid)) {
@@ -404,10 +401,11 @@ BmmListThirdPartyDrivers ( EmptyLineAfter = FALSE;
if (SpecialHandlerFn (String, &NewName, &EmptyLineAfter)) {
FreePool (String);
- String = NewName;
+ String = NewName;
DriverListPtr[Count].EmptyLineAfter = EmptyLineAfter;
}
}
+
DriverListPtr[Count].PromptId = HiiSetString (HiiHandle, 0, String, NULL);
FreePool (String);
@@ -416,11 +414,12 @@ BmmListThirdPartyDrivers ( String = HiiGetString (HiiHandle, STRING_TOKEN (STR_MISSING_STRING), NULL);
ASSERT (String != NULL);
}
+
DriverListPtr[Count].HelpId = HiiSetString (HiiHandle, 0, String, NULL);
FreePool (String);
- DevicePathStr = ExtractDevicePathFromHandle(HiiHandles[Index]);
- if (DevicePathStr != NULL){
+ DevicePathStr = ExtractDevicePathFromHandle (HiiHandles[Index]);
+ if (DevicePathStr != NULL) {
DriverListPtr[Count].DevicePathId = HiiSetString (HiiHandle, 0, DevicePathStr, NULL);
FreePool (DevicePathStr);
} else {
@@ -437,7 +436,7 @@ BmmListThirdPartyDrivers ( );
ASSERT (DriverListPtr != NULL);
gHiiDriverList = DriverListPtr;
- CurrentSize += UI_HII_DRIVER_LIST_SIZE;
+ CurrentSize += UI_HII_DRIVER_LIST_SIZE;
}
}
@@ -455,15 +454,14 @@ BmmListThirdPartyDrivers ( 0,
&gHiiDriverList[Index].FormSetGuid,
gHiiDriverList[Index].DevicePathId
- );
+ );
if (gHiiDriverList[Index].EmptyLineAfter) {
BmmCreateEmptyLine (HiiHandle, StartOpCodeHandle);
}
- Index ++;
+ Index++;
}
return EFI_SUCCESS;
}
-
diff --git a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManagerCustomizedUiSupport.h b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManagerCustomizedUiSupport.h index 0dff6e5569..dece1ec175 100644 --- a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManagerCustomizedUiSupport.h +++ b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManagerCustomizedUiSupport.h @@ -18,8 +18,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent **/
VOID
BmmCreateTimeOutMenu (
- IN EFI_HII_HANDLE HiiHandle,
- IN VOID *StartOpCodeHandle
+ IN EFI_HII_HANDLE HiiHandle,
+ IN VOID *StartOpCodeHandle
);
/**
@@ -30,9 +30,9 @@ BmmCreateTimeOutMenu ( **/
VOID
-BmmCreateBootNextMenu(
- IN EFI_HII_HANDLE HiiHandle,
- IN VOID *StartOpCodeHandle
+BmmCreateBootNextMenu (
+ IN EFI_HII_HANDLE HiiHandle,
+ IN VOID *StartOpCodeHandle
);
/**
@@ -44,8 +44,8 @@ BmmCreateBootNextMenu( **/
VOID
BmmCreateBootOptionMenu (
- IN EFI_HII_HANDLE HiiHandle,
- IN VOID *StartOpCodeHandle
+ IN EFI_HII_HANDLE HiiHandle,
+ IN VOID *StartOpCodeHandle
);
/**
@@ -57,8 +57,8 @@ BmmCreateBootOptionMenu ( **/
VOID
BmmCreateDriverOptionMenu (
- IN EFI_HII_HANDLE HiiHandle,
- IN VOID *StartOpCodeHandle
+ IN EFI_HII_HANDLE HiiHandle,
+ IN VOID *StartOpCodeHandle
);
/**
@@ -70,8 +70,8 @@ BmmCreateDriverOptionMenu ( **/
VOID
BmmCreateComOptionMenu (
- IN EFI_HII_HANDLE HiiHandle,
- IN VOID *StartOpCodeHandle
+ IN EFI_HII_HANDLE HiiHandle,
+ IN VOID *StartOpCodeHandle
);
/**
@@ -83,8 +83,8 @@ BmmCreateComOptionMenu ( **/
VOID
BmmCreateBootFromFileMenu (
- IN EFI_HII_HANDLE HiiHandle,
- IN VOID *StartOpCodeHandle
+ IN EFI_HII_HANDLE HiiHandle,
+ IN VOID *StartOpCodeHandle
);
/**
@@ -96,8 +96,8 @@ BmmCreateBootFromFileMenu ( **/
VOID
BmmCreateEmptyLine (
- IN EFI_HII_HANDLE HiiHandle,
- IN VOID *StartOpCodeHandle
+ IN EFI_HII_HANDLE HiiHandle,
+ IN VOID *StartOpCodeHandle
);
/**
@@ -116,7 +116,7 @@ EFI_STATUS IN CHAR16 *DriverName,
OUT CHAR16 **NewName,
OUT BOOLEAN *EmptyLineAfter
-);
+ );
/**
Search the drivers in the system which need to show in the front page
@@ -132,10 +132,10 @@ EFI_STATUS **/
EFI_STATUS
BmmListThirdPartyDrivers (
- IN EFI_HII_HANDLE HiiHandle,
- IN EFI_GUID *ClassGuid,
- IN DRIVER_SPECIAL_HANDLER SpecialHandlerFn,
- IN VOID *StartOpCodeHandle
+ IN EFI_HII_HANDLE HiiHandle,
+ IN EFI_GUID *ClassGuid,
+ IN DRIVER_SPECIAL_HANDLER SpecialHandlerFn,
+ IN VOID *StartOpCodeHandle
);
#endif
diff --git a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootOption.c b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootOption.c index 45d0fbb8a1..cdaa2db153 100644 --- a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootOption.c +++ b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootOption.c @@ -15,7 +15,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent ///
/// Define the maximum characters that will be accepted.
///
-#define MAX_CHAR 480
+#define MAX_CHAR 480
/**
@@ -27,21 +27,21 @@ BmmSetupResetReminder ( VOID
)
{
- EFI_INPUT_KEY Key;
- CHAR16 *StringBuffer1;
- CHAR16 *StringBuffer2;
- EFI_STATUS Status;
- EDKII_FORM_BROWSER_EXTENSION2_PROTOCOL *FormBrowserEx2;
+ EFI_INPUT_KEY Key;
+ CHAR16 *StringBuffer1;
+ CHAR16 *StringBuffer2;
+ EFI_STATUS Status;
+ EDKII_FORM_BROWSER_EXTENSION2_PROTOCOL *FormBrowserEx2;
//
// Use BrowserEx2 protocol to check whether reset is required.
//
- Status = gBS->LocateProtocol (&gEdkiiFormBrowserEx2ProtocolGuid, NULL, (VOID **) &FormBrowserEx2);
+ Status = gBS->LocateProtocol (&gEdkiiFormBrowserEx2ProtocolGuid, NULL, (VOID **)&FormBrowserEx2);
//
- //check any reset required change is applied? if yes, reset system
+ // check any reset required change is applied? if yes, reset system
//
- if (!EFI_ERROR(Status) && FormBrowserEx2->IsResetRequired()) {
+ if (!EFI_ERROR (Status) && FormBrowserEx2->IsResetRequired ()) {
StringBuffer1 = AllocateZeroPool (MAX_CHAR * sizeof (CHAR16));
ASSERT (StringBuffer1 != NULL);
StringBuffer2 = AllocateZeroPool (MAX_CHAR * sizeof (CHAR16));
@@ -73,39 +73,39 @@ BmmSetupResetReminder ( **/
BM_MENU_ENTRY *
BOpt_CreateMenuEntry (
- UINTN MenuType
+ UINTN MenuType
)
{
- BM_MENU_ENTRY *MenuEntry;
- UINTN ContextSize;
+ BM_MENU_ENTRY *MenuEntry;
+ UINTN ContextSize;
//
// Get context size according to menu type
//
switch (MenuType) {
- case BM_LOAD_CONTEXT_SELECT:
- ContextSize = sizeof (BM_LOAD_CONTEXT);
- break;
+ case BM_LOAD_CONTEXT_SELECT:
+ ContextSize = sizeof (BM_LOAD_CONTEXT);
+ break;
- case BM_FILE_CONTEXT_SELECT:
- ContextSize = sizeof (BM_FILE_CONTEXT);
- break;
+ case BM_FILE_CONTEXT_SELECT:
+ ContextSize = sizeof (BM_FILE_CONTEXT);
+ break;
- case BM_CONSOLE_CONTEXT_SELECT:
- ContextSize = sizeof (BM_CONSOLE_CONTEXT);
- break;
+ case BM_CONSOLE_CONTEXT_SELECT:
+ ContextSize = sizeof (BM_CONSOLE_CONTEXT);
+ break;
- case BM_TERMINAL_CONTEXT_SELECT:
- ContextSize = sizeof (BM_TERMINAL_CONTEXT);
- break;
+ case BM_TERMINAL_CONTEXT_SELECT:
+ ContextSize = sizeof (BM_TERMINAL_CONTEXT);
+ break;
- case BM_HANDLE_CONTEXT_SELECT:
- ContextSize = sizeof (BM_HANDLE_CONTEXT);
- break;
+ case BM_HANDLE_CONTEXT_SELECT:
+ ContextSize = sizeof (BM_HANDLE_CONTEXT);
+ break;
- default:
- ContextSize = 0;
- break;
+ default:
+ ContextSize = 0;
+ break;
}
if (ContextSize == 0) {
@@ -139,67 +139,70 @@ BOpt_CreateMenuEntry ( **/
VOID
BOpt_DestroyMenuEntry (
- BM_MENU_ENTRY *MenuEntry
+ BM_MENU_ENTRY *MenuEntry
)
{
- BM_LOAD_CONTEXT *LoadContext;
- BM_FILE_CONTEXT *FileContext;
- BM_CONSOLE_CONTEXT *ConsoleContext;
- BM_TERMINAL_CONTEXT *TerminalContext;
- BM_HANDLE_CONTEXT *HandleContext;
+ BM_LOAD_CONTEXT *LoadContext;
+ BM_FILE_CONTEXT *FileContext;
+ BM_CONSOLE_CONTEXT *ConsoleContext;
+ BM_TERMINAL_CONTEXT *TerminalContext;
+ BM_HANDLE_CONTEXT *HandleContext;
//
// Select by the type in Menu entry for current context type
//
switch (MenuEntry->ContextSelection) {
- case BM_LOAD_CONTEXT_SELECT:
- LoadContext = (BM_LOAD_CONTEXT *) MenuEntry->VariableContext;
- FreePool (LoadContext->FilePathList);
- if (LoadContext->OptionalData != NULL) {
- FreePool (LoadContext->OptionalData);
- }
- FreePool (LoadContext);
- break;
+ case BM_LOAD_CONTEXT_SELECT:
+ LoadContext = (BM_LOAD_CONTEXT *)MenuEntry->VariableContext;
+ FreePool (LoadContext->FilePathList);
+ if (LoadContext->OptionalData != NULL) {
+ FreePool (LoadContext->OptionalData);
+ }
- case BM_FILE_CONTEXT_SELECT:
- FileContext = (BM_FILE_CONTEXT *) MenuEntry->VariableContext;
+ FreePool (LoadContext);
+ break;
- if (!FileContext->IsRoot) {
- FreePool (FileContext->DevicePath);
- } else {
- if (FileContext->FHandle != NULL) {
- FileContext->FHandle->Close (FileContext->FHandle);
+ case BM_FILE_CONTEXT_SELECT:
+ FileContext = (BM_FILE_CONTEXT *)MenuEntry->VariableContext;
+
+ if (!FileContext->IsRoot) {
+ FreePool (FileContext->DevicePath);
+ } else {
+ if (FileContext->FHandle != NULL) {
+ FileContext->FHandle->Close (FileContext->FHandle);
+ }
}
- }
- if (FileContext->FileName != NULL) {
- FreePool (FileContext->FileName);
- }
- if (FileContext->Info != NULL) {
- FreePool (FileContext->Info);
- }
- FreePool (FileContext);
- break;
-
- case BM_CONSOLE_CONTEXT_SELECT:
- ConsoleContext = (BM_CONSOLE_CONTEXT *) MenuEntry->VariableContext;
- FreePool (ConsoleContext->DevicePath);
- FreePool (ConsoleContext);
- break;
-
- case BM_TERMINAL_CONTEXT_SELECT:
- TerminalContext = (BM_TERMINAL_CONTEXT *) MenuEntry->VariableContext;
- FreePool (TerminalContext->DevicePath);
- FreePool (TerminalContext);
- break;
-
- case BM_HANDLE_CONTEXT_SELECT:
- HandleContext = (BM_HANDLE_CONTEXT *) MenuEntry->VariableContext;
- FreePool (HandleContext);
- break;
-
- default:
- break;
+ if (FileContext->FileName != NULL) {
+ FreePool (FileContext->FileName);
+ }
+
+ if (FileContext->Info != NULL) {
+ FreePool (FileContext->Info);
+ }
+
+ FreePool (FileContext);
+ break;
+
+ case BM_CONSOLE_CONTEXT_SELECT:
+ ConsoleContext = (BM_CONSOLE_CONTEXT *)MenuEntry->VariableContext;
+ FreePool (ConsoleContext->DevicePath);
+ FreePool (ConsoleContext);
+ break;
+
+ case BM_TERMINAL_CONTEXT_SELECT:
+ TerminalContext = (BM_TERMINAL_CONTEXT *)MenuEntry->VariableContext;
+ FreePool (TerminalContext->DevicePath);
+ FreePool (TerminalContext);
+ break;
+
+ case BM_HANDLE_CONTEXT_SELECT:
+ HandleContext = (BM_HANDLE_CONTEXT *)MenuEntry->VariableContext;
+ FreePool (HandleContext);
+ break;
+
+ default:
+ break;
}
FreePool (MenuEntry->DisplayString);
@@ -224,13 +227,13 @@ BOpt_DestroyMenuEntry ( **/
BM_MENU_ENTRY *
BOpt_GetMenuEntry (
- BM_MENU_OPTION *MenuOption,
- UINTN MenuNumber
+ BM_MENU_OPTION *MenuOption,
+ UINTN MenuNumber
)
{
- BM_MENU_ENTRY *NewMenuEntry;
- UINTN Index;
- LIST_ENTRY *List;
+ BM_MENU_ENTRY *NewMenuEntry;
+ UINTN Index;
+ LIST_ENTRY *List;
ASSERT (MenuNumber < MenuOption->MenuNumber);
@@ -251,10 +254,11 @@ BOpt_GetMenuEntry ( **/
VOID
BOpt_FreeMenu (
- BM_MENU_OPTION *FreeMenu
+ BM_MENU_OPTION *FreeMenu
)
{
- BM_MENU_ENTRY *MenuEntry;
+ BM_MENU_ENTRY *MenuEntry;
+
while (!IsListEmpty (&FreeMenu->Head)) {
MenuEntry = CR (
FreeMenu->Head.ForwardLink,
@@ -265,6 +269,7 @@ BOpt_FreeMenu ( RemoveEntryList (&MenuEntry->Link);
BOpt_DestroyMenuEntry (MenuEntry);
}
+
FreeMenu->MenuNumber = 0;
}
@@ -281,7 +286,7 @@ BOpt_FreeMenu ( **/
EFI_STATUS
BOpt_GetBootOptions (
- IN BMM_CALLBACK_DATA *CallbackData
+ IN BMM_CALLBACK_DATA *CallbackData
)
{
UINTN Index;
@@ -317,7 +322,7 @@ BOpt_GetBootOptions ( //
// Get the BootOrder from the Var
//
- GetEfiGlobalVariable2 (L"BootOrder", (VOID **) &BootOrderList, &BootOrderListSize);
+ GetEfiGlobalVariable2 (L"BootOrder", (VOID **)&BootOrderList, &BootOrderListSize);
if (BootOrderList == NULL) {
return EFI_NOT_FOUND;
}
@@ -325,13 +330,14 @@ BOpt_GetBootOptions ( //
// Get the BootNext from the Var
//
- GetEfiGlobalVariable2 (L"BootNext", (VOID **) &BootNext, &BootNextSize);
+ GetEfiGlobalVariable2 (L"BootNext", (VOID **)&BootNext, &BootNextSize);
if (BootNext != NULL) {
if (BootNextSize != sizeof (UINT16)) {
FreePool (BootNext);
BootNext = NULL;
}
}
+
BootOption = EfiBootManagerGetLoadOptions (&BootOptionCount, LoadOptionTypeBoot);
for (Index = 0; Index < BootOrderListSize / sizeof (UINT16); Index++) {
//
@@ -345,13 +351,13 @@ BOpt_GetBootOptions ( //
// Get all loadoptions from the VAR
//
- GetEfiGlobalVariable2 (BootString, (VOID **) &LoadOptionFromVar, &BootOptionSize);
+ GetEfiGlobalVariable2 (BootString, (VOID **)&LoadOptionFromVar, &BootOptionSize);
if (LoadOptionFromVar == NULL) {
continue;
}
if (BootNext != NULL) {
- BootNextFlag = (BOOLEAN) (*BootNext == BootOrderList[Index]);
+ BootNextFlag = (BOOLEAN)(*BootNext == BootOrderList[Index]);
} else {
BootNextFlag = FALSE;
}
@@ -359,19 +365,19 @@ BOpt_GetBootOptions ( NewMenuEntry = BOpt_CreateMenuEntry (BM_LOAD_CONTEXT_SELECT);
ASSERT (NULL != NewMenuEntry);
- NewLoadContext = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext;
+ NewLoadContext = (BM_LOAD_CONTEXT *)NewMenuEntry->VariableContext;
- LoadOptionPtr = LoadOptionFromVar;
- LoadOptionEnd = LoadOptionFromVar + BootOptionSize;
+ LoadOptionPtr = LoadOptionFromVar;
+ LoadOptionEnd = LoadOptionFromVar + BootOptionSize;
- NewMenuEntry->OptionNumber = BootOrderList[Index];
- NewLoadContext->Deleted = FALSE;
- NewLoadContext->IsBootNext = BootNextFlag;
+ NewMenuEntry->OptionNumber = BootOrderList[Index];
+ NewLoadContext->Deleted = FALSE;
+ NewLoadContext->IsBootNext = BootNextFlag;
//
// Is a Legacy Device?
//
- Ptr = (UINT8 *) LoadOptionFromVar;
+ Ptr = (UINT8 *)LoadOptionFromVar;
//
// Attribute = *(UINT32 *)Ptr;
@@ -386,38 +392,39 @@ BOpt_GetBootOptions ( //
// Description = (CHAR16 *)Ptr;
//
- Ptr += StrSize ((CHAR16 *) Ptr);
+ Ptr += StrSize ((CHAR16 *)Ptr);
//
// Now Ptr point to Device Path
//
- DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) Ptr;
+ DevicePath = (EFI_DEVICE_PATH_PROTOCOL *)Ptr;
if ((BBS_DEVICE_PATH == DevicePath->Type) && (BBS_BBS_DP == DevicePath->SubType)) {
NewLoadContext->IsLegacy = TRUE;
} else {
NewLoadContext->IsLegacy = FALSE;
}
+
//
// LoadOption is a pointer type of UINT8
// for easy use with following LOAD_OPTION
// embedded in this struct
//
- NewLoadContext->Attributes = *(UINT32 *) LoadOptionPtr;
+ NewLoadContext->Attributes = *(UINT32 *)LoadOptionPtr;
LoadOptionPtr += sizeof (UINT32);
- NewLoadContext->FilePathListLength = *(UINT16 *) LoadOptionPtr;
- LoadOptionPtr += sizeof (UINT16);
+ NewLoadContext->FilePathListLength = *(UINT16 *)LoadOptionPtr;
+ LoadOptionPtr += sizeof (UINT16);
- StringSize = StrSize((UINT16*)LoadOptionPtr);
+ StringSize = StrSize ((UINT16 *)LoadOptionPtr);
- NewLoadContext->Description = AllocateZeroPool (StrSize((UINT16*)LoadOptionPtr));
+ NewLoadContext->Description = AllocateZeroPool (StrSize ((UINT16 *)LoadOptionPtr));
ASSERT (NewLoadContext->Description != NULL);
- StrCpyS (NewLoadContext->Description, StrSize((UINT16*)LoadOptionPtr) / sizeof (UINT16), (UINT16*)LoadOptionPtr);
+ StrCpyS (NewLoadContext->Description, StrSize ((UINT16 *)LoadOptionPtr) / sizeof (UINT16), (UINT16 *)LoadOptionPtr);
ASSERT (NewLoadContext->Description != NULL);
- NewMenuEntry->DisplayString = NewLoadContext->Description;
+ NewMenuEntry->DisplayString = NewLoadContext->Description;
NewMenuEntry->DisplayStringToken = HiiSetString (CallbackData->BmmHiiHandle, 0, NewMenuEntry->DisplayString, NULL);
LoadOptionPtr += StringSize;
@@ -426,21 +433,21 @@ BOpt_GetBootOptions ( ASSERT (NewLoadContext->FilePathList != NULL);
CopyMem (
NewLoadContext->FilePathList,
- (EFI_DEVICE_PATH_PROTOCOL *) LoadOptionPtr,
+ (EFI_DEVICE_PATH_PROTOCOL *)LoadOptionPtr,
NewLoadContext->FilePathListLength
);
- NewMenuEntry->HelpString = UiDevicePathToStr (NewLoadContext->FilePathList);
+ NewMenuEntry->HelpString = UiDevicePathToStr (NewLoadContext->FilePathList);
NewMenuEntry->HelpStringToken = HiiSetString (CallbackData->BmmHiiHandle, 0, NewMenuEntry->HelpString, NULL);
LoadOptionPtr += NewLoadContext->FilePathListLength;
if (LoadOptionPtr < LoadOptionEnd) {
OptionalDataSize = BootOptionSize -
- sizeof (UINT32) -
- sizeof (UINT16) -
- StringSize -
- NewLoadContext->FilePathListLength;
+ sizeof (UINT32) -
+ sizeof (UINT16) -
+ StringSize -
+ NewLoadContext->FilePathListLength;
NewLoadContext->OptionalData = AllocateZeroPool (OptionalDataSize);
ASSERT (NewLoadContext->OptionalData != NULL);
@@ -455,11 +462,13 @@ BOpt_GetBootOptions ( MenuCount++;
FreePool (LoadOptionFromVar);
}
+
EfiBootManagerFreeLoadOptions (BootOption, BootOptionCount);
if (BootNext != NULL) {
FreePool (BootNext);
}
+
if (BootOrderList != NULL) {
FreePool (BootOrderList);
}
@@ -484,19 +493,19 @@ BOpt_FindDrivers ( VOID
)
{
- UINTN NoDevicePathHandles;
- EFI_HANDLE *DevicePathHandle;
- UINTN Index;
- EFI_STATUS Status;
- BM_MENU_ENTRY *NewMenuEntry;
- BM_HANDLE_CONTEXT *NewHandleContext;
- EFI_HANDLE CurHandle;
- UINTN OptionNumber;
- EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *SimpleFs;
- EFI_LOAD_FILE_PROTOCOL *LoadFile;
-
- SimpleFs = NULL;
- LoadFile = NULL;
+ UINTN NoDevicePathHandles;
+ EFI_HANDLE *DevicePathHandle;
+ UINTN Index;
+ EFI_STATUS Status;
+ BM_MENU_ENTRY *NewMenuEntry;
+ BM_HANDLE_CONTEXT *NewHandleContext;
+ EFI_HANDLE CurHandle;
+ UINTN OptionNumber;
+ EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *SimpleFs;
+ EFI_LOAD_FILE_PROTOCOL *LoadFile;
+
+ SimpleFs = NULL;
+ LoadFile = NULL;
InitializeListHead (&DriverMenu.Head);
@@ -523,7 +532,7 @@ BOpt_FindDrivers ( Status = gBS->HandleProtocol (
CurHandle,
&gEfiSimpleFileSystemProtocolGuid,
- (VOID **) &SimpleFs
+ (VOID **)&SimpleFs
);
if (Status == EFI_SUCCESS) {
continue;
@@ -532,7 +541,7 @@ BOpt_FindDrivers ( Status = gBS->HandleProtocol (
CurHandle,
&gEfiLoadFileProtocolGuid,
- (VOID **) &LoadFile
+ (VOID **)&LoadFile
);
if (Status == EFI_SUCCESS) {
continue;
@@ -544,17 +553,16 @@ BOpt_FindDrivers ( return EFI_OUT_OF_RESOURCES;
}
- NewHandleContext = (BM_HANDLE_CONTEXT *) NewMenuEntry->VariableContext;
- NewHandleContext->Handle = CurHandle;
- NewHandleContext->DevicePath = DevicePathFromHandle (CurHandle);
- NewMenuEntry->DisplayString = UiDevicePathToStr (NewHandleContext->DevicePath);
- NewMenuEntry->DisplayStringToken = HiiSetString (mBmmCallbackInfo->BmmHiiHandle,0,NewMenuEntry->DisplayString,NULL);
- NewMenuEntry->HelpString = NULL;
- NewMenuEntry->HelpStringToken = NewMenuEntry->DisplayStringToken;
- NewMenuEntry->OptionNumber = OptionNumber;
+ NewHandleContext = (BM_HANDLE_CONTEXT *)NewMenuEntry->VariableContext;
+ NewHandleContext->Handle = CurHandle;
+ NewHandleContext->DevicePath = DevicePathFromHandle (CurHandle);
+ NewMenuEntry->DisplayString = UiDevicePathToStr (NewHandleContext->DevicePath);
+ NewMenuEntry->DisplayStringToken = HiiSetString (mBmmCallbackInfo->BmmHiiHandle, 0, NewMenuEntry->DisplayString, NULL);
+ NewMenuEntry->HelpString = NULL;
+ NewMenuEntry->HelpStringToken = NewMenuEntry->DisplayStringToken;
+ NewMenuEntry->OptionNumber = OptionNumber;
OptionNumber++;
InsertTailList (&DriverMenu.Head, &NewMenuEntry->Link);
-
}
if (DevicePathHandle != NULL) {
@@ -576,16 +584,16 @@ BOpt_FindDrivers ( **/
UINT16
BOpt_GetOptionNumber (
- CHAR16 *Type
+ CHAR16 *Type
)
{
- UINT16 *OrderList;
- UINTN OrderListSize;
- UINTN Index;
- CHAR16 StrTemp[20];
- UINT16 *OptionBuffer;
- UINT16 OptionNumber;
- UINTN OptionSize;
+ UINT16 *OrderList;
+ UINTN OrderListSize;
+ UINTN Index;
+ CHAR16 StrTemp[20];
+ UINT16 *OptionBuffer;
+ UINT16 OptionNumber;
+ UINTN OptionSize;
OrderListSize = 0;
OrderList = NULL;
@@ -594,7 +602,7 @@ BOpt_GetOptionNumber ( UnicodeSPrint (StrTemp, sizeof (StrTemp), L"%sOrder", Type);
- GetEfiGlobalVariable2 (StrTemp, (VOID **) &OrderList, &OrderListSize);
+ GetEfiGlobalVariable2 (StrTemp, (VOID **)&OrderList, &OrderListSize);
for (OptionNumber = 0; ; OptionNumber++) {
if (OrderList != NULL) {
for (Index = 0; Index < OrderListSize / sizeof (UINT16); Index++) {
@@ -610,9 +618,10 @@ BOpt_GetOptionNumber ( //
continue;
}
- UnicodeSPrint (StrTemp, sizeof (StrTemp), L"%s%04x", Type, (UINTN) OptionNumber);
- DEBUG((DEBUG_ERROR,"Option = %s\n", StrTemp));
- GetEfiGlobalVariable2 (StrTemp, (VOID **) &OptionBuffer, &OptionSize);
+
+ UnicodeSPrint (StrTemp, sizeof (StrTemp), L"%s%04x", Type, (UINTN)OptionNumber);
+ DEBUG ((DEBUG_ERROR, "Option = %s\n", StrTemp));
+ GetEfiGlobalVariable2 (StrTemp, (VOID **)&OptionBuffer, &OptionSize);
if (NULL == OptionBuffer) {
//
// The Boot[OptionNumber] / Driver[OptionNumber] NOT occurs, we found it
@@ -667,22 +676,22 @@ BOpt_GetDriverOptionNumber ( **/
EFI_STATUS
BOpt_GetDriverOptions (
- IN BMM_CALLBACK_DATA *CallbackData
+ IN BMM_CALLBACK_DATA *CallbackData
)
{
- UINTN Index;
- UINT16 DriverString[12];
- UINT8 *LoadOptionFromVar;
- UINTN DriverOptionSize;
-
- UINT16 *DriverOrderList;
- UINTN DriverOrderListSize;
- BM_MENU_ENTRY *NewMenuEntry;
- BM_LOAD_CONTEXT *NewLoadContext;
- UINT8 *LoadOptionPtr;
- UINTN StringSize;
- UINTN OptionalDataSize;
- UINT8 *LoadOptionEnd;
+ UINTN Index;
+ UINT16 DriverString[12];
+ UINT8 *LoadOptionFromVar;
+ UINTN DriverOptionSize;
+
+ UINT16 *DriverOrderList;
+ UINTN DriverOrderListSize;
+ BM_MENU_ENTRY *NewMenuEntry;
+ BM_LOAD_CONTEXT *NewLoadContext;
+ UINT8 *LoadOptionPtr;
+ UINTN StringSize;
+ UINTN OptionalDataSize;
+ UINT8 *LoadOptionEnd;
DriverOrderListSize = 0;
DriverOrderList = NULL;
@@ -693,7 +702,7 @@ BOpt_GetDriverOptions ( //
// Get the DriverOrder from the Var
//
- GetEfiGlobalVariable2 (L"DriverOrder", (VOID **) &DriverOrderList, &DriverOrderListSize);
+ GetEfiGlobalVariable2 (L"DriverOrder", (VOID **)&DriverOrderList, &DriverOrderListSize);
if (DriverOrderList == NULL) {
return EFI_NOT_FOUND;
}
@@ -708,23 +717,22 @@ BOpt_GetDriverOptions ( //
// Get all loadoptions from the VAR
//
- GetEfiGlobalVariable2 (DriverString, (VOID **) &LoadOptionFromVar, &DriverOptionSize);
+ GetEfiGlobalVariable2 (DriverString, (VOID **)&LoadOptionFromVar, &DriverOptionSize);
if (LoadOptionFromVar == NULL) {
continue;
}
-
NewMenuEntry = BOpt_CreateMenuEntry (BM_LOAD_CONTEXT_SELECT);
if (NULL == NewMenuEntry) {
return EFI_OUT_OF_RESOURCES;
}
- NewLoadContext = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext;
- LoadOptionPtr = LoadOptionFromVar;
- LoadOptionEnd = LoadOptionFromVar + DriverOptionSize;
- NewMenuEntry->OptionNumber = DriverOrderList[Index];
- NewLoadContext->Deleted = FALSE;
- NewLoadContext->IsLegacy = FALSE;
+ NewLoadContext = (BM_LOAD_CONTEXT *)NewMenuEntry->VariableContext;
+ LoadOptionPtr = LoadOptionFromVar;
+ LoadOptionEnd = LoadOptionFromVar + DriverOptionSize;
+ NewMenuEntry->OptionNumber = DriverOrderList[Index];
+ NewLoadContext->Deleted = FALSE;
+ NewLoadContext->IsLegacy = FALSE;
//
// LoadOption is a pointer type of UINT8
@@ -732,22 +740,22 @@ BOpt_GetDriverOptions ( // embedded in this struct
//
- NewLoadContext->Attributes = *(UINT32 *) LoadOptionPtr;
+ NewLoadContext->Attributes = *(UINT32 *)LoadOptionPtr;
LoadOptionPtr += sizeof (UINT32);
- NewLoadContext->FilePathListLength = *(UINT16 *) LoadOptionPtr;
- LoadOptionPtr += sizeof (UINT16);
+ NewLoadContext->FilePathListLength = *(UINT16 *)LoadOptionPtr;
+ LoadOptionPtr += sizeof (UINT16);
- StringSize = StrSize ((UINT16 *) LoadOptionPtr);
+ StringSize = StrSize ((UINT16 *)LoadOptionPtr);
NewLoadContext->Description = AllocateZeroPool (StringSize);
ASSERT (NewLoadContext->Description != NULL);
CopyMem (
NewLoadContext->Description,
- (UINT16 *) LoadOptionPtr,
+ (UINT16 *)LoadOptionPtr,
StringSize
);
- NewMenuEntry->DisplayString = NewLoadContext->Description;
+ NewMenuEntry->DisplayString = NewLoadContext->Description;
NewMenuEntry->DisplayStringToken = HiiSetString (CallbackData->BmmHiiHandle, 0, NewMenuEntry->DisplayString, NULL);
LoadOptionPtr += StringSize;
@@ -756,21 +764,21 @@ BOpt_GetDriverOptions ( ASSERT (NewLoadContext->FilePathList != NULL);
CopyMem (
NewLoadContext->FilePathList,
- (EFI_DEVICE_PATH_PROTOCOL *) LoadOptionPtr,
+ (EFI_DEVICE_PATH_PROTOCOL *)LoadOptionPtr,
NewLoadContext->FilePathListLength
);
- NewMenuEntry->HelpString = UiDevicePathToStr (NewLoadContext->FilePathList);
+ NewMenuEntry->HelpString = UiDevicePathToStr (NewLoadContext->FilePathList);
NewMenuEntry->HelpStringToken = HiiSetString (CallbackData->BmmHiiHandle, 0, NewMenuEntry->HelpString, NULL);
LoadOptionPtr += NewLoadContext->FilePathListLength;
if (LoadOptionPtr < LoadOptionEnd) {
OptionalDataSize = DriverOptionSize -
- sizeof (UINT32) -
- sizeof (UINT16) -
- StringSize -
- NewLoadContext->FilePathListLength;
+ sizeof (UINT32) -
+ sizeof (UINT16) -
+ StringSize -
+ NewLoadContext->FilePathListLength;
NewLoadContext->OptionalData = AllocateZeroPool (OptionalDataSize);
ASSERT (NewLoadContext->OptionalData != NULL);
@@ -779,12 +787,10 @@ BOpt_GetDriverOptions ( LoadOptionPtr,
OptionalDataSize
);
-
}
InsertTailList (&DriverOptionMenu.Head, &NewMenuEntry->Link);
FreePool (LoadOptionFromVar);
-
}
if (DriverOrderList != NULL) {
@@ -793,7 +799,6 @@ BOpt_GetDriverOptions ( DriverOptionMenu.MenuNumber = Index;
return EFI_SUCCESS;
-
}
/**
@@ -804,31 +809,32 @@ BOpt_GetDriverOptions ( **/
VOID
GetBootOrder (
- IN BMM_CALLBACK_DATA *CallbackData
+ IN BMM_CALLBACK_DATA *CallbackData
)
{
- BMM_FAKE_NV_DATA *BmmConfig;
- UINT16 Index;
- UINT16 OptionOrderIndex;
- UINTN DeviceType;
- BM_MENU_ENTRY *NewMenuEntry;
- BM_LOAD_CONTEXT *NewLoadContext;
+ BMM_FAKE_NV_DATA *BmmConfig;
+ UINT16 Index;
+ UINT16 OptionOrderIndex;
+ UINTN DeviceType;
+ BM_MENU_ENTRY *NewMenuEntry;
+ BM_LOAD_CONTEXT *NewLoadContext;
ASSERT (CallbackData != NULL);
- DeviceType = (UINTN) -1;
+ DeviceType = (UINTN)-1;
BmmConfig = &CallbackData->BmmFakeNvData;
ZeroMem (BmmConfig->BootOptionOrder, sizeof (BmmConfig->BootOptionOrder));
for (Index = 0, OptionOrderIndex = 0; ((Index < BootOptionMenu.MenuNumber) &&
- (OptionOrderIndex < (sizeof (BmmConfig->BootOptionOrder) / sizeof (BmmConfig->BootOptionOrder[0]))));
- Index++) {
+ (OptionOrderIndex < (sizeof (BmmConfig->BootOptionOrder) / sizeof (BmmConfig->BootOptionOrder[0]))));
+ Index++)
+ {
NewMenuEntry = BOpt_GetMenuEntry (&BootOptionMenu, Index);
- NewLoadContext = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext;
+ NewLoadContext = (BM_LOAD_CONTEXT *)NewMenuEntry->VariableContext;
if (NewLoadContext->IsLegacy) {
- if (((BBS_BBS_DEVICE_PATH *) NewLoadContext->FilePathList)->DeviceType != DeviceType) {
- DeviceType = ((BBS_BBS_DEVICE_PATH *) NewLoadContext->FilePathList)->DeviceType;
+ if (((BBS_BBS_DEVICE_PATH *)NewLoadContext->FilePathList)->DeviceType != DeviceType) {
+ DeviceType = ((BBS_BBS_DEVICE_PATH *)NewLoadContext->FilePathList)->DeviceType;
} else {
//
// Only show one legacy boot option for the same device type
@@ -837,7 +843,8 @@ GetBootOrder ( continue;
}
}
- BmmConfig->BootOptionOrder[OptionOrderIndex++] = (UINT32) (NewMenuEntry->OptionNumber + 1);
+
+ BmmConfig->BootOptionOrder[OptionOrderIndex++] = (UINT32)(NewMenuEntry->OptionNumber + 1);
}
}
@@ -849,32 +856,32 @@ GetBootOrder ( **/
VOID
GetDriverOrder (
- IN BMM_CALLBACK_DATA *CallbackData
+ IN BMM_CALLBACK_DATA *CallbackData
)
{
- BMM_FAKE_NV_DATA *BmmConfig;
- UINT16 Index;
- UINT16 OptionOrderIndex;
- UINTN DeviceType;
- BM_MENU_ENTRY *NewMenuEntry;
- BM_LOAD_CONTEXT *NewLoadContext;
-
+ BMM_FAKE_NV_DATA *BmmConfig;
+ UINT16 Index;
+ UINT16 OptionOrderIndex;
+ UINTN DeviceType;
+ BM_MENU_ENTRY *NewMenuEntry;
+ BM_LOAD_CONTEXT *NewLoadContext;
ASSERT (CallbackData != NULL);
- DeviceType = (UINTN) -1;
+ DeviceType = (UINTN)-1;
BmmConfig = &CallbackData->BmmFakeNvData;
ZeroMem (BmmConfig->DriverOptionOrder, sizeof (BmmConfig->DriverOptionOrder));
for (Index = 0, OptionOrderIndex = 0; ((Index < DriverOptionMenu.MenuNumber) &&
- (OptionOrderIndex < (sizeof (BmmConfig->DriverOptionOrder) / sizeof (BmmConfig->DriverOptionOrder[0]))));
- Index++) {
+ (OptionOrderIndex < (sizeof (BmmConfig->DriverOptionOrder) / sizeof (BmmConfig->DriverOptionOrder[0]))));
+ Index++)
+ {
NewMenuEntry = BOpt_GetMenuEntry (&DriverOptionMenu, Index);
- NewLoadContext = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext;
+ NewLoadContext = (BM_LOAD_CONTEXT *)NewMenuEntry->VariableContext;
if (NewLoadContext->IsLegacy) {
- if (((BBS_BBS_DEVICE_PATH *) NewLoadContext->FilePathList)->DeviceType != DeviceType) {
- DeviceType = ((BBS_BBS_DEVICE_PATH *) NewLoadContext->FilePathList)->DeviceType;
+ if (((BBS_BBS_DEVICE_PATH *)NewLoadContext->FilePathList)->DeviceType != DeviceType) {
+ DeviceType = ((BBS_BBS_DEVICE_PATH *)NewLoadContext->FilePathList)->DeviceType;
} else {
//
// Only show one legacy boot option for the same device type
@@ -883,7 +890,8 @@ GetDriverOrder ( continue;
}
}
- BmmConfig->DriverOptionOrder[OptionOrderIndex++] = (UINT32) (NewMenuEntry->OptionNumber + 1);
+
+ BmmConfig->DriverOptionOrder[OptionOrderIndex++] = (UINT32)(NewMenuEntry->OptionNumber + 1);
}
}
@@ -898,15 +906,15 @@ GetDriverOrder ( BOOLEAN
EFIAPI
BootFromFile (
- IN EFI_DEVICE_PATH_PROTOCOL *FilePath
+ IN EFI_DEVICE_PATH_PROTOCOL *FilePath
)
{
- EFI_BOOT_MANAGER_LOAD_OPTION BootOption;
- CHAR16 *FileName;
+ EFI_BOOT_MANAGER_LOAD_OPTION BootOption;
+ CHAR16 *FileName;
FileName = NULL;
- FileName = ExtractFileNameFromDevicePath(FilePath);
+ FileName = ExtractFileNameFromDevicePath (FilePath);
if (FileName != NULL) {
EfiBootManagerInitializeLoadOption (
&BootOption,
@@ -931,7 +939,7 @@ BootFromFile ( EfiBootManagerBoot (&BootOption);
BmmSetConsoleMode (TRUE);
- FreePool(FileName);
+ FreePool (FileName);
EfiBootManagerFreeLoadOption (&BootOption);
}
@@ -947,24 +955,24 @@ BootFromFile ( **/
BOOLEAN
-ReSendForm(
+ReSendForm (
IN EFI_DEVICE_PATH_PROTOCOL *FilePath,
IN EFI_FORM_ID FormId
)
{
gBootMaintenancePrivate.LoadContext->FilePathList = FilePath;
- UpdateOptionPage(&gBootMaintenancePrivate, FormId, FilePath);
+ UpdateOptionPage (&gBootMaintenancePrivate, FormId, FilePath);
gBootMaintenancePrivate.FormBrowser2->SendForm (
- gBootMaintenancePrivate.FormBrowser2,
- &gBootMaintenancePrivate.BmmHiiHandle,
- 1,
- &mBootMaintGuid,
- FormId,
- NULL,
- NULL
- );
+ gBootMaintenancePrivate.FormBrowser2,
+ &gBootMaintenancePrivate.BmmHiiHandle,
+ 1,
+ &mBootMaintGuid,
+ FormId,
+ NULL,
+ NULL
+ );
return TRUE;
}
@@ -979,10 +987,10 @@ ReSendForm( BOOLEAN
EFIAPI
CreateBootOptionFromFile (
- IN EFI_DEVICE_PATH_PROTOCOL *FilePath
+ IN EFI_DEVICE_PATH_PROTOCOL *FilePath
)
{
- return ReSendForm(FilePath, FORM_BOOT_ADD_ID);
+ return ReSendForm (FilePath, FORM_BOOT_ADD_ID);
}
/**
@@ -997,8 +1005,8 @@ CreateBootOptionFromFile ( BOOLEAN
EFIAPI
CreateDriverOptionFromFile (
- IN EFI_DEVICE_PATH_PROTOCOL *FilePath
+ IN EFI_DEVICE_PATH_PROTOCOL *FilePath
)
{
- return ReSendForm(FilePath, FORM_DRV_ADD_FILE_ID);
+ return ReSendForm (FilePath, FORM_DRV_ADD_FILE_ID);
}
diff --git a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/ConsoleOption.c b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/ConsoleOption.c index 5d1c6d34e6..7c02a78166 100644 --- a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/ConsoleOption.c +++ b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/ConsoleOption.c @@ -31,7 +31,7 @@ MatchDevicePaths ( EFI_DEVICE_PATH_PROTOCOL *DevicePathInst;
UINTN Size;
- if (Multi == NULL || Single == NULL) {
+ if ((Multi == NULL) || (Single == NULL)) {
return FALSE;
}
@@ -69,14 +69,14 @@ MatchDevicePaths ( **/
BOOLEAN
IsIsaSerialNode (
- IN ACPI_HID_DEVICE_PATH *Acpi
+ IN ACPI_HID_DEVICE_PATH *Acpi
)
{
- return (BOOLEAN) (
- (DevicePathType (Acpi) == ACPI_DEVICE_PATH) &&
- (DevicePathSubType (Acpi) == ACPI_DP) &&
- (ReadUnaligned32 (&Acpi->HID) == EISA_PNP_ID (0x0501))
- );
+ return (BOOLEAN)(
+ (DevicePathType (Acpi) == ACPI_DEVICE_PATH) &&
+ (DevicePathSubType (Acpi) == ACPI_DP) &&
+ (ReadUnaligned32 (&Acpi->HID) == EISA_PNP_ID (0x0501))
+ );
}
/**
@@ -119,20 +119,20 @@ ChangeTerminalDevicePath ( BM_TERMINAL_CONTEXT *NewTerminalContext;
BM_MENU_ENTRY *NewMenuEntry;
- Node = DevicePath;
- Node = NextDevicePathNode (Node);
- Com = 0;
+ Node = DevicePath;
+ Node = NextDevicePathNode (Node);
+ Com = 0;
while (!IsDevicePathEnd (Node)) {
- Acpi = (ACPI_HID_DEVICE_PATH *) Node;
+ Acpi = (ACPI_HID_DEVICE_PATH *)Node;
if (IsIsaSerialNode (Acpi)) {
CopyMem (&Com, &Acpi->UID, sizeof (UINT32));
}
NewMenuEntry = BOpt_GetMenuEntry (&TerminalMenu, Com);
- NewTerminalContext = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext;
+ NewTerminalContext = (BM_TERMINAL_CONTEXT *)NewMenuEntry->VariableContext;
if ((DevicePathType (Node) == MESSAGING_DEVICE_PATH) && (DevicePathSubType (Node) == MSG_UART_DP)) {
- Uart = (UART_DEVICE_PATH *) Node;
+ Uart = (UART_DEVICE_PATH *)Node;
CopyMem (
&Uart->BaudRate,
&NewTerminalContext->BaudRate,
@@ -164,7 +164,7 @@ ChangeTerminalDevicePath ( Node1 = NextDevicePathNode (Node1);
while (!IsDevicePathEnd (Node1)) {
if ((DevicePathType (Node1) == MESSAGING_DEVICE_PATH) && (DevicePathSubType (Node1) == MSG_UART_DP)) {
- Uart1 = (UART_DEVICE_PATH *) Node1;
+ Uart1 = (UART_DEVICE_PATH *)Node1;
CopyMem (
&Uart1->BaudRate,
&NewTerminalContext->BaudRate,
@@ -190,11 +190,13 @@ ChangeTerminalDevicePath ( );
break;
}
+
//
// end if
//
Node1 = NextDevicePathNode (Node1);
}
+
//
// end while
//
@@ -206,7 +208,6 @@ ChangeTerminalDevicePath ( }
return EFI_SUCCESS;
-
}
/**
@@ -229,23 +230,23 @@ ChangeVariableDevicePath ( BM_TERMINAL_CONTEXT *NewTerminalContext;
BM_MENU_ENTRY *NewMenuEntry;
- Node = DevicePath;
- Node = NextDevicePathNode (Node);
- Com = 0;
+ Node = DevicePath;
+ Node = NextDevicePathNode (Node);
+ Com = 0;
while (!IsDevicePathEnd (Node)) {
- Acpi = (ACPI_HID_DEVICE_PATH *) Node;
+ Acpi = (ACPI_HID_DEVICE_PATH *)Node;
if (IsIsaSerialNode (Acpi)) {
CopyMem (&Com, &Acpi->UID, sizeof (UINT32));
}
if ((DevicePathType (Node) == MESSAGING_DEVICE_PATH) && (DevicePathSubType (Node) == MSG_UART_DP)) {
NewMenuEntry = BOpt_GetMenuEntry (
- &TerminalMenu,
- Com
- );
+ &TerminalMenu,
+ Com
+ );
ASSERT (NewMenuEntry != NULL);
- NewTerminalContext = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext;
- Uart = (UART_DEVICE_PATH *) Node;
+ NewTerminalContext = (BM_TERMINAL_CONTEXT *)NewMenuEntry->VariableContext;
+ Uart = (UART_DEVICE_PATH *)Node;
CopyMem (
&Uart->BaudRate,
&NewTerminalContext->BaudRate,
@@ -287,8 +288,8 @@ ChangeVariableDevicePath ( **/
BOOLEAN
RetrieveUartUid (
- IN EFI_HANDLE Handle,
- IN OUT UINT32 *AcpiUid
+ IN EFI_HANDLE Handle,
+ IN OUT UINT32 *AcpiUid
)
{
EFI_STATUS Status;
@@ -298,27 +299,29 @@ RetrieveUartUid ( Status = gBS->HandleProtocol (
Handle,
&gEfiDevicePathProtocolGuid,
- (VOID **) &DevicePath
+ (VOID **)&DevicePath
);
if (EFI_ERROR (Status)) {
return FALSE;
}
Acpi = NULL;
- for (; !IsDevicePathEnd (DevicePath); DevicePath = NextDevicePathNode (DevicePath)) {
+ for ( ; !IsDevicePathEnd (DevicePath); DevicePath = NextDevicePathNode (DevicePath)) {
if ((DevicePathType (DevicePath) == MESSAGING_DEVICE_PATH) && (DevicePathSubType (DevicePath) == MSG_UART_DP)) {
break;
}
+
//
// Acpi points to the node before the Uart node
//
- Acpi = (ACPI_HID_DEVICE_PATH *) DevicePath;
+ Acpi = (ACPI_HID_DEVICE_PATH *)DevicePath;
}
if ((Acpi != NULL) && IsIsaSerialNode (Acpi)) {
if (AcpiUid != NULL) {
CopyMem (AcpiUid, &Acpi->UID, sizeof (UINT32));
}
+
return TRUE;
} else {
return FALSE;
@@ -333,8 +336,8 @@ RetrieveUartUid ( **/
VOID
SortedUartHandle (
- IN EFI_HANDLE *Handles,
- IN UINTN NoHandles
+ IN EFI_HANDLE *Handles,
+ IN UINTN NoHandles
)
{
UINTN Index1;
@@ -349,6 +352,7 @@ SortedUartHandle ( if (!RetrieveUartUid (Handles[Index1], &AcpiUid1)) {
continue;
}
+
TempHandle = Handles[Index1];
Position = Index1;
TempAcpiUid = AcpiUid1;
@@ -357,12 +361,14 @@ SortedUartHandle ( if (!RetrieveUartUid (Handles[Index2], &AcpiUid2)) {
continue;
}
+
if (AcpiUid2 < TempAcpiUid) {
TempAcpiUid = AcpiUid2;
TempHandle = Handles[Index2];
Position = Index2;
}
}
+
Handles[Position] = Handles[Index1];
Handles[Index1] = TempHandle;
}
@@ -382,9 +388,9 @@ SortedUartHandle ( **/
BOOLEAN
IsTerminalDevicePath (
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
- OUT TYPE_OF_TERMINAL *Termi,
- OUT UINTN *Com
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
+ OUT TYPE_OF_TERMINAL *Termi,
+ OUT UINTN *Com
);
/**
@@ -422,13 +428,13 @@ LocateSerialIo ( //
InitializeListHead (&TerminalMenu.Head);
TerminalMenu.MenuNumber = 0;
- Status = gBS->LocateHandleBuffer (
- ByProtocol,
- &gEfiSerialIoProtocolGuid,
- NULL,
- &NoHandles,
- &Handles
- );
+ Status = gBS->LocateHandleBuffer (
+ ByProtocol,
+ &gEfiSerialIoProtocolGuid,
+ NULL,
+ &NoHandles,
+ &Handles
+ );
if (EFI_ERROR (Status)) {
//
// No serial ports present
@@ -447,20 +453,21 @@ LocateSerialIo ( // Check to see whether the handle has DevicePath Protocol installed
//
gBS->HandleProtocol (
- Handles[Index],
- &gEfiDevicePathProtocolGuid,
- (VOID **) &DevicePath
- );
+ Handles[Index],
+ &gEfiDevicePathProtocolGuid,
+ (VOID **)&DevicePath
+ );
Acpi = NULL;
for (Node = DevicePath; !IsDevicePathEnd (Node); Node = NextDevicePathNode (Node)) {
if ((DevicePathType (Node) == MESSAGING_DEVICE_PATH) && (DevicePathSubType (Node) == MSG_UART_DP)) {
break;
}
+
//
// Acpi points to the node before Uart node
//
- Acpi = (ACPI_HID_DEVICE_PATH *) Node;
+ Acpi = (ACPI_HID_DEVICE_PATH *)Node;
}
if ((Acpi != NULL) && IsIsaSerialNode (Acpi)) {
@@ -470,7 +477,7 @@ LocateSerialIo ( return EFI_OUT_OF_RESOURCES;
}
- NewTerminalContext = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext;
+ NewTerminalContext = (BM_TERMINAL_CONTEXT *)NewMenuEntry->VariableContext;
CopyMem (&NewMenuEntry->OptionNumber, &Acpi->UID, sizeof (UINT32));
NewTerminalContext->DevicePath = DuplicateDevicePath (DevicePath);
//
@@ -491,10 +498,10 @@ LocateSerialIo ( NewMenuEntry->HelpStringToken = NewMenuEntry->DisplayStringToken;
gBS->HandleProtocol (
- Handles[Index],
- &gEfiSerialIoProtocolGuid,
- (VOID **) &SerialIo
- );
+ Handles[Index],
+ &gEfiSerialIoProtocolGuid,
+ (VOID **)&SerialIo
+ );
CopyMem (
&NewTerminalContext->BaudRate,
@@ -523,6 +530,7 @@ LocateSerialIo ( TerminalMenu.MenuNumber++;
}
}
+
if (Handles != NULL) {
FreePool (Handles);
}
@@ -530,9 +538,9 @@ LocateSerialIo ( //
// Get L"ConOut", L"ConIn" and L"ErrOut" from the Var
//
- GetEfiGlobalVariable2 (L"ConOut", (VOID**)&OutDevicePath, NULL);
- GetEfiGlobalVariable2 (L"ConIn", (VOID**)&InpDevicePath, NULL);
- GetEfiGlobalVariable2 (L"ErrOut", (VOID**)&ErrDevicePath, NULL);
+ GetEfiGlobalVariable2 (L"ConOut", (VOID **)&OutDevicePath, NULL);
+ GetEfiGlobalVariable2 (L"ConIn", (VOID **)&InpDevicePath, NULL);
+ GetEfiGlobalVariable2 (L"ErrOut", (VOID **)&ErrDevicePath, NULL);
if (OutDevicePath != NULL) {
UpdateComAttributeFromVariable (OutDevicePath);
}
@@ -551,26 +559,27 @@ LocateSerialIo ( return EFI_NOT_FOUND;
}
- NewTerminalContext = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext;
+ NewTerminalContext = (BM_TERMINAL_CONTEXT *)NewMenuEntry->VariableContext;
- NewTerminalContext->TerminalType = 0;
- NewTerminalContext->IsConIn = FALSE;
- NewTerminalContext->IsConOut = FALSE;
- NewTerminalContext->IsStdErr = FALSE;
+ NewTerminalContext->TerminalType = 0;
+ NewTerminalContext->IsConIn = FALSE;
+ NewTerminalContext->IsConOut = FALSE;
+ NewTerminalContext->IsStdErr = FALSE;
- Vendor.Header.Type = MESSAGING_DEVICE_PATH;
- Vendor.Header.SubType = MSG_VENDOR_DP;
+ Vendor.Header.Type = MESSAGING_DEVICE_PATH;
+ Vendor.Header.SubType = MSG_VENDOR_DP;
for (Index2 = 0; Index2 < (ARRAY_SIZE (TerminalTypeGuid)); Index2++) {
CopyMem (&Vendor.Guid, &TerminalTypeGuid[Index2], sizeof (EFI_GUID));
SetDevicePathNodeLength (&Vendor.Header, sizeof (VENDOR_DEVICE_PATH));
NewDevicePath = AppendDevicePathNode (
NewTerminalContext->DevicePath,
- (EFI_DEVICE_PATH_PROTOCOL *) &Vendor
+ (EFI_DEVICE_PATH_PROTOCOL *)&Vendor
);
if (NewMenuEntry->HelpString != NULL) {
FreePool (NewMenuEntry->HelpString);
}
+
//
// NewMenuEntry->HelpString = UiDevicePathToStr (NewDevicePath);
// NewMenuEntry->DisplayString = NewMenuEntry->HelpString;
@@ -582,18 +591,18 @@ LocateSerialIo ( NewMenuEntry->HelpStringToken = NewMenuEntry->DisplayStringToken;
if (MatchDevicePaths (OutDevicePath, NewDevicePath)) {
- NewTerminalContext->IsConOut = TRUE;
- NewTerminalContext->TerminalType = (UINT8) Index2;
+ NewTerminalContext->IsConOut = TRUE;
+ NewTerminalContext->TerminalType = (UINT8)Index2;
}
if (MatchDevicePaths (InpDevicePath, NewDevicePath)) {
- NewTerminalContext->IsConIn = TRUE;
- NewTerminalContext->TerminalType = (UINT8) Index2;
+ NewTerminalContext->IsConIn = TRUE;
+ NewTerminalContext->TerminalType = (UINT8)Index2;
}
if (MatchDevicePaths (ErrDevicePath, NewDevicePath)) {
- NewTerminalContext->IsStdErr = TRUE;
- NewTerminalContext->TerminalType = (UINT8) Index2;
+ NewTerminalContext->IsStdErr = TRUE;
+ NewTerminalContext->TerminalType = (UINT8)Index2;
}
}
}
@@ -624,24 +633,24 @@ UpdateComAttributeFromVariable ( BM_TERMINAL_CONTEXT *NewTerminalContext;
UINTN Index;
- Node = DevicePath;
- Node = NextDevicePathNode (Node);
- TerminalNumber = 0;
+ Node = DevicePath;
+ Node = NextDevicePathNode (Node);
+ TerminalNumber = 0;
for (Index = 0; Index < TerminalMenu.MenuNumber; Index++) {
while (!IsDevicePathEnd (Node)) {
- Acpi = (ACPI_HID_DEVICE_PATH *) Node;
+ Acpi = (ACPI_HID_DEVICE_PATH *)Node;
if (IsIsaSerialNode (Acpi)) {
CopyMem (&TerminalNumber, &Acpi->UID, sizeof (UINT32));
}
if ((DevicePathType (Node) == MESSAGING_DEVICE_PATH) && (DevicePathSubType (Node) == MSG_UART_DP)) {
- Uart = (UART_DEVICE_PATH *) Node;
- NewMenuEntry = BOpt_GetMenuEntry (&TerminalMenu, TerminalNumber);
+ Uart = (UART_DEVICE_PATH *)Node;
+ NewMenuEntry = BOpt_GetMenuEntry (&TerminalMenu, TerminalNumber);
if (NULL == NewMenuEntry) {
return EFI_NOT_FOUND;
}
- NewTerminalContext = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext;
+ NewTerminalContext = (BM_TERMINAL_CONTEXT *)NewMenuEntry->VariableContext;
CopyMem (
&NewTerminalContext->BaudRate,
&Uart->BaudRate,
@@ -666,15 +675,15 @@ UpdateComAttributeFromVariable ( sizeof (UINT8)
);
- SerialNode = NewTerminalContext->DevicePath;
- SerialNode = NextDevicePathNode (SerialNode);
+ SerialNode = NewTerminalContext->DevicePath;
+ SerialNode = NextDevicePathNode (SerialNode);
while (!IsDevicePathEnd (SerialNode)) {
if ((DevicePathType (SerialNode) == MESSAGING_DEVICE_PATH) && (DevicePathSubType (SerialNode) == MSG_UART_DP)) {
//
// Update following device paths according to
// previous acquired uart attributes
//
- Uart1 = (UART_DEVICE_PATH *) SerialNode;
+ Uart1 = (UART_DEVICE_PATH *)SerialNode;
CopyMem (
&Uart1->BaudRate,
&NewTerminalContext->BaudRate,
@@ -702,6 +711,7 @@ UpdateComAttributeFromVariable ( SerialNode = NextDevicePathNode (SerialNode);
}
+
//
// end while
//
@@ -709,6 +719,7 @@ UpdateComAttributeFromVariable ( Node = NextDevicePathNode (Node);
}
+
//
// end while
//
@@ -734,7 +745,7 @@ UpdateComAttributeFromVariable ( **/
EFI_STATUS
GetConsoleMenu (
- IN UINTN ConsoleMenuType
+ IN UINTN ConsoleMenuType
)
{
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
@@ -755,26 +766,26 @@ GetConsoleMenu ( AllDevicePath = NULL;
AllCount = 0;
switch (ConsoleMenuType) {
- case BM_CONSOLE_IN_CONTEXT_SELECT:
- ConsoleMenu = &ConsoleInpMenu;
- GetEfiGlobalVariable2 (L"ConIn", (VOID**)&DevicePath, NULL);
- GetEfiGlobalVariable2 (L"ConInDev", (VOID**)&AllDevicePath, NULL);
- break;
-
- case BM_CONSOLE_OUT_CONTEXT_SELECT:
- ConsoleMenu = &ConsoleOutMenu;
- GetEfiGlobalVariable2 (L"ConOut", (VOID**)&DevicePath, NULL);
- GetEfiGlobalVariable2 (L"ConOutDev", (VOID**)&AllDevicePath, NULL);
- break;
-
- case BM_CONSOLE_ERR_CONTEXT_SELECT:
- ConsoleMenu = &ConsoleErrMenu;
- GetEfiGlobalVariable2 (L"ErrOut", (VOID**)&DevicePath, NULL);
- GetEfiGlobalVariable2 (L"ErrOutDev", (VOID**)&AllDevicePath, NULL);
- break;
-
- default:
- return EFI_UNSUPPORTED;
+ case BM_CONSOLE_IN_CONTEXT_SELECT:
+ ConsoleMenu = &ConsoleInpMenu;
+ GetEfiGlobalVariable2 (L"ConIn", (VOID **)&DevicePath, NULL);
+ GetEfiGlobalVariable2 (L"ConInDev", (VOID **)&AllDevicePath, NULL);
+ break;
+
+ case BM_CONSOLE_OUT_CONTEXT_SELECT:
+ ConsoleMenu = &ConsoleOutMenu;
+ GetEfiGlobalVariable2 (L"ConOut", (VOID **)&DevicePath, NULL);
+ GetEfiGlobalVariable2 (L"ConOutDev", (VOID **)&AllDevicePath, NULL);
+ break;
+
+ case BM_CONSOLE_ERR_CONTEXT_SELECT:
+ ConsoleMenu = &ConsoleErrMenu;
+ GetEfiGlobalVariable2 (L"ErrOut", (VOID **)&DevicePath, NULL);
+ GetEfiGlobalVariable2 (L"ErrOutDev", (VOID **)&AllDevicePath, NULL);
+ break;
+
+ default:
+ return EFI_UNSUPPORTED;
}
if (NULL == AllDevicePath) {
@@ -791,19 +802,19 @@ GetConsoleMenu ( MultiDevicePath = AllDevicePath;
Index2 = 0;
for (Index = 0; Index < AllCount; Index++) {
- DevicePathInst = GetNextDevicePathInstance (&MultiDevicePath, &Size);
+ DevicePathInst = GetNextDevicePathInstance (&MultiDevicePath, &Size);
- NewMenuEntry = BOpt_CreateMenuEntry (BM_CONSOLE_CONTEXT_SELECT);
+ NewMenuEntry = BOpt_CreateMenuEntry (BM_CONSOLE_CONTEXT_SELECT);
if (NULL == NewMenuEntry) {
return EFI_OUT_OF_RESOURCES;
}
- NewConsoleContext = (BM_CONSOLE_CONTEXT *) NewMenuEntry->VariableContext;
- NewMenuEntry->OptionNumber = Index2;
+ NewConsoleContext = (BM_CONSOLE_CONTEXT *)NewMenuEntry->VariableContext;
+ NewMenuEntry->OptionNumber = Index2;
NewConsoleContext->DevicePath = DuplicateDevicePath (DevicePathInst);
ASSERT (NewConsoleContext->DevicePath != NULL);
- NewMenuEntry->DisplayString = EfiLibStrFromDatahub (NewConsoleContext->DevicePath);
+ NewMenuEntry->DisplayString = EfiLibStrFromDatahub (NewConsoleContext->DevicePath);
if (NULL == NewMenuEntry->DisplayString) {
NewMenuEntry->DisplayString = UiDevicePathToStr (NewConsoleContext->DevicePath);
}
@@ -887,9 +898,9 @@ FreeAllConsoles ( **/
BOOLEAN
IsTerminalDevicePath (
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
- OUT TYPE_OF_TERMINAL *Termi,
- OUT UINTN *Com
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
+ OUT TYPE_OF_TERMINAL *Termi,
+ OUT UINTN *Com
)
{
BOOLEAN IsTerminal;
@@ -908,24 +919,25 @@ IsTerminalDevicePath ( //
// Vendor points to the node before the End node
//
- Vendor = (VENDOR_DEVICE_PATH *) Node;
+ Vendor = (VENDOR_DEVICE_PATH *)Node;
if ((DevicePathType (Node) == MESSAGING_DEVICE_PATH) && (DevicePathSubType (Node) == MSG_UART_DP)) {
- Uart = (UART_DEVICE_PATH *) Node;
+ Uart = (UART_DEVICE_PATH *)Node;
}
if (Uart == NULL) {
//
// Acpi points to the node before the UART node
//
- Acpi = (ACPI_HID_DEVICE_PATH *) Node;
+ Acpi = (ACPI_HID_DEVICE_PATH *)Node;
}
}
- if (Vendor == NULL ||
- DevicePathType (Vendor) != MESSAGING_DEVICE_PATH ||
- DevicePathSubType (Vendor) != MSG_VENDOR_DP ||
- Uart == NULL) {
+ if ((Vendor == NULL) ||
+ (DevicePathType (Vendor) != MESSAGING_DEVICE_PATH) ||
+ (DevicePathSubType (Vendor) != MSG_VENDOR_DP) ||
+ (Uart == NULL))
+ {
return FALSE;
}
@@ -936,7 +948,7 @@ IsTerminalDevicePath ( //
for (Index = 0; Index < ARRAY_SIZE (TerminalTypeGuid); Index++) {
if (CompareGuid (&Vendor->Guid, &TerminalTypeGuid[Index])) {
- *Termi = Index;
+ *Termi = Index;
IsTerminal = TRUE;
break;
}
@@ -966,28 +978,28 @@ IsTerminalDevicePath ( **/
VOID
GetConsoleOutMode (
- IN BMM_CALLBACK_DATA *CallbackData
+ IN BMM_CALLBACK_DATA *CallbackData
)
{
- UINTN Col;
- UINTN Row;
- UINTN CurrentCol;
- UINTN CurrentRow;
- UINTN Mode;
- UINTN MaxMode;
- EFI_STATUS Status;
+ UINTN Col;
+ UINTN Row;
+ UINTN CurrentCol;
+ UINTN CurrentRow;
+ UINTN Mode;
+ UINTN MaxMode;
+ EFI_STATUS Status;
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *ConOut;
- ConOut = gST->ConOut;
- MaxMode = (UINTN) (ConOut->Mode->MaxMode);
+ ConOut = gST->ConOut;
+ MaxMode = (UINTN)(ConOut->Mode->MaxMode);
CurrentCol = PcdGet32 (PcdSetupConOutColumn);
CurrentRow = PcdGet32 (PcdSetupConOutRow);
for (Mode = 0; Mode < MaxMode; Mode++) {
Status = ConOut->QueryMode (ConOut, Mode, &Col, &Row);
- if (!EFI_ERROR(Status)) {
- if (CurrentCol == Col && CurrentRow == Row) {
- CallbackData->BmmFakeNvData.ConsoleOutMode = (UINT16) Mode;
+ if (!EFI_ERROR (Status)) {
+ if ((CurrentCol == Col) && (CurrentRow == Row)) {
+ CallbackData->BmmFakeNvData.ConsoleOutMode = (UINT16)Mode;
break;
}
}
@@ -1004,28 +1016,29 @@ GetConsoleOutMode ( **/
VOID
GetConsoleInCheck (
- IN BMM_CALLBACK_DATA *CallbackData
+ IN BMM_CALLBACK_DATA *CallbackData
)
{
- UINT16 Index;
- BM_MENU_ENTRY *NewMenuEntry;
- UINT8 *ConInCheck;
- BM_CONSOLE_CONTEXT *NewConsoleContext;
- BM_TERMINAL_CONTEXT *NewTerminalContext;
+ UINT16 Index;
+ BM_MENU_ENTRY *NewMenuEntry;
+ UINT8 *ConInCheck;
+ BM_CONSOLE_CONTEXT *NewConsoleContext;
+ BM_TERMINAL_CONTEXT *NewTerminalContext;
ASSERT (CallbackData != NULL);
ConInCheck = &CallbackData->BmmFakeNvData.ConsoleInCheck[0];
for (Index = 0; ((Index < ConsoleInpMenu.MenuNumber) && \
- (Index < MAX_MENU_NUMBER)) ; Index++) {
+ (Index < MAX_MENU_NUMBER)); Index++)
+ {
NewMenuEntry = BOpt_GetMenuEntry (&ConsoleInpMenu, Index);
- NewConsoleContext = (BM_CONSOLE_CONTEXT *) NewMenuEntry->VariableContext;
+ NewConsoleContext = (BM_CONSOLE_CONTEXT *)NewMenuEntry->VariableContext;
ConInCheck[Index] = NewConsoleContext->IsActive;
}
for (Index = 0; Index < TerminalMenu.MenuNumber; Index++) {
- NewMenuEntry = BOpt_GetMenuEntry (&TerminalMenu, Index);
- NewTerminalContext = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext;
+ NewMenuEntry = BOpt_GetMenuEntry (&TerminalMenu, Index);
+ NewTerminalContext = (BM_TERMINAL_CONTEXT *)NewMenuEntry->VariableContext;
ASSERT (Index + ConsoleInpMenu.MenuNumber < MAX_MENU_NUMBER);
ConInCheck[Index + ConsoleInpMenu.MenuNumber] = NewTerminalContext->IsConIn;
}
@@ -1041,27 +1054,28 @@ GetConsoleInCheck ( **/
VOID
GetConsoleOutCheck (
- IN BMM_CALLBACK_DATA *CallbackData
+ IN BMM_CALLBACK_DATA *CallbackData
)
{
- UINT16 Index;
- BM_MENU_ENTRY *NewMenuEntry;
- UINT8 *ConOutCheck;
- BM_CONSOLE_CONTEXT *NewConsoleContext;
- BM_TERMINAL_CONTEXT *NewTerminalContext;
+ UINT16 Index;
+ BM_MENU_ENTRY *NewMenuEntry;
+ UINT8 *ConOutCheck;
+ BM_CONSOLE_CONTEXT *NewConsoleContext;
+ BM_TERMINAL_CONTEXT *NewTerminalContext;
ASSERT (CallbackData != NULL);
ConOutCheck = &CallbackData->BmmFakeNvData.ConsoleOutCheck[0];
for (Index = 0; ((Index < ConsoleOutMenu.MenuNumber) && \
- (Index < MAX_MENU_NUMBER)) ; Index++) {
- NewMenuEntry = BOpt_GetMenuEntry (&ConsoleOutMenu, Index);
- NewConsoleContext = (BM_CONSOLE_CONTEXT *) NewMenuEntry->VariableContext;
+ (Index < MAX_MENU_NUMBER)); Index++)
+ {
+ NewMenuEntry = BOpt_GetMenuEntry (&ConsoleOutMenu, Index);
+ NewConsoleContext = (BM_CONSOLE_CONTEXT *)NewMenuEntry->VariableContext;
ConOutCheck[Index] = NewConsoleContext->IsActive;
}
for (Index = 0; Index < TerminalMenu.MenuNumber; Index++) {
- NewMenuEntry = BOpt_GetMenuEntry (&TerminalMenu, Index);
- NewTerminalContext = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext;
+ NewMenuEntry = BOpt_GetMenuEntry (&TerminalMenu, Index);
+ NewTerminalContext = (BM_TERMINAL_CONTEXT *)NewMenuEntry->VariableContext;
ASSERT (Index + ConsoleOutMenu.MenuNumber < MAX_MENU_NUMBER);
ConOutCheck[Index + ConsoleOutMenu.MenuNumber] = NewTerminalContext->IsConOut;
}
@@ -1077,27 +1091,28 @@ GetConsoleOutCheck ( **/
VOID
GetConsoleErrCheck (
- IN BMM_CALLBACK_DATA *CallbackData
+ IN BMM_CALLBACK_DATA *CallbackData
)
{
- UINT16 Index;
- BM_MENU_ENTRY *NewMenuEntry;
- UINT8 *ConErrCheck;
- BM_CONSOLE_CONTEXT *NewConsoleContext;
- BM_TERMINAL_CONTEXT *NewTerminalContext;
+ UINT16 Index;
+ BM_MENU_ENTRY *NewMenuEntry;
+ UINT8 *ConErrCheck;
+ BM_CONSOLE_CONTEXT *NewConsoleContext;
+ BM_TERMINAL_CONTEXT *NewTerminalContext;
ASSERT (CallbackData != NULL);
ConErrCheck = &CallbackData->BmmFakeNvData.ConsoleErrCheck[0];
for (Index = 0; ((Index < ConsoleErrMenu.MenuNumber) && \
- (Index < MAX_MENU_NUMBER)) ; Index++) {
- NewMenuEntry = BOpt_GetMenuEntry (&ConsoleErrMenu, Index);
- NewConsoleContext = (BM_CONSOLE_CONTEXT *) NewMenuEntry->VariableContext;
+ (Index < MAX_MENU_NUMBER)); Index++)
+ {
+ NewMenuEntry = BOpt_GetMenuEntry (&ConsoleErrMenu, Index);
+ NewConsoleContext = (BM_CONSOLE_CONTEXT *)NewMenuEntry->VariableContext;
ConErrCheck[Index] = NewConsoleContext->IsActive;
}
for (Index = 0; Index < TerminalMenu.MenuNumber; Index++) {
- NewMenuEntry = BOpt_GetMenuEntry (&TerminalMenu, Index);
- NewTerminalContext = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext;
+ NewMenuEntry = BOpt_GetMenuEntry (&TerminalMenu, Index);
+ NewTerminalContext = (BM_TERMINAL_CONTEXT *)NewMenuEntry->VariableContext;
ASSERT (Index + ConsoleErrMenu.MenuNumber < MAX_MENU_NUMBER);
ConErrCheck[Index + ConsoleErrMenu.MenuNumber] = NewTerminalContext->IsStdErr;
}
@@ -1113,7 +1128,7 @@ GetConsoleErrCheck ( **/
VOID
GetTerminalAttribute (
- IN BMM_CALLBACK_DATA *CallbackData
+ IN BMM_CALLBACK_DATA *CallbackData
)
{
BMM_FAKE_NV_DATA *CurrentFakeNVMap;
@@ -1126,35 +1141,38 @@ GetTerminalAttribute ( CurrentFakeNVMap = &CallbackData->BmmFakeNvData;
for (TerminalIndex = 0; ((TerminalIndex < TerminalMenu.MenuNumber) && \
- (TerminalIndex < MAX_MENU_NUMBER)); TerminalIndex++) {
- NewMenuEntry = BOpt_GetMenuEntry (&TerminalMenu, TerminalIndex);
- NewTerminalContext = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext;
- for (AttributeIndex = 0; AttributeIndex < sizeof (BaudRateList) / sizeof (BaudRateList [0]); AttributeIndex++) {
- if (NewTerminalContext->BaudRate == (UINT64) (BaudRateList[AttributeIndex].Value)) {
+ (TerminalIndex < MAX_MENU_NUMBER)); TerminalIndex++)
+ {
+ NewMenuEntry = BOpt_GetMenuEntry (&TerminalMenu, TerminalIndex);
+ NewTerminalContext = (BM_TERMINAL_CONTEXT *)NewMenuEntry->VariableContext;
+ for (AttributeIndex = 0; AttributeIndex < sizeof (BaudRateList) / sizeof (BaudRateList[0]); AttributeIndex++) {
+ if (NewTerminalContext->BaudRate == (UINT64)(BaudRateList[AttributeIndex].Value)) {
NewTerminalContext->BaudRateIndex = AttributeIndex;
break;
}
}
+
for (AttributeIndex = 0; AttributeIndex < ARRAY_SIZE (DataBitsList); AttributeIndex++) {
- if (NewTerminalContext->DataBits == (UINT64) (DataBitsList[AttributeIndex].Value)) {
+ if (NewTerminalContext->DataBits == (UINT64)(DataBitsList[AttributeIndex].Value)) {
NewTerminalContext->DataBitsIndex = AttributeIndex;
break;
}
}
for (AttributeIndex = 0; AttributeIndex < ARRAY_SIZE (ParityList); AttributeIndex++) {
- if (NewTerminalContext->Parity == (UINT64) (ParityList[AttributeIndex].Value)) {
+ if (NewTerminalContext->Parity == (UINT64)(ParityList[AttributeIndex].Value)) {
NewTerminalContext->ParityIndex = AttributeIndex;
break;
}
}
for (AttributeIndex = 0; AttributeIndex < ARRAY_SIZE (StopBitsList); AttributeIndex++) {
- if (NewTerminalContext->StopBits == (UINT64) (StopBitsList[AttributeIndex].Value)) {
+ if (NewTerminalContext->StopBits == (UINT64)(StopBitsList[AttributeIndex].Value)) {
NewTerminalContext->StopBitsIndex = AttributeIndex;
break;
}
}
+
CurrentFakeNVMap->COMBaudRate[TerminalIndex] = NewTerminalContext->BaudRateIndex;
CurrentFakeNVMap->COMDataRate[TerminalIndex] = NewTerminalContext->DataBitsIndex;
CurrentFakeNVMap->COMStopBits[TerminalIndex] = NewTerminalContext->StopBitsIndex;
@@ -1163,4 +1181,3 @@ GetTerminalAttribute ( CurrentFakeNVMap->COMFlowControl[TerminalIndex] = NewTerminalContext->FlowControl;
}
}
-
diff --git a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/Data.c b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/Data.c index 21c4ef3d55..ba2f05808c 100644 --- a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/Data.c +++ b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/Data.c @@ -9,34 +9,34 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include "BootMaintenanceManager.h"
VOID *mStartOpCodeHandle = NULL;
-VOID *mEndOpCodeHandle = NULL;
-EFI_IFR_GUID_LABEL *mStartLabel = NULL;
-EFI_IFR_GUID_LABEL *mEndLabel = NULL;
+VOID *mEndOpCodeHandle = NULL;
+EFI_IFR_GUID_LABEL *mStartLabel = NULL;
+EFI_IFR_GUID_LABEL *mEndLabel = NULL;
///
/// Terminal type string token storage
///
-UINT16 TerminalType[9] = {
- STRING_TOKEN(STR_COM_TYPE_0),
- STRING_TOKEN(STR_COM_TYPE_1),
- STRING_TOKEN(STR_COM_TYPE_2),
- STRING_TOKEN(STR_COM_TYPE_3),
- STRING_TOKEN(STR_COM_TYPE_4),
- STRING_TOKEN(STR_COM_TYPE_5),
- STRING_TOKEN(STR_COM_TYPE_6),
- STRING_TOKEN(STR_COM_TYPE_7),
- STRING_TOKEN(STR_COM_TYPE_8),
+UINT16 TerminalType[9] = {
+ STRING_TOKEN (STR_COM_TYPE_0),
+ STRING_TOKEN (STR_COM_TYPE_1),
+ STRING_TOKEN (STR_COM_TYPE_2),
+ STRING_TOKEN (STR_COM_TYPE_3),
+ STRING_TOKEN (STR_COM_TYPE_4),
+ STRING_TOKEN (STR_COM_TYPE_5),
+ STRING_TOKEN (STR_COM_TYPE_6),
+ STRING_TOKEN (STR_COM_TYPE_7),
+ STRING_TOKEN (STR_COM_TYPE_8),
};
///
/// Flow Control type string token storage
///
-UINT16 mFlowControlType[2] = {
- STRING_TOKEN(STR_NONE_FLOW_CONTROL),
- STRING_TOKEN(STR_HARDWARE_FLOW_CONTROL)
+UINT16 mFlowControlType[2] = {
+ STRING_TOKEN (STR_NONE_FLOW_CONTROL),
+ STRING_TOKEN (STR_HARDWARE_FLOW_CONTROL)
};
-UINT32 mFlowControlValue[2] = {
+UINT32 mFlowControlValue[2] = {
0,
UART_FLOW_CONTROL_HARDWARE
};
@@ -44,215 +44,215 @@ UINT32 mFlowControlValue[2] = { ///
/// Console Input Device Selection Menu
///
-BM_MENU_OPTION ConsoleInpMenu = {
+BM_MENU_OPTION ConsoleInpMenu = {
BM_MENU_OPTION_SIGNATURE,
- {NULL},
+ { NULL },
0
};
///
/// Console Output Device Selection Menu
///
-BM_MENU_OPTION ConsoleOutMenu = {
+BM_MENU_OPTION ConsoleOutMenu = {
BM_MENU_OPTION_SIGNATURE,
- {NULL},
+ { NULL },
0
};
///
/// Error Output Device Selection Menu
///
-BM_MENU_OPTION ConsoleErrMenu = {
+BM_MENU_OPTION ConsoleErrMenu = {
BM_MENU_OPTION_SIGNATURE,
- {NULL},
+ { NULL },
0
};
///
/// Boot Option from variable Menu
///
-BM_MENU_OPTION BootOptionMenu = {
+BM_MENU_OPTION BootOptionMenu = {
BM_MENU_OPTION_SIGNATURE,
- {NULL},
+ { NULL },
0
};
///
/// Driver Option from variable menu
///
-BM_MENU_OPTION DriverOptionMenu = {
+BM_MENU_OPTION DriverOptionMenu = {
BM_MENU_OPTION_SIGNATURE,
- {NULL},
+ { NULL },
0
};
///
/// Handles in current system selection menu
///
-BM_MENU_OPTION DriverMenu = {
+BM_MENU_OPTION DriverMenu = {
BM_MENU_OPTION_SIGNATURE,
- {NULL},
+ { NULL },
0
};
-BM_MENU_OPTION TerminalMenu = {
+BM_MENU_OPTION TerminalMenu = {
BM_MENU_OPTION_SIGNATURE,
- {NULL},
+ { NULL },
0
};
///
/// Value and string token correspondency for BaudRate
///
-COM_ATTR BaudRateList[19] = {
+COM_ATTR BaudRateList[19] = {
{
115200,
- STRING_TOKEN(STR_COM_BAUD_RATE_0)
+ STRING_TOKEN (STR_COM_BAUD_RATE_0)
},
{
57600,
- STRING_TOKEN(STR_COM_BAUD_RATE_1)
+ STRING_TOKEN (STR_COM_BAUD_RATE_1)
},
{
38400,
- STRING_TOKEN(STR_COM_BAUD_RATE_2)
+ STRING_TOKEN (STR_COM_BAUD_RATE_2)
},
{
19200,
- STRING_TOKEN(STR_COM_BAUD_RATE_3)
+ STRING_TOKEN (STR_COM_BAUD_RATE_3)
},
{
9600,
- STRING_TOKEN(STR_COM_BAUD_RATE_4)
+ STRING_TOKEN (STR_COM_BAUD_RATE_4)
},
{
7200,
- STRING_TOKEN(STR_COM_BAUD_RATE_5)
+ STRING_TOKEN (STR_COM_BAUD_RATE_5)
},
{
4800,
- STRING_TOKEN(STR_COM_BAUD_RATE_6)
+ STRING_TOKEN (STR_COM_BAUD_RATE_6)
},
{
3600,
- STRING_TOKEN(STR_COM_BAUD_RATE_7)
+ STRING_TOKEN (STR_COM_BAUD_RATE_7)
},
{
2400,
- STRING_TOKEN(STR_COM_BAUD_RATE_8)
+ STRING_TOKEN (STR_COM_BAUD_RATE_8)
},
{
2000,
- STRING_TOKEN(STR_COM_BAUD_RATE_9)
+ STRING_TOKEN (STR_COM_BAUD_RATE_9)
},
{
1800,
- STRING_TOKEN(STR_COM_BAUD_RATE_10)
+ STRING_TOKEN (STR_COM_BAUD_RATE_10)
},
{
1200,
- STRING_TOKEN(STR_COM_BAUD_RATE_11)
+ STRING_TOKEN (STR_COM_BAUD_RATE_11)
},
{
600,
- STRING_TOKEN(STR_COM_BAUD_RATE_12)
+ STRING_TOKEN (STR_COM_BAUD_RATE_12)
},
{
300,
- STRING_TOKEN(STR_COM_BAUD_RATE_13)
+ STRING_TOKEN (STR_COM_BAUD_RATE_13)
},
{
150,
- STRING_TOKEN(STR_COM_BAUD_RATE_14)
+ STRING_TOKEN (STR_COM_BAUD_RATE_14)
},
{
134,
- STRING_TOKEN(STR_COM_BAUD_RATE_15)
+ STRING_TOKEN (STR_COM_BAUD_RATE_15)
},
{
110,
- STRING_TOKEN(STR_COM_BAUD_RATE_16)
+ STRING_TOKEN (STR_COM_BAUD_RATE_16)
},
{
75,
- STRING_TOKEN(STR_COM_BAUD_RATE_17)
+ STRING_TOKEN (STR_COM_BAUD_RATE_17)
},
{
50,
- STRING_TOKEN(STR_COM_BAUD_RATE_18)
+ STRING_TOKEN (STR_COM_BAUD_RATE_18)
}
};
///
/// Value and string token correspondency for DataBits
///
-COM_ATTR DataBitsList[4] = {
+COM_ATTR DataBitsList[4] = {
{
5,
- STRING_TOKEN(STR_COM_DATA_BITS_0)
+ STRING_TOKEN (STR_COM_DATA_BITS_0)
},
{
6,
- STRING_TOKEN(STR_COM_DATA_BITS_1)
+ STRING_TOKEN (STR_COM_DATA_BITS_1)
},
{
7,
- STRING_TOKEN(STR_COM_DATA_BITS_2)
+ STRING_TOKEN (STR_COM_DATA_BITS_2)
},
{
8,
- STRING_TOKEN(STR_COM_DATA_BITS_3)
+ STRING_TOKEN (STR_COM_DATA_BITS_3)
}
};
///
/// Value and string token correspondency for Parity
///
-COM_ATTR ParityList[5] = {
+COM_ATTR ParityList[5] = {
{
NoParity,
- STRING_TOKEN(STR_COM_PAR_0)
+ STRING_TOKEN (STR_COM_PAR_0)
},
{
EvenParity,
- STRING_TOKEN(STR_COM_PAR_1)
+ STRING_TOKEN (STR_COM_PAR_1)
},
{
OddParity,
- STRING_TOKEN(STR_COM_PAR_2)
+ STRING_TOKEN (STR_COM_PAR_2)
},
{
MarkParity,
- STRING_TOKEN(STR_COM_PAR_3)
+ STRING_TOKEN (STR_COM_PAR_3)
},
{
SpaceParity,
- STRING_TOKEN(STR_COM_PAR_4)
+ STRING_TOKEN (STR_COM_PAR_4)
}
};
///
/// Value and string token correspondency for Baudreate
///
-COM_ATTR StopBitsList[3] = {
+COM_ATTR StopBitsList[3] = {
{
OneStopBit,
- STRING_TOKEN(STR_COM_STOP_BITS_0)
+ STRING_TOKEN (STR_COM_STOP_BITS_0)
},
{
OneFiveStopBits,
- STRING_TOKEN(STR_COM_STOP_BITS_1)
+ STRING_TOKEN (STR_COM_STOP_BITS_1)
},
{
TwoStopBits,
- STRING_TOKEN(STR_COM_STOP_BITS_2)
+ STRING_TOKEN (STR_COM_STOP_BITS_2)
}
};
///
/// Guid for messaging path, used in Serial port setting.
///
-EFI_GUID TerminalTypeGuid[9] = {
+EFI_GUID TerminalTypeGuid[9] = {
DEVICE_PATH_MESSAGING_PC_ANSI,
DEVICE_PATH_MESSAGING_VT_100,
DEVICE_PATH_MESSAGING_VT_100_PLUS,
diff --git a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/FormGuid.h b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/FormGuid.h index 3031242923..2bf233423d 100644 --- a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/FormGuid.h +++ b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/FormGuid.h @@ -5,6 +5,7 @@ Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR> SPDX-License-Identifier: BSD-2-Clause-Patent
**/
+
#ifndef _FORM_GUID_H_
#define _FORM_GUID_H_
@@ -41,50 +42,48 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #define FORM_CON_MODE_ID 0x1021
#define FORM_BOOT_FROM_FILE_ID 0x1024
-
-#define MAXIMUM_FORM_ID 0x10FF
-
-#define KEY_VALUE_COM_SET_BAUD_RATE 0x1101
-#define KEY_VALUE_COM_SET_DATA_BITS 0x1102
-#define KEY_VALUE_COM_SET_STOP_BITS 0x1103
-#define KEY_VALUE_COM_SET_PARITY 0x1104
-#define KEY_VALUE_COM_SET_TERMI_TYPE 0x1105
-#define KEY_VALUE_MAIN_BOOT_NEXT 0x1106
-#define KEY_VALUE_BOOT_ADD_DESC_DATA 0x1107
-#define KEY_VALUE_BOOT_ADD_OPT_DATA 0x1108
-#define KEY_VALUE_DRIVER_ADD_DESC_DATA 0x1109
-#define KEY_VALUE_DRIVER_ADD_OPT_DATA 0x110A
-#define KEY_VALUE_SAVE_AND_EXIT 0x110B
-#define KEY_VALUE_NO_SAVE_AND_EXIT 0x110C
-#define KEY_VALUE_BOOT_FROM_FILE 0x110D
-#define FORM_RESET 0x110E
-#define KEY_VALUE_BOOT_DESCRIPTION 0x110F
-#define KEY_VALUE_BOOT_OPTION 0x1110
-#define KEY_VALUE_DRIVER_DESCRIPTION 0x1111
-#define KEY_VALUE_DRIVER_OPTION 0x1112
-#define KEY_VALUE_SAVE_AND_EXIT_BOOT 0x1113
-#define KEY_VALUE_NO_SAVE_AND_EXIT_BOOT 0x1114
-#define KEY_VALUE_SAVE_AND_EXIT_DRIVER 0x1115
-#define KEY_VALUE_NO_SAVE_AND_EXIT_DRIVER 0x1116
-#define KEY_VALUE_TRIGGER_FORM_OPEN_ACTION 0x1117
-
-#define MAXIMUM_NORMAL_KEY_VALUE 0x11FF
+#define MAXIMUM_FORM_ID 0x10FF
+
+#define KEY_VALUE_COM_SET_BAUD_RATE 0x1101
+#define KEY_VALUE_COM_SET_DATA_BITS 0x1102
+#define KEY_VALUE_COM_SET_STOP_BITS 0x1103
+#define KEY_VALUE_COM_SET_PARITY 0x1104
+#define KEY_VALUE_COM_SET_TERMI_TYPE 0x1105
+#define KEY_VALUE_MAIN_BOOT_NEXT 0x1106
+#define KEY_VALUE_BOOT_ADD_DESC_DATA 0x1107
+#define KEY_VALUE_BOOT_ADD_OPT_DATA 0x1108
+#define KEY_VALUE_DRIVER_ADD_DESC_DATA 0x1109
+#define KEY_VALUE_DRIVER_ADD_OPT_DATA 0x110A
+#define KEY_VALUE_SAVE_AND_EXIT 0x110B
+#define KEY_VALUE_NO_SAVE_AND_EXIT 0x110C
+#define KEY_VALUE_BOOT_FROM_FILE 0x110D
+#define FORM_RESET 0x110E
+#define KEY_VALUE_BOOT_DESCRIPTION 0x110F
+#define KEY_VALUE_BOOT_OPTION 0x1110
+#define KEY_VALUE_DRIVER_DESCRIPTION 0x1111
+#define KEY_VALUE_DRIVER_OPTION 0x1112
+#define KEY_VALUE_SAVE_AND_EXIT_BOOT 0x1113
+#define KEY_VALUE_NO_SAVE_AND_EXIT_BOOT 0x1114
+#define KEY_VALUE_SAVE_AND_EXIT_DRIVER 0x1115
+#define KEY_VALUE_NO_SAVE_AND_EXIT_DRIVER 0x1116
+#define KEY_VALUE_TRIGGER_FORM_OPEN_ACTION 0x1117
+
+#define MAXIMUM_NORMAL_KEY_VALUE 0x11FF
//
// Varstore ID defined for Buffer Storage
//
-#define VARSTORE_ID_BOOT_MAINT 0x1000
+#define VARSTORE_ID_BOOT_MAINT 0x1000
//
// End Label
//
-#define LABEL_FORM_MAIN_START 0xfffc
-#define LABEL_FORM_MAIN_END 0xfffd
-
-#define LABEL_BMM_PLATFORM_INFORMATION 0xfffe
-#define LABEL_END 0xffff
-#define MAX_MENU_NUMBER 100
+#define LABEL_FORM_MAIN_START 0xfffc
+#define LABEL_FORM_MAIN_END 0xfffd
+#define LABEL_BMM_PLATFORM_INFORMATION 0xfffe
+#define LABEL_END 0xffff
+#define MAX_MENU_NUMBER 100
///
/// This is the structure that will be used to store the
@@ -99,81 +98,81 @@ typedef struct { // Three questions displayed at the main page
// for Timeout, BootNext, Variables respectively
//
- UINT16 BootTimeOut;
- UINT32 BootNext;
+ UINT16 BootTimeOut;
+ UINT32 BootNext;
//
// This is the COM1 Attributes value storage
//
- UINT8 COM1BaudRate;
- UINT8 COM1DataRate;
- UINT8 COM1StopBits;
- UINT8 COM1Parity;
- UINT8 COM1TerminalType;
+ UINT8 COM1BaudRate;
+ UINT8 COM1DataRate;
+ UINT8 COM1StopBits;
+ UINT8 COM1Parity;
+ UINT8 COM1TerminalType;
//
// This is the COM2 Attributes value storage
//
- UINT8 COM2BaudRate;
- UINT8 COM2DataRate;
- UINT8 COM2StopBits;
- UINT8 COM2Parity;
- UINT8 COM2TerminalType;
+ UINT8 COM2BaudRate;
+ UINT8 COM2DataRate;
+ UINT8 COM2StopBits;
+ UINT8 COM2Parity;
+ UINT8 COM2TerminalType;
//
// Driver Option Add Handle page storage
//
- UINT16 DriverAddHandleDesc[MAX_MENU_NUMBER];
- UINT16 DriverAddHandleOptionalData[MAX_MENU_NUMBER];
- UINT8 DriverAddActive;
- UINT8 DriverAddForceReconnect;
+ UINT16 DriverAddHandleDesc[MAX_MENU_NUMBER];
+ UINT16 DriverAddHandleOptionalData[MAX_MENU_NUMBER];
+ UINT8 DriverAddActive;
+ UINT8 DriverAddForceReconnect;
//
// Console Input/Output/Errorout using COM port check storage
//
- UINT8 ConsoleInputCOM1;
- UINT8 ConsoleInputCOM2;
- UINT8 ConsoleOutputCOM1;
- UINT8 ConsoleOutputCOM2;
- UINT8 ConsoleErrorCOM1;
- UINT8 ConsoleErrorCOM2;
+ UINT8 ConsoleInputCOM1;
+ UINT8 ConsoleInputCOM2;
+ UINT8 ConsoleOutputCOM1;
+ UINT8 ConsoleOutputCOM2;
+ UINT8 ConsoleErrorCOM1;
+ UINT8 ConsoleErrorCOM2;
//
// At most 100 input/output/errorout device for console storage
//
- UINT8 ConsoleCheck[MAX_MENU_NUMBER];
+ UINT8 ConsoleCheck[MAX_MENU_NUMBER];
//
// At most 100 input/output/errorout device for console storage
//
- UINT8 ConsoleInCheck[MAX_MENU_NUMBER];
- UINT8 ConsoleOutCheck[MAX_MENU_NUMBER];
- UINT8 ConsoleErrCheck[MAX_MENU_NUMBER];
+ UINT8 ConsoleInCheck[MAX_MENU_NUMBER];
+ UINT8 ConsoleOutCheck[MAX_MENU_NUMBER];
+ UINT8 ConsoleErrCheck[MAX_MENU_NUMBER];
//
// Boot or Driver Option Order storage
// The value is the OptionNumber+1 because the order list value cannot be 0
// Use UINT32 to hold the potential value 0xFFFF+1=0x10000
//
- UINT32 BootOptionOrder[MAX_MENU_NUMBER];
- UINT32 DriverOptionOrder[MAX_MENU_NUMBER];
+ UINT32 BootOptionOrder[MAX_MENU_NUMBER];
+ UINT32 DriverOptionOrder[MAX_MENU_NUMBER];
//
// Boot or Driver Option Delete storage
//
- BOOLEAN BootOptionDel[MAX_MENU_NUMBER];
- BOOLEAN DriverOptionDel[MAX_MENU_NUMBER];
- BOOLEAN BootOptionDelMark[MAX_MENU_NUMBER];
- BOOLEAN DriverOptionDelMark[MAX_MENU_NUMBER];
+ BOOLEAN BootOptionDel[MAX_MENU_NUMBER];
+ BOOLEAN DriverOptionDel[MAX_MENU_NUMBER];
+ BOOLEAN BootOptionDelMark[MAX_MENU_NUMBER];
+ BOOLEAN DriverOptionDelMark[MAX_MENU_NUMBER];
//
// This is the Terminal Attributes value storage
//
- UINT8 COMBaudRate[MAX_MENU_NUMBER];
- UINT8 COMDataRate[MAX_MENU_NUMBER];
- UINT8 COMStopBits[MAX_MENU_NUMBER];
- UINT8 COMParity[MAX_MENU_NUMBER];
- UINT8 COMTerminalType[MAX_MENU_NUMBER];
- UINT8 COMFlowControl[MAX_MENU_NUMBER];
+ UINT8 COMBaudRate[MAX_MENU_NUMBER];
+ UINT8 COMDataRate[MAX_MENU_NUMBER];
+ UINT8 COMStopBits[MAX_MENU_NUMBER];
+ UINT8 COMParity[MAX_MENU_NUMBER];
+ UINT8 COMTerminalType[MAX_MENU_NUMBER];
+ UINT8 COMFlowControl[MAX_MENU_NUMBER];
//
// We use DisableMap array to record the enable/disable state of each boot device
@@ -181,26 +180,25 @@ typedef struct { // the most left one stands for BBS table item 0, and the most right one stands for item 256
// If the bit is 1, it means the boot device has been disabled.
//
- UINT8 DisableMap[32];
+ UINT8 DisableMap[32];
//
// Console Output Text Mode
//
- UINT16 ConsoleOutMode;
+ UINT16 ConsoleOutMode;
//
// UINT16 PadArea[10];
//
- UINT16 BootDescriptionData[MAX_MENU_NUMBER];
- UINT16 BootOptionalData[127];
- UINT16 DriverDescriptionData[MAX_MENU_NUMBER];
- UINT16 DriverOptionalData[127];
- BOOLEAN BootOptionChanged;
- BOOLEAN DriverOptionChanged;
- UINT8 Active;
- UINT8 ForceReconnect;
+ UINT16 BootDescriptionData[MAX_MENU_NUMBER];
+ UINT16 BootOptionalData[127];
+ UINT16 DriverDescriptionData[MAX_MENU_NUMBER];
+ UINT16 DriverOptionalData[127];
+ BOOLEAN BootOptionChanged;
+ BOOLEAN DriverOptionChanged;
+ UINT8 Active;
+ UINT8 ForceReconnect;
} BMM_FAKE_NV_DATA;
#endif
-
diff --git a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/UpdatePage.c b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/UpdatePage.c index e2b444cc45..ca81b7f352 100644 --- a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/UpdatePage.c +++ b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/UpdatePage.c @@ -29,13 +29,13 @@ CreateUpdateData ( //
// Create Hii Extend Label OpCode as the start opcode
//
- mStartLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (mStartOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));
+ mStartLabel = (EFI_IFR_GUID_LABEL *)HiiCreateGuidOpCode (mStartOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));
mStartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;
//
// Create Hii Extend Label OpCode as the end opcode
//
- mEndLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (mEndOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));
+ mEndLabel = (EFI_IFR_GUID_LABEL *)HiiCreateGuidOpCode (mEndOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));
mEndLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;
mEndLabel->Number = LABEL_END;
}
@@ -64,9 +64,8 @@ RefreshUpdateData ( //
// Create Hii Extend Label OpCode as the start opcode
//
- mStartLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (mStartOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));
+ mStartLabel = (EFI_IFR_GUID_LABEL *)HiiCreateGuidOpCode (mStartOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));
mStartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;
-
}
/**
@@ -78,7 +77,7 @@ RefreshUpdateData ( **/
VOID
UpdatePageStart (
- IN BMM_CALLBACK_DATA *CallbackData
+ IN BMM_CALLBACK_DATA *CallbackData
)
{
RefreshUpdateData ();
@@ -109,7 +108,7 @@ UpdatePageStart ( **/
VOID
UpdatePageEnd (
- IN BMM_CALLBACK_DATA *CallbackData
+ IN BMM_CALLBACK_DATA *CallbackData
)
{
//
@@ -164,8 +163,8 @@ UpdatePageEnd ( **/
VOID
CleanUpPage (
- IN UINT16 LabelId,
- IN BMM_CALLBACK_DATA *CallbackData
+ IN UINT16 LabelId,
+ IN BMM_CALLBACK_DATA *CallbackData
)
{
RefreshUpdateData ();
@@ -191,11 +190,11 @@ CleanUpPage ( **/
VOID
UpdateConCOMPage (
- IN BMM_CALLBACK_DATA *CallbackData
+ IN BMM_CALLBACK_DATA *CallbackData
)
{
- BM_MENU_ENTRY *NewMenuEntry;
- UINT16 Index;
+ BM_MENU_ENTRY *NewMenuEntry;
+ UINT16 Index;
CallbackData->BmmAskSaveOrNot = TRUE;
@@ -210,14 +209,13 @@ UpdateConCOMPage ( NewMenuEntry->DisplayStringToken,
STRING_TOKEN (STR_NULL_STRING),
EFI_IFR_FLAG_CALLBACK,
- (UINT16) (TERMINAL_OPTION_OFFSET + Index)
+ (UINT16)(TERMINAL_OPTION_OFFSET + Index)
);
}
UpdatePageEnd (CallbackData);
}
-
/**
Create a list of boot option from global BootOptionMenu. It
allow user to delete the boot option.
@@ -227,12 +225,12 @@ UpdateConCOMPage ( **/
VOID
UpdateBootDelPage (
- IN BMM_CALLBACK_DATA *CallbackData
+ IN BMM_CALLBACK_DATA *CallbackData
)
{
- BM_MENU_ENTRY *NewMenuEntry;
- BM_LOAD_CONTEXT *NewLoadContext;
- UINT16 Index;
+ BM_MENU_ENTRY *NewMenuEntry;
+ BM_LOAD_CONTEXT *NewLoadContext;
+ UINT16 Index;
CallbackData->BmmAskSaveOrNot = TRUE;
@@ -240,8 +238,8 @@ UpdateBootDelPage ( ASSERT (BootOptionMenu.MenuNumber <= (sizeof (CallbackData->BmmFakeNvData.BootOptionDel) / sizeof (CallbackData->BmmFakeNvData.BootOptionDel[0])));
for (Index = 0; Index < BootOptionMenu.MenuNumber; Index++) {
- NewMenuEntry = BOpt_GetMenuEntry (&BootOptionMenu, Index);
- NewLoadContext = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext;
+ NewMenuEntry = BOpt_GetMenuEntry (&BootOptionMenu, Index);
+ NewLoadContext = (BM_LOAD_CONTEXT *)NewMenuEntry->VariableContext;
if (NewLoadContext->IsLegacy) {
continue;
}
@@ -255,15 +253,15 @@ UpdateBootDelPage ( // deleted, browser maintains old useless info. So clear this info here, and later update this info to browser
// through HiiSetBrowserData function.
//
- CallbackData->BmmFakeNvData.BootOptionDel[Index] = FALSE;
+ CallbackData->BmmFakeNvData.BootOptionDel[Index] = FALSE;
CallbackData->BmmOldFakeNVData.BootOptionDel[Index] = FALSE;
}
HiiCreateCheckBoxOpCode (
mStartOpCodeHandle,
- (EFI_QUESTION_ID) (BOOT_OPTION_DEL_QUESTION_ID + Index),
+ (EFI_QUESTION_ID)(BOOT_OPTION_DEL_QUESTION_ID + Index),
VARSTORE_ID_BOOT_MAINT,
- (UINT16) (BOOT_OPTION_DEL_VAR_OFFSET + Index),
+ (UINT16)(BOOT_OPTION_DEL_VAR_OFFSET + Index),
NewMenuEntry->DisplayStringToken,
NewMenuEntry->HelpStringToken,
EFI_IFR_FLAG_CALLBACK,
@@ -271,6 +269,7 @@ UpdateBootDelPage ( NULL
);
}
+
UpdatePageEnd (CallbackData);
}
@@ -282,11 +281,11 @@ UpdateBootDelPage ( **/
VOID
UpdateDrvAddHandlePage (
- IN BMM_CALLBACK_DATA *CallbackData
+ IN BMM_CALLBACK_DATA *CallbackData
)
{
- BM_MENU_ENTRY *NewMenuEntry;
- UINT16 Index;
+ BM_MENU_ENTRY *NewMenuEntry;
+ UINT16 Index;
CallbackData->BmmAskSaveOrNot = FALSE;
@@ -301,7 +300,7 @@ UpdateDrvAddHandlePage ( NewMenuEntry->DisplayStringToken,
STRING_TOKEN (STR_NULL_STRING),
EFI_IFR_FLAG_CALLBACK,
- (UINT16) (HANDLE_OPTION_OFFSET + Index)
+ (UINT16)(HANDLE_OPTION_OFFSET + Index)
);
}
@@ -317,12 +316,12 @@ UpdateDrvAddHandlePage ( **/
VOID
UpdateDrvDelPage (
- IN BMM_CALLBACK_DATA *CallbackData
+ IN BMM_CALLBACK_DATA *CallbackData
)
{
- BM_MENU_ENTRY *NewMenuEntry;
- BM_LOAD_CONTEXT *NewLoadContext;
- UINT16 Index;
+ BM_MENU_ENTRY *NewMenuEntry;
+ BM_LOAD_CONTEXT *NewLoadContext;
+ UINT16 Index;
CallbackData->BmmAskSaveOrNot = TRUE;
@@ -330,9 +329,9 @@ UpdateDrvDelPage ( ASSERT (DriverOptionMenu.MenuNumber <= (sizeof (CallbackData->BmmFakeNvData.DriverOptionDel) / sizeof (CallbackData->BmmFakeNvData.DriverOptionDel[0])));
for (Index = 0; Index < DriverOptionMenu.MenuNumber; Index++) {
- NewMenuEntry = BOpt_GetMenuEntry (&DriverOptionMenu, Index);
+ NewMenuEntry = BOpt_GetMenuEntry (&DriverOptionMenu, Index);
- NewLoadContext = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext;
+ NewLoadContext = (BM_LOAD_CONTEXT *)NewMenuEntry->VariableContext;
NewLoadContext->Deleted = FALSE;
if (CallbackData->BmmFakeNvData.DriverOptionDel[Index] && !CallbackData->BmmFakeNvData.DriverOptionDelMark[Index]) {
@@ -342,14 +341,15 @@ UpdateDrvDelPage ( // deleted, browser maintains old useless info. So clear this info here, and later update this info to browser
// through HiiSetBrowserData function.
//
- CallbackData->BmmFakeNvData.DriverOptionDel[Index] = FALSE;
+ CallbackData->BmmFakeNvData.DriverOptionDel[Index] = FALSE;
CallbackData->BmmOldFakeNVData.DriverOptionDel[Index] = FALSE;
}
+
HiiCreateCheckBoxOpCode (
mStartOpCodeHandle,
- (EFI_QUESTION_ID) (DRIVER_OPTION_DEL_QUESTION_ID + Index),
+ (EFI_QUESTION_ID)(DRIVER_OPTION_DEL_QUESTION_ID + Index),
VARSTORE_ID_BOOT_MAINT,
- (UINT16) (DRIVER_OPTION_DEL_VAR_OFFSET + Index),
+ (UINT16)(DRIVER_OPTION_DEL_VAR_OFFSET + Index),
NewMenuEntry->DisplayStringToken,
NewMenuEntry->HelpStringToken,
EFI_IFR_FLAG_CALLBACK,
@@ -370,15 +370,15 @@ UpdateDrvDelPage ( **/
VOID
UpdateDriverAddHandleDescPage (
- IN BMM_CALLBACK_DATA *CallbackData
+ IN BMM_CALLBACK_DATA *CallbackData
)
{
- BM_MENU_ENTRY *NewMenuEntry;
+ BM_MENU_ENTRY *NewMenuEntry;
- CallbackData->BmmFakeNvData.DriverAddActive = 0x01;
- CallbackData->BmmFakeNvData.DriverAddForceReconnect = 0x00;
- CallbackData->BmmAskSaveOrNot = TRUE;
- NewMenuEntry = CallbackData->MenuEntry;
+ CallbackData->BmmFakeNvData.DriverAddActive = 0x01;
+ CallbackData->BmmFakeNvData.DriverAddForceReconnect = 0x00;
+ CallbackData->BmmAskSaveOrNot = TRUE;
+ NewMenuEntry = CallbackData->MenuEntry;
UpdatePageStart (CallbackData);
@@ -392,7 +392,7 @@ UpdateDriverAddHandleDescPage ( HiiCreateStringOpCode (
mStartOpCodeHandle,
- (EFI_QUESTION_ID) DRV_ADD_HANDLE_DESC_QUESTION_ID,
+ (EFI_QUESTION_ID)DRV_ADD_HANDLE_DESC_QUESTION_ID,
VARSTORE_ID_BOOT_MAINT,
DRV_ADD_HANDLE_DESC_VAR_OFFSET,
STRING_TOKEN (STR_LOAD_OPTION_DESC),
@@ -406,7 +406,7 @@ UpdateDriverAddHandleDescPage ( HiiCreateCheckBoxOpCode (
mStartOpCodeHandle,
- (EFI_QUESTION_ID) DRV_ADD_RECON_QUESTION_ID,
+ (EFI_QUESTION_ID)DRV_ADD_RECON_QUESTION_ID,
VARSTORE_ID_BOOT_MAINT,
DRV_ADD_RECON_VAR_OFFSET,
STRING_TOKEN (STR_LOAD_OPTION_FORCE_RECON),
@@ -418,7 +418,7 @@ UpdateDriverAddHandleDescPage ( HiiCreateStringOpCode (
mStartOpCodeHandle,
- (EFI_QUESTION_ID) DRIVER_ADD_OPTION_QUESTION_ID,
+ (EFI_QUESTION_ID)DRIVER_ADD_OPTION_QUESTION_ID,
VARSTORE_ID_BOOT_MAINT,
DRIVER_ADD_OPTION_VAR_OFFSET,
STRING_TOKEN (STR_OPTIONAL_DATA),
@@ -443,20 +443,20 @@ UpdateDriverAddHandleDescPage ( **/
VOID
UpdateConsolePage (
- IN UINT16 UpdatePageId,
- IN BM_MENU_OPTION *ConsoleMenu,
- IN BMM_CALLBACK_DATA *CallbackData
+ IN UINT16 UpdatePageId,
+ IN BM_MENU_OPTION *ConsoleMenu,
+ IN BMM_CALLBACK_DATA *CallbackData
)
{
- BM_MENU_ENTRY *NewMenuEntry;
- BM_CONSOLE_CONTEXT *NewConsoleContext;
- BM_TERMINAL_CONTEXT *NewTerminalContext;
- UINT16 Index;
- UINT16 Index2;
- UINT8 CheckFlags;
- UINT8 *ConsoleCheck;
- EFI_QUESTION_ID QuestionIdBase;
- UINT16 VariableOffsetBase;
+ BM_MENU_ENTRY *NewMenuEntry;
+ BM_CONSOLE_CONTEXT *NewConsoleContext;
+ BM_TERMINAL_CONTEXT *NewTerminalContext;
+ UINT16 Index;
+ UINT16 Index2;
+ UINT8 CheckFlags;
+ UINT8 *ConsoleCheck;
+ EFI_QUESTION_ID QuestionIdBase;
+ UINT16 VariableOffsetBase;
CallbackData->BmmAskSaveOrNot = TRUE;
@@ -467,42 +467,45 @@ UpdateConsolePage ( VariableOffsetBase = 0;
switch (UpdatePageId) {
- case FORM_CON_IN_ID:
- ConsoleCheck = &CallbackData->BmmFakeNvData.ConsoleInCheck[0];
- QuestionIdBase = CON_IN_DEVICE_QUESTION_ID;
- VariableOffsetBase = CON_IN_DEVICE_VAR_OFFSET;
- break;
-
- case FORM_CON_OUT_ID:
- ConsoleCheck = &CallbackData->BmmFakeNvData.ConsoleOutCheck[0];
- QuestionIdBase = CON_OUT_DEVICE_QUESTION_ID;
- VariableOffsetBase = CON_OUT_DEVICE_VAR_OFFSET;
- break;
-
- case FORM_CON_ERR_ID:
- ConsoleCheck = &CallbackData->BmmFakeNvData.ConsoleErrCheck[0];
- QuestionIdBase = CON_ERR_DEVICE_QUESTION_ID;
- VariableOffsetBase = CON_ERR_DEVICE_VAR_OFFSET;
- break;
+ case FORM_CON_IN_ID:
+ ConsoleCheck = &CallbackData->BmmFakeNvData.ConsoleInCheck[0];
+ QuestionIdBase = CON_IN_DEVICE_QUESTION_ID;
+ VariableOffsetBase = CON_IN_DEVICE_VAR_OFFSET;
+ break;
+
+ case FORM_CON_OUT_ID:
+ ConsoleCheck = &CallbackData->BmmFakeNvData.ConsoleOutCheck[0];
+ QuestionIdBase = CON_OUT_DEVICE_QUESTION_ID;
+ VariableOffsetBase = CON_OUT_DEVICE_VAR_OFFSET;
+ break;
+
+ case FORM_CON_ERR_ID:
+ ConsoleCheck = &CallbackData->BmmFakeNvData.ConsoleErrCheck[0];
+ QuestionIdBase = CON_ERR_DEVICE_QUESTION_ID;
+ VariableOffsetBase = CON_ERR_DEVICE_VAR_OFFSET;
+ break;
}
+
ASSERT (ConsoleCheck != NULL);
for (Index = 0; ((Index < ConsoleMenu->MenuNumber) && \
- (Index < MAX_MENU_NUMBER)) ; Index++) {
- CheckFlags = 0;
- NewMenuEntry = BOpt_GetMenuEntry (ConsoleMenu, Index);
- NewConsoleContext = (BM_CONSOLE_CONTEXT *) NewMenuEntry->VariableContext;
+ (Index < MAX_MENU_NUMBER)); Index++)
+ {
+ CheckFlags = 0;
+ NewMenuEntry = BOpt_GetMenuEntry (ConsoleMenu, Index);
+ NewConsoleContext = (BM_CONSOLE_CONTEXT *)NewMenuEntry->VariableContext;
if (NewConsoleContext->IsActive) {
- CheckFlags |= EFI_IFR_CHECKBOX_DEFAULT;
+ CheckFlags |= EFI_IFR_CHECKBOX_DEFAULT;
ConsoleCheck[Index] = TRUE;
} else {
ConsoleCheck[Index] = FALSE;
}
+
HiiCreateCheckBoxOpCode (
mStartOpCodeHandle,
- (EFI_QUESTION_ID) (QuestionIdBase + Index),
+ (EFI_QUESTION_ID)(QuestionIdBase + Index),
VARSTORE_ID_BOOT_MAINT,
- (UINT16) (VariableOffsetBase + Index),
+ (UINT16)(VariableOffsetBase + Index),
NewMenuEntry->DisplayStringToken,
NewMenuEntry->HelpStringToken,
EFI_IFR_FLAG_CALLBACK,
@@ -512,26 +515,29 @@ UpdateConsolePage ( }
for (Index2 = 0; ((Index2 < TerminalMenu.MenuNumber) && \
- (Index2 < MAX_MENU_NUMBER)); Index2++) {
- CheckFlags = 0;
- NewMenuEntry = BOpt_GetMenuEntry (&TerminalMenu, Index2);
- NewTerminalContext = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext;
+ (Index2 < MAX_MENU_NUMBER)); Index2++)
+ {
+ CheckFlags = 0;
+ NewMenuEntry = BOpt_GetMenuEntry (&TerminalMenu, Index2);
+ NewTerminalContext = (BM_TERMINAL_CONTEXT *)NewMenuEntry->VariableContext;
ASSERT (Index < MAX_MENU_NUMBER);
if (((NewTerminalContext->IsConIn != 0) && (UpdatePageId == FORM_CON_IN_ID)) ||
((NewTerminalContext->IsConOut != 0) && (UpdatePageId == FORM_CON_OUT_ID)) ||
((NewTerminalContext->IsStdErr != 0) && (UpdatePageId == FORM_CON_ERR_ID))
- ) {
- CheckFlags |= EFI_IFR_CHECKBOX_DEFAULT;
+ )
+ {
+ CheckFlags |= EFI_IFR_CHECKBOX_DEFAULT;
ConsoleCheck[Index] = TRUE;
} else {
ConsoleCheck[Index] = FALSE;
}
+
HiiCreateCheckBoxOpCode (
mStartOpCodeHandle,
- (EFI_QUESTION_ID) (QuestionIdBase + Index),
+ (EFI_QUESTION_ID)(QuestionIdBase + Index),
VARSTORE_ID_BOOT_MAINT,
- (UINT16) (VariableOffsetBase + Index),
+ (UINT16)(VariableOffsetBase + Index),
NewMenuEntry->DisplayStringToken,
NewMenuEntry->HelpStringToken,
EFI_IFR_FLAG_CALLBACK,
@@ -556,58 +562,60 @@ UpdateConsolePage ( **/
VOID
UpdateOrderPage (
- IN UINT16 UpdatePageId,
- IN BM_MENU_OPTION *OptionMenu,
- IN BMM_CALLBACK_DATA *CallbackData
+ IN UINT16 UpdatePageId,
+ IN BM_MENU_OPTION *OptionMenu,
+ IN BMM_CALLBACK_DATA *CallbackData
)
{
- BM_MENU_ENTRY *NewMenuEntry;
- UINT16 Index;
- UINT16 OptionIndex;
- VOID *OptionsOpCodeHandle;
- BOOLEAN BootOptionFound;
- UINT32 *OptionOrder;
- EFI_QUESTION_ID QuestionId;
- UINT16 VarOffset;
+ BM_MENU_ENTRY *NewMenuEntry;
+ UINT16 Index;
+ UINT16 OptionIndex;
+ VOID *OptionsOpCodeHandle;
+ BOOLEAN BootOptionFound;
+ UINT32 *OptionOrder;
+ EFI_QUESTION_ID QuestionId;
+ UINT16 VarOffset;
CallbackData->BmmAskSaveOrNot = TRUE;
UpdatePageStart (CallbackData);
OptionOrder = NULL;
- QuestionId = 0;
- VarOffset = 0;
+ QuestionId = 0;
+ VarOffset = 0;
switch (UpdatePageId) {
+ case FORM_BOOT_CHG_ID:
+ //
+ // If the BootOptionOrder in the BmmFakeNvData are same with the date in the BmmOldFakeNVData,
+ // means all Boot Options has been save in BootOptionMenu, we can get the date from the menu.
+ // else means browser maintains some uncommitted date which are not saved in BootOptionMenu,
+ // so we should not get the data from BootOptionMenu to show it.
+ //
+ if (CompareMem (CallbackData->BmmFakeNvData.BootOptionOrder, CallbackData->BmmOldFakeNVData.BootOptionOrder, sizeof (CallbackData->BmmFakeNvData.BootOptionOrder)) == 0) {
+ GetBootOrder (CallbackData);
+ }
- case FORM_BOOT_CHG_ID:
- //
- // If the BootOptionOrder in the BmmFakeNvData are same with the date in the BmmOldFakeNVData,
- // means all Boot Options has been save in BootOptionMenu, we can get the date from the menu.
- // else means browser maintains some uncommitted date which are not saved in BootOptionMenu,
- // so we should not get the data from BootOptionMenu to show it.
- //
- if (CompareMem (CallbackData->BmmFakeNvData.BootOptionOrder, CallbackData->BmmOldFakeNVData.BootOptionOrder, sizeof (CallbackData->BmmFakeNvData.BootOptionOrder)) == 0) {
- GetBootOrder (CallbackData);
- }
- OptionOrder = CallbackData->BmmFakeNvData.BootOptionOrder;
- QuestionId = BOOT_OPTION_ORDER_QUESTION_ID;
- VarOffset = BOOT_OPTION_ORDER_VAR_OFFSET;
- break;
+ OptionOrder = CallbackData->BmmFakeNvData.BootOptionOrder;
+ QuestionId = BOOT_OPTION_ORDER_QUESTION_ID;
+ VarOffset = BOOT_OPTION_ORDER_VAR_OFFSET;
+ break;
- case FORM_DRV_CHG_ID:
- //
- // If the DriverOptionOrder in the BmmFakeNvData are same with the date in the BmmOldFakeNVData,
- // means all Driver Options has been save in DriverOptionMenu, we can get the DriverOptionOrder from the menu.
- // else means browser maintains some uncommitted date which are not saved in DriverOptionMenu,
- // so we should not get the data from DriverOptionMenu to show it.
- //
- if (CompareMem (CallbackData->BmmFakeNvData.DriverOptionOrder, CallbackData->BmmOldFakeNVData.DriverOptionOrder, sizeof (CallbackData->BmmFakeNvData.DriverOptionOrder)) == 0) {
- GetDriverOrder (CallbackData);
- }
- OptionOrder = CallbackData->BmmFakeNvData.DriverOptionOrder;
- QuestionId = DRIVER_OPTION_ORDER_QUESTION_ID;
- VarOffset = DRIVER_OPTION_ORDER_VAR_OFFSET;
- break;
+ case FORM_DRV_CHG_ID:
+ //
+ // If the DriverOptionOrder in the BmmFakeNvData are same with the date in the BmmOldFakeNVData,
+ // means all Driver Options has been save in DriverOptionMenu, we can get the DriverOptionOrder from the menu.
+ // else means browser maintains some uncommitted date which are not saved in DriverOptionMenu,
+ // so we should not get the data from DriverOptionMenu to show it.
+ //
+ if (CompareMem (CallbackData->BmmFakeNvData.DriverOptionOrder, CallbackData->BmmOldFakeNVData.DriverOptionOrder, sizeof (CallbackData->BmmFakeNvData.DriverOptionOrder)) == 0) {
+ GetDriverOrder (CallbackData);
+ }
+
+ OptionOrder = CallbackData->BmmFakeNvData.DriverOptionOrder;
+ QuestionId = DRIVER_OPTION_ORDER_QUESTION_ID;
+ VarOffset = DRIVER_OPTION_ORDER_VAR_OFFSET;
+ break;
}
+
ASSERT (OptionOrder != NULL);
OptionsOpCodeHandle = HiiAllocateOpCodeHandle ();
@@ -617,12 +625,13 @@ UpdateOrderPage ( for (OptionIndex = 0; (OptionOrder[OptionIndex] != 0 && OptionIndex < MAX_MENU_NUMBER); OptionIndex++) {
BootOptionFound = FALSE;
for (Index = 0; Index < OptionMenu->MenuNumber; Index++) {
- NewMenuEntry = BOpt_GetMenuEntry (OptionMenu, Index);
- if ((UINT32) (NewMenuEntry->OptionNumber + 1) == OptionOrder[OptionIndex]) {
+ NewMenuEntry = BOpt_GetMenuEntry (OptionMenu, Index);
+ if ((UINT32)(NewMenuEntry->OptionNumber + 1) == OptionOrder[OptionIndex]) {
BootOptionFound = TRUE;
break;
}
}
+
if (BootOptionFound) {
HiiCreateOneOfOptionOpCode (
OptionsOpCodeHandle,
@@ -654,7 +663,6 @@ UpdateOrderPage ( HiiFreeOpCodeHandle (OptionsOpCodeHandle);
UpdatePageEnd (CallbackData);
-
}
/**
@@ -665,26 +673,26 @@ UpdateOrderPage ( **/
VOID
UpdateConModePage (
- IN BMM_CALLBACK_DATA *CallbackData
+ IN BMM_CALLBACK_DATA *CallbackData
)
{
- UINTN Mode;
- UINTN Index;
- UINTN Col;
- UINTN Row;
- CHAR16 ModeString[50];
- CHAR16 *PStr;
- UINTN MaxMode;
- UINTN ValidMode;
- EFI_STRING_ID *ModeToken;
- EFI_STATUS Status;
- VOID *OptionsOpCodeHandle;
+ UINTN Mode;
+ UINTN Index;
+ UINTN Col;
+ UINTN Row;
+ CHAR16 ModeString[50];
+ CHAR16 *PStr;
+ UINTN MaxMode;
+ UINTN ValidMode;
+ EFI_STRING_ID *ModeToken;
+ EFI_STATUS Status;
+ VOID *OptionsOpCodeHandle;
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *ConOut;
ConOut = gST->ConOut;
Index = 0;
ValidMode = 0;
- MaxMode = (UINTN) (ConOut->Mode->MaxMode);
+ MaxMode = (UINTN)(ConOut->Mode->MaxMode);
CallbackData->BmmAskSaveOrNot = TRUE;
@@ -698,6 +706,7 @@ UpdateConModePage ( if (EFI_ERROR (Status)) {
continue;
}
+
ValidMode++;
}
@@ -708,8 +717,8 @@ UpdateConModePage ( OptionsOpCodeHandle = HiiAllocateOpCodeHandle ();
ASSERT (OptionsOpCodeHandle != NULL);
- ModeToken = AllocateZeroPool (sizeof (EFI_STRING_ID) * ValidMode);
- ASSERT(ModeToken != NULL);
+ ModeToken = AllocateZeroPool (sizeof (EFI_STRING_ID) * ValidMode);
+ ASSERT (ModeToken != NULL);
//
// Determin which mode should be the first entry in menu
@@ -730,7 +739,7 @@ UpdateConModePage ( //
UnicodeValueToStringS (ModeString, sizeof (ModeString), 0, Col, 0);
PStr = &ModeString[0];
- StrnCatS (PStr, ARRAY_SIZE (ModeString), L" x ", StrLen(L" x ") + 1);
+ StrnCatS (PStr, ARRAY_SIZE (ModeString), L" x ", StrLen (L" x ") + 1);
PStr = PStr + StrLen (PStr);
UnicodeValueToStringS (
PStr,
@@ -748,7 +757,7 @@ UpdateConModePage ( ModeToken[Index],
EFI_IFR_OPTION_DEFAULT,
EFI_IFR_TYPE_NUM_SIZE_16,
- (UINT16) Mode
+ (UINT16)Mode
);
} else {
HiiCreateOneOfOptionOpCode (
@@ -756,15 +765,16 @@ UpdateConModePage ( ModeToken[Index],
0,
EFI_IFR_TYPE_NUM_SIZE_16,
- (UINT16) Mode
+ (UINT16)Mode
);
}
+
Index++;
}
HiiCreateOneOfOpCode (
mStartOpCodeHandle,
- (EFI_QUESTION_ID) CON_MODE_QUESTION_ID,
+ (EFI_QUESTION_ID)CON_MODE_QUESTION_ID,
VARSTORE_ID_BOOT_MAINT,
CON_MODE_VAR_OFFSET,
STRING_TOKEN (STR_CON_MODE_SETUP),
@@ -781,46 +791,47 @@ UpdateConModePage ( UpdatePageEnd (CallbackData);
}
- /**
- Create the dynamic page which allows user to set the property such as Baud Rate, Data Bits,
- Parity, Stop Bits, Terminal Type.
+/**
+ Create the dynamic page which allows user to set the property such as Baud Rate, Data Bits,
+ Parity, Stop Bits, Terminal Type.
- @param CallbackData The BMM context data.
+ @param CallbackData The BMM context data.
**/
VOID
UpdateTerminalPage (
- IN BMM_CALLBACK_DATA *CallbackData
+ IN BMM_CALLBACK_DATA *CallbackData
)
{
- UINT8 Index;
- UINT8 CheckFlags;
- BM_MENU_ENTRY *NewMenuEntry;
- VOID *OptionsOpCodeHandle;
- UINTN CurrentTerminal;
+ UINT8 Index;
+ UINT8 CheckFlags;
+ BM_MENU_ENTRY *NewMenuEntry;
+ VOID *OptionsOpCodeHandle;
+ UINTN CurrentTerminal;
CallbackData->BmmAskSaveOrNot = TRUE;
UpdatePageStart (CallbackData);
CurrentTerminal = CallbackData->CurrentTerminal;
- NewMenuEntry = BOpt_GetMenuEntry (
- &TerminalMenu,
- CurrentTerminal
- );
+ NewMenuEntry = BOpt_GetMenuEntry (
+ &TerminalMenu,
+ CurrentTerminal
+ );
if (NewMenuEntry == NULL) {
- return ;
+ return;
}
OptionsOpCodeHandle = HiiAllocateOpCodeHandle ();
ASSERT (OptionsOpCodeHandle != NULL);
- for (Index = 0; Index < sizeof (BaudRateList) / sizeof (BaudRateList [0]); Index++) {
+ for (Index = 0; Index < sizeof (BaudRateList) / sizeof (BaudRateList[0]); Index++) {
CheckFlags = 0;
if (BaudRateList[Index].Value == 115200) {
CheckFlags |= EFI_IFR_OPTION_DEFAULT;
}
+
HiiCreateOneOfOptionOpCode (
OptionsOpCodeHandle,
BaudRateList[Index].StringToken,
@@ -832,9 +843,9 @@ UpdateTerminalPage ( HiiCreateOneOfOpCode (
mStartOpCodeHandle,
- (EFI_QUESTION_ID) (COM_BAUD_RATE_QUESTION_ID + CurrentTerminal),
+ (EFI_QUESTION_ID)(COM_BAUD_RATE_QUESTION_ID + CurrentTerminal),
VARSTORE_ID_BOOT_MAINT,
- (UINT16) (COM_BAUD_RATE_VAR_OFFSET + CurrentTerminal),
+ (UINT16)(COM_BAUD_RATE_VAR_OFFSET + CurrentTerminal),
STRING_TOKEN (STR_COM_BAUD_RATE),
STRING_TOKEN (STR_COM_BAUD_RATE),
EFI_IFR_FLAG_CALLBACK,
@@ -865,9 +876,9 @@ UpdateTerminalPage ( HiiCreateOneOfOpCode (
mStartOpCodeHandle,
- (EFI_QUESTION_ID) (COM_DATA_RATE_QUESTION_ID + CurrentTerminal),
+ (EFI_QUESTION_ID)(COM_DATA_RATE_QUESTION_ID + CurrentTerminal),
VARSTORE_ID_BOOT_MAINT,
- (UINT16) (COM_DATA_RATE_VAR_OFFSET + CurrentTerminal),
+ (UINT16)(COM_DATA_RATE_VAR_OFFSET + CurrentTerminal),
STRING_TOKEN (STR_COM_DATA_BITS),
STRING_TOKEN (STR_COM_DATA_BITS),
EFI_IFR_FLAG_CALLBACK,
@@ -897,9 +908,9 @@ UpdateTerminalPage ( HiiCreateOneOfOpCode (
mStartOpCodeHandle,
- (EFI_QUESTION_ID) (COM_PARITY_QUESTION_ID + CurrentTerminal),
+ (EFI_QUESTION_ID)(COM_PARITY_QUESTION_ID + CurrentTerminal),
VARSTORE_ID_BOOT_MAINT,
- (UINT16) (COM_PARITY_VAR_OFFSET + CurrentTerminal),
+ (UINT16)(COM_PARITY_VAR_OFFSET + CurrentTerminal),
STRING_TOKEN (STR_COM_PARITY),
STRING_TOKEN (STR_COM_PARITY),
EFI_IFR_FLAG_CALLBACK,
@@ -929,9 +940,9 @@ UpdateTerminalPage ( HiiCreateOneOfOpCode (
mStartOpCodeHandle,
- (EFI_QUESTION_ID) (COM_STOP_BITS_QUESTION_ID + CurrentTerminal),
+ (EFI_QUESTION_ID)(COM_STOP_BITS_QUESTION_ID + CurrentTerminal),
VARSTORE_ID_BOOT_MAINT,
- (UINT16) (COM_STOP_BITS_VAR_OFFSET + CurrentTerminal),
+ (UINT16)(COM_STOP_BITS_VAR_OFFSET + CurrentTerminal),
STRING_TOKEN (STR_COM_STOP_BITS),
STRING_TOKEN (STR_COM_STOP_BITS),
EFI_IFR_FLAG_CALLBACK,
@@ -952,7 +963,7 @@ UpdateTerminalPage ( HiiCreateOneOfOptionOpCode (
OptionsOpCodeHandle,
- (EFI_STRING_ID) TerminalType[Index],
+ (EFI_STRING_ID)TerminalType[Index],
CheckFlags,
EFI_IFR_TYPE_NUM_SIZE_8,
Index
@@ -961,9 +972,9 @@ UpdateTerminalPage ( HiiCreateOneOfOpCode (
mStartOpCodeHandle,
- (EFI_QUESTION_ID) (COM_TERMINAL_QUESTION_ID + CurrentTerminal),
+ (EFI_QUESTION_ID)(COM_TERMINAL_QUESTION_ID + CurrentTerminal),
VARSTORE_ID_BOOT_MAINT,
- (UINT16) (COM_TERMINAL_VAR_OFFSET + CurrentTerminal),
+ (UINT16)(COM_TERMINAL_VAR_OFFSET + CurrentTerminal),
STRING_TOKEN (STR_COM_TERMI_TYPE),
STRING_TOKEN (STR_COM_TERMI_TYPE),
EFI_IFR_FLAG_CALLBACK,
@@ -977,13 +988,14 @@ UpdateTerminalPage ( ASSERT (OptionsOpCodeHandle != NULL);
for (Index = 0; Index < ARRAY_SIZE (mFlowControlType); Index++) {
- CheckFlags = 0;
+ CheckFlags = 0;
if (Index == 0) {
CheckFlags |= EFI_IFR_OPTION_DEFAULT;
}
+
HiiCreateOneOfOptionOpCode (
OptionsOpCodeHandle,
- (EFI_STRING_ID) mFlowControlType[Index],
+ (EFI_STRING_ID)mFlowControlType[Index],
CheckFlags,
EFI_IFR_TYPE_NUM_SIZE_8,
mFlowControlValue[Index]
@@ -992,9 +1004,9 @@ UpdateTerminalPage ( HiiCreateOneOfOpCode (
mStartOpCodeHandle,
- (EFI_QUESTION_ID) (COM_FLOWCONTROL_QUESTION_ID + CurrentTerminal),
+ (EFI_QUESTION_ID)(COM_FLOWCONTROL_QUESTION_ID + CurrentTerminal),
VARSTORE_ID_BOOT_MAINT,
- (UINT16) (COM_FLOWCONTROL_VAR_OFFSET + CurrentTerminal),
+ (UINT16)(COM_FLOWCONTROL_VAR_OFFSET + CurrentTerminal),
STRING_TOKEN (STR_COM_FLOW_CONTROL),
STRING_TOKEN (STR_COM_FLOW_CONTROL),
EFI_IFR_FLAG_CALLBACK,
@@ -1017,20 +1029,21 @@ Update add boot/driver option page. **/
VOID
-UpdateOptionPage(
- IN BMM_CALLBACK_DATA *CallbackData,
- IN EFI_FORM_ID FormId,
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
+UpdateOptionPage (
+ IN BMM_CALLBACK_DATA *CallbackData,
+ IN EFI_FORM_ID FormId,
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
)
{
- CHAR16 *String;
- EFI_STRING_ID StringToken;
+ CHAR16 *String;
+ EFI_STRING_ID StringToken;
String = NULL;
- if (DevicePath != NULL){
- String = ExtractFileNameFromDevicePath(DevicePath);
+ if (DevicePath != NULL) {
+ String = ExtractFileNameFromDevicePath (DevicePath);
}
+
if (String == NULL) {
String = HiiGetString (CallbackData->BmmHiiHandle, STRING_TOKEN (STR_NULL_STRING), NULL);
ASSERT (String != NULL);
@@ -1039,14 +1052,14 @@ UpdateOptionPage( StringToken = HiiSetString (CallbackData->BmmHiiHandle, 0, String, NULL);
FreePool (String);
- if(FormId == FORM_BOOT_ADD_ID){
+ if (FormId == FORM_BOOT_ADD_ID) {
if (!CallbackData->BmmFakeNvData.BootOptionChanged) {
ZeroMem (CallbackData->BmmFakeNvData.BootOptionalData, sizeof (CallbackData->BmmFakeNvData.BootOptionalData));
ZeroMem (CallbackData->BmmFakeNvData.BootDescriptionData, sizeof (CallbackData->BmmFakeNvData.BootDescriptionData));
ZeroMem (CallbackData->BmmOldFakeNVData.BootOptionalData, sizeof (CallbackData->BmmOldFakeNVData.BootOptionalData));
ZeroMem (CallbackData->BmmOldFakeNVData.BootDescriptionData, sizeof (CallbackData->BmmOldFakeNVData.BootDescriptionData));
}
- } else if (FormId == FORM_DRV_ADD_FILE_ID){
+ } else if (FormId == FORM_DRV_ADD_FILE_ID) {
if (!CallbackData->BmmFakeNvData.DriverOptionChanged) {
ZeroMem (CallbackData->BmmFakeNvData.DriverOptionalData, sizeof (CallbackData->BmmFakeNvData.DriverOptionalData));
ZeroMem (CallbackData->BmmFakeNvData.DriverDescriptionData, sizeof (CallbackData->BmmFakeNvData.DriverDescriptionData));
@@ -1055,7 +1068,7 @@ UpdateOptionPage( }
}
- RefreshUpdateData();
+ RefreshUpdateData ();
mStartLabel->Number = FormId;
HiiCreateSubTitleOpCode (
@@ -1070,8 +1083,8 @@ UpdateOptionPage( CallbackData->BmmHiiHandle,
&mBootMaintGuid,
FormId,
- mStartOpCodeHandle,// Label FormId
- mEndOpCodeHandle // LABEL_END
+ mStartOpCodeHandle, // Label FormId
+ mEndOpCodeHandle // LABEL_END
);
}
@@ -1085,34 +1098,34 @@ UpdateOptionPage( **/
VOID
UpdatePageBody (
- IN UINT16 UpdatePageId,
- IN BMM_CALLBACK_DATA *CallbackData
+ IN UINT16 UpdatePageId,
+ IN BMM_CALLBACK_DATA *CallbackData
)
{
CleanUpPage (UpdatePageId, CallbackData);
switch (UpdatePageId) {
- case FORM_CON_IN_ID:
- UpdateConsolePage (UpdatePageId, &ConsoleInpMenu, CallbackData);
- break;
+ case FORM_CON_IN_ID:
+ UpdateConsolePage (UpdatePageId, &ConsoleInpMenu, CallbackData);
+ break;
- case FORM_CON_OUT_ID:
- UpdateConsolePage (UpdatePageId, &ConsoleOutMenu, CallbackData);
- break;
+ case FORM_CON_OUT_ID:
+ UpdateConsolePage (UpdatePageId, &ConsoleOutMenu, CallbackData);
+ break;
- case FORM_CON_ERR_ID:
- UpdateConsolePage (UpdatePageId, &ConsoleErrMenu, CallbackData);
- break;
+ case FORM_CON_ERR_ID:
+ UpdateConsolePage (UpdatePageId, &ConsoleErrMenu, CallbackData);
+ break;
- case FORM_BOOT_CHG_ID:
- UpdateOrderPage (UpdatePageId, &BootOptionMenu, CallbackData);
- break;
+ case FORM_BOOT_CHG_ID:
+ UpdateOrderPage (UpdatePageId, &BootOptionMenu, CallbackData);
+ break;
- case FORM_DRV_CHG_ID:
- UpdateOrderPage (UpdatePageId, &DriverOptionMenu, CallbackData);
- break;
+ case FORM_DRV_CHG_ID:
+ UpdateOrderPage (UpdatePageId, &DriverOptionMenu, CallbackData);
+ break;
- default:
- break;
+ default:
+ break;
}
}
@@ -1125,8 +1138,8 @@ UpdatePageBody ( **/
VOID
UpdatePageId (
- BMM_CALLBACK_DATA *Private,
- UINT16 NewPageId
+ BMM_CALLBACK_DATA *Private,
+ UINT16 NewPageId
)
{
if ((NewPageId < FILE_OPTION_OFFSET) && (NewPageId >= HANDLE_OPTION_OFFSET)) {
@@ -1144,7 +1157,7 @@ UpdatePageId ( }
if ((NewPageId > 0) && (NewPageId < MAXIMUM_FORM_ID)) {
- Private->BmmPreviousPageId = Private->BmmCurrentPageId;
- Private->BmmCurrentPageId = NewPageId;
+ Private->BmmPreviousPageId = Private->BmmCurrentPageId;
+ Private->BmmCurrentPageId = NewPageId;
}
}
diff --git a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/Variable.c b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/Variable.c index e28f76b8de..82a0ed66a7 100644 --- a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/Variable.c +++ b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/Variable.c @@ -22,28 +22,29 @@ Var_DelBootOption ( VOID
)
{
- BM_MENU_ENTRY *NewMenuEntry;
- BM_LOAD_CONTEXT *NewLoadContext;
- EFI_STATUS Status;
- UINTN Index;
- UINTN Index2;
+ BM_MENU_ENTRY *NewMenuEntry;
+ BM_LOAD_CONTEXT *NewLoadContext;
+ EFI_STATUS Status;
+ UINTN Index;
+ UINTN Index2;
- Index2 = 0;
+ Index2 = 0;
for (Index = 0; Index < BootOptionMenu.MenuNumber; Index++) {
NewMenuEntry = BOpt_GetMenuEntry (&BootOptionMenu, (Index - Index2));
if (NULL == NewMenuEntry) {
return EFI_NOT_FOUND;
}
- NewLoadContext = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext;
+ NewLoadContext = (BM_LOAD_CONTEXT *)NewMenuEntry->VariableContext;
if (!NewLoadContext->Deleted) {
continue;
}
- Status = EfiBootManagerDeleteLoadOptionVariable (NewMenuEntry->OptionNumber,LoadOptionTypeBoot);
+ Status = EfiBootManagerDeleteLoadOptionVariable (NewMenuEntry->OptionNumber, LoadOptionTypeBoot);
if (EFI_ERROR (Status)) {
- return Status;
+ return Status;
}
+
Index2++;
//
// If current Load Option is the same as BootNext,
@@ -78,24 +79,25 @@ Var_DelDriverOption ( VOID
)
{
- BM_MENU_ENTRY *NewMenuEntry;
- BM_LOAD_CONTEXT *NewLoadContext;
- EFI_STATUS Status;
- UINTN Index;
- UINTN Index2;
+ BM_MENU_ENTRY *NewMenuEntry;
+ BM_LOAD_CONTEXT *NewLoadContext;
+ EFI_STATUS Status;
+ UINTN Index;
+ UINTN Index2;
- Index2 = 0;
+ Index2 = 0;
for (Index = 0; Index < DriverOptionMenu.MenuNumber; Index++) {
NewMenuEntry = BOpt_GetMenuEntry (&DriverOptionMenu, (Index - Index2));
if (NULL == NewMenuEntry) {
return EFI_NOT_FOUND;
}
- NewLoadContext = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext;
+ NewLoadContext = (BM_LOAD_CONTEXT *)NewMenuEntry->VariableContext;
if (!NewLoadContext->Deleted) {
continue;
}
- Status = EfiBootManagerDeleteLoadOptionVariable (NewMenuEntry->OptionNumber,LoadOptionTypeDriver);
+
+ Status = EfiBootManagerDeleteLoadOptionVariable (NewMenuEntry->OptionNumber, LoadOptionTypeDriver);
if (EFI_ERROR (Status)) {
return Status;
}
@@ -136,9 +138,9 @@ Var_DelDriverOption ( **/
EFI_STATUS
Var_UpdateConsoleOption (
- IN UINT16 *ConsoleName,
- IN BM_MENU_OPTION *ConsoleMenu,
- IN UINT16 UpdatePageId
+ IN UINT16 *ConsoleName,
+ IN BM_MENU_OPTION *ConsoleMenu,
+ IN UINT16 UpdatePageId
)
{
EFI_DEVICE_PATH_PROTOCOL *ConDevicePath;
@@ -150,12 +152,12 @@ Var_UpdateConsoleOption ( EFI_DEVICE_PATH_PROTOCOL *TerminalDevicePath;
UINTN Index;
- GetEfiGlobalVariable2 (ConsoleName, (VOID**)&ConDevicePath, NULL);
+ GetEfiGlobalVariable2 (ConsoleName, (VOID **)&ConDevicePath, NULL);
if (ConDevicePath != NULL) {
EfiLibDeleteVariable (ConsoleName, &gEfiGlobalVariableGuid);
FreePool (ConDevicePath);
ConDevicePath = NULL;
- };
+ }
//
// First add all console input device from console input menu
@@ -163,7 +165,7 @@ Var_UpdateConsoleOption ( for (Index = 0; Index < ConsoleMenu->MenuNumber; Index++) {
NewMenuEntry = BOpt_GetMenuEntry (ConsoleMenu, Index);
- NewConsoleContext = (BM_CONSOLE_CONTEXT *) NewMenuEntry->VariableContext;
+ NewConsoleContext = (BM_CONSOLE_CONTEXT *)NewMenuEntry->VariableContext;
if (NewConsoleContext->IsActive) {
ConDevicePath = AppendDevicePathInstance (
ConDevicePath,
@@ -175,11 +177,12 @@ Var_UpdateConsoleOption ( for (Index = 0; Index < TerminalMenu.MenuNumber; Index++) {
NewMenuEntry = BOpt_GetMenuEntry (&TerminalMenu, Index);
- NewTerminalContext = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext;
+ NewTerminalContext = (BM_TERMINAL_CONTEXT *)NewMenuEntry->VariableContext;
if (((NewTerminalContext->IsConIn != 0) && (UpdatePageId == FORM_CON_IN_ID)) ||
((NewTerminalContext->IsConOut != 0) && (UpdatePageId == FORM_CON_OUT_ID)) ||
((NewTerminalContext->IsStdErr != 0) && (UpdatePageId == FORM_CON_ERR_ID))
- ) {
+ )
+ {
Vendor.Header.Type = MESSAGING_DEVICE_PATH;
Vendor.Header.SubType = MSG_VENDOR_DP;
@@ -191,9 +194,9 @@ Var_UpdateConsoleOption ( );
SetDevicePathNodeLength (&Vendor.Header, sizeof (VENDOR_DEVICE_PATH));
TerminalDevicePath = AppendDevicePathNode (
- NewTerminalContext->DevicePath,
- (EFI_DEVICE_PATH_PROTOCOL *) &Vendor
- );
+ NewTerminalContext->DevicePath,
+ (EFI_DEVICE_PATH_PROTOCOL *)&Vendor
+ );
ASSERT (TerminalDevicePath != NULL);
ChangeTerminalDevicePath (TerminalDevicePath, TRUE);
ConDevicePath = AppendDevicePathInstance (
@@ -217,7 +220,6 @@ Var_UpdateConsoleOption ( }
return EFI_SUCCESS;
-
}
/**
@@ -285,28 +287,28 @@ Var_UpdateErrorOutOption ( **/
EFI_STATUS
Var_UpdateDriverOption (
- IN BMM_CALLBACK_DATA *CallbackData,
- IN EFI_HII_HANDLE HiiHandle,
- IN UINT16 *DescriptionData,
- IN UINT16 *OptionalData,
- IN UINT8 ForceReconnect
+ IN BMM_CALLBACK_DATA *CallbackData,
+ IN EFI_HII_HANDLE HiiHandle,
+ IN UINT16 *DescriptionData,
+ IN UINT16 *OptionalData,
+ IN UINT8 ForceReconnect
)
{
- UINT16 Index;
- UINT16 DriverString[12];
- BM_MENU_ENTRY *NewMenuEntry;
- BM_LOAD_CONTEXT *NewLoadContext;
- BOOLEAN OptionalDataExist;
- EFI_STATUS Status;
+ UINT16 Index;
+ UINT16 DriverString[12];
+ BM_MENU_ENTRY *NewMenuEntry;
+ BM_LOAD_CONTEXT *NewLoadContext;
+ BOOLEAN OptionalDataExist;
+ EFI_STATUS Status;
EFI_BOOT_MANAGER_LOAD_OPTION LoadOption;
UINT8 *OptionalDesData;
UINT32 OptionalDataSize;
OptionalDataExist = FALSE;
- OptionalDesData = NULL;
- OptionalDataSize = 0;
+ OptionalDesData = NULL;
+ OptionalDataSize = 0;
- Index = BOpt_GetDriverOptionNumber ();
+ Index = BOpt_GetDriverOptionNumber ();
UnicodeSPrint (
DriverString,
sizeof (DriverString),
@@ -320,8 +322,8 @@ Var_UpdateDriverOption ( if (*OptionalData != 0x0000) {
OptionalDataExist = TRUE;
- OptionalDesData = (UINT8 *)OptionalData;
- OptionalDataSize = (UINT32)StrSize (OptionalData);
+ OptionalDesData = (UINT8 *)OptionalData;
+ OptionalDataSize = (UINT32)StrSize (OptionalData);
}
NewMenuEntry = BOpt_CreateMenuEntry (BM_LOAD_CONTEXT_SELECT);
@@ -338,20 +340,20 @@ Var_UpdateDriverOption ( CallbackData->LoadContext->FilePathList,
OptionalDesData,
OptionalDataSize
- );
- if (EFI_ERROR (Status)){
+ );
+ if (EFI_ERROR (Status)) {
return Status;
}
- Status = EfiBootManagerAddLoadOptionVariable (&LoadOption,(UINTN) -1 );
+ Status = EfiBootManagerAddLoadOptionVariable (&LoadOption, (UINTN)-1);
if (EFI_ERROR (Status)) {
- EfiBootManagerFreeLoadOption(&LoadOption);
+ EfiBootManagerFreeLoadOption (&LoadOption);
return Status;
}
- NewLoadContext = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext;
- NewLoadContext->Deleted = FALSE;
- NewLoadContext->Attributes = LoadOption.Attributes;
+ NewLoadContext = (BM_LOAD_CONTEXT *)NewMenuEntry->VariableContext;
+ NewLoadContext->Deleted = FALSE;
+ NewLoadContext->Attributes = LoadOption.Attributes;
NewLoadContext->FilePathListLength = (UINT16)GetDevicePathSize (LoadOption.FilePath);
NewLoadContext->Description = AllocateZeroPool (StrSize (DescriptionData));
@@ -371,10 +373,10 @@ Var_UpdateDriverOption ( GetDevicePathSize (CallbackData->LoadContext->FilePathList)
);
- NewMenuEntry->HelpString = UiDevicePathToStr (NewLoadContext->FilePathList);
- NewMenuEntry->OptionNumber = Index;
+ NewMenuEntry->HelpString = UiDevicePathToStr (NewLoadContext->FilePathList);
+ NewMenuEntry->OptionNumber = Index;
NewMenuEntry->DisplayStringToken = HiiSetString (HiiHandle, 0, NewMenuEntry->DisplayString, NULL);
- NewMenuEntry->HelpStringToken = HiiSetString (HiiHandle, 0, NewMenuEntry->HelpString, NULL);
+ NewMenuEntry->HelpStringToken = HiiSetString (HiiHandle, 0, NewMenuEntry->HelpString, NULL);
if (OptionalDataExist) {
NewLoadContext->OptionalData = AllocateZeroPool (LoadOption.OptionalDataSize);
@@ -389,7 +391,7 @@ Var_UpdateDriverOption ( InsertTailList (&DriverOptionMenu.Head, &NewMenuEntry->Link);
DriverOptionMenu.MenuNumber++;
- EfiBootManagerFreeLoadOption(&LoadOption);
+ EfiBootManagerFreeLoadOption (&LoadOption);
return EFI_SUCCESS;
}
@@ -410,26 +412,26 @@ Var_UpdateDriverOption ( **/
EFI_STATUS
Var_UpdateBootOption (
- IN BMM_CALLBACK_DATA *CallbackData
+ IN BMM_CALLBACK_DATA *CallbackData
)
{
- UINT16 BootString[10];
- UINT16 Index;
- BM_MENU_ENTRY *NewMenuEntry;
- BM_LOAD_CONTEXT *NewLoadContext;
- BOOLEAN OptionalDataExist;
- EFI_STATUS Status;
- BMM_FAKE_NV_DATA *NvRamMap;
+ UINT16 BootString[10];
+ UINT16 Index;
+ BM_MENU_ENTRY *NewMenuEntry;
+ BM_LOAD_CONTEXT *NewLoadContext;
+ BOOLEAN OptionalDataExist;
+ EFI_STATUS Status;
+ BMM_FAKE_NV_DATA *NvRamMap;
EFI_BOOT_MANAGER_LOAD_OPTION LoadOption;
UINT8 *OptionalData;
UINT32 OptionalDataSize;
OptionalDataExist = FALSE;
- NvRamMap = &CallbackData->BmmFakeNvData;
- OptionalData = NULL;
- OptionalDataSize = 0;
+ NvRamMap = &CallbackData->BmmFakeNvData;
+ OptionalData = NULL;
+ OptionalDataSize = 0;
- Index = BOpt_GetBootOptionNumber () ;
+ Index = BOpt_GetBootOptionNumber ();
UnicodeSPrint (BootString, sizeof (BootString), L"Boot%04x", Index);
if (NvRamMap->BootDescriptionData[0] == 0x0000) {
@@ -438,8 +440,8 @@ Var_UpdateBootOption ( if (NvRamMap->BootOptionalData[0] != 0x0000) {
OptionalDataExist = TRUE;
- OptionalData = (UINT8 *)NvRamMap->BootOptionalData;
- OptionalDataSize = (UINT32)StrSize (NvRamMap->BootOptionalData);
+ OptionalData = (UINT8 *)NvRamMap->BootOptionalData;
+ OptionalDataSize = (UINT32)StrSize (NvRamMap->BootOptionalData);
}
NewMenuEntry = BOpt_CreateMenuEntry (BM_LOAD_CONTEXT_SELECT);
@@ -456,21 +458,21 @@ Var_UpdateBootOption ( CallbackData->LoadContext->FilePathList,
OptionalData,
OptionalDataSize
- );
- if (EFI_ERROR (Status)){
+ );
+ if (EFI_ERROR (Status)) {
return Status;
}
- Status = EfiBootManagerAddLoadOptionVariable (&LoadOption,(UINTN) -1 );
+ Status = EfiBootManagerAddLoadOptionVariable (&LoadOption, (UINTN)-1);
if (EFI_ERROR (Status)) {
- EfiBootManagerFreeLoadOption(&LoadOption);
+ EfiBootManagerFreeLoadOption (&LoadOption);
return Status;
}
- NewLoadContext = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext;
- NewLoadContext->Deleted = FALSE;
- NewLoadContext->Attributes = LoadOption.Attributes;
- NewLoadContext->FilePathListLength = (UINT16) GetDevicePathSize (LoadOption.FilePath);
+ NewLoadContext = (BM_LOAD_CONTEXT *)NewMenuEntry->VariableContext;
+ NewLoadContext->Deleted = FALSE;
+ NewLoadContext->Attributes = LoadOption.Attributes;
+ NewLoadContext->FilePathListLength = (UINT16)GetDevicePathSize (LoadOption.FilePath);
NewLoadContext->Description = AllocateZeroPool (StrSize (NvRamMap->BootDescriptionData));
ASSERT (NewLoadContext->Description != NULL);
@@ -491,10 +493,10 @@ Var_UpdateBootOption ( GetDevicePathSize (CallbackData->LoadContext->FilePathList)
);
- NewMenuEntry->HelpString = UiDevicePathToStr (NewLoadContext->FilePathList);
- NewMenuEntry->OptionNumber = Index;
+ NewMenuEntry->HelpString = UiDevicePathToStr (NewLoadContext->FilePathList);
+ NewMenuEntry->OptionNumber = Index;
NewMenuEntry->DisplayStringToken = HiiSetString (CallbackData->BmmHiiHandle, 0, NewMenuEntry->DisplayString, NULL);
- NewMenuEntry->HelpStringToken = HiiSetString (CallbackData->BmmHiiHandle, 0, NewMenuEntry->HelpString, NULL);
+ NewMenuEntry->HelpStringToken = HiiSetString (CallbackData->BmmHiiHandle, 0, NewMenuEntry->HelpString, NULL);
if (OptionalDataExist) {
NewLoadContext->OptionalData = AllocateZeroPool (LoadOption.OptionalDataSize);
@@ -509,7 +511,7 @@ Var_UpdateBootOption ( InsertTailList (&BootOptionMenu.Head, &NewMenuEntry->Link);
BootOptionMenu.MenuNumber++;
- EfiBootManagerFreeLoadOption(&LoadOption);
+ EfiBootManagerFreeLoadOption (&LoadOption);
return EFI_SUCCESS;
}
@@ -529,7 +531,7 @@ Var_UpdateBootOption ( **/
EFI_STATUS
Var_UpdateBootNext (
- IN BMM_CALLBACK_DATA *CallbackData
+ IN BMM_CALLBACK_DATA *CallbackData
)
{
BM_MENU_ENTRY *NewMenuEntry;
@@ -538,14 +540,14 @@ Var_UpdateBootNext ( UINT16 Index;
EFI_STATUS Status;
- Status = EFI_SUCCESS;
- CurrentFakeNVMap = &CallbackData->BmmFakeNvData;
+ Status = EFI_SUCCESS;
+ CurrentFakeNVMap = &CallbackData->BmmFakeNvData;
for (Index = 0; Index < BootOptionMenu.MenuNumber; Index++) {
NewMenuEntry = BOpt_GetMenuEntry (&BootOptionMenu, Index);
ASSERT (NULL != NewMenuEntry);
- NewLoadContext = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext;
- NewLoadContext->IsBootNext = FALSE;
+ NewLoadContext = (BM_LOAD_CONTEXT *)NewMenuEntry->VariableContext;
+ NewLoadContext->IsBootNext = FALSE;
}
if (CurrentFakeNVMap->BootNext == NONE_BOOTNEXT_VALUE) {
@@ -554,19 +556,19 @@ Var_UpdateBootNext ( }
NewMenuEntry = BOpt_GetMenuEntry (
- &BootOptionMenu,
- CurrentFakeNVMap->BootNext
- );
+ &BootOptionMenu,
+ CurrentFakeNVMap->BootNext
+ );
ASSERT (NewMenuEntry != NULL);
- NewLoadContext = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext;
- Status = gRT->SetVariable (
- L"BootNext",
- &gEfiGlobalVariableGuid,
- VAR_FLAG,
- sizeof (UINT16),
- &NewMenuEntry->OptionNumber
- );
+ NewLoadContext = (BM_LOAD_CONTEXT *)NewMenuEntry->VariableContext;
+ Status = gRT->SetVariable (
+ L"BootNext",
+ &gEfiGlobalVariableGuid,
+ VAR_FLAG,
+ sizeof (UINT16),
+ &NewMenuEntry->OptionNumber
+ );
NewLoadContext->IsBootNext = TRUE;
CallbackData->BmmOldFakeNVData.BootNext = CurrentFakeNVMap->BootNext;
return Status;
@@ -586,7 +588,7 @@ Var_UpdateBootNext ( **/
EFI_STATUS
Var_UpdateBootOrder (
- IN BMM_CALLBACK_DATA *CallbackData
+ IN BMM_CALLBACK_DATA *CallbackData
)
{
EFI_STATUS Status;
@@ -599,7 +601,7 @@ Var_UpdateBootOrder ( //
// First check whether BootOrder is present in current configuration
//
- GetEfiGlobalVariable2 (L"BootOrder", (VOID **) &BootOrder, &BootOrderSize);
+ GetEfiGlobalVariable2 (L"BootOrder", (VOID **)&BootOrder, &BootOrderSize);
if (BootOrder == NULL) {
return EFI_OUT_OF_RESOURCES;
}
@@ -611,7 +613,7 @@ Var_UpdateBootOrder ( //
for (OrderIndex = 0; (OrderIndex < BootOptionMenu.MenuNumber) && (CallbackData->BmmFakeNvData.BootOptionOrder[OrderIndex] != 0); OrderIndex++) {
for (Index = OrderIndex; Index < BootOrderSize / sizeof (UINT16); Index++) {
- if ((BootOrder[Index] == (UINT16) (CallbackData->BmmFakeNvData.BootOptionOrder[OrderIndex] - 1)) && (OrderIndex != Index)) {
+ if ((BootOrder[Index] == (UINT16)(CallbackData->BmmFakeNvData.BootOptionOrder[OrderIndex] - 1)) && (OrderIndex != Index)) {
OptionNumber = BootOrder[Index];
CopyMem (&BootOrder[OrderIndex + 1], &BootOrder[OrderIndex], (Index - OrderIndex) * sizeof (UINT16));
BootOrder[OrderIndex] = OptionNumber;
@@ -632,7 +634,6 @@ Var_UpdateBootOrder ( BOpt_GetBootOptions (CallbackData);
return Status;
-
}
/**
@@ -649,7 +650,7 @@ Var_UpdateBootOrder ( **/
EFI_STATUS
Var_UpdateDriverOrder (
- IN BMM_CALLBACK_DATA *CallbackData
+ IN BMM_CALLBACK_DATA *CallbackData
)
{
EFI_STATUS Status;
@@ -664,12 +665,13 @@ Var_UpdateDriverOrder ( //
// First check whether DriverOrder is present in current configuration
//
- GetEfiGlobalVariable2 (L"DriverOrder", (VOID **) &DriverOrderList, &DriverOrderListSize);
+ GetEfiGlobalVariable2 (L"DriverOrder", (VOID **)&DriverOrderList, &DriverOrderListSize);
NewDriverOrderList = AllocateZeroPool (DriverOrderListSize);
if (NewDriverOrderList == NULL) {
return EFI_OUT_OF_RESOURCES;
}
+
//
// If exists, delete it to hold new DriverOrder
//
@@ -680,7 +682,7 @@ Var_UpdateDriverOrder ( ASSERT (DriverOptionMenu.MenuNumber <= (sizeof (CallbackData->BmmFakeNvData.DriverOptionOrder) / sizeof (CallbackData->BmmFakeNvData.DriverOptionOrder[0])));
for (Index = 0; Index < DriverOptionMenu.MenuNumber; Index++) {
- NewDriverOrderList[Index] = (UINT16) (CallbackData->BmmFakeNvData.DriverOptionOrder[Index] - 1);
+ NewDriverOrderList[Index] = (UINT16)(CallbackData->BmmFakeNvData.DriverOptionOrder[Index] - 1);
}
Status = gRT->SetVariable (
@@ -710,7 +712,7 @@ Var_UpdateDriverOrder ( **/
EFI_STATUS
Var_UpdateConMode (
- IN BMM_CALLBACK_DATA *CallbackData
+ IN BMM_CALLBACK_DATA *CallbackData
)
{
EFI_STATUS Status;
@@ -720,10 +722,10 @@ Var_UpdateConMode ( Mode = CallbackData->BmmFakeNvData.ConsoleOutMode;
Status = gST->ConOut->QueryMode (gST->ConOut, Mode, &(ModeInfo.Column), &(ModeInfo.Row));
- if (!EFI_ERROR(Status)) {
- Status = PcdSet32S (PcdSetupConOutColumn, (UINT32) ModeInfo.Column);
+ if (!EFI_ERROR (Status)) {
+ Status = PcdSet32S (PcdSetupConOutColumn, (UINT32)ModeInfo.Column);
if (!EFI_ERROR (Status)) {
- Status = PcdSet32S (PcdSetupConOutRow, (UINT32) ModeInfo.Row);
+ Status = PcdSet32S (PcdSetupConOutRow, (UINT32)ModeInfo.Row);
}
}
diff --git a/MdeModulePkg/Library/BootManagerUiLib/BootManager.c b/MdeModulePkg/Library/BootManagerUiLib/BootManager.c index e378ac52b5..b7526796d6 100644 --- a/MdeModulePkg/Library/BootManagerUiLib/BootManager.c +++ b/MdeModulePkg/Library/BootManagerUiLib/BootManager.c @@ -8,26 +8,26 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include "BootManager.h"
-UINT16 mKeyInput;
-EFI_GUID mBootManagerGuid = BOOT_MANAGER_FORMSET_GUID;
+UINT16 mKeyInput;
+EFI_GUID mBootManagerGuid = BOOT_MANAGER_FORMSET_GUID;
//
// Boot video resolution and text mode.
//
-UINT32 mBmBootHorizontalResolution = 0;
-UINT32 mBmBootVerticalResolution = 0;
-UINT32 mBmBootTextModeColumn = 0;
-UINT32 mBmBootTextModeRow = 0;
+UINT32 mBmBootHorizontalResolution = 0;
+UINT32 mBmBootVerticalResolution = 0;
+UINT32 mBmBootTextModeColumn = 0;
+UINT32 mBmBootTextModeRow = 0;
//
// BIOS setup video resolution and text mode.
//
-UINT32 mBmSetupTextModeColumn = 0;
-UINT32 mBmSetupTextModeRow = 0;
-UINT32 mBmSetupHorizontalResolution = 0;
-UINT32 mBmSetupVerticalResolution = 0;
+UINT32 mBmSetupTextModeColumn = 0;
+UINT32 mBmSetupTextModeRow = 0;
+UINT32 mBmSetupHorizontalResolution = 0;
+UINT32 mBmSetupVerticalResolution = 0;
-BOOLEAN mBmModeInitialized = FALSE;
+BOOLEAN mBmModeInitialized = FALSE;
-CHAR16 *mDeviceTypeStr[] = {
+CHAR16 *mDeviceTypeStr[] = {
L"Legacy BEV",
L"Legacy Floppy",
L"Legacy Hard Drive",
@@ -44,21 +44,22 @@ HII_VENDOR_DEVICE_PATH mBootManagerHiiVendorDevicePath = { HARDWARE_DEVICE_PATH,
HW_VENDOR_DP,
{
- (UINT8) (sizeof (VENDOR_DEVICE_PATH)),
- (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)
+ (UINT8)(sizeof (VENDOR_DEVICE_PATH)),
+ (UINT8)((sizeof (VENDOR_DEVICE_PATH)) >> 8)
}
},
//
// {1DDDBE15-481D-4d2b-8277-B191EAF66525}
//
- { 0x1dddbe15, 0x481d, 0x4d2b, { 0x82, 0x77, 0xb1, 0x91, 0xea, 0xf6, 0x65, 0x25 } }
+ { 0x1dddbe15, 0x481d, 0x4d2b, { 0x82, 0x77, 0xb1, 0x91, 0xea, 0xf6, 0x65, 0x25 }
+ }
},
{
END_DEVICE_PATH_TYPE,
END_ENTIRE_DEVICE_PATH_SUBTYPE,
{
- (UINT8) (END_DEVICE_PATH_LENGTH),
- (UINT8) ((END_DEVICE_PATH_LENGTH) >> 8)
+ (UINT8)(END_DEVICE_PATH_LENGTH),
+ (UINT8)((END_DEVICE_PATH_LENGTH) >> 8)
}
}
};
@@ -116,7 +117,7 @@ BmSetConsoleMode ( Status = gBS->HandleProtocol (
gST->ConsoleOutHandle,
&gEfiGraphicsOutputProtocolGuid,
- (VOID**)&GraphicsOutput
+ (VOID **)&GraphicsOutput
);
if (EFI_ERROR (Status)) {
GraphicsOutput = NULL;
@@ -125,7 +126,7 @@ BmSetConsoleMode ( Status = gBS->HandleProtocol (
gST->ConsoleOutHandle,
&gEfiSimpleTextOutProtocolGuid,
- (VOID**)&SimpleTextOut
+ (VOID **)&SimpleTextOut
);
if (EFI_ERROR (Status)) {
SimpleTextOut = NULL;
@@ -154,7 +155,7 @@ BmSetConsoleMode ( }
if (GraphicsOutput != NULL) {
- MaxGopMode = GraphicsOutput->Mode->MaxMode;
+ MaxGopMode = GraphicsOutput->Mode->MaxMode;
}
if (SimpleTextOut != NULL) {
@@ -170,22 +171,24 @@ BmSetConsoleMode ( //
for (ModeNumber = 0; ModeNumber < MaxGopMode; ModeNumber++) {
Status = GraphicsOutput->QueryMode (
- GraphicsOutput,
- ModeNumber,
- &SizeOfInfo,
- &Info
- );
+ GraphicsOutput,
+ ModeNumber,
+ &SizeOfInfo,
+ &Info
+ );
if (!EFI_ERROR (Status)) {
if ((Info->HorizontalResolution == NewHorizontalResolution) &&
- (Info->VerticalResolution == NewVerticalResolution)) {
+ (Info->VerticalResolution == NewVerticalResolution))
+ {
if ((GraphicsOutput->Mode->Info->HorizontalResolution == NewHorizontalResolution) &&
- (GraphicsOutput->Mode->Info->VerticalResolution == NewVerticalResolution)) {
+ (GraphicsOutput->Mode->Info->VerticalResolution == NewVerticalResolution))
+ {
//
// Current resolution is same with required resolution, check if text mode need be set
//
Status = SimpleTextOut->QueryMode (SimpleTextOut, SimpleTextOut->Mode->Mode, &CurrentColumn, &CurrentRow);
ASSERT_EFI_ERROR (Status);
- if (CurrentColumn == NewColumns && CurrentRow == NewRows) {
+ if ((CurrentColumn == NewColumns) && (CurrentRow == NewRows)) {
//
// If current text mode is same with required text mode. Do nothing
//
@@ -197,7 +200,7 @@ BmSetConsoleMode ( //
for (Index = 0; Index < MaxTextMode; Index++) {
Status = SimpleTextOut->QueryMode (SimpleTextOut, Index, &CurrentColumn, &CurrentRow);
- if (!EFI_ERROR(Status)) {
+ if (!EFI_ERROR (Status)) {
if ((CurrentColumn == NewColumns) && (CurrentRow == NewRows)) {
//
// Required text mode is supported, set it.
@@ -216,6 +219,7 @@ BmSetConsoleMode ( }
}
}
+
if (Index == MaxTextMode) {
//
// If required text mode is not supported, return error.
@@ -236,6 +240,7 @@ BmSetConsoleMode ( }
}
}
+
FreePool (Info);
}
}
@@ -266,19 +271,21 @@ BmSetConsoleMode ( // Locate all the handles with GOP protocol and reconnect it.
//
Status = gBS->LocateHandleBuffer (
- ByProtocol,
- &gEfiSimpleTextOutProtocolGuid,
- NULL,
- &HandleCount,
- &HandleBuffer
- );
+ ByProtocol,
+ &gEfiSimpleTextOutProtocolGuid,
+ NULL,
+ &HandleCount,
+ &HandleBuffer
+ );
if (!EFI_ERROR (Status)) {
for (Index = 0; Index < HandleCount; Index++) {
gBS->DisconnectController (HandleBuffer[Index], NULL, NULL);
}
+
for (Index = 0; Index < HandleCount; Index++) {
gBS->ConnectController (HandleBuffer[Index], NULL, NULL, TRUE);
}
+
if (HandleBuffer != NULL) {
FreePool (HandleBuffer);
}
@@ -297,20 +304,20 @@ BmSetupResetReminder ( VOID
)
{
- EFI_INPUT_KEY Key;
- CHAR16 *StringBuffer1;
- CHAR16 *StringBuffer2;
- EFI_STATUS Status;
- EDKII_FORM_BROWSER_EXTENSION2_PROTOCOL *FormBrowserEx2;
+ EFI_INPUT_KEY Key;
+ CHAR16 *StringBuffer1;
+ CHAR16 *StringBuffer2;
+ EFI_STATUS Status;
+ EDKII_FORM_BROWSER_EXTENSION2_PROTOCOL *FormBrowserEx2;
//
// Use BrowserEx2 protocol to check whether reset is required.
//
- Status = gBS->LocateProtocol (&gEdkiiFormBrowserEx2ProtocolGuid, NULL, (VOID **) &FormBrowserEx2);
+ Status = gBS->LocateProtocol (&gEdkiiFormBrowserEx2ProtocolGuid, NULL, (VOID **)&FormBrowserEx2);
//
- //check any reset required change is applied? if yes, reset system
+ // check any reset required change is applied? if yes, reset system
//
- if (!EFI_ERROR(Status) && FormBrowserEx2->IsResetRequired ()) {
+ if (!EFI_ERROR (Status) && FormBrowserEx2->IsResetRequired ()) {
StringBuffer1 = AllocateZeroPool (MAX_STRING_LEN * sizeof (CHAR16));
ASSERT (StringBuffer1 != NULL);
StringBuffer2 = AllocateZeroPool (MAX_STRING_LEN * sizeof (CHAR16));
@@ -352,20 +359,20 @@ GroupMultipleLegacyBootOption4SameType ( VOID
)
{
- EFI_STATUS Status;
- UINTN Index;
- UINTN DeviceIndex;
- UINTN DeviceTypeIndex[7];
- UINTN *NextIndex;
- UINT16 OptionNumber;
- UINT16 *BootOrder;
- UINTN BootOrderSize;
- CHAR16 OptionName[sizeof ("Boot####")];
- EFI_BOOT_MANAGER_LOAD_OPTION BootOption;
+ EFI_STATUS Status;
+ UINTN Index;
+ UINTN DeviceIndex;
+ UINTN DeviceTypeIndex[7];
+ UINTN *NextIndex;
+ UINT16 OptionNumber;
+ UINT16 *BootOrder;
+ UINTN BootOrderSize;
+ CHAR16 OptionName[sizeof ("Boot####")];
+ EFI_BOOT_MANAGER_LOAD_OPTION BootOption;
SetMem (DeviceTypeIndex, sizeof (DeviceTypeIndex), 0xff);
- GetEfiGlobalVariable2 (L"BootOrder", (VOID **) &BootOrder, &BootOrderSize);
+ GetEfiGlobalVariable2 (L"BootOrder", (VOID **)&BootOrder, &BootOrderSize);
if (BootOrder == NULL) {
return;
}
@@ -376,15 +383,16 @@ GroupMultipleLegacyBootOption4SameType ( ASSERT_EFI_ERROR (Status);
if ((DevicePathType (BootOption.FilePath) == BBS_DEVICE_PATH) &&
- (DevicePathSubType (BootOption.FilePath) == BBS_BBS_DP)) {
+ (DevicePathSubType (BootOption.FilePath) == BBS_BBS_DP))
+ {
//
// Legacy Boot Option
//
DEBUG ((DEBUG_ERROR, "[BootManagerDxe] ==== Find Legacy Boot Option 0x%x! ==== \n", Index));
- ASSERT ((((BBS_BBS_DEVICE_PATH *) BootOption.FilePath)->DeviceType & 0xF) < ARRAY_SIZE (DeviceTypeIndex));
- NextIndex = &DeviceTypeIndex[((BBS_BBS_DEVICE_PATH *) BootOption.FilePath)->DeviceType & 0xF];
+ ASSERT ((((BBS_BBS_DEVICE_PATH *)BootOption.FilePath)->DeviceType & 0xF) < ARRAY_SIZE (DeviceTypeIndex));
+ NextIndex = &DeviceTypeIndex[((BBS_BBS_DEVICE_PATH *)BootOption.FilePath)->DeviceType & 0xF];
- if (*NextIndex == (UINTN) -1) {
+ if (*NextIndex == (UINTN)-1) {
//
// *NextIndex is the Index in BootOrder to put the next Option Number for the same type
//
@@ -401,12 +409,13 @@ GroupMultipleLegacyBootOption4SameType ( // Update the DeviceTypeIndex array to reflect the right shift operation
//
for (DeviceIndex = 0; DeviceIndex < ARRAY_SIZE (DeviceTypeIndex); DeviceIndex++) {
- if (DeviceTypeIndex[DeviceIndex] != (UINTN) -1 && DeviceTypeIndex[DeviceIndex] >= *NextIndex) {
+ if ((DeviceTypeIndex[DeviceIndex] != (UINTN)-1) && (DeviceTypeIndex[DeviceIndex] >= *NextIndex)) {
DeviceTypeIndex[DeviceIndex]++;
}
}
}
}
+
EfiBootManagerFreeLoadOption (&BootOption);
}
@@ -430,12 +439,12 @@ GroupMultipleLegacyBootOption4SameType ( **/
CHAR16 *
BmDevicePathToStr (
- IN EFI_DEVICE_PATH_PROTOCOL *DevPath
+ IN EFI_DEVICE_PATH_PROTOCOL *DevPath
)
{
- EFI_STATUS Status;
- CHAR16 *ToText;
- EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *DevPathToText;
+ EFI_STATUS Status;
+ CHAR16 *ToText;
+ EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *DevPathToText;
if (DevPath == NULL) {
return NULL;
@@ -444,7 +453,7 @@ BmDevicePathToStr ( Status = gBS->LocateProtocol (
&gEfiDevicePathToTextProtocolGuid,
NULL,
- (VOID **) &DevPathToText
+ (VOID **)&DevPathToText
);
ASSERT_EFI_ERROR (Status);
ToText = DevPathToText->ConvertDevicePathToText (
@@ -485,7 +494,7 @@ UpdateBootManager ( BOOLEAN NeedEndOp;
UINTN MaxLen;
- DeviceType = (UINT16) -1;
+ DeviceType = (UINT16)-1;
//
// for better user experience
@@ -516,18 +525,18 @@ UpdateBootManager ( //
// Create Hii Extend Label OpCode as the start opcode
//
- StartLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (StartOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));
+ StartLabel = (EFI_IFR_GUID_LABEL *)HiiCreateGuidOpCode (StartOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));
StartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;
StartLabel->Number = LABEL_BOOT_OPTION;
//
// Create Hii Extend Label OpCode as the end opcode
//
- EndLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (EndOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));
+ EndLabel = (EFI_IFR_GUID_LABEL *)HiiCreateGuidOpCode (EndOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));
EndLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;
EndLabel->Number = LABEL_BOOT_OPTION_END;
- mKeyInput = 0;
- NeedEndOp = FALSE;
+ mKeyInput = 0;
+ NeedEndOp = FALSE;
for (Index = 0; Index < BootOptionCount; Index++) {
//
// At this stage we are creating a menu entry, thus the Keys are reproduceable
@@ -544,28 +553,28 @@ UpdateBootManager ( //
// Group the legacy boot option in the sub title created dynamically
//
- IsLegacyOption = (BOOLEAN) (
- (DevicePathType (BootOption[Index].FilePath) == BBS_DEVICE_PATH) &&
- (DevicePathSubType (BootOption[Index].FilePath) == BBS_BBS_DP)
- );
+ IsLegacyOption = (BOOLEAN)(
+ (DevicePathType (BootOption[Index].FilePath) == BBS_DEVICE_PATH) &&
+ (DevicePathSubType (BootOption[Index].FilePath) == BBS_BBS_DP)
+ );
if (!IsLegacyOption && NeedEndOp) {
NeedEndOp = FALSE;
HiiCreateEndOpCode (StartOpCodeHandle);
}
- if (IsLegacyOption && DeviceType != ((BBS_BBS_DEVICE_PATH *) BootOption[Index].FilePath)->DeviceType) {
+ if (IsLegacyOption && (DeviceType != ((BBS_BBS_DEVICE_PATH *)BootOption[Index].FilePath)->DeviceType)) {
if (NeedEndOp) {
HiiCreateEndOpCode (StartOpCodeHandle);
}
- DeviceType = ((BBS_BBS_DEVICE_PATH *) BootOption[Index].FilePath)->DeviceType;
+ DeviceType = ((BBS_BBS_DEVICE_PATH *)BootOption[Index].FilePath)->DeviceType;
Token = HiiSetString (
HiiHandle,
0,
mDeviceTypeStr[
- MIN (DeviceType & 0xF, ARRAY_SIZE (mDeviceTypeStr) - 1)
- ],
+ MIN (DeviceType & 0xF, ARRAY_SIZE (mDeviceTypeStr) - 1)
+ ],
NULL
);
HiiCreateSubTitleOpCode (StartOpCodeHandle, Token, 0, 0, 1);
@@ -576,10 +585,10 @@ UpdateBootManager ( Token = HiiSetString (HiiHandle, 0, BootOption[Index].Description, NULL);
- TempStr = BmDevicePathToStr (BootOption[Index].FilePath);
- TempSize = StrSize (TempStr);
+ TempStr = BmDevicePathToStr (BootOption[Index].FilePath);
+ TempSize = StrSize (TempStr);
HelpString = AllocateZeroPool (TempSize + StrSize (L"Device Path : "));
- MaxLen = (TempSize + StrSize (L"Device Path : "))/sizeof(CHAR16);
+ MaxLen = (TempSize + StrSize (L"Device Path : "))/sizeof (CHAR16);
ASSERT (HelpString != NULL);
StrCatS (HelpString, MaxLen, L"Device Path : ");
StrCatS (HelpString, MaxLen, TempStr);
@@ -639,15 +648,16 @@ UpdateBootManager ( EFI_STATUS
EFIAPI
BootManagerExtractConfig (
- IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
- IN CONST EFI_STRING Request,
- OUT EFI_STRING *Progress,
- OUT EFI_STRING *Results
+ IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
+ IN CONST EFI_STRING Request,
+ OUT EFI_STRING *Progress,
+ OUT EFI_STRING *Results
)
{
- if (Progress == NULL || Results == NULL) {
+ if ((Progress == NULL) || (Results == NULL)) {
return EFI_INVALID_PARAMETER;
}
+
*Progress = Request;
return EFI_NOT_FOUND;
}
@@ -671,12 +681,12 @@ BootManagerExtractConfig ( EFI_STATUS
EFIAPI
BootManagerRouteConfig (
- IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
- IN CONST EFI_STRING Configuration,
- OUT EFI_STRING *Progress
+ IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
+ IN CONST EFI_STRING Configuration,
+ OUT EFI_STRING *Progress
)
{
- if (Configuration == NULL || Progress == NULL) {
+ if ((Configuration == NULL) || (Progress == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -694,11 +704,11 @@ BmInitialBootModeInfo ( VOID
)
{
- EFI_STATUS Status;
- EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
- EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *SimpleTextOut;
- UINTN BootTextColumn;
- UINTN BootTextRow;
+ EFI_STATUS Status;
+ EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
+ EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *SimpleTextOut;
+ UINTN BootTextColumn;
+ UINTN BootTextRow;
if (mBmModeInitialized) {
return;
@@ -711,7 +721,7 @@ BmInitialBootModeInfo ( Status = gBS->HandleProtocol (
gST->ConsoleOutHandle,
&gEfiGraphicsOutputProtocolGuid,
- (VOID**)&GraphicsOutput
+ (VOID **)&GraphicsOutput
);
if (EFI_ERROR (Status)) {
GraphicsOutput = NULL;
@@ -720,7 +730,7 @@ BmInitialBootModeInfo ( Status = gBS->HandleProtocol (
gST->ConsoleOutHandle,
&gEfiSimpleTextOutProtocolGuid,
- (VOID**)&SimpleTextOut
+ (VOID **)&SimpleTextOut
);
if (EFI_ERROR (Status)) {
SimpleTextOut = NULL;
@@ -753,7 +763,7 @@ BmInitialBootModeInfo ( mBmSetupTextModeColumn = PcdGet32 (PcdSetupConOutColumn);
mBmSetupTextModeRow = PcdGet32 (PcdSetupConOutRow);
- mBmModeInitialized = TRUE;
+ mBmModeInitialized = TRUE;
}
/**
@@ -777,26 +787,27 @@ BmInitialBootModeInfo ( EFI_STATUS
EFIAPI
BootManagerCallback (
- IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
- IN EFI_BROWSER_ACTION Action,
- IN EFI_QUESTION_ID QuestionId,
- IN UINT8 Type,
- IN EFI_IFR_TYPE_VALUE *Value,
- OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
+ IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
+ IN EFI_BROWSER_ACTION Action,
+ IN EFI_QUESTION_ID QuestionId,
+ IN UINT8 Type,
+ IN EFI_IFR_TYPE_VALUE *Value,
+ OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
)
{
- EFI_BOOT_MANAGER_LOAD_OPTION *BootOption;
- UINTN BootOptionCount;
- EFI_INPUT_KEY Key;
+ EFI_BOOT_MANAGER_LOAD_OPTION *BootOption;
+ UINTN BootOptionCount;
+ EFI_INPUT_KEY Key;
if (Action == EFI_BROWSER_ACTION_FORM_OPEN) {
//
- //Means enter the boot manager form.
- //Update the boot manage page,because the boot option may changed.
+ // Means enter the boot manager form.
+ // Update the boot manage page,because the boot option may changed.
//
- if (QuestionId == 0x1212){
- UpdateBootManager();
+ if (QuestionId == 0x1212) {
+ UpdateBootManager ();
}
+
return EFI_SUCCESS;
}
@@ -820,7 +831,7 @@ BootManagerCallback ( gST->ConOut->ClearScreen (gST->ConOut);
//
- //check any reset required change is applied? if yes, reset system
+ // check any reset required change is applied? if yes, reset system
//
BmSetupResetReminder ();
@@ -833,9 +844,9 @@ BootManagerCallback ( if (EFI_ERROR (BootOption[QuestionId - 1].Status)) {
gST->ConOut->OutputString (
- gST->ConOut,
- HiiGetString (gBootManagerPrivate.HiiHandle, STRING_TOKEN (STR_ANY_KEY_CONTINUE), NULL)
- );
+ gST->ConOut,
+ HiiGetString (gBootManagerPrivate.HiiHandle, STRING_TOKEN (STR_ANY_KEY_CONTINUE), NULL)
+ );
gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);
}
@@ -858,24 +869,24 @@ BootManagerCallback ( EFI_STATUS
EFIAPI
BootManagerUiLibConstructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
//
// Install Device Path Protocol and Config Access protocol to driver handle
//
gBootManagerPrivate.DriverHandle = NULL;
- Status = gBS->InstallMultipleProtocolInterfaces (
- &gBootManagerPrivate.DriverHandle,
- &gEfiDevicePathProtocolGuid,
- &mBootManagerHiiVendorDevicePath,
- &gEfiHiiConfigAccessProtocolGuid,
- &gBootManagerPrivate.ConfigAccess,
- NULL
- );
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &gBootManagerPrivate.DriverHandle,
+ &gEfiDevicePathProtocolGuid,
+ &mBootManagerHiiVendorDevicePath,
+ &gEfiHiiConfigAccessProtocolGuid,
+ &gBootManagerPrivate.ConfigAccess,
+ NULL
+ );
ASSERT_EFI_ERROR (Status);
//
@@ -906,11 +917,11 @@ BootManagerUiLibConstructor ( EFI_STATUS
EFIAPI
BootManagerUiLibDestructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
Status = gBS->UninstallMultipleProtocolInterfaces (
gBootManagerPrivate.DriverHandle,
diff --git a/MdeModulePkg/Library/BootManagerUiLib/BootManager.h b/MdeModulePkg/Library/BootManagerUiLib/BootManager.h index f1ee922b37..0076a9dfce 100644 --- a/MdeModulePkg/Library/BootManagerUiLib/BootManager.h +++ b/MdeModulePkg/Library/BootManagerUiLib/BootManager.h @@ -33,8 +33,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent /// HII specific Vendor Device Path definition.
///
typedef struct {
- VENDOR_DEVICE_PATH VendorDevicePath;
- EFI_DEVICE_PATH_PROTOCOL End;
+ VENDOR_DEVICE_PATH VendorDevicePath;
+ EFI_DEVICE_PATH_PROTOCOL End;
} HII_VENDOR_DEVICE_PATH;
#pragma pack()
@@ -46,11 +46,11 @@ typedef struct { 0x847bc3fe, 0xb974, 0x446d, {0x94, 0x49, 0x5a, 0xd5, 0x41, 0x2e, 0x99, 0x3b} \
}
-#define BOOT_MANAGER_FORM_ID 0x1000
+#define BOOT_MANAGER_FORM_ID 0x1000
-#define LABEL_BOOT_OPTION 0x00
-#define LABEL_BOOT_OPTION_END 0x01
-#define MAX_STRING_LEN 200
+#define LABEL_BOOT_OPTION 0x00
+#define LABEL_BOOT_OPTION_END 0x01
+#define MAX_STRING_LEN 200
//
// Variable created with this flag will be "Efi:...."
@@ -60,23 +60,23 @@ typedef struct { //
// These are the VFR compiler generated data representing our VFR data.
//
-extern UINT8 BootManagerVfrBin[];
+extern UINT8 BootManagerVfrBin[];
#define BOOT_MANAGER_CALLBACK_DATA_SIGNATURE SIGNATURE_32 ('B', 'M', 'C', 'B')
typedef struct {
- UINTN Signature;
+ UINTN Signature;
//
// HII relative handles
//
- EFI_HII_HANDLE HiiHandle;
- EFI_HANDLE DriverHandle;
+ EFI_HII_HANDLE HiiHandle;
+ EFI_HANDLE DriverHandle;
//
// Produced protocols
//
- EFI_HII_CONFIG_ACCESS_PROTOCOL ConfigAccess;
+ EFI_HII_CONFIG_ACCESS_PROTOCOL ConfigAccess;
} BOOT_MANAGER_CALLBACK_DATA;
/**
@@ -100,12 +100,12 @@ typedef struct { EFI_STATUS
EFIAPI
BootManagerCallback (
- IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
- IN EFI_BROWSER_ACTION Action,
- IN EFI_QUESTION_ID QuestionId,
- IN UINT8 Type,
- IN EFI_IFR_TYPE_VALUE *Value,
- OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
+ IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
+ IN EFI_BROWSER_ACTION Action,
+ IN EFI_QUESTION_ID QuestionId,
+ IN UINT8 Type,
+ IN EFI_IFR_TYPE_VALUE *Value,
+ OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
);
/**
@@ -133,10 +133,10 @@ BootManagerCallback ( EFI_STATUS
EFIAPI
BootManagerExtractConfig (
- IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
- IN CONST EFI_STRING Request,
- OUT EFI_STRING *Progress,
- OUT EFI_STRING *Results
+ IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
+ IN CONST EFI_STRING Request,
+ OUT EFI_STRING *Progress,
+ OUT EFI_STRING *Results
);
/**
@@ -158,9 +158,9 @@ BootManagerExtractConfig ( EFI_STATUS
EFIAPI
BootManagerRouteConfig (
- IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
- IN CONST EFI_STRING Configuration,
- OUT EFI_STRING *Progress
+ IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
+ IN CONST EFI_STRING Configuration,
+ OUT EFI_STRING *Progress
);
#endif
diff --git a/MdeModulePkg/Library/BrotliCustomDecompressLib/BrotliDecUefiSupport.c b/MdeModulePkg/Library/BrotliCustomDecompressLib/BrotliDecUefiSupport.c index 102146535b..f89db846ef 100644 --- a/MdeModulePkg/Library/BrotliCustomDecompressLib/BrotliDecUefiSupport.c +++ b/MdeModulePkg/Library/BrotliCustomDecompressLib/BrotliDecUefiSupport.c @@ -12,7 +12,7 @@ **/
VOID *
BrDummyMalloc (
- IN size_t Size
+ IN size_t Size
)
{
ASSERT (FALSE);
@@ -24,7 +24,7 @@ BrDummyMalloc ( **/
VOID
BrDummyFree (
- IN VOID * Ptr
+ IN VOID *Ptr
)
{
ASSERT (FALSE);
diff --git a/MdeModulePkg/Library/BrotliCustomDecompressLib/BrotliDecUefiSupport.h b/MdeModulePkg/Library/BrotliCustomDecompressLib/BrotliDecUefiSupport.h index 9f84347670..71e76bcbf2 100644 --- a/MdeModulePkg/Library/BrotliCustomDecompressLib/BrotliDecUefiSupport.h +++ b/MdeModulePkg/Library/BrotliCustomDecompressLib/BrotliDecUefiSupport.h @@ -14,30 +14,30 @@ #include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
-#define memcpy CopyMem
-#define memmove CopyMem
-#define memset(dest,ch,count) SetMem(dest,(UINTN)(count),(UINT8)(ch))
-#define malloc BrDummyMalloc
-#define free BrDummyFree
-
-typedef INT8 int8_t;
-typedef INT16 int16_t;
-typedef INT32 int32_t;
-typedef INT64 int64_t;
-typedef UINT8 uint8_t;
-typedef UINT16 uint16_t;
-typedef UINT32 uint32_t;
-typedef UINT64 uint64_t;
-typedef UINTN size_t;
+#define memcpy CopyMem
+#define memmove CopyMem
+#define memset(dest, ch, count) SetMem(dest,(UINTN)(count),(UINT8)(ch))
+#define malloc BrDummyMalloc
+#define free BrDummyFree
+
+typedef INT8 int8_t;
+typedef INT16 int16_t;
+typedef INT32 int32_t;
+typedef INT64 int64_t;
+typedef UINT8 uint8_t;
+typedef UINT16 uint16_t;
+typedef UINT32 uint32_t;
+typedef UINT64 uint64_t;
+typedef UINTN size_t;
VOID *
BrDummyMalloc (
- IN size_t Size
+ IN size_t Size
);
VOID
BrDummyFree (
- IN VOID * Ptr
+ IN VOID *Ptr
);
#endif
diff --git a/MdeModulePkg/Library/BrotliCustomDecompressLib/BrotliDecompress.c b/MdeModulePkg/Library/BrotliCustomDecompressLib/BrotliDecompress.c index 53e2255f5f..3cb31ab984 100644 --- a/MdeModulePkg/Library/BrotliCustomDecompressLib/BrotliDecompress.c +++ b/MdeModulePkg/Library/BrotliCustomDecompressLib/BrotliDecompress.c @@ -17,18 +17,18 @@ **/
VOID *
BrAlloc (
- IN VOID * Ptr,
- IN size_t Size
+ IN VOID *Ptr,
+ IN size_t Size
)
{
- VOID *Addr;
- BROTLI_BUFF *Private;
+ VOID *Addr;
+ BROTLI_BUFF *Private;
Private = (BROTLI_BUFF *)Ptr;
if (Private->BuffSize >= Size) {
- Addr = Private->Buff;
- Private->Buff = (VOID *) ((UINT8 *)Addr + Size);
+ Addr = Private->Buff;
+ Private->Buff = (VOID *)((UINT8 *)Addr + Size);
Private->BuffSize -= Size;
return Addr;
} else {
@@ -45,8 +45,8 @@ BrAlloc ( **/
VOID
BrFree (
- IN VOID * Ptr,
- IN VOID * Address
+ IN VOID *Ptr,
+ IN VOID *Address
)
{
//
@@ -79,83 +79,89 @@ BrFree ( **/
EFI_STATUS
BrotliDecompress (
- IN CONST VOID* Source,
- IN UINTN SourceSize,
- IN OUT VOID* Destination,
- IN OUT UINTN DestSize,
- IN VOID * BuffInfo
+ IN CONST VOID *Source,
+ IN UINTN SourceSize,
+ IN OUT VOID *Destination,
+ IN OUT UINTN DestSize,
+ IN VOID *BuffInfo
)
{
- UINT8 * Input;
- UINT8 * Output;
- const UINT8 * NextIn;
- UINT8 * NextOut;
- size_t TotalOut;
- size_t AvailableIn;
- size_t AvailableOut;
- VOID * Temp;
- BrotliDecoderResult Result;
- BrotliDecoderState * BroState;
-
- TotalOut = 0;
+ UINT8 *Input;
+ UINT8 *Output;
+ const UINT8 *NextIn;
+ UINT8 *NextOut;
+ size_t TotalOut;
+ size_t AvailableIn;
+ size_t AvailableOut;
+ VOID *Temp;
+ BrotliDecoderResult Result;
+ BrotliDecoderState *BroState;
+
+ TotalOut = 0;
AvailableOut = FILE_BUFFER_SIZE;
- Result = BROTLI_DECODER_RESULT_ERROR;
- BroState = BrotliDecoderCreateInstance(BrAlloc, BrFree, BuffInfo);
- Temp = Destination;
+ Result = BROTLI_DECODER_RESULT_ERROR;
+ BroState = BrotliDecoderCreateInstance (BrAlloc, BrFree, BuffInfo);
+ Temp = Destination;
if (BroState == NULL) {
return EFI_INVALID_PARAMETER;
}
- Input = (UINT8 *)BrAlloc(BuffInfo, FILE_BUFFER_SIZE);
- Output = (UINT8 *)BrAlloc(BuffInfo, FILE_BUFFER_SIZE);
- if ((Input==NULL) || (Output==NULL)) {
- BrFree(BuffInfo, Input);
- BrFree(BuffInfo, Output);
- BrotliDecoderDestroyInstance(BroState);
+
+ Input = (UINT8 *)BrAlloc (BuffInfo, FILE_BUFFER_SIZE);
+ Output = (UINT8 *)BrAlloc (BuffInfo, FILE_BUFFER_SIZE);
+ if ((Input == NULL) || (Output == NULL)) {
+ BrFree (BuffInfo, Input);
+ BrFree (BuffInfo, Output);
+ BrotliDecoderDestroyInstance (BroState);
return EFI_INVALID_PARAMETER;
}
+
NextOut = Output;
- Result = BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT;
+ Result = BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT;
while (1) {
if (Result == BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT) {
if (SourceSize == 0) {
break;
}
+
if (SourceSize >= FILE_BUFFER_SIZE) {
AvailableIn = FILE_BUFFER_SIZE;
- }else{
+ } else {
AvailableIn = SourceSize;
}
- CopyMem(Input, Source, AvailableIn);
- Source = (VOID *)((UINT8 *)Source + AvailableIn);
+
+ CopyMem (Input, Source, AvailableIn);
+ Source = (VOID *)((UINT8 *)Source + AvailableIn);
SourceSize -= AvailableIn;
- NextIn = Input;
+ NextIn = Input;
} else if (Result == BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT) {
- CopyMem(Temp, Output, FILE_BUFFER_SIZE);
+ CopyMem (Temp, Output, FILE_BUFFER_SIZE);
AvailableOut = FILE_BUFFER_SIZE;
- Temp = (VOID *)((UINT8 *)Temp +FILE_BUFFER_SIZE);
- NextOut = Output;
+ Temp = (VOID *)((UINT8 *)Temp +FILE_BUFFER_SIZE);
+ NextOut = Output;
} else {
break; /* Error or success. */
}
- Result = BrotliDecoderDecompressStream(
- BroState,
- &AvailableIn,
- &NextIn,
- &AvailableOut,
- &NextOut,
- &TotalOut
- );
+
+ Result = BrotliDecoderDecompressStream (
+ BroState,
+ &AvailableIn,
+ &NextIn,
+ &AvailableOut,
+ &NextOut,
+ &TotalOut
+ );
}
+
if (NextOut != Output) {
- CopyMem(Temp, Output, (size_t)(NextOut - Output));
+ CopyMem (Temp, Output, (size_t)(NextOut - Output));
}
DestSize = TotalOut;
- BrFree(BuffInfo, Input);
- BrFree(BuffInfo, Output);
- BrotliDecoderDestroyInstance(BroState);
+ BrFree (BuffInfo, Input);
+ BrFree (BuffInfo, Output);
+ BrotliDecoderDestroyInstance (BroState);
return (Result == BROTLI_DECODER_RESULT_SUCCESS) ? EFI_SUCCESS : EFI_INVALID_PARAMETER;
}
@@ -169,19 +175,20 @@ BrotliDecompress ( @return The size of the uncompressed buffer.
**/
UINT64
-BrGetDecodedSizeOfBuf(
- IN UINT8 * EncodedData,
- IN UINT8 StartOffset,
- IN UINT8 EndOffset
+BrGetDecodedSizeOfBuf (
+ IN UINT8 *EncodedData,
+ IN UINT8 StartOffset,
+ IN UINT8 EndOffset
)
{
- UINT64 DecodedSize;
- INTN Index;
+ UINT64 DecodedSize;
+ INTN Index;
/* Parse header */
DecodedSize = 0;
- for (Index = EndOffset - 1; Index >= StartOffset; Index--)
- DecodedSize = LShiftU64(DecodedSize, 8) + EncodedData[Index];
+ for (Index = EndOffset - 1; Index >= StartOffset; Index--) {
+ DecodedSize = LShiftU64 (DecodedSize, 8) + EncodedData[Index];
+ }
return DecodedSize;
}
@@ -218,23 +225,23 @@ BrGetDecodedSizeOfBuf( EFI_STATUS
EFIAPI
BrotliUefiDecompressGetInfo (
- IN CONST VOID * Source,
- IN UINT32 SourceSize,
- OUT UINT32 * DestinationSize,
- OUT UINT32 * ScratchSize
+ IN CONST VOID *Source,
+ IN UINT32 SourceSize,
+ OUT UINT32 *DestinationSize,
+ OUT UINT32 *ScratchSize
)
{
UINT64 GetSize;
UINT8 MaxOffset;
- ASSERT(SourceSize >= BROTLI_SCRATCH_MAX);
+ ASSERT (SourceSize >= BROTLI_SCRATCH_MAX);
- MaxOffset = BROTLI_DECODE_MAX;
- GetSize = BrGetDecodedSizeOfBuf((UINT8 *)Source, MaxOffset - BROTLI_INFO_SIZE, MaxOffset);
+ MaxOffset = BROTLI_DECODE_MAX;
+ GetSize = BrGetDecodedSizeOfBuf ((UINT8 *)Source, MaxOffset - BROTLI_INFO_SIZE, MaxOffset);
*DestinationSize = (UINT32)GetSize;
- MaxOffset = BROTLI_SCRATCH_MAX;
- GetSize = BrGetDecodedSizeOfBuf((UINT8 *)Source, MaxOffset - BROTLI_INFO_SIZE, MaxOffset);
- *ScratchSize = (UINT32)GetSize;
+ MaxOffset = BROTLI_SCRATCH_MAX;
+ GetSize = BrGetDecodedSizeOfBuf ((UINT8 *)Source, MaxOffset - BROTLI_INFO_SIZE, MaxOffset);
+ *ScratchSize = (UINT32)GetSize;
return EFI_SUCCESS;
}
@@ -263,31 +270,31 @@ BrotliUefiDecompressGetInfo ( EFI_STATUS
EFIAPI
BrotliUefiDecompress (
- IN CONST VOID * Source,
- IN UINTN SourceSize,
- IN OUT VOID * Destination,
- IN OUT VOID * Scratch
+ IN CONST VOID *Source,
+ IN UINTN SourceSize,
+ IN OUT VOID *Destination,
+ IN OUT VOID *Scratch
)
{
- UINTN DestSize = 0;
- EFI_STATUS Status;
- BROTLI_BUFF BroBuff;
- UINT64 GetSize;
- UINT8 MaxOffset;
+ UINTN DestSize = 0;
+ EFI_STATUS Status;
+ BROTLI_BUFF BroBuff;
+ UINT64 GetSize;
+ UINT8 MaxOffset;
MaxOffset = BROTLI_SCRATCH_MAX;
- GetSize = BrGetDecodedSizeOfBuf((UINT8 *)Source, MaxOffset - BROTLI_INFO_SIZE, MaxOffset);
+ GetSize = BrGetDecodedSizeOfBuf ((UINT8 *)Source, MaxOffset - BROTLI_INFO_SIZE, MaxOffset);
BroBuff.Buff = Scratch;
BroBuff.BuffSize = (UINTN)GetSize;
- Status = BrotliDecompress(
- (VOID *)((UINT8 *)Source + BROTLI_SCRATCH_MAX),
- SourceSize - BROTLI_SCRATCH_MAX,
- Destination,
- DestSize,
- (VOID *)(&BroBuff)
- );
+ Status = BrotliDecompress (
+ (VOID *)((UINT8 *)Source + BROTLI_SCRATCH_MAX),
+ SourceSize - BROTLI_SCRATCH_MAX,
+ Destination,
+ DestSize,
+ (VOID *)(&BroBuff)
+ );
return Status;
}
diff --git a/MdeModulePkg/Library/BrotliCustomDecompressLib/BrotliDecompressLibInternal.h b/MdeModulePkg/Library/BrotliCustomDecompressLib/BrotliDecompressLibInternal.h index 8f91829a0e..312a5ede52 100644 --- a/MdeModulePkg/Library/BrotliCustomDecompressLib/BrotliDecompressLibInternal.h +++ b/MdeModulePkg/Library/BrotliCustomDecompressLib/BrotliDecompressLibInternal.h @@ -16,16 +16,15 @@ #include <brotli/c/include/brotli/types.h>
#include <brotli/c/include/brotli/decode.h>
-typedef struct
-{
+typedef struct {
VOID *Buff;
UINTN BuffSize;
} BROTLI_BUFF;
-#define FILE_BUFFER_SIZE 65536
-#define BROTLI_INFO_SIZE 8
-#define BROTLI_DECODE_MAX 8
-#define BROTLI_SCRATCH_MAX 16
+#define FILE_BUFFER_SIZE 65536
+#define BROTLI_INFO_SIZE 8
+#define BROTLI_DECODE_MAX 8
+#define BROTLI_SCRATCH_MAX 16
EFI_STATUS
EFIAPI
diff --git a/MdeModulePkg/Library/BrotliCustomDecompressLib/GuidedSectionExtraction.c b/MdeModulePkg/Library/BrotliCustomDecompressLib/GuidedSectionExtraction.c index fd5a0d7cdb..262f218f1f 100644 --- a/MdeModulePkg/Library/BrotliCustomDecompressLib/GuidedSectionExtraction.c +++ b/MdeModulePkg/Library/BrotliCustomDecompressLib/GuidedSectionExtraction.c @@ -59,31 +59,35 @@ BrotliGuidedSectionGetInfo ( if (IS_SECTION2 (InputSection)) {
if (!CompareGuid (
- &gBrotliCustomDecompressGuid,
- &(((EFI_GUID_DEFINED_SECTION2 *) InputSection)->SectionDefinitionGuid))) {
+ &gBrotliCustomDecompressGuid,
+ &(((EFI_GUID_DEFINED_SECTION2 *)InputSection)->SectionDefinitionGuid)
+ ))
+ {
return RETURN_INVALID_PARAMETER;
}
- *SectionAttribute = ((EFI_GUID_DEFINED_SECTION2 *) InputSection)->Attributes;
+ *SectionAttribute = ((EFI_GUID_DEFINED_SECTION2 *)InputSection)->Attributes;
return BrotliUefiDecompressGetInfo (
- (UINT8 *) InputSection + ((EFI_GUID_DEFINED_SECTION2 *) InputSection)->DataOffset,
- SECTION2_SIZE (InputSection) - ((EFI_GUID_DEFINED_SECTION2 *) InputSection)->DataOffset,
+ (UINT8 *)InputSection + ((EFI_GUID_DEFINED_SECTION2 *)InputSection)->DataOffset,
+ SECTION2_SIZE (InputSection) - ((EFI_GUID_DEFINED_SECTION2 *)InputSection)->DataOffset,
OutputBufferSize,
ScratchBufferSize
);
} else {
if (!CompareGuid (
- &gBrotliCustomDecompressGuid,
- &(((EFI_GUID_DEFINED_SECTION *) InputSection)->SectionDefinitionGuid))) {
+ &gBrotliCustomDecompressGuid,
+ &(((EFI_GUID_DEFINED_SECTION *)InputSection)->SectionDefinitionGuid)
+ ))
+ {
return RETURN_INVALID_PARAMETER;
}
- *SectionAttribute = ((EFI_GUID_DEFINED_SECTION *) InputSection)->Attributes;
+ *SectionAttribute = ((EFI_GUID_DEFINED_SECTION *)InputSection)->Attributes;
return BrotliUefiDecompressGetInfo (
- (UINT8 *) InputSection + ((EFI_GUID_DEFINED_SECTION *) InputSection)->DataOffset,
- SECTION_SIZE (InputSection) - ((EFI_GUID_DEFINED_SECTION *) InputSection)->DataOffset,
+ (UINT8 *)InputSection + ((EFI_GUID_DEFINED_SECTION *)InputSection)->DataOffset,
+ SECTION_SIZE (InputSection) - ((EFI_GUID_DEFINED_SECTION *)InputSection)->DataOffset,
OutputBufferSize,
ScratchBufferSize
);
@@ -136,38 +140,44 @@ BrotliGuidedSectionExtraction ( if (IS_SECTION2 (InputSection)) {
if (!CompareGuid (
- &gBrotliCustomDecompressGuid,
- &(((EFI_GUID_DEFINED_SECTION2 *) InputSection)->SectionDefinitionGuid))) {
+ &gBrotliCustomDecompressGuid,
+ &(((EFI_GUID_DEFINED_SECTION2 *)InputSection)->SectionDefinitionGuid)
+ ))
+ {
return RETURN_INVALID_PARAMETER;
}
+
//
// Authentication is set to Zero, which may be ignored.
//
*AuthenticationStatus = 0;
return BrotliUefiDecompress (
- (UINT8 *) InputSection + ((EFI_GUID_DEFINED_SECTION2 *) InputSection)->DataOffset,
- SECTION2_SIZE (InputSection) - ((EFI_GUID_DEFINED_SECTION2 *) InputSection)->DataOffset,
+ (UINT8 *)InputSection + ((EFI_GUID_DEFINED_SECTION2 *)InputSection)->DataOffset,
+ SECTION2_SIZE (InputSection) - ((EFI_GUID_DEFINED_SECTION2 *)InputSection)->DataOffset,
*OutputBuffer,
ScratchBuffer
);
} else {
if (!CompareGuid (
- &gBrotliCustomDecompressGuid,
- &(((EFI_GUID_DEFINED_SECTION *) InputSection)->SectionDefinitionGuid))) {
+ &gBrotliCustomDecompressGuid,
+ &(((EFI_GUID_DEFINED_SECTION *)InputSection)->SectionDefinitionGuid)
+ ))
+ {
return RETURN_INVALID_PARAMETER;
}
+
//
// Authentication is set to Zero, which may be ignored.
//
*AuthenticationStatus = 0;
return BrotliUefiDecompress (
- (UINT8 *) InputSection + ((EFI_GUID_DEFINED_SECTION *) InputSection)->DataOffset,
- SECTION_SIZE (InputSection) - ((EFI_GUID_DEFINED_SECTION *) InputSection)->DataOffset,
+ (UINT8 *)InputSection + ((EFI_GUID_DEFINED_SECTION *)InputSection)->DataOffset,
+ SECTION_SIZE (InputSection) - ((EFI_GUID_DEFINED_SECTION *)InputSection)->DataOffset,
*OutputBuffer,
ScratchBuffer
- );
+ );
}
}
@@ -184,8 +194,8 @@ BrotliDecompressLibConstructor ( )
{
return ExtractGuidedSectionRegisterHandlers (
- &gBrotliCustomDecompressGuid,
- BrotliGuidedSectionGetInfo,
- BrotliGuidedSectionExtraction
- );
+ &gBrotliCustomDecompressGuid,
+ BrotliGuidedSectionGetInfo,
+ BrotliGuidedSectionExtraction
+ );
}
diff --git a/MdeModulePkg/Library/CpuExceptionHandlerLibNull/CpuExceptionHandlerLibNull.c b/MdeModulePkg/Library/CpuExceptionHandlerLibNull/CpuExceptionHandlerLibNull.c index ecd0886dc4..35ab5a8db5 100644 --- a/MdeModulePkg/Library/CpuExceptionHandlerLibNull/CpuExceptionHandlerLibNull.c +++ b/MdeModulePkg/Library/CpuExceptionHandlerLibNull/CpuExceptionHandlerLibNull.c @@ -27,7 +27,7 @@ EFI_STATUS
EFIAPI
InitializeCpuExceptionHandlers (
- IN EFI_VECTOR_HANDOFF_INFO *VectorInfo OPTIONAL
+ IN EFI_VECTOR_HANDOFF_INFO *VectorInfo OPTIONAL
)
{
return EFI_SUCCESS;
@@ -52,7 +52,7 @@ InitializeCpuExceptionHandlers ( EFI_STATUS
EFIAPI
InitializeCpuInterruptHandlers (
- IN EFI_VECTOR_HANDOFF_INFO *VectorInfo OPTIONAL
+ IN EFI_VECTOR_HANDOFF_INFO *VectorInfo OPTIONAL
)
{
return EFI_SUCCESS;
@@ -84,8 +84,8 @@ InitializeCpuInterruptHandlers ( EFI_STATUS
EFIAPI
RegisterCpuInterruptHandler (
- IN EFI_EXCEPTION_TYPE InterruptType,
- IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler
+ IN EFI_EXCEPTION_TYPE InterruptType,
+ IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler
)
{
return EFI_UNSUPPORTED;
@@ -100,8 +100,8 @@ RegisterCpuInterruptHandler ( VOID
EFIAPI
DumpCpuContext (
- IN EFI_EXCEPTION_TYPE ExceptionType,
- IN EFI_SYSTEM_CONTEXT SystemContext
+ IN EFI_EXCEPTION_TYPE ExceptionType,
+ IN EFI_SYSTEM_CONTEXT SystemContext
)
{
}
@@ -132,10 +132,9 @@ DumpCpuContext ( EFI_STATUS
EFIAPI
InitializeCpuExceptionHandlersEx (
- IN EFI_VECTOR_HANDOFF_INFO *VectorInfo OPTIONAL,
- IN CPU_EXCEPTION_INIT_DATA *InitData OPTIONAL
+ IN EFI_VECTOR_HANDOFF_INFO *VectorInfo OPTIONAL,
+ IN CPU_EXCEPTION_INIT_DATA *InitData OPTIONAL
)
{
return InitializeCpuExceptionHandlers (VectorInfo);
}
-
diff --git a/MdeModulePkg/Library/CustomizedDisplayLib/Colors.h b/MdeModulePkg/Library/CustomizedDisplayLib/Colors.h index f2cbb8940f..487c6d4f2d 100644 --- a/MdeModulePkg/Library/CustomizedDisplayLib/Colors.h +++ b/MdeModulePkg/Library/CustomizedDisplayLib/Colors.h @@ -14,25 +14,25 @@ SPDX-License-Identifier: BSD-2-Clause-Patent //
// Screen Color Settings
//
-#define PICKLIST_HIGHLIGHT_TEXT EFI_WHITE
-#define PICKLIST_HIGHLIGHT_BACKGROUND EFI_BACKGROUND_CYAN
-#define TITLE_TEXT EFI_WHITE
-#define TITLE_BACKGROUND EFI_BACKGROUND_BLUE
-#define KEYHELP_TEXT EFI_LIGHTGRAY
-#define KEYHELP_BACKGROUND EFI_BACKGROUND_BLACK
-#define SUBTITLE_BACKGROUND EFI_BACKGROUND_LIGHTGRAY
-#define BANNER_TEXT EFI_BLUE
-#define BANNER_BACKGROUND EFI_BACKGROUND_LIGHTGRAY
-#define FIELD_TEXT_GRAYED EFI_DARKGRAY
-#define FIELD_BACKGROUND EFI_BACKGROUND_LIGHTGRAY
-#define POPUP_TEXT EFI_LIGHTGRAY
-#define POPUP_BACKGROUND EFI_BACKGROUND_BLUE
-#define POPUP_INVERSE_TEXT EFI_LIGHTGRAY
-#define POPUP_INVERSE_BACKGROUND EFI_BACKGROUND_BLACK
-#define HELP_TEXT EFI_BLUE
-#define ERROR_TEXT EFI_RED | EFI_BRIGHT
-#define INFO_TEXT EFI_YELLOW | EFI_BRIGHT
-#define ARROW_TEXT EFI_RED | EFI_BRIGHT
-#define ARROW_BACKGROUND EFI_BACKGROUND_LIGHTGRAY
+#define PICKLIST_HIGHLIGHT_TEXT EFI_WHITE
+#define PICKLIST_HIGHLIGHT_BACKGROUND EFI_BACKGROUND_CYAN
+#define TITLE_TEXT EFI_WHITE
+#define TITLE_BACKGROUND EFI_BACKGROUND_BLUE
+#define KEYHELP_TEXT EFI_LIGHTGRAY
+#define KEYHELP_BACKGROUND EFI_BACKGROUND_BLACK
+#define SUBTITLE_BACKGROUND EFI_BACKGROUND_LIGHTGRAY
+#define BANNER_TEXT EFI_BLUE
+#define BANNER_BACKGROUND EFI_BACKGROUND_LIGHTGRAY
+#define FIELD_TEXT_GRAYED EFI_DARKGRAY
+#define FIELD_BACKGROUND EFI_BACKGROUND_LIGHTGRAY
+#define POPUP_TEXT EFI_LIGHTGRAY
+#define POPUP_BACKGROUND EFI_BACKGROUND_BLUE
+#define POPUP_INVERSE_TEXT EFI_LIGHTGRAY
+#define POPUP_INVERSE_BACKGROUND EFI_BACKGROUND_BLACK
+#define HELP_TEXT EFI_BLUE
+#define ERROR_TEXT EFI_RED | EFI_BRIGHT
+#define INFO_TEXT EFI_YELLOW | EFI_BRIGHT
+#define ARROW_TEXT EFI_RED | EFI_BRIGHT
+#define ARROW_BACKGROUND EFI_BACKGROUND_LIGHTGRAY
#endif
diff --git a/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.c b/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.c index 4dca484eb8..b3da13d0a3 100644 --- a/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.c +++ b/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.c @@ -8,14 +8,16 @@ SPDX-License-Identifier: BSD-2-Clause-Patent **/
#include "CustomizedDisplayLibInternal.h"
-EFI_GUID gCustomizedDisplayLibGuid = { 0x99fdc8fd, 0x849b, 0x4eba, { 0xad, 0x13, 0xfb, 0x96, 0x99, 0xc9, 0xa, 0x4d } };
+EFI_GUID gCustomizedDisplayLibGuid = {
+ 0x99fdc8fd, 0x849b, 0x4eba, { 0xad, 0x13, 0xfb, 0x96, 0x99, 0xc9, 0xa, 0x4d }
+};
-EFI_HII_HANDLE mCDLStringPackHandle;
-UINT16 gClassOfVfr; // Formset class information
-BOOLEAN gLibIsFirstForm = TRUE;
-BANNER_DATA *gBannerData;
+EFI_HII_HANDLE mCDLStringPackHandle;
+UINT16 gClassOfVfr; // Formset class information
+BOOLEAN gLibIsFirstForm = TRUE;
+BANNER_DATA *gBannerData;
-UINTN gFooterHeight;
+UINTN gFooterHeight;
/**
+------------------------------------------------------------------------------+
@@ -51,14 +53,14 @@ Statement EFI_STATUS
EFIAPI
DisplayPageFrame (
- IN FORM_DISPLAY_ENGINE_FORM *FormData,
- OUT EFI_SCREEN_DESCRIPTOR *ScreenForStatement
+ IN FORM_DISPLAY_ENGINE_FORM *FormData,
+ OUT EFI_SCREEN_DESCRIPTOR *ScreenForStatement
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
ASSERT (FormData != NULL && ScreenForStatement != NULL);
- if (FormData == NULL || ScreenForStatement == NULL) {
+ if ((FormData == NULL) || (ScreenForStatement == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -69,17 +71,18 @@ DisplayPageFrame ( gClassOfVfr = FORMSET_CLASS_PLATFORM_SETUP;
- ProcessExternedOpcode(FormData);
+ ProcessExternedOpcode (FormData);
//
// Calculate the ScreenForStatement.
//
- ScreenForStatement->BottomRow = gScreenDimensions.BottomRow - STATUS_BAR_HEIGHT - gFooterHeight;
+ ScreenForStatement->BottomRow = gScreenDimensions.BottomRow - STATUS_BAR_HEIGHT - gFooterHeight;
if (gClassOfVfr == FORMSET_CLASS_FRONT_PAGE) {
- ScreenForStatement->TopRow = gScreenDimensions.TopRow + FRONT_PAGE_HEADER_HEIGHT;
+ ScreenForStatement->TopRow = gScreenDimensions.TopRow + FRONT_PAGE_HEADER_HEIGHT;
} else {
- ScreenForStatement->TopRow = gScreenDimensions.TopRow + NONE_FRONT_PAGE_HEADER_HEIGHT;
+ ScreenForStatement->TopRow = gScreenDimensions.TopRow + NONE_FRONT_PAGE_HEADER_HEIGHT;
}
+
ScreenForStatement->LeftColumn = gScreenDimensions.LeftColumn;
ScreenForStatement->RightColumn = gScreenDimensions.RightColumn;
@@ -105,7 +108,7 @@ DisplayPageFrame ( PrintFramework (FormData);
- UpdateStatusBar(NV_UPDATE_REQUIRED, FormData->SettingChangedFlag);
+ UpdateStatusBar (NV_UPDATE_REQUIRED, FormData->SettingChangedFlag);
return EFI_SUCCESS;
}
@@ -122,27 +125,27 @@ DisplayPageFrame ( VOID
EFIAPI
RefreshKeyHelp (
- IN FORM_DISPLAY_ENGINE_FORM *FormData,
- IN FORM_DISPLAY_ENGINE_STATEMENT *Statement,
- IN BOOLEAN Selected
+ IN FORM_DISPLAY_ENGINE_FORM *FormData,
+ IN FORM_DISPLAY_ENGINE_STATEMENT *Statement,
+ IN BOOLEAN Selected
)
{
- UINTN SecCol;
- UINTN ThdCol;
- UINTN RightColumnOfHelp;
- UINTN TopRowOfHelp;
- UINTN BottomRowOfHelp;
- UINTN StartColumnOfHelp;
- EFI_IFR_NUMERIC *NumericOp;
- EFI_IFR_DATE *DateOp;
- EFI_IFR_TIME *TimeOp;
- BOOLEAN HexDisplay;
- UINTN ColumnWidth1;
- UINTN ColumnWidth2;
- UINTN ColumnWidth3;
- CHAR16 *ColumnStr1;
- CHAR16 *ColumnStr2;
- CHAR16 *ColumnStr3;
+ UINTN SecCol;
+ UINTN ThdCol;
+ UINTN RightColumnOfHelp;
+ UINTN TopRowOfHelp;
+ UINTN BottomRowOfHelp;
+ UINTN StartColumnOfHelp;
+ EFI_IFR_NUMERIC *NumericOp;
+ EFI_IFR_DATE *DateOp;
+ EFI_IFR_TIME *TimeOp;
+ BOOLEAN HexDisplay;
+ UINTN ColumnWidth1;
+ UINTN ColumnWidth2;
+ UINTN ColumnWidth3;
+ CHAR16 *ColumnStr1;
+ CHAR16 *ColumnStr2;
+ CHAR16 *ColumnStr3;
ASSERT (FormData != NULL);
if (FormData == NULL) {
@@ -155,8 +158,8 @@ RefreshKeyHelp ( return;
}
- SecCol = gScreenDimensions.LeftColumn + (gScreenDimensions.RightColumn - gScreenDimensions.LeftColumn) / 3;
- ThdCol = gScreenDimensions.LeftColumn + (gScreenDimensions.RightColumn - gScreenDimensions.LeftColumn) / 3 * 2;
+ SecCol = gScreenDimensions.LeftColumn + (gScreenDimensions.RightColumn - gScreenDimensions.LeftColumn) / 3;
+ ThdCol = gScreenDimensions.LeftColumn + (gScreenDimensions.RightColumn - gScreenDimensions.LeftColumn) / 3 * 2;
//
// + 2 means leave 1 space before the first hotkey info.
@@ -166,12 +169,12 @@ RefreshKeyHelp ( TopRowOfHelp = gScreenDimensions.BottomRow - STATUS_BAR_HEIGHT - gFooterHeight + 1;
BottomRowOfHelp = gScreenDimensions.BottomRow - STATUS_BAR_HEIGHT - 2;
- ColumnWidth1 = SecCol - StartColumnOfHelp;
- ColumnWidth2 = ThdCol - SecCol;
- ColumnWidth3 = RightColumnOfHelp - ThdCol;
- ColumnStr1 = gLibEmptyString;
- ColumnStr2 = gLibEmptyString;
- ColumnStr3 = gLibEmptyString;
+ ColumnWidth1 = SecCol - StartColumnOfHelp;
+ ColumnWidth2 = ThdCol - SecCol;
+ ColumnWidth3 = RightColumnOfHelp - ThdCol;
+ ColumnStr1 = gLibEmptyString;
+ ColumnStr2 = gLibEmptyString;
+ ColumnStr3 = gLibEmptyString;
//
// Clean the space at gScreenDimensions.LeftColumn + 1.
@@ -190,139 +193,152 @@ RefreshKeyHelp ( if (gClassOfVfr == FORMSET_CLASS_PLATFORM_SETUP) {
ColumnStr3 = gEscapeString;
}
+
PrintStringAtWithWidth (ThdCol, BottomRowOfHelp, ColumnStr3, ColumnWidth3);
return;
}
HexDisplay = FALSE;
- NumericOp = NULL;
- DateOp = NULL;
- TimeOp = NULL;
+ NumericOp = NULL;
+ DateOp = NULL;
+ TimeOp = NULL;
if (Statement->OpCode->OpCode == EFI_IFR_NUMERIC_OP) {
- NumericOp = (EFI_IFR_NUMERIC *) Statement->OpCode;
+ NumericOp = (EFI_IFR_NUMERIC *)Statement->OpCode;
HexDisplay = (NumericOp->Flags & EFI_IFR_DISPLAY_UINT_HEX) == EFI_IFR_DISPLAY_UINT_HEX;
} else if (Statement->OpCode->OpCode == EFI_IFR_DATE_OP) {
- DateOp = (EFI_IFR_DATE *) Statement->OpCode;
+ DateOp = (EFI_IFR_DATE *)Statement->OpCode;
HexDisplay = (DateOp->Flags & EFI_IFR_DISPLAY_UINT_HEX) == EFI_IFR_DISPLAY_UINT_HEX;
} else if (Statement->OpCode->OpCode == EFI_IFR_TIME_OP) {
- TimeOp = (EFI_IFR_TIME *) Statement->OpCode;
+ TimeOp = (EFI_IFR_TIME *)Statement->OpCode;
HexDisplay = (TimeOp->Flags & EFI_IFR_DISPLAY_UINT_HEX) == EFI_IFR_DISPLAY_UINT_HEX;
}
- switch (Statement->OpCode->OpCode) {
- case EFI_IFR_ORDERED_LIST_OP:
- case EFI_IFR_ONE_OF_OP:
- case EFI_IFR_NUMERIC_OP:
- case EFI_IFR_TIME_OP:
- case EFI_IFR_DATE_OP:
- if (!Selected) {
- PrintHotKeyHelpString (FormData, TRUE);
-
- if (gClassOfVfr == FORMSET_CLASS_PLATFORM_SETUP) {
- ColumnStr3 = gEscapeString;
- }
- PrintStringAtWithWidth (ThdCol, BottomRowOfHelp, ColumnStr3, ColumnWidth3);
- if ((Statement->OpCode->OpCode == EFI_IFR_DATE_OP) ||
- (Statement->OpCode->OpCode == EFI_IFR_TIME_OP)) {
- PrintAt (
- ColumnWidth1,
- StartColumnOfHelp,
- BottomRowOfHelp,
- L"%c%c%c%c%s",
- ARROW_UP,
- ARROW_DOWN,
- ARROW_RIGHT,
- ARROW_LEFT,
- gMoveHighlight
- );
- PrintStringAtWithWidth (SecCol, BottomRowOfHelp, gEnterString, ColumnWidth2);
- PrintStringAtWithWidth (StartColumnOfHelp, TopRowOfHelp, gAdjustNumber, ColumnWidth1);
- } else {
- PrintAt (ColumnWidth1, StartColumnOfHelp, BottomRowOfHelp, L"%c%c%s", ARROW_UP, ARROW_DOWN, gMoveHighlight);
- if (Statement->OpCode->OpCode == EFI_IFR_NUMERIC_OP && NumericOp != NULL && LibGetFieldFromNum(Statement->OpCode) != 0) {
- ColumnStr1 = gAdjustNumber;
+ switch (Statement->OpCode->OpCode) {
+ case EFI_IFR_ORDERED_LIST_OP:
+ case EFI_IFR_ONE_OF_OP:
+ case EFI_IFR_NUMERIC_OP:
+ case EFI_IFR_TIME_OP:
+ case EFI_IFR_DATE_OP:
+ if (!Selected) {
+ PrintHotKeyHelpString (FormData, TRUE);
+
+ if (gClassOfVfr == FORMSET_CLASS_PLATFORM_SETUP) {
+ ColumnStr3 = gEscapeString;
}
- PrintStringAtWithWidth (StartColumnOfHelp, TopRowOfHelp, ColumnStr1, ColumnWidth1);
- PrintStringAtWithWidth (SecCol, BottomRowOfHelp, gEnterString, ColumnWidth2);
- }
- } else {
- PrintHotKeyHelpString (FormData, FALSE);
- PrintStringAtWithWidth (SecCol, BottomRowOfHelp, gEnterCommitString, ColumnWidth2);
- //
- // If it is a selected numeric with manual input, display different message
- //
- if ((Statement->OpCode->OpCode == EFI_IFR_NUMERIC_OP) ||
- (Statement->OpCode->OpCode == EFI_IFR_DATE_OP) ||
- (Statement->OpCode->OpCode == EFI_IFR_TIME_OP)) {
- ColumnStr2 = HexDisplay ? gHexNumericInput : gDecNumericInput;
- PrintStringAtWithWidth (StartColumnOfHelp, BottomRowOfHelp, gLibEmptyString, ColumnWidth1);
+ PrintStringAtWithWidth (ThdCol, BottomRowOfHelp, ColumnStr3, ColumnWidth3);
+
+ if ((Statement->OpCode->OpCode == EFI_IFR_DATE_OP) ||
+ (Statement->OpCode->OpCode == EFI_IFR_TIME_OP))
+ {
+ PrintAt (
+ ColumnWidth1,
+ StartColumnOfHelp,
+ BottomRowOfHelp,
+ L"%c%c%c%c%s",
+ ARROW_UP,
+ ARROW_DOWN,
+ ARROW_RIGHT,
+ ARROW_LEFT,
+ gMoveHighlight
+ );
+ PrintStringAtWithWidth (SecCol, BottomRowOfHelp, gEnterString, ColumnWidth2);
+ PrintStringAtWithWidth (StartColumnOfHelp, TopRowOfHelp, gAdjustNumber, ColumnWidth1);
+ } else {
+ PrintAt (ColumnWidth1, StartColumnOfHelp, BottomRowOfHelp, L"%c%c%s", ARROW_UP, ARROW_DOWN, gMoveHighlight);
+ if ((Statement->OpCode->OpCode == EFI_IFR_NUMERIC_OP) && (NumericOp != NULL) && (LibGetFieldFromNum (Statement->OpCode) != 0)) {
+ ColumnStr1 = gAdjustNumber;
+ }
+
+ PrintStringAtWithWidth (StartColumnOfHelp, TopRowOfHelp, ColumnStr1, ColumnWidth1);
+ PrintStringAtWithWidth (SecCol, BottomRowOfHelp, gEnterString, ColumnWidth2);
+ }
} else {
- PrintAt (ColumnWidth1, StartColumnOfHelp, BottomRowOfHelp, L"%c%c%s", ARROW_UP, ARROW_DOWN, gMoveHighlight);
- }
+ PrintHotKeyHelpString (FormData, FALSE);
+ PrintStringAtWithWidth (SecCol, BottomRowOfHelp, gEnterCommitString, ColumnWidth2);
+
+ //
+ // If it is a selected numeric with manual input, display different message
+ //
+ if ((Statement->OpCode->OpCode == EFI_IFR_NUMERIC_OP) ||
+ (Statement->OpCode->OpCode == EFI_IFR_DATE_OP) ||
+ (Statement->OpCode->OpCode == EFI_IFR_TIME_OP))
+ {
+ ColumnStr2 = HexDisplay ? gHexNumericInput : gDecNumericInput;
+ PrintStringAtWithWidth (StartColumnOfHelp, BottomRowOfHelp, gLibEmptyString, ColumnWidth1);
+ } else {
+ PrintAt (ColumnWidth1, StartColumnOfHelp, BottomRowOfHelp, L"%c%c%s", ARROW_UP, ARROW_DOWN, gMoveHighlight);
+ }
- if (Statement->OpCode->OpCode == EFI_IFR_ORDERED_LIST_OP) {
- ColumnStr1 = gPlusString;
- ColumnStr3 = gMinusString;
- }
- PrintStringAtWithWidth (StartColumnOfHelp, TopRowOfHelp, ColumnStr1, ColumnWidth1);
- PrintStringAtWithWidth (ThdCol, TopRowOfHelp, ColumnStr3, ColumnWidth3);
- PrintStringAtWithWidth (SecCol, TopRowOfHelp, ColumnStr2, ColumnWidth2);
+ if (Statement->OpCode->OpCode == EFI_IFR_ORDERED_LIST_OP) {
+ ColumnStr1 = gPlusString;
+ ColumnStr3 = gMinusString;
+ }
- PrintStringAtWithWidth (ThdCol, BottomRowOfHelp, gEnterEscapeString, ColumnWidth3);
- }
- break;
+ PrintStringAtWithWidth (StartColumnOfHelp, TopRowOfHelp, ColumnStr1, ColumnWidth1);
+ PrintStringAtWithWidth (ThdCol, TopRowOfHelp, ColumnStr3, ColumnWidth3);
+ PrintStringAtWithWidth (SecCol, TopRowOfHelp, ColumnStr2, ColumnWidth2);
- case EFI_IFR_CHECKBOX_OP:
- PrintHotKeyHelpString (FormData, TRUE);
+ PrintStringAtWithWidth (ThdCol, BottomRowOfHelp, gEnterEscapeString, ColumnWidth3);
+ }
- if (gClassOfVfr == FORMSET_CLASS_PLATFORM_SETUP) {
- ColumnStr3 = gEscapeString;
- }
- PrintStringAtWithWidth (ThdCol, BottomRowOfHelp, ColumnStr3, ColumnWidth3);
+ break;
- PrintAt (ColumnWidth1, StartColumnOfHelp, BottomRowOfHelp, L"%c%c%s", ARROW_UP, ARROW_DOWN, gMoveHighlight);
- PrintStringAtWithWidth (SecCol, BottomRowOfHelp, gToggleCheckBox, ColumnWidth2);
- PrintStringAtWithWidth (StartColumnOfHelp, TopRowOfHelp, gLibEmptyString, ColumnWidth1);
- break;
-
- case EFI_IFR_REF_OP:
- case EFI_IFR_PASSWORD_OP:
- case EFI_IFR_STRING_OP:
- case EFI_IFR_TEXT_OP:
- case EFI_IFR_ACTION_OP:
- case EFI_IFR_RESET_BUTTON_OP:
- case EFI_IFR_SUBTITLE_OP:
- if (!Selected) {
+ case EFI_IFR_CHECKBOX_OP:
PrintHotKeyHelpString (FormData, TRUE);
if (gClassOfVfr == FORMSET_CLASS_PLATFORM_SETUP) {
ColumnStr3 = gEscapeString;
}
+
PrintStringAtWithWidth (ThdCol, BottomRowOfHelp, ColumnStr3, ColumnWidth3);
PrintAt (ColumnWidth1, StartColumnOfHelp, BottomRowOfHelp, L"%c%c%s", ARROW_UP, ARROW_DOWN, gMoveHighlight);
- if (Statement->OpCode->OpCode != EFI_IFR_TEXT_OP && Statement->OpCode->OpCode != EFI_IFR_SUBTITLE_OP) {
- ColumnStr2 = gEnterString;
- }
- PrintStringAtWithWidth (SecCol, BottomRowOfHelp, ColumnStr2, ColumnWidth2);
- PrintStringAtWithWidth (StartColumnOfHelp, TopRowOfHelp, ColumnStr1, ColumnWidth1);
- } else {
- PrintHotKeyHelpString (FormData, FALSE);
- if (Statement->OpCode->OpCode != EFI_IFR_REF_OP) {
- ColumnStr2 = gEnterCommitString;
- ColumnStr3 = gEnterEscapeString;
+ PrintStringAtWithWidth (SecCol, BottomRowOfHelp, gToggleCheckBox, ColumnWidth2);
+ PrintStringAtWithWidth (StartColumnOfHelp, TopRowOfHelp, gLibEmptyString, ColumnWidth1);
+ break;
+
+ case EFI_IFR_REF_OP:
+ case EFI_IFR_PASSWORD_OP:
+ case EFI_IFR_STRING_OP:
+ case EFI_IFR_TEXT_OP:
+ case EFI_IFR_ACTION_OP:
+ case EFI_IFR_RESET_BUTTON_OP:
+ case EFI_IFR_SUBTITLE_OP:
+ if (!Selected) {
+ PrintHotKeyHelpString (FormData, TRUE);
+
+ if (gClassOfVfr == FORMSET_CLASS_PLATFORM_SETUP) {
+ ColumnStr3 = gEscapeString;
+ }
+
+ PrintStringAtWithWidth (ThdCol, BottomRowOfHelp, ColumnStr3, ColumnWidth3);
+
+ PrintAt (ColumnWidth1, StartColumnOfHelp, BottomRowOfHelp, L"%c%c%s", ARROW_UP, ARROW_DOWN, gMoveHighlight);
+ if ((Statement->OpCode->OpCode != EFI_IFR_TEXT_OP) && (Statement->OpCode->OpCode != EFI_IFR_SUBTITLE_OP)) {
+ ColumnStr2 = gEnterString;
+ }
+
+ PrintStringAtWithWidth (SecCol, BottomRowOfHelp, ColumnStr2, ColumnWidth2);
+ PrintStringAtWithWidth (StartColumnOfHelp, TopRowOfHelp, ColumnStr1, ColumnWidth1);
+ } else {
+ PrintHotKeyHelpString (FormData, FALSE);
+ if (Statement->OpCode->OpCode != EFI_IFR_REF_OP) {
+ ColumnStr2 = gEnterCommitString;
+ ColumnStr3 = gEnterEscapeString;
+ }
+
+ PrintStringAtWithWidth (StartColumnOfHelp, TopRowOfHelp, ColumnStr1, ColumnWidth1);
+ PrintStringAtWithWidth (StartColumnOfHelp, BottomRowOfHelp, ColumnStr1, ColumnWidth1);
+ PrintStringAtWithWidth (SecCol, BottomRowOfHelp, ColumnStr2, ColumnWidth2);
+ PrintStringAtWithWidth (ThdCol, BottomRowOfHelp, ColumnStr3, ColumnWidth3);
}
- PrintStringAtWithWidth (StartColumnOfHelp, TopRowOfHelp, ColumnStr1, ColumnWidth1);
- PrintStringAtWithWidth (StartColumnOfHelp, BottomRowOfHelp, ColumnStr1, ColumnWidth1);
- PrintStringAtWithWidth (SecCol, BottomRowOfHelp, ColumnStr2, ColumnWidth2);
- PrintStringAtWithWidth (ThdCol, BottomRowOfHelp, ColumnStr3, ColumnWidth3);
- }
- break;
- default:
- break;
+ break;
+
+ default:
+ break;
}
}
@@ -338,57 +354,59 @@ RefreshKeyHelp ( VOID
EFIAPI
UpdateStatusBar (
- IN UINTN MessageType,
- IN BOOLEAN State
+ IN UINTN MessageType,
+ IN BOOLEAN State
)
{
- UINTN Index;
- CHAR16 OptionWidth;
+ UINTN Index;
+ CHAR16 OptionWidth;
- OptionWidth = (CHAR16) ((gScreenDimensions.RightColumn - gScreenDimensions.LeftColumn) / 3);
+ OptionWidth = (CHAR16)((gScreenDimensions.RightColumn - gScreenDimensions.LeftColumn) / 3);
switch (MessageType) {
- case INPUT_ERROR:
- if (State) {
- gST->ConOut->SetAttribute (gST->ConOut, ERROR_TEXT);
- PrintStringAt (
- gScreenDimensions.LeftColumn + OptionWidth,
- gScreenDimensions.BottomRow - 1,
- gInputErrorMessage
- );
- } else {
- gST->ConOut->SetAttribute (gST->ConOut, KEYHELP_BACKGROUND);
- for (Index = 0; Index < (LibGetStringWidth (gInputErrorMessage) - 2) / 2; Index++) {
- PrintStringAt (gScreenDimensions.LeftColumn + OptionWidth + Index, gScreenDimensions.BottomRow - 1, L" ");
+ case INPUT_ERROR:
+ if (State) {
+ gST->ConOut->SetAttribute (gST->ConOut, ERROR_TEXT);
+ PrintStringAt (
+ gScreenDimensions.LeftColumn + OptionWidth,
+ gScreenDimensions.BottomRow - 1,
+ gInputErrorMessage
+ );
+ } else {
+ gST->ConOut->SetAttribute (gST->ConOut, KEYHELP_BACKGROUND);
+ for (Index = 0; Index < (LibGetStringWidth (gInputErrorMessage) - 2) / 2; Index++) {
+ PrintStringAt (gScreenDimensions.LeftColumn + OptionWidth + Index, gScreenDimensions.BottomRow - 1, L" ");
+ }
}
- }
- break;
- case NV_UPDATE_REQUIRED:
- //
- // Global setting support. Show configuration change on every form.
- //
- if (State) {
- gST->ConOut->SetAttribute (gST->ConOut, INFO_TEXT);
- PrintStringAt (
- gScreenDimensions.LeftColumn + OptionWidth * 2,
- gScreenDimensions.BottomRow - 1,
- gNvUpdateMessage
- );
- } else {
- gST->ConOut->SetAttribute (gST->ConOut, KEYHELP_BACKGROUND);
- for (Index = 0; Index < (LibGetStringWidth (gNvUpdateMessage) - 2) / 2; Index++) {
+ break;
+
+ case NV_UPDATE_REQUIRED:
+ //
+ // Global setting support. Show configuration change on every form.
+ //
+ if (State) {
+ gST->ConOut->SetAttribute (gST->ConOut, INFO_TEXT);
PrintStringAt (
- (gScreenDimensions.LeftColumn + OptionWidth * 2 + Index),
+ gScreenDimensions.LeftColumn + OptionWidth * 2,
gScreenDimensions.BottomRow - 1,
- L" "
+ gNvUpdateMessage
);
+ } else {
+ gST->ConOut->SetAttribute (gST->ConOut, KEYHELP_BACKGROUND);
+ for (Index = 0; Index < (LibGetStringWidth (gNvUpdateMessage) - 2) / 2; Index++) {
+ PrintStringAt (
+ (gScreenDimensions.LeftColumn + OptionWidth * 2 + Index),
+ gScreenDimensions.BottomRow - 1,
+ L" "
+ );
+ }
}
- }
- break;
- default:
- break;
+ break;
+
+ default:
+ break;
}
}
@@ -408,28 +426,28 @@ CreateDialog ( ...
)
{
- VA_LIST Marker;
- EFI_INPUT_KEY KeyValue;
- EFI_STATUS Status;
- UINTN LargestString;
- UINTN LineNum;
- UINTN Index;
- UINTN Count;
- CHAR16 Character;
- UINTN Start;
- UINTN End;
- UINTN Top;
- UINTN Bottom;
- CHAR16 *String;
- UINTN DimensionsWidth;
- UINTN DimensionsHeight;
- UINTN CurrentAttribute;
- BOOLEAN CursorVisible;
+ VA_LIST Marker;
+ EFI_INPUT_KEY KeyValue;
+ EFI_STATUS Status;
+ UINTN LargestString;
+ UINTN LineNum;
+ UINTN Index;
+ UINTN Count;
+ CHAR16 Character;
+ UINTN Start;
+ UINTN End;
+ UINTN Top;
+ UINTN Bottom;
+ CHAR16 *String;
+ UINTN DimensionsWidth;
+ UINTN DimensionsHeight;
+ UINTN CurrentAttribute;
+ BOOLEAN CursorVisible;
//
// If screen dimension info is not ready, get it from console.
//
- if (gScreenDimensions.RightColumn == 0 || gScreenDimensions.BottomRow == 0) {
+ if ((gScreenDimensions.RightColumn == 0) || (gScreenDimensions.BottomRow == 0)) {
ZeroMem (&gScreenDimensions, sizeof (EFI_SCREEN_DESCRIPTOR));
gST->ConOut->QueryMode (
gST->ConOut,
@@ -439,27 +457,28 @@ CreateDialog ( );
}
- DimensionsWidth = gScreenDimensions.RightColumn - gScreenDimensions.LeftColumn;
- DimensionsHeight = gScreenDimensions.BottomRow - gScreenDimensions.TopRow;
+ DimensionsWidth = gScreenDimensions.RightColumn - gScreenDimensions.LeftColumn;
+ DimensionsHeight = gScreenDimensions.BottomRow - gScreenDimensions.TopRow;
LargestString = 0;
LineNum = 0;
VA_START (Marker, Key);
- while ((String = VA_ARG (Marker, CHAR16 *)) != NULL) {
- LineNum ++;
+ while ((String = VA_ARG (Marker, CHAR16 *)) != NULL) {
+ LineNum++;
if ((LibGetStringWidth (String) / 2) > LargestString) {
LargestString = (LibGetStringWidth (String) / 2);
}
}
+
VA_END (Marker);
if ((LargestString + 2) > DimensionsWidth) {
LargestString = DimensionsWidth - 2;
}
- CurrentAttribute = gST->ConOut->Mode->Attribute;
- CursorVisible = gST->ConOut->Mode->CursorVisible;
+ CurrentAttribute = gST->ConOut->Mode->Attribute;
+ CursorVisible = gST->ConOut->Mode->CursorVisible;
gST->ConOut->EnableCursor (gST->ConOut, FALSE);
gST->ConOut->SetAttribute (gST->ConOut, GetPopupColor ());
@@ -467,11 +486,11 @@ CreateDialog ( // Subtract the PopUp width from total Columns, allow for one space extra on
// each end plus a border.
//
- Start = (DimensionsWidth - LargestString - 2) / 2 + gScreenDimensions.LeftColumn + 1;
- End = Start + LargestString + 1;
+ Start = (DimensionsWidth - LargestString - 2) / 2 + gScreenDimensions.LeftColumn + 1;
+ End = Start + LargestString + 1;
- Top = ((DimensionsHeight - LineNum - 2) / 2) + gScreenDimensions.TopRow - 1;
- Bottom = Top + LineNum + 2;
+ Top = ((DimensionsHeight - LineNum - 2) / 2) + gScreenDimensions.TopRow - 1;
+ Bottom = Top + LineNum + 2;
Character = BOXDRAW_DOWN_RIGHT;
PrintCharAt (Start, Top, Character);
@@ -487,7 +506,7 @@ CreateDialog ( Count = 0;
VA_START (Marker, Key);
for (Index = Top; Index + 2 < Bottom; Index++, Count++) {
- String = VA_ARG (Marker, CHAR16*);
+ String = VA_ARG (Marker, CHAR16 *);
if (String[0] == CHAR_NULL) {
//
@@ -522,17 +541,18 @@ CreateDialog ( PrintCharAt (Start, Index + 1, Character);
PrintCharAt (End - 1, Index + 1, Character);
}
+
VA_END (Marker);
Character = BOXDRAW_UP_RIGHT;
PrintCharAt (Start, Bottom - 1, Character);
Character = BOXDRAW_HORIZONTAL;
for (Index = Start; Index + 2 < End; Index++) {
- PrintCharAt ((UINTN)-1, (UINTN) -1, Character);
+ PrintCharAt ((UINTN)-1, (UINTN)-1, Character);
}
Character = BOXDRAW_UP_LEFT;
- PrintCharAt ((UINTN)-1, (UINTN) -1, Character);
+ PrintCharAt ((UINTN)-1, (UINTN)-1, Character);
if (Key != NULL) {
Status = WaitForKeyStroke (&KeyValue);
@@ -555,9 +575,9 @@ ConfirmDataChange ( VOID
)
{
- CHAR16 YesResponse;
- CHAR16 NoResponse;
- EFI_INPUT_KEY Key;
+ CHAR16 YesResponse;
+ CHAR16 NoResponse;
+ EFI_INPUT_KEY Key;
gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);
@@ -571,9 +591,9 @@ ConfirmDataChange ( CreateDialog (&Key, gLibEmptyString, gSaveChanges, gAreYouSure, gLibEmptyString, NULL);
} while
(
- (Key.ScanCode != SCAN_ESC) &&
- ((Key.UnicodeChar | UPPER_LOWER_CASE_OFFSET) != (NoResponse | UPPER_LOWER_CASE_OFFSET)) &&
- ((Key.UnicodeChar | UPPER_LOWER_CASE_OFFSET) != (YesResponse | UPPER_LOWER_CASE_OFFSET))
+ (Key.ScanCode != SCAN_ESC) &&
+ ((Key.UnicodeChar | UPPER_LOWER_CASE_OFFSET) != (NoResponse | UPPER_LOWER_CASE_OFFSET)) &&
+ ((Key.UnicodeChar | UPPER_LOWER_CASE_OFFSET) != (YesResponse | UPPER_LOWER_CASE_OFFSET))
);
if (Key.ScanCode == SCAN_ESC) {
@@ -617,14 +637,16 @@ FormExitPolicy ( UINT64
EFIAPI
FormExitTimeout (
- IN FORM_DISPLAY_ENGINE_FORM *FormData
+ IN FORM_DISPLAY_ENGINE_FORM *FormData
)
{
return 0;
}
+
//
// Print Functions
//
+
/**
Prints a unicode string to the default console, at
the supplied cursor position, using L"%s" format.
@@ -639,9 +661,9 @@ FormExitTimeout ( UINTN
EFIAPI
PrintStringAt (
- IN UINTN Column,
- IN UINTN Row,
- IN CHAR16 *String
+ IN UINTN Column,
+ IN UINTN Row,
+ IN CHAR16 *String
)
{
return PrintAt (0, Column, Row, L"%s", String);
@@ -662,10 +684,10 @@ PrintStringAt ( UINTN
EFIAPI
PrintStringAtWithWidth (
- IN UINTN Column,
- IN UINTN Row,
- IN CHAR16 *String,
- IN UINTN Width
+ IN UINTN Column,
+ IN UINTN Row,
+ IN CHAR16 *String,
+ IN UINTN Width
)
{
return PrintAt (Width, Column, Row, L"%s", String);
@@ -685,9 +707,9 @@ PrintStringAtWithWidth ( UINTN
EFIAPI
PrintCharAt (
- IN UINTN Column,
- IN UINTN Row,
- CHAR16 Character
+ IN UINTN Column,
+ IN UINTN Row,
+ CHAR16 Character
)
{
return PrintAt (0, Column, Row, L"%c", Character);
@@ -706,11 +728,11 @@ PrintCharAt ( VOID
EFIAPI
ClearLines (
- IN UINTN LeftColumn,
- IN UINTN RightColumn,
- IN UINTN TopRow,
- IN UINTN BottomRow,
- IN UINTN TextAttribute
+ IN UINTN LeftColumn,
+ IN UINTN RightColumn,
+ IN UINTN TopRow,
+ IN UINTN BottomRow,
+ IN UINTN TextAttribute
)
{
CHAR16 *Buffer;
@@ -914,14 +936,14 @@ ClearDisplayPage ( EFI_STATUS
EFIAPI
CustomizedDisplayLibConstructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
mCDLStringPackHandle = HiiAddPackages (&gCustomizedDisplayLibGuid, ImageHandle, CustomizedDisplayLibStrings, NULL);
ASSERT (mCDLStringPackHandle != NULL);
- InitializeLibStrings();
+ InitializeLibStrings ();
return EFI_SUCCESS;
}
@@ -943,7 +965,7 @@ CustomizedDisplayLibDestructor ( IN EFI_SYSTEM_TABLE *SystemTable
)
{
- HiiRemovePackages(mCDLStringPackHandle);
+ HiiRemovePackages (mCDLStringPackHandle);
FreeLibStrings ();
diff --git a/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLibInternal.c b/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLibInternal.c index d770a0f873..58130d9383 100644 --- a/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLibInternal.c +++ b/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLibInternal.c @@ -8,33 +8,33 @@ SPDX-License-Identifier: BSD-2-Clause-Patent **/
#include "CustomizedDisplayLibInternal.h"
-EFI_SCREEN_DESCRIPTOR gScreenDimensions;
-CHAR16 *mLibUnknownString;
-extern EFI_HII_HANDLE mCDLStringPackHandle;
-CHAR16 *mSpaceBuffer;
-#define SPACE_BUFFER_SIZE 1000
+EFI_SCREEN_DESCRIPTOR gScreenDimensions;
+CHAR16 *mLibUnknownString;
+extern EFI_HII_HANDLE mCDLStringPackHandle;
+CHAR16 *mSpaceBuffer;
+#define SPACE_BUFFER_SIZE 1000
//
// Browser Global Strings
//
-CHAR16 *gEnterString;
-CHAR16 *gEnterCommitString;
-CHAR16 *gEnterEscapeString;
-CHAR16 *gEscapeString;
-CHAR16 *gMoveHighlight;
-CHAR16 *gDecNumericInput;
-CHAR16 *gHexNumericInput;
-CHAR16 *gToggleCheckBox;
-CHAR16 *gLibEmptyString;
-CHAR16 *gAreYouSure;
-CHAR16 *gYesResponse;
-CHAR16 *gNoResponse;
-CHAR16 *gPlusString;
-CHAR16 *gMinusString;
-CHAR16 *gAdjustNumber;
-CHAR16 *gSaveChanges;
-CHAR16 *gNvUpdateMessage;
-CHAR16 *gInputErrorMessage;
+CHAR16 *gEnterString;
+CHAR16 *gEnterCommitString;
+CHAR16 *gEnterEscapeString;
+CHAR16 *gEscapeString;
+CHAR16 *gMoveHighlight;
+CHAR16 *gDecNumericInput;
+CHAR16 *gHexNumericInput;
+CHAR16 *gToggleCheckBox;
+CHAR16 *gLibEmptyString;
+CHAR16 *gAreYouSure;
+CHAR16 *gYesResponse;
+CHAR16 *gNoResponse;
+CHAR16 *gPlusString;
+CHAR16 *gMinusString;
+CHAR16 *gAdjustNumber;
+CHAR16 *gSaveChanges;
+CHAR16 *gNvUpdateMessage;
+CHAR16 *gInputErrorMessage;
/**
@@ -45,14 +45,14 @@ CHAR16 *gInputErrorMessage; **/
VOID
PrintBannerInfo (
- IN FORM_DISPLAY_ENGINE_FORM *FormData
+ IN FORM_DISPLAY_ENGINE_FORM *FormData
)
{
- UINT8 Line;
- UINT8 Alignment;
- CHAR16 *StrFrontPageBanner;
- UINT8 RowIdx;
- UINT8 ColumnIdx;
+ UINT8 Line;
+ UINT8 Alignment;
+ CHAR16 *StrFrontPageBanner;
+ UINT8 RowIdx;
+ UINT8 ColumnIdx;
//
// ClearLines(0, LocalScreen.RightColumn, 0, BANNER_HEIGHT-1, BANNER_TEXT | BANNER_BACKGROUND);
@@ -68,54 +68,55 @@ PrintBannerInfo ( //
// for (Line = 0; Line < BANNER_HEIGHT; Line++) {
//
- for (Line = (UINT8) gScreenDimensions.TopRow; Line < BANNER_HEIGHT + (UINT8) gScreenDimensions.TopRow; Line++) {
+ for (Line = (UINT8)gScreenDimensions.TopRow; Line < BANNER_HEIGHT + (UINT8)gScreenDimensions.TopRow; Line++) {
//
// for (Alignment = 0; Alignment < BANNER_COLUMNS; Alignment++) {
//
- for (Alignment = (UINT8) gScreenDimensions.LeftColumn;
- Alignment < BANNER_COLUMNS + (UINT8) gScreenDimensions.LeftColumn;
+ for (Alignment = (UINT8)gScreenDimensions.LeftColumn;
+ Alignment < BANNER_COLUMNS + (UINT8)gScreenDimensions.LeftColumn;
Alignment++
- ) {
- RowIdx = (UINT8) (Line - (UINT8) gScreenDimensions.TopRow);
- ColumnIdx = (UINT8) (Alignment - (UINT8) gScreenDimensions.LeftColumn);
+ )
+ {
+ RowIdx = (UINT8)(Line - (UINT8)gScreenDimensions.TopRow);
+ ColumnIdx = (UINT8)(Alignment - (UINT8)gScreenDimensions.LeftColumn);
ASSERT (RowIdx < BANNER_HEIGHT && ColumnIdx < BANNER_COLUMNS);
- if (gBannerData!= NULL && gBannerData->Banner[RowIdx][ColumnIdx] != 0x0000) {
+ if ((gBannerData != NULL) && (gBannerData->Banner[RowIdx][ColumnIdx] != 0x0000)) {
StrFrontPageBanner = LibGetToken (gBannerData->Banner[RowIdx][ColumnIdx], FormData->HiiHandle);
} else {
continue;
}
switch (Alignment - gScreenDimensions.LeftColumn) {
- case 0:
- //
- // Handle left column
- //
- PrintStringAt (gScreenDimensions.LeftColumn + BANNER_LEFT_COLUMN_INDENT, Line, StrFrontPageBanner);
- break;
+ case 0:
+ //
+ // Handle left column
+ //
+ PrintStringAt (gScreenDimensions.LeftColumn + BANNER_LEFT_COLUMN_INDENT, Line, StrFrontPageBanner);
+ break;
- case 1:
- //
- // Handle center column
- //
- PrintStringAt (
- gScreenDimensions.LeftColumn + (gScreenDimensions.RightColumn - gScreenDimensions.LeftColumn) / 3,
- Line,
- StrFrontPageBanner
- );
- break;
-
- case 2:
- //
- // Handle right column
- //
- PrintStringAt (
- gScreenDimensions.LeftColumn + (gScreenDimensions.RightColumn - gScreenDimensions.LeftColumn) * 2 / 3,
- Line,
- StrFrontPageBanner
- );
- break;
+ case 1:
+ //
+ // Handle center column
+ //
+ PrintStringAt (
+ gScreenDimensions.LeftColumn + (gScreenDimensions.RightColumn - gScreenDimensions.LeftColumn) / 3,
+ Line,
+ StrFrontPageBanner
+ );
+ break;
+
+ case 2:
+ //
+ // Handle right column
+ //
+ PrintStringAt (
+ gScreenDimensions.LeftColumn + (gScreenDimensions.RightColumn - gScreenDimensions.LeftColumn) * 2 / 3,
+ Line,
+ StrFrontPageBanner
+ );
+ break;
}
FreePool (StrFrontPageBanner);
@@ -130,15 +131,15 @@ PrintBannerInfo ( **/
VOID
PrintFramework (
- IN FORM_DISPLAY_ENGINE_FORM *FormData
+ IN FORM_DISPLAY_ENGINE_FORM *FormData
)
{
- UINTN Index;
- CHAR16 Character;
- CHAR16 *Buffer;
- UINTN Row;
- CHAR16 *TitleStr;
- UINTN TitleColumn;
+ UINTN Index;
+ CHAR16 Character;
+ CHAR16 *Buffer;
+ UINTN Row;
+ CHAR16 *TitleStr;
+ UINTN TitleColumn;
if (gClassOfVfr != FORMSET_CLASS_PLATFORM_SETUP) {
//
@@ -171,10 +172,10 @@ PrintFramework ( Character = BOXDRAW_DOWN_RIGHT;
PrintCharAt (gScreenDimensions.LeftColumn, gScreenDimensions.TopRow, Character);
- PrintStringAt ((UINTN) -1, (UINTN) -1, Buffer);
+ PrintStringAt ((UINTN)-1, (UINTN)-1, Buffer);
Character = BOXDRAW_DOWN_LEFT;
- PrintCharAt ((UINTN) -1, (UINTN) -1, Character);
+ PrintCharAt ((UINTN)-1, (UINTN)-1, Character);
Character = BOXDRAW_VERTICAL;
for (Row = gScreenDimensions.TopRow + 1; Row <= gScreenDimensions.TopRow + NONE_FRONT_PAGE_HEADER_HEIGHT - 2; Row++) {
@@ -199,10 +200,10 @@ PrintFramework ( Character = BOXDRAW_UP_RIGHT;
PrintCharAt (gScreenDimensions.LeftColumn, gScreenDimensions.TopRow + NONE_FRONT_PAGE_HEADER_HEIGHT - 1, Character);
- PrintStringAt ((UINTN) -1, (UINTN) -1, Buffer);
+ PrintStringAt ((UINTN)-1, (UINTN)-1, Buffer);
Character = BOXDRAW_UP_LEFT;
- PrintCharAt ((UINTN) -1, (UINTN) -1, Character);
+ PrintCharAt ((UINTN)-1, (UINTN)-1, Character);
//
// Print Bottom border line
@@ -213,15 +214,16 @@ PrintFramework ( Character = BOXDRAW_DOWN_RIGHT;
PrintCharAt (gScreenDimensions.LeftColumn, gScreenDimensions.BottomRow - STATUS_BAR_HEIGHT - gFooterHeight, Character);
- PrintStringAt ((UINTN) -1, (UINTN) -1, Buffer);
+ PrintStringAt ((UINTN)-1, (UINTN)-1, Buffer);
Character = BOXDRAW_DOWN_LEFT;
- PrintCharAt ((UINTN) -1, (UINTN) -1, Character);
+ PrintCharAt ((UINTN)-1, (UINTN)-1, Character);
Character = BOXDRAW_VERTICAL;
for (Row = gScreenDimensions.BottomRow - STATUS_BAR_HEIGHT - gFooterHeight + 1;
Row <= gScreenDimensions.BottomRow - STATUS_BAR_HEIGHT - 2;
Row++
- ) {
+ )
+ {
PrintCharAt (gScreenDimensions.LeftColumn, Row, Character);
PrintCharAt (gScreenDimensions.RightColumn - 1, Row, Character);
}
@@ -229,10 +231,10 @@ PrintFramework ( Character = BOXDRAW_UP_RIGHT;
PrintCharAt (gScreenDimensions.LeftColumn, gScreenDimensions.BottomRow - STATUS_BAR_HEIGHT - 1, Character);
- PrintStringAt ((UINTN) -1, (UINTN) -1, Buffer);
+ PrintStringAt ((UINTN)-1, (UINTN)-1, Buffer);
Character = BOXDRAW_UP_LEFT;
- PrintCharAt ((UINTN) -1, (UINTN) -1, Character);
+ PrintCharAt ((UINTN)-1, (UINTN)-1, Character);
FreePool (Buffer);
}
@@ -246,12 +248,12 @@ PrintFramework ( **/
VOID
-ProcessUserOpcode(
- IN EFI_IFR_OP_HEADER *OpCodeData
+ProcessUserOpcode (
+ IN EFI_IFR_OP_HEADER *OpCodeData
)
{
- EFI_GUID * ClassGuid;
- UINT8 ClassGuidNum;
+ EFI_GUID *ClassGuid;
+ UINT8 ClassGuidNum;
ClassGuid = NULL;
ClassGuidNum = 0;
@@ -261,65 +263,70 @@ ProcessUserOpcode( //
// process the statement outside of form,if it is formset op, get its formsetguid or classguid and compared with gFrontPageFormSetGuid
//
- if (CompareMem (PcdGetPtr (PcdFrontPageFormSetGuid), &((EFI_IFR_FORM_SET *) OpCodeData)->Guid, sizeof (EFI_GUID)) == 0){
+ if (CompareMem (PcdGetPtr (PcdFrontPageFormSetGuid), &((EFI_IFR_FORM_SET *)OpCodeData)->Guid, sizeof (EFI_GUID)) == 0) {
gClassOfVfr = FORMSET_CLASS_FRONT_PAGE;
- } else{
+ } else {
ClassGuidNum = (UINT8)(((EFI_IFR_FORM_SET *)OpCodeData)->Flags & 0x3);
ClassGuid = (EFI_GUID *)(VOID *)((UINT8 *)OpCodeData + sizeof (EFI_IFR_FORM_SET));
- while (ClassGuidNum-- > 0){
- if (CompareGuid((EFI_GUID*)PcdGetPtr (PcdFrontPageFormSetGuid),ClassGuid)){
+ while (ClassGuidNum-- > 0) {
+ if (CompareGuid ((EFI_GUID *)PcdGetPtr (PcdFrontPageFormSetGuid), ClassGuid)) {
gClassOfVfr = FORMSET_CLASS_FRONT_PAGE;
break;
}
- ClassGuid ++;
+
+ ClassGuid++;
}
}
+
break;
case EFI_IFR_GUID_OP:
- if (CompareGuid (&gEfiIfrTianoGuid, (EFI_GUID *)((CHAR8*) OpCodeData + sizeof (EFI_IFR_OP_HEADER)))) {
+ if (CompareGuid (&gEfiIfrTianoGuid, (EFI_GUID *)((CHAR8 *)OpCodeData + sizeof (EFI_IFR_OP_HEADER)))) {
//
// Tiano specific GUIDed opcodes
//
- switch (((EFI_IFR_GUID_LABEL *) OpCodeData)->ExtendOpCode) {
- case EFI_IFR_EXTEND_OP_LABEL:
- //
- // just ignore label
- //
- break;
+ switch (((EFI_IFR_GUID_LABEL *)OpCodeData)->ExtendOpCode) {
+ case EFI_IFR_EXTEND_OP_LABEL:
+ //
+ // just ignore label
+ //
+ break;
- case EFI_IFR_EXTEND_OP_BANNER:
- //
- // Only in front page form set, we care about the banner data.
- //
- if (gClassOfVfr == FORMSET_CLASS_FRONT_PAGE) {
+ case EFI_IFR_EXTEND_OP_BANNER:
//
- // Initialize Driver private data
+ // Only in front page form set, we care about the banner data.
//
- if (gBannerData == NULL) {
- gBannerData = AllocateZeroPool (sizeof (BANNER_DATA));
- ASSERT (gBannerData != NULL);
+ if (gClassOfVfr == FORMSET_CLASS_FRONT_PAGE) {
+ //
+ // Initialize Driver private data
+ //
+ if (gBannerData == NULL) {
+ gBannerData = AllocateZeroPool (sizeof (BANNER_DATA));
+ ASSERT (gBannerData != NULL);
+ }
+
+ CopyMem (
+ &gBannerData->Banner[((EFI_IFR_GUID_BANNER *)OpCodeData)->LineNumber][
+ ((EFI_IFR_GUID_BANNER *)OpCodeData)->Alignment],
+ &((EFI_IFR_GUID_BANNER *)OpCodeData)->Title,
+ sizeof (EFI_STRING_ID)
+ );
}
- CopyMem (
- &gBannerData->Banner[((EFI_IFR_GUID_BANNER *) OpCodeData)->LineNumber][
- ((EFI_IFR_GUID_BANNER *) OpCodeData)->Alignment],
- &((EFI_IFR_GUID_BANNER *) OpCodeData)->Title,
- sizeof (EFI_STRING_ID)
- );
- }
- break;
+ break;
- case EFI_IFR_EXTEND_OP_SUBCLASS:
- if (((EFI_IFR_GUID_SUBCLASS *) OpCodeData)->SubClass == EFI_FRONT_PAGE_SUBCLASS) {
- gClassOfVfr = FORMSET_CLASS_FRONT_PAGE;
- }
- break;
+ case EFI_IFR_EXTEND_OP_SUBCLASS:
+ if (((EFI_IFR_GUID_SUBCLASS *)OpCodeData)->SubClass == EFI_FRONT_PAGE_SUBCLASS) {
+ gClassOfVfr = FORMSET_CLASS_FRONT_PAGE;
+ }
- default:
- break;
+ break;
+
+ default:
+ break;
}
}
+
break;
default:
@@ -337,37 +344,36 @@ ProcessUserOpcode( **/
VOID
ProcessExternedOpcode (
- IN FORM_DISPLAY_ENGINE_FORM *FormData
+ IN FORM_DISPLAY_ENGINE_FORM *FormData
)
{
- LIST_ENTRY *Link;
- LIST_ENTRY *NestLink;
- FORM_DISPLAY_ENGINE_STATEMENT *Statement;
- FORM_DISPLAY_ENGINE_STATEMENT *NestStatement;
+ LIST_ENTRY *Link;
+ LIST_ENTRY *NestLink;
+ FORM_DISPLAY_ENGINE_STATEMENT *Statement;
+ FORM_DISPLAY_ENGINE_STATEMENT *NestStatement;
Link = GetFirstNode (&FormData->StatementListOSF);
while (!IsNull (&FormData->StatementListOSF, Link)) {
Statement = FORM_DISPLAY_ENGINE_STATEMENT_FROM_LINK (Link);
- Link = GetNextNode (&FormData->StatementListOSF, Link);
+ Link = GetNextNode (&FormData->StatementListOSF, Link);
- ProcessUserOpcode(Statement->OpCode);
+ ProcessUserOpcode (Statement->OpCode);
}
Link = GetFirstNode (&FormData->StatementListHead);
while (!IsNull (&FormData->StatementListHead, Link)) {
Statement = FORM_DISPLAY_ENGINE_STATEMENT_FROM_LINK (Link);
- Link = GetNextNode (&FormData->StatementListHead, Link);
+ Link = GetNextNode (&FormData->StatementListHead, Link);
- ProcessUserOpcode(Statement->OpCode);
+ ProcessUserOpcode (Statement->OpCode);
NestLink = GetFirstNode (&Statement->NestStatementList);
while (!IsNull (&Statement->NestStatementList, NestLink)) {
NestStatement = FORM_DISPLAY_ENGINE_STATEMENT_FROM_LINK (NestLink);
- NestLink = GetNextNode (&Statement->NestStatementList, NestLink);
+ NestLink = GetNextNode (&Statement->NestStatementList, NestLink);
- ProcessUserOpcode(NestStatement->OpCode);
+ ProcessUserOpcode (NestStatement->OpCode);
}
-
}
}
@@ -382,21 +388,21 @@ ProcessExternedOpcode ( **/
EFI_STATUS
ScreenDiemensionInfoValidate (
- IN FORM_DISPLAY_ENGINE_FORM *FormData
+ IN FORM_DISPLAY_ENGINE_FORM *FormData
)
{
- LIST_ENTRY *Link;
- UINTN Index;
+ LIST_ENTRY *Link;
+ UINTN Index;
//
// Calculate total number of Register HotKeys.
//
Index = 0;
- if (!IsListEmpty (&FormData->HotKeyListHead)){
- Link = GetFirstNode (&FormData->HotKeyListHead);
+ if (!IsListEmpty (&FormData->HotKeyListHead)) {
+ Link = GetFirstNode (&FormData->HotKeyListHead);
while (!IsNull (&FormData->HotKeyListHead, Link)) {
Link = GetNextNode (&FormData->HotKeyListHead, Link);
- Index ++;
+ Index++;
}
}
@@ -405,7 +411,6 @@ ScreenDiemensionInfoValidate ( //
gFooterHeight = FOOTER_HEIGHT + (Index / 3);
-
ZeroMem (&gScreenDimensions, sizeof (EFI_SCREEN_DESCRIPTOR));
gST->ConOut->QueryMode (
gST->ConOut,
@@ -420,7 +425,8 @@ ScreenDiemensionInfoValidate ( if (FormData->ScreenDimensions != NULL) {
if ((gScreenDimensions.RightColumn < FormData->ScreenDimensions->RightColumn) ||
(gScreenDimensions.BottomRow < FormData->ScreenDimensions->BottomRow)
- ) {
+ )
+ {
return EFI_INVALID_PARAMETER;
} else {
//
@@ -430,8 +436,9 @@ ScreenDiemensionInfoValidate ( (FormData->ScreenDimensions->BottomRow > FormData->ScreenDimensions->TopRow) &&
((FormData->ScreenDimensions->RightColumn - FormData->ScreenDimensions->LeftColumn) > 2) &&
((FormData->ScreenDimensions->BottomRow - FormData->ScreenDimensions->TopRow) > STATUS_BAR_HEIGHT +
- FRONT_PAGE_HEADER_HEIGHT + gFooterHeight + 3)) {
- CopyMem (&gScreenDimensions, (VOID *) FormData->ScreenDimensions, sizeof (EFI_SCREEN_DESCRIPTOR));
+ FRONT_PAGE_HEADER_HEIGHT + gFooterHeight + 3))
+ {
+ CopyMem (&gScreenDimensions, (VOID *)FormData->ScreenDimensions, sizeof (EFI_SCREEN_DESCRIPTOR));
} else {
return EFI_INVALID_PARAMETER;
}
@@ -453,8 +460,8 @@ ScreenDiemensionInfoValidate ( **/
CHAR16 *
LibGetToken (
- IN EFI_STRING_ID Token,
- IN EFI_HII_HANDLE HiiHandle
+ IN EFI_STRING_ID Token,
+ IN EFI_HII_HANDLE HiiHandle
)
{
EFI_STRING String;
@@ -465,10 +472,9 @@ LibGetToken ( ASSERT (String != NULL);
}
- return (CHAR16 *) String;
+ return (CHAR16 *)String;
}
-
/**
Count the storage space of a Unicode string.
@@ -487,31 +493,32 @@ LibGetToken ( **/
UINTN
LibGetStringWidth (
- IN CHAR16 *String
+ IN CHAR16 *String
)
{
- UINTN Index;
- UINTN Count;
- UINTN IncrementValue;
+ UINTN Index;
+ UINTN Count;
+ UINTN IncrementValue;
ASSERT (String != NULL);
if (String == NULL) {
return 0;
}
- Index = 0;
- Count = 0;
- IncrementValue = 1;
+ Index = 0;
+ Count = 0;
+ IncrementValue = 1;
do {
//
// Advance to the null-terminator or to the first width directive
//
- for (;
- (String[Index] != NARROW_CHAR) && (String[Index] != WIDE_CHAR) && (String[Index] != 0);
- Index++, Count = Count + IncrementValue
- )
- ;
+ for ( ;
+ (String[Index] != NARROW_CHAR) && (String[Index] != WIDE_CHAR) && (String[Index] != 0);
+ Index++, Count = Count + IncrementValue
+ )
+ {
+ }
//
// We hit the null-terminator, we now have a count
@@ -519,6 +526,7 @@ LibGetStringWidth ( if (String[Index] == 0) {
break;
}
+
//
// We encountered a narrow directive - strip it from the size calculation since it doesn't get printed
// and also set the flag that determines what we increment by.(if narrow, increment by 1, if wide increment by 2)
@@ -555,8 +563,8 @@ LibGetStringWidth ( **/
VOID
PrintHotKeyHelpString (
- IN FORM_DISPLAY_ENGINE_FORM *FormData,
- IN BOOLEAN SetState
+ IN FORM_DISPLAY_ENGINE_FORM *FormData,
+ IN BOOLEAN SetState
)
{
UINTN CurrentCol;
@@ -573,9 +581,9 @@ PrintHotKeyHelpString ( CHAR16 *ColumnStr;
CopyMem (&LocalScreen, &gScreenDimensions, sizeof (EFI_SCREEN_DESCRIPTOR));
- ColumnWidth = (LocalScreen.RightColumn - LocalScreen.LeftColumn) / 3;
- BottomRowOfHotKeyHelp = LocalScreen.BottomRow - STATUS_BAR_HEIGHT - 3;
- ColumnStr = gLibEmptyString;
+ ColumnWidth = (LocalScreen.RightColumn - LocalScreen.LeftColumn) / 3;
+ BottomRowOfHotKeyHelp = LocalScreen.BottomRow - STATUS_BAR_HEIGHT - 3;
+ ColumnStr = gLibEmptyString;
//
// Calculate total number of Register HotKeys.
@@ -598,6 +606,7 @@ PrintHotKeyHelpString ( CurrentCol = LocalScreen.LeftColumn + 2;
ColumnIndexWidth = ColumnWidth - 2;
}
+
CurrentRow = BottomRowOfHotKeyHelp - Index / 3;
//
@@ -605,7 +614,7 @@ PrintHotKeyHelpString ( //
BakChar = L'\0';
if (StrLen (HotKey->HelpString) > ColumnIndexWidth) {
- BakChar = HotKey->HelpString[ColumnIndexWidth];
+ BakChar = HotKey->HelpString[ColumnIndexWidth];
HotKey->HelpString[ColumnIndexWidth] = L'\0';
}
@@ -615,16 +624,18 @@ PrintHotKeyHelpString ( if (SetState) {
ColumnStr = HotKey->HelpString;
}
+
PrintStringAtWithWidth (CurrentCol, CurrentRow, ColumnStr, ColumnIndexWidth);
if (BakChar != L'\0') {
HotKey->HelpString[ColumnIndexWidth] = BakChar;
}
+
//
// Get Next Hot Key.
//
Link = GetNextNode (&FormData->HotKeyListHead, Link);
- Index ++;
+ Index++;
}
if (SetState) {
@@ -636,9 +647,10 @@ PrintHotKeyHelpString ( if (ColumnIndex == 0) {
CurrentCol = LocalScreen.LeftColumn + 2 * ColumnWidth;
ColumnIndexWidth = ColumnWidth - 1;
- ColumnIndex ++;
+ ColumnIndex++;
PrintStringAtWithWidth (CurrentCol, CurrentRow, gLibEmptyString, ColumnIndexWidth);
}
+
if (ColumnIndex == 1) {
CurrentCol = LocalScreen.LeftColumn + ColumnWidth;
ColumnIndexWidth = ColumnWidth;
@@ -658,34 +670,34 @@ PrintHotKeyHelpString ( **/
UINT64
LibGetFieldFromNum (
- IN EFI_IFR_OP_HEADER *OpCode
+ IN EFI_IFR_OP_HEADER *OpCode
)
{
- EFI_IFR_NUMERIC *NumericOp;
- UINT64 Step;
+ EFI_IFR_NUMERIC *NumericOp;
+ UINT64 Step;
- NumericOp = (EFI_IFR_NUMERIC *) OpCode;
+ NumericOp = (EFI_IFR_NUMERIC *)OpCode;
switch (NumericOp->Flags & EFI_IFR_NUMERIC_SIZE) {
- case EFI_IFR_NUMERIC_SIZE_1:
- Step = NumericOp->data.u8.Step;
- break;
+ case EFI_IFR_NUMERIC_SIZE_1:
+ Step = NumericOp->data.u8.Step;
+ break;
- case EFI_IFR_NUMERIC_SIZE_2:
- Step = NumericOp->data.u16.Step;
- break;
+ case EFI_IFR_NUMERIC_SIZE_2:
+ Step = NumericOp->data.u16.Step;
+ break;
- case EFI_IFR_NUMERIC_SIZE_4:
- Step = NumericOp->data.u32.Step;
- break;
+ case EFI_IFR_NUMERIC_SIZE_4:
+ Step = NumericOp->data.u32.Step;
+ break;
- case EFI_IFR_NUMERIC_SIZE_8:
- Step = NumericOp->data.u64.Step;
- break;
+ case EFI_IFR_NUMERIC_SIZE_8:
+ Step = NumericOp->data.u64.Step;
+ break;
- default:
- Step = 0;
- break;
+ default:
+ Step = 0;
+ break;
}
return Step;
@@ -700,29 +712,29 @@ InitializeLibStrings ( VOID
)
{
- mLibUnknownString = L"!";
-
- gEnterString = LibGetToken (STRING_TOKEN (ENTER_STRING), mCDLStringPackHandle);
- gEnterCommitString = LibGetToken (STRING_TOKEN (ENTER_COMMIT_STRING), mCDLStringPackHandle);
- gEnterEscapeString = LibGetToken (STRING_TOKEN (ENTER_ESCAPE_STRING), mCDLStringPackHandle);
- gEscapeString = LibGetToken (STRING_TOKEN (ESCAPE_STRING), mCDLStringPackHandle);
- gMoveHighlight = LibGetToken (STRING_TOKEN (MOVE_HIGHLIGHT), mCDLStringPackHandle);
- gDecNumericInput = LibGetToken (STRING_TOKEN (DEC_NUMERIC_INPUT), mCDLStringPackHandle);
- gHexNumericInput = LibGetToken (STRING_TOKEN (HEX_NUMERIC_INPUT), mCDLStringPackHandle);
- gToggleCheckBox = LibGetToken (STRING_TOKEN (TOGGLE_CHECK_BOX), mCDLStringPackHandle);
-
- gAreYouSure = LibGetToken (STRING_TOKEN (ARE_YOU_SURE), mCDLStringPackHandle);
- gYesResponse = LibGetToken (STRING_TOKEN (ARE_YOU_SURE_YES), mCDLStringPackHandle);
- gNoResponse = LibGetToken (STRING_TOKEN (ARE_YOU_SURE_NO), mCDLStringPackHandle);
- gPlusString = LibGetToken (STRING_TOKEN (PLUS_STRING), mCDLStringPackHandle);
- gMinusString = LibGetToken (STRING_TOKEN (MINUS_STRING), mCDLStringPackHandle);
- gAdjustNumber = LibGetToken (STRING_TOKEN (ADJUST_NUMBER), mCDLStringPackHandle);
- gSaveChanges = LibGetToken (STRING_TOKEN (SAVE_CHANGES), mCDLStringPackHandle);
-
- gLibEmptyString = LibGetToken (STRING_TOKEN (EMPTY_STRING), mCDLStringPackHandle);
-
- gNvUpdateMessage = LibGetToken (STRING_TOKEN (NV_UPDATE_MESSAGE), mCDLStringPackHandle);
- gInputErrorMessage = LibGetToken (STRING_TOKEN (INPUT_ERROR_MESSAGE), mCDLStringPackHandle);
+ mLibUnknownString = L"!";
+
+ gEnterString = LibGetToken (STRING_TOKEN (ENTER_STRING), mCDLStringPackHandle);
+ gEnterCommitString = LibGetToken (STRING_TOKEN (ENTER_COMMIT_STRING), mCDLStringPackHandle);
+ gEnterEscapeString = LibGetToken (STRING_TOKEN (ENTER_ESCAPE_STRING), mCDLStringPackHandle);
+ gEscapeString = LibGetToken (STRING_TOKEN (ESCAPE_STRING), mCDLStringPackHandle);
+ gMoveHighlight = LibGetToken (STRING_TOKEN (MOVE_HIGHLIGHT), mCDLStringPackHandle);
+ gDecNumericInput = LibGetToken (STRING_TOKEN (DEC_NUMERIC_INPUT), mCDLStringPackHandle);
+ gHexNumericInput = LibGetToken (STRING_TOKEN (HEX_NUMERIC_INPUT), mCDLStringPackHandle);
+ gToggleCheckBox = LibGetToken (STRING_TOKEN (TOGGLE_CHECK_BOX), mCDLStringPackHandle);
+
+ gAreYouSure = LibGetToken (STRING_TOKEN (ARE_YOU_SURE), mCDLStringPackHandle);
+ gYesResponse = LibGetToken (STRING_TOKEN (ARE_YOU_SURE_YES), mCDLStringPackHandle);
+ gNoResponse = LibGetToken (STRING_TOKEN (ARE_YOU_SURE_NO), mCDLStringPackHandle);
+ gPlusString = LibGetToken (STRING_TOKEN (PLUS_STRING), mCDLStringPackHandle);
+ gMinusString = LibGetToken (STRING_TOKEN (MINUS_STRING), mCDLStringPackHandle);
+ gAdjustNumber = LibGetToken (STRING_TOKEN (ADJUST_NUMBER), mCDLStringPackHandle);
+ gSaveChanges = LibGetToken (STRING_TOKEN (SAVE_CHANGES), mCDLStringPackHandle);
+
+ gLibEmptyString = LibGetToken (STRING_TOKEN (EMPTY_STRING), mCDLStringPackHandle);
+
+ gNvUpdateMessage = LibGetToken (STRING_TOKEN (NV_UPDATE_MESSAGE), mCDLStringPackHandle);
+ gInputErrorMessage = LibGetToken (STRING_TOKEN (INPUT_ERROR_MESSAGE), mCDLStringPackHandle);
//
// SpaceBuffer;
@@ -733,7 +745,6 @@ InitializeLibStrings ( mSpaceBuffer[SPACE_BUFFER_SIZE] = L'\0';
}
-
/**
Free the HII String.
@@ -778,7 +789,7 @@ FreeLibStrings ( **/
EFI_STATUS
WaitForKeyStroke (
- OUT EFI_INPUT_KEY *Key
+ OUT EFI_INPUT_KEY *Key
)
{
EFI_STATUS Status;
@@ -796,10 +807,10 @@ WaitForKeyStroke ( gBS->WaitForEvent (1, &gST->ConIn->WaitForKey, &Index);
}
+
return Status;
}
-
/**
Set Buffer to Value for Size bytes.
@@ -810,9 +821,9 @@ WaitForKeyStroke ( **/
VOID
LibSetUnicodeMem (
- IN VOID *Buffer,
- IN UINTN Size,
- IN CHAR16 Value
+ IN VOID *Buffer,
+ IN UINTN Size,
+ IN CHAR16 Value
)
{
CHAR16 *Ptr;
@@ -859,12 +870,12 @@ PrintInternal ( //
// For now, allocate an arbitrarily long buffer
//
- Buffer = AllocateZeroPool (0x10000);
- BackupBuffer = AllocateZeroPool (0x10000);
+ Buffer = AllocateZeroPool (0x10000);
+ BackupBuffer = AllocateZeroPool (0x10000);
ASSERT (Buffer);
ASSERT (BackupBuffer);
- if (Column != (UINTN) -1) {
+ if (Column != (UINTN)-1) {
Out->SetCursorPosition (Out, Column, Row);
}
@@ -882,7 +893,7 @@ PrintInternal ( CharWidth = 1;
do {
- for (; (Buffer[Index] != NARROW_CHAR) && (Buffer[Index] != WIDE_CHAR) && (Buffer[Index] != 0); Index++) {
+ for ( ; (Buffer[Index] != NARROW_CHAR) && (Buffer[Index] != WIDE_CHAR) && (Buffer[Index] != 0); Index++) {
BackupBuffer[Index] = Buffer[Index];
}
@@ -894,7 +905,7 @@ PrintInternal ( // Print this out, we are about to switch widths
//
Out->OutputString (Out, &BackupBuffer[PreviousIndex]);
- Count = StrLen (&BackupBuffer[PreviousIndex]);
+ Count = StrLen (&BackupBuffer[PreviousIndex]);
PrintWidth += Count * CharWidth;
TotalCount += Count;
@@ -923,14 +934,13 @@ PrintInternal ( }
Index++;
-
} while (Buffer[Index] != 0);
//
// We hit the end of the string - print it
//
Out->OutputString (Out, &BackupBuffer[PreviousIndex]);
- Count = StrLen (&BackupBuffer[PreviousIndex]);
+ Count = StrLen (&BackupBuffer[PreviousIndex]);
PrintWidth += Count * CharWidth;
TotalCount += Count;
if (PrintWidth < Width) {
@@ -960,19 +970,18 @@ PrintInternal ( UINTN
EFIAPI
PrintAt (
- IN UINTN Width,
- IN UINTN Column,
- IN UINTN Row,
- IN CHAR16 *Fmt,
+ IN UINTN Width,
+ IN UINTN Column,
+ IN UINTN Row,
+ IN CHAR16 *Fmt,
...
)
{
- VA_LIST Args;
- UINTN LengthOfPrinted;
+ VA_LIST Args;
+ UINTN LengthOfPrinted;
VA_START (Args, Fmt);
LengthOfPrinted = PrintInternal (Width, Column, Row, gST->ConOut, Fmt, Args);
VA_END (Args);
return LengthOfPrinted;
}
-
diff --git a/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLibInternal.h b/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLibInternal.h index 08a330401b..01213cb059 100644 --- a/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLibInternal.h +++ b/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLibInternal.h @@ -10,8 +10,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #ifndef __CUSTOMIZED_DISPLAY_LIB_INTERNAL_H__
#define __CUSTOMIZED_DISPLAY_LIB_INTERNAL_H__
-
-
#include <PiDxe.h>
#include <Protocol/SimpleTextOut.h>
@@ -47,33 +45,30 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include "Colors.h"
+#define FORMSET_CLASS_PLATFORM_SETUP 0x0001
+#define FORMSET_CLASS_FRONT_PAGE 0x0002
-
-#define FORMSET_CLASS_PLATFORM_SETUP 0x0001
-#define FORMSET_CLASS_FRONT_PAGE 0x0002
-
-
-#define FRONT_PAGE_HEADER_HEIGHT 6
-#define NONE_FRONT_PAGE_HEADER_HEIGHT 3
-#define FOOTER_HEIGHT 4
-#define STATUS_BAR_HEIGHT 1
+#define FRONT_PAGE_HEADER_HEIGHT 6
+#define NONE_FRONT_PAGE_HEADER_HEIGHT 3
+#define FOOTER_HEIGHT 4
+#define STATUS_BAR_HEIGHT 1
//
// Screen definitions
//
-#define BANNER_HEIGHT 6
-#define BANNER_COLUMNS 3
-#define BANNER_LEFT_COLUMN_INDENT 1
+#define BANNER_HEIGHT 6
+#define BANNER_COLUMNS 3
+#define BANNER_LEFT_COLUMN_INDENT 1
//
// Character definitions
//
-#define UPPER_LOWER_CASE_OFFSET 0x20
+#define UPPER_LOWER_CASE_OFFSET 0x20
//
// This is the Input Error Message
//
-#define INPUT_ERROR 1
+#define INPUT_ERROR 1
//
// This is the NV RAM update required Message
@@ -81,35 +76,36 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #define NV_UPDATE_REQUIRED 2
typedef struct {
- EFI_STRING_ID Banner[BANNER_HEIGHT][BANNER_COLUMNS];
+ EFI_STRING_ID Banner[BANNER_HEIGHT][BANNER_COLUMNS];
} BANNER_DATA;
-extern UINT16 gClassOfVfr; // Formset class information
-extern BANNER_DATA *gBannerData;
-extern EFI_SCREEN_DESCRIPTOR gScreenDimensions;
-extern UINTN gFooterHeight;
+extern UINT16 gClassOfVfr; // Formset class information
+extern BANNER_DATA *gBannerData;
+extern EFI_SCREEN_DESCRIPTOR gScreenDimensions;
+extern UINTN gFooterHeight;
//
// Browser Global Strings
//
-extern CHAR16 *gEnterString;
-extern CHAR16 *gEnterCommitString;
-extern CHAR16 *gEnterEscapeString;
-extern CHAR16 *gEscapeString;
-extern CHAR16 *gMoveHighlight;
-extern CHAR16 *gDecNumericInput;
-extern CHAR16 *gHexNumericInput;
-extern CHAR16 *gToggleCheckBox;
-extern CHAR16 *gLibEmptyString;
-extern CHAR16 *gAreYouSure;
-extern CHAR16 *gYesResponse;
-extern CHAR16 *gNoResponse;
-extern CHAR16 *gPlusString;
-extern CHAR16 *gMinusString;
-extern CHAR16 *gAdjustNumber;
-extern CHAR16 *gSaveChanges;
-extern CHAR16 *gNvUpdateMessage;
-extern CHAR16 *gInputErrorMessage;
+extern CHAR16 *gEnterString;
+extern CHAR16 *gEnterCommitString;
+extern CHAR16 *gEnterEscapeString;
+extern CHAR16 *gEscapeString;
+extern CHAR16 *gMoveHighlight;
+extern CHAR16 *gDecNumericInput;
+extern CHAR16 *gHexNumericInput;
+extern CHAR16 *gToggleCheckBox;
+extern CHAR16 *gLibEmptyString;
+extern CHAR16 *gAreYouSure;
+extern CHAR16 *gYesResponse;
+extern CHAR16 *gNoResponse;
+extern CHAR16 *gPlusString;
+extern CHAR16 *gMinusString;
+extern CHAR16 *gAdjustNumber;
+extern CHAR16 *gSaveChanges;
+extern CHAR16 *gNvUpdateMessage;
+extern CHAR16 *gInputErrorMessage;
+
/**
Print banner info for front page.
@@ -119,7 +115,7 @@ extern CHAR16 *gInputErrorMessage; **/
VOID
PrintBannerInfo (
- IN FORM_DISPLAY_ENGINE_FORM *FormData
+ IN FORM_DISPLAY_ENGINE_FORM *FormData
);
/**
@@ -129,7 +125,7 @@ PrintBannerInfo ( **/
VOID
PrintFramework (
- IN FORM_DISPLAY_ENGINE_FORM *FormData
+ IN FORM_DISPLAY_ENGINE_FORM *FormData
);
/**
@@ -143,7 +139,7 @@ PrintFramework ( **/
EFI_STATUS
ScreenDiemensionInfoValidate (
- IN FORM_DISPLAY_ENGINE_FORM *FormData
+ IN FORM_DISPLAY_ENGINE_FORM *FormData
);
/**
@@ -158,8 +154,8 @@ ScreenDiemensionInfoValidate ( **/
CHAR16 *
LibGetToken (
- IN EFI_STRING_ID Token,
- IN EFI_HII_HANDLE HiiHandle
+ IN EFI_STRING_ID Token,
+ IN EFI_HII_HANDLE HiiHandle
);
/**
@@ -180,7 +176,7 @@ LibGetToken ( **/
UINTN
LibGetStringWidth (
- IN CHAR16 *String
+ IN CHAR16 *String
);
/**
@@ -192,8 +188,8 @@ LibGetStringWidth ( **/
VOID
PrintHotKeyHelpString (
- IN FORM_DISPLAY_ENGINE_FORM *FormData,
- IN BOOLEAN SetState
+ IN FORM_DISPLAY_ENGINE_FORM *FormData,
+ IN BOOLEAN SetState
);
/**
@@ -205,7 +201,7 @@ PrintHotKeyHelpString ( **/
UINT64
LibGetFieldFromNum (
- IN EFI_IFR_OP_HEADER *OpCode
+ IN EFI_IFR_OP_HEADER *OpCode
);
/**
@@ -236,7 +232,7 @@ FreeLibStrings ( **/
EFI_STATUS
WaitForKeyStroke (
- OUT EFI_INPUT_KEY *Key
+ OUT EFI_INPUT_KEY *Key
);
/**
@@ -249,9 +245,9 @@ WaitForKeyStroke ( **/
VOID
LibSetUnicodeMem (
- IN VOID *Buffer,
- IN UINTN Size,
- IN CHAR16 Value
+ IN VOID *Buffer,
+ IN UINTN Size,
+ IN CHAR16 Value
);
/**
@@ -270,10 +266,10 @@ LibSetUnicodeMem ( UINTN
EFIAPI
PrintAt (
- IN UINTN Width,
- IN UINTN Column,
- IN UINTN Row,
- IN CHAR16 *Fmt,
+ IN UINTN Width,
+ IN UINTN Column,
+ IN UINTN Row,
+ IN CHAR16 *Fmt,
...
);
@@ -285,7 +281,7 @@ PrintAt ( **/
VOID
ProcessExternedOpcode (
- IN FORM_DISPLAY_ENGINE_FORM *FormData
+ IN FORM_DISPLAY_ENGINE_FORM *FormData
);
#endif
diff --git a/MdeModulePkg/Library/DebugAgentLibNull/DebugAgentLibNull.c b/MdeModulePkg/Library/DebugAgentLibNull/DebugAgentLibNull.c index e180f90e6b..8e70705eb6 100644 --- a/MdeModulePkg/Library/DebugAgentLibNull/DebugAgentLibNull.c +++ b/MdeModulePkg/Library/DebugAgentLibNull/DebugAgentLibNull.c @@ -58,7 +58,7 @@ InitializeDebugAgent ( BOOLEAN
EFIAPI
SaveAndSetDebugTimerInterrupt (
- IN BOOLEAN EnableStatus
+ IN BOOLEAN EnableStatus
)
{
return FALSE;
diff --git a/MdeModulePkg/Library/DeviceManagerUiLib/DeviceManager.c b/MdeModulePkg/Library/DeviceManagerUiLib/DeviceManager.c index 3bc13d3407..c8ca25e87f 100644 --- a/MdeModulePkg/Library/DeviceManagerUiLib/DeviceManager.c +++ b/MdeModulePkg/Library/DeviceManagerUiLib/DeviceManager.c @@ -19,9 +19,9 @@ DEVICE_MANAGER_CALLBACK_DATA gDeviceManagerPrivate = { }
};
-#define MAX_MAC_ADDRESS_NODE_LIST_LEN 10
+#define MAX_MAC_ADDRESS_NODE_LIST_LEN 10
-EFI_GUID mDeviceManagerGuid = DEVICE_MANAGER_FORMSET_GUID;
+EFI_GUID mDeviceManagerGuid = DEVICE_MANAGER_FORMSET_GUID;
//
// Which Mac Address string is select
@@ -40,21 +40,22 @@ HII_VENDOR_DEVICE_PATH mDeviceManagerHiiVendorDevicePath = { HARDWARE_DEVICE_PATH,
HW_VENDOR_DP,
{
- (UINT8) (sizeof (VENDOR_DEVICE_PATH)),
- (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)
+ (UINT8)(sizeof (VENDOR_DEVICE_PATH)),
+ (UINT8)((sizeof (VENDOR_DEVICE_PATH)) >> 8)
}
},
//
// {102579A0-3686-466e-ACD8-80C087044F4A}
//
- { 0x102579a0, 0x3686, 0x466e, { 0xac, 0xd8, 0x80, 0xc0, 0x87, 0x4, 0x4f, 0x4a } }
+ { 0x102579a0, 0x3686, 0x466e, { 0xac, 0xd8, 0x80, 0xc0, 0x87, 0x4, 0x4f, 0x4a }
+ }
},
{
END_DEVICE_PATH_TYPE,
END_ENTIRE_DEVICE_PATH_SUBTYPE,
{
- (UINT8) (END_DEVICE_PATH_LENGTH),
- (UINT8) ((END_DEVICE_PATH_LENGTH) >> 8)
+ (UINT8)(END_DEVICE_PATH_LENGTH),
+ (UINT8)((END_DEVICE_PATH_LENGTH) >> 8)
}
}
};
@@ -70,11 +71,11 @@ HII_VENDOR_DEVICE_PATH mDeviceManagerHiiVendorDevicePath = { **/
CHAR16 *
DmExtractDevicePathFromHiiHandle (
- IN EFI_HII_HANDLE Handle
+ IN EFI_HII_HANDLE Handle
)
{
- EFI_STATUS Status;
- EFI_HANDLE DriverHandle;
+ EFI_STATUS Status;
+ EFI_HANDLE DriverHandle;
ASSERT (Handle != NULL);
@@ -86,10 +87,11 @@ DmExtractDevicePathFromHiiHandle ( if (EFI_ERROR (Status)) {
return NULL;
}
+
//
// Get device path string.
//
- return ConvertDevicePathToText(DevicePathFromHandle (DriverHandle), FALSE, FALSE);
+ return ConvertDevicePathToText (DevicePathFromHandle (DriverHandle), FALSE, FALSE);
}
/**
@@ -101,25 +103,25 @@ DmExtractDevicePathFromHiiHandle ( **/
BOOLEAN
-GetMacAddressString(
- IN MAC_ADDR_DEVICE_PATH *MacAddressNode,
- OUT CHAR16 **PBuffer
+GetMacAddressString (
+ IN MAC_ADDR_DEVICE_PATH *MacAddressNode,
+ OUT CHAR16 **PBuffer
)
{
- UINTN HwAddressSize;
- UINTN Index;
- UINT8 *HwAddress;
+ UINTN HwAddressSize;
+ UINTN Index;
+ UINT8 *HwAddress;
EFI_DEVICE_PATH_PROTOCOL *Node;
- UINT16 VlanId;
- CHAR16 *String;
- UINTN BufferLen;
+ UINT16 VlanId;
+ CHAR16 *String;
+ UINTN BufferLen;
VlanId = 0;
String = NULL;
- ASSERT(MacAddressNode != NULL);
+ ASSERT (MacAddressNode != NULL);
HwAddressSize = sizeof (EFI_MAC_ADDRESS);
- if (MacAddressNode->IfType == 0x01 || MacAddressNode->IfType == 0x00) {
+ if ((MacAddressNode->IfType == 0x01) || (MacAddressNode->IfType == 0x00)) {
HwAddressSize = 6;
}
@@ -128,13 +130,13 @@ GetMacAddressString( // The size is the Number size + ":" size + Vlan size(\XXXX) + End
//
BufferLen = (4 + 2 * HwAddressSize + (HwAddressSize - 1) + 5 + 1) * sizeof (CHAR16);
- String = AllocateZeroPool (BufferLen);
+ String = AllocateZeroPool (BufferLen);
if (String == NULL) {
return FALSE;
}
*PBuffer = String;
- StrCpyS(String, BufferLen / sizeof (CHAR16), L"MAC:");
+ StrCpyS (String, BufferLen / sizeof (CHAR16), L"MAC:");
String += 4;
//
@@ -161,9 +163,10 @@ GetMacAddressString( //
Node = (EFI_DEVICE_PATH_PROTOCOL *)MacAddressNode;
while (!IsDevicePathEnd (Node)) {
- if (Node->Type == MESSAGING_DEVICE_PATH && Node->SubType == MSG_VLAN_DP) {
- VlanId = ((VLAN_DEVICE_PATH *) Node)->VlanId;
+ if ((Node->Type == MESSAGING_DEVICE_PATH) && (Node->SubType == MSG_VLAN_DP)) {
+ VlanId = ((VLAN_DEVICE_PATH *)Node)->VlanId;
}
+
Node = NextDevicePathNode (Node);
}
@@ -198,19 +201,19 @@ GetMacAddressString( **/
BOOLEAN
AddIdToMacDeviceList (
- IN EFI_STRING MacAddrString
+ IN EFI_STRING MacAddrString
)
{
- MENU_INFO_ITEM *TempDeviceList;
- UINTN Index;
- EFI_STRING StoredString;
- EFI_STRING_ID PromptId;
- EFI_HII_HANDLE HiiHandle;
+ MENU_INFO_ITEM *TempDeviceList;
+ UINTN Index;
+ EFI_STRING StoredString;
+ EFI_STRING_ID PromptId;
+ EFI_HII_HANDLE HiiHandle;
- HiiHandle = gDeviceManagerPrivate.HiiHandle;
+ HiiHandle = gDeviceManagerPrivate.HiiHandle;
TempDeviceList = NULL;
- for (Index = 0; Index < mMacDeviceList.CurListLen; Index ++) {
+ for (Index = 0; Index < mMacDeviceList.CurListLen; Index++) {
StoredString = HiiGetString (HiiHandle, mMacDeviceList.NodeList[Index].PromptId, NULL);
if (StoredString == NULL) {
return FALSE;
@@ -224,13 +227,13 @@ AddIdToMacDeviceList ( }
}
- PromptId = HiiSetString(HiiHandle, 0, MacAddrString, NULL);
+ PromptId = HiiSetString (HiiHandle, 0, MacAddrString, NULL);
//
// If not in the list, save it.
//
if (mMacDeviceList.MaxListLen > mMacDeviceList.CurListLen + 1) {
- mMacDeviceList.NodeList[mMacDeviceList.CurListLen].PromptId = PromptId;
- mMacDeviceList.NodeList[mMacDeviceList.CurListLen].QuestionId = (EFI_QUESTION_ID) (mMacDeviceList.CurListLen + NETWORK_DEVICE_LIST_KEY_OFFSET);
+ mMacDeviceList.NodeList[mMacDeviceList.CurListLen].PromptId = PromptId;
+ mMacDeviceList.NodeList[mMacDeviceList.CurListLen].QuestionId = (EFI_QUESTION_ID)(mMacDeviceList.CurListLen + NETWORK_DEVICE_LIST_KEY_OFFSET);
} else {
mMacDeviceList.MaxListLen += MAX_MAC_ADDRESS_NODE_LIST_LEN;
if (mMacDeviceList.CurListLen != 0) {
@@ -246,12 +249,14 @@ AddIdToMacDeviceList ( if (TempDeviceList == NULL) {
return FALSE;
}
- TempDeviceList[mMacDeviceList.CurListLen].PromptId = PromptId;
- TempDeviceList[mMacDeviceList.CurListLen].QuestionId = (EFI_QUESTION_ID) (mMacDeviceList.CurListLen + NETWORK_DEVICE_LIST_KEY_OFFSET);
+
+ TempDeviceList[mMacDeviceList.CurListLen].PromptId = PromptId;
+ TempDeviceList[mMacDeviceList.CurListLen].QuestionId = (EFI_QUESTION_ID)(mMacDeviceList.CurListLen + NETWORK_DEVICE_LIST_KEY_OFFSET);
mMacDeviceList.NodeList = TempDeviceList;
}
- mMacDeviceList.CurListLen ++;
+
+ mMacDeviceList.CurListLen++;
return TRUE;
}
@@ -273,28 +278,29 @@ AddIdToMacDeviceList ( **/
BOOLEAN
IsMacAddressDevicePath (
- IN VOID *Node,
- IN EFI_FORM_ID NextShowFormId,
- OUT BOOLEAN *NeedAddItem
+ IN VOID *Node,
+ IN EFI_FORM_ID NextShowFormId,
+ OUT BOOLEAN *NeedAddItem
)
{
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- CHAR16 *Buffer;
- BOOLEAN ReturnVal;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ CHAR16 *Buffer;
+ BOOLEAN ReturnVal;
ASSERT (Node != NULL);
*NeedAddItem = FALSE;
ReturnVal = FALSE;
- Buffer = NULL;
+ Buffer = NULL;
- DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) Node;
+ DevicePath = (EFI_DEVICE_PATH_PROTOCOL *)Node;
//
// find the partition device path node
//
while (!IsDevicePathEnd (DevicePath)) {
if ((DevicePathType (DevicePath) == MESSAGING_DEVICE_PATH) &&
- (DevicePathSubType (DevicePath) == MSG_MAC_ADDR_DP)) {
+ (DevicePathSubType (DevicePath) == MSG_MAC_ADDR_DP))
+ {
ReturnVal = TRUE;
if (DEVICE_MANAGER_FORM_ID == NextShowFormId) {
@@ -302,7 +308,7 @@ IsMacAddressDevicePath ( break;
}
- if (!GetMacAddressString((MAC_ADDR_DEVICE_PATH*)DevicePath, &Buffer)) {
+ if (!GetMacAddressString ((MAC_ADDR_DEVICE_PATH *)DevicePath, &Buffer)) {
break;
}
@@ -310,6 +316,7 @@ IsMacAddressDevicePath ( if (StrCmp (Buffer, mSelectedMacAddrString) == 0) {
*NeedAddItem = TRUE;
}
+
break;
}
@@ -321,9 +328,11 @@ IsMacAddressDevicePath ( if (AddIdToMacDeviceList (Buffer)) {
*NeedAddItem = TRUE;
}
+
break;
}
}
+
DevicePath = NextDevicePathNode (DevicePath);
}
@@ -347,40 +356,43 @@ IsMacAddressDevicePath ( **/
BOOLEAN
IsNeedAddNetworkMenu (
- IN EFI_HII_HANDLE Handle,
- IN EFI_FORM_ID NextShowFormId,
- OUT UINTN *ItemCount
+ IN EFI_HII_HANDLE Handle,
+ IN EFI_FORM_ID NextShowFormId,
+ OUT UINTN *ItemCount
)
{
- EFI_STATUS Status;
- UINTN EntryCount;
- UINTN Index;
- EFI_HANDLE DriverHandle;
- EFI_HANDLE ControllerHandle;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- EFI_DEVICE_PATH_PROTOCOL *TmpDevicePath;
- EFI_DEVICE_PATH_PROTOCOL *ChildDevicePath;
- EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *OpenInfoBuffer;
- BOOLEAN IsNeedAdd;
-
- IsNeedAdd = FALSE;
+ EFI_STATUS Status;
+ UINTN EntryCount;
+ UINTN Index;
+ EFI_HANDLE DriverHandle;
+ EFI_HANDLE ControllerHandle;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ EFI_DEVICE_PATH_PROTOCOL *TmpDevicePath;
+ EFI_DEVICE_PATH_PROTOCOL *ChildDevicePath;
+ EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *OpenInfoBuffer;
+ BOOLEAN IsNeedAdd;
+
+ IsNeedAdd = FALSE;
OpenInfoBuffer = NULL;
if ((Handle == NULL) || (ItemCount == NULL)) {
return FALSE;
}
+
*ItemCount = 0;
Status = gHiiDatabase->GetPackageListHandle (gHiiDatabase, Handle, &DriverHandle);
if (EFI_ERROR (Status)) {
return FALSE;
}
+
//
// Get the device path by the got Driver handle .
//
- Status = gBS->HandleProtocol (DriverHandle, &gEfiDevicePathProtocolGuid, (VOID **) &DevicePath);
+ Status = gBS->HandleProtocol (DriverHandle, &gEfiDevicePathProtocolGuid, (VOID **)&DevicePath);
if (EFI_ERROR (Status)) {
return FALSE;
}
+
TmpDevicePath = DevicePath;
//
@@ -389,10 +401,11 @@ IsNeedAddNetworkMenu ( // add this info to the menu and return.
// Else check more about the child handle devcie path.
//
- if (IsMacAddressDevicePath(TmpDevicePath, NextShowFormId,&IsNeedAdd)) {
+ if (IsMacAddressDevicePath (TmpDevicePath, NextShowFormId, &IsNeedAdd)) {
if ((NETWORK_DEVICE_LIST_FORM_ID == NextShowFormId) && IsNeedAdd) {
(*ItemCount) = 1;
}
+
return IsNeedAdd;
}
@@ -401,7 +414,7 @@ IsNeedAddNetworkMenu ( // And the child handle has the network devcie connected.
//
TmpDevicePath = DevicePath;
- Status = gBS->LocateDevicePath(&gEfiDevicePathProtocolGuid, &TmpDevicePath, &ControllerHandle);
+ Status = gBS->LocateDevicePath (&gEfiDevicePathProtocolGuid, &TmpDevicePath, &ControllerHandle);
if (EFI_ERROR (Status)) {
return FALSE;
}
@@ -437,7 +450,7 @@ IsNeedAddNetworkMenu ( Status = gBS->OpenProtocol (
OpenInfoBuffer[Index].ControllerHandle,
&gEfiDevicePathProtocolGuid,
- (VOID **) &ChildDevicePath,
+ (VOID **)&ChildDevicePath,
NULL,
NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -449,7 +462,7 @@ IsNeedAddNetworkMenu ( //
// Check whether this device path include mac address device path.
//
- if (!IsMacAddressDevicePath(ChildDevicePath, NextShowFormId,&IsNeedAdd)) {
+ if (!IsMacAddressDevicePath (ChildDevicePath, NextShowFormId, &IsNeedAdd)) {
//
// If this path not has mac address path, check the other.
//
@@ -462,6 +475,7 @@ IsNeedAddNetworkMenu ( if (IsNeedAdd) {
(*ItemCount) += 1;
}
+
continue;
} else {
//
@@ -477,6 +491,7 @@ Done: if (OpenInfoBuffer != NULL) {
FreePool (OpenInfoBuffer);
}
+
return IsNeedAdd;
}
@@ -487,42 +502,42 @@ Done: **/
VOID
-CreateDeviceManagerForm(
- IN EFI_FORM_ID NextShowFormId
-)
+CreateDeviceManagerForm (
+ IN EFI_FORM_ID NextShowFormId
+ )
{
- UINTN Index;
- EFI_STRING String;
- EFI_STRING_ID Token;
- EFI_STRING_ID TokenHelp;
- EFI_HII_HANDLE *HiiHandles;
- EFI_HII_HANDLE HiiHandle;
- EFI_GUID FormSetGuid;
- VOID *StartOpCodeHandle;
- VOID *EndOpCodeHandle;
- EFI_IFR_GUID_LABEL *StartLabel;
- EFI_IFR_GUID_LABEL *EndLabel;
- BOOLEAN AddNetworkMenu;
- UINTN AddItemCount;
- UINTN NewStringLen;
- EFI_STRING NewStringTitle;
- CHAR16 *DevicePathStr;
- EFI_STRING_ID DevicePathId;
- EFI_IFR_FORM_SET *Buffer;
- UINTN BufferSize;
- UINT8 ClassGuidNum;
- EFI_GUID *ClassGuid;
- UINTN TempSize;
- UINT8 *Ptr;
- EFI_STATUS Status;
-
- TempSize =0;
+ UINTN Index;
+ EFI_STRING String;
+ EFI_STRING_ID Token;
+ EFI_STRING_ID TokenHelp;
+ EFI_HII_HANDLE *HiiHandles;
+ EFI_HII_HANDLE HiiHandle;
+ EFI_GUID FormSetGuid;
+ VOID *StartOpCodeHandle;
+ VOID *EndOpCodeHandle;
+ EFI_IFR_GUID_LABEL *StartLabel;
+ EFI_IFR_GUID_LABEL *EndLabel;
+ BOOLEAN AddNetworkMenu;
+ UINTN AddItemCount;
+ UINTN NewStringLen;
+ EFI_STRING NewStringTitle;
+ CHAR16 *DevicePathStr;
+ EFI_STRING_ID DevicePathId;
+ EFI_IFR_FORM_SET *Buffer;
+ UINTN BufferSize;
+ UINT8 ClassGuidNum;
+ EFI_GUID *ClassGuid;
+ UINTN TempSize;
+ UINT8 *Ptr;
+ EFI_STATUS Status;
+
+ TempSize = 0;
BufferSize = 0;
- Buffer = NULL;
+ Buffer = NULL;
- HiiHandle = gDeviceManagerPrivate.HiiHandle;
+ HiiHandle = gDeviceManagerPrivate.HiiHandle;
AddNetworkMenu = FALSE;
- AddItemCount = 0;
+ AddItemCount = 0;
//
// If need show the Network device list form, clear the old save list first.
//
@@ -538,8 +553,9 @@ CreateDeviceManagerForm( if (String == NULL) {
return;
}
- NewStringLen = StrLen (mSelectedMacAddrString) * 2;
- NewStringLen += (StrLen (String) + 2) * 2;
+
+ NewStringLen = StrLen (mSelectedMacAddrString) * 2;
+ NewStringLen += (StrLen (String) + 2) * 2;
NewStringTitle = AllocatePool (NewStringLen);
UnicodeSPrint (NewStringTitle, NewStringLen, L"%s %s", String, mSelectedMacAddrString);
HiiSetString (HiiHandle, STRING_TOKEN (STR_FORM_NETWORK_DEVICE_TITLE), NewStringTitle, NULL);
@@ -559,17 +575,17 @@ CreateDeviceManagerForm( //
// Create Hii Extend Label OpCode as the start opcode
//
- StartLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (StartOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));
+ StartLabel = (EFI_IFR_GUID_LABEL *)HiiCreateGuidOpCode (StartOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));
StartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;
//
// According to the next show Form id(mNextShowFormId) to decide which form need to update.
//
- StartLabel->Number = (UINT16) (LABEL_FORM_ID_OFFSET + NextShowFormId);
+ StartLabel->Number = (UINT16)(LABEL_FORM_ID_OFFSET + NextShowFormId);
//
// Create Hii Extend Label OpCode as the end opcode
//
- EndLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (EndOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));
+ EndLabel = (EFI_IFR_GUID_LABEL *)HiiCreateGuidOpCode (EndOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));
EndLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;
EndLabel->Number = LABEL_END;
@@ -583,23 +599,24 @@ CreateDeviceManagerForm( // Search for formset of each class type
//
for (Index = 0; HiiHandles[Index] != NULL; Index++) {
- Status = HiiGetFormSetFromHiiHandle(HiiHandles[Index], &Buffer,&BufferSize);
- if (EFI_ERROR (Status)){
+ Status = HiiGetFormSetFromHiiHandle (HiiHandles[Index], &Buffer, &BufferSize);
+ if (EFI_ERROR (Status)) {
continue;
}
+
Ptr = (UINT8 *)Buffer;
- while(TempSize < BufferSize) {
- TempSize += ((EFI_IFR_OP_HEADER *) Ptr)->Length;
- if (((EFI_IFR_OP_HEADER *) Ptr)->Length <= OFFSET_OF (EFI_IFR_FORM_SET, Flags)){
- Ptr += ((EFI_IFR_OP_HEADER *) Ptr)->Length;
+ while (TempSize < BufferSize) {
+ TempSize += ((EFI_IFR_OP_HEADER *)Ptr)->Length;
+ if (((EFI_IFR_OP_HEADER *)Ptr)->Length <= OFFSET_OF (EFI_IFR_FORM_SET, Flags)) {
+ Ptr += ((EFI_IFR_OP_HEADER *)Ptr)->Length;
continue;
}
- ClassGuidNum = (UINT8) (((EFI_IFR_FORM_SET *)Ptr)->Flags & 0x3);
- ClassGuid = (EFI_GUID *) (VOID *)(Ptr + sizeof (EFI_IFR_FORM_SET));
+ ClassGuidNum = (UINT8)(((EFI_IFR_FORM_SET *)Ptr)->Flags & 0x3);
+ ClassGuid = (EFI_GUID *)(VOID *)(Ptr + sizeof (EFI_IFR_FORM_SET));
while (ClassGuidNum-- > 0) {
- if (CompareGuid (&gEfiHiiPlatformSetupFormsetGuid, ClassGuid)== 0) {
- ClassGuid ++;
+ if (CompareGuid (&gEfiHiiPlatformSetupFormsetGuid, ClassGuid) == 0) {
+ ClassGuid++;
continue;
}
@@ -608,6 +625,7 @@ CreateDeviceManagerForm( String = HiiGetString (HiiHandle, STRING_TOKEN (STR_MISSING_STRING), NULL);
ASSERT (String != NULL);
}
+
Token = HiiSetString (HiiHandle, 0, String, NULL);
FreePool (String);
@@ -616,15 +634,16 @@ CreateDeviceManagerForm( String = HiiGetString (HiiHandle, STRING_TOKEN (STR_MISSING_STRING), NULL);
ASSERT (String != NULL);
}
+
TokenHelp = HiiSetString (HiiHandle, 0, String, NULL);
FreePool (String);
- CopyMem (&FormSetGuid, &((EFI_IFR_FORM_SET *) Ptr)->Guid, sizeof (EFI_GUID));
+ CopyMem (&FormSetGuid, &((EFI_IFR_FORM_SET *)Ptr)->Guid, sizeof (EFI_GUID));
//
// Network device process
//
- if (IsNeedAddNetworkMenu (HiiHandles[Index], NextShowFormId,&AddItemCount)) {
+ if (IsNeedAddNetworkMenu (HiiHandles[Index], NextShowFormId, &AddItemCount)) {
if (NextShowFormId == DEVICE_MANAGER_FORM_ID) {
//
// Only show one menu item "Network Config" in the device manger form.
@@ -637,8 +656,8 @@ CreateDeviceManagerForm( STRING_TOKEN (STR_FORM_NETWORK_DEVICE_LIST_TITLE),
STRING_TOKEN (STR_FORM_NETWORK_DEVICE_LIST_HELP),
EFI_IFR_FLAG_CALLBACK,
- (EFI_QUESTION_ID) QUESTION_NETWORK_DEVICE_ID
- );
+ (EFI_QUESTION_ID)QUESTION_NETWORK_DEVICE_ID
+ );
}
} else if (NextShowFormId == NETWORK_DEVICE_LIST_FORM_ID) {
//
@@ -652,63 +671,67 @@ CreateDeviceManagerForm( STRING_TOKEN (STR_NETWORK_DEVICE_HELP),
EFI_IFR_FLAG_CALLBACK,
mMacDeviceList.NodeList[mMacDeviceList.CurListLen - AddItemCount].QuestionId
- );
+ );
AddItemCount -= 1;
}
} else if (NextShowFormId == NETWORK_DEVICE_FORM_ID) {
//
// In network device form, only the selected mac address device need to be show.
//
- DevicePathStr = DmExtractDevicePathFromHiiHandle(HiiHandles[Index]);
+ DevicePathStr = DmExtractDevicePathFromHiiHandle (HiiHandles[Index]);
DevicePathId = 0;
- if (DevicePathStr != NULL){
+ if (DevicePathStr != NULL) {
DevicePathId = HiiSetString (HiiHandle, 0, DevicePathStr, NULL);
- FreePool(DevicePathStr);
+ FreePool (DevicePathStr);
}
+
HiiCreateGotoExOpCode (
StartOpCodeHandle,
0,
Token,
TokenHelp,
0,
- (EFI_QUESTION_ID) (Index + DEVICE_KEY_OFFSET),
+ (EFI_QUESTION_ID)(Index + DEVICE_KEY_OFFSET),
0,
&FormSetGuid,
DevicePathId
- );
+ );
}
} else {
//
// Not network device process, only need to show at device manger form.
//
if (NextShowFormId == DEVICE_MANAGER_FORM_ID) {
- DevicePathStr = DmExtractDevicePathFromHiiHandle(HiiHandles[Index]);
+ DevicePathStr = DmExtractDevicePathFromHiiHandle (HiiHandles[Index]);
DevicePathId = 0;
- if (DevicePathStr != NULL){
+ if (DevicePathStr != NULL) {
DevicePathId = HiiSetString (HiiHandle, 0, DevicePathStr, NULL);
- FreePool(DevicePathStr);
+ FreePool (DevicePathStr);
}
+
HiiCreateGotoExOpCode (
StartOpCodeHandle,
0,
Token,
TokenHelp,
0,
- (EFI_QUESTION_ID) (Index + DEVICE_KEY_OFFSET),
+ (EFI_QUESTION_ID)(Index + DEVICE_KEY_OFFSET),
0,
&FormSetGuid,
DevicePathId
- );
+ );
}
}
+
break;
}
- Ptr += ((EFI_IFR_OP_HEADER *) Ptr)->Length;
+ Ptr += ((EFI_IFR_OP_HEADER *)Ptr)->Length;
}
- FreePool(Buffer);
- Buffer = NULL;
- TempSize = 0;
+
+ FreePool (Buffer);
+ Buffer = NULL;
+ TempSize = 0;
BufferSize = 0;
}
@@ -750,15 +773,16 @@ CreateDeviceManagerForm( EFI_STATUS
EFIAPI
DeviceManagerExtractConfig (
- IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
- IN CONST EFI_STRING Request,
- OUT EFI_STRING *Progress,
- OUT EFI_STRING *Results
+ IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
+ IN CONST EFI_STRING Request,
+ OUT EFI_STRING *Progress,
+ OUT EFI_STRING *Results
)
{
- if (Progress == NULL || Results == NULL) {
+ if ((Progress == NULL) || (Results == NULL)) {
return EFI_INVALID_PARAMETER;
}
+
*Progress = Request;
return EFI_NOT_FOUND;
}
@@ -781,12 +805,12 @@ DeviceManagerExtractConfig ( EFI_STATUS
EFIAPI
DeviceManagerRouteConfig (
- IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
- IN CONST EFI_STRING Configuration,
- OUT EFI_STRING *Progress
+ IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
+ IN CONST EFI_STRING Configuration,
+ OUT EFI_STRING *Progress
)
{
- if (Configuration == NULL || Progress == NULL) {
+ if ((Configuration == NULL) || (Progress == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -814,15 +838,15 @@ DeviceManagerRouteConfig ( EFI_STATUS
EFIAPI
DeviceManagerCallback (
- IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
- IN EFI_BROWSER_ACTION Action,
- IN EFI_QUESTION_ID QuestionId,
- IN UINT8 Type,
- IN EFI_IFR_TYPE_VALUE *Value,
- OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
+ IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
+ IN EFI_BROWSER_ACTION Action,
+ IN EFI_QUESTION_ID QuestionId,
+ IN UINT8 Type,
+ IN EFI_IFR_TYPE_VALUE *Value,
+ OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
)
{
- UINTN CurIndex;
+ UINTN CurIndex;
if (Action != EFI_BROWSER_ACTION_CHANGING) {
//
@@ -830,21 +854,24 @@ DeviceManagerCallback ( //
return EFI_UNSUPPORTED;
}
+
if ((Value == NULL) || (ActionRequest == NULL)) {
return EFI_INVALID_PARAMETER;
}
+
if ((QuestionId < MAX_KEY_SECTION_LEN + NETWORK_DEVICE_LIST_KEY_OFFSET) && (QuestionId >= NETWORK_DEVICE_LIST_KEY_OFFSET)) {
//
// If user select the mac address, need to record mac address string to support next form show.
//
- for (CurIndex = 0; CurIndex < mMacDeviceList.CurListLen; CurIndex ++) {
+ for (CurIndex = 0; CurIndex < mMacDeviceList.CurListLen; CurIndex++) {
if (mMacDeviceList.NodeList[CurIndex].QuestionId == QuestionId) {
- mSelectedMacAddrString = HiiGetString (gDeviceManagerPrivate.HiiHandle, mMacDeviceList.NodeList[CurIndex].PromptId, NULL);
+ mSelectedMacAddrString = HiiGetString (gDeviceManagerPrivate.HiiHandle, mMacDeviceList.NodeList[CurIndex].PromptId, NULL);
}
}
- CreateDeviceManagerForm(NETWORK_DEVICE_FORM_ID);
- } else if(QuestionId == QUESTION_NETWORK_DEVICE_ID){
- CreateDeviceManagerForm(NETWORK_DEVICE_LIST_FORM_ID);
+
+ CreateDeviceManagerForm (NETWORK_DEVICE_FORM_ID);
+ } else if (QuestionId == QUESTION_NETWORK_DEVICE_ID) {
+ CreateDeviceManagerForm (NETWORK_DEVICE_LIST_FORM_ID);
}
return EFI_SUCCESS;
@@ -863,33 +890,33 @@ DeviceManagerCallback ( EFI_STATUS
EFIAPI
DeviceManagerUiLibConstructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
-)
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
gDeviceManagerPrivate.DriverHandle = NULL;
- Status = gBS->InstallMultipleProtocolInterfaces (
- &gDeviceManagerPrivate.DriverHandle,
- &gEfiDevicePathProtocolGuid,
- &mDeviceManagerHiiVendorDevicePath,
- &gEfiHiiConfigAccessProtocolGuid,
- &gDeviceManagerPrivate.ConfigAccess,
- NULL
- );
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &gDeviceManagerPrivate.DriverHandle,
+ &gEfiDevicePathProtocolGuid,
+ &mDeviceManagerHiiVendorDevicePath,
+ &gEfiHiiConfigAccessProtocolGuid,
+ &gDeviceManagerPrivate.ConfigAccess,
+ NULL
+ );
ASSERT_EFI_ERROR (Status);
//
// Publish our HII data.
//
gDeviceManagerPrivate.HiiHandle = HiiAddPackages (
- &mDeviceManagerGuid,
- gDeviceManagerPrivate.DriverHandle,
- DeviceManagerVfrBin,
- DeviceManagerUiLibStrings,
- NULL
- );
+ &mDeviceManagerGuid,
+ gDeviceManagerPrivate.DriverHandle,
+ DeviceManagerVfrBin,
+ DeviceManagerUiLibStrings,
+ NULL
+ );
ASSERT (gDeviceManagerPrivate.HiiHandle != NULL);
//
@@ -917,12 +944,12 @@ DeviceManagerUiLibConstructor ( **/
EFI_STATUS
EFIAPI
-DeviceManagerUiLibDestructor(
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
-)
+DeviceManagerUiLibDestructor (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
Status = gBS->UninstallMultipleProtocolInterfaces (
gDeviceManagerPrivate.DriverHandle,
@@ -938,4 +965,3 @@ DeviceManagerUiLibDestructor( return EFI_SUCCESS;
}
-
diff --git a/MdeModulePkg/Library/DeviceManagerUiLib/DeviceManager.h b/MdeModulePkg/Library/DeviceManagerUiLib/DeviceManager.h index c53c2a1a0e..4c711234db 100644 --- a/MdeModulePkg/Library/DeviceManagerUiLib/DeviceManager.h +++ b/MdeModulePkg/Library/DeviceManagerUiLib/DeviceManager.h @@ -34,18 +34,18 @@ SPDX-License-Identifier: BSD-2-Clause-Patent 0x3ebfa8e6, 0x511d, 0x4b5b, {0xa9, 0x5f, 0xfb, 0x38, 0x26, 0xf, 0x1c, 0x27} \
}
-#define LABEL_END 0xffff
-#define LABEL_FORM_ID_OFFSET 0x0100
+#define LABEL_END 0xffff
+#define LABEL_FORM_ID_OFFSET 0x0100
-#define DEVICE_MANAGER_FORM_ID 0x1000
-#define NETWORK_DEVICE_LIST_FORM_ID 0x1001
-#define NETWORK_DEVICE_FORM_ID 0x1002
-#define DEVICE_KEY_OFFSET 0x4000
-#define NETWORK_DEVICE_LIST_KEY_OFFSET 0x2000
+#define DEVICE_MANAGER_FORM_ID 0x1000
+#define NETWORK_DEVICE_LIST_FORM_ID 0x1001
+#define NETWORK_DEVICE_FORM_ID 0x1002
+#define DEVICE_KEY_OFFSET 0x4000
+#define NETWORK_DEVICE_LIST_KEY_OFFSET 0x2000
-#define MAX_KEY_SECTION_LEN 0x1000
+#define MAX_KEY_SECTION_LEN 0x1000
-#define QUESTION_NETWORK_DEVICE_ID 0x3FFF
+#define QUESTION_NETWORK_DEVICE_ID 0x3FFF
//
// These are the VFR compiler generated data representing our VFR data.
//
@@ -57,40 +57,40 @@ extern UINT8 DeviceManagerVfrBin[]; /// HII specific Vendor Device Path definition.
///
typedef struct {
- VENDOR_DEVICE_PATH VendorDevicePath;
- EFI_DEVICE_PATH_PROTOCOL End;
+ VENDOR_DEVICE_PATH VendorDevicePath;
+ EFI_DEVICE_PATH_PROTOCOL End;
} HII_VENDOR_DEVICE_PATH;
typedef struct {
- UINTN Signature;
+ UINTN Signature;
///
/// Device Manager HII relative handles
///
- EFI_HII_HANDLE HiiHandle;
+ EFI_HII_HANDLE HiiHandle;
- EFI_HANDLE DriverHandle;
+ EFI_HANDLE DriverHandle;
///
/// Device Manager Produced protocols
///
- EFI_HII_CONFIG_ACCESS_PROTOCOL ConfigAccess;
+ EFI_HII_CONFIG_ACCESS_PROTOCOL ConfigAccess;
///
/// Configuration data
///
- UINT8 VideoBios;
+ UINT8 VideoBios;
} DEVICE_MANAGER_CALLBACK_DATA;
typedef struct {
- EFI_STRING_ID PromptId;
- EFI_QUESTION_ID QuestionId;
-}MENU_INFO_ITEM;
+ EFI_STRING_ID PromptId;
+ EFI_QUESTION_ID QuestionId;
+} MENU_INFO_ITEM;
typedef struct {
- UINTN CurListLen;
- UINTN MaxListLen;
- MENU_INFO_ITEM *NodeList;
+ UINTN CurListLen;
+ UINTN MaxListLen;
+ MENU_INFO_ITEM *NodeList;
} MAC_ADDRESS_NODE_LIST;
#define DEVICE_MANAGER_CALLBACK_DATA_FROM_THIS(a) \
@@ -100,8 +100,8 @@ typedef struct { DEVICE_MANAGER_CALLBACK_DATA_SIGNATURE \
)
typedef struct {
- EFI_STRING_ID StringId;
- UINT16 Class;
+ EFI_STRING_ID StringId;
+ UINT16 Class;
} DEVICE_MANAGER_MENU_ITEM;
/**
@@ -129,10 +129,10 @@ typedef struct { EFI_STATUS
EFIAPI
DeviceManagerExtractConfig (
- IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
- IN CONST EFI_STRING Request,
- OUT EFI_STRING *Progress,
- OUT EFI_STRING *Results
+ IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
+ IN CONST EFI_STRING Request,
+ OUT EFI_STRING *Progress,
+ OUT EFI_STRING *Results
);
/**
@@ -154,9 +154,9 @@ DeviceManagerExtractConfig ( EFI_STATUS
EFIAPI
DeviceManagerRouteConfig (
- IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
- IN CONST EFI_STRING Configuration,
- OUT EFI_STRING *Progress
+ IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
+ IN CONST EFI_STRING Configuration,
+ OUT EFI_STRING *Progress
);
/**
@@ -178,12 +178,12 @@ DeviceManagerRouteConfig ( EFI_STATUS
EFIAPI
DeviceManagerCallback (
- IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
- IN EFI_BROWSER_ACTION Action,
- IN EFI_QUESTION_ID QuestionId,
- IN UINT8 Type,
- IN EFI_IFR_TYPE_VALUE *Value,
- OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
+ IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
+ IN EFI_BROWSER_ACTION Action,
+ IN EFI_QUESTION_ID QuestionId,
+ IN UINT8 Type,
+ IN EFI_IFR_TYPE_VALUE *Value,
+ OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
);
#endif
diff --git a/MdeModulePkg/Library/DisplayUpdateProgressLibGraphics/DisplayUpdateProgressLibGraphics.c b/MdeModulePkg/Library/DisplayUpdateProgressLibGraphics/DisplayUpdateProgressLibGraphics.c index 5f3ae6ab72..83053464e0 100644 --- a/MdeModulePkg/Library/DisplayUpdateProgressLibGraphics/DisplayUpdateProgressLibGraphics.c +++ b/MdeModulePkg/Library/DisplayUpdateProgressLibGraphics/DisplayUpdateProgressLibGraphics.c @@ -34,7 +34,7 @@ EFI_GRAPHICS_OUTPUT_PROTOCOL *mGop = NULL; //
// Set to 100 percent so it is reset on first call.
//
-UINTN mPreviousProgress = 100;
+UINTN mPreviousProgress = 100;
//
// Display coordinates for the progress bar.
@@ -99,7 +99,7 @@ const EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION mProgressBarDefaultColor = { // Set to TRUE if a valid Graphics Output Protocol is found and the progress
// bar fits under the boot logo using the current graphics mode.
//
-BOOLEAN mGraphicsGood = FALSE;
+BOOLEAN mGraphicsGood = FALSE;
/**
Internal function used to find the bounds of the white logo (on black or
@@ -110,7 +110,7 @@ BOOLEAN mGraphicsGood = FALSE; **/
VOID
FindDim (
- VOID
+ VOID
)
{
EFI_STATUS Status;
@@ -189,6 +189,7 @@ FindDim ( DEBUG ((DEBUG_INFO, "StartX found at (%d, %d) Color is: 0x%X \n", LogoX, LogoY, Pixel->Raw));
break;
}
+
Pixel = Pixel + Width;
}
}
@@ -204,6 +205,7 @@ FindDim ( DEBUG ((DEBUG_INFO, "EndX found at (%d, %d) Color is: 0x%X \n", LogoX, LogoY, Pixel->Raw));
break;
}
+
Pixel = Pixel + Width;
}
}
@@ -226,13 +228,14 @@ FindDim ( for (LogoY = 0, LogoStartY = Height; LogoY < LogoStartY; LogoY++) {
Pixel = (EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION *)(Logo + (Width * LogoY));
for (LogoX = 0; LogoX < (INTN)Width; LogoX++) {
- //not black or red
+ // not black or red
if ((Pixel->Raw & mLogoDetectionColorMask.Raw) != 0x0) {
LogoStartY = LogoY;
- LogoEndY = LogoY; //for next loop will search from bottom side back to this row.
+ LogoEndY = LogoY; // for next loop will search from bottom side back to this row.
DEBUG ((DEBUG_INFO, "StartY found at (%d, %d) Color is: 0x%X \n", LogoX, LogoY, Pixel->Raw));
break;
}
+
Pixel++;
}
}
@@ -248,6 +251,7 @@ FindDim ( DEBUG ((DEBUG_INFO, "EndY found at (%d, %d) Color is: 0x%X \n", LogoX, LogoY, Pixel->Raw));
break;
}
+
Pixel++;
}
}
@@ -360,7 +364,7 @@ DisplayUpdateProgress ( Status = gBS->HandleProtocol (
gST->ConsoleOutHandle,
&gEfiGraphicsOutputProtocolGuid,
- (VOID**)&mGop
+ (VOID **)&mGop
);
if (EFI_ERROR (Status)) {
Status = gBS->LocateProtocol (&gEfiGraphicsOutputProtocolGuid, NULL, (VOID **)&mGop);
@@ -405,7 +409,9 @@ DisplayUpdateProgress ( 0
);
- DEBUG ((DEBUG_VERBOSE, "Color is 0x%X\n",
+ DEBUG ((
+ DEBUG_VERBOSE,
+ "Color is 0x%X\n",
(Color == NULL) ? mProgressBarDefaultColor.Raw : Color->Raw
));
diff --git a/MdeModulePkg/Library/DisplayUpdateProgressLibText/DisplayUpdateProgressLibText.c b/MdeModulePkg/Library/DisplayUpdateProgressLibText/DisplayUpdateProgressLibText.c index 960a4165fc..4823a24d0d 100644 --- a/MdeModulePkg/Library/DisplayUpdateProgressLibText/DisplayUpdateProgressLibText.c +++ b/MdeModulePkg/Library/DisplayUpdateProgressLibText/DisplayUpdateProgressLibText.c @@ -86,15 +86,19 @@ DisplayUpdateProgress ( if (Color->Pixel.Blue >= 0x40) {
mProgressBarForegroundColor |= EFI_BLUE;
}
+
if (Color->Pixel.Green >= 0x40) {
mProgressBarForegroundColor |= EFI_GREEN;
}
+
if (Color->Pixel.Red >= 0x40) {
mProgressBarForegroundColor |= EFI_RED;
}
- if (Color->Pixel.Blue >= 0xC0 || Color->Pixel.Green >= 0xC0 || Color->Pixel.Red >= 0xC0) {
+
+ if ((Color->Pixel.Blue >= 0xC0) || (Color->Pixel.Green >= 0xC0) || (Color->Pixel.Red >= 0xC0)) {
mProgressBarForegroundColor |= EFI_BRIGHT;
}
+
if (mProgressBarForegroundColor == EFI_BLACK) {
mProgressBarForegroundColor = EFI_WHITE;
}
@@ -147,7 +151,7 @@ DisplayUpdateProgress ( //
// Print remaining portion of progress bar
//
- for (; Index < 50; Index++) {
+ for ( ; Index < 50; Index++) {
Print (L"%c", BLOCKELEMENT_LIGHT_SHADE);
}
diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/CapsuleOnDisk.c b/MdeModulePkg/Library/DxeCapsuleLibFmp/CapsuleOnDisk.c index 060abef3ab..41b3282d29 100644 --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/CapsuleOnDisk.c +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/CapsuleOnDisk.c @@ -18,7 +18,7 @@ **/
BOOLEAN
IsCapsuleNameCapsule (
- IN EFI_CAPSULE_HEADER *CapsuleHeader
+ IN EFI_CAPSULE_HEADER *CapsuleHeader
);
/**
@@ -37,16 +37,16 @@ IsCapsuleNameCapsule ( **/
EFI_PHYSICAL_ADDRESS *
ValidateCapsuleNameCapsuleIntegrity (
- IN EFI_CAPSULE_HEADER *CapsuleHeader,
- OUT UINTN *CapsuleNameNum
+ IN EFI_CAPSULE_HEADER *CapsuleHeader,
+ OUT UINTN *CapsuleNameNum
)
{
- UINT8 *CapsuleNamePtr;
- UINT8 *CapsuleNameBufStart;
- UINT8 *CapsuleNameBufEnd;
- UINTN Index;
- UINTN StringSize;
- EFI_PHYSICAL_ADDRESS *CapsuleNameBuf;
+ UINT8 *CapsuleNamePtr;
+ UINT8 *CapsuleNameBufStart;
+ UINT8 *CapsuleNameBufEnd;
+ UINTN Index;
+ UINTN StringSize;
+ EFI_PHYSICAL_ADDRESS *CapsuleNameBuf;
if (!IsCapsuleNameCapsule (CapsuleHeader)) {
return NULL;
@@ -59,14 +59,14 @@ ValidateCapsuleNameCapsuleIntegrity ( return NULL;
}
- *CapsuleNameNum = 0;
- Index = 0;
- CapsuleNameBufStart = (UINT8 *) CapsuleHeader + CapsuleHeader->HeaderSize;
+ *CapsuleNameNum = 0;
+ Index = 0;
+ CapsuleNameBufStart = (UINT8 *)CapsuleHeader + CapsuleHeader->HeaderSize;
//
// If strings are not aligned on a 16-bit boundary, reallocate memory for it.
//
- if (((UINTN) CapsuleNameBufStart & BIT0) != 0) {
+ if (((UINTN)CapsuleNameBufStart & BIT0) != 0) {
CapsuleNameBufStart = AllocateCopyPool (CapsuleHeader->CapsuleImageSize - CapsuleHeader->HeaderSize, CapsuleNameBufStart);
if (CapsuleNameBufStart == NULL) {
return NULL;
@@ -77,9 +77,9 @@ ValidateCapsuleNameCapsuleIntegrity ( CapsuleNamePtr = CapsuleNameBufStart;
while (CapsuleNamePtr < CapsuleNameBufEnd) {
- StringSize= StrnSizeS ((CHAR16 *) CapsuleNamePtr, (CapsuleNameBufEnd - CapsuleNamePtr)/sizeof(CHAR16));
+ StringSize = StrnSizeS ((CHAR16 *)CapsuleNamePtr, (CapsuleNameBufEnd - CapsuleNamePtr)/sizeof (CHAR16));
CapsuleNamePtr += StringSize;
- (*CapsuleNameNum) ++;
+ (*CapsuleNameNum)++;
}
//
@@ -89,6 +89,7 @@ ValidateCapsuleNameCapsuleIntegrity ( if (CapsuleNameBufStart != (UINT8 *)CapsuleHeader + CapsuleHeader->HeaderSize) {
FreePool (CapsuleNameBufStart);
}
+
return NULL;
}
@@ -97,15 +98,16 @@ ValidateCapsuleNameCapsuleIntegrity ( if (CapsuleNameBufStart != (UINT8 *)CapsuleHeader + CapsuleHeader->HeaderSize) {
FreePool (CapsuleNameBufStart);
}
+
return NULL;
}
CapsuleNamePtr = CapsuleNameBufStart;
while (CapsuleNamePtr < CapsuleNameBufEnd) {
- StringSize= StrnSizeS ((CHAR16 *) CapsuleNamePtr, (CapsuleNameBufEnd - CapsuleNamePtr)/sizeof(CHAR16));
- CapsuleNameBuf[Index] = (EFI_PHYSICAL_ADDRESS)(UINTN) CapsuleNamePtr;
- CapsuleNamePtr += StringSize;
- Index ++;
+ StringSize = StrnSizeS ((CHAR16 *)CapsuleNamePtr, (CapsuleNameBufEnd - CapsuleNamePtr)/sizeof (CHAR16));
+ CapsuleNameBuf[Index] = (EFI_PHYSICAL_ADDRESS)(UINTN)CapsuleNamePtr;
+ CapsuleNamePtr += StringSize;
+ Index++;
}
return CapsuleNameBuf;
@@ -122,13 +124,13 @@ ValidateCapsuleNameCapsuleIntegrity ( static
CHAR16 *
UpperCaseString (
- IN CHAR16 *Str
+ IN CHAR16 *Str
)
{
CHAR16 *Cptr;
for (Cptr = Str; *Cptr != L'\0'; Cptr++) {
- if (L'a' <= *Cptr && *Cptr <= L'z') {
+ if ((L'a' <= *Cptr) && (*Cptr <= L'z')) {
*Cptr = *Cptr - L'a' + L'A';
}
}
@@ -148,18 +150,19 @@ UpperCaseString ( static
VOID
GetSubStringBeforePeriod (
- IN CHAR16 *Str,
- OUT CHAR16 *SubStr,
- OUT UINTN *SubStrLen
+ IN CHAR16 *Str,
+ OUT CHAR16 *SubStr,
+ OUT UINTN *SubStrLen
)
{
- UINTN Index;
+ UINTN Index;
+
for (Index = 0; Str[Index] != L'.' && Str[Index] != L'\0'; Index++) {
SubStr[Index] = Str[Index];
}
SubStr[Index] = L'\0';
- *SubStrLen = Index;
+ *SubStrLen = Index;
}
/**
@@ -173,16 +176,17 @@ GetSubStringBeforePeriod ( static
VOID
PadStrInTail (
- IN CHAR16 *StrBuf,
- IN UINTN PadLen,
- IN CHAR16 Character
+ IN CHAR16 *StrBuf,
+ IN UINTN PadLen,
+ IN CHAR16 Character
)
{
- UINTN Index;
+ UINTN Index;
- for (Index = 0; StrBuf[Index] != L'\0'; Index++);
+ for (Index = 0; StrBuf[Index] != L'\0'; Index++) {
+ }
- while(PadLen != 0) {
+ while (PadLen != 0) {
StrBuf[Index] = Character;
Index++;
PadLen--;
@@ -208,26 +212,27 @@ SplitFileNameExtension ( OUT CHAR16 *FileNameExtension
)
{
- UINTN Index;
- UINTN StringLen;
+ UINTN Index;
+ UINTN StringLen;
- StringLen = StrnLenS(FileName, MAX_FILE_NAME_SIZE);
- for (Index = StringLen; Index > 0 && FileName[Index] != L'.'; Index--);
+ StringLen = StrnLenS (FileName, MAX_FILE_NAME_SIZE);
+ for (Index = StringLen; Index > 0 && FileName[Index] != L'.'; Index--) {
+ }
//
// No period exists. No FileName Extension
//
- if (Index == 0 && FileName[Index] != L'.') {
+ if ((Index == 0) && (FileName[Index] != L'.')) {
FileNameExtension[0] = L'\0';
- Index = StringLen;
+ Index = StringLen;
} else {
- StrCpyS(FileNameExtension, MAX_FILE_NAME_SIZE, &FileName[Index+1]);
+ StrCpyS (FileNameExtension, MAX_FILE_NAME_SIZE, &FileName[Index+1]);
}
//
// Copy First file name
//
- StrnCpyS(FileNameFirst, MAX_FILE_NAME_SIZE, FileName, Index);
+ StrnCpyS (FileNameFirst, MAX_FILE_NAME_SIZE, FileName, Index);
FileNameFirst[Index] = L'\0';
}
@@ -243,51 +248,51 @@ SplitFileNameExtension ( **/
EFI_STATUS
-GetBootOptionInOrder(
- OUT EFI_BOOT_MANAGER_LOAD_OPTION **OptionBuf,
- OUT UINTN *OptionCount
+GetBootOptionInOrder (
+ OUT EFI_BOOT_MANAGER_LOAD_OPTION **OptionBuf,
+ OUT UINTN *OptionCount
)
{
- EFI_STATUS Status;
- UINTN DataSize;
- UINT16 BootNext;
- CHAR16 BootOptionName[20];
- EFI_BOOT_MANAGER_LOAD_OPTION *BootOrderOptionBuf;
- UINTN BootOrderCount;
- EFI_BOOT_MANAGER_LOAD_OPTION BootNextOptionEntry;
- UINTN BootNextCount;
- EFI_BOOT_MANAGER_LOAD_OPTION *TempBuf;
-
- BootOrderOptionBuf = NULL;
- TempBuf = NULL;
- BootNextCount = 0;
- BootOrderCount = 0;
- *OptionBuf = NULL;
- *OptionCount = 0;
+ EFI_STATUS Status;
+ UINTN DataSize;
+ UINT16 BootNext;
+ CHAR16 BootOptionName[20];
+ EFI_BOOT_MANAGER_LOAD_OPTION *BootOrderOptionBuf;
+ UINTN BootOrderCount;
+ EFI_BOOT_MANAGER_LOAD_OPTION BootNextOptionEntry;
+ UINTN BootNextCount;
+ EFI_BOOT_MANAGER_LOAD_OPTION *TempBuf;
+
+ BootOrderOptionBuf = NULL;
+ TempBuf = NULL;
+ BootNextCount = 0;
+ BootOrderCount = 0;
+ *OptionBuf = NULL;
+ *OptionCount = 0;
//
// First Get BootOption from "BootNext"
//
- DataSize = sizeof(BootNext);
- Status = gRT->GetVariable (
- EFI_BOOT_NEXT_VARIABLE_NAME,
- &gEfiGlobalVariableGuid,
- NULL,
- &DataSize,
- (VOID *)&BootNext
- );
+ DataSize = sizeof (BootNext);
+ Status = gRT->GetVariable (
+ EFI_BOOT_NEXT_VARIABLE_NAME,
+ &gEfiGlobalVariableGuid,
+ NULL,
+ &DataSize,
+ (VOID *)&BootNext
+ );
//
// BootNext variable is a single UINT16
//
- if (!EFI_ERROR(Status) && DataSize == sizeof(UINT16)) {
+ if (!EFI_ERROR (Status) && (DataSize == sizeof (UINT16))) {
//
// Add the boot next boot option
//
UnicodeSPrint (BootOptionName, sizeof (BootOptionName), L"Boot%04x", BootNext);
- ZeroMem(&BootNextOptionEntry, sizeof(EFI_BOOT_MANAGER_LOAD_OPTION));
+ ZeroMem (&BootNextOptionEntry, sizeof (EFI_BOOT_MANAGER_LOAD_OPTION));
Status = EfiBootManagerVariableToLoadOption (BootOptionName, &BootNextOptionEntry);
- if (!EFI_ERROR(Status)) {
+ if (!EFI_ERROR (Status)) {
BootNextCount = 1;
}
}
@@ -296,31 +301,31 @@ GetBootOptionInOrder( // Second get BootOption from "BootOrder"
//
BootOrderOptionBuf = EfiBootManagerGetLoadOptions (&BootOrderCount, LoadOptionTypeBoot);
- if (BootNextCount == 0 && BootOrderCount == 0) {
+ if ((BootNextCount == 0) && (BootOrderCount == 0)) {
return EFI_NOT_FOUND;
}
//
// At least one BootOption is found
//
- TempBuf = AllocatePool(sizeof(EFI_BOOT_MANAGER_LOAD_OPTION) * (BootNextCount + BootOrderCount));
+ TempBuf = AllocatePool (sizeof (EFI_BOOT_MANAGER_LOAD_OPTION) * (BootNextCount + BootOrderCount));
if (TempBuf != NULL) {
if (BootNextCount == 1) {
- CopyMem(TempBuf, &BootNextOptionEntry, sizeof(EFI_BOOT_MANAGER_LOAD_OPTION));
+ CopyMem (TempBuf, &BootNextOptionEntry, sizeof (EFI_BOOT_MANAGER_LOAD_OPTION));
}
if (BootOrderCount > 0) {
- CopyMem(TempBuf + BootNextCount, BootOrderOptionBuf, sizeof(EFI_BOOT_MANAGER_LOAD_OPTION) * BootOrderCount);
+ CopyMem (TempBuf + BootNextCount, BootOrderOptionBuf, sizeof (EFI_BOOT_MANAGER_LOAD_OPTION) * BootOrderCount);
}
*OptionBuf = TempBuf;
*OptionCount = BootNextCount + BootOrderCount;
- Status = EFI_SUCCESS;
+ Status = EFI_SUCCESS;
} else {
Status = EFI_OUT_OF_RESOURCES;
}
- FreePool(BootOrderOptionBuf);
+ FreePool (BootOrderOptionBuf);
return Status;
}
@@ -335,9 +340,9 @@ GetBootOptionInOrder( **/
EFI_STATUS
-GetBootOptionByNumber(
- IN UINT16 Number,
- OUT EFI_BOOT_MANAGER_LOAD_OPTION **OptionBuf
+GetBootOptionByNumber (
+ IN UINT16 Number,
+ OUT EFI_BOOT_MANAGER_LOAD_OPTION **OptionBuf
)
{
EFI_STATUS Status;
@@ -372,16 +377,16 @@ GetBootOptionByNumber( **/
EFI_STATUS
-GetEfiSysPartitionFromDevPath(
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
- OUT EFI_HANDLE *FsHandle
+GetEfiSysPartitionFromDevPath (
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
+ OUT EFI_HANDLE *FsHandle
)
{
- EFI_STATUS Status;
- EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
- HARDDRIVE_DEVICE_PATH *Hd;
- EFI_HANDLE Handle;
- EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *Fs;
+ EFI_STATUS Status;
+ EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
+ HARDDRIVE_DEVICE_PATH *Hd;
+ EFI_HANDLE Handle;
+ EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *Fs;
//
// Check if the device path contains GPT node
@@ -389,12 +394,14 @@ GetEfiSysPartitionFromDevPath( TempDevicePath = DevicePath;
while (!IsDevicePathEnd (TempDevicePath)) {
if ((DevicePathType (TempDevicePath) == MEDIA_DEVICE_PATH) &&
- (DevicePathSubType (TempDevicePath) == MEDIA_HARDDRIVE_DP)) {
+ (DevicePathSubType (TempDevicePath) == MEDIA_HARDDRIVE_DP))
+ {
Hd = (HARDDRIVE_DEVICE_PATH *)TempDevicePath;
if (Hd->MBRType == MBR_TYPE_EFI_PARTITION_TABLE_HEADER) {
break;
}
}
+
TempDevicePath = NextDevicePathNode (TempDevicePath);
}
@@ -407,9 +414,9 @@ GetEfiSysPartitionFromDevPath( //
// Search for simple file system on this handler
//
- if (!EFI_ERROR(Status)) {
- Status = gBS->HandleProtocol(Handle, &gEfiSimpleFileSystemProtocolGuid, (VOID **)&Fs);
- if (!EFI_ERROR(Status)) {
+ if (!EFI_ERROR (Status)) {
+ Status = gBS->HandleProtocol (Handle, &gEfiSimpleFileSystemProtocolGuid, (VOID **)&Fs);
+ if (!EFI_ERROR (Status)) {
*FsHandle = Handle;
return EFI_SUCCESS;
}
@@ -437,33 +444,33 @@ GetEfiSysPartitionFromDevPath( **/
EFI_STATUS
-GetEfiSysPartitionFromActiveBootOption(
- IN UINTN MaxRetry,
- IN OUT UINT16 **LoadOptionNumber,
- OUT EFI_HANDLE *FsHandle
+GetEfiSysPartitionFromActiveBootOption (
+ IN UINTN MaxRetry,
+ IN OUT UINT16 **LoadOptionNumber,
+ OUT EFI_HANDLE *FsHandle
)
{
- EFI_STATUS Status;
- EFI_BOOT_MANAGER_LOAD_OPTION *BootOptionBuf;
- UINTN BootOptionNum;
- UINTN Index;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- EFI_DEVICE_PATH_PROTOCOL *CurFullPath;
- EFI_DEVICE_PATH_PROTOCOL *PreFullPath;
-
- *FsHandle = NULL;
+ EFI_STATUS Status;
+ EFI_BOOT_MANAGER_LOAD_OPTION *BootOptionBuf;
+ UINTN BootOptionNum;
+ UINTN Index;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ EFI_DEVICE_PATH_PROTOCOL *CurFullPath;
+ EFI_DEVICE_PATH_PROTOCOL *PreFullPath;
+
+ *FsHandle = NULL;
CurFullPath = NULL;
if (*LoadOptionNumber != NULL) {
BootOptionNum = 1;
- Status = GetBootOptionByNumber(**LoadOptionNumber, &BootOptionBuf);
- if (EFI_ERROR(Status)) {
+ Status = GetBootOptionByNumber (**LoadOptionNumber, &BootOptionBuf);
+ if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "GetBootOptionByIndex Failed %x! No BootOption available for connection\n", Status));
return Status;
}
} else {
- Status = GetBootOptionInOrder(&BootOptionBuf, &BootOptionNum);
- if (EFI_ERROR(Status)) {
+ Status = GetBootOptionInOrder (&BootOptionBuf, &BootOptionNum);
+ if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "GetBootOptionInOrder Failed %x! No BootOption available for connection\n", Status));
return Status;
}
@@ -479,26 +486,28 @@ GetEfiSysPartitionFromActiveBootOption( //
// Get the boot option from the link list
//
- DevicePath = BootOptionBuf[Index].FilePath;
+ DevicePath = BootOptionBuf[Index].FilePath;
//
// Skip inactive or legacy boot options
//
- if ((BootOptionBuf[Index].Attributes & LOAD_OPTION_ACTIVE) == 0 ||
- DevicePathType (DevicePath) == BBS_DEVICE_PATH) {
+ if (((BootOptionBuf[Index].Attributes & LOAD_OPTION_ACTIVE) == 0) ||
+ (DevicePathType (DevicePath) == BBS_DEVICE_PATH))
+ {
continue;
}
DEBUG_CODE_BEGIN ();
- CHAR16 *DevicePathStr;
-
- DevicePathStr = ConvertDevicePathToText(DevicePath, TRUE, TRUE);
- if (DevicePathStr != NULL){
- DEBUG((DEBUG_INFO, "Try BootOption %s\n", DevicePathStr));
- FreePool(DevicePathStr);
- } else {
- DEBUG((DEBUG_INFO, "DevicePathToStr failed\n"));
- }
+ CHAR16 *DevicePathStr;
+
+ DevicePathStr = ConvertDevicePathToText (DevicePath, TRUE, TRUE);
+ if (DevicePathStr != NULL) {
+ DEBUG ((DEBUG_INFO, "Try BootOption %s\n", DevicePathStr));
+ FreePool (DevicePathStr);
+ } else {
+ DEBUG ((DEBUG_INFO, "DevicePathToStr failed\n"));
+ }
+
DEBUG_CODE_END ();
CurFullPath = NULL;
@@ -507,7 +516,7 @@ GetEfiSysPartitionFromActiveBootOption( //
do {
PreFullPath = CurFullPath;
- CurFullPath = EfiBootManagerGetNextLoadOptionDevicePath(DevicePath, CurFullPath);
+ CurFullPath = EfiBootManagerGetNextLoadOptionDevicePath (DevicePath, CurFullPath);
if (PreFullPath != NULL) {
FreePool (PreFullPath);
@@ -522,13 +531,14 @@ GetEfiSysPartitionFromActiveBootOption( }
DEBUG_CODE_BEGIN ();
- CHAR16 *DevicePathStr1;
+ CHAR16 *DevicePathStr1;
+
+ DevicePathStr1 = ConvertDevicePathToText (CurFullPath, TRUE, TRUE);
+ if (DevicePathStr1 != NULL) {
+ DEBUG ((DEBUG_INFO, "Full device path %s\n", DevicePathStr1));
+ FreePool (DevicePathStr1);
+ }
- DevicePathStr1 = ConvertDevicePathToText(CurFullPath, TRUE, TRUE);
- if (DevicePathStr1 != NULL){
- DEBUG((DEBUG_INFO, "Full device path %s\n", DevicePathStr1));
- FreePool(DevicePathStr1);
- }
DEBUG_CODE_END ();
//
@@ -537,44 +547,44 @@ GetEfiSysPartitionFromActiveBootOption( // FullDevice could contain extra directory & file info. So don't check connection status here.
//
EfiBootManagerConnectDevicePath (CurFullPath, NULL);
- Status = GetEfiSysPartitionFromDevPath(CurFullPath, FsHandle);
+ Status = GetEfiSysPartitionFromDevPath (CurFullPath, FsHandle);
//
// Some relocation device like USB need more time to get enumerated
//
- while (EFI_ERROR(Status) && MaxRetry > 0) {
- EfiBootManagerConnectDevicePath(CurFullPath, NULL);
+ while (EFI_ERROR (Status) && MaxRetry > 0) {
+ EfiBootManagerConnectDevicePath (CurFullPath, NULL);
//
// Search for EFI system partition protocol on full device path in Boot Option
//
- Status = GetEfiSysPartitionFromDevPath(CurFullPath, FsHandle);
- if (!EFI_ERROR(Status)) {
+ Status = GetEfiSysPartitionFromDevPath (CurFullPath, FsHandle);
+ if (!EFI_ERROR (Status)) {
break;
}
- DEBUG((DEBUG_ERROR, "GetEfiSysPartitionFromDevPath Loop %x\n", Status));
+
+ DEBUG ((DEBUG_ERROR, "GetEfiSysPartitionFromDevPath Loop %x\n", Status));
//
// Stall 100ms if connection failed to ensure USB stack is ready
//
- gBS->Stall(100000);
- MaxRetry --;
+ gBS->Stall (100000);
+ MaxRetry--;
}
- } while(EFI_ERROR(Status));
+ } while (EFI_ERROR (Status));
//
// Find a qualified Simple File System
//
- if (!EFI_ERROR(Status)) {
+ if (!EFI_ERROR (Status)) {
break;
}
-
}
//
// Return the OptionNumber of the boot option where EFI system partition is got from
//
if (*LoadOptionNumber == NULL) {
- *LoadOptionNumber = AllocateCopyPool (sizeof(UINT16), (UINT16 *) &BootOptionBuf[Index].OptionNumber);
+ *LoadOptionNumber = AllocateCopyPool (sizeof (UINT16), (UINT16 *)&BootOptionBuf[Index].OptionNumber);
if (*LoadOptionNumber == NULL) {
Status = EFI_OUT_OF_RESOURCES;
}
@@ -588,20 +598,22 @@ GetEfiSysPartitionFromActiveBootOption( }
DEBUG_CODE_BEGIN ();
- CHAR16 *DevicePathStr2;
- if (*FsHandle != NULL) {
- DevicePathStr2 = ConvertDevicePathToText(CurFullPath, TRUE, TRUE);
- if (DevicePathStr2 != NULL){
- DEBUG((DEBUG_INFO, "Found Active EFI System Partion on %s\n", DevicePathStr2));
- FreePool(DevicePathStr2);
- }
- } else {
- DEBUG((DEBUG_INFO, "Failed to found Active EFI System Partion\n"));
+ CHAR16 *DevicePathStr2;
+
+ if (*FsHandle != NULL) {
+ DevicePathStr2 = ConvertDevicePathToText (CurFullPath, TRUE, TRUE);
+ if (DevicePathStr2 != NULL) {
+ DEBUG ((DEBUG_INFO, "Found Active EFI System Partion on %s\n", DevicePathStr2));
+ FreePool (DevicePathStr2);
}
+ } else {
+ DEBUG ((DEBUG_INFO, "Failed to found Active EFI System Partion\n"));
+ }
+
DEBUG_CODE_END ();
if (CurFullPath != NULL) {
- FreePool(CurFullPath);
+ FreePool (CurFullPath);
}
//
@@ -609,24 +621,23 @@ GetEfiSysPartitionFromActiveBootOption( //
for (Index = 0; Index < BootOptionNum; Index++) {
if (BootOptionBuf[Index].Description != NULL) {
- FreePool(BootOptionBuf[Index].Description);
+ FreePool (BootOptionBuf[Index].Description);
}
if (BootOptionBuf[Index].FilePath != NULL) {
- FreePool(BootOptionBuf[Index].FilePath);
+ FreePool (BootOptionBuf[Index].FilePath);
}
if (BootOptionBuf[Index].OptionalData != NULL) {
- FreePool(BootOptionBuf[Index].OptionalData);
+ FreePool (BootOptionBuf[Index].OptionalData);
}
}
- FreePool(BootOptionBuf);
+ FreePool (BootOptionBuf);
return Status;
}
-
/**
This routine is called to get all file infos with in a given dir & with given file attribute, the file info is listed in
alphabetical order described in UEFI spec.
@@ -640,31 +651,31 @@ GetEfiSysPartitionFromActiveBootOption( **/
EFI_STATUS
-GetFileInfoListInAlphabetFromDir(
+GetFileInfoListInAlphabetFromDir (
IN EFI_FILE_HANDLE Dir,
IN UINT64 FileAttr,
OUT LIST_ENTRY *FileInfoList,
OUT UINTN *FileNum
)
{
- EFI_STATUS Status;
- FILE_INFO_ENTRY *NewFileInfoEntry;
- FILE_INFO_ENTRY *TempFileInfoEntry;
- EFI_FILE_INFO *FileInfo;
- CHAR16 *NewFileName;
- CHAR16 *ListedFileName;
- CHAR16 *NewFileNameExtension;
- CHAR16 *ListedFileNameExtension;
- CHAR16 *TempNewSubStr;
- CHAR16 *TempListedSubStr;
- LIST_ENTRY *Link;
- BOOLEAN NoFile;
- UINTN FileCount;
- UINTN IndexNew;
- UINTN IndexListed;
- UINTN NewSubStrLen;
- UINTN ListedSubStrLen;
- INTN SubStrCmpResult;
+ EFI_STATUS Status;
+ FILE_INFO_ENTRY *NewFileInfoEntry;
+ FILE_INFO_ENTRY *TempFileInfoEntry;
+ EFI_FILE_INFO *FileInfo;
+ CHAR16 *NewFileName;
+ CHAR16 *ListedFileName;
+ CHAR16 *NewFileNameExtension;
+ CHAR16 *ListedFileNameExtension;
+ CHAR16 *TempNewSubStr;
+ CHAR16 *TempListedSubStr;
+ LIST_ENTRY *Link;
+ BOOLEAN NoFile;
+ UINTN FileCount;
+ UINTN IndexNew;
+ UINTN IndexListed;
+ UINTN NewSubStrLen;
+ UINTN ListedSubStrLen;
+ INTN SubStrCmpResult;
Status = EFI_SUCCESS;
NewFileName = NULL;
@@ -677,20 +688,21 @@ GetFileInfoListInAlphabetFromDir( NoFile = FALSE;
FileCount = 0;
- InitializeListHead(FileInfoList);
+ InitializeListHead (FileInfoList);
- TempNewSubStr = (CHAR16 *) AllocateZeroPool(MAX_FILE_NAME_SIZE);
- TempListedSubStr = (CHAR16 *) AllocateZeroPool(MAX_FILE_NAME_SIZE);
+ TempNewSubStr = (CHAR16 *)AllocateZeroPool (MAX_FILE_NAME_SIZE);
+ TempListedSubStr = (CHAR16 *)AllocateZeroPool (MAX_FILE_NAME_SIZE);
- if (TempNewSubStr == NULL || TempListedSubStr == NULL ) {
+ if ((TempNewSubStr == NULL) || (TempListedSubStr == NULL)) {
Status = EFI_OUT_OF_RESOURCES;
goto EXIT;
}
- for ( Status = FileHandleFindFirstFile(Dir, &FileInfo)
- ; !EFI_ERROR(Status) && !NoFile
- ; Status = FileHandleFindNextFile(Dir, FileInfo, &NoFile)
- ){
+ for ( Status = FileHandleFindFirstFile (Dir, &FileInfo)
+ ; !EFI_ERROR (Status) && !NoFile
+ ; Status = FileHandleFindNextFile (Dir, FileInfo, &NoFile)
+ )
+ {
if (FileInfo == NULL) {
goto EXIT;
}
@@ -703,31 +715,33 @@ GetFileInfoListInAlphabetFromDir( }
NewFileInfoEntry = NULL;
- NewFileInfoEntry = (FILE_INFO_ENTRY*)AllocateZeroPool(sizeof(FILE_INFO_ENTRY));
+ NewFileInfoEntry = (FILE_INFO_ENTRY *)AllocateZeroPool (sizeof (FILE_INFO_ENTRY));
if (NewFileInfoEntry == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto EXIT;
}
+
NewFileInfoEntry->Signature = FILE_INFO_SIGNATURE;
- NewFileInfoEntry->FileInfo = AllocateCopyPool((UINTN) FileInfo->Size, FileInfo);
+ NewFileInfoEntry->FileInfo = AllocateCopyPool ((UINTN)FileInfo->Size, FileInfo);
if (NewFileInfoEntry->FileInfo == NULL) {
- FreePool(NewFileInfoEntry);
+ FreePool (NewFileInfoEntry);
Status = EFI_OUT_OF_RESOURCES;
goto EXIT;
}
- NewFileInfoEntry->FileNameFirstPart = (CHAR16 *) AllocateZeroPool(MAX_FILE_NAME_SIZE);
+ NewFileInfoEntry->FileNameFirstPart = (CHAR16 *)AllocateZeroPool (MAX_FILE_NAME_SIZE);
if (NewFileInfoEntry->FileNameFirstPart == NULL) {
- FreePool(NewFileInfoEntry->FileInfo);
- FreePool(NewFileInfoEntry);
+ FreePool (NewFileInfoEntry->FileInfo);
+ FreePool (NewFileInfoEntry);
Status = EFI_OUT_OF_RESOURCES;
goto EXIT;
}
- NewFileInfoEntry->FileNameSecondPart = (CHAR16 *) AllocateZeroPool(MAX_FILE_NAME_SIZE);
+
+ NewFileInfoEntry->FileNameSecondPart = (CHAR16 *)AllocateZeroPool (MAX_FILE_NAME_SIZE);
if (NewFileInfoEntry->FileNameSecondPart == NULL) {
- FreePool(NewFileInfoEntry->FileInfo);
- FreePool(NewFileInfoEntry->FileNameFirstPart);
- FreePool(NewFileInfoEntry);
+ FreePool (NewFileInfoEntry->FileInfo);
+ FreePool (NewFileInfoEntry->FileNameFirstPart);
+ FreePool (NewFileInfoEntry);
Status = EFI_OUT_OF_RESOURCES;
goto EXIT;
}
@@ -738,9 +752,9 @@ GetFileInfoListInAlphabetFromDir( //
NewFileName = NewFileInfoEntry->FileNameFirstPart;
NewFileNameExtension = NewFileInfoEntry->FileNameSecondPart;
- SplitFileNameExtension(FileInfo->FileName, NewFileName, NewFileNameExtension);
- UpperCaseString(NewFileName);
- UpperCaseString(NewFileNameExtension);
+ SplitFileNameExtension (FileInfo->FileName, NewFileName, NewFileNameExtension);
+ UpperCaseString (NewFileName);
+ UpperCaseString (NewFileNameExtension);
//
// Insert capsule file in alphabetical ordered list
@@ -749,7 +763,7 @@ GetFileInfoListInAlphabetFromDir( //
// Get the FileInfo from the link list
//
- TempFileInfoEntry = CR (Link, FILE_INFO_ENTRY, Link, FILE_INFO_SIGNATURE);
+ TempFileInfoEntry = CR (Link, FILE_INFO_ENTRY, Link, FILE_INFO_SIGNATURE);
ListedFileName = TempFileInfoEntry->FileNameFirstPart;
ListedFileNameExtension = TempFileInfoEntry->FileNameSecondPart;
@@ -758,25 +772,25 @@ GetFileInfoListInAlphabetFromDir( //
IndexListed = 0;
IndexNew = 0;
- while (TRUE){
+ while (TRUE) {
//
// First compare each substrings in NewFileName & ListedFileName between periods
//
- GetSubStringBeforePeriod(&NewFileName[IndexNew], TempNewSubStr, &NewSubStrLen);
- GetSubStringBeforePeriod(&ListedFileName[IndexListed], TempListedSubStr, &ListedSubStrLen);
+ GetSubStringBeforePeriod (&NewFileName[IndexNew], TempNewSubStr, &NewSubStrLen);
+ GetSubStringBeforePeriod (&ListedFileName[IndexListed], TempListedSubStr, &ListedSubStrLen);
if (NewSubStrLen > ListedSubStrLen) {
//
// Substr in NewFileName is longer. Pad tail with SPACE
//
- PadStrInTail(TempListedSubStr, NewSubStrLen - ListedSubStrLen, L' ');
- } else if (NewSubStrLen < ListedSubStrLen){
+ PadStrInTail (TempListedSubStr, NewSubStrLen - ListedSubStrLen, L' ');
+ } else if (NewSubStrLen < ListedSubStrLen) {
//
// Substr in ListedFileName is longer. Pad tail with SPACE
//
- PadStrInTail(TempNewSubStr, ListedSubStrLen - NewSubStrLen, L' ');
+ PadStrInTail (TempNewSubStr, ListedSubStrLen - NewSubStrLen, L' ');
}
- SubStrCmpResult = StrnCmp(TempNewSubStr, TempListedSubStr, MAX_FILE_NAME_LEN);
+ SubStrCmpResult = StrnCmp (TempNewSubStr, TempListedSubStr, MAX_FILE_NAME_LEN);
if (SubStrCmpResult != 0) {
break;
}
@@ -789,7 +803,7 @@ GetFileInfoListInAlphabetFromDir( //
// Reach File First Name end
//
- if (NewFileName[IndexNew] == L'\0' || ListedFileName[IndexListed] == L'\0') {
+ if ((NewFileName[IndexNew] == L'\0') || (ListedFileName[IndexListed] == L'\0')) {
break;
}
@@ -812,7 +826,7 @@ GetFileInfoListInAlphabetFromDir( // 2. if NewFileName is shorter than ListedFileName
//
if (NewFileName[IndexNew] == L'\0') {
- if (ListedFileName[IndexListed] != L'\0' || (StrnCmp(NewFileNameExtension, ListedFileNameExtension, MAX_FILE_NAME_LEN) < 0)) {
+ if ((ListedFileName[IndexListed] != L'\0') || (StrnCmp (NewFileNameExtension, ListedFileNameExtension, MAX_FILE_NAME_LEN) < 0)) {
break;
}
}
@@ -829,7 +843,7 @@ GetFileInfoListInAlphabetFromDir( // else
// Insert at the tail of this list (Link = FileInfoList)
//
- InsertTailList(Link, &NewFileInfoEntry->Link);
+ InsertTailList (Link, &NewFileInfoEntry->Link);
FileCount++;
}
@@ -839,32 +853,32 @@ GetFileInfoListInAlphabetFromDir( EXIT:
if (TempNewSubStr != NULL) {
- FreePool(TempNewSubStr);
+ FreePool (TempNewSubStr);
}
if (TempListedSubStr != NULL) {
- FreePool(TempListedSubStr);
+ FreePool (TempListedSubStr);
}
- if (EFI_ERROR(Status)) {
- while(!IsListEmpty(FileInfoList)) {
+ if (EFI_ERROR (Status)) {
+ while (!IsListEmpty (FileInfoList)) {
Link = FileInfoList->ForwardLink;
- RemoveEntryList(Link);
+ RemoveEntryList (Link);
TempFileInfoEntry = CR (Link, FILE_INFO_ENTRY, Link, FILE_INFO_SIGNATURE);
- FreePool(TempFileInfoEntry->FileInfo);
- FreePool(TempFileInfoEntry->FileNameFirstPart);
- FreePool(TempFileInfoEntry->FileNameSecondPart);
- FreePool(TempFileInfoEntry);
+ FreePool (TempFileInfoEntry->FileInfo);
+ FreePool (TempFileInfoEntry->FileNameFirstPart);
+ FreePool (TempFileInfoEntry->FileNameSecondPart);
+ FreePool (TempFileInfoEntry);
}
+
*FileNum = 0;
}
return Status;
}
-
/**
This routine is called to get all qualified image from file from an given directory
in alphabetic order. All the file image is copied to allocated boottime memory.
@@ -879,38 +893,38 @@ EXIT: **/
EFI_STATUS
-GetFileImageInAlphabetFromDir(
- IN EFI_FILE_HANDLE Dir,
- IN UINT64 FileAttr,
- OUT IMAGE_INFO **FilePtr,
- OUT UINTN *FileNum
+GetFileImageInAlphabetFromDir (
+ IN EFI_FILE_HANDLE Dir,
+ IN UINT64 FileAttr,
+ OUT IMAGE_INFO **FilePtr,
+ OUT UINTN *FileNum
)
{
- EFI_STATUS Status;
- LIST_ENTRY *Link;
- EFI_FILE_HANDLE FileHandle;
- FILE_INFO_ENTRY *FileInfoEntry;
- EFI_FILE_INFO *FileInfo;
- UINTN FileCount;
- IMAGE_INFO *TempFilePtrBuf;
- UINTN Size;
- LIST_ENTRY FileInfoList;
-
- FileHandle = NULL;
- FileCount = 0;
- TempFilePtrBuf = NULL;
- *FilePtr = NULL;
+ EFI_STATUS Status;
+ LIST_ENTRY *Link;
+ EFI_FILE_HANDLE FileHandle;
+ FILE_INFO_ENTRY *FileInfoEntry;
+ EFI_FILE_INFO *FileInfo;
+ UINTN FileCount;
+ IMAGE_INFO *TempFilePtrBuf;
+ UINTN Size;
+ LIST_ENTRY FileInfoList;
+
+ FileHandle = NULL;
+ FileCount = 0;
+ TempFilePtrBuf = NULL;
+ *FilePtr = NULL;
//
// Get file list in Dir in alphabetical order
//
- Status = GetFileInfoListInAlphabetFromDir(
+ Status = GetFileInfoListInAlphabetFromDir (
Dir,
FileAttr,
&FileInfoList,
&FileCount
);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "GetFileInfoListInAlphabetFromDir Failed!\n"));
goto EXIT;
}
@@ -921,7 +935,7 @@ GetFileImageInAlphabetFromDir( goto EXIT;
}
- TempFilePtrBuf = (IMAGE_INFO *)AllocateZeroPool(sizeof(IMAGE_INFO) * FileCount);
+ TempFilePtrBuf = (IMAGE_INFO *)AllocateZeroPool (sizeof (IMAGE_INFO) * FileCount);
if (TempFilePtrBuf == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto EXIT;
@@ -938,64 +952,66 @@ GetFileImageInAlphabetFromDir( FileInfoEntry = CR (Link, FILE_INFO_ENTRY, Link, FILE_INFO_SIGNATURE);
FileInfo = FileInfoEntry->FileInfo;
- Status = Dir->Open(
+ Status = Dir->Open (
Dir,
&FileHandle,
FileInfo->FileName,
EFI_FILE_MODE_READ,
0
);
- if (EFI_ERROR(Status)){
+ if (EFI_ERROR (Status)) {
continue;
}
- Size = (UINTN)FileInfo->FileSize;
- TempFilePtrBuf[FileCount].ImageAddress = AllocateZeroPool(Size);
+ Size = (UINTN)FileInfo->FileSize;
+ TempFilePtrBuf[FileCount].ImageAddress = AllocateZeroPool (Size);
if (TempFilePtrBuf[FileCount].ImageAddress == NULL) {
- DEBUG((DEBUG_ERROR, "Fail to allocate memory for capsule. Stop processing the rest.\n"));
+ DEBUG ((DEBUG_ERROR, "Fail to allocate memory for capsule. Stop processing the rest.\n"));
break;
}
- Status = FileHandle->Read(
+ Status = FileHandle->Read (
FileHandle,
&Size,
TempFilePtrBuf[FileCount].ImageAddress
);
- FileHandle->Close(FileHandle);
+ FileHandle->Close (FileHandle);
//
// Skip read error file
//
- if (EFI_ERROR(Status) || Size != (UINTN)FileInfo->FileSize) {
+ if (EFI_ERROR (Status) || (Size != (UINTN)FileInfo->FileSize)) {
//
// Remove this error file info accordingly
// & move Link to BackLink
//
- Link = RemoveEntryList(Link);
+ Link = RemoveEntryList (Link);
Link = Link->BackLink;
- FreePool(FileInfoEntry->FileInfo);
- FreePool(FileInfoEntry->FileNameFirstPart);
- FreePool(FileInfoEntry->FileNameSecondPart);
- FreePool(FileInfoEntry);
+ FreePool (FileInfoEntry->FileInfo);
+ FreePool (FileInfoEntry->FileNameFirstPart);
+ FreePool (FileInfoEntry->FileNameSecondPart);
+ FreePool (FileInfoEntry);
- FreePool(TempFilePtrBuf[FileCount].ImageAddress);
+ FreePool (TempFilePtrBuf[FileCount].ImageAddress);
TempFilePtrBuf[FileCount].ImageAddress = NULL;
TempFilePtrBuf[FileCount].FileInfo = NULL;
continue;
}
+
TempFilePtrBuf[FileCount].FileInfo = FileInfo;
FileCount++;
}
DEBUG_CODE_BEGIN ();
- for (Link = FileInfoList.ForwardLink; Link != &FileInfoList; Link = Link->ForwardLink) {
- FileInfoEntry = CR (Link, FILE_INFO_ENTRY, Link, FILE_INFO_SIGNATURE);
- FileInfo = FileInfoEntry->FileInfo;
- DEBUG((DEBUG_INFO, "Successfully read capsule file %s from disk.\n", FileInfo->FileName));
- }
+ for (Link = FileInfoList.ForwardLink; Link != &FileInfoList; Link = Link->ForwardLink) {
+ FileInfoEntry = CR (Link, FILE_INFO_ENTRY, Link, FILE_INFO_SIGNATURE);
+ FileInfo = FileInfoEntry->FileInfo;
+ DEBUG ((DEBUG_INFO, "Successfully read capsule file %s from disk.\n", FileInfo->FileName));
+ }
+
DEBUG_CODE_END ();
EXIT:
@@ -1006,15 +1022,15 @@ EXIT: //
// FileInfo will be freed by Calller
//
- while(!IsListEmpty(&FileInfoList)) {
+ while (!IsListEmpty (&FileInfoList)) {
Link = FileInfoList.ForwardLink;
- RemoveEntryList(Link);
+ RemoveEntryList (Link);
FileInfoEntry = CR (Link, FILE_INFO_ENTRY, Link, FILE_INFO_SIGNATURE);
- FreePool(FileInfoEntry->FileNameFirstPart);
- FreePool(FileInfoEntry->FileNameSecondPart);
- FreePool(FileInfoEntry);
+ FreePool (FileInfoEntry->FileNameFirstPart);
+ FreePool (FileInfoEntry->FileNameSecondPart);
+ FreePool (FileInfoEntry);
}
return Status;
@@ -1030,31 +1046,31 @@ EXIT: **/
EFI_STATUS
-RemoveFileFromDir(
- IN EFI_FILE_HANDLE Dir,
- IN UINT64 FileAttr
+RemoveFileFromDir (
+ IN EFI_FILE_HANDLE Dir,
+ IN UINT64 FileAttr
)
{
- EFI_STATUS Status;
- LIST_ENTRY *Link;
- LIST_ENTRY FileInfoList;
- EFI_FILE_HANDLE FileHandle;
- FILE_INFO_ENTRY *FileInfoEntry;
- EFI_FILE_INFO *FileInfo;
- UINTN FileCount;
+ EFI_STATUS Status;
+ LIST_ENTRY *Link;
+ LIST_ENTRY FileInfoList;
+ EFI_FILE_HANDLE FileHandle;
+ FILE_INFO_ENTRY *FileInfoEntry;
+ EFI_FILE_INFO *FileInfo;
+ UINTN FileCount;
FileHandle = NULL;
//
// Get file list in Dir in alphabetical order
//
- Status = GetFileInfoListInAlphabetFromDir(
+ Status = GetFileInfoListInAlphabetFromDir (
Dir,
FileAttr,
&FileInfoList,
&FileCount
);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "GetFileInfoListInAlphabetFromDir Failed!\n"));
goto EXIT;
}
@@ -1075,30 +1091,30 @@ RemoveFileFromDir( FileInfoEntry = CR (Link, FILE_INFO_ENTRY, Link, FILE_INFO_SIGNATURE);
FileInfo = FileInfoEntry->FileInfo;
- Status = Dir->Open(
+ Status = Dir->Open (
Dir,
&FileHandle,
FileInfo->FileName,
EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE,
0
);
- if (EFI_ERROR(Status)){
+ if (EFI_ERROR (Status)) {
continue;
}
- Status = FileHandle->Delete(FileHandle);
+ Status = FileHandle->Delete (FileHandle);
}
EXIT:
- while(!IsListEmpty(&FileInfoList)) {
+ while (!IsListEmpty (&FileInfoList)) {
Link = FileInfoList.ForwardLink;
- RemoveEntryList(Link);
+ RemoveEntryList (Link);
FileInfoEntry = CR (Link, FILE_INFO_ENTRY, Link, FILE_INFO_SIGNATURE);
- FreePool(FileInfoEntry->FileInfo);
- FreePool(FileInfoEntry);
+ FreePool (FileInfoEntry->FileInfo);
+ FreePool (FileInfoEntry);
}
return Status;
@@ -1119,12 +1135,12 @@ EXIT: **/
EFI_STATUS
-GetAllCapsuleOnDisk(
- IN UINTN MaxRetry,
- OUT IMAGE_INFO **CapsulePtr,
- OUT UINTN *CapsuleNum,
- OUT EFI_HANDLE *FsHandle,
- OUT UINT16 *LoadOptionNumber
+GetAllCapsuleOnDisk (
+ IN UINTN MaxRetry,
+ OUT IMAGE_INFO **CapsulePtr,
+ OUT UINTN *CapsuleNum,
+ OUT EFI_HANDLE *FsHandle,
+ OUT UINT16 *LoadOptionNumber
)
{
EFI_STATUS Status;
@@ -1136,52 +1152,53 @@ GetAllCapsuleOnDisk( TempOptionNumber = NULL;
*CapsuleNum = 0;
- Status = GetEfiSysPartitionFromActiveBootOption(MaxRetry, &TempOptionNumber, FsHandle);
- if (EFI_ERROR(Status)) {
+ Status = GetEfiSysPartitionFromActiveBootOption (MaxRetry, &TempOptionNumber, FsHandle);
+ if (EFI_ERROR (Status)) {
return Status;
}
- Status = gBS->HandleProtocol(*FsHandle, &gEfiSimpleFileSystemProtocolGuid, (VOID **)&Fs);
- if (EFI_ERROR(Status)) {
+ Status = gBS->HandleProtocol (*FsHandle, &gEfiSimpleFileSystemProtocolGuid, (VOID **)&Fs);
+ if (EFI_ERROR (Status)) {
return Status;
}
- Status = Fs->OpenVolume(Fs, &RootDir);
- if (EFI_ERROR(Status)) {
+ Status = Fs->OpenVolume (Fs, &RootDir);
+ if (EFI_ERROR (Status)) {
return Status;
}
- Status = RootDir->Open(
+ Status = RootDir->Open (
RootDir,
&FileDir,
EFI_CAPSULE_FILE_DIRECTORY,
EFI_FILE_MODE_READ,
0
);
- if (EFI_ERROR(Status)) {
- DEBUG((DEBUG_ERROR, "CodLibGetAllCapsuleOnDisk fail to open RootDir!\n"));
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "CodLibGetAllCapsuleOnDisk fail to open RootDir!\n"));
RootDir->Close (RootDir);
return Status;
}
+
RootDir->Close (RootDir);
//
// Only Load files with EFI_FILE_SYSTEM or EFI_FILE_ARCHIVE attribute
// ignore EFI_FILE_READ_ONLY, EFI_FILE_HIDDEN, EFI_FILE_RESERVED, EFI_FILE_DIRECTORY
//
- Status = GetFileImageInAlphabetFromDir(
+ Status = GetFileImageInAlphabetFromDir (
FileDir,
EFI_FILE_SYSTEM | EFI_FILE_ARCHIVE,
CapsulePtr,
CapsuleNum
);
- DEBUG((DEBUG_INFO, "GetFileImageInAlphabetFromDir status %x\n", Status));
+ DEBUG ((DEBUG_INFO, "GetFileImageInAlphabetFromDir status %x\n", Status));
//
// Always remove file to avoid deadloop in capsule process
//
- Status = RemoveFileFromDir(FileDir, EFI_FILE_SYSTEM | EFI_FILE_ARCHIVE);
- DEBUG((DEBUG_INFO, "RemoveFileFromDir status %x\n", Status));
+ Status = RemoveFileFromDir (FileDir, EFI_FILE_SYSTEM | EFI_FILE_ARCHIVE);
+ DEBUG ((DEBUG_INFO, "RemoveFileFromDir status %x\n", Status));
FileDir->Close (FileDir);
@@ -1205,10 +1222,10 @@ GetAllCapsuleOnDisk( **/
EFI_STATUS
BuildGatherList (
- IN VOID **CapsuleBuffer,
- IN UINTN *CapsuleSize,
- IN UINTN CapsuleNum,
- OUT EFI_CAPSULE_BLOCK_DESCRIPTOR **BlockDescriptors
+ IN VOID **CapsuleBuffer,
+ IN UINTN *CapsuleSize,
+ IN UINTN CapsuleNum,
+ OUT EFI_CAPSULE_BLOCK_DESCRIPTOR **BlockDescriptors
)
{
EFI_STATUS Status;
@@ -1225,13 +1242,13 @@ BuildGatherList ( //
// Allocate memory for the descriptors.
//
- BlockDescriptors1 = AllocateZeroPool (2 * sizeof (EFI_CAPSULE_BLOCK_DESCRIPTOR));
+ BlockDescriptors1 = AllocateZeroPool (2 * sizeof (EFI_CAPSULE_BLOCK_DESCRIPTOR));
if (BlockDescriptors1 == NULL) {
DEBUG ((DEBUG_ERROR, "BuildGatherList: failed to allocate memory for descriptors\n"));
Status = EFI_OUT_OF_RESOURCES;
goto ERREXIT;
} else {
- DEBUG ((DEBUG_INFO, "BuildGatherList: creating capsule descriptors at 0x%X\n", (UINTN) BlockDescriptors1));
+ DEBUG ((DEBUG_INFO, "BuildGatherList: creating capsule descriptors at 0x%X\n", (UINTN)BlockDescriptors1));
}
//
@@ -1242,15 +1259,15 @@ BuildGatherList ( }
if (BlockDescriptorPre != NULL) {
- BlockDescriptorPre->Union.ContinuationPointer = (UINTN) BlockDescriptors1;
- BlockDescriptorPre->Length = 0;
+ BlockDescriptorPre->Union.ContinuationPointer = (UINTN)BlockDescriptors1;
+ BlockDescriptorPre->Length = 0;
}
- BlockDescriptors1->Union.DataBlock = (UINTN) CapsuleBuffer[Index];
- BlockDescriptors1->Length = CapsuleSize[Index];
+ BlockDescriptors1->Union.DataBlock = (UINTN)CapsuleBuffer[Index];
+ BlockDescriptors1->Length = CapsuleSize[Index];
BlockDescriptorPre = BlockDescriptors1 + 1;
- BlockDescriptors1 = NULL;
+ BlockDescriptors1 = NULL;
}
//
@@ -1258,8 +1275,8 @@ BuildGatherList ( //
if (BlockDescriptorPre != NULL) {
BlockDescriptorPre->Union.ContinuationPointer = (UINTN)NULL;
- BlockDescriptorPre->Length = 0;
- *BlockDescriptors = BlockDescriptorsHeader;
+ BlockDescriptorPre->Length = 0;
+ *BlockDescriptors = BlockDescriptorsHeader;
}
return EFI_SUCCESS;
@@ -1282,35 +1299,35 @@ ERREXIT: **/
BOOLEAN
EFIAPI
-CoDCheckCapsuleOnDiskFlag(
+CoDCheckCapsuleOnDiskFlag (
VOID
)
{
- EFI_STATUS Status;
- UINT64 OsIndication;
- UINTN DataSize;
+ EFI_STATUS Status;
+ UINT64 OsIndication;
+ UINTN DataSize;
//
// Check File Capsule Delivery Supported Flag in OsIndication variable
//
OsIndication = 0;
- DataSize = sizeof(UINT64);
- Status = gRT->GetVariable (
- EFI_OS_INDICATIONS_VARIABLE_NAME,
- &gEfiGlobalVariableGuid,
- NULL,
- &DataSize,
- &OsIndication
- );
- if (!EFI_ERROR(Status) &&
- (OsIndication & EFI_OS_INDICATIONS_FILE_CAPSULE_DELIVERY_SUPPORTED) != 0) {
+ DataSize = sizeof (UINT64);
+ Status = gRT->GetVariable (
+ EFI_OS_INDICATIONS_VARIABLE_NAME,
+ &gEfiGlobalVariableGuid,
+ NULL,
+ &DataSize,
+ &OsIndication
+ );
+ if (!EFI_ERROR (Status) &&
+ ((OsIndication & EFI_OS_INDICATIONS_FILE_CAPSULE_DELIVERY_SUPPORTED) != 0))
+ {
return TRUE;
}
return FALSE;
}
-
/**
This routine is called to clear CapsuleOnDisk flags including OsIndications and BootNext variable.
@@ -1319,40 +1336,41 @@ CoDCheckCapsuleOnDiskFlag( **/
EFI_STATUS
EFIAPI
-CoDClearCapsuleOnDiskFlag(
+CoDClearCapsuleOnDiskFlag (
VOID
)
{
- EFI_STATUS Status;
- UINT64 OsIndication;
- UINTN DataSize;
+ EFI_STATUS Status;
+ UINT64 OsIndication;
+ UINTN DataSize;
//
// Reset File Capsule Delivery Supported Flag in OsIndication variable
//
OsIndication = 0;
- DataSize = sizeof(UINT64);
- Status = gRT->GetVariable (
- EFI_OS_INDICATIONS_VARIABLE_NAME,
- &gEfiGlobalVariableGuid,
- NULL,
- &DataSize,
- &OsIndication
- );
- if (EFI_ERROR(Status) ||
- (OsIndication & EFI_OS_INDICATIONS_FILE_CAPSULE_DELIVERY_SUPPORTED) == 0) {
+ DataSize = sizeof (UINT64);
+ Status = gRT->GetVariable (
+ EFI_OS_INDICATIONS_VARIABLE_NAME,
+ &gEfiGlobalVariableGuid,
+ NULL,
+ &DataSize,
+ &OsIndication
+ );
+ if (EFI_ERROR (Status) ||
+ ((OsIndication & EFI_OS_INDICATIONS_FILE_CAPSULE_DELIVERY_SUPPORTED) == 0))
+ {
return Status;
}
OsIndication &= ~((UINT64)EFI_OS_INDICATIONS_FILE_CAPSULE_DELIVERY_SUPPORTED);
- Status = gRT->SetVariable (
- EFI_OS_INDICATIONS_VARIABLE_NAME,
- &gEfiGlobalVariableGuid,
- EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
- sizeof(UINT64),
- &OsIndication
- );
- ASSERT(!EFI_ERROR(Status));
+ Status = gRT->SetVariable (
+ EFI_OS_INDICATIONS_VARIABLE_NAME,
+ &gEfiGlobalVariableGuid,
+ EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
+ sizeof (UINT64),
+ &OsIndication
+ );
+ ASSERT (!EFI_ERROR (Status));
//
// Delete BootNext variable. Capsule Process may reset system, so can't rely on Bds to clear this variable
@@ -1377,7 +1395,7 @@ CoDClearCapsuleOnDiskFlag( **/
EFI_STATUS
-CoDClearCapsuleRelocationInfo(
+CoDClearCapsuleRelocationInfo (
VOID
)
{
@@ -1408,32 +1426,32 @@ CoDClearCapsuleRelocationInfo( **/
EFI_STATUS
-RelocateCapsuleToDisk(
- UINTN MaxRetry
+RelocateCapsuleToDisk (
+ UINTN MaxRetry
)
{
- EFI_STATUS Status;
- UINTN CapsuleOnDiskNum;
- UINTN Index;
- UINTN DataSize;
- UINT64 TotalImageSize;
- UINT64 TotalImageNameSize;
- IMAGE_INFO *CapsuleOnDiskBuf;
- EFI_HANDLE Handle;
- EFI_HANDLE TempHandle;
- EFI_HANDLE *HandleBuffer;
- UINTN NumberOfHandles;
- EFI_BLOCK_IO_PROTOCOL *BlockIo;
- UINT8 *CapsuleDataBuf;
- UINT8 *CapsulePtr;
- EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *Fs;
- EFI_FILE_HANDLE RootDir;
- EFI_FILE_HANDLE TempCodFile;
- UINT64 TempCodFileSize;
- EFI_DEVICE_PATH *TempDevicePath;
- BOOLEAN RelocationInfo;
- UINT16 LoadOptionNumber;
- EFI_CAPSULE_HEADER FileNameCapsuleHeader;
+ EFI_STATUS Status;
+ UINTN CapsuleOnDiskNum;
+ UINTN Index;
+ UINTN DataSize;
+ UINT64 TotalImageSize;
+ UINT64 TotalImageNameSize;
+ IMAGE_INFO *CapsuleOnDiskBuf;
+ EFI_HANDLE Handle;
+ EFI_HANDLE TempHandle;
+ EFI_HANDLE *HandleBuffer;
+ UINTN NumberOfHandles;
+ EFI_BLOCK_IO_PROTOCOL *BlockIo;
+ UINT8 *CapsuleDataBuf;
+ UINT8 *CapsulePtr;
+ EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *Fs;
+ EFI_FILE_HANDLE RootDir;
+ EFI_FILE_HANDLE TempCodFile;
+ UINT64 TempCodFileSize;
+ EFI_DEVICE_PATH *TempDevicePath;
+ BOOLEAN RelocationInfo;
+ UINT16 LoadOptionNumber;
+ EFI_CAPSULE_HEADER FileNameCapsuleHeader;
RootDir = NULL;
TempCodFile = NULL;
@@ -1447,8 +1465,8 @@ RelocateCapsuleToDisk( //
// 1. Load all Capsule On Disks in to memory
//
- Status = GetAllCapsuleOnDisk(MaxRetry, &CapsuleOnDiskBuf, &CapsuleOnDiskNum, &Handle, &LoadOptionNumber);
- if (EFI_ERROR(Status) || CapsuleOnDiskNum == 0 || CapsuleOnDiskBuf == NULL) {
+ Status = GetAllCapsuleOnDisk (MaxRetry, &CapsuleOnDiskBuf, &CapsuleOnDiskNum, &Handle, &LoadOptionNumber);
+ if (EFI_ERROR (Status) || (CapsuleOnDiskNum == 0) || (CapsuleOnDiskBuf == NULL)) {
DEBUG ((DEBUG_INFO, "RelocateCapsule: GetAllCapsuleOnDisk Status - 0x%x\n", Status));
return EFI_NOT_FOUND;
}
@@ -1458,9 +1476,9 @@ RelocateCapsuleToDisk( // If no platform special device path specified or the device path is invalid, use the EFI system partition where
// stores the capsules as relocation device.
//
- if (IsDevicePathValid ((EFI_DEVICE_PATH *)PcdGetPtr(PcdCodRelocationDevPath), PcdGetSize(PcdCodRelocationDevPath))) {
- Status = EfiBootManagerConnectDevicePath ((EFI_DEVICE_PATH *)PcdGetPtr(PcdCodRelocationDevPath), &TempHandle);
- if (EFI_ERROR(Status)) {
+ if (IsDevicePathValid ((EFI_DEVICE_PATH *)PcdGetPtr (PcdCodRelocationDevPath), PcdGetSize (PcdCodRelocationDevPath))) {
+ Status = EfiBootManagerConnectDevicePath ((EFI_DEVICE_PATH *)PcdGetPtr (PcdCodRelocationDevPath), &TempHandle);
+ if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "RelocateCapsule: EfiBootManagerConnectDevicePath Status - 0x%x\n", Status));
goto EXIT;
}
@@ -1469,14 +1487,14 @@ RelocateCapsuleToDisk( // Connect all the child handle. Partition & FAT drivers are allowed in this case
//
gBS->ConnectController (TempHandle, NULL, NULL, TRUE);
- Status = gBS->LocateHandleBuffer(
+ Status = gBS->LocateHandleBuffer (
ByProtocol,
&gEfiSimpleFileSystemProtocolGuid,
NULL,
&NumberOfHandles,
&HandleBuffer
);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "RelocateCapsule: LocateHandleBuffer Status - 0x%x\n", Status));
goto EXIT;
}
@@ -1485,19 +1503,19 @@ RelocateCapsuleToDisk( // Find first Simple File System Handle which can match PcdCodRelocationDevPath
//
for (Index = 0; Index < NumberOfHandles; Index++) {
- Status = gBS->HandleProtocol(HandleBuffer[Index], &gEfiDevicePathProtocolGuid, (VOID **)&TempDevicePath);
- if (EFI_ERROR(Status)) {
+ Status = gBS->HandleProtocol (HandleBuffer[Index], &gEfiDevicePathProtocolGuid, (VOID **)&TempDevicePath);
+ if (EFI_ERROR (Status)) {
continue;
}
- DataSize = GetDevicePathSize((EFI_DEVICE_PATH *)PcdGetPtr(PcdCodRelocationDevPath)) - sizeof(EFI_DEVICE_PATH);
- if (0 == CompareMem((EFI_DEVICE_PATH *)PcdGetPtr(PcdCodRelocationDevPath), TempDevicePath, DataSize)) {
+ DataSize = GetDevicePathSize ((EFI_DEVICE_PATH *)PcdGetPtr (PcdCodRelocationDevPath)) - sizeof (EFI_DEVICE_PATH);
+ if (0 == CompareMem ((EFI_DEVICE_PATH *)PcdGetPtr (PcdCodRelocationDevPath), TempDevicePath, DataSize)) {
Handle = HandleBuffer[Index];
break;
}
}
- FreePool(HandleBuffer);
+ FreePool (HandleBuffer);
if (Index == NumberOfHandles) {
DEBUG ((DEBUG_ERROR, "RelocateCapsule: No simple file system protocol found.\n"));
@@ -1505,14 +1523,14 @@ RelocateCapsuleToDisk( }
}
- Status = gBS->HandleProtocol(Handle, &gEfiBlockIoProtocolGuid, (VOID **)&BlockIo);
- if (EFI_ERROR(Status) || BlockIo->Media->ReadOnly) {
- DEBUG((DEBUG_ERROR, "Fail to find Capsule on Disk relocation BlockIo device or device is ReadOnly!\n"));
+ Status = gBS->HandleProtocol (Handle, &gEfiBlockIoProtocolGuid, (VOID **)&BlockIo);
+ if (EFI_ERROR (Status) || BlockIo->Media->ReadOnly) {
+ DEBUG ((DEBUG_ERROR, "Fail to find Capsule on Disk relocation BlockIo device or device is ReadOnly!\n"));
goto EXIT;
}
- Status = gBS->HandleProtocol(Handle, &gEfiSimpleFileSystemProtocolGuid, (VOID **)&Fs);
- if (EFI_ERROR(Status)) {
+ Status = gBS->HandleProtocol (Handle, &gEfiSimpleFileSystemProtocolGuid, (VOID **)&Fs);
+ if (EFI_ERROR (Status)) {
goto EXIT;
}
@@ -1530,40 +1548,41 @@ RelocateCapsuleToDisk( goto EXIT;
}
- if (MAX_ADDRESS - (UINTN)TotalImageNameSize <= StrSize(CapsuleOnDiskBuf[Index].FileInfo->FileName)) {
+ if (MAX_ADDRESS - (UINTN)TotalImageNameSize <= StrSize (CapsuleOnDiskBuf[Index].FileInfo->FileName)) {
Status = EFI_INVALID_PARAMETER;
goto EXIT;
}
TotalImageSize += CapsuleOnDiskBuf[Index].FileInfo->FileSize;
- TotalImageNameSize += StrSize(CapsuleOnDiskBuf[Index].FileInfo->FileName);
- DEBUG((DEBUG_INFO, "RelocateCapsule: %x Size %x\n",CapsuleOnDiskBuf[Index].FileInfo->FileName, CapsuleOnDiskBuf[Index].FileInfo->FileSize));
+ TotalImageNameSize += StrSize (CapsuleOnDiskBuf[Index].FileInfo->FileName);
+ DEBUG ((DEBUG_INFO, "RelocateCapsule: %x Size %x\n", CapsuleOnDiskBuf[Index].FileInfo->FileName, CapsuleOnDiskBuf[Index].FileInfo->FileSize));
}
- DEBUG((DEBUG_INFO, "RelocateCapsule: TotalImageSize %x\n", TotalImageSize));
- DEBUG((DEBUG_INFO, "RelocateCapsule: TotalImageNameSize %x\n", TotalImageNameSize));
+ DEBUG ((DEBUG_INFO, "RelocateCapsule: TotalImageSize %x\n", TotalImageSize));
+ DEBUG ((DEBUG_INFO, "RelocateCapsule: TotalImageNameSize %x\n", TotalImageNameSize));
- if (MAX_ADDRESS - (UINTN)TotalImageNameSize <= sizeof(UINT64) * 2 ||
- MAX_ADDRESS - (UINTN)TotalImageSize <= (UINTN)TotalImageNameSize + sizeof(UINT64) * 2) {
+ if ((MAX_ADDRESS - (UINTN)TotalImageNameSize <= sizeof (UINT64) * 2) ||
+ (MAX_ADDRESS - (UINTN)TotalImageSize <= (UINTN)TotalImageNameSize + sizeof (UINT64) * 2))
+ {
Status = EFI_INVALID_PARAMETER;
goto EXIT;
}
- TempCodFileSize = sizeof(UINT64) + TotalImageSize + sizeof(EFI_CAPSULE_HEADER) + TotalImageNameSize;
+ TempCodFileSize = sizeof (UINT64) + TotalImageSize + sizeof (EFI_CAPSULE_HEADER) + TotalImageNameSize;
//
// Check if CapsuleTotalSize. There could be reminder, so use LastBlock number directly
//
- if (DivU64x32(TempCodFileSize, BlockIo->Media->BlockSize) > BlockIo->Media->LastBlock) {
- DEBUG((DEBUG_ERROR, "RelocateCapsule: Relocation device isn't big enough to hold all Capsule on Disk!\n"));
- DEBUG((DEBUG_ERROR, "TotalImageSize = %x\n", TotalImageSize));
- DEBUG((DEBUG_ERROR, "TotalImageNameSize = %x\n", TotalImageNameSize));
- DEBUG((DEBUG_ERROR, "RelocationDev BlockSize = %x LastBlock = %x\n", BlockIo->Media->BlockSize, BlockIo->Media->LastBlock));
+ if (DivU64x32 (TempCodFileSize, BlockIo->Media->BlockSize) > BlockIo->Media->LastBlock) {
+ DEBUG ((DEBUG_ERROR, "RelocateCapsule: Relocation device isn't big enough to hold all Capsule on Disk!\n"));
+ DEBUG ((DEBUG_ERROR, "TotalImageSize = %x\n", TotalImageSize));
+ DEBUG ((DEBUG_ERROR, "TotalImageNameSize = %x\n", TotalImageNameSize));
+ DEBUG ((DEBUG_ERROR, "RelocationDev BlockSize = %x LastBlock = %x\n", BlockIo->Media->BlockSize, BlockIo->Media->LastBlock));
Status = EFI_OUT_OF_RESOURCES;
goto EXIT;
}
- CapsuleDataBuf = AllocatePool((UINTN) TempCodFileSize);
+ CapsuleDataBuf = AllocatePool ((UINTN)TempCodFileSize);
if (CapsuleDataBuf == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto EXIT;
@@ -1572,79 +1591,80 @@ RelocateCapsuleToDisk( //
// First UINT64 reserved for total image size, including capsule name capsule.
//
- *(UINT64 *) CapsuleDataBuf = TotalImageSize + sizeof(EFI_CAPSULE_HEADER) + TotalImageNameSize;
+ *(UINT64 *)CapsuleDataBuf = TotalImageSize + sizeof (EFI_CAPSULE_HEADER) + TotalImageNameSize;
//
// Line up all the Capsule on Disk and write to relocation disk at one time. It could save some time in disk write
//
- for (Index = 0, CapsulePtr = CapsuleDataBuf + sizeof(UINT64); Index < CapsuleOnDiskNum; Index++) {
- CopyMem(CapsulePtr, CapsuleOnDiskBuf[Index].ImageAddress, (UINTN) CapsuleOnDiskBuf[Index].FileInfo->FileSize);
+ for (Index = 0, CapsulePtr = CapsuleDataBuf + sizeof (UINT64); Index < CapsuleOnDiskNum; Index++) {
+ CopyMem (CapsulePtr, CapsuleOnDiskBuf[Index].ImageAddress, (UINTN)CapsuleOnDiskBuf[Index].FileInfo->FileSize);
CapsulePtr += CapsuleOnDiskBuf[Index].FileInfo->FileSize;
}
//
// Line the capsule header for capsule name capsule.
//
- CopyGuid(&FileNameCapsuleHeader.CapsuleGuid, &gEdkiiCapsuleOnDiskNameGuid);
- FileNameCapsuleHeader.CapsuleImageSize = (UINT32) TotalImageNameSize + sizeof(EFI_CAPSULE_HEADER);
+ CopyGuid (&FileNameCapsuleHeader.CapsuleGuid, &gEdkiiCapsuleOnDiskNameGuid);
+ FileNameCapsuleHeader.CapsuleImageSize = (UINT32)TotalImageNameSize + sizeof (EFI_CAPSULE_HEADER);
FileNameCapsuleHeader.Flags = CAPSULE_FLAGS_PERSIST_ACROSS_RESET;
- FileNameCapsuleHeader.HeaderSize = sizeof(EFI_CAPSULE_HEADER);
- CopyMem(CapsulePtr, &FileNameCapsuleHeader, FileNameCapsuleHeader.HeaderSize);
+ FileNameCapsuleHeader.HeaderSize = sizeof (EFI_CAPSULE_HEADER);
+ CopyMem (CapsulePtr, &FileNameCapsuleHeader, FileNameCapsuleHeader.HeaderSize);
CapsulePtr += FileNameCapsuleHeader.HeaderSize;
//
// Line up all the Capsule file names.
//
for (Index = 0; Index < CapsuleOnDiskNum; Index++) {
- CopyMem(CapsulePtr, CapsuleOnDiskBuf[Index].FileInfo->FileName, StrSize(CapsuleOnDiskBuf[Index].FileInfo->FileName));
- CapsulePtr += StrSize(CapsuleOnDiskBuf[Index].FileInfo->FileName);
+ CopyMem (CapsulePtr, CapsuleOnDiskBuf[Index].FileInfo->FileName, StrSize (CapsuleOnDiskBuf[Index].FileInfo->FileName));
+ CapsulePtr += StrSize (CapsuleOnDiskBuf[Index].FileInfo->FileName);
}
//
// 5. Flash all Capsules on Disk to TempCoD.tmp under RootDir
//
- Status = Fs->OpenVolume(Fs, &RootDir);
- if (EFI_ERROR(Status)) {
- DEBUG((DEBUG_ERROR, "RelocateCapsule: OpenVolume error. %x\n", Status));
+ Status = Fs->OpenVolume (Fs, &RootDir);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "RelocateCapsule: OpenVolume error. %x\n", Status));
goto EXIT;
}
- Status = RootDir->Open(
+ Status = RootDir->Open (
RootDir,
&TempCodFile,
- (CHAR16 *)PcdGetPtr(PcdCoDRelocationFileName),
+ (CHAR16 *)PcdGetPtr (PcdCoDRelocationFileName),
EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE,
0
);
- if (!EFI_ERROR(Status)) {
+ if (!EFI_ERROR (Status)) {
//
// Error handling code to prevent malicious code to hold this file to block capsule on disk
//
- TempCodFile->Delete(TempCodFile);
+ TempCodFile->Delete (TempCodFile);
}
- Status = RootDir->Open(
+
+ Status = RootDir->Open (
RootDir,
&TempCodFile,
- (CHAR16 *)PcdGetPtr(PcdCoDRelocationFileName),
+ (CHAR16 *)PcdGetPtr (PcdCoDRelocationFileName),
EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE,
0
);
- if (EFI_ERROR(Status)) {
- DEBUG((DEBUG_ERROR, "RelocateCapsule: Open TemCoD.tmp error. %x\n", Status));
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "RelocateCapsule: Open TemCoD.tmp error. %x\n", Status));
goto EXIT;
}
//
// Always write at the begining of TempCap file
//
- DataSize = (UINTN) TempCodFileSize;
- Status = TempCodFile->Write(
- TempCodFile,
- &DataSize,
- CapsuleDataBuf
- );
- if (EFI_ERROR(Status)) {
- DEBUG((DEBUG_ERROR, "RelocateCapsule: Write TemCoD.tmp error. %x\n", Status));
+ DataSize = (UINTN)TempCodFileSize;
+ Status = TempCodFile->Write (
+ TempCodFile,
+ &DataSize,
+ CapsuleDataBuf
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "RelocateCapsule: Write TemCoD.tmp error. %x\n", Status));
goto EXIT;
}
@@ -1658,30 +1678,30 @@ RelocateCapsuleToDisk( // It is used in next reboot by TCB
//
RelocationInfo = TRUE;
- Status = gRT->SetVariable(
- COD_RELOCATION_INFO_VAR_NAME,
- &gEfiCapsuleVendorGuid,
- EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
- sizeof (BOOLEAN),
- &RelocationInfo
- );
+ Status = gRT->SetVariable (
+ COD_RELOCATION_INFO_VAR_NAME,
+ &gEfiCapsuleVendorGuid,
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
+ sizeof (BOOLEAN),
+ &RelocationInfo
+ );
//
// Save the LoadOptionNumber of the boot option, where the capsule is relocated,
// into "CodRelocationLoadOption" var. It is used in next reboot after capsule is
// updated out of TCB to remove the TempCoDFile.
//
- Status = gRT->SetVariable(
- COD_RELOCATION_LOAD_OPTION_VAR_NAME,
- &gEfiCapsuleVendorGuid,
- EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
- sizeof (UINT16),
- &LoadOptionNumber
- );
+ Status = gRT->SetVariable (
+ COD_RELOCATION_LOAD_OPTION_VAR_NAME,
+ &gEfiCapsuleVendorGuid,
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
+ sizeof (UINT16),
+ &LoadOptionNumber
+ );
EXIT:
if (CapsuleDataBuf != NULL) {
- FreePool(CapsuleDataBuf);
+ FreePool (CapsuleDataBuf);
}
if (CapsuleOnDiskBuf != NULL) {
@@ -1689,14 +1709,15 @@ EXIT: // Free resources allocated by CodLibGetAllCapsuleOnDisk
//
for (Index = 0; Index < CapsuleOnDiskNum; Index++ ) {
- FreePool(CapsuleOnDiskBuf[Index].ImageAddress);
- FreePool(CapsuleOnDiskBuf[Index].FileInfo);
+ FreePool (CapsuleOnDiskBuf[Index].ImageAddress);
+ FreePool (CapsuleOnDiskBuf[Index].FileInfo);
}
- FreePool(CapsuleOnDiskBuf);
+
+ FreePool (CapsuleOnDiskBuf);
}
if (TempCodFile != NULL) {
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
TempCodFile->Delete (TempCodFile);
} else {
TempCodFile->Close (TempCodFile);
@@ -1724,7 +1745,7 @@ EXIT: **/
EFI_STATUS
RelocateCapsuleToRam (
- UINTN MaxRetry
+ UINTN MaxRetry
)
{
EFI_STATUS Status;
@@ -1752,7 +1773,7 @@ RelocateCapsuleToRam ( // 1. Load all Capsule On Disks into memory
//
Status = GetAllCapsuleOnDisk (MaxRetry, &CapsuleOnDiskBuf, &CapsuleOnDiskNum, &Handle, NULL);
- if (EFI_ERROR (Status) || CapsuleOnDiskNum == 0 || CapsuleOnDiskBuf == NULL) {
+ if (EFI_ERROR (Status) || (CapsuleOnDiskNum == 0) || (CapsuleOnDiskBuf == NULL)) {
DEBUG ((DEBUG_ERROR, "GetAllCapsuleOnDisk Status - 0x%x\n", Status));
return EFI_NOT_FOUND;
}
@@ -1774,9 +1795,9 @@ RelocateCapsuleToRam ( }
for (Index = 0; Index < CapsuleOnDiskNum; Index++) {
- CapsuleBuffer[Index] = (VOID *)(UINTN) CapsuleOnDiskBuf[Index].ImageAddress;
- CapsuleSize[Index] = (UINTN) CapsuleOnDiskBuf[Index].FileInfo->FileSize;
- TotalStringSize += StrSize (CapsuleOnDiskBuf[Index].FileInfo->FileName);
+ CapsuleBuffer[Index] = (VOID *)(UINTN)CapsuleOnDiskBuf[Index].ImageAddress;
+ CapsuleSize[Index] = (UINTN)CapsuleOnDiskBuf[Index].FileInfo->FileSize;
+ TotalStringSize += StrSize (CapsuleOnDiskBuf[Index].FileInfo->FileName);
}
// If Persist Across Reset isn't supported, skip the file name strings capsule
@@ -1784,6 +1805,7 @@ RelocateCapsuleToRam ( CapsulesToProcess = CapsuleOnDiskNum;
goto BuildGather;
}
+
CapsulesToProcess = CapsuleOnDiskNum + 1;
FileNameCapsule = AllocateZeroPool (sizeof (EFI_CAPSULE_HEADER) + TotalStringSize);
@@ -1794,41 +1816,44 @@ RelocateCapsuleToRam ( return EFI_OUT_OF_RESOURCES;
}
- FileNameCapsule->CapsuleImageSize = (UINT32) (sizeof (EFI_CAPSULE_HEADER) + TotalStringSize);
- FileNameCapsule->Flags = CAPSULE_FLAGS_PERSIST_ACROSS_RESET;
- FileNameCapsule->HeaderSize = sizeof (EFI_CAPSULE_HEADER);
+ FileNameCapsule->CapsuleImageSize = (UINT32)(sizeof (EFI_CAPSULE_HEADER) + TotalStringSize);
+ FileNameCapsule->Flags = CAPSULE_FLAGS_PERSIST_ACROSS_RESET;
+ FileNameCapsule->HeaderSize = sizeof (EFI_CAPSULE_HEADER);
CopyGuid (&(FileNameCapsule->CapsuleGuid), &gEdkiiCapsuleOnDiskNameGuid);
StringBuf = (UINT8 *)FileNameCapsule + FileNameCapsule->HeaderSize;
- for (Index = 0; Index < CapsuleOnDiskNum; Index ++) {
+ for (Index = 0; Index < CapsuleOnDiskNum; Index++) {
StringSize = StrSize (CapsuleOnDiskBuf[Index].FileInfo->FileName);
CopyMem (StringBuf, CapsuleOnDiskBuf[Index].FileInfo->FileName, StringSize);
StringBuf += StringSize;
}
CapsuleBuffer[CapsuleOnDiskNum] = FileNameCapsule;
- CapsuleSize[CapsuleOnDiskNum] = TotalStringSize + sizeof (EFI_CAPSULE_HEADER);
+ CapsuleSize[CapsuleOnDiskNum] = TotalStringSize + sizeof (EFI_CAPSULE_HEADER);
//
// 3. Build Gather list for the capsules
//
BuildGather:
Status = BuildGatherList (CapsuleBuffer, CapsuleSize, CapsulesToProcess, &BlockDescriptors);
- if (EFI_ERROR (Status) || BlockDescriptors == NULL) {
+ if (EFI_ERROR (Status) || (BlockDescriptors == NULL)) {
FreePool (CapsuleBuffer);
FreePool (CapsuleSize);
if (FileNameCapsule != NULL) {
FreePool (FileNameCapsule);
}
+
return EFI_OUT_OF_RESOURCES;
}
//
// 4. Call UpdateCapsule() service
//
- Status = gRT->UpdateCapsule ((EFI_CAPSULE_HEADER **) CapsuleBuffer,
- CapsulesToProcess,
- (UINTN) BlockDescriptors);
+ Status = gRT->UpdateCapsule (
+ (EFI_CAPSULE_HEADER **)CapsuleBuffer,
+ CapsulesToProcess,
+ (UINTN)BlockDescriptors
+ );
return Status;
}
@@ -1857,8 +1882,8 @@ BuildGather: **/
EFI_STATUS
EFIAPI
-CoDRelocateCapsule(
- UINTN MaxRetry
+CoDRelocateCapsule (
+ UINTN MaxRetry
)
{
if (!PcdGetBool (PcdCapsuleOnDiskSupport)) {
@@ -1877,7 +1902,7 @@ CoDRelocateCapsule( DEBUG ((DEBUG_INFO, "Capsule In Ram is supported, call gRT->UpdateCapsule().\n"));
return RelocateCapsuleToRam (MaxRetry);
} else {
- DEBUG ((DEBUG_INFO, "Reallcoate all Capsule on Disks to %s in RootDir.\n", (CHAR16 *)PcdGetPtr(PcdCoDRelocationFileName)));
+ DEBUG ((DEBUG_INFO, "Reallcoate all Capsule on Disks to %s in RootDir.\n", (CHAR16 *)PcdGetPtr (PcdCoDRelocationFileName)));
return RelocateCapsuleToDisk (MaxRetry);
}
}
@@ -1896,7 +1921,7 @@ CoDRelocateCapsule( EFI_STATUS
EFIAPI
CoDRemoveTempFile (
- UINTN MaxRetry
+ UINTN MaxRetry
)
{
EFI_STATUS Status;
@@ -1909,9 +1934,9 @@ CoDRemoveTempFile ( RootDir = NULL;
TempCodFile = NULL;
- DataSize = sizeof(UINT16);
+ DataSize = sizeof (UINT16);
- LoadOptionNumber = AllocatePool (sizeof(UINT16));
+ LoadOptionNumber = AllocatePool (sizeof (UINT16));
if (LoadOptionNumber == NULL) {
return EFI_OUT_OF_RESOURCES;
}
@@ -1926,54 +1951,54 @@ CoDRemoveTempFile ( &DataSize,
(VOID *)LoadOptionNumber
);
- if (EFI_ERROR(Status) || DataSize != sizeof(UINT16)) {
+ if (EFI_ERROR (Status) || (DataSize != sizeof (UINT16))) {
goto EXIT;
}
//
// Get the EFI file system from the boot option where the capsules are relocated
//
- Status = GetEfiSysPartitionFromActiveBootOption(MaxRetry, &LoadOptionNumber, &FsHandle);
- if (EFI_ERROR(Status)) {
+ Status = GetEfiSysPartitionFromActiveBootOption (MaxRetry, &LoadOptionNumber, &FsHandle);
+ if (EFI_ERROR (Status)) {
goto EXIT;
}
- Status = gBS->HandleProtocol(FsHandle, &gEfiSimpleFileSystemProtocolGuid, (VOID **)&Fs);
- if (EFI_ERROR(Status)) {
+ Status = gBS->HandleProtocol (FsHandle, &gEfiSimpleFileSystemProtocolGuid, (VOID **)&Fs);
+ if (EFI_ERROR (Status)) {
goto EXIT;
}
- Status = Fs->OpenVolume(Fs, &RootDir);
- if (EFI_ERROR(Status)) {
+ Status = Fs->OpenVolume (Fs, &RootDir);
+ if (EFI_ERROR (Status)) {
goto EXIT;
}
//
// Delete the TempCoDFile
//
- Status = RootDir->Open(
+ Status = RootDir->Open (
RootDir,
&TempCodFile,
- (CHAR16 *)PcdGetPtr(PcdCoDRelocationFileName),
+ (CHAR16 *)PcdGetPtr (PcdCoDRelocationFileName),
EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE,
0
);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
goto EXIT;
}
- TempCodFile->Delete(TempCodFile);
+ TempCodFile->Delete (TempCodFile);
//
// Clear "CoDRelocationLoadOption" variable
//
Status = gRT->SetVariable (
- COD_RELOCATION_LOAD_OPTION_VAR_NAME,
- &gEfiCapsuleVendorGuid,
- 0,
- 0,
- NULL
- );
+ COD_RELOCATION_LOAD_OPTION_VAR_NAME,
+ &gEfiCapsuleVendorGuid,
+ 0,
+ 0,
+ NULL
+ );
EXIT:
if (LoadOptionNumber != NULL) {
@@ -1981,7 +2006,7 @@ EXIT: }
if (RootDir != NULL) {
- RootDir->Close(RootDir);
+ RootDir->Close (RootDir);
}
return Status;
diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/CapsuleOnDisk.h b/MdeModulePkg/Library/DxeCapsuleLibFmp/CapsuleOnDisk.h index 4300e32770..39f9596d50 100644 --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/CapsuleOnDisk.h +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/CapsuleOnDisk.h @@ -38,26 +38,26 @@ //
// This data structure is the part of FILE_INFO_ENTRY
//
-#define FILE_INFO_SIGNATURE SIGNATURE_32 ('F', 'L', 'I', 'F')
+#define FILE_INFO_SIGNATURE SIGNATURE_32 ('F', 'L', 'I', 'F')
//
// LoadOptionNumber of the boot option where the capsules is relocated.
//
-#define COD_RELOCATION_LOAD_OPTION_VAR_NAME L"CodRelocationLoadOption"
+#define COD_RELOCATION_LOAD_OPTION_VAR_NAME L"CodRelocationLoadOption"
//
// (20 * (6+5+2))+1) unicode characters from EFI FAT spec (doubled for bytes)
//
-#define MAX_FILE_NAME_SIZE 522
-#define MAX_FILE_NAME_LEN (MAX_FILE_NAME_SIZE / sizeof(CHAR16))
-#define MAX_FILE_INFO_LEN (OFFSET_OF(EFI_FILE_INFO, FileName) + MAX_FILE_NAME_LEN)
+#define MAX_FILE_NAME_SIZE 522
+#define MAX_FILE_NAME_LEN (MAX_FILE_NAME_SIZE / sizeof(CHAR16))
+#define MAX_FILE_INFO_LEN (OFFSET_OF(EFI_FILE_INFO, FileName) + MAX_FILE_NAME_LEN)
typedef struct {
- UINTN Signature;
- LIST_ENTRY Link; /// Linked list members.
- EFI_FILE_INFO *FileInfo; /// Pointer to the FileInfo struct for this file or NULL.
- CHAR16 *FileNameFirstPart; /// Text to the left of right-most period in the file name. String is capitialized
- CHAR16 *FileNameSecondPart; /// Text to the right of right-most period in the file name.String is capitialized. Maybe NULL
+ UINTN Signature;
+ LIST_ENTRY Link; /// Linked list members.
+ EFI_FILE_INFO *FileInfo; /// Pointer to the FileInfo struct for this file or NULL.
+ CHAR16 *FileNameFirstPart; /// Text to the left of right-most period in the file name. String is capitialized
+ CHAR16 *FileNameSecondPart; /// Text to the right of right-most period in the file name.String is capitialized. Maybe NULL
} FILE_INFO_ENTRY;
typedef struct {
diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c index 395311b2bf..197af267af 100644 --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.c @@ -41,11 +41,11 @@ #include <Protocol/FirmwareManagementProgress.h>
#include <Protocol/DevicePath.h>
-EFI_SYSTEM_RESOURCE_TABLE *mEsrtTable = NULL;
-BOOLEAN mIsVirtualAddrConverted = FALSE;
+EFI_SYSTEM_RESOURCE_TABLE *mEsrtTable = NULL;
+BOOLEAN mIsVirtualAddrConverted = FALSE;
-BOOLEAN mDxeCapsuleLibEndOfDxe = FALSE;
-EFI_EVENT mDxeCapsuleLibEndOfDxeEvent = NULL;
+BOOLEAN mDxeCapsuleLibEndOfDxe = FALSE;
+EFI_EVENT mDxeCapsuleLibEndOfDxeEvent = NULL;
EDKII_FIRMWARE_MANAGEMENT_PROGRESS_PROTOCOL *mFmpProgress = NULL;
@@ -68,8 +68,8 @@ InitCapsuleVariable ( **/
EFI_STATUS
RecordCapsuleStatusVariable (
- IN EFI_CAPSULE_HEADER *CapsuleHeader,
- IN EFI_STATUS CapsuleStatus
+ IN EFI_CAPSULE_HEADER *CapsuleHeader,
+ IN EFI_STATUS CapsuleStatus
);
/**
@@ -121,7 +121,7 @@ UpdateImageProgress ( **/
BOOLEAN
IsCapsuleNameCapsule (
- IN EFI_CAPSULE_HEADER *CapsuleHeader
+ IN EFI_CAPSULE_HEADER *CapsuleHeader
)
{
return CompareGuid (&CapsuleHeader->CapsuleGuid, &gEdkiiCapsuleOnDiskNameGuid);
@@ -140,7 +140,7 @@ IsFmpCapsuleGuid ( IN EFI_GUID *CapsuleGuid
)
{
- if (CompareGuid(&gEfiFmpCapsuleGuid, CapsuleGuid)) {
+ if (CompareGuid (&gEfiFmpCapsuleGuid, CapsuleGuid)) {
return TRUE;
}
@@ -170,9 +170,11 @@ IsValidCapsuleHeader ( if (CapsuleHeader->CapsuleImageSize != CapsuleSize) {
return FALSE;
}
+
if (CapsuleHeader->HeaderSize >= CapsuleHeader->CapsuleImageSize) {
return FALSE;
}
+
return TRUE;
}
@@ -202,68 +204,72 @@ ValidateFmpCapsule ( OUT UINT16 *EmbeddedDriverCount OPTIONAL
)
{
- EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER *FmpCapsuleHeader;
- UINT8 *EndOfCapsule;
- EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER *ImageHeader;
- UINT8 *EndOfPayload;
- UINT64 *ItemOffsetList;
- UINT32 ItemNum;
- UINTN Index;
- UINTN FmpCapsuleSize;
- UINTN FmpCapsuleHeaderSize;
- UINT64 FmpImageSize;
- UINTN FmpImageHeaderSize;
-
- if (!IsFmpCapsuleGuid(&CapsuleHeader->CapsuleGuid)) {
+ EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER *FmpCapsuleHeader;
+ UINT8 *EndOfCapsule;
+ EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER *ImageHeader;
+ UINT8 *EndOfPayload;
+ UINT64 *ItemOffsetList;
+ UINT32 ItemNum;
+ UINTN Index;
+ UINTN FmpCapsuleSize;
+ UINTN FmpCapsuleHeaderSize;
+ UINT64 FmpImageSize;
+ UINTN FmpImageHeaderSize;
+
+ if (!IsFmpCapsuleGuid (&CapsuleHeader->CapsuleGuid)) {
return ValidateFmpCapsule ((EFI_CAPSULE_HEADER *)((UINTN)CapsuleHeader + CapsuleHeader->HeaderSize), EmbeddedDriverCount);
}
if (CapsuleHeader->HeaderSize >= CapsuleHeader->CapsuleImageSize) {
- DEBUG((DEBUG_ERROR, "HeaderSize(0x%x) >= CapsuleImageSize(0x%x)\n", CapsuleHeader->HeaderSize, CapsuleHeader->CapsuleImageSize));
+ DEBUG ((DEBUG_ERROR, "HeaderSize(0x%x) >= CapsuleImageSize(0x%x)\n", CapsuleHeader->HeaderSize, CapsuleHeader->CapsuleImageSize));
return EFI_INVALID_PARAMETER;
}
- FmpCapsuleHeader = (EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER *) ((UINT8 *) CapsuleHeader + CapsuleHeader->HeaderSize);
- EndOfCapsule = (UINT8 *) CapsuleHeader + CapsuleHeader->CapsuleImageSize;
+ FmpCapsuleHeader = (EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER *)((UINT8 *)CapsuleHeader + CapsuleHeader->HeaderSize);
+ EndOfCapsule = (UINT8 *)CapsuleHeader + CapsuleHeader->CapsuleImageSize;
FmpCapsuleSize = (UINTN)EndOfCapsule - (UINTN)FmpCapsuleHeader;
- if (FmpCapsuleSize < sizeof(EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER)) {
- DEBUG((DEBUG_ERROR, "FmpCapsuleSize(0x%x) < EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER\n", FmpCapsuleSize));
+ if (FmpCapsuleSize < sizeof (EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER)) {
+ DEBUG ((DEBUG_ERROR, "FmpCapsuleSize(0x%x) < EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER\n", FmpCapsuleSize));
return EFI_INVALID_PARAMETER;
}
// Check EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER
if (FmpCapsuleHeader->Version != EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER_INIT_VERSION) {
- DEBUG((DEBUG_ERROR, "FmpCapsuleHeader->Version(0x%x) != EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER_INIT_VERSION\n", FmpCapsuleHeader->Version));
+ DEBUG ((DEBUG_ERROR, "FmpCapsuleHeader->Version(0x%x) != EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER_INIT_VERSION\n", FmpCapsuleHeader->Version));
return EFI_INVALID_PARAMETER;
}
+
ItemOffsetList = (UINT64 *)(FmpCapsuleHeader + 1);
// No overflow
ItemNum = FmpCapsuleHeader->EmbeddedDriverCount + FmpCapsuleHeader->PayloadItemCount;
- if ((FmpCapsuleSize - sizeof(EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER))/sizeof(UINT64) < ItemNum) {
- DEBUG((DEBUG_ERROR, "ItemNum(0x%x) too big\n", ItemNum));
+ if ((FmpCapsuleSize - sizeof (EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER))/sizeof (UINT64) < ItemNum) {
+ DEBUG ((DEBUG_ERROR, "ItemNum(0x%x) too big\n", ItemNum));
return EFI_INVALID_PARAMETER;
}
- FmpCapsuleHeaderSize = sizeof(EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER) + sizeof(UINT64)*ItemNum;
+
+ FmpCapsuleHeaderSize = sizeof (EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER) + sizeof (UINT64)*ItemNum;
// Check ItemOffsetList
for (Index = 0; Index < ItemNum; Index++) {
if (ItemOffsetList[Index] >= FmpCapsuleSize) {
- DEBUG((DEBUG_ERROR, "ItemOffsetList[%d](0x%lx) >= FmpCapsuleSize(0x%x)\n", Index, ItemOffsetList[Index], FmpCapsuleSize));
+ DEBUG ((DEBUG_ERROR, "ItemOffsetList[%d](0x%lx) >= FmpCapsuleSize(0x%x)\n", Index, ItemOffsetList[Index], FmpCapsuleSize));
return EFI_INVALID_PARAMETER;
}
+
if (ItemOffsetList[Index] < FmpCapsuleHeaderSize) {
- DEBUG((DEBUG_ERROR, "ItemOffsetList[%d](0x%lx) < FmpCapsuleHeaderSize(0x%x)\n", Index, ItemOffsetList[Index], FmpCapsuleHeaderSize));
+ DEBUG ((DEBUG_ERROR, "ItemOffsetList[%d](0x%lx) < FmpCapsuleHeaderSize(0x%x)\n", Index, ItemOffsetList[Index], FmpCapsuleHeaderSize));
return EFI_INVALID_PARAMETER;
}
+
//
// All the address in ItemOffsetList must be stored in ascending order
//
if (Index > 0) {
if (ItemOffsetList[Index] <= ItemOffsetList[Index - 1]) {
- DEBUG((DEBUG_ERROR, "ItemOffsetList[%d](0x%lx) < ItemOffsetList[%d](0x%x)\n", Index, ItemOffsetList[Index], Index - 1, ItemOffsetList[Index - 1]));
+ DEBUG ((DEBUG_ERROR, "ItemOffsetList[%d](0x%lx) < ItemOffsetList[%d](0x%x)\n", Index, ItemOffsetList[Index], Index - 1, ItemOffsetList[Index - 1]));
return EFI_INVALID_PARAMETER;
}
}
@@ -271,33 +277,37 @@ ValidateFmpCapsule ( // Check EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER
for (Index = FmpCapsuleHeader->EmbeddedDriverCount; Index < ItemNum; Index++) {
- ImageHeader = (EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER *)((UINT8 *)FmpCapsuleHeader + ItemOffsetList[Index]);
+ ImageHeader = (EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER *)((UINT8 *)FmpCapsuleHeader + ItemOffsetList[Index]);
if (Index == ItemNum - 1) {
EndOfPayload = (UINT8 *)((UINTN)EndOfCapsule - (UINTN)FmpCapsuleHeader);
} else {
EndOfPayload = (UINT8 *)(UINTN)ItemOffsetList[Index+1];
}
+
FmpImageSize = (UINTN)EndOfPayload - ItemOffsetList[Index];
- FmpImageHeaderSize = sizeof(EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER);
+ FmpImageHeaderSize = sizeof (EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER);
if ((ImageHeader->Version > EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER_INIT_VERSION) ||
- (ImageHeader->Version < 1)) {
- DEBUG((DEBUG_ERROR, "ImageHeader->Version(0x%x) Unknown\n", ImageHeader->Version));
+ (ImageHeader->Version < 1))
+ {
+ DEBUG ((DEBUG_ERROR, "ImageHeader->Version(0x%x) Unknown\n", ImageHeader->Version));
return EFI_INVALID_PARAMETER;
}
+
if (ImageHeader->Version == 1) {
- FmpImageHeaderSize = OFFSET_OF(EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER, UpdateHardwareInstance);
+ FmpImageHeaderSize = OFFSET_OF (EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER, UpdateHardwareInstance);
} else if (ImageHeader->Version == 2) {
- FmpImageHeaderSize = OFFSET_OF(EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER, ImageCapsuleSupport);
+ FmpImageHeaderSize = OFFSET_OF (EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER, ImageCapsuleSupport);
}
+
if (FmpImageSize < FmpImageHeaderSize) {
- DEBUG((DEBUG_ERROR, "FmpImageSize(0x%lx) < FmpImageHeaderSize(0x%x)\n", FmpImageSize, FmpImageHeaderSize));
+ DEBUG ((DEBUG_ERROR, "FmpImageSize(0x%lx) < FmpImageHeaderSize(0x%x)\n", FmpImageSize, FmpImageHeaderSize));
return EFI_INVALID_PARAMETER;
}
// No overflow
if (FmpImageSize != (UINT64)FmpImageHeaderSize + (UINT64)ImageHeader->UpdateImageSize + (UINT64)ImageHeader->UpdateVendorCodeSize) {
- DEBUG((DEBUG_ERROR, "FmpImageSize(0x%lx) mismatch, UpdateImageSize(0x%x) UpdateVendorCodeSize(0x%x)\n", FmpImageSize, ImageHeader->UpdateImageSize, ImageHeader->UpdateVendorCodeSize));
+ DEBUG ((DEBUG_ERROR, "FmpImageSize(0x%lx) mismatch, UpdateImageSize(0x%x) UpdateVendorCodeSize(0x%x)\n", FmpImageSize, ImageHeader->UpdateImageSize, ImageHeader->UpdateVendorCodeSize));
return EFI_INVALID_PARAMETER;
}
}
@@ -308,9 +318,10 @@ ValidateFmpCapsule ( //
EndOfPayload = (UINT8 *)(FmpCapsuleHeader + 1);
if (EndOfPayload != EndOfCapsule) {
- DEBUG((DEBUG_ERROR, "EndOfPayload(0x%x) mismatch, EndOfCapsule(0x%x)\n", EndOfPayload, EndOfCapsule));
+ DEBUG ((DEBUG_ERROR, "EndOfPayload(0x%x) mismatch, EndOfCapsule(0x%x)\n", EndOfPayload, EndOfCapsule));
return EFI_INVALID_PARAMETER;
}
+
return EFI_UNSUPPORTED;
}
@@ -336,14 +347,14 @@ DisplayCapsuleImage ( IN EFI_CAPSULE_HEADER *CapsuleHeader
)
{
- DISPLAY_DISPLAY_PAYLOAD *ImagePayload;
- UINTN PayloadSize;
- EFI_STATUS Status;
- EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Blt;
- UINTN BltSize;
- UINTN Height;
- UINTN Width;
- EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
+ DISPLAY_DISPLAY_PAYLOAD *ImagePayload;
+ UINTN PayloadSize;
+ EFI_STATUS Status;
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Blt;
+ UINTN BltSize;
+ UINTN Height;
+ UINTN Width;
+ EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
//
// UX capsule doesn't have extended header entries.
@@ -351,7 +362,8 @@ DisplayCapsuleImage ( if (CapsuleHeader->HeaderSize != sizeof (EFI_CAPSULE_HEADER)) {
return EFI_UNSUPPORTED;
}
- ImagePayload = (DISPLAY_DISPLAY_PAYLOAD *)((UINTN) CapsuleHeader + CapsuleHeader->HeaderSize);
+
+ ImagePayload = (DISPLAY_DISPLAY_PAYLOAD *)((UINTN)CapsuleHeader + CapsuleHeader->HeaderSize);
//
// (CapsuleImageSize > HeaderSize) is guaranteed by IsValidCapsuleHeader().
//
@@ -368,9 +380,11 @@ DisplayCapsuleImage ( if (ImagePayload->Version != 1) {
return EFI_UNSUPPORTED;
}
- if (CalculateCheckSum8((UINT8 *)CapsuleHeader, CapsuleHeader->CapsuleImageSize) != 0) {
+
+ if (CalculateCheckSum8 ((UINT8 *)CapsuleHeader, CapsuleHeader->CapsuleImageSize) != 0) {
return EFI_UNSUPPORTED;
}
+
//
// Only Support Bitmap by now
//
@@ -383,8 +397,8 @@ DisplayCapsuleImage ( //
Status = gBS->HandleProtocol (gST->ConsoleOutHandle, &gEfiGraphicsOutputProtocolGuid, (VOID **)&GraphicsOutput);
if (EFI_ERROR (Status)) {
- Status = gBS->LocateProtocol(&gEfiGraphicsOutputProtocolGuid, NULL, (VOID **)&GraphicsOutput);
- if (EFI_ERROR(Status)) {
+ Status = gBS->LocateProtocol (&gEfiGraphicsOutputProtocolGuid, NULL, (VOID **)&GraphicsOutput);
+ if (EFI_ERROR (Status)) {
return EFI_UNSUPPORTED;
}
}
@@ -393,12 +407,12 @@ DisplayCapsuleImage ( return EFI_UNSUPPORTED;
}
- Blt = NULL;
- Width = 0;
+ Blt = NULL;
+ Width = 0;
Height = 0;
Status = TranslateBmpToGopBlt (
ImagePayload + 1,
- PayloadSize - sizeof(DISPLAY_DISPLAY_PAYLOAD),
+ PayloadSize - sizeof (DISPLAY_DISPLAY_PAYLOAD),
&Blt,
&BltSize,
&Height,
@@ -415,14 +429,14 @@ DisplayCapsuleImage ( EfiBltBufferToVideo,
0,
0,
- (UINTN) ImagePayload->OffsetX,
- (UINTN) ImagePayload->OffsetY,
+ (UINTN)ImagePayload->OffsetX,
+ (UINTN)ImagePayload->OffsetY,
Width,
Height,
Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)
);
- FreePool(Blt);
+ FreePool (Blt);
return Status;
}
@@ -440,44 +454,45 @@ DisplayCapsuleImage ( **/
VOID
DumpFmpImageInfo (
- IN UINTN ImageInfoSize,
- IN EFI_FIRMWARE_IMAGE_DESCRIPTOR *ImageInfo,
- IN UINT32 DescriptorVersion,
- IN UINT8 DescriptorCount,
- IN UINTN DescriptorSize,
- IN UINT32 PackageVersion,
- IN CHAR16 *PackageVersionName
+ IN UINTN ImageInfoSize,
+ IN EFI_FIRMWARE_IMAGE_DESCRIPTOR *ImageInfo,
+ IN UINT32 DescriptorVersion,
+ IN UINT8 DescriptorCount,
+ IN UINTN DescriptorSize,
+ IN UINT32 PackageVersion,
+ IN CHAR16 *PackageVersionName
)
{
- EFI_FIRMWARE_IMAGE_DESCRIPTOR *CurrentImageInfo;
- UINTN Index;
-
- DEBUG((DEBUG_VERBOSE, " DescriptorVersion - 0x%x\n", DescriptorVersion));
- DEBUG((DEBUG_VERBOSE, " DescriptorCount - 0x%x\n", DescriptorCount));
- DEBUG((DEBUG_VERBOSE, " DescriptorSize - 0x%x\n", DescriptorSize));
- DEBUG((DEBUG_VERBOSE, " PackageVersion - 0x%x\n", PackageVersion));
- DEBUG((DEBUG_VERBOSE, " PackageVersionName - %s\n\n", PackageVersionName));
+ EFI_FIRMWARE_IMAGE_DESCRIPTOR *CurrentImageInfo;
+ UINTN Index;
+
+ DEBUG ((DEBUG_VERBOSE, " DescriptorVersion - 0x%x\n", DescriptorVersion));
+ DEBUG ((DEBUG_VERBOSE, " DescriptorCount - 0x%x\n", DescriptorCount));
+ DEBUG ((DEBUG_VERBOSE, " DescriptorSize - 0x%x\n", DescriptorSize));
+ DEBUG ((DEBUG_VERBOSE, " PackageVersion - 0x%x\n", PackageVersion));
+ DEBUG ((DEBUG_VERBOSE, " PackageVersionName - %s\n\n", PackageVersionName));
CurrentImageInfo = ImageInfo;
for (Index = 0; Index < DescriptorCount; Index++) {
- DEBUG((DEBUG_VERBOSE, " ImageDescriptor (%d)\n", Index));
- DEBUG((DEBUG_VERBOSE, " ImageIndex - 0x%x\n", CurrentImageInfo->ImageIndex));
- DEBUG((DEBUG_VERBOSE, " ImageTypeId - %g\n", &CurrentImageInfo->ImageTypeId));
- DEBUG((DEBUG_VERBOSE, " ImageId - 0x%lx\n", CurrentImageInfo->ImageId));
- DEBUG((DEBUG_VERBOSE, " ImageIdName - %s\n", CurrentImageInfo->ImageIdName));
- DEBUG((DEBUG_VERBOSE, " Version - 0x%x\n", CurrentImageInfo->Version));
- DEBUG((DEBUG_VERBOSE, " VersionName - %s\n", CurrentImageInfo->VersionName));
- DEBUG((DEBUG_VERBOSE, " Size - 0x%x\n", CurrentImageInfo->Size));
- DEBUG((DEBUG_VERBOSE, " AttributesSupported - 0x%lx\n", CurrentImageInfo->AttributesSupported));
- DEBUG((DEBUG_VERBOSE, " AttributesSetting - 0x%lx\n", CurrentImageInfo->AttributesSetting));
- DEBUG((DEBUG_VERBOSE, " Compatibilities - 0x%lx\n", CurrentImageInfo->Compatibilities));
+ DEBUG ((DEBUG_VERBOSE, " ImageDescriptor (%d)\n", Index));
+ DEBUG ((DEBUG_VERBOSE, " ImageIndex - 0x%x\n", CurrentImageInfo->ImageIndex));
+ DEBUG ((DEBUG_VERBOSE, " ImageTypeId - %g\n", &CurrentImageInfo->ImageTypeId));
+ DEBUG ((DEBUG_VERBOSE, " ImageId - 0x%lx\n", CurrentImageInfo->ImageId));
+ DEBUG ((DEBUG_VERBOSE, " ImageIdName - %s\n", CurrentImageInfo->ImageIdName));
+ DEBUG ((DEBUG_VERBOSE, " Version - 0x%x\n", CurrentImageInfo->Version));
+ DEBUG ((DEBUG_VERBOSE, " VersionName - %s\n", CurrentImageInfo->VersionName));
+ DEBUG ((DEBUG_VERBOSE, " Size - 0x%x\n", CurrentImageInfo->Size));
+ DEBUG ((DEBUG_VERBOSE, " AttributesSupported - 0x%lx\n", CurrentImageInfo->AttributesSupported));
+ DEBUG ((DEBUG_VERBOSE, " AttributesSetting - 0x%lx\n", CurrentImageInfo->AttributesSetting));
+ DEBUG ((DEBUG_VERBOSE, " Compatibilities - 0x%lx\n", CurrentImageInfo->Compatibilities));
if (DescriptorVersion > 1) {
- DEBUG((DEBUG_VERBOSE, " LowestSupportedImageVersion - 0x%x\n", CurrentImageInfo->LowestSupportedImageVersion));
+ DEBUG ((DEBUG_VERBOSE, " LowestSupportedImageVersion - 0x%x\n", CurrentImageInfo->LowestSupportedImageVersion));
if (DescriptorVersion > 2) {
- DEBUG((DEBUG_VERBOSE, " LastAttemptVersion - 0x%x\n", CurrentImageInfo->LastAttemptVersion));
- DEBUG((DEBUG_VERBOSE, " LastAttemptStatus - 0x%x\n", CurrentImageInfo->LastAttemptStatus));
- DEBUG((DEBUG_VERBOSE, " HardwareInstance - 0x%lx\n", CurrentImageInfo->HardwareInstance));
+ DEBUG ((DEBUG_VERBOSE, " LastAttemptVersion - 0x%x\n", CurrentImageInfo->LastAttemptVersion));
+ DEBUG ((DEBUG_VERBOSE, " LastAttemptStatus - 0x%x\n", CurrentImageInfo->LastAttemptStatus));
+ DEBUG ((DEBUG_VERBOSE, " HardwareInstance - 0x%lx\n", CurrentImageInfo->HardwareInstance));
}
}
+
//
// Use DescriptorSize to move ImageInfo Pointer to stay compatible with different ImageInfo version
//
@@ -492,7 +507,7 @@ DumpFmpImageInfo ( **/
VOID
DumpFmpCapsule (
- IN EFI_CAPSULE_HEADER *CapsuleHeader
+ IN EFI_CAPSULE_HEADER *CapsuleHeader
)
{
EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER *FmpCapsuleHeader;
@@ -502,29 +517,30 @@ DumpFmpCapsule ( FmpCapsuleHeader = (EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER *)((UINT8 *)CapsuleHeader + CapsuleHeader->HeaderSize);
- DEBUG((DEBUG_VERBOSE, "FmpCapsule:\n"));
- DEBUG((DEBUG_VERBOSE, " Version - 0x%x\n", FmpCapsuleHeader->Version));
- DEBUG((DEBUG_VERBOSE, " EmbeddedDriverCount - 0x%x\n", FmpCapsuleHeader->EmbeddedDriverCount));
- DEBUG((DEBUG_VERBOSE, " PayloadItemCount - 0x%x\n", FmpCapsuleHeader->PayloadItemCount));
+ DEBUG ((DEBUG_VERBOSE, "FmpCapsule:\n"));
+ DEBUG ((DEBUG_VERBOSE, " Version - 0x%x\n", FmpCapsuleHeader->Version));
+ DEBUG ((DEBUG_VERBOSE, " EmbeddedDriverCount - 0x%x\n", FmpCapsuleHeader->EmbeddedDriverCount));
+ DEBUG ((DEBUG_VERBOSE, " PayloadItemCount - 0x%x\n", FmpCapsuleHeader->PayloadItemCount));
ItemOffsetList = (UINT64 *)(FmpCapsuleHeader + 1);
for (Index = 0; Index < FmpCapsuleHeader->EmbeddedDriverCount; Index++) {
- DEBUG((DEBUG_VERBOSE, " ItemOffsetList[%d] - 0x%lx\n", Index, ItemOffsetList[Index]));
+ DEBUG ((DEBUG_VERBOSE, " ItemOffsetList[%d] - 0x%lx\n", Index, ItemOffsetList[Index]));
}
- for (; Index < (UINT32)FmpCapsuleHeader->EmbeddedDriverCount + FmpCapsuleHeader->PayloadItemCount; Index++) {
- DEBUG((DEBUG_VERBOSE, " ItemOffsetList[%d] - 0x%lx\n", Index, ItemOffsetList[Index]));
+
+ for ( ; Index < (UINT32)FmpCapsuleHeader->EmbeddedDriverCount + FmpCapsuleHeader->PayloadItemCount; Index++) {
+ DEBUG ((DEBUG_VERBOSE, " ItemOffsetList[%d] - 0x%lx\n", Index, ItemOffsetList[Index]));
ImageHeader = (EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER *)((UINT8 *)FmpCapsuleHeader + ItemOffsetList[Index]);
- DEBUG((DEBUG_VERBOSE, " ImageHeader:\n"));
- DEBUG((DEBUG_VERBOSE, " Version - 0x%x\n", ImageHeader->Version));
- DEBUG((DEBUG_VERBOSE, " UpdateImageTypeId - %g\n", &ImageHeader->UpdateImageTypeId));
- DEBUG((DEBUG_VERBOSE, " UpdateImageIndex - 0x%x\n", ImageHeader->UpdateImageIndex));
- DEBUG((DEBUG_VERBOSE, " UpdateImageSize - 0x%x\n", ImageHeader->UpdateImageSize));
- DEBUG((DEBUG_VERBOSE, " UpdateVendorCodeSize - 0x%x\n", ImageHeader->UpdateVendorCodeSize));
+ DEBUG ((DEBUG_VERBOSE, " ImageHeader:\n"));
+ DEBUG ((DEBUG_VERBOSE, " Version - 0x%x\n", ImageHeader->Version));
+ DEBUG ((DEBUG_VERBOSE, " UpdateImageTypeId - %g\n", &ImageHeader->UpdateImageTypeId));
+ DEBUG ((DEBUG_VERBOSE, " UpdateImageIndex - 0x%x\n", ImageHeader->UpdateImageIndex));
+ DEBUG ((DEBUG_VERBOSE, " UpdateImageSize - 0x%x\n", ImageHeader->UpdateImageSize));
+ DEBUG ((DEBUG_VERBOSE, " UpdateVendorCodeSize - 0x%x\n", ImageHeader->UpdateVendorCodeSize));
if (ImageHeader->Version >= 2) {
- DEBUG((DEBUG_VERBOSE, " UpdateHardwareInstance - 0x%lx\n", ImageHeader->UpdateHardwareInstance));
+ DEBUG ((DEBUG_VERBOSE, " UpdateHardwareInstance - 0x%lx\n", ImageHeader->UpdateHardwareInstance));
if (ImageHeader->Version >= EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER_INIT_VERSION) {
- DEBUG((DEBUG_VERBOSE, " ImageCapsuleSupport - 0x%lx\n", ImageHeader->ImageCapsuleSupport));
+ DEBUG ((DEBUG_VERBOSE, " ImageCapsuleSupport - 0x%lx\n", ImageHeader->ImageCapsuleSupport));
}
}
}
@@ -538,18 +554,18 @@ DumpAllFmpInfo ( VOID
)
{
- EFI_STATUS Status;
- EFI_HANDLE *HandleBuffer;
- UINTN NumberOfHandles;
- EFI_FIRMWARE_MANAGEMENT_PROTOCOL *Fmp;
- UINTN Index;
- UINTN ImageInfoSize;
- EFI_FIRMWARE_IMAGE_DESCRIPTOR *FmpImageInfoBuf;
- UINT32 FmpImageInfoDescriptorVer;
- UINT8 FmpImageInfoCount;
- UINTN DescriptorSize;
- UINT32 PackageVersion;
- CHAR16 *PackageVersionName;
+ EFI_STATUS Status;
+ EFI_HANDLE *HandleBuffer;
+ UINTN NumberOfHandles;
+ EFI_FIRMWARE_MANAGEMENT_PROTOCOL *Fmp;
+ UINTN Index;
+ UINTN ImageInfoSize;
+ EFI_FIRMWARE_IMAGE_DESCRIPTOR *FmpImageInfoBuf;
+ UINT32 FmpImageInfoDescriptorVer;
+ UINT8 FmpImageInfoCount;
+ UINTN DescriptorSize;
+ UINT32 PackageVersion;
+ CHAR16 *PackageVersionName;
Status = gBS->LocateHandleBuffer (
ByProtocol,
@@ -558,31 +574,31 @@ DumpAllFmpInfo ( &NumberOfHandles,
&HandleBuffer
);
- if (EFI_ERROR(Status)) {
- return ;
+ if (EFI_ERROR (Status)) {
+ return;
}
for (Index = 0; Index < NumberOfHandles; Index++) {
- Status = gBS->HandleProtocol(
+ Status = gBS->HandleProtocol (
HandleBuffer[Index],
&gEfiFirmwareManagementProtocolGuid,
(VOID **)&Fmp
);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
continue;
}
ImageInfoSize = 0;
- Status = Fmp->GetImageInfo (
- Fmp,
- &ImageInfoSize,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL
- );
+ Status = Fmp->GetImageInfo (
+ Fmp,
+ &ImageInfoSize,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+ );
if (Status != EFI_BUFFER_TOO_SMALL) {
continue;
}
@@ -593,23 +609,23 @@ DumpAllFmpInfo ( }
PackageVersionName = NULL;
- Status = Fmp->GetImageInfo (
- Fmp,
- &ImageInfoSize, // ImageInfoSize
- FmpImageInfoBuf, // ImageInfo
- &FmpImageInfoDescriptorVer, // DescriptorVersion
- &FmpImageInfoCount, // DescriptorCount
- &DescriptorSize, // DescriptorSize
- &PackageVersion, // PackageVersion
- &PackageVersionName // PackageVersionName
- );
- if (EFI_ERROR(Status)) {
- FreePool(FmpImageInfoBuf);
+ Status = Fmp->GetImageInfo (
+ Fmp,
+ &ImageInfoSize, // ImageInfoSize
+ FmpImageInfoBuf, // ImageInfo
+ &FmpImageInfoDescriptorVer, // DescriptorVersion
+ &FmpImageInfoCount, // DescriptorCount
+ &DescriptorSize, // DescriptorSize
+ &PackageVersion, // PackageVersion
+ &PackageVersionName // PackageVersionName
+ );
+ if (EFI_ERROR (Status)) {
+ FreePool (FmpImageInfoBuf);
continue;
}
- DEBUG((DEBUG_INFO, "FMP (%d) ImageInfo:\n", Index));
- DumpFmpImageInfo(
+ DEBUG ((DEBUG_INFO, "FMP (%d) ImageInfo:\n", Index));
+ DumpFmpImageInfo (
ImageInfoSize, // ImageInfoSize
FmpImageInfoBuf, // ImageInfo
FmpImageInfoDescriptorVer, // DescriptorVersion
@@ -620,15 +636,15 @@ DumpAllFmpInfo ( );
if (PackageVersionName != NULL) {
- FreePool(PackageVersionName);
+ FreePool (PackageVersionName);
}
- FreePool(FmpImageInfoBuf);
+ FreePool (FmpImageInfoBuf);
}
FreePool (HandleBuffer);
- return ;
+ return;
}
/**
@@ -649,37 +665,39 @@ DumpAllFmpInfo ( **/
EFI_STATUS
GetFmpHandleBufferByType (
- IN EFI_GUID *UpdateImageTypeId,
- IN UINT64 UpdateHardwareInstance,
- OUT UINTN *NoHandles OPTIONAL,
- OUT EFI_HANDLE **HandleBuf OPTIONAL,
- OUT BOOLEAN **ResetRequiredBuf OPTIONAL
+ IN EFI_GUID *UpdateImageTypeId,
+ IN UINT64 UpdateHardwareInstance,
+ OUT UINTN *NoHandles OPTIONAL,
+ OUT EFI_HANDLE **HandleBuf OPTIONAL,
+ OUT BOOLEAN **ResetRequiredBuf OPTIONAL
)
{
- EFI_STATUS Status;
- EFI_HANDLE *HandleBuffer;
- UINTN NumberOfHandles;
- EFI_HANDLE *MatchedHandleBuffer;
- BOOLEAN *MatchedResetRequiredBuffer;
- UINTN MatchedNumberOfHandles;
- EFI_FIRMWARE_MANAGEMENT_PROTOCOL *Fmp;
- UINTN Index;
- UINTN ImageInfoSize;
- EFI_FIRMWARE_IMAGE_DESCRIPTOR *FmpImageInfoBuf;
- UINT32 FmpImageInfoDescriptorVer;
- UINT8 FmpImageInfoCount;
- UINTN DescriptorSize;
- UINT32 PackageVersion;
- CHAR16 *PackageVersionName;
- UINTN Index2;
- EFI_FIRMWARE_IMAGE_DESCRIPTOR *TempFmpImageInfo;
+ EFI_STATUS Status;
+ EFI_HANDLE *HandleBuffer;
+ UINTN NumberOfHandles;
+ EFI_HANDLE *MatchedHandleBuffer;
+ BOOLEAN *MatchedResetRequiredBuffer;
+ UINTN MatchedNumberOfHandles;
+ EFI_FIRMWARE_MANAGEMENT_PROTOCOL *Fmp;
+ UINTN Index;
+ UINTN ImageInfoSize;
+ EFI_FIRMWARE_IMAGE_DESCRIPTOR *FmpImageInfoBuf;
+ UINT32 FmpImageInfoDescriptorVer;
+ UINT8 FmpImageInfoCount;
+ UINTN DescriptorSize;
+ UINT32 PackageVersion;
+ CHAR16 *PackageVersionName;
+ UINTN Index2;
+ EFI_FIRMWARE_IMAGE_DESCRIPTOR *TempFmpImageInfo;
if (NoHandles != NULL) {
*NoHandles = 0;
}
+
if (HandleBuf != NULL) {
*HandleBuf = NULL;
}
+
if (ResetRequiredBuf != NULL) {
*ResetRequiredBuf = NULL;
}
@@ -691,7 +709,7 @@ GetFmpHandleBufferByType ( &NumberOfHandles,
&HandleBuffer
);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
return Status;
}
@@ -699,7 +717,7 @@ GetFmpHandleBufferByType ( MatchedHandleBuffer = NULL;
if (HandleBuf != NULL) {
- MatchedHandleBuffer = AllocateZeroPool (sizeof(EFI_HANDLE) * NumberOfHandles);
+ MatchedHandleBuffer = AllocateZeroPool (sizeof (EFI_HANDLE) * NumberOfHandles);
if (MatchedHandleBuffer == NULL) {
FreePool (HandleBuffer);
return EFI_OUT_OF_RESOURCES;
@@ -708,37 +726,38 @@ GetFmpHandleBufferByType ( MatchedResetRequiredBuffer = NULL;
if (ResetRequiredBuf != NULL) {
- MatchedResetRequiredBuffer = AllocateZeroPool (sizeof(BOOLEAN) * NumberOfHandles);
+ MatchedResetRequiredBuffer = AllocateZeroPool (sizeof (BOOLEAN) * NumberOfHandles);
if (MatchedResetRequiredBuffer == NULL) {
if (MatchedHandleBuffer != NULL) {
FreePool (MatchedHandleBuffer);
}
+
FreePool (HandleBuffer);
return EFI_OUT_OF_RESOURCES;
}
}
for (Index = 0; Index < NumberOfHandles; Index++) {
- Status = gBS->HandleProtocol(
+ Status = gBS->HandleProtocol (
HandleBuffer[Index],
&gEfiFirmwareManagementProtocolGuid,
(VOID **)&Fmp
);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
continue;
}
ImageInfoSize = 0;
- Status = Fmp->GetImageInfo (
- Fmp,
- &ImageInfoSize,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL
- );
+ Status = Fmp->GetImageInfo (
+ Fmp,
+ &ImageInfoSize,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+ );
if (Status != EFI_BUFFER_TOO_SMALL) {
continue;
}
@@ -749,23 +768,23 @@ GetFmpHandleBufferByType ( }
PackageVersionName = NULL;
- Status = Fmp->GetImageInfo (
- Fmp,
- &ImageInfoSize, // ImageInfoSize
- FmpImageInfoBuf, // ImageInfo
- &FmpImageInfoDescriptorVer, // DescriptorVersion
- &FmpImageInfoCount, // DescriptorCount
- &DescriptorSize, // DescriptorSize
- &PackageVersion, // PackageVersion
- &PackageVersionName // PackageVersionName
- );
- if (EFI_ERROR(Status)) {
- FreePool(FmpImageInfoBuf);
+ Status = Fmp->GetImageInfo (
+ Fmp,
+ &ImageInfoSize, // ImageInfoSize
+ FmpImageInfoBuf, // ImageInfo
+ &FmpImageInfoDescriptorVer, // DescriptorVersion
+ &FmpImageInfoCount, // DescriptorCount
+ &DescriptorSize, // DescriptorSize
+ &PackageVersion, // PackageVersion
+ &PackageVersionName // PackageVersionName
+ );
+ if (EFI_ERROR (Status)) {
+ FreePool (FmpImageInfoBuf);
continue;
}
if (PackageVersionName != NULL) {
- FreePool(PackageVersionName);
+ FreePool (PackageVersionName);
}
TempFmpImageInfo = FmpImageInfoBuf;
@@ -773,26 +792,31 @@ GetFmpHandleBufferByType ( //
// Check if this FMP instance matches
//
- if (CompareGuid(UpdateImageTypeId, &TempFmpImageInfo->ImageTypeId)) {
+ if (CompareGuid (UpdateImageTypeId, &TempFmpImageInfo->ImageTypeId)) {
if ((UpdateHardwareInstance == 0) ||
((FmpImageInfoDescriptorVer >= EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION) &&
- (UpdateHardwareInstance == TempFmpImageInfo->HardwareInstance))) {
+ (UpdateHardwareInstance == TempFmpImageInfo->HardwareInstance)))
+ {
if (MatchedHandleBuffer != NULL) {
MatchedHandleBuffer[MatchedNumberOfHandles] = HandleBuffer[Index];
}
+
if (MatchedResetRequiredBuffer != NULL) {
MatchedResetRequiredBuffer[MatchedNumberOfHandles] = (((TempFmpImageInfo->AttributesSupported &
- IMAGE_ATTRIBUTE_RESET_REQUIRED) != 0) &&
- ((TempFmpImageInfo->AttributesSetting &
- IMAGE_ATTRIBUTE_RESET_REQUIRED) != 0));
+ IMAGE_ATTRIBUTE_RESET_REQUIRED) != 0) &&
+ ((TempFmpImageInfo->AttributesSetting &
+ IMAGE_ATTRIBUTE_RESET_REQUIRED) != 0));
}
+
MatchedNumberOfHandles++;
break;
}
}
+
TempFmpImageInfo = (EFI_FIRMWARE_IMAGE_DESCRIPTOR *)((UINT8 *)TempFmpImageInfo + DescriptorSize);
}
- FreePool(FmpImageInfoBuf);
+
+ FreePool (FmpImageInfoBuf);
}
FreePool (HandleBuffer);
@@ -804,9 +828,11 @@ GetFmpHandleBufferByType ( if (NoHandles != NULL) {
*NoHandles = MatchedNumberOfHandles;
}
+
if (HandleBuf != NULL) {
*HandleBuf = MatchedHandleBuffer;
}
+
if (ResetRequiredBuf != NULL) {
*ResetRequiredBuf = MatchedResetRequiredBuffer;
}
@@ -823,39 +849,39 @@ GetFmpHandleBufferByType ( **/
UINT32
GetFmpImageInfoDescriptorVer (
- IN EFI_HANDLE Handle
+ IN EFI_HANDLE Handle
)
{
- EFI_STATUS Status;
- EFI_FIRMWARE_MANAGEMENT_PROTOCOL *Fmp;
- UINTN ImageInfoSize;
- EFI_FIRMWARE_IMAGE_DESCRIPTOR *FmpImageInfoBuf;
- UINT32 FmpImageInfoDescriptorVer;
- UINT8 FmpImageInfoCount;
- UINTN DescriptorSize;
- UINT32 PackageVersion;
- CHAR16 *PackageVersionName;
-
- Status = gBS->HandleProtocol(
+ EFI_STATUS Status;
+ EFI_FIRMWARE_MANAGEMENT_PROTOCOL *Fmp;
+ UINTN ImageInfoSize;
+ EFI_FIRMWARE_IMAGE_DESCRIPTOR *FmpImageInfoBuf;
+ UINT32 FmpImageInfoDescriptorVer;
+ UINT8 FmpImageInfoCount;
+ UINTN DescriptorSize;
+ UINT32 PackageVersion;
+ CHAR16 *PackageVersionName;
+
+ Status = gBS->HandleProtocol (
Handle,
&gEfiFirmwareManagementProtocolGuid,
(VOID **)&Fmp
);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
return 0;
}
ImageInfoSize = 0;
- Status = Fmp->GetImageInfo (
- Fmp,
- &ImageInfoSize,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL
- );
+ Status = Fmp->GetImageInfo (
+ Fmp,
+ &ImageInfoSize,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+ );
if (Status != EFI_BUFFER_TOO_SMALL) {
return 0;
}
@@ -866,20 +892,21 @@ GetFmpImageInfoDescriptorVer ( }
PackageVersionName = NULL;
- Status = Fmp->GetImageInfo (
- Fmp,
- &ImageInfoSize, // ImageInfoSize
- FmpImageInfoBuf, // ImageInfo
- &FmpImageInfoDescriptorVer, // DescriptorVersion
- &FmpImageInfoCount, // DescriptorCount
- &DescriptorSize, // DescriptorSize
- &PackageVersion, // PackageVersion
- &PackageVersionName // PackageVersionName
- );
- if (EFI_ERROR(Status)) {
- FreePool(FmpImageInfoBuf);
+ Status = Fmp->GetImageInfo (
+ Fmp,
+ &ImageInfoSize, // ImageInfoSize
+ FmpImageInfoBuf, // ImageInfo
+ &FmpImageInfoDescriptorVer, // DescriptorVersion
+ &FmpImageInfoCount, // DescriptorCount
+ &DescriptorSize, // DescriptorSize
+ &PackageVersion, // PackageVersion
+ &PackageVersionName // PackageVersionName
+ );
+ if (EFI_ERROR (Status)) {
+ FreePool (FmpImageInfoBuf);
return 0;
}
+
return FmpImageInfoDescriptorVer;
}
@@ -894,24 +921,24 @@ GetFmpImageInfoDescriptorVer ( **/
EFI_STATUS
SetFmpImageData (
- IN EFI_HANDLE Handle,
- IN EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER *ImageHeader,
- IN UINTN PayloadIndex
+ IN EFI_HANDLE Handle,
+ IN EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER *ImageHeader,
+ IN UINTN PayloadIndex
)
{
- EFI_STATUS Status;
- EFI_FIRMWARE_MANAGEMENT_PROTOCOL *Fmp;
- UINT8 *Image;
- VOID *VendorCode;
- CHAR16 *AbortReason;
- EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS ProgressCallback;
+ EFI_STATUS Status;
+ EFI_FIRMWARE_MANAGEMENT_PROTOCOL *Fmp;
+ UINT8 *Image;
+ VOID *VendorCode;
+ CHAR16 *AbortReason;
+ EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS ProgressCallback;
- Status = gBS->HandleProtocol(
+ Status = gBS->HandleProtocol (
Handle,
&gEfiFirmwareManagementProtocolGuid,
(VOID **)&Fmp
);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
return Status;
}
@@ -937,9 +964,9 @@ SetFmpImageData ( // ImageCapsuleSupport field if version is 2.
//
if (ImageHeader->Version == 1) {
- Image = (UINT8 *)ImageHeader + OFFSET_OF(EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER, UpdateHardwareInstance);
+ Image = (UINT8 *)ImageHeader + OFFSET_OF (EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER, UpdateHardwareInstance);
} else {
- Image = (UINT8 *)ImageHeader + OFFSET_OF(EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER, ImageCapsuleSupport);
+ Image = (UINT8 *)ImageHeader + OFFSET_OF (EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER, ImageCapsuleSupport);
}
}
@@ -948,29 +975,31 @@ SetFmpImageData ( } else {
VendorCode = Image + ImageHeader->UpdateImageSize;
}
+
AbortReason = NULL;
- DEBUG((DEBUG_INFO, "Fmp->SetImage ...\n"));
- DEBUG((DEBUG_INFO, "ImageTypeId - %g, ", &ImageHeader->UpdateImageTypeId));
- DEBUG((DEBUG_INFO, "PayloadIndex - 0x%x, ", PayloadIndex));
- DEBUG((DEBUG_INFO, "ImageIndex - 0x%x ", ImageHeader->UpdateImageIndex));
+ DEBUG ((DEBUG_INFO, "Fmp->SetImage ...\n"));
+ DEBUG ((DEBUG_INFO, "ImageTypeId - %g, ", &ImageHeader->UpdateImageTypeId));
+ DEBUG ((DEBUG_INFO, "PayloadIndex - 0x%x, ", PayloadIndex));
+ DEBUG ((DEBUG_INFO, "ImageIndex - 0x%x ", ImageHeader->UpdateImageIndex));
if (ImageHeader->Version >= 2) {
- DEBUG((DEBUG_INFO, "(UpdateHardwareInstance - 0x%x)", ImageHeader->UpdateHardwareInstance));
+ DEBUG ((DEBUG_INFO, "(UpdateHardwareInstance - 0x%x)", ImageHeader->UpdateHardwareInstance));
if (ImageHeader->Version >= EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER_INIT_VERSION) {
- DEBUG((DEBUG_INFO, "(ImageCapsuleSupport - 0x%x)", ImageHeader->ImageCapsuleSupport));
+ DEBUG ((DEBUG_INFO, "(ImageCapsuleSupport - 0x%x)", ImageHeader->ImageCapsuleSupport));
}
}
- DEBUG((DEBUG_INFO, "\n"));
+
+ DEBUG ((DEBUG_INFO, "\n"));
//
// Before calling SetImage(), reset the progress bar to 0%
//
ProgressCallback = UpdateImageProgress;
- Status = UpdateImageProgress (0);
+ Status = UpdateImageProgress (0);
if (EFI_ERROR (Status)) {
ProgressCallback = NULL;
}
- Status = Fmp->SetImage(
+ Status = Fmp->SetImage (
Fmp,
ImageHeader->UpdateImageIndex, // ImageIndex
Image, // Image
@@ -986,10 +1015,10 @@ SetFmpImageData ( UpdateImageProgress (100);
}
- DEBUG((DEBUG_INFO, "Fmp->SetImage - %r\n", Status));
+ DEBUG ((DEBUG_INFO, "Fmp->SetImage - %r\n", Status));
if (AbortReason != NULL) {
DEBUG ((DEBUG_ERROR, "%s\n", AbortReason));
- FreePool(AbortReason);
+ FreePool (AbortReason);
}
//
@@ -1014,11 +1043,11 @@ StartFmpImage ( IN UINTN ImageSize
)
{
- MEMMAP_DEVICE_PATH MemMapNode;
- EFI_STATUS Status;
- EFI_HANDLE ImageHandle;
- EFI_DEVICE_PATH_PROTOCOL *DriverDevicePath;
- UINTN ExitDataSize;
+ MEMMAP_DEVICE_PATH MemMapNode;
+ EFI_STATUS Status;
+ EFI_HANDLE ImageHandle;
+ EFI_DEVICE_PATH_PROTOCOL *DriverDevicePath;
+ UINTN ExitDataSize;
SetDevicePathNodeLength (&MemMapNode.Header, sizeof (MemMapNode));
MemMapNode.Header.Type = HARDWARE_DEVICE_PATH;
@@ -1032,8 +1061,8 @@ StartFmpImage ( return EFI_OUT_OF_RESOURCES;
}
- DEBUG((DEBUG_INFO, "FmpCapsule: LoadImage ...\n"));
- Status = gBS->LoadImage(
+ DEBUG ((DEBUG_INFO, "FmpCapsule: LoadImage ...\n"));
+ Status = gBS->LoadImage (
FALSE,
gImageHandle,
DriverDevicePath,
@@ -1041,8 +1070,8 @@ StartFmpImage ( ImageSize,
&ImageHandle
);
- DEBUG((DEBUG_INFO, "FmpCapsule: LoadImage - %r\n", Status));
- if (EFI_ERROR(Status)) {
+ DEBUG ((DEBUG_INFO, "FmpCapsule: LoadImage - %r\n", Status));
+ if (EFI_ERROR (Status)) {
//
// With EFI_SECURITY_VIOLATION retval, the Image was loaded and an ImageHandle was created
// with a valid EFI_LOADED_IMAGE_PROTOCOL, but the image can not be started right now.
@@ -1052,22 +1081,23 @@ StartFmpImage ( if (Status == EFI_SECURITY_VIOLATION) {
gBS->UnloadImage (ImageHandle);
}
- FreePool(DriverDevicePath);
+
+ FreePool (DriverDevicePath);
return Status;
}
- DEBUG((DEBUG_INFO, "FmpCapsule: StartImage ...\n"));
- Status = gBS->StartImage(
+ DEBUG ((DEBUG_INFO, "FmpCapsule: StartImage ...\n"));
+ Status = gBS->StartImage (
ImageHandle,
&ExitDataSize,
NULL
);
- DEBUG((DEBUG_INFO, "FmpCapsule: StartImage - %r\n", Status));
- if (EFI_ERROR(Status)) {
+ DEBUG ((DEBUG_INFO, "FmpCapsule: StartImage - %r\n", Status));
+ if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "Driver Return Status = %r\n", Status));
}
- FreePool(DriverDevicePath);
+ FreePool (DriverDevicePath);
return Status;
}
@@ -1091,16 +1121,16 @@ RecordFmpCapsuleStatus ( IN CHAR16 *CapFileName OPTIONAL
)
{
- EFI_STATUS Status;
- EFI_DEVICE_PATH_PROTOCOL *FmpDevicePath;
- UINT32 FmpImageInfoDescriptorVer;
- EFI_STATUS StatusEsrt;
- ESRT_MANAGEMENT_PROTOCOL *EsrtProtocol;
- EFI_SYSTEM_RESOURCE_ENTRY EsrtEntry;
+ EFI_STATUS Status;
+ EFI_DEVICE_PATH_PROTOCOL *FmpDevicePath;
+ UINT32 FmpImageInfoDescriptorVer;
+ EFI_STATUS StatusEsrt;
+ ESRT_MANAGEMENT_PROTOCOL *EsrtProtocol;
+ EFI_SYSTEM_RESOURCE_ENTRY EsrtEntry;
FmpDevicePath = NULL;
if (Handle != NULL) {
- gBS->HandleProtocol(
+ gBS->HandleProtocol (
Handle,
&gEfiDevicePathProtocolGuid,
(VOID **)&FmpDevicePath
@@ -1119,13 +1149,13 @@ RecordFmpCapsuleStatus ( //
// Update corresponding ESRT entry LastAttemp Status
//
- Status = gBS->LocateProtocol(&gEsrtManagementProtocolGuid, NULL, (VOID **)&EsrtProtocol);
+ Status = gBS->LocateProtocol (&gEsrtManagementProtocolGuid, NULL, (VOID **)&EsrtProtocol);
if (EFI_ERROR (Status)) {
- return ;
+ return;
}
if (Handle == NULL) {
- return ;
+ return;
}
//
@@ -1134,15 +1164,16 @@ RecordFmpCapsuleStatus ( //
FmpImageInfoDescriptorVer = GetFmpImageInfoDescriptorVer (Handle);
if (FmpImageInfoDescriptorVer < EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION) {
- StatusEsrt = EsrtProtocol->GetEsrtEntry(&ImageHeader->UpdateImageTypeId, &EsrtEntry);
- if (!EFI_ERROR(StatusEsrt)){
- if (!EFI_ERROR(CapsuleStatus)) {
+ StatusEsrt = EsrtProtocol->GetEsrtEntry (&ImageHeader->UpdateImageTypeId, &EsrtEntry);
+ if (!EFI_ERROR (StatusEsrt)) {
+ if (!EFI_ERROR (CapsuleStatus)) {
EsrtEntry.LastAttemptStatus = LAST_ATTEMPT_STATUS_SUCCESS;
} else {
EsrtEntry.LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFUL;
}
+
EsrtEntry.LastAttemptVersion = 0;
- EsrtProtocol->UpdateEsrtEntry(&EsrtEntry);
+ EsrtProtocol->UpdateEsrtEntry (&EsrtEntry);
}
}
}
@@ -1189,20 +1220,21 @@ ProcessFmpCapsuleImage ( BOOLEAN NotReady;
BOOLEAN Abort;
- if (!IsFmpCapsuleGuid(&CapsuleHeader->CapsuleGuid)) {
+ if (!IsFmpCapsuleGuid (&CapsuleHeader->CapsuleGuid)) {
return ProcessFmpCapsuleImage ((EFI_CAPSULE_HEADER *)((UINTN)CapsuleHeader + CapsuleHeader->HeaderSize), CapFileName, ResetRequired);
}
NotReady = FALSE;
- Abort = FALSE;
+ Abort = FALSE;
- DumpFmpCapsule(CapsuleHeader);
+ DumpFmpCapsule (CapsuleHeader);
- FmpCapsuleHeader = (EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER *) ((UINT8 *) CapsuleHeader + CapsuleHeader->HeaderSize);
+ FmpCapsuleHeader = (EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER *)((UINT8 *)CapsuleHeader + CapsuleHeader->HeaderSize);
if (FmpCapsuleHeader->Version > EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER_INIT_VERSION) {
return EFI_INVALID_PARAMETER;
}
+
ItemOffsetList = (UINT64 *)(FmpCapsuleHeader + 1);
ItemNum = FmpCapsuleHeader->EmbeddedDriverCount + FmpCapsuleHeader->PayloadItemCount;
@@ -1219,7 +1251,8 @@ ProcessFmpCapsuleImage ( //
for (Index = 0; Index < FmpCapsuleHeader->EmbeddedDriverCount; Index++) {
if ((FmpCapsuleHeader->PayloadItemCount == 0) &&
- (Index == (UINTN)FmpCapsuleHeader->EmbeddedDriverCount - 1)) {
+ (Index == (UINTN)FmpCapsuleHeader->EmbeddedDriverCount - 1))
+ {
//
// When driver is last element in the ItemOffsetList array, the driver size is calculated by reference CapsuleImageSize in EFI_CAPSULE_HEADER
//
@@ -1232,7 +1265,7 @@ ProcessFmpCapsuleImage ( (UINT8 *)FmpCapsuleHeader + ItemOffsetList[Index],
DriverLen
);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "Driver Return Status = %r\n", Status));
return Status;
}
@@ -1241,7 +1274,7 @@ ProcessFmpCapsuleImage ( //
// 2. Route payload to right FMP instance
//
- DEBUG((DEBUG_INFO, "FmpCapsule: route payload to right FMP instance ...\n"));
+ DEBUG ((DEBUG_INFO, "FmpCapsule: route payload to right FMP instance ...\n"));
DumpAllFmpInfo ();
@@ -1249,7 +1282,7 @@ ProcessFmpCapsuleImage ( // Check all the payload entry in capsule payload list
//
for (Index = FmpCapsuleHeader->EmbeddedDriverCount; Index < ItemNum; Index++) {
- ImageHeader = (EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER *)((UINT8 *)FmpCapsuleHeader + ItemOffsetList[Index]);
+ ImageHeader = (EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER *)((UINT8 *)FmpCapsuleHeader + ItemOffsetList[Index]);
UpdateHardwareInstance = 0;
///
@@ -1266,9 +1299,10 @@ ProcessFmpCapsuleImage ( &HandleBuffer,
&ResetRequiredBuffer
);
- if (EFI_ERROR(Status) ||
+ if (EFI_ERROR (Status) ||
(HandleBuffer == NULL) ||
- (ResetRequiredBuffer == NULL)) {
+ (ResetRequiredBuffer == NULL))
+ {
NotReady = TRUE;
RecordFmpCapsuleStatus (
NULL,
@@ -1316,11 +1350,13 @@ ProcessFmpCapsuleImage ( CapFileName
);
}
+
if (HandleBuffer != NULL) {
- FreePool(HandleBuffer);
+ FreePool (HandleBuffer);
}
+
if (ResetRequiredBuffer != NULL) {
- FreePool(ResetRequiredBuffer);
+ FreePool (ResetRequiredBuffer);
}
}
@@ -1345,7 +1381,7 @@ ProcessFmpCapsuleImage ( **/
BOOLEAN
IsNestedFmpCapsule (
- IN EFI_CAPSULE_HEADER *CapsuleHeader
+ IN EFI_CAPSULE_HEADER *CapsuleHeader
)
{
EFI_STATUS Status;
@@ -1359,10 +1395,10 @@ IsNestedFmpCapsule ( EsrtGuidFound = FALSE;
if (mIsVirtualAddrConverted) {
- if(mEsrtTable != NULL) {
+ if (mEsrtTable != NULL) {
EsrtEntry = (EFI_SYSTEM_RESOURCE_ENTRY *)(mEsrtTable + 1);
- for (Index = 0; Index < mEsrtTable->FwResourceCount ; Index++, EsrtEntry++) {
- if (CompareGuid(&EsrtEntry->FwClass, &CapsuleHeader->CapsuleGuid)) {
+ for (Index = 0; Index < mEsrtTable->FwResourceCount; Index++, EsrtEntry++) {
+ if (CompareGuid (&EsrtEntry->FwClass, &CapsuleHeader->CapsuleGuid)) {
EsrtGuidFound = TRUE;
break;
}
@@ -1372,10 +1408,10 @@ IsNestedFmpCapsule ( //
// Check ESRT protocol
//
- Status = gBS->LocateProtocol(&gEsrtManagementProtocolGuid, NULL, (VOID **)&EsrtProtocol);
- if (!EFI_ERROR(Status)) {
- Status = EsrtProtocol->GetEsrtEntry(&CapsuleHeader->CapsuleGuid, &Entry);
- if (!EFI_ERROR(Status)) {
+ Status = gBS->LocateProtocol (&gEsrtManagementProtocolGuid, NULL, (VOID **)&EsrtProtocol);
+ if (!EFI_ERROR (Status)) {
+ Status = EsrtProtocol->GetEsrtEntry (&CapsuleHeader->CapsuleGuid, &Entry);
+ if (!EFI_ERROR (Status)) {
EsrtGuidFound = TRUE;
}
}
@@ -1391,11 +1427,12 @@ IsNestedFmpCapsule ( NULL,
NULL
);
- if (!EFI_ERROR(Status)) {
+ if (!EFI_ERROR (Status)) {
EsrtGuidFound = TRUE;
}
}
}
+
if (!EsrtGuidFound) {
return FALSE;
}
@@ -1405,16 +1442,19 @@ IsNestedFmpCapsule ( // FMP GUID after ESRT one
//
NestedCapsuleHeader = (EFI_CAPSULE_HEADER *)((UINT8 *)CapsuleHeader + CapsuleHeader->HeaderSize);
- NestedCapsuleSize = (UINTN)CapsuleHeader + CapsuleHeader->CapsuleImageSize - (UINTN)NestedCapsuleHeader;
- if (NestedCapsuleSize < sizeof(EFI_CAPSULE_HEADER)) {
+ NestedCapsuleSize = (UINTN)CapsuleHeader + CapsuleHeader->CapsuleImageSize - (UINTN)NestedCapsuleHeader;
+ if (NestedCapsuleSize < sizeof (EFI_CAPSULE_HEADER)) {
return FALSE;
}
- if (!IsValidCapsuleHeader(NestedCapsuleHeader, NestedCapsuleSize)) {
+
+ if (!IsValidCapsuleHeader (NestedCapsuleHeader, NestedCapsuleSize)) {
return FALSE;
}
- if (!IsFmpCapsuleGuid(&NestedCapsuleHeader->CapsuleGuid)) {
+
+ if (!IsFmpCapsuleGuid (&NestedCapsuleHeader->CapsuleGuid)) {
return FALSE;
}
+
DEBUG ((DEBUG_INFO, "IsNestedFmpCapsule\n"));
return TRUE;
}
@@ -1429,15 +1469,17 @@ IsNestedFmpCapsule ( **/
BOOLEAN
IsFmpCapsule (
- IN EFI_CAPSULE_HEADER *CapsuleHeader
+ IN EFI_CAPSULE_HEADER *CapsuleHeader
)
{
- if (IsFmpCapsuleGuid(&CapsuleHeader->CapsuleGuid)) {
+ if (IsFmpCapsuleGuid (&CapsuleHeader->CapsuleGuid)) {
return TRUE;
}
- if (IsNestedFmpCapsule(CapsuleHeader)) {
+
+ if (IsNestedFmpCapsule (CapsuleHeader)) {
return TRUE;
}
+
return FALSE;
}
@@ -1468,23 +1510,25 @@ SupportCapsuleImage ( //
// Check capsule file name capsule
//
- if (IsCapsuleNameCapsule(CapsuleHeader)) {
+ if (IsCapsuleNameCapsule (CapsuleHeader)) {
return EFI_SUCCESS;
}
- if (IsFmpCapsule(CapsuleHeader)) {
+ if (IsFmpCapsule (CapsuleHeader)) {
//
// Fake capsule header is valid case in QueryCapsuleCpapbilities().
//
if (CapsuleHeader->HeaderSize == CapsuleHeader->CapsuleImageSize) {
return EFI_SUCCESS;
}
+
//
// Check layout of FMP capsule
//
- return ValidateFmpCapsule(CapsuleHeader, NULL);
+ return ValidateFmpCapsule (CapsuleHeader, NULL);
}
- DEBUG((DEBUG_ERROR, "Unknown Capsule Guid - %g\n", &CapsuleHeader->CapsuleGuid));
+
+ DEBUG ((DEBUG_ERROR, "Unknown Capsule Guid - %g\n", &CapsuleHeader->CapsuleGuid));
return EFI_UNSUPPORTED;
}
@@ -1510,10 +1554,10 @@ ProcessThisCapsuleImage ( OUT BOOLEAN *ResetRequired OPTIONAL
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
if (SupportCapsuleImage (CapsuleHeader) != EFI_SUCCESS) {
- RecordCapsuleStatusVariable(CapsuleHeader, EFI_UNSUPPORTED);
+ RecordCapsuleStatusVariable (CapsuleHeader, EFI_UNSUPPORTED);
return EFI_UNSUPPORTED;
}
@@ -1521,9 +1565,9 @@ ProcessThisCapsuleImage ( // Display image in firmware update display capsule
//
if (CompareGuid (&gWindowsUxCapsuleGuid, &CapsuleHeader->CapsuleGuid)) {
- DEBUG((DEBUG_INFO, "ProcessCapsuleImage for WindowsUxCapsule ...\n"));
- Status = DisplayCapsuleImage(CapsuleHeader);
- RecordCapsuleStatusVariable(CapsuleHeader, Status);
+ DEBUG ((DEBUG_INFO, "ProcessCapsuleImage for WindowsUxCapsule ...\n"));
+ Status = DisplayCapsuleImage (CapsuleHeader);
+ RecordCapsuleStatusVariable (CapsuleHeader, Status);
return Status;
}
@@ -1531,21 +1575,21 @@ ProcessThisCapsuleImage ( // Check FMP capsule layout
//
if (IsFmpCapsule (CapsuleHeader)) {
- DEBUG((DEBUG_INFO, "ProcessCapsuleImage for FmpCapsule ...\n"));
- DEBUG((DEBUG_INFO, "ValidateFmpCapsule ...\n"));
- Status = ValidateFmpCapsule(CapsuleHeader, NULL);
- DEBUG((DEBUG_INFO, "ValidateFmpCapsule - %r\n", Status));
- if (EFI_ERROR(Status)) {
- RecordCapsuleStatusVariable(CapsuleHeader, Status);
+ DEBUG ((DEBUG_INFO, "ProcessCapsuleImage for FmpCapsule ...\n"));
+ DEBUG ((DEBUG_INFO, "ValidateFmpCapsule ...\n"));
+ Status = ValidateFmpCapsule (CapsuleHeader, NULL);
+ DEBUG ((DEBUG_INFO, "ValidateFmpCapsule - %r\n", Status));
+ if (EFI_ERROR (Status)) {
+ RecordCapsuleStatusVariable (CapsuleHeader, Status);
return Status;
}
//
// Process EFI FMP Capsule
//
- DEBUG((DEBUG_INFO, "ProcessFmpCapsuleImage ...\n"));
- Status = ProcessFmpCapsuleImage(CapsuleHeader, CapFileName, ResetRequired);
- DEBUG((DEBUG_INFO, "ProcessFmpCapsuleImage - %r\n", Status));
+ DEBUG ((DEBUG_INFO, "ProcessFmpCapsuleImage ...\n"));
+ Status = ProcessFmpCapsuleImage (CapsuleHeader, CapFileName, ResetRequired);
+ DEBUG ((DEBUG_INFO, "ProcessFmpCapsuleImage - %r\n", Status));
return Status;
}
@@ -1602,11 +1646,11 @@ DxeCapsuleLibEndOfDxe ( EFI_STATUS
EFIAPI
DxeCapsuleLibConstructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
Status = gBS->CreateEventEx (
EVT_NOTIFY_SIGNAL,
@@ -1618,7 +1662,7 @@ DxeCapsuleLibConstructor ( );
ASSERT_EFI_ERROR (Status);
- InitCapsuleVariable();
+ InitCapsuleVariable ();
return EFI_SUCCESS;
}
@@ -1634,11 +1678,11 @@ DxeCapsuleLibConstructor ( EFI_STATUS
EFIAPI
DxeCapsuleLibDestructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
//
// Close the End of DXE event.
diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleProcessLib.c b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleProcessLib.c index 6d05a9f229..2a38a3d95b 100644 --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleProcessLib.c +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleProcessLib.c @@ -102,7 +102,7 @@ IsValidCapsuleHeader ( **/
BOOLEAN
IsCapsuleNameCapsule (
- IN EFI_CAPSULE_HEADER *CapsuleHeader
+ IN EFI_CAPSULE_HEADER *CapsuleHeader
);
/**
@@ -118,17 +118,17 @@ IsCapsuleNameCapsule ( **/
EFI_PHYSICAL_ADDRESS *
ValidateCapsuleNameCapsuleIntegrity (
- IN EFI_CAPSULE_HEADER *CapsuleHeader,
- OUT UINTN *CapsuleNameNum
+ IN EFI_CAPSULE_HEADER *CapsuleHeader,
+ OUT UINTN *CapsuleNameNum
);
-extern BOOLEAN mDxeCapsuleLibEndOfDxe;
-BOOLEAN mNeedReset = FALSE;
+extern BOOLEAN mDxeCapsuleLibEndOfDxe;
+BOOLEAN mNeedReset = FALSE;
-VOID **mCapsulePtr;
-CHAR16 **mCapsuleNamePtr;
-EFI_STATUS *mCapsuleStatusArray;
-UINT32 mCapsuleTotalNumber;
+VOID **mCapsulePtr;
+CHAR16 **mCapsuleNamePtr;
+EFI_STATUS *mCapsuleStatusArray;
+UINT32 mCapsuleTotalNumber;
/**
The firmware implements to process the capsule image.
@@ -172,7 +172,7 @@ UpdateImageProgress ( UINTN Seconds;
EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION *Color;
- DEBUG((DEBUG_INFO, "Update Progress - %d%%\n", Completion));
+ DEBUG ((DEBUG_INFO, "Update Progress - %d%%\n", Completion));
if (Completion > 100) {
return EFI_INVALID_PARAMETER;
@@ -216,15 +216,15 @@ InitCapsulePtr ( VOID
)
{
- EFI_PEI_HOB_POINTERS HobPointer;
- UINTN Index;
- UINTN Index2;
- UINTN Index3;
- UINTN CapsuleNameNumber;
- UINTN CapsuleNameTotalNumber;
- UINTN CapsuleNameCapsuleTotalNumber;
- VOID **CapsuleNameCapsulePtr;
- EFI_PHYSICAL_ADDRESS *CapsuleNameAddress;
+ EFI_PEI_HOB_POINTERS HobPointer;
+ UINTN Index;
+ UINTN Index2;
+ UINTN Index3;
+ UINTN CapsuleNameNumber;
+ UINTN CapsuleNameTotalNumber;
+ UINTN CapsuleNameCapsuleTotalNumber;
+ VOID **CapsuleNameCapsulePtr;
+ EFI_PHYSICAL_ADDRESS *CapsuleNameAddress;
CapsuleNameNumber = 0;
CapsuleNameTotalNumber = 0;
@@ -236,44 +236,47 @@ InitCapsulePtr ( //
HobPointer.Raw = GetHobList ();
while ((HobPointer.Raw = GetNextHob (EFI_HOB_TYPE_UEFI_CAPSULE, HobPointer.Raw)) != NULL) {
- if (!IsValidCapsuleHeader((VOID *)(UINTN)HobPointer.Capsule->BaseAddress, HobPointer.Capsule->Length)) {
+ if (!IsValidCapsuleHeader ((VOID *)(UINTN)HobPointer.Capsule->BaseAddress, HobPointer.Capsule->Length)) {
HobPointer.Header->HobType = EFI_HOB_TYPE_UNUSED; // Mark this hob as invalid
} else {
- if (IsCapsuleNameCapsule((VOID *)(UINTN)HobPointer.Capsule->BaseAddress)) {
+ if (IsCapsuleNameCapsule ((VOID *)(UINTN)HobPointer.Capsule->BaseAddress)) {
CapsuleNameCapsuleTotalNumber++;
} else {
mCapsuleTotalNumber++;
}
}
+
HobPointer.Raw = GET_NEXT_HOB (HobPointer);
}
DEBUG ((DEBUG_INFO, "mCapsuleTotalNumber - 0x%x\n", mCapsuleTotalNumber));
if (mCapsuleTotalNumber == 0) {
- return ;
+ return;
}
//
// Init temp Capsule Data table.
//
- mCapsulePtr = (VOID **) AllocateZeroPool (sizeof (VOID *) * mCapsuleTotalNumber);
+ mCapsulePtr = (VOID **)AllocateZeroPool (sizeof (VOID *) * mCapsuleTotalNumber);
if (mCapsulePtr == NULL) {
DEBUG ((DEBUG_ERROR, "Allocate mCapsulePtr fail!\n"));
mCapsuleTotalNumber = 0;
- return ;
+ return;
}
- mCapsuleStatusArray = (EFI_STATUS *) AllocateZeroPool (sizeof (EFI_STATUS) * mCapsuleTotalNumber);
+
+ mCapsuleStatusArray = (EFI_STATUS *)AllocateZeroPool (sizeof (EFI_STATUS) * mCapsuleTotalNumber);
if (mCapsuleStatusArray == NULL) {
DEBUG ((DEBUG_ERROR, "Allocate mCapsuleStatusArray fail!\n"));
FreePool (mCapsulePtr);
- mCapsulePtr = NULL;
+ mCapsulePtr = NULL;
mCapsuleTotalNumber = 0;
- return ;
+ return;
}
+
SetMemN (mCapsuleStatusArray, sizeof (EFI_STATUS) * mCapsuleTotalNumber, EFI_NOT_READY);
- CapsuleNameCapsulePtr = (VOID **) AllocateZeroPool (sizeof (VOID *) * CapsuleNameCapsuleTotalNumber);
+ CapsuleNameCapsulePtr = (VOID **)AllocateZeroPool (sizeof (VOID *) * CapsuleNameCapsuleTotalNumber);
if (CapsuleNameCapsulePtr == NULL) {
DEBUG ((DEBUG_ERROR, "Allocate CapsuleNameCapsulePtr fail!\n"));
FreePool (mCapsulePtr);
@@ -281,28 +284,29 @@ InitCapsulePtr ( mCapsulePtr = NULL;
mCapsuleStatusArray = NULL;
mCapsuleTotalNumber = 0;
- return ;
+ return;
}
//
// Find all capsule images from hob
//
HobPointer.Raw = GetHobList ();
- Index = 0;
- Index2 = 0;
+ Index = 0;
+ Index2 = 0;
while ((HobPointer.Raw = GetNextHob (EFI_HOB_TYPE_UEFI_CAPSULE, HobPointer.Raw)) != NULL) {
- if (IsCapsuleNameCapsule ((VOID *) (UINTN) HobPointer.Capsule->BaseAddress)) {
- CapsuleNameCapsulePtr [Index2++] = (VOID *) (UINTN) HobPointer.Capsule->BaseAddress;
+ if (IsCapsuleNameCapsule ((VOID *)(UINTN)HobPointer.Capsule->BaseAddress)) {
+ CapsuleNameCapsulePtr[Index2++] = (VOID *)(UINTN)HobPointer.Capsule->BaseAddress;
} else {
- mCapsulePtr [Index++] = (VOID *) (UINTN) HobPointer.Capsule->BaseAddress;
+ mCapsulePtr[Index++] = (VOID *)(UINTN)HobPointer.Capsule->BaseAddress;
}
+
HobPointer.Raw = GET_NEXT_HOB (HobPointer);
}
//
// Find Capsule On Disk Names
//
- for (Index = 0; Index < CapsuleNameCapsuleTotalNumber; Index ++) {
+ for (Index = 0; Index < CapsuleNameCapsuleTotalNumber; Index++) {
CapsuleNameAddress = ValidateCapsuleNameCapsuleIntegrity (CapsuleNameCapsulePtr[Index], &CapsuleNameNumber);
if (CapsuleNameAddress != NULL ) {
CapsuleNameTotalNumber += CapsuleNameNumber;
@@ -310,7 +314,7 @@ InitCapsulePtr ( }
if (CapsuleNameTotalNumber == mCapsuleTotalNumber) {
- mCapsuleNamePtr = (CHAR16 **) AllocateZeroPool (sizeof (CHAR16 *) * mCapsuleTotalNumber);
+ mCapsuleNamePtr = (CHAR16 **)AllocateZeroPool (sizeof (CHAR16 *) * mCapsuleTotalNumber);
if (mCapsuleNamePtr == NULL) {
DEBUG ((DEBUG_ERROR, "Allocate mCapsuleNamePtr fail!\n"));
FreePool (mCapsulePtr);
@@ -319,14 +323,14 @@ InitCapsulePtr ( mCapsulePtr = NULL;
mCapsuleStatusArray = NULL;
mCapsuleTotalNumber = 0;
- return ;
+ return;
}
- for (Index = 0, Index3 = 0; Index < CapsuleNameCapsuleTotalNumber; Index ++) {
+ for (Index = 0, Index3 = 0; Index < CapsuleNameCapsuleTotalNumber; Index++) {
CapsuleNameAddress = ValidateCapsuleNameCapsuleIntegrity (CapsuleNameCapsulePtr[Index], &CapsuleNameNumber);
if (CapsuleNameAddress != NULL ) {
- for (Index2 = 0; Index2 < CapsuleNameNumber; Index2 ++) {
- mCapsuleNamePtr[Index3 ++] = (CHAR16 *)(UINTN) CapsuleNameAddress[Index2];
+ for (Index2 = 0; Index2 < CapsuleNameNumber; Index2++) {
+ mCapsuleNamePtr[Index3++] = (CHAR16 *)(UINTN)CapsuleNameAddress[Index2];
}
}
}
@@ -367,36 +371,37 @@ PopulateCapsuleInConfigurationTable ( VOID
)
{
- VOID **CapsulePtrCache;
- EFI_GUID *CapsuleGuidCache;
- EFI_CAPSULE_HEADER *CapsuleHeader;
- EFI_CAPSULE_TABLE *CapsuleTable;
- UINT32 CacheIndex;
- UINT32 CacheNumber;
- UINT32 CapsuleNumber;
- UINTN Index;
- UINTN Size;
- EFI_STATUS Status;
+ VOID **CapsulePtrCache;
+ EFI_GUID *CapsuleGuidCache;
+ EFI_CAPSULE_HEADER *CapsuleHeader;
+ EFI_CAPSULE_TABLE *CapsuleTable;
+ UINT32 CacheIndex;
+ UINT32 CacheNumber;
+ UINT32 CapsuleNumber;
+ UINTN Index;
+ UINTN Size;
+ EFI_STATUS Status;
if (mCapsuleTotalNumber == 0) {
- return ;
+ return;
}
- CapsulePtrCache = NULL;
- CapsuleGuidCache = NULL;
- CacheIndex = 0;
- CacheNumber = 0;
+ CapsulePtrCache = NULL;
+ CapsuleGuidCache = NULL;
+ CacheIndex = 0;
+ CacheNumber = 0;
- CapsulePtrCache = (VOID **) AllocateZeroPool (sizeof (VOID *) * mCapsuleTotalNumber);
+ CapsulePtrCache = (VOID **)AllocateZeroPool (sizeof (VOID *) * mCapsuleTotalNumber);
if (CapsulePtrCache == NULL) {
DEBUG ((DEBUG_ERROR, "Allocate CapsulePtrCache fail!\n"));
- return ;
+ return;
}
- CapsuleGuidCache = (EFI_GUID *) AllocateZeroPool (sizeof (EFI_GUID) * mCapsuleTotalNumber);
+
+ CapsuleGuidCache = (EFI_GUID *)AllocateZeroPool (sizeof (EFI_GUID) * mCapsuleTotalNumber);
if (CapsuleGuidCache == NULL) {
DEBUG ((DEBUG_ERROR, "Allocate CapsuleGuidCache fail!\n"));
FreePool (CapsulePtrCache);
- return ;
+ return;
}
//
@@ -410,7 +415,7 @@ PopulateCapsuleInConfigurationTable ( // array for later sorting capsules by CapsuleGuid.
//
for (Index = 0; Index < mCapsuleTotalNumber; Index++) {
- CapsuleHeader = (EFI_CAPSULE_HEADER*) mCapsulePtr [Index];
+ CapsuleHeader = (EFI_CAPSULE_HEADER *)mCapsulePtr[Index];
if ((CapsuleHeader->Flags & CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE) != 0) {
//
// For each capsule, we compare it with known CapsuleGuid in the CacheArray.
@@ -419,13 +424,15 @@ PopulateCapsuleInConfigurationTable ( //
CacheIndex = 0;
while (CacheIndex < CacheNumber) {
- if (CompareGuid(&CapsuleGuidCache[CacheIndex],&CapsuleHeader->CapsuleGuid)) {
+ if (CompareGuid (&CapsuleGuidCache[CacheIndex], &CapsuleHeader->CapsuleGuid)) {
break;
}
+
CacheIndex++;
}
+
if (CacheIndex == CacheNumber) {
- CopyMem(&CapsuleGuidCache[CacheNumber++],&CapsuleHeader->CapsuleGuid,sizeof(EFI_GUID));
+ CopyMem (&CapsuleGuidCache[CacheNumber++], &CapsuleHeader->CapsuleGuid, sizeof (EFI_GUID));
}
}
}
@@ -442,34 +449,36 @@ PopulateCapsuleInConfigurationTable ( for (CacheIndex = 0; CacheIndex < CacheNumber; CacheIndex++) {
CapsuleNumber = 0;
for (Index = 0; Index < mCapsuleTotalNumber; Index++) {
- CapsuleHeader = (EFI_CAPSULE_HEADER*) mCapsulePtr [Index];
+ CapsuleHeader = (EFI_CAPSULE_HEADER *)mCapsulePtr[Index];
if ((CapsuleHeader->Flags & CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE) != 0) {
if (CompareGuid (&CapsuleGuidCache[CacheIndex], &CapsuleHeader->CapsuleGuid)) {
//
// Cache Caspuleheader to the array, this array is uniqued with certain CapsuleGuid.
//
- CapsulePtrCache[CapsuleNumber++] = (VOID*)CapsuleHeader;
+ CapsulePtrCache[CapsuleNumber++] = (VOID *)CapsuleHeader;
}
}
}
+
if (CapsuleNumber != 0) {
- Size = sizeof(EFI_CAPSULE_TABLE) + (CapsuleNumber - 1) * sizeof(VOID*);
+ Size = sizeof (EFI_CAPSULE_TABLE) + (CapsuleNumber - 1) * sizeof (VOID *);
CapsuleTable = AllocateRuntimePool (Size);
if (CapsuleTable == NULL) {
DEBUG ((DEBUG_ERROR, "Allocate CapsuleTable (%g) fail!\n", &CapsuleGuidCache[CacheIndex]));
continue;
}
+
CapsuleTable->CapsuleArrayNumber = CapsuleNumber;
- CopyMem(&CapsuleTable->CapsulePtr[0], CapsulePtrCache, CapsuleNumber * sizeof(VOID*));
- Status = gBS->InstallConfigurationTable (&CapsuleGuidCache[CacheIndex], (VOID*)CapsuleTable);
+ CopyMem (&CapsuleTable->CapsulePtr[0], CapsulePtrCache, CapsuleNumber * sizeof (VOID *));
+ Status = gBS->InstallConfigurationTable (&CapsuleGuidCache[CacheIndex], (VOID *)CapsuleTable);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "InstallConfigurationTable (%g) fail!\n", &CapsuleGuidCache[CacheIndex]));
}
}
}
- FreePool(CapsuleGuidCache);
- FreePool(CapsulePtrCache);
+ FreePool (CapsuleGuidCache);
+ FreePool (CapsulePtrCache);
}
/**
@@ -492,15 +501,15 @@ ProcessTheseCapsules ( IN BOOLEAN FirstRound
)
{
- EFI_STATUS Status;
- EFI_CAPSULE_HEADER *CapsuleHeader;
- UINT32 Index;
- ESRT_MANAGEMENT_PROTOCOL *EsrtManagement;
- UINT16 EmbeddedDriverCount;
- BOOLEAN ResetRequired;
- CHAR16 *CapsuleName;
+ EFI_STATUS Status;
+ EFI_CAPSULE_HEADER *CapsuleHeader;
+ UINT32 Index;
+ ESRT_MANAGEMENT_PROTOCOL *EsrtManagement;
+ UINT16 EmbeddedDriverCount;
+ BOOLEAN ResetRequired;
+ CHAR16 *CapsuleName;
- REPORT_STATUS_CODE(EFI_PROGRESS_CODE, (EFI_SOFTWARE | PcdGet32(PcdStatusCodeSubClassCapsule) | PcdGet32(PcdCapsuleStatusCodeProcessCapsulesBegin)));
+ REPORT_STATUS_CODE (EFI_PROGRESS_CODE, (EFI_SOFTWARE | PcdGet32 (PcdStatusCodeSubClassCapsule) | PcdGet32 (PcdCapsuleStatusCodeProcessCapsulesBegin)));
if (FirstRound) {
InitCapsulePtr ();
@@ -527,20 +536,20 @@ ProcessTheseCapsules ( PopulateCapsuleInConfigurationTable ();
}
- REPORT_STATUS_CODE(EFI_PROGRESS_CODE, (EFI_SOFTWARE | PcdGet32(PcdStatusCodeSubClassCapsule) | PcdGet32(PcdCapsuleStatusCodeUpdatingFirmware)));
+ REPORT_STATUS_CODE (EFI_PROGRESS_CODE, (EFI_SOFTWARE | PcdGet32 (PcdStatusCodeSubClassCapsule) | PcdGet32 (PcdCapsuleStatusCodeUpdatingFirmware)));
//
// If Windows UX capsule exist, process it first
//
for (Index = 0; Index < mCapsuleTotalNumber; Index++) {
- CapsuleHeader = (EFI_CAPSULE_HEADER*) mCapsulePtr [Index];
- CapsuleName = (mCapsuleNamePtr == NULL) ? NULL : mCapsuleNamePtr[Index];
+ CapsuleHeader = (EFI_CAPSULE_HEADER *)mCapsulePtr[Index];
+ CapsuleName = (mCapsuleNamePtr == NULL) ? NULL : mCapsuleNamePtr[Index];
if (CompareGuid (&CapsuleHeader->CapsuleGuid, &gWindowsUxCapsuleGuid)) {
DEBUG ((DEBUG_INFO, "ProcessThisCapsuleImage (Ux) - 0x%x\n", CapsuleHeader));
DEBUG ((DEBUG_INFO, "Display logo capsule is found.\n"));
- Status = ProcessThisCapsuleImage (CapsuleHeader, CapsuleName, NULL);
- mCapsuleStatusArray [Index] = EFI_SUCCESS;
- DEBUG((DEBUG_INFO, "ProcessThisCapsuleImage (Ux) - %r\n", Status));
+ Status = ProcessThisCapsuleImage (CapsuleHeader, CapsuleName, NULL);
+ mCapsuleStatusArray[Index] = EFI_SUCCESS;
+ DEBUG ((DEBUG_INFO, "ProcessThisCapsuleImage (Ux) - %r\n", Status));
break;
}
}
@@ -551,46 +560,47 @@ ProcessTheseCapsules ( // All capsules left are recognized by platform.
//
for (Index = 0; Index < mCapsuleTotalNumber; Index++) {
- if (mCapsuleStatusArray [Index] != EFI_NOT_READY) {
+ if (mCapsuleStatusArray[Index] != EFI_NOT_READY) {
// already processed
continue;
}
- CapsuleHeader = (EFI_CAPSULE_HEADER*) mCapsulePtr [Index];
- CapsuleName = (mCapsuleNamePtr == NULL) ? NULL : mCapsuleNamePtr[Index];
+
+ CapsuleHeader = (EFI_CAPSULE_HEADER *)mCapsulePtr[Index];
+ CapsuleName = (mCapsuleNamePtr == NULL) ? NULL : mCapsuleNamePtr[Index];
if (!CompareGuid (&CapsuleHeader->CapsuleGuid, &gWindowsUxCapsuleGuid)) {
//
// Call capsule library to process capsule image.
//
EmbeddedDriverCount = 0;
- if (IsFmpCapsule(CapsuleHeader)) {
+ if (IsFmpCapsule (CapsuleHeader)) {
Status = ValidateFmpCapsule (CapsuleHeader, &EmbeddedDriverCount);
- if (EFI_ERROR(Status)) {
- DEBUG((DEBUG_ERROR, "ValidateFmpCapsule failed. Ignore!\n"));
- mCapsuleStatusArray [Index] = EFI_ABORTED;
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "ValidateFmpCapsule failed. Ignore!\n"));
+ mCapsuleStatusArray[Index] = EFI_ABORTED;
continue;
}
} else {
- mCapsuleStatusArray [Index] = EFI_ABORTED;
+ mCapsuleStatusArray[Index] = EFI_ABORTED;
continue;
}
if ((!FirstRound) || (EmbeddedDriverCount == 0)) {
- DEBUG((DEBUG_INFO, "ProcessThisCapsuleImage - 0x%x\n", CapsuleHeader));
- ResetRequired = FALSE;
- Status = ProcessThisCapsuleImage (CapsuleHeader, CapsuleName, &ResetRequired);
- mCapsuleStatusArray [Index] = Status;
- DEBUG((DEBUG_INFO, "ProcessThisCapsuleImage - %r\n", Status));
+ DEBUG ((DEBUG_INFO, "ProcessThisCapsuleImage - 0x%x\n", CapsuleHeader));
+ ResetRequired = FALSE;
+ Status = ProcessThisCapsuleImage (CapsuleHeader, CapsuleName, &ResetRequired);
+ mCapsuleStatusArray[Index] = Status;
+ DEBUG ((DEBUG_INFO, "ProcessThisCapsuleImage - %r\n", Status));
if (Status != EFI_NOT_READY) {
- if (EFI_ERROR(Status)) {
- REPORT_STATUS_CODE(EFI_ERROR_CODE, (EFI_SOFTWARE | PcdGet32(PcdStatusCodeSubClassCapsule) | PcdGet32(PcdCapsuleStatusCodeUpdateFirmwareFailed)));
+ if (EFI_ERROR (Status)) {
+ REPORT_STATUS_CODE (EFI_ERROR_CODE, (EFI_SOFTWARE | PcdGet32 (PcdStatusCodeSubClassCapsule) | PcdGet32 (PcdCapsuleStatusCodeUpdateFirmwareFailed)));
DEBUG ((DEBUG_ERROR, "Capsule process failed!\n"));
} else {
- REPORT_STATUS_CODE(EFI_PROGRESS_CODE, (EFI_SOFTWARE | PcdGet32(PcdStatusCodeSubClassCapsule) | PcdGet32(PcdCapsuleStatusCodeUpdateFirmwareSuccess)));
+ REPORT_STATUS_CODE (EFI_PROGRESS_CODE, (EFI_SOFTWARE | PcdGet32 (PcdStatusCodeSubClassCapsule) | PcdGet32 (PcdCapsuleStatusCodeUpdateFirmwareSuccess)));
}
mNeedReset |= ResetRequired;
- if ((CapsuleHeader->Flags & PcdGet16(PcdSystemRebootAfterCapsuleProcessFlag)) != 0) {
+ if ((CapsuleHeader->Flags & PcdGet16 (PcdSystemRebootAfterCapsuleProcessFlag)) != 0) {
mNeedReset = TRUE;
}
}
@@ -598,16 +608,17 @@ ProcessTheseCapsules ( }
}
- Status = gBS->LocateProtocol(&gEsrtManagementProtocolGuid, NULL, (VOID **)&EsrtManagement);
+ Status = gBS->LocateProtocol (&gEsrtManagementProtocolGuid, NULL, (VOID **)&EsrtManagement);
//
// Always sync ESRT Cache from FMP Instance
//
- if (!EFI_ERROR(Status)) {
- EsrtManagement->SyncEsrtFmp();
+ if (!EFI_ERROR (Status)) {
+ EsrtManagement->SyncEsrtFmp ();
}
+
Status = EFI_SUCCESS;
- REPORT_STATUS_CODE(EFI_PROGRESS_CODE, (EFI_SOFTWARE | PcdGet32(PcdStatusCodeSubClassCapsule) | PcdGet32(PcdCapsuleStatusCodeProcessCapsulesEnd)));
+ REPORT_STATUS_CODE (EFI_PROGRESS_CODE, (EFI_SOFTWARE | PcdGet32 (PcdStatusCodeSubClassCapsule) | PcdGet32 (PcdCapsuleStatusCodeProcessCapsulesEnd)));
return Status;
}
@@ -620,13 +631,13 @@ DoResetSystem ( VOID
)
{
- DEBUG((DEBUG_INFO, "Capsule Request Cold Reboot."));
+ DEBUG ((DEBUG_INFO, "Capsule Request Cold Reboot."));
- REPORT_STATUS_CODE(EFI_PROGRESS_CODE, (EFI_SOFTWARE | PcdGet32(PcdStatusCodeSubClassCapsule) | PcdGet32(PcdCapsuleStatusCodeResettingSystem)));
+ REPORT_STATUS_CODE (EFI_PROGRESS_CODE, (EFI_SOFTWARE | PcdGet32 (PcdStatusCodeSubClassCapsule) | PcdGet32 (PcdCapsuleStatusCodeResettingSystem)));
- gRT->ResetSystem(EfiResetCold, EFI_SUCCESS, 0, NULL);
+ gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL);
- CpuDeadLoop();
+ CpuDeadLoop ();
}
/**
@@ -666,26 +677,27 @@ ProcessCapsules ( VOID
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
if (!mDxeCapsuleLibEndOfDxe) {
- Status = ProcessTheseCapsules(TRUE);
+ Status = ProcessTheseCapsules (TRUE);
//
// Reboot System if and only if all capsule processed.
// If not, defer reset to 2nd process.
//
- if (mNeedReset && AreAllImagesProcessed()) {
- DoResetSystem();
+ if (mNeedReset && AreAllImagesProcessed ()) {
+ DoResetSystem ();
}
} else {
- Status = ProcessTheseCapsules(FALSE);
+ Status = ProcessTheseCapsules (FALSE);
//
// Reboot System if required after all capsule processed
//
if (mNeedReset) {
- DoResetSystem();
+ DoResetSystem ();
}
}
+
return Status;
}
diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleReportLib.c b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleReportLib.c index 82f8c1f49c..efc6b4ce26 100644 --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleReportLib.c +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleReportLib.c @@ -37,7 +37,7 @@ **/
EFI_STATUS
-CoDClearCapsuleRelocationInfo(
+CoDClearCapsuleRelocationInfo (
VOID
);
@@ -52,23 +52,24 @@ GetCurrentCapsuleLastIndex ( VOID
)
{
- UINTN Size;
- CHAR16 CapsuleLastStr[sizeof("Capsule####")];
- EFI_STATUS Status;
- UINT16 CurrentIndex;
+ UINTN Size;
+ CHAR16 CapsuleLastStr[sizeof ("Capsule####")];
+ EFI_STATUS Status;
+ UINT16 CurrentIndex;
- Size = sizeof(L"Capsule####") - sizeof(CHAR16); // no zero terminator
- Status = gRT->GetVariable(
+ Size = sizeof (L"Capsule####") - sizeof (CHAR16); // no zero terminator
+ Status = gRT->GetVariable (
L"CapsuleLast",
&gEfiCapsuleReportGuid,
NULL,
&Size,
CapsuleLastStr
);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
return -1;
}
- CurrentIndex = (UINT16)StrHexToUintn(&CapsuleLastStr[sizeof("Capsule") - 1]);
+
+ CurrentIndex = (UINT16)StrHexToUintn (&CapsuleLastStr[sizeof ("Capsule") - 1]);
return CurrentIndex;
}
@@ -83,11 +84,11 @@ GetNewCapsuleResultIndex ( VOID
)
{
- INTN CurrentIndex;
+ INTN CurrentIndex;
- CurrentIndex = GetCurrentCapsuleLastIndex();
- if (CurrentIndex >= PcdGet16(PcdCapsuleMax)) {
- DEBUG((DEBUG_INFO, " CapsuleResult variable Rolling Over!\n"));
+ CurrentIndex = GetCurrentCapsuleLastIndex ();
+ if (CurrentIndex >= PcdGet16 (PcdCapsuleMax)) {
+ DEBUG ((DEBUG_INFO, " CapsuleResult variable Rolling Over!\n"));
return 0;
}
@@ -108,22 +109,27 @@ LockVariable ( IN EDKII_VARIABLE_POLICY_PROTOCOL *VariablePolicy
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
// Set the policies to protect the target variables
- Status = RegisterBasicVariablePolicy (VariablePolicy,
- &VariableGuid,
- VariableName,
- VARIABLE_POLICY_NO_MIN_SIZE,
- VARIABLE_POLICY_NO_MAX_SIZE,
- VARIABLE_POLICY_NO_MUST_ATTR,
- VARIABLE_POLICY_NO_CANT_ATTR,
- VARIABLE_POLICY_TYPE_LOCK_NOW);
+ Status = RegisterBasicVariablePolicy (
+ VariablePolicy,
+ &VariableGuid,
+ VariableName,
+ VARIABLE_POLICY_NO_MIN_SIZE,
+ VARIABLE_POLICY_NO_MAX_SIZE,
+ VARIABLE_POLICY_NO_MUST_ATTR,
+ VARIABLE_POLICY_NO_CANT_ATTR,
+ VARIABLE_POLICY_TYPE_LOCK_NOW
+ );
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "DxeCapsuleLibFmp: Failed to lock variable %g %s. Status = %r\n",
- &VariableGuid,
- VariableName,
- Status));
+ DEBUG ((
+ DEBUG_ERROR,
+ "DxeCapsuleLibFmp: Failed to lock variable %g %s. Status = %r\n",
+ &VariableGuid,
+ VariableName,
+ Status
+ ));
ASSERT_EFI_ERROR (Status);
}
}
@@ -139,36 +145,36 @@ LockVariable ( **/
EFI_STATUS
WriteNewCapsuleResultVariable (
- IN VOID *CapsuleResult,
- IN UINTN CapsuleResultSize
+ IN VOID *CapsuleResult,
+ IN UINTN CapsuleResultSize
)
{
- INTN CapsuleResultIndex;
- CHAR16 CapsuleResultStr[sizeof("Capsule####")];
- UINTN Size;
- EFI_STATUS Status;
+ INTN CapsuleResultIndex;
+ CHAR16 CapsuleResultStr[sizeof ("Capsule####")];
+ UINTN Size;
+ EFI_STATUS Status;
- CapsuleResultIndex = GetNewCapsuleResultIndex();
- DEBUG((DEBUG_INFO, "New CapsuleResultIndex - 0x%x\n", CapsuleResultIndex));
+ CapsuleResultIndex = GetNewCapsuleResultIndex ();
+ DEBUG ((DEBUG_INFO, "New CapsuleResultIndex - 0x%x\n", CapsuleResultIndex));
- UnicodeSPrint(
+ UnicodeSPrint (
CapsuleResultStr,
- sizeof(CapsuleResultStr),
+ sizeof (CapsuleResultStr),
L"Capsule%04x",
CapsuleResultIndex
);
- Status = gRT->SetVariable(
+ Status = gRT->SetVariable (
CapsuleResultStr,
&gEfiCapsuleReportGuid,
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
CapsuleResultSize,
CapsuleResult
);
- if (!EFI_ERROR(Status)) {
- Size = sizeof(L"Capsule####") - sizeof(CHAR16); // no zero terminator
- DEBUG((DEBUG_INFO, "Set CapsuleLast - %s\n", CapsuleResultStr));
- Status = gRT->SetVariable(
+ if (!EFI_ERROR (Status)) {
+ Size = sizeof (L"Capsule####") - sizeof (CHAR16); // no zero terminator
+ DEBUG ((DEBUG_INFO, "Set CapsuleLast - %s\n", CapsuleResultStr));
+ Status = gRT->SetVariable (
L"CapsuleLast",
&gEfiCapsuleReportGuid,
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
@@ -191,24 +197,25 @@ WriteNewCapsuleResultVariable ( **/
EFI_STATUS
RecordCapsuleStatusVariable (
- IN EFI_CAPSULE_HEADER *CapsuleHeader,
- IN EFI_STATUS CapsuleStatus
+ IN EFI_CAPSULE_HEADER *CapsuleHeader,
+ IN EFI_STATUS CapsuleStatus
)
{
EFI_CAPSULE_RESULT_VARIABLE_HEADER CapsuleResultVariable;
EFI_STATUS Status;
- CapsuleResultVariable.VariableTotalSize = sizeof(CapsuleResultVariable);
- CapsuleResultVariable.Reserved = 0;
+ CapsuleResultVariable.VariableTotalSize = sizeof (CapsuleResultVariable);
+ CapsuleResultVariable.Reserved = 0;
CopyGuid (&CapsuleResultVariable.CapsuleGuid, &CapsuleHeader->CapsuleGuid);
- ZeroMem(&CapsuleResultVariable.CapsuleProcessed, sizeof(CapsuleResultVariable.CapsuleProcessed));
- gRT->GetTime(&CapsuleResultVariable.CapsuleProcessed, NULL);
+ ZeroMem (&CapsuleResultVariable.CapsuleProcessed, sizeof (CapsuleResultVariable.CapsuleProcessed));
+ gRT->GetTime (&CapsuleResultVariable.CapsuleProcessed, NULL);
CapsuleResultVariable.CapsuleStatus = CapsuleStatus;
Status = EFI_SUCCESS;
if ((CapsuleHeader->Flags & CAPSULE_FLAGS_PERSIST_ACROSS_RESET) != 0) {
- Status = WriteNewCapsuleResultVariable(&CapsuleResultVariable, sizeof(CapsuleResultVariable));
+ Status = WriteNewCapsuleResultVariable (&CapsuleResultVariable, sizeof (CapsuleResultVariable));
}
+
return Status;
}
@@ -245,58 +252,61 @@ RecordFmpCapsuleStatusVariable ( UINTN CapFileNameSize;
DevicePathStr = NULL;
- CapFileNameSize = sizeof(CHAR16);
+ CapFileNameSize = sizeof (CHAR16);
if (FmpDevicePath != NULL) {
DevicePathStr = ConvertDevicePathToText (FmpDevicePath, FALSE, FALSE);
}
+
if (DevicePathStr != NULL) {
- DevicePathStrSize = StrSize(DevicePathStr);
+ DevicePathStrSize = StrSize (DevicePathStr);
} else {
- DevicePathStrSize = sizeof(CHAR16);
+ DevicePathStrSize = sizeof (CHAR16);
}
if (CapFileName != NULL) {
- CapFileNameSize = StrSize(CapFileName);
+ CapFileNameSize = StrSize (CapFileName);
}
//
// Allocate room for CapsuleFileName.
//
- CapsuleResultVariableSize = sizeof(EFI_CAPSULE_RESULT_VARIABLE_HEADER) + sizeof(EFI_CAPSULE_RESULT_VARIABLE_FMP) + CapFileNameSize + DevicePathStrSize;
+ CapsuleResultVariableSize = sizeof (EFI_CAPSULE_RESULT_VARIABLE_HEADER) + sizeof (EFI_CAPSULE_RESULT_VARIABLE_FMP) + CapFileNameSize + DevicePathStrSize;
- CapsuleResultVariable = AllocateZeroPool (CapsuleResultVariableSize);
+ CapsuleResultVariable = AllocateZeroPool (CapsuleResultVariableSize);
if (CapsuleResultVariable == NULL) {
return EFI_OUT_OF_RESOURCES;
}
- CapsuleResultVariableHeader = (VOID *)CapsuleResultVariable;
+
+ CapsuleResultVariableHeader = (VOID *)CapsuleResultVariable;
CapsuleResultVariableHeader->VariableTotalSize = (UINT32)CapsuleResultVariableSize;
- CapsuleResultVariableHeader->Reserved = 0;
- CopyGuid(&CapsuleResultVariableHeader->CapsuleGuid, &CapsuleHeader->CapsuleGuid);
- ZeroMem(&CapsuleResultVariableHeader->CapsuleProcessed, sizeof(CapsuleResultVariableHeader->CapsuleProcessed));
- gRT->GetTime(&CapsuleResultVariableHeader->CapsuleProcessed, NULL);
+ CapsuleResultVariableHeader->Reserved = 0;
+ CopyGuid (&CapsuleResultVariableHeader->CapsuleGuid, &CapsuleHeader->CapsuleGuid);
+ ZeroMem (&CapsuleResultVariableHeader->CapsuleProcessed, sizeof (CapsuleResultVariableHeader->CapsuleProcessed));
+ gRT->GetTime (&CapsuleResultVariableHeader->CapsuleProcessed, NULL);
CapsuleResultVariableHeader->CapsuleStatus = CapsuleStatus;
- CapsuleResultVariableFmp = (VOID *)(CapsuleResultVariable + sizeof(EFI_CAPSULE_RESULT_VARIABLE_HEADER));
- CapsuleResultVariableFmp->Version = 0x1;
- CapsuleResultVariableFmp->PayloadIndex = (UINT8)PayloadIndex;
+ CapsuleResultVariableFmp = (VOID *)(CapsuleResultVariable + sizeof (EFI_CAPSULE_RESULT_VARIABLE_HEADER));
+ CapsuleResultVariableFmp->Version = 0x1;
+ CapsuleResultVariableFmp->PayloadIndex = (UINT8)PayloadIndex;
CapsuleResultVariableFmp->UpdateImageIndex = ImageHeader->UpdateImageIndex;
CopyGuid (&CapsuleResultVariableFmp->UpdateImageTypeId, &ImageHeader->UpdateImageTypeId);
if (CapFileName != NULL) {
- CopyMem((UINT8 *)CapsuleResultVariableFmp + sizeof(EFI_CAPSULE_RESULT_VARIABLE_FMP), CapFileName, CapFileNameSize);
+ CopyMem ((UINT8 *)CapsuleResultVariableFmp + sizeof (EFI_CAPSULE_RESULT_VARIABLE_FMP), CapFileName, CapFileNameSize);
}
if (DevicePathStr != NULL) {
- CopyMem ((UINT8 *)CapsuleResultVariableFmp + sizeof(EFI_CAPSULE_RESULT_VARIABLE_FMP) + CapFileNameSize, DevicePathStr, DevicePathStrSize);
+ CopyMem ((UINT8 *)CapsuleResultVariableFmp + sizeof (EFI_CAPSULE_RESULT_VARIABLE_FMP) + CapFileNameSize, DevicePathStr, DevicePathStrSize);
FreePool (DevicePathStr);
DevicePathStr = NULL;
}
Status = EFI_SUCCESS;
if ((CapsuleHeader->Flags & CAPSULE_FLAGS_PERSIST_ACROSS_RESET) != 0) {
- Status = WriteNewCapsuleResultVariable(CapsuleResultVariable, CapsuleResultVariableSize);
+ Status = WriteNewCapsuleResultVariable (CapsuleResultVariable, CapsuleResultVariableSize);
}
+
FreePool (CapsuleResultVariable);
return Status;
}
@@ -308,29 +318,29 @@ RecordFmpCapsuleStatusVariable ( **/
VOID
InitCapsuleMaxVariable (
- EDKII_VARIABLE_POLICY_PROTOCOL *VariablePolicy
+ EDKII_VARIABLE_POLICY_PROTOCOL *VariablePolicy
)
{
- EFI_STATUS Status;
- UINTN Size;
- CHAR16 CapsuleMaxStr[sizeof("Capsule####")];
+ EFI_STATUS Status;
+ UINTN Size;
+ CHAR16 CapsuleMaxStr[sizeof ("Capsule####")];
- UnicodeSPrint(
+ UnicodeSPrint (
CapsuleMaxStr,
- sizeof(CapsuleMaxStr),
+ sizeof (CapsuleMaxStr),
L"Capsule%04x",
- PcdGet16(PcdCapsuleMax)
+ PcdGet16 (PcdCapsuleMax)
);
- Size = sizeof(L"Capsule####") - sizeof(CHAR16); // no zero terminator
- Status = gRT->SetVariable(
+ Size = sizeof (L"Capsule####") - sizeof (CHAR16); // no zero terminator
+ Status = gRT->SetVariable (
L"CapsuleMax",
&gEfiCapsuleReportGuid,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
Size,
CapsuleMaxStr
);
- if (!EFI_ERROR(Status)) {
+ if (!EFI_ERROR (Status)) {
// Lock it per UEFI spec.
LockVariable (gEfiCapsuleReportGuid, L"CapsuleMax", VariablePolicy);
}
@@ -343,18 +353,18 @@ InitCapsuleMaxVariable ( **/
VOID
InitCapsuleLastVariable (
- EDKII_VARIABLE_POLICY_PROTOCOL *VariablePolicy
+ EDKII_VARIABLE_POLICY_PROTOCOL *VariablePolicy
)
{
- EFI_STATUS Status;
- EFI_BOOT_MODE BootMode;
- VOID *CapsuleResult;
- UINTN Size;
- CHAR16 CapsuleLastStr[sizeof("Capsule####")];
+ EFI_STATUS Status;
+ EFI_BOOT_MODE BootMode;
+ VOID *CapsuleResult;
+ UINTN Size;
+ CHAR16 CapsuleLastStr[sizeof ("Capsule####")];
- BootMode = GetBootModeHob();
+ BootMode = GetBootModeHob ();
if (BootMode == BOOT_ON_FLASH_UPDATE) {
- Status = gRT->SetVariable(
+ Status = gRT->SetVariable (
L"CapsuleLast",
&gEfiCapsuleReportGuid,
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
@@ -366,30 +376,30 @@ InitCapsuleLastVariable ( //
// Check if OS/APP cleared L"Capsule####"
//
- ZeroMem(CapsuleLastStr, sizeof(CapsuleLastStr));
- Size = sizeof(L"Capsule####") - sizeof(CHAR16); // no zero terminator
- Status = gRT->GetVariable(
+ ZeroMem (CapsuleLastStr, sizeof (CapsuleLastStr));
+ Size = sizeof (L"Capsule####") - sizeof (CHAR16); // no zero terminator
+ Status = gRT->GetVariable (
L"CapsuleLast",
&gEfiCapsuleReportGuid,
NULL,
&Size,
CapsuleLastStr
);
- if (!EFI_ERROR(Status)) {
+ if (!EFI_ERROR (Status)) {
//
// L"CapsuleLast" is got, check if data is there.
//
Status = GetVariable2 (
CapsuleLastStr,
&gEfiCapsuleReportGuid,
- (VOID **) &CapsuleResult,
+ (VOID **)&CapsuleResult,
NULL
);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
//
// If no data, delete L"CapsuleLast"
//
- Status = gRT->SetVariable(
+ Status = gRT->SetVariable (
L"CapsuleLast",
&gEfiCapsuleReportGuid,
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
@@ -416,19 +426,19 @@ InitCapsuleUpdateVariable ( VOID
)
{
- EFI_STATUS Status;
- UINTN Index;
- CHAR16 CapsuleVarName[30];
- CHAR16 *TempVarName;
+ EFI_STATUS Status;
+ UINTN Index;
+ CHAR16 CapsuleVarName[30];
+ CHAR16 *TempVarName;
//
// Clear all the capsule variables CapsuleUpdateData, CapsuleUpdateData1, CapsuleUpdateData2...
// as early as possible which will avoid the next time boot after the capsule update
// will still into the capsule loop
//
- StrCpyS (CapsuleVarName, sizeof(CapsuleVarName)/sizeof(CapsuleVarName[0]), EFI_CAPSULE_VARIABLE_NAME);
+ StrCpyS (CapsuleVarName, sizeof (CapsuleVarName)/sizeof (CapsuleVarName[0]), EFI_CAPSULE_VARIABLE_NAME);
TempVarName = CapsuleVarName + StrLen (CapsuleVarName);
- Index = 0;
+ Index = 0;
while (TRUE) {
if (Index > 0) {
UnicodeValueToStringS (
@@ -439,6 +449,7 @@ InitCapsuleUpdateVariable ( 0
);
}
+
Status = gRT->SetVariable (
CapsuleVarName,
&gEfiCapsuleVendorGuid,
@@ -452,6 +463,7 @@ InitCapsuleUpdateVariable ( //
break;
}
+
Index++;
}
}
@@ -463,15 +475,15 @@ InitCapsuleUpdateVariable ( **/
VOID
InitCapsuleRelocationInfo (
- EDKII_VARIABLE_POLICY_PROTOCOL *VariablePolicy
+ EDKII_VARIABLE_POLICY_PROTOCOL *VariablePolicy
)
{
- CoDClearCapsuleRelocationInfo();
+ CoDClearCapsuleRelocationInfo ();
//
// Unlock Capsule On Disk relocation Info variable only when Capsule On Disk flag is enabled
//
- if (!CoDCheckCapsuleOnDiskFlag()) {
+ if (!CoDCheckCapsuleOnDiskFlag ()) {
LockVariable (gEfiCapsuleVendorGuid, COD_RELOCATION_INFO_VAR_NAME, VariablePolicy);
}
}
@@ -484,16 +496,17 @@ InitCapsuleVariable ( VOID
)
{
- EFI_STATUS Status;
- EDKII_VARIABLE_POLICY_PROTOCOL *VariablePolicy;
+ EFI_STATUS Status;
+ EDKII_VARIABLE_POLICY_PROTOCOL *VariablePolicy;
// Locate the VariablePolicy protocol
- Status = gBS->LocateProtocol (&gEdkiiVariablePolicyProtocolGuid, NULL, (VOID**)&VariablePolicy);
+ Status = gBS->LocateProtocol (&gEdkiiVariablePolicyProtocolGuid, NULL, (VOID **)&VariablePolicy);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "DxeCapsuleReportLib %a - Could not locate VariablePolicy protocol! %r\n", __FUNCTION__, Status));
ASSERT_EFI_ERROR (Status);
}
- InitCapsuleUpdateVariable();
+
+ InitCapsuleUpdateVariable ();
InitCapsuleMaxVariable (VariablePolicy);
InitCapsuleLastVariable (VariablePolicy);
InitCapsuleRelocationInfo (VariablePolicy);
diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleReportLibNull.c b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleReportLibNull.c index 958229521e..b425e99e67 100644 --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleReportLibNull.c +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleReportLibNull.c @@ -24,8 +24,8 @@ **/
EFI_STATUS
RecordCapsuleStatusVariable (
- IN EFI_CAPSULE_HEADER *CapsuleHeader,
- IN EFI_STATUS CapsuleStatus
+ IN EFI_CAPSULE_HEADER *CapsuleHeader,
+ IN EFI_STATUS CapsuleStatus
)
{
return EFI_UNSUPPORTED;
diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c index f94044a409..9ceb44fe4d 100644 --- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c +++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleRuntime.c @@ -20,10 +20,10 @@ #include <Library/UefiRuntimeServicesTableLib.h>
#include <Library/MemoryAllocationLib.h>
-extern EFI_SYSTEM_RESOURCE_TABLE *mEsrtTable;
-extern BOOLEAN mIsVirtualAddrConverted;
-EFI_EVENT mDxeRuntimeCapsuleLibVirtualAddressChangeEvent = NULL;
-EFI_EVENT mDxeRuntimeCapsuleLibReadyToBootEvent = NULL;
+extern EFI_SYSTEM_RESOURCE_TABLE *mEsrtTable;
+extern BOOLEAN mIsVirtualAddrConverted;
+EFI_EVENT mDxeRuntimeCapsuleLibVirtualAddressChangeEvent = NULL;
+EFI_EVENT mDxeRuntimeCapsuleLibReadyToBootEvent = NULL;
/**
Convert EsrtTable physical address to virtual address.
@@ -35,8 +35,8 @@ EFI_EVENT mDxeRuntimeCapsuleLibReadyToBootEvent = NULL; VOID
EFIAPI
DxeCapsuleLibVirtualAddressChangeEvent (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
gRT->ConvertPointer (EFI_OPTIONAL_PTR, (VOID **)&mEsrtTable);
@@ -54,22 +54,23 @@ STATIC VOID
EFIAPI
DxeCapsuleLibReadyToBootEventNotify (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
- UINTN Index;
- EFI_CONFIGURATION_TABLE *ConfigEntry;
- EFI_SYSTEM_RESOURCE_TABLE *EsrtTable;
+ UINTN Index;
+ EFI_CONFIGURATION_TABLE *ConfigEntry;
+ EFI_SYSTEM_RESOURCE_TABLE *EsrtTable;
//
// Get Esrt table first
//
ConfigEntry = gST->ConfigurationTable;
for (Index = 0; Index < gST->NumberOfTableEntries; Index++) {
- if (CompareGuid(&gEfiSystemResourceTableGuid, &ConfigEntry->VendorGuid)) {
+ if (CompareGuid (&gEfiSystemResourceTableGuid, &ConfigEntry->VendorGuid)) {
break;
}
+
ConfigEntry++;
}
@@ -80,12 +81,13 @@ DxeCapsuleLibReadyToBootEventNotify ( //
// Search Esrt to check given capsule is qualified
//
- EsrtTable = (EFI_SYSTEM_RESOURCE_TABLE *) ConfigEntry->VendorTable;
+ EsrtTable = (EFI_SYSTEM_RESOURCE_TABLE *)ConfigEntry->VendorTable;
mEsrtTable = AllocateRuntimeCopyPool (
sizeof (EFI_SYSTEM_RESOURCE_TABLE) +
EsrtTable->FwResourceCount * sizeof (EFI_SYSTEM_RESOURCE_ENTRY),
- EsrtTable);
+ EsrtTable
+ );
ASSERT (mEsrtTable != NULL);
//
@@ -106,11 +108,11 @@ DxeCapsuleLibReadyToBootEventNotify ( EFI_STATUS
EFIAPI
DxeRuntimeCapsuleLibConstructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
//
// Make sure we can handle virtual address changes.
@@ -152,11 +154,11 @@ DxeRuntimeCapsuleLibConstructor ( EFI_STATUS
EFIAPI
DxeRuntimeCapsuleLibDestructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
//
// Close the VirtualAddressChange event.
diff --git a/MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.c b/MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.c index 55985abd78..aced356324 100644 --- a/MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.c +++ b/MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.c @@ -21,7 +21,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent EFI_STATUS
EFIAPI
SupportCapsuleImage (
- IN EFI_CAPSULE_HEADER *CapsuleHeader
+ IN EFI_CAPSULE_HEADER *CapsuleHeader
)
{
return EFI_UNSUPPORTED;
@@ -40,7 +40,7 @@ SupportCapsuleImage ( EFI_STATUS
EFIAPI
ProcessCapsuleImage (
- IN EFI_CAPSULE_HEADER *CapsuleHeader
+ IN EFI_CAPSULE_HEADER *CapsuleHeader
)
{
return EFI_UNSUPPORTED;
@@ -85,7 +85,6 @@ ProcessCapsules ( return EFI_UNSUPPORTED;
}
-
/**
This routine is called to check if CapsuleOnDisk flag in OsIndications Variable
is enabled.
@@ -96,7 +95,7 @@ ProcessCapsules ( **/
BOOLEAN
EFIAPI
-CoDCheckCapsuleOnDiskFlag(
+CoDCheckCapsuleOnDiskFlag (
VOID
)
{
@@ -111,7 +110,7 @@ CoDCheckCapsuleOnDiskFlag( **/
EFI_STATUS
EFIAPI
-CoDClearCapsuleOnDiskFlag(
+CoDClearCapsuleOnDiskFlag (
VOID
)
{
@@ -142,8 +141,8 @@ CoDClearCapsuleOnDiskFlag( **/
EFI_STATUS
EFIAPI
-CoDRelocateCapsule(
- UINTN MaxRetry
+CoDRelocateCapsule (
+ UINTN MaxRetry
)
{
return EFI_UNSUPPORTED;
@@ -163,7 +162,7 @@ CoDRelocateCapsule( EFI_STATUS
EFIAPI
CoDRemoveTempFile (
- UINTN MaxRetry
+ UINTN MaxRetry
)
{
return EFI_UNSUPPORTED;
diff --git a/MdeModulePkg/Library/DxeCoreMemoryAllocationLib/DxeCoreMemoryAllocationServices.h b/MdeModulePkg/Library/DxeCoreMemoryAllocationLib/DxeCoreMemoryAllocationServices.h index 73b3569b64..acbb666bbd 100644 --- a/MdeModulePkg/Library/DxeCoreMemoryAllocationLib/DxeCoreMemoryAllocationServices.h +++ b/MdeModulePkg/Library/DxeCoreMemoryAllocationLib/DxeCoreMemoryAllocationServices.h @@ -12,7 +12,6 @@ #ifndef _DXE_CORE_MEMORY_ALLOCATION_SERVICES_H_
#define _DXE_CORE_MEMORY_ALLOCATION_SERVICES_H_
-
/**
Allocates pages from the memory map.
@@ -34,14 +33,12 @@ EFI_STATUS
EFIAPI
CoreAllocatePages (
- IN EFI_ALLOCATE_TYPE Type,
- IN EFI_MEMORY_TYPE MemoryType,
- IN UINTN NumberOfPages,
+ IN EFI_ALLOCATE_TYPE Type,
+ IN EFI_MEMORY_TYPE MemoryType,
+ IN UINTN NumberOfPages,
IN OUT EFI_PHYSICAL_ADDRESS *Memory
);
-
-
/**
Frees previous allocated pages.
@@ -56,11 +53,10 @@ CoreAllocatePages ( EFI_STATUS
EFIAPI
CoreFreePages (
- IN EFI_PHYSICAL_ADDRESS Memory,
- IN UINTN NumberOfPages
+ IN EFI_PHYSICAL_ADDRESS Memory,
+ IN UINTN NumberOfPages
);
-
/**
Allocate pool of a particular type.
@@ -94,7 +90,7 @@ CoreAllocatePool ( EFI_STATUS
EFIAPI
CoreFreePool (
- IN VOID *Buffer
+ IN VOID *Buffer
);
#endif
diff --git a/MdeModulePkg/Library/DxeCoreMemoryAllocationLib/DxeCoreMemoryProfileLib.c b/MdeModulePkg/Library/DxeCoreMemoryAllocationLib/DxeCoreMemoryProfileLib.c index 3ef31562c1..0e12669eaa 100644 --- a/MdeModulePkg/Library/DxeCoreMemoryAllocationLib/DxeCoreMemoryProfileLib.c +++ b/MdeModulePkg/Library/DxeCoreMemoryAllocationLib/DxeCoreMemoryProfileLib.c @@ -6,7 +6,6 @@ **/
-
#include <PiDxe.h>
#include <Guid/MemoryProfile.h>
@@ -38,14 +37,13 @@ EFI_STATUS
EFIAPI
MemoryProfileLibRecord (
- IN PHYSICAL_ADDRESS CallerAddress,
- IN MEMORY_PROFILE_ACTION Action,
- IN EFI_MEMORY_TYPE MemoryType,
- IN VOID *Buffer,
- IN UINTN Size,
- IN CHAR8 *ActionString OPTIONAL
+ IN PHYSICAL_ADDRESS CallerAddress,
+ IN MEMORY_PROFILE_ACTION Action,
+ IN EFI_MEMORY_TYPE MemoryType,
+ IN VOID *Buffer,
+ IN UINTN Size,
+ IN CHAR8 *ActionString OPTIONAL
)
{
return CoreUpdateProfile (CallerAddress, Action, MemoryType, Size, Buffer, ActionString);
}
-
diff --git a/MdeModulePkg/Library/DxeCoreMemoryAllocationLib/DxeCoreMemoryProfileLibNull.c b/MdeModulePkg/Library/DxeCoreMemoryAllocationLib/DxeCoreMemoryProfileLibNull.c index 42d4bd26f4..01f9210777 100644 --- a/MdeModulePkg/Library/DxeCoreMemoryAllocationLib/DxeCoreMemoryProfileLibNull.c +++ b/MdeModulePkg/Library/DxeCoreMemoryAllocationLib/DxeCoreMemoryProfileLibNull.c @@ -6,7 +6,6 @@ **/
-
#include <PiDxe.h>
#include <Guid/MemoryProfile.h>
@@ -36,14 +35,13 @@ EFI_STATUS
EFIAPI
MemoryProfileLibRecord (
- IN PHYSICAL_ADDRESS CallerAddress,
- IN MEMORY_PROFILE_ACTION Action,
- IN EFI_MEMORY_TYPE MemoryType,
- IN VOID *Buffer,
- IN UINTN Size,
- IN CHAR8 *ActionString OPTIONAL
+ IN PHYSICAL_ADDRESS CallerAddress,
+ IN MEMORY_PROFILE_ACTION Action,
+ IN EFI_MEMORY_TYPE MemoryType,
+ IN VOID *Buffer,
+ IN UINTN Size,
+ IN CHAR8 *ActionString OPTIONAL
)
{
return EFI_UNSUPPORTED;
}
-
diff --git a/MdeModulePkg/Library/DxeCoreMemoryAllocationLib/MemoryAllocationLib.c b/MdeModulePkg/Library/DxeCoreMemoryAllocationLib/MemoryAllocationLib.c index cecf2ddbe7..e813e87f24 100644 --- a/MdeModulePkg/Library/DxeCoreMemoryAllocationLib/MemoryAllocationLib.c +++ b/MdeModulePkg/Library/DxeCoreMemoryAllocationLib/MemoryAllocationLib.c @@ -8,10 +8,8 @@ **/
-
#include <PiDxe.h>
-
#include <Library/MemoryAllocationLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
@@ -49,7 +47,8 @@ InternalAllocatePages ( if (EFI_ERROR (Status)) {
return NULL;
}
- return (VOID *) (UINTN) Memory;
+
+ return (VOID *)(UINTN)Memory;
}
/**
@@ -76,7 +75,7 @@ AllocatePages ( Buffer = InternalAllocatePages (EfiBootServicesData, Pages);
if (Buffer != NULL) {
MemoryProfileLibRecord (
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
MEMORY_PROFILE_ACTION_LIB_ALLOCATE_PAGES,
EfiBootServicesData,
Buffer,
@@ -84,6 +83,7 @@ AllocatePages ( NULL
);
}
+
return Buffer;
}
@@ -111,7 +111,7 @@ AllocateRuntimePages ( Buffer = InternalAllocatePages (EfiRuntimeServicesData, Pages);
if (Buffer != NULL) {
MemoryProfileLibRecord (
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RUNTIME_PAGES,
EfiRuntimeServicesData,
Buffer,
@@ -119,6 +119,7 @@ AllocateRuntimePages ( NULL
);
}
+
return Buffer;
}
@@ -146,7 +147,7 @@ AllocateReservedPages ( Buffer = InternalAllocatePages (EfiReservedMemoryType, Pages);
if (Buffer != NULL) {
MemoryProfileLibRecord (
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RESERVED_PAGES,
EfiReservedMemoryType,
Buffer,
@@ -154,6 +155,7 @@ AllocateReservedPages ( NULL
);
}
+
return Buffer;
}
@@ -184,7 +186,7 @@ FreePages ( EFI_STATUS Status;
ASSERT (Pages != 0);
- Status = CoreFreePages ((EFI_PHYSICAL_ADDRESS) (UINTN) Buffer, Pages);
+ Status = CoreFreePages ((EFI_PHYSICAL_ADDRESS)(UINTN)Buffer, Pages);
ASSERT_EFI_ERROR (Status);
}
@@ -228,23 +230,25 @@ InternalAllocateAlignedPages ( if (Pages == 0) {
return NULL;
}
+
if (Alignment > EFI_PAGE_SIZE) {
//
// Calculate the total number of pages since alignment is larger than page size.
//
- AlignmentMask = Alignment - 1;
- RealPages = Pages + EFI_SIZE_TO_PAGES (Alignment);
+ AlignmentMask = Alignment - 1;
+ RealPages = Pages + EFI_SIZE_TO_PAGES (Alignment);
//
// Make sure that Pages plus EFI_SIZE_TO_PAGES (Alignment) does not overflow.
//
ASSERT (RealPages > Pages);
- Status = CoreAllocatePages (AllocateAnyPages, MemoryType, RealPages, &Memory);
+ Status = CoreAllocatePages (AllocateAnyPages, MemoryType, RealPages, &Memory);
if (EFI_ERROR (Status)) {
return NULL;
}
- AlignedMemory = ((UINTN) Memory + AlignmentMask) & ~AlignmentMask;
- UnalignedPages = EFI_SIZE_TO_PAGES (AlignedMemory - (UINTN) Memory);
+
+ AlignedMemory = ((UINTN)Memory + AlignmentMask) & ~AlignmentMask;
+ UnalignedPages = EFI_SIZE_TO_PAGES (AlignedMemory - (UINTN)Memory);
if (UnalignedPages > 0) {
//
// Free first unaligned page(s).
@@ -252,6 +256,7 @@ InternalAllocateAlignedPages ( Status = CoreFreePages (Memory, UnalignedPages);
ASSERT_EFI_ERROR (Status);
}
+
Memory = AlignedMemory + EFI_PAGES_TO_SIZE (Pages);
UnalignedPages = RealPages - Pages - UnalignedPages;
if (UnalignedPages > 0) {
@@ -269,9 +274,11 @@ InternalAllocateAlignedPages ( if (EFI_ERROR (Status)) {
return NULL;
}
- AlignedMemory = (UINTN) Memory;
+
+ AlignedMemory = (UINTN)Memory;
}
- return (VOID *) AlignedMemory;
+
+ return (VOID *)AlignedMemory;
}
/**
@@ -304,7 +311,7 @@ AllocateAlignedPages ( Buffer = InternalAllocateAlignedPages (EfiBootServicesData, Pages, Alignment);
if (Buffer != NULL) {
MemoryProfileLibRecord (
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
MEMORY_PROFILE_ACTION_LIB_ALLOCATE_ALIGNED_PAGES,
EfiBootServicesData,
Buffer,
@@ -312,6 +319,7 @@ AllocateAlignedPages ( NULL
);
}
+
return Buffer;
}
@@ -345,7 +353,7 @@ AllocateAlignedRuntimePages ( Buffer = InternalAllocateAlignedPages (EfiRuntimeServicesData, Pages, Alignment);
if (Buffer != NULL) {
MemoryProfileLibRecord (
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
MEMORY_PROFILE_ACTION_LIB_ALLOCATE_ALIGNED_RUNTIME_PAGES,
EfiRuntimeServicesData,
Buffer,
@@ -353,6 +361,7 @@ AllocateAlignedRuntimePages ( NULL
);
}
+
return Buffer;
}
@@ -386,7 +395,7 @@ AllocateAlignedReservedPages ( Buffer = InternalAllocateAlignedPages (EfiReservedMemoryType, Pages, Alignment);
if (Buffer != NULL) {
MemoryProfileLibRecord (
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
MEMORY_PROFILE_ACTION_LIB_ALLOCATE_ALIGNED_RESERVED_PAGES,
EfiReservedMemoryType,
Buffer,
@@ -394,6 +403,7 @@ AllocateAlignedReservedPages ( NULL
);
}
+
return Buffer;
}
@@ -424,7 +434,7 @@ FreeAlignedPages ( EFI_STATUS Status;
ASSERT (Pages != 0);
- Status = CoreFreePages ((EFI_PHYSICAL_ADDRESS) (UINTN) Buffer, Pages);
+ Status = CoreFreePages ((EFI_PHYSICAL_ADDRESS)(UINTN)Buffer, Pages);
ASSERT_EFI_ERROR (Status);
}
@@ -456,6 +466,7 @@ InternalAllocatePool ( if (EFI_ERROR (Status)) {
Memory = NULL;
}
+
return Memory;
}
@@ -482,7 +493,7 @@ AllocatePool ( Buffer = InternalAllocatePool (EfiBootServicesData, AllocationSize);
if (Buffer != NULL) {
MemoryProfileLibRecord (
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
MEMORY_PROFILE_ACTION_LIB_ALLOCATE_POOL,
EfiBootServicesData,
Buffer,
@@ -490,6 +501,7 @@ AllocatePool ( NULL
);
}
+
return Buffer;
}
@@ -516,7 +528,7 @@ AllocateRuntimePool ( Buffer = InternalAllocatePool (EfiRuntimeServicesData, AllocationSize);
if (Buffer != NULL) {
MemoryProfileLibRecord (
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RUNTIME_POOL,
EfiRuntimeServicesData,
Buffer,
@@ -524,6 +536,7 @@ AllocateRuntimePool ( NULL
);
}
+
return Buffer;
}
@@ -550,7 +563,7 @@ AllocateReservedPool ( Buffer = InternalAllocatePool (EfiReservedMemoryType, AllocationSize);
if (Buffer != NULL) {
MemoryProfileLibRecord (
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RESERVED_POOL,
EfiReservedMemoryType,
Buffer,
@@ -558,6 +571,7 @@ AllocateReservedPool ( NULL
);
}
+
return Buffer;
}
@@ -587,6 +601,7 @@ InternalAllocateZeroPool ( if (Memory != NULL) {
Memory = ZeroMem (Memory, AllocationSize);
}
+
return Memory;
}
@@ -614,7 +629,7 @@ AllocateZeroPool ( Buffer = InternalAllocateZeroPool (EfiBootServicesData, AllocationSize);
if (Buffer != NULL) {
MemoryProfileLibRecord (
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
MEMORY_PROFILE_ACTION_LIB_ALLOCATE_ZERO_POOL,
EfiBootServicesData,
Buffer,
@@ -622,6 +637,7 @@ AllocateZeroPool ( NULL
);
}
+
return Buffer;
}
@@ -649,7 +665,7 @@ AllocateRuntimeZeroPool ( Buffer = InternalAllocateZeroPool (EfiRuntimeServicesData, AllocationSize);
if (Buffer != NULL) {
MemoryProfileLibRecord (
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RUNTIME_ZERO_POOL,
EfiRuntimeServicesData,
Buffer,
@@ -657,6 +673,7 @@ AllocateRuntimeZeroPool ( NULL
);
}
+
return Buffer;
}
@@ -684,7 +701,7 @@ AllocateReservedZeroPool ( Buffer = InternalAllocateZeroPool (EfiReservedMemoryType, AllocationSize);
if (Buffer != NULL) {
MemoryProfileLibRecord (
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RESERVED_ZERO_POOL,
EfiReservedMemoryType,
Buffer,
@@ -692,6 +709,7 @@ AllocateReservedZeroPool ( NULL
);
}
+
return Buffer;
}
@@ -722,12 +740,13 @@ InternalAllocateCopyPool ( VOID *Memory;
ASSERT (Buffer != NULL);
- ASSERT (AllocationSize <= (MAX_ADDRESS - (UINTN) Buffer + 1));
+ ASSERT (AllocationSize <= (MAX_ADDRESS - (UINTN)Buffer + 1));
Memory = InternalAllocatePool (PoolType, AllocationSize);
if (Memory != NULL) {
- Memory = CopyMem (Memory, Buffer, AllocationSize);
+ Memory = CopyMem (Memory, Buffer, AllocationSize);
}
+
return Memory;
}
@@ -760,7 +779,7 @@ AllocateCopyPool ( NewBuffer = InternalAllocateCopyPool (EfiBootServicesData, AllocationSize, Buffer);
if (NewBuffer != NULL) {
MemoryProfileLibRecord (
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
MEMORY_PROFILE_ACTION_LIB_ALLOCATE_COPY_POOL,
EfiBootServicesData,
NewBuffer,
@@ -768,6 +787,7 @@ AllocateCopyPool ( NULL
);
}
+
return NewBuffer;
}
@@ -800,7 +820,7 @@ AllocateRuntimeCopyPool ( NewBuffer = InternalAllocateCopyPool (EfiRuntimeServicesData, AllocationSize, Buffer);
if (NewBuffer != NULL) {
MemoryProfileLibRecord (
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RUNTIME_COPY_POOL,
EfiRuntimeServicesData,
NewBuffer,
@@ -808,6 +828,7 @@ AllocateRuntimeCopyPool ( NULL
);
}
+
return NewBuffer;
}
@@ -840,7 +861,7 @@ AllocateReservedCopyPool ( NewBuffer = InternalAllocateCopyPool (EfiReservedMemoryType, AllocationSize, Buffer);
if (NewBuffer != NULL) {
MemoryProfileLibRecord (
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RESERVED_COPY_POOL,
EfiRuntimeServicesData,
NewBuffer,
@@ -848,6 +869,7 @@ AllocateReservedCopyPool ( NULL
);
}
+
return NewBuffer;
}
@@ -884,10 +906,11 @@ InternalReallocatePool ( VOID *NewBuffer;
NewBuffer = InternalAllocateZeroPool (PoolType, NewSize);
- if (NewBuffer != NULL && OldBuffer != NULL) {
+ if ((NewBuffer != NULL) && (OldBuffer != NULL)) {
CopyMem (NewBuffer, OldBuffer, MIN (OldSize, NewSize));
FreePool (OldBuffer);
}
+
return NewBuffer;
}
@@ -925,7 +948,7 @@ ReallocatePool ( Buffer = InternalReallocatePool (EfiBootServicesData, OldSize, NewSize, OldBuffer);
if (Buffer != NULL) {
MemoryProfileLibRecord (
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
MEMORY_PROFILE_ACTION_LIB_REALLOCATE_POOL,
EfiBootServicesData,
Buffer,
@@ -933,6 +956,7 @@ ReallocatePool ( NULL
);
}
+
return Buffer;
}
@@ -970,7 +994,7 @@ ReallocateRuntimePool ( Buffer = InternalReallocatePool (EfiRuntimeServicesData, OldSize, NewSize, OldBuffer);
if (Buffer != NULL) {
MemoryProfileLibRecord (
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
MEMORY_PROFILE_ACTION_LIB_REALLOCATE_RUNTIME_POOL,
EfiRuntimeServicesData,
Buffer,
@@ -978,6 +1002,7 @@ ReallocateRuntimePool ( NULL
);
}
+
return Buffer;
}
@@ -1015,7 +1040,7 @@ ReallocateReservedPool ( Buffer = InternalReallocatePool (EfiReservedMemoryType, OldSize, NewSize, OldBuffer);
if (Buffer != NULL) {
MemoryProfileLibRecord (
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
MEMORY_PROFILE_ACTION_LIB_REALLOCATE_RESERVED_POOL,
EfiReservedMemoryType,
Buffer,
@@ -1023,6 +1048,7 @@ ReallocateReservedPool ( NULL
);
}
+
return Buffer;
}
@@ -1043,12 +1069,11 @@ ReallocateReservedPool ( VOID
EFIAPI
FreePool (
- IN VOID *Buffer
+ IN VOID *Buffer
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
Status = CoreFreePool (Buffer);
ASSERT_EFI_ERROR (Status);
}
-
diff --git a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c index eb9cea5011..ef14bc0738 100644 --- a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c +++ b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c @@ -16,19 +16,18 @@ SPDX-License-Identifier: BSD-2-Clause-Patent **/
-
#include "DxeCorePerformanceLibInternal.h"
//
// Data for FPDT performance records.
//
-#define SMM_BOOT_RECORD_COMM_SIZE (OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data) + sizeof(SMM_BOOT_RECORD_COMMUNICATE))
-#define STRING_SIZE (FPDT_STRING_EVENT_RECORD_NAME_LENGTH * sizeof (CHAR8))
-#define FIRMWARE_RECORD_BUFFER 0x10000
-#define CACHE_HANDLE_GUID_COUNT 0x800
+#define SMM_BOOT_RECORD_COMM_SIZE (OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data) + sizeof(SMM_BOOT_RECORD_COMMUNICATE))
+#define STRING_SIZE (FPDT_STRING_EVENT_RECORD_NAME_LENGTH * sizeof (CHAR8))
+#define FIRMWARE_RECORD_BUFFER 0x10000
+#define CACHE_HANDLE_GUID_COUNT 0x800
-BOOT_PERFORMANCE_TABLE *mAcpiBootPerformanceTable = NULL;
-BOOT_PERFORMANCE_TABLE mBootPerformanceTableTemplate = {
+BOOT_PERFORMANCE_TABLE *mAcpiBootPerformanceTable = NULL;
+BOOT_PERFORMANCE_TABLE mBootPerformanceTableTemplate = {
{
EFI_ACPI_5_0_FPDT_BOOT_PERFORMANCE_TABLE_SIGNATURE,
sizeof (BOOT_PERFORMANCE_TABLE)
@@ -57,8 +56,8 @@ typedef struct { EFI_GUID ModuleGuid;
} HANDLE_GUID_MAP;
-HANDLE_GUID_MAP mCacheHandleGuidTable[CACHE_HANDLE_GUID_COUNT];
-UINTN mCachePairCount = 0;
+HANDLE_GUID_MAP mCacheHandleGuidTable[CACHE_HANDLE_GUID_COUNT];
+UINTN mCachePairCount = 0;
UINT32 mLoadImageCount = 0;
UINT32 mPerformanceLength = 0;
@@ -67,22 +66,22 @@ UINT32 mBootRecordSize = 0; UINTN mBootRecordMaxSize = 0;
UINT32 mCachedLength = 0;
-BOOLEAN mFpdtBufferIsReported = FALSE;
-BOOLEAN mLackSpaceIsReported = FALSE;
-CHAR8 *mPlatformLanguage = NULL;
-UINT8 *mPerformancePointer = NULL;
-UINT8 *mBootRecordBuffer = NULL;
-BOOLEAN mLockInsertRecord = FALSE;
-CHAR8 *mDevicePathString = NULL;
+BOOLEAN mFpdtBufferIsReported = FALSE;
+BOOLEAN mLackSpaceIsReported = FALSE;
+CHAR8 *mPlatformLanguage = NULL;
+UINT8 *mPerformancePointer = NULL;
+UINT8 *mBootRecordBuffer = NULL;
+BOOLEAN mLockInsertRecord = FALSE;
+CHAR8 *mDevicePathString = NULL;
EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *mDevicePathToText = NULL;
//
// Interfaces for PerformanceMeasurement Protocol.
//
-EDKII_PERFORMANCE_MEASUREMENT_PROTOCOL mPerformanceMeasurementInterface = {
+EDKII_PERFORMANCE_MEASUREMENT_PROTOCOL mPerformanceMeasurementInterface = {
CreatePerformanceMeasurement,
- };
+};
PERFORMANCE_PROPERTY mPerformanceProperty;
@@ -97,9 +96,9 @@ PERFORMANCE_PROPERTY mPerformanceProperty; **/
EFI_STATUS
GetFpdtRecordPtr (
- IN UINT8 RecordSize,
- IN OUT FPDT_RECORD_PTR *FpdtRecordPtr
-)
+ IN UINT8 RecordSize,
+ IN OUT FPDT_RECORD_PTR *FpdtRecordPtr
+ )
{
if (mFpdtBufferIsReported) {
//
@@ -110,6 +109,7 @@ GetFpdtRecordPtr ( DEBUG ((DEBUG_INFO, "DxeCorePerformanceLib: No enough space to save boot records\n"));
mLackSpaceIsReported = TRUE;
}
+
return EFI_OUT_OF_RESOURCES;
} else {
//
@@ -128,15 +128,18 @@ GetFpdtRecordPtr ( mPerformancePointer
);
if (mPerformancePointer == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
+ return EFI_OUT_OF_RESOURCES;
+ }
+
mMaxPerformanceLength = mPerformanceLength + RecordSize + FIRMWARE_RECORD_BUFFER;
}
+
//
// Covert buffer to FPDT Ptr Union type.
//
FpdtRecordPtr->RecordHeader = (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER *)(mPerformancePointer + mPerformanceLength);
}
+
return EFI_SUCCESS;
}
@@ -158,16 +161,17 @@ IsKnownTokens ( return FALSE;
}
- if (AsciiStrCmp (Token, SEC_TOK) == 0 ||
- AsciiStrCmp (Token, PEI_TOK) == 0 ||
- AsciiStrCmp (Token, DXE_TOK) == 0 ||
- AsciiStrCmp (Token, BDS_TOK) == 0 ||
- AsciiStrCmp (Token, DRIVERBINDING_START_TOK) == 0 ||
- AsciiStrCmp (Token, DRIVERBINDING_SUPPORT_TOK) == 0 ||
- AsciiStrCmp (Token, DRIVERBINDING_STOP_TOK) == 0 ||
- AsciiStrCmp (Token, LOAD_IMAGE_TOK) == 0 ||
- AsciiStrCmp (Token, START_IMAGE_TOK) == 0 ||
- AsciiStrCmp (Token, PEIM_TOK) == 0) {
+ if ((AsciiStrCmp (Token, SEC_TOK) == 0) ||
+ (AsciiStrCmp (Token, PEI_TOK) == 0) ||
+ (AsciiStrCmp (Token, DXE_TOK) == 0) ||
+ (AsciiStrCmp (Token, BDS_TOK) == 0) ||
+ (AsciiStrCmp (Token, DRIVERBINDING_START_TOK) == 0) ||
+ (AsciiStrCmp (Token, DRIVERBINDING_SUPPORT_TOK) == 0) ||
+ (AsciiStrCmp (Token, DRIVERBINDING_STOP_TOK) == 0) ||
+ (AsciiStrCmp (Token, LOAD_IMAGE_TOK) == 0) ||
+ (AsciiStrCmp (Token, START_IMAGE_TOK) == 0) ||
+ (AsciiStrCmp (Token, PEIM_TOK) == 0))
+ {
return TRUE;
} else {
return FALSE;
@@ -185,19 +189,20 @@ Check whether the ID is a known one which map to the known Token. **/
BOOLEAN
IsKnownID (
- IN UINT32 Identifier
+ IN UINT32 Identifier
)
{
- if (Identifier == MODULE_START_ID ||
- Identifier == MODULE_END_ID ||
- Identifier == MODULE_LOADIMAGE_START_ID ||
- Identifier == MODULE_LOADIMAGE_END_ID ||
- Identifier == MODULE_DB_START_ID ||
- Identifier == MODULE_DB_END_ID ||
- Identifier == MODULE_DB_SUPPORT_START_ID ||
- Identifier == MODULE_DB_SUPPORT_END_ID ||
- Identifier == MODULE_DB_STOP_START_ID ||
- Identifier == MODULE_DB_STOP_END_ID) {
+ if ((Identifier == MODULE_START_ID) ||
+ (Identifier == MODULE_END_ID) ||
+ (Identifier == MODULE_LOADIMAGE_START_ID) ||
+ (Identifier == MODULE_LOADIMAGE_END_ID) ||
+ (Identifier == MODULE_DB_START_ID) ||
+ (Identifier == MODULE_DB_END_ID) ||
+ (Identifier == MODULE_DB_SUPPORT_START_ID) ||
+ (Identifier == MODULE_DB_SUPPORT_END_ID) ||
+ (Identifier == MODULE_DB_STOP_START_ID) ||
+ (Identifier == MODULE_DB_STOP_END_ID))
+ {
return TRUE;
} else {
return FALSE;
@@ -214,23 +219,23 @@ IsKnownID ( **/
VOID
InternalGetSmmPerfData (
- OUT VOID **SmmPerfData,
- OUT UINTN *SmmPerfDataSize,
- IN BOOLEAN SkipGetPerfData
+ OUT VOID **SmmPerfData,
+ OUT UINTN *SmmPerfDataSize,
+ IN BOOLEAN SkipGetPerfData
)
{
- EFI_STATUS Status;
- UINT8 *SmmBootRecordCommBuffer;
- EFI_SMM_COMMUNICATE_HEADER *SmmCommBufferHeader;
- SMM_BOOT_RECORD_COMMUNICATE *SmmCommData;
- UINTN CommSize;
- EFI_SMM_COMMUNICATION_PROTOCOL *Communication;
- EDKII_PI_SMM_COMMUNICATION_REGION_TABLE *SmmCommRegionTable;
- EFI_MEMORY_DESCRIPTOR *SmmCommMemRegion;
- UINTN Index;
- VOID *SmmBootRecordData;
- UINTN SmmBootRecordDataSize;
- UINTN ReservedMemSize;
+ EFI_STATUS Status;
+ UINT8 *SmmBootRecordCommBuffer;
+ EFI_SMM_COMMUNICATE_HEADER *SmmCommBufferHeader;
+ SMM_BOOT_RECORD_COMMUNICATE *SmmCommData;
+ UINTN CommSize;
+ EFI_SMM_COMMUNICATION_PROTOCOL *Communication;
+ EDKII_PI_SMM_COMMUNICATION_REGION_TABLE *SmmCommRegionTable;
+ EFI_MEMORY_DESCRIPTOR *SmmCommMemRegion;
+ UINTN Index;
+ VOID *SmmBootRecordData;
+ UINTN SmmBootRecordDataSize;
+ UINTN ReservedMemSize;
//
// Collect boot records from SMM drivers.
@@ -239,76 +244,81 @@ InternalGetSmmPerfData ( SmmCommData = NULL;
SmmBootRecordData = NULL;
ReservedMemSize = 0;
- Status = gBS->LocateProtocol (&gEfiSmmCommunicationProtocolGuid, NULL, (VOID **) &Communication);
+ Status = gBS->LocateProtocol (&gEfiSmmCommunicationProtocolGuid, NULL, (VOID **)&Communication);
if (!EFI_ERROR (Status)) {
//
// Initialize communicate buffer
// Get the prepared Reserved Memory Range
//
Status = EfiGetSystemConfigurationTable (
- &gEdkiiPiSmmCommunicationRegionTableGuid,
- (VOID **) &SmmCommRegionTable
- );
+ &gEdkiiPiSmmCommunicationRegionTableGuid,
+ (VOID **)&SmmCommRegionTable
+ );
if (!EFI_ERROR (Status)) {
ASSERT (SmmCommRegionTable != NULL);
- SmmCommMemRegion = (EFI_MEMORY_DESCRIPTOR *) (SmmCommRegionTable + 1);
- for (Index = 0; Index < SmmCommRegionTable->NumberOfEntries; Index ++) {
+ SmmCommMemRegion = (EFI_MEMORY_DESCRIPTOR *)(SmmCommRegionTable + 1);
+ for (Index = 0; Index < SmmCommRegionTable->NumberOfEntries; Index++) {
if (SmmCommMemRegion->Type == EfiConventionalMemory) {
break;
}
- SmmCommMemRegion = (EFI_MEMORY_DESCRIPTOR *) ((UINT8 *) SmmCommMemRegion + SmmCommRegionTable->DescriptorSize);
+
+ SmmCommMemRegion = (EFI_MEMORY_DESCRIPTOR *)((UINT8 *)SmmCommMemRegion + SmmCommRegionTable->DescriptorSize);
}
+
ASSERT (Index < SmmCommRegionTable->NumberOfEntries);
ASSERT (SmmCommMemRegion->PhysicalStart > 0);
ASSERT (SmmCommMemRegion->NumberOfPages > 0);
- ReservedMemSize = (UINTN) SmmCommMemRegion->NumberOfPages * EFI_PAGE_SIZE;
+ ReservedMemSize = (UINTN)SmmCommMemRegion->NumberOfPages * EFI_PAGE_SIZE;
//
// Check enough reserved memory space
//
if (ReservedMemSize > SMM_BOOT_RECORD_COMM_SIZE) {
- SmmBootRecordCommBuffer = (VOID *) (UINTN) SmmCommMemRegion->PhysicalStart;
- SmmCommBufferHeader = (EFI_SMM_COMMUNICATE_HEADER*)SmmBootRecordCommBuffer;
- SmmCommData = (SMM_BOOT_RECORD_COMMUNICATE*)SmmCommBufferHeader->Data;
- ZeroMem((UINT8*)SmmCommData, sizeof(SMM_BOOT_RECORD_COMMUNICATE));
+ SmmBootRecordCommBuffer = (VOID *)(UINTN)SmmCommMemRegion->PhysicalStart;
+ SmmCommBufferHeader = (EFI_SMM_COMMUNICATE_HEADER *)SmmBootRecordCommBuffer;
+ SmmCommData = (SMM_BOOT_RECORD_COMMUNICATE *)SmmCommBufferHeader->Data;
+ ZeroMem ((UINT8 *)SmmCommData, sizeof (SMM_BOOT_RECORD_COMMUNICATE));
CopyGuid (&SmmCommBufferHeader->HeaderGuid, &gEfiFirmwarePerformanceGuid);
- SmmCommBufferHeader->MessageLength = sizeof(SMM_BOOT_RECORD_COMMUNICATE);
- CommSize = SMM_BOOT_RECORD_COMM_SIZE;
+ SmmCommBufferHeader->MessageLength = sizeof (SMM_BOOT_RECORD_COMMUNICATE);
+ CommSize = SMM_BOOT_RECORD_COMM_SIZE;
//
// Get the size of boot records.
//
SmmCommData->Function = SMM_FPDT_FUNCTION_GET_BOOT_RECORD_SIZE;
SmmCommData->BootRecordData = NULL;
- Status = Communication->Communicate (Communication, SmmBootRecordCommBuffer, &CommSize);
+ Status = Communication->Communicate (Communication, SmmBootRecordCommBuffer, &CommSize);
- if (!EFI_ERROR (Status) && !EFI_ERROR (SmmCommData->ReturnStatus) && SmmCommData->BootRecordSize != 0) {
+ if (!EFI_ERROR (Status) && !EFI_ERROR (SmmCommData->ReturnStatus) && (SmmCommData->BootRecordSize != 0)) {
if (SkipGetPerfData) {
*SmmPerfDataSize = SmmCommData->BootRecordSize;
return;
}
+
//
// Get all boot records
//
- SmmCommData->Function = SMM_FPDT_FUNCTION_GET_BOOT_RECORD_DATA_BY_OFFSET;
- SmmBootRecordDataSize = SmmCommData->BootRecordSize;
- SmmBootRecordData = AllocateZeroPool(SmmBootRecordDataSize);
+ SmmCommData->Function = SMM_FPDT_FUNCTION_GET_BOOT_RECORD_DATA_BY_OFFSET;
+ SmmBootRecordDataSize = SmmCommData->BootRecordSize;
+ SmmBootRecordData = AllocateZeroPool (SmmBootRecordDataSize);
ASSERT (SmmBootRecordData != NULL);
SmmCommData->BootRecordOffset = 0;
- SmmCommData->BootRecordData = (VOID *) ((UINTN) SmmCommMemRegion->PhysicalStart + SMM_BOOT_RECORD_COMM_SIZE);
+ SmmCommData->BootRecordData = (VOID *)((UINTN)SmmCommMemRegion->PhysicalStart + SMM_BOOT_RECORD_COMM_SIZE);
SmmCommData->BootRecordSize = ReservedMemSize - SMM_BOOT_RECORD_COMM_SIZE;
while (SmmCommData->BootRecordOffset < SmmBootRecordDataSize) {
Status = Communication->Communicate (Communication, SmmBootRecordCommBuffer, &CommSize);
ASSERT_EFI_ERROR (Status);
- ASSERT_EFI_ERROR(SmmCommData->ReturnStatus);
+ ASSERT_EFI_ERROR (SmmCommData->ReturnStatus);
if (SmmCommData->BootRecordOffset + SmmCommData->BootRecordSize > SmmBootRecordDataSize) {
- CopyMem ((UINT8 *) SmmBootRecordData + SmmCommData->BootRecordOffset, SmmCommData->BootRecordData, SmmBootRecordDataSize - SmmCommData->BootRecordOffset);
+ CopyMem ((UINT8 *)SmmBootRecordData + SmmCommData->BootRecordOffset, SmmCommData->BootRecordData, SmmBootRecordDataSize - SmmCommData->BootRecordOffset);
} else {
- CopyMem ((UINT8 *) SmmBootRecordData + SmmCommData->BootRecordOffset, SmmCommData->BootRecordData, SmmCommData->BootRecordSize);
+ CopyMem ((UINT8 *)SmmBootRecordData + SmmCommData->BootRecordOffset, SmmCommData->BootRecordData, SmmCommData->BootRecordSize);
}
+
SmmCommData->BootRecordOffset = SmmCommData->BootRecordOffset + SmmCommData->BootRecordSize;
}
+
*SmmPerfData = SmmBootRecordData;
*SmmPerfDataSize = SmmBootRecordDataSize;
}
@@ -328,12 +338,12 @@ AllocateBootPerformanceTable ( VOID
)
{
- EFI_STATUS Status;
- UINTN Size;
- UINTN BootPerformanceDataSize;
- UINT8 *BootPerformanceData;
- FIRMWARE_PERFORMANCE_VARIABLE PerformanceVariable;
- UINTN SmmBootRecordDataSize;
+ EFI_STATUS Status;
+ UINTN Size;
+ UINTN BootPerformanceDataSize;
+ UINT8 *BootPerformanceData;
+ FIRMWARE_PERFORMANCE_VARIABLE PerformanceVariable;
+ UINTN SmmBootRecordDataSize;
SmmBootRecordDataSize = 0;
@@ -353,7 +363,7 @@ AllocateBootPerformanceTable ( // Try to allocate the same runtime buffer as last time boot.
//
ZeroMem (&PerformanceVariable, sizeof (PerformanceVariable));
- Size = sizeof (PerformanceVariable);
+ Size = sizeof (PerformanceVariable);
Status = gRT->GetVariable (
EFI_FIRMWARE_PERFORMANCE_VARIABLE_NAME,
&gEfiFirmwarePerformanceGuid,
@@ -369,7 +379,7 @@ AllocateBootPerformanceTable ( &PerformanceVariable.BootPerformanceTablePointer
);
if (!EFI_ERROR (Status)) {
- mAcpiBootPerformanceTable = (BOOT_PERFORMANCE_TABLE *) (UINTN) PerformanceVariable.BootPerformanceTablePointer;
+ mAcpiBootPerformanceTable = (BOOT_PERFORMANCE_TABLE *)(UINTN)PerformanceVariable.BootPerformanceTablePointer;
}
}
@@ -377,14 +387,15 @@ AllocateBootPerformanceTable ( //
// Fail to allocate at specified address, continue to allocate at any address.
//
- mAcpiBootPerformanceTable = (BOOT_PERFORMANCE_TABLE *) AllocatePeiAccessiblePages (
- EfiReservedMemoryType,
- EFI_SIZE_TO_PAGES (BootPerformanceDataSize)
- );
+ mAcpiBootPerformanceTable = (BOOT_PERFORMANCE_TABLE *)AllocatePeiAccessiblePages (
+ EfiReservedMemoryType,
+ EFI_SIZE_TO_PAGES (BootPerformanceDataSize)
+ );
if (mAcpiBootPerformanceTable != NULL) {
ZeroMem (mAcpiBootPerformanceTable, BootPerformanceDataSize);
}
}
+
DEBUG ((DEBUG_INFO, "DxeCorePerformanceLib: ACPI Boot Performance Table address = 0x%x\n", mAcpiBootPerformanceTable));
if (mAcpiBootPerformanceTable == NULL) {
@@ -394,7 +405,7 @@ AllocateBootPerformanceTable ( //
// Prepare Boot Performance Table.
//
- BootPerformanceData = (UINT8 *) mAcpiBootPerformanceTable;
+ BootPerformanceData = (UINT8 *)mAcpiBootPerformanceTable;
//
// Fill Basic Boot record to Boot Performance Table.
//
@@ -406,14 +417,14 @@ AllocateBootPerformanceTable ( if (mPerformancePointer != NULL) {
CopyMem (BootPerformanceData, mPerformancePointer, mPerformanceLength);
mAcpiBootPerformanceTable->Header.Length += mPerformanceLength;
- BootPerformanceData = BootPerformanceData + mPerformanceLength;
+ BootPerformanceData = BootPerformanceData + mPerformanceLength;
FreePool (mPerformancePointer);
mPerformancePointer = NULL;
mPerformanceLength = 0;
mMaxPerformanceLength = 0;
}
- mBootRecordBuffer = (UINT8 *) mAcpiBootPerformanceTable;
+ mBootRecordBuffer = (UINT8 *)mAcpiBootPerformanceTable;
mBootRecordSize = mAcpiBootPerformanceTable->Header.Length;
mBootRecordMaxSize = BootPerformanceDataSize;
@@ -437,28 +448,29 @@ AllocateBootPerformanceTable ( EFI_STATUS
GetModuleInfoFromHandle (
IN EFI_HANDLE Handle,
- OUT CHAR8 *NameString,
- IN UINTN BufferSize,
- OUT EFI_GUID *ModuleGuid OPTIONAL
+ OUT CHAR8 *NameString,
+ IN UINTN BufferSize,
+ OUT EFI_GUID *ModuleGuid OPTIONAL
)
{
- EFI_STATUS Status;
- EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
- EFI_DRIVER_BINDING_PROTOCOL *DriverBinding;
- CHAR8 *PdbFileName;
- EFI_GUID *TempGuid;
- UINTN StartIndex;
- UINTN Index;
- INTN Count;
- BOOLEAN ModuleGuidIsGet;
- UINTN StringSize;
- CHAR16 *StringPtr;
- EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2;
- MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvFilePath;
-
- if (NameString == NULL || BufferSize == 0) {
+ EFI_STATUS Status;
+ EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
+ EFI_DRIVER_BINDING_PROTOCOL *DriverBinding;
+ CHAR8 *PdbFileName;
+ EFI_GUID *TempGuid;
+ UINTN StartIndex;
+ UINTN Index;
+ INTN Count;
+ BOOLEAN ModuleGuidIsGet;
+ UINTN StringSize;
+ CHAR16 *StringPtr;
+ EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2;
+ MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvFilePath;
+
+ if ((NameString == NULL) || (BufferSize == 0)) {
return EFI_INVALID_PARAMETER;
}
+
//
// Try to get the ModuleGuid and name string form the caached array.
//
@@ -472,14 +484,14 @@ GetModuleInfoFromHandle ( }
}
- Status = EFI_INVALID_PARAMETER;
+ Status = EFI_INVALID_PARAMETER;
LoadedImage = NULL;
ModuleGuidIsGet = FALSE;
//
// Initialize GUID as zero value.
//
- TempGuid = &gZeroGuid;
+ TempGuid = &gZeroGuid;
//
// Initialize it as "" string.
//
@@ -490,49 +502,50 @@ GetModuleInfoFromHandle ( // Try Handle as ImageHandle.
//
Status = gBS->HandleProtocol (
- Handle,
- &gEfiLoadedImageProtocolGuid,
- (VOID**) &LoadedImage
- );
+ Handle,
+ &gEfiLoadedImageProtocolGuid,
+ (VOID **)&LoadedImage
+ );
if (EFI_ERROR (Status)) {
//
// Try Handle as Controller Handle
//
Status = gBS->OpenProtocol (
- Handle,
- &gEfiDriverBindingProtocolGuid,
- (VOID **) &DriverBinding,
- NULL,
- NULL,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
+ Handle,
+ &gEfiDriverBindingProtocolGuid,
+ (VOID **)&DriverBinding,
+ NULL,
+ NULL,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL
+ );
if (!EFI_ERROR (Status)) {
//
// Get Image protocol from ImageHandle
//
Status = gBS->HandleProtocol (
- DriverBinding->ImageHandle,
- &gEfiLoadedImageProtocolGuid,
- (VOID**) &LoadedImage
- );
+ DriverBinding->ImageHandle,
+ &gEfiLoadedImageProtocolGuid,
+ (VOID **)&LoadedImage
+ );
}
}
}
- if (!EFI_ERROR (Status) && LoadedImage != NULL) {
+ if (!EFI_ERROR (Status) && (LoadedImage != NULL)) {
//
// Get Module Guid from DevicePath.
//
- if (LoadedImage->FilePath != NULL &&
- LoadedImage->FilePath->Type == MEDIA_DEVICE_PATH &&
- LoadedImage->FilePath->SubType == MEDIA_PIWG_FW_FILE_DP
- ) {
+ if ((LoadedImage->FilePath != NULL) &&
+ (LoadedImage->FilePath->Type == MEDIA_DEVICE_PATH) &&
+ (LoadedImage->FilePath->SubType == MEDIA_PIWG_FW_FILE_DP)
+ )
+ {
//
// Determine GUID associated with module logging performance
//
ModuleGuidIsGet = TRUE;
- FvFilePath = (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) LoadedImage->FilePath;
+ FvFilePath = (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *)LoadedImage->FilePath;
TempGuid = &FvFilePath->FvFileName;
}
@@ -540,20 +553,21 @@ GetModuleInfoFromHandle ( // Method 1 Get Module Name from PDB string.
//
PdbFileName = PeCoffLoaderGetPdbPointer (LoadedImage->ImageBase);
- if (PdbFileName != NULL && BufferSize > 0) {
+ if ((PdbFileName != NULL) && (BufferSize > 0)) {
StartIndex = 0;
for (Index = 0; PdbFileName[Index] != 0; Index++) {
if ((PdbFileName[Index] == '\\') || (PdbFileName[Index] == '/')) {
StartIndex = Index + 1;
}
}
+
//
// Copy the PDB file name to our temporary string.
// If the length is bigger than BufferSize, trim the redudant characters to avoid overflow in array boundary.
//
for (Index = 0; Index < BufferSize - 1; Index++) {
NameString[Index] = PdbFileName[Index + StartIndex];
- if (NameString[Index] == 0 || NameString[Index] == '.') {
+ if ((NameString[Index] == 0) || (NameString[Index] == '.')) {
NameString[Index] = 0;
break;
}
@@ -562,6 +576,7 @@ GetModuleInfoFromHandle ( if (Index == BufferSize - 1) {
NameString[Index] = 0;
}
+
//
// Module Name is got.
//
@@ -575,15 +590,16 @@ GetModuleInfoFromHandle ( Status = gBS->HandleProtocol (
Handle,
&gEfiComponentName2ProtocolGuid,
- (VOID **) &ComponentName2
+ (VOID **)&ComponentName2
);
if (!EFI_ERROR (Status)) {
//
// Get the current platform language setting
//
if (mPlatformLanguage == NULL) {
- GetEfiGlobalVariable2 (L"PlatformLang", (VOID **) &mPlatformLanguage, NULL);
+ GetEfiGlobalVariable2 (L"PlatformLang", (VOID **)&mPlatformLanguage, NULL);
}
+
if (mPlatformLanguage != NULL) {
Status = ComponentName2->GetDriverName (
ComponentName2,
@@ -592,8 +608,9 @@ GetModuleInfoFromHandle ( );
if (!EFI_ERROR (Status)) {
for (Index = 0; Index < BufferSize - 1 && StringPtr[Index] != 0; Index++) {
- NameString[Index] = (CHAR8) StringPtr[Index];
+ NameString[Index] = (CHAR8)StringPtr[Index];
}
+
NameString[Index] = 0;
//
// Module Name is got.
@@ -609,21 +626,22 @@ GetModuleInfoFromHandle ( //
StringPtr = NULL;
StringSize = 0;
- Status = GetSectionFromAnyFv (
- TempGuid,
- EFI_SECTION_USER_INTERFACE,
- 0,
- (VOID **) &StringPtr,
- &StringSize
- );
+ Status = GetSectionFromAnyFv (
+ TempGuid,
+ EFI_SECTION_USER_INTERFACE,
+ 0,
+ (VOID **)&StringPtr,
+ &StringSize
+ );
if (!EFI_ERROR (Status)) {
//
// Method 3. Get the name string from FFS UI section
//
for (Index = 0; Index < BufferSize - 1 && StringPtr[Index] != 0; Index++) {
- NameString[Index] = (CHAR8) StringPtr[Index];
+ NameString[Index] = (CHAR8)StringPtr[Index];
}
+
NameString[Index] = 0;
FreePool (StringPtr);
}
@@ -635,9 +653,9 @@ Done: //
if (ModuleGuid != NULL) {
CopyGuid (ModuleGuid, TempGuid);
- if (IsZeroGuid(TempGuid) && (Handle != NULL) && !ModuleGuidIsGet) {
- // Handle is GUID
- CopyGuid (ModuleGuid, (EFI_GUID *) Handle);
+ if (IsZeroGuid (TempGuid) && (Handle != NULL) && !ModuleGuidIsGet) {
+ // Handle is GUID
+ CopyGuid (ModuleGuid, (EFI_GUID *)Handle);
}
}
@@ -648,7 +666,7 @@ Done: mCacheHandleGuidTable[mCachePairCount].Handle = Handle;
CopyGuid (&mCacheHandleGuidTable[mCachePairCount].ModuleGuid, ModuleGuid);
AsciiStrCpyS (mCacheHandleGuidTable[mCachePairCount].NameString, FPDT_STRING_EVENT_RECORD_NAME_LENGTH, NameString);
- mCachePairCount ++;
+ mCachePairCount++;
}
return Status;
@@ -671,75 +689,86 @@ Done: EFI_STATUS
GetFpdtRecordId (
IN PERF_MEASUREMENT_ATTRIBUTE Attribute,
- IN CONST VOID *Handle,
- IN CONST CHAR8 *String,
- OUT UINT16 *ProgressID
+ IN CONST VOID *Handle,
+ IN CONST CHAR8 *String,
+ OUT UINT16 *ProgressID
)
{
//
// Token to PerfId.
//
if (String != NULL) {
- if (AsciiStrCmp (String, START_IMAGE_TOK) == 0) { // "StartImage:"
+ if (AsciiStrCmp (String, START_IMAGE_TOK) == 0) {
+ // "StartImage:"
if (Attribute == PerfStartEntry) {
- *ProgressID = MODULE_START_ID;
+ *ProgressID = MODULE_START_ID;
} else {
- *ProgressID = MODULE_END_ID;
+ *ProgressID = MODULE_END_ID;
}
- } else if (AsciiStrCmp (String, LOAD_IMAGE_TOK) == 0) { // "LoadImage:"
+ } else if (AsciiStrCmp (String, LOAD_IMAGE_TOK) == 0) {
+ // "LoadImage:"
if (Attribute == PerfStartEntry) {
- *ProgressID = MODULE_LOADIMAGE_START_ID;
+ *ProgressID = MODULE_LOADIMAGE_START_ID;
} else {
- *ProgressID = MODULE_LOADIMAGE_END_ID;
+ *ProgressID = MODULE_LOADIMAGE_END_ID;
}
- } else if (AsciiStrCmp (String, DRIVERBINDING_START_TOK) == 0) { // "DB:Start:"
+ } else if (AsciiStrCmp (String, DRIVERBINDING_START_TOK) == 0) {
+ // "DB:Start:"
if (Attribute == PerfStartEntry) {
- *ProgressID = MODULE_DB_START_ID;
+ *ProgressID = MODULE_DB_START_ID;
} else {
- *ProgressID = MODULE_DB_END_ID;
+ *ProgressID = MODULE_DB_END_ID;
}
- } else if (AsciiStrCmp (String, DRIVERBINDING_SUPPORT_TOK) == 0) { // "DB:Support:"
+ } else if (AsciiStrCmp (String, DRIVERBINDING_SUPPORT_TOK) == 0) {
+ // "DB:Support:"
if (PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
return RETURN_UNSUPPORTED;
}
+
if (Attribute == PerfStartEntry) {
- *ProgressID = MODULE_DB_SUPPORT_START_ID;
+ *ProgressID = MODULE_DB_SUPPORT_START_ID;
} else {
- *ProgressID = MODULE_DB_SUPPORT_END_ID;
+ *ProgressID = MODULE_DB_SUPPORT_END_ID;
}
- } else if (AsciiStrCmp (String, DRIVERBINDING_STOP_TOK) == 0) { // "DB:Stop:"
+ } else if (AsciiStrCmp (String, DRIVERBINDING_STOP_TOK) == 0) {
+ // "DB:Stop:"
if (PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
- return RETURN_UNSUPPORTED;
+ return RETURN_UNSUPPORTED;
}
+
if (Attribute == PerfStartEntry) {
- *ProgressID = MODULE_DB_STOP_START_ID;
+ *ProgressID = MODULE_DB_STOP_START_ID;
} else {
- *ProgressID = MODULE_DB_STOP_END_ID;
+ *ProgressID = MODULE_DB_STOP_END_ID;
}
- } else if (AsciiStrCmp (String, PEI_TOK) == 0 || // "PEI"
- AsciiStrCmp (String, DXE_TOK) == 0 || // "DXE"
- AsciiStrCmp (String, BDS_TOK) == 0) { // "BDS"
+ } else if ((AsciiStrCmp (String, PEI_TOK) == 0) || // "PEI"
+ (AsciiStrCmp (String, DXE_TOK) == 0) || // "DXE"
+ (AsciiStrCmp (String, BDS_TOK) == 0)) // "BDS"
+ {
if (Attribute == PerfStartEntry) {
- *ProgressID = PERF_CROSSMODULE_START_ID;
+ *ProgressID = PERF_CROSSMODULE_START_ID;
} else {
- *ProgressID = PERF_CROSSMODULE_END_ID;
+ *ProgressID = PERF_CROSSMODULE_END_ID;
}
- } else { // Pref used in Modules.
+ } else {
+ // Pref used in Modules.
if (Attribute == PerfStartEntry) {
- *ProgressID = PERF_INMODULE_START_ID;
+ *ProgressID = PERF_INMODULE_START_ID;
} else {
- *ProgressID = PERF_INMODULE_END_ID;
+ *ProgressID = PERF_INMODULE_END_ID;
}
}
- } else if (Handle!= NULL) { // Pref used in Modules.
+ } else if (Handle != NULL) {
+ // Pref used in Modules.
if (Attribute == PerfStartEntry) {
- *ProgressID = PERF_INMODULE_START_ID;
+ *ProgressID = PERF_INMODULE_START_ID;
} else {
- *ProgressID = PERF_INMODULE_END_ID;
+ *ProgressID = PERF_INMODULE_END_ID;
}
} else {
return EFI_INVALID_PARAMETER;
}
+
return EFI_SUCCESS;
}
@@ -754,9 +783,9 @@ GetFpdtRecordId ( **/
VOID
CopyStringIntoPerfRecordAndUpdateLength (
- IN OUT CHAR8 *Destination,
+ IN OUT CHAR8 *Destination,
IN CONST CHAR8 *Source,
- IN OUT UINT8 *Length
+ IN OUT UINT8 *Length
)
{
UINTN StringLen;
@@ -772,12 +801,13 @@ CopyStringIntoPerfRecordAndUpdateLength ( DestMax = STRING_SIZE;
}
}
+
StringLen = AsciiStrLen (Source);
if (StringLen >= DestMax) {
StringLen = DestMax -1;
}
- AsciiStrnCpyS(Destination, DestMax, Source, StringLen);
+ AsciiStrnCpyS (Destination, DestMax, Source, StringLen);
*Length += (UINT8)DestMax;
return;
@@ -799,10 +829,10 @@ CopyStringIntoPerfRecordAndUpdateLength ( **/
EFI_STATUS
GetDeviceInfoFromHandleAndUpdateLength (
- IN CONST VOID *Handle,
- IN EFI_HANDLE ControllerHandle,
- OUT CHAR8 *ComponentNameString,
- IN OUT UINT8 *Length
+ IN CONST VOID *Handle,
+ IN EFI_HANDLE ControllerHandle,
+ OUT CHAR8 *ComponentNameString,
+ IN OUT UINT8 *Length
)
{
EFI_DEVICE_PATH_PROTOCOL *DevicePathProtocol;
@@ -816,12 +846,12 @@ GetDeviceInfoFromHandleAndUpdateLength ( ControllerNameStringSize = 0;
Status = gBS->HandleProtocol (
- (EFI_HANDLE) Handle,
+ (EFI_HANDLE)Handle,
&gEfiComponentName2ProtocolGuid,
- (VOID **) &ComponentName2
+ (VOID **)&ComponentName2
);
- if (!EFI_ERROR(Status)) {
+ if (!EFI_ERROR (Status)) {
//
// Get the current platform language setting
//
@@ -843,7 +873,7 @@ GetDeviceInfoFromHandleAndUpdateLength ( // This will produce the size of the unicode string, which is twice as large as the ASCII one
// This must be an even number, so ok to divide by 2
//
- ControllerNameStringSize = StrSize(StringPtr) / 2;
+ ControllerNameStringSize = StrSize (StringPtr) / 2;
//
// The + 1 is because we want to add a space between the ControllerName and the device path
@@ -855,12 +885,12 @@ GetDeviceInfoFromHandleAndUpdateLength ( ControllerNameStringSize = FPDT_MAX_PERF_RECORD_SIZE - (*Length) - 1;
}
- UnicodeStrnToAsciiStrS(StringPtr, ControllerNameStringSize - 1, ComponentNameString, ControllerNameStringSize, &ControllerNameStringSize);
+ UnicodeStrnToAsciiStrS (StringPtr, ControllerNameStringSize - 1, ComponentNameString, ControllerNameStringSize, &ControllerNameStringSize);
//
// Add a space in the end of the ControllerName
//
- AsciiStringPtr = ComponentNameString + ControllerNameStringSize - 1;
+ AsciiStringPtr = ComponentNameString + ControllerNameStringSize - 1;
*AsciiStringPtr = 0x20;
AsciiStringPtr++;
*AsciiStringPtr = 0;
@@ -873,7 +903,7 @@ GetDeviceInfoFromHandleAndUpdateLength ( // This function returns the device path protocol from the handle specified by Handle. If Handle is
// NULL or Handle does not contain a device path protocol, then NULL is returned.
//
- DevicePathProtocol = DevicePathFromHandle(ControllerHandle);
+ DevicePathProtocol = DevicePathFromHandle (ControllerHandle);
if (DevicePathProtocol != NULL) {
StringPtr = ConvertDevicePathToText (DevicePathProtocol, TRUE, FALSE);
@@ -882,7 +912,7 @@ GetDeviceInfoFromHandleAndUpdateLength ( // This will produce the size of the unicode string, which is twice as large as the ASCII one
// This must be an even number, so ok to divide by 2
//
- DevicePathStringSize = StrSize(StringPtr) / 2;
+ DevicePathStringSize = StrSize (StringPtr) / 2;
if ((DevicePathStringSize + (*Length)) > FPDT_MAX_PERF_RECORD_SIZE) {
//
@@ -897,7 +927,7 @@ GetDeviceInfoFromHandleAndUpdateLength ( AsciiStringPtr = ComponentNameString;
}
- UnicodeStrnToAsciiStrS(StringPtr, DevicePathStringSize - 1, AsciiStringPtr, DevicePathStringSize, &DevicePathStringSize);
+ UnicodeStrnToAsciiStrS (StringPtr, DevicePathStringSize - 1, AsciiStringPtr, DevicePathStringSize, &DevicePathStringSize);
*Length += (UINT8)DevicePathStringSize;
return EFI_SUCCESS;
}
@@ -941,19 +971,19 @@ InsertFpdtRecord ( IN PERF_MEASUREMENT_ATTRIBUTE Attribute
)
{
- EFI_GUID ModuleGuid;
- CHAR8 ModuleName[FPDT_STRING_EVENT_RECORD_NAME_LENGTH];
- FPDT_RECORD_PTR FpdtRecordPtr;
- FPDT_RECORD_PTR CachedFpdtRecordPtr;
- UINT64 TimeStamp;
- CONST CHAR8 *StringPtr;
- UINTN DestMax;
- UINTN StringLen;
- EFI_STATUS Status;
- UINT16 ProgressId;
-
- StringPtr = NULL;
- ProgressId = 0;
+ EFI_GUID ModuleGuid;
+ CHAR8 ModuleName[FPDT_STRING_EVENT_RECORD_NAME_LENGTH];
+ FPDT_RECORD_PTR FpdtRecordPtr;
+ FPDT_RECORD_PTR CachedFpdtRecordPtr;
+ UINT64 TimeStamp;
+ CONST CHAR8 *StringPtr;
+ UINTN DestMax;
+ UINTN StringLen;
+ EFI_STATUS Status;
+ UINT16 ProgressId;
+
+ StringPtr = NULL;
+ ProgressId = 0;
ZeroMem (ModuleName, sizeof (ModuleName));
//
@@ -986,6 +1016,7 @@ InsertFpdtRecord ( if (EFI_ERROR (Status)) {
return Status;
}
+
PerfId = ProgressId;
}
}
@@ -999,7 +1030,7 @@ InsertFpdtRecord ( }
//
- //3. Get the TimeStamp.
+ // 3. Get the TimeStamp.
//
if (Ticker == 0) {
Ticker = GetPerformanceCounter ();
@@ -1014,199 +1045,217 @@ InsertFpdtRecord ( // 4. Fill in the FPDT record according to different Performance Identifier.
//
switch (PerfId) {
- case MODULE_START_ID:
- case MODULE_END_ID:
- GetModuleInfoFromHandle ((EFI_HANDLE)CallerIdentifier, ModuleName, sizeof (ModuleName), &ModuleGuid);
- StringPtr = ModuleName;
- //
- // Cache the offset of start image start record and use to update the start image end record if needed.
- //
- if (Attribute == PerfEntry && PerfId == MODULE_START_ID) {
- if (mFpdtBufferIsReported) {
- mCachedLength = mBootRecordSize;
- } else {
- mCachedLength = mPerformanceLength;
- }
- }
- if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
- FpdtRecordPtr.GuidEvent->Header.Type = FPDT_GUID_EVENT_TYPE;
- FpdtRecordPtr.GuidEvent->Header.Length = sizeof (FPDT_GUID_EVENT_RECORD);
- FpdtRecordPtr.GuidEvent->Header.Revision = FPDT_RECORD_REVISION_1;
- FpdtRecordPtr.GuidEvent->ProgressID = PerfId;
- FpdtRecordPtr.GuidEvent->Timestamp = TimeStamp;
- CopyMem (&FpdtRecordPtr.GuidEvent->Guid, &ModuleGuid, sizeof (FpdtRecordPtr.GuidEvent->Guid));
- if (CallerIdentifier == NULL && PerfId == MODULE_END_ID && mCachedLength != 0) {
- if (mFpdtBufferIsReported) {
- CachedFpdtRecordPtr.RecordHeader = (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER *)(mBootRecordBuffer + mCachedLength);
- } else {
- CachedFpdtRecordPtr.RecordHeader = (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER *)(mPerformancePointer + mCachedLength);
- }
- CopyMem (&FpdtRecordPtr.GuidEvent->Guid, &CachedFpdtRecordPtr.GuidEvent->Guid, sizeof (FpdtRecordPtr.GuidEvent->Guid));
- mCachedLength = 0;
- }
- }
- break;
-
- case MODULE_LOADIMAGE_START_ID:
- case MODULE_LOADIMAGE_END_ID:
- GetModuleInfoFromHandle ((EFI_HANDLE)CallerIdentifier, ModuleName, sizeof (ModuleName), &ModuleGuid);
- StringPtr = ModuleName;
- if (PerfId == MODULE_LOADIMAGE_START_ID) {
- mLoadImageCount ++;
+ case MODULE_START_ID:
+ case MODULE_END_ID:
+ GetModuleInfoFromHandle ((EFI_HANDLE)CallerIdentifier, ModuleName, sizeof (ModuleName), &ModuleGuid);
+ StringPtr = ModuleName;
//
- // Cache the offset of load image start record and use to be updated by the load image end record if needed.
+ // Cache the offset of start image start record and use to update the start image end record if needed.
//
- if (CallerIdentifier == NULL && Attribute == PerfEntry) {
+ if ((Attribute == PerfEntry) && (PerfId == MODULE_START_ID)) {
if (mFpdtBufferIsReported) {
mCachedLength = mBootRecordSize;
} else {
mCachedLength = mPerformanceLength;
}
}
- }
- if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
- FpdtRecordPtr.GuidQwordEvent->Header.Type = FPDT_GUID_QWORD_EVENT_TYPE;
- FpdtRecordPtr.GuidQwordEvent->Header.Length = sizeof (FPDT_GUID_QWORD_EVENT_RECORD);
- FpdtRecordPtr.GuidQwordEvent->Header.Revision = FPDT_RECORD_REVISION_1;
- FpdtRecordPtr.GuidQwordEvent->ProgressID = PerfId;
- FpdtRecordPtr.GuidQwordEvent->Timestamp = TimeStamp;
- FpdtRecordPtr.GuidQwordEvent->Qword = mLoadImageCount;
- CopyMem (&FpdtRecordPtr.GuidQwordEvent->Guid, &ModuleGuid, sizeof (FpdtRecordPtr.GuidQwordEvent->Guid));
- if (PerfId == MODULE_LOADIMAGE_END_ID && mCachedLength != 0) {
- if (mFpdtBufferIsReported) {
- CachedFpdtRecordPtr.RecordHeader = (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER *)(mBootRecordBuffer + mCachedLength);
- } else {
- CachedFpdtRecordPtr.RecordHeader = (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER *)(mPerformancePointer + mCachedLength);
+
+ if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
+ FpdtRecordPtr.GuidEvent->Header.Type = FPDT_GUID_EVENT_TYPE;
+ FpdtRecordPtr.GuidEvent->Header.Length = sizeof (FPDT_GUID_EVENT_RECORD);
+ FpdtRecordPtr.GuidEvent->Header.Revision = FPDT_RECORD_REVISION_1;
+ FpdtRecordPtr.GuidEvent->ProgressID = PerfId;
+ FpdtRecordPtr.GuidEvent->Timestamp = TimeStamp;
+ CopyMem (&FpdtRecordPtr.GuidEvent->Guid, &ModuleGuid, sizeof (FpdtRecordPtr.GuidEvent->Guid));
+ if ((CallerIdentifier == NULL) && (PerfId == MODULE_END_ID) && (mCachedLength != 0)) {
+ if (mFpdtBufferIsReported) {
+ CachedFpdtRecordPtr.RecordHeader = (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER *)(mBootRecordBuffer + mCachedLength);
+ } else {
+ CachedFpdtRecordPtr.RecordHeader = (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER *)(mPerformancePointer + mCachedLength);
+ }
+
+ CopyMem (&FpdtRecordPtr.GuidEvent->Guid, &CachedFpdtRecordPtr.GuidEvent->Guid, sizeof (FpdtRecordPtr.GuidEvent->Guid));
+ mCachedLength = 0;
}
- CopyMem (&CachedFpdtRecordPtr.GuidQwordEvent->Guid, &ModuleGuid, sizeof (CachedFpdtRecordPtr.GuidQwordEvent->Guid));
- mCachedLength = 0;
}
- }
- break;
-
- case MODULE_DB_START_ID:
- case MODULE_DB_SUPPORT_START_ID:
- case MODULE_DB_SUPPORT_END_ID:
- case MODULE_DB_STOP_START_ID:
- case MODULE_DB_STOP_END_ID:
- GetModuleInfoFromHandle ((EFI_HANDLE)CallerIdentifier, ModuleName, sizeof (ModuleName), &ModuleGuid);
- StringPtr = ModuleName;
- if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
- FpdtRecordPtr.GuidQwordEvent->Header.Type = FPDT_GUID_QWORD_EVENT_TYPE;
- FpdtRecordPtr.GuidQwordEvent->Header.Length = sizeof (FPDT_GUID_QWORD_EVENT_RECORD);
- FpdtRecordPtr.GuidQwordEvent->Header.Revision = FPDT_RECORD_REVISION_1;
- FpdtRecordPtr.GuidQwordEvent->ProgressID = PerfId;
- FpdtRecordPtr.GuidQwordEvent->Timestamp = TimeStamp;
- FpdtRecordPtr.GuidQwordEvent->Qword = Address;
- CopyMem (&FpdtRecordPtr.GuidQwordEvent->Guid, &ModuleGuid, sizeof (FpdtRecordPtr.GuidQwordEvent->Guid));
- }
- break;
-
- case MODULE_DB_END_ID:
- GetModuleInfoFromHandle ((EFI_HANDLE)CallerIdentifier, ModuleName, sizeof (ModuleName), &ModuleGuid);
- StringPtr = ModuleName;
- if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
- FpdtRecordPtr.GuidQwordStringEvent->Header.Type = FPDT_GUID_QWORD_STRING_EVENT_TYPE;
- FpdtRecordPtr.GuidQwordStringEvent->Header.Length = sizeof (FPDT_GUID_QWORD_STRING_EVENT_RECORD);;
- FpdtRecordPtr.GuidQwordStringEvent->Header.Revision = FPDT_RECORD_REVISION_1;
- FpdtRecordPtr.GuidQwordStringEvent->ProgressID = PerfId;
- FpdtRecordPtr.GuidQwordStringEvent->Timestamp = TimeStamp;
- FpdtRecordPtr.GuidQwordStringEvent->Qword = Address;
- CopyMem (&FpdtRecordPtr.GuidQwordStringEvent->Guid, &ModuleGuid, sizeof (FpdtRecordPtr.GuidQwordStringEvent->Guid));
- if (Address != 0) {
- GetDeviceInfoFromHandleAndUpdateLength(CallerIdentifier, (EFI_HANDLE)(UINTN)Address, FpdtRecordPtr.GuidQwordStringEvent->String, &FpdtRecordPtr.GuidQwordStringEvent->Header.Length);
+
+ break;
+
+ case MODULE_LOADIMAGE_START_ID:
+ case MODULE_LOADIMAGE_END_ID:
+ GetModuleInfoFromHandle ((EFI_HANDLE)CallerIdentifier, ModuleName, sizeof (ModuleName), &ModuleGuid);
+ StringPtr = ModuleName;
+ if (PerfId == MODULE_LOADIMAGE_START_ID) {
+ mLoadImageCount++;
+ //
+ // Cache the offset of load image start record and use to be updated by the load image end record if needed.
+ //
+ if ((CallerIdentifier == NULL) && (Attribute == PerfEntry)) {
+ if (mFpdtBufferIsReported) {
+ mCachedLength = mBootRecordSize;
+ } else {
+ mCachedLength = mPerformanceLength;
+ }
+ }
}
- }
- break;
- case PERF_EVENTSIGNAL_START_ID:
- case PERF_EVENTSIGNAL_END_ID:
- case PERF_CALLBACK_START_ID:
- case PERF_CALLBACK_END_ID:
- if (String == NULL || Guid == NULL) {
- return EFI_INVALID_PARAMETER;
- }
- StringPtr = String;
- if (AsciiStrLen (String) == 0) {
- StringPtr = "unknown name";
- }
- if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
- FpdtRecordPtr.DualGuidStringEvent->Header.Type = FPDT_DUAL_GUID_STRING_EVENT_TYPE;
- FpdtRecordPtr.DualGuidStringEvent->Header.Length = sizeof (FPDT_DUAL_GUID_STRING_EVENT_RECORD);
- FpdtRecordPtr.DualGuidStringEvent->Header.Revision = FPDT_RECORD_REVISION_1;
- FpdtRecordPtr.DualGuidStringEvent->ProgressID = PerfId;
- FpdtRecordPtr.DualGuidStringEvent->Timestamp = TimeStamp;
- CopyMem (&FpdtRecordPtr.DualGuidStringEvent->Guid1, CallerIdentifier, sizeof (FpdtRecordPtr.DualGuidStringEvent->Guid1));
- CopyMem (&FpdtRecordPtr.DualGuidStringEvent->Guid2, Guid, sizeof (FpdtRecordPtr.DualGuidStringEvent->Guid2));
- CopyStringIntoPerfRecordAndUpdateLength (FpdtRecordPtr.DualGuidStringEvent->String, StringPtr, &FpdtRecordPtr.DualGuidStringEvent->Header.Length);
- }
- break;
-
- case PERF_EVENT_ID:
- case PERF_FUNCTION_START_ID:
- case PERF_FUNCTION_END_ID:
- case PERF_INMODULE_START_ID:
- case PERF_INMODULE_END_ID:
- case PERF_CROSSMODULE_START_ID:
- case PERF_CROSSMODULE_END_ID:
- GetModuleInfoFromHandle ((EFI_HANDLE)CallerIdentifier, ModuleName, sizeof (ModuleName), &ModuleGuid);
- if (String != NULL) {
- StringPtr = String;
- } else {
+ if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
+ FpdtRecordPtr.GuidQwordEvent->Header.Type = FPDT_GUID_QWORD_EVENT_TYPE;
+ FpdtRecordPtr.GuidQwordEvent->Header.Length = sizeof (FPDT_GUID_QWORD_EVENT_RECORD);
+ FpdtRecordPtr.GuidQwordEvent->Header.Revision = FPDT_RECORD_REVISION_1;
+ FpdtRecordPtr.GuidQwordEvent->ProgressID = PerfId;
+ FpdtRecordPtr.GuidQwordEvent->Timestamp = TimeStamp;
+ FpdtRecordPtr.GuidQwordEvent->Qword = mLoadImageCount;
+ CopyMem (&FpdtRecordPtr.GuidQwordEvent->Guid, &ModuleGuid, sizeof (FpdtRecordPtr.GuidQwordEvent->Guid));
+ if ((PerfId == MODULE_LOADIMAGE_END_ID) && (mCachedLength != 0)) {
+ if (mFpdtBufferIsReported) {
+ CachedFpdtRecordPtr.RecordHeader = (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER *)(mBootRecordBuffer + mCachedLength);
+ } else {
+ CachedFpdtRecordPtr.RecordHeader = (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER *)(mPerformancePointer + mCachedLength);
+ }
+
+ CopyMem (&CachedFpdtRecordPtr.GuidQwordEvent->Guid, &ModuleGuid, sizeof (CachedFpdtRecordPtr.GuidQwordEvent->Guid));
+ mCachedLength = 0;
+ }
+ }
+
+ break;
+
+ case MODULE_DB_START_ID:
+ case MODULE_DB_SUPPORT_START_ID:
+ case MODULE_DB_SUPPORT_END_ID:
+ case MODULE_DB_STOP_START_ID:
+ case MODULE_DB_STOP_END_ID:
+ GetModuleInfoFromHandle ((EFI_HANDLE)CallerIdentifier, ModuleName, sizeof (ModuleName), &ModuleGuid);
StringPtr = ModuleName;
- }
- if (AsciiStrLen (StringPtr) == 0) {
- StringPtr = "unknown name";
- }
- if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
- FpdtRecordPtr.DynamicStringEvent->Header.Type = FPDT_DYNAMIC_STRING_EVENT_TYPE;
- FpdtRecordPtr.DynamicStringEvent->Header.Length = sizeof (FPDT_DYNAMIC_STRING_EVENT_RECORD);
- FpdtRecordPtr.DynamicStringEvent->Header.Revision = FPDT_RECORD_REVISION_1;
- FpdtRecordPtr.DynamicStringEvent->ProgressID = PerfId;
- FpdtRecordPtr.DynamicStringEvent->Timestamp = TimeStamp;
- CopyMem (&FpdtRecordPtr.DynamicStringEvent->Guid, &ModuleGuid, sizeof (FpdtRecordPtr.DynamicStringEvent->Guid));
- CopyStringIntoPerfRecordAndUpdateLength (FpdtRecordPtr.DynamicStringEvent->String, StringPtr, &FpdtRecordPtr.DynamicStringEvent->Header.Length);
- }
- break;
+ if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
+ FpdtRecordPtr.GuidQwordEvent->Header.Type = FPDT_GUID_QWORD_EVENT_TYPE;
+ FpdtRecordPtr.GuidQwordEvent->Header.Length = sizeof (FPDT_GUID_QWORD_EVENT_RECORD);
+ FpdtRecordPtr.GuidQwordEvent->Header.Revision = FPDT_RECORD_REVISION_1;
+ FpdtRecordPtr.GuidQwordEvent->ProgressID = PerfId;
+ FpdtRecordPtr.GuidQwordEvent->Timestamp = TimeStamp;
+ FpdtRecordPtr.GuidQwordEvent->Qword = Address;
+ CopyMem (&FpdtRecordPtr.GuidQwordEvent->Guid, &ModuleGuid, sizeof (FpdtRecordPtr.GuidQwordEvent->Guid));
+ }
+
+ break;
+
+ case MODULE_DB_END_ID:
+ GetModuleInfoFromHandle ((EFI_HANDLE)CallerIdentifier, ModuleName, sizeof (ModuleName), &ModuleGuid);
+ StringPtr = ModuleName;
+ if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
+ FpdtRecordPtr.GuidQwordStringEvent->Header.Type = FPDT_GUID_QWORD_STRING_EVENT_TYPE;
+ FpdtRecordPtr.GuidQwordStringEvent->Header.Length = sizeof (FPDT_GUID_QWORD_STRING_EVENT_RECORD);
+ FpdtRecordPtr.GuidQwordStringEvent->Header.Revision = FPDT_RECORD_REVISION_1;
+ FpdtRecordPtr.GuidQwordStringEvent->ProgressID = PerfId;
+ FpdtRecordPtr.GuidQwordStringEvent->Timestamp = TimeStamp;
+ FpdtRecordPtr.GuidQwordStringEvent->Qword = Address;
+ CopyMem (&FpdtRecordPtr.GuidQwordStringEvent->Guid, &ModuleGuid, sizeof (FpdtRecordPtr.GuidQwordStringEvent->Guid));
+ if (Address != 0) {
+ GetDeviceInfoFromHandleAndUpdateLength (CallerIdentifier, (EFI_HANDLE)(UINTN)Address, FpdtRecordPtr.GuidQwordStringEvent->String, &FpdtRecordPtr.GuidQwordStringEvent->Header.Length);
+ }
+ }
+
+ break;
+
+ case PERF_EVENTSIGNAL_START_ID:
+ case PERF_EVENTSIGNAL_END_ID:
+ case PERF_CALLBACK_START_ID:
+ case PERF_CALLBACK_END_ID:
+ if ((String == NULL) || (Guid == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ StringPtr = String;
+ if (AsciiStrLen (String) == 0) {
+ StringPtr = "unknown name";
+ }
+
+ if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
+ FpdtRecordPtr.DualGuidStringEvent->Header.Type = FPDT_DUAL_GUID_STRING_EVENT_TYPE;
+ FpdtRecordPtr.DualGuidStringEvent->Header.Length = sizeof (FPDT_DUAL_GUID_STRING_EVENT_RECORD);
+ FpdtRecordPtr.DualGuidStringEvent->Header.Revision = FPDT_RECORD_REVISION_1;
+ FpdtRecordPtr.DualGuidStringEvent->ProgressID = PerfId;
+ FpdtRecordPtr.DualGuidStringEvent->Timestamp = TimeStamp;
+ CopyMem (&FpdtRecordPtr.DualGuidStringEvent->Guid1, CallerIdentifier, sizeof (FpdtRecordPtr.DualGuidStringEvent->Guid1));
+ CopyMem (&FpdtRecordPtr.DualGuidStringEvent->Guid2, Guid, sizeof (FpdtRecordPtr.DualGuidStringEvent->Guid2));
+ CopyStringIntoPerfRecordAndUpdateLength (FpdtRecordPtr.DualGuidStringEvent->String, StringPtr, &FpdtRecordPtr.DualGuidStringEvent->Header.Length);
+ }
- default:
- if (Attribute != PerfEntry) {
+ break;
+
+ case PERF_EVENT_ID:
+ case PERF_FUNCTION_START_ID:
+ case PERF_FUNCTION_END_ID:
+ case PERF_INMODULE_START_ID:
+ case PERF_INMODULE_END_ID:
+ case PERF_CROSSMODULE_START_ID:
+ case PERF_CROSSMODULE_END_ID:
GetModuleInfoFromHandle ((EFI_HANDLE)CallerIdentifier, ModuleName, sizeof (ModuleName), &ModuleGuid);
if (String != NULL) {
StringPtr = String;
} else {
StringPtr = ModuleName;
}
+
if (AsciiStrLen (StringPtr) == 0) {
StringPtr = "unknown name";
}
+
if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
- FpdtRecordPtr.DynamicStringEvent->Header.Type = FPDT_DYNAMIC_STRING_EVENT_TYPE;
- FpdtRecordPtr.DynamicStringEvent->Header.Length = sizeof (FPDT_DYNAMIC_STRING_EVENT_RECORD);
- FpdtRecordPtr.DynamicStringEvent->Header.Revision = FPDT_RECORD_REVISION_1;
- FpdtRecordPtr.DynamicStringEvent->ProgressID = PerfId;
- FpdtRecordPtr.DynamicStringEvent->Timestamp = TimeStamp;
+ FpdtRecordPtr.DynamicStringEvent->Header.Type = FPDT_DYNAMIC_STRING_EVENT_TYPE;
+ FpdtRecordPtr.DynamicStringEvent->Header.Length = sizeof (FPDT_DYNAMIC_STRING_EVENT_RECORD);
+ FpdtRecordPtr.DynamicStringEvent->Header.Revision = FPDT_RECORD_REVISION_1;
+ FpdtRecordPtr.DynamicStringEvent->ProgressID = PerfId;
+ FpdtRecordPtr.DynamicStringEvent->Timestamp = TimeStamp;
CopyMem (&FpdtRecordPtr.DynamicStringEvent->Guid, &ModuleGuid, sizeof (FpdtRecordPtr.DynamicStringEvent->Guid));
CopyStringIntoPerfRecordAndUpdateLength (FpdtRecordPtr.DynamicStringEvent->String, StringPtr, &FpdtRecordPtr.DynamicStringEvent->Header.Length);
}
- } else {
- return EFI_INVALID_PARAMETER;
- }
- break;
+
+ break;
+
+ default:
+ if (Attribute != PerfEntry) {
+ GetModuleInfoFromHandle ((EFI_HANDLE)CallerIdentifier, ModuleName, sizeof (ModuleName), &ModuleGuid);
+ if (String != NULL) {
+ StringPtr = String;
+ } else {
+ StringPtr = ModuleName;
+ }
+
+ if (AsciiStrLen (StringPtr) == 0) {
+ StringPtr = "unknown name";
+ }
+
+ if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
+ FpdtRecordPtr.DynamicStringEvent->Header.Type = FPDT_DYNAMIC_STRING_EVENT_TYPE;
+ FpdtRecordPtr.DynamicStringEvent->Header.Length = sizeof (FPDT_DYNAMIC_STRING_EVENT_RECORD);
+ FpdtRecordPtr.DynamicStringEvent->Header.Revision = FPDT_RECORD_REVISION_1;
+ FpdtRecordPtr.DynamicStringEvent->ProgressID = PerfId;
+ FpdtRecordPtr.DynamicStringEvent->Timestamp = TimeStamp;
+ CopyMem (&FpdtRecordPtr.DynamicStringEvent->Guid, &ModuleGuid, sizeof (FpdtRecordPtr.DynamicStringEvent->Guid));
+ CopyStringIntoPerfRecordAndUpdateLength (FpdtRecordPtr.DynamicStringEvent->String, StringPtr, &FpdtRecordPtr.DynamicStringEvent->Header.Length);
+ }
+ } else {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ break;
}
//
// 4.2 When PcdEdkiiFpdtStringRecordEnableOnly==TRUE, create string record for all Perf entries.
//
if (PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
- if (StringPtr == NULL ||PerfId == MODULE_DB_SUPPORT_START_ID || PerfId == MODULE_DB_SUPPORT_END_ID) {
+ if ((StringPtr == NULL) || (PerfId == MODULE_DB_SUPPORT_START_ID) || (PerfId == MODULE_DB_SUPPORT_END_ID)) {
return EFI_INVALID_PARAMETER;
}
- FpdtRecordPtr.DynamicStringEvent->Header.Type = FPDT_DYNAMIC_STRING_EVENT_TYPE;
- FpdtRecordPtr.DynamicStringEvent->Header.Length = sizeof (FPDT_DYNAMIC_STRING_EVENT_RECORD);
- FpdtRecordPtr.DynamicStringEvent->Header.Revision = FPDT_RECORD_REVISION_1;
- FpdtRecordPtr.DynamicStringEvent->ProgressID = PerfId;
- FpdtRecordPtr.DynamicStringEvent->Timestamp = TimeStamp;
+
+ FpdtRecordPtr.DynamicStringEvent->Header.Type = FPDT_DYNAMIC_STRING_EVENT_TYPE;
+ FpdtRecordPtr.DynamicStringEvent->Header.Length = sizeof (FPDT_DYNAMIC_STRING_EVENT_RECORD);
+ FpdtRecordPtr.DynamicStringEvent->Header.Revision = FPDT_RECORD_REVISION_1;
+ FpdtRecordPtr.DynamicStringEvent->ProgressID = PerfId;
+ FpdtRecordPtr.DynamicStringEvent->Timestamp = TimeStamp;
if (Guid != NULL) {
//
// Cache the event guid in string event record.
@@ -1215,37 +1264,44 @@ InsertFpdtRecord ( } else {
CopyMem (&FpdtRecordPtr.DynamicStringEvent->Guid, &ModuleGuid, sizeof (FpdtRecordPtr.DynamicStringEvent->Guid));
}
+
if (AsciiStrLen (StringPtr) == 0) {
StringPtr = "unknown name";
}
+
CopyStringIntoPerfRecordAndUpdateLength (FpdtRecordPtr.DynamicStringEvent->String, StringPtr, &FpdtRecordPtr.DynamicStringEvent->Header.Length);
if ((PerfId == MODULE_LOADIMAGE_START_ID) || (PerfId == MODULE_END_ID)) {
FpdtRecordPtr.DynamicStringEvent->Header.Length = (UINT8)(sizeof (FPDT_DYNAMIC_STRING_EVENT_RECORD)+ STRING_SIZE);
}
- if ((PerfId == MODULE_LOADIMAGE_END_ID || PerfId == MODULE_END_ID) && mCachedLength != 0) {
+
+ if (((PerfId == MODULE_LOADIMAGE_END_ID) || (PerfId == MODULE_END_ID)) && (mCachedLength != 0)) {
if (mFpdtBufferIsReported) {
CachedFpdtRecordPtr.RecordHeader = (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER *)(mBootRecordBuffer + mCachedLength);
} else {
CachedFpdtRecordPtr.RecordHeader = (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER *)(mPerformancePointer + mCachedLength);
}
+
if (PerfId == MODULE_LOADIMAGE_END_ID) {
- DestMax = CachedFpdtRecordPtr.DynamicStringEvent->Header.Length - sizeof (FPDT_DYNAMIC_STRING_EVENT_RECORD);
+ DestMax = CachedFpdtRecordPtr.DynamicStringEvent->Header.Length - sizeof (FPDT_DYNAMIC_STRING_EVENT_RECORD);
StringLen = AsciiStrLen (StringPtr);
if (StringLen >= DestMax) {
StringLen = DestMax -1;
}
+
CopyMem (&CachedFpdtRecordPtr.DynamicStringEvent->Guid, &ModuleGuid, sizeof (CachedFpdtRecordPtr.DynamicStringEvent->Guid));
AsciiStrnCpyS (CachedFpdtRecordPtr.DynamicStringEvent->String, DestMax, StringPtr, StringLen);
} else if (PerfId == MODULE_END_ID) {
- DestMax = FpdtRecordPtr.DynamicStringEvent->Header.Length - sizeof (FPDT_DYNAMIC_STRING_EVENT_RECORD);
+ DestMax = FpdtRecordPtr.DynamicStringEvent->Header.Length - sizeof (FPDT_DYNAMIC_STRING_EVENT_RECORD);
StringLen = AsciiStrLen (CachedFpdtRecordPtr.DynamicStringEvent->String);
if (StringLen >= DestMax) {
StringLen = DestMax -1;
}
+
CopyMem (&FpdtRecordPtr.DynamicStringEvent->Guid, &CachedFpdtRecordPtr.DynamicStringEvent->Guid, sizeof (CachedFpdtRecordPtr.DynamicStringEvent->Guid));
AsciiStrnCpyS (FpdtRecordPtr.DynamicStringEvent->String, DestMax, CachedFpdtRecordPtr.DynamicStringEvent->String, StringLen);
}
+
mCachedLength = 0;
}
}
@@ -1254,11 +1310,12 @@ InsertFpdtRecord ( // 5. Update the length of the used buffer after fill in the record.
//
if (mFpdtBufferIsReported) {
- mBootRecordSize += FpdtRecordPtr.RecordHeader->Length;
+ mBootRecordSize += FpdtRecordPtr.RecordHeader->Length;
mAcpiBootPerformanceTable->Header.Length += FpdtRecordPtr.RecordHeader->Length;
} else {
mPerformanceLength += FpdtRecordPtr.RecordHeader->Length;
}
+
return EFI_SUCCESS;
}
@@ -1277,10 +1334,10 @@ InternalGetPeiPerformance ( VOID *HobStart
)
{
- UINT8 *FirmwarePerformanceHob;
- FPDT_PEI_EXT_PERF_HEADER *PeiPerformanceLogHeader;
- UINT8 *EventRec;
- EFI_HOB_GUID_TYPE *GuidHob;
+ UINT8 *FirmwarePerformanceHob;
+ FPDT_PEI_EXT_PERF_HEADER *PeiPerformanceLogHeader;
+ UINT8 *EventRec;
+ EFI_HOB_GUID_TYPE *GuidHob;
GuidHob = GetNextGuidHob (&gEdkiiFpdtExtendedFirmwarePerformanceGuid, HobStart);
while (GuidHob != NULL) {
@@ -1326,27 +1383,28 @@ InternalGetPeiPerformance ( VOID
EFIAPI
ReportFpdtRecordBuffer (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
- EFI_STATUS Status;
- UINT64 BPDTAddr;
+ EFI_STATUS Status;
+ UINT64 BPDTAddr;
if (!mFpdtBufferIsReported) {
Status = AllocateBootPerformanceTable ();
- if (!EFI_ERROR(Status)) {
+ if (!EFI_ERROR (Status)) {
BPDTAddr = (UINT64)(UINTN)mAcpiBootPerformanceTable;
REPORT_STATUS_CODE_EX (
- EFI_PROGRESS_CODE,
- EFI_SOFTWARE_DXE_BS_DRIVER,
- 0,
- NULL,
- &gEdkiiFpdtExtendedFirmwarePerformanceGuid,
- &BPDTAddr,
- sizeof (UINT64)
- );
+ EFI_PROGRESS_CODE,
+ EFI_SOFTWARE_DXE_BS_DRIVER,
+ 0,
+ NULL,
+ &gEdkiiFpdtExtendedFirmwarePerformanceGuid,
+ &BPDTAddr,
+ sizeof (UINT64)
+ );
}
+
//
// Set FPDT report state to TRUE.
//
@@ -1364,14 +1422,14 @@ ReportFpdtRecordBuffer ( VOID
EFIAPI
UpdateBootPerformanceTable (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
- VOID *SmmBootRecordData;
- UINTN SmmBootRecordDataSize;
- UINTN AppendSize;
- UINT8 *FirmwarePerformanceTablePtr;
+ VOID *SmmBootRecordData;
+ UINTN SmmBootRecordDataSize;
+ UINTN AppendSize;
+ UINT8 *FirmwarePerformanceTablePtr;
SmmBootRecordDataSize = 0;
@@ -1381,7 +1439,7 @@ UpdateBootPerformanceTable ( SmmBootRecordData = NULL;
InternalGetSmmPerfData (&SmmBootRecordData, &SmmBootRecordDataSize, FALSE);
- FirmwarePerformanceTablePtr = (UINT8 *) mAcpiBootPerformanceTable + mAcpiBootPerformanceTable->Header.Length;
+ FirmwarePerformanceTablePtr = (UINT8 *)mAcpiBootPerformanceTable + mAcpiBootPerformanceTable->Header.Length;
if (mAcpiBootPerformanceTable->Header.Length + SmmBootRecordDataSize > mBootRecordMaxSize) {
DEBUG ((DEBUG_INFO, "DxeCorePerformanceLib: No enough space to save all SMM boot performance data\n"));
@@ -1389,10 +1447,11 @@ UpdateBootPerformanceTable ( } else {
AppendSize = SmmBootRecordDataSize;
}
+
if (SmmBootRecordData != NULL) {
CopyMem (FirmwarePerformanceTablePtr, SmmBootRecordData, AppendSize);
- mAcpiBootPerformanceTable->Header.Length += (UINT32) AppendSize;
- mBootRecordSize += (UINT32) AppendSize;
+ mAcpiBootPerformanceTable->Header.Length += (UINT32)AppendSize;
+ mBootRecordSize += (UINT32)AppendSize;
FreePool (SmmBootRecordData);
}
}
@@ -1417,11 +1476,11 @@ DxeCorePerformanceLibConstructor ( IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
- EFI_HANDLE Handle;
- EFI_EVENT EndOfDxeEvent;
- EFI_EVENT ReadyToBootEvent;
- PERFORMANCE_PROPERTY *PerformanceProperty;
+ EFI_STATUS Status;
+ EFI_HANDLE Handle;
+ EFI_EVENT EndOfDxeEvent;
+ EFI_EVENT ReadyToBootEvent;
+ PERFORMANCE_PROPERTY *PerformanceProperty;
if (!PerformanceMeasurementEnabled ()) {
//
@@ -1433,7 +1492,7 @@ DxeCorePerformanceLibConstructor ( //
// Dump normal PEI performance records
//
- InternalGetPeiPerformance (GetHobList());
+ InternalGetPeiPerformance (GetHobList ());
//
// Install the protocol interfaces for DXE performance library instance.
@@ -1473,7 +1532,7 @@ DxeCorePerformanceLibConstructor ( ASSERT_EFI_ERROR (Status);
- Status = EfiGetSystemConfigurationTable (&gPerformanceProtocolGuid, (VOID **) &PerformanceProperty);
+ Status = EfiGetSystemConfigurationTable (&gPerformanceProtocolGuid, (VOID **)&PerformanceProperty);
if (EFI_ERROR (Status)) {
//
// Install configuration table for performance property.
@@ -1521,13 +1580,14 @@ CreatePerformanceMeasurement ( IN PERF_MEASUREMENT_ATTRIBUTE Attribute
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
Status = EFI_SUCCESS;
if (mLockInsertRecord) {
return EFI_INVALID_PARAMETER;
}
+
mLockInsertRecord = TRUE;
Status = InsertFpdtRecord (CallerIdentifier, Guid, String, TimeStamp, Address, (UINT16)Identifier, Attribute);
@@ -1572,7 +1632,7 @@ StartPerformanceMeasurementEx ( IN UINT32 Identifier
)
{
- CONST CHAR8 *String;
+ CONST CHAR8 *String;
if (Token != NULL) {
String = Token;
@@ -1621,7 +1681,7 @@ EndPerformanceMeasurementEx ( IN UINT32 Identifier
)
{
- CONST CHAR8 *String;
+ CONST CHAR8 *String;
if (Token != NULL) {
String = Token;
@@ -1681,13 +1741,13 @@ EndPerformanceMeasurementEx ( UINTN
EFIAPI
GetPerformanceMeasurementEx (
- IN UINTN LogEntryKey,
- OUT CONST VOID **Handle,
- OUT CONST CHAR8 **Token,
- OUT CONST CHAR8 **Module,
- OUT UINT64 *StartTimeStamp,
- OUT UINT64 *EndTimeStamp,
- OUT UINT32 *Identifier
+ IN UINTN LogEntryKey,
+ OUT CONST VOID **Handle,
+ OUT CONST CHAR8 **Token,
+ OUT CONST CHAR8 **Module,
+ OUT UINT64 *StartTimeStamp,
+ OUT UINT64 *EndTimeStamp,
+ OUT UINT32 *Identifier
)
{
return 0;
@@ -1808,12 +1868,12 @@ EndPerformanceMeasurement ( UINTN
EFIAPI
GetPerformanceMeasurement (
- IN UINTN LogEntryKey,
- OUT CONST VOID **Handle,
- OUT CONST CHAR8 **Token,
- OUT CONST CHAR8 **Module,
- OUT UINT64 *StartTimeStamp,
- OUT UINT64 *EndTimeStamp
+ IN UINTN LogEntryKey,
+ OUT CONST VOID **Handle,
+ OUT CONST CHAR8 **Token,
+ OUT CONST CHAR8 **Module,
+ OUT UINT64 *StartTimeStamp,
+ OUT UINT64 *EndTimeStamp
)
{
return 0;
@@ -1837,7 +1897,7 @@ PerformanceMeasurementEnabled ( VOID
)
{
- return (BOOLEAN) ((PcdGet8(PcdPerformanceLibraryPropertyMask) & PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED) != 0);
+ return (BOOLEAN)((PcdGet8 (PcdPerformanceLibraryPropertyMask) & PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED) != 0);
}
/**
@@ -1883,14 +1943,15 @@ LogPerformanceMeasurement ( BOOLEAN
EFIAPI
LogPerformanceMeasurementEnabled (
- IN CONST UINTN Type
+ IN CONST UINTN Type
)
{
//
// When Performance measurement is enabled and the type is not filtered, the performance can be logged.
//
- if (PerformanceMeasurementEnabled () && (PcdGet8(PcdPerformanceLibraryPropertyMask) & Type) == 0) {
+ if (PerformanceMeasurementEnabled () && ((PcdGet8 (PcdPerformanceLibraryPropertyMask) & Type) == 0)) {
return TRUE;
}
+
return FALSE;
}
diff --git a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLibInternal.h b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLibInternal.h index bfb472711e..8f32018c06 100644 --- a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLibInternal.h +++ b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLibInternal.h @@ -12,7 +12,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #ifndef _DXE_CORE_PERFORMANCE_LIB_INTERNAL_H_
#define _DXE_CORE_PERFORMANCE_LIB_INTERNAL_H_
-
#include <PiDxe.h>
#include <Guid/Performance.h>
@@ -65,7 +64,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent **/
EFI_STATUS
EFIAPI
-CreatePerformanceMeasurement(
+CreatePerformanceMeasurement (
IN CONST VOID *CallerIdentifier OPTIONAL,
IN CONST VOID *Guid OPTIONAL,
IN CONST CHAR8 *String OPTIONAL,
diff --git a/MdeModulePkg/Library/DxeCrc32GuidedSectionExtractLib/DxeCrc32GuidedSectionExtractLib.c b/MdeModulePkg/Library/DxeCrc32GuidedSectionExtractLib/DxeCrc32GuidedSectionExtractLib.c index 1c0904c8f0..3e40dfa618 100644 --- a/MdeModulePkg/Library/DxeCrc32GuidedSectionExtractLib/DxeCrc32GuidedSectionExtractLib.c +++ b/MdeModulePkg/Library/DxeCrc32GuidedSectionExtractLib/DxeCrc32GuidedSectionExtractLib.c @@ -21,13 +21,13 @@ SPDX-License-Identifier: BSD-2-Clause-Patent /// CRC32 Guided Section header
///
typedef struct {
- EFI_GUID_DEFINED_SECTION GuidedSectionHeader; ///< EFI guided section header
- UINT32 CRC32Checksum; ///< 32bit CRC check sum
+ EFI_GUID_DEFINED_SECTION GuidedSectionHeader; ///< EFI guided section header
+ UINT32 CRC32Checksum; ///< 32bit CRC check sum
} CRC32_SECTION_HEADER;
typedef struct {
- EFI_GUID_DEFINED_SECTION2 GuidedSectionHeader; ///< EFI guided section header
- UINT32 CRC32Checksum; ///< 32bit CRC check sum
+ EFI_GUID_DEFINED_SECTION2 GuidedSectionHeader; ///< EFI guided section header
+ UINT32 CRC32Checksum; ///< 32bit CRC check sum
} CRC32_SECTION2_HEADER;
/**
@@ -60,31 +60,37 @@ Crc32GuidedSectionGetInfo ( // Check whether the input guid section is recognized.
//
if (!CompareGuid (
- &gEfiCrc32GuidedSectionExtractionGuid,
- &(((EFI_GUID_DEFINED_SECTION2 *) InputSection)->SectionDefinitionGuid))) {
+ &gEfiCrc32GuidedSectionExtractionGuid,
+ &(((EFI_GUID_DEFINED_SECTION2 *)InputSection)->SectionDefinitionGuid)
+ ))
+ {
return EFI_INVALID_PARAMETER;
}
+
//
// Retrieve the size and attribute of the input section data.
//
- *SectionAttribute = ((EFI_GUID_DEFINED_SECTION2 *) InputSection)->Attributes;
+ *SectionAttribute = ((EFI_GUID_DEFINED_SECTION2 *)InputSection)->Attributes;
*ScratchBufferSize = 0;
- *OutputBufferSize = SECTION2_SIZE (InputSection) - ((EFI_GUID_DEFINED_SECTION2 *) InputSection)->DataOffset;
+ *OutputBufferSize = SECTION2_SIZE (InputSection) - ((EFI_GUID_DEFINED_SECTION2 *)InputSection)->DataOffset;
} else {
//
// Check whether the input guid section is recognized.
//
if (!CompareGuid (
- &gEfiCrc32GuidedSectionExtractionGuid,
- &(((EFI_GUID_DEFINED_SECTION *) InputSection)->SectionDefinitionGuid))) {
+ &gEfiCrc32GuidedSectionExtractionGuid,
+ &(((EFI_GUID_DEFINED_SECTION *)InputSection)->SectionDefinitionGuid)
+ ))
+ {
return EFI_INVALID_PARAMETER;
}
+
//
// Retrieve the size and attribute of the input section data.
//
- *SectionAttribute = ((EFI_GUID_DEFINED_SECTION *) InputSection)->Attributes;
+ *SectionAttribute = ((EFI_GUID_DEFINED_SECTION *)InputSection)->Attributes;
*ScratchBufferSize = 0;
- *OutputBufferSize = SECTION_SIZE (InputSection) - ((EFI_GUID_DEFINED_SECTION *) InputSection)->DataOffset;
+ *OutputBufferSize = SECTION_SIZE (InputSection) - ((EFI_GUID_DEFINED_SECTION *)InputSection)->DataOffset;
}
return EFI_SUCCESS;
@@ -116,55 +122,59 @@ Crc32GuidedSectionHandler ( OUT UINT32 *AuthenticationStatus
)
{
- EFI_STATUS Status;
- UINT32 SectionCrc32Checksum;
- UINT32 Crc32Checksum;
- UINT32 OutputBufferSize;
- VOID *DummyInterface;
+ EFI_STATUS Status;
+ UINT32 SectionCrc32Checksum;
+ UINT32 Crc32Checksum;
+ UINT32 OutputBufferSize;
+ VOID *DummyInterface;
if (IS_SECTION2 (InputSection)) {
//
// Check whether the input guid section is recognized.
//
if (!CompareGuid (
- &gEfiCrc32GuidedSectionExtractionGuid,
- &(((EFI_GUID_DEFINED_SECTION2 *) InputSection)->SectionDefinitionGuid))) {
+ &gEfiCrc32GuidedSectionExtractionGuid,
+ &(((EFI_GUID_DEFINED_SECTION2 *)InputSection)->SectionDefinitionGuid)
+ ))
+ {
return EFI_INVALID_PARAMETER;
}
//
// Get section Crc32 checksum.
//
- SectionCrc32Checksum = ((CRC32_SECTION2_HEADER *) InputSection)->CRC32Checksum;
- *OutputBuffer = (UINT8 *) InputSection + ((EFI_GUID_DEFINED_SECTION2 *) InputSection)->DataOffset;
- OutputBufferSize = SECTION2_SIZE (InputSection) - ((EFI_GUID_DEFINED_SECTION2 *) InputSection)->DataOffset;
+ SectionCrc32Checksum = ((CRC32_SECTION2_HEADER *)InputSection)->CRC32Checksum;
+ *OutputBuffer = (UINT8 *)InputSection + ((EFI_GUID_DEFINED_SECTION2 *)InputSection)->DataOffset;
+ OutputBufferSize = SECTION2_SIZE (InputSection) - ((EFI_GUID_DEFINED_SECTION2 *)InputSection)->DataOffset;
//
// Implicitly CRC32 GUIDed section should have STATUS_VALID bit set
//
- ASSERT (((EFI_GUID_DEFINED_SECTION2 *) InputSection)->Attributes & EFI_GUIDED_SECTION_AUTH_STATUS_VALID);
+ ASSERT (((EFI_GUID_DEFINED_SECTION2 *)InputSection)->Attributes & EFI_GUIDED_SECTION_AUTH_STATUS_VALID);
*AuthenticationStatus = EFI_AUTH_STATUS_IMAGE_SIGNED;
} else {
//
// Check whether the input guid section is recognized.
//
if (!CompareGuid (
- &gEfiCrc32GuidedSectionExtractionGuid,
- &(((EFI_GUID_DEFINED_SECTION *) InputSection)->SectionDefinitionGuid))) {
+ &gEfiCrc32GuidedSectionExtractionGuid,
+ &(((EFI_GUID_DEFINED_SECTION *)InputSection)->SectionDefinitionGuid)
+ ))
+ {
return EFI_INVALID_PARAMETER;
}
//
// Get section Crc32 checksum.
//
- SectionCrc32Checksum = ((CRC32_SECTION_HEADER *) InputSection)->CRC32Checksum;
- *OutputBuffer = (UINT8 *) InputSection + ((EFI_GUID_DEFINED_SECTION *) InputSection)->DataOffset;
- OutputBufferSize = SECTION_SIZE (InputSection) - ((EFI_GUID_DEFINED_SECTION *) InputSection)->DataOffset;
+ SectionCrc32Checksum = ((CRC32_SECTION_HEADER *)InputSection)->CRC32Checksum;
+ *OutputBuffer = (UINT8 *)InputSection + ((EFI_GUID_DEFINED_SECTION *)InputSection)->DataOffset;
+ OutputBufferSize = SECTION_SIZE (InputSection) - ((EFI_GUID_DEFINED_SECTION *)InputSection)->DataOffset;
//
// Implicitly CRC32 GUIDed section should have STATUS_VALID bit set
//
- ASSERT (((EFI_GUID_DEFINED_SECTION *) InputSection)->Attributes & EFI_GUIDED_SECTION_AUTH_STATUS_VALID);
+ ASSERT (((EFI_GUID_DEFINED_SECTION *)InputSection)->Attributes & EFI_GUIDED_SECTION_AUTH_STATUS_VALID);
*AuthenticationStatus = EFI_AUTH_STATUS_IMAGE_SIGNED;
}
@@ -222,8 +232,8 @@ DxeCrc32GuidedSectionExtractLibConstructor ( )
{
return ExtractGuidedSectionRegisterHandlers (
- &gEfiCrc32GuidedSectionExtractionGuid,
- Crc32GuidedSectionGetInfo,
- Crc32GuidedSectionHandler
- );
+ &gEfiCrc32GuidedSectionExtractionGuid,
+ Crc32GuidedSectionGetInfo,
+ Crc32GuidedSectionHandler
+ );
}
diff --git a/MdeModulePkg/Library/DxeDebugPrintErrorLevelLib/DxeDebugPrintErrorLevelLib.c b/MdeModulePkg/Library/DxeDebugPrintErrorLevelLib/DxeDebugPrintErrorLevelLib.c index 7f3ccb06d8..547eb1532c 100644 --- a/MdeModulePkg/Library/DxeDebugPrintErrorLevelLib/DxeDebugPrintErrorLevelLib.c +++ b/MdeModulePkg/Library/DxeDebugPrintErrorLevelLib/DxeDebugPrintErrorLevelLib.c @@ -78,7 +78,7 @@ EFI_DEBUG_MASK_PROTOCOL mDebugMaskProtocol = { /// This variable prevents the EFI Variable Services from being called fort
/// every DEBUG() macro.
///
-BOOLEAN mGlobalErrorLevelInitialized = FALSE;
+BOOLEAN mGlobalErrorLevelInitialized = FALSE;
///
/// Global variable that contains the current debug error level mask for the
@@ -90,7 +90,7 @@ BOOLEAN mGlobalErrorLevelInitialized = FALSE; /// Debug Mask Protocol SetDebugMask() service is called, then that overrides
/// the PcdDebugPrintErrorLevel and the EFI Variable setting.
///
-UINT32 mDebugPrintErrorLevel = 0;
+UINT32 mDebugPrintErrorLevel = 0;
///
/// Global variable that is used to cache a pointer to the EFI System Table
@@ -98,7 +98,7 @@ UINT32 mDebugPrintErrorLevel = 0; /// the global debug print error level mask value. The UefiBootServicesTableLib
/// is not used to prevent a circular dependency between these libraries.
///
-EFI_SYSTEM_TABLE *mSystemTable = NULL;
+EFI_SYSTEM_TABLE *mSystemTable = NULL;
/**
The constructor function caches the PCI Express Base Address and creates a
@@ -118,7 +118,7 @@ DxeDebugPrintErrorLevelLibConstructor ( IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
//
// Initialize the error level mask from PCD setting.
@@ -129,11 +129,12 @@ DxeDebugPrintErrorLevelLibConstructor ( // Install Debug Mask Protocol onto ImageHandle
//
mSystemTable = SystemTable;
- Status = SystemTable->BootServices->InstallMultipleProtocolInterfaces (
- &ImageHandle,
- &gEfiDebugMaskProtocolGuid, &mDebugMaskProtocol,
- NULL
- );
+ Status = SystemTable->BootServices->InstallMultipleProtocolInterfaces (
+ &ImageHandle,
+ &gEfiDebugMaskProtocolGuid,
+ &mDebugMaskProtocol,
+ NULL
+ );
//
// Attempt to retrieve the global debug print error level mask from the EFI Variable
@@ -170,7 +171,8 @@ DxeDebugPrintErrorLevelLibDestructor ( //
return SystemTable->BootServices->UninstallMultipleProtocolInterfaces (
ImageHandle,
- &gEfiDebugMaskProtocolGuid, &mDebugMaskProtocol,
+ &gEfiDebugMaskProtocolGuid,
+ &mDebugMaskProtocol,
NULL
);
}
@@ -219,14 +221,14 @@ GetDebugPrintErrorLevel ( // Attempt to retrieve the global debug print error level mask from the
// EFI Variable
//
- Size = sizeof (GlobalErrorLevel);
+ Size = sizeof (GlobalErrorLevel);
Status = mSystemTable->RuntimeServices->GetVariable (
- DEBUG_MASK_VARIABLE_NAME,
- &gEfiGenericVariableGuid,
- NULL,
- &Size,
- &GlobalErrorLevel
- );
+ DEBUG_MASK_VARIABLE_NAME,
+ &gEfiGenericVariableGuid,
+ NULL,
+ &Size,
+ &GlobalErrorLevel
+ );
if (Status != EFI_NOT_AVAILABLE_YET) {
//
// If EFI Variable Services are available, then set a flag so the EFI
@@ -248,7 +250,7 @@ GetDebugPrintErrorLevel ( Hob = GetFirstGuidHob (&gEfiGenericVariableGuid);
if (Hob != NULL) {
if (GET_GUID_HOB_DATA_SIZE (Hob) == sizeof (UINT32)) {
- mDebugPrintErrorLevel = *(UINT32 *)GET_GUID_HOB_DATA (Hob);
+ mDebugPrintErrorLevel = *(UINT32 *)GET_GUID_HOB_DATA (Hob);
mGlobalErrorLevelInitialized = TRUE;
}
}
@@ -296,25 +298,26 @@ SetDebugPrintErrorLevel ( // Attempt to store the global debug print error level mask in an EFI Variable
//
GlobalErrorLevel = (UINTN)ErrorLevel;
- Size = sizeof (GlobalErrorLevel);
- Status = mSystemTable->RuntimeServices->SetVariable (
- DEBUG_MASK_VARIABLE_NAME,
- &gEfiGenericVariableGuid,
- (EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS),
- Size,
- &GlobalErrorLevel
- );
+ Size = sizeof (GlobalErrorLevel);
+ Status = mSystemTable->RuntimeServices->SetVariable (
+ DEBUG_MASK_VARIABLE_NAME,
+ &gEfiGenericVariableGuid,
+ (EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS),
+ Size,
+ &GlobalErrorLevel
+ );
if (!EFI_ERROR (Status)) {
//
// If the EFI Variable was updated, then update the mask value for this
// module and return TRUE.
//
mGlobalErrorLevelInitialized = TRUE;
- mDebugPrintErrorLevel = ErrorLevel;
+ mDebugPrintErrorLevel = ErrorLevel;
return TRUE;
}
}
}
+
//
// Return FALSE since the EFI Variable could not be updated.
//
diff --git a/MdeModulePkg/Library/DxeFileExplorerProtocol/DxeFileExplorerProtocol.c b/MdeModulePkg/Library/DxeFileExplorerProtocol/DxeFileExplorerProtocol.c index 14f29b55bb..a8f07c8996 100644 --- a/MdeModulePkg/Library/DxeFileExplorerProtocol/DxeFileExplorerProtocol.c +++ b/MdeModulePkg/Library/DxeFileExplorerProtocol/DxeFileExplorerProtocol.c @@ -20,7 +20,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include <Library/BaseLib.h>
#include <Library/DebugLib.h>
-EFI_FILE_EXPLORER_PROTOCOL *mProtocol = NULL;
+EFI_FILE_EXPLORER_PROTOCOL *mProtocol = NULL;
/**
The constructor function caches the pointer to file explorer protocol.
@@ -37,16 +37,16 @@ EFI_FILE_EXPLORER_PROTOCOL *mProtocol = NULL; EFI_STATUS
EFIAPI
FileExplorerConstructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
Status = SystemTable->BootServices->LocateProtocol (
&gEfiFileExplorerProtocolGuid,
NULL,
- (VOID**) &mProtocol
+ (VOID **)&mProtocol
);
ASSERT_EFI_ERROR (Status);
ASSERT (mProtocol != NULL);
diff --git a/MdeModulePkg/Library/DxeIpmiLibIpmiProtocol/DxeIpmiLibIpmiProtocol.c b/MdeModulePkg/Library/DxeIpmiLibIpmiProtocol/DxeIpmiLibIpmiProtocol.c index 0ee7095aba..05847de9ad 100644 --- a/MdeModulePkg/Library/DxeIpmiLibIpmiProtocol/DxeIpmiLibIpmiProtocol.c +++ b/MdeModulePkg/Library/DxeIpmiLibIpmiProtocol/DxeIpmiLibIpmiProtocol.c @@ -11,7 +11,7 @@ #include <Library/UefiBootServicesTableLib.h>
#include <Library/DebugLib.h>
-IPMI_PROTOCOL *mIpmiProtocol = NULL;
+IPMI_PROTOCOL *mIpmiProtocol = NULL;
/**
This service enables submitting commands via Ipmi.
@@ -34,22 +34,22 @@ IPMI_PROTOCOL *mIpmiProtocol = NULL; EFI_STATUS
EFIAPI
IpmiSubmitCommand (
- IN UINT8 NetFunction,
- IN UINT8 Command,
- IN UINT8 *RequestData,
- IN UINT32 RequestDataSize,
- OUT UINT8 *ResponseData,
- IN OUT UINT32 *ResponseDataSize
+ IN UINT8 NetFunction,
+ IN UINT8 Command,
+ IN UINT8 *RequestData,
+ IN UINT32 RequestDataSize,
+ OUT UINT8 *ResponseData,
+ IN OUT UINT32 *ResponseDataSize
)
{
EFI_STATUS Status;
if (mIpmiProtocol == NULL) {
Status = gBS->LocateProtocol (
- &gIpmiProtocolGuid,
- NULL,
- (VOID **) &mIpmiProtocol
- );
+ &gIpmiProtocolGuid,
+ NULL,
+ (VOID **)&mIpmiProtocol
+ );
if (EFI_ERROR (Status)) {
//
// Dxe Ipmi Protocol is not installed. So, IPMI device is not present.
@@ -71,5 +71,6 @@ IpmiSubmitCommand ( if (EFI_ERROR (Status)) {
return Status;
}
+
return EFI_SUCCESS;
}
diff --git a/MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.c b/MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.c index 9a7f8c440a..8e35cc4302 100644 --- a/MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.c +++ b/MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.c @@ -11,7 +11,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent **/
-
#include <PiDxe.h>
#include <Guid/PerformanceMeasurement.h>
@@ -24,7 +23,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent //
// The cached Performance Protocol and PerformanceEx Protocol interface.
//
-EDKII_PERFORMANCE_MEASUREMENT_PROTOCOL *mPerformanceMeasurement = NULL;
+EDKII_PERFORMANCE_MEASUREMENT_PROTOCOL *mPerformanceMeasurement = NULL;
/**
The function caches the pointers to PerformanceEx protocol and Performance Protocol.
@@ -40,14 +39,14 @@ GetPerformanceMeasurementProtocol ( VOID
)
{
- EFI_STATUS Status;
- EDKII_PERFORMANCE_MEASUREMENT_PROTOCOL *PerformanceMeasurement;
+ EFI_STATUS Status;
+ EDKII_PERFORMANCE_MEASUREMENT_PROTOCOL *PerformanceMeasurement;
if (mPerformanceMeasurement != NULL) {
return EFI_SUCCESS;
}
- Status = gBS->LocateProtocol (&gEdkiiPerformanceMeasurementProtocolGuid, NULL, (VOID **) &PerformanceMeasurement);
+ Status = gBS->LocateProtocol (&gEdkiiPerformanceMeasurementProtocolGuid, NULL, (VOID **)&PerformanceMeasurement);
if (!EFI_ERROR (Status)) {
ASSERT (PerformanceMeasurement != NULL);
//
@@ -92,8 +91,8 @@ StartPerformanceMeasurementEx ( IN UINT32 Identifier
)
{
- EFI_STATUS Status;
- CONST CHAR8* String;
+ EFI_STATUS Status;
+ CONST CHAR8 *String;
Status = GetPerformanceMeasurementProtocol ();
if (EFI_ERROR (Status)) {
@@ -114,7 +113,7 @@ StartPerformanceMeasurementEx ( ASSERT (FALSE);
}
- return (RETURN_STATUS) Status;
+ return (RETURN_STATUS)Status;
}
/**
@@ -151,8 +150,8 @@ EndPerformanceMeasurementEx ( IN UINT32 Identifier
)
{
- EFI_STATUS Status;
- CONST CHAR8* String;
+ EFI_STATUS Status;
+ CONST CHAR8 *String;
Status = GetPerformanceMeasurementProtocol ();
if (EFI_ERROR (Status)) {
@@ -173,7 +172,7 @@ EndPerformanceMeasurementEx ( ASSERT (FALSE);
}
- return (RETURN_STATUS) Status;
+ return (RETURN_STATUS)Status;
}
/**
@@ -220,17 +219,16 @@ EndPerformanceMeasurementEx ( UINTN
EFIAPI
GetPerformanceMeasurementEx (
- IN UINTN LogEntryKey,
- OUT CONST VOID **Handle,
- OUT CONST CHAR8 **Token,
- OUT CONST CHAR8 **Module,
- OUT UINT64 *StartTimeStamp,
- OUT UINT64 *EndTimeStamp,
- OUT UINT32 *Identifier
+ IN UINTN LogEntryKey,
+ OUT CONST VOID **Handle,
+ OUT CONST CHAR8 **Token,
+ OUT CONST CHAR8 **Module,
+ OUT UINT64 *StartTimeStamp,
+ OUT UINT64 *EndTimeStamp,
+ OUT UINT32 *Identifier
)
{
return 0;
-
}
/**
@@ -341,12 +339,12 @@ EndPerformanceMeasurement ( UINTN
EFIAPI
GetPerformanceMeasurement (
- IN UINTN LogEntryKey,
- OUT CONST VOID **Handle,
- OUT CONST CHAR8 **Token,
- OUT CONST CHAR8 **Module,
- OUT UINT64 *StartTimeStamp,
- OUT UINT64 *EndTimeStamp
+ IN UINTN LogEntryKey,
+ OUT CONST VOID **Handle,
+ OUT CONST CHAR8 **Token,
+ OUT CONST CHAR8 **Module,
+ OUT UINT64 *StartTimeStamp,
+ OUT UINT64 *EndTimeStamp
)
{
return 0;
@@ -370,7 +368,7 @@ PerformanceMeasurementEnabled ( VOID
)
{
- return (BOOLEAN) ((PcdGet8(PcdPerformanceLibraryPropertyMask) & PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED) != 0);
+ return (BOOLEAN)((PcdGet8 (PcdPerformanceLibraryPropertyMask) & PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED) != 0);
}
/**
@@ -394,7 +392,7 @@ LogPerformanceMeasurement ( IN CONST VOID *CallerIdentifier,
IN CONST VOID *Guid OPTIONAL,
IN CONST CHAR8 *String OPTIONAL,
- IN UINT64 Address OPTIONAL,
+ IN UINT64 Address OPTIONAL,
IN UINT32 Identifier
)
{
@@ -411,7 +409,7 @@ LogPerformanceMeasurement ( ASSERT (FALSE);
}
- return (RETURN_STATUS) Status;
+ return (RETURN_STATUS)Status;
}
/**
@@ -429,14 +427,15 @@ LogPerformanceMeasurement ( BOOLEAN
EFIAPI
LogPerformanceMeasurementEnabled (
- IN CONST UINTN Type
+ IN CONST UINTN Type
)
{
//
// When Performance measurement is enabled and the type is not filtered, the performance can be logged.
//
- if (PerformanceMeasurementEnabled () && (PcdGet8(PcdPerformanceLibraryPropertyMask) & Type) == 0) {
+ if (PerformanceMeasurementEnabled () && ((PcdGet8 (PcdPerformanceLibraryPropertyMask) & Type) == 0)) {
return TRUE;
}
+
return FALSE;
}
diff --git a/MdeModulePkg/Library/DxePrintLibPrint2Protocol/PrintLib.c b/MdeModulePkg/Library/DxePrintLibPrint2Protocol/PrintLib.c index b702170388..21f8a0beab 100644 --- a/MdeModulePkg/Library/DxePrintLibPrint2Protocol/PrintLib.c +++ b/MdeModulePkg/Library/DxePrintLibPrint2Protocol/PrintLib.c @@ -21,13 +21,13 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include <Library/DebugLib.h>
#include <Library/PcdLib.h>
-#define ASSERT_UNICODE_BUFFER(Buffer) ASSERT ((((UINTN) (Buffer)) & 0x01) == 0)
+#define ASSERT_UNICODE_BUFFER(Buffer) ASSERT ((((UINTN) (Buffer)) & 0x01) == 0)
//
// Safe print checks
//
-#define RSIZE_MAX (PcdGet32 (PcdMaximumUnicodeStringLength))
-#define ASCII_RSIZE_MAX (PcdGet32 (PcdMaximumAsciiStringLength))
+#define RSIZE_MAX (PcdGet32 (PcdMaximumUnicodeStringLength))
+#define ASCII_RSIZE_MAX (PcdGet32 (PcdMaximumAsciiStringLength))
#define SAFE_PRINT_CONSTRAINT_CHECK(Expression, RetVal) \
do { \
@@ -54,16 +54,16 @@ EFI_PRINT2S_PROTOCOL *mPrint2SProtocol = NULL; EFI_STATUS
EFIAPI
PrintLibConstructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
Status = SystemTable->BootServices->LocateProtocol (
&gEfiPrint2SProtocolGuid,
NULL,
- (VOID**) &mPrint2SProtocol
+ (VOID **)&mPrint2SProtocol
);
ASSERT_EFI_ERROR (Status);
ASSERT (mPrint2SProtocol != NULL);
@@ -71,7 +71,6 @@ PrintLibConstructor ( return Status;
}
-
/**
Worker function that converts a VA_LIST to a BASE_LIST based on a Null-terminated
format string.
@@ -111,14 +110,16 @@ DxePrintLibPrint2ProtocolVaListToBaseList ( if (ASCII_RSIZE_MAX != 0) {
SAFE_PRINT_CONSTRAINT_CHECK ((AsciiStrnLenS (Format, ASCII_RSIZE_MAX + 1) <= ASCII_RSIZE_MAX), FALSE);
}
+
BytesPerFormatCharacter = 1;
- FormatMask = 0xff;
+ FormatMask = 0xff;
} else {
if (RSIZE_MAX != 0) {
SAFE_PRINT_CONSTRAINT_CHECK ((StrnLenS ((CHAR16 *)Format, RSIZE_MAX + 1) <= RSIZE_MAX), FALSE);
}
+
BytesPerFormatCharacter = 2;
- FormatMask = 0xffff;
+ FormatMask = 0xffff;
}
//
@@ -145,41 +146,41 @@ DxePrintLibPrint2ProtocolVaListToBaseList ( FormatCharacter = ((*Format & 0xff) | ((BytesPerFormatCharacter == 1) ? 0 : (*(Format + 1) << 8))) & FormatMask;
switch (FormatCharacter) {
- case '.':
- case '-':
- case '+':
- case ' ':
- case ',':
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- break;
- case 'L':
- case 'l':
- Long = TRUE;
- break;
- case '*':
- BASE_ARG (BaseListMarker, UINTN) = VA_ARG (VaListMarker, UINTN);
- break;
- case '\0':
- //
- // Make no output if Format string terminates unexpectedly when
- // looking up for flag, width, precision and type.
- //
- Format -= BytesPerFormatCharacter;
+ case '.':
+ case '-':
+ case '+':
+ case ' ':
+ case ',':
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ break;
+ case 'L':
+ case 'l':
+ Long = TRUE;
+ break;
+ case '*':
+ BASE_ARG (BaseListMarker, UINTN) = VA_ARG (VaListMarker, UINTN);
+ break;
+ case '\0':
+ //
+ // Make no output if Format string terminates unexpectedly when
+ // looking up for flag, width, precision and type.
+ //
+ Format -= BytesPerFormatCharacter;
//
// break skipped on purpose.
//
- default:
- Done = TRUE;
- break;
+ default:
+ Done = TRUE;
+ break;
}
}
@@ -187,33 +188,35 @@ DxePrintLibPrint2ProtocolVaListToBaseList ( // Handle each argument type
//
switch (FormatCharacter) {
- case 'p':
- if (sizeof (VOID *) > 4) {
- Long = TRUE;
- }
- case 'X':
- case 'x':
- case 'u':
- case 'd':
- if (Long) {
- BASE_ARG (BaseListMarker, INT64) = VA_ARG (VaListMarker, INT64);
- } else {
- BASE_ARG (BaseListMarker, int) = VA_ARG (VaListMarker, int);
- }
- break;
- case 's':
- case 'S':
- case 'a':
- case 'g':
- case 't':
- BASE_ARG (BaseListMarker, VOID *) = VA_ARG (VaListMarker, VOID *);
- break;
- case 'c':
- BASE_ARG (BaseListMarker, UINTN) = VA_ARG (VaListMarker, UINTN);
- break;
- case 'r':
- BASE_ARG (BaseListMarker, RETURN_STATUS) = VA_ARG (VaListMarker, RETURN_STATUS);
- break;
+ case 'p':
+ if (sizeof (VOID *) > 4) {
+ Long = TRUE;
+ }
+
+ case 'X':
+ case 'x':
+ case 'u':
+ case 'd':
+ if (Long) {
+ BASE_ARG (BaseListMarker, INT64) = VA_ARG (VaListMarker, INT64);
+ } else {
+ BASE_ARG (BaseListMarker, int) = VA_ARG (VaListMarker, int);
+ }
+
+ break;
+ case 's':
+ case 'S':
+ case 'a':
+ case 'g':
+ case 't':
+ BASE_ARG (BaseListMarker, VOID *) = VA_ARG (VaListMarker, VOID *);
+ break;
+ case 'c':
+ BASE_ARG (BaseListMarker, UINTN) = VA_ARG (VaListMarker, UINTN);
+ break;
+ case 'r':
+ BASE_ARG (BaseListMarker, RETURN_STATUS) = VA_ARG (VaListMarker, RETURN_STATUS);
+ break;
}
}
@@ -235,6 +238,7 @@ DxePrintLibPrint2ProtocolVaListToBaseList ( //
FormatCharacter = ((*Format & 0xff) | ((BytesPerFormatCharacter == 1) ? 0 : (*(Format + 1) << 8))) & FormatMask;
}
+
return TRUE;
}
@@ -408,8 +412,8 @@ UnicodeSPrint ( ...
)
{
- VA_LIST Marker;
- UINTN NumberOfPrinted;
+ VA_LIST Marker;
+ UINTN NumberOfPrinted;
VA_START (Marker, FormatString);
NumberOfPrinted = UnicodeVSPrint (StartOfBuffer, BufferSize, FormatString, Marker);
@@ -583,8 +587,8 @@ UnicodeSPrintAsciiFormat ( ...
)
{
- VA_LIST Marker;
- UINTN NumberOfPrinted;
+ VA_LIST Marker;
+ UINTN NumberOfPrinted;
VA_START (Marker, FormatString);
NumberOfPrinted = UnicodeVSPrintAsciiFormat (StartOfBuffer, BufferSize, FormatString, Marker);
@@ -696,10 +700,10 @@ UnicodeValueToStringS ( UINTN
EFIAPI
AsciiVSPrint (
- OUT CHAR8 *StartOfBuffer,
- IN UINTN BufferSize,
- IN CONST CHAR8 *FormatString,
- IN VA_LIST Marker
+ OUT CHAR8 *StartOfBuffer,
+ IN UINTN BufferSize,
+ IN CONST CHAR8 *FormatString,
+ IN VA_LIST Marker
)
{
UINT64 BaseListMarker[256 / sizeof (UINT64)];
@@ -757,10 +761,10 @@ AsciiVSPrint ( UINTN
EFIAPI
AsciiBSPrint (
- OUT CHAR8 *StartOfBuffer,
- IN UINTN BufferSize,
- IN CONST CHAR8 *FormatString,
- IN BASE_LIST Marker
+ OUT CHAR8 *StartOfBuffer,
+ IN UINTN BufferSize,
+ IN CONST CHAR8 *FormatString,
+ IN BASE_LIST Marker
)
{
return mPrint2SProtocol->AsciiBSPrint (StartOfBuffer, BufferSize, FormatString, Marker);
@@ -813,8 +817,8 @@ AsciiSPrint ( ...
)
{
- VA_LIST Marker;
- UINTN NumberOfPrinted;
+ VA_LIST Marker;
+ UINTN NumberOfPrinted;
VA_START (Marker, FormatString);
NumberOfPrinted = AsciiVSPrint (StartOfBuffer, BufferSize, FormatString, Marker);
@@ -988,8 +992,8 @@ AsciiSPrintUnicodeFormat ( ...
)
{
- VA_LIST Marker;
- UINTN NumberOfPrinted;
+ VA_LIST Marker;
+ UINTN NumberOfPrinted;
VA_START (Marker, FormatString);
NumberOfPrinted = AsciiVSPrintUnicodeFormat (StartOfBuffer, BufferSize, FormatString, Marker);
@@ -997,7 +1001,6 @@ AsciiSPrintUnicodeFormat ( return NumberOfPrinted;
}
-
/**
Converts a decimal value to a Null-terminated Ascii string.
@@ -1050,46 +1053,46 @@ AsciiSPrintUnicodeFormat ( RETURN_STATUS
EFIAPI
AsciiValueToStringS (
- IN OUT CHAR8 *Buffer,
- IN UINTN BufferSize,
- IN UINTN Flags,
- IN INT64 Value,
- IN UINTN Width
+ IN OUT CHAR8 *Buffer,
+ IN UINTN BufferSize,
+ IN UINTN Flags,
+ IN INT64 Value,
+ IN UINTN Width
)
{
return mPrint2SProtocol->AsciiValueToStringS (Buffer, BufferSize, Flags, Value, Width);
}
-#define PREFIX_SIGN BIT1
-#define PREFIX_BLANK BIT2
-#define LONG_TYPE BIT4
-#define OUTPUT_UNICODE BIT6
-#define FORMAT_UNICODE BIT8
-#define PAD_TO_WIDTH BIT9
-#define ARGUMENT_UNICODE BIT10
-#define PRECISION BIT11
-#define ARGUMENT_REVERSED BIT12
-#define COUNT_ONLY_NO_PRINT BIT13
-#define UNSIGNED_TYPE BIT14
+#define PREFIX_SIGN BIT1
+#define PREFIX_BLANK BIT2
+#define LONG_TYPE BIT4
+#define OUTPUT_UNICODE BIT6
+#define FORMAT_UNICODE BIT8
+#define PAD_TO_WIDTH BIT9
+#define ARGUMENT_UNICODE BIT10
+#define PRECISION BIT11
+#define ARGUMENT_REVERSED BIT12
+#define COUNT_ONLY_NO_PRINT BIT13
+#define UNSIGNED_TYPE BIT14
//
// Record date and time information
//
typedef struct {
- UINT16 Year;
- UINT8 Month;
- UINT8 Day;
- UINT8 Hour;
- UINT8 Minute;
- UINT8 Second;
- UINT8 Pad1;
- UINT32 Nanosecond;
- INT16 TimeZone;
- UINT8 Daylight;
- UINT8 Pad2;
+ UINT16 Year;
+ UINT8 Month;
+ UINT8 Day;
+ UINT8 Hour;
+ UINT8 Minute;
+ UINT8 Second;
+ UINT8 Pad1;
+ UINT32 Nanosecond;
+ INT16 TimeZone;
+ UINT8 Daylight;
+ UINT8 Pad2;
} TIME;
-GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 mHexStr[] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
+GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 mHexStr[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
/**
Internal function that convert a number to a string in Buffer.
@@ -1117,7 +1120,7 @@ InternalPrintLibValueToString ( //
*Buffer = 0;
do {
- Value = (INT64)DivU64x32Remainder ((UINT64)Value, (UINT32)Radix, &Remainder);
+ Value = (INT64)DivU64x32Remainder ((UINT64)Value, (UINT32)Radix, &Remainder);
*(++Buffer) = mHexStr[Remainder];
} while (Value != 0);
@@ -1204,10 +1207,10 @@ InternalPrintLibSPrint ( return NumberOfPrinted;
}
-#define WARNING_STATUS_NUMBER 5
-#define ERROR_STATUS_NUMBER 33
+#define WARNING_STATUS_NUMBER 5
+#define ERROR_STATUS_NUMBER 33
-GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 * CONST mStatusString[] = {
+GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 *CONST mStatusString[] = {
"Success", // RETURN_SUCCESS = 0
"Warning Unknown Glyph", // RETURN_WARN_UNKNOWN_GLYPH = 1
"Warning Delete Failure", // RETURN_WARN_DELETE_FAILURE = 2
@@ -1267,20 +1270,21 @@ GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 * CONST mStatusString[] = { **/
CHAR8 *
InternalPrintLibFillBuffer (
- OUT CHAR8 *Buffer,
- IN CHAR8 *EndBuffer,
- IN INTN Length,
- IN UINTN Character,
- IN INTN Increment
+ OUT CHAR8 *Buffer,
+ IN CHAR8 *EndBuffer,
+ IN INTN Length,
+ IN UINTN Character,
+ IN INTN Increment
)
{
INTN Index;
for (Index = 0; Index < Length && Buffer < EndBuffer; Index++) {
- *Buffer = (CHAR8) Character;
+ *Buffer = (CHAR8)Character;
if (Increment != 1) {
*(Buffer + 1) = (CHAR8)(Character >> 8);
}
+
Buffer += Increment;
}
@@ -1325,36 +1329,36 @@ InternalPrintLibSPrintMarker ( IN BASE_LIST BaseListMarker OPTIONAL
)
{
- CHAR8 *OriginalBuffer;
- CHAR8 *EndBuffer;
- CHAR8 ValueBuffer[MAXIMUM_VALUE_CHARACTERS];
- UINT32 BytesPerOutputCharacter;
- UINTN BytesPerFormatCharacter;
- UINTN FormatMask;
- UINTN FormatCharacter;
- UINTN Width;
- UINTN Precision;
- INT64 Value;
- CONST CHAR8 *ArgumentString;
- UINTN Character;
- GUID *TmpGuid;
- TIME *TmpTime;
- UINTN Count;
- UINTN ArgumentMask;
- INTN BytesPerArgumentCharacter;
- UINTN ArgumentCharacter;
- BOOLEAN Done;
- UINTN Index;
- CHAR8 Prefix;
- BOOLEAN ZeroPad;
- BOOLEAN Comma;
- UINTN Digits;
- UINTN Radix;
- RETURN_STATUS Status;
- UINT32 GuidData1;
- UINT16 GuidData2;
- UINT16 GuidData3;
- UINTN LengthToReturn;
+ CHAR8 *OriginalBuffer;
+ CHAR8 *EndBuffer;
+ CHAR8 ValueBuffer[MAXIMUM_VALUE_CHARACTERS];
+ UINT32 BytesPerOutputCharacter;
+ UINTN BytesPerFormatCharacter;
+ UINTN FormatMask;
+ UINTN FormatCharacter;
+ UINTN Width;
+ UINTN Precision;
+ INT64 Value;
+ CONST CHAR8 *ArgumentString;
+ UINTN Character;
+ GUID *TmpGuid;
+ TIME *TmpTime;
+ UINTN Count;
+ UINTN ArgumentMask;
+ INTN BytesPerArgumentCharacter;
+ UINTN ArgumentCharacter;
+ BOOLEAN Done;
+ UINTN Index;
+ CHAR8 Prefix;
+ BOOLEAN ZeroPad;
+ BOOLEAN Comma;
+ UINTN Digits;
+ UINTN Radix;
+ RETURN_STATUS Status;
+ UINT32 GuidData1;
+ UINT16 GuidData2;
+ UINT16 GuidData3;
+ UINTN LengthToReturn;
//
// If you change this code be sure to match the 2 versions of this function.
@@ -1386,11 +1390,13 @@ InternalPrintLibSPrintMarker ( if (RSIZE_MAX != 0) {
SAFE_PRINT_CONSTRAINT_CHECK ((BufferSize <= RSIZE_MAX), 0);
}
+
BytesPerOutputCharacter = 2;
} else {
if (ASCII_RSIZE_MAX != 0) {
SAFE_PRINT_CONSTRAINT_CHECK ((BufferSize <= ASCII_RSIZE_MAX), 0);
}
+
BytesPerOutputCharacter = 1;
}
@@ -1402,14 +1408,16 @@ InternalPrintLibSPrintMarker ( if (RSIZE_MAX != 0) {
SAFE_PRINT_CONSTRAINT_CHECK ((StrnLenS ((CHAR16 *)Format, RSIZE_MAX + 1) <= RSIZE_MAX), 0);
}
+
BytesPerFormatCharacter = 2;
- FormatMask = 0xffff;
+ FormatMask = 0xffff;
} else {
if (ASCII_RSIZE_MAX != 0) {
SAFE_PRINT_CONSTRAINT_CHECK ((AsciiStrnLenS (Format, ASCII_RSIZE_MAX + 1) <= ASCII_RSIZE_MAX), 0);
}
+
BytesPerFormatCharacter = 1;
- FormatMask = 0xff;
+ FormatMask = 0xff;
}
if ((Flags & COUNT_ONLY_NO_PRINT) != 0) {
@@ -1426,7 +1434,7 @@ InternalPrintLibSPrintMarker ( }
LengthToReturn = 0;
- EndBuffer = NULL;
+ EndBuffer = NULL;
OriginalBuffer = NULL;
//
@@ -1454,10 +1462,11 @@ InternalPrintLibSPrintMarker ( if ((Buffer != NULL) && (Buffer >= EndBuffer)) {
break;
}
+
//
// Clear all the flag bits except those that may have been passed in
//
- Flags &= (UINTN) (OUTPUT_UNICODE | FORMAT_UNICODE | COUNT_ONLY_NO_PRINT);
+ Flags &= (UINTN)(OUTPUT_UNICODE | FORMAT_UNICODE | COUNT_ONLY_NO_PRINT);
//
// Set the default width to zero, and the default precision to 1
@@ -1471,344 +1480,415 @@ InternalPrintLibSPrintMarker ( Digits = 0;
switch (FormatCharacter) {
- case '%':
- //
- // Parse Flags and Width
- //
- for (Done = FALSE; !Done; ) {
- Format += BytesPerFormatCharacter;
- FormatCharacter = ((*Format & 0xff) | ((BytesPerFormatCharacter == 1) ? 0 : (*(Format + 1) << 8))) & FormatMask;
+ case '%':
+ //
+ // Parse Flags and Width
+ //
+ for (Done = FALSE; !Done; ) {
+ Format += BytesPerFormatCharacter;
+ FormatCharacter = ((*Format & 0xff) | ((BytesPerFormatCharacter == 1) ? 0 : (*(Format + 1) << 8))) & FormatMask;
+ switch (FormatCharacter) {
+ case '.':
+ Flags |= PRECISION;
+ break;
+ case '-':
+ Flags |= LEFT_JUSTIFY;
+ break;
+ case '+':
+ Flags |= PREFIX_SIGN;
+ break;
+ case ' ':
+ Flags |= PREFIX_BLANK;
+ break;
+ case ',':
+ Flags |= COMMA_TYPE;
+ break;
+ case 'L':
+ case 'l':
+ Flags |= LONG_TYPE;
+ break;
+ case '*':
+ if ((Flags & PRECISION) == 0) {
+ Flags |= PAD_TO_WIDTH;
+ if (BaseListMarker == NULL) {
+ Width = VA_ARG (VaListMarker, UINTN);
+ } else {
+ Width = BASE_ARG (BaseListMarker, UINTN);
+ }
+ } else {
+ if (BaseListMarker == NULL) {
+ Precision = VA_ARG (VaListMarker, UINTN);
+ } else {
+ Precision = BASE_ARG (BaseListMarker, UINTN);
+ }
+ }
+
+ break;
+ case '0':
+ if ((Flags & PRECISION) == 0) {
+ Flags |= PREFIX_ZERO;
+ }
+
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ for (Count = 0; ((FormatCharacter >= '0') && (FormatCharacter <= '9')); ) {
+ Count = (Count * 10) + FormatCharacter - '0';
+ Format += BytesPerFormatCharacter;
+ FormatCharacter = ((*Format & 0xff) | ((BytesPerFormatCharacter == 1) ? 0 : (*(Format + 1) << 8))) & FormatMask;
+ }
+
+ Format -= BytesPerFormatCharacter;
+ if ((Flags & PRECISION) == 0) {
+ Flags |= PAD_TO_WIDTH;
+ Width = Count;
+ } else {
+ Precision = Count;
+ }
+
+ break;
+
+ case '\0':
+ //
+ // Make no output if Format string terminates unexpectedly when
+ // looking up for flag, width, precision and type.
+ //
+ Format -= BytesPerFormatCharacter;
+ Precision = 0;
+ //
+ // break skipped on purpose.
+ //
+ default:
+ Done = TRUE;
+ break;
+ }
+ }
+
+ //
+ // Handle each argument type
+ //
switch (FormatCharacter) {
- case '.':
- Flags |= PRECISION;
- break;
- case '-':
- Flags |= LEFT_JUSTIFY;
- break;
- case '+':
- Flags |= PREFIX_SIGN;
- break;
- case ' ':
- Flags |= PREFIX_BLANK;
- break;
- case ',':
- Flags |= COMMA_TYPE;
- break;
- case 'L':
- case 'l':
- Flags |= LONG_TYPE;
- break;
- case '*':
- if ((Flags & PRECISION) == 0) {
- Flags |= PAD_TO_WIDTH;
- if (BaseListMarker == NULL) {
- Width = VA_ARG (VaListMarker, UINTN);
- } else {
- Width = BASE_ARG (BaseListMarker, UINTN);
- }
- } else {
- if (BaseListMarker == NULL) {
- Precision = VA_ARG (VaListMarker, UINTN);
- } else {
- Precision = BASE_ARG (BaseListMarker, UINTN);
+ case 'p':
+ //
+ // Flag space, +, 0, L & l are invalid for type p.
+ //
+ Flags &= ~((UINTN)(PREFIX_BLANK | PREFIX_SIGN | PREFIX_ZERO | LONG_TYPE));
+ if (sizeof (VOID *) > 4) {
+ Flags |= LONG_TYPE;
}
- }
- break;
- case '0':
- if ((Flags & PRECISION) == 0) {
- Flags |= PREFIX_ZERO;
- }
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- for (Count = 0; ((FormatCharacter >= '0') && (FormatCharacter <= '9')); ){
- Count = (Count * 10) + FormatCharacter - '0';
- Format += BytesPerFormatCharacter;
- FormatCharacter = ((*Format & 0xff) | ((BytesPerFormatCharacter == 1) ? 0 : (*(Format + 1) << 8))) & FormatMask;
- }
- Format -= BytesPerFormatCharacter;
- if ((Flags & PRECISION) == 0) {
- Flags |= PAD_TO_WIDTH;
- Width = Count;
- } else {
- Precision = Count;
- }
- break;
- case '\0':
//
- // Make no output if Format string terminates unexpectedly when
- // looking up for flag, width, precision and type.
+ // break skipped on purpose
//
- Format -= BytesPerFormatCharacter;
- Precision = 0;
+ case 'X':
+ Flags |= PREFIX_ZERO;
//
- // break skipped on purpose.
+ // break skipped on purpose
//
- default:
- Done = TRUE;
- break;
- }
- }
+ case 'x':
+ Flags |= RADIX_HEX;
+ //
+ // break skipped on purpose
+ //
+ case 'u':
+ if ((Flags & RADIX_HEX) == 0) {
+ Flags &= ~((UINTN)(PREFIX_SIGN));
+ Flags |= UNSIGNED_TYPE;
+ }
- //
- // Handle each argument type
- //
- switch (FormatCharacter) {
- case 'p':
- //
- // Flag space, +, 0, L & l are invalid for type p.
- //
- Flags &= ~((UINTN) (PREFIX_BLANK | PREFIX_SIGN | PREFIX_ZERO | LONG_TYPE));
- if (sizeof (VOID *) > 4) {
- Flags |= LONG_TYPE;
- }
- //
- // break skipped on purpose
- //
- case 'X':
- Flags |= PREFIX_ZERO;
- //
- // break skipped on purpose
- //
- case 'x':
- Flags |= RADIX_HEX;
- //
- // break skipped on purpose
- //
- case 'u':
- if ((Flags & RADIX_HEX) == 0) {
- Flags &= ~((UINTN) (PREFIX_SIGN));
- Flags |= UNSIGNED_TYPE;
- }
- //
- // break skipped on purpose
- //
- case 'd':
- if ((Flags & LONG_TYPE) == 0) {
//
- // 'd', 'u', 'x', and 'X' that are not preceded by 'l' or 'L' are assumed to be type "int".
- // This assumption is made so the format string definition is compatible with the ANSI C
- // Specification for formatted strings. It is recommended that the Base Types be used
- // everywhere, but in this one case, compliance with ANSI C is more important, and
- // provides an implementation that is compatible with that largest possible set of CPU
- // architectures. This is why the type "int" is used in this one case.
+ // break skipped on purpose
//
- if (BaseListMarker == NULL) {
- Value = VA_ARG (VaListMarker, int);
- } else {
- Value = BASE_ARG (BaseListMarker, int);
- }
- } else {
- if (BaseListMarker == NULL) {
- Value = VA_ARG (VaListMarker, INT64);
- } else {
- Value = BASE_ARG (BaseListMarker, INT64);
- }
- }
- if ((Flags & PREFIX_BLANK) != 0) {
- Prefix = ' ';
- }
- if ((Flags & PREFIX_SIGN) != 0) {
- Prefix = '+';
- }
- if ((Flags & COMMA_TYPE) != 0) {
- Comma = TRUE;
- }
- if ((Flags & RADIX_HEX) == 0) {
- Radix = 10;
- if (Comma) {
- Flags &= ~((UINTN) PREFIX_ZERO);
- Precision = 1;
- }
- if (Value < 0 && (Flags & UNSIGNED_TYPE) == 0) {
- Flags |= PREFIX_SIGN;
- Prefix = '-';
- Value = -Value;
- } else if ((Flags & UNSIGNED_TYPE) != 0 && (Flags & LONG_TYPE) == 0) {
+ case 'd':
+ if ((Flags & LONG_TYPE) == 0) {
+ //
+ // 'd', 'u', 'x', and 'X' that are not preceded by 'l' or 'L' are assumed to be type "int".
+ // This assumption is made so the format string definition is compatible with the ANSI C
+ // Specification for formatted strings. It is recommended that the Base Types be used
+ // everywhere, but in this one case, compliance with ANSI C is more important, and
+ // provides an implementation that is compatible with that largest possible set of CPU
+ // architectures. This is why the type "int" is used in this one case.
+ //
+ if (BaseListMarker == NULL) {
+ Value = VA_ARG (VaListMarker, int);
+ } else {
+ Value = BASE_ARG (BaseListMarker, int);
+ }
+ } else {
+ if (BaseListMarker == NULL) {
+ Value = VA_ARG (VaListMarker, INT64);
+ } else {
+ Value = BASE_ARG (BaseListMarker, INT64);
+ }
+ }
+
+ if ((Flags & PREFIX_BLANK) != 0) {
+ Prefix = ' ';
+ }
+
+ if ((Flags & PREFIX_SIGN) != 0) {
+ Prefix = '+';
+ }
+
+ if ((Flags & COMMA_TYPE) != 0) {
+ Comma = TRUE;
+ }
+
+ if ((Flags & RADIX_HEX) == 0) {
+ Radix = 10;
+ if (Comma) {
+ Flags &= ~((UINTN)PREFIX_ZERO);
+ Precision = 1;
+ }
+
+ if ((Value < 0) && ((Flags & UNSIGNED_TYPE) == 0)) {
+ Flags |= PREFIX_SIGN;
+ Prefix = '-';
+ Value = -Value;
+ } else if (((Flags & UNSIGNED_TYPE) != 0) && ((Flags & LONG_TYPE) == 0)) {
+ //
+ // 'd', 'u', 'x', and 'X' that are not preceded by 'l' or 'L' are assumed to be type "int".
+ // This assumption is made so the format string definition is compatible with the ANSI C
+ // Specification for formatted strings. It is recommended that the Base Types be used
+ // everywhere, but in this one case, compliance with ANSI C is more important, and
+ // provides an implementation that is compatible with that largest possible set of CPU
+ // architectures. This is why the type "unsigned int" is used in this one case.
+ //
+ Value = (unsigned int)Value;
+ }
+ } else {
+ Radix = 16;
+ Comma = FALSE;
+ if (((Flags & LONG_TYPE) == 0) && (Value < 0)) {
+ //
+ // 'd', 'u', 'x', and 'X' that are not preceded by 'l' or 'L' are assumed to be type "int".
+ // This assumption is made so the format string definition is compatible with the ANSI C
+ // Specification for formatted strings. It is recommended that the Base Types be used
+ // everywhere, but in this one case, compliance with ANSI C is more important, and
+ // provides an implementation that is compatible with that largest possible set of CPU
+ // architectures. This is why the type "unsigned int" is used in this one case.
+ //
+ Value = (unsigned int)Value;
+ }
+ }
+
//
- // 'd', 'u', 'x', and 'X' that are not preceded by 'l' or 'L' are assumed to be type "int".
- // This assumption is made so the format string definition is compatible with the ANSI C
- // Specification for formatted strings. It is recommended that the Base Types be used
- // everywhere, but in this one case, compliance with ANSI C is more important, and
- // provides an implementation that is compatible with that largest possible set of CPU
- // architectures. This is why the type "unsigned int" is used in this one case.
+ // Convert Value to a reversed string
//
- Value = (unsigned int)Value;
- }
- } else {
- Radix = 16;
- Comma = FALSE;
- if ((Flags & LONG_TYPE) == 0 && Value < 0) {
+ Count = InternalPrintLibValueToString (ValueBuffer, Value, Radix) - ValueBuffer;
+ if ((Value == 0) && (Precision == 0)) {
+ Count = 0;
+ }
+
+ ArgumentString = (CHAR8 *)ValueBuffer + Count;
+
+ Digits = Count % 3;
+ if (Digits != 0) {
+ Digits = 3 - Digits;
+ }
+
+ if (Comma && (Count != 0)) {
+ Count += ((Count - 1) / 3);
+ }
+
+ if (Prefix != 0) {
+ Count++;
+ Precision++;
+ }
+
+ Flags |= ARGUMENT_REVERSED;
+ ZeroPad = TRUE;
+ if ((Flags & PREFIX_ZERO) != 0) {
+ if ((Flags & LEFT_JUSTIFY) == 0) {
+ if ((Flags & PAD_TO_WIDTH) != 0) {
+ if ((Flags & PRECISION) == 0) {
+ Precision = Width;
+ }
+ }
+ }
+ }
+
+ break;
+
+ case 's':
+ case 'S':
+ Flags |= ARGUMENT_UNICODE;
+ //
+ // break skipped on purpose
+ //
+ case 'a':
+ if (BaseListMarker == NULL) {
+ ArgumentString = VA_ARG (VaListMarker, CHAR8 *);
+ } else {
+ ArgumentString = BASE_ARG (BaseListMarker, CHAR8 *);
+ }
+
+ if (ArgumentString == NULL) {
+ Flags &= (~(UINTN)ARGUMENT_UNICODE);
+ ArgumentString = "<null string>";
+ }
+
//
- // 'd', 'u', 'x', and 'X' that are not preceded by 'l' or 'L' are assumed to be type "int".
- // This assumption is made so the format string definition is compatible with the ANSI C
- // Specification for formatted strings. It is recommended that the Base Types be used
- // everywhere, but in this one case, compliance with ANSI C is more important, and
- // provides an implementation that is compatible with that largest possible set of CPU
- // architectures. This is why the type "unsigned int" is used in this one case.
+ // Set the default precision for string to be zero if not specified.
//
- Value = (unsigned int)Value;
- }
- }
- //
- // Convert Value to a reversed string
- //
- Count = InternalPrintLibValueToString (ValueBuffer, Value, Radix) - ValueBuffer;
- if (Value == 0 && Precision == 0) {
- Count = 0;
- }
- ArgumentString = (CHAR8 *)ValueBuffer + Count;
+ if ((Flags & PRECISION) == 0) {
+ Precision = 0;
+ }
- Digits = Count % 3;
- if (Digits != 0) {
- Digits = 3 - Digits;
- }
- if (Comma && Count != 0) {
- Count += ((Count - 1) / 3);
- }
- if (Prefix != 0) {
- Count++;
- Precision++;
- }
- Flags |= ARGUMENT_REVERSED;
- ZeroPad = TRUE;
- if ((Flags & PREFIX_ZERO) != 0) {
- if ((Flags & LEFT_JUSTIFY) == 0) {
- if ((Flags & PAD_TO_WIDTH) != 0) {
- if ((Flags & PRECISION) == 0) {
- Precision = Width;
+ break;
+
+ case 'c':
+ if (BaseListMarker == NULL) {
+ Character = VA_ARG (VaListMarker, UINTN) & 0xffff;
+ } else {
+ Character = BASE_ARG (BaseListMarker, UINTN) & 0xffff;
+ }
+
+ ArgumentString = (CHAR8 *)&Character;
+ Flags |= ARGUMENT_UNICODE;
+ break;
+
+ case 'g':
+ if (BaseListMarker == NULL) {
+ TmpGuid = VA_ARG (VaListMarker, GUID *);
+ } else {
+ TmpGuid = BASE_ARG (BaseListMarker, GUID *);
+ }
+
+ if (TmpGuid == NULL) {
+ ArgumentString = "<null guid>";
+ } else {
+ GuidData1 = ReadUnaligned32 (&(TmpGuid->Data1));
+ GuidData2 = ReadUnaligned16 (&(TmpGuid->Data2));
+ GuidData3 = ReadUnaligned16 (&(TmpGuid->Data3));
+ InternalPrintLibSPrint (
+ ValueBuffer,
+ MAXIMUM_VALUE_CHARACTERS,
+ 0,
+ "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
+ GuidData1,
+ GuidData2,
+ GuidData3,
+ TmpGuid->Data4[0],
+ TmpGuid->Data4[1],
+ TmpGuid->Data4[2],
+ TmpGuid->Data4[3],
+ TmpGuid->Data4[4],
+ TmpGuid->Data4[5],
+ TmpGuid->Data4[6],
+ TmpGuid->Data4[7]
+ );
+ ArgumentString = ValueBuffer;
+ }
+
+ break;
+
+ case 't':
+ if (BaseListMarker == NULL) {
+ TmpTime = VA_ARG (VaListMarker, TIME *);
+ } else {
+ TmpTime = BASE_ARG (BaseListMarker, TIME *);
+ }
+
+ if (TmpTime == NULL) {
+ ArgumentString = "<null time>";
+ } else {
+ InternalPrintLibSPrint (
+ ValueBuffer,
+ MAXIMUM_VALUE_CHARACTERS,
+ 0,
+ "%02d/%02d/%04d %02d:%02d",
+ TmpTime->Month,
+ TmpTime->Day,
+ TmpTime->Year,
+ TmpTime->Hour,
+ TmpTime->Minute
+ );
+ ArgumentString = ValueBuffer;
+ }
+
+ break;
+
+ case 'r':
+ if (BaseListMarker == NULL) {
+ Status = VA_ARG (VaListMarker, RETURN_STATUS);
+ } else {
+ Status = BASE_ARG (BaseListMarker, RETURN_STATUS);
+ }
+
+ ArgumentString = ValueBuffer;
+ if (RETURN_ERROR (Status)) {
+ //
+ // Clear error bit
+ //
+ Index = Status & ~MAX_BIT;
+ if ((Index > 0) && (Index <= ERROR_STATUS_NUMBER)) {
+ ArgumentString = mStatusString[Index + WARNING_STATUS_NUMBER];
+ }
+ } else {
+ Index = Status;
+ if (Index <= WARNING_STATUS_NUMBER) {
+ ArgumentString = mStatusString[Index];
}
}
- }
- }
- break;
- case 's':
- case 'S':
- Flags |= ARGUMENT_UNICODE;
- //
- // break skipped on purpose
- //
- case 'a':
- if (BaseListMarker == NULL) {
- ArgumentString = VA_ARG (VaListMarker, CHAR8 *);
- } else {
- ArgumentString = BASE_ARG (BaseListMarker, CHAR8 *);
- }
- if (ArgumentString == NULL) {
- Flags &= (~(UINTN)ARGUMENT_UNICODE);
- ArgumentString = "<null string>";
- }
- //
- // Set the default precision for string to be zero if not specified.
- //
- if ((Flags & PRECISION) == 0) {
- Precision = 0;
- }
- break;
+ if (ArgumentString == ValueBuffer) {
+ InternalPrintLibSPrint ((CHAR8 *)ValueBuffer, MAXIMUM_VALUE_CHARACTERS, 0, "%08X", Status);
+ }
- case 'c':
- if (BaseListMarker == NULL) {
- Character = VA_ARG (VaListMarker, UINTN) & 0xffff;
- } else {
- Character = BASE_ARG (BaseListMarker, UINTN) & 0xffff;
- }
- ArgumentString = (CHAR8 *)&Character;
- Flags |= ARGUMENT_UNICODE;
- break;
+ break;
- case 'g':
- if (BaseListMarker == NULL) {
- TmpGuid = VA_ARG (VaListMarker, GUID *);
- } else {
- TmpGuid = BASE_ARG (BaseListMarker, GUID *);
- }
- if (TmpGuid == NULL) {
- ArgumentString = "<null guid>";
- } else {
- GuidData1 = ReadUnaligned32 (&(TmpGuid->Data1));
- GuidData2 = ReadUnaligned16 (&(TmpGuid->Data2));
- GuidData3 = ReadUnaligned16 (&(TmpGuid->Data3));
- InternalPrintLibSPrint (
- ValueBuffer,
- MAXIMUM_VALUE_CHARACTERS,
- 0,
- "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
- GuidData1,
- GuidData2,
- GuidData3,
- TmpGuid->Data4[0],
- TmpGuid->Data4[1],
- TmpGuid->Data4[2],
- TmpGuid->Data4[3],
- TmpGuid->Data4[4],
- TmpGuid->Data4[5],
- TmpGuid->Data4[6],
- TmpGuid->Data4[7]
- );
- ArgumentString = ValueBuffer;
- }
- break;
+ case '\r':
+ Format += BytesPerFormatCharacter;
+ FormatCharacter = ((*Format & 0xff) | ((BytesPerFormatCharacter == 1) ? 0 : (*(Format + 1) << 8))) & FormatMask;
+ if (FormatCharacter == '\n') {
+ //
+ // Translate '\r\n' to '\r\n'
+ //
+ ArgumentString = "\r\n";
+ } else {
+ //
+ // Translate '\r' to '\r'
+ //
+ ArgumentString = "\r";
+ Format -= BytesPerFormatCharacter;
+ }
- case 't':
- if (BaseListMarker == NULL) {
- TmpTime = VA_ARG (VaListMarker, TIME *);
- } else {
- TmpTime = BASE_ARG (BaseListMarker, TIME *);
- }
- if (TmpTime == NULL) {
- ArgumentString = "<null time>";
- } else {
- InternalPrintLibSPrint (
- ValueBuffer,
- MAXIMUM_VALUE_CHARACTERS,
- 0,
- "%02d/%02d/%04d %02d:%02d",
- TmpTime->Month,
- TmpTime->Day,
- TmpTime->Year,
- TmpTime->Hour,
- TmpTime->Minute
- );
- ArgumentString = ValueBuffer;
- }
- break;
+ break;
- case 'r':
- if (BaseListMarker == NULL) {
- Status = VA_ARG (VaListMarker, RETURN_STATUS);
- } else {
- Status = BASE_ARG (BaseListMarker, RETURN_STATUS);
- }
- ArgumentString = ValueBuffer;
- if (RETURN_ERROR (Status)) {
- //
- // Clear error bit
- //
- Index = Status & ~MAX_BIT;
- if (Index > 0 && Index <= ERROR_STATUS_NUMBER) {
- ArgumentString = mStatusString [Index + WARNING_STATUS_NUMBER];
- }
- } else {
- Index = Status;
- if (Index <= WARNING_STATUS_NUMBER) {
- ArgumentString = mStatusString [Index];
- }
- }
- if (ArgumentString == ValueBuffer) {
- InternalPrintLibSPrint ((CHAR8 *) ValueBuffer, MAXIMUM_VALUE_CHARACTERS, 0, "%08X", Status);
+ case '\n':
+ //
+ // Translate '\n' to '\r\n' and '\n\r' to '\r\n'
+ //
+ ArgumentString = "\r\n";
+ Format += BytesPerFormatCharacter;
+ FormatCharacter = ((*Format & 0xff) | ((BytesPerFormatCharacter == 1) ? 0 : (*(Format + 1) << 8))) & FormatMask;
+ if (FormatCharacter != '\r') {
+ Format -= BytesPerFormatCharacter;
+ }
+
+ break;
+
+ case '%':
+ default:
+ //
+ // if the type is '%' or unknown, then print it to the screen
+ //
+ ArgumentString = (CHAR8 *)&FormatCharacter;
+ Flags |= ARGUMENT_UNICODE;
+ break;
}
+
break;
case '\r':
- Format += BytesPerFormatCharacter;
+ Format += BytesPerFormatCharacter;
FormatCharacter = ((*Format & 0xff) | ((BytesPerFormatCharacter == 1) ? 0 : (*(Format + 1) << 8))) & FormatMask;
if (FormatCharacter == '\n') {
//
@@ -1820,78 +1900,41 @@ InternalPrintLibSPrintMarker ( // Translate '\r' to '\r'
//
ArgumentString = "\r";
- Format -= BytesPerFormatCharacter;
+ Format -= BytesPerFormatCharacter;
}
+
break;
case '\n':
//
// Translate '\n' to '\r\n' and '\n\r' to '\r\n'
//
- ArgumentString = "\r\n";
- Format += BytesPerFormatCharacter;
+ ArgumentString = "\r\n";
+ Format += BytesPerFormatCharacter;
FormatCharacter = ((*Format & 0xff) | ((BytesPerFormatCharacter == 1) ? 0 : (*(Format + 1) << 8))) & FormatMask;
if (FormatCharacter != '\r') {
- Format -= BytesPerFormatCharacter;
+ Format -= BytesPerFormatCharacter;
}
+
break;
- case '%':
default:
- //
- // if the type is '%' or unknown, then print it to the screen
- //
ArgumentString = (CHAR8 *)&FormatCharacter;
- Flags |= ARGUMENT_UNICODE;
+ Flags |= ARGUMENT_UNICODE;
break;
- }
- break;
-
- case '\r':
- Format += BytesPerFormatCharacter;
- FormatCharacter = ((*Format & 0xff) | ((BytesPerFormatCharacter == 1) ? 0 : (*(Format + 1) << 8))) & FormatMask;
- if (FormatCharacter == '\n') {
- //
- // Translate '\r\n' to '\r\n'
- //
- ArgumentString = "\r\n";
- } else {
- //
- // Translate '\r' to '\r'
- //
- ArgumentString = "\r";
- Format -= BytesPerFormatCharacter;
- }
- break;
-
- case '\n':
- //
- // Translate '\n' to '\r\n' and '\n\r' to '\r\n'
- //
- ArgumentString = "\r\n";
- Format += BytesPerFormatCharacter;
- FormatCharacter = ((*Format & 0xff) | ((BytesPerFormatCharacter == 1) ? 0 : (*(Format + 1) << 8))) & FormatMask;
- if (FormatCharacter != '\r') {
- Format -= BytesPerFormatCharacter;
- }
- break;
-
- default:
- ArgumentString = (CHAR8 *)&FormatCharacter;
- Flags |= ARGUMENT_UNICODE;
- break;
}
//
// Retrieve the ArgumentString attriubutes
//
if ((Flags & ARGUMENT_UNICODE) != 0) {
- ArgumentMask = 0xffff;
+ ArgumentMask = 0xffff;
BytesPerArgumentCharacter = 2;
} else {
- ArgumentMask = 0xff;
+ ArgumentMask = 0xff;
BytesPerArgumentCharacter = 1;
}
+
if ((Flags & ARGUMENT_REVERSED) != 0) {
BytesPerArgumentCharacter = -BytesPerArgumentCharacter;
} else {
@@ -1900,11 +1943,12 @@ InternalPrintLibSPrintMarker ( // ArgumentString is either null-terminated, or it contains Precision characters
//
for (Count = 0;
- (ArgumentString[Count * BytesPerArgumentCharacter] != '\0' ||
- (BytesPerArgumentCharacter > 1 &&
- ArgumentString[Count * BytesPerArgumentCharacter + 1]!= '\0')) &&
- (Count < Precision || ((Flags & PRECISION) == 0));
- Count++) {
+ (ArgumentString[Count * BytesPerArgumentCharacter] != '\0' ||
+ (BytesPerArgumentCharacter > 1 &&
+ ArgumentString[Count * BytesPerArgumentCharacter + 1] != '\0')) &&
+ (Count < Precision || ((Flags & PRECISION) == 0));
+ Count++)
+ {
ArgumentCharacter = ((ArgumentString[Count * BytesPerArgumentCharacter] & 0xff) | ((ArgumentString[Count * BytesPerArgumentCharacter + 1]) << 8)) & ArgumentMask;
if (ArgumentCharacter == 0) {
break;
@@ -1921,7 +1965,7 @@ InternalPrintLibSPrintMarker ( //
if ((Flags & (PAD_TO_WIDTH | LEFT_JUSTIFY)) == (PAD_TO_WIDTH)) {
LengthToReturn += ((Width - Precision) * BytesPerOutputCharacter);
- if ((Flags & COUNT_ONLY_NO_PRINT) == 0 && Buffer != NULL) {
+ if (((Flags & COUNT_ONLY_NO_PRINT) == 0) && (Buffer != NULL)) {
Buffer = InternalPrintLibFillBuffer (Buffer, EndBuffer, Width - Precision, ' ', BytesPerOutputCharacter);
}
}
@@ -1929,22 +1973,24 @@ InternalPrintLibSPrintMarker ( if (ZeroPad) {
if (Prefix != 0) {
LengthToReturn += (1 * BytesPerOutputCharacter);
- if ((Flags & COUNT_ONLY_NO_PRINT) == 0 && Buffer != NULL) {
+ if (((Flags & COUNT_ONLY_NO_PRINT) == 0) && (Buffer != NULL)) {
Buffer = InternalPrintLibFillBuffer (Buffer, EndBuffer, 1, Prefix, BytesPerOutputCharacter);
}
}
+
LengthToReturn += ((Precision - Count) * BytesPerOutputCharacter);
- if ((Flags & COUNT_ONLY_NO_PRINT) == 0 && Buffer != NULL) {
+ if (((Flags & COUNT_ONLY_NO_PRINT) == 0) && (Buffer != NULL)) {
Buffer = InternalPrintLibFillBuffer (Buffer, EndBuffer, Precision - Count, '0', BytesPerOutputCharacter);
}
} else {
LengthToReturn += ((Precision - Count) * BytesPerOutputCharacter);
- if ((Flags & COUNT_ONLY_NO_PRINT) == 0 && Buffer != NULL) {
+ if (((Flags & COUNT_ONLY_NO_PRINT) == 0) && (Buffer != NULL)) {
Buffer = InternalPrintLibFillBuffer (Buffer, EndBuffer, Precision - Count, ' ', BytesPerOutputCharacter);
}
+
if (Prefix != 0) {
LengthToReturn += (1 * BytesPerOutputCharacter);
- if ((Flags & COUNT_ONLY_NO_PRINT) == 0 && Buffer != NULL) {
+ if (((Flags & COUNT_ONLY_NO_PRINT) == 0) && (Buffer != NULL)) {
Buffer = InternalPrintLibFillBuffer (Buffer, EndBuffer, 1, Prefix, BytesPerOutputCharacter);
}
}
@@ -1963,14 +2009,16 @@ InternalPrintLibSPrintMarker ( //
while (Index < Count &&
(ArgumentString[0] != '\0' ||
- (BytesPerArgumentCharacter > 1 && ArgumentString[1] != '\0'))) {
+ (BytesPerArgumentCharacter > 1 && ArgumentString[1] != '\0')))
+ {
ArgumentCharacter = ((*ArgumentString & 0xff) | (((UINT8)*(ArgumentString + 1)) << 8)) & ArgumentMask;
LengthToReturn += (1 * BytesPerOutputCharacter);
- if ((Flags & COUNT_ONLY_NO_PRINT) == 0 && Buffer != NULL) {
+ if (((Flags & COUNT_ONLY_NO_PRINT) == 0) && (Buffer != NULL)) {
Buffer = InternalPrintLibFillBuffer (Buffer, EndBuffer, 1, ArgumentCharacter, BytesPerOutputCharacter);
}
- ArgumentString += BytesPerArgumentCharacter;
+
+ ArgumentString += BytesPerArgumentCharacter;
Index++;
if (Comma) {
Digits++;
@@ -1979,7 +2027,7 @@ InternalPrintLibSPrintMarker ( Index++;
if (Index < Count) {
LengthToReturn += (1 * BytesPerOutputCharacter);
- if ((Flags & COUNT_ONLY_NO_PRINT) == 0 && Buffer != NULL) {
+ if (((Flags & COUNT_ONLY_NO_PRINT) == 0) && (Buffer != NULL)) {
Buffer = InternalPrintLibFillBuffer (Buffer, EndBuffer, 1, ',', BytesPerOutputCharacter);
}
}
@@ -1992,7 +2040,7 @@ InternalPrintLibSPrintMarker ( //
if ((Flags & (PAD_TO_WIDTH | LEFT_JUSTIFY)) == (PAD_TO_WIDTH | LEFT_JUSTIFY)) {
LengthToReturn += ((Width - Precision) * BytesPerOutputCharacter);
- if ((Flags & COUNT_ONLY_NO_PRINT) == 0 && Buffer != NULL) {
+ if (((Flags & COUNT_ONLY_NO_PRINT) == 0) && (Buffer != NULL)) {
Buffer = InternalPrintLibFillBuffer (Buffer, EndBuffer, Width - Precision, ' ', BytesPerOutputCharacter);
}
}
@@ -2041,7 +2089,7 @@ InternalPrintLibSPrintMarker ( UINTN
EFIAPI
SPrintLength (
- IN CONST CHAR16 *FormatString,
+ IN CONST CHAR16 *FormatString,
IN VA_LIST Marker
)
{
@@ -2067,8 +2115,8 @@ SPrintLength ( UINTN
EFIAPI
SPrintLengthAsciiFormat (
- IN CONST CHAR8 *FormatString,
- IN VA_LIST Marker
+ IN CONST CHAR8 *FormatString,
+ IN VA_LIST Marker
)
{
return InternalPrintLibSPrintMarker (NULL, 0, OUTPUT_UNICODE | COUNT_ONLY_NO_PRINT, (CHAR8 *)FormatString, Marker, NULL);
diff --git a/MdeModulePkg/Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c b/MdeModulePkg/Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c index 92559a54f3..ed01d8aacb 100644 --- a/MdeModulePkg/Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c +++ b/MdeModulePkg/Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c @@ -47,8 +47,8 @@ InternalGetReportStatusCode ( //
// Check gBS just in case ReportStatusCode is called before gBS is initialized.
//
- if (gBS != NULL && gBS->LocateProtocol != NULL) {
- Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID**) &mReportStatusCodeLibStatusCodeProtocol);
+ if ((gBS != NULL) && (gBS->LocateProtocol != NULL)) {
+ Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID **)&mReportStatusCodeLibStatusCodeProtocol);
if (EFI_ERROR (Status)) {
mReportStatusCodeLibStatusCodeProtocol = NULL;
}
@@ -80,16 +80,17 @@ InternalGetReportStatusCode ( **/
EFI_STATUS
InternalReportStatusCode (
- IN EFI_STATUS_CODE_TYPE Type,
- IN EFI_STATUS_CODE_VALUE Value,
- IN UINT32 Instance,
- IN CONST EFI_GUID *CallerId OPTIONAL,
- IN EFI_STATUS_CODE_DATA *Data OPTIONAL
+ IN EFI_STATUS_CODE_TYPE Type,
+ IN EFI_STATUS_CODE_VALUE Value,
+ IN UINT32 Instance,
+ IN CONST EFI_GUID *CallerId OPTIONAL,
+ IN EFI_STATUS_CODE_DATA *Data OPTIONAL
)
{
- if ((ReportProgressCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) ||
- (ReportErrorCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) ||
- (ReportDebugCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE)) {
+ if ((ReportProgressCodeEnabled () && (((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE)) ||
+ (ReportErrorCodeEnabled () && (((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE)) ||
+ (ReportDebugCodeEnabled () && (((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE)))
+ {
//
// If mReportStatusCodeLibStatusCodeProtocol is NULL, then check if Report Status Code Protocol is available in system.
//
@@ -107,7 +108,6 @@ InternalReportStatusCode ( return EFI_UNSUPPORTED;
}
-
/**
Converts a status code to an 8-bit POST code value.
@@ -146,15 +146,16 @@ CodeTypeToPostCode ( // Convert Value to an 8 bit post code
//
if (((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) ||
- ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) ) {
- *PostCode = (UINT8) ((((Value & EFI_STATUS_CODE_CLASS_MASK) >> 24) << 5) |
- (((Value & EFI_STATUS_CODE_SUBCLASS_MASK) >> 16) & 0x1f));
+ ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE))
+ {
+ *PostCode = (UINT8)((((Value & EFI_STATUS_CODE_CLASS_MASK) >> 24) << 5) |
+ (((Value & EFI_STATUS_CODE_SUBCLASS_MASK) >> 16) & 0x1f));
return TRUE;
}
+
return FALSE;
}
-
/**
Extracts ASSERT() information from a status code structure.
@@ -208,17 +209,18 @@ ReportStatusCodeExtractAssertInfo ( if (((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) &&
((CodeType & EFI_STATUS_CODE_SEVERITY_MASK) == EFI_ERROR_UNRECOVERED) &&
- ((Value & EFI_STATUS_CODE_OPERATION_MASK) == EFI_SW_EC_ILLEGAL_SOFTWARE_STATE)) {
+ ((Value & EFI_STATUS_CODE_OPERATION_MASK) == EFI_SW_EC_ILLEGAL_SOFTWARE_STATE))
+ {
AssertData = (EFI_DEBUG_ASSERT_DATA *)(Data + 1);
*Filename = (CHAR8 *)(AssertData + 1);
*Description = *Filename + AsciiStrLen (*Filename) + 1;
*LineNumber = AssertData->LineNumber;
return TRUE;
}
+
return FALSE;
}
-
/**
Extracts DEBUG() information from a status code structure.
@@ -287,13 +289,12 @@ ReportStatusCodeExtractDebugInfo ( // 64-bit aligned is a must, otherwise retrieving 64-bit parameter from BASE_LIST will
// cause unalignment exception.
//
- *Marker = (BASE_LIST) (DebugInfo + 1);
+ *Marker = (BASE_LIST)(DebugInfo + 1);
*Format = (CHAR8 *)(((UINT64 *)*Marker) + 12);
return TRUE;
}
-
/**
Reports a status code.
@@ -325,7 +326,6 @@ ReportStatusCode ( return InternalReportStatusCode (Type, Value, 0, &gEfiCallerIdGuid, NULL);
}
-
/**
Reports a status code with a Device Path Protocol as the extended data.
@@ -371,7 +371,6 @@ ReportStatusCodeWithDevicePath ( );
}
-
/**
Reports a status code with an extended data buffer.
@@ -427,7 +426,6 @@ ReportStatusCodeWithExtendedData ( );
}
-
/**
Reports a status code with full parameters.
@@ -496,7 +494,7 @@ ReportStatusCodeEx ( //
StatusCodeData = (EFI_STATUS_CODE_DATA *)Buffer;
} else {
- if (gBS == NULL || gBS->AllocatePool == NULL || gBS->FreePool == NULL) {
+ if ((gBS == NULL) || (gBS->AllocatePool == NULL) || (gBS->FreePool == NULL)) {
return EFI_UNSUPPORTED;
}
@@ -523,11 +521,12 @@ ReportStatusCodeEx ( //
// Fill in the extended data header
//
- StatusCodeData->HeaderSize = (UINT16) sizeof (EFI_STATUS_CODE_DATA);
- StatusCodeData->Size = (UINT16) ExtendedDataSize;
+ StatusCodeData->HeaderSize = (UINT16)sizeof (EFI_STATUS_CODE_DATA);
+ StatusCodeData->Size = (UINT16)ExtendedDataSize;
if (ExtendedDataGuid == NULL) {
ExtendedDataGuid = &gEfiStatusCodeSpecificDataGuid;
}
+
CopyGuid (&StatusCodeData->Type, ExtendedDataGuid);
//
@@ -543,6 +542,7 @@ ReportStatusCodeEx ( if (CallerId == NULL) {
CallerId = &gEfiCallerIdGuid;
}
+
Status = InternalReportStatusCode (Type, Value, Instance, CallerId, StatusCodeData);
//
@@ -555,7 +555,6 @@ ReportStatusCodeEx ( return Status;
}
-
/**
Returns TRUE if status codes of type EFI_PROGRESS_CODE are enabled
@@ -574,10 +573,9 @@ ReportProgressCodeEnabled ( VOID
)
{
- return (BOOLEAN) ((PcdGet8 (PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED) != 0);
+ return (BOOLEAN)((PcdGet8 (PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED) != 0);
}
-
/**
Returns TRUE if status codes of type EFI_ERROR_CODE are enabled
@@ -596,10 +594,9 @@ ReportErrorCodeEnabled ( VOID
)
{
- return (BOOLEAN) ((PcdGet8 (PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED) != 0);
+ return (BOOLEAN)((PcdGet8 (PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED) != 0);
}
-
/**
Returns TRUE if status codes of type EFI_DEBUG_CODE are enabled
@@ -618,5 +615,5 @@ ReportDebugCodeEnabled ( VOID
)
{
- return (BOOLEAN) ((PcdGet8 (PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED) != 0);
+ return (BOOLEAN)((PcdGet8 (PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED) != 0);
}
diff --git a/MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.c b/MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.c index 47b814fe8d..98e979dff6 100644 --- a/MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.c +++ b/MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.c @@ -71,8 +71,8 @@ ResetShutdown ( VOID
EFIAPI
ResetPlatformSpecific (
- IN UINTN DataSize,
- IN VOID *ResetData
+ IN UINTN DataSize,
+ IN VOID *ResetData
)
{
gRT->ResetSystem (EfiResetPlatformSpecific, EFI_SUCCESS, DataSize, ResetData);
@@ -93,10 +93,10 @@ ResetPlatformSpecific ( VOID
EFIAPI
ResetSystem (
- IN EFI_RESET_TYPE ResetType,
- IN EFI_STATUS ResetStatus,
- IN UINTN DataSize,
- IN VOID *ResetData OPTIONAL
+ IN EFI_RESET_TYPE ResetType,
+ IN EFI_STATUS ResetStatus,
+ IN UINTN DataSize,
+ IN VOID *ResetData OPTIONAL
)
{
gRT->ResetSystem (ResetType, ResetStatus, DataSize, ResetData);
diff --git a/MdeModulePkg/Library/DxeResetSystemLib/UnitTest/DxeResetSystemLibUnitTest.c b/MdeModulePkg/Library/DxeResetSystemLib/UnitTest/DxeResetSystemLibUnitTest.c index 3bba38b579..c286f57c85 100644 --- a/MdeModulePkg/Library/DxeResetSystemLib/UnitTest/DxeResetSystemLibUnitTest.c +++ b/MdeModulePkg/Library/DxeResetSystemLib/UnitTest/DxeResetSystemLibUnitTest.c @@ -22,8 +22,8 @@ #include <Library/UnitTestLib.h>
#include <Library/ResetSystemLib.h>
-#define UNIT_TEST_APP_NAME "DxeResetSystemLib Unit Tests"
-#define UNIT_TEST_APP_VERSION "1.0"
+#define UNIT_TEST_APP_NAME "DxeResetSystemLib Unit Tests"
+#define UNIT_TEST_APP_VERSION "1.0"
/**
Resets the entire platform.
@@ -44,10 +44,10 @@ STATIC VOID
EFIAPI
MockResetSystem (
- IN EFI_RESET_TYPE ResetType,
- IN EFI_STATUS ResetStatus,
- IN UINTN DataSize,
- IN VOID *ResetData OPTIONAL
+ IN EFI_RESET_TYPE ResetType,
+ IN EFI_STATUS ResetStatus,
+ IN UINTN DataSize,
+ IN VOID *ResetData OPTIONAL
)
{
check_expected_ptr (ResetType);
@@ -256,15 +256,15 @@ UnitTestingEntry ( Framework = NULL;
- DEBUG(( DEBUG_INFO, "%a v%a\n", UNIT_TEST_APP_NAME, UNIT_TEST_APP_VERSION ));
+ DEBUG ((DEBUG_INFO, "%a v%a\n", UNIT_TEST_APP_NAME, UNIT_TEST_APP_VERSION));
//
// Start setting up the test framework for running the tests.
//
Status = InitUnitTestFramework (&Framework, UNIT_TEST_APP_NAME, gEfiCallerBaseName, UNIT_TEST_APP_VERSION);
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "Failed in InitUnitTestFramework. Status = %r\n", Status));
- goto EXIT;
+ DEBUG ((DEBUG_ERROR, "Failed in InitUnitTestFramework. Status = %r\n", Status));
+ goto EXIT;
}
//
@@ -304,8 +304,8 @@ EXIT: **/
int
main (
- int argc,
- char *argv[]
+ int argc,
+ char *argv[]
)
{
return UnitTestingEntry ();
diff --git a/MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.c b/MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.c index f72d9a0362..8b8cf3a7d3 100644 --- a/MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.c +++ b/MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.c @@ -15,7 +15,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include <Library/DevicePathLib.h>
#include <Library/UefiBootServicesTableLib.h>
-#define SECURITY_HANDLER_TABLE_SIZE 0x10
+#define SECURITY_HANDLER_TABLE_SIZE 0x10
//
// Secruity Operation on Image and none Image.
@@ -27,24 +27,24 @@ SPDX-License-Identifier: BSD-2-Clause-Patent | EFI_AUTH_OPERATION_AUTHENTICATION_STATE)
typedef struct {
- UINT32 SecurityOperation;
- SECURITY_FILE_AUTHENTICATION_STATE_HANDLER SecurityHandler;
+ UINT32 SecurityOperation;
+ SECURITY_FILE_AUTHENTICATION_STATE_HANDLER SecurityHandler;
} SECURITY_INFO;
typedef struct {
- UINT32 Security2Operation;
- SECURITY2_FILE_AUTHENTICATION_HANDLER Security2Handler;
+ UINT32 Security2Operation;
+ SECURITY2_FILE_AUTHENTICATION_HANDLER Security2Handler;
} SECURITY2_INFO;
-UINT32 mCurrentAuthOperation = 0;
-UINT32 mNumberOfSecurityHandler = 0;
-UINT32 mMaxNumberOfSecurityHandler = 0;
-SECURITY_INFO *mSecurityTable = NULL;
+UINT32 mCurrentAuthOperation = 0;
+UINT32 mNumberOfSecurityHandler = 0;
+UINT32 mMaxNumberOfSecurityHandler = 0;
+SECURITY_INFO *mSecurityTable = NULL;
-UINT32 mCurrentAuthOperation2 = 0;
-UINT32 mNumberOfSecurity2Handler = 0;
-UINT32 mMaxNumberOfSecurity2Handler = 0;
-SECURITY2_INFO *mSecurity2Table = NULL;
+UINT32 mCurrentAuthOperation2 = 0;
+UINT32 mNumberOfSecurity2Handler = 0;
+UINT32 mMaxNumberOfSecurity2Handler = 0;
+SECURITY2_INFO *mSecurity2Table = NULL;
/**
Reallocates more global memory to store the registered Handler list.
@@ -93,8 +93,8 @@ ReallocateSecurityHandlerTable ( **/
BOOLEAN
CheckAuthenticationOperation (
- IN UINT32 CurrentAuthOperation,
- IN UINT32 CheckAuthOperation
+ IN UINT32 CurrentAuthOperation,
+ IN UINT32 CheckAuthOperation
)
{
//
@@ -108,7 +108,8 @@ CheckAuthenticationOperation ( //
if ((CurrentAuthOperation & EFI_AUTH_OPERATION_MEASURE_IMAGE) == EFI_AUTH_OPERATION_MEASURE_IMAGE) {
if (((CheckAuthOperation & EFI_AUTH_OPERATION_MEASURE_IMAGE) == EFI_AUTH_OPERATION_MEASURE_IMAGE) ||
- ((CheckAuthOperation & EFI_AUTH_IMAGE_OPERATION_MASK) == EFI_AUTH_OPERATION_NONE)) {
+ ((CheckAuthOperation & EFI_AUTH_IMAGE_OPERATION_MASK) == EFI_AUTH_OPERATION_NONE))
+ {
return TRUE;
} else {
return FALSE;
@@ -160,7 +161,7 @@ RegisterSecurityHandler ( //
// Allocate more resources for new handler.
//
- Status = ReallocateSecurityHandlerTable();
+ Status = ReallocateSecurityHandlerTable ();
ASSERT_EFI_ERROR (Status);
}
@@ -169,7 +170,7 @@ RegisterSecurityHandler ( //
mSecurityTable[mNumberOfSecurityHandler].SecurityOperation = AuthenticationOperation;
mSecurityTable[mNumberOfSecurityHandler].SecurityHandler = SecurityHandler;
- mNumberOfSecurityHandler ++;
+ mNumberOfSecurityHandler++;
return EFI_SUCCESS;
}
@@ -208,18 +209,18 @@ RegisterSecurityHandler ( EFI_STATUS
EFIAPI
ExecuteSecurityHandlers (
- IN UINT32 AuthenticationStatus,
- IN CONST EFI_DEVICE_PATH_PROTOCOL *FilePath
+ IN UINT32 AuthenticationStatus,
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *FilePath
)
{
- UINT32 Index;
- EFI_STATUS Status;
- UINT32 HandlerAuthenticationStatus;
- VOID *FileBuffer;
- UINTN FileSize;
- EFI_HANDLE Handle;
- EFI_DEVICE_PATH_PROTOCOL *Node;
- EFI_DEVICE_PATH_PROTOCOL *FilePathToVerfiy;
+ UINT32 Index;
+ EFI_STATUS Status;
+ UINT32 HandlerAuthenticationStatus;
+ VOID *FileBuffer;
+ UINTN FileSize;
+ EFI_HANDLE Handle;
+ EFI_DEVICE_PATH_PROTOCOL *Node;
+ EFI_DEVICE_PATH_PROTOCOL *FilePathToVerfiy;
if (FilePath == NULL) {
return EFI_INVALID_PARAMETER;
@@ -236,11 +237,11 @@ ExecuteSecurityHandlers ( FileBuffer = NULL;
FileSize = 0;
HandlerAuthenticationStatus = AuthenticationStatus;
- FilePathToVerfiy = (EFI_DEVICE_PATH_PROTOCOL *) FilePath;
+ FilePathToVerfiy = (EFI_DEVICE_PATH_PROTOCOL *)FilePath;
//
// Run security handler in same order to their registered list
//
- for (Index = 0; Index < mNumberOfSecurityHandler; Index ++) {
+ for (Index = 0; Index < mNumberOfSecurityHandler; Index++) {
if ((mSecurityTable[Index].SecurityOperation & EFI_AUTH_OPERATION_IMAGE_REQUIRED) == EFI_AUTH_OPERATION_IMAGE_REQUIRED) {
//
// Try get file buffer when the handler requires image buffer.
@@ -258,6 +259,7 @@ ExecuteSecurityHandlers ( //
FileBuffer = GetFileBufferByFilePath (TRUE, FilePath, &FileSize, &AuthenticationStatus);
}
+
if ((FileBuffer != NULL) && (!EFI_ERROR (Status))) {
//
// LoadFile () may cause the device path of the Handle be updated.
@@ -266,12 +268,13 @@ ExecuteSecurityHandlers ( }
}
}
+
Status = mSecurityTable[Index].SecurityHandler (
- HandlerAuthenticationStatus,
- FilePathToVerfiy,
- FileBuffer,
- FileSize
- );
+ HandlerAuthenticationStatus,
+ FilePathToVerfiy,
+ FileBuffer,
+ FileSize
+ );
if (EFI_ERROR (Status)) {
break;
}
@@ -280,6 +283,7 @@ ExecuteSecurityHandlers ( if (FileBuffer != NULL) {
FreePool (FileBuffer);
}
+
if (FilePathToVerfiy != FilePath) {
FreePool (FilePathToVerfiy);
}
@@ -303,10 +307,10 @@ ReallocateSecurity2HandlerTable ( // Reallocate memory for security info structure.
//
mSecurity2Table = ReallocatePool (
- mMaxNumberOfSecurity2Handler * sizeof (SECURITY2_INFO),
- (mMaxNumberOfSecurity2Handler + SECURITY_HANDLER_TABLE_SIZE) * sizeof (SECURITY2_INFO),
- mSecurity2Table
- );
+ mMaxNumberOfSecurity2Handler * sizeof (SECURITY2_INFO),
+ (mMaxNumberOfSecurity2Handler + SECURITY_HANDLER_TABLE_SIZE) * sizeof (SECURITY2_INFO),
+ mSecurity2Table
+ );
//
// No enough resource is allocated.
@@ -339,8 +343,8 @@ ReallocateSecurity2HandlerTable ( **/
BOOLEAN
CheckAuthentication2Operation (
- IN UINT32 CurrentAuthOperation,
- IN UINT32 CheckAuthOperation
+ IN UINT32 CurrentAuthOperation,
+ IN UINT32 CheckAuthOperation
)
{
//
@@ -349,9 +353,11 @@ CheckAuthentication2Operation ( if (CheckAuthOperation == EFI_AUTH_OPERATION_NONE) {
return FALSE;
}
+
if ((CheckAuthOperation & ~(EFI_AUTH_IMAGE_OPERATION_MASK |
EFI_AUTH_NONE_IMAGE_OPERATION_MASK |
- EFI_AUTH_OPERATION_IMAGE_REQUIRED)) != 0) {
+ EFI_AUTH_OPERATION_IMAGE_REQUIRED)) != 0)
+ {
return FALSE;
}
@@ -361,7 +367,8 @@ CheckAuthentication2Operation ( //
if ((CurrentAuthOperation & EFI_AUTH_OPERATION_MEASURE_IMAGE) == EFI_AUTH_OPERATION_MEASURE_IMAGE) {
if (((CheckAuthOperation & EFI_AUTH_OPERATION_MEASURE_IMAGE) == EFI_AUTH_OPERATION_MEASURE_IMAGE) ||
- ((CheckAuthOperation & EFI_AUTH_IMAGE_OPERATION_MASK) == 0)) {
+ ((CheckAuthOperation & EFI_AUTH_IMAGE_OPERATION_MASK) == 0))
+ {
return TRUE;
} else {
return FALSE;
@@ -392,8 +399,8 @@ CheckAuthentication2Operation ( EFI_STATUS
EFIAPI
RegisterSecurity2Handler (
- IN SECURITY2_FILE_AUTHENTICATION_HANDLER Security2Handler,
- IN UINT32 AuthenticationOperation
+ IN SECURITY2_FILE_AUTHENTICATION_HANDLER Security2Handler,
+ IN UINT32 AuthenticationOperation
)
{
EFI_STATUS Status;
@@ -413,7 +420,7 @@ RegisterSecurity2Handler ( //
// Allocate more resources for new handler.
//
- Status = ReallocateSecurity2HandlerTable();
+ Status = ReallocateSecurity2HandlerTable ();
ASSERT_EFI_ERROR (Status);
}
@@ -422,7 +429,7 @@ RegisterSecurity2Handler ( //
mSecurity2Table[mNumberOfSecurity2Handler].Security2Operation = AuthenticationOperation;
mSecurity2Table[mNumberOfSecurity2Handler].Security2Handler = Security2Handler;
- mNumberOfSecurity2Handler ++;
+ mNumberOfSecurity2Handler++;
return EFI_SUCCESS;
}
@@ -471,21 +478,21 @@ RegisterSecurity2Handler ( EFI_STATUS
EFIAPI
ExecuteSecurity2Handlers (
- IN UINT32 AuthenticationOperation,
- IN UINT32 AuthenticationStatus,
- IN CONST EFI_DEVICE_PATH_PROTOCOL *File OPTIONAL,
- IN VOID *FileBuffer,
- IN UINTN FileSize,
- IN BOOLEAN BootPolicy
+ IN UINT32 AuthenticationOperation,
+ IN UINT32 AuthenticationStatus,
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *File OPTIONAL,
+ IN VOID *FileBuffer,
+ IN UINTN FileSize,
+ IN BOOLEAN BootPolicy
)
{
- UINT32 Index;
- EFI_STATUS Status;
+ UINT32 Index;
+ EFI_STATUS Status;
//
// Invalid case if File and FileBuffer are both NULL.
//
- if (File == NULL && FileBuffer == NULL) {
+ if ((File == NULL) && (FileBuffer == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -499,25 +506,26 @@ ExecuteSecurity2Handlers ( //
// Run security handler in same order to their registered list
//
- for (Index = 0; Index < mNumberOfSecurity2Handler; Index ++) {
+ for (Index = 0; Index < mNumberOfSecurity2Handler; Index++) {
//
// If FileBuffer is not NULL, the input is Image, which will be handled by EFI_AUTH_IMAGE_OPERATION_MASK operation.
// If FileBuffer is NULL, the input is not Image, which will be handled by EFI_AUTH_NONE_IMAGE_OPERATION_MASK operation.
// Other cases are ignored.
//
- if ((FileBuffer != NULL && (mSecurity2Table[Index].Security2Operation & EFI_AUTH_IMAGE_OPERATION_MASK) != 0) ||
- (FileBuffer == NULL && (mSecurity2Table[Index].Security2Operation & EFI_AUTH_NONE_IMAGE_OPERATION_MASK) != 0)) {
+ if (((FileBuffer != NULL) && ((mSecurity2Table[Index].Security2Operation & EFI_AUTH_IMAGE_OPERATION_MASK) != 0)) ||
+ ((FileBuffer == NULL) && ((mSecurity2Table[Index].Security2Operation & EFI_AUTH_NONE_IMAGE_OPERATION_MASK) != 0)))
+ {
//
// Execute registered handlers based on input AuthenticationOperation
//
if ((mSecurity2Table[Index].Security2Operation & AuthenticationOperation) != 0) {
Status = mSecurity2Table[Index].Security2Handler (
- AuthenticationStatus,
- File,
- FileBuffer,
- FileSize,
- BootPolicy
- );
+ AuthenticationStatus,
+ File,
+ FileBuffer,
+ FileSize,
+ BootPolicy
+ );
if (EFI_ERROR (Status)) {
return Status;
}
diff --git a/MdeModulePkg/Library/FileExplorerLib/FileExplorer.c b/MdeModulePkg/Library/FileExplorerLib/FileExplorer.c index b262cf714f..ef949267fc 100644 --- a/MdeModulePkg/Library/FileExplorerLib/FileExplorer.c +++ b/MdeModulePkg/Library/FileExplorerLib/FileExplorer.c @@ -6,17 +6,16 @@ SPDX-License-Identifier: BSD-2-Clause-Patent **/
-
#include "FileExplorer.h"
-EFI_GUID FileExplorerGuid = EFI_FILE_EXPLORE_FORMSET_GUID;
+EFI_GUID FileExplorerGuid = EFI_FILE_EXPLORE_FORMSET_GUID;
///
/// File system selection menu
///
-MENU_OPTION mFsOptionMenu = {
+MENU_OPTION mFsOptionMenu = {
MENU_OPTION_SIGNATURE,
- {NULL},
+ { NULL },
0,
FALSE
};
@@ -43,34 +42,35 @@ HII_VENDOR_DEVICE_PATH FeHiiVendorDevicePath = { HARDWARE_DEVICE_PATH,
HW_VENDOR_DP,
{
- (UINT8) (sizeof (VENDOR_DEVICE_PATH)),
- (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)
+ (UINT8)(sizeof (VENDOR_DEVICE_PATH)),
+ (UINT8)((sizeof (VENDOR_DEVICE_PATH)) >> 8)
}
},
//
// Will be replace with gEfiCallerIdGuid in code.
//
- { 0x0, 0x0, 0x0, { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } }
+ { 0x0, 0x0, 0x0, { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }
+ }
},
{
END_DEVICE_PATH_TYPE,
END_ENTIRE_DEVICE_PATH_SUBTYPE,
{
- (UINT8) (END_DEVICE_PATH_LENGTH),
- (UINT8) ((END_DEVICE_PATH_LENGTH) >> 8)
+ (UINT8)(END_DEVICE_PATH_LENGTH),
+ (UINT8)((END_DEVICE_PATH_LENGTH) >> 8)
}
}
};
VOID *mLibStartOpCodeHandle = NULL;
-VOID *mLibEndOpCodeHandle = NULL;
-EFI_IFR_GUID_LABEL *mLibStartLabel = NULL;
-EFI_IFR_GUID_LABEL *mLibEndLabel = NULL;
+VOID *mLibEndOpCodeHandle = NULL;
+EFI_IFR_GUID_LABEL *mLibStartLabel = NULL;
+EFI_IFR_GUID_LABEL *mLibEndLabel = NULL;
UINT16 mQuestionIdUpdate;
-CHAR16 mNewFileName[MAX_FILE_NAME_LEN];
-CHAR16 mNewFolderName[MAX_FOLDER_NAME_LEN];
-UINTN mNewFileQuestionId = NEW_FILE_QUESTION_ID_BASE;
-UINTN mNewFolderQuestionId = NEW_FOLDER_QUESTION_ID_BASE;
+CHAR16 mNewFileName[MAX_FILE_NAME_LEN];
+CHAR16 mNewFolderName[MAX_FOLDER_NAME_LEN];
+UINTN mNewFileQuestionId = NEW_FILE_QUESTION_ID_BASE;
+UINTN mNewFolderQuestionId = NEW_FOLDER_QUESTION_ID_BASE;
/**
Create a new file or folder in current directory.
@@ -82,8 +82,8 @@ UINTN mNewFolderQuestionId = NEW_FOLDER_QUESTION_ID_BASE; **/
EFI_STATUS
LibCreateNewFile (
- IN CHAR16 *FileName,
- IN BOOLEAN CreateFile
+ IN CHAR16 *FileName,
+ IN BOOLEAN CreateFile
);
/**
@@ -109,13 +109,13 @@ LibCreateNewFile ( EFI_STATUS
EFIAPI
LibExtractConfig (
- IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
- IN CONST EFI_STRING Request,
- OUT EFI_STRING *Progress,
- OUT EFI_STRING *Results
+ IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
+ IN CONST EFI_STRING Request,
+ OUT EFI_STRING *Progress,
+ OUT EFI_STRING *Results
)
{
- if (Progress == NULL || Results == NULL) {
+ if ((Progress == NULL) || (Results == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -141,12 +141,12 @@ LibExtractConfig ( EFI_STATUS
EFIAPI
LibRouteConfig (
- IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
- IN CONST EFI_STRING Configuration,
- OUT EFI_STRING *Progress
+ IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
+ IN CONST EFI_STRING Configuration,
+ OUT EFI_STRING *Progress
)
{
- if (Configuration == NULL || Progress == NULL) {
+ if ((Configuration == NULL) || (Progress == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -177,24 +177,24 @@ LibRouteConfig ( EFI_STATUS
EFIAPI
LibCallback (
- IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
- IN EFI_BROWSER_ACTION Action,
- IN EFI_QUESTION_ID QuestionId,
- IN UINT8 Type,
- IN EFI_IFR_TYPE_VALUE *Value,
- OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
+ IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
+ IN EFI_BROWSER_ACTION Action,
+ IN EFI_QUESTION_ID QuestionId,
+ IN UINT8 Type,
+ IN EFI_IFR_TYPE_VALUE *Value,
+ OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
)
{
- EFI_STATUS Status;
- BOOLEAN NeedExit;
- CHAR16 *NewFileName;
- CHAR16 *NewFolderName;
+ EFI_STATUS Status;
+ BOOLEAN NeedExit;
+ CHAR16 *NewFileName;
+ CHAR16 *NewFolderName;
- NeedExit = TRUE;
+ NeedExit = TRUE;
NewFileName = NULL;
NewFolderName = NULL;
- if (Action != EFI_BROWSER_ACTION_CHANGING && Action != EFI_BROWSER_ACTION_CHANGED) {
+ if ((Action != EFI_BROWSER_ACTION_CHANGING) && (Action != EFI_BROWSER_ACTION_CHANGED)) {
//
// Do nothing for other UEFI Action. Only do call back when data is changed.
//
@@ -209,13 +209,13 @@ LibCallback ( if (QuestionId == KEY_VALUE_CREATE_FILE_AND_EXIT) {
*ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT;
if (!IsZeroBuffer (mNewFileName, sizeof (mNewFileName))) {
- Status = LibCreateNewFile (mNewFileName,TRUE);
- ZeroMem (mNewFileName,sizeof (mNewFileName));
+ Status = LibCreateNewFile (mNewFileName, TRUE);
+ ZeroMem (mNewFileName, sizeof (mNewFileName));
}
}
if (QuestionId == KEY_VALUE_NO_CREATE_FILE_AND_EXIT) {
- ZeroMem (mNewFileName,sizeof (mNewFileName));
+ ZeroMem (mNewFileName, sizeof (mNewFileName));
*ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT;
}
@@ -223,12 +223,12 @@ LibCallback ( *ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT;
if (!IsZeroBuffer (mNewFolderName, sizeof (mNewFolderName))) {
Status = LibCreateNewFile (mNewFolderName, FALSE);
- ZeroMem (mNewFolderName,sizeof (mNewFolderName));
+ ZeroMem (mNewFolderName, sizeof (mNewFolderName));
}
}
if (QuestionId == KEY_VALUE_NO_CREATE_FOLDER_AND_EXIT) {
- ZeroMem (mNewFolderName,sizeof (mNewFolderName));
+ ZeroMem (mNewFolderName, sizeof (mNewFolderName));
*ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT;
}
@@ -255,7 +255,7 @@ LibCallback ( }
if (QuestionId >= FILE_OPTION_OFFSET) {
- LibGetDevicePath(QuestionId);
+ LibGetDevicePath (QuestionId);
//
// Process the extra action.
@@ -272,8 +272,9 @@ LibCallback ( if (Value == NULL) {
return EFI_INVALID_PARAMETER;
}
+
if (QuestionId >= FILE_OPTION_OFFSET) {
- LibGetDevicePath(QuestionId);
+ LibGetDevicePath (QuestionId);
Status = LibUpdateFileExplorer (QuestionId);
if (EFI_ERROR (Status)) {
return Status;
@@ -296,7 +297,7 @@ LibCreateMenuEntry ( VOID
)
{
- MENU_ENTRY *MenuEntry;
+ MENU_ENTRY *MenuEntry;
//
// Create new menu entry
@@ -312,11 +313,10 @@ LibCreateMenuEntry ( return NULL;
}
- MenuEntry->Signature = MENU_ENTRY_SIGNATURE;
+ MenuEntry->Signature = MENU_ENTRY_SIGNATURE;
return MenuEntry;
}
-
/**
Get the Menu Entry from the list in Menu Entry List.
@@ -331,13 +331,13 @@ LibCreateMenuEntry ( **/
MENU_ENTRY *
LibGetMenuEntry (
- MENU_OPTION *MenuOption,
- UINTN MenuNumber
+ MENU_OPTION *MenuOption,
+ UINTN MenuNumber
)
{
- MENU_ENTRY *NewMenuEntry;
- UINTN Index;
- LIST_ENTRY *List;
+ MENU_ENTRY *NewMenuEntry;
+ UINTN Index;
+ LIST_ENTRY *List;
ASSERT (MenuNumber < MenuOption->MenuNumber);
@@ -359,12 +359,12 @@ LibGetMenuEntry ( **/
VOID
LibDestroyMenuEntry (
- MENU_ENTRY *MenuEntry
+ MENU_ENTRY *MenuEntry
)
{
- FILE_CONTEXT *FileContext;
+ FILE_CONTEXT *FileContext;
- FileContext = (FILE_CONTEXT *) MenuEntry->VariableContext;
+ FileContext = (FILE_CONTEXT *)MenuEntry->VariableContext;
if (!FileContext->IsRoot) {
if (FileContext->DevicePath != NULL) {
@@ -385,6 +385,7 @@ LibDestroyMenuEntry ( if (MenuEntry->DisplayString != NULL) {
FreePool (MenuEntry->DisplayString);
}
+
if (MenuEntry->HelpString != NULL) {
FreePool (MenuEntry->HelpString);
}
@@ -392,7 +393,6 @@ LibDestroyMenuEntry ( FreePool (MenuEntry);
}
-
/**
Free resources allocated in Allocate Rountine.
@@ -400,10 +400,11 @@ LibDestroyMenuEntry ( **/
VOID
LibFreeMenu (
- MENU_OPTION *FreeMenu
+ MENU_OPTION *FreeMenu
)
{
- MENU_ENTRY *MenuEntry;
+ MENU_ENTRY *MenuEntry;
+
while (!IsListEmpty (&FreeMenu->Head)) {
MenuEntry = CR (
FreeMenu->Head.ForwardLink,
@@ -414,6 +415,7 @@ LibFreeMenu ( RemoveEntryList (&MenuEntry->Link);
LibDestroyMenuEntry (MenuEntry);
}
+
FreeMenu->MenuNumber = 0;
}
@@ -428,12 +430,12 @@ LibFreeMenu ( **/
EFI_FILE_HANDLE
LibOpenRoot (
- IN EFI_HANDLE DeviceHandle
+ IN EFI_HANDLE DeviceHandle
)
{
- EFI_STATUS Status;
- EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *Volume;
- EFI_FILE_HANDLE File;
+ EFI_STATUS Status;
+ EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *Volume;
+ EFI_FILE_HANDLE File;
File = NULL;
@@ -443,7 +445,7 @@ LibOpenRoot ( Status = gBS->HandleProtocol (
DeviceHandle,
&gEfiSimpleFileSystemProtocolGuid,
- (VOID *) &Volume
+ (VOID *)&Volume
);
//
@@ -451,10 +453,11 @@ LibOpenRoot ( //
if (!EFI_ERROR (Status)) {
Status = Volume->OpenVolume (
- Volume,
- &File
- );
+ Volume,
+ &File
+ );
}
+
//
// Done
//
@@ -471,12 +474,12 @@ LibOpenRoot ( **/
CHAR16 *
LibDevicePathToStr (
- IN EFI_DEVICE_PATH_PROTOCOL *DevPath
+ IN EFI_DEVICE_PATH_PROTOCOL *DevPath
)
{
- EFI_STATUS Status;
- CHAR16 *ToText;
- EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *DevPathToText;
+ EFI_STATUS Status;
+ CHAR16 *ToText;
+ EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *DevPathToText;
if (DevPath == NULL) {
return NULL;
@@ -485,7 +488,7 @@ LibDevicePathToStr ( Status = gBS->LocateProtocol (
&gEfiDevicePathToTextProtocolGuid,
NULL,
- (VOID **) &DevPathToText
+ (VOID **)&DevPathToText
);
ASSERT_EFI_ERROR (Status);
ToText = DevPathToText->ConvertDevicePathToText (
@@ -509,14 +512,14 @@ LibDevicePathToStr ( **/
CHAR16 *
LibStrDuplicate (
- IN CHAR16 *Src
+ IN CHAR16 *Src
)
{
CHAR16 *Dest;
UINTN Size;
- Size = StrSize (Src);
- Dest = AllocateZeroPool (Size);
+ Size = StrSize (Src);
+ Dest = AllocateZeroPool (Size);
ASSERT (Dest != NULL);
if (Dest != NULL) {
CopyMem (Dest, Src, Size);
@@ -538,16 +541,16 @@ LibStrDuplicate ( **/
VOID *
LibFileInfo (
- IN EFI_FILE_HANDLE FHand,
- IN EFI_GUID *InfoType
+ IN EFI_FILE_HANDLE FHand,
+ IN EFI_GUID *InfoType
)
{
- EFI_STATUS Status;
- EFI_FILE_INFO *Buffer;
- UINTN BufferSize;
+ EFI_STATUS Status;
+ EFI_FILE_INFO *Buffer;
+ UINTN BufferSize;
- Buffer = NULL;
- BufferSize = 0;
+ Buffer = NULL;
+ BufferSize = 0;
Status = FHand->GetInfo (
FHand,
@@ -580,12 +583,12 @@ LibFileInfo ( @retval the file type string.
**/
-CHAR16*
+CHAR16 *
LibGetTypeFromName (
- IN CHAR16 *FileName
+ IN CHAR16 *FileName
)
{
- UINTN Index;
+ UINTN Index;
Index = StrLen (FileName) - 1;
while ((FileName[Index] != L'.') && (Index != 0)) {
@@ -607,11 +610,11 @@ LibToLowerString ( IN CHAR16 *String
)
{
- CHAR16 *TmpStr;
+ CHAR16 *TmpStr;
for (TmpStr = String; *TmpStr != L'\0'; TmpStr++) {
- if (*TmpStr >= L'A' && *TmpStr <= L'Z') {
- *TmpStr = (CHAR16) (*TmpStr - L'A' + L'a');
+ if ((*TmpStr >= L'A') && (*TmpStr <= L'Z')) {
+ *TmpStr = (CHAR16)(*TmpStr - L'A' + L'a');
}
}
}
@@ -632,9 +635,9 @@ LibIsSupportedFileType ( IN UINT16 *FileName
)
{
- CHAR16 *InputFileType;
- CHAR16 *TmpStr;
- BOOLEAN IsSupported;
+ CHAR16 *InputFileType;
+ CHAR16 *TmpStr;
+ BOOLEAN IsSupported;
if (gFileExplorerPrivate.FileType == NULL) {
return TRUE;
@@ -649,8 +652,8 @@ LibIsSupportedFileType ( }
TmpStr = AllocateCopyPool (StrSize (InputFileType), InputFileType);
- ASSERT(TmpStr != NULL);
- LibToLowerString(TmpStr);
+ ASSERT (TmpStr != NULL);
+ LibToLowerString (TmpStr);
IsSupported = (StrStr (gFileExplorerPrivate.FileType, TmpStr) == NULL ? FALSE : TRUE);
@@ -689,12 +692,12 @@ LibAppendFileName ( //
// Check overflow
//
- if (((MAX_UINTN - Size1) < Size2) || ((MAX_UINTN - Size1 - Size2) < sizeof(CHAR16))) {
+ if (((MAX_UINTN - Size1) < Size2) || ((MAX_UINTN - Size1 - Size2) < sizeof (CHAR16))) {
return NULL;
}
MaxLen = (Size1 + Size2 + sizeof (CHAR16))/ sizeof (CHAR16);
- Str = AllocateZeroPool (Size1 + Size2 + sizeof (CHAR16));
+ Str = AllocateZeroPool (Size1 + Size2 + sizeof (CHAR16));
ASSERT (Str != NULL);
TmpStr = AllocateZeroPool (Size1 + Size2 + sizeof (CHAR16));
@@ -710,7 +713,7 @@ LibAppendFileName ( Ptr = Str;
LastSlash = Str;
while (*Ptr != 0) {
- if (*Ptr == '\\' && *(Ptr + 1) == '.' && *(Ptr + 2) == '.' && *(Ptr + 3) == L'\\') {
+ if ((*Ptr == '\\') && (*(Ptr + 1) == '.') && (*(Ptr + 2) == '.') && (*(Ptr + 3) == L'\\')) {
//
// Convert "\Name\..\" to "\"
// DO NOT convert the .. if it is at the end of the string. This will
@@ -722,9 +725,9 @@ LibAppendFileName ( // that overlap.
//
StrCpyS (TmpStr, MaxLen, Ptr + 3);
- StrCpyS (LastSlash, MaxLen - ((UINTN) LastSlash - (UINTN) Str) / sizeof (CHAR16), TmpStr);
+ StrCpyS (LastSlash, MaxLen - ((UINTN)LastSlash - (UINTN)Str) / sizeof (CHAR16), TmpStr);
Ptr = LastSlash;
- } else if (*Ptr == '\\' && *(Ptr + 1) == '.' && *(Ptr + 2) == '\\') {
+ } else if ((*Ptr == '\\') && (*(Ptr + 1) == '.') && (*(Ptr + 2) == '\\')) {
//
// Convert a "\.\" to a "\"
//
@@ -734,7 +737,7 @@ LibAppendFileName ( // that overlap.
//
StrCpyS (TmpStr, MaxLen, Ptr + 2);
- StrCpyS (Ptr, MaxLen - ((UINTN) Ptr - (UINTN) Str) / sizeof (CHAR16), TmpStr);
+ StrCpyS (Ptr, MaxLen - ((UINTN)Ptr - (UINTN)Str) / sizeof (CHAR16), TmpStr);
Ptr = LastSlash;
} else if (*Ptr == '\\') {
LastSlash = Ptr;
@@ -763,15 +766,15 @@ LibFindFileSystem ( VOID
)
{
- UINTN NoSimpleFsHandles;
- EFI_HANDLE *SimpleFsHandle;
- UINT16 *VolumeLabel;
- UINTN Index;
- EFI_STATUS Status;
- MENU_ENTRY *MenuEntry;
- FILE_CONTEXT *FileContext;
- UINTN OptionNumber;
- EFI_FILE_SYSTEM_VOLUME_LABEL *Info;
+ UINTN NoSimpleFsHandles;
+ EFI_HANDLE *SimpleFsHandle;
+ UINT16 *VolumeLabel;
+ UINTN Index;
+ EFI_STATUS Status;
+ MENU_ENTRY *MenuEntry;
+ FILE_CONTEXT *FileContext;
+ UINTN OptionNumber;
+ EFI_FILE_SYSTEM_VOLUME_LABEL *Info;
NoSimpleFsHandles = 0;
OptionNumber = 0;
@@ -800,24 +803,24 @@ LibFindFileSystem ( return EFI_OUT_OF_RESOURCES;
}
- FileContext = (FILE_CONTEXT *) MenuEntry->VariableContext;
+ FileContext = (FILE_CONTEXT *)MenuEntry->VariableContext;
FileContext->DeviceHandle = SimpleFsHandle[Index];
- FileContext->FileHandle = LibOpenRoot (FileContext->DeviceHandle);
+ FileContext->FileHandle = LibOpenRoot (FileContext->DeviceHandle);
if (FileContext->FileHandle == NULL) {
LibDestroyMenuEntry (MenuEntry);
continue;
}
- MenuEntry->HelpString = LibDevicePathToStr (DevicePathFromHandle (FileContext->DeviceHandle));
- FileContext->FileName = LibStrDuplicate (L"\\");
+ MenuEntry->HelpString = LibDevicePathToStr (DevicePathFromHandle (FileContext->DeviceHandle));
+ FileContext->FileName = LibStrDuplicate (L"\\");
FileContext->DevicePath = FileDevicePath (FileContext->DeviceHandle, FileContext->FileName);
- FileContext->IsDir = TRUE;
- FileContext->IsRoot = TRUE;
+ FileContext->IsDir = TRUE;
+ FileContext->IsRoot = TRUE;
//
// Get current file system's Volume Label
//
- Info = (EFI_FILE_SYSTEM_VOLUME_LABEL *) LibFileInfo (FileContext->FileHandle, &gEfiFileSystemVolumeLabelInfoIdGuid);
+ Info = (EFI_FILE_SYSTEM_VOLUME_LABEL *)LibFileInfo (FileContext->FileHandle, &gEfiFileSystemVolumeLabelInfoIdGuid);
if (Info == NULL) {
VolumeLabel = L"NO FILE SYSTEM INFO";
} else {
@@ -826,7 +829,8 @@ LibFindFileSystem ( VolumeLabel = L"NO VOLUME LABEL";
}
}
- MenuEntry->DisplayString = AllocateZeroPool (MAX_CHAR);
+
+ MenuEntry->DisplayString = AllocateZeroPool (MAX_CHAR);
ASSERT (MenuEntry->DisplayString != NULL);
UnicodeSPrint (
MenuEntry->DisplayString,
@@ -836,14 +840,15 @@ LibFindFileSystem ( MenuEntry->HelpString
);
MenuEntry->DisplayStringToken = HiiSetString (
- gFileExplorerPrivate.FeHiiHandle,
- 0,
- MenuEntry->DisplayString,
- NULL
- );
+ gFileExplorerPrivate.FeHiiHandle,
+ 0,
+ MenuEntry->DisplayString,
+ NULL
+ );
- if (Info != NULL)
+ if (Info != NULL) {
FreePool (Info);
+ }
OptionNumber++;
InsertTailList (&gFileExplorerPrivate.FsOptionMenu->Head, &MenuEntry->Link);
@@ -870,17 +875,17 @@ LibFindFileSystem ( **/
EFI_STATUS
LibGetFileHandleFromMenu (
- IN MENU_ENTRY *MenuEntry,
- OUT EFI_FILE_HANDLE *RetFileHandle
+ IN MENU_ENTRY *MenuEntry,
+ OUT EFI_FILE_HANDLE *RetFileHandle
)
{
- EFI_FILE_HANDLE Dir;
- EFI_FILE_HANDLE NewDir;
- FILE_CONTEXT *FileContext;
- EFI_STATUS Status;
+ EFI_FILE_HANDLE Dir;
+ EFI_FILE_HANDLE NewDir;
+ FILE_CONTEXT *FileContext;
+ EFI_STATUS Status;
- FileContext = (FILE_CONTEXT *) MenuEntry->VariableContext;
- Dir = FileContext->FileHandle;
+ FileContext = (FILE_CONTEXT *)MenuEntry->VariableContext;
+ Dir = FileContext->FileHandle;
//
// Open current directory to get files from it
@@ -924,14 +929,14 @@ LibGetFileHandleFromDevicePath ( OUT EFI_HANDLE *DeviceHandle
)
{
- EFI_DEVICE_PATH_PROTOCOL *DevicePathNode;
- EFI_DEVICE_PATH_PROTOCOL *TempDevicePathNode;
- EFI_STATUS Status;
- EFI_HANDLE Handle;
- EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *Volume;
- EFI_FILE_HANDLE FileHandle;
- EFI_FILE_HANDLE LastHandle;
- CHAR16 *TempPath;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePathNode;
+ EFI_DEVICE_PATH_PROTOCOL *TempDevicePathNode;
+ EFI_STATUS Status;
+ EFI_HANDLE Handle;
+ EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *Volume;
+ EFI_FILE_HANDLE FileHandle;
+ EFI_FILE_HANDLE LastHandle;
+ CHAR16 *TempPath;
*ParentFileName = NULL;
@@ -939,12 +944,12 @@ LibGetFileHandleFromDevicePath ( // Attempt to access the file via a file system interface
//
DevicePathNode = RootDirectory;
- Status = gBS->LocateDevicePath (&gEfiSimpleFileSystemProtocolGuid, &DevicePathNode, &Handle);
+ Status = gBS->LocateDevicePath (&gEfiSimpleFileSystemProtocolGuid, &DevicePathNode, &Handle);
if (EFI_ERROR (Status)) {
return Status;
}
- Status = gBS->HandleProtocol (Handle, &gEfiSimpleFileSystemProtocolGuid, (VOID**)&Volume);
+ Status = gBS->HandleProtocol (Handle, &gEfiSimpleFileSystemProtocolGuid, (VOID **)&Volume);
if (EFI_ERROR (Status)) {
return Status;
}
@@ -959,9 +964,9 @@ LibGetFileHandleFromDevicePath ( *DeviceHandle = Handle;
- if (IsDevicePathEnd(DevicePathNode)) {
+ if (IsDevicePathEnd (DevicePathNode)) {
*ParentFileName = AllocateCopyPool (StrSize (L"\\"), L"\\");
- *RetFileHandle = FileHandle;
+ *RetFileHandle = FileHandle;
return EFI_SUCCESS;
}
@@ -972,7 +977,6 @@ LibGetFileHandleFromDevicePath ( //
TempDevicePathNode = DuplicateDevicePath (DevicePathNode);
if (TempDevicePathNode == NULL) {
-
//
// Setting Status to an EFI_ERROR value will cause the rest of
// the file system support below to be skipped.
@@ -988,8 +992,9 @@ LibGetFileHandleFromDevicePath ( //
DevicePathNode = TempDevicePathNode;
while (!EFI_ERROR (Status) && !IsDevicePathEnd (DevicePathNode)) {
- if (DevicePathType (DevicePathNode) != MEDIA_DEVICE_PATH ||
- DevicePathSubType (DevicePathNode) != MEDIA_FILEPATH_DP) {
+ if ((DevicePathType (DevicePathNode) != MEDIA_DEVICE_PATH) ||
+ (DevicePathSubType (DevicePathNode) != MEDIA_FILEPATH_DP))
+ {
Status = EFI_UNSUPPORTED;
goto Done;
}
@@ -998,21 +1003,22 @@ LibGetFileHandleFromDevicePath ( FileHandle = NULL;
Status = LastHandle->Open (
- LastHandle,
- &FileHandle,
- ((FILEPATH_DEVICE_PATH *) DevicePathNode)->PathName,
- EFI_FILE_MODE_READ,
- 0
- );
+ LastHandle,
+ &FileHandle,
+ ((FILEPATH_DEVICE_PATH *)DevicePathNode)->PathName,
+ EFI_FILE_MODE_READ,
+ 0
+ );
if (*ParentFileName == NULL) {
- *ParentFileName = AllocateCopyPool (StrSize (((FILEPATH_DEVICE_PATH *) DevicePathNode)->PathName), ((FILEPATH_DEVICE_PATH *) DevicePathNode)->PathName);
+ *ParentFileName = AllocateCopyPool (StrSize (((FILEPATH_DEVICE_PATH *)DevicePathNode)->PathName), ((FILEPATH_DEVICE_PATH *)DevicePathNode)->PathName);
} else {
- TempPath = LibAppendFileName (*ParentFileName, ((FILEPATH_DEVICE_PATH *) DevicePathNode)->PathName);
+ TempPath = LibAppendFileName (*ParentFileName, ((FILEPATH_DEVICE_PATH *)DevicePathNode)->PathName);
if (TempPath == NULL) {
LastHandle->Close (LastHandle);
Status = EFI_OUT_OF_RESOURCES;
goto Done;
}
+
FreePool (*ParentFileName);
*ParentFileName = TempPath;
}
@@ -1055,45 +1061,46 @@ Done: **/
EFI_STATUS
LibCreateNewFile (
- IN CHAR16 *FileName,
- IN BOOLEAN CreateFile
+ IN CHAR16 *FileName,
+ IN BOOLEAN CreateFile
)
{
- EFI_FILE_HANDLE FileHandle;
- EFI_FILE_HANDLE NewHandle;
- EFI_HANDLE DeviceHandle;
- EFI_STATUS Status;
- CHAR16 *ParentName;
- CHAR16 *FullFileName;
-
- NewHandle = NULL;
+ EFI_FILE_HANDLE FileHandle;
+ EFI_FILE_HANDLE NewHandle;
+ EFI_HANDLE DeviceHandle;
+ EFI_STATUS Status;
+ CHAR16 *ParentName;
+ CHAR16 *FullFileName;
+
+ NewHandle = NULL;
FullFileName = NULL;
- LibGetFileHandleFromDevicePath(gFileExplorerPrivate.RetDevicePath, &FileHandle, &ParentName, &DeviceHandle);
+ LibGetFileHandleFromDevicePath (gFileExplorerPrivate.RetDevicePath, &FileHandle, &ParentName, &DeviceHandle);
FullFileName = LibAppendFileName (ParentName, FileName);
if (FullFileName == NULL) {
return EFI_OUT_OF_RESOURCES;
}
+
if (CreateFile) {
- Status = FileHandle->Open(
- FileHandle,
- &NewHandle,
- FullFileName,
- EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE| EFI_FILE_MODE_CREATE,
- 0
- );
+ Status = FileHandle->Open (
+ FileHandle,
+ &NewHandle,
+ FullFileName,
+ EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE| EFI_FILE_MODE_CREATE,
+ 0
+ );
if (EFI_ERROR (Status)) {
FileHandle->Close (FileHandle);
return Status;
}
} else {
- Status = FileHandle->Open(
- FileHandle,
- &NewHandle,
- FullFileName,
- EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE| EFI_FILE_MODE_CREATE,
- EFI_FILE_DIRECTORY
- );
+ Status = FileHandle->Open (
+ FileHandle,
+ &NewHandle,
+ FullFileName,
+ EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE| EFI_FILE_MODE_CREATE,
+ EFI_FILE_DIRECTORY
+ );
if (EFI_ERROR (Status)) {
FileHandle->Close (FileHandle);
return Status;
@@ -1108,7 +1115,6 @@ LibCreateNewFile ( gFileExplorerPrivate.RetDevicePath = FileDevicePath (DeviceHandle, FullFileName);
return EFI_SUCCESS;
-
}
/**
@@ -1127,19 +1133,19 @@ LibCreateNewFile ( **/
EFI_STATUS
LibFindFiles (
- IN EFI_FILE_HANDLE FileHandle,
- IN UINT16 *FileName,
- IN EFI_HANDLE DeviceHandle
+ IN EFI_FILE_HANDLE FileHandle,
+ IN UINT16 *FileName,
+ IN EFI_HANDLE DeviceHandle
)
{
- EFI_FILE_INFO *DirInfo;
- UINTN BufferSize;
- UINTN DirBufferSize;
- MENU_ENTRY *NewMenuEntry;
- FILE_CONTEXT *NewFileContext;
- UINTN Pass;
- EFI_STATUS Status;
- UINTN OptionNumber;
+ EFI_FILE_INFO *DirInfo;
+ UINTN BufferSize;
+ UINTN DirBufferSize;
+ MENU_ENTRY *NewMenuEntry;
+ FILE_CONTEXT *NewFileContext;
+ UINTN Pass;
+ EFI_STATUS Status;
+ UINTN OptionNumber;
OptionNumber = 0;
@@ -1157,17 +1163,18 @@ LibFindFiles ( Status = EFI_SUCCESS;
for (Pass = 1; Pass <= 2; Pass++) {
FileHandle->SetPosition (FileHandle, 0);
- for (;;) {
- BufferSize = DirBufferSize;
- Status = FileHandle->Read (FileHandle, &BufferSize, DirInfo);
- if (EFI_ERROR (Status) || BufferSize == 0) {
+ for ( ; ;) {
+ BufferSize = DirBufferSize;
+ Status = FileHandle->Read (FileHandle, &BufferSize, DirInfo);
+ if (EFI_ERROR (Status) || (BufferSize == 0)) {
Status = EFI_SUCCESS;
break;
}
- if (((DirInfo->Attribute & EFI_FILE_DIRECTORY) != 0 && Pass == 2) ||
- ((DirInfo->Attribute & EFI_FILE_DIRECTORY) == 0 && Pass == 1)
- ) {
+ if ((((DirInfo->Attribute & EFI_FILE_DIRECTORY) != 0) && (Pass == 2)) ||
+ (((DirInfo->Attribute & EFI_FILE_DIRECTORY) == 0) && (Pass == 1))
+ )
+ {
//
// Pass 1 is for Directories
// Pass 2 is for file names
@@ -1175,7 +1182,7 @@ LibFindFiles ( continue;
}
- if (!((DirInfo->Attribute & EFI_FILE_DIRECTORY) != 0 || LibIsSupportedFileType (DirInfo->FileName))) {
+ if (!(((DirInfo->Attribute & EFI_FILE_DIRECTORY) != 0) || LibIsSupportedFileType (DirInfo->FileName))) {
//
// Slip file unless it is a directory entry or a .EFI file
//
@@ -1188,21 +1195,22 @@ LibFindFiles ( goto Done;
}
- NewFileContext = (FILE_CONTEXT *) NewMenuEntry->VariableContext;
+ NewFileContext = (FILE_CONTEXT *)NewMenuEntry->VariableContext;
NewFileContext->DeviceHandle = DeviceHandle;
- NewFileContext->FileName = LibAppendFileName (FileName, DirInfo->FileName);
- if (NewFileContext->FileName == NULL) {
+ NewFileContext->FileName = LibAppendFileName (FileName, DirInfo->FileName);
+ if (NewFileContext->FileName == NULL) {
LibDestroyMenuEntry (NewMenuEntry);
Status = EFI_OUT_OF_RESOURCES;
goto Done;
}
+
NewFileContext->FileHandle = FileHandle;
NewFileContext->DevicePath = FileDevicePath (NewFileContext->DeviceHandle, NewFileContext->FileName);
- NewMenuEntry->HelpString = NULL;
- NewFileContext->IsDir = (BOOLEAN) ((DirInfo->Attribute & EFI_FILE_DIRECTORY) == EFI_FILE_DIRECTORY);
+ NewMenuEntry->HelpString = NULL;
+ NewFileContext->IsDir = (BOOLEAN)((DirInfo->Attribute & EFI_FILE_DIRECTORY) == EFI_FILE_DIRECTORY);
if (NewFileContext->IsDir) {
- BufferSize = StrLen (DirInfo->FileName) * 2 + 6;
+ BufferSize = StrLen (DirInfo->FileName) * 2 + 6;
NewMenuEntry->DisplayString = AllocateZeroPool (BufferSize);
UnicodeSPrint (
NewMenuEntry->DisplayString,
@@ -1221,7 +1229,7 @@ LibFindFiles ( NULL
);
- NewFileContext->IsRoot = FALSE;
+ NewFileContext->IsRoot = FALSE;
OptionNumber++;
InsertTailList (&gFileExplorerPrivate.FsOptionMenu->Head, &NewMenuEntry->Link);
@@ -1252,6 +1260,7 @@ LibRefreshUpdateData ( if (mLibStartOpCodeHandle != NULL) {
HiiFreeOpCodeHandle (mLibStartOpCodeHandle);
}
+
if (mLibEndOpCodeHandle != NULL) {
HiiFreeOpCodeHandle (mLibEndOpCodeHandle);
}
@@ -1260,17 +1269,17 @@ LibRefreshUpdateData ( // Create new OpCode Handle
//
mLibStartOpCodeHandle = HiiAllocateOpCodeHandle ();
- mLibEndOpCodeHandle = HiiAllocateOpCodeHandle ();
+ mLibEndOpCodeHandle = HiiAllocateOpCodeHandle ();
//
// Create Hii Extend Label OpCode as the start opcode
//
- mLibStartLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (
- mLibStartOpCodeHandle,
- &gEfiIfrTianoGuid,
- NULL,
- sizeof (EFI_IFR_GUID_LABEL)
- );
+ mLibStartLabel = (EFI_IFR_GUID_LABEL *)HiiCreateGuidOpCode (
+ mLibStartOpCodeHandle,
+ &gEfiIfrTianoGuid,
+ NULL,
+ sizeof (EFI_IFR_GUID_LABEL)
+ );
mLibStartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;
mLibStartLabel->Number = FORM_FILE_EXPLORER_ID;
@@ -1278,7 +1287,7 @@ LibRefreshUpdateData ( //
// Create Hii Extend Label OpCode as the start opcode
//
- mLibEndLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (
+ mLibEndLabel = (EFI_IFR_GUID_LABEL *)HiiCreateGuidOpCode (
mLibEndOpCodeHandle,
&gEfiIfrTianoGuid,
NULL,
@@ -1299,15 +1308,15 @@ LibUpdateFileExplorePage ( VOID
)
{
- UINTN Index;
- MENU_ENTRY *NewMenuEntry;
- FILE_CONTEXT *NewFileContext;
- MENU_OPTION *MenuOption;
- BOOLEAN CreateNewFile;
+ UINTN Index;
+ MENU_ENTRY *NewMenuEntry;
+ FILE_CONTEXT *NewFileContext;
+ MENU_OPTION *MenuOption;
+ BOOLEAN CreateNewFile;
- NewMenuEntry = NULL;
- NewFileContext = NULL;
- CreateNewFile = FALSE;
+ NewMenuEntry = NULL;
+ NewFileContext = NULL;
+ CreateNewFile = FALSE;
LibRefreshUpdateData ();
MenuOption = gFileExplorerPrivate.FsOptionMenu;
@@ -1315,8 +1324,8 @@ LibUpdateFileExplorePage ( mQuestionIdUpdate += QUESTION_ID_UPDATE_STEP;
for (Index = 0; Index < MenuOption->MenuNumber; Index++) {
- NewMenuEntry = LibGetMenuEntry (MenuOption, Index);
- NewFileContext = (FILE_CONTEXT *) NewMenuEntry->VariableContext;
+ NewMenuEntry = LibGetMenuEntry (MenuOption, Index);
+ NewFileContext = (FILE_CONTEXT *)NewMenuEntry->VariableContext;
if (!NewFileContext->IsRoot && !CreateNewFile) {
HiiCreateGotoOpCode (
@@ -1325,7 +1334,7 @@ LibUpdateFileExplorePage ( STRING_TOKEN (STR_NEW_FILE),
STRING_TOKEN (STR_NEW_FILE_HELP),
EFI_IFR_FLAG_CALLBACK,
- (UINT16) (mNewFileQuestionId++)
+ (UINT16)(mNewFileQuestionId++)
);
HiiCreateGotoOpCode (
mLibStartOpCodeHandle,
@@ -1333,9 +1342,9 @@ LibUpdateFileExplorePage ( STRING_TOKEN (STR_NEW_FOLDER),
STRING_TOKEN (STR_NEW_FOLDER_HELP),
EFI_IFR_FLAG_CALLBACK,
- (UINT16) (mNewFolderQuestionId++)
+ (UINT16)(mNewFolderQuestionId++)
);
- HiiCreateTextOpCode(
+ HiiCreateTextOpCode (
mLibStartOpCodeHandle,
STRING_TOKEN (STR_NULL_STRING),
STRING_TOKEN (STR_NULL_STRING),
@@ -1350,7 +1359,7 @@ LibUpdateFileExplorePage ( //
HiiCreateActionOpCode (
mLibStartOpCodeHandle,
- (UINT16) (FILE_OPTION_OFFSET + Index + mQuestionIdUpdate),
+ (UINT16)(FILE_OPTION_OFFSET + Index + mQuestionIdUpdate),
NewMenuEntry->DisplayStringToken,
STRING_TOKEN (STR_NULL_STRING),
EFI_IFR_FLAG_CALLBACK,
@@ -1366,7 +1375,7 @@ LibUpdateFileExplorePage ( NewMenuEntry->DisplayStringToken,
STRING_TOKEN (STR_NULL_STRING),
EFI_IFR_FLAG_CALLBACK,
- (UINT16) (FILE_OPTION_OFFSET + Index + mQuestionIdUpdate)
+ (UINT16)(FILE_OPTION_OFFSET + Index + mQuestionIdUpdate)
);
}
}
@@ -1391,19 +1400,19 @@ LibUpdateFileExplorePage ( **/
EFI_STATUS
LibUpdateFileExplorer (
- IN UINT16 KeyValue
+ IN UINT16 KeyValue
)
{
- UINT16 FileOptionMask;
- MENU_ENTRY *NewMenuEntry;
- FILE_CONTEXT *NewFileContext;
- EFI_STATUS Status;
- EFI_FILE_HANDLE FileHandle;
-
- Status = EFI_SUCCESS;
- FileOptionMask = (UINT16) (FILE_OPTION_MASK & KeyValue) - mQuestionIdUpdate;
+ UINT16 FileOptionMask;
+ MENU_ENTRY *NewMenuEntry;
+ FILE_CONTEXT *NewFileContext;
+ EFI_STATUS Status;
+ EFI_FILE_HANDLE FileHandle;
+
+ Status = EFI_SUCCESS;
+ FileOptionMask = (UINT16)(FILE_OPTION_MASK & KeyValue) - mQuestionIdUpdate;
NewMenuEntry = LibGetMenuEntry (gFileExplorerPrivate.FsOptionMenu, FileOptionMask);
- NewFileContext = (FILE_CONTEXT *) NewMenuEntry->VariableContext;
+ NewFileContext = (FILE_CONTEXT *)NewMenuEntry->VariableContext;
if (NewFileContext->IsDir) {
RemoveEntryList (&NewMenuEntry->Link);
@@ -1417,6 +1426,7 @@ LibUpdateFileExplorer ( LibFreeMenu (gFileExplorerPrivate.FsOptionMenu);
}
}
+
LibDestroyMenuEntry (NewMenuEntry);
}
@@ -1431,22 +1441,23 @@ LibUpdateFileExplorer ( **/
VOID
LibGetDevicePath (
- IN UINT16 KeyValue
+ IN UINT16 KeyValue
)
{
- UINT16 FileOptionMask;
- MENU_ENTRY *NewMenuEntry;
- FILE_CONTEXT *NewFileContext;
+ UINT16 FileOptionMask;
+ MENU_ENTRY *NewMenuEntry;
+ FILE_CONTEXT *NewFileContext;
- FileOptionMask = (UINT16) (FILE_OPTION_MASK & KeyValue) - mQuestionIdUpdate;
+ FileOptionMask = (UINT16)(FILE_OPTION_MASK & KeyValue) - mQuestionIdUpdate;
NewMenuEntry = LibGetMenuEntry (gFileExplorerPrivate.FsOptionMenu, FileOptionMask);
- NewFileContext = (FILE_CONTEXT *) NewMenuEntry->VariableContext;
+ NewFileContext = (FILE_CONTEXT *)NewMenuEntry->VariableContext;
if (gFileExplorerPrivate.RetDevicePath != NULL) {
FreePool (gFileExplorerPrivate.RetDevicePath);
}
+
gFileExplorerPrivate.RetDevicePath = DuplicateDevicePath (NewFileContext->DevicePath);
}
@@ -1478,57 +1489,58 @@ ChooseFile ( OUT EFI_DEVICE_PATH_PROTOCOL **File OPTIONAL
)
{
- EFI_FILE_HANDLE FileHandle;
- EFI_STATUS Status;
- UINT16 *FileName;
- EFI_HANDLE DeviceHandle;
+ EFI_FILE_HANDLE FileHandle;
+ EFI_STATUS Status;
+ UINT16 *FileName;
+ EFI_HANDLE DeviceHandle;
if ((ChooseHandler == NULL) && (File == NULL)) {
return EFI_INVALID_PARAMETER;
}
mQuestionIdUpdate = 0;
- FileName = NULL;
+ FileName = NULL;
gFileExplorerPrivate.RetDevicePath = NULL;
gFileExplorerPrivate.ChooseHandler = ChooseHandler;
if (FileType != NULL) {
gFileExplorerPrivate.FileType = AllocateCopyPool (StrSize (FileType), FileType);
- ASSERT(gFileExplorerPrivate.FileType != NULL);
- LibToLowerString(gFileExplorerPrivate.FileType);
+ ASSERT (gFileExplorerPrivate.FileType != NULL);
+ LibToLowerString (gFileExplorerPrivate.FileType);
} else {
gFileExplorerPrivate.FileType = NULL;
}
if (RootDirectory == NULL) {
- Status = LibFindFileSystem();
+ Status = LibFindFileSystem ();
} else {
- Status = LibGetFileHandleFromDevicePath(RootDirectory, &FileHandle, &FileName, &DeviceHandle);
+ Status = LibGetFileHandleFromDevicePath (RootDirectory, &FileHandle, &FileName, &DeviceHandle);
if (EFI_ERROR (Status)) {
goto Done;
}
Status = LibFindFiles (FileHandle, FileName, DeviceHandle);
}
+
if (EFI_ERROR (Status)) {
goto Done;
}
- LibUpdateFileExplorePage();
+ LibUpdateFileExplorePage ();
gFileExplorerPrivate.FormBrowser2->SendForm (
- gFileExplorerPrivate.FormBrowser2,
- &gFileExplorerPrivate.FeHiiHandle,
- 1,
- &FileExplorerGuid,
- 0,
- NULL,
- NULL
- );
+ gFileExplorerPrivate.FormBrowser2,
+ &gFileExplorerPrivate.FeHiiHandle,
+ 1,
+ &FileExplorerGuid,
+ 0,
+ NULL,
+ NULL
+ );
Done:
if ((Status == EFI_SUCCESS) && (File != NULL)) {
- *File = gFileExplorerPrivate.RetDevicePath;
+ *File = gFileExplorerPrivate.RetDevicePath;
} else if (gFileExplorerPrivate.RetDevicePath != NULL) {
FreePool (gFileExplorerPrivate.RetDevicePath);
}
@@ -1559,13 +1571,13 @@ Done: EFI_STATUS
EFIAPI
FileExplorerLibConstructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
- gHiiVendorDevicePath = (HII_VENDOR_DEVICE_PATH*) DuplicateDevicePath ((EFI_DEVICE_PATH_PROTOCOL*)&FeHiiVendorDevicePath);
+ gHiiVendorDevicePath = (HII_VENDOR_DEVICE_PATH *)DuplicateDevicePath ((EFI_DEVICE_PATH_PROTOCOL *)&FeHiiVendorDevicePath);
ASSERT (gHiiVendorDevicePath != NULL);
CopyGuid (&gHiiVendorDevicePath->VendorDevicePath.Guid, &gEfiCallerIdGuid);
@@ -1583,6 +1595,7 @@ FileExplorerLibConstructor ( if (Status == EFI_ALREADY_STARTED) {
return EFI_SUCCESS;
}
+
if (EFI_ERROR (Status)) {
return Status;
}
@@ -1591,18 +1604,18 @@ FileExplorerLibConstructor ( // Post our File Explorer VFR binary to the HII database.
//
gFileExplorerPrivate.FeHiiHandle = HiiAddPackages (
- &FileExplorerGuid,
- gFileExplorerPrivate.FeDriverHandle,
- FileExplorerVfrBin,
- FileExplorerLibStrings,
- NULL
- );
+ &FileExplorerGuid,
+ gFileExplorerPrivate.FeDriverHandle,
+ FileExplorerVfrBin,
+ FileExplorerLibStrings,
+ NULL
+ );
ASSERT (gFileExplorerPrivate.FeHiiHandle != NULL);
//
// Locate Formbrowser2 protocol
//
- Status = gBS->LocateProtocol (&gEfiFormBrowser2ProtocolGuid, NULL, (VOID **) &gFileExplorerPrivate.FormBrowser2);
+ Status = gBS->LocateProtocol (&gEfiFormBrowser2ProtocolGuid, NULL, (VOID **)&gFileExplorerPrivate.FormBrowser2);
ASSERT_EFI_ERROR (Status);
InitializeListHead (&gFileExplorerPrivate.FsOptionMenu->Head);
@@ -1621,11 +1634,11 @@ FileExplorerLibConstructor ( EFI_STATUS
EFIAPI
FileExplorerLibDestructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
ASSERT (gHiiVendorDevicePath != NULL);
diff --git a/MdeModulePkg/Library/FileExplorerLib/FileExplorer.h b/MdeModulePkg/Library/FileExplorerLib/FileExplorer.h index cc84c2a654..c7587c166b 100644 --- a/MdeModulePkg/Library/FileExplorerLib/FileExplorer.h +++ b/MdeModulePkg/Library/FileExplorerLib/FileExplorer.h @@ -32,8 +32,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include "FormGuid.h"
-#define FILE_EXPLORER_CALLBACK_DATA_SIGNATURE SIGNATURE_32 ('f', 'e', 'c', 'k')
-
+#define FILE_EXPLORER_CALLBACK_DATA_SIGNATURE SIGNATURE_32 ('f', 'e', 'c', 'k')
#pragma pack(1)
@@ -41,77 +40,76 @@ SPDX-License-Identifier: BSD-2-Clause-Patent /// HII specific Vendor Device Path definition.
///
typedef struct {
- VENDOR_DEVICE_PATH VendorDevicePath;
- EFI_DEVICE_PATH_PROTOCOL End;
+ VENDOR_DEVICE_PATH VendorDevicePath;
+ EFI_DEVICE_PATH_PROTOCOL End;
} HII_VENDOR_DEVICE_PATH;
#pragma pack()
typedef struct {
- EFI_HANDLE DeviceHandle;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- EFI_FILE_HANDLE FileHandle;
- UINT16 *FileName;
+ EFI_HANDLE DeviceHandle;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ EFI_FILE_HANDLE FileHandle;
+ UINT16 *FileName;
- BOOLEAN IsRoot;
- BOOLEAN IsDir;
+ BOOLEAN IsRoot;
+ BOOLEAN IsDir;
} FILE_CONTEXT;
typedef struct {
- UINTN Signature;
- LIST_ENTRY Link;
- UINT16 *DisplayString;
- UINT16 *HelpString;
- EFI_STRING_ID DisplayStringToken;
- EFI_STRING_ID HelpStringToken;
- VOID *VariableContext;
+ UINTN Signature;
+ LIST_ENTRY Link;
+ UINT16 *DisplayString;
+ UINT16 *HelpString;
+ EFI_STRING_ID DisplayStringToken;
+ EFI_STRING_ID HelpStringToken;
+ VOID *VariableContext;
} MENU_ENTRY;
typedef struct {
- UINTN Signature;
- LIST_ENTRY Head;
- UINTN MenuNumber;
- BOOLEAN Used;
+ UINTN Signature;
+ LIST_ENTRY Head;
+ UINTN MenuNumber;
+ BOOLEAN Used;
} MENU_OPTION;
typedef struct {
//
// Shared callback data.
//
- UINTN Signature;
+ UINTN Signature;
//
// File explorer formset callback data.
//
- EFI_HII_HANDLE FeHiiHandle;
- EFI_HANDLE FeDriverHandle;
- EFI_HII_CONFIG_ACCESS_PROTOCOL FeConfigAccess;
- EFI_FORM_BROWSER2_PROTOCOL *FormBrowser2;
- MENU_OPTION *FsOptionMenu;
- CHAR16 *FileType;
- CHOOSE_HANDLER ChooseHandler;
- EFI_DEVICE_PATH_PROTOCOL *RetDevicePath;
-
+ EFI_HII_HANDLE FeHiiHandle;
+ EFI_HANDLE FeDriverHandle;
+ EFI_HII_CONFIG_ACCESS_PROTOCOL FeConfigAccess;
+ EFI_FORM_BROWSER2_PROTOCOL *FormBrowser2;
+ MENU_OPTION *FsOptionMenu;
+ CHAR16 *FileType;
+ CHOOSE_HANDLER ChooseHandler;
+ EFI_DEVICE_PATH_PROTOCOL *RetDevicePath;
} FILE_EXPLORER_CALLBACK_DATA;
#define FILE_EXPLORER_PRIVATE_FROM_THIS(a) CR (a, FILE_EXPLORER_CALLBACK_DATA, FeConfigAccess, FILE_EXPLORER_CALLBACK_DATA_SIGNATURE)
-extern UINT8 FileExplorerVfrBin[];
+extern UINT8 FileExplorerVfrBin[];
-#define MENU_OPTION_SIGNATURE SIGNATURE_32 ('m', 'e', 'n', 'u')
-#define MENU_ENTRY_SIGNATURE SIGNATURE_32 ('e', 'n', 't', 'r')
+#define MENU_OPTION_SIGNATURE SIGNATURE_32 ('m', 'e', 'n', 'u')
+#define MENU_ENTRY_SIGNATURE SIGNATURE_32 ('e', 'n', 't', 'r')
///
/// Define the maximum characters that will be accepted.
///
-#define MAX_CHAR 480
-#define FILE_OPTION_OFFSET 0x8000
-#define FILE_OPTION_MASK 0x7FFF
-#define QUESTION_ID_UPDATE_STEP 200
-#define MAX_FILE_NAME_LEN 20
-#define MAX_FOLDER_NAME_LEN 20
-#define NEW_FILE_QUESTION_ID_BASE 0x5000;
-#define NEW_FOLDER_QUESTION_ID_BASE 0x6000;
+#define MAX_CHAR 480
+#define FILE_OPTION_OFFSET 0x8000
+#define FILE_OPTION_MASK 0x7FFF
+#define QUESTION_ID_UPDATE_STEP 200
+#define MAX_FILE_NAME_LEN 20
+#define MAX_FOLDER_NAME_LEN 20
+#define NEW_FILE_QUESTION_ID_BASE 0x5000;
+#define NEW_FOLDER_QUESTION_ID_BASE 0x6000;
/**
This function processes the results of changes in configuration.
@@ -143,15 +141,14 @@ extern UINT8 FileExplorerVfrBin[]; EFI_STATUS
EFIAPI
LibCallback (
- IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
- IN EFI_BROWSER_ACTION Action,
- IN EFI_QUESTION_ID QuestionId,
- IN UINT8 Type,
- IN EFI_IFR_TYPE_VALUE *Value,
- OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
+ IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
+ IN EFI_BROWSER_ACTION Action,
+ IN EFI_QUESTION_ID QuestionId,
+ IN UINT8 Type,
+ IN EFI_IFR_TYPE_VALUE *Value,
+ OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
);
-
/**
This function allows a caller to extract the current configuration for one
or more named elements from the target driver.
@@ -177,10 +174,10 @@ LibCallback ( EFI_STATUS
EFIAPI
LibExtractConfig (
- IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
- IN CONST EFI_STRING Request,
- OUT EFI_STRING *Progress,
- OUT EFI_STRING *Results
+ IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
+ IN CONST EFI_STRING Request,
+ OUT EFI_STRING *Progress,
+ OUT EFI_STRING *Results
);
/**
@@ -202,9 +199,9 @@ LibExtractConfig ( EFI_STATUS
EFIAPI
LibRouteConfig (
- IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
- IN CONST EFI_STRING Configuration,
- OUT EFI_STRING *Progress
+ IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
+ IN CONST EFI_STRING Configuration,
+ OUT EFI_STRING *Progress
);
/**
@@ -218,10 +215,9 @@ LibRouteConfig ( **/
EFI_STATUS
LibUpdateFileExplorer (
- IN UINT16 KeyValue
+ IN UINT16 KeyValue
);
-
/**
Get the device path info saved in the menu structure.
@@ -230,7 +226,7 @@ LibUpdateFileExplorer ( **/
VOID
LibGetDevicePath (
- IN UINT16 KeyValue
+ IN UINT16 KeyValue
);
#endif
diff --git a/MdeModulePkg/Library/FileExplorerLib/FormGuid.h b/MdeModulePkg/Library/FileExplorerLib/FormGuid.h index a084a50b3b..52a34dc283 100644 --- a/MdeModulePkg/Library/FileExplorerLib/FormGuid.h +++ b/MdeModulePkg/Library/FileExplorerLib/FormGuid.h @@ -6,11 +6,9 @@ SPDX-License-Identifier: BSD-2-Clause-Patent **/
-
#ifndef _FILE_EXPLORER_FORM_GUID_H_
#define _FILE_EXPLORER_FORM_GUID_H_
-
#define EFI_FILE_EXPLORE_FORMSET_GUID \
{ \
0xfe561596, 0xe6bf, 0x41a6, {0x83, 0x76, 0xc7, 0x2b, 0x71, 0x98, 0x74, 0xd0} \
@@ -26,7 +24,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #define KEY_VALUE_CREATE_FOLDER_AND_EXIT 0x3002
#define KEY_VALUE_NO_CREATE_FOLDER_AND_EXIT 0x3003
-#define LABEL_END 0xffff
+#define LABEL_END 0xffff
#endif
-
diff --git a/MdeModulePkg/Library/FmpAuthenticationLibNull/FmpAuthenticationLibNull.c b/MdeModulePkg/Library/FmpAuthenticationLibNull/FmpAuthenticationLibNull.c index 533e1ea5ac..6b205a9715 100644 --- a/MdeModulePkg/Library/FmpAuthenticationLibNull/FmpAuthenticationLibNull.c +++ b/MdeModulePkg/Library/FmpAuthenticationLibNull/FmpAuthenticationLibNull.c @@ -55,6 +55,6 @@ AuthenticateFmpImage ( IN UINTN PublicKeyDataLength
)
{
- ASSERT(FALSE);
+ ASSERT (FALSE);
return RETURN_UNSUPPORTED;
}
diff --git a/MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.c b/MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.c index 3731c3f34a..432577bcfd 100644 --- a/MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.c +++ b/MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.c @@ -15,23 +15,23 @@ #include <Library/FrameBufferBltLib.h>
struct FRAME_BUFFER_CONFIGURE {
- UINT32 PixelsPerScanLine;
- UINT32 BytesPerPixel;
- UINT32 Width;
- UINT32 Height;
- UINT8 *FrameBuffer;
- EFI_GRAPHICS_PIXEL_FORMAT PixelFormat;
- EFI_PIXEL_BITMASK PixelMasks;
- INT8 PixelShl[4]; // R-G-B-Rsvd
- INT8 PixelShr[4]; // R-G-B-Rsvd
- UINT8 LineBuffer[0];
+ UINT32 PixelsPerScanLine;
+ UINT32 BytesPerPixel;
+ UINT32 Width;
+ UINT32 Height;
+ UINT8 *FrameBuffer;
+ EFI_GRAPHICS_PIXEL_FORMAT PixelFormat;
+ EFI_PIXEL_BITMASK PixelMasks;
+ INT8 PixelShl[4]; // R-G-B-Rsvd
+ INT8 PixelShr[4]; // R-G-B-Rsvd
+ UINT8 LineBuffer[0];
};
-CONST EFI_PIXEL_BITMASK mRgbPixelMasks = {
+CONST EFI_PIXEL_BITMASK mRgbPixelMasks = {
0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000
};
-CONST EFI_PIXEL_BITMASK mBgrPixelMasks = {
+CONST EFI_PIXEL_BITMASK mBgrPixelMasks = {
0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000
};
@@ -45,10 +45,10 @@ CONST EFI_PIXEL_BITMASK mBgrPixelMasks = { **/
VOID
FrameBufferBltLibConfigurePixelFormat (
- IN CONST EFI_PIXEL_BITMASK *BitMask,
- OUT UINT32 *BytesPerPixel,
- OUT INT8 *PixelShl,
- OUT INT8 *PixelShr
+ IN CONST EFI_PIXEL_BITMASK *BitMask,
+ OUT UINT32 *BytesPerPixel,
+ OUT INT8 *PixelShl,
+ OUT INT8 *PixelShr
)
{
UINT8 Index;
@@ -58,26 +58,34 @@ FrameBufferBltLibConfigurePixelFormat ( ASSERT (BytesPerPixel != NULL);
MergedMasks = 0;
- Masks = (UINT32*) BitMask;
+ Masks = (UINT32 *)BitMask;
for (Index = 0; Index < 3; Index++) {
ASSERT ((MergedMasks & Masks[Index]) == 0);
- PixelShl[Index] = (INT8) HighBitSet32 (Masks[Index]) - 23 + (Index * 8);
+ PixelShl[Index] = (INT8)HighBitSet32 (Masks[Index]) - 23 + (Index * 8);
if (PixelShl[Index] < 0) {
PixelShr[Index] = -PixelShl[Index];
PixelShl[Index] = 0;
} else {
PixelShr[Index] = 0;
}
- DEBUG ((DEBUG_INFO, "%d: shl:%d shr:%d mask:%x\n", Index,
- PixelShl[Index], PixelShr[Index], Masks[Index]));
- MergedMasks = (UINT32) (MergedMasks | Masks[Index]);
+ DEBUG ((
+ DEBUG_INFO,
+ "%d: shl:%d shr:%d mask:%x\n",
+ Index,
+ PixelShl[Index],
+ PixelShr[Index],
+ Masks[Index]
+ ));
+
+ MergedMasks = (UINT32)(MergedMasks | Masks[Index]);
}
- MergedMasks = (UINT32) (MergedMasks | Masks[3]);
+
+ MergedMasks = (UINT32)(MergedMasks | Masks[3]);
ASSERT (MergedMasks != 0);
- *BytesPerPixel = (UINT32) ((HighBitSet32 (MergedMasks) + 7) / 8);
+ *BytesPerPixel = (UINT32)((HighBitSet32 (MergedMasks) + 7) / 8);
DEBUG ((DEBUG_INFO, "Bytes per pixel: %d\n", *BytesPerPixel));
}
@@ -107,35 +115,35 @@ FrameBufferBltConfigure ( IN OUT UINTN *ConfigureSize
)
{
- CONST EFI_PIXEL_BITMASK *BitMask;
- UINT32 BytesPerPixel;
- INT8 PixelShl[4];
- INT8 PixelShr[4];
+ CONST EFI_PIXEL_BITMASK *BitMask;
+ UINT32 BytesPerPixel;
+ INT8 PixelShl[4];
+ INT8 PixelShr[4];
if (ConfigureSize == NULL) {
return RETURN_INVALID_PARAMETER;
}
switch (FrameBufferInfo->PixelFormat) {
- case PixelRedGreenBlueReserved8BitPerColor:
- BitMask = &mRgbPixelMasks;
- break;
+ case PixelRedGreenBlueReserved8BitPerColor:
+ BitMask = &mRgbPixelMasks;
+ break;
- case PixelBlueGreenRedReserved8BitPerColor:
- BitMask = &mBgrPixelMasks;
- break;
+ case PixelBlueGreenRedReserved8BitPerColor:
+ BitMask = &mBgrPixelMasks;
+ break;
- case PixelBitMask:
- BitMask = &FrameBufferInfo->PixelInformation;
- break;
+ case PixelBitMask:
+ BitMask = &FrameBufferInfo->PixelInformation;
+ break;
- case PixelBltOnly:
- ASSERT (FrameBufferInfo->PixelFormat != PixelBltOnly);
- return RETURN_UNSUPPORTED;
+ case PixelBltOnly:
+ ASSERT (FrameBufferInfo->PixelFormat != PixelBltOnly);
+ return RETURN_UNSUPPORTED;
- default:
- ASSERT (FALSE);
- return RETURN_INVALID_PARAMETER;
+ default:
+ ASSERT (FALSE);
+ return RETURN_INVALID_PARAMETER;
}
if (FrameBufferInfo->PixelsPerScanLine < FrameBufferInfo->HorizontalResolution) {
@@ -145,9 +153,10 @@ FrameBufferBltConfigure ( FrameBufferBltLibConfigurePixelFormat (BitMask, &BytesPerPixel, PixelShl, PixelShr);
if (*ConfigureSize < sizeof (FRAME_BUFFER_CONFIGURE)
- + FrameBufferInfo->HorizontalResolution * BytesPerPixel) {
+ + FrameBufferInfo->HorizontalResolution * BytesPerPixel)
+ {
*ConfigureSize = sizeof (FRAME_BUFFER_CONFIGURE)
- + FrameBufferInfo->HorizontalResolution * BytesPerPixel;
+ + FrameBufferInfo->HorizontalResolution * BytesPerPixel;
return RETURN_BUFFER_TOO_SMALL;
}
@@ -155,12 +164,12 @@ FrameBufferBltConfigure ( return RETURN_INVALID_PARAMETER;
}
- CopyMem (&Configure->PixelMasks, BitMask, sizeof (*BitMask));
- CopyMem (Configure->PixelShl, PixelShl, sizeof (PixelShl));
- CopyMem (Configure->PixelShr, PixelShr, sizeof (PixelShr));
+ CopyMem (&Configure->PixelMasks, BitMask, sizeof (*BitMask));
+ CopyMem (Configure->PixelShl, PixelShl, sizeof (PixelShl));
+ CopyMem (Configure->PixelShr, PixelShr, sizeof (PixelShr));
Configure->BytesPerPixel = BytesPerPixel;
Configure->PixelFormat = FrameBufferInfo->PixelFormat;
- Configure->FrameBuffer = (UINT8*) FrameBuffer;
+ Configure->FrameBuffer = (UINT8 *)FrameBuffer;
Configure->Width = FrameBufferInfo->HorizontalResolution;
Configure->Height = FrameBufferInfo->VerticalResolution;
Configure->PixelsPerScanLine = FrameBufferInfo->PixelsPerScanLine;
@@ -185,25 +194,25 @@ FrameBufferBltConfigure ( **/
EFI_STATUS
FrameBufferBltLibVideoFill (
- IN FRAME_BUFFER_CONFIGURE *Configure,
- IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Color,
- IN UINTN DestinationX,
- IN UINTN DestinationY,
- IN UINTN Width,
- IN UINTN Height
+ IN FRAME_BUFFER_CONFIGURE *Configure,
+ IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Color,
+ IN UINTN DestinationX,
+ IN UINTN DestinationY,
+ IN UINTN Width,
+ IN UINTN Height
)
{
- UINTN IndexX;
- UINTN IndexY;
- UINT8 *Destination;
- UINT8 Uint8;
- UINT32 Uint32;
- UINT64 WideFill;
- BOOLEAN UseWideFill;
- BOOLEAN LineBufferReady;
- UINTN Offset;
- UINTN WidthInBytes;
- UINTN SizeInBytes;
+ UINTN IndexX;
+ UINTN IndexY;
+ UINT8 *Destination;
+ UINT8 Uint8;
+ UINT32 Uint32;
+ UINT64 WideFill;
+ BOOLEAN UseWideFill;
+ BOOLEAN LineBufferReady;
+ UINTN Offset;
+ UINTN WidthInBytes;
+ UINTN SizeInBytes;
//
// BltBuffer to Video: Source is BltBuffer, destination is Video
@@ -218,25 +227,29 @@ FrameBufferBltLibVideoFill ( return RETURN_INVALID_PARAMETER;
}
- if (Width == 0 || Height == 0) {
+ if ((Width == 0) || (Height == 0)) {
DEBUG ((DEBUG_VERBOSE, "VideoFill: Width or Height is 0\n"));
return RETURN_INVALID_PARAMETER;
}
WidthInBytes = Width * Configure->BytesPerPixel;
- Uint32 = *(UINT32*) Color;
+ Uint32 = *(UINT32 *)Color;
WideFill =
- (UINT32) (
- (((Uint32 << Configure->PixelShl[0]) >> Configure->PixelShr[0]) &
- Configure->PixelMasks.RedMask) |
- (((Uint32 << Configure->PixelShl[1]) >> Configure->PixelShr[1]) &
- Configure->PixelMasks.GreenMask) |
- (((Uint32 << Configure->PixelShl[2]) >> Configure->PixelShr[2]) &
- Configure->PixelMasks.BlueMask)
- );
- DEBUG ((DEBUG_VERBOSE, "VideoFill: color=0x%x, wide-fill=0x%x\n",
- Uint32, WideFill));
+ (UINT32)(
+ (((Uint32 << Configure->PixelShl[0]) >> Configure->PixelShr[0]) &
+ Configure->PixelMasks.RedMask) |
+ (((Uint32 << Configure->PixelShl[1]) >> Configure->PixelShr[1]) &
+ Configure->PixelMasks.GreenMask) |
+ (((Uint32 << Configure->PixelShl[2]) >> Configure->PixelShr[2]) &
+ Configure->PixelMasks.BlueMask)
+ );
+ DEBUG ((
+ DEBUG_VERBOSE,
+ "VideoFill: color=0x%x, wide-fill=0x%x\n",
+ Uint32,
+ WideFill
+ ));
//
// If the size of the pixel data evenly divides the sizeof
@@ -245,7 +258,7 @@ FrameBufferBltLibVideoFill ( UseWideFill = TRUE;
if ((sizeof (WideFill) % Configure->BytesPerPixel) == 0) {
for (IndexX = Configure->BytesPerPixel; IndexX < sizeof (WideFill); IndexX++) {
- ((UINT8*) &WideFill)[IndexX] = ((UINT8*) &WideFill)[IndexX % Configure->BytesPerPixel];
+ ((UINT8 *)&WideFill)[IndexX] = ((UINT8 *)&WideFill)[IndexX % Configure->BytesPerPixel];
}
} else {
//
@@ -253,14 +266,16 @@ FrameBufferBltLibVideoFill ( // a wide fill operation.
//
for (
- IndexX = 1, Uint8 = ((UINT8*) &WideFill)[0];
- IndexX < Configure->BytesPerPixel;
- IndexX++) {
- if (Uint8 != ((UINT8*) &WideFill)[IndexX]) {
+ IndexX = 1, Uint8 = ((UINT8 *)&WideFill)[0];
+ IndexX < Configure->BytesPerPixel;
+ IndexX++)
+ {
+ if (Uint8 != ((UINT8 *)&WideFill)[IndexX]) {
UseWideFill = FALSE;
break;
}
}
+
if (UseWideFill) {
SetMem (&WideFill, sizeof (WideFill), Uint8);
}
@@ -268,26 +283,27 @@ FrameBufferBltLibVideoFill ( if (UseWideFill && (DestinationX == 0) && (Width == Configure->PixelsPerScanLine)) {
DEBUG ((DEBUG_VERBOSE, "VideoFill (wide, one-shot)\n"));
- Offset = DestinationY * Configure->PixelsPerScanLine;
- Offset = Configure->BytesPerPixel * Offset;
+ Offset = DestinationY * Configure->PixelsPerScanLine;
+ Offset = Configure->BytesPerPixel * Offset;
Destination = Configure->FrameBuffer + Offset;
SizeInBytes = WidthInBytes * Height;
if (SizeInBytes >= 8) {
- SetMem32 (Destination, SizeInBytes & ~3, (UINT32) WideFill);
+ SetMem32 (Destination, SizeInBytes & ~3, (UINT32)WideFill);
Destination += SizeInBytes & ~3;
SizeInBytes &= 3;
}
+
if (SizeInBytes > 0) {
- SetMem (Destination, SizeInBytes, (UINT8) (UINTN) WideFill);
+ SetMem (Destination, SizeInBytes, (UINT8)(UINTN)WideFill);
}
} else {
LineBufferReady = FALSE;
for (IndexY = DestinationY; IndexY < (Height + DestinationY); IndexY++) {
- Offset = (IndexY * Configure->PixelsPerScanLine) + DestinationX;
- Offset = Configure->BytesPerPixel * Offset;
+ Offset = (IndexY * Configure->PixelsPerScanLine) + DestinationX;
+ Offset = Configure->BytesPerPixel * Offset;
Destination = Configure->FrameBuffer + Offset;
- if (UseWideFill && (((UINTN) Destination & 7) == 0)) {
+ if (UseWideFill && (((UINTN)Destination & 7) == 0)) {
DEBUG ((DEBUG_VERBOSE, "VideoFill (wide)\n"));
SizeInBytes = WidthInBytes;
if (SizeInBytes >= 8) {
@@ -295,6 +311,7 @@ FrameBufferBltLibVideoFill ( Destination += SizeInBytes & ~7;
SizeInBytes &= 7;
}
+
if (SizeInBytes > 0) {
CopyMem (Destination, &WideFill, SizeInBytes);
}
@@ -307,11 +324,13 @@ FrameBufferBltLibVideoFill ( (Configure->LineBuffer + (IndexX * Configure->BytesPerPixel)),
Configure->LineBuffer,
MIN (IndexX, Width - IndexX) * Configure->BytesPerPixel
- );
+ );
IndexX += MIN (IndexX, Width - IndexX);
}
+
LineBufferReady = TRUE;
}
+
CopyMem (Destination, Configure->LineBuffer, WidthInBytes);
}
}
@@ -340,26 +359,26 @@ FrameBufferBltLibVideoFill ( **/
RETURN_STATUS
FrameBufferBltLibVideoToBltBuffer (
- IN FRAME_BUFFER_CONFIGURE *Configure,
- OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer,
- IN UINTN SourceX,
- IN UINTN SourceY,
- IN UINTN DestinationX,
- IN UINTN DestinationY,
- IN UINTN Width,
- IN UINTN Height,
- IN UINTN Delta
+ IN FRAME_BUFFER_CONFIGURE *Configure,
+ OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer,
+ IN UINTN SourceX,
+ IN UINTN SourceY,
+ IN UINTN DestinationX,
+ IN UINTN DestinationY,
+ IN UINTN Width,
+ IN UINTN Height,
+ IN UINTN Delta
)
{
- UINTN DstY;
- UINTN SrcY;
- EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Blt;
- UINT8 *Source;
- UINT8 *Destination;
- UINTN IndexX;
- UINT32 Uint32;
- UINTN Offset;
- UINTN WidthInBytes;
+ UINTN DstY;
+ UINTN SrcY;
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Blt;
+ UINT8 *Source;
+ UINT8 *Destination;
+ UINTN IndexX;
+ UINT32 Uint32;
+ UINTN Offset;
+ UINTN WidthInBytes;
//
// Video to BltBuffer: Source is Video, destination is BltBuffer
@@ -372,7 +391,7 @@ FrameBufferBltLibVideoToBltBuffer ( return RETURN_INVALID_PARAMETER;
}
- if (Width == 0 || Height == 0) {
+ if ((Width == 0) || (Height == 0)) {
return RETURN_INVALID_PARAMETER;
}
@@ -392,14 +411,14 @@ FrameBufferBltLibVideoToBltBuffer ( //
for (SrcY = SourceY, DstY = DestinationY;
DstY < (Height + DestinationY);
- SrcY++, DstY++) {
-
+ SrcY++, DstY++)
+ {
Offset = (SrcY * Configure->PixelsPerScanLine) + SourceX;
Offset = Configure->BytesPerPixel * Offset;
Source = Configure->FrameBuffer + Offset;
if (Configure->PixelFormat == PixelBlueGreenRedReserved8BitPerColor) {
- Destination = (UINT8 *) BltBuffer + (DstY * Delta) + (DestinationX * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
+ Destination = (UINT8 *)BltBuffer + (DstY * Delta) + (DestinationX * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
} else {
Destination = Configure->LineBuffer;
}
@@ -409,18 +428,18 @@ FrameBufferBltLibVideoToBltBuffer ( if (Configure->PixelFormat != PixelBlueGreenRedReserved8BitPerColor) {
for (IndexX = 0; IndexX < Width; IndexX++) {
Blt = (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *)
- ((UINT8 *) BltBuffer + (DstY * Delta) +
- (DestinationX + IndexX) * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
- Uint32 = *(UINT32*) (Configure->LineBuffer + (IndexX * Configure->BytesPerPixel));
- *(UINT32*) Blt =
- (UINT32) (
- (((Uint32 & Configure->PixelMasks.RedMask) >>
- Configure->PixelShl[0]) << Configure->PixelShr[0]) |
- (((Uint32 & Configure->PixelMasks.GreenMask) >>
- Configure->PixelShl[1]) << Configure->PixelShr[1]) |
- (((Uint32 & Configure->PixelMasks.BlueMask) >>
- Configure->PixelShl[2]) << Configure->PixelShr[2])
- );
+ ((UINT8 *)BltBuffer + (DstY * Delta) +
+ (DestinationX + IndexX) * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
+ Uint32 = *(UINT32 *)(Configure->LineBuffer + (IndexX * Configure->BytesPerPixel));
+ *(UINT32 *)Blt =
+ (UINT32)(
+ (((Uint32 & Configure->PixelMasks.RedMask) >>
+ Configure->PixelShl[0]) << Configure->PixelShr[0]) |
+ (((Uint32 & Configure->PixelMasks.GreenMask) >>
+ Configure->PixelShl[1]) << Configure->PixelShr[1]) |
+ (((Uint32 & Configure->PixelMasks.BlueMask) >>
+ Configure->PixelShl[2]) << Configure->PixelShr[2])
+ );
}
}
}
@@ -448,26 +467,26 @@ FrameBufferBltLibVideoToBltBuffer ( **/
RETURN_STATUS
FrameBufferBltLibBufferToVideo (
- IN FRAME_BUFFER_CONFIGURE *Configure,
- IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer,
- IN UINTN SourceX,
- IN UINTN SourceY,
- IN UINTN DestinationX,
- IN UINTN DestinationY,
- IN UINTN Width,
- IN UINTN Height,
- IN UINTN Delta
+ IN FRAME_BUFFER_CONFIGURE *Configure,
+ IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer,
+ IN UINTN SourceX,
+ IN UINTN SourceY,
+ IN UINTN DestinationX,
+ IN UINTN DestinationY,
+ IN UINTN Width,
+ IN UINTN Height,
+ IN UINTN Delta
)
{
- UINTN DstY;
- UINTN SrcY;
- EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Blt;
- UINT8 *Source;
- UINT8 *Destination;
- UINTN IndexX;
- UINT32 Uint32;
- UINTN Offset;
- UINTN WidthInBytes;
+ UINTN DstY;
+ UINTN SrcY;
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Blt;
+ UINT8 *Source;
+ UINT8 *Destination;
+ UINTN IndexX;
+ UINT32 Uint32;
+ UINTN Offset;
+ UINTN WidthInBytes;
//
// BltBuffer to Video: Source is BltBuffer, destination is Video
@@ -480,7 +499,7 @@ FrameBufferBltLibBufferToVideo ( return RETURN_INVALID_PARAMETER;
}
- if (Width == 0 || Height == 0) {
+ if ((Width == 0) || (Height == 0)) {
return RETURN_INVALID_PARAMETER;
}
@@ -497,33 +516,34 @@ FrameBufferBltLibBufferToVideo ( for (SrcY = SourceY, DstY = DestinationY;
SrcY < (Height + SourceY);
- SrcY++, DstY++) {
-
- Offset = (DstY * Configure->PixelsPerScanLine) + DestinationX;
- Offset = Configure->BytesPerPixel * Offset;
+ SrcY++, DstY++)
+ {
+ Offset = (DstY * Configure->PixelsPerScanLine) + DestinationX;
+ Offset = Configure->BytesPerPixel * Offset;
Destination = Configure->FrameBuffer + Offset;
if (Configure->PixelFormat == PixelBlueGreenRedReserved8BitPerColor) {
- Source = (UINT8 *) BltBuffer + (SrcY * Delta) + SourceX * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL);
+ Source = (UINT8 *)BltBuffer + (SrcY * Delta) + SourceX * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL);
} else {
for (IndexX = 0; IndexX < Width; IndexX++) {
Blt =
- (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) (
- (UINT8 *) BltBuffer +
- (SrcY * Delta) +
- ((SourceX + IndexX) * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL))
- );
- Uint32 = *(UINT32*) Blt;
- *(UINT32*) (Configure->LineBuffer + (IndexX * Configure->BytesPerPixel)) =
- (UINT32) (
- (((Uint32 << Configure->PixelShl[0]) >> Configure->PixelShr[0]) &
- Configure->PixelMasks.RedMask) |
- (((Uint32 << Configure->PixelShl[1]) >> Configure->PixelShr[1]) &
- Configure->PixelMasks.GreenMask) |
- (((Uint32 << Configure->PixelShl[2]) >> Configure->PixelShr[2]) &
- Configure->PixelMasks.BlueMask)
- );
+ (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *)(
+ (UINT8 *)BltBuffer +
+ (SrcY * Delta) +
+ ((SourceX + IndexX) * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL))
+ );
+ Uint32 = *(UINT32 *)Blt;
+ *(UINT32 *)(Configure->LineBuffer + (IndexX * Configure->BytesPerPixel)) =
+ (UINT32)(
+ (((Uint32 << Configure->PixelShl[0]) >> Configure->PixelShr[0]) &
+ Configure->PixelMasks.RedMask) |
+ (((Uint32 << Configure->PixelShl[1]) >> Configure->PixelShr[1]) &
+ Configure->PixelMasks.GreenMask) |
+ (((Uint32 << Configure->PixelShl[2]) >> Configure->PixelShr[2]) &
+ Configure->PixelMasks.BlueMask)
+ );
}
+
Source = Configure->LineBuffer;
}
@@ -550,20 +570,20 @@ FrameBufferBltLibBufferToVideo ( **/
RETURN_STATUS
FrameBufferBltLibVideoToVideo (
- IN FRAME_BUFFER_CONFIGURE *Configure,
- IN UINTN SourceX,
- IN UINTN SourceY,
- IN UINTN DestinationX,
- IN UINTN DestinationY,
- IN UINTN Width,
- IN UINTN Height
+ IN FRAME_BUFFER_CONFIGURE *Configure,
+ IN UINTN SourceX,
+ IN UINTN SourceY,
+ IN UINTN DestinationX,
+ IN UINTN DestinationY,
+ IN UINTN Width,
+ IN UINTN Height
)
{
- UINT8 *Source;
- UINT8 *Destination;
- UINTN Offset;
- UINTN WidthInBytes;
- INTN LineStride;
+ UINT8 *Source;
+ UINT8 *Destination;
+ UINTN Offset;
+ UINTN WidthInBytes;
+ INTN LineStride;
//
// Video to Video: Source is Video, destination is Video
@@ -584,7 +604,7 @@ FrameBufferBltLibVideoToVideo ( return RETURN_INVALID_PARAMETER;
}
- if (Width == 0 || Height == 0) {
+ if ((Width == 0) || (Height == 0)) {
return RETURN_INVALID_PARAMETER;
}
@@ -594,8 +614,8 @@ FrameBufferBltLibVideoToVideo ( Offset = Configure->BytesPerPixel * Offset;
Source = Configure->FrameBuffer + Offset;
- Offset = (DestinationY * Configure->PixelsPerScanLine) + DestinationX;
- Offset = Configure->BytesPerPixel * Offset;
+ Offset = (DestinationY * Configure->PixelsPerScanLine) + DestinationX;
+ Offset = Configure->BytesPerPixel * Offset;
Destination = Configure->FrameBuffer + Offset;
LineStride = Configure->BytesPerPixel * Configure->PixelsPerScanLine;
@@ -603,15 +623,15 @@ FrameBufferBltLibVideoToVideo ( //
// Copy from last line to avoid source is corrupted by copying
//
- Source += Height * LineStride;
+ Source += Height * LineStride;
Destination += Height * LineStride;
- LineStride = -LineStride;
+ LineStride = -LineStride;
}
while (Height-- > 0) {
CopyMem (Destination, Source, WidthInBytes);
- Source += LineStride;
+ Source += LineStride;
Destination += LineStride;
}
@@ -648,16 +668,16 @@ FrameBufferBltLibVideoToVideo ( RETURN_STATUS
EFIAPI
FrameBufferBlt (
- IN FRAME_BUFFER_CONFIGURE *Configure,
- IN OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer OPTIONAL,
- IN EFI_GRAPHICS_OUTPUT_BLT_OPERATION BltOperation,
- IN UINTN SourceX,
- IN UINTN SourceY,
- IN UINTN DestinationX,
- IN UINTN DestinationY,
- IN UINTN Width,
- IN UINTN Height,
- IN UINTN Delta
+ IN FRAME_BUFFER_CONFIGURE *Configure,
+ IN OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer OPTIONAL,
+ IN EFI_GRAPHICS_OUTPUT_BLT_OPERATION BltOperation,
+ IN UINTN SourceX,
+ IN UINTN SourceY,
+ IN UINTN DestinationX,
+ IN UINTN DestinationY,
+ IN UINTN Width,
+ IN UINTN Height,
+ IN UINTN Delta
)
{
if (Configure == NULL) {
@@ -665,54 +685,54 @@ FrameBufferBlt ( }
switch (BltOperation) {
- case EfiBltVideoToBltBuffer:
- return FrameBufferBltLibVideoToBltBuffer (
- Configure,
- BltBuffer,
- SourceX,
- SourceY,
- DestinationX,
- DestinationY,
- Width,
- Height,
- Delta
- );
-
- case EfiBltVideoToVideo:
- return FrameBufferBltLibVideoToVideo (
- Configure,
- SourceX,
- SourceY,
- DestinationX,
- DestinationY,
- Width,
- Height
- );
-
- case EfiBltVideoFill:
- return FrameBufferBltLibVideoFill (
- Configure,
- BltBuffer,
- DestinationX,
- DestinationY,
- Width,
- Height
- );
-
- case EfiBltBufferToVideo:
- return FrameBufferBltLibBufferToVideo (
- Configure,
- BltBuffer,
- SourceX,
- SourceY,
- DestinationX,
- DestinationY,
- Width,
- Height,
- Delta
- );
-
- default:
- return RETURN_INVALID_PARAMETER;
+ case EfiBltVideoToBltBuffer:
+ return FrameBufferBltLibVideoToBltBuffer (
+ Configure,
+ BltBuffer,
+ SourceX,
+ SourceY,
+ DestinationX,
+ DestinationY,
+ Width,
+ Height,
+ Delta
+ );
+
+ case EfiBltVideoToVideo:
+ return FrameBufferBltLibVideoToVideo (
+ Configure,
+ SourceX,
+ SourceY,
+ DestinationX,
+ DestinationY,
+ Width,
+ Height
+ );
+
+ case EfiBltVideoFill:
+ return FrameBufferBltLibVideoFill (
+ Configure,
+ BltBuffer,
+ DestinationX,
+ DestinationY,
+ Width,
+ Height
+ );
+
+ case EfiBltBufferToVideo:
+ return FrameBufferBltLibBufferToVideo (
+ Configure,
+ BltBuffer,
+ SourceX,
+ SourceY,
+ DestinationX,
+ DestinationY,
+ Width,
+ Height,
+ Delta
+ );
+
+ default:
+ return RETURN_INVALID_PARAMETER;
}
}
diff --git a/MdeModulePkg/Library/LockBoxNullLib/LockBoxNullLib.c b/MdeModulePkg/Library/LockBoxNullLib/LockBoxNullLib.c index 41d2972b34..4ce45ae409 100644 --- a/MdeModulePkg/Library/LockBoxNullLib/LockBoxNullLib.c +++ b/MdeModulePkg/Library/LockBoxNullLib/LockBoxNullLib.c @@ -27,9 +27,9 @@ SPDX-License-Identifier: BSD-2-Clause-Patent RETURN_STATUS
EFIAPI
SaveLockBox (
- IN GUID *Guid,
- IN VOID *Buffer,
- IN UINTN Length
+ IN GUID *Guid,
+ IN VOID *Buffer,
+ IN UINTN Length
)
{
return RETURN_SUCCESS;
@@ -51,8 +51,8 @@ SaveLockBox ( RETURN_STATUS
EFIAPI
SetLockBoxAttributes (
- IN GUID *Guid,
- IN UINT64 Attributes
+ IN GUID *Guid,
+ IN UINT64 Attributes
)
{
return RETURN_SUCCESS;
@@ -80,10 +80,10 @@ SetLockBoxAttributes ( RETURN_STATUS
EFIAPI
UpdateLockBox (
- IN GUID *Guid,
- IN UINTN Offset,
- IN VOID *Buffer,
- IN UINTN Length
+ IN GUID *Guid,
+ IN UINTN Offset,
+ IN VOID *Buffer,
+ IN UINTN Length
)
{
return RETURN_SUCCESS;
@@ -110,9 +110,9 @@ UpdateLockBox ( RETURN_STATUS
EFIAPI
RestoreLockBox (
- IN GUID *Guid,
- IN VOID *Buffer OPTIONAL,
- IN OUT UINTN *Length OPTIONAL
+ IN GUID *Guid,
+ IN VOID *Buffer OPTIONAL,
+ IN OUT UINTN *Length OPTIONAL
)
{
return RETURN_SUCCESS;
diff --git a/MdeModulePkg/Library/LzmaCustomDecompressLib/F86GuidedSectionExtraction.c b/MdeModulePkg/Library/LzmaCustomDecompressLib/F86GuidedSectionExtraction.c index fefe02033f..70cfae5660 100644 --- a/MdeModulePkg/Library/LzmaCustomDecompressLib/F86GuidedSectionExtraction.c +++ b/MdeModulePkg/Library/LzmaCustomDecompressLib/F86GuidedSectionExtraction.c @@ -61,31 +61,35 @@ LzmaArchGuidedSectionGetInfo ( if (IS_SECTION2 (InputSection)) {
if (!CompareGuid (
- &gLzmaF86CustomDecompressGuid,
- &(((EFI_GUID_DEFINED_SECTION2 *) InputSection)->SectionDefinitionGuid))) {
+ &gLzmaF86CustomDecompressGuid,
+ &(((EFI_GUID_DEFINED_SECTION2 *)InputSection)->SectionDefinitionGuid)
+ ))
+ {
return RETURN_INVALID_PARAMETER;
}
- *SectionAttribute = ((EFI_GUID_DEFINED_SECTION2 *) InputSection)->Attributes;
+ *SectionAttribute = ((EFI_GUID_DEFINED_SECTION2 *)InputSection)->Attributes;
return LzmaUefiDecompressGetInfo (
- (UINT8 *) InputSection + ((EFI_GUID_DEFINED_SECTION2 *) InputSection)->DataOffset,
- SECTION2_SIZE (InputSection) - ((EFI_GUID_DEFINED_SECTION2 *) InputSection)->DataOffset,
+ (UINT8 *)InputSection + ((EFI_GUID_DEFINED_SECTION2 *)InputSection)->DataOffset,
+ SECTION2_SIZE (InputSection) - ((EFI_GUID_DEFINED_SECTION2 *)InputSection)->DataOffset,
OutputBufferSize,
ScratchBufferSize
);
} else {
if (!CompareGuid (
- &gLzmaF86CustomDecompressGuid,
- &(((EFI_GUID_DEFINED_SECTION *) InputSection)->SectionDefinitionGuid))) {
+ &gLzmaF86CustomDecompressGuid,
+ &(((EFI_GUID_DEFINED_SECTION *)InputSection)->SectionDefinitionGuid)
+ ))
+ {
return RETURN_INVALID_PARAMETER;
}
- *SectionAttribute = ((EFI_GUID_DEFINED_SECTION *) InputSection)->Attributes;
+ *SectionAttribute = ((EFI_GUID_DEFINED_SECTION *)InputSection)->Attributes;
return LzmaUefiDecompressGetInfo (
- (UINT8 *) InputSection + ((EFI_GUID_DEFINED_SECTION *) InputSection)->DataOffset,
- SECTION_SIZE (InputSection) - ((EFI_GUID_DEFINED_SECTION *) InputSection)->DataOffset,
+ (UINT8 *)InputSection + ((EFI_GUID_DEFINED_SECTION *)InputSection)->DataOffset,
+ SECTION_SIZE (InputSection) - ((EFI_GUID_DEFINED_SECTION *)InputSection)->DataOffset,
OutputBufferSize,
ScratchBufferSize
);
@@ -134,25 +138,25 @@ LzmaArchGuidedSectionExtraction ( OUT UINT32 *AuthenticationStatus
)
{
- EFI_GUID *InputGuid;
- VOID *Source;
- UINTN SourceSize;
- EFI_STATUS Status;
- UINT32 X86State;
- UINT32 OutputBufferSize;
- UINT32 ScratchBufferSize;
+ EFI_GUID *InputGuid;
+ VOID *Source;
+ UINTN SourceSize;
+ EFI_STATUS Status;
+ UINT32 X86State;
+ UINT32 OutputBufferSize;
+ UINT32 ScratchBufferSize;
ASSERT (OutputBuffer != NULL);
ASSERT (InputSection != NULL);
if (IS_SECTION2 (InputSection)) {
- InputGuid = &(((EFI_GUID_DEFINED_SECTION2 *) InputSection)->SectionDefinitionGuid);
- Source = (UINT8 *) InputSection + ((EFI_GUID_DEFINED_SECTION2 *) InputSection)->DataOffset;
- SourceSize = SECTION2_SIZE (InputSection) - ((EFI_GUID_DEFINED_SECTION2 *) InputSection)->DataOffset;
+ InputGuid = &(((EFI_GUID_DEFINED_SECTION2 *)InputSection)->SectionDefinitionGuid);
+ Source = (UINT8 *)InputSection + ((EFI_GUID_DEFINED_SECTION2 *)InputSection)->DataOffset;
+ SourceSize = SECTION2_SIZE (InputSection) - ((EFI_GUID_DEFINED_SECTION2 *)InputSection)->DataOffset;
} else {
- InputGuid = &(((EFI_GUID_DEFINED_SECTION *) InputSection)->SectionDefinitionGuid);
- Source = (UINT8 *) InputSection + ((EFI_GUID_DEFINED_SECTION *) InputSection)->DataOffset;
- SourceSize = SECTION_SIZE (InputSection) - ((EFI_GUID_DEFINED_SECTION *) InputSection)->DataOffset;
+ InputGuid = &(((EFI_GUID_DEFINED_SECTION *)InputSection)->SectionDefinitionGuid);
+ Source = (UINT8 *)InputSection + ((EFI_GUID_DEFINED_SECTION *)InputSection)->DataOffset;
+ SourceSize = SECTION_SIZE (InputSection) - ((EFI_GUID_DEFINED_SECTION *)InputSection)->DataOffset;
}
if (!CompareGuid (&gLzmaF86CustomDecompressGuid, InputGuid)) {
@@ -165,33 +169,32 @@ LzmaArchGuidedSectionExtraction ( *AuthenticationStatus = 0;
Status = LzmaUefiDecompress (
- Source,
- SourceSize,
- *OutputBuffer,
- ScratchBuffer
- );
+ Source,
+ SourceSize,
+ *OutputBuffer,
+ ScratchBuffer
+ );
//
// After decompress, the data need to be converted to the raw data.
//
if (!EFI_ERROR (Status)) {
Status = LzmaUefiDecompressGetInfo (
- Source,
- (UINT32) SourceSize,
- &OutputBufferSize,
- &ScratchBufferSize
- );
+ Source,
+ (UINT32)SourceSize,
+ &OutputBufferSize,
+ &ScratchBufferSize
+ );
if (!EFI_ERROR (Status)) {
- x86_Convert_Init(X86State);
- x86_Convert(*OutputBuffer, OutputBufferSize, 0, &X86State, 0);
+ x86_Convert_Init (X86State);
+ x86_Convert (*OutputBuffer, OutputBufferSize, 0, &X86State, 0);
}
}
return Status;
}
-
/**
Register LzmaArchDecompress and LzmaArchDecompressGetInfo handlers with LzmaF86CustomDecompressGuid.
@@ -205,8 +208,8 @@ LzmaArchDecompressLibConstructor ( )
{
return ExtractGuidedSectionRegisterHandlers (
- &gLzmaF86CustomDecompressGuid,
- LzmaArchGuidedSectionGetInfo,
- LzmaArchGuidedSectionExtraction
- );
+ &gLzmaF86CustomDecompressGuid,
+ LzmaArchGuidedSectionGetInfo,
+ LzmaArchGuidedSectionExtraction
+ );
}
diff --git a/MdeModulePkg/Library/LzmaCustomDecompressLib/GuidedSectionExtraction.c b/MdeModulePkg/Library/LzmaCustomDecompressLib/GuidedSectionExtraction.c index 4d89836d0c..cace79e32b 100644 --- a/MdeModulePkg/Library/LzmaCustomDecompressLib/GuidedSectionExtraction.c +++ b/MdeModulePkg/Library/LzmaCustomDecompressLib/GuidedSectionExtraction.c @@ -59,31 +59,35 @@ LzmaGuidedSectionGetInfo ( if (IS_SECTION2 (InputSection)) {
if (!CompareGuid (
- &gLzmaCustomDecompressGuid,
- &(((EFI_GUID_DEFINED_SECTION2 *) InputSection)->SectionDefinitionGuid))) {
+ &gLzmaCustomDecompressGuid,
+ &(((EFI_GUID_DEFINED_SECTION2 *)InputSection)->SectionDefinitionGuid)
+ ))
+ {
return RETURN_INVALID_PARAMETER;
}
- *SectionAttribute = ((EFI_GUID_DEFINED_SECTION2 *) InputSection)->Attributes;
+ *SectionAttribute = ((EFI_GUID_DEFINED_SECTION2 *)InputSection)->Attributes;
return LzmaUefiDecompressGetInfo (
- (UINT8 *) InputSection + ((EFI_GUID_DEFINED_SECTION2 *) InputSection)->DataOffset,
- SECTION2_SIZE (InputSection) - ((EFI_GUID_DEFINED_SECTION2 *) InputSection)->DataOffset,
+ (UINT8 *)InputSection + ((EFI_GUID_DEFINED_SECTION2 *)InputSection)->DataOffset,
+ SECTION2_SIZE (InputSection) - ((EFI_GUID_DEFINED_SECTION2 *)InputSection)->DataOffset,
OutputBufferSize,
ScratchBufferSize
);
} else {
if (!CompareGuid (
- &gLzmaCustomDecompressGuid,
- &(((EFI_GUID_DEFINED_SECTION *) InputSection)->SectionDefinitionGuid))) {
+ &gLzmaCustomDecompressGuid,
+ &(((EFI_GUID_DEFINED_SECTION *)InputSection)->SectionDefinitionGuid)
+ ))
+ {
return RETURN_INVALID_PARAMETER;
}
- *SectionAttribute = ((EFI_GUID_DEFINED_SECTION *) InputSection)->Attributes;
+ *SectionAttribute = ((EFI_GUID_DEFINED_SECTION *)InputSection)->Attributes;
return LzmaUefiDecompressGetInfo (
- (UINT8 *) InputSection + ((EFI_GUID_DEFINED_SECTION *) InputSection)->DataOffset,
- SECTION_SIZE (InputSection) - ((EFI_GUID_DEFINED_SECTION *) InputSection)->DataOffset,
+ (UINT8 *)InputSection + ((EFI_GUID_DEFINED_SECTION *)InputSection)->DataOffset,
+ SECTION_SIZE (InputSection) - ((EFI_GUID_DEFINED_SECTION *)InputSection)->DataOffset,
OutputBufferSize,
ScratchBufferSize
);
@@ -137,8 +141,10 @@ LzmaGuidedSectionExtraction ( if (IS_SECTION2 (InputSection)) {
if (!CompareGuid (
- &gLzmaCustomDecompressGuid,
- &(((EFI_GUID_DEFINED_SECTION2 *) InputSection)->SectionDefinitionGuid))) {
+ &gLzmaCustomDecompressGuid,
+ &(((EFI_GUID_DEFINED_SECTION2 *)InputSection)->SectionDefinitionGuid)
+ ))
+ {
return RETURN_INVALID_PARAMETER;
}
@@ -148,15 +154,17 @@ LzmaGuidedSectionExtraction ( *AuthenticationStatus = 0;
return LzmaUefiDecompress (
- (UINT8 *) InputSection + ((EFI_GUID_DEFINED_SECTION2 *) InputSection)->DataOffset,
- SECTION2_SIZE (InputSection) - ((EFI_GUID_DEFINED_SECTION2 *) InputSection)->DataOffset,
+ (UINT8 *)InputSection + ((EFI_GUID_DEFINED_SECTION2 *)InputSection)->DataOffset,
+ SECTION2_SIZE (InputSection) - ((EFI_GUID_DEFINED_SECTION2 *)InputSection)->DataOffset,
*OutputBuffer,
ScratchBuffer
);
} else {
if (!CompareGuid (
- &gLzmaCustomDecompressGuid,
- &(((EFI_GUID_DEFINED_SECTION *) InputSection)->SectionDefinitionGuid))) {
+ &gLzmaCustomDecompressGuid,
+ &(((EFI_GUID_DEFINED_SECTION *)InputSection)->SectionDefinitionGuid)
+ ))
+ {
return RETURN_INVALID_PARAMETER;
}
@@ -166,15 +174,14 @@ LzmaGuidedSectionExtraction ( *AuthenticationStatus = 0;
return LzmaUefiDecompress (
- (UINT8 *) InputSection + ((EFI_GUID_DEFINED_SECTION *) InputSection)->DataOffset,
- SECTION_SIZE (InputSection) - ((EFI_GUID_DEFINED_SECTION *) InputSection)->DataOffset,
+ (UINT8 *)InputSection + ((EFI_GUID_DEFINED_SECTION *)InputSection)->DataOffset,
+ SECTION_SIZE (InputSection) - ((EFI_GUID_DEFINED_SECTION *)InputSection)->DataOffset,
*OutputBuffer,
ScratchBuffer
- );
+ );
}
}
-
/**
Register LzmaDecompress and LzmaDecompressGetInfo handlers with LzmaCustomerDecompressGuid.
@@ -188,8 +195,8 @@ LzmaDecompressLibConstructor ( )
{
return ExtractGuidedSectionRegisterHandlers (
- &gLzmaCustomDecompressGuid,
- LzmaGuidedSectionGetInfo,
- LzmaGuidedSectionExtraction
- );
+ &gLzmaCustomDecompressGuid,
+ LzmaGuidedSectionGetInfo,
+ LzmaGuidedSectionExtraction
+ );
}
diff --git a/MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaDecompress.c b/MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaDecompress.c index 8f7c242dca..18577acf38 100644 --- a/MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaDecompress.c +++ b/MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaDecompress.c @@ -11,13 +11,12 @@ #include "Sdk/C/7zVersion.h"
#include "Sdk/C/LzmaDec.h"
-#define SCRATCH_BUFFER_REQUEST_SIZE SIZE_64KB
+#define SCRATCH_BUFFER_REQUEST_SIZE SIZE_64KB
-typedef struct
-{
- ISzAlloc Functions;
- VOID *Buffer;
- UINTN BufferSize;
+typedef struct {
+ ISzAlloc Functions;
+ VOID *Buffer;
+ UINTN BufferSize;
} ISzAllocWithData;
/**
@@ -30,18 +29,18 @@ typedef struct **/
VOID *
SzAlloc (
- CONST ISzAlloc *P,
- size_t Size
+ CONST ISzAlloc *P,
+ size_t Size
)
{
- VOID *Addr;
- ISzAllocWithData *Private;
+ VOID *Addr;
+ ISzAllocWithData *Private;
- Private = (ISzAllocWithData*) P;
+ Private = (ISzAllocWithData *)P;
if (Private->BufferSize >= Size) {
- Addr = Private->Buffer;
- Private->Buffer = (VOID*) ((UINT8*)Addr + Size);
+ Addr = Private->Buffer;
+ Private->Buffer = (VOID *)((UINT8 *)Addr + Size);
Private->BufferSize -= Size;
return Addr;
} else {
@@ -58,8 +57,8 @@ SzAlloc ( **/
VOID
SzFree (
- CONST ISzAlloc *P,
- VOID *Address
+ CONST ISzAlloc *P,
+ VOID *Address
)
{
//
@@ -69,7 +68,7 @@ SzFree ( //
}
-#define LZMA_HEADER_SIZE (LZMA_PROPS_SIZE + 8)
+#define LZMA_HEADER_SIZE (LZMA_PROPS_SIZE + 8)
/**
Get the size of the uncompressed buffer by parsing EncodeData header.
@@ -79,17 +78,18 @@ SzFree ( @return The size of the uncompressed buffer.
**/
UINT64
-GetDecodedSizeOfBuf(
- UINT8 *EncodedData
+GetDecodedSizeOfBuf (
+ UINT8 *EncodedData
)
{
- UINT64 DecodedSize;
- INTN Index;
+ UINT64 DecodedSize;
+ INTN Index;
/* Parse header */
DecodedSize = 0;
- for (Index = LZMA_PROPS_SIZE + 7; Index >= LZMA_PROPS_SIZE; Index--)
- DecodedSize = LShiftU64(DecodedSize, 8) + EncodedData[Index];
+ for (Index = LZMA_PROPS_SIZE + 7; Index >= LZMA_PROPS_SIZE; Index--) {
+ DecodedSize = LShiftU64 (DecodedSize, 8) + EncodedData[Index];
+ }
return DecodedSize;
}
@@ -143,15 +143,15 @@ LzmaUefiDecompressGetInfo ( {
UInt64 DecodedSize;
- ASSERT(SourceSize >= LZMA_HEADER_SIZE);
+ ASSERT (SourceSize >= LZMA_HEADER_SIZE);
- DecodedSize = GetDecodedSizeOfBuf((UINT8*)Source);
+ DecodedSize = GetDecodedSizeOfBuf ((UINT8 *)Source);
if (DecodedSize > MAX_UINT32) {
return RETURN_UNSUPPORTED;
}
*DestinationSize = (UINT32)DecodedSize;
- *ScratchSize = SCRATCH_BUFFER_REQUEST_SIZE;
+ *ScratchSize = SCRATCH_BUFFER_REQUEST_SIZE;
return RETURN_SUCCESS;
}
@@ -192,25 +192,25 @@ LzmaUefiDecompress ( SizeT EncodedDataSize;
ISzAllocWithData AllocFuncs;
- AllocFuncs.Functions.Alloc = SzAlloc;
- AllocFuncs.Functions.Free = SzFree;
- AllocFuncs.Buffer = Scratch;
- AllocFuncs.BufferSize = SCRATCH_BUFFER_REQUEST_SIZE;
-
- DecodedBufSize = (SizeT)GetDecodedSizeOfBuf((UINT8*)Source);
- EncodedDataSize = (SizeT) (SourceSize - LZMA_HEADER_SIZE);
-
- LzmaResult = LzmaDecode(
- Destination,
- &DecodedBufSize,
- (Byte*)((UINT8*)Source + LZMA_HEADER_SIZE),
- &EncodedDataSize,
- Source,
- LZMA_PROPS_SIZE,
- LZMA_FINISH_END,
- &Status,
- &(AllocFuncs.Functions)
- );
+ AllocFuncs.Functions.Alloc = SzAlloc;
+ AllocFuncs.Functions.Free = SzFree;
+ AllocFuncs.Buffer = Scratch;
+ AllocFuncs.BufferSize = SCRATCH_BUFFER_REQUEST_SIZE;
+
+ DecodedBufSize = (SizeT)GetDecodedSizeOfBuf ((UINT8 *)Source);
+ EncodedDataSize = (SizeT)(SourceSize - LZMA_HEADER_SIZE);
+
+ LzmaResult = LzmaDecode (
+ Destination,
+ &DecodedBufSize,
+ (Byte *)((UINT8 *)Source + LZMA_HEADER_SIZE),
+ &EncodedDataSize,
+ Source,
+ LZMA_PROPS_SIZE,
+ LZMA_FINISH_END,
+ &Status,
+ &(AllocFuncs.Functions)
+ );
if (LzmaResult == SZ_OK) {
return RETURN_SUCCESS;
@@ -218,4 +218,3 @@ LzmaUefiDecompress ( return RETURN_INVALID_PARAMETER;
}
}
-
diff --git a/MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaDecompressLibInternal.h b/MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaDecompressLibInternal.h index fbafd5f100..1dc54eb930 100644 --- a/MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaDecompressLibInternal.h +++ b/MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaDecompressLibInternal.h @@ -92,4 +92,3 @@ LzmaUefiDecompress ( );
#endif
-
diff --git a/MdeModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/7zTypes.h b/MdeModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/7zTypes.h index 42b7040dd7..502a32e4da 100644 --- a/MdeModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/7zTypes.h +++ b/MdeModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/7zTypes.h @@ -9,73 +9,71 @@ #endif
#ifdef EFIAPI
-#include "UefiLzma.h"
+ #include "UefiLzma.h"
#else
-#include <stddef.h>
+ #include <stddef.h>
#endif
#ifndef EXTERN_C_BEGIN
-#ifdef __cplusplus
-#define EXTERN_C_BEGIN extern "C" {
-#define EXTERN_C_END }
-#else
+ #ifdef __cplusplus
+#define EXTERN_C_BEGIN extern "C" {
+#define EXTERN_C_END }
+ #else
#define EXTERN_C_BEGIN
#define EXTERN_C_END
-#endif
+ #endif
#endif
EXTERN_C_BEGIN
-#define SZ_OK 0
+#define SZ_OK 0
-#define SZ_ERROR_DATA 1
-#define SZ_ERROR_MEM 2
-#define SZ_ERROR_CRC 3
-#define SZ_ERROR_UNSUPPORTED 4
-#define SZ_ERROR_PARAM 5
-#define SZ_ERROR_INPUT_EOF 6
-#define SZ_ERROR_OUTPUT_EOF 7
-#define SZ_ERROR_READ 8
-#define SZ_ERROR_WRITE 9
-#define SZ_ERROR_PROGRESS 10
-#define SZ_ERROR_FAIL 11
-#define SZ_ERROR_THREAD 12
+#define SZ_ERROR_DATA 1
+#define SZ_ERROR_MEM 2
+#define SZ_ERROR_CRC 3
+#define SZ_ERROR_UNSUPPORTED 4
+#define SZ_ERROR_PARAM 5
+#define SZ_ERROR_INPUT_EOF 6
+#define SZ_ERROR_OUTPUT_EOF 7
+#define SZ_ERROR_READ 8
+#define SZ_ERROR_WRITE 9
+#define SZ_ERROR_PROGRESS 10
+#define SZ_ERROR_FAIL 11
+#define SZ_ERROR_THREAD 12
-#define SZ_ERROR_ARCHIVE 16
-#define SZ_ERROR_NO_ARCHIVE 17
+#define SZ_ERROR_ARCHIVE 16
+#define SZ_ERROR_NO_ARCHIVE 17
typedef int SRes;
-
#ifdef _WIN32
/* typedef DWORD WRes; */
typedef unsigned WRes;
-#define MY_SRes_HRESULT_FROM_WRes(x) HRESULT_FROM_WIN32(x)
+#define MY_SRes_HRESULT_FROM_WRes(x) HRESULT_FROM_WIN32(x)
#else
typedef int WRes;
-#define MY__FACILITY_WIN32 7
-#define MY__FACILITY__WRes MY__FACILITY_WIN32
-#define MY_SRes_HRESULT_FROM_WRes(x) ((HRESULT)(x) <= 0 ? ((HRESULT)(x)) : ((HRESULT) (((x) & 0x0000FFFF) | (MY__FACILITY__WRes << 16) | 0x80000000)))
+#define MY__FACILITY_WIN32 7
+#define MY__FACILITY__WRes MY__FACILITY_WIN32
+#define MY_SRes_HRESULT_FROM_WRes(x) ((HRESULT)(x) <= 0 ? ((HRESULT)(x)) : ((HRESULT) (((x) & 0x0000FFFF) | (MY__FACILITY__WRes << 16) | 0x80000000)))
#endif
-
#ifndef RINOK
-#define RINOK(x) { int __result__ = (x); if (__result__ != 0) return __result__; }
+#define RINOK(x) { int __result__ = (x); if (__result__ != 0) return __result__; }
#endif
-typedef unsigned char Byte;
-typedef short Int16;
+typedef unsigned char Byte;
+typedef short Int16;
typedef unsigned short UInt16;
#ifdef _LZMA_UINT32_IS_ULONG
-typedef long Int32;
+typedef long Int32;
typedef unsigned long UInt32;
#else
-typedef int Int32;
+typedef int Int32;
typedef unsigned int UInt32;
#endif
@@ -84,20 +82,20 @@ typedef unsigned int UInt32; /* define _SZ_NO_INT_64, if your compiler doesn't support 64-bit integers.
NOTES: Some code will work incorrectly in that case! */
-typedef long Int64;
+typedef long Int64;
typedef unsigned long UInt64;
#else
-#if defined(_MSC_VER) || defined(__BORLANDC__)
-typedef __int64 Int64;
+ #if defined (_MSC_VER) || defined (__BORLANDC__)
+typedef __int64 Int64;
typedef unsigned __int64 UInt64;
-#define UINT64_CONST(n) n
-#else
-typedef long long int Int64;
+#define UINT64_CONST(n) n
+ #else
+typedef long long int Int64;
typedef unsigned long long int UInt64;
-#define UINT64_CONST(n) n ## ULL
-#endif
+#define UINT64_CONST(n) n ## ULL
+ #endif
#endif
@@ -109,28 +107,27 @@ typedef size_t SizeT; typedef int BoolInt;
/* typedef BoolInt Bool; */
-#define True 1
-#define False 0
-
+#define True 1
+#define False 0
#ifdef _WIN32
-#define MY_STD_CALL __stdcall
+#define MY_STD_CALL __stdcall
#else
#define MY_STD_CALL
#endif
-#if defined(_MSC_VER) && !defined(__clang__)
+#if defined (_MSC_VER) && !defined (__clang__)
-#if _MSC_VER >= 1300
-#define MY_NO_INLINE __declspec(noinline)
-#else
+ #if _MSC_VER >= 1300
+#define MY_NO_INLINE __declspec(noinline)
+ #else
#define MY_NO_INLINE
-#endif
+ #endif
-#define MY_FORCE_INLINE __forceinline
+#define MY_FORCE_INLINE __forceinline
-#define MY_CDECL __cdecl
-#define MY_FAST_CALL __fastcall
+#define MY_CDECL __cdecl
+#define MY_FAST_CALL __fastcall
#else
@@ -142,6 +139,7 @@ typedef int BoolInt; /* inline keyword : for C++ / C99 */
/* GCC, clang: */
+
/*
#if defined (__GNUC__) && (__GNUC__ >= 4)
#define MY_FORCE_INLINE __attribute__((always_inline))
@@ -151,179 +149,252 @@ typedef int BoolInt; #endif
-
/* The following interfaces use first parameter as pointer to structure */
typedef struct IByteIn IByteIn;
-struct IByteIn
-{
- Byte (*Read)(const IByteIn *p); /* reads one byte, returns 0 in case of EOF or error */
+struct IByteIn {
+ Byte (*Read)(
+ const IByteIn *p
+ ); /* reads one byte, returns 0 in case of EOF or error */
};
-#define IByteIn_Read(p) (p)->Read(p)
+#define IByteIn_Read(p) (p)->Read(p)
typedef struct IByteOut IByteOut;
-struct IByteOut
-{
- void (*Write)(const IByteOut *p, Byte b);
+struct IByteOut {
+ void (*Write)(
+ const IByteOut *p,
+ Byte b
+ );
};
-#define IByteOut_Write(p, b) (p)->Write(p, b)
+#define IByteOut_Write(p, b) (p)->Write(p, b)
typedef struct ISeqInStream ISeqInStream;
-struct ISeqInStream
-{
- SRes (*Read)(const ISeqInStream *p, void *buf, size_t *size);
- /* if (input(*size) != 0 && output(*size) == 0) means end_of_stream.
- (output(*size) < input(*size)) is allowed */
+struct ISeqInStream {
+ SRes (*Read)(
+ const ISeqInStream *p,
+ void *buf,
+ size_t *size
+ );
+
+ /* if (input(*size) != 0 && output(*size) == 0) means end_of_stream.
+ (output(*size) < input(*size)) is allowed */
};
-#define ISeqInStream_Read(p, buf, size) (p)->Read(p, buf, size)
-/* it can return SZ_ERROR_INPUT_EOF */
-SRes SeqInStream_Read(const ISeqInStream *stream, void *buf, size_t size);
-SRes SeqInStream_Read2(const ISeqInStream *stream, void *buf, size_t size, SRes errorType);
-SRes SeqInStream_ReadByte(const ISeqInStream *stream, Byte *buf);
+#define ISeqInStream_Read(p, buf, size) (p)->Read(p, buf, size)
+/* it can return SZ_ERROR_INPUT_EOF */
+SRes
+SeqInStream_Read (
+ const ISeqInStream *stream,
+ void *buf,
+ size_t size
+ );
+
+SRes
+SeqInStream_Read2 (
+ const ISeqInStream *stream,
+ void *buf,
+ size_t size,
+ SRes errorType
+ );
+
+SRes
+SeqInStream_ReadByte (
+ const ISeqInStream *stream,
+ Byte *buf
+ );
typedef struct ISeqOutStream ISeqOutStream;
-struct ISeqOutStream
-{
- size_t (*Write)(const ISeqOutStream *p, const void *buf, size_t size);
- /* Returns: result - the number of actually written bytes.
- (result < size) means error */
+struct ISeqOutStream {
+ size_t (*Write)(
+ const ISeqOutStream *p,
+ const void *buf,
+ size_t size
+ );
+
+ /* Returns: result - the number of actually written bytes.
+ (result < size) means error */
};
-#define ISeqOutStream_Write(p, buf, size) (p)->Write(p, buf, size)
-typedef enum
-{
+#define ISeqOutStream_Write(p, buf, size) (p)->Write(p, buf, size)
+
+typedef enum {
SZ_SEEK_SET = 0,
SZ_SEEK_CUR = 1,
SZ_SEEK_END = 2
} ESzSeek;
-
typedef struct ISeekInStream ISeekInStream;
-struct ISeekInStream
-{
- SRes (*Read)(const ISeekInStream *p, void *buf, size_t *size); /* same as ISeqInStream::Read */
- SRes (*Seek)(const ISeekInStream *p, Int64 *pos, ESzSeek origin);
+struct ISeekInStream {
+ SRes (*Read)(
+ const ISeekInStream *p,
+ void *buf,
+ size_t *size
+ ); /* same as ISeqInStream::Read */
+ SRes (*Seek)(
+ const ISeekInStream *p,
+ Int64 *pos,
+ ESzSeek origin
+ );
};
-#define ISeekInStream_Read(p, buf, size) (p)->Read(p, buf, size)
-#define ISeekInStream_Seek(p, pos, origin) (p)->Seek(p, pos, origin)
+#define ISeekInStream_Read(p, buf, size) (p)->Read(p, buf, size)
+#define ISeekInStream_Seek(p, pos, origin) (p)->Seek(p, pos, origin)
typedef struct ILookInStream ILookInStream;
-struct ILookInStream
-{
- SRes (*Look)(const ILookInStream *p, const void **buf, size_t *size);
- /* if (input(*size) != 0 && output(*size) == 0) means end_of_stream.
- (output(*size) > input(*size)) is not allowed
- (output(*size) < input(*size)) is allowed */
- SRes (*Skip)(const ILookInStream *p, size_t offset);
- /* offset must be <= output(*size) of Look */
-
- SRes (*Read)(const ILookInStream *p, void *buf, size_t *size);
- /* reads directly (without buffer). It's same as ISeqInStream::Read */
- SRes (*Seek)(const ILookInStream *p, Int64 *pos, ESzSeek origin);
+struct ILookInStream {
+ SRes (*Look)(
+ const ILookInStream *p,
+ const void **buf,
+ size_t *size
+ );
+
+ /* if (input(*size) != 0 && output(*size) == 0) means end_of_stream.
+ (output(*size) > input(*size)) is not allowed
+ (output(*size) < input(*size)) is allowed */
+ SRes (*Skip)(
+ const ILookInStream *p,
+ size_t offset
+ );
+ /* offset must be <= output(*size) of Look */
+
+ SRes (*Read)(
+ const ILookInStream *p,
+ void *buf,
+ size_t *size
+ );
+ /* reads directly (without buffer). It's same as ISeqInStream::Read */
+ SRes (*Seek)(
+ const ILookInStream *p,
+ Int64 *pos,
+ ESzSeek origin
+ );
};
-#define ILookInStream_Look(p, buf, size) (p)->Look(p, buf, size)
-#define ILookInStream_Skip(p, offset) (p)->Skip(p, offset)
-#define ILookInStream_Read(p, buf, size) (p)->Read(p, buf, size)
-#define ILookInStream_Seek(p, pos, origin) (p)->Seek(p, pos, origin)
+#define ILookInStream_Look(p, buf, size) (p)->Look(p, buf, size)
+#define ILookInStream_Skip(p, offset) (p)->Skip(p, offset)
+#define ILookInStream_Read(p, buf, size) (p)->Read(p, buf, size)
+#define ILookInStream_Seek(p, pos, origin) (p)->Seek(p, pos, origin)
+SRes
+LookInStream_LookRead (
+ const ILookInStream *stream,
+ void *buf,
+ size_t *size
+ );
-SRes LookInStream_LookRead(const ILookInStream *stream, void *buf, size_t *size);
-SRes LookInStream_SeekTo(const ILookInStream *stream, UInt64 offset);
+SRes
+LookInStream_SeekTo (
+ const ILookInStream *stream,
+ UInt64 offset
+ );
/* reads via ILookInStream::Read */
-SRes LookInStream_Read2(const ILookInStream *stream, void *buf, size_t size, SRes errorType);
-SRes LookInStream_Read(const ILookInStream *stream, void *buf, size_t size);
-
-
-
-typedef struct
-{
- ILookInStream vt;
- const ISeekInStream *realStream;
-
- size_t pos;
- size_t size; /* it's data size */
+SRes
+LookInStream_Read2 (
+ const ILookInStream *stream,
+ void *buf,
+ size_t size,
+ SRes errorType
+ );
+
+SRes
+LookInStream_Read (
+ const ILookInStream *stream,
+ void *buf,
+ size_t size
+ );
+
+typedef struct {
+ ILookInStream vt;
+ const ISeekInStream *realStream;
+
+ size_t pos;
+ size_t size; /* it's data size */
/* the following variables must be set outside */
- Byte *buf;
- size_t bufSize;
+ Byte *buf;
+ size_t bufSize;
} CLookToRead2;
-void LookToRead2_CreateVTable(CLookToRead2 *p, int lookahead);
-
-#define LookToRead2_Init(p) { (p)->pos = (p)->size = 0; }
+void
+LookToRead2_CreateVTable (
+ CLookToRead2 *p,
+ int lookahead
+ );
+#define LookToRead2_Init(p) { (p)->pos = (p)->size = 0; }
-typedef struct
-{
- ISeqInStream vt;
- const ILookInStream *realStream;
+typedef struct {
+ ISeqInStream vt;
+ const ILookInStream *realStream;
} CSecToLook;
-void SecToLook_CreateVTable(CSecToLook *p);
+void
+SecToLook_CreateVTable (
+ CSecToLook *p
+ );
-
-
-typedef struct
-{
- ISeqInStream vt;
- const ILookInStream *realStream;
+typedef struct {
+ ISeqInStream vt;
+ const ILookInStream *realStream;
} CSecToRead;
-void SecToRead_CreateVTable(CSecToRead *p);
-
+void
+SecToRead_CreateVTable (
+ CSecToRead *p
+ );
typedef struct ICompressProgress ICompressProgress;
-struct ICompressProgress
-{
- SRes (*Progress)(const ICompressProgress *p, UInt64 inSize, UInt64 outSize);
- /* Returns: result. (result != SZ_OK) means break.
- Value (UInt64)(Int64)-1 for size means unknown value. */
-};
-#define ICompressProgress_Progress(p, inSize, outSize) (p)->Progress(p, inSize, outSize)
+struct ICompressProgress {
+ SRes (*Progress)(
+ const ICompressProgress *p,
+ UInt64 inSize,
+ UInt64 outSize
+ );
+ /* Returns: result. (result != SZ_OK) means break.
+ Value (UInt64)(Int64)-1 for size means unknown value. */
+};
+#define ICompressProgress_Progress(p, inSize, outSize) (p)->Progress(p, inSize, outSize)
typedef struct ISzAlloc ISzAlloc;
-typedef const ISzAlloc * ISzAllocPtr;
-
-struct ISzAlloc
-{
- void *(*Alloc)(ISzAllocPtr p, size_t size);
- void (*Free)(ISzAllocPtr p, void *address); /* address can be 0 */
+typedef const ISzAlloc *ISzAllocPtr;
+
+struct ISzAlloc {
+ void *(*Alloc)(
+ ISzAllocPtr p,
+ size_t size
+ );
+ void (*Free)(
+ ISzAllocPtr p,
+ void *address
+ ); /* address can be 0 */
};
-#define ISzAlloc_Alloc(p, size) (p)->Alloc(p, size)
-#define ISzAlloc_Free(p, a) (p)->Free(p, a)
+#define ISzAlloc_Alloc(p, size) (p)->Alloc(p, size)
+#define ISzAlloc_Free(p, a) (p)->Free(p, a)
/* deprecated */
-#define IAlloc_Alloc(p, size) ISzAlloc_Alloc(p, size)
-#define IAlloc_Free(p, a) ISzAlloc_Free(p, a)
-
-
-
-
+#define IAlloc_Alloc(p, size) ISzAlloc_Alloc(p, size)
+#define IAlloc_Free(p, a) ISzAlloc_Free(p, a)
#ifndef MY_offsetof
#ifdef offsetof
- #define MY_offsetof(type, m) offsetof(type, m)
- /*
- #define MY_offsetof(type, m) FIELD_OFFSET(type, m)
- */
+#define MY_offsetof(type, m) offsetof(type, m)
+
+/*
+#define MY_offsetof(type, m) FIELD_OFFSET(type, m)
+*/
#else
- #define MY_offsetof(type, m) ((size_t)&(((type *)0)->m))
+#define MY_offsetof(type, m) ((size_t)&(((type *)0)->m))
#endif
#endif
-
-
#ifndef MY_container_of
/*
@@ -339,38 +410,36 @@ struct ISzAlloc GCC 4.8.1 : classes with non-public variable members"
*/
-#define MY_container_of(ptr, type, m) ((type *)((char *)(1 ? (ptr) : &((type *)0)->m) - MY_offsetof(type, m)))
-
+#define MY_container_of(ptr, type, m) ((type *)((char *)(1 ? (ptr) : &((type *)0)->m) - MY_offsetof(type, m)))
#endif
-#define CONTAINER_FROM_VTBL_SIMPLE(ptr, type, m) ((type *)(ptr))
+#define CONTAINER_FROM_VTBL_SIMPLE(ptr, type, m) ((type *)(ptr))
/*
#define CONTAINER_FROM_VTBL(ptr, type, m) CONTAINER_FROM_VTBL_SIMPLE(ptr, type, m)
*/
-#define CONTAINER_FROM_VTBL(ptr, type, m) MY_container_of(ptr, type, m)
+#define CONTAINER_FROM_VTBL(ptr, type, m) MY_container_of(ptr, type, m)
+
+#define CONTAINER_FROM_VTBL_CLS(ptr, type, m) CONTAINER_FROM_VTBL_SIMPLE(ptr, type, m)
-#define CONTAINER_FROM_VTBL_CLS(ptr, type, m) CONTAINER_FROM_VTBL_SIMPLE(ptr, type, m)
/*
#define CONTAINER_FROM_VTBL_CLS(ptr, type, m) CONTAINER_FROM_VTBL(ptr, type, m)
*/
-
-
#ifdef _WIN32
-#define CHAR_PATH_SEPARATOR '\\'
-#define WCHAR_PATH_SEPARATOR L'\\'
-#define STRING_PATH_SEPARATOR "\\"
-#define WSTRING_PATH_SEPARATOR L"\\"
+#define CHAR_PATH_SEPARATOR '\\'
+#define WCHAR_PATH_SEPARATOR L'\\'
+#define STRING_PATH_SEPARATOR "\\"
+#define WSTRING_PATH_SEPARATOR L"\\"
#else
-#define CHAR_PATH_SEPARATOR '/'
-#define WCHAR_PATH_SEPARATOR L'/'
-#define STRING_PATH_SEPARATOR "/"
-#define WSTRING_PATH_SEPARATOR L"/"
+#define CHAR_PATH_SEPARATOR '/'
+#define WCHAR_PATH_SEPARATOR L'/'
+#define STRING_PATH_SEPARATOR "/"
+#define WSTRING_PATH_SEPARATOR L"/"
#endif
diff --git a/MdeModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/7zVersion.h b/MdeModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/7zVersion.h index 0074c64be9..a45aa2008f 100644 --- a/MdeModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/7zVersion.h +++ b/MdeModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/7zVersion.h @@ -1,27 +1,27 @@ -#define MY_VER_MAJOR 19
-#define MY_VER_MINOR 00
-#define MY_VER_BUILD 0
-#define MY_VERSION_NUMBERS "19.00"
-#define MY_VERSION MY_VERSION_NUMBERS
+#define MY_VER_MAJOR 19
+#define MY_VER_MINOR 00
+#define MY_VER_BUILD 0
+#define MY_VERSION_NUMBERS "19.00"
+#define MY_VERSION MY_VERSION_NUMBERS
#ifdef MY_CPU_NAME
- #define MY_VERSION_CPU MY_VERSION " (" MY_CPU_NAME ")"
+#define MY_VERSION_CPU MY_VERSION " (" MY_CPU_NAME ")"
#else
- #define MY_VERSION_CPU MY_VERSION
+#define MY_VERSION_CPU MY_VERSION
#endif
-#define MY_DATE "2019-02-21"
+#define MY_DATE "2019-02-21"
#undef MY_COPYRIGHT
#undef MY_VERSION_COPYRIGHT_DATE
-#define MY_AUTHOR_NAME "Igor Pavlov"
-#define MY_COPYRIGHT_PD "Igor Pavlov : Public domain"
-#define MY_COPYRIGHT_CR "Copyright (c) 1999-2018 Igor Pavlov"
+#define MY_AUTHOR_NAME "Igor Pavlov"
+#define MY_COPYRIGHT_PD "Igor Pavlov : Public domain"
+#define MY_COPYRIGHT_CR "Copyright (c) 1999-2018 Igor Pavlov"
#ifdef USE_COPYRIGHT_CR
- #define MY_COPYRIGHT MY_COPYRIGHT_CR
+#define MY_COPYRIGHT MY_COPYRIGHT_CR
#else
- #define MY_COPYRIGHT MY_COPYRIGHT_PD
+#define MY_COPYRIGHT MY_COPYRIGHT_PD
#endif
-#define MY_COPYRIGHT_DATE MY_COPYRIGHT " : " MY_DATE
-#define MY_VERSION_COPYRIGHT_DATE MY_VERSION_CPU " : " MY_COPYRIGHT " : " MY_DATE
+#define MY_COPYRIGHT_DATE MY_COPYRIGHT " : " MY_DATE
+#define MY_VERSION_COPYRIGHT_DATE MY_VERSION_CPU " : " MY_COPYRIGHT " : " MY_DATE
diff --git a/MdeModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/Bra.h b/MdeModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/Bra.h index ecf7b0c447..85085192fb 100644 --- a/MdeModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/Bra.h +++ b/MdeModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/Bra.h @@ -51,13 +51,55 @@ in CALL instructions to increase the compression ratio. }
*/
-#define x86_Convert_Init(state) { state = 0; }
-SizeT x86_Convert(Byte *data, SizeT size, UInt32 ip, UInt32 *state, int encoding);
-SizeT ARM_Convert(Byte *data, SizeT size, UInt32 ip, int encoding);
-SizeT ARMT_Convert(Byte *data, SizeT size, UInt32 ip, int encoding);
-SizeT PPC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding);
-SizeT SPARC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding);
-SizeT IA64_Convert(Byte *data, SizeT size, UInt32 ip, int encoding);
+#define x86_Convert_Init(state) { state = 0; }
+SizeT
+x86_Convert (
+ Byte *data,
+ SizeT size,
+ UInt32 ip,
+ UInt32 *state,
+ int encoding
+ );
+
+SizeT
+ARM_Convert (
+ Byte *data,
+ SizeT size,
+ UInt32 ip,
+ int encoding
+ );
+
+SizeT
+ARMT_Convert (
+ Byte *data,
+ SizeT size,
+ UInt32 ip,
+ int encoding
+ );
+
+SizeT
+PPC_Convert (
+ Byte *data,
+ SizeT size,
+ UInt32 ip,
+ int encoding
+ );
+
+SizeT
+SPARC_Convert (
+ Byte *data,
+ SizeT size,
+ UInt32 ip,
+ int encoding
+ );
+
+SizeT
+IA64_Convert (
+ Byte *data,
+ SizeT size,
+ UInt32 ip,
+ int encoding
+ );
EXTERN_C_END
diff --git a/MdeModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/Bra86.c b/MdeModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/Bra86.c index a6463c63ba..ec5f574035 100644 --- a/MdeModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/Bra86.c +++ b/MdeModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/Bra86.c @@ -5,40 +5,49 @@ #include "Bra.h"
-#define Test86MSByte(b) ((((b) + 1) & 0xFE) == 0)
+#define Test86MSByte(b) ((((b) + 1) & 0xFE) == 0)
-SizeT x86_Convert(Byte *data, SizeT size, UInt32 ip, UInt32 *state, int encoding)
+SizeT
+x86_Convert (
+ Byte *data,
+ SizeT size,
+ UInt32 ip,
+ UInt32 *state,
+ int encoding
+ )
{
- SizeT pos = 0;
- UInt32 mask = *state & 7;
- if (size < 5)
+ SizeT pos = 0;
+ UInt32 mask = *state & 7;
+
+ if (size < 5) {
return 0;
+ }
+
size -= 4;
- ip += 5;
+ ip += 5;
- for (;;)
- {
- Byte *p = data + pos;
- const Byte *limit = data + size;
- for (; p < limit; p++)
- if ((*p & 0xFE) == 0xE8)
+ for ( ; ;) {
+ Byte *p = data + pos;
+ const Byte *limit = data + size;
+ for ( ; p < limit; p++) {
+ if ((*p & 0xFE) == 0xE8) {
break;
+ }
+ }
{
- SizeT d = (SizeT)(p - data - pos);
+ SizeT d = (SizeT)(p - data - pos);
pos = (SizeT)(p - data);
- if (p >= limit)
- {
+ if (p >= limit) {
*state = (d > 2 ? 0 : mask >> (unsigned)d);
return pos;
}
- if (d > 2)
+
+ if (d > 2) {
mask = 0;
- else
- {
+ } else {
mask >>= (unsigned)d;
- if (mask != 0 && (mask > 4 || mask == 3 || Test86MSByte(p[(size_t)(mask >> 1) + 1])))
- {
+ if ((mask != 0) && ((mask > 4) || (mask == 3) || Test86MSByte (p[(size_t)(mask >> 1) + 1]))) {
mask = (mask >> 1) | 4;
pos++;
continue;
@@ -46,35 +55,35 @@ SizeT x86_Convert(Byte *data, SizeT size, UInt32 ip, UInt32 *state, int encoding }
}
- if (Test86MSByte(p[4]))
- {
- UInt32 v = ((UInt32)p[4] << 24) | ((UInt32)p[3] << 16) | ((UInt32)p[2] << 8) | ((UInt32)p[1]);
- UInt32 cur = ip + (UInt32)pos;
+ if (Test86MSByte (p[4])) {
+ UInt32 v = ((UInt32)p[4] << 24) | ((UInt32)p[3] << 16) | ((UInt32)p[2] << 8) | ((UInt32)p[1]);
+ UInt32 cur = ip + (UInt32)pos;
pos += 5;
- if (encoding)
+ if (encoding) {
v += cur;
- else
+ } else {
v -= cur;
- if (mask != 0)
- {
- unsigned sh = (mask & 6) << 2;
- if (Test86MSByte((Byte)(v >> sh)))
- {
+ }
+
+ if (mask != 0) {
+ unsigned sh = (mask & 6) << 2;
+ if (Test86MSByte ((Byte)(v >> sh))) {
v ^= (((UInt32)0x100 << sh) - 1);
- if (encoding)
+ if (encoding) {
v += cur;
- else
+ } else {
v -= cur;
+ }
}
+
mask = 0;
}
+
p[1] = (Byte)v;
p[2] = (Byte)(v >> 8);
p[3] = (Byte)(v >> 16);
p[4] = (Byte)(0 - ((v >> 24) & 1));
- }
- else
- {
+ } else {
mask = (mask >> 1) | 4;
pos++;
}
diff --git a/MdeModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/Compiler.h b/MdeModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/Compiler.h index c788648cd2..e8968d3497 100644 --- a/MdeModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/Compiler.h +++ b/MdeModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/Compiler.h @@ -7,8 +7,8 @@ #ifdef _MSC_VER
#ifdef UNDER_CE
- #define RPC_NO_WINDOWS_H
- /* #pragma warning(disable : 4115) // '_RPC_ASYNC_STATE' : named type definition in parentheses */
+#define RPC_NO_WINDOWS_H
+/* #pragma warning(disable : 4115) // '_RPC_ASYNC_STATE' : named type definition in parentheses */
#pragma warning(disable : 4201) // nonstandard extension used : nameless struct/union
#pragma warning(disable : 4214) // nonstandard extension used : bit field types other than int
#endif
@@ -27,7 +27,7 @@ #endif
-#define UNUSED_VAR(x) (void)x;
+#define UNUSED_VAR(x) (void)x;
/* #define UNUSED_VAR(x) x=x; */
#endif
diff --git a/MdeModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/CpuArch.h b/MdeModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/CpuArch.h index 5f74c1c0cb..671a77bdb7 100644 --- a/MdeModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/CpuArch.h +++ b/MdeModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/CpuArch.h @@ -16,269 +16,252 @@ If MY_CPU_LE and MY_CPU_BE are not defined, we don't know about ENDIANNESS of pl MY_CPU_LE_UNALIGN means that CPU is LITTLE ENDIAN and CPU supports unaligned memory accesses.
*/
-#if defined(_M_X64) \
- || defined(_M_AMD64) \
- || defined(__x86_64__) \
- || defined(__AMD64__) \
- || defined(__amd64__)
- #define MY_CPU_AMD64
+#if defined (_M_X64) \
+ || defined (_M_AMD64) \
+ || defined (__x86_64__) \
+ || defined (__AMD64__) \
+ || defined (__amd64__)
+#define MY_CPU_AMD64
#ifdef __ILP32__
- #define MY_CPU_NAME "x32"
+#define MY_CPU_NAME "x32"
#else
- #define MY_CPU_NAME "x64"
+#define MY_CPU_NAME "x64"
#endif
- #define MY_CPU_64BIT
+#define MY_CPU_64BIT
#endif
-
-#if defined(_M_IX86) \
- || defined(__i386__)
- #define MY_CPU_X86
- #define MY_CPU_NAME "x86"
- #define MY_CPU_32BIT
+#if defined (_M_IX86) \
+ || defined (__i386__)
+#define MY_CPU_X86
+#define MY_CPU_NAME "x86"
+#define MY_CPU_32BIT
#endif
-
-#if defined(_M_ARM64) \
- || defined(__AARCH64EL__) \
- || defined(__AARCH64EB__) \
- || defined(__aarch64__)
- #define MY_CPU_ARM64
- #define MY_CPU_NAME "arm64"
- #define MY_CPU_64BIT
+#if defined (_M_ARM64) \
+ || defined (__AARCH64EL__) \
+ || defined (__AARCH64EB__) \
+ || defined (__aarch64__)
+#define MY_CPU_ARM64
+#define MY_CPU_NAME "arm64"
+#define MY_CPU_64BIT
#endif
-
-#if defined(_M_ARM) \
- || defined(_M_ARM_NT) \
- || defined(_M_ARMT) \
- || defined(__arm__) \
- || defined(__thumb__) \
- || defined(__ARMEL__) \
- || defined(__ARMEB__) \
- || defined(__THUMBEL__) \
- || defined(__THUMBEB__)
- #define MY_CPU_ARM
- #define MY_CPU_NAME "arm"
- #define MY_CPU_32BIT
+#if defined (_M_ARM) \
+ || defined (_M_ARM_NT) \
+ || defined (_M_ARMT) \
+ || defined (__arm__) \
+ || defined (__thumb__) \
+ || defined (__ARMEL__) \
+ || defined (__ARMEB__) \
+ || defined (__THUMBEL__) \
+ || defined (__THUMBEB__)
+#define MY_CPU_ARM
+#define MY_CPU_NAME "arm"
+#define MY_CPU_32BIT
#endif
-
-#if defined(_M_IA64) \
- || defined(__ia64__)
- #define MY_CPU_IA64
- #define MY_CPU_NAME "ia64"
- #define MY_CPU_64BIT
+#if defined (_M_IA64) \
+ || defined (__ia64__)
+#define MY_CPU_IA64
+#define MY_CPU_NAME "ia64"
+#define MY_CPU_64BIT
#endif
-
-#if defined(__mips64) \
- || defined(__mips64__) \
- || (defined(__mips) && (__mips == 64 || __mips == 4 || __mips == 3))
- #define MY_CPU_NAME "mips64"
- #define MY_CPU_64BIT
-#elif defined(__mips__)
- #define MY_CPU_NAME "mips"
- /* #define MY_CPU_32BIT */
+#if defined (__mips64) \
+ || defined (__mips64__) \
+ || (defined (__mips) && (__mips == 64 || __mips == 4 || __mips == 3))
+#define MY_CPU_NAME "mips64"
+#define MY_CPU_64BIT
+#elif defined (__mips__)
+#define MY_CPU_NAME "mips"
+/* #define MY_CPU_32BIT */
#endif
-
-#if defined(__ppc64__) \
- || defined(__powerpc64__)
+#if defined (__ppc64__) \
+ || defined (__powerpc64__)
#ifdef __ILP32__
- #define MY_CPU_NAME "ppc64-32"
+#define MY_CPU_NAME "ppc64-32"
#else
- #define MY_CPU_NAME "ppc64"
+#define MY_CPU_NAME "ppc64"
#endif
- #define MY_CPU_64BIT
-#elif defined(__ppc__) \
- || defined(__powerpc__)
- #define MY_CPU_NAME "ppc"
- #define MY_CPU_32BIT
+#define MY_CPU_64BIT
+#elif defined (__ppc__) \
+ || defined (__powerpc__)
+#define MY_CPU_NAME "ppc"
+#define MY_CPU_32BIT
#endif
-
-#if defined(__sparc64__)
- #define MY_CPU_NAME "sparc64"
- #define MY_CPU_64BIT
-#elif defined(__sparc__)
- #define MY_CPU_NAME "sparc"
- /* #define MY_CPU_32BIT */
+#if defined (__sparc64__)
+#define MY_CPU_NAME "sparc64"
+#define MY_CPU_64BIT
+#elif defined (__sparc__)
+#define MY_CPU_NAME "sparc"
+/* #define MY_CPU_32BIT */
#endif
-
-#if defined(MY_CPU_X86) || defined(MY_CPU_AMD64)
+#if defined (MY_CPU_X86) || defined (MY_CPU_AMD64)
#define MY_CPU_X86_OR_AMD64
#endif
-
#ifdef _WIN32
#ifdef MY_CPU_ARM
- #define MY_CPU_ARM_LE
+#define MY_CPU_ARM_LE
#endif
#ifdef MY_CPU_ARM64
- #define MY_CPU_ARM64_LE
+#define MY_CPU_ARM64_LE
#endif
#ifdef _M_IA64
- #define MY_CPU_IA64_LE
+#define MY_CPU_IA64_LE
#endif
#endif
-
-#if defined(MY_CPU_X86_OR_AMD64) \
- || defined(MY_CPU_ARM_LE) \
- || defined(MY_CPU_ARM64_LE) \
- || defined(MY_CPU_IA64_LE) \
- || defined(__LITTLE_ENDIAN__) \
- || defined(__ARMEL__) \
- || defined(__THUMBEL__) \
- || defined(__AARCH64EL__) \
- || defined(__MIPSEL__) \
- || defined(__MIPSEL) \
- || defined(_MIPSEL) \
- || defined(__BFIN__) \
- || (defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__))
- #define MY_CPU_LE
+#if defined (MY_CPU_X86_OR_AMD64) \
+ || defined (MY_CPU_ARM_LE) \
+ || defined (MY_CPU_ARM64_LE) \
+ || defined (MY_CPU_IA64_LE) \
+ || defined (__LITTLE_ENDIAN__) \
+ || defined (__ARMEL__) \
+ || defined (__THUMBEL__) \
+ || defined (__AARCH64EL__) \
+ || defined (__MIPSEL__) \
+ || defined (__MIPSEL) \
+ || defined (_MIPSEL) \
+ || defined (__BFIN__) \
+ || (defined (__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__))
+#define MY_CPU_LE
#endif
-#if defined(__BIG_ENDIAN__) \
- || defined(__ARMEB__) \
- || defined(__THUMBEB__) \
- || defined(__AARCH64EB__) \
- || defined(__MIPSEB__) \
- || defined(__MIPSEB) \
- || defined(_MIPSEB) \
- || defined(__m68k__) \
- || defined(__s390__) \
- || defined(__s390x__) \
- || defined(__zarch__) \
- || (defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__))
- #define MY_CPU_BE
+#if defined (__BIG_ENDIAN__) \
+ || defined (__ARMEB__) \
+ || defined (__THUMBEB__) \
+ || defined (__AARCH64EB__) \
+ || defined (__MIPSEB__) \
+ || defined (__MIPSEB) \
+ || defined (_MIPSEB) \
+ || defined (__m68k__) \
+ || defined (__s390__) \
+ || defined (__s390x__) \
+ || defined (__zarch__) \
+ || (defined (__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__))
+#define MY_CPU_BE
#endif
-
-#if defined(MY_CPU_LE) && defined(MY_CPU_BE)
+#if defined (MY_CPU_LE) && defined (MY_CPU_BE)
#error Stop_Compiling_Bad_Endian
#endif
-
-#if defined(MY_CPU_32BIT) && defined(MY_CPU_64BIT)
+#if defined (MY_CPU_32BIT) && defined (MY_CPU_64BIT)
#error Stop_Compiling_Bad_32_64_BIT
#endif
-
#ifndef MY_CPU_NAME
#ifdef MY_CPU_LE
- #define MY_CPU_NAME "LE"
- #elif defined(MY_CPU_BE)
- #define MY_CPU_NAME "BE"
+#define MY_CPU_NAME "LE"
+ #elif defined (MY_CPU_BE)
+#define MY_CPU_NAME "BE"
#else
- /*
- #define MY_CPU_NAME ""
- */
+
+/*
+#define MY_CPU_NAME ""
+*/
#endif
#endif
-
-
-
-
#ifdef MY_CPU_LE
- #if defined(MY_CPU_X86_OR_AMD64) \
- || defined(MY_CPU_ARM64) \
- || defined(__ARM_FEATURE_UNALIGNED)
- #define MY_CPU_LE_UNALIGN
+ #if defined (MY_CPU_X86_OR_AMD64) \
+ || defined (MY_CPU_ARM64) \
+ || defined (__ARM_FEATURE_UNALIGNED)
+#define MY_CPU_LE_UNALIGN
#endif
#endif
-
#ifdef MY_CPU_LE_UNALIGN
-#define GetUi16(p) (*(const UInt16 *)(const void *)(p))
-#define GetUi32(p) (*(const UInt32 *)(const void *)(p))
-#define GetUi64(p) (*(const UInt64 *)(const void *)(p))
+#define GetUi16(p) (*(const UInt16 *)(const void *)(p))
+#define GetUi32(p) (*(const UInt32 *)(const void *)(p))
+#define GetUi64(p) (*(const UInt64 *)(const void *)(p))
-#define SetUi16(p, v) { *(UInt16 *)(p) = (v); }
-#define SetUi32(p, v) { *(UInt32 *)(p) = (v); }
-#define SetUi64(p, v) { *(UInt64 *)(p) = (v); }
+#define SetUi16(p, v) { *(UInt16 *)(p) = (v); }
+#define SetUi32(p, v) { *(UInt32 *)(p) = (v); }
+#define SetUi64(p, v) { *(UInt64 *)(p) = (v); }
#else
-#define GetUi16(p) ( (UInt16) ( \
+#define GetUi16(p) ( (UInt16) (\
((const Byte *)(p))[0] | \
((UInt16)((const Byte *)(p))[1] << 8) ))
-#define GetUi32(p) ( \
+#define GetUi32(p) (\
((const Byte *)(p))[0] | \
((UInt32)((const Byte *)(p))[1] << 8) | \
((UInt32)((const Byte *)(p))[2] << 16) | \
((UInt32)((const Byte *)(p))[3] << 24))
-#define GetUi64(p) (GetUi32(p) | ((UInt64)GetUi32(((const Byte *)(p)) + 4) << 32))
+#define GetUi64(p) (GetUi32(p) | ((UInt64)GetUi32(((const Byte *)(p)) + 4) << 32))
-#define SetUi16(p, v) { Byte *_ppp_ = (Byte *)(p); UInt32 _vvv_ = (v); \
+#define SetUi16(p, v) { Byte *_ppp_ = (Byte *)(p); UInt32 _vvv_ = (v);\
_ppp_[0] = (Byte)_vvv_; \
_ppp_[1] = (Byte)(_vvv_ >> 8); }
-#define SetUi32(p, v) { Byte *_ppp_ = (Byte *)(p); UInt32 _vvv_ = (v); \
+#define SetUi32(p, v) { Byte *_ppp_ = (Byte *)(p); UInt32 _vvv_ = (v);\
_ppp_[0] = (Byte)_vvv_; \
_ppp_[1] = (Byte)(_vvv_ >> 8); \
_ppp_[2] = (Byte)(_vvv_ >> 16); \
_ppp_[3] = (Byte)(_vvv_ >> 24); }
-#define SetUi64(p, v) { Byte *_ppp2_ = (Byte *)(p); UInt64 _vvv2_ = (v); \
+#define SetUi64(p, v) { Byte *_ppp2_ = (Byte *)(p); UInt64 _vvv2_ = (v);\
SetUi32(_ppp2_ , (UInt32)_vvv2_); \
SetUi32(_ppp2_ + 4, (UInt32)(_vvv2_ >> 32)); }
#endif
#ifdef __has_builtin
- #define MY__has_builtin(x) __has_builtin(x)
+#define MY__has_builtin(x) __has_builtin(x)
#else
- #define MY__has_builtin(x) 0
+#define MY__has_builtin(x) 0
#endif
-#if defined(MY_CPU_LE_UNALIGN) && /* defined(_WIN64) && */ (_MSC_VER >= 1300)
+#if defined (MY_CPU_LE_UNALIGN) && /* defined(_WIN64) && */ (_MSC_VER >= 1300)
/* Note: we use bswap instruction, that is unsupported in 386 cpu */
-#include <stdlib.h>
+ #include <stdlib.h>
-#pragma intrinsic(_byteswap_ushort)
-#pragma intrinsic(_byteswap_ulong)
-#pragma intrinsic(_byteswap_uint64)
+ #pragma intrinsic(_byteswap_ushort)
+ #pragma intrinsic(_byteswap_ulong)
+ #pragma intrinsic(_byteswap_uint64)
/* #define GetBe16(p) _byteswap_ushort(*(const UInt16 *)(const Byte *)(p)) */
-#define GetBe32(p) _byteswap_ulong(*(const UInt32 *)(const Byte *)(p))
-#define GetBe64(p) _byteswap_uint64(*(const UInt64 *)(const Byte *)(p))
+#define GetBe32(p) _byteswap_ulong(*(const UInt32 *)(const Byte *)(p))
+#define GetBe64(p) _byteswap_uint64(*(const UInt64 *)(const Byte *)(p))
-#define SetBe32(p, v) (*(UInt32 *)(void *)(p)) = _byteswap_ulong(v)
+#define SetBe32(p, v) (*(UInt32 *)(void *)(p)) = _byteswap_ulong(v)
-#elif defined(MY_CPU_LE_UNALIGN) && ( \
- (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))) \
- || (defined(__clang__) && MY__has_builtin(__builtin_bswap16)) )
+#elif defined (MY_CPU_LE_UNALIGN) && ( \
+ (defined (__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))) \
+ || (defined (__clang__) && MY__has_builtin (__builtin_bswap16)))
/* #define GetBe16(p) __builtin_bswap16(*(const UInt16 *)(const Byte *)(p)) */
-#define GetBe32(p) __builtin_bswap32(*(const UInt32 *)(const Byte *)(p))
-#define GetBe64(p) __builtin_bswap64(*(const UInt64 *)(const Byte *)(p))
+#define GetBe32(p) __builtin_bswap32(*(const UInt32 *)(const Byte *)(p))
+#define GetBe64(p) __builtin_bswap64(*(const UInt64 *)(const Byte *)(p))
-#define SetBe32(p, v) (*(UInt32 *)(void *)(p)) = __builtin_bswap32(v)
+#define SetBe32(p, v) (*(UInt32 *)(void *)(p)) = __builtin_bswap32(v)
#else
-#define GetBe32(p) ( \
+#define GetBe32(p) (\
((UInt32)((const Byte *)(p))[0] << 24) | \
((UInt32)((const Byte *)(p))[1] << 16) | \
((UInt32)((const Byte *)(p))[2] << 8) | \
((const Byte *)(p))[3] )
-#define GetBe64(p) (((UInt64)GetBe32(p) << 32) | GetBe32(((const Byte *)(p)) + 4))
+#define GetBe64(p) (((UInt64)GetBe32(p) << 32) | GetBe32(((const Byte *)(p)) + 4))
-#define SetBe32(p, v) { Byte *_ppp_ = (Byte *)(p); UInt32 _vvv_ = (v); \
+#define SetBe32(p, v) { Byte *_ppp_ = (Byte *)(p); UInt32 _vvv_ = (v);\
_ppp_[0] = (Byte)(_vvv_ >> 24); \
_ppp_[1] = (Byte)(_vvv_ >> 16); \
_ppp_[2] = (Byte)(_vvv_ >> 8); \
@@ -286,48 +269,65 @@ MY_CPU_LE_UNALIGN means that CPU is LITTLE ENDIAN and CPU supports unaligned mem #endif
-
#ifndef GetBe16
-#define GetBe16(p) ( (UInt16) ( \
+#define GetBe16(p) ( (UInt16) (\
((UInt16)((const Byte *)(p))[0] << 8) | \
((const Byte *)(p))[1] ))
#endif
-
-
#ifdef MY_CPU_X86_OR_AMD64
-typedef struct
-{
- UInt32 maxFunc;
- UInt32 vendor[3];
- UInt32 ver;
- UInt32 b;
- UInt32 c;
- UInt32 d;
+typedef struct {
+ UInt32 maxFunc;
+ UInt32 vendor[3];
+ UInt32 ver;
+ UInt32 b;
+ UInt32 c;
+ UInt32 d;
} Cx86cpuid;
-enum
-{
+enum {
CPU_FIRM_INTEL,
CPU_FIRM_AMD,
CPU_FIRM_VIA
};
-void MyCPUID(UInt32 function, UInt32 *a, UInt32 *b, UInt32 *c, UInt32 *d);
-
-BoolInt x86cpuid_CheckAndRead(Cx86cpuid *p);
-int x86cpuid_GetFirm(const Cx86cpuid *p);
-
-#define x86cpuid_GetFamily(ver) (((ver >> 16) & 0xFF0) | ((ver >> 8) & 0xF))
-#define x86cpuid_GetModel(ver) (((ver >> 12) & 0xF0) | ((ver >> 4) & 0xF))
-#define x86cpuid_GetStepping(ver) (ver & 0xF)
-
-BoolInt CPU_Is_InOrder();
-BoolInt CPU_Is_Aes_Supported();
-BoolInt CPU_IsSupported_PageGB();
+void
+MyCPUID (
+ UInt32 function,
+ UInt32 *a,
+ UInt32 *b,
+ UInt32 *c,
+ UInt32 *d
+ );
+
+BoolInt
+x86cpuid_CheckAndRead (
+ Cx86cpuid *p
+ );
+
+int
+x86cpuid_GetFirm (
+ const Cx86cpuid *p
+ );
+
+#define x86cpuid_GetFamily(ver) (((ver >> 16) & 0xFF0) | ((ver >> 8) & 0xF))
+#define x86cpuid_GetModel(ver) (((ver >> 12) & 0xF0) | ((ver >> 4) & 0xF))
+#define x86cpuid_GetStepping(ver) (ver & 0xF)
+
+BoolInt
+CPU_Is_InOrder (
+ );
+
+BoolInt
+CPU_Is_Aes_Supported (
+ );
+
+BoolInt
+CPU_IsSupported_PageGB (
+ );
#endif
diff --git a/MdeModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/LzFind.c b/MdeModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/LzFind.c index 670a9fab12..2102409a4b 100644 --- a/MdeModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/LzFind.c +++ b/MdeModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/LzFind.c @@ -4,393 +4,547 @@ #include "Precomp.h"
#ifndef EFIAPI
-#include <string.h>
+ #include <string.h>
#endif
#include "LzFind.h"
#include "LzHash.h"
-#define kEmptyHashValue 0
-#define kMaxValForNormalize ((UInt32)0xFFFFFFFF)
-#define kNormalizeStepMin (1 << 10) /* it must be power of 2 */
-#define kNormalizeMask (~(UInt32)(kNormalizeStepMin - 1))
-#define kMaxHistorySize ((UInt32)7 << 29)
+#define kEmptyHashValue 0
+#define kMaxValForNormalize ((UInt32)0xFFFFFFFF)
+#define kNormalizeStepMin (1 << 10)/* it must be power of 2 */
+#define kNormalizeMask (~(UInt32)(kNormalizeStepMin - 1))
+#define kMaxHistorySize ((UInt32)7 << 29)
-#define kStartMaxLen 3
+#define kStartMaxLen 3
-static void LzInWindow_Free(CMatchFinder *p, ISzAllocPtr alloc)
+static void
+LzInWindow_Free (
+ CMatchFinder *p,
+ ISzAllocPtr alloc
+ )
{
- if (!p->directInput)
- {
- ISzAlloc_Free(alloc, p->bufferBase);
+ if (!p->directInput) {
+ ISzAlloc_Free (alloc, p->bufferBase);
p->bufferBase = NULL;
}
}
/* keepSizeBefore + keepSizeAfter + keepSizeReserv must be < 4G) */
-static int LzInWindow_Create(CMatchFinder *p, UInt32 keepSizeReserv, ISzAllocPtr alloc)
+static int
+LzInWindow_Create (
+ CMatchFinder *p,
+ UInt32 keepSizeReserv,
+ ISzAllocPtr alloc
+ )
{
- UInt32 blockSize = p->keepSizeBefore + p->keepSizeAfter + keepSizeReserv;
- if (p->directInput)
- {
+ UInt32 blockSize = p->keepSizeBefore + p->keepSizeAfter + keepSizeReserv;
+
+ if (p->directInput) {
p->blockSize = blockSize;
return 1;
}
- if (!p->bufferBase || p->blockSize != blockSize)
- {
- LzInWindow_Free(p, alloc);
- p->blockSize = blockSize;
- p->bufferBase = (Byte *)ISzAlloc_Alloc(alloc, (size_t)blockSize);
+
+ if (!p->bufferBase || (p->blockSize != blockSize)) {
+ LzInWindow_Free (p, alloc);
+ p->blockSize = blockSize;
+ p->bufferBase = (Byte *)ISzAlloc_Alloc (alloc, (size_t)blockSize);
}
+
return (p->bufferBase != NULL);
}
-Byte *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p) { return p->buffer; }
+Byte *
+MatchFinder_GetPointerToCurrentPos (
+ CMatchFinder *p
+ )
+{
+ return p->buffer;
+}
-UInt32 MatchFinder_GetNumAvailableBytes(CMatchFinder *p) { return p->streamPos - p->pos; }
+UInt32
+MatchFinder_GetNumAvailableBytes (
+ CMatchFinder *p
+ )
+{
+ return p->streamPos - p->pos;
+}
-void MatchFinder_ReduceOffsets(CMatchFinder *p, UInt32 subValue)
+void
+MatchFinder_ReduceOffsets (
+ CMatchFinder *p,
+ UInt32 subValue
+ )
{
- p->posLimit -= subValue;
- p->pos -= subValue;
+ p->posLimit -= subValue;
+ p->pos -= subValue;
p->streamPos -= subValue;
}
-static void MatchFinder_ReadBlock(CMatchFinder *p)
+static void
+MatchFinder_ReadBlock (
+ CMatchFinder *p
+ )
{
- if (p->streamEndWasReached || p->result != SZ_OK)
+ if (p->streamEndWasReached || (p->result != SZ_OK)) {
return;
+ }
/* We use (p->streamPos - p->pos) value. (p->streamPos < p->pos) is allowed. */
- if (p->directInput)
- {
- UInt32 curSize = 0xFFFFFFFF - (p->streamPos - p->pos);
- if (curSize > p->directInputRem)
+ if (p->directInput) {
+ UInt32 curSize = 0xFFFFFFFF - (p->streamPos - p->pos);
+ if (curSize > p->directInputRem) {
curSize = (UInt32)p->directInputRem;
+ }
+
p->directInputRem -= curSize;
- p->streamPos += curSize;
- if (p->directInputRem == 0)
+ p->streamPos += curSize;
+ if (p->directInputRem == 0) {
p->streamEndWasReached = 1;
+ }
+
return;
}
- for (;;)
- {
- Byte *dest = p->buffer + (p->streamPos - p->pos);
- size_t size = (p->bufferBase + p->blockSize - dest);
- if (size == 0)
+ for ( ; ;) {
+ Byte *dest = p->buffer + (p->streamPos - p->pos);
+ size_t size = (p->bufferBase + p->blockSize - dest);
+ if (size == 0) {
return;
+ }
- p->result = ISeqInStream_Read(p->stream, dest, &size);
- if (p->result != SZ_OK)
+ p->result = ISeqInStream_Read (p->stream, dest, &size);
+ if (p->result != SZ_OK) {
return;
- if (size == 0)
- {
+ }
+
+ if (size == 0) {
p->streamEndWasReached = 1;
return;
}
+
p->streamPos += (UInt32)size;
- if (p->streamPos - p->pos > p->keepSizeAfter)
+ if (p->streamPos - p->pos > p->keepSizeAfter) {
return;
+ }
}
}
-void MatchFinder_MoveBlock(CMatchFinder *p)
+void
+MatchFinder_MoveBlock (
+ CMatchFinder *p
+ )
{
- memmove(p->bufferBase,
- p->buffer - p->keepSizeBefore,
- (size_t)(p->streamPos - p->pos) + p->keepSizeBefore);
+ memmove (
+ p->bufferBase,
+ p->buffer - p->keepSizeBefore,
+ (size_t)(p->streamPos - p->pos) + p->keepSizeBefore
+ );
p->buffer = p->bufferBase + p->keepSizeBefore;
}
-int MatchFinder_NeedMove(CMatchFinder *p)
+int
+MatchFinder_NeedMove (
+ CMatchFinder *p
+ )
{
- if (p->directInput)
+ if (p->directInput) {
return 0;
+ }
+
/* if (p->streamEndWasReached) return 0; */
return ((size_t)(p->bufferBase + p->blockSize - p->buffer) <= p->keepSizeAfter);
}
-void MatchFinder_ReadIfRequired(CMatchFinder *p)
+void
+MatchFinder_ReadIfRequired (
+ CMatchFinder *p
+ )
{
- if (p->streamEndWasReached)
+ if (p->streamEndWasReached) {
return;
- if (p->keepSizeAfter >= p->streamPos - p->pos)
- MatchFinder_ReadBlock(p);
+ }
+
+ if (p->keepSizeAfter >= p->streamPos - p->pos) {
+ MatchFinder_ReadBlock (p);
+ }
}
-static void MatchFinder_CheckAndMoveAndRead(CMatchFinder *p)
+static void
+MatchFinder_CheckAndMoveAndRead (
+ CMatchFinder *p
+ )
{
- if (MatchFinder_NeedMove(p))
- MatchFinder_MoveBlock(p);
- MatchFinder_ReadBlock(p);
+ if (MatchFinder_NeedMove (p)) {
+ MatchFinder_MoveBlock (p);
+ }
+
+ MatchFinder_ReadBlock (p);
}
-static void MatchFinder_SetDefaultSettings(CMatchFinder *p)
+static void
+MatchFinder_SetDefaultSettings (
+ CMatchFinder *p
+ )
{
- p->cutValue = 32;
- p->btMode = 1;
+ p->cutValue = 32;
+ p->btMode = 1;
p->numHashBytes = 4;
- p->bigHash = 0;
+ p->bigHash = 0;
}
-#define kCrcPoly 0xEDB88320
+#define kCrcPoly 0xEDB88320
-void MatchFinder_Construct(CMatchFinder *p)
+void
+MatchFinder_Construct (
+ CMatchFinder *p
+ )
{
- unsigned i;
- p->bufferBase = NULL;
- p->directInput = 0;
- p->hash = NULL;
+ unsigned i;
+
+ p->bufferBase = NULL;
+ p->directInput = 0;
+ p->hash = NULL;
p->expectedDataSize = (UInt64)(Int64)-1;
- MatchFinder_SetDefaultSettings(p);
+ MatchFinder_SetDefaultSettings (p);
- for (i = 0; i < 256; i++)
- {
- UInt32 r = (UInt32)i;
- unsigned j;
- for (j = 0; j < 8; j++)
+ for (i = 0; i < 256; i++) {
+ UInt32 r = (UInt32)i;
+ unsigned j;
+ for (j = 0; j < 8; j++) {
r = (r >> 1) ^ (kCrcPoly & ((UInt32)0 - (r & 1)));
+ }
+
p->crc[i] = r;
}
}
-static void MatchFinder_FreeThisClassMemory(CMatchFinder *p, ISzAllocPtr alloc)
+static void
+MatchFinder_FreeThisClassMemory (
+ CMatchFinder *p,
+ ISzAllocPtr alloc
+ )
{
- ISzAlloc_Free(alloc, p->hash);
+ ISzAlloc_Free (alloc, p->hash);
p->hash = NULL;
}
-void MatchFinder_Free(CMatchFinder *p, ISzAllocPtr alloc)
+void
+MatchFinder_Free (
+ CMatchFinder *p,
+ ISzAllocPtr alloc
+ )
{
- MatchFinder_FreeThisClassMemory(p, alloc);
- LzInWindow_Free(p, alloc);
+ MatchFinder_FreeThisClassMemory (p, alloc);
+ LzInWindow_Free (p, alloc);
}
-static CLzRef* AllocRefs(size_t num, ISzAllocPtr alloc)
+static CLzRef *
+AllocRefs (
+ size_t num,
+ ISzAllocPtr alloc
+ )
{
- size_t sizeInBytes = (size_t)num * sizeof(CLzRef);
- if (sizeInBytes / sizeof(CLzRef) != num)
+ size_t sizeInBytes = (size_t)num * sizeof (CLzRef);
+
+ if (sizeInBytes / sizeof (CLzRef) != num) {
return NULL;
- return (CLzRef *)ISzAlloc_Alloc(alloc, sizeInBytes);
+ }
+
+ return (CLzRef *)ISzAlloc_Alloc (alloc, sizeInBytes);
}
-int MatchFinder_Create(CMatchFinder *p, UInt32 historySize,
- UInt32 keepAddBufferBefore, UInt32 matchMaxLen, UInt32 keepAddBufferAfter,
- ISzAllocPtr alloc)
+int
+MatchFinder_Create (
+ CMatchFinder *p,
+ UInt32 historySize,
+ UInt32 keepAddBufferBefore,
+ UInt32 matchMaxLen,
+ UInt32 keepAddBufferAfter,
+ ISzAllocPtr alloc
+ )
{
- UInt32 sizeReserv;
+ UInt32 sizeReserv;
- if (historySize > kMaxHistorySize)
- {
- MatchFinder_Free(p, alloc);
+ if (historySize > kMaxHistorySize) {
+ MatchFinder_Free (p, alloc);
return 0;
}
sizeReserv = historySize >> 1;
- if (historySize >= ((UInt32)3 << 30)) sizeReserv = historySize >> 3;
- else if (historySize >= ((UInt32)2 << 30)) sizeReserv = historySize >> 2;
+ if (historySize >= ((UInt32)3 << 30)) {
+ sizeReserv = historySize >> 3;
+ } else if (historySize >= ((UInt32)2 << 30)) {
+ sizeReserv = historySize >> 2;
+ }
sizeReserv += (keepAddBufferBefore + matchMaxLen + keepAddBufferAfter) / 2 + (1 << 19);
p->keepSizeBefore = historySize + keepAddBufferBefore + 1;
- p->keepSizeAfter = matchMaxLen + keepAddBufferAfter;
+ p->keepSizeAfter = matchMaxLen + keepAddBufferAfter;
/* we need one additional byte, since we use MoveBlock after pos++ and before dictionary using */
- if (LzInWindow_Create(p, sizeReserv, alloc))
- {
- UInt32 newCyclicBufferSize = historySize + 1;
- UInt32 hs;
+ if (LzInWindow_Create (p, sizeReserv, alloc)) {
+ UInt32 newCyclicBufferSize = historySize + 1;
+ UInt32 hs;
p->matchMaxLen = matchMaxLen;
{
p->fixedHashSize = 0;
- if (p->numHashBytes == 2)
+ if (p->numHashBytes == 2) {
hs = (1 << 16) - 1;
- else
- {
+ } else {
hs = historySize;
- if (hs > p->expectedDataSize)
+ if (hs > p->expectedDataSize) {
hs = (UInt32)p->expectedDataSize;
- if (hs != 0)
+ }
+
+ if (hs != 0) {
hs--;
- hs |= (hs >> 1);
- hs |= (hs >> 2);
- hs |= (hs >> 4);
- hs |= (hs >> 8);
+ }
+
+ hs |= (hs >> 1);
+ hs |= (hs >> 2);
+ hs |= (hs >> 4);
+ hs |= (hs >> 8);
hs >>= 1;
- hs |= 0xFFFF; /* don't change it! It's required for Deflate */
- if (hs > (1 << 24))
- {
- if (p->numHashBytes == 3)
+ hs |= 0xFFFF; /* don't change it! It's required for Deflate */
+ if (hs > (1 << 24)) {
+ if (p->numHashBytes == 3) {
hs = (1 << 24) - 1;
- else
+ } else {
hs >>= 1;
+ }
+
/* if (bigHash) mode, GetHeads4b() in LzFindMt.c needs (hs >= ((1 << 24) - 1))) */
}
}
+
p->hashMask = hs;
hs++;
- if (p->numHashBytes > 2) p->fixedHashSize += kHash2Size;
- if (p->numHashBytes > 3) p->fixedHashSize += kHash3Size;
- if (p->numHashBytes > 4) p->fixedHashSize += kHash4Size;
+ if (p->numHashBytes > 2) {
+ p->fixedHashSize += kHash2Size;
+ }
+
+ if (p->numHashBytes > 3) {
+ p->fixedHashSize += kHash3Size;
+ }
+
+ if (p->numHashBytes > 4) {
+ p->fixedHashSize += kHash4Size;
+ }
+
hs += p->fixedHashSize;
}
{
- size_t newSize;
- size_t numSons;
- p->historySize = historySize;
- p->hashSizeSum = hs;
+ size_t newSize;
+ size_t numSons;
+ p->historySize = historySize;
+ p->hashSizeSum = hs;
p->cyclicBufferSize = newCyclicBufferSize;
numSons = newCyclicBufferSize;
- if (p->btMode)
+ if (p->btMode) {
numSons <<= 1;
+ }
+
newSize = hs + numSons;
- if (p->hash && p->numRefs == newSize)
+ if (p->hash && (p->numRefs == newSize)) {
return 1;
+ }
- MatchFinder_FreeThisClassMemory(p, alloc);
+ MatchFinder_FreeThisClassMemory (p, alloc);
p->numRefs = newSize;
- p->hash = AllocRefs(newSize, alloc);
+ p->hash = AllocRefs (newSize, alloc);
- if (p->hash)
- {
+ if (p->hash) {
p->son = p->hash + p->hashSizeSum;
return 1;
}
}
}
- MatchFinder_Free(p, alloc);
+ MatchFinder_Free (p, alloc);
return 0;
}
-static void MatchFinder_SetLimits(CMatchFinder *p)
+static void
+MatchFinder_SetLimits (
+ CMatchFinder *p
+ )
{
- UInt32 limit = kMaxValForNormalize - p->pos;
- UInt32 limit2 = p->cyclicBufferSize - p->cyclicBufferPos;
+ UInt32 limit = kMaxValForNormalize - p->pos;
+ UInt32 limit2 = p->cyclicBufferSize - p->cyclicBufferPos;
- if (limit2 < limit)
+ if (limit2 < limit) {
limit = limit2;
+ }
+
limit2 = p->streamPos - p->pos;
- if (limit2 <= p->keepSizeAfter)
- {
- if (limit2 > 0)
+ if (limit2 <= p->keepSizeAfter) {
+ if (limit2 > 0) {
limit2 = 1;
- }
- else
+ }
+ } else {
limit2 -= p->keepSizeAfter;
+ }
- if (limit2 < limit)
+ if (limit2 < limit) {
limit = limit2;
+ }
{
- UInt32 lenLimit = p->streamPos - p->pos;
- if (lenLimit > p->matchMaxLen)
+ UInt32 lenLimit = p->streamPos - p->pos;
+ if (lenLimit > p->matchMaxLen) {
lenLimit = p->matchMaxLen;
+ }
+
p->lenLimit = lenLimit;
}
p->posLimit = p->pos + limit;
}
-
-void MatchFinder_Init_LowHash(CMatchFinder *p)
+void
+MatchFinder_Init_LowHash (
+ CMatchFinder *p
+ )
{
- size_t i;
- CLzRef *items = p->hash;
- size_t numItems = p->fixedHashSize;
- for (i = 0; i < numItems; i++)
+ size_t i;
+ CLzRef *items = p->hash;
+ size_t numItems = p->fixedHashSize;
+
+ for (i = 0; i < numItems; i++) {
items[i] = kEmptyHashValue;
+ }
}
-
-void MatchFinder_Init_HighHash(CMatchFinder *p)
+void
+MatchFinder_Init_HighHash (
+ CMatchFinder *p
+ )
{
- size_t i;
- CLzRef *items = p->hash + p->fixedHashSize;
- size_t numItems = (size_t)p->hashMask + 1;
- for (i = 0; i < numItems; i++)
+ size_t i;
+ CLzRef *items = p->hash + p->fixedHashSize;
+ size_t numItems = (size_t)p->hashMask + 1;
+
+ for (i = 0; i < numItems; i++) {
items[i] = kEmptyHashValue;
+ }
}
-
-void MatchFinder_Init_3(CMatchFinder *p, int readData)
+void
+MatchFinder_Init_3 (
+ CMatchFinder *p,
+ int readData
+ )
{
- p->cyclicBufferPos = 0;
- p->buffer = p->bufferBase;
- p->pos =
- p->streamPos = p->cyclicBufferSize;
- p->result = SZ_OK;
+ p->cyclicBufferPos = 0;
+ p->buffer = p->bufferBase;
+ p->pos =
+ p->streamPos = p->cyclicBufferSize;
+ p->result = SZ_OK;
p->streamEndWasReached = 0;
- if (readData)
- MatchFinder_ReadBlock(p);
+ if (readData) {
+ MatchFinder_ReadBlock (p);
+ }
- MatchFinder_SetLimits(p);
+ MatchFinder_SetLimits (p);
}
-
-void MatchFinder_Init(CMatchFinder *p)
+void
+MatchFinder_Init (
+ CMatchFinder *p
+ )
{
- MatchFinder_Init_HighHash(p);
- MatchFinder_Init_LowHash(p);
- MatchFinder_Init_3(p, True);
+ MatchFinder_Init_HighHash (p);
+ MatchFinder_Init_LowHash (p);
+ MatchFinder_Init_3 (p, True);
}
-
-static UInt32 MatchFinder_GetSubValue(CMatchFinder *p)
+static UInt32
+MatchFinder_GetSubValue (
+ CMatchFinder *p
+ )
{
return (p->pos - p->historySize - 1) & kNormalizeMask;
}
-void MatchFinder_Normalize3(UInt32 subValue, CLzRef *items, size_t numItems)
+void
+MatchFinder_Normalize3 (
+ UInt32 subValue,
+ CLzRef *items,
+ size_t numItems
+ )
{
- size_t i;
- for (i = 0; i < numItems; i++)
- {
- UInt32 value = items[i];
- if (value <= subValue)
+ size_t i;
+
+ for (i = 0; i < numItems; i++) {
+ UInt32 value = items[i];
+ if (value <= subValue) {
value = kEmptyHashValue;
- else
+ } else {
value -= subValue;
+ }
+
items[i] = value;
}
}
-static void MatchFinder_Normalize(CMatchFinder *p)
+static void
+MatchFinder_Normalize (
+ CMatchFinder *p
+ )
{
- UInt32 subValue = MatchFinder_GetSubValue(p);
- MatchFinder_Normalize3(subValue, p->hash, p->numRefs);
- MatchFinder_ReduceOffsets(p, subValue);
-}
+ UInt32 subValue = MatchFinder_GetSubValue (p);
+ MatchFinder_Normalize3 (subValue, p->hash, p->numRefs);
+ MatchFinder_ReduceOffsets (p, subValue);
+}
MY_NO_INLINE
-static void MatchFinder_CheckLimits(CMatchFinder *p)
+static void
+MatchFinder_CheckLimits (
+ CMatchFinder *p
+ )
{
- if (p->pos == kMaxValForNormalize)
- MatchFinder_Normalize(p);
- if (!p->streamEndWasReached && p->keepSizeAfter == p->streamPos - p->pos)
- MatchFinder_CheckAndMoveAndRead(p);
- if (p->cyclicBufferPos == p->cyclicBufferSize)
+ if (p->pos == kMaxValForNormalize) {
+ MatchFinder_Normalize (p);
+ }
+
+ if (!p->streamEndWasReached && (p->keepSizeAfter == p->streamPos - p->pos)) {
+ MatchFinder_CheckAndMoveAndRead (p);
+ }
+
+ if (p->cyclicBufferPos == p->cyclicBufferSize) {
p->cyclicBufferPos = 0;
- MatchFinder_SetLimits(p);
-}
+ }
+ MatchFinder_SetLimits (p);
+}
/*
(lenLimit > maxLen)
*/
MY_FORCE_INLINE
-static UInt32 * Hc_GetMatchesSpec(unsigned lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son,
- UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue,
- UInt32 *distances, unsigned maxLen)
+static UInt32 *
+Hc_GetMatchesSpec (
+ unsigned lenLimit,
+ UInt32 curMatch,
+ UInt32 pos,
+ const Byte *cur,
+ CLzRef *son,
+ UInt32 _cyclicBufferPos,
+ UInt32 _cyclicBufferSize,
+ UInt32 cutValue,
+ UInt32 *distances,
+ unsigned maxLen
+ )
{
/*
son[_cyclicBufferPos] = curMatch;
@@ -421,151 +575,165 @@ static UInt32 * Hc_GetMatchesSpec(unsigned lenLimit, UInt32 curMatch, UInt32 pos }
*/
- const Byte *lim = cur + lenLimit;
+ const Byte *lim = cur + lenLimit;
+
son[_cyclicBufferPos] = curMatch;
- do
- {
- UInt32 delta = pos - curMatch;
- if (delta >= _cyclicBufferSize)
+ do {
+ UInt32 delta = pos - curMatch;
+ if (delta >= _cyclicBufferSize) {
break;
+ }
+
{
- ptrdiff_t diff;
+ ptrdiff_t diff;
curMatch = son[_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)];
- diff = (ptrdiff_t)0 - delta;
- if (cur[maxLen] == cur[maxLen + diff])
- {
- const Byte *c = cur;
- while (*c == c[diff])
- {
- if (++c == lim)
- {
+ diff = (ptrdiff_t)0 - delta;
+ if (cur[maxLen] == cur[maxLen + diff]) {
+ const Byte *c = cur;
+ while (*c == c[diff]) {
+ if (++c == lim) {
distances[0] = (UInt32)(lim - cur);
distances[1] = delta - 1;
return distances + 2;
}
}
+
{
- unsigned len = (unsigned)(c - cur);
- if (maxLen < len)
- {
- maxLen = len;
+ unsigned len = (unsigned)(c - cur);
+ if (maxLen < len) {
+ maxLen = len;
distances[0] = (UInt32)len;
distances[1] = delta - 1;
- distances += 2;
+ distances += 2;
}
}
}
}
- }
- while (--cutValue);
+ } while (--cutValue);
return distances;
}
-
MY_FORCE_INLINE
-UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son,
- UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue,
- UInt32 *distances, UInt32 maxLen)
+UInt32 *
+GetMatchesSpec1 (
+ UInt32 lenLimit,
+ UInt32 curMatch,
+ UInt32 pos,
+ const Byte *cur,
+ CLzRef *son,
+ UInt32 _cyclicBufferPos,
+ UInt32 _cyclicBufferSize,
+ UInt32 cutValue,
+ UInt32 *distances,
+ UInt32 maxLen
+ )
{
- CLzRef *ptr0 = son + ((size_t)_cyclicBufferPos << 1) + 1;
- CLzRef *ptr1 = son + ((size_t)_cyclicBufferPos << 1);
- unsigned len0 = 0, len1 = 0;
- for (;;)
- {
- UInt32 delta = pos - curMatch;
- if (cutValue-- == 0 || delta >= _cyclicBufferSize)
- {
+ CLzRef *ptr0 = son + ((size_t)_cyclicBufferPos << 1) + 1;
+ CLzRef *ptr1 = son + ((size_t)_cyclicBufferPos << 1);
+ unsigned len0 = 0, len1 = 0;
+
+ for ( ; ;) {
+ UInt32 delta = pos - curMatch;
+ if ((cutValue-- == 0) || (delta >= _cyclicBufferSize)) {
*ptr0 = *ptr1 = kEmptyHashValue;
return distances;
}
+
{
- CLzRef *pair = son + ((size_t)(_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)) << 1);
- const Byte *pb = cur - delta;
- unsigned len = (len0 < len1 ? len0 : len1);
- UInt32 pair0 = pair[0];
- if (pb[len] == cur[len])
- {
- if (++len != lenLimit && pb[len] == cur[len])
- while (++len != lenLimit)
- if (pb[len] != cur[len])
+ CLzRef *pair = son + ((size_t)(_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)) << 1);
+ const Byte *pb = cur - delta;
+ unsigned len = (len0 < len1 ? len0 : len1);
+ UInt32 pair0 = pair[0];
+ if (pb[len] == cur[len]) {
+ if ((++len != lenLimit) && (pb[len] == cur[len])) {
+ while (++len != lenLimit) {
+ if (pb[len] != cur[len]) {
break;
- if (maxLen < len)
- {
- maxLen = (UInt32)len;
+ }
+ }
+ }
+
+ if (maxLen < len) {
+ maxLen = (UInt32)len;
*distances++ = (UInt32)len;
*distances++ = delta - 1;
- if (len == lenLimit)
- {
+ if (len == lenLimit) {
*ptr1 = pair0;
*ptr0 = pair[1];
return distances;
}
}
}
- if (pb[len] < cur[len])
- {
- *ptr1 = curMatch;
- ptr1 = pair + 1;
+
+ if (pb[len] < cur[len]) {
+ *ptr1 = curMatch;
+ ptr1 = pair + 1;
curMatch = *ptr1;
- len1 = len;
- }
- else
- {
- *ptr0 = curMatch;
- ptr0 = pair;
+ len1 = len;
+ } else {
+ *ptr0 = curMatch;
+ ptr0 = pair;
curMatch = *ptr0;
- len0 = len;
+ len0 = len;
}
}
}
}
-static void SkipMatchesSpec(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son,
- UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue)
+static void
+SkipMatchesSpec (
+ UInt32 lenLimit,
+ UInt32 curMatch,
+ UInt32 pos,
+ const Byte *cur,
+ CLzRef *son,
+ UInt32 _cyclicBufferPos,
+ UInt32 _cyclicBufferSize,
+ UInt32 cutValue
+ )
{
- CLzRef *ptr0 = son + ((size_t)_cyclicBufferPos << 1) + 1;
- CLzRef *ptr1 = son + ((size_t)_cyclicBufferPos << 1);
- unsigned len0 = 0, len1 = 0;
- for (;;)
- {
- UInt32 delta = pos - curMatch;
- if (cutValue-- == 0 || delta >= _cyclicBufferSize)
- {
+ CLzRef *ptr0 = son + ((size_t)_cyclicBufferPos << 1) + 1;
+ CLzRef *ptr1 = son + ((size_t)_cyclicBufferPos << 1);
+ unsigned len0 = 0, len1 = 0;
+
+ for ( ; ;) {
+ UInt32 delta = pos - curMatch;
+ if ((cutValue-- == 0) || (delta >= _cyclicBufferSize)) {
*ptr0 = *ptr1 = kEmptyHashValue;
return;
}
+
{
- CLzRef *pair = son + ((size_t)(_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)) << 1);
- const Byte *pb = cur - delta;
- unsigned len = (len0 < len1 ? len0 : len1);
- if (pb[len] == cur[len])
- {
- while (++len != lenLimit)
- if (pb[len] != cur[len])
+ CLzRef *pair = son + ((size_t)(_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)) << 1);
+ const Byte *pb = cur - delta;
+ unsigned len = (len0 < len1 ? len0 : len1);
+ if (pb[len] == cur[len]) {
+ while (++len != lenLimit) {
+ if (pb[len] != cur[len]) {
break;
+ }
+ }
+
{
- if (len == lenLimit)
- {
+ if (len == lenLimit) {
*ptr1 = pair[0];
*ptr0 = pair[1];
return;
}
}
}
- if (pb[len] < cur[len])
- {
- *ptr1 = curMatch;
- ptr1 = pair + 1;
+
+ if (pb[len] < cur[len]) {
+ *ptr1 = curMatch;
+ ptr1 = pair + 1;
curMatch = *ptr1;
- len1 = len;
- }
- else
- {
- *ptr0 = curMatch;
- ptr0 = pair;
+ len1 = len;
+ } else {
+ *ptr0 = curMatch;
+ ptr0 = pair;
curMatch = *ptr0;
- len0 = len;
+ len0 = len;
}
}
}
@@ -576,19 +744,25 @@ static void SkipMatchesSpec(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const p->buffer++; \
if (++p->pos == p->posLimit) MatchFinder_CheckLimits(p);
-#define MOVE_POS_RET MOVE_POS return (UInt32)offset;
+#define MOVE_POS_RET MOVE_POS return (UInt32)offset;
-static void MatchFinder_MovePos(CMatchFinder *p) { MOVE_POS; }
+static void
+MatchFinder_MovePos (
+ CMatchFinder *p
+ )
+{
+ MOVE_POS;
+}
#define GET_MATCHES_HEADER2(minLen, ret_op) \
unsigned lenLimit; UInt32 hv; const Byte *cur; UInt32 curMatch; \
lenLimit = (unsigned)p->lenLimit; { if (lenLimit < minLen) { MatchFinder_MovePos(p); ret_op; }} \
cur = p->buffer;
-#define GET_MATCHES_HEADER(minLen) GET_MATCHES_HEADER2(minLen, return 0)
-#define SKIP_HEADER(minLen) GET_MATCHES_HEADER2(minLen, continue)
+#define GET_MATCHES_HEADER(minLen) GET_MATCHES_HEADER2(minLen, return 0)
+#define SKIP_HEADER(minLen) GET_MATCHES_HEADER2(minLen, continue)
-#define MF_PARAMS(p) p->pos, p->buffer, p->son, p->cyclicBufferPos, p->cyclicBufferSize, p->cutValue
+#define MF_PARAMS(p) p->pos, p->buffer, p->son, p->cyclicBufferPos, p->cyclicBufferSize, p->cutValue
#define GET_MATCHES_FOOTER(offset, maxLen) \
offset = (unsigned)(GetMatchesSpec1((UInt32)lenLimit, curMatch, MF_PARAMS(p), \
@@ -597,128 +771,143 @@ static void MatchFinder_MovePos(CMatchFinder *p) { MOVE_POS; } #define SKIP_FOOTER \
SkipMatchesSpec((UInt32)lenLimit, curMatch, MF_PARAMS(p)); MOVE_POS;
-#define UPDATE_maxLen { \
+#define UPDATE_maxLen {\
ptrdiff_t diff = (ptrdiff_t)0 - d2; \
const Byte *c = cur + maxLen; \
const Byte *lim = cur + lenLimit; \
for (; c != lim; c++) if (*(c + diff) != *c) break; \
maxLen = (unsigned)(c - cur); }
-static UInt32 Bt2_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
+static UInt32
+Bt2_MatchFinder_GetMatches (
+ CMatchFinder *p,
+ UInt32 *distances
+ )
{
- unsigned offset;
- GET_MATCHES_HEADER(2)
+ unsigned offset;
+
+ GET_MATCHES_HEADER (2)
HASH2_CALC;
- curMatch = p->hash[hv];
+ curMatch = p->hash[hv];
p->hash[hv] = p->pos;
- offset = 0;
- GET_MATCHES_FOOTER(offset, 1)
+ offset = 0;
+ GET_MATCHES_FOOTER (offset, 1)
}
-UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
+UInt32
+Bt3Zip_MatchFinder_GetMatches (
+ CMatchFinder *p,
+ UInt32 *distances
+ )
{
- unsigned offset;
- GET_MATCHES_HEADER(3)
+ unsigned offset;
+
+ GET_MATCHES_HEADER (3)
HASH_ZIP_CALC;
- curMatch = p->hash[hv];
+ curMatch = p->hash[hv];
p->hash[hv] = p->pos;
- offset = 0;
- GET_MATCHES_FOOTER(offset, 2)
+ offset = 0;
+ GET_MATCHES_FOOTER (offset, 2)
}
-static UInt32 Bt3_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
+static UInt32
+Bt3_MatchFinder_GetMatches (
+ CMatchFinder *p,
+ UInt32 *distances
+ )
{
- UInt32 h2, d2, pos;
- unsigned maxLen, offset;
- UInt32 *hash;
- GET_MATCHES_HEADER(3)
+ UInt32 h2, d2, pos;
+ unsigned maxLen, offset;
+ UInt32 *hash;
+
+ GET_MATCHES_HEADER (3)
HASH3_CALC;
hash = p->hash;
- pos = p->pos;
+ pos = p->pos;
d2 = pos - hash[h2];
curMatch = (hash + kFix3HashSize)[hv];
- hash[h2] = pos;
+ hash[h2] = pos;
(hash + kFix3HashSize)[hv] = pos;
maxLen = 2;
offset = 0;
- if (d2 < p->cyclicBufferSize && *(cur - d2) == *cur)
- {
+ if ((d2 < p->cyclicBufferSize) && (*(cur - d2) == *cur)) {
UPDATE_maxLen
- distances[0] = (UInt32)maxLen;
+ distances[0] = (UInt32)maxLen;
distances[1] = d2 - 1;
- offset = 2;
- if (maxLen == lenLimit)
- {
- SkipMatchesSpec((UInt32)lenLimit, curMatch, MF_PARAMS(p));
+ offset = 2;
+ if (maxLen == lenLimit) {
+ SkipMatchesSpec ((UInt32)lenLimit, curMatch, MF_PARAMS (p));
MOVE_POS_RET;
}
}
- GET_MATCHES_FOOTER(offset, maxLen)
+ GET_MATCHES_FOOTER (offset, maxLen)
}
-static UInt32 Bt4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
+static UInt32
+Bt4_MatchFinder_GetMatches (
+ CMatchFinder *p,
+ UInt32 *distances
+ )
{
- UInt32 h2, h3, d2, d3, pos;
- unsigned maxLen, offset;
- UInt32 *hash;
- GET_MATCHES_HEADER(4)
+ UInt32 h2, h3, d2, d3, pos;
+ unsigned maxLen, offset;
+ UInt32 *hash;
+
+ GET_MATCHES_HEADER (4)
HASH4_CALC;
hash = p->hash;
- pos = p->pos;
+ pos = p->pos;
- d2 = pos - hash[ h2];
+ d2 = pos - hash[h2];
d3 = pos - (hash + kFix3HashSize)[h3];
curMatch = (hash + kFix4HashSize)[hv];
- hash[ h2] = pos;
+ hash[h2] = pos;
(hash + kFix3HashSize)[h3] = pos;
(hash + kFix4HashSize)[hv] = pos;
maxLen = 0;
offset = 0;
- if (d2 < p->cyclicBufferSize && *(cur - d2) == *cur)
- {
- maxLen = 2;
+ if ((d2 < p->cyclicBufferSize) && (*(cur - d2) == *cur)) {
+ maxLen = 2;
distances[0] = 2;
distances[1] = d2 - 1;
- offset = 2;
+ offset = 2;
}
- if (d2 != d3 && d3 < p->cyclicBufferSize && *(cur - d3) == *cur)
- {
- maxLen = 3;
+ if ((d2 != d3) && (d3 < p->cyclicBufferSize) && (*(cur - d3) == *cur)) {
+ maxLen = 3;
distances[(size_t)offset + 1] = d3 - 1;
- offset += 2;
- d2 = d3;
+ offset += 2;
+ d2 = d3;
}
- if (offset != 0)
- {
+ if (offset != 0) {
UPDATE_maxLen
- distances[(size_t)offset - 2] = (UInt32)maxLen;
- if (maxLen == lenLimit)
- {
- SkipMatchesSpec((UInt32)lenLimit, curMatch, MF_PARAMS(p));
+ distances[(size_t)offset - 2] = (UInt32)maxLen;
+ if (maxLen == lenLimit) {
+ SkipMatchesSpec ((UInt32)lenLimit, curMatch, MF_PARAMS (p));
MOVE_POS_RET;
}
}
- if (maxLen < 3)
+ if (maxLen < 3) {
maxLen = 3;
+ }
- GET_MATCHES_FOOTER(offset, maxLen)
+ GET_MATCHES_FOOTER (offset, maxLen)
}
/*
@@ -797,63 +986,69 @@ static UInt32 Bt5_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) GET_MATCHES_FOOTER(offset, maxLen)
}
*/
-
-static UInt32 Hc4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
+static UInt32
+Hc4_MatchFinder_GetMatches (
+ CMatchFinder *p,
+ UInt32 *distances
+ )
{
- UInt32 h2, h3, d2, d3, pos;
- unsigned maxLen, offset;
- UInt32 *hash;
- GET_MATCHES_HEADER(4)
+ UInt32 h2, h3, d2, d3, pos;
+ unsigned maxLen, offset;
+ UInt32 *hash;
+
+ GET_MATCHES_HEADER (4)
HASH4_CALC;
hash = p->hash;
- pos = p->pos;
+ pos = p->pos;
- d2 = pos - hash[ h2];
+ d2 = pos - hash[h2];
d3 = pos - (hash + kFix3HashSize)[h3];
curMatch = (hash + kFix4HashSize)[hv];
- hash[ h2] = pos;
+ hash[h2] = pos;
(hash + kFix3HashSize)[h3] = pos;
(hash + kFix4HashSize)[hv] = pos;
maxLen = 0;
offset = 0;
- if (d2 < p->cyclicBufferSize && *(cur - d2) == *cur)
- {
- maxLen = 2;
+ if ((d2 < p->cyclicBufferSize) && (*(cur - d2) == *cur)) {
+ maxLen = 2;
distances[0] = 2;
distances[1] = d2 - 1;
- offset = 2;
+ offset = 2;
}
- if (d2 != d3 && d3 < p->cyclicBufferSize && *(cur - d3) == *cur)
- {
- maxLen = 3;
+ if ((d2 != d3) && (d3 < p->cyclicBufferSize) && (*(cur - d3) == *cur)) {
+ maxLen = 3;
distances[(size_t)offset + 1] = d3 - 1;
- offset += 2;
- d2 = d3;
+ offset += 2;
+ d2 = d3;
}
- if (offset != 0)
- {
+ if (offset != 0) {
UPDATE_maxLen
- distances[(size_t)offset - 2] = (UInt32)maxLen;
- if (maxLen == lenLimit)
- {
+ distances[(size_t)offset - 2] = (UInt32)maxLen;
+ if (maxLen == lenLimit) {
p->son[p->cyclicBufferPos] = curMatch;
MOVE_POS_RET;
}
}
- if (maxLen < 3)
+ if (maxLen < 3) {
maxLen = 3;
+ }
- offset = (unsigned)(Hc_GetMatchesSpec(lenLimit, curMatch, MF_PARAMS(p),
- distances + offset, maxLen) - (distances));
+ offset = (unsigned)(Hc_GetMatchesSpec (
+ lenLimit,
+ curMatch,
+ MF_PARAMS (p),
+ distances + offset,
+ maxLen
+ ) - (distances));
MOVE_POS_RET
}
@@ -935,78 +1130,95 @@ static UInt32 Hc5_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances) MOVE_POS_RET
}
*/
-
-UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
+UInt32
+Hc3Zip_MatchFinder_GetMatches (
+ CMatchFinder *p,
+ UInt32 *distances
+ )
{
- unsigned offset;
- GET_MATCHES_HEADER(3)
+ unsigned offset;
+
+ GET_MATCHES_HEADER (3)
HASH_ZIP_CALC;
- curMatch = p->hash[hv];
+ curMatch = p->hash[hv];
p->hash[hv] = p->pos;
- offset = (unsigned)(Hc_GetMatchesSpec(lenLimit, curMatch, MF_PARAMS(p),
- distances, 2) - (distances));
+ offset = (unsigned)(Hc_GetMatchesSpec (
+ lenLimit,
+ curMatch,
+ MF_PARAMS (p),
+ distances,
+ 2
+ ) - (distances));
MOVE_POS_RET
}
-static void Bt2_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
+static void
+Bt2_MatchFinder_Skip (
+ CMatchFinder *p,
+ UInt32 num
+ )
{
- do
- {
- SKIP_HEADER(2)
+ do {
+ SKIP_HEADER (2)
HASH2_CALC;
- curMatch = p->hash[hv];
+ curMatch = p->hash[hv];
p->hash[hv] = p->pos;
SKIP_FOOTER
- }
- while (--num != 0);
+ } while (--num != 0);
}
-void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
+void
+Bt3Zip_MatchFinder_Skip (
+ CMatchFinder *p,
+ UInt32 num
+ )
{
- do
- {
- SKIP_HEADER(3)
+ do {
+ SKIP_HEADER (3)
HASH_ZIP_CALC;
- curMatch = p->hash[hv];
+ curMatch = p->hash[hv];
p->hash[hv] = p->pos;
SKIP_FOOTER
- }
- while (--num != 0);
+ } while (--num != 0);
}
-static void Bt3_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
+static void
+Bt3_MatchFinder_Skip (
+ CMatchFinder *p,
+ UInt32 num
+ )
{
- do
- {
- UInt32 h2;
- UInt32 *hash;
- SKIP_HEADER(3)
+ do {
+ UInt32 h2;
+ UInt32 *hash;
+ SKIP_HEADER (3)
HASH3_CALC;
- hash = p->hash;
- curMatch = (hash + kFix3HashSize)[hv];
- hash[h2] =
- (hash + kFix3HashSize)[hv] = p->pos;
+ hash = p->hash;
+ curMatch = (hash + kFix3HashSize)[hv];
+ hash[h2] =
+ (hash + kFix3HashSize)[hv] = p->pos;
SKIP_FOOTER
- }
- while (--num != 0);
+ } while (--num != 0);
}
-static void Bt4_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
+static void
+Bt4_MatchFinder_Skip (
+ CMatchFinder *p,
+ UInt32 num
+ )
{
- do
- {
- UInt32 h2, h3;
- UInt32 *hash;
- SKIP_HEADER(4)
+ do {
+ UInt32 h2, h3;
+ UInt32 *hash;
+ SKIP_HEADER (4)
HASH4_CALC;
- hash = p->hash;
- curMatch = (hash + kFix4HashSize)[hv];
- hash[ h2] =
- (hash + kFix3HashSize)[h3] =
- (hash + kFix4HashSize)[hv] = p->pos;
+ hash = p->hash;
+ curMatch = (hash + kFix4HashSize)[hv];
+ hash[h2] =
+ (hash + kFix3HashSize)[h3] =
+ (hash + kFix4HashSize)[hv] = p->pos;
SKIP_FOOTER
- }
- while (--num != 0);
+ } while (--num != 0);
}
/*
@@ -1029,24 +1241,25 @@ static void Bt5_MatchFinder_Skip(CMatchFinder *p, UInt32 num) while (--num != 0);
}
*/
-
-static void Hc4_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
+static void
+Hc4_MatchFinder_Skip (
+ CMatchFinder *p,
+ UInt32 num
+ )
{
- do
- {
- UInt32 h2, h3;
- UInt32 *hash;
- SKIP_HEADER(4)
+ do {
+ UInt32 h2, h3;
+ UInt32 *hash;
+ SKIP_HEADER (4)
HASH4_CALC;
- hash = p->hash;
- curMatch = (hash + kFix4HashSize)[hv];
- hash[ h2] =
- (hash + kFix3HashSize)[h3] =
- (hash + kFix4HashSize)[hv] = p->pos;
- p->son[p->cyclicBufferPos] = curMatch;
+ hash = p->hash;
+ curMatch = (hash + kFix4HashSize)[hv];
+ hash[h2] =
+ (hash + kFix3HashSize)[h3] =
+ (hash + kFix4HashSize)[hv] = p->pos;
+ p->son[p->cyclicBufferPos] = curMatch;
MOVE_POS
- }
- while (--num != 0);
+ } while (--num != 0);
}
/*
@@ -1070,33 +1283,38 @@ static void Hc5_MatchFinder_Skip(CMatchFinder *p, UInt32 num) while (--num != 0);
}
*/
-
-void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
+void
+Hc3Zip_MatchFinder_Skip (
+ CMatchFinder *p,
+ UInt32 num
+ )
{
- do
- {
- SKIP_HEADER(3)
+ do {
+ SKIP_HEADER (3)
HASH_ZIP_CALC;
- curMatch = p->hash[hv];
- p->hash[hv] = p->pos;
+ curMatch = p->hash[hv];
+ p->hash[hv] = p->pos;
p->son[p->cyclicBufferPos] = curMatch;
MOVE_POS
- }
- while (--num != 0);
+ } while (--num != 0);
}
-void MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder *vTable)
+void
+MatchFinder_CreateVTable (
+ CMatchFinder *p,
+ IMatchFinder *vTable
+ )
{
- vTable->Init = (Mf_Init_Func)MatchFinder_Init;
- vTable->GetNumAvailableBytes = (Mf_GetNumAvailableBytes_Func)MatchFinder_GetNumAvailableBytes;
+ vTable->Init = (Mf_Init_Func)MatchFinder_Init;
+ vTable->GetNumAvailableBytes = (Mf_GetNumAvailableBytes_Func)MatchFinder_GetNumAvailableBytes;
vTable->GetPointerToCurrentPos = (Mf_GetPointerToCurrentPos_Func)MatchFinder_GetPointerToCurrentPos;
- if (!p->btMode)
- {
+ if (!p->btMode) {
/* if (p->numHashBytes <= 4) */
{
vTable->GetMatches = (Mf_GetMatches_Func)Hc4_MatchFinder_GetMatches;
- vTable->Skip = (Mf_Skip_Func)Hc4_MatchFinder_Skip;
+ vTable->Skip = (Mf_Skip_Func)Hc4_MatchFinder_Skip;
}
+
/*
else
{
@@ -1104,22 +1322,18 @@ void MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder *vTable) vTable->Skip = (Mf_Skip_Func)Hc5_MatchFinder_Skip;
}
*/
- }
- else if (p->numHashBytes == 2)
- {
+ } else if (p->numHashBytes == 2) {
vTable->GetMatches = (Mf_GetMatches_Func)Bt2_MatchFinder_GetMatches;
- vTable->Skip = (Mf_Skip_Func)Bt2_MatchFinder_Skip;
- }
- else if (p->numHashBytes == 3)
- {
+ vTable->Skip = (Mf_Skip_Func)Bt2_MatchFinder_Skip;
+ } else if (p->numHashBytes == 3) {
vTable->GetMatches = (Mf_GetMatches_Func)Bt3_MatchFinder_GetMatches;
- vTable->Skip = (Mf_Skip_Func)Bt3_MatchFinder_Skip;
- }
- else /* if (p->numHashBytes == 4) */
- {
+ vTable->Skip = (Mf_Skip_Func)Bt3_MatchFinder_Skip;
+ } else {
+ /* if (p->numHashBytes == 4) */
vTable->GetMatches = (Mf_GetMatches_Func)Bt4_MatchFinder_GetMatches;
- vTable->Skip = (Mf_Skip_Func)Bt4_MatchFinder_Skip;
+ vTable->Skip = (Mf_Skip_Func)Bt4_MatchFinder_Skip;
}
+
/*
else
{
diff --git a/MdeModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/LzFind.h b/MdeModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/LzFind.h index 61bb9dd302..923d3e3d95 100644 --- a/MdeModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/LzFind.h +++ b/MdeModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/LzFind.h @@ -10,77 +10,126 @@ EXTERN_C_BEGIN typedef UInt32 CLzRef;
-typedef struct _CMatchFinder
-{
- Byte *buffer;
- UInt32 pos;
- UInt32 posLimit;
- UInt32 streamPos;
- UInt32 lenLimit;
-
- UInt32 cyclicBufferPos;
- UInt32 cyclicBufferSize; /* it must be = (historySize + 1) */
-
- Byte streamEndWasReached;
- Byte btMode;
- Byte bigHash;
- Byte directInput;
-
- UInt32 matchMaxLen;
- CLzRef *hash;
- CLzRef *son;
- UInt32 hashMask;
- UInt32 cutValue;
-
- Byte *bufferBase;
- ISeqInStream *stream;
-
- UInt32 blockSize;
- UInt32 keepSizeBefore;
- UInt32 keepSizeAfter;
-
- UInt32 numHashBytes;
- size_t directInputRem;
- UInt32 historySize;
- UInt32 fixedHashSize;
- UInt32 hashSizeSum;
- SRes result;
- UInt32 crc[256];
- size_t numRefs;
-
- UInt64 expectedDataSize;
+typedef struct _CMatchFinder {
+ Byte *buffer;
+ UInt32 pos;
+ UInt32 posLimit;
+ UInt32 streamPos;
+ UInt32 lenLimit;
+
+ UInt32 cyclicBufferPos;
+ UInt32 cyclicBufferSize; /* it must be = (historySize + 1) */
+
+ Byte streamEndWasReached;
+ Byte btMode;
+ Byte bigHash;
+ Byte directInput;
+
+ UInt32 matchMaxLen;
+ CLzRef *hash;
+ CLzRef *son;
+ UInt32 hashMask;
+ UInt32 cutValue;
+
+ Byte *bufferBase;
+ ISeqInStream *stream;
+
+ UInt32 blockSize;
+ UInt32 keepSizeBefore;
+ UInt32 keepSizeAfter;
+
+ UInt32 numHashBytes;
+ size_t directInputRem;
+ UInt32 historySize;
+ UInt32 fixedHashSize;
+ UInt32 hashSizeSum;
+ SRes result;
+ UInt32 crc[256];
+ size_t numRefs;
+
+ UInt64 expectedDataSize;
} CMatchFinder;
-#define Inline_MatchFinder_GetPointerToCurrentPos(p) ((p)->buffer)
+#define Inline_MatchFinder_GetPointerToCurrentPos(p) ((p)->buffer)
-#define Inline_MatchFinder_GetNumAvailableBytes(p) ((p)->streamPos - (p)->pos)
+#define Inline_MatchFinder_GetNumAvailableBytes(p) ((p)->streamPos - (p)->pos)
#define Inline_MatchFinder_IsFinishedOK(p) \
((p)->streamEndWasReached \
&& (p)->streamPos == (p)->pos \
&& (!(p)->directInput || (p)->directInputRem == 0))
-int MatchFinder_NeedMove(CMatchFinder *p);
-Byte *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p);
-void MatchFinder_MoveBlock(CMatchFinder *p);
-void MatchFinder_ReadIfRequired(CMatchFinder *p);
+int
+MatchFinder_NeedMove (
+ CMatchFinder *p
+ );
-void MatchFinder_Construct(CMatchFinder *p);
+Byte *
+MatchFinder_GetPointerToCurrentPos (
+ CMatchFinder *p
+ );
+
+void
+MatchFinder_MoveBlock (
+ CMatchFinder *p
+ );
+
+void
+MatchFinder_ReadIfRequired (
+ CMatchFinder *p
+ );
+
+void
+MatchFinder_Construct (
+ CMatchFinder *p
+ );
/* Conditions:
historySize <= 3 GB
keepAddBufferBefore + matchMaxLen + keepAddBufferAfter < 511MB
*/
-int MatchFinder_Create(CMatchFinder *p, UInt32 historySize,
- UInt32 keepAddBufferBefore, UInt32 matchMaxLen, UInt32 keepAddBufferAfter,
- ISzAllocPtr alloc);
-void MatchFinder_Free(CMatchFinder *p, ISzAllocPtr alloc);
-void MatchFinder_Normalize3(UInt32 subValue, CLzRef *items, size_t numItems);
-void MatchFinder_ReduceOffsets(CMatchFinder *p, UInt32 subValue);
-
-UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *buffer, CLzRef *son,
- UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 _cutValue,
- UInt32 *distances, UInt32 maxLen);
+int
+MatchFinder_Create (
+ CMatchFinder *p,
+ UInt32 historySize,
+ UInt32 keepAddBufferBefore,
+ UInt32 matchMaxLen,
+ UInt32 keepAddBufferAfter,
+ ISzAllocPtr alloc
+ );
+
+void
+MatchFinder_Free (
+ CMatchFinder *p,
+ ISzAllocPtr alloc
+ );
+
+void
+MatchFinder_Normalize3 (
+ UInt32 subValue,
+ CLzRef *items,
+ size_t numItems
+ );
+
+void
+MatchFinder_ReduceOffsets (
+ CMatchFinder *p,
+ UInt32 subValue
+ );
+
+UInt32 *
+GetMatchesSpec1 (
+ UInt32 lenLimit,
+ UInt32 curMatch,
+ UInt32 pos,
+ const Byte *buffer,
+ CLzRef *son,
+ UInt32 _cyclicBufferPos,
+ UInt32 _cyclicBufferSize,
+ UInt32 _cutValue,
+ UInt32 *distances,
+ UInt32 maxLen
+ );
/*
Conditions:
@@ -88,33 +137,82 @@ Conditions: Mf_GetPointerToCurrentPos_Func's result must be used only before any other function
*/
-typedef void (*Mf_Init_Func)(void *object);
-typedef UInt32 (*Mf_GetNumAvailableBytes_Func)(void *object);
-typedef const Byte * (*Mf_GetPointerToCurrentPos_Func)(void *object);
-typedef UInt32 (*Mf_GetMatches_Func)(void *object, UInt32 *distances);
-typedef void (*Mf_Skip_Func)(void *object, UInt32);
-
-typedef struct _IMatchFinder
-{
- Mf_Init_Func Init;
- Mf_GetNumAvailableBytes_Func GetNumAvailableBytes;
- Mf_GetPointerToCurrentPos_Func GetPointerToCurrentPos;
- Mf_GetMatches_Func GetMatches;
- Mf_Skip_Func Skip;
+typedef void (*Mf_Init_Func)(
+ void *object
+ );
+typedef UInt32 (*Mf_GetNumAvailableBytes_Func)(
+ void *object
+ );
+typedef const Byte * (*Mf_GetPointerToCurrentPos_Func)(
+ void *object
+ );
+typedef UInt32 (*Mf_GetMatches_Func)(
+ void *object,
+ UInt32 *distances
+ );
+typedef void (*Mf_Skip_Func)(
+ void *object,
+ UInt32
+ );
+
+typedef struct _IMatchFinder {
+ Mf_Init_Func Init;
+ Mf_GetNumAvailableBytes_Func GetNumAvailableBytes;
+ Mf_GetPointerToCurrentPos_Func GetPointerToCurrentPos;
+ Mf_GetMatches_Func GetMatches;
+ Mf_Skip_Func Skip;
} IMatchFinder;
-void MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder *vTable);
-
-void MatchFinder_Init_LowHash(CMatchFinder *p);
-void MatchFinder_Init_HighHash(CMatchFinder *p);
-void MatchFinder_Init_3(CMatchFinder *p, int readData);
-void MatchFinder_Init(CMatchFinder *p);
-
-UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances);
-UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances);
-
-void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num);
-void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num);
+void
+MatchFinder_CreateVTable (
+ CMatchFinder *p,
+ IMatchFinder *vTable
+ );
+
+void
+MatchFinder_Init_LowHash (
+ CMatchFinder *p
+ );
+
+void
+MatchFinder_Init_HighHash (
+ CMatchFinder *p
+ );
+
+void
+MatchFinder_Init_3 (
+ CMatchFinder *p,
+ int readData
+ );
+
+void
+MatchFinder_Init (
+ CMatchFinder *p
+ );
+
+UInt32
+Bt3Zip_MatchFinder_GetMatches (
+ CMatchFinder *p,
+ UInt32 *distances
+ );
+
+UInt32
+Hc3Zip_MatchFinder_GetMatches (
+ CMatchFinder *p,
+ UInt32 *distances
+ );
+
+void
+Bt3Zip_MatchFinder_Skip (
+ CMatchFinder *p,
+ UInt32 num
+ );
+
+void
+Hc3Zip_MatchFinder_Skip (
+ CMatchFinder *p,
+ UInt32 num
+ );
EXTERN_C_END
diff --git a/MdeModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/LzHash.h b/MdeModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/LzHash.h index 2191444072..eec8bb13bd 100644 --- a/MdeModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/LzHash.h +++ b/MdeModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/LzHash.h @@ -4,29 +4,29 @@ #ifndef __LZ_HASH_H
#define __LZ_HASH_H
-#define kHash2Size (1 << 10)
-#define kHash3Size (1 << 16)
-#define kHash4Size (1 << 20)
+#define kHash2Size (1 << 10)
+#define kHash3Size (1 << 16)
+#define kHash4Size (1 << 20)
-#define kFix3HashSize (kHash2Size)
-#define kFix4HashSize (kHash2Size + kHash3Size)
-#define kFix5HashSize (kHash2Size + kHash3Size + kHash4Size)
+#define kFix3HashSize (kHash2Size)
+#define kFix4HashSize (kHash2Size + kHash3Size)
+#define kFix5HashSize (kHash2Size + kHash3Size + kHash4Size)
-#define HASH2_CALC hv = cur[0] | ((UInt32)cur[1] << 8);
+#define HASH2_CALC hv = cur[0] | ((UInt32)cur[1] << 8);
-#define HASH3_CALC { \
+#define HASH3_CALC {\
UInt32 temp = p->crc[cur[0]] ^ cur[1]; \
h2 = temp & (kHash2Size - 1); \
hv = (temp ^ ((UInt32)cur[2] << 8)) & p->hashMask; }
-#define HASH4_CALC { \
+#define HASH4_CALC {\
UInt32 temp = p->crc[cur[0]] ^ cur[1]; \
h2 = temp & (kHash2Size - 1); \
temp ^= ((UInt32)cur[2] << 8); \
h3 = temp & (kHash3Size - 1); \
hv = (temp ^ (p->crc[cur[3]] << 5)) & p->hashMask; }
-#define HASH5_CALC { \
+#define HASH5_CALC {\
UInt32 temp = p->crc[cur[0]] ^ cur[1]; \
h2 = temp & (kHash2Size - 1); \
temp ^= ((UInt32)cur[2] << 8); \
@@ -36,18 +36,17 @@ hv = (temp ^ (p->crc[cur[4]] << 3)) & p->hashMask; }
/* #define HASH_ZIP_CALC hv = ((cur[0] | ((UInt32)cur[1] << 8)) ^ p->crc[cur[2]]) & 0xFFFF; */
-#define HASH_ZIP_CALC hv = ((cur[2] | ((UInt32)cur[0] << 8)) ^ p->crc[cur[1]]) & 0xFFFF;
-
+#define HASH_ZIP_CALC hv = ((cur[2] | ((UInt32)cur[0] << 8)) ^ p->crc[cur[1]]) & 0xFFFF;
#define MT_HASH2_CALC \
h2 = (p->crc[cur[0]] ^ cur[1]) & (kHash2Size - 1);
-#define MT_HASH3_CALC { \
+#define MT_HASH3_CALC {\
UInt32 temp = p->crc[cur[0]] ^ cur[1]; \
h2 = temp & (kHash2Size - 1); \
h3 = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); }
-#define MT_HASH4_CALC { \
+#define MT_HASH4_CALC {\
UInt32 temp = p->crc[cur[0]] ^ cur[1]; \
h2 = temp & (kHash2Size - 1); \
temp ^= ((UInt32)cur[2] << 8); \
diff --git a/MdeModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/LzmaDec.c b/MdeModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/LzmaDec.c index 80fb74525a..54c7077984 100644 --- a/MdeModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/LzmaDec.c +++ b/MdeModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/LzmaDec.c @@ -4,38 +4,38 @@ #include "Precomp.h"
#ifndef EFIAPI
-#include <string.h>
+ #include <string.h>
#endif
/* #include "CpuArch.h" */
#include "LzmaDec.h"
-#define kNumTopBits 24
-#define kTopValue ((UInt32)1 << kNumTopBits)
+#define kNumTopBits 24
+#define kTopValue ((UInt32)1 << kNumTopBits)
-#define kNumBitModelTotalBits 11
-#define kBitModelTotal (1 << kNumBitModelTotalBits)
-#define kNumMoveBits 5
+#define kNumBitModelTotalBits 11
+#define kBitModelTotal (1 << kNumBitModelTotalBits)
+#define kNumMoveBits 5
-#define RC_INIT_SIZE 5
+#define RC_INIT_SIZE 5
-#define NORMALIZE if (range < kTopValue) { range <<= 8; code = (code << 8) | (*buf++); }
+#define NORMALIZE if (range < kTopValue) { range <<= 8; code = (code << 8) | (*buf++); }
-#define IF_BIT_0(p) ttt = *(p); NORMALIZE; bound = (range >> kNumBitModelTotalBits) * (UInt32)ttt; if (code < bound)
-#define UPDATE_0(p) range = bound; *(p) = (CLzmaProb)(ttt + ((kBitModelTotal - ttt) >> kNumMoveBits));
-#define UPDATE_1(p) range -= bound; code -= bound; *(p) = (CLzmaProb)(ttt - (ttt >> kNumMoveBits));
-#define GET_BIT2(p, i, A0, A1) IF_BIT_0(p) \
+#define IF_BIT_0(p) ttt = *(p); NORMALIZE; bound = (range >> kNumBitModelTotalBits) * (UInt32)ttt; if (code < bound)
+#define UPDATE_0(p) range = bound; *(p) = (CLzmaProb)(ttt + ((kBitModelTotal - ttt) >> kNumMoveBits));
+#define UPDATE_1(p) range -= bound; code -= bound; *(p) = (CLzmaProb)(ttt - (ttt >> kNumMoveBits));
+#define GET_BIT2(p, i, A0, A1) IF_BIT_0(p)\
{ UPDATE_0(p); i = (i + i); A0; } else \
{ UPDATE_1(p); i = (i + i) + 1; A1; }
-#define TREE_GET_BIT(probs, i) { GET_BIT2(probs + i, i, ;, ;); }
+#define TREE_GET_BIT(probs, i) { GET_BIT2(probs + i, i, ;, ;); }
-#define REV_BIT(p, i, A0, A1) IF_BIT_0(p + i) \
+#define REV_BIT(p, i, A0, A1) IF_BIT_0(p + i)\
{ UPDATE_0(p + i); A0; } else \
{ UPDATE_1(p + i); A1; }
-#define REV_BIT_VAR( p, i, m) REV_BIT(p, i, i += m; m += m, m += m; i += m; )
-#define REV_BIT_CONST(p, i, m) REV_BIT(p, i, i += m; , i += m * 2; )
-#define REV_BIT_LAST( p, i, m) REV_BIT(p, i, i -= m , ; )
+#define REV_BIT_VAR(p, i, m) REV_BIT(p, i, i += m; m += m, m += m; i += m; )
+#define REV_BIT_CONST(p, i, m) REV_BIT(p, i, i += m; , i += m * 2; )
+#define REV_BIT_LAST(p, i, m) REV_BIT(p, i, i -= m , ; )
#define TREE_DECODE(probs, limit, i) \
{ i = 1; do { TREE_GET_BIT(probs, i); } while (i < limit); i -= limit; }
@@ -43,7 +43,7 @@ /* #define _LZMA_SIZE_OPT */
#ifdef _LZMA_SIZE_OPT
-#define TREE_6_DECODE(probs, i) TREE_DECODE(probs, (1 << 6), i)
+#define TREE_6_DECODE(probs, i) TREE_DECODE(probs, (1 << 6), i)
#else
#define TREE_6_DECODE(probs, i) \
{ i = 1; \
@@ -56,7 +56,7 @@ i -= 0x40; }
#endif
-#define NORMAL_LITER_DEC TREE_GET_BIT(prob, symbol)
+#define NORMAL_LITER_DEC TREE_GET_BIT(prob, symbol)
#define MATCHED_LITER_DEC \
matchByte += matchByte; \
bit = offs; \
@@ -64,66 +64,64 @@ probLit = prob + (offs + bit + symbol); \
GET_BIT2(probLit, symbol, offs ^= bit; , ;)
+#define NORMALIZE_CHECK if (range < kTopValue) { if (buf >= bufLimit) return DUMMY_ERROR; range <<= 8; code = (code << 8) | (*buf++); }
-
-#define NORMALIZE_CHECK if (range < kTopValue) { if (buf >= bufLimit) return DUMMY_ERROR; range <<= 8; code = (code << 8) | (*buf++); }
-
-#define IF_BIT_0_CHECK(p) ttt = *(p); NORMALIZE_CHECK; bound = (range >> kNumBitModelTotalBits) * (UInt32)ttt; if (code < bound)
-#define UPDATE_0_CHECK range = bound;
-#define UPDATE_1_CHECK range -= bound; code -= bound;
-#define GET_BIT2_CHECK(p, i, A0, A1) IF_BIT_0_CHECK(p) \
+#define IF_BIT_0_CHECK(p) ttt = *(p); NORMALIZE_CHECK; bound = (range >> kNumBitModelTotalBits) * (UInt32)ttt; if (code < bound)
+#define UPDATE_0_CHECK range = bound;
+#define UPDATE_1_CHECK range -= bound; code -= bound;
+#define GET_BIT2_CHECK(p, i, A0, A1) IF_BIT_0_CHECK(p)\
{ UPDATE_0_CHECK; i = (i + i); A0; } else \
{ UPDATE_1_CHECK; i = (i + i) + 1; A1; }
-#define GET_BIT_CHECK(p, i) GET_BIT2_CHECK(p, i, ; , ;)
+#define GET_BIT_CHECK(p, i) GET_BIT2_CHECK(p, i, ; , ;)
#define TREE_DECODE_CHECK(probs, limit, i) \
{ i = 1; do { GET_BIT_CHECK(probs + i, i) } while (i < limit); i -= limit; }
-
-#define REV_BIT_CHECK(p, i, m) IF_BIT_0_CHECK(p + i) \
+#define REV_BIT_CHECK(p, i, m) IF_BIT_0_CHECK(p + i)\
{ UPDATE_0_CHECK; i += m; m += m; } else \
{ UPDATE_1_CHECK; m += m; i += m; }
+#define kNumPosBitsMax 4
+#define kNumPosStatesMax (1 << kNumPosBitsMax)
-#define kNumPosBitsMax 4
-#define kNumPosStatesMax (1 << kNumPosBitsMax)
-
-#define kLenNumLowBits 3
-#define kLenNumLowSymbols (1 << kLenNumLowBits)
-#define kLenNumHighBits 8
-#define kLenNumHighSymbols (1 << kLenNumHighBits)
+#define kLenNumLowBits 3
+#define kLenNumLowSymbols (1 << kLenNumLowBits)
+#define kLenNumHighBits 8
+#define kLenNumHighSymbols (1 << kLenNumHighBits)
-#define LenLow 0
-#define LenHigh (LenLow + 2 * (kNumPosStatesMax << kLenNumLowBits))
-#define kNumLenProbs (LenHigh + kLenNumHighSymbols)
+#define LenLow 0
+#define LenHigh (LenLow + 2 * (kNumPosStatesMax << kLenNumLowBits))
+#define kNumLenProbs (LenHigh + kLenNumHighSymbols)
-#define LenChoice LenLow
-#define LenChoice2 (LenLow + (1 << kLenNumLowBits))
+#define LenChoice LenLow
+#define LenChoice2 (LenLow + (1 << kLenNumLowBits))
-#define kNumStates 12
-#define kNumStates2 16
-#define kNumLitStates 7
+#define kNumStates 12
+#define kNumStates2 16
+#define kNumLitStates 7
-#define kStartPosModelIndex 4
-#define kEndPosModelIndex 14
-#define kNumFullDistances (1 << (kEndPosModelIndex >> 1))
+#define kStartPosModelIndex 4
+#define kEndPosModelIndex 14
+#define kNumFullDistances (1 << (kEndPosModelIndex >> 1))
-#define kNumPosSlotBits 6
-#define kNumLenToPosStates 4
+#define kNumPosSlotBits 6
+#define kNumLenToPosStates 4
-#define kNumAlignBits 4
-#define kAlignTableSize (1 << kNumAlignBits)
+#define kNumAlignBits 4
+#define kAlignTableSize (1 << kNumAlignBits)
-#define kMatchMinLen 2
-#define kMatchSpecLenStart (kMatchMinLen + kLenNumLowSymbols * 2 + kLenNumHighSymbols)
+#define kMatchMinLen 2
+#define kMatchSpecLenStart (kMatchMinLen + kLenNumLowSymbols * 2 + kLenNumHighSymbols)
/* External ASM code needs same CLzmaProb array layout. So don't change it. */
/* (probs_1664) is faster and better for code size at some platforms */
+
/*
#ifdef MY_CPU_X86_OR_AMD64
*/
-#define kStartOffset 1664
-#define GET_PROBS p->probs_1664
+#define kStartOffset 1664
+#define GET_PROBS p->probs_1664
+
/*
#define GET_PROBS p->probs + kStartOffset
#else
@@ -132,19 +130,19 @@ #endif
*/
-#define SpecPos (-kStartOffset)
-#define IsRep0Long (SpecPos + kNumFullDistances)
-#define RepLenCoder (IsRep0Long + (kNumStates2 << kNumPosBitsMax))
-#define LenCoder (RepLenCoder + kNumLenProbs)
-#define IsMatch (LenCoder + kNumLenProbs)
-#define Align (IsMatch + (kNumStates2 << kNumPosBitsMax))
-#define IsRep (Align + kAlignTableSize)
-#define IsRepG0 (IsRep + kNumStates)
-#define IsRepG1 (IsRepG0 + kNumStates)
-#define IsRepG2 (IsRepG1 + kNumStates)
-#define PosSlot (IsRepG2 + kNumStates)
-#define Literal (PosSlot + (kNumLenToPosStates << kNumPosSlotBits))
-#define NUM_BASE_PROBS (Literal + kStartOffset)
+#define SpecPos (-kStartOffset)
+#define IsRep0Long (SpecPos + kNumFullDistances)
+#define RepLenCoder (IsRep0Long + (kNumStates2 << kNumPosBitsMax))
+#define LenCoder (RepLenCoder + kNumLenProbs)
+#define IsMatch (LenCoder + kNumLenProbs)
+#define Align (IsMatch + (kNumStates2 << kNumPosBitsMax))
+#define IsRep (Align + kAlignTableSize)
+#define IsRepG0 (IsRep + kNumStates)
+#define IsRepG1 (IsRepG0 + kNumStates)
+#define IsRepG2 (IsRepG1 + kNumStates)
+#define PosSlot (IsRepG2 + kNumStates)
+#define Literal (PosSlot + (kNumLenToPosStates << kNumPosSlotBits))
+#define NUM_BASE_PROBS (Literal + kStartOffset)
#if Align != 0 && kStartOffset != 0
#error Stop_Compiling_Bad_LZMA_kAlign
@@ -154,17 +152,15 @@ #error Stop_Compiling_Bad_LZMA_PROBS
#endif
+#define LZMA_LIT_SIZE 0x300
-#define LZMA_LIT_SIZE 0x300
-
-#define LzmaProps_GetNumProbs(p) (NUM_BASE_PROBS + ((UInt32)LZMA_LIT_SIZE << ((p)->lc + (p)->lp)))
-
+#define LzmaProps_GetNumProbs(p) (NUM_BASE_PROBS + ((UInt32)LZMA_LIT_SIZE << ((p)->lc + (p)->lp)))
-#define CALC_POS_STATE(processedPos, pbMask) (((processedPos) & (pbMask)) << 4)
-#define COMBINED_PS_STATE (posState + state)
-#define GET_LEN_STATE (posState)
+#define CALC_POS_STATE(processedPos, pbMask) (((processedPos) & (pbMask)) << 4)
+#define COMBINED_PS_STATE (posState + state)
+#define GET_LEN_STATE (posState)
-#define LZMA_DIC_MIN (1 << 12)
+#define LZMA_DIC_MIN (1 << 12)
/*
p->remainLen : shows status of LZMA decoder:
@@ -175,12 +171,13 @@ p->remainLen : shows status of LZMA decoder: */
/* ---------- LZMA_DECODE_REAL ---------- */
+
/*
LzmaDec_DecodeReal_3() can be implemented in external ASM file.
3 - is the code compatibility version of that function for check at link time.
*/
-#define LZMA_DECODE_REAL LzmaDec_DecodeReal_3
+#define LZMA_DECODE_REAL LzmaDec_DecodeReal_3
/*
LZMA_DECODE_REAL()
@@ -209,60 +206,71 @@ Out: = kMatchSpecLenStart : finished
*/
-
#ifdef _LZMA_DEC_OPT
-int MY_FAST_CALL LZMA_DECODE_REAL(CLzmaDec *p, SizeT limit, const Byte *bufLimit);
+int MY_FAST_CALL
+LZMA_DECODE_REAL (
+ CLzmaDec *p,
+ SizeT limit,
+ const Byte *bufLimit
+ );
#else
static
-int MY_FAST_CALL LZMA_DECODE_REAL(CLzmaDec *p, SizeT limit, const Byte *bufLimit)
+int MY_FAST_CALL
+LZMA_DECODE_REAL (
+ CLzmaDec *p,
+ SizeT limit,
+ const Byte *bufLimit
+ )
{
- CLzmaProb *probs = GET_PROBS;
- unsigned state = (unsigned)p->state;
- UInt32 rep0 = p->reps[0], rep1 = p->reps[1], rep2 = p->reps[2], rep3 = p->reps[3];
- unsigned pbMask = ((unsigned)1 << (p->prop.pb)) - 1;
- unsigned lc = p->prop.lc;
- unsigned lpMask = ((unsigned)0x100 << p->prop.lp) - ((unsigned)0x100 >> lc);
-
- Byte *dic = p->dic;
- SizeT dicBufSize = p->dicBufSize;
- SizeT dicPos = p->dicPos;
-
- UInt32 processedPos = p->processedPos;
- UInt32 checkDicSize = p->checkDicSize;
- unsigned len = 0;
-
- const Byte *buf = p->buf;
- UInt32 range = p->range;
- UInt32 code = p->code;
-
- do
- {
- CLzmaProb *prob;
- UInt32 bound;
- unsigned ttt;
- unsigned posState = CALC_POS_STATE(processedPos, pbMask);
+ CLzmaProb *probs = GET_PROBS;
+ unsigned state = (unsigned)p->state;
+ UInt32 rep0 = p->reps[0], rep1 = p->reps[1], rep2 = p->reps[2], rep3 = p->reps[3];
+ unsigned pbMask = ((unsigned)1 << (p->prop.pb)) - 1;
+ unsigned lc = p->prop.lc;
+ unsigned lpMask = ((unsigned)0x100 << p->prop.lp) - ((unsigned)0x100 >> lc);
+
+ Byte *dic = p->dic;
+ SizeT dicBufSize = p->dicBufSize;
+ SizeT dicPos = p->dicPos;
+
+ UInt32 processedPos = p->processedPos;
+ UInt32 checkDicSize = p->checkDicSize;
+ unsigned len = 0;
+
+ const Byte *buf = p->buf;
+ UInt32 range = p->range;
+ UInt32 code = p->code;
+
+ do {
+ CLzmaProb *prob;
+ UInt32 bound;
+ unsigned ttt;
+ unsigned posState = CALC_POS_STATE (processedPos, pbMask);
prob = probs + IsMatch + COMBINED_PS_STATE;
- IF_BIT_0(prob)
- {
- unsigned symbol;
- UPDATE_0(prob);
+ IF_BIT_0 (prob) {
+ unsigned symbol;
+
+ UPDATE_0 (prob);
prob = probs + Literal;
- if (processedPos != 0 || checkDicSize != 0)
+ if ((processedPos != 0) || (checkDicSize != 0)) {
prob += (UInt32)3 * ((((processedPos << 8) + dic[(dicPos == 0 ? dicBufSize : dicPos) - 1]) & lpMask) << lc);
+ }
+
processedPos++;
- if (state < kNumLitStates)
- {
+ if (state < kNumLitStates) {
state -= (state < 4) ? state : 3;
symbol = 1;
- #ifdef _LZMA_SIZE_OPT
- do { NORMAL_LITER_DEC } while (symbol < 0x100);
- #else
- NORMAL_LITER_DEC
+ #ifdef _LZMA_SIZE_OPT
+ do {
+ NORMAL_LITER_DEC
+ } while (symbol < 0x100);
+
+ #else
NORMAL_LITER_DEC
NORMAL_LITER_DEC
NORMAL_LITER_DEC
@@ -270,27 +278,24 @@ int MY_FAST_CALL LZMA_DECODE_REAL(CLzmaDec *p, SizeT limit, const Byte *bufLimit NORMAL_LITER_DEC
NORMAL_LITER_DEC
NORMAL_LITER_DEC
- #endif
- }
- else
- {
- unsigned matchByte = dic[dicPos - rep0 + (dicPos < rep0 ? dicBufSize : 0)];
- unsigned offs = 0x100;
+ NORMAL_LITER_DEC
+ #endif
+ } else {
+ unsigned matchByte = dic[dicPos - rep0 + (dicPos < rep0 ? dicBufSize : 0)];
+ unsigned offs = 0x100;
state -= (state < 10) ? 3 : 6;
symbol = 1;
- #ifdef _LZMA_SIZE_OPT
- do
- {
- unsigned bit;
- CLzmaProb *probLit;
+ #ifdef _LZMA_SIZE_OPT
+ do {
+ unsigned bit;
+ CLzmaProb *probLit;
MATCHED_LITER_DEC
- }
- while (symbol < 0x100);
- #else
+ } while (symbol < 0x100);
+
+ #else
{
- unsigned bit;
- CLzmaProb *probLit;
- MATCHED_LITER_DEC
+ unsigned bit;
+ CLzmaProb *probLit;
MATCHED_LITER_DEC
MATCHED_LITER_DEC
MATCHED_LITER_DEC
@@ -298,8 +303,9 @@ int MY_FAST_CALL LZMA_DECODE_REAL(CLzmaDec *p, SizeT limit, const Byte *bufLimit MATCHED_LITER_DEC
MATCHED_LITER_DEC
MATCHED_LITER_DEC
+ MATCHED_LITER_DEC
}
- #endif
+ #endif
}
dic[dicPos++] = (Byte)symbol;
@@ -307,62 +313,50 @@ int MY_FAST_CALL LZMA_DECODE_REAL(CLzmaDec *p, SizeT limit, const Byte *bufLimit }
{
- UPDATE_1(prob);
+ UPDATE_1 (prob);
prob = probs + IsRep + state;
- IF_BIT_0(prob)
- {
- UPDATE_0(prob);
+ IF_BIT_0 (prob) {
+ UPDATE_0 (prob);
state += kNumStates;
- prob = probs + LenCoder;
- }
- else
- {
- UPDATE_1(prob);
+ prob = probs + LenCoder;
+ } else {
+ UPDATE_1 (prob);
+
/*
// that case was checked before with kBadRepCode
if (checkDicSize == 0 && processedPos == 0)
return SZ_ERROR_DATA;
*/
prob = probs + IsRepG0 + state;
- IF_BIT_0(prob)
- {
- UPDATE_0(prob);
+ IF_BIT_0 (prob) {
+ UPDATE_0 (prob);
prob = probs + IsRep0Long + COMBINED_PS_STATE;
- IF_BIT_0(prob)
- {
- UPDATE_0(prob);
+ IF_BIT_0 (prob) {
+ UPDATE_0 (prob);
dic[dicPos] = dic[dicPos - rep0 + (dicPos < rep0 ? dicBufSize : 0)];
dicPos++;
processedPos++;
state = state < kNumLitStates ? 9 : 11;
continue;
}
- UPDATE_1(prob);
- }
- else
- {
- UInt32 distance;
- UPDATE_1(prob);
+ UPDATE_1 (prob);
+ } else {
+ UInt32 distance;
+ UPDATE_1 (prob);
prob = probs + IsRepG1 + state;
- IF_BIT_0(prob)
- {
- UPDATE_0(prob);
+ IF_BIT_0 (prob) {
+ UPDATE_0 (prob);
distance = rep1;
- }
- else
- {
- UPDATE_1(prob);
+ } else {
+ UPDATE_1 (prob);
prob = probs + IsRepG2 + state;
- IF_BIT_0(prob)
- {
- UPDATE_0(prob);
+ IF_BIT_0 (prob) {
+ UPDATE_0 (prob);
distance = rep2;
- }
- else
- {
- UPDATE_1(prob);
+ } else {
+ UPDATE_1 (prob);
distance = rep3;
- rep3 = rep2;
+ rep3 = rep2;
}
rep2 = rep1;
}
@@ -370,120 +364,102 @@ int MY_FAST_CALL LZMA_DECODE_REAL(CLzmaDec *p, SizeT limit, const Byte *bufLimit rep0 = distance;
}
state = state < kNumLitStates ? 8 : 11;
- prob = probs + RepLenCoder;
+ prob = probs + RepLenCoder;
}
- #ifdef _LZMA_SIZE_OPT
+ #ifdef _LZMA_SIZE_OPT
{
- unsigned lim, offset;
- CLzmaProb *probLen = prob + LenChoice;
- IF_BIT_0(probLen)
- {
- UPDATE_0(probLen);
+ unsigned lim, offset;
+ CLzmaProb *probLen = prob + LenChoice;
+ IF_BIT_0 (probLen) {
+ UPDATE_0 (probLen);
probLen = prob + LenLow + GET_LEN_STATE;
- offset = 0;
- lim = (1 << kLenNumLowBits);
- }
- else
- {
- UPDATE_1(probLen);
+ offset = 0;
+ lim = (1 << kLenNumLowBits);
+ } else {
+ UPDATE_1 (probLen);
probLen = prob + LenChoice2;
- IF_BIT_0(probLen)
- {
- UPDATE_0(probLen);
+ IF_BIT_0 (probLen) {
+ UPDATE_0 (probLen);
probLen = prob + LenLow + GET_LEN_STATE + (1 << kLenNumLowBits);
- offset = kLenNumLowSymbols;
- lim = (1 << kLenNumLowBits);
- }
- else
- {
- UPDATE_1(probLen);
+ offset = kLenNumLowSymbols;
+ lim = (1 << kLenNumLowBits);
+ } else {
+ UPDATE_1 (probLen);
probLen = prob + LenHigh;
- offset = kLenNumLowSymbols * 2;
- lim = (1 << kLenNumHighBits);
+ offset = kLenNumLowSymbols * 2;
+ lim = (1 << kLenNumHighBits);
}
}
- TREE_DECODE(probLen, lim, len);
+ TREE_DECODE (probLen, lim, len);
len += offset;
}
- #else
+ #else
{
- CLzmaProb *probLen = prob + LenChoice;
- IF_BIT_0(probLen)
- {
- UPDATE_0(probLen);
+ CLzmaProb *probLen = prob + LenChoice;
+ IF_BIT_0 (probLen) {
+ UPDATE_0 (probLen);
probLen = prob + LenLow + GET_LEN_STATE;
- len = 1;
- TREE_GET_BIT(probLen, len);
- TREE_GET_BIT(probLen, len);
- TREE_GET_BIT(probLen, len);
+ len = 1;
+ TREE_GET_BIT (probLen, len);
+ TREE_GET_BIT (probLen, len);
+ TREE_GET_BIT (probLen, len);
len -= 8;
- }
- else
- {
- UPDATE_1(probLen);
+ } else {
+ UPDATE_1 (probLen);
probLen = prob + LenChoice2;
- IF_BIT_0(probLen)
- {
- UPDATE_0(probLen);
+ IF_BIT_0 (probLen) {
+ UPDATE_0 (probLen);
probLen = prob + LenLow + GET_LEN_STATE + (1 << kLenNumLowBits);
- len = 1;
- TREE_GET_BIT(probLen, len);
- TREE_GET_BIT(probLen, len);
- TREE_GET_BIT(probLen, len);
- }
- else
- {
- UPDATE_1(probLen);
+ len = 1;
+ TREE_GET_BIT (probLen, len);
+ TREE_GET_BIT (probLen, len);
+ TREE_GET_BIT (probLen, len);
+ } else {
+ UPDATE_1 (probLen);
probLen = prob + LenHigh;
- TREE_DECODE(probLen, (1 << kLenNumHighBits), len);
+ TREE_DECODE (probLen, (1 << kLenNumHighBits), len);
len += kLenNumLowSymbols * 2;
}
}
}
- #endif
+ #endif
- if (state >= kNumStates)
- {
- UInt32 distance;
+ if (state >= kNumStates) {
+ UInt32 distance;
prob = probs + PosSlot +
- ((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) << kNumPosSlotBits);
- TREE_6_DECODE(prob, distance);
- if (distance >= kStartPosModelIndex)
- {
- unsigned posSlot = (unsigned)distance;
- unsigned numDirectBits = (unsigned)(((distance >> 1) - 1));
+ ((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) << kNumPosSlotBits);
+ TREE_6_DECODE (prob, distance);
+ if (distance >= kStartPosModelIndex) {
+ unsigned posSlot = (unsigned)distance;
+ unsigned numDirectBits = (unsigned)(((distance >> 1) - 1));
distance = (2 | (distance & 1));
- if (posSlot < kEndPosModelIndex)
- {
+ if (posSlot < kEndPosModelIndex) {
distance <<= numDirectBits;
- prob = probs + SpecPos;
+ prob = probs + SpecPos;
{
- UInt32 m = 1;
+ UInt32 m = 1;
distance++;
- do
- {
- REV_BIT_VAR(prob, distance, m);
- }
- while (--numDirectBits);
+ do {
+ REV_BIT_VAR (prob, distance, m);
+ } while (--numDirectBits);
+
distance -= m;
}
- }
- else
- {
+ } else {
numDirectBits -= kNumAlignBits;
- do
- {
+ do {
NORMALIZE
- range >>= 1;
+ range >>= 1;
{
- UInt32 t;
- code -= range;
- t = (0 - ((UInt32)code >> 31)); /* (UInt32)((Int32)code >> 31) */
+ UInt32 t;
+ code -= range;
+ t = (0 - ((UInt32)code >> 31)); /* (UInt32)((Int32)code >> 31) */
distance = (distance << 1) + (t + 1);
- code += range & t;
+ code += range & t;
}
+
/*
distance <<= 1;
if (code >= range)
@@ -492,34 +468,32 @@ int MY_FAST_CALL LZMA_DECODE_REAL(CLzmaDec *p, SizeT limit, const Byte *bufLimit distance |= 1;
}
*/
- }
- while (--numDirectBits);
- prob = probs + Align;
+ } while (--numDirectBits);
+
+ prob = probs + Align;
distance <<= kNumAlignBits;
{
- unsigned i = 1;
- REV_BIT_CONST(prob, i, 1);
- REV_BIT_CONST(prob, i, 2);
- REV_BIT_CONST(prob, i, 4);
+ unsigned i = 1;
+ REV_BIT_CONST (prob, i, 1);
+ REV_BIT_CONST (prob, i, 2);
+ REV_BIT_CONST (prob, i, 4);
REV_BIT_LAST (prob, i, 8);
distance |= i;
}
- if (distance == (UInt32)0xFFFFFFFF)
- {
- len = kMatchSpecLenStart;
+ if (distance == (UInt32)0xFFFFFFFF) {
+ len = kMatchSpecLenStart;
state -= kNumStates;
break;
}
}
}
- rep3 = rep2;
- rep2 = rep1;
- rep1 = rep0;
- rep0 = distance + 1;
+ rep3 = rep2;
+ rep2 = rep1;
+ rep1 = rep0;
+ rep0 = distance + 1;
state = (state < kNumStates + kNumLitStates) ? kNumLitStates : kNumLitStates + 3;
- if (distance >= (checkDicSize == 0 ? processedPos: checkDicSize))
- {
+ if (distance >= ((checkDicSize == 0) ? processedPos : checkDicSize)) {
p->dicPos = dicPos;
return SZ_ERROR_DATA;
}
@@ -528,660 +502,740 @@ int MY_FAST_CALL LZMA_DECODE_REAL(CLzmaDec *p, SizeT limit, const Byte *bufLimit len += kMatchMinLen;
{
- SizeT rem;
- unsigned curLen;
- SizeT pos;
+ SizeT rem;
+ unsigned curLen;
+ SizeT pos;
- if ((rem = limit - dicPos) == 0)
- {
+ if ((rem = limit - dicPos) == 0) {
p->dicPos = dicPos;
return SZ_ERROR_DATA;
}
curLen = ((rem < len) ? (unsigned)rem : len);
- pos = dicPos - rep0 + (dicPos < rep0 ? dicBufSize : 0);
+ pos = dicPos - rep0 + (dicPos < rep0 ? dicBufSize : 0);
processedPos += (UInt32)curLen;
len -= curLen;
- if (curLen <= dicBufSize - pos)
- {
- Byte *dest = dic + dicPos;
- ptrdiff_t src = (ptrdiff_t)pos - (ptrdiff_t)dicPos;
- const Byte *lim = dest + curLen;
+ if (curLen <= dicBufSize - pos) {
+ Byte *dest = dic + dicPos;
+ ptrdiff_t src = (ptrdiff_t)pos - (ptrdiff_t)dicPos;
+ const Byte *lim = dest + curLen;
dicPos += (SizeT)curLen;
- do
+ do {
*(dest) = (Byte)*(dest + src);
- while (++dest != lim);
- }
- else
- {
- do
- {
+ } while (++dest != lim);
+ } else {
+ do {
dic[dicPos++] = dic[pos];
- if (++pos == dicBufSize)
+ if (++pos == dicBufSize) {
pos = 0;
- }
- while (--curLen != 0);
+ }
+ } while (--curLen != 0);
}
}
}
- }
- while (dicPos < limit && buf < bufLimit);
+ } while (dicPos < limit && buf < bufLimit);
NORMALIZE;
- p->buf = buf;
- p->range = range;
- p->code = code;
- p->remainLen = (UInt32)len;
- p->dicPos = dicPos;
+ p->buf = buf;
+ p->range = range;
+ p->code = code;
+ p->remainLen = (UInt32)len;
+ p->dicPos = dicPos;
p->processedPos = processedPos;
- p->reps[0] = rep0;
- p->reps[1] = rep1;
- p->reps[2] = rep2;
- p->reps[3] = rep3;
- p->state = (UInt32)state;
+ p->reps[0] = rep0;
+ p->reps[1] = rep1;
+ p->reps[2] = rep2;
+ p->reps[3] = rep3;
+ p->state = (UInt32)state;
return SZ_OK;
}
+
#endif
-static void MY_FAST_CALL LzmaDec_WriteRem(CLzmaDec *p, SizeT limit)
+static void MY_FAST_CALL
+LzmaDec_WriteRem (
+ CLzmaDec *p,
+ SizeT limit
+ )
{
- if (p->remainLen != 0 && p->remainLen < kMatchSpecLenStart)
- {
- Byte *dic = p->dic;
- SizeT dicPos = p->dicPos;
- SizeT dicBufSize = p->dicBufSize;
- unsigned len = (unsigned)p->remainLen;
- SizeT rep0 = p->reps[0]; /* we use SizeT to avoid the BUG of VC14 for AMD64 */
- SizeT rem = limit - dicPos;
- if (rem < len)
+ if ((p->remainLen != 0) && (p->remainLen < kMatchSpecLenStart)) {
+ Byte *dic = p->dic;
+ SizeT dicPos = p->dicPos;
+ SizeT dicBufSize = p->dicBufSize;
+ unsigned len = (unsigned)p->remainLen;
+ SizeT rep0 = p->reps[0]; /* we use SizeT to avoid the BUG of VC14 for AMD64 */
+ SizeT rem = limit - dicPos;
+ if (rem < len) {
len = (unsigned)(rem);
+ }
- if (p->checkDicSize == 0 && p->prop.dicSize - p->processedPos <= len)
+ if ((p->checkDicSize == 0) && (p->prop.dicSize - p->processedPos <= len)) {
p->checkDicSize = p->prop.dicSize;
+ }
p->processedPos += (UInt32)len;
- p->remainLen -= (UInt32)len;
- while (len != 0)
- {
+ p->remainLen -= (UInt32)len;
+ while (len != 0) {
len--;
dic[dicPos] = dic[dicPos - rep0 + (dicPos < rep0 ? dicBufSize : 0)];
dicPos++;
}
+
p->dicPos = dicPos;
}
}
-
-#define kRange0 0xFFFFFFFF
-#define kBound0 ((kRange0 >> kNumBitModelTotalBits) << (kNumBitModelTotalBits - 1))
-#define kBadRepCode (kBound0 + (((kRange0 - kBound0) >> kNumBitModelTotalBits) << (kNumBitModelTotalBits - 1)))
+#define kRange0 0xFFFFFFFF
+#define kBound0 ((kRange0 >> kNumBitModelTotalBits) << (kNumBitModelTotalBits - 1))
+#define kBadRepCode (kBound0 + (((kRange0 - kBound0) >> kNumBitModelTotalBits) << (kNumBitModelTotalBits - 1)))
#if kBadRepCode != (0xC0000000 - 0x400)
#error Stop_Compiling_Bad_LZMA_Check
#endif
-static int MY_FAST_CALL LzmaDec_DecodeReal2(CLzmaDec *p, SizeT limit, const Byte *bufLimit)
+static int MY_FAST_CALL
+LzmaDec_DecodeReal2 (
+ CLzmaDec *p,
+ SizeT limit,
+ const Byte *bufLimit
+ )
{
- do
- {
- SizeT limit2 = limit;
- if (p->checkDicSize == 0)
- {
- UInt32 rem = p->prop.dicSize - p->processedPos;
- if (limit - p->dicPos > rem)
+ do {
+ SizeT limit2 = limit;
+ if (p->checkDicSize == 0) {
+ UInt32 rem = p->prop.dicSize - p->processedPos;
+ if (limit - p->dicPos > rem) {
limit2 = p->dicPos + rem;
+ }
- if (p->processedPos == 0)
- if (p->code >= kBadRepCode)
+ if (p->processedPos == 0) {
+ if (p->code >= kBadRepCode) {
return SZ_ERROR_DATA;
+ }
+ }
}
- RINOK(LZMA_DECODE_REAL(p, limit2, bufLimit));
+ RINOK (LZMA_DECODE_REAL (p, limit2, bufLimit));
- if (p->checkDicSize == 0 && p->processedPos >= p->prop.dicSize)
+ if ((p->checkDicSize == 0) && (p->processedPos >= p->prop.dicSize)) {
p->checkDicSize = p->prop.dicSize;
+ }
- LzmaDec_WriteRem(p, limit);
- }
- while (p->dicPos < limit && p->buf < bufLimit && p->remainLen < kMatchSpecLenStart);
+ LzmaDec_WriteRem (p, limit);
+ } while (p->dicPos < limit && p->buf < bufLimit && p->remainLen < kMatchSpecLenStart);
return 0;
}
-typedef enum
-{
+typedef enum {
DUMMY_ERROR, /* unexpected end of input stream */
DUMMY_LIT,
DUMMY_MATCH,
DUMMY_REP
} ELzmaDummy;
-static ELzmaDummy LzmaDec_TryDummy(const CLzmaDec *p, const Byte *buf, SizeT inSize)
+static ELzmaDummy
+LzmaDec_TryDummy (
+ const CLzmaDec *p,
+ const Byte *buf,
+ SizeT inSize
+ )
{
- UInt32 range = p->range;
- UInt32 code = p->code;
- const Byte *bufLimit = buf + inSize;
- const CLzmaProb *probs = GET_PROBS;
- unsigned state = (unsigned)p->state;
- ELzmaDummy res;
+ UInt32 range = p->range;
+ UInt32 code = p->code;
+ const Byte *bufLimit = buf + inSize;
+ const CLzmaProb *probs = GET_PROBS;
+ unsigned state = (unsigned)p->state;
+ ELzmaDummy res;
{
- const CLzmaProb *prob;
- UInt32 bound;
- unsigned ttt;
- unsigned posState = CALC_POS_STATE(p->processedPos, (1 << p->prop.pb) - 1);
+ const CLzmaProb *prob;
+ UInt32 bound;
+ unsigned ttt;
+ unsigned posState = CALC_POS_STATE (p->processedPos, (1 << p->prop.pb) - 1);
prob = probs + IsMatch + COMBINED_PS_STATE;
- IF_BIT_0_CHECK(prob)
- {
+ IF_BIT_0_CHECK (prob) {
UPDATE_0_CHECK
/* if (bufLimit - buf >= 7) return DUMMY_LIT; */
- prob = probs + Literal;
- if (p->checkDicSize != 0 || p->processedPos != 0)
- prob += ((UInt32)LZMA_LIT_SIZE *
- ((((p->processedPos) & ((1 << (p->prop.lp)) - 1)) << p->prop.lc) +
- (p->dic[(p->dicPos == 0 ? p->dicBufSize : p->dicPos) - 1] >> (8 - p->prop.lc))));
+ prob = probs + Literal;
- if (state < kNumLitStates)
- {
- unsigned symbol = 1;
- do { GET_BIT_CHECK(prob + symbol, symbol) } while (symbol < 0x100);
+ if ((p->checkDicSize != 0) || (p->processedPos != 0)) {
+ prob += ((UInt32)LZMA_LIT_SIZE *
+ ((((p->processedPos) & ((1 << (p->prop.lp)) - 1)) << p->prop.lc) +
+ (p->dic[(p->dicPos == 0 ? p->dicBufSize : p->dicPos) - 1] >> (8 - p->prop.lc))));
}
- else
- {
- unsigned matchByte = p->dic[p->dicPos - p->reps[0] +
- (p->dicPos < p->reps[0] ? p->dicBufSize : 0)];
- unsigned offs = 0x100;
- unsigned symbol = 1;
- do
- {
- unsigned bit;
- const CLzmaProb *probLit;
+
+ if (state < kNumLitStates) {
+ unsigned symbol = 1;
+ do {
+ GET_BIT_CHECK (prob + symbol, symbol)
+ } while (symbol < 0x100);
+ } else {
+ unsigned matchByte = p->dic[p->dicPos - p->reps[0] +
+ (p->dicPos < p->reps[0] ? p->dicBufSize : 0)];
+ unsigned offs = 0x100;
+ unsigned symbol = 1;
+ do {
+ unsigned bit;
+ const CLzmaProb *probLit;
matchByte += matchByte;
- bit = offs;
- offs &= matchByte;
- probLit = prob + (offs + bit + symbol);
- GET_BIT2_CHECK(probLit, symbol, offs ^= bit; , ; )
- }
- while (symbol < 0x100);
+ bit = offs;
+ offs &= matchByte;
+ probLit = prob + (offs + bit + symbol);
+ GET_BIT2_CHECK (
+ probLit,
+ symbol,
+ offs ^= bit;
+ ,
+ ;
+ )
+ } while (symbol < 0x100);
}
+
res = DUMMY_LIT;
- }
- else
- {
- unsigned len;
+ } else {
+ unsigned len;
UPDATE_1_CHECK;
prob = probs + IsRep + state;
- IF_BIT_0_CHECK(prob)
- {
+ IF_BIT_0_CHECK (prob) {
UPDATE_0_CHECK;
state = 0;
- prob = probs + LenCoder;
- res = DUMMY_MATCH;
- }
- else
- {
+ prob = probs + LenCoder;
+ res = DUMMY_MATCH;
+ } else {
UPDATE_1_CHECK;
- res = DUMMY_REP;
+ res = DUMMY_REP;
prob = probs + IsRepG0 + state;
- IF_BIT_0_CHECK(prob)
- {
+ IF_BIT_0_CHECK (prob) {
UPDATE_0_CHECK;
prob = probs + IsRep0Long + COMBINED_PS_STATE;
- IF_BIT_0_CHECK(prob)
- {
+ IF_BIT_0_CHECK (prob) {
UPDATE_0_CHECK;
NORMALIZE_CHECK;
return DUMMY_REP;
- }
- else
- {
+ } else {
UPDATE_1_CHECK;
}
- }
- else
- {
+ } else {
UPDATE_1_CHECK;
prob = probs + IsRepG1 + state;
- IF_BIT_0_CHECK(prob)
- {
+ IF_BIT_0_CHECK (prob) {
UPDATE_0_CHECK;
- }
- else
- {
+ } else {
UPDATE_1_CHECK;
prob = probs + IsRepG2 + state;
- IF_BIT_0_CHECK(prob)
- {
+ IF_BIT_0_CHECK (prob) {
UPDATE_0_CHECK;
- }
- else
- {
+ } else {
UPDATE_1_CHECK;
}
}
}
state = kNumStates;
- prob = probs + RepLenCoder;
+ prob = probs + RepLenCoder;
}
{
- unsigned limit, offset;
- const CLzmaProb *probLen = prob + LenChoice;
- IF_BIT_0_CHECK(probLen)
- {
+ unsigned limit, offset;
+ const CLzmaProb *probLen = prob + LenChoice;
+ IF_BIT_0_CHECK (probLen) {
UPDATE_0_CHECK;
probLen = prob + LenLow + GET_LEN_STATE;
- offset = 0;
- limit = 1 << kLenNumLowBits;
- }
- else
- {
+ offset = 0;
+ limit = 1 << kLenNumLowBits;
+ } else {
UPDATE_1_CHECK;
probLen = prob + LenChoice2;
- IF_BIT_0_CHECK(probLen)
- {
+ IF_BIT_0_CHECK (probLen) {
UPDATE_0_CHECK;
probLen = prob + LenLow + GET_LEN_STATE + (1 << kLenNumLowBits);
- offset = kLenNumLowSymbols;
- limit = 1 << kLenNumLowBits;
- }
- else
- {
+ offset = kLenNumLowSymbols;
+ limit = 1 << kLenNumLowBits;
+ } else {
UPDATE_1_CHECK;
probLen = prob + LenHigh;
- offset = kLenNumLowSymbols * 2;
- limit = 1 << kLenNumHighBits;
+ offset = kLenNumLowSymbols * 2;
+ limit = 1 << kLenNumHighBits;
}
}
- TREE_DECODE_CHECK(probLen, limit, len);
+ TREE_DECODE_CHECK (probLen, limit, len);
len += offset;
}
- if (state < 4)
- {
- unsigned posSlot;
+ if (state < 4) {
+ unsigned posSlot;
prob = probs + PosSlot +
- ((len < kNumLenToPosStates - 1 ? len : kNumLenToPosStates - 1) <<
- kNumPosSlotBits);
- TREE_DECODE_CHECK(prob, 1 << kNumPosSlotBits, posSlot);
- if (posSlot >= kStartPosModelIndex)
- {
- unsigned numDirectBits = ((posSlot >> 1) - 1);
+ ((len < kNumLenToPosStates - 1 ? len : kNumLenToPosStates - 1) <<
+ kNumPosSlotBits);
+ TREE_DECODE_CHECK (prob, 1 << kNumPosSlotBits, posSlot);
+ if (posSlot >= kStartPosModelIndex) {
+ unsigned numDirectBits = ((posSlot >> 1) - 1);
/* if (bufLimit - buf >= 8) return DUMMY_MATCH; */
- if (posSlot < kEndPosModelIndex)
- {
+ if (posSlot < kEndPosModelIndex) {
prob = probs + SpecPos + ((2 | (posSlot & 1)) << numDirectBits);
- }
- else
- {
+ } else {
numDirectBits -= kNumAlignBits;
- do
- {
+ do {
NORMALIZE_CHECK
- range >>= 1;
+ range >>= 1;
code -= range & (((code - range) >> 31) - 1);
/* if (code >= range) code -= range; */
- }
- while (--numDirectBits);
- prob = probs + Align;
+ } while (--numDirectBits);
+
+ prob = probs + Align;
numDirectBits = kNumAlignBits;
}
+
{
- unsigned i = 1;
- unsigned m = 1;
- do
- {
- REV_BIT_CHECK(prob, i, m);
- }
- while (--numDirectBits);
+ unsigned i = 1;
+ unsigned m = 1;
+ do {
+ REV_BIT_CHECK (prob, i, m);
+ } while (--numDirectBits);
}
}
}
}
}
+
NORMALIZE_CHECK;
return res;
}
-
-void LzmaDec_InitDicAndState(CLzmaDec *p, BoolInt initDic, BoolInt initState)
+void
+LzmaDec_InitDicAndState (
+ CLzmaDec *p,
+ BoolInt initDic,
+ BoolInt initState
+ )
{
- p->remainLen = kMatchSpecLenStart + 1;
+ p->remainLen = kMatchSpecLenStart + 1;
p->tempBufSize = 0;
- if (initDic)
- {
+ if (initDic) {
p->processedPos = 0;
p->checkDicSize = 0;
- p->remainLen = kMatchSpecLenStart + 2;
+ p->remainLen = kMatchSpecLenStart + 2;
}
- if (initState)
+
+ if (initState) {
p->remainLen = kMatchSpecLenStart + 2;
+ }
}
-void LzmaDec_Init(CLzmaDec *p)
+void
+LzmaDec_Init (
+ CLzmaDec *p
+ )
{
p->dicPos = 0;
- LzmaDec_InitDicAndState(p, True, True);
+ LzmaDec_InitDicAndState (p, True, True);
}
-
-SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit, const Byte *src, SizeT *srcLen,
- ELzmaFinishMode finishMode, ELzmaStatus *status)
+SRes
+LzmaDec_DecodeToDic (
+ CLzmaDec *p,
+ SizeT dicLimit,
+ const Byte *src,
+ SizeT *srcLen,
+ ELzmaFinishMode finishMode,
+ ELzmaStatus *status
+ )
{
- SizeT inSize = *srcLen;
+ SizeT inSize = *srcLen;
+
(*srcLen) = 0;
*status = LZMA_STATUS_NOT_SPECIFIED;
- if (p->remainLen > kMatchSpecLenStart)
- {
- for (; inSize > 0 && p->tempBufSize < RC_INIT_SIZE; (*srcLen)++, inSize--)
+ if (p->remainLen > kMatchSpecLenStart) {
+ for ( ; inSize > 0 && p->tempBufSize < RC_INIT_SIZE; (*srcLen)++, inSize--) {
p->tempBuf[p->tempBufSize++] = *src++;
- if (p->tempBufSize != 0 && p->tempBuf[0] != 0)
+ }
+
+ if ((p->tempBufSize != 0) && (p->tempBuf[0] != 0)) {
return SZ_ERROR_DATA;
- if (p->tempBufSize < RC_INIT_SIZE)
- {
+ }
+
+ if (p->tempBufSize < RC_INIT_SIZE) {
*status = LZMA_STATUS_NEEDS_MORE_INPUT;
return SZ_OK;
}
+
p->code =
- ((UInt32)p->tempBuf[1] << 24)
+ ((UInt32)p->tempBuf[1] << 24)
| ((UInt32)p->tempBuf[2] << 16)
| ((UInt32)p->tempBuf[3] << 8)
| ((UInt32)p->tempBuf[4]);
- p->range = 0xFFFFFFFF;
+ p->range = 0xFFFFFFFF;
p->tempBufSize = 0;
- if (p->remainLen > kMatchSpecLenStart + 1)
- {
- SizeT numProbs = LzmaProps_GetNumProbs(&p->prop);
- SizeT i;
- CLzmaProb *probs = p->probs;
- for (i = 0; i < numProbs; i++)
+ if (p->remainLen > kMatchSpecLenStart + 1) {
+ SizeT numProbs = LzmaProps_GetNumProbs (&p->prop);
+ SizeT i;
+ CLzmaProb *probs = p->probs;
+ for (i = 0; i < numProbs; i++) {
probs[i] = kBitModelTotal >> 1;
+ }
+
p->reps[0] = p->reps[1] = p->reps[2] = p->reps[3] = 1;
- p->state = 0;
+ p->state = 0;
}
p->remainLen = 0;
}
- LzmaDec_WriteRem(p, dicLimit);
+ LzmaDec_WriteRem (p, dicLimit);
- while (p->remainLen != kMatchSpecLenStart)
- {
- int checkEndMarkNow = 0;
+ while (p->remainLen != kMatchSpecLenStart) {
+ int checkEndMarkNow = 0;
- if (p->dicPos >= dicLimit)
- {
- if (p->remainLen == 0 && p->code == 0)
- {
- *status = LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK;
+ if (p->dicPos >= dicLimit) {
+ if ((p->remainLen == 0) && (p->code == 0)) {
+ *status = LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK;
+ return SZ_OK;
+ }
+
+ if (finishMode == LZMA_FINISH_ANY) {
+ *status = LZMA_STATUS_NOT_FINISHED;
+ return SZ_OK;
+ }
+
+ if (p->remainLen != 0) {
+ *status = LZMA_STATUS_NOT_FINISHED;
+ return SZ_ERROR_DATA;
+ }
+
+ checkEndMarkNow = 1;
+ }
+
+ if (p->tempBufSize == 0) {
+ SizeT processed;
+ const Byte *bufLimit;
+ if ((inSize < LZMA_REQUIRED_INPUT_MAX) || checkEndMarkNow) {
+ int dummyRes = LzmaDec_TryDummy (p, src, inSize);
+ if (dummyRes == DUMMY_ERROR) {
+ memcpy (p->tempBuf, src, inSize);
+ p->tempBufSize = (unsigned)inSize;
+ (*srcLen) += inSize;
+ *status = LZMA_STATUS_NEEDS_MORE_INPUT;
return SZ_OK;
}
- if (finishMode == LZMA_FINISH_ANY)
- {
+
+ if (checkEndMarkNow && (dummyRes != DUMMY_MATCH)) {
*status = LZMA_STATUS_NOT_FINISHED;
+ return SZ_ERROR_DATA;
+ }
+
+ bufLimit = src;
+ } else {
+ bufLimit = src + inSize - LZMA_REQUIRED_INPUT_MAX;
+ }
+
+ p->buf = src;
+ if (LzmaDec_DecodeReal2 (p, dicLimit, bufLimit) != 0) {
+ return SZ_ERROR_DATA;
+ }
+
+ processed = (SizeT)(p->buf - src);
+ (*srcLen) += processed;
+ src += processed;
+ inSize -= processed;
+ } else {
+ unsigned rem = p->tempBufSize, lookAhead = 0;
+ while (rem < LZMA_REQUIRED_INPUT_MAX && lookAhead < inSize) {
+ p->tempBuf[rem++] = src[lookAhead++];
+ }
+
+ p->tempBufSize = rem;
+ if ((rem < LZMA_REQUIRED_INPUT_MAX) || checkEndMarkNow) {
+ int dummyRes = LzmaDec_TryDummy (p, p->tempBuf, (SizeT)rem);
+ if (dummyRes == DUMMY_ERROR) {
+ (*srcLen) += (SizeT)lookAhead;
+ *status = LZMA_STATUS_NEEDS_MORE_INPUT;
return SZ_OK;
}
- if (p->remainLen != 0)
- {
+
+ if (checkEndMarkNow && (dummyRes != DUMMY_MATCH)) {
*status = LZMA_STATUS_NOT_FINISHED;
return SZ_ERROR_DATA;
}
- checkEndMarkNow = 1;
}
- if (p->tempBufSize == 0)
- {
- SizeT processed;
- const Byte *bufLimit;
- if (inSize < LZMA_REQUIRED_INPUT_MAX || checkEndMarkNow)
- {
- int dummyRes = LzmaDec_TryDummy(p, src, inSize);
- if (dummyRes == DUMMY_ERROR)
- {
- memcpy(p->tempBuf, src, inSize);
- p->tempBufSize = (unsigned)inSize;
- (*srcLen) += inSize;
- *status = LZMA_STATUS_NEEDS_MORE_INPUT;
- return SZ_OK;
- }
- if (checkEndMarkNow && dummyRes != DUMMY_MATCH)
- {
- *status = LZMA_STATUS_NOT_FINISHED;
- return SZ_ERROR_DATA;
- }
- bufLimit = src;
- }
- else
- bufLimit = src + inSize - LZMA_REQUIRED_INPUT_MAX;
- p->buf = src;
- if (LzmaDec_DecodeReal2(p, dicLimit, bufLimit) != 0)
- return SZ_ERROR_DATA;
- processed = (SizeT)(p->buf - src);
- (*srcLen) += processed;
- src += processed;
- inSize -= processed;
+ p->buf = p->tempBuf;
+ if (LzmaDec_DecodeReal2 (p, dicLimit, p->buf) != 0) {
+ return SZ_ERROR_DATA;
}
- else
+
{
- unsigned rem = p->tempBufSize, lookAhead = 0;
- while (rem < LZMA_REQUIRED_INPUT_MAX && lookAhead < inSize)
- p->tempBuf[rem++] = src[lookAhead++];
- p->tempBufSize = rem;
- if (rem < LZMA_REQUIRED_INPUT_MAX || checkEndMarkNow)
- {
- int dummyRes = LzmaDec_TryDummy(p, p->tempBuf, (SizeT)rem);
- if (dummyRes == DUMMY_ERROR)
- {
- (*srcLen) += (SizeT)lookAhead;
- *status = LZMA_STATUS_NEEDS_MORE_INPUT;
- return SZ_OK;
- }
- if (checkEndMarkNow && dummyRes != DUMMY_MATCH)
- {
- *status = LZMA_STATUS_NOT_FINISHED;
- return SZ_ERROR_DATA;
- }
+ unsigned kkk = (unsigned)(p->buf - p->tempBuf);
+ if (rem < kkk) {
+ return SZ_ERROR_FAIL; /* some internal error */
}
- p->buf = p->tempBuf;
- if (LzmaDec_DecodeReal2(p, dicLimit, p->buf) != 0)
- return SZ_ERROR_DATA;
- {
- unsigned kkk = (unsigned)(p->buf - p->tempBuf);
- if (rem < kkk)
- return SZ_ERROR_FAIL; /* some internal error */
- rem -= kkk;
- if (lookAhead < rem)
- return SZ_ERROR_FAIL; /* some internal error */
- lookAhead -= rem;
+ rem -= kkk;
+ if (lookAhead < rem) {
+ return SZ_ERROR_FAIL; /* some internal error */
}
- (*srcLen) += (SizeT)lookAhead;
- src += lookAhead;
- inSize -= (SizeT)lookAhead;
- p->tempBufSize = 0;
+
+ lookAhead -= rem;
}
+ (*srcLen) += (SizeT)lookAhead;
+ src += lookAhead;
+ inSize -= (SizeT)lookAhead;
+ p->tempBufSize = 0;
+ }
}
- if (p->code != 0)
+ if (p->code != 0) {
return SZ_ERROR_DATA;
+ }
+
*status = LZMA_STATUS_FINISHED_WITH_MARK;
return SZ_OK;
}
-
-SRes LzmaDec_DecodeToBuf(CLzmaDec *p, Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status)
+SRes
+LzmaDec_DecodeToBuf (
+ CLzmaDec *p,
+ Byte *dest,
+ SizeT *destLen,
+ const Byte *src,
+ SizeT *srcLen,
+ ELzmaFinishMode finishMode,
+ ELzmaStatus *status
+ )
{
- SizeT outSize = *destLen;
- SizeT inSize = *srcLen;
+ SizeT outSize = *destLen;
+ SizeT inSize = *srcLen;
+
*srcLen = *destLen = 0;
- for (;;)
- {
- SizeT inSizeCur = inSize, outSizeCur, dicPos;
- ELzmaFinishMode curFinishMode;
- SRes res;
- if (p->dicPos == p->dicBufSize)
+ for ( ; ;) {
+ SizeT inSizeCur = inSize, outSizeCur, dicPos;
+ ELzmaFinishMode curFinishMode;
+ SRes res;
+ if (p->dicPos == p->dicBufSize) {
p->dicPos = 0;
+ }
+
dicPos = p->dicPos;
- if (outSize > p->dicBufSize - dicPos)
- {
- outSizeCur = p->dicBufSize;
+ if (outSize > p->dicBufSize - dicPos) {
+ outSizeCur = p->dicBufSize;
curFinishMode = LZMA_FINISH_ANY;
- }
- else
- {
- outSizeCur = dicPos + outSize;
+ } else {
+ outSizeCur = dicPos + outSize;
curFinishMode = finishMode;
}
- res = LzmaDec_DecodeToDic(p, outSizeCur, src, &inSizeCur, curFinishMode, status);
- src += inSizeCur;
- inSize -= inSizeCur;
- *srcLen += inSizeCur;
+ res = LzmaDec_DecodeToDic (p, outSizeCur, src, &inSizeCur, curFinishMode, status);
+ src += inSizeCur;
+ inSize -= inSizeCur;
+ *srcLen += inSizeCur;
outSizeCur = p->dicPos - dicPos;
- memcpy(dest, p->dic + dicPos, outSizeCur);
- dest += outSizeCur;
- outSize -= outSizeCur;
+ memcpy (dest, p->dic + dicPos, outSizeCur);
+ dest += outSizeCur;
+ outSize -= outSizeCur;
*destLen += outSizeCur;
- if (res != 0)
+ if (res != 0) {
return res;
- if (outSizeCur == 0 || outSize == 0)
+ }
+
+ if ((outSizeCur == 0) || (outSize == 0)) {
return SZ_OK;
+ }
}
}
-void LzmaDec_FreeProbs(CLzmaDec *p, ISzAllocPtr alloc)
+void
+LzmaDec_FreeProbs (
+ CLzmaDec *p,
+ ISzAllocPtr alloc
+ )
{
- ISzAlloc_Free(alloc, p->probs);
+ ISzAlloc_Free (alloc, p->probs);
p->probs = NULL;
}
-static void LzmaDec_FreeDict(CLzmaDec *p, ISzAllocPtr alloc)
+static void
+LzmaDec_FreeDict (
+ CLzmaDec *p,
+ ISzAllocPtr alloc
+ )
{
- ISzAlloc_Free(alloc, p->dic);
+ ISzAlloc_Free (alloc, p->dic);
p->dic = NULL;
}
-void LzmaDec_Free(CLzmaDec *p, ISzAllocPtr alloc)
+void
+LzmaDec_Free (
+ CLzmaDec *p,
+ ISzAllocPtr alloc
+ )
{
- LzmaDec_FreeProbs(p, alloc);
- LzmaDec_FreeDict(p, alloc);
+ LzmaDec_FreeProbs (p, alloc);
+ LzmaDec_FreeDict (p, alloc);
}
-SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size)
+SRes
+LzmaProps_Decode (
+ CLzmaProps *p,
+ const Byte *data,
+ unsigned size
+ )
{
- UInt32 dicSize;
- Byte d;
+ UInt32 dicSize;
+ Byte d;
- if (size < LZMA_PROPS_SIZE)
+ if (size < LZMA_PROPS_SIZE) {
return SZ_ERROR_UNSUPPORTED;
- else
+ } else {
dicSize = data[1] | ((UInt32)data[2] << 8) | ((UInt32)data[3] << 16) | ((UInt32)data[4] << 24);
+ }
- if (dicSize < LZMA_DIC_MIN)
+ if (dicSize < LZMA_DIC_MIN) {
dicSize = LZMA_DIC_MIN;
+ }
+
p->dicSize = dicSize;
d = data[0];
- if (d >= (9 * 5 * 5))
+ if (d >= (9 * 5 * 5)) {
return SZ_ERROR_UNSUPPORTED;
+ }
p->lc = (Byte)(d % 9);
- d /= 9;
+ d /= 9;
p->pb = (Byte)(d / 5);
p->lp = (Byte)(d % 5);
return SZ_OK;
}
-static SRes LzmaDec_AllocateProbs2(CLzmaDec *p, const CLzmaProps *propNew, ISzAllocPtr alloc)
+static SRes
+LzmaDec_AllocateProbs2 (
+ CLzmaDec *p,
+ const CLzmaProps *propNew,
+ ISzAllocPtr alloc
+ )
{
- UInt32 numProbs = LzmaProps_GetNumProbs(propNew);
- if (!p->probs || numProbs != p->numProbs)
- {
- LzmaDec_FreeProbs(p, alloc);
- p->probs = (CLzmaProb *)ISzAlloc_Alloc(alloc, numProbs * sizeof(CLzmaProb));
- if (!p->probs)
+ UInt32 numProbs = LzmaProps_GetNumProbs (propNew);
+
+ if (!p->probs || (numProbs != p->numProbs)) {
+ LzmaDec_FreeProbs (p, alloc);
+ p->probs = (CLzmaProb *)ISzAlloc_Alloc (alloc, numProbs * sizeof (CLzmaProb));
+ if (!p->probs) {
return SZ_ERROR_MEM;
+ }
+
p->probs_1664 = p->probs + 1664;
- p->numProbs = numProbs;
+ p->numProbs = numProbs;
}
+
return SZ_OK;
}
-SRes LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAllocPtr alloc)
+SRes
+LzmaDec_AllocateProbs (
+ CLzmaDec *p,
+ const Byte *props,
+ unsigned propsSize,
+ ISzAllocPtr alloc
+ )
{
- CLzmaProps propNew;
- RINOK(LzmaProps_Decode(&propNew, props, propsSize));
- RINOK(LzmaDec_AllocateProbs2(p, &propNew, alloc));
+ CLzmaProps propNew;
+
+ RINOK (LzmaProps_Decode (&propNew, props, propsSize));
+ RINOK (LzmaDec_AllocateProbs2 (p, &propNew, alloc));
p->prop = propNew;
return SZ_OK;
}
-SRes LzmaDec_Allocate(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAllocPtr alloc)
+SRes
+LzmaDec_Allocate (
+ CLzmaDec *p,
+ const Byte *props,
+ unsigned propsSize,
+ ISzAllocPtr alloc
+ )
{
- CLzmaProps propNew;
- SizeT dicBufSize;
- RINOK(LzmaProps_Decode(&propNew, props, propsSize));
- RINOK(LzmaDec_AllocateProbs2(p, &propNew, alloc));
+ CLzmaProps propNew;
+ SizeT dicBufSize;
+
+ RINOK (LzmaProps_Decode (&propNew, props, propsSize));
+ RINOK (LzmaDec_AllocateProbs2 (p, &propNew, alloc));
{
- UInt32 dictSize = propNew.dicSize;
- SizeT mask = ((UInt32)1 << 12) - 1;
- if (dictSize >= ((UInt32)1 << 30)) mask = ((UInt32)1 << 22) - 1;
- else if (dictSize >= ((UInt32)1 << 22)) mask = ((UInt32)1 << 20) - 1;;
+ UInt32 dictSize = propNew.dicSize;
+ SizeT mask = ((UInt32)1 << 12) - 1;
+ if (dictSize >= ((UInt32)1 << 30)) {
+ mask = ((UInt32)1 << 22) - 1;
+ } else if (dictSize >= ((UInt32)1 << 22)) {
+ mask = ((UInt32)1 << 20) - 1;
+ }
+
dicBufSize = ((SizeT)dictSize + mask) & ~mask;
- if (dicBufSize < dictSize)
+ if (dicBufSize < dictSize) {
dicBufSize = dictSize;
+ }
}
- if (!p->dic || dicBufSize != p->dicBufSize)
- {
- LzmaDec_FreeDict(p, alloc);
- p->dic = (Byte *)ISzAlloc_Alloc(alloc, dicBufSize);
- if (!p->dic)
- {
- LzmaDec_FreeProbs(p, alloc);
+ if (!p->dic || (dicBufSize != p->dicBufSize)) {
+ LzmaDec_FreeDict (p, alloc);
+ p->dic = (Byte *)ISzAlloc_Alloc (alloc, dicBufSize);
+ if (!p->dic) {
+ LzmaDec_FreeProbs (p, alloc);
return SZ_ERROR_MEM;
}
}
+
p->dicBufSize = dicBufSize;
- p->prop = propNew;
+ p->prop = propNew;
return SZ_OK;
}
-SRes LzmaDecode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen,
- const Byte *propData, unsigned propSize, ELzmaFinishMode finishMode,
- ELzmaStatus *status, ISzAllocPtr alloc)
+SRes
+LzmaDecode (
+ Byte *dest,
+ SizeT *destLen,
+ const Byte *src,
+ SizeT *srcLen,
+ const Byte *propData,
+ unsigned propSize,
+ ELzmaFinishMode finishMode,
+ ELzmaStatus *status,
+ ISzAllocPtr alloc
+ )
{
- CLzmaDec p;
- SRes res;
- SizeT outSize = *destLen, inSize = *srcLen;
+ CLzmaDec p;
+ SRes res;
+ SizeT outSize = *destLen, inSize = *srcLen;
+
*destLen = *srcLen = 0;
- *status = LZMA_STATUS_NOT_SPECIFIED;
- if (inSize < RC_INIT_SIZE)
+ *status = LZMA_STATUS_NOT_SPECIFIED;
+ if (inSize < RC_INIT_SIZE) {
return SZ_ERROR_INPUT_EOF;
- LzmaDec_Construct(&p);
- RINOK(LzmaDec_AllocateProbs(&p, propData, propSize, alloc));
- p.dic = dest;
+ }
+
+ LzmaDec_Construct (&p);
+ RINOK (LzmaDec_AllocateProbs (&p, propData, propSize, alloc));
+ p.dic = dest;
p.dicBufSize = outSize;
- LzmaDec_Init(&p);
- *srcLen = inSize;
- res = LzmaDec_DecodeToDic(&p, outSize, src, srcLen, finishMode, status);
+ LzmaDec_Init (&p);
+ *srcLen = inSize;
+ res = LzmaDec_DecodeToDic (&p, outSize, src, srcLen, finishMode, status);
*destLen = p.dicPos;
- if (res == SZ_OK && *status == LZMA_STATUS_NEEDS_MORE_INPUT)
+ if ((res == SZ_OK) && (*status == LZMA_STATUS_NEEDS_MORE_INPUT)) {
res = SZ_ERROR_INPUT_EOF;
- LzmaDec_FreeProbs(&p, alloc);
+ }
+
+ LzmaDec_FreeProbs (&p, alloc);
return res;
}
diff --git a/MdeModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/LzmaDec.h b/MdeModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/LzmaDec.h index ebc568cb4f..11f028876f 100644 --- a/MdeModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/LzmaDec.h +++ b/MdeModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/LzmaDec.h @@ -9,6 +9,7 @@ EXTERN_C_BEGIN
/* #define _LZMA_PROB32 */
+
/* _LZMA_PROB32 can increase the speed on some CPUs,
but memory usage for CLzmaDec::probs will be doubled in that case */
@@ -20,18 +21,16 @@ typedef #endif
CLzmaProb;
-
/* ---------- LZMA Properties ---------- */
-#define LZMA_PROPS_SIZE 5
+#define LZMA_PROPS_SIZE 5
-typedef struct _CLzmaProps
-{
- Byte lc;
- Byte lp;
- Byte pb;
- Byte _pad_;
- UInt32 dicSize;
+typedef struct _CLzmaProps {
+ Byte lc;
+ Byte lp;
+ Byte pb;
+ Byte _pad_;
+ UInt32 dicSize;
} CLzmaProps;
/* LzmaProps_Decode - decodes properties
@@ -40,49 +39,54 @@ Returns: SZ_ERROR_UNSUPPORTED - Unsupported properties
*/
-SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size);
-
+SRes
+LzmaProps_Decode (
+ CLzmaProps *p,
+ const Byte *data,
+ unsigned size
+ );
/* ---------- LZMA Decoder state ---------- */
/* LZMA_REQUIRED_INPUT_MAX = number of required input bytes for worst case.
Num bits = log2((2^11 / 31) ^ 22) + 26 < 134 + 26 = 160; */
-#define LZMA_REQUIRED_INPUT_MAX 20
+#define LZMA_REQUIRED_INPUT_MAX 20
-typedef struct
-{
+typedef struct {
/* Don't change this structure. ASM code can use it. */
- CLzmaProps prop;
- CLzmaProb *probs;
- CLzmaProb *probs_1664;
- Byte *dic;
- SizeT dicBufSize;
- SizeT dicPos;
- const Byte *buf;
- UInt32 range;
- UInt32 code;
- UInt32 processedPos;
- UInt32 checkDicSize;
- UInt32 reps[4];
- UInt32 state;
- UInt32 remainLen;
-
- UInt32 numProbs;
- unsigned tempBufSize;
- Byte tempBuf[LZMA_REQUIRED_INPUT_MAX];
+ CLzmaProps prop;
+ CLzmaProb *probs;
+ CLzmaProb *probs_1664;
+ Byte *dic;
+ SizeT dicBufSize;
+ SizeT dicPos;
+ const Byte *buf;
+ UInt32 range;
+ UInt32 code;
+ UInt32 processedPos;
+ UInt32 checkDicSize;
+ UInt32 reps[4];
+ UInt32 state;
+ UInt32 remainLen;
+
+ UInt32 numProbs;
+ unsigned tempBufSize;
+ Byte tempBuf[LZMA_REQUIRED_INPUT_MAX];
} CLzmaDec;
-#define LzmaDec_Construct(p) { (p)->dic = NULL; (p)->probs = NULL; }
+#define LzmaDec_Construct(p) { (p)->dic = NULL; (p)->probs = NULL; }
-void LzmaDec_Init(CLzmaDec *p);
+void
+LzmaDec_Init (
+ CLzmaDec *p
+ );
/* There are two types of LZMA streams:
- Stream with end mark. That end mark adds about 6 bytes to compressed size.
- Stream without end mark. You must know exact uncompressed size to decompress such stream. */
-typedef enum
-{
+typedef enum {
LZMA_FINISH_ANY, /* finish at any point */
LZMA_FINISH_END /* block must be finished at the end */
} ELzmaFinishMode;
@@ -102,8 +106,7 @@ typedef enum 3) Check that output(srcLen) = compressedSize, if you know real compressedSize.
You must use correct finish mode in that case. */
-typedef enum
-{
+typedef enum {
LZMA_STATUS_NOT_SPECIFIED, /* use main error code instead */
LZMA_STATUS_FINISHED_WITH_MARK, /* stream was finished with end mark. */
LZMA_STATUS_NOT_FINISHED, /* stream was not finished */
@@ -113,7 +116,6 @@ typedef enum /* ELzmaStatus is used only as output value for function call */
-
/* ---------- Interfaces ---------- */
/* There are 3 levels of interfaces:
@@ -123,7 +125,6 @@ typedef enum You can select any of these interfaces, but don't mix functions from different
groups for same object. */
-
/* There are two variants to allocate state for Dictionary Interface:
1) LzmaDec_Allocate / LzmaDec_Free
2) LzmaDec_AllocateProbs / LzmaDec_FreeProbs
@@ -136,11 +137,33 @@ LzmaDec_Allocate* can return: SZ_ERROR_UNSUPPORTED - Unsupported properties
*/
-SRes LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAllocPtr alloc);
-void LzmaDec_FreeProbs(CLzmaDec *p, ISzAllocPtr alloc);
-
-SRes LzmaDec_Allocate(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAllocPtr alloc);
-void LzmaDec_Free(CLzmaDec *p, ISzAllocPtr alloc);
+SRes
+LzmaDec_AllocateProbs (
+ CLzmaDec *p,
+ const Byte *props,
+ unsigned propsSize,
+ ISzAllocPtr alloc
+ );
+
+void
+LzmaDec_FreeProbs (
+ CLzmaDec *p,
+ ISzAllocPtr alloc
+ );
+
+SRes
+LzmaDec_Allocate (
+ CLzmaDec *p,
+ const Byte *props,
+ unsigned propsSize,
+ ISzAllocPtr alloc
+ );
+
+void
+LzmaDec_Free (
+ CLzmaDec *p,
+ ISzAllocPtr alloc
+ );
/* ---------- Dictionary Interface ---------- */
@@ -183,9 +206,15 @@ Returns: SZ_ERROR_DATA - Data error
*/
-SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit,
- const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status);
-
+SRes
+LzmaDec_DecodeToDic (
+ CLzmaDec *p,
+ SizeT dicLimit,
+ const Byte *src,
+ SizeT *srcLen,
+ ELzmaFinishMode finishMode,
+ ELzmaStatus *status
+ );
/* ---------- Buffer Interface ---------- */
@@ -200,9 +229,16 @@ finishMode: LZMA_FINISH_END - Stream must be finished after (*destLen).
*/
-SRes LzmaDec_DecodeToBuf(CLzmaDec *p, Byte *dest, SizeT *destLen,
- const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status);
-
+SRes
+LzmaDec_DecodeToBuf (
+ CLzmaDec *p,
+ Byte *dest,
+ SizeT *destLen,
+ const Byte *src,
+ SizeT *srcLen,
+ ELzmaFinishMode finishMode,
+ ELzmaStatus *status
+ );
/* ---------- One Call Interface ---------- */
@@ -225,9 +261,18 @@ Returns: SZ_ERROR_INPUT_EOF - It needs more bytes in input buffer (src).
*/
-SRes LzmaDecode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen,
- const Byte *propData, unsigned propSize, ELzmaFinishMode finishMode,
- ELzmaStatus *status, ISzAllocPtr alloc);
+SRes
+LzmaDecode (
+ Byte *dest,
+ SizeT *destLen,
+ const Byte *src,
+ SizeT *srcLen,
+ const Byte *propData,
+ unsigned propSize,
+ ELzmaFinishMode finishMode,
+ ELzmaStatus *status,
+ ISzAllocPtr alloc
+ );
EXTERN_C_END
diff --git a/MdeModulePkg/Library/LzmaCustomDecompressLib/UefiLzma.h b/MdeModulePkg/Library/LzmaCustomDecompressLib/UefiLzma.h index e1315b6ec3..b1941bd403 100644 --- a/MdeModulePkg/Library/LzmaCustomDecompressLib/UefiLzma.h +++ b/MdeModulePkg/Library/LzmaCustomDecompressLib/UefiLzma.h @@ -15,23 +15,22 @@ #include <Library/BaseMemoryLib.h>
#ifdef _WIN32
-#undef _WIN32
+ #undef _WIN32
#endif
typedef UINTN size_t;
#ifdef _WIN64
-#undef _WIN64
+ #undef _WIN64
#endif
#ifndef _PTRDIFF_T_DEFINED
typedef int ptrdiff_t;
#endif
-#define memcpy CopyMem
-#define memmove CopyMem
+#define memcpy CopyMem
+#define memmove CopyMem
#define _LZMA_SIZE_OPT
#endif // __UEFILZMA_H__
-
diff --git a/MdeModulePkg/Library/NonDiscoverableDeviceRegistrationLib/NonDiscoverableDeviceRegistrationLib.c b/MdeModulePkg/Library/NonDiscoverableDeviceRegistrationLib/NonDiscoverableDeviceRegistrationLib.c index 8074268986..a68612dd76 100644 --- a/MdeModulePkg/Library/NonDiscoverableDeviceRegistrationLib/NonDiscoverableDeviceRegistrationLib.c +++ b/MdeModulePkg/Library/NonDiscoverableDeviceRegistrationLib/NonDiscoverableDeviceRegistrationLib.c @@ -34,44 +34,44 @@ GetGuidFromType ( )
{
switch (Type) {
- case NonDiscoverableDeviceTypeAhci:
- return &gEdkiiNonDiscoverableAhciDeviceGuid;
+ case NonDiscoverableDeviceTypeAhci:
+ return &gEdkiiNonDiscoverableAhciDeviceGuid;
- case NonDiscoverableDeviceTypeAmba:
- return &gEdkiiNonDiscoverableAmbaDeviceGuid;
+ case NonDiscoverableDeviceTypeAmba:
+ return &gEdkiiNonDiscoverableAmbaDeviceGuid;
- case NonDiscoverableDeviceTypeEhci:
- return &gEdkiiNonDiscoverableEhciDeviceGuid;
+ case NonDiscoverableDeviceTypeEhci:
+ return &gEdkiiNonDiscoverableEhciDeviceGuid;
- case NonDiscoverableDeviceTypeNvme:
- return &gEdkiiNonDiscoverableNvmeDeviceGuid;
+ case NonDiscoverableDeviceTypeNvme:
+ return &gEdkiiNonDiscoverableNvmeDeviceGuid;
- case NonDiscoverableDeviceTypeOhci:
- return &gEdkiiNonDiscoverableOhciDeviceGuid;
+ case NonDiscoverableDeviceTypeOhci:
+ return &gEdkiiNonDiscoverableOhciDeviceGuid;
- case NonDiscoverableDeviceTypeSdhci:
- return &gEdkiiNonDiscoverableSdhciDeviceGuid;
+ case NonDiscoverableDeviceTypeSdhci:
+ return &gEdkiiNonDiscoverableSdhciDeviceGuid;
- case NonDiscoverableDeviceTypeUfs:
- return &gEdkiiNonDiscoverableUfsDeviceGuid;
+ case NonDiscoverableDeviceTypeUfs:
+ return &gEdkiiNonDiscoverableUfsDeviceGuid;
- case NonDiscoverableDeviceTypeUhci:
- return &gEdkiiNonDiscoverableUhciDeviceGuid;
+ case NonDiscoverableDeviceTypeUhci:
+ return &gEdkiiNonDiscoverableUhciDeviceGuid;
- case NonDiscoverableDeviceTypeXhci:
- return &gEdkiiNonDiscoverableXhciDeviceGuid;
+ case NonDiscoverableDeviceTypeXhci:
+ return &gEdkiiNonDiscoverableXhciDeviceGuid;
- default:
- return NULL;
+ default:
+ return NULL;
}
}
#pragma pack (1)
typedef struct {
- VENDOR_DEVICE_PATH Vendor;
- UINT64 BaseAddress;
- UINT8 ResourceType;
- EFI_DEVICE_PATH_PROTOCOL End;
+ VENDOR_DEVICE_PATH Vendor;
+ UINT64 BaseAddress;
+ UINT8 ResourceType;
+ EFI_DEVICE_PATH_PROTOCOL End;
} NON_DISCOVERABLE_DEVICE_PATH;
#pragma pack ()
@@ -108,25 +108,26 @@ RegisterNonDiscoverableMmioDevice ( ...
)
{
- NON_DISCOVERABLE_DEVICE *Device;
- NON_DISCOVERABLE_DEVICE_PATH *DevicePath;
- EFI_HANDLE LocalHandle;
- EFI_STATUS Status;
- UINTN AllocSize;
- UINTN Index;
- VA_LIST Args;
- EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Desc;
- EFI_ACPI_END_TAG_DESCRIPTOR *End;
- UINTN Base, Size;
-
- if (Type >= NonDiscoverableDeviceTypeMax ||
- DmaType >= NonDiscoverableDeviceDmaTypeMax ||
- NumMmioResources == 0) {
+ NON_DISCOVERABLE_DEVICE *Device;
+ NON_DISCOVERABLE_DEVICE_PATH *DevicePath;
+ EFI_HANDLE LocalHandle;
+ EFI_STATUS Status;
+ UINTN AllocSize;
+ UINTN Index;
+ VA_LIST Args;
+ EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Desc;
+ EFI_ACPI_END_TAG_DESCRIPTOR *End;
+ UINTN Base, Size;
+
+ if ((Type >= NonDiscoverableDeviceTypeMax) ||
+ (DmaType >= NonDiscoverableDeviceDmaTypeMax) ||
+ (NumMmioResources == 0))
+ {
return EFI_INVALID_PARAMETER;
}
if (Handle == NULL) {
- Handle = &LocalHandle;
+ Handle = &LocalHandle;
LocalHandle = NULL;
}
@@ -141,13 +142,13 @@ RegisterNonDiscoverableMmioDevice ( Device->Type = GetGuidFromType (Type);
ASSERT (Device->Type != NULL);
- Device->DmaType = DmaType;
+ Device->DmaType = DmaType;
Device->Initialize = InitFunc;
- Device->Resources = (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *)(Device + 1);
+ Device->Resources = (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *)(Device + 1);
VA_START (Args, NumMmioResources);
for (Index = 0; Index < NumMmioResources; Index++) {
- Desc = &Device->Resources [Index];
+ Desc = &Device->Resources[Index];
Base = VA_ARG (Args, UINTN);
Size = VA_ARG (Args, UINTN);
@@ -160,9 +161,10 @@ RegisterNonDiscoverableMmioDevice ( Desc->AddrSpaceGranularity = ((EFI_PHYSICAL_ADDRESS)Base + Size > SIZE_4GB) ? 64 : 32;
Desc->AddrTranslationOffset = 0;
}
+
VA_END (Args);
- End = (EFI_ACPI_END_TAG_DESCRIPTOR *)&Device->Resources [NumMmioResources];
+ End = (EFI_ACPI_END_TAG_DESCRIPTOR *)&Device->Resources[NumMmioResources];
End->Desc = ACPI_END_TAG_DESCRIPTOR;
End->Checksum = 0;
@@ -170,7 +172,8 @@ RegisterNonDiscoverableMmioDevice ( DevicePath = (NON_DISCOVERABLE_DEVICE_PATH *)CreateDeviceNode (
HARDWARE_DEVICE_PATH,
HW_VENDOR_DP,
- sizeof (*DevicePath));
+ sizeof (*DevicePath)
+ );
if (DevicePath == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto FreeDevice;
@@ -182,20 +185,27 @@ RegisterNonDiscoverableMmioDevice ( // Use the base address and type of the first region to
// make the device path unique
//
- DevicePath->BaseAddress = Device->Resources [0].AddrRangeMin;
- DevicePath->ResourceType = Device->Resources [0].ResType;
+ DevicePath->BaseAddress = Device->Resources[0].AddrRangeMin;
+ DevicePath->ResourceType = Device->Resources[0].ResType;
- SetDevicePathNodeLength (&DevicePath->Vendor,
- sizeof (*DevicePath) - sizeof (DevicePath->End));
+ SetDevicePathNodeLength (
+ &DevicePath->Vendor,
+ sizeof (*DevicePath) - sizeof (DevicePath->End)
+ );
SetDevicePathEndNode (&DevicePath->End);
- Status = gBS->InstallMultipleProtocolInterfaces (Handle,
- &gEdkiiNonDiscoverableDeviceProtocolGuid, Device,
- &gEfiDevicePathProtocolGuid, DevicePath,
- NULL);
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ Handle,
+ &gEdkiiNonDiscoverableDeviceProtocolGuid,
+ Device,
+ &gEfiDevicePathProtocolGuid,
+ DevicePath,
+ NULL
+ );
if (EFI_ERROR (Status)) {
goto FreeDevicePath;
}
+
return EFI_SUCCESS;
FreeDevicePath:
diff --git a/MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHookStatusCodeLibNull.c b/MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHookStatusCodeLibNull.c index d545050f02..f1f088efd7 100644 --- a/MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHookStatusCodeLibNull.c +++ b/MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHookStatusCodeLibNull.c @@ -6,7 +6,6 @@ **/
-
/**
Initialize OEM status code device .
@@ -44,11 +43,11 @@ OemHookStatusCodeInitialize ( EFI_STATUS
EFIAPI
OemHookStatusCodeReport (
- IN EFI_STATUS_CODE_TYPE CodeType,
- IN EFI_STATUS_CODE_VALUE Value,
- IN UINT32 Instance,
- IN EFI_GUID *CallerId OPTIONAL,
- IN EFI_STATUS_CODE_DATA *Data OPTIONAL
+ IN EFI_STATUS_CODE_TYPE CodeType,
+ IN EFI_STATUS_CODE_VALUE Value,
+ IN UINT32 Instance,
+ IN EFI_GUID *CallerId OPTIONAL,
+ IN EFI_STATUS_CODE_DATA *Data OPTIONAL
)
{
return EFI_SUCCESS;
diff --git a/MdeModulePkg/Library/PciHostBridgeLibNull/PciHostBridgeLibNull.c b/MdeModulePkg/Library/PciHostBridgeLibNull/PciHostBridgeLibNull.c index 0b86ef3ad5..097387607c 100644 --- a/MdeModulePkg/Library/PciHostBridgeLibNull/PciHostBridgeLibNull.c +++ b/MdeModulePkg/Library/PciHostBridgeLibNull/PciHostBridgeLibNull.c @@ -11,7 +11,7 @@ #include <Library/DebugLib.h>
GLOBAL_REMOVE_IF_UNREFERENCED
-CHAR16 *mPciHostBridgeLibAcpiAddressSpaceTypeStr[] = {
+CHAR16 *mPciHostBridgeLibAcpiAddressSpaceTypeStr[] = {
L"Mem", L"I/O", L"Bus"
};
@@ -27,7 +27,7 @@ CHAR16 *mPciHostBridgeLibAcpiAddressSpaceTypeStr[] = { PCI_ROOT_BRIDGE *
EFIAPI
PciHostBridgeGetRootBridges (
- UINTN *Count
+ UINTN *Count
)
{
*Count = 0;
@@ -43,8 +43,8 @@ PciHostBridgeGetRootBridges ( VOID
EFIAPI
PciHostBridgeFreeRootBridges (
- PCI_ROOT_BRIDGE *Bridges,
- UINTN Count
+ PCI_ROOT_BRIDGE *Bridges,
+ UINTN Count
)
{
return;
@@ -67,43 +67,52 @@ PciHostBridgeFreeRootBridges ( VOID
EFIAPI
PciHostBridgeResourceConflict (
- EFI_HANDLE HostBridgeHandle,
- VOID *Configuration
+ EFI_HANDLE HostBridgeHandle,
+ VOID *Configuration
)
{
- EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Descriptor;
- UINTN RootBridgeIndex;
+ EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Descriptor;
+ UINTN RootBridgeIndex;
+
DEBUG ((DEBUG_ERROR, "PciHostBridge: Resource conflict happens!\n"));
RootBridgeIndex = 0;
- Descriptor = (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *) Configuration;
+ Descriptor = (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *)Configuration;
while (Descriptor->Desc == ACPI_ADDRESS_SPACE_DESCRIPTOR) {
DEBUG ((DEBUG_ERROR, "RootBridge[%d]:\n", RootBridgeIndex++));
- for (; Descriptor->Desc == ACPI_ADDRESS_SPACE_DESCRIPTOR; Descriptor++) {
- ASSERT (Descriptor->ResType <
- (sizeof (mPciHostBridgeLibAcpiAddressSpaceTypeStr) /
- sizeof (mPciHostBridgeLibAcpiAddressSpaceTypeStr[0])
- )
- );
- DEBUG ((DEBUG_ERROR, " %s: Length/Alignment = 0x%lx / 0x%lx\n",
- mPciHostBridgeLibAcpiAddressSpaceTypeStr[Descriptor->ResType],
- Descriptor->AddrLen, Descriptor->AddrRangeMax
- ));
+ for ( ; Descriptor->Desc == ACPI_ADDRESS_SPACE_DESCRIPTOR; Descriptor++) {
+ ASSERT (
+ Descriptor->ResType <
+ (sizeof (mPciHostBridgeLibAcpiAddressSpaceTypeStr) /
+ sizeof (mPciHostBridgeLibAcpiAddressSpaceTypeStr[0])
+ )
+ );
+ DEBUG ((
+ DEBUG_ERROR,
+ " %s: Length/Alignment = 0x%lx / 0x%lx\n",
+ mPciHostBridgeLibAcpiAddressSpaceTypeStr[Descriptor->ResType],
+ Descriptor->AddrLen,
+ Descriptor->AddrRangeMax
+ ));
if (Descriptor->ResType == ACPI_ADDRESS_SPACE_TYPE_MEM) {
- DEBUG ((DEBUG_ERROR, " Granularity/SpecificFlag = %ld / %02x%s\n",
- Descriptor->AddrSpaceGranularity, Descriptor->SpecificFlag,
- ((Descriptor->SpecificFlag &
- EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_CACHEABLE_PREFETCHABLE
- ) != 0) ? L" (Prefetchable)" : L""
- ));
+ DEBUG ((
+ DEBUG_ERROR,
+ " Granularity/SpecificFlag = %ld / %02x%s\n",
+ Descriptor->AddrSpaceGranularity,
+ Descriptor->SpecificFlag,
+ ((Descriptor->SpecificFlag &
+ EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_CACHEABLE_PREFETCHABLE
+ ) != 0) ? L" (Prefetchable)" : L""
+ ));
}
}
+
//
// Skip the END descriptor for root bridge
//
ASSERT (Descriptor->Desc == ACPI_END_TAG_DESCRIPTOR);
Descriptor = (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *)(
- (EFI_ACPI_END_TAG_DESCRIPTOR *)Descriptor + 1
- );
+ (EFI_ACPI_END_TAG_DESCRIPTOR *)Descriptor + 1
+ );
}
}
diff --git a/MdeModulePkg/Library/PeiCrc32GuidedSectionExtractLib/PeiCrc32GuidedSectionExtractLib.c b/MdeModulePkg/Library/PeiCrc32GuidedSectionExtractLib/PeiCrc32GuidedSectionExtractLib.c index 4bd4e4b32e..63f149e7e0 100644 --- a/MdeModulePkg/Library/PeiCrc32GuidedSectionExtractLib/PeiCrc32GuidedSectionExtractLib.c +++ b/MdeModulePkg/Library/PeiCrc32GuidedSectionExtractLib/PeiCrc32GuidedSectionExtractLib.c @@ -19,13 +19,13 @@ SPDX-License-Identifier: BSD-2-Clause-Patent /// CRC32 Guided Section header
///
typedef struct {
- EFI_GUID_DEFINED_SECTION GuidedSectionHeader; ///< EFI guided section header
- UINT32 CRC32Checksum; ///< 32bit CRC check sum
+ EFI_GUID_DEFINED_SECTION GuidedSectionHeader; ///< EFI guided section header
+ UINT32 CRC32Checksum; ///< 32bit CRC check sum
} CRC32_SECTION_HEADER;
typedef struct {
- EFI_GUID_DEFINED_SECTION2 GuidedSectionHeader; ///< EFI guided section header
- UINT32 CRC32Checksum; ///< 32bit CRC check sum
+ EFI_GUID_DEFINED_SECTION2 GuidedSectionHeader; ///< EFI guided section header
+ UINT32 CRC32Checksum; ///< 32bit CRC check sum
} CRC32_SECTION2_HEADER;
/**
@@ -58,31 +58,37 @@ Crc32GuidedSectionGetInfo ( // Check whether the input guid section is recognized.
//
if (!CompareGuid (
- &gEfiCrc32GuidedSectionExtractionGuid,
- &(((EFI_GUID_DEFINED_SECTION2 *) InputSection)->SectionDefinitionGuid))) {
+ &gEfiCrc32GuidedSectionExtractionGuid,
+ &(((EFI_GUID_DEFINED_SECTION2 *)InputSection)->SectionDefinitionGuid)
+ ))
+ {
return EFI_INVALID_PARAMETER;
}
+
//
// Retrieve the size and attribute of the input section data.
//
- *SectionAttribute = ((EFI_GUID_DEFINED_SECTION2 *) InputSection)->Attributes;
+ *SectionAttribute = ((EFI_GUID_DEFINED_SECTION2 *)InputSection)->Attributes;
*ScratchBufferSize = 0;
- *OutputBufferSize = SECTION2_SIZE (InputSection) - ((EFI_GUID_DEFINED_SECTION2 *) InputSection)->DataOffset;
+ *OutputBufferSize = SECTION2_SIZE (InputSection) - ((EFI_GUID_DEFINED_SECTION2 *)InputSection)->DataOffset;
} else {
//
// Check whether the input guid section is recognized.
//
if (!CompareGuid (
- &gEfiCrc32GuidedSectionExtractionGuid,
- &(((EFI_GUID_DEFINED_SECTION *) InputSection)->SectionDefinitionGuid))) {
+ &gEfiCrc32GuidedSectionExtractionGuid,
+ &(((EFI_GUID_DEFINED_SECTION *)InputSection)->SectionDefinitionGuid)
+ ))
+ {
return EFI_INVALID_PARAMETER;
}
+
//
// Retrieve the size and attribute of the input section data.
//
- *SectionAttribute = ((EFI_GUID_DEFINED_SECTION *) InputSection)->Attributes;
+ *SectionAttribute = ((EFI_GUID_DEFINED_SECTION *)InputSection)->Attributes;
*ScratchBufferSize = 0;
- *OutputBufferSize = SECTION_SIZE (InputSection) - ((EFI_GUID_DEFINED_SECTION *) InputSection)->DataOffset;
+ *OutputBufferSize = SECTION_SIZE (InputSection) - ((EFI_GUID_DEFINED_SECTION *)InputSection)->DataOffset;
}
return EFI_SUCCESS;
@@ -114,53 +120,57 @@ Crc32GuidedSectionHandler ( OUT UINT32 *AuthenticationStatus
)
{
- UINT32 SectionCrc32Checksum;
- UINT32 Crc32Checksum;
- UINT32 OutputBufferSize;
+ UINT32 SectionCrc32Checksum;
+ UINT32 Crc32Checksum;
+ UINT32 OutputBufferSize;
if (IS_SECTION2 (InputSection)) {
//
// Check whether the input guid section is recognized.
//
if (!CompareGuid (
- &gEfiCrc32GuidedSectionExtractionGuid,
- &(((EFI_GUID_DEFINED_SECTION2 *) InputSection)->SectionDefinitionGuid))) {
+ &gEfiCrc32GuidedSectionExtractionGuid,
+ &(((EFI_GUID_DEFINED_SECTION2 *)InputSection)->SectionDefinitionGuid)
+ ))
+ {
return EFI_INVALID_PARAMETER;
}
//
// Get section Crc32 checksum.
//
- SectionCrc32Checksum = ((CRC32_SECTION2_HEADER *) InputSection)->CRC32Checksum;
- *OutputBuffer = (UINT8 *) InputSection + ((EFI_GUID_DEFINED_SECTION2 *) InputSection)->DataOffset;
- OutputBufferSize = SECTION2_SIZE (InputSection) - ((EFI_GUID_DEFINED_SECTION2 *) InputSection)->DataOffset;
+ SectionCrc32Checksum = ((CRC32_SECTION2_HEADER *)InputSection)->CRC32Checksum;
+ *OutputBuffer = (UINT8 *)InputSection + ((EFI_GUID_DEFINED_SECTION2 *)InputSection)->DataOffset;
+ OutputBufferSize = SECTION2_SIZE (InputSection) - ((EFI_GUID_DEFINED_SECTION2 *)InputSection)->DataOffset;
//
// Implicitly CRC32 GUIDed section should have STATUS_VALID bit set
//
- ASSERT (((EFI_GUID_DEFINED_SECTION2 *) InputSection)->Attributes & EFI_GUIDED_SECTION_AUTH_STATUS_VALID);
+ ASSERT (((EFI_GUID_DEFINED_SECTION2 *)InputSection)->Attributes & EFI_GUIDED_SECTION_AUTH_STATUS_VALID);
*AuthenticationStatus = EFI_AUTH_STATUS_IMAGE_SIGNED;
} else {
//
// Check whether the input guid section is recognized.
//
if (!CompareGuid (
- &gEfiCrc32GuidedSectionExtractionGuid,
- &(((EFI_GUID_DEFINED_SECTION *) InputSection)->SectionDefinitionGuid))) {
+ &gEfiCrc32GuidedSectionExtractionGuid,
+ &(((EFI_GUID_DEFINED_SECTION *)InputSection)->SectionDefinitionGuid)
+ ))
+ {
return EFI_INVALID_PARAMETER;
}
//
// Get section Crc32 checksum.
//
- SectionCrc32Checksum = ((CRC32_SECTION_HEADER *) InputSection)->CRC32Checksum;
- *OutputBuffer = (UINT8 *) InputSection + ((EFI_GUID_DEFINED_SECTION *) InputSection)->DataOffset;
- OutputBufferSize = SECTION_SIZE (InputSection) - ((EFI_GUID_DEFINED_SECTION *) InputSection)->DataOffset;
+ SectionCrc32Checksum = ((CRC32_SECTION_HEADER *)InputSection)->CRC32Checksum;
+ *OutputBuffer = (UINT8 *)InputSection + ((EFI_GUID_DEFINED_SECTION *)InputSection)->DataOffset;
+ OutputBufferSize = SECTION_SIZE (InputSection) - ((EFI_GUID_DEFINED_SECTION *)InputSection)->DataOffset;
//
// Implicitly CRC32 GUIDed section should have STATUS_VALID bit set
//
- ASSERT (((EFI_GUID_DEFINED_SECTION *) InputSection)->Attributes & EFI_GUIDED_SECTION_AUTH_STATUS_VALID);
+ ASSERT (((EFI_GUID_DEFINED_SECTION *)InputSection)->Attributes & EFI_GUIDED_SECTION_AUTH_STATUS_VALID);
*AuthenticationStatus = EFI_AUTH_STATUS_IMAGE_SIGNED;
}
@@ -198,13 +208,13 @@ Crc32GuidedSectionHandler ( EFI_STATUS
EFIAPI
PeiCrc32GuidedSectionExtractLibConstructor (
- IN EFI_PEI_FILE_HANDLE FileHandle,
- IN CONST EFI_PEI_SERVICES **PeiServices
+ IN EFI_PEI_FILE_HANDLE FileHandle,
+ IN CONST EFI_PEI_SERVICES **PeiServices
)
{
return ExtractGuidedSectionRegisterHandlers (
- &gEfiCrc32GuidedSectionExtractionGuid,
- Crc32GuidedSectionGetInfo,
- Crc32GuidedSectionHandler
- );
+ &gEfiCrc32GuidedSectionExtractionGuid,
+ Crc32GuidedSectionGetInfo,
+ Crc32GuidedSectionHandler
+ );
}
diff --git a/MdeModulePkg/Library/PeiDebugLibDebugPpi/DebugLib.c b/MdeModulePkg/Library/PeiDebugLibDebugPpi/DebugLib.c index 05a7dab99c..4fb0ad8b84 100644 --- a/MdeModulePkg/Library/PeiDebugLibDebugPpi/DebugLib.c +++ b/MdeModulePkg/Library/PeiDebugLibDebugPpi/DebugLib.c @@ -40,14 +40,13 @@ DebugPrint ( ...
)
{
- VA_LIST Marker;
+ VA_LIST Marker;
VA_START (Marker, Format);
DebugVPrint (ErrorLevel, Format, Marker);
VA_END (Marker);
}
-
/**
Prints a debug message to the debug output device if the specified
error level is enabled.
@@ -68,13 +67,13 @@ DebugPrint ( VOID
EFIAPI
DebugBPrint (
- IN UINTN ErrorLevel,
- IN CONST CHAR8 *Format,
- IN BASE_LIST BaseListMarker
+ IN UINTN ErrorLevel,
+ IN CONST CHAR8 *Format,
+ IN BASE_LIST BaseListMarker
)
{
- EFI_STATUS Status;
- EDKII_DEBUG_PPI *DebugPpi;
+ EFI_STATUS Status;
+ EDKII_DEBUG_PPI *DebugPpi;
//
// If Format is NULL, then ASSERT().
@@ -89,11 +88,11 @@ DebugBPrint ( }
Status = PeiServicesLocatePpi (
- &gEdkiiDebugPpiGuid,
- 0,
- NULL,
- (VOID **)&DebugPpi
- );
+ &gEdkiiDebugPpiGuid,
+ 0,
+ NULL,
+ (VOID **)&DebugPpi
+ );
if (EFI_ERROR (Status)) {
return;
}
@@ -105,7 +104,6 @@ DebugBPrint ( );
}
-
/**
Worker function that convert a VA_LIST to a BASE_LIST based on a
Null-terminated format string.
@@ -129,8 +127,8 @@ VaListToBaseList ( IN UINTN Size
)
{
- BASE_LIST BaseListStart;
- BOOLEAN Long;
+ BASE_LIST BaseListStart;
+ BOOLEAN Long;
ASSERT (Format != NULL);
@@ -138,7 +136,7 @@ VaListToBaseList ( BaseListStart = BaseListMarker;
- for (; *Format != '\0'; Format++) {
+ for ( ; *Format != '\0'; Format++) {
//
// Only format with prefix % is processed.
//
@@ -152,25 +150,28 @@ VaListToBaseList ( // Parse Flags and Width
//
for (Format++; TRUE; Format++) {
- if (*Format == '.' || *Format == '-' || *Format == '+' || *Format == ' ') {
+ if ((*Format == '.') || (*Format == '-') || (*Format == '+') || (*Format == ' ')) {
//
// These characters in format field are omitted.
//
continue;
}
- if (*Format >= '0' && *Format <= '9') {
+
+ if ((*Format >= '0') && (*Format <= '9')) {
//
// These characters in format field are omitted.
//
continue;
}
- if (*Format == 'L' || *Format == 'l') {
+
+ if ((*Format == 'L') || (*Format == 'l')) {
//
// 'L" or "l" in format field means the number being printed is a UINT64
//
Long = TRUE;
continue;
}
+
if (*Format == '*') {
//
// '*' in format field means the precision of the field is specified by
@@ -179,6 +180,7 @@ VaListToBaseList ( BASE_ARG (BaseListMarker, UINTN) = VA_ARG (VaListMarker, UINTN);
continue;
}
+
if (*Format == '\0') {
//
// Make no output if Format string terminates unexpectedly when
@@ -186,6 +188,7 @@ VaListToBaseList ( //
Format--;
}
+
//
// When valid argument type detected or format string terminates unexpectedly,
// the inner loop is done.
@@ -199,13 +202,14 @@ VaListToBaseList ( if ((*Format == 'p') && (sizeof (VOID *) > 4)) {
Long = TRUE;
}
- if (*Format == 'p' || *Format == 'X' || *Format == 'x' || *Format == 'd' || *Format == 'u') {
+
+ if ((*Format == 'p') || (*Format == 'X') || (*Format == 'x') || (*Format == 'd') || (*Format == 'u')) {
if (Long) {
BASE_ARG (BaseListMarker, INT64) = VA_ARG (VaListMarker, INT64);
} else {
BASE_ARG (BaseListMarker, int) = VA_ARG (VaListMarker, int);
}
- } else if (*Format == 's' || *Format == 'S' || *Format == 'a' || *Format == 'g' || *Format == 't') {
+ } else if ((*Format == 's') || (*Format == 'S') || (*Format == 'a') || (*Format == 'g') || (*Format == 't')) {
BASE_ARG (BaseListMarker, VOID *) = VA_ARG (VaListMarker, VOID *);
} else if (*Format == 'c') {
BASE_ARG (BaseListMarker, UINTN) = VA_ARG (VaListMarker, UINTN);
@@ -224,7 +228,6 @@ VaListToBaseList ( return TRUE;
}
-
/**
Prints a debug message to the debug output device if the specified
error level is enabled.
@@ -243,13 +246,13 @@ VaListToBaseList ( VOID
EFIAPI
DebugVPrint (
- IN UINTN ErrorLevel,
- IN CONST CHAR8 *Format,
- IN VA_LIST VaListMarker
+ IN UINTN ErrorLevel,
+ IN CONST CHAR8 *Format,
+ IN VA_LIST VaListMarker
)
{
- UINT64 BaseListMarker[256 / sizeof (UINT64)];
- BOOLEAN Converted;
+ UINT64 BaseListMarker[256 / sizeof (UINT64)];
+ BOOLEAN Converted;
//
// Convert the VaList to BaseList
@@ -268,7 +271,6 @@ DebugVPrint ( DebugBPrint (ErrorLevel, Format, (BASE_LIST)BaseListMarker);
}
-
/**
Prints an assert message containing a filename, line number, and description.
This may be followed by a breakpoint or a dead loop.
@@ -298,15 +300,15 @@ DebugAssert ( IN CONST CHAR8 *Description
)
{
- EFI_STATUS Status;
- EDKII_DEBUG_PPI *DebugPpi;
+ EFI_STATUS Status;
+ EDKII_DEBUG_PPI *DebugPpi;
Status = PeiServicesLocatePpi (
- &gEdkiiDebugPpiGuid,
- 0,
- NULL,
- (VOID **)&DebugPpi
- );
+ &gEdkiiDebugPpiGuid,
+ 0,
+ NULL,
+ (VOID **)&DebugPpi
+ );
if (EFI_ERROR (Status)) {
//
// Generate a Breakpoint, DeadLoop, or NOP based on PCD settings
@@ -325,7 +327,6 @@ DebugAssert ( }
}
-
/**
Fills a target buffer with PcdDebugClearMemoryValue, and returns the target buffer.
@@ -353,7 +354,6 @@ DebugClearMemory ( return SetMem (Buffer, Length, PcdGet8 (PcdDebugClearMemoryValue));
}
-
/**
Returns TRUE if ASSERT() macros are enabled.
@@ -370,10 +370,9 @@ DebugAssertEnabled ( VOID
)
{
- return (BOOLEAN) ((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED) != 0);
+ return (BOOLEAN)((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED) != 0);
}
-
/**
Returns TRUE if DEBUG() macros are enabled.
@@ -390,10 +389,9 @@ DebugPrintEnabled ( VOID
)
{
- return (BOOLEAN) ((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_PRINT_ENABLED) != 0);
+ return (BOOLEAN)((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_PRINT_ENABLED) != 0);
}
-
/**
Returns TRUE if DEBUG_CODE() macros are enabled.
@@ -410,10 +408,9 @@ DebugCodeEnabled ( VOID
)
{
- return (BOOLEAN) ((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_CODE_ENABLED) != 0);
+ return (BOOLEAN)((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_CODE_ENABLED) != 0);
}
-
/**
Returns TRUE if DEBUG_CLEAR_MEMORY() macro is enabled.
@@ -430,10 +427,9 @@ DebugClearMemoryEnabled ( VOID
)
{
- return (BOOLEAN) ((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED) != 0);
+ return (BOOLEAN)((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED) != 0);
}
-
/**
Returns TRUE if any one of the bit is set both in ErrorLevel and PcdFixedDebugPrintErrorLevel.
@@ -446,9 +442,8 @@ DebugClearMemoryEnabled ( BOOLEAN
EFIAPI
DebugPrintLevelEnabled (
- IN CONST UINTN ErrorLevel
+ IN CONST UINTN ErrorLevel
)
{
- return (BOOLEAN) ((ErrorLevel & PcdGet32(PcdFixedDebugPrintErrorLevel)) != 0);
+ return (BOOLEAN)((ErrorLevel & PcdGet32 (PcdFixedDebugPrintErrorLevel)) != 0);
}
-
diff --git a/MdeModulePkg/Library/PeiDebugPrintHobLib/PeiDebugPrintHobLib.c b/MdeModulePkg/Library/PeiDebugPrintHobLib/PeiDebugPrintHobLib.c index e545be206f..1228587b9d 100644 --- a/MdeModulePkg/Library/PeiDebugPrintHobLib/PeiDebugPrintHobLib.c +++ b/MdeModulePkg/Library/PeiDebugPrintHobLib/PeiDebugPrintHobLib.c @@ -16,7 +16,6 @@ #include <Ppi/ReadOnlyVariable2.h>
#include <Guid/DebugMask.h>
-
/**
The constructor reads variable and sets HOB
@@ -29,15 +28,15 @@ EFI_STATUS
EFIAPI
PeiDebugPrintHobLibConstructor (
- IN EFI_PEI_FILE_HANDLE FileHandle,
- IN CONST EFI_PEI_SERVICES **PeiServices
+ IN EFI_PEI_FILE_HANDLE FileHandle,
+ IN CONST EFI_PEI_SERVICES **PeiServices
)
{
- EFI_STATUS Status;
- EFI_PEI_READ_ONLY_VARIABLE2_PPI *Variable;
- UINTN Size;
- UINT64 GlobalErrorLevel;
- UINT32 HobErrorLevel;
+ EFI_STATUS Status;
+ EFI_PEI_READ_ONLY_VARIABLE2_PPI *Variable;
+ UINTN Size;
+ UINT64 GlobalErrorLevel;
+ UINT32 HobErrorLevel;
Status = PeiServicesLocatePpi (
&gEfiPeiReadOnlyVariable2PpiGuid,
@@ -46,7 +45,7 @@ PeiDebugPrintHobLibConstructor ( (VOID **)&Variable
);
if (!EFI_ERROR (Status)) {
- Size = sizeof (GlobalErrorLevel);
+ Size = sizeof (GlobalErrorLevel);
Status = Variable->GetVariable (
Variable,
DEBUG_MASK_VARIABLE_NAME,
diff --git a/MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c b/MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c index fb47401466..7ae5b16c84 100644 --- a/MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c +++ b/MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c @@ -25,7 +25,7 @@ // VA_LIST can not initialize to NULL for all compiler, so we use this to
// indicate a null VA_LIST
//
-VA_LIST mVaListNull;
+VA_LIST mVaListNull;
/**
Prints a debug message to the debug output device if the specified error level is enabled.
@@ -53,7 +53,7 @@ DebugPrint ( ...
)
{
- VA_LIST Marker;
+ VA_LIST Marker;
VA_START (Marker, Format);
DebugVPrint (ErrorLevel, Format, Marker);
@@ -84,10 +84,10 @@ DebugPrint ( **/
VOID
DebugPrintMarker (
- IN UINTN ErrorLevel,
- IN CONST CHAR8 *Format,
- IN VA_LIST VaListMarker,
- IN BASE_LIST BaseListMarker
+ IN UINTN ErrorLevel,
+ IN CONST CHAR8 *Format,
+ IN VA_LIST VaListMarker,
+ IN BASE_LIST BaseListMarker
)
{
UINT64 Buffer[(EFI_STATUS_CODE_DATA_MAX_SIZE / sizeof (UINT64)) + 1];
@@ -152,8 +152,10 @@ DebugPrintMarker ( // Copy the Format string into the record. It will be truncated if it's too long.
//
AsciiStrnCpyS (
- FormatString, sizeof(Buffer) - (4 + sizeof(EFI_DEBUG_INFO) + 12 * sizeof(UINT64)),
- Format, sizeof(Buffer) - (4 + sizeof(EFI_DEBUG_INFO) + 12 * sizeof(UINT64)) - 1
+ FormatString,
+ sizeof (Buffer) - (4 + sizeof (EFI_DEBUG_INFO) + 12 * sizeof (UINT64)),
+ Format,
+ sizeof (Buffer) - (4 + sizeof (EFI_DEBUG_INFO) + 12 * sizeof (UINT64)) - 1
);
//
@@ -166,37 +168,41 @@ DebugPrintMarker ( // Use the actual format string.
//
Format = FormatString;
- for (; *Format != '\0'; Format++) {
+ for ( ; *Format != '\0'; Format++) {
//
// Only format with prefix % is processed.
//
if (*Format != '%') {
continue;
}
+
Long = FALSE;
//
// Parse Flags and Width
//
for (Format++; TRUE; Format++) {
- if (*Format == '.' || *Format == '-' || *Format == '+' || *Format == ' ') {
+ if ((*Format == '.') || (*Format == '-') || (*Format == '+') || (*Format == ' ')) {
//
// These characters in format field are omitted.
//
continue;
}
- if (*Format >= '0' && *Format <= '9') {
+
+ if ((*Format >= '0') && (*Format <= '9')) {
//
// These characters in format field are omitted.
//
continue;
}
- if (*Format == 'L' || *Format == 'l') {
+
+ if ((*Format == 'L') || (*Format == 'l')) {
//
// 'L" or "l" in format field means the number being printed is a UINT64
//
Long = TRUE;
continue;
}
+
if (*Format == '*') {
//
// '*' in format field means the precision of the field is specified by
@@ -207,8 +213,10 @@ DebugPrintMarker ( } else {
BASE_ARG (BaseListMarkerPointer, UINTN) = BASE_ARG (BaseListMarker, UINTN);
}
+
continue;
}
+
if (*Format == '\0') {
//
// Make no output if Format string terminates unexpectedly when
@@ -216,6 +224,7 @@ DebugPrintMarker ( //
Format--;
}
+
//
// When valid argument type detected or format string terminates unexpectedly,
// the inner loop is done.
@@ -229,7 +238,8 @@ DebugPrintMarker ( if ((*Format == 'p') && (sizeof (VOID *) > 4)) {
Long = TRUE;
}
- if (*Format == 'p' || *Format == 'X' || *Format == 'x' || *Format == 'd' || *Format == 'u') {
+
+ if ((*Format == 'p') || (*Format == 'X') || (*Format == 'x') || (*Format == 'd') || (*Format == 'u')) {
if (Long) {
if (BaseListMarker == NULL) {
BASE_ARG (BaseListMarkerPointer, INT64) = VA_ARG (VaListMarker, INT64);
@@ -243,7 +253,7 @@ DebugPrintMarker ( BASE_ARG (BaseListMarkerPointer, int) = BASE_ARG (BaseListMarker, int);
}
}
- } else if (*Format == 's' || *Format == 'S' || *Format == 'a' || *Format == 'g' || *Format == 't') {
+ } else if ((*Format == 's') || (*Format == 'S') || (*Format == 'a') || (*Format == 'g') || (*Format == 't')) {
if (BaseListMarker == NULL) {
BASE_ARG (BaseListMarkerPointer, VOID *) = VA_ARG (VaListMarker, VOID *);
} else {
@@ -310,9 +320,9 @@ DebugPrintMarker ( VOID
EFIAPI
DebugVPrint (
- IN UINTN ErrorLevel,
- IN CONST CHAR8 *Format,
- IN VA_LIST VaListMarker
+ IN UINTN ErrorLevel,
+ IN CONST CHAR8 *Format,
+ IN VA_LIST VaListMarker
)
{
DebugPrintMarker (ErrorLevel, Format, VaListMarker, NULL);
@@ -338,9 +348,9 @@ DebugVPrint ( VOID
EFIAPI
DebugBPrint (
- IN UINTN ErrorLevel,
- IN CONST CHAR8 *Format,
- IN BASE_LIST BaseListMarker
+ IN UINTN ErrorLevel,
+ IN CONST CHAR8 *Format,
+ IN BASE_LIST BaseListMarker
)
{
DebugPrintMarker (ErrorLevel, Format, mVaListNull, BaseListMarker);
@@ -375,7 +385,7 @@ DebugAssert ( IN CONST CHAR8 *Description
)
{
- UINT64 Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE / sizeof(UINT64)];
+ UINT64 Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE / sizeof (UINT64)];
EFI_DEBUG_ASSERT_DATA *AssertData;
UINTN HeaderSize;
UINTN TotalSize;
@@ -387,13 +397,13 @@ DebugAssert ( //
// Get string size
//
- HeaderSize = sizeof (EFI_DEBUG_ASSERT_DATA);
+ HeaderSize = sizeof (EFI_DEBUG_ASSERT_DATA);
//
// Compute string size of module name enclosed by []
//
- ModuleNameSize = 2 + AsciiStrSize (gEfiCallerBaseName);
- FileNameSize = AsciiStrSize (FileName);
- DescriptionSize = AsciiStrSize (Description);
+ ModuleNameSize = 2 + AsciiStrSize (gEfiCallerBaseName);
+ FileNameSize = AsciiStrSize (FileName);
+ DescriptionSize = AsciiStrSize (Description);
//
// Make sure it will all fit in the passed in buffer.
@@ -422,12 +432,13 @@ DebugAssert ( }
}
}
+
//
// Fill in EFI_DEBUG_ASSERT_DATA
//
- AssertData = (EFI_DEBUG_ASSERT_DATA *)Buffer;
+ AssertData = (EFI_DEBUG_ASSERT_DATA *)Buffer;
AssertData->LineNumber = (UINT32)LineNumber;
- TotalSize = sizeof (EFI_DEBUG_ASSERT_DATA);
+ TotalSize = sizeof (EFI_DEBUG_ASSERT_DATA);
Temp = (CHAR8 *)(AssertData + 1);
@@ -435,24 +446,24 @@ DebugAssert ( // Copy Ascii [ModuleName].
//
if (ModuleNameSize != 0) {
- CopyMem(Temp, "[", 1);
- CopyMem(Temp + 1, gEfiCallerBaseName, ModuleNameSize - 3);
- CopyMem(Temp + ModuleNameSize - 2, "] ", 2);
+ CopyMem (Temp, "[", 1);
+ CopyMem (Temp + 1, gEfiCallerBaseName, ModuleNameSize - 3);
+ CopyMem (Temp + ModuleNameSize - 2, "] ", 2);
}
//
// Copy Ascii FileName including NULL terminator.
//
- Temp = CopyMem (Temp + ModuleNameSize, FileName, FileNameSize);
+ Temp = CopyMem (Temp + ModuleNameSize, FileName, FileNameSize);
Temp[FileNameSize - 1] = 0;
- TotalSize += (ModuleNameSize + FileNameSize);
+ TotalSize += (ModuleNameSize + FileNameSize);
//
// Copy Ascii Description include NULL terminator.
//
- Temp = CopyMem (Temp + FileNameSize, Description, DescriptionSize);
+ Temp = CopyMem (Temp + FileNameSize, Description, DescriptionSize);
Temp[DescriptionSize - 1] = 0;
- TotalSize += DescriptionSize;
+ TotalSize += DescriptionSize;
REPORT_STATUS_CODE_EX (
(EFI_ERROR_CODE | EFI_ERROR_UNRECOVERED),
@@ -474,7 +485,6 @@ DebugAssert ( }
}
-
/**
Fills a target buffer with PcdDebugClearMemoryValue, and returns the target buffer.
@@ -502,7 +512,6 @@ DebugClearMemory ( return SetMem (Buffer, Length, PcdGet8 (PcdDebugClearMemoryValue));
}
-
/**
Returns TRUE if ASSERT() macros are enabled.
@@ -519,10 +528,9 @@ DebugAssertEnabled ( VOID
)
{
- return (BOOLEAN) ((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED) != 0);
+ return (BOOLEAN)((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED) != 0);
}
-
/**
Returns TRUE if DEBUG() macros are enabled.
@@ -539,10 +547,9 @@ DebugPrintEnabled ( VOID
)
{
- return (BOOLEAN) ((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_PRINT_ENABLED) != 0);
+ return (BOOLEAN)((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_PRINT_ENABLED) != 0);
}
-
/**
Returns TRUE if DEBUG_CODE() macros are enabled.
@@ -559,10 +566,9 @@ DebugCodeEnabled ( VOID
)
{
- return (BOOLEAN) ((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_CODE_ENABLED) != 0);
+ return (BOOLEAN)((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_CODE_ENABLED) != 0);
}
-
/**
Returns TRUE if DEBUG_CLEAR_MEMORY() macro is enabled.
@@ -579,7 +585,7 @@ DebugClearMemoryEnabled ( VOID
)
{
- return (BOOLEAN) ((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED) != 0);
+ return (BOOLEAN)((PcdGet8 (PcdDebugPropertyMask) & DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED) != 0);
}
/**
@@ -594,8 +600,8 @@ DebugClearMemoryEnabled ( BOOLEAN
EFIAPI
DebugPrintLevelEnabled (
- IN CONST UINTN ErrorLevel
+ IN CONST UINTN ErrorLevel
)
{
- return (BOOLEAN) ((ErrorLevel & PcdGet32(PcdFixedDebugPrintErrorLevel)) != 0);
+ return (BOOLEAN)((ErrorLevel & PcdGet32 (PcdFixedDebugPrintErrorLevel)) != 0);
}
diff --git a/MdeModulePkg/Library/PeiIpmiLibIpmiPpi/PeiIpmiLibIpmiPpi.c b/MdeModulePkg/Library/PeiIpmiLibIpmiPpi/PeiIpmiLibIpmiPpi.c index 648af08761..a543a11b7c 100644 --- a/MdeModulePkg/Library/PeiIpmiLibIpmiPpi/PeiIpmiLibIpmiPpi.c +++ b/MdeModulePkg/Library/PeiIpmiLibIpmiPpi/PeiIpmiLibIpmiPpi.c @@ -12,7 +12,6 @@ #include <Library/PeiServicesLib.h>
#include <Library/DebugLib.h>
-
/**
This service enables submitting commands via Ipmi.
@@ -34,23 +33,23 @@ EFI_STATUS
EFIAPI
IpmiSubmitCommand (
- IN UINT8 NetFunction,
- IN UINT8 Command,
- IN UINT8 *RequestData,
- IN UINT32 RequestDataSize,
- OUT UINT8 *ResponseData,
- IN OUT UINT32 *ResponseDataSize
+ IN UINT8 NetFunction,
+ IN UINT8 Command,
+ IN UINT8 *RequestData,
+ IN UINT32 RequestDataSize,
+ OUT UINT8 *ResponseData,
+ IN OUT UINT32 *ResponseDataSize
)
{
- EFI_STATUS Status;
- PEI_IPMI_PPI *IpmiPpi;
+ EFI_STATUS Status;
+ PEI_IPMI_PPI *IpmiPpi;
- Status = PeiServicesLocatePpi(
- &gPeiIpmiPpiGuid,
- 0,
- NULL,
- (VOID **) &IpmiPpi
- );
+ Status = PeiServicesLocatePpi (
+ &gPeiIpmiPpiGuid,
+ 0,
+ NULL,
+ (VOID **)&IpmiPpi
+ );
if (EFI_ERROR (Status)) {
//
// Ipmi Ppi is not installed. So, IPMI device is not present.
@@ -60,16 +59,17 @@ IpmiSubmitCommand ( }
Status = IpmiPpi->IpmiSubmitCommand (
- IpmiPpi,
- NetFunction,
- Command,
- RequestData,
- RequestDataSize,
- ResponseData,
- ResponseDataSize
- );
+ IpmiPpi,
+ NetFunction,
+ Command,
+ RequestData,
+ RequestDataSize,
+ ResponseData,
+ ResponseDataSize
+ );
if (EFI_ERROR (Status)) {
return Status;
}
+
return EFI_SUCCESS;
}
diff --git a/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c b/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c index ac033d4a6a..93edc01014 100644 --- a/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c +++ b/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c @@ -13,7 +13,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent **/
-
#include <PiPei.h>
#include <Guid/ExtendedFirmwarePerformance.h>
@@ -27,9 +26,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include <Library/PcdLib.h>
#include <Library/BaseMemoryLib.h>
-#define STRING_SIZE (FPDT_STRING_EVENT_RECORD_NAME_LENGTH * sizeof (CHAR8))
-#define PEI_MAX_RECORD_SIZE (sizeof (FPDT_DUAL_GUID_STRING_EVENT_RECORD) + STRING_SIZE)
-
+#define STRING_SIZE (FPDT_STRING_EVENT_RECORD_NAME_LENGTH * sizeof (CHAR8))
+#define PEI_MAX_RECORD_SIZE (sizeof (FPDT_DUAL_GUID_STRING_EVENT_RECORD) + STRING_SIZE)
/**
Return the pointer to the FPDT record in the allocated memory.
@@ -46,38 +44,40 @@ GetFpdtRecordPtr ( IN UINT8 RecordSize,
IN OUT FPDT_RECORD_PTR *FpdtRecordPtr,
IN OUT FPDT_PEI_EXT_PERF_HEADER **PeiPerformanceLogHeader
-)
+ )
{
- UINT16 PeiPerformanceLogEntries;
- UINTN PeiPerformanceSize;
- UINT8 *PeiFirmwarePerformance;
- EFI_HOB_GUID_TYPE *GuidHob;
+ UINT16 PeiPerformanceLogEntries;
+ UINTN PeiPerformanceSize;
+ UINT8 *PeiFirmwarePerformance;
+ EFI_HOB_GUID_TYPE *GuidHob;
//
// Get the number of PeiPerformanceLogEntries form PCD.
//
- PeiPerformanceLogEntries = (UINT16) (PcdGet16 (PcdMaxPeiPerformanceLogEntries16) != 0 ?
- PcdGet16 (PcdMaxPeiPerformanceLogEntries16) :
- PcdGet8 (PcdMaxPeiPerformanceLogEntries));
+ PeiPerformanceLogEntries = (UINT16)(PcdGet16 (PcdMaxPeiPerformanceLogEntries16) != 0 ?
+ PcdGet16 (PcdMaxPeiPerformanceLogEntries16) :
+ PcdGet8 (PcdMaxPeiPerformanceLogEntries));
//
// Create GUID HOB Data.
//
- GuidHob = GetFirstGuidHob (&gEdkiiFpdtExtendedFirmwarePerformanceGuid);
+ GuidHob = GetFirstGuidHob (&gEdkiiFpdtExtendedFirmwarePerformanceGuid);
PeiFirmwarePerformance = NULL;
while (GuidHob != NULL) {
//
// PEI Performance HOB was found, then return the existing one.
//
- PeiFirmwarePerformance = (UINT8*)GET_GUID_HOB_DATA (GuidHob);
+ PeiFirmwarePerformance = (UINT8 *)GET_GUID_HOB_DATA (GuidHob);
*PeiPerformanceLogHeader = (FPDT_PEI_EXT_PERF_HEADER *)PeiFirmwarePerformance;
- if (!(*PeiPerformanceLogHeader)->HobIsFull && (*PeiPerformanceLogHeader)->SizeOfAllEntries + RecordSize > (PeiPerformanceLogEntries * PEI_MAX_RECORD_SIZE)) {
+ if (!(*PeiPerformanceLogHeader)->HobIsFull && ((*PeiPerformanceLogHeader)->SizeOfAllEntries + RecordSize > (PeiPerformanceLogEntries * PEI_MAX_RECORD_SIZE))) {
(*PeiPerformanceLogHeader)->HobIsFull = TRUE;
}
- if (!(*PeiPerformanceLogHeader)->HobIsFull && (*PeiPerformanceLogHeader)->SizeOfAllEntries + RecordSize <= (PeiPerformanceLogEntries * PEI_MAX_RECORD_SIZE)) {
+
+ if (!(*PeiPerformanceLogHeader)->HobIsFull && ((*PeiPerformanceLogHeader)->SizeOfAllEntries + RecordSize <= (PeiPerformanceLogEntries * PEI_MAX_RECORD_SIZE))) {
FpdtRecordPtr->RecordHeader = (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER *)(PeiFirmwarePerformance + sizeof (FPDT_PEI_EXT_PERF_HEADER) + (*PeiPerformanceLogHeader)->SizeOfAllEntries);
break;
}
+
//
// Previous HOB is used, then find next one.
//
@@ -88,12 +88,12 @@ GetFpdtRecordPtr ( //
// PEI Performance HOB was not found, then build one.
//
- PeiPerformanceSize = sizeof (FPDT_PEI_EXT_PERF_HEADER) +
- PEI_MAX_RECORD_SIZE * PeiPerformanceLogEntries;
- PeiFirmwarePerformance = (UINT8*)BuildGuidHob (&gEdkiiFpdtExtendedFirmwarePerformanceGuid, PeiPerformanceSize);
+ PeiPerformanceSize = sizeof (FPDT_PEI_EXT_PERF_HEADER) +
+ PEI_MAX_RECORD_SIZE * PeiPerformanceLogEntries;
+ PeiFirmwarePerformance = (UINT8 *)BuildGuidHob (&gEdkiiFpdtExtendedFirmwarePerformanceGuid, PeiPerformanceSize);
if (PeiFirmwarePerformance != NULL) {
ZeroMem (PeiFirmwarePerformance, PeiPerformanceSize);
- (*PeiPerformanceLogHeader) = (FPDT_PEI_EXT_PERF_HEADER *)PeiFirmwarePerformance;
+ (*PeiPerformanceLogHeader) = (FPDT_PEI_EXT_PERF_HEADER *)PeiFirmwarePerformance;
FpdtRecordPtr->RecordHeader = (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER *)(PeiFirmwarePerformance + sizeof (FPDT_PEI_EXT_PERF_HEADER));
}
}
@@ -126,16 +126,17 @@ IsKnownTokens ( return FALSE;
}
- if (AsciiStrCmp (Token, SEC_TOK) == 0 ||
- AsciiStrCmp (Token, PEI_TOK) == 0 ||
- AsciiStrCmp (Token, DXE_TOK) == 0 ||
- AsciiStrCmp (Token, BDS_TOK) == 0 ||
- AsciiStrCmp (Token, DRIVERBINDING_START_TOK) == 0 ||
- AsciiStrCmp (Token, DRIVERBINDING_SUPPORT_TOK) == 0 ||
- AsciiStrCmp (Token, DRIVERBINDING_STOP_TOK) == 0 ||
- AsciiStrCmp (Token, LOAD_IMAGE_TOK) == 0 ||
- AsciiStrCmp (Token, START_IMAGE_TOK) == 0 ||
- AsciiStrCmp (Token, PEIM_TOK) == 0) {
+ if ((AsciiStrCmp (Token, SEC_TOK) == 0) ||
+ (AsciiStrCmp (Token, PEI_TOK) == 0) ||
+ (AsciiStrCmp (Token, DXE_TOK) == 0) ||
+ (AsciiStrCmp (Token, BDS_TOK) == 0) ||
+ (AsciiStrCmp (Token, DRIVERBINDING_START_TOK) == 0) ||
+ (AsciiStrCmp (Token, DRIVERBINDING_SUPPORT_TOK) == 0) ||
+ (AsciiStrCmp (Token, DRIVERBINDING_STOP_TOK) == 0) ||
+ (AsciiStrCmp (Token, LOAD_IMAGE_TOK) == 0) ||
+ (AsciiStrCmp (Token, START_IMAGE_TOK) == 0) ||
+ (AsciiStrCmp (Token, PEIM_TOK) == 0))
+ {
return TRUE;
} else {
return FALSE;
@@ -153,19 +154,20 @@ Check whether the ID is a known one which map to the known Token. **/
BOOLEAN
IsKnownID (
- IN UINT32 Identifier
+ IN UINT32 Identifier
)
{
- if (Identifier == MODULE_START_ID ||
- Identifier == MODULE_END_ID ||
- Identifier == MODULE_LOADIMAGE_START_ID ||
- Identifier == MODULE_LOADIMAGE_END_ID ||
- Identifier == MODULE_DB_START_ID ||
- Identifier == MODULE_DB_END_ID ||
- Identifier == MODULE_DB_SUPPORT_START_ID ||
- Identifier == MODULE_DB_SUPPORT_END_ID ||
- Identifier == MODULE_DB_STOP_START_ID ||
- Identifier == MODULE_DB_STOP_END_ID) {
+ if ((Identifier == MODULE_START_ID) ||
+ (Identifier == MODULE_END_ID) ||
+ (Identifier == MODULE_LOADIMAGE_START_ID) ||
+ (Identifier == MODULE_LOADIMAGE_END_ID) ||
+ (Identifier == MODULE_DB_START_ID) ||
+ (Identifier == MODULE_DB_END_ID) ||
+ (Identifier == MODULE_DB_SUPPORT_START_ID) ||
+ (Identifier == MODULE_DB_SUPPORT_END_ID) ||
+ (Identifier == MODULE_DB_STOP_START_ID) ||
+ (Identifier == MODULE_DB_STOP_END_ID))
+ {
return TRUE;
} else {
return FALSE;
@@ -188,10 +190,10 @@ IsKnownID ( **/
EFI_STATUS
GetFpdtRecordId (
- IN BOOLEAN Attribute,
- IN CONST VOID *Handle,
- IN CONST CHAR8 *String,
- OUT UINT16 *ProgressID
+ IN BOOLEAN Attribute,
+ IN CONST VOID *Handle,
+ IN CONST CHAR8 *String,
+ OUT UINT16 *ProgressID
)
{
//
@@ -199,33 +201,38 @@ GetFpdtRecordId ( // When PcdEdkiiFpdtStringRecordEnableOnly is TRUE, all records are with type of FPDT_DYNAMIC_STRING_EVENT_TYPE.
//
if (String != NULL) {
- if (AsciiStrCmp (String, LOAD_IMAGE_TOK) == 0) { // "LoadImage:"
+ if (AsciiStrCmp (String, LOAD_IMAGE_TOK) == 0) {
+ // "LoadImage:"
if (Attribute == PerfStartEntry) {
*ProgressID = MODULE_LOADIMAGE_START_ID;
} else {
*ProgressID = MODULE_LOADIMAGE_END_ID;
}
- } else if (AsciiStrCmp (String, SEC_TOK) == 0 || // "SEC"
- AsciiStrCmp (String, PEI_TOK) == 0) { // "PEI"
+ } else if ((AsciiStrCmp (String, SEC_TOK) == 0) || // "SEC"
+ (AsciiStrCmp (String, PEI_TOK) == 0)) // "PEI"
+ {
if (Attribute == PerfStartEntry) {
*ProgressID = PERF_CROSSMODULE_START_ID;
} else {
*ProgressID = PERF_CROSSMODULE_END_ID;
}
- } else if (AsciiStrCmp (String, PEIM_TOK) == 0) { // "PEIM"
+ } else if (AsciiStrCmp (String, PEIM_TOK) == 0) {
+ // "PEIM"
if (Attribute == PerfStartEntry) {
*ProgressID = MODULE_START_ID;
} else {
*ProgressID = MODULE_END_ID;
}
- } else { //Pref used in Modules.
+ } else {
+ // Pref used in Modules.
if (Attribute == PerfStartEntry) {
*ProgressID = PERF_INMODULE_START_ID;
} else {
*ProgressID = PERF_INMODULE_END_ID;
}
}
- } else if (Handle != NULL) { //Pref used in Modules.
+ } else if (Handle != NULL) {
+ // Pref used in Modules.
if (Attribute == PerfStartEntry) {
*ProgressID = PERF_INMODULE_START_ID;
} else {
@@ -249,9 +256,9 @@ GetFpdtRecordId ( **/
VOID
CopyStringIntoPerfRecordAndUpdateLength (
- IN OUT CHAR8 *Destination,
+ IN OUT CHAR8 *Destination,
IN CONST CHAR8 *Source,
- IN OUT UINT8 *Length
+ IN OUT UINT8 *Length
)
{
UINTN StringLen;
@@ -267,18 +274,18 @@ CopyStringIntoPerfRecordAndUpdateLength ( DestMax = STRING_SIZE;
}
}
+
StringLen = AsciiStrLen (Source);
if (StringLen >= DestMax) {
StringLen = DestMax -1;
}
- AsciiStrnCpyS(Destination, DestMax, Source, StringLen);
+ AsciiStrnCpyS (Destination, DestMax, Source, StringLen);
*Length += (UINT8)DestMax;
return;
}
-
/**
Convert PEI performance log to FPDT String boot record.
@@ -309,16 +316,16 @@ InsertFpdtRecord ( IN PERF_MEASUREMENT_ATTRIBUTE Attribute
)
{
- FPDT_RECORD_PTR FpdtRecordPtr;
- CONST VOID *ModuleGuid;
- CONST CHAR8 *StringPtr;
- EFI_STATUS Status;
- UINT64 TimeStamp;
- FPDT_PEI_EXT_PERF_HEADER *PeiPerformanceLogHeader;
-
- StringPtr = NULL;
+ FPDT_RECORD_PTR FpdtRecordPtr;
+ CONST VOID *ModuleGuid;
+ CONST CHAR8 *StringPtr;
+ EFI_STATUS Status;
+ UINT64 TimeStamp;
+ FPDT_PEI_EXT_PERF_HEADER *PeiPerformanceLogHeader;
+
+ StringPtr = NULL;
FpdtRecordPtr.RecordHeader = NULL;
- PeiPerformanceLogHeader = NULL;
+ PeiPerformanceLogHeader = NULL;
//
// 1. Get the Perf Id for records from PERF_START/PERF_END, PERF_START_EX/PERF_END_EX.
@@ -337,7 +344,7 @@ InsertFpdtRecord ( if ((PerfId != 0) && (IsKnownID (PerfId)) && (!IsKnownTokens (String))) {
return EFI_UNSUPPORTED;
} else if ((PerfId != 0) && (!IsKnownID (PerfId)) && (!IsKnownTokens (String))) {
- if (Attribute == PerfStartEntry && ((PerfId & 0x000F) != 0)) {
+ if ((Attribute == PerfStartEntry) && ((PerfId & 0x000F) != 0)) {
PerfId &= 0xFFF0;
} else if ((Attribute == PerfEndEntry) && ((PerfId & 0x000F) == 0)) {
PerfId += 1;
@@ -383,113 +390,123 @@ InsertFpdtRecord ( // 5. Fill in the FPDT record according to different Performance Identifier.
//
switch (PerfId) {
- case MODULE_START_ID:
- case MODULE_END_ID:
- StringPtr = PEIM_TOK;
- if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
- FpdtRecordPtr.GuidEvent->Header.Type = FPDT_GUID_EVENT_TYPE;
- FpdtRecordPtr.GuidEvent->Header.Length = sizeof (FPDT_GUID_EVENT_RECORD);
- FpdtRecordPtr.GuidEvent->Header.Revision = FPDT_RECORD_REVISION_1;
- FpdtRecordPtr.GuidEvent->ProgressID = PerfId;
- FpdtRecordPtr.GuidEvent->Timestamp = TimeStamp;
- CopyMem (&FpdtRecordPtr.GuidEvent->Guid, ModuleGuid, sizeof (EFI_GUID));
- }
- break;
-
- case MODULE_LOADIMAGE_START_ID:
- case MODULE_LOADIMAGE_END_ID:
- StringPtr = LOAD_IMAGE_TOK;
- if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
- FpdtRecordPtr.GuidQwordEvent->Header.Type = FPDT_GUID_QWORD_EVENT_TYPE;
- FpdtRecordPtr.GuidQwordEvent->Header.Length = sizeof (FPDT_GUID_QWORD_EVENT_RECORD);
- FpdtRecordPtr.GuidQwordEvent->Header.Revision = FPDT_RECORD_REVISION_1;
- FpdtRecordPtr.GuidQwordEvent->ProgressID = PerfId;
- FpdtRecordPtr.GuidQwordEvent->Timestamp = TimeStamp;
- if (PerfId == MODULE_LOADIMAGE_START_ID) {
- PeiPerformanceLogHeader->LoadImageCount++;
+ case MODULE_START_ID:
+ case MODULE_END_ID:
+ StringPtr = PEIM_TOK;
+ if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
+ FpdtRecordPtr.GuidEvent->Header.Type = FPDT_GUID_EVENT_TYPE;
+ FpdtRecordPtr.GuidEvent->Header.Length = sizeof (FPDT_GUID_EVENT_RECORD);
+ FpdtRecordPtr.GuidEvent->Header.Revision = FPDT_RECORD_REVISION_1;
+ FpdtRecordPtr.GuidEvent->ProgressID = PerfId;
+ FpdtRecordPtr.GuidEvent->Timestamp = TimeStamp;
+ CopyMem (&FpdtRecordPtr.GuidEvent->Guid, ModuleGuid, sizeof (EFI_GUID));
}
- FpdtRecordPtr.GuidQwordEvent->Qword = PeiPerformanceLogHeader->LoadImageCount;
- CopyMem (&FpdtRecordPtr.GuidQwordEvent->Guid, ModuleGuid, sizeof (EFI_GUID));
- }
- break;
-
- case PERF_EVENTSIGNAL_START_ID:
- case PERF_EVENTSIGNAL_END_ID:
- case PERF_CALLBACK_START_ID:
- case PERF_CALLBACK_END_ID:
- if (String == NULL || Guid == NULL) {
- return EFI_INVALID_PARAMETER;
- }
- StringPtr = String;
- if (AsciiStrLen (String) == 0) {
- StringPtr = "unknown name";
- }
- if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
- FpdtRecordPtr.DualGuidStringEvent->Header.Type = FPDT_DUAL_GUID_STRING_EVENT_TYPE;
- FpdtRecordPtr.DualGuidStringEvent->Header.Length = sizeof (FPDT_DUAL_GUID_STRING_EVENT_RECORD);
- FpdtRecordPtr.DualGuidStringEvent->Header.Revision = FPDT_RECORD_REVISION_1;
- FpdtRecordPtr.DualGuidStringEvent->ProgressID = PerfId;
- FpdtRecordPtr.DualGuidStringEvent->Timestamp = TimeStamp;
- CopyMem (&FpdtRecordPtr.DualGuidStringEvent->Guid1, ModuleGuid, sizeof (FpdtRecordPtr.DualGuidStringEvent->Guid1));
- CopyMem (&FpdtRecordPtr.DualGuidStringEvent->Guid2, Guid, sizeof (FpdtRecordPtr.DualGuidStringEvent->Guid2));
- CopyStringIntoPerfRecordAndUpdateLength (FpdtRecordPtr.DualGuidStringEvent->String, StringPtr, &FpdtRecordPtr.DualGuidStringEvent->Header.Length);
- }
- break;
-
- case PERF_EVENT_ID:
- case PERF_FUNCTION_START_ID:
- case PERF_FUNCTION_END_ID:
- case PERF_INMODULE_START_ID:
- case PERF_INMODULE_END_ID:
- case PERF_CROSSMODULE_START_ID:
- case PERF_CROSSMODULE_END_ID:
- if (String != NULL && AsciiStrLen (String) != 0) {
+
+ break;
+
+ case MODULE_LOADIMAGE_START_ID:
+ case MODULE_LOADIMAGE_END_ID:
+ StringPtr = LOAD_IMAGE_TOK;
+ if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
+ FpdtRecordPtr.GuidQwordEvent->Header.Type = FPDT_GUID_QWORD_EVENT_TYPE;
+ FpdtRecordPtr.GuidQwordEvent->Header.Length = sizeof (FPDT_GUID_QWORD_EVENT_RECORD);
+ FpdtRecordPtr.GuidQwordEvent->Header.Revision = FPDT_RECORD_REVISION_1;
+ FpdtRecordPtr.GuidQwordEvent->ProgressID = PerfId;
+ FpdtRecordPtr.GuidQwordEvent->Timestamp = TimeStamp;
+ if (PerfId == MODULE_LOADIMAGE_START_ID) {
+ PeiPerformanceLogHeader->LoadImageCount++;
+ }
+
+ FpdtRecordPtr.GuidQwordEvent->Qword = PeiPerformanceLogHeader->LoadImageCount;
+ CopyMem (&FpdtRecordPtr.GuidQwordEvent->Guid, ModuleGuid, sizeof (EFI_GUID));
+ }
+
+ break;
+
+ case PERF_EVENTSIGNAL_START_ID:
+ case PERF_EVENTSIGNAL_END_ID:
+ case PERF_CALLBACK_START_ID:
+ case PERF_CALLBACK_END_ID:
+ if ((String == NULL) || (Guid == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
StringPtr = String;
- } else {
- StringPtr = "unknown name";
- }
- if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
- FpdtRecordPtr.DynamicStringEvent->Header.Type = FPDT_DYNAMIC_STRING_EVENT_TYPE;
- FpdtRecordPtr.DynamicStringEvent->Header.Length = sizeof (FPDT_DYNAMIC_STRING_EVENT_RECORD);
- FpdtRecordPtr.DynamicStringEvent->Header.Revision = FPDT_RECORD_REVISION_1;
- FpdtRecordPtr.DynamicStringEvent->ProgressID = PerfId;
- FpdtRecordPtr.DynamicStringEvent->Timestamp = TimeStamp;
- CopyMem (&FpdtRecordPtr.DynamicStringEvent->Guid, ModuleGuid, sizeof (EFI_GUID));
- CopyStringIntoPerfRecordAndUpdateLength (FpdtRecordPtr.DynamicStringEvent->String, StringPtr, &FpdtRecordPtr.DynamicStringEvent->Header.Length);
- }
- break;
-
- default:
- if (Attribute != PerfEntry) {
- if (String != NULL && AsciiStrLen (String) != 0) {
- StringPtr = String;
- } else {
- StringPtr = "unknown name";
- }
- if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
- FpdtRecordPtr.DynamicStringEvent->Header.Type = FPDT_DYNAMIC_STRING_EVENT_TYPE;
- FpdtRecordPtr.DynamicStringEvent->Header.Length = sizeof (FPDT_DYNAMIC_STRING_EVENT_RECORD);
- FpdtRecordPtr.DynamicStringEvent->Header.Revision = FPDT_RECORD_REVISION_1;
- FpdtRecordPtr.DynamicStringEvent->ProgressID = PerfId;
- FpdtRecordPtr.DynamicStringEvent->Timestamp = TimeStamp;
- CopyMem (&FpdtRecordPtr.DynamicStringEvent->Guid, ModuleGuid, sizeof (FpdtRecordPtr.DynamicStringEvent->Guid));
- CopyStringIntoPerfRecordAndUpdateLength (FpdtRecordPtr.DynamicStringEvent->String, StringPtr, &FpdtRecordPtr.DynamicStringEvent->Header.Length);
- }
- } else {
- return EFI_INVALID_PARAMETER;
- }
- break;
+ if (AsciiStrLen (String) == 0) {
+ StringPtr = "unknown name";
+ }
+
+ if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
+ FpdtRecordPtr.DualGuidStringEvent->Header.Type = FPDT_DUAL_GUID_STRING_EVENT_TYPE;
+ FpdtRecordPtr.DualGuidStringEvent->Header.Length = sizeof (FPDT_DUAL_GUID_STRING_EVENT_RECORD);
+ FpdtRecordPtr.DualGuidStringEvent->Header.Revision = FPDT_RECORD_REVISION_1;
+ FpdtRecordPtr.DualGuidStringEvent->ProgressID = PerfId;
+ FpdtRecordPtr.DualGuidStringEvent->Timestamp = TimeStamp;
+ CopyMem (&FpdtRecordPtr.DualGuidStringEvent->Guid1, ModuleGuid, sizeof (FpdtRecordPtr.DualGuidStringEvent->Guid1));
+ CopyMem (&FpdtRecordPtr.DualGuidStringEvent->Guid2, Guid, sizeof (FpdtRecordPtr.DualGuidStringEvent->Guid2));
+ CopyStringIntoPerfRecordAndUpdateLength (FpdtRecordPtr.DualGuidStringEvent->String, StringPtr, &FpdtRecordPtr.DualGuidStringEvent->Header.Length);
+ }
+
+ break;
+
+ case PERF_EVENT_ID:
+ case PERF_FUNCTION_START_ID:
+ case PERF_FUNCTION_END_ID:
+ case PERF_INMODULE_START_ID:
+ case PERF_INMODULE_END_ID:
+ case PERF_CROSSMODULE_START_ID:
+ case PERF_CROSSMODULE_END_ID:
+ if ((String != NULL) && (AsciiStrLen (String) != 0)) {
+ StringPtr = String;
+ } else {
+ StringPtr = "unknown name";
+ }
+
+ if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
+ FpdtRecordPtr.DynamicStringEvent->Header.Type = FPDT_DYNAMIC_STRING_EVENT_TYPE;
+ FpdtRecordPtr.DynamicStringEvent->Header.Length = sizeof (FPDT_DYNAMIC_STRING_EVENT_RECORD);
+ FpdtRecordPtr.DynamicStringEvent->Header.Revision = FPDT_RECORD_REVISION_1;
+ FpdtRecordPtr.DynamicStringEvent->ProgressID = PerfId;
+ FpdtRecordPtr.DynamicStringEvent->Timestamp = TimeStamp;
+ CopyMem (&FpdtRecordPtr.DynamicStringEvent->Guid, ModuleGuid, sizeof (EFI_GUID));
+ CopyStringIntoPerfRecordAndUpdateLength (FpdtRecordPtr.DynamicStringEvent->String, StringPtr, &FpdtRecordPtr.DynamicStringEvent->Header.Length);
+ }
+
+ break;
+
+ default:
+ if (Attribute != PerfEntry) {
+ if ((String != NULL) && (AsciiStrLen (String) != 0)) {
+ StringPtr = String;
+ } else {
+ StringPtr = "unknown name";
+ }
+
+ if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
+ FpdtRecordPtr.DynamicStringEvent->Header.Type = FPDT_DYNAMIC_STRING_EVENT_TYPE;
+ FpdtRecordPtr.DynamicStringEvent->Header.Length = sizeof (FPDT_DYNAMIC_STRING_EVENT_RECORD);
+ FpdtRecordPtr.DynamicStringEvent->Header.Revision = FPDT_RECORD_REVISION_1;
+ FpdtRecordPtr.DynamicStringEvent->ProgressID = PerfId;
+ FpdtRecordPtr.DynamicStringEvent->Timestamp = TimeStamp;
+ CopyMem (&FpdtRecordPtr.DynamicStringEvent->Guid, ModuleGuid, sizeof (FpdtRecordPtr.DynamicStringEvent->Guid));
+ CopyStringIntoPerfRecordAndUpdateLength (FpdtRecordPtr.DynamicStringEvent->String, StringPtr, &FpdtRecordPtr.DynamicStringEvent->Header.Length);
+ }
+ } else {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ break;
}
//
// 5.2 When PcdEdkiiFpdtStringRecordEnableOnly==TRUE, create string record for all Perf entries.
//
if (PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
- FpdtRecordPtr.DynamicStringEvent->Header.Type = FPDT_DYNAMIC_STRING_EVENT_TYPE;
- FpdtRecordPtr.DynamicStringEvent->Header.Length = sizeof (FPDT_DYNAMIC_STRING_EVENT_RECORD);
- FpdtRecordPtr.DynamicStringEvent->Header.Revision = FPDT_RECORD_REVISION_1;
- FpdtRecordPtr.DynamicStringEvent->ProgressID = PerfId;
- FpdtRecordPtr.DynamicStringEvent->Timestamp = TimeStamp;
+ FpdtRecordPtr.DynamicStringEvent->Header.Type = FPDT_DYNAMIC_STRING_EVENT_TYPE;
+ FpdtRecordPtr.DynamicStringEvent->Header.Length = sizeof (FPDT_DYNAMIC_STRING_EVENT_RECORD);
+ FpdtRecordPtr.DynamicStringEvent->Header.Revision = FPDT_RECORD_REVISION_1;
+ FpdtRecordPtr.DynamicStringEvent->ProgressID = PerfId;
+ FpdtRecordPtr.DynamicStringEvent->Timestamp = TimeStamp;
if (Guid != NULL) {
//
// Cache the event guid in string event record.
@@ -498,6 +515,7 @@ InsertFpdtRecord ( } else {
CopyMem (&FpdtRecordPtr.DynamicStringEvent->Guid, ModuleGuid, sizeof (EFI_GUID));
}
+
CopyStringIntoPerfRecordAndUpdateLength (FpdtRecordPtr.DynamicStringEvent->String, StringPtr, &FpdtRecordPtr.DynamicStringEvent->Header.Length);
}
@@ -543,7 +561,7 @@ StartPerformanceMeasurementEx ( IN UINT32 Identifier
)
{
- CONST CHAR8 *String;
+ CONST CHAR8 *String;
if (Token != NULL) {
String = Token;
@@ -554,7 +572,6 @@ StartPerformanceMeasurementEx ( }
return (RETURN_STATUS)InsertFpdtRecord (Handle, NULL, String, TimeStamp, 0, (UINT16)Identifier, PerfStartEntry);
-
}
/**
@@ -589,7 +606,7 @@ EndPerformanceMeasurementEx ( IN UINT32 Identifier
)
{
- CONST CHAR8 *String;
+ CONST CHAR8 *String;
if (Token != NULL) {
String = Token;
@@ -648,13 +665,13 @@ EndPerformanceMeasurementEx ( UINTN
EFIAPI
GetPerformanceMeasurementEx (
- IN UINTN LogEntryKey,
- OUT CONST VOID **Handle,
- OUT CONST CHAR8 **Token,
- OUT CONST CHAR8 **Module,
- OUT UINT64 *StartTimeStamp,
- OUT UINT64 *EndTimeStamp,
- OUT UINT32 *Identifier
+ IN UINTN LogEntryKey,
+ OUT CONST VOID **Handle,
+ OUT CONST CHAR8 **Token,
+ OUT CONST CHAR8 **Module,
+ OUT UINT64 *StartTimeStamp,
+ OUT UINT64 *EndTimeStamp,
+ OUT UINT32 *Identifier
)
{
return 0;
@@ -771,12 +788,12 @@ EndPerformanceMeasurement ( UINTN
EFIAPI
GetPerformanceMeasurement (
- IN UINTN LogEntryKey,
- OUT CONST VOID **Handle,
- OUT CONST CHAR8 **Token,
- OUT CONST CHAR8 **Module,
- OUT UINT64 *StartTimeStamp,
- OUT UINT64 *EndTimeStamp
+ IN UINTN LogEntryKey,
+ OUT CONST VOID **Handle,
+ OUT CONST CHAR8 **Token,
+ OUT CONST CHAR8 **Module,
+ OUT UINT64 *StartTimeStamp,
+ OUT UINT64 *EndTimeStamp
)
{
return 0;
@@ -800,7 +817,7 @@ PerformanceMeasurementEnabled ( VOID
)
{
- return (BOOLEAN) ((PcdGet8(PcdPerformanceLibraryPropertyMask) & PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED) != 0);
+ return (BOOLEAN)((PcdGet8 (PcdPerformanceLibraryPropertyMask) & PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED) != 0);
}
/**
@@ -846,14 +863,15 @@ LogPerformanceMeasurement ( BOOLEAN
EFIAPI
LogPerformanceMeasurementEnabled (
- IN CONST UINTN Type
+ IN CONST UINTN Type
)
{
//
// When Performance measurement is enabled and the type is not filtered, the performance can be logged.
//
- if (PerformanceMeasurementEnabled () && (PcdGet8(PcdPerformanceLibraryPropertyMask) & Type) == 0) {
+ if (PerformanceMeasurementEnabled () && ((PcdGet8 (PcdPerformanceLibraryPropertyMask) & Type) == 0)) {
return TRUE;
}
+
return FALSE;
}
diff --git a/MdeModulePkg/Library/PeiReportStatusCodeLib/ReportStatusCodeLib.c b/MdeModulePkg/Library/PeiReportStatusCodeLib/ReportStatusCodeLib.c index 43b4d49d30..b0a5f61cda 100644 --- a/MdeModulePkg/Library/PeiReportStatusCodeLib/ReportStatusCodeLib.c +++ b/MdeModulePkg/Library/PeiReportStatusCodeLib/ReportStatusCodeLib.c @@ -45,41 +45,42 @@ **/
EFI_STATUS
InternalReportStatusCode (
- IN EFI_STATUS_CODE_TYPE Type,
- IN EFI_STATUS_CODE_VALUE Value,
- IN UINT32 Instance,
- IN CONST EFI_GUID *CallerId OPTIONAL,
- IN EFI_STATUS_CODE_DATA *Data OPTIONAL
+ IN EFI_STATUS_CODE_TYPE Type,
+ IN EFI_STATUS_CODE_VALUE Value,
+ IN UINT32 Instance,
+ IN CONST EFI_GUID *CallerId OPTIONAL,
+ IN EFI_STATUS_CODE_DATA *Data OPTIONAL
)
{
CONST EFI_PEI_SERVICES **PeiServices;
EFI_STATUS Status;
- if ((ReportProgressCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) ||
- (ReportErrorCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) ||
- (ReportDebugCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE)) {
+ if ((ReportProgressCodeEnabled () && (((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE)) ||
+ (ReportErrorCodeEnabled () && (((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE)) ||
+ (ReportDebugCodeEnabled () && (((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE)))
+ {
PeiServices = GetPeiServicesTablePointer ();
- Status = (*PeiServices)->ReportStatusCode (
- PeiServices,
- Type,
- Value,
- Instance,
- (EFI_GUID *)CallerId,
- Data
- );
+ Status = (*PeiServices)->ReportStatusCode (
+ PeiServices,
+ Type,
+ Value,
+ Instance,
+ (EFI_GUID *)CallerId,
+ Data
+ );
if (Status == EFI_NOT_AVAILABLE_YET) {
Status = OemHookStatusCodeInitialize ();
if (!EFI_ERROR (Status)) {
- return OemHookStatusCodeReport (Type, Value, Instance, (EFI_GUID *) CallerId, Data);
+ return OemHookStatusCodeReport (Type, Value, Instance, (EFI_GUID *)CallerId, Data);
}
}
+
return Status;
}
return EFI_UNSUPPORTED;
}
-
/**
Converts a status code to an 8-bit POST code value.
@@ -118,15 +119,16 @@ CodeTypeToPostCode ( // Convert Value to an 8 bit post code
//
if (((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) ||
- ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE)) {
- *PostCode = (UINT8) ((((Value & EFI_STATUS_CODE_CLASS_MASK) >> 24) << 5) |
- (((Value & EFI_STATUS_CODE_SUBCLASS_MASK) >> 16) & 0x1f));
+ ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE))
+ {
+ *PostCode = (UINT8)((((Value & EFI_STATUS_CODE_CLASS_MASK) >> 24) << 5) |
+ (((Value & EFI_STATUS_CODE_SUBCLASS_MASK) >> 16) & 0x1f));
return TRUE;
}
+
return FALSE;
}
-
/**
Extracts ASSERT() information from a status code structure.
@@ -180,17 +182,18 @@ ReportStatusCodeExtractAssertInfo ( if (((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) &&
((CodeType & EFI_STATUS_CODE_SEVERITY_MASK) == EFI_ERROR_UNRECOVERED) &&
- ((Value & EFI_STATUS_CODE_OPERATION_MASK) == EFI_SW_EC_ILLEGAL_SOFTWARE_STATE)) {
+ ((Value & EFI_STATUS_CODE_OPERATION_MASK) == EFI_SW_EC_ILLEGAL_SOFTWARE_STATE))
+ {
AssertData = (EFI_DEBUG_ASSERT_DATA *)(Data + 1);
*Filename = (CHAR8 *)(AssertData + 1);
*Description = *Filename + AsciiStrLen (*Filename) + 1;
*LineNumber = AssertData->LineNumber;
return TRUE;
}
+
return FALSE;
}
-
/**
Extracts DEBUG() information from a status code structure.
@@ -259,13 +262,12 @@ ReportStatusCodeExtractDebugInfo ( // 64-bit aligned is a must, otherwise retrieving 64-bit parameter from BASE_LIST will
// cause unalignment exception.
//
- *Marker = (BASE_LIST) (DebugInfo + 1);
+ *Marker = (BASE_LIST)(DebugInfo + 1);
*Format = (CHAR8 *)(((UINT64 *)*Marker) + 12);
return TRUE;
}
-
/**
Reports a status code.
@@ -297,7 +299,6 @@ ReportStatusCode ( return InternalReportStatusCode (Type, Value, 0, &gEfiCallerIdGuid, NULL);
}
-
/**
Reports a status code with a Device Path Protocol as the extended data.
@@ -341,7 +342,6 @@ ReportStatusCodeWithDevicePath ( return EFI_UNSUPPORTED;
}
-
/**
Reports a status code with an extended data buffer.
@@ -397,7 +397,6 @@ ReportStatusCodeWithExtendedData ( );
}
-
/**
Reports a status code with full parameters.
@@ -471,23 +470,26 @@ ReportStatusCodeEx ( DEBUG ((DEBUG_ERROR, "Status code extended data is too large to be reported!\n"));
return EFI_OUT_OF_RESOURCES;
}
- StatusCodeData = (EFI_STATUS_CODE_DATA *) Buffer;
- StatusCodeData->HeaderSize = (UINT16) sizeof (EFI_STATUS_CODE_DATA);
- StatusCodeData->Size = (UINT16) ExtendedDataSize;
+
+ StatusCodeData = (EFI_STATUS_CODE_DATA *)Buffer;
+ StatusCodeData->HeaderSize = (UINT16)sizeof (EFI_STATUS_CODE_DATA);
+ StatusCodeData->Size = (UINT16)ExtendedDataSize;
if (ExtendedDataGuid == NULL) {
ExtendedDataGuid = &gEfiStatusCodeSpecificDataGuid;
}
+
CopyGuid (&StatusCodeData->Type, ExtendedDataGuid);
if (ExtendedData != NULL) {
CopyMem (StatusCodeData + 1, ExtendedData, ExtendedDataSize);
}
+
if (CallerId == NULL) {
CallerId = &gEfiCallerIdGuid;
}
+
return InternalReportStatusCode (Type, Value, Instance, CallerId, StatusCodeData);
}
-
/**
Returns TRUE if status codes of type EFI_PROGRESS_CODE are enabled
@@ -506,10 +508,9 @@ ReportProgressCodeEnabled ( VOID
)
{
- return (BOOLEAN) ((PcdGet8 (PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED) != 0);
+ return (BOOLEAN)((PcdGet8 (PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED) != 0);
}
-
/**
Returns TRUE if status codes of type EFI_ERROR_CODE are enabled
@@ -528,10 +529,9 @@ ReportErrorCodeEnabled ( VOID
)
{
- return (BOOLEAN) ((PcdGet8 (PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED) != 0);
+ return (BOOLEAN)((PcdGet8 (PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED) != 0);
}
-
/**
Returns TRUE if status codes of type EFI_DEBUG_CODE are enabled
@@ -550,5 +550,5 @@ ReportDebugCodeEnabled ( VOID
)
{
- return (BOOLEAN) ((PcdGet8 (PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED) != 0);
+ return (BOOLEAN)((PcdGet8 (PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED) != 0);
}
diff --git a/MdeModulePkg/Library/PeiResetSystemLib/PeiResetSystemLib.c b/MdeModulePkg/Library/PeiResetSystemLib/PeiResetSystemLib.c index 6c8c770ca3..2a4ee80317 100644 --- a/MdeModulePkg/Library/PeiResetSystemLib/PeiResetSystemLib.c +++ b/MdeModulePkg/Library/PeiResetSystemLib/PeiResetSystemLib.c @@ -71,8 +71,8 @@ ResetShutdown ( VOID
EFIAPI
ResetPlatformSpecific (
- IN UINTN DataSize,
- IN VOID *ResetData
+ IN UINTN DataSize,
+ IN VOID *ResetData
)
{
PeiServicesResetSystem2 (EfiResetPlatformSpecific, EFI_SUCCESS, DataSize, ResetData);
@@ -93,10 +93,10 @@ ResetPlatformSpecific ( VOID
EFIAPI
ResetSystem (
- IN EFI_RESET_TYPE ResetType,
- IN EFI_STATUS ResetStatus,
- IN UINTN DataSize,
- IN VOID *ResetData OPTIONAL
+ IN EFI_RESET_TYPE ResetType,
+ IN EFI_STATUS ResetStatus,
+ IN UINTN DataSize,
+ IN VOID *ResetData OPTIONAL
)
{
PeiServicesResetSystem2 (ResetType, ResetStatus, DataSize, ResetData);
diff --git a/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptExecute.c b/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptExecute.c index f7fb787cd5..279daefac1 100644 --- a/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptExecute.c +++ b/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptExecute.c @@ -51,14 +51,14 @@ **/
EFI_STATUS
InternalSmbusExecute (
- IN UINTN SmbusAddress,
- IN EFI_SMBUS_OPERATION Operation,
- IN OUT UINTN *Length,
- IN OUT VOID *Buffer
+ IN UINTN SmbusAddress,
+ IN EFI_SMBUS_OPERATION Operation,
+ IN OUT UINTN *Length,
+ IN OUT VOID *Buffer
)
{
- EFI_STATUS Status;
- UINT8 WorkBuffer[MAX_SMBUS_BLOCK_LEN];
+ EFI_STATUS Status;
+ UINT8 WorkBuffer[MAX_SMBUS_BLOCK_LEN];
switch (Operation) {
case EfiSmbusQuickRead:
@@ -74,28 +74,28 @@ InternalSmbusExecute ( SmBusReceiveByte (SmbusAddress, &Status);
break;
case EfiSmbusSendByte:
- DEBUG ((DEBUG_INFO, "EfiSmbusSendByte - 0x%08x (0x%02x)\n", SmbusAddress, (UINTN)*(UINT8 *) Buffer));
- SmBusSendByte (SmbusAddress, *(UINT8 *) Buffer, &Status);
+ DEBUG ((DEBUG_INFO, "EfiSmbusSendByte - 0x%08x (0x%02x)\n", SmbusAddress, (UINTN)*(UINT8 *)Buffer));
+ SmBusSendByte (SmbusAddress, *(UINT8 *)Buffer, &Status);
break;
case EfiSmbusReadByte:
DEBUG ((DEBUG_INFO, "EfiSmbusReadByte - 0x%08x\n", SmbusAddress));
SmBusReadDataByte (SmbusAddress, &Status);
break;
case EfiSmbusWriteByte:
- DEBUG ((DEBUG_INFO, "EfiSmbusWriteByte - 0x%08x (0x%02x)\n", SmbusAddress, (UINTN)*(UINT8 *) Buffer));
- SmBusWriteDataByte (SmbusAddress, *(UINT8 *) Buffer, &Status);
+ DEBUG ((DEBUG_INFO, "EfiSmbusWriteByte - 0x%08x (0x%02x)\n", SmbusAddress, (UINTN)*(UINT8 *)Buffer));
+ SmBusWriteDataByte (SmbusAddress, *(UINT8 *)Buffer, &Status);
break;
case EfiSmbusReadWord:
DEBUG ((DEBUG_INFO, "EfiSmbusReadWord - 0x%08x\n", SmbusAddress));
SmBusReadDataWord (SmbusAddress, &Status);
break;
case EfiSmbusWriteWord:
- DEBUG ((DEBUG_INFO, "EfiSmbusWriteWord - 0x%08x (0x%04x)\n", SmbusAddress, (UINTN)*(UINT16 *) Buffer));
- SmBusWriteDataWord (SmbusAddress, *(UINT16 *) Buffer, &Status);
+ DEBUG ((DEBUG_INFO, "EfiSmbusWriteWord - 0x%08x (0x%04x)\n", SmbusAddress, (UINTN)*(UINT16 *)Buffer));
+ SmBusWriteDataWord (SmbusAddress, *(UINT16 *)Buffer, &Status);
break;
case EfiSmbusProcessCall:
- DEBUG ((DEBUG_INFO, "EfiSmbusProcessCall - 0x%08x (0x%04x)\n", SmbusAddress, (UINTN)*(UINT16 *) Buffer));
- SmBusProcessCall (SmbusAddress, *(UINT16 *) Buffer, &Status);
+ DEBUG ((DEBUG_INFO, "EfiSmbusProcessCall - 0x%08x (0x%04x)\n", SmbusAddress, (UINTN)*(UINT16 *)Buffer));
+ SmBusProcessCall (SmbusAddress, *(UINT16 *)Buffer, &Status);
break;
case EfiSmbusReadBlock:
DEBUG ((DEBUG_INFO, "EfiSmbusReadBlock - 0x%08x\n", SmbusAddress));
@@ -130,31 +130,31 @@ InternalSmbusExecute ( **/
EFI_STATUS
BuildLoopData (
- IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
+ IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
IN UINT64 Address,
OUT UINTN *AddressStride,
OUT UINTN *BufferStride
)
{
- UINTN AlignMask;
+ UINTN AlignMask;
if (Width >= S3BootScriptWidthMaximum) {
return EFI_INVALID_PARAMETER;
}
- *AddressStride = (UINT32)(1 << (Width & 0x03));
- *BufferStride = *AddressStride;
+ *AddressStride = (UINT32)(1 << (Width & 0x03));
+ *BufferStride = *AddressStride;
- AlignMask = *AddressStride - 1;
+ AlignMask = *AddressStride - 1;
if ((Address & AlignMask) != 0) {
return EFI_INVALID_PARAMETER;
}
- if (Width >= S3BootScriptWidthFifoUint8 && Width <= S3BootScriptWidthFifoUint64) {
+ if ((Width >= S3BootScriptWidthFifoUint8) && (Width <= S3BootScriptWidthFifoUint64)) {
*AddressStride = 0;
}
- if (Width >= S3BootScriptWidthFillUint8 && Width <= S3BootScriptWidthFillUint64) {
+ if ((Width >= S3BootScriptWidthFillUint8) && (Width <= S3BootScriptWidthFillUint64)) {
*BufferStride = 0;
}
@@ -178,10 +178,10 @@ BuildLoopData ( **/
EFI_STATUS
ScriptIoRead (
- IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
- IN UINT64 Address,
- IN UINTN Count,
- OUT VOID *Buffer
+ IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
+ IN UINT64 Address,
+ IN UINTN Count,
+ OUT VOID *Buffer
)
{
EFI_STATUS Status;
@@ -189,7 +189,7 @@ ScriptIoRead ( UINTN BufferStride;
PTR Out;
- Out.Buf = (UINT8 *) Buffer;
+ Out.Buf = (UINT8 *)Buffer;
if (Address > MAX_IO_ADDRESS) {
return EFI_INVALID_PARAMETER;
@@ -199,66 +199,66 @@ ScriptIoRead ( if (EFI_ERROR (Status)) {
return Status;
}
+
//
// Loop for each iteration and move the data
//
- for (; Count > 0; Count--, Address += AddressStride, Out.Buf += BufferStride) {
+ for ( ; Count > 0; Count--, Address += AddressStride, Out.Buf += BufferStride) {
switch (Width) {
+ case S3BootScriptWidthUint8:
+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint8 - 0x%08x\n", (UINTN)Address));
+ *Out.Uint8 = IoRead8 ((UINTN)Address);
+ break;
+ case S3BootScriptWidthFifoUint8:
+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint8 - 0x%08x\n", (UINTN)Address));
+ *Out.Uint8 = IoRead8 ((UINTN)Address);
+ break;
+ case S3BootScriptWidthFillUint8:
+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint8 - 0x%08x\n", (UINTN)Address));
+ *Out.Uint8 = IoRead8 ((UINTN)Address);
+ break;
- case S3BootScriptWidthUint8:
- DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint8 - 0x%08x\n", (UINTN) Address));
- *Out.Uint8 = IoRead8 ((UINTN) Address);
- break;
- case S3BootScriptWidthFifoUint8:
- DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint8 - 0x%08x\n", (UINTN) Address));
- *Out.Uint8 = IoRead8 ((UINTN) Address);
- break;
- case S3BootScriptWidthFillUint8:
- DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint8 - 0x%08x\n", (UINTN) Address));
- *Out.Uint8 = IoRead8 ((UINTN) Address);
- break;
-
- case S3BootScriptWidthUint16:
- DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint16 - 0x%08x\n", (UINTN) Address));
- *Out.Uint16 = IoRead16 ((UINTN) Address);
- break;
- case S3BootScriptWidthFifoUint16:
- DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint16 - 0x%08x\n", (UINTN) Address));
- *Out.Uint16 = IoRead16 ((UINTN) Address);
- break;
- case S3BootScriptWidthFillUint16:
- DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint16 - 0x%08x\n", (UINTN) Address));
- *Out.Uint16 = IoRead16 ((UINTN) Address);
- break;
+ case S3BootScriptWidthUint16:
+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint16 - 0x%08x\n", (UINTN)Address));
+ *Out.Uint16 = IoRead16 ((UINTN)Address);
+ break;
+ case S3BootScriptWidthFifoUint16:
+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint16 - 0x%08x\n", (UINTN)Address));
+ *Out.Uint16 = IoRead16 ((UINTN)Address);
+ break;
+ case S3BootScriptWidthFillUint16:
+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint16 - 0x%08x\n", (UINTN)Address));
+ *Out.Uint16 = IoRead16 ((UINTN)Address);
+ break;
- case S3BootScriptWidthUint32:
- DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint32 - 0x%08x\n", (UINTN) Address));
- *Out.Uint32 = IoRead32 ((UINTN) Address);
- break;
- case S3BootScriptWidthFifoUint32:
- DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint32 - 0x%08x\n", (UINTN) Address));
- *Out.Uint32 = IoRead32 ((UINTN) Address);
- break;
- case S3BootScriptWidthFillUint32:
- DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint32 - 0x%08x\n", (UINTN) Address));
- *Out.Uint32 = IoRead32 ((UINTN) Address);
- break;
+ case S3BootScriptWidthUint32:
+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint32 - 0x%08x\n", (UINTN)Address));
+ *Out.Uint32 = IoRead32 ((UINTN)Address);
+ break;
+ case S3BootScriptWidthFifoUint32:
+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint32 - 0x%08x\n", (UINTN)Address));
+ *Out.Uint32 = IoRead32 ((UINTN)Address);
+ break;
+ case S3BootScriptWidthFillUint32:
+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint32 - 0x%08x\n", (UINTN)Address));
+ *Out.Uint32 = IoRead32 ((UINTN)Address);
+ break;
- case S3BootScriptWidthUint64:
- DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint64 - 0x%08x\n", (UINTN) Address));
- *Out.Uint64 = IoRead64 ((UINTN) Address);
- break;
- case S3BootScriptWidthFifoUint64:
- DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint64 - 0x%08x\n", (UINTN) Address));
- *Out.Uint64 = IoRead64 ((UINTN) Address);
- break;
- case S3BootScriptWidthFillUint64:
- DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint64 - 0x%08x\n", (UINTN) Address));
- *Out.Uint64 = IoRead64 ((UINTN) Address);
- break;
+ case S3BootScriptWidthUint64:
+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint64 - 0x%08x\n", (UINTN)Address));
+ *Out.Uint64 = IoRead64 ((UINTN)Address);
+ break;
+ case S3BootScriptWidthFifoUint64:
+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint64 - 0x%08x\n", (UINTN)Address));
+ *Out.Uint64 = IoRead64 ((UINTN)Address);
+ break;
+ case S3BootScriptWidthFillUint64:
+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint64 - 0x%08x\n", (UINTN)Address));
+ *Out.Uint64 = IoRead64 ((UINTN)Address);
+ break;
- default:
- return EFI_INVALID_PARAMETER;
+ default:
+ return EFI_INVALID_PARAMETER;
}
}
@@ -283,9 +283,9 @@ ScriptIoRead ( EFI_STATUS
ScriptIoWrite (
IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
- IN UINT64 Address,
- IN UINTN Count,
- IN VOID *Buffer
+ IN UINT64 Address,
+ IN UINTN Count,
+ IN VOID *Buffer
)
{
EFI_STATUS Status;
@@ -295,7 +295,7 @@ ScriptIoWrite ( PTR In;
PTR OriginalIn;
- In.Buf = (UINT8 *) Buffer;
+ In.Buf = (UINT8 *)Buffer;
if (Address > MAX_IO_ADDRESS) {
return EFI_INVALID_PARAMETER;
@@ -305,69 +305,70 @@ ScriptIoWrite ( if (EFI_ERROR (Status)) {
return Status;
}
+
//
// Loop for each iteration and move the data
//
OriginalAddress = Address;
- OriginalIn.Buf = In.Buf;
- for (; Count > 0; Count--, Address += AddressStride, In.Buf += BufferStride) {
+ OriginalIn.Buf = In.Buf;
+ for ( ; Count > 0; Count--, Address += AddressStride, In.Buf += BufferStride) {
switch (Width) {
case S3BootScriptWidthUint8:
DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint8 - 0x%08x (0x%02x)\n", (UINTN)Address, (UINTN)*In.Uint8));
- IoWrite8 ((UINTN) Address, *In.Uint8);
+ IoWrite8 ((UINTN)Address, *In.Uint8);
break;
case S3BootScriptWidthFifoUint8:
DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint8 - 0x%08x (0x%02x)\n", (UINTN)OriginalAddress, (UINTN)*In.Uint8));
- IoWrite8 ((UINTN) OriginalAddress, *In.Uint8);
+ IoWrite8 ((UINTN)OriginalAddress, *In.Uint8);
break;
case S3BootScriptWidthFillUint8:
DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint8 - 0x%08x (0x%02x)\n", (UINTN)Address, (UINTN)*OriginalIn.Uint8));
- IoWrite8 ((UINTN) Address, *OriginalIn.Uint8);
+ IoWrite8 ((UINTN)Address, *OriginalIn.Uint8);
break;
case S3BootScriptWidthUint16:
DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint16 - 0x%08x (0x%04x)\n", (UINTN)Address, (UINTN)*In.Uint16));
- IoWrite16 ((UINTN) Address, *In.Uint16);
+ IoWrite16 ((UINTN)Address, *In.Uint16);
break;
case S3BootScriptWidthFifoUint16:
DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint16 - 0x%08x (0x%04x)\n", (UINTN)OriginalAddress, (UINTN)*In.Uint16));
- IoWrite16 ((UINTN) OriginalAddress, *In.Uint16);
+ IoWrite16 ((UINTN)OriginalAddress, *In.Uint16);
break;
case S3BootScriptWidthFillUint16:
DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint16 - 0x%08x (0x%04x)\n", (UINTN)Address, (UINTN)*OriginalIn.Uint16));
- IoWrite16 ((UINTN) Address, *OriginalIn.Uint16);
+ IoWrite16 ((UINTN)Address, *OriginalIn.Uint16);
break;
case S3BootScriptWidthUint32:
DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint32 - 0x%08x (0x%08x)\n", (UINTN)Address, (UINTN)*In.Uint32));
- IoWrite32 ((UINTN) Address, *In.Uint32);
+ IoWrite32 ((UINTN)Address, *In.Uint32);
break;
case S3BootScriptWidthFifoUint32:
DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint32 - 0x%08x (0x%08x)\n", (UINTN)OriginalAddress, (UINTN)*In.Uint32));
- IoWrite32 ((UINTN) OriginalAddress, *In.Uint32);
+ IoWrite32 ((UINTN)OriginalAddress, *In.Uint32);
break;
case S3BootScriptWidthFillUint32:
DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint32 - 0x%08x (0x%08x)\n", (UINTN)Address, (UINTN)*OriginalIn.Uint32));
- IoWrite32 ((UINTN) Address, *OriginalIn.Uint32);
+ IoWrite32 ((UINTN)Address, *OriginalIn.Uint32);
break;
case S3BootScriptWidthUint64:
DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint64 - 0x%08x (0x%016lx)\n", (UINTN)Address, *In.Uint64));
- IoWrite64 ((UINTN) Address, *In.Uint64);
+ IoWrite64 ((UINTN)Address, *In.Uint64);
break;
case S3BootScriptWidthFifoUint64:
DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint64 - 0x%08x (0x%016lx)\n", (UINTN)OriginalAddress, *In.Uint64));
- IoWrite64 ((UINTN) OriginalAddress, *In.Uint64);
+ IoWrite64 ((UINTN)OriginalAddress, *In.Uint64);
break;
case S3BootScriptWidthFillUint64:
DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint64 - 0x%08x (0x%016lx)\n", (UINTN)Address, *OriginalIn.Uint64));
- IoWrite64 ((UINTN) Address, *OriginalIn.Uint64);
+ IoWrite64 ((UINTN)Address, *OriginalIn.Uint64);
break;
default:
return EFI_INVALID_PARAMETER;
}
}
-
return EFI_SUCCESS;
}
+
/**
Interpret the boot script node with EFI_BOOT_SCRIPT_IO_WRITE OP code.
@@ -382,24 +383,25 @@ ScriptIoWrite ( **/
EFI_STATUS
BootScriptExecuteIoWrite (
- IN UINT8 *Script
+ IN UINT8 *Script
)
{
- S3_BOOT_SCRIPT_LIB_WIDTH Width;
- UINT64 Address;
- UINTN Count;
+ S3_BOOT_SCRIPT_LIB_WIDTH Width;
+ UINT64 Address;
+ UINTN Count;
VOID *Buffer;
- EFI_BOOT_SCRIPT_IO_WRITE IoWrite;
+ EFI_BOOT_SCRIPT_IO_WRITE IoWrite;
- CopyMem ((VOID*)&IoWrite, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_IO_WRITE));
- Width = (S3_BOOT_SCRIPT_LIB_WIDTH) IoWrite.Width;
+ CopyMem ((VOID *)&IoWrite, (VOID *)Script, sizeof (EFI_BOOT_SCRIPT_IO_WRITE));
+ Width = (S3_BOOT_SCRIPT_LIB_WIDTH)IoWrite.Width;
Address = IoWrite.Address;
- Count = IoWrite.Count;
- Buffer = Script + sizeof (EFI_BOOT_SCRIPT_IO_WRITE);
+ Count = IoWrite.Count;
+ Buffer = Script + sizeof (EFI_BOOT_SCRIPT_IO_WRITE);
DEBUG ((DEBUG_INFO, "BootScriptExecuteIoWrite - 0x%08x, 0x%08x, 0x%08x\n", (UINTN)Address, Count, (UINTN)Width));
- return ScriptIoWrite(Width, Address, Count, Buffer);
+ return ScriptIoWrite (Width, Address, Count, Buffer);
}
+
/**
Perform memory read operation
@@ -418,10 +420,10 @@ BootScriptExecuteIoWrite ( **/
EFI_STATUS
ScriptMemoryRead (
- IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
- IN UINT64 Address,
- IN UINTN Count,
- IN OUT VOID *Buffer
+ IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
+ IN UINT64 Address,
+ IN UINTN Count,
+ IN OUT VOID *Buffer
)
{
EFI_STATUS Status;
@@ -431,74 +433,76 @@ ScriptMemoryRead ( Out.Buf = Buffer;
- Status = BuildLoopData (Width, Address, &AddressStride, &BufferStride);
+ Status = BuildLoopData (Width, Address, &AddressStride, &BufferStride);
if (EFI_ERROR (Status)) {
return Status;
}
+
//
// Loop for each iteration and move the data
//
- for (; Count > 0; Count--, Address += AddressStride, Out.Buf += BufferStride) {
+ for ( ; Count > 0; Count--, Address += AddressStride, Out.Buf += BufferStride) {
switch (Width) {
- case S3BootScriptWidthUint8:
- DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint8 - 0x%08x\n", (UINTN)Address));
- *Out.Uint8 = MmioRead8 ((UINTN) Address);
- break;
- case S3BootScriptWidthFifoUint8:
- DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint8 - 0x%08x\n", (UINTN)Address));
- *Out.Uint8 = MmioRead8 ((UINTN) Address);
- break;
- case S3BootScriptWidthFillUint8:
- DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint8 - 0x%08x\n", (UINTN)Address));
- *Out.Uint8 = MmioRead8 ((UINTN) Address);
- break;
+ case S3BootScriptWidthUint8:
+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint8 - 0x%08x\n", (UINTN)Address));
+ *Out.Uint8 = MmioRead8 ((UINTN)Address);
+ break;
+ case S3BootScriptWidthFifoUint8:
+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint8 - 0x%08x\n", (UINTN)Address));
+ *Out.Uint8 = MmioRead8 ((UINTN)Address);
+ break;
+ case S3BootScriptWidthFillUint8:
+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint8 - 0x%08x\n", (UINTN)Address));
+ *Out.Uint8 = MmioRead8 ((UINTN)Address);
+ break;
- case S3BootScriptWidthUint16:
- DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint16 - 0x%08x\n", (UINTN)Address));
- *Out.Uint16 = MmioRead16 ((UINTN) Address);
- break;
- case S3BootScriptWidthFifoUint16:
- DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint16 - 0x%08x\n", (UINTN)Address));
- *Out.Uint16 = MmioRead16 ((UINTN) Address);
- break;
- case S3BootScriptWidthFillUint16:
- DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint16 - 0x%08x\n", (UINTN)Address));
- *Out.Uint16 = MmioRead16 ((UINTN) Address);
- break;
+ case S3BootScriptWidthUint16:
+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint16 - 0x%08x\n", (UINTN)Address));
+ *Out.Uint16 = MmioRead16 ((UINTN)Address);
+ break;
+ case S3BootScriptWidthFifoUint16:
+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint16 - 0x%08x\n", (UINTN)Address));
+ *Out.Uint16 = MmioRead16 ((UINTN)Address);
+ break;
+ case S3BootScriptWidthFillUint16:
+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint16 - 0x%08x\n", (UINTN)Address));
+ *Out.Uint16 = MmioRead16 ((UINTN)Address);
+ break;
- case S3BootScriptWidthUint32:
- DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint32 - 0x%08x\n", (UINTN)Address));
- *Out.Uint32 = MmioRead32 ((UINTN) Address);
- break;
- case S3BootScriptWidthFifoUint32:
- DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint32 - 0x%08x\n", (UINTN)Address));
- *Out.Uint32 = MmioRead32 ((UINTN) Address);
- break;
- case S3BootScriptWidthFillUint32:
- DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint32 - 0x%08x\n", (UINTN)Address));
- *Out.Uint32 = MmioRead32 ((UINTN) Address);
- break;
+ case S3BootScriptWidthUint32:
+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint32 - 0x%08x\n", (UINTN)Address));
+ *Out.Uint32 = MmioRead32 ((UINTN)Address);
+ break;
+ case S3BootScriptWidthFifoUint32:
+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint32 - 0x%08x\n", (UINTN)Address));
+ *Out.Uint32 = MmioRead32 ((UINTN)Address);
+ break;
+ case S3BootScriptWidthFillUint32:
+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint32 - 0x%08x\n", (UINTN)Address));
+ *Out.Uint32 = MmioRead32 ((UINTN)Address);
+ break;
- case S3BootScriptWidthUint64:
- DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint64 - 0x%08x\n", (UINTN)Address));
- *Out.Uint64 = MmioRead64 ((UINTN) Address);
- break;
- case S3BootScriptWidthFifoUint64:
- DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint64 - 0x%08x\n", (UINTN)Address));
- *Out.Uint64 = MmioRead64 ((UINTN) Address);
- break;
- case S3BootScriptWidthFillUint64:
- DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint64 - 0x%08x\n", (UINTN)Address));
- *Out.Uint64 = MmioRead64 ((UINTN) Address);
- break;
+ case S3BootScriptWidthUint64:
+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint64 - 0x%08x\n", (UINTN)Address));
+ *Out.Uint64 = MmioRead64 ((UINTN)Address);
+ break;
+ case S3BootScriptWidthFifoUint64:
+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint64 - 0x%08x\n", (UINTN)Address));
+ *Out.Uint64 = MmioRead64 ((UINTN)Address);
+ break;
+ case S3BootScriptWidthFillUint64:
+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint64 - 0x%08x\n", (UINTN)Address));
+ *Out.Uint64 = MmioRead64 ((UINTN)Address);
+ break;
- default:
- return EFI_UNSUPPORTED;
+ default:
+ return EFI_UNSUPPORTED;
}
}
return EFI_SUCCESS;
}
+
/**
Perform memory write operation
@@ -517,10 +521,10 @@ ScriptMemoryRead ( **/
EFI_STATUS
ScriptMemoryWrite (
- IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
- IN UINT64 Address,
- IN UINTN Count,
- IN OUT VOID *Buffer
+ IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
+ IN UINT64 Address,
+ IN UINTN Count,
+ IN OUT VOID *Buffer
)
{
EFI_STATUS Status;
@@ -530,73 +534,76 @@ ScriptMemoryWrite ( PTR In;
PTR OriginalIn;
- In.Buf = Buffer;
+ In.Buf = Buffer;
- Status = BuildLoopData (Width, Address, &AddressStride, &BufferStride);
+ Status = BuildLoopData (Width, Address, &AddressStride, &BufferStride);
if (EFI_ERROR (Status)) {
return Status;
}
+
//
// Loop for each iteration and move the data
//
OriginalAddress = Address;
- OriginalIn.Buf = In.Buf;
- for (; Count > 0; Count--, Address += AddressStride, In.Buf += BufferStride) {
+ OriginalIn.Buf = In.Buf;
+ for ( ; Count > 0; Count--, Address += AddressStride, In.Buf += BufferStride) {
switch (Width) {
case S3BootScriptWidthUint8:
DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint8 - 0x%08x (0x%02x)\n", (UINTN)Address, (UINTN)*In.Uint8));
- MmioWrite8 ((UINTN) Address, *In.Uint8);
+ MmioWrite8 ((UINTN)Address, *In.Uint8);
break;
case S3BootScriptWidthFifoUint8:
DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint8 - 0x%08x (0x%02x)\n", (UINTN)OriginalAddress, (UINTN)*In.Uint8));
- MmioWrite8 ((UINTN) OriginalAddress, *In.Uint8);
+ MmioWrite8 ((UINTN)OriginalAddress, *In.Uint8);
break;
case S3BootScriptWidthFillUint8:
DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint8 - 0x%08x (0x%02x)\n", (UINTN)Address, (UINTN)*OriginalIn.Uint8));
- MmioWrite8 ((UINTN) Address, *OriginalIn.Uint8);
+ MmioWrite8 ((UINTN)Address, *OriginalIn.Uint8);
break;
case S3BootScriptWidthUint16:
DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint16 - 0x%08x (0x%04x)\n", (UINTN)Address, (UINTN)*In.Uint16));
- MmioWrite16 ((UINTN) Address, *In.Uint16);
+ MmioWrite16 ((UINTN)Address, *In.Uint16);
break;
case S3BootScriptWidthFifoUint16:
DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint16 - 0x%08x (0x%04x)\n", (UINTN)OriginalAddress, (UINTN)*In.Uint16));
- MmioWrite16 ((UINTN) OriginalAddress, *In.Uint16);
+ MmioWrite16 ((UINTN)OriginalAddress, *In.Uint16);
break;
case S3BootScriptWidthFillUint16:
DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint16 - 0x%08x (0x%04x)\n", (UINTN)Address, (UINTN)*OriginalIn.Uint16));
- MmioWrite16 ((UINTN) Address, *OriginalIn.Uint16);
+ MmioWrite16 ((UINTN)Address, *OriginalIn.Uint16);
break;
case S3BootScriptWidthUint32:
DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint32 - 0x%08x (0x%08x)\n", (UINTN)Address, (UINTN)*In.Uint32));
- MmioWrite32 ((UINTN) Address, *In.Uint32);
+ MmioWrite32 ((UINTN)Address, *In.Uint32);
break;
case S3BootScriptWidthFifoUint32:
DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint32 - 0x%08x (0x%08x)\n", (UINTN)OriginalAddress, (UINTN)*In.Uint32));
- MmioWrite32 ((UINTN) OriginalAddress, *In.Uint32);
+ MmioWrite32 ((UINTN)OriginalAddress, *In.Uint32);
break;
case S3BootScriptWidthFillUint32:
DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint32 - 0x%08x (0x%08x)\n", (UINTN)Address, (UINTN)*OriginalIn.Uint32));
- MmioWrite32 ((UINTN) Address, *OriginalIn.Uint32);
+ MmioWrite32 ((UINTN)Address, *OriginalIn.Uint32);
break;
case S3BootScriptWidthUint64:
DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint64 - 0x%08x (0x%016lx)\n", (UINTN)Address, *In.Uint64));
- MmioWrite64 ((UINTN) Address, *In.Uint64);
+ MmioWrite64 ((UINTN)Address, *In.Uint64);
break;
case S3BootScriptWidthFifoUint64:
DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint64 - 0x%08x (0x%016lx)\n", (UINTN)OriginalAddress, *In.Uint64));
- MmioWrite64 ((UINTN) OriginalAddress, *In.Uint64);
+ MmioWrite64 ((UINTN)OriginalAddress, *In.Uint64);
break;
case S3BootScriptWidthFillUint64:
DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint64 - 0x%08x (0x%016lx)\n", (UINTN)Address, *OriginalIn.Uint64));
- MmioWrite64 ((UINTN) Address, *OriginalIn.Uint64);
+ MmioWrite64 ((UINTN)Address, *OriginalIn.Uint64);
break;
default:
return EFI_UNSUPPORTED;
}
}
+
return EFI_SUCCESS;
}
+
/**
Interpret the boot script node with EFI_BOOT_SCRIPT_MEM_WRITE OP code.
@@ -612,25 +619,25 @@ ScriptMemoryWrite ( **/
EFI_STATUS
BootScriptExecuteMemoryWrite (
- IN UINT8 *Script
+ IN UINT8 *Script
)
{
- VOID *Buffer;
- S3_BOOT_SCRIPT_LIB_WIDTH Width;
- UINT64 Address;
- UINTN Count;
+ VOID *Buffer;
+ S3_BOOT_SCRIPT_LIB_WIDTH Width;
+ UINT64 Address;
+ UINTN Count;
EFI_BOOT_SCRIPT_MEM_WRITE MemWrite;
- CopyMem((VOID*)&MemWrite, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_MEM_WRITE));
+ CopyMem ((VOID *)&MemWrite, (VOID *)Script, sizeof (EFI_BOOT_SCRIPT_MEM_WRITE));
Width = (S3_BOOT_SCRIPT_LIB_WIDTH)MemWrite.Width;
Address = MemWrite.Address;
Count = MemWrite.Count;
- Buffer = Script + sizeof(EFI_BOOT_SCRIPT_MEM_WRITE);
+ Buffer = Script + sizeof (EFI_BOOT_SCRIPT_MEM_WRITE);
DEBUG ((DEBUG_INFO, "BootScriptExecuteMemoryWrite - 0x%08x, 0x%08x, 0x%08x\n", (UINTN)Address, Count, (UINTN)Width));
- return ScriptMemoryWrite (Width,Address, Count, Buffer);
-
+ return ScriptMemoryWrite (Width, Address, Count, Buffer);
}
+
/**
Performance PCI configuration 2 read operation
@@ -647,11 +654,11 @@ BootScriptExecuteMemoryWrite ( **/
EFI_STATUS
ScriptPciCfg2Read (
- IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
- IN UINT16 Segment,
- IN UINT64 Address,
- IN UINTN Count,
- OUT VOID *Buffer
+ IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
+ IN UINT16 Segment,
+ IN UINT64 Address,
+ IN UINTN Count,
+ OUT VOID *Buffer
)
{
EFI_STATUS Status;
@@ -660,7 +667,7 @@ ScriptPciCfg2Read ( PTR Out;
UINT64 PciAddress;
- Out.Buf = (UINT8 *) Buffer;
+ Out.Buf = (UINT8 *)Buffer;
PciAddress = PCI_ADDRESS_ENCODE (Segment, Address);
@@ -668,54 +675,56 @@ ScriptPciCfg2Read ( if (EFI_ERROR (Status)) {
return Status;
}
+
//
// Loop for each iteration and move the data
//
- for (; Count > 0; Count--, PciAddress += AddressStride, Out.Buf += BufferStride) {
+ for ( ; Count > 0; Count--, PciAddress += AddressStride, Out.Buf += BufferStride) {
switch (Width) {
- case S3BootScriptWidthUint8:
- DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint8 - 0x%016lx\n", PciAddress));
- *Out.Uint8 = PciSegmentRead8 (PciAddress);
- break;
- case S3BootScriptWidthFifoUint8:
- DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint8 - 0x%016lx\n", PciAddress));
- *Out.Uint8 = PciSegmentRead8 (PciAddress);
- break;
- case S3BootScriptWidthFillUint8:
- DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint8 - 0x%016lx\n", PciAddress));
- *Out.Uint8 = PciSegmentRead8 (PciAddress);
- break;
+ case S3BootScriptWidthUint8:
+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint8 - 0x%016lx\n", PciAddress));
+ *Out.Uint8 = PciSegmentRead8 (PciAddress);
+ break;
+ case S3BootScriptWidthFifoUint8:
+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint8 - 0x%016lx\n", PciAddress));
+ *Out.Uint8 = PciSegmentRead8 (PciAddress);
+ break;
+ case S3BootScriptWidthFillUint8:
+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint8 - 0x%016lx\n", PciAddress));
+ *Out.Uint8 = PciSegmentRead8 (PciAddress);
+ break;
- case S3BootScriptWidthUint16:
- DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint16 - 0x%016lx\n", PciAddress));
- *Out.Uint16 = PciSegmentRead16 (PciAddress);
- break;
- case S3BootScriptWidthFifoUint16:
- DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint16 - 0x%016lx\n", PciAddress));
- *Out.Uint16 = PciSegmentRead16 (PciAddress);
- break;
- case S3BootScriptWidthFillUint16:
- DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint16 - 0x%016lx\n", PciAddress));
- *Out.Uint16 = PciSegmentRead16 (PciAddress);
- break;
+ case S3BootScriptWidthUint16:
+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint16 - 0x%016lx\n", PciAddress));
+ *Out.Uint16 = PciSegmentRead16 (PciAddress);
+ break;
+ case S3BootScriptWidthFifoUint16:
+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint16 - 0x%016lx\n", PciAddress));
+ *Out.Uint16 = PciSegmentRead16 (PciAddress);
+ break;
+ case S3BootScriptWidthFillUint16:
+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint16 - 0x%016lx\n", PciAddress));
+ *Out.Uint16 = PciSegmentRead16 (PciAddress);
+ break;
- case S3BootScriptWidthUint32:
- DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint32 - 0x%016lx\n", PciAddress));
- *Out.Uint32 = PciSegmentRead32 (PciAddress);
- break;
- case S3BootScriptWidthFifoUint32:
- DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint32 - 0x%016lx\n", PciAddress));
- *Out.Uint32 = PciSegmentRead32 (PciAddress);
- break;
- case S3BootScriptWidthFillUint32:
- DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint32 - 0x%016lx\n", PciAddress));
- *Out.Uint32 = PciSegmentRead32 (PciAddress);
- break;
+ case S3BootScriptWidthUint32:
+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint32 - 0x%016lx\n", PciAddress));
+ *Out.Uint32 = PciSegmentRead32 (PciAddress);
+ break;
+ case S3BootScriptWidthFifoUint32:
+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint32 - 0x%016lx\n", PciAddress));
+ *Out.Uint32 = PciSegmentRead32 (PciAddress);
+ break;
+ case S3BootScriptWidthFillUint32:
+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint32 - 0x%016lx\n", PciAddress));
+ *Out.Uint32 = PciSegmentRead32 (PciAddress);
+ break;
- default:
- return EFI_INVALID_PARAMETER;
+ default:
+ return EFI_INVALID_PARAMETER;
}
}
+
return EFI_SUCCESS;
}
@@ -735,11 +744,11 @@ ScriptPciCfg2Read ( **/
EFI_STATUS
ScriptPciCfg2Write (
- IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
- IN UINT16 Segment,
- IN UINT64 Address,
- IN UINTN Count,
- IN VOID *Buffer
+ IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
+ IN UINT16 Segment,
+ IN UINT64 Address,
+ IN UINTN Count,
+ IN VOID *Buffer
)
{
EFI_STATUS Status;
@@ -750,7 +759,7 @@ ScriptPciCfg2Write ( PTR OriginalIn;
UINT64 PciAddress;
- In.Buf = (UINT8 *) Buffer;
+ In.Buf = (UINT8 *)Buffer;
PciAddress = PCI_ADDRESS_ENCODE (Segment, Address);
@@ -758,12 +767,13 @@ ScriptPciCfg2Write ( if (EFI_ERROR (Status)) {
return Status;
}
+
//
// Loop for each iteration and move the data
//
OriginalPciAddress = PciAddress;
- OriginalIn.Buf = In.Buf;
- for (; Count > 0; Count--, PciAddress += AddressStride, In.Buf += BufferStride) {
+ OriginalIn.Buf = In.Buf;
+ for ( ; Count > 0; Count--, PciAddress += AddressStride, In.Buf += BufferStride) {
switch (Width) {
case S3BootScriptWidthUint8:
DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint8 - 0x%016lx (0x%02x)\n", PciAddress, (UINTN)*In.Uint8));
@@ -805,8 +815,10 @@ ScriptPciCfg2Write ( return EFI_INVALID_PARAMETER;
}
}
+
return EFI_SUCCESS;
}
+
/**
Performance PCI configuration read operation
@@ -824,14 +836,15 @@ ScriptPciCfg2Write ( **/
EFI_STATUS
ScriptPciCfgRead (
- IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
- IN UINT64 Address,
- IN UINTN Count,
- OUT VOID *Buffer
+ IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
+ IN UINT64 Address,
+ IN UINTN Count,
+ OUT VOID *Buffer
)
{
return ScriptPciCfg2Read (Width, 0, Address, Count, Buffer);
}
+
/**
Performance PCI configuration write operation
@@ -850,14 +863,15 @@ ScriptPciCfgRead ( EFI_STATUS
EFIAPI
ScriptPciCfgWrite (
- IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
- IN UINT64 Address,
- IN UINTN Count,
- IN VOID *Buffer
+ IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
+ IN UINT64 Address,
+ IN UINTN Count,
+ IN VOID *Buffer
)
{
return ScriptPciCfg2Write (Width, 0, Address, Count, Buffer);
}
+
/**
Interpret the boot script node with EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE OP code.
@@ -867,7 +881,7 @@ ScriptPciCfgWrite ( **/
EFI_STATUS
BootScriptExecutePciCfgWrite (
- IN UINT8 *Script
+ IN UINT8 *Script
)
{
VOID *Buffer;
@@ -876,16 +890,17 @@ BootScriptExecutePciCfgWrite ( UINTN Count;
EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE PciCfgWrite;
- CopyMem ((VOID*)&PciCfgWrite, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE));
+ CopyMem ((VOID *)&PciCfgWrite, (VOID *)Script, sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE));
Width = (S3_BOOT_SCRIPT_LIB_WIDTH)PciCfgWrite.Width;
Address = PciCfgWrite.Address;
Count = PciCfgWrite.Count;
- Buffer = Script + sizeof(EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE);
+ Buffer = Script + sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE);
DEBUG ((DEBUG_INFO, "BootScriptExecutePciCfgWrite - 0x%016lx, 0x%08x, 0x%08x\n", PCI_ADDRESS_ENCODE (0, Address), Count, (UINTN)Width));
return ScriptPciCfgWrite (Width, Address, Count, Buffer);
}
+
/**
Interpret the boot script node with EFI_BOOT_SCRIPT_IO_READ_WRITE OP code.
@@ -897,39 +912,41 @@ BootScriptExecutePciCfgWrite ( **/
EFI_STATUS
BootScriptExecuteIoReadWrite (
- IN UINT8 *Script,
- IN UINT64 AndMask,
- IN UINT64 OrMask
+ IN UINT8 *Script,
+ IN UINT64 AndMask,
+ IN UINT64 OrMask
)
{
- EFI_STATUS Status;
- UINT64 Data;
- EFI_BOOT_SCRIPT_IO_READ_WRITE IoReadWrite;
+ EFI_STATUS Status;
+ UINT64 Data;
+ EFI_BOOT_SCRIPT_IO_READ_WRITE IoReadWrite;
Data = 0;
- CopyMem((VOID*)&IoReadWrite, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_IO_READ_WRITE));
+ CopyMem ((VOID *)&IoReadWrite, (VOID *)Script, sizeof (EFI_BOOT_SCRIPT_IO_READ_WRITE));
DEBUG ((DEBUG_INFO, "BootScriptExecuteIoReadWrite - 0x%08x, 0x%016lx, 0x%016lx\n", (UINTN)IoReadWrite.Address, AndMask, OrMask));
Status = ScriptIoRead (
- (S3_BOOT_SCRIPT_LIB_WIDTH) IoReadWrite.Width,
+ (S3_BOOT_SCRIPT_LIB_WIDTH)IoReadWrite.Width,
IoReadWrite.Address,
1,
&Data
);
if (!EFI_ERROR (Status)) {
- Data = (Data & AndMask) | OrMask;
+ Data = (Data & AndMask) | OrMask;
Status = ScriptIoWrite (
- (S3_BOOT_SCRIPT_LIB_WIDTH) IoReadWrite.Width,
+ (S3_BOOT_SCRIPT_LIB_WIDTH)IoReadWrite.Width,
IoReadWrite.Address,
1,
&Data
);
}
+
return Status;
}
+
/**
Interpret the boot script node with EFI_BOOT_SCRIPT_MEM_READ_WRITE OP code.
@@ -941,39 +958,41 @@ BootScriptExecuteIoReadWrite ( **/
EFI_STATUS
BootScriptExecuteMemoryReadWrite (
- IN UINT8 *Script,
- IN UINT64 AndMask,
- IN UINT64 OrMask
+ IN UINT8 *Script,
+ IN UINT64 AndMask,
+ IN UINT64 OrMask
)
{
- EFI_STATUS Status;
- UINT64 Data;
+ EFI_STATUS Status;
+ UINT64 Data;
EFI_BOOT_SCRIPT_MEM_READ_WRITE MemReadWrite;
Data = 0;
- CopyMem((VOID*)&MemReadWrite, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_MEM_READ_WRITE));
+ CopyMem ((VOID *)&MemReadWrite, (VOID *)Script, sizeof (EFI_BOOT_SCRIPT_MEM_READ_WRITE));
DEBUG ((DEBUG_INFO, "BootScriptExecuteMemoryReadWrite - 0x%08x, 0x%016lx, 0x%016lx\n", (UINTN)MemReadWrite.Address, AndMask, OrMask));
Status = ScriptMemoryRead (
- (S3_BOOT_SCRIPT_LIB_WIDTH) MemReadWrite.Width,
+ (S3_BOOT_SCRIPT_LIB_WIDTH)MemReadWrite.Width,
MemReadWrite.Address,
1,
&Data
);
if (!EFI_ERROR (Status)) {
- Data = (Data & AndMask) | OrMask;
+ Data = (Data & AndMask) | OrMask;
Status = ScriptMemoryWrite (
- (S3_BOOT_SCRIPT_LIB_WIDTH) MemReadWrite.Width,
+ (S3_BOOT_SCRIPT_LIB_WIDTH)MemReadWrite.Width,
MemReadWrite.Address,
1,
&Data
);
}
+
return Status;
}
+
/**
Interpret the boot script node with EFI_BOOT_SCRIPT_PCI_CFG_READ_WRITE OP code.
@@ -985,24 +1004,24 @@ BootScriptExecuteMemoryReadWrite ( **/
EFI_STATUS
BootScriptExecutePciCfgReadWrite (
- IN UINT8 *Script,
- IN UINT64 AndMask,
- IN UINT64 OrMask
+ IN UINT8 *Script,
+ IN UINT64 AndMask,
+ IN UINT64 OrMask
)
{
- EFI_STATUS Status;
- UINT64 Data;
+ EFI_STATUS Status;
+ UINT64 Data;
EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE PciCfgReadWrite;
Data = 0;
- CopyMem((VOID*)&PciCfgReadWrite, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE));
+ CopyMem ((VOID *)&PciCfgReadWrite, (VOID *)Script, sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE));
DEBUG ((DEBUG_INFO, "BootScriptExecutePciCfgReadWrite - 0x%016lx, 0x%016lx, 0x%016lx\n", PCI_ADDRESS_ENCODE (0, PciCfgReadWrite.Address), AndMask, OrMask));
Status = ScriptPciCfgRead (
- (S3_BOOT_SCRIPT_LIB_WIDTH) PciCfgReadWrite.Width,
+ (S3_BOOT_SCRIPT_LIB_WIDTH)PciCfgReadWrite.Width,
PciCfgReadWrite.Address,
1,
&Data
@@ -1014,7 +1033,7 @@ BootScriptExecutePciCfgReadWrite ( Data = (Data & AndMask) | OrMask;
Status = ScriptPciCfgWrite (
- (S3_BOOT_SCRIPT_LIB_WIDTH) PciCfgReadWrite.Width,
+ (S3_BOOT_SCRIPT_LIB_WIDTH)PciCfgReadWrite.Width,
PciCfgReadWrite.Address,
1,
&Data
@@ -1022,6 +1041,7 @@ BootScriptExecutePciCfgReadWrite ( return Status;
}
+
/**
Interpret the boot script node with EFI_BOOT_SCRIPT_SMBUS_EXECUTE OP code.
@@ -1033,26 +1053,27 @@ BootScriptExecutePciCfgReadWrite ( **/
EFI_STATUS
BootScriptExecuteSmbusExecute (
- IN UINT8 *Script
+ IN UINT8 *Script
)
{
- UINTN SmBusAddress;
- UINTN DataSize;
- EFI_BOOT_SCRIPT_SMBUS_EXECUTE SmbusExecuteEntry;
+ UINTN SmBusAddress;
+ UINTN DataSize;
+ EFI_BOOT_SCRIPT_SMBUS_EXECUTE SmbusExecuteEntry;
- CopyMem ((VOID*)&SmbusExecuteEntry, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_SMBUS_EXECUTE ));
+ CopyMem ((VOID *)&SmbusExecuteEntry, (VOID *)Script, sizeof (EFI_BOOT_SCRIPT_SMBUS_EXECUTE));
DEBUG ((DEBUG_INFO, "BootScriptExecuteSmbusExecute - 0x%08x, 0x%08x\n", (UINTN)SmbusExecuteEntry.SmBusAddress, (UINTN)SmbusExecuteEntry.Operation));
SmBusAddress = (UINTN)SmbusExecuteEntry.SmBusAddress;
- DataSize = (UINTN) SmbusExecuteEntry.DataSize;
+ DataSize = (UINTN)SmbusExecuteEntry.DataSize;
return InternalSmbusExecute (
SmBusAddress,
- (EFI_SMBUS_OPERATION) SmbusExecuteEntry.Operation,
+ (EFI_SMBUS_OPERATION)SmbusExecuteEntry.Operation,
&DataSize,
Script + sizeof (EFI_BOOT_SCRIPT_SMBUS_EXECUTE)
);
}
+
/**
Interpret the boot script node with EFI_BOOT_SCRIPT_STALL OP code.
@@ -1062,18 +1083,19 @@ BootScriptExecuteSmbusExecute ( **/
EFI_STATUS
BootScriptExecuteStall (
- IN UINT8 *Script
+ IN UINT8 *Script
)
{
- EFI_BOOT_SCRIPT_STALL Stall;
+ EFI_BOOT_SCRIPT_STALL Stall;
- CopyMem ((VOID*)&Stall, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_STALL));
+ CopyMem ((VOID *)&Stall, (VOID *)Script, sizeof (EFI_BOOT_SCRIPT_STALL));
DEBUG ((DEBUG_INFO, "BootScriptExecuteStall - 0x%08x\n", (UINTN)Stall.Duration));
- MicroSecondDelay ((UINTN) Stall.Duration);
+ MicroSecondDelay ((UINTN)Stall.Duration);
return EFI_SUCCESS;
}
+
/**
Interpret the boot script node with EFI_BOOT_SCRIPT_DISPATCH OP code.
@@ -1082,22 +1104,23 @@ BootScriptExecuteStall ( **/
EFI_STATUS
BootScriptExecuteDispatch (
- IN UINT8 *Script
+ IN UINT8 *Script
)
{
EFI_STATUS Status;
DISPATCH_ENTRYPOINT_FUNC EntryFunc;
EFI_BOOT_SCRIPT_DISPATCH ScriptDispatch;
- CopyMem ((VOID*)&ScriptDispatch, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_DISPATCH));
- EntryFunc = (DISPATCH_ENTRYPOINT_FUNC) (UINTN) (ScriptDispatch.EntryPoint);
+ CopyMem ((VOID *)&ScriptDispatch, (VOID *)Script, sizeof (EFI_BOOT_SCRIPT_DISPATCH));
+ EntryFunc = (DISPATCH_ENTRYPOINT_FUNC)(UINTN)(ScriptDispatch.EntryPoint);
DEBUG ((DEBUG_INFO, "BootScriptExecuteDispatch - 0x%08x\n", (UINTN)ScriptDispatch.EntryPoint));
- Status = EntryFunc (NULL, NULL);
+ Status = EntryFunc (NULL, NULL);
return Status;
}
+
/**
Interpret the boot script node with EFI_BOOT_SCRIPT_DISPATCH_2 OP code.
@@ -1106,23 +1129,24 @@ BootScriptExecuteDispatch ( **/
EFI_STATUS
BootScriptExecuteDispatch2 (
- IN UINT8 *Script
+ IN UINT8 *Script
)
{
- EFI_STATUS Status;
- DISPATCH_ENTRYPOINT_FUNC EntryFunc;
+ EFI_STATUS Status;
+ DISPATCH_ENTRYPOINT_FUNC EntryFunc;
EFI_BOOT_SCRIPT_DISPATCH_2 ScriptDispatch2;
- CopyMem ((VOID*)&ScriptDispatch2, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_DISPATCH_2));
+ CopyMem ((VOID *)&ScriptDispatch2, (VOID *)Script, sizeof (EFI_BOOT_SCRIPT_DISPATCH_2));
DEBUG ((DEBUG_INFO, "BootScriptExecuteDispatch2 - 0x%08x(0x%08x)\n", (UINTN)ScriptDispatch2.EntryPoint, (UINTN)ScriptDispatch2.Context));
- EntryFunc = (DISPATCH_ENTRYPOINT_FUNC) (UINTN) (ScriptDispatch2.EntryPoint);
+ EntryFunc = (DISPATCH_ENTRYPOINT_FUNC)(UINTN)(ScriptDispatch2.EntryPoint);
- Status = EntryFunc (NULL, (VOID *) (UINTN) ScriptDispatch2.Context);
+ Status = EntryFunc (NULL, (VOID *)(UINTN)ScriptDispatch2.Context);
return Status;
}
+
/**
Interpret the boot script node with EFI_BOOT_SCRIPT_MEM_POLL OP code.
@@ -1136,45 +1160,44 @@ BootScriptExecuteDispatch2 ( **/
EFI_STATUS
BootScriptExecuteMemPoll (
- IN UINT8 *Script,
- IN UINT64 AndMask,
- IN UINT64 OrMask
+ IN UINT8 *Script,
+ IN UINT64 AndMask,
+ IN UINT64 OrMask
)
{
+ UINT64 Data;
+ UINT64 LoopTimes;
+ EFI_STATUS Status;
+ EFI_BOOT_SCRIPT_MEM_POLL MemPoll;
- UINT64 Data;
- UINT64 LoopTimes;
- EFI_STATUS Status;
- EFI_BOOT_SCRIPT_MEM_POLL MemPoll;
-
- CopyMem ((VOID*)&MemPoll, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_MEM_POLL));
+ CopyMem ((VOID *)&MemPoll, (VOID *)Script, sizeof (EFI_BOOT_SCRIPT_MEM_POLL));
DEBUG ((DEBUG_INFO, "BootScriptExecuteMemPoll - 0x%08x, 0x%016lx, 0x%016lx\n", (UINTN)MemPoll.Address, AndMask, OrMask));
- Data = 0;
+ Data = 0;
Status = ScriptMemoryRead (
- (S3_BOOT_SCRIPT_LIB_WIDTH) MemPoll.Width,
- MemPoll.Address,
- 1,
- &Data
- );
- if ((!EFI_ERROR (Status)) && (Data & AndMask) == OrMask) {
+ (S3_BOOT_SCRIPT_LIB_WIDTH)MemPoll.Width,
+ MemPoll.Address,
+ 1,
+ &Data
+ );
+ if ((!EFI_ERROR (Status)) && ((Data & AndMask) == OrMask)) {
return EFI_SUCCESS;
}
for (LoopTimes = 0; LoopTimes < MemPoll.LoopTimes; LoopTimes++) {
MicroSecondDelay ((UINTN)MemPoll.Duration);
- Data = 0;
+ Data = 0;
Status = ScriptMemoryRead (
- (S3_BOOT_SCRIPT_LIB_WIDTH) MemPoll.Width,
+ (S3_BOOT_SCRIPT_LIB_WIDTH)MemPoll.Width,
MemPoll.Address,
1,
&Data
);
- if ((!EFI_ERROR (Status)) && (Data & AndMask) == OrMask) {
- return EFI_SUCCESS;
- }
+ if ((!EFI_ERROR (Status)) && ((Data & AndMask) == OrMask)) {
+ return EFI_SUCCESS;
+ }
}
if (LoopTimes < MemPoll.LoopTimes) {
@@ -1183,6 +1206,7 @@ BootScriptExecuteMemPoll ( return EFI_DEVICE_ERROR;
}
}
+
/**
Execute the boot script to interpret the Store arbitrary information.
This opcode is a no-op on dispatch and is only used for debugging script issues.
@@ -1192,23 +1216,24 @@ BootScriptExecuteMemPoll ( **/
VOID
BootScriptExecuteInformation (
- IN UINT8 *Script
+ IN UINT8 *Script
)
{
- UINT32 Index;
- EFI_BOOT_SCRIPT_INFORMATION Information;
- UINT8 *InformationData;
+ UINT32 Index;
+ EFI_BOOT_SCRIPT_INFORMATION Information;
+ UINT8 *InformationData;
- CopyMem ((VOID*)&Information, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_INFORMATION));
+ CopyMem ((VOID *)&Information, (VOID *)Script, sizeof (EFI_BOOT_SCRIPT_INFORMATION));
InformationData = Script + sizeof (EFI_BOOT_SCRIPT_INFORMATION);
- DEBUG ((DEBUG_INFO, "BootScriptExecuteInformation - 0x%08x\n", (UINTN) InformationData));
+ DEBUG ((DEBUG_INFO, "BootScriptExecuteInformation - 0x%08x\n", (UINTN)InformationData));
DEBUG ((DEBUG_INFO, "BootScriptInformation: "));
for (Index = 0; Index < Information.InformationLength; Index++) {
DEBUG ((DEBUG_INFO, "%02x ", InformationData[Index]));
}
+
DEBUG ((DEBUG_INFO, "\n"));
}
@@ -1220,23 +1245,24 @@ BootScriptExecuteInformation ( **/
VOID
BootScriptExecuteLabel (
- IN UINT8 *Script
+ IN UINT8 *Script
)
{
- UINT32 Index;
- EFI_BOOT_SCRIPT_INFORMATION Information;
- UINT8 *InformationData;
+ UINT32 Index;
+ EFI_BOOT_SCRIPT_INFORMATION Information;
+ UINT8 *InformationData;
- CopyMem ((VOID*)&Information, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_INFORMATION));
+ CopyMem ((VOID *)&Information, (VOID *)Script, sizeof (EFI_BOOT_SCRIPT_INFORMATION));
InformationData = Script + sizeof (EFI_BOOT_SCRIPT_INFORMATION);
- DEBUG ((DEBUG_INFO, "BootScriptExecuteLabel - 0x%08x\n", (UINTN) InformationData));
+ DEBUG ((DEBUG_INFO, "BootScriptExecuteLabel - 0x%08x\n", (UINTN)InformationData));
DEBUG ((DEBUG_INFO, "BootScriptLabel: "));
for (Index = 0; Index < Information.InformationLength; Index++) {
DEBUG ((DEBUG_INFO, "%02x ", InformationData[Index]));
}
+
DEBUG ((DEBUG_INFO, "\n"));
}
@@ -1251,79 +1277,80 @@ BootScriptExecuteLabel ( VOID
CheckAndOrMask (
IN EFI_BOOT_SCRIPT_COMMON_HEADER *ScriptHeader,
- OUT UINT64 *AndMask,
- OUT UINT64 *OrMask,
- IN UINT8 *Script
+ OUT UINT64 *AndMask,
+ OUT UINT64 *OrMask,
+ IN UINT8 *Script
)
{
- UINT8 *DataPtr;
- UINTN Size;
+ UINT8 *DataPtr;
+ UINTN Size;
switch (ScriptHeader->OpCode) {
- case EFI_BOOT_SCRIPT_IO_READ_WRITE_OPCODE:
- Size = sizeof (EFI_BOOT_SCRIPT_IO_READ_WRITE);
- break;
-
- case EFI_BOOT_SCRIPT_MEM_READ_WRITE_OPCODE:
- Size = sizeof (EFI_BOOT_SCRIPT_MEM_READ_WRITE);
- break;
-
- case EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE_OPCODE:
- Size = sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE);
- break;
- case EFI_BOOT_SCRIPT_MEM_POLL_OPCODE:
- Size = sizeof (EFI_BOOT_SCRIPT_MEM_POLL);
- break;
-
- case EFI_BOOT_SCRIPT_IO_POLL_OPCODE:
- Size = sizeof (EFI_BOOT_SCRIPT_IO_POLL);
- break;
-
- case EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE_OPCODE:
- Size = sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE);
- break;
-
- case EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL_OPCODE:
- Size = sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL);
- break;
-
- case EFI_BOOT_SCRIPT_PCI_CONFIG_POLL_OPCODE:
- Size = sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_POLL);
- break;
-
- default:
- return;
+ case EFI_BOOT_SCRIPT_IO_READ_WRITE_OPCODE:
+ Size = sizeof (EFI_BOOT_SCRIPT_IO_READ_WRITE);
+ break;
+
+ case EFI_BOOT_SCRIPT_MEM_READ_WRITE_OPCODE:
+ Size = sizeof (EFI_BOOT_SCRIPT_MEM_READ_WRITE);
+ break;
+
+ case EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE_OPCODE:
+ Size = sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE);
+ break;
+ case EFI_BOOT_SCRIPT_MEM_POLL_OPCODE:
+ Size = sizeof (EFI_BOOT_SCRIPT_MEM_POLL);
+ break;
+
+ case EFI_BOOT_SCRIPT_IO_POLL_OPCODE:
+ Size = sizeof (EFI_BOOT_SCRIPT_IO_POLL);
+ break;
+
+ case EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE_OPCODE:
+ Size = sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE);
+ break;
+
+ case EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL_OPCODE:
+ Size = sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL);
+ break;
+
+ case EFI_BOOT_SCRIPT_PCI_CONFIG_POLL_OPCODE:
+ Size = sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_POLL);
+ break;
+
+ default:
+ return;
}
DataPtr = Script + Size;
switch (ScriptHeader->Width) {
- case S3BootScriptWidthUint8:
- *AndMask = (UINT64) (*(UINT8*) (DataPtr + 1));
- *OrMask = (UINT64) (*DataPtr);
- break;
-
- case S3BootScriptWidthUint16:
- *AndMask = (UINT64) (*(UINT16 *) (DataPtr + 2));
- *OrMask = (UINT64) (*(UINT16 *) DataPtr);
- break;
-
- case S3BootScriptWidthUint32:
- *AndMask = (UINT64) (*(UINT32 *) (DataPtr + 4));
- *OrMask = (UINT64) (*(UINT32 *) DataPtr);
- break;
-
- case S3BootScriptWidthUint64:
- *AndMask = (UINT64) (*(UINT64 *) (DataPtr + 8));
- *OrMask = (UINT64) (*(UINT64 *) DataPtr);
- break;
-
- default:
- break;
+ case S3BootScriptWidthUint8:
+ *AndMask = (UINT64)(*(UINT8 *)(DataPtr + 1));
+ *OrMask = (UINT64)(*DataPtr);
+ break;
+
+ case S3BootScriptWidthUint16:
+ *AndMask = (UINT64)(*(UINT16 *)(DataPtr + 2));
+ *OrMask = (UINT64)(*(UINT16 *)DataPtr);
+ break;
+
+ case S3BootScriptWidthUint32:
+ *AndMask = (UINT64)(*(UINT32 *)(DataPtr + 4));
+ *OrMask = (UINT64)(*(UINT32 *)DataPtr);
+ break;
+
+ case S3BootScriptWidthUint64:
+ *AndMask = (UINT64)(*(UINT64 *)(DataPtr + 8));
+ *OrMask = (UINT64)(*(UINT64 *)DataPtr);
+ break;
+
+ default:
+ break;
}
return;
}
+
/**
Interpret the boot script node with EFI_BOOT_SCRIPT_IO_POLL OP code.
@@ -1337,40 +1364,41 @@ CheckAndOrMask ( **/
EFI_STATUS
BootScriptExecuteIoPoll (
- IN UINT8 *Script,
- IN UINT64 AndMask,
- IN UINT64 OrMask
+ IN UINT8 *Script,
+ IN UINT64 AndMask,
+ IN UINT64 OrMask
)
{
- EFI_STATUS Status;
- UINT64 Data;
- UINT64 LoopTimes;
- EFI_BOOT_SCRIPT_IO_POLL IoPoll;
+ EFI_STATUS Status;
+ UINT64 Data;
+ UINT64 LoopTimes;
+ EFI_BOOT_SCRIPT_IO_POLL IoPoll;
- CopyMem ((VOID*)&IoPoll, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_IO_POLL));
+ CopyMem ((VOID *)&IoPoll, (VOID *)Script, sizeof (EFI_BOOT_SCRIPT_IO_POLL));
DEBUG ((DEBUG_INFO, "BootScriptExecuteIoPoll - 0x%08x, 0x%016lx, 0x%016lx\n", (UINTN)IoPoll.Address, AndMask, OrMask));
- Data = 0;
+ Data = 0;
Status = ScriptIoRead (
- (S3_BOOT_SCRIPT_LIB_WIDTH) IoPoll.Width,
+ (S3_BOOT_SCRIPT_LIB_WIDTH)IoPoll.Width,
IoPoll.Address,
1,
&Data
);
- if ((!EFI_ERROR (Status)) && (Data & AndMask) == OrMask) {
+ if ((!EFI_ERROR (Status)) && ((Data & AndMask) == OrMask)) {
return EFI_SUCCESS;
}
+
for (LoopTimes = 0; LoopTimes < IoPoll.Delay; LoopTimes++) {
NanoSecondDelay (100);
- Data = 0;
+ Data = 0;
Status = ScriptIoRead (
- (S3_BOOT_SCRIPT_LIB_WIDTH) IoPoll.Width,
+ (S3_BOOT_SCRIPT_LIB_WIDTH)IoPoll.Width,
IoPoll.Address,
1,
&Data
);
- if ((!EFI_ERROR (Status)) &&(Data & AndMask) == OrMask) {
+ if ((!EFI_ERROR (Status)) && ((Data & AndMask) == OrMask)) {
return EFI_SUCCESS;
}
}
@@ -1381,6 +1409,7 @@ BootScriptExecuteIoPoll ( return EFI_DEVICE_ERROR;
}
}
+
/**
Interpret the boot script node with EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE OP code.
@@ -1391,29 +1420,28 @@ BootScriptExecuteIoPoll ( **/
EFI_STATUS
BootScriptExecutePciCfg2Write (
- IN UINT8 *Script
+ IN UINT8 *Script
)
{
- VOID *Buffer;
- S3_BOOT_SCRIPT_LIB_WIDTH Width;
- UINT16 Segment;
- UINT64 Address;
- UINTN Count;
- EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE PciCfg2Write;
+ VOID *Buffer;
+ S3_BOOT_SCRIPT_LIB_WIDTH Width;
+ UINT16 Segment;
+ UINT64 Address;
+ UINTN Count;
+ EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE PciCfg2Write;
- CopyMem ((VOID*)&PciCfg2Write, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE));
+ CopyMem ((VOID *)&PciCfg2Write, (VOID *)Script, sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE));
Width = (S3_BOOT_SCRIPT_LIB_WIDTH)PciCfg2Write.Width;
Segment = PciCfg2Write.Segment;
Address = PciCfg2Write.Address;
Count = PciCfg2Write.Count;
- Buffer = Script + sizeof(EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE);
+ Buffer = Script + sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE);
DEBUG ((DEBUG_INFO, "BootScriptExecutePciCfg2Write - 0x%016lx, 0x%08x, 0x%08x\n", PCI_ADDRESS_ENCODE (Segment, Address), Count, (UINTN)Width));
return ScriptPciCfg2Write (Width, Segment, Address, Count, Buffer);
}
-
/**
Interpret the boot script node with EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE OP code.
@@ -1426,23 +1454,23 @@ BootScriptExecutePciCfg2Write ( **/
EFI_STATUS
BootScriptExecutePciCfg2ReadWrite (
- IN UINT8 *Script,
- IN UINT64 AndMask,
- IN UINT64 OrMask
+ IN UINT8 *Script,
+ IN UINT64 AndMask,
+ IN UINT64 OrMask
)
{
- UINT64 Data;
- EFI_STATUS Status;
- EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE PciCfg2ReadWrite;
+ UINT64 Data;
+ EFI_STATUS Status;
+ EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE PciCfg2ReadWrite;
Data = 0;
- CopyMem ((VOID*)&PciCfg2ReadWrite, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE));
+ CopyMem ((VOID *)&PciCfg2ReadWrite, (VOID *)Script, sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE));
DEBUG ((DEBUG_INFO, "BootScriptExecutePciCfg2ReadWrite - 0x%016lx, 0x%016lx, 0x%016lx\n", PCI_ADDRESS_ENCODE (PciCfg2ReadWrite.Segment, PciCfg2ReadWrite.Address), AndMask, OrMask));
Status = ScriptPciCfg2Read (
- (S3_BOOT_SCRIPT_LIB_WIDTH) PciCfg2ReadWrite.Width,
+ (S3_BOOT_SCRIPT_LIB_WIDTH)PciCfg2ReadWrite.Width,
PciCfg2ReadWrite.Segment,
PciCfg2ReadWrite.Address,
1,
@@ -1452,9 +1480,9 @@ BootScriptExecutePciCfg2ReadWrite ( return Status;
}
- Data = (Data & AndMask) | OrMask;
+ Data = (Data & AndMask) | OrMask;
Status = ScriptPciCfg2Write (
- (S3_BOOT_SCRIPT_LIB_WIDTH) PciCfg2ReadWrite.Width,
+ (S3_BOOT_SCRIPT_LIB_WIDTH)PciCfg2ReadWrite.Width,
PciCfg2ReadWrite.Segment,
PciCfg2ReadWrite.Address,
1,
@@ -1462,6 +1490,7 @@ BootScriptExecutePciCfg2ReadWrite ( );
return Status;
}
+
/**
Interpret the boot script node with EFI_BOOT_SCRIPT_PCI_CONFIG_POLL OP code.
@@ -1475,41 +1504,43 @@ BootScriptExecutePciCfg2ReadWrite ( **/
EFI_STATUS
BootScriptPciCfgPoll (
- IN UINT8 *Script,
- IN UINT64 AndMask,
- IN UINT64 OrMask
+ IN UINT8 *Script,
+ IN UINT64 AndMask,
+ IN UINT64 OrMask
)
{
- UINT64 Data;
- UINT64 LoopTimes;
- EFI_STATUS Status;
- EFI_BOOT_SCRIPT_PCI_CONFIG_POLL PciCfgPoll;
- CopyMem ((VOID*)&PciCfgPoll, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_PCI_CONFIG_POLL));
+ UINT64 Data;
+ UINT64 LoopTimes;
+ EFI_STATUS Status;
+ EFI_BOOT_SCRIPT_PCI_CONFIG_POLL PciCfgPoll;
+
+ CopyMem ((VOID *)&PciCfgPoll, (VOID *)Script, sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_POLL));
DEBUG ((DEBUG_INFO, "BootScriptPciCfgPoll - 0x%016lx, 0x%016lx, 0x%016lx\n", PCI_ADDRESS_ENCODE (0, PciCfgPoll.Address), AndMask, OrMask));
- Data = 0;
+ Data = 0;
Status = ScriptPciCfgRead (
- (S3_BOOT_SCRIPT_LIB_WIDTH) PciCfgPoll.Width,
+ (S3_BOOT_SCRIPT_LIB_WIDTH)PciCfgPoll.Width,
PciCfgPoll.Address,
1,
&Data
);
- if ((!EFI_ERROR (Status)) &&(Data & AndMask) == OrMask) {
+ if ((!EFI_ERROR (Status)) && ((Data & AndMask) == OrMask)) {
return EFI_SUCCESS;
}
for (LoopTimes = 0; LoopTimes < PciCfgPoll.Delay; LoopTimes++) {
NanoSecondDelay (100);
- Data = 0;
+ Data = 0;
Status = ScriptPciCfgRead (
- (S3_BOOT_SCRIPT_LIB_WIDTH) PciCfgPoll.Width,
+ (S3_BOOT_SCRIPT_LIB_WIDTH)PciCfgPoll.Width,
PciCfgPoll.Address,
1,
&Data
);
if ((!EFI_ERROR (Status)) &&
- (Data & AndMask) == OrMask) {
+ ((Data & AndMask) == OrMask))
+ {
return EFI_SUCCESS;
}
}
@@ -1535,44 +1566,44 @@ BootScriptPciCfgPoll ( **/
EFI_STATUS
BootScriptPciCfg2Poll (
- IN UINT8 *Script,
- IN UINT64 AndMask,
- IN UINT64 OrMask
+ IN UINT8 *Script,
+ IN UINT64 AndMask,
+ IN UINT64 OrMask
)
{
- EFI_STATUS Status;
- UINT64 Data;
- UINT64 LoopTimes;
- EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL PciCfg2Poll;
+ EFI_STATUS Status;
+ UINT64 Data;
+ UINT64 LoopTimes;
+ EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL PciCfg2Poll;
Data = 0;
- CopyMem ((VOID*)&PciCfg2Poll, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL));
+ CopyMem ((VOID *)&PciCfg2Poll, (VOID *)Script, sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL));
DEBUG ((DEBUG_INFO, "BootScriptPciCfg2Poll - 0x%016lx, 0x%016lx, 0x%016lx\n", PCI_ADDRESS_ENCODE (PciCfg2Poll.Segment, PciCfg2Poll.Address), AndMask, OrMask));
Status = ScriptPciCfg2Read (
- (S3_BOOT_SCRIPT_LIB_WIDTH) PciCfg2Poll.Width,
+ (S3_BOOT_SCRIPT_LIB_WIDTH)PciCfg2Poll.Width,
PciCfg2Poll.Segment,
PciCfg2Poll.Address,
1,
&Data
);
- if ((!EFI_ERROR (Status)) && (Data & AndMask) == OrMask) {
+ if ((!EFI_ERROR (Status)) && ((Data & AndMask) == OrMask)) {
return EFI_SUCCESS;
}
for (LoopTimes = 0; LoopTimes < PciCfg2Poll.Delay; LoopTimes++) {
NanoSecondDelay (100);
- Data = 0;
+ Data = 0;
Status = ScriptPciCfg2Read (
- (S3_BOOT_SCRIPT_LIB_WIDTH) PciCfg2Poll.Width,
+ (S3_BOOT_SCRIPT_LIB_WIDTH)PciCfg2Poll.Width,
PciCfg2Poll.Segment,
PciCfg2Poll.Address,
1,
&Data
);
- if ((!EFI_ERROR (Status)) && (Data & AndMask) == OrMask) {
+ if ((!EFI_ERROR (Status)) && ((Data & AndMask) == OrMask)) {
return EFI_SUCCESS;
}
}
@@ -1582,7 +1613,6 @@ BootScriptPciCfg2Poll ( } else {
return EFI_DEVICE_ERROR;
}
-
}
/**
@@ -1598,17 +1628,18 @@ S3BootScriptExecute ( VOID
)
{
- EFI_STATUS Status;
- UINT8* Script;
- UINTN StartAddress;
- UINT32 TableLength;
- UINT64 AndMask;
- UINT64 OrMask;
+ EFI_STATUS Status;
+ UINT8 *Script;
+ UINTN StartAddress;
+ UINT32 TableLength;
+ UINT64 AndMask;
+ UINT64 OrMask;
EFI_BOOT_SCRIPT_COMMON_HEADER ScriptHeader;
EFI_BOOT_SCRIPT_TABLE_HEADER TableHeader;
+
Script = mS3BootScriptTablePtr->TableBase;
if (Script != 0) {
- CopyMem ((VOID*)&TableHeader, Script, sizeof(EFI_BOOT_SCRIPT_TABLE_HEADER));
+ CopyMem ((VOID *)&TableHeader, Script, sizeof (EFI_BOOT_SCRIPT_TABLE_HEADER));
} else {
return EFI_INVALID_PARAMETER;
}
@@ -1620,145 +1651,144 @@ S3BootScriptExecute ( DEBUG ((DEBUG_INFO, "TableHeader - 0x%08x\n", Script));
- StartAddress = (UINTN) Script;
- TableLength = TableHeader.TableLength;
- Script = Script + TableHeader.Length;
- Status = EFI_SUCCESS;
- AndMask = 0;
- OrMask = 0;
+ StartAddress = (UINTN)Script;
+ TableLength = TableHeader.TableLength;
+ Script = Script + TableHeader.Length;
+ Status = EFI_SUCCESS;
+ AndMask = 0;
+ OrMask = 0;
DEBUG ((DEBUG_INFO, "TableHeader.Version - 0x%04x\n", (UINTN)TableHeader.Version));
DEBUG ((DEBUG_INFO, "TableHeader.TableLength - 0x%08x\n", (UINTN)TableLength));
- while ((UINTN) Script < (UINTN) (StartAddress + TableLength)) {
+ while ((UINTN)Script < (UINTN)(StartAddress + TableLength)) {
DEBUG ((DEBUG_INFO, "ExecuteBootScript - %08x\n", (UINTN)Script));
- CopyMem ((VOID*)&ScriptHeader, Script, sizeof(EFI_BOOT_SCRIPT_COMMON_HEADER));
+ CopyMem ((VOID *)&ScriptHeader, Script, sizeof (EFI_BOOT_SCRIPT_COMMON_HEADER));
switch (ScriptHeader.OpCode) {
+ case EFI_BOOT_SCRIPT_MEM_WRITE_OPCODE:
+ DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_MEM_WRITE_OPCODE\n"));
+ Status = BootScriptExecuteMemoryWrite (Script);
+ break;
- case EFI_BOOT_SCRIPT_MEM_WRITE_OPCODE:
- DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_MEM_WRITE_OPCODE\n"));
- Status = BootScriptExecuteMemoryWrite (Script);
- break;
-
- case EFI_BOOT_SCRIPT_MEM_READ_WRITE_OPCODE:
- DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_MEM_READ_WRITE_OPCODE\n"));
- CheckAndOrMask (&ScriptHeader, &AndMask, &OrMask, Script);
- Status = BootScriptExecuteMemoryReadWrite (
- Script,
- AndMask,
- OrMask
- );
- break;
+ case EFI_BOOT_SCRIPT_MEM_READ_WRITE_OPCODE:
+ DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_MEM_READ_WRITE_OPCODE\n"));
+ CheckAndOrMask (&ScriptHeader, &AndMask, &OrMask, Script);
+ Status = BootScriptExecuteMemoryReadWrite (
+ Script,
+ AndMask,
+ OrMask
+ );
+ break;
- case EFI_BOOT_SCRIPT_IO_WRITE_OPCODE:
- DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_IO_WRITE_OPCODE\n"));
- Status = BootScriptExecuteIoWrite (Script);
- break;
+ case EFI_BOOT_SCRIPT_IO_WRITE_OPCODE:
+ DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_IO_WRITE_OPCODE\n"));
+ Status = BootScriptExecuteIoWrite (Script);
+ break;
- case EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE_OPCODE:
- DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE_OPCODE\n"));
- Status = BootScriptExecutePciCfgWrite (Script);
- break;
+ case EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE_OPCODE:
+ DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE_OPCODE\n"));
+ Status = BootScriptExecutePciCfgWrite (Script);
+ break;
- case EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE_OPCODE:
- DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE_OPCODE\n"));
- CheckAndOrMask (&ScriptHeader, &AndMask, &OrMask, Script);
- Status = BootScriptExecutePciCfgReadWrite (
- Script,
- AndMask,
- OrMask
- );
- break;
- case EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE_OPCODE:
- DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE_OPCODE\n"));
- Status = BootScriptExecutePciCfg2Write (Script);
- break;
+ case EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE_OPCODE:
+ DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE_OPCODE\n"));
+ CheckAndOrMask (&ScriptHeader, &AndMask, &OrMask, Script);
+ Status = BootScriptExecutePciCfgReadWrite (
+ Script,
+ AndMask,
+ OrMask
+ );
+ break;
+ case EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE_OPCODE:
+ DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE_OPCODE\n"));
+ Status = BootScriptExecutePciCfg2Write (Script);
+ break;
- case EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE_OPCODE:
- DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE_OPCODE\n"));
- CheckAndOrMask (&ScriptHeader, &AndMask, &OrMask, Script);
- Status = BootScriptExecutePciCfg2ReadWrite (
- Script,
- AndMask,
- OrMask
- );
- break;
- case EFI_BOOT_SCRIPT_DISPATCH_OPCODE:
- DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_DISPATCH_OPCODE\n"));
- Status = BootScriptExecuteDispatch (Script);
- break;
+ case EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE_OPCODE:
+ DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE_OPCODE\n"));
+ CheckAndOrMask (&ScriptHeader, &AndMask, &OrMask, Script);
+ Status = BootScriptExecutePciCfg2ReadWrite (
+ Script,
+ AndMask,
+ OrMask
+ );
+ break;
+ case EFI_BOOT_SCRIPT_DISPATCH_OPCODE:
+ DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_DISPATCH_OPCODE\n"));
+ Status = BootScriptExecuteDispatch (Script);
+ break;
- case EFI_BOOT_SCRIPT_DISPATCH_2_OPCODE:
- DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_DISPATCH_2_OPCODE\n"));
- Status = BootScriptExecuteDispatch2 (Script);
- break;
+ case EFI_BOOT_SCRIPT_DISPATCH_2_OPCODE:
+ DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_DISPATCH_2_OPCODE\n"));
+ Status = BootScriptExecuteDispatch2 (Script);
+ break;
- case EFI_BOOT_SCRIPT_INFORMATION_OPCODE:
- DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_INFORMATION_OPCODE\n"));
- BootScriptExecuteInformation (Script);
- break;
+ case EFI_BOOT_SCRIPT_INFORMATION_OPCODE:
+ DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_INFORMATION_OPCODE\n"));
+ BootScriptExecuteInformation (Script);
+ break;
- case S3_BOOT_SCRIPT_LIB_TERMINATE_OPCODE:
- DEBUG ((DEBUG_INFO, "S3_BOOT_SCRIPT_LIB_TERMINATE_OPCODE\n"));
- DEBUG ((DEBUG_INFO, "S3BootScriptDone - %r\n", EFI_SUCCESS));
- return EFI_SUCCESS;
+ case S3_BOOT_SCRIPT_LIB_TERMINATE_OPCODE:
+ DEBUG ((DEBUG_INFO, "S3_BOOT_SCRIPT_LIB_TERMINATE_OPCODE\n"));
+ DEBUG ((DEBUG_INFO, "S3BootScriptDone - %r\n", EFI_SUCCESS));
+ return EFI_SUCCESS;
+
+ case EFI_BOOT_SCRIPT_IO_READ_WRITE_OPCODE:
+ DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_IO_READ_WRITE_OPCODE\n"));
+ CheckAndOrMask (&ScriptHeader, &AndMask, &OrMask, Script);
+ Status = BootScriptExecuteIoReadWrite (
+ Script,
+ AndMask,
+ OrMask
+ );
+ break;
- case EFI_BOOT_SCRIPT_IO_READ_WRITE_OPCODE:
- DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_IO_READ_WRITE_OPCODE\n"));
- CheckAndOrMask (&ScriptHeader, &AndMask, &OrMask, Script);
- Status = BootScriptExecuteIoReadWrite (
- Script,
- AndMask,
- OrMask
- );
- break;
+ case EFI_BOOT_SCRIPT_SMBUS_EXECUTE_OPCODE:
+ DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_SMBUS_EXECUTE_OPCODE\n"));
+ Status = BootScriptExecuteSmbusExecute (Script);
+ break;
- case EFI_BOOT_SCRIPT_SMBUS_EXECUTE_OPCODE:
- DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_SMBUS_EXECUTE_OPCODE\n"));
- Status = BootScriptExecuteSmbusExecute (Script);
- break;
+ case EFI_BOOT_SCRIPT_STALL_OPCODE:
+ DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_STALL_OPCODE\n"));
+ Status = BootScriptExecuteStall (Script);
+ break;
- case EFI_BOOT_SCRIPT_STALL_OPCODE:
- DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_STALL_OPCODE\n"));
- Status = BootScriptExecuteStall (Script);
- break;
+ case EFI_BOOT_SCRIPT_MEM_POLL_OPCODE:
+ DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_MEM_POLL_OPCODE\n"));
+ CheckAndOrMask (&ScriptHeader, &AndMask, &OrMask, Script);
+ Status = BootScriptExecuteMemPoll (Script, AndMask, OrMask);
- case EFI_BOOT_SCRIPT_MEM_POLL_OPCODE:
- DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_MEM_POLL_OPCODE\n"));
- CheckAndOrMask (&ScriptHeader, &AndMask, &OrMask, Script);
- Status = BootScriptExecuteMemPoll (Script, AndMask, OrMask);
+ break;
- break;
+ case EFI_BOOT_SCRIPT_IO_POLL_OPCODE:
+ DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_IO_POLL_OPCODE\n"));
+ CheckAndOrMask (&ScriptHeader, &AndMask, &OrMask, Script);
+ Status = BootScriptExecuteIoPoll (Script, AndMask, OrMask);
+ break;
- case EFI_BOOT_SCRIPT_IO_POLL_OPCODE:
- DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_IO_POLL_OPCODE\n"));
- CheckAndOrMask (&ScriptHeader, &AndMask, &OrMask, Script);
- Status = BootScriptExecuteIoPoll (Script, AndMask, OrMask);
- break;
+ case EFI_BOOT_SCRIPT_PCI_CONFIG_POLL_OPCODE:
+ DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_PCI_CONFIG_POLL_OPCODE\n"));
+ CheckAndOrMask (&ScriptHeader, &AndMask, &OrMask, Script);
+ Status = BootScriptPciCfgPoll (Script, AndMask, OrMask);
+ break;
- case EFI_BOOT_SCRIPT_PCI_CONFIG_POLL_OPCODE:
- DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_PCI_CONFIG_POLL_OPCODE\n"));
- CheckAndOrMask (&ScriptHeader, &AndMask, &OrMask, Script);
- Status = BootScriptPciCfgPoll (Script, AndMask, OrMask);
- break;
+ case EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL_OPCODE:
+ DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL_OPCODE\n"));
+ CheckAndOrMask (&ScriptHeader, &AndMask, &OrMask, Script);
+ Status = BootScriptPciCfg2Poll (Script, AndMask, OrMask);
+ break;
- case EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL_OPCODE:
- DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL_OPCODE\n"));
- CheckAndOrMask (&ScriptHeader, &AndMask, &OrMask, Script);
- Status = BootScriptPciCfg2Poll (Script, AndMask, OrMask);
- break;
-
- case S3_BOOT_SCRIPT_LIB_LABEL_OPCODE:
- //
- // For label
- //
- DEBUG ((DEBUG_INFO, "S3_BOOT_SCRIPT_LIB_LABEL_OPCODE\n"));
- BootScriptExecuteLabel (Script);
- break;
- default:
- DEBUG ((DEBUG_INFO, "S3BootScriptDone - %r\n", EFI_UNSUPPORTED));
- return EFI_UNSUPPORTED;
+ case S3_BOOT_SCRIPT_LIB_LABEL_OPCODE:
+ //
+ // For label
+ //
+ DEBUG ((DEBUG_INFO, "S3_BOOT_SCRIPT_LIB_LABEL_OPCODE\n"));
+ BootScriptExecuteLabel (Script);
+ break;
+ default:
+ DEBUG ((DEBUG_INFO, "S3BootScriptDone - %r\n", EFI_UNSUPPORTED));
+ return EFI_UNSUPPORTED;
}
if (EFI_ERROR (Status)) {
@@ -1766,7 +1796,7 @@ S3BootScriptExecute ( return Status;
}
- Script = Script + ScriptHeader.Length;
+ Script = Script + ScriptHeader.Length;
}
DEBUG ((DEBUG_INFO, "S3BootScriptDone - %r\n", Status));
diff --git a/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptInternalFormat.h b/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptInternalFormat.h index 85bc8af39b..cf49368303 100644 --- a/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptInternalFormat.h +++ b/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptInternalFormat.h @@ -18,164 +18,163 @@ //
typedef struct {
- UINT16 OpCode;
- UINT8 Length;
+ UINT16 OpCode;
+ UINT8 Length;
} EFI_BOOT_SCRIPT_GENERIC_HEADER;
typedef struct {
- UINT16 OpCode;
- UINT8 Length;
- UINT16 Version;
- UINT32 TableLength;
- UINT16 Reserved[2];
+ UINT16 OpCode;
+ UINT8 Length;
+ UINT16 Version;
+ UINT32 TableLength;
+ UINT16 Reserved[2];
} EFI_BOOT_SCRIPT_TABLE_HEADER;
typedef struct {
- UINT16 OpCode;
- UINT8 Length;
- UINT32 Width;
+ UINT16 OpCode;
+ UINT8 Length;
+ UINT32 Width;
} EFI_BOOT_SCRIPT_COMMON_HEADER;
typedef struct {
- UINT16 OpCode;
- UINT8 Length;
- UINT32 Width;
- UINT32 Count;
- UINT64 Address;
+ UINT16 OpCode;
+ UINT8 Length;
+ UINT32 Width;
+ UINT32 Count;
+ UINT64 Address;
} EFI_BOOT_SCRIPT_IO_WRITE;
typedef struct {
- UINT16 OpCode;
- UINT8 Length;
- UINT32 Width;
- UINT64 Address;
+ UINT16 OpCode;
+ UINT8 Length;
+ UINT32 Width;
+ UINT64 Address;
} EFI_BOOT_SCRIPT_IO_READ_WRITE;
typedef struct {
- UINT16 OpCode;
- UINT8 Length;
- UINT32 Width;
- UINT32 Count;
- UINT64 Address;
+ UINT16 OpCode;
+ UINT8 Length;
+ UINT32 Width;
+ UINT32 Count;
+ UINT64 Address;
} EFI_BOOT_SCRIPT_MEM_WRITE;
typedef struct {
- UINT16 OpCode;
- UINT8 Length;
- UINT32 Width;
- UINT64 Address;
+ UINT16 OpCode;
+ UINT8 Length;
+ UINT32 Width;
+ UINT64 Address;
} EFI_BOOT_SCRIPT_MEM_READ_WRITE;
typedef struct {
- UINT16 OpCode;
- UINT8 Length;
- UINT32 Width;
- UINT32 Count;
- UINT64 Address;
+ UINT16 OpCode;
+ UINT8 Length;
+ UINT32 Width;
+ UINT32 Count;
+ UINT64 Address;
} EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE;
typedef struct {
- UINT16 OpCode;
- UINT8 Length;
- UINT32 Width;
- UINT32 Count;
- UINT64 Address;
- UINT16 Segment;
+ UINT16 OpCode;
+ UINT8 Length;
+ UINT32 Width;
+ UINT32 Count;
+ UINT64 Address;
+ UINT16 Segment;
} EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE;
typedef struct {
- UINT16 OpCode;
- UINT8 Length;
- UINT32 Width;
- UINT64 Address;
+ UINT16 OpCode;
+ UINT8 Length;
+ UINT32 Width;
+ UINT64 Address;
} EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE;
typedef struct {
- UINT16 OpCode;
- UINT8 Length;
- UINT32 Width;
- UINT64 Address;
- UINT16 Segment;
+ UINT16 OpCode;
+ UINT8 Length;
+ UINT32 Width;
+ UINT64 Address;
+ UINT16 Segment;
} EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE;
typedef struct {
- UINT16 OpCode;
- UINT8 Length;
- UINT64 SmBusAddress;
- UINT32 Operation;
- UINT32 DataSize;
+ UINT16 OpCode;
+ UINT8 Length;
+ UINT64 SmBusAddress;
+ UINT32 Operation;
+ UINT32 DataSize;
} EFI_BOOT_SCRIPT_SMBUS_EXECUTE;
typedef struct {
- UINT16 OpCode;
- UINT8 Length;
- UINT64 Duration;
+ UINT16 OpCode;
+ UINT8 Length;
+ UINT64 Duration;
} EFI_BOOT_SCRIPT_STALL;
typedef struct {
- UINT16 OpCode;
- UINT8 Length;
- EFI_PHYSICAL_ADDRESS EntryPoint;
+ UINT16 OpCode;
+ UINT8 Length;
+ EFI_PHYSICAL_ADDRESS EntryPoint;
} EFI_BOOT_SCRIPT_DISPATCH;
typedef struct {
- UINT16 OpCode;
- UINT8 Length;
- EFI_PHYSICAL_ADDRESS EntryPoint;
- EFI_PHYSICAL_ADDRESS Context;
+ UINT16 OpCode;
+ UINT8 Length;
+ EFI_PHYSICAL_ADDRESS EntryPoint;
+ EFI_PHYSICAL_ADDRESS Context;
} EFI_BOOT_SCRIPT_DISPATCH_2;
typedef struct {
- UINT16 OpCode;
- UINT8 Length;
- UINT32 Width;
- UINT64 Address;
- UINT64 Duration;
- UINT64 LoopTimes;
+ UINT16 OpCode;
+ UINT8 Length;
+ UINT32 Width;
+ UINT64 Address;
+ UINT64 Duration;
+ UINT64 LoopTimes;
} EFI_BOOT_SCRIPT_MEM_POLL;
typedef struct {
- UINT16 OpCode;
- UINT8 Length;
- UINT32 InformationLength;
-// UINT8 InformationData[InformationLength];
+ UINT16 OpCode;
+ UINT8 Length;
+ UINT32 InformationLength;
+ // UINT8 InformationData[InformationLength];
} EFI_BOOT_SCRIPT_INFORMATION;
typedef struct {
- UINT16 OpCode;
- UINT8 Length;
- UINT32 Width;
- UINT64 Address;
- UINT64 Delay;
+ UINT16 OpCode;
+ UINT8 Length;
+ UINT32 Width;
+ UINT64 Address;
+ UINT64 Delay;
} EFI_BOOT_SCRIPT_IO_POLL;
typedef struct {
- UINT16 OpCode;
- UINT8 Length;
- UINT32 Width;
- UINT64 Address;
- UINT64 Delay;
+ UINT16 OpCode;
+ UINT8 Length;
+ UINT32 Width;
+ UINT64 Address;
+ UINT64 Delay;
} EFI_BOOT_SCRIPT_PCI_CONFIG_POLL;
typedef struct {
- UINT16 OpCode;
- UINT8 Length;
- UINT32 Width;
- UINT64 Address;
- UINT16 Segment;
- UINT64 Delay;
+ UINT16 OpCode;
+ UINT8 Length;
+ UINT32 Width;
+ UINT64 Address;
+ UINT16 Segment;
+ UINT64 Delay;
} EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL;
typedef struct {
- UINT16 OpCode;
- UINT8 Length;
+ UINT16 OpCode;
+ UINT8 Length;
} EFI_BOOT_SCRIPT_TERMINATE;
-
#pragma pack()
-#define BOOT_SCRIPT_NODE_MAX_LENGTH 1024
+#define BOOT_SCRIPT_NODE_MAX_LENGTH 1024
-#define BOOT_SCRIPT_TABLE_VERSION 0x0001
+#define BOOT_SCRIPT_TABLE_VERSION 0x0001
#endif
diff --git a/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c b/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c index 20378502c8..f8d4983d81 100644 --- a/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c +++ b/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c @@ -94,37 +94,37 @@ **/
-SCRIPT_TABLE_PRIVATE_DATA *mS3BootScriptTablePtr;
+SCRIPT_TABLE_PRIVATE_DATA *mS3BootScriptTablePtr;
//
// Allocate SMM copy because we can not use mS3BootScriptTablePtr after SmmReadyToLock in InSmm.
//
-SCRIPT_TABLE_PRIVATE_DATA *mS3BootScriptTableSmmPtr;
+SCRIPT_TABLE_PRIVATE_DATA *mS3BootScriptTableSmmPtr;
-EFI_GUID mBootScriptDataGuid = {
+EFI_GUID mBootScriptDataGuid = {
0xaea6b965, 0xdcf5, 0x4311, { 0xb4, 0xb8, 0xf, 0x12, 0x46, 0x44, 0x94, 0xd2 }
};
-EFI_GUID mBootScriptDataBootTimeGuid = {
+EFI_GUID mBootScriptDataBootTimeGuid = {
0xb5af1d7a, 0xb8cf, 0x4eb3, { 0x89, 0x25, 0xa8, 0x20, 0xe1, 0x6b, 0x68, 0x7d }
};
-EFI_GUID mBootScriptTableBaseGuid = {
+EFI_GUID mBootScriptTableBaseGuid = {
0x1810ab4a, 0x2314, 0x4df6, { 0x81, 0xeb, 0x67, 0xc6, 0xec, 0x5, 0x85, 0x91 }
};
-EFI_GUID mBootScriptSmmPrivateDataGuid = {
+EFI_GUID mBootScriptSmmPrivateDataGuid = {
0x627ee2da, 0x3bf9, 0x439b, { 0x92, 0x9f, 0x2e, 0xe, 0x6e, 0x9d, 0xba, 0x62 }
};
-EFI_EVENT mEventDxeSmmReadyToLock = NULL;
-VOID *mRegistrationSmmExitBootServices = NULL;
-VOID *mRegistrationSmmLegacyBoot = NULL;
-VOID *mRegistrationSmmReadyToLock = NULL;
-BOOLEAN mS3BootScriptTableAllocated = FALSE;
-BOOLEAN mS3BootScriptTableSmmAllocated = FALSE;
-EFI_SMM_SYSTEM_TABLE2 *mBootScriptSmst = NULL;
-BOOLEAN mS3BootScriptAcpiS3Enable = TRUE;
+EFI_EVENT mEventDxeSmmReadyToLock = NULL;
+VOID *mRegistrationSmmExitBootServices = NULL;
+VOID *mRegistrationSmmLegacyBoot = NULL;
+VOID *mRegistrationSmmReadyToLock = NULL;
+BOOLEAN mS3BootScriptTableAllocated = FALSE;
+BOOLEAN mS3BootScriptTableSmmAllocated = FALSE;
+EFI_SMM_SYSTEM_TABLE2 *mBootScriptSmst = NULL;
+BOOLEAN mS3BootScriptAcpiS3Enable = TRUE;
/**
This is an internal function to add a terminate node the entry, recalculate the table
@@ -132,14 +132,15 @@ BOOLEAN mS3BootScriptAcpiS3Enable = TRUE; @return the base address of the boot script table.
**/
-UINT8*
+UINT8 *
S3BootScriptInternalCloseTable (
VOID
)
{
- UINT8 *S3TableBase;
- EFI_BOOT_SCRIPT_TERMINATE ScriptTerminate;
- EFI_BOOT_SCRIPT_TABLE_HEADER *ScriptTableInfo;
+ UINT8 *S3TableBase;
+ EFI_BOOT_SCRIPT_TERMINATE ScriptTerminate;
+ EFI_BOOT_SCRIPT_TABLE_HEADER *ScriptTableInfo;
+
S3TableBase = mS3BootScriptTablePtr->TableBase;
if (S3TableBase == NULL) {
@@ -148,20 +149,19 @@ S3BootScriptInternalCloseTable ( //
return S3TableBase;
}
+
//
// Append the termination entry.
//
- ScriptTerminate.OpCode = S3_BOOT_SCRIPT_LIB_TERMINATE_OPCODE;
- ScriptTerminate.Length = (UINT8) sizeof (EFI_BOOT_SCRIPT_TERMINATE);
+ ScriptTerminate.OpCode = S3_BOOT_SCRIPT_LIB_TERMINATE_OPCODE;
+ ScriptTerminate.Length = (UINT8)sizeof (EFI_BOOT_SCRIPT_TERMINATE);
CopyMem (mS3BootScriptTablePtr->TableBase + mS3BootScriptTablePtr->TableLength, &ScriptTerminate, sizeof (EFI_BOOT_SCRIPT_TERMINATE));
//
// fill the table length
//
- ScriptTableInfo = (EFI_BOOT_SCRIPT_TABLE_HEADER*)(mS3BootScriptTablePtr->TableBase);
+ ScriptTableInfo = (EFI_BOOT_SCRIPT_TABLE_HEADER *)(mS3BootScriptTablePtr->TableBase);
ScriptTableInfo->TableLength = mS3BootScriptTablePtr->TableLength + sizeof (EFI_BOOT_SCRIPT_TERMINATE);
-
-
return S3TableBase;
//
// NOTE: Here we did NOT adjust the mS3BootScriptTablePtr->TableLength to
@@ -180,7 +180,7 @@ SaveBootScriptDataToLockBox ( VOID
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
//
// Save whole memory copy into LockBox.
@@ -203,7 +203,7 @@ SaveBootScriptDataToLockBox ( Status = SaveLockBox (
&mBootScriptTableBaseGuid,
(VOID *)&mS3BootScriptTablePtr->TableBase,
- sizeof(mS3BootScriptTablePtr->TableBase)
+ sizeof (mS3BootScriptTablePtr->TableBase)
);
ASSERT_EFI_ERROR (Status);
@@ -225,8 +225,8 @@ S3BootScriptEventCallBack ( IN VOID *Context
)
{
- EFI_STATUS Status;
- VOID *Interface;
+ EFI_STATUS Status;
+ VOID *Interface;
//
// Try to locate it because EfiCreateProtocolNotifyEvent will trigger it once when registration.
@@ -238,7 +238,7 @@ S3BootScriptEventCallBack ( &Interface
);
if (EFI_ERROR (Status)) {
- return ;
+ return;
}
//
@@ -295,7 +295,7 @@ S3BootScriptSmmEventCallBack ( // Save a SMM copy. If TableBase is NOT null, it means SMM copy has been ready, skip copy mem.
//
if (mS3BootScriptTableSmmPtr->TableBase == NULL) {
- CopyMem (mS3BootScriptTableSmmPtr, mS3BootScriptTablePtr, sizeof(*mS3BootScriptTablePtr));
+ CopyMem (mS3BootScriptTableSmmPtr, mS3BootScriptTablePtr, sizeof (*mS3BootScriptTablePtr));
//
// Set InSmm, we allow boot script update when InSmm, but not allow boot script outside SMM.
@@ -303,6 +303,7 @@ S3BootScriptSmmEventCallBack ( //
mS3BootScriptTableSmmPtr->InSmm = TRUE;
}
+
//
// We should not use ACPI Reserved copy, because it is not safe.
//
@@ -325,7 +326,7 @@ SaveBootTimeDataToLockBox ( VOID
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
//
// ACPI Reserved copy is not safe, restore from BootScriptData LockBox first,
@@ -344,7 +345,7 @@ SaveBootTimeDataToLockBox ( //
Status = SaveLockBox (
&mBootScriptDataBootTimeGuid,
- (VOID *) mS3BootScriptTablePtr->TableBase,
+ (VOID *)mS3BootScriptTablePtr->TableBase,
mS3BootScriptTablePtr->BootTimeScriptLength
);
ASSERT_EFI_ERROR (Status);
@@ -360,17 +361,17 @@ SaveSmmPriviateDataToLockBoxAtRuntime ( VOID
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
//
// Save boot script SMM private data with BackFromS3 = TRUE.
//
mS3BootScriptTablePtr->BackFromS3 = TRUE;
- Status = SaveLockBox (
- &mBootScriptSmmPrivateDataGuid,
- (VOID *) mS3BootScriptTablePtr,
- sizeof (SCRIPT_TABLE_PRIVATE_DATA)
- );
+ Status = SaveLockBox (
+ &mBootScriptSmmPrivateDataGuid,
+ (VOID *)mS3BootScriptTablePtr,
+ sizeof (SCRIPT_TABLE_PRIVATE_DATA)
+ );
ASSERT_EFI_ERROR (Status);
Status = SetLockBoxAttributes (&mBootScriptSmmPrivateDataGuid, LOCK_BOX_ATTRIBUTE_RESTORE_IN_PLACE);
@@ -395,13 +396,13 @@ SaveSmmPriviateDataToLockBoxAtRuntime ( EFI_STATUS
EFIAPI
S3BootScriptSmmAtRuntimeCallBack (
- IN CONST EFI_GUID *Protocol,
- IN VOID *Interface,
- IN EFI_HANDLE Handle
+ IN CONST EFI_GUID *Protocol,
+ IN VOID *Interface,
+ IN EFI_HANDLE Handle
)
{
if (!mS3BootScriptTablePtr->AtRuntime) {
- mS3BootScriptTablePtr->BootTimeScriptLength = (UINT32) (mS3BootScriptTablePtr->TableLength + sizeof (EFI_BOOT_SCRIPT_TERMINATE));
+ mS3BootScriptTablePtr->BootTimeScriptLength = (UINT32)(mS3BootScriptTablePtr->TableLength + sizeof (EFI_BOOT_SCRIPT_TERMINATE));
SaveBootTimeDataToLockBox ();
mS3BootScriptTablePtr->AtRuntime = TRUE;
@@ -425,17 +426,17 @@ S3BootScriptSmmAtRuntimeCallBack ( RETURN_STATUS
EFIAPI
S3BootScriptLibInitialize (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
- SCRIPT_TABLE_PRIVATE_DATA *S3TablePtr;
- SCRIPT_TABLE_PRIVATE_DATA *S3TableSmmPtr;
- VOID *Registration;
- EFI_SMM_BASE2_PROTOCOL *SmmBase2;
- BOOLEAN InSmm;
- EFI_PHYSICAL_ADDRESS Buffer;
+ EFI_STATUS Status;
+ SCRIPT_TABLE_PRIVATE_DATA *S3TablePtr;
+ SCRIPT_TABLE_PRIVATE_DATA *S3TableSmmPtr;
+ VOID *Registration;
+ EFI_SMM_BASE2_PROTOCOL *SmmBase2;
+ BOOLEAN InSmm;
+ EFI_PHYSICAL_ADDRESS Buffer;
if (!PcdGetBool (PcdAcpiS3Enable)) {
mS3BootScriptAcpiS3Enable = FALSE;
@@ -443,7 +444,7 @@ S3BootScriptLibInitialize ( return RETURN_SUCCESS;
}
- S3TablePtr = (SCRIPT_TABLE_PRIVATE_DATA*)(UINTN)PcdGet64(PcdS3BootScriptTablePrivateDataPtr);
+ S3TablePtr = (SCRIPT_TABLE_PRIVATE_DATA *)(UINTN)PcdGet64 (PcdS3BootScriptTablePrivateDataPtr);
//
// The Boot script private data is not be initialized. create it
//
@@ -452,16 +453,16 @@ S3BootScriptLibInitialize ( Status = gBS->AllocatePages (
AllocateMaxAddress,
EfiReservedMemoryType,
- EFI_SIZE_TO_PAGES(sizeof(SCRIPT_TABLE_PRIVATE_DATA)),
+ EFI_SIZE_TO_PAGES (sizeof (SCRIPT_TABLE_PRIVATE_DATA)),
&Buffer
);
ASSERT_EFI_ERROR (Status);
mS3BootScriptTableAllocated = TRUE;
- S3TablePtr = (VOID *) (UINTN) Buffer;
+ S3TablePtr = (VOID *)(UINTN)Buffer;
- Status = PcdSet64S (PcdS3BootScriptTablePrivateDataPtr, (UINT64) (UINTN)S3TablePtr);
+ Status = PcdSet64S (PcdS3BootScriptTablePrivateDataPtr, (UINT64)(UINTN)S3TablePtr);
ASSERT_EFI_ERROR (Status);
- ZeroMem (S3TablePtr, sizeof(SCRIPT_TABLE_PRIVATE_DATA));
+ ZeroMem (S3TablePtr, sizeof (SCRIPT_TABLE_PRIVATE_DATA));
//
// Create event to notify the library system enter the SmmLocked phase.
//
@@ -474,22 +475,26 @@ S3BootScriptLibInitialize ( );
ASSERT (mEventDxeSmmReadyToLock != NULL);
}
+
mS3BootScriptTablePtr = S3TablePtr;
//
// Get InSmm, we need to register SmmReadyToLock if this library is linked to SMM driver.
//
- Status = gBS->LocateProtocol (&gEfiSmmBase2ProtocolGuid, NULL, (VOID**) &SmmBase2);
+ Status = gBS->LocateProtocol (&gEfiSmmBase2ProtocolGuid, NULL, (VOID **)&SmmBase2);
if (EFI_ERROR (Status)) {
return RETURN_SUCCESS;
}
+
Status = SmmBase2->InSmm (SmmBase2, &InSmm);
if (EFI_ERROR (Status)) {
return RETURN_SUCCESS;
}
+
if (!InSmm) {
return RETURN_SUCCESS;
}
+
//
// Good, we are in SMM
//
@@ -498,22 +503,22 @@ S3BootScriptLibInitialize ( return RETURN_SUCCESS;
}
- S3TableSmmPtr = (SCRIPT_TABLE_PRIVATE_DATA*)(UINTN)PcdGet64(PcdS3BootScriptTablePrivateSmmDataPtr);
+ S3TableSmmPtr = (SCRIPT_TABLE_PRIVATE_DATA *)(UINTN)PcdGet64 (PcdS3BootScriptTablePrivateSmmDataPtr);
//
// The Boot script private data in SMM is not be initialized. create it
//
if (S3TableSmmPtr == 0) {
Status = mBootScriptSmst->SmmAllocatePool (
EfiRuntimeServicesData,
- sizeof(SCRIPT_TABLE_PRIVATE_DATA),
- (VOID **) &S3TableSmmPtr
+ sizeof (SCRIPT_TABLE_PRIVATE_DATA),
+ (VOID **)&S3TableSmmPtr
);
ASSERT_EFI_ERROR (Status);
mS3BootScriptTableSmmAllocated = TRUE;
- Status = PcdSet64S (PcdS3BootScriptTablePrivateSmmDataPtr, (UINT64) (UINTN)S3TableSmmPtr);
+ Status = PcdSet64S (PcdS3BootScriptTablePrivateSmmDataPtr, (UINT64)(UINTN)S3TableSmmPtr);
ASSERT_EFI_ERROR (Status);
- ZeroMem (S3TableSmmPtr, sizeof(SCRIPT_TABLE_PRIVATE_DATA));
+ ZeroMem (S3TableSmmPtr, sizeof (SCRIPT_TABLE_PRIVATE_DATA));
//
// Register SmmExitBootServices and SmmLegacyBoot notification.
@@ -532,6 +537,7 @@ S3BootScriptLibInitialize ( );
ASSERT_EFI_ERROR (Status);
}
+
mS3BootScriptTableSmmPtr = S3TableSmmPtr;
//
@@ -563,11 +569,11 @@ S3BootScriptLibInitialize ( RETURN_STATUS
EFIAPI
S3BootScriptLibDeinitialize (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
if (!mS3BootScriptAcpiS3Enable) {
return RETURN_SUCCESS;
@@ -595,6 +601,7 @@ S3BootScriptLibDeinitialize ( );
ASSERT_EFI_ERROR (Status);
}
+
if (mRegistrationSmmLegacyBoot != NULL) {
//
// Unregister SmmLegacyBoot notification.
@@ -606,6 +613,7 @@ S3BootScriptLibDeinitialize ( );
ASSERT_EFI_ERROR (Status);
}
+
if (mRegistrationSmmReadyToLock != NULL) {
//
// Unregister SmmReadyToLock notification.
@@ -623,11 +631,12 @@ S3BootScriptLibDeinitialize ( // Free the resources allocated and set PCDs to 0.
//
if (mS3BootScriptTableAllocated) {
- Status = gBS->FreePages ((EFI_PHYSICAL_ADDRESS) (UINTN) mS3BootScriptTablePtr, EFI_SIZE_TO_PAGES(sizeof(SCRIPT_TABLE_PRIVATE_DATA)));
+ Status = gBS->FreePages ((EFI_PHYSICAL_ADDRESS)(UINTN)mS3BootScriptTablePtr, EFI_SIZE_TO_PAGES (sizeof (SCRIPT_TABLE_PRIVATE_DATA)));
ASSERT_EFI_ERROR (Status);
Status = PcdSet64S (PcdS3BootScriptTablePrivateDataPtr, 0);
ASSERT_EFI_ERROR (Status);
}
+
if ((mBootScriptSmst != NULL) && mS3BootScriptTableSmmAllocated) {
Status = mBootScriptSmst->SmmFreePool (mS3BootScriptTableSmmPtr);
ASSERT_EFI_ERROR (Status);
@@ -648,95 +657,98 @@ S3BootScriptLibDeinitialize ( @retval the address from which the a new s3 boot script entry will write into
**/
-UINT8*
+UINT8 *
S3BootScriptGetBootTimeEntryAddAddress (
UINT8 EntryLength
)
{
- EFI_PHYSICAL_ADDRESS S3TableBase;
- EFI_PHYSICAL_ADDRESS NewS3TableBase;
- UINT8 *NewEntryPtr;
- UINT32 TableLength;
- UINT16 PageNumber;
- EFI_STATUS Status;
- EFI_BOOT_SCRIPT_TABLE_HEADER *ScriptTableInfo;
-
- S3TableBase = (EFI_PHYSICAL_ADDRESS)(UINTN)(mS3BootScriptTablePtr->TableBase);
- if (S3TableBase == 0) {
- //
- // The table is not exist. This is the first to add entry.
- // Allocate ACPI script table space under 4G memory.
- //
- S3TableBase = 0xffffffff;
- Status = gBS->AllocatePages (
- AllocateMaxAddress,
- EfiReservedMemoryType,
- 2 + PcdGet16(PcdS3BootScriptRuntimeTableReservePageNumber),
- (EFI_PHYSICAL_ADDRESS*)&S3TableBase
- );
+ EFI_PHYSICAL_ADDRESS S3TableBase;
+ EFI_PHYSICAL_ADDRESS NewS3TableBase;
+ UINT8 *NewEntryPtr;
+ UINT32 TableLength;
+ UINT16 PageNumber;
+ EFI_STATUS Status;
+ EFI_BOOT_SCRIPT_TABLE_HEADER *ScriptTableInfo;
+
+ S3TableBase = (EFI_PHYSICAL_ADDRESS)(UINTN)(mS3BootScriptTablePtr->TableBase);
+ if (S3TableBase == 0) {
+ //
+ // The table is not exist. This is the first to add entry.
+ // Allocate ACPI script table space under 4G memory.
+ //
+ S3TableBase = 0xffffffff;
+ Status = gBS->AllocatePages (
+ AllocateMaxAddress,
+ EfiReservedMemoryType,
+ 2 + PcdGet16 (PcdS3BootScriptRuntimeTableReservePageNumber),
+ (EFI_PHYSICAL_ADDRESS *)&S3TableBase
+ );
+
+ if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
+ return 0;
+ }
- if (EFI_ERROR(Status)) {
- ASSERT_EFI_ERROR (Status);
- return 0;
- }
- //
- // Fill Table Header
- //
- ScriptTableInfo = (EFI_BOOT_SCRIPT_TABLE_HEADER*)(UINTN)S3TableBase;
- ScriptTableInfo->OpCode = S3_BOOT_SCRIPT_LIB_TABLE_OPCODE;
- ScriptTableInfo->Length = (UINT8) sizeof (EFI_BOOT_SCRIPT_TABLE_HEADER);
- ScriptTableInfo->Version = BOOT_SCRIPT_TABLE_VERSION;
- ScriptTableInfo->TableLength = 0; // will be calculate at CloseTable
- mS3BootScriptTablePtr->TableLength = sizeof (EFI_BOOT_SCRIPT_TABLE_HEADER);
- mS3BootScriptTablePtr->TableBase = (UINT8*)(UINTN)S3TableBase;
- mS3BootScriptTablePtr->TableMemoryPageNumber = (UINT16)(2 + PcdGet16(PcdS3BootScriptRuntimeTableReservePageNumber));
- }
-
- // Here we do not count the reserved memory for runtime script table.
- PageNumber = (UINT16) (mS3BootScriptTablePtr->TableMemoryPageNumber - PcdGet16(PcdS3BootScriptRuntimeTableReservePageNumber));
- TableLength = mS3BootScriptTablePtr->TableLength;
- if (EFI_PAGES_TO_SIZE ((UINTN) PageNumber) < (TableLength + EntryLength + sizeof (EFI_BOOT_SCRIPT_TERMINATE))) {
- //
- // The buffer is too small to hold the table, Reallocate the buffer
- //
- NewS3TableBase = 0xffffffff;
- Status = gBS->AllocatePages (
- AllocateMaxAddress,
- EfiReservedMemoryType,
- 2 + PageNumber + PcdGet16(PcdS3BootScriptRuntimeTableReservePageNumber),
- (EFI_PHYSICAL_ADDRESS*)&NewS3TableBase
- );
+ //
+ // Fill Table Header
+ //
+ ScriptTableInfo = (EFI_BOOT_SCRIPT_TABLE_HEADER *)(UINTN)S3TableBase;
+ ScriptTableInfo->OpCode = S3_BOOT_SCRIPT_LIB_TABLE_OPCODE;
+ ScriptTableInfo->Length = (UINT8)sizeof (EFI_BOOT_SCRIPT_TABLE_HEADER);
+ ScriptTableInfo->Version = BOOT_SCRIPT_TABLE_VERSION;
+ ScriptTableInfo->TableLength = 0; // will be calculate at CloseTable
+ mS3BootScriptTablePtr->TableLength = sizeof (EFI_BOOT_SCRIPT_TABLE_HEADER);
+ mS3BootScriptTablePtr->TableBase = (UINT8 *)(UINTN)S3TableBase;
+ mS3BootScriptTablePtr->TableMemoryPageNumber = (UINT16)(2 + PcdGet16 (PcdS3BootScriptRuntimeTableReservePageNumber));
+ }
+
+ // Here we do not count the reserved memory for runtime script table.
+ PageNumber = (UINT16)(mS3BootScriptTablePtr->TableMemoryPageNumber - PcdGet16 (PcdS3BootScriptRuntimeTableReservePageNumber));
+ TableLength = mS3BootScriptTablePtr->TableLength;
+ if (EFI_PAGES_TO_SIZE ((UINTN)PageNumber) < (TableLength + EntryLength + sizeof (EFI_BOOT_SCRIPT_TERMINATE))) {
+ //
+ // The buffer is too small to hold the table, Reallocate the buffer
+ //
+ NewS3TableBase = 0xffffffff;
+ Status = gBS->AllocatePages (
+ AllocateMaxAddress,
+ EfiReservedMemoryType,
+ 2 + PageNumber + PcdGet16 (PcdS3BootScriptRuntimeTableReservePageNumber),
+ (EFI_PHYSICAL_ADDRESS *)&NewS3TableBase
+ );
+
+ if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
+ return 0;
+ }
+
+ CopyMem ((VOID *)(UINTN)NewS3TableBase, (VOID *)(UINTN)S3TableBase, TableLength);
+ gBS->FreePages (S3TableBase, mS3BootScriptTablePtr->TableMemoryPageNumber);
+
+ mS3BootScriptTablePtr->TableBase = (UINT8 *)(UINTN)NewS3TableBase;
+ mS3BootScriptTablePtr->TableMemoryPageNumber = (UINT16)(2 + PageNumber + PcdGet16 (PcdS3BootScriptRuntimeTableReservePageNumber));
+ }
+
+ //
+ // calculate the the start address for the new entry.
+ //
+ NewEntryPtr = mS3BootScriptTablePtr->TableBase + TableLength;
+
+ //
+ // update the table lenghth
+ //
+ mS3BootScriptTablePtr->TableLength = TableLength + EntryLength;
- if (EFI_ERROR(Status)) {
- ASSERT_EFI_ERROR (Status);
- return 0;
- }
-
- CopyMem ((VOID*)(UINTN)NewS3TableBase, (VOID*)(UINTN)S3TableBase, TableLength);
- gBS->FreePages (S3TableBase, mS3BootScriptTablePtr->TableMemoryPageNumber);
-
- mS3BootScriptTablePtr->TableBase = (UINT8*)(UINTN)NewS3TableBase;
- mS3BootScriptTablePtr->TableMemoryPageNumber = (UINT16) (2 + PageNumber + PcdGet16(PcdS3BootScriptRuntimeTableReservePageNumber));
- }
- //
- // calculate the the start address for the new entry.
- //
- NewEntryPtr = mS3BootScriptTablePtr->TableBase + TableLength;
-
- //
- // update the table lenghth
- //
- mS3BootScriptTablePtr->TableLength = TableLength + EntryLength;
-
- //
- // In the boot time, we will not append the termination entry to the boot script
- // table until the callers think there is no boot time data that should be added and
- // it is caller's responsibility to explicit call the CloseTable.
- //
- //
-
- return NewEntryPtr;
+ //
+ // In the boot time, we will not append the termination entry to the boot script
+ // table until the callers think there is no boot time data that should be added and
+ // it is caller's responsibility to explicit call the CloseTable.
+ //
+ //
+
+ return NewEntryPtr;
}
+
/**
To get the start address from which a new runtime(after SmmReadyToLock) s3 boot script entry will write into.
In this case, it should be ensured that there is enough buffer to hold the entry.
@@ -745,26 +757,27 @@ S3BootScriptGetBootTimeEntryAddAddress ( @retval the address from which the a new s3 runtime(after SmmReadyToLock) script entry will write into
**/
-UINT8*
+UINT8 *
S3BootScriptGetRuntimeEntryAddAddress (
UINT8 EntryLength
)
{
- UINT8 *NewEntryPtr;
-
- NewEntryPtr = NULL;
- //
- // Check if the memory range reserved for S3 Boot Script table is large enough to hold the node.
- //
- if ((mS3BootScriptTablePtr->TableLength + EntryLength + sizeof (EFI_BOOT_SCRIPT_TERMINATE)) <= EFI_PAGES_TO_SIZE ((UINTN) (mS3BootScriptTablePtr->TableMemoryPageNumber))) {
- NewEntryPtr = mS3BootScriptTablePtr->TableBase + mS3BootScriptTablePtr->TableLength;
- mS3BootScriptTablePtr->TableLength = mS3BootScriptTablePtr->TableLength + EntryLength;
- //
- // Append a terminate node on every insert
- //
- S3BootScriptInternalCloseTable ();
- }
- return (UINT8*)NewEntryPtr;
+ UINT8 *NewEntryPtr;
+
+ NewEntryPtr = NULL;
+ //
+ // Check if the memory range reserved for S3 Boot Script table is large enough to hold the node.
+ //
+ if ((mS3BootScriptTablePtr->TableLength + EntryLength + sizeof (EFI_BOOT_SCRIPT_TERMINATE)) <= EFI_PAGES_TO_SIZE ((UINTN)(mS3BootScriptTablePtr->TableMemoryPageNumber))) {
+ NewEntryPtr = mS3BootScriptTablePtr->TableBase + mS3BootScriptTablePtr->TableLength;
+ mS3BootScriptTablePtr->TableLength = mS3BootScriptTablePtr->TableLength + EntryLength;
+ //
+ // Append a terminate node on every insert
+ //
+ S3BootScriptInternalCloseTable ();
+ }
+
+ return (UINT8 *)NewEntryPtr;
}
/**
@@ -776,18 +789,18 @@ RestoreBootTimeDataFromLockBox ( VOID
)
{
- EFI_STATUS Status;
- UINTN LockBoxLength;
+ EFI_STATUS Status;
+ UINTN LockBoxLength;
//
// Restore boot time boot script data from LockBox.
//
LockBoxLength = mS3BootScriptTablePtr->BootTimeScriptLength;
- Status = RestoreLockBox (
- &mBootScriptDataBootTimeGuid,
- (VOID *) mS3BootScriptTablePtr->TableBase,
- &LockBoxLength
- );
+ Status = RestoreLockBox (
+ &mBootScriptDataBootTimeGuid,
+ (VOID *)mS3BootScriptTablePtr->TableBase,
+ &LockBoxLength
+ );
ASSERT_EFI_ERROR (Status);
//
@@ -796,7 +809,7 @@ RestoreBootTimeDataFromLockBox ( Status = UpdateLockBox (
&mBootScriptDataGuid,
0,
- (VOID *) mS3BootScriptTablePtr->TableBase,
+ (VOID *)mS3BootScriptTablePtr->TableBase,
LockBoxLength
);
ASSERT_EFI_ERROR (Status);
@@ -804,7 +817,7 @@ RestoreBootTimeDataFromLockBox ( //
// Update TableLength.
//
- mS3BootScriptTablePtr->TableLength = (UINT32) (mS3BootScriptTablePtr->BootTimeScriptLength - sizeof (EFI_BOOT_SCRIPT_TERMINATE));
+ mS3BootScriptTablePtr->TableLength = (UINT32)(mS3BootScriptTablePtr->BootTimeScriptLength - sizeof (EFI_BOOT_SCRIPT_TERMINATE));
}
/**
@@ -814,12 +827,12 @@ RestoreBootTimeDataFromLockBox ( @retval the address from which the a new s3 boot script entry will write into
**/
-UINT8*
+UINT8 *
S3BootScriptGetEntryAddAddress (
UINT8 EntryLength
)
{
- UINT8* NewEntryPtr;
+ UINT8 *NewEntryPtr;
if (!mS3BootScriptAcpiS3Enable) {
return NULL;
@@ -847,12 +860,12 @@ S3BootScriptGetEntryAddAddress ( mS3BootScriptTablePtr->BackFromS3 = FALSE;
}
- NewEntryPtr = S3BootScriptGetRuntimeEntryAddAddress (EntryLength);
+ NewEntryPtr = S3BootScriptGetRuntimeEntryAddAddress (EntryLength);
} else {
- NewEntryPtr = S3BootScriptGetBootTimeEntryAddAddress (EntryLength);
+ NewEntryPtr = S3BootScriptGetBootTimeEntryAddAddress (EntryLength);
}
- return NewEntryPtr;
+ return NewEntryPtr;
}
/**
@@ -863,7 +876,7 @@ S3BootScriptGetEntryAddAddress ( **/
VOID
SyncBootScript (
- IN UINT8 *Script
+ IN UINT8 *Script
)
{
EFI_STATUS Status;
@@ -875,12 +888,12 @@ SyncBootScript ( // If it is not after SmmReadyToLock in SMM,
// just return.
//
- return ;
+ return;
}
- ScriptOffset = (UINT32) (Script - mS3BootScriptTablePtr->TableBase);
+ ScriptOffset = (UINT32)(Script - mS3BootScriptTablePtr->TableBase);
- TotalScriptLength = (UINT32) (mS3BootScriptTablePtr->TableLength + sizeof (EFI_BOOT_SCRIPT_TERMINATE));
+ TotalScriptLength = (UINT32)(mS3BootScriptTablePtr->TableLength + sizeof (EFI_BOOT_SCRIPT_TERMINATE));
//
// Update BootScriptData
@@ -932,26 +945,27 @@ SyncBootScript ( @note this function could only called in boot time phase
**/
-UINT8*
+UINT8 *
EFIAPI
S3BootScriptCloseTable (
VOID
)
{
- UINT8 *S3TableBase;
- UINT32 TableLength;
- UINT8 *Buffer;
- EFI_STATUS Status;
- EFI_BOOT_SCRIPT_TABLE_HEADER *ScriptTableInfo;
+ UINT8 *S3TableBase;
+ UINT32 TableLength;
+ UINT8 *Buffer;
+ EFI_STATUS Status;
+ EFI_BOOT_SCRIPT_TABLE_HEADER *ScriptTableInfo;
S3TableBase = mS3BootScriptTablePtr->TableBase;
if (S3TableBase == 0) {
return 0;
}
+
//
// Append the termination record the S3 boot script table
//
- S3BootScriptInternalCloseTable();
+ S3BootScriptInternalCloseTable ();
TableLength = mS3BootScriptTablePtr->TableLength + sizeof (EFI_BOOT_SCRIPT_TERMINATE);
//
// Allocate the buffer and copy the boot script to the buffer.
@@ -959,11 +973,12 @@ S3BootScriptCloseTable ( Status = gBS->AllocatePool (
EfiBootServicesData,
(UINTN)TableLength,
- (VOID **) &Buffer
+ (VOID **)&Buffer
);
if (EFI_ERROR (Status)) {
- return 0;
+ return 0;
}
+
CopyMem (Buffer, S3TableBase, TableLength);
//
@@ -971,14 +986,15 @@ S3BootScriptCloseTable ( // will write the record to the first entry of the table.
//
// Fill the table header.
- ScriptTableInfo = (EFI_BOOT_SCRIPT_TABLE_HEADER*)S3TableBase;
+ ScriptTableInfo = (EFI_BOOT_SCRIPT_TABLE_HEADER *)S3TableBase;
ScriptTableInfo->OpCode = S3_BOOT_SCRIPT_LIB_TABLE_OPCODE;
- ScriptTableInfo->Length = (UINT8) sizeof (EFI_BOOT_SCRIPT_TABLE_HEADER);
+ ScriptTableInfo->Length = (UINT8)sizeof (EFI_BOOT_SCRIPT_TABLE_HEADER);
ScriptTableInfo->TableLength = 0; // will be calculate at close the table
mS3BootScriptTablePtr->TableLength = sizeof (EFI_BOOT_SCRIPT_TABLE_HEADER);
return Buffer;
}
+
/**
Save I/O write to boot script
@@ -993,33 +1009,36 @@ S3BootScriptCloseTable ( RETURN_STATUS
EFIAPI
S3BootScriptSaveIoWrite (
- IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
- IN UINT64 Address,
- IN UINTN Count,
- IN VOID *Buffer
+ IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
+ IN UINT64 Address,
+ IN UINTN Count,
+ IN VOID *Buffer
)
{
UINT8 Length;
- UINT8 *Script;
+ UINT8 *Script;
UINT8 WidthInByte;
EFI_BOOT_SCRIPT_IO_WRITE ScriptIoWrite;
- WidthInByte = (UINT8) (0x01 << (Width & 0x03));
+ WidthInByte = (UINT8)(0x01 << (Width & 0x03));
//
// Truncation check
//
if ((Count > MAX_UINT8) ||
- (WidthInByte * Count > MAX_UINT8 - sizeof (EFI_BOOT_SCRIPT_IO_WRITE))) {
+ (WidthInByte * Count > MAX_UINT8 - sizeof (EFI_BOOT_SCRIPT_IO_WRITE)))
+ {
return RETURN_OUT_OF_RESOURCES;
}
+
Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_IO_WRITE) + (WidthInByte * Count));
Script = S3BootScriptGetEntryAddAddress (Length);
if (Script == NULL) {
return RETURN_OUT_OF_RESOURCES;
}
+
//
// save script data
//
@@ -1027,9 +1046,9 @@ S3BootScriptSaveIoWrite ( ScriptIoWrite.Length = Length;
ScriptIoWrite.Width = Width;
ScriptIoWrite.Address = Address;
- ScriptIoWrite.Count = (UINT32) Count;
- CopyMem ((VOID*)Script, (VOID*)&ScriptIoWrite, sizeof(EFI_BOOT_SCRIPT_IO_WRITE));
- CopyMem ((VOID*)(Script + sizeof (EFI_BOOT_SCRIPT_IO_WRITE)), Buffer, WidthInByte * Count);
+ ScriptIoWrite.Count = (UINT32)Count;
+ CopyMem ((VOID *)Script, (VOID *)&ScriptIoWrite, sizeof (EFI_BOOT_SCRIPT_IO_WRITE));
+ CopyMem ((VOID *)(Script + sizeof (EFI_BOOT_SCRIPT_IO_WRITE)), Buffer, WidthInByte * Count);
SyncBootScript (Script);
@@ -1050,24 +1069,25 @@ S3BootScriptSaveIoWrite ( RETURN_STATUS
EFIAPI
S3BootScriptSaveIoReadWrite (
- IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
- IN UINT64 Address,
- IN VOID *Data,
- IN VOID *DataMask
+ IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
+ IN UINT64 Address,
+ IN VOID *Data,
+ IN VOID *DataMask
)
{
- UINT8 Length;
- UINT8 *Script;
- UINT8 WidthInByte;
+ UINT8 Length;
+ UINT8 *Script;
+ UINT8 WidthInByte;
EFI_BOOT_SCRIPT_IO_READ_WRITE ScriptIoReadWrite;
- WidthInByte = (UINT8) (0x01 << (Width & 0x03));
- Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_IO_READ_WRITE) + (WidthInByte * 2));
+ WidthInByte = (UINT8)(0x01 << (Width & 0x03));
+ Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_IO_READ_WRITE) + (WidthInByte * 2));
Script = S3BootScriptGetEntryAddAddress (Length);
if (Script == NULL) {
return RETURN_OUT_OF_RESOURCES;
}
+
//
// Build script data
//
@@ -1076,14 +1096,15 @@ S3BootScriptSaveIoReadWrite ( ScriptIoReadWrite.Width = Width;
ScriptIoReadWrite.Address = Address;
- CopyMem ((VOID*)Script, (VOID*)&ScriptIoReadWrite, sizeof(EFI_BOOT_SCRIPT_IO_READ_WRITE));
- CopyMem ((VOID*)(Script + sizeof (EFI_BOOT_SCRIPT_IO_READ_WRITE)), Data, WidthInByte);
- CopyMem ((VOID*)(Script + sizeof (EFI_BOOT_SCRIPT_IO_READ_WRITE) + WidthInByte), DataMask, WidthInByte);
+ CopyMem ((VOID *)Script, (VOID *)&ScriptIoReadWrite, sizeof (EFI_BOOT_SCRIPT_IO_READ_WRITE));
+ CopyMem ((VOID *)(Script + sizeof (EFI_BOOT_SCRIPT_IO_READ_WRITE)), Data, WidthInByte);
+ CopyMem ((VOID *)(Script + sizeof (EFI_BOOT_SCRIPT_IO_READ_WRITE) + WidthInByte), DataMask, WidthInByte);
SyncBootScript (Script);
return RETURN_SUCCESS;
}
+
/**
Adds a record for a memory write operation into a specified boot script table.
@@ -1098,48 +1119,52 @@ S3BootScriptSaveIoReadWrite ( RETURN_STATUS
EFIAPI
S3BootScriptSaveMemWrite (
- IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
- IN UINT64 Address,
- IN UINTN Count,
- IN VOID *Buffer
+ IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
+ IN UINT64 Address,
+ IN UINTN Count,
+ IN VOID *Buffer
)
{
- UINT8 Length;
- UINT8 *Script;
- UINT8 WidthInByte;
+ UINT8 Length;
+ UINT8 *Script;
+ UINT8 WidthInByte;
EFI_BOOT_SCRIPT_MEM_WRITE ScriptMemWrite;
- WidthInByte = (UINT8) (0x01 << (Width & 0x03));
+ WidthInByte = (UINT8)(0x01 << (Width & 0x03));
//
// Truncation check
//
if ((Count > MAX_UINT8) ||
- (WidthInByte * Count > MAX_UINT8 - sizeof (EFI_BOOT_SCRIPT_MEM_WRITE))) {
+ (WidthInByte * Count > MAX_UINT8 - sizeof (EFI_BOOT_SCRIPT_MEM_WRITE)))
+ {
return RETURN_OUT_OF_RESOURCES;
}
+
Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_MEM_WRITE) + (WidthInByte * Count));
Script = S3BootScriptGetEntryAddAddress (Length);
if (Script == NULL) {
return RETURN_OUT_OF_RESOURCES;
}
+
//
// Build script data
//
- ScriptMemWrite.OpCode = EFI_BOOT_SCRIPT_MEM_WRITE_OPCODE;
- ScriptMemWrite.Length = Length;
- ScriptMemWrite.Width = Width;
- ScriptMemWrite.Address = Address;
- ScriptMemWrite.Count = (UINT32) Count;
+ ScriptMemWrite.OpCode = EFI_BOOT_SCRIPT_MEM_WRITE_OPCODE;
+ ScriptMemWrite.Length = Length;
+ ScriptMemWrite.Width = Width;
+ ScriptMemWrite.Address = Address;
+ ScriptMemWrite.Count = (UINT32)Count;
- CopyMem ((VOID*)Script, (VOID*)&ScriptMemWrite, sizeof(EFI_BOOT_SCRIPT_MEM_WRITE));
- CopyMem ((VOID*)(Script + sizeof (EFI_BOOT_SCRIPT_MEM_WRITE)), Buffer, WidthInByte * Count);
+ CopyMem ((VOID *)Script, (VOID *)&ScriptMemWrite, sizeof (EFI_BOOT_SCRIPT_MEM_WRITE));
+ CopyMem ((VOID *)(Script + sizeof (EFI_BOOT_SCRIPT_MEM_WRITE)), Buffer, WidthInByte * Count);
SyncBootScript (Script);
return RETURN_SUCCESS;
}
+
/**
Adds a record for a memory modify operation into a specified boot script table.
@@ -1154,40 +1179,42 @@ S3BootScriptSaveMemWrite ( RETURN_STATUS
EFIAPI
S3BootScriptSaveMemReadWrite (
- IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
- IN UINT64 Address,
- IN VOID *Data,
- IN VOID *DataMask
+ IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
+ IN UINT64 Address,
+ IN VOID *Data,
+ IN VOID *DataMask
)
{
- UINT8 Length;
- UINT8 *Script;
- UINT8 WidthInByte;
+ UINT8 Length;
+ UINT8 *Script;
+ UINT8 WidthInByte;
EFI_BOOT_SCRIPT_MEM_READ_WRITE ScriptMemReadWrite;
- WidthInByte = (UINT8) (0x01 << (Width & 0x03));
- Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_MEM_READ_WRITE) + (WidthInByte * 2));
+ WidthInByte = (UINT8)(0x01 << (Width & 0x03));
+ Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_MEM_READ_WRITE) + (WidthInByte * 2));
Script = S3BootScriptGetEntryAddAddress (Length);
if (Script == NULL) {
return RETURN_OUT_OF_RESOURCES;
}
+
//
// Build script data
//
- ScriptMemReadWrite.OpCode = EFI_BOOT_SCRIPT_MEM_READ_WRITE_OPCODE;
- ScriptMemReadWrite.Length = Length;
- ScriptMemReadWrite.Width = Width;
- ScriptMemReadWrite.Address = Address;
+ ScriptMemReadWrite.OpCode = EFI_BOOT_SCRIPT_MEM_READ_WRITE_OPCODE;
+ ScriptMemReadWrite.Length = Length;
+ ScriptMemReadWrite.Width = Width;
+ ScriptMemReadWrite.Address = Address;
- CopyMem ((VOID*)Script, (VOID*)&ScriptMemReadWrite , sizeof (EFI_BOOT_SCRIPT_MEM_READ_WRITE));
- CopyMem ((VOID*)(Script + sizeof (EFI_BOOT_SCRIPT_MEM_READ_WRITE)), Data, WidthInByte);
- CopyMem ((VOID*)(Script + sizeof (EFI_BOOT_SCRIPT_MEM_READ_WRITE) + WidthInByte), DataMask, WidthInByte);
+ CopyMem ((VOID *)Script, (VOID *)&ScriptMemReadWrite, sizeof (EFI_BOOT_SCRIPT_MEM_READ_WRITE));
+ CopyMem ((VOID *)(Script + sizeof (EFI_BOOT_SCRIPT_MEM_READ_WRITE)), Data, WidthInByte);
+ CopyMem ((VOID *)(Script + sizeof (EFI_BOOT_SCRIPT_MEM_READ_WRITE) + WidthInByte), DataMask, WidthInByte);
SyncBootScript (Script);
return RETURN_SUCCESS;
}
+
/**
Adds a record for a PCI configuration space write operation into a specified boot script table.
@@ -1204,54 +1231,59 @@ S3BootScriptSaveMemReadWrite ( RETURN_STATUS
EFIAPI
S3BootScriptSavePciCfgWrite (
- IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
- IN UINT64 Address,
- IN UINTN Count,
- IN VOID *Buffer
+ IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
+ IN UINT64 Address,
+ IN UINTN Count,
+ IN VOID *Buffer
)
{
- UINT8 Length;
- UINT8 *Script;
- UINT8 WidthInByte;
+ UINT8 Length;
+ UINT8 *Script;
+ UINT8 WidthInByte;
EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE ScriptPciWrite;
- if (Width == S3BootScriptWidthUint64 ||
- Width == S3BootScriptWidthFifoUint64 ||
- Width == S3BootScriptWidthFillUint64) {
+ if ((Width == S3BootScriptWidthUint64) ||
+ (Width == S3BootScriptWidthFifoUint64) ||
+ (Width == S3BootScriptWidthFillUint64))
+ {
return EFI_INVALID_PARAMETER;
}
- WidthInByte = (UINT8) (0x01 << (Width & 0x03));
+ WidthInByte = (UINT8)(0x01 << (Width & 0x03));
//
// Truncation check
//
if ((Count > MAX_UINT8) ||
- (WidthInByte * Count > MAX_UINT8 - sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE))) {
+ (WidthInByte * Count > MAX_UINT8 - sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE)))
+ {
return RETURN_OUT_OF_RESOURCES;
}
+
Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE) + (WidthInByte * Count));
Script = S3BootScriptGetEntryAddAddress (Length);
if (Script == NULL) {
return RETURN_OUT_OF_RESOURCES;
}
+
//
// Build script data
//
- ScriptPciWrite.OpCode = EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE_OPCODE;
- ScriptPciWrite.Length = Length;
- ScriptPciWrite.Width = Width;
- ScriptPciWrite.Address = Address;
- ScriptPciWrite.Count = (UINT32) Count;
+ ScriptPciWrite.OpCode = EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE_OPCODE;
+ ScriptPciWrite.Length = Length;
+ ScriptPciWrite.Width = Width;
+ ScriptPciWrite.Address = Address;
+ ScriptPciWrite.Count = (UINT32)Count;
- CopyMem ((VOID*)Script, (VOID*)&ScriptPciWrite, sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE));
- CopyMem ((VOID*)(Script + sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE)), Buffer, WidthInByte * Count);
+ CopyMem ((VOID *)Script, (VOID *)&ScriptPciWrite, sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE));
+ CopyMem ((VOID *)(Script + sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE)), Buffer, WidthInByte * Count);
SyncBootScript (Script);
return RETURN_SUCCESS;
}
+
/**
Adds a record for a PCI configuration space modify operation into a specified boot script table.
@@ -1268,42 +1300,44 @@ S3BootScriptSavePciCfgWrite ( RETURN_STATUS
EFIAPI
S3BootScriptSavePciCfgReadWrite (
- IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
- IN UINT64 Address,
- IN VOID *Data,
- IN VOID *DataMask
+ IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
+ IN UINT64 Address,
+ IN VOID *Data,
+ IN VOID *DataMask
)
{
- UINT8 Length;
- UINT8 *Script;
- UINT8 WidthInByte;
+ UINT8 Length;
+ UINT8 *Script;
+ UINT8 WidthInByte;
EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE ScriptPciReadWrite;
- if (Width == S3BootScriptWidthUint64 ||
- Width == S3BootScriptWidthFifoUint64 ||
- Width == S3BootScriptWidthFillUint64) {
+ if ((Width == S3BootScriptWidthUint64) ||
+ (Width == S3BootScriptWidthFifoUint64) ||
+ (Width == S3BootScriptWidthFillUint64))
+ {
return EFI_INVALID_PARAMETER;
}
- WidthInByte = (UINT8) (0x01 << (Width & 0x03));
- Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE) + (WidthInByte * 2));
+ WidthInByte = (UINT8)(0x01 << (Width & 0x03));
+ Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE) + (WidthInByte * 2));
Script = S3BootScriptGetEntryAddAddress (Length);
if (Script == NULL) {
return RETURN_OUT_OF_RESOURCES;
}
+
//
// Build script data
//
- ScriptPciReadWrite.OpCode = EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE_OPCODE;
- ScriptPciReadWrite.Length = Length;
- ScriptPciReadWrite.Width = Width;
- ScriptPciReadWrite.Address = Address;
+ ScriptPciReadWrite.OpCode = EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE_OPCODE;
+ ScriptPciReadWrite.Length = Length;
+ ScriptPciReadWrite.Width = Width;
+ ScriptPciReadWrite.Address = Address;
- CopyMem ((VOID*)Script, (VOID*)&ScriptPciReadWrite, sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE));
- CopyMem ((VOID*)(Script + sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE)), Data, WidthInByte);
+ CopyMem ((VOID *)Script, (VOID *)&ScriptPciReadWrite, sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE));
+ CopyMem ((VOID *)(Script + sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE)), Data, WidthInByte);
CopyMem (
- (VOID*)(Script + sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE) + WidthInByte),
+ (VOID *)(Script + sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE) + WidthInByte),
DataMask,
WidthInByte
);
@@ -1312,6 +1346,7 @@ S3BootScriptSavePciCfgReadWrite ( return RETURN_SUCCESS;
}
+
/**
Adds a record for a PCI configuration 2 space write operation into a specified boot script table.
@@ -1329,56 +1364,61 @@ S3BootScriptSavePciCfgReadWrite ( RETURN_STATUS
EFIAPI
S3BootScriptSavePciCfg2Write (
- IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
- IN UINT16 Segment,
- IN UINT64 Address,
- IN UINTN Count,
- IN VOID *Buffer
+ IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
+ IN UINT16 Segment,
+ IN UINT64 Address,
+ IN UINTN Count,
+ IN VOID *Buffer
)
{
- UINT8 Length;
- UINT8 *Script;
- UINT8 WidthInByte;
+ UINT8 Length;
+ UINT8 *Script;
+ UINT8 WidthInByte;
EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE ScriptPciWrite2;
- if (Width == S3BootScriptWidthUint64 ||
- Width == S3BootScriptWidthFifoUint64 ||
- Width == S3BootScriptWidthFillUint64) {
+ if ((Width == S3BootScriptWidthUint64) ||
+ (Width == S3BootScriptWidthFifoUint64) ||
+ (Width == S3BootScriptWidthFillUint64))
+ {
return EFI_INVALID_PARAMETER;
}
- WidthInByte = (UINT8) (0x01 << (Width & 0x03));
+ WidthInByte = (UINT8)(0x01 << (Width & 0x03));
//
// Truncation check
//
if ((Count > MAX_UINT8) ||
- (WidthInByte * Count > MAX_UINT8 - sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE))) {
+ (WidthInByte * Count > MAX_UINT8 - sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE)))
+ {
return RETURN_OUT_OF_RESOURCES;
}
+
Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE) + (WidthInByte * Count));
Script = S3BootScriptGetEntryAddAddress (Length);
if (Script == NULL) {
return RETURN_OUT_OF_RESOURCES;
}
+
//
// Build script data
//
- ScriptPciWrite2.OpCode = EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE_OPCODE;
- ScriptPciWrite2.Length = Length;
- ScriptPciWrite2.Width = Width;
- ScriptPciWrite2.Address = Address;
- ScriptPciWrite2.Segment = Segment;
- ScriptPciWrite2.Count = (UINT32)Count;
+ ScriptPciWrite2.OpCode = EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE_OPCODE;
+ ScriptPciWrite2.Length = Length;
+ ScriptPciWrite2.Width = Width;
+ ScriptPciWrite2.Address = Address;
+ ScriptPciWrite2.Segment = Segment;
+ ScriptPciWrite2.Count = (UINT32)Count;
- CopyMem ((VOID*)Script, (VOID*)&ScriptPciWrite2, sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE));
- CopyMem ((VOID*)(Script + sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE)), Buffer, WidthInByte * Count);
+ CopyMem ((VOID *)Script, (VOID *)&ScriptPciWrite2, sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE));
+ CopyMem ((VOID *)(Script + sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE)), Buffer, WidthInByte * Count);
SyncBootScript (Script);
return RETURN_SUCCESS;
}
+
/**
Adds a record for a PCI configuration 2 space modify operation into a specified boot script table.
@@ -1396,44 +1436,46 @@ S3BootScriptSavePciCfg2Write ( RETURN_STATUS
EFIAPI
S3BootScriptSavePciCfg2ReadWrite (
- IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
- IN UINT16 Segment,
- IN UINT64 Address,
- IN VOID *Data,
- IN VOID *DataMask
+ IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
+ IN UINT16 Segment,
+ IN UINT64 Address,
+ IN VOID *Data,
+ IN VOID *DataMask
)
{
- UINT8 Length;
- UINT8 *Script;
- UINT8 WidthInByte;
+ UINT8 Length;
+ UINT8 *Script;
+ UINT8 WidthInByte;
EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE ScriptPciReadWrite2;
- if (Width == S3BootScriptWidthUint64 ||
- Width == S3BootScriptWidthFifoUint64 ||
- Width == S3BootScriptWidthFillUint64) {
+ if ((Width == S3BootScriptWidthUint64) ||
+ (Width == S3BootScriptWidthFifoUint64) ||
+ (Width == S3BootScriptWidthFillUint64))
+ {
return EFI_INVALID_PARAMETER;
}
- WidthInByte = (UINT8) (0x01 << (Width & 0x03));
- Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE) + (WidthInByte * 2));
+ WidthInByte = (UINT8)(0x01 << (Width & 0x03));
+ Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE) + (WidthInByte * 2));
Script = S3BootScriptGetEntryAddAddress (Length);
if (Script == NULL) {
return RETURN_OUT_OF_RESOURCES;
}
+
//
// Build script data
//
- ScriptPciReadWrite2.OpCode = EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE_OPCODE;
- ScriptPciReadWrite2.Length = Length;
- ScriptPciReadWrite2.Width = Width;
- ScriptPciReadWrite2.Segment = Segment;
- ScriptPciReadWrite2.Address = Address;
+ ScriptPciReadWrite2.OpCode = EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE_OPCODE;
+ ScriptPciReadWrite2.Length = Length;
+ ScriptPciReadWrite2.Width = Width;
+ ScriptPciReadWrite2.Segment = Segment;
+ ScriptPciReadWrite2.Address = Address;
- CopyMem ((VOID*)Script, (VOID*)&ScriptPciReadWrite2, sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE));
- CopyMem ((VOID*)(Script + sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE)), Data, WidthInByte);
+ CopyMem ((VOID *)Script, (VOID *)&ScriptPciReadWrite2, sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE));
+ CopyMem ((VOID *)(Script + sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE)), Data, WidthInByte);
CopyMem (
- (VOID*)(Script + sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE) + WidthInByte),
+ (VOID *)(Script + sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE) + WidthInByte),
DataMask,
WidthInByte
);
@@ -1477,19 +1519,19 @@ S3BootScriptSavePciCfg2ReadWrite ( **/
EFI_STATUS
CheckParameters (
- IN UINTN SmBusAddress,
- IN EFI_SMBUS_OPERATION Operation,
- IN OUT UINTN *Length,
- IN VOID *Buffer
+ IN UINTN SmBusAddress,
+ IN EFI_SMBUS_OPERATION Operation,
+ IN OUT UINTN *Length,
+ IN VOID *Buffer
)
{
- EFI_STATUS Status;
- UINTN RequiredLen;
- EFI_SMBUS_DEVICE_COMMAND Command;
- BOOLEAN PecCheck;
+ EFI_STATUS Status;
+ UINTN RequiredLen;
+ EFI_SMBUS_DEVICE_COMMAND Command;
+ BOOLEAN PecCheck;
- Command = SMBUS_LIB_COMMAND (SmBusAddress);
- PecCheck = SMBUS_LIB_PEC (SmBusAddress);
+ Command = SMBUS_LIB_COMMAND (SmBusAddress);
+ PecCheck = SMBUS_LIB_PEC (SmBusAddress);
//
// Set default value to be 2:
// for SmbusReadWord, SmbusWriteWord and SmbusProcessCall.
@@ -1499,32 +1541,35 @@ CheckParameters ( switch (Operation) {
case EfiSmbusQuickRead:
case EfiSmbusQuickWrite:
- if (PecCheck || Command != 0) {
+ if (PecCheck || (Command != 0)) {
return EFI_UNSUPPORTED;
}
+
break;
case EfiSmbusReceiveByte:
case EfiSmbusSendByte:
if (Command != 0) {
return EFI_UNSUPPORTED;
}
- //
- // Cascade to check length parameter.
- //
+
+ //
+ // Cascade to check length parameter.
+ //
case EfiSmbusReadByte:
case EfiSmbusWriteByte:
RequiredLen = 1;
- //
- // Cascade to check length parameter.
- //
+ //
+ // Cascade to check length parameter.
+ //
case EfiSmbusReadWord:
case EfiSmbusWriteWord:
case EfiSmbusProcessCall:
- if (Buffer == NULL || Length == NULL) {
+ if ((Buffer == NULL) || (Length == NULL)) {
return EFI_INVALID_PARAMETER;
} else if (*Length < RequiredLen) {
Status = EFI_BUFFER_TOO_SMALL;
}
+
*Length = RequiredLen;
break;
case EfiSmbusReadBlock:
@@ -1533,13 +1578,16 @@ CheckParameters ( if ((Buffer == NULL) ||
(Length == NULL) ||
(*Length < MIN_SMBUS_BLOCK_LEN) ||
- (*Length > MAX_SMBUS_BLOCK_LEN)) {
+ (*Length > MAX_SMBUS_BLOCK_LEN))
+ {
return EFI_INVALID_PARAMETER;
}
+
break;
default:
return EFI_INVALID_PARAMETER;
}
+
return Status;
}
@@ -1558,16 +1606,16 @@ CheckParameters ( RETURN_STATUS
EFIAPI
S3BootScriptSaveSmbusExecute (
- IN UINTN SmBusAddress,
- IN EFI_SMBUS_OPERATION Operation,
- IN UINTN *Length,
- IN VOID *Buffer
+ IN UINTN SmBusAddress,
+ IN EFI_SMBUS_OPERATION Operation,
+ IN UINTN *Length,
+ IN VOID *Buffer
)
{
- EFI_STATUS Status;
- UINTN BufferLength;
- UINT8 DataSize;
- UINT8 *Script;
+ EFI_STATUS Status;
+ UINTN BufferLength;
+ UINT8 DataSize;
+ UINT8 *Script;
EFI_BOOT_SCRIPT_SMBUS_EXECUTE ScriptSmbusExecute;
if (Length == NULL) {
@@ -1587,24 +1635,26 @@ S3BootScriptSaveSmbusExecute ( if (BufferLength > MAX_UINT8 - sizeof (EFI_BOOT_SCRIPT_SMBUS_EXECUTE)) {
return RETURN_OUT_OF_RESOURCES;
}
+
DataSize = (UINT8)(sizeof (EFI_BOOT_SCRIPT_SMBUS_EXECUTE) + BufferLength);
Script = S3BootScriptGetEntryAddAddress (DataSize);
if (Script == NULL) {
return RETURN_OUT_OF_RESOURCES;
}
+
//
// Build script data
//
ScriptSmbusExecute.OpCode = EFI_BOOT_SCRIPT_SMBUS_EXECUTE_OPCODE;
ScriptSmbusExecute.Length = DataSize;
- ScriptSmbusExecute.SmBusAddress = (UINT64) SmBusAddress;
+ ScriptSmbusExecute.SmBusAddress = (UINT64)SmBusAddress;
ScriptSmbusExecute.Operation = Operation;
- ScriptSmbusExecute.DataSize = (UINT32) BufferLength;
+ ScriptSmbusExecute.DataSize = (UINT32)BufferLength;
- CopyMem ((VOID*)Script, (VOID*)&ScriptSmbusExecute, sizeof (EFI_BOOT_SCRIPT_SMBUS_EXECUTE));
+ CopyMem ((VOID *)Script, (VOID *)&ScriptSmbusExecute, sizeof (EFI_BOOT_SCRIPT_SMBUS_EXECUTE));
CopyMem (
- (VOID*)(Script + sizeof (EFI_BOOT_SCRIPT_SMBUS_EXECUTE)),
+ (VOID *)(Script + sizeof (EFI_BOOT_SCRIPT_SMBUS_EXECUTE)),
Buffer,
BufferLength
);
@@ -1613,6 +1663,7 @@ S3BootScriptSaveSmbusExecute ( return RETURN_SUCCESS;
}
+
/**
Adds a record for an execution stall on the processor into a specified boot script table.
@@ -1624,11 +1675,11 @@ S3BootScriptSaveSmbusExecute ( RETURN_STATUS
EFIAPI
S3BootScriptSaveStall (
- IN UINTN Duration
+ IN UINTN Duration
)
{
- UINT8 Length;
- UINT8 *Script;
+ UINT8 Length;
+ UINT8 *Script;
EFI_BOOT_SCRIPT_STALL ScriptStall;
Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_STALL));
@@ -1637,19 +1688,21 @@ S3BootScriptSaveStall ( if (Script == NULL) {
return RETURN_OUT_OF_RESOURCES;
}
+
//
// Build script data
//
- ScriptStall.OpCode = EFI_BOOT_SCRIPT_STALL_OPCODE;
- ScriptStall.Length = Length;
- ScriptStall.Duration = Duration;
+ ScriptStall.OpCode = EFI_BOOT_SCRIPT_STALL_OPCODE;
+ ScriptStall.Length = Length;
+ ScriptStall.Duration = Duration;
- CopyMem ((VOID*)Script, (VOID*)&ScriptStall, sizeof (EFI_BOOT_SCRIPT_STALL));
+ CopyMem ((VOID *)Script, (VOID *)&ScriptStall, sizeof (EFI_BOOT_SCRIPT_STALL));
SyncBootScript (Script);
return RETURN_SUCCESS;
}
+
/**
Adds a record for dispatching specified arbitrary code into a specified boot script table.
@@ -1662,34 +1715,36 @@ S3BootScriptSaveStall ( RETURN_STATUS
EFIAPI
S3BootScriptSaveDispatch2 (
- IN VOID *EntryPoint,
- IN VOID *Context
+ IN VOID *EntryPoint,
+ IN VOID *Context
)
{
- UINT8 Length;
- UINT8 *Script;
+ UINT8 Length;
+ UINT8 *Script;
EFI_BOOT_SCRIPT_DISPATCH_2 ScriptDispatch2;
+
Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_DISPATCH_2));
Script = S3BootScriptGetEntryAddAddress (Length);
if (Script == NULL) {
return RETURN_OUT_OF_RESOURCES;
}
+
//
// Build script data
//
ScriptDispatch2.OpCode = EFI_BOOT_SCRIPT_DISPATCH_2_OPCODE;
ScriptDispatch2.Length = Length;
ScriptDispatch2.EntryPoint = (EFI_PHYSICAL_ADDRESS)(UINTN)EntryPoint;
- ScriptDispatch2.Context = (EFI_PHYSICAL_ADDRESS)(UINTN)Context;
+ ScriptDispatch2.Context = (EFI_PHYSICAL_ADDRESS)(UINTN)Context;
- CopyMem ((VOID*)Script, (VOID*)&ScriptDispatch2, sizeof (EFI_BOOT_SCRIPT_DISPATCH_2));
+ CopyMem ((VOID *)Script, (VOID *)&ScriptDispatch2, sizeof (EFI_BOOT_SCRIPT_DISPATCH_2));
SyncBootScript (Script);
return RETURN_SUCCESS;
-
}
+
/**
Adds a record for memory reads of the memory location and continues when the exit criteria is
satisfied or after a defined duration.
@@ -1713,20 +1768,20 @@ S3BootScriptSaveDispatch2 ( RETURN_STATUS
EFIAPI
S3BootScriptSaveMemPoll (
- IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
- IN UINT64 Address,
- IN VOID *BitMask,
- IN VOID *BitValue,
- IN UINTN Duration,
- IN UINT64 LoopTimes
+ IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
+ IN UINT64 Address,
+ IN VOID *BitMask,
+ IN VOID *BitValue,
+ IN UINTN Duration,
+ IN UINT64 LoopTimes
)
{
- UINT8 Length;
- UINT8 *Script;
- UINT8 WidthInByte;
- EFI_BOOT_SCRIPT_MEM_POLL ScriptMemPoll;
+ UINT8 Length;
+ UINT8 *Script;
+ UINT8 WidthInByte;
+ EFI_BOOT_SCRIPT_MEM_POLL ScriptMemPoll;
- WidthInByte = (UINT8) (0x01 << (Width & 0x03));
+ WidthInByte = (UINT8)(0x01 << (Width & 0x03));
Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_MEM_POLL) + (WidthInByte * 2));
@@ -1734,24 +1789,26 @@ S3BootScriptSaveMemPoll ( if (Script == NULL) {
return RETURN_OUT_OF_RESOURCES;
}
+
//
// Build script data
//
- ScriptMemPoll.OpCode = EFI_BOOT_SCRIPT_MEM_POLL_OPCODE;
- ScriptMemPoll.Length = Length;
- ScriptMemPoll.Width = Width;
- ScriptMemPoll.Address = Address;
- ScriptMemPoll.Duration = Duration;
+ ScriptMemPoll.OpCode = EFI_BOOT_SCRIPT_MEM_POLL_OPCODE;
+ ScriptMemPoll.Length = Length;
+ ScriptMemPoll.Width = Width;
+ ScriptMemPoll.Address = Address;
+ ScriptMemPoll.Duration = Duration;
ScriptMemPoll.LoopTimes = LoopTimes;
- CopyMem ((UINT8 *) (Script + sizeof (EFI_BOOT_SCRIPT_MEM_POLL)), BitValue, WidthInByte);
- CopyMem ((UINT8 *) (Script + sizeof (EFI_BOOT_SCRIPT_MEM_POLL) + WidthInByte), BitMask, WidthInByte);
- CopyMem ((VOID*)Script, (VOID*)&ScriptMemPoll, sizeof (EFI_BOOT_SCRIPT_MEM_POLL));
+ CopyMem ((UINT8 *)(Script + sizeof (EFI_BOOT_SCRIPT_MEM_POLL)), BitValue, WidthInByte);
+ CopyMem ((UINT8 *)(Script + sizeof (EFI_BOOT_SCRIPT_MEM_POLL) + WidthInByte), BitMask, WidthInByte);
+ CopyMem ((VOID *)Script, (VOID *)&ScriptMemPoll, sizeof (EFI_BOOT_SCRIPT_MEM_POLL));
SyncBootScript (Script);
return RETURN_SUCCESS;
}
+
/**
Store arbitrary information in the boot script table. This opcode is a no-op on dispatch and is only
used for debugging script issues.
@@ -1766,12 +1823,12 @@ S3BootScriptSaveMemPoll ( RETURN_STATUS
EFIAPI
S3BootScriptSaveInformation (
- IN UINT32 InformationLength,
- IN VOID *Information
+ IN UINT32 InformationLength,
+ IN VOID *Information
)
{
- UINT8 Length;
- UINT8 *Script;
+ UINT8 Length;
+ UINT8 *Script;
EFI_BOOT_SCRIPT_INFORMATION ScriptInformation;
//
@@ -1780,29 +1837,30 @@ S3BootScriptSaveInformation ( if (InformationLength > MAX_UINT8 - sizeof (EFI_BOOT_SCRIPT_INFORMATION)) {
return RETURN_OUT_OF_RESOURCES;
}
+
Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_INFORMATION) + InformationLength);
Script = S3BootScriptGetEntryAddAddress (Length);
if (Script == NULL) {
return RETURN_OUT_OF_RESOURCES;
}
+
//
// Build script data
//
- ScriptInformation.OpCode = EFI_BOOT_SCRIPT_INFORMATION_OPCODE;
- ScriptInformation.Length = Length;
-
+ ScriptInformation.OpCode = EFI_BOOT_SCRIPT_INFORMATION_OPCODE;
+ ScriptInformation.Length = Length;
ScriptInformation.InformationLength = InformationLength;
- CopyMem ((VOID*)Script, (VOID*)&ScriptInformation, sizeof (EFI_BOOT_SCRIPT_INFORMATION));
- CopyMem ((VOID*)(Script + sizeof (EFI_BOOT_SCRIPT_INFORMATION)), (VOID *) Information, (UINTN) InformationLength);
+ CopyMem ((VOID *)Script, (VOID *)&ScriptInformation, sizeof (EFI_BOOT_SCRIPT_INFORMATION));
+ CopyMem ((VOID *)(Script + sizeof (EFI_BOOT_SCRIPT_INFORMATION)), (VOID *)Information, (UINTN)InformationLength);
SyncBootScript (Script);
return RETURN_SUCCESS;
-
}
+
/**
Store a string in the boot script table. This opcode is a no-op on dispatch and is only
used for debugging script issues.
@@ -1816,14 +1874,15 @@ S3BootScriptSaveInformation ( RETURN_STATUS
EFIAPI
S3BootScriptSaveInformationAsciiString (
- IN CONST CHAR8 *String
+ IN CONST CHAR8 *String
)
{
return S3BootScriptSaveInformation (
- (UINT32) AsciiStrLen (String) + 1,
- (VOID*) String
+ (UINT32)AsciiStrLen (String) + 1,
+ (VOID *)String
);
}
+
/**
Adds a record for dispatching specified arbitrary code into a specified boot script table.
@@ -1835,11 +1894,11 @@ S3BootScriptSaveInformationAsciiString ( RETURN_STATUS
EFIAPI
S3BootScriptSaveDispatch (
- IN VOID *EntryPoint
+ IN VOID *EntryPoint
)
{
- UINT8 Length;
- UINT8 *Script;
+ UINT8 Length;
+ UINT8 *Script;
EFI_BOOT_SCRIPT_DISPATCH ScriptDispatch;
Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_DISPATCH));
@@ -1848,6 +1907,7 @@ S3BootScriptSaveDispatch ( if (Script == NULL) {
return RETURN_OUT_OF_RESOURCES;
}
+
//
// Build script data
//
@@ -1855,13 +1915,13 @@ S3BootScriptSaveDispatch ( ScriptDispatch.Length = Length;
ScriptDispatch.EntryPoint = (EFI_PHYSICAL_ADDRESS)(UINTN)EntryPoint;
- CopyMem ((VOID*)Script, (VOID*)&ScriptDispatch, sizeof (EFI_BOOT_SCRIPT_DISPATCH));
+ CopyMem ((VOID *)Script, (VOID *)&ScriptDispatch, sizeof (EFI_BOOT_SCRIPT_DISPATCH));
SyncBootScript (Script);
return RETURN_SUCCESS;
-
}
+
/**
Adds a record for I/O reads the I/O location and continues when the exit criteria is satisfied or after a
defined duration.
@@ -1881,38 +1941,38 @@ S3BootScriptSaveDispatch ( RETURN_STATUS
EFIAPI
S3BootScriptSaveIoPoll (
- IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
- IN UINT64 Address,
+ IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
+ IN UINT64 Address,
IN VOID *Data,
IN VOID *DataMask,
- IN UINT64 Delay
+ IN UINT64 Delay
)
{
- UINT8 WidthInByte;
- UINT8 *Script;
- UINT8 Length;
+ UINT8 WidthInByte;
+ UINT8 *Script;
+ UINT8 Length;
EFI_BOOT_SCRIPT_IO_POLL ScriptIoPoll;
-
- WidthInByte = (UINT8) (0x01 << (Width & 0x03));
- Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_IO_POLL) + (WidthInByte * 2));
+ WidthInByte = (UINT8)(0x01 << (Width & 0x03));
+ Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_IO_POLL) + (WidthInByte * 2));
Script = S3BootScriptGetEntryAddAddress (Length);
if (Script == NULL) {
return RETURN_OUT_OF_RESOURCES;
}
+
//
// Build script data
//
- ScriptIoPoll.OpCode = EFI_BOOT_SCRIPT_IO_POLL_OPCODE;
- ScriptIoPoll.Length = (UINT8) (sizeof (EFI_BOOT_SCRIPT_IO_POLL) + (WidthInByte * 2));
- ScriptIoPoll.Width = Width;
- ScriptIoPoll.Address = Address;
- ScriptIoPoll.Delay = Delay;
+ ScriptIoPoll.OpCode = EFI_BOOT_SCRIPT_IO_POLL_OPCODE;
+ ScriptIoPoll.Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_IO_POLL) + (WidthInByte * 2));
+ ScriptIoPoll.Width = Width;
+ ScriptIoPoll.Address = Address;
+ ScriptIoPoll.Delay = Delay;
- CopyMem ((VOID*)Script, (VOID*)&ScriptIoPoll, sizeof (EFI_BOOT_SCRIPT_IO_POLL));
- CopyMem ((UINT8 *) (Script + sizeof (EFI_BOOT_SCRIPT_IO_POLL)), Data, WidthInByte);
- CopyMem ((UINT8 *) (Script + sizeof (EFI_BOOT_SCRIPT_IO_POLL) + WidthInByte), DataMask, WidthInByte);
+ CopyMem ((VOID *)Script, (VOID *)&ScriptIoPoll, sizeof (EFI_BOOT_SCRIPT_IO_POLL));
+ CopyMem ((UINT8 *)(Script + sizeof (EFI_BOOT_SCRIPT_IO_POLL)), Data, WidthInByte);
+ CopyMem ((UINT8 *)(Script + sizeof (EFI_BOOT_SCRIPT_IO_POLL) + WidthInByte), DataMask, WidthInByte);
SyncBootScript (Script);
@@ -1939,48 +1999,51 @@ S3BootScriptSaveIoPoll ( RETURN_STATUS
EFIAPI
S3BootScriptSavePciPoll (
- IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
- IN UINT64 Address,
- IN VOID *Data,
- IN VOID *DataMask,
- IN UINT64 Delay
-)
+ IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
+ IN UINT64 Address,
+ IN VOID *Data,
+ IN VOID *DataMask,
+ IN UINT64 Delay
+ )
{
- UINT8 *Script;
- UINT8 WidthInByte;
- UINT8 Length;
+ UINT8 *Script;
+ UINT8 WidthInByte;
+ UINT8 Length;
EFI_BOOT_SCRIPT_PCI_CONFIG_POLL ScriptPciPoll;
- if (Width == S3BootScriptWidthUint64 ||
- Width == S3BootScriptWidthFifoUint64 ||
- Width == S3BootScriptWidthFillUint64) {
+ if ((Width == S3BootScriptWidthUint64) ||
+ (Width == S3BootScriptWidthFifoUint64) ||
+ (Width == S3BootScriptWidthFillUint64))
+ {
return EFI_INVALID_PARAMETER;
}
- WidthInByte = (UINT8) (0x01 << (Width & 0x03));
- Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_POLL) + (WidthInByte * 2));
+ WidthInByte = (UINT8)(0x01 << (Width & 0x03));
+ Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_POLL) + (WidthInByte * 2));
Script = S3BootScriptGetEntryAddAddress (Length);
if (Script == NULL) {
return RETURN_OUT_OF_RESOURCES;
}
+
//
// Build script data
//
- ScriptPciPoll.OpCode = EFI_BOOT_SCRIPT_PCI_CONFIG_POLL_OPCODE;
- ScriptPciPoll.Length = (UINT8) (sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_POLL) + (WidthInByte * 2));
- ScriptPciPoll.Width = Width;
- ScriptPciPoll.Address = Address;
- ScriptPciPoll.Delay = Delay;
+ ScriptPciPoll.OpCode = EFI_BOOT_SCRIPT_PCI_CONFIG_POLL_OPCODE;
+ ScriptPciPoll.Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_POLL) + (WidthInByte * 2));
+ ScriptPciPoll.Width = Width;
+ ScriptPciPoll.Address = Address;
+ ScriptPciPoll.Delay = Delay;
- CopyMem ((VOID*)Script, (VOID*)&ScriptPciPoll, sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_POLL));
- CopyMem ((UINT8 *) (Script + sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_POLL)), Data, WidthInByte);
- CopyMem ((UINT8 *) (Script + sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_POLL) + WidthInByte), DataMask, WidthInByte);
+ CopyMem ((VOID *)Script, (VOID *)&ScriptPciPoll, sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_POLL));
+ CopyMem ((UINT8 *)(Script + sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_POLL)), Data, WidthInByte);
+ CopyMem ((UINT8 *)(Script + sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_POLL) + WidthInByte), DataMask, WidthInByte);
SyncBootScript (Script);
return RETURN_SUCCESS;
}
+
/**
Adds a record for PCI configuration space reads and continues when the exit criteria is satisfied or
after a defined duration.
@@ -2002,50 +2065,53 @@ S3BootScriptSavePciPoll ( RETURN_STATUS
EFIAPI
S3BootScriptSavePci2Poll (
- IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
- IN UINT16 Segment,
- IN UINT64 Address,
- IN VOID *Data,
- IN VOID *DataMask,
- IN UINT64 Delay
-)
+ IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
+ IN UINT16 Segment,
+ IN UINT64 Address,
+ IN VOID *Data,
+ IN VOID *DataMask,
+ IN UINT64 Delay
+ )
{
- UINT8 WidthInByte;
- UINT8 *Script;
- UINT8 Length;
+ UINT8 WidthInByte;
+ UINT8 *Script;
+ UINT8 Length;
EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL ScriptPci2Poll;
- if (Width == S3BootScriptWidthUint64 ||
- Width == S3BootScriptWidthFifoUint64 ||
- Width == S3BootScriptWidthFillUint64) {
+ if ((Width == S3BootScriptWidthUint64) ||
+ (Width == S3BootScriptWidthFifoUint64) ||
+ (Width == S3BootScriptWidthFillUint64))
+ {
return EFI_INVALID_PARAMETER;
}
- WidthInByte = (UINT8) (0x01 << (Width & 0x03));
- Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL) + (WidthInByte * 2));
+ WidthInByte = (UINT8)(0x01 << (Width & 0x03));
+ Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL) + (WidthInByte * 2));
Script = S3BootScriptGetEntryAddAddress (Length);
if (Script == NULL) {
return RETURN_OUT_OF_RESOURCES;
}
+
//
// Build script data
//
- ScriptPci2Poll.OpCode = EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL_OPCODE;
- ScriptPci2Poll.Length = (UINT8) (sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL) + (WidthInByte * 2));
- ScriptPci2Poll.Width = Width;
- ScriptPci2Poll.Segment = Segment;
- ScriptPci2Poll.Address = Address;
- ScriptPci2Poll.Delay = Delay;
+ ScriptPci2Poll.OpCode = EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL_OPCODE;
+ ScriptPci2Poll.Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL) + (WidthInByte * 2));
+ ScriptPci2Poll.Width = Width;
+ ScriptPci2Poll.Segment = Segment;
+ ScriptPci2Poll.Address = Address;
+ ScriptPci2Poll.Delay = Delay;
- CopyMem ((VOID*)Script, (VOID*)&ScriptPci2Poll, sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL));
- CopyMem ((UINT8 *) (Script + sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL)), Data, WidthInByte);
- CopyMem ((UINT8 *) (Script + sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL) + WidthInByte), DataMask, WidthInByte);
+ CopyMem ((VOID *)Script, (VOID *)&ScriptPci2Poll, sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL));
+ CopyMem ((UINT8 *)(Script + sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL)), Data, WidthInByte);
+ CopyMem ((UINT8 *)(Script + sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL) + WidthInByte), DataMask, WidthInByte);
SyncBootScript (Script);
return RETURN_SUCCESS;
}
+
/**
Do the calculation of start address from which a new s3 boot script entry will write into.
@@ -2058,59 +2124,61 @@ S3BootScriptSavePci2Poll ( **/
VOID
S3BootScriptCalculateInsertAddress (
- IN UINT8 EntryLength,
+ IN UINT8 EntryLength,
IN VOID *Position OPTIONAL,
- IN BOOLEAN BeforeOrAfter OPTIONAL,
- OUT UINT8 **Script
+ IN BOOLEAN BeforeOrAfter OPTIONAL,
+ OUT UINT8 **Script
)
{
- UINTN TableLength;
- UINT8 *S3TableBase;
- UINTN PositionOffset;
- EFI_BOOT_SCRIPT_COMMON_HEADER ScriptHeader;
- //
- // The entry inserting to table is already added to the end of the table
- //
- TableLength = mS3BootScriptTablePtr->TableLength - EntryLength;
- S3TableBase = mS3BootScriptTablePtr->TableBase ;
- //
- // calculate the Position offset
- //
- if (Position != NULL) {
- PositionOffset = (UINTN)Position - (UINTN)S3TableBase;
-
- //
- // If the BeforeOrAfter is FALSE, that means to insert the node right after the node.
- //
- if (!BeforeOrAfter) {
- CopyMem ((VOID*)&ScriptHeader, Position, sizeof(EFI_BOOT_SCRIPT_COMMON_HEADER));
- PositionOffset += (ScriptHeader.Length);
- }
- //
- // Insert the node before the adjusted Position
- //
- CopyMem (S3TableBase+PositionOffset+EntryLength, S3TableBase+PositionOffset, TableLength - PositionOffset);
- //
- // calculate the the start address for the new entry.
- //
- *Script = S3TableBase + PositionOffset;
-
- } else {
- if (!BeforeOrAfter) {
- //
- // Insert the node to the end of the table
- //
- *Script = S3TableBase + TableLength;
- } else {
- //
- // Insert the node to the beginning of the table
- //
- PositionOffset = (UINTN) sizeof(EFI_BOOT_SCRIPT_TABLE_HEADER);
- CopyMem (S3TableBase+PositionOffset+EntryLength, S3TableBase+PositionOffset, TableLength - PositionOffset);
- *Script = S3TableBase + PositionOffset;
- }
- }
+ UINTN TableLength;
+ UINT8 *S3TableBase;
+ UINTN PositionOffset;
+ EFI_BOOT_SCRIPT_COMMON_HEADER ScriptHeader;
+
+ //
+ // The entry inserting to table is already added to the end of the table
+ //
+ TableLength = mS3BootScriptTablePtr->TableLength - EntryLength;
+ S3TableBase = mS3BootScriptTablePtr->TableBase;
+ //
+ // calculate the Position offset
+ //
+ if (Position != NULL) {
+ PositionOffset = (UINTN)Position - (UINTN)S3TableBase;
+
+ //
+ // If the BeforeOrAfter is FALSE, that means to insert the node right after the node.
+ //
+ if (!BeforeOrAfter) {
+ CopyMem ((VOID *)&ScriptHeader, Position, sizeof (EFI_BOOT_SCRIPT_COMMON_HEADER));
+ PositionOffset += (ScriptHeader.Length);
+ }
+
+ //
+ // Insert the node before the adjusted Position
+ //
+ CopyMem (S3TableBase+PositionOffset+EntryLength, S3TableBase+PositionOffset, TableLength - PositionOffset);
+ //
+ // calculate the the start address for the new entry.
+ //
+ *Script = S3TableBase + PositionOffset;
+ } else {
+ if (!BeforeOrAfter) {
+ //
+ // Insert the node to the end of the table
+ //
+ *Script = S3TableBase + TableLength;
+ } else {
+ //
+ // Insert the node to the beginning of the table
+ //
+ PositionOffset = (UINTN)sizeof (EFI_BOOT_SCRIPT_TABLE_HEADER);
+ CopyMem (S3TableBase+PositionOffset+EntryLength, S3TableBase+PositionOffset, TableLength - PositionOffset);
+ *Script = S3TableBase + PositionOffset;
+ }
+ }
}
+
/**
Move the last boot script entry to the position
@@ -2129,21 +2197,21 @@ S3BootScriptCalculateInsertAddress ( RETURN_STATUS
EFIAPI
S3BootScriptMoveLastOpcode (
- IN BOOLEAN BeforeOrAfter,
- IN OUT VOID **Position OPTIONAL
-)
+ IN BOOLEAN BeforeOrAfter,
+ IN OUT VOID **Position OPTIONAL
+ )
{
- UINT8* Script;
- VOID *TempPosition;
- UINTN StartAddress;
- UINT32 TableLength;
+ UINT8 *Script;
+ VOID *TempPosition;
+ UINTN StartAddress;
+ UINT32 TableLength;
EFI_BOOT_SCRIPT_COMMON_HEADER ScriptHeader;
- BOOLEAN ValidatePosition;
- UINT8* LastOpcode;
- UINT8 TempBootScriptEntry[BOOT_SCRIPT_NODE_MAX_LENGTH];
+ BOOLEAN ValidatePosition;
+ UINT8 *LastOpcode;
+ UINT8 TempBootScriptEntry[BOOT_SCRIPT_NODE_MAX_LENGTH];
ValidatePosition = FALSE;
- TempPosition = (Position == NULL) ? NULL:(*Position);
+ TempPosition = (Position == NULL) ? NULL : (*Position);
//
// Check that the script is initialized and synced without adding an entry to the script.
@@ -2152,38 +2220,42 @@ S3BootScriptMoveLastOpcode ( if (Script == NULL) {
return RETURN_OUT_OF_RESOURCES;
}
+
Script = mS3BootScriptTablePtr->TableBase;
- StartAddress = (UINTN) Script;
- TableLength = mS3BootScriptTablePtr->TableLength;
- Script = Script + sizeof(EFI_BOOT_SCRIPT_TABLE_HEADER);
- LastOpcode = Script;
+ StartAddress = (UINTN)Script;
+ TableLength = mS3BootScriptTablePtr->TableLength;
+ Script = Script + sizeof (EFI_BOOT_SCRIPT_TABLE_HEADER);
+ LastOpcode = Script;
//
// Find the last boot Script Entry which is not the terminate node
//
- while ((UINTN) Script < (UINTN) (StartAddress + TableLength)) {
- CopyMem ((VOID*)&ScriptHeader, Script, sizeof(EFI_BOOT_SCRIPT_COMMON_HEADER));
- if (TempPosition != NULL && TempPosition == Script) {
+ while ((UINTN)Script < (UINTN)(StartAddress + TableLength)) {
+ CopyMem ((VOID *)&ScriptHeader, Script, sizeof (EFI_BOOT_SCRIPT_COMMON_HEADER));
+ if ((TempPosition != NULL) && (TempPosition == Script)) {
//
// If the position is specified, the position must be pointed to a boot script entry start address.
//
ValidatePosition = TRUE;
}
+
if (ScriptHeader.OpCode != S3_BOOT_SCRIPT_LIB_TERMINATE_OPCODE) {
LastOpcode = Script;
}
- Script = Script + ScriptHeader.Length;
+
+ Script = Script + ScriptHeader.Length;
}
+
//
// If the position is specified, but not the start of a boot script entry, it is a invalid input
//
- if (TempPosition != NULL && !ValidatePosition) {
+ if ((TempPosition != NULL) && !ValidatePosition) {
return RETURN_INVALID_PARAMETER;
}
- CopyMem ((VOID*)&ScriptHeader, LastOpcode, sizeof(EFI_BOOT_SCRIPT_COMMON_HEADER));
+ CopyMem ((VOID *)&ScriptHeader, LastOpcode, sizeof (EFI_BOOT_SCRIPT_COMMON_HEADER));
- CopyMem((VOID*)TempBootScriptEntry, LastOpcode, ScriptHeader.Length);
+ CopyMem ((VOID *)TempBootScriptEntry, LastOpcode, ScriptHeader.Length);
//
// Find the right position to write the node in
//
@@ -2192,11 +2264,11 @@ S3BootScriptMoveLastOpcode ( TempPosition,
BeforeOrAfter,
&Script
- );
+ );
//
// Copy the node to Boot script table
//
- CopyMem((VOID*)Script, (VOID*)TempBootScriptEntry, ScriptHeader.Length);
+ CopyMem ((VOID *)Script, (VOID *)TempBootScriptEntry, ScriptHeader.Length);
SyncBootScript (Script);
@@ -2206,8 +2278,10 @@ S3BootScriptMoveLastOpcode ( if (Position != NULL) {
*Position = Script;
}
+
return RETURN_SUCCESS;
}
+
/**
Create a Label node in the boot script table.
@@ -2229,14 +2303,14 @@ S3BootScriptMoveLastOpcode ( RETURN_STATUS
EFIAPI
S3BootScriptLabelInternal (
- IN BOOLEAN BeforeOrAfter,
- IN OUT VOID **Position OPTIONAL,
- IN UINT32 InformationLength,
- IN CONST CHAR8 *Information
+ IN BOOLEAN BeforeOrAfter,
+ IN OUT VOID **Position OPTIONAL,
+ IN UINT32 InformationLength,
+ IN CONST CHAR8 *Information
)
{
- UINT8 Length;
- UINT8 *Script;
+ UINT8 Length;
+ UINT8 *Script;
EFI_BOOT_SCRIPT_INFORMATION ScriptInformation;
//
@@ -2245,29 +2319,30 @@ S3BootScriptLabelInternal ( if (InformationLength > MAX_UINT8 - sizeof (EFI_BOOT_SCRIPT_INFORMATION)) {
return RETURN_OUT_OF_RESOURCES;
}
+
Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_INFORMATION) + InformationLength);
Script = S3BootScriptGetEntryAddAddress (Length);
if (Script == NULL) {
return RETURN_OUT_OF_RESOURCES;
}
+
//
// Build script data
//
- ScriptInformation.OpCode = S3_BOOT_SCRIPT_LIB_LABEL_OPCODE;
- ScriptInformation.Length = Length;
-
+ ScriptInformation.OpCode = S3_BOOT_SCRIPT_LIB_LABEL_OPCODE;
+ ScriptInformation.Length = Length;
ScriptInformation.InformationLength = InformationLength;
- CopyMem ((VOID*)Script, (VOID*)&ScriptInformation, sizeof (EFI_BOOT_SCRIPT_INFORMATION));
- CopyMem ((VOID*)(Script + sizeof (EFI_BOOT_SCRIPT_INFORMATION)), (VOID *) Information, (UINTN) InformationLength);
+ CopyMem ((VOID *)Script, (VOID *)&ScriptInformation, sizeof (EFI_BOOT_SCRIPT_INFORMATION));
+ CopyMem ((VOID *)(Script + sizeof (EFI_BOOT_SCRIPT_INFORMATION)), (VOID *)Information, (UINTN)InformationLength);
SyncBootScript (Script);
return S3BootScriptMoveLastOpcode (BeforeOrAfter, Position);
-
}
+
/**
Find a label within the boot script table and, if not present, optionally create it.
@@ -2293,24 +2368,26 @@ S3BootScriptLabelInternal ( RETURN_STATUS
EFIAPI
S3BootScriptLabel (
- IN BOOLEAN BeforeOrAfter,
- IN BOOLEAN CreateIfNotFound,
- IN OUT VOID **Position OPTIONAL,
- IN CONST CHAR8 *Label
+ IN BOOLEAN BeforeOrAfter,
+ IN BOOLEAN CreateIfNotFound,
+ IN OUT VOID **Position OPTIONAL,
+ IN CONST CHAR8 *Label
)
{
- UINT8* Script;
- UINTN StartAddress;
- UINT32 TableLength;
+ UINT8 *Script;
+ UINTN StartAddress;
+ UINT32 TableLength;
EFI_BOOT_SCRIPT_COMMON_HEADER ScriptHeader;
EFI_BOOT_SCRIPT_TABLE_HEADER TableHeader;
UINT32 LabelLength;
+
//
// Check NULL Label
//
if (Label == NULL) {
return EFI_INVALID_PARAMETER;
}
+
//
// Check empty Label
//
@@ -2332,27 +2409,29 @@ S3BootScriptLabel ( // Check the header and search for existing label.
//
Script = mS3BootScriptTablePtr->TableBase;
- CopyMem ((VOID*)&TableHeader, Script, sizeof(EFI_BOOT_SCRIPT_TABLE_HEADER));
+ CopyMem ((VOID *)&TableHeader, Script, sizeof (EFI_BOOT_SCRIPT_TABLE_HEADER));
if (TableHeader.OpCode != S3_BOOT_SCRIPT_LIB_TABLE_OPCODE) {
return EFI_INVALID_PARAMETER;
}
- StartAddress = (UINTN) Script;
- TableLength = mS3BootScriptTablePtr->TableLength;
- Script = Script + TableHeader.Length;
- while ((UINTN) Script < (UINTN) (StartAddress + TableLength)) {
- CopyMem ((VOID*)&ScriptHeader, Script, sizeof(EFI_BOOT_SCRIPT_COMMON_HEADER));
+ StartAddress = (UINTN)Script;
+ TableLength = mS3BootScriptTablePtr->TableLength;
+ Script = Script + TableHeader.Length;
+ while ((UINTN)Script < (UINTN)(StartAddress + TableLength)) {
+ CopyMem ((VOID *)&ScriptHeader, Script, sizeof (EFI_BOOT_SCRIPT_COMMON_HEADER));
if (ScriptHeader.OpCode == S3_BOOT_SCRIPT_LIB_LABEL_OPCODE) {
- if (AsciiStrCmp ((CHAR8 *)(UINTN)(Script+sizeof(EFI_BOOT_SCRIPT_INFORMATION)), Label) == 0) {
+ if (AsciiStrCmp ((CHAR8 *)(UINTN)(Script+sizeof (EFI_BOOT_SCRIPT_INFORMATION)), Label) == 0) {
(*Position) = Script;
return EFI_SUCCESS;
}
}
- Script = Script + ScriptHeader.Length;
+
+ Script = Script + ScriptHeader.Length;
}
+
if (CreateIfNotFound) {
- LabelLength = (UINT32)AsciiStrSize(Label);
- return S3BootScriptLabelInternal (BeforeOrAfter,Position, LabelLength, Label);
+ LabelLength = (UINT32)AsciiStrSize (Label);
+ return S3BootScriptLabelInternal (BeforeOrAfter, Position, LabelLength, Label);
} else {
return EFI_NOT_FOUND;
}
@@ -2375,13 +2454,13 @@ S3BootScriptLabel ( RETURN_STATUS
EFIAPI
S3BootScriptCompare (
- IN UINT8 *Position1,
- IN UINT8 *Position2,
- OUT UINTN *RelativePosition
+ IN UINT8 *Position1,
+ IN UINT8 *Position2,
+ OUT UINTN *RelativePosition
)
{
- UINT8* Script;
- UINT32 TableLength;
+ UINT8 *Script;
+ UINT32 TableLength;
if (RelativePosition == NULL) {
return EFI_INVALID_PARAMETER;
@@ -2394,19 +2473,22 @@ S3BootScriptCompare ( if (Script == NULL) {
return RETURN_OUT_OF_RESOURCES;
}
+
Script = mS3BootScriptTablePtr->TableBase;
//
// mS3BootScriptTablePtr->TableLength does not include the termination node, so add it up
//
TableLength = mS3BootScriptTablePtr->TableLength + sizeof (EFI_BOOT_SCRIPT_TERMINATE);
- if (Position1 < Script || Position1 > Script+TableLength) {
+ if ((Position1 < Script) || (Position1 > Script+TableLength)) {
return EFI_INVALID_PARAMETER;
}
- if (Position2 < Script || Position2 > Script+TableLength) {
+
+ if ((Position2 < Script) || (Position2 > Script+TableLength)) {
return EFI_INVALID_PARAMETER;
}
- *RelativePosition = (Position1 < Position2)?-1:((Position1 == Position2)?0:1);
+
+ *RelativePosition = (Position1 < Position2) ? -1 : ((Position1 == Position2) ? 0 : 1);
return EFI_SUCCESS;
}
diff --git a/MdeModulePkg/Library/PiDxeS3BootScriptLib/InternalBootScriptLib.h b/MdeModulePkg/Library/PiDxeS3BootScriptLib/InternalBootScriptLib.h index 9485994087..b443aec08e 100644 --- a/MdeModulePkg/Library/PiDxeS3BootScriptLib/InternalBootScriptLib.h +++ b/MdeModulePkg/Library/PiDxeS3BootScriptLib/InternalBootScriptLib.h @@ -7,6 +7,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
+
#ifndef __INTERNAL_BOOT_SCRIPT_LIB__
#define __INTERNAL_BOOT_SCRIPT_LIB__
@@ -35,12 +36,12 @@ #include "BootScriptInternalFormat.h"
-#define MAX_IO_ADDRESS 0xFFFF
+#define MAX_IO_ADDRESS 0xFFFF
//
// Macro to convert a UEFI PCI address + segment to a PCI Segment Library PCI address
//
-#define PCI_ADDRESS_ENCODE(S, A) PCI_SEGMENT_LIB_ADDRESS( \
+#define PCI_ADDRESS_ENCODE(S, A) PCI_SEGMENT_LIB_ADDRESS(\
S, \
((((UINTN)(A)) & 0xff000000) >> 24), \
((((UINTN)(A)) & 0x00ff0000) >> 16), \
@@ -49,57 +50,54 @@ )
typedef union {
- UINT8 volatile *Buf;
- UINT8 volatile *Uint8;
- UINT16 volatile *Uint16;
- UINT32 volatile *Uint32;
- UINT64 volatile *Uint64;
- UINTN volatile Uint;
+ UINT8 volatile *Buf;
+ UINT8 volatile *Uint8;
+ UINT16 volatile *Uint16;
+ UINT32 volatile *Uint32;
+ UINT64 volatile *Uint64;
+ UINTN volatile Uint;
} PTR;
-
// Minimum and maximum length for SMBus bus block protocols defined in SMBus spec 2.0.
//
-#define MIN_SMBUS_BLOCK_LEN 1
-#define MAX_SMBUS_BLOCK_LEN 32
+#define MIN_SMBUS_BLOCK_LEN 1
+#define MAX_SMBUS_BLOCK_LEN 32
//
// The boot script private data.
//
typedef struct {
- UINT8 *TableBase;
- UINT32 TableLength; // Record the actual memory length
- UINT16 TableMemoryPageNumber; // Record the page number Allocated for the table
- BOOLEAN InSmm; // Record if this library is in SMM.
- BOOLEAN AtRuntime; // Record if current state is after SmmExitBootServices or SmmLegacyBoot.
- UINT32 BootTimeScriptLength; // Maintain boot time script length in LockBox after SmmReadyToLock in SMM.
- BOOLEAN SmmLocked; // Record if current state is after SmmReadyToLock
- BOOLEAN BackFromS3; // Indicate that the system is back from S3.
+ UINT8 *TableBase;
+ UINT32 TableLength; // Record the actual memory length
+ UINT16 TableMemoryPageNumber; // Record the page number Allocated for the table
+ BOOLEAN InSmm; // Record if this library is in SMM.
+ BOOLEAN AtRuntime; // Record if current state is after SmmExitBootServices or SmmLegacyBoot.
+ UINT32 BootTimeScriptLength; // Maintain boot time script length in LockBox after SmmReadyToLock in SMM.
+ BOOLEAN SmmLocked; // Record if current state is after SmmReadyToLock
+ BOOLEAN BackFromS3; // Indicate that the system is back from S3.
} SCRIPT_TABLE_PRIVATE_DATA;
typedef
EFI_STATUS
-(EFIAPI *DISPATCH_ENTRYPOINT_FUNC) (
+(EFIAPI *DISPATCH_ENTRYPOINT_FUNC)(
IN EFI_HANDLE ImageHandle,
IN VOID *Context
);
-extern SCRIPT_TABLE_PRIVATE_DATA *mS3BootScriptTablePtr;
+extern SCRIPT_TABLE_PRIVATE_DATA *mS3BootScriptTablePtr;
//
// Define Opcode for Label which is implementation specific and no standard spec define.
//
-#define S3_BOOT_SCRIPT_LIB_LABEL_OPCODE 0xFE
+#define S3_BOOT_SCRIPT_LIB_LABEL_OPCODE 0xFE
///
/// The opcode indicate the start of the boot script table.
///
-#define S3_BOOT_SCRIPT_LIB_TABLE_OPCODE 0xAA
+#define S3_BOOT_SCRIPT_LIB_TABLE_OPCODE 0xAA
///
/// The opcode indicate the end of the boot script table.
///
-#define S3_BOOT_SCRIPT_LIB_TERMINATE_OPCODE 0xFF
-
+#define S3_BOOT_SCRIPT_LIB_TERMINATE_OPCODE 0xFF
#endif //__INTERNAL_BOOT_SCRIPT_LIB__
-
diff --git a/MdeModulePkg/Library/PiSmmCoreMemoryAllocationLib/MemoryAllocationLib.c b/MdeModulePkg/Library/PiSmmCoreMemoryAllocationLib/MemoryAllocationLib.c index fd20a779cd..9a4d5b8cac 100644 --- a/MdeModulePkg/Library/PiSmmCoreMemoryAllocationLib/MemoryAllocationLib.c +++ b/MdeModulePkg/Library/PiSmmCoreMemoryAllocationLib/MemoryAllocationLib.c @@ -40,14 +40,15 @@ UINTN mSmmCoreMemoryAllocLibSmramRangeCount = 0; BOOLEAN
EFIAPI
BufferInSmram (
- IN VOID *Buffer
+ IN VOID *Buffer
)
{
UINTN Index;
- for (Index = 0; Index < mSmmCoreMemoryAllocLibSmramRangeCount; Index ++) {
- if (((EFI_PHYSICAL_ADDRESS) (UINTN) Buffer >= mSmmCoreMemoryAllocLibSmramRanges[Index].CpuStart) &&
- ((EFI_PHYSICAL_ADDRESS) (UINTN) Buffer < (mSmmCoreMemoryAllocLibSmramRanges[Index].CpuStart + mSmmCoreMemoryAllocLibSmramRanges[Index].PhysicalSize))) {
+ for (Index = 0; Index < mSmmCoreMemoryAllocLibSmramRangeCount; Index++) {
+ if (((EFI_PHYSICAL_ADDRESS)(UINTN)Buffer >= mSmmCoreMemoryAllocLibSmramRanges[Index].CpuStart) &&
+ ((EFI_PHYSICAL_ADDRESS)(UINTN)Buffer < (mSmmCoreMemoryAllocLibSmramRanges[Index].CpuStart + mSmmCoreMemoryAllocLibSmramRanges[Index].PhysicalSize)))
+ {
return TRUE;
}
}
@@ -85,7 +86,8 @@ InternalAllocatePages ( if (EFI_ERROR (Status)) {
return NULL;
}
- return (VOID *) (UINTN) Memory;
+
+ return (VOID *)(UINTN)Memory;
}
/**
@@ -112,14 +114,15 @@ AllocatePages ( Buffer = InternalAllocatePages (EfiRuntimeServicesData, Pages);
if (Buffer != NULL) {
MemoryProfileLibRecord (
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
MEMORY_PROFILE_ACTION_LIB_ALLOCATE_PAGES,
EfiRuntimeServicesData,
Buffer,
- EFI_PAGES_TO_SIZE(Pages),
+ EFI_PAGES_TO_SIZE (Pages),
NULL
);
}
+
return Buffer;
}
@@ -147,14 +150,15 @@ AllocateRuntimePages ( Buffer = InternalAllocatePages (EfiRuntimeServicesData, Pages);
if (Buffer != NULL) {
MemoryProfileLibRecord (
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RUNTIME_PAGES,
EfiRuntimeServicesData,
Buffer,
- EFI_PAGES_TO_SIZE(Pages),
+ EFI_PAGES_TO_SIZE (Pages),
NULL
);
}
+
return Buffer;
}
@@ -212,14 +216,15 @@ FreePages ( // When Buffer is in SMRAM range, it should be allocated by SmmAllocatePages() service.
// So, SmmFreePages() service is used to free it.
//
- Status = SmmFreePages ((EFI_PHYSICAL_ADDRESS) (UINTN) Buffer, Pages);
+ Status = SmmFreePages ((EFI_PHYSICAL_ADDRESS)(UINTN)Buffer, Pages);
} else {
//
// When Buffer is out of SMRAM range, it should be allocated by gBS->AllocatePages() service.
// So, gBS->FreePages() service is used to free it.
//
- Status = gBS->FreePages ((EFI_PHYSICAL_ADDRESS) (UINTN) Buffer, Pages);
+ Status = gBS->FreePages ((EFI_PHYSICAL_ADDRESS)(UINTN)Buffer, Pages);
}
+
ASSERT_EFI_ERROR (Status);
}
@@ -263,23 +268,25 @@ InternalAllocateAlignedPages ( if (Pages == 0) {
return NULL;
}
+
if (Alignment > EFI_PAGE_SIZE) {
//
// Calculate the total number of pages since alignment is larger than page size.
//
- AlignmentMask = Alignment - 1;
- RealPages = Pages + EFI_SIZE_TO_PAGES (Alignment);
+ AlignmentMask = Alignment - 1;
+ RealPages = Pages + EFI_SIZE_TO_PAGES (Alignment);
//
// Make sure that Pages plus EFI_SIZE_TO_PAGES (Alignment) does not overflow.
//
ASSERT (RealPages > Pages);
- Status = SmmAllocatePages (AllocateAnyPages, MemoryType, RealPages, &Memory);
+ Status = SmmAllocatePages (AllocateAnyPages, MemoryType, RealPages, &Memory);
if (EFI_ERROR (Status)) {
return NULL;
}
- AlignedMemory = ((UINTN) Memory + AlignmentMask) & ~AlignmentMask;
- UnalignedPages = EFI_SIZE_TO_PAGES (AlignedMemory - (UINTN) Memory);
+
+ AlignedMemory = ((UINTN)Memory + AlignmentMask) & ~AlignmentMask;
+ UnalignedPages = EFI_SIZE_TO_PAGES (AlignedMemory - (UINTN)Memory);
if (UnalignedPages > 0) {
//
// Free first unaligned page(s).
@@ -287,6 +294,7 @@ InternalAllocateAlignedPages ( Status = SmmFreePages (Memory, UnalignedPages);
ASSERT_EFI_ERROR (Status);
}
+
Memory = AlignedMemory + EFI_PAGES_TO_SIZE (Pages);
UnalignedPages = RealPages - Pages - UnalignedPages;
if (UnalignedPages > 0) {
@@ -304,9 +312,11 @@ InternalAllocateAlignedPages ( if (EFI_ERROR (Status)) {
return NULL;
}
- AlignedMemory = (UINTN) Memory;
+
+ AlignedMemory = (UINTN)Memory;
}
- return (VOID *) AlignedMemory;
+
+ return (VOID *)AlignedMemory;
}
/**
@@ -339,14 +349,15 @@ AllocateAlignedPages ( Buffer = InternalAllocateAlignedPages (EfiRuntimeServicesData, Pages, Alignment);
if (Buffer != NULL) {
MemoryProfileLibRecord (
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
MEMORY_PROFILE_ACTION_LIB_ALLOCATE_ALIGNED_PAGES,
EfiRuntimeServicesData,
Buffer,
- EFI_PAGES_TO_SIZE(Pages),
+ EFI_PAGES_TO_SIZE (Pages),
NULL
);
}
+
return Buffer;
}
@@ -380,14 +391,15 @@ AllocateAlignedRuntimePages ( Buffer = InternalAllocateAlignedPages (EfiRuntimeServicesData, Pages, Alignment);
if (Buffer != NULL) {
MemoryProfileLibRecord (
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
MEMORY_PROFILE_ACTION_LIB_ALLOCATE_ALIGNED_RUNTIME_PAGES,
EfiRuntimeServicesData,
Buffer,
- EFI_PAGES_TO_SIZE(Pages),
+ EFI_PAGES_TO_SIZE (Pages),
NULL
);
}
+
return Buffer;
}
@@ -451,14 +463,15 @@ FreeAlignedPages ( // When Buffer is in SMRAM range, it should be allocated by SmmAllocatePages() service.
// So, SmmFreePages() service is used to free it.
//
- Status = SmmFreePages ((EFI_PHYSICAL_ADDRESS) (UINTN) Buffer, Pages);
+ Status = SmmFreePages ((EFI_PHYSICAL_ADDRESS)(UINTN)Buffer, Pages);
} else {
//
// When Buffer is out of SMRAM range, it should be allocated by gBS->AllocatePages() service.
// So, gBS->FreePages() service is used to free it.
//
- Status = gBS->FreePages ((EFI_PHYSICAL_ADDRESS) (UINTN) Buffer, Pages);
+ Status = gBS->FreePages ((EFI_PHYSICAL_ADDRESS)(UINTN)Buffer, Pages);
}
+
ASSERT_EFI_ERROR (Status);
}
@@ -490,6 +503,7 @@ InternalAllocatePool ( if (EFI_ERROR (Status)) {
Memory = NULL;
}
+
return Memory;
}
@@ -516,7 +530,7 @@ AllocatePool ( Buffer = InternalAllocatePool (EfiRuntimeServicesData, AllocationSize);
if (Buffer != NULL) {
MemoryProfileLibRecord (
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
MEMORY_PROFILE_ACTION_LIB_ALLOCATE_POOL,
EfiRuntimeServicesData,
Buffer,
@@ -524,6 +538,7 @@ AllocatePool ( NULL
);
}
+
return Buffer;
}
@@ -550,7 +565,7 @@ AllocateRuntimePool ( Buffer = InternalAllocatePool (EfiRuntimeServicesData, AllocationSize);
if (Buffer != NULL) {
MemoryProfileLibRecord (
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RUNTIME_POOL,
EfiRuntimeServicesData,
Buffer,
@@ -558,6 +573,7 @@ AllocateRuntimePool ( NULL
);
}
+
return Buffer;
}
@@ -608,6 +624,7 @@ InternalAllocateZeroPool ( if (Memory != NULL) {
Memory = ZeroMem (Memory, AllocationSize);
}
+
return Memory;
}
@@ -635,7 +652,7 @@ AllocateZeroPool ( Buffer = InternalAllocateZeroPool (EfiRuntimeServicesData, AllocationSize);
if (Buffer != NULL) {
MemoryProfileLibRecord (
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
MEMORY_PROFILE_ACTION_LIB_ALLOCATE_ZERO_POOL,
EfiRuntimeServicesData,
Buffer,
@@ -643,6 +660,7 @@ AllocateZeroPool ( NULL
);
}
+
return Buffer;
}
@@ -670,7 +688,7 @@ AllocateRuntimeZeroPool ( Buffer = InternalAllocateZeroPool (EfiRuntimeServicesData, AllocationSize);
if (Buffer != NULL) {
MemoryProfileLibRecord (
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RUNTIME_ZERO_POOL,
EfiRuntimeServicesData,
Buffer,
@@ -678,6 +696,7 @@ AllocateRuntimeZeroPool ( NULL
);
}
+
return Buffer;
}
@@ -730,12 +749,13 @@ InternalAllocateCopyPool ( VOID *Memory;
ASSERT (Buffer != NULL);
- ASSERT (AllocationSize <= (MAX_ADDRESS - (UINTN) Buffer + 1));
+ ASSERT (AllocationSize <= (MAX_ADDRESS - (UINTN)Buffer + 1));
Memory = InternalAllocatePool (PoolType, AllocationSize);
if (Memory != NULL) {
- Memory = CopyMem (Memory, Buffer, AllocationSize);
+ Memory = CopyMem (Memory, Buffer, AllocationSize);
}
+
return Memory;
}
@@ -768,7 +788,7 @@ AllocateCopyPool ( NewBuffer = InternalAllocateCopyPool (EfiRuntimeServicesData, AllocationSize, Buffer);
if (NewBuffer != NULL) {
MemoryProfileLibRecord (
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
MEMORY_PROFILE_ACTION_LIB_ALLOCATE_COPY_POOL,
EfiRuntimeServicesData,
NewBuffer,
@@ -776,6 +796,7 @@ AllocateCopyPool ( NULL
);
}
+
return NewBuffer;
}
@@ -808,7 +829,7 @@ AllocateRuntimeCopyPool ( NewBuffer = InternalAllocateCopyPool (EfiRuntimeServicesData, AllocationSize, Buffer);
if (NewBuffer != NULL) {
MemoryProfileLibRecord (
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RUNTIME_COPY_POOL,
EfiRuntimeServicesData,
NewBuffer,
@@ -816,6 +837,7 @@ AllocateRuntimeCopyPool ( NULL
);
}
+
return NewBuffer;
}
@@ -879,10 +901,11 @@ InternalReallocatePool ( VOID *NewBuffer;
NewBuffer = InternalAllocateZeroPool (PoolType, NewSize);
- if (NewBuffer != NULL && OldBuffer != NULL) {
+ if ((NewBuffer != NULL) && (OldBuffer != NULL)) {
CopyMem (NewBuffer, OldBuffer, MIN (OldSize, NewSize));
FreePool (OldBuffer);
}
+
return NewBuffer;
}
@@ -920,7 +943,7 @@ ReallocatePool ( Buffer = InternalReallocatePool (EfiRuntimeServicesData, OldSize, NewSize, OldBuffer);
if (Buffer != NULL) {
MemoryProfileLibRecord (
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
MEMORY_PROFILE_ACTION_LIB_REALLOCATE_POOL,
EfiRuntimeServicesData,
Buffer,
@@ -928,6 +951,7 @@ ReallocatePool ( NULL
);
}
+
return Buffer;
}
@@ -965,7 +989,7 @@ ReallocateRuntimePool ( Buffer = InternalReallocatePool (EfiRuntimeServicesData, OldSize, NewSize, OldBuffer);
if (Buffer != NULL) {
MemoryProfileLibRecord (
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
MEMORY_PROFILE_ACTION_LIB_REALLOCATE_RUNTIME_POOL,
EfiRuntimeServicesData,
Buffer,
@@ -973,6 +997,7 @@ ReallocateRuntimePool ( NULL
);
}
+
return Buffer;
}
@@ -1025,10 +1050,10 @@ ReallocateReservedPool ( VOID
EFIAPI
FreePool (
- IN VOID *Buffer
+ IN VOID *Buffer
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
if (BufferInSmram (Buffer)) {
//
@@ -1043,6 +1068,7 @@ FreePool ( //
Status = gBS->FreePool (Buffer);
}
+
ASSERT_EFI_ERROR (Status);
}
@@ -1077,8 +1103,8 @@ PiSmmCoreMemoryAllocationLibConstructor ( // so temporarily use BootServicesData to hold the SmramRanges data.
//
mSmmCoreMemoryAllocLibSmramRangeCount = SmmCorePrivate->SmramRangeCount;
- Size = mSmmCoreMemoryAllocLibSmramRangeCount * sizeof (EFI_SMRAM_DESCRIPTOR);
- Status = gBS->AllocatePool (EfiBootServicesData, Size, (VOID **) &mSmmCoreMemoryAllocLibSmramRanges);
+ Size = mSmmCoreMemoryAllocLibSmramRangeCount * sizeof (EFI_SMRAM_DESCRIPTOR);
+ Status = gBS->AllocatePool (EfiBootServicesData, Size, (VOID **)&mSmmCoreMemoryAllocLibSmramRanges);
ASSERT_EFI_ERROR (Status);
ASSERT (mSmmCoreMemoryAllocLibSmramRanges != NULL);
CopyMem (mSmmCoreMemoryAllocLibSmramRanges, SmmCorePrivate->SmramRanges, Size);
@@ -1091,8 +1117,8 @@ PiSmmCoreMemoryAllocationLibConstructor ( //
// Move the SmramRanges data from BootServicesData to SMRAM.
//
- BootServicesData = mSmmCoreMemoryAllocLibSmramRanges;
- mSmmCoreMemoryAllocLibSmramRanges = (EFI_SMRAM_DESCRIPTOR *) AllocateCopyPool (Size, (VOID *) BootServicesData);
+ BootServicesData = mSmmCoreMemoryAllocLibSmramRanges;
+ mSmmCoreMemoryAllocLibSmramRanges = (EFI_SMRAM_DESCRIPTOR *)AllocateCopyPool (Size, (VOID *)BootServicesData);
ASSERT (mSmmCoreMemoryAllocLibSmramRanges != NULL);
//
diff --git a/MdeModulePkg/Library/PiSmmCoreMemoryAllocationLib/PiSmmCoreMemoryAllocationServices.h b/MdeModulePkg/Library/PiSmmCoreMemoryAllocationLib/PiSmmCoreMemoryAllocationServices.h index 789fcf2c01..64429e028a 100644 --- a/MdeModulePkg/Library/PiSmmCoreMemoryAllocationLib/PiSmmCoreMemoryAllocationServices.h +++ b/MdeModulePkg/Library/PiSmmCoreMemoryAllocationLib/PiSmmCoreMemoryAllocationServices.h @@ -16,26 +16,26 @@ // It should be aligned with the definition in PiSmmCore.
//
typedef struct {
- UINTN Signature;
+ UINTN Signature;
///
/// The ImageHandle passed into the entry point of the SMM IPL. This ImageHandle
/// is used by the SMM Core to fill in the ParentImageHandle field of the Loaded
/// Image Protocol for each SMM Driver that is dispatched by the SMM Core.
///
- EFI_HANDLE SmmIplImageHandle;
+ EFI_HANDLE SmmIplImageHandle;
///
/// The number of SMRAM ranges passed from the SMM IPL to the SMM Core. The SMM
/// Core uses these ranges of SMRAM to initialize the SMM Core memory manager.
///
- UINTN SmramRangeCount;
+ UINTN SmramRangeCount;
///
/// A table of SMRAM ranges passed from the SMM IPL to the SMM Core. The SMM
/// Core uses these ranges of SMRAM to initialize the SMM Core memory manager.
///
- EFI_SMRAM_DESCRIPTOR *SmramRanges;
+ EFI_SMRAM_DESCRIPTOR *SmramRanges;
///
/// The SMM Foundation Entry Point. The SMM Core fills in this field when the
@@ -46,48 +46,48 @@ typedef struct { /// the SMM Foundation Entry Point as soon as the SMM Configuration Protocol is
/// available.
///
- EFI_SMM_ENTRY_POINT SmmEntryPoint;
+ EFI_SMM_ENTRY_POINT SmmEntryPoint;
///
/// Boolean flag set to TRUE while an SMI is being processed by the SMM Core.
///
- BOOLEAN SmmEntryPointRegistered;
+ BOOLEAN SmmEntryPointRegistered;
///
/// Boolean flag set to TRUE while an SMI is being processed by the SMM Core.
///
- BOOLEAN InSmm;
+ BOOLEAN InSmm;
///
/// This field is set by the SMM Core then the SMM Core is initialized. This field is
/// used by the SMM Base 2 Protocol and SMM Communication Protocol implementations in
/// the SMM IPL.
///
- EFI_SMM_SYSTEM_TABLE2 *Smst;
+ EFI_SMM_SYSTEM_TABLE2 *Smst;
///
/// This field is used by the SMM Communicatioon Protocol to pass a buffer into
/// a software SMI handler and for the software SMI handler to pass a buffer back to
/// the caller of the SMM Communication Protocol.
///
- VOID *CommunicationBuffer;
+ VOID *CommunicationBuffer;
///
/// This field is used by the SMM Communicatioon Protocol to pass the size of a buffer,
/// in bytes, into a software SMI handler and for the software SMI handler to pass the
/// size, in bytes, of a buffer back to the caller of the SMM Communication Protocol.
///
- UINTN BufferSize;
+ UINTN BufferSize;
///
/// This field is used by the SMM Communication Protocol to pass the return status from
/// a software SMI handler back to the caller of the SMM Communication Protocol.
///
- EFI_STATUS ReturnStatus;
+ EFI_STATUS ReturnStatus;
- EFI_PHYSICAL_ADDRESS PiSmmCoreImageBase;
- UINT64 PiSmmCoreImageSize;
- EFI_PHYSICAL_ADDRESS PiSmmCoreEntryPoint;
+ EFI_PHYSICAL_ADDRESS PiSmmCoreImageBase;
+ UINT64 PiSmmCoreImageSize;
+ EFI_PHYSICAL_ADDRESS PiSmmCoreEntryPoint;
} SMM_CORE_PRIVATE_DATA;
/**
@@ -122,10 +122,10 @@ SmmInitializeMemoryServices ( EFI_STATUS
EFIAPI
SmmAllocatePages (
- IN EFI_ALLOCATE_TYPE Type,
- IN EFI_MEMORY_TYPE MemoryType,
- IN UINTN NumberOfPages,
- OUT EFI_PHYSICAL_ADDRESS *Memory
+ IN EFI_ALLOCATE_TYPE Type,
+ IN EFI_MEMORY_TYPE MemoryType,
+ IN UINTN NumberOfPages,
+ OUT EFI_PHYSICAL_ADDRESS *Memory
);
/**
@@ -142,8 +142,8 @@ SmmAllocatePages ( EFI_STATUS
EFIAPI
SmmFreePages (
- IN EFI_PHYSICAL_ADDRESS Memory,
- IN UINTN NumberOfPages
+ IN EFI_PHYSICAL_ADDRESS Memory,
+ IN UINTN NumberOfPages
);
/**
@@ -162,9 +162,9 @@ SmmFreePages ( EFI_STATUS
EFIAPI
SmmAllocatePool (
- IN EFI_MEMORY_TYPE PoolType,
- IN UINTN Size,
- OUT VOID **Buffer
+ IN EFI_MEMORY_TYPE PoolType,
+ IN UINTN Size,
+ OUT VOID **Buffer
);
/**
@@ -179,7 +179,7 @@ SmmAllocatePool ( EFI_STATUS
EFIAPI
SmmFreePool (
- IN VOID *Buffer
+ IN VOID *Buffer
);
#endif
diff --git a/MdeModulePkg/Library/PiSmmCoreMemoryAllocationLib/PiSmmCoreMemoryProfileLib.c b/MdeModulePkg/Library/PiSmmCoreMemoryAllocationLib/PiSmmCoreMemoryProfileLib.c index 32ef22256f..82ad226e2e 100644 --- a/MdeModulePkg/Library/PiSmmCoreMemoryAllocationLib/PiSmmCoreMemoryProfileLib.c +++ b/MdeModulePkg/Library/PiSmmCoreMemoryAllocationLib/PiSmmCoreMemoryProfileLib.c @@ -15,7 +15,7 @@ #include "PiSmmCoreMemoryProfileServices.h"
-EDKII_MEMORY_PROFILE_PROTOCOL *mLibProfileProtocol;
+EDKII_MEMORY_PROFILE_PROTOCOL *mLibProfileProtocol;
/**
Check whether the start address of buffer is within any of the SMRAM ranges.
@@ -28,7 +28,7 @@ EDKII_MEMORY_PROFILE_PROTOCOL *mLibProfileProtocol; BOOLEAN
EFIAPI
BufferInSmram (
- IN VOID *Buffer
+ IN VOID *Buffer
);
/**
@@ -47,7 +47,7 @@ PiSmmCoreMemoryProfileLibConstructor ( IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
//
// Locate Profile Protocol
@@ -89,12 +89,12 @@ PiSmmCoreMemoryProfileLibConstructor ( EFI_STATUS
EFIAPI
MemoryProfileLibRecord (
- IN PHYSICAL_ADDRESS CallerAddress,
- IN MEMORY_PROFILE_ACTION Action,
- IN EFI_MEMORY_TYPE MemoryType,
- IN VOID *Buffer,
- IN UINTN Size,
- IN CHAR8 *ActionString OPTIONAL
+ IN PHYSICAL_ADDRESS CallerAddress,
+ IN MEMORY_PROFILE_ACTION Action,
+ IN EFI_MEMORY_TYPE MemoryType,
+ IN VOID *Buffer,
+ IN UINTN Size,
+ IN CHAR8 *ActionString OPTIONAL
)
{
if (BufferInSmram (Buffer)) {
@@ -103,6 +103,7 @@ MemoryProfileLibRecord ( if (mLibProfileProtocol == NULL) {
return EFI_UNSUPPORTED;
}
+
return mLibProfileProtocol->Record (
mLibProfileProtocol,
CallerAddress,
@@ -114,4 +115,3 @@ MemoryProfileLibRecord ( );
}
}
-
diff --git a/MdeModulePkg/Library/PiSmmCoreMemoryAllocationLib/PiSmmCoreMemoryProfileLibNull.c b/MdeModulePkg/Library/PiSmmCoreMemoryAllocationLib/PiSmmCoreMemoryProfileLibNull.c index b132024d04..22b2cf883a 100644 --- a/MdeModulePkg/Library/PiSmmCoreMemoryAllocationLib/PiSmmCoreMemoryProfileLibNull.c +++ b/MdeModulePkg/Library/PiSmmCoreMemoryAllocationLib/PiSmmCoreMemoryProfileLibNull.c @@ -35,14 +35,13 @@ EFI_STATUS
EFIAPI
MemoryProfileLibRecord (
- IN PHYSICAL_ADDRESS CallerAddress,
- IN MEMORY_PROFILE_ACTION Action,
- IN EFI_MEMORY_TYPE MemoryType,
- IN VOID *Buffer,
- IN UINTN Size,
- IN CHAR8 *ActionString OPTIONAL
+ IN PHYSICAL_ADDRESS CallerAddress,
+ IN MEMORY_PROFILE_ACTION Action,
+ IN EFI_MEMORY_TYPE MemoryType,
+ IN VOID *Buffer,
+ IN UINTN Size,
+ IN CHAR8 *ActionString OPTIONAL
)
{
return EFI_UNSUPPORTED;
}
-
diff --git a/MdeModulePkg/Library/PlatformBootManagerLibNull/PlatformBootManager.c b/MdeModulePkg/Library/PlatformBootManagerLibNull/PlatformBootManager.c index 43560bf2aa..db6ada3aac 100644 --- a/MdeModulePkg/Library/PlatformBootManagerLibNull/PlatformBootManager.c +++ b/MdeModulePkg/Library/PlatformBootManagerLibNull/PlatformBootManager.c @@ -9,7 +9,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include <Library/PlatformBootManagerLib.h>
-
/**
Do the platform specific action before the console is connected.
@@ -54,7 +53,7 @@ PlatformBootManagerAfterConsole ( VOID
EFIAPI
PlatformBootManagerWaitCallback (
- UINT16 TimeoutRemain
+ UINT16 TimeoutRemain
)
{
return;
@@ -75,4 +74,3 @@ PlatformBootManagerUnableToBoot ( {
return;
}
-
diff --git a/MdeModulePkg/Library/PlatformVarCleanupLib/PlatVarCleanup.h b/MdeModulePkg/Library/PlatformVarCleanupLib/PlatVarCleanup.h index c809a7086b..332521360d 100644 --- a/MdeModulePkg/Library/PlatformVarCleanupLib/PlatVarCleanup.h +++ b/MdeModulePkg/Library/PlatformVarCleanupLib/PlatVarCleanup.h @@ -38,65 +38,65 @@ SPDX-License-Identifier: BSD-2-Clause-Patent // This data array is ready to be used as input of HiiAddPackages() to
// create a packagelist (which contains Form packages, String packages, etc).
//
-extern UINT8 PlatVarCleanupBin[];
+extern UINT8 PlatVarCleanupBin[];
//
// This is the generated String package data for all .UNI files.
// This data array is ready to be used as input of HiiAddPackages() to
// create a packagelist (which contains Form packages, String packages, etc).
//
-extern UINT8 PlatformVarCleanupLibStrings[];
+extern UINT8 PlatformVarCleanupLibStrings[];
-#define USER_VARIABLE_NODE_SIGNATURE SIGNATURE_32 ('U', 'V', 'N', 'S')
+#define USER_VARIABLE_NODE_SIGNATURE SIGNATURE_32 ('U', 'V', 'N', 'S')
typedef struct {
- UINTN Signature;
- LIST_ENTRY Link;
- EFI_GUID Guid;
- CHAR16 *PromptString;
- LIST_ENTRY NameLink;
+ UINTN Signature;
+ LIST_ENTRY Link;
+ EFI_GUID Guid;
+ CHAR16 *PromptString;
+ LIST_ENTRY NameLink;
} USER_VARIABLE_NODE;
-#define USER_VARIABLE_FROM_LINK(a) CR (a, USER_VARIABLE_NODE, Link, USER_VARIABLE_NODE_SIGNATURE)
+#define USER_VARIABLE_FROM_LINK(a) CR (a, USER_VARIABLE_NODE, Link, USER_VARIABLE_NODE_SIGNATURE)
-#define USER_VARIABLE_NAME_NODE_SIGNATURE SIGNATURE_32 ('U', 'V', 'N', 'N')
+#define USER_VARIABLE_NAME_NODE_SIGNATURE SIGNATURE_32 ('U', 'V', 'N', 'N')
typedef struct {
- UINTN Signature;
- LIST_ENTRY Link;
- CHAR16 *Name;
- UINTN DataSize;
- UINT32 Attributes;
- UINT16 Index;
- EFI_QUESTION_ID QuestionId;
- CHAR16 *PromptString;
- CHAR16 *HelpString;
- BOOLEAN Deleted;
+ UINTN Signature;
+ LIST_ENTRY Link;
+ CHAR16 *Name;
+ UINTN DataSize;
+ UINT32 Attributes;
+ UINT16 Index;
+ EFI_QUESTION_ID QuestionId;
+ CHAR16 *PromptString;
+ CHAR16 *HelpString;
+ BOOLEAN Deleted;
} USER_VARIABLE_NAME_NODE;
-#define USER_VARIABLE_NAME_FROM_LINK(a) CR (a, USER_VARIABLE_NAME_NODE, Link, USER_VARIABLE_NAME_NODE_SIGNATURE)
+#define USER_VARIABLE_NAME_FROM_LINK(a) CR (a, USER_VARIABLE_NAME_NODE, Link, USER_VARIABLE_NAME_NODE_SIGNATURE)
#pragma pack(1)
//
// HII specific Vendor Device Path definition.
//
typedef struct {
- VENDOR_DEVICE_PATH VendorDevicePath;
- EFI_DEVICE_PATH_PROTOCOL End;
+ VENDOR_DEVICE_PATH VendorDevicePath;
+ EFI_DEVICE_PATH_PROTOCOL End;
} HII_VENDOR_DEVICE_PATH;
#pragma pack()
-#define VARIABLE_CLEANUP_HII_PRIVATE_SIGNATURE SIGNATURE_32 ('V', 'C', 'H', 'P')
+#define VARIABLE_CLEANUP_HII_PRIVATE_SIGNATURE SIGNATURE_32 ('V', 'C', 'H', 'P')
typedef struct {
- UINTN Signature;
- EFI_HANDLE DriverHandle;
- EFI_HII_HANDLE HiiHandle;
- EFI_HII_CONFIG_ACCESS_PROTOCOL ConfigAccess;
- EFI_HII_CONFIG_ROUTING_PROTOCOL *ConfigRouting;
- VARIABLE_CLEANUP_DATA VariableCleanupData;
+ UINTN Signature;
+ EFI_HANDLE DriverHandle;
+ EFI_HII_HANDLE HiiHandle;
+ EFI_HII_CONFIG_ACCESS_PROTOCOL ConfigAccess;
+ EFI_HII_CONFIG_ROUTING_PROTOCOL *ConfigRouting;
+ VARIABLE_CLEANUP_DATA VariableCleanupData;
} VARIABLE_CLEANUP_HII_PRIVATE_DATA;
-#define VARIABLE_CLEANUP_HII_PRIVATE_FROM_THIS(a) CR (a, VARIABLE_CLEANUP_HII_PRIVATE_DATA, ConfigAccess, VARIABLE_CLEANUP_HII_PRIVATE_SIGNATURE)
+#define VARIABLE_CLEANUP_HII_PRIVATE_FROM_THIS(a) CR (a, VARIABLE_CLEANUP_HII_PRIVATE_DATA, ConfigAccess, VARIABLE_CLEANUP_HII_PRIVATE_SIGNATURE)
#endif
diff --git a/MdeModulePkg/Library/PlatformVarCleanupLib/PlatVarCleanupHii.h b/MdeModulePkg/Library/PlatformVarCleanupLib/PlatVarCleanupHii.h index 74bcdb4b9f..9f9cc94bfe 100644 --- a/MdeModulePkg/Library/PlatformVarCleanupLib/PlatVarCleanupHii.h +++ b/MdeModulePkg/Library/PlatformVarCleanupLib/PlatVarCleanupHii.h @@ -17,37 +17,37 @@ SPDX-License-Identifier: BSD-2-Clause-Patent 0x24f14d8a, 0xd7a8, 0x4991, { 0x91, 0xe0, 0x96, 0xc3, 0xb7, 0xdb, 0x84, 0x56 } \
}
-#define MAX_USER_VARIABLE_COUNT 0x1000
+#define MAX_USER_VARIABLE_COUNT 0x1000
typedef struct {
- UINT8 SelectAll;
+ UINT8 SelectAll;
//
// FALSE is to not delete, TRUE is to delete.
//
- UINT8 UserVariable[MAX_USER_VARIABLE_COUNT];
+ UINT8 UserVariable[MAX_USER_VARIABLE_COUNT];
} VARIABLE_CLEANUP_DATA;
-#define VARIABLE_CLEANUP_VARSTORE_ID 0x8000
+#define VARIABLE_CLEANUP_VARSTORE_ID 0x8000
//
// Field offset of structure VARIABLE_CLEANUP_DATA
//
-#define VAR_OFFSET(Field) ((UINTN) &(((VARIABLE_CLEANUP_DATA *) 0)->Field))
-#define USER_VARIABLE_VAR_OFFSET (VAR_OFFSET (UserVariable))
+#define VAR_OFFSET(Field) ((UINTN) &(((VARIABLE_CLEANUP_DATA *) 0)->Field))
+#define USER_VARIABLE_VAR_OFFSET (VAR_OFFSET (UserVariable))
-#define FORM_ID_VARIABLE_CLEANUP 0x8000
+#define FORM_ID_VARIABLE_CLEANUP 0x8000
-#define LABEL_START 0x0000
-#define LABEL_END 0xFFFF
+#define LABEL_START 0x0000
+#define LABEL_END 0xFFFF
-#define SELECT_ALL_QUESTION_ID 0x7FFD
-#define SAVE_AND_EXIT_QUESTION_ID 0x7FFE
-#define NO_SAVE_AND_EXIT_QUESTION_ID 0x7FFF
+#define SELECT_ALL_QUESTION_ID 0x7FFD
+#define SAVE_AND_EXIT_QUESTION_ID 0x7FFE
+#define NO_SAVE_AND_EXIT_QUESTION_ID 0x7FFF
//
// Tool automatic generated Question Id start from 1.
// In order to avoid to conflict them, the user variable QuestionID offset is defined from 0x8000.
//
-#define USER_VARIABLE_QUESTION_ID 0x8000
+#define USER_VARIABLE_QUESTION_ID 0x8000
#endif
diff --git a/MdeModulePkg/Library/PlatformVarCleanupLib/PlatVarCleanupLib.c b/MdeModulePkg/Library/PlatformVarCleanupLib/PlatVarCleanupLib.c index 0633f8197f..d37367823d 100644 --- a/MdeModulePkg/Library/PlatformVarCleanupLib/PlatVarCleanupLib.c +++ b/MdeModulePkg/Library/PlatformVarCleanupLib/PlatVarCleanupLib.c @@ -8,31 +8,31 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include "PlatVarCleanup.h"
-VAR_ERROR_FLAG mLastVarErrorFlag = VAR_ERROR_FLAG_NO_ERROR;
-EDKII_VAR_CHECK_PROTOCOL *mVarCheck = NULL;
+VAR_ERROR_FLAG mLastVarErrorFlag = VAR_ERROR_FLAG_NO_ERROR;
+EDKII_VAR_CHECK_PROTOCOL *mVarCheck = NULL;
///
/// The flag to indicate whether the platform has left the DXE phase of execution.
///
-BOOLEAN mEndOfDxe = FALSE;
+BOOLEAN mEndOfDxe = FALSE;
-EFI_EVENT mPlatVarCleanupLibEndOfDxeEvent = NULL;
+EFI_EVENT mPlatVarCleanupLibEndOfDxeEvent = NULL;
-LIST_ENTRY mUserVariableList = INITIALIZE_LIST_HEAD_VARIABLE (mUserVariableList);
-UINT16 mUserVariableCount = 0;
-UINT16 mMarkedUserVariableCount = 0;
+LIST_ENTRY mUserVariableList = INITIALIZE_LIST_HEAD_VARIABLE (mUserVariableList);
+UINT16 mUserVariableCount = 0;
+UINT16 mMarkedUserVariableCount = 0;
-EFI_GUID mVariableCleanupHiiGuid = VARIABLE_CLEANUP_HII_GUID;
-CHAR16 mVarStoreName[] = L"VariableCleanup";
+EFI_GUID mVariableCleanupHiiGuid = VARIABLE_CLEANUP_HII_GUID;
+CHAR16 mVarStoreName[] = L"VariableCleanup";
-HII_VENDOR_DEVICE_PATH mVarCleanupHiiVendorDevicePath = {
+HII_VENDOR_DEVICE_PATH mVarCleanupHiiVendorDevicePath = {
{
{
HARDWARE_DEVICE_PATH,
HW_VENDOR_DP,
{
- (UINT8) (sizeof (VENDOR_DEVICE_PATH)),
- (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)
+ (UINT8)(sizeof (VENDOR_DEVICE_PATH)),
+ (UINT8)((sizeof (VENDOR_DEVICE_PATH)) >> 8)
}
},
VARIABLE_CLEANUP_HII_GUID
@@ -41,8 +41,8 @@ HII_VENDOR_DEVICE_PATH mVarCleanupHiiVendorDevicePath = { END_DEVICE_PATH_TYPE,
END_ENTIRE_DEVICE_PATH_SUBTYPE,
{
- (UINT8) (sizeof (EFI_DEVICE_PATH_PROTOCOL)),
- (UINT8) ((sizeof (EFI_DEVICE_PATH_PROTOCOL)) >> 8)
+ (UINT8)(sizeof (EFI_DEVICE_PATH_PROTOCOL)),
+ (UINT8)((sizeof (EFI_DEVICE_PATH_PROTOCOL)) >> 8)
}
}
};
@@ -58,11 +58,11 @@ InternalGetVarErrorFlag ( VOID
)
{
- EFI_STATUS Status;
- UINTN Size;
- VAR_ERROR_FLAG ErrorFlag;
+ EFI_STATUS Status;
+ UINTN Size;
+ VAR_ERROR_FLAG ErrorFlag;
- Size = sizeof (ErrorFlag);
+ Size = sizeof (ErrorFlag);
Status = gRT->GetVariable (
VAR_ERROR_FLAG_NAME,
&gEdkiiVarErrorFlagGuid,
@@ -74,6 +74,7 @@ InternalGetVarErrorFlag ( DEBUG ((DEBUG_INFO, "%s - not found\n", VAR_ERROR_FLAG_NAME));
return VAR_ERROR_FLAG_NO_ERROR;
}
+
return ErrorFlag;
}
@@ -89,20 +90,21 @@ InternalGetVarErrorFlag ( **/
BOOLEAN
IsUserVariable (
- IN CHAR16 *Name,
- IN EFI_GUID *Guid
+ IN CHAR16 *Name,
+ IN EFI_GUID *Guid
)
{
- EFI_STATUS Status;
- VAR_CHECK_VARIABLE_PROPERTY Property;
+ EFI_STATUS Status;
+ VAR_CHECK_VARIABLE_PROPERTY Property;
if (mVarCheck == NULL) {
gBS->LocateProtocol (
&gEdkiiVarCheckProtocolGuid,
NULL,
- (VOID **) &mVarCheck
+ (VOID **)&mVarCheck
);
}
+
ASSERT (mVarCheck != NULL);
ZeroMem (&Property, sizeof (Property));
@@ -119,12 +121,12 @@ IsUserVariable ( return TRUE;
}
-// DEBUG ((DEBUG_INFO, "PlatformVarCleanup - Variable Property: %g:%s\n", Guid, Name));
-// DEBUG ((DEBUG_INFO, " Revision - 0x%04x\n", Property.Revision));
-// DEBUG ((DEBUG_INFO, " Property - 0x%04x\n", Property.Property));
-// DEBUG ((DEBUG_INFO, " Attribute - 0x%08x\n", Property.Attributes));
-// DEBUG ((DEBUG_INFO, " MinSize - 0x%x\n", Property.MinSize));
-// DEBUG ((DEBUG_INFO, " MaxSize - 0x%x\n", Property.MaxSize));
+ // DEBUG ((DEBUG_INFO, "PlatformVarCleanup - Variable Property: %g:%s\n", Guid, Name));
+ // DEBUG ((DEBUG_INFO, " Revision - 0x%04x\n", Property.Revision));
+ // DEBUG ((DEBUG_INFO, " Property - 0x%04x\n", Property.Property));
+ // DEBUG ((DEBUG_INFO, " Attribute - 0x%08x\n", Property.Attributes));
+ // DEBUG ((DEBUG_INFO, " MinSize - 0x%x\n", Property.MinSize));
+ // DEBUG ((DEBUG_INFO, " MaxSize - 0x%x\n", Property.MaxSize));
return FALSE;
}
@@ -139,15 +141,16 @@ IsUserVariable ( **/
USER_VARIABLE_NODE *
FindUserVariableNodeByGuid (
- IN EFI_GUID *Guid
+ IN EFI_GUID *Guid
)
{
- USER_VARIABLE_NODE *UserVariableNode;
- LIST_ENTRY *Link;
+ USER_VARIABLE_NODE *UserVariableNode;
+ LIST_ENTRY *Link;
for (Link = mUserVariableList.ForwardLink
- ;Link != &mUserVariableList
- ;Link = Link->ForwardLink) {
+ ; Link != &mUserVariableList
+ ; Link = Link->ForwardLink)
+ {
UserVariableNode = USER_VARIABLE_FROM_LINK (Link);
if (CompareGuid (Guid, &UserVariableNode->Guid)) {
@@ -185,56 +188,57 @@ CreateUserVariableNode ( VOID
)
{
- EFI_STATUS Status;
- EFI_STATUS GetVariableStatus;
- CHAR16 *VarName;
- UINTN MaxVarNameSize;
- UINTN VarNameSize;
- UINTN MaxDataSize;
- UINTN DataSize;
- VOID *Data;
- UINT32 Attributes;
- EFI_GUID Guid;
- USER_VARIABLE_NODE *UserVariableNode;
- USER_VARIABLE_NAME_NODE *UserVariableNameNode;
- UINT16 Index;
- UINTN StringSize;
+ EFI_STATUS Status;
+ EFI_STATUS GetVariableStatus;
+ CHAR16 *VarName;
+ UINTN MaxVarNameSize;
+ UINTN VarNameSize;
+ UINTN MaxDataSize;
+ UINTN DataSize;
+ VOID *Data;
+ UINT32 Attributes;
+ EFI_GUID Guid;
+ USER_VARIABLE_NODE *UserVariableNode;
+ USER_VARIABLE_NAME_NODE *UserVariableNameNode;
+ UINT16 Index;
+ UINTN StringSize;
//
// Initialize 128 * sizeof (CHAR16) variable name size.
//
MaxVarNameSize = 128 * sizeof (CHAR16);
- VarName = AllocateZeroPool (MaxVarNameSize);
+ VarName = AllocateZeroPool (MaxVarNameSize);
ASSERT (VarName != NULL);
//
// Initialize 0x1000 variable data size.
//
MaxDataSize = 0x1000;
- Data = AllocateZeroPool (MaxDataSize);
+ Data = AllocateZeroPool (MaxDataSize);
ASSERT (Data != NULL);
Index = 0;
do {
VarNameSize = MaxVarNameSize;
- Status = gRT->GetNextVariableName (&VarNameSize, VarName, &Guid);
+ Status = gRT->GetNextVariableName (&VarNameSize, VarName, &Guid);
if (Status == EFI_BUFFER_TOO_SMALL) {
VarName = ReallocatePool (MaxVarNameSize, VarNameSize, VarName);
ASSERT (VarName != NULL);
MaxVarNameSize = VarNameSize;
- Status = gRT->GetNextVariableName (&VarNameSize, VarName, &Guid);
+ Status = gRT->GetNextVariableName (&VarNameSize, VarName, &Guid);
}
if (!EFI_ERROR (Status)) {
if (IsUserVariable (VarName, &Guid)) {
- DataSize = MaxDataSize;
+ DataSize = MaxDataSize;
GetVariableStatus = gRT->GetVariable (VarName, &Guid, &Attributes, &DataSize, Data);
if (GetVariableStatus == EFI_BUFFER_TOO_SMALL) {
Data = ReallocatePool (MaxDataSize, DataSize, Data);
ASSERT (Data != NULL);
- MaxDataSize = DataSize;
+ MaxDataSize = DataSize;
GetVariableStatus = gRT->GetVariable (VarName, &Guid, &Attributes, &DataSize, Data);
}
+
ASSERT_EFI_ERROR (GetVariableStatus);
if ((Attributes & EFI_VARIABLE_NON_VOLATILE) != 0) {
@@ -246,23 +250,23 @@ CreateUserVariableNode ( //
UserVariableNameNode = AllocateZeroPool (sizeof (*UserVariableNameNode));
ASSERT (UserVariableNameNode != NULL);
- UserVariableNameNode->Signature = USER_VARIABLE_NAME_NODE_SIGNATURE;
- UserVariableNameNode->Name = AllocateCopyPool (VarNameSize, VarName);
+ UserVariableNameNode->Signature = USER_VARIABLE_NAME_NODE_SIGNATURE;
+ UserVariableNameNode->Name = AllocateCopyPool (VarNameSize, VarName);
UserVariableNameNode->Attributes = Attributes;
- UserVariableNameNode->DataSize = DataSize;
- UserVariableNameNode->Index = Index;
- UserVariableNameNode->QuestionId = (EFI_QUESTION_ID) (USER_VARIABLE_QUESTION_ID + Index);
+ UserVariableNameNode->DataSize = DataSize;
+ UserVariableNameNode->Index = Index;
+ UserVariableNameNode->QuestionId = (EFI_QUESTION_ID)(USER_VARIABLE_QUESTION_ID + Index);
//
// 2 space * sizeof (CHAR16) + StrSize.
//
- StringSize = 2 * sizeof (CHAR16) + StrSize (UserVariableNameNode->Name);
+ StringSize = 2 * sizeof (CHAR16) + StrSize (UserVariableNameNode->Name);
UserVariableNameNode->PromptString = AllocatePool (StringSize);
ASSERT (UserVariableNameNode->PromptString != NULL);
UnicodeSPrint (UserVariableNameNode->PromptString, StringSize, L" %s", UserVariableNameNode->Name);
//
// (33 chars of "Attribtues = 0x and DataSize = 0x" + 1 terminator + (sizeof (UINT32) + sizeof (UINTN)) * 2) * sizeof (CHAR16).
//
- StringSize = (33 + 1 + (sizeof (UINT32) + sizeof (UINTN)) * 2) * sizeof (CHAR16);
+ StringSize = (33 + 1 + (sizeof (UINT32) + sizeof (UINTN)) * 2) * sizeof (CHAR16);
UserVariableNameNode->HelpString = AllocatePool (StringSize);
ASSERT (UserVariableNameNode->HelpString != NULL);
UnicodeSPrint (UserVariableNameNode->HelpString, StringSize, L"Attribtues = 0x%08x and DataSize = 0x%x", UserVariableNameNode->Attributes, UserVariableNameNode->DataSize);
@@ -291,19 +295,19 @@ DestroyUserVariableNode ( VOID
)
{
- USER_VARIABLE_NODE *UserVariableNode;
- LIST_ENTRY *Link;
- USER_VARIABLE_NAME_NODE *UserVariableNameNode;
- LIST_ENTRY *NameLink;
+ USER_VARIABLE_NODE *UserVariableNode;
+ LIST_ENTRY *Link;
+ USER_VARIABLE_NAME_NODE *UserVariableNameNode;
+ LIST_ENTRY *NameLink;
while (mUserVariableList.ForwardLink != &mUserVariableList) {
- Link = mUserVariableList.ForwardLink;
+ Link = mUserVariableList.ForwardLink;
UserVariableNode = USER_VARIABLE_FROM_LINK (Link);
RemoveEntryList (&UserVariableNode->Link);
while (UserVariableNode->NameLink.ForwardLink != &UserVariableNode->NameLink) {
- NameLink = UserVariableNode->NameLink.ForwardLink;
+ NameLink = UserVariableNode->NameLink.ForwardLink;
UserVariableNameNode = USER_VARIABLE_NAME_FROM_LINK (NameLink);
RemoveEntryList (&UserVariableNameNode->Link);
@@ -339,19 +343,19 @@ DestroyUserVariableNode ( **/
EFI_STATUS
CreateTimeBasedPayload (
- IN OUT UINTN *DataSize,
- IN OUT UINT8 **Data
+ IN OUT UINTN *DataSize,
+ IN OUT UINT8 **Data
)
{
- EFI_STATUS Status;
- UINT8 *NewData;
- UINT8 *Payload;
- UINTN PayloadSize;
- EFI_VARIABLE_AUTHENTICATION_2 *DescriptorData;
- UINTN DescriptorSize;
- EFI_TIME Time;
-
- if (Data == NULL || DataSize == NULL) {
+ EFI_STATUS Status;
+ UINT8 *NewData;
+ UINT8 *Payload;
+ UINTN PayloadSize;
+ EFI_VARIABLE_AUTHENTICATION_2 *DescriptorData;
+ UINTN DescriptorSize;
+ EFI_TIME Time;
+
+ if ((Data == NULL) || (DataSize == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -365,7 +369,7 @@ CreateTimeBasedPayload ( PayloadSize = *DataSize;
DescriptorSize = OFFSET_OF (EFI_VARIABLE_AUTHENTICATION_2, AuthInfo) + OFFSET_OF (WIN_CERTIFICATE_UEFI_GUID, CertData);
- NewData = (UINT8 *) AllocateZeroPool (DescriptorSize + PayloadSize);
+ NewData = (UINT8 *)AllocateZeroPool (DescriptorSize + PayloadSize);
if (NewData == NULL) {
return EFI_OUT_OF_RESOURCES;
}
@@ -374,7 +378,7 @@ CreateTimeBasedPayload ( CopyMem (NewData + DescriptorSize, Payload, PayloadSize);
}
- DescriptorData = (EFI_VARIABLE_AUTHENTICATION_2 *) (NewData);
+ DescriptorData = (EFI_VARIABLE_AUTHENTICATION_2 *)(NewData);
ZeroMem (&Time, sizeof (EFI_TIME));
Status = gRT->GetTime (&Time, NULL);
@@ -382,6 +386,7 @@ CreateTimeBasedPayload ( FreePool (NewData);
return Status;
}
+
Time.Pad1 = 0;
Time.Nanosecond = 0;
Time.TimeZone = 0;
@@ -423,19 +428,19 @@ CreateTimeBasedPayload ( **/
EFI_STATUS
CreateCounterBasedPayload (
- IN OUT UINTN *DataSize,
- IN OUT UINT8 **Data
+ IN OUT UINTN *DataSize,
+ IN OUT UINT8 **Data
)
{
- EFI_STATUS Status;
- UINT8 *NewData;
- UINT8 *Payload;
- UINTN PayloadSize;
- EFI_VARIABLE_AUTHENTICATION *DescriptorData;
- UINTN DescriptorSize;
- UINT64 MonotonicCount;
-
- if (Data == NULL || DataSize == NULL) {
+ EFI_STATUS Status;
+ UINT8 *NewData;
+ UINT8 *Payload;
+ UINTN PayloadSize;
+ EFI_VARIABLE_AUTHENTICATION *DescriptorData;
+ UINTN DescriptorSize;
+ UINT64 MonotonicCount;
+
+ if ((Data == NULL) || (DataSize == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -451,7 +456,7 @@ CreateCounterBasedPayload ( DescriptorSize = (OFFSET_OF (EFI_VARIABLE_AUTHENTICATION, AuthInfo)) + \
(OFFSET_OF (WIN_CERTIFICATE_UEFI_GUID, CertData)) + \
sizeof (EFI_CERT_BLOCK_RSA_2048_SHA256);
- NewData = (UINT8 *) AllocateZeroPool (DescriptorSize + PayloadSize);
+ NewData = (UINT8 *)AllocateZeroPool (DescriptorSize + PayloadSize);
if (NewData == NULL) {
return EFI_OUT_OF_RESOURCES;
}
@@ -460,13 +465,14 @@ CreateCounterBasedPayload ( CopyMem (NewData + DescriptorSize, Payload, PayloadSize);
}
- DescriptorData = (EFI_VARIABLE_AUTHENTICATION *) (NewData);
+ DescriptorData = (EFI_VARIABLE_AUTHENTICATION *)(NewData);
Status = gBS->GetNextMonotonicCount (&MonotonicCount);
if (EFI_ERROR (Status)) {
FreePool (NewData);
return Status;
}
+
DescriptorData->MonotonicCount = MonotonicCount;
DescriptorData->AuthInfo.Hdr.dwLength = OFFSET_OF (WIN_CERTIFICATE_UEFI_GUID, CertData) + sizeof (EFI_CERT_BLOCK_RSA_2048_SHA256);
@@ -496,38 +502,40 @@ DeleteUserVariable ( IN VARIABLE_CLEANUP_DATA *VariableCleanupData OPTIONAL
)
{
- EFI_STATUS Status;
- USER_VARIABLE_NODE *UserVariableNode;
- LIST_ENTRY *Link;
- USER_VARIABLE_NAME_NODE *UserVariableNameNode;
- LIST_ENTRY *NameLink;
- UINTN DataSize;
- UINT8 *Data;
+ EFI_STATUS Status;
+ USER_VARIABLE_NODE *UserVariableNode;
+ LIST_ENTRY *Link;
+ USER_VARIABLE_NAME_NODE *UserVariableNameNode;
+ LIST_ENTRY *NameLink;
+ UINTN DataSize;
+ UINT8 *Data;
for (Link = mUserVariableList.ForwardLink
- ;Link != &mUserVariableList
- ;Link = Link->ForwardLink) {
+ ; Link != &mUserVariableList
+ ; Link = Link->ForwardLink)
+ {
UserVariableNode = USER_VARIABLE_FROM_LINK (Link);
for (NameLink = UserVariableNode->NameLink.ForwardLink
- ;NameLink != &UserVariableNode->NameLink
- ;NameLink = NameLink->ForwardLink) {
+ ; NameLink != &UserVariableNode->NameLink
+ ; NameLink = NameLink->ForwardLink)
+ {
UserVariableNameNode = USER_VARIABLE_NAME_FROM_LINK (NameLink);
if (!UserVariableNameNode->Deleted && (DeleteAll || ((VariableCleanupData != NULL) && (VariableCleanupData->UserVariable[UserVariableNameNode->Index] == TRUE)))) {
DEBUG ((DEBUG_INFO, "PlatformVarCleanup - Delete variable: %g:%s\n", &UserVariableNode->Guid, UserVariableNameNode->Name));
if ((UserVariableNameNode->Attributes & EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS) != 0) {
DataSize = 0;
- Data = NULL;
- Status = CreateTimeBasedPayload (&DataSize, &Data);
+ Data = NULL;
+ Status = CreateTimeBasedPayload (&DataSize, &Data);
if (!EFI_ERROR (Status)) {
Status = gRT->SetVariable (UserVariableNameNode->Name, &UserVariableNode->Guid, UserVariableNameNode->Attributes, DataSize, Data);
FreePool (Data);
}
} else if ((UserVariableNameNode->Attributes & EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS) != 0) {
DataSize = 0;
- Data = NULL;
- Status = CreateCounterBasedPayload (&DataSize, &Data);
+ Data = NULL;
+ Status = CreateCounterBasedPayload (&DataSize, &Data);
if (!EFI_ERROR (Status)) {
Status = gRT->SetVariable (UserVariableNameNode->Name, &UserVariableNode->Guid, UserVariableNameNode->Attributes, DataSize, Data);
FreePool (Data);
@@ -535,6 +543,7 @@ DeleteUserVariable ( } else {
Status = gRT->SetVariable (UserVariableNameNode->Name, &UserVariableNode->Guid, 0, 0, NULL);
}
+
if (!EFI_ERROR (Status)) {
UserVariableNameNode->Deleted = TRUE;
} else {
@@ -569,21 +578,21 @@ DeleteUserVariable ( EFI_STATUS
EFIAPI
VariableCleanupHiiExtractConfig (
- IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
- IN CONST EFI_STRING Request,
- OUT EFI_STRING *Progress,
- OUT EFI_STRING *Results
+ IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
+ IN CONST EFI_STRING Request,
+ OUT EFI_STRING *Progress,
+ OUT EFI_STRING *Results
)
{
- EFI_STATUS Status;
- VARIABLE_CLEANUP_HII_PRIVATE_DATA *Private;
- UINTN BufferSize;
- EFI_STRING ConfigRequestHdr;
- EFI_STRING ConfigRequest;
- BOOLEAN AllocatedRequest;
- UINTN Size;
-
- if (Progress == NULL || Results == NULL) {
+ EFI_STATUS Status;
+ VARIABLE_CLEANUP_HII_PRIVATE_DATA *Private;
+ UINTN BufferSize;
+ EFI_STRING ConfigRequestHdr;
+ EFI_STRING ConfigRequest;
+ BOOLEAN AllocatedRequest;
+ UINTN Size;
+
+ if ((Progress == NULL) || (Results == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -601,7 +610,7 @@ VariableCleanupHiiExtractConfig ( //
// Convert buffer data to <ConfigResp> by helper function BlockToConfig().
//
- BufferSize = sizeof (VARIABLE_CLEANUP_DATA);
+ BufferSize = sizeof (VARIABLE_CLEANUP_DATA);
ConfigRequest = Request;
if ((Request == NULL) || (StrStr (Request, L"OFFSET") == NULL)) {
//
@@ -614,7 +623,7 @@ VariableCleanupHiiExtractConfig ( mVarStoreName,
Private->DriverHandle
);
- Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16);
+ Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16);
ConfigRequest = AllocateZeroPool (Size);
ASSERT (ConfigRequest != NULL);
AllocatedRequest = TRUE;
@@ -625,7 +634,7 @@ VariableCleanupHiiExtractConfig ( Status = Private->ConfigRouting->BlockToConfig (
Private->ConfigRouting,
ConfigRequest,
- (UINT8 *) &Private->VariableCleanupData,
+ (UINT8 *)&Private->VariableCleanupData,
BufferSize,
Results,
Progress
@@ -639,6 +648,7 @@ VariableCleanupHiiExtractConfig ( FreePool (ConfigRequest);
ConfigRequest = NULL;
}
+
//
// Set Progress string to the original request string or the string's null terminator.
//
@@ -662,17 +672,17 @@ UpdateUserVariableForm ( IN VARIABLE_CLEANUP_HII_PRIVATE_DATA *Private
)
{
- EFI_STRING_ID PromptStringToken;
- EFI_STRING_ID HelpStringToken;
- VOID *StartOpCodeHandle;
- VOID *EndOpCodeHandle;
- EFI_IFR_GUID_LABEL *StartLabel;
- EFI_IFR_GUID_LABEL *EndLabel;
- USER_VARIABLE_NODE *UserVariableNode;
- LIST_ENTRY *Link;
- USER_VARIABLE_NAME_NODE *UserVariableNameNode;
- LIST_ENTRY *NameLink;
- BOOLEAN Created;
+ EFI_STRING_ID PromptStringToken;
+ EFI_STRING_ID HelpStringToken;
+ VOID *StartOpCodeHandle;
+ VOID *EndOpCodeHandle;
+ EFI_IFR_GUID_LABEL *StartLabel;
+ EFI_IFR_GUID_LABEL *EndLabel;
+ USER_VARIABLE_NODE *UserVariableNode;
+ LIST_ENTRY *Link;
+ USER_VARIABLE_NAME_NODE *UserVariableNameNode;
+ LIST_ENTRY *NameLink;
+ BOOLEAN Created;
//
// Init OpCode Handle.
@@ -686,16 +696,16 @@ UpdateUserVariableForm ( //
// Create Hii Extend Label OpCode as the start opcode.
//
- StartLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (StartOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));
+ StartLabel = (EFI_IFR_GUID_LABEL *)HiiCreateGuidOpCode (StartOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));
StartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;
- StartLabel->Number = LABEL_START;
+ StartLabel->Number = LABEL_START;
//
// Create Hii Extend Label OpCode as the end opcode.
//
- EndLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (EndOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));
+ EndLabel = (EFI_IFR_GUID_LABEL *)HiiCreateGuidOpCode (EndOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));
EndLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;
- EndLabel->Number = LABEL_END;
+ EndLabel->Number = LABEL_END;
HiiUpdateForm (
Private->HiiHandle,
@@ -706,8 +716,9 @@ UpdateUserVariableForm ( );
for (Link = mUserVariableList.ForwardLink
- ;Link != &mUserVariableList
- ;Link = Link->ForwardLink) {
+ ; Link != &mUserVariableList
+ ; Link = Link->ForwardLink)
+ {
UserVariableNode = USER_VARIABLE_FROM_LINK (Link);
//
@@ -715,8 +726,9 @@ UpdateUserVariableForm ( //
Created = FALSE;
for (NameLink = UserVariableNode->NameLink.ForwardLink
- ;NameLink != &UserVariableNode->NameLink
- ;NameLink = NameLink->ForwardLink) {
+ ; NameLink != &UserVariableNode->NameLink
+ ; NameLink = NameLink->ForwardLink)
+ {
UserVariableNameNode = USER_VARIABLE_NAME_FROM_LINK (NameLink);
if (!UserVariableNameNode->Deleted) {
@@ -733,12 +745,12 @@ UpdateUserVariableForm ( // Only create opcode for the non-deleted variables.
//
PromptStringToken = HiiSetString (Private->HiiHandle, 0, UserVariableNameNode->PromptString, NULL);
- HelpStringToken = HiiSetString (Private->HiiHandle, 0, UserVariableNameNode->HelpString, NULL);
+ HelpStringToken = HiiSetString (Private->HiiHandle, 0, UserVariableNameNode->HelpString, NULL);
HiiCreateCheckBoxOpCode (
StartOpCodeHandle,
UserVariableNameNode->QuestionId,
VARIABLE_CLEANUP_VARSTORE_ID,
- (UINT16) (USER_VARIABLE_VAR_OFFSET + UserVariableNameNode->Index),
+ (UINT16)(USER_VARIABLE_VAR_OFFSET + UserVariableNameNode->Index),
PromptStringToken,
HelpStringToken,
EFI_IFR_FLAG_CALLBACK,
@@ -826,18 +838,19 @@ UpdateUserVariableForm ( EFI_STATUS
EFIAPI
VariableCleanupHiiRouteConfig (
- IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
- IN CONST EFI_STRING Configuration,
- OUT EFI_STRING *Progress
+ IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
+ IN CONST EFI_STRING Configuration,
+ OUT EFI_STRING *Progress
)
{
- EFI_STATUS Status;
- VARIABLE_CLEANUP_HII_PRIVATE_DATA *Private;
- UINTN BufferSize;
+ EFI_STATUS Status;
+ VARIABLE_CLEANUP_HII_PRIVATE_DATA *Private;
+ UINTN BufferSize;
if (Progress == NULL) {
return EFI_INVALID_PARAMETER;
}
+
*Progress = Configuration;
if (Configuration == NULL) {
@@ -861,19 +874,19 @@ VariableCleanupHiiRouteConfig ( // Convert <ConfigResp> to buffer data by helper function ConfigToBlock().
//
Status = Private->ConfigRouting->ConfigToBlock (
- Private->ConfigRouting,
- Configuration,
- (UINT8 *) &Private->VariableCleanupData,
- &BufferSize,
- Progress
- );
+ Private->ConfigRouting,
+ Configuration,
+ (UINT8 *)&Private->VariableCleanupData,
+ &BufferSize,
+ Progress
+ );
ASSERT_EFI_ERROR (Status);
DeleteUserVariable (FALSE, &Private->VariableCleanupData);
//
// For "F10" hotkey to refresh the form.
//
-// UpdateUserVariableForm (Private);
+ // UpdateUserVariableForm (Private);
return EFI_SUCCESS;
}
@@ -905,16 +918,16 @@ VariableCleanupHiiRouteConfig ( EFI_STATUS
EFIAPI
VariableCleanupHiiCallback (
- IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
- IN EFI_BROWSER_ACTION Action,
- IN EFI_QUESTION_ID QuestionId,
- IN UINT8 Type,
- IN EFI_IFR_TYPE_VALUE *Value,
- OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
+ IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
+ IN EFI_BROWSER_ACTION Action,
+ IN EFI_QUESTION_ID QuestionId,
+ IN UINT8 Type,
+ IN EFI_IFR_TYPE_VALUE *Value,
+ OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
)
{
- VARIABLE_CLEANUP_HII_PRIVATE_DATA *Private;
- VARIABLE_CLEANUP_DATA *VariableCleanupData;
+ VARIABLE_CLEANUP_HII_PRIVATE_DATA *Private;
+ VARIABLE_CLEANUP_DATA *VariableCleanupData;
Private = VARIABLE_CLEANUP_HII_PRIVATE_FROM_THIS (This);
@@ -929,7 +942,7 @@ VariableCleanupHiiCallback ( // Retrieve uncommitted data from Form Browser.
//
VariableCleanupData = &Private->VariableCleanupData;
- HiiGetBrowserData (&mVariableCleanupHiiGuid, mVarStoreName, sizeof (VARIABLE_CLEANUP_DATA), (UINT8 *) VariableCleanupData);
+ HiiGetBrowserData (&mVariableCleanupHiiGuid, mVarStoreName, sizeof (VARIABLE_CLEANUP_DATA), (UINT8 *)VariableCleanupData);
if (Action == EFI_BROWSER_ACTION_CHANGING) {
if (Value == NULL) {
return EFI_INVALID_PARAMETER;
@@ -938,8 +951,9 @@ VariableCleanupHiiCallback ( if ((Value == NULL) || (ActionRequest == NULL)) {
return EFI_INVALID_PARAMETER;
}
+
if ((QuestionId >= USER_VARIABLE_QUESTION_ID) && (QuestionId < USER_VARIABLE_QUESTION_ID + MAX_USER_VARIABLE_COUNT)) {
- if (Value->b){
+ if (Value->b) {
//
// Means one user variable checkbox is marked to delete but not press F10 or "Commit Changes and Exit" menu.
//
@@ -964,7 +978,7 @@ VariableCleanupHiiCallback ( } else {
switch (QuestionId) {
case SELECT_ALL_QUESTION_ID:
- if (Value->b){
+ if (Value->b) {
//
// Means the SelectAll checkbox is marked to delete all user variables but not press F10 or "Commit Changes and Exit" menu.
//
@@ -977,6 +991,7 @@ VariableCleanupHiiCallback ( SetMem (VariableCleanupData->UserVariable, sizeof (VariableCleanupData->UserVariable), FALSE);
mMarkedUserVariableCount = 0;
}
+
break;
case SAVE_AND_EXIT_QUESTION_ID:
DeleteUserVariable (FALSE, VariableCleanupData);
@@ -999,7 +1014,7 @@ VariableCleanupHiiCallback ( //
// Pass changed uncommitted data back to Form Browser.
//
- HiiSetBrowserData (&mVariableCleanupHiiGuid, mVarStoreName, sizeof (VARIABLE_CLEANUP_DATA), (UINT8 *) VariableCleanupData, NULL);
+ HiiSetBrowserData (&mVariableCleanupHiiGuid, mVarStoreName, sizeof (VARIABLE_CLEANUP_DATA), (UINT8 *)VariableCleanupData, NULL);
return EFI_SUCCESS;
}
@@ -1022,13 +1037,13 @@ VariableCleanupHiiCallback ( EFI_STATUS
EFIAPI
PlatformVarCleanup (
- IN VAR_ERROR_FLAG Flag,
- IN VAR_CLEANUP_TYPE Type
+ IN VAR_ERROR_FLAG Flag,
+ IN VAR_CLEANUP_TYPE Type
)
{
- EFI_STATUS Status;
- EFI_FORM_BROWSER2_PROTOCOL *FormBrowser2;
- VARIABLE_CLEANUP_HII_PRIVATE_DATA *Private;
+ EFI_STATUS Status;
+ EFI_FORM_BROWSER2_PROTOCOL *FormBrowser2;
+ VARIABLE_CLEANUP_HII_PRIVATE_DATA *Private;
if (!mEndOfDxe) {
//
@@ -1037,7 +1052,7 @@ PlatformVarCleanup ( return EFI_UNSUPPORTED;
}
- if ((Type >= VarCleanupMax) || ((Flag & ((VAR_ERROR_FLAG) (VAR_ERROR_FLAG_SYSTEM_ERROR & VAR_ERROR_FLAG_USER_ERROR))) == 0)) {
+ if ((Type >= VarCleanupMax) || ((Flag & ((VAR_ERROR_FLAG)(VAR_ERROR_FLAG_SYSTEM_ERROR & VAR_ERROR_FLAG_USER_ERROR))) == 0)) {
return EFI_INVALID_PARAMETER;
}
@@ -1048,7 +1063,7 @@ PlatformVarCleanup ( return EFI_SUCCESS;
}
- if ((Flag & (~((VAR_ERROR_FLAG) VAR_ERROR_FLAG_SYSTEM_ERROR))) == 0) {
+ if ((Flag & (~((VAR_ERROR_FLAG)VAR_ERROR_FLAG_SYSTEM_ERROR))) == 0) {
//
// This sample does not support system variables cleanup.
//
@@ -1080,7 +1095,7 @@ PlatformVarCleanup ( //
// Locate FormBrowser2 protocol.
//
- Status = gBS->LocateProtocol (&gEfiFormBrowser2ProtocolGuid, NULL, (VOID **) &FormBrowser2);
+ Status = gBS->LocateProtocol (&gEfiFormBrowser2ProtocolGuid, NULL, (VOID **)&FormBrowser2);
if (EFI_ERROR (Status)) {
return Status;
}
@@ -1090,7 +1105,7 @@ PlatformVarCleanup ( return EFI_OUT_OF_RESOURCES;
}
- Private->Signature = VARIABLE_CLEANUP_HII_PRIVATE_SIGNATURE;
+ Private->Signature = VARIABLE_CLEANUP_HII_PRIVATE_SIGNATURE;
Private->ConfigAccess.ExtractConfig = VariableCleanupHiiExtractConfig;
Private->ConfigAccess.RouteConfig = VariableCleanupHiiRouteConfig;
Private->ConfigAccess.Callback = VariableCleanupHiiCallback;
@@ -1098,7 +1113,7 @@ PlatformVarCleanup ( Status = gBS->LocateProtocol (
&gEfiHiiConfigRoutingProtocolGuid,
NULL,
- (VOID **) &Private->ConfigRouting
+ (VOID **)&Private->ConfigRouting
);
if (EFI_ERROR (Status)) {
goto Done;
@@ -1163,6 +1178,7 @@ Done: NULL
);
}
+
if (Private->HiiHandle != NULL) {
HiiRemovePackages (Private->HiiHandle);
}
@@ -1225,11 +1241,11 @@ PlatformVarCleanupEndOfDxeEvent ( EFI_STATUS
EFIAPI
PlatformVarCleanupLibConstructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
mLastVarErrorFlag = InternalGetVarErrorFlag ();
DEBUG ((DEBUG_INFO, "mLastVarErrorFlag - 0x%02x\n", mLastVarErrorFlag));
@@ -1262,11 +1278,11 @@ PlatformVarCleanupLibConstructor ( EFI_STATUS
EFIAPI
PlatformVarCleanupLibDestructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
//
// Close the End of DXE event.
diff --git a/MdeModulePkg/Library/ResetUtilityLib/ResetUtility.c b/MdeModulePkg/Library/ResetUtilityLib/ResetUtility.c index bb151d0331..50131a431f 100644 --- a/MdeModulePkg/Library/ResetUtilityLib/ResetUtility.c +++ b/MdeModulePkg/Library/ResetUtilityLib/ResetUtility.c @@ -15,8 +15,8 @@ #pragma pack(1)
typedef struct {
- CHAR16 NullTerminator;
- GUID ResetSubtype;
+ CHAR16 NullTerminator;
+ GUID ResetSubtype;
} RESET_UTILITY_GUID_SPECIFIC_RESET_DATA;
#pragma pack()
@@ -45,8 +45,8 @@ STATIC_ASSERT ( VOID
EFIAPI
ResetSystemWithSubtype (
- IN EFI_RESET_TYPE ResetType,
- IN CONST GUID *ResetSubtype
+ IN EFI_RESET_TYPE ResetType,
+ IN CONST GUID *ResetSubtype
)
{
RESET_UTILITY_GUID_SPECIFIC_RESET_DATA ResetData;
@@ -79,7 +79,7 @@ ResetSystemWithSubtype ( VOID
EFIAPI
ResetPlatformSpecificGuid (
- IN CONST GUID *ResetSubtype
+ IN CONST GUID *ResetSubtype
)
{
ResetSystemWithSubtype (EfiResetPlatformSpecific, ResetSubtype);
@@ -110,8 +110,8 @@ GetResetPlatformSpecificGuid ( IN CONST VOID *ResetData
)
{
- UINTN ResetDataStringSize;
- GUID *ResetSubtypeGuid;
+ UINTN ResetDataStringSize;
+ GUID *ResetSubtypeGuid;
//
// Make sure parameters are valid
@@ -130,11 +130,12 @@ GetResetPlatformSpecificGuid ( // Now, assuming that we have enough data for a GUID after the string, the
// GUID should be immediately after the string itself.
//
- if ((ResetDataStringSize < DataSize) && (DataSize - ResetDataStringSize) >= sizeof (GUID)) {
+ if ((ResetDataStringSize < DataSize) && ((DataSize - ResetDataStringSize) >= sizeof (GUID))) {
ResetSubtypeGuid = (GUID *)((UINT8 *)ResetData + ResetDataStringSize);
DEBUG ((DEBUG_VERBOSE, "%a - Detected reset subtype %g...\n", __FUNCTION__, ResetSubtypeGuid));
return ResetSubtypeGuid;
}
+
return NULL;
}
@@ -174,12 +175,12 @@ GetResetPlatformSpecificGuid ( RETURN_STATUS
EFIAPI
BuildResetData (
- IN OUT UINTN *ResetDataSize,
- IN OUT VOID *ResetData,
- IN CONST GUID *ResetSubtype OPTIONAL,
- IN CONST CHAR16 *ResetString OPTIONAL,
- IN UINTN ExtraDataSize OPTIONAL,
- IN CONST VOID *ExtraData OPTIONAL
+ IN OUT UINTN *ResetDataSize,
+ IN OUT VOID *ResetData,
+ IN CONST GUID *ResetSubtype OPTIONAL,
+ IN CONST CHAR16 *ResetString OPTIONAL,
+ IN UINTN ExtraDataSize OPTIONAL,
+ IN CONST VOID *ExtraData OPTIONAL
)
{
UINTN ResetStringSize;
@@ -192,16 +193,18 @@ BuildResetData ( if (ResetDataSize == NULL) {
return RETURN_INVALID_PARAMETER;
}
+
//
// If extra data is indicated, but pointer is NULL.
//
- if (ExtraDataSize > 0 && ExtraData == NULL) {
+ if ((ExtraDataSize > 0) && (ExtraData == NULL)) {
return RETURN_INVALID_PARAMETER;
}
+
//
// If extra data is indicated, but no subtype GUID is supplied.
//
- if (ResetSubtype == NULL && ExtraDataSize > 0) {
+ if ((ResetSubtype == NULL) && (ExtraDataSize > 0)) {
return RETURN_INVALID_PARAMETER;
}
@@ -229,6 +232,7 @@ BuildResetData ( *ResetDataSize = ResetDataBufferSize;
return RETURN_BUFFER_TOO_SMALL;
}
+
*ResetDataSize = ResetDataBufferSize;
if (ResetData == NULL) {
return RETURN_INVALID_PARAMETER;
@@ -244,6 +248,7 @@ BuildResetData ( CopyMem (Data, ResetSubtype, sizeof (GUID));
Data += sizeof (GUID);
}
+
if (ExtraDataSize > 0) {
CopyMem (Data, ExtraData, ExtraDataSize);
}
diff --git a/MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/ReportStatusCodeLib.c b/MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/ReportStatusCodeLib.c index dc7fcf7a2d..fdda288d33 100644 --- a/MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/ReportStatusCodeLib.c +++ b/MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/ReportStatusCodeLib.c @@ -21,7 +21,6 @@ #include <Guid/StatusCodeDataTypeDebug.h>
#include <Guid/EventGroup.h>
-
//
// Define the maximum extended data size that is supported when a status code is reported.
//
@@ -56,8 +55,8 @@ InternalGetReportStatusCode ( //
// Check gBS just in case ReportStatusCode is called before gBS is initialized.
//
- if (gBS != NULL && gBS->LocateProtocol != NULL) {
- Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID**) &mReportStatusCodeLibStatusCodeProtocol);
+ if ((gBS != NULL) && (gBS->LocateProtocol != NULL)) {
+ Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID **)&mReportStatusCodeLibStatusCodeProtocol);
if (EFI_ERROR (Status)) {
mReportStatusCodeLibStatusCodeProtocol = NULL;
}
@@ -74,14 +73,15 @@ InternalGetReportStatusCode ( VOID
EFIAPI
ReportStatusCodeLibVirtualAddressChange (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
if (mReportStatusCodeLibStatusCodeProtocol == NULL) {
return;
}
- EfiConvertPointer (0, (VOID **) &mReportStatusCodeLibStatusCodeProtocol);
+
+ EfiConvertPointer (0, (VOID **)&mReportStatusCodeLibStatusCodeProtocol);
}
/**
@@ -94,8 +94,8 @@ ReportStatusCodeLibVirtualAddressChange ( VOID
EFIAPI
ReportStatusCodeLibExitBootServices (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
//
@@ -121,8 +121,8 @@ ReportStatusCodeLibExitBootServices ( EFI_STATUS
EFIAPI
ReportStatusCodeLibConstructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
@@ -217,16 +217,17 @@ ReportStatusCodeLibDestructor ( **/
EFI_STATUS
InternalReportStatusCode (
- IN EFI_STATUS_CODE_TYPE Type,
- IN EFI_STATUS_CODE_VALUE Value,
- IN UINT32 Instance,
- IN CONST EFI_GUID *CallerId OPTIONAL,
- IN EFI_STATUS_CODE_DATA *Data OPTIONAL
+ IN EFI_STATUS_CODE_TYPE Type,
+ IN EFI_STATUS_CODE_VALUE Value,
+ IN UINT32 Instance,
+ IN CONST EFI_GUID *CallerId OPTIONAL,
+ IN EFI_STATUS_CODE_DATA *Data OPTIONAL
)
{
- if ((ReportProgressCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) ||
- (ReportErrorCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) ||
- (ReportDebugCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE)) {
+ if ((ReportProgressCodeEnabled () && (((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE)) ||
+ (ReportErrorCodeEnabled () && (((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE)) ||
+ (ReportDebugCodeEnabled () && (((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE)))
+ {
//
// If mReportStatusCodeLibStatusCodeProtocol is NULL, then check if Report Status Code Protocol is available in system.
//
@@ -244,7 +245,6 @@ InternalReportStatusCode ( return EFI_UNSUPPORTED;
}
-
/**
Converts a status code to an 8-bit POST code value.
@@ -283,15 +283,16 @@ CodeTypeToPostCode ( // Convert Value to an 8 bit post code
//
if (((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) ||
- ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) ) {
- *PostCode = (UINT8) ((((Value & EFI_STATUS_CODE_CLASS_MASK) >> 24) << 5) |
- (((Value & EFI_STATUS_CODE_SUBCLASS_MASK) >> 16) & 0x1f));
+ ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE))
+ {
+ *PostCode = (UINT8)((((Value & EFI_STATUS_CODE_CLASS_MASK) >> 24) << 5) |
+ (((Value & EFI_STATUS_CODE_SUBCLASS_MASK) >> 16) & 0x1f));
return TRUE;
}
+
return FALSE;
}
-
/**
Extracts ASSERT() information from a status code structure.
@@ -345,17 +346,18 @@ ReportStatusCodeExtractAssertInfo ( if (((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) &&
((CodeType & EFI_STATUS_CODE_SEVERITY_MASK) == EFI_ERROR_UNRECOVERED) &&
- ((Value & EFI_STATUS_CODE_OPERATION_MASK) == EFI_SW_EC_ILLEGAL_SOFTWARE_STATE)) {
+ ((Value & EFI_STATUS_CODE_OPERATION_MASK) == EFI_SW_EC_ILLEGAL_SOFTWARE_STATE))
+ {
AssertData = (EFI_DEBUG_ASSERT_DATA *)(Data + 1);
*Filename = (CHAR8 *)(AssertData + 1);
*Description = *Filename + AsciiStrLen (*Filename) + 1;
*LineNumber = AssertData->LineNumber;
return TRUE;
}
+
return FALSE;
}
-
/**
Extracts DEBUG() information from a status code structure.
@@ -424,13 +426,12 @@ ReportStatusCodeExtractDebugInfo ( // 64-bit aligned is a must, otherwise retrieving 64-bit parameter from BASE_LIST will
// cause unalignment exception.
//
- *Marker = (BASE_LIST) (DebugInfo + 1);
+ *Marker = (BASE_LIST)(DebugInfo + 1);
*Format = (CHAR8 *)(((UINT64 *)*Marker) + 12);
return TRUE;
}
-
/**
Reports a status code.
@@ -462,7 +463,6 @@ ReportStatusCode ( return InternalReportStatusCode (Type, Value, 0, &gEfiCallerIdGuid, NULL);
}
-
/**
Reports a status code with a Device Path Protocol as the extended data.
@@ -508,7 +508,6 @@ ReportStatusCodeWithDevicePath ( );
}
-
/**
Reports a status code with an extended data buffer.
@@ -564,7 +563,6 @@ ReportStatusCodeWithExtendedData ( );
}
-
/**
Reports a status code with full parameters.
@@ -630,13 +628,13 @@ ReportStatusCodeEx ( //
// Use Buffer instead of allocating if possible.
//
- StatusCodeData = (EFI_STATUS_CODE_DATA *) StatusCodeBuffer;
+ StatusCodeData = (EFI_STATUS_CODE_DATA *)StatusCodeBuffer;
} else {
if (mHaveExitedBootServices) {
return EFI_OUT_OF_RESOURCES;
}
- if (gBS == NULL || gBS->AllocatePool == NULL || gBS->FreePool == NULL) {
+ if ((gBS == NULL) || (gBS->AllocatePool == NULL) || (gBS->FreePool == NULL)) {
return EFI_UNSUPPORTED;
}
@@ -653,11 +651,12 @@ ReportStatusCodeEx ( //
// Fill in the extended data header
//
- StatusCodeData->HeaderSize = (UINT16) sizeof (EFI_STATUS_CODE_DATA);
- StatusCodeData->Size = (UINT16) ExtendedDataSize;
+ StatusCodeData->HeaderSize = (UINT16)sizeof (EFI_STATUS_CODE_DATA);
+ StatusCodeData->Size = (UINT16)ExtendedDataSize;
if (ExtendedDataGuid == NULL) {
ExtendedDataGuid = &gEfiStatusCodeSpecificDataGuid;
}
+
CopyGuid (&StatusCodeData->Type, ExtendedDataGuid);
//
@@ -673,19 +672,19 @@ ReportStatusCodeEx ( if (CallerId == NULL) {
CallerId = &gEfiCallerIdGuid;
}
+
Status = InternalReportStatusCode (Type, Value, Instance, CallerId, StatusCodeData);
//
// Free the allocated buffer
//
- if (StatusCodeData != (EFI_STATUS_CODE_DATA *) StatusCodeBuffer) {
+ if (StatusCodeData != (EFI_STATUS_CODE_DATA *)StatusCodeBuffer) {
gBS->FreePool (StatusCodeData);
}
return Status;
}
-
/**
Returns TRUE if status codes of type EFI_PROGRESS_CODE are enabled
@@ -704,10 +703,9 @@ ReportProgressCodeEnabled ( VOID
)
{
- return (BOOLEAN) ((PcdGet8 (PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED) != 0);
+ return (BOOLEAN)((PcdGet8 (PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED) != 0);
}
-
/**
Returns TRUE if status codes of type EFI_ERROR_CODE are enabled
@@ -726,10 +724,9 @@ ReportErrorCodeEnabled ( VOID
)
{
- return (BOOLEAN) ((PcdGet8 (PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED) != 0);
+ return (BOOLEAN)((PcdGet8 (PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED) != 0);
}
-
/**
Returns TRUE if status codes of type EFI_DEBUG_CODE are enabled
@@ -748,5 +745,5 @@ ReportDebugCodeEnabled ( VOID
)
{
- return (BOOLEAN) ((PcdGet8 (PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED) != 0);
+ return (BOOLEAN)((PcdGet8 (PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED) != 0);
}
diff --git a/MdeModulePkg/Library/RuntimeResetSystemLib/RuntimeResetSystemLib.c b/MdeModulePkg/Library/RuntimeResetSystemLib/RuntimeResetSystemLib.c index f4490180cc..59b5c2b9d8 100644 --- a/MdeModulePkg/Library/RuntimeResetSystemLib/RuntimeResetSystemLib.c +++ b/MdeModulePkg/Library/RuntimeResetSystemLib/RuntimeResetSystemLib.c @@ -12,8 +12,8 @@ #include <Library/UefiBootServicesTableLib.h>
#include <Library/DebugLib.h>
-EFI_EVENT mRuntimeResetSystemLibVirtualAddressChangeEvent;
-EFI_RUNTIME_SERVICES *mInternalRT;
+EFI_EVENT mRuntimeResetSystemLibVirtualAddressChangeEvent;
+EFI_RUNTIME_SERVICES *mInternalRT;
/**
This function causes a system-wide reset (cold reset), in which
@@ -76,8 +76,8 @@ ResetShutdown ( VOID
EFIAPI
ResetPlatformSpecific (
- IN UINTN DataSize,
- IN VOID *ResetData
+ IN UINTN DataSize,
+ IN VOID *ResetData
)
{
mInternalRT->ResetSystem (EfiResetPlatformSpecific, EFI_SUCCESS, DataSize, ResetData);
@@ -98,10 +98,10 @@ ResetPlatformSpecific ( VOID
EFIAPI
ResetSystem (
- IN EFI_RESET_TYPE ResetType,
- IN EFI_STATUS ResetStatus,
- IN UINTN DataSize,
- IN VOID *ResetData OPTIONAL
+ IN EFI_RESET_TYPE ResetType,
+ IN EFI_STATUS ResetStatus,
+ IN UINTN DataSize,
+ IN VOID *ResetData OPTIONAL
)
{
mInternalRT->ResetSystem (ResetType, ResetStatus, DataSize, ResetData);
@@ -117,11 +117,11 @@ ResetSystem ( VOID
EFIAPI
RuntimeResetSystemLibVirtualAddressChange (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
- mInternalRT->ConvertPointer (0, (VOID **) &mInternalRT);
+ mInternalRT->ConvertPointer (0, (VOID **)&mInternalRT);
}
/**
@@ -139,8 +139,8 @@ RuntimeResetSystemLibVirtualAddressChange ( EFI_STATUS
EFIAPI
RuntimeResetSystemLibConstruct (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
@@ -181,8 +181,8 @@ RuntimeResetSystemLibConstruct ( EFI_STATUS
EFIAPI
RuntimeResetSystemLibDeconstruct (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
diff --git a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c index 7cdf5d0b79..3efe56e056 100644 --- a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c +++ b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c @@ -21,14 +21,13 @@ SPDX-License-Identifier: BSD-2-Clause-Patent **/
-
#include "SmmCorePerformanceLibInternal.h"
-#define STRING_SIZE (FPDT_STRING_EVENT_RECORD_NAME_LENGTH * sizeof (CHAR8))
-#define FIRMWARE_RECORD_BUFFER 0x1000
-#define CACHE_HANDLE_GUID_COUNT 0x100
+#define STRING_SIZE (FPDT_STRING_EVENT_RECORD_NAME_LENGTH * sizeof (CHAR8))
+#define FIRMWARE_RECORD_BUFFER 0x1000
+#define CACHE_HANDLE_GUID_COUNT 0x100
-SMM_BOOT_PERFORMANCE_TABLE *mSmmBootPerformanceTable = NULL;
+SMM_BOOT_PERFORMANCE_TABLE *mSmmBootPerformanceTable = NULL;
typedef struct {
EFI_HANDLE Handle;
@@ -36,24 +35,24 @@ typedef struct { EFI_GUID ModuleGuid;
} HANDLE_GUID_MAP;
-HANDLE_GUID_MAP mCacheHandleGuidTable[CACHE_HANDLE_GUID_COUNT];
-UINTN mCachePairCount = 0;
+HANDLE_GUID_MAP mCacheHandleGuidTable[CACHE_HANDLE_GUID_COUNT];
+UINTN mCachePairCount = 0;
-UINT32 mPerformanceLength = sizeof (SMM_BOOT_PERFORMANCE_TABLE);
-UINT32 mMaxPerformanceLength = 0;
-UINT32 mLoadImageCount = 0;
-BOOLEAN mFpdtDataIsReported = FALSE;
-BOOLEAN mLackSpaceIsReport = FALSE;
-CHAR8 *mPlatformLanguage = NULL;
-SPIN_LOCK mSmmFpdtLock;
+UINT32 mPerformanceLength = sizeof (SMM_BOOT_PERFORMANCE_TABLE);
+UINT32 mMaxPerformanceLength = 0;
+UINT32 mLoadImageCount = 0;
+BOOLEAN mFpdtDataIsReported = FALSE;
+BOOLEAN mLackSpaceIsReport = FALSE;
+CHAR8 *mPlatformLanguage = NULL;
+SPIN_LOCK mSmmFpdtLock;
PERFORMANCE_PROPERTY mPerformanceProperty;
-UINT32 mCachedLength = 0;
-UINT32 mBootRecordSize = 0;
+UINT32 mCachedLength = 0;
+UINT32 mBootRecordSize = 0;
//
// Interfaces for SMM PerformanceMeasurement Protocol.
//
-EDKII_PERFORMANCE_MEASUREMENT_PROTOCOL mPerformanceMeasurementInterface = {
+EDKII_PERFORMANCE_MEASUREMENT_PROTOCOL mPerformanceMeasurementInterface = {
CreatePerformanceMeasurement,
};
@@ -68,9 +67,9 @@ EDKII_PERFORMANCE_MEASUREMENT_PROTOCOL mPerformanceMeasurementInterface = { **/
EFI_STATUS
GetFpdtRecordPtr (
- IN UINT8 RecordSize,
- IN OUT FPDT_RECORD_PTR *FpdtRecordPtr
-)
+ IN UINT8 RecordSize,
+ IN OUT FPDT_RECORD_PTR *FpdtRecordPtr
+ )
{
if (mFpdtDataIsReported) {
//
@@ -81,12 +80,13 @@ GetFpdtRecordPtr ( DEBUG ((DEBUG_INFO, "SmmCorePerformanceLib: No enough space to save boot records\n"));
mLackSpaceIsReport = TRUE;
}
+
return EFI_OUT_OF_RESOURCES;
} else {
//
// Covert buffer to FPDT Ptr Union type.
//
- FpdtRecordPtr->RecordHeader = (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER *)((UINT8*)mSmmBootPerformanceTable + mSmmBootPerformanceTable->Header.Length);
+ FpdtRecordPtr->RecordHeader = (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER *)((UINT8 *)mSmmBootPerformanceTable + mSmmBootPerformanceTable->Header.Length);
}
} else {
//
@@ -97,24 +97,26 @@ GetFpdtRecordPtr ( mPerformanceLength,
mPerformanceLength + RecordSize + FIRMWARE_RECORD_BUFFER,
mSmmBootPerformanceTable
- );
+ );
if (mSmmBootPerformanceTable == NULL) {
return EFI_OUT_OF_RESOURCES;
}
+
mSmmBootPerformanceTable->Header.Length = mPerformanceLength;
- mMaxPerformanceLength = mPerformanceLength + RecordSize + FIRMWARE_RECORD_BUFFER;
+ mMaxPerformanceLength = mPerformanceLength + RecordSize + FIRMWARE_RECORD_BUFFER;
}
+
//
// Covert buffer to FPDT Ptr Union type.
//
- FpdtRecordPtr->RecordHeader = (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER *)((UINT8*)mSmmBootPerformanceTable + mSmmBootPerformanceTable->Header.Length);
+ FpdtRecordPtr->RecordHeader = (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER *)((UINT8 *)mSmmBootPerformanceTable + mSmmBootPerformanceTable->Header.Length);
}
+
FpdtRecordPtr->RecordHeader->Length = 0;
return EFI_SUCCESS;
}
-
/**
Check whether the Token is a known one which is uesed by core.
@@ -133,16 +135,17 @@ IsKnownTokens ( return FALSE;
}
- if (AsciiStrCmp (Token, SEC_TOK) == 0 ||
- AsciiStrCmp (Token, PEI_TOK) == 0 ||
- AsciiStrCmp (Token, DXE_TOK) == 0 ||
- AsciiStrCmp (Token, BDS_TOK) == 0 ||
- AsciiStrCmp (Token, DRIVERBINDING_START_TOK) == 0 ||
- AsciiStrCmp (Token, DRIVERBINDING_SUPPORT_TOK) == 0 ||
- AsciiStrCmp (Token, DRIVERBINDING_STOP_TOK) == 0 ||
- AsciiStrCmp (Token, LOAD_IMAGE_TOK) == 0 ||
- AsciiStrCmp (Token, START_IMAGE_TOK) == 0 ||
- AsciiStrCmp (Token, PEIM_TOK) == 0) {
+ if ((AsciiStrCmp (Token, SEC_TOK) == 0) ||
+ (AsciiStrCmp (Token, PEI_TOK) == 0) ||
+ (AsciiStrCmp (Token, DXE_TOK) == 0) ||
+ (AsciiStrCmp (Token, BDS_TOK) == 0) ||
+ (AsciiStrCmp (Token, DRIVERBINDING_START_TOK) == 0) ||
+ (AsciiStrCmp (Token, DRIVERBINDING_SUPPORT_TOK) == 0) ||
+ (AsciiStrCmp (Token, DRIVERBINDING_STOP_TOK) == 0) ||
+ (AsciiStrCmp (Token, LOAD_IMAGE_TOK) == 0) ||
+ (AsciiStrCmp (Token, START_IMAGE_TOK) == 0) ||
+ (AsciiStrCmp (Token, PEIM_TOK) == 0))
+ {
return TRUE;
} else {
return FALSE;
@@ -160,19 +163,20 @@ Check whether the ID is a known one which map to the known Token. **/
BOOLEAN
IsKnownID (
- IN UINT32 Identifier
+ IN UINT32 Identifier
)
{
- if (Identifier == MODULE_START_ID ||
- Identifier == MODULE_END_ID ||
- Identifier == MODULE_LOADIMAGE_START_ID ||
- Identifier == MODULE_LOADIMAGE_END_ID ||
- Identifier == MODULE_DB_START_ID ||
- Identifier == MODULE_DB_END_ID ||
- Identifier == MODULE_DB_SUPPORT_START_ID ||
- Identifier == MODULE_DB_SUPPORT_END_ID ||
- Identifier == MODULE_DB_STOP_START_ID ||
- Identifier == MODULE_DB_STOP_END_ID) {
+ if ((Identifier == MODULE_START_ID) ||
+ (Identifier == MODULE_END_ID) ||
+ (Identifier == MODULE_LOADIMAGE_START_ID) ||
+ (Identifier == MODULE_LOADIMAGE_END_ID) ||
+ (Identifier == MODULE_DB_START_ID) ||
+ (Identifier == MODULE_DB_END_ID) ||
+ (Identifier == MODULE_DB_SUPPORT_START_ID) ||
+ (Identifier == MODULE_DB_SUPPORT_END_ID) ||
+ (Identifier == MODULE_DB_STOP_START_ID) ||
+ (Identifier == MODULE_DB_STOP_END_ID))
+ {
return TRUE;
} else {
return FALSE;
@@ -205,34 +209,39 @@ GetFpdtRecordId ( // Token to Id.
//
if (String != NULL) {
- if (AsciiStrCmp (String, START_IMAGE_TOK) == 0) { // "StartImage:"
+ if (AsciiStrCmp (String, START_IMAGE_TOK) == 0) {
+ // "StartImage:"
if (Attribute == PerfStartEntry) {
- *ProgressID = MODULE_START_ID;
+ *ProgressID = MODULE_START_ID;
} else {
- *ProgressID = MODULE_END_ID;
+ *ProgressID = MODULE_END_ID;
}
- } else if (AsciiStrCmp (String, LOAD_IMAGE_TOK) == 0) { // "LoadImage:"
+ } else if (AsciiStrCmp (String, LOAD_IMAGE_TOK) == 0) {
+ // "LoadImage:"
if (Attribute == PerfStartEntry) {
- *ProgressID = MODULE_LOADIMAGE_START_ID;
+ *ProgressID = MODULE_LOADIMAGE_START_ID;
} else {
- *ProgressID = MODULE_LOADIMAGE_END_ID;
+ *ProgressID = MODULE_LOADIMAGE_END_ID;
}
- } else { // Pref used in Modules
+ } else {
+ // Pref used in Modules
if (Attribute == PerfStartEntry) {
- *ProgressID = PERF_INMODULE_START_ID;
+ *ProgressID = PERF_INMODULE_START_ID;
} else {
- *ProgressID = PERF_INMODULE_END_ID;
+ *ProgressID = PERF_INMODULE_END_ID;
}
}
- } else if (Handle != NULL) { // Pref used in Modules
+ } else if (Handle != NULL) {
+ // Pref used in Modules
if (Attribute == PerfStartEntry) {
- *ProgressID = PERF_INMODULE_START_ID;
+ *ProgressID = PERF_INMODULE_START_ID;
} else {
- *ProgressID = PERF_INMODULE_END_ID;
+ *ProgressID = PERF_INMODULE_END_ID;
}
} else {
return EFI_UNSUPPORTED;
}
+
return EFI_SUCCESS;
}
@@ -253,26 +262,26 @@ GetFpdtRecordId ( EFI_STATUS
EFIAPI
GetModuleInfoFromHandle (
- IN EFI_HANDLE Handle,
- OUT CHAR8 *NameString,
- IN UINTN BufferSize,
- OUT EFI_GUID *ModuleGuid OPTIONAL
+ IN EFI_HANDLE Handle,
+ OUT CHAR8 *NameString,
+ IN UINTN BufferSize,
+ OUT EFI_GUID *ModuleGuid OPTIONAL
)
{
- EFI_STATUS Status;
- EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
- EFI_DRIVER_BINDING_PROTOCOL *DriverBinding;
- CHAR8 *PdbFileName;
- EFI_GUID *TempGuid;
- UINTN StartIndex;
- UINTN Index;
- INTN Count;
- BOOLEAN ModuleGuidIsGet;
- UINTN StringSize;
- CHAR16 *StringPtr;
- MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvFilePath;
-
- if (NameString == NULL || BufferSize == 0) {
+ EFI_STATUS Status;
+ EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
+ EFI_DRIVER_BINDING_PROTOCOL *DriverBinding;
+ CHAR8 *PdbFileName;
+ EFI_GUID *TempGuid;
+ UINTN StartIndex;
+ UINTN Index;
+ INTN Count;
+ BOOLEAN ModuleGuidIsGet;
+ UINTN StringSize;
+ CHAR16 *StringPtr;
+ MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvFilePath;
+
+ if ((NameString == NULL) || (BufferSize == 0)) {
return EFI_INVALID_PARAMETER;
}
@@ -289,14 +298,14 @@ GetModuleInfoFromHandle ( }
}
- Status = EFI_INVALID_PARAMETER;
+ Status = EFI_INVALID_PARAMETER;
LoadedImage = NULL;
ModuleGuidIsGet = FALSE;
//
// Initialize GUID as zero value.
//
- TempGuid = &gZeroGuid;
+ TempGuid = &gZeroGuid;
//
// Initialize it as "" string.
//
@@ -307,49 +316,50 @@ GetModuleInfoFromHandle ( // Try Handle as ImageHandle.
//
Status = gBS->HandleProtocol (
- Handle,
- &gEfiLoadedImageProtocolGuid,
- (VOID**) &LoadedImage
- );
+ Handle,
+ &gEfiLoadedImageProtocolGuid,
+ (VOID **)&LoadedImage
+ );
if (EFI_ERROR (Status)) {
//
// Try Handle as Controller Handle
//
Status = gBS->OpenProtocol (
- Handle,
- &gEfiDriverBindingProtocolGuid,
- (VOID **) &DriverBinding,
- NULL,
- NULL,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
+ Handle,
+ &gEfiDriverBindingProtocolGuid,
+ (VOID **)&DriverBinding,
+ NULL,
+ NULL,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL
+ );
if (!EFI_ERROR (Status)) {
//
// Get Image protocol from ImageHandle
//
Status = gBS->HandleProtocol (
- DriverBinding->ImageHandle,
- &gEfiLoadedImageProtocolGuid,
- (VOID**) &LoadedImage
- );
+ DriverBinding->ImageHandle,
+ &gEfiLoadedImageProtocolGuid,
+ (VOID **)&LoadedImage
+ );
}
}
}
- if (!EFI_ERROR (Status) && LoadedImage != NULL) {
+ if (!EFI_ERROR (Status) && (LoadedImage != NULL)) {
//
// Get Module Guid from DevicePath.
//
- if (LoadedImage->FilePath != NULL &&
- LoadedImage->FilePath->Type == MEDIA_DEVICE_PATH &&
- LoadedImage->FilePath->SubType == MEDIA_PIWG_FW_FILE_DP
- ) {
+ if ((LoadedImage->FilePath != NULL) &&
+ (LoadedImage->FilePath->Type == MEDIA_DEVICE_PATH) &&
+ (LoadedImage->FilePath->SubType == MEDIA_PIWG_FW_FILE_DP)
+ )
+ {
//
// Determine GUID associated with module logging performance
//
ModuleGuidIsGet = TRUE;
- FvFilePath = (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) LoadedImage->FilePath;
+ FvFilePath = (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *)LoadedImage->FilePath;
TempGuid = &FvFilePath->FvFileName;
}
@@ -357,20 +367,21 @@ GetModuleInfoFromHandle ( // Method 1 Get Module Name from PDB string.
//
PdbFileName = PeCoffLoaderGetPdbPointer (LoadedImage->ImageBase);
- if (PdbFileName != NULL && BufferSize > 0) {
+ if ((PdbFileName != NULL) && (BufferSize > 0)) {
StartIndex = 0;
for (Index = 0; PdbFileName[Index] != 0; Index++) {
if ((PdbFileName[Index] == '\\') || (PdbFileName[Index] == '/')) {
StartIndex = Index + 1;
}
}
+
//
// Copy the PDB file name to our temporary string.
// If the length is bigger than BufferSize, trim the redudant characters to avoid overflow in array boundary.
//
for (Index = 0; Index < BufferSize - 1; Index++) {
NameString[Index] = PdbFileName[Index + StartIndex];
- if (NameString[Index] == 0 || NameString[Index] == '.') {
+ if ((NameString[Index] == 0) || (NameString[Index] == '.')) {
NameString[Index] = 0;
break;
}
@@ -379,6 +390,7 @@ GetModuleInfoFromHandle ( if (Index == BufferSize - 1) {
NameString[Index] = 0;
}
+
//
// Module Name is got.
//
@@ -392,21 +404,22 @@ GetModuleInfoFromHandle ( //
StringPtr = NULL;
StringSize = 0;
- Status = GetSectionFromAnyFv (
- TempGuid,
- EFI_SECTION_USER_INTERFACE,
- 0,
- (VOID **) &StringPtr,
- &StringSize
- );
+ Status = GetSectionFromAnyFv (
+ TempGuid,
+ EFI_SECTION_USER_INTERFACE,
+ 0,
+ (VOID **)&StringPtr,
+ &StringSize
+ );
if (!EFI_ERROR (Status)) {
//
// Method 3. Get the name string from FFS UI section
//
for (Index = 0; Index < BufferSize - 1 && StringPtr[Index] != 0; Index++) {
- NameString[Index] = (CHAR8) StringPtr[Index];
+ NameString[Index] = (CHAR8)StringPtr[Index];
}
+
NameString[Index] = 0;
FreePool (StringPtr);
}
@@ -418,9 +431,9 @@ Done: //
if (ModuleGuid != NULL) {
CopyGuid (ModuleGuid, TempGuid);
- if (IsZeroGuid(TempGuid) && (Handle != NULL) && !ModuleGuidIsGet) {
- // Handle is GUID
- CopyGuid (ModuleGuid, (EFI_GUID *) Handle);
+ if (IsZeroGuid (TempGuid) && (Handle != NULL) && !ModuleGuidIsGet) {
+ // Handle is GUID
+ CopyGuid (ModuleGuid, (EFI_GUID *)Handle);
}
}
@@ -431,7 +444,7 @@ Done: mCacheHandleGuidTable[mCachePairCount].Handle = Handle;
CopyGuid (&mCacheHandleGuidTable[mCachePairCount].ModuleGuid, ModuleGuid);
AsciiStrCpyS (mCacheHandleGuidTable[mCachePairCount].NameString, FPDT_STRING_EVENT_RECORD_NAME_LENGTH, NameString);
- mCachePairCount ++;
+ mCachePairCount++;
}
return Status;
@@ -448,9 +461,9 @@ Done: **/
VOID
CopyStringIntoPerfRecordAndUpdateLength (
- IN OUT CHAR8 *Destination,
+ IN OUT CHAR8 *Destination,
IN CONST CHAR8 *Source,
- IN OUT UINT8 *Length
+ IN OUT UINT8 *Length
)
{
UINTN StringLen;
@@ -466,12 +479,13 @@ CopyStringIntoPerfRecordAndUpdateLength ( DestMax = STRING_SIZE;
}
}
+
StringLen = AsciiStrLen (Source);
if (StringLen >= DestMax) {
StringLen = DestMax -1;
}
- AsciiStrnCpyS(Destination, DestMax, Source, StringLen);
+ AsciiStrnCpyS (Destination, DestMax, Source, StringLen);
*Length += (UINT8)DestMax;
return;
@@ -513,18 +527,18 @@ InsertFpdtRecord ( )
{
- EFI_STATUS Status;
- EFI_GUID ModuleGuid;
- CHAR8 ModuleName[FPDT_STRING_EVENT_RECORD_NAME_LENGTH];
- FPDT_RECORD_PTR FpdtRecordPtr;
- FPDT_RECORD_PTR CachedFpdtRecordPtr;
- UINT64 TimeStamp;
- CONST CHAR8 *StringPtr;
- UINTN DestMax;
- UINTN StringLen;
- UINT16 ProgressId;
-
- StringPtr = NULL;
+ EFI_STATUS Status;
+ EFI_GUID ModuleGuid;
+ CHAR8 ModuleName[FPDT_STRING_EVENT_RECORD_NAME_LENGTH];
+ FPDT_RECORD_PTR FpdtRecordPtr;
+ FPDT_RECORD_PTR CachedFpdtRecordPtr;
+ UINT64 TimeStamp;
+ CONST CHAR8 *StringPtr;
+ UINTN DestMax;
+ UINTN StringLen;
+ UINT16 ProgressId;
+
+ StringPtr = NULL;
ZeroMem (ModuleName, sizeof (ModuleName));
//
@@ -550,6 +564,7 @@ InsertFpdtRecord ( PerfId += 1;
}
}
+
if (PerfId == 0) {
//
// Get ProgressID form the String Token.
@@ -558,6 +573,7 @@ InsertFpdtRecord ( if (EFI_ERROR (Status)) {
return Status;
}
+
PerfId = ProgressId;
}
}
@@ -586,134 +602,147 @@ InsertFpdtRecord ( // 4. Fill in the FPDT record according to different Performance Identifier.
//
switch (PerfId) {
- case MODULE_START_ID:
- case MODULE_END_ID:
- GetModuleInfoFromHandle ((EFI_HANDLE)CallerIdentifier, ModuleName, sizeof (ModuleName), &ModuleGuid);
- StringPtr = ModuleName;
- //
- // Cache the offset of start image start record and use to update the start image end record if needed.
- //
- if (PerfId == MODULE_START_ID && Attribute == PerfEntry) {
- mCachedLength = mSmmBootPerformanceTable->Header.Length;
- }
- if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
- FpdtRecordPtr.GuidEvent->Header.Type = FPDT_GUID_EVENT_TYPE;
- FpdtRecordPtr.GuidEvent->Header.Length = sizeof (FPDT_GUID_EVENT_RECORD);
- FpdtRecordPtr.GuidEvent->Header.Revision = FPDT_RECORD_REVISION_1;
- FpdtRecordPtr.GuidEvent->ProgressID = PerfId;
- FpdtRecordPtr.GuidEvent->Timestamp = TimeStamp;
- CopyMem (&FpdtRecordPtr.GuidEvent->Guid, &ModuleGuid, sizeof (FpdtRecordPtr.GuidEvent->Guid));
- if (CallerIdentifier == NULL && PerfId == MODULE_END_ID && mCachedLength != 0) {
- CachedFpdtRecordPtr.RecordHeader = (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER *)((UINT8*)mSmmBootPerformanceTable + mCachedLength);
- CopyMem (&FpdtRecordPtr.GuidEvent->Guid, &CachedFpdtRecordPtr.GuidEvent->Guid, sizeof (FpdtRecordPtr.GuidEvent->Guid));
- mCachedLength = 0;
- }
- }
- break;
-
- case MODULE_LOADIMAGE_START_ID:
- case MODULE_LOADIMAGE_END_ID:
- GetModuleInfoFromHandle ((EFI_HANDLE)CallerIdentifier, ModuleName, sizeof (ModuleName), &ModuleGuid);
- StringPtr = ModuleName;
- if (PerfId == MODULE_LOADIMAGE_START_ID) {
- mLoadImageCount++;
+ case MODULE_START_ID:
+ case MODULE_END_ID:
+ GetModuleInfoFromHandle ((EFI_HANDLE)CallerIdentifier, ModuleName, sizeof (ModuleName), &ModuleGuid);
+ StringPtr = ModuleName;
//
- // Cache the offset of load image start record and use to be updated by the load image end record if needed.
+ // Cache the offset of start image start record and use to update the start image end record if needed.
//
- if (CallerIdentifier == NULL && Attribute == PerfEntry) {
+ if ((PerfId == MODULE_START_ID) && (Attribute == PerfEntry)) {
mCachedLength = mSmmBootPerformanceTable->Header.Length;
}
- }
- if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
- FpdtRecordPtr.GuidQwordEvent->Header.Type = FPDT_GUID_QWORD_EVENT_TYPE;
- FpdtRecordPtr.GuidQwordEvent->Header.Length = sizeof (FPDT_GUID_QWORD_EVENT_RECORD);
- FpdtRecordPtr.GuidQwordEvent->Header.Revision = FPDT_RECORD_REVISION_1;
- FpdtRecordPtr.GuidQwordEvent->ProgressID = PerfId;
- FpdtRecordPtr.GuidQwordEvent->Timestamp = TimeStamp;
- FpdtRecordPtr.GuidQwordEvent->Qword = mLoadImageCount;
- CopyMem (&FpdtRecordPtr.GuidQwordEvent->Guid, &ModuleGuid, sizeof (FpdtRecordPtr.GuidQwordEvent->Guid));
- if (PerfId == MODULE_LOADIMAGE_END_ID && mCachedLength != 0) {
- CachedFpdtRecordPtr.RecordHeader = (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER *)((UINT8*)mSmmBootPerformanceTable + mCachedLength);
- CopyMem (&CachedFpdtRecordPtr.GuidQwordEvent->Guid, &ModuleGuid, sizeof (CachedFpdtRecordPtr.GuidQwordEvent->Guid));
- mCachedLength = 0;
+
+ if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
+ FpdtRecordPtr.GuidEvent->Header.Type = FPDT_GUID_EVENT_TYPE;
+ FpdtRecordPtr.GuidEvent->Header.Length = sizeof (FPDT_GUID_EVENT_RECORD);
+ FpdtRecordPtr.GuidEvent->Header.Revision = FPDT_RECORD_REVISION_1;
+ FpdtRecordPtr.GuidEvent->ProgressID = PerfId;
+ FpdtRecordPtr.GuidEvent->Timestamp = TimeStamp;
+ CopyMem (&FpdtRecordPtr.GuidEvent->Guid, &ModuleGuid, sizeof (FpdtRecordPtr.GuidEvent->Guid));
+ if ((CallerIdentifier == NULL) && (PerfId == MODULE_END_ID) && (mCachedLength != 0)) {
+ CachedFpdtRecordPtr.RecordHeader = (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER *)((UINT8 *)mSmmBootPerformanceTable + mCachedLength);
+ CopyMem (&FpdtRecordPtr.GuidEvent->Guid, &CachedFpdtRecordPtr.GuidEvent->Guid, sizeof (FpdtRecordPtr.GuidEvent->Guid));
+ mCachedLength = 0;
+ }
}
- }
- break;
- case PERF_EVENTSIGNAL_START_ID:
- case PERF_EVENTSIGNAL_END_ID:
- case PERF_CALLBACK_START_ID:
- case PERF_CALLBACK_END_ID:
- if (String == NULL || Guid == NULL) {
- return EFI_INVALID_PARAMETER;
- }
- StringPtr = String;
- if (AsciiStrLen (String) == 0) {
- StringPtr = "unknown name";
- }
- if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
- FpdtRecordPtr.DualGuidStringEvent->Header.Type = FPDT_DUAL_GUID_STRING_EVENT_TYPE;
- FpdtRecordPtr.DualGuidStringEvent->Header.Length = sizeof (FPDT_DUAL_GUID_STRING_EVENT_RECORD);
- FpdtRecordPtr.DualGuidStringEvent->Header.Revision = FPDT_RECORD_REVISION_1;
- FpdtRecordPtr.DualGuidStringEvent->ProgressID = PerfId;
- FpdtRecordPtr.DualGuidStringEvent->Timestamp = TimeStamp;
- CopyMem (&FpdtRecordPtr.DualGuidStringEvent->Guid1, CallerIdentifier, sizeof (FpdtRecordPtr.DualGuidStringEvent->Guid1));
- CopyMem (&FpdtRecordPtr.DualGuidStringEvent->Guid2, Guid, sizeof (FpdtRecordPtr.DualGuidStringEvent->Guid2));
- CopyStringIntoPerfRecordAndUpdateLength (FpdtRecordPtr.DualGuidStringEvent->String, StringPtr, &FpdtRecordPtr.DualGuidStringEvent->Header.Length);
- }
- break;
-
- case PERF_EVENT_ID:
- case PERF_FUNCTION_START_ID:
- case PERF_FUNCTION_END_ID:
- case PERF_INMODULE_START_ID:
- case PERF_INMODULE_END_ID:
- case PERF_CROSSMODULE_START_ID:
- case PERF_CROSSMODULE_END_ID:
- GetModuleInfoFromHandle ((EFI_HANDLE)CallerIdentifier, ModuleName, sizeof (ModuleName), &ModuleGuid);
- if (String != NULL) {
- StringPtr = String;
- } else {
+ break;
+
+ case MODULE_LOADIMAGE_START_ID:
+ case MODULE_LOADIMAGE_END_ID:
+ GetModuleInfoFromHandle ((EFI_HANDLE)CallerIdentifier, ModuleName, sizeof (ModuleName), &ModuleGuid);
StringPtr = ModuleName;
- }
- if (AsciiStrLen (StringPtr) == 0) {
- StringPtr = "unknown name";
- }
- if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
- FpdtRecordPtr.DynamicStringEvent->Header.Type = FPDT_DYNAMIC_STRING_EVENT_TYPE;
- FpdtRecordPtr.DynamicStringEvent->Header.Length = sizeof (FPDT_DYNAMIC_STRING_EVENT_RECORD);
- FpdtRecordPtr.DynamicStringEvent->Header.Revision = FPDT_RECORD_REVISION_1;
- FpdtRecordPtr.DynamicStringEvent->ProgressID = PerfId;
- FpdtRecordPtr.DynamicStringEvent->Timestamp = TimeStamp;
- CopyMem (&FpdtRecordPtr.DynamicStringEvent->Guid, &ModuleGuid, sizeof (FpdtRecordPtr.DynamicStringEvent->Guid));
- CopyStringIntoPerfRecordAndUpdateLength (FpdtRecordPtr.DynamicStringEvent->String, StringPtr, &FpdtRecordPtr.DynamicStringEvent->Header.Length);
- }
- break;
+ if (PerfId == MODULE_LOADIMAGE_START_ID) {
+ mLoadImageCount++;
+ //
+ // Cache the offset of load image start record and use to be updated by the load image end record if needed.
+ //
+ if ((CallerIdentifier == NULL) && (Attribute == PerfEntry)) {
+ mCachedLength = mSmmBootPerformanceTable->Header.Length;
+ }
+ }
+
+ if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
+ FpdtRecordPtr.GuidQwordEvent->Header.Type = FPDT_GUID_QWORD_EVENT_TYPE;
+ FpdtRecordPtr.GuidQwordEvent->Header.Length = sizeof (FPDT_GUID_QWORD_EVENT_RECORD);
+ FpdtRecordPtr.GuidQwordEvent->Header.Revision = FPDT_RECORD_REVISION_1;
+ FpdtRecordPtr.GuidQwordEvent->ProgressID = PerfId;
+ FpdtRecordPtr.GuidQwordEvent->Timestamp = TimeStamp;
+ FpdtRecordPtr.GuidQwordEvent->Qword = mLoadImageCount;
+ CopyMem (&FpdtRecordPtr.GuidQwordEvent->Guid, &ModuleGuid, sizeof (FpdtRecordPtr.GuidQwordEvent->Guid));
+ if ((PerfId == MODULE_LOADIMAGE_END_ID) && (mCachedLength != 0)) {
+ CachedFpdtRecordPtr.RecordHeader = (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER *)((UINT8 *)mSmmBootPerformanceTable + mCachedLength);
+ CopyMem (&CachedFpdtRecordPtr.GuidQwordEvent->Guid, &ModuleGuid, sizeof (CachedFpdtRecordPtr.GuidQwordEvent->Guid));
+ mCachedLength = 0;
+ }
+ }
+
+ break;
+
+ case PERF_EVENTSIGNAL_START_ID:
+ case PERF_EVENTSIGNAL_END_ID:
+ case PERF_CALLBACK_START_ID:
+ case PERF_CALLBACK_END_ID:
+ if ((String == NULL) || (Guid == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ StringPtr = String;
+ if (AsciiStrLen (String) == 0) {
+ StringPtr = "unknown name";
+ }
- default:
- if (Attribute != PerfEntry) {
+ if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
+ FpdtRecordPtr.DualGuidStringEvent->Header.Type = FPDT_DUAL_GUID_STRING_EVENT_TYPE;
+ FpdtRecordPtr.DualGuidStringEvent->Header.Length = sizeof (FPDT_DUAL_GUID_STRING_EVENT_RECORD);
+ FpdtRecordPtr.DualGuidStringEvent->Header.Revision = FPDT_RECORD_REVISION_1;
+ FpdtRecordPtr.DualGuidStringEvent->ProgressID = PerfId;
+ FpdtRecordPtr.DualGuidStringEvent->Timestamp = TimeStamp;
+ CopyMem (&FpdtRecordPtr.DualGuidStringEvent->Guid1, CallerIdentifier, sizeof (FpdtRecordPtr.DualGuidStringEvent->Guid1));
+ CopyMem (&FpdtRecordPtr.DualGuidStringEvent->Guid2, Guid, sizeof (FpdtRecordPtr.DualGuidStringEvent->Guid2));
+ CopyStringIntoPerfRecordAndUpdateLength (FpdtRecordPtr.DualGuidStringEvent->String, StringPtr, &FpdtRecordPtr.DualGuidStringEvent->Header.Length);
+ }
+
+ break;
+
+ case PERF_EVENT_ID:
+ case PERF_FUNCTION_START_ID:
+ case PERF_FUNCTION_END_ID:
+ case PERF_INMODULE_START_ID:
+ case PERF_INMODULE_END_ID:
+ case PERF_CROSSMODULE_START_ID:
+ case PERF_CROSSMODULE_END_ID:
GetModuleInfoFromHandle ((EFI_HANDLE)CallerIdentifier, ModuleName, sizeof (ModuleName), &ModuleGuid);
if (String != NULL) {
StringPtr = String;
} else {
StringPtr = ModuleName;
}
+
if (AsciiStrLen (StringPtr) == 0) {
StringPtr = "unknown name";
}
+
if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
- FpdtRecordPtr.DynamicStringEvent->Header.Type = FPDT_DYNAMIC_STRING_EVENT_TYPE;
- FpdtRecordPtr.DynamicStringEvent->Header.Length = sizeof (FPDT_DYNAMIC_STRING_EVENT_RECORD);
- FpdtRecordPtr.DynamicStringEvent->Header.Revision = FPDT_RECORD_REVISION_1;
- FpdtRecordPtr.DynamicStringEvent->ProgressID = PerfId;
- FpdtRecordPtr.DynamicStringEvent->Timestamp = TimeStamp;
+ FpdtRecordPtr.DynamicStringEvent->Header.Type = FPDT_DYNAMIC_STRING_EVENT_TYPE;
+ FpdtRecordPtr.DynamicStringEvent->Header.Length = sizeof (FPDT_DYNAMIC_STRING_EVENT_RECORD);
+ FpdtRecordPtr.DynamicStringEvent->Header.Revision = FPDT_RECORD_REVISION_1;
+ FpdtRecordPtr.DynamicStringEvent->ProgressID = PerfId;
+ FpdtRecordPtr.DynamicStringEvent->Timestamp = TimeStamp;
CopyMem (&FpdtRecordPtr.DynamicStringEvent->Guid, &ModuleGuid, sizeof (FpdtRecordPtr.DynamicStringEvent->Guid));
CopyStringIntoPerfRecordAndUpdateLength (FpdtRecordPtr.DynamicStringEvent->String, StringPtr, &FpdtRecordPtr.DynamicStringEvent->Header.Length);
}
- } else {
- return EFI_INVALID_PARAMETER;
- }
- break;
+
+ break;
+
+ default:
+ if (Attribute != PerfEntry) {
+ GetModuleInfoFromHandle ((EFI_HANDLE)CallerIdentifier, ModuleName, sizeof (ModuleName), &ModuleGuid);
+ if (String != NULL) {
+ StringPtr = String;
+ } else {
+ StringPtr = ModuleName;
+ }
+
+ if (AsciiStrLen (StringPtr) == 0) {
+ StringPtr = "unknown name";
+ }
+
+ if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
+ FpdtRecordPtr.DynamicStringEvent->Header.Type = FPDT_DYNAMIC_STRING_EVENT_TYPE;
+ FpdtRecordPtr.DynamicStringEvent->Header.Length = sizeof (FPDT_DYNAMIC_STRING_EVENT_RECORD);
+ FpdtRecordPtr.DynamicStringEvent->Header.Revision = FPDT_RECORD_REVISION_1;
+ FpdtRecordPtr.DynamicStringEvent->ProgressID = PerfId;
+ FpdtRecordPtr.DynamicStringEvent->Timestamp = TimeStamp;
+ CopyMem (&FpdtRecordPtr.DynamicStringEvent->Guid, &ModuleGuid, sizeof (FpdtRecordPtr.DynamicStringEvent->Guid));
+ CopyStringIntoPerfRecordAndUpdateLength (FpdtRecordPtr.DynamicStringEvent->String, StringPtr, &FpdtRecordPtr.DynamicStringEvent->Header.Length);
+ }
+ } else {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ break;
}
//
@@ -723,11 +752,12 @@ InsertFpdtRecord ( if (StringPtr == NULL) {
return EFI_INVALID_PARAMETER;
}
- FpdtRecordPtr.DynamicStringEvent->Header.Type = FPDT_DYNAMIC_STRING_EVENT_TYPE;
- FpdtRecordPtr.DynamicStringEvent->Header.Length = sizeof (FPDT_DYNAMIC_STRING_EVENT_RECORD);
- FpdtRecordPtr.DynamicStringEvent->Header.Revision = FPDT_RECORD_REVISION_1;
- FpdtRecordPtr.DynamicStringEvent->ProgressID = PerfId;
- FpdtRecordPtr.DynamicStringEvent->Timestamp = TimeStamp;
+
+ FpdtRecordPtr.DynamicStringEvent->Header.Type = FPDT_DYNAMIC_STRING_EVENT_TYPE;
+ FpdtRecordPtr.DynamicStringEvent->Header.Length = sizeof (FPDT_DYNAMIC_STRING_EVENT_RECORD);
+ FpdtRecordPtr.DynamicStringEvent->Header.Revision = FPDT_RECORD_REVISION_1;
+ FpdtRecordPtr.DynamicStringEvent->ProgressID = PerfId;
+ FpdtRecordPtr.DynamicStringEvent->Timestamp = TimeStamp;
if (Guid != NULL) {
//
// Cache the event guid in string event record.
@@ -736,33 +766,39 @@ InsertFpdtRecord ( } else {
CopyMem (&FpdtRecordPtr.DynamicStringEvent->Guid, &ModuleGuid, sizeof (FpdtRecordPtr.DynamicStringEvent->Guid));
}
+
if (AsciiStrLen (StringPtr) == 0) {
StringPtr = "unknown name";
}
+
CopyStringIntoPerfRecordAndUpdateLength (FpdtRecordPtr.DynamicStringEvent->String, StringPtr, &FpdtRecordPtr.DynamicStringEvent->Header.Length);
if ((PerfId == MODULE_LOADIMAGE_START_ID) || (PerfId == MODULE_END_ID)) {
FpdtRecordPtr.DynamicStringEvent->Header.Length = (UINT8)(sizeof (FPDT_DYNAMIC_STRING_EVENT_RECORD)+ STRING_SIZE);
}
- if ((PerfId == MODULE_LOADIMAGE_END_ID || PerfId == MODULE_END_ID) && mCachedLength != 0) {
- CachedFpdtRecordPtr.RecordHeader = (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER *)((UINT8*)mSmmBootPerformanceTable + mCachedLength);
+
+ if (((PerfId == MODULE_LOADIMAGE_END_ID) || (PerfId == MODULE_END_ID)) && (mCachedLength != 0)) {
+ CachedFpdtRecordPtr.RecordHeader = (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER *)((UINT8 *)mSmmBootPerformanceTable + mCachedLength);
if (PerfId == MODULE_LOADIMAGE_END_ID) {
- DestMax = CachedFpdtRecordPtr.DynamicStringEvent->Header.Length - sizeof (FPDT_DYNAMIC_STRING_EVENT_RECORD);
+ DestMax = CachedFpdtRecordPtr.DynamicStringEvent->Header.Length - sizeof (FPDT_DYNAMIC_STRING_EVENT_RECORD);
StringLen = AsciiStrLen (StringPtr);
if (StringLen >= DestMax) {
StringLen = DestMax -1;
}
+
CopyMem (&CachedFpdtRecordPtr.DynamicStringEvent->Guid, &ModuleGuid, sizeof (CachedFpdtRecordPtr.DynamicStringEvent->Guid));
AsciiStrnCpyS (CachedFpdtRecordPtr.DynamicStringEvent->String, DestMax, StringPtr, StringLen);
} else if (PerfId == MODULE_END_ID) {
- DestMax = FpdtRecordPtr.DynamicStringEvent->Header.Length - sizeof (FPDT_DYNAMIC_STRING_EVENT_RECORD);
+ DestMax = FpdtRecordPtr.DynamicStringEvent->Header.Length - sizeof (FPDT_DYNAMIC_STRING_EVENT_RECORD);
StringLen = AsciiStrLen (CachedFpdtRecordPtr.DynamicStringEvent->String);
if (StringLen >= DestMax) {
StringLen = DestMax -1;
}
+
CopyMem (&FpdtRecordPtr.DynamicStringEvent->Guid, &CachedFpdtRecordPtr.DynamicStringEvent->Guid, sizeof (CachedFpdtRecordPtr.DynamicStringEvent->Guid));
AsciiStrnCpyS (FpdtRecordPtr.DynamicStringEvent->String, DestMax, CachedFpdtRecordPtr.DynamicStringEvent->String, StringLen);
}
+
mCachedLength = 0;
}
}
@@ -770,7 +806,7 @@ InsertFpdtRecord ( //
// 5. Update the length of the used buffer after fill in the record.
//
- mPerformanceLength += FpdtRecordPtr.RecordHeader->Length;
+ mPerformanceLength += FpdtRecordPtr.RecordHeader->Length;
mSmmBootPerformanceTable->Header.Length += FpdtRecordPtr.RecordHeader->Length;
return EFI_SUCCESS;
@@ -803,10 +839,10 @@ InsertFpdtRecord ( EFI_STATUS
EFIAPI
FpdtSmiHandler (
- IN EFI_HANDLE DispatchHandle,
- IN CONST VOID *RegisterContext,
- IN OUT VOID *CommBuffer,
- IN OUT UINTN *CommBufferSize
+ IN EFI_HANDLE DispatchHandle,
+ IN CONST VOID *RegisterContext,
+ IN OUT VOID *CommBuffer,
+ IN OUT UINTN *CommBufferSize
)
{
EFI_STATUS Status;
@@ -820,13 +856,13 @@ FpdtSmiHandler ( //
// If input is invalid, stop processing this SMI
//
- if (CommBuffer == NULL || CommBufferSize == NULL) {
+ if ((CommBuffer == NULL) || (CommBufferSize == NULL)) {
return EFI_SUCCESS;
}
TempCommBufferSize = *CommBufferSize;
- if(TempCommBufferSize < sizeof (SMM_BOOT_RECORD_COMMUNICATE)) {
+ if (TempCommBufferSize < sizeof (SMM_BOOT_RECORD_COMMUNICATE)) {
return EFI_SUCCESS;
}
@@ -835,27 +871,28 @@ FpdtSmiHandler ( return EFI_SUCCESS;
}
- SmmCommData = (SMM_BOOT_RECORD_COMMUNICATE*)CommBuffer;
+ SmmCommData = (SMM_BOOT_RECORD_COMMUNICATE *)CommBuffer;
Status = EFI_SUCCESS;
switch (SmmCommData->Function) {
- case SMM_FPDT_FUNCTION_GET_BOOT_RECORD_SIZE :
+ case SMM_FPDT_FUNCTION_GET_BOOT_RECORD_SIZE:
if (mSmmBootPerformanceTable != NULL) {
mBootRecordSize = mSmmBootPerformanceTable->Header.Length - sizeof (SMM_BOOT_PERFORMANCE_TABLE);
}
+
SmmCommData->BootRecordSize = mBootRecordSize;
break;
- case SMM_FPDT_FUNCTION_GET_BOOT_RECORD_DATA :
+ case SMM_FPDT_FUNCTION_GET_BOOT_RECORD_DATA:
Status = EFI_UNSUPPORTED;
break;
- case SMM_FPDT_FUNCTION_GET_BOOT_RECORD_DATA_BY_OFFSET :
+ case SMM_FPDT_FUNCTION_GET_BOOT_RECORD_DATA_BY_OFFSET:
BootRecordOffset = SmmCommData->BootRecordOffset;
BootRecordData = SmmCommData->BootRecordData;
BootRecordSize = SmmCommData->BootRecordSize;
- if (BootRecordData == NULL || BootRecordOffset >= mBootRecordSize) {
+ if ((BootRecordData == NULL) || (BootRecordOffset >= mBootRecordSize)) {
Status = EFI_INVALID_PARAMETER;
break;
}
@@ -866,15 +903,17 @@ FpdtSmiHandler ( if (BootRecordSize > mBootRecordSize - BootRecordOffset) {
BootRecordSize = mBootRecordSize - BootRecordOffset;
}
+
SmmCommData->BootRecordSize = BootRecordSize;
if (!SmmIsBufferOutsideSmmValid ((UINTN)BootRecordData, BootRecordSize)) {
DEBUG ((DEBUG_ERROR, "FpdtSmiHandler: MM Data buffer in MMRAM or overflow!\n"));
Status = EFI_ACCESS_DENIED;
break;
}
- BootRecordBuffer = ((UINT8 *) (mSmmBootPerformanceTable)) + sizeof (SMM_BOOT_PERFORMANCE_TABLE);
+
+ BootRecordBuffer = ((UINT8 *)(mSmmBootPerformanceTable)) + sizeof (SMM_BOOT_PERFORMANCE_TABLE);
CopyMem (
- (UINT8*)BootRecordData,
+ (UINT8 *)BootRecordData,
BootRecordBuffer + BootRecordOffset,
BootRecordSize
);
@@ -901,14 +940,14 @@ FpdtSmiHandler ( VOID
EFIAPI
InitializeSmmCorePerformanceLib (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
- EFI_HANDLE Handle;
- EFI_HANDLE SmiHandle;
- EFI_STATUS Status;
- PERFORMANCE_PROPERTY *PerformanceProperty;
+ EFI_HANDLE Handle;
+ EFI_HANDLE SmiHandle;
+ EFI_STATUS Status;
+ PERFORMANCE_PROPERTY *PerformanceProperty;
//
// Initialize spin lock
@@ -931,10 +970,10 @@ InitializeSmmCorePerformanceLib ( // Register SMI handler.
//
SmiHandle = NULL;
- Status = gSmst->SmiHandlerRegister (FpdtSmiHandler, &gEfiFirmwarePerformanceGuid, &SmiHandle);
+ Status = gSmst->SmiHandlerRegister (FpdtSmiHandler, &gEfiFirmwarePerformanceGuid, &SmiHandle);
ASSERT_EFI_ERROR (Status);
- Status = EfiGetSystemConfigurationTable (&gPerformanceProtocolGuid, (VOID **) &PerformanceProperty);
+ Status = EfiGetSystemConfigurationTable (&gPerformanceProtocolGuid, (VOID **)&PerformanceProperty);
if (EFI_ERROR (Status)) {
//
// Install configuration table for performance property.
@@ -1025,7 +1064,7 @@ SmmCorePerformanceLibConstructor ( **/
EFI_STATUS
EFIAPI
-CreatePerformanceMeasurement(
+CreatePerformanceMeasurement (
IN CONST VOID *CallerIdentifier OPTIONAL,
IN CONST VOID *Guid OPTIONAL,
IN CONST CHAR8 *String OPTIONAL,
@@ -1035,7 +1074,7 @@ CreatePerformanceMeasurement( IN PERF_MEASUREMENT_ATTRIBUTE Attribute
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
Status = EFI_SUCCESS;
@@ -1080,7 +1119,7 @@ StartPerformanceMeasurementEx ( IN UINT32 Identifier
)
{
- CONST CHAR8 *String;
+ CONST CHAR8 *String;
if (Token != NULL) {
String = Token;
@@ -1129,7 +1168,7 @@ EndPerformanceMeasurementEx ( IN UINT32 Identifier
)
{
- CONST CHAR8 *String;
+ CONST CHAR8 *String;
if (Token != NULL) {
String = Token;
@@ -1188,13 +1227,13 @@ EndPerformanceMeasurementEx ( UINTN
EFIAPI
GetPerformanceMeasurementEx (
- IN UINTN LogEntryKey,
- OUT CONST VOID **Handle,
- OUT CONST CHAR8 **Token,
- OUT CONST CHAR8 **Module,
- OUT UINT64 *StartTimeStamp,
- OUT UINT64 *EndTimeStamp,
- OUT UINT32 *Identifier
+ IN UINTN LogEntryKey,
+ OUT CONST VOID **Handle,
+ OUT CONST CHAR8 **Token,
+ OUT CONST CHAR8 **Module,
+ OUT UINT64 *StartTimeStamp,
+ OUT UINT64 *EndTimeStamp,
+ OUT UINT32 *Identifier
)
{
return 0;
@@ -1315,12 +1354,12 @@ EndPerformanceMeasurement ( UINTN
EFIAPI
GetPerformanceMeasurement (
- IN UINTN LogEntryKey,
- OUT CONST VOID **Handle,
- OUT CONST CHAR8 **Token,
- OUT CONST CHAR8 **Module,
- OUT UINT64 *StartTimeStamp,
- OUT UINT64 *EndTimeStamp
+ IN UINTN LogEntryKey,
+ OUT CONST VOID **Handle,
+ OUT CONST CHAR8 **Token,
+ OUT CONST CHAR8 **Module,
+ OUT UINT64 *StartTimeStamp,
+ OUT UINT64 *EndTimeStamp
)
{
return 0;
@@ -1344,7 +1383,7 @@ PerformanceMeasurementEnabled ( VOID
)
{
- return (BOOLEAN) ((PcdGet8(PcdPerformanceLibraryPropertyMask) & PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED) != 0);
+ return (BOOLEAN)((PcdGet8 (PcdPerformanceLibraryPropertyMask) & PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED) != 0);
}
/**
@@ -1390,14 +1429,15 @@ LogPerformanceMeasurement ( BOOLEAN
EFIAPI
LogPerformanceMeasurementEnabled (
- IN CONST UINTN Type
+ IN CONST UINTN Type
)
{
//
// When Performance measurement is enabled and the type is not filtered, the performance can be logged.
//
- if (PerformanceMeasurementEnabled () && (PcdGet8(PcdPerformanceLibraryPropertyMask) & Type) == 0) {
+ if (PerformanceMeasurementEnabled () && ((PcdGet8 (PcdPerformanceLibraryPropertyMask) & Type) == 0)) {
return TRUE;
}
+
return FALSE;
}
diff --git a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLibInternal.h b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLibInternal.h index c6963d2ebe..62b496484c 100644 --- a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLibInternal.h +++ b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLibInternal.h @@ -12,7 +12,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #ifndef _SMM_CORE_PERFORMANCE_LIB_INTERNAL_H_
#define _SMM_CORE_PERFORMANCE_LIB_INTERNAL_H_
-
#include <Guid/Performance.h>
#include <Guid/PerformanceMeasurement.h>
#include <Guid/ExtendedFirmwarePerformance.h>
@@ -43,6 +42,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent //
// Interface declarations for SMM PerformanceMeasurement Protocol.
//
+
/**
Create performance record with event description and a timestamp.
@@ -63,7 +63,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent **/
EFI_STATUS
EFIAPI
-CreatePerformanceMeasurement(
+CreatePerformanceMeasurement (
IN CONST VOID *CallerIdentifier OPTIONAL,
IN CONST VOID *Guid OPTIONAL,
IN CONST CHAR8 *String OPTIONAL,
diff --git a/MdeModulePkg/Library/SmmCorePlatformHookLibNull/SmmCorePlatformHookLibNull.c b/MdeModulePkg/Library/SmmCorePlatformHookLibNull/SmmCorePlatformHookLibNull.c index 8046b0fa5a..9396a5fe8a 100644 --- a/MdeModulePkg/Library/SmmCorePlatformHookLibNull/SmmCorePlatformHookLibNull.c +++ b/MdeModulePkg/Library/SmmCorePlatformHookLibNull/SmmCorePlatformHookLibNull.c @@ -26,7 +26,6 @@ PlatformHookBeforeSmmDispatch ( return EFI_SUCCESS;
}
-
/**
Performs platform specific tasks after invoking registered SMI handlers.
diff --git a/MdeModulePkg/Library/SmmIpmiLibSmmIpmiProtocol/SmmIpmiLibSmmIpmiProtocol.c b/MdeModulePkg/Library/SmmIpmiLibSmmIpmiProtocol/SmmIpmiLibSmmIpmiProtocol.c index e06944d833..607126aa0b 100644 --- a/MdeModulePkg/Library/SmmIpmiLibSmmIpmiProtocol/SmmIpmiLibSmmIpmiProtocol.c +++ b/MdeModulePkg/Library/SmmIpmiLibSmmIpmiProtocol/SmmIpmiLibSmmIpmiProtocol.c @@ -12,7 +12,7 @@ #include <Library/SmmServicesTableLib.h>
#include <Library/DebugLib.h>
-IPMI_PROTOCOL *mIpmiProtocol = NULL;
+IPMI_PROTOCOL *mIpmiProtocol = NULL;
/**
This service enables submitting commands via Ipmi.
@@ -35,22 +35,22 @@ IPMI_PROTOCOL *mIpmiProtocol = NULL; EFI_STATUS
EFIAPI
IpmiSubmitCommand (
- IN UINT8 NetFunction,
- IN UINT8 Command,
- IN UINT8 *RequestData,
- IN UINT32 RequestDataSize,
- OUT UINT8 *ResponseData,
- IN OUT UINT32 *ResponseDataSize
+ IN UINT8 NetFunction,
+ IN UINT8 Command,
+ IN UINT8 *RequestData,
+ IN UINT32 RequestDataSize,
+ OUT UINT8 *ResponseData,
+ IN OUT UINT32 *ResponseDataSize
)
{
EFI_STATUS Status;
if (mIpmiProtocol == NULL) {
Status = gSmst->SmmLocateProtocol (
- &gSmmIpmiProtocolGuid,
- NULL,
- (VOID **) &mIpmiProtocol
- );
+ &gSmmIpmiProtocolGuid,
+ NULL,
+ (VOID **)&mIpmiProtocol
+ );
if (EFI_ERROR (Status)) {
//
// Smm Ipmi Protocol is not installed. So, IPMI device is not present.
@@ -72,5 +72,6 @@ IpmiSubmitCommand ( if (EFI_ERROR (Status)) {
return Status;
}
+
return EFI_SUCCESS;
}
diff --git a/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxDxeLib.c b/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxDxeLib.c index 3740b9863e..78a9b86af4 100644 --- a/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxDxeLib.c +++ b/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxDxeLib.c @@ -34,7 +34,7 @@ LockBoxGetSmmCommProtocol ( VOID
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
//
// If the protocol has been got previously, return it.
@@ -51,6 +51,7 @@ LockBoxGetSmmCommProtocol ( if (EFI_ERROR (Status)) {
mLockBoxSmmCommProtocol = NULL;
}
+
return mLockBoxSmmCommProtocol;
}
@@ -65,12 +66,12 @@ LockBoxGetSmmCommBuffer ( VOID
)
{
- EFI_STATUS Status;
- UINTN MinimalSizeNeeded;
- EDKII_PI_SMM_COMMUNICATION_REGION_TABLE *PiSmmCommunicationRegionTable;
- UINT32 Index;
- EFI_MEMORY_DESCRIPTOR *Entry;
- UINTN Size;
+ EFI_STATUS Status;
+ UINTN MinimalSizeNeeded;
+ EDKII_PI_SMM_COMMUNICATION_REGION_TABLE *PiSmmCommunicationRegionTable;
+ UINT32 Index;
+ EFI_MEMORY_DESCRIPTOR *Entry;
+ UINTN Size;
//
// If the buffer has been got previously, return it.
@@ -81,37 +82,49 @@ LockBoxGetSmmCommBuffer ( MinimalSizeNeeded = sizeof (EFI_GUID) +
sizeof (UINTN) +
- MAX (sizeof (EFI_SMM_LOCK_BOX_PARAMETER_SAVE),
- MAX (sizeof (EFI_SMM_LOCK_BOX_PARAMETER_SET_ATTRIBUTES),
- MAX (sizeof (EFI_SMM_LOCK_BOX_PARAMETER_UPDATE),
- MAX (sizeof (EFI_SMM_LOCK_BOX_PARAMETER_RESTORE),
- sizeof (EFI_SMM_LOCK_BOX_PARAMETER_RESTORE_ALL_IN_PLACE)))));
+ MAX (
+ sizeof (EFI_SMM_LOCK_BOX_PARAMETER_SAVE),
+ MAX (
+ sizeof (EFI_SMM_LOCK_BOX_PARAMETER_SET_ATTRIBUTES),
+ MAX (
+ sizeof (EFI_SMM_LOCK_BOX_PARAMETER_UPDATE),
+ MAX (
+ sizeof (EFI_SMM_LOCK_BOX_PARAMETER_RESTORE),
+ sizeof (EFI_SMM_LOCK_BOX_PARAMETER_RESTORE_ALL_IN_PLACE)
+ )
+ )
+ )
+ );
Status = EfiGetSystemConfigurationTable (
&gEdkiiPiSmmCommunicationRegionTableGuid,
- (VOID **) &PiSmmCommunicationRegionTable
+ (VOID **)&PiSmmCommunicationRegionTable
);
if (EFI_ERROR (Status)) {
mLockBoxSmmCommBuffer = NULL;
return mLockBoxSmmCommBuffer;
}
+
ASSERT (PiSmmCommunicationRegionTable != NULL);
- Entry = (EFI_MEMORY_DESCRIPTOR *) (PiSmmCommunicationRegionTable + 1);
- Size = 0;
+ Entry = (EFI_MEMORY_DESCRIPTOR *)(PiSmmCommunicationRegionTable + 1);
+ Size = 0;
for (Index = 0; Index < PiSmmCommunicationRegionTable->NumberOfEntries; Index++) {
if (Entry->Type == EfiConventionalMemory) {
- Size = EFI_PAGES_TO_SIZE ((UINTN) Entry->NumberOfPages);
+ Size = EFI_PAGES_TO_SIZE ((UINTN)Entry->NumberOfPages);
if (Size >= MinimalSizeNeeded) {
break;
}
}
- Entry = (EFI_MEMORY_DESCRIPTOR *) ((UINT8 *) Entry + PiSmmCommunicationRegionTable->DescriptorSize);
+
+ Entry = (EFI_MEMORY_DESCRIPTOR *)((UINT8 *)Entry + PiSmmCommunicationRegionTable->DescriptorSize);
}
+
if (Index >= PiSmmCommunicationRegionTable->NumberOfEntries) {
mLockBoxSmmCommBuffer = NULL;
} else {
- mLockBoxSmmCommBuffer = (UINT8 *) (UINTN) Entry->PhysicalStart;
+ mLockBoxSmmCommBuffer = (UINT8 *)(UINTN)Entry->PhysicalStart;
}
+
return mLockBoxSmmCommBuffer;
}
@@ -133,18 +146,18 @@ LockBoxGetSmmCommBuffer ( RETURN_STATUS
EFIAPI
SaveLockBox (
- IN GUID *Guid,
- IN VOID *Buffer,
- IN UINTN Length
+ IN GUID *Guid,
+ IN VOID *Buffer,
+ IN UINTN Length
)
{
- EFI_STATUS Status;
- EFI_SMM_COMMUNICATION_PROTOCOL *SmmCommunication;
- EFI_SMM_LOCK_BOX_PARAMETER_SAVE *LockBoxParameterSave;
- EFI_SMM_COMMUNICATE_HEADER *CommHeader;
- UINT8 TempCommBuffer[sizeof(EFI_GUID) + sizeof(UINTN) + sizeof(EFI_SMM_LOCK_BOX_PARAMETER_SAVE)];
- UINT8 *CommBuffer;
- UINTN CommSize;
+ EFI_STATUS Status;
+ EFI_SMM_COMMUNICATION_PROTOCOL *SmmCommunication;
+ EFI_SMM_LOCK_BOX_PARAMETER_SAVE *LockBoxParameterSave;
+ EFI_SMM_COMMUNICATE_HEADER *CommHeader;
+ UINT8 TempCommBuffer[sizeof (EFI_GUID) + sizeof (UINTN) + sizeof (EFI_SMM_LOCK_BOX_PARAMETER_SAVE)];
+ UINT8 *CommBuffer;
+ UINTN CommSize;
DEBUG ((DEBUG_INFO, "SmmLockBoxDxeLib SaveLockBox - Enter\n"));
@@ -167,27 +180,28 @@ SaveLockBox ( if (CommBuffer == NULL) {
CommBuffer = &TempCommBuffer[0];
}
+
CommHeader = (EFI_SMM_COMMUNICATE_HEADER *)&CommBuffer[0];
- CopyMem (&CommHeader->HeaderGuid, &gEfiSmmLockBoxCommunicationGuid, sizeof(gEfiSmmLockBoxCommunicationGuid));
- CommHeader->MessageLength = sizeof(*LockBoxParameterSave);
+ CopyMem (&CommHeader->HeaderGuid, &gEfiSmmLockBoxCommunicationGuid, sizeof (gEfiSmmLockBoxCommunicationGuid));
+ CommHeader->MessageLength = sizeof (*LockBoxParameterSave);
- LockBoxParameterSave = (EFI_SMM_LOCK_BOX_PARAMETER_SAVE *)&CommBuffer[OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data)];
- LockBoxParameterSave->Header.Command = EFI_SMM_LOCK_BOX_COMMAND_SAVE;
- LockBoxParameterSave->Header.DataLength = sizeof(*LockBoxParameterSave);
+ LockBoxParameterSave = (EFI_SMM_LOCK_BOX_PARAMETER_SAVE *)&CommBuffer[OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data)];
+ LockBoxParameterSave->Header.Command = EFI_SMM_LOCK_BOX_COMMAND_SAVE;
+ LockBoxParameterSave->Header.DataLength = sizeof (*LockBoxParameterSave);
LockBoxParameterSave->Header.ReturnStatus = (UINT64)-1;
- CopyMem (&LockBoxParameterSave->Guid, Guid, sizeof(*Guid));
- LockBoxParameterSave->Buffer = (EFI_PHYSICAL_ADDRESS)(UINTN)Buffer;
- LockBoxParameterSave->Length = (UINT64)Length;
+ CopyMem (&LockBoxParameterSave->Guid, Guid, sizeof (*Guid));
+ LockBoxParameterSave->Buffer = (EFI_PHYSICAL_ADDRESS)(UINTN)Buffer;
+ LockBoxParameterSave->Length = (UINT64)Length;
//
// Send command
//
- CommSize = sizeof(EFI_GUID) + sizeof(UINTN) + sizeof(EFI_SMM_LOCK_BOX_PARAMETER_SAVE);
- Status = SmmCommunication->Communicate (
- SmmCommunication,
- &CommBuffer[0],
- &CommSize
- );
+ CommSize = sizeof (EFI_GUID) + sizeof (UINTN) + sizeof (EFI_SMM_LOCK_BOX_PARAMETER_SAVE);
+ Status = SmmCommunication->Communicate (
+ SmmCommunication,
+ &CommBuffer[0],
+ &CommSize
+ );
ASSERT_EFI_ERROR (Status);
Status = (EFI_STATUS)LockBoxParameterSave->Header.ReturnStatus;
@@ -216,17 +230,17 @@ SaveLockBox ( RETURN_STATUS
EFIAPI
SetLockBoxAttributes (
- IN GUID *Guid,
- IN UINT64 Attributes
+ IN GUID *Guid,
+ IN UINT64 Attributes
)
{
- EFI_STATUS Status;
- EFI_SMM_COMMUNICATION_PROTOCOL *SmmCommunication;
- EFI_SMM_LOCK_BOX_PARAMETER_SET_ATTRIBUTES *LockBoxParameterSetAttributes;
- EFI_SMM_COMMUNICATE_HEADER *CommHeader;
- UINT8 TempCommBuffer[sizeof(EFI_GUID) + sizeof(UINTN) + sizeof(EFI_SMM_LOCK_BOX_PARAMETER_SET_ATTRIBUTES)];
- UINT8 *CommBuffer;
- UINTN CommSize;
+ EFI_STATUS Status;
+ EFI_SMM_COMMUNICATION_PROTOCOL *SmmCommunication;
+ EFI_SMM_LOCK_BOX_PARAMETER_SET_ATTRIBUTES *LockBoxParameterSetAttributes;
+ EFI_SMM_COMMUNICATE_HEADER *CommHeader;
+ UINT8 TempCommBuffer[sizeof (EFI_GUID) + sizeof (UINTN) + sizeof (EFI_SMM_LOCK_BOX_PARAMETER_SET_ATTRIBUTES)];
+ UINT8 *CommBuffer;
+ UINTN CommSize;
DEBUG ((DEBUG_INFO, "SmmLockBoxDxeLib SetLockBoxAttributes - Enter\n"));
@@ -234,7 +248,8 @@ SetLockBoxAttributes ( // Basic check
//
if ((Guid == NULL) ||
- ((Attributes & ~(LOCK_BOX_ATTRIBUTE_RESTORE_IN_PLACE | LOCK_BOX_ATTRIBUTE_RESTORE_IN_S3_ONLY)) != 0)) {
+ ((Attributes & ~(LOCK_BOX_ATTRIBUTE_RESTORE_IN_PLACE | LOCK_BOX_ATTRIBUTE_RESTORE_IN_S3_ONLY)) != 0))
+ {
return EFI_INVALID_PARAMETER;
}
@@ -250,26 +265,27 @@ SetLockBoxAttributes ( if (CommBuffer == NULL) {
CommBuffer = &TempCommBuffer[0];
}
+
CommHeader = (EFI_SMM_COMMUNICATE_HEADER *)&CommBuffer[0];
- CopyMem (&CommHeader->HeaderGuid, &gEfiSmmLockBoxCommunicationGuid, sizeof(gEfiSmmLockBoxCommunicationGuid));
- CommHeader->MessageLength = sizeof(*LockBoxParameterSetAttributes);
+ CopyMem (&CommHeader->HeaderGuid, &gEfiSmmLockBoxCommunicationGuid, sizeof (gEfiSmmLockBoxCommunicationGuid));
+ CommHeader->MessageLength = sizeof (*LockBoxParameterSetAttributes);
- LockBoxParameterSetAttributes = (EFI_SMM_LOCK_BOX_PARAMETER_SET_ATTRIBUTES *)&CommBuffer[OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data)];
- LockBoxParameterSetAttributes->Header.Command = EFI_SMM_LOCK_BOX_COMMAND_SET_ATTRIBUTES;
- LockBoxParameterSetAttributes->Header.DataLength = sizeof(*LockBoxParameterSetAttributes);
+ LockBoxParameterSetAttributes = (EFI_SMM_LOCK_BOX_PARAMETER_SET_ATTRIBUTES *)&CommBuffer[OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data)];
+ LockBoxParameterSetAttributes->Header.Command = EFI_SMM_LOCK_BOX_COMMAND_SET_ATTRIBUTES;
+ LockBoxParameterSetAttributes->Header.DataLength = sizeof (*LockBoxParameterSetAttributes);
LockBoxParameterSetAttributes->Header.ReturnStatus = (UINT64)-1;
- CopyMem (&LockBoxParameterSetAttributes->Guid, Guid, sizeof(*Guid));
+ CopyMem (&LockBoxParameterSetAttributes->Guid, Guid, sizeof (*Guid));
LockBoxParameterSetAttributes->Attributes = (UINT64)Attributes;
//
// Send command
//
- CommSize = sizeof(EFI_GUID) + sizeof(UINTN) + sizeof(EFI_SMM_LOCK_BOX_PARAMETER_SET_ATTRIBUTES);
- Status = SmmCommunication->Communicate (
- SmmCommunication,
- &CommBuffer[0],
- &CommSize
- );
+ CommSize = sizeof (EFI_GUID) + sizeof (UINTN) + sizeof (EFI_SMM_LOCK_BOX_PARAMETER_SET_ATTRIBUTES);
+ Status = SmmCommunication->Communicate (
+ SmmCommunication,
+ &CommBuffer[0],
+ &CommSize
+ );
ASSERT_EFI_ERROR (Status);
Status = (EFI_STATUS)LockBoxParameterSetAttributes->Header.ReturnStatus;
@@ -304,19 +320,19 @@ SetLockBoxAttributes ( RETURN_STATUS
EFIAPI
UpdateLockBox (
- IN GUID *Guid,
- IN UINTN Offset,
- IN VOID *Buffer,
- IN UINTN Length
+ IN GUID *Guid,
+ IN UINTN Offset,
+ IN VOID *Buffer,
+ IN UINTN Length
)
{
- EFI_STATUS Status;
- EFI_SMM_COMMUNICATION_PROTOCOL *SmmCommunication;
- EFI_SMM_LOCK_BOX_PARAMETER_UPDATE *LockBoxParameterUpdate;
- EFI_SMM_COMMUNICATE_HEADER *CommHeader;
- UINT8 TempCommBuffer[sizeof(EFI_GUID) + sizeof(UINTN) + sizeof(EFI_SMM_LOCK_BOX_PARAMETER_UPDATE)];
- UINT8 *CommBuffer;
- UINTN CommSize;
+ EFI_STATUS Status;
+ EFI_SMM_COMMUNICATION_PROTOCOL *SmmCommunication;
+ EFI_SMM_LOCK_BOX_PARAMETER_UPDATE *LockBoxParameterUpdate;
+ EFI_SMM_COMMUNICATE_HEADER *CommHeader;
+ UINT8 TempCommBuffer[sizeof (EFI_GUID) + sizeof (UINTN) + sizeof (EFI_SMM_LOCK_BOX_PARAMETER_UPDATE)];
+ UINT8 *CommBuffer;
+ UINTN CommSize;
DEBUG ((DEBUG_INFO, "SmmLockBoxDxeLib UpdateLockBox - Enter\n"));
@@ -339,15 +355,16 @@ UpdateLockBox ( if (CommBuffer == NULL) {
CommBuffer = &TempCommBuffer[0];
}
+
CommHeader = (EFI_SMM_COMMUNICATE_HEADER *)&CommBuffer[0];
- CopyMem (&CommHeader->HeaderGuid, &gEfiSmmLockBoxCommunicationGuid, sizeof(gEfiSmmLockBoxCommunicationGuid));
- CommHeader->MessageLength = sizeof(*LockBoxParameterUpdate);
+ CopyMem (&CommHeader->HeaderGuid, &gEfiSmmLockBoxCommunicationGuid, sizeof (gEfiSmmLockBoxCommunicationGuid));
+ CommHeader->MessageLength = sizeof (*LockBoxParameterUpdate);
- LockBoxParameterUpdate = (EFI_SMM_LOCK_BOX_PARAMETER_UPDATE *)(UINTN)&CommBuffer[OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data)];
- LockBoxParameterUpdate->Header.Command = EFI_SMM_LOCK_BOX_COMMAND_UPDATE;
- LockBoxParameterUpdate->Header.DataLength = sizeof(*LockBoxParameterUpdate);
+ LockBoxParameterUpdate = (EFI_SMM_LOCK_BOX_PARAMETER_UPDATE *)(UINTN)&CommBuffer[OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data)];
+ LockBoxParameterUpdate->Header.Command = EFI_SMM_LOCK_BOX_COMMAND_UPDATE;
+ LockBoxParameterUpdate->Header.DataLength = sizeof (*LockBoxParameterUpdate);
LockBoxParameterUpdate->Header.ReturnStatus = (UINT64)-1;
- CopyMem (&LockBoxParameterUpdate->Guid, Guid, sizeof(*Guid));
+ CopyMem (&LockBoxParameterUpdate->Guid, Guid, sizeof (*Guid));
LockBoxParameterUpdate->Offset = (UINT64)Offset;
LockBoxParameterUpdate->Buffer = (EFI_PHYSICAL_ADDRESS)(UINTN)Buffer;
LockBoxParameterUpdate->Length = (UINT64)Length;
@@ -355,12 +372,12 @@ UpdateLockBox ( //
// Send command
//
- CommSize = sizeof(EFI_GUID) + sizeof(UINTN) + sizeof(EFI_SMM_LOCK_BOX_PARAMETER_UPDATE);
- Status = SmmCommunication->Communicate (
- SmmCommunication,
- &CommBuffer[0],
- &CommSize
- );
+ CommSize = sizeof (EFI_GUID) + sizeof (UINTN) + sizeof (EFI_SMM_LOCK_BOX_PARAMETER_UPDATE);
+ Status = SmmCommunication->Communicate (
+ SmmCommunication,
+ &CommBuffer[0],
+ &CommSize
+ );
ASSERT_EFI_ERROR (Status);
Status = (EFI_STATUS)LockBoxParameterUpdate->Header.ReturnStatus;
@@ -394,18 +411,18 @@ UpdateLockBox ( RETURN_STATUS
EFIAPI
RestoreLockBox (
- IN GUID *Guid,
- IN VOID *Buffer OPTIONAL,
- IN OUT UINTN *Length OPTIONAL
+ IN GUID *Guid,
+ IN VOID *Buffer OPTIONAL,
+ IN OUT UINTN *Length OPTIONAL
)
{
- EFI_STATUS Status;
- EFI_SMM_COMMUNICATION_PROTOCOL *SmmCommunication;
- EFI_SMM_LOCK_BOX_PARAMETER_RESTORE *LockBoxParameterRestore;
- EFI_SMM_COMMUNICATE_HEADER *CommHeader;
- UINT8 TempCommBuffer[sizeof(EFI_GUID) + sizeof(UINTN) + sizeof(EFI_SMM_LOCK_BOX_PARAMETER_RESTORE)];
- UINT8 *CommBuffer;
- UINTN CommSize;
+ EFI_STATUS Status;
+ EFI_SMM_COMMUNICATION_PROTOCOL *SmmCommunication;
+ EFI_SMM_LOCK_BOX_PARAMETER_RESTORE *LockBoxParameterRestore;
+ EFI_SMM_COMMUNICATE_HEADER *CommHeader;
+ UINT8 TempCommBuffer[sizeof (EFI_GUID) + sizeof (UINTN) + sizeof (EFI_SMM_LOCK_BOX_PARAMETER_RESTORE)];
+ UINT8 *CommBuffer;
+ UINTN CommSize;
DEBUG ((DEBUG_INFO, "SmmLockBoxDxeLib RestoreLockBox - Enter\n"));
@@ -414,7 +431,8 @@ RestoreLockBox ( //
if ((Guid == NULL) ||
((Buffer == NULL) && (Length != NULL)) ||
- ((Buffer != NULL) && (Length == NULL))) {
+ ((Buffer != NULL) && (Length == NULL)))
+ {
return EFI_INVALID_PARAMETER;
}
@@ -430,15 +448,16 @@ RestoreLockBox ( if (CommBuffer == NULL) {
CommBuffer = &TempCommBuffer[0];
}
+
CommHeader = (EFI_SMM_COMMUNICATE_HEADER *)&CommBuffer[0];
- CopyMem (&CommHeader->HeaderGuid, &gEfiSmmLockBoxCommunicationGuid, sizeof(gEfiSmmLockBoxCommunicationGuid));
- CommHeader->MessageLength = sizeof(*LockBoxParameterRestore);
+ CopyMem (&CommHeader->HeaderGuid, &gEfiSmmLockBoxCommunicationGuid, sizeof (gEfiSmmLockBoxCommunicationGuid));
+ CommHeader->MessageLength = sizeof (*LockBoxParameterRestore);
- LockBoxParameterRestore = (EFI_SMM_LOCK_BOX_PARAMETER_RESTORE *)&CommBuffer[OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data)];
- LockBoxParameterRestore->Header.Command = EFI_SMM_LOCK_BOX_COMMAND_RESTORE;
- LockBoxParameterRestore->Header.DataLength = sizeof(*LockBoxParameterRestore);
+ LockBoxParameterRestore = (EFI_SMM_LOCK_BOX_PARAMETER_RESTORE *)&CommBuffer[OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data)];
+ LockBoxParameterRestore->Header.Command = EFI_SMM_LOCK_BOX_COMMAND_RESTORE;
+ LockBoxParameterRestore->Header.DataLength = sizeof (*LockBoxParameterRestore);
LockBoxParameterRestore->Header.ReturnStatus = (UINT64)-1;
- CopyMem (&LockBoxParameterRestore->Guid, Guid, sizeof(*Guid));
+ CopyMem (&LockBoxParameterRestore->Guid, Guid, sizeof (*Guid));
LockBoxParameterRestore->Buffer = (EFI_PHYSICAL_ADDRESS)(UINTN)Buffer;
if (Length != NULL) {
LockBoxParameterRestore->Length = (EFI_PHYSICAL_ADDRESS)*Length;
@@ -449,12 +468,12 @@ RestoreLockBox ( //
// Send command
//
- CommSize = sizeof(EFI_GUID) + sizeof(UINTN) + sizeof(EFI_SMM_LOCK_BOX_PARAMETER_RESTORE);
- Status = SmmCommunication->Communicate (
- SmmCommunication,
- &CommBuffer[0],
- &CommSize
- );
+ CommSize = sizeof (EFI_GUID) + sizeof (UINTN) + sizeof (EFI_SMM_LOCK_BOX_PARAMETER_RESTORE);
+ Status = SmmCommunication->Communicate (
+ SmmCommunication,
+ &CommBuffer[0],
+ &CommSize
+ );
ASSERT_EFI_ERROR (Status);
if (Length != NULL) {
@@ -484,13 +503,13 @@ RestoreAllLockBoxInPlace ( VOID
)
{
- EFI_STATUS Status;
- EFI_SMM_COMMUNICATION_PROTOCOL *SmmCommunication;
- EFI_SMM_LOCK_BOX_PARAMETER_RESTORE_ALL_IN_PLACE *LockBoxParameterRestoreAllInPlace;
- EFI_SMM_COMMUNICATE_HEADER *CommHeader;
- UINT8 TempCommBuffer[sizeof(EFI_GUID) + sizeof(UINTN) + sizeof(EFI_SMM_LOCK_BOX_PARAMETER_RESTORE_ALL_IN_PLACE)];
- UINT8 *CommBuffer;
- UINTN CommSize;
+ EFI_STATUS Status;
+ EFI_SMM_COMMUNICATION_PROTOCOL *SmmCommunication;
+ EFI_SMM_LOCK_BOX_PARAMETER_RESTORE_ALL_IN_PLACE *LockBoxParameterRestoreAllInPlace;
+ EFI_SMM_COMMUNICATE_HEADER *CommHeader;
+ UINT8 TempCommBuffer[sizeof (EFI_GUID) + sizeof (UINTN) + sizeof (EFI_SMM_LOCK_BOX_PARAMETER_RESTORE_ALL_IN_PLACE)];
+ UINT8 *CommBuffer;
+ UINTN CommSize;
DEBUG ((DEBUG_INFO, "SmmLockBoxDxeLib RestoreAllLockBoxInPlace - Enter\n"));
@@ -506,24 +525,25 @@ RestoreAllLockBoxInPlace ( if (CommBuffer == NULL) {
CommBuffer = &TempCommBuffer[0];
}
+
CommHeader = (EFI_SMM_COMMUNICATE_HEADER *)&CommBuffer[0];
- CopyMem (&CommHeader->HeaderGuid, &gEfiSmmLockBoxCommunicationGuid, sizeof(gEfiSmmLockBoxCommunicationGuid));
- CommHeader->MessageLength = sizeof(*LockBoxParameterRestoreAllInPlace);
+ CopyMem (&CommHeader->HeaderGuid, &gEfiSmmLockBoxCommunicationGuid, sizeof (gEfiSmmLockBoxCommunicationGuid));
+ CommHeader->MessageLength = sizeof (*LockBoxParameterRestoreAllInPlace);
- LockBoxParameterRestoreAllInPlace = (EFI_SMM_LOCK_BOX_PARAMETER_RESTORE_ALL_IN_PLACE *)&CommBuffer[OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data)];
- LockBoxParameterRestoreAllInPlace->Header.Command = EFI_SMM_LOCK_BOX_COMMAND_RESTORE_ALL_IN_PLACE;
- LockBoxParameterRestoreAllInPlace->Header.DataLength = sizeof(*LockBoxParameterRestoreAllInPlace);
+ LockBoxParameterRestoreAllInPlace = (EFI_SMM_LOCK_BOX_PARAMETER_RESTORE_ALL_IN_PLACE *)&CommBuffer[OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data)];
+ LockBoxParameterRestoreAllInPlace->Header.Command = EFI_SMM_LOCK_BOX_COMMAND_RESTORE_ALL_IN_PLACE;
+ LockBoxParameterRestoreAllInPlace->Header.DataLength = sizeof (*LockBoxParameterRestoreAllInPlace);
LockBoxParameterRestoreAllInPlace->Header.ReturnStatus = (UINT64)-1;
//
// Send command
//
- CommSize = sizeof(EFI_GUID) + sizeof(UINTN) + sizeof(EFI_SMM_LOCK_BOX_PARAMETER_RESTORE_ALL_IN_PLACE);
- Status = SmmCommunication->Communicate (
- SmmCommunication,
- &CommBuffer[0],
- &CommSize
- );
+ CommSize = sizeof (EFI_GUID) + sizeof (UINTN) + sizeof (EFI_SMM_LOCK_BOX_PARAMETER_RESTORE_ALL_IN_PLACE);
+ Status = SmmCommunication->Communicate (
+ SmmCommunication,
+ &CommBuffer[0],
+ &CommSize
+ );
ASSERT_EFI_ERROR (Status);
Status = (EFI_STATUS)LockBoxParameterRestoreAllInPlace->Header.ReturnStatus;
diff --git a/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxLibPrivate.h b/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxLibPrivate.h index 449333e94b..583be6b6ed 100644 --- a/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxLibPrivate.h +++ b/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxLibPrivate.h @@ -17,28 +17,28 @@ SPDX-License-Identifier: BSD-2-Clause-Patent // Below data structure is used for lockbox registration in SMST
//
-#define SMM_LOCK_BOX_SIGNATURE_32 SIGNATURE_64 ('L','O','C','K','B','_','3','2')
-#define SMM_LOCK_BOX_SIGNATURE_64 SIGNATURE_64 ('L','O','C','K','B','_','6','4')
+#define SMM_LOCK_BOX_SIGNATURE_32 SIGNATURE_64 ('L','O','C','K','B','_','3','2')
+#define SMM_LOCK_BOX_SIGNATURE_64 SIGNATURE_64 ('L','O','C','K','B','_','6','4')
typedef struct {
- UINT64 Signature;
- EFI_PHYSICAL_ADDRESS LockBoxDataAddress;
+ UINT64 Signature;
+ EFI_PHYSICAL_ADDRESS LockBoxDataAddress;
} SMM_LOCK_BOX_CONTEXT;
//
// Below data structure is used for lockbox management
//
-#define SMM_LOCK_BOX_DATA_SIGNATURE SIGNATURE_64 ('L','O','C','K','B','O','X','D')
+#define SMM_LOCK_BOX_DATA_SIGNATURE SIGNATURE_64 ('L','O','C','K','B','O','X','D')
typedef struct {
- UINT64 Signature;
- EFI_GUID Guid;
- EFI_PHYSICAL_ADDRESS Buffer;
- UINT64 Length;
- UINT64 Attributes;
- EFI_PHYSICAL_ADDRESS SmramBuffer;
- LIST_ENTRY Link;
+ UINT64 Signature;
+ EFI_GUID Guid;
+ EFI_PHYSICAL_ADDRESS Buffer;
+ UINT64 Length;
+ UINT64 Attributes;
+ EFI_PHYSICAL_ADDRESS SmramBuffer;
+ LIST_ENTRY Link;
} SMM_LOCK_BOX_DATA;
#pragma pack()
@@ -69,4 +69,3 @@ SmmLockBoxMmDestructor ( );
#endif
-
diff --git a/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxMmLib.c b/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxMmLib.c index 7f7ab10427..ab2cb7a2b4 100644 --- a/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxMmLib.c +++ b/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxMmLib.c @@ -24,15 +24,15 @@ SPDX-License-Identifier: BSD-2-Clause-Patent We need handle this library carefully. Only one library instance will construct the environment.
Below 2 global variable can only be used in constructor. They should NOT be used in any other library functions.
**/
-SMM_LOCK_BOX_CONTEXT mSmmLockBoxContext;
-LIST_ENTRY mLockBoxQueue = INITIALIZE_LIST_HEAD_VARIABLE (mLockBoxQueue);
+SMM_LOCK_BOX_CONTEXT mSmmLockBoxContext;
+LIST_ENTRY mLockBoxQueue = INITIALIZE_LIST_HEAD_VARIABLE (mLockBoxQueue);
-BOOLEAN mSmmConfigurationTableInstalled = FALSE;
-VOID *mSmmLockBoxRegistrationSmmEndOfDxe = NULL;
-VOID *mSmmLockBoxRegistrationSmmReadyToLock = NULL;
-VOID *mSmmLockBoxRegistrationEndOfS3Resume = NULL;
-BOOLEAN mSmmLockBoxSmmReadyToLock = FALSE;
-BOOLEAN mSmmLockBoxDuringS3Resume = FALSE;
+BOOLEAN mSmmConfigurationTableInstalled = FALSE;
+VOID *mSmmLockBoxRegistrationSmmEndOfDxe = NULL;
+VOID *mSmmLockBoxRegistrationSmmReadyToLock = NULL;
+VOID *mSmmLockBoxRegistrationEndOfS3Resume = NULL;
+BOOLEAN mSmmLockBoxSmmReadyToLock = FALSE;
+BOOLEAN mSmmLockBoxDuringS3Resume = FALSE;
/**
This function return SmmLockBox context from SMST.
@@ -44,7 +44,7 @@ InternalGetSmmLockBoxContext ( VOID
)
{
- UINTN Index;
+ UINTN Index;
//
// Check if gEfiSmmLockBoxCommunicationGuid is installed by someone
@@ -107,10 +107,10 @@ SmmLockBoxSmmReadyToLockNotify ( EFI_STATUS
EFIAPI
SmmLockBoxS3EntryCallBack (
- IN EFI_HANDLE DispatchHandle,
- IN CONST VOID *Context OPTIONAL,
- IN OUT VOID *CommBuffer OPTIONAL,
- IN OUT UINTN *CommBufferSize OPTIONAL
+ IN EFI_HANDLE DispatchHandle,
+ IN CONST VOID *Context OPTIONAL,
+ IN OUT VOID *CommBuffer OPTIONAL,
+ IN OUT UINTN *CommBufferSize OPTIONAL
)
{
mSmmLockBoxDuringS3Resume = TRUE;
@@ -134,10 +134,10 @@ SmmLockBoxSmmEndOfDxeNotify ( IN EFI_HANDLE Handle
)
{
- EFI_STATUS Status;
- EFI_SMM_SX_DISPATCH2_PROTOCOL *SxDispatch;
- EFI_SMM_SX_REGISTER_CONTEXT EntryRegisterContext;
- EFI_HANDLE S3EntryHandle;
+ EFI_STATUS Status;
+ EFI_SMM_SX_DISPATCH2_PROTOCOL *SxDispatch;
+ EFI_SMM_SX_REGISTER_CONTEXT EntryRegisterContext;
+ EFI_HANDLE S3EntryHandle;
//
// Locate SmmSxDispatch2 protocol.
@@ -154,12 +154,12 @@ SmmLockBoxSmmEndOfDxeNotify ( //
EntryRegisterContext.Type = SxS3;
EntryRegisterContext.Phase = SxEntry;
- Status = SxDispatch->Register (
- SxDispatch,
- SmmLockBoxS3EntryCallBack,
- &EntryRegisterContext,
- &S3EntryHandle
- );
+ Status = SxDispatch->Register (
+ SxDispatch,
+ SmmLockBoxS3EntryCallBack,
+ &EntryRegisterContext,
+ &S3EntryHandle
+ );
ASSERT_EFI_ERROR (Status);
}
@@ -199,8 +199,8 @@ SmmLockBoxMmConstructor ( VOID
)
{
- EFI_STATUS Status;
- SMM_LOCK_BOX_CONTEXT *SmmLockBoxContext;
+ EFI_STATUS Status;
+ SMM_LOCK_BOX_CONTEXT *SmmLockBoxContext;
DEBUG ((DEBUG_INFO, "SmmLockBoxSmmLib SmmLockBoxMmConstructor - Enter\n"));
@@ -251,18 +251,19 @@ SmmLockBoxMmConstructor ( //
// If no one install this, it means this is first instance. Install it.
//
- if (sizeof(UINTN) == sizeof(UINT64)) {
+ if (sizeof (UINTN) == sizeof (UINT64)) {
mSmmLockBoxContext.Signature = SMM_LOCK_BOX_SIGNATURE_64;
} else {
mSmmLockBoxContext.Signature = SMM_LOCK_BOX_SIGNATURE_32;
}
+
mSmmLockBoxContext.LockBoxDataAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)&mLockBoxQueue;
Status = gMmst->MmInstallConfigurationTable (
gMmst,
&gEfiSmmLockBoxCommunicationGuid,
&mSmmLockBoxContext,
- sizeof(mSmmLockBoxContext)
+ sizeof (mSmmLockBoxContext)
);
ASSERT_EFI_ERROR (Status);
mSmmConfigurationTableInstalled = TRUE;
@@ -287,7 +288,7 @@ SmmLockBoxMmDestructor ( VOID
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
DEBUG ((DEBUG_INFO, "SmmLockBoxSmmLib SmmLockBoxMmDestructor in %a module\n", gEfiCallerBaseName));
@@ -313,6 +314,7 @@ SmmLockBoxMmDestructor ( );
ASSERT_EFI_ERROR (Status);
}
+
if (mSmmLockBoxRegistrationSmmEndOfDxe != NULL) {
//
// Unregister SmmEndOfDxe notification.
@@ -324,6 +326,7 @@ SmmLockBoxMmDestructor ( );
ASSERT_EFI_ERROR (Status);
}
+
if (mSmmLockBoxRegistrationEndOfS3Resume != NULL) {
//
// Unregister EndOfS3Resume notification.
@@ -349,13 +352,14 @@ InternalGetLockBoxQueue ( VOID
)
{
- SMM_LOCK_BOX_CONTEXT *SmmLockBoxContext;
+ SMM_LOCK_BOX_CONTEXT *SmmLockBoxContext;
SmmLockBoxContext = InternalGetSmmLockBoxContext ();
ASSERT (SmmLockBoxContext != NULL);
if (SmmLockBoxContext == NULL) {
return NULL;
}
+
return (LIST_ENTRY *)(UINTN)SmmLockBoxContext->LockBoxDataAddress;
}
@@ -368,19 +372,20 @@ InternalGetLockBoxQueue ( **/
SMM_LOCK_BOX_DATA *
InternalFindLockBoxByGuid (
- IN EFI_GUID *Guid
+ IN EFI_GUID *Guid
)
{
- LIST_ENTRY *Link;
- SMM_LOCK_BOX_DATA *LockBox;
- LIST_ENTRY *LockBoxQueue;
+ LIST_ENTRY *Link;
+ SMM_LOCK_BOX_DATA *LockBox;
+ LIST_ENTRY *LockBoxQueue;
LockBoxQueue = InternalGetLockBoxQueue ();
ASSERT (LockBoxQueue != NULL);
for (Link = LockBoxQueue->ForwardLink;
Link != LockBoxQueue;
- Link = Link->ForwardLink) {
+ Link = Link->ForwardLink)
+ {
LockBox = BASE_CR (
Link,
SMM_LOCK_BOX_DATA,
@@ -390,6 +395,7 @@ InternalFindLockBoxByGuid ( return LockBox;
}
}
+
return NULL;
}
@@ -411,15 +417,15 @@ InternalFindLockBoxByGuid ( RETURN_STATUS
EFIAPI
SaveLockBox (
- IN GUID *Guid,
- IN VOID *Buffer,
- IN UINTN Length
+ IN GUID *Guid,
+ IN VOID *Buffer,
+ IN UINTN Length
)
{
- SMM_LOCK_BOX_DATA *LockBox;
- EFI_PHYSICAL_ADDRESS SmramBuffer;
- EFI_STATUS Status;
- LIST_ENTRY *LockBoxQueue;
+ SMM_LOCK_BOX_DATA *LockBox;
+ EFI_PHYSICAL_ADDRESS SmramBuffer;
+ EFI_STATUS Status;
+ LIST_ENTRY *LockBoxQueue;
DEBUG ((DEBUG_INFO, "SmmLockBoxSmmLib SaveLockBox - Enter\n"));
@@ -460,7 +466,7 @@ SaveLockBox ( //
Status = gMmst->MmAllocatePool (
EfiRuntimeServicesData,
- sizeof(*LockBox),
+ sizeof (*LockBox),
(VOID **)&LockBox
);
ASSERT_EFI_ERROR (Status);
@@ -478,8 +484,8 @@ SaveLockBox ( //
// Insert LockBox to queue
//
- LockBox->Signature = SMM_LOCK_BOX_DATA_SIGNATURE;
- CopyMem (&LockBox->Guid, Guid, sizeof(EFI_GUID));
+ LockBox->Signature = SMM_LOCK_BOX_DATA_SIGNATURE;
+ CopyMem (&LockBox->Guid, Guid, sizeof (EFI_GUID));
LockBox->Buffer = (EFI_PHYSICAL_ADDRESS)(UINTN)Buffer;
LockBox->Length = (UINT64)Length;
LockBox->Attributes = 0;
@@ -520,11 +526,11 @@ SaveLockBox ( RETURN_STATUS
EFIAPI
SetLockBoxAttributes (
- IN GUID *Guid,
- IN UINT64 Attributes
+ IN GUID *Guid,
+ IN UINT64 Attributes
)
{
- SMM_LOCK_BOX_DATA *LockBox;
+ SMM_LOCK_BOX_DATA *LockBox;
DEBUG ((DEBUG_INFO, "SmmLockBoxSmmLib SetLockBoxAttributes - Enter\n"));
@@ -532,13 +538,15 @@ SetLockBoxAttributes ( // Basic check
//
if ((Guid == NULL) ||
- ((Attributes & ~(LOCK_BOX_ATTRIBUTE_RESTORE_IN_PLACE | LOCK_BOX_ATTRIBUTE_RESTORE_IN_S3_ONLY)) != 0)) {
+ ((Attributes & ~(LOCK_BOX_ATTRIBUTE_RESTORE_IN_PLACE | LOCK_BOX_ATTRIBUTE_RESTORE_IN_S3_ONLY)) != 0))
+ {
DEBUG ((DEBUG_INFO, "SmmLockBoxSmmLib SetLockBoxAttributes - Exit (%r)\n", EFI_INVALID_PARAMETER));
return EFI_INVALID_PARAMETER;
}
if (((Attributes & LOCK_BOX_ATTRIBUTE_RESTORE_IN_PLACE) != 0) &&
- ((Attributes & LOCK_BOX_ATTRIBUTE_RESTORE_IN_S3_ONLY) != 0)) {
+ ((Attributes & LOCK_BOX_ATTRIBUTE_RESTORE_IN_S3_ONLY) != 0))
+ {
DEBUG ((DEBUG_INFO, "SmmLockBoxSmmLib SetLockBoxAttributes - Exit (%r)\n", EFI_INVALID_PARAMETER));
DEBUG ((DEBUG_INFO, " LOCK_BOX_ATTRIBUTE_RESTORE_IN_PLACE and LOCK_BOX_ATTRIBUTE_RESTORE_IN_S3_ONLY\n\n"));
DEBUG ((DEBUG_INFO, " can not be set together\n"));
@@ -555,9 +563,10 @@ SetLockBoxAttributes ( }
if ((((Attributes & LOCK_BOX_ATTRIBUTE_RESTORE_IN_PLACE) != 0) &&
- ((LockBox->Attributes & LOCK_BOX_ATTRIBUTE_RESTORE_IN_S3_ONLY) != 0)) ||
+ ((LockBox->Attributes & LOCK_BOX_ATTRIBUTE_RESTORE_IN_S3_ONLY) != 0)) ||
(((LockBox->Attributes & LOCK_BOX_ATTRIBUTE_RESTORE_IN_PLACE) != 0) &&
- ((Attributes & LOCK_BOX_ATTRIBUTE_RESTORE_IN_S3_ONLY) != 0))) {
+ ((Attributes & LOCK_BOX_ATTRIBUTE_RESTORE_IN_S3_ONLY) != 0)))
+ {
DEBUG ((DEBUG_INFO, "SmmLockBoxSmmLib SetLockBoxAttributes 0x%lx 0x%lx - Exit (%r)\n", LockBox->Attributes, Attributes, EFI_INVALID_PARAMETER));
DEBUG ((DEBUG_INFO, " LOCK_BOX_ATTRIBUTE_RESTORE_IN_PLACE and LOCK_BOX_ATTRIBUTE_RESTORE_IN_S3_ONLY\n\n"));
DEBUG ((DEBUG_INFO, " can not be set together\n"));
@@ -598,15 +607,15 @@ SetLockBoxAttributes ( RETURN_STATUS
EFIAPI
UpdateLockBox (
- IN GUID *Guid,
- IN UINTN Offset,
- IN VOID *Buffer,
- IN UINTN Length
+ IN GUID *Guid,
+ IN UINTN Offset,
+ IN VOID *Buffer,
+ IN UINTN Length
)
{
- SMM_LOCK_BOX_DATA *LockBox;
- EFI_PHYSICAL_ADDRESS SmramBuffer;
- EFI_STATUS Status;
+ SMM_LOCK_BOX_DATA *LockBox;
+ EFI_PHYSICAL_ADDRESS SmramBuffer;
+ EFI_STATUS Status;
DEBUG ((DEBUG_INFO, "SmmLockBoxSmmLib UpdateLockBox - Enter\n"));
@@ -614,7 +623,8 @@ UpdateLockBox ( // Basic check
//
if ((Guid == NULL) || (Buffer == NULL) || (Length == 0) ||
- (Length > MAX_UINTN - Offset)) {
+ (Length > MAX_UINTN - Offset))
+ {
DEBUG ((DEBUG_INFO, "SmmLockBoxSmmLib UpdateLockBox - Exit (%r)\n", EFI_INVALID_PARAMETER));
return EFI_INVALID_PARAMETER;
}
@@ -683,6 +693,7 @@ UpdateLockBox ( Offset - (UINTN)LockBox->Length
);
}
+
LockBox->Length = Offset + Length;
} else {
//
@@ -693,6 +704,7 @@ UpdateLockBox ( return EFI_BUFFER_TOO_SMALL;
}
}
+
ASSERT ((UINTN)LockBox->SmramBuffer <= (MAX_ADDRESS - Offset));
CopyMem ((VOID *)((UINTN)LockBox->SmramBuffer + Offset), Buffer, Length);
@@ -724,13 +736,13 @@ UpdateLockBox ( RETURN_STATUS
EFIAPI
RestoreLockBox (
- IN GUID *Guid,
- IN VOID *Buffer OPTIONAL,
- IN OUT UINTN *Length OPTIONAL
+ IN GUID *Guid,
+ IN VOID *Buffer OPTIONAL,
+ IN OUT UINTN *Length OPTIONAL
)
{
- SMM_LOCK_BOX_DATA *LockBox;
- VOID *RestoreBuffer;
+ SMM_LOCK_BOX_DATA *LockBox;
+ VOID *RestoreBuffer;
DEBUG ((DEBUG_INFO, "SmmLockBoxSmmLib RestoreLockBox - Enter\n"));
@@ -739,7 +751,8 @@ RestoreLockBox ( //
if ((Guid == NULL) ||
((Buffer == NULL) && (Length != NULL)) ||
- ((Buffer != NULL) && (Length == NULL))) {
+ ((Buffer != NULL) && (Length == NULL)))
+ {
DEBUG ((DEBUG_INFO, "SmmLockBoxSmmLib RestoreLockBox - Exit (%r)\n", EFI_INVALID_PARAMETER));
return EFI_INVALID_PARAMETER;
}
@@ -758,7 +771,8 @@ RestoreLockBox ( if (((LockBox->Attributes & LOCK_BOX_ATTRIBUTE_RESTORE_IN_S3_ONLY) != 0) &&
mSmmLockBoxSmmReadyToLock &&
- !mSmmLockBoxDuringS3Resume) {
+ !mSmmLockBoxDuringS3Resume)
+ {
//
// With LOCK_BOX_ATTRIBUTE_RESTORE_IN_S3_ONLY,
// this LockBox can be restored in S3 resume only.
@@ -782,6 +796,7 @@ RestoreLockBox ( DEBUG ((DEBUG_INFO, "SmmLockBoxSmmLib RestoreLockBox - Exit (%r)\n", EFI_WRITE_PROTECTED));
return EFI_WRITE_PROTECTED;
}
+
RestoreBuffer = (VOID *)(UINTN)LockBox->Buffer;
}
@@ -797,6 +812,7 @@ RestoreLockBox ( DEBUG ((DEBUG_INFO, "SmmLockBoxSmmLib RestoreLockBox - Exit (%r)\n", EFI_BUFFER_TOO_SMALL));
return EFI_BUFFER_TOO_SMALL;
}
+
*Length = (UINTN)LockBox->Length;
}
@@ -825,9 +841,9 @@ RestoreAllLockBoxInPlace ( VOID
)
{
- SMM_LOCK_BOX_DATA *LockBox;
- LIST_ENTRY *Link;
- LIST_ENTRY *LockBoxQueue;
+ SMM_LOCK_BOX_DATA *LockBox;
+ LIST_ENTRY *Link;
+ LIST_ENTRY *LockBoxQueue;
DEBUG ((DEBUG_INFO, "SmmLockBoxSmmLib RestoreAllLockBoxInPlace - Enter\n"));
@@ -839,7 +855,8 @@ RestoreAllLockBoxInPlace ( //
for (Link = LockBoxQueue->ForwardLink;
Link != LockBoxQueue;
- Link = Link->ForwardLink) {
+ Link = Link->ForwardLink)
+ {
LockBox = BASE_CR (
Link,
SMM_LOCK_BOX_DATA,
@@ -852,6 +869,7 @@ RestoreAllLockBoxInPlace ( CopyMem ((VOID *)(UINTN)LockBox->Buffer, (VOID *)(UINTN)LockBox->SmramBuffer, (UINTN)LockBox->Length);
}
}
+
//
// Done
//
diff --git a/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxPeiLib.c b/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxPeiLib.c index 2dfbfc92a5..69d4c42ad1 100644 --- a/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxPeiLib.c +++ b/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxPeiLib.c @@ -28,10 +28,10 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #if defined (MDE_CPU_IA32)
typedef struct _LIST_ENTRY64 LIST_ENTRY64;
struct _LIST_ENTRY64 {
- LIST_ENTRY64 *ForwardLink;
- UINT32 Reserved1;
- LIST_ENTRY64 *BackLink;
- UINT32 Reserved2;
+ LIST_ENTRY64 *ForwardLink;
+ UINT32 Reserved1;
+ LIST_ENTRY64 *BackLink;
+ UINT32 Reserved2;
};
typedef struct {
@@ -57,14 +57,14 @@ typedef struct { } EFI_SMM_SYSTEM_TABLE2_64;
typedef struct {
- EFI_GUID VendorGuid;
- UINT64 VendorTable;
+ EFI_GUID VendorGuid;
+ UINT64 VendorTable;
} EFI_CONFIGURATION_TABLE64;
#endif
#if defined (MDE_CPU_X64)
-typedef LIST_ENTRY LIST_ENTRY64;
-typedef EFI_SMM_SYSTEM_TABLE2 EFI_SMM_SYSTEM_TABLE2_64;
+typedef LIST_ENTRY LIST_ENTRY64;
+typedef EFI_SMM_SYSTEM_TABLE2 EFI_SMM_SYSTEM_TABLE2_64;
typedef EFI_CONFIGURATION_TABLE EFI_CONFIGURATION_TABLE64;
#endif
@@ -77,10 +77,10 @@ typedef EFI_CONFIGURATION_TABLE EFI_CONFIGURATION_TABLE64; **/
LIST_ENTRY *
InternalInitLinkDxe (
- IN LIST_ENTRY *LinkList
+ IN LIST_ENTRY *LinkList
)
{
- if ((sizeof(UINTN) == sizeof(UINT32)) && (FeaturePcdGet (PcdDxeIplSwitchToLongMode)) ) {
+ if ((sizeof (UINTN) == sizeof (UINT32)) && (FeaturePcdGet (PcdDxeIplSwitchToLongMode))) {
//
// 32 PEI + 64 DXE
//
@@ -99,10 +99,10 @@ InternalInitLinkDxe ( **/
LIST_ENTRY *
InternalNextLinkDxe (
- IN LIST_ENTRY *Link
+ IN LIST_ENTRY *Link
)
{
- if ((sizeof(UINTN) == sizeof(UINT32)) && (FeaturePcdGet (PcdDxeIplSwitchToLongMode)) ) {
+ if ((sizeof (UINTN) == sizeof (UINT32)) && (FeaturePcdGet (PcdDxeIplSwitchToLongMode))) {
//
// 32 PEI + 64 DXE
//
@@ -122,16 +122,17 @@ InternalNextLinkDxe ( **/
SMM_LOCK_BOX_DATA *
InternalFindLockBoxByGuidFromSmram (
- IN LIST_ENTRY *LockBoxQueue,
- IN EFI_GUID *Guid
+ IN LIST_ENTRY *LockBoxQueue,
+ IN EFI_GUID *Guid
)
{
- LIST_ENTRY *Link;
- SMM_LOCK_BOX_DATA *LockBox;
+ LIST_ENTRY *Link;
+ SMM_LOCK_BOX_DATA *LockBox;
for (Link = InternalInitLinkDxe (LockBoxQueue);
Link != LockBoxQueue;
- Link = InternalNextLinkDxe (Link)) {
+ Link = InternalNextLinkDxe (Link))
+ {
LockBox = BASE_CR (
Link,
SMM_LOCK_BOX_DATA,
@@ -141,6 +142,7 @@ InternalFindLockBoxByGuidFromSmram ( return LockBox;
}
}
+
return NULL;
}
@@ -155,38 +157,40 @@ InternalFindLockBoxByGuidFromSmram ( **/
VOID *
InternalSmstGetVendorTableByGuid (
- IN UINT64 Signature,
- IN EFI_SMM_SYSTEM_TABLE2 *Smst,
- IN EFI_GUID *VendorGuid
+ IN UINT64 Signature,
+ IN EFI_SMM_SYSTEM_TABLE2 *Smst,
+ IN EFI_GUID *VendorGuid
)
{
- EFI_CONFIGURATION_TABLE *SmmConfigurationTable;
- UINTN NumberOfTableEntries;
- UINTN Index;
- EFI_SMM_SYSTEM_TABLE2_64 *Smst64;
- EFI_CONFIGURATION_TABLE64 *SmmConfigurationTable64;
+ EFI_CONFIGURATION_TABLE *SmmConfigurationTable;
+ UINTN NumberOfTableEntries;
+ UINTN Index;
+ EFI_SMM_SYSTEM_TABLE2_64 *Smst64;
+ EFI_CONFIGURATION_TABLE64 *SmmConfigurationTable64;
- if ((sizeof(UINTN) == sizeof(UINT32)) && (FeaturePcdGet (PcdDxeIplSwitchToLongMode))) {
+ if ((sizeof (UINTN) == sizeof (UINT32)) && (FeaturePcdGet (PcdDxeIplSwitchToLongMode))) {
//
// 32 PEI + 64 DXE
//
- Smst64 = (EFI_SMM_SYSTEM_TABLE2_64 *)Smst;
+ Smst64 = (EFI_SMM_SYSTEM_TABLE2_64 *)Smst;
SmmConfigurationTable64 = (EFI_CONFIGURATION_TABLE64 *)(UINTN)Smst64->SmmConfigurationTable;
- NumberOfTableEntries = (UINTN)Smst64->NumberOfTableEntries;
+ NumberOfTableEntries = (UINTN)Smst64->NumberOfTableEntries;
for (Index = 0; Index < NumberOfTableEntries; Index++) {
if (CompareGuid (&SmmConfigurationTable64[Index].VendorGuid, VendorGuid)) {
return (VOID *)(UINTN)SmmConfigurationTable64[Index].VendorTable;
}
}
+
return NULL;
} else {
SmmConfigurationTable = Smst->SmmConfigurationTable;
- NumberOfTableEntries = Smst->NumberOfTableEntries;
+ NumberOfTableEntries = Smst->NumberOfTableEntries;
for (Index = 0; Index < NumberOfTableEntries; Index++) {
if (CompareGuid (&SmmConfigurationTable[Index].VendorGuid, VendorGuid)) {
return (VOID *)SmmConfigurationTable[Index].VendorTable;
}
}
+
return NULL;
}
}
@@ -201,14 +205,14 @@ InternalGetSmmLockBoxContext ( VOID
)
{
- EFI_SMRAM_DESCRIPTOR *SmramDescriptor;
- SMM_S3_RESUME_STATE *SmmS3ResumeState;
- VOID *GuidHob;
- SMM_LOCK_BOX_CONTEXT *SmmLockBoxContext;
+ EFI_SMRAM_DESCRIPTOR *SmramDescriptor;
+ SMM_S3_RESUME_STATE *SmmS3ResumeState;
+ VOID *GuidHob;
+ SMM_LOCK_BOX_CONTEXT *SmmLockBoxContext;
GuidHob = GetFirstGuidHob (&gEfiAcpiVariableGuid);
ASSERT (GuidHob != NULL);
- SmramDescriptor = (EFI_SMRAM_DESCRIPTOR *) GET_GUID_HOB_DATA (GuidHob);
+ SmramDescriptor = (EFI_SMRAM_DESCRIPTOR *)GET_GUID_HOB_DATA (GuidHob);
SmmS3ResumeState = (SMM_S3_RESUME_STATE *)(UINTN)SmramDescriptor->CpuStart;
SmmLockBoxContext = (SMM_LOCK_BOX_CONTEXT *)InternalSmstGetVendorTableByGuid (
@@ -237,18 +241,18 @@ InternalGetSmmLockBoxContext ( **/
EFI_STATUS
InternalRestoreLockBoxFromSmram (
- IN GUID *Guid,
- IN VOID *Buffer OPTIONAL,
- IN OUT UINTN *Length OPTIONAL
+ IN GUID *Guid,
+ IN VOID *Buffer OPTIONAL,
+ IN OUT UINTN *Length OPTIONAL
)
{
- PEI_SMM_ACCESS_PPI *SmmAccess;
- UINTN Index;
- EFI_STATUS Status;
- SMM_LOCK_BOX_CONTEXT *SmmLockBoxContext;
- LIST_ENTRY *LockBoxQueue;
- SMM_LOCK_BOX_DATA *LockBox;
- VOID *RestoreBuffer;
+ PEI_SMM_ACCESS_PPI *SmmAccess;
+ UINTN Index;
+ EFI_STATUS Status;
+ SMM_LOCK_BOX_CONTEXT *SmmLockBoxContext;
+ LIST_ENTRY *LockBoxQueue;
+ SMM_LOCK_BOX_DATA *LockBox;
+ VOID *RestoreBuffer;
//
// Get needed resource
@@ -269,7 +273,7 @@ InternalRestoreLockBoxFromSmram ( // Get LockBox context
//
SmmLockBoxContext = InternalGetSmmLockBoxContext ();
- LockBoxQueue = (LIST_ENTRY *)(UINTN)SmmLockBoxContext->LockBoxDataAddress;
+ LockBoxQueue = (LIST_ENTRY *)(UINTN)SmmLockBoxContext->LockBoxDataAddress;
//
// We do NOT check Buffer address in SMRAM, because if SMRAM not locked, we trust the caller.
@@ -305,6 +309,7 @@ InternalRestoreLockBoxFromSmram ( if ((LockBox->Attributes & LOCK_BOX_ATTRIBUTE_RESTORE_IN_PLACE) == 0) {
return EFI_WRITE_PROTECTED;
}
+
RestoreBuffer = (VOID *)(UINTN)LockBox->Buffer;
}
@@ -319,6 +324,7 @@ InternalRestoreLockBoxFromSmram ( *Length = (UINTN)LockBox->Length;
return EFI_BUFFER_TOO_SMALL;
}
+
*Length = (UINTN)LockBox->Length;
}
@@ -343,13 +349,13 @@ InternalRestoreAllLockBoxInPlaceFromSmram ( VOID
)
{
- PEI_SMM_ACCESS_PPI *SmmAccess;
- UINTN Index;
- EFI_STATUS Status;
- SMM_LOCK_BOX_CONTEXT *SmmLockBoxContext;
- LIST_ENTRY *LockBoxQueue;
- SMM_LOCK_BOX_DATA *LockBox;
- LIST_ENTRY *Link;
+ PEI_SMM_ACCESS_PPI *SmmAccess;
+ UINTN Index;
+ EFI_STATUS Status;
+ SMM_LOCK_BOX_CONTEXT *SmmLockBoxContext;
+ LIST_ENTRY *LockBoxQueue;
+ SMM_LOCK_BOX_DATA *LockBox;
+ LIST_ENTRY *Link;
//
// Get needed resource
@@ -370,7 +376,7 @@ InternalRestoreAllLockBoxInPlaceFromSmram ( // Get LockBox context
//
SmmLockBoxContext = InternalGetSmmLockBoxContext ();
- LockBoxQueue = (LIST_ENTRY *)(UINTN)SmmLockBoxContext->LockBoxDataAddress;
+ LockBoxQueue = (LIST_ENTRY *)(UINTN)SmmLockBoxContext->LockBoxDataAddress;
//
// We do NOT check Buffer address in SMRAM, because if SMRAM not locked, we trust the caller.
@@ -381,7 +387,8 @@ InternalRestoreAllLockBoxInPlaceFromSmram ( //
for (Link = InternalInitLinkDxe (LockBoxQueue);
Link != LockBoxQueue;
- Link = InternalNextLinkDxe (Link)) {
+ Link = InternalNextLinkDxe (Link))
+ {
LockBox = BASE_CR (
Link,
SMM_LOCK_BOX_DATA,
@@ -394,6 +401,7 @@ InternalRestoreAllLockBoxInPlaceFromSmram ( CopyMem ((VOID *)(UINTN)LockBox->Buffer, (VOID *)(UINTN)LockBox->SmramBuffer, (UINTN)LockBox->Length);
}
}
+
//
// Done
//
@@ -418,9 +426,9 @@ InternalRestoreAllLockBoxInPlaceFromSmram ( RETURN_STATUS
EFIAPI
SaveLockBox (
- IN GUID *Guid,
- IN VOID *Buffer,
- IN UINTN Length
+ IN GUID *Guid,
+ IN VOID *Buffer,
+ IN UINTN Length
)
{
ASSERT (FALSE);
@@ -447,8 +455,8 @@ SaveLockBox ( RETURN_STATUS
EFIAPI
SetLockBoxAttributes (
- IN GUID *Guid,
- IN UINT64 Attributes
+ IN GUID *Guid,
+ IN UINT64 Attributes
)
{
ASSERT (FALSE);
@@ -481,10 +489,10 @@ SetLockBoxAttributes ( RETURN_STATUS
EFIAPI
UpdateLockBox (
- IN GUID *Guid,
- IN UINTN Offset,
- IN VOID *Buffer,
- IN UINTN Length
+ IN GUID *Guid,
+ IN UINTN Offset,
+ IN VOID *Buffer,
+ IN UINTN Length
)
{
ASSERT (FALSE);
@@ -516,18 +524,18 @@ UpdateLockBox ( RETURN_STATUS
EFIAPI
RestoreLockBox (
- IN GUID *Guid,
- IN VOID *Buffer OPTIONAL,
- IN OUT UINTN *Length OPTIONAL
+ IN GUID *Guid,
+ IN VOID *Buffer OPTIONAL,
+ IN OUT UINTN *Length OPTIONAL
)
{
- EFI_STATUS Status;
- EFI_PEI_SMM_COMMUNICATION_PPI *SmmCommunicationPpi;
- EFI_SMM_LOCK_BOX_PARAMETER_RESTORE *LockBoxParameterRestore;
- EFI_SMM_COMMUNICATE_HEADER *CommHeader;
- UINT8 CommBuffer[sizeof(EFI_GUID) + sizeof(UINT64) + sizeof(EFI_SMM_LOCK_BOX_PARAMETER_RESTORE)];
- UINTN CommSize;
- UINT64 MessageLength;
+ EFI_STATUS Status;
+ EFI_PEI_SMM_COMMUNICATION_PPI *SmmCommunicationPpi;
+ EFI_SMM_LOCK_BOX_PARAMETER_RESTORE *LockBoxParameterRestore;
+ EFI_SMM_COMMUNICATE_HEADER *CommHeader;
+ UINT8 CommBuffer[sizeof (EFI_GUID) + sizeof (UINT64) + sizeof (EFI_SMM_LOCK_BOX_PARAMETER_RESTORE)];
+ UINTN CommSize;
+ UINT64 MessageLength;
//
// Please aware that there is UINTN in EFI_SMM_COMMUNICATE_HEADER. It might be UINT64 in DXE, while it is UINT32 in PEI.
@@ -545,7 +553,8 @@ RestoreLockBox ( //
if ((Guid == NULL) ||
((Buffer == NULL) && (Length != NULL)) ||
- ((Buffer != NULL) && (Length == NULL))) {
+ ((Buffer != NULL) && (Length == NULL)))
+ {
return EFI_INVALID_PARAMETER;
}
@@ -569,29 +578,31 @@ RestoreLockBox ( // Prepare parameter
//
CommHeader = (EFI_SMM_COMMUNICATE_HEADER *)&CommBuffer[0];
- CopyMem (&CommHeader->HeaderGuid, &gEfiSmmLockBoxCommunicationGuid, sizeof(gEfiSmmLockBoxCommunicationGuid));
- if ((sizeof(UINTN) == sizeof(UINT32)) && (FeaturePcdGet (PcdDxeIplSwitchToLongMode)) ) {
- MessageLength = sizeof(*LockBoxParameterRestore);
- CopyMem (&CommBuffer[OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, MessageLength)], &MessageLength, sizeof(MessageLength));
+ CopyMem (&CommHeader->HeaderGuid, &gEfiSmmLockBoxCommunicationGuid, sizeof (gEfiSmmLockBoxCommunicationGuid));
+ if ((sizeof (UINTN) == sizeof (UINT32)) && (FeaturePcdGet (PcdDxeIplSwitchToLongMode))) {
+ MessageLength = sizeof (*LockBoxParameterRestore);
+ CopyMem (&CommBuffer[OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, MessageLength)], &MessageLength, sizeof (MessageLength));
} else {
- CommHeader->MessageLength = sizeof(*LockBoxParameterRestore);
+ CommHeader->MessageLength = sizeof (*LockBoxParameterRestore);
}
DEBUG ((DEBUG_INFO, "SmmLockBoxPeiLib CommBuffer - %x\n", &CommBuffer[0]));
- if ((sizeof(UINTN) == sizeof(UINT32)) && (FeaturePcdGet (PcdDxeIplSwitchToLongMode)) ) {
- LockBoxParameterRestore = (EFI_SMM_LOCK_BOX_PARAMETER_RESTORE *)&CommBuffer[OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, MessageLength) + sizeof(UINT64)];
+ if ((sizeof (UINTN) == sizeof (UINT32)) && (FeaturePcdGet (PcdDxeIplSwitchToLongMode))) {
+ LockBoxParameterRestore = (EFI_SMM_LOCK_BOX_PARAMETER_RESTORE *)&CommBuffer[OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, MessageLength) + sizeof (UINT64)];
} else {
- LockBoxParameterRestore = (EFI_SMM_LOCK_BOX_PARAMETER_RESTORE *)&CommBuffer[OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, MessageLength) + sizeof(UINTN)];
+ LockBoxParameterRestore = (EFI_SMM_LOCK_BOX_PARAMETER_RESTORE *)&CommBuffer[OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, MessageLength) + sizeof (UINTN)];
}
+
DEBUG ((DEBUG_INFO, "SmmLockBoxPeiLib LockBoxParameterRestore - %x\n", LockBoxParameterRestore));
- LockBoxParameterRestore->Header.Command = EFI_SMM_LOCK_BOX_COMMAND_RESTORE;
- LockBoxParameterRestore->Header.DataLength = sizeof(*LockBoxParameterRestore);
+ LockBoxParameterRestore->Header.Command = EFI_SMM_LOCK_BOX_COMMAND_RESTORE;
+ LockBoxParameterRestore->Header.DataLength = sizeof (*LockBoxParameterRestore);
LockBoxParameterRestore->Header.ReturnStatus = (UINT64)-1;
if (Guid != 0) {
- CopyMem (&LockBoxParameterRestore->Guid, Guid, sizeof(*Guid));
+ CopyMem (&LockBoxParameterRestore->Guid, Guid, sizeof (*Guid));
} else {
- ZeroMem (&LockBoxParameterRestore->Guid, sizeof(*Guid));
+ ZeroMem (&LockBoxParameterRestore->Guid, sizeof (*Guid));
}
+
LockBoxParameterRestore->Buffer = (EFI_PHYSICAL_ADDRESS)(UINTN)Buffer;
if (Length != NULL) {
LockBoxParameterRestore->Length = (EFI_PHYSICAL_ADDRESS)*Length;
@@ -602,18 +613,18 @@ RestoreLockBox ( //
// Send command
//
- CommSize = sizeof(CommBuffer);
- Status = SmmCommunicationPpi->Communicate (
- SmmCommunicationPpi,
- &CommBuffer[0],
- &CommSize
- );
+ CommSize = sizeof (CommBuffer);
+ Status = SmmCommunicationPpi->Communicate (
+ SmmCommunicationPpi,
+ &CommBuffer[0],
+ &CommSize
+ );
if (Status == EFI_NOT_STARTED) {
//
// Pei SMM communication not ready yet, so we access SMRAM directly
//
DEBUG ((DEBUG_INFO, "SmmLockBoxPeiLib Communicate - (%r)\n", Status));
- Status = InternalRestoreLockBoxFromSmram (Guid, Buffer, Length);
+ Status = InternalRestoreLockBoxFromSmram (Guid, Buffer, Length);
LockBoxParameterRestore->Header.ReturnStatus = (UINT64)Status;
if (Length != NULL) {
LockBoxParameterRestore->Length = (UINT64)*Length;
@@ -651,13 +662,13 @@ RestoreAllLockBoxInPlace ( VOID
)
{
- EFI_STATUS Status;
- EFI_PEI_SMM_COMMUNICATION_PPI *SmmCommunicationPpi;
- EFI_SMM_LOCK_BOX_PARAMETER_RESTORE_ALL_IN_PLACE *LockBoxParameterRestoreAllInPlace;
- EFI_SMM_COMMUNICATE_HEADER *CommHeader;
- UINT8 CommBuffer[sizeof(EFI_GUID) + sizeof(UINT64) + sizeof(EFI_SMM_LOCK_BOX_PARAMETER_RESTORE_ALL_IN_PLACE)];
- UINTN CommSize;
- UINT64 MessageLength;
+ EFI_STATUS Status;
+ EFI_PEI_SMM_COMMUNICATION_PPI *SmmCommunicationPpi;
+ EFI_SMM_LOCK_BOX_PARAMETER_RESTORE_ALL_IN_PLACE *LockBoxParameterRestoreAllInPlace;
+ EFI_SMM_COMMUNICATE_HEADER *CommHeader;
+ UINT8 CommBuffer[sizeof (EFI_GUID) + sizeof (UINT64) + sizeof (EFI_SMM_LOCK_BOX_PARAMETER_RESTORE_ALL_IN_PLACE)];
+ UINTN CommSize;
+ UINT64 MessageLength;
//
// Please aware that there is UINTN in EFI_SMM_COMMUNICATE_HEADER. It might be UINT64 in DXE, while it is UINT32 in PEI.
@@ -690,40 +701,42 @@ RestoreAllLockBoxInPlace ( // Prepare parameter
//
CommHeader = (EFI_SMM_COMMUNICATE_HEADER *)&CommBuffer[0];
- CopyMem (&CommHeader->HeaderGuid, &gEfiSmmLockBoxCommunicationGuid, sizeof(gEfiSmmLockBoxCommunicationGuid));
- if ((sizeof(UINTN) == sizeof(UINT32)) && (FeaturePcdGet (PcdDxeIplSwitchToLongMode)) ) {
- MessageLength = sizeof(*LockBoxParameterRestoreAllInPlace);
- CopyMem (&CommBuffer[OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, MessageLength)], &MessageLength, sizeof(MessageLength));
+ CopyMem (&CommHeader->HeaderGuid, &gEfiSmmLockBoxCommunicationGuid, sizeof (gEfiSmmLockBoxCommunicationGuid));
+ if ((sizeof (UINTN) == sizeof (UINT32)) && (FeaturePcdGet (PcdDxeIplSwitchToLongMode))) {
+ MessageLength = sizeof (*LockBoxParameterRestoreAllInPlace);
+ CopyMem (&CommBuffer[OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, MessageLength)], &MessageLength, sizeof (MessageLength));
} else {
- CommHeader->MessageLength = sizeof(*LockBoxParameterRestoreAllInPlace);
+ CommHeader->MessageLength = sizeof (*LockBoxParameterRestoreAllInPlace);
}
- if ((sizeof(UINTN) == sizeof(UINT32)) && (FeaturePcdGet (PcdDxeIplSwitchToLongMode)) ) {
- LockBoxParameterRestoreAllInPlace = (EFI_SMM_LOCK_BOX_PARAMETER_RESTORE_ALL_IN_PLACE *)&CommBuffer[OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, MessageLength) + sizeof(UINT64)];
+ if ((sizeof (UINTN) == sizeof (UINT32)) && (FeaturePcdGet (PcdDxeIplSwitchToLongMode))) {
+ LockBoxParameterRestoreAllInPlace = (EFI_SMM_LOCK_BOX_PARAMETER_RESTORE_ALL_IN_PLACE *)&CommBuffer[OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, MessageLength) + sizeof (UINT64)];
} else {
- LockBoxParameterRestoreAllInPlace = (EFI_SMM_LOCK_BOX_PARAMETER_RESTORE_ALL_IN_PLACE *)&CommBuffer[OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, MessageLength) + sizeof(UINTN)];
+ LockBoxParameterRestoreAllInPlace = (EFI_SMM_LOCK_BOX_PARAMETER_RESTORE_ALL_IN_PLACE *)&CommBuffer[OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, MessageLength) + sizeof (UINTN)];
}
- LockBoxParameterRestoreAllInPlace->Header.Command = EFI_SMM_LOCK_BOX_COMMAND_RESTORE_ALL_IN_PLACE;
- LockBoxParameterRestoreAllInPlace->Header.DataLength = sizeof(*LockBoxParameterRestoreAllInPlace);
+
+ LockBoxParameterRestoreAllInPlace->Header.Command = EFI_SMM_LOCK_BOX_COMMAND_RESTORE_ALL_IN_PLACE;
+ LockBoxParameterRestoreAllInPlace->Header.DataLength = sizeof (*LockBoxParameterRestoreAllInPlace);
LockBoxParameterRestoreAllInPlace->Header.ReturnStatus = (UINT64)-1;
//
// Send command
//
- CommSize = sizeof(CommBuffer);
- Status = SmmCommunicationPpi->Communicate (
- SmmCommunicationPpi,
- &CommBuffer[0],
- &CommSize
- );
+ CommSize = sizeof (CommBuffer);
+ Status = SmmCommunicationPpi->Communicate (
+ SmmCommunicationPpi,
+ &CommBuffer[0],
+ &CommSize
+ );
if (Status == EFI_NOT_STARTED) {
//
// Pei SMM communication not ready yet, so we access SMRAM directly
//
DEBUG ((DEBUG_INFO, "SmmLockBoxPeiLib Communicate - (%r)\n", Status));
- Status = InternalRestoreAllLockBoxInPlaceFromSmram ();
+ Status = InternalRestoreAllLockBoxInPlaceFromSmram ();
LockBoxParameterRestoreAllInPlace->Header.ReturnStatus = (UINT64)Status;
}
+
ASSERT_EFI_ERROR (Status);
Status = (EFI_STATUS)LockBoxParameterRestoreAllInPlace->Header.ReturnStatus;
diff --git a/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxStandaloneMmLib.c b/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxStandaloneMmLib.c index 722121da43..a8f9d30862 100644 --- a/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxStandaloneMmLib.c +++ b/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxStandaloneMmLib.c @@ -45,8 +45,8 @@ SmmLockBoxStandaloneMmConstructor ( EFI_STATUS
EFIAPI
SmmLockBoxStandaloneMmDestructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_MM_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_MM_SYSTEM_TABLE *SystemTable
)
{
return SmmLockBoxMmDestructor ();
diff --git a/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxTraditionalMmLib.c b/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxTraditionalMmLib.c index a748abb16c..fbbea1a49a 100644 --- a/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxTraditionalMmLib.c +++ b/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxTraditionalMmLib.c @@ -45,8 +45,8 @@ SmmLockBoxTraditionalConstructor ( EFI_STATUS
EFIAPI
SmmLockBoxTraditionalDestructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
return SmmLockBoxMmDestructor ();
diff --git a/MdeModulePkg/Library/SmmMemoryAllocationProfileLib/MemoryAllocationLib.c b/MdeModulePkg/Library/SmmMemoryAllocationProfileLib/MemoryAllocationLib.c index 27a6748f58..17c380a1d8 100644 --- a/MdeModulePkg/Library/SmmMemoryAllocationProfileLib/MemoryAllocationLib.c +++ b/MdeModulePkg/Library/SmmMemoryAllocationProfileLib/MemoryAllocationLib.c @@ -69,11 +69,11 @@ SmmMemoryAllocationLibConstructor ( //
// Get SMRAM range information
//
- Size = 0;
+ Size = 0;
Status = SmmAccess->GetCapabilities (SmmAccess, &Size, NULL);
ASSERT (Status == EFI_BUFFER_TOO_SMALL);
- mSmramRanges = (EFI_SMRAM_DESCRIPTOR *) AllocatePool (Size);
+ mSmramRanges = (EFI_SMRAM_DESCRIPTOR *)AllocatePool (Size);
ASSERT (mSmramRanges != NULL);
Status = SmmAccess->GetCapabilities (SmmAccess, &Size, mSmramRanges);
@@ -116,14 +116,15 @@ SmmMemoryAllocationLibDestructor ( BOOLEAN
EFIAPI
BufferInSmram (
- IN VOID *Buffer
+ IN VOID *Buffer
)
{
UINTN Index;
- for (Index = 0; Index < mSmramRangeCount; Index ++) {
- if (((EFI_PHYSICAL_ADDRESS) (UINTN) Buffer >= mSmramRanges[Index].CpuStart) &&
- ((EFI_PHYSICAL_ADDRESS) (UINTN) Buffer < (mSmramRanges[Index].CpuStart + mSmramRanges[Index].PhysicalSize))) {
+ for (Index = 0; Index < mSmramRangeCount; Index++) {
+ if (((EFI_PHYSICAL_ADDRESS)(UINTN)Buffer >= mSmramRanges[Index].CpuStart) &&
+ ((EFI_PHYSICAL_ADDRESS)(UINTN)Buffer < (mSmramRanges[Index].CpuStart + mSmramRanges[Index].PhysicalSize)))
+ {
return TRUE;
}
}
@@ -162,7 +163,8 @@ InternalAllocatePages ( if (EFI_ERROR (Status)) {
return NULL;
}
- return (VOID *) (UINTN) Memory;
+
+ return (VOID *)(UINTN)Memory;
}
/**
@@ -189,14 +191,15 @@ AllocatePages ( Buffer = InternalAllocatePages (EfiRuntimeServicesData, Pages);
if (Buffer != NULL) {
MemoryProfileLibRecord (
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
MEMORY_PROFILE_ACTION_LIB_ALLOCATE_PAGES,
EfiRuntimeServicesData,
Buffer,
- EFI_PAGES_TO_SIZE(Pages),
+ EFI_PAGES_TO_SIZE (Pages),
NULL
);
}
+
return Buffer;
}
@@ -224,14 +227,15 @@ AllocateRuntimePages ( Buffer = InternalAllocatePages (EfiRuntimeServicesData, Pages);
if (Buffer != NULL) {
MemoryProfileLibRecord (
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RUNTIME_PAGES,
EfiRuntimeServicesData,
Buffer,
- EFI_PAGES_TO_SIZE(Pages),
+ EFI_PAGES_TO_SIZE (Pages),
NULL
);
}
+
return Buffer;
}
@@ -289,14 +293,15 @@ FreePages ( // When Buffer is in SMRAM range, it should be allocated by gSmst->SmmAllocatePages() service.
// So, gSmst->SmmFreePages() service is used to free it.
//
- Status = gSmst->SmmFreePages ((EFI_PHYSICAL_ADDRESS) (UINTN) Buffer, Pages);
+ Status = gSmst->SmmFreePages ((EFI_PHYSICAL_ADDRESS)(UINTN)Buffer, Pages);
} else {
//
// When Buffer is out of SMRAM range, it should be allocated by gBS->AllocatePages() service.
// So, gBS->FreePages() service is used to free it.
//
- Status = gBS->FreePages ((EFI_PHYSICAL_ADDRESS) (UINTN) Buffer, Pages);
+ Status = gBS->FreePages ((EFI_PHYSICAL_ADDRESS)(UINTN)Buffer, Pages);
}
+
ASSERT_EFI_ERROR (Status);
}
@@ -341,23 +346,25 @@ InternalAllocateAlignedPages ( if (Pages == 0) {
return NULL;
}
+
if (Alignment > EFI_PAGE_SIZE) {
//
// Calculate the total number of pages since alignment is larger than page size.
//
- AlignmentMask = Alignment - 1;
- RealPages = Pages + EFI_SIZE_TO_PAGES (Alignment);
+ AlignmentMask = Alignment - 1;
+ RealPages = Pages + EFI_SIZE_TO_PAGES (Alignment);
//
// Make sure that Pages plus EFI_SIZE_TO_PAGES (Alignment) does not overflow.
//
ASSERT (RealPages > Pages);
- Status = gSmst->SmmAllocatePages (AllocateAnyPages, MemoryType, RealPages, &Memory);
+ Status = gSmst->SmmAllocatePages (AllocateAnyPages, MemoryType, RealPages, &Memory);
if (EFI_ERROR (Status)) {
return NULL;
}
- AlignedMemory = ((UINTN) Memory + AlignmentMask) & ~AlignmentMask;
- UnalignedPages = EFI_SIZE_TO_PAGES (AlignedMemory - (UINTN) Memory);
+
+ AlignedMemory = ((UINTN)Memory + AlignmentMask) & ~AlignmentMask;
+ UnalignedPages = EFI_SIZE_TO_PAGES (AlignedMemory - (UINTN)Memory);
if (UnalignedPages > 0) {
//
// Free first unaligned page(s).
@@ -365,6 +372,7 @@ InternalAllocateAlignedPages ( Status = gSmst->SmmFreePages (Memory, UnalignedPages);
ASSERT_EFI_ERROR (Status);
}
+
Memory = AlignedMemory + EFI_PAGES_TO_SIZE (Pages);
UnalignedPages = RealPages - Pages - UnalignedPages;
if (UnalignedPages > 0) {
@@ -382,9 +390,11 @@ InternalAllocateAlignedPages ( if (EFI_ERROR (Status)) {
return NULL;
}
- AlignedMemory = (UINTN) Memory;
+
+ AlignedMemory = (UINTN)Memory;
}
- return (VOID *) AlignedMemory;
+
+ return (VOID *)AlignedMemory;
}
/**
@@ -418,14 +428,15 @@ AllocateAlignedPages ( Buffer = InternalAllocateAlignedPages (EfiRuntimeServicesData, Pages, Alignment);
if (Buffer != NULL) {
MemoryProfileLibRecord (
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
MEMORY_PROFILE_ACTION_LIB_ALLOCATE_ALIGNED_PAGES,
EfiRuntimeServicesData,
Buffer,
- EFI_PAGES_TO_SIZE(Pages),
+ EFI_PAGES_TO_SIZE (Pages),
NULL
);
}
+
return Buffer;
}
@@ -460,14 +471,15 @@ AllocateAlignedRuntimePages ( Buffer = InternalAllocateAlignedPages (EfiRuntimeServicesData, Pages, Alignment);
if (Buffer != NULL) {
MemoryProfileLibRecord (
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
MEMORY_PROFILE_ACTION_LIB_ALLOCATE_ALIGNED_RUNTIME_PAGES,
EfiRuntimeServicesData,
Buffer,
- EFI_PAGES_TO_SIZE(Pages),
+ EFI_PAGES_TO_SIZE (Pages),
NULL
);
}
+
return Buffer;
}
@@ -532,14 +544,15 @@ FreeAlignedPages ( // When Buffer is in SMRAM range, it should be allocated by gSmst->SmmAllocatePages() service.
// So, gSmst->SmmFreePages() service is used to free it.
//
- Status = gSmst->SmmFreePages ((EFI_PHYSICAL_ADDRESS) (UINTN) Buffer, Pages);
+ Status = gSmst->SmmFreePages ((EFI_PHYSICAL_ADDRESS)(UINTN)Buffer, Pages);
} else {
//
// When Buffer is out of SMRAM range, it should be allocated by gBS->AllocatePages() service.
// So, gBS->FreePages() service is used to free it.
//
- Status = gBS->FreePages ((EFI_PHYSICAL_ADDRESS) (UINTN) Buffer, Pages);
+ Status = gBS->FreePages ((EFI_PHYSICAL_ADDRESS)(UINTN)Buffer, Pages);
}
+
ASSERT_EFI_ERROR (Status);
}
@@ -570,6 +583,7 @@ InternalAllocatePool ( if (EFI_ERROR (Status)) {
Memory = NULL;
}
+
return Memory;
}
@@ -597,7 +611,7 @@ AllocatePool ( Buffer = InternalAllocatePool (EfiRuntimeServicesData, AllocationSize);
if (Buffer != NULL) {
MemoryProfileLibRecord (
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
MEMORY_PROFILE_ACTION_LIB_ALLOCATE_POOL,
EfiRuntimeServicesData,
Buffer,
@@ -605,6 +619,7 @@ AllocatePool ( NULL
);
}
+
return Buffer;
}
@@ -632,7 +647,7 @@ AllocateRuntimePool ( Buffer = InternalAllocatePool (EfiRuntimeServicesData, AllocationSize);
if (Buffer != NULL) {
MemoryProfileLibRecord (
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RUNTIME_POOL,
EfiRuntimeServicesData,
Buffer,
@@ -640,6 +655,7 @@ AllocateRuntimePool ( NULL
);
}
+
return Buffer;
}
@@ -691,6 +707,7 @@ InternalAllocateZeroPool ( if (Memory != NULL) {
Memory = ZeroMem (Memory, AllocationSize);
}
+
return Memory;
}
@@ -718,7 +735,7 @@ AllocateZeroPool ( Buffer = InternalAllocateZeroPool (EfiRuntimeServicesData, AllocationSize);
if (Buffer != NULL) {
MemoryProfileLibRecord (
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
MEMORY_PROFILE_ACTION_LIB_ALLOCATE_ZERO_POOL,
EfiRuntimeServicesData,
Buffer,
@@ -726,6 +743,7 @@ AllocateZeroPool ( NULL
);
}
+
return Buffer;
}
@@ -753,7 +771,7 @@ AllocateRuntimeZeroPool ( Buffer = InternalAllocateZeroPool (EfiRuntimeServicesData, AllocationSize);
if (Buffer != NULL) {
MemoryProfileLibRecord (
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RUNTIME_ZERO_POOL,
EfiRuntimeServicesData,
Buffer,
@@ -761,6 +779,7 @@ AllocateRuntimeZeroPool ( NULL
);
}
+
return Buffer;
}
@@ -813,12 +832,13 @@ InternalAllocateCopyPool ( VOID *Memory;
ASSERT (Buffer != NULL);
- ASSERT (AllocationSize <= (MAX_ADDRESS - (UINTN) Buffer + 1));
+ ASSERT (AllocationSize <= (MAX_ADDRESS - (UINTN)Buffer + 1));
Memory = InternalAllocatePool (PoolType, AllocationSize);
if (Memory != NULL) {
- Memory = CopyMem (Memory, Buffer, AllocationSize);
+ Memory = CopyMem (Memory, Buffer, AllocationSize);
}
+
return Memory;
}
@@ -852,7 +872,7 @@ AllocateCopyPool ( NewBuffer = InternalAllocateCopyPool (EfiRuntimeServicesData, AllocationSize, Buffer);
if (NewBuffer != NULL) {
MemoryProfileLibRecord (
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
MEMORY_PROFILE_ACTION_LIB_ALLOCATE_COPY_POOL,
EfiRuntimeServicesData,
NewBuffer,
@@ -860,6 +880,7 @@ AllocateCopyPool ( NULL
);
}
+
return NewBuffer;
}
@@ -893,7 +914,7 @@ AllocateRuntimeCopyPool ( NewBuffer = InternalAllocateCopyPool (EfiRuntimeServicesData, AllocationSize, Buffer);
if (NewBuffer != NULL) {
MemoryProfileLibRecord (
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RUNTIME_COPY_POOL,
EfiRuntimeServicesData,
NewBuffer,
@@ -901,6 +922,7 @@ AllocateRuntimeCopyPool ( NULL
);
}
+
return NewBuffer;
}
@@ -965,10 +987,11 @@ InternalReallocatePool ( VOID *NewBuffer;
NewBuffer = InternalAllocateZeroPool (PoolType, NewSize);
- if (NewBuffer != NULL && OldBuffer != NULL) {
+ if ((NewBuffer != NULL) && (OldBuffer != NULL)) {
CopyMem (NewBuffer, OldBuffer, MIN (OldSize, NewSize));
FreePool (OldBuffer);
}
+
return NewBuffer;
}
@@ -1006,7 +1029,7 @@ ReallocatePool ( Buffer = InternalReallocatePool (EfiRuntimeServicesData, OldSize, NewSize, OldBuffer);
if (Buffer != NULL) {
MemoryProfileLibRecord (
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
MEMORY_PROFILE_ACTION_LIB_REALLOCATE_POOL,
EfiRuntimeServicesData,
Buffer,
@@ -1014,6 +1037,7 @@ ReallocatePool ( NULL
);
}
+
return Buffer;
}
@@ -1051,7 +1075,7 @@ ReallocateRuntimePool ( Buffer = InternalReallocatePool (EfiRuntimeServicesData, OldSize, NewSize, OldBuffer);
if (Buffer != NULL) {
MemoryProfileLibRecord (
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
MEMORY_PROFILE_ACTION_LIB_REALLOCATE_RUNTIME_POOL,
EfiRuntimeServicesData,
Buffer,
@@ -1059,6 +1083,7 @@ ReallocateRuntimePool ( NULL
);
}
+
return Buffer;
}
@@ -1112,10 +1137,10 @@ ReallocateReservedPool ( VOID
EFIAPI
FreePool (
- IN VOID *Buffer
+ IN VOID *Buffer
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
if (BufferInSmram (Buffer)) {
//
@@ -1130,5 +1155,6 @@ FreePool ( //
Status = gBS->FreePool (Buffer);
}
+
ASSERT_EFI_ERROR (Status);
}
diff --git a/MdeModulePkg/Library/SmmMemoryAllocationProfileLib/SmmMemoryProfileLib.c b/MdeModulePkg/Library/SmmMemoryAllocationProfileLib/SmmMemoryProfileLib.c index 83ffcf5109..a874a7489d 100644 --- a/MdeModulePkg/Library/SmmMemoryAllocationProfileLib/SmmMemoryProfileLib.c +++ b/MdeModulePkg/Library/SmmMemoryAllocationProfileLib/SmmMemoryProfileLib.c @@ -14,8 +14,8 @@ #include <Guid/MemoryProfile.h>
-EDKII_MEMORY_PROFILE_PROTOCOL *mLibProfileProtocol;
-EDKII_SMM_MEMORY_PROFILE_PROTOCOL *mLibSmmProfileProtocol;
+EDKII_MEMORY_PROFILE_PROTOCOL *mLibProfileProtocol;
+EDKII_SMM_MEMORY_PROFILE_PROTOCOL *mLibSmmProfileProtocol;
/**
Check whether the start address of buffer is within any of the SMRAM ranges.
@@ -28,7 +28,7 @@ EDKII_SMM_MEMORY_PROFILE_PROTOCOL *mLibSmmProfileProtocol; BOOLEAN
EFIAPI
BufferInSmram (
- IN VOID *Buffer
+ IN VOID *Buffer
);
/**
@@ -47,7 +47,7 @@ SmmMemoryProfileLibConstructor ( IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
//
// Locate Profile Protocol
@@ -98,18 +98,19 @@ SmmMemoryProfileLibConstructor ( EFI_STATUS
EFIAPI
MemoryProfileLibRecord (
- IN PHYSICAL_ADDRESS CallerAddress,
- IN MEMORY_PROFILE_ACTION Action,
- IN EFI_MEMORY_TYPE MemoryType,
- IN VOID *Buffer,
- IN UINTN Size,
- IN CHAR8 *ActionString OPTIONAL
+ IN PHYSICAL_ADDRESS CallerAddress,
+ IN MEMORY_PROFILE_ACTION Action,
+ IN EFI_MEMORY_TYPE MemoryType,
+ IN VOID *Buffer,
+ IN UINTN Size,
+ IN CHAR8 *ActionString OPTIONAL
)
{
if (BufferInSmram (Buffer)) {
if (mLibSmmProfileProtocol == NULL) {
return EFI_UNSUPPORTED;
}
+
return mLibSmmProfileProtocol->Record (
mLibSmmProfileProtocol,
CallerAddress,
@@ -123,6 +124,7 @@ MemoryProfileLibRecord ( if (mLibProfileProtocol == NULL) {
return EFI_UNSUPPORTED;
}
+
return mLibProfileProtocol->Record (
mLibProfileProtocol,
CallerAddress,
@@ -134,4 +136,3 @@ MemoryProfileLibRecord ( );
}
}
-
diff --git a/MdeModulePkg/Library/SmmPerformanceLib/SmmPerformanceLib.c b/MdeModulePkg/Library/SmmPerformanceLib/SmmPerformanceLib.c index c3fa79b2de..623f8a978c 100644 --- a/MdeModulePkg/Library/SmmPerformanceLib/SmmPerformanceLib.c +++ b/MdeModulePkg/Library/SmmPerformanceLib/SmmPerformanceLib.c @@ -11,7 +11,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent **/
-
#include <Guid/PerformanceMeasurement.h>
#include <Library/PerformanceLib.h>
@@ -41,8 +40,7 @@ SmmPerformanceLibConstructor ( IN EFI_SYSTEM_TABLE *SystemTable
)
{
-
- mPerformanceMeasurementEnabled = (BOOLEAN) ((PcdGet8(PcdPerformanceLibraryPropertyMask) & PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED) != 0);
+ mPerformanceMeasurementEnabled = (BOOLEAN)((PcdGet8 (PcdPerformanceLibraryPropertyMask) & PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED) != 0);
return EFI_SUCCESS;
}
@@ -61,14 +59,14 @@ GetPerformanceMeasurementProtocol ( VOID
)
{
- EFI_STATUS Status;
- EDKII_PERFORMANCE_MEASUREMENT_PROTOCOL *PerformanceMeasurement;
+ EFI_STATUS Status;
+ EDKII_PERFORMANCE_MEASUREMENT_PROTOCOL *PerformanceMeasurement;
if (mPerformanceMeasurement != NULL) {
return EFI_SUCCESS;
}
- Status = gSmst->SmmLocateProtocol (&gEdkiiSmmPerformanceMeasurementProtocolGuid, NULL, (VOID **) &PerformanceMeasurement);
+ Status = gSmst->SmmLocateProtocol (&gEdkiiSmmPerformanceMeasurementProtocolGuid, NULL, (VOID **)&PerformanceMeasurement);
if (!EFI_ERROR (Status)) {
ASSERT (PerformanceMeasurement != NULL);
//
@@ -77,6 +75,7 @@ GetPerformanceMeasurementProtocol ( mPerformanceMeasurement = PerformanceMeasurement;
return EFI_SUCCESS;
}
+
return EFI_NOT_FOUND;
}
@@ -112,8 +111,8 @@ StartPerformanceMeasurementEx ( IN UINT32 Identifier
)
{
- EFI_STATUS Status;
- CONST CHAR8* String;
+ EFI_STATUS Status;
+ CONST CHAR8 *String;
Status = GetPerformanceMeasurementProtocol ();
if (EFI_ERROR (Status)) {
@@ -134,7 +133,7 @@ StartPerformanceMeasurementEx ( ASSERT (FALSE);
}
- return (RETURN_STATUS) Status;
+ return (RETURN_STATUS)Status;
}
/**
@@ -171,8 +170,8 @@ EndPerformanceMeasurementEx ( IN UINT32 Identifier
)
{
- EFI_STATUS Status;
- CONST CHAR8* String;
+ EFI_STATUS Status;
+ CONST CHAR8 *String;
Status = GetPerformanceMeasurementProtocol ();
if (EFI_ERROR (Status)) {
@@ -193,7 +192,7 @@ EndPerformanceMeasurementEx ( ASSERT (FALSE);
}
- return (RETURN_STATUS) Status;
+ return (RETURN_STATUS)Status;
}
/**
@@ -240,13 +239,13 @@ EndPerformanceMeasurementEx ( UINTN
EFIAPI
GetPerformanceMeasurementEx (
- IN UINTN LogEntryKey,
- OUT CONST VOID **Handle,
- OUT CONST CHAR8 **Token,
- OUT CONST CHAR8 **Module,
- OUT UINT64 *StartTimeStamp,
- OUT UINT64 *EndTimeStamp,
- OUT UINT32 *Identifier
+ IN UINTN LogEntryKey,
+ OUT CONST VOID **Handle,
+ OUT CONST CHAR8 **Token,
+ OUT CONST CHAR8 **Module,
+ OUT UINT64 *StartTimeStamp,
+ OUT UINT64 *EndTimeStamp,
+ OUT UINT32 *Identifier
)
{
return 0;
@@ -360,12 +359,12 @@ EndPerformanceMeasurement ( UINTN
EFIAPI
GetPerformanceMeasurement (
- IN UINTN LogEntryKey,
- OUT CONST VOID **Handle,
- OUT CONST CHAR8 **Token,
- OUT CONST CHAR8 **Module,
- OUT UINT64 *StartTimeStamp,
- OUT UINT64 *EndTimeStamp
+ IN UINTN LogEntryKey,
+ OUT CONST VOID **Handle,
+ OUT CONST CHAR8 **Token,
+ OUT CONST CHAR8 **Module,
+ OUT UINT64 *StartTimeStamp,
+ OUT UINT64 *EndTimeStamp
)
{
return 0;
@@ -430,7 +429,7 @@ LogPerformanceMeasurement ( ASSERT (FALSE);
}
- return (RETURN_STATUS) Status;
+ return (RETURN_STATUS)Status;
}
/**
@@ -448,14 +447,15 @@ LogPerformanceMeasurement ( BOOLEAN
EFIAPI
LogPerformanceMeasurementEnabled (
- IN CONST UINTN Type
+ IN CONST UINTN Type
)
{
//
// When Performance measurement is enabled and the type is not filtered, the performance can be logged.
//
- if (PerformanceMeasurementEnabled () && (PcdGet8(PcdPerformanceLibraryPropertyMask) & Type) == 0) {
+ if (PerformanceMeasurementEnabled () && ((PcdGet8 (PcdPerformanceLibraryPropertyMask) & Type) == 0)) {
return TRUE;
}
+
return FALSE;
}
diff --git a/MdeModulePkg/Library/SmmReportStatusCodeLib/ReportStatusCodeLib.c b/MdeModulePkg/Library/SmmReportStatusCodeLib/ReportStatusCodeLib.c index fb1769db92..f9afd1f13c 100644 --- a/MdeModulePkg/Library/SmmReportStatusCodeLib/ReportStatusCodeLib.c +++ b/MdeModulePkg/Library/SmmReportStatusCodeLib/ReportStatusCodeLib.c @@ -20,9 +20,8 @@ #include "ReportStatusCodeLib.h"
-EFI_MM_REPORT_STATUS_CODE mReportStatusCode = NULL;
-EFI_MM_STATUS_CODE_PROTOCOL *mStatusCodeProtocol = NULL;
-
+EFI_MM_REPORT_STATUS_CODE mReportStatusCode = NULL;
+EFI_MM_STATUS_CODE_PROTOCOL *mStatusCodeProtocol = NULL;
/**
Locate the report status code service.
@@ -36,12 +35,13 @@ InternalGetReportStatusCode ( VOID
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
- Status = InternalLocateProtocol (&gEfiMmStatusCodeProtocolGuid, NULL, (VOID**)&mStatusCodeProtocol);
- if (!EFI_ERROR (Status) && mStatusCodeProtocol != NULL) {
+ Status = InternalLocateProtocol (&gEfiMmStatusCodeProtocolGuid, NULL, (VOID **)&mStatusCodeProtocol);
+ if (!EFI_ERROR (Status) && (mStatusCodeProtocol != NULL)) {
return mStatusCodeProtocol->ReportStatusCode;
}
+
return NULL;
}
@@ -69,16 +69,17 @@ InternalGetReportStatusCode ( **/
EFI_STATUS
InternalReportStatusCode (
- IN EFI_STATUS_CODE_TYPE Type,
- IN EFI_STATUS_CODE_VALUE Value,
- IN UINT32 Instance,
- IN CONST EFI_GUID *CallerId OPTIONAL,
- IN EFI_STATUS_CODE_DATA *Data OPTIONAL
+ IN EFI_STATUS_CODE_TYPE Type,
+ IN EFI_STATUS_CODE_VALUE Value,
+ IN UINT32 Instance,
+ IN CONST EFI_GUID *CallerId OPTIONAL,
+ IN EFI_STATUS_CODE_DATA *Data OPTIONAL
)
{
- if ((ReportProgressCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) ||
- (ReportErrorCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) ||
- (ReportDebugCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE)) {
+ if ((ReportProgressCodeEnabled () && (((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE)) ||
+ (ReportErrorCodeEnabled () && (((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE)) ||
+ (ReportDebugCodeEnabled () && (((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE)))
+ {
//
// If mReportStatusCode is NULL, then check if status code service is available in system.
//
@@ -92,13 +93,12 @@ InternalReportStatusCode ( //
// A status code service is present in system, so pass in all the parameters to the service.
//
- return (*mReportStatusCode) (mStatusCodeProtocol, Type, Value, Instance, (EFI_GUID *)CallerId, Data);
+ return (*mReportStatusCode)(mStatusCodeProtocol, Type, Value, Instance, (EFI_GUID *)CallerId, Data);
}
return EFI_UNSUPPORTED;
}
-
/**
Converts a status code to an 8-bit POST code value.
@@ -137,15 +137,16 @@ CodeTypeToPostCode ( // Convert Value to an 8 bit post code
//
if (((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) ||
- ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) ) {
- *PostCode = (UINT8) ((((Value & EFI_STATUS_CODE_CLASS_MASK) >> 24) << 5) |
- (((Value & EFI_STATUS_CODE_SUBCLASS_MASK) >> 16) & 0x1f));
+ ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE))
+ {
+ *PostCode = (UINT8)((((Value & EFI_STATUS_CODE_CLASS_MASK) >> 24) << 5) |
+ (((Value & EFI_STATUS_CODE_SUBCLASS_MASK) >> 16) & 0x1f));
return TRUE;
}
+
return FALSE;
}
-
/**
Extracts ASSERT() information from a status code structure.
@@ -199,17 +200,18 @@ ReportStatusCodeExtractAssertInfo ( if (((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) &&
((CodeType & EFI_STATUS_CODE_SEVERITY_MASK) == EFI_ERROR_UNRECOVERED) &&
- ((Value & EFI_STATUS_CODE_OPERATION_MASK) == EFI_SW_EC_ILLEGAL_SOFTWARE_STATE)) {
+ ((Value & EFI_STATUS_CODE_OPERATION_MASK) == EFI_SW_EC_ILLEGAL_SOFTWARE_STATE))
+ {
AssertData = (EFI_DEBUG_ASSERT_DATA *)(Data + 1);
*Filename = (CHAR8 *)(AssertData + 1);
*Description = *Filename + AsciiStrLen (*Filename) + 1;
*LineNumber = AssertData->LineNumber;
return TRUE;
}
+
return FALSE;
}
-
/**
Extracts DEBUG() information from a status code structure.
@@ -278,13 +280,12 @@ ReportStatusCodeExtractDebugInfo ( // 64-bit aligned is a must, otherwise retrieving 64-bit parameter from BASE_LIST will
// cause unalignment exception.
//
- *Marker = (BASE_LIST) (DebugInfo + 1);
+ *Marker = (BASE_LIST)(DebugInfo + 1);
*Format = (CHAR8 *)(((UINT64 *)*Marker) + 12);
return TRUE;
}
-
/**
Reports a status code.
@@ -316,7 +317,6 @@ ReportStatusCode ( return InternalReportStatusCode (Type, Value, 0, &gEfiCallerIdGuid, NULL);
}
-
/**
Reports a status code with an extended data buffer.
@@ -372,7 +372,6 @@ ReportStatusCodeWithExtendedData ( );
}
-
/**
Reports a status code with full parameters.
@@ -444,11 +443,12 @@ ReportStatusCodeEx ( //
// Fill in the extended data header
//
- StatusCodeData->HeaderSize = (UINT16) sizeof (EFI_STATUS_CODE_DATA);
- StatusCodeData->Size = (UINT16) ExtendedDataSize;
+ StatusCodeData->HeaderSize = (UINT16)sizeof (EFI_STATUS_CODE_DATA);
+ StatusCodeData->Size = (UINT16)ExtendedDataSize;
if (ExtendedDataGuid == NULL) {
ExtendedDataGuid = &gEfiStatusCodeSpecificDataGuid;
}
+
CopyGuid (&StatusCodeData->Type, ExtendedDataGuid);
//
@@ -464,6 +464,7 @@ ReportStatusCodeEx ( if (CallerId == NULL) {
CallerId = &gEfiCallerIdGuid;
}
+
Status = InternalReportStatusCode (Type, Value, Instance, CallerId, StatusCodeData);
//
@@ -474,7 +475,6 @@ ReportStatusCodeEx ( return Status;
}
-
/**
Returns TRUE if status codes of type EFI_PROGRESS_CODE are enabled
@@ -493,10 +493,9 @@ ReportProgressCodeEnabled ( VOID
)
{
- return (BOOLEAN) ((PcdGet8 (PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED) != 0);
+ return (BOOLEAN)((PcdGet8 (PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED) != 0);
}
-
/**
Returns TRUE if status codes of type EFI_ERROR_CODE are enabled
@@ -515,10 +514,9 @@ ReportErrorCodeEnabled ( VOID
)
{
- return (BOOLEAN) ((PcdGet8 (PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED) != 0);
+ return (BOOLEAN)((PcdGet8 (PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED) != 0);
}
-
/**
Returns TRUE if status codes of type EFI_DEBUG_CODE are enabled
@@ -537,5 +535,5 @@ ReportDebugCodeEnabled ( VOID
)
{
- return (BOOLEAN) ((PcdGet8 (PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED) != 0);
+ return (BOOLEAN)((PcdGet8 (PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED) != 0);
}
diff --git a/MdeModulePkg/Library/SmmSmiHandlerProfileLib/MmSmiHandlerProfileLib.c b/MdeModulePkg/Library/SmmSmiHandlerProfileLib/MmSmiHandlerProfileLib.c index 25a0ccb49d..c5d840326e 100644 --- a/MdeModulePkg/Library/SmmSmiHandlerProfileLib/MmSmiHandlerProfileLib.c +++ b/MdeModulePkg/Library/SmmSmiHandlerProfileLib/MmSmiHandlerProfileLib.c @@ -37,16 +37,17 @@ SMI_HANDLER_PROFILE_PROTOCOL *mSmiHandlerProfile; EFI_STATUS
EFIAPI
SmiHandlerProfileRegisterHandler (
- IN EFI_GUID *HandlerGuid,
- IN EFI_SMM_HANDLER_ENTRY_POINT2 Handler,
- IN PHYSICAL_ADDRESS CallerAddress,
- IN VOID *Context OPTIONAL,
- IN UINTN ContextSize OPTIONAL
+ IN EFI_GUID *HandlerGuid,
+ IN EFI_SMM_HANDLER_ENTRY_POINT2 Handler,
+ IN PHYSICAL_ADDRESS CallerAddress,
+ IN VOID *Context OPTIONAL,
+ IN UINTN ContextSize OPTIONAL
)
{
if (mSmiHandlerProfile != NULL) {
return mSmiHandlerProfile->RegisterHandler (mSmiHandlerProfile, HandlerGuid, Handler, CallerAddress, Context, ContextSize);
}
+
return EFI_UNSUPPORTED;
}
@@ -70,15 +71,16 @@ SmiHandlerProfileRegisterHandler ( EFI_STATUS
EFIAPI
SmiHandlerProfileUnregisterHandler (
- IN EFI_GUID *HandlerGuid,
- IN EFI_SMM_HANDLER_ENTRY_POINT2 Handler,
- IN VOID *Context OPTIONAL,
- IN UINTN ContextSize OPTIONAL
+ IN EFI_GUID *HandlerGuid,
+ IN EFI_SMM_HANDLER_ENTRY_POINT2 Handler,
+ IN VOID *Context OPTIONAL,
+ IN UINTN ContextSize OPTIONAL
)
{
if (mSmiHandlerProfile != NULL) {
return mSmiHandlerProfile->UnregisterHandler (mSmiHandlerProfile, HandlerGuid, Handler, Context, ContextSize);
}
+
return EFI_UNSUPPORTED;
}
@@ -95,7 +97,7 @@ MmSmiHandlerProfileLibInitialization ( gMmst->MmLocateProtocol (
&gSmiHandlerProfileGuid,
NULL,
- (VOID **) &mSmiHandlerProfile
+ (VOID **)&mSmiHandlerProfile
);
return EFI_SUCCESS;
}
diff --git a/MdeModulePkg/Library/SmmSmiHandlerProfileLib/SmmSmiHandlerProfileLib.c b/MdeModulePkg/Library/SmmSmiHandlerProfileLib/SmmSmiHandlerProfileLib.c index 0167d81b88..da8cee7f15 100644 --- a/MdeModulePkg/Library/SmmSmiHandlerProfileLib/SmmSmiHandlerProfileLib.c +++ b/MdeModulePkg/Library/SmmSmiHandlerProfileLib/SmmSmiHandlerProfileLib.c @@ -22,8 +22,8 @@ EFI_STATUS
EFIAPI
SmmSmiHandlerProfileLibConstructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
return MmSmiHandlerProfileLibInitialization ();
diff --git a/MdeModulePkg/Library/SmmSmiHandlerProfileLib/StandaloneMmSmiHandlerProfileLib.c b/MdeModulePkg/Library/SmmSmiHandlerProfileLib/StandaloneMmSmiHandlerProfileLib.c index a7714390e5..c426b11159 100644 --- a/MdeModulePkg/Library/SmmSmiHandlerProfileLib/StandaloneMmSmiHandlerProfileLib.c +++ b/MdeModulePkg/Library/SmmSmiHandlerProfileLib/StandaloneMmSmiHandlerProfileLib.c @@ -28,4 +28,3 @@ StandaloneMmSmiHandlerProfileLibConstructor ( {
return MmSmiHandlerProfileLibInitialization ();
}
-
diff --git a/MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.c b/MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.c index b9c5b68de8..880b428d56 100644 --- a/MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.c +++ b/MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.c @@ -24,12 +24,12 @@ SPDX-License-Identifier: BSD-2-Clause-Patent EFI_STATUS
EFIAPI
TpmMeasureAndLogData (
- IN UINT32 PcrIndex,
- IN UINT32 EventType,
- IN VOID *EventLog,
- IN UINT32 LogLen,
- IN VOID *HashData,
- IN UINT64 HashDataLen
+ IN UINT32 PcrIndex,
+ IN UINT32 EventType,
+ IN VOID *EventLog,
+ IN UINT32 LogLen,
+ IN VOID *HashData,
+ IN UINT64 HashDataLen
)
{
//
diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c index a7261d64f0..962892d38f 100644 --- a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c +++ b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c @@ -10,7 +10,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include "InternalBm.h"
-EFI_RAM_DISK_PROTOCOL *mRamDisk = NULL;
+EFI_RAM_DISK_PROTOCOL *mRamDisk = NULL;
EFI_BOOT_MANAGER_REFRESH_LEGACY_BOOT_OPTION mBmRefreshLegacyBootOption = NULL;
EFI_BOOT_MANAGER_LEGACY_BOOT mBmLegacyBoot = NULL;
@@ -19,8 +19,12 @@ EFI_BOOT_MANAGER_LEGACY_BOOT mBmLegacyBoot = NULL; /// This GUID is used for an EFI Variable that stores the front device pathes
/// for a partial device path that starts with the HD node.
///
-EFI_GUID mBmHardDriveBootVariableGuid = { 0xfab7e9e1, 0x39dd, 0x4f2b, { 0x84, 0x08, 0xe2, 0x0e, 0x90, 0x6c, 0xb6, 0xde } };
-EFI_GUID mBmAutoCreateBootOptionGuid = { 0x8108ac4e, 0x9f11, 0x4d59, { 0x85, 0x0e, 0xe2, 0x1a, 0x52, 0x2c, 0x59, 0xb2 } };
+EFI_GUID mBmHardDriveBootVariableGuid = {
+ 0xfab7e9e1, 0x39dd, 0x4f2b, { 0x84, 0x08, 0xe2, 0x0e, 0x90, 0x6c, 0xb6, 0xde }
+};
+EFI_GUID mBmAutoCreateBootOptionGuid = {
+ 0x8108ac4e, 0x9f11, 0x4d59, { 0x85, 0x0e, 0xe2, 0x1a, 0x52, 0x2c, 0x59, 0xb2 }
+};
/**
@@ -40,9 +44,9 @@ BmEndOfBdsPerfCode ( //
// Record the performance data for End of BDS
//
- PERF_CROSSMODULE_END("BDS");
+ PERF_CROSSMODULE_END ("BDS");
- return ;
+ return;
}
/**
@@ -54,8 +58,8 @@ BmEndOfBdsPerfCode ( VOID
EFIAPI
EfiBootManagerRegisterLegacyBootSupport (
- EFI_BOOT_MANAGER_REFRESH_LEGACY_BOOT_OPTION RefreshLegacyBootOption,
- EFI_BOOT_MANAGER_LEGACY_BOOT LegacyBoot
+ EFI_BOOT_MANAGER_REFRESH_LEGACY_BOOT_OPTION RefreshLegacyBootOption,
+ EFI_BOOT_MANAGER_LEGACY_BOOT LegacyBoot
)
{
mBmRefreshLegacyBootOption = RefreshLegacyBootOption;
@@ -72,12 +76,13 @@ EfiBootManagerRegisterLegacyBootSupport ( **/
BOOLEAN
BmIsAutoCreateBootOption (
- EFI_BOOT_MANAGER_LOAD_OPTION *BootOption
+ EFI_BOOT_MANAGER_LOAD_OPTION *BootOption
)
{
if ((BootOption->OptionalDataSize == sizeof (EFI_GUID)) &&
- CompareGuid ((EFI_GUID *) BootOption->OptionalData, &mBmAutoCreateBootOptionGuid)
- ) {
+ CompareGuid ((EFI_GUID *)BootOption->OptionalData, &mBmAutoCreateBootOptionGuid)
+ )
+ {
return TRUE;
} else {
return FALSE;
@@ -94,16 +99,16 @@ BmIsAutoCreateBootOption ( **/
UINTN
BmFindBootOptionInVariable (
- IN EFI_BOOT_MANAGER_LOAD_OPTION *OptionToFind
+ IN EFI_BOOT_MANAGER_LOAD_OPTION *OptionToFind
)
{
- EFI_STATUS Status;
- EFI_BOOT_MANAGER_LOAD_OPTION BootOption;
- UINTN OptionNumber;
- CHAR16 OptionName[BM_OPTION_NAME_LEN];
- EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;
- UINTN BootOptionCount;
- UINTN Index;
+ EFI_STATUS Status;
+ EFI_BOOT_MANAGER_LOAD_OPTION BootOption;
+ UINTN OptionNumber;
+ CHAR16 OptionName[BM_OPTION_NAME_LEN];
+ EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;
+ UINTN BootOptionCount;
+ UINTN Index;
OptionNumber = LoadOptionNumberUnassigned;
@@ -112,8 +117,11 @@ BmFindBootOptionInVariable ( //
if (OptionToFind->OptionNumber != LoadOptionNumberUnassigned) {
UnicodeSPrint (
- OptionName, sizeof (OptionName), L"%s%04x",
- mBmLoadOptionName[OptionToFind->OptionType], OptionToFind->OptionNumber
+ OptionName,
+ sizeof (OptionName),
+ L"%s%04x",
+ mBmLoadOptionName[OptionToFind->OptionType],
+ OptionToFind->OptionNumber
);
Status = EfiBootManagerVariableToLoadOption (OptionName, &BootOption);
@@ -124,9 +132,11 @@ BmFindBootOptionInVariable ( (CompareMem (OptionToFind->FilePath, BootOption.FilePath, GetDevicePathSize (OptionToFind->FilePath)) == 0) &&
(OptionToFind->OptionalDataSize == BootOption.OptionalDataSize) &&
(CompareMem (OptionToFind->OptionalData, BootOption.OptionalData, OptionToFind->OptionalDataSize) == 0)
- ) {
+ )
+ {
OptionNumber = OptionToFind->OptionNumber;
}
+
EfiBootManagerFreeLoadOption (&BootOption);
}
}
@@ -158,24 +168,24 @@ BmFindBootOptionInVariable ( **/
EFI_DEVICE_PATH_PROTOCOL *
BmAdjustFvFilePath (
- IN EFI_DEVICE_PATH_PROTOCOL *FilePath
+ IN EFI_DEVICE_PATH_PROTOCOL *FilePath
)
{
- EFI_STATUS Status;
- UINTN Index;
- EFI_DEVICE_PATH_PROTOCOL *FvFileNode;
- EFI_HANDLE FvHandle;
- EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
- UINTN FvHandleCount;
- EFI_HANDLE *FvHandles;
- EFI_DEVICE_PATH_PROTOCOL *NewDevicePath;
- EFI_DEVICE_PATH_PROTOCOL *FullPath;
+ EFI_STATUS Status;
+ UINTN Index;
+ EFI_DEVICE_PATH_PROTOCOL *FvFileNode;
+ EFI_HANDLE FvHandle;
+ EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
+ UINTN FvHandleCount;
+ EFI_HANDLE *FvHandles;
+ EFI_DEVICE_PATH_PROTOCOL *NewDevicePath;
+ EFI_DEVICE_PATH_PROTOCOL *FullPath;
//
// Get the file buffer by using the exactly FilePath.
//
FvFileNode = FilePath;
- Status = gBS->LocateDevicePath (&gEfiFirmwareVolume2ProtocolGuid, &FvFileNode, &FvHandle);
+ Status = gBS->LocateDevicePath (&gEfiFirmwareVolume2ProtocolGuid, &FvFileNode, &FvHandle);
if (!EFI_ERROR (Status)) {
return DuplicateDevicePath (FilePath);
}
@@ -195,10 +205,10 @@ BmAdjustFvFilePath ( gBS->HandleProtocol (
gImageHandle,
&gEfiLoadedImageProtocolGuid,
- (VOID **) &LoadedImage
+ (VOID **)&LoadedImage
);
NewDevicePath = AppendDevicePathNode (DevicePathFromHandle (LoadedImage->DeviceHandle), FvFileNode);
- FullPath = BmAdjustFvFilePath (NewDevicePath);
+ FullPath = BmAdjustFvFilePath (NewDevicePath);
FreePool (NewDevicePath);
if (FullPath != NULL) {
return FullPath;
@@ -221,8 +231,9 @@ BmAdjustFvFilePath ( //
continue;
}
+
NewDevicePath = AppendDevicePathNode (DevicePathFromHandle (FvHandles[Index]), FvFileNode);
- FullPath = BmAdjustFvFilePath (NewDevicePath);
+ FullPath = BmAdjustFvFilePath (NewDevicePath);
FreePool (NewDevicePath);
if (FullPath != NULL) {
break;
@@ -232,6 +243,7 @@ BmAdjustFvFilePath ( if (FvHandles != NULL) {
FreePool (FvHandles);
}
+
return FullPath;
}
@@ -247,14 +259,14 @@ BmAdjustFvFilePath ( **/
BOOLEAN
BmIsFvFilePath (
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
)
{
- EFI_STATUS Status;
- EFI_HANDLE Handle;
- EFI_DEVICE_PATH_PROTOCOL *Node;
+ EFI_STATUS Status;
+ EFI_HANDLE Handle;
+ EFI_DEVICE_PATH_PROTOCOL *Node;
- Node = DevicePath;
+ Node = DevicePath;
Status = gBS->LocateDevicePath (&gEfiFirmwareVolume2ProtocolGuid, &Node, &Handle);
if (!EFI_ERROR (Status)) {
return TRUE;
@@ -266,6 +278,7 @@ BmIsFvFilePath ( return IsDevicePathEnd (NextDevicePathNode (DevicePath));
}
}
+
return FALSE;
}
@@ -282,8 +295,8 @@ BmIsFvFilePath ( **/
BOOLEAN
BmMatchUsbClass (
- IN EFI_USB_IO_PROTOCOL *UsbIo,
- IN USB_CLASS_DEVICE_PATH *UsbClass
+ IN EFI_USB_IO_PROTOCOL *UsbIo,
+ IN USB_CLASS_DEVICE_PATH *UsbClass
)
{
EFI_STATUS Status;
@@ -294,7 +307,8 @@ BmMatchUsbClass ( UINT8 DeviceProtocol;
if ((DevicePathType (UsbClass) != MESSAGING_DEVICE_PATH) ||
- (DevicePathSubType (UsbClass) != MSG_USB_CLASS_DP)){
+ (DevicePathSubType (UsbClass) != MSG_USB_CLASS_DP))
+ {
return FALSE;
}
@@ -307,12 +321,14 @@ BmMatchUsbClass ( }
if ((UsbClass->VendorId != 0xffff) &&
- (UsbClass->VendorId != DevDesc.IdVendor)) {
+ (UsbClass->VendorId != DevDesc.IdVendor))
+ {
return FALSE;
}
if ((UsbClass->ProductId != 0xffff) &&
- (UsbClass->ProductId != DevDesc.IdProduct)) {
+ (UsbClass->ProductId != DevDesc.IdProduct))
+ {
return FALSE;
}
@@ -338,17 +354,20 @@ BmMatchUsbClass ( // Check Class, SubClass and Protocol.
//
if ((UsbClass->DeviceClass != 0xff) &&
- (UsbClass->DeviceClass != DeviceClass)) {
+ (UsbClass->DeviceClass != DeviceClass))
+ {
return FALSE;
}
if ((UsbClass->DeviceSubClass != 0xff) &&
- (UsbClass->DeviceSubClass != DeviceSubClass)) {
+ (UsbClass->DeviceSubClass != DeviceSubClass))
+ {
return FALSE;
}
if ((UsbClass->DeviceProtocol != 0xff) &&
- (UsbClass->DeviceProtocol != DeviceProtocol)) {
+ (UsbClass->DeviceProtocol != DeviceProtocol))
+ {
return FALSE;
}
@@ -368,23 +387,24 @@ BmMatchUsbClass ( **/
BOOLEAN
BmMatchUsbWwid (
- IN EFI_USB_IO_PROTOCOL *UsbIo,
- IN USB_WWID_DEVICE_PATH *UsbWwid
+ IN EFI_USB_IO_PROTOCOL *UsbIo,
+ IN USB_WWID_DEVICE_PATH *UsbWwid
)
{
- EFI_STATUS Status;
- EFI_USB_DEVICE_DESCRIPTOR DevDesc;
- EFI_USB_INTERFACE_DESCRIPTOR IfDesc;
- UINT16 *LangIdTable;
- UINT16 TableSize;
- UINT16 Index;
- CHAR16 *CompareStr;
- UINTN CompareLen;
- CHAR16 *SerialNumberStr;
- UINTN Length;
+ EFI_STATUS Status;
+ EFI_USB_DEVICE_DESCRIPTOR DevDesc;
+ EFI_USB_INTERFACE_DESCRIPTOR IfDesc;
+ UINT16 *LangIdTable;
+ UINT16 TableSize;
+ UINT16 Index;
+ CHAR16 *CompareStr;
+ UINTN CompareLen;
+ CHAR16 *SerialNumberStr;
+ UINTN Length;
if ((DevicePathType (UsbWwid) != MESSAGING_DEVICE_PATH) ||
- (DevicePathSubType (UsbWwid) != MSG_USB_WWID_DP)) {
+ (DevicePathSubType (UsbWwid) != MSG_USB_WWID_DP))
+ {
return FALSE;
}
@@ -395,8 +415,10 @@ BmMatchUsbWwid ( if (EFI_ERROR (Status)) {
return FALSE;
}
+
if ((DevDesc.IdVendor != UsbWwid->VendorId) ||
- (DevDesc.IdProduct != UsbWwid->ProductId)) {
+ (DevDesc.IdProduct != UsbWwid->ProductId))
+ {
return FALSE;
}
@@ -407,6 +429,7 @@ BmMatchUsbWwid ( if (EFI_ERROR (Status)) {
return FALSE;
}
+
if (IfDesc.InterfaceNumber != UsbWwid->InterfaceNumber) {
return FALSE;
}
@@ -421,9 +444,9 @@ BmMatchUsbWwid ( //
// Get all supported languages.
//
- TableSize = 0;
+ TableSize = 0;
LangIdTable = NULL;
- Status = UsbIo->UsbGetSupportedLanguages (UsbIo, &LangIdTable, &TableSize);
+ Status = UsbIo->UsbGetSupportedLanguages (UsbIo, &LangIdTable, &TableSize);
if (EFI_ERROR (Status) || (TableSize == 0) || (LangIdTable == NULL)) {
return FALSE;
}
@@ -431,7 +454,7 @@ BmMatchUsbWwid ( //
// Serial number in USB WWID device path is the last 64-or-less UTF-16 characters.
//
- CompareStr = (CHAR16 *) (UINTN) (UsbWwid + 1);
+ CompareStr = (CHAR16 *)(UINTN)(UsbWwid + 1);
CompareLen = (DevicePathNodeLength (UsbWwid) - sizeof (USB_WWID_DEVICE_PATH)) / sizeof (CHAR16);
if (CompareStr[CompareLen - 1] == L'\0') {
CompareLen--;
@@ -442,19 +465,20 @@ BmMatchUsbWwid ( //
for (Index = 0; Index < TableSize / sizeof (UINT16); Index++) {
SerialNumberStr = NULL;
- Status = UsbIo->UsbGetStringDescriptor (
- UsbIo,
- LangIdTable[Index],
- DevDesc.StrSerialNumber,
- &SerialNumberStr
- );
+ Status = UsbIo->UsbGetStringDescriptor (
+ UsbIo,
+ LangIdTable[Index],
+ DevDesc.StrSerialNumber,
+ &SerialNumberStr
+ );
if (EFI_ERROR (Status) || (SerialNumberStr == NULL)) {
continue;
}
Length = StrLen (SerialNumberStr);
if ((Length >= CompareLen) &&
- (CompareMem (SerialNumberStr + Length - CompareLen, CompareStr, CompareLen * sizeof (CHAR16)) == 0)) {
+ (CompareMem (SerialNumberStr + Length - CompareLen, CompareStr, CompareLen * sizeof (CHAR16)) == 0))
+ {
FreePool (SerialNumberStr);
return TRUE;
}
@@ -515,28 +539,28 @@ BmFindUsbDevice ( //
// Get the Usb IO interface.
//
- Status = gBS->HandleProtocol(
+ Status = gBS->HandleProtocol (
UsbIoHandles[Index],
&gEfiUsbIoProtocolGuid,
- (VOID **) &UsbIo
+ (VOID **)&UsbIo
);
UsbIoDevicePath = DevicePathFromHandle (UsbIoHandles[Index]);
Matched = FALSE;
if (!EFI_ERROR (Status) && (UsbIoDevicePath != NULL)) {
-
//
// Compare starting part of UsbIoHandle's device path with ParentDevicePath.
//
if (CompareMem (UsbIoDevicePath, DevicePath, ParentDevicePathSize) == 0) {
- if (BmMatchUsbClass (UsbIo, (USB_CLASS_DEVICE_PATH *) ((UINTN) DevicePath + ParentDevicePathSize)) ||
- BmMatchUsbWwid (UsbIo, (USB_WWID_DEVICE_PATH *) ((UINTN) DevicePath + ParentDevicePathSize))) {
+ if (BmMatchUsbClass (UsbIo, (USB_CLASS_DEVICE_PATH *)((UINTN)DevicePath + ParentDevicePathSize)) ||
+ BmMatchUsbWwid (UsbIo, (USB_WWID_DEVICE_PATH *)((UINTN)DevicePath + ParentDevicePathSize)))
+ {
Matched = TRUE;
}
}
}
if (!Matched) {
- (*UsbIoHandleCount) --;
+ (*UsbIoHandleCount)--;
CopyMem (&UsbIoHandles[Index], &UsbIoHandles[Index + 1], (*UsbIoHandleCount - Index) * sizeof (EFI_HANDLE));
} else {
Index++;
@@ -579,19 +603,19 @@ BmExpandUsbDevicePath ( IN EFI_DEVICE_PATH_PROTOCOL *ShortformNode
)
{
- UINTN ParentDevicePathSize;
- EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath;
- EFI_DEVICE_PATH_PROTOCOL *NextFullPath;
- EFI_HANDLE *Handles;
- UINTN HandleCount;
- UINTN Index;
- BOOLEAN GetNext;
+ UINTN ParentDevicePathSize;
+ EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath;
+ EFI_DEVICE_PATH_PROTOCOL *NextFullPath;
+ EFI_HANDLE *Handles;
+ UINTN HandleCount;
+ UINTN Index;
+ BOOLEAN GetNext;
- NextFullPath = NULL;
- GetNext = (BOOLEAN)(FullPath == NULL);
- ParentDevicePathSize = (UINTN) ShortformNode - (UINTN) FilePath;
- RemainingDevicePath = NextDevicePathNode (ShortformNode);
- Handles = BmFindUsbDevice (FilePath, ParentDevicePathSize, &HandleCount);
+ NextFullPath = NULL;
+ GetNext = (BOOLEAN)(FullPath == NULL);
+ ParentDevicePathSize = (UINTN)ShortformNode - (UINTN)FilePath;
+ RemainingDevicePath = NextDevicePathNode (ShortformNode);
+ Handles = BmFindUsbDevice (FilePath, ParentDevicePathSize, &HandleCount);
for (Index = 0; Index < HandleCount; Index++) {
FilePath = AppendDevicePath (DevicePathFromHandle (Handles[Index]), RemainingDevicePath);
@@ -601,6 +625,7 @@ BmExpandUsbDevicePath ( //
continue;
}
+
NextFullPath = BmGetNextLoadOptionDevicePath (FilePath, NULL);
FreePool (FilePath);
if (NextFullPath == NULL) {
@@ -609,6 +634,7 @@ BmExpandUsbDevicePath ( //
continue;
}
+
if (GetNext) {
break;
} else {
@@ -638,27 +664,27 @@ BmExpandUsbDevicePath ( **/
EFI_DEVICE_PATH_PROTOCOL *
BmExpandFileDevicePath (
- IN EFI_DEVICE_PATH_PROTOCOL *FilePath,
- IN EFI_DEVICE_PATH_PROTOCOL *FullPath
+ IN EFI_DEVICE_PATH_PROTOCOL *FilePath,
+ IN EFI_DEVICE_PATH_PROTOCOL *FullPath
)
{
- EFI_STATUS Status;
- UINTN Index;
- UINTN HandleCount;
- EFI_HANDLE *Handles;
- EFI_BLOCK_IO_PROTOCOL *BlockIo;
- UINTN MediaType;
- EFI_DEVICE_PATH_PROTOCOL *NextFullPath;
- BOOLEAN GetNext;
+ EFI_STATUS Status;
+ UINTN Index;
+ UINTN HandleCount;
+ EFI_HANDLE *Handles;
+ EFI_BLOCK_IO_PROTOCOL *BlockIo;
+ UINTN MediaType;
+ EFI_DEVICE_PATH_PROTOCOL *NextFullPath;
+ BOOLEAN GetNext;
EfiBootManagerConnectAll ();
Status = gBS->LocateHandleBuffer (ByProtocol, &gEfiSimpleFileSystemProtocolGuid, NULL, &HandleCount, &Handles);
if (EFI_ERROR (Status)) {
HandleCount = 0;
- Handles = NULL;
+ Handles = NULL;
}
- GetNext = (BOOLEAN)(FullPath == NULL);
+ GetNext = (BOOLEAN)(FullPath == NULL);
NextFullPath = NULL;
//
// Enumerate all removable media devices followed by all fixed media devices,
@@ -666,14 +692,16 @@ BmExpandFileDevicePath ( //
for (MediaType = 0; MediaType < 3; MediaType++) {
for (Index = 0; Index < HandleCount; Index++) {
- Status = gBS->HandleProtocol (Handles[Index], &gEfiBlockIoProtocolGuid, (VOID *) &BlockIo);
+ Status = gBS->HandleProtocol (Handles[Index], &gEfiBlockIoProtocolGuid, (VOID *)&BlockIo);
if (EFI_ERROR (Status)) {
BlockIo = NULL;
}
- if ((MediaType == 0 && BlockIo != NULL && BlockIo->Media->RemovableMedia) ||
- (MediaType == 1 && BlockIo != NULL && !BlockIo->Media->RemovableMedia) ||
- (MediaType == 2 && BlockIo == NULL)
- ) {
+
+ if (((MediaType == 0) && (BlockIo != NULL) && BlockIo->Media->RemovableMedia) ||
+ ((MediaType == 1) && (BlockIo != NULL) && !BlockIo->Media->RemovableMedia) ||
+ ((MediaType == 2) && (BlockIo == NULL))
+ )
+ {
NextFullPath = AppendDevicePath (DevicePathFromHandle (Handles[Index]), FilePath);
if (GetNext) {
break;
@@ -684,6 +712,7 @@ BmExpandFileDevicePath ( }
}
}
+
if (NextFullPath != NULL) {
break;
}
@@ -709,27 +738,27 @@ BmExpandFileDevicePath ( **/
EFI_DEVICE_PATH_PROTOCOL *
BmExpandUriDevicePath (
- IN EFI_DEVICE_PATH_PROTOCOL *FilePath,
- IN EFI_DEVICE_PATH_PROTOCOL *FullPath
+ IN EFI_DEVICE_PATH_PROTOCOL *FilePath,
+ IN EFI_DEVICE_PATH_PROTOCOL *FullPath
)
{
- EFI_STATUS Status;
- UINTN Index;
- UINTN HandleCount;
- EFI_HANDLE *Handles;
- EFI_DEVICE_PATH_PROTOCOL *NextFullPath;
- EFI_DEVICE_PATH_PROTOCOL *RamDiskDevicePath;
- BOOLEAN GetNext;
+ EFI_STATUS Status;
+ UINTN Index;
+ UINTN HandleCount;
+ EFI_HANDLE *Handles;
+ EFI_DEVICE_PATH_PROTOCOL *NextFullPath;
+ EFI_DEVICE_PATH_PROTOCOL *RamDiskDevicePath;
+ BOOLEAN GetNext;
EfiBootManagerConnectAll ();
Status = gBS->LocateHandleBuffer (ByProtocol, &gEfiLoadFileProtocolGuid, NULL, &HandleCount, &Handles);
if (EFI_ERROR (Status)) {
HandleCount = 0;
- Handles = NULL;
+ Handles = NULL;
}
NextFullPath = NULL;
- GetNext = (BOOLEAN)(FullPath == NULL);
+ GetNext = (BOOLEAN)(FullPath == NULL);
for (Index = 0; Index < HandleCount; Index++) {
NextFullPath = BmExpandLoadFile (Handles[Index], FilePath);
@@ -749,6 +778,7 @@ BmExpandUriDevicePath ( BmDestroyRamDisk (RamDiskDevicePath);
FreePool (RamDiskDevicePath);
}
+
FreePool (NextFullPath);
NextFullPath = NULL;
}
@@ -769,15 +799,15 @@ BmExpandUriDevicePath ( **/
VOID
BmCachePartitionDevicePath (
- IN OUT EFI_DEVICE_PATH_PROTOCOL **CachedDevicePath,
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
+ IN OUT EFI_DEVICE_PATH_PROTOCOL **CachedDevicePath,
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
)
{
- EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
- UINTN Count;
+ EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
+ UINTN Count;
if (BmMatchDevicePaths (*CachedDevicePath, DevicePath)) {
- TempDevicePath = *CachedDevicePath;
+ TempDevicePath = *CachedDevicePath;
*CachedDevicePath = BmDelPartMatchInstance (*CachedDevicePath, DevicePath);
FreePool (TempDevicePath);
}
@@ -787,7 +817,7 @@ BmCachePartitionDevicePath ( return;
}
- TempDevicePath = *CachedDevicePath;
+ TempDevicePath = *CachedDevicePath;
*CachedDevicePath = AppendDevicePathInstance (DevicePath, *CachedDevicePath);
if (TempDevicePath != NULL) {
FreePool (TempDevicePath);
@@ -797,7 +827,7 @@ BmCachePartitionDevicePath ( // Here limit the device path instance number to 12, which is max number for a system support 3 IDE controller
// If the user try to boot many OS in different HDs or partitions, in theory, the 'HDDP' variable maybe become larger and larger.
//
- Count = 0;
+ Count = 0;
TempDevicePath = *CachedDevicePath;
while (!IsDevicePathEnd (TempDevicePath)) {
TempDevicePath = NextDevicePathNode (TempDevicePath);
@@ -807,6 +837,7 @@ BmCachePartitionDevicePath ( while (!IsDevicePathEndType (TempDevicePath)) {
TempDevicePath = NextDevicePathNode (TempDevicePath);
}
+
Count++;
//
// If the CachedDevicePath variable contain too much instance, only remain 12 instances.
@@ -855,7 +886,7 @@ BmExpandPartitionDevicePath ( // If exist, search the front path which point to partition node in the variable instants.
// If fail to find or 'HDDP' not exist, reconnect all and search in all system
//
- GetVariable2 (L"HDDP", &mBmHardDriveBootVariableGuid, (VOID **) &CachedDevicePath, &CachedDevicePathSize);
+ GetVariable2 (L"HDDP", &mBmHardDriveBootVariableGuid, (VOID **)&CachedDevicePath, &CachedDevicePathSize);
//
// Delete the invalid 'HDDP' variable.
@@ -863,28 +894,28 @@ BmExpandPartitionDevicePath ( if ((CachedDevicePath != NULL) && !IsDevicePathValid (CachedDevicePath, CachedDevicePathSize)) {
FreePool (CachedDevicePath);
CachedDevicePath = NULL;
- Status = gRT->SetVariable (
- L"HDDP",
- &mBmHardDriveBootVariableGuid,
- 0,
- 0,
- NULL
- );
+ Status = gRT->SetVariable (
+ L"HDDP",
+ &mBmHardDriveBootVariableGuid,
+ 0,
+ 0,
+ NULL
+ );
ASSERT_EFI_ERROR (Status);
}
FullPath = NULL;
if (CachedDevicePath != NULL) {
TempNewDevicePath = CachedDevicePath;
- NeedAdjust = FALSE;
+ NeedAdjust = FALSE;
do {
//
// Check every instance of the variable
// First, check whether the instance contain the partition node, which is needed for distinguishing multi
// partial partition boot option. Second, check whether the instance could be connected.
//
- Instance = GetNextDevicePathInstance (&TempNewDevicePath, &Size);
- if (BmMatchPartitionDevicePathNode (Instance, (HARDDRIVE_DEVICE_PATH *) FilePath)) {
+ Instance = GetNextDevicePathInstance (&TempNewDevicePath, &Size);
+ if (BmMatchPartitionDevicePathNode (Instance, (HARDDRIVE_DEVICE_PATH *)FilePath)) {
//
// Connect the device path instance, the device path point to hard drive media device path node
// e.g. ACPI() /PCI()/ATA()/Partition()
@@ -916,12 +947,12 @@ BmExpandPartitionDevicePath ( // Failing to save only impacts performance next time expanding the short-form device path
//
Status = gRT->SetVariable (
- L"HDDP",
- &mBmHardDriveBootVariableGuid,
- EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE,
- GetDevicePathSize (CachedDevicePath),
- CachedDevicePath
- );
+ L"HDDP",
+ &mBmHardDriveBootVariableGuid,
+ EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE,
+ GetDevicePathSize (CachedDevicePath),
+ CachedDevicePath
+ );
}
FreePool (Instance);
@@ -930,11 +961,12 @@ BmExpandPartitionDevicePath ( }
}
}
+
//
// Come here means the first instance is not matched
//
NeedAdjust = TRUE;
- FreePool(Instance);
+ FreePool (Instance);
} while (TempNewDevicePath != NULL);
}
@@ -948,6 +980,7 @@ BmExpandPartitionDevicePath ( BlockIoHandleCount = 0;
BlockIoBuffer = NULL;
}
+
//
// Loop through all the device handles that support the BLOCK_IO Protocol
//
@@ -957,12 +990,12 @@ BmExpandPartitionDevicePath ( continue;
}
- if (BmMatchPartitionDevicePathNode (BlockIoDevicePath, (HARDDRIVE_DEVICE_PATH *) FilePath)) {
+ if (BmMatchPartitionDevicePathNode (BlockIoDevicePath, (HARDDRIVE_DEVICE_PATH *)FilePath)) {
//
// Find the matched partition device path
//
TempDevicePath = AppendDevicePath (BlockIoDevicePath, NextDevicePathNode (FilePath));
- FullPath = BmGetNextLoadOptionDevicePath (TempDevicePath, NULL);
+ FullPath = BmGetNextLoadOptionDevicePath (TempDevicePath, NULL);
FreePool (TempDevicePath);
if (FullPath != NULL) {
@@ -988,9 +1021,11 @@ BmExpandPartitionDevicePath ( if (CachedDevicePath != NULL) {
FreePool (CachedDevicePath);
}
+
if (BlockIoBuffer != NULL) {
FreePool (BlockIoBuffer);
}
+
return FullPath;
}
@@ -1007,29 +1042,29 @@ BmExpandPartitionDevicePath ( **/
EFI_DEVICE_PATH_PROTOCOL *
BmExpandMediaDevicePath (
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
- IN EFI_DEVICE_PATH_PROTOCOL *FullPath
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
+ IN EFI_DEVICE_PATH_PROTOCOL *FullPath
)
{
- EFI_STATUS Status;
- EFI_HANDLE Handle;
- EFI_BLOCK_IO_PROTOCOL *BlockIo;
- VOID *Buffer;
- EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
- EFI_DEVICE_PATH_PROTOCOL *NextFullPath;
- UINTN Size;
- UINTN TempSize;
- EFI_HANDLE *SimpleFileSystemHandles;
- UINTN NumberSimpleFileSystemHandles;
- UINTN Index;
- BOOLEAN GetNext;
+ EFI_STATUS Status;
+ EFI_HANDLE Handle;
+ EFI_BLOCK_IO_PROTOCOL *BlockIo;
+ VOID *Buffer;
+ EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
+ EFI_DEVICE_PATH_PROTOCOL *NextFullPath;
+ UINTN Size;
+ UINTN TempSize;
+ EFI_HANDLE *SimpleFileSystemHandles;
+ UINTN NumberSimpleFileSystemHandles;
+ UINTN Index;
+ BOOLEAN GetNext;
GetNext = (BOOLEAN)(FullPath == NULL);
//
// Check whether the device is connected
//
TempDevicePath = DevicePath;
- Status = gBS->LocateDevicePath (&gEfiSimpleFileSystemProtocolGuid, &TempDevicePath, &Handle);
+ Status = gBS->LocateDevicePath (&gEfiSimpleFileSystemProtocolGuid, &TempDevicePath, &Handle);
if (!EFI_ERROR (Status)) {
ASSERT (IsDevicePathEnd (TempDevicePath));
@@ -1062,20 +1097,21 @@ BmExpandMediaDevicePath ( // returned. After the Block IO protocol is reinstalled, subsequent
// Block IO read/write will success.
//
- Status = gBS->HandleProtocol (Handle, &gEfiBlockIoProtocolGuid, (VOID **) &BlockIo);
+ Status = gBS->HandleProtocol (Handle, &gEfiBlockIoProtocolGuid, (VOID **)&BlockIo);
ASSERT_EFI_ERROR (Status);
if (EFI_ERROR (Status)) {
return NULL;
}
+
Buffer = AllocatePool (BlockIo->Media->BlockSize);
if (Buffer != NULL) {
BlockIo->ReadBlocks (
- BlockIo,
- BlockIo->Media->MediaId,
- 0,
- BlockIo->Media->BlockSize,
- Buffer
- );
+ BlockIo,
+ BlockIo->Media->MediaId,
+ 0,
+ BlockIo->Media->BlockSize,
+ Buffer
+ );
FreePool (Buffer);
}
@@ -1083,7 +1119,7 @@ BmExpandMediaDevicePath ( // Detect the the default boot file from removable Media
//
NextFullPath = NULL;
- Size = GetDevicePathSize (DevicePath) - END_DEVICE_PATH_LENGTH;
+ Size = GetDevicePathSize (DevicePath) - END_DEVICE_PATH_LENGTH;
gBS->LocateHandleBuffer (
ByProtocol,
&gEfiSimpleFileSystemProtocolGuid,
@@ -1096,7 +1132,7 @@ BmExpandMediaDevicePath ( // Get the device path size of SimpleFileSystem handle
//
TempDevicePath = DevicePathFromHandle (SimpleFileSystemHandles[Index]);
- TempSize = GetDevicePathSize (TempDevicePath) - END_DEVICE_PATH_LENGTH;
+ TempSize = GetDevicePathSize (TempDevicePath) - END_DEVICE_PATH_LENGTH;
//
// Check whether the device path of boot option is part of the SimpleFileSystem handle's device path
//
@@ -1128,13 +1164,14 @@ BmExpandMediaDevicePath ( **/
BOOLEAN
BmMatchHttpBootDevicePath (
- IN EFI_DEVICE_PATH_PROTOCOL *Left,
- IN EFI_DEVICE_PATH_PROTOCOL *Right
+ IN EFI_DEVICE_PATH_PROTOCOL *Left,
+ IN EFI_DEVICE_PATH_PROTOCOL *Right
)
{
- for (; !IsDevicePathEnd (Left) && !IsDevicePathEnd (Right)
- ; Left = NextDevicePathNode (Left), Right = NextDevicePathNode (Right)
- ) {
+ for ( ; !IsDevicePathEnd (Left) && !IsDevicePathEnd (Right)
+ ; Left = NextDevicePathNode (Left), Right = NextDevicePathNode (Right)
+ )
+ {
if (CompareMem (Left, Right, DevicePathNodeLength (Left)) != 0) {
if ((DevicePathType (Left) != MESSAGING_DEVICE_PATH) || (DevicePathType (Right) != MESSAGING_DEVICE_PATH)) {
return FALSE;
@@ -1151,12 +1188,14 @@ BmMatchHttpBootDevicePath ( if (((DevicePathSubType (Left) != MSG_IPv4_DP) || (DevicePathSubType (Right) != MSG_IPv4_DP)) &&
((DevicePathSubType (Left) != MSG_IPv6_DP) || (DevicePathSubType (Right) != MSG_IPv6_DP)) &&
((DevicePathSubType (Left) != MSG_URI_DP) || (DevicePathSubType (Right) != MSG_URI_DP))
- ) {
+ )
+ {
return FALSE;
}
}
}
- return (BOOLEAN) (IsDevicePathEnd (Left) && IsDevicePathEnd (Right));
+
+ return (BOOLEAN)(IsDevicePathEnd (Left) && IsDevicePathEnd (Right));
}
/**
@@ -1170,16 +1209,16 @@ BmMatchHttpBootDevicePath ( **/
EFI_DEVICE_PATH_PROTOCOL *
BmExpandNetworkFileSystem (
- IN EFI_HANDLE LoadFileHandle,
- OUT EFI_HANDLE *RamDiskHandle
+ IN EFI_HANDLE LoadFileHandle,
+ OUT EFI_HANDLE *RamDiskHandle
)
{
- EFI_STATUS Status;
- EFI_HANDLE Handle;
- EFI_HANDLE *Handles;
- UINTN HandleCount;
- UINTN Index;
- EFI_DEVICE_PATH_PROTOCOL *Node;
+ EFI_STATUS Status;
+ EFI_HANDLE Handle;
+ EFI_HANDLE *Handles;
+ UINTN HandleCount;
+ UINTN Index;
+ EFI_DEVICE_PATH_PROTOCOL *Node;
Status = gBS->LocateHandleBuffer (
ByProtocol,
@@ -1189,17 +1228,18 @@ BmExpandNetworkFileSystem ( &Handles
);
if (EFI_ERROR (Status)) {
- Handles = NULL;
+ Handles = NULL;
HandleCount = 0;
}
Handle = NULL;
for (Index = 0; Index < HandleCount; Index++) {
- Node = DevicePathFromHandle (Handles[Index]);
+ Node = DevicePathFromHandle (Handles[Index]);
Status = gBS->LocateDevicePath (&gEfiLoadFileProtocolGuid, &Node, &Handle);
if (!EFI_ERROR (Status) &&
(Handle == LoadFileHandle) &&
- (DevicePathType (Node) == MEDIA_DEVICE_PATH) && (DevicePathSubType (Node) == MEDIA_RAM_DISK_DP)) {
+ (DevicePathType (Node) == MEDIA_DEVICE_PATH) && (DevicePathSubType (Node) == MEDIA_RAM_DISK_DP))
+ {
//
// Find the BlockIo instance populated from the LoadFile.
//
@@ -1238,28 +1278,28 @@ BmExpandNetworkFileSystem ( **/
EFI_DEVICE_PATH_PROTOCOL *
BmGetRamDiskDevicePath (
- IN EFI_DEVICE_PATH_PROTOCOL *FilePath
+ IN EFI_DEVICE_PATH_PROTOCOL *FilePath
)
{
- EFI_STATUS Status;
- EFI_DEVICE_PATH_PROTOCOL *RamDiskDevicePath;
- EFI_DEVICE_PATH_PROTOCOL *Node;
- EFI_HANDLE Handle;
+ EFI_STATUS Status;
+ EFI_DEVICE_PATH_PROTOCOL *RamDiskDevicePath;
+ EFI_DEVICE_PATH_PROTOCOL *Node;
+ EFI_HANDLE Handle;
- Node = FilePath;
+ Node = FilePath;
Status = gBS->LocateDevicePath (&gEfiLoadFileProtocolGuid, &Node, &Handle);
if (!EFI_ERROR (Status) &&
(DevicePathType (Node) == MEDIA_DEVICE_PATH) &&
(DevicePathSubType (Node) == MEDIA_RAM_DISK_DP)
- ) {
-
+ )
+ {
//
// Construct the device path pointing to RAM Disk
//
- Node = NextDevicePathNode (Node);
+ Node = NextDevicePathNode (Node);
RamDiskDevicePath = DuplicateDevicePath (FilePath);
ASSERT (RamDiskDevicePath != NULL);
- SetDevicePathEndNode ((VOID *) ((UINTN) RamDiskDevicePath + ((UINTN) Node - (UINTN) FilePath)));
+ SetDevicePathEndNode ((VOID *)((UINTN)RamDiskDevicePath + ((UINTN)Node - (UINTN)FilePath)));
return RamDiskDevicePath;
}
@@ -1276,15 +1316,14 @@ BmGetRamDiskDevicePath ( **/
VOID *
BmGetRamDiskMemoryInfo (
- IN EFI_DEVICE_PATH_PROTOCOL *RamDiskDevicePath,
- OUT UINTN *RamDiskSizeInPages
+ IN EFI_DEVICE_PATH_PROTOCOL *RamDiskDevicePath,
+ OUT UINTN *RamDiskSizeInPages
)
{
-
- EFI_STATUS Status;
- EFI_HANDLE Handle;
- UINT64 StartingAddr;
- UINT64 EndingAddr;
+ EFI_STATUS Status;
+ EFI_HANDLE Handle;
+ UINT64 StartingAddr;
+ UINT64 EndingAddr;
ASSERT (RamDiskDevicePath != NULL);
@@ -1295,12 +1334,14 @@ BmGetRamDiskMemoryInfo ( //
Status = gBS->LocateDevicePath (&gEfiLoadFileProtocolGuid, &RamDiskDevicePath, &Handle);
ASSERT_EFI_ERROR (Status);
- ASSERT ((DevicePathType (RamDiskDevicePath) == MEDIA_DEVICE_PATH) &&
- (DevicePathSubType (RamDiskDevicePath) == MEDIA_RAM_DISK_DP));
- StartingAddr = ReadUnaligned64 ((UINT64 *) ((MEDIA_RAM_DISK_DEVICE_PATH *) RamDiskDevicePath)->StartingAddr);
- EndingAddr = ReadUnaligned64 ((UINT64 *) ((MEDIA_RAM_DISK_DEVICE_PATH *) RamDiskDevicePath)->EndingAddr);
- *RamDiskSizeInPages = EFI_SIZE_TO_PAGES ((UINTN) (EndingAddr - StartingAddr + 1));
- return (VOID *) (UINTN) StartingAddr;
+ ASSERT (
+ (DevicePathType (RamDiskDevicePath) == MEDIA_DEVICE_PATH) &&
+ (DevicePathSubType (RamDiskDevicePath) == MEDIA_RAM_DISK_DP)
+ );
+ StartingAddr = ReadUnaligned64 ((UINT64 *)((MEDIA_RAM_DISK_DEVICE_PATH *)RamDiskDevicePath)->StartingAddr);
+ EndingAddr = ReadUnaligned64 ((UINT64 *)((MEDIA_RAM_DISK_DEVICE_PATH *)RamDiskDevicePath)->EndingAddr);
+ *RamDiskSizeInPages = EFI_SIZE_TO_PAGES ((UINTN)(EndingAddr - StartingAddr + 1));
+ return (VOID *)(UINTN)StartingAddr;
}
/**
@@ -1314,12 +1355,12 @@ BmGetRamDiskMemoryInfo ( **/
VOID
BmDestroyRamDisk (
- IN EFI_DEVICE_PATH_PROTOCOL *RamDiskDevicePath
+ IN EFI_DEVICE_PATH_PROTOCOL *RamDiskDevicePath
)
{
- EFI_STATUS Status;
- VOID *RamDiskBuffer;
- UINTN RamDiskSizeInPages;
+ EFI_STATUS Status;
+ VOID *RamDiskBuffer;
+ UINTN RamDiskSizeInPages;
ASSERT (RamDiskDevicePath != NULL);
@@ -1329,9 +1370,10 @@ BmDestroyRamDisk ( // Destroy RAM Disk.
//
if (mRamDisk == NULL) {
- Status = gBS->LocateProtocol (&gEfiRamDiskProtocolGuid, NULL, (VOID *) &mRamDisk);
+ Status = gBS->LocateProtocol (&gEfiRamDiskProtocolGuid, NULL, (VOID *)&mRamDisk);
ASSERT_EFI_ERROR (Status);
}
+
Status = mRamDisk->Unregister (RamDiskDevicePath);
ASSERT_EFI_ERROR (Status);
FreePages (RamDiskBuffer, RamDiskSizeInPages);
@@ -1347,21 +1389,21 @@ BmDestroyRamDisk ( **/
EFI_DEVICE_PATH_PROTOCOL *
BmExpandLoadFile (
- IN EFI_HANDLE LoadFileHandle,
- IN EFI_DEVICE_PATH_PROTOCOL *FilePath
+ IN EFI_HANDLE LoadFileHandle,
+ IN EFI_DEVICE_PATH_PROTOCOL *FilePath
)
{
- EFI_STATUS Status;
- EFI_LOAD_FILE_PROTOCOL *LoadFile;
- VOID *FileBuffer;
- EFI_HANDLE RamDiskHandle;
- UINTN BufferSize;
- EFI_DEVICE_PATH_PROTOCOL *FullPath;
+ EFI_STATUS Status;
+ EFI_LOAD_FILE_PROTOCOL *LoadFile;
+ VOID *FileBuffer;
+ EFI_HANDLE RamDiskHandle;
+ UINTN BufferSize;
+ EFI_DEVICE_PATH_PROTOCOL *FullPath;
Status = gBS->OpenProtocol (
LoadFileHandle,
&gEfiLoadFileProtocolGuid,
- (VOID **) &LoadFile,
+ (VOID **)&LoadFile,
gImageHandle,
NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -1370,7 +1412,7 @@ BmExpandLoadFile ( FileBuffer = NULL;
BufferSize = 0;
- Status = LoadFile->LoadFile (LoadFile, FilePath, TRUE, &BufferSize, FileBuffer);
+ Status = LoadFile->LoadFile (LoadFile, FilePath, TRUE, &BufferSize, FileBuffer);
if ((Status != EFI_WARN_FILE_SYSTEM) && (Status != EFI_BUFFER_TOO_SMALL)) {
return NULL;
}
@@ -1388,35 +1430,38 @@ BmExpandLoadFile ( FileBuffer = AllocateReservedPages (EFI_SIZE_TO_PAGES (BufferSize));
if (FileBuffer == NULL) {
DEBUG_CODE_BEGIN ();
- EFI_DEVICE_PATH *LoadFilePath;
- CHAR16 *LoadFileText;
- CHAR16 *FileText;
+ EFI_DEVICE_PATH *LoadFilePath;
+ CHAR16 *LoadFileText;
+ CHAR16 *FileText;
+
+ LoadFilePath = DevicePathFromHandle (LoadFileHandle);
+ if (LoadFilePath == NULL) {
+ LoadFileText = NULL;
+ } else {
+ LoadFileText = ConvertDevicePathToText (LoadFilePath, FALSE, FALSE);
+ }
+
+ FileText = ConvertDevicePathToText (FilePath, FALSE, FALSE);
+
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a:%a: failed to allocate reserved pages: "
+ "BufferSize=%Lu LoadFile=\"%s\" FilePath=\"%s\"\n",
+ gEfiCallerBaseName,
+ __FUNCTION__,
+ (UINT64)BufferSize,
+ LoadFileText,
+ FileText
+ ));
+
+ if (FileText != NULL) {
+ FreePool (FileText);
+ }
+
+ if (LoadFileText != NULL) {
+ FreePool (LoadFileText);
+ }
- LoadFilePath = DevicePathFromHandle (LoadFileHandle);
- if (LoadFilePath == NULL) {
- LoadFileText = NULL;
- } else {
- LoadFileText = ConvertDevicePathToText (LoadFilePath, FALSE, FALSE);
- }
- FileText = ConvertDevicePathToText (FilePath, FALSE, FALSE);
-
- DEBUG ((
- DEBUG_ERROR,
- "%a:%a: failed to allocate reserved pages: "
- "BufferSize=%Lu LoadFile=\"%s\" FilePath=\"%s\"\n",
- gEfiCallerBaseName,
- __FUNCTION__,
- (UINT64)BufferSize,
- LoadFileText,
- FileText
- ));
-
- if (FileText != NULL) {
- FreePool (FileText);
- }
- if (LoadFileText != NULL) {
- FreePool (LoadFileText);
- }
DEBUG_CODE_END ();
return NULL;
}
@@ -1459,20 +1504,20 @@ BmExpandLoadFile ( **/
EFI_DEVICE_PATH_PROTOCOL *
BmExpandLoadFiles (
- IN EFI_DEVICE_PATH_PROTOCOL *FilePath
+ IN EFI_DEVICE_PATH_PROTOCOL *FilePath
)
{
- EFI_STATUS Status;
- EFI_HANDLE Handle;
- EFI_HANDLE *Handles;
- UINTN HandleCount;
- UINTN Index;
- EFI_DEVICE_PATH_PROTOCOL *Node;
+ EFI_STATUS Status;
+ EFI_HANDLE Handle;
+ EFI_HANDLE *Handles;
+ UINTN HandleCount;
+ UINTN Index;
+ EFI_DEVICE_PATH_PROTOCOL *Node;
//
// Get file buffer from load file instance.
//
- Node = FilePath;
+ Node = FilePath;
Status = gBS->LocateDevicePath (&gEfiLoadFileProtocolGuid, &Node, &Handle);
if (!EFI_ERROR (Status) && IsDevicePathEnd (Node)) {
//
@@ -1494,15 +1539,17 @@ BmExpandLoadFiles ( &Handles
);
if (EFI_ERROR (Status)) {
- Handles = NULL;
+ Handles = NULL;
HandleCount = 0;
}
+
for (Index = 0; Index < HandleCount; Index++) {
if (BmMatchHttpBootDevicePath (DevicePathFromHandle (Handles[Index]), FilePath)) {
Handle = Handles[Index];
break;
}
}
+
if (Handles != NULL) {
FreePool (Handles);
}
@@ -1530,9 +1577,9 @@ BmExpandLoadFiles ( VOID *
EFIAPI
EfiBootManagerGetLoadOptionBuffer (
- IN EFI_DEVICE_PATH_PROTOCOL *FilePath,
- OUT EFI_DEVICE_PATH_PROTOCOL **FullPath,
- OUT UINTN *FileSize
+ IN EFI_DEVICE_PATH_PROTOCOL *FilePath,
+ OUT EFI_DEVICE_PATH_PROTOCOL **FullPath,
+ OUT UINTN *FileSize
)
{
*FullPath = NULL;
@@ -1557,20 +1604,20 @@ EfiBootManagerGetLoadOptionBuffer ( **/
EFI_DEVICE_PATH_PROTOCOL *
BmGetNextLoadOptionDevicePath (
- IN EFI_DEVICE_PATH_PROTOCOL *FilePath,
- IN EFI_DEVICE_PATH_PROTOCOL *FullPath
+ IN EFI_DEVICE_PATH_PROTOCOL *FilePath,
+ IN EFI_DEVICE_PATH_PROTOCOL *FullPath
)
{
- EFI_HANDLE Handle;
- EFI_DEVICE_PATH_PROTOCOL *Node;
- EFI_STATUS Status;
+ EFI_HANDLE Handle;
+ EFI_DEVICE_PATH_PROTOCOL *Node;
+ EFI_STATUS Status;
ASSERT (FilePath != NULL);
//
// Boot from media device by adding a default file name \EFI\BOOT\BOOT{machine type short-name}.EFI
//
- Node = FilePath;
+ Node = FilePath;
Status = gBS->LocateDevicePath (&gEfiSimpleFileSystemProtocolGuid, &Node, &Handle);
if (EFI_ERROR (Status)) {
Status = gBS->LocateDevicePath (&gEfiBlockIoProtocolGuid, &Node, &Handle);
@@ -1584,7 +1631,8 @@ BmGetNextLoadOptionDevicePath ( // Expand the short-form device path to full device path
//
if ((DevicePathType (FilePath) == MEDIA_DEVICE_PATH) &&
- (DevicePathSubType (FilePath) == MEDIA_HARDDRIVE_DP)) {
+ (DevicePathSubType (FilePath) == MEDIA_HARDDRIVE_DP))
+ {
//
// Expand the Harddrive device path
//
@@ -1594,19 +1642,21 @@ BmGetNextLoadOptionDevicePath ( return NULL;
}
} else if ((DevicePathType (FilePath) == MEDIA_DEVICE_PATH) &&
- (DevicePathSubType (FilePath) == MEDIA_FILEPATH_DP)) {
+ (DevicePathSubType (FilePath) == MEDIA_FILEPATH_DP))
+ {
//
// Expand the File-path device path
//
return BmExpandFileDevicePath (FilePath, FullPath);
} else if ((DevicePathType (FilePath) == MESSAGING_DEVICE_PATH) &&
- (DevicePathSubType (FilePath) == MSG_URI_DP)) {
+ (DevicePathSubType (FilePath) == MSG_URI_DP))
+ {
//
// Expand the URI device path
//
return BmExpandUriDevicePath (FilePath, FullPath);
} else {
- Node = FilePath;
+ Node = FilePath;
Status = gBS->LocateDevicePath (&gEfiUsbIoProtocolGuid, &Node, &Handle);
if (EFI_ERROR (Status)) {
//
@@ -1616,7 +1666,8 @@ BmGetNextLoadOptionDevicePath ( //
for (Node = FilePath; !IsDevicePathEnd (Node); Node = NextDevicePathNode (Node)) {
if ((DevicePathType (Node) == MESSAGING_DEVICE_PATH) &&
- ((DevicePathSubType (Node) == MSG_USB_CLASS_DP) || (DevicePathSubType (Node) == MSG_USB_WWID_DP))) {
+ ((DevicePathSubType (Node) == MSG_USB_CLASS_DP) || (DevicePathSubType (Node) == MSG_USB_WWID_DP)))
+ {
break;
}
}
@@ -1633,6 +1684,7 @@ BmGetNextLoadOptionDevicePath ( //
BmConnectUsbShortFormDevicePath (FilePath);
}
+
return BmExpandUsbDevicePath (FilePath, FullPath, Node);
}
}
@@ -1678,16 +1730,16 @@ BmGetNextLoadOptionDevicePath ( **/
BOOLEAN
BmIsBootManagerMenuFilePath (
- EFI_DEVICE_PATH_PROTOCOL *DevicePath
-)
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath
+ )
{
- EFI_HANDLE FvHandle;
- VOID *NameGuid;
- EFI_STATUS Status;
+ EFI_HANDLE FvHandle;
+ VOID *NameGuid;
+ EFI_STATUS Status;
Status = gBS->LocateDevicePath (&gEfiFirmwareVolume2ProtocolGuid, &DevicePath, &FvHandle);
if (!EFI_ERROR (Status)) {
- NameGuid = EfiGetNameGuidFromFwVolDevicePathNode ((CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) DevicePath);
+ NameGuid = EfiGetNameGuidFromFwVolDevicePathNode ((CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *)DevicePath);
if (NameGuid != NULL) {
return CompareGuid (NameGuid, PcdGetPtr (PcdBootManagerMenuFile));
}
@@ -1712,11 +1764,11 @@ BmIsBootManagerMenuFilePath ( **/
VOID
BmReportLoadFailure (
- IN UINT32 ErrorCode,
- IN EFI_STATUS FailureStatus
+ IN UINT32 ErrorCode,
+ IN EFI_STATUS FailureStatus
)
{
- EFI_RETURN_STATUS_EXTENDED_DATA ExtendedData;
+ EFI_RETURN_STATUS_EXTENDED_DATA ExtendedData;
if (!ReportErrorCodeEnabled ()) {
return;
@@ -1764,27 +1816,27 @@ BmReportLoadFailure ( VOID
EFIAPI
EfiBootManagerBoot (
- IN EFI_BOOT_MANAGER_LOAD_OPTION *BootOption
+ IN EFI_BOOT_MANAGER_LOAD_OPTION *BootOption
)
{
- EFI_STATUS Status;
- EFI_HANDLE ImageHandle;
- EFI_LOADED_IMAGE_PROTOCOL *ImageInfo;
- UINT16 Uint16;
- UINTN OptionNumber;
- UINTN OriginalOptionNumber;
- EFI_DEVICE_PATH_PROTOCOL *FilePath;
- EFI_DEVICE_PATH_PROTOCOL *RamDiskDevicePath;
- VOID *FileBuffer;
- UINTN FileSize;
- EFI_BOOT_LOGO_PROTOCOL *BootLogo;
- EFI_EVENT LegacyBootEvent;
+ EFI_STATUS Status;
+ EFI_HANDLE ImageHandle;
+ EFI_LOADED_IMAGE_PROTOCOL *ImageInfo;
+ UINT16 Uint16;
+ UINTN OptionNumber;
+ UINTN OriginalOptionNumber;
+ EFI_DEVICE_PATH_PROTOCOL *FilePath;
+ EFI_DEVICE_PATH_PROTOCOL *RamDiskDevicePath;
+ VOID *FileBuffer;
+ UINTN FileSize;
+ EFI_BOOT_LOGO_PROTOCOL *BootLogo;
+ EFI_EVENT LegacyBootEvent;
if (BootOption == NULL) {
return;
}
- if (BootOption->FilePath == NULL || BootOption->OptionType != LoadOptionTypeBoot) {
+ if ((BootOption->FilePath == NULL) || (BootOption->OptionType != LoadOptionTypeBoot)) {
BootOption->Status = EFI_INVALID_PARAMETER;
return;
}
@@ -1802,21 +1854,21 @@ EfiBootManagerBoot ( OptionNumber = Uint16;
OriginalOptionNumber = BootOption->OptionNumber;
BootOption->OptionNumber = OptionNumber;
- Status = EfiBootManagerLoadOptionToVariable (BootOption);
+ Status = EfiBootManagerLoadOptionToVariable (BootOption);
BootOption->OptionNumber = OriginalOptionNumber;
}
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "[Bds] Failed to create Boot#### for a temporary boot - %r!\n", Status));
BootOption->Status = Status;
- return ;
+ return;
}
}
//
// 2. Set BootCurrent
//
- Uint16 = (UINT16) OptionNumber;
+ Uint16 = (UINT16)OptionNumber;
BmSetVariableAndReportStatusCodeOnError (
L"BootCurrent",
&gEfiGlobalVariableGuid,
@@ -1833,7 +1885,7 @@ EfiBootManagerBoot ( DEBUG ((DEBUG_INFO, "[Bds] Booting Boot Manager Menu.\n"));
BmStopHotkeyService (NULL, NULL);
} else {
- EfiSignalEventReadyToBoot();
+ EfiSignalEventReadyToBoot ();
//
// Report Status Code to indicate ReadyToBoot was signalled
//
@@ -1844,15 +1896,15 @@ EfiBootManagerBoot ( BmRepairAllControllers (0);
}
- PERF_START_EX (gImageHandle, "BdsAttempt", NULL, 0, (UINT32) OptionNumber);
+ PERF_START_EX (gImageHandle, "BdsAttempt", NULL, 0, (UINT32)OptionNumber);
//
// 5. Adjust the different type memory page number just before booting
// and save the updated info into the variable for next boot to use
//
BmSetMemoryTypeInformationVariable (
- (BOOLEAN) ((BootOption->Attributes & LOAD_OPTION_CATEGORY) == LOAD_OPTION_CATEGORY_BOOT)
- );
+ (BOOLEAN)((BootOption->Attributes & LOAD_OPTION_CATEGORY) == LOAD_OPTION_CATEGORY_BOOT)
+ );
//
// 6. Load EFI boot option to ImageHandle
@@ -1863,6 +1915,7 @@ EfiBootManagerBoot ( } else {
DEBUG ((DEBUG_INFO | DEBUG_LOAD, "[Bds]Booting %s\n", BootOption->Description));
}
+
DEBUG_CODE_END ();
ImageHandle = NULL;
@@ -1885,9 +1938,11 @@ EfiBootManagerBoot ( &ImageHandle
);
}
+
if (FileBuffer != NULL) {
FreePool (FileBuffer);
}
+
if (FilePath != NULL) {
FreePool (FilePath);
}
@@ -1902,6 +1957,7 @@ EfiBootManagerBoot ( if (Status == EFI_SECURITY_VIOLATION) {
gBS->UnloadImage (ImageHandle);
}
+
//
// Destroy the RAM disk
//
@@ -1909,6 +1965,7 @@ EfiBootManagerBoot ( BmDestroyRamDisk (RamDiskDevicePath);
FreePool (RamDiskDevicePath);
}
+
//
// Report Status Code with the failure status to indicate that the failure to load boot option
//
@@ -1931,28 +1988,28 @@ EfiBootManagerBoot ( //
// Create an event to be signalled when Legacy Boot occurs to write performance data.
//
- Status = EfiCreateEventLegacyBootEx(
+ Status = EfiCreateEventLegacyBootEx (
TPL_NOTIFY,
BmEndOfBdsPerfCode,
NULL,
&LegacyBootEvent
);
ASSERT_EFI_ERROR (Status);
- );
+ );
mBmLegacyBoot (BootOption);
} else {
BootOption->Status = EFI_UNSUPPORTED;
}
- PERF_END_EX (gImageHandle, "BdsAttempt", NULL, 0, (UINT32) OptionNumber);
+ PERF_END_EX (gImageHandle, "BdsAttempt", NULL, 0, (UINT32)OptionNumber);
return;
}
//
// Provide the image with its load options
//
- Status = gBS->HandleProtocol (ImageHandle, &gEfiLoadedImageProtocolGuid, (VOID **) &ImageInfo);
+ Status = gBS->HandleProtocol (ImageHandle, &gEfiLoadedImageProtocolGuid, (VOID **)&ImageInfo);
ASSERT_EFI_ERROR (Status);
if (!BmIsAutoCreateBootOption (BootOption)) {
@@ -1975,7 +2032,7 @@ EfiBootManagerBoot ( //
PERF_CODE (
BmEndOfBdsPerfCode (NULL, NULL);
- );
+ );
REPORT_STATUS_CODE (EFI_PROGRESS_CODE, PcdGet32 (PcdProgressCodeOsLoaderStart));
@@ -1997,8 +2054,8 @@ EfiBootManagerBoot ( //
BmReportLoadFailure (EFI_SW_DXE_BS_EC_BOOT_OPTION_FAILED, Status);
}
- PERF_END_EX (gImageHandle, "BdsAttempt", NULL, 0, (UINT32) OptionNumber);
+ PERF_END_EX (gImageHandle, "BdsAttempt", NULL, 0, (UINT32)OptionNumber);
//
// Clear the Watchdog Timer after the image returns
@@ -2009,7 +2066,7 @@ EfiBootManagerBoot ( // Set Logo status invalid after trying one boot option
//
BootLogo = NULL;
- Status = gBS->LocateProtocol (&gEfiBootLogoProtocolGuid, NULL, (VOID **) &BootLogo);
+ Status = gBS->LocateProtocol (&gEfiBootLogoProtocolGuid, NULL, (VOID **)&BootLogo);
if (!EFI_ERROR (Status) && (BootLogo != NULL)) {
Status = BootLogo->SetBootLogo (BootLogo, NULL, 0, 0, 0, 0);
ASSERT_EFI_ERROR (Status);
@@ -2047,11 +2104,11 @@ EfiBootManagerBoot ( **/
BOOLEAN
BmMatchPartitionDevicePathNode (
- IN EFI_DEVICE_PATH_PROTOCOL *BlockIoDevicePath,
- IN HARDDRIVE_DEVICE_PATH *HardDriveDevicePath
+ IN EFI_DEVICE_PATH_PROTOCOL *BlockIoDevicePath,
+ IN HARDDRIVE_DEVICE_PATH *HardDriveDevicePath
)
{
- HARDDRIVE_DEVICE_PATH *Node;
+ HARDDRIVE_DEVICE_PATH *Node;
if ((BlockIoDevicePath == NULL) || (HardDriveDevicePath == NULL)) {
return FALSE;
@@ -2063,11 +2120,12 @@ BmMatchPartitionDevicePathNode ( while (!IsDevicePathEnd (BlockIoDevicePath)) {
if ((DevicePathType (BlockIoDevicePath) == MEDIA_DEVICE_PATH) &&
(DevicePathSubType (BlockIoDevicePath) == MEDIA_HARDDRIVE_DP)
- ) {
+ )
+ {
//
// See if the harddrive device path in blockio matches the orig Hard Drive Node
//
- Node = (HARDDRIVE_DEVICE_PATH *) BlockIoDevicePath;
+ Node = (HARDDRIVE_DEVICE_PATH *)BlockIoDevicePath;
//
// Match Signature and PartitionNumber.
@@ -2076,7 +2134,8 @@ BmMatchPartitionDevicePathNode ( if ((Node->PartitionNumber == HardDriveDevicePath->PartitionNumber) &&
(Node->MBRType == HardDriveDevicePath->MBRType) &&
(Node->SignatureType == HardDriveDevicePath->SignatureType) &&
- (CompareMem (Node->Signature, HardDriveDevicePath->Signature, sizeof (Node->Signature)) == 0)) {
+ (CompareMem (Node->Signature, HardDriveDevicePath->Signature, sizeof (Node->Signature)) == 0))
+ {
return TRUE;
}
}
@@ -2106,17 +2165,17 @@ BmMatchPartitionDevicePathNode ( **/
EFI_BOOT_MANAGER_LOAD_OPTION *
BmEnumerateBootOptions (
- UINTN *BootOptionCount
+ UINTN *BootOptionCount
)
{
- EFI_STATUS Status;
- EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;
- UINTN HandleCount;
- EFI_HANDLE *Handles;
- EFI_BLOCK_IO_PROTOCOL *BlkIo;
- UINTN Removable;
- UINTN Index;
- CHAR16 *Description;
+ EFI_STATUS Status;
+ EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;
+ UINTN HandleCount;
+ EFI_HANDLE *Handles;
+ EFI_BLOCK_IO_PROTOCOL *BlkIo;
+ UINTN Removable;
+ UINTN Index;
+ CHAR16 *Description;
ASSERT (BootOptionCount != NULL);
@@ -2139,7 +2198,7 @@ BmEnumerateBootOptions ( Status = gBS->HandleProtocol (
Handles[Index],
&gEfiBlockIoProtocolGuid,
- (VOID **) &BlkIo
+ (VOID **)&BlkIo
);
if (EFI_ERROR (Status)) {
continue;
@@ -2201,14 +2260,15 @@ BmEnumerateBootOptions ( Status = gBS->HandleProtocol (
Handles[Index],
&gEfiBlockIoProtocolGuid,
- (VOID **) &BlkIo
+ (VOID **)&BlkIo
);
- if (!EFI_ERROR (Status)) {
+ if (!EFI_ERROR (Status)) {
//
// Skip if the file system handle supports a BlkIo protocol, which we've handled in above
//
continue;
}
+
Description = BmGetBootDescription (Handles[Index]);
BootOptions = ReallocatePool (
sizeof (EFI_BOOT_MANAGER_LOAD_OPTION) * (*BootOptionCount),
@@ -2292,15 +2352,15 @@ EfiBootManagerRefreshAllBootOption ( VOID
)
{
- EFI_STATUS Status;
- EFI_BOOT_MANAGER_LOAD_OPTION *NvBootOptions;
- UINTN NvBootOptionCount;
- EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;
- UINTN BootOptionCount;
- EFI_BOOT_MANAGER_LOAD_OPTION *UpdatedBootOptions;
- UINTN UpdatedBootOptionCount;
- UINTN Index;
- EDKII_PLATFORM_BOOT_MANAGER_PROTOCOL *PlatformBootManager;
+ EFI_STATUS Status;
+ EFI_BOOT_MANAGER_LOAD_OPTION *NvBootOptions;
+ UINTN NvBootOptionCount;
+ EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;
+ UINTN BootOptionCount;
+ EFI_BOOT_MANAGER_LOAD_OPTION *UpdatedBootOptions;
+ UINTN UpdatedBootOptionCount;
+ UINTN Index;
+ EDKII_PLATFORM_BOOT_MANAGER_PROTOCOL *PlatformBootManager;
//
// Optionally refresh the legacy boot option
@@ -2309,7 +2369,7 @@ EfiBootManagerRefreshAllBootOption ( mBmRefreshLegacyBootOption ();
}
- BootOptions = BmEnumerateBootOptions (&BootOptionCount);
+ BootOptions = BmEnumerateBootOptions (&BootOptionCount);
//
// Mark the boot option as added by BDS by setting OptionalData to a special GUID
@@ -2322,21 +2382,25 @@ EfiBootManagerRefreshAllBootOption ( //
// Locate Platform Boot Options Protocol
//
- Status = gBS->LocateProtocol (&gEdkiiPlatformBootManagerProtocolGuid,
- NULL,
- (VOID **)&PlatformBootManager);
+ Status = gBS->LocateProtocol (
+ &gEdkiiPlatformBootManagerProtocolGuid,
+ NULL,
+ (VOID **)&PlatformBootManager
+ );
if (!EFI_ERROR (Status)) {
//
// If found, call platform specific refresh to all auto enumerated and NV
// boot options.
//
- Status = PlatformBootManager->RefreshAllBootOptions ((CONST EFI_BOOT_MANAGER_LOAD_OPTION *)BootOptions,
- (CONST UINTN)BootOptionCount,
- &UpdatedBootOptions,
- &UpdatedBootOptionCount);
+ Status = PlatformBootManager->RefreshAllBootOptions (
+ (CONST EFI_BOOT_MANAGER_LOAD_OPTION *)BootOptions,
+ (CONST UINTN)BootOptionCount,
+ &UpdatedBootOptions,
+ &UpdatedBootOptionCount
+ );
if (!EFI_ERROR (Status)) {
EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount);
- BootOptions = UpdatedBootOptions;
+ BootOptions = UpdatedBootOptions;
BootOptionCount = UpdatedBootOptionCount;
}
}
@@ -2349,8 +2413,9 @@ EfiBootManagerRefreshAllBootOption ( for (Index = 0; Index < NvBootOptionCount; Index++) {
if (((DevicePathType (NvBootOptions[Index].FilePath) != BBS_DEVICE_PATH) ||
(DevicePathSubType (NvBootOptions[Index].FilePath) != BBS_BBS_DP)
- ) && BmIsAutoCreateBootOption (&NvBootOptions[Index])
- ) {
+ ) && BmIsAutoCreateBootOption (&NvBootOptions[Index])
+ )
+ {
//
// Only check those added by BDS
// so that the boot options added by end-user or OS installer won't be deleted
@@ -2370,14 +2435,14 @@ EfiBootManagerRefreshAllBootOption ( //
for (Index = 0; Index < BootOptionCount; Index++) {
if (EfiBootManagerFindLoadOption (&BootOptions[Index], NvBootOptions, NvBootOptionCount) == -1) {
- EfiBootManagerAddLoadOptionVariable (&BootOptions[Index], (UINTN) -1);
+ EfiBootManagerAddLoadOptionVariable (&BootOptions[Index], (UINTN)-1);
//
// Try best to add the boot options so continue upon failure.
//
}
}
- EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount);
+ EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount);
EfiBootManagerFreeLoadOptions (NvBootOptions, NvBootOptionCount);
}
@@ -2398,18 +2463,18 @@ EfiBootManagerRefreshAllBootOption ( **/
EFI_STATUS
BmRegisterBootManagerMenu (
- OUT EFI_BOOT_MANAGER_LOAD_OPTION *BootOption
+ OUT EFI_BOOT_MANAGER_LOAD_OPTION *BootOption
)
{
- EFI_STATUS Status;
- CHAR16 *Description;
- UINTN DescriptionLength;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- UINTN HandleCount;
- EFI_HANDLE *Handles;
- UINTN Index;
-
- DevicePath = NULL;
+ EFI_STATUS Status;
+ CHAR16 *Description;
+ UINTN DescriptionLength;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ UINTN HandleCount;
+ EFI_HANDLE *Handles;
+ UINTN Index;
+
+ DevicePath = NULL;
Description = NULL;
//
// Try to find BootManagerMenu from LoadFile protocol
@@ -2428,6 +2493,7 @@ BmRegisterBootManagerMenu ( break;
}
}
+
if (HandleCount != 0) {
FreePool (Handles);
}
@@ -2443,6 +2509,7 @@ BmRegisterBootManagerMenu ( DEBUG ((DEBUG_WARN, "[Bds]BootManagerMenu FFS section can not be found, skip its boot option registration\n"));
return EFI_NOT_FOUND;
}
+
ASSERT (DevicePath != NULL);
//
// Get BootManagerMenu application's description from EFI User Interface Section.
@@ -2451,7 +2518,7 @@ BmRegisterBootManagerMenu ( PcdGetPtr (PcdBootManagerMenuFile),
EFI_SECTION_USER_INTERFACE,
0,
- (VOID **) &Description,
+ (VOID **)&Description,
&DescriptionLength
);
if (EFI_ERROR (Status)) {
@@ -2484,7 +2551,7 @@ BmRegisterBootManagerMenu ( EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount);
);
- return EfiBootManagerAddLoadOptionVariable (BootOption, (UINTN) -1);
+ return EfiBootManagerAddLoadOptionVariable (BootOption, (UINTN)-1);
}
/**
@@ -2502,30 +2569,30 @@ BmRegisterBootManagerMenu ( EFI_STATUS
EFIAPI
EfiBootManagerGetBootManagerMenu (
- EFI_BOOT_MANAGER_LOAD_OPTION *BootOption
+ EFI_BOOT_MANAGER_LOAD_OPTION *BootOption
)
{
- EFI_STATUS Status;
- UINTN BootOptionCount;
- EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;
- UINTN Index;
+ EFI_STATUS Status;
+ UINTN BootOptionCount;
+ EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;
+ UINTN Index;
BootOptions = EfiBootManagerGetLoadOptions (&BootOptionCount, LoadOptionTypeBoot);
for (Index = 0; Index < BootOptionCount; Index++) {
if (BmIsBootManagerMenuFilePath (BootOptions[Index].FilePath)) {
- Status = EfiBootManagerInitializeLoadOption (
- BootOption,
- BootOptions[Index].OptionNumber,
- BootOptions[Index].OptionType,
- BootOptions[Index].Attributes,
- BootOptions[Index].Description,
- BootOptions[Index].FilePath,
- BootOptions[Index].OptionalData,
- BootOptions[Index].OptionalDataSize
- );
- ASSERT_EFI_ERROR (Status);
- break;
+ Status = EfiBootManagerInitializeLoadOption (
+ BootOption,
+ BootOptions[Index].OptionNumber,
+ BootOptions[Index].OptionType,
+ BootOptions[Index].Attributes,
+ BootOptions[Index].Description,
+ BootOptions[Index].FilePath,
+ BootOptions[Index].OptionalData,
+ BootOptions[Index].OptionalDataSize
+ );
+ ASSERT_EFI_ERROR (Status);
+ break;
}
}
@@ -2558,9 +2625,9 @@ EfiBootManagerGetBootManagerMenu ( EFI_DEVICE_PATH_PROTOCOL *
EFIAPI
EfiBootManagerGetNextLoadOptionDevicePath (
- IN EFI_DEVICE_PATH_PROTOCOL *FilePath,
- IN EFI_DEVICE_PATH_PROTOCOL *FullPath
+ IN EFI_DEVICE_PATH_PROTOCOL *FilePath,
+ IN EFI_DEVICE_PATH_PROTOCOL *FullPath
)
{
- return BmGetNextLoadOptionDevicePath(FilePath, FullPath);
+ return BmGetNextLoadOptionDevicePath (FilePath, FullPath);
}
diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c b/MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c index aa891feb17..fac33b9ee9 100644 --- a/MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c +++ b/MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c @@ -9,15 +9,15 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include "InternalBm.h"
-#define VENDOR_IDENTIFICATION_OFFSET 3
-#define VENDOR_IDENTIFICATION_LENGTH 8
-#define PRODUCT_IDENTIFICATION_OFFSET 11
-#define PRODUCT_IDENTIFICATION_LENGTH 16
+#define VENDOR_IDENTIFICATION_OFFSET 3
+#define VENDOR_IDENTIFICATION_LENGTH 8
+#define PRODUCT_IDENTIFICATION_OFFSET 11
+#define PRODUCT_IDENTIFICATION_LENGTH 16
-CONST UINT16 mBmUsbLangId = 0x0409; // English
-CHAR16 mBmUefiPrefix[] = L"UEFI ";
+CONST UINT16 mBmUsbLangId = 0x0409; // English
+CHAR16 mBmUefiPrefix[] = L"UEFI ";
-LIST_ENTRY mPlatformBootDescriptionHandlers = INITIALIZE_LIST_HEAD_VARIABLE (mPlatformBootDescriptionHandlers);
+LIST_ENTRY mPlatformBootDescriptionHandlers = INITIALIZE_LIST_HEAD_VARIABLE (mPlatformBootDescriptionHandlers);
/**
For a bootable Device path, return its boot type.
@@ -39,27 +39,28 @@ LIST_ENTRY mPlatformBootDescriptionHandlers = INITIALIZE_LIST_HEAD_VARIABLE (mPl **/
BM_BOOT_TYPE
BmDevicePathType (
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
)
{
- EFI_DEVICE_PATH_PROTOCOL *Node;
- EFI_DEVICE_PATH_PROTOCOL *NextNode;
+ EFI_DEVICE_PATH_PROTOCOL *Node;
+ EFI_DEVICE_PATH_PROTOCOL *NextNode;
ASSERT (DevicePath != NULL);
for (Node = DevicePath; !IsDevicePathEndType (Node); Node = NextDevicePathNode (Node)) {
switch (DevicePathType (Node)) {
-
case ACPI_DEVICE_PATH:
- if (EISA_ID_TO_NUM (((ACPI_HID_DEVICE_PATH *) Node)->HID) == 0x0604) {
+ if (EISA_ID_TO_NUM (((ACPI_HID_DEVICE_PATH *)Node)->HID) == 0x0604) {
return BmAcpiFloppyBoot;
}
+
break;
case HARDWARE_DEVICE_PATH:
if (DevicePathSubType (Node) == HW_CONTROLLER_DP) {
return BmHardwareDeviceBoot;
}
+
break;
case MESSAGING_DEVICE_PATH:
@@ -70,9 +71,9 @@ BmDevicePathType ( do {
NextNode = NextDevicePathNode (NextNode);
} while (
- (DevicePathType (NextNode) == MESSAGING_DEVICE_PATH) &&
- (DevicePathSubType(NextNode) == MSG_DEVICE_LOGICAL_UNIT_DP)
- );
+ (DevicePathType (NextNode) == MESSAGING_DEVICE_PATH) &&
+ (DevicePathSubType (NextNode) == MSG_DEVICE_LOGICAL_UNIT_DP)
+ );
//
// If the device path not only point to driver device, it is not a messaging device path,
@@ -82,21 +83,21 @@ BmDevicePathType ( }
switch (DevicePathSubType (Node)) {
- case MSG_ATAPI_DP:
- return BmMessageAtapiBoot;
- break;
+ case MSG_ATAPI_DP:
+ return BmMessageAtapiBoot;
+ break;
- case MSG_SATA_DP:
- return BmMessageSataBoot;
- break;
+ case MSG_SATA_DP:
+ return BmMessageSataBoot;
+ break;
- case MSG_USB_DP:
- return BmMessageUsbBoot;
- break;
+ case MSG_USB_DP:
+ return BmMessageUsbBoot;
+ break;
- case MSG_SCSI_DP:
- return BmMessageScsiBoot;
- break;
+ case MSG_SCSI_DP:
+ return BmMessageScsiBoot;
+ break;
}
}
}
@@ -111,17 +112,18 @@ BmDevicePathType ( **/
VOID
BmEliminateExtraSpaces (
- IN CHAR16 *Str
+ IN CHAR16 *Str
)
{
- UINTN Index;
- UINTN ActualIndex;
+ UINTN Index;
+ UINTN ActualIndex;
for (Index = 0, ActualIndex = 0; Str[Index] != L'\0'; Index++) {
if ((Str[Index] != L' ') || ((ActualIndex > 0) && (Str[ActualIndex - 1] != L' '))) {
Str[ActualIndex++] = Str[Index];
}
}
+
Str[ActualIndex] = L'\0';
}
@@ -134,70 +136,72 @@ BmEliminateExtraSpaces ( **/
CHAR16 *
BmGetDescriptionFromDiskInfo (
- IN EFI_HANDLE Handle
+ IN EFI_HANDLE Handle
)
{
- UINTN Index;
- EFI_STATUS Status;
- EFI_DISK_INFO_PROTOCOL *DiskInfo;
- UINT32 BufferSize;
- EFI_ATAPI_IDENTIFY_DATA IdentifyData;
- EFI_SCSI_INQUIRY_DATA InquiryData;
- CHAR16 *Description;
- UINTN Length;
- CONST UINTN ModelNameLength = 40;
- CONST UINTN SerialNumberLength = 20;
- CHAR8 *StrPtr;
- UINT8 Temp;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
-
- Description = NULL;
+ UINTN Index;
+ EFI_STATUS Status;
+ EFI_DISK_INFO_PROTOCOL *DiskInfo;
+ UINT32 BufferSize;
+ EFI_ATAPI_IDENTIFY_DATA IdentifyData;
+ EFI_SCSI_INQUIRY_DATA InquiryData;
+ CHAR16 *Description;
+ UINTN Length;
+ CONST UINTN ModelNameLength = 40;
+ CONST UINTN SerialNumberLength = 20;
+ CHAR8 *StrPtr;
+ UINT8 Temp;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+
+ Description = NULL;
Status = gBS->HandleProtocol (
Handle,
&gEfiDiskInfoProtocolGuid,
- (VOID **) &DiskInfo
+ (VOID **)&DiskInfo
);
if (EFI_ERROR (Status)) {
return NULL;
}
if (CompareGuid (&DiskInfo->Interface, &gEfiDiskInfoAhciInterfaceGuid) ||
- CompareGuid (&DiskInfo->Interface, &gEfiDiskInfoIdeInterfaceGuid)) {
- BufferSize = sizeof (EFI_ATAPI_IDENTIFY_DATA);
- Status = DiskInfo->Identify (
- DiskInfo,
- &IdentifyData,
- &BufferSize
- );
+ CompareGuid (&DiskInfo->Interface, &gEfiDiskInfoIdeInterfaceGuid))
+ {
+ BufferSize = sizeof (EFI_ATAPI_IDENTIFY_DATA);
+ Status = DiskInfo->Identify (
+ DiskInfo,
+ &IdentifyData,
+ &BufferSize
+ );
if (!EFI_ERROR (Status)) {
Description = AllocateZeroPool ((ModelNameLength + SerialNumberLength + 2) * sizeof (CHAR16));
ASSERT (Description != NULL);
for (Index = 0; Index + 1 < ModelNameLength; Index += 2) {
- Description[Index] = (CHAR16) IdentifyData.ModelName[Index + 1];
- Description[Index + 1] = (CHAR16) IdentifyData.ModelName[Index];
+ Description[Index] = (CHAR16)IdentifyData.ModelName[Index + 1];
+ Description[Index + 1] = (CHAR16)IdentifyData.ModelName[Index];
}
- Length = Index;
+ Length = Index;
Description[Length++] = L' ';
for (Index = 0; Index + 1 < SerialNumberLength; Index += 2) {
- Description[Length + Index] = (CHAR16) IdentifyData.SerialNo[Index + 1];
- Description[Length + Index + 1] = (CHAR16) IdentifyData.SerialNo[Index];
+ Description[Length + Index] = (CHAR16)IdentifyData.SerialNo[Index + 1];
+ Description[Length + Index + 1] = (CHAR16)IdentifyData.SerialNo[Index];
}
- Length += Index;
+
+ Length += Index;
Description[Length++] = L'\0';
ASSERT (Length == ModelNameLength + SerialNumberLength + 2);
BmEliminateExtraSpaces (Description);
}
} else if (CompareGuid (&DiskInfo->Interface, &gEfiDiskInfoScsiInterfaceGuid)) {
- BufferSize = sizeof (EFI_SCSI_INQUIRY_DATA);
- Status = DiskInfo->Inquiry (
- DiskInfo,
- &InquiryData,
- &BufferSize
- );
+ BufferSize = sizeof (EFI_SCSI_INQUIRY_DATA);
+ Status = DiskInfo->Inquiry (
+ DiskInfo,
+ &InquiryData,
+ &BufferSize
+ );
if (!EFI_ERROR (Status)) {
Description = AllocateZeroPool ((VENDOR_IDENTIFICATION_LENGTH + PRODUCT_IDENTIFICATION_LENGTH + 2) * sizeof (CHAR16));
ASSERT (Description != NULL);
@@ -207,8 +211,8 @@ BmGetDescriptionFromDiskInfo ( // EFI_SCSI_INQUIRY_DATA.Reserved_5_95[11 - 26] save the product identification,
// Here combine the vendor identification and product identification to the description.
//
- StrPtr = (CHAR8 *) (&InquiryData.Reserved_5_95[VENDOR_IDENTIFICATION_OFFSET]);
- Temp = StrPtr[VENDOR_IDENTIFICATION_LENGTH];
+ StrPtr = (CHAR8 *)(&InquiryData.Reserved_5_95[VENDOR_IDENTIFICATION_OFFSET]);
+ Temp = StrPtr[VENDOR_IDENTIFICATION_LENGTH];
StrPtr[VENDOR_IDENTIFICATION_LENGTH] = '\0';
AsciiStrToUnicodeStrS (StrPtr, Description, VENDOR_IDENTIFICATION_LENGTH + 1);
StrPtr[VENDOR_IDENTIFICATION_LENGTH] = Temp;
@@ -218,7 +222,7 @@ BmGetDescriptionFromDiskInfo ( //
Description[VENDOR_IDENTIFICATION_LENGTH] = L' ';
- StrPtr = (CHAR8 *) (&InquiryData.Reserved_5_95[PRODUCT_IDENTIFICATION_OFFSET]);
+ StrPtr = (CHAR8 *)(&InquiryData.Reserved_5_95[PRODUCT_IDENTIFICATION_OFFSET]);
StrPtr[PRODUCT_IDENTIFICATION_LENGTH] = '\0';
AsciiStrToUnicodeStrS (StrPtr, Description + VENDOR_IDENTIFICATION_LENGTH + 1, PRODUCT_IDENTIFICATION_LENGTH + 1);
@@ -233,6 +237,7 @@ BmGetDescriptionFromDiskInfo ( while (!IsDevicePathEnd (DevicePath) && (DevicePathType (DevicePath) != MESSAGING_DEVICE_PATH)) {
DevicePath = NextDevicePathNode (DevicePath);
}
+
if (IsDevicePathEnd (DevicePath)) {
return NULL;
}
@@ -260,23 +265,23 @@ BmGetDescriptionFromDiskInfo ( **/
CHAR16 *
BmGetUsbDescription (
- IN EFI_HANDLE Handle
+ IN EFI_HANDLE Handle
)
{
- EFI_STATUS Status;
- EFI_USB_IO_PROTOCOL *UsbIo;
- CHAR16 NullChar;
- CHAR16 *Manufacturer;
- CHAR16 *Product;
- CHAR16 *SerialNumber;
- CHAR16 *Description;
- EFI_USB_DEVICE_DESCRIPTOR DevDesc;
- UINTN DescMaxSize;
+ EFI_STATUS Status;
+ EFI_USB_IO_PROTOCOL *UsbIo;
+ CHAR16 NullChar;
+ CHAR16 *Manufacturer;
+ CHAR16 *Product;
+ CHAR16 *SerialNumber;
+ CHAR16 *Description;
+ EFI_USB_DEVICE_DESCRIPTOR DevDesc;
+ UINTN DescMaxSize;
Status = gBS->HandleProtocol (
Handle,
&gEfiUsbIoProtocolGuid,
- (VOID **) &UsbIo
+ (VOID **)&UsbIo
);
if (EFI_ERROR (Status)) {
return NULL;
@@ -322,27 +327,30 @@ BmGetUsbDescription ( if ((Manufacturer == &NullChar) &&
(Product == &NullChar) &&
(SerialNumber == &NullChar)
- ) {
+ )
+ {
return NULL;
}
DescMaxSize = StrSize (Manufacturer) + StrSize (Product) + StrSize (SerialNumber);
Description = AllocateZeroPool (DescMaxSize);
ASSERT (Description != NULL);
- StrCatS (Description, DescMaxSize/sizeof(CHAR16), Manufacturer);
- StrCatS (Description, DescMaxSize/sizeof(CHAR16), L" ");
+ StrCatS (Description, DescMaxSize/sizeof (CHAR16), Manufacturer);
+ StrCatS (Description, DescMaxSize/sizeof (CHAR16), L" ");
- StrCatS (Description, DescMaxSize/sizeof(CHAR16), Product);
- StrCatS (Description, DescMaxSize/sizeof(CHAR16), L" ");
+ StrCatS (Description, DescMaxSize/sizeof (CHAR16), Product);
+ StrCatS (Description, DescMaxSize/sizeof (CHAR16), L" ");
- StrCatS (Description, DescMaxSize/sizeof(CHAR16), SerialNumber);
+ StrCatS (Description, DescMaxSize/sizeof (CHAR16), SerialNumber);
if (Manufacturer != &NullChar) {
FreePool (Manufacturer);
}
+
if (Product != &NullChar) {
FreePool (Product);
}
+
if (SerialNumber != &NullChar) {
FreePool (SerialNumber);
}
@@ -361,17 +369,17 @@ BmGetUsbDescription ( **/
CHAR16 *
BmGetNetworkDescription (
- IN EFI_HANDLE Handle
+ IN EFI_HANDLE Handle
)
{
- EFI_STATUS Status;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- MAC_ADDR_DEVICE_PATH *Mac;
- VLAN_DEVICE_PATH *Vlan;
- EFI_DEVICE_PATH_PROTOCOL *Ip;
- EFI_DEVICE_PATH_PROTOCOL *Uri;
- CHAR16 *Description;
- UINTN DescriptionSize;
+ EFI_STATUS Status;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ MAC_ADDR_DEVICE_PATH *Mac;
+ VLAN_DEVICE_PATH *Vlan;
+ EFI_DEVICE_PATH_PROTOCOL *Ip;
+ EFI_DEVICE_PATH_PROTOCOL *Uri;
+ CHAR16 *Description;
+ UINTN DescriptionSize;
Status = gBS->OpenProtocol (
Handle,
@@ -388,7 +396,7 @@ BmGetNetworkDescription ( Status = gBS->OpenProtocol (
Handle,
&gEfiDevicePathProtocolGuid,
- (VOID **) &DevicePath,
+ (VOID **)&DevicePath,
gImageHandle,
Handle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -410,7 +418,8 @@ BmGetNetworkDescription ( while (!IsDevicePathEnd (DevicePath) &&
((DevicePathType (DevicePath) != MESSAGING_DEVICE_PATH) ||
(DevicePathSubType (DevicePath) != MSG_MAC_ADDR_DP))
- ) {
+ )
+ {
DevicePath = NextDevicePathNode (DevicePath);
}
@@ -418,7 +427,7 @@ BmGetNetworkDescription ( return NULL;
}
- Mac = (MAC_ADDR_DEVICE_PATH *) DevicePath;
+ Mac = (MAC_ADDR_DEVICE_PATH *)DevicePath;
DevicePath = NextDevicePathNode (DevicePath);
//
@@ -426,8 +435,9 @@ BmGetNetworkDescription ( //
if ((DevicePathType (DevicePath) == MESSAGING_DEVICE_PATH) &&
(DevicePathSubType (DevicePath) == MSG_VLAN_DP)
- ) {
- Vlan = (VLAN_DEVICE_PATH *) DevicePath;
+ )
+ {
+ Vlan = (VLAN_DEVICE_PATH *)DevicePath;
DevicePath = NextDevicePathNode (DevicePath);
} else {
Vlan = NULL;
@@ -438,7 +448,8 @@ BmGetNetworkDescription ( //
if ((DevicePathType (DevicePath) == MESSAGING_DEVICE_PATH) &&
(DevicePathSubType (DevicePath) == MSG_WIFI_DP)
- ) {
+ )
+ {
DevicePath = NextDevicePathNode (DevicePath);
}
@@ -448,8 +459,9 @@ BmGetNetworkDescription ( if ((DevicePathType (DevicePath) == MESSAGING_DEVICE_PATH) &&
((DevicePathSubType (DevicePath) == MSG_IPv4_DP) ||
(DevicePathSubType (DevicePath) == MSG_IPv6_DP))
- ) {
- Ip = DevicePath;
+ )
+ {
+ Ip = DevicePath;
DevicePath = NextDevicePathNode (DevicePath);
} else {
Ip = NULL;
@@ -460,7 +472,8 @@ BmGetNetworkDescription ( //
if ((DevicePathType (DevicePath) == MESSAGING_DEVICE_PATH) &&
(DevicePathSubType (DevicePath) == MSG_DNS_DP)
- ) {
+ )
+ {
DevicePath = NextDevicePathNode (DevicePath);
}
@@ -469,8 +482,9 @@ BmGetNetworkDescription ( //
if ((DevicePathType (DevicePath) == MESSAGING_DEVICE_PATH) &&
(DevicePathSubType (DevicePath) == MSG_URI_DP)
- ) {
- Uri = DevicePath;
+ )
+ {
+ Uri = DevicePath;
DevicePath = NextDevicePathNode (DevicePath);
} else {
Uri = NULL;
@@ -485,14 +499,19 @@ BmGetNetworkDescription ( Description = AllocatePool (DescriptionSize);
ASSERT (Description != NULL);
UnicodeSPrint (
- Description, DescriptionSize,
+ Description,
+ DescriptionSize,
(Vlan == NULL) ?
L"%sv%d (MAC:%02x%02x%02x%02x%02x%02x)" :
L"%sv%d (MAC:%02x%02x%02x%02x%02x%02x VLAN%d)",
(Uri == NULL) ? L"PXE" : L"HTTP",
((Ip == NULL) || (DevicePathSubType (Ip) == MSG_IPv4_DP)) ? 4 : 6,
- Mac->MacAddress.Addr[0], Mac->MacAddress.Addr[1], Mac->MacAddress.Addr[2],
- Mac->MacAddress.Addr[3], Mac->MacAddress.Addr[4], Mac->MacAddress.Addr[5],
+ Mac->MacAddress.Addr[0],
+ Mac->MacAddress.Addr[1],
+ Mac->MacAddress.Addr[2],
+ Mac->MacAddress.Addr[3],
+ Mac->MacAddress.Addr[4],
+ Mac->MacAddress.Addr[5],
(Vlan == NULL) ? 0 : Vlan->VlanId
);
return Description;
@@ -507,14 +526,14 @@ BmGetNetworkDescription ( **/
CHAR16 *
BmGetLoadFileDescription (
- IN EFI_HANDLE Handle
+ IN EFI_HANDLE Handle
)
{
- EFI_STATUS Status;
- EFI_DEVICE_PATH_PROTOCOL *FilePath;
- EFI_DEVICE_PATH_PROTOCOL *DevicePathNode;
- CHAR16 *Description;
- EFI_LOAD_FILE_PROTOCOL *LoadFile;
+ EFI_STATUS Status;
+ EFI_DEVICE_PATH_PROTOCOL *FilePath;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePathNode;
+ CHAR16 *Description;
+ EFI_LOAD_FILE_PROTOCOL *LoadFile;
Status = gBS->HandleProtocol (Handle, &gEfiLoadFileProtocolGuid, (VOID **)&LoadFile);
if (EFI_ERROR (Status)) {
@@ -525,14 +544,15 @@ BmGetLoadFileDescription ( // Get the file name
//
Description = NULL;
- Status = gBS->HandleProtocol (Handle, &gEfiDevicePathProtocolGuid, (VOID **)&FilePath);
+ Status = gBS->HandleProtocol (Handle, &gEfiDevicePathProtocolGuid, (VOID **)&FilePath);
if (!EFI_ERROR (Status)) {
DevicePathNode = FilePath;
while (!IsDevicePathEnd (DevicePathNode)) {
- if (DevicePathNode->Type == MEDIA_DEVICE_PATH && DevicePathNode->SubType == MEDIA_FILEPATH_DP) {
+ if ((DevicePathNode->Type == MEDIA_DEVICE_PATH) && (DevicePathNode->SubType == MEDIA_FILEPATH_DP)) {
Description = (CHAR16 *)(DevicePathNode + 1);
break;
}
+
DevicePathNode = NextDevicePathNode (DevicePathNode);
}
}
@@ -553,21 +573,21 @@ BmGetLoadFileDescription ( **/
CHAR16 *
BmGetNvmeDescription (
- IN EFI_HANDLE Handle
+ IN EFI_HANDLE Handle
)
{
- EFI_STATUS Status;
- EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL *NvmePassthru;
- EFI_DEV_PATH_PTR DevicePath;
- EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET CommandPacket;
- EFI_NVM_EXPRESS_COMMAND Command;
- EFI_NVM_EXPRESS_COMPLETION Completion;
- NVME_ADMIN_CONTROLLER_DATA ControllerData;
- CHAR16 *Description;
- CHAR16 *Char;
- UINTN Index;
-
- Status = gBS->HandleProtocol (Handle, &gEfiDevicePathProtocolGuid, (VOID **) &DevicePath.DevPath);
+ EFI_STATUS Status;
+ EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL *NvmePassthru;
+ EFI_DEV_PATH_PTR DevicePath;
+ EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET CommandPacket;
+ EFI_NVM_EXPRESS_COMMAND Command;
+ EFI_NVM_EXPRESS_COMPLETION Completion;
+ NVME_ADMIN_CONTROLLER_DATA ControllerData;
+ CHAR16 *Description;
+ CHAR16 *Char;
+ UINTN Index;
+
+ Status = gBS->HandleProtocol (Handle, &gEfiDevicePathProtocolGuid, (VOID **)&DevicePath.DevPath);
if (EFI_ERROR (Status)) {
return NULL;
}
@@ -575,7 +595,8 @@ BmGetNvmeDescription ( Status = gBS->LocateDevicePath (&gEfiNvmExpressPassThruProtocolGuid, &DevicePath.DevPath, &Handle);
if (EFI_ERROR (Status) ||
(DevicePathType (DevicePath.DevPath) != MESSAGING_DEVICE_PATH) ||
- (DevicePathSubType (DevicePath.DevPath) != MSG_NVME_NAMESPACE_DP)) {
+ (DevicePathSubType (DevicePath.DevPath) != MSG_NVME_NAMESPACE_DP))
+ {
//
// Do not return description when the Handle is not a child of NVME controller.
//
@@ -585,19 +606,19 @@ BmGetNvmeDescription ( //
// Send ADMIN_IDENTIFY command to NVME controller to get the model and serial number.
//
- Status = gBS->HandleProtocol (Handle, &gEfiNvmExpressPassThruProtocolGuid, (VOID **) &NvmePassthru);
+ Status = gBS->HandleProtocol (Handle, &gEfiNvmExpressPassThruProtocolGuid, (VOID **)&NvmePassthru);
ASSERT_EFI_ERROR (Status);
- ZeroMem (&CommandPacket, sizeof(EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET));
- ZeroMem (&Command, sizeof(EFI_NVM_EXPRESS_COMMAND));
- ZeroMem (&Completion, sizeof(EFI_NVM_EXPRESS_COMPLETION));
+ ZeroMem (&CommandPacket, sizeof (EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET));
+ ZeroMem (&Command, sizeof (EFI_NVM_EXPRESS_COMMAND));
+ ZeroMem (&Completion, sizeof (EFI_NVM_EXPRESS_COMPLETION));
Command.Cdw0.Opcode = NVME_ADMIN_IDENTIFY_CMD;
//
// According to Nvm Express 1.1 spec Figure 38, When not used, the field shall be cleared to 0h.
// For the Identify command, the Namespace Identifier is only used for the Namespace data structure.
//
- Command.Nsid = 0;
+ Command.Nsid = 0;
CommandPacket.NvmeCmd = &Command;
CommandPacket.NvmeCompletion = &Completion;
CommandPacket.TransferBuffer = &ControllerData;
@@ -607,15 +628,15 @@ BmGetNvmeDescription ( //
// Set bit 0 (Cns bit) to 1 to identify a controller
//
- Command.Cdw10 = 1;
- Command.Flags = CDW10_VALID;
+ Command.Cdw10 = 1;
+ Command.Flags = CDW10_VALID;
Status = NvmePassthru->PassThru (
- NvmePassthru,
- 0,
- &CommandPacket,
- NULL
- );
+ NvmePassthru,
+ 0,
+ &CommandPacket,
+ NULL
+ );
if (EFI_ERROR (Status)) {
return NULL;
}
@@ -624,20 +645,26 @@ BmGetNvmeDescription ( (ARRAY_SIZE (ControllerData.Mn) + 1
+ ARRAY_SIZE (ControllerData.Sn) + 1
+ MAXIMUM_VALUE_CHARACTERS + 1
- ) * sizeof (CHAR16));
+ ) * sizeof (CHAR16)
+ );
if (Description != NULL) {
Char = Description;
for (Index = 0; Index < ARRAY_SIZE (ControllerData.Mn); Index++) {
- *(Char++) = (CHAR16) ControllerData.Mn[Index];
+ *(Char++) = (CHAR16)ControllerData.Mn[Index];
}
+
*(Char++) = L' ';
for (Index = 0; Index < ARRAY_SIZE (ControllerData.Sn); Index++) {
- *(Char++) = (CHAR16) ControllerData.Sn[Index];
+ *(Char++) = (CHAR16)ControllerData.Sn[Index];
}
+
*(Char++) = L' ';
UnicodeValueToStringS (
- Char, sizeof (CHAR16) * (MAXIMUM_VALUE_CHARACTERS + 1),
- 0, DevicePath.NvmeNamespace->NamespaceId, 0
+ Char,
+ sizeof (CHAR16) * (MAXIMUM_VALUE_CHARACTERS + 1),
+ 0,
+ DevicePath.NvmeNamespace->NamespaceId,
+ 0
);
BmEliminateExtraSpaces (Description);
}
@@ -654,54 +681,56 @@ BmGetNvmeDescription ( **/
CHAR16 *
BmGetMiscDescription (
- IN EFI_HANDLE Handle
+ IN EFI_HANDLE Handle
)
{
- EFI_STATUS Status;
- CHAR16 *Description;
- EFI_BLOCK_IO_PROTOCOL *BlockIo;
- EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *Fs;
+ EFI_STATUS Status;
+ CHAR16 *Description;
+ EFI_BLOCK_IO_PROTOCOL *BlockIo;
+ EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *Fs;
switch (BmDevicePathType (DevicePathFromHandle (Handle))) {
- case BmAcpiFloppyBoot:
- Description = L"Floppy";
- break;
-
- case BmMessageAtapiBoot:
- case BmMessageSataBoot:
- Status = gBS->HandleProtocol (Handle, &gEfiBlockIoProtocolGuid, (VOID **) &BlockIo);
- ASSERT_EFI_ERROR (Status);
- //
- // Assume a removable SATA device should be the DVD/CD device
- //
- Description = BlockIo->Media->RemovableMedia ? L"DVD/CDROM" : L"Hard Drive";
- break;
+ case BmAcpiFloppyBoot:
+ Description = L"Floppy";
+ break;
+
+ case BmMessageAtapiBoot:
+ case BmMessageSataBoot:
+ Status = gBS->HandleProtocol (Handle, &gEfiBlockIoProtocolGuid, (VOID **)&BlockIo);
+ ASSERT_EFI_ERROR (Status);
+ //
+ // Assume a removable SATA device should be the DVD/CD device
+ //
+ Description = BlockIo->Media->RemovableMedia ? L"DVD/CDROM" : L"Hard Drive";
+ break;
- case BmMessageUsbBoot:
- Description = L"USB Device";
- break;
+ case BmMessageUsbBoot:
+ Description = L"USB Device";
+ break;
- case BmMessageScsiBoot:
- Description = L"SCSI Device";
- break;
+ case BmMessageScsiBoot:
+ Description = L"SCSI Device";
+ break;
- case BmHardwareDeviceBoot:
- Status = gBS->HandleProtocol (Handle, &gEfiBlockIoProtocolGuid, (VOID **) &BlockIo);
- if (!EFI_ERROR (Status)) {
- Description = BlockIo->Media->RemovableMedia ? L"Removable Disk" : L"Hard Drive";
- } else {
- Description = L"Misc Device";
- }
- break;
+ case BmHardwareDeviceBoot:
+ Status = gBS->HandleProtocol (Handle, &gEfiBlockIoProtocolGuid, (VOID **)&BlockIo);
+ if (!EFI_ERROR (Status)) {
+ Description = BlockIo->Media->RemovableMedia ? L"Removable Disk" : L"Hard Drive";
+ } else {
+ Description = L"Misc Device";
+ }
- default:
- Status = gBS->HandleProtocol (Handle, &gEfiSimpleFileSystemProtocolGuid, (VOID **) &Fs);
- if (!EFI_ERROR (Status)) {
- Description = L"Non-Block Boot Device";
- } else {
- Description = L"Misc Device";
- }
- break;
+ break;
+
+ default:
+ Status = gBS->HandleProtocol (Handle, &gEfiSimpleFileSystemProtocolGuid, (VOID **)&Fs);
+ if (!EFI_ERROR (Status)) {
+ Description = L"Non-Block Boot Device";
+ } else {
+ Description = L"Misc Device";
+ }
+
+ break;
}
return AllocateCopyPool (StrSize (Description), Description);
@@ -722,13 +751,14 @@ EfiBootManagerRegisterBootDescriptionHandler ( IN EFI_BOOT_MANAGER_BOOT_DESCRIPTION_HANDLER Handler
)
{
- LIST_ENTRY *Link;
- BM_BOOT_DESCRIPTION_ENTRY *Entry;
+ LIST_ENTRY *Link;
+ BM_BOOT_DESCRIPTION_ENTRY *Entry;
for ( Link = GetFirstNode (&mPlatformBootDescriptionHandlers)
- ; !IsNull (&mPlatformBootDescriptionHandlers, Link)
- ; Link = GetNextNode (&mPlatformBootDescriptionHandlers, Link)
- ) {
+ ; !IsNull (&mPlatformBootDescriptionHandlers, Link)
+ ; Link = GetNextNode (&mPlatformBootDescriptionHandlers, Link)
+ )
+ {
Entry = CR (Link, BM_BOOT_DESCRIPTION_ENTRY, Link, BM_BOOT_DESCRIPTION_ENTRY_SIGNATURE);
if (Entry->Handler == Handler) {
return EFI_ALREADY_STARTED;
@@ -746,7 +776,7 @@ EfiBootManagerRegisterBootDescriptionHandler ( return EFI_SUCCESS;
}
-BM_GET_BOOT_DESCRIPTION mBmBootDescriptionHandlers[] = {
+BM_GET_BOOT_DESCRIPTION mBmBootDescriptionHandlers[] = {
BmGetUsbDescription,
BmGetDescriptionFromDiskInfo,
BmGetNetworkDescription,
@@ -764,22 +794,22 @@ BM_GET_BOOT_DESCRIPTION mBmBootDescriptionHandlers[] = { **/
CHAR16 *
BmGetBootDescription (
- IN EFI_HANDLE Handle
+ IN EFI_HANDLE Handle
)
{
- LIST_ENTRY *Link;
- BM_BOOT_DESCRIPTION_ENTRY *Entry;
- CHAR16 *Description;
- CHAR16 *DefaultDescription;
- CHAR16 *Temp;
- UINTN Index;
+ LIST_ENTRY *Link;
+ BM_BOOT_DESCRIPTION_ENTRY *Entry;
+ CHAR16 *Description;
+ CHAR16 *DefaultDescription;
+ CHAR16 *Temp;
+ UINTN Index;
//
// Firstly get the default boot description
//
DefaultDescription = NULL;
for (Index = 0; Index < ARRAY_SIZE (mBmBootDescriptionHandlers); Index++) {
- DefaultDescription = mBmBootDescriptionHandlers[Index] (Handle);
+ DefaultDescription = mBmBootDescriptionHandlers[Index](Handle);
if (DefaultDescription != NULL) {
//
// Avoid description confusion between UEFI & Legacy boot option by adding "UEFI " prefix
@@ -794,16 +824,18 @@ BmGetBootDescription ( break;
}
}
+
ASSERT (DefaultDescription != NULL);
//
// Secondly query platform for the better boot description
//
for ( Link = GetFirstNode (&mPlatformBootDescriptionHandlers)
- ; !IsNull (&mPlatformBootDescriptionHandlers, Link)
- ; Link = GetNextNode (&mPlatformBootDescriptionHandlers, Link)
- ) {
- Entry = CR (Link, BM_BOOT_DESCRIPTION_ENTRY, Link, BM_BOOT_DESCRIPTION_ENTRY_SIGNATURE);
+ ; !IsNull (&mPlatformBootDescriptionHandlers, Link)
+ ; Link = GetNextNode (&mPlatformBootDescriptionHandlers, Link)
+ )
+ {
+ Entry = CR (Link, BM_BOOT_DESCRIPTION_ENTRY, Link, BM_BOOT_DESCRIPTION_ENTRY_SIGNATURE);
Description = Entry->Handler (Handle, DefaultDescription);
if (Description != NULL) {
FreePool (DefaultDescription);
@@ -823,16 +855,16 @@ BmGetBootDescription ( **/
VOID
BmMakeBootOptionDescriptionUnique (
- EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions,
- UINTN BootOptionCount
+ EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions,
+ UINTN BootOptionCount
)
{
- UINTN Base;
- UINTN Index;
- UINTN DescriptionSize;
- UINTN MaxSuffixSize;
- BOOLEAN *Visited;
- UINTN MatchCount;
+ UINTN Base;
+ UINTN Index;
+ UINTN DescriptionSize;
+ UINTN MaxSuffixSize;
+ BOOLEAN *Visited;
+ UINTN MatchCount;
if (BootOptionCount == 0) {
return;
@@ -856,15 +888,17 @@ BmMakeBootOptionDescriptionUnique ( Visited[Base] = TRUE;
DescriptionSize = StrSize (BootOptions[Base].Description);
for (Index = Base + 1; Index < BootOptionCount; Index++) {
- if (!Visited[Index] && StrCmp (BootOptions[Base].Description, BootOptions[Index].Description) == 0) {
+ if (!Visited[Index] && (StrCmp (BootOptions[Base].Description, BootOptions[Index].Description) == 0)) {
Visited[Index] = TRUE;
MatchCount++;
FreePool (BootOptions[Index].Description);
BootOptions[Index].Description = AllocatePool (DescriptionSize + MaxSuffixSize);
UnicodeSPrint (
- BootOptions[Index].Description, DescriptionSize + MaxSuffixSize,
+ BootOptions[Index].Description,
+ DescriptionSize + MaxSuffixSize,
L"%s %d",
- BootOptions[Base].Description, MatchCount
+ BootOptions[Base].Description,
+ MatchCount
);
}
}
diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmConnect.c b/MdeModulePkg/Library/UefiBootManagerLib/BmConnect.c index d4a263b8fe..d1fb0f72ba 100644 --- a/MdeModulePkg/Library/UefiBootManagerLib/BmConnect.c +++ b/MdeModulePkg/Library/UefiBootManagerLib/BmConnect.c @@ -52,7 +52,6 @@ BmConnectAllDriversToAllControllers ( // the connect again.
//
Status = gDS->Dispatch ();
-
} while (!EFI_ERROR (Status));
}
@@ -154,7 +153,6 @@ EfiBootManagerConnectDevicePath ( }
}
-
if (!EFI_ERROR (Status)) {
PreviousHandle = Handle;
//
@@ -175,11 +173,13 @@ EfiBootManagerConnectDevicePath ( if (Status == EFI_NOT_FOUND) {
Status = EFI_SUCCESS;
}
+
if (MatchingHandle != NULL) {
*MatchingHandle = Handle;
}
}
}
+
//
// Loop until RemainingDevicePath is an empty device path
//
@@ -243,16 +243,16 @@ EfiBootManagerDisconnectAll ( **/
EFI_STATUS
BmConnectUsbShortFormDevicePath (
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
)
{
- EFI_STATUS Status;
- EFI_HANDLE *Handles;
- UINTN HandleCount;
- UINTN Index;
- EFI_PCI_IO_PROTOCOL *PciIo;
- UINT8 Class[3];
- BOOLEAN AtLeastOneConnected;
+ EFI_STATUS Status;
+ EFI_HANDLE *Handles;
+ UINTN HandleCount;
+ UINTN Index;
+ EFI_PCI_IO_PROTOCOL *PciIo;
+ UINT8 Class[3];
+ BOOLEAN AtLeastOneConnected;
//
// Check the passed in parameters
@@ -263,7 +263,8 @@ BmConnectUsbShortFormDevicePath ( if ((DevicePathType (DevicePath) != MESSAGING_DEVICE_PATH) ||
((DevicePathSubType (DevicePath) != MSG_USB_CLASS_DP) && (DevicePathSubType (DevicePath) != MSG_USB_WWID_DP))
- ) {
+ )
+ {
return EFI_INVALID_PARAMETER;
}
@@ -271,19 +272,19 @@ BmConnectUsbShortFormDevicePath ( // Find the usb host controller firstly, then connect with the remaining device path
//
AtLeastOneConnected = FALSE;
- Status = gBS->LocateHandleBuffer (
- ByProtocol,
- &gEfiPciIoProtocolGuid,
- NULL,
- &HandleCount,
- &Handles
- );
+ Status = gBS->LocateHandleBuffer (
+ ByProtocol,
+ &gEfiPciIoProtocolGuid,
+ NULL,
+ &HandleCount,
+ &Handles
+ );
if (!EFI_ERROR (Status)) {
for (Index = 0; Index < HandleCount; Index++) {
Status = gBS->HandleProtocol (
Handles[Index],
&gEfiPciIoProtocolGuid,
- (VOID **) &PciIo
+ (VOID **)&PciIo
);
if (!EFI_ERROR (Status)) {
//
@@ -292,14 +293,15 @@ BmConnectUsbShortFormDevicePath ( Status = PciIo->Pci.Read (PciIo, EfiPciIoWidthUint8, 0x09, 3, &Class);
if (!EFI_ERROR (Status) &&
((PCI_CLASS_SERIAL == Class[2]) && (PCI_CLASS_SERIAL_USB == Class[1]))
- ) {
+ )
+ {
Status = gBS->ConnectController (
Handles[Index],
NULL,
DevicePath,
FALSE
);
- if (!EFI_ERROR(Status)) {
+ if (!EFI_ERROR (Status)) {
AtLeastOneConnected = TRUE;
}
}
diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmConsole.c b/MdeModulePkg/Library/UefiBootManagerLib/BmConsole.c index bdbb9a8770..60e7b1099a 100644 --- a/MdeModulePkg/Library/UefiBootManagerLib/BmConsole.c +++ b/MdeModulePkg/Library/UefiBootManagerLib/BmConsole.c @@ -9,7 +9,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include "InternalBm.h"
-CHAR16 *mConVarName[] = {
+CHAR16 *mConVarName[] = {
L"ConIn",
L"ConOut",
L"ErrOut",
@@ -28,16 +28,16 @@ BmGetVideoController ( VOID
)
{
- EFI_STATUS Status;
- UINTN RootBridgeHandleCount;
- EFI_HANDLE *RootBridgeHandleBuffer;
- UINTN HandleCount;
- EFI_HANDLE *HandleBuffer;
- UINTN RootBridgeIndex;
- UINTN Index;
- EFI_HANDLE VideoController;
- EFI_PCI_IO_PROTOCOL *PciIo;
- PCI_TYPE00 Pci;
+ EFI_STATUS Status;
+ UINTN RootBridgeHandleCount;
+ EFI_HANDLE *RootBridgeHandleBuffer;
+ UINTN HandleCount;
+ EFI_HANDLE *HandleBuffer;
+ UINTN RootBridgeIndex;
+ UINTN Index;
+ EFI_HANDLE VideoController;
+ EFI_PCI_IO_PROTOCOL *PciIo;
+ PCI_TYPE00 Pci;
//
// Make all the PCI_IO protocols show up
@@ -72,18 +72,18 @@ BmGetVideoController ( }
for (Index = 0; Index < HandleCount; Index++) {
- Status = gBS->HandleProtocol (HandleBuffer[Index], &gEfiPciIoProtocolGuid, (VOID **) &PciIo);
+ Status = gBS->HandleProtocol (HandleBuffer[Index], &gEfiPciIoProtocolGuid, (VOID **)&PciIo);
if (!EFI_ERROR (Status)) {
//
// Check for all video controller
//
Status = PciIo->Pci.Read (
- PciIo,
- EfiPciIoWidthUint32,
- 0,
- sizeof (Pci) / sizeof (UINT32),
- &Pci
- );
+ PciIo,
+ EfiPciIoWidthUint32,
+ 0,
+ sizeof (Pci) / sizeof (UINT32),
+ &Pci
+ );
if (!EFI_ERROR (Status) && IS_PCI_VGA (&Pci)) {
// TODO: use IS_PCI_DISPLAY??
VideoController = HandleBuffer[Index];
@@ -91,12 +91,14 @@ BmGetVideoController ( }
}
}
+
FreePool (HandleBuffer);
if (VideoController != NULL) {
break;
}
}
+
FreePool (RootBridgeHandleBuffer);
return VideoController;
@@ -113,7 +115,7 @@ BmGetVideoController ( EFI_DEVICE_PATH_PROTOCOL *
EFIAPI
EfiBootManagerGetGopDevicePath (
- IN EFI_HANDLE VideoController
+ IN EFI_HANDLE VideoController
)
{
UINTN Index;
@@ -130,7 +132,6 @@ EfiBootManagerGetGopDevicePath ( EFI_DEVICE_PATH_PROTOCOL *GopPool;
EFI_DEVICE_PATH_PROTOCOL *ReturnDevicePath;
-
Status = gBS->ProtocolsPerHandle (
VideoController,
&ProtocolBuffer,
@@ -161,7 +162,7 @@ EfiBootManagerGetGopDevicePath ( Status = gBS->OpenProtocol (
OpenInfoBuffer[Index].ControllerHandle,
&gEfiDevicePathProtocolGuid,
- (VOID **) &DevicePath,
+ (VOID **)&DevicePath,
NULL,
NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -174,9 +175,10 @@ EfiBootManagerGetGopDevicePath ( for (Next = DevicePath; !IsDevicePathEnd (Next); Next = NextDevicePathNode (Next)) {
Previous = Next;
}
+
ASSERT (Previous != NULL);
- if (DevicePathType (Previous) == ACPI_DEVICE_PATH && DevicePathSubType (Previous) == ACPI_ADR_DP) {
+ if ((DevicePathType (Previous) == ACPI_DEVICE_PATH) && (DevicePathSubType (Previous) == ACPI_ADR_DP)) {
Status = gBS->OpenProtocol (
OpenInfoBuffer[Index].ControllerHandle,
&gEfiGraphicsOutputProtocolGuid,
@@ -190,19 +192,19 @@ EfiBootManagerGetGopDevicePath ( // Append the device path to GOP pool when there is GOP protocol installed.
//
TempDevicePath = GopPool;
- GopPool = AppendDevicePathInstance (GopPool, DevicePath);
+ GopPool = AppendDevicePathInstance (GopPool, DevicePath);
gBS->FreePool (TempDevicePath);
}
}
- if (DevicePathType (Previous) == HARDWARE_DEVICE_PATH && DevicePathSubType (Previous) == HW_CONTROLLER_DP) {
+ if ((DevicePathType (Previous) == HARDWARE_DEVICE_PATH) && (DevicePathSubType (Previous) == HW_CONTROLLER_DP)) {
//
// Recursively look for GOP child in this frame buffer handle
//
DEBUG ((DEBUG_INFO, "[Bds] Looking for GOP child deeper ... \n"));
- TempDevicePath = GopPool;
+ TempDevicePath = GopPool;
ReturnDevicePath = EfiBootManagerGetGopDevicePath (OpenInfoBuffer[Index].ControllerHandle);
- GopPool = AppendDevicePathInstance (GopPool, ReturnDevicePath);
+ GopPool = AppendDevicePathInstance (GopPool, ReturnDevicePath);
gBS->FreePool (ReturnDevicePath);
gBS->FreePool (TempDevicePath);
}
@@ -228,10 +230,10 @@ EfiBootManagerGetGopDevicePath ( EFI_STATUS
EFIAPI
EfiBootManagerConnectVideoController (
- EFI_HANDLE VideoController OPTIONAL
+ EFI_HANDLE VideoController OPTIONAL
)
{
- EFI_DEVICE_PATH_PROTOCOL *Gop;
+ EFI_DEVICE_PATH_PROTOCOL *Gop;
if (VideoController == NULL) {
//
@@ -285,21 +287,21 @@ EfiBootManagerConnectVideoController ( **/
BOOLEAN
BmUpdateSystemTableConsole (
- IN CHAR16 *VarName,
- IN EFI_GUID *ConsoleGuid,
- IN OUT EFI_HANDLE *ConsoleHandle,
- IN OUT VOID **ProtocolInterface
+ IN CHAR16 *VarName,
+ IN EFI_GUID *ConsoleGuid,
+ IN OUT EFI_HANDLE *ConsoleHandle,
+ IN OUT VOID **ProtocolInterface
)
{
- EFI_STATUS Status;
- UINTN DevicePathSize;
- EFI_DEVICE_PATH_PROTOCOL *FullDevicePath;
- EFI_DEVICE_PATH_PROTOCOL *VarConsole;
- EFI_DEVICE_PATH_PROTOCOL *Instance;
- EFI_DEVICE_PATH_PROTOCOL *FullInstance;
- VOID *Interface;
- EFI_HANDLE NewHandle;
- EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *TextOut;
+ EFI_STATUS Status;
+ UINTN DevicePathSize;
+ EFI_DEVICE_PATH_PROTOCOL *FullDevicePath;
+ EFI_DEVICE_PATH_PROTOCOL *VarConsole;
+ EFI_DEVICE_PATH_PROTOCOL *Instance;
+ EFI_DEVICE_PATH_PROTOCOL *FullInstance;
+ VOID *Interface;
+ EFI_HANDLE NewHandle;
+ EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *TextOut;
ASSERT (VarName != NULL);
ASSERT (ConsoleHandle != NULL);
@@ -308,11 +310,11 @@ BmUpdateSystemTableConsole ( if (*ConsoleHandle != NULL) {
Status = gBS->HandleProtocol (
- *ConsoleHandle,
- ConsoleGuid,
- &Interface
- );
- if (Status == EFI_SUCCESS && Interface == *ProtocolInterface) {
+ *ConsoleHandle,
+ ConsoleGuid,
+ &Interface
+ );
+ if ((Status == EFI_SUCCESS) && (Interface == *ProtocolInterface)) {
//
// If ConsoleHandle is valid and console protocol on this handle also
// also matched, just return.
@@ -324,7 +326,7 @@ BmUpdateSystemTableConsole ( //
// Get all possible consoles device path from EFI variable
//
- GetEfiGlobalVariable2 (VarName, (VOID **) &VarConsole, NULL);
+ GetEfiGlobalVariable2 (VarName, (VOID **)&VarConsole, NULL);
if (VarConsole == NULL) {
//
// If there is no any console device, just return.
@@ -338,7 +340,7 @@ BmUpdateSystemTableConsole ( //
// Check every instance of the console variable
//
- Instance = GetNextDevicePathInstance (&VarConsole, &DevicePathSize);
+ Instance = GetNextDevicePathInstance (&VarConsole, &DevicePathSize);
if (Instance == NULL) {
DEBUG ((DEBUG_ERROR, "[Bds] No valid console instance is found for %s!\n", VarName));
// We should not ASSERT when all the console devices are removed.
@@ -351,11 +353,11 @@ BmUpdateSystemTableConsole ( // Find console device handle by device path instance
//
FullInstance = Instance;
- Status = gBS->LocateDevicePath (
- ConsoleGuid,
- &Instance,
- &NewHandle
- );
+ Status = gBS->LocateDevicePath (
+ ConsoleGuid,
+ &Instance,
+ &NewHandle
+ );
FreePool (FullInstance);
if (!EFI_ERROR (Status)) {
//
@@ -376,16 +378,16 @@ BmUpdateSystemTableConsole ( //
// If it is console out device, set console mode 80x25 if current mode is invalid.
//
- TextOut = (EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *) Interface;
+ TextOut = (EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *)Interface;
if (TextOut->Mode->Mode == -1) {
TextOut->SetMode (TextOut, 0);
}
}
+
FreePool (FullDevicePath);
return TRUE;
}
}
-
} while (Instance != NULL);
//
@@ -435,10 +437,11 @@ EfiBootManagerUpdateConsoleVariable ( if (CustomizedConDevicePath == ExclusiveDevicePath) {
return EFI_UNSUPPORTED;
}
+
//
// Delete the ExclusiveDevicePath from current default console
//
- GetEfiGlobalVariable2 (mConVarName[ConsoleType], (VOID **) &VarConsole, NULL);
+ GetEfiGlobalVariable2 (mConVarName[ConsoleType], (VOID **)&VarConsole, NULL);
//
// Initialize NewDevicePath
//
@@ -448,9 +451,10 @@ EfiBootManagerUpdateConsoleVariable ( // If ExclusiveDevicePath is even the part of the instance in VarConsole, delete it.
// In the end, NewDevicePath is the final device path.
//
- if (ExclusiveDevicePath != NULL && VarConsole != NULL) {
- NewDevicePath = BmDelPartMatchInstance (VarConsole, ExclusiveDevicePath);
+ if ((ExclusiveDevicePath != NULL) && (VarConsole != NULL)) {
+ NewDevicePath = BmDelPartMatchInstance (VarConsole, ExclusiveDevicePath);
}
+
//
// Try to append customized device path to NewDevicePath.
//
@@ -465,9 +469,9 @@ EfiBootManagerUpdateConsoleVariable ( // just append current customized device path
//
TempNewDevicePath = NewDevicePath;
- NewDevicePath = AppendDevicePathInstance (NewDevicePath, CustomizedConDevicePath);
+ NewDevicePath = AppendDevicePathInstance (NewDevicePath, CustomizedConDevicePath);
if (TempNewDevicePath != NULL) {
- FreePool(TempNewDevicePath);
+ FreePool (TempNewDevicePath);
}
}
}
@@ -479,28 +483,28 @@ EfiBootManagerUpdateConsoleVariable ( mConVarName[ConsoleType],
&gEfiGlobalVariableGuid,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS
- | ((ConsoleType < ConInDev) ? EFI_VARIABLE_NON_VOLATILE : 0),
+ | ((ConsoleType < ConInDev) ? EFI_VARIABLE_NON_VOLATILE : 0),
GetDevicePathSize (NewDevicePath),
NewDevicePath
);
if (VarConsole == NewDevicePath) {
if (VarConsole != NULL) {
- FreePool(VarConsole);
+ FreePool (VarConsole);
}
} else {
if (VarConsole != NULL) {
- FreePool(VarConsole);
+ FreePool (VarConsole);
}
+
if (NewDevicePath != NULL) {
- FreePool(NewDevicePath);
+ FreePool (NewDevicePath);
}
}
return Status;
}
-
/**
Connect the console device base on the variable ConsoleType.
@@ -515,7 +519,7 @@ EfiBootManagerUpdateConsoleVariable ( EFI_STATUS
EFIAPI
EfiBootManagerConnectConsoleVariable (
- IN CONSOLE_TYPE ConsoleType
+ IN CONSOLE_TYPE ConsoleType
)
{
EFI_STATUS Status;
@@ -538,7 +542,7 @@ EfiBootManagerConnectConsoleVariable ( //
// Check if the console variable exist
//
- GetEfiGlobalVariable2 (mConVarName[ConsoleType], (VOID **) &StartDevicePath, NULL);
+ GetEfiGlobalVariable2 (mConVarName[ConsoleType], (VOID **)&StartDevicePath, NULL);
if (StartDevicePath == NULL) {
return EFI_UNSUPPORTED;
}
@@ -548,13 +552,13 @@ EfiBootManagerConnectConsoleVariable ( //
// Check every instance of the console variable
//
- Instance = GetNextDevicePathInstance (&CopyOfDevicePath, &Size);
+ Instance = GetNextDevicePathInstance (&CopyOfDevicePath, &Size);
if (Instance == NULL) {
FreePool (StartDevicePath);
return EFI_UNSUPPORTED;
}
- Next = Instance;
+ Next = Instance;
while (!IsDevicePathEndType (Next)) {
Next = NextDevicePathNode (Next);
}
@@ -568,23 +572,26 @@ EfiBootManagerConnectConsoleVariable ( //
if ((DevicePathType (Instance) == MESSAGING_DEVICE_PATH) &&
((DevicePathSubType (Instance) == MSG_USB_CLASS_DP) || (DevicePathSubType (Instance) == MSG_USB_WWID_DP))
- ) {
+ )
+ {
Status = BmConnectUsbShortFormDevicePath (Instance);
if (!EFI_ERROR (Status)) {
DeviceExist = TRUE;
}
} else {
for (Next = Instance; !IsDevicePathEnd (Next); Next = NextDevicePathNode (Next)) {
- if (DevicePathType (Next) == ACPI_DEVICE_PATH && DevicePathSubType (Next) == ACPI_ADR_DP) {
+ if ((DevicePathType (Next) == ACPI_DEVICE_PATH) && (DevicePathSubType (Next) == ACPI_ADR_DP)) {
break;
- } else if (DevicePathType (Next) == HARDWARE_DEVICE_PATH &&
- DevicePathSubType (Next) == HW_CONTROLLER_DP &&
- DevicePathType (NextDevicePathNode (Next)) == ACPI_DEVICE_PATH &&
- DevicePathSubType (NextDevicePathNode (Next)) == ACPI_ADR_DP
- ) {
+ } else if ((DevicePathType (Next) == HARDWARE_DEVICE_PATH) &&
+ (DevicePathSubType (Next) == HW_CONTROLLER_DP) &&
+ (DevicePathType (NextDevicePathNode (Next)) == ACPI_DEVICE_PATH) &&
+ (DevicePathSubType (NextDevicePathNode (Next)) == ACPI_ADR_DP)
+ )
+ {
break;
}
}
+
if (!IsDevicePathEnd (Next)) {
//
// For GOP device path, start the video driver with NULL remaining device path
@@ -597,6 +604,7 @@ EfiBootManagerConnectConsoleVariable ( } else {
Status = EfiBootManagerConnectDevicePath (Instance, NULL);
}
+
if (EFI_ERROR (Status)) {
//
// Delete the instance from the console varialbe
@@ -606,7 +614,8 @@ EfiBootManagerConnectConsoleVariable ( DeviceExist = TRUE;
}
}
- FreePool(Instance);
+
+ FreePool (Instance);
} while (CopyOfDevicePath != NULL);
FreePool (StartDevicePath);
@@ -618,7 +627,6 @@ EfiBootManagerConnectConsoleVariable ( return EFI_SUCCESS;
}
-
/**
This function will search every input/output device in current system,
and make every input/output device as potential console device.
@@ -643,46 +651,46 @@ EfiBootManagerConnectAllConsoles ( // Update all the console variables
//
gBS->LocateHandleBuffer (
- ByProtocol,
- &gEfiSimpleTextInProtocolGuid,
- NULL,
- &HandleCount,
- &HandleBuffer
- );
+ ByProtocol,
+ &gEfiSimpleTextInProtocolGuid,
+ NULL,
+ &HandleCount,
+ &HandleBuffer
+ );
for (Index = 0; Index < HandleCount; Index++) {
gBS->HandleProtocol (
- HandleBuffer[Index],
- &gEfiDevicePathProtocolGuid,
- (VOID **) &ConDevicePath
- );
+ HandleBuffer[Index],
+ &gEfiDevicePathProtocolGuid,
+ (VOID **)&ConDevicePath
+ );
EfiBootManagerUpdateConsoleVariable (ConIn, ConDevicePath, NULL);
}
if (HandleBuffer != NULL) {
- FreePool(HandleBuffer);
+ FreePool (HandleBuffer);
HandleBuffer = NULL;
}
gBS->LocateHandleBuffer (
- ByProtocol,
- &gEfiSimpleTextOutProtocolGuid,
- NULL,
- &HandleCount,
- &HandleBuffer
- );
+ ByProtocol,
+ &gEfiSimpleTextOutProtocolGuid,
+ NULL,
+ &HandleCount,
+ &HandleBuffer
+ );
for (Index = 0; Index < HandleCount; Index++) {
gBS->HandleProtocol (
- HandleBuffer[Index],
- &gEfiDevicePathProtocolGuid,
- (VOID **) &ConDevicePath
- );
+ HandleBuffer[Index],
+ &gEfiDevicePathProtocolGuid,
+ (VOID **)&ConDevicePath
+ );
EfiBootManagerUpdateConsoleVariable (ConOut, ConDevicePath, NULL);
EfiBootManagerUpdateConsoleVariable (ErrOut, ConDevicePath, NULL);
}
if (HandleBuffer != NULL) {
- FreePool(HandleBuffer);
+ FreePool (HandleBuffer);
}
//
@@ -691,7 +699,6 @@ EfiBootManagerConnectAllConsoles ( EfiBootManagerConnectAllDefaultConsoles ();
}
-
/**
This function will connect all the console devices base on the console
device variable ConIn, ConOut and ErrOut.
@@ -706,9 +713,9 @@ EfiBootManagerConnectAllDefaultConsoles ( VOID
)
{
- EFI_STATUS Status;
- BOOLEAN OneConnected;
- BOOLEAN SystemTableUpdated;
+ EFI_STATUS Status;
+ BOOLEAN OneConnected;
+ BOOLEAN SystemTableUpdated;
OneConnected = FALSE;
@@ -716,32 +723,36 @@ EfiBootManagerConnectAllDefaultConsoles ( if (!EFI_ERROR (Status)) {
OneConnected = TRUE;
}
- PERF_EVENT ("ConOutReady");
+ PERF_EVENT ("ConOutReady");
Status = EfiBootManagerConnectConsoleVariable (ConIn);
if (!EFI_ERROR (Status)) {
OneConnected = TRUE;
}
+
PERF_EVENT ("ConInReady");
Status = EfiBootManagerConnectConsoleVariable (ErrOut);
if (!EFI_ERROR (Status)) {
OneConnected = TRUE;
}
+
PERF_EVENT ("ErrOutReady");
SystemTableUpdated = FALSE;
//
// Fill console handles in System Table if no console device assignd.
//
- if (BmUpdateSystemTableConsole (L"ConIn", &gEfiSimpleTextInProtocolGuid, &gST->ConsoleInHandle, (VOID **) &gST->ConIn)) {
+ if (BmUpdateSystemTableConsole (L"ConIn", &gEfiSimpleTextInProtocolGuid, &gST->ConsoleInHandle, (VOID **)&gST->ConIn)) {
SystemTableUpdated = TRUE;
}
- if (BmUpdateSystemTableConsole (L"ConOut", &gEfiSimpleTextOutProtocolGuid, &gST->ConsoleOutHandle, (VOID **) &gST->ConOut)) {
+
+ if (BmUpdateSystemTableConsole (L"ConOut", &gEfiSimpleTextOutProtocolGuid, &gST->ConsoleOutHandle, (VOID **)&gST->ConOut)) {
SystemTableUpdated = TRUE;
}
- if (BmUpdateSystemTableConsole (L"ErrOut", &gEfiSimpleTextOutProtocolGuid, &gST->StandardErrorHandle, (VOID **) &gST->StdErr)) {
+
+ if (BmUpdateSystemTableConsole (L"ErrOut", &gEfiSimpleTextOutProtocolGuid, &gST->StandardErrorHandle, (VOID **)&gST->StdErr)) {
SystemTableUpdated = TRUE;
}
@@ -751,10 +762,10 @@ EfiBootManagerConnectAllDefaultConsoles ( //
gST->Hdr.CRC32 = 0;
gBS->CalculateCrc32 (
- (UINT8 *) &gST->Hdr,
- gST->Hdr.HeaderSize,
- &gST->Hdr.CRC32
- );
+ (UINT8 *)&gST->Hdr,
+ gST->Hdr.HeaderSize,
+ &gST->Hdr.CRC32
+ );
}
return OneConnected ? EFI_SUCCESS : EFI_DEVICE_ERROR;
diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmDriverHealth.c b/MdeModulePkg/Library/UefiBootManagerLib/BmDriverHealth.c index eacd45439b..46a2fa2016 100644 --- a/MdeModulePkg/Library/UefiBootManagerLib/BmDriverHealth.c +++ b/MdeModulePkg/Library/UefiBootManagerLib/BmDriverHealth.c @@ -11,14 +11,14 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include "InternalBm.h"
GLOBAL_REMOVE_IF_UNREFERENCED
- CHAR16 *mBmHealthStatusText[] = {
- L"Healthy",
- L"Repair Required",
- L"Configuration Required",
- L"Failed",
- L"Reconnect Required",
- L"Reboot Required"
- };
+CHAR16 *mBmHealthStatusText[] = {
+ L"Healthy",
+ L"Repair Required",
+ L"Configuration Required",
+ L"Failed",
+ L"Reconnect Required",
+ L"Reboot Required"
+};
/**
Return the controller name.
@@ -37,17 +37,17 @@ GLOBAL_REMOVE_IF_UNREFERENCED **/
CHAR16 *
BmGetControllerName (
- IN EFI_HANDLE DriverHealthHandle,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle
+ IN EFI_HANDLE DriverHealthHandle,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle
)
{
- EFI_STATUS Status;
- CHAR16 *ControllerName;
- CHAR8 *LanguageVariable;
- CHAR8 *BestLanguage;
- BOOLEAN Iso639Language;
- EFI_COMPONENT_NAME_PROTOCOL *ComponentName;
+ EFI_STATUS Status;
+ CHAR16 *ControllerName;
+ CHAR8 *LanguageVariable;
+ CHAR8 *BestLanguage;
+ BOOLEAN Iso639Language;
+ EFI_COMPONENT_NAME_PROTOCOL *ComponentName;
ControllerName = NULL;
@@ -55,16 +55,16 @@ BmGetControllerName ( // Locate Component Name (2) protocol on the driver binging handle.
//
Iso639Language = FALSE;
- Status = gBS->HandleProtocol (
- DriverHealthHandle,
- &gEfiComponentName2ProtocolGuid,
- (VOID **) &ComponentName
- );
+ Status = gBS->HandleProtocol (
+ DriverHealthHandle,
+ &gEfiComponentName2ProtocolGuid,
+ (VOID **)&ComponentName
+ );
if (EFI_ERROR (Status)) {
Status = gBS->HandleProtocol (
DriverHealthHandle,
&gEfiComponentNameProtocolGuid,
- (VOID **) &ComponentName
+ (VOID **)&ComponentName
);
if (!EFI_ERROR (Status)) {
Iso639Language = TRUE;
@@ -72,14 +72,14 @@ BmGetControllerName ( }
if (!EFI_ERROR (Status)) {
- GetEfiGlobalVariable2 (Iso639Language ? L"Lang" : L"PlatformLang", (VOID**)&LanguageVariable, NULL);
- BestLanguage = GetBestLanguage(
- ComponentName->SupportedLanguages,
- Iso639Language,
- (LanguageVariable != NULL) ? LanguageVariable : "",
- Iso639Language ? "eng" : "en-US",
- NULL
- );
+ GetEfiGlobalVariable2 (Iso639Language ? L"Lang" : L"PlatformLang", (VOID **)&LanguageVariable, NULL);
+ BestLanguage = GetBestLanguage (
+ ComponentName->SupportedLanguages,
+ Iso639Language,
+ (LanguageVariable != NULL) ? LanguageVariable : "",
+ Iso639Language ? "eng" : "en-US",
+ NULL
+ );
if (LanguageVariable != NULL) {
FreePool (LanguageVariable);
}
@@ -111,15 +111,16 @@ BmGetControllerName ( **/
VOID
BmDisplayMessages (
- IN EFI_BOOT_MANAGER_DRIVER_HEALTH_INFO *DriverHealthInfo
+ IN EFI_BOOT_MANAGER_DRIVER_HEALTH_INFO *DriverHealthInfo
)
{
- UINTN Index;
- EFI_STRING String;
- CHAR16 *ControllerName;
+ UINTN Index;
+ EFI_STRING String;
+ CHAR16 *ControllerName;
- if (DriverHealthInfo->MessageList == NULL ||
- DriverHealthInfo->MessageList[0].HiiHandle == NULL) {
+ if ((DriverHealthInfo->MessageList == NULL) ||
+ (DriverHealthInfo->MessageList[0].HiiHandle == NULL))
+ {
return;
}
@@ -163,8 +164,8 @@ BmDisplayMessages ( EFI_STATUS
EFIAPI
BmRepairNotify (
- IN UINTN Value,
- IN UINTN Limit
+ IN UINTN Value,
+ IN UINTN Limit
)
{
DEBUG ((DEBUG_INFO, "[BDS]RepairNotify: %d/%d\n", Value, Limit));
@@ -189,11 +190,11 @@ BmRepairNotify ( **/
EFI_STATUS
BmGetSingleControllerHealthStatus (
- IN OUT EFI_BOOT_MANAGER_DRIVER_HEALTH_INFO **DriverHealthInfo,
- IN OUT UINTN *Count,
- IN EFI_HANDLE DriverHealthHandle,
- IN EFI_HANDLE ControllerHandle OPTIONAL,
- IN EFI_HANDLE ChildHandle OPTIONAL
+ IN OUT EFI_BOOT_MANAGER_DRIVER_HEALTH_INFO **DriverHealthInfo,
+ IN OUT UINTN *Count,
+ IN EFI_HANDLE DriverHealthHandle,
+ IN EFI_HANDLE ControllerHandle OPTIONAL,
+ IN EFI_HANDLE ChildHandle OPTIONAL
)
{
EFI_STATUS Status;
@@ -209,17 +210,16 @@ BmGetSingleControllerHealthStatus ( Status = gBS->HandleProtocol (
DriverHealthHandle,
&gEfiDriverHealthProtocolGuid,
- (VOID **) &DriverHealth
+ (VOID **)&DriverHealth
);
ASSERT_EFI_ERROR (Status);
-
if (ControllerHandle == NULL) {
//
// If ControllerHandle is NULL, the return the cumulative health status of the driver
//
Status = DriverHealth->GetHealthStatus (DriverHealth, NULL, NULL, &HealthStatus, NULL, NULL);
- if (!EFI_ERROR (Status) && HealthStatus == EfiDriverHealthStatusHealthy) {
+ if (!EFI_ERROR (Status) && (HealthStatus == EfiDriverHealthStatusHealthy)) {
*DriverHealthInfo = ReallocatePool (
(*Count) * sizeof (EFI_BOOT_MANAGER_DRIVER_HEALTH_INFO),
(*Count + 1) * sizeof (EFI_BOOT_MANAGER_DRIVER_HEALTH_INFO),
@@ -235,6 +235,7 @@ BmGetSingleControllerHealthStatus ( Status = EFI_ABORTED;
}
+
return Status;
}
@@ -285,28 +286,28 @@ BmGetSingleControllerHealthStatus ( EFI_BOOT_MANAGER_DRIVER_HEALTH_INFO *
EFIAPI
EfiBootManagerGetDriverHealthInfo (
- UINTN *Count
+ UINTN *Count
)
{
- EFI_STATUS Status;
- UINTN NumHandles;
- EFI_HANDLE *DriverHealthHandles;
- UINTN DriverHealthIndex;
- EFI_HANDLE *Handles;
- UINTN HandleCount;
- UINTN ControllerIndex;
- UINTN ChildIndex;
+ EFI_STATUS Status;
+ UINTN NumHandles;
+ EFI_HANDLE *DriverHealthHandles;
+ UINTN DriverHealthIndex;
+ EFI_HANDLE *Handles;
+ UINTN HandleCount;
+ UINTN ControllerIndex;
+ UINTN ChildIndex;
EFI_BOOT_MANAGER_DRIVER_HEALTH_INFO *DriverHealthInfo;
//
// Initialize local variables
//
- *Count = 0;
- DriverHealthInfo = NULL;
- Handles = NULL;
- DriverHealthHandles = NULL;
- NumHandles = 0;
- HandleCount = 0;
+ *Count = 0;
+ DriverHealthInfo = NULL;
+ Handles = NULL;
+ DriverHealthHandles = NULL;
+ NumHandles = 0;
+ HandleCount = 0;
Status = gBS->LocateHandleBuffer (
ByProtocol,
@@ -316,7 +317,7 @@ EfiBootManagerGetDriverHealthInfo ( &DriverHealthHandles
);
- if (Status == EFI_NOT_FOUND || NumHandles == 0) {
+ if ((Status == EFI_NOT_FOUND) || (NumHandles == 0)) {
//
// If there are no Driver Health Protocols handles, then return EFI_NOT_FOUND
//
@@ -348,14 +349,15 @@ EfiBootManagerGetDriverHealthInfo ( // Retrieve the list of all handles from the handle database
//
Status = gBS->LocateHandleBuffer (
- AllHandles,
- NULL,
- NULL,
- &HandleCount,
- &Handles
- );
+ AllHandles,
+ NULL,
+ NULL,
+ &HandleCount,
+ &Handles
+ );
ASSERT_EFI_ERROR (Status);
}
+
//
// Loop through all the controller handles in the handle database
//
@@ -382,6 +384,7 @@ EfiBootManagerGetDriverHealthInfo ( if (Handles != NULL) {
FreePool (Handles);
}
+
if (DriverHealthHandles != NULL) {
FreePool (DriverHealthHandles);
}
@@ -401,17 +404,18 @@ EfiBootManagerGetDriverHealthInfo ( EFI_STATUS
EFIAPI
EfiBootManagerFreeDriverHealthInfo (
- EFI_BOOT_MANAGER_DRIVER_HEALTH_INFO *DriverHealthInfo,
- UINTN Count
+ EFI_BOOT_MANAGER_DRIVER_HEALTH_INFO *DriverHealthInfo,
+ UINTN Count
)
{
- UINTN Index;
+ UINTN Index;
for (Index = 0; Index < Count; Index++) {
if (DriverHealthInfo[Index].MessageList != NULL) {
FreePool (DriverHealthInfo[Index].MessageList);
}
}
+
return gBS->FreePool (DriverHealthInfo);
}
@@ -423,22 +427,22 @@ EfiBootManagerFreeDriverHealthInfo ( **/
VOID
BmRepairAllControllers (
- UINTN ReconnectRepairCount
+ UINTN ReconnectRepairCount
)
{
- EFI_STATUS Status;
- EFI_BOOT_MANAGER_DRIVER_HEALTH_INFO *DriverHealthInfo;
- EFI_DRIVER_HEALTH_STATUS HealthStatus;
- UINTN Count;
- UINTN Index;
- BOOLEAN RepairRequired;
- BOOLEAN ConfigurationRequired;
- BOOLEAN ReconnectRequired;
- BOOLEAN RebootRequired;
- EFI_HII_HANDLE *HiiHandles;
- EFI_FORM_BROWSER2_PROTOCOL *FormBrowser2;
- UINT32 MaxRepairCount;
- UINT32 RepairCount;
+ EFI_STATUS Status;
+ EFI_BOOT_MANAGER_DRIVER_HEALTH_INFO *DriverHealthInfo;
+ EFI_DRIVER_HEALTH_STATUS HealthStatus;
+ UINTN Count;
+ UINTN Index;
+ BOOLEAN RepairRequired;
+ BOOLEAN ConfigurationRequired;
+ BOOLEAN ReconnectRequired;
+ BOOLEAN RebootRequired;
+ EFI_HII_HANDLE *HiiHandles;
+ EFI_FORM_BROWSER2_PROTOCOL *FormBrowser2;
+ UINT32 MaxRepairCount;
+ UINT32 RepairCount;
//
// Configure PcdDriverHealthConfigureForm to ZeroGuid to disable driver health check.
@@ -447,11 +451,11 @@ BmRepairAllControllers ( return;
}
- Status = gBS->LocateProtocol (&gEfiFormBrowser2ProtocolGuid, NULL, (VOID **) &FormBrowser2);
+ Status = gBS->LocateProtocol (&gEfiFormBrowser2ProtocolGuid, NULL, (VOID **)&FormBrowser2);
ASSERT_EFI_ERROR (Status);
MaxRepairCount = PcdGet32 (PcdMaxRepairCount);
- RepairCount = 0;
+ RepairCount = 0;
do {
RepairRequired = FALSE;
@@ -467,7 +471,7 @@ BmRepairAllControllers ( }
if (DriverHealthInfo[Index].HealthStatus == EfiDriverHealthStatusRepairRequired) {
- RepairRequired = TRUE;
+ RepairRequired = TRUE;
BmDisplayMessages (&DriverHealthInfo[Index]);
@@ -510,6 +514,7 @@ BmRepairAllControllers ( break;
}
}
+
FreePool (HiiHandles);
}
}
@@ -522,7 +527,6 @@ BmRepairAllControllers ( ReconnectRequired = FALSE;
DriverHealthInfo = EfiBootManagerGetDriverHealthInfo (&Count);
for (Index = 0; Index < Count; Index++) {
-
BmDisplayMessages (&DriverHealthInfo[Index]);
if (DriverHealthInfo[Index].HealthStatus == EfiDriverHealthStatusReconnectRequired) {
@@ -531,7 +535,7 @@ BmRepairAllControllers ( //
// Disconnect failed. Need to promote reconnect to a reboot.
//
- RebootRequired = TRUE;
+ RebootRequired = TRUE;
} else {
gBS->ConnectController (DriverHealthInfo[Index].ControllerHandle, NULL, NULL, TRUE);
ReconnectRequired = TRUE;
@@ -539,42 +543,48 @@ BmRepairAllControllers ( }
if (DriverHealthInfo[Index].HealthStatus == EfiDriverHealthStatusRebootRequired) {
- RebootRequired = TRUE;
+ RebootRequired = TRUE;
}
}
- EfiBootManagerFreeDriverHealthInfo (DriverHealthInfo, Count);
+ EfiBootManagerFreeDriverHealthInfo (DriverHealthInfo, Count);
DEBUG_CODE_BEGIN ();
- CHAR16 *ControllerName;
+ CHAR16 *ControllerName;
- DriverHealthInfo = EfiBootManagerGetDriverHealthInfo (&Count);
- for (Index = 0; Index < Count; Index++) {
- ControllerName = BmGetControllerName (
- DriverHealthInfo[Index].DriverHealthHandle,
- DriverHealthInfo[Index].ControllerHandle,
- DriverHealthInfo[Index].ChildHandle
- );
- DEBUG ((
- DEBUG_INFO,
- "%02d: %s - %s\n",
- Index,
- ControllerName,
- mBmHealthStatusText[DriverHealthInfo[Index].HealthStatus]
- ));
- if (ControllerName != NULL) {
- FreePool (ControllerName);
- }
+ DriverHealthInfo = EfiBootManagerGetDriverHealthInfo (&Count);
+ for (Index = 0; Index < Count; Index++) {
+ ControllerName = BmGetControllerName (
+ DriverHealthInfo[Index].DriverHealthHandle,
+ DriverHealthInfo[Index].ControllerHandle,
+ DriverHealthInfo[Index].ChildHandle
+ );
+ DEBUG ((
+ DEBUG_INFO,
+ "%02d: %s - %s\n",
+ Index,
+ ControllerName,
+ mBmHealthStatusText[DriverHealthInfo[Index].HealthStatus]
+ ));
+ if (ControllerName != NULL) {
+ FreePool (ControllerName);
}
- EfiBootManagerFreeDriverHealthInfo (DriverHealthInfo, Count);
+ }
+
+ EfiBootManagerFreeDriverHealthInfo (DriverHealthInfo, Count);
DEBUG_CODE_END ();
if (ReconnectRequired) {
if (ReconnectRepairCount < MAX_RECONNECT_REPAIR) {
BmRepairAllControllers (ReconnectRepairCount + 1);
} else {
- DEBUG ((DEBUG_ERROR, "[%a:%d] Repair failed after %d retries.\n",
- __FUNCTION__, DEBUG_LINE_NUMBER, ReconnectRepairCount));
+ DEBUG ((
+ DEBUG_ERROR,
+ "[%a:%d] Repair failed after %d retries.\n",
+ __FUNCTION__,
+ DEBUG_LINE_NUMBER,
+ ReconnectRepairCount
+ ));
}
}
diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmHotkey.c b/MdeModulePkg/Library/UefiBootManagerLib/BmHotkey.c index 9dd3c56617..90bee73a23 100644 --- a/MdeModulePkg/Library/UefiBootManagerLib/BmHotkey.c +++ b/MdeModulePkg/Library/UefiBootManagerLib/BmHotkey.c @@ -12,20 +12,19 @@ SPDX-License-Identifier: BSD-2-Clause-Patent //
// Lock for linked list
//
-EFI_LOCK mBmHotkeyLock = EFI_INITIALIZE_LOCK_VARIABLE (TPL_NOTIFY);
-LIST_ENTRY mBmHotkeyList = INITIALIZE_LIST_HEAD_VARIABLE (mBmHotkeyList);
-EFI_EVENT mBmHotkeyTriggered = NULL;
-BOOLEAN mBmHotkeyServiceStarted = FALSE;
-UINTN mBmHotkeySupportCount = 0;
+EFI_LOCK mBmHotkeyLock = EFI_INITIALIZE_LOCK_VARIABLE (TPL_NOTIFY);
+LIST_ENTRY mBmHotkeyList = INITIALIZE_LIST_HEAD_VARIABLE (mBmHotkeyList);
+EFI_EVENT mBmHotkeyTriggered = NULL;
+BOOLEAN mBmHotkeyServiceStarted = FALSE;
+UINTN mBmHotkeySupportCount = 0;
//
// Set OptionNumber as unassigned value to indicate the option isn't initialized
//
-EFI_BOOT_MANAGER_LOAD_OPTION mBmHotkeyBootOption = { LoadOptionNumberUnassigned };
-
-EFI_BOOT_MANAGER_KEY_OPTION *mBmContinueKeyOption = NULL;
-VOID *mBmTxtInExRegistration = NULL;
+EFI_BOOT_MANAGER_LOAD_OPTION mBmHotkeyBootOption = { LoadOptionNumberUnassigned };
+EFI_BOOT_MANAGER_KEY_OPTION *mBmContinueKeyOption = NULL;
+VOID *mBmTxtInExRegistration = NULL;
/**
Return the buffer size of the EFI_BOOT_MANAGER_KEY_OPTION data.
@@ -40,7 +39,7 @@ BmSizeOfKeyOption ( )
{
return OFFSET_OF (EFI_BOOT_MANAGER_KEY_OPTION, Keys)
- + KeyOption->KeyData.Options.InputKeyCount * sizeof (EFI_INPUT_KEY);
+ + KeyOption->KeyData.Options.InputKeyCount * sizeof (EFI_INPUT_KEY);
}
/**
@@ -55,14 +54,14 @@ BmSizeOfKeyOption ( **/
BOOLEAN
BmIsKeyOptionValid (
- IN CONST EFI_BOOT_MANAGER_KEY_OPTION *KeyOption,
- IN UINTN KeyOptionSize
-)
+ IN CONST EFI_BOOT_MANAGER_KEY_OPTION *KeyOption,
+ IN UINTN KeyOptionSize
+ )
{
- UINT16 OptionName[BM_OPTION_NAME_LEN];
- UINT8 *BootOption;
- UINTN BootOptionSize;
- UINT32 Crc;
+ UINT16 OptionName[BM_OPTION_NAME_LEN];
+ UINT8 *BootOption;
+ UINTN BootOptionSize;
+ UINT32 Crc;
if (BmSizeOfKeyOption (KeyOption) != KeyOptionSize) {
return FALSE;
@@ -72,10 +71,13 @@ BmIsKeyOptionValid ( // Check whether corresponding Boot Option exist
//
UnicodeSPrint (
- OptionName, sizeof (OptionName), L"%s%04x",
- mBmLoadOptionName[LoadOptionTypeBoot], KeyOption->BootOption
+ OptionName,
+ sizeof (OptionName),
+ L"%s%04x",
+ mBmLoadOptionName[LoadOptionTypeBoot],
+ KeyOption->BootOption
);
- GetEfiGlobalVariable2 (OptionName, (VOID **) &BootOption, &BootOptionSize);
+ GetEfiGlobalVariable2 (OptionName, (VOID **)&BootOption, &BootOptionSize);
if (BootOption == NULL) {
return FALSE;
@@ -87,7 +89,7 @@ BmIsKeyOptionValid ( gBS->CalculateCrc32 (BootOption, BootOptionSize, &Crc);
FreePool (BootOption);
- return (BOOLEAN) (KeyOption->BootOptionCrc == Crc);
+ return (BOOLEAN)(KeyOption->BootOptionCrc == Crc);
}
/**
@@ -103,18 +105,19 @@ BmIsKeyOptionValid ( **/
BOOLEAN
BmIsKeyOptionVariable (
- CHAR16 *Name,
- EFI_GUID *Guid,
- UINT16 *OptionNumber
+ CHAR16 *Name,
+ EFI_GUID *Guid,
+ UINT16 *OptionNumber
)
{
- UINTN Index;
- UINTN Uint;
+ UINTN Index;
+ UINTN Uint;
if (!CompareGuid (Guid, &gEfiGlobalVariableGuid) ||
(StrSize (Name) != sizeof (L"Key####")) ||
(StrnCmp (Name, L"Key", 3) != 0)
- ) {
+ )
+ {
return FALSE;
}
@@ -124,7 +127,7 @@ BmIsKeyOptionVariable ( if (Uint == -1) {
return FALSE;
} else {
- *OptionNumber = (UINT16) Uint + *OptionNumber * 0x10;
+ *OptionNumber = (UINT16)Uint + *OptionNumber * 0x10;
}
}
@@ -132,8 +135,8 @@ BmIsKeyOptionVariable ( }
typedef struct {
- EFI_BOOT_MANAGER_KEY_OPTION *KeyOptions;
- UINTN KeyOptionCount;
+ EFI_BOOT_MANAGER_KEY_OPTION *KeyOptions;
+ UINTN KeyOptionCount;
} BM_COLLECT_KEY_OPTIONS_PARAM;
/**
@@ -145,18 +148,18 @@ typedef struct { **/
VOID
BmCollectKeyOptions (
- CHAR16 *Name,
- EFI_GUID *Guid,
- VOID *Context
+ CHAR16 *Name,
+ EFI_GUID *Guid,
+ VOID *Context
)
{
- UINTN Index;
- BM_COLLECT_KEY_OPTIONS_PARAM *Param;
- VOID *KeyOption;
- UINT16 OptionNumber;
- UINTN KeyOptionSize;
+ UINTN Index;
+ BM_COLLECT_KEY_OPTIONS_PARAM *Param;
+ VOID *KeyOption;
+ UINT16 OptionNumber;
+ UINTN KeyOptionSize;
- Param = (BM_COLLECT_KEY_OPTIONS_PARAM *) Context;
+ Param = (BM_COLLECT_KEY_OPTIONS_PARAM *)Context;
if (BmIsKeyOptionVariable (Name, Guid, &OptionNumber)) {
GetEfiGlobalVariable2 (Name, &KeyOption, &KeyOptionSize);
@@ -176,11 +179,13 @@ BmCollectKeyOptions ( break;
}
}
+
CopyMem (&Param->KeyOptions[Index + 1], &Param->KeyOptions[Index], (Param->KeyOptionCount - Index) * sizeof (EFI_BOOT_MANAGER_KEY_OPTION));
CopyMem (&Param->KeyOptions[Index], KeyOption, KeyOptionSize);
Param->KeyOptions[Index].OptionNumber = OptionNumber;
Param->KeyOptionCount++;
}
+
FreePool (KeyOption);
}
}
@@ -195,19 +200,19 @@ BmCollectKeyOptions ( **/
EFI_BOOT_MANAGER_KEY_OPTION *
BmGetKeyOptions (
- OUT UINTN *Count
+ OUT UINTN *Count
)
{
- BM_COLLECT_KEY_OPTIONS_PARAM Param;
+ BM_COLLECT_KEY_OPTIONS_PARAM Param;
if (Count == NULL) {
return NULL;
}
- Param.KeyOptions = NULL;
+ Param.KeyOptions = NULL;
Param.KeyOptionCount = 0;
- BmForEachVariable (BmCollectKeyOptions, (VOID *) &Param);
+ BmForEachVariable (BmCollectKeyOptions, (VOID *)&Param);
*Count = Param.KeyOptionCount;
@@ -225,11 +230,11 @@ BmGetKeyOptions ( **/
BOOLEAN
BmBitSet (
- IN UINT32 Value,
- IN UINT32 Bit
+ IN UINT32 Value,
+ IN UINT32 Bit
)
{
- return (BOOLEAN) ((Value & Bit) != 0);
+ return (BOOLEAN)((Value & Bit) != 0);
}
/**
@@ -244,12 +249,12 @@ BmBitSet ( **/
EFI_STATUS
BmInitializeKeyFields (
- IN UINT32 Modifier,
- IN VA_LIST Args,
- OUT EFI_BOOT_MANAGER_KEY_OPTION *KeyOption
+ IN UINT32 Modifier,
+ IN VA_LIST Args,
+ OUT EFI_BOOT_MANAGER_KEY_OPTION *KeyOption
)
{
- EFI_INPUT_KEY *Key;
+ EFI_INPUT_KEY *Key;
if (KeyOption == NULL) {
return EFI_INVALID_PARAMETER;
@@ -261,6 +266,7 @@ BmInitializeKeyFields ( if (Key == NULL) {
break;
}
+
CopyMem (
&KeyOption->Keys[KeyOption->KeyData.Options.InputKeyCount],
Key,
@@ -277,30 +283,36 @@ BmInitializeKeyFields ( }
if ((Modifier & ~(EFI_BOOT_MANAGER_SHIFT_PRESSED
- | EFI_BOOT_MANAGER_CONTROL_PRESSED
- | EFI_BOOT_MANAGER_ALT_PRESSED
- | EFI_BOOT_MANAGER_LOGO_PRESSED
- | EFI_BOOT_MANAGER_MENU_KEY_PRESSED
- | EFI_BOOT_MANAGER_SYS_REQ_PRESSED
- )) != 0) {
+ | EFI_BOOT_MANAGER_CONTROL_PRESSED
+ | EFI_BOOT_MANAGER_ALT_PRESSED
+ | EFI_BOOT_MANAGER_LOGO_PRESSED
+ | EFI_BOOT_MANAGER_MENU_KEY_PRESSED
+ | EFI_BOOT_MANAGER_SYS_REQ_PRESSED
+ )) != 0)
+ {
return EFI_INVALID_PARAMETER;
}
if (BmBitSet (Modifier, EFI_BOOT_MANAGER_SHIFT_PRESSED)) {
KeyOption->KeyData.Options.ShiftPressed = 1;
}
+
if (BmBitSet (Modifier, EFI_BOOT_MANAGER_CONTROL_PRESSED)) {
KeyOption->KeyData.Options.ControlPressed = 1;
}
+
if (BmBitSet (Modifier, EFI_BOOT_MANAGER_ALT_PRESSED)) {
KeyOption->KeyData.Options.AltPressed = 1;
}
+
if (BmBitSet (Modifier, EFI_BOOT_MANAGER_LOGO_PRESSED)) {
KeyOption->KeyData.Options.LogoPressed = 1;
}
+
if (BmBitSet (Modifier, EFI_BOOT_MANAGER_MENU_KEY_PRESSED)) {
KeyOption->KeyData.Options.MenuPressed = 1;
}
+
if (BmBitSet (Modifier, EFI_BOOT_MANAGER_SYS_REQ_PRESSED)) {
KeyOption->KeyData.Options.SysReqPressed = 1;
}
@@ -337,14 +349,14 @@ EfiBootManagerHotkeyBoot ( EFI_STATUS
EFIAPI
BmHotkeyCallback (
- IN EFI_KEY_DATA *KeyData
-)
+ IN EFI_KEY_DATA *KeyData
+ )
{
- LIST_ENTRY *Link;
- BM_HOTKEY *Hotkey;
- CHAR16 OptionName[BM_OPTION_NAME_LEN];
- EFI_STATUS Status;
- EFI_KEY_DATA *HotkeyData;
+ LIST_ENTRY *Link;
+ BM_HOTKEY *Hotkey;
+ CHAR16 OptionName[BM_OPTION_NAME_LEN];
+ EFI_STATUS Status;
+ EFI_KEY_DATA *HotkeyData;
if (mBmHotkeyBootOption.OptionNumber != LoadOptionNumberUnassigned) {
//
@@ -357,9 +369,10 @@ BmHotkeyCallback ( EfiAcquireLock (&mBmHotkeyLock);
for ( Link = GetFirstNode (&mBmHotkeyList)
- ; !IsNull (&mBmHotkeyList, Link)
- ; Link = GetNextNode (&mBmHotkeyList, Link)
- ) {
+ ; !IsNull (&mBmHotkeyList, Link)
+ ; Link = GetNextNode (&mBmHotkeyList, Link)
+ )
+ {
Hotkey = BM_HOTKEY_FROM_LINK (Link);
//
@@ -370,10 +383,10 @@ BmHotkeyCallback ( if ((KeyData->Key.ScanCode == HotkeyData->Key.ScanCode) &&
(KeyData->Key.UnicodeChar == HotkeyData->Key.UnicodeChar) &&
(((KeyData->KeyState.KeyShiftState & EFI_SHIFT_STATE_VALID) != 0) ?
- (KeyData->KeyState.KeyShiftState == HotkeyData->KeyState.KeyShiftState) : TRUE
+ (KeyData->KeyState.KeyShiftState == HotkeyData->KeyState.KeyShiftState) : TRUE
)
- ) {
-
+ )
+ {
//
// Receive an expecting key stroke, transit to next waiting state
//
@@ -395,8 +408,11 @@ BmHotkeyCallback ( // Launch its BootOption
//
UnicodeSPrint (
- OptionName, sizeof (OptionName), L"%s%04x",
- mBmLoadOptionName[LoadOptionTypeBoot], Hotkey->BootOption
+ OptionName,
+ sizeof (OptionName),
+ L"%s%04x",
+ mBmLoadOptionName[LoadOptionTypeBoot],
+ Hotkey->BootOption
);
Status = EfiBootManagerVariableToLoadOption (OptionName, &mBmHotkeyBootOption);
DEBUG ((DEBUG_INFO, "[Bds]Hotkey for %s pressed - %r\n", OptionName, Status));
@@ -413,8 +429,8 @@ BmHotkeyCallback ( //
Hotkey->WaitingKey = 0;
}
-
}
+
EfiReleaseLock (&mBmHotkeyLock);
return EFI_SUCCESS;
@@ -432,11 +448,11 @@ BmHotkeyCallback ( **/
EFI_HANDLE *
BmGetActiveConsoleIn (
- OUT UINTN *Count
+ OUT UINTN *Count
)
{
- EFI_STATUS Status;
- EFI_HANDLE *Handles;
+ EFI_STATUS Status;
+ EFI_HANDLE *Handles;
Handles = NULL;
*Count = 0;
@@ -479,20 +495,20 @@ BmGetActiveConsoleIn ( **/
EFI_STATUS
BmUnregisterHotkeyNotify (
- IN BM_HOTKEY *Hotkey
+ IN BM_HOTKEY *Hotkey
)
{
- EFI_STATUS Status;
- UINTN Index;
- UINTN KeyIndex;
- EFI_HANDLE *Handles;
- UINTN HandleCount;
- EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *TxtInEx;
- VOID *NotifyHandle;
+ EFI_STATUS Status;
+ UINTN Index;
+ UINTN KeyIndex;
+ EFI_HANDLE *Handles;
+ UINTN HandleCount;
+ EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *TxtInEx;
+ VOID *NotifyHandle;
Handles = BmGetActiveConsoleIn (&HandleCount);
for (Index = 0; Index < HandleCount; Index++) {
- Status = gBS->HandleProtocol (Handles[Index], &gEfiSimpleTextInputExProtocolGuid, (VOID **) &TxtInEx);
+ Status = gBS->HandleProtocol (Handles[Index], &gEfiSimpleTextInputExProtocolGuid, (VOID **)&TxtInEx);
ASSERT_EFI_ERROR (Status);
for (KeyIndex = 0; KeyIndex < Hotkey->CodeCount; KeyIndex++) {
Status = TxtInEx->RegisterKeyNotify (
@@ -530,9 +546,9 @@ BmRegisterHotkeyNotify ( IN BM_HOTKEY *Hotkey
)
{
- EFI_STATUS Status;
- UINTN Index;
- VOID *NotifyHandle;
+ EFI_STATUS Status;
+ UINTN Index;
+ VOID *NotifyHandle;
for (Index = 0; Index < Hotkey->CodeCount; Index++) {
Status = TxtInEx->RegisterKeyNotify (
@@ -573,58 +589,64 @@ BmRegisterHotkeyNotify ( **/
VOID
BmGenerateKeyShiftState (
- IN UINTN Depth,
- IN EFI_BOOT_MANAGER_KEY_OPTION *KeyOption,
- IN UINT32 KeyShiftState,
- IN UINT32 *KeyShiftStates,
- IN UINTN *KeyShiftStateCount
+ IN UINTN Depth,
+ IN EFI_BOOT_MANAGER_KEY_OPTION *KeyOption,
+ IN UINT32 KeyShiftState,
+ IN UINT32 *KeyShiftStates,
+ IN UINTN *KeyShiftStateCount
)
{
switch (Depth) {
- case 0:
- if (KeyOption->KeyData.Options.ShiftPressed) {
- BmGenerateKeyShiftState (Depth + 1, KeyOption, KeyShiftState | EFI_RIGHT_SHIFT_PRESSED, KeyShiftStates, KeyShiftStateCount);
- BmGenerateKeyShiftState (Depth + 1, KeyOption, KeyShiftState | EFI_LEFT_SHIFT_PRESSED, KeyShiftStates, KeyShiftStateCount);
- } else {
- BmGenerateKeyShiftState (Depth + 1, KeyOption, KeyShiftState, KeyShiftStates, KeyShiftStateCount);
- }
- break;
+ case 0:
+ if (KeyOption->KeyData.Options.ShiftPressed) {
+ BmGenerateKeyShiftState (Depth + 1, KeyOption, KeyShiftState | EFI_RIGHT_SHIFT_PRESSED, KeyShiftStates, KeyShiftStateCount);
+ BmGenerateKeyShiftState (Depth + 1, KeyOption, KeyShiftState | EFI_LEFT_SHIFT_PRESSED, KeyShiftStates, KeyShiftStateCount);
+ } else {
+ BmGenerateKeyShiftState (Depth + 1, KeyOption, KeyShiftState, KeyShiftStates, KeyShiftStateCount);
+ }
- case 1:
- if (KeyOption->KeyData.Options.ControlPressed) {
- BmGenerateKeyShiftState (Depth + 1, KeyOption, KeyShiftState | EFI_RIGHT_CONTROL_PRESSED, KeyShiftStates, KeyShiftStateCount);
- BmGenerateKeyShiftState (Depth + 1, KeyOption, KeyShiftState | EFI_LEFT_CONTROL_PRESSED, KeyShiftStates, KeyShiftStateCount);
- } else {
- BmGenerateKeyShiftState (Depth + 1, KeyOption, KeyShiftState, KeyShiftStates, KeyShiftStateCount);
- }
- break;
+ break;
- case 2:
- if (KeyOption->KeyData.Options.AltPressed) {
- BmGenerateKeyShiftState (Depth + 1, KeyOption, KeyShiftState | EFI_RIGHT_ALT_PRESSED, KeyShiftStates, KeyShiftStateCount);
- BmGenerateKeyShiftState (Depth + 1, KeyOption, KeyShiftState | EFI_LEFT_ALT_PRESSED, KeyShiftStates, KeyShiftStateCount);
- } else {
- BmGenerateKeyShiftState (Depth + 1, KeyOption, KeyShiftState, KeyShiftStates, KeyShiftStateCount);
- }
- break;
- case 3:
- if (KeyOption->KeyData.Options.LogoPressed) {
- BmGenerateKeyShiftState (Depth + 1, KeyOption, KeyShiftState | EFI_RIGHT_LOGO_PRESSED, KeyShiftStates, KeyShiftStateCount);
- BmGenerateKeyShiftState (Depth + 1, KeyOption, KeyShiftState | EFI_LEFT_LOGO_PRESSED, KeyShiftStates, KeyShiftStateCount);
- } else {
- BmGenerateKeyShiftState (Depth + 1, KeyOption, KeyShiftState, KeyShiftStates, KeyShiftStateCount);
- }
- break;
- case 4:
- if (KeyOption->KeyData.Options.MenuPressed) {
- KeyShiftState |= EFI_MENU_KEY_PRESSED;
- }
- if (KeyOption->KeyData.Options.SysReqPressed) {
- KeyShiftState |= EFI_SYS_REQ_PRESSED;
- }
- KeyShiftStates[*KeyShiftStateCount] = KeyShiftState;
- (*KeyShiftStateCount)++;
- break;
+ case 1:
+ if (KeyOption->KeyData.Options.ControlPressed) {
+ BmGenerateKeyShiftState (Depth + 1, KeyOption, KeyShiftState | EFI_RIGHT_CONTROL_PRESSED, KeyShiftStates, KeyShiftStateCount);
+ BmGenerateKeyShiftState (Depth + 1, KeyOption, KeyShiftState | EFI_LEFT_CONTROL_PRESSED, KeyShiftStates, KeyShiftStateCount);
+ } else {
+ BmGenerateKeyShiftState (Depth + 1, KeyOption, KeyShiftState, KeyShiftStates, KeyShiftStateCount);
+ }
+
+ break;
+
+ case 2:
+ if (KeyOption->KeyData.Options.AltPressed) {
+ BmGenerateKeyShiftState (Depth + 1, KeyOption, KeyShiftState | EFI_RIGHT_ALT_PRESSED, KeyShiftStates, KeyShiftStateCount);
+ BmGenerateKeyShiftState (Depth + 1, KeyOption, KeyShiftState | EFI_LEFT_ALT_PRESSED, KeyShiftStates, KeyShiftStateCount);
+ } else {
+ BmGenerateKeyShiftState (Depth + 1, KeyOption, KeyShiftState, KeyShiftStates, KeyShiftStateCount);
+ }
+
+ break;
+ case 3:
+ if (KeyOption->KeyData.Options.LogoPressed) {
+ BmGenerateKeyShiftState (Depth + 1, KeyOption, KeyShiftState | EFI_RIGHT_LOGO_PRESSED, KeyShiftStates, KeyShiftStateCount);
+ BmGenerateKeyShiftState (Depth + 1, KeyOption, KeyShiftState | EFI_LEFT_LOGO_PRESSED, KeyShiftStates, KeyShiftStateCount);
+ } else {
+ BmGenerateKeyShiftState (Depth + 1, KeyOption, KeyShiftState, KeyShiftStates, KeyShiftStateCount);
+ }
+
+ break;
+ case 4:
+ if (KeyOption->KeyData.Options.MenuPressed) {
+ KeyShiftState |= EFI_MENU_KEY_PRESSED;
+ }
+
+ if (KeyOption->KeyData.Options.SysReqPressed) {
+ KeyShiftState |= EFI_SYS_REQ_PRESSED;
+ }
+
+ KeyShiftStates[*KeyShiftStateCount] = KeyShiftState;
+ (*KeyShiftStateCount)++;
+ break;
}
}
@@ -636,22 +658,22 @@ BmGenerateKeyShiftState ( **/
EFI_STATUS
BmProcessKeyOption (
- IN EFI_BOOT_MANAGER_KEY_OPTION *KeyOption
+ IN EFI_BOOT_MANAGER_KEY_OPTION *KeyOption
)
{
- EFI_STATUS Status;
- EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *TxtInEx;
- EFI_HANDLE *Handles;
- UINTN HandleCount;
- UINTN HandleIndex;
- UINTN Index;
- BM_HOTKEY *Hotkey;
- UINTN KeyIndex;
+ EFI_STATUS Status;
+ EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *TxtInEx;
+ EFI_HANDLE *Handles;
+ UINTN HandleCount;
+ UINTN HandleIndex;
+ UINTN Index;
+ BM_HOTKEY *Hotkey;
+ UINTN KeyIndex;
//
// 16 is enough to enumerate all the possible combination of LEFT_XXX and RIGHT_XXX
//
- UINT32 KeyShiftStates[16];
- UINTN KeyShiftStateCount;
+ UINT32 KeyShiftStates[16];
+ UINTN KeyShiftStateCount;
if (KeyOption->KeyData.Options.InputKeyCount > mBmHotkeySupportCount) {
return EFI_UNSUPPORTED;
@@ -671,17 +693,18 @@ BmProcessKeyOption ( Hotkey->Signature = BM_HOTKEY_SIGNATURE;
Hotkey->BootOption = KeyOption->BootOption;
- Hotkey->IsContinue = (BOOLEAN) (KeyOption == mBmContinueKeyOption);
- Hotkey->CodeCount = (UINT8) KeyOption->KeyData.Options.InputKeyCount;
+ Hotkey->IsContinue = (BOOLEAN)(KeyOption == mBmContinueKeyOption);
+ Hotkey->CodeCount = (UINT8)KeyOption->KeyData.Options.InputKeyCount;
for (KeyIndex = 0; KeyIndex < Hotkey->CodeCount; KeyIndex++) {
CopyMem (&Hotkey->KeyData[KeyIndex].Key, &KeyOption->Keys[KeyIndex], sizeof (EFI_INPUT_KEY));
Hotkey->KeyData[KeyIndex].KeyState.KeyShiftState = KeyShiftStates[Index];
}
+
InsertTailList (&mBmHotkeyList, &Hotkey->Link);
for (HandleIndex = 0; HandleIndex < HandleCount; HandleIndex++) {
- Status = gBS->HandleProtocol (Handles[HandleIndex], &gEfiSimpleTextInputExProtocolGuid, (VOID **) &TxtInEx);
+ Status = gBS->HandleProtocol (Handles[HandleIndex], &gEfiSimpleTextInputExProtocolGuid, (VOID **)&TxtInEx);
ASSERT_EFI_ERROR (Status);
BmRegisterHotkeyNotify (TxtInEx, Hotkey);
}
@@ -690,6 +713,7 @@ BmProcessKeyOption ( if (Handles != NULL) {
FreePool (Handles);
}
+
EfiReleaseLock (&mBmHotkeyLock);
return EFI_SUCCESS;
@@ -705,8 +729,8 @@ BmProcessKeyOption ( VOID
EFIAPI
BmTxtInExCallback (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
EFI_STATUS Status;
@@ -717,24 +741,24 @@ BmTxtInExCallback ( while (TRUE) {
BufferSize = sizeof (EFI_HANDLE);
- Status = gBS->LocateHandle (
- ByRegisterNotify,
- NULL,
- mBmTxtInExRegistration,
- &BufferSize,
- &Handle
- );
+ Status = gBS->LocateHandle (
+ ByRegisterNotify,
+ NULL,
+ mBmTxtInExRegistration,
+ &BufferSize,
+ &Handle
+ );
if (EFI_ERROR (Status)) {
//
// If no more notification events exist
//
- return ;
+ return;
}
Status = gBS->HandleProtocol (
Handle,
&gEfiSimpleTextInputExProtocolGuid,
- (VOID **) &TxtInEx
+ (VOID **)&TxtInEx
);
ASSERT_EFI_ERROR (Status);
@@ -745,6 +769,7 @@ BmTxtInExCallback ( for (Link = GetFirstNode (&mBmHotkeyList); !IsNull (&mBmHotkeyList, Link); Link = GetNextNode (&mBmHotkeyList, Link)) {
BmRegisterHotkeyNotify (TxtInEx, BM_HOTKEY_FROM_LINK (Link));
}
+
EfiReleaseLock (&mBmHotkeyLock);
}
}
@@ -760,8 +785,8 @@ BmTxtInExCallback ( **/
EFI_STATUS
BmFreeKeyOptions (
- IN EFI_BOOT_MANAGER_KEY_OPTION *KeyOptions,
- IN UINTN KeyOptionCount
+ IN EFI_BOOT_MANAGER_KEY_OPTION *KeyOptions,
+ IN UINTN KeyOptionCount
)
{
if (KeyOptions != NULL) {
@@ -786,7 +811,7 @@ BmFreeKeyOptions ( EFI_STATUS
EFIAPI
EfiBootManagerRegisterContinueKeyOption (
- IN UINT32 Modifier,
+ IN UINT32 Modifier,
...
)
{
@@ -823,12 +848,12 @@ EfiBootManagerRegisterContinueKeyOption ( VOID
EFIAPI
BmStopHotkeyService (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
- LIST_ENTRY *Link;
- BM_HOTKEY *Hotkey;
+ LIST_ENTRY *Link;
+ BM_HOTKEY *Hotkey;
DEBUG ((DEBUG_INFO, "[Bds]Stop Hotkey Service!\n"));
gBS->CloseEvent (Event);
@@ -837,9 +862,10 @@ BmStopHotkeyService ( for (Link = GetFirstNode (&mBmHotkeyList); !IsNull (&mBmHotkeyList, Link); ) {
Hotkey = BM_HOTKEY_FROM_LINK (Link);
BmUnregisterHotkeyNotify (Hotkey);
- Link = RemoveEntryList (Link);
+ Link = RemoveEntryList (Link);
FreePool (Hotkey);
}
+
EfiReleaseLock (&mBmHotkeyLock);
}
@@ -854,7 +880,7 @@ BmStopHotkeyService ( EFI_STATUS
EFIAPI
EfiBootManagerStartHotkeyService (
- IN EFI_EVENT *HotkeyTriggered
+ IN EFI_EVENT *HotkeyTriggered
)
{
EFI_STATUS Status;
@@ -864,11 +890,12 @@ EfiBootManagerStartHotkeyService ( EFI_EVENT Event;
UINT32 *BootOptionSupport;
- GetEfiGlobalVariable2 (EFI_BOOT_OPTION_SUPPORT_VARIABLE_NAME, (VOID **) &BootOptionSupport, NULL);
+ GetEfiGlobalVariable2 (EFI_BOOT_OPTION_SUPPORT_VARIABLE_NAME, (VOID **)&BootOptionSupport, NULL);
if (BootOptionSupport != NULL) {
if ((*BootOptionSupport & EFI_BOOT_OPTION_SUPPORT_KEY) != 0) {
mBmHotkeySupportCount = ((*BootOptionSupport & EFI_BOOT_OPTION_SUPPORT_COUNT) >> LowBitSet32 (EFI_BOOT_OPTION_SUPPORT_COUNT));
}
+
FreePool (BootOptionSupport);
}
@@ -891,9 +918,10 @@ EfiBootManagerStartHotkeyService ( }
KeyOptions = BmGetKeyOptions (&KeyOptionCount);
- for (Index = 0; Index < KeyOptionCount; Index ++) {
+ for (Index = 0; Index < KeyOptionCount; Index++) {
BmProcessKeyOption (&KeyOptions[Index]);
}
+
BmFreeKeyOptions (KeyOptions, KeyOptionCount);
if (mBmContinueKeyOption != NULL) {
@@ -942,27 +970,30 @@ EfiBootManagerStartHotkeyService ( EFI_STATUS
EFIAPI
EfiBootManagerAddKeyOptionVariable (
- OUT EFI_BOOT_MANAGER_KEY_OPTION *AddedOption OPTIONAL,
- IN UINT16 BootOptionNumber,
- IN UINT32 Modifier,
+ OUT EFI_BOOT_MANAGER_KEY_OPTION *AddedOption OPTIONAL,
+ IN UINT16 BootOptionNumber,
+ IN UINT32 Modifier,
...
)
{
- EFI_STATUS Status;
- VA_LIST Args;
- VOID *BootOption;
- UINTN BootOptionSize;
- CHAR16 BootOptionName[BM_OPTION_NAME_LEN];
- EFI_BOOT_MANAGER_KEY_OPTION KeyOption;
- EFI_BOOT_MANAGER_KEY_OPTION *KeyOptions;
- UINTN KeyOptionCount;
- UINTN Index;
- UINTN KeyOptionNumber;
- CHAR16 KeyOptionName[sizeof ("Key####")];
+ EFI_STATUS Status;
+ VA_LIST Args;
+ VOID *BootOption;
+ UINTN BootOptionSize;
+ CHAR16 BootOptionName[BM_OPTION_NAME_LEN];
+ EFI_BOOT_MANAGER_KEY_OPTION KeyOption;
+ EFI_BOOT_MANAGER_KEY_OPTION *KeyOptions;
+ UINTN KeyOptionCount;
+ UINTN Index;
+ UINTN KeyOptionNumber;
+ CHAR16 KeyOptionName[sizeof ("Key####")];
UnicodeSPrint (
- BootOptionName, sizeof (BootOptionName), L"%s%04x",
- mBmLoadOptionName[LoadOptionTypeBoot], BootOptionNumber
+ BootOptionName,
+ sizeof (BootOptionName),
+ L"%s%04x",
+ mBmLoadOptionName[LoadOptionTypeBoot],
+ BootOptionNumber
);
GetEfiGlobalVariable2 (BootOptionName, &BootOption, &BootOptionSize);
@@ -972,7 +1003,7 @@ EfiBootManagerAddKeyOptionVariable ( ZeroMem (&KeyOption, sizeof (EFI_BOOT_MANAGER_KEY_OPTION));
KeyOption.BootOption = BootOptionNumber;
- Status = gBS->CalculateCrc32 (BootOption, BootOptionSize, &KeyOption.BootOptionCrc);
+ Status = gBS->CalculateCrc32 (BootOption, BootOptionSize, &KeyOption.BootOptionCrc);
ASSERT_EFI_ERROR (Status);
FreePool (BootOption);
@@ -990,16 +1021,19 @@ EfiBootManagerAddKeyOptionVariable ( KeyOptions = BmGetKeyOptions (&KeyOptionCount);
for (Index = 0; Index < KeyOptionCount; Index++) {
if ((KeyOptions[Index].KeyData.PackedValue == KeyOption.KeyData.PackedValue) &&
- (CompareMem (KeyOptions[Index].Keys, KeyOption.Keys, KeyOption.KeyData.Options.InputKeyCount * sizeof (EFI_INPUT_KEY)) == 0)) {
+ (CompareMem (KeyOptions[Index].Keys, KeyOption.Keys, KeyOption.KeyData.Options.InputKeyCount * sizeof (EFI_INPUT_KEY)) == 0))
+ {
break;
}
if ((KeyOptionNumber == LoadOptionNumberUnassigned) &&
(KeyOptions[Index].OptionNumber > Index)
- ){
+ )
+ {
KeyOptionNumber = Index;
}
}
+
BmFreeKeyOptions (KeyOptions, KeyOptionCount);
if (Index < KeyOptionCount) {
@@ -1053,22 +1087,22 @@ EfiBootManagerAddKeyOptionVariable ( EFI_STATUS
EFIAPI
EfiBootManagerDeleteKeyOptionVariable (
- IN EFI_BOOT_MANAGER_KEY_OPTION *DeletedOption OPTIONAL,
- IN UINT32 Modifier,
+ IN EFI_BOOT_MANAGER_KEY_OPTION *DeletedOption OPTIONAL,
+ IN UINT32 Modifier,
...
)
{
- EFI_STATUS Status;
- UINTN Index;
- VA_LIST Args;
- EFI_BOOT_MANAGER_KEY_OPTION KeyOption;
- EFI_BOOT_MANAGER_KEY_OPTION *KeyOptions;
- UINTN KeyOptionCount;
- LIST_ENTRY *Link;
- BM_HOTKEY *Hotkey;
- UINT32 ShiftState;
- BOOLEAN Match;
- CHAR16 KeyOptionName[sizeof ("Key####")];
+ EFI_STATUS Status;
+ UINTN Index;
+ VA_LIST Args;
+ EFI_BOOT_MANAGER_KEY_OPTION KeyOption;
+ EFI_BOOT_MANAGER_KEY_OPTION *KeyOptions;
+ UINTN KeyOptionCount;
+ LIST_ENTRY *Link;
+ BM_HOTKEY *Hotkey;
+ UINT32 ShiftState;
+ BOOLEAN Match;
+ CHAR16 KeyOptionName[sizeof ("Key####")];
ZeroMem (&KeyOption, sizeof (EFI_BOOT_MANAGER_KEY_OPTION));
VA_START (Args, Modifier);
@@ -1086,19 +1120,20 @@ EfiBootManagerDeleteKeyOptionVariable ( //
for (Link = GetFirstNode (&mBmHotkeyList); !IsNull (&mBmHotkeyList, Link); ) {
Hotkey = BM_HOTKEY_FROM_LINK (Link);
- Match = (BOOLEAN) (Hotkey->CodeCount == KeyOption.KeyData.Options.InputKeyCount);
+ Match = (BOOLEAN)(Hotkey->CodeCount == KeyOption.KeyData.Options.InputKeyCount);
for (Index = 0; Match && (Index < Hotkey->CodeCount); Index++) {
ShiftState = Hotkey->KeyData[Index].KeyState.KeyShiftState;
if (
- (BmBitSet (ShiftState, EFI_RIGHT_SHIFT_PRESSED | EFI_LEFT_SHIFT_PRESSED) != KeyOption.KeyData.Options.ShiftPressed) ||
- (BmBitSet (ShiftState, EFI_RIGHT_CONTROL_PRESSED | EFI_LEFT_CONTROL_PRESSED) != KeyOption.KeyData.Options.ControlPressed) ||
- (BmBitSet (ShiftState, EFI_RIGHT_ALT_PRESSED | EFI_LEFT_ALT_PRESSED) != KeyOption.KeyData.Options.AltPressed) ||
- (BmBitSet (ShiftState, EFI_RIGHT_LOGO_PRESSED | EFI_LEFT_LOGO_PRESSED) != KeyOption.KeyData.Options.LogoPressed) ||
- (BmBitSet (ShiftState, EFI_MENU_KEY_PRESSED) != KeyOption.KeyData.Options.MenuPressed) ||
- (BmBitSet (ShiftState, EFI_SYS_REQ_PRESSED) != KeyOption.KeyData.Options.SysReqPressed) ||
- (CompareMem (&Hotkey->KeyData[Index].Key, &KeyOption.Keys[Index], sizeof (EFI_INPUT_KEY)) != 0)
- ) {
+ (BmBitSet (ShiftState, EFI_RIGHT_SHIFT_PRESSED | EFI_LEFT_SHIFT_PRESSED) != KeyOption.KeyData.Options.ShiftPressed) ||
+ (BmBitSet (ShiftState, EFI_RIGHT_CONTROL_PRESSED | EFI_LEFT_CONTROL_PRESSED) != KeyOption.KeyData.Options.ControlPressed) ||
+ (BmBitSet (ShiftState, EFI_RIGHT_ALT_PRESSED | EFI_LEFT_ALT_PRESSED) != KeyOption.KeyData.Options.AltPressed) ||
+ (BmBitSet (ShiftState, EFI_RIGHT_LOGO_PRESSED | EFI_LEFT_LOGO_PRESSED) != KeyOption.KeyData.Options.LogoPressed) ||
+ (BmBitSet (ShiftState, EFI_MENU_KEY_PRESSED) != KeyOption.KeyData.Options.MenuPressed) ||
+ (BmBitSet (ShiftState, EFI_SYS_REQ_PRESSED) != KeyOption.KeyData.Options.SysReqPressed) ||
+ (CompareMem (&Hotkey->KeyData[Index].Key, &KeyOption.Keys[Index], sizeof (EFI_INPUT_KEY)) != 0)
+ )
+ {
//
// Break when any field doesn't match
//
@@ -1123,26 +1158,31 @@ EfiBootManagerDeleteKeyOptionVariable ( for (Index = 0; Index < KeyOptionCount; Index++) {
if ((KeyOptions[Index].KeyData.PackedValue == KeyOption.KeyData.PackedValue) &&
(CompareMem (
- KeyOptions[Index].Keys, KeyOption.Keys,
- KeyOption.KeyData.Options.InputKeyCount * sizeof (EFI_INPUT_KEY)) == 0)
- ) {
+ KeyOptions[Index].Keys,
+ KeyOption.Keys,
+ KeyOption.KeyData.Options.InputKeyCount * sizeof (EFI_INPUT_KEY)
+ ) == 0)
+ )
+ {
UnicodeSPrint (KeyOptionName, sizeof (KeyOptionName), L"Key%04x", KeyOptions[Index].OptionNumber);
Status = gRT->SetVariable (
- KeyOptionName,
- &gEfiGlobalVariableGuid,
- EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
- 0,
- NULL
- );
+ KeyOptionName,
+ &gEfiGlobalVariableGuid,
+ EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
+ 0,
+ NULL
+ );
//
// Return the deleted key option in case needed by caller
//
if (DeletedOption != NULL) {
CopyMem (DeletedOption, &KeyOptions[Index], sizeof (EFI_BOOT_MANAGER_KEY_OPTION));
}
+
break;
}
}
+
BmFreeKeyOptions (KeyOptions, KeyOptionCount);
EfiReleaseLock (&mBmHotkeyLock);
diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c b/MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c index de9dde2d3d..32a9cbb425 100644 --- a/MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c +++ b/MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c @@ -10,20 +10,20 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include "InternalBm.h"
GLOBAL_REMOVE_IF_UNREFERENCED
- CHAR16 *mBmLoadOptionName[] = {
- L"Driver",
- L"SysPrep",
- L"Boot",
- L"PlatformRecovery"
- };
+CHAR16 *mBmLoadOptionName[] = {
+ L"Driver",
+ L"SysPrep",
+ L"Boot",
+ L"PlatformRecovery"
+};
GLOBAL_REMOVE_IF_UNREFERENCED
- CHAR16 *mBmLoadOptionOrderName[] = {
- EFI_DRIVER_ORDER_VARIABLE_NAME,
- EFI_SYS_PREP_ORDER_VARIABLE_NAME,
- EFI_BOOT_ORDER_VARIABLE_NAME,
- NULL // PlatformRecovery#### doesn't have associated *Order variable
- };
+CHAR16 *mBmLoadOptionOrderName[] = {
+ EFI_DRIVER_ORDER_VARIABLE_NAME,
+ EFI_SYS_PREP_ORDER_VARIABLE_NAME,
+ EFI_BOOT_ORDER_VARIABLE_NAME,
+ NULL // PlatformRecovery#### doesn't have associated *Order variable
+};
/**
Call Visitor function for each variable in variable storage.
@@ -33,32 +33,33 @@ GLOBAL_REMOVE_IF_UNREFERENCED **/
VOID
BmForEachVariable (
- BM_VARIABLE_VISITOR Visitor,
- VOID *Context
+ BM_VARIABLE_VISITOR Visitor,
+ VOID *Context
)
{
- EFI_STATUS Status;
- CHAR16 *Name;
- EFI_GUID Guid;
- UINTN NameSize;
- UINTN NewNameSize;
+ EFI_STATUS Status;
+ CHAR16 *Name;
+ EFI_GUID Guid;
+ UINTN NameSize;
+ UINTN NewNameSize;
NameSize = sizeof (CHAR16);
- Name = AllocateZeroPool (NameSize);
+ Name = AllocateZeroPool (NameSize);
ASSERT (Name != NULL);
while (TRUE) {
NewNameSize = NameSize;
- Status = gRT->GetNextVariableName (&NewNameSize, Name, &Guid);
+ Status = gRT->GetNextVariableName (&NewNameSize, Name, &Guid);
if (Status == EFI_BUFFER_TOO_SMALL) {
Name = ReallocatePool (NameSize, NewNameSize, Name);
ASSERT (Name != NULL);
- Status = gRT->GetNextVariableName (&NewNameSize, Name, &Guid);
+ Status = gRT->GetNextVariableName (&NewNameSize, Name, &Guid);
NameSize = NewNameSize;
}
if (Status == EFI_NOT_FOUND) {
break;
}
+
ASSERT_EFI_ERROR (Status);
Visitor (Name, &Guid, Context);
@@ -80,35 +81,37 @@ BmForEachVariable ( **/
EFI_STATUS
BmGetFreeOptionNumber (
- IN EFI_BOOT_MANAGER_LOAD_OPTION_TYPE LoadOptionType,
- OUT UINT16 *FreeOptionNumber
+ IN EFI_BOOT_MANAGER_LOAD_OPTION_TYPE LoadOptionType,
+ OUT UINT16 *FreeOptionNumber
)
{
-
- UINTN OptionNumber;
- UINTN Index;
- UINT16 *OptionOrder;
- UINTN OptionOrderSize;
- UINT16 *BootNext;
+ UINTN OptionNumber;
+ UINTN Index;
+ UINT16 *OptionOrder;
+ UINTN OptionOrderSize;
+ UINT16 *BootNext;
ASSERT (FreeOptionNumber != NULL);
- ASSERT (LoadOptionType == LoadOptionTypeDriver ||
- LoadOptionType == LoadOptionTypeBoot ||
- LoadOptionType == LoadOptionTypeSysPrep);
+ ASSERT (
+ LoadOptionType == LoadOptionTypeDriver ||
+ LoadOptionType == LoadOptionTypeBoot ||
+ LoadOptionType == LoadOptionTypeSysPrep
+ );
- GetEfiGlobalVariable2 (mBmLoadOptionOrderName[LoadOptionType], (VOID **) &OptionOrder, &OptionOrderSize);
+ GetEfiGlobalVariable2 (mBmLoadOptionOrderName[LoadOptionType], (VOID **)&OptionOrder, &OptionOrderSize);
ASSERT ((OptionOrder != NULL && OptionOrderSize != 0) || (OptionOrder == NULL && OptionOrderSize == 0));
BootNext = NULL;
if (LoadOptionType == LoadOptionTypeBoot) {
- GetEfiGlobalVariable2 (L"BootNext", (VOID**) &BootNext, NULL);
+ GetEfiGlobalVariable2 (L"BootNext", (VOID **)&BootNext, NULL);
}
for (OptionNumber = 0;
OptionNumber < OptionOrderSize / sizeof (UINT16)
- + ((BootNext != NULL) ? 1 : 0);
+ + ((BootNext != NULL) ? 1 : 0);
OptionNumber++
- ) {
+ )
+ {
//
// Search in OptionOrder whether the OptionNumber exists
//
@@ -124,10 +127,12 @@ BmGetFreeOptionNumber ( //
if ((Index == OptionOrderSize / sizeof (UINT16)) &&
((BootNext == NULL) || (OptionNumber != *BootNext))
- ) {
+ )
+ {
break;
}
}
+
if (OptionOrder != NULL) {
FreePool (OptionOrder);
}
@@ -144,7 +149,7 @@ BmGetFreeOptionNumber ( if (OptionNumber == 0x10000) {
return EFI_OUT_OF_RESOURCES;
} else {
- *FreeOptionNumber = (UINT16) OptionNumber;
+ *FreeOptionNumber = (UINT16)OptionNumber;
return EFI_SUCCESS;
}
}
@@ -161,23 +166,24 @@ BmGetFreeOptionNumber ( EFI_STATUS
EFIAPI
EfiBootManagerLoadOptionToVariable (
- IN CONST EFI_BOOT_MANAGER_LOAD_OPTION *Option
+ IN CONST EFI_BOOT_MANAGER_LOAD_OPTION *Option
)
{
- EFI_STATUS Status;
- UINTN VariableSize;
- UINT8 *Variable;
- UINT8 *Ptr;
- CHAR16 OptionName[BM_OPTION_NAME_LEN];
- CHAR16 *Description;
- CHAR16 NullChar;
- EDKII_VARIABLE_LOCK_PROTOCOL *VariableLock;
- UINT32 VariableAttributes;
+ EFI_STATUS Status;
+ UINTN VariableSize;
+ UINT8 *Variable;
+ UINT8 *Ptr;
+ CHAR16 OptionName[BM_OPTION_NAME_LEN];
+ CHAR16 *Description;
+ CHAR16 NullChar;
+ EDKII_VARIABLE_LOCK_PROTOCOL *VariableLock;
+ UINT32 VariableAttributes;
if ((Option->OptionNumber == LoadOptionNumberUnassigned) ||
(Option->FilePath == NULL) ||
- ((UINT32) Option->OptionType >= LoadOptionTypeMax)
- ) {
+ ((UINT32)Option->OptionType >= LoadOptionTypeMax)
+ )
+ {
return EFI_INVALID_PARAMETER;
}
@@ -206,26 +212,26 @@ in the array is variable length, and ends at the device path end structure.
*/
VariableSize = sizeof (Option->Attributes)
- + sizeof (UINT16)
- + StrSize (Description)
- + GetDevicePathSize (Option->FilePath)
- + Option->OptionalDataSize;
+ + sizeof (UINT16)
+ + StrSize (Description)
+ + GetDevicePathSize (Option->FilePath)
+ + Option->OptionalDataSize;
- Variable = AllocatePool (VariableSize);
+ Variable = AllocatePool (VariableSize);
ASSERT (Variable != NULL);
- Ptr = Variable;
- WriteUnaligned32 ((UINT32 *) Ptr, Option->Attributes);
- Ptr += sizeof (Option->Attributes);
+ Ptr = Variable;
+ WriteUnaligned32 ((UINT32 *)Ptr, Option->Attributes);
+ Ptr += sizeof (Option->Attributes);
- WriteUnaligned16 ((UINT16 *) Ptr, (UINT16) GetDevicePathSize (Option->FilePath));
- Ptr += sizeof (UINT16);
+ WriteUnaligned16 ((UINT16 *)Ptr, (UINT16)GetDevicePathSize (Option->FilePath));
+ Ptr += sizeof (UINT16);
CopyMem (Ptr, Description, StrSize (Description));
- Ptr += StrSize (Description);
+ Ptr += StrSize (Description);
CopyMem (Ptr, Option->FilePath, GetDevicePathSize (Option->FilePath));
- Ptr += GetDevicePathSize (Option->FilePath);
+ Ptr += GetDevicePathSize (Option->FilePath);
CopyMem (Ptr, Option->OptionalData, Option->OptionalDataSize);
@@ -236,11 +242,12 @@ structure. //
// Lock the PlatformRecovery####
//
- Status = gBS->LocateProtocol (&gEdkiiVariableLockProtocolGuid, NULL, (VOID **) &VariableLock);
+ Status = gBS->LocateProtocol (&gEdkiiVariableLockProtocolGuid, NULL, (VOID **)&VariableLock);
if (!EFI_ERROR (Status)) {
Status = VariableLock->RequestToLock (VariableLock, OptionName, &gEfiGlobalVariableGuid);
ASSERT_EFI_ERROR (Status);
}
+
VariableAttributes = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS;
}
@@ -270,20 +277,21 @@ structure. **/
EFI_STATUS
BmAddOptionNumberToOrderVariable (
- IN CHAR16 *OptionOrderName,
- IN UINT16 OptionNumber,
- IN UINTN Position
+ IN CHAR16 *OptionOrderName,
+ IN UINT16 OptionNumber,
+ IN UINTN Position
)
{
- EFI_STATUS Status;
- UINTN Index;
- UINT16 *OptionOrder;
- UINT16 *NewOptionOrder;
- UINTN OptionOrderSize;
+ EFI_STATUS Status;
+ UINTN Index;
+ UINT16 *OptionOrder;
+ UINT16 *NewOptionOrder;
+ UINTN OptionOrderSize;
+
//
// Update the option order variable
//
- GetEfiGlobalVariable2 (OptionOrderName, (VOID **) &OptionOrder, &OptionOrderSize);
+ GetEfiGlobalVariable2 (OptionOrderName, (VOID **)&OptionOrder, &OptionOrderSize);
ASSERT ((OptionOrder != NULL && OptionOrderSize != 0) || (OptionOrder == NULL && OptionOrderSize == 0));
Status = EFI_SUCCESS;
@@ -295,7 +303,7 @@ BmAddOptionNumberToOrderVariable ( }
if (!EFI_ERROR (Status)) {
- Position = MIN (Position, OptionOrderSize / sizeof (UINT16));
+ Position = MIN (Position, OptionOrderSize / sizeof (UINT16));
NewOptionOrder = AllocatePool (OptionOrderSize + sizeof (UINT16));
ASSERT (NewOptionOrder != NULL);
@@ -303,6 +311,7 @@ BmAddOptionNumberToOrderVariable ( CopyMem (NewOptionOrder, OptionOrder, Position * sizeof (UINT16));
CopyMem (&NewOptionOrder[Position + 1], &OptionOrder[Position], OptionOrderSize - Position * sizeof (UINT16));
}
+
NewOptionOrder[Position] = OptionNumber;
Status = gRT->SetVariable (
@@ -345,21 +354,22 @@ BmAddOptionNumberToOrderVariable ( EFI_STATUS
EFIAPI
EfiBootManagerAddLoadOptionVariable (
- IN OUT EFI_BOOT_MANAGER_LOAD_OPTION *Option,
- IN UINTN Position
+ IN OUT EFI_BOOT_MANAGER_LOAD_OPTION *Option,
+ IN UINTN Position
)
{
- EFI_STATUS Status;
- UINT16 OptionNumber;
+ EFI_STATUS Status;
+ UINT16 OptionNumber;
if (Option == NULL) {
return EFI_INVALID_PARAMETER;
}
- if (Option->OptionType != LoadOptionTypeDriver &&
- Option->OptionType != LoadOptionTypeSysPrep &&
- Option->OptionType != LoadOptionTypeBoot
- ) {
+ if ((Option->OptionType != LoadOptionTypeDriver) &&
+ (Option->OptionType != LoadOptionTypeSysPrep) &&
+ (Option->OptionType != LoadOptionTypeBoot)
+ )
+ {
return EFI_INVALID_PARAMETER;
}
@@ -371,6 +381,7 @@ EfiBootManagerAddLoadOptionVariable ( if (EFI_ERROR (Status)) {
return Status;
}
+
Option->OptionNumber = OptionNumber;
}
@@ -378,7 +389,7 @@ EfiBootManagerAddLoadOptionVariable ( return EFI_INVALID_PARAMETER;
}
- Status = BmAddOptionNumberToOrderVariable (mBmLoadOptionOrderName[Option->OptionType], (UINT16) Option->OptionNumber, Position);
+ Status = BmAddOptionNumberToOrderVariable (mBmLoadOptionOrderName[Option->OptionType], (UINT16)Option->OptionNumber, Position);
if (!EFI_ERROR (Status)) {
//
// Save the Boot#### or Driver#### variable
@@ -405,15 +416,15 @@ EfiBootManagerAddLoadOptionVariable ( VOID
EFIAPI
EfiBootManagerSortLoadOptionVariable (
- EFI_BOOT_MANAGER_LOAD_OPTION_TYPE OptionType,
- SORT_COMPARE CompareFunction
+ EFI_BOOT_MANAGER_LOAD_OPTION_TYPE OptionType,
+ SORT_COMPARE CompareFunction
)
{
- EFI_STATUS Status;
- EFI_BOOT_MANAGER_LOAD_OPTION *LoadOption;
- UINTN LoadOptionCount;
- UINTN Index;
- UINT16 *OptionOrder;
+ EFI_STATUS Status;
+ EFI_BOOT_MANAGER_LOAD_OPTION *LoadOption;
+ UINTN LoadOptionCount;
+ UINTN Index;
+ UINT16 *OptionOrder;
LoadOption = EfiBootManagerGetLoadOptions (&LoadOptionCount, OptionType);
@@ -433,7 +444,7 @@ EfiBootManagerSortLoadOptionVariable ( OptionOrder = AllocatePool (LoadOptionCount * sizeof (UINT16));
ASSERT (OptionOrder != NULL);
for (Index = 0; Index < LoadOptionCount; Index++) {
- OptionOrder[Index] = (UINT16) LoadOption[Index].OptionNumber;
+ OptionOrder[Index] = (UINT16)LoadOption[Index].OptionNumber;
}
Status = gRT->SetVariable (
@@ -470,14 +481,14 @@ EfiBootManagerSortLoadOptionVariable ( EFI_STATUS
EFIAPI
EfiBootManagerInitializeLoadOption (
- IN OUT EFI_BOOT_MANAGER_LOAD_OPTION *Option,
- IN UINTN OptionNumber,
- IN EFI_BOOT_MANAGER_LOAD_OPTION_TYPE OptionType,
- IN UINT32 Attributes,
- IN CHAR16 *Description,
- IN EFI_DEVICE_PATH_PROTOCOL *FilePath,
- IN UINT8 *OptionalData OPTIONAL,
- IN UINT32 OptionalDataSize
+ IN OUT EFI_BOOT_MANAGER_LOAD_OPTION *Option,
+ IN UINTN OptionNumber,
+ IN EFI_BOOT_MANAGER_LOAD_OPTION_TYPE OptionType,
+ IN UINT32 Attributes,
+ IN CHAR16 *Description,
+ IN EFI_DEVICE_PATH_PROTOCOL *FilePath,
+ IN UINT8 *OptionalData OPTIONAL,
+ IN UINT32 OptionalDataSize
)
{
if ((Option == NULL) || (Description == NULL) || (FilePath == NULL)) {
@@ -485,20 +496,21 @@ EfiBootManagerInitializeLoadOption ( }
if (((OptionalData != NULL) && (OptionalDataSize == 0)) ||
- ((OptionalData == NULL) && (OptionalDataSize != 0))) {
+ ((OptionalData == NULL) && (OptionalDataSize != 0)))
+ {
return EFI_INVALID_PARAMETER;
}
- if ((UINT32) OptionType >= LoadOptionTypeMax) {
+ if ((UINT32)OptionType >= LoadOptionTypeMax) {
return EFI_INVALID_PARAMETER;
}
ZeroMem (Option, sizeof (EFI_BOOT_MANAGER_LOAD_OPTION));
- Option->OptionNumber = OptionNumber;
- Option->OptionType = OptionType;
- Option->Attributes = Attributes;
- Option->Description = AllocateCopyPool (StrSize (Description), Description);
- Option->FilePath = DuplicateDevicePath (FilePath);
+ Option->OptionNumber = OptionNumber;
+ Option->OptionType = OptionType;
+ Option->Attributes = Attributes;
+ Option->Description = AllocateCopyPool (StrSize (Description), Description);
+ Option->FilePath = DuplicateDevicePath (FilePath);
if (OptionalData != NULL) {
Option->OptionalData = AllocateCopyPool (OptionalDataSize, OptionalData);
Option->OptionalDataSize = OptionalDataSize;
@@ -507,7 +519,6 @@ EfiBootManagerInitializeLoadOption ( return EFI_SUCCESS;
}
-
/**
Return the index of the load option in the load option array.
@@ -524,12 +535,12 @@ EfiBootManagerInitializeLoadOption ( INTN
EFIAPI
EfiBootManagerFindLoadOption (
- IN CONST EFI_BOOT_MANAGER_LOAD_OPTION *Key,
- IN CONST EFI_BOOT_MANAGER_LOAD_OPTION *Array,
- IN UINTN Count
+ IN CONST EFI_BOOT_MANAGER_LOAD_OPTION *Key,
+ IN CONST EFI_BOOT_MANAGER_LOAD_OPTION *Array,
+ IN UINTN Count
)
{
- UINTN Index;
+ UINTN Index;
for (Index = 0; Index < Count; Index++) {
if ((Key->OptionType == Array[Index].OptionType) &&
@@ -537,8 +548,9 @@ EfiBootManagerFindLoadOption ( (StrCmp (Key->Description, Array[Index].Description) == 0) &&
(CompareMem (Key->FilePath, Array[Index].FilePath, GetDevicePathSize (Key->FilePath)) == 0) &&
(Key->OptionalDataSize == Array[Index].OptionalDataSize) &&
- (CompareMem (Key->OptionalData, Array[Index].OptionalData, Key->OptionalDataSize) == 0)) {
- return (INTN) Index;
+ (CompareMem (Key->OptionalData, Array[Index].OptionalData, Key->OptionalDataSize) == 0))
+ {
+ return (INTN)Index;
}
}
@@ -563,21 +575,21 @@ EfiBootManagerDeleteLoadOptionVariable ( IN EFI_BOOT_MANAGER_LOAD_OPTION_TYPE OptionType
)
{
- UINT16 *OptionOrder;
- UINTN OptionOrderSize;
- UINTN Index;
- CHAR16 OptionName[BM_OPTION_NAME_LEN];
+ UINT16 *OptionOrder;
+ UINTN OptionOrderSize;
+ UINTN Index;
+ CHAR16 OptionName[BM_OPTION_NAME_LEN];
- if (((UINT32) OptionType >= LoadOptionTypeMax) || (OptionNumber >= LoadOptionNumberMax)) {
+ if (((UINT32)OptionType >= LoadOptionTypeMax) || (OptionNumber >= LoadOptionNumberMax)) {
return EFI_INVALID_PARAMETER;
}
- if (OptionType == LoadOptionTypeDriver || OptionType == LoadOptionTypeSysPrep || OptionType == LoadOptionTypeBoot) {
+ if ((OptionType == LoadOptionTypeDriver) || (OptionType == LoadOptionTypeSysPrep) || (OptionType == LoadOptionTypeBoot)) {
//
// If the associated *Order exists, firstly remove the reference in *Order for
// Driver####, SysPrep#### and Boot####.
//
- GetEfiGlobalVariable2 (mBmLoadOptionOrderName[OptionType], (VOID **) &OptionOrder, &OptionOrderSize);
+ GetEfiGlobalVariable2 (mBmLoadOptionOrderName[OptionType], (VOID **)&OptionOrder, &OptionOrderSize);
ASSERT ((OptionOrder != NULL && OptionOrderSize != 0) || (OptionOrder == NULL && OptionOrderSize == 0));
for (Index = 0; Index < OptionOrderSize / sizeof (UINT16); Index++) {
@@ -594,6 +606,7 @@ EfiBootManagerDeleteLoadOptionVariable ( break;
}
}
+
if (OptionOrder != NULL) {
FreePool (OptionOrder);
}
@@ -650,12 +663,15 @@ BmGetDevicePathSizeEx ( if (NodeSize == 0) {
return 0;
}
+
Size += NodeSize;
if (Size > MaxSize) {
return 0;
}
+
DevicePath = NextDevicePathNode (DevicePath);
}
+
Size += DevicePathNodeLength (DevicePath);
if (Size > MaxSize) {
return 0;
@@ -684,18 +700,19 @@ BmGetDevicePathSizeEx ( **/
UINTN
BmStrSizeEx (
- IN CONST CHAR16 *String,
- IN UINTN MaxStringLen
+ IN CONST CHAR16 *String,
+ IN UINTN MaxStringLen
)
{
- UINTN Length;
+ UINTN Length;
ASSERT (String != NULL && MaxStringLen != 0);
- ASSERT (((UINTN) String & BIT0) == 0);
+ ASSERT (((UINTN)String & BIT0) == 0);
- for (Length = 0; *String != L'\0' && MaxStringLen != Length; String++, Length+=2);
+ for (Length = 0; *String != L'\0' && MaxStringLen != Length; String++, Length += 2) {
+ }
- if (*String != L'\0' && MaxStringLen == Length) {
+ if ((*String != L'\0') && (MaxStringLen == Length)) {
return 0;
}
@@ -715,8 +732,8 @@ BmStrSizeEx ( **/
BOOLEAN
BmValidateOption (
- UINT8 *Variable,
- UINTN VariableSize
+ UINT8 *Variable,
+ UINTN VariableSize
)
{
UINT16 FilePathSize;
@@ -735,19 +752,19 @@ BmValidateOption ( //
// Get the option's device path size
//
- FilePathSize = ReadUnaligned16 ((UINT16 *) Variable);
- Variable += sizeof (UINT16);
+ FilePathSize = ReadUnaligned16 ((UINT16 *)Variable);
+ Variable += sizeof (UINT16);
//
// Get the option's description string size
//
- DescriptionSize = BmStrSizeEx ((CHAR16 *) Variable, VariableSize - sizeof (UINT16) - sizeof (UINT32));
- Variable += DescriptionSize;
+ DescriptionSize = BmStrSizeEx ((CHAR16 *)Variable, VariableSize - sizeof (UINT16) - sizeof (UINT32));
+ Variable += DescriptionSize;
//
// Get the option's device path
//
- DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) Variable;
+ DevicePath = (EFI_DEVICE_PATH_PROTOCOL *)Variable;
//
// Validation boot option variable.
@@ -760,7 +777,7 @@ BmValidateOption ( return FALSE;
}
- return (BOOLEAN) (BmGetDevicePathSizeEx (DevicePath, FilePathSize) != 0);
+ return (BOOLEAN)(BmGetDevicePathSizeEx (DevicePath, FilePathSize) != 0);
}
/**
@@ -778,16 +795,16 @@ BmValidateOption ( BOOLEAN
EFIAPI
EfiBootManagerIsValidLoadOptionVariableName (
- IN CHAR16 *VariableName,
- OUT EFI_BOOT_MANAGER_LOAD_OPTION_TYPE *OptionType OPTIONAL,
- OUT UINT16 *OptionNumber OPTIONAL
+ IN CHAR16 *VariableName,
+ OUT EFI_BOOT_MANAGER_LOAD_OPTION_TYPE *OptionType OPTIONAL,
+ OUT UINT16 *OptionNumber OPTIONAL
)
{
- UINTN VariableNameLen;
- UINTN Index;
- UINTN Uint;
- EFI_BOOT_MANAGER_LOAD_OPTION_TYPE LocalOptionType;
- UINT16 LocalOptionNumber;
+ UINTN VariableNameLen;
+ UINTN Index;
+ UINTN Uint;
+ EFI_BOOT_MANAGER_LOAD_OPTION_TYPE LocalOptionType;
+ UINT16 LocalOptionNumber;
if (VariableName == NULL) {
return FALSE;
@@ -808,10 +825,12 @@ EfiBootManagerIsValidLoadOptionVariableName ( for (LocalOptionType = 0; LocalOptionType < ARRAY_SIZE (mBmLoadOptionName); LocalOptionType++) {
if ((VariableNameLen - 4 == StrLen (mBmLoadOptionName[LocalOptionType])) &&
(StrnCmp (VariableName, mBmLoadOptionName[LocalOptionType], VariableNameLen - 4) == 0)
- ) {
+ )
+ {
break;
}
}
+
if (LocalOptionType == ARRAY_SIZE (mBmLoadOptionName)) {
return FALSE;
}
@@ -825,9 +844,10 @@ EfiBootManagerIsValidLoadOptionVariableName ( if (Uint == -1) {
break;
} else {
- LocalOptionNumber = (UINT16) Uint + LocalOptionNumber * 0x10;
+ LocalOptionNumber = (UINT16)Uint + LocalOptionNumber * 0x10;
}
}
+
if (Index != VariableNameLen) {
return FALSE;
}
@@ -857,9 +877,9 @@ EfiBootManagerIsValidLoadOptionVariableName ( EFI_STATUS
EFIAPI
EfiBootManagerVariableToLoadOptionEx (
- IN CHAR16 *VariableName,
- IN EFI_GUID *VendorGuid,
- IN OUT EFI_BOOT_MANAGER_LOAD_OPTION *Option
+ IN CHAR16 *VariableName,
+ IN EFI_GUID *VendorGuid,
+ IN OUT EFI_BOOT_MANAGER_LOAD_OPTION *Option
)
{
EFI_STATUS Status;
@@ -886,7 +906,7 @@ EfiBootManagerVariableToLoadOptionEx ( //
// Read the variable
//
- GetVariable2 (VariableName, VendorGuid, (VOID **) &Variable, &VariableSize);
+ GetVariable2 (VariableName, VendorGuid, (VOID **)&Variable, &VariableSize);
if (Variable == NULL) {
return EFI_NOT_FOUND;
}
@@ -894,7 +914,7 @@ EfiBootManagerVariableToLoadOptionEx ( //
// Validate *#### variable data.
//
- if (!BmValidateOption(Variable, VariableSize)) {
+ if (!BmValidateOption (Variable, VariableSize)) {
FreePool (Variable);
return EFI_INVALID_PARAMETER;
}
@@ -902,33 +922,33 @@ EfiBootManagerVariableToLoadOptionEx ( //
// Get the option attribute
//
- VariablePtr = Variable;
- Attribute = ReadUnaligned32 ((UINT32 *) VariablePtr);
+ VariablePtr = Variable;
+ Attribute = ReadUnaligned32 ((UINT32 *)VariablePtr);
VariablePtr += sizeof (UINT32);
//
// Get the option's device path size
//
- FilePathSize = ReadUnaligned16 ((UINT16 *) VariablePtr);
+ FilePathSize = ReadUnaligned16 ((UINT16 *)VariablePtr);
VariablePtr += sizeof (UINT16);
//
// Get the option's description string
//
- Description = (CHAR16 *) VariablePtr;
+ Description = (CHAR16 *)VariablePtr;
//
// Get the option's description string size
//
- VariablePtr += StrSize ((CHAR16 *) VariablePtr);
+ VariablePtr += StrSize ((CHAR16 *)VariablePtr);
//
// Get the option's device path
//
- FilePath = (EFI_DEVICE_PATH_PROTOCOL *) VariablePtr;
+ FilePath = (EFI_DEVICE_PATH_PROTOCOL *)VariablePtr;
VariablePtr += FilePathSize;
- OptionalDataSize = (UINT32) (VariableSize - ((UINTN) VariablePtr - (UINTN) Variable));
+ OptionalDataSize = (UINT32)(VariableSize - ((UINTN)VariablePtr - (UINTN)Variable));
if (OptionalDataSize == 0) {
OptionalData = NULL;
} else {
@@ -965,18 +985,18 @@ Build the Boot#### or Driver#### option from the VariableName. EFI_STATUS
EFIAPI
EfiBootManagerVariableToLoadOption (
- IN CHAR16 *VariableName,
- IN OUT EFI_BOOT_MANAGER_LOAD_OPTION *Option
+ IN CHAR16 *VariableName,
+ IN OUT EFI_BOOT_MANAGER_LOAD_OPTION *Option
)
{
return EfiBootManagerVariableToLoadOptionEx (VariableName, &gEfiGlobalVariableGuid, Option);
}
typedef struct {
- EFI_BOOT_MANAGER_LOAD_OPTION_TYPE OptionType;
- EFI_GUID *Guid;
- EFI_BOOT_MANAGER_LOAD_OPTION *Options;
- UINTN OptionCount;
+ EFI_BOOT_MANAGER_LOAD_OPTION_TYPE OptionType;
+ EFI_GUID *Guid;
+ EFI_BOOT_MANAGER_LOAD_OPTION *Options;
+ UINTN OptionCount;
} BM_COLLECT_LOAD_OPTIONS_PARAM;
/**
@@ -989,25 +1009,26 @@ typedef struct { **/
VOID
BmCollectLoadOptions (
- IN CHAR16 *Name,
- IN EFI_GUID *Guid,
- IN VOID *Context
+ IN CHAR16 *Name,
+ IN EFI_GUID *Guid,
+ IN VOID *Context
)
{
- EFI_STATUS Status;
- EFI_BOOT_MANAGER_LOAD_OPTION_TYPE OptionType;
- UINT16 OptionNumber;
- EFI_BOOT_MANAGER_LOAD_OPTION Option;
- UINTN Index;
- BM_COLLECT_LOAD_OPTIONS_PARAM *Param;
+ EFI_STATUS Status;
+ EFI_BOOT_MANAGER_LOAD_OPTION_TYPE OptionType;
+ UINT16 OptionNumber;
+ EFI_BOOT_MANAGER_LOAD_OPTION Option;
+ UINTN Index;
+ BM_COLLECT_LOAD_OPTIONS_PARAM *Param;
- Param = (BM_COLLECT_LOAD_OPTIONS_PARAM *) Context;
+ Param = (BM_COLLECT_LOAD_OPTIONS_PARAM *)Context;
if (CompareGuid (Guid, Param->Guid) && (
- Param->OptionType == LoadOptionTypePlatformRecovery &&
- EfiBootManagerIsValidLoadOptionVariableName (Name, &OptionType, &OptionNumber) &&
- OptionType == LoadOptionTypePlatformRecovery
- )) {
+ (Param->OptionType == LoadOptionTypePlatformRecovery) &&
+ EfiBootManagerIsValidLoadOptionVariableName (Name, &OptionType, &OptionNumber) &&
+ (OptionType == LoadOptionTypePlatformRecovery)
+ ))
+ {
Status = EfiBootManagerVariableToLoadOptionEx (Name, Guid, &Option);
if (!EFI_ERROR (Status)) {
for (Index = 0; Index < Param->OptionCount; Index++) {
@@ -1015,6 +1036,7 @@ BmCollectLoadOptions ( break;
}
}
+
Param->Options = ReallocatePool (
Param->OptionCount * sizeof (EFI_BOOT_MANAGER_LOAD_OPTION),
(Param->OptionCount + 1) * sizeof (EFI_BOOT_MANAGER_LOAD_OPTION),
@@ -1047,24 +1069,24 @@ EfiBootManagerGetLoadOptions ( IN EFI_BOOT_MANAGER_LOAD_OPTION_TYPE LoadOptionType
)
{
- EFI_STATUS Status;
- UINT16 *OptionOrder;
- UINTN OptionOrderSize;
- UINTN Index;
- UINTN OptionIndex;
- EFI_BOOT_MANAGER_LOAD_OPTION *Options;
- CHAR16 OptionName[BM_OPTION_NAME_LEN];
- UINT16 OptionNumber;
- BM_COLLECT_LOAD_OPTIONS_PARAM Param;
+ EFI_STATUS Status;
+ UINT16 *OptionOrder;
+ UINTN OptionOrderSize;
+ UINTN Index;
+ UINTN OptionIndex;
+ EFI_BOOT_MANAGER_LOAD_OPTION *Options;
+ CHAR16 OptionName[BM_OPTION_NAME_LEN];
+ UINT16 OptionNumber;
+ BM_COLLECT_LOAD_OPTIONS_PARAM Param;
*OptionCount = 0;
Options = NULL;
- if (LoadOptionType == LoadOptionTypeDriver || LoadOptionType == LoadOptionTypeSysPrep || LoadOptionType == LoadOptionTypeBoot) {
+ if ((LoadOptionType == LoadOptionTypeDriver) || (LoadOptionType == LoadOptionTypeSysPrep) || (LoadOptionType == LoadOptionTypeBoot)) {
//
// Read the BootOrder, or DriverOrder variable.
//
- GetEfiGlobalVariable2 (mBmLoadOptionOrderName[LoadOptionType], (VOID **) &OptionOrder, &OptionOrderSize);
+ GetEfiGlobalVariable2 (mBmLoadOptionOrderName[LoadOptionType], (VOID **)&OptionOrder, &OptionOrderSize);
if (OptionOrder == NULL) {
return NULL;
}
@@ -1098,17 +1120,16 @@ EfiBootManagerGetLoadOptions ( ASSERT (Options != NULL);
*OptionCount = OptionIndex;
}
-
} else if (LoadOptionType == LoadOptionTypePlatformRecovery) {
- Param.OptionType = LoadOptionTypePlatformRecovery;
- Param.Options = NULL;
+ Param.OptionType = LoadOptionTypePlatformRecovery;
+ Param.Options = NULL;
Param.OptionCount = 0;
- Param.Guid = &gEfiGlobalVariableGuid;
+ Param.Guid = &gEfiGlobalVariableGuid;
- BmForEachVariable (BmCollectLoadOptions, (VOID *) &Param);
+ BmForEachVariable (BmCollectLoadOptions, (VOID *)&Param);
*OptionCount = Param.OptionCount;
- Options = Param.Options;
+ Options = Param.Options;
}
return Options;
@@ -1136,9 +1157,11 @@ EfiBootManagerFreeLoadOption ( if (LoadOption->Description != NULL) {
FreePool (LoadOption->Description);
}
+
if (LoadOption->FilePath != NULL) {
FreePool (LoadOption->FilePath);
}
+
if (LoadOption->OptionalData != NULL) {
FreePool (LoadOption->OptionalData);
}
@@ -1164,13 +1187,13 @@ EfiBootManagerFreeLoadOptions ( IN UINTN OptionCount
)
{
- UINTN Index;
+ UINTN Index;
if (Option == NULL) {
return EFI_NOT_FOUND;
}
- for (Index = 0;Index < OptionCount; Index++) {
+ for (Index = 0; Index < OptionCount; Index++) {
EfiBootManagerFreeLoadOption (&Option[Index]);
}
@@ -1195,40 +1218,43 @@ EfiBootManagerFreeLoadOptions ( **/
BOOLEAN
BmIsLoadOptionPeHeaderValid (
- IN EFI_BOOT_MANAGER_LOAD_OPTION_TYPE Type,
- IN VOID *FileBuffer,
- IN UINTN FileSize
+ IN EFI_BOOT_MANAGER_LOAD_OPTION_TYPE Type,
+ IN VOID *FileBuffer,
+ IN UINTN FileSize
)
{
- EFI_IMAGE_DOS_HEADER *DosHeader;
- EFI_IMAGE_OPTIONAL_HEADER_UNION *PeHeader;
- EFI_IMAGE_OPTIONAL_HEADER32 *OptionalHeader;
- UINT16 Subsystem;
+ EFI_IMAGE_DOS_HEADER *DosHeader;
+ EFI_IMAGE_OPTIONAL_HEADER_UNION *PeHeader;
+ EFI_IMAGE_OPTIONAL_HEADER32 *OptionalHeader;
+ UINT16 Subsystem;
- if (FileBuffer == NULL || FileSize == 0) {
+ if ((FileBuffer == NULL) || (FileSize == 0)) {
return FALSE;
}
//
// Read dos header
//
- DosHeader = (EFI_IMAGE_DOS_HEADER *) FileBuffer;
- if (FileSize >= sizeof (EFI_IMAGE_DOS_HEADER) &&
- FileSize > DosHeader->e_lfanew && DosHeader->e_magic == EFI_IMAGE_DOS_SIGNATURE
- ) {
+ DosHeader = (EFI_IMAGE_DOS_HEADER *)FileBuffer;
+ if ((FileSize >= sizeof (EFI_IMAGE_DOS_HEADER)) &&
+ (FileSize > DosHeader->e_lfanew) && (DosHeader->e_magic == EFI_IMAGE_DOS_SIGNATURE)
+ )
+ {
//
// Read and check PE signature
//
- PeHeader = (EFI_IMAGE_OPTIONAL_HEADER_UNION *) ((UINT8 *) FileBuffer + DosHeader->e_lfanew);
- if (FileSize >= DosHeader->e_lfanew + sizeof (EFI_IMAGE_OPTIONAL_HEADER_UNION) &&
- PeHeader->Pe32.Signature == EFI_IMAGE_NT_SIGNATURE
- ) {
+ PeHeader = (EFI_IMAGE_OPTIONAL_HEADER_UNION *)((UINT8 *)FileBuffer + DosHeader->e_lfanew);
+ if ((FileSize >= DosHeader->e_lfanew + sizeof (EFI_IMAGE_OPTIONAL_HEADER_UNION)) &&
+ (PeHeader->Pe32.Signature == EFI_IMAGE_NT_SIGNATURE)
+ )
+ {
//
// Check PE32 or PE32+ magic, and machine type
//
- OptionalHeader = (EFI_IMAGE_OPTIONAL_HEADER32 *) &PeHeader->Pe32.OptionalHeader;
- if (OptionalHeader->Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC ||
- OptionalHeader->Magic == EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC) {
+ OptionalHeader = (EFI_IMAGE_OPTIONAL_HEADER32 *)&PeHeader->Pe32.OptionalHeader;
+ if ((OptionalHeader->Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) ||
+ (OptionalHeader->Magic == EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC))
+ {
//
// Check the Subsystem:
// Driver#### must be of type BootServiceDriver or RuntimeDriver
@@ -1236,12 +1262,13 @@ BmIsLoadOptionPeHeaderValid ( //
Subsystem = OptionalHeader->Subsystem;
if ((Type == LoadOptionTypeMax) ||
- (Type == LoadOptionTypeDriver && Subsystem == EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER) ||
- (Type == LoadOptionTypeDriver && Subsystem == EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER) ||
- (Type == LoadOptionTypeSysPrep && Subsystem == EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION) ||
- (Type == LoadOptionTypeBoot && Subsystem == EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION) ||
- (Type == LoadOptionTypePlatformRecovery && Subsystem == EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION)
- ) {
+ ((Type == LoadOptionTypeDriver) && (Subsystem == EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER)) ||
+ ((Type == LoadOptionTypeDriver) && (Subsystem == EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER)) ||
+ ((Type == LoadOptionTypeSysPrep) && (Subsystem == EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION)) ||
+ ((Type == LoadOptionTypeBoot) && (Subsystem == EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION)) ||
+ ((Type == LoadOptionTypePlatformRecovery) && (Subsystem == EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION))
+ )
+ {
return TRUE;
}
}
@@ -1273,22 +1300,22 @@ BmIsLoadOptionPeHeaderValid ( **/
VOID *
BmGetNextLoadOptionBuffer (
- IN EFI_BOOT_MANAGER_LOAD_OPTION_TYPE Type,
- IN EFI_DEVICE_PATH_PROTOCOL *FilePath,
- OUT EFI_DEVICE_PATH_PROTOCOL **FullPath,
- OUT UINTN *FileSize
+ IN EFI_BOOT_MANAGER_LOAD_OPTION_TYPE Type,
+ IN EFI_DEVICE_PATH_PROTOCOL *FilePath,
+ OUT EFI_DEVICE_PATH_PROTOCOL **FullPath,
+ OUT UINTN *FileSize
)
{
- VOID *FileBuffer;
- EFI_DEVICE_PATH_PROTOCOL *PreFullPath;
- EFI_DEVICE_PATH_PROTOCOL *CurFullPath;
- UINTN LocalFileSize;
- UINT32 AuthenticationStatus;
- EFI_DEVICE_PATH_PROTOCOL *RamDiskDevicePath;
+ VOID *FileBuffer;
+ EFI_DEVICE_PATH_PROTOCOL *PreFullPath;
+ EFI_DEVICE_PATH_PROTOCOL *CurFullPath;
+ UINTN LocalFileSize;
+ UINT32 AuthenticationStatus;
+ EFI_DEVICE_PATH_PROTOCOL *RamDiskDevicePath;
LocalFileSize = 0;
- FileBuffer = NULL;
- CurFullPath = *FullPath;
+ FileBuffer = NULL;
+ CurFullPath = *FullPath;
do {
PreFullPath = CurFullPath;
CurFullPath = BmGetNextLoadOptionDevicePath (FilePath, CurFullPath);
@@ -1298,9 +1325,11 @@ BmGetNextLoadOptionBuffer ( if ((PreFullPath != NULL) && (PreFullPath != *FullPath)) {
FreePool (PreFullPath);
}
+
if (CurFullPath == NULL) {
break;
}
+
FileBuffer = GetFileBufferByFilePath (TRUE, CurFullPath, &LocalFileSize, &AuthenticationStatus);
if ((FileBuffer != NULL) && !BmIsLoadOptionPeHeaderValid (Type, FileBuffer, LocalFileSize)) {
//
@@ -1321,7 +1350,7 @@ BmGetNextLoadOptionBuffer ( } while (FileBuffer == NULL);
if (FileBuffer == NULL) {
- CurFullPath = NULL;
+ CurFullPath = NULL;
LocalFileSize = 0;
}
@@ -1349,18 +1378,18 @@ BmGetNextLoadOptionBuffer ( EFI_STATUS
EFIAPI
EfiBootManagerProcessLoadOption (
- IN EFI_BOOT_MANAGER_LOAD_OPTION *LoadOption
+ IN EFI_BOOT_MANAGER_LOAD_OPTION *LoadOption
)
{
- EFI_STATUS Status;
- EFI_DEVICE_PATH_PROTOCOL *PreFullPath;
- EFI_DEVICE_PATH_PROTOCOL *CurFullPath;
- EFI_HANDLE ImageHandle;
- EFI_LOADED_IMAGE_PROTOCOL *ImageInfo;
- VOID *FileBuffer;
- UINTN FileSize;
-
- if ((UINT32) LoadOption->OptionType >= LoadOptionTypeMax) {
+ EFI_STATUS Status;
+ EFI_DEVICE_PATH_PROTOCOL *PreFullPath;
+ EFI_DEVICE_PATH_PROTOCOL *CurFullPath;
+ EFI_HANDLE ImageHandle;
+ EFI_LOADED_IMAGE_PROTOCOL *ImageInfo;
+ VOID *FileBuffer;
+ UINTN FileSize;
+
+ if ((UINT32)LoadOption->OptionType >= LoadOptionTypeMax) {
return EFI_INVALID_PARAMETER;
}
@@ -1380,8 +1409,10 @@ EfiBootManagerProcessLoadOption ( // Load and start the load option.
//
DEBUG ((
- DEBUG_INFO | DEBUG_LOAD, "Process %s%04x (%s) ...\n",
- mBmLoadOptionName[LoadOption->OptionType], LoadOption->OptionNumber,
+ DEBUG_INFO | DEBUG_LOAD,
+ "Process %s%04x (%s) ...\n",
+ mBmLoadOptionName[LoadOption->OptionType],
+ LoadOption->OptionNumber,
LoadOption->Description
));
ImageHandle = NULL;
@@ -1398,9 +1429,11 @@ EfiBootManagerProcessLoadOption ( if (PreFullPath != NULL) {
FreePool (PreFullPath);
}
+
if (FileBuffer == NULL) {
break;
}
+
Status = gBS->LoadImage (
FALSE,
gImageHandle,
@@ -1426,7 +1459,7 @@ EfiBootManagerProcessLoadOption ( ASSERT_EFI_ERROR (Status);
ImageInfo->LoadOptionsSize = LoadOption->OptionalDataSize;
- ImageInfo->LoadOptions = LoadOption->OptionalData;
+ ImageInfo->LoadOptions = LoadOption->OptionalData;
//
// Before calling the image, enable the Watchdog Timer for the 5-minute period
//
@@ -1434,9 +1467,12 @@ EfiBootManagerProcessLoadOption ( LoadOption->Status = gBS->StartImage (ImageHandle, &LoadOption->ExitDataSize, &LoadOption->ExitData);
DEBUG ((
- DEBUG_INFO | DEBUG_LOAD, "%s%04x Return Status = %r\n",
- mBmLoadOptionName[LoadOption->OptionType], LoadOption->OptionNumber, LoadOption->Status
- ));
+ DEBUG_INFO | DEBUG_LOAD,
+ "%s%04x Return Status = %r\n",
+ mBmLoadOptionName[LoadOption->OptionType],
+ LoadOption->OptionNumber,
+ LoadOption->Status
+ ));
//
// Clear the Watchdog Timer after the image returns
diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c b/MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c index 6e7af3e3d9..a5e32ebdba 100644 --- a/MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c +++ b/MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c @@ -37,27 +37,27 @@ BmDelPartMatchInstance ( NewDevicePath = NULL;
TempNewDevicePath = NULL;
- if (Multi == NULL || Single == NULL) {
+ if ((Multi == NULL) || (Single == NULL)) {
return Multi;
}
- Instance = GetNextDevicePathInstance (&Multi, &InstanceSize);
- SingleDpSize = GetDevicePathSize (Single) - END_DEVICE_PATH_LENGTH;
- InstanceSize -= END_DEVICE_PATH_LENGTH;
+ Instance = GetNextDevicePathInstance (&Multi, &InstanceSize);
+ SingleDpSize = GetDevicePathSize (Single) - END_DEVICE_PATH_LENGTH;
+ InstanceSize -= END_DEVICE_PATH_LENGTH;
while (Instance != NULL) {
-
if (CompareMem (Instance, Single, MIN (SingleDpSize, InstanceSize)) != 0) {
//
// Append the device path instance which does not match with Single
//
TempNewDevicePath = NewDevicePath;
- NewDevicePath = AppendDevicePathInstance (NewDevicePath, Instance);
+ NewDevicePath = AppendDevicePathInstance (NewDevicePath, Instance);
if (TempNewDevicePath != NULL) {
- FreePool(TempNewDevicePath);
+ FreePool (TempNewDevicePath);
}
}
- FreePool(Instance);
+
+ FreePool (Instance);
Instance = GetNextDevicePathInstance (&Multi, &InstanceSize);
InstanceSize -= END_DEVICE_PATH_LENGTH;
}
@@ -88,7 +88,7 @@ BmMatchDevicePaths ( EFI_DEVICE_PATH_PROTOCOL *DevicePathInst;
UINTN Size;
- if (Multi == NULL || Single == NULL) {
+ if ((Multi == NULL) || (Single == NULL)) {
return FALSE;
}
@@ -127,7 +127,7 @@ BmMatchDevicePaths ( **/
VOID
BmSetMemoryTypeInformationVariable (
- IN BOOLEAN Boot
+ IN BOOLEAN Boot
)
{
EFI_STATUS Status;
@@ -147,7 +147,6 @@ BmSetMemoryTypeInformationVariable ( MemoryTypeInformationModified = FALSE;
MemoryTypeInformationVariableExists = FALSE;
-
BootMode = GetBootModeHob ();
//
// In BOOT_IN_RECOVERY_MODE, Variable region is not reliable.
@@ -163,13 +162,13 @@ BmSetMemoryTypeInformationVariable ( //
if (BootMode != BOOT_WITH_DEFAULT_SETTINGS) {
VariableSize = 0;
- Status = gRT->GetVariable (
- EFI_MEMORY_TYPE_INFORMATION_VARIABLE_NAME,
- &gEfiMemoryTypeInformationGuid,
- NULL,
- &VariableSize,
- NULL
- );
+ Status = gRT->GetVariable (
+ EFI_MEMORY_TYPE_INFORMATION_VARIABLE_NAME,
+ &gEfiMemoryTypeInformationGuid,
+ NULL,
+ &VariableSize,
+ NULL
+ );
if (Status == EFI_BUFFER_TOO_SMALL) {
MemoryTypeInformationVariableExists = TRUE;
}
@@ -181,9 +180,9 @@ BmSetMemoryTypeInformationVariable ( //
Status = EfiGetSystemConfigurationTable (
&gEfiMemoryTypeInformationGuid,
- (VOID **) &CurrentMemoryTypeInformation
+ (VOID **)&CurrentMemoryTypeInformation
);
- if (EFI_ERROR (Status) || CurrentMemoryTypeInformation == NULL) {
+ if (EFI_ERROR (Status) || (CurrentMemoryTypeInformation == NULL)) {
return;
}
@@ -199,6 +198,7 @@ BmSetMemoryTypeInformationVariable ( //
return;
}
+
VariableSize = GET_GUID_HOB_DATA_SIZE (GuidHob);
PreviousMemoryTypeInformation = AllocateCopyPool (VariableSize, GET_GUID_HOB_DATA (GuidHob));
if (PreviousMemoryTypeInformation == NULL) {
@@ -213,12 +213,12 @@ BmSetMemoryTypeInformationVariable ( DEBUG ((DEBUG_INFO, "====== ======== ======== ========\n"));
for (Index = 0; PreviousMemoryTypeInformation[Index].Type != EfiMaxMemoryType; Index++) {
-
for (Index1 = 0; CurrentMemoryTypeInformation[Index1].Type != EfiMaxMemoryType; Index1++) {
if (PreviousMemoryTypeInformation[Index].Type == CurrentMemoryTypeInformation[Index1].Type) {
break;
}
}
+
if (CurrentMemoryTypeInformation[Index1].Type == EfiMaxMemoryType) {
continue;
}
@@ -244,13 +244,14 @@ BmSetMemoryTypeInformationVariable ( } else if (Current > Previous) {
Next = Current + (Current >> 2);
}
- if (Next > 0 && Next < 4) {
+
+ if ((Next > 0) && (Next < 4)) {
Next = 4;
}
if (Next != Previous) {
PreviousMemoryTypeInformation[Index].NumberOfPages = Next;
- MemoryTypeInformationModified = TRUE;
+ MemoryTypeInformationModified = TRUE;
}
DEBUG ((DEBUG_INFO, " %02x %08x %08x %08x\n", PreviousMemoryTypeInformation[Index].Type, Previous, Current, Next));
@@ -286,6 +287,7 @@ BmSetMemoryTypeInformationVariable ( DEBUG ((DEBUG_ERROR, "Memory Type Information settings cannot be saved. OS S4 may fail!\n"));
}
}
+
FreePool (PreviousMemoryTypeInformation);
}
@@ -324,11 +326,11 @@ BmSetMemoryTypeInformationVariable ( **/
EFI_STATUS
BmSetVariableAndReportStatusCodeOnError (
- IN CHAR16 *VariableName,
- IN EFI_GUID *VendorGuid,
- IN UINT32 Attributes,
- IN UINTN DataSize,
- IN VOID *Data
+ IN CHAR16 *VariableName,
+ IN EFI_GUID *VendorGuid,
+ IN UINT32 Attributes,
+ IN UINTN DataSize,
+ IN VOID *Data
)
{
EFI_STATUS Status;
@@ -343,7 +345,7 @@ BmSetVariableAndReportStatusCodeOnError ( Data
);
if (EFI_ERROR (Status)) {
- NameSize = StrSize (VariableName);
+ NameSize = StrSize (VariableName);
SetVariableStatus = AllocatePool (sizeof (EDKII_SET_VARIABLE_STATUS) + NameSize + DataSize);
if (SetVariableStatus != NULL) {
CopyGuid (&SetVariableStatus->Guid, VendorGuid);
@@ -351,8 +353,8 @@ BmSetVariableAndReportStatusCodeOnError ( SetVariableStatus->DataSize = DataSize;
SetVariableStatus->SetStatus = Status;
SetVariableStatus->Attributes = Attributes;
- CopyMem (SetVariableStatus + 1, VariableName, NameSize);
- CopyMem (((UINT8 *) (SetVariableStatus + 1)) + NameSize, Data, DataSize);
+ CopyMem (SetVariableStatus + 1, VariableName, NameSize);
+ CopyMem (((UINT8 *)(SetVariableStatus + 1)) + NameSize, Data, DataSize);
REPORT_STATUS_CODE_EX (
EFI_ERROR_CODE,
@@ -371,7 +373,6 @@ BmSetVariableAndReportStatusCodeOnError ( return Status;
}
-
/**
Print the device path info.
@@ -379,10 +380,10 @@ BmSetVariableAndReportStatusCodeOnError ( **/
VOID
BmPrintDp (
- EFI_DEVICE_PATH_PROTOCOL *DevicePath
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath
)
{
- CHAR16 *Str;
+ CHAR16 *Str;
Str = ConvertDevicePathToText (DevicePath, FALSE, FALSE);
DEBUG ((DEBUG_INFO, "%s", Str));
@@ -401,7 +402,7 @@ BmPrintDp ( **/
UINTN
BmCharToUint (
- IN CHAR16 Char
+ IN CHAR16 Char
)
{
if ((Char >= L'0') && (Char <= L'9')) {
@@ -412,7 +413,7 @@ BmCharToUint ( return (Char - L'A' + 0xA);
}
- return (UINTN) -1;
+ return (UINTN)-1;
}
/**
@@ -428,32 +429,32 @@ EfiBootManagerDispatchDeferredImages ( VOID
)
{
- EFI_STATUS Status;
- EFI_DEFERRED_IMAGE_LOAD_PROTOCOL *DeferredImage;
- UINTN HandleCount;
- EFI_HANDLE *Handles;
- UINTN Index;
- UINTN ImageIndex;
- EFI_DEVICE_PATH_PROTOCOL *ImageDevicePath;
- VOID *Image;
- UINTN ImageSize;
- BOOLEAN BootOption;
- EFI_HANDLE ImageHandle;
- UINTN ImageCount;
- UINTN LoadCount;
+ EFI_STATUS Status;
+ EFI_DEFERRED_IMAGE_LOAD_PROTOCOL *DeferredImage;
+ UINTN HandleCount;
+ EFI_HANDLE *Handles;
+ UINTN Index;
+ UINTN ImageIndex;
+ EFI_DEVICE_PATH_PROTOCOL *ImageDevicePath;
+ VOID *Image;
+ UINTN ImageSize;
+ BOOLEAN BootOption;
+ EFI_HANDLE ImageHandle;
+ UINTN ImageCount;
+ UINTN LoadCount;
//
// Find all the deferred image load protocols.
//
HandleCount = 0;
- Handles = NULL;
- Status = gBS->LocateHandleBuffer (
- ByProtocol,
- &gEfiDeferredImageLoadProtocolGuid,
- NULL,
- &HandleCount,
- &Handles
- );
+ Handles = NULL;
+ Status = gBS->LocateHandleBuffer (
+ ByProtocol,
+ &gEfiDeferredImageLoadProtocolGuid,
+ NULL,
+ &HandleCount,
+ &Handles
+ );
if (EFI_ERROR (Status)) {
return EFI_NOT_FOUND;
}
@@ -461,12 +462,12 @@ EfiBootManagerDispatchDeferredImages ( ImageCount = 0;
LoadCount = 0;
for (Index = 0; Index < HandleCount; Index++) {
- Status = gBS->HandleProtocol (Handles[Index], &gEfiDeferredImageLoadProtocolGuid, (VOID **) &DeferredImage);
+ Status = gBS->HandleProtocol (Handles[Index], &gEfiDeferredImageLoadProtocolGuid, (VOID **)&DeferredImage);
if (EFI_ERROR (Status)) {
continue;
}
- for (ImageIndex = 0; ;ImageIndex++) {
+ for (ImageIndex = 0; ; ImageIndex++) {
//
// Load all the deferred images in this protocol instance.
//
@@ -474,25 +475,26 @@ EfiBootManagerDispatchDeferredImages ( DeferredImage,
ImageIndex,
&ImageDevicePath,
- (VOID **) &Image,
+ (VOID **)&Image,
&ImageSize,
&BootOption
);
if (EFI_ERROR (Status)) {
break;
}
+
ImageCount++;
//
// Load and start the image.
//
Status = gBS->LoadImage (
- BootOption,
- gImageHandle,
- ImageDevicePath,
- NULL,
- 0,
- &ImageHandle
- );
+ BootOption,
+ gImageHandle,
+ ImageDevicePath,
+ NULL,
+ 0,
+ &ImageHandle
+ );
if (EFI_ERROR (Status)) {
//
// With EFI_SECURITY_VIOLATION retval, the Image was loaded and an ImageHandle was created
@@ -519,6 +521,7 @@ EfiBootManagerDispatchDeferredImages ( }
}
}
+
if (Handles != NULL) {
FreePool (Handles);
}
diff --git a/MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h b/MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h index ac866ac25f..a9b0d485ca 100644 --- a/MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h +++ b/MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h @@ -72,15 +72,15 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include <Library/HiiLib.h>
#if !defined (EFI_REMOVABLE_MEDIA_FILE_NAME)
- #if defined (MDE_CPU_EBC)
- //
- // Uefi specification only defines the default boot file name for IA32, X64
- // and IPF processor, so need define boot file name for EBC architecture here.
- //
- #define EFI_REMOVABLE_MEDIA_FILE_NAME L"\\EFI\\BOOT\\BOOTEBC.EFI"
- #else
- #error "Can not determine the default boot file name for unknown processor type!"
- #endif
+ #if defined (MDE_CPU_EBC)
+//
+// Uefi specification only defines the default boot file name for IA32, X64
+// and IPF processor, so need define boot file name for EBC architecture here.
+//
+#define EFI_REMOVABLE_MEDIA_FILE_NAME L"\\EFI\\BOOT\\BOOTEBC.EFI"
+ #else
+ #error "Can not determine the default boot file name for unknown processor type!"
+ #endif
#endif
typedef enum {
@@ -95,21 +95,21 @@ typedef enum { typedef
CHAR16 *
-(* BM_GET_BOOT_DESCRIPTION) (
- IN EFI_HANDLE Handle
+(*BM_GET_BOOT_DESCRIPTION) (
+ IN EFI_HANDLE Handle
);
//
// PlatformRecovery#### is the load option with the longest name
//
-#define BM_OPTION_NAME_LEN sizeof ("PlatformRecovery####")
+#define BM_OPTION_NAME_LEN sizeof ("PlatformRecovery####")
extern CHAR16 *mBmLoadOptionName[];
//
// Maximum number of reconnect retry to repair controller; it is to limit the
// number of recursive call of BmRepairAllControllers.
//
-#define MAX_RECONNECT_REPAIR 10
+#define MAX_RECONNECT_REPAIR 10
/**
Visitor function to be called by BmForEachVariable for each variable
@@ -122,9 +122,9 @@ extern CHAR16 *mBmLoadOptionName[]; typedef
VOID
(*BM_VARIABLE_VISITOR) (
- CHAR16 *Name,
- EFI_GUID *Guid,
- VOID *Context
+ CHAR16 *Name,
+ EFI_GUID *Guid,
+ VOID *Context
);
/**
@@ -135,15 +135,15 @@ VOID **/
VOID
BmForEachVariable (
- BM_VARIABLE_VISITOR Visitor,
- VOID *Context
+ BM_VARIABLE_VISITOR Visitor,
+ VOID *Context
);
-#define BM_BOOT_DESCRIPTION_ENTRY_SIGNATURE SIGNATURE_32 ('b', 'm', 'd', 'h')
+#define BM_BOOT_DESCRIPTION_ENTRY_SIGNATURE SIGNATURE_32 ('b', 'm', 'd', 'h')
typedef struct {
- UINT32 Signature;
- LIST_ENTRY Link;
- EFI_BOOT_MANAGER_BOOT_DESCRIPTION_HANDLER Handler;
+ UINT32 Signature;
+ LIST_ENTRY Link;
+ EFI_BOOT_MANAGER_BOOT_DESCRIPTION_HANDLER Handler;
} BM_BOOT_DESCRIPTION_ENTRY;
/**
@@ -154,22 +154,22 @@ typedef struct { **/
VOID
BmRepairAllControllers (
- UINTN ReconnectRepairCount
+ UINTN ReconnectRepairCount
);
-#define BM_HOTKEY_SIGNATURE SIGNATURE_32 ('b', 'm', 'h', 'k')
+#define BM_HOTKEY_SIGNATURE SIGNATURE_32 ('b', 'm', 'h', 'k')
typedef struct {
- UINT32 Signature;
- LIST_ENTRY Link;
-
- BOOLEAN IsContinue;
- UINT16 BootOption;
- UINT8 CodeCount;
- UINT8 WaitingKey;
- EFI_KEY_DATA KeyData[3];
+ UINT32 Signature;
+ LIST_ENTRY Link;
+
+ BOOLEAN IsContinue;
+ UINT16 BootOption;
+ UINT8 CodeCount;
+ UINT8 WaitingKey;
+ EFI_KEY_DATA KeyData[3];
} BM_HOTKEY;
-#define BM_HOTKEY_FROM_LINK(a) CR (a, BM_HOTKEY, Link, BM_HOTKEY_SIGNATURE)
+#define BM_HOTKEY_FROM_LINK(a) CR (a, BM_HOTKEY, Link, BM_HOTKEY_SIGNATURE)
/**
Get the Option Number that wasn't used.
@@ -184,8 +184,8 @@ typedef struct { **/
EFI_STATUS
BmGetFreeOptionNumber (
- IN EFI_BOOT_MANAGER_LOAD_OPTION_TYPE LoadOptionType,
- OUT UINT16 *FreeOptionNumber
+ IN EFI_BOOT_MANAGER_LOAD_OPTION_TYPE LoadOptionType,
+ OUT UINT16 *FreeOptionNumber
);
/**
@@ -200,7 +200,7 @@ BmGetFreeOptionNumber ( **/
VOID
BmSetMemoryTypeInformationVariable (
- IN BOOLEAN Boot
+ IN BOOLEAN Boot
);
/**
@@ -217,8 +217,8 @@ BmSetMemoryTypeInformationVariable ( **/
BOOLEAN
BmMatchPartitionDevicePathNode (
- IN EFI_DEVICE_PATH_PROTOCOL *BlockIoDevicePath,
- IN HARDDRIVE_DEVICE_PATH *HardDriveDevicePath
+ IN EFI_DEVICE_PATH_PROTOCOL *BlockIoDevicePath,
+ IN HARDDRIVE_DEVICE_PATH *HardDriveDevicePath
);
/**
@@ -237,7 +237,7 @@ BmMatchPartitionDevicePathNode ( **/
EFI_STATUS
BmConnectUsbShortFormDevicePath (
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
);
/**
@@ -249,8 +249,8 @@ BmConnectUsbShortFormDevicePath ( VOID
EFIAPI
BmStopHotkeyService (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
);
/**
@@ -288,11 +288,11 @@ BmStopHotkeyService ( **/
EFI_STATUS
BmSetVariableAndReportStatusCodeOnError (
- IN CHAR16 *VariableName,
- IN EFI_GUID *VendorGuid,
- IN UINT32 Attributes,
- IN UINTN DataSize,
- IN VOID *Data
+ IN CHAR16 *VariableName,
+ IN EFI_GUID *VendorGuid,
+ IN UINT32 Attributes,
+ IN UINTN DataSize,
+ IN VOID *Data
);
/**
@@ -340,7 +340,7 @@ BmDelPartMatchInstance ( **/
VOID
BmPrintDp (
- EFI_DEVICE_PATH_PROTOCOL *DevicePath
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath
);
/**
@@ -353,7 +353,7 @@ BmPrintDp ( **/
UINTN
BmCharToUint (
- IN CHAR16 Char
+ IN CHAR16 Char
);
/**
@@ -365,7 +365,7 @@ BmCharToUint ( **/
CHAR16 *
BmGetBootDescription (
- IN EFI_HANDLE Handle
+ IN EFI_HANDLE Handle
);
/**
@@ -377,8 +377,8 @@ BmGetBootDescription ( **/
VOID
BmMakeBootOptionDescriptionUnique (
- EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions,
- UINTN BootOptionCount
+ EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions,
+ UINTN BootOptionCount
);
/**
@@ -391,8 +391,8 @@ BmMakeBootOptionDescriptionUnique ( **/
EFI_DEVICE_PATH_PROTOCOL *
BmExpandLoadFile (
- IN EFI_HANDLE LoadFileHandle,
- IN EFI_DEVICE_PATH_PROTOCOL *FilePath
+ IN EFI_HANDLE LoadFileHandle,
+ IN EFI_DEVICE_PATH_PROTOCOL *FilePath
);
/**
@@ -404,7 +404,7 @@ BmExpandLoadFile ( **/
EFI_DEVICE_PATH_PROTOCOL *
BmGetRamDiskDevicePath (
- IN EFI_DEVICE_PATH_PROTOCOL *FilePath
+ IN EFI_DEVICE_PATH_PROTOCOL *FilePath
);
/**
@@ -418,7 +418,7 @@ BmGetRamDiskDevicePath ( **/
VOID
BmDestroyRamDisk (
- IN EFI_DEVICE_PATH_PROTOCOL *RamDiskDevicePath
+ IN EFI_DEVICE_PATH_PROTOCOL *RamDiskDevicePath
);
/**
@@ -434,8 +434,8 @@ BmDestroyRamDisk ( **/
EFI_DEVICE_PATH_PROTOCOL *
BmGetNextLoadOptionDevicePath (
- IN EFI_DEVICE_PATH_PROTOCOL *FilePath,
- IN EFI_DEVICE_PATH_PROTOCOL *FullPath
+ IN EFI_DEVICE_PATH_PROTOCOL *FilePath,
+ IN EFI_DEVICE_PATH_PROTOCOL *FullPath
);
/**
@@ -460,9 +460,10 @@ BmGetNextLoadOptionDevicePath ( **/
VOID *
BmGetNextLoadOptionBuffer (
- IN EFI_BOOT_MANAGER_LOAD_OPTION_TYPE Type,
- IN EFI_DEVICE_PATH_PROTOCOL *FilePath,
- OUT EFI_DEVICE_PATH_PROTOCOL **FullPath,
- OUT UINTN *FileSize
+ IN EFI_BOOT_MANAGER_LOAD_OPTION_TYPE Type,
+ IN EFI_DEVICE_PATH_PROTOCOL *FilePath,
+ OUT EFI_DEVICE_PATH_PROTOCOL **FullPath,
+ OUT UINTN *FileSize
);
+
#endif // _INTERNAL_BM_H_
diff --git a/MdeModulePkg/Library/UefiHiiLib/HiiLanguage.c b/MdeModulePkg/Library/UefiHiiLib/HiiLanguage.c index b2f3723242..47f03d540d 100644 --- a/MdeModulePkg/Library/UefiHiiLib/HiiLanguage.c +++ b/MdeModulePkg/Library/UefiHiiLib/HiiLanguage.c @@ -6,7 +6,6 @@ **/
-
#include "InternalHiiLib.h"
/**
@@ -30,7 +29,7 @@ CHAR8 *
EFIAPI
HiiGetSupportedLanguages (
- IN EFI_HII_HANDLE HiiHandle
+ IN EFI_HII_HANDLE HiiHandle
)
{
EFI_STATUS Status;
@@ -44,7 +43,7 @@ HiiGetSupportedLanguages ( // Retrieve the size required for the supported languages buffer.
//
LanguageSize = 0;
- Status = gHiiString->GetLanguages (gHiiString, HiiHandle, &TempSupportedLanguages, &LanguageSize);
+ Status = gHiiString->GetLanguages (gHiiString, HiiHandle, &TempSupportedLanguages, &LanguageSize);
//
// If GetLanguages() returns EFI_SUCCESS for a zero size,
@@ -87,4 +86,3 @@ HiiGetSupportedLanguages ( //
return SupportedLanguages;
}
-
diff --git a/MdeModulePkg/Library/UefiHiiLib/HiiLib.c b/MdeModulePkg/Library/UefiHiiLib/HiiLib.c index 6cca1ba1d6..63a37ab59a 100644 --- a/MdeModulePkg/Library/UefiHiiLib/HiiLib.c +++ b/MdeModulePkg/Library/UefiHiiLib/HiiLib.c @@ -8,32 +8,32 @@ #include "InternalHiiLib.h"
-#define GUID_CONFIG_STRING_TYPE 0x00
-#define NAME_CONFIG_STRING_TYPE 0x01
-#define PATH_CONFIG_STRING_TYPE 0x02
+#define GUID_CONFIG_STRING_TYPE 0x00
+#define NAME_CONFIG_STRING_TYPE 0x01
+#define PATH_CONFIG_STRING_TYPE 0x02
-#define ACTION_SET_DEFAUTL_VALUE 0x01
-#define ACTION_VALIDATE_SETTING 0x02
+#define ACTION_SET_DEFAUTL_VALUE 0x01
+#define ACTION_VALIDATE_SETTING 0x02
#define HII_LIB_DEFAULT_VARSTORE_SIZE 0x200
typedef struct {
- LIST_ENTRY Entry; // Link to Block array
- UINT16 Offset;
- UINT16 Width;
- UINT8 OpCode;
- UINT8 Scope;
+ LIST_ENTRY Entry; // Link to Block array
+ UINT16 Offset;
+ UINT16 Width;
+ UINT8 OpCode;
+ UINT8 Scope;
} IFR_BLOCK_DATA;
typedef struct {
- EFI_VARSTORE_ID VarStoreId;
- UINT16 Size;
+ EFI_VARSTORE_ID VarStoreId;
+ UINT16 Size;
} IFR_VARSTORAGE_DATA;
//
// <ConfigHdr> Template
//
-GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR16 mConfigHdrTemplate[] = L"GUID=00000000000000000000000000000000&NAME=0000&PATH=00";
+GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR16 mConfigHdrTemplate[] = L"GUID=00000000000000000000000000000000&NAME=0000&PATH=00";
EFI_FORM_BROWSER2_PROTOCOL *mUefiFormBrowser2 = NULL;
@@ -60,8 +60,8 @@ GLOBAL_REMOVE_IF_UNREFERENCED CONST EFI_HII_PACKAGE_HEADER mEndOfPakageList = { EFI_STATUS
EFIAPI
InternalHiiExtractGuidFromHiiHandle (
- IN EFI_HII_HANDLE Handle,
- OUT EFI_GUID *Guid
+ IN EFI_HII_HANDLE Handle,
+ OUT EFI_GUID *Guid
)
{
EFI_STATUS Status;
@@ -74,7 +74,7 @@ InternalHiiExtractGuidFromHiiHandle ( //
// Get HII PackageList
//
- BufferSize = 0;
+ BufferSize = 0;
HiiPackageList = NULL;
Status = gHiiDatabase->ExportPackageLists (gHiiDatabase, Handle, &BufferSize, HiiPackageList);
@@ -86,6 +86,7 @@ InternalHiiExtractGuidFromHiiHandle ( Status = gHiiDatabase->ExportPackageLists (gHiiDatabase, Handle, &BufferSize, HiiPackageList);
}
+
if (EFI_ERROR (Status)) {
FreePool (HiiPackageList);
return Status;
@@ -159,6 +160,7 @@ HiiAddPackages ( for (Length = 0, VA_START (Args, DeviceHandle); (Package = VA_ARG (Args, UINT32 *)) != NULL; ) {
Length += (ReadUnaligned32 (Package) - sizeof (UINT32));
}
+
VA_END (Args);
//
@@ -205,6 +207,7 @@ HiiAddPackages ( CopyMem (Data, Package + 1, Length);
Data += Length;
}
+
VA_END (Args);
//
@@ -248,17 +251,16 @@ HiiAddPackages ( VOID
EFIAPI
HiiRemovePackages (
- IN EFI_HII_HANDLE HiiHandle
+ IN EFI_HII_HANDLE HiiHandle
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
ASSERT (HiiHandle != NULL);
Status = gHiiDatabase->RemovePackageList (gHiiDatabase, HiiHandle);
ASSERT_EFI_ERROR (Status);
}
-
/**
Retrieves the array of all the HII Handles or the HII handles of a specific
package list GUID in the HII Database.
@@ -297,13 +299,13 @@ HiiGetHiiHandles ( // Retrieve the size required for the buffer of all HII handles.
//
HandleBufferLength = 0;
- Status = gHiiDatabase->ListPackageLists (
- gHiiDatabase,
- EFI_HII_PACKAGE_TYPE_ALL,
- NULL,
- &HandleBufferLength,
- &TempHiiHandleBuffer
- );
+ Status = gHiiDatabase->ListPackageLists (
+ gHiiDatabase,
+ EFI_HII_PACKAGE_TYPE_ALL,
+ NULL,
+ &HandleBufferLength,
+ &TempHiiHandleBuffer
+ );
//
// If ListPackageLists() returns EFI_SUCCESS for a zero size,
@@ -361,6 +363,7 @@ HiiGetHiiHandles ( HiiHandleBuffer[Index2++] = HiiHandleBuffer[Index1];
}
}
+
if (Index2 > 0) {
HiiHandleBuffer[Index2] = NULL;
return HiiHandleBuffer;
@@ -388,10 +391,10 @@ HiiGetHiiHandles ( **/
EFI_STATUS
EFIAPI
-HiiGetFormSetFromHiiHandle(
- IN EFI_HII_HANDLE Handle,
- OUT EFI_IFR_FORM_SET **Buffer,
- OUT UINTN *BufferSize
+HiiGetFormSetFromHiiHandle (
+ IN EFI_HII_HANDLE Handle,
+ OUT EFI_IFR_FORM_SET **Buffer,
+ OUT UINTN *BufferSize
)
{
EFI_STATUS Status;
@@ -407,7 +410,7 @@ HiiGetFormSetFromHiiHandle( UINT32 PackageListLength;
EFI_HII_PACKAGE_HEADER PackageHeader;
- TempSize = 0;
+ TempSize = 0;
FormSetBuffer = NULL;
TempBuffer = NULL;
@@ -415,8 +418,8 @@ HiiGetFormSetFromHiiHandle( // Get HII PackageList
//
PackageListSize = 0;
- HiiPackageList = NULL;
- Status = gHiiDatabase->ExportPackageLists (gHiiDatabase, Handle, &PackageListSize, HiiPackageList);
+ HiiPackageList = NULL;
+ Status = gHiiDatabase->ExportPackageLists (gHiiDatabase, Handle, &PackageListSize, HiiPackageList);
if (EFI_ERROR (Status) && (Status != EFI_BUFFER_TOO_SMALL)) {
return Status;
}
@@ -432,12 +435,12 @@ HiiGetFormSetFromHiiHandle( //
// Get Form package from this HII package List
//
- Status = EFI_NOT_FOUND;
- Offset = sizeof (EFI_HII_PACKAGE_LIST_HEADER);
+ Status = EFI_NOT_FOUND;
+ Offset = sizeof (EFI_HII_PACKAGE_LIST_HEADER);
PackageListLength = ReadUnaligned32 (&HiiPackageList->PackageLength);
while (Offset < PackageListLength) {
- Package = ((UINT8 *) HiiPackageList) + Offset;
+ Package = ((UINT8 *)HiiPackageList) + Offset;
CopyMem (&PackageHeader, Package, sizeof (EFI_HII_PACKAGE_HEADER));
Offset += PackageHeader.Length;
@@ -451,47 +454,51 @@ HiiGetFormSetFromHiiHandle( Offset2 = sizeof (EFI_HII_PACKAGE_HEADER);
while (Offset2 < PackageHeader.Length) {
OpCodeData = Package + Offset2;
- Offset2 += ((EFI_IFR_OP_HEADER *) OpCodeData)->Length;
+ Offset2 += ((EFI_IFR_OP_HEADER *)OpCodeData)->Length;
- if (((EFI_IFR_OP_HEADER *) OpCodeData)->OpCode != EFI_IFR_FORM_SET_OP) {
+ if (((EFI_IFR_OP_HEADER *)OpCodeData)->OpCode != EFI_IFR_FORM_SET_OP) {
continue;
}
- if (FormSetBuffer != NULL){
+ if (FormSetBuffer != NULL) {
TempBuffer = ReallocatePool (
TempSize,
- TempSize + ((EFI_IFR_OP_HEADER *) OpCodeData)->Length,
+ TempSize + ((EFI_IFR_OP_HEADER *)OpCodeData)->Length,
FormSetBuffer
);
if (TempBuffer == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto Done;
}
- CopyMem (TempBuffer + TempSize, OpCodeData, ((EFI_IFR_OP_HEADER *) OpCodeData)->Length);
+
+ CopyMem (TempBuffer + TempSize, OpCodeData, ((EFI_IFR_OP_HEADER *)OpCodeData)->Length);
FormSetBuffer = NULL;
} else {
- TempBuffer = AllocatePool (TempSize + ((EFI_IFR_OP_HEADER *) OpCodeData)->Length);
+ TempBuffer = AllocatePool (TempSize + ((EFI_IFR_OP_HEADER *)OpCodeData)->Length);
if (TempBuffer == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto Done;
}
- CopyMem (TempBuffer, OpCodeData, ((EFI_IFR_OP_HEADER *) OpCodeData)->Length);
+
+ CopyMem (TempBuffer, OpCodeData, ((EFI_IFR_OP_HEADER *)OpCodeData)->Length);
}
- TempSize += ((EFI_IFR_OP_HEADER *) OpCodeData)->Length;
+
+ TempSize += ((EFI_IFR_OP_HEADER *)OpCodeData)->Length;
FormSetBuffer = TempBuffer;
Status = EFI_SUCCESS;
//
- //One form package has one formset, exit current form package to search other form package in the packagelist.
+ // One form package has one formset, exit current form package to search other form package in the packagelist.
//
break;
}
}
+
Done:
FreePool (HiiPackageList);
*BufferSize = TempSize;
- *Buffer = (EFI_IFR_FORM_SET *)FormSetBuffer;
+ *Buffer = (EFI_IFR_FORM_SET *)FormSetBuffer;
return Status;
}
@@ -526,8 +533,8 @@ InternalHiiLowerConfigString ( Lower = TRUE;
} else if (*String == L'&') {
Lower = FALSE;
- } else if (Lower && *String >= L'A' && *String <= L'F') {
- *String = (CHAR16) (*String - L'A' + L'a');
+ } else if (Lower && (*String >= L'A') && (*String <= L'F')) {
+ *String = (CHAR16)(*String - L'A' + L'a');
}
}
@@ -578,6 +585,7 @@ InternalHiiBlockToConfig ( if (EFI_ERROR (Status)) {
return NULL;
}
+
return ConfigResp;
}
@@ -617,8 +625,8 @@ InternalHiiBrowserCallback ( // Locate protocols
//
if (mUefiFormBrowser2 == NULL) {
- Status = gBS->LocateProtocol (&gEfiFormBrowser2ProtocolGuid, NULL, (VOID **) &mUefiFormBrowser2);
- if (EFI_ERROR (Status) || mUefiFormBrowser2 == NULL) {
+ Status = gBS->LocateProtocol (&gEfiFormBrowser2ProtocolGuid, NULL, (VOID **)&mUefiFormBrowser2);
+ if (EFI_ERROR (Status) || (mUefiFormBrowser2 == NULL)) {
return NULL;
}
}
@@ -635,13 +643,13 @@ InternalHiiBrowserCallback ( // Retrieve the length of the buffer required ResultsData from the Browser Callback
//
Status = mUefiFormBrowser2->BrowserCallback (
- mUefiFormBrowser2,
- &ResultsDataSize,
- &TempResultsData,
- TRUE,
- VariableGuid,
- VariableName
- );
+ mUefiFormBrowser2,
+ &ResultsDataSize,
+ &TempResultsData,
+ TRUE,
+ VariableGuid,
+ VariableName
+ );
if (!EFI_ERROR (Status)) {
//
@@ -668,13 +676,13 @@ InternalHiiBrowserCallback ( // Retrieve or set the ResultsData from the Browser Callback
//
Status = mUefiFormBrowser2->BrowserCallback (
- mUefiFormBrowser2,
- &ResultsDataSize,
- ResultsData,
- (BOOLEAN)(SetResultsData == NULL),
- VariableGuid,
- VariableName
- );
+ mUefiFormBrowser2,
+ &ResultsDataSize,
+ ResultsData,
+ (BOOLEAN)(SetResultsData == NULL),
+ VariableGuid,
+ VariableName
+ );
if (EFI_ERROR (Status)) {
return NULL;
}
@@ -736,7 +744,7 @@ HiiConstructConfigHdr ( NameLength = StrLen (Name);
}
- DevicePath = NULL;
+ DevicePath = NULL;
DevicePathSize = 0;
//
// Retrieve DevicePath Protocol associated with DriverHandle
@@ -746,6 +754,7 @@ HiiConstructConfigHdr ( if (DevicePath == NULL) {
return NULL;
}
+
//
// Compute the size of the device path in bytes
//
@@ -767,7 +776,7 @@ HiiConstructConfigHdr ( //
StrCpyS (String, MaxLen, L"GUID=");
ReturnString = String;
- String += StrLen (String);
+ String += StrLen (String);
if (Guid != NULL) {
//
@@ -795,7 +804,7 @@ HiiConstructConfigHdr ( //
// Append Name converted to <Char>NameLength
//
- for (; *Name != L'\0'; Name++) {
+ for ( ; *Name != L'\0'; Name++) {
UnicodeValueToStringS (
String,
sizeof (CHAR16) * MaxLen - ((UINTN)String - (UINTN)ReturnString),
@@ -856,20 +865,20 @@ HiiConstructConfigHdr ( **/
EFI_STATUS
InternalHiiGetBufferFromString (
- IN EFI_STRING String,
- IN UINT8 Flag,
- OUT UINT8 **Buffer
+ IN EFI_STRING String,
+ IN UINT8 Flag,
+ OUT UINT8 **Buffer
)
{
- UINTN Length;
- EFI_STRING ConfigHdr;
- CHAR16 *StringPtr;
- UINT8 *DataBuffer;
- CHAR16 TemStr[5];
- UINTN Index;
- UINT8 DigitUint8;
-
- if (String == NULL || Buffer == NULL) {
+ UINTN Length;
+ EFI_STRING ConfigHdr;
+ CHAR16 *StringPtr;
+ UINT8 *DataBuffer;
+ CHAR16 TemStr[5];
+ UINTN Index;
+ UINT8 DigitUint8;
+
+ if ((String == NULL) || (Buffer == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -880,68 +889,72 @@ InternalHiiGetBufferFromString ( // The content between 'GUID', 'NAME', 'PATH' of <ConfigHdr> and '&' of next element
// or '\0' (end of configuration string) is the UNICODE %02x bytes encoding string.
//
- for (Length = 0; *String != 0 && *String != L'&'; String++, Length++);
+ for (Length = 0; *String != 0 && *String != L'&'; String++, Length++) {
+ }
switch (Flag) {
- case GUID_CONFIG_STRING_TYPE:
- case PATH_CONFIG_STRING_TYPE:
- //
- // The data in <ConfigHdr> is encoded as hex UNICODE %02x bytes in the same order
- // as the device path and Guid resides in RAM memory.
- // Translate the data into binary.
- //
- DataBuffer = (UINT8 *) AllocateZeroPool ((Length + 1) / 2);
- if (DataBuffer == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
- //
- // Convert binary byte one by one
- //
- ZeroMem (TemStr, sizeof (TemStr));
- for (Index = 0; Index < Length; Index ++) {
- TemStr[0] = ConfigHdr[Index];
- DigitUint8 = (UINT8) StrHexToUint64 (TemStr);
- if ((Index & 1) == 0) {
- DataBuffer [Index/2] = DigitUint8;
- } else {
- DataBuffer [Index/2] = (UINT8) ((DataBuffer [Index/2] << 4) + DigitUint8);
+ case GUID_CONFIG_STRING_TYPE:
+ case PATH_CONFIG_STRING_TYPE:
+ //
+ // The data in <ConfigHdr> is encoded as hex UNICODE %02x bytes in the same order
+ // as the device path and Guid resides in RAM memory.
+ // Translate the data into binary.
+ //
+ DataBuffer = (UINT8 *)AllocateZeroPool ((Length + 1) / 2);
+ if (DataBuffer == NULL) {
+ return EFI_OUT_OF_RESOURCES;
}
- }
- *Buffer = DataBuffer;
- break;
+ //
+ // Convert binary byte one by one
+ //
+ ZeroMem (TemStr, sizeof (TemStr));
+ for (Index = 0; Index < Length; Index++) {
+ TemStr[0] = ConfigHdr[Index];
+ DigitUint8 = (UINT8)StrHexToUint64 (TemStr);
+ if ((Index & 1) == 0) {
+ DataBuffer[Index/2] = DigitUint8;
+ } else {
+ DataBuffer[Index/2] = (UINT8)((DataBuffer[Index/2] << 4) + DigitUint8);
+ }
+ }
- case NAME_CONFIG_STRING_TYPE:
- //
- // Convert Config String to Unicode String, e.g. "0041004200430044" => "ABCD"
- //
+ *Buffer = DataBuffer;
+ break;
- //
- // Add the tailling char L'\0'
- //
- DataBuffer = (UINT8 *) AllocateZeroPool ((Length/4 + 1) * sizeof (CHAR16));
- if (DataBuffer == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
- //
- // Convert character one by one
- //
- StringPtr = (CHAR16 *) DataBuffer;
- ZeroMem (TemStr, sizeof (TemStr));
- for (Index = 0; Index < Length; Index += 4) {
- StrnCpyS (TemStr, sizeof (TemStr) / sizeof (CHAR16), ConfigHdr + Index, 4);
- StringPtr[Index/4] = (CHAR16) StrHexToUint64 (TemStr);
- }
- //
- // Add tailing L'\0' character
- //
- StringPtr[Index/4] = L'\0';
+ case NAME_CONFIG_STRING_TYPE:
+ //
+ // Convert Config String to Unicode String, e.g. "0041004200430044" => "ABCD"
+ //
- *Buffer = DataBuffer;
- break;
+ //
+ // Add the tailling char L'\0'
+ //
+ DataBuffer = (UINT8 *)AllocateZeroPool ((Length/4 + 1) * sizeof (CHAR16));
+ if (DataBuffer == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
- default:
- return EFI_INVALID_PARAMETER;
+ //
+ // Convert character one by one
+ //
+ StringPtr = (CHAR16 *)DataBuffer;
+ ZeroMem (TemStr, sizeof (TemStr));
+ for (Index = 0; Index < Length; Index += 4) {
+ StrnCpyS (TemStr, sizeof (TemStr) / sizeof (CHAR16), ConfigHdr + Index, 4);
+ StringPtr[Index/4] = (CHAR16)StrHexToUint64 (TemStr);
+ }
+
+ //
+ // Add tailing L'\0' character
+ //
+ StringPtr[Index/4] = L'\0';
+
+ *Buffer = DataBuffer;
+ break;
+
+ default:
+ return EFI_INVALID_PARAMETER;
}
return EFI_SUCCESS;
@@ -964,8 +977,8 @@ BlockArrayCheck ( IN UINT16 VarWidth
)
{
- LIST_ENTRY *Link;
- IFR_BLOCK_DATA *BlockData;
+ LIST_ENTRY *Link;
+ IFR_BLOCK_DATA *BlockData;
//
// No Request Block array, all vars are got.
@@ -1007,17 +1020,17 @@ BlockArrayCheck ( EFI_STATUS
EFIAPI
InternalHiiGetValueOfNumber (
- IN EFI_STRING ValueString,
- OUT UINT8 **ValueData,
- OUT UINTN *ValueLength
+ IN EFI_STRING ValueString,
+ OUT UINT8 **ValueData,
+ OUT UINTN *ValueLength
)
{
- EFI_STRING StringPtr;
- UINTN Length;
- UINT8 *Buf;
- UINT8 DigitUint8;
- UINTN Index;
- CHAR16 TemStr[2];
+ EFI_STRING StringPtr;
+ UINTN Length;
+ UINT8 *Buf;
+ UINT8 DigitUint8;
+ UINTN Index;
+ CHAR16 TemStr[2];
ASSERT (ValueString != NULL && ValueData != NULL && ValueLength != NULL);
ASSERT (*ValueString != L'\0');
@@ -1029,12 +1042,13 @@ InternalHiiGetValueOfNumber ( while (*StringPtr != L'\0' && *StringPtr != L'&') {
StringPtr++;
}
+
Length = StringPtr - ValueString;
//
// Allocate buffer to store the value
//
- Buf = (UINT8 *) AllocateZeroPool ((Length + 1) / 2);
+ Buf = (UINT8 *)AllocateZeroPool ((Length + 1) / 2);
if (Buf == NULL) {
return EFI_OUT_OF_RESOURCES;
}
@@ -1043,21 +1057,21 @@ InternalHiiGetValueOfNumber ( // Convert character one by one to the value buffer
//
ZeroMem (TemStr, sizeof (TemStr));
- for (Index = 0; Index < Length; Index ++) {
- TemStr[0] = ValueString[Length - Index - 1];
- DigitUint8 = (UINT8) StrHexToUint64 (TemStr);
+ for (Index = 0; Index < Length; Index++) {
+ TemStr[0] = ValueString[Length - Index - 1];
+ DigitUint8 = (UINT8)StrHexToUint64 (TemStr);
if ((Index & 1) == 0) {
- Buf [Index/2] = DigitUint8;
+ Buf[Index/2] = DigitUint8;
} else {
- Buf [Index/2] = (UINT8) ((DigitUint8 << 4) + Buf [Index/2]);
+ Buf[Index/2] = (UINT8)((DigitUint8 << 4) + Buf[Index/2]);
}
}
//
// Set the converted value and string length.
//
- *ValueData = Buf;
- *ValueLength = Length;
+ *ValueData = Buf;
+ *ValueLength = Length;
return EFI_SUCCESS;
}
@@ -1073,15 +1087,15 @@ InternalHiiGetValueOfNumber ( **/
EFI_STATUS
GetValueFromRequest (
- IN CHAR16 *ConfigElement,
- IN CHAR16 *VarName,
- OUT UINT64 *VarValue
+ IN CHAR16 *ConfigElement,
+ IN CHAR16 *VarName,
+ OUT UINT64 *VarValue
)
{
- UINT8 *TmpBuffer;
- CHAR16 *StringPtr;
- UINTN Length;
- EFI_STATUS Status;
+ UINT8 *TmpBuffer;
+ CHAR16 *StringPtr;
+ UINTN Length;
+ EFI_STATUS Status;
//
// Find VarName related string.
@@ -1132,15 +1146,15 @@ GetValueFromRequest ( **/
EFI_STATUS
ValidateQuestionFromVfr (
- IN EFI_HII_PACKAGE_LIST_HEADER *HiiPackageList,
- IN UINTN PackageListLength,
- IN EFI_GUID *VarGuid,
- IN CHAR16 *VarName,
- IN UINT8 *VarBuffer,
- IN IFR_BLOCK_DATA *CurrentBlockArray,
- IN CHAR16 *RequestElement,
- IN EFI_HII_HANDLE HiiHandle,
- IN BOOLEAN NameValueType
+ IN EFI_HII_PACKAGE_LIST_HEADER *HiiPackageList,
+ IN UINTN PackageListLength,
+ IN EFI_GUID *VarGuid,
+ IN CHAR16 *VarName,
+ IN UINT8 *VarBuffer,
+ IN IFR_BLOCK_DATA *CurrentBlockArray,
+ IN CHAR16 *RequestElement,
+ IN EFI_HII_HANDLE HiiHandle,
+ IN BOOLEAN NameValueType
)
{
IFR_BLOCK_DATA VarBlockData;
@@ -1187,8 +1201,8 @@ ValidateQuestionFromVfr ( IfrEfiVarStore = NULL;
ZeroMem (&VarStoreData, sizeof (IFR_VARSTORAGE_DATA));
ZeroMem (&VarBlockData, sizeof (VarBlockData));
- BitOffset = 0;
- BitWidth = 0;
+ BitOffset = 0;
+ BitWidth = 0;
QuestionReferBitField = FALSE;
//
@@ -1196,639 +1210,679 @@ ValidateQuestionFromVfr ( //
PackageOffset = sizeof (EFI_HII_PACKAGE_LIST_HEADER);
while (PackageOffset < PackageListLength) {
- CopyMem (&PackageHeader, (UINT8 *) HiiPackageList + PackageOffset, sizeof (PackageHeader));
+ CopyMem (&PackageHeader, (UINT8 *)HiiPackageList + PackageOffset, sizeof (PackageHeader));
//
// Parse IFR opcode from the form package.
//
if (PackageHeader.Type == EFI_HII_PACKAGE_FORMS) {
IfrOffset = sizeof (PackageHeader);
- PackageData = (UINT8 *) HiiPackageList + PackageOffset;
+ PackageData = (UINT8 *)HiiPackageList + PackageOffset;
while (IfrOffset < PackageHeader.Length) {
- IfrOpHdr = (EFI_IFR_OP_HEADER *) (PackageData + IfrOffset);
+ IfrOpHdr = (EFI_IFR_OP_HEADER *)(PackageData + IfrOffset);
//
// Validate current setting to the value built in IFR opcode
//
switch (IfrOpHdr->OpCode) {
- case EFI_IFR_VARSTORE_OP:
- //
- // VarStoreId has been found. No further found.
- //
- if (VarStoreData.VarStoreId != 0) {
- break;
- }
- //
- // Find the matched VarStoreId to the input VarGuid and VarName
- //
- IfrVarStore = (EFI_IFR_VARSTORE *) IfrOpHdr;
- if (CompareGuid ((EFI_GUID *) (VOID *) &IfrVarStore->Guid, VarGuid)) {
- VarStoreName = (CHAR8 *) IfrVarStore->Name;
- for (Index = 0; VarStoreName[Index] != 0; Index ++) {
- if ((CHAR16) VarStoreName[Index] != VarName[Index]) {
- break;
- }
+ case EFI_IFR_VARSTORE_OP:
+ //
+ // VarStoreId has been found. No further found.
+ //
+ if (VarStoreData.VarStoreId != 0) {
+ break;
}
+
//
- // The matched VarStore is found.
+ // Find the matched VarStoreId to the input VarGuid and VarName
//
- if ((VarStoreName[Index] != 0) || (VarName[Index] != 0)) {
+ IfrVarStore = (EFI_IFR_VARSTORE *)IfrOpHdr;
+ if (CompareGuid ((EFI_GUID *)(VOID *)&IfrVarStore->Guid, VarGuid)) {
+ VarStoreName = (CHAR8 *)IfrVarStore->Name;
+ for (Index = 0; VarStoreName[Index] != 0; Index++) {
+ if ((CHAR16)VarStoreName[Index] != VarName[Index]) {
+ break;
+ }
+ }
+
+ //
+ // The matched VarStore is found.
+ //
+ if ((VarStoreName[Index] != 0) || (VarName[Index] != 0)) {
+ IfrVarStore = NULL;
+ }
+ } else {
IfrVarStore = NULL;
}
- } else {
- IfrVarStore = NULL;
- }
- if (IfrVarStore != NULL) {
- VarStoreData.VarStoreId = IfrVarStore->VarStoreId;
- VarStoreData.Size = IfrVarStore->Size;
- }
- break;
- case EFI_IFR_VARSTORE_NAME_VALUE_OP:
- //
- // VarStoreId has been found. No further found.
- //
- if (VarStoreData.VarStoreId != 0) {
- break;
- }
- //
- // Find the matched VarStoreId to the input VarGuid
- //
- IfrNameValueStore = (EFI_IFR_VARSTORE_NAME_VALUE *) IfrOpHdr;
- if (!CompareGuid ((EFI_GUID *) (VOID *) &IfrNameValueStore->Guid, VarGuid)) {
- IfrNameValueStore = NULL;
- }
+ if (IfrVarStore != NULL) {
+ VarStoreData.VarStoreId = IfrVarStore->VarStoreId;
+ VarStoreData.Size = IfrVarStore->Size;
+ }
- if (IfrNameValueStore != NULL) {
- VarStoreData.VarStoreId = IfrNameValueStore->VarStoreId;
- }
- break;
- case EFI_IFR_VARSTORE_EFI_OP:
- //
- // VarStore is found. Don't need to search any more.
- //
- if (VarStoreData.VarStoreId != 0) {
break;
- }
-
- IfrEfiVarStore = (EFI_IFR_VARSTORE_EFI *) IfrOpHdr;
+ case EFI_IFR_VARSTORE_NAME_VALUE_OP:
+ //
+ // VarStoreId has been found. No further found.
+ //
+ if (VarStoreData.VarStoreId != 0) {
+ break;
+ }
- //
- // If the length is small than the structure, this is from old efi
- // varstore definition. Old efi varstore get config directly from
- // GetVariable function.
- //
- if (IfrOpHdr->Length < sizeof (EFI_IFR_VARSTORE_EFI)) {
- break;
- }
+ //
+ // Find the matched VarStoreId to the input VarGuid
+ //
+ IfrNameValueStore = (EFI_IFR_VARSTORE_NAME_VALUE *)IfrOpHdr;
+ if (!CompareGuid ((EFI_GUID *)(VOID *)&IfrNameValueStore->Guid, VarGuid)) {
+ IfrNameValueStore = NULL;
+ }
- if (CompareGuid ((EFI_GUID *) (VOID *) &IfrEfiVarStore->Guid, VarGuid)) {
- VarStoreName = (CHAR8 *) IfrEfiVarStore->Name;
- for (Index = 0; VarStoreName[Index] != 0; Index ++) {
- if ((CHAR16) VarStoreName[Index] != VarName[Index]) {
- break;
- }
+ if (IfrNameValueStore != NULL) {
+ VarStoreData.VarStoreId = IfrNameValueStore->VarStoreId;
}
+
+ break;
+ case EFI_IFR_VARSTORE_EFI_OP:
//
- // The matched VarStore is found.
+ // VarStore is found. Don't need to search any more.
//
- if ((VarStoreName[Index] != 0) || (VarName[Index] != 0)) {
- IfrEfiVarStore = NULL;
+ if (VarStoreData.VarStoreId != 0) {
+ break;
}
- } else {
- IfrEfiVarStore = NULL;
- }
- if (IfrEfiVarStore != NULL) {
+ IfrEfiVarStore = (EFI_IFR_VARSTORE_EFI *)IfrOpHdr;
+
//
- // Find the matched VarStore
+ // If the length is small than the structure, this is from old efi
+ // varstore definition. Old efi varstore get config directly from
+ // GetVariable function.
//
- VarStoreData.VarStoreId = IfrEfiVarStore->VarStoreId;
- VarStoreData.Size = IfrEfiVarStore->Size;
- }
- break;
- case EFI_IFR_FORM_OP:
- case EFI_IFR_FORM_MAP_OP:
- //
- // Check the matched VarStoreId is found.
- //
- if (VarStoreData.VarStoreId == 0) {
- return EFI_SUCCESS;
- }
- break;
- case EFI_IFR_ONE_OF_OP:
- //
- // Check whether current value is the one of option.
- //
-
- //
- // OneOf question is not in IFR Form. This IFR form is not valid.
- //
- if (VarStoreData.VarStoreId == 0) {
- return EFI_INVALID_PARAMETER;
- }
- //
- // Check whether this question is for the requested varstore.
- //
- IfrOneOf = (EFI_IFR_ONE_OF *) IfrOpHdr;
- if (IfrOneOf->Question.VarStoreId != VarStoreData.VarStoreId) {
- break;
- }
+ if (IfrOpHdr->Length < sizeof (EFI_IFR_VARSTORE_EFI)) {
+ break;
+ }
- if (NameValueType) {
- QuestionName = HiiGetString (HiiHandle, IfrOneOf->Question.VarStoreInfo.VarName, NULL);
- ASSERT (QuestionName != NULL);
+ if (CompareGuid ((EFI_GUID *)(VOID *)&IfrEfiVarStore->Guid, VarGuid)) {
+ VarStoreName = (CHAR8 *)IfrEfiVarStore->Name;
+ for (Index = 0; VarStoreName[Index] != 0; Index++) {
+ if ((CHAR16)VarStoreName[Index] != VarName[Index]) {
+ break;
+ }
+ }
- if (StrStr (RequestElement, QuestionName) == NULL) {
//
- // This question is not in the current configuration string. Skip it.
+ // The matched VarStore is found.
//
- break;
+ if ((VarStoreName[Index] != 0) || (VarName[Index] != 0)) {
+ IfrEfiVarStore = NULL;
+ }
+ } else {
+ IfrEfiVarStore = NULL;
}
- Status = GetValueFromRequest (RequestElement, QuestionName, &VarValue);
- if (EFI_ERROR (Status)) {
- return Status;
- }
- } else {
- //
- // Get Offset by Question header and Width by DataType Flags
- //
- if (QuestionReferBitField) {
+ if (IfrEfiVarStore != NULL) {
//
- // Get the byte offset/width for bit field.
+ // Find the matched VarStore
//
- BitOffset = IfrOneOf->Question.VarStoreInfo.VarOffset;
- BitWidth = IfrOneOf->Flags & EDKII_IFR_NUMERIC_SIZE_BIT;
- Offset = BitOffset / 8;
- TotalBits = BitOffset % 8 + BitWidth;
- Width = (TotalBits % 8 == 0 ? TotalBits / 8: TotalBits / 8 + 1);
- } else {
- Offset = IfrOneOf->Question.VarStoreInfo.VarOffset;
- Width = (UINT16) (1 << (IfrOneOf->Flags & EFI_IFR_NUMERIC_SIZE));
+ VarStoreData.VarStoreId = IfrEfiVarStore->VarStoreId;
+ VarStoreData.Size = IfrEfiVarStore->Size;
}
+
+ break;
+ case EFI_IFR_FORM_OP:
+ case EFI_IFR_FORM_MAP_OP:
//
- // Check whether this question is in current block array.
+ // Check the matched VarStoreId is found.
//
- if (!BlockArrayCheck (CurrentBlockArray, Offset, Width)) {
- //
- // This question is not in the current configuration string. Skip it.
- //
- break;
+ if (VarStoreData.VarStoreId == 0) {
+ return EFI_SUCCESS;
}
+
+ break;
+ case EFI_IFR_ONE_OF_OP:
//
- // Check this var question is in the var storage
+ // Check whether current value is the one of option.
//
- if ((Offset + Width) > VarStoreData.Size) {
- //
- // This question exceeds the var store size.
- //
+
+ //
+ // OneOf question is not in IFR Form. This IFR form is not valid.
+ //
+ if (VarStoreData.VarStoreId == 0) {
return EFI_INVALID_PARAMETER;
}
//
- // Get the current value for oneof opcode
+ // Check whether this question is for the requested varstore.
//
- VarValue = 0;
- if (QuestionReferBitField) {
+ IfrOneOf = (EFI_IFR_ONE_OF *)IfrOpHdr;
+ if (IfrOneOf->Question.VarStoreId != VarStoreData.VarStoreId) {
+ break;
+ }
+
+ if (NameValueType) {
+ QuestionName = HiiGetString (HiiHandle, IfrOneOf->Question.VarStoreInfo.VarName, NULL);
+ ASSERT (QuestionName != NULL);
+
+ if (StrStr (RequestElement, QuestionName) == NULL) {
+ //
+ // This question is not in the current configuration string. Skip it.
+ //
+ break;
+ }
+
+ Status = GetValueFromRequest (RequestElement, QuestionName, &VarValue);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ } else {
//
- // Get the value in bit fields.
+ // Get Offset by Question header and Width by DataType Flags
//
- StartBit = BitOffset % 8;
- EndBit = StartBit + BitWidth - 1;
- CopyMem ((UINT8 *) &BufferValue, VarBuffer + Offset, Width);
- VarValue = BitFieldRead32 (BufferValue, StartBit, EndBit);
- } else {
- CopyMem (&VarValue, VarBuffer + Offset, Width);
- }
- }
- //
- // Set Block Data, to be checked in the following Oneof option opcode.
- //
- VarBlockData.OpCode = IfrOpHdr->OpCode;
- VarBlockData.Scope = IfrOpHdr->Scope;
- break;
- case EFI_IFR_NUMERIC_OP:
- //
- // Check the current value is in the numeric range.
- //
+ if (QuestionReferBitField) {
+ //
+ // Get the byte offset/width for bit field.
+ //
+ BitOffset = IfrOneOf->Question.VarStoreInfo.VarOffset;
+ BitWidth = IfrOneOf->Flags & EDKII_IFR_NUMERIC_SIZE_BIT;
+ Offset = BitOffset / 8;
+ TotalBits = BitOffset % 8 + BitWidth;
+ Width = (TotalBits % 8 == 0 ? TotalBits / 8 : TotalBits / 8 + 1);
+ } else {
+ Offset = IfrOneOf->Question.VarStoreInfo.VarOffset;
+ Width = (UINT16)(1 << (IfrOneOf->Flags & EFI_IFR_NUMERIC_SIZE));
+ }
- //
- // Numeric question is not in IFR Form. This IFR form is not valid.
- //
- if (VarStoreData.VarStoreId == 0) {
- return EFI_INVALID_PARAMETER;
- }
- //
- // Check whether this question is for the requested varstore.
- //
- IfrNumeric = (EFI_IFR_NUMERIC *) IfrOpHdr;
- if (IfrNumeric->Question.VarStoreId != VarStoreData.VarStoreId) {
- break;
- }
+ //
+ // Check whether this question is in current block array.
+ //
+ if (!BlockArrayCheck (CurrentBlockArray, Offset, Width)) {
+ //
+ // This question is not in the current configuration string. Skip it.
+ //
+ break;
+ }
- if (NameValueType) {
- QuestionName = HiiGetString (HiiHandle, IfrNumeric->Question.VarStoreInfo.VarName, NULL);
- ASSERT (QuestionName != NULL);
+ //
+ // Check this var question is in the var storage
+ //
+ if ((Offset + Width) > VarStoreData.Size) {
+ //
+ // This question exceeds the var store size.
+ //
+ return EFI_INVALID_PARAMETER;
+ }
- if (StrStr (RequestElement, QuestionName) == NULL) {
//
- // This question is not in the current configuration string. Skip it.
+ // Get the current value for oneof opcode
//
- break;
+ VarValue = 0;
+ if (QuestionReferBitField) {
+ //
+ // Get the value in bit fields.
+ //
+ StartBit = BitOffset % 8;
+ EndBit = StartBit + BitWidth - 1;
+ CopyMem ((UINT8 *)&BufferValue, VarBuffer + Offset, Width);
+ VarValue = BitFieldRead32 (BufferValue, StartBit, EndBit);
+ } else {
+ CopyMem (&VarValue, VarBuffer + Offset, Width);
+ }
}
- Status = GetValueFromRequest (RequestElement, QuestionName, &VarValue);
- if (EFI_ERROR (Status)) {
- return Status;
- }
- } else {
//
- // Get Offset by Question header and Width by DataType Flags
+ // Set Block Data, to be checked in the following Oneof option opcode.
//
- if (QuestionReferBitField) {
- //
- // Get the byte offset/width for bit field.
- //
- BitOffset = IfrNumeric->Question.VarStoreInfo.VarOffset;
- BitWidth = IfrNumeric->Flags & EDKII_IFR_NUMERIC_SIZE_BIT;
- Offset = BitOffset / 8;
- TotalBits = BitOffset % 8 + BitWidth;
- Width = (TotalBits % 8 == 0 ? TotalBits / 8: TotalBits / 8 + 1);
- } else {
- Offset = IfrNumeric->Question.VarStoreInfo.VarOffset;
- Width = (UINT16) (1 << (IfrNumeric->Flags & EFI_IFR_NUMERIC_SIZE));
- }
+ VarBlockData.OpCode = IfrOpHdr->OpCode;
+ VarBlockData.Scope = IfrOpHdr->Scope;
+ break;
+ case EFI_IFR_NUMERIC_OP:
//
- // Check whether this question is in current block array.
+ // Check the current value is in the numeric range.
//
- if (!BlockArrayCheck (CurrentBlockArray, Offset, Width)) {
- //
- // This question is not in the current configuration string. Skip it.
- //
- break;
- }
+
//
- // Check this var question is in the var storage
+ // Numeric question is not in IFR Form. This IFR form is not valid.
//
- if ((Offset + Width) > VarStoreData.Size) {
- //
- // This question exceeds the var store size.
- //
+ if (VarStoreData.VarStoreId == 0) {
return EFI_INVALID_PARAMETER;
}
//
- // Check the current value is in the numeric range.
+ // Check whether this question is for the requested varstore.
//
- VarValue = 0;
- if (QuestionReferBitField) {
- //
- // Get the value in the bit fields.
- //
- StartBit = BitOffset % 8;
- EndBit = StartBit + BitWidth - 1;
- CopyMem ((UINT8 *) &BufferValue, VarBuffer + Offset, Width);
- VarValue = BitFieldRead32 (BufferValue, StartBit, EndBit);
- } else {
- CopyMem (&VarValue, VarBuffer + Offset, Width);
+ IfrNumeric = (EFI_IFR_NUMERIC *)IfrOpHdr;
+ if (IfrNumeric->Question.VarStoreId != VarStoreData.VarStoreId) {
+ break;
}
- }
- if ( QuestionReferBitField) {
- //
- // Value in bit fields was stored as UINt32 type.
- //
- if ((IfrNumeric->Flags & EDKII_IFR_DISPLAY_BIT) == 0) {
- if ((INT32) VarValue < (INT32) IfrNumeric->data.u32.MinValue || (INT32) VarValue > (INT32) IfrNumeric->data.u32.MaxValue) {
- //
- // Not in the valid range.
- //
- return EFI_INVALID_PARAMETER;
- }
- } else {
- if (VarValue < IfrNumeric->data.u32.MinValue || VarValue > IfrNumeric->data.u32.MaxValue) {
- //
- // Not in the valid range.
- //
- return EFI_INVALID_PARAMETER;
- }
- }
- } else {
- if ((IfrNumeric->Flags & EFI_IFR_DISPLAY) == 0) {
- switch (IfrNumeric->Flags & EFI_IFR_NUMERIC_SIZE) {
- case EFI_IFR_NUMERIC_SIZE_1:
- if ((INT8) VarValue < (INT8) IfrNumeric->data.u8.MinValue || (INT8) VarValue > (INT8) IfrNumeric->data.u8.MaxValue) {
- //
- // Not in the valid range.
- //
- return EFI_INVALID_PARAMETER;
- }
+
+ if (NameValueType) {
+ QuestionName = HiiGetString (HiiHandle, IfrNumeric->Question.VarStoreInfo.VarName, NULL);
+ ASSERT (QuestionName != NULL);
+
+ if (StrStr (RequestElement, QuestionName) == NULL) {
+ //
+ // This question is not in the current configuration string. Skip it.
+ //
break;
- case EFI_IFR_NUMERIC_SIZE_2:
- if ((INT16) VarValue < (INT16) IfrNumeric->data.u16.MinValue || (INT16) VarValue > (INT16) IfrNumeric->data.u16.MaxValue) {
- //
- // Not in the valid range.
- //
- return EFI_INVALID_PARAMETER;
- }
+ }
+
+ Status = GetValueFromRequest (RequestElement, QuestionName, &VarValue);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ } else {
+ //
+ // Get Offset by Question header and Width by DataType Flags
+ //
+ if (QuestionReferBitField) {
+ //
+ // Get the byte offset/width for bit field.
+ //
+ BitOffset = IfrNumeric->Question.VarStoreInfo.VarOffset;
+ BitWidth = IfrNumeric->Flags & EDKII_IFR_NUMERIC_SIZE_BIT;
+ Offset = BitOffset / 8;
+ TotalBits = BitOffset % 8 + BitWidth;
+ Width = (TotalBits % 8 == 0 ? TotalBits / 8 : TotalBits / 8 + 1);
+ } else {
+ Offset = IfrNumeric->Question.VarStoreInfo.VarOffset;
+ Width = (UINT16)(1 << (IfrNumeric->Flags & EFI_IFR_NUMERIC_SIZE));
+ }
+
+ //
+ // Check whether this question is in current block array.
+ //
+ if (!BlockArrayCheck (CurrentBlockArray, Offset, Width)) {
+ //
+ // This question is not in the current configuration string. Skip it.
+ //
break;
- case EFI_IFR_NUMERIC_SIZE_4:
- if ((INT32) VarValue < (INT32) IfrNumeric->data.u32.MinValue || (INT32) VarValue > (INT32) IfrNumeric->data.u32.MaxValue) {
+ }
+
+ //
+ // Check this var question is in the var storage
+ //
+ if ((Offset + Width) > VarStoreData.Size) {
+ //
+ // This question exceeds the var store size.
+ //
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // Check the current value is in the numeric range.
+ //
+ VarValue = 0;
+ if (QuestionReferBitField) {
+ //
+ // Get the value in the bit fields.
+ //
+ StartBit = BitOffset % 8;
+ EndBit = StartBit + BitWidth - 1;
+ CopyMem ((UINT8 *)&BufferValue, VarBuffer + Offset, Width);
+ VarValue = BitFieldRead32 (BufferValue, StartBit, EndBit);
+ } else {
+ CopyMem (&VarValue, VarBuffer + Offset, Width);
+ }
+ }
+
+ if ( QuestionReferBitField) {
+ //
+ // Value in bit fields was stored as UINt32 type.
+ //
+ if ((IfrNumeric->Flags & EDKII_IFR_DISPLAY_BIT) == 0) {
+ if (((INT32)VarValue < (INT32)IfrNumeric->data.u32.MinValue) || ((INT32)VarValue > (INT32)IfrNumeric->data.u32.MaxValue)) {
//
// Not in the valid range.
//
return EFI_INVALID_PARAMETER;
}
- break;
- case EFI_IFR_NUMERIC_SIZE_8:
- if ((INT64) VarValue < (INT64) IfrNumeric->data.u64.MinValue || (INT64) VarValue > (INT64) IfrNumeric->data.u64.MaxValue) {
+ } else {
+ if ((VarValue < IfrNumeric->data.u32.MinValue) || (VarValue > IfrNumeric->data.u32.MaxValue)) {
//
// Not in the valid range.
//
return EFI_INVALID_PARAMETER;
}
- break;
}
} else {
- switch (IfrNumeric->Flags & EFI_IFR_NUMERIC_SIZE) {
- case EFI_IFR_NUMERIC_SIZE_1:
- if ((UINT8) VarValue < IfrNumeric->data.u8.MinValue || (UINT8) VarValue > IfrNumeric->data.u8.MaxValue) {
- //
- // Not in the valid range.
- //
- return EFI_INVALID_PARAMETER;
+ if ((IfrNumeric->Flags & EFI_IFR_DISPLAY) == 0) {
+ switch (IfrNumeric->Flags & EFI_IFR_NUMERIC_SIZE) {
+ case EFI_IFR_NUMERIC_SIZE_1:
+ if (((INT8)VarValue < (INT8)IfrNumeric->data.u8.MinValue) || ((INT8)VarValue > (INT8)IfrNumeric->data.u8.MaxValue)) {
+ //
+ // Not in the valid range.
+ //
+ return EFI_INVALID_PARAMETER;
+ }
+
+ break;
+ case EFI_IFR_NUMERIC_SIZE_2:
+ if (((INT16)VarValue < (INT16)IfrNumeric->data.u16.MinValue) || ((INT16)VarValue > (INT16)IfrNumeric->data.u16.MaxValue)) {
+ //
+ // Not in the valid range.
+ //
+ return EFI_INVALID_PARAMETER;
+ }
+
+ break;
+ case EFI_IFR_NUMERIC_SIZE_4:
+ if (((INT32)VarValue < (INT32)IfrNumeric->data.u32.MinValue) || ((INT32)VarValue > (INT32)IfrNumeric->data.u32.MaxValue)) {
+ //
+ // Not in the valid range.
+ //
+ return EFI_INVALID_PARAMETER;
+ }
+
+ break;
+ case EFI_IFR_NUMERIC_SIZE_8:
+ if (((INT64)VarValue < (INT64)IfrNumeric->data.u64.MinValue) || ((INT64)VarValue > (INT64)IfrNumeric->data.u64.MaxValue)) {
+ //
+ // Not in the valid range.
+ //
+ return EFI_INVALID_PARAMETER;
+ }
+
+ break;
}
- break;
- case EFI_IFR_NUMERIC_SIZE_2:
- if ((UINT16) VarValue < IfrNumeric->data.u16.MinValue || (UINT16) VarValue > IfrNumeric->data.u16.MaxValue) {
- //
- // Not in the valid range.
- //
- return EFI_INVALID_PARAMETER;
+ } else {
+ switch (IfrNumeric->Flags & EFI_IFR_NUMERIC_SIZE) {
+ case EFI_IFR_NUMERIC_SIZE_1:
+ if (((UINT8)VarValue < IfrNumeric->data.u8.MinValue) || ((UINT8)VarValue > IfrNumeric->data.u8.MaxValue)) {
+ //
+ // Not in the valid range.
+ //
+ return EFI_INVALID_PARAMETER;
+ }
+
+ break;
+ case EFI_IFR_NUMERIC_SIZE_2:
+ if (((UINT16)VarValue < IfrNumeric->data.u16.MinValue) || ((UINT16)VarValue > IfrNumeric->data.u16.MaxValue)) {
+ //
+ // Not in the valid range.
+ //
+ return EFI_INVALID_PARAMETER;
+ }
+
+ break;
+ case EFI_IFR_NUMERIC_SIZE_4:
+ if (((UINT32)VarValue < IfrNumeric->data.u32.MinValue) || ((UINT32)VarValue > IfrNumeric->data.u32.MaxValue)) {
+ //
+ // Not in the valid range.
+ //
+ return EFI_INVALID_PARAMETER;
+ }
+
+ break;
+ case EFI_IFR_NUMERIC_SIZE_8:
+ if (((UINT64)VarValue < IfrNumeric->data.u64.MinValue) || ((UINT64)VarValue > IfrNumeric->data.u64.MaxValue)) {
+ //
+ // Not in the valid range.
+ //
+ return EFI_INVALID_PARAMETER;
+ }
+
+ break;
}
- break;
- case EFI_IFR_NUMERIC_SIZE_4:
- if ((UINT32) VarValue < IfrNumeric->data.u32.MinValue || (UINT32) VarValue > IfrNumeric->data.u32.MaxValue) {
- //
- // Not in the valid range.
- //
- return EFI_INVALID_PARAMETER;
- }
- break;
- case EFI_IFR_NUMERIC_SIZE_8:
- if ((UINT64) VarValue < IfrNumeric->data.u64.MinValue || (UINT64) VarValue > IfrNumeric->data.u64.MaxValue) {
- //
- // Not in the valid range.
- //
- return EFI_INVALID_PARAMETER;
- }
- break;
}
}
- }
- break;
- case EFI_IFR_CHECKBOX_OP:
- //
- // Check value is BOOLEAN type, only 0 and 1 is valid.
- //
-
- //
- // CheckBox question is not in IFR Form. This IFR form is not valid.
- //
- if (VarStoreData.VarStoreId == 0) {
- return EFI_INVALID_PARAMETER;
- }
- //
- // Check whether this question is for the requested varstore.
- //
- IfrCheckBox = (EFI_IFR_CHECKBOX *) IfrOpHdr;
- if (IfrCheckBox->Question.VarStoreId != VarStoreData.VarStoreId) {
break;
- }
-
- if (NameValueType) {
- QuestionName = HiiGetString (HiiHandle, IfrCheckBox->Question.VarStoreInfo.VarName, NULL);
- ASSERT (QuestionName != NULL);
-
- if (StrStr (RequestElement, QuestionName) == NULL) {
- //
- // This question is not in the current configuration string. Skip it.
- //
- break;
- }
+ case EFI_IFR_CHECKBOX_OP:
+ //
+ // Check value is BOOLEAN type, only 0 and 1 is valid.
+ //
- Status = GetValueFromRequest (RequestElement, QuestionName, &VarValue);
- if (EFI_ERROR (Status)) {
- return Status;
- }
- } else {
//
- // Get Offset by Question header
+ // CheckBox question is not in IFR Form. This IFR form is not valid.
//
- if (QuestionReferBitField) {
- //
- // Get the byte offset/width for bit field.
- //
- BitOffset = IfrCheckBox->Question.VarStoreInfo.VarOffset;
- BitWidth = 1;
- Offset = BitOffset / 8;
- TotalBits = BitOffset % 8 + BitWidth;
- Width = (TotalBits % 8 == 0 ? TotalBits / 8: TotalBits / 8 + 1);
- } else {
- Offset = IfrCheckBox->Question.VarStoreInfo.VarOffset;
- Width = (UINT16) sizeof (BOOLEAN);
+ if (VarStoreData.VarStoreId == 0) {
+ return EFI_INVALID_PARAMETER;
}
+
//
- // Check whether this question is in current block array.
+ // Check whether this question is for the requested varstore.
//
- if (!BlockArrayCheck (CurrentBlockArray, Offset, Width)) {
- //
- // This question is not in the current configuration string. Skip it.
- //
+ IfrCheckBox = (EFI_IFR_CHECKBOX *)IfrOpHdr;
+ if (IfrCheckBox->Question.VarStoreId != VarStoreData.VarStoreId) {
break;
}
- //
- // Check this var question is in the var storage
- //
- if ((Offset + Width) > VarStoreData.Size) {
+
+ if (NameValueType) {
+ QuestionName = HiiGetString (HiiHandle, IfrCheckBox->Question.VarStoreInfo.VarName, NULL);
+ ASSERT (QuestionName != NULL);
+
+ if (StrStr (RequestElement, QuestionName) == NULL) {
+ //
+ // This question is not in the current configuration string. Skip it.
+ //
+ break;
+ }
+
+ Status = GetValueFromRequest (RequestElement, QuestionName, &VarValue);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ } else {
//
- // This question exceeds the var store size.
+ // Get Offset by Question header
//
- return EFI_INVALID_PARAMETER;
- }
- //
- // Check the current value is in the numeric range.
- //
- VarValue = 0;
- if (QuestionReferBitField) {
+ if (QuestionReferBitField) {
+ //
+ // Get the byte offset/width for bit field.
+ //
+ BitOffset = IfrCheckBox->Question.VarStoreInfo.VarOffset;
+ BitWidth = 1;
+ Offset = BitOffset / 8;
+ TotalBits = BitOffset % 8 + BitWidth;
+ Width = (TotalBits % 8 == 0 ? TotalBits / 8 : TotalBits / 8 + 1);
+ } else {
+ Offset = IfrCheckBox->Question.VarStoreInfo.VarOffset;
+ Width = (UINT16)sizeof (BOOLEAN);
+ }
+
//
- // Get the value in bit fields.
+ // Check whether this question is in current block array.
//
- StartBit = BitOffset % 8;
- EndBit = StartBit + BitWidth - 1;
- CopyMem ((UINT8 *) &BufferValue, VarBuffer + Offset, Width);
- VarValue = BitFieldRead32 (BufferValue, StartBit, EndBit);
- } else {
- CopyMem (&VarValue, VarBuffer + Offset, Width);
- }
- }
- //
- // Boolean type, only 1 and 0 is valid.
- //
- if (VarValue > 1) {
- return EFI_INVALID_PARAMETER;
- }
- break;
- case EFI_IFR_STRING_OP:
- //
- // Check current string length is less than maxsize
- //
-
- //
- // CheckBox question is not in IFR Form. This IFR form is not valid.
- //
- if (VarStoreData.VarStoreId == 0) {
- return EFI_INVALID_PARAMETER;
- }
+ if (!BlockArrayCheck (CurrentBlockArray, Offset, Width)) {
+ //
+ // This question is not in the current configuration string. Skip it.
+ //
+ break;
+ }
- //
- // Check whether this question is for the requested varstore.
- //
- IfrString = (EFI_IFR_STRING *) IfrOpHdr;
- if (IfrString->Question.VarStoreId != VarStoreData.VarStoreId) {
- break;
- }
- //
- // Get the Max size of the string.
- //
- Width = (UINT16) (IfrString->MaxSize * sizeof (UINT16));
- if (NameValueType) {
- QuestionName = HiiGetString (HiiHandle, IfrString->Question.VarStoreInfo.VarName, NULL);
- ASSERT (QuestionName != NULL);
+ //
+ // Check this var question is in the var storage
+ //
+ if ((Offset + Width) > VarStoreData.Size) {
+ //
+ // This question exceeds the var store size.
+ //
+ return EFI_INVALID_PARAMETER;
+ }
- StringPtr = StrStr (RequestElement, QuestionName);
- if (StringPtr == NULL) {
//
- // This question is not in the current configuration string. Skip it.
+ // Check the current value is in the numeric range.
//
- break;
+ VarValue = 0;
+ if (QuestionReferBitField) {
+ //
+ // Get the value in bit fields.
+ //
+ StartBit = BitOffset % 8;
+ EndBit = StartBit + BitWidth - 1;
+ CopyMem ((UINT8 *)&BufferValue, VarBuffer + Offset, Width);
+ VarValue = BitFieldRead32 (BufferValue, StartBit, EndBit);
+ } else {
+ CopyMem (&VarValue, VarBuffer + Offset, Width);
+ }
}
+
//
- // Skip the VarName.
+ // Boolean type, only 1 and 0 is valid.
//
- StringPtr += StrLen (QuestionName);
+ if (VarValue > 1) {
+ return EFI_INVALID_PARAMETER;
+ }
+ break;
+ case EFI_IFR_STRING_OP:
//
- // Skip the "=".
+ // Check current string length is less than maxsize
//
- StringPtr += 1;
//
- // Check current string length is less than maxsize
- // e.g Config String: "0041004200430044", Unicode String: "ABCD". Unicode String length = Config String length / 4.
- // Config string format in UEFI spec.
- // <NvConfig> ::= <Label>'='<String>
- // <String> ::= [<Char>]+
- // <Char> ::= <HexCh>4
+ // CheckBox question is not in IFR Form. This IFR form is not valid.
//
- if (StrLen (StringPtr) / 4 > IfrString->MaxSize) {
+ if (VarStoreData.VarStoreId == 0) {
return EFI_INVALID_PARAMETER;
}
- } else {
+
//
- // Get Offset/Width by Question header and OneOf Flags
+ // Check whether this question is for the requested varstore.
//
- Offset = IfrString->Question.VarStoreInfo.VarOffset;
+ IfrString = (EFI_IFR_STRING *)IfrOpHdr;
+ if (IfrString->Question.VarStoreId != VarStoreData.VarStoreId) {
+ break;
+ }
+
//
- // Check whether this question is in current block array.
+ // Get the Max size of the string.
//
- if (!BlockArrayCheck (CurrentBlockArray, Offset, Width)) {
+ Width = (UINT16)(IfrString->MaxSize * sizeof (UINT16));
+ if (NameValueType) {
+ QuestionName = HiiGetString (HiiHandle, IfrString->Question.VarStoreInfo.VarName, NULL);
+ ASSERT (QuestionName != NULL);
+
+ StringPtr = StrStr (RequestElement, QuestionName);
+ if (StringPtr == NULL) {
+ //
+ // This question is not in the current configuration string. Skip it.
+ //
+ break;
+ }
+
//
- // This question is not in the current configuration string. Skip it.
+ // Skip the VarName.
//
+ StringPtr += StrLen (QuestionName);
+
+ //
+ // Skip the "=".
+ //
+ StringPtr += 1;
+
+ //
+ // Check current string length is less than maxsize
+ // e.g Config String: "0041004200430044", Unicode String: "ABCD". Unicode String length = Config String length / 4.
+ // Config string format in UEFI spec.
+ // <NvConfig> ::= <Label>'='<String>
+ // <String> ::= [<Char>]+
+ // <Char> ::= <HexCh>4
+ //
+ if (StrLen (StringPtr) / 4 > IfrString->MaxSize) {
+ return EFI_INVALID_PARAMETER;
+ }
+ } else {
+ //
+ // Get Offset/Width by Question header and OneOf Flags
+ //
+ Offset = IfrString->Question.VarStoreInfo.VarOffset;
+ //
+ // Check whether this question is in current block array.
+ //
+ if (!BlockArrayCheck (CurrentBlockArray, Offset, Width)) {
+ //
+ // This question is not in the current configuration string. Skip it.
+ //
+ break;
+ }
+
+ //
+ // Check this var question is in the var storage
+ //
+ if ((Offset + Width) > VarStoreData.Size) {
+ //
+ // This question exceeds the var store size.
+ //
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // Check current string length is less than maxsize
+ //
+ if (StrLen ((CHAR16 *)(VarBuffer + Offset)) > IfrString->MaxSize) {
+ return EFI_INVALID_PARAMETER;
+ }
+ }
+
+ break;
+ case EFI_IFR_ONE_OF_OPTION_OP:
+ //
+ // Opcode Scope is zero. This one of option is not to be checked.
+ //
+ if (VarBlockData.Scope == 0) {
break;
}
+
//
- // Check this var question is in the var storage
+ // Only check for OneOf and OrderList opcode
//
- if ((Offset + Width) > VarStoreData.Size) {
+ IfrOneOfOption = (EFI_IFR_ONE_OF_OPTION *)IfrOpHdr;
+ if (VarBlockData.OpCode == EFI_IFR_ONE_OF_OP) {
//
- // This question exceeds the var store size.
+ // Check current value is the value of one of option.
//
- return EFI_INVALID_PARAMETER;
+ ASSERT (IfrOneOfOption->Type <= EFI_IFR_TYPE_NUM_SIZE_64);
+ ZeroMem (&TmpValue, sizeof (EFI_IFR_TYPE_VALUE));
+ CopyMem (&TmpValue, &IfrOneOfOption->Value, IfrOneOfOption->Header.Length - OFFSET_OF (EFI_IFR_ONE_OF_OPTION, Value));
+ if (VarValue == TmpValue.u64) {
+ //
+ // The value is one of option value.
+ // Set OpCode to Zero, don't need check again.
+ //
+ VarBlockData.OpCode = 0;
+ }
}
+ break;
+ case EFI_IFR_END_OP:
+ QuestionReferBitField = FALSE;
//
- // Check current string length is less than maxsize
+ // Decrease opcode scope for the validated opcode
+ //
+ if (VarBlockData.Scope > 0) {
+ VarBlockData.Scope--;
+ }
+
//
- if (StrLen ((CHAR16 *) (VarBuffer + Offset)) > IfrString->MaxSize) {
+ // OneOf value doesn't belong to one of option value.
+ //
+ if ((VarBlockData.Scope == 0) && (VarBlockData.OpCode == EFI_IFR_ONE_OF_OP)) {
return EFI_INVALID_PARAMETER;
}
- }
- break;
- case EFI_IFR_ONE_OF_OPTION_OP:
- //
- // Opcode Scope is zero. This one of option is not to be checked.
- //
- if (VarBlockData.Scope == 0) {
+
break;
- }
+ case EFI_IFR_GUID_OP:
+ if (CompareGuid ((EFI_GUID *)((UINT8 *)IfrOpHdr + sizeof (EFI_IFR_OP_HEADER)), &gEdkiiIfrBitVarstoreGuid)) {
+ QuestionReferBitField = TRUE;
+ }
- //
- // Only check for OneOf and OrderList opcode
- //
- IfrOneOfOption = (EFI_IFR_ONE_OF_OPTION *) IfrOpHdr;
- if (VarBlockData.OpCode == EFI_IFR_ONE_OF_OP) {
+ break;
+ default:
//
- // Check current value is the value of one of option.
+ // Increase Scope for the validated opcode
//
- ASSERT (IfrOneOfOption->Type <= EFI_IFR_TYPE_NUM_SIZE_64);
- ZeroMem (&TmpValue, sizeof (EFI_IFR_TYPE_VALUE));
- CopyMem (&TmpValue, &IfrOneOfOption->Value, IfrOneOfOption->Header.Length - OFFSET_OF (EFI_IFR_ONE_OF_OPTION, Value));
- if (VarValue == TmpValue.u64) {
- //
- // The value is one of option value.
- // Set OpCode to Zero, don't need check again.
- //
- VarBlockData.OpCode = 0;
+ if (VarBlockData.Scope > 0) {
+ VarBlockData.Scope = (UINT8)(VarBlockData.Scope + IfrOpHdr->Scope);
}
- }
- break;
- case EFI_IFR_END_OP:
- QuestionReferBitField = FALSE;
- //
- // Decrease opcode scope for the validated opcode
- //
- if (VarBlockData.Scope > 0) {
- VarBlockData.Scope --;
- }
- //
- // OneOf value doesn't belong to one of option value.
- //
- if ((VarBlockData.Scope == 0) && (VarBlockData.OpCode == EFI_IFR_ONE_OF_OP)) {
- return EFI_INVALID_PARAMETER;
- }
- break;
- case EFI_IFR_GUID_OP:
- if (CompareGuid ((EFI_GUID *)((UINT8*)IfrOpHdr + sizeof (EFI_IFR_OP_HEADER)), &gEdkiiIfrBitVarstoreGuid)) {
- QuestionReferBitField = TRUE;
- }
- break;
- default:
- //
- // Increase Scope for the validated opcode
- //
- if (VarBlockData.Scope > 0) {
- VarBlockData.Scope = (UINT8) (VarBlockData.Scope + IfrOpHdr->Scope);
- }
- break;
+ break;
}
+
//
// Go to the next opcode
//
IfrOffset += IfrOpHdr->Length;
}
+
//
// Only one form is in a package list.
//
@@ -1857,23 +1911,23 @@ ValidateQuestionFromVfr ( **/
EFI_STATUS
GetBlockDataInfo (
- IN CHAR16 *ConfigElement,
- OUT IFR_BLOCK_DATA **CurrentBlockArray,
- OUT UINT8 **VarBuffer
+ IN CHAR16 *ConfigElement,
+ OUT IFR_BLOCK_DATA **CurrentBlockArray,
+ OUT UINT8 **VarBuffer
)
{
- IFR_BLOCK_DATA *BlockData;
- IFR_BLOCK_DATA *NewBlockData;
- EFI_STRING StringPtr;
- UINTN Length;
- UINT8 *TmpBuffer;
- UINT16 Offset;
- UINT16 Width;
- LIST_ENTRY *Link;
- UINTN MaxBufferSize;
- EFI_STATUS Status;
- IFR_BLOCK_DATA *BlockArray;
- UINT8 *DataBuffer;
+ IFR_BLOCK_DATA *BlockData;
+ IFR_BLOCK_DATA *NewBlockData;
+ EFI_STRING StringPtr;
+ UINTN Length;
+ UINT8 *TmpBuffer;
+ UINT16 Offset;
+ UINT16 Width;
+ LIST_ENTRY *Link;
+ UINTN MaxBufferSize;
+ EFI_STATUS Status;
+ IFR_BLOCK_DATA *BlockArray;
+ UINT8 *DataBuffer;
//
// Initialize the local variables.
@@ -1884,7 +1938,7 @@ GetBlockDataInfo ( TmpBuffer = NULL;
BlockArray = NULL;
MaxBufferSize = HII_LIB_DEFAULT_VARSTORE_SIZE;
- DataBuffer = AllocateZeroPool (MaxBufferSize);
+ DataBuffer = AllocateZeroPool (MaxBufferSize);
if (DataBuffer == NULL) {
return EFI_OUT_OF_RESOURCES;
}
@@ -1892,11 +1946,12 @@ GetBlockDataInfo ( //
// Init BlockArray
//
- BlockArray = (IFR_BLOCK_DATA *) AllocateZeroPool (sizeof (IFR_BLOCK_DATA));
+ BlockArray = (IFR_BLOCK_DATA *)AllocateZeroPool (sizeof (IFR_BLOCK_DATA));
if (BlockArray == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto Done;
}
+
InitializeListHead (&BlockArray->Entry);
StringPtr = StrStr (ConfigElement, L"&OFFSET=");
@@ -1920,6 +1975,7 @@ GetBlockDataInfo ( if (EFI_ERROR (Status)) {
goto Done;
}
+
Offset = 0;
CopyMem (
&Offset,
@@ -1934,6 +1990,7 @@ GetBlockDataInfo ( Status = EFI_INVALID_PARAMETER;
goto Done;
}
+
StringPtr += StrLen (L"&WIDTH=");
//
@@ -1943,6 +2000,7 @@ GetBlockDataInfo ( if (EFI_ERROR (Status)) {
goto Done;
}
+
Width = 0;
CopyMem (
&Width,
@@ -1953,7 +2011,7 @@ GetBlockDataInfo ( TmpBuffer = NULL;
StringPtr += Length;
- if (*StringPtr != 0 && *StringPtr != L'&') {
+ if ((*StringPtr != 0) && (*StringPtr != L'&')) {
Status = EFI_INVALID_PARAMETER;
goto Done;
}
@@ -1962,6 +2020,7 @@ GetBlockDataInfo ( Status = EFI_INVALID_PARAMETER;
goto Done;
}
+
StringPtr += StrLen (L"&VALUE=");
//
@@ -1973,7 +2032,7 @@ GetBlockDataInfo ( }
StringPtr += Length;
- if (*StringPtr != 0 && *StringPtr != L'&') {
+ if ((*StringPtr != 0) && (*StringPtr != L'&')) {
Status = EFI_INVALID_PARAMETER;
goto Done;
}
@@ -1983,14 +2042,15 @@ GetBlockDataInfo ( //
if ((UINT32)Offset + Width > MaxBufferSize) {
DataBuffer = ReallocatePool (
- MaxBufferSize,
- Offset + Width + HII_LIB_DEFAULT_VARSTORE_SIZE,
- DataBuffer
- );
+ MaxBufferSize,
+ Offset + Width + HII_LIB_DEFAULT_VARSTORE_SIZE,
+ DataBuffer
+ );
if (DataBuffer == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto Done;
}
+
MaxBufferSize = Offset + Width + HII_LIB_DEFAULT_VARSTORE_SIZE;
}
@@ -2004,11 +2064,12 @@ GetBlockDataInfo ( //
// Set new Block Data
//
- NewBlockData = (IFR_BLOCK_DATA *) AllocateZeroPool (sizeof (IFR_BLOCK_DATA));
+ NewBlockData = (IFR_BLOCK_DATA *)AllocateZeroPool (sizeof (IFR_BLOCK_DATA));
if (NewBlockData == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto Done;
}
+
NewBlockData->Offset = Offset;
NewBlockData->Width = Width;
@@ -2021,6 +2082,7 @@ GetBlockDataInfo ( if (NewBlockData->Width > BlockData->Width) {
BlockData->Width = NewBlockData->Width;
}
+
FreePool (NewBlockData);
break;
} else if (NewBlockData->Offset < BlockData->Offset) {
@@ -2045,6 +2107,7 @@ GetBlockDataInfo ( if (*StringPtr == 0) {
break;
}
+
//
// Go to next ConfigBlock
//
@@ -2055,16 +2118,18 @@ GetBlockDataInfo ( //
Link = BlockArray->Entry.ForwardLink;
while ((Link != &BlockArray->Entry) && (Link->ForwardLink != &BlockArray->Entry)) {
- BlockData = BASE_CR (Link, IFR_BLOCK_DATA, Entry);
+ BlockData = BASE_CR (Link, IFR_BLOCK_DATA, Entry);
NewBlockData = BASE_CR (Link->ForwardLink, IFR_BLOCK_DATA, Entry);
if ((NewBlockData->Offset >= BlockData->Offset) && (NewBlockData->Offset <= (BlockData->Offset + BlockData->Width))) {
if ((NewBlockData->Offset + NewBlockData->Width) > (BlockData->Offset + BlockData->Width)) {
- BlockData->Width = (UINT16) (NewBlockData->Offset + NewBlockData->Width - BlockData->Offset);
+ BlockData->Width = (UINT16)(NewBlockData->Offset + NewBlockData->Width - BlockData->Offset);
}
+
RemoveEntryList (Link->ForwardLink);
FreePool (NewBlockData);
continue;
}
+
Link = Link->ForwardLink;
}
@@ -2086,6 +2151,7 @@ Done: RemoveEntryList (&BlockData->Entry);
FreePool (BlockData);
}
+
FreePool (BlockArray);
}
@@ -2109,20 +2175,20 @@ Done: EFI_STATUS
EFIAPI
InternalHiiValidateCurrentSetting (
- IN EFI_STRING ConfigResp,
- IN EFI_HII_PACKAGE_LIST_HEADER *HiiPackageList,
- IN UINTN PackageListLength,
- IN EFI_GUID *VarGuid,
- IN CHAR16 *VarName,
- IN EFI_HII_HANDLE HiiHandle
+ IN EFI_STRING ConfigResp,
+ IN EFI_HII_PACKAGE_LIST_HEADER *HiiPackageList,
+ IN UINTN PackageListLength,
+ IN EFI_GUID *VarGuid,
+ IN CHAR16 *VarName,
+ IN EFI_HII_HANDLE HiiHandle
)
{
- CHAR16 *StringPtr;
- EFI_STATUS Status;
- IFR_BLOCK_DATA *CurrentBlockArray;
- IFR_BLOCK_DATA *BlockData;
- UINT8 *VarBuffer;
- BOOLEAN NameValueType;
+ CHAR16 *StringPtr;
+ EFI_STATUS Status;
+ IFR_BLOCK_DATA *CurrentBlockArray;
+ IFR_BLOCK_DATA *BlockData;
+ UINT8 *VarBuffer;
+ BOOLEAN NameValueType;
CurrentBlockArray = NULL;
VarBuffer = NULL;
@@ -2133,10 +2199,11 @@ InternalHiiValidateCurrentSetting ( // If StringPtr != NULL, get the request elements.
//
if (StrStr (ConfigResp, L"&OFFSET=") != NULL) {
- Status = GetBlockDataInfo(ConfigResp, &CurrentBlockArray, &VarBuffer);
+ Status = GetBlockDataInfo (ConfigResp, &CurrentBlockArray, &VarBuffer);
if (EFI_ERROR (Status)) {
return Status;
}
+
NameValueType = FALSE;
} else {
//
@@ -2155,17 +2222,17 @@ InternalHiiValidateCurrentSetting ( }
}
- Status = ValidateQuestionFromVfr(
- HiiPackageList,
- PackageListLength,
- VarGuid,
- VarName,
- VarBuffer,
- CurrentBlockArray,
- ConfigResp,
- HiiHandle,
- NameValueType
- );
+ Status = ValidateQuestionFromVfr (
+ HiiPackageList,
+ PackageListLength,
+ VarGuid,
+ VarName,
+ VarBuffer,
+ CurrentBlockArray,
+ ConfigResp,
+ HiiHandle,
+ NameValueType
+ );
if (VarBuffer != NULL) {
FreePool (VarBuffer);
@@ -2180,6 +2247,7 @@ InternalHiiValidateCurrentSetting ( RemoveEntryList (&BlockData->Entry);
FreePool (BlockData);
}
+
FreePool (CurrentBlockArray);
}
@@ -2199,10 +2267,10 @@ InternalHiiValidateCurrentSetting ( **/
BOOLEAN
GetElementsFromRequest (
- IN EFI_STRING ConfigRequest
+ IN EFI_STRING ConfigRequest
)
{
- EFI_STRING TmpRequest;
+ EFI_STRING TmpRequest;
TmpRequest = StrStr (ConfigRequest, L"PATH=");
ASSERT (TmpRequest != NULL);
@@ -2241,25 +2309,25 @@ GetElementsFromRequest ( BOOLEAN
EFIAPI
InternalHiiIfrValueAction (
- IN CONST EFI_STRING Request OPTIONAL,
- IN UINT16 DefaultId,
- IN UINT8 ActionType
+ IN CONST EFI_STRING Request OPTIONAL,
+ IN UINT16 DefaultId,
+ IN UINT8 ActionType
)
{
- EFI_STRING ConfigAltResp;
- EFI_STRING ConfigAltHdr;
- EFI_STRING ConfigResp;
- EFI_STRING Progress;
- EFI_STRING StringPtr;
- EFI_STRING StringHdr;
- EFI_STATUS Status;
- EFI_HANDLE DriverHandle;
- EFI_HANDLE TempDriverHandle;
- EFI_HII_HANDLE *HiiHandleBuffer;
- EFI_HII_HANDLE HiiHandle;
- UINT32 Index;
- EFI_GUID *VarGuid;
- EFI_STRING VarName;
+ EFI_STRING ConfigAltResp;
+ EFI_STRING ConfigAltHdr;
+ EFI_STRING ConfigResp;
+ EFI_STRING Progress;
+ EFI_STRING StringPtr;
+ EFI_STRING StringHdr;
+ EFI_STATUS Status;
+ EFI_HANDLE DriverHandle;
+ EFI_HANDLE TempDriverHandle;
+ EFI_HII_HANDLE *HiiHandleBuffer;
+ EFI_HII_HANDLE HiiHandle;
+ UINT32 Index;
+ EFI_GUID *VarGuid;
+ EFI_STRING VarName;
EFI_HII_PACKAGE_LIST_HEADER *HiiPackageList;
UINTN PackageListLength;
@@ -2267,12 +2335,12 @@ InternalHiiIfrValueAction ( EFI_DEVICE_PATH_PROTOCOL *DevicePath;
EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
- ConfigAltResp = NULL;
- ConfigResp = NULL;
- VarGuid = NULL;
- VarName = NULL;
- DevicePath = NULL;
- ConfigAltHdr = NULL;
+ ConfigAltResp = NULL;
+ ConfigResp = NULL;
+ VarGuid = NULL;
+ VarName = NULL;
+ DevicePath = NULL;
+ ConfigAltHdr = NULL;
HiiHandleBuffer = NULL;
Index = 0;
TempDriverHandle = NULL;
@@ -2295,12 +2363,12 @@ InternalHiiIfrValueAction ( Request,
&Progress,
&ConfigAltResp
- );
+ );
} else {
Status = gHiiConfigRouting->ExportConfig (
gHiiConfigRouting,
&ConfigAltResp
- );
+ );
}
if (EFI_ERROR (Status)) {
@@ -2323,8 +2391,9 @@ InternalHiiIfrValueAction ( Status = EFI_INVALID_PARAMETER;
goto Done;
}
+
StringPtr += StrLen (L"GUID=");
- Status = InternalHiiGetBufferFromString (StringPtr, GUID_CONFIG_STRING_TYPE, (UINT8 **) &VarGuid);
+ Status = InternalHiiGetBufferFromString (StringPtr, GUID_CONFIG_STRING_TYPE, (UINT8 **)&VarGuid);
if (EFI_ERROR (Status)) {
goto Done;
}
@@ -2335,12 +2404,14 @@ InternalHiiIfrValueAction ( while (*StringPtr != L'\0' && StrnCmp (StringPtr, L"&NAME=", StrLen (L"&NAME=")) != 0) {
StringPtr++;
}
+
if (*StringPtr == L'\0') {
Status = EFI_INVALID_PARAMETER;
goto Done;
}
+
StringPtr += StrLen (L"&NAME=");
- Status = InternalHiiGetBufferFromString (StringPtr, NAME_CONFIG_STRING_TYPE, (UINT8 **) &VarName);
+ Status = InternalHiiGetBufferFromString (StringPtr, NAME_CONFIG_STRING_TYPE, (UINT8 **)&VarName);
if (EFI_ERROR (Status)) {
goto Done;
}
@@ -2351,12 +2422,14 @@ InternalHiiIfrValueAction ( while (*StringPtr != L'\0' && StrnCmp (StringPtr, L"&PATH=", StrLen (L"&PATH=")) != 0) {
StringPtr++;
}
+
if (*StringPtr == L'\0') {
Status = EFI_INVALID_PARAMETER;
goto Done;
}
+
StringPtr += StrLen (L"&PATH=");
- Status = InternalHiiGetBufferFromString (StringPtr, PATH_CONFIG_STRING_TYPE, (UINT8 **) &DevicePath);
+ Status = InternalHiiGetBufferFromString (StringPtr, PATH_CONFIG_STRING_TYPE, (UINT8 **)&DevicePath);
if (EFI_ERROR (Status)) {
goto Done;
}
@@ -2365,7 +2438,7 @@ InternalHiiIfrValueAction ( // Get the Driver handle by the got device path.
//
TempDevicePath = DevicePath;
- Status = gBS->LocateDevicePath (&gEfiDevicePathProtocolGuid, &TempDevicePath, &DriverHandle);
+ Status = gBS->LocateDevicePath (&gEfiDevicePathProtocolGuid, &TempDevicePath, &DriverHandle);
if (EFI_ERROR (Status)) {
goto Done;
}
@@ -2379,7 +2452,7 @@ InternalHiiIfrValueAction ( goto Done;
}
- for (Index = 0; HiiHandleBuffer[Index] != NULL; Index ++) {
+ for (Index = 0; HiiHandleBuffer[Index] != NULL; Index++) {
gHiiDatabase->GetPackageListHandle (gHiiDatabase, HiiHandleBuffer[Index], &TempDriverHandle);
if (TempDriverHandle == DriverHandle) {
break;
@@ -2402,9 +2475,9 @@ InternalHiiIfrValueAction ( //
// 2. Get HiiPackage by HiiHandle
//
- PackageListLength = 0;
- HiiPackageList = NULL;
- Status = gHiiDatabase->ExportPackageLists (gHiiDatabase, HiiHandle, &PackageListLength, HiiPackageList);
+ PackageListLength = 0;
+ HiiPackageList = NULL;
+ Status = gHiiDatabase->ExportPackageLists (gHiiDatabase, HiiHandle, &PackageListLength, HiiPackageList);
//
// The return status should always be EFI_BUFFER_TOO_SMALL as input buffer's size is 0.
@@ -2438,9 +2511,9 @@ InternalHiiIfrValueAction ( VarGuid,
VarName,
DevicePath,
- (ActionType == ACTION_SET_DEFAUTL_VALUE) ? &DefaultId:NULL, // it can be NULL to get the current setting.
+ (ActionType == ACTION_SET_DEFAUTL_VALUE) ? &DefaultId : NULL, // it can be NULL to get the current setting.
&ConfigResp
- );
+ );
//
// The required setting can't be found. So, it is not required to be validated and set.
@@ -2449,6 +2522,7 @@ InternalHiiIfrValueAction ( Status = EFI_SUCCESS;
goto NextConfigAltResp;
}
+
//
// Only the ConfigHdr is found. Not any block data is found. No data is required to be validated and set.
//
@@ -2512,6 +2586,7 @@ NextConfigAltResp: while (*StringPtr != L'\0' && *StringPtr != L'&') {
StringPtr++;
}
+
if (*StringPtr == L'\0') {
break;
}
@@ -2520,12 +2595,13 @@ NextConfigAltResp: // Construct ConfigAltHdr string "&<ConfigHdr>&ALTCFG=\0"
// | 1 | StrLen (ConfigHdr) | 8 | 1 |
//
- MaxLen = 1 + StringPtr - StringHdr + 8 + 1;
- ConfigAltHdr = AllocateZeroPool ( MaxLen * sizeof (CHAR16));
+ MaxLen = 1 + StringPtr - StringHdr + 8 + 1;
+ ConfigAltHdr = AllocateZeroPool (MaxLen * sizeof (CHAR16));
if (ConfigAltHdr == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto Done;
}
+
StrCpyS (ConfigAltHdr, MaxLen, L"&");
StrnCatS (ConfigAltHdr, MaxLen, StringHdr, StringPtr - StringHdr);
StrCatS (ConfigAltHdr, MaxLen, L"&ALTCFG=");
@@ -2559,7 +2635,7 @@ NextConfigAltResp: //
// Skip char '&'
//
- StringPtr ++;
+ StringPtr++;
}
Done:
@@ -2611,7 +2687,7 @@ Done: BOOLEAN
EFIAPI
HiiValidateSettings (
- IN CONST EFI_STRING Request OPTIONAL
+ IN CONST EFI_STRING Request OPTIONAL
)
{
return InternalHiiIfrValueAction (Request, 0, ACTION_VALIDATE_SETTING);
@@ -2636,8 +2712,8 @@ HiiValidateSettings ( BOOLEAN
EFIAPI
HiiSetToDefaults (
- IN CONST EFI_STRING Request OPTIONAL,
- IN UINT16 DefaultId
+ IN CONST EFI_STRING Request OPTIONAL,
+ IN UINT16 DefaultId
)
{
return InternalHiiIfrValueAction (Request, DefaultId, ACTION_SET_DEFAUTL_VALUE);
@@ -2761,7 +2837,7 @@ HiiIsConfigHdrMatch ( Result = InternalHiiCompareSubString (ConfigHdr, CompareConfigHdr, L"GUID=", L"&NAME=");
}
- if (Result && Name != NULL) {
+ if (Result && (Name != NULL)) {
//
// Compare NAME value strings
//
@@ -2817,8 +2893,8 @@ HiiGetBrowserData ( //
// Construct <ConfigResp> mConfigHdrTemplate L'&' ResultsData L'\0'
//
- Size = (StrLen (mConfigHdrTemplate) + 1) * sizeof (CHAR16);
- Size = Size + (StrLen (ResultsData) + 1) * sizeof (CHAR16);
+ Size = (StrLen (mConfigHdrTemplate) + 1) * sizeof (CHAR16);
+ Size = Size + (StrLen (ResultsData) + 1) * sizeof (CHAR16);
ConfigResp = AllocateZeroPool (Size);
UnicodeSPrint (ConfigResp, Size, L"%s&%s", mConfigHdrTemplate, ResultsData);
@@ -2898,7 +2974,7 @@ HiiSetBrowserData ( // Allocate and fill a buffer large enough to hold the <ConfigHdr> template
// followed by "&OFFSET=0&WIDTH=WWWWWWWWWWWWWWWW" followed by a Null-terminator
//
- Size = (StrLen (mConfigHdrTemplate) + 32 + 1) * sizeof (CHAR16);
+ Size = (StrLen (mConfigHdrTemplate) + 32 + 1) * sizeof (CHAR16);
ConfigRequest = AllocateZeroPool (Size);
UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", mConfigHdrTemplate, (UINT64)BufferSize);
} else {
@@ -2906,11 +2982,12 @@ HiiSetBrowserData ( // Allocate and fill a buffer large enough to hold the <ConfigHdr> template
// followed by <RequestElement> followed by a Null-terminator
//
- Size = StrLen (mConfigHdrTemplate) * sizeof (CHAR16);
- Size = Size + (StrLen (RequestElement) + 1) * sizeof (CHAR16);
+ Size = StrLen (mConfigHdrTemplate) * sizeof (CHAR16);
+ Size = Size + (StrLen (RequestElement) + 1) * sizeof (CHAR16);
ConfigRequest = AllocateZeroPool (Size);
UnicodeSPrint (ConfigRequest, Size, L"%s%s", mConfigHdrTemplate, RequestElement);
}
+
if (ConfigRequest == NULL) {
return FALSE;
}
@@ -2927,7 +3004,7 @@ HiiSetBrowserData ( //
// Set data in the uncommitted browser state information
//
- ResultsData = InternalHiiBrowserCallback (VariableGuid, VariableName, ConfigResp + StrLen(mConfigHdrTemplate) + 1);
+ ResultsData = InternalHiiBrowserCallback (VariableGuid, VariableName, ConfigResp + StrLen (mConfigHdrTemplate) + 1);
FreePool (ConfigResp);
return (BOOLEAN)(ResultsData != NULL);
@@ -2942,15 +3019,15 @@ HiiSetBrowserData ( #define HII_LIB_OPCODE_ALLOCATION_SIZE 0x200
typedef struct {
- UINT8 *Buffer;
- UINTN BufferSize;
- UINTN Position;
+ UINT8 *Buffer;
+ UINTN BufferSize;
+ UINTN Position;
} HII_LIB_OPCODE_BUFFER;
///
/// Lookup table that converts EFI_IFR_TYPE_X enum values to a width in bytes
///
-GLOBAL_REMOVE_IF_UNREFERENCED CONST UINT8 mHiiDefaultTypeToWidth[] = {
+GLOBAL_REMOVE_IF_UNREFERENCED CONST UINT8 mHiiDefaultTypeToWidth[] = {
1, // EFI_IFR_TYPE_NUM_SIZE_8
2, // EFI_IFR_TYPE_NUM_SIZE_16
4, // EFI_IFR_TYPE_NUM_SIZE_32
@@ -2981,13 +3058,15 @@ HiiAllocateOpCodeHandle ( if (OpCodeBuffer == NULL) {
return NULL;
}
+
OpCodeBuffer->Buffer = (UINT8 *)AllocatePool (HII_LIB_OPCODE_ALLOCATION_SIZE);
if (OpCodeBuffer->Buffer == NULL) {
FreePool (OpCodeBuffer);
return NULL;
}
+
OpCodeBuffer->BufferSize = HII_LIB_OPCODE_ALLOCATION_SIZE;
- OpCodeBuffer->Position = 0;
+ OpCodeBuffer->Position = 0;
return (VOID *)OpCodeBuffer;
}
@@ -3015,6 +3094,7 @@ HiiFreeOpCodeHandle ( if (OpCodeBuffer->Buffer != NULL) {
FreePool (OpCodeBuffer->Buffer);
}
+
FreePool (OpCodeBuffer);
}
@@ -3074,15 +3154,16 @@ InternalHiiGrowOpCodeHandle ( OpCodeBuffer = (HII_LIB_OPCODE_BUFFER *)OpCodeHandle;
if (OpCodeBuffer->Position + Size > OpCodeBuffer->BufferSize) {
Buffer = ReallocatePool (
- OpCodeBuffer->BufferSize,
- OpCodeBuffer->BufferSize + (Size + HII_LIB_OPCODE_ALLOCATION_SIZE),
- OpCodeBuffer->Buffer
- );
+ OpCodeBuffer->BufferSize,
+ OpCodeBuffer->BufferSize + (Size + HII_LIB_OPCODE_ALLOCATION_SIZE),
+ OpCodeBuffer->Buffer
+ );
ASSERT (Buffer != NULL);
- OpCodeBuffer->Buffer = Buffer;
+ OpCodeBuffer->Buffer = Buffer;
OpCodeBuffer->BufferSize += (Size + HII_LIB_OPCODE_ALLOCATION_SIZE);
}
- Buffer = OpCodeBuffer->Buffer + OpCodeBuffer->Position;
+
+ Buffer = OpCodeBuffer->Buffer + OpCodeBuffer->Position;
OpCodeBuffer->Position += Size;
return Buffer;
}
@@ -3116,11 +3197,11 @@ InternalHiiCreateOpCodeExtended ( ASSERT (OpCodeTemplate != NULL);
ASSERT ((OpCodeSize + ExtensionSize) <= 0x7F);
- Header = (EFI_IFR_OP_HEADER *)OpCodeTemplate;
+ Header = (EFI_IFR_OP_HEADER *)OpCodeTemplate;
Header->OpCode = OpCode;
Header->Scope = Scope;
Header->Length = (UINT8)(OpCodeSize + ExtensionSize);
- Buffer = InternalHiiGrowOpCodeHandle (OpCodeHandle, Header->Length);
+ Buffer = InternalHiiGrowOpCodeHandle (OpCodeHandle, Header->Length);
return (UINT8 *)CopyMem (Buffer, Header, OpCodeSize);
}
@@ -3259,11 +3340,11 @@ HiiCreateOneOfOptionOpCode ( ZeroMem (&OpCode, sizeof (OpCode));
OpCode.Option = StringId;
- OpCode.Flags = (UINT8) (Flags & (EFI_IFR_OPTION_DEFAULT | EFI_IFR_OPTION_DEFAULT_MFG));
+ OpCode.Flags = (UINT8)(Flags & (EFI_IFR_OPTION_DEFAULT | EFI_IFR_OPTION_DEFAULT_MFG));
OpCode.Type = Type;
CopyMem (&OpCode.Value, &Value, mHiiDefaultTypeToWidth[Type]);
- return InternalHiiCreateOpCode (OpCodeHandle, &OpCode, EFI_IFR_ONE_OF_OPTION_OP, OFFSET_OF(EFI_IFR_ONE_OF_OPTION, Value) + mHiiDefaultTypeToWidth[Type]);
+ return InternalHiiCreateOpCode (OpCodeHandle, &OpCode, EFI_IFR_ONE_OF_OPTION_OP, OFFSET_OF (EFI_IFR_ONE_OF_OPTION, Value) + mHiiDefaultTypeToWidth[Type]);
}
/**
@@ -3299,7 +3380,7 @@ HiiCreateDefaultOpCode ( OpCode.DefaultId = DefaultId;
CopyMem (&OpCode.Value, &Value, mHiiDefaultTypeToWidth[Type]);
- return InternalHiiCreateOpCode (OpCodeHandle, &OpCode, EFI_IFR_DEFAULT_OP, OFFSET_OF(EFI_IFR_DEFAULT, Value) + mHiiDefaultTypeToWidth[Type]);
+ return InternalHiiCreateOpCode (OpCodeHandle, &OpCode, EFI_IFR_DEFAULT_OP, OFFSET_OF (EFI_IFR_DEFAULT, Value) + mHiiDefaultTypeToWidth[Type]);
}
/**
@@ -3351,9 +3432,10 @@ HiiCreateGuidOpCode ( OpCodeSize - sizeof (OpCode),
0
);
- if (OpCodePointer != NULL && GuidOpCode != NULL) {
+ if ((OpCodePointer != NULL) && (GuidOpCode != NULL)) {
CopyMem (OpCodePointer + 1, (EFI_IFR_GUID *)GuidOpCode + 1, OpCodeSize - sizeof (OpCode));
}
+
return (UINT8 *)OpCodePointer;
}
@@ -3676,7 +3758,7 @@ HiiCreateNumericOpCode ( ASSERT ((QuestionFlags & (~(EFI_IFR_FLAG_READ_ONLY | EFI_IFR_FLAG_CALLBACK | EFI_IFR_FLAG_RESET_REQUIRED | EFI_IFR_FLAG_REST_STYLE))) == 0);
- Length = 0;
+ Length = 0;
ZeroMem (&OpCode, sizeof (OpCode));
OpCode.Question.QuestionId = QuestionId;
OpCode.Question.VarStoreId = VarStoreId;
@@ -3687,33 +3769,33 @@ HiiCreateNumericOpCode ( OpCode.Flags = NumericFlags;
switch (NumericFlags & EFI_IFR_NUMERIC_SIZE) {
- case EFI_IFR_NUMERIC_SIZE_1:
- OpCode.data.u8.MinValue = (UINT8)Minimum;
- OpCode.data.u8.MaxValue = (UINT8)Maximum;
- OpCode.data.u8.Step = (UINT8)Step;
- Length = 3;
- break;
-
- case EFI_IFR_NUMERIC_SIZE_2:
- OpCode.data.u16.MinValue = (UINT16)Minimum;
- OpCode.data.u16.MaxValue = (UINT16)Maximum;
- OpCode.data.u16.Step = (UINT16)Step;
- Length = 6;
- break;
-
- case EFI_IFR_NUMERIC_SIZE_4:
- OpCode.data.u32.MinValue = (UINT32)Minimum;
- OpCode.data.u32.MaxValue = (UINT32)Maximum;
- OpCode.data.u32.Step = (UINT32)Step;
- Length = 12;
- break;
-
- case EFI_IFR_NUMERIC_SIZE_8:
- OpCode.data.u64.MinValue = Minimum;
- OpCode.data.u64.MaxValue = Maximum;
- OpCode.data.u64.Step = Step;
- Length = 24;
- break;
+ case EFI_IFR_NUMERIC_SIZE_1:
+ OpCode.data.u8.MinValue = (UINT8)Minimum;
+ OpCode.data.u8.MaxValue = (UINT8)Maximum;
+ OpCode.data.u8.Step = (UINT8)Step;
+ Length = 3;
+ break;
+
+ case EFI_IFR_NUMERIC_SIZE_2:
+ OpCode.data.u16.MinValue = (UINT16)Minimum;
+ OpCode.data.u16.MaxValue = (UINT16)Maximum;
+ OpCode.data.u16.Step = (UINT16)Step;
+ Length = 6;
+ break;
+
+ case EFI_IFR_NUMERIC_SIZE_4:
+ OpCode.data.u32.MinValue = (UINT32)Minimum;
+ OpCode.data.u32.MaxValue = (UINT32)Maximum;
+ OpCode.data.u32.Step = (UINT32)Step;
+ Length = 12;
+ break;
+
+ case EFI_IFR_NUMERIC_SIZE_8:
+ OpCode.data.u64.MinValue = Minimum;
+ OpCode.data.u64.MaxValue = Maximum;
+ OpCode.data.u64.Step = Step;
+ Length = 24;
+ break;
}
Length += OFFSET_OF (EFI_IFR_NUMERIC, data);
@@ -3784,7 +3866,7 @@ HiiCreateStringOpCode ( OpCode.Question.Flags = QuestionFlags;
OpCode.MinSize = MinSize;
OpCode.MaxSize = MaxSize;
- OpCode.Flags = (UINT8) (StringFlags & EFI_IFR_STRING_MULTI_LINE);
+ OpCode.Flags = (UINT8)(StringFlags & EFI_IFR_STRING_MULTI_LINE);
if (DefaultsOpCodeHandle == NULL) {
return InternalHiiCreateOpCode (OpCodeHandle, &OpCode, EFI_IFR_STRING_OP, sizeof (OpCode));
@@ -3861,6 +3943,7 @@ HiiCreateOneOfOpCode ( if (DefaultsOpCodeHandle != NULL) {
InternalHiiAppendOpCodes (OpCodeHandle, DefaultsOpCodeHandle);
}
+
HiiCreateEndOpCode (OpCodeHandle);
return InternalHiiOpCodeHandleBuffer (OpCodeHandle) + Position;
}
@@ -3930,6 +4013,7 @@ HiiCreateOrderedListOpCode ( if (DefaultsOpCodeHandle != NULL) {
InternalHiiAppendOpCodes (OpCodeHandle, DefaultsOpCodeHandle);
}
+
HiiCreateEndOpCode (OpCodeHandle);
return InternalHiiOpCodeHandleBuffer (OpCodeHandle) + Position;
}
@@ -4006,8 +4090,8 @@ HiiCreateDateOpCode ( IN VOID *DefaultsOpCodeHandle OPTIONAL
)
{
- EFI_IFR_DATE OpCode;
- UINTN Position;
+ EFI_IFR_DATE OpCode;
+ UINTN Position;
ASSERT ((QuestionFlags & (~(EFI_IFR_FLAG_READ_ONLY | EFI_IFR_FLAG_CALLBACK | EFI_IFR_FLAG_RESET_REQUIRED | EFI_IFR_FLAG_REST_STYLE))) == 0);
ASSERT ((DateFlags & (~(EFI_QF_DATE_YEAR_SUPPRESS | EFI_QF_DATE_MONTH_SUPPRESS | EFI_QF_DATE_DAY_SUPPRESS | EFI_QF_DATE_STORAGE))) == 0);
@@ -4071,8 +4155,8 @@ HiiCreateTimeOpCode ( IN VOID *DefaultsOpCodeHandle OPTIONAL
)
{
- EFI_IFR_TIME OpCode;
- UINTN Position;
+ EFI_IFR_TIME OpCode;
+ UINTN Position;
ASSERT ((QuestionFlags & (~(EFI_IFR_FLAG_READ_ONLY | EFI_IFR_FLAG_CALLBACK | EFI_IFR_FLAG_RESET_REQUIRED | EFI_IFR_FLAG_REST_STYLE))) == 0);
ASSERT ((TimeFlags & (~(QF_TIME_HOUR_SUPPRESS | QF_TIME_MINUTE_SUPPRESS | QF_TIME_SECOND_SUPPRESS | QF_TIME_STORAGE))) == 0);
@@ -4117,33 +4201,33 @@ HiiCreateTimeOpCode ( EFI_STATUS
EFIAPI
InternalHiiUpdateFormPackageData (
- IN EFI_GUID *FormSetGuid OPTIONAL,
- IN EFI_FORM_ID FormId,
- IN EFI_HII_PACKAGE_HEADER *Package,
- IN HII_LIB_OPCODE_BUFFER *OpCodeBufferStart,
- IN HII_LIB_OPCODE_BUFFER *OpCodeBufferEnd OPTIONAL,
- OUT EFI_HII_PACKAGE_HEADER *TempPackage
+ IN EFI_GUID *FormSetGuid OPTIONAL,
+ IN EFI_FORM_ID FormId,
+ IN EFI_HII_PACKAGE_HEADER *Package,
+ IN HII_LIB_OPCODE_BUFFER *OpCodeBufferStart,
+ IN HII_LIB_OPCODE_BUFFER *OpCodeBufferEnd OPTIONAL,
+ OUT EFI_HII_PACKAGE_HEADER *TempPackage
)
{
- UINTN AddSize;
- UINT8 *BufferPos;
- EFI_HII_PACKAGE_HEADER PackageHeader;
- UINTN Offset;
- EFI_IFR_OP_HEADER *IfrOpHdr;
- EFI_IFR_OP_HEADER *UpdateIfrOpHdr;
- BOOLEAN GetFormSet;
- BOOLEAN GetForm;
- BOOLEAN Updated;
- UINTN UpdatePackageLength;
+ UINTN AddSize;
+ UINT8 *BufferPos;
+ EFI_HII_PACKAGE_HEADER PackageHeader;
+ UINTN Offset;
+ EFI_IFR_OP_HEADER *IfrOpHdr;
+ EFI_IFR_OP_HEADER *UpdateIfrOpHdr;
+ BOOLEAN GetFormSet;
+ BOOLEAN GetForm;
+ BOOLEAN Updated;
+ UINTN UpdatePackageLength;
CopyMem (TempPackage, Package, sizeof (EFI_HII_PACKAGE_HEADER));
UpdatePackageLength = sizeof (EFI_HII_PACKAGE_HEADER);
- BufferPos = (UINT8 *) (TempPackage + 1);
+ BufferPos = (UINT8 *)(TempPackage + 1);
CopyMem (&PackageHeader, Package, sizeof (EFI_HII_PACKAGE_HEADER));
- IfrOpHdr = (EFI_IFR_OP_HEADER *)((UINT8 *) Package + sizeof (EFI_HII_PACKAGE_HEADER));
+ IfrOpHdr = (EFI_IFR_OP_HEADER *)((UINT8 *)Package + sizeof (EFI_HII_PACKAGE_HEADER));
Offset = sizeof (EFI_HII_PACKAGE_HEADER);
- GetFormSet = (BOOLEAN) ((FormSetGuid == NULL) ? TRUE : FALSE);
+ GetFormSet = (BOOLEAN)((FormSetGuid == NULL) ? TRUE : FALSE);
GetForm = FALSE;
Updated = FALSE;
@@ -4156,13 +4240,13 @@ InternalHiiUpdateFormPackageData ( // Find the matched FormSet and Form
//
if ((IfrOpHdr->OpCode == EFI_IFR_FORM_SET_OP) && (FormSetGuid != NULL)) {
- if (CompareGuid((GUID *)(VOID *)&((EFI_IFR_FORM_SET *) IfrOpHdr)->Guid, FormSetGuid)) {
+ if (CompareGuid ((GUID *)(VOID *)&((EFI_IFR_FORM_SET *)IfrOpHdr)->Guid, FormSetGuid)) {
GetFormSet = TRUE;
} else {
GetFormSet = FALSE;
}
- } else if (IfrOpHdr->OpCode == EFI_IFR_FORM_OP || IfrOpHdr->OpCode == EFI_IFR_FORM_MAP_OP) {
- if (CompareMem (&((EFI_IFR_FORM *) IfrOpHdr)->FormId, &FormId, sizeof (EFI_FORM_ID)) == 0) {
+ } else if ((IfrOpHdr->OpCode == EFI_IFR_FORM_OP) || (IfrOpHdr->OpCode == EFI_IFR_FORM_MAP_OP)) {
+ if (CompareMem (&((EFI_IFR_FORM *)IfrOpHdr)->FormId, &FormId, sizeof (EFI_FORM_ID)) == 0) {
GetForm = TRUE;
} else {
GetForm = FALSE;
@@ -4173,29 +4257,32 @@ InternalHiiUpdateFormPackageData ( // The matched Form is found, and Update data in this form
//
if (GetFormSet && GetForm) {
- UpdateIfrOpHdr = (EFI_IFR_OP_HEADER *) OpCodeBufferStart->Buffer;
+ UpdateIfrOpHdr = (EFI_IFR_OP_HEADER *)OpCodeBufferStart->Buffer;
if ((UpdateIfrOpHdr->Length == IfrOpHdr->Length) && \
- (CompareMem (IfrOpHdr, UpdateIfrOpHdr, UpdateIfrOpHdr->Length) == 0)) {
+ (CompareMem (IfrOpHdr, UpdateIfrOpHdr, UpdateIfrOpHdr->Length) == 0))
+ {
//
// Remove the original data when End OpCode buffer exist.
//
if (OpCodeBufferEnd != NULL) {
Offset += IfrOpHdr->Length;
- IfrOpHdr = (EFI_IFR_OP_HEADER *) ((UINT8 *) (IfrOpHdr) + IfrOpHdr->Length);
- UpdateIfrOpHdr = (EFI_IFR_OP_HEADER *) OpCodeBufferEnd->Buffer;
+ IfrOpHdr = (EFI_IFR_OP_HEADER *)((UINT8 *)(IfrOpHdr) + IfrOpHdr->Length);
+ UpdateIfrOpHdr = (EFI_IFR_OP_HEADER *)OpCodeBufferEnd->Buffer;
while (Offset < PackageHeader.Length) {
//
// Search the matched end opcode
//
if ((UpdateIfrOpHdr->Length == IfrOpHdr->Length) && \
- (CompareMem (IfrOpHdr, UpdateIfrOpHdr, UpdateIfrOpHdr->Length) == 0)) {
+ (CompareMem (IfrOpHdr, UpdateIfrOpHdr, UpdateIfrOpHdr->Length) == 0))
+ {
break;
}
+
//
// Go to the next Op-Code
//
- Offset += IfrOpHdr->Length;
- IfrOpHdr = (EFI_IFR_OP_HEADER *) ((UINT8 *) (IfrOpHdr) + IfrOpHdr->Length);
+ Offset += IfrOpHdr->Length;
+ IfrOpHdr = (EFI_IFR_OP_HEADER *)((UINT8 *)(IfrOpHdr) + IfrOpHdr->Length);
}
if (Offset >= PackageHeader.Length) {
@@ -4209,7 +4296,7 @@ InternalHiiUpdateFormPackageData ( //
// Insert the updated data
//
- AddSize = ((EFI_IFR_OP_HEADER *) OpCodeBufferStart->Buffer)->Length;
+ AddSize = ((EFI_IFR_OP_HEADER *)OpCodeBufferStart->Buffer)->Length;
CopyMem (BufferPos, OpCodeBufferStart->Buffer + AddSize, OpCodeBufferStart->Position - AddSize);
BufferPos += OpCodeBufferStart->Position - AddSize;
UpdatePackageLength += OpCodeBufferStart->Position - AddSize;
@@ -4227,7 +4314,7 @@ InternalHiiUpdateFormPackageData ( // Copy the left package data.
//
Offset += IfrOpHdr->Length;
- CopyMem (BufferPos, (UINT8 *) Package + Offset, PackageHeader.Length - Offset);
+ CopyMem (BufferPos, (UINT8 *)Package + Offset, PackageHeader.Length - Offset);
UpdatePackageLength += PackageHeader.Length - Offset;
//
@@ -4241,8 +4328,8 @@ InternalHiiUpdateFormPackageData ( //
// Go to the next Op-Code
//
- Offset += IfrOpHdr->Length;
- IfrOpHdr = (EFI_IFR_OP_HEADER *) ((CHAR8 *) (IfrOpHdr) + IfrOpHdr->Length);
+ Offset += IfrOpHdr->Length;
+ IfrOpHdr = (EFI_IFR_OP_HEADER *)((CHAR8 *)(IfrOpHdr) + IfrOpHdr->Length);
}
if (!Updated) {
@@ -4251,10 +4338,11 @@ InternalHiiUpdateFormPackageData ( //
return EFI_NOT_FOUND;
}
+
//
// Update the package length.
//
- PackageHeader.Length = (UINT32) UpdatePackageLength;
+ PackageHeader.Length = (UINT32)UpdatePackageLength;
CopyMem (TempPackage, &PackageHeader, sizeof (EFI_HII_PACKAGE_HEADER));
return EFI_SUCCESS;
@@ -4353,15 +4441,15 @@ HiiUpdateForm ( //
// Retrieve buffer data from Opcode Handle
//
- OpCodeBufferStart = (HII_LIB_OPCODE_BUFFER *) StartOpCodeHandle;
- OpCodeBufferEnd = (HII_LIB_OPCODE_BUFFER *) EndOpCodeHandle;
+ OpCodeBufferStart = (HII_LIB_OPCODE_BUFFER *)StartOpCodeHandle;
+ OpCodeBufferEnd = (HII_LIB_OPCODE_BUFFER *)EndOpCodeHandle;
//
// Get the original package list
//
- BufferSize = 0;
- HiiPackageList = NULL;
- Status = gHiiDatabase->ExportPackageLists (gHiiDatabase, HiiHandle, &BufferSize, HiiPackageList);
+ BufferSize = 0;
+ HiiPackageList = NULL;
+ Status = gHiiDatabase->ExportPackageLists (gHiiDatabase, HiiHandle, &BufferSize, HiiPackageList);
//
// The return status should always be EFI_BUFFER_TOO_SMALL as input buffer's size is 0.
//
@@ -4383,7 +4471,7 @@ HiiUpdateForm ( //
// Calculate and allocate space for retrieval of IFR data
//
- BufferSize += OpCodeBufferStart->Position;
+ BufferSize += OpCodeBufferStart->Position;
UpdatePackageList = AllocateZeroPool (BufferSize);
if (UpdatePackageList == NULL) {
Status = EFI_OUT_OF_RESOURCES;
@@ -4399,7 +4487,7 @@ HiiUpdateForm ( goto Finish;
}
- UpdateBufferPos = (UINT8 *) UpdatePackageList;
+ UpdateBufferPos = (UINT8 *)UpdatePackageList;
//
// Copy the package list header
@@ -4410,11 +4498,11 @@ HiiUpdateForm ( //
// Go through each package to find the matched package and update one by one
//
- Updated = FALSE;
- Offset = sizeof (EFI_HII_PACKAGE_LIST_HEADER);
+ Updated = FALSE;
+ Offset = sizeof (EFI_HII_PACKAGE_LIST_HEADER);
PackageListLength = ReadUnaligned32 (&HiiPackageList->PackageLength);
while (Offset < PackageListLength) {
- Package = (EFI_HII_PACKAGE_HEADER *) (((UINT8 *) HiiPackageList) + Offset);
+ Package = (EFI_HII_PACKAGE_HEADER *)(((UINT8 *)HiiPackageList) + Offset);
CopyMem (&PackageHeader, Package, sizeof (EFI_HII_PACKAGE_HEADER));
Offset += Package->Length;
@@ -4426,7 +4514,7 @@ HiiUpdateForm ( //
// The matched package is found. Its package buffer will be updated by the input new data.
//
- if (!EFI_ERROR(Status)) {
+ if (!EFI_ERROR (Status)) {
//
// Set Update Flag
//
@@ -4450,8 +4538,8 @@ HiiUpdateForm ( //
// Update package list length
//
- BufferSize = UpdateBufferPos - (UINT8 *) UpdatePackageList;
- WriteUnaligned32 (&UpdatePackageList->PackageLength, (UINT32) BufferSize);
+ BufferSize = UpdateBufferPos - (UINT8 *)UpdatePackageList;
+ WriteUnaligned32 (&UpdatePackageList->PackageLength, (UINT32)BufferSize);
//
// Update Package to show form
diff --git a/MdeModulePkg/Library/UefiHiiLib/HiiString.c b/MdeModulePkg/Library/UefiHiiLib/HiiString.c index 078811e835..2c586ef64d 100644 --- a/MdeModulePkg/Library/UefiHiiLib/HiiString.c +++ b/MdeModulePkg/Library/UefiHiiLib/HiiString.c @@ -7,7 +7,6 @@ **/
-
#include "InternalHiiLib.h"
/**
@@ -57,10 +56,10 @@ HiiSetString ( IN CONST CHAR8 *SupportedLanguages OPTIONAL
)
{
- EFI_STATUS Status;
- CHAR8 *AllocatedLanguages;
- CHAR8 *Supported;
- CHAR8 *Language;
+ EFI_STATUS Status;
+ CHAR8 *AllocatedLanguages;
+ CHAR8 *Supported;
+ CHAR8 *Language;
ASSERT (HiiHandle != NULL);
ASSERT (String != NULL);
@@ -97,12 +96,14 @@ HiiSetString ( //
// Search for the next language separator and replace it with a Null-terminator
//
- for (; *Supported != 0 && *Supported != ';'; Supported++);
+ for ( ; *Supported != 0 && *Supported != ';'; Supported++) {
+ }
+
if (*Supported != 0) {
*(Supported++) = '\0';
}
- if ((SupportedLanguages == NULL) && AsciiStrnCmp (Language, UEFI_CONFIG_LANG, AsciiStrLen (UEFI_CONFIG_LANG)) == 0) {
+ if ((SupportedLanguages == NULL) && (AsciiStrnCmp (Language, UEFI_CONFIG_LANG, AsciiStrLen (UEFI_CONFIG_LANG)) == 0)) {
//
// Skip string package used for keyword protocol.
//
@@ -138,7 +139,6 @@ HiiSetString ( }
}
-
/**
Retrieves a string from a string package names by GUID in a specific language.
If the language is not specified, then a string from a string package in the
@@ -292,7 +292,7 @@ HiiGetStringEx ( //
// Get the current platform language setting
//
- GetEfiGlobalVariable2 (L"PlatformLang", (VOID**)&PlatformLanguage, NULL);
+ GetEfiGlobalVariable2 (L"PlatformLang", (VOID **)&PlatformLanguage, NULL);
//
// If Languag is NULL, then set it to an empty string, so it will be
@@ -318,23 +318,22 @@ HiiGetStringEx ( goto Error;
}
} else {
- BestLanguage = (CHAR8 *) Language;
+ BestLanguage = (CHAR8 *)Language;
}
-
//
// Retrieve the size of the string in the string package for the BestLanguage
//
StringSize = 0;
- Status = gHiiString->GetString (
- gHiiString,
- BestLanguage,
- HiiHandle,
- StringId,
- &TempString,
- &StringSize,
- NULL
- );
+ Status = gHiiString->GetString (
+ gHiiString,
+ BestLanguage,
+ HiiHandle,
+ StringId,
+ &TempString,
+ &StringSize,
+ NULL
+ );
//
// If GetString() returns EFI_SUCCESS for a zero size,
// then there are no supported languages registered for HiiHandle. If GetString()
@@ -380,10 +379,12 @@ Error: if (SupportedLanguages != NULL) {
FreePool (SupportedLanguages);
}
+
if (PlatformLanguage != NULL) {
FreePool (PlatformLanguage);
}
- if (TryBestLanguage && BestLanguage != NULL) {
+
+ if (TryBestLanguage && (BestLanguage != NULL)) {
FreePool (BestLanguage);
}
diff --git a/MdeModulePkg/Library/UefiHiiServicesLib/UefiHiiServicesLib.c b/MdeModulePkg/Library/UefiHiiServicesLib/UefiHiiServicesLib.c index 179559bb98..f0a8b9fe62 100644 --- a/MdeModulePkg/Library/UefiHiiServicesLib/UefiHiiServicesLib.c +++ b/MdeModulePkg/Library/UefiHiiServicesLib/UefiHiiServicesLib.c @@ -73,35 +73,35 @@ UefiHiiServicesLibConstructor ( IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
//
// Retrieve the pointer to the UEFI HII String Protocol
//
- Status = gBS->LocateProtocol (&gEfiHiiStringProtocolGuid, NULL, (VOID **) &gHiiString);
+ Status = gBS->LocateProtocol (&gEfiHiiStringProtocolGuid, NULL, (VOID **)&gHiiString);
ASSERT_EFI_ERROR (Status);
//
// Retrieve the pointer to the UEFI HII Database Protocol
//
- Status = gBS->LocateProtocol (&gEfiHiiDatabaseProtocolGuid, NULL, (VOID **) &gHiiDatabase);
+ Status = gBS->LocateProtocol (&gEfiHiiDatabaseProtocolGuid, NULL, (VOID **)&gHiiDatabase);
ASSERT_EFI_ERROR (Status);
//
// Retrieve the pointer to the UEFI HII Config Routing Protocol
//
- Status = gBS->LocateProtocol (&gEfiHiiConfigRoutingProtocolGuid, NULL, (VOID **) &gHiiConfigRouting);
+ Status = gBS->LocateProtocol (&gEfiHiiConfigRoutingProtocolGuid, NULL, (VOID **)&gHiiConfigRouting);
ASSERT_EFI_ERROR (Status);
//
// Retrieve the pointer to the optional UEFI HII Font Protocol
//
- gBS->LocateProtocol (&gEfiHiiFontProtocolGuid, NULL, (VOID **) &gHiiFont);
+ gBS->LocateProtocol (&gEfiHiiFontProtocolGuid, NULL, (VOID **)&gHiiFont);
//
// Retrieve the pointer to the optional UEFI HII Image Protocol
//
- gBS->LocateProtocol (&gEfiHiiImageProtocolGuid, NULL, (VOID **) &gHiiImage);
+ gBS->LocateProtocol (&gEfiHiiImageProtocolGuid, NULL, (VOID **)&gHiiImage);
return EFI_SUCCESS;
}
diff --git a/MdeModulePkg/Library/UefiMemoryAllocationProfileLib/DxeMemoryProfileLib.c b/MdeModulePkg/Library/UefiMemoryAllocationProfileLib/DxeMemoryProfileLib.c index fadf0b7f6a..84708e2256 100644 --- a/MdeModulePkg/Library/UefiMemoryAllocationProfileLib/DxeMemoryProfileLib.c +++ b/MdeModulePkg/Library/UefiMemoryAllocationProfileLib/DxeMemoryProfileLib.c @@ -6,16 +6,14 @@ **/
-
#include <Uefi.h>
-
#include <Library/UefiBootServicesTableLib.h>
#include <Library/DebugLib.h>
#include <Guid/MemoryProfile.h>
-EDKII_MEMORY_PROFILE_PROTOCOL *mLibProfileProtocol;
+EDKII_MEMORY_PROFILE_PROTOCOL *mLibProfileProtocol;
/**
The constructor function initializes memory profile for DXE phase.
@@ -33,12 +31,12 @@ MemoryProfileLibConstructor ( IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
Status = gBS->LocateProtocol (
&gEdkiiMemoryProfileGuid,
NULL,
- (VOID **) &mLibProfileProtocol
+ (VOID **)&mLibProfileProtocol
);
if (EFI_ERROR (Status)) {
mLibProfileProtocol = NULL;
@@ -72,17 +70,18 @@ MemoryProfileLibConstructor ( EFI_STATUS
EFIAPI
MemoryProfileLibRecord (
- IN PHYSICAL_ADDRESS CallerAddress,
- IN MEMORY_PROFILE_ACTION Action,
- IN EFI_MEMORY_TYPE MemoryType,
- IN VOID *Buffer,
- IN UINTN Size,
- IN CHAR8 *ActionString OPTIONAL
+ IN PHYSICAL_ADDRESS CallerAddress,
+ IN MEMORY_PROFILE_ACTION Action,
+ IN EFI_MEMORY_TYPE MemoryType,
+ IN VOID *Buffer,
+ IN UINTN Size,
+ IN CHAR8 *ActionString OPTIONAL
)
{
if (mLibProfileProtocol == NULL) {
return EFI_UNSUPPORTED;
}
+
return mLibProfileProtocol->Record (
mLibProfileProtocol,
CallerAddress,
@@ -93,4 +92,3 @@ MemoryProfileLibRecord ( ActionString
);
}
-
diff --git a/MdeModulePkg/Library/UefiMemoryAllocationProfileLib/MemoryAllocationLib.c b/MdeModulePkg/Library/UefiMemoryAllocationProfileLib/MemoryAllocationLib.c index ca63df00a2..38c95b9eb7 100644 --- a/MdeModulePkg/Library/UefiMemoryAllocationProfileLib/MemoryAllocationLib.c +++ b/MdeModulePkg/Library/UefiMemoryAllocationProfileLib/MemoryAllocationLib.c @@ -7,10 +7,8 @@ **/
-
#include <Uefi.h>
-
#include <Library/MemoryAllocationLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/BaseMemoryLib.h>
@@ -48,7 +46,8 @@ InternalAllocatePages ( if (EFI_ERROR (Status)) {
return NULL;
}
- return (VOID *) (UINTN) Memory;
+
+ return (VOID *)(UINTN)Memory;
}
/**
@@ -75,7 +74,7 @@ AllocatePages ( Buffer = InternalAllocatePages (EfiBootServicesData, Pages);
if (Buffer != NULL) {
MemoryProfileLibRecord (
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
MEMORY_PROFILE_ACTION_LIB_ALLOCATE_PAGES,
EfiBootServicesData,
Buffer,
@@ -83,6 +82,7 @@ AllocatePages ( NULL
);
}
+
return Buffer;
}
@@ -110,7 +110,7 @@ AllocateRuntimePages ( Buffer = InternalAllocatePages (EfiRuntimeServicesData, Pages);
if (Buffer != NULL) {
MemoryProfileLibRecord (
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RUNTIME_PAGES,
EfiRuntimeServicesData,
Buffer,
@@ -118,6 +118,7 @@ AllocateRuntimePages ( NULL
);
}
+
return Buffer;
}
@@ -145,7 +146,7 @@ AllocateReservedPages ( Buffer = InternalAllocatePages (EfiReservedMemoryType, Pages);
if (Buffer != NULL) {
MemoryProfileLibRecord (
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RESERVED_PAGES,
EfiReservedMemoryType,
Buffer,
@@ -153,6 +154,7 @@ AllocateReservedPages ( NULL
);
}
+
return Buffer;
}
@@ -180,10 +182,10 @@ FreePages ( IN UINTN Pages
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
ASSERT (Pages != 0);
- Status = gBS->FreePages ((EFI_PHYSICAL_ADDRESS) (UINTN) Buffer, Pages);
+ Status = gBS->FreePages ((EFI_PHYSICAL_ADDRESS)(UINTN)Buffer, Pages);
ASSERT_EFI_ERROR (Status);
}
@@ -227,23 +229,25 @@ InternalAllocateAlignedPages ( if (Pages == 0) {
return NULL;
}
+
if (Alignment > EFI_PAGE_SIZE) {
//
// Calculate the total number of pages since alignment is larger than page size.
//
- AlignmentMask = Alignment - 1;
- RealPages = Pages + EFI_SIZE_TO_PAGES (Alignment);
+ AlignmentMask = Alignment - 1;
+ RealPages = Pages + EFI_SIZE_TO_PAGES (Alignment);
//
// Make sure that Pages plus EFI_SIZE_TO_PAGES (Alignment) does not overflow.
//
ASSERT (RealPages > Pages);
- Status = gBS->AllocatePages (AllocateAnyPages, MemoryType, RealPages, &Memory);
+ Status = gBS->AllocatePages (AllocateAnyPages, MemoryType, RealPages, &Memory);
if (EFI_ERROR (Status)) {
return NULL;
}
- AlignedMemory = ((UINTN) Memory + AlignmentMask) & ~AlignmentMask;
- UnalignedPages = EFI_SIZE_TO_PAGES (AlignedMemory - (UINTN) Memory);
+
+ AlignedMemory = ((UINTN)Memory + AlignmentMask) & ~AlignmentMask;
+ UnalignedPages = EFI_SIZE_TO_PAGES (AlignedMemory - (UINTN)Memory);
if (UnalignedPages > 0) {
//
// Free first unaligned page(s).
@@ -251,6 +255,7 @@ InternalAllocateAlignedPages ( Status = gBS->FreePages (Memory, UnalignedPages);
ASSERT_EFI_ERROR (Status);
}
+
Memory = AlignedMemory + EFI_PAGES_TO_SIZE (Pages);
UnalignedPages = RealPages - Pages - UnalignedPages;
if (UnalignedPages > 0) {
@@ -268,9 +273,11 @@ InternalAllocateAlignedPages ( if (EFI_ERROR (Status)) {
return NULL;
}
- AlignedMemory = (UINTN) Memory;
+
+ AlignedMemory = (UINTN)Memory;
}
- return (VOID *) AlignedMemory;
+
+ return (VOID *)AlignedMemory;
}
/**
@@ -303,7 +310,7 @@ AllocateAlignedPages ( Buffer = InternalAllocateAlignedPages (EfiBootServicesData, Pages, Alignment);
if (Buffer != NULL) {
MemoryProfileLibRecord (
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
MEMORY_PROFILE_ACTION_LIB_ALLOCATE_ALIGNED_PAGES,
EfiBootServicesData,
Buffer,
@@ -311,6 +318,7 @@ AllocateAlignedPages ( NULL
);
}
+
return Buffer;
}
@@ -344,7 +352,7 @@ AllocateAlignedRuntimePages ( Buffer = InternalAllocateAlignedPages (EfiRuntimeServicesData, Pages, Alignment);
if (Buffer != NULL) {
MemoryProfileLibRecord (
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
MEMORY_PROFILE_ACTION_LIB_ALLOCATE_ALIGNED_RUNTIME_PAGES,
EfiRuntimeServicesData,
Buffer,
@@ -352,6 +360,7 @@ AllocateAlignedRuntimePages ( NULL
);
}
+
return Buffer;
}
@@ -385,7 +394,7 @@ AllocateAlignedReservedPages ( Buffer = InternalAllocateAlignedPages (EfiReservedMemoryType, Pages, Alignment);
if (Buffer != NULL) {
MemoryProfileLibRecord (
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
MEMORY_PROFILE_ACTION_LIB_ALLOCATE_ALIGNED_RESERVED_PAGES,
EfiReservedMemoryType,
Buffer,
@@ -393,6 +402,7 @@ AllocateAlignedReservedPages ( NULL
);
}
+
return Buffer;
}
@@ -423,7 +433,7 @@ FreeAlignedPages ( EFI_STATUS Status;
ASSERT (Pages != 0);
- Status = gBS->FreePages ((EFI_PHYSICAL_ADDRESS) (UINTN) Buffer, Pages);
+ Status = gBS->FreePages ((EFI_PHYSICAL_ADDRESS)(UINTN)Buffer, Pages);
ASSERT_EFI_ERROR (Status);
}
@@ -453,6 +463,7 @@ InternalAllocatePool ( if (EFI_ERROR (Status)) {
Memory = NULL;
}
+
return Memory;
}
@@ -479,7 +490,7 @@ AllocatePool ( Buffer = InternalAllocatePool (EfiBootServicesData, AllocationSize);
if (Buffer != NULL) {
MemoryProfileLibRecord (
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
MEMORY_PROFILE_ACTION_LIB_ALLOCATE_POOL,
EfiBootServicesData,
Buffer,
@@ -487,6 +498,7 @@ AllocatePool ( NULL
);
}
+
return Buffer;
}
@@ -513,7 +525,7 @@ AllocateRuntimePool ( Buffer = InternalAllocatePool (EfiRuntimeServicesData, AllocationSize);
if (Buffer != NULL) {
MemoryProfileLibRecord (
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RUNTIME_POOL,
EfiRuntimeServicesData,
Buffer,
@@ -521,6 +533,7 @@ AllocateRuntimePool ( NULL
);
}
+
return Buffer;
}
@@ -547,7 +560,7 @@ AllocateReservedPool ( Buffer = InternalAllocatePool (EfiReservedMemoryType, AllocationSize);
if (Buffer != NULL) {
MemoryProfileLibRecord (
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RESERVED_POOL,
EfiReservedMemoryType,
Buffer,
@@ -555,6 +568,7 @@ AllocateReservedPool ( NULL
);
}
+
return Buffer;
}
@@ -584,6 +598,7 @@ InternalAllocateZeroPool ( if (Memory != NULL) {
Memory = ZeroMem (Memory, AllocationSize);
}
+
return Memory;
}
@@ -611,7 +626,7 @@ AllocateZeroPool ( Buffer = InternalAllocateZeroPool (EfiBootServicesData, AllocationSize);
if (Buffer != NULL) {
MemoryProfileLibRecord (
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
MEMORY_PROFILE_ACTION_LIB_ALLOCATE_ZERO_POOL,
EfiBootServicesData,
Buffer,
@@ -619,6 +634,7 @@ AllocateZeroPool ( NULL
);
}
+
return Buffer;
}
@@ -646,7 +662,7 @@ AllocateRuntimeZeroPool ( Buffer = InternalAllocateZeroPool (EfiRuntimeServicesData, AllocationSize);
if (Buffer != NULL) {
MemoryProfileLibRecord (
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RUNTIME_ZERO_POOL,
EfiRuntimeServicesData,
Buffer,
@@ -654,6 +670,7 @@ AllocateRuntimeZeroPool ( NULL
);
}
+
return Buffer;
}
@@ -681,7 +698,7 @@ AllocateReservedZeroPool ( Buffer = InternalAllocateZeroPool (EfiReservedMemoryType, AllocationSize);
if (Buffer != NULL) {
MemoryProfileLibRecord (
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RESERVED_ZERO_POOL,
EfiReservedMemoryType,
Buffer,
@@ -689,6 +706,7 @@ AllocateReservedZeroPool ( NULL
);
}
+
return Buffer;
}
@@ -719,12 +737,13 @@ InternalAllocateCopyPool ( VOID *Memory;
ASSERT (Buffer != NULL);
- ASSERT (AllocationSize <= (MAX_ADDRESS - (UINTN) Buffer + 1));
+ ASSERT (AllocationSize <= (MAX_ADDRESS - (UINTN)Buffer + 1));
Memory = InternalAllocatePool (PoolType, AllocationSize);
if (Memory != NULL) {
- Memory = CopyMem (Memory, Buffer, AllocationSize);
+ Memory = CopyMem (Memory, Buffer, AllocationSize);
}
+
return Memory;
}
@@ -757,7 +776,7 @@ AllocateCopyPool ( NewBuffer = InternalAllocateCopyPool (EfiBootServicesData, AllocationSize, Buffer);
if (NewBuffer != NULL) {
MemoryProfileLibRecord (
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
MEMORY_PROFILE_ACTION_LIB_ALLOCATE_COPY_POOL,
EfiBootServicesData,
NewBuffer,
@@ -765,6 +784,7 @@ AllocateCopyPool ( NULL
);
}
+
return NewBuffer;
}
@@ -797,7 +817,7 @@ AllocateRuntimeCopyPool ( NewBuffer = InternalAllocateCopyPool (EfiRuntimeServicesData, AllocationSize, Buffer);
if (NewBuffer != NULL) {
MemoryProfileLibRecord (
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RUNTIME_COPY_POOL,
EfiRuntimeServicesData,
NewBuffer,
@@ -805,6 +825,7 @@ AllocateRuntimeCopyPool ( NULL
);
}
+
return NewBuffer;
}
@@ -837,7 +858,7 @@ AllocateReservedCopyPool ( NewBuffer = InternalAllocateCopyPool (EfiReservedMemoryType, AllocationSize, Buffer);
if (NewBuffer != NULL) {
MemoryProfileLibRecord (
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
MEMORY_PROFILE_ACTION_LIB_ALLOCATE_RESERVED_COPY_POOL,
EfiRuntimeServicesData,
NewBuffer,
@@ -845,6 +866,7 @@ AllocateReservedCopyPool ( NULL
);
}
+
return NewBuffer;
}
@@ -881,10 +903,11 @@ InternalReallocatePool ( VOID *NewBuffer;
NewBuffer = InternalAllocateZeroPool (PoolType, NewSize);
- if (NewBuffer != NULL && OldBuffer != NULL) {
+ if ((NewBuffer != NULL) && (OldBuffer != NULL)) {
CopyMem (NewBuffer, OldBuffer, MIN (OldSize, NewSize));
FreePool (OldBuffer);
}
+
return NewBuffer;
}
@@ -922,7 +945,7 @@ ReallocatePool ( Buffer = InternalReallocatePool (EfiBootServicesData, OldSize, NewSize, OldBuffer);
if (Buffer != NULL) {
MemoryProfileLibRecord (
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
MEMORY_PROFILE_ACTION_LIB_REALLOCATE_POOL,
EfiBootServicesData,
Buffer,
@@ -930,6 +953,7 @@ ReallocatePool ( NULL
);
}
+
return Buffer;
}
@@ -967,7 +991,7 @@ ReallocateRuntimePool ( Buffer = InternalReallocatePool (EfiRuntimeServicesData, OldSize, NewSize, OldBuffer);
if (Buffer != NULL) {
MemoryProfileLibRecord (
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
MEMORY_PROFILE_ACTION_LIB_REALLOCATE_RUNTIME_POOL,
EfiRuntimeServicesData,
Buffer,
@@ -975,6 +999,7 @@ ReallocateRuntimePool ( NULL
);
}
+
return Buffer;
}
@@ -1012,7 +1037,7 @@ ReallocateReservedPool ( Buffer = InternalReallocatePool (EfiReservedMemoryType, OldSize, NewSize, OldBuffer);
if (Buffer != NULL) {
MemoryProfileLibRecord (
- (PHYSICAL_ADDRESS) (UINTN) RETURN_ADDRESS(0),
+ (PHYSICAL_ADDRESS)(UINTN)RETURN_ADDRESS (0),
MEMORY_PROFILE_ACTION_LIB_REALLOCATE_RESERVED_POOL,
EfiReservedMemoryType,
Buffer,
@@ -1020,6 +1045,7 @@ ReallocateReservedPool ( NULL
);
}
+
return Buffer;
}
@@ -1040,12 +1066,11 @@ ReallocateReservedPool ( VOID
EFIAPI
FreePool (
- IN VOID *Buffer
+ IN VOID *Buffer
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
Status = gBS->FreePool (Buffer);
ASSERT_EFI_ERROR (Status);
}
-
diff --git a/MdeModulePkg/Library/UefiSortLib/UefiSortLib.c b/MdeModulePkg/Library/UefiSortLib/UefiSortLib.c index 29d8735c22..0ba1244930 100644 --- a/MdeModulePkg/Library/UefiSortLib/UefiSortLib.c +++ b/MdeModulePkg/Library/UefiSortLib/UefiSortLib.c @@ -19,7 +19,7 @@ #include <Library/SortLib.h>
#include <Library/DevicePathLib.h>
-STATIC EFI_UNICODE_COLLATION_PROTOCOL *mUnicodeCollation = NULL;
+STATIC EFI_UNICODE_COLLATION_PROTOCOL *mUnicodeCollation = NULL;
#define USL_FREE_NON_NULL(Pointer) \
{ \
@@ -50,19 +50,19 @@ STATIC EFI_UNICODE_COLLATION_PROTOCOL *mUnicodeCollation = NULL; VOID
EFIAPI
PerformQuickSort (
- IN OUT VOID *BufferToSort,
- IN CONST UINTN Count,
- IN CONST UINTN ElementSize,
- IN SORT_COMPARE CompareFunction
+ IN OUT VOID *BufferToSort,
+ IN CONST UINTN Count,
+ IN CONST UINTN ElementSize,
+ IN SORT_COMPARE CompareFunction
)
{
VOID *Buffer;
- ASSERT(BufferToSort != NULL);
- ASSERT(CompareFunction != NULL);
+ ASSERT (BufferToSort != NULL);
+ ASSERT (CompareFunction != NULL);
- Buffer = AllocateZeroPool(ElementSize);
- ASSERT(Buffer != NULL);
+ Buffer = AllocateZeroPool (ElementSize);
+ ASSERT (Buffer != NULL);
QuickSort (
BufferToSort,
@@ -72,7 +72,7 @@ PerformQuickSort ( Buffer
);
- FreePool(Buffer);
+ FreePool (Buffer);
return;
}
@@ -89,8 +89,8 @@ PerformQuickSort ( INTN
EFIAPI
DevicePathCompare (
- IN CONST VOID *Buffer1,
- IN CONST VOID *Buffer2
+ IN CONST VOID *Buffer1,
+ IN CONST VOID *Buffer2
)
{
EFI_DEVICE_PATH_PROTOCOL *DevicePath1;
@@ -100,8 +100,8 @@ DevicePathCompare ( EFI_STATUS Status;
INTN RetVal;
- DevicePath1 = *(EFI_DEVICE_PATH_PROTOCOL**)Buffer1;
- DevicePath2 = *(EFI_DEVICE_PATH_PROTOCOL**)Buffer2;
+ DevicePath1 = *(EFI_DEVICE_PATH_PROTOCOL **)Buffer1;
+ DevicePath2 = *(EFI_DEVICE_PATH_PROTOCOL **)Buffer2;
if (DevicePath1 == NULL) {
if (DevicePath2 == NULL) {
@@ -116,37 +116,41 @@ DevicePathCompare ( }
if (mUnicodeCollation == NULL) {
- Status = gBS->LocateProtocol(
- &gEfiUnicodeCollation2ProtocolGuid,
- NULL,
- (VOID**)&mUnicodeCollation);
+ Status = gBS->LocateProtocol (
+ &gEfiUnicodeCollation2ProtocolGuid,
+ NULL,
+ (VOID **)&mUnicodeCollation
+ );
- ASSERT_EFI_ERROR(Status);
+ ASSERT_EFI_ERROR (Status);
}
- TextPath1 = ConvertDevicePathToText(
- DevicePath1,
- FALSE,
- FALSE);
+ TextPath1 = ConvertDevicePathToText (
+ DevicePath1,
+ FALSE,
+ FALSE
+ );
- TextPath2 = ConvertDevicePathToText(
- DevicePath2,
- FALSE,
- FALSE);
+ TextPath2 = ConvertDevicePathToText (
+ DevicePath2,
+ FALSE,
+ FALSE
+ );
if (TextPath1 == NULL) {
RetVal = -1;
} else if (TextPath2 == NULL) {
RetVal = 1;
} else {
- RetVal = mUnicodeCollation->StriColl(
- mUnicodeCollation,
- TextPath1,
- TextPath2);
+ RetVal = mUnicodeCollation->StriColl (
+ mUnicodeCollation,
+ TextPath1,
+ TextPath2
+ );
}
- USL_FREE_NON_NULL(TextPath1);
- USL_FREE_NON_NULL(TextPath2);
+ USL_FREE_NON_NULL (TextPath1);
+ USL_FREE_NON_NULL (TextPath2);
return (RetVal);
}
@@ -164,27 +168,29 @@ DevicePathCompare ( INTN
EFIAPI
StringNoCaseCompare (
- IN CONST VOID *Buffer1,
- IN CONST VOID *Buffer2
+ IN CONST VOID *Buffer1,
+ IN CONST VOID *Buffer2
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
+
if (mUnicodeCollation == NULL) {
- Status = gBS->LocateProtocol(
- &gEfiUnicodeCollation2ProtocolGuid,
- NULL,
- (VOID**)&mUnicodeCollation);
+ Status = gBS->LocateProtocol (
+ &gEfiUnicodeCollation2ProtocolGuid,
+ NULL,
+ (VOID **)&mUnicodeCollation
+ );
- ASSERT_EFI_ERROR(Status);
+ ASSERT_EFI_ERROR (Status);
}
- return (mUnicodeCollation->StriColl(
- mUnicodeCollation,
- *(CHAR16**)Buffer1,
- *(CHAR16**)Buffer2));
+ return (mUnicodeCollation->StriColl (
+ mUnicodeCollation,
+ *(CHAR16 **)Buffer1,
+ *(CHAR16 **)Buffer2
+ ));
}
-
/**
Function to compare 2 strings.
@@ -198,11 +204,12 @@ StringNoCaseCompare ( INTN
EFIAPI
StringCompare (
- IN CONST VOID *Buffer1,
- IN CONST VOID *Buffer2
+ IN CONST VOID *Buffer1,
+ IN CONST VOID *Buffer2
)
{
- return (StrCmp(
- *(CHAR16**)Buffer1,
- *(CHAR16**)Buffer2));
+ return (StrCmp (
+ *(CHAR16 **)Buffer1,
+ *(CHAR16 **)Buffer2
+ ));
}
diff --git a/MdeModulePkg/Library/UefiSortLib/UnitTest/UefiSortLibUnitTest.c b/MdeModulePkg/Library/UefiSortLib/UnitTest/UefiSortLibUnitTest.c index 4f44a02c5b..3d15167f9a 100644 --- a/MdeModulePkg/Library/UefiSortLib/UnitTest/UefiSortLibUnitTest.c +++ b/MdeModulePkg/Library/UefiSortLib/UnitTest/UefiSortLibUnitTest.c @@ -21,10 +21,10 @@ #include <Library/UnitTestLib.h>
#include <Library/SortLib.h>
-#define UNIT_TEST_APP_NAME "UefiSortLib Unit Tests"
-#define UNIT_TEST_APP_VERSION "1.0"
+#define UNIT_TEST_APP_NAME "UefiSortLib Unit Tests"
+#define UNIT_TEST_APP_VERSION "1.0"
-#define TEST_ARRAY_SIZE_9 9
+#define TEST_ARRAY_SIZE_9 9
/**
The function is called by PerformQuickSort to compare int values.
@@ -40,13 +40,13 @@ INTN
EFIAPI
TestCompareFunction (
- IN CONST VOID *Left,
- IN CONST VOID *Right
+ IN CONST VOID *Left,
+ IN CONST VOID *Right
)
{
- if (*(UINT32*)Right > *(UINT32*)Left) {
+ if (*(UINT32 *)Right > *(UINT32 *)Left) {
return 1;
- } else if (*(UINT32*)Right < *(UINT32*)Left) {
+ } else if (*(UINT32 *)Right < *(UINT32 *)Left) {
return -1;
}
@@ -74,10 +74,10 @@ SortUINT32ArrayShouldSucceed ( IN UNIT_TEST_CONTEXT Context
)
{
- UINTN TestCount;
- UINT32 Index;
- UINT32 TestBuffer[TEST_ARRAY_SIZE_9];
- UINT32 TestResult[TEST_ARRAY_SIZE_9];
+ UINTN TestCount;
+ UINT32 Index;
+ UINT32 TestBuffer[TEST_ARRAY_SIZE_9];
+ UINT32 TestResult[TEST_ARRAY_SIZE_9];
TestCount = TEST_ARRAY_SIZE_9;
for (Index = 0; Index < TEST_ARRAY_SIZE_9; Index++) {
@@ -112,8 +112,8 @@ CompareSameBufferShouldSucceed ( IN UNIT_TEST_CONTEXT Context
)
{
- INTN retval;
- CONST CHAR16* TestBuffer[] = { L"abcdefg" };
+ INTN retval;
+ CONST CHAR16 *TestBuffer[] = { L"abcdefg" };
retval = StringCompare (TestBuffer, TestBuffer);
UT_ASSERT_TRUE (retval == 0);
@@ -142,7 +142,7 @@ UnitTestingEntry ( Framework = NULL;
- DEBUG(( DEBUG_INFO, "%a v%a\n", UNIT_TEST_APP_NAME, UNIT_TEST_APP_VERSION ));
+ DEBUG ((DEBUG_INFO, "%a v%a\n", UNIT_TEST_APP_NAME, UNIT_TEST_APP_VERSION));
//
// Start setting up the test framework for running the tests.
@@ -166,8 +166,8 @@ UnitTestingEntry ( //
// --------------Suite--------Description------------Name--------------Function----------------Pre---Post---Context-----------
//
- AddTestCase (SortTests, "Sort the Array", "Sort", SortUINT32ArrayShouldSucceed, NULL, NULL, NULL);
- AddTestCase (SortTests, "Compare the Buffer", "Compare", CompareSameBufferShouldSucceed, NULL, NULL, NULL);
+ AddTestCase (SortTests, "Sort the Array", "Sort", SortUINT32ArrayShouldSucceed, NULL, NULL, NULL);
+ AddTestCase (SortTests, "Compare the Buffer", "Compare", CompareSameBufferShouldSucceed, NULL, NULL, NULL);
//
// Execute the tests.
@@ -185,7 +185,7 @@ EXIT: ///
/// Avoid ECC error for function name that starts with lower case letter
///
-#define UefiSortLibUnitTestMain main
+#define UefiSortLibUnitTestMain main
/**
Standard POSIX C entry point for host based unit test execution.
diff --git a/MdeModulePkg/Library/VarCheckHiiLib/InternalVarCheckStructure.h b/MdeModulePkg/Library/VarCheckHiiLib/InternalVarCheckStructure.h index a78d099052..c7da537eb4 100644 --- a/MdeModulePkg/Library/VarCheckHiiLib/InternalVarCheckStructure.h +++ b/MdeModulePkg/Library/VarCheckHiiLib/InternalVarCheckStructure.h @@ -20,60 +20,60 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #define VAR_CHECK_HII_REVISION 0x0002
typedef struct {
- UINT16 Revision;
- UINT16 HeaderLength;
- UINT32 Length; // Length include this header
- UINT8 OpCode;
- UINT8 Reserved;
- UINT16 Size;
- UINT32 Attributes;
- EFI_GUID Guid;
-//CHAR16 Name[];
+ UINT16 Revision;
+ UINT16 HeaderLength;
+ UINT32 Length; // Length include this header
+ UINT8 OpCode;
+ UINT8 Reserved;
+ UINT16 Size;
+ UINT32 Attributes;
+ EFI_GUID Guid;
+ // CHAR16 Name[];
} VAR_CHECK_HII_VARIABLE_HEADER;
typedef struct {
- UINT8 OpCode;
- UINT8 Length; // Length include this header
- UINT16 VarOffset;
- UINT8 StorageWidth;
- BOOLEAN BitFieldStore; // Whether the Question is stored in bit field, if TRUE, the VarOffset/StorageWidth will be saved as bit level, otherwise in byte level.
+ UINT8 OpCode;
+ UINT8 Length; // Length include this header
+ UINT16 VarOffset;
+ UINT8 StorageWidth;
+ BOOLEAN BitFieldStore; // Whether the Question is stored in bit field, if TRUE, the VarOffset/StorageWidth will be saved as bit level, otherwise in byte level.
} VAR_CHECK_HII_QUESTION_HEADER;
typedef struct {
- UINT8 OpCode;
- UINT8 Length; // Length include this header
- UINT16 VarOffset;
- UINT8 StorageWidth;
- BOOLEAN BitFieldStore; // Whether the Question is stored in bit field, if TRUE, the VarOffset/StorageWidth will be saved as bit level, otherwise in byte level.
-//UINTx Data[]; // x = UINT8/UINT16/UINT32/UINT64;
+ UINT8 OpCode;
+ UINT8 Length; // Length include this header
+ UINT16 VarOffset;
+ UINT8 StorageWidth;
+ BOOLEAN BitFieldStore; // Whether the Question is stored in bit field, if TRUE, the VarOffset/StorageWidth will be saved as bit level, otherwise in byte level.
+ // UINTx Data[]; // x = UINT8/UINT16/UINT32/UINT64;
} VAR_CHECK_HII_QUESTION_ONEOF;
typedef struct {
- UINT8 OpCode;
- UINT8 Length; // Length include this header
- UINT16 VarOffset;
- UINT8 StorageWidth;
- BOOLEAN BitFieldStore; // Whether the Question is stored in bit field, if TRUE, the VarOffset/StorageWidth will be saved as bit level, otherwise in byte level.
+ UINT8 OpCode;
+ UINT8 Length; // Length include this header
+ UINT16 VarOffset;
+ UINT8 StorageWidth;
+ BOOLEAN BitFieldStore; // Whether the Question is stored in bit field, if TRUE, the VarOffset/StorageWidth will be saved as bit level, otherwise in byte level.
} VAR_CHECK_HII_QUESTION_CHECKBOX;
typedef struct {
- UINT8 OpCode;
- UINT8 Length; // Length include this header
- UINT16 VarOffset;
- UINT8 StorageWidth;
- BOOLEAN BitFieldStore; // Whether the Question is stored in bit field, if TRUE, the VarOffset/StorageWidth will be saved as bit level, otherwise in byte level.
-//UINTx Minimum; // x = UINT8/UINT16/UINT32/UINT64;
-//UINTx Maximum; // x = UINT8/UINT16/UINT32/UINT64;
+ UINT8 OpCode;
+ UINT8 Length; // Length include this header
+ UINT16 VarOffset;
+ UINT8 StorageWidth;
+ BOOLEAN BitFieldStore; // Whether the Question is stored in bit field, if TRUE, the VarOffset/StorageWidth will be saved as bit level, otherwise in byte level.
+ // UINTx Minimum; // x = UINT8/UINT16/UINT32/UINT64;
+ // UINTx Maximum; // x = UINT8/UINT16/UINT32/UINT64;
} VAR_CHECK_HII_QUESTION_NUMERIC;
typedef struct {
- UINT8 OpCode;
- UINT8 Length; // Length include this header
- UINT16 VarOffset;
- UINT8 StorageWidth;
- BOOLEAN BitFieldStore; // Whether the Question is stored in bit field, if TRUE, the VarOffset/StorageWidth will be saved as bit level, otherwise in byte level.
- UINT8 MaxContainers;
-//UINTx Data[]; // x = UINT8/UINT16/UINT32/UINT64;
+ UINT8 OpCode;
+ UINT8 Length; // Length include this header
+ UINT16 VarOffset;
+ UINT8 StorageWidth;
+ BOOLEAN BitFieldStore; // Whether the Question is stored in bit field, if TRUE, the VarOffset/StorageWidth will be saved as bit level, otherwise in byte level.
+ UINT8 MaxContainers;
+ // UINTx Data[]; // x = UINT8/UINT16/UINT32/UINT64;
} VAR_CHECK_HII_QUESTION_ORDEREDLIST;
#pragma pack ()
diff --git a/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHii.h b/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHii.h index fe0863922f..89de54ddf4 100644 --- a/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHii.h +++ b/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHii.h @@ -25,17 +25,17 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include "InternalVarCheckStructure.h"
#include "VarCheckHiiGen.h"
-//#define DUMP_VAR_CHECK_HII
-//#define DUMP_HII_DATA
+// #define DUMP_VAR_CHECK_HII
+// #define DUMP_HII_DATA
typedef struct {
- UINT8 HiiOpCode;
- CHAR8 *HiiOpCodeStr;
+ UINT8 HiiOpCode;
+ CHAR8 *HiiOpCodeStr;
} VAR_CHECK_HII_OPCODE_STRING;
typedef struct {
- UINT8 PackageType;
- CHAR8 *PackageTypeStr;
+ UINT8 PackageType;
+ CHAR8 *PackageTypeStr;
} VAR_CHECK_HII_PACKAGE_TYPE_STRING;
/**
@@ -51,7 +51,7 @@ DumpVarCheckHii ( IN UINTN VarCheckHiiBinSize
);
-extern VAR_CHECK_HII_VARIABLE_HEADER *mVarCheckHiiBin;
-extern UINTN mVarCheckHiiBinSize;
+extern VAR_CHECK_HII_VARIABLE_HEADER *mVarCheckHiiBin;
+extern UINTN mVarCheckHiiBinSize;
#endif
diff --git a/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGen.c b/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGen.c index 3d787b8f7a..ca8227df6b 100644 --- a/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGen.c +++ b/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGen.c @@ -8,33 +8,33 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include "VarCheckHiiGen.h"
-LIST_ENTRY mVarCheckHiiList = INITIALIZE_LIST_HEAD_VARIABLE (mVarCheckHiiList);
+LIST_ENTRY mVarCheckHiiList = INITIALIZE_LIST_HEAD_VARIABLE (mVarCheckHiiList);
-#define VAR_CHECK_HII_VARIABLE_NODE_SIGNATURE SIGNATURE_32 ('V', 'C', 'H', 'V')
+#define VAR_CHECK_HII_VARIABLE_NODE_SIGNATURE SIGNATURE_32 ('V', 'C', 'H', 'V')
typedef struct {
- UINTN Signature;
- LIST_ENTRY Link;
- VAR_CHECK_HII_VARIABLE_HEADER *HiiVariable;
- EFI_VARSTORE_ID VarStoreId;
+ UINTN Signature;
+ LIST_ENTRY Link;
+ VAR_CHECK_HII_VARIABLE_HEADER *HiiVariable;
+ EFI_VARSTORE_ID VarStoreId;
- VAR_CHECK_HII_QUESTION_HEADER **HiiQuestionArray;
+ VAR_CHECK_HII_QUESTION_HEADER **HiiQuestionArray;
} VAR_CHECK_HII_VARIABLE_NODE;
-#define VAR_CHECK_HII_VARIABLE_FROM_LINK(a) CR (a, VAR_CHECK_HII_VARIABLE_NODE, Link, VAR_CHECK_HII_VARIABLE_NODE_SIGNATURE)
+#define VAR_CHECK_HII_VARIABLE_FROM_LINK(a) CR (a, VAR_CHECK_HII_VARIABLE_NODE, Link, VAR_CHECK_HII_VARIABLE_NODE_SIGNATURE)
-CHAR16 *mVarName = NULL;
-UINTN mMaxVarNameSize = 0;
+CHAR16 *mVarName = NULL;
+UINTN mMaxVarNameSize = 0;
#ifdef DUMP_HII_DATA
-GLOBAL_REMOVE_IF_UNREFERENCED VAR_CHECK_HII_OPCODE_STRING mIfrOpCodeStringTable[] = {
- {EFI_IFR_VARSTORE_OP, "EFI_IFR_VARSTORE_OP"},
- {EFI_IFR_VARSTORE_EFI_OP, "EFI_IFR_VARSTORE_EFI_OP"},
- {EFI_IFR_ONE_OF_OP, "EFI_IFR_ONE_OF_OP"},
- {EFI_IFR_CHECKBOX_OP, "EFI_IFR_CHECKBOX_OP"},
- {EFI_IFR_NUMERIC_OP, "EFI_IFR_NUMERIC_OP"},
- {EFI_IFR_ORDERED_LIST_OP, "EFI_IFR_ORDERED_LIST_OP"},
- {EFI_IFR_ONE_OF_OPTION_OP, "EFI_IFR_ONE_OF_OPTION_OP"},
+GLOBAL_REMOVE_IF_UNREFERENCED VAR_CHECK_HII_OPCODE_STRING mIfrOpCodeStringTable[] = {
+ { EFI_IFR_VARSTORE_OP, "EFI_IFR_VARSTORE_OP" },
+ { EFI_IFR_VARSTORE_EFI_OP, "EFI_IFR_VARSTORE_EFI_OP" },
+ { EFI_IFR_ONE_OF_OP, "EFI_IFR_ONE_OF_OP" },
+ { EFI_IFR_CHECKBOX_OP, "EFI_IFR_CHECKBOX_OP" },
+ { EFI_IFR_NUMERIC_OP, "EFI_IFR_NUMERIC_OP" },
+ { EFI_IFR_ORDERED_LIST_OP, "EFI_IFR_ORDERED_LIST_OP" },
+ { EFI_IFR_ONE_OF_OPTION_OP, "EFI_IFR_ONE_OF_OPTION_OP" },
};
/**
@@ -51,6 +51,7 @@ IfrOpCodeToStr ( )
{
UINTN Index;
+
for (Index = 0; Index < ARRAY_SIZE (mIfrOpCodeStringTable); Index++) {
if (mIfrOpCodeStringTable[Index].HiiOpCode == IfrOpCode) {
return mIfrOpCodeStringTable[Index].HiiOpCodeStr;
@@ -61,19 +62,19 @@ IfrOpCodeToStr ( }
GLOBAL_REMOVE_IF_UNREFERENCED VAR_CHECK_HII_PACKAGE_TYPE_STRING mPackageTypeStringTable[] = {
- {EFI_HII_PACKAGE_TYPE_ALL, "EFI_HII_PACKAGE_TYPE_ALL"},
- {EFI_HII_PACKAGE_TYPE_GUID, "EFI_HII_PACKAGE_TYPE_GUID"},
- {EFI_HII_PACKAGE_FORMS, "EFI_HII_PACKAGE_FORMS"},
- {EFI_HII_PACKAGE_STRINGS, "EFI_HII_PACKAGE_STRINGS"},
- {EFI_HII_PACKAGE_FONTS, "EFI_HII_PACKAGE_FONTS"},
- {EFI_HII_PACKAGE_IMAGES, "EFI_HII_PACKAGE_IMAGES"},
- {EFI_HII_PACKAGE_SIMPLE_FONTS, "EFI_HII_PACKAGE_SIMPLE_FONTS"},
- {EFI_HII_PACKAGE_DEVICE_PATH, "EFI_HII_PACKAGE_DEVICE_PATH"},
- {EFI_HII_PACKAGE_KEYBOARD_LAYOUT, "EFI_HII_PACKAGE_KEYBOARD_LAYOUT"},
- {EFI_HII_PACKAGE_ANIMATIONS, "EFI_HII_PACKAGE_ANIMATIONS"},
- {EFI_HII_PACKAGE_END, "EFI_HII_PACKAGE_END"},
- {EFI_HII_PACKAGE_TYPE_SYSTEM_BEGIN, "EFI_HII_PACKAGE_TYPE_SYSTEM_BEGIN"},
- {EFI_HII_PACKAGE_TYPE_SYSTEM_END, "EFI_HII_PACKAGE_TYPE_SYSTEM_END"},
+ { EFI_HII_PACKAGE_TYPE_ALL, "EFI_HII_PACKAGE_TYPE_ALL" },
+ { EFI_HII_PACKAGE_TYPE_GUID, "EFI_HII_PACKAGE_TYPE_GUID" },
+ { EFI_HII_PACKAGE_FORMS, "EFI_HII_PACKAGE_FORMS" },
+ { EFI_HII_PACKAGE_STRINGS, "EFI_HII_PACKAGE_STRINGS" },
+ { EFI_HII_PACKAGE_FONTS, "EFI_HII_PACKAGE_FONTS" },
+ { EFI_HII_PACKAGE_IMAGES, "EFI_HII_PACKAGE_IMAGES" },
+ { EFI_HII_PACKAGE_SIMPLE_FONTS, "EFI_HII_PACKAGE_SIMPLE_FONTS" },
+ { EFI_HII_PACKAGE_DEVICE_PATH, "EFI_HII_PACKAGE_DEVICE_PATH" },
+ { EFI_HII_PACKAGE_KEYBOARD_LAYOUT, "EFI_HII_PACKAGE_KEYBOARD_LAYOUT" },
+ { EFI_HII_PACKAGE_ANIMATIONS, "EFI_HII_PACKAGE_ANIMATIONS" },
+ { EFI_HII_PACKAGE_END, "EFI_HII_PACKAGE_END" },
+ { EFI_HII_PACKAGE_TYPE_SYSTEM_BEGIN, "EFI_HII_PACKAGE_TYPE_SYSTEM_BEGIN" },
+ { EFI_HII_PACKAGE_TYPE_SYSTEM_END, "EFI_HII_PACKAGE_TYPE_SYSTEM_END" },
};
/**
@@ -89,7 +90,8 @@ HiiPackageTypeToStr ( IN UINT8 PackageType
)
{
- UINTN Index;
+ UINTN Index;
+
for (Index = 0; Index < ARRAY_SIZE (mPackageTypeStringTable); Index++) {
if (mPackageTypeStringTable[Index].PackageType == PackageType) {
return mPackageTypeStringTable[Index].PackageTypeStr;
@@ -107,29 +109,29 @@ HiiPackageTypeToStr ( **/
VOID
DumpHiiPackage (
- IN VOID *HiiPackage
+ IN VOID *HiiPackage
)
{
- EFI_HII_PACKAGE_HEADER *HiiPackageHeader;
- EFI_IFR_OP_HEADER *IfrOpCodeHeader;
- EFI_IFR_VARSTORE *IfrVarStore;
- EFI_IFR_VARSTORE_EFI *IfrEfiVarStore;
- BOOLEAN QuestionStoredInBitField;
+ EFI_HII_PACKAGE_HEADER *HiiPackageHeader;
+ EFI_IFR_OP_HEADER *IfrOpCodeHeader;
+ EFI_IFR_VARSTORE *IfrVarStore;
+ EFI_IFR_VARSTORE_EFI *IfrEfiVarStore;
+ BOOLEAN QuestionStoredInBitField;
- HiiPackageHeader = (EFI_HII_PACKAGE_HEADER *) HiiPackage;
+ HiiPackageHeader = (EFI_HII_PACKAGE_HEADER *)HiiPackage;
QuestionStoredInBitField = FALSE;
- DEBUG ((DEBUG_INFO, " HiiPackageHeader->Type - 0x%02x (%a)\n", HiiPackageHeader->Type, HiiPackageTypeToStr ((UINT8) HiiPackageHeader->Type)));
+ DEBUG ((DEBUG_INFO, " HiiPackageHeader->Type - 0x%02x (%a)\n", HiiPackageHeader->Type, HiiPackageTypeToStr ((UINT8)HiiPackageHeader->Type)));
DEBUG ((DEBUG_INFO, " HiiPackageHeader->Length - 0x%06x\n", HiiPackageHeader->Length));
switch (HiiPackageHeader->Type) {
case EFI_HII_PACKAGE_FORMS:
- IfrOpCodeHeader = (EFI_IFR_OP_HEADER *) (HiiPackageHeader + 1);
+ IfrOpCodeHeader = (EFI_IFR_OP_HEADER *)(HiiPackageHeader + 1);
- while ((UINTN) IfrOpCodeHeader < ((UINTN) HiiPackageHeader + HiiPackageHeader->Length)) {
+ while ((UINTN)IfrOpCodeHeader < ((UINTN)HiiPackageHeader + HiiPackageHeader->Length)) {
switch (IfrOpCodeHeader->OpCode) {
case EFI_IFR_VARSTORE_OP:
- IfrVarStore = (EFI_IFR_VARSTORE *) IfrOpCodeHeader;
+ IfrVarStore = (EFI_IFR_VARSTORE *)IfrOpCodeHeader;
DEBUG ((DEBUG_INFO, " IfrOpCodeHeader->OpCode - 0x%02x (%a)\n", IfrOpCodeHeader->OpCode, IfrOpCodeToStr (IfrOpCodeHeader->OpCode)));
DEBUG ((DEBUG_INFO, " IfrOpCodeHeader->Length - 0x%02x\n", IfrOpCodeHeader->Length));
DEBUG ((DEBUG_INFO, " IfrOpCodeHeader->Scope - 0x%02x\n", IfrOpCodeHeader->Scope));
@@ -140,7 +142,7 @@ DumpHiiPackage ( break;
case EFI_IFR_VARSTORE_EFI_OP:
- IfrEfiVarStore = (EFI_IFR_VARSTORE_EFI *) IfrOpCodeHeader;
+ IfrEfiVarStore = (EFI_IFR_VARSTORE_EFI *)IfrOpCodeHeader;
if (IfrEfiVarStore->Header.Length >= sizeof (EFI_IFR_VARSTORE_EFI)) {
DEBUG ((DEBUG_INFO, " IfrOpCodeHeader->OpCode - 0x%02x (%a)\n", IfrOpCodeHeader->OpCode, IfrOpCodeToStr (IfrOpCodeHeader->OpCode)));
DEBUG ((DEBUG_INFO, " IfrOpCodeHeader->Length - 0x%02x\n", IfrOpCodeHeader->Length));
@@ -151,35 +153,37 @@ DumpHiiPackage ( DEBUG ((DEBUG_INFO, " Attributes - 0x%08x\n", IfrEfiVarStore->Attributes));
DEBUG ((DEBUG_INFO, " Name - %a\n", IfrEfiVarStore->Name));
}
+
break;
case EFI_IFR_GUID_OP:
if (CompareGuid ((EFI_GUID *)((UINTN)IfrOpCodeHeader + sizeof (EFI_IFR_OP_HEADER)), &gEdkiiIfrBitVarstoreGuid)) {
QuestionStoredInBitField = TRUE;
}
+
break;
case EFI_IFR_ONE_OF_OP:
case EFI_IFR_CHECKBOX_OP:
case EFI_IFR_NUMERIC_OP:
case EFI_IFR_ORDERED_LIST_OP:
- DEBUG ((DEBUG_INFO, " IfrOpCodeHeader->OpCode - 0x%02x (%a) (%a)\n", IfrOpCodeHeader->OpCode, IfrOpCodeToStr (IfrOpCodeHeader->OpCode), (QuestionStoredInBitField? "bit level": "byte level")));
+ DEBUG ((DEBUG_INFO, " IfrOpCodeHeader->OpCode - 0x%02x (%a) (%a)\n", IfrOpCodeHeader->OpCode, IfrOpCodeToStr (IfrOpCodeHeader->OpCode), (QuestionStoredInBitField ? "bit level" : "byte level")));
DEBUG ((DEBUG_INFO, " IfrOpCodeHeader->Length - 0x%02x\n", IfrOpCodeHeader->Length));
DEBUG ((DEBUG_INFO, " IfrOpCodeHeader->Scope - 0x%02x\n", IfrOpCodeHeader->Scope));
- DEBUG ((DEBUG_INFO, " Prompt - 0x%04x\n", ((EFI_IFR_ONE_OF *) IfrOpCodeHeader)->Question.Header.Prompt));
- DEBUG ((DEBUG_INFO, " Help - 0x%04x\n", ((EFI_IFR_ONE_OF *) IfrOpCodeHeader)->Question.Header.Help));
- DEBUG ((DEBUG_INFO, " QuestionId - 0x%04x\n", ((EFI_IFR_ONE_OF *) IfrOpCodeHeader)->Question.QuestionId));
- DEBUG ((DEBUG_INFO, " VarStoreId - 0x%04x\n", ((EFI_IFR_ONE_OF *) IfrOpCodeHeader)->Question.VarStoreId));
- DEBUG ((DEBUG_INFO, " VarStoreInfo - 0x%04x (%a)\n", ((EFI_IFR_ONE_OF * )IfrOpCodeHeader)->Question.VarStoreInfo.VarOffset, (QuestionStoredInBitField? "bit level": "byte level")));
+ DEBUG ((DEBUG_INFO, " Prompt - 0x%04x\n", ((EFI_IFR_ONE_OF *)IfrOpCodeHeader)->Question.Header.Prompt));
+ DEBUG ((DEBUG_INFO, " Help - 0x%04x\n", ((EFI_IFR_ONE_OF *)IfrOpCodeHeader)->Question.Header.Help));
+ DEBUG ((DEBUG_INFO, " QuestionId - 0x%04x\n", ((EFI_IFR_ONE_OF *)IfrOpCodeHeader)->Question.QuestionId));
+ DEBUG ((DEBUG_INFO, " VarStoreId - 0x%04x\n", ((EFI_IFR_ONE_OF *)IfrOpCodeHeader)->Question.VarStoreId));
+ DEBUG ((DEBUG_INFO, " VarStoreInfo - 0x%04x (%a)\n", ((EFI_IFR_ONE_OF *)IfrOpCodeHeader)->Question.VarStoreInfo.VarOffset, (QuestionStoredInBitField ? "bit level" : "byte level")));
{
- EFI_IFR_ONE_OF *IfrOneOf;
- EFI_IFR_CHECKBOX *IfrCheckBox;
- EFI_IFR_NUMERIC *IfrNumeric;
- EFI_IFR_ORDERED_LIST *IfrOrderedList;
+ EFI_IFR_ONE_OF *IfrOneOf;
+ EFI_IFR_CHECKBOX *IfrCheckBox;
+ EFI_IFR_NUMERIC *IfrNumeric;
+ EFI_IFR_ORDERED_LIST *IfrOrderedList;
switch (IfrOpCodeHeader->OpCode) {
case EFI_IFR_ONE_OF_OP:
- IfrOneOf = (EFI_IFR_ONE_OF *) IfrOpCodeHeader;
+ IfrOneOf = (EFI_IFR_ONE_OF *)IfrOpCodeHeader;
DEBUG ((DEBUG_INFO, " Flags - 0x%02x\n", IfrOneOf->Flags));
if (QuestionStoredInBitField) {
//
@@ -190,35 +194,36 @@ DumpHiiPackage ( DEBUG ((DEBUG_INFO, " Step - 0x%08x\n", IfrOneOf->data.u32.Step));
} else {
switch (IfrOneOf->Flags & EFI_IFR_NUMERIC_SIZE) {
- case EFI_IFR_NUMERIC_SIZE_1:
- DEBUG ((DEBUG_INFO, " MinValue - 0x%02x\n", IfrOneOf->data.u8.MinValue));
- DEBUG ((DEBUG_INFO, " MaxValue - 0x%02x\n", IfrOneOf->data.u8.MaxValue));
- DEBUG ((DEBUG_INFO, " Step - 0x%02x\n", IfrOneOf->data.u8.Step));
- break;
- case EFI_IFR_NUMERIC_SIZE_2:
- DEBUG ((DEBUG_INFO, " MinValue - 0x%04x\n", IfrOneOf->data.u16.MinValue));
- DEBUG ((DEBUG_INFO, " MaxValue - 0x%04x\n", IfrOneOf->data.u16.MaxValue));
- DEBUG ((DEBUG_INFO, " Step - 0x%04x\n", IfrOneOf->data.u16.Step));
- break;
- case EFI_IFR_NUMERIC_SIZE_4:
- DEBUG ((DEBUG_INFO, " MinValue - 0x%08x\n", IfrOneOf->data.u32.MinValue));
- DEBUG ((DEBUG_INFO, " MaxValue - 0x%08x\n", IfrOneOf->data.u32.MaxValue));
- DEBUG ((DEBUG_INFO, " Step - 0x%08x\n", IfrOneOf->data.u32.Step));
- break;
- case EFI_IFR_NUMERIC_SIZE_8:
- DEBUG ((DEBUG_INFO, " MinValue - 0x%016lx\n", IfrOneOf->data.u64.MinValue));
- DEBUG ((DEBUG_INFO, " MaxValue - 0x%016lx\n", IfrOneOf->data.u64.MaxValue));
- DEBUG ((DEBUG_INFO, " Step - 0x%016lx\n", IfrOneOf->data.u64.Step));
- break;
+ case EFI_IFR_NUMERIC_SIZE_1:
+ DEBUG ((DEBUG_INFO, " MinValue - 0x%02x\n", IfrOneOf->data.u8.MinValue));
+ DEBUG ((DEBUG_INFO, " MaxValue - 0x%02x\n", IfrOneOf->data.u8.MaxValue));
+ DEBUG ((DEBUG_INFO, " Step - 0x%02x\n", IfrOneOf->data.u8.Step));
+ break;
+ case EFI_IFR_NUMERIC_SIZE_2:
+ DEBUG ((DEBUG_INFO, " MinValue - 0x%04x\n", IfrOneOf->data.u16.MinValue));
+ DEBUG ((DEBUG_INFO, " MaxValue - 0x%04x\n", IfrOneOf->data.u16.MaxValue));
+ DEBUG ((DEBUG_INFO, " Step - 0x%04x\n", IfrOneOf->data.u16.Step));
+ break;
+ case EFI_IFR_NUMERIC_SIZE_4:
+ DEBUG ((DEBUG_INFO, " MinValue - 0x%08x\n", IfrOneOf->data.u32.MinValue));
+ DEBUG ((DEBUG_INFO, " MaxValue - 0x%08x\n", IfrOneOf->data.u32.MaxValue));
+ DEBUG ((DEBUG_INFO, " Step - 0x%08x\n", IfrOneOf->data.u32.Step));
+ break;
+ case EFI_IFR_NUMERIC_SIZE_8:
+ DEBUG ((DEBUG_INFO, " MinValue - 0x%016lx\n", IfrOneOf->data.u64.MinValue));
+ DEBUG ((DEBUG_INFO, " MaxValue - 0x%016lx\n", IfrOneOf->data.u64.MaxValue));
+ DEBUG ((DEBUG_INFO, " Step - 0x%016lx\n", IfrOneOf->data.u64.Step));
+ break;
}
}
+
break;
case EFI_IFR_CHECKBOX_OP:
- IfrCheckBox = (EFI_IFR_CHECKBOX *) IfrOpCodeHeader;
+ IfrCheckBox = (EFI_IFR_CHECKBOX *)IfrOpCodeHeader;
DEBUG ((DEBUG_INFO, " Flags - 0x%02x\n", IfrCheckBox->Flags));
break;
case EFI_IFR_NUMERIC_OP:
- IfrNumeric = (EFI_IFR_NUMERIC *) IfrOpCodeHeader;
+ IfrNumeric = (EFI_IFR_NUMERIC *)IfrOpCodeHeader;
DEBUG ((DEBUG_INFO, " Flags - 0x%02x\n", IfrNumeric->Flags));
if (QuestionStoredInBitField) {
//
@@ -229,31 +234,32 @@ DumpHiiPackage ( DEBUG ((DEBUG_INFO, " Step - 0x%08x\n", IfrNumeric->data.u32.Step));
} else {
switch (IfrNumeric->Flags & EFI_IFR_NUMERIC_SIZE) {
- case EFI_IFR_NUMERIC_SIZE_1:
- DEBUG ((DEBUG_INFO, " MinValue - 0x%02x\n", IfrNumeric->data.u8.MinValue));
- DEBUG ((DEBUG_INFO, " MaxValue - 0x%02x\n", IfrNumeric->data.u8.MaxValue));
- DEBUG ((DEBUG_INFO, " Step - 0x%02x\n", IfrNumeric->data.u8.Step));
- break;
- case EFI_IFR_NUMERIC_SIZE_2:
- DEBUG ((DEBUG_INFO, " MinValue - 0x%04x\n", IfrNumeric->data.u16.MinValue));
- DEBUG ((DEBUG_INFO, " MaxValue - 0x%04x\n", IfrNumeric->data.u16.MaxValue));
- DEBUG ((DEBUG_INFO, " Step - 0x%04x\n", IfrNumeric->data.u16.Step));
- break;
- case EFI_IFR_NUMERIC_SIZE_4:
- DEBUG ((DEBUG_INFO, " MinValue - 0x%08x\n", IfrNumeric->data.u32.MinValue));
- DEBUG ((DEBUG_INFO, " MaxValue - 0x%08x\n", IfrNumeric->data.u32.MaxValue));
- DEBUG ((DEBUG_INFO, " Step - 0x%08x\n", IfrNumeric->data.u32.Step));
- break;
- case EFI_IFR_NUMERIC_SIZE_8:
- DEBUG ((DEBUG_INFO, " MinValue - 0x%016lx\n", IfrNumeric->data.u64.MinValue));
- DEBUG ((DEBUG_INFO, " MaxValue - 0x%016lx\n", IfrNumeric->data.u64.MaxValue));
- DEBUG ((DEBUG_INFO, " Step - 0x%016lx\n", IfrNumeric->data.u64.Step));
- break;
+ case EFI_IFR_NUMERIC_SIZE_1:
+ DEBUG ((DEBUG_INFO, " MinValue - 0x%02x\n", IfrNumeric->data.u8.MinValue));
+ DEBUG ((DEBUG_INFO, " MaxValue - 0x%02x\n", IfrNumeric->data.u8.MaxValue));
+ DEBUG ((DEBUG_INFO, " Step - 0x%02x\n", IfrNumeric->data.u8.Step));
+ break;
+ case EFI_IFR_NUMERIC_SIZE_2:
+ DEBUG ((DEBUG_INFO, " MinValue - 0x%04x\n", IfrNumeric->data.u16.MinValue));
+ DEBUG ((DEBUG_INFO, " MaxValue - 0x%04x\n", IfrNumeric->data.u16.MaxValue));
+ DEBUG ((DEBUG_INFO, " Step - 0x%04x\n", IfrNumeric->data.u16.Step));
+ break;
+ case EFI_IFR_NUMERIC_SIZE_4:
+ DEBUG ((DEBUG_INFO, " MinValue - 0x%08x\n", IfrNumeric->data.u32.MinValue));
+ DEBUG ((DEBUG_INFO, " MaxValue - 0x%08x\n", IfrNumeric->data.u32.MaxValue));
+ DEBUG ((DEBUG_INFO, " Step - 0x%08x\n", IfrNumeric->data.u32.Step));
+ break;
+ case EFI_IFR_NUMERIC_SIZE_8:
+ DEBUG ((DEBUG_INFO, " MinValue - 0x%016lx\n", IfrNumeric->data.u64.MinValue));
+ DEBUG ((DEBUG_INFO, " MaxValue - 0x%016lx\n", IfrNumeric->data.u64.MaxValue));
+ DEBUG ((DEBUG_INFO, " Step - 0x%016lx\n", IfrNumeric->data.u64.Step));
+ break;
}
}
+
break;
case EFI_IFR_ORDERED_LIST_OP:
- IfrOrderedList = (EFI_IFR_ORDERED_LIST *) IfrOpCodeHeader;
+ IfrOrderedList = (EFI_IFR_ORDERED_LIST *)IfrOpCodeHeader;
DEBUG ((DEBUG_INFO, " MaxContainers - 0x%02x\n", IfrOrderedList->MaxContainers));
DEBUG ((DEBUG_INFO, " Flags - 0x%02x\n", IfrOrderedList->Flags));
break;
@@ -262,11 +268,11 @@ DumpHiiPackage ( }
if (IfrOpCodeHeader->Scope != 0) {
- UINTN Scope;
- EFI_IFR_ONE_OF_OPTION *IfrOneOfOption;
+ UINTN Scope;
+ EFI_IFR_ONE_OF_OPTION *IfrOneOfOption;
- IfrOpCodeHeader = (EFI_IFR_OP_HEADER *) ((UINTN) IfrOpCodeHeader + IfrOpCodeHeader->Length);
- Scope = 1;
+ IfrOpCodeHeader = (EFI_IFR_OP_HEADER *)((UINTN)IfrOpCodeHeader + IfrOpCodeHeader->Length);
+ Scope = 1;
while (Scope != 0) {
switch (IfrOpCodeHeader->OpCode) {
case EFI_IFR_ONE_OF_OPTION_OP:
@@ -295,6 +301,7 @@ DumpHiiPackage ( default:
break;
}
+
break;
}
@@ -308,15 +315,18 @@ DumpHiiPackage ( } else if (IfrOpCodeHeader->Scope != 0) {
Scope++;
}
- IfrOpCodeHeader = (EFI_IFR_OP_HEADER *) ((UINTN) IfrOpCodeHeader + IfrOpCodeHeader->Length);
+
+ IfrOpCodeHeader = (EFI_IFR_OP_HEADER *)((UINTN)IfrOpCodeHeader + IfrOpCodeHeader->Length);
}
}
}
default:
break;
}
- IfrOpCodeHeader = (EFI_IFR_OP_HEADER *) ((UINTN) IfrOpCodeHeader + IfrOpCodeHeader->Length);
+
+ IfrOpCodeHeader = (EFI_IFR_OP_HEADER *)((UINTN)IfrOpCodeHeader + IfrOpCodeHeader->Length);
}
+
break;
default:
break;
@@ -332,33 +342,33 @@ DumpHiiPackage ( **/
VOID
DumpHiiDatabase (
- IN VOID *HiiDatabase,
- IN UINTN HiiDatabaseSize
+ IN VOID *HiiDatabase,
+ IN UINTN HiiDatabaseSize
)
{
- EFI_HII_PACKAGE_LIST_HEADER *HiiPackageListHeader;
- EFI_HII_PACKAGE_HEADER *HiiPackageHeader;
+ EFI_HII_PACKAGE_LIST_HEADER *HiiPackageListHeader;
+ EFI_HII_PACKAGE_HEADER *HiiPackageHeader;
DEBUG ((DEBUG_INFO, "HiiDatabaseSize - 0x%x\n", HiiDatabaseSize));
- HiiPackageListHeader = (EFI_HII_PACKAGE_LIST_HEADER *) HiiDatabase;
+ HiiPackageListHeader = (EFI_HII_PACKAGE_LIST_HEADER *)HiiDatabase;
- while ((UINTN) HiiPackageListHeader < ((UINTN) HiiDatabase + HiiDatabaseSize)) {
+ while ((UINTN)HiiPackageListHeader < ((UINTN)HiiDatabase + HiiDatabaseSize)) {
DEBUG ((DEBUG_INFO, "HiiPackageListHeader->PackageListGuid - %g\n", &HiiPackageListHeader->PackageListGuid));
DEBUG ((DEBUG_INFO, "HiiPackageListHeader->PackageLength - 0x%x\n", (UINTN)HiiPackageListHeader->PackageLength));
HiiPackageHeader = (EFI_HII_PACKAGE_HEADER *)(HiiPackageListHeader + 1);
- while ((UINTN) HiiPackageHeader < (UINTN) HiiPackageListHeader + HiiPackageListHeader->PackageLength) {
-
+ while ((UINTN)HiiPackageHeader < (UINTN)HiiPackageListHeader + HiiPackageListHeader->PackageLength) {
DumpHiiPackage (HiiPackageHeader);
- HiiPackageHeader = (EFI_HII_PACKAGE_HEADER *) ((UINTN) HiiPackageHeader + HiiPackageHeader->Length);
+ HiiPackageHeader = (EFI_HII_PACKAGE_HEADER *)((UINTN)HiiPackageHeader + HiiPackageHeader->Length);
}
- HiiPackageListHeader = (EFI_HII_PACKAGE_LIST_HEADER *) ((UINTN) HiiPackageListHeader + HiiPackageListHeader->PackageLength);
+ HiiPackageListHeader = (EFI_HII_PACKAGE_LIST_HEADER *)((UINTN)HiiPackageListHeader + HiiPackageListHeader->PackageLength);
}
- return ;
+ return;
}
+
#endif
/**
@@ -387,6 +397,7 @@ InternalVarCheckAllocatePool ( if (EFI_ERROR (Status)) {
Memory = NULL;
}
+
return Memory;
}
@@ -405,7 +416,7 @@ InternalVarCheckAllocatePool ( **/
VOID *
InternalVarCheckAllocateZeroPool (
- IN UINTN AllocationSize
+ IN UINTN AllocationSize
)
{
VOID *Memory;
@@ -414,6 +425,7 @@ InternalVarCheckAllocateZeroPool ( if (Memory != NULL) {
Memory = ZeroMem (Memory, AllocationSize);
}
+
return Memory;
}
@@ -434,10 +446,10 @@ InternalVarCheckAllocateZeroPool ( VOID
EFIAPI
InternalVarCheckFreePool (
- IN VOID *Buffer
+ IN VOID *Buffer
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
Status = gBS->FreePool (Buffer);
ASSERT_EFI_ERROR (Status);
@@ -466,18 +478,19 @@ InternalVarCheckFreePool ( **/
VOID *
InternalVarCheckReallocatePool (
- IN UINTN OldSize,
- IN UINTN NewSize,
- IN VOID *OldBuffer OPTIONAL
+ IN UINTN OldSize,
+ IN UINTN NewSize,
+ IN VOID *OldBuffer OPTIONAL
)
{
VOID *NewBuffer;
NewBuffer = InternalVarCheckAllocateZeroPool (NewSize);
- if (NewBuffer != NULL && OldBuffer != NULL) {
+ if ((NewBuffer != NULL) && (OldBuffer != NULL)) {
CopyMem (NewBuffer, OldBuffer, MIN (OldSize, NewSize));
InternalVarCheckFreePool (OldBuffer);
}
+
return NewBuffer;
}
@@ -491,25 +504,25 @@ InternalVarCheckReallocatePool ( **/
VOID
MergeHiiQuestion (
- IN OUT VAR_CHECK_HII_VARIABLE_NODE *HiiVariableNode,
- IN VAR_CHECK_HII_QUESTION_HEADER *HiiQuestion,
- IN BOOLEAN FromFv
+ IN OUT VAR_CHECK_HII_VARIABLE_NODE *HiiVariableNode,
+ IN VAR_CHECK_HII_QUESTION_HEADER *HiiQuestion,
+ IN BOOLEAN FromFv
)
{
- VAR_CHECK_HII_QUESTION_HEADER *HiiQuestion1;
- VAR_CHECK_HII_QUESTION_HEADER *HiiQuestion2;
- VAR_CHECK_HII_QUESTION_HEADER *NewHiiQuestion;
- UINT8 NewLength;
- UINT64 Minimum1;
- UINT64 Maximum1;
- UINT64 OneValue1;
- UINT64 Minimum2;
- UINT64 Maximum2;
- UINT64 OneValue2;
- UINT8 *Ptr;
- UINT8 *Ptr1;
- UINT8 *Ptr2;
- UINTN ArrayIndex;
+ VAR_CHECK_HII_QUESTION_HEADER *HiiQuestion1;
+ VAR_CHECK_HII_QUESTION_HEADER *HiiQuestion2;
+ VAR_CHECK_HII_QUESTION_HEADER *NewHiiQuestion;
+ UINT8 NewLength;
+ UINT64 Minimum1;
+ UINT64 Maximum1;
+ UINT64 OneValue1;
+ UINT64 Minimum2;
+ UINT64 Maximum2;
+ UINT64 OneValue2;
+ UINT8 *Ptr;
+ UINT8 *Ptr1;
+ UINT8 *Ptr2;
+ UINTN ArrayIndex;
//
// Hii Question from Hii Database has high priority.
@@ -533,7 +546,7 @@ MergeHiiQuestion ( switch (HiiQuestion1->OpCode) {
case EFI_IFR_ONE_OF_OP:
- DEBUG ((DEBUG_INFO, "MergeHiiQuestion - EFI_IFR_ONE_OF_OP VarOffset = 0x%04x (%a)\n", HiiQuestion1->VarOffset, (HiiQuestion1->BitFieldStore? "bit level": "byte level")));
+ DEBUG ((DEBUG_INFO, "MergeHiiQuestion - EFI_IFR_ONE_OF_OP VarOffset = 0x%04x (%a)\n", HiiQuestion1->VarOffset, (HiiQuestion1->BitFieldStore ? "bit level" : "byte level")));
//
// Get the length of Hii Question 1.
//
@@ -542,13 +555,13 @@ MergeHiiQuestion ( //
// Check if the one of options in Hii Question 2 have been in Hii Question 1.
//
- Ptr2 = (UINT8 *) ((VAR_CHECK_HII_QUESTION_ONEOF *) HiiQuestion2 + 1);
- while ((UINTN) Ptr2 < (UINTN) HiiQuestion2 + HiiQuestion2->Length) {
+ Ptr2 = (UINT8 *)((VAR_CHECK_HII_QUESTION_ONEOF *)HiiQuestion2 + 1);
+ while ((UINTN)Ptr2 < (UINTN)HiiQuestion2 + HiiQuestion2->Length) {
OneValue2 = 0;
CopyMem (&OneValue2, Ptr2, HiiQuestion2->StorageWidth);
- Ptr1 = (UINT8 *) ((VAR_CHECK_HII_QUESTION_ONEOF *) HiiQuestion1 + 1);
- while ((UINTN) Ptr1 < (UINTN) HiiQuestion1 + HiiQuestion1->Length) {
+ Ptr1 = (UINT8 *)((VAR_CHECK_HII_QUESTION_ONEOF *)HiiQuestion1 + 1);
+ while ((UINTN)Ptr1 < (UINTN)HiiQuestion1 + HiiQuestion1->Length) {
OneValue1 = 0;
CopyMem (&OneValue1, Ptr1, HiiQuestion1->StorageWidth);
if (OneValue2 == OneValue1) {
@@ -557,14 +570,17 @@ MergeHiiQuestion ( //
break;
}
+
Ptr1 += HiiQuestion1->StorageWidth;
}
- if ((UINTN) Ptr1 >= ((UINTN) HiiQuestion1 + HiiQuestion1->Length)) {
+
+ if ((UINTN)Ptr1 >= ((UINTN)HiiQuestion1 + HiiQuestion1->Length)) {
//
// No match
//
- NewLength = (UINT8) (NewLength + HiiQuestion1->StorageWidth);
+ NewLength = (UINT8)(NewLength + HiiQuestion1->StorageWidth);
}
+
Ptr2 += HiiQuestion2->StorageWidth;
}
@@ -579,15 +595,15 @@ MergeHiiQuestion ( // Use the new length.
//
NewHiiQuestion->Length = NewLength;
- Ptr = (UINT8 *) NewHiiQuestion + HiiQuestion1->Length;
+ Ptr = (UINT8 *)NewHiiQuestion + HiiQuestion1->Length;
- Ptr2 = (UINT8 *) ((VAR_CHECK_HII_QUESTION_ONEOF *) HiiQuestion2 + 1);
- while ((UINTN) Ptr2 < (UINTN) HiiQuestion2 + HiiQuestion2->Length) {
+ Ptr2 = (UINT8 *)((VAR_CHECK_HII_QUESTION_ONEOF *)HiiQuestion2 + 1);
+ while ((UINTN)Ptr2 < (UINTN)HiiQuestion2 + HiiQuestion2->Length) {
OneValue2 = 0;
CopyMem (&OneValue2, Ptr2, HiiQuestion2->StorageWidth);
- Ptr1 = (UINT8 *) ((VAR_CHECK_HII_QUESTION_ONEOF *) HiiQuestion1 + 1);
- while ((UINTN) Ptr1 < (UINTN) HiiQuestion1 + HiiQuestion1->Length) {
+ Ptr1 = (UINT8 *)((VAR_CHECK_HII_QUESTION_ONEOF *)HiiQuestion1 + 1);
+ while ((UINTN)Ptr1 < (UINTN)HiiQuestion1 + HiiQuestion1->Length) {
OneValue1 = 0;
CopyMem (&OneValue1, Ptr1, HiiQuestion1->StorageWidth);
if (OneValue2 == OneValue1) {
@@ -596,35 +612,39 @@ MergeHiiQuestion ( //
break;
}
+
Ptr1 += HiiQuestion1->StorageWidth;
}
- if ((UINTN) Ptr1 >= ((UINTN) HiiQuestion1 + HiiQuestion1->Length)) {
+
+ if ((UINTN)Ptr1 >= ((UINTN)HiiQuestion1 + HiiQuestion1->Length)) {
//
// No match
//
CopyMem (Ptr, &OneValue2, HiiQuestion1->StorageWidth);
Ptr += HiiQuestion1->StorageWidth;
}
+
Ptr2 += HiiQuestion2->StorageWidth;
}
HiiVariableNode->HiiQuestionArray[ArrayIndex] = NewHiiQuestion;
InternalVarCheckFreePool (HiiQuestion1);
}
+
break;
case EFI_IFR_CHECKBOX_OP:
- DEBUG ((DEBUG_INFO, "MergeHiiQuestion - EFI_IFR_CHECKBOX_OP VarOffset = 0x%04x (%a)\n", HiiQuestion1->VarOffset, (HiiQuestion1->BitFieldStore? "bit level": "byte level")));
+ DEBUG ((DEBUG_INFO, "MergeHiiQuestion - EFI_IFR_CHECKBOX_OP VarOffset = 0x%04x (%a)\n", HiiQuestion1->VarOffset, (HiiQuestion1->BitFieldStore ? "bit level" : "byte level")));
break;
case EFI_IFR_NUMERIC_OP:
- DEBUG ((DEBUG_INFO, "MergeHiiQuestion - EFI_IFR_NUMERIC_OP VarOffset = 0x%04x (%a)\n", HiiQuestion1->VarOffset, (HiiQuestion1->BitFieldStore? "bit level": "byte level")));
+ DEBUG ((DEBUG_INFO, "MergeHiiQuestion - EFI_IFR_NUMERIC_OP VarOffset = 0x%04x (%a)\n", HiiQuestion1->VarOffset, (HiiQuestion1->BitFieldStore ? "bit level" : "byte level")));
//
// Get minimum and maximum of Hii Question 1.
//
Minimum1 = 0;
Maximum1 = 0;
- Ptr = (UINT8 *) ((VAR_CHECK_HII_QUESTION_NUMERIC *) HiiQuestion1 + 1);
+ Ptr = (UINT8 *)((VAR_CHECK_HII_QUESTION_NUMERIC *)HiiQuestion1 + 1);
CopyMem (&Minimum1, Ptr, HiiQuestion1->StorageWidth);
Ptr += HiiQuestion1->StorageWidth;
CopyMem (&Maximum1, Ptr, HiiQuestion1->StorageWidth);
@@ -634,7 +654,7 @@ MergeHiiQuestion ( //
Minimum2 = 0;
Maximum2 = 0;
- Ptr = (UINT8 *) ((VAR_CHECK_HII_QUESTION_NUMERIC *) HiiQuestion2 + 1);
+ Ptr = (UINT8 *)((VAR_CHECK_HII_QUESTION_NUMERIC *)HiiQuestion2 + 1);
CopyMem (&Minimum2, Ptr, HiiQuestion2->StorageWidth);
Ptr += HiiQuestion2->StorageWidth;
CopyMem (&Maximum2, Ptr, HiiQuestion2->StorageWidth);
@@ -642,11 +662,12 @@ MergeHiiQuestion ( //
// Update minimum.
//
- Ptr = (UINT8 *) ((VAR_CHECK_HII_QUESTION_NUMERIC *) HiiQuestion1 + 1);
+ Ptr = (UINT8 *)((VAR_CHECK_HII_QUESTION_NUMERIC *)HiiQuestion1 + 1);
if (Minimum2 < Minimum1) {
Minimum1 = Minimum2;
CopyMem (Ptr, &Minimum1, HiiQuestion1->StorageWidth);
}
+
//
// Update maximum.
//
@@ -655,6 +676,7 @@ MergeHiiQuestion ( Maximum1 = Maximum2;
CopyMem (Ptr, &Maximum1, HiiQuestion1->StorageWidth);
}
+
break;
case EFI_IFR_ORDERED_LIST_OP:
@@ -667,13 +689,13 @@ MergeHiiQuestion ( //
// Check if the one of options in Hii Question 2 have been in Hii Question 1.
//
- Ptr2 = (UINT8 *) ((VAR_CHECK_HII_QUESTION_ORDEREDLIST *) HiiQuestion2 + 1);
- while ((UINTN) Ptr2 < (UINTN) HiiQuestion2 + HiiQuestion2->Length) {
+ Ptr2 = (UINT8 *)((VAR_CHECK_HII_QUESTION_ORDEREDLIST *)HiiQuestion2 + 1);
+ while ((UINTN)Ptr2 < (UINTN)HiiQuestion2 + HiiQuestion2->Length) {
OneValue2 = 0;
CopyMem (&OneValue2, Ptr2, HiiQuestion2->StorageWidth);
- Ptr1 = (UINT8 *) ((VAR_CHECK_HII_QUESTION_ORDEREDLIST *) HiiQuestion1 + 1);
- while ((UINTN) Ptr1 < (UINTN) HiiQuestion1 + HiiQuestion1->Length) {
+ Ptr1 = (UINT8 *)((VAR_CHECK_HII_QUESTION_ORDEREDLIST *)HiiQuestion1 + 1);
+ while ((UINTN)Ptr1 < (UINTN)HiiQuestion1 + HiiQuestion1->Length) {
OneValue1 = 0;
CopyMem (&OneValue1, Ptr1, HiiQuestion1->StorageWidth);
if (OneValue2 == OneValue1) {
@@ -682,14 +704,17 @@ MergeHiiQuestion ( //
break;
}
+
Ptr1 += HiiQuestion1->StorageWidth;
}
- if ((UINTN) Ptr1 >= ((UINTN) HiiQuestion1 + HiiQuestion1->Length)) {
+
+ if ((UINTN)Ptr1 >= ((UINTN)HiiQuestion1 + HiiQuestion1->Length)) {
//
// No match
//
- NewLength = (UINT8) (NewLength + HiiQuestion1->StorageWidth);
+ NewLength = (UINT8)(NewLength + HiiQuestion1->StorageWidth);
}
+
Ptr2 += HiiQuestion2->StorageWidth;
}
@@ -704,15 +729,15 @@ MergeHiiQuestion ( // Use the new length.
//
NewHiiQuestion->Length = NewLength;
- Ptr = (UINT8 *) NewHiiQuestion + HiiQuestion1->Length;
+ Ptr = (UINT8 *)NewHiiQuestion + HiiQuestion1->Length;
- Ptr2 = (UINT8 *) ((VAR_CHECK_HII_QUESTION_ORDEREDLIST *) HiiQuestion2 + 1);
- while ((UINTN) Ptr2 < (UINTN) HiiQuestion2 + HiiQuestion2->Length) {
+ Ptr2 = (UINT8 *)((VAR_CHECK_HII_QUESTION_ORDEREDLIST *)HiiQuestion2 + 1);
+ while ((UINTN)Ptr2 < (UINTN)HiiQuestion2 + HiiQuestion2->Length) {
OneValue2 = 0;
CopyMem (&OneValue2, Ptr2, HiiQuestion2->StorageWidth);
- Ptr1 = (UINT8 *) ((VAR_CHECK_HII_QUESTION_ORDEREDLIST *) HiiQuestion1 + 1);
- while ((UINTN) Ptr1 < (UINTN) HiiQuestion1 + HiiQuestion1->Length) {
+ Ptr1 = (UINT8 *)((VAR_CHECK_HII_QUESTION_ORDEREDLIST *)HiiQuestion1 + 1);
+ while ((UINTN)Ptr1 < (UINTN)HiiQuestion1 + HiiQuestion1->Length) {
OneValue1 = 0;
CopyMem (&OneValue1, Ptr1, HiiQuestion1->StorageWidth);
if (OneValue2 == OneValue1) {
@@ -721,21 +746,25 @@ MergeHiiQuestion ( //
break;
}
+
Ptr1 += HiiQuestion1->StorageWidth;
}
- if ((UINTN) Ptr1 >= ((UINTN) HiiQuestion1 + HiiQuestion1->Length)) {
+
+ if ((UINTN)Ptr1 >= ((UINTN)HiiQuestion1 + HiiQuestion1->Length)) {
//
// No match
//
CopyMem (Ptr, &OneValue2, HiiQuestion1->StorageWidth);
Ptr += HiiQuestion1->StorageWidth;
}
+
Ptr2 += HiiQuestion2->StorageWidth;
}
HiiVariableNode->HiiQuestionArray[ArrayIndex] = NewHiiQuestion;
InternalVarCheckFreePool (HiiQuestion1);
}
+
break;
default:
@@ -762,14 +791,14 @@ MergeHiiQuestion ( **/
VOID
GetOneOfOption (
- IN EFI_IFR_OP_HEADER *IfrOpCodeHeader,
- OUT UINTN *Count,
- OUT UINT8 *Width,
- OUT VOID *OptionBuffer OPTIONAL
+ IN EFI_IFR_OP_HEADER *IfrOpCodeHeader,
+ OUT UINTN *Count,
+ OUT UINT8 *Width,
+ OUT VOID *OptionBuffer OPTIONAL
)
{
- UINTN Scope;
- EFI_IFR_ONE_OF_OPTION *IfrOneOfOption;
+ UINTN Scope;
+ EFI_IFR_ONE_OF_OPTION *IfrOneOfOption;
//
// Assume all OPTION has same Width.
@@ -780,56 +809,62 @@ GetOneOfOption ( //
// Nested OpCode.
//
- Scope = 1;
- IfrOpCodeHeader = (EFI_IFR_OP_HEADER *) ((UINTN) IfrOpCodeHeader + IfrOpCodeHeader->Length);
+ Scope = 1;
+ IfrOpCodeHeader = (EFI_IFR_OP_HEADER *)((UINTN)IfrOpCodeHeader + IfrOpCodeHeader->Length);
while (Scope != 0) {
switch (IfrOpCodeHeader->OpCode) {
case EFI_IFR_ONE_OF_OPTION_OP:
- IfrOneOfOption = (EFI_IFR_ONE_OF_OPTION *) IfrOpCodeHeader;
+ IfrOneOfOption = (EFI_IFR_ONE_OF_OPTION *)IfrOpCodeHeader;
switch (IfrOneOfOption->Type) {
case EFI_IFR_TYPE_NUM_SIZE_8:
*Count = *Count + 1;
*Width = sizeof (UINT8);
if (OptionBuffer != NULL) {
CopyMem (OptionBuffer, &IfrOneOfOption->Value.u8, sizeof (UINT8));
- OptionBuffer = (UINT8 *) OptionBuffer + 1;
+ OptionBuffer = (UINT8 *)OptionBuffer + 1;
}
+
break;
case EFI_IFR_TYPE_NUM_SIZE_16:
*Count = *Count + 1;
*Width = sizeof (UINT16);
if (OptionBuffer != NULL) {
CopyMem (OptionBuffer, &IfrOneOfOption->Value.u16, sizeof (UINT16));
- OptionBuffer = (UINT16 *) OptionBuffer + 1;
+ OptionBuffer = (UINT16 *)OptionBuffer + 1;
}
+
break;
case EFI_IFR_TYPE_NUM_SIZE_32:
*Count = *Count + 1;
*Width = sizeof (UINT32);
if (OptionBuffer != NULL) {
CopyMem (OptionBuffer, &IfrOneOfOption->Value.u32, sizeof (UINT32));
- OptionBuffer = (UINT32 *) OptionBuffer + 1;
+ OptionBuffer = (UINT32 *)OptionBuffer + 1;
}
+
break;
case EFI_IFR_TYPE_NUM_SIZE_64:
*Count = *Count + 1;
*Width = sizeof (UINT64);
if (OptionBuffer != NULL) {
CopyMem (OptionBuffer, &IfrOneOfOption->Value.u64, sizeof (UINT64));
- OptionBuffer = (UINT64 *) OptionBuffer + 1;
+ OptionBuffer = (UINT64 *)OptionBuffer + 1;
}
+
break;
case EFI_IFR_TYPE_BOOLEAN:
*Count = *Count + 1;
*Width = sizeof (BOOLEAN);
if (OptionBuffer != NULL) {
CopyMem (OptionBuffer, &IfrOneOfOption->Value.b, sizeof (BOOLEAN));
- OptionBuffer = (BOOLEAN *) OptionBuffer + 1;
+ OptionBuffer = (BOOLEAN *)OptionBuffer + 1;
}
+
break;
default:
break;
}
+
break;
}
@@ -848,11 +883,12 @@ GetOneOfOption ( //
Scope++;
}
- IfrOpCodeHeader = (EFI_IFR_OP_HEADER *) ((UINTN) IfrOpCodeHeader + IfrOpCodeHeader->Length);
+
+ IfrOpCodeHeader = (EFI_IFR_OP_HEADER *)((UINTN)IfrOpCodeHeader + IfrOpCodeHeader->Length);
}
}
- return ;
+ return;
}
/**
@@ -878,7 +914,7 @@ ParseHiiQuestionOneOf ( UINT8 OptionWidth;
UINT8 BitWidth;
- IfrOneOf = (EFI_IFR_ONE_OF *) IfrOpCodeHeader;
+ IfrOneOf = (EFI_IFR_ONE_OF *)IfrOpCodeHeader;
BitWidth = 0;
if (StoredInBitField) {
@@ -887,9 +923,9 @@ ParseHiiQuestionOneOf ( // And the options in the OneOf is saved as UINT32 type.
//
BitWidth = IfrOneOf->Flags & EDKII_IFR_NUMERIC_SIZE_BIT;
- Width = sizeof (UINT32);
+ Width = sizeof (UINT32);
} else {
- Width = (UINT8) (1 << (IfrOneOf->Flags & EFI_IFR_NUMERIC_SIZE));
+ Width = (UINT8)(1 << (IfrOneOf->Flags & EFI_IFR_NUMERIC_SIZE));
}
GetOneOfOption (IfrOpCodeHeader, &OptionCount, &OptionWidth, NULL);
@@ -899,10 +935,10 @@ ParseHiiQuestionOneOf ( OneOf = InternalVarCheckAllocateZeroPool (Length);
ASSERT (OneOf != NULL);
- OneOf->OpCode = EFI_IFR_ONE_OF_OP;
- OneOf->Length = (UINT8) Length;
- OneOf->VarOffset = IfrOneOf->Question.VarStoreInfo.VarOffset;
- OneOf->BitFieldStore = StoredInBitField;
+ OneOf->OpCode = EFI_IFR_ONE_OF_OP;
+ OneOf->Length = (UINT8)Length;
+ OneOf->VarOffset = IfrOneOf->Question.VarStoreInfo.VarOffset;
+ OneOf->BitFieldStore = StoredInBitField;
if (StoredInBitField) {
OneOf->StorageWidth = BitWidth;
} else {
@@ -911,7 +947,7 @@ ParseHiiQuestionOneOf ( GetOneOfOption (IfrOpCodeHeader, &OptionCount, &OptionWidth, OneOf + 1);
- return (VAR_CHECK_HII_QUESTION_HEADER *) OneOf;
+ return (VAR_CHECK_HII_QUESTION_HEADER *)OneOf;
}
/**
@@ -929,24 +965,24 @@ ParseHiiQuestionCheckBox ( IN BOOLEAN StoredInBitField
)
{
- EFI_IFR_CHECKBOX *IfrCheckBox;
- VAR_CHECK_HII_QUESTION_CHECKBOX *CheckBox;
+ EFI_IFR_CHECKBOX *IfrCheckBox;
+ VAR_CHECK_HII_QUESTION_CHECKBOX *CheckBox;
- IfrCheckBox = (EFI_IFR_CHECKBOX *) IfrOpCodeHeader;
+ IfrCheckBox = (EFI_IFR_CHECKBOX *)IfrOpCodeHeader;
CheckBox = InternalVarCheckAllocateZeroPool (sizeof (*CheckBox));
ASSERT (CheckBox != NULL);
- CheckBox->OpCode = EFI_IFR_CHECKBOX_OP;
- CheckBox->Length = (UINT8) sizeof (*CheckBox);;
- CheckBox->VarOffset = IfrCheckBox->Question.VarStoreInfo.VarOffset;
- CheckBox->BitFieldStore = StoredInBitField;
+ CheckBox->OpCode = EFI_IFR_CHECKBOX_OP;
+ CheckBox->Length = (UINT8)sizeof (*CheckBox);
+ CheckBox->VarOffset = IfrCheckBox->Question.VarStoreInfo.VarOffset;
+ CheckBox->BitFieldStore = StoredInBitField;
if (StoredInBitField) {
CheckBox->StorageWidth = 1;
} else {
- CheckBox->StorageWidth = (UINT8) sizeof (BOOLEAN);
+ CheckBox->StorageWidth = (UINT8)sizeof (BOOLEAN);
}
- return (VAR_CHECK_HII_QUESTION_HEADER *) CheckBox;
+ return (VAR_CHECK_HII_QUESTION_HEADER *)CheckBox;
}
/**
@@ -964,13 +1000,13 @@ ParseHiiQuestionNumeric ( IN BOOLEAN StoredInBitField
)
{
- EFI_IFR_NUMERIC *IfrNumeric;
- VAR_CHECK_HII_QUESTION_NUMERIC *Numeric;
- UINT8 Width;
- UINT8 BitWidth;
+ EFI_IFR_NUMERIC *IfrNumeric;
+ VAR_CHECK_HII_QUESTION_NUMERIC *Numeric;
+ UINT8 Width;
+ UINT8 BitWidth;
- IfrNumeric = (EFI_IFR_NUMERIC *) IfrOpCodeHeader;
- BitWidth = 0;
+ IfrNumeric = (EFI_IFR_NUMERIC *)IfrOpCodeHeader;
+ BitWidth = 0;
Numeric = InternalVarCheckAllocateZeroPool (sizeof (VAR_CHECK_HII_QUESTION_NUMERIC) + 2 * sizeof (UINT64));
ASSERT (Numeric != NULL);
@@ -981,15 +1017,15 @@ ParseHiiQuestionNumeric ( // And the Minimum Maximum of Numeric is saved as UINT32 type.
//
BitWidth = IfrNumeric->Flags & EDKII_IFR_NUMERIC_SIZE_BIT;
- Width = sizeof (UINT32);
+ Width = sizeof (UINT32);
} else {
- Width = (UINT8) (1 << (IfrNumeric->Flags & EFI_IFR_NUMERIC_SIZE));
+ Width = (UINT8)(1 << (IfrNumeric->Flags & EFI_IFR_NUMERIC_SIZE));
}
- Numeric->OpCode = EFI_IFR_NUMERIC_OP;
- Numeric->Length = (UINT8) (sizeof (VAR_CHECK_HII_QUESTION_NUMERIC) + 2 * Width);
- Numeric->VarOffset = IfrNumeric->Question.VarStoreInfo.VarOffset;
- Numeric->BitFieldStore = StoredInBitField;
+ Numeric->OpCode = EFI_IFR_NUMERIC_OP;
+ Numeric->Length = (UINT8)(sizeof (VAR_CHECK_HII_QUESTION_NUMERIC) + 2 * Width);
+ Numeric->VarOffset = IfrNumeric->Question.VarStoreInfo.VarOffset;
+ Numeric->BitFieldStore = StoredInBitField;
if (StoredInBitField) {
Numeric->StorageWidth = BitWidth;
} else {
@@ -998,7 +1034,7 @@ ParseHiiQuestionNumeric ( CopyMem (Numeric + 1, &IfrNumeric->data, Width * 2);
- return (VAR_CHECK_HII_QUESTION_HEADER *) Numeric;
+ return (VAR_CHECK_HII_QUESTION_HEADER *)Numeric;
}
/**
@@ -1014,13 +1050,13 @@ ParseHiiQuestionOrderedList ( IN EFI_IFR_OP_HEADER *IfrOpCodeHeader
)
{
- EFI_IFR_ORDERED_LIST *IfrOrderedList;
- VAR_CHECK_HII_QUESTION_ORDEREDLIST *OrderedList;
- UINTN Length;
- UINTN OptionCount;
- UINT8 OptionWidth;
+ EFI_IFR_ORDERED_LIST *IfrOrderedList;
+ VAR_CHECK_HII_QUESTION_ORDEREDLIST *OrderedList;
+ UINTN Length;
+ UINTN OptionCount;
+ UINT8 OptionWidth;
- IfrOrderedList = (EFI_IFR_ORDERED_LIST *) IfrOpCodeHeader;
+ IfrOrderedList = (EFI_IFR_ORDERED_LIST *)IfrOpCodeHeader;
GetOneOfOption (IfrOpCodeHeader, &OptionCount, &OptionWidth, NULL);
@@ -1029,7 +1065,7 @@ ParseHiiQuestionOrderedList ( OrderedList = InternalVarCheckAllocateZeroPool (Length);
ASSERT (OrderedList != NULL);
OrderedList->OpCode = EFI_IFR_ORDERED_LIST_OP;
- OrderedList->Length = (UINT8) Length;
+ OrderedList->Length = (UINT8)Length;
OrderedList->VarOffset = IfrOrderedList->Question.VarStoreInfo.VarOffset;
OrderedList->StorageWidth = OptionWidth;
OrderedList->MaxContainers = IfrOrderedList->MaxContainers;
@@ -1037,7 +1073,7 @@ ParseHiiQuestionOrderedList ( GetOneOfOption (IfrOpCodeHeader, &OptionCount, &OptionWidth, OrderedList + 1);
- return (VAR_CHECK_HII_QUESTION_HEADER *) OrderedList;
+ return (VAR_CHECK_HII_QUESTION_HEADER *)OrderedList;
}
/**
@@ -1051,14 +1087,14 @@ ParseHiiQuestionOrderedList ( **/
VOID
ParseHiiQuestion (
- IN VAR_CHECK_HII_VARIABLE_NODE *HiiVariableNode,
- IN EFI_IFR_OP_HEADER *IfrOpCodeHeader,
- IN BOOLEAN FromFv,
- IN BOOLEAN StoredInBitField
+ IN VAR_CHECK_HII_VARIABLE_NODE *HiiVariableNode,
+ IN EFI_IFR_OP_HEADER *IfrOpCodeHeader,
+ IN BOOLEAN FromFv,
+ IN BOOLEAN StoredInBitField
)
{
- VAR_CHECK_HII_QUESTION_HEADER *HiiQuestion;
- UINTN ArrayIndex;
+ VAR_CHECK_HII_QUESTION_HEADER *HiiQuestion;
+ UINTN ArrayIndex;
//
// Currently only OneOf, CheckBox and Numeric can be stored in bit field.
@@ -1091,6 +1127,7 @@ ParseHiiQuestion ( } else {
ArrayIndex = HiiQuestion->VarOffset * 8;
}
+
if (HiiVariableNode->HiiQuestionArray[ArrayIndex] != NULL) {
MergeHiiQuestion (HiiVariableNode, HiiQuestion, FromFv);
} else {
@@ -1109,20 +1146,22 @@ ParseHiiQuestion ( **/
VAR_CHECK_HII_VARIABLE_NODE *
FindHiiVariableNode (
- IN CHAR16 *Name,
- IN EFI_GUID *Guid
+ IN CHAR16 *Name,
+ IN EFI_GUID *Guid
)
{
- VAR_CHECK_HII_VARIABLE_NODE *HiiVariableNode;
- LIST_ENTRY *Link;
+ VAR_CHECK_HII_VARIABLE_NODE *HiiVariableNode;
+ LIST_ENTRY *Link;
for (Link = mVarCheckHiiList.ForwardLink
- ;Link != &mVarCheckHiiList
- ;Link = Link->ForwardLink) {
+ ; Link != &mVarCheckHiiList
+ ; Link = Link->ForwardLink)
+ {
HiiVariableNode = VAR_CHECK_HII_VARIABLE_FROM_LINK (Link);
- if ((StrCmp (Name, (CHAR16 *) (HiiVariableNode->HiiVariable + 1)) == 0) &&
- CompareGuid (Guid, &HiiVariableNode->HiiVariable->Guid)) {
+ if ((StrCmp (Name, (CHAR16 *)(HiiVariableNode->HiiVariable + 1)) == 0) &&
+ CompareGuid (Guid, &HiiVariableNode->HiiVariable->Guid))
+ {
return HiiVariableNode;
}
}
@@ -1140,11 +1179,11 @@ FindHiiVariableNode ( **/
VAR_CHECK_HII_VARIABLE_NODE *
FindHiiVariableNodeByVarStoreId (
- IN EFI_VARSTORE_ID VarStoreId
+ IN EFI_VARSTORE_ID VarStoreId
)
{
- VAR_CHECK_HII_VARIABLE_NODE *HiiVariableNode;
- LIST_ENTRY *Link;
+ VAR_CHECK_HII_VARIABLE_NODE *HiiVariableNode;
+ LIST_ENTRY *Link;
if (VarStoreId == 0) {
//
@@ -1155,8 +1194,9 @@ FindHiiVariableNodeByVarStoreId ( }
for (Link = mVarCheckHiiList.ForwardLink
- ;Link != &mVarCheckHiiList
- ;Link = Link->ForwardLink) {
+ ; Link != &mVarCheckHiiList
+ ; Link = Link->ForwardLink)
+ {
HiiVariableNode = VAR_CHECK_HII_VARIABLE_FROM_LINK (Link);
//
// The variable store identifier, which is unique within the current form set.
@@ -1178,12 +1218,13 @@ DestroyVarStoreId ( VOID
)
{
- VAR_CHECK_HII_VARIABLE_NODE *HiiVariableNode;
- LIST_ENTRY *Link;
+ VAR_CHECK_HII_VARIABLE_NODE *HiiVariableNode;
+ LIST_ENTRY *Link;
for (Link = mVarCheckHiiList.ForwardLink
- ;Link != &mVarCheckHiiList
- ;Link = Link->ForwardLink) {
+ ; Link != &mVarCheckHiiList
+ ; Link = Link->ForwardLink)
+ {
HiiVariableNode = VAR_CHECK_HII_VARIABLE_FROM_LINK (Link);
//
// The variable store identifier, which is unique within the current form set.
@@ -1201,25 +1242,26 @@ DestroyVarStoreId ( **/
VOID
CreateHiiVariableNode (
- IN EFI_IFR_VARSTORE_EFI *IfrEfiVarStore
+ IN EFI_IFR_VARSTORE_EFI *IfrEfiVarStore
)
{
- VAR_CHECK_HII_VARIABLE_NODE *HiiVariableNode;
- VAR_CHECK_HII_VARIABLE_HEADER *HiiVariable;
- UINTN HeaderLength;
- CHAR16 *VarName;
- UINTN VarNameSize;
+ VAR_CHECK_HII_VARIABLE_NODE *HiiVariableNode;
+ VAR_CHECK_HII_VARIABLE_HEADER *HiiVariable;
+ UINTN HeaderLength;
+ CHAR16 *VarName;
+ UINTN VarNameSize;
//
// Get variable name.
//
- VarNameSize = AsciiStrSize ((CHAR8 *) IfrEfiVarStore->Name) * sizeof (CHAR16);
+ VarNameSize = AsciiStrSize ((CHAR8 *)IfrEfiVarStore->Name) * sizeof (CHAR16);
if (VarNameSize > mMaxVarNameSize) {
mVarName = InternalVarCheckReallocatePool (mMaxVarNameSize, VarNameSize, mVarName);
ASSERT (mVarName != NULL);
mMaxVarNameSize = VarNameSize;
}
- AsciiStrToUnicodeStrS ((CHAR8 *) IfrEfiVarStore->Name, mVarName, mMaxVarNameSize / sizeof (CHAR16));
+
+ AsciiStrToUnicodeStrS ((CHAR8 *)IfrEfiVarStore->Name, mVarName, mMaxVarNameSize / sizeof (CHAR16));
VarName = mVarName;
HiiVariableNode = FindHiiVariableNode (
@@ -1231,24 +1273,24 @@ CreateHiiVariableNode ( // Not found, then create new.
//
HeaderLength = sizeof (*HiiVariable) + VarNameSize;
- HiiVariable = InternalVarCheckAllocateZeroPool (HeaderLength);
+ HiiVariable = InternalVarCheckAllocateZeroPool (HeaderLength);
ASSERT (HiiVariable != NULL);
- HiiVariable->Revision = VAR_CHECK_HII_REVISION;
- HiiVariable->OpCode = EFI_IFR_VARSTORE_EFI_OP;
- HiiVariable->HeaderLength = (UINT16) HeaderLength;
- HiiVariable->Size = IfrEfiVarStore->Size;
- HiiVariable->Attributes = IfrEfiVarStore->Attributes;
+ HiiVariable->Revision = VAR_CHECK_HII_REVISION;
+ HiiVariable->OpCode = EFI_IFR_VARSTORE_EFI_OP;
+ HiiVariable->HeaderLength = (UINT16)HeaderLength;
+ HiiVariable->Size = IfrEfiVarStore->Size;
+ HiiVariable->Attributes = IfrEfiVarStore->Attributes;
CopyGuid (&HiiVariable->Guid, &IfrEfiVarStore->Guid);
- StrCpyS ((CHAR16 *) (HiiVariable + 1), VarNameSize / sizeof (CHAR16), VarName);
+ StrCpyS ((CHAR16 *)(HiiVariable + 1), VarNameSize / sizeof (CHAR16), VarName);
HiiVariableNode = InternalVarCheckAllocateZeroPool (sizeof (*HiiVariableNode));
ASSERT (HiiVariableNode != NULL);
- HiiVariableNode->Signature = VAR_CHECK_HII_VARIABLE_NODE_SIGNATURE;
+ HiiVariableNode->Signature = VAR_CHECK_HII_VARIABLE_NODE_SIGNATURE;
HiiVariableNode->HiiVariable = HiiVariable;
//
// The variable store identifier, which is unique within the current form set.
//
- HiiVariableNode->VarStoreId = IfrEfiVarStore->VarStoreId;
+ HiiVariableNode->VarStoreId = IfrEfiVarStore->VarStoreId;
HiiVariableNode->HiiQuestionArray = InternalVarCheckAllocateZeroPool (IfrEfiVarStore->Size * 8 * sizeof (VAR_CHECK_HII_QUESTION_HEADER *));
InsertTailList (&mVarCheckHiiList, &HiiVariableNode->Link);
@@ -1265,40 +1307,44 @@ CreateHiiVariableNode ( **/
VOID
ParseHiiVariable (
- IN VOID *HiiPackage
+ IN VOID *HiiPackage
)
{
- EFI_HII_PACKAGE_HEADER *HiiPackageHeader;
- EFI_IFR_OP_HEADER *IfrOpCodeHeader;
- EFI_IFR_VARSTORE_EFI *IfrEfiVarStore;
+ EFI_HII_PACKAGE_HEADER *HiiPackageHeader;
+ EFI_IFR_OP_HEADER *IfrOpCodeHeader;
+ EFI_IFR_VARSTORE_EFI *IfrEfiVarStore;
- HiiPackageHeader = (EFI_HII_PACKAGE_HEADER *) HiiPackage;
+ HiiPackageHeader = (EFI_HII_PACKAGE_HEADER *)HiiPackage;
switch (HiiPackageHeader->Type) {
case EFI_HII_PACKAGE_FORMS:
- IfrOpCodeHeader = (EFI_IFR_OP_HEADER *) (HiiPackageHeader + 1);
+ IfrOpCodeHeader = (EFI_IFR_OP_HEADER *)(HiiPackageHeader + 1);
- while ((UINTN) IfrOpCodeHeader < (UINTN) HiiPackageHeader + HiiPackageHeader->Length) {
+ while ((UINTN)IfrOpCodeHeader < (UINTN)HiiPackageHeader + HiiPackageHeader->Length) {
switch (IfrOpCodeHeader->OpCode) {
case EFI_IFR_VARSTORE_EFI_OP:
//
// Come to EFI VARSTORE in Form Package.
//
- IfrEfiVarStore = (EFI_IFR_VARSTORE_EFI *) IfrOpCodeHeader;
+ IfrEfiVarStore = (EFI_IFR_VARSTORE_EFI *)IfrOpCodeHeader;
if ((IfrEfiVarStore->Header.Length >= sizeof (EFI_IFR_VARSTORE_EFI)) &&
- ((IfrEfiVarStore->Attributes & EFI_VARIABLE_NON_VOLATILE) != 0)) {
+ ((IfrEfiVarStore->Attributes & EFI_VARIABLE_NON_VOLATILE) != 0))
+ {
//
// Only create node list for Hii Variable with NV attribute.
//
CreateHiiVariableNode (IfrEfiVarStore);
}
+
break;
default:
break;
}
- IfrOpCodeHeader = (EFI_IFR_OP_HEADER *) ((UINTN) IfrOpCodeHeader + IfrOpCodeHeader->Length);
+
+ IfrOpCodeHeader = (EFI_IFR_OP_HEADER *)((UINTN)IfrOpCodeHeader + IfrOpCodeHeader->Length);
}
+
break;
default:
@@ -1315,34 +1361,35 @@ ParseHiiVariable ( **/
VOID
VarCheckParseHiiPackage (
- IN VOID *HiiPackage,
- IN BOOLEAN FromFv
+ IN VOID *HiiPackage,
+ IN BOOLEAN FromFv
)
{
- EFI_HII_PACKAGE_HEADER *HiiPackageHeader;
- EFI_IFR_OP_HEADER *IfrOpCodeHeader;
- VAR_CHECK_HII_VARIABLE_NODE *HiiVariableNode;
- BOOLEAN QuestionStoredInBitField;
+ EFI_HII_PACKAGE_HEADER *HiiPackageHeader;
+ EFI_IFR_OP_HEADER *IfrOpCodeHeader;
+ VAR_CHECK_HII_VARIABLE_NODE *HiiVariableNode;
+ BOOLEAN QuestionStoredInBitField;
//
// Parse and create Hii Variable node list for this Hii Package.
//
ParseHiiVariable (HiiPackage);
- HiiPackageHeader = (EFI_HII_PACKAGE_HEADER *) HiiPackage;
+ HiiPackageHeader = (EFI_HII_PACKAGE_HEADER *)HiiPackage;
QuestionStoredInBitField = FALSE;
switch (HiiPackageHeader->Type) {
case EFI_HII_PACKAGE_FORMS:
- IfrOpCodeHeader = (EFI_IFR_OP_HEADER *) (HiiPackageHeader + 1);
+ IfrOpCodeHeader = (EFI_IFR_OP_HEADER *)(HiiPackageHeader + 1);
- while ((UINTN) IfrOpCodeHeader < (UINTN) HiiPackageHeader + HiiPackageHeader->Length) {
+ while ((UINTN)IfrOpCodeHeader < (UINTN)HiiPackageHeader + HiiPackageHeader->Length) {
switch (IfrOpCodeHeader->OpCode) {
case EFI_IFR_GUID_OP:
if (CompareGuid ((EFI_GUID *)((UINTN)IfrOpCodeHeader + sizeof (EFI_IFR_OP_HEADER)), &gEdkiiIfrBitVarstoreGuid)) {
QuestionStoredInBitField = TRUE;
}
+
break;
case EFI_IFR_END_OP:
@@ -1353,31 +1400,36 @@ VarCheckParseHiiPackage ( case EFI_IFR_CHECKBOX_OP:
case EFI_IFR_NUMERIC_OP:
case EFI_IFR_ORDERED_LIST_OP:
- HiiVariableNode = FindHiiVariableNodeByVarStoreId (((EFI_IFR_ONE_OF *) IfrOpCodeHeader)->Question.VarStoreId);
+ HiiVariableNode = FindHiiVariableNodeByVarStoreId (((EFI_IFR_ONE_OF *)IfrOpCodeHeader)->Question.VarStoreId);
if ((HiiVariableNode == NULL) ||
//
// No related Hii Variable node found.
//
- ((((EFI_IFR_ONE_OF *) IfrOpCodeHeader)->Question.Header.Prompt == 0) && (((EFI_IFR_ONE_OF *) IfrOpCodeHeader)->Question.Header.Help == 0))) {
- //
- // meanless IFR item introduced by ECP.
- //
+ ((((EFI_IFR_ONE_OF *)IfrOpCodeHeader)->Question.Header.Prompt == 0) && (((EFI_IFR_ONE_OF *)IfrOpCodeHeader)->Question.Header.Help == 0)))
+ {
+ //
+ // meanless IFR item introduced by ECP.
+ //
} else {
//
// Normal IFR
//
ParseHiiQuestion (HiiVariableNode, IfrOpCodeHeader, FromFv, QuestionStoredInBitField);
}
+
default:
break;
}
- IfrOpCodeHeader = (EFI_IFR_OP_HEADER *) ((UINTN) IfrOpCodeHeader + IfrOpCodeHeader->Length);
+
+ IfrOpCodeHeader = (EFI_IFR_OP_HEADER *)((UINTN)IfrOpCodeHeader + IfrOpCodeHeader->Length);
}
+
break;
default:
break;
}
+
DestroyVarStoreId ();
}
@@ -1390,28 +1442,28 @@ VarCheckParseHiiPackage ( **/
VOID
VarCheckParseHiiDatabase (
- IN VOID *HiiDatabase,
- IN UINTN HiiDatabaseSize
+ IN VOID *HiiDatabase,
+ IN UINTN HiiDatabaseSize
)
{
- EFI_HII_PACKAGE_LIST_HEADER *HiiPackageListHeader;
- EFI_HII_PACKAGE_HEADER *HiiPackageHeader;
+ EFI_HII_PACKAGE_LIST_HEADER *HiiPackageListHeader;
+ EFI_HII_PACKAGE_HEADER *HiiPackageHeader;
- HiiPackageListHeader = (EFI_HII_PACKAGE_LIST_HEADER *) HiiDatabase;
+ HiiPackageListHeader = (EFI_HII_PACKAGE_LIST_HEADER *)HiiDatabase;
- while ((UINTN) HiiPackageListHeader < ((UINTN) HiiDatabase + HiiDatabaseSize)) {
- HiiPackageHeader = (EFI_HII_PACKAGE_HEADER *) (HiiPackageListHeader + 1);
+ while ((UINTN)HiiPackageListHeader < ((UINTN)HiiDatabase + HiiDatabaseSize)) {
+ HiiPackageHeader = (EFI_HII_PACKAGE_HEADER *)(HiiPackageListHeader + 1);
- while ((UINTN) HiiPackageHeader < ((UINTN) HiiPackageListHeader + HiiPackageListHeader->PackageLength)) {
+ while ((UINTN)HiiPackageHeader < ((UINTN)HiiPackageListHeader + HiiPackageListHeader->PackageLength)) {
//
// Parse Hii Package.
//
VarCheckParseHiiPackage (HiiPackageHeader, FALSE);
- HiiPackageHeader = (EFI_HII_PACKAGE_HEADER *) ((UINTN) HiiPackageHeader + HiiPackageHeader->Length);
+ HiiPackageHeader = (EFI_HII_PACKAGE_HEADER *)((UINTN)HiiPackageHeader + HiiPackageHeader->Length);
}
- HiiPackageListHeader = (EFI_HII_PACKAGE_LIST_HEADER *) ((UINTN) HiiPackageListHeader + HiiPackageListHeader->PackageLength);
+ HiiPackageListHeader = (EFI_HII_PACKAGE_LIST_HEADER *)((UINTN)HiiPackageListHeader + HiiPackageListHeader->PackageLength);
}
}
@@ -1424,9 +1476,9 @@ DestroyHiiVariableNode ( VOID
)
{
- VAR_CHECK_HII_VARIABLE_NODE *HiiVariableNode;
- LIST_ENTRY *HiiVariableLink;
- UINTN Index;
+ VAR_CHECK_HII_VARIABLE_NODE *HiiVariableNode;
+ LIST_ENTRY *HiiVariableLink;
+ UINTN Index;
while (mVarCheckHiiList.ForwardLink != &mVarCheckHiiList) {
HiiVariableLink = mVarCheckHiiList.ForwardLink;
@@ -1437,11 +1489,12 @@ DestroyHiiVariableNode ( //
// Free the allocated buffer.
//
- for (Index = 0; Index < HiiVariableNode->HiiVariable->Size * (UINTN) 8; Index++) {
+ for (Index = 0; Index < HiiVariableNode->HiiVariable->Size * (UINTN)8; Index++) {
if (HiiVariableNode->HiiQuestionArray[Index] != NULL) {
InternalVarCheckFreePool (HiiVariableNode->HiiQuestionArray[Index]);
}
}
+
InternalVarCheckFreePool (HiiVariableNode->HiiQuestionArray);
InternalVarCheckFreePool (HiiVariableNode->HiiVariable);
InternalVarCheckFreePool (HiiVariableNode);
@@ -1461,13 +1514,13 @@ BuildVarCheckHiiBin ( OUT UINTN *Size
)
{
- VAR_CHECK_HII_VARIABLE_NODE *HiiVariableNode;
- LIST_ENTRY *HiiVariableLink;
- UINTN Index;
- VOID *Data;
- UINT8 *Ptr;
- UINT32 BinSize;
- UINT32 HiiVariableLength;
+ VAR_CHECK_HII_VARIABLE_NODE *HiiVariableNode;
+ LIST_ENTRY *HiiVariableLink;
+ UINTN Index;
+ VOID *Data;
+ UINT8 *Ptr;
+ UINT32 BinSize;
+ UINT32 HiiVariableLength;
//
// Get Size
@@ -1475,28 +1528,29 @@ BuildVarCheckHiiBin ( BinSize = 0;
for (HiiVariableLink = mVarCheckHiiList.ForwardLink
- ;HiiVariableLink != &mVarCheckHiiList
- ;HiiVariableLink = HiiVariableLink->ForwardLink) {
+ ; HiiVariableLink != &mVarCheckHiiList
+ ; HiiVariableLink = HiiVariableLink->ForwardLink)
+ {
//
// For Hii Variable header align.
//
- BinSize = (UINT32) HEADER_ALIGN (BinSize);
+ BinSize = (UINT32)HEADER_ALIGN (BinSize);
- HiiVariableNode = VAR_CHECK_HII_VARIABLE_FROM_LINK (HiiVariableLink);
+ HiiVariableNode = VAR_CHECK_HII_VARIABLE_FROM_LINK (HiiVariableLink);
HiiVariableLength = HiiVariableNode->HiiVariable->HeaderLength;
- for (Index = 0; Index < HiiVariableNode->HiiVariable->Size * (UINTN) 8; Index++) {
+ for (Index = 0; Index < HiiVariableNode->HiiVariable->Size * (UINTN)8; Index++) {
if (HiiVariableNode->HiiQuestionArray[Index] != NULL) {
//
// For Hii Question header align.
//
- HiiVariableLength = (UINT32) HEADER_ALIGN (HiiVariableLength);
+ HiiVariableLength = (UINT32)HEADER_ALIGN (HiiVariableLength);
HiiVariableLength += HiiVariableNode->HiiQuestionArray[Index]->Length;
}
}
HiiVariableNode->HiiVariable->Length = HiiVariableLength;
- BinSize += HiiVariableLength;
+ BinSize += HiiVariableLength;
}
DEBUG ((DEBUG_INFO, "VarCheckHiiBin - size = 0x%x\n", BinSize));
@@ -1515,7 +1569,7 @@ BuildVarCheckHiiBin ( //
// Make sure the allocated buffer for VarCheckHiiBin at required alignment.
//
- ASSERT ((((UINTN) Data) & (HEADER_ALIGNMENT - 1)) == 0);
+ ASSERT ((((UINTN)Data) & (HEADER_ALIGNMENT - 1)) == 0);
DEBUG ((DEBUG_INFO, "VarCheckHiiBin - built at 0x%x\n", Data));
//
@@ -1523,23 +1577,24 @@ BuildVarCheckHiiBin ( //
Ptr = Data;
for (HiiVariableLink = mVarCheckHiiList.ForwardLink
- ;HiiVariableLink != &mVarCheckHiiList
- ;HiiVariableLink = HiiVariableLink->ForwardLink) {
+ ; HiiVariableLink != &mVarCheckHiiList
+ ; HiiVariableLink = HiiVariableLink->ForwardLink)
+ {
//
// For Hii Variable header align.
//
- Ptr = (UINT8 *) HEADER_ALIGN (Ptr);
+ Ptr = (UINT8 *)HEADER_ALIGN (Ptr);
HiiVariableNode = VAR_CHECK_HII_VARIABLE_FROM_LINK (HiiVariableLink);
CopyMem (Ptr, HiiVariableNode->HiiVariable, HiiVariableNode->HiiVariable->HeaderLength);
Ptr += HiiVariableNode->HiiVariable->HeaderLength;
- for (Index = 0; Index < HiiVariableNode->HiiVariable->Size * (UINTN) 8; Index++) {
+ for (Index = 0; Index < HiiVariableNode->HiiVariable->Size * (UINTN)8; Index++) {
if (HiiVariableNode->HiiQuestionArray[Index] != NULL) {
//
// For Hii Question header align.
//
- Ptr = (UINT8 *) HEADER_ALIGN (Ptr);
+ Ptr = (UINT8 *)HEADER_ALIGN (Ptr);
CopyMem (Ptr, HiiVariableNode->HiiQuestionArray[Index], HiiVariableNode->HiiQuestionArray[Index]->Length);
Ptr += HiiVariableNode->HiiQuestionArray[Index]->Length;
}
@@ -1574,10 +1629,9 @@ VarCheckHiiGen ( InternalVarCheckFreePool (mVarName);
}
-#ifdef DUMP_VAR_CHECK_HII
+ #ifdef DUMP_VAR_CHECK_HII
DEBUG_CODE (
DumpVarCheckHii (mVarCheckHiiBin, mVarCheckHiiBinSize);
- );
-#endif
+ );
+ #endif
}
-
diff --git a/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGen.h b/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGen.h index 02783c4312..c70bf726cd 100644 --- a/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGen.h +++ b/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGen.h @@ -19,7 +19,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent **/
VOID
DumpHiiPackage (
- IN VOID *HiiPackage
+ IN VOID *HiiPackage
);
/**
@@ -31,8 +31,8 @@ DumpHiiPackage ( **/
VOID
DumpHiiDatabase (
- IN VOID *HiiDatabase,
- IN UINTN HiiDatabaseSize
+ IN VOID *HiiDatabase,
+ IN UINTN HiiDatabaseSize
);
/**
@@ -50,7 +50,7 @@ DumpHiiDatabase ( **/
VOID *
InternalVarCheckAllocateZeroPool (
- IN UINTN AllocationSize
+ IN UINTN AllocationSize
);
/**
@@ -70,7 +70,7 @@ InternalVarCheckAllocateZeroPool ( VOID
EFIAPI
InternalVarCheckFreePool (
- IN VOID *Buffer
+ IN VOID *Buffer
);
/**
@@ -82,8 +82,8 @@ InternalVarCheckFreePool ( **/
VOID
VarCheckParseHiiPackage (
- IN VOID *HiiPackage,
- IN BOOLEAN FromFv
+ IN VOID *HiiPackage,
+ IN BOOLEAN FromFv
);
/**
@@ -95,8 +95,8 @@ VarCheckParseHiiPackage ( **/
VOID
VarCheckParseHiiDatabase (
- IN VOID *HiiDatabase,
- IN UINTN HiiDatabaseSize
+ IN VOID *HiiDatabase,
+ IN UINTN HiiDatabaseSize
);
/**
diff --git a/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGenFromFv.c b/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGenFromFv.c index 6bac4bce9d..562f5a02f6 100644 --- a/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGenFromFv.c +++ b/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGenFromFv.c @@ -12,26 +12,26 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #define EFI_VFR_ATTRACT_GUID \
{ 0xd0bc7cb4, 0x6a47, 0x495f, { 0xaa, 0x11, 0x71, 0x7, 0x46, 0xda, 0x6, 0xa2 } }
-EFI_GUID gVfrArrayAttractGuid = EFI_VFR_ATTRACT_GUID;
+EFI_GUID gVfrArrayAttractGuid = EFI_VFR_ATTRACT_GUID;
#define ALL_FF_GUID \
{ 0xFFFFFFFF, 0xFFFF, 0xFFFF, { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF } }
-EFI_GUID mAllFfGuid = ALL_FF_GUID;
+EFI_GUID mAllFfGuid = ALL_FF_GUID;
-#define VAR_CHECK_VFR_DRIVER_INFO_SIGNATURE SIGNATURE_32 ('V', 'D', 'R', 'I')
+#define VAR_CHECK_VFR_DRIVER_INFO_SIGNATURE SIGNATURE_32 ('V', 'D', 'R', 'I')
typedef struct {
- UINTN Signature;
- LIST_ENTRY Link;
- EFI_GUID *DriverGuid;
+ UINTN Signature;
+ LIST_ENTRY Link;
+ EFI_GUID *DriverGuid;
} VAR_CHECK_VFR_DRIVER_INFO;
-LIST_ENTRY mVfrDriverList = INITIALIZE_LIST_HEAD_VARIABLE (mVfrDriverList);
+LIST_ENTRY mVfrDriverList = INITIALIZE_LIST_HEAD_VARIABLE (mVfrDriverList);
#define VAR_CHECK_VFR_DRIVER_INFO_FROM_LINK(a) CR (a, VAR_CHECK_VFR_DRIVER_INFO, Link, VAR_CHECK_VFR_DRIVER_INFO_SIGNATURE)
-#define MAX_MATCH_GUID_NUM 100
+#define MAX_MATCH_GUID_NUM 100
/**
Get the address by Guid.
@@ -51,17 +51,17 @@ LIST_ENTRY mVfrDriverList = INITIALIZE_LIST_HEAD_VARIABLE ( **/
EFI_STATUS
GetAddressByGuid (
- IN VOID *Ffs,
- IN EFI_GUID *Guid,
- IN UINTN Length,
- OUT UINTN **Offset,
- OUT UINT8 *NumOfMatchingGuid
+ IN VOID *Ffs,
+ IN EFI_GUID *Guid,
+ IN UINTN Length,
+ OUT UINTN **Offset,
+ OUT UINT8 *NumOfMatchingGuid
)
{
- UINTN LoopControl;
- BOOLEAN Found;
+ UINTN LoopControl;
+ BOOLEAN Found;
- if((Ffs == NULL) || (Guid == NULL) || (Length == 0)){
+ if ((Ffs == NULL) || (Guid == NULL) || (Length == 0)) {
return EFI_NOT_FOUND;
}
@@ -71,7 +71,7 @@ GetAddressByGuid ( Found = FALSE;
for (LoopControl = 0; LoopControl < Length; LoopControl++) {
- if (CompareGuid (Guid, (EFI_GUID *) ((UINT8 *) Ffs + LoopControl))) {
+ if (CompareGuid (Guid, (EFI_GUID *)((UINT8 *)Ffs + LoopControl))) {
Found = TRUE;
//
// If NumOfMatchGuid or Offset are NULL, means user only want
@@ -82,6 +82,7 @@ GetAddressByGuid ( *Offset = InternalVarCheckAllocateZeroPool (sizeof (UINTN) * MAX_MATCH_GUID_NUM);
ASSERT (*Offset != NULL);
}
+
*(*Offset + *NumOfMatchingGuid) = LoopControl + sizeof (EFI_GUID);
(*NumOfMatchingGuid)++;
} else {
@@ -110,20 +111,21 @@ GetAddressByGuid ( **/
EFI_STATUS
SearchVfrBinInFfs (
- IN VOID *Ffs,
- IN VOID *EfiAddr,
- IN UINTN Length,
- OUT UINTN **Offset,
- OUT UINT8 *NumOfMatchingOffset
+ IN VOID *Ffs,
+ IN VOID *EfiAddr,
+ IN UINTN Length,
+ OUT UINTN **Offset,
+ OUT UINT8 *NumOfMatchingOffset
)
{
- UINTN Index;
- EFI_STATUS Status;
- UINTN VirOffValue;
+ UINTN Index;
+ EFI_STATUS Status;
+ UINTN VirOffValue;
if ((Ffs == NULL) || (Offset == NULL)) {
return EFI_NOT_FOUND;
}
+
Status = GetAddressByGuid (
Ffs,
&gVfrArrayAttractGuid,
@@ -139,11 +141,11 @@ SearchVfrBinInFfs ( //
// Got the virOffset after the GUID
//
- VirOffValue = *(UINTN *) ((UINTN) Ffs + *(*Offset + Index));
+ VirOffValue = *(UINTN *)((UINTN)Ffs + *(*Offset + Index));
//
// Transfer the offset to the VA address. One modules may own multiple VfrBin address.
//
- *(*Offset + Index) = (UINTN) EfiAddr + VirOffValue;
+ *(*Offset + Index) = (UINTN)EfiAddr + VirOffValue;
}
return Status;
@@ -164,17 +166,17 @@ ParseFfs ( IN EFI_GUID *DriverGuid
)
{
- EFI_STATUS Status;
- EFI_FV_FILETYPE FoundType;
- EFI_FV_FILE_ATTRIBUTES FileAttributes;
- UINT32 AuthenticationStatus;
- UINTN Size;
- VOID *Buffer;
- UINTN SectionSize;
- VOID *SectionBuffer;
- UINTN VfrBinIndex;
- UINT8 NumberofMatchingVfrBin;
- UINTN *VfrBinBaseAddress;
+ EFI_STATUS Status;
+ EFI_FV_FILETYPE FoundType;
+ EFI_FV_FILE_ATTRIBUTES FileAttributes;
+ UINT32 AuthenticationStatus;
+ UINTN Size;
+ VOID *Buffer;
+ UINTN SectionSize;
+ VOID *SectionBuffer;
+ UINTN VfrBinIndex;
+ UINT8 NumberofMatchingVfrBin;
+ UINTN *VfrBinBaseAddress;
Status = Fv2->ReadFile (
Fv2,
@@ -199,42 +201,42 @@ ParseFfs ( &Size,
&AuthenticationStatus
);
- if (!EFI_ERROR (Status)) {
- Status = SearchVfrBinInFfs (Buffer, 0, Size, &VfrBinBaseAddress, &NumberofMatchingVfrBin);
- if (!EFI_ERROR (Status)) {
- SectionBuffer = NULL;
- Status = Fv2->ReadSection (
- Fv2,
- DriverGuid,
- EFI_SECTION_PE32,
- 0, // Instance
- &SectionBuffer,
- &SectionSize,
- &AuthenticationStatus
- );
- if (!EFI_ERROR (Status)) {
- DEBUG ((DEBUG_INFO , "FfsNameGuid - %g\n", DriverGuid));
- DEBUG ((DEBUG_INFO , "NumberofMatchingVfrBin - 0x%02x\n", NumberofMatchingVfrBin));
-
- for (VfrBinIndex = 0; VfrBinIndex < NumberofMatchingVfrBin; VfrBinIndex++) {
-#ifdef DUMP_HII_DATA
- DEBUG_CODE (
- DumpHiiPackage ((UINT8 *) (UINTN) SectionBuffer + VfrBinBaseAddress[VfrBinIndex] + sizeof (UINT32));
- );
-#endif
- VarCheckParseHiiPackage ((UINT8 *) (UINTN) SectionBuffer + VfrBinBaseAddress[VfrBinIndex] + sizeof (UINT32), TRUE);
- }
-
- FreePool (SectionBuffer);
+ if (!EFI_ERROR (Status)) {
+ Status = SearchVfrBinInFfs (Buffer, 0, Size, &VfrBinBaseAddress, &NumberofMatchingVfrBin);
+ if (!EFI_ERROR (Status)) {
+ SectionBuffer = NULL;
+ Status = Fv2->ReadSection (
+ Fv2,
+ DriverGuid,
+ EFI_SECTION_PE32,
+ 0, // Instance
+ &SectionBuffer,
+ &SectionSize,
+ &AuthenticationStatus
+ );
+ if (!EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_INFO, "FfsNameGuid - %g\n", DriverGuid));
+ DEBUG ((DEBUG_INFO, "NumberofMatchingVfrBin - 0x%02x\n", NumberofMatchingVfrBin));
+
+ for (VfrBinIndex = 0; VfrBinIndex < NumberofMatchingVfrBin; VfrBinIndex++) {
+ #ifdef DUMP_HII_DATA
+ DEBUG_CODE (
+ DumpHiiPackage ((UINT8 *)(UINTN)SectionBuffer + VfrBinBaseAddress[VfrBinIndex] + sizeof (UINT32));
+ );
+ #endif
+ VarCheckParseHiiPackage ((UINT8 *)(UINTN)SectionBuffer + VfrBinBaseAddress[VfrBinIndex] + sizeof (UINT32), TRUE);
}
- InternalVarCheckFreePool (VfrBinBaseAddress);
+ FreePool (SectionBuffer);
}
- FreePool (Buffer);
+ InternalVarCheckFreePool (VfrBinBaseAddress);
}
- return TRUE;
+ FreePool (Buffer);
+ }
+
+ return TRUE;
}
/**
@@ -245,31 +247,31 @@ ParseFfs ( **/
VOID
ParseFv (
- IN BOOLEAN ScanAll
+ IN BOOLEAN ScanAll
)
{
- EFI_STATUS Status;
- EFI_HANDLE *HandleBuffer;
- UINTN HandleCount;
- UINTN Index;
- EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv2;
- VOID *Key;
- EFI_FV_FILETYPE FileType;
- EFI_GUID NameGuid;
- EFI_FV_FILE_ATTRIBUTES FileAttributes;
- UINTN Size;
- UINTN FfsIndex;
- VAR_CHECK_VFR_DRIVER_INFO *VfrDriverInfo;
- LIST_ENTRY *VfrDriverLink;
+ EFI_STATUS Status;
+ EFI_HANDLE *HandleBuffer;
+ UINTN HandleCount;
+ UINTN Index;
+ EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv2;
+ VOID *Key;
+ EFI_FV_FILETYPE FileType;
+ EFI_GUID NameGuid;
+ EFI_FV_FILE_ATTRIBUTES FileAttributes;
+ UINTN Size;
+ UINTN FfsIndex;
+ VAR_CHECK_VFR_DRIVER_INFO *VfrDriverInfo;
+ LIST_ENTRY *VfrDriverLink;
HandleBuffer = NULL;
- Status = gBS->LocateHandleBuffer (
- ByProtocol,
- &gEfiFirmwareVolume2ProtocolGuid,
- NULL,
- &HandleCount,
- &HandleBuffer
- );
+ Status = gBS->LocateHandleBuffer (
+ ByProtocol,
+ &gEfiFirmwareVolume2ProtocolGuid,
+ NULL,
+ &HandleCount,
+ &HandleBuffer
+ );
if (EFI_ERROR (Status)) {
return;
}
@@ -278,31 +280,32 @@ ParseFv ( // Search all FVs
//
for (Index = 0; Index < HandleCount; Index++) {
- DEBUG ((DEBUG_INFO , "FvIndex - %x\n", Index));
+ DEBUG ((DEBUG_INFO, "FvIndex - %x\n", Index));
Status = gBS->HandleProtocol (
HandleBuffer[Index],
&gEfiFirmwareVolume2ProtocolGuid,
- (VOID **) &Fv2
+ (VOID **)&Fv2
);
ASSERT_EFI_ERROR (Status);
DEBUG_CODE_BEGIN ();
- EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *Fvb2;
- EFI_PHYSICAL_ADDRESS FvAddress;
- UINT64 FvSize;
-
- Status = gBS->HandleProtocol (
- HandleBuffer[Index],
- &gEfiFirmwareVolumeBlock2ProtocolGuid,
- (VOID **) &Fvb2
- );
- ASSERT_EFI_ERROR (Status);
- Status = Fvb2->GetPhysicalAddress (Fvb2, &FvAddress);
- if (!EFI_ERROR (Status)) {
- DEBUG ((DEBUG_INFO , "FvAddress - 0x%08x\n", FvAddress));
- FvSize = ((EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) FvAddress)->FvLength;
- DEBUG ((DEBUG_INFO , "FvSize - 0x%08x\n", FvSize));
- }
+ EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *Fvb2;
+ EFI_PHYSICAL_ADDRESS FvAddress;
+ UINT64 FvSize;
+
+ Status = gBS->HandleProtocol (
+ HandleBuffer[Index],
+ &gEfiFirmwareVolumeBlock2ProtocolGuid,
+ (VOID **)&Fvb2
+ );
+ ASSERT_EFI_ERROR (Status);
+ Status = Fvb2->GetPhysicalAddress (Fvb2, &FvAddress);
+ if (!EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_INFO, "FvAddress - 0x%08x\n", FvAddress));
+ FvSize = ((EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)FvAddress)->FvLength;
+ DEBUG ((DEBUG_INFO, "FvSize - 0x%08x\n", FvSize));
+ }
+
DEBUG_CODE_END ();
if (ScanAll) {
@@ -314,14 +317,14 @@ ParseFv ( for (FfsIndex = 0; ; FfsIndex++) {
FileType = EFI_FV_FILETYPE_ALL;
- Status = Fv2->GetNextFile (
- Fv2,
- Key,
- &FileType,
- &NameGuid,
- &FileAttributes,
- &Size
- );
+ Status = Fv2->GetNextFile (
+ Fv2,
+ Key,
+ &FileType,
+ &NameGuid,
+ &FileAttributes,
+ &Size
+ );
if (EFI_ERROR (Status)) {
break;
}
@@ -360,19 +363,19 @@ ParseFv ( **/
VOID
CreateVfrDriverList (
- IN EFI_GUID *DriverGuidArray
+ IN EFI_GUID *DriverGuidArray
)
{
- UINTN Index;
- VAR_CHECK_VFR_DRIVER_INFO *VfrDriverInfo;
+ UINTN Index;
+ VAR_CHECK_VFR_DRIVER_INFO *VfrDriverInfo;
for (Index = 0; !IsZeroGuid (&DriverGuidArray[Index]); Index++) {
- DEBUG ((DEBUG_INFO , "CreateVfrDriverList: %g\n", &DriverGuidArray[Index]));
- VfrDriverInfo = InternalVarCheckAllocateZeroPool (sizeof (*VfrDriverInfo));
- ASSERT (VfrDriverInfo != NULL);
- VfrDriverInfo->Signature = VAR_CHECK_VFR_DRIVER_INFO_SIGNATURE;
- VfrDriverInfo->DriverGuid = &DriverGuidArray[Index];
- InsertTailList (&mVfrDriverList, &VfrDriverInfo->Link);
+ DEBUG ((DEBUG_INFO, "CreateVfrDriverList: %g\n", &DriverGuidArray[Index]));
+ VfrDriverInfo = InternalVarCheckAllocateZeroPool (sizeof (*VfrDriverInfo));
+ ASSERT (VfrDriverInfo != NULL);
+ VfrDriverInfo->Signature = VAR_CHECK_VFR_DRIVER_INFO_SIGNATURE;
+ VfrDriverInfo->DriverGuid = &DriverGuidArray[Index];
+ InsertTailList (&mVfrDriverList, &VfrDriverInfo->Link);
}
}
@@ -385,8 +388,8 @@ DestroyVfrDriverList ( VOID
)
{
- VAR_CHECK_VFR_DRIVER_INFO *VfrDriverInfo;
- LIST_ENTRY *VfrDriverLink;
+ VAR_CHECK_VFR_DRIVER_INFO *VfrDriverInfo;
+ LIST_ENTRY *VfrDriverLink;
while (mVfrDriverList.ForwardLink != &mVfrDriverList) {
VfrDriverLink = mVfrDriverList.ForwardLink;
@@ -405,15 +408,15 @@ VarCheckHiiGenFromFv ( VOID
)
{
- EFI_GUID *DriverGuidArray;
- BOOLEAN ScanAll;
+ EFI_GUID *DriverGuidArray;
+ BOOLEAN ScanAll;
- DEBUG ((DEBUG_INFO , "VarCheckHiiGenDxeFromFv\n"));
+ DEBUG ((DEBUG_INFO, "VarCheckHiiGenDxeFromFv\n"));
//
// Get vfr driver guid array from PCD.
//
- DriverGuidArray = (EFI_GUID *) PcdGetPtr (PcdVarCheckVfrDriverGuidArray);
+ DriverGuidArray = (EFI_GUID *)PcdGetPtr (PcdVarCheckVfrDriverGuidArray);
if (IsZeroGuid (&DriverGuidArray[0])) {
//
diff --git a/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGenFromHii.c b/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGenFromHii.c index b113ff8fa8..27d10f8bc6 100644 --- a/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGenFromHii.c +++ b/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiGenFromHii.c @@ -17,16 +17,16 @@ VarCheckHiiGenFromHiiDatabase ( VOID
)
{
- EFI_STATUS Status;
- UINTN BufferSize;
- VOID *Buffer;
- EFI_PHYSICAL_ADDRESS BufferAddress;
- EFI_HII_DATABASE_PROTOCOL *HiiDatabase;
+ EFI_STATUS Status;
+ UINTN BufferSize;
+ VOID *Buffer;
+ EFI_PHYSICAL_ADDRESS BufferAddress;
+ EFI_HII_DATABASE_PROTOCOL *HiiDatabase;
//
// Locate HII Database protocol
//
- Status = gBS->LocateProtocol (&gEfiHiiDatabaseProtocolGuid, NULL, (VOID **) &HiiDatabase);
+ Status = gBS->LocateProtocol (&gEfiHiiDatabaseProtocolGuid, NULL, (VOID **)&HiiDatabase);
if (EFI_ERROR (Status)) {
return;
}
@@ -36,15 +36,15 @@ VarCheckHiiGenFromHiiDatabase ( // Should fail with EFI_BUFFER_TOO_SMALL.
//
BufferSize = 0;
- Buffer = NULL;
- Status = HiiDatabase->ExportPackageLists (HiiDatabase, 0, &BufferSize, Buffer);
+ Buffer = NULL;
+ Status = HiiDatabase->ExportPackageLists (HiiDatabase, 0, &BufferSize, Buffer);
if (Status == EFI_BUFFER_TOO_SMALL) {
//
// Allocate buffer to hold the HII Database.
//
Status = gBS->AllocatePages (AllocateAnyPages, EfiBootServicesData, EFI_SIZE_TO_PAGES (BufferSize), &BufferAddress);
ASSERT_EFI_ERROR (Status);
- Buffer = (VOID *) (UINTN) BufferAddress;
+ Buffer = (VOID *)(UINTN)BufferAddress;
//
// Export HII Database into the buffer.
@@ -52,13 +52,13 @@ VarCheckHiiGenFromHiiDatabase ( Status = HiiDatabase->ExportPackageLists (HiiDatabase, 0, &BufferSize, Buffer);
ASSERT_EFI_ERROR (Status);
- DEBUG ((DEBUG_INFO , "VarCheckHiiGenDxeFromHii - HII Database exported at 0x%x, size = 0x%x\n", Buffer, BufferSize));
+ DEBUG ((DEBUG_INFO, "VarCheckHiiGenDxeFromHii - HII Database exported at 0x%x, size = 0x%x\n", Buffer, BufferSize));
-#ifdef DUMP_HII_DATA
+ #ifdef DUMP_HII_DATA
DEBUG_CODE (
DumpHiiDatabase (Buffer, BufferSize);
);
-#endif
+ #endif
VarCheckParseHiiDatabase (Buffer, BufferSize);
diff --git a/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiLibNullClass.c b/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiLibNullClass.c index 0f3c0f5311..ee2d98c7d1 100644 --- a/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiLibNullClass.c +++ b/MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiLibNullClass.c @@ -8,7 +8,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include "VarCheckHii.h"
-GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 mVarCheckHiiHex[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
+GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 mVarCheckHiiHex[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
/**
Dump some hexadecimal data.
@@ -21,21 +21,21 @@ GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 mVarCheckHiiHex[] = {'0', '1', '2', '3 **/
VOID
VarCheckHiiInternalDumpHex (
- IN UINTN Indent,
- IN UINTN Offset,
- IN UINTN DataSize,
- IN VOID *UserData
+ IN UINTN Indent,
+ IN UINTN Offset,
+ IN UINTN DataSize,
+ IN VOID *UserData
)
{
- UINT8 *Data;
+ UINT8 *Data;
- CHAR8 Val[50];
+ CHAR8 Val[50];
- CHAR8 Str[20];
+ CHAR8 Str[20];
- UINT8 TempByte;
- UINTN Size;
- UINTN Index;
+ UINT8 TempByte;
+ UINTN Size;
+ UINTN Index;
Data = UserData;
while (DataSize != 0) {
@@ -45,19 +45,19 @@ VarCheckHiiInternalDumpHex ( }
for (Index = 0; Index < Size; Index += 1) {
- TempByte = Data[Index];
- Val[Index * 3 + 0] = mVarCheckHiiHex[TempByte >> 4];
- Val[Index * 3 + 1] = mVarCheckHiiHex[TempByte & 0xF];
- Val[Index * 3 + 2] = (CHAR8) ((Index == 7) ? '-' : ' ');
- Str[Index] = (CHAR8) ((TempByte < ' ' || TempByte > 'z') ? '.' : TempByte);
+ TempByte = Data[Index];
+ Val[Index * 3 + 0] = mVarCheckHiiHex[TempByte >> 4];
+ Val[Index * 3 + 1] = mVarCheckHiiHex[TempByte & 0xF];
+ Val[Index * 3 + 2] = (CHAR8)((Index == 7) ? '-' : ' ');
+ Str[Index] = (CHAR8)((TempByte < ' ' || TempByte > 'z') ? '.' : TempByte);
}
- Val[Index * 3] = 0;
- Str[Index] = 0;
- DEBUG ((DEBUG_INFO , "%*a%08X: %-48a *%a*\r\n", Indent, "", Offset, Val, Str));
+ Val[Index * 3] = 0;
+ Str[Index] = 0;
+ DEBUG ((DEBUG_INFO, "%*a%08X: %-48a *%a*\r\n", Indent, "", Offset, Val, Str));
- Data += Size;
- Offset += Size;
+ Data += Size;
+ Offset += Size;
DataSize -= Size;
}
}
@@ -80,35 +80,35 @@ VarCheckHiiQuestion ( IN UINTN DataSize
)
{
- UINT64 OneData;
- UINT64 Minimum;
- UINT64 Maximum;
- UINT64 OneValue;
- UINT8 *Ptr;
- UINT8 Index;
- UINT8 MaxContainers;
- UINT8 StartBit;
- UINT8 EndBit;
- UINT8 TotalBits;
- UINT16 VarOffsetByteLevel;
- UINT8 StorageWidthByteLevel;
+ UINT64 OneData;
+ UINT64 Minimum;
+ UINT64 Maximum;
+ UINT64 OneValue;
+ UINT8 *Ptr;
+ UINT8 Index;
+ UINT8 MaxContainers;
+ UINT8 StartBit;
+ UINT8 EndBit;
+ UINT8 TotalBits;
+ UINT16 VarOffsetByteLevel;
+ UINT8 StorageWidthByteLevel;
if (HiiQuestion->BitFieldStore) {
VarOffsetByteLevel = HiiQuestion->VarOffset / 8;
TotalBits = HiiQuestion->VarOffset % 8 + HiiQuestion->StorageWidth;
- StorageWidthByteLevel = (TotalBits % 8 == 0 ? TotalBits / 8: TotalBits / 8 + 1);
+ StorageWidthByteLevel = (TotalBits % 8 == 0 ? TotalBits / 8 : TotalBits / 8 + 1);
} else {
VarOffsetByteLevel = HiiQuestion->VarOffset;
StorageWidthByteLevel = HiiQuestion->StorageWidth;
}
- if (((UINT32) VarOffsetByteLevel + StorageWidthByteLevel) > DataSize) {
- DEBUG ((DEBUG_INFO , "VarCheckHiiQuestion fail: (VarOffset(0x%04x) + StorageWidth(0x%02x)) > Size(0x%x)\n", VarOffsetByteLevel, StorageWidthByteLevel, DataSize));
+ if (((UINT32)VarOffsetByteLevel + StorageWidthByteLevel) > DataSize) {
+ DEBUG ((DEBUG_INFO, "VarCheckHiiQuestion fail: (VarOffset(0x%04x) + StorageWidth(0x%02x)) > Size(0x%x)\n", VarOffsetByteLevel, StorageWidthByteLevel, DataSize));
return FALSE;
}
OneData = 0;
- CopyMem (&OneData, (UINT8 *) Data + VarOffsetByteLevel, StorageWidthByteLevel);
+ CopyMem (&OneData, (UINT8 *)Data + VarOffsetByteLevel, StorageWidthByteLevel);
if (HiiQuestion->BitFieldStore) {
//
// Get the value from the bit field.
@@ -120,8 +120,8 @@ VarCheckHiiQuestion ( switch (HiiQuestion->OpCode) {
case EFI_IFR_ONE_OF_OP:
- Ptr = (UINT8 *) ((VAR_CHECK_HII_QUESTION_ONEOF *) HiiQuestion + 1);
- while ((UINTN) Ptr < (UINTN) HiiQuestion + HiiQuestion->Length) {
+ Ptr = (UINT8 *)((VAR_CHECK_HII_QUESTION_ONEOF *)HiiQuestion + 1);
+ while ((UINTN)Ptr < (UINTN)HiiQuestion + HiiQuestion->Length) {
OneValue = 0;
if (HiiQuestion->BitFieldStore) {
//
@@ -131,40 +131,49 @@ VarCheckHiiQuestion ( } else {
CopyMem (&OneValue, Ptr, HiiQuestion->StorageWidth);
}
+
if (OneData == OneValue) {
//
// Match
//
break;
}
+
if (HiiQuestion->BitFieldStore) {
Ptr += sizeof (UINT32);
} else {
Ptr += HiiQuestion->StorageWidth;
}
}
- if ((UINTN) Ptr >= ((UINTN) HiiQuestion + HiiQuestion->Length)) {
+
+ if ((UINTN)Ptr >= ((UINTN)HiiQuestion + HiiQuestion->Length)) {
//
// No match
//
- DEBUG ((DEBUG_INFO , "VarCheckHiiQuestion fail: OneOf mismatch (0x%lx)\n", OneData));
- DEBUG_CODE (VarCheckHiiInternalDumpHex (2, 0, HiiQuestion->Length, (UINT8 *) HiiQuestion););
+ DEBUG ((DEBUG_INFO, "VarCheckHiiQuestion fail: OneOf mismatch (0x%lx)\n", OneData));
+ DEBUG_CODE (
+ VarCheckHiiInternalDumpHex (2, 0, HiiQuestion->Length, (UINT8 *)HiiQuestion);
+ );
return FALSE;
}
+
break;
case EFI_IFR_CHECKBOX_OP:
if ((OneData != 0) && (OneData != 1)) {
- DEBUG ((DEBUG_INFO , "VarCheckHiiQuestion fail: CheckBox mismatch (0x%lx)\n", OneData));
- DEBUG_CODE (VarCheckHiiInternalDumpHex (2, 0, HiiQuestion->Length, (UINT8 *) HiiQuestion););
+ DEBUG ((DEBUG_INFO, "VarCheckHiiQuestion fail: CheckBox mismatch (0x%lx)\n", OneData));
+ DEBUG_CODE (
+ VarCheckHiiInternalDumpHex (2, 0, HiiQuestion->Length, (UINT8 *)HiiQuestion);
+ );
return FALSE;
}
+
break;
case EFI_IFR_NUMERIC_OP:
Minimum = 0;
Maximum = 0;
- Ptr = (UINT8 *) ((VAR_CHECK_HII_QUESTION_NUMERIC *) HiiQuestion + 1);
+ Ptr = (UINT8 *)((VAR_CHECK_HII_QUESTION_NUMERIC *)HiiQuestion + 1);
if (HiiQuestion->BitFieldStore) {
//
// For Numeric stored in bit field, the value of Maximum/Minimum are saved as UINT32 type.
@@ -184,21 +193,25 @@ VarCheckHiiQuestion ( // No need to check Step, because it is ONLY for UI.
//
if ((OneData < Minimum) || (OneData > Maximum)) {
- DEBUG ((DEBUG_INFO , "VarCheckHiiQuestion fail: Numeric mismatch (0x%lx)\n", OneData));
- DEBUG_CODE (VarCheckHiiInternalDumpHex (2, 0, HiiQuestion->Length, (UINT8 *) HiiQuestion););
+ DEBUG ((DEBUG_INFO, "VarCheckHiiQuestion fail: Numeric mismatch (0x%lx)\n", OneData));
+ DEBUG_CODE (
+ VarCheckHiiInternalDumpHex (2, 0, HiiQuestion->Length, (UINT8 *)HiiQuestion);
+ );
return FALSE;
}
+
break;
case EFI_IFR_ORDERED_LIST_OP:
- MaxContainers = ((VAR_CHECK_HII_QUESTION_ORDEREDLIST *) HiiQuestion)->MaxContainers;
- if (((UINT32) HiiQuestion->VarOffset + HiiQuestion->StorageWidth * MaxContainers) > DataSize) {
- DEBUG ((DEBUG_INFO , "VarCheckHiiQuestion fail: (VarOffset(0x%04x) + StorageWidth(0x%02x) * MaxContainers(0x%02x)) > Size(0x%x)\n", HiiQuestion->VarOffset, HiiQuestion->StorageWidth, MaxContainers, DataSize));
+ MaxContainers = ((VAR_CHECK_HII_QUESTION_ORDEREDLIST *)HiiQuestion)->MaxContainers;
+ if (((UINT32)HiiQuestion->VarOffset + HiiQuestion->StorageWidth * MaxContainers) > DataSize) {
+ DEBUG ((DEBUG_INFO, "VarCheckHiiQuestion fail: (VarOffset(0x%04x) + StorageWidth(0x%02x) * MaxContainers(0x%02x)) > Size(0x%x)\n", HiiQuestion->VarOffset, HiiQuestion->StorageWidth, MaxContainers, DataSize));
return FALSE;
}
+
for (Index = 0; Index < MaxContainers; Index++) {
OneData = 0;
- CopyMem (&OneData, (UINT8 *) Data + HiiQuestion->VarOffset + HiiQuestion->StorageWidth * Index, HiiQuestion->StorageWidth);
+ CopyMem (&OneData, (UINT8 *)Data + HiiQuestion->VarOffset + HiiQuestion->StorageWidth * Index, HiiQuestion->StorageWidth);
if (OneData == 0) {
//
// The value of 0 is used to determine if a particular "slot" in the array is empty.
@@ -206,8 +219,8 @@ VarCheckHiiQuestion ( continue;
}
- Ptr = (UINT8 *) ((VAR_CHECK_HII_QUESTION_ORDEREDLIST *) HiiQuestion + 1);
- while ((UINTN) Ptr < ((UINTN) HiiQuestion + HiiQuestion->Length)) {
+ Ptr = (UINT8 *)((VAR_CHECK_HII_QUESTION_ORDEREDLIST *)HiiQuestion + 1);
+ while ((UINTN)Ptr < ((UINTN)HiiQuestion + HiiQuestion->Length)) {
OneValue = 0;
CopyMem (&OneValue, Ptr, HiiQuestion->StorageWidth);
if (OneData == OneValue) {
@@ -216,18 +229,25 @@ VarCheckHiiQuestion ( //
break;
}
+
Ptr += HiiQuestion->StorageWidth;
}
- if ((UINTN) Ptr >= ((UINTN) HiiQuestion + HiiQuestion->Length)) {
+
+ if ((UINTN)Ptr >= ((UINTN)HiiQuestion + HiiQuestion->Length)) {
//
// No match
//
- DEBUG ((DEBUG_INFO , "VarCheckHiiQuestion fail: OrderedList mismatch\n"));
- DEBUG_CODE (VarCheckHiiInternalDumpHex (2, 0, HiiQuestion->StorageWidth * MaxContainers, (UINT8 *) Data + HiiQuestion->VarOffset););
- DEBUG_CODE (VarCheckHiiInternalDumpHex (2, 0, HiiQuestion->Length, (UINT8 *) HiiQuestion););
+ DEBUG ((DEBUG_INFO, "VarCheckHiiQuestion fail: OrderedList mismatch\n"));
+ DEBUG_CODE (
+ VarCheckHiiInternalDumpHex (2, 0, HiiQuestion->StorageWidth * MaxContainers, (UINT8 *)Data + HiiQuestion->VarOffset);
+ );
+ DEBUG_CODE (
+ VarCheckHiiInternalDumpHex (2, 0, HiiQuestion->Length, (UINT8 *)HiiQuestion);
+ );
return FALSE;
}
}
+
break;
default:
@@ -238,8 +258,8 @@ VarCheckHiiQuestion ( return TRUE;
}
-VAR_CHECK_HII_VARIABLE_HEADER *mVarCheckHiiBin = NULL;
-UINTN mVarCheckHiiBinSize = 0;
+VAR_CHECK_HII_VARIABLE_HEADER *mVarCheckHiiBin = NULL;
+UINTN mVarCheckHiiBinSize = 0;
/**
SetVariable check handler HII.
@@ -257,15 +277,15 @@ UINTN mVarCheckHiiBinSize = 0; EFI_STATUS
EFIAPI
SetVariableCheckHandlerHii (
- IN CHAR16 *VariableName,
- IN EFI_GUID *VendorGuid,
- IN UINT32 Attributes,
- IN UINTN DataSize,
- IN VOID *Data
+ IN CHAR16 *VariableName,
+ IN EFI_GUID *VendorGuid,
+ IN UINT32 Attributes,
+ IN UINTN DataSize,
+ IN VOID *Data
)
{
- VAR_CHECK_HII_VARIABLE_HEADER *HiiVariable;
- VAR_CHECK_HII_QUESTION_HEADER *HiiQuestion;
+ VAR_CHECK_HII_VARIABLE_HEADER *HiiVariable;
+ VAR_CHECK_HII_QUESTION_HEADER *HiiQuestion;
if (mVarCheckHiiBin == NULL) {
return EFI_SUCCESS;
@@ -281,14 +301,15 @@ SetVariableCheckHandlerHii ( //
// For Hii Variable header align.
//
- HiiVariable = (VAR_CHECK_HII_VARIABLE_HEADER *) HEADER_ALIGN (mVarCheckHiiBin);
- while ((UINTN) HiiVariable < ((UINTN) mVarCheckHiiBin + mVarCheckHiiBinSize)) {
- if ((StrCmp ((CHAR16 *) (HiiVariable + 1), VariableName) == 0) &&
- (CompareGuid (&HiiVariable->Guid, VendorGuid))) {
+ HiiVariable = (VAR_CHECK_HII_VARIABLE_HEADER *)HEADER_ALIGN (mVarCheckHiiBin);
+ while ((UINTN)HiiVariable < ((UINTN)mVarCheckHiiBin + mVarCheckHiiBinSize)) {
+ if ((StrCmp ((CHAR16 *)(HiiVariable + 1), VariableName) == 0) &&
+ (CompareGuid (&HiiVariable->Guid, VendorGuid)))
+ {
//
// Found the Hii Variable that could be used to do check.
//
- DEBUG ((DEBUG_INFO , "VarCheckHiiVariable - %s:%g with Attributes = 0x%08x Size = 0x%x\n", VariableName, VendorGuid, Attributes, DataSize));
+ DEBUG ((DEBUG_INFO, "VarCheckHiiVariable - %s:%g with Attributes = 0x%08x Size = 0x%x\n", VariableName, VendorGuid, Attributes, DataSize));
if (HiiVariable->Attributes != Attributes) {
DEBUG ((DEBUG_INFO, "VarCheckHiiVariable fail for Attributes - 0x%08x\n", HiiVariable->Attributes));
return EFI_SECURITY_VIOLATION;
@@ -308,24 +329,26 @@ SetVariableCheckHandlerHii ( // Do the check.
// For Hii Question header align.
//
- HiiQuestion = (VAR_CHECK_HII_QUESTION_HEADER *) HEADER_ALIGN (((UINTN) HiiVariable + HiiVariable->HeaderLength));
- while ((UINTN) HiiQuestion < ((UINTN) HiiVariable + HiiVariable->Length)) {
+ HiiQuestion = (VAR_CHECK_HII_QUESTION_HEADER *)HEADER_ALIGN (((UINTN)HiiVariable + HiiVariable->HeaderLength));
+ while ((UINTN)HiiQuestion < ((UINTN)HiiVariable + HiiVariable->Length)) {
if (!VarCheckHiiQuestion (HiiQuestion, Data, DataSize)) {
return EFI_SECURITY_VIOLATION;
}
+
//
// For Hii Question header align.
//
- HiiQuestion = (VAR_CHECK_HII_QUESTION_HEADER *) HEADER_ALIGN (((UINTN) HiiQuestion + HiiQuestion->Length));
+ HiiQuestion = (VAR_CHECK_HII_QUESTION_HEADER *)HEADER_ALIGN (((UINTN)HiiQuestion + HiiQuestion->Length));
}
DEBUG ((DEBUG_INFO, "VarCheckHiiVariable - ALL CHECK PASS!\n"));
return EFI_SUCCESS;
}
+
//
// For Hii Variable header align.
//
- HiiVariable = (VAR_CHECK_HII_VARIABLE_HEADER *) HEADER_ALIGN (((UINTN) HiiVariable + HiiVariable->Length));
+ HiiVariable = (VAR_CHECK_HII_VARIABLE_HEADER *)HEADER_ALIGN (((UINTN)HiiVariable + HiiVariable->Length));
}
// Not found, so pass.
@@ -333,12 +356,12 @@ SetVariableCheckHandlerHii ( }
#ifdef DUMP_VAR_CHECK_HII
-GLOBAL_REMOVE_IF_UNREFERENCED VAR_CHECK_HII_OPCODE_STRING mHiiOpCodeStringTable[] = {
- {EFI_IFR_VARSTORE_EFI_OP, "EfiVarStore"},
- {EFI_IFR_ONE_OF_OP, "OneOf"},
- {EFI_IFR_CHECKBOX_OP, "CheckBox"},
- {EFI_IFR_NUMERIC_OP, "Numeric"},
- {EFI_IFR_ORDERED_LIST_OP, "OrderedList"},
+GLOBAL_REMOVE_IF_UNREFERENCED VAR_CHECK_HII_OPCODE_STRING mHiiOpCodeStringTable[] = {
+ { EFI_IFR_VARSTORE_EFI_OP, "EfiVarStore" },
+ { EFI_IFR_ONE_OF_OP, "OneOf" },
+ { EFI_IFR_CHECKBOX_OP, "CheckBox" },
+ { EFI_IFR_NUMERIC_OP, "Numeric" },
+ { EFI_IFR_ORDERED_LIST_OP, "OrderedList" },
};
/**
@@ -354,7 +377,8 @@ HiiOpCodeToStr ( IN UINT8 HiiOpCode
)
{
- UINTN Index;
+ UINTN Index;
+
for (Index = 0; Index < ARRAY_SIZE (mHiiOpCodeStringTable); Index++) {
if (mHiiOpCodeStringTable[Index].HiiOpCode == HiiOpCode) {
return mHiiOpCodeStringTable[Index].HiiOpCodeStr;
@@ -375,21 +399,21 @@ DumpHiiQuestion ( IN VAR_CHECK_HII_QUESTION_HEADER *HiiQuestion
)
{
- UINT64 Minimum;
- UINT64 Maximum;
- UINT64 OneValue;
- UINT8 *Ptr;
+ UINT64 Minimum;
+ UINT64 Maximum;
+ UINT64 OneValue;
+ UINT8 *Ptr;
DEBUG ((DEBUG_INFO, " VAR_CHECK_HII_QUESTION_HEADER\n"));
- DEBUG ((DEBUG_INFO, " OpCode - 0x%02x (%a) (%a)\n", HiiQuestion->OpCode, HiiOpCodeToStr (HiiQuestion->OpCode), (HiiQuestion->BitFieldStore? "bit level": "byte level")));
+ DEBUG ((DEBUG_INFO, " OpCode - 0x%02x (%a) (%a)\n", HiiQuestion->OpCode, HiiOpCodeToStr (HiiQuestion->OpCode), (HiiQuestion->BitFieldStore ? "bit level" : "byte level")));
DEBUG ((DEBUG_INFO, " Length - 0x%02x\n", HiiQuestion->Length));
- DEBUG ((DEBUG_INFO, " VarOffset - 0x%04x (%a)\n", HiiQuestion->VarOffset, (HiiQuestion->BitFieldStore? "bit level": "byte level")));
- DEBUG ((DEBUG_INFO, " StorageWidth - 0x%02x (%a)\n", HiiQuestion->StorageWidth, (HiiQuestion->BitFieldStore? "bit level": "byte level")));
+ DEBUG ((DEBUG_INFO, " VarOffset - 0x%04x (%a)\n", HiiQuestion->VarOffset, (HiiQuestion->BitFieldStore ? "bit level" : "byte level")));
+ DEBUG ((DEBUG_INFO, " StorageWidth - 0x%02x (%a)\n", HiiQuestion->StorageWidth, (HiiQuestion->BitFieldStore ? "bit level" : "byte level")));
switch (HiiQuestion->OpCode) {
case EFI_IFR_ONE_OF_OP:
- Ptr = (UINT8 *) ((VAR_CHECK_HII_QUESTION_ONEOF *) HiiQuestion + 1);
- while ((UINTN) Ptr < ((UINTN) HiiQuestion + HiiQuestion->Length)) {
+ Ptr = (UINT8 *)((VAR_CHECK_HII_QUESTION_ONEOF *)HiiQuestion + 1);
+ while ((UINTN)Ptr < ((UINTN)HiiQuestion + HiiQuestion->Length)) {
OneValue = 0;
if (HiiQuestion->BitFieldStore) {
//
@@ -417,12 +441,14 @@ DumpHiiQuestion ( break;
}
}
+
if (HiiQuestion->BitFieldStore) {
Ptr += sizeof (UINT32);
} else {
Ptr += HiiQuestion->StorageWidth;
}
}
+
break;
case EFI_IFR_CHECKBOX_OP:
@@ -431,8 +457,8 @@ DumpHiiQuestion ( case EFI_IFR_NUMERIC_OP:
Minimum = 0;
Maximum = 0;
- Ptr = (UINT8 *) ((VAR_CHECK_HII_QUESTION_NUMERIC *) HiiQuestion + 1);
- if(HiiQuestion->BitFieldStore) {
+ Ptr = (UINT8 *)((VAR_CHECK_HII_QUESTION_NUMERIC *)HiiQuestion + 1);
+ if (HiiQuestion->BitFieldStore) {
//
// For Numeric stored in bit field, the value of Maximum/Minimum are saved as UINT32 type.
//
@@ -471,12 +497,13 @@ DumpHiiQuestion ( break;
}
}
+
break;
case EFI_IFR_ORDERED_LIST_OP:
- DEBUG ((DEBUG_INFO, " MaxContainers - 0x%02x\n", ((VAR_CHECK_HII_QUESTION_ORDEREDLIST *) HiiQuestion)->MaxContainers));
- Ptr = (UINT8 *) ((VAR_CHECK_HII_QUESTION_ORDEREDLIST *) HiiQuestion + 1);
- while ((UINTN) Ptr < ((UINTN) HiiQuestion + HiiQuestion->Length)) {
+ DEBUG ((DEBUG_INFO, " MaxContainers - 0x%02x\n", ((VAR_CHECK_HII_QUESTION_ORDEREDLIST *)HiiQuestion)->MaxContainers));
+ Ptr = (UINT8 *)((VAR_CHECK_HII_QUESTION_ORDEREDLIST *)HiiQuestion + 1);
+ while ((UINTN)Ptr < ((UINTN)HiiQuestion + HiiQuestion->Length)) {
OneValue = 0;
CopyMem (&OneValue, Ptr, HiiQuestion->StorageWidth);
switch (HiiQuestion->StorageWidth) {
@@ -496,8 +523,10 @@ DumpHiiQuestion ( ASSERT (FALSE);
break;
}
+
Ptr += HiiQuestion->StorageWidth;
}
+
break;
default:
@@ -517,7 +546,7 @@ DumpHiiVariable ( IN VAR_CHECK_HII_VARIABLE_HEADER *HiiVariable
)
{
- VAR_CHECK_HII_QUESTION_HEADER *HiiQuestion;
+ VAR_CHECK_HII_QUESTION_HEADER *HiiQuestion;
DEBUG ((DEBUG_INFO, "VAR_CHECK_HII_VARIABLE_HEADER\n"));
DEBUG ((DEBUG_INFO, " Revision - 0x%04x\n", HiiVariable->Revision));
@@ -532,8 +561,8 @@ DumpHiiVariable ( //
// For Hii Question header align.
//
- HiiQuestion = (VAR_CHECK_HII_QUESTION_HEADER *) HEADER_ALIGN (((UINTN) HiiVariable + HiiVariable->HeaderLength));
- while ((UINTN) HiiQuestion < ((UINTN) HiiVariable + HiiVariable->Length)) {
+ HiiQuestion = (VAR_CHECK_HII_QUESTION_HEADER *)HEADER_ALIGN (((UINTN)HiiVariable + HiiVariable->HeaderLength));
+ while ((UINTN)HiiQuestion < ((UINTN)HiiVariable + HiiVariable->Length)) {
//
// Dump Hii Question related to the Hii Variable.
//
@@ -541,7 +570,7 @@ DumpHiiVariable ( //
// For Hii Question header align.
//
- HiiQuestion = (VAR_CHECK_HII_QUESTION_HEADER *) HEADER_ALIGN (((UINTN) HiiQuestion + HiiQuestion->Length));
+ HiiQuestion = (VAR_CHECK_HII_QUESTION_HEADER *)HEADER_ALIGN (((UINTN)HiiQuestion + HiiQuestion->Length));
}
}
@@ -558,22 +587,23 @@ DumpVarCheckHii ( IN UINTN VarCheckHiiBinSize
)
{
- VAR_CHECK_HII_VARIABLE_HEADER *HiiVariable;
+ VAR_CHECK_HII_VARIABLE_HEADER *HiiVariable;
DEBUG ((DEBUG_INFO, "DumpVarCheckHii\n"));
//
// For Hii Variable header align.
//
- HiiVariable = (VAR_CHECK_HII_VARIABLE_HEADER *) HEADER_ALIGN (VarCheckHiiBin);
- while ((UINTN) HiiVariable < ((UINTN) VarCheckHiiBin + VarCheckHiiBinSize)) {
+ HiiVariable = (VAR_CHECK_HII_VARIABLE_HEADER *)HEADER_ALIGN (VarCheckHiiBin);
+ while ((UINTN)HiiVariable < ((UINTN)VarCheckHiiBin + VarCheckHiiBinSize)) {
DumpHiiVariable (HiiVariable);
//
// For Hii Variable header align.
//
- HiiVariable = (VAR_CHECK_HII_VARIABLE_HEADER *) HEADER_ALIGN (((UINTN) HiiVariable + HiiVariable->Length));
+ HiiVariable = (VAR_CHECK_HII_VARIABLE_HEADER *)HEADER_ALIGN (((UINTN)HiiVariable + HiiVariable->Length));
}
}
+
#endif
/**
@@ -588,14 +618,13 @@ DumpVarCheckHii ( EFI_STATUS
EFIAPI
VarCheckHiiLibNullClassConstructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
VarCheckLibRegisterEndOfDxeCallback (VarCheckHiiGen);
- VarCheckLibRegisterAddressPointer ((VOID **) &mVarCheckHiiBin);
+ VarCheckLibRegisterAddressPointer ((VOID **)&mVarCheckHiiBin);
VarCheckLibRegisterSetVariableCheckHandler (SetVariableCheckHandlerHii);
return EFI_SUCCESS;
}
-
diff --git a/MdeModulePkg/Library/VarCheckLib/VarCheckLib.c b/MdeModulePkg/Library/VarCheckLib/VarCheckLib.c index e7cc76a7f0..87afe03414 100644 --- a/MdeModulePkg/Library/VarCheckLib/VarCheckLib.c +++ b/MdeModulePkg/Library/VarCheckLib/VarCheckLib.c @@ -15,36 +15,36 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include <Guid/GlobalVariable.h>
#include <Guid/HardwareErrorVariable.h>
-BOOLEAN mVarCheckLibEndOfDxe = FALSE;
+BOOLEAN mVarCheckLibEndOfDxe = FALSE;
-#define VAR_CHECK_TABLE_SIZE 0x8
+#define VAR_CHECK_TABLE_SIZE 0x8
-UINTN mVarCheckLibEndOfDxeCallbackCount = 0;
-UINTN mVarCheckLibEndOfDxeCallbackMaxCount = 0;
-VAR_CHECK_END_OF_DXE_CALLBACK *mVarCheckLibEndOfDxeCallback = NULL;
+UINTN mVarCheckLibEndOfDxeCallbackCount = 0;
+UINTN mVarCheckLibEndOfDxeCallbackMaxCount = 0;
+VAR_CHECK_END_OF_DXE_CALLBACK *mVarCheckLibEndOfDxeCallback = NULL;
-UINTN mVarCheckLibAddressPointerCount = 0;
-UINTN mVarCheckLibAddressPointerMaxCount = 0;
-VOID ***mVarCheckLibAddressPointer = NULL;
+UINTN mVarCheckLibAddressPointerCount = 0;
+UINTN mVarCheckLibAddressPointerMaxCount = 0;
+VOID ***mVarCheckLibAddressPointer = NULL;
-UINTN mNumberOfVarCheckHandler = 0;
-UINTN mMaxNumberOfVarCheckHandler = 0;
-VAR_CHECK_SET_VARIABLE_CHECK_HANDLER *mVarCheckHandlerTable = NULL;
+UINTN mNumberOfVarCheckHandler = 0;
+UINTN mMaxNumberOfVarCheckHandler = 0;
+VAR_CHECK_SET_VARIABLE_CHECK_HANDLER *mVarCheckHandlerTable = NULL;
typedef struct {
- EFI_GUID Guid;
- VAR_CHECK_VARIABLE_PROPERTY VariableProperty;
- //CHAR16 *Name;
+ EFI_GUID Guid;
+ VAR_CHECK_VARIABLE_PROPERTY VariableProperty;
+ // CHAR16 *Name;
} VAR_CHECK_VARIABLE_ENTRY;
-UINTN mNumberOfVarCheckVariable = 0;
-UINTN mMaxNumberOfVarCheckVariable = 0;
-VARIABLE_ENTRY_PROPERTY **mVarCheckVariableTable = NULL;
+UINTN mNumberOfVarCheckVariable = 0;
+UINTN mMaxNumberOfVarCheckVariable = 0;
+VARIABLE_ENTRY_PROPERTY **mVarCheckVariableTable = NULL;
//
// Handle variables with wildcard name specially.
//
-VARIABLE_ENTRY_PROPERTY mVarCheckVariableWithWildcardName[] = {
+VARIABLE_ENTRY_PROPERTY mVarCheckVariableWithWildcardName[] = {
{
&gEfiGlobalVariableGuid,
L"Boot####",
@@ -106,10 +106,10 @@ VARIABLE_ENTRY_PROPERTY mVarCheckVariableWithWildcardName[] = { BOOLEAN
EFIAPI
VarCheckInternalIsHexaDecimalDigitCharacter (
- IN CHAR16 Char
+ IN CHAR16 Char
)
{
- return (BOOLEAN) ((Char >= L'0' && Char <= L'9') || (Char >= L'A' && Char <= L'F'));
+ return (BOOLEAN)((Char >= L'0' && Char <= L'9') || (Char >= L'A' && Char <= L'F'));
}
/**
@@ -124,29 +124,31 @@ VarCheckInternalIsHexaDecimalDigitCharacter ( **/
VAR_CHECK_VARIABLE_PROPERTY *
VariablePropertyGetWithWildcardName (
- IN CHAR16 *VariableName,
- IN EFI_GUID *VendorGuid,
- IN BOOLEAN WildcardMatch
+ IN CHAR16 *VariableName,
+ IN EFI_GUID *VendorGuid,
+ IN BOOLEAN WildcardMatch
)
{
- UINTN Index;
- UINTN NameLength;
+ UINTN Index;
+ UINTN NameLength;
NameLength = StrLen (VariableName) - 4;
for (Index = 0; Index < sizeof (mVarCheckVariableWithWildcardName)/sizeof (mVarCheckVariableWithWildcardName[0]); Index++) {
- if (CompareGuid (mVarCheckVariableWithWildcardName[Index].Guid, VendorGuid)){
+ if (CompareGuid (mVarCheckVariableWithWildcardName[Index].Guid, VendorGuid)) {
if (WildcardMatch) {
if ((StrLen (VariableName) == StrLen (mVarCheckVariableWithWildcardName[Index].Name)) &&
(StrnCmp (VariableName, mVarCheckVariableWithWildcardName[Index].Name, NameLength) == 0) &&
VarCheckInternalIsHexaDecimalDigitCharacter (VariableName[NameLength]) &&
VarCheckInternalIsHexaDecimalDigitCharacter (VariableName[NameLength + 1]) &&
VarCheckInternalIsHexaDecimalDigitCharacter (VariableName[NameLength + 2]) &&
- VarCheckInternalIsHexaDecimalDigitCharacter (VariableName[NameLength + 3])) {
+ VarCheckInternalIsHexaDecimalDigitCharacter (VariableName[NameLength + 3]))
+ {
return &mVarCheckVariableWithWildcardName[Index].VariableProperty;
}
}
+
if (StrCmp (mVarCheckVariableWithWildcardName[Index].Name, VariableName) == 0) {
- return &mVarCheckVariableWithWildcardName[Index].VariableProperty;
+ return &mVarCheckVariableWithWildcardName[Index].VariableProperty;
}
}
}
@@ -166,9 +168,9 @@ VariablePropertyGetWithWildcardName ( **/
VAR_CHECK_VARIABLE_PROPERTY *
VariablePropertyGetFunction (
- IN CHAR16 *Name,
- IN EFI_GUID *Guid,
- IN BOOLEAN WildcardMatch
+ IN CHAR16 *Name,
+ IN EFI_GUID *Guid,
+ IN BOOLEAN WildcardMatch
)
{
UINTN Index;
@@ -176,8 +178,8 @@ VariablePropertyGetFunction ( CHAR16 *VariableName;
for (Index = 0; Index < mNumberOfVarCheckVariable; Index++) {
- Entry = (VAR_CHECK_VARIABLE_ENTRY *) mVarCheckVariableTable[Index];
- VariableName = (CHAR16 *) ((UINTN) Entry + sizeof (*Entry));
+ Entry = (VAR_CHECK_VARIABLE_ENTRY *)mVarCheckVariableTable[Index];
+ VariableName = (CHAR16 *)((UINTN)Entry + sizeof (*Entry));
if (CompareGuid (&Entry->Guid, Guid) && (StrCmp (VariableName, Name) == 0)) {
return &Entry->VariableProperty;
}
@@ -200,13 +202,13 @@ VariablePropertyGetFunction ( **/
EFI_STATUS
VarCheckAddTableEntry (
- IN OUT UINTN **Table,
- IN OUT UINTN *MaxNumber,
- IN OUT UINTN *CurrentNumber,
- IN UINTN Entry
+ IN OUT UINTN **Table,
+ IN OUT UINTN *MaxNumber,
+ IN OUT UINTN *CurrentNumber,
+ IN UINTN Entry
)
{
- UINTN *TempTable;
+ UINTN *TempTable;
//
// Check whether the table is enough to store new entry.
@@ -263,7 +265,7 @@ VarCheckLibRegisterEndOfDxeCallback ( IN VAR_CHECK_END_OF_DXE_CALLBACK Callback
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
if (Callback == NULL) {
return EFI_INVALID_PARAMETER;
@@ -274,11 +276,11 @@ VarCheckLibRegisterEndOfDxeCallback ( }
Status = VarCheckAddTableEntry (
- (UINTN **) &mVarCheckLibEndOfDxeCallback,
- &mVarCheckLibEndOfDxeCallbackMaxCount,
- &mVarCheckLibEndOfDxeCallbackCount,
- (UINTN) Callback
- );
+ (UINTN **)&mVarCheckLibEndOfDxeCallback,
+ &mVarCheckLibEndOfDxeCallbackMaxCount,
+ &mVarCheckLibEndOfDxeCallbackCount,
+ (UINTN)Callback
+ );
DEBUG ((DEBUG_INFO, "VarCheckLibRegisterEndOfDxeCallback - 0x%x %r\n", Callback, Status));
@@ -300,26 +302,27 @@ VarCheckLibRegisterEndOfDxeCallback ( VOID ***
EFIAPI
VarCheckLibInitializeAtEndOfDxe (
- IN OUT UINTN *AddressPointerCount OPTIONAL
+ IN OUT UINTN *AddressPointerCount OPTIONAL
)
{
- VOID *TempTable;
- UINTN TotalCount;
- UINTN Index;
+ VOID *TempTable;
+ UINTN TotalCount;
+ UINTN Index;
for (Index = 0; Index < mVarCheckLibEndOfDxeCallbackCount; Index++) {
//
// Invoke the callback registered by VarCheckLibRegisterEndOfDxeCallback().
//
- mVarCheckLibEndOfDxeCallback[Index] ();
+ mVarCheckLibEndOfDxeCallback[Index]();
}
+
if (mVarCheckLibEndOfDxeCallback != NULL) {
//
// Free the callback buffer.
//
- mVarCheckLibEndOfDxeCallbackCount = 0;
+ mVarCheckLibEndOfDxeCallbackCount = 0;
mVarCheckLibEndOfDxeCallbackMaxCount = 0;
- FreePool ((VOID *) mVarCheckLibEndOfDxeCallback);
+ FreePool ((VOID *)mVarCheckLibEndOfDxeCallback);
mVarCheckLibEndOfDxeCallback = NULL;
}
@@ -330,11 +333,12 @@ VarCheckLibInitializeAtEndOfDxe ( //
// Free the address pointer buffer.
//
- mVarCheckLibAddressPointerCount = 0;
+ mVarCheckLibAddressPointerCount = 0;
mVarCheckLibAddressPointerMaxCount = 0;
- FreePool ((VOID *) mVarCheckLibAddressPointer);
+ FreePool ((VOID *)mVarCheckLibAddressPointer);
mVarCheckLibAddressPointer = NULL;
}
+
return NULL;
}
@@ -343,29 +347,29 @@ VarCheckLibInitializeAtEndOfDxe ( // Also cover VarCheckHandler and the entries, and VarCheckVariable and the entries.
//
TotalCount = mVarCheckLibAddressPointerCount + (mNumberOfVarCheckHandler + 1) + (mNumberOfVarCheckVariable + 1);
- TempTable = ReallocateRuntimePool (
- mVarCheckLibAddressPointerMaxCount * sizeof (VOID **),
- TotalCount * sizeof (VOID **),
- (VOID *) mVarCheckLibAddressPointer
- );
+ TempTable = ReallocateRuntimePool (
+ mVarCheckLibAddressPointerMaxCount * sizeof (VOID **),
+ TotalCount * sizeof (VOID **),
+ (VOID *)mVarCheckLibAddressPointer
+ );
if (TempTable != NULL) {
- mVarCheckLibAddressPointer = (VOID ***) TempTable;
+ mVarCheckLibAddressPointer = (VOID ***)TempTable;
//
// Cover VarCheckHandler and the entries.
//
- mVarCheckLibAddressPointer[mVarCheckLibAddressPointerCount++] = (VOID **) &mVarCheckHandlerTable;
+ mVarCheckLibAddressPointer[mVarCheckLibAddressPointerCount++] = (VOID **)&mVarCheckHandlerTable;
for (Index = 0; Index < mNumberOfVarCheckHandler; Index++) {
- mVarCheckLibAddressPointer[mVarCheckLibAddressPointerCount++] = (VOID **) &mVarCheckHandlerTable[Index];
+ mVarCheckLibAddressPointer[mVarCheckLibAddressPointerCount++] = (VOID **)&mVarCheckHandlerTable[Index];
}
//
// Cover VarCheckVariable and the entries.
//
- mVarCheckLibAddressPointer[mVarCheckLibAddressPointerCount++] = (VOID **) &mVarCheckVariableTable;
+ mVarCheckLibAddressPointer[mVarCheckLibAddressPointerCount++] = (VOID **)&mVarCheckVariableTable;
for (Index = 0; Index < mNumberOfVarCheckVariable; Index++) {
- mVarCheckLibAddressPointer[mVarCheckLibAddressPointerCount++] = (VOID **) &mVarCheckVariableTable[Index];
+ mVarCheckLibAddressPointer[mVarCheckLibAddressPointerCount++] = (VOID **)&mVarCheckVariableTable[Index];
}
ASSERT (mVarCheckLibAddressPointerCount == TotalCount);
@@ -392,10 +396,10 @@ VarCheckLibInitializeAtEndOfDxe ( EFI_STATUS
EFIAPI
VarCheckLibRegisterAddressPointer (
- IN VOID **AddressPointer
+ IN VOID **AddressPointer
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
if (AddressPointer == NULL) {
return EFI_INVALID_PARAMETER;
@@ -405,12 +409,12 @@ VarCheckLibRegisterAddressPointer ( return EFI_ACCESS_DENIED;
}
- Status = VarCheckAddTableEntry(
- (UINTN **) &mVarCheckLibAddressPointer,
- &mVarCheckLibAddressPointerMaxCount,
- &mVarCheckLibAddressPointerCount,
- (UINTN) AddressPointer
- );
+ Status = VarCheckAddTableEntry (
+ (UINTN **)&mVarCheckLibAddressPointer,
+ &mVarCheckLibAddressPointerMaxCount,
+ &mVarCheckLibAddressPointerCount,
+ (UINTN)AddressPointer
+ );
DEBUG ((DEBUG_INFO, "VarCheckLibRegisterAddressPointer - 0x%x %r\n", AddressPointer, Status));
@@ -434,10 +438,10 @@ VarCheckLibRegisterAddressPointer ( EFI_STATUS
EFIAPI
VarCheckLibRegisterSetVariableCheckHandler (
- IN VAR_CHECK_SET_VARIABLE_CHECK_HANDLER Handler
+ IN VAR_CHECK_SET_VARIABLE_CHECK_HANDLER Handler
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
if (Handler == NULL) {
return EFI_INVALID_PARAMETER;
@@ -447,12 +451,12 @@ VarCheckLibRegisterSetVariableCheckHandler ( return EFI_ACCESS_DENIED;
}
- Status = VarCheckAddTableEntry(
- (UINTN **) &mVarCheckHandlerTable,
- &mMaxNumberOfVarCheckHandler,
- &mNumberOfVarCheckHandler,
- (UINTN) Handler
- );
+ Status = VarCheckAddTableEntry (
+ (UINTN **)&mVarCheckHandlerTable,
+ &mMaxNumberOfVarCheckHandler,
+ &mNumberOfVarCheckHandler,
+ (UINTN)Handler
+ );
DEBUG ((DEBUG_INFO, "VarCheckLibRegisterSetVariableCheckHandler - 0x%x %r\n", Handler, Status));
@@ -477,17 +481,17 @@ VarCheckLibRegisterSetVariableCheckHandler ( EFI_STATUS
EFIAPI
VarCheckLibVariablePropertySet (
- IN CHAR16 *Name,
- IN EFI_GUID *Guid,
- IN VAR_CHECK_VARIABLE_PROPERTY *VariableProperty
+ IN CHAR16 *Name,
+ IN EFI_GUID *Guid,
+ IN VAR_CHECK_VARIABLE_PROPERTY *VariableProperty
)
{
- EFI_STATUS Status;
- VAR_CHECK_VARIABLE_ENTRY *Entry;
- CHAR16 *VariableName;
- VAR_CHECK_VARIABLE_PROPERTY *Property;
+ EFI_STATUS Status;
+ VAR_CHECK_VARIABLE_ENTRY *Entry;
+ CHAR16 *VariableName;
+ VAR_CHECK_VARIABLE_PROPERTY *Property;
- if (Name == NULL || Name[0] == 0 || Guid == NULL) {
+ if ((Name == NULL) || (Name[0] == 0) || (Guid == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -516,16 +520,17 @@ VarCheckLibVariablePropertySet ( if (Entry == NULL) {
return EFI_OUT_OF_RESOURCES;
}
- VariableName = (CHAR16 *) ((UINTN) Entry + sizeof (*Entry));
+
+ VariableName = (CHAR16 *)((UINTN)Entry + sizeof (*Entry));
StrCpyS (VariableName, StrSize (Name)/sizeof (CHAR16), Name);
CopyGuid (&Entry->Guid, Guid);
CopyMem (&Entry->VariableProperty, VariableProperty, sizeof (*VariableProperty));
- Status = VarCheckAddTableEntry(
- (UINTN **) &mVarCheckVariableTable,
+ Status = VarCheckAddTableEntry (
+ (UINTN **)&mVarCheckVariableTable,
&mMaxNumberOfVarCheckVariable,
&mNumberOfVarCheckVariable,
- (UINTN) Entry
+ (UINTN)Entry
);
if (EFI_ERROR (Status)) {
@@ -551,14 +556,14 @@ VarCheckLibVariablePropertySet ( EFI_STATUS
EFIAPI
VarCheckLibVariablePropertyGet (
- IN CHAR16 *Name,
- IN EFI_GUID *Guid,
- OUT VAR_CHECK_VARIABLE_PROPERTY *VariableProperty
+ IN CHAR16 *Name,
+ IN EFI_GUID *Guid,
+ OUT VAR_CHECK_VARIABLE_PROPERTY *VariableProperty
)
{
- VAR_CHECK_VARIABLE_PROPERTY *Property;
+ VAR_CHECK_VARIABLE_PROPERTY *Property;
- if (Name == NULL || Name[0] == 0 || Guid == NULL) {
+ if ((Name == NULL) || (Name[0] == 0) || (Guid == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -600,17 +605,17 @@ VarCheckLibVariablePropertyGet ( EFI_STATUS
EFIAPI
VarCheckLibSetVariableCheck (
- IN CHAR16 *VariableName,
- IN EFI_GUID *VendorGuid,
- IN UINT32 Attributes,
- IN UINTN DataSize,
- IN VOID *Data,
- IN VAR_CHECK_REQUEST_SOURCE RequestSource
+ IN CHAR16 *VariableName,
+ IN EFI_GUID *VendorGuid,
+ IN UINT32 Attributes,
+ IN UINTN DataSize,
+ IN VOID *Data,
+ IN VAR_CHECK_REQUEST_SOURCE RequestSource
)
{
- EFI_STATUS Status;
- UINTN Index;
- VAR_CHECK_VARIABLE_PROPERTY *Property;
+ EFI_STATUS Status;
+ UINTN Index;
+ VAR_CHECK_VARIABLE_PROPERTY *Property;
if (!mVarCheckLibEndOfDxe) {
//
@@ -630,6 +635,7 @@ VarCheckLibSetVariableCheck ( DEBUG ((DEBUG_INFO, "Variable Check ReadOnly variable fail %r - %g:%s\n", EFI_WRITE_PROTECTED, VendorGuid, VariableName));
return EFI_WRITE_PROTECTED;
}
+
if (!((((Attributes & EFI_VARIABLE_APPEND_WRITE) == 0) && (DataSize == 0)) || (Attributes == 0))) {
//
// Not to delete variable.
@@ -638,6 +644,7 @@ VarCheckLibSetVariableCheck ( DEBUG ((DEBUG_INFO, "Variable Check Attributes(0x%08x to 0x%08x) fail %r - %g:%s\n", Property->Attributes, Attributes, EFI_INVALID_PARAMETER, VendorGuid, VariableName));
return EFI_INVALID_PARAMETER;
}
+
if (DataSize != 0) {
if ((DataSize < Property->MinSize) || (DataSize > Property->MaxSize)) {
DEBUG ((DEBUG_INFO, "Variable Check DataSize fail(0x%x not in 0x%x - 0x%x) %r - %g:%s\n", DataSize, Property->MinSize, Property->MaxSize, EFI_INVALID_PARAMETER, VendorGuid, VariableName));
@@ -648,24 +655,26 @@ VarCheckLibSetVariableCheck ( }
for (Index = 0; Index < mNumberOfVarCheckHandler; Index++) {
- Status = mVarCheckHandlerTable[Index] (
- VariableName,
- VendorGuid,
- Attributes,
- DataSize,
- Data
- );
- if (Status == EFI_WRITE_PROTECTED && RequestSource == VarCheckFromTrusted) {
+ Status = mVarCheckHandlerTable[Index](
+ VariableName,
+ VendorGuid,
+ Attributes,
+ DataSize,
+ Data
+ );
+ if ((Status == EFI_WRITE_PROTECTED) && (RequestSource == VarCheckFromTrusted)) {
//
// If RequestSource is trusted, then allow variable to be set even if it
// is write protected.
//
continue;
}
+
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_INFO, "Variable Check handler fail %r - %g:%s\n", Status, VendorGuid, VariableName));
return Status;
}
}
+
return EFI_SUCCESS;
}
diff --git a/MdeModulePkg/Library/VarCheckPcdLib/VarCheckPcdLibNullClass.c b/MdeModulePkg/Library/VarCheckPcdLib/VarCheckPcdLibNullClass.c index 31efa69148..90cef6e85d 100644 --- a/MdeModulePkg/Library/VarCheckPcdLib/VarCheckPcdLibNullClass.c +++ b/MdeModulePkg/Library/VarCheckPcdLib/VarCheckPcdLibNullClass.c @@ -15,9 +15,9 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include "VarCheckPcdStructure.h"
-//#define DUMP_VAR_CHECK_PCD
+// #define DUMP_VAR_CHECK_PCD
-GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 mVarCheckPcdHex[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
+GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 mVarCheckPcdHex[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
/**
Dump some hexadecimal data.
@@ -30,21 +30,21 @@ GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 mVarCheckPcdHex[] = {'0', '1', '2', '3 **/
VOID
VarCheckPcdInternalDumpHex (
- IN UINTN Indent,
- IN UINTN Offset,
- IN UINTN DataSize,
- IN VOID *UserData
+ IN UINTN Indent,
+ IN UINTN Offset,
+ IN UINTN DataSize,
+ IN VOID *UserData
)
{
- UINT8 *Data;
+ UINT8 *Data;
- CHAR8 Val[50];
+ CHAR8 Val[50];
- CHAR8 Str[20];
+ CHAR8 Str[20];
- UINT8 TempByte;
- UINTN Size;
- UINTN Index;
+ UINT8 TempByte;
+ UINTN Size;
+ UINTN Index;
Data = UserData;
while (DataSize != 0) {
@@ -54,19 +54,19 @@ VarCheckPcdInternalDumpHex ( }
for (Index = 0; Index < Size; Index += 1) {
- TempByte = Data[Index];
- Val[Index * 3 + 0] = mVarCheckPcdHex[TempByte >> 4];
- Val[Index * 3 + 1] = mVarCheckPcdHex[TempByte & 0xF];
- Val[Index * 3 + 2] = (CHAR8) ((Index == 7) ? '-' : ' ');
- Str[Index] = (CHAR8) ((TempByte < ' ' || TempByte > 'z') ? '.' : TempByte);
+ TempByte = Data[Index];
+ Val[Index * 3 + 0] = mVarCheckPcdHex[TempByte >> 4];
+ Val[Index * 3 + 1] = mVarCheckPcdHex[TempByte & 0xF];
+ Val[Index * 3 + 2] = (CHAR8)((Index == 7) ? '-' : ' ');
+ Str[Index] = (CHAR8)((TempByte < ' ' || TempByte > 'z') ? '.' : TempByte);
}
- Val[Index * 3] = 0;
- Str[Index] = 0;
+ Val[Index * 3] = 0;
+ Str[Index] = 0;
DEBUG ((DEBUG_INFO, "%*a%08X: %-48a *%a*\r\n", Indent, "", Offset, Val, Str));
- Data += Size;
- Offset += Size;
+ Data += Size;
+ Offset += Size;
DataSize -= Size;
}
}
@@ -84,24 +84,24 @@ VarCheckPcdInternalDumpHex ( **/
BOOLEAN
VarCheckPcdValidData (
- IN VAR_CHECK_PCD_VALID_DATA_HEADER *PcdValidData,
- IN VOID *Data,
- IN UINTN DataSize
+ IN VAR_CHECK_PCD_VALID_DATA_HEADER *PcdValidData,
+ IN VOID *Data,
+ IN UINTN DataSize
)
{
- UINT64 OneData;
- UINT64 Minimum;
- UINT64 Maximum;
- UINT64 OneValue;
- UINT8 *Ptr;
+ UINT64 OneData;
+ UINT64 Minimum;
+ UINT64 Maximum;
+ UINT64 OneValue;
+ UINT8 *Ptr;
OneData = 0;
- CopyMem (&OneData, (UINT8 *) Data + PcdValidData->VarOffset, PcdValidData->StorageWidth);
+ CopyMem (&OneData, (UINT8 *)Data + PcdValidData->VarOffset, PcdValidData->StorageWidth);
switch (PcdValidData->Type) {
case VarCheckPcdValidList:
- Ptr = (UINT8 *) ((VAR_CHECK_PCD_VALID_LIST *) PcdValidData + 1);
- while ((UINTN) Ptr < (UINTN) PcdValidData + PcdValidData->Length) {
+ Ptr = (UINT8 *)((VAR_CHECK_PCD_VALID_LIST *)PcdValidData + 1);
+ while ((UINTN)Ptr < (UINTN)PcdValidData + PcdValidData->Length) {
OneValue = 0;
CopyMem (&OneValue, Ptr, PcdValidData->StorageWidth);
if (OneData == OneValue) {
@@ -110,23 +110,28 @@ VarCheckPcdValidData ( //
break;
}
+
Ptr += PcdValidData->StorageWidth;
}
- if ((UINTN) Ptr >= ((UINTN) PcdValidData + PcdValidData->Length)) {
+
+ if ((UINTN)Ptr >= ((UINTN)PcdValidData + PcdValidData->Length)) {
//
// No match
//
DEBUG ((DEBUG_INFO, "VarCheckPcdValidData fail: ValidList mismatch (0x%lx)\n", OneData));
- DEBUG_CODE (VarCheckPcdInternalDumpHex (2, 0, PcdValidData->Length, (UINT8 *) PcdValidData););
+ DEBUG_CODE (
+ VarCheckPcdInternalDumpHex (2, 0, PcdValidData->Length, (UINT8 *)PcdValidData);
+ );
return FALSE;
}
+
break;
case VarCheckPcdValidRange:
Minimum = 0;
Maximum = 0;
- Ptr = (UINT8 *) ((VAR_CHECK_PCD_VALID_RANGE *) PcdValidData + 1);
- while ((UINTN) Ptr < (UINTN) PcdValidData + PcdValidData->Length) {
+ Ptr = (UINT8 *)((VAR_CHECK_PCD_VALID_RANGE *)PcdValidData + 1);
+ while ((UINTN)Ptr < (UINTN)PcdValidData + PcdValidData->Length) {
CopyMem (&Minimum, Ptr, PcdValidData->StorageWidth);
Ptr += PcdValidData->StorageWidth;
CopyMem (&Maximum, Ptr, PcdValidData->StorageWidth);
@@ -136,8 +141,11 @@ VarCheckPcdValidData ( return TRUE;
}
}
+
DEBUG ((DEBUG_INFO, "VarCheckPcdValidData fail: ValidRange mismatch (0x%lx)\n", OneData));
- DEBUG_CODE (VarCheckPcdInternalDumpHex (2, 0, PcdValidData->Length, (UINT8 *) PcdValidData););
+ DEBUG_CODE (
+ VarCheckPcdInternalDumpHex (2, 0, PcdValidData->Length, (UINT8 *)PcdValidData);
+ );
return FALSE;
break;
@@ -149,8 +157,8 @@ VarCheckPcdValidData ( return TRUE;
}
-VAR_CHECK_PCD_VARIABLE_HEADER *mVarCheckPcdBin = NULL;
-UINTN mVarCheckPcdBinSize = 0;
+VAR_CHECK_PCD_VARIABLE_HEADER *mVarCheckPcdBin = NULL;
+UINTN mVarCheckPcdBinSize = 0;
/**
SetVariable check handler PCD.
@@ -168,15 +176,15 @@ UINTN mVarCheckPcdBinSize = 0; EFI_STATUS
EFIAPI
SetVariableCheckHandlerPcd (
- IN CHAR16 *VariableName,
- IN EFI_GUID *VendorGuid,
- IN UINT32 Attributes,
- IN UINTN DataSize,
- IN VOID *Data
+ IN CHAR16 *VariableName,
+ IN EFI_GUID *VendorGuid,
+ IN UINT32 Attributes,
+ IN UINTN DataSize,
+ IN VOID *Data
)
{
- VAR_CHECK_PCD_VARIABLE_HEADER *PcdVariable;
- VAR_CHECK_PCD_VALID_DATA_HEADER *PcdValidData;
+ VAR_CHECK_PCD_VARIABLE_HEADER *PcdVariable;
+ VAR_CHECK_PCD_VALID_DATA_HEADER *PcdValidData;
if (mVarCheckPcdBin == NULL) {
return EFI_SUCCESS;
@@ -192,15 +200,16 @@ SetVariableCheckHandlerPcd ( //
// For Pcd Variable header align.
//
- PcdVariable = (VAR_CHECK_PCD_VARIABLE_HEADER *) HEADER_ALIGN (mVarCheckPcdBin);
- while ((UINTN) PcdVariable < ((UINTN) mVarCheckPcdBin + mVarCheckPcdBinSize)) {
- if ((StrCmp ((CHAR16 *) (PcdVariable + 1), VariableName) == 0) &&
- (CompareGuid (&PcdVariable->Guid, VendorGuid))) {
+ PcdVariable = (VAR_CHECK_PCD_VARIABLE_HEADER *)HEADER_ALIGN (mVarCheckPcdBin);
+ while ((UINTN)PcdVariable < ((UINTN)mVarCheckPcdBin + mVarCheckPcdBinSize)) {
+ if ((StrCmp ((CHAR16 *)(PcdVariable + 1), VariableName) == 0) &&
+ (CompareGuid (&PcdVariable->Guid, VendorGuid)))
+ {
//
// Found the Pcd Variable that could be used to do check.
//
DEBUG ((DEBUG_INFO, "VarCheckPcdVariable - %s:%g with Attributes = 0x%08x Size = 0x%x\n", VariableName, VendorGuid, Attributes, DataSize));
- if ((PcdVariable->Attributes != 0) && PcdVariable->Attributes != Attributes) {
+ if ((PcdVariable->Attributes != 0) && (PcdVariable->Attributes != Attributes)) {
DEBUG ((DEBUG_INFO, "VarCheckPcdVariable fail for Attributes - 0x%08x\n", PcdVariable->Attributes));
return EFI_SECURITY_VIOLATION;
}
@@ -214,26 +223,28 @@ SetVariableCheckHandlerPcd ( // Do the check.
// For Pcd ValidData header align.
//
- PcdValidData = (VAR_CHECK_PCD_VALID_DATA_HEADER *) HEADER_ALIGN (((UINTN) PcdVariable + PcdVariable->HeaderLength));
- while ((UINTN) PcdValidData < ((UINTN) PcdVariable + PcdVariable->Length)) {
- if (((UINTN) PcdValidData->VarOffset + PcdValidData->StorageWidth) <= DataSize) {
+ PcdValidData = (VAR_CHECK_PCD_VALID_DATA_HEADER *)HEADER_ALIGN (((UINTN)PcdVariable + PcdVariable->HeaderLength));
+ while ((UINTN)PcdValidData < ((UINTN)PcdVariable + PcdVariable->Length)) {
+ if (((UINTN)PcdValidData->VarOffset + PcdValidData->StorageWidth) <= DataSize) {
if (!VarCheckPcdValidData (PcdValidData, Data, DataSize)) {
return EFI_SECURITY_VIOLATION;
}
}
+
//
// For Pcd ValidData header align.
//
- PcdValidData = (VAR_CHECK_PCD_VALID_DATA_HEADER *) HEADER_ALIGN (((UINTN) PcdValidData + PcdValidData->Length));
+ PcdValidData = (VAR_CHECK_PCD_VALID_DATA_HEADER *)HEADER_ALIGN (((UINTN)PcdValidData + PcdValidData->Length));
}
DEBUG ((DEBUG_INFO, "VarCheckPcdVariable - ALL CHECK PASS!\n"));
return EFI_SUCCESS;
}
+
//
// For Pcd Variable header align.
//
- PcdVariable = (VAR_CHECK_PCD_VARIABLE_HEADER *) HEADER_ALIGN (((UINTN) PcdVariable + PcdVariable->Length));
+ PcdVariable = (VAR_CHECK_PCD_VARIABLE_HEADER *)HEADER_ALIGN (((UINTN)PcdVariable + PcdVariable->Length));
}
// Not found, so pass.
@@ -241,6 +252,7 @@ SetVariableCheckHandlerPcd ( }
#ifdef DUMP_VAR_CHECK_PCD
+
/**
Dump Pcd ValidData.
@@ -249,13 +261,13 @@ SetVariableCheckHandlerPcd ( **/
VOID
DumpPcdValidData (
- IN VAR_CHECK_PCD_VALID_DATA_HEADER *PcdValidData
+ IN VAR_CHECK_PCD_VALID_DATA_HEADER *PcdValidData
)
{
- UINT64 Minimum;
- UINT64 Maximum;
- UINT64 OneValue;
- UINT8 *Ptr;
+ UINT64 Minimum;
+ UINT64 Maximum;
+ UINT64 OneValue;
+ UINT8 *Ptr;
DEBUG ((DEBUG_INFO, " VAR_CHECK_PCD_VALID_DATA_HEADER\n"));
DEBUG ((DEBUG_INFO, " Type - 0x%02x\n", PcdValidData->Type));
@@ -265,8 +277,8 @@ DumpPcdValidData ( switch (PcdValidData->Type) {
case VarCheckPcdValidList:
- Ptr = (UINT8 *) ((VAR_CHECK_PCD_VALID_LIST *) PcdValidData + 1);
- while ((UINTN) Ptr < ((UINTN) PcdValidData + PcdValidData->Length)) {
+ Ptr = (UINT8 *)((VAR_CHECK_PCD_VALID_LIST *)PcdValidData + 1);
+ while ((UINTN)Ptr < ((UINTN)PcdValidData + PcdValidData->Length)) {
OneValue = 0;
CopyMem (&OneValue, Ptr, PcdValidData->StorageWidth);
switch (PcdValidData->StorageWidth) {
@@ -286,15 +298,17 @@ DumpPcdValidData ( ASSERT (FALSE);
break;
}
+
Ptr += PcdValidData->StorageWidth;
}
+
break;
case VarCheckPcdValidRange:
Minimum = 0;
Maximum = 0;
- Ptr = (UINT8 *) ((VAR_CHECK_PCD_VALID_RANGE *) PcdValidData + 1);
- while ((UINTN) Ptr < (UINTN) PcdValidData + PcdValidData->Length) {
+ Ptr = (UINT8 *)((VAR_CHECK_PCD_VALID_RANGE *)PcdValidData + 1);
+ while ((UINTN)Ptr < (UINTN)PcdValidData + PcdValidData->Length) {
CopyMem (&Minimum, Ptr, PcdValidData->StorageWidth);
Ptr += PcdValidData->StorageWidth;
CopyMem (&Maximum, Ptr, PcdValidData->StorageWidth);
@@ -322,6 +336,7 @@ DumpPcdValidData ( break;
}
}
+
break;
default:
@@ -341,7 +356,7 @@ DumpPcdVariable ( IN VAR_CHECK_PCD_VARIABLE_HEADER *PcdVariable
)
{
- VAR_CHECK_PCD_VALID_DATA_HEADER *PcdValidData;
+ VAR_CHECK_PCD_VALID_DATA_HEADER *PcdValidData;
DEBUG ((DEBUG_INFO, "VAR_CHECK_PCD_VARIABLE_HEADER\n"));
DEBUG ((DEBUG_INFO, " Revision - 0x%04x\n", PcdVariable->Revision));
@@ -355,8 +370,8 @@ DumpPcdVariable ( //
// For Pcd ValidData header align.
//
- PcdValidData = (VAR_CHECK_PCD_VALID_DATA_HEADER *) HEADER_ALIGN (((UINTN) PcdVariable + PcdVariable->HeaderLength));
- while ((UINTN) PcdValidData < ((UINTN) PcdVariable + PcdVariable->Length)) {
+ PcdValidData = (VAR_CHECK_PCD_VALID_DATA_HEADER *)HEADER_ALIGN (((UINTN)PcdVariable + PcdVariable->HeaderLength));
+ while ((UINTN)PcdValidData < ((UINTN)PcdVariable + PcdVariable->Length)) {
//
// Dump Pcd ValidData related to the Pcd Variable.
//
@@ -364,7 +379,7 @@ DumpPcdVariable ( //
// For Pcd ValidData header align.
//
- PcdValidData = (VAR_CHECK_PCD_VALID_DATA_HEADER *) HEADER_ALIGN (((UINTN) PcdValidData + PcdValidData->Length));
+ PcdValidData = (VAR_CHECK_PCD_VALID_DATA_HEADER *)HEADER_ALIGN (((UINTN)PcdValidData + PcdValidData->Length));
}
}
@@ -381,22 +396,23 @@ DumpVarCheckPcd ( IN UINTN VarCheckPcdBinSize
)
{
- VAR_CHECK_PCD_VARIABLE_HEADER *PcdVariable;
+ VAR_CHECK_PCD_VARIABLE_HEADER *PcdVariable;
DEBUG ((DEBUG_INFO, "DumpVarCheckPcd\n"));
//
// For Pcd Variable header align.
//
- PcdVariable = (VAR_CHECK_PCD_VARIABLE_HEADER *) HEADER_ALIGN (VarCheckPcdBin);
- while ((UINTN) PcdVariable < ((UINTN) VarCheckPcdBin + VarCheckPcdBinSize)) {
+ PcdVariable = (VAR_CHECK_PCD_VARIABLE_HEADER *)HEADER_ALIGN (VarCheckPcdBin);
+ while ((UINTN)PcdVariable < ((UINTN)VarCheckPcdBin + VarCheckPcdBinSize)) {
DumpPcdVariable (PcdVariable);
//
// For Pcd Variable header align.
//
- PcdVariable = (VAR_CHECK_PCD_VARIABLE_HEADER *) HEADER_ALIGN (((UINTN) PcdVariable + PcdVariable->Length));
+ PcdVariable = (VAR_CHECK_PCD_VARIABLE_HEADER *)HEADER_ALIGN (((UINTN)PcdVariable + PcdVariable->Length));
}
}
+
#endif
/**
@@ -409,9 +425,9 @@ LocateVarCheckPcdBin ( VOID
)
{
- EFI_STATUS Status;
- VAR_CHECK_PCD_VARIABLE_HEADER *VarCheckPcdBin;
- UINTN VarCheckPcdBinSize;
+ EFI_STATUS Status;
+ VAR_CHECK_PCD_VARIABLE_HEADER *VarCheckPcdBin;
+ UINTN VarCheckPcdBinSize;
//
// Search the VarCheckPcdBin from the first RAW section of current FFS.
@@ -419,7 +435,7 @@ LocateVarCheckPcdBin ( Status = GetSectionFromFfs (
EFI_SECTION_RAW,
0,
- (VOID **) &VarCheckPcdBin,
+ (VOID **)&VarCheckPcdBin,
&VarCheckPcdBinSize
);
if (!EFI_ERROR (Status)) {
@@ -432,17 +448,17 @@ LocateVarCheckPcdBin ( //
// Make sure the allocated buffer for VarCheckPcdBin at required alignment.
//
- ASSERT ((((UINTN) mVarCheckPcdBin) & (HEADER_ALIGNMENT - 1)) == 0);
+ ASSERT ((((UINTN)mVarCheckPcdBin) & (HEADER_ALIGNMENT - 1)) == 0);
mVarCheckPcdBinSize = VarCheckPcdBinSize;
FreePool (VarCheckPcdBin);
DEBUG ((DEBUG_INFO, "VarCheckPcdBin - at 0x%x size = 0x%x\n", mVarCheckPcdBin, mVarCheckPcdBinSize));
-#ifdef DUMP_VAR_CHECK_PCD
+ #ifdef DUMP_VAR_CHECK_PCD
DEBUG_CODE (
DumpVarCheckPcd (mVarCheckPcdBin, mVarCheckPcdBinSize);
- );
-#endif
+ );
+ #endif
} else {
DEBUG ((DEBUG_INFO, "[VarCheckPcd] No VarCheckPcdBin found at the first RAW section\n"));
}
@@ -460,12 +476,12 @@ LocateVarCheckPcdBin ( EFI_STATUS
EFIAPI
VarCheckPcdLibNullClassConstructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
LocateVarCheckPcdBin ();
- VarCheckLibRegisterAddressPointer ((VOID **) &mVarCheckPcdBin);
+ VarCheckLibRegisterAddressPointer ((VOID **)&mVarCheckPcdBin);
VarCheckLibRegisterSetVariableCheckHandler (SetVariableCheckHandlerPcd);
return EFI_SUCCESS;
diff --git a/MdeModulePkg/Library/VarCheckPcdLib/VarCheckPcdStructure.h b/MdeModulePkg/Library/VarCheckPcdLib/VarCheckPcdStructure.h index 324dcd8f1f..4001ae6c9c 100644 --- a/MdeModulePkg/Library/VarCheckPcdLib/VarCheckPcdStructure.h +++ b/MdeModulePkg/Library/VarCheckPcdLib/VarCheckPcdStructure.h @@ -27,42 +27,42 @@ typedef enum { } VAR_CHECK_PCD_CHECK_TYPE;
typedef struct {
- UINT16 Revision;
- UINT16 HeaderLength;
- UINT32 Length; // Length include this header
- UINT8 Type;
- UINT8 Reserved[3];
- UINT32 Attributes;
- EFI_GUID Guid;
-//CHAR16 Name[];
+ UINT16 Revision;
+ UINT16 HeaderLength;
+ UINT32 Length; // Length include this header
+ UINT8 Type;
+ UINT8 Reserved[3];
+ UINT32 Attributes;
+ EFI_GUID Guid;
+ // CHAR16 Name[];
} VAR_CHECK_PCD_VARIABLE_HEADER;
typedef struct {
- UINT8 Type;
- UINT8 Length; // Length include this header
- UINT16 VarOffset;
- UINT8 StorageWidth;
+ UINT8 Type;
+ UINT8 Length; // Length include this header
+ UINT16 VarOffset;
+ UINT8 StorageWidth;
} VAR_CHECK_PCD_VALID_DATA_HEADER;
typedef struct {
- UINT8 Type;
- UINT8 Length; // Length include this header
- UINT16 VarOffset;
- UINT8 StorageWidth;
-//UINTx Data[]; // x = UINT8/UINT16/UINT32/UINT64;
+ UINT8 Type;
+ UINT8 Length; // Length include this header
+ UINT16 VarOffset;
+ UINT8 StorageWidth;
+ // UINTx Data[]; // x = UINT8/UINT16/UINT32/UINT64;
} VAR_CHECK_PCD_VALID_LIST;
-//typedef struct {
+// typedef struct {
// UINTx Minimum; // x = UINT8/UINT16/UINT32/UINT64
// UINTx Maximum; // x = UINT8/UINT16/UINT32/UINT64
-//} VAR_CHECK_PCD_VALID_RANGE_DATA;
+// } VAR_CHECK_PCD_VALID_RANGE_DATA;
typedef struct {
- UINT8 Type;
- UINT8 Length; // Length include this header
- UINT16 VarOffset;
- UINT8 StorageWidth;
-// VAR_CHECK_PCD_VALID_RANGE_DATA ValidRange[];
+ UINT8 Type;
+ UINT8 Length; // Length include this header
+ UINT16 VarOffset;
+ UINT8 StorageWidth;
+ // VAR_CHECK_PCD_VALID_RANGE_DATA ValidRange[];
} VAR_CHECK_PCD_VALID_RANGE;
#pragma pack ()
diff --git a/MdeModulePkg/Library/VarCheckPolicyLib/VarCheckPolicyLib.c b/MdeModulePkg/Library/VarCheckPolicyLib/VarCheckPolicyLib.c index e50edb4ffc..da90f4fc6a 100644 --- a/MdeModulePkg/Library/VarCheckPolicyLib/VarCheckPolicyLib.c +++ b/MdeModulePkg/Library/VarCheckPolicyLib/VarCheckPolicyLib.c @@ -24,29 +24,27 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include "VarCheckPolicyLib.h"
-//================================================
+// ================================================
// As a VarCheck library, we're linked into the VariableServices
// and may not be able to call them indirectly. To get around this,
// use the internal GetVariable function to query the variable store.
-//================================================
+// ================================================
EFI_STATUS
EFIAPI
VariableServiceGetVariable (
- IN CHAR16 *VariableName,
- IN EFI_GUID *VendorGuid,
- OUT UINT32 *Attributes OPTIONAL,
- IN OUT UINTN *DataSize,
- OUT VOID *Data
+ IN CHAR16 *VariableName,
+ IN EFI_GUID *VendorGuid,
+ OUT UINT32 *Attributes OPTIONAL,
+ IN OUT UINTN *DataSize,
+ OUT VOID *Data
);
-
-UINT8 mSecurityEvalBuffer[VAR_CHECK_POLICY_MM_COMM_BUFFER_SIZE];
+UINT8 mSecurityEvalBuffer[VAR_CHECK_POLICY_MM_COMM_BUFFER_SIZE];
// Pagination Cache Variables
-UINT8 *mPaginationCache = NULL;
-UINTN mPaginationCacheSize = 0;
-UINT32 mCurrentPaginationCommand = 0;
-
+UINT8 *mPaginationCache = NULL;
+UINTN mPaginationCacheSize = 0;
+UINT32 mCurrentPaginationCommand = 0;
/**
MM Communication Handler to recieve commands from the DXE protocol for
@@ -68,27 +66,27 @@ STATIC EFI_STATUS
EFIAPI
VarCheckPolicyLibMmiHandler (
- IN EFI_HANDLE DispatchHandle,
- IN CONST VOID *RegisterContext,
- IN OUT VOID *CommBuffer,
- IN OUT UINTN *CommBufferSize
+ IN EFI_HANDLE DispatchHandle,
+ IN CONST VOID *RegisterContext,
+ IN OUT VOID *CommBuffer,
+ IN OUT UINTN *CommBufferSize
)
{
- UINTN InternalCommBufferSize;
- VOID *InternalCommBuffer;
- EFI_STATUS Status;
- EFI_STATUS SubCommandStatus;
- VAR_CHECK_POLICY_COMM_HEADER *PolicyCommmHeader;
- VAR_CHECK_POLICY_COMM_HEADER *InternalPolicyCommmHeader;
- VAR_CHECK_POLICY_COMM_IS_ENABLED_PARAMS *IsEnabledParams;
- VAR_CHECK_POLICY_COMM_DUMP_PARAMS *DumpParamsIn;
- VAR_CHECK_POLICY_COMM_DUMP_PARAMS *DumpParamsOut;
- UINT8 *DumpInputBuffer;
- UINT8 *DumpOutputBuffer;
- UINTN DumpTotalPages;
- VARIABLE_POLICY_ENTRY *PolicyEntry;
- UINTN ExpectedSize;
- UINT32 TempSize;
+ UINTN InternalCommBufferSize;
+ VOID *InternalCommBuffer;
+ EFI_STATUS Status;
+ EFI_STATUS SubCommandStatus;
+ VAR_CHECK_POLICY_COMM_HEADER *PolicyCommmHeader;
+ VAR_CHECK_POLICY_COMM_HEADER *InternalPolicyCommmHeader;
+ VAR_CHECK_POLICY_COMM_IS_ENABLED_PARAMS *IsEnabledParams;
+ VAR_CHECK_POLICY_COMM_DUMP_PARAMS *DumpParamsIn;
+ VAR_CHECK_POLICY_COMM_DUMP_PARAMS *DumpParamsOut;
+ UINT8 *DumpInputBuffer;
+ UINT8 *DumpOutputBuffer;
+ UINTN DumpTotalPages;
+ VARIABLE_POLICY_ENTRY *PolicyEntry;
+ UINTN ExpectedSize;
+ UINT32 TempSize;
Status = EFI_SUCCESS;
@@ -96,22 +94,25 @@ VarCheckPolicyLibMmiHandler ( // Validate some input parameters.
//
// If either of the pointers are NULL, we can't proceed.
- if (CommBuffer == NULL || CommBufferSize == NULL) {
- DEBUG(( DEBUG_INFO, "%a - Invalid comm buffer pointers!\n", __FUNCTION__ ));
+ if ((CommBuffer == NULL) || (CommBufferSize == NULL)) {
+ DEBUG ((DEBUG_INFO, "%a - Invalid comm buffer pointers!\n", __FUNCTION__));
return EFI_INVALID_PARAMETER;
}
+
// Make sure that the buffer does not overlap SMM.
// This should be covered by the SmiManage infrastructure, but just to be safe...
InternalCommBufferSize = *CommBufferSize;
- if (InternalCommBufferSize > VAR_CHECK_POLICY_MM_COMM_BUFFER_SIZE ||
- !VarCheckPolicyIsBufferOutsideValid((UINTN)CommBuffer, (UINT64)InternalCommBufferSize)) {
+ if ((InternalCommBufferSize > VAR_CHECK_POLICY_MM_COMM_BUFFER_SIZE) ||
+ !VarCheckPolicyIsBufferOutsideValid ((UINTN)CommBuffer, (UINT64)InternalCommBufferSize))
+ {
DEBUG ((DEBUG_ERROR, "%a - Invalid CommBuffer supplied! 0x%016lX[0x%016lX]\n", __FUNCTION__, CommBuffer, InternalCommBufferSize));
return EFI_INVALID_PARAMETER;
}
+
// If the size does not meet a minimum threshold, we cannot proceed.
- ExpectedSize = sizeof(VAR_CHECK_POLICY_COMM_HEADER);
+ ExpectedSize = sizeof (VAR_CHECK_POLICY_COMM_HEADER);
if (InternalCommBufferSize < ExpectedSize) {
- DEBUG(( DEBUG_INFO, "%a - Bad comm buffer size! %d < %d\n", __FUNCTION__, InternalCommBufferSize, ExpectedSize ));
+ DEBUG ((DEBUG_INFO, "%a - Bad comm buffer size! %d < %d\n", __FUNCTION__, InternalCommBufferSize, ExpectedSize));
return EFI_INVALID_PARAMETER;
}
@@ -120,13 +121,14 @@ VarCheckPolicyLibMmiHandler ( // without worrying about TOCTOU.
//
InternalCommBuffer = &mSecurityEvalBuffer[0];
- CopyMem(InternalCommBuffer, CommBuffer, InternalCommBufferSize);
- PolicyCommmHeader = CommBuffer;
+ CopyMem (InternalCommBuffer, CommBuffer, InternalCommBufferSize);
+ PolicyCommmHeader = CommBuffer;
InternalPolicyCommmHeader = InternalCommBuffer;
// Check the revision and the signature of the comm header.
- if (InternalPolicyCommmHeader->Signature != VAR_CHECK_POLICY_COMM_SIG ||
- InternalPolicyCommmHeader->Revision != VAR_CHECK_POLICY_COMM_REVISION) {
- DEBUG(( DEBUG_INFO, "%a - Signature or revision are incorrect!\n", __FUNCTION__ ));
+ if ((InternalPolicyCommmHeader->Signature != VAR_CHECK_POLICY_COMM_SIG) ||
+ (InternalPolicyCommmHeader->Revision != VAR_CHECK_POLICY_COMM_REVISION))
+ {
+ DEBUG ((DEBUG_INFO, "%a - Signature or revision are incorrect!\n", __FUNCTION__));
// We have verified the buffer is not null and have enough size to hold Result field.
PolicyCommmHeader->Result = EFI_INVALID_PARAMETER;
return EFI_SUCCESS;
@@ -134,10 +136,10 @@ VarCheckPolicyLibMmiHandler ( // If we're in the middle of a paginated dump and any other command is sent,
// pagination cache must be cleared.
- if (mPaginationCache != NULL && InternalPolicyCommmHeader->Command != mCurrentPaginationCommand) {
+ if ((mPaginationCache != NULL) && (InternalPolicyCommmHeader->Command != mCurrentPaginationCommand)) {
FreePool (mPaginationCache);
- mPaginationCache = NULL;
- mPaginationCacheSize = 0;
+ mPaginationCache = NULL;
+ mPaginationCacheSize = 0;
mCurrentPaginationCommand = 0;
}
@@ -145,65 +147,66 @@ VarCheckPolicyLibMmiHandler ( // Now we can process the command as it was sent.
//
PolicyCommmHeader->Result = EFI_ABORTED; // Set a default return for incomplete commands.
- switch(InternalPolicyCommmHeader->Command) {
+ switch (InternalPolicyCommmHeader->Command) {
case VAR_CHECK_POLICY_COMMAND_DISABLE:
- PolicyCommmHeader->Result = DisableVariablePolicy();
+ PolicyCommmHeader->Result = DisableVariablePolicy ();
break;
case VAR_CHECK_POLICY_COMMAND_IS_ENABLED:
// Make sure that we're dealing with a reasonable size.
// This add should be safe because these are fixed sizes so far.
- ExpectedSize += sizeof(VAR_CHECK_POLICY_COMM_IS_ENABLED_PARAMS);
+ ExpectedSize += sizeof (VAR_CHECK_POLICY_COMM_IS_ENABLED_PARAMS);
if (InternalCommBufferSize < ExpectedSize) {
- DEBUG(( DEBUG_INFO, "%a - Bad comm buffer size! %d < %d\n", __FUNCTION__, InternalCommBufferSize, ExpectedSize ));
+ DEBUG ((DEBUG_INFO, "%a - Bad comm buffer size! %d < %d\n", __FUNCTION__, InternalCommBufferSize, ExpectedSize));
PolicyCommmHeader->Result = EFI_INVALID_PARAMETER;
break;
}
// Now that we know we've got a valid size, we can fill in the rest of the data.
- IsEnabledParams = (VAR_CHECK_POLICY_COMM_IS_ENABLED_PARAMS*)((UINT8*)CommBuffer + sizeof(VAR_CHECK_POLICY_COMM_HEADER));
- IsEnabledParams->State = IsVariablePolicyEnabled();
+ IsEnabledParams = (VAR_CHECK_POLICY_COMM_IS_ENABLED_PARAMS *)((UINT8 *)CommBuffer + sizeof (VAR_CHECK_POLICY_COMM_HEADER));
+ IsEnabledParams->State = IsVariablePolicyEnabled ();
PolicyCommmHeader->Result = EFI_SUCCESS;
break;
case VAR_CHECK_POLICY_COMMAND_REGISTER:
// Make sure that we're dealing with a reasonable size.
// This add should be safe because these are fixed sizes so far.
- ExpectedSize += sizeof(VARIABLE_POLICY_ENTRY);
+ ExpectedSize += sizeof (VARIABLE_POLICY_ENTRY);
if (InternalCommBufferSize < ExpectedSize) {
- DEBUG(( DEBUG_INFO, "%a - Bad comm buffer size! %d < %d\n", __FUNCTION__, InternalCommBufferSize, ExpectedSize ));
+ DEBUG ((DEBUG_INFO, "%a - Bad comm buffer size! %d < %d\n", __FUNCTION__, InternalCommBufferSize, ExpectedSize));
PolicyCommmHeader->Result = EFI_INVALID_PARAMETER;
break;
}
// At the very least, we can assume that we're working with a valid policy entry.
// Time to compare its internal size.
- PolicyEntry = (VARIABLE_POLICY_ENTRY*)((UINT8*)InternalCommBuffer + sizeof(VAR_CHECK_POLICY_COMM_HEADER));
- if (PolicyEntry->Version != VARIABLE_POLICY_ENTRY_REVISION ||
- PolicyEntry->Size < sizeof(VARIABLE_POLICY_ENTRY) ||
- EFI_ERROR(SafeUintnAdd(sizeof(VAR_CHECK_POLICY_COMM_HEADER), PolicyEntry->Size, &ExpectedSize)) ||
- InternalCommBufferSize < ExpectedSize) {
- DEBUG(( DEBUG_INFO, "%a - Bad policy entry contents!\n", __FUNCTION__ ));
+ PolicyEntry = (VARIABLE_POLICY_ENTRY *)((UINT8 *)InternalCommBuffer + sizeof (VAR_CHECK_POLICY_COMM_HEADER));
+ if ((PolicyEntry->Version != VARIABLE_POLICY_ENTRY_REVISION) ||
+ (PolicyEntry->Size < sizeof (VARIABLE_POLICY_ENTRY)) ||
+ EFI_ERROR (SafeUintnAdd (sizeof (VAR_CHECK_POLICY_COMM_HEADER), PolicyEntry->Size, &ExpectedSize)) ||
+ (InternalCommBufferSize < ExpectedSize))
+ {
+ DEBUG ((DEBUG_INFO, "%a - Bad policy entry contents!\n", __FUNCTION__));
PolicyCommmHeader->Result = EFI_INVALID_PARAMETER;
break;
}
- PolicyCommmHeader->Result = RegisterVariablePolicy( PolicyEntry );
+ PolicyCommmHeader->Result = RegisterVariablePolicy (PolicyEntry);
break;
case VAR_CHECK_POLICY_COMMAND_DUMP:
// Make sure that we're dealing with a reasonable size.
// This add should be safe because these are fixed sizes so far.
- ExpectedSize += sizeof(VAR_CHECK_POLICY_COMM_DUMP_PARAMS) + VAR_CHECK_POLICY_MM_DUMP_BUFFER_SIZE;
+ ExpectedSize += sizeof (VAR_CHECK_POLICY_COMM_DUMP_PARAMS) + VAR_CHECK_POLICY_MM_DUMP_BUFFER_SIZE;
if (InternalCommBufferSize < ExpectedSize) {
- DEBUG(( DEBUG_INFO, "%a - Bad comm buffer size! %d < %d\n", __FUNCTION__, InternalCommBufferSize, ExpectedSize ));
+ DEBUG ((DEBUG_INFO, "%a - Bad comm buffer size! %d < %d\n", __FUNCTION__, InternalCommBufferSize, ExpectedSize));
PolicyCommmHeader->Result = EFI_INVALID_PARAMETER;
break;
}
// Now that we know we've got a valid size, we can fill in the rest of the data.
- DumpParamsIn = (VAR_CHECK_POLICY_COMM_DUMP_PARAMS*)(InternalPolicyCommmHeader + 1);
- DumpParamsOut = (VAR_CHECK_POLICY_COMM_DUMP_PARAMS*)(PolicyCommmHeader + 1);
+ DumpParamsIn = (VAR_CHECK_POLICY_COMM_DUMP_PARAMS *)(InternalPolicyCommmHeader + 1);
+ DumpParamsOut = (VAR_CHECK_POLICY_COMM_DUMP_PARAMS *)(PolicyCommmHeader + 1);
// If we're requesting the first page, initialize the cache and get the sizes.
if (DumpParamsIn->PageRequested == 0) {
@@ -214,15 +217,15 @@ VarCheckPolicyLibMmiHandler ( // Determine what the required size is going to be.
DumpParamsOut->TotalSize = 0;
- DumpParamsOut->PageSize = 0;
- DumpParamsOut->HasMore = FALSE;
- TempSize = 0;
- SubCommandStatus = DumpVariablePolicy (NULL, &TempSize);
- if (SubCommandStatus == EFI_BUFFER_TOO_SMALL && TempSize > 0) {
+ DumpParamsOut->PageSize = 0;
+ DumpParamsOut->HasMore = FALSE;
+ TempSize = 0;
+ SubCommandStatus = DumpVariablePolicy (NULL, &TempSize);
+ if ((SubCommandStatus == EFI_BUFFER_TOO_SMALL) && (TempSize > 0)) {
mCurrentPaginationCommand = VAR_CHECK_POLICY_COMMAND_DUMP;
- mPaginationCacheSize = TempSize;
- DumpParamsOut->TotalSize = TempSize;
- mPaginationCache = AllocatePool (mPaginationCacheSize);
+ mPaginationCacheSize = TempSize;
+ DumpParamsOut->TotalSize = TempSize;
+ mPaginationCache = AllocatePool (mPaginationCacheSize);
if (mPaginationCache == NULL) {
SubCommandStatus = EFI_OUT_OF_RESOURCES;
}
@@ -234,39 +237,41 @@ VarCheckPolicyLibMmiHandler ( }
// Populate the remaining fields and we can boogie.
- if (!EFI_ERROR (SubCommandStatus) && mPaginationCache != NULL) {
+ if (!EFI_ERROR (SubCommandStatus) && (mPaginationCache != NULL)) {
DumpParamsOut->HasMore = TRUE;
}
} else if (mPaginationCache != NULL) {
DumpParamsOut->TotalSize = (UINT32)mPaginationCacheSize;
- DumpOutputBuffer = (UINT8*)(DumpParamsOut + 1);
+ DumpOutputBuffer = (UINT8 *)(DumpParamsOut + 1);
// Make sure that we don't over-index the cache.
DumpTotalPages = mPaginationCacheSize / VAR_CHECK_POLICY_MM_DUMP_BUFFER_SIZE;
if (mPaginationCacheSize % VAR_CHECK_POLICY_MM_DUMP_BUFFER_SIZE != 0) {
DumpTotalPages++;
}
+
if (DumpParamsIn->PageRequested > DumpTotalPages) {
SubCommandStatus = EFI_INVALID_PARAMETER;
} else {
// Figure out how far into the page cache we need to go for our next page.
// We know the blind subtraction won't be bad because we already checked for page 0.
DumpInputBuffer = &mPaginationCache[VAR_CHECK_POLICY_MM_DUMP_BUFFER_SIZE * (DumpParamsIn->PageRequested - 1)];
- TempSize = VAR_CHECK_POLICY_MM_DUMP_BUFFER_SIZE;
+ TempSize = VAR_CHECK_POLICY_MM_DUMP_BUFFER_SIZE;
// If we're getting the last page, adjust the PageSize.
if (DumpParamsIn->PageRequested == DumpTotalPages) {
TempSize = mPaginationCacheSize % VAR_CHECK_POLICY_MM_DUMP_BUFFER_SIZE;
}
+
CopyMem (DumpOutputBuffer, DumpInputBuffer, TempSize);
DumpParamsOut->PageSize = TempSize;
// If we just got the last page, settle up the cache.
if (DumpParamsIn->PageRequested == DumpTotalPages) {
DumpParamsOut->HasMore = FALSE;
FreePool (mPaginationCache);
- mPaginationCache = NULL;
- mPaginationCacheSize = 0;
+ mPaginationCache = NULL;
+ mPaginationCacheSize = 0;
mCurrentPaginationCommand = 0;
- // Otherwise, we could do more here.
+ // Otherwise, we could do more here.
} else {
DumpParamsOut->HasMore = TRUE;
}
@@ -274,12 +279,13 @@ VarCheckPolicyLibMmiHandler ( // If we made it this far, we're basically good.
SubCommandStatus = EFI_SUCCESS;
}
- // If we've requested any other page than 0 and the cache is empty, we must have timed out.
+
+ // If we've requested any other page than 0 and the cache is empty, we must have timed out.
} else {
DumpParamsOut->TotalSize = 0;
- DumpParamsOut->PageSize = 0;
- DumpParamsOut->HasMore = FALSE;
- SubCommandStatus = EFI_TIMEOUT;
+ DumpParamsOut->PageSize = 0;
+ DumpParamsOut->HasMore = FALSE;
+ SubCommandStatus = EFI_TIMEOUT;
}
// There's currently no use for this, but it shouldn't be hard to implement.
@@ -287,23 +293,27 @@ VarCheckPolicyLibMmiHandler ( break;
case VAR_CHECK_POLICY_COMMAND_LOCK:
- PolicyCommmHeader->Result = LockVariablePolicy();
+ PolicyCommmHeader->Result = LockVariablePolicy ();
break;
default:
// Mark unknown requested command as EFI_UNSUPPORTED.
- DEBUG(( DEBUG_INFO, "%a - Invalid command requested! %d\n", __FUNCTION__, PolicyCommmHeader->Command ));
+ DEBUG ((DEBUG_INFO, "%a - Invalid command requested! %d\n", __FUNCTION__, PolicyCommmHeader->Command));
PolicyCommmHeader->Result = EFI_UNSUPPORTED;
break;
}
- DEBUG(( DEBUG_VERBOSE, "%a - Command %d returning %r.\n", __FUNCTION__,
- PolicyCommmHeader->Command, PolicyCommmHeader->Result ));
+ DEBUG ((
+ DEBUG_VERBOSE,
+ "%a - Command %d returning %r.\n",
+ __FUNCTION__,
+ PolicyCommmHeader->Command,
+ PolicyCommmHeader->Result
+ ));
return Status;
}
-
/**
Constructor function of VarCheckPolicyLib to register VarCheck handler and
SW MMI handlers.
@@ -317,28 +327,30 @@ VarCheckPolicyLibCommonConstructor ( VOID
)
{
- EFI_STATUS Status;
- EFI_HANDLE DiscardedHandle;
+ EFI_STATUS Status;
+ EFI_HANDLE DiscardedHandle;
// Initialize the business logic with the internal GetVariable handler.
- Status = InitVariablePolicyLib( VariableServiceGetVariable );
+ Status = InitVariablePolicyLib (VariableServiceGetVariable);
// Only proceed with init if the business logic could be initialized.
- if (!EFI_ERROR( Status )) {
+ if (!EFI_ERROR (Status)) {
// Register the VarCheck handler for SetVariable filtering.
// Forward the check to the business logic of the library.
- VarCheckLibRegisterSetVariableCheckHandler( ValidateSetVariable );
+ VarCheckLibRegisterSetVariableCheckHandler (ValidateSetVariable);
// Register the MMI handlers for receiving policy commands.
DiscardedHandle = NULL;
- Status = gMmst->MmiHandlerRegister( VarCheckPolicyLibMmiHandler,
- &gVarCheckPolicyLibMmiHandlerGuid,
- &DiscardedHandle );
+ Status = gMmst->MmiHandlerRegister (
+ VarCheckPolicyLibMmiHandler,
+ &gVarCheckPolicyLibMmiHandlerGuid,
+ &DiscardedHandle
+ );
}
// Otherwise, there's not much we can do.
else {
- DEBUG(( DEBUG_ERROR, "%a - Cannot Initialize VariablePolicyLib! %r\n", __FUNCTION__, Status ));
- ASSERT_EFI_ERROR( Status );
+ DEBUG ((DEBUG_ERROR, "%a - Cannot Initialize VariablePolicyLib! %r\n", __FUNCTION__, Status));
+ ASSERT_EFI_ERROR (Status);
}
return Status;
diff --git a/MdeModulePkg/Library/VarCheckPolicyLib/VarCheckPolicyLibStandaloneMm.c b/MdeModulePkg/Library/VarCheckPolicyLib/VarCheckPolicyLibStandaloneMm.c index b283ced9d4..784a2422aa 100644 --- a/MdeModulePkg/Library/VarCheckPolicyLib/VarCheckPolicyLibStandaloneMm.c +++ b/MdeModulePkg/Library/VarCheckPolicyLib/VarCheckPolicyLibStandaloneMm.c @@ -23,8 +23,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent EFI_STATUS
EFIAPI
VarCheckPolicyLibStandaloneConstructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_MM_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_MM_SYSTEM_TABLE *SystemTable
)
{
return VarCheckPolicyLibCommonConstructor ();
diff --git a/MdeModulePkg/Library/VarCheckPolicyLib/VarCheckPolicyLibTraditional.c b/MdeModulePkg/Library/VarCheckPolicyLib/VarCheckPolicyLibTraditional.c index f404aaaa47..07bead2724 100644 --- a/MdeModulePkg/Library/VarCheckPolicyLib/VarCheckPolicyLibTraditional.c +++ b/MdeModulePkg/Library/VarCheckPolicyLib/VarCheckPolicyLibTraditional.c @@ -23,8 +23,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent EFI_STATUS
EFIAPI
VarCheckPolicyLibTraditionalConstructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
return VarCheckPolicyLibCommonConstructor ();
diff --git a/MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLibNullClass.c b/MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLibNullClass.c index 5767213224..9fbfd9df02 100644 --- a/MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLibNullClass.c +++ b/MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLibNullClass.c @@ -21,16 +21,16 @@ SPDX-License-Identifier: BSD-2-Clause-Patent typedef
EFI_STATUS
-(EFIAPI *INTERNAL_VAR_CHECK_FUNCTION) (
+(EFIAPI *INTERNAL_VAR_CHECK_FUNCTION)(
IN VAR_CHECK_VARIABLE_PROPERTY *Propery,
IN UINTN DataSize,
IN VOID *Data
);
typedef struct {
- CHAR16 *Name;
- VAR_CHECK_VARIABLE_PROPERTY VariableProperty;
- INTERNAL_VAR_CHECK_FUNCTION CheckFunction;
+ CHAR16 *Name;
+ VAR_CHECK_VARIABLE_PROPERTY VariableProperty;
+ INTERNAL_VAR_CHECK_FUNCTION CheckFunction;
} UEFI_DEFINED_VARIABLE_ENTRY;
/**
@@ -47,45 +47,51 @@ typedef struct { EFI_STATUS
EFIAPI
InternalVarCheckLoadOption (
- IN VAR_CHECK_VARIABLE_PROPERTY *VariablePropery,
- IN UINTN DataSize,
- IN VOID *Data
+ IN VAR_CHECK_VARIABLE_PROPERTY *VariablePropery,
+ IN UINTN DataSize,
+ IN VOID *Data
)
{
UINT16 FilePathListLength;
CHAR16 *Description;
EFI_DEVICE_PATH_PROTOCOL *FilePathList;
- FilePathListLength = *((UINT16 *) ((UINTN) Data + sizeof (UINT32)));
+ FilePathListLength = *((UINT16 *)((UINTN)Data + sizeof (UINT32)));
//
// Check Description
//
- Description = (CHAR16 *) ((UINTN) Data + sizeof (UINT32) + sizeof (UINT16));
- while (Description < (CHAR16 *) ((UINTN) Data + DataSize)) {
+ Description = (CHAR16 *)((UINTN)Data + sizeof (UINT32) + sizeof (UINT16));
+ while (Description < (CHAR16 *)((UINTN)Data + DataSize)) {
if (*Description == L'\0') {
break;
}
+
Description++;
}
- if ((UINTN) Description >= ((UINTN) Data + DataSize)) {
+
+ if ((UINTN)Description >= ((UINTN)Data + DataSize)) {
return EFI_INVALID_PARAMETER;
}
+
Description++;
//
// Check FilePathList
//
- FilePathList = (EFI_DEVICE_PATH_PROTOCOL *) Description;
- if ((UINTN) FilePathList > (MAX_ADDRESS - FilePathListLength)) {
+ FilePathList = (EFI_DEVICE_PATH_PROTOCOL *)Description;
+ if ((UINTN)FilePathList > (MAX_ADDRESS - FilePathListLength)) {
return EFI_INVALID_PARAMETER;
}
- if (((UINTN) FilePathList + FilePathListLength) > ((UINTN) Data + DataSize)) {
+
+ if (((UINTN)FilePathList + FilePathListLength) > ((UINTN)Data + DataSize)) {
return EFI_INVALID_PARAMETER;
}
+
if (FilePathListLength < sizeof (EFI_DEVICE_PATH_PROTOCOL)) {
return EFI_INVALID_PARAMETER;
}
+
if (!IsDevicePathValid (FilePathList, FilePathListLength)) {
return EFI_INVALID_PARAMETER;
}
@@ -107,9 +113,9 @@ InternalVarCheckLoadOption ( EFI_STATUS
EFIAPI
InternalVarCheckKeyOption (
- IN VAR_CHECK_VARIABLE_PROPERTY *VariablePropery,
- IN UINTN DataSize,
- IN VOID *Data
+ IN VAR_CHECK_VARIABLE_PROPERTY *VariablePropery,
+ IN UINTN DataSize,
+ IN VOID *Data
)
{
if (((DataSize - sizeof (EFI_KEY_OPTION)) % sizeof (EFI_INPUT_KEY)) != 0) {
@@ -133,14 +139,15 @@ InternalVarCheckKeyOption ( EFI_STATUS
EFIAPI
InternalVarCheckDevicePath (
- IN VAR_CHECK_VARIABLE_PROPERTY *VariablePropery,
- IN UINTN DataSize,
- IN VOID *Data
+ IN VAR_CHECK_VARIABLE_PROPERTY *VariablePropery,
+ IN UINTN DataSize,
+ IN VOID *Data
)
{
- if (!IsDevicePathValid ((EFI_DEVICE_PATH_PROTOCOL *) Data, DataSize)) {
+ if (!IsDevicePathValid ((EFI_DEVICE_PATH_PROTOCOL *)Data, DataSize)) {
return EFI_INVALID_PARAMETER;
}
+
return EFI_SUCCESS;
}
@@ -158,23 +165,26 @@ InternalVarCheckDevicePath ( EFI_STATUS
EFIAPI
InternalVarCheckAsciiString (
- IN VAR_CHECK_VARIABLE_PROPERTY *VariablePropery,
- IN UINTN DataSize,
- IN VOID *Data
+ IN VAR_CHECK_VARIABLE_PROPERTY *VariablePropery,
+ IN UINTN DataSize,
+ IN VOID *Data
)
{
- CHAR8 *String;
- UINTN Index;
+ CHAR8 *String;
+ UINTN Index;
- String = (CHAR8 *) Data;
+ String = (CHAR8 *)Data;
if (String[DataSize - 1] == '\0') {
return EFI_SUCCESS;
} else {
- for (Index = 1; Index < DataSize && (String[DataSize - 1 - Index] != '\0'); Index++);
+ for (Index = 1; Index < DataSize && (String[DataSize - 1 - Index] != '\0'); Index++) {
+ }
+
if (Index == DataSize) {
return EFI_INVALID_PARAMETER;
}
}
+
return EFI_SUCCESS;
}
@@ -192,14 +202,15 @@ InternalVarCheckAsciiString ( EFI_STATUS
EFIAPI
InternalVarCheckSizeArray (
- IN VAR_CHECK_VARIABLE_PROPERTY *VariablePropery,
- IN UINTN DataSize,
- IN VOID *Data
+ IN VAR_CHECK_VARIABLE_PROPERTY *VariablePropery,
+ IN UINTN DataSize,
+ IN VOID *Data
)
{
if ((DataSize % VariablePropery->MinSize) != 0) {
return EFI_INVALID_PARAMETER;
}
+
return EFI_SUCCESS;
}
@@ -211,7 +222,7 @@ InternalVarCheckSizeArray ( // only permit the creation of variables with a UEFI Specification-defined
// VendorGuid when these variables are documented in the UEFI Specification.
//
-UEFI_DEFINED_VARIABLE_ENTRY mGlobalVariableList[] = {
+UEFI_DEFINED_VARIABLE_ENTRY mGlobalVariableList[] = {
{
EFI_LANG_CODES_VARIABLE_NAME,
{
@@ -555,7 +566,7 @@ UEFI_DEFINED_VARIABLE_ENTRY mGlobalVariableList[] = { },
};
-UEFI_DEFINED_VARIABLE_ENTRY mGlobalVariableList2[] = {
+UEFI_DEFINED_VARIABLE_ENTRY mGlobalVariableList2[] = {
{
L"Boot####",
{
@@ -616,7 +627,7 @@ UEFI_DEFINED_VARIABLE_ENTRY mGlobalVariableList2[] = { //
// EFI_IMAGE_SECURITY_DATABASE_GUID
//
-UEFI_DEFINED_VARIABLE_ENTRY mImageSecurityVariableList[] = {
+UEFI_DEFINED_VARIABLE_ENTRY mImageSecurityVariableList[] = {
{
EFI_IMAGE_SECURITY_DATABASE,
{
@@ -655,7 +666,7 @@ UEFI_DEFINED_VARIABLE_ENTRY mImageSecurityVariableList[] = { //
// EFI_HARDWARE_ERROR_VARIABLE
//
-UEFI_DEFINED_VARIABLE_ENTRY mHwErrRecVariable = {
+UEFI_DEFINED_VARIABLE_ENTRY mHwErrRecVariable = {
L"HwErrRec####",
{
VAR_CHECK_VARIABLE_PROPERTY_REVISION,
@@ -667,7 +678,7 @@ UEFI_DEFINED_VARIABLE_ENTRY mHwErrRecVariable = { NULL
};
-EFI_GUID *mUefiDefinedGuid[] = {
+EFI_GUID *mUefiDefinedGuid[] = {
&gEfiGlobalVariableGuid,
&gEfiImageSecurityDatabaseGuid,
&gEfiHardwareErrorVariableGuid
@@ -690,10 +701,10 @@ EFI_GUID *mUefiDefinedGuid[] = { BOOLEAN
EFIAPI
VarCheckUefiIsHexaDecimalDigitCharacter (
- IN CHAR16 Char
+ IN CHAR16 Char
)
{
- return (BOOLEAN) ((Char >= L'0' && Char <= L'9') || (Char >= L'A' && Char <= L'F'));
+ return (BOOLEAN)((Char >= L'0' && Char <= L'9') || (Char >= L'A' && Char <= L'F'));
}
/**
@@ -713,17 +724,18 @@ VarCheckUefiIsHexaDecimalDigitCharacter ( BOOLEAN
EFIAPI
IsHwErrRecVariable (
- IN CHAR16 *VariableName,
- IN EFI_GUID *VendorGuid
+ IN CHAR16 *VariableName,
+ IN EFI_GUID *VendorGuid
)
{
if (!CompareGuid (VendorGuid, &gEfiHardwareErrorVariableGuid) ||
(StrLen (VariableName) != StrLen (L"HwErrRec####")) ||
- (StrnCmp(VariableName, L"HwErrRec", StrLen (L"HwErrRec")) != 0) ||
+ (StrnCmp (VariableName, L"HwErrRec", StrLen (L"HwErrRec")) != 0) ||
!VarCheckUefiIsHexaDecimalDigitCharacter (VariableName[0x8]) ||
!VarCheckUefiIsHexaDecimalDigitCharacter (VariableName[0x9]) ||
!VarCheckUefiIsHexaDecimalDigitCharacter (VariableName[0xA]) ||
- !VarCheckUefiIsHexaDecimalDigitCharacter (VariableName[0xB])) {
+ !VarCheckUefiIsHexaDecimalDigitCharacter (VariableName[0xB]))
+ {
return FALSE;
}
@@ -742,13 +754,13 @@ IsHwErrRecVariable ( **/
INTERNAL_VAR_CHECK_FUNCTION
GetUefiDefinedVarCheckFunction (
- IN CHAR16 *VariableName,
- IN EFI_GUID *VendorGuid,
- OUT VAR_CHECK_VARIABLE_PROPERTY **VariableProperty
+ IN CHAR16 *VariableName,
+ IN EFI_GUID *VendorGuid,
+ OUT VAR_CHECK_VARIABLE_PROPERTY **VariableProperty
)
{
- UINTN Index;
- UINTN NameLength;
+ UINTN Index;
+ UINTN NameLength;
if (CompareGuid (VendorGuid, &gEfiGlobalVariableGuid)) {
//
@@ -771,7 +783,8 @@ GetUefiDefinedVarCheckFunction ( VarCheckUefiIsHexaDecimalDigitCharacter (VariableName[NameLength]) &&
VarCheckUefiIsHexaDecimalDigitCharacter (VariableName[NameLength + 1]) &&
VarCheckUefiIsHexaDecimalDigitCharacter (VariableName[NameLength + 2]) &&
- VarCheckUefiIsHexaDecimalDigitCharacter (VariableName[NameLength + 3])) {
+ VarCheckUefiIsHexaDecimalDigitCharacter (VariableName[NameLength + 3]))
+ {
*VariableProperty = &(mGlobalVariableList2[Index].VariableProperty);
return mGlobalVariableList2[Index].CheckFunction;
}
@@ -799,18 +812,18 @@ GetUefiDefinedVarCheckFunction ( EFI_STATUS
EFIAPI
SetVariableCheckHandlerUefiDefined (
- IN CHAR16 *VariableName,
- IN EFI_GUID *VendorGuid,
- IN UINT32 Attributes,
- IN UINTN DataSize,
- IN VOID *Data
+ IN CHAR16 *VariableName,
+ IN EFI_GUID *VendorGuid,
+ IN UINT32 Attributes,
+ IN UINTN DataSize,
+ IN VOID *Data
)
{
- EFI_STATUS Status;
- UINTN Index;
- VAR_CHECK_VARIABLE_PROPERTY Property;
- VAR_CHECK_VARIABLE_PROPERTY *VarCheckProperty;
- INTERNAL_VAR_CHECK_FUNCTION VarCheckFunction;
+ EFI_STATUS Status;
+ UINTN Index;
+ VAR_CHECK_VARIABLE_PROPERTY Property;
+ VAR_CHECK_VARIABLE_PROPERTY *VarCheckProperty;
+ INTERNAL_VAR_CHECK_FUNCTION VarCheckFunction;
if ((((Attributes & EFI_VARIABLE_APPEND_WRITE) == 0) && (DataSize == 0)) || (Attributes == 0)) {
//
@@ -872,7 +885,7 @@ VariablePropertySetUefiDefined ( VOID
)
{
- UINTN Index;
+ UINTN Index;
//
// EFI_GLOBAL_VARIABLE
@@ -884,6 +897,7 @@ VariablePropertySetUefiDefined ( &mGlobalVariableList[Index].VariableProperty
);
}
+
for (Index = 0; Index < sizeof (mGlobalVariableList2)/sizeof (mGlobalVariableList2[0]); Index++) {
VarCheckLibVariablePropertySet (
mGlobalVariableList2[Index].Name,
diff --git a/MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.c b/MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.c index 6bcb95247f..e82e91f7aa 100644 --- a/MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.c +++ b/MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.c @@ -36,22 +36,22 @@ SPDX-License-Identifier: BSD-2-Clause-Patent STATIC
VOID
PopulateCommonData (
- OUT VARIABLE_POLICY_ENTRY *EntPtr,
- IN CONST EFI_GUID *Namespace,
- IN UINT32 MinSize,
- IN UINT32 MaxSize,
- IN UINT32 AttributesMustHave,
- IN UINT32 AttributesCantHave,
- IN UINT8 LockPolicyType
+ OUT VARIABLE_POLICY_ENTRY *EntPtr,
+ IN CONST EFI_GUID *Namespace,
+ IN UINT32 MinSize,
+ IN UINT32 MaxSize,
+ IN UINT32 AttributesMustHave,
+ IN UINT32 AttributesCantHave,
+ IN UINT8 LockPolicyType
)
{
- EntPtr->Version = VARIABLE_POLICY_ENTRY_REVISION;
- CopyGuid( &EntPtr->Namespace, Namespace );
- EntPtr->MinSize = MinSize;
- EntPtr->MaxSize = MaxSize;
- EntPtr->AttributesMustHave = AttributesMustHave;
- EntPtr->AttributesCantHave = AttributesCantHave;
- EntPtr->LockPolicyType = LockPolicyType;
+ EntPtr->Version = VARIABLE_POLICY_ENTRY_REVISION;
+ CopyGuid (&EntPtr->Namespace, Namespace);
+ EntPtr->MinSize = MinSize;
+ EntPtr->MaxSize = MaxSize;
+ EntPtr->AttributesMustHave = AttributesMustHave;
+ EntPtr->AttributesCantHave = AttributesCantHave;
+ EntPtr->LockPolicyType = LockPolicyType;
// NOTE: As a heler, fix up MaxSize for compatibility with the old model.
if (EntPtr->MaxSize == 0) {
@@ -61,7 +61,6 @@ PopulateCommonData ( return;
}
-
/**
This helper function will allocate and populate a new VariablePolicy
structure for a policy that does not contain any sub-structures (such as
@@ -90,51 +89,54 @@ PopulateCommonData ( EFI_STATUS
EFIAPI
CreateBasicVariablePolicy (
- IN CONST EFI_GUID *Namespace,
- IN CONST CHAR16 *Name OPTIONAL,
- IN UINT32 MinSize,
- IN UINT32 MaxSize,
- IN UINT32 AttributesMustHave,
- IN UINT32 AttributesCantHave,
- IN UINT8 LockPolicyType,
- OUT VARIABLE_POLICY_ENTRY **NewEntry
+ IN CONST EFI_GUID *Namespace,
+ IN CONST CHAR16 *Name OPTIONAL,
+ IN UINT32 MinSize,
+ IN UINT32 MaxSize,
+ IN UINT32 AttributesMustHave,
+ IN UINT32 AttributesCantHave,
+ IN UINT8 LockPolicyType,
+ OUT VARIABLE_POLICY_ENTRY **NewEntry
)
{
- UINTN TotalSize;
- UINTN NameSize;
- VARIABLE_POLICY_ENTRY *EntPtr;
- CHAR16 *CopyName;
+ UINTN TotalSize;
+ UINTN NameSize;
+ VARIABLE_POLICY_ENTRY *EntPtr;
+ CHAR16 *CopyName;
// Check some initial invalid parameters for this function.
- if (Namespace == NULL || NewEntry == NULL) {
+ if ((Namespace == NULL) || (NewEntry == NULL)) {
return EFI_INVALID_PARAMETER;
}
- if (LockPolicyType != VARIABLE_POLICY_TYPE_NO_LOCK &&
- LockPolicyType != VARIABLE_POLICY_TYPE_LOCK_NOW &&
- LockPolicyType != VARIABLE_POLICY_TYPE_LOCK_ON_CREATE) {
+
+ if ((LockPolicyType != VARIABLE_POLICY_TYPE_NO_LOCK) &&
+ (LockPolicyType != VARIABLE_POLICY_TYPE_LOCK_NOW) &&
+ (LockPolicyType != VARIABLE_POLICY_TYPE_LOCK_ON_CREATE))
+ {
return EFI_INVALID_PARAMETER;
}
//
// Set NameSize to suppress incorrect compiler/analyzer warnings
//
- NameSize = 0;
+ NameSize = 0;
// Now we've gotta determine the total size of the buffer required for
// the VariablePolicy structure.
- TotalSize = sizeof( VARIABLE_POLICY_ENTRY );
+ TotalSize = sizeof (VARIABLE_POLICY_ENTRY);
if (Name != NULL) {
- NameSize = StrnSizeS( Name, MAX_UINT16 );
+ NameSize = StrnSizeS (Name, MAX_UINT16);
TotalSize += NameSize;
}
+
// Make sure the size fits within a VARIABLE_POLICY_ENTRY.Size.
- ASSERT( TotalSize <= MAX_UINT16 );
+ ASSERT (TotalSize <= MAX_UINT16);
if (TotalSize > MAX_UINT16) {
return EFI_BUFFER_TOO_SMALL;
}
// Allocate a buffer to hold all the data. We're on the home stretch.
- *NewEntry = AllocatePool( TotalSize );
+ *NewEntry = AllocatePool (TotalSize);
if (*NewEntry == NULL) {
return EFI_OUT_OF_RESOURCES;
}
@@ -142,24 +144,25 @@ CreateBasicVariablePolicy ( // If we're still here, we're basically done.
// Copy the data and GET... OUT....
EntPtr = *NewEntry;
- PopulateCommonData ( EntPtr,
- Namespace,
- MinSize,
- MaxSize,
- AttributesMustHave,
- AttributesCantHave,
- LockPolicyType );
- EntPtr->Size = (UINT16)TotalSize; // This is safe because we've already checked.
- EntPtr->OffsetToName = sizeof(VARIABLE_POLICY_ENTRY);
+ PopulateCommonData (
+ EntPtr,
+ Namespace,
+ MinSize,
+ MaxSize,
+ AttributesMustHave,
+ AttributesCantHave,
+ LockPolicyType
+ );
+ EntPtr->Size = (UINT16)TotalSize; // This is safe because we've already checked.
+ EntPtr->OffsetToName = sizeof (VARIABLE_POLICY_ENTRY);
if (Name != NULL) {
- CopyName = (CHAR16*)((UINT8*)EntPtr + EntPtr->OffsetToName);
- CopyMem( CopyName, Name, NameSize );
+ CopyName = (CHAR16 *)((UINT8 *)EntPtr + EntPtr->OffsetToName);
+ CopyMem (CopyName, Name, NameSize);
}
return EFI_SUCCESS;
}
-
/**
This helper function will allocate and populate a new VariablePolicy
structure for a policy with a lock type of VARIABLE_POLICY_TYPE_LOCK_ON_VAR_STATE.
@@ -188,49 +191,51 @@ CreateBasicVariablePolicy ( EFI_STATUS
EFIAPI
CreateVarStateVariablePolicy (
- IN CONST EFI_GUID *Namespace,
- IN CONST CHAR16 *Name OPTIONAL,
- IN UINT32 MinSize,
- IN UINT32 MaxSize,
- IN UINT32 AttributesMustHave,
- IN UINT32 AttributesCantHave,
- IN CONST EFI_GUID *VarStateNamespace,
- IN UINT8 VarStateValue,
- IN CONST CHAR16 *VarStateName,
- OUT VARIABLE_POLICY_ENTRY **NewEntry
+ IN CONST EFI_GUID *Namespace,
+ IN CONST CHAR16 *Name OPTIONAL,
+ IN UINT32 MinSize,
+ IN UINT32 MaxSize,
+ IN UINT32 AttributesMustHave,
+ IN UINT32 AttributesCantHave,
+ IN CONST EFI_GUID *VarStateNamespace,
+ IN UINT8 VarStateValue,
+ IN CONST CHAR16 *VarStateName,
+ OUT VARIABLE_POLICY_ENTRY **NewEntry
)
{
- UINTN TotalSize;
- UINTN NameSize;
- UINTN VarStateNameSize;
- VARIABLE_POLICY_ENTRY *EntPtr;
- CHAR16 *CopyName;
- VARIABLE_LOCK_ON_VAR_STATE_POLICY *CopyPolicy;
+ UINTN TotalSize;
+ UINTN NameSize;
+ UINTN VarStateNameSize;
+ VARIABLE_POLICY_ENTRY *EntPtr;
+ CHAR16 *CopyName;
+ VARIABLE_LOCK_ON_VAR_STATE_POLICY *CopyPolicy;
// Check some initial invalid parameters for this function.
- if (Namespace == NULL || VarStateNamespace == NULL ||
- VarStateName == NULL || NewEntry == NULL) {
+ if ((Namespace == NULL) || (VarStateNamespace == NULL) ||
+ (VarStateName == NULL) || (NewEntry == NULL))
+ {
return EFI_INVALID_PARAMETER;
}
// Now we've gotta determine the total size of the buffer required for
// the VariablePolicy structure.
- VarStateNameSize = StrnSizeS( VarStateName, MAX_UINT16 );
- TotalSize = sizeof( VARIABLE_POLICY_ENTRY ) +
- sizeof(VARIABLE_LOCK_ON_VAR_STATE_POLICY) +
- VarStateNameSize;
+ VarStateNameSize = StrnSizeS (VarStateName, MAX_UINT16);
+ TotalSize = sizeof (VARIABLE_POLICY_ENTRY) +
+ sizeof (VARIABLE_LOCK_ON_VAR_STATE_POLICY) +
+ VarStateNameSize;
if (Name != NULL) {
- NameSize = StrnSizeS( Name, MAX_UINT16 );
+ NameSize = StrnSizeS (Name, MAX_UINT16);
TotalSize += NameSize;
}
+
// Make sure the size fits within a VARIABLE_POLICY_ENTRY.Size.
- ASSERT( TotalSize <= MAX_UINT16 );
+ ASSERT (TotalSize <= MAX_UINT16);
if (TotalSize > MAX_UINT16) {
return EFI_BUFFER_TOO_SMALL;
}
// Allocate a buffer to hold all the data. We're on the home stretch.
- *NewEntry = AllocatePool( TotalSize );
+ *NewEntry = AllocatePool (TotalSize);
if (*NewEntry == NULL) {
return EFI_OUT_OF_RESOURCES;
}
@@ -238,33 +243,34 @@ CreateVarStateVariablePolicy ( // If we're still here, we're basically done.
// Copy the data and GET... OUT....
EntPtr = *NewEntry;
- PopulateCommonData ( EntPtr,
- Namespace,
- MinSize,
- MaxSize,
- AttributesMustHave,
- AttributesCantHave,
- VARIABLE_POLICY_TYPE_LOCK_ON_VAR_STATE );
- EntPtr->Size = (UINT16)TotalSize; // This is safe because we've already checked.
- EntPtr->OffsetToName = sizeof(VARIABLE_POLICY_ENTRY) +
- sizeof(VARIABLE_LOCK_ON_VAR_STATE_POLICY) +
- (UINT16)VarStateNameSize;
-
- CopyPolicy = (VARIABLE_LOCK_ON_VAR_STATE_POLICY*)((UINT8*)EntPtr + sizeof(VARIABLE_POLICY_ENTRY));
- CopyName = (CHAR16*)((UINT8*)CopyPolicy + sizeof(VARIABLE_LOCK_ON_VAR_STATE_POLICY));
- CopyGuid( &CopyPolicy->Namespace, VarStateNamespace );
+ PopulateCommonData (
+ EntPtr,
+ Namespace,
+ MinSize,
+ MaxSize,
+ AttributesMustHave,
+ AttributesCantHave,
+ VARIABLE_POLICY_TYPE_LOCK_ON_VAR_STATE
+ );
+ EntPtr->Size = (UINT16)TotalSize; // This is safe because we've already checked.
+ EntPtr->OffsetToName = sizeof (VARIABLE_POLICY_ENTRY) +
+ sizeof (VARIABLE_LOCK_ON_VAR_STATE_POLICY) +
+ (UINT16)VarStateNameSize;
+
+ CopyPolicy = (VARIABLE_LOCK_ON_VAR_STATE_POLICY *)((UINT8 *)EntPtr + sizeof (VARIABLE_POLICY_ENTRY));
+ CopyName = (CHAR16 *)((UINT8 *)CopyPolicy + sizeof (VARIABLE_LOCK_ON_VAR_STATE_POLICY));
+ CopyGuid (&CopyPolicy->Namespace, VarStateNamespace);
CopyPolicy->Value = VarStateValue;
- CopyMem( CopyName, VarStateName, VarStateNameSize );
+ CopyMem (CopyName, VarStateName, VarStateNameSize);
if (Name != NULL) {
- CopyName = (CHAR16*)((UINT8*)EntPtr + EntPtr->OffsetToName);
- CopyMem( CopyName, Name, NameSize );
+ CopyName = (CHAR16 *)((UINT8 *)EntPtr + EntPtr->OffsetToName);
+ CopyMem (CopyName, Name, NameSize);
}
return EFI_SUCCESS;
}
-
/**
This helper function does everything that CreateBasicVariablePolicy() does, but also
uses the passed in protocol to register the policy with the infrastructure.
@@ -297,8 +303,8 @@ RegisterBasicVariablePolicy ( IN UINT8 LockPolicyType
)
{
- VARIABLE_POLICY_ENTRY *NewEntry;
- EFI_STATUS Status;
+ VARIABLE_POLICY_ENTRY *NewEntry;
+ EFI_STATUS Status;
// Check the simple things.
if (VariablePolicy == NULL) {
@@ -307,29 +313,30 @@ RegisterBasicVariablePolicy ( // Create the new entry and make sure that everything worked.
NewEntry = NULL;
- Status = CreateBasicVariablePolicy( Namespace,
- Name,
- MinSize,
- MaxSize,
- AttributesMustHave,
- AttributesCantHave,
- LockPolicyType,
- &NewEntry );
+ Status = CreateBasicVariablePolicy (
+ Namespace,
+ Name,
+ MinSize,
+ MaxSize,
+ AttributesMustHave,
+ AttributesCantHave,
+ LockPolicyType,
+ &NewEntry
+ );
// If that was successful, attempt to register the new policy.
- if (!EFI_ERROR( Status )) {
- Status = VariablePolicy->RegisterVariablePolicy( NewEntry );
+ if (!EFI_ERROR (Status)) {
+ Status = VariablePolicy->RegisterVariablePolicy (NewEntry);
}
// If we allocated the buffer, free the buffer.
if (NewEntry != NULL) {
- FreePool( NewEntry );
+ FreePool (NewEntry);
}
return Status;
}
-
/**
This helper function does everything that CreateBasicVariablePolicy() does, but also
uses the passed in protocol to register the policy with the infrastructure.
@@ -366,8 +373,8 @@ RegisterVarStateVariablePolicy ( IN UINT8 VarStateValue
)
{
- VARIABLE_POLICY_ENTRY *NewEntry;
- EFI_STATUS Status;
+ VARIABLE_POLICY_ENTRY *NewEntry;
+ EFI_STATUS Status;
// Check the simple things.
if (VariablePolicy == NULL) {
@@ -376,25 +383,27 @@ RegisterVarStateVariablePolicy ( // Create the new entry and make sure that everything worked.
NewEntry = NULL;
- Status = CreateVarStateVariablePolicy( Namespace,
- Name,
- MinSize,
- MaxSize,
- AttributesMustHave,
- AttributesCantHave,
- VarStateNamespace,
- VarStateValue,
- VarStateName,
- &NewEntry );
+ Status = CreateVarStateVariablePolicy (
+ Namespace,
+ Name,
+ MinSize,
+ MaxSize,
+ AttributesMustHave,
+ AttributesCantHave,
+ VarStateNamespace,
+ VarStateValue,
+ VarStateName,
+ &NewEntry
+ );
// If that was successful, attempt to register the new policy.
- if (!EFI_ERROR( Status )) {
- Status = VariablePolicy->RegisterVariablePolicy( NewEntry );
+ if (!EFI_ERROR (Status)) {
+ Status = VariablePolicy->RegisterVariablePolicy (NewEntry);
}
// If we allocated the buffer, free the buffer.
if (NewEntry != NULL) {
- FreePool( NewEntry );
+ FreePool (NewEntry);
}
return Status;
diff --git a/MdeModulePkg/Library/VariablePolicyLib/VariablePolicyExtraInitNull.c b/MdeModulePkg/Library/VariablePolicyLib/VariablePolicyExtraInitNull.c index ad2ee0b2fb..bb701f14c6 100644 --- a/MdeModulePkg/Library/VariablePolicyLib/VariablePolicyExtraInitNull.c +++ b/MdeModulePkg/Library/VariablePolicyLib/VariablePolicyExtraInitNull.c @@ -9,7 +9,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include <Library/UefiRuntimeServicesTableLib.h>
-
/**
An extra init hook that enables the RuntimeDxe library instance to
register VirtualAddress change callbacks. Among other things.
@@ -27,7 +26,6 @@ VariablePolicyExtraInit ( return EFI_SUCCESS;
}
-
/**
An extra deinit hook that enables the RuntimeDxe library instance to
register VirtualAddress change callbacks. Among other things.
diff --git a/MdeModulePkg/Library/VariablePolicyLib/VariablePolicyExtraInitRuntimeDxe.c b/MdeModulePkg/Library/VariablePolicyLib/VariablePolicyExtraInitRuntimeDxe.c index 3ca87048b1..ffd43dc549 100644 --- a/MdeModulePkg/Library/VariablePolicyLib/VariablePolicyExtraInitRuntimeDxe.c +++ b/MdeModulePkg/Library/VariablePolicyLib/VariablePolicyExtraInitRuntimeDxe.c @@ -10,10 +10,10 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiRuntimeServicesTableLib.h>
-extern EFI_GET_VARIABLE mGetVariableHelper;
-extern UINT8 *mPolicyTable;
-STATIC BOOLEAN mIsVirtualAddrConverted;
-STATIC EFI_EVENT mVariablePolicyLibVirtualAddressChangeEvent = NULL;
+extern EFI_GET_VARIABLE mGetVariableHelper;
+extern UINT8 *mPolicyTable;
+STATIC BOOLEAN mIsVirtualAddrConverted;
+STATIC EFI_EVENT mVariablePolicyLibVirtualAddressChangeEvent = NULL;
/**
For the RuntimeDxe version of this lib, convert internal pointer addresses to virtual addresses.
@@ -26,8 +26,8 @@ STATIC VOID
EFIAPI
VariablePolicyLibVirtualAddressCallback (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
gRT->ConvertPointer (0, (VOID **)&mPolicyTable);
@@ -35,7 +35,6 @@ VariablePolicyLibVirtualAddressCallback ( mIsVirtualAddrConverted = TRUE;
}
-
/**
An extra init hook that enables the RuntimeDxe library instance to
register VirtualAddress change callbacks. Among other things.
@@ -49,15 +48,16 @@ VariablePolicyExtraInit ( VOID
)
{
- return gBS->CreateEventEx (EVT_NOTIFY_SIGNAL,
- TPL_NOTIFY,
- VariablePolicyLibVirtualAddressCallback,
- NULL,
- &gEfiEventVirtualAddressChangeGuid,
- &mVariablePolicyLibVirtualAddressChangeEvent);
+ return gBS->CreateEventEx (
+ EVT_NOTIFY_SIGNAL,
+ TPL_NOTIFY,
+ VariablePolicyLibVirtualAddressCallback,
+ NULL,
+ &gEfiEventVirtualAddressChangeGuid,
+ &mVariablePolicyLibVirtualAddressChangeEvent
+ );
}
-
/**
An extra deinit hook that enables the RuntimeDxe library instance to
register VirtualAddress change callbacks. Among other things.
@@ -76,8 +76,7 @@ VariablePolicyExtraDeinit ( Status = EFI_SUCCESS;
if (mIsVirtualAddrConverted) {
Status = gBS->CloseEvent (mVariablePolicyLibVirtualAddressChangeEvent);
- }
- else {
+ } else {
Status = EFI_SUCCESS;
}
diff --git a/MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.c b/MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.c index 12944ac7ea..82dae67ef5 100644 --- a/MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.c +++ b/MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.c @@ -17,7 +17,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include <Protocol/VariablePolicy.h>
#include <Library/VariablePolicyLib.h>
-
// IMPORTANT NOTE: This library is currently rife with multiple return statements
// for error handling. A refactor should remove these at some point.
@@ -25,38 +24,37 @@ SPDX-License-Identifier: BSD-2-Clause-Patent // This library was designed with advanced unit-test features.
// This define handles the configuration.
#ifdef INTERNAL_UNIT_TEST
-#undef STATIC
+ #undef STATIC
#define STATIC // Nothing...
#endif
// An abstracted GetVariable interface that enables configuration regardless of the environment.
-EFI_GET_VARIABLE mGetVariableHelper = NULL;
+EFI_GET_VARIABLE mGetVariableHelper = NULL;
// Master switch to lock this entire interface. Does not stop enforcement,
// just prevents the configuration from being changed for the rest of the boot.
-STATIC BOOLEAN mInterfaceLocked = FALSE;
+STATIC BOOLEAN mInterfaceLocked = FALSE;
// Master switch to disable the entire interface for a single boot.
// This will disable all policy enforcement for the duration of the boot.
-STATIC BOOLEAN mProtectionDisabled = FALSE;
+STATIC BOOLEAN mProtectionDisabled = FALSE;
// Table to hold all the current policies.
-UINT8 *mPolicyTable = NULL;
-STATIC UINT32 mCurrentTableSize = 0;
-STATIC UINT32 mCurrentTableUsage = 0;
-STATIC UINT32 mCurrentTableCount = 0;
+UINT8 *mPolicyTable = NULL;
+STATIC UINT32 mCurrentTableSize = 0;
+STATIC UINT32 mCurrentTableUsage = 0;
+STATIC UINT32 mCurrentTableCount = 0;
-#define POLICY_TABLE_STEP_SIZE 0x1000
+#define POLICY_TABLE_STEP_SIZE 0x1000
// NOTE: DO NOT USE THESE MACROS on any structure that has not been validated.
// Current table data has already been sanitized.
-#define GET_NEXT_POLICY(CurPolicy) (VARIABLE_POLICY_ENTRY*)((UINT8*)CurPolicy + CurPolicy->Size)
-#define GET_POLICY_NAME(CurPolicy) (CHAR16*)((UINTN)CurPolicy + CurPolicy->OffsetToName)
-
-#define MATCH_PRIORITY_EXACT 0
-#define MATCH_PRIORITY_MAX MATCH_PRIORITY_EXACT
-#define MATCH_PRIORITY_MIN MAX_UINT8
+#define GET_NEXT_POLICY(CurPolicy) (VARIABLE_POLICY_ENTRY*)((UINT8*)CurPolicy + CurPolicy->Size)
+#define GET_POLICY_NAME(CurPolicy) (CHAR16*)((UINTN)CurPolicy + CurPolicy->OffsetToName)
+#define MATCH_PRIORITY_EXACT 0
+#define MATCH_PRIORITY_MAX MATCH_PRIORITY_EXACT
+#define MATCH_PRIORITY_MIN MAX_UINT8
/**
An extra init hook that enables the RuntimeDxe library instance to
@@ -84,7 +82,6 @@ VariablePolicyExtraDeinit ( VOID
);
-
/**
This helper function determines whether the structure of an incoming policy
is valid and internally consistent.
@@ -99,27 +96,28 @@ VariablePolicyExtraDeinit ( STATIC
BOOLEAN
IsValidVariablePolicyStructure (
- IN CONST VARIABLE_POLICY_ENTRY *NewPolicy
+ IN CONST VARIABLE_POLICY_ENTRY *NewPolicy
)
{
- EFI_STATUS Status;
- UINTN EntryEnd;
- CHAR16 *CheckChar;
- UINTN WildcardCount;
+ EFI_STATUS Status;
+ UINTN EntryEnd;
+ CHAR16 *CheckChar;
+ UINTN WildcardCount;
// Sanitize some quick values.
- if (NewPolicy == NULL || NewPolicy->Size == 0 ||
+ if ((NewPolicy == NULL) || (NewPolicy->Size == 0) ||
// Structure size should be at least as long as the minumum structure and a NULL string.
- NewPolicy->Size < sizeof(VARIABLE_POLICY_ENTRY) ||
+ (NewPolicy->Size < sizeof (VARIABLE_POLICY_ENTRY)) ||
// Check for the known revision.
- NewPolicy->Version != VARIABLE_POLICY_ENTRY_REVISION) {
+ (NewPolicy->Version != VARIABLE_POLICY_ENTRY_REVISION))
+ {
return FALSE;
}
// Calculate the theoretical end of the structure and make sure
// that the structure can fit in memory.
- Status = SafeUintnAdd( (UINTN)NewPolicy, NewPolicy->Size, &EntryEnd );
- if (EFI_ERROR( Status )) {
+ Status = SafeUintnAdd ((UINTN)NewPolicy, NewPolicy->Size, &EntryEnd);
+ if (EFI_ERROR (Status)) {
return FALSE;
}
@@ -129,10 +127,10 @@ IsValidVariablePolicyStructure ( }
// Check for the valid list of lock policies.
- if (NewPolicy->LockPolicyType != VARIABLE_POLICY_TYPE_NO_LOCK &&
- NewPolicy->LockPolicyType != VARIABLE_POLICY_TYPE_LOCK_NOW &&
- NewPolicy->LockPolicyType != VARIABLE_POLICY_TYPE_LOCK_ON_CREATE &&
- NewPolicy->LockPolicyType != VARIABLE_POLICY_TYPE_LOCK_ON_VAR_STATE)
+ if ((NewPolicy->LockPolicyType != VARIABLE_POLICY_TYPE_NO_LOCK) &&
+ (NewPolicy->LockPolicyType != VARIABLE_POLICY_TYPE_LOCK_NOW) &&
+ (NewPolicy->LockPolicyType != VARIABLE_POLICY_TYPE_LOCK_ON_CREATE) &&
+ (NewPolicy->LockPolicyType != VARIABLE_POLICY_TYPE_LOCK_ON_VAR_STATE))
{
return FALSE;
}
@@ -141,26 +139,32 @@ IsValidVariablePolicyStructure ( // terminates before the OffsetToName for the matching policy variable Name.
if (NewPolicy->LockPolicyType == VARIABLE_POLICY_TYPE_LOCK_ON_VAR_STATE) {
// Adjust CheckChar to the offset of the LockPolicy->Name.
- Status = SafeUintnAdd( (UINTN)NewPolicy + sizeof(VARIABLE_POLICY_ENTRY),
- sizeof(VARIABLE_LOCK_ON_VAR_STATE_POLICY),
- (UINTN*)&CheckChar );
- if (EFI_ERROR( Status ) || EntryEnd <= (UINTN)CheckChar) {
+ Status = SafeUintnAdd (
+ (UINTN)NewPolicy + sizeof (VARIABLE_POLICY_ENTRY),
+ sizeof (VARIABLE_LOCK_ON_VAR_STATE_POLICY),
+ (UINTN *)&CheckChar
+ );
+ if (EFI_ERROR (Status) || (EntryEnd <= (UINTN)CheckChar)) {
return FALSE;
}
+
while (*CheckChar != CHAR_NULL) {
if (EntryEnd <= (UINTN)CheckChar) {
return FALSE;
}
+
CheckChar++;
}
+
// At this point we should have either exeeded the structure or be pointing at the last char in LockPolicy->Name.
// We should check to make sure that the policy Name comes immediately after this charcter.
- if ((UINTN)++CheckChar != (UINTN)NewPolicy + NewPolicy->OffsetToName) {
+ if ((UINTN)++ CheckChar != (UINTN)NewPolicy + NewPolicy->OffsetToName) {
return FALSE;
}
- // If the policy type is any other value, make sure that the LockPolicy structure has a zero length.
+
+ // If the policy type is any other value, make sure that the LockPolicy structure has a zero length.
} else {
- if (NewPolicy->OffsetToName != sizeof(VARIABLE_POLICY_ENTRY)) {
+ if (NewPolicy->OffsetToName != sizeof (VARIABLE_POLICY_ENTRY)) {
return FALSE;
}
}
@@ -169,7 +173,7 @@ IsValidVariablePolicyStructure ( // before the end of the structure.
// We've already checked that the name is within the bounds of the structure.
if (NewPolicy->Size != NewPolicy->OffsetToName) {
- CheckChar = (CHAR16*)((UINTN)NewPolicy + NewPolicy->OffsetToName);
+ CheckChar = (CHAR16 *)((UINTN)NewPolicy + NewPolicy->OffsetToName);
WildcardCount = 0;
while (*CheckChar != CHAR_NULL) {
// Make sure there aren't excessive wildcards.
@@ -179,16 +183,18 @@ IsValidVariablePolicyStructure ( return FALSE;
}
}
+
// Make sure you're still within the bounds of the policy structure.
if (EntryEnd <= (UINTN)CheckChar) {
return FALSE;
}
+
CheckChar++;
}
// Finally, we should be pointed at the very last character in Name, so we should be right
// up against the end of the structure.
- if ((UINTN)++CheckChar != EntryEnd) {
+ if ((UINTN)++ CheckChar != EntryEnd) {
return FALSE;
}
}
@@ -196,7 +202,6 @@ IsValidVariablePolicyStructure ( return TRUE;
}
-
/**
This helper function evaluates a policy and determines whether it matches the target
variable. If matched, will also return a value corresponding to the priority of the match.
@@ -219,22 +224,22 @@ IsValidVariablePolicyStructure ( STATIC
BOOLEAN
EvaluatePolicyMatch (
- IN CONST VARIABLE_POLICY_ENTRY *EvalEntry,
- IN CONST CHAR16 *VariableName,
- IN CONST EFI_GUID *VendorGuid,
- OUT UINT8 *MatchPriority OPTIONAL
+ IN CONST VARIABLE_POLICY_ENTRY *EvalEntry,
+ IN CONST CHAR16 *VariableName,
+ IN CONST EFI_GUID *VendorGuid,
+ OUT UINT8 *MatchPriority OPTIONAL
)
{
- BOOLEAN Result;
- CHAR16 *PolicyName;
- UINT8 CalculatedPriority;
- UINTN Index;
+ BOOLEAN Result;
+ CHAR16 *PolicyName;
+ UINT8 CalculatedPriority;
+ UINTN Index;
- Result = FALSE;
+ Result = FALSE;
CalculatedPriority = MATCH_PRIORITY_EXACT;
// Step 1: If the GUID doesn't match, we're done. No need to evaluate anything else.
- if (!CompareGuid( &EvalEntry->Namespace, VendorGuid )) {
+ if (!CompareGuid (&EvalEntry->Namespace, VendorGuid)) {
goto Exit;
}
@@ -243,47 +248,50 @@ EvaluatePolicyMatch ( // Missing Name is indicated by size being equal to name.
if (EvalEntry->Size == EvalEntry->OffsetToName) {
CalculatedPriority = MATCH_PRIORITY_MIN;
- Result = TRUE;
+ Result = TRUE;
goto Exit;
}
// Now that we know the name exists, get it.
- PolicyName = GET_POLICY_NAME( EvalEntry );
+ PolicyName = GET_POLICY_NAME (EvalEntry);
// Evaluate the name against the policy name and check for a match.
// Account for any wildcards.
- Index = 0;
+ Index = 0;
Result = TRUE;
// Keep going until the end of both strings.
while (PolicyName[Index] != CHAR_NULL || VariableName[Index] != CHAR_NULL) {
// If we don't have a match...
- if (PolicyName[Index] != VariableName[Index] || PolicyName[Index] == '#') {
+ if ((PolicyName[Index] != VariableName[Index]) || (PolicyName[Index] == '#')) {
// If this is a numerical wildcard, we can consider
// it a match if we alter the priority.
- if (PolicyName[Index] == L'#' &&
- ((L'0' <= VariableName[Index] && VariableName[Index] <= L'9') ||
- (L'A' <= VariableName[Index] && VariableName[Index] <= L'F') ||
- (L'a' <= VariableName[Index] && VariableName[Index] <= L'f'))) {
+ if ((PolicyName[Index] == L'#') &&
+ (((L'0' <= VariableName[Index]) && (VariableName[Index] <= L'9')) ||
+ ((L'A' <= VariableName[Index]) && (VariableName[Index] <= L'F')) ||
+ ((L'a' <= VariableName[Index]) && (VariableName[Index] <= L'f'))))
+ {
if (CalculatedPriority < MATCH_PRIORITY_MIN) {
CalculatedPriority++;
}
- // Otherwise, not a match.
+
+ // Otherwise, not a match.
} else {
Result = FALSE;
goto Exit;
}
}
+
Index++;
}
Exit:
- if (Result && MatchPriority != NULL) {
+ if (Result && (MatchPriority != NULL)) {
*MatchPriority = CalculatedPriority;
}
+
return Result;
}
-
/**
This helper function walks the current policy table and returns a pointer
to the best match, if any are found. Leverages EvaluatePolicyMatch() to
@@ -300,30 +308,30 @@ Exit: **/
STATIC
-VARIABLE_POLICY_ENTRY*
+VARIABLE_POLICY_ENTRY *
GetBestPolicyMatch (
- IN CONST CHAR16 *VariableName,
- IN CONST EFI_GUID *VendorGuid,
- OUT UINT8 *ReturnPriority OPTIONAL
+ IN CONST CHAR16 *VariableName,
+ IN CONST EFI_GUID *VendorGuid,
+ OUT UINT8 *ReturnPriority OPTIONAL
)
{
- VARIABLE_POLICY_ENTRY *BestResult;
- VARIABLE_POLICY_ENTRY *CurrentEntry;
- UINT8 MatchPriority;
- UINT8 CurrentPriority;
- UINTN Index;
+ VARIABLE_POLICY_ENTRY *BestResult;
+ VARIABLE_POLICY_ENTRY *CurrentEntry;
+ UINT8 MatchPriority;
+ UINT8 CurrentPriority;
+ UINTN Index;
- BestResult = NULL;
+ BestResult = NULL;
MatchPriority = MATCH_PRIORITY_EXACT;
// Walk all entries in the table, looking for matches.
- CurrentEntry = (VARIABLE_POLICY_ENTRY*)mPolicyTable;
+ CurrentEntry = (VARIABLE_POLICY_ENTRY *)mPolicyTable;
for (Index = 0; Index < mCurrentTableCount; Index++) {
// Check for a match.
- if (EvaluatePolicyMatch( CurrentEntry, VariableName, VendorGuid, &CurrentPriority )) {
+ if (EvaluatePolicyMatch (CurrentEntry, VariableName, VendorGuid, &CurrentPriority)) {
// If match is better, take it.
- if (BestResult == NULL || CurrentPriority < MatchPriority) {
- BestResult = CurrentEntry;
+ if ((BestResult == NULL) || (CurrentPriority < MatchPriority)) {
+ BestResult = CurrentEntry;
MatchPriority = CurrentPriority;
}
@@ -334,7 +342,7 @@ GetBestPolicyMatch ( }
// If we're still in the loop, move to the next entry.
- CurrentEntry = GET_NEXT_POLICY( CurrentEntry );
+ CurrentEntry = GET_NEXT_POLICY (CurrentEntry);
}
// If a return priority was requested, return it.
@@ -345,7 +353,6 @@ GetBestPolicyMatch ( return BestResult;
}
-
/**
This API function validates and registers a new policy with
the policy enforcement engine.
@@ -365,65 +372,72 @@ GetBestPolicyMatch ( EFI_STATUS
EFIAPI
RegisterVariablePolicy (
- IN CONST VARIABLE_POLICY_ENTRY *NewPolicy
+ IN CONST VARIABLE_POLICY_ENTRY *NewPolicy
)
{
- EFI_STATUS Status;
- VARIABLE_POLICY_ENTRY *MatchPolicy;
- UINT8 MatchPriority;
- UINT32 NewSize;
- UINT8 *NewTable;
+ EFI_STATUS Status;
+ VARIABLE_POLICY_ENTRY *MatchPolicy;
+ UINT8 MatchPriority;
+ UINT32 NewSize;
+ UINT8 *NewTable;
- if (!IsVariablePolicyLibInitialized()) {
+ if (!IsVariablePolicyLibInitialized ()) {
return EFI_NOT_READY;
}
+
if (mInterfaceLocked) {
return EFI_WRITE_PROTECTED;
}
- if (!IsValidVariablePolicyStructure( NewPolicy )) {
+ if (!IsValidVariablePolicyStructure (NewPolicy)) {
return EFI_INVALID_PARAMETER;
}
// Check to see whether an exact matching policy already exists.
- MatchPolicy = GetBestPolicyMatch( GET_POLICY_NAME( NewPolicy ),
- &NewPolicy->Namespace,
- &MatchPriority );
- if (MatchPolicy != NULL && MatchPriority == MATCH_PRIORITY_EXACT) {
+ MatchPolicy = GetBestPolicyMatch (
+ GET_POLICY_NAME (NewPolicy),
+ &NewPolicy->Namespace,
+ &MatchPriority
+ );
+ if ((MatchPolicy != NULL) && (MatchPriority == MATCH_PRIORITY_EXACT)) {
return EFI_ALREADY_STARTED;
}
// If none exists, create it.
// If we need more space, allocate that now.
- Status = SafeUint32Add( mCurrentTableUsage, NewPolicy->Size, &NewSize );
- if (EFI_ERROR( Status )) {
+ Status = SafeUint32Add (mCurrentTableUsage, NewPolicy->Size, &NewSize);
+ if (EFI_ERROR (Status)) {
return EFI_ABORTED;
}
+
if (NewSize > mCurrentTableSize) {
// Use NewSize to calculate the new table size in units of POLICY_TABLE_STEP_SIZE.
NewSize = (NewSize % POLICY_TABLE_STEP_SIZE) > 0 ?
- (NewSize / POLICY_TABLE_STEP_SIZE) + 1 :
- (NewSize / POLICY_TABLE_STEP_SIZE);
+ (NewSize / POLICY_TABLE_STEP_SIZE) + 1 :
+ (NewSize / POLICY_TABLE_STEP_SIZE);
// Calculate the new table size in absolute bytes.
- Status = SafeUint32Mult( NewSize, POLICY_TABLE_STEP_SIZE, &NewSize );
- if (EFI_ERROR( Status )) {
+ Status = SafeUint32Mult (NewSize, POLICY_TABLE_STEP_SIZE, &NewSize);
+ if (EFI_ERROR (Status)) {
return EFI_ABORTED;
}
// Reallocate and copy the table.
- NewTable = AllocateRuntimePool( NewSize );
+ NewTable = AllocateRuntimePool (NewSize);
if (NewTable == NULL) {
return EFI_OUT_OF_RESOURCES;
}
- CopyMem( NewTable, mPolicyTable, mCurrentTableUsage );
+
+ CopyMem (NewTable, mPolicyTable, mCurrentTableUsage);
mCurrentTableSize = NewSize;
if (mPolicyTable != NULL) {
- FreePool( mPolicyTable );
+ FreePool (mPolicyTable);
}
+
mPolicyTable = NewTable;
}
+
// Copy the policy into the table.
- CopyMem( mPolicyTable + mCurrentTableUsage, NewPolicy, NewPolicy->Size );
+ CopyMem (mPolicyTable + mCurrentTableUsage, NewPolicy, NewPolicy->Size);
mCurrentTableUsage += NewPolicy->Size;
mCurrentTableCount += 1;
@@ -432,7 +446,6 @@ RegisterVariablePolicy ( return EFI_SUCCESS;
}
-
/**
This API function checks to see whether the parameters to SetVariable would
be allowed according to the current variable policies.
@@ -455,25 +468,25 @@ RegisterVariablePolicy ( EFI_STATUS
EFIAPI
ValidateSetVariable (
- IN CHAR16 *VariableName,
- IN EFI_GUID *VendorGuid,
- IN UINT32 Attributes,
- IN UINTN DataSize,
- IN VOID *Data
+ IN CHAR16 *VariableName,
+ IN EFI_GUID *VendorGuid,
+ IN UINT32 Attributes,
+ IN UINTN DataSize,
+ IN VOID *Data
)
{
- BOOLEAN IsDel;
- VARIABLE_POLICY_ENTRY *ActivePolicy;
- EFI_STATUS Status;
- EFI_STATUS ReturnStatus;
- VARIABLE_LOCK_ON_VAR_STATE_POLICY *StateVarPolicy;
- CHAR16 *StateVarName;
- UINTN StateVarSize;
- UINT8 StateVar;
+ BOOLEAN IsDel;
+ VARIABLE_POLICY_ENTRY *ActivePolicy;
+ EFI_STATUS Status;
+ EFI_STATUS ReturnStatus;
+ VARIABLE_LOCK_ON_VAR_STATE_POLICY *StateVarPolicy;
+ CHAR16 *StateVarName;
+ UINTN StateVarSize;
+ UINT8 StateVar;
ReturnStatus = EFI_SUCCESS;
- if (!IsVariablePolicyLibInitialized()) {
+ if (!IsVariablePolicyLibInitialized ()) {
ReturnStatus = EFI_NOT_READY;
goto Exit;
}
@@ -493,7 +506,7 @@ ValidateSetVariable ( }
// Find an active policy if one exists.
- ActivePolicy = GetBestPolicyMatch( VariableName, VendorGuid, NULL );
+ ActivePolicy = GetBestPolicyMatch (VariableName, VendorGuid, NULL);
// If we have an active policy, check it against the incoming data.
if (ActivePolicy != NULL) {
@@ -501,20 +514,34 @@ ValidateSetVariable ( // Only enforce size and attribute constraints when updating data, not deleting.
if (!IsDel) {
// Check for size constraints.
- if ((ActivePolicy->MinSize > 0 && DataSize < ActivePolicy->MinSize) ||
- (ActivePolicy->MaxSize > 0 && DataSize > ActivePolicy->MaxSize)) {
+ if (((ActivePolicy->MinSize > 0) && (DataSize < ActivePolicy->MinSize)) ||
+ ((ActivePolicy->MaxSize > 0) && (DataSize > ActivePolicy->MaxSize)))
+ {
ReturnStatus = EFI_INVALID_PARAMETER;
- DEBUG(( DEBUG_VERBOSE, "%a - Bad Size. 0x%X <> 0x%X-0x%X\n", __FUNCTION__,
- DataSize, ActivePolicy->MinSize, ActivePolicy->MaxSize ));
+ DEBUG ((
+ DEBUG_VERBOSE,
+ "%a - Bad Size. 0x%X <> 0x%X-0x%X\n",
+ __FUNCTION__,
+ DataSize,
+ ActivePolicy->MinSize,
+ ActivePolicy->MaxSize
+ ));
goto Exit;
}
// Check for attribute constraints.
- if ((ActivePolicy->AttributesMustHave & Attributes) != ActivePolicy->AttributesMustHave ||
- (ActivePolicy->AttributesCantHave & Attributes) != 0) {
+ if (((ActivePolicy->AttributesMustHave & Attributes) != ActivePolicy->AttributesMustHave) ||
+ ((ActivePolicy->AttributesCantHave & Attributes) != 0))
+ {
ReturnStatus = EFI_INVALID_PARAMETER;
- DEBUG(( DEBUG_VERBOSE, "%a - Bad Attributes. 0x%X <> 0x%X:0x%X\n", __FUNCTION__,
- Attributes, ActivePolicy->AttributesMustHave, ActivePolicy->AttributesCantHave ));
+ DEBUG ((
+ DEBUG_VERBOSE,
+ "%a - Bad Attributes. 0x%X <> 0x%X:0x%X\n",
+ __FUNCTION__,
+ Attributes,
+ ActivePolicy->AttributesMustHave,
+ ActivePolicy->AttributesCantHave
+ ));
goto Exit;
}
}
@@ -526,37 +553,43 @@ ValidateSetVariable ( if (ActivePolicy->LockPolicyType == VARIABLE_POLICY_TYPE_LOCK_NOW) {
ReturnStatus = EFI_WRITE_PROTECTED;
goto Exit;
- // Check for lock on create.
+ // Check for lock on create.
} else if (ActivePolicy->LockPolicyType == VARIABLE_POLICY_TYPE_LOCK_ON_CREATE) {
StateVarSize = 0;
- Status = mGetVariableHelper( VariableName,
- VendorGuid,
- NULL,
- &StateVarSize,
- NULL );
+ Status = mGetVariableHelper (
+ VariableName,
+ VendorGuid,
+ NULL,
+ &StateVarSize,
+ NULL
+ );
if (Status == EFI_BUFFER_TOO_SMALL) {
ReturnStatus = EFI_WRITE_PROTECTED;
goto Exit;
}
- // Check for lock on state variable.
+
+ // Check for lock on state variable.
} else if (ActivePolicy->LockPolicyType == VARIABLE_POLICY_TYPE_LOCK_ON_VAR_STATE) {
- StateVarPolicy = (VARIABLE_LOCK_ON_VAR_STATE_POLICY*)((UINT8*)ActivePolicy + sizeof(VARIABLE_POLICY_ENTRY));
- StateVarName = (CHAR16*)((UINT8*)StateVarPolicy + sizeof(VARIABLE_LOCK_ON_VAR_STATE_POLICY));
- StateVarSize = sizeof(StateVar);
- Status = mGetVariableHelper( StateVarName,
- &StateVarPolicy->Namespace,
- NULL,
- &StateVarSize,
- &StateVar );
+ StateVarPolicy = (VARIABLE_LOCK_ON_VAR_STATE_POLICY *)((UINT8 *)ActivePolicy + sizeof (VARIABLE_POLICY_ENTRY));
+ StateVarName = (CHAR16 *)((UINT8 *)StateVarPolicy + sizeof (VARIABLE_LOCK_ON_VAR_STATE_POLICY));
+ StateVarSize = sizeof (StateVar);
+ Status = mGetVariableHelper (
+ StateVarName,
+ &StateVarPolicy->Namespace,
+ NULL,
+ &StateVarSize,
+ &StateVar
+ );
// If the variable was found, check the state. If matched, this variable is locked.
- if (!EFI_ERROR( Status )) {
+ if (!EFI_ERROR (Status)) {
if (StateVar == StateVarPolicy->Value) {
ReturnStatus = EFI_WRITE_PROTECTED;
goto Exit;
}
- // EFI_NOT_FOUND and EFI_BUFFER_TOO_SMALL indicate that the state doesn't match.
- } else if (Status != EFI_NOT_FOUND && Status != EFI_BUFFER_TOO_SMALL) {
+
+ // EFI_NOT_FOUND and EFI_BUFFER_TOO_SMALL indicate that the state doesn't match.
+ } else if ((Status != EFI_NOT_FOUND) && (Status != EFI_BUFFER_TOO_SMALL)) {
// We don't know what happened, but it isn't good.
ReturnStatus = EFI_ABORTED;
goto Exit;
@@ -565,11 +598,10 @@ ValidateSetVariable ( }
Exit:
- DEBUG(( DEBUG_VERBOSE, "%a - Variable (%g:%s) returning %r.\n", __FUNCTION__, VendorGuid, VariableName, ReturnStatus ));
+ DEBUG ((DEBUG_VERBOSE, "%a - Variable (%g:%s) returning %r.\n", __FUNCTION__, VendorGuid, VariableName, ReturnStatus));
return ReturnStatus;
}
-
/**
This API function disables the variable policy enforcement. If it's
already been called once, will return EFI_ALREADY_STARTED.
@@ -587,23 +619,26 @@ DisableVariablePolicy ( VOID
)
{
- if (!IsVariablePolicyLibInitialized()) {
+ if (!IsVariablePolicyLibInitialized ()) {
return EFI_NOT_READY;
}
+
if (mProtectionDisabled) {
return EFI_ALREADY_STARTED;
}
+
if (mInterfaceLocked) {
return EFI_WRITE_PROTECTED;
}
+
if (!PcdGetBool (PcdAllowVariablePolicyEnforcementDisable)) {
return EFI_WRITE_PROTECTED;
}
+
mProtectionDisabled = TRUE;
return EFI_SUCCESS;
}
-
/**
This API function will dump the entire contents of the variable policy table.
@@ -623,16 +658,16 @@ DisableVariablePolicy ( EFI_STATUS
EFIAPI
DumpVariablePolicy (
- OUT UINT8 *Policy,
- IN OUT UINT32 *Size
+ OUT UINT8 *Policy,
+ IN OUT UINT32 *Size
)
{
- if (!IsVariablePolicyLibInitialized()) {
+ if (!IsVariablePolicyLibInitialized ()) {
return EFI_NOT_READY;
}
// Check the parameters.
- if (Size == NULL || (*Size > 0 && Policy == NULL)) {
+ if ((Size == NULL) || ((*Size > 0) && (Policy == NULL))) {
return EFI_INVALID_PARAMETER;
}
@@ -643,13 +678,12 @@ DumpVariablePolicy ( }
// If we're still here, copy the table and bounce.
- CopyMem( Policy, mPolicyTable, mCurrentTableUsage );
+ CopyMem (Policy, mPolicyTable, mCurrentTableUsage);
*Size = mCurrentTableUsage;
return EFI_SUCCESS;
}
-
/**
This API function returns whether or not the policy engine is
currently being enforced.
@@ -665,13 +699,13 @@ IsVariablePolicyEnabled ( VOID
)
{
- if (!IsVariablePolicyLibInitialized()) {
+ if (!IsVariablePolicyLibInitialized ()) {
return FALSE;
}
+
return !mProtectionDisabled;
}
-
/**
This API function locks the interface so that no more policy updates
can be performed or changes made to the enforcement until the next boot.
@@ -686,17 +720,18 @@ LockVariablePolicy ( VOID
)
{
- if (!IsVariablePolicyLibInitialized()) {
+ if (!IsVariablePolicyLibInitialized ()) {
return EFI_NOT_READY;
}
+
if (mInterfaceLocked) {
return EFI_WRITE_PROTECTED;
}
+
mInterfaceLocked = TRUE;
return EFI_SUCCESS;
}
-
/**
This API function returns whether or not the policy interface is locked
for the remainder of the boot.
@@ -712,13 +747,13 @@ IsVariablePolicyInterfaceLocked ( VOID
)
{
- if (!IsVariablePolicyLibInitialized()) {
+ if (!IsVariablePolicyLibInitialized ()) {
return FALSE;
}
+
return mInterfaceLocked;
}
-
/**
This helper function initializes the library and sets
up any required internal structures or handlers.
@@ -736,10 +771,10 @@ IsVariablePolicyInterfaceLocked ( EFI_STATUS
EFIAPI
InitVariablePolicyLib (
- IN EFI_GET_VARIABLE GetVariableHelper
+ IN EFI_GET_VARIABLE GetVariableHelper
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
Status = EFI_SUCCESS;
@@ -747,27 +782,26 @@ InitVariablePolicyLib ( return EFI_ALREADY_STARTED;
}
- if (!EFI_ERROR( Status )) {
- Status = VariablePolicyExtraInit();
+ if (!EFI_ERROR (Status)) {
+ Status = VariablePolicyExtraInit ();
}
- if (!EFI_ERROR( Status )) {
+ if (!EFI_ERROR (Status)) {
// Save an internal pointer to the GetVariableHelper.
mGetVariableHelper = GetVariableHelper;
// Initialize the global state.
- mInterfaceLocked = FALSE;
+ mInterfaceLocked = FALSE;
mProtectionDisabled = FALSE;
- mPolicyTable = NULL;
- mCurrentTableSize = 0;
- mCurrentTableUsage = 0;
- mCurrentTableCount = 0;
+ mPolicyTable = NULL;
+ mCurrentTableSize = 0;
+ mCurrentTableUsage = 0;
+ mCurrentTableCount = 0;
}
return Status;
}
-
/**
This helper function returns whether or not the library is currently initialized.
@@ -784,7 +818,6 @@ IsVariablePolicyLibInitialized ( return (mGetVariableHelper != NULL);
}
-
/**
This helper function tears down the library.
@@ -800,7 +833,7 @@ DeinitVariablePolicyLib ( VOID
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
Status = EFI_SUCCESS;
@@ -808,20 +841,20 @@ DeinitVariablePolicyLib ( return EFI_NOT_READY;
}
- if (!EFI_ERROR( Status )) {
- Status = VariablePolicyExtraDeinit();
+ if (!EFI_ERROR (Status)) {
+ Status = VariablePolicyExtraDeinit ();
}
- if (!EFI_ERROR( Status )) {
- mGetVariableHelper = NULL;
- mInterfaceLocked = FALSE;
+ if (!EFI_ERROR (Status)) {
+ mGetVariableHelper = NULL;
+ mInterfaceLocked = FALSE;
mProtectionDisabled = FALSE;
- mCurrentTableSize = 0;
- mCurrentTableUsage = 0;
- mCurrentTableCount = 0;
+ mCurrentTableSize = 0;
+ mCurrentTableUsage = 0;
+ mCurrentTableCount = 0;
if (mPolicyTable != NULL) {
- FreePool( mPolicyTable );
+ FreePool (mPolicyTable);
mPolicyTable = NULL;
}
}
|