]>
Commit | Line | Data |
---|---|---|
e42e9404 | 1 | /** @file\r |
2 | The internal header file includes the common header files, defines\r | |
3 | internal structure and functions used by SmmCore module.\r | |
4 | \r | |
e524f680 | 5 | Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>\r |
e42e9404 | 6 | This program and the accompanying materials are licensed and made available \r |
7 | under the terms and conditions of the BSD License which accompanies this \r | |
8 | distribution. The full text of the license may be found at \r | |
9 | http://opensource.org/licenses/bsd-license.php \r | |
10 | \r | |
11 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r | |
12 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r | |
13 | \r | |
14 | **/\r | |
15 | \r | |
16 | #ifndef _SMM_CORE_H_\r | |
17 | #define _SMM_CORE_H_\r | |
18 | \r | |
19 | #include <PiSmm.h>\r | |
20 | \r | |
21 | #include <Protocol/DxeSmmReadyToLock.h>\r | |
22 | #include <Protocol/SmmReadyToLock.h>\r | |
46ece1ff | 23 | #include <Protocol/SmmEndOfDxe.h>\r |
e42e9404 | 24 | #include <Protocol/CpuIo2.h>\r |
25 | #include <Protocol/SmmCommunication.h>\r | |
26 | #include <Protocol/SmmAccess2.h>\r | |
27 | #include <Protocol/FirmwareVolume2.h> \r | |
28 | #include <Protocol/LoadedImage.h> \r | |
29 | #include <Protocol/DevicePath.h> \r | |
30 | #include <Protocol/Security.h> \r | |
bc2dfdbc | 31 | #include <Protocol/Security2.h>\r |
53ec4d7f SZ |
32 | #include <Protocol/SmmExitBootServices.h>\r |
33 | #include <Protocol/SmmLegacyBoot.h>\r | |
34 | #include <Protocol/SmmReadyToBoot.h>\r | |
e42e9404 | 35 | \r |
36 | #include <Guid/Apriori.h>\r | |
37 | #include <Guid/EventGroup.h>\r | |
38 | #include <Guid/EventLegacyBios.h>\r | |
84edd20b | 39 | #include <Guid/MemoryProfile.h>\r |
94a1bc12 | 40 | #include <Guid/LoadModuleAtFixedAddress.h>\r |
e42e9404 | 41 | \r |
42 | #include <Library/BaseLib.h>\r | |
43 | #include <Library/BaseMemoryLib.h>\r | |
44 | #include <Library/PeCoffLib.h>\r | |
e524f680 | 45 | #include <Library/PeCoffGetEntryPointLib.h>\r |
e42e9404 | 46 | #include <Library/CacheMaintenanceLib.h>\r |
47 | #include <Library/DebugLib.h>\r | |
48 | #include <Library/ReportStatusCodeLib.h>\r | |
49 | #include <Library/MemoryAllocationLib.h>\r | |
50 | #include <Library/DevicePathLib.h> \r | |
51 | #include <Library/UefiLib.h> \r | |
3c447c27 | 52 | #include <Library/UefiBootServicesTableLib.h>\r |
53 | #include <Library/PcdLib.h>\r | |
495797c5 | 54 | #include <Library/SmmCorePlatformHookLib.h>\r |
55 | #include <Library/PerformanceLib.h>\r | |
c2cb08df | 56 | #include <Library/TimerLib.h>\r |
3720ee6d | 57 | #include <Library/HobLib.h>\r |
842b1242 | 58 | #include <Library/SmmMemLib.h>\r |
e42e9404 | 59 | \r |
60 | #include "PiSmmCorePrivateData.h"\r | |
61 | \r | |
62 | //\r | |
63 | // Used to build a table of SMI Handlers that the SMM Core registers\r | |
64 | //\r | |
65 | typedef struct {\r | |
66 | EFI_SMM_HANDLER_ENTRY_POINT2 Handler;\r | |
67 | EFI_GUID *HandlerType;\r | |
68 | EFI_HANDLE DispatchHandle;\r | |
69 | BOOLEAN UnRegister;\r | |
70 | } SMM_CORE_SMI_HANDLERS;\r | |
71 | \r | |
72 | //\r | |
73 | // Structure for recording the state of an SMM Driver\r | |
74 | //\r | |
75 | #define EFI_SMM_DRIVER_ENTRY_SIGNATURE SIGNATURE_32('s', 'd','r','v')\r | |
76 | \r | |
77 | typedef struct {\r | |
78 | UINTN Signature;\r | |
79 | LIST_ENTRY Link; // mDriverList\r | |
80 | \r | |
81 | LIST_ENTRY ScheduledLink; // mScheduledQueue\r | |
82 | \r | |
83 | EFI_HANDLE FvHandle;\r | |
84 | EFI_GUID FileName;\r | |
85 | EFI_DEVICE_PATH_PROTOCOL *FvFileDevicePath;\r | |
86 | EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv;\r | |
87 | \r | |
88 | VOID *Depex;\r | |
89 | UINTN DepexSize;\r | |
90 | \r | |
91 | BOOLEAN Before;\r | |
92 | BOOLEAN After;\r | |
93 | EFI_GUID BeforeAfterGuid;\r | |
94 | \r | |
95 | BOOLEAN Dependent;\r | |
e42e9404 | 96 | BOOLEAN Scheduled;\r |
e42e9404 | 97 | BOOLEAN Initialized;\r |
98 | BOOLEAN DepexProtocolError;\r | |
99 | \r | |
100 | EFI_HANDLE ImageHandle;\r | |
101 | EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;\r | |
102 | //\r | |
103 | // Image EntryPoint in SMRAM\r | |
104 | //\r | |
105 | PHYSICAL_ADDRESS ImageEntryPoint;\r | |
106 | //\r | |
107 | // Image Buffer in SMRAM \r | |
108 | //\r | |
109 | PHYSICAL_ADDRESS ImageBuffer;\r | |
110 | //\r | |
111 | // Image Page Number\r | |
112 | //\r | |
113 | UINTN NumberOfPage;\r | |
285a682c JY |
114 | EFI_HANDLE SmmImageHandle;\r |
115 | EFI_LOADED_IMAGE_PROTOCOL SmmLoadedImage;\r | |
e42e9404 | 116 | } EFI_SMM_DRIVER_ENTRY;\r |
117 | \r | |
118 | #define EFI_HANDLE_SIGNATURE SIGNATURE_32('h','n','d','l')\r | |
119 | \r | |
120 | ///\r | |
121 | /// IHANDLE - contains a list of protocol handles\r | |
122 | ///\r | |
123 | typedef struct {\r | |
124 | UINTN Signature;\r | |
125 | /// All handles list of IHANDLE\r | |
126 | LIST_ENTRY AllHandles;\r | |
127 | /// List of PROTOCOL_INTERFACE's for this handle\r | |
128 | LIST_ENTRY Protocols;\r | |
129 | UINTN LocateRequest;\r | |
130 | } IHANDLE;\r | |
131 | \r | |
132 | #define ASSERT_IS_HANDLE(a) ASSERT((a)->Signature == EFI_HANDLE_SIGNATURE)\r | |
133 | \r | |
134 | #define PROTOCOL_ENTRY_SIGNATURE SIGNATURE_32('p','r','t','e')\r | |
135 | \r | |
136 | ///\r | |
137 | /// PROTOCOL_ENTRY - each different protocol has 1 entry in the protocol\r | |
138 | /// database. Each handler that supports this protocol is listed, along\r | |
139 | /// with a list of registered notifies.\r | |
140 | ///\r | |
141 | typedef struct {\r | |
142 | UINTN Signature;\r | |
143 | /// Link Entry inserted to mProtocolDatabase\r | |
144 | LIST_ENTRY AllEntries;\r | |
145 | /// ID of the protocol\r | |
146 | EFI_GUID ProtocolID;\r | |
147 | /// All protocol interfaces\r | |
148 | LIST_ENTRY Protocols;\r | |
149 | /// Registerd notification handlers\r | |
150 | LIST_ENTRY Notify;\r | |
151 | } PROTOCOL_ENTRY;\r | |
152 | \r | |
153 | #define PROTOCOL_INTERFACE_SIGNATURE SIGNATURE_32('p','i','f','c')\r | |
154 | \r | |
155 | ///\r | |
156 | /// PROTOCOL_INTERFACE - each protocol installed on a handle is tracked\r | |
157 | /// with a protocol interface structure\r | |
158 | ///\r | |
159 | typedef struct {\r | |
160 | UINTN Signature;\r | |
161 | /// Link on IHANDLE.Protocols\r | |
162 | LIST_ENTRY Link;\r | |
163 | /// Back pointer\r | |
164 | IHANDLE *Handle;\r | |
165 | /// Link on PROTOCOL_ENTRY.Protocols\r | |
166 | LIST_ENTRY ByProtocol;\r | |
167 | /// The protocol ID\r | |
168 | PROTOCOL_ENTRY *Protocol;\r | |
169 | /// The interface value\r | |
170 | VOID *Interface;\r | |
171 | } PROTOCOL_INTERFACE;\r | |
172 | \r | |
173 | #define PROTOCOL_NOTIFY_SIGNATURE SIGNATURE_32('p','r','t','n')\r | |
174 | \r | |
175 | ///\r | |
176 | /// PROTOCOL_NOTIFY - used for each register notification for a protocol\r | |
177 | ///\r | |
178 | typedef struct {\r | |
179 | UINTN Signature;\r | |
180 | PROTOCOL_ENTRY *Protocol;\r | |
181 | /// All notifications for this protocol\r | |
182 | LIST_ENTRY Link;\r | |
183 | /// Notification function\r | |
184 | EFI_SMM_NOTIFY_FN Function;\r | |
185 | /// Last position notified\r | |
186 | LIST_ENTRY *Position;\r | |
187 | } PROTOCOL_NOTIFY;\r | |
188 | \r | |
189 | //\r | |
190 | // SMM Core Global Variables\r | |
191 | //\r | |
192 | extern SMM_CORE_PRIVATE_DATA *gSmmCorePrivate;\r | |
193 | extern EFI_SMM_SYSTEM_TABLE2 gSmmCoreSmst;\r | |
194 | extern LIST_ENTRY gHandleList;\r | |
3c447c27 | 195 | extern EFI_PHYSICAL_ADDRESS gLoadModuleAtFixAddressSmramBase;\r |
e42e9404 | 196 | \r |
197 | /**\r | |
198 | Called to initialize the memory service.\r | |
199 | \r | |
200 | @param SmramRangeCount Number of SMRAM Regions\r | |
201 | @param SmramRanges Pointer to SMRAM Descriptors\r | |
202 | \r | |
203 | **/\r | |
204 | VOID\r | |
205 | SmmInitializeMemoryServices (\r | |
206 | IN UINTN SmramRangeCount,\r | |
207 | IN EFI_SMRAM_DESCRIPTOR *SmramRanges\r | |
208 | );\r | |
209 | \r | |
210 | /**\r | |
211 | The SmmInstallConfigurationTable() function is used to maintain the list\r | |
212 | of configuration tables that are stored in the System Management System\r | |
213 | Table. The list is stored as an array of (GUID, Pointer) pairs. The list\r | |
214 | must be allocated from pool memory with PoolType set to EfiRuntimeServicesData.\r | |
215 | \r | |
216 | @param SystemTable A pointer to the SMM System Table (SMST).\r | |
217 | @param Guid A pointer to the GUID for the entry to add, update, or remove.\r | |
218 | @param Table A pointer to the buffer of the table to add.\r | |
219 | @param TableSize The size of the table to install.\r | |
220 | \r | |
221 | @retval EFI_SUCCESS The (Guid, Table) pair was added, updated, or removed.\r | |
222 | @retval EFI_INVALID_PARAMETER Guid is not valid.\r | |
223 | @retval EFI_NOT_FOUND An attempt was made to delete a non-existent entry.\r | |
224 | @retval EFI_OUT_OF_RESOURCES There is not enough memory available to complete the operation.\r | |
225 | \r | |
226 | **/\r | |
227 | EFI_STATUS\r | |
228 | EFIAPI\r | |
229 | SmmInstallConfigurationTable (\r | |
230 | IN CONST EFI_SMM_SYSTEM_TABLE2 *SystemTable,\r | |
231 | IN CONST EFI_GUID *Guid,\r | |
232 | IN VOID *Table,\r | |
233 | IN UINTN TableSize\r | |
234 | );\r | |
235 | \r | |
236 | /**\r | |
237 | Wrapper function to SmmInstallProtocolInterfaceNotify. This is the public API which\r | |
238 | Calls the private one which contains a BOOLEAN parameter for notifications\r | |
239 | \r | |
240 | @param UserHandle The handle to install the protocol handler on,\r | |
241 | or NULL if a new handle is to be allocated\r | |
242 | @param Protocol The protocol to add to the handle\r | |
243 | @param InterfaceType Indicates whether Interface is supplied in\r | |
244 | native form.\r | |
245 | @param Interface The interface for the protocol being added\r | |
246 | \r | |
247 | @return Status code\r | |
248 | \r | |
249 | **/\r | |
250 | EFI_STATUS\r | |
251 | EFIAPI\r | |
252 | SmmInstallProtocolInterface (\r | |
253 | IN OUT EFI_HANDLE *UserHandle,\r | |
254 | IN EFI_GUID *Protocol,\r | |
255 | IN EFI_INTERFACE_TYPE InterfaceType,\r | |
256 | IN VOID *Interface\r | |
257 | );\r | |
258 | \r | |
259 | /**\r | |
260 | Allocates pages from the memory map.\r | |
261 | \r | |
262 | @param Type The type of allocation to perform\r | |
263 | @param MemoryType The type of memory to turn the allocated pages\r | |
264 | into\r | |
265 | @param NumberOfPages The number of pages to allocate\r | |
266 | @param Memory A pointer to receive the base allocated memory\r | |
267 | address\r | |
268 | \r | |
269 | @retval EFI_INVALID_PARAMETER Parameters violate checking rules defined in spec.\r | |
270 | @retval EFI_NOT_FOUND Could not allocate pages match the requirement.\r | |
271 | @retval EFI_OUT_OF_RESOURCES No enough pages to allocate.\r | |
272 | @retval EFI_SUCCESS Pages successfully allocated.\r | |
273 | \r | |
274 | **/\r | |
275 | EFI_STATUS\r | |
276 | EFIAPI\r | |
277 | SmmAllocatePages (\r | |
278 | IN EFI_ALLOCATE_TYPE Type,\r | |
279 | IN EFI_MEMORY_TYPE MemoryType,\r | |
280 | IN UINTN NumberOfPages,\r | |
281 | OUT EFI_PHYSICAL_ADDRESS *Memory\r | |
282 | );\r | |
283 | \r | |
84edd20b SZ |
284 | /**\r |
285 | Allocates pages from the memory map.\r | |
286 | \r | |
287 | @param Type The type of allocation to perform\r | |
288 | @param MemoryType The type of memory to turn the allocated pages\r | |
289 | into\r | |
290 | @param NumberOfPages The number of pages to allocate\r | |
291 | @param Memory A pointer to receive the base allocated memory\r | |
292 | address\r | |
293 | \r | |
294 | @retval EFI_INVALID_PARAMETER Parameters violate checking rules defined in spec.\r | |
295 | @retval EFI_NOT_FOUND Could not allocate pages match the requirement.\r | |
296 | @retval EFI_OUT_OF_RESOURCES No enough pages to allocate.\r | |
297 | @retval EFI_SUCCESS Pages successfully allocated.\r | |
298 | \r | |
299 | **/\r | |
300 | EFI_STATUS\r | |
301 | EFIAPI\r | |
302 | SmmInternalAllocatePages (\r | |
303 | IN EFI_ALLOCATE_TYPE Type,\r | |
304 | IN EFI_MEMORY_TYPE MemoryType,\r | |
305 | IN UINTN NumberOfPages,\r | |
306 | OUT EFI_PHYSICAL_ADDRESS *Memory\r | |
307 | );\r | |
308 | \r | |
e42e9404 | 309 | /**\r |
310 | Frees previous allocated pages.\r | |
311 | \r | |
312 | @param Memory Base address of memory being freed\r | |
313 | @param NumberOfPages The number of pages to free\r | |
314 | \r | |
315 | @retval EFI_NOT_FOUND Could not find the entry that covers the range\r | |
ddfae264 | 316 | @retval EFI_INVALID_PARAMETER Address not aligned, Address is zero or NumberOfPages is zero.\r |
e42e9404 | 317 | @return EFI_SUCCESS Pages successfully freed.\r |
318 | \r | |
319 | **/\r | |
320 | EFI_STATUS\r | |
321 | EFIAPI\r | |
322 | SmmFreePages (\r | |
323 | IN EFI_PHYSICAL_ADDRESS Memory,\r | |
324 | IN UINTN NumberOfPages\r | |
325 | );\r | |
326 | \r | |
84edd20b SZ |
327 | /**\r |
328 | Frees previous allocated pages.\r | |
329 | \r | |
330 | @param Memory Base address of memory being freed\r | |
331 | @param NumberOfPages The number of pages to free\r | |
332 | \r | |
333 | @retval EFI_NOT_FOUND Could not find the entry that covers the range\r | |
ddfae264 | 334 | @retval EFI_INVALID_PARAMETER Address not aligned, Address is zero or NumberOfPages is zero.\r |
84edd20b SZ |
335 | @return EFI_SUCCESS Pages successfully freed.\r |
336 | \r | |
337 | **/\r | |
338 | EFI_STATUS\r | |
339 | EFIAPI\r | |
340 | SmmInternalFreePages (\r | |
341 | IN EFI_PHYSICAL_ADDRESS Memory,\r | |
342 | IN UINTN NumberOfPages\r | |
343 | );\r | |
344 | \r | |
e42e9404 | 345 | /**\r |
346 | Allocate pool of a particular type.\r | |
347 | \r | |
348 | @param PoolType Type of pool to allocate\r | |
349 | @param Size The amount of pool to allocate\r | |
350 | @param Buffer The address to return a pointer to the allocated\r | |
351 | pool\r | |
352 | \r | |
353 | @retval EFI_INVALID_PARAMETER PoolType not valid\r | |
354 | @retval EFI_OUT_OF_RESOURCES Size exceeds max pool size or allocation failed.\r | |
355 | @retval EFI_SUCCESS Pool successfully allocated.\r | |
356 | \r | |
357 | **/\r | |
358 | EFI_STATUS\r | |
359 | EFIAPI\r | |
360 | SmmAllocatePool (\r | |
361 | IN EFI_MEMORY_TYPE PoolType,\r | |
362 | IN UINTN Size,\r | |
363 | OUT VOID **Buffer\r | |
364 | );\r | |
365 | \r | |
84edd20b SZ |
366 | /**\r |
367 | Allocate pool of a particular type.\r | |
368 | \r | |
369 | @param PoolType Type of pool to allocate\r | |
370 | @param Size The amount of pool to allocate\r | |
371 | @param Buffer The address to return a pointer to the allocated\r | |
372 | pool\r | |
373 | \r | |
374 | @retval EFI_INVALID_PARAMETER PoolType not valid\r | |
375 | @retval EFI_OUT_OF_RESOURCES Size exceeds max pool size or allocation failed.\r | |
376 | @retval EFI_SUCCESS Pool successfully allocated.\r | |
377 | \r | |
378 | **/\r | |
379 | EFI_STATUS\r | |
380 | EFIAPI\r | |
381 | SmmInternalAllocatePool (\r | |
382 | IN EFI_MEMORY_TYPE PoolType,\r | |
383 | IN UINTN Size,\r | |
384 | OUT VOID **Buffer\r | |
385 | );\r | |
386 | \r | |
e42e9404 | 387 | /**\r |
388 | Frees pool.\r | |
389 | \r | |
390 | @param Buffer The allocated pool entry to free\r | |
391 | \r | |
392 | @retval EFI_INVALID_PARAMETER Buffer is not a valid value.\r | |
393 | @retval EFI_SUCCESS Pool successfully freed.\r | |
394 | \r | |
395 | **/\r | |
396 | EFI_STATUS\r | |
397 | EFIAPI\r | |
398 | SmmFreePool (\r | |
399 | IN VOID *Buffer\r | |
400 | );\r | |
401 | \r | |
84edd20b SZ |
402 | /**\r |
403 | Frees pool.\r | |
404 | \r | |
405 | @param Buffer The allocated pool entry to free\r | |
406 | \r | |
407 | @retval EFI_INVALID_PARAMETER Buffer is not a valid value.\r | |
408 | @retval EFI_SUCCESS Pool successfully freed.\r | |
409 | \r | |
410 | **/\r | |
411 | EFI_STATUS\r | |
412 | EFIAPI\r | |
413 | SmmInternalFreePool (\r | |
414 | IN VOID *Buffer\r | |
415 | );\r | |
416 | \r | |
e42e9404 | 417 | /**\r |
418 | Installs a protocol interface into the boot services environment.\r | |
419 | \r | |
420 | @param UserHandle The handle to install the protocol handler on,\r | |
421 | or NULL if a new handle is to be allocated\r | |
422 | @param Protocol The protocol to add to the handle\r | |
423 | @param InterfaceType Indicates whether Interface is supplied in\r | |
424 | native form.\r | |
425 | @param Interface The interface for the protocol being added\r | |
426 | @param Notify indicates whether notify the notification list\r | |
427 | for this protocol\r | |
428 | \r | |
429 | @retval EFI_INVALID_PARAMETER Invalid parameter\r | |
430 | @retval EFI_OUT_OF_RESOURCES No enough buffer to allocate\r | |
431 | @retval EFI_SUCCESS Protocol interface successfully installed\r | |
432 | \r | |
433 | **/\r | |
434 | EFI_STATUS\r | |
435 | SmmInstallProtocolInterfaceNotify (\r | |
436 | IN OUT EFI_HANDLE *UserHandle,\r | |
437 | IN EFI_GUID *Protocol,\r | |
438 | IN EFI_INTERFACE_TYPE InterfaceType,\r | |
439 | IN VOID *Interface,\r | |
440 | IN BOOLEAN Notify\r | |
441 | );\r | |
442 | \r | |
443 | /**\r | |
444 | Uninstalls all instances of a protocol:interfacer from a handle.\r | |
445 | If the last protocol interface is remove from the handle, the\r | |
446 | handle is freed.\r | |
447 | \r | |
448 | @param UserHandle The handle to remove the protocol handler from\r | |
449 | @param Protocol The protocol, of protocol:interface, to remove\r | |
450 | @param Interface The interface, of protocol:interface, to remove\r | |
451 | \r | |
452 | @retval EFI_INVALID_PARAMETER Protocol is NULL.\r | |
453 | @retval EFI_SUCCESS Protocol interface successfully uninstalled.\r | |
454 | \r | |
455 | **/\r | |
456 | EFI_STATUS\r | |
457 | EFIAPI\r | |
458 | SmmUninstallProtocolInterface (\r | |
459 | IN EFI_HANDLE UserHandle,\r | |
460 | IN EFI_GUID *Protocol,\r | |
461 | IN VOID *Interface\r | |
462 | );\r | |
463 | \r | |
464 | /**\r | |
465 | Queries a handle to determine if it supports a specified protocol.\r | |
466 | \r | |
467 | @param UserHandle The handle being queried.\r | |
468 | @param Protocol The published unique identifier of the protocol.\r | |
469 | @param Interface Supplies the address where a pointer to the\r | |
470 | corresponding Protocol Interface is returned.\r | |
471 | \r | |
472 | @return The requested protocol interface for the handle\r | |
473 | \r | |
474 | **/\r | |
475 | EFI_STATUS\r | |
476 | EFIAPI\r | |
477 | SmmHandleProtocol (\r | |
478 | IN EFI_HANDLE UserHandle,\r | |
479 | IN EFI_GUID *Protocol,\r | |
480 | OUT VOID **Interface\r | |
481 | );\r | |
482 | \r | |
483 | /**\r | |
484 | Add a new protocol notification record for the request protocol.\r | |
485 | \r | |
486 | @param Protocol The requested protocol to add the notify\r | |
487 | registration\r | |
488 | @param Function Points to the notification function\r | |
489 | @param Registration Returns the registration record\r | |
490 | \r | |
491 | @retval EFI_INVALID_PARAMETER Invalid parameter\r | |
492 | @retval EFI_SUCCESS Successfully returned the registration record\r | |
493 | that has been added\r | |
494 | \r | |
495 | **/\r | |
496 | EFI_STATUS\r | |
497 | EFIAPI\r | |
498 | SmmRegisterProtocolNotify (\r | |
499 | IN CONST EFI_GUID *Protocol,\r | |
500 | IN EFI_SMM_NOTIFY_FN Function,\r | |
501 | OUT VOID **Registration\r | |
502 | );\r | |
503 | \r | |
504 | /**\r | |
505 | Locates the requested handle(s) and returns them in Buffer.\r | |
506 | \r | |
507 | @param SearchType The type of search to perform to locate the\r | |
508 | handles\r | |
509 | @param Protocol The protocol to search for\r | |
510 | @param SearchKey Dependant on SearchType\r | |
511 | @param BufferSize On input the size of Buffer. On output the\r | |
512 | size of data returned.\r | |
513 | @param Buffer The buffer to return the results in\r | |
514 | \r | |
515 | @retval EFI_BUFFER_TOO_SMALL Buffer too small, required buffer size is\r | |
516 | returned in BufferSize.\r | |
517 | @retval EFI_INVALID_PARAMETER Invalid parameter\r | |
518 | @retval EFI_SUCCESS Successfully found the requested handle(s) and\r | |
519 | returns them in Buffer.\r | |
520 | \r | |
521 | **/\r | |
522 | EFI_STATUS\r | |
523 | EFIAPI\r | |
524 | SmmLocateHandle (\r | |
525 | IN EFI_LOCATE_SEARCH_TYPE SearchType,\r | |
526 | IN EFI_GUID *Protocol OPTIONAL,\r | |
527 | IN VOID *SearchKey OPTIONAL,\r | |
528 | IN OUT UINTN *BufferSize,\r | |
529 | OUT EFI_HANDLE *Buffer\r | |
530 | );\r | |
531 | \r | |
532 | /**\r | |
533 | Return the first Protocol Interface that matches the Protocol GUID. If\r | |
534 | Registration is pasased in return a Protocol Instance that was just add\r | |
535 | to the system. If Retistration is NULL return the first Protocol Interface\r | |
536 | you find.\r | |
537 | \r | |
538 | @param Protocol The protocol to search for\r | |
539 | @param Registration Optional Registration Key returned from\r | |
540 | RegisterProtocolNotify()\r | |
541 | @param Interface Return the Protocol interface (instance).\r | |
542 | \r | |
543 | @retval EFI_SUCCESS If a valid Interface is returned\r | |
544 | @retval EFI_INVALID_PARAMETER Invalid parameter\r | |
545 | @retval EFI_NOT_FOUND Protocol interface not found\r | |
546 | \r | |
547 | **/\r | |
548 | EFI_STATUS\r | |
549 | EFIAPI\r | |
550 | SmmLocateProtocol (\r | |
551 | IN EFI_GUID *Protocol,\r | |
552 | IN VOID *Registration OPTIONAL,\r | |
553 | OUT VOID **Interface\r | |
554 | );\r | |
555 | \r | |
285a682c JY |
556 | /**\r |
557 | Function returns an array of handles that support the requested protocol\r | |
558 | in a buffer allocated from pool. This is a version of SmmLocateHandle()\r | |
559 | that allocates a buffer for the caller.\r | |
560 | \r | |
561 | @param SearchType Specifies which handle(s) are to be returned.\r | |
562 | @param Protocol Provides the protocol to search by. This\r | |
563 | parameter is only valid for SearchType\r | |
564 | ByProtocol.\r | |
565 | @param SearchKey Supplies the search key depending on the\r | |
566 | SearchType.\r | |
567 | @param NumberHandles The number of handles returned in Buffer.\r | |
568 | @param Buffer A pointer to the buffer to return the requested\r | |
569 | array of handles that support Protocol.\r | |
570 | \r | |
571 | @retval EFI_SUCCESS The result array of handles was returned.\r | |
572 | @retval EFI_NOT_FOUND No handles match the search.\r | |
573 | @retval EFI_OUT_OF_RESOURCES There is not enough pool memory to store the\r | |
574 | matching results.\r | |
575 | @retval EFI_INVALID_PARAMETER One or more paramters are not valid.\r | |
576 | \r | |
577 | **/\r | |
578 | EFI_STATUS\r | |
579 | EFIAPI\r | |
580 | SmmLocateHandleBuffer (\r | |
581 | IN EFI_LOCATE_SEARCH_TYPE SearchType,\r | |
582 | IN EFI_GUID *Protocol OPTIONAL,\r | |
583 | IN VOID *SearchKey OPTIONAL,\r | |
584 | IN OUT UINTN *NumberHandles,\r | |
585 | OUT EFI_HANDLE **Buffer\r | |
586 | );\r | |
587 | \r | |
e42e9404 | 588 | /**\r |
589 | Manage SMI of a particular type.\r | |
590 | \r | |
591 | @param HandlerType Points to the handler type or NULL for root SMI handlers.\r | |
592 | @param Context Points to an optional context buffer.\r | |
593 | @param CommBuffer Points to the optional communication buffer.\r | |
594 | @param CommBufferSize Points to the size of the optional communication buffer.\r | |
595 | \r | |
596 | @retval EFI_SUCCESS Interrupt source was processed successfully but not quiesced.\r | |
597 | @retval EFI_INTERRUPT_PENDING One or more SMI sources could not be quiesced.\r | |
598 | @retval EFI_WARN_INTERRUPT_SOURCE_PENDING Interrupt source was not handled or quiesced.\r | |
599 | @retval EFI_WARN_INTERRUPT_SOURCE_QUIESCED Interrupt source was handled and quiesced.\r | |
600 | \r | |
601 | **/\r | |
602 | EFI_STATUS\r | |
603 | EFIAPI\r | |
604 | SmiManage (\r | |
605 | IN CONST EFI_GUID *HandlerType,\r | |
606 | IN CONST VOID *Context OPTIONAL,\r | |
607 | IN OUT VOID *CommBuffer OPTIONAL,\r | |
608 | IN OUT UINTN *CommBufferSize OPTIONAL\r | |
609 | );\r | |
610 | \r | |
611 | /**\r | |
612 | Registers a handler to execute within SMM.\r | |
613 | \r | |
614 | @param Handler Handler service funtion pointer.\r | |
615 | @param HandlerType Points to the handler type or NULL for root SMI handlers.\r | |
616 | @param DispatchHandle On return, contains a unique handle which can be used to later unregister the handler function.\r | |
617 | \r | |
618 | @retval EFI_SUCCESS Handler register success.\r | |
619 | @retval EFI_INVALID_PARAMETER Handler or DispatchHandle is NULL.\r | |
620 | \r | |
621 | **/\r | |
622 | EFI_STATUS\r | |
623 | EFIAPI\r | |
624 | SmiHandlerRegister (\r | |
625 | IN EFI_SMM_HANDLER_ENTRY_POINT2 Handler,\r | |
626 | IN CONST EFI_GUID *HandlerType OPTIONAL,\r | |
627 | OUT EFI_HANDLE *DispatchHandle\r | |
628 | );\r | |
629 | \r | |
630 | /**\r | |
631 | Unregister a handler in SMM.\r | |
632 | \r | |
633 | @param DispatchHandle The handle that was specified when the handler was registered.\r | |
634 | \r | |
635 | @retval EFI_SUCCESS Handler function was successfully unregistered.\r | |
636 | @retval EFI_INVALID_PARAMETER DispatchHandle does not refer to a valid handle.\r | |
637 | \r | |
638 | **/\r | |
639 | EFI_STATUS\r | |
640 | EFIAPI\r | |
641 | SmiHandlerUnRegister (\r | |
642 | IN EFI_HANDLE DispatchHandle\r | |
643 | );\r | |
644 | \r | |
645 | /**\r | |
646 | This function is the main entry point for an SMM handler dispatch\r | |
647 | or communicate-based callback.\r | |
648 | \r | |
649 | @param DispatchHandle The unique handle assigned to this handler by SmiHandlerRegister().\r | |
650 | @param Context Points to an optional handler context which was specified when the handler was registered.\r | |
651 | @param CommBuffer A pointer to a collection of data in memory that will\r | |
652 | be conveyed from a non-SMM environment into an SMM environment.\r | |
653 | @param CommBufferSize The size of the CommBuffer.\r | |
654 | \r | |
655 | @return Status Code\r | |
656 | \r | |
657 | **/\r | |
658 | EFI_STATUS\r | |
659 | EFIAPI\r | |
660 | SmmDriverDispatchHandler (\r | |
661 | IN EFI_HANDLE DispatchHandle,\r | |
662 | IN CONST VOID *Context, OPTIONAL\r | |
663 | IN OUT VOID *CommBuffer, OPTIONAL\r | |
664 | IN OUT UINTN *CommBufferSize OPTIONAL\r | |
665 | );\r | |
666 | \r | |
667 | /**\r | |
668 | This function is the main entry point for an SMM handler dispatch\r | |
669 | or communicate-based callback.\r | |
670 | \r | |
671 | @param DispatchHandle The unique handle assigned to this handler by SmiHandlerRegister().\r | |
672 | @param Context Points to an optional handler context which was specified when the handler was registered.\r | |
673 | @param CommBuffer A pointer to a collection of data in memory that will\r | |
674 | be conveyed from a non-SMM environment into an SMM environment.\r | |
675 | @param CommBufferSize The size of the CommBuffer.\r | |
676 | \r | |
677 | @return Status Code\r | |
678 | \r | |
679 | **/\r | |
680 | EFI_STATUS\r | |
681 | EFIAPI\r | |
682 | SmmLegacyBootHandler (\r | |
683 | IN EFI_HANDLE DispatchHandle,\r | |
684 | IN CONST VOID *Context, OPTIONAL\r | |
685 | IN OUT VOID *CommBuffer, OPTIONAL\r | |
686 | IN OUT UINTN *CommBufferSize OPTIONAL\r | |
687 | );\r | |
688 | \r | |
689 | /**\r | |
690 | This function is the main entry point for an SMM handler dispatch\r | |
691 | or communicate-based callback.\r | |
692 | \r | |
693 | @param DispatchHandle The unique handle assigned to this handler by SmiHandlerRegister().\r | |
694 | @param Context Points to an optional handler context which was specified when the handler was registered.\r | |
695 | @param CommBuffer A pointer to a collection of data in memory that will\r | |
696 | be conveyed from a non-SMM environment into an SMM environment.\r | |
697 | @param CommBufferSize The size of the CommBuffer.\r | |
698 | \r | |
699 | @return Status Code\r | |
700 | \r | |
701 | **/\r | |
702 | EFI_STATUS\r | |
703 | EFIAPI\r | |
704 | SmmReadyToLockHandler (\r | |
705 | IN EFI_HANDLE DispatchHandle,\r | |
706 | IN CONST VOID *Context, OPTIONAL\r | |
707 | IN OUT VOID *CommBuffer, OPTIONAL\r | |
708 | IN OUT UINTN *CommBufferSize OPTIONAL\r | |
709 | );\r | |
710 | \r | |
46ece1ff JY |
711 | /**\r |
712 | This function is the main entry point for an SMM handler dispatch\r | |
713 | or communicate-based callback.\r | |
714 | \r | |
715 | @param DispatchHandle The unique handle assigned to this handler by SmiHandlerRegister().\r | |
716 | @param Context Points to an optional handler context which was specified when the handler was registered.\r | |
717 | @param CommBuffer A pointer to a collection of data in memory that will\r | |
718 | be conveyed from a non-SMM environment into an SMM environment.\r | |
719 | @param CommBufferSize The size of the CommBuffer.\r | |
720 | \r | |
721 | @return Status Code\r | |
722 | \r | |
723 | **/\r | |
724 | EFI_STATUS\r | |
725 | EFIAPI\r | |
726 | SmmEndOfDxeHandler (\r | |
727 | IN EFI_HANDLE DispatchHandle,\r | |
728 | IN CONST VOID *Context, OPTIONAL\r | |
729 | IN OUT VOID *CommBuffer, OPTIONAL\r | |
730 | IN OUT UINTN *CommBufferSize OPTIONAL\r | |
731 | );\r | |
732 | \r | |
53ec4d7f SZ |
733 | /**\r |
734 | This function is the main entry point for an SMM handler dispatch\r | |
735 | or communicate-based callback.\r | |
736 | \r | |
737 | @param DispatchHandle The unique handle assigned to this handler by SmiHandlerRegister().\r | |
738 | @param Context Points to an optional handler context which was specified when the handler was registered.\r | |
739 | @param CommBuffer A pointer to a collection of data in memory that will\r | |
740 | be conveyed from a non-SMM environment into an SMM environment.\r | |
741 | @param CommBufferSize The size of the CommBuffer.\r | |
742 | \r | |
743 | @return Status Code\r | |
744 | \r | |
745 | **/\r | |
746 | EFI_STATUS\r | |
747 | EFIAPI\r | |
748 | SmmExitBootServicesHandler (\r | |
749 | IN EFI_HANDLE DispatchHandle,\r | |
750 | IN CONST VOID *Context, OPTIONAL\r | |
751 | IN OUT VOID *CommBuffer, OPTIONAL\r | |
752 | IN OUT UINTN *CommBufferSize OPTIONAL\r | |
753 | );\r | |
754 | \r | |
755 | /**\r | |
756 | This function is the main entry point for an SMM handler dispatch\r | |
757 | or communicate-based callback.\r | |
758 | \r | |
759 | @param DispatchHandle The unique handle assigned to this handler by SmiHandlerRegister().\r | |
760 | @param Context Points to an optional handler context which was specified when the handler was registered.\r | |
761 | @param CommBuffer A pointer to a collection of data in memory that will\r | |
762 | be conveyed from a non-SMM environment into an SMM environment.\r | |
763 | @param CommBufferSize The size of the CommBuffer.\r | |
764 | \r | |
765 | @return Status Code\r | |
766 | \r | |
767 | **/\r | |
768 | EFI_STATUS\r | |
769 | EFIAPI\r | |
770 | SmmReadyToBootHandler (\r | |
771 | IN EFI_HANDLE DispatchHandle,\r | |
772 | IN CONST VOID *Context, OPTIONAL\r | |
773 | IN OUT VOID *CommBuffer, OPTIONAL\r | |
774 | IN OUT UINTN *CommBufferSize OPTIONAL\r | |
775 | );\r | |
776 | \r | |
e42e9404 | 777 | /**\r |
778 | Place holder function until all the SMM System Table Service are available.\r | |
779 | \r | |
780 | @param Arg1 Undefined\r | |
781 | @param Arg2 Undefined\r | |
782 | @param Arg3 Undefined\r | |
783 | @param Arg4 Undefined\r | |
784 | @param Arg5 Undefined\r | |
785 | \r | |
786 | @return EFI_NOT_AVAILABLE_YET\r | |
787 | \r | |
788 | **/\r | |
789 | EFI_STATUS\r | |
790 | EFIAPI\r | |
791 | SmmEfiNotAvailableYetArg5 (\r | |
792 | UINTN Arg1,\r | |
793 | UINTN Arg2,\r | |
794 | UINTN Arg3,\r | |
795 | UINTN Arg4,\r | |
796 | UINTN Arg5\r | |
797 | );\r | |
798 | \r | |
799 | //\r | |
800 | //Functions used during debug buils\r | |
801 | //\r | |
802 | \r | |
803 | /**\r | |
804 | Traverse the discovered list for any drivers that were discovered but not loaded\r | |
805 | because the dependency experessions evaluated to false.\r | |
806 | \r | |
807 | **/\r | |
808 | VOID\r | |
809 | SmmDisplayDiscoveredNotDispatched (\r | |
810 | VOID\r | |
811 | );\r | |
812 | \r | |
813 | /**\r | |
814 | Add free SMRAM region for use by memory service.\r | |
815 | \r | |
816 | @param MemBase Base address of memory region.\r | |
817 | @param MemLength Length of the memory region.\r | |
818 | @param Type Memory type.\r | |
819 | @param Attributes Memory region state.\r | |
820 | \r | |
821 | **/\r | |
822 | VOID\r | |
823 | SmmAddMemoryRegion (\r | |
824 | IN EFI_PHYSICAL_ADDRESS MemBase,\r | |
825 | IN UINT64 MemLength,\r | |
826 | IN EFI_MEMORY_TYPE Type,\r | |
827 | IN UINT64 Attributes\r | |
828 | );\r | |
829 | \r | |
830 | /**\r | |
831 | Finds the protocol entry for the requested protocol.\r | |
832 | \r | |
833 | @param Protocol The ID of the protocol\r | |
834 | @param Create Create a new entry if not found\r | |
835 | \r | |
836 | @return Protocol entry\r | |
837 | \r | |
838 | **/\r | |
839 | PROTOCOL_ENTRY *\r | |
840 | SmmFindProtocolEntry (\r | |
841 | IN EFI_GUID *Protocol,\r | |
842 | IN BOOLEAN Create\r | |
843 | );\r | |
844 | \r | |
845 | /**\r | |
846 | Signal event for every protocol in protocol entry.\r | |
847 | \r | |
848 | @param Prot Protocol interface\r | |
849 | \r | |
850 | **/\r | |
851 | VOID\r | |
852 | SmmNotifyProtocol (\r | |
853 | IN PROTOCOL_INTERFACE *Prot\r | |
854 | );\r | |
855 | \r | |
856 | /**\r | |
857 | Finds the protocol instance for the requested handle and protocol.\r | |
858 | Note: This function doesn't do parameters checking, it's caller's responsibility\r | |
859 | to pass in valid parameters.\r | |
860 | \r | |
861 | @param Handle The handle to search the protocol on\r | |
862 | @param Protocol GUID of the protocol\r | |
863 | @param Interface The interface for the protocol being searched\r | |
864 | \r | |
865 | @return Protocol instance (NULL: Not found)\r | |
866 | \r | |
867 | **/\r | |
868 | PROTOCOL_INTERFACE *\r | |
869 | SmmFindProtocolInterface (\r | |
870 | IN IHANDLE *Handle,\r | |
871 | IN EFI_GUID *Protocol,\r | |
872 | IN VOID *Interface\r | |
873 | );\r | |
874 | \r | |
875 | /**\r | |
876 | Removes Protocol from the protocol list (but not the handle list).\r | |
877 | \r | |
878 | @param Handle The handle to remove protocol on.\r | |
879 | @param Protocol GUID of the protocol to be moved\r | |
880 | @param Interface The interface of the protocol\r | |
881 | \r | |
882 | @return Protocol Entry\r | |
883 | \r | |
884 | **/\r | |
885 | PROTOCOL_INTERFACE *\r | |
886 | SmmRemoveInterfaceFromProtocol (\r | |
887 | IN IHANDLE *Handle,\r | |
888 | IN EFI_GUID *Protocol,\r | |
889 | IN VOID *Interface\r | |
890 | );\r | |
891 | \r | |
892 | /**\r | |
893 | This is the POSTFIX version of the dependency evaluator. This code does\r | |
894 | not need to handle Before or After, as it is not valid to call this\r | |
fa542a1e | 895 | routine in this case. POSTFIX means all the math is done on top of the stack.\r |
e42e9404 | 896 | \r |
897 | @param DriverEntry DriverEntry element to update.\r | |
898 | \r | |
899 | @retval TRUE If driver is ready to run.\r | |
900 | @retval FALSE If driver is not ready to run or some fatal error\r | |
901 | was found.\r | |
902 | \r | |
903 | **/\r | |
904 | BOOLEAN\r | |
905 | SmmIsSchedulable (\r | |
906 | IN EFI_SMM_DRIVER_ENTRY *DriverEntry\r | |
907 | );\r | |
908 | \r | |
84edd20b SZ |
909 | //\r |
910 | // SmramProfile\r | |
911 | //\r | |
912 | \r | |
913 | /**\r | |
914 | Initialize SMRAM profile.\r | |
915 | \r | |
916 | **/\r | |
917 | VOID\r | |
918 | SmramProfileInit (\r | |
919 | VOID\r | |
920 | );\r | |
921 | \r | |
e524f680 SZ |
922 | /**\r |
923 | Install SMRAM profile protocol.\r | |
924 | \r | |
925 | **/\r | |
926 | VOID\r | |
927 | SmramProfileInstallProtocol (\r | |
928 | VOID\r | |
929 | );\r | |
930 | \r | |
84edd20b SZ |
931 | /**\r |
932 | Register SMM image to SMRAM profile.\r | |
933 | \r | |
934 | @param DriverEntry SMM image info.\r | |
935 | @param RegisterToDxe Register image to DXE.\r | |
936 | \r | |
e524f680 SZ |
937 | @return EFI_SUCCESS Register successfully.\r |
938 | @return EFI_UNSUPPORTED Memory profile unsupported,\r | |
939 | or memory profile for the image is not required.\r | |
940 | @return EFI_OUT_OF_RESOURCES No enough resource for this register.\r | |
84edd20b SZ |
941 | \r |
942 | **/\r | |
e524f680 | 943 | EFI_STATUS\r |
84edd20b SZ |
944 | RegisterSmramProfileImage (\r |
945 | IN EFI_SMM_DRIVER_ENTRY *DriverEntry,\r | |
946 | IN BOOLEAN RegisterToDxe\r | |
947 | );\r | |
948 | \r | |
949 | /**\r | |
950 | Unregister image from SMRAM profile.\r | |
951 | \r | |
952 | @param DriverEntry SMM image info.\r | |
953 | @param UnregisterToDxe Unregister image from DXE.\r | |
954 | \r | |
e524f680 SZ |
955 | @return EFI_SUCCESS Unregister successfully.\r |
956 | @return EFI_UNSUPPORTED Memory profile unsupported,\r | |
957 | or memory profile for the image is not required.\r | |
958 | @return EFI_NOT_FOUND The image is not found.\r | |
84edd20b SZ |
959 | \r |
960 | **/\r | |
e524f680 | 961 | EFI_STATUS\r |
84edd20b SZ |
962 | UnregisterSmramProfileImage (\r |
963 | IN EFI_SMM_DRIVER_ENTRY *DriverEntry,\r | |
964 | IN BOOLEAN UnregisterToDxe\r | |
965 | );\r | |
966 | \r | |
967 | /**\r | |
968 | Update SMRAM profile information.\r | |
969 | \r | |
970 | @param CallerAddress Address of caller who call Allocate or Free.\r | |
971 | @param Action This Allocate or Free action.\r | |
972 | @param MemoryType Memory type.\r | |
e524f680 | 973 | EfiMaxMemoryType means the MemoryType is unknown.\r |
84edd20b SZ |
974 | @param Size Buffer size.\r |
975 | @param Buffer Buffer address.\r | |
e524f680 SZ |
976 | @param ActionString String for memory profile action.\r |
977 | Only needed for user defined allocate action.\r | |
84edd20b | 978 | \r |
e524f680 SZ |
979 | @return EFI_SUCCESS Memory profile is updated.\r |
980 | @return EFI_UNSUPPORTED Memory profile is unsupported,\r | |
981 | or memory profile for the image is not required,\r | |
982 | or memory profile for the memory type is not required.\r | |
983 | @return EFI_ACCESS_DENIED It is during memory profile data getting.\r | |
984 | @return EFI_ABORTED Memory profile recording is not enabled.\r | |
985 | @return EFI_OUT_OF_RESOURCES No enough resource to update memory profile for allocate action.\r | |
986 | @return EFI_NOT_FOUND No matched allocate info found for free action.\r | |
84edd20b SZ |
987 | \r |
988 | **/\r | |
e524f680 SZ |
989 | EFI_STATUS\r |
990 | EFIAPI\r | |
84edd20b | 991 | SmmCoreUpdateProfile (\r |
e524f680 SZ |
992 | IN PHYSICAL_ADDRESS CallerAddress,\r |
993 | IN MEMORY_PROFILE_ACTION Action,\r | |
994 | IN EFI_MEMORY_TYPE MemoryType, // Valid for AllocatePages/AllocatePool\r | |
995 | IN UINTN Size, // Valid for AllocatePages/FreePages/AllocatePool\r | |
996 | IN VOID *Buffer,\r | |
997 | IN CHAR8 *ActionString OPTIONAL\r | |
84edd20b SZ |
998 | );\r |
999 | \r | |
1000 | /**\r | |
1001 | Register SMRAM profile handler.\r | |
1002 | \r | |
1003 | **/\r | |
1004 | VOID\r | |
1005 | RegisterSmramProfileHandler (\r | |
1006 | VOID\r | |
1007 | );\r | |
1008 | \r | |
1009 | /**\r | |
1010 | SMRAM profile ready to lock callback function.\r | |
1011 | \r | |
1012 | **/\r | |
1013 | VOID\r | |
1014 | SmramProfileReadyToLock (\r | |
1015 | VOID\r | |
1016 | );\r | |
1017 | \r | |
285a682c JY |
1018 | /**\r |
1019 | Initialize MemoryAttributes support.\r | |
1020 | **/\r | |
1021 | VOID\r | |
1022 | EFIAPI\r | |
1023 | SmmCoreInitializeMemoryAttributesTable (\r | |
1024 | VOID\r | |
1025 | );\r | |
1026 | \r | |
1027 | /**\r | |
1028 | This function returns a copy of the current memory map. The map is an array of\r | |
1029 | memory descriptors, each of which describes a contiguous block of memory.\r | |
1030 | \r | |
1031 | @param[in, out] MemoryMapSize A pointer to the size, in bytes, of the\r | |
1032 | MemoryMap buffer. On input, this is the size of\r | |
1033 | the buffer allocated by the caller. On output,\r | |
1034 | it is the size of the buffer returned by the\r | |
1035 | firmware if the buffer was large enough, or the\r | |
1036 | size of the buffer needed to contain the map if\r | |
1037 | the buffer was too small.\r | |
1038 | @param[in, out] MemoryMap A pointer to the buffer in which firmware places\r | |
1039 | the current memory map.\r | |
1040 | @param[out] MapKey A pointer to the location in which firmware\r | |
1041 | returns the key for the current memory map.\r | |
1042 | @param[out] DescriptorSize A pointer to the location in which firmware\r | |
1043 | returns the size, in bytes, of an individual\r | |
1044 | EFI_MEMORY_DESCRIPTOR.\r | |
1045 | @param[out] DescriptorVersion A pointer to the location in which firmware\r | |
1046 | returns the version number associated with the\r | |
1047 | EFI_MEMORY_DESCRIPTOR.\r | |
1048 | \r | |
1049 | @retval EFI_SUCCESS The memory map was returned in the MemoryMap\r | |
1050 | buffer.\r | |
1051 | @retval EFI_BUFFER_TOO_SMALL The MemoryMap buffer was too small. The current\r | |
1052 | buffer size needed to hold the memory map is\r | |
1053 | returned in MemoryMapSize.\r | |
1054 | @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.\r | |
1055 | \r | |
1056 | **/\r | |
1057 | EFI_STATUS\r | |
1058 | EFIAPI\r | |
1059 | SmmCoreGetMemoryMap (\r | |
1060 | IN OUT UINTN *MemoryMapSize,\r | |
1061 | IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap,\r | |
1062 | OUT UINTN *MapKey,\r | |
1063 | OUT UINTN *DescriptorSize,\r | |
1064 | OUT UINT32 *DescriptorVersion\r | |
1065 | );\r | |
1066 | \r | |
1067 | ///\r | |
1068 | /// For generic EFI machines make the default allocations 4K aligned\r | |
1069 | ///\r | |
1070 | #define EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT (EFI_PAGE_SIZE)\r | |
1071 | #define DEFAULT_PAGE_ALLOCATION (EFI_PAGE_SIZE)\r | |
1072 | \r | |
84edd20b SZ |
1073 | extern UINTN mFullSmramRangeCount;\r |
1074 | extern EFI_SMRAM_DESCRIPTOR *mFullSmramRanges;\r | |
1075 | \r | |
285a682c JY |
1076 | extern EFI_SMM_DRIVER_ENTRY *mSmmCoreDriverEntry;\r |
1077 | \r | |
0b256fb1 JY |
1078 | extern EFI_LOADED_IMAGE_PROTOCOL *mSmmCoreLoadedImage;\r |
1079 | \r | |
63aa86b0 SZ |
1080 | //\r |
1081 | // Page management\r | |
1082 | //\r | |
1083 | \r | |
1084 | typedef struct {\r | |
1085 | LIST_ENTRY Link;\r | |
1086 | UINTN NumberOfPages;\r | |
1087 | } FREE_PAGE_LIST;\r | |
1088 | \r | |
1089 | extern LIST_ENTRY mSmmMemoryMap;\r | |
1090 | \r | |
1091 | //\r | |
1092 | // Pool management\r | |
1093 | //\r | |
1094 | \r | |
1095 | //\r | |
1096 | // MIN_POOL_SHIFT must not be less than 5\r | |
1097 | //\r | |
1098 | #define MIN_POOL_SHIFT 6\r | |
1099 | #define MIN_POOL_SIZE (1 << MIN_POOL_SHIFT)\r | |
1100 | \r | |
1101 | //\r | |
1102 | // MAX_POOL_SHIFT must not be less than EFI_PAGE_SHIFT - 1\r | |
1103 | //\r | |
1104 | #define MAX_POOL_SHIFT (EFI_PAGE_SHIFT - 1)\r | |
1105 | #define MAX_POOL_SIZE (1 << MAX_POOL_SHIFT)\r | |
1106 | \r | |
1107 | //\r | |
1108 | // MAX_POOL_INDEX are calculated by maximum and minimum pool sizes\r | |
1109 | //\r | |
1110 | #define MAX_POOL_INDEX (MAX_POOL_SHIFT - MIN_POOL_SHIFT + 1)\r | |
1111 | \r | |
1112 | typedef struct {\r | |
5f4d3e17 JY |
1113 | UINTN Size;\r |
1114 | BOOLEAN Available;\r | |
1115 | EFI_MEMORY_TYPE Type;\r | |
63aa86b0 SZ |
1116 | } POOL_HEADER;\r |
1117 | \r | |
1118 | typedef struct {\r | |
1119 | POOL_HEADER Header;\r | |
1120 | LIST_ENTRY Link;\r | |
1121 | } FREE_POOL_HEADER;\r | |
1122 | \r | |
5f4d3e17 JY |
1123 | typedef enum {\r |
1124 | SmmPoolTypeCode,\r | |
1125 | SmmPoolTypeData,\r | |
1126 | SmmPoolTypeMax,\r | |
1127 | } SMM_POOL_TYPE;\r | |
1128 | \r | |
1129 | extern LIST_ENTRY mSmmPoolLists[SmmPoolTypeMax][MAX_POOL_INDEX];\r | |
63aa86b0 | 1130 | \r |
e42e9404 | 1131 | #endif\r |