]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Core/Dxe/Imem.h
Don't align image address for TeImage, because TeImage section alignment is undefined.
[mirror_edk2.git] / MdeModulePkg / Core / Dxe / Imem.h
1 /** @file
2 Data structure and functions to allocate and free memory space.
3
4 Copyright (c) 2006 - 2008, Intel Corporation. <BR>
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 _IMEM_H_
16 #define _IMEM_H_
17
18 #if defined (MDE_CPU_IPF)
19 //
20 // For Itanium machines make the default allocations 8K aligned
21 //
22 #define EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT (EFI_PAGE_SIZE * 2)
23 #define DEFAULT_PAGE_ALLOCATION (EFI_PAGE_SIZE * 2)
24
25 #else
26 //
27 // For genric EFI machines make the default allocations 4K aligned
28 //
29 #define EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT (EFI_PAGE_SIZE)
30 #define DEFAULT_PAGE_ALLOCATION (EFI_PAGE_SIZE)
31
32 #endif
33
34
35 //
36 // MEMORY_MAP_ENTRY
37 //
38
39 #define MEMORY_MAP_SIGNATURE EFI_SIGNATURE_32('m','m','a','p')
40 typedef struct {
41 UINTN Signature;
42 LIST_ENTRY Link;
43 BOOLEAN FromPages;
44
45 EFI_MEMORY_TYPE Type;
46 UINT64 Start;
47 UINT64 End;
48
49 UINT64 VirtualStart;
50 UINT64 Attribute;
51 } MEMORY_MAP;
52
53 //
54 // Internal prototypes
55 //
56
57
58 /**
59 Internal function. Used by the pool functions to allocate pages
60 to back pool allocation requests.
61
62 @param PoolType The type of memory for the new pool pages
63 @param NumberOfPages No of pages to allocate
64 @param Alignment Bits to align.
65
66 @return The allocated memory, or NULL
67
68 **/
69 VOID *
70 CoreAllocatePoolPages (
71 IN EFI_MEMORY_TYPE PoolType,
72 IN UINTN NumberOfPages,
73 IN UINTN Alignment
74 );
75
76
77
78 /**
79 Internal function. Frees pool pages allocated via AllocatePoolPages ()
80
81 @param Memory The base address to free
82 @param NumberOfPages The number of pages to free
83
84 **/
85 VOID
86 CoreFreePoolPages (
87 IN EFI_PHYSICAL_ADDRESS Memory,
88 IN UINTN NumberOfPages
89 );
90
91
92
93 /**
94 Internal function to allocate pool of a particular type.
95 Caller must have the memory lock held
96
97 @param PoolType Type of pool to allocate
98 @param Size The amount of pool to allocate
99
100 @return The allocate pool, or NULL
101
102 **/
103 VOID *
104 CoreAllocatePoolI (
105 IN EFI_MEMORY_TYPE PoolType,
106 IN UINTN Size
107 );
108
109
110
111 /**
112 Internal function to free a pool entry.
113 Caller must have the memory lock held
114
115 @param Buffer The allocated pool entry to free
116
117 @retval EFI_INVALID_PARAMETER Buffer not valid
118 @retval EFI_SUCCESS Buffer successfully freed.
119
120 **/
121 EFI_STATUS
122 CoreFreePoolI (
123 IN VOID *Buffer
124 );
125
126
127
128 /**
129 Enter critical section by gaining lock on gMemoryLock.
130
131 **/
132 VOID
133 CoreAcquireMemoryLock (
134 VOID
135 );
136
137
138 /**
139 Exit critical section by releasing lock on gMemoryLock.
140
141 **/
142 VOID
143 CoreReleaseMemoryLock (
144 VOID
145 );
146
147
148 //
149 // Internal Global data
150 //
151
152 extern EFI_LOCK gMemoryLock;
153 extern LIST_ENTRY gMemoryMap;
154 extern LIST_ENTRY mGcdMemorySpaceMap;
155 #endif