]>
git.proxmox.com Git - mirror_edk2.git/blob - EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/EfiLibAllocate.c
3 Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>
4 This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 Support routines for memory allocation routines for use with drivers.
23 #include "EfiDriverLib.h"
27 IN UINTN AllocationSize
33 Allocate BootServicesData pool.
37 AllocationSize - The size to allocate
41 Pointer of the buffer allocated.
48 gBS
->AllocatePool (EfiBootServicesData
, AllocationSize
, &Memory
);
53 EfiLibAllocateRuntimePool (
54 IN UINTN AllocationSize
60 Allocate RuntimeServicesData pool.
64 AllocationSize - The size to allocate
68 Pointer of the buffer allocated.
75 gBS
->AllocatePool (EfiRuntimeServicesData
, AllocationSize
, &Memory
);
80 EfiLibAllocateZeroPool (
81 IN UINTN AllocationSize
87 Allocate BootServicesData pool and zero it.
91 AllocationSize - The size to allocate
95 Pointer of the buffer allocated.
101 Memory
= EfiLibAllocatePool (AllocationSize
);
102 if (Memory
!= NULL
) {
103 gBS
->SetMem (Memory
, AllocationSize
, 0);
110 EfiLibAllocateRuntimeZeroPool (
111 IN UINTN AllocationSize
117 Allocate RuntimeServicesData pool and zero it.
121 AllocationSize - The size to allocate
125 Pointer of the buffer allocated.
131 Memory
= EfiLibAllocateRuntimePool (AllocationSize
);
132 if (Memory
!= NULL
) {
133 gBS
->SetMem (Memory
, AllocationSize
, 0);
140 EfiLibAllocateCopyPool (
141 IN UINTN AllocationSize
,
148 Allocate BootServicesData pool and use a buffer provided by
153 AllocationSize - The size to allocate
155 Buffer - Buffer that will be filled into the buffer allocated
159 Pointer of the buffer allocated.
166 gBS
->AllocatePool (EfiBootServicesData
, AllocationSize
, &Memory
);
167 if (Memory
!= NULL
) {
168 gBS
->CopyMem (Memory
, Buffer
, AllocationSize
);
175 EfiLibAllocateRuntimeCopyPool (
176 IN UINTN AllocationSize
,
183 Allocate RuntimeServicesData pool and use a buffer provided by
188 AllocationSize - The size to allocate
190 Buffer - Buffer that will be filled into the buffer allocated
194 Pointer of the buffer allocated.
201 gBS
->AllocatePool (EfiRuntimeServicesData
, AllocationSize
, &Memory
);
202 if (Memory
!= NULL
) {
203 gBS
->CopyMem (Memory
, Buffer
, AllocationSize
);
218 Free pool safely (without setting back Buffer to NULL).
222 Buffer - The allocated pool entry to free
226 Pointer of the buffer allocated.
230 if (Buffer
!= NULL
) {
231 gBS
->FreePool (Buffer
);