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