]>
Commit | Line | Data |
---|---|---|
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 | |
7 | Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>\r | |
8 | This program and the accompanying materials \r | |
9 | are licensed and made available under the terms and conditions of the BSD License \r | |
10 | which accompanies this distribution. The full text of the license may be found at \r | |
11 | http://opensource.org/licenses/bsd-license.php\r | |
12 | \r | |
13 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r | |
14 | WITHOUT 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 | UINT8 mMorControl;\r | |
21 | \r | |
22 | /**\r | |
23 | Ready to Boot Event notification handler.\r | |
24 | \r | |
25 | Sequence of OS boot events is measured in this event notification handler.\r | |
26 | \r | |
27 | @param[in] Event Event whose notification function is being invoked\r | |
28 | @param[in] Context Pointer to the notification function's context\r | |
29 | \r | |
30 | **/\r | |
31 | VOID\r | |
32 | EFIAPI\r | |
33 | OnReadyToBoot (\r | |
34 | IN EFI_EVENT Event,\r | |
35 | IN VOID *Context\r | |
36 | )\r | |
37 | {\r | |
38 | EFI_STATUS Status;\r | |
39 | UINTN DataSize;\r | |
40 | \r | |
41 | if (MOR_CLEAR_MEMORY_VALUE (mMorControl) == 0x0) {\r | |
42 | //\r | |
43 | // MorControl is expected, directly return to avoid unnecessary variable operation\r | |
44 | //\r | |
45 | return ;\r | |
46 | }\r | |
47 | //\r | |
48 | // Clear MOR_CLEAR_MEMORY_BIT\r | |
49 | //\r | |
50 | DEBUG ((EFI_D_INFO, "TcgMor: Clear MorClearMemory bit\n"));\r | |
51 | mMorControl &= 0xFE; \r | |
52 | \r | |
53 | DataSize = sizeof (mMorControl);\r | |
54 | Status = gRT->SetVariable (\r | |
55 | MEMORY_OVERWRITE_REQUEST_VARIABLE_NAME, \r | |
56 | &gEfiMemoryOverwriteControlDataGuid, \r | |
57 | EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r | |
58 | DataSize, \r | |
59 | &mMorControl\r | |
60 | );\r | |
61 | if (EFI_ERROR (Status)) {\r | |
62 | DEBUG ((EFI_D_ERROR, "TcgMor: Clear MOR_CLEAR_MEMORY_BIT failure, Status = %r\n"));\r | |
63 | }\r | |
64 | }\r | |
65 | \r | |
66 | \r | |
67 | /**\r | |
68 | Entry Point for TCG MOR Control driver.\r | |
69 | \r | |
70 | @param[in] ImageHandle Image handle of this driver.\r | |
71 | @param[in] SystemTable A Pointer to the EFI System Table.\r | |
72 | \r | |
73 | @retval EFI_SUCEESS \r | |
74 | @return Others Some error occurs.\r | |
75 | **/\r | |
76 | EFI_STATUS\r | |
77 | EFIAPI\r | |
78 | MorDriverEntryPoint (\r | |
79 | IN EFI_HANDLE ImageHandle,\r | |
80 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
81 | )\r | |
82 | {\r | |
83 | EFI_STATUS Status;\r | |
84 | UINTN DataSize;\r | |
85 | EFI_EVENT Event;\r | |
86 | \r | |
87 | ///\r | |
88 | /// The firmware is required to create the MemoryOverwriteRequestControl UEFI variable.\r | |
89 | ///\r | |
90 | \r | |
91 | DataSize = sizeof (mMorControl);\r | |
92 | Status = gRT->GetVariable (\r | |
93 | MEMORY_OVERWRITE_REQUEST_VARIABLE_NAME, \r | |
94 | &gEfiMemoryOverwriteControlDataGuid, \r | |
95 | NULL, \r | |
96 | &DataSize, \r | |
97 | &mMorControl\r | |
98 | );\r | |
99 | if (EFI_ERROR (Status)) {\r | |
100 | //\r | |
101 | // Set default value to 0\r | |
102 | //\r | |
103 | mMorControl = 0;\r | |
104 | Status = gRT->SetVariable (\r | |
105 | MEMORY_OVERWRITE_REQUEST_VARIABLE_NAME, \r | |
106 | &gEfiMemoryOverwriteControlDataGuid, \r | |
107 | EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r | |
108 | DataSize, \r | |
109 | &mMorControl\r | |
110 | );\r | |
111 | DEBUG ((EFI_D_INFO, "TcgMor: Create MOR variable! Status = %r\n", Status));\r | |
112 | } else {\r | |
113 | //\r | |
114 | // Create a Ready To Boot Event and Clear the MorControl bit in the call back function.\r | |
115 | //\r | |
116 | DEBUG ((EFI_D_INFO, "TcgMor: Create ReadyToBoot Event for MorControl Bit cleanning!\n"));\r | |
117 | Status = EfiCreateEventReadyToBootEx (\r | |
118 | TPL_CALLBACK,\r | |
119 | OnReadyToBoot,\r | |
120 | NULL,\r | |
121 | &Event\r | |
122 | );\r | |
123 | } \r | |
124 | \r | |
125 | return Status;\r | |
126 | }\r | |
127 | \r | |
128 | \r |