\r
#include "Capsule.h"\r
\r
-#define DEFAULT_SG_LIST_HEADS (20)\r
+#define DEFAULT_SG_LIST_HEADS (20)\r
\r
#ifdef MDE_CPU_IA32\r
//\r
// Global Descriptor Table (GDT)\r
//\r
-GLOBAL_REMOVE_IF_UNREFERENCED IA32_SEGMENT_DESCRIPTOR mGdtEntries[] = {\r
-/* selector { Global Segment Descriptor } */\r
-/* 0x00 */ {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, //null descriptor\r
-/* 0x08 */ {{0xffff, 0, 0, 0x3, 1, 0, 1, 0xf, 0, 0, 1, 1, 0}}, //linear data segment descriptor\r
-/* 0x10 */ {{0xffff, 0, 0, 0xf, 1, 0, 1, 0xf, 0, 0, 1, 1, 0}}, //linear code segment descriptor\r
-/* 0x18 */ {{0xffff, 0, 0, 0x3, 1, 0, 1, 0xf, 0, 0, 1, 1, 0}}, //system data segment descriptor\r
-/* 0x20 */ {{0xffff, 0, 0, 0xb, 1, 0, 1, 0xf, 0, 0, 1, 1, 0}}, //system code segment descriptor\r
-/* 0x28 */ {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, //spare segment descriptor\r
-/* 0x30 */ {{0xffff, 0, 0, 0x3, 1, 0, 1, 0xf, 0, 0, 1, 1, 0}}, //system data segment descriptor\r
-/* 0x38 */ {{0xffff, 0, 0, 0xb, 1, 0, 1, 0xf, 0, 1, 0, 1, 0}}, //system code segment descriptor\r
-/* 0x40 */ {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, //spare segment descriptor\r
+GLOBAL_REMOVE_IF_UNREFERENCED IA32_SEGMENT_DESCRIPTOR mGdtEntries[] = {\r
+ /* selector { Global Segment Descriptor } */\r
+ /* 0x00 */ {\r
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }\r
+ }, // null descriptor\r
+ /* 0x08 */ {\r
+ { 0xffff, 0, 0, 0x3, 1, 0, 1, 0xf, 0, 0, 1, 1, 0 }\r
+ }, // linear data segment descriptor\r
+ /* 0x10 */ {\r
+ { 0xffff, 0, 0, 0xf, 1, 0, 1, 0xf, 0, 0, 1, 1, 0 }\r
+ }, // linear code segment descriptor\r
+ /* 0x18 */ {\r
+ { 0xffff, 0, 0, 0x3, 1, 0, 1, 0xf, 0, 0, 1, 1, 0 }\r
+ }, // system data segment descriptor\r
+ /* 0x20 */ {\r
+ { 0xffff, 0, 0, 0xb, 1, 0, 1, 0xf, 0, 0, 1, 1, 0 }\r
+ }, // system code segment descriptor\r
+ /* 0x28 */ {\r
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }\r
+ }, // spare segment descriptor\r
+ /* 0x30 */ {\r
+ { 0xffff, 0, 0, 0x3, 1, 0, 1, 0xf, 0, 0, 1, 1, 0 }\r
+ }, // system data segment descriptor\r
+ /* 0x38 */ {\r
+ { 0xffff, 0, 0, 0xb, 1, 0, 1, 0xf, 0, 1, 0, 1, 0 }\r
+ }, // system code segment descriptor\r
+ /* 0x40 */ {\r
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }\r
+ }, // spare segment descriptor\r
};\r
\r
//\r
// IA32 Gdt register\r
//\r
-GLOBAL_REMOVE_IF_UNREFERENCED CONST IA32_DESCRIPTOR mGdt = {\r
+GLOBAL_REMOVE_IF_UNREFERENCED CONST IA32_DESCRIPTOR mGdt = {\r
sizeof (mGdtEntries) - 1,\r
- (UINTN) mGdtEntries\r
- };\r
-\r
+ (UINTN)mGdtEntries\r
+};\r
\r
/**\r
The function will check if 1G page is supported.\r
VOID\r
)\r
{\r
- UINT32 RegEax;\r
- UINT32 RegEdx;\r
- BOOLEAN Page1GSupport;\r
+ UINT32 RegEax;\r
+ UINT32 RegEdx;\r
+ BOOLEAN Page1GSupport;\r
\r
Page1GSupport = FALSE;\r
- if (PcdGetBool(PcdUse1GPageTable)) {\r
+ if (PcdGetBool (PcdUse1GPageTable)) {\r
AsmCpuid (0x80000000, &RegEax, NULL, NULL, NULL);\r
if (RegEax >= 0x80000001) {\r
AsmCpuid (0x80000001, NULL, NULL, NULL, &RegEdx);\r
**/\r
UINTN\r
CalculatePageTableSize (\r
- IN BOOLEAN Page1GSupport\r
+ IN BOOLEAN Page1GSupport\r
)\r
{\r
- UINTN ExtraPageTablePages;\r
- UINTN TotalPagesNum;\r
- UINT8 PhysicalAddressBits;\r
- UINT32 NumberOfPml4EntriesNeeded;\r
- UINT32 NumberOfPdpEntriesNeeded;\r
+ UINTN ExtraPageTablePages;\r
+ UINTN TotalPagesNum;\r
+ UINT8 PhysicalAddressBits;\r
+ UINT32 NumberOfPml4EntriesNeeded;\r
+ UINT32 NumberOfPdpEntriesNeeded;\r
\r
//\r
// Create 4G page table by default,\r
//\r
if (PhysicalAddressBits <= 39 ) {\r
NumberOfPml4EntriesNeeded = 1;\r
- NumberOfPdpEntriesNeeded = (UINT32)LShiftU64 (1, (PhysicalAddressBits - 30));\r
+ NumberOfPdpEntriesNeeded = (UINT32)LShiftU64 (1, (PhysicalAddressBits - 30));\r
} else {\r
NumberOfPml4EntriesNeeded = (UINT32)LShiftU64 (1, (PhysicalAddressBits - 39));\r
- NumberOfPdpEntriesNeeded = 512;\r
+ NumberOfPdpEntriesNeeded = 512;\r
}\r
\r
if (!Page1GSupport) {\r
} else {\r
TotalPagesNum = NumberOfPml4EntriesNeeded + 1;\r
}\r
+\r
TotalPagesNum += ExtraPageTablePages;\r
\r
return EFI_PAGES_TO_SIZE (TotalPagesNum);\r
**/\r
VOID\r
Create4GPageTables (\r
- IN EFI_PHYSICAL_ADDRESS PageTablesAddress,\r
- IN BOOLEAN Page1GSupport\r
+ IN EFI_PHYSICAL_ADDRESS PageTablesAddress,\r
+ IN BOOLEAN Page1GSupport\r
)\r
{\r
- UINT8 PhysicalAddressBits;\r
- EFI_PHYSICAL_ADDRESS PageAddress;\r
- UINTN IndexOfPml4Entries;\r
- UINTN IndexOfPdpEntries;\r
- UINTN IndexOfPageDirectoryEntries;\r
- UINT32 NumberOfPml4EntriesNeeded;\r
- UINT32 NumberOfPdpEntriesNeeded;\r
- PAGE_MAP_AND_DIRECTORY_POINTER *PageMapLevel4Entry;\r
- PAGE_MAP_AND_DIRECTORY_POINTER *PageMap;\r
- PAGE_MAP_AND_DIRECTORY_POINTER *PageDirectoryPointerEntry;\r
- PAGE_TABLE_ENTRY *PageDirectoryEntry;\r
- UINTN BigPageAddress;\r
- PAGE_TABLE_1G_ENTRY *PageDirectory1GEntry;\r
- UINT64 AddressEncMask;\r
+ UINT8 PhysicalAddressBits;\r
+ EFI_PHYSICAL_ADDRESS PageAddress;\r
+ UINTN IndexOfPml4Entries;\r
+ UINTN IndexOfPdpEntries;\r
+ UINTN IndexOfPageDirectoryEntries;\r
+ UINT32 NumberOfPml4EntriesNeeded;\r
+ UINT32 NumberOfPdpEntriesNeeded;\r
+ PAGE_MAP_AND_DIRECTORY_POINTER *PageMapLevel4Entry;\r
+ PAGE_MAP_AND_DIRECTORY_POINTER *PageMap;\r
+ PAGE_MAP_AND_DIRECTORY_POINTER *PageDirectoryPointerEntry;\r
+ PAGE_TABLE_ENTRY *PageDirectoryEntry;\r
+ UINTN BigPageAddress;\r
+ PAGE_TABLE_1G_ENTRY *PageDirectory1GEntry;\r
+ UINT64 AddressEncMask;\r
\r
//\r
// Make sure AddressEncMask is contained to smallest supported address field.\r
//\r
if (PhysicalAddressBits <= 39 ) {\r
NumberOfPml4EntriesNeeded = 1;\r
- NumberOfPdpEntriesNeeded = (UINT32)LShiftU64 (1, (PhysicalAddressBits - 30));\r
+ NumberOfPdpEntriesNeeded = (UINT32)LShiftU64 (1, (PhysicalAddressBits - 30));\r
} else {\r
NumberOfPml4EntriesNeeded = (UINT32)LShiftU64 (1, (PhysicalAddressBits - 39));\r
- NumberOfPdpEntriesNeeded = 512;\r
+ NumberOfPdpEntriesNeeded = 512;\r
}\r
\r
//\r
// Pre-allocate big pages to avoid later allocations.\r
//\r
- BigPageAddress = (UINTN) PageTablesAddress;\r
+ BigPageAddress = (UINTN)PageTablesAddress;\r
\r
//\r
// By architecture only one PageMapLevel4 exists - so lets allocate storage for it.\r
//\r
- PageMap = (VOID *) BigPageAddress;\r
+ PageMap = (VOID *)BigPageAddress;\r
BigPageAddress += SIZE_4KB;\r
\r
PageMapLevel4Entry = PageMap;\r
// Each PML4 entry points to a page of Page Directory Pointer entires.\r
// So lets allocate space for them and fill them in in the IndexOfPdpEntries loop.\r
//\r
- PageDirectoryPointerEntry = (VOID *) BigPageAddress;\r
- BigPageAddress += SIZE_4KB;\r
+ PageDirectoryPointerEntry = (VOID *)BigPageAddress;\r
+ BigPageAddress += SIZE_4KB;\r
\r
//\r
// Make a PML4 Entry\r
//\r
- PageMapLevel4Entry->Uint64 = (UINT64)(UINTN)PageDirectoryPointerEntry | AddressEncMask;\r
+ PageMapLevel4Entry->Uint64 = (UINT64)(UINTN)PageDirectoryPointerEntry | AddressEncMask;\r
PageMapLevel4Entry->Bits.ReadWrite = 1;\r
- PageMapLevel4Entry->Bits.Present = 1;\r
+ PageMapLevel4Entry->Bits.Present = 1;\r
\r
if (Page1GSupport) {\r
- PageDirectory1GEntry = (VOID *) PageDirectoryPointerEntry;\r
+ PageDirectory1GEntry = (VOID *)PageDirectoryPointerEntry;\r
\r
for (IndexOfPageDirectoryEntries = 0; IndexOfPageDirectoryEntries < 512; IndexOfPageDirectoryEntries++, PageDirectory1GEntry++, PageAddress += SIZE_1GB) {\r
//\r
// Fill in the Page Directory entries\r
//\r
- PageDirectory1GEntry->Uint64 = (UINT64)PageAddress | AddressEncMask;\r
+ PageDirectory1GEntry->Uint64 = (UINT64)PageAddress | AddressEncMask;\r
PageDirectory1GEntry->Bits.ReadWrite = 1;\r
- PageDirectory1GEntry->Bits.Present = 1;\r
- PageDirectory1GEntry->Bits.MustBe1 = 1;\r
+ PageDirectory1GEntry->Bits.Present = 1;\r
+ PageDirectory1GEntry->Bits.MustBe1 = 1;\r
}\r
} else {\r
for (IndexOfPdpEntries = 0; IndexOfPdpEntries < NumberOfPdpEntriesNeeded; IndexOfPdpEntries++, PageDirectoryPointerEntry++) {\r
// Each Directory Pointer entries points to a page of Page Directory entires.\r
// So allocate space for them and fill them in in the IndexOfPageDirectoryEntries loop.\r
//\r
- PageDirectoryEntry = (VOID *) BigPageAddress;\r
- BigPageAddress += SIZE_4KB;\r
+ PageDirectoryEntry = (VOID *)BigPageAddress;\r
+ BigPageAddress += SIZE_4KB;\r
\r
//\r
// Fill in a Page Directory Pointer Entries\r
//\r
- PageDirectoryPointerEntry->Uint64 = (UINT64)(UINTN)PageDirectoryEntry | AddressEncMask;\r
+ PageDirectoryPointerEntry->Uint64 = (UINT64)(UINTN)PageDirectoryEntry | AddressEncMask;\r
PageDirectoryPointerEntry->Bits.ReadWrite = 1;\r
- PageDirectoryPointerEntry->Bits.Present = 1;\r
+ PageDirectoryPointerEntry->Bits.Present = 1;\r
\r
for (IndexOfPageDirectoryEntries = 0; IndexOfPageDirectoryEntries < 512; IndexOfPageDirectoryEntries++, PageDirectoryEntry++, PageAddress += SIZE_2MB) {\r
//\r
// Fill in the Page Directory entries\r
//\r
- PageDirectoryEntry->Uint64 = (UINT64)PageAddress | AddressEncMask;\r
+ PageDirectoryEntry->Uint64 = (UINT64)PageAddress | AddressEncMask;\r
PageDirectoryEntry->Bits.ReadWrite = 1;\r
- PageDirectoryEntry->Bits.Present = 1;\r
- PageDirectoryEntry->Bits.MustBe1 = 1;\r
+ PageDirectoryEntry->Bits.Present = 1;\r
+ PageDirectoryEntry->Bits.MustBe1 = 1;\r
}\r
}\r
\r
- for (; IndexOfPdpEntries < 512; IndexOfPdpEntries++, PageDirectoryPointerEntry++) {\r
+ for ( ; IndexOfPdpEntries < 512; IndexOfPdpEntries++, PageDirectoryPointerEntry++) {\r
ZeroMem (\r
PageDirectoryPointerEntry,\r
- sizeof(PAGE_MAP_AND_DIRECTORY_POINTER)\r
+ sizeof (PAGE_MAP_AND_DIRECTORY_POINTER)\r
);\r
}\r
}\r
//\r
// For the PML4 entries we are not using fill in a null entry.\r
//\r
- for (; IndexOfPml4Entries < 512; IndexOfPml4Entries++, PageMapLevel4Entry++) {\r
+ for ( ; IndexOfPml4Entries < 512; IndexOfPml4Entries++, PageMapLevel4Entry++) {\r
ZeroMem (\r
PageMapLevel4Entry,\r
sizeof (PAGE_MAP_AND_DIRECTORY_POINTER)\r
**/\r
EFI_STATUS\r
Thunk32To64 (\r
- EFI_PHYSICAL_ADDRESS PageTableAddress,\r
- SWITCH_32_TO_64_CONTEXT *Context,\r
- SWITCH_64_TO_32_CONTEXT *ReturnContext\r
+ EFI_PHYSICAL_ADDRESS PageTableAddress,\r
+ SWITCH_32_TO_64_CONTEXT *Context,\r
+ SWITCH_64_TO_32_CONTEXT *ReturnContext\r
)\r
{\r
- UINTN SetJumpFlag;\r
- EFI_STATUS Status;\r
+ UINTN SetJumpFlag;\r
+ EFI_STATUS Status;\r
\r
//\r
// Save return address, LongJump will return here then\r
//\r
- SetJumpFlag = SetJump ((BASE_LIBRARY_JUMP_BUFFER *) (UINTN) Context->JumpBuffer);\r
+ SetJumpFlag = SetJump ((BASE_LIBRARY_JUMP_BUFFER *)(UINTN)Context->JumpBuffer);\r
\r
if (SetJumpFlag == 0) {\r
-\r
//\r
// Build 4G Page Tables.\r
//\r
//\r
// Write CR3\r
//\r
- AsmWriteCr3 ((UINTN) PageTableAddress);\r
+ AsmWriteCr3 ((UINTN)PageTableAddress);\r
\r
DEBUG ((\r
DEBUG_INFO,\r
// Transfer to long mode\r
//\r
AsmEnablePaging64 (\r
- 0x38,\r
- (UINT64) Context->EntryPoint,\r
- (UINT64)(UINTN) Context,\r
- (UINT64)(UINTN) ReturnContext,\r
+ 0x38,\r
+ (UINT64)Context->EntryPoint,\r
+ (UINT64)(UINTN)Context,\r
+ (UINT64)(UINTN)ReturnContext,\r
Context->StackBufferBase + Context->StackBufferLength\r
);\r
}\r
// Convert to 32-bit Status and return\r
//\r
Status = EFI_SUCCESS;\r
- if ((UINTN) ReturnContext->ReturnStatus != 0) {\r
- Status = ENCODE_ERROR ((UINTN) ReturnContext->ReturnStatus);\r
+ if ((UINTN)ReturnContext->ReturnStatus != 0) {\r
+ Status = ENCODE_ERROR ((UINTN)ReturnContext->ReturnStatus);\r
}\r
\r
return Status;\r
**/\r
EFI_STATUS\r
ModeSwitch (\r
- IN EFI_CAPSULE_LONG_MODE_BUFFER *LongModeBuffer,\r
- IN COALESCE_ENTRY CoalesceEntry,\r
- IN EFI_PHYSICAL_ADDRESS BlockListAddr,\r
- IN MEMORY_RESOURCE_DESCRIPTOR *MemoryResource,\r
- IN OUT VOID **MemoryBase,\r
- IN OUT UINTN *MemorySize\r
+ IN EFI_CAPSULE_LONG_MODE_BUFFER *LongModeBuffer,\r
+ IN COALESCE_ENTRY CoalesceEntry,\r
+ IN EFI_PHYSICAL_ADDRESS BlockListAddr,\r
+ IN MEMORY_RESOURCE_DESCRIPTOR *MemoryResource,\r
+ IN OUT VOID **MemoryBase,\r
+ IN OUT UINTN *MemorySize\r
)\r
{\r
- EFI_STATUS Status;\r
- EFI_PHYSICAL_ADDRESS MemoryBase64;\r
- UINT64 MemorySize64;\r
- EFI_PHYSICAL_ADDRESS MemoryEnd64;\r
- SWITCH_32_TO_64_CONTEXT Context;\r
- SWITCH_64_TO_32_CONTEXT ReturnContext;\r
- BASE_LIBRARY_JUMP_BUFFER JumpBuffer;\r
- EFI_PHYSICAL_ADDRESS ReservedRangeBase;\r
- EFI_PHYSICAL_ADDRESS ReservedRangeEnd;\r
- BOOLEAN Page1GSupport;\r
+ EFI_STATUS Status;\r
+ EFI_PHYSICAL_ADDRESS MemoryBase64;\r
+ UINT64 MemorySize64;\r
+ EFI_PHYSICAL_ADDRESS MemoryEnd64;\r
+ SWITCH_32_TO_64_CONTEXT Context;\r
+ SWITCH_64_TO_32_CONTEXT ReturnContext;\r
+ BASE_LIBRARY_JUMP_BUFFER JumpBuffer;\r
+ EFI_PHYSICAL_ADDRESS ReservedRangeBase;\r
+ EFI_PHYSICAL_ADDRESS ReservedRangeEnd;\r
+ BOOLEAN Page1GSupport;\r
\r
ZeroMem (&Context, sizeof (SWITCH_32_TO_64_CONTEXT));\r
ZeroMem (&ReturnContext, sizeof (SWITCH_64_TO_32_CONTEXT));\r
\r
- MemoryBase64 = (UINT64) (UINTN) *MemoryBase;\r
- MemorySize64 = (UINT64) (UINTN) *MemorySize;\r
- MemoryEnd64 = MemoryBase64 + MemorySize64;\r
+ MemoryBase64 = (UINT64)(UINTN)*MemoryBase;\r
+ MemorySize64 = (UINT64)(UINTN)*MemorySize;\r
+ MemoryEnd64 = MemoryBase64 + MemorySize64;\r
\r
Page1GSupport = IsPage1GSupport ();\r
\r
return EFI_OUT_OF_RESOURCES;\r
}\r
} else if (ReservedRangeBase < MemoryEnd64) {\r
- if (ReservedRangeEnd < MemoryEnd64 &&\r
- ReservedRangeBase - MemoryBase64 < MemoryEnd64 - ReservedRangeEnd) {\r
+ if ((ReservedRangeEnd < MemoryEnd64) &&\r
+ (ReservedRangeBase - MemoryBase64 < MemoryEnd64 - ReservedRangeEnd))\r
+ {\r
MemoryBase64 = ReservedRangeEnd;\r
} else {\r
MemorySize64 = (UINT64)(UINTN)(ReservedRangeBase - MemoryBase64);\r
//\r
// Initialize context jumping to 64-bit enviroment\r
//\r
- Context.JumpBuffer = (EFI_PHYSICAL_ADDRESS)(UINTN)&JumpBuffer;\r
- Context.StackBufferBase = LongModeBuffer->StackBaseAddress;\r
- Context.StackBufferLength = LongModeBuffer->StackSize;\r
- Context.EntryPoint = (EFI_PHYSICAL_ADDRESS)(UINTN)CoalesceEntry;\r
- Context.BlockListAddr = BlockListAddr;\r
- Context.MemoryResource = (EFI_PHYSICAL_ADDRESS)(UINTN)MemoryResource;\r
- Context.MemoryBase64Ptr = (EFI_PHYSICAL_ADDRESS)(UINTN)&MemoryBase64;\r
- Context.MemorySize64Ptr = (EFI_PHYSICAL_ADDRESS)(UINTN)&MemorySize64;\r
- Context.Page1GSupport = Page1GSupport;\r
- Context.AddressEncMask = PcdGet64 (PcdPteMemoryEncryptionAddressOrMask) & PAGING_1G_ADDRESS_MASK_64;\r
+ Context.JumpBuffer = (EFI_PHYSICAL_ADDRESS)(UINTN)&JumpBuffer;\r
+ Context.StackBufferBase = LongModeBuffer->StackBaseAddress;\r
+ Context.StackBufferLength = LongModeBuffer->StackSize;\r
+ Context.EntryPoint = (EFI_PHYSICAL_ADDRESS)(UINTN)CoalesceEntry;\r
+ Context.BlockListAddr = BlockListAddr;\r
+ Context.MemoryResource = (EFI_PHYSICAL_ADDRESS)(UINTN)MemoryResource;\r
+ Context.MemoryBase64Ptr = (EFI_PHYSICAL_ADDRESS)(UINTN)&MemoryBase64;\r
+ Context.MemorySize64Ptr = (EFI_PHYSICAL_ADDRESS)(UINTN)&MemorySize64;\r
+ Context.Page1GSupport = Page1GSupport;\r
+ Context.AddressEncMask = PcdGet64 (PcdPteMemoryEncryptionAddressOrMask) & PAGING_1G_ADDRESS_MASK_64;\r
\r
//\r
// Prepare data for return back\r
//\r
- ReturnContext.ReturnCs = 0x10;\r
- ReturnContext.ReturnEntryPoint = (EFI_PHYSICAL_ADDRESS)(UINTN)ReturnFunction;\r
+ ReturnContext.ReturnCs = 0x10;\r
+ ReturnContext.ReturnEntryPoint = (EFI_PHYSICAL_ADDRESS)(UINTN)ReturnFunction;\r
//\r
// Will save the return status of processing capsule\r
//\r
- ReturnContext.ReturnStatus = 0;\r
+ ReturnContext.ReturnStatus = 0;\r
\r
//\r
// Save original GDT\r
Status = Thunk32To64 (LongModeBuffer->PageTableAddress, &Context, &ReturnContext);\r
\r
if (!EFI_ERROR (Status)) {\r
- *MemoryBase = (VOID *) (UINTN) MemoryBase64;\r
- *MemorySize = (UINTN) MemorySize64;\r
+ *MemoryBase = (VOID *)(UINTN)MemoryBase64;\r
+ *MemorySize = (UINTN)MemorySize64;\r
}\r
\r
return Status;\r
-\r
}\r
\r
/**\r
**/\r
EFI_STATUS\r
FindCapsuleCoalesceImage (\r
- OUT EFI_PHYSICAL_ADDRESS *CoalesceImageEntryPoint,\r
- OUT UINT16 *CoalesceImageMachineType\r
+ OUT EFI_PHYSICAL_ADDRESS *CoalesceImageEntryPoint,\r
+ OUT UINT16 *CoalesceImageMachineType\r
)\r
{\r
- EFI_STATUS Status;\r
- UINTN Instance;\r
- EFI_PEI_LOAD_FILE_PPI *LoadFile;\r
- EFI_PEI_FV_HANDLE VolumeHandle;\r
- EFI_PEI_FILE_HANDLE FileHandle;\r
- EFI_PHYSICAL_ADDRESS CoalesceImageAddress;\r
- UINT64 CoalesceImageSize;\r
- UINT32 AuthenticationState;\r
+ EFI_STATUS Status;\r
+ UINTN Instance;\r
+ EFI_PEI_LOAD_FILE_PPI *LoadFile;\r
+ EFI_PEI_FV_HANDLE VolumeHandle;\r
+ EFI_PEI_FILE_HANDLE FileHandle;\r
+ EFI_PHYSICAL_ADDRESS CoalesceImageAddress;\r
+ UINT64 CoalesceImageSize;\r
+ UINT32 AuthenticationState;\r
\r
Instance = 0;\r
\r
if (EFI_ERROR (Status)) {\r
return Status;\r
}\r
- Status = PeiServicesFfsFindFileByName (PcdGetPtr(PcdCapsuleCoalesceFile), VolumeHandle, &FileHandle);\r
+\r
+ Status = PeiServicesFfsFindFileByName (PcdGetPtr (PcdCapsuleCoalesceFile), VolumeHandle, &FileHandle);\r
if (!EFI_ERROR (Status)) {\r
- Status = PeiServicesLocatePpi (&gEfiPeiLoadFilePpiGuid, 0, NULL, (VOID **) &LoadFile);\r
+ Status = PeiServicesLocatePpi (&gEfiPeiLoadFilePpiGuid, 0, NULL, (VOID **)&LoadFile);\r
ASSERT_EFI_ERROR (Status);\r
\r
Status = LoadFile->LoadFile (\r
DEBUG ((DEBUG_ERROR, "Unable to find PE32 section in CapsuleX64 image ffs %r!\n", Status));\r
return Status;\r
}\r
- *CoalesceImageMachineType = PeCoffLoaderGetMachineType ((VOID *) (UINTN) CoalesceImageAddress);\r
+\r
+ *CoalesceImageMachineType = PeCoffLoaderGetMachineType ((VOID *)(UINTN)CoalesceImageAddress);\r
break;\r
} else {\r
continue;\r
**/\r
EFI_STATUS\r
GetLongModeContext (\r
- OUT EFI_CAPSULE_LONG_MODE_BUFFER *LongModeBuffer\r
+ OUT EFI_CAPSULE_LONG_MODE_BUFFER *LongModeBuffer\r
)\r
{\r
- EFI_STATUS Status;\r
- UINTN Size;\r
- EFI_PEI_READ_ONLY_VARIABLE2_PPI *PPIVariableServices;\r
+ EFI_STATUS Status;\r
+ UINTN Size;\r
+ EFI_PEI_READ_ONLY_VARIABLE2_PPI *PPIVariableServices;\r
\r
Status = PeiServicesLocatePpi (\r
&gEfiPeiReadOnlyVariable2PpiGuid,\r
0,\r
NULL,\r
- (VOID **) &PPIVariableServices\r
+ (VOID **)&PPIVariableServices\r
);\r
ASSERT_EFI_ERROR (Status);\r
\r
- Size = sizeof (EFI_CAPSULE_LONG_MODE_BUFFER);\r
+ Size = sizeof (EFI_CAPSULE_LONG_MODE_BUFFER);\r
Status = PPIVariableServices->GetVariable (\r
PPIVariableServices,\r
EFI_CAPSULE_LONG_MODE_BUFFER_NAME,\r
LongModeBuffer\r
);\r
if (EFI_ERROR (Status)) {\r
- DEBUG (( DEBUG_ERROR, "Error Get LongModeBuffer variable %r!\n", Status));\r
+ DEBUG ((DEBUG_ERROR, "Error Get LongModeBuffer variable %r!\n", Status));\r
}\r
+\r
return Status;\r
}\r
+\r
#endif\r
\r
#if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)\r
+\r
/**\r
Get physical address bits.\r
\r
VOID\r
)\r
{\r
- UINT32 RegEax;\r
- UINT8 PhysicalAddressBits;\r
- VOID *Hob;\r
+ UINT32 RegEax;\r
+ UINT8 PhysicalAddressBits;\r
+ VOID *Hob;\r
\r
//\r
// Get physical address bits supported.\r
//\r
Hob = GetFirstHob (EFI_HOB_TYPE_CPU);\r
if (Hob != NULL) {\r
- PhysicalAddressBits = ((EFI_HOB_CPU *) Hob)->SizeOfMemorySpace;\r
+ PhysicalAddressBits = ((EFI_HOB_CPU *)Hob)->SizeOfMemorySpace;\r
} else {\r
AsmCpuid (0x80000000, &RegEax, NULL, NULL, NULL);\r
if (RegEax >= 0x80000008) {\r
AsmCpuid (0x80000008, &RegEax, NULL, NULL, NULL);\r
- PhysicalAddressBits = (UINT8) RegEax;\r
+ PhysicalAddressBits = (UINT8)RegEax;\r
} else {\r
PhysicalAddressBits = 36;\r
}\r
\r
return PhysicalAddressBits;\r
}\r
+\r
#endif\r
\r
/**\r
**/\r
VOID\r
SortMemoryResourceDescriptor (\r
- IN OUT MEMORY_RESOURCE_DESCRIPTOR *MemoryResource\r
+ IN OUT MEMORY_RESOURCE_DESCRIPTOR *MemoryResource\r
)\r
{\r
- MEMORY_RESOURCE_DESCRIPTOR *MemoryResourceEntry;\r
- MEMORY_RESOURCE_DESCRIPTOR *NextMemoryResourceEntry;\r
- MEMORY_RESOURCE_DESCRIPTOR TempMemoryResource;\r
+ MEMORY_RESOURCE_DESCRIPTOR *MemoryResourceEntry;\r
+ MEMORY_RESOURCE_DESCRIPTOR *NextMemoryResourceEntry;\r
+ MEMORY_RESOURCE_DESCRIPTOR TempMemoryResource;\r
\r
- MemoryResourceEntry = MemoryResource;\r
+ MemoryResourceEntry = MemoryResource;\r
NextMemoryResourceEntry = MemoryResource + 1;\r
while (MemoryResourceEntry->ResourceLength != 0) {\r
while (NextMemoryResourceEntry->ResourceLength != 0) {\r
**/\r
VOID\r
MergeMemoryResourceDescriptor (\r
- IN OUT MEMORY_RESOURCE_DESCRIPTOR *MemoryResource\r
+ IN OUT MEMORY_RESOURCE_DESCRIPTOR *MemoryResource\r
)\r
{\r
- MEMORY_RESOURCE_DESCRIPTOR *MemoryResourceEntry;\r
- MEMORY_RESOURCE_DESCRIPTOR *NewMemoryResourceEntry;\r
- MEMORY_RESOURCE_DESCRIPTOR *NextMemoryResourceEntry;\r
- MEMORY_RESOURCE_DESCRIPTOR *MemoryResourceEnd;\r
+ MEMORY_RESOURCE_DESCRIPTOR *MemoryResourceEntry;\r
+ MEMORY_RESOURCE_DESCRIPTOR *NewMemoryResourceEntry;\r
+ MEMORY_RESOURCE_DESCRIPTOR *NextMemoryResourceEntry;\r
+ MEMORY_RESOURCE_DESCRIPTOR *MemoryResourceEnd;\r
\r
- MemoryResourceEntry = MemoryResource;\r
+ MemoryResourceEntry = MemoryResource;\r
NewMemoryResourceEntry = MemoryResource;\r
while (MemoryResourceEntry->ResourceLength != 0) {\r
CopyMem (NewMemoryResourceEntry, MemoryResourceEntry, sizeof (MEMORY_RESOURCE_DESCRIPTOR));\r
NextMemoryResourceEntry = MemoryResourceEntry + 1;\r
\r
while ((NextMemoryResourceEntry->ResourceLength != 0) &&\r
- (NextMemoryResourceEntry->PhysicalStart == (MemoryResourceEntry->PhysicalStart + MemoryResourceEntry->ResourceLength))) {\r
+ (NextMemoryResourceEntry->PhysicalStart == (MemoryResourceEntry->PhysicalStart + MemoryResourceEntry->ResourceLength)))\r
+ {\r
MemoryResourceEntry->ResourceLength += NextMemoryResourceEntry->ResourceLength;\r
if (NewMemoryResourceEntry != MemoryResourceEntry) {\r
NewMemoryResourceEntry->ResourceLength += NextMemoryResourceEntry->ResourceLength;\r
NextMemoryResourceEntry = NextMemoryResourceEntry + 1;\r
}\r
\r
- MemoryResourceEntry = NextMemoryResourceEntry;\r
+ MemoryResourceEntry = NextMemoryResourceEntry;\r
NewMemoryResourceEntry = NewMemoryResourceEntry + 1;\r
}\r
\r
VOID\r
)\r
{\r
- EFI_PEI_HOB_POINTERS Hob;\r
- UINTN Index;\r
- EFI_HOB_RESOURCE_DESCRIPTOR *ResourceDescriptor;\r
- MEMORY_RESOURCE_DESCRIPTOR *MemoryResource;\r
- EFI_STATUS Status;\r
+ EFI_PEI_HOB_POINTERS Hob;\r
+ UINTN Index;\r
+ EFI_HOB_RESOURCE_DESCRIPTOR *ResourceDescriptor;\r
+ MEMORY_RESOURCE_DESCRIPTOR *MemoryResource;\r
+ EFI_STATUS Status;\r
\r
//\r
// Get the count of memory resource descriptor.\r
//\r
- Index = 0;\r
+ Index = 0;\r
Hob.Raw = GetFirstHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR);\r
while (Hob.Raw != NULL) {\r
- ResourceDescriptor = (EFI_HOB_RESOURCE_DESCRIPTOR *) Hob.Raw;\r
+ ResourceDescriptor = (EFI_HOB_RESOURCE_DESCRIPTOR *)Hob.Raw;\r
if (ResourceDescriptor->ResourceType == EFI_RESOURCE_SYSTEM_MEMORY) {\r
Index++;\r
}\r
+\r
Hob.Raw = GET_NEXT_HOB (Hob);\r
Hob.Raw = GetNextHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR, Hob.Raw);\r
}\r
\r
if (Index == 0) {\r
DEBUG ((DEBUG_INFO | DEBUG_WARN, "No memory resource descriptor reported in HOB list before capsule Coalesce\n"));\r
-#if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)\r
+ #if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)\r
//\r
// Allocate memory to hold memory resource descriptor,\r
// include extra one NULL terminate memory resource descriptor.\r
//\r
- Status = PeiServicesAllocatePool ((1 + 1) * sizeof (MEMORY_RESOURCE_DESCRIPTOR), (VOID **) &MemoryResource);\r
+ Status = PeiServicesAllocatePool ((1 + 1) * sizeof (MEMORY_RESOURCE_DESCRIPTOR), (VOID **)&MemoryResource);\r
ASSERT_EFI_ERROR (Status);\r
ZeroMem (MemoryResource, (1 + 1) * sizeof (MEMORY_RESOURCE_DESCRIPTOR));\r
\r
- MemoryResource[0].PhysicalStart = 0;\r
+ MemoryResource[0].PhysicalStart = 0;\r
MemoryResource[0].ResourceLength = LShiftU64 (1, GetPhysicalAddressBits ());\r
- DEBUG ((DEBUG_INFO, "MemoryResource[0x0] - Start(0x%0lx) Length(0x%0lx)\n",\r
- MemoryResource[0x0].PhysicalStart, MemoryResource[0x0].ResourceLength));\r
+ DEBUG ((\r
+ DEBUG_INFO,\r
+ "MemoryResource[0x0] - Start(0x%0lx) Length(0x%0lx)\n",\r
+ MemoryResource[0x0].PhysicalStart,\r
+ MemoryResource[0x0].ResourceLength\r
+ ));\r
return MemoryResource;\r
-#else\r
+ #else\r
return NULL;\r
-#endif\r
+ #endif\r
}\r
\r
//\r
// Allocate memory to hold memory resource descriptor,\r
// include extra one NULL terminate memory resource descriptor.\r
//\r
- Status = PeiServicesAllocatePool ((Index + 1) * sizeof (MEMORY_RESOURCE_DESCRIPTOR), (VOID **) &MemoryResource);\r
+ Status = PeiServicesAllocatePool ((Index + 1) * sizeof (MEMORY_RESOURCE_DESCRIPTOR), (VOID **)&MemoryResource);\r
ASSERT_EFI_ERROR (Status);\r
ZeroMem (MemoryResource, (Index + 1) * sizeof (MEMORY_RESOURCE_DESCRIPTOR));\r
\r
//\r
// Get the content of memory resource descriptor.\r
//\r
- Index = 0;\r
+ Index = 0;\r
Hob.Raw = GetFirstHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR);\r
while (Hob.Raw != NULL) {\r
- ResourceDescriptor = (EFI_HOB_RESOURCE_DESCRIPTOR *) Hob.Raw;\r
+ ResourceDescriptor = (EFI_HOB_RESOURCE_DESCRIPTOR *)Hob.Raw;\r
if (ResourceDescriptor->ResourceType == EFI_RESOURCE_SYSTEM_MEMORY) {\r
- DEBUG ((DEBUG_INFO, "MemoryResource[0x%x] - Start(0x%0lx) Length(0x%0lx)\n",\r
- Index, ResourceDescriptor->PhysicalStart, ResourceDescriptor->ResourceLength));\r
- MemoryResource[Index].PhysicalStart = ResourceDescriptor->PhysicalStart;\r
+ DEBUG ((\r
+ DEBUG_INFO,\r
+ "MemoryResource[0x%x] - Start(0x%0lx) Length(0x%0lx)\n",\r
+ Index,\r
+ ResourceDescriptor->PhysicalStart,\r
+ ResourceDescriptor->ResourceLength\r
+ ));\r
+ MemoryResource[Index].PhysicalStart = ResourceDescriptor->PhysicalStart;\r
MemoryResource[Index].ResourceLength = ResourceDescriptor->ResourceLength;\r
Index++;\r
}\r
+\r
Hob.Raw = GET_NEXT_HOB (Hob);\r
Hob.Raw = GetNextHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR, Hob.Raw);\r
}\r
VOID\r
)\r
{\r
- EFI_STATUS Status;\r
- UINTN Size;\r
- EFI_PEI_READ_ONLY_VARIABLE2_PPI *PPIVariableServices;\r
- EFI_PHYSICAL_ADDRESS CapsuleDataPtr64;\r
+ EFI_STATUS Status;\r
+ UINTN Size;\r
+ EFI_PEI_READ_ONLY_VARIABLE2_PPI *PPIVariableServices;\r
+ EFI_PHYSICAL_ADDRESS CapsuleDataPtr64;\r
\r
CapsuleDataPtr64 = 0;\r
\r
- Status = PeiServicesLocatePpi(\r
- &gEfiPeiReadOnlyVariable2PpiGuid,\r
- 0,\r
- NULL,\r
- (VOID **)&PPIVariableServices\r
- );\r
+ Status = PeiServicesLocatePpi (\r
+ &gEfiPeiReadOnlyVariable2PpiGuid,\r
+ 0,\r
+ NULL,\r
+ (VOID **)&PPIVariableServices\r
+ );\r
\r
if (EFI_ERROR (Status)) {\r
DEBUG ((DEBUG_ERROR, "Failed to find ReadOnlyVariable2PPI\n"));\r
//\r
// Check for Update capsule\r
//\r
- Size = sizeof (CapsuleDataPtr64);\r
+ Size = sizeof (CapsuleDataPtr64);\r
Status = PPIVariableServices->GetVariable (\r
PPIVariableServices,\r
EFI_CAPSULE_VARIABLE_NAME,\r
**/\r
EFI_STATUS\r
GetScatterGatherHeadEntries (\r
- OUT UINTN *ListLength,\r
- OUT EFI_PHYSICAL_ADDRESS **HeadList\r
+ OUT UINTN *ListLength,\r
+ OUT EFI_PHYSICAL_ADDRESS **HeadList\r
)\r
{\r
- EFI_STATUS Status;\r
- UINTN Size;\r
- UINTN Index;\r
- UINTN TempIndex;\r
- UINTN ValidIndex;\r
- BOOLEAN Flag;\r
- CHAR16 CapsuleVarName[30];\r
- CHAR16 *TempVarName;\r
- EFI_PHYSICAL_ADDRESS CapsuleDataPtr64;\r
- EFI_PEI_READ_ONLY_VARIABLE2_PPI *PPIVariableServices;\r
- EFI_PHYSICAL_ADDRESS *TempList;\r
- EFI_PHYSICAL_ADDRESS *EnlargedTempList;\r
- UINTN TempListLength;\r
+ EFI_STATUS Status;\r
+ UINTN Size;\r
+ UINTN Index;\r
+ UINTN TempIndex;\r
+ UINTN ValidIndex;\r
+ BOOLEAN Flag;\r
+ CHAR16 CapsuleVarName[30];\r
+ CHAR16 *TempVarName;\r
+ EFI_PHYSICAL_ADDRESS CapsuleDataPtr64;\r
+ EFI_PEI_READ_ONLY_VARIABLE2_PPI *PPIVariableServices;\r
+ EFI_PHYSICAL_ADDRESS *TempList;\r
+ EFI_PHYSICAL_ADDRESS *EnlargedTempList;\r
+ UINTN TempListLength;\r
\r
Index = 0;\r
TempVarName = NULL;\r
}\r
\r
*ListLength = 0;\r
- *HeadList = NULL;\r
+ *HeadList = NULL;\r
\r
Status = PeiServicesLocatePpi (\r
- &gEfiPeiReadOnlyVariable2PpiGuid,\r
- 0,\r
- NULL,\r
- (VOID **)&PPIVariableServices\r
- );\r
+ &gEfiPeiReadOnlyVariable2PpiGuid,\r
+ 0,\r
+ NULL,\r
+ (VOID **)&PPIVariableServices\r
+ );\r
\r
if (EFI_ERROR (Status)) {\r
DEBUG ((DEBUG_ERROR, "Failed to find ReadOnlyVariable2PPI\n"));\r
// Allocate memory for sg list head\r
//\r
TempListLength = DEFAULT_SG_LIST_HEADS * sizeof (EFI_PHYSICAL_ADDRESS);\r
- TempList = AllocateZeroPool (TempListLength);\r
+ TempList = AllocateZeroPool (TempListLength);\r
if (TempList == NULL) {\r
- DEBUG((DEBUG_ERROR, "Failed to allocate memory\n"));\r
+ DEBUG ((DEBUG_ERROR, "Failed to allocate memory\n"));\r
return EFI_OUT_OF_RESOURCES;\r
}\r
\r
0\r
);\r
}\r
- Size = sizeof (CapsuleDataPtr64);\r
+\r
+ Size = sizeof (CapsuleDataPtr64);\r
Status = PPIVariableServices->GetVariable (\r
PPIVariableServices,\r
CapsuleVarName,\r
if (Status != EFI_NOT_FOUND) {\r
DEBUG ((DEBUG_ERROR, "Unexpected error getting Capsule Update variable. Status = %r\n"));\r
}\r
+\r
break;\r
}\r
\r
break;\r
}\r
}\r
+\r
if (Flag) {\r
Index++;\r
continue;\r
DEBUG ((DEBUG_ERROR, "Fail to allocate memory!\n"));\r
return EFI_OUT_OF_RESOURCES;\r
}\r
+\r
CopyMem (EnlargedTempList, TempList, TempListLength);\r
FreePool (TempList);\r
- TempList = EnlargedTempList;\r
+ TempList = EnlargedTempList;\r
TempListLength *= 2;\r
}\r
\r
EFI_STATUS\r
EFIAPI\r
CapsuleCoalesce (\r
- IN EFI_PEI_SERVICES **PeiServices,\r
- IN OUT VOID **MemoryBase,\r
- IN OUT UINTN *MemorySize\r
+ IN EFI_PEI_SERVICES **PeiServices,\r
+ IN OUT VOID **MemoryBase,\r
+ IN OUT UINTN *MemorySize\r
)\r
{\r
- EFI_STATUS Status;\r
- EFI_BOOT_MODE BootMode;\r
- UINTN ListLength;\r
- EFI_PHYSICAL_ADDRESS *VariableArrayAddress;\r
- MEMORY_RESOURCE_DESCRIPTOR *MemoryResource;\r
-#ifdef MDE_CPU_IA32\r
- UINT16 CoalesceImageMachineType;\r
- EFI_PHYSICAL_ADDRESS CoalesceImageEntryPoint;\r
- COALESCE_ENTRY CoalesceEntry;\r
- EFI_CAPSULE_LONG_MODE_BUFFER LongModeBuffer;\r
-#endif\r
-\r
- ListLength = 0;\r
+ EFI_STATUS Status;\r
+ EFI_BOOT_MODE BootMode;\r
+ UINTN ListLength;\r
+ EFI_PHYSICAL_ADDRESS *VariableArrayAddress;\r
+ MEMORY_RESOURCE_DESCRIPTOR *MemoryResource;\r
+\r
+ #ifdef MDE_CPU_IA32\r
+ UINT16 CoalesceImageMachineType;\r
+ EFI_PHYSICAL_ADDRESS CoalesceImageEntryPoint;\r
+ COALESCE_ENTRY CoalesceEntry;\r
+ EFI_CAPSULE_LONG_MODE_BUFFER LongModeBuffer;\r
+ #endif\r
+\r
+ ListLength = 0;\r
VariableArrayAddress = NULL;\r
\r
//\r
// Get SG list entries\r
//\r
Status = GetScatterGatherHeadEntries (&ListLength, &VariableArrayAddress);\r
- if (EFI_ERROR (Status) || VariableArrayAddress == NULL) {\r
+ if (EFI_ERROR (Status) || (VariableArrayAddress == NULL)) {\r
DEBUG ((DEBUG_ERROR, "%a failed to get Scatter Gather List Head Entries. Status = %r\n", __FUNCTION__, Status));\r
goto Done;\r
}\r
\r
MemoryResource = BuildMemoryResourceDescriptor ();\r
\r
-#ifdef MDE_CPU_IA32\r
+ #ifdef MDE_CPU_IA32\r
if (FeaturePcdGet (PcdDxeIplSwitchToLongMode)) {\r
//\r
// Switch to 64-bit mode to process capsule data when:\r
// In 64-bit mode, we can process capsule data above 4GB.\r
//\r
CoalesceImageEntryPoint = 0;\r
- Status = GetLongModeContext (&LongModeBuffer);\r
+ Status = GetLongModeContext (&LongModeBuffer);\r
if (EFI_ERROR (Status)) {\r
DEBUG ((DEBUG_ERROR, "Fail to find the variable for long mode context!\n"));\r
Status = EFI_NOT_FOUND;\r
Status = EFI_NOT_FOUND;\r
goto Done;\r
}\r
+\r
ASSERT (CoalesceImageEntryPoint != 0);\r
- CoalesceEntry = (COALESCE_ENTRY) (UINTN) CoalesceImageEntryPoint;\r
- Status = ModeSwitch (&LongModeBuffer, CoalesceEntry, (EFI_PHYSICAL_ADDRESS)(UINTN)VariableArrayAddress, MemoryResource, MemoryBase, MemorySize);\r
+ CoalesceEntry = (COALESCE_ENTRY)(UINTN)CoalesceImageEntryPoint;\r
+ Status = ModeSwitch (&LongModeBuffer, CoalesceEntry, (EFI_PHYSICAL_ADDRESS)(UINTN)VariableArrayAddress, MemoryResource, MemoryBase, MemorySize);\r
} else {\r
//\r
// Capsule is processed in IA32 mode.\r
//\r
Status = CapsuleDataCoalesce (PeiServices, (EFI_PHYSICAL_ADDRESS *)(UINTN)VariableArrayAddress, MemoryResource, MemoryBase, MemorySize);\r
}\r
-#else\r
+\r
+ #else\r
//\r
// Process capsule directly.\r
//\r
Status = CapsuleDataCoalesce (PeiServices, (EFI_PHYSICAL_ADDRESS *)(UINTN)VariableArrayAddress, MemoryResource, MemoryBase, MemorySize);\r
-#endif\r
+ #endif\r
\r
DEBUG ((DEBUG_INFO, "Capsule Coalesce Status = %r!\n", Status));\r
\r
EFI_STATUS\r
EFIAPI\r
CheckCapsuleUpdate (\r
- IN EFI_PEI_SERVICES **PeiServices\r
+ IN EFI_PEI_SERVICES **PeiServices\r
)\r
{\r
if (AreCapsulesStaged ()) {\r
return EFI_NOT_FOUND;\r
}\r
}\r
+\r
/**\r
This function will look at a capsule and determine if it's a test pattern.\r
If it is, then it will verify it and emit an error message if corruption is detected.\r
**/\r
BOOLEAN\r
CapsuleTestPattern (\r
- IN EFI_PEI_SERVICES **PeiServices,\r
- IN VOID *CapsuleBase\r
+ IN EFI_PEI_SERVICES **PeiServices,\r
+ IN VOID *CapsuleBase\r
)\r
{\r
- UINT32 *TestPtr;\r
- UINT32 TestCounter;\r
- UINT32 TestSize;\r
- BOOLEAN RetValue;\r
+ UINT32 *TestPtr;\r
+ UINT32 TestCounter;\r
+ UINT32 TestSize;\r
+ BOOLEAN RetValue;\r
\r
RetValue = FALSE;\r
\r
// Look at the capsule data and determine if it's a test pattern. If it\r
// is, then test it now.\r
//\r
- TestPtr = (UINT32 *) CapsuleBase;\r
+ TestPtr = (UINT32 *)CapsuleBase;\r
//\r
// 0x54534554 "TEST"\r
//\r
//\r
// Skip over the signature and the size fields in the pattern data header\r
//\r
- TestPtr += 2;\r
+ TestPtr += 2;\r
TestCounter = 0;\r
while (TestSize > 0) {\r
if (*TestPtr != TestCounter) {\r
EFI_STATUS\r
EFIAPI\r
CreateState (\r
- IN EFI_PEI_SERVICES **PeiServices,\r
- IN VOID *CapsuleBase,\r
- IN UINTN CapsuleSize\r
+ IN EFI_PEI_SERVICES **PeiServices,\r
+ IN VOID *CapsuleBase,\r
+ IN UINTN CapsuleSize\r
)\r
{\r
- EFI_STATUS Status;\r
- EFI_CAPSULE_PEIM_PRIVATE_DATA *PrivateData;\r
- UINTN Size;\r
- EFI_PHYSICAL_ADDRESS NewBuffer;\r
- UINTN CapsuleNumber;\r
- UINT32 Index;\r
- EFI_PHYSICAL_ADDRESS BaseAddress;\r
- UINT64 Length;\r
-\r
- PrivateData = (EFI_CAPSULE_PEIM_PRIVATE_DATA *) CapsuleBase;\r
+ EFI_STATUS Status;\r
+ EFI_CAPSULE_PEIM_PRIVATE_DATA *PrivateData;\r
+ UINTN Size;\r
+ EFI_PHYSICAL_ADDRESS NewBuffer;\r
+ UINTN CapsuleNumber;\r
+ UINT32 Index;\r
+ EFI_PHYSICAL_ADDRESS BaseAddress;\r
+ UINT64 Length;\r
+\r
+ PrivateData = (EFI_CAPSULE_PEIM_PRIVATE_DATA *)CapsuleBase;\r
if (PrivateData->Signature != EFI_CAPSULE_PEIM_PRIVATE_DATA_SIGNATURE) {\r
return EFI_VOLUME_CORRUPTED;\r
}\r
+\r
if (PrivateData->CapsuleAllImageSize >= MAX_ADDRESS) {\r
DEBUG ((DEBUG_ERROR, "CapsuleAllImageSize too big - 0x%lx\n", PrivateData->CapsuleAllImageSize));\r
return EFI_OUT_OF_RESOURCES;\r
}\r
+\r
if (PrivateData->CapsuleNumber >= MAX_ADDRESS) {\r
DEBUG ((DEBUG_ERROR, "CapsuleNumber too big - 0x%lx\n", PrivateData->CapsuleNumber));\r
return EFI_OUT_OF_RESOURCES;\r
}\r
+\r
//\r
// Capsule Number and Capsule Offset is in the tail of Capsule data.\r
//\r
DEBUG ((DEBUG_ERROR, "AllocatePages Failed!\n"));\r
return Status;\r
}\r
+\r
//\r
// Copy to our new buffer for DXE\r
//\r
- DEBUG ((DEBUG_INFO, "Capsule copy from 0x%8X to 0x%8X with size 0x%8X\n", (UINTN)((UINT8 *)PrivateData + sizeof(EFI_CAPSULE_PEIM_PRIVATE_DATA) + (CapsuleNumber - 1) * sizeof(UINT64)), (UINTN) NewBuffer, Size));\r
- CopyMem ((VOID *) (UINTN) NewBuffer, (VOID *) (UINTN) ((UINT8 *)PrivateData + sizeof(EFI_CAPSULE_PEIM_PRIVATE_DATA) + (CapsuleNumber - 1) * sizeof(UINT64)), Size);\r
+ DEBUG ((DEBUG_INFO, "Capsule copy from 0x%8X to 0x%8X with size 0x%8X\n", (UINTN)((UINT8 *)PrivateData + sizeof (EFI_CAPSULE_PEIM_PRIVATE_DATA) + (CapsuleNumber - 1) * sizeof (UINT64)), (UINTN)NewBuffer, Size));\r
+ CopyMem ((VOID *)(UINTN)NewBuffer, (VOID *)(UINTN)((UINT8 *)PrivateData + sizeof (EFI_CAPSULE_PEIM_PRIVATE_DATA) + (CapsuleNumber - 1) * sizeof (UINT64)), Size);\r
//\r
// Check for test data pattern. If it is the test pattern, then we'll\r
// test it and still create the HOB so that it can be used to verify\r
// corrupted so nothing will happen.\r
//\r
DEBUG_CODE (\r
- CapsuleTestPattern (PeiServices, (VOID *) (UINTN) NewBuffer);\r
- );\r
+ CapsuleTestPattern (PeiServices, (VOID *)(UINTN)NewBuffer);\r
+ );\r
\r
//\r
// Build the UEFI Capsule Hob for each capsule image.\r
//\r
- for (Index = 0; Index < CapsuleNumber; Index ++) {\r
+ for (Index = 0; Index < CapsuleNumber; Index++) {\r
BaseAddress = NewBuffer + PrivateData->CapsuleOffset[Index];\r
- Length = ((EFI_CAPSULE_HEADER *)((UINTN) BaseAddress))->CapsuleImageSize;\r
+ Length = ((EFI_CAPSULE_HEADER *)((UINTN)BaseAddress))->CapsuleImageSize;\r
\r
BuildCvHob (BaseAddress, Length);\r
}\r
return EFI_SUCCESS;\r
}\r
\r
-CONST EFI_PEI_CAPSULE_PPI mCapsulePpi = {\r
+CONST EFI_PEI_CAPSULE_PPI mCapsulePpi = {\r
CapsuleCoalesce,\r
CheckCapsuleUpdate,\r
CreateState\r
};\r
\r
-CONST EFI_PEI_PPI_DESCRIPTOR mUefiPpiListCapsule = {\r
+CONST EFI_PEI_PPI_DESCRIPTOR mUefiPpiListCapsule = {\r
(EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
&gEfiPeiCapsulePpiGuid,\r
- (EFI_PEI_CAPSULE_PPI *) &mCapsulePpi\r
+ (EFI_PEI_CAPSULE_PPI *)&mCapsulePpi\r
};\r
\r
/**\r