]> git.proxmox.com Git - mirror_edk2.git/blame - SecurityPkg/Tcg/MemoryOverwriteControl/TcgMor.c
Add security package to repository.
[mirror_edk2.git] / SecurityPkg / Tcg / MemoryOverwriteControl / TcgMor.c
CommitLineData
0c18794e 1/** @file\r
2 TCG MOR (Memory Overwrite Request) Control Driver.\r
3\r
4 This driver initilize MemoryOverwriteRequestControl variable. It \r
5 will clear MOR_CLEAR_MEMORY_BIT bit if it is set.\r
6\r
7Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>\r
8This program and the accompanying materials \r
9are licensed and made available under the terms and conditions of the BSD License \r
10which accompanies this distribution. The full text of the license may be found at \r
11http://opensource.org/licenses/bsd-license.php\r
12\r
13THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
14WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
15\r
16**/\r
17\r
18#include "TcgMor.h"\r
19\r
20/**\r
21 Entry Point for TCG MOR Control driver.\r
22\r
23 @param[in] ImageHandle Image handle of this driver.\r
24 @param[in] SystemTable A Pointer to the EFI System Table.\r
25\r
26 @retval EFI_SUCEESS \r
27 @return Others Some error occurs.\r
28**/\r
29EFI_STATUS\r
30EFIAPI\r
31MorDriverEntryPoint (\r
32 IN EFI_HANDLE ImageHandle,\r
33 IN EFI_SYSTEM_TABLE *SystemTable\r
34 )\r
35{\r
36 EFI_STATUS Status;\r
37 UINT8 MorControl;\r
38 UINTN DataSize;\r
39\r
40 ///\r
41 /// The firmware is required to create the MemoryOverwriteRequestControl UEFI variable.\r
42 ///\r
43\r
44 DataSize = sizeof (MorControl);\r
45 Status = gRT->GetVariable (\r
46 MEMORY_OVERWRITE_REQUEST_VARIABLE_NAME, \r
47 &gEfiMemoryOverwriteControlDataGuid, \r
48 NULL, \r
49 &DataSize, \r
50 &MorControl\r
51 );\r
52 if (EFI_ERROR (Status)) {\r
53 //\r
54 // Set default value to 0\r
55 //\r
56 MorControl = 0;\r
57 } else {\r
58 if (MOR_CLEAR_MEMORY_VALUE (MorControl) == 0x0) {\r
59 //\r
60 // MorControl is expected, directly return to avoid unnecessary variable operation\r
61 //\r
62 return EFI_SUCCESS;\r
63 }\r
64 //\r
65 // Clear MOR_CLEAR_MEMORY_BIT\r
66 //\r
67 DEBUG ((EFI_D_INFO, "TcgMor: Clear MorClearMemory bit\n"));\r
68 MorControl &= 0xFE;\r
69 }\r
70 \r
71 Status = gRT->SetVariable (\r
72 MEMORY_OVERWRITE_REQUEST_VARIABLE_NAME, \r
73 &gEfiMemoryOverwriteControlDataGuid, \r
74 EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
75 DataSize, \r
76 &MorControl\r
77 );\r
78 ASSERT_EFI_ERROR (Status);\r
79 return Status;\r
80}\r
81\r
82\r