VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/Firmware/MdePkg/Library/DxeServicesLib/Allocate.c@ 85788

Last change on this file since 85788 was 80721, checked in by vboxsync, 5 years ago

Devices/EFI/FirmwareNew: Start upgrade process to edk2-stable201908 (compiles on Windows and works to some extent), bugref:4643

  • Property svn:eol-style set to native
File size: 1.2 KB
Line 
1/** @file
2 DxeServicesLib memory allocation routines
3
4 Copyright (c) 2018, Linaro, Ltd. All rights reserved.<BR>
5
6 SPDX-License-Identifier: BSD-2-Clause-Patent
7
8**/
9
10#include <PiDxe.h>
11#include <Library/UefiBootServicesTableLib.h>
12#include <Library/DxeServicesLib.h>
13
14/**
15 Allocates one or more 4KB pages of a given type from a memory region that is
16 accessible to PEI.
17
18 Allocates the number of 4KB pages of type 'MemoryType' and returns a
19 pointer to the allocated buffer. The buffer returned is aligned on a 4KB
20 boundary. If Pages is 0, then NULL is returned. If there is not enough
21 memory remaining to satisfy the request, then NULL is returned.
22
23 @param[in] MemoryType The memory type to allocate
24 @param[in] Pages The number of 4 KB pages to allocate.
25
26 @return A pointer to the allocated buffer or NULL if allocation fails.
27
28**/
29VOID *
30EFIAPI
31AllocatePeiAccessiblePages (
32 IN EFI_MEMORY_TYPE MemoryType,
33 IN UINTN Pages
34 )
35{
36 EFI_STATUS Status;
37 EFI_PHYSICAL_ADDRESS Memory;
38
39 if (Pages == 0) {
40 return NULL;
41 }
42
43 Status = gBS->AllocatePages (AllocateAnyPages, MemoryType, Pages, &Memory);
44 if (EFI_ERROR (Status)) {
45 return NULL;
46 }
47 return (VOID *)(UINTN)Memory;
48}
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette