]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Library/PiSmmCoreMemoryAllocationLib/PiSmmCoreMemoryAllocationServices.h
MdeModulePkg PiSmmCoreMemoryAllocationLib: Get SMRAM ranges
[mirror_edk2.git] / MdeModulePkg / Library / PiSmmCoreMemoryAllocationLib / PiSmmCoreMemoryAllocationServices.h
1 /** @file
2 Contains function prototypes for Memory Services in the SMM Core.
3
4 This header file borrows the PiSmmCore Memory Allocation services as the primitive
5 for memory allocation.
6
7 Copyright (c) 2008 - 2015, Intel Corporation. All rights reserved.<BR>
8 This program and the accompanying materials
9 are licensed and made available under the terms and conditions of the BSD License
10 which accompanies this distribution. The full text of the license may be found at
11 http://opensource.org/licenses/bsd-license.php
12
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15
16 **/
17
18 #ifndef _PI_SMM_CORE_MEMORY_ALLOCATION_SERVICES_H_
19 #define _PI_SMM_CORE_MEMORY_ALLOCATION_SERVICES_H_
20
21 //
22 // It should be aligned with the definition in PiSmmCore.
23 //
24 typedef struct {
25 UINTN Signature;
26
27 ///
28 /// The ImageHandle passed into the entry point of the SMM IPL. This ImageHandle
29 /// is used by the SMM Core to fill in the ParentImageHandle field of the Loaded
30 /// Image Protocol for each SMM Driver that is dispatched by the SMM Core.
31 ///
32 EFI_HANDLE SmmIplImageHandle;
33
34 ///
35 /// The number of SMRAM ranges passed from the SMM IPL to the SMM Core. The SMM
36 /// Core uses these ranges of SMRAM to initialize the SMM Core memory manager.
37 ///
38 UINTN SmramRangeCount;
39
40 ///
41 /// A table of SMRAM ranges passed from the SMM IPL to the SMM Core. The SMM
42 /// Core uses these ranges of SMRAM to initialize the SMM Core memory manager.
43 ///
44 EFI_SMRAM_DESCRIPTOR *SmramRanges;
45
46 ///
47 /// The SMM Foundation Entry Point. The SMM Core fills in this field when the
48 /// SMM Core is initialized. The SMM IPL is responsbile for registering this entry
49 /// point with the SMM Configuration Protocol. The SMM Configuration Protocol may
50 /// not be available at the time the SMM IPL and SMM Core are started, so the SMM IPL
51 /// sets up a protocol notification on the SMM Configuration Protocol and registers
52 /// the SMM Foundation Entry Point as soon as the SMM Configuration Protocol is
53 /// available.
54 ///
55 EFI_SMM_ENTRY_POINT SmmEntryPoint;
56
57 ///
58 /// Boolean flag set to TRUE while an SMI is being processed by the SMM Core.
59 ///
60 BOOLEAN SmmEntryPointRegistered;
61
62 ///
63 /// Boolean flag set to TRUE while an SMI is being processed by the SMM Core.
64 ///
65 BOOLEAN InSmm;
66
67 ///
68 /// This field is set by the SMM Core then the SMM Core is initialized. This field is
69 /// used by the SMM Base 2 Protocol and SMM Communication Protocol implementations in
70 /// the SMM IPL.
71 ///
72 EFI_SMM_SYSTEM_TABLE2 *Smst;
73
74 ///
75 /// This field is used by the SMM Communicatioon Protocol to pass a buffer into
76 /// a software SMI handler and for the software SMI handler to pass a buffer back to
77 /// the caller of the SMM Communication Protocol.
78 ///
79 VOID *CommunicationBuffer;
80
81 ///
82 /// This field is used by the SMM Communicatioon Protocol to pass the size of a buffer,
83 /// in bytes, into a software SMI handler and for the software SMI handler to pass the
84 /// size, in bytes, of a buffer back to the caller of the SMM Communication Protocol.
85 ///
86 UINTN BufferSize;
87
88 ///
89 /// This field is used by the SMM Communication Protocol to pass the return status from
90 /// a software SMI handler back to the caller of the SMM Communication Protocol.
91 ///
92 EFI_STATUS ReturnStatus;
93
94 EFI_PHYSICAL_ADDRESS PiSmmCoreImageBase;
95 UINT64 PiSmmCoreImageSize;
96 EFI_PHYSICAL_ADDRESS PiSmmCoreEntryPoint;
97
98 UINTN FullSmramRangeCount;
99 EFI_SMRAM_DESCRIPTOR *FullSmramRanges;
100 } SMM_CORE_PRIVATE_DATA;
101
102 /**
103 Called to initialize the memory service.
104
105 @param SmramRangeCount Number of SMRAM Regions
106 @param SmramRanges Pointer to SMRAM Descriptors
107
108 **/
109 VOID
110 SmmInitializeMemoryServices (
111 IN UINTN SmramRangeCount,
112 IN EFI_SMRAM_DESCRIPTOR *SmramRanges
113 );
114
115 /**
116 Allocates pages from the memory map.
117
118 @param Type The type of allocation to perform
119 @param MemoryType The type of memory to turn the allocated pages
120 into
121 @param NumberOfPages The number of pages to allocate
122 @param Memory A pointer to receive the base allocated memory
123 address
124
125 @retval EFI_INVALID_PARAMETER Parameters violate checking rules defined in spec.
126 @retval EFI_NOT_FOUND Could not allocate pages match the requirement.
127 @retval EFI_OUT_OF_RESOURCES No enough pages to allocate.
128 @retval EFI_SUCCESS Pages successfully allocated.
129
130 **/
131 EFI_STATUS
132 EFIAPI
133 SmmAllocatePages (
134 IN EFI_ALLOCATE_TYPE Type,
135 IN EFI_MEMORY_TYPE MemoryType,
136 IN UINTN NumberOfPages,
137 OUT EFI_PHYSICAL_ADDRESS *Memory
138 );
139
140 /**
141 Frees previous allocated pages.
142
143 @param Memory Base address of memory being freed
144 @param NumberOfPages The number of pages to free
145
146 @retval EFI_NOT_FOUND Could not find the entry that covers the range
147 @retval EFI_INVALID_PARAMETER Address not aligned
148 @return EFI_SUCCESS Pages successfully freed.
149
150 **/
151 EFI_STATUS
152 EFIAPI
153 SmmFreePages (
154 IN EFI_PHYSICAL_ADDRESS Memory,
155 IN UINTN NumberOfPages
156 );
157
158 /**
159 Allocate pool of a particular type.
160
161 @param PoolType Type of pool to allocate
162 @param Size The amount of pool to allocate
163 @param Buffer The address to return a pointer to the allocated
164 pool
165
166 @retval EFI_INVALID_PARAMETER PoolType not valid
167 @retval EFI_OUT_OF_RESOURCES Size exceeds max pool size or allocation failed.
168 @retval EFI_SUCCESS Pool successfully allocated.
169
170 **/
171 EFI_STATUS
172 EFIAPI
173 SmmAllocatePool (
174 IN EFI_MEMORY_TYPE PoolType,
175 IN UINTN Size,
176 OUT VOID **Buffer
177 );
178
179 /**
180 Frees pool.
181
182 @param Buffer The allocated pool entry to free
183
184 @retval EFI_INVALID_PARAMETER Buffer is not a valid value.
185 @retval EFI_SUCCESS Pool successfully freed.
186
187 **/
188 EFI_STATUS
189 EFIAPI
190 SmmFreePool (
191 IN VOID *Buffer
192 );
193
194 #endif