SecurityPkg/Tcg/TcgPei/TcgPei.c File Reference


Functions

EFI_STATUS EFIAPI PhysicalPresencePpiNotifyCallback (IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor, IN VOID *Ppi)
EFI_STATUS EFIAPI FirmwareVolmeInfoPpiNotifyCallback (IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor, IN VOID *Ppi)
EFI_STATUS EFIAPI EndofPeiSignalNotifyCallBack (IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor, IN VOID *Ppi)
EFI_STATUS HashLogExtendEvent (IN EFI_PEI_SERVICES **PeiServices, IN UINT8 *HashData, IN UINTN HashDataLen, IN TIS_TPM_HANDLE TpmHandle, IN TCG_PCR_EVENT_HDR *NewEventHdr, IN UINT8 *NewEventData)
EFI_STATUS EFIAPI MeasureCRTMVersion (IN EFI_PEI_SERVICES **PeiServices, IN TIS_TPM_HANDLE TpmHandle)
EFI_STATUS EFIAPI MeasureFvImage (IN EFI_PHYSICAL_ADDRESS FvBase, IN UINT64 FvLength)
EFI_STATUS EFIAPI MeasureMainBios (IN EFI_PEI_SERVICES **PeiServices, IN TIS_TPM_HANDLE TpmHandle)
BOOLEAN EFIAPI IsTpmUsable (IN EFI_PEI_SERVICES **PeiServices, IN TIS_TPM_HANDLE TpmHandle)
EFI_STATUS EFIAPI PeimEntryMP (IN EFI_PEI_SERVICES **PeiServices)
EFI_STATUS EFIAPI PeimEntryMA (IN EFI_PEI_FILE_HANDLE FileHandle, IN CONST EFI_PEI_SERVICES **PeiServices)

Variables

BOOLEAN mImageInMemory = FALSE
EFI_PEI_PPI_DESCRIPTOR mTpmInitializedPpiList
EFI_PEI_PPI_DESCRIPTOR mTpmInitializationDonePpiList
EFI_PLATFORM_FIRMWARE_BLOB * mMeasuredBaseFvInfo
UINT32 mMeasuredBaseFvIndex = 0
EFI_PLATFORM_FIRMWARE_BLOB * mMeasuredChildFvInfo
UINT32 mMeasuredChildFvIndex = 0
EFI_PEI_FIRMWARE_VOLUME_INFO_MEASUREMENT_EXCLUDED_PPImMeasurementExcludedFvPpi
EFI_PEI_NOTIFY_DESCRIPTOR mNotifyList []

Detailed Description

Initialize TPM device and measure FVs before handing off control to DXE.

Copyright (c) 2005 - 2015, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php

THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.


Function Documentation

EFI_STATUS EFIAPI EndofPeiSignalNotifyCallBack ( IN EFI_PEI_SERVICES **  PeiServices,
IN EFI_PEI_NOTIFY_DESCRIPTOR *  NotifyDescriptor,
IN VOID *  Ppi 
)

Record all measured Firmware Volum Information into a Guid Hob

Parameters:
[in] PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
[in] NotifyDescriptor Address of the notification descriptor data structure.
[in] Ppi Address of the PPI that was installed.
Return values:
EFI_SUCCESS The FV Info is measured and recorded to TPM.
Returns:
Others Fail to measure FV.
Record all measured Firmware Volum Information into a Guid Hob Guid Hob payload layout is

UINT32 *************************** FIRMWARE_BLOB number EFI_PLATFORM_FIRMWARE_BLOB******** BLOB Array

Parameters:
[in] PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
[in] NotifyDescriptor Address of the notification descriptor data structure.
[in] Ppi Address of the PPI that was installed.
Return values:
EFI_SUCCESS The FV Info is measured and recorded to TPM.
Returns:
Others Fail to measure FV.

EFI_STATUS EFIAPI FirmwareVolmeInfoPpiNotifyCallback ( IN EFI_PEI_SERVICES **  PeiServices,
IN EFI_PEI_NOTIFY_DESCRIPTOR *  NotifyDescriptor,
IN VOID *  Ppi 
)

Measure and record the Firmware Volum Information once FvInfoPPI install.

Parameters:
[in] PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
[in] NotifyDescriptor Address of the notification descriptor data structure.
[in] Ppi Address of the PPI that was installed.
Return values:
EFI_SUCCESS The FV Info is measured and recorded to TPM.
Returns:
Others Fail to measure FV.

EFI_STATUS HashLogExtendEvent ( IN EFI_PEI_SERVICES **  PeiServices,
IN UINT8 *  HashData,
IN UINTN  HashDataLen,
IN TIS_TPM_HANDLE  TpmHandle,
IN TCG_PCR_EVENT_HDR *  NewEventHdr,
IN UINT8 *  NewEventData 
)

Do a hash operation on a data buffer, extend a specific TPM PCR with the hash result, and build a GUIDed HOB recording the event which will be passed to the DXE phase and added into the Event Log.

Parameters:
[in] PeiServices Describes the list of possible PEI Services.
[in] HashData Physical address of the start of the data buffer to be hashed, extended, and logged.
[in] HashDataLen The length, in bytes, of the buffer referenced by HashData.
[in] TpmHandle TPM handle.
[in] NewEventHdr Pointer to a TCG_PCR_EVENT_HDR data structure.
[in] NewEventData Pointer to the new event data.
Return values:
EFI_SUCCESS Operation completed successfully.
EFI_OUT_OF_RESOURCES No enough memory to log the new event.
EFI_DEVICE_ERROR The command was unsuccessful.

References EFI_STATUS(), gTcgEventEntryHobGuid, gTpmErrorHobGuid, TpmCommExtend(), and TpmCommHashAll().

BOOLEAN EFIAPI IsTpmUsable ( IN EFI_PEI_SERVICES **  PeiServices,
IN TIS_TPM_HANDLE  TpmHandle 
)

Check if TPM chip is activeated or not.

Parameters:
[in] PeiServices Describes the list of possible PEI Services.
[in] TpmHandle TPM handle.
Return values:
TRUE TPM is activated.
FALSE TPM is deactivated.

References BOOLEAN(), EFI_STATUS(), and TpmCommGetCapability().

Referenced by PeimEntryMP().

EFI_STATUS EFIAPI MeasureCRTMVersion ( IN EFI_PEI_SERVICES **  PeiServices,
IN TIS_TPM_HANDLE  TpmHandle 
)

Measure CRTM version.

Parameters:
[in] PeiServices Describes the list of possible PEI Services.
[in] TpmHandle TPM handle.
Return values:
EFI_SUCCESS Operation completed successfully.
EFI_OUT_OF_RESOURCES No enough memory to log the new event.
EFI_DEVICE_ERROR The command was unsuccessful.

References HashLogExtendEvent().

EFI_STATUS EFIAPI MeasureFvImage ( IN EFI_PHYSICAL_ADDRESS  FvBase,
IN UINT64  FvLength 
)

Measure FV image. Add it into the measured FV list after the FV is measured successfully.

Parameters:
[in] FvBase Base address of FV image.
[in] FvLength Length of FV image.
Return values:
EFI_SUCCESS Fv image is measured successfully or it has been already measured.
EFI_OUT_OF_RESOURCES No enough memory to log the new event.
EFI_DEVICE_ERROR The command was unsuccessful.

References EFI_PEI_FIRMWARE_VOLUME_INFO_MEASUREMENT_EXCLUDED_PPI::Count, EFI_STATUS(), EFI_PEI_FIRMWARE_VOLUME_INFO_MEASUREMENT_EXCLUDED_PPI::Fv, EFI_PEI_FIRMWARE_VOLUME_INFO_MEASUREMENT_EXCLUDED_FV::FvBase, HashLogExtendEvent(), mMeasuredBaseFvIndex, mMeasuredBaseFvInfo, TPM_BASE_ADDRESS, and UINTN().

EFI_STATUS EFIAPI MeasureMainBios ( IN EFI_PEI_SERVICES **  PeiServices,
IN TIS_TPM_HANDLE  TpmHandle 
)

Measure main BIOS.

Parameters:
[in] PeiServices Describes the list of possible PEI Services.
[in] TpmHandle TPM handle.
Return values:
EFI_SUCCESS Operation completed successfully.
EFI_OUT_OF_RESOURCES No enough memory to log the new event.
EFI_DEVICE_ERROR The command was unsuccessful.

References EFI_STATUS(), MeasureFvImage(), TRUE, and UINTN().

EFI_STATUS EFIAPI PeimEntryMA ( IN EFI_PEI_FILE_HANDLE  FileHandle,
IN CONST EFI_PEI_SERVICES **  PeiServices 
)

Entry point of this module.

Parameters:
[in] FileHandle Handle of the file being invoked.
[in] PeiServices Describes the list of possible PEI Services.
Returns:
Status.

References EFI_STATUS(), gEfiTpmDeviceInstanceTpm12Guid, gTpmErrorHobGuid, mImageInMemory, mTpmInitializationDonePpiList, mTpmInitializedPpiList, PeimEntryMP(), TisPcRequestUseTpm(), TPM_BASE_ADDRESS, TpmCommContinueSelfTest(), TpmCommStartup(), TRUE, and UINTN().

EFI_STATUS EFIAPI PeimEntryMP ( IN EFI_PEI_SERVICES **  PeiServices  ) 

Do measurement after memory is ready.

Parameters:
[in] PeiServices Describes the list of possible PEI Services.
Return values:
EFI_SUCCESS Operation completed successfully.
EFI_OUT_OF_RESOURCES No enough memory to log the new event.
EFI_DEVICE_ERROR The command was unsuccessful.

References EFI_STATUS(), gEfiPeiFirmwareVolumeInfoMeasurementExcludedPpiGuid, IsTpmUsable(), MeasureCRTMVersion(), MeasureMainBios(), mMeasuredBaseFvInfo, mMeasuredChildFvInfo, mNotifyList, TisPcRequestUseTpm(), TPM_BASE_ADDRESS, and UINTN().

EFI_STATUS EFIAPI PhysicalPresencePpiNotifyCallback ( IN EFI_PEI_SERVICES **  PeiServices,
IN EFI_PEI_NOTIFY_DESCRIPTOR *  NotifyDescriptor,
IN VOID *  Ppi 
)

Lock physical presence if needed.

Parameters:
[in] PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation
[in] NotifyDescriptor Address of the notification descriptor data structure.
[in] Ppi Address of the PPI that was installed.
Return values:
EFI_SUCCESS Operation completed successfully.
Set physicalPresenceLifetimeLock, physicalPresenceHWEnable and physicalPresenceCMDEnable bit by corresponding PCDs. And lock physical presence if needed.

Parameters:
[in] PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation
[in] NotifyDescriptor Address of the notification descriptor data structure.
[in] Ppi Address of the PPI that was installed.
Return values:
EFI_SUCCESS Operation completed successfully.
EFI_ABORTED physicalPresenceCMDEnable is locked.
EFI_DEVICE_ERROR The command was unsuccessful.

References BOOLEAN(), EFI_STATUS(), _PEI_LOCK_PHYSICAL_PRESENCE_PPI::LockPhysicalPresence, TPM_BASE_ADDRESS, TpmCommGetCapability(), TpmCommPhysicalPresence(), TRUE, and UINTN().


Variable Documentation

BOOLEAN mImageInMemory = FALSE

EFI_PLATFORM_FIRMWARE_BLOB* mMeasuredBaseFvInfo

EFI_PLATFORM_FIRMWARE_BLOB* mMeasuredChildFvInfo

EFI_PEI_NOTIFY_DESCRIPTOR mNotifyList[]

Initial value:

 {
  {
    EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK,
    &gPeiLockPhysicalPresencePpiGuid,
    PhysicalPresencePpiNotifyCallback
  },
  {
    EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK,
    &gEfiPeiFirmwareVolumeInfoPpiGuid,
    FirmwareVolmeInfoPpiNotifyCallback 
  },
  {
    EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK,
    &gEfiPeiFirmwareVolumeInfo2PpiGuid,
    FirmwareVolmeInfoPpiNotifyCallback 
  },
  {
    (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
    &gEfiEndOfPeiSignalPpiGuid,
    EndofPeiSignalNotifyCallBack
  }
}

EFI_PEI_PPI_DESCRIPTOR mTpmInitializationDonePpiList

Initial value:

 {
  EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
  &gPeiTpmInitializationDonePpiGuid,
  NULL
}

EFI_PEI_PPI_DESCRIPTOR mTpmInitializedPpiList

Initial value:

 {
  EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
  &gPeiTpmInitializedPpiGuid,
  NULL
}


Generated on Thu Sep 24 23:44:24 2015 for SecurityPkg[ALL] by  doxygen 1.5.7.1