]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteTraditionalMm.c
MdeModulePkg: Apply uncrustify changes
[mirror_edk2.git] / MdeModulePkg / Universal / FaultTolerantWriteDxe / FaultTolerantWriteTraditionalMm.c
CommitLineData
22cedf5b
AB
1/** @file\r
2\r
3 Parts of the SMM/MM implementation that are specific to traditional MM\r
4\r
5Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved. <BR>\r
6Copyright (c) 2018, Linaro, Ltd. All rights reserved. <BR>\r
9d510e61 7SPDX-License-Identifier: BSD-2-Clause-Patent\r
22cedf5b
AB
8\r
9**/\r
10\r
11#include <Library/SmmMemLib.h>\r
12#include <Library/UefiBootServicesTableLib.h>\r
13#include "FaultTolerantWrite.h"\r
14#include "FaultTolerantWriteSmmCommon.h"\r
15\r
16/**\r
17 This function checks if the buffer is valid per processor architecture and\r
18 does not overlap with SMRAM.\r
19\r
20 @param Buffer The buffer start address to be checked.\r
21 @param Length The buffer length to be checked.\r
22\r
23 @retval TRUE This buffer is valid per processor architecture and does not\r
24 overlap with SMRAM.\r
25 @retval FALSE This buffer is not valid per processor architecture or overlaps\r
26 with SMRAM.\r
27**/\r
28BOOLEAN\r
29FtwSmmIsBufferOutsideSmmValid (\r
30 IN EFI_PHYSICAL_ADDRESS Buffer,\r
31 IN UINT64 Length\r
32 )\r
33{\r
34 return SmmIsBufferOutsideSmmValid (Buffer, Length);\r
35}\r
36\r
37/**\r
38 Internal implementation of CRC32. Depending on the execution context\r
39 (traditional SMM or DXE vs standalone MM), this function is implemented\r
40 via a call to the CalculateCrc32 () boot service, or via a library\r
41 call.\r
42\r
43 If Buffer is NULL, then ASSERT().\r
44 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
45\r
46 @param[in] Buffer A pointer to the buffer on which the 32-bit CRC is\r
47 to be computed.\r
48 @param[in] Length The number of bytes in the buffer Data.\r
49\r
50 @retval Crc32 The 32-bit CRC was computed for the data buffer.\r
51\r
52**/\r
53UINT32\r
54FtwCalculateCrc32 (\r
1436aea4
MK
55 IN VOID *Buffer,\r
56 IN UINTN Length\r
22cedf5b
AB
57 )\r
58{\r
1436aea4
MK
59 EFI_STATUS Status;\r
60 UINT32 ReturnValue;\r
22cedf5b
AB
61\r
62 Status = gBS->CalculateCrc32 (Buffer, Length, &ReturnValue);\r
63 ASSERT_EFI_ERROR (Status);\r
64\r
65 return ReturnValue;\r
66}\r
67\r
68/**\r
44289eea 69 Notify the system that the SMM FTW driver is ready.\r
22cedf5b
AB
70**/\r
71VOID\r
72FtwNotifySmmReady (\r
73 VOID\r
74 )\r
75{\r
1436aea4
MK
76 EFI_HANDLE FtwHandle;\r
77 EFI_STATUS Status;\r
22cedf5b
AB
78\r
79 FtwHandle = NULL;\r
1436aea4
MK
80 Status = gBS->InstallProtocolInterface (\r
81 &FtwHandle,\r
82 &gEfiSmmFaultTolerantWriteProtocolGuid,\r
83 EFI_NATIVE_INTERFACE,\r
84 NULL\r
85 );\r
22cedf5b
AB
86 ASSERT_EFI_ERROR (Status);\r
87}\r
88\r
89/**\r
90 This function is the entry point of the Fault Tolerant Write driver.\r
91\r
92 @param[in] ImageHandle A handle for the image that is initializing this driver\r
93 @param[in] SystemTable A pointer to the EFI system table\r
94\r
95 @retval EFI_SUCCESS The initialization finished successfully.\r
96 @retval EFI_OUT_OF_RESOURCES Allocate memory error\r
97 @retval EFI_INVALID_PARAMETER Workspace or Spare block does not exist\r
98\r
99**/\r
100EFI_STATUS\r
101EFIAPI\r
102SmmFaultTolerantWriteInitialize (\r
1436aea4
MK
103 IN EFI_HANDLE ImageHandle,\r
104 IN EFI_SYSTEM_TABLE *SystemTable\r
22cedf5b
AB
105 )\r
106{\r
107 return MmFaultTolerantWriteInitialize ();\r
108}\r