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