Home | History | Annotate | Download | only in PeiTcg2PhysicalPresenceLib
      1 /** @file
      2   Get TPM 2.0 physical presence information.
      3 
      4   This library will get TPM 2.0 physical presence information.
      5 
      6 Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>
      7 This program and the accompanying materials
      8 are licensed and made available under the terms and conditions of the BSD License
      9 which accompanies this distribution.  The full text of the license may be found at
     10 http://opensource.org/licenses/bsd-license.php
     11 
     12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
     13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
     14 
     15 **/
     16 
     17 #include <PiPei.h>
     18 
     19 #include <Guid/Tcg2PhysicalPresenceData.h>
     20 #include <Ppi/ReadOnlyVariable2.h>
     21 
     22 #include <Library/DebugLib.h>
     23 #include <Library/PeiServicesLib.h>
     24 #include <Library/PeiServicesTablePointerLib.h>
     25 #include <Library/Tcg2PhysicalPresenceLib.h>
     26 
     27 /**
     28   Return TPM2 ManagementFlags set by PP interface.
     29 
     30   @retval    ManagementFlags    TPM2 Management Flags.
     31 **/
     32 UINT32
     33 EFIAPI
     34 Tcg2PhysicalPresenceLibGetManagementFlags (
     35   VOID
     36   )
     37 {
     38   EFI_STATUS                        Status;
     39   EFI_PEI_READ_ONLY_VARIABLE2_PPI   *VariablePpi;
     40   EFI_TCG2_PHYSICAL_PRESENCE_FLAGS  PpiFlags;
     41   UINTN                             DataSize;
     42 
     43   Status = PeiServicesLocatePpi (&gEfiPeiReadOnlyVariable2PpiGuid, 0, NULL, (VOID **) &VariablePpi);
     44   ASSERT_EFI_ERROR (Status);
     45 
     46   DataSize = sizeof (EFI_TCG2_PHYSICAL_PRESENCE_FLAGS);
     47   Status = VariablePpi->GetVariable (
     48                           VariablePpi,
     49                           TCG2_PHYSICAL_PRESENCE_FLAGS_VARIABLE,
     50                           &gEfiTcg2PhysicalPresenceGuid,
     51                           NULL,
     52                           &DataSize,
     53                           &PpiFlags
     54                           );
     55   if (EFI_ERROR (Status)) {
     56     PpiFlags.PPFlags = TCG2_BIOS_TPM_MANAGEMENT_FLAG_DEFAULT | TCG2_BIOS_STORAGE_MANAGEMENT_FLAG_DEFAULT;
     57   }
     58   return PpiFlags.PPFlags;
     59 }
     60