2 The logic to process capsule.
4 Caution: This module requires additional review when modified.
5 This driver will have external input - capsule image.
6 This external input must be validated carefully to avoid security issue like
7 buffer overflow, integer overflow.
9 CapsuleDataCoalesce() will do basic validation before coalesce capsule data
12 (C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR>
13 Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
14 This program and the accompanying materials
15 are licensed and made available under the terms and conditions of the BSD License
16 which accompanies this distribution. The full text of the license may be found at
17 http://opensource.org/licenses/bsd-license.php
19 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
20 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
27 #include <Guid/CapsuleVendor.h>
29 #include <Library/BaseMemoryLib.h>
30 #include <Library/DebugLib.h>
31 #include <Library/PrintLib.h>
32 #include <Library/BaseLib.h>
34 #include "CommonHeader.h"
36 #define MIN_COALESCE_ADDR (1024 * 1024)
39 Given a pointer to the capsule block list, info on the available system
40 memory, and the size of a buffer, find a free block of memory where a
41 buffer of the given size can be copied to safely.
43 @param BlockList Pointer to head of capsule block descriptors
44 @param MemBase Pointer to the base of memory in which we want to find free space
45 @param MemSize The size of the block of memory pointed to by MemBase
46 @param DataSize How big a free block we want to find
48 @return A pointer to a memory block of at least DataSize that lies somewhere
49 between MemBase and (MemBase + MemSize). The memory pointed to does not
50 contain any of the capsule block descriptors or capsule blocks pointed to
56 EFI_CAPSULE_BLOCK_DESCRIPTOR
*BlockList
,
63 The capsule block descriptors may be fragmented and spread all over memory.
64 To simplify the coalescing of capsule blocks, first coalesce all the
65 capsule block descriptors low in memory.
67 The descriptors passed in can be fragmented throughout memory. Here
68 they are relocated into memory to turn them into a contiguous (null
71 @param PeiServices pointer to PEI services table
72 @param BlockList pointer to the capsule block descriptors
73 @param NumDescriptors number of capsule data block descriptors, whose Length is non-zero.
74 @param MemBase base of system memory in which we can work
75 @param MemSize size of the system memory pointed to by MemBase
77 @retval NULL could not relocate the descriptors
78 @retval Pointer to the base of the successfully-relocated block descriptors.
81 EFI_CAPSULE_BLOCK_DESCRIPTOR
*
82 RelocateBlockDescriptors (
83 IN EFI_PEI_SERVICES
**PeiServices
,
84 IN EFI_CAPSULE_BLOCK_DESCRIPTOR
*BlockList
,
85 IN UINTN NumDescriptors
,
91 Check every capsule header.
93 @param CapsuleHeader The pointer to EFI_CAPSULE_HEADER
95 @retval FALSE Capsule is OK
96 @retval TRUE Capsule is corrupted
101 IN EFI_CAPSULE_HEADER
*CapsuleHeader
105 Determine if two buffers overlap in memory.
107 @param Buff1 pointer to first buffer
108 @param Size1 size of Buff1
109 @param Buff2 pointer to second buffer
110 @param Size2 size of Buff2
112 @retval TRUE Buffers overlap in memory.
113 @retval FALSE Buffer doesn't overlap.
125 Given a pointer to a capsule block descriptor, traverse the list to figure
126 out how many legitimate descriptors there are, and how big the capsule it
129 @param Desc Pointer to the capsule block descriptors
130 @param NumDescriptors Optional pointer to where to return the number of capsule data descriptors, whose Length is non-zero.
131 @param CapsuleSize Optional pointer to where to return the capsule image size
132 @param CapsuleNumber Optional pointer to where to return the number of capsule
134 @retval EFI_NOT_FOUND No descriptors containing data in the list
135 @retval EFI_SUCCESS Return data is valid
140 IN EFI_CAPSULE_BLOCK_DESCRIPTOR
*Desc
,
141 IN OUT UINTN
*NumDescriptors OPTIONAL
,
142 IN OUT UINTN
*CapsuleSize OPTIONAL
,
143 IN OUT UINTN
*CapsuleNumber OPTIONAL
147 Given a pointer to the capsule block list, info on the available system
148 memory, and the size of a buffer, find a free block of memory where a
149 buffer of the given size can be copied to safely.
151 @param BlockList Pointer to head of capsule block descriptors
152 @param MemBase Pointer to the base of memory in which we want to find free space
153 @param MemSize The size of the block of memory pointed to by MemBase
154 @param DataSize How big a free block we want to find
156 @return A pointer to a memory block of at least DataSize that lies somewhere
157 between MemBase and (MemBase + MemSize). The memory pointed to does not
158 contain any of the capsule block descriptors or capsule blocks pointed to
164 EFI_CAPSULE_BLOCK_DESCRIPTOR
*BlockList
,
171 EFI_CAPSULE_BLOCK_DESCRIPTOR
*CurrDesc
;
172 EFI_CAPSULE_BLOCK_DESCRIPTOR
*TempDesc
;
177 // Need at least enough to copy the data to at the end of the buffer, so
178 // say the end is less the data size for easy comparisons here.
180 MemEnd
= MemBase
+ MemSize
- DataSize
;
181 CurrDesc
= BlockList
;
183 // Go through all the descriptor blocks and see if any obstruct the range
185 while (CurrDesc
!= NULL
) {
187 // Get the size of this block list and see if it's in the way
191 Size
= sizeof (EFI_CAPSULE_BLOCK_DESCRIPTOR
);
192 while (TempDesc
->Length
!= 0) {
193 Size
+= sizeof (EFI_CAPSULE_BLOCK_DESCRIPTOR
);
197 if (IsOverlapped (MemBase
, DataSize
, (UINT8
*) CurrDesc
, Size
)) {
199 // Set our new base to the end of this block list and start all over
201 MemBase
= (UINT8
*) CurrDesc
+ Size
;
202 CurrDesc
= BlockList
;
203 if (MemBase
> MemEnd
) {
210 // Now go through all the blocks and make sure none are in the way
212 while ((CurrDesc
->Length
!= 0) && (!Failed
)) {
213 if (IsOverlapped (MemBase
, DataSize
, (UINT8
*) (UINTN
) CurrDesc
->Union
.DataBlock
, (UINTN
) CurrDesc
->Length
)) {
215 // Set our new base to the end of this block and start all over
218 MemBase
= (UINT8
*) ((UINTN
) CurrDesc
->Union
.DataBlock
) + CurrDesc
->Length
;
219 CurrDesc
= BlockList
;
220 if (MemBase
> MemEnd
) {
227 // Normal continuation -- jump to next block descriptor list
230 CurrDesc
= (EFI_CAPSULE_BLOCK_DESCRIPTOR
*) (UINTN
) CurrDesc
->Union
.ContinuationPointer
;
237 Validate capsule by MemoryResource.
239 @param MemoryResource Pointer to the buffer of memory resource descriptor.
240 @param Address Address to be validated.
241 @param Size Size to be validated.
243 @retval TRUE No memory resource descriptor reported in HOB list before capsule Coalesce,
244 or it is valid in one MemoryResource.
245 FALSE It is not in any MemoryResource.
249 ValidateCapsuleByMemoryResource (
250 IN MEMORY_RESOURCE_DESCRIPTOR
*MemoryResource
,
251 IN EFI_PHYSICAL_ADDRESS Address
,
260 if (Size
> MAX_ADDRESS
) {
261 DEBUG ((EFI_D_ERROR
, "ERROR: Size(0x%lx) > MAX_ADDRESS\n", Size
));
268 if (Address
> (MAX_ADDRESS
- Size
)) {
269 DEBUG ((EFI_D_ERROR
, "ERROR: Address(0x%lx) > (MAX_ADDRESS - Size(0x%lx))\n", Address
, Size
));
273 if (MemoryResource
== NULL
) {
275 // No memory resource descriptor reported in HOB list before capsule Coalesce.
280 for (Index
= 0; MemoryResource
[Index
].ResourceLength
!= 0; Index
++) {
281 if ((Address
>= MemoryResource
[Index
].PhysicalStart
) &&
282 ((Address
+ Size
) <= (MemoryResource
[Index
].PhysicalStart
+ MemoryResource
[Index
].ResourceLength
))) {
283 DEBUG ((EFI_D_INFO
, "Address(0x%lx) Size(0x%lx) in MemoryResource[0x%x] - Start(0x%lx) Length(0x%lx)\n",
285 Index
, MemoryResource
[Index
].PhysicalStart
, MemoryResource
[Index
].ResourceLength
));
290 DEBUG ((EFI_D_ERROR
, "ERROR: Address(0x%lx) Size(0x%lx) not in any MemoryResource\n", Address
, Size
));
295 Check the integrity of the capsule descriptors.
297 @param BlockList Pointer to the capsule descriptors
298 @param MemoryResource Pointer to the buffer of memory resource descriptor.
300 @retval NULL BlockList is not valid.
301 @retval LastBlockDesc Last one Block in BlockList
304 EFI_CAPSULE_BLOCK_DESCRIPTOR
*
305 ValidateCapsuleIntegrity (
306 IN EFI_CAPSULE_BLOCK_DESCRIPTOR
*BlockList
,
307 IN MEMORY_RESOURCE_DESCRIPTOR
*MemoryResource
310 EFI_CAPSULE_HEADER
*CapsuleHeader
;
313 EFI_CAPSULE_BLOCK_DESCRIPTOR
*Ptr
;
315 DEBUG ((EFI_D_INFO
, "ValidateCapsuleIntegrity\n"));
318 // Go through the list to look for inconsistencies. Check for:
319 // * misaligned block descriptors.
320 // * The first capsule header guid
321 // * The first capsule header flag
322 // * The first capsule header HeaderSize
323 // * Below check will be done in ValidateCapsuleByMemoryResource()
324 // Length > MAX_ADDRESS
325 // Ptr + sizeof (EFI_CAPSULE_BLOCK_DESCRIPTOR) > MAX_ADDRESS
326 // DataBlock + Length > MAX_ADDRESS
332 if (!ValidateCapsuleByMemoryResource (MemoryResource
, (EFI_PHYSICAL_ADDRESS
) (UINTN
) Ptr
, sizeof (EFI_CAPSULE_BLOCK_DESCRIPTOR
))) {
336 DEBUG ((EFI_D_INFO
, "Ptr - 0x%x\n", Ptr
));
337 DEBUG ((EFI_D_INFO
, "Ptr->Length - 0x%x\n", Ptr
->Length
));
338 DEBUG ((EFI_D_INFO
, "Ptr->Union - 0x%x\n", Ptr
->Union
.ContinuationPointer
));
339 while ((Ptr
->Length
!= 0) || (Ptr
->Union
.ContinuationPointer
!= (EFI_PHYSICAL_ADDRESS
) (UINTN
) NULL
)) {
341 // Make sure the descriptor is aligned at UINT64 in memory
343 if ((UINTN
) Ptr
& (sizeof(UINT64
) - 1)) {
344 DEBUG ((EFI_D_ERROR
, "ERROR: BlockList address failed alignment check\n"));
348 if (Ptr
->Length
== 0) {
350 // Descriptor points to another list of block descriptors somewhere
353 Ptr
= (EFI_CAPSULE_BLOCK_DESCRIPTOR
*) (UINTN
) Ptr
->Union
.ContinuationPointer
;
354 if (!ValidateCapsuleByMemoryResource (MemoryResource
, (EFI_PHYSICAL_ADDRESS
) (UINTN
) Ptr
, sizeof (EFI_CAPSULE_BLOCK_DESCRIPTOR
))) {
357 DEBUG ((EFI_D_INFO
, "Ptr(C) - 0x%x\n", Ptr
));
358 DEBUG ((EFI_D_INFO
, "Ptr->Length - 0x%x\n", Ptr
->Length
));
359 DEBUG ((EFI_D_INFO
, "Ptr->Union - 0x%x\n", Ptr
->Union
.ContinuationPointer
));
361 if (!ValidateCapsuleByMemoryResource (MemoryResource
, Ptr
->Union
.DataBlock
, Ptr
->Length
)) {
366 //To enhance the reliability of check-up, the first capsule's header is checked here.
367 //More reliabilities check-up will do later.
369 if (CapsuleSize
== 0) {
371 //Move to the first capsule to check its header.
373 CapsuleHeader
= (EFI_CAPSULE_HEADER
*)((UINTN
)Ptr
->Union
.DataBlock
);
377 if (Ptr
->Length
< sizeof(EFI_CAPSULE_HEADER
)) {
378 DEBUG ((EFI_D_ERROR
, "ERROR: Ptr->Length(0x%lx) < sizeof(EFI_CAPSULE_HEADER)\n", Ptr
->Length
));
382 // Make sure HeaderSize field is valid
384 if (CapsuleHeader
->HeaderSize
> CapsuleHeader
->CapsuleImageSize
) {
385 DEBUG ((EFI_D_ERROR
, "ERROR: CapsuleHeader->HeaderSize(0x%x) > CapsuleHeader->CapsuleImageSize(0x%x)\n", CapsuleHeader
->HeaderSize
, CapsuleHeader
->CapsuleImageSize
));
388 if (IsCapsuleCorrupted (CapsuleHeader
)) {
392 CapsuleSize
= CapsuleHeader
->CapsuleImageSize
;
395 if (CapsuleSize
>= Ptr
->Length
) {
396 CapsuleSize
= CapsuleSize
- Ptr
->Length
;
398 DEBUG ((EFI_D_ERROR
, "ERROR: CapsuleSize(0x%lx) < Ptr->Length(0x%lx)\n", CapsuleSize
, Ptr
->Length
));
406 // Move to next BLOCK descriptor
409 if (!ValidateCapsuleByMemoryResource (MemoryResource
, (EFI_PHYSICAL_ADDRESS
) (UINTN
) Ptr
, sizeof (EFI_CAPSULE_BLOCK_DESCRIPTOR
))) {
412 DEBUG ((EFI_D_INFO
, "Ptr(B) - 0x%x\n", Ptr
));
413 DEBUG ((EFI_D_INFO
, "Ptr->Length - 0x%x\n", Ptr
->Length
));
414 DEBUG ((EFI_D_INFO
, "Ptr->Union - 0x%x\n", Ptr
->Union
.ContinuationPointer
));
418 if (CapsuleCount
== 0) {
420 // No any capsule is found in BlockList
422 DEBUG ((EFI_D_ERROR
, "ERROR: CapsuleCount(0x%x) == 0\n", CapsuleCount
));
426 if (CapsuleSize
!= 0) {
428 // Capsule data is incomplete.
430 DEBUG ((EFI_D_ERROR
, "ERROR: CapsuleSize(0x%lx) != 0\n", CapsuleSize
));
438 The capsule block descriptors may be fragmented and spread all over memory.
439 To simplify the coalescing of capsule blocks, first coalesce all the
440 capsule block descriptors low in memory.
442 The descriptors passed in can be fragmented throughout memory. Here
443 they are relocated into memory to turn them into a contiguous (null
446 @param PeiServices pointer to PEI services table
447 @param BlockList pointer to the capsule block descriptors
448 @param NumDescriptors number of capsule data block descriptors, whose Length is non-zero.
449 @param MemBase base of system memory in which we can work
450 @param MemSize size of the system memory pointed to by MemBase
452 @retval NULL could not relocate the descriptors
453 @retval Pointer to the base of the successfully-relocated block descriptors.
456 EFI_CAPSULE_BLOCK_DESCRIPTOR
*
457 RelocateBlockDescriptors (
458 IN EFI_PEI_SERVICES
**PeiServices
,
459 IN EFI_CAPSULE_BLOCK_DESCRIPTOR
*BlockList
,
460 IN UINTN NumDescriptors
,
465 EFI_CAPSULE_BLOCK_DESCRIPTOR
*NewBlockList
;
466 EFI_CAPSULE_BLOCK_DESCRIPTOR
*CurrBlockDescHead
;
467 EFI_CAPSULE_BLOCK_DESCRIPTOR
*TempBlockDesc
;
468 EFI_CAPSULE_BLOCK_DESCRIPTOR
*PrevBlockDescTail
;
474 // Get the info on the blocks and descriptors. Since we're going to move
475 // the descriptors low in memory, adjust the base/size values accordingly here.
476 // NumDescriptors is the number of legit data descriptors, so add one for
477 // a terminator. (Already done by caller, no check is needed.)
480 BufferSize
= NumDescriptors
* sizeof (EFI_CAPSULE_BLOCK_DESCRIPTOR
);
481 NewBlockList
= (EFI_CAPSULE_BLOCK_DESCRIPTOR
*) MemBase
;
482 if (MemSize
< BufferSize
) {
486 MemSize
-= BufferSize
;
487 MemBase
+= BufferSize
;
489 // Go through all the blocks and make sure none are in the way
491 TempBlockDesc
= BlockList
;
492 while (TempBlockDesc
->Union
.ContinuationPointer
!= (EFI_PHYSICAL_ADDRESS
) (UINTN
) NULL
) {
493 if (TempBlockDesc
->Length
== 0) {
495 // Next block of descriptors
497 TempBlockDesc
= (EFI_CAPSULE_BLOCK_DESCRIPTOR
*) (UINTN
) TempBlockDesc
->Union
.ContinuationPointer
;
500 // If the capsule data pointed to by this descriptor is in the way,
504 (UINT8
*) NewBlockList
,
506 (UINT8
*) (UINTN
) TempBlockDesc
->Union
.DataBlock
,
507 (UINTN
) TempBlockDesc
->Length
510 // Relocate the block
512 RelocBuffer
= FindFreeMem (BlockList
, MemBase
, MemSize
, (UINTN
) TempBlockDesc
->Length
);
513 if (RelocBuffer
== NULL
) {
517 CopyMem ((VOID
*) RelocBuffer
, (VOID
*) (UINTN
) TempBlockDesc
->Union
.DataBlock
, (UINTN
) TempBlockDesc
->Length
);
518 DEBUG ((EFI_D_INFO
, "Capsule relocate descriptors from/to/size 0x%lX 0x%lX 0x%lX\n", TempBlockDesc
->Union
.DataBlock
, (UINT64
)(UINTN
)RelocBuffer
, TempBlockDesc
->Length
));
519 TempBlockDesc
->Union
.DataBlock
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) RelocBuffer
;
525 // Now go through all the block descriptors to make sure that they're not
526 // in the memory region we want to copy them to.
528 CurrBlockDescHead
= BlockList
;
529 PrevBlockDescTail
= NULL
;
530 while ((CurrBlockDescHead
!= NULL
) && (CurrBlockDescHead
->Union
.ContinuationPointer
!= (EFI_PHYSICAL_ADDRESS
) (UINTN
) NULL
)) {
532 // Get the size of this list then see if it overlaps our low region
534 TempBlockDesc
= CurrBlockDescHead
;
535 BlockListSize
= sizeof (EFI_CAPSULE_BLOCK_DESCRIPTOR
);
536 while (TempBlockDesc
->Length
!= 0) {
537 BlockListSize
+= sizeof (EFI_CAPSULE_BLOCK_DESCRIPTOR
);
542 (UINT8
*) NewBlockList
,
544 (UINT8
*) CurrBlockDescHead
,
548 // Overlaps, so move it out of the way
550 RelocBuffer
= FindFreeMem (BlockList
, MemBase
, MemSize
, BlockListSize
);
551 if (RelocBuffer
== NULL
) {
554 CopyMem ((VOID
*) RelocBuffer
, (VOID
*) CurrBlockDescHead
, BlockListSize
);
555 DEBUG ((EFI_D_INFO
, "Capsule reloc descriptor block #2\n"));
557 // Point the previous block's next point to this copied version. If
558 // the tail pointer is null, then this is the first descriptor block.
560 if (PrevBlockDescTail
== NULL
) {
561 BlockList
= (EFI_CAPSULE_BLOCK_DESCRIPTOR
*) RelocBuffer
;
563 PrevBlockDescTail
->Union
.DataBlock
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) RelocBuffer
;
567 // Save our new tail and jump to the next block list
569 PrevBlockDescTail
= TempBlockDesc
;
570 CurrBlockDescHead
= (EFI_CAPSULE_BLOCK_DESCRIPTOR
*) (UINTN
) TempBlockDesc
->Union
.ContinuationPointer
;
573 // Cleared out low memory. Now copy the descriptors down there.
575 TempBlockDesc
= BlockList
;
576 CurrBlockDescHead
= NewBlockList
;
577 while ((TempBlockDesc
!= NULL
) && (TempBlockDesc
->Union
.ContinuationPointer
!= (EFI_PHYSICAL_ADDRESS
) (UINTN
) NULL
)) {
578 if (TempBlockDesc
->Length
!= 0) {
579 CurrBlockDescHead
->Union
.DataBlock
= TempBlockDesc
->Union
.DataBlock
;
580 CurrBlockDescHead
->Length
= TempBlockDesc
->Length
;
584 TempBlockDesc
= (EFI_CAPSULE_BLOCK_DESCRIPTOR
*) (UINTN
) TempBlockDesc
->Union
.ContinuationPointer
;
590 CurrBlockDescHead
->Union
.ContinuationPointer
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) NULL
;
591 CurrBlockDescHead
->Length
= 0;
596 Determine if two buffers overlap in memory.
598 @param Buff1 pointer to first buffer
599 @param Size1 size of Buff1
600 @param Buff2 pointer to second buffer
601 @param Size2 size of Buff2
603 @retval TRUE Buffers overlap in memory.
604 @retval FALSE Buffer doesn't overlap.
616 // If buff1's end is less than the start of buff2, then it's ok.
617 // Also, if buff1's start is beyond buff2's end, then it's ok.
619 if (((Buff1
+ Size1
) <= Buff2
) || (Buff1
>= (Buff2
+ Size2
))) {
627 Given a pointer to a capsule block descriptor, traverse the list to figure
628 out how many legitimate descriptors there are, and how big the capsule it
631 @param Desc Pointer to the capsule block descriptors
632 @param NumDescriptors Optional pointer to where to return the number of capsule data descriptors, whose Length is non-zero.
633 @param CapsuleSize Optional pointer to where to return the capsule image size
634 @param CapsuleNumber Optional pointer to where to return the number of capsule
636 @retval EFI_NOT_FOUND No descriptors containing data in the list
637 @retval EFI_SUCCESS Return data is valid
642 IN EFI_CAPSULE_BLOCK_DESCRIPTOR
*Desc
,
643 IN OUT UINTN
*NumDescriptors OPTIONAL
,
644 IN OUT UINTN
*CapsuleSize OPTIONAL
,
645 IN OUT UINTN
*CapsuleNumber OPTIONAL
651 UINTN ThisCapsuleImageSize
;
652 EFI_CAPSULE_HEADER
*CapsuleHeader
;
654 DEBUG ((EFI_D_INFO
, "GetCapsuleInfo enter\n"));
656 ASSERT (Desc
!= NULL
);
661 ThisCapsuleImageSize
= 0;
663 while (Desc
->Union
.ContinuationPointer
!= (EFI_PHYSICAL_ADDRESS
) (UINTN
) NULL
) {
664 if (Desc
->Length
== 0) {
666 // Descriptor points to another list of block descriptors somewhere
668 Desc
= (EFI_CAPSULE_BLOCK_DESCRIPTOR
*) (UINTN
) Desc
->Union
.ContinuationPointer
;
672 // It is needed, because ValidateCapsuleIntegrity() only validate one individual capsule Size.
673 // While here we need check all capsules size.
675 if (Desc
->Length
>= (MAX_ADDRESS
- Size
)) {
676 DEBUG ((EFI_D_ERROR
, "ERROR: Desc->Length(0x%lx) >= (MAX_ADDRESS - Size(0x%x))\n", Desc
->Length
, Size
));
677 return EFI_OUT_OF_RESOURCES
;
679 Size
+= (UINTN
) Desc
->Length
;
683 // See if this is first capsule's header
685 if (ThisCapsuleImageSize
== 0) {
686 CapsuleHeader
= (EFI_CAPSULE_HEADER
*)((UINTN
)Desc
->Union
.DataBlock
);
688 // This has been checked in ValidateCapsuleIntegrity()
691 ThisCapsuleImageSize
= CapsuleHeader
->CapsuleImageSize
;
695 // This has been checked in ValidateCapsuleIntegrity()
697 ASSERT (ThisCapsuleImageSize
>= Desc
->Length
);
698 ThisCapsuleImageSize
= (UINTN
)(ThisCapsuleImageSize
- Desc
->Length
);
707 // If no descriptors, then fail
710 DEBUG ((EFI_D_ERROR
, "ERROR: Count == 0\n"));
711 return EFI_NOT_FOUND
;
715 // checked in ValidateCapsuleIntegrity()
717 ASSERT (ThisCapsuleImageSize
== 0);
719 if (NumDescriptors
!= NULL
) {
720 *NumDescriptors
= Count
;
723 if (CapsuleSize
!= NULL
) {
727 if (CapsuleNumber
!= NULL
) {
728 *CapsuleNumber
= Number
;
735 Check every capsule header.
737 @param CapsuleHeader The pointer to EFI_CAPSULE_HEADER
739 @retval FALSE Capsule is OK
740 @retval TRUE Capsule is corrupted
745 IN EFI_CAPSULE_HEADER
*CapsuleHeader
749 //A capsule to be updated across a system reset should contain CAPSULE_FLAGS_PERSIST_ACROSS_RESET.
751 if ((CapsuleHeader
->Flags
& CAPSULE_FLAGS_PERSIST_ACROSS_RESET
) == 0) {
755 //Make sure the flags combination is supported by the platform.
757 if ((CapsuleHeader
->Flags
& (CAPSULE_FLAGS_PERSIST_ACROSS_RESET
| CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE
)) == CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE
) {
760 if ((CapsuleHeader
->Flags
& (CAPSULE_FLAGS_PERSIST_ACROSS_RESET
| CAPSULE_FLAGS_INITIATE_RESET
)) == CAPSULE_FLAGS_INITIATE_RESET
) {
768 Try to verify the integrity of a capsule test pattern before the
769 capsule gets coalesced. This can be useful in narrowing down
770 where capsule data corruption occurs.
772 The test pattern mode fills in memory with a counting UINT32 value.
773 If the capsule is not divided up in a multiple of 4-byte blocks, then
774 things get messy doing the check. Therefore there are some cases
775 here where we just give up and skip the pre-coalesce check.
777 @param PeiServices PEI services table
778 @param Desc Pointer to capsule descriptors
781 CapsuleTestPatternPreCoalesce (
782 IN EFI_PEI_SERVICES
**PeiServices
,
783 IN EFI_CAPSULE_BLOCK_DESCRIPTOR
*Desc
790 DEBUG ((EFI_D_INFO
, "CapsuleTestPatternPreCoalesce\n"));
793 // Find first data descriptor
795 while ((Desc
->Length
== 0) && (Desc
->Union
.ContinuationPointer
!= (EFI_PHYSICAL_ADDRESS
) (UINTN
) NULL
)) {
796 Desc
= (EFI_CAPSULE_BLOCK_DESCRIPTOR
*) (UINTN
) Desc
->Union
.ContinuationPointer
;
799 if (Desc
->Union
.ContinuationPointer
== 0) {
803 // First one better be long enough to at least hold the test signature
805 if (Desc
->Length
< sizeof (UINT32
)) {
806 DEBUG ((EFI_D_INFO
, "Capsule test pattern pre-coalesce punted #1\n"));
810 TestPtr
= (UINT32
*) (UINTN
) Desc
->Union
.DataBlock
;
814 if (*TestPtr
!= 0x54534554) {
819 TestSize
= (UINT32
) Desc
->Length
- 2 * sizeof (UINT32
);
821 // Skip over the signature and the size fields in the pattern data header
825 if ((TestSize
& 0x03) != 0) {
826 DEBUG ((EFI_D_INFO
, "Capsule test pattern pre-coalesce punted #2\n"));
830 while (TestSize
> 0) {
831 if (*TestPtr
!= TestCounter
) {
832 DEBUG ((EFI_D_INFO
, "Capsule test pattern pre-coalesce failed data corruption check\n"));
836 TestSize
-= sizeof (UINT32
);
841 while ((Desc
->Length
== 0) && (Desc
->Union
.ContinuationPointer
!= (EFI_PHYSICAL_ADDRESS
) (UINTN
) NULL
)) {
842 Desc
= (EFI_CAPSULE_BLOCK_DESCRIPTOR
*) (UINTN
) Desc
->Union
.ContinuationPointer
;
845 if (Desc
->Union
.ContinuationPointer
== (EFI_PHYSICAL_ADDRESS
) (UINTN
) NULL
) {
848 TestSize
= (UINT32
) Desc
->Length
;
849 TestPtr
= (UINT32
*) (UINTN
) Desc
->Union
.DataBlock
;
854 Checks for the presence of capsule descriptors.
855 Get capsule descriptors from variable CapsuleUpdateData, CapsuleUpdateData1, CapsuleUpdateData2...
857 @param BlockListBuffer Pointer to the buffer of capsule descriptors variables
858 @param MemoryResource Pointer to the buffer of memory resource descriptor.
859 @param BlockDescriptorList Pointer to the capsule descriptors list
861 @retval EFI_SUCCESS a valid capsule is present
862 @retval EFI_NOT_FOUND if a valid capsule is not present
865 BuildCapsuleDescriptors (
866 IN EFI_PHYSICAL_ADDRESS
*BlockListBuffer
,
867 IN MEMORY_RESOURCE_DESCRIPTOR
*MemoryResource
,
868 OUT EFI_CAPSULE_BLOCK_DESCRIPTOR
**BlockDescriptorList
872 EFI_CAPSULE_BLOCK_DESCRIPTOR
*LastBlock
;
873 EFI_CAPSULE_BLOCK_DESCRIPTOR
*TempBlock
;
874 EFI_CAPSULE_BLOCK_DESCRIPTOR
*HeadBlock
;
876 DEBUG ((EFI_D_INFO
, "BuildCapsuleDescriptors enter\n"));
883 while (BlockListBuffer
[Index
] != 0) {
885 // Test integrity of descriptors.
887 if (BlockListBuffer
[Index
] < MAX_ADDRESS
) {
888 TempBlock
= ValidateCapsuleIntegrity ((EFI_CAPSULE_BLOCK_DESCRIPTOR
*)(UINTN
)BlockListBuffer
[Index
], MemoryResource
);
889 if (TempBlock
!= NULL
) {
890 if (LastBlock
== NULL
) {
891 LastBlock
= TempBlock
;
894 // Return the base of the block descriptors
896 HeadBlock
= (EFI_CAPSULE_BLOCK_DESCRIPTOR
*)(UINTN
)BlockListBuffer
[Index
];
899 // Combine the different BlockList into single BlockList.
901 LastBlock
->Union
.DataBlock
= (EFI_PHYSICAL_ADDRESS
)(UINTN
)BlockListBuffer
[Index
];
902 LastBlock
->Length
= 0;
903 LastBlock
= TempBlock
;
907 DEBUG ((EFI_D_ERROR
, "ERROR: BlockListBuffer[Index](0x%lx) < MAX_ADDRESS\n", BlockListBuffer
[Index
]));
912 if (HeadBlock
!= NULL
) {
913 *BlockDescriptorList
= HeadBlock
;
916 return EFI_NOT_FOUND
;
920 The function to coalesce a fragmented capsule in memory.
922 Memory Map for coalesced capsule:
923 MemBase + ---->+---------------------------+<-----------+
924 MemSize | ------------------------- | |
925 | | Capsule [Num-1] | | |
926 | ------------------------- | |
927 | | ................ | | |
928 | ------------------------- | |
929 | | Capsule [1] | | |
930 | ------------------------- | |
931 | | Capsule [0] | | |
932 | ------------------------- | |
934 CapsuleImageBase-->+---------------------------+
935 | ------------------------- | |
936 | | CapsuleOffset[Num-1] | | |
937 | ------------------------- | |
938 | | ................ | | CapsuleSize
939 | ------------------------- | |
940 | | CapsuleOffset[1] | | |
941 | ------------------------- | |
942 | | CapsuleOffset[0] | | |
943 |---------------------------| |
944 | | CapsuleNumber | | |
945 | ------------------------- | |
946 | | CapsuleAllImageSize | | |
947 | ------------------------- | |
949 DestPtr ---->+---------------------------+<-----------+
951 | FreeMem | FreeMemSize
953 FreeMemBase --->+---------------------------+<-----------+
955 +---------------------------+
956 | BlockDescriptor n |
957 +---------------------------+
958 | ................. |
959 +---------------------------+
960 | BlockDescriptor 1 |
961 +---------------------------+
962 | BlockDescriptor 0 |
963 +---------------------------+
964 | PrivateDataDesc 0 |
965 MemBase ---->+---------------------------+<----- BlockList
967 Caution: This function may receive untrusted input.
968 The capsule data is external input, so this routine will do basic validation before
969 coalesce capsule data into memory.
971 @param PeiServices General purpose services available to every PEIM.
972 @param BlockListBuffer Pointer to the buffer of Capsule Descriptor Variables.
973 @param MemoryResource Pointer to the buffer of memory resource descriptor.
974 @param MemoryBase Pointer to the base of a block of memory that we can walk
975 all over while trying to coalesce our buffers.
976 On output, this variable will hold the base address of
978 @param MemorySize Size of the memory region pointed to by MemoryBase.
979 On output, this variable will contain the size of the
982 @retval EFI_NOT_FOUND If we could not find the capsule descriptors.
984 @retval EFI_BUFFER_TOO_SMALL
985 If we could not coalesce the capsule in the memory
986 region provided to us.
988 @retval EFI_SUCCESS Processed the capsule successfully.
992 CapsuleDataCoalesce (
993 IN EFI_PEI_SERVICES
**PeiServices
,
994 IN EFI_PHYSICAL_ADDRESS
*BlockListBuffer
,
995 IN MEMORY_RESOURCE_DESCRIPTOR
*MemoryResource
,
996 IN OUT VOID
**MemoryBase
,
997 IN OUT UINTN
*MemorySize
1000 VOID
*NewCapsuleBase
;
1001 VOID
*CapsuleImageBase
;
1009 UINT64 CapsuleImageSize
;
1011 UINTN CapsuleNumber
;
1012 UINTN DescriptorsSize
;
1014 UINTN NumDescriptors
;
1015 BOOLEAN CapsuleBeginFlag
;
1017 EFI_CAPSULE_HEADER
*CapsuleHeader
;
1018 EFI_CAPSULE_PEIM_PRIVATE_DATA PrivateData
;
1019 EFI_CAPSULE_PEIM_PRIVATE_DATA
*PrivateDataPtr
;
1020 EFI_CAPSULE_BLOCK_DESCRIPTOR
*BlockList
;
1021 EFI_CAPSULE_BLOCK_DESCRIPTOR
*CurrentBlockDesc
;
1022 EFI_CAPSULE_BLOCK_DESCRIPTOR
*TempBlockDesc
;
1023 EFI_CAPSULE_BLOCK_DESCRIPTOR PrivateDataDesc
[2];
1025 DEBUG ((EFI_D_INFO
, "CapsuleDataCoalesce enter\n"));
1030 CapsuleImageSize
= 0;
1031 PrivateDataPtr
= NULL
;
1032 CapsuleHeader
= NULL
;
1033 CapsuleBeginFlag
= TRUE
;
1038 // Build capsule descriptors list
1040 Status
= BuildCapsuleDescriptors (BlockListBuffer
, MemoryResource
, &BlockList
);
1041 if (EFI_ERROR (Status
)) {
1046 CapsuleTestPatternPreCoalesce (PeiServices
, BlockList
);
1050 // Get the size of our descriptors and the capsule size. GetCapsuleInfo()
1051 // returns the number of descriptors that actually point to data, so add
1052 // one for a terminator. Do that below.
1054 Status
= GetCapsuleInfo (BlockList
, &NumDescriptors
, &CapsuleSize
, &CapsuleNumber
);
1055 if (EFI_ERROR (Status
)) {
1058 DEBUG ((EFI_D_INFO
, "CapsuleSize - 0x%x\n", CapsuleSize
));
1059 DEBUG ((EFI_D_INFO
, "CapsuleNumber - 0x%x\n", CapsuleNumber
));
1060 DEBUG ((EFI_D_INFO
, "NumDescriptors - 0x%x\n", NumDescriptors
));
1061 if ((CapsuleSize
== 0) || (NumDescriptors
== 0) || (CapsuleNumber
== 0)) {
1062 return EFI_NOT_FOUND
;
1065 if (CapsuleNumber
- 1 >= (MAX_ADDRESS
- (sizeof (EFI_CAPSULE_PEIM_PRIVATE_DATA
) + sizeof(UINT64
))) / sizeof(UINT64
)) {
1066 DEBUG ((EFI_D_ERROR
, "ERROR: CapsuleNumber - 0x%x\n", CapsuleNumber
));
1067 return EFI_BUFFER_TOO_SMALL
;
1071 // Initialize our local copy of private data. When we're done, we'll create a
1072 // descriptor for it as well so that it can be put into free memory without
1073 // trashing anything.
1075 PrivateData
.Signature
= EFI_CAPSULE_PEIM_PRIVATE_DATA_SIGNATURE
;
1076 PrivateData
.CapsuleAllImageSize
= (UINT64
) CapsuleSize
;
1077 PrivateData
.CapsuleNumber
= (UINT64
) CapsuleNumber
;
1078 PrivateData
.CapsuleOffset
[0] = 0;
1080 // NOTE: Only data in sizeof (EFI_CAPSULE_PEIM_PRIVATE_DATA) is valid, CapsuleOffset field is uninitialized at this moment.
1081 // The code sets partial length here for Descriptor.Length check, but later it will use full length to reserve those PrivateData region.
1083 PrivateDataDesc
[0].Union
.DataBlock
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) &PrivateData
;
1084 PrivateDataDesc
[0].Length
= sizeof (EFI_CAPSULE_PEIM_PRIVATE_DATA
);
1085 PrivateDataDesc
[1].Union
.DataBlock
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) BlockList
;
1086 PrivateDataDesc
[1].Length
= 0;
1088 // Add PrivateDataDesc[0] in beginning, as it is new descriptor. PrivateDataDesc[1] is NOT needed.
1089 // In addition, one NULL terminator is added in the end. See RelocateBlockDescriptors().
1091 NumDescriptors
+= 2;
1095 if (CapsuleSize
>= (MAX_ADDRESS
- (sizeof (EFI_CAPSULE_PEIM_PRIVATE_DATA
) + (CapsuleNumber
- 1) * sizeof(UINT64
) + sizeof(UINT64
)))) {
1096 DEBUG ((EFI_D_ERROR
, "ERROR: CapsuleSize - 0x%x\n", CapsuleSize
));
1097 return EFI_BUFFER_TOO_SMALL
;
1100 // Need add sizeof(UINT64) for PrivateData alignment
1102 CapsuleSize
+= sizeof (EFI_CAPSULE_PEIM_PRIVATE_DATA
) + (CapsuleNumber
- 1) * sizeof(UINT64
) + sizeof(UINT64
);
1103 BlockList
= PrivateDataDesc
;
1107 if (NumDescriptors
>= (MAX_ADDRESS
/ sizeof(EFI_CAPSULE_BLOCK_DESCRIPTOR
))) {
1108 DEBUG ((EFI_D_ERROR
, "ERROR: NumDescriptors - 0x%x\n", NumDescriptors
));
1109 return EFI_BUFFER_TOO_SMALL
;
1111 DescriptorsSize
= NumDescriptors
* sizeof (EFI_CAPSULE_BLOCK_DESCRIPTOR
);
1115 if (DescriptorsSize
>= (MAX_ADDRESS
- CapsuleSize
)) {
1116 DEBUG ((EFI_D_ERROR
, "ERROR: DescriptorsSize - 0x%lx, CapsuleSize - 0x%lx\n", (UINT64
)DescriptorsSize
, (UINT64
)CapsuleSize
));
1117 return EFI_BUFFER_TOO_SMALL
;
1121 // Don't go below some min address. If the base is below it,
1122 // then move it up and adjust the size accordingly.
1124 DEBUG ((EFI_D_INFO
, "Capsule Memory range from 0x%8X to 0x%8X\n", (UINTN
) *MemoryBase
, (UINTN
)*MemoryBase
+ *MemorySize
));
1125 if ((UINTN
)*MemoryBase
< (UINTN
) MIN_COALESCE_ADDR
) {
1126 if (((UINTN
)*MemoryBase
+ *MemorySize
) < (UINTN
) MIN_COALESCE_ADDR
) {
1127 DEBUG ((EFI_D_ERROR
, "ERROR: *MemoryBase + *MemorySize - 0x%x\n", (UINTN
)*MemoryBase
+ *MemorySize
));
1128 return EFI_BUFFER_TOO_SMALL
;
1130 *MemorySize
= *MemorySize
- ((UINTN
) MIN_COALESCE_ADDR
- (UINTN
) *MemoryBase
);
1131 *MemoryBase
= (VOID
*) (UINTN
) MIN_COALESCE_ADDR
;
1135 if (*MemorySize
<= (CapsuleSize
+ DescriptorsSize
)) {
1136 DEBUG ((EFI_D_ERROR
, "ERROR: CapsuleSize + DescriptorsSize - 0x%x\n", CapsuleSize
+ DescriptorsSize
));
1137 return EFI_BUFFER_TOO_SMALL
;
1140 FreeMemBase
= *MemoryBase
;
1141 FreeMemSize
= *MemorySize
;
1142 DEBUG ((EFI_D_INFO
, "Capsule Free Memory from 0x%8X to 0x%8X\n", (UINTN
) FreeMemBase
, (UINTN
) FreeMemBase
+ FreeMemSize
));
1145 // Relocate all the block descriptors to low memory to make further
1146 // processing easier.
1148 BlockList
= RelocateBlockDescriptors (PeiServices
, BlockList
, NumDescriptors
, FreeMemBase
, FreeMemSize
);
1149 if (BlockList
== NULL
) {
1151 // Not enough room to relocate the descriptors
1153 return EFI_BUFFER_TOO_SMALL
;
1157 // Take the top of memory for the capsule. UINT64 align up.
1159 DestPtr
= FreeMemBase
+ FreeMemSize
- CapsuleSize
;
1160 DestPtr
= (UINT8
*) (((UINTN
)DestPtr
+ sizeof (UINT64
) - 1) & ~(sizeof (UINT64
) - 1));
1161 FreeMemBase
= (UINT8
*) BlockList
+ DescriptorsSize
;
1162 FreeMemSize
= (UINTN
) DestPtr
- (UINTN
) FreeMemBase
;
1163 NewCapsuleBase
= (VOID
*) DestPtr
;
1164 CapsuleImageBase
= (UINT8
*)NewCapsuleBase
+ sizeof(EFI_CAPSULE_PEIM_PRIVATE_DATA
) + (CapsuleNumber
- 1) * sizeof(UINT64
);
1166 PrivateDataPtr
= (EFI_CAPSULE_PEIM_PRIVATE_DATA
*) NewCapsuleBase
;
1169 // Move all the blocks to the top (high) of memory.
1170 // Relocate all the obstructing blocks. Note that the block descriptors
1171 // were coalesced when they were relocated, so we can just ++ the pointer.
1173 CurrentBlockDesc
= BlockList
;
1174 while ((CurrentBlockDesc
->Length
!= 0) || (CurrentBlockDesc
->Union
.ContinuationPointer
!= (EFI_PHYSICAL_ADDRESS
) (UINTN
) NULL
)) {
1175 if (CapsuleTimes
== 0) {
1177 // The first entry is the block descriptor for EFI_CAPSULE_PEIM_PRIVATE_DATA.
1178 // CapsuleOffset field is uninitialized at this time. No need copy it, but need to reserve for future use.
1180 ASSERT (CurrentBlockDesc
->Union
.DataBlock
== (UINT64
)(UINTN
)&PrivateData
);
1181 DestLength
= sizeof (EFI_CAPSULE_PEIM_PRIVATE_DATA
) + (CapsuleNumber
- 1) * sizeof(UINT64
);
1183 DestLength
= (UINTN
)CurrentBlockDesc
->Length
;
1186 // See if any of the remaining capsule blocks are in the way
1188 TempBlockDesc
= CurrentBlockDesc
;
1189 while (TempBlockDesc
->Length
!= 0) {
1191 // Is this block in the way of where we want to copy the current descriptor to?
1196 (UINT8
*) (UINTN
) TempBlockDesc
->Union
.DataBlock
,
1197 (UINTN
) TempBlockDesc
->Length
1200 // Relocate the block
1202 RelocPtr
= FindFreeMem (BlockList
, FreeMemBase
, FreeMemSize
, (UINTN
) TempBlockDesc
->Length
);
1203 if (RelocPtr
== NULL
) {
1204 return EFI_BUFFER_TOO_SMALL
;
1207 CopyMem ((VOID
*) RelocPtr
, (VOID
*) (UINTN
) TempBlockDesc
->Union
.DataBlock
, (UINTN
) TempBlockDesc
->Length
);
1208 DEBUG ((EFI_D_INFO
, "Capsule reloc data block from 0x%8X to 0x%8X with size 0x%8X\n",
1209 (UINTN
) TempBlockDesc
->Union
.DataBlock
, (UINTN
) RelocPtr
, (UINTN
) TempBlockDesc
->Length
));
1211 TempBlockDesc
->Union
.DataBlock
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) RelocPtr
;
1219 // Ok, we made it through. Copy the block.
1220 // we just support greping one capsule from the lists of block descs list.
1224 //Skip the first block descriptor that filled with EFI_CAPSULE_PEIM_PRIVATE_DATA
1226 if (CapsuleTimes
> 1) {
1228 //For every capsule entry point, check its header to determine whether to relocate it.
1229 //If it is invalid, skip it and move on to the next capsule. If it is valid, relocate it.
1231 if (CapsuleBeginFlag
) {
1232 CapsuleBeginFlag
= FALSE
;
1233 CapsuleHeader
= (EFI_CAPSULE_HEADER
*)(UINTN
)CurrentBlockDesc
->Union
.DataBlock
;
1234 SizeLeft
= CapsuleHeader
->CapsuleImageSize
;
1237 // No more check here is needed, because IsCapsuleCorrupted() already in ValidateCapsuleIntegrity()
1239 ASSERT (CapsuleIndex
< CapsuleNumber
);
1242 // Relocate this capsule
1244 CapsuleImageSize
+= SizeLeft
;
1246 // Cache the begin offset of this capsule
1248 ASSERT (PrivateDataPtr
->Signature
== EFI_CAPSULE_PEIM_PRIVATE_DATA_SIGNATURE
);
1249 ASSERT ((UINTN
)DestPtr
>= (UINTN
)CapsuleImageBase
);
1250 PrivateDataPtr
->CapsuleOffset
[CapsuleIndex
++] = (UINTN
)DestPtr
- (UINTN
)CapsuleImageBase
;
1254 // Below ASSERT is checked in ValidateCapsuleIntegrity()
1256 ASSERT (CurrentBlockDesc
->Length
<= SizeLeft
);
1258 CopyMem ((VOID
*) DestPtr
, (VOID
*) (UINTN
) (CurrentBlockDesc
->Union
.DataBlock
), (UINTN
)CurrentBlockDesc
->Length
);
1259 DEBUG ((EFI_D_INFO
, "Capsule coalesce block no.0x%lX from 0x%lX to 0x%lX with size 0x%lX\n",(UINT64
)CapsuleTimes
,
1260 CurrentBlockDesc
->Union
.DataBlock
, (UINT64
)(UINTN
)DestPtr
, CurrentBlockDesc
->Length
));
1261 DestPtr
+= CurrentBlockDesc
->Length
;
1262 SizeLeft
-= CurrentBlockDesc
->Length
;
1264 if (SizeLeft
== 0) {
1266 //Here is the end of the current capsule image.
1268 CapsuleBeginFlag
= TRUE
;
1272 // The first entry is the block descriptor for EFI_CAPSULE_PEIM_PRIVATE_DATA.
1273 // CapsuleOffset field is uninitialized at this time. No need copy it, but need to reserve for future use.
1275 ASSERT (CurrentBlockDesc
->Length
== sizeof (EFI_CAPSULE_PEIM_PRIVATE_DATA
));
1276 ASSERT ((UINTN
)DestPtr
== (UINTN
)NewCapsuleBase
);
1277 CopyMem ((VOID
*) DestPtr
, (VOID
*) (UINTN
) CurrentBlockDesc
->Union
.DataBlock
, (UINTN
) CurrentBlockDesc
->Length
);
1278 DestPtr
+= sizeof (EFI_CAPSULE_PEIM_PRIVATE_DATA
) + (CapsuleNumber
- 1) * sizeof(UINT64
);
1281 //Walk through the block descriptor list.
1286 // We return the base of memory we want reserved, and the size.
1287 // The memory peim should handle it appropriately from there.
1289 *MemorySize
= (UINTN
) CapsuleSize
;
1290 *MemoryBase
= (VOID
*) NewCapsuleBase
;
1292 ASSERT (PrivateDataPtr
->Signature
== EFI_CAPSULE_PEIM_PRIVATE_DATA_SIGNATURE
);
1293 ASSERT (PrivateDataPtr
->CapsuleAllImageSize
== CapsuleImageSize
);
1294 ASSERT (PrivateDataPtr
->CapsuleNumber
== CapsuleIndex
);