]> git.proxmox.com Git - mirror_edk2.git/blame - SecurityPkg/Tcg/Tcg2PlatformDxe/Tcg2PlatformDxe.c
SecrutiyPkg/Tcg: Import Tcg2PlatformDxe from edk2-platforms
[mirror_edk2.git] / SecurityPkg / Tcg / Tcg2PlatformDxe / Tcg2PlatformDxe.c
CommitLineData
ebbc8ab2
SB
1/** @file\r
2 Platform specific TPM2 component for configuring the Platform Hierarchy.\r
3\r
4 Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.<BR>\r
5 SPDX-License-Identifier: BSD-2-Clause-Patent\r
6\r
7**/\r
8\r
9#include <PiDxe.h>\r
10\r
11#include <Library/DebugLib.h>\r
12#include <Library/UefiBootServicesTableLib.h>\r
13#include <Library/UefiLib.h>\r
14#include <Library/TpmPlatformHierarchyLib.h>\r
15#include <Protocol/DxeSmmReadyToLock.h>\r
16\r
17/**\r
18 This callback function will run at the SmmReadyToLock event.\r
19\r
20 Configuration of the TPM's Platform Hierarchy Authorization Value (platformAuth)\r
21 and Platform Hierarchy Authorization Policy (platformPolicy) can be defined through this function.\r
22\r
23 @param Event Pointer to this event\r
24 @param Context Event hanlder private data\r
25 **/\r
26VOID\r
27EFIAPI\r
28SmmReadyToLockEventCallBack (\r
29 IN EFI_EVENT Event,\r
30 IN VOID *Context\r
31 )\r
32{\r
33 EFI_STATUS Status;\r
34 VOID *Interface;\r
35\r
36 //\r
37 // Try to locate it because EfiCreateProtocolNotifyEvent will trigger it once when registration.\r
38 // Just return if it is not found.\r
39 //\r
40 Status = gBS->LocateProtocol (\r
41 &gEfiDxeSmmReadyToLockProtocolGuid,\r
42 NULL,\r
43 &Interface\r
44 );\r
45 if (EFI_ERROR (Status)) {\r
46 return ;\r
47 }\r
48\r
49 ConfigureTpmPlatformHierarchy ();\r
50\r
51 gBS->CloseEvent (Event);\r
52}\r
53\r
54/**\r
55 The driver's entry point. Will register a function for callback during SmmReadyToLock event to\r
56 configure the TPM's platform authorization.\r
57\r
58 @param[in] ImageHandle The firmware allocated handle for the EFI image.\r
59 @param[in] SystemTable A pointer to the EFI System Table.\r
60\r
61 @retval EFI_SUCCESS The entry point is executed successfully.\r
62 @retval other Some error occurs when executing this entry point.\r
63**/\r
64EFI_STATUS\r
65EFIAPI\r
66Tcg2PlatformDxeEntryPoint (\r
67 IN EFI_HANDLE ImageHandle,\r
68 IN EFI_SYSTEM_TABLE *SystemTable\r
69 )\r
70{\r
71 VOID *Registration;\r
72 EFI_EVENT Event;\r
73\r
74 Event = EfiCreateProtocolNotifyEvent (\r
75 &gEfiDxeSmmReadyToLockProtocolGuid,\r
76 TPL_CALLBACK,\r
77 SmmReadyToLockEventCallBack,\r
78 NULL,\r
79 &Registration\r
80 );\r
81\r
82 ASSERT (Event != NULL);\r
83\r
84 return EFI_SUCCESS;\r
85}\r