Changeset 58466 in vbox for trunk/src/VBox/Devices/EFI/Firmware/MdePkg/Library/UefiMemoryAllocationLib
- Timestamp:
- Oct 29, 2015 4:30:44 AM (9 years ago)
- svn:sync-xref-src-repo-rev:
- 103777
- Location:
- trunk/src/VBox/Devices/EFI/Firmware
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/EFI/Firmware
- Property svn:mergeinfo changed
/vendor/edk2/current merged: 103769-103776
- Property svn:mergeinfo changed
-
trunk/src/VBox/Devices/EFI/Firmware/MdePkg/Library/UefiMemoryAllocationLib/MemoryAllocationLib.c
r58459 r58466 1 1 /** @file 2 Support routines for memory allocation routines based 2 Support routines for memory allocation routines based 3 3 on boot services for Dxe phase drivers. 4 4 5 5 Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR> 6 This program and the accompanying materials 7 are licensed and made available under the terms and conditions of the BSD License 8 which accompanies this distribution. The full text of the license may be found at 9 http://opensource.org/licenses/bsd-license.php. 10 11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 6 This program and the accompanying materials 7 are licensed and made available under the terms and conditions of the BSD License 8 which accompanies this distribution. The full text of the license may be found at 9 http://opensource.org/licenses/bsd-license.php. 10 11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 13 13 14 14 **/ … … 38 38 VOID * 39 39 InternalAllocatePages ( 40 IN EFI_MEMORY_TYPE MemoryType, 40 IN EFI_MEMORY_TYPE MemoryType, 41 41 IN UINTN Pages 42 42 ) 43 43 { 44 44 EFI_STATUS Status; 45 EFI_PHYSICAL_ADDRESS Memory; 45 EFI_PHYSICAL_ADDRESS Memory; 46 46 47 47 if (Pages == 0) { … … 130 130 Allocation Library. If it is not possible to free allocated pages, then this function will 131 131 perform no actions. 132 132 133 133 If Buffer was not allocated with a page allocation function in the Memory Allocation Library, 134 134 then ASSERT(). 135 135 If Pages is zero, then ASSERT(). 136 136 137 137 @param Buffer The pointer to the buffer of pages to free. 138 138 @param Pages The number of 4 KB pages to free. … … 173 173 VOID * 174 174 InternalAllocateAlignedPages ( 175 IN EFI_MEMORY_TYPE MemoryType, 175 IN EFI_MEMORY_TYPE MemoryType, 176 176 IN UINTN Pages, 177 177 IN UINTN Alignment … … 189 189 // 190 190 ASSERT ((Alignment & (Alignment - 1)) == 0); 191 191 192 192 if (Pages == 0) { 193 193 return NULL; … … 203 203 // 204 204 ASSERT (RealPages > Pages); 205 205 206 206 Status = gBS->AllocatePages (AllocateAnyPages, MemoryType, RealPages, &Memory); 207 207 if (EFI_ERROR (Status)) { … … 246 246 returned. If there is not enough memory at the specified alignment remaining to satisfy the 247 247 request, then NULL is returned. 248 248 249 249 If Alignment is not a power of two and Alignment is not zero, then ASSERT(). 250 250 If Pages plus EFI_SIZE_TO_PAGES (Alignment) overflows, then ASSERT(). … … 274 274 returned. If there is not enough memory at the specified alignment remaining to satisfy the 275 275 request, then NULL is returned. 276 276 277 277 If Alignment is not a power of two and Alignment is not zero, then ASSERT(). 278 278 If Pages plus EFI_SIZE_TO_PAGES (Alignment) overflows, then ASSERT(). … … 302 302 returned. If there is not enough memory at the specified alignment remaining to satisfy the 303 303 request, then NULL is returned. 304 304 305 305 If Alignment is not a power of two and Alignment is not zero, then ASSERT(). 306 306 If Pages plus EFI_SIZE_TO_PAGES (Alignment) overflows, then ASSERT(). … … 329 329 Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer. Buffer 330 330 must have been allocated on a previous call to the aligned page allocation services of the Memory 331 Allocation Library. If it is not possible to free allocated pages, then this function will 331 Allocation Library. If it is not possible to free allocated pages, then this function will 332 332 perform no actions. 333 333 334 334 If Buffer was not allocated with an aligned page allocation function in the Memory Allocation 335 335 Library, then ASSERT(). 336 336 If Pages is zero, then ASSERT(). 337 337 338 338 @param Buffer The pointer to the buffer of pages to free. 339 339 @param Pages The number of 4 KB pages to free. … … 369 369 VOID * 370 370 InternalAllocatePool ( 371 IN EFI_MEMORY_TYPE MemoryType, 371 IN EFI_MEMORY_TYPE MemoryType, 372 372 IN UINTN AllocationSize 373 373 ) … … 462 462 VOID * 463 463 InternalAllocateZeroPool ( 464 IN EFI_MEMORY_TYPE PoolType, 464 IN EFI_MEMORY_TYPE PoolType, 465 465 IN UINTN AllocationSize 466 ) 466 ) 467 467 { 468 468 VOID *Memory; … … 549 549 is not enough memory remaining to satisfy the request, then NULL is returned. 550 550 If Buffer is NULL, then ASSERT(). 551 If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). 551 If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). 552 552 553 553 @param PoolType The type of pool to allocate. … … 560 560 VOID * 561 561 InternalAllocateCopyPool ( 562 IN EFI_MEMORY_TYPE PoolType, 562 IN EFI_MEMORY_TYPE PoolType, 563 563 IN UINTN AllocationSize, 564 564 IN CONST VOID *Buffer 565 ) 565 ) 566 566 { 567 567 VOID *Memory; … … 575 575 } 576 576 return Memory; 577 } 577 } 578 578 579 579 /** … … 584 584 allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there 585 585 is not enough memory remaining to satisfy the request, then NULL is returned. 586 586 587 587 If Buffer is NULL, then ASSERT(). 588 If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). 588 If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). 589 589 590 590 @param AllocationSize The number of bytes to allocate and zero. … … 611 611 allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there 612 612 is not enough memory remaining to satisfy the request, then NULL is returned. 613 613 614 614 If Buffer is NULL, then ASSERT(). 615 If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). 615 If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). 616 616 617 617 @param AllocationSize The number of bytes to allocate and zero. … … 638 638 allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there 639 639 is not enough memory remaining to satisfy the request, then NULL is returned. 640 640 641 641 If Buffer is NULL, then ASSERT(). 642 If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). 642 If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). 643 643 644 644 @param AllocationSize The number of bytes to allocate and zero. … … 662 662 663 663 Allocates and zeros the number bytes specified by NewSize from memory of the type 664 specified by PoolType. If OldBuffer is not NULL, then the smaller of OldSize and 665 NewSize bytes are copied from OldBuffer to the newly allocated buffer, and 666 OldBuffer is freed. A pointer to the newly allocated buffer is returned. 667 If NewSize is 0, then a valid buffer of 0 size is returned. If there is not 664 specified by PoolType. If OldBuffer is not NULL, then the smaller of OldSize and 665 NewSize bytes are copied from OldBuffer to the newly allocated buffer, and 666 OldBuffer is freed. A pointer to the newly allocated buffer is returned. 667 If NewSize is 0, then a valid buffer of 0 size is returned. If there is not 668 668 enough memory remaining to satisfy the request, then NULL is returned. 669 669 670 670 If the allocation of the new buffer is successful and the smaller of NewSize and OldSize 671 671 is greater than (MAX_ADDRESS - OldBuffer + 1), then ASSERT(). … … 674 674 @param OldSize The size, in bytes, of OldBuffer. 675 675 @param NewSize The size, in bytes, of the buffer to reallocate. 676 @param OldBuffer The buffer to copy to the allocated buffer. This is an optional 676 @param OldBuffer The buffer to copy to the allocated buffer. This is an optional 677 677 parameter that may be NULL. 678 678 … … 682 682 VOID * 683 683 InternalReallocatePool ( 684 IN EFI_MEMORY_TYPE PoolType, 684 IN EFI_MEMORY_TYPE PoolType, 685 685 IN UINTN OldSize, 686 686 IN UINTN NewSize, … … 702 702 703 703 Allocates and zeros the number bytes specified by NewSize from memory of type 704 EfiBootServicesData. If OldBuffer is not NULL, then the smaller of OldSize and 705 NewSize bytes are copied from OldBuffer to the newly allocated buffer, and 706 OldBuffer is freed. A pointer to the newly allocated buffer is returned. 707 If NewSize is 0, then a valid buffer of 0 size is returned. If there is not 704 EfiBootServicesData. If OldBuffer is not NULL, then the smaller of OldSize and 705 NewSize bytes are copied from OldBuffer to the newly allocated buffer, and 706 OldBuffer is freed. A pointer to the newly allocated buffer is returned. 707 If NewSize is 0, then a valid buffer of 0 size is returned. If there is not 708 708 enough memory remaining to satisfy the request, then NULL is returned. 709 709 710 710 If the allocation of the new buffer is successful and the smaller of NewSize and OldSize 711 711 is greater than (MAX_ADDRESS - OldBuffer + 1), then ASSERT(). … … 713 713 @param OldSize The size, in bytes, of OldBuffer. 714 714 @param NewSize The size, in bytes, of the buffer to reallocate. 715 @param OldBuffer The buffer to copy to the allocated buffer. This is an optional 715 @param OldBuffer The buffer to copy to the allocated buffer. This is an optional 716 716 parameter that may be NULL. 717 717 … … 734 734 735 735 Allocates and zeros the number bytes specified by NewSize from memory of type 736 EfiRuntimeServicesData. If OldBuffer is not NULL, then the smaller of OldSize and 737 NewSize bytes are copied from OldBuffer to the newly allocated buffer, and 738 OldBuffer is freed. A pointer to the newly allocated buffer is returned. 739 If NewSize is 0, then a valid buffer of 0 size is returned. If there is not 736 EfiRuntimeServicesData. If OldBuffer is not NULL, then the smaller of OldSize and 737 NewSize bytes are copied from OldBuffer to the newly allocated buffer, and 738 OldBuffer is freed. A pointer to the newly allocated buffer is returned. 739 If NewSize is 0, then a valid buffer of 0 size is returned. If there is not 740 740 enough memory remaining to satisfy the request, then NULL is returned. 741 741 … … 745 745 @param OldSize The size, in bytes, of OldBuffer. 746 746 @param NewSize The size, in bytes, of the buffer to reallocate. 747 @param OldBuffer The buffer to copy to the allocated buffer. This is an optional 747 @param OldBuffer The buffer to copy to the allocated buffer. This is an optional 748 748 parameter that may be NULL. 749 749 … … 766 766 767 767 Allocates and zeros the number bytes specified by NewSize from memory of type 768 EfiReservedMemoryType. If OldBuffer is not NULL, then the smaller of OldSize and 769 NewSize bytes are copied from OldBuffer to the newly allocated buffer, and 770 OldBuffer is freed. A pointer to the newly allocated buffer is returned. 771 If NewSize is 0, then a valid buffer of 0 size is returned. If there is not 768 EfiReservedMemoryType. If OldBuffer is not NULL, then the smaller of OldSize and 769 NewSize bytes are copied from OldBuffer to the newly allocated buffer, and 770 OldBuffer is freed. A pointer to the newly allocated buffer is returned. 771 If NewSize is 0, then a valid buffer of 0 size is returned. If there is not 772 772 enough memory remaining to satisfy the request, then NULL is returned. 773 773 … … 777 777 @param OldSize The size, in bytes, of OldBuffer. 778 778 @param NewSize The size, in bytes, of the buffer to reallocate. 779 @param OldBuffer The buffer to copy to the allocated buffer. This is an optional 779 @param OldBuffer The buffer to copy to the allocated buffer. This is an optional 780 780 parameter that may be NULL. 781 781 … … 801 801 pool allocation services of the Memory Allocation Library. If it is not possible to free pool 802 802 resources, then this function will perform no actions. 803 803 804 804 If Buffer was not allocated with a pool allocation function in the Memory Allocation Library, 805 805 then ASSERT().
Note:
See TracChangeset
for help on using the changeset viewer.