]> git.proxmox.com Git - mirror_edk2.git/blame - ArmPkg/Include/Library/UncachedMemoryAllocationLib.h
Added support for L2 (4K) page tables and made the CPU driver change cachability...
[mirror_edk2.git] / ArmPkg / Include / Library / UncachedMemoryAllocationLib.h
CommitLineData
2ef2b01e
A
1/** @file
2
3 Copyright (c) 2008-2009 Apple Inc. All rights reserved.<BR>
4
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13**/
14
15#ifndef __UNCACHED_MEMORY_ALLOCATION_LIB_H__
16#define __UNCACHED_MEMORY_ALLOCATION_LIB_H__
17
18/**
19 Converts a cached or uncached address to a physical address suitable for use in SoC registers.
20
21 @param VirtualAddress The pointer to convert.
22
23 @return The physical address of the supplied virtual pointer.
24
25**/
26EFI_PHYSICAL_ADDRESS
27ConvertToPhysicalAddress (
28 IN VOID *VirtualAddress
29 );
30
31/**
32 Converts a cached or uncached address to a cached address.
33
34 @param Address The pointer to convert.
35
36 @return The address of the cached memory location corresponding to the input address.
37
38**/
39VOID *
40ConvertToCachedAddress (
41 IN VOID *Address
42 );
43
44/**
45 Converts a cached or uncached address to an uncached address.
46
47 @param Address The pointer to convert.
48
49 @return The address of the uncached memory location corresponding to the input address.
50
51**/
52VOID *
53ConvertToUncachedAddress (
54 IN VOID *Address
55 );
56
57/**
58 Allocates one or more 4KB pages of type EfiBootServicesData.
59
60 Allocates the number of 4KB pages of type EfiBootServicesData and returns a pointer to the
61 allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL
62 is returned. If there is not enough memory remaining to satisfy the request, then NULL is
63 returned.
64
65 @param Pages The number of 4 KB pages to allocate.
66
67 @return A pointer to the allocated buffer or NULL if allocation fails.
68
69**/
70VOID *
71EFIAPI
72UncachedAllocatePages (
73 IN UINTN Pages
74 );
75
76/**
77 Allocates one or more 4KB pages of type EfiRuntimeServicesData.
78
79 Allocates the number of 4KB pages of type EfiRuntimeServicesData and returns a pointer to the
80 allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL
81 is returned. If there is not enough memory remaining to satisfy the request, then NULL is
82 returned.
83
84 @param Pages The number of 4 KB pages to allocate.
85
86 @return A pointer to the allocated buffer or NULL if allocation fails.
87
88**/
89VOID *
90EFIAPI
91UncachedAllocateRuntimePages (
92 IN UINTN Pages
93 );
94
95/**
96 Allocates one or more 4KB pages of type EfiReservedMemoryType.
97
98 Allocates the number of 4KB pages of type EfiReservedMemoryType and returns a pointer to the
99 allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL
100 is returned. If there is not enough memory remaining to satisfy the request, then NULL is
101 returned.
102
103 @param Pages The number of 4 KB pages to allocate.
104
105 @return A pointer to the allocated buffer or NULL if allocation fails.
106
107**/
108VOID *
109EFIAPI
110UncachedAllocateReservedPages (
111 IN UINTN Pages
112 );
113
114/**
115 Frees one or more 4KB pages that were previously allocated with one of the page allocation
116 functions in the Memory Allocation Library.
117
118 Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer. Buffer
119 must have been allocated on a previous call to the page allocation services of the Memory
120 Allocation Library.
121 If Buffer was not allocated with a page allocation function in the Memory Allocation Library,
122 then ASSERT().
123 If Pages is zero, then ASSERT().
124
125 @param Buffer Pointer to the buffer of pages to free.
126 @param Pages The number of 4 KB pages to free.
127
128**/
129VOID
130EFIAPI
131UncachedFreePages (
132 IN VOID *Buffer,
133 IN UINTN Pages
134 );
135
136/**
137 Allocates one or more 4KB pages of type EfiBootServicesData at a specified alignment.
138
139 Allocates the number of 4KB pages specified by Pages of type EfiBootServicesData with an
140 alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is
141 returned. If there is not enough memory at the specified alignment remaining to satisfy the
142 request, then NULL is returned.
143 If Alignment is not a power of two and Alignment is not zero, then ASSERT().
144
145 @param Pages The number of 4 KB pages to allocate.
146 @param Alignment The requested alignment of the allocation. Must be a power of two.
147 If Alignment is zero, then byte alignment is used.
148
149 @return A pointer to the allocated buffer or NULL if allocation fails.
150
151**/
152VOID *
153EFIAPI
154UncachedAllocateAlignedPages (
155 IN UINTN Pages,
156 IN UINTN Alignment
157 );
158
159/**
160 Allocates one or more 4KB pages of type EfiRuntimeServicesData at a specified alignment.
161
162 Allocates the number of 4KB pages specified by Pages of type EfiRuntimeServicesData with an
163 alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is
164 returned. If there is not enough memory at the specified alignment remaining to satisfy the
165 request, then NULL is returned.
166 If Alignment is not a power of two and Alignment is not zero, then ASSERT().
167
168 @param Pages The number of 4 KB pages to allocate.
169 @param Alignment The requested alignment of the allocation. Must be a power of two.
170 If Alignment is zero, then byte alignment is used.
171
172 @return A pointer to the allocated buffer or NULL if allocation fails.
173
174**/
175VOID *
176EFIAPI
177UncachedAllocateAlignedRuntimePages (
178 IN UINTN Pages,
179 IN UINTN Alignment
180 );
181
182/**
183 Allocates one or more 4KB pages of type EfiReservedMemoryType at a specified alignment.
184
185 Allocates the number of 4KB pages specified by Pages of type EfiReservedMemoryType with an
186 alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is
187 returned. If there is not enough memory at the specified alignment remaining to satisfy the
188 request, then NULL is returned.
189 If Alignment is not a power of two and Alignment is not zero, then ASSERT().
190
191 @param Pages The number of 4 KB pages to allocate.
192 @param Alignment The requested alignment of the allocation. Must be a power of two.
193 If Alignment is zero, then byte alignment is used.
194
195 @return A pointer to the allocated buffer or NULL if allocation fails.
196
197**/
198VOID *
199EFIAPI
200UncachedAllocateAlignedReservedPages (
201 IN UINTN Pages,
202 IN UINTN Alignment
203 );
204
205/**
206 Frees one or more 4KB pages that were previously allocated with one of the aligned page
207 allocation functions in the Memory Allocation Library.
208
209 Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer. Buffer
210 must have been allocated on a previous call to the aligned page allocation services of the Memory
211 Allocation Library.
212 If Buffer was not allocated with an aligned page allocation function in the Memory Allocation
213 Library, then ASSERT().
214 If Pages is zero, then ASSERT().
215
216 @param Buffer Pointer to the buffer of pages to free.
217 @param Pages The number of 4 KB pages to free.
218
219**/
220VOID
221EFIAPI
222UncachedFreeAlignedPages (
223 IN VOID *Buffer,
224 IN UINTN Pages
225 );
226
227/**
228 Allocates a buffer of type EfiBootServicesData.
229
230 Allocates the number bytes specified by AllocationSize of type EfiBootServicesData and returns a
231 pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is
232 returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.
233
234 @param AllocationSize The number of bytes to allocate.
235
236 @return A pointer to the allocated buffer or NULL if allocation fails.
237
238**/
239VOID *
240EFIAPI
241UncachedAllocatePool (
242 IN UINTN AllocationSize
243 );
244
245/**
246 Allocates a buffer of type EfiRuntimeServicesData.
247
248 Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData and returns
249 a pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is
250 returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.
251
252 @param AllocationSize The number of bytes to allocate.
253
254 @return A pointer to the allocated buffer or NULL if allocation fails.
255
256**/
257VOID *
258EFIAPI
259UncachedAllocateRuntimePool (
260 IN UINTN AllocationSize
261 );
262
263/**
264 Allocates a buffer of type EfieservedMemoryType.
265
266 Allocates the number bytes specified by AllocationSize of type EfieservedMemoryType and returns
267 a pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is
268 returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.
269
270 @param AllocationSize The number of bytes to allocate.
271
272 @return A pointer to the allocated buffer or NULL if allocation fails.
273
274**/
275VOID *
276EFIAPI
277UncachedAllocateReservedPool (
278 IN UINTN AllocationSize
279 );
280
281/**
282 Allocates and zeros a buffer of type EfiBootServicesData.
283
284 Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, clears the
285 buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a
286 valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the
287 request, then NULL is returned.
288
289 @param AllocationSize The number of bytes to allocate and zero.
290
291 @return A pointer to the allocated buffer or NULL if allocation fails.
292
293**/
294VOID *
295EFIAPI
296UncachedAllocateZeroPool (
297 IN UINTN AllocationSize
298 );
299
300/**
301 Allocates and zeros a buffer of type EfiRuntimeServicesData.
302
303 Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData, clears the
304 buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a
305 valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the
306 request, then NULL is returned.
307
308 @param AllocationSize The number of bytes to allocate and zero.
309
310 @return A pointer to the allocated buffer or NULL if allocation fails.
311
312**/
313VOID *
314EFIAPI
315UncachedAllocateRuntimeZeroPool (
316 IN UINTN AllocationSize
317 );
318
319/**
320 Allocates and zeros a buffer of type EfiReservedMemoryType.
321
322 Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType, clears the
323 buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a
324 valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the
325 request, then NULL is returned.
326
327 @param AllocationSize The number of bytes to allocate and zero.
328
329 @return A pointer to the allocated buffer or NULL if allocation fails.
330
331**/
332VOID *
333EFIAPI
334UncachedAllocateReservedZeroPool (
335 IN UINTN AllocationSize
336 );
337
338/**
339 Copies a buffer to an allocated buffer of type EfiBootServicesData.
340
341 Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, copies
342 AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the
343 allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
344 is not enough memory remaining to satisfy the request, then NULL is returned.
345 If Buffer is NULL, then ASSERT().
346 If AllocationSize is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT().
347
348 @param AllocationSize The number of bytes to allocate and zero.
349 @param Buffer The buffer to copy to the allocated buffer.
350
351 @return A pointer to the allocated buffer or NULL if allocation fails.
352
353**/
354VOID *
355EFIAPI
356UncachedAllocateCopyPool (
357 IN UINTN AllocationSize,
358 IN CONST VOID *Buffer
359 );
360
361/**
362 Copies a buffer to an allocated buffer of type EfiRuntimeServicesData.
363
364 Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData, copies
365 AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the
366 allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
367 is not enough memory remaining to satisfy the request, then NULL is returned.
368 If Buffer is NULL, then ASSERT().
369 If AllocationSize is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT().
370
371 @param AllocationSize The number of bytes to allocate and zero.
372 @param Buffer The buffer to copy to the allocated buffer.
373
374 @return A pointer to the allocated buffer or NULL if allocation fails.
375
376**/
377VOID *
378EFIAPI
379UncachedAllocateRuntimeCopyPool (
380 IN UINTN AllocationSize,
381 IN CONST VOID *Buffer
382 );
383
384/**
385 Copies a buffer to an allocated buffer of type EfiReservedMemoryType.
386
387 Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType, copies
388 AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the
389 allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
390 is not enough memory remaining to satisfy the request, then NULL is returned.
391 If Buffer is NULL, then ASSERT().
392 If AllocationSize is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT().
393
394 @param AllocationSize The number of bytes to allocate and zero.
395 @param Buffer The buffer to copy to the allocated buffer.
396
397 @return A pointer to the allocated buffer or NULL if allocation fails.
398
399**/
400VOID *
401EFIAPI
402UncachedAllocateReservedCopyPool (
403 IN UINTN AllocationSize,
404 IN CONST VOID *Buffer
405 );
406
407/**
408 Frees a buffer that was previously allocated with one of the pool allocation functions in the
409 Memory Allocation Library.
410
411 Frees the buffer specified by Buffer. Buffer must have been allocated on a previous call to the
412 pool allocation services of the Memory Allocation Library.
413 If Buffer was not allocated with a pool allocation function in the Memory Allocation Library,
414 then ASSERT().
415
416 @param Buffer Pointer to the buffer to free.
417
418**/
419VOID
420EFIAPI
421UncachedFreePool (
422 IN VOID *Buffer
423 );
424
425/**
426 Allocates a buffer of type EfiBootServicesData at a specified alignment.
427
428 Allocates the number bytes specified by AllocationSize of type EfiBootServicesData with an
429 alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0,
430 then a valid buffer of 0 size is returned. If there is not enough memory at the specified
431 alignment remaining to satisfy the request, then NULL is returned.
432 If Alignment is not a power of two and Alignment is not zero, then ASSERT().
433
434 @param AllocationSize The number of bytes to allocate.
435 @param Alignment The requested alignment of the allocation. Must be a power of two.
436 If Alignment is zero, then byte alignment is used.
437
438 @return A pointer to the allocated buffer or NULL if allocation fails.
439
440**/
441VOID *
442EFIAPI
443UncachedAllocateAlignedPool (
444 IN UINTN AllocationSize,
445 IN UINTN Alignment
446 );
447
448/**
449 Allocates a buffer of type EfiRuntimeServicesData at a specified alignment.
450
451 Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData with an
452 alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0,
453 then a valid buffer of 0 size is returned. If there is not enough memory at the specified
454 alignment remaining to satisfy the request, then NULL is returned.
455 If Alignment is not a power of two and Alignment is not zero, then ASSERT().
456
457 @param AllocationSize The number of bytes to allocate.
458 @param Alignment The requested alignment of the allocation. Must be a power of two.
459 If Alignment is zero, then byte alignment is used.
460
461 @return A pointer to the allocated buffer or NULL if allocation fails.
462
463**/
464VOID *
465EFIAPI
466UncachedAllocateAlignedRuntimePool (
467 IN UINTN AllocationSize,
468 IN UINTN Alignment
469 );
470
471/**
472 Allocates a buffer of type EfieservedMemoryType at a specified alignment.
473
474 Allocates the number bytes specified by AllocationSize of type EfieservedMemoryType with an
475 alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0,
476 then a valid buffer of 0 size is returned. If there is not enough memory at the specified
477 alignment remaining to satisfy the request, then NULL is returned.
478 If Alignment is not a power of two and Alignment is not zero, then ASSERT().
479
480 @param AllocationSize The number of bytes to allocate.
481 @param Alignment The requested alignment of the allocation. Must be a power of two.
482 If Alignment is zero, then byte alignment is used.
483
484 @return A pointer to the allocated buffer or NULL if allocation fails.
485
486**/
487VOID *
488EFIAPI
489UncachedAllocateAlignedReservedPool (
490 IN UINTN AllocationSize,
491 IN UINTN Alignment
492 );
493
494/**
495 Allocates and zeros a buffer of type EfiBootServicesData at a specified alignment.
496
497 Allocates the number bytes specified by AllocationSize of type EfiBootServicesData with an
498 alignment specified by Alignment, clears the buffer with zeros, and returns a pointer to the
499 allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
500 is not enough memory at the specified alignment remaining to satisfy the request, then NULL is
501 returned.
502 If Alignment is not a power of two and Alignment is not zero, then ASSERT().
503
504 @param AllocationSize The number of bytes to allocate.
505 @param Alignment The requested alignment of the allocation. Must be a power of two.
506 If Alignment is zero, then byte alignment is used.
507
508 @return A pointer to the allocated buffer or NULL if allocation fails.
509
510**/
511VOID *
512EFIAPI
513UncachedAllocateAlignedZeroPool (
514 IN UINTN AllocationSize,
515 IN UINTN Alignment
516 );
517
518/**
519 Allocates and zeros a buffer of type EfiRuntimeServicesData at a specified alignment.
520
521 Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData with an
522 alignment specified by Alignment, clears the buffer with zeros, and returns a pointer to the
523 allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
524 is not enough memory at the specified alignment remaining to satisfy the request, then NULL is
525 returned.
526 If Alignment is not a power of two and Alignment is not zero, then ASSERT().
527
528 @param AllocationSize The number of bytes to allocate.
529 @param Alignment The requested alignment of the allocation. Must be a power of two.
530 If Alignment is zero, then byte alignment is used.
531
532 @return A pointer to the allocated buffer or NULL if allocation fails.
533
534**/
535VOID *
536EFIAPI
537UncachedAllocateAlignedRuntimeZeroPool (
538 IN UINTN AllocationSize,
539 IN UINTN Alignment
540 );
541
542/**
543 Allocates and zeros a buffer of type EfieservedMemoryType at a specified alignment.
544
545 Allocates the number bytes specified by AllocationSize of type EfieservedMemoryType with an
546 alignment specified by Alignment, clears the buffer with zeros, and returns a pointer to the
547 allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
548 is not enough memory at the specified alignment remaining to satisfy the request, then NULL is
549 returned.
550 If Alignment is not a power of two and Alignment is not zero, then ASSERT().
551
552 @param AllocationSize The number of bytes to allocate.
553 @param Alignment The requested alignment of the allocation. Must be a power of two.
554 If Alignment is zero, then byte alignment is used.
555
556 @return A pointer to the allocated buffer or NULL if allocation fails.
557
558**/
559VOID *
560EFIAPI
561UncachedAllocateAlignedReservedZeroPool (
562 IN UINTN AllocationSize,
563 IN UINTN Alignment
564 );
565
566/**
567 Copies a buffer to an allocated buffer of type EfiBootServicesData at a specified alignment.
568
569 Allocates the number bytes specified by AllocationSize of type EfiBootServicesData type with an
570 alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0,
571 then a valid buffer of 0 size is returned. If there is not enough memory at the specified
572 alignment remaining to satisfy the request, then NULL is returned.
573 If Alignment is not a power of two and Alignment is not zero, then ASSERT().
574
575 @param AllocationSize The number of bytes to allocate.
576 @param Buffer The buffer to copy to the allocated buffer.
577 @param Alignment The requested alignment of the allocation. Must be a power of two.
578 If Alignment is zero, then byte alignment is used.
579
580 @return A pointer to the allocated buffer or NULL if allocation fails.
581
582**/
583VOID *
584EFIAPI
585UncachedAllocateAlignedCopyPool (
586 IN UINTN AllocationSize,
587 IN CONST VOID *Buffer,
588 IN UINTN Alignment
589 );
590
591/**
592 Copies a buffer to an allocated buffer of type EfiRuntimeServicesData at a specified alignment.
593
594 Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData type with an
595 alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0,
596 then a valid buffer of 0 size is returned. If there is not enough memory at the specified
597 alignment remaining to satisfy the request, then NULL is returned.
598 If Alignment is not a power of two and Alignment is not zero, then ASSERT().
599
600 @param AllocationSize The number of bytes to allocate.
601 @param Buffer The buffer to copy to the allocated buffer.
602 @param Alignment The requested alignment of the allocation. Must be a power of two.
603 If Alignment is zero, then byte alignment is used.
604
605 @return A pointer to the allocated buffer or NULL if allocation fails.
606
607**/
608VOID *
609EFIAPI
610UncachedAllocateAlignedRuntimeCopyPool (
611 IN UINTN AllocationSize,
612 IN CONST VOID *Buffer,
613 IN UINTN Alignment
614 );
615
616/**
617 Copies a buffer to an allocated buffer of type EfiReservedMemoryType at a specified alignment.
618
619 Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType type with an
620 alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0,
621 then a valid buffer of 0 size is returned. If there is not enough memory at the specified
622 alignment remaining to satisfy the request, then NULL is returned.
623 If Alignment is not a power of two and Alignment is not zero, then ASSERT().
624
625 @param AllocationSize The number of bytes to allocate.
626 @param Buffer The buffer to copy to the allocated buffer.
627 @param Alignment The requested alignment of the allocation. Must be a power of two.
628 If Alignment is zero, then byte alignment is used.
629
630 @return A pointer to the allocated buffer or NULL if allocation fails.
631
632**/
633VOID *
634EFIAPI
635UncachedAllocateAlignedReservedCopyPool (
636 IN UINTN AllocationSize,
637 IN CONST VOID *Buffer,
638 IN UINTN Alignment
639 );
640
641/**
642 Frees a buffer that was previously allocated with one of the aligned pool allocation functions
643 in the Memory Allocation Library.
644
645 Frees the buffer specified by Buffer. Buffer must have been allocated on a previous call to the
646 aligned pool allocation services of the Memory Allocation Library.
647 If Buffer was not allocated with an aligned pool allocation function in the Memory Allocation
648 Library, then ASSERT().
649
650 @param Buffer Pointer to the buffer to free.
651
652**/
653VOID
654EFIAPI
655UncachedFreeAlignedPool (
656 IN VOID *Buffer
657 );
658
659VOID
660EFIAPI
661UncachedSafeFreePool (
662 IN VOID *Buffer
663 );
664
665#endif // __UNCACHED_MEMORY_ALLOCATION_LIB_H__