]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Core/Dxe/Imem.h
Code Scrub for Dxe Core.
[mirror_edk2.git] / MdeModulePkg / Core / Dxe / Imem.h
CommitLineData
23c98c94 1/** @file\r
504214c4 2 Data structure and functions to allocate and free memory space.\r
28a00297 3\r
23c98c94 4Copyright (c) 2006 - 2008, Intel Corporation. <BR>\r
5All rights reserved. This program and the accompanying materials\r
6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
28a00297 9\r
23c98c94 10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
162ed594 12\r
13**/\r
28a00297 14\r
15#ifndef _IMEM_H_\r
16#define _IMEM_H_\r
17\r
18#if defined (MDE_CPU_IPF)\r
19//\r
20// For Itanium machines make the default allocations 8K aligned\r
21//\r
22#define EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT (EFI_PAGE_SIZE * 2)\r
23#define DEFAULT_PAGE_ALLOCATION (EFI_PAGE_SIZE * 2)\r
24\r
25#else\r
26//\r
27// For genric EFI machines make the default allocations 4K aligned\r
28//\r
29#define EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT (EFI_PAGE_SIZE)\r
30#define DEFAULT_PAGE_ALLOCATION (EFI_PAGE_SIZE)\r
31\r
32#endif\r
33\r
34\r
35//\r
36// MEMORY_MAP_ENTRY\r
37//\r
38\r
39#define MEMORY_MAP_SIGNATURE EFI_SIGNATURE_32('m','m','a','p')\r
40typedef struct {\r
41 UINTN Signature;\r
42 LIST_ENTRY Link;\r
43 BOOLEAN FromPages;\r
44\r
45 EFI_MEMORY_TYPE Type;\r
46 UINT64 Start;\r
47 UINT64 End;\r
48\r
49 UINT64 VirtualStart;\r
50 UINT64 Attribute;\r
51} MEMORY_MAP;\r
52\r
53//\r
54// Internal prototypes\r
55//\r
56\r
28a00297 57\r
162ed594 58/**\r
28a00297 59 Internal function. Used by the pool functions to allocate pages\r
60 to back pool allocation requests.\r
61\r
022c6d45 62 @param PoolType The type of memory for the new pool pages\r
63 @param NumberOfPages No of pages to allocate\r
64 @param Alignment Bits to align.\r
28a00297 65\r
162ed594 66 @return The allocated memory, or NULL\r
28a00297 67\r
162ed594 68**/\r
69VOID *\r
70CoreAllocatePoolPages (\r
23c98c94 71 IN EFI_MEMORY_TYPE PoolType,\r
72 IN UINTN NumberOfPages,\r
73 IN UINTN Alignment\r
74 );\r
28a00297 75\r
28a00297 76\r
28a00297 77\r
162ed594 78/**\r
79 Internal function. Frees pool pages allocated via AllocatePoolPages ()\r
28a00297 80\r
022c6d45 81 @param Memory The base address to free\r
162ed594 82 @param NumberOfPages The number of pages to free\r
28a00297 83\r
162ed594 84**/\r
28a00297 85VOID\r
86CoreFreePoolPages (\r
87 IN EFI_PHYSICAL_ADDRESS Memory,\r
88 IN UINTN NumberOfPages\r
23c98c94 89 );\r
28a00297 90\r
28a00297 91\r
28a00297 92\r
162ed594 93/**\r
94 Internal function to allocate pool of a particular type.\r
95 Caller must have the memory lock held\r
28a00297 96\r
022c6d45 97 @param PoolType Type of pool to allocate\r
98 @param Size The amount of pool to allocate\r
28a00297 99\r
162ed594 100 @return The allocate pool, or NULL\r
28a00297 101\r
162ed594 102**/\r
28a00297 103VOID *\r
104CoreAllocatePoolI (\r
105 IN EFI_MEMORY_TYPE PoolType,\r
106 IN UINTN Size\r
23c98c94 107 );\r
28a00297 108\r
28a00297 109\r
28a00297 110\r
162ed594 111/**\r
112 Internal function to free a pool entry.\r
28a00297 113 Caller must have the memory lock held\r
114\r
022c6d45 115 @param Buffer The allocated pool entry to free\r
28a00297 116\r
022c6d45 117 @retval EFI_INVALID_PARAMETER Buffer not valid\r
162ed594 118 @retval EFI_SUCCESS Buffer successfully freed.\r
28a00297 119\r
162ed594 120**/\r
28a00297 121EFI_STATUS\r
122CoreFreePoolI (\r
23c98c94 123 IN VOID *Buffer\r
124 );\r
28a00297 125\r
28a00297 126\r
28a00297 127\r
162ed594 128/**\r
129 Enter critical section by gaining lock on gMemoryLock.\r
28a00297 130\r
162ed594 131**/\r
28a00297 132VOID\r
133CoreAcquireMemoryLock (\r
134 VOID\r
23c98c94 135 );\r
28a00297 136\r
28a00297 137\r
162ed594 138/**\r
139 Exit critical section by releasing lock on gMemoryLock.\r
28a00297 140\r
162ed594 141**/\r
28a00297 142VOID\r
143CoreReleaseMemoryLock (\r
144 VOID\r
23c98c94 145 );\r
28a00297 146\r
147\r
148//\r
149// Internal Global data\r
150//\r
151\r
022c6d45 152extern EFI_LOCK gMemoryLock;\r
28a00297 153extern LIST_ENTRY gMemoryMap;\r
154extern MEMORY_MAP *gMemoryLastConvert;\r
155extern LIST_ENTRY mGcdMemorySpaceMap;\r
156#endif\r