]> git.proxmox.com Git - mirror_edk2.git/blame - EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/EfiLibAllocate.c
Update the copyright notice format
[mirror_edk2.git] / EdkCompatibilityPkg / Foundation / Library / Dxe / EfiDriverLib / EfiLibAllocate.c
CommitLineData
3eb9473e 1/*++\r
2\r
4ea9375a
HT
3Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>\r
4This program and the accompanying materials \r
3eb9473e 5are licensed and made available under the terms and conditions of the BSD License \r
6which accompanies this distribution. The full text of the license may be found at \r
7http://opensource.org/licenses/bsd-license.php \r
8 \r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
11\r
12Module Name:\r
13\r
14 EfiLibAllocate.c\r
15\r
16Abstract:\r
17\r
18 Support routines for memory allocation routines for use with drivers.\r
19\r
20--*/\r
21\r
22#include "Tiano.h"\r
23#include "EfiDriverLib.h"\r
24\r
25VOID *\r
26EfiLibAllocatePool (\r
27 IN UINTN AllocationSize\r
28 )\r
29/*++\r
30\r
31Routine Description:\r
32\r
33 Allocate BootServicesData pool.\r
34\r
35Arguments:\r
36\r
37 AllocationSize - The size to allocate\r
38\r
39Returns:\r
40\r
41 Pointer of the buffer allocated.\r
42\r
43--*/\r
44{\r
45 VOID *Memory;\r
46\r
47 Memory = NULL;\r
48 gBS->AllocatePool (EfiBootServicesData, AllocationSize, &Memory);\r
49 return Memory;\r
50}\r
51\r
52VOID *\r
53EfiLibAllocateRuntimePool (\r
54 IN UINTN AllocationSize\r
55 )\r
56/*++\r
57\r
58Routine Description:\r
59\r
60 Allocate RuntimeServicesData pool.\r
61\r
62Arguments:\r
63\r
64 AllocationSize - The size to allocate\r
65\r
66Returns:\r
67\r
68 Pointer of the buffer allocated.\r
69\r
70--*/\r
71{\r
72 VOID *Memory;\r
73\r
74 Memory = NULL;\r
75 gBS->AllocatePool (EfiRuntimeServicesData, AllocationSize, &Memory);\r
76 return Memory;\r
77}\r
78\r
79VOID *\r
80EfiLibAllocateZeroPool (\r
81 IN UINTN AllocationSize\r
82 )\r
83/*++\r
84\r
85Routine Description:\r
86\r
87 Allocate BootServicesData pool and zero it.\r
88\r
89Arguments:\r
90\r
91 AllocationSize - The size to allocate\r
92\r
93Returns:\r
94\r
95 Pointer of the buffer allocated.\r
96\r
97--*/\r
98{\r
99 VOID *Memory;\r
100\r
101 Memory = EfiLibAllocatePool (AllocationSize);\r
102 if (Memory != NULL) {\r
103 gBS->SetMem (Memory, AllocationSize, 0);\r
104 }\r
105\r
106 return Memory;\r
107}\r
108\r
109VOID *\r
110EfiLibAllocateRuntimeZeroPool (\r
111 IN UINTN AllocationSize\r
112 )\r
113/*++\r
114\r
115Routine Description:\r
116\r
117 Allocate RuntimeServicesData pool and zero it.\r
118\r
119Arguments:\r
120\r
121 AllocationSize - The size to allocate\r
122\r
123Returns:\r
124\r
125 Pointer of the buffer allocated.\r
126\r
127--*/\r
128{\r
129 VOID *Memory;\r
130\r
131 Memory = EfiLibAllocateRuntimePool (AllocationSize);\r
132 if (Memory != NULL) {\r
133 gBS->SetMem (Memory, AllocationSize, 0);\r
134 }\r
135\r
136 return Memory;\r
137}\r
138\r
139VOID *\r
140EfiLibAllocateCopyPool (\r
141 IN UINTN AllocationSize,\r
142 IN VOID *Buffer\r
143 )\r
144/*++\r
145\r
146Routine Description:\r
147\r
148 Allocate BootServicesData pool and use a buffer provided by \r
149 caller to fill it.\r
150\r
151Arguments:\r
152\r
153 AllocationSize - The size to allocate\r
154 \r
155 Buffer - Buffer that will be filled into the buffer allocated\r
156\r
157Returns:\r
158\r
159 Pointer of the buffer allocated.\r
160\r
161--*/\r
162{\r
163 VOID *Memory;\r
164\r
165 Memory = NULL;\r
166 gBS->AllocatePool (EfiBootServicesData, AllocationSize, &Memory);\r
167 if (Memory != NULL) {\r
168 gBS->CopyMem (Memory, Buffer, AllocationSize);\r
169 }\r
170\r
171 return Memory;\r
172}\r
173\r
174VOID *\r
175EfiLibAllocateRuntimeCopyPool (\r
176 IN UINTN AllocationSize,\r
177 IN VOID *Buffer\r
178 )\r
179/*++\r
180\r
181Routine Description:\r
182\r
183 Allocate RuntimeServicesData pool and use a buffer provided by \r
184 caller to fill it.\r
185\r
186Arguments:\r
187\r
188 AllocationSize - The size to allocate\r
189 \r
190 Buffer - Buffer that will be filled into the buffer allocated\r
191\r
192Returns:\r
193\r
194 Pointer of the buffer allocated.\r
195\r
196--*/\r
197{\r
198 VOID *Memory;\r
199\r
200 Memory = NULL;\r
201 gBS->AllocatePool (EfiRuntimeServicesData, AllocationSize, &Memory);\r
202 if (Memory != NULL) {\r
203 gBS->CopyMem (Memory, Buffer, AllocationSize);\r
204 }\r
205\r
206 return Memory;\r
207}\r
208\r
209\r
210VOID\r
211EfiLibSafeFreePool (\r
212 IN VOID *Buffer\r
213 )\r
214/*++\r
215\r
216Routine Description:\r
217\r
218 Free pool safely (without setting back Buffer to NULL).\r
219\r
220Arguments:\r
221 \r
222 Buffer - The allocated pool entry to free\r
223\r
224Returns:\r
225\r
226 Pointer of the buffer allocated.\r
227\r
228--*/\r
229{\r
230 if (Buffer != NULL) {\r
231 gBS->FreePool (Buffer);\r
232 }\r
7ccf38a3 233}\r