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