mirror of
https://github.com/tianocore/edk2
synced 2026-08-27 00:23:19 -04:00
TcgTpmPkg/Library: introduce PlatformTpmLib
This is prepartion patch to add softwared-based TPM library
using TCG TPM v2.0 Reference Library[0].
TCG TPM v2.0 Reference Library[0] provides the TPM device functions
with platform specific layer. This layer has platform interfaces
which start with prefix "__plat_" to implement software based TPM.
PlatformTpmLib is used to implment these interfaces.
When TpmLib calls "__plat_XXX()", the correspond function
"PlatformTpmLibXXX()" in PlatformTpmLib would be called.
Not all __plat_XXX interfaces are required to be implemented, and
default implementations for some interfaces can be utilised.
Here, PlatformTpmLib implements correspond __plat_XXX function in
TPM reference library files:
- Clock.c
- ExtraData.c
- Failure.c
- NVMem.c
- Unique.c
- VendorInfo.c
NOTE:
To support to generation of platform specific endorsement seed,
the function PlatformTpmLibGetEPS() is defined in EPS.c
This platform function allows a platform to specify an endorsement seed
when the fTPM is manufactured.
Link: https://github.com/TrustedComputingGroup/TPM [0]
Signed-off-by: Yeoreum Yun <yeoreum.yun@arm.com>
This commit is contained in:
parent
31d7cb91c1
commit
bfa8e9b8cb
15 changed files with 2006 additions and 0 deletions
769
TcgTpmPkg/Include/Library/PlatformTpmLib.h
Normal file
769
TcgTpmPkg/Include/Library/PlatformTpmLib.h
Normal file
|
|
@ -0,0 +1,769 @@
|
||||||
|
/** @file
|
||||||
|
This file connects the platform specific functions of
|
||||||
|
the TCG TPM reference code to the corresponding functions in PlatformTpmLib.
|
||||||
|
|
||||||
|
To use TPM reference code as software based TPM, each Platform should
|
||||||
|
implements TpmPlatformLib.
|
||||||
|
|
||||||
|
For the __plat_XXX interface, Please see the:
|
||||||
|
- https://github.com/TrustedComputingGroup/TPM/tree/main/TPMCmd/Platform/src
|
||||||
|
- https://github.com/TrustedComputingGroup/TPM/tree/main/TPMCmd/tpm/include/platform_interface
|
||||||
|
|
||||||
|
Copyright (c) 2025, Arm Limited. All rights reserved.<BR>
|
||||||
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <Uefi/UefiBaseType.h>
|
||||||
|
|
||||||
|
//
|
||||||
|
// ClockRateAdjust uses predefined signal values and encapsulates the platform
|
||||||
|
// specifics regarding the number of ticks the underlying clock is running at.
|
||||||
|
//
|
||||||
|
// The adjustment must be one of these values. A COARSE adjustment is 1%, MEDIUM
|
||||||
|
// is 0.1%, and FINE is the smallest amount supported by the platform. The
|
||||||
|
// total (cumulative) adjustment is limited to ~15% total. Attempts to adjust
|
||||||
|
// the clock further are silently ignored as are any invalid values. These
|
||||||
|
// values are defined here to insulate them from spec changes and to avoid
|
||||||
|
// needing visibility to the doc-generated structure headers.
|
||||||
|
typedef enum {
|
||||||
|
TpmClockAdjustCoarseSlower = -3,
|
||||||
|
TpmClockAdjustMediumSlower = -2,
|
||||||
|
TpmClockAdjustFineSlower = -1,
|
||||||
|
TpmClockAdjustFineFaster = 1,
|
||||||
|
TpmClockAdjustMediumFaster = 2,
|
||||||
|
TpmClockAdjustCoarseFaster = 3
|
||||||
|
} PLATFORM_TPM_CLOCK_ADJUST_STEP;
|
||||||
|
|
||||||
|
#define PLATFORM_TPM_TYPE_UNKNOWN 0x00
|
||||||
|
#define PLATFORM_TPM_TYPE_DISCRETE_CHIP 0x01
|
||||||
|
#define PLATFORM_TPM_TYPE_INTEGRATE_SOC 0x02
|
||||||
|
#define PLATFORM_TPM_TYPE_FTPM 0x03
|
||||||
|
#define PLATFORM_TPM_TYPE_VTPM 0x04
|
||||||
|
|
||||||
|
// ** From EPS.c
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat__GetEPS()
|
||||||
|
|
||||||
|
This function used to generate Endorsement Seed when
|
||||||
|
first initailization of TPM.
|
||||||
|
|
||||||
|
EPS can be generated, for example, as follows:
|
||||||
|
|
||||||
|
EPS = SHA-512(TRNG_output || nonce || optional_mixing || DeviceUnique)
|
||||||
|
|
||||||
|
Alternatively, EPS can be generated using DRBG_Generate(),
|
||||||
|
as done in the TCG TPM 2.0 reference implementation.
|
||||||
|
|
||||||
|
This function is not expected to fail; however,
|
||||||
|
if it does have the potential to fail,
|
||||||
|
the platform should handle the failure appropriately,
|
||||||
|
for example by disabling TPM functionality or
|
||||||
|
retrying the manufacturing process.
|
||||||
|
|
||||||
|
@param [in] Size Size of endorsement seed
|
||||||
|
@param [out] EndorsementSeed Endorsement Seed.
|
||||||
|
|
||||||
|
**/
|
||||||
|
VOID
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibGetEPS (
|
||||||
|
IN UINT16 Size,
|
||||||
|
OUT UINT8 *EndorsementSeed
|
||||||
|
);
|
||||||
|
|
||||||
|
// ** From Clock.c
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat__TimerReset()
|
||||||
|
|
||||||
|
This function sets current system clock time as t0 for counting TPM time.
|
||||||
|
This function is called at a power on event to reset the clock. When the clock
|
||||||
|
is reset, the indication that the clock was stopped is also set.
|
||||||
|
|
||||||
|
**/
|
||||||
|
VOID
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibTimerReset (
|
||||||
|
VOID
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat__TimerRestart()
|
||||||
|
|
||||||
|
This function should be called in order to simulate the restart of the timer
|
||||||
|
should it be stopped while power is still applied.
|
||||||
|
|
||||||
|
**/
|
||||||
|
VOID
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibTimerRestart (
|
||||||
|
VOID
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat__RealTime()
|
||||||
|
|
||||||
|
This is another, probably futile, attempt to define a portable function
|
||||||
|
that will return a 64-bit clock value that has mSec resolution.
|
||||||
|
|
||||||
|
@return value realtime
|
||||||
|
|
||||||
|
**/
|
||||||
|
UINT64
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibRealTime (
|
||||||
|
VOID
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat__TimerRead()
|
||||||
|
|
||||||
|
This function provides access to the tick timer of the platform. The TPM code
|
||||||
|
uses this value to drive the TPM Clock.
|
||||||
|
|
||||||
|
The tick timer is supposed to run when power is applied to the device. This timer
|
||||||
|
should not be reset by time events including _TPM_Init. It should only be reset
|
||||||
|
when TPM power is re-applied.
|
||||||
|
|
||||||
|
If the TPM is run in a protected environment, that environment may provide the
|
||||||
|
tick time to the TPM as long as the time provided by the environment is not
|
||||||
|
allowed to go backwards. If the time provided by the system can go backwards
|
||||||
|
during a power discontinuity, then the _plat__Signal_PowerOn should call
|
||||||
|
_plat__TimerReset().
|
||||||
|
|
||||||
|
@return value timeval
|
||||||
|
|
||||||
|
**/
|
||||||
|
UINT64
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibTimerRead (
|
||||||
|
VOID
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat__TimerWasReset()
|
||||||
|
|
||||||
|
This function is used to interrogate the flag indicating if the tick timer has
|
||||||
|
been reset.
|
||||||
|
|
||||||
|
If the resetFlag parameter is SET, then the flag will be CLEAR before the
|
||||||
|
function returns.
|
||||||
|
|
||||||
|
@return TRUE Timer was reset.
|
||||||
|
@return FALSE Timer wasn't reset.
|
||||||
|
|
||||||
|
**/
|
||||||
|
INT32
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibTimerWasReset (
|
||||||
|
VOID
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat__TimerWasStopped()
|
||||||
|
|
||||||
|
This function is used to interrogate the flag indicating if the tick timer has
|
||||||
|
been stopped. If so, this is typically a reason to roll the nonce.
|
||||||
|
|
||||||
|
This function will CLEAR the s_timerStopped flag before returning. This provides
|
||||||
|
functionality that is similar to status register that is cleared when read. This
|
||||||
|
is the model used here because it is the one that has the most impact on the TPM
|
||||||
|
code as the flag can only be accessed by one entity in the TPM. Any other
|
||||||
|
implementation of the hardware can be made to look like a read-once register.
|
||||||
|
|
||||||
|
@return TRUE timer was stopped
|
||||||
|
@return FALSE timer wasn't stopped
|
||||||
|
|
||||||
|
**/
|
||||||
|
BOOLEAN
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibTimerWasStopped (
|
||||||
|
VOID
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat__ClockAdjustRate()
|
||||||
|
|
||||||
|
Adjust the clock rate.
|
||||||
|
|
||||||
|
@param [in] Adjust The adjust number. It could be positive
|
||||||
|
|
||||||
|
**/
|
||||||
|
VOID
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibClockAdjustRate (
|
||||||
|
IN INT32 Adjust
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat__GetEntropy()
|
||||||
|
|
||||||
|
This function is used to get available hardware entropy. In a hardware
|
||||||
|
implementation of this function, there would be no call to the system
|
||||||
|
to get entropy.
|
||||||
|
|
||||||
|
@param [out] Entropy output buffer
|
||||||
|
@param [in] Amount amount reuqested.
|
||||||
|
|
||||||
|
@return < 0 Failed to generate entropy
|
||||||
|
@return >= 0 The returned amount of entropy (bytes)
|
||||||
|
|
||||||
|
**/
|
||||||
|
INT32
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibGetEntropy (
|
||||||
|
OUT UINT8 *Entropy,
|
||||||
|
IN UINT32 Amount
|
||||||
|
);
|
||||||
|
|
||||||
|
// ** From NVMem.c
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat__NVEnable()
|
||||||
|
|
||||||
|
Enable NV memory.
|
||||||
|
|
||||||
|
the NV state would be read in, decrypted and integrity checked if needs.
|
||||||
|
|
||||||
|
The recovery from an integrity failure depends on where the error occurred. It
|
||||||
|
it was in the state that is discarded by TPM Reset, then the error is
|
||||||
|
recoverable if the TPM is reset. Otherwise, the TPM must go into failure mode.
|
||||||
|
|
||||||
|
@param [in] PlatParameter Platform parameter to enable NV storage
|
||||||
|
@param [in] ParamSize Size of PlatParameter
|
||||||
|
|
||||||
|
@return 0 if success
|
||||||
|
@return > 0 if receive recoverable error
|
||||||
|
@return < 0 if unrecoverable error
|
||||||
|
|
||||||
|
**/
|
||||||
|
INT32
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibNVEnable (
|
||||||
|
IN VOID *PlatParameter,
|
||||||
|
IN UINTN ParamSize
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat__NVDisable()
|
||||||
|
|
||||||
|
Disable NV memory.
|
||||||
|
|
||||||
|
**/
|
||||||
|
VOID
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibNVDisable (
|
||||||
|
VOID
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat__GetNvReadyState()
|
||||||
|
|
||||||
|
Check if NV is available.
|
||||||
|
|
||||||
|
@return 0 NV is available
|
||||||
|
@return 1 NV is not available due to write failure
|
||||||
|
@return 2 NV is not available due to rate limit
|
||||||
|
|
||||||
|
**/
|
||||||
|
INT32
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibGetNvReadyState (
|
||||||
|
VOID
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat__NvMemoryRead()
|
||||||
|
|
||||||
|
Read a chunk of NV memory.
|
||||||
|
|
||||||
|
@param [in] StartOffset Read start offset
|
||||||
|
@param [in] Size Size to read
|
||||||
|
@param [out] Data Data buffer
|
||||||
|
|
||||||
|
@return 1 Success to read
|
||||||
|
@return 0 Failed to read
|
||||||
|
|
||||||
|
**/
|
||||||
|
INT32
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibNvMemoryRead (
|
||||||
|
IN UINT32 StartOffset,
|
||||||
|
IN UINT32 Size,
|
||||||
|
OUT VOID *Data
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat__NvGetChangedStatus()
|
||||||
|
|
||||||
|
This function checks to see if the NV is different from the test value
|
||||||
|
so that NV will not be written if it has not changed.
|
||||||
|
|
||||||
|
@param [in] StartOffset Start offset to compare
|
||||||
|
@param [in] Size Size for compare
|
||||||
|
@param [in] Data Data to be compared
|
||||||
|
|
||||||
|
@return NV_HAS_CHANGED(1) the NV location is different from the test value
|
||||||
|
@return NV_IS_SAME(0) the NV location is the same as the test value
|
||||||
|
@return NV_INVALID_LOCATION(-1) the NV location is invalid; also triggers failure mode
|
||||||
|
**/
|
||||||
|
INT32
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibNvGetChangedStatus (
|
||||||
|
IN UINT32 StartOffset,
|
||||||
|
IN UINT32 Size,
|
||||||
|
IN VOID *Data
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat__NvMemoryWrite()
|
||||||
|
|
||||||
|
This function is used to update NV memory. The "write" is to a memory copy of
|
||||||
|
NV. At the end of the current command, any changes are written to
|
||||||
|
the actual NV memory.
|
||||||
|
|
||||||
|
NOTE: A useful optimization would be for this code to compare the current
|
||||||
|
contents of NV with the local copy and note the blocks that have changed. Then
|
||||||
|
only write those blocks when _plat__NvCommit() is called.
|
||||||
|
|
||||||
|
@param [in] StartOffset Start Offset to write
|
||||||
|
@param [in] Size Size to wrrite
|
||||||
|
@param [in] Data Data
|
||||||
|
|
||||||
|
@return 0 Failed to write
|
||||||
|
@return 1 Success to write
|
||||||
|
|
||||||
|
**/
|
||||||
|
INT32
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibNvMemoryWrite (
|
||||||
|
IN UINT32 StartOffset,
|
||||||
|
IN UINT32 Size,
|
||||||
|
IN VOID *Data
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat__NvMemoryClear()
|
||||||
|
|
||||||
|
Function is used to set a range of NV memory bytes to an implementation-dependent
|
||||||
|
value. The value represents the erase state of the memory.
|
||||||
|
|
||||||
|
@param [in] StartOffset Start offset to clear
|
||||||
|
@param [in] SIze Size to be clear
|
||||||
|
|
||||||
|
|
||||||
|
@return 0 Failed to clear
|
||||||
|
@return 1 Success
|
||||||
|
|
||||||
|
**/
|
||||||
|
INT32
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibNvMemoryClear (
|
||||||
|
IN UINT32 StartOffset,
|
||||||
|
IN UINT32 Size
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat__NvMemoryMove()
|
||||||
|
|
||||||
|
Function: Move a chunk of NV memory from source to destination
|
||||||
|
This function should ensure that if there overlap, the original data is
|
||||||
|
copied before it is written.
|
||||||
|
|
||||||
|
@param [in] SourceOffset Source offset to move
|
||||||
|
@param [in] DestOffset Destination offset to move
|
||||||
|
@param [in] Size Size to be moved
|
||||||
|
|
||||||
|
@return 0 Failed to move
|
||||||
|
@return 1 Success
|
||||||
|
|
||||||
|
**/
|
||||||
|
INT32
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibNvMemoryMove (
|
||||||
|
IN UINT32 SourceOffset,
|
||||||
|
IN UINT32 DestOffset,
|
||||||
|
IN UINT32 Size
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat__NvCommit()
|
||||||
|
|
||||||
|
This function writes the local copy of NV to NV for permanent store.
|
||||||
|
It will write TPM_NV_MEMORY_SIZE bytes to NV.
|
||||||
|
|
||||||
|
@return 0 NV write success
|
||||||
|
@return non-0 NV write fail
|
||||||
|
|
||||||
|
**/
|
||||||
|
INT32
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibNvCommit (
|
||||||
|
VOID
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat__SetNvAvail()
|
||||||
|
|
||||||
|
Set the current NV state to available.
|
||||||
|
This function is for testing purpose only.
|
||||||
|
It is not part of the platform NV logic
|
||||||
|
|
||||||
|
**/
|
||||||
|
VOID
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibSetNvAvail (
|
||||||
|
VOID
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat__ClearNvAvail()
|
||||||
|
|
||||||
|
Set the current NV state to unavailable.
|
||||||
|
This function is for testing purpose only.
|
||||||
|
It is not part of the platform NV logic.
|
||||||
|
|
||||||
|
**/
|
||||||
|
VOID
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibClearNvAvail (
|
||||||
|
VOID
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat__NVNeedsManufacture()
|
||||||
|
|
||||||
|
This function checks whether TPM's NV state needs to be manufactured.
|
||||||
|
|
||||||
|
@return TRUE TPM's NV storage should be manufactured
|
||||||
|
@return FALSE TPM's NV storage is already manufactured
|
||||||
|
|
||||||
|
**/
|
||||||
|
BOOLEAN
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibNVNeedsManufacture (
|
||||||
|
VOID
|
||||||
|
);
|
||||||
|
|
||||||
|
// ** From Unique.c
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat__GetUnique()
|
||||||
|
|
||||||
|
This function is used to access the platform-specific unique value.
|
||||||
|
This function places the unique value in the provided Buffer ('b')
|
||||||
|
and returns the number of bytes transferred. The function will not
|
||||||
|
copy more data than 'Size'.
|
||||||
|
|
||||||
|
NOTE: If a platform unique value has unequal distribution of uniqueness
|
||||||
|
and 'Size' is smaller than the size of the unique value, the 'Size'
|
||||||
|
portion with the most uniqueness should be returned.
|
||||||
|
|
||||||
|
@param [in] Which if == 0, Copy unique value from start
|
||||||
|
otherwise, copy from end
|
||||||
|
@param [in] Size Size of Buffer
|
||||||
|
@param [out] Buffer Output Buffer
|
||||||
|
|
||||||
|
@return Size of unique value.
|
||||||
|
|
||||||
|
**/
|
||||||
|
UINT32
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibGetUnique (
|
||||||
|
IN UINT32 Which,
|
||||||
|
IN UINT32 Size,
|
||||||
|
OUT UINT8 *Buffer
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat__GetManufacturerCapabilityCode()
|
||||||
|
|
||||||
|
return the 4 character Manufacturer Capability code.
|
||||||
|
This should come from the platform library since
|
||||||
|
that is provided by the manufacturer.
|
||||||
|
|
||||||
|
|
||||||
|
@return Manufacturer capability Code.
|
||||||
|
|
||||||
|
**/
|
||||||
|
UINT32
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibGetManufacturerCapabilityCode (
|
||||||
|
VOID
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat__GetVendorCapabilityCode()
|
||||||
|
|
||||||
|
return the 4 character VendorStrings for Capabilities.
|
||||||
|
Index is ONE-BASED, and may be in the range [1,4] inclusive.
|
||||||
|
Any other index returns all zeros. The return value will be interpreted
|
||||||
|
as an array of 4 ASCII characters (with no null terminator).
|
||||||
|
|
||||||
|
@param[in] Index index
|
||||||
|
|
||||||
|
@return Vendor specific capability code.
|
||||||
|
|
||||||
|
**/
|
||||||
|
UINT32
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibGetVendorCapabilityCode (
|
||||||
|
IN INT32 Index
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat__GetTpmFirmwareVersionHigh()
|
||||||
|
|
||||||
|
return the most-significant 32-bits of the TPM Firmware Version
|
||||||
|
|
||||||
|
@return High 32-bits of TPM Firmware Version.
|
||||||
|
|
||||||
|
**/
|
||||||
|
UINT32
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibGetTpmFirmwareVersionHigh (
|
||||||
|
VOID
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat__GetTpmFirmwareVersionLow()
|
||||||
|
|
||||||
|
return the least-significant 32-bits of the TPM Firmware Version
|
||||||
|
|
||||||
|
@return Low 32-bits of TPM Firmware Version.
|
||||||
|
|
||||||
|
**/
|
||||||
|
UINT32
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibGetTpmFirmwareVersionLow (
|
||||||
|
VOID
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat__GetTpmFirmwareSvn()
|
||||||
|
|
||||||
|
return the TPM Firmware current SVN.
|
||||||
|
|
||||||
|
@return current SVN.
|
||||||
|
|
||||||
|
**/
|
||||||
|
UINT16
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibGetTpmFirmwareSvn (
|
||||||
|
VOID
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat__GetTpmFirmwareMaxSvn()
|
||||||
|
|
||||||
|
return the TPM Firmware maximum SVN.
|
||||||
|
|
||||||
|
@return Maximum SVN.
|
||||||
|
|
||||||
|
**/
|
||||||
|
UINT16
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibGetTpmFirmwareMaxSvn (
|
||||||
|
VOID
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat__GetTpmFirmwareSvnSecret()
|
||||||
|
|
||||||
|
return the TPM Firmware SVN Secret value associated with SVN
|
||||||
|
|
||||||
|
@param[in] Svn Svn
|
||||||
|
@param[in] SecretBufferSize Secret Buffer Size
|
||||||
|
@param[out] SecretBuffer Secret Buffer
|
||||||
|
@param[out] SecretSize Secret Svn Size
|
||||||
|
|
||||||
|
@return 0 Success
|
||||||
|
@return < 0 Error
|
||||||
|
|
||||||
|
**/
|
||||||
|
INT32
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibGetTpmFirmwareSvnSecret (
|
||||||
|
IN UINT16 Svn,
|
||||||
|
IN UINT16 SecretBufferSize,
|
||||||
|
OUT UINT8 *SecretBuffer,
|
||||||
|
OUT UINT16 *SecretSize
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat__GetTpmFirmwareSecret()
|
||||||
|
|
||||||
|
return the TPM Firmware Secret value associated with SVN
|
||||||
|
|
||||||
|
@param[in] SecretBufferSize Secret Buffer Size
|
||||||
|
@param[out] SecretBuffer Secret Buffer
|
||||||
|
@param[out] SecretSize Secret Svn Size
|
||||||
|
|
||||||
|
@return 0 Success
|
||||||
|
@return < 0 Error
|
||||||
|
|
||||||
|
**/
|
||||||
|
INT32
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibGetTpmFirmwareSecret (
|
||||||
|
IN UINT16 SecretBufferSize,
|
||||||
|
OUT UINT8 *SecretBuffer,
|
||||||
|
OUT UINT16 *SecretSize
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat__GetVendorTpmType()
|
||||||
|
|
||||||
|
return the Platform TPM type.
|
||||||
|
|
||||||
|
@return TPM type.
|
||||||
|
|
||||||
|
**/
|
||||||
|
UINT32
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibGetVendorTpmType (
|
||||||
|
VOID
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat__GetPlatformManufactureData
|
||||||
|
|
||||||
|
This function allows the platform to provide a small amount of data to be
|
||||||
|
stored as part of the TPM's PERSISTENT_DATA structure during manufacture.
|
||||||
|
Of course the platform can store data separately as well,
|
||||||
|
but this allows a simple platform implementation to store
|
||||||
|
a few bytes of data without implementing a multi-layer storage system.
|
||||||
|
This function is called on manufacture and CLEAR.
|
||||||
|
The buffer will contain the last value provided
|
||||||
|
to the Core library.
|
||||||
|
|
||||||
|
@param[out] PlatformPersistentData Platform data.
|
||||||
|
@param[in] Size Size of PlatformPersistentData.
|
||||||
|
|
||||||
|
**/
|
||||||
|
VOID
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibGetPlatformManufactureData (
|
||||||
|
UINT8 *PlatformPersistentData,
|
||||||
|
UINT32 Size
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat_internal_resetFailureData()
|
||||||
|
|
||||||
|
Reset platform specific failure data.
|
||||||
|
|
||||||
|
**/
|
||||||
|
VOID
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibInternalResetFailureData (
|
||||||
|
VOID
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat__InFailureMode()
|
||||||
|
|
||||||
|
Check whether platform is in the failure mode.
|
||||||
|
|
||||||
|
@return whether TPM is in failure mode or not
|
||||||
|
|
||||||
|
**/
|
||||||
|
BOOLEAN
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibInFailureMode (
|
||||||
|
VOID
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat__Fail()
|
||||||
|
|
||||||
|
This is the platform depended failure exit for the TPM.
|
||||||
|
|
||||||
|
@param[in] Function Function name where failure happens.
|
||||||
|
@param[in] Line line number where failure happens.
|
||||||
|
@param[in] LocationCode Location code where failure happens.
|
||||||
|
@param[in] FailureCode Fail reson.
|
||||||
|
|
||||||
|
**/
|
||||||
|
VOID
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibFail (
|
||||||
|
IN CONST CHAR8 *Function,
|
||||||
|
IN INT32 Line,
|
||||||
|
IN UINT64 LocationCode,
|
||||||
|
IN INT32 FailureCode
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat__GetFailureCode()
|
||||||
|
|
||||||
|
Get last failure code.
|
||||||
|
|
||||||
|
@return Last failure code.
|
||||||
|
|
||||||
|
**/
|
||||||
|
UINT32
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibGetFailureCode (
|
||||||
|
VOID
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat__GetFailureLocation()
|
||||||
|
|
||||||
|
Get last failure location.
|
||||||
|
|
||||||
|
@return Last failure location code.
|
||||||
|
|
||||||
|
**/
|
||||||
|
UINT64
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibGetFailureLocation (
|
||||||
|
VOID
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat__GetFailureFunctionName()
|
||||||
|
|
||||||
|
Get last function name where failed.
|
||||||
|
|
||||||
|
@return Last function name where failed.
|
||||||
|
|
||||||
|
**/
|
||||||
|
CONST CHAR8 *
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibGetFailureFunctionName (
|
||||||
|
VOID
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat__GetFailureLine()
|
||||||
|
|
||||||
|
Get last failure line.
|
||||||
|
|
||||||
|
@return Last line number where failed.
|
||||||
|
|
||||||
|
**/
|
||||||
|
UINT32
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibGetFailureLine (
|
||||||
|
VOID
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
This function is called in TpmLibConstructor() to
|
||||||
|
initialise PlatformTpmLib once.
|
||||||
|
|
||||||
|
@return EFI_SUCCESS Success
|
||||||
|
@return Others Errors
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibInit (
|
||||||
|
VOID
|
||||||
|
);
|
||||||
160
TcgTpmPkg/Library/PlatformTpmNullLib/Clock.c
Normal file
160
TcgTpmPkg/Library/PlatformTpmNullLib/Clock.c
Normal file
|
|
@ -0,0 +1,160 @@
|
||||||
|
/** @file
|
||||||
|
Clock part of PlatformTpmLib to use TpmLib.
|
||||||
|
|
||||||
|
Copyright (c) 2025, Arm Limited. All rights reserved.<BR>
|
||||||
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
|
|
||||||
|
**/
|
||||||
|
#include <Library/BaseLib.h>
|
||||||
|
#include <Library/PlatformTpmLib.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat__TimerReset()
|
||||||
|
|
||||||
|
This function sets current system clock time as t0 for counting TPM time.
|
||||||
|
This function is called at a power on event to reset the clock. When the clock
|
||||||
|
is reset, the indication that the clock was stopped is also set.
|
||||||
|
|
||||||
|
**/
|
||||||
|
VOID
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibTimerReset (
|
||||||
|
VOID
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat__TimerRestart()
|
||||||
|
|
||||||
|
This function should be called in order to simulate the restart of the timer
|
||||||
|
should it be stopped while power is still applied.
|
||||||
|
|
||||||
|
**/
|
||||||
|
VOID
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibTimerRestart (
|
||||||
|
VOID
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat__RealTime()
|
||||||
|
|
||||||
|
This is another, probably futile, attempt to define a portable function
|
||||||
|
that will return a 64-bit clock value that has mSec resolution.
|
||||||
|
|
||||||
|
@return value realtime
|
||||||
|
|
||||||
|
**/
|
||||||
|
UINT64
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibRealTime (
|
||||||
|
VOID
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat__TimerRead()
|
||||||
|
|
||||||
|
This function provides access to the tick timer of the platform. The TPM code
|
||||||
|
uses this value to drive the TPM Clock.
|
||||||
|
|
||||||
|
The tick timer is supposed to run when power is applied to the device. This timer
|
||||||
|
should not be reset by time events including _TPM_Init. It should only be reset
|
||||||
|
when TPM power is re-applied.
|
||||||
|
|
||||||
|
If the TPM is run in a protected environment, that environment may provide the
|
||||||
|
tick time to the TPM as long as the time provided by the environment is not
|
||||||
|
allowed to go backwards. If the time provided by the system can go backwards
|
||||||
|
during a power discontinuity, then the _plat__Signal_PowerOn should call
|
||||||
|
_plat__TimerReset().
|
||||||
|
|
||||||
|
@return value timeval
|
||||||
|
|
||||||
|
**/
|
||||||
|
UINT64
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibTimerRead (
|
||||||
|
VOID
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat__TimerWasReset()
|
||||||
|
|
||||||
|
This function is used to interrogate the flag indicating if the tick timer has
|
||||||
|
been reset.
|
||||||
|
|
||||||
|
If the resetFlag parameter is SET, then the flag will be CLEAR before the
|
||||||
|
function returns.
|
||||||
|
|
||||||
|
@return 0 Timer wasn't reset.
|
||||||
|
@return others Timer was reset.
|
||||||
|
|
||||||
|
**/
|
||||||
|
INT32
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibTimerWasReset (
|
||||||
|
VOID
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat__TimerWasStopped()
|
||||||
|
|
||||||
|
This function is used to interrogate the flag indicating if the tick timer has
|
||||||
|
been stopped. If so, this is typically a reason to roll the nonce.
|
||||||
|
|
||||||
|
This function will CLEAR the s_timerStopped flag before returning. This provides
|
||||||
|
functionality that is similar to status register that is cleared when read. This
|
||||||
|
is the model used here because it is the one that has the most impact on the TPM
|
||||||
|
code as the flag can only be accessed by one entity in the TPM. Any other
|
||||||
|
implementation of the hardware can be made to look like a read-once register.
|
||||||
|
|
||||||
|
@return TRUE timer was stopped
|
||||||
|
@return FALSE timer wasn't stopped
|
||||||
|
|
||||||
|
**/
|
||||||
|
BOOLEAN
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibTimerWasStopped (
|
||||||
|
VOID
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat__ClockAdjustRate()
|
||||||
|
|
||||||
|
ClockRateAdjust uses predefined signal values and encapsulates the platform
|
||||||
|
specifics regarding the number of ticks the underlying clock is running at.
|
||||||
|
|
||||||
|
The adjustment must be one of these values. A COARSE adjustment is 1%, MEDIUM
|
||||||
|
is 0.1%, and FINE is the smallest amount supported by the platform. The
|
||||||
|
total (cumulative) adjustment is limited to ~15% total. Attempts to adjust
|
||||||
|
the clock further are silently ignored as are any invalid values. These
|
||||||
|
values are defined here to insulate them from spec changes and to avoid
|
||||||
|
needing visibility to the doc-generated structure headers.
|
||||||
|
|
||||||
|
@param [in] Adjust The adjust number. It could be positive
|
||||||
|
|
||||||
|
**/
|
||||||
|
VOID
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibClockAdjustRate (
|
||||||
|
IN INT32 Adjust
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
45
TcgTpmPkg/Library/PlatformTpmNullLib/EPS.c
Normal file
45
TcgTpmPkg/Library/PlatformTpmNullLib/EPS.c
Normal file
|
|
@ -0,0 +1,45 @@
|
||||||
|
/** @file
|
||||||
|
Endoresment Seed generation part of PlatformTpmLib to use TpmLib.
|
||||||
|
|
||||||
|
To see the plat_XXX interface in TPM reference library, see:
|
||||||
|
- https://github.com/TrustedComputingGroup/TPM/tree/main/TPMCmd/Platform/src
|
||||||
|
|
||||||
|
Copyright (c) 2025, Arm Limited. All rights reserved.<BR>
|
||||||
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
|
|
||||||
|
**/
|
||||||
|
#include <Library/BaseLib.h>
|
||||||
|
#include <Library/PlatformTpmLib.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat__GetEPS()
|
||||||
|
|
||||||
|
This function used to generate Endorsement Seed when
|
||||||
|
first initailization of TPM.
|
||||||
|
|
||||||
|
EPS can be generated, for example, as follows:
|
||||||
|
|
||||||
|
EPS = SHA-512(TRNG_output || nonce || optional_mixing || DeviceUnique)
|
||||||
|
|
||||||
|
Alternatively, EPS can be generated using DRBG_Generate(),
|
||||||
|
as done in the TCG TPM 2.0 reference implementation.
|
||||||
|
|
||||||
|
This function is not expected to fail; however,
|
||||||
|
if it does have the potential to fail,
|
||||||
|
the platform should handle the failure appropriately,
|
||||||
|
for example by disabling TPM functionality or
|
||||||
|
retrying the manufacturing process.
|
||||||
|
|
||||||
|
@param [in] Size Size of endorsement seed
|
||||||
|
@param [out] EndorsementSeed Endorsement Seed.
|
||||||
|
|
||||||
|
**/
|
||||||
|
VOID
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibGetEPS (
|
||||||
|
IN UINT16 Size,
|
||||||
|
OUT UINT8 *EndorsementSeed
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
36
TcgTpmPkg/Library/PlatformTpmNullLib/Entropy.c
Normal file
36
TcgTpmPkg/Library/PlatformTpmNullLib/Entropy.c
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
/** @file
|
||||||
|
Get entropy part of PlatformTpmLib to use TpmLib.
|
||||||
|
|
||||||
|
To see the plat_XXX interfaces in TPM reference library, see:
|
||||||
|
- https://github.com/TrustedComputingGroup/TPM/tree/main/TPMCmd/Platform/src
|
||||||
|
|
||||||
|
Copyright (c) 2025, Arm Limited. All rights reserved.<BR>
|
||||||
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
|
|
||||||
|
**/
|
||||||
|
#include <Library/BaseLib.h>
|
||||||
|
#include <Library/PlatformTpmLib.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat__GetEntropy()
|
||||||
|
|
||||||
|
This function is used to get available hardware entropy. In a hardware
|
||||||
|
implementation of this function, there would be no call to the system
|
||||||
|
to get entropy.
|
||||||
|
|
||||||
|
@param [out] Entropy output buffer.
|
||||||
|
@param [in] Amount amount reuqested.
|
||||||
|
|
||||||
|
@return < 0 Failed to generate entropy
|
||||||
|
@return >= 0 The returned amount of entropy (bytes)
|
||||||
|
|
||||||
|
**/
|
||||||
|
INT32
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibGetEntropy (
|
||||||
|
OUT UINT8 *Entropy,
|
||||||
|
IN UINT32 Amount
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
45
TcgTpmPkg/Library/PlatformTpmNullLib/ExtraData.c
Normal file
45
TcgTpmPkg/Library/PlatformTpmNullLib/ExtraData.c
Normal file
|
|
@ -0,0 +1,45 @@
|
||||||
|
/** @file
|
||||||
|
Endoresment Seed generation part of PlatformTpmLib to use TpmLib.
|
||||||
|
|
||||||
|
To see the plat_XXX interface in TPM reference library, see:
|
||||||
|
- https://github.com/TrustedComputingGroup/TPM/tree/main/TPMCmd/Platform/src
|
||||||
|
|
||||||
|
Copyright (c) 2025, Arm Limited. All rights reserved.<BR>
|
||||||
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
|
|
||||||
|
**/
|
||||||
|
#include <Library/BaseLib.h>
|
||||||
|
#include <Library/BaseMemoryLib.h>
|
||||||
|
#include <Library/PlatformTpmLib.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat__GetPlatformManufactureData
|
||||||
|
|
||||||
|
This function allows the platform to provide a small amount of data to be
|
||||||
|
stored as part of the TPM's PERSISTENT_DATA structure during manufacture.
|
||||||
|
Of course the platform can store data separately as well,
|
||||||
|
but this allows a simple platform implementation to store
|
||||||
|
a few bytes of data without implementing a multi-layer storage system.
|
||||||
|
This function is called on manufacture and CLEAR.
|
||||||
|
The buffer will contain the last value provided
|
||||||
|
to the Core library.
|
||||||
|
|
||||||
|
@param[out] PlatformPersistentData Platform data.
|
||||||
|
@param[in] Size Size of PlatformPersistentData.
|
||||||
|
|
||||||
|
**/
|
||||||
|
VOID
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibGetPlatformManufactureData (
|
||||||
|
UINT8 *PlatformPersistentData,
|
||||||
|
UINT32 Size
|
||||||
|
)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Using TCG Tpm library's implementation.
|
||||||
|
* See TPMCmd/Platform/src/ExtraData.c
|
||||||
|
*/
|
||||||
|
if ((PlatformPersistentData != NULL) && (Size != 0)) {
|
||||||
|
SetMem (PlatformPersistentData, Size, 0xFF);
|
||||||
|
}
|
||||||
|
}
|
||||||
161
TcgTpmPkg/Library/PlatformTpmNullLib/Failure.c
Normal file
161
TcgTpmPkg/Library/PlatformTpmNullLib/Failure.c
Normal file
|
|
@ -0,0 +1,161 @@
|
||||||
|
/** @file
|
||||||
|
This module provides the platform specific entry and fail processing. The
|
||||||
|
PlatformTpmLibFail() function is used to call to ExecuteCommand() in the TPM code.
|
||||||
|
This function does whatever processing is necessary to set up the platform
|
||||||
|
in anticipation of the call to the TPM including settup for error processing.
|
||||||
|
|
||||||
|
The PlatformTpmLib() function is called when there is a failure in the TPM.
|
||||||
|
The TPM code will have set the flag to indicate that the TPM is in failure mode.
|
||||||
|
This call will then recursively call ExecuteCommand in order to build the
|
||||||
|
failure mode response. When ExecuteCommand() returns to PlatformTpmLib(), the
|
||||||
|
platform will do some platform specific operation to return to the environment in
|
||||||
|
which the TPM is executing.
|
||||||
|
|
||||||
|
To see the plat_XXX interfaces in TPM reference library, see:
|
||||||
|
- https://github.com/TrustedComputingGroup/TPM/tree/main/TPMCmd/Platform/src
|
||||||
|
|
||||||
|
Copyright (c) 2025, Arm Limited. All rights reserved.<BR>
|
||||||
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
|
|
||||||
|
**/
|
||||||
|
#include <Library/BaseLib.h>
|
||||||
|
#include <Library/PlatformTpmLib.h>
|
||||||
|
|
||||||
|
STATIC BOOLEAN InFailureMode;
|
||||||
|
STATIC CONST CHAR8 *LastFailedFuncName;
|
||||||
|
STATIC UINT32 LastFailedLineNumber;
|
||||||
|
STATIC UINT64 LastFailedLocation;
|
||||||
|
STATIC UINT32 LastFailedCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat_internal_resetFailureData()
|
||||||
|
|
||||||
|
Reset platform specific failure data.
|
||||||
|
|
||||||
|
**/
|
||||||
|
VOID
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibInternalResetFailureData (
|
||||||
|
VOID
|
||||||
|
)
|
||||||
|
{
|
||||||
|
InFailureMode = FALSE;
|
||||||
|
LastFailedFuncName = NULL;
|
||||||
|
LastFailedLineNumber = 0;
|
||||||
|
LastFailedLocation = 0;
|
||||||
|
LastFailedCode = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat__InFailureMode()
|
||||||
|
|
||||||
|
Check whether platform is in the failure mode.
|
||||||
|
|
||||||
|
@return whether TPM is in failure mode or not
|
||||||
|
|
||||||
|
**/
|
||||||
|
BOOLEAN
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibInFailureMode (
|
||||||
|
VOID
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return InFailureMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat__Fail()
|
||||||
|
|
||||||
|
This is the platform depended failure exit for the TPM.
|
||||||
|
|
||||||
|
@param[in] Function Function name where failure happens.
|
||||||
|
@param[in] Line line number where failure happens.
|
||||||
|
@param[in] LocationCode Location code where failure happens.
|
||||||
|
@param[in] FailureCode Fail reson.
|
||||||
|
|
||||||
|
**/
|
||||||
|
VOID
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibFail (
|
||||||
|
IN CONST CHAR8 *Function,
|
||||||
|
IN INT32 Line,
|
||||||
|
IN UINT64 LocationCode,
|
||||||
|
IN INT32 FailureCode
|
||||||
|
)
|
||||||
|
{
|
||||||
|
InFailureMode = TRUE;
|
||||||
|
LastFailedFuncName = Function;
|
||||||
|
LastFailedLineNumber = Line;
|
||||||
|
LastFailedLocation = LocationCode;
|
||||||
|
LastFailedCode = FailureCode;
|
||||||
|
|
||||||
|
CpuDeadLoop ();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat__GetFailureCode()
|
||||||
|
|
||||||
|
Get last failure code.
|
||||||
|
|
||||||
|
@return Last failure code.
|
||||||
|
|
||||||
|
**/
|
||||||
|
UINT32
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibGetFailureCode (
|
||||||
|
VOID
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return LastFailedCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat__GetFailureLocation()
|
||||||
|
|
||||||
|
Get last failure location.
|
||||||
|
|
||||||
|
@return Last failure location code.
|
||||||
|
|
||||||
|
**/
|
||||||
|
UINT64
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibGetFailureLocation (
|
||||||
|
VOID
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return LastFailedLocation;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat__GetFailureFunctionName()
|
||||||
|
|
||||||
|
Get last failure location.
|
||||||
|
|
||||||
|
@return Last function name where failed.
|
||||||
|
|
||||||
|
**/
|
||||||
|
CONST CHAR8 *
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibGetFailureFunctionName (
|
||||||
|
VOID
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return LastFailedFuncName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat__GetFailureLine()
|
||||||
|
|
||||||
|
Get last failure line.
|
||||||
|
|
||||||
|
@return Last line number where failed.
|
||||||
|
|
||||||
|
**/
|
||||||
|
UINT32
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibGetFailureLine (
|
||||||
|
VOID
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return LastFailedLineNumber;
|
||||||
|
}
|
||||||
26
TcgTpmPkg/Library/PlatformTpmNullLib/Init.c
Normal file
26
TcgTpmPkg/Library/PlatformTpmNullLib/Init.c
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
/** @file
|
||||||
|
Platform specific Initialisation for PlatformTpmLib.
|
||||||
|
|
||||||
|
Copyright (c) 2025, Arm Limited. All rights reserved.<BR>
|
||||||
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
|
|
||||||
|
**/
|
||||||
|
#include <Library/BaseLib.h>
|
||||||
|
#include <Library/PlatformTpmLib.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
This function is called in TpmLibConstructor() to
|
||||||
|
initialise PlatformTpmLib once.
|
||||||
|
|
||||||
|
@return EFI_SUCCESS Success
|
||||||
|
@return Others Errors
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibInit (
|
||||||
|
VOID
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
277
TcgTpmPkg/Library/PlatformTpmNullLib/NVMem.c
Normal file
277
TcgTpmPkg/Library/PlatformTpmNullLib/NVMem.c
Normal file
|
|
@ -0,0 +1,277 @@
|
||||||
|
/** @file
|
||||||
|
Tpm Nv Storage part of PlatformTpmLib to use TpmLib.
|
||||||
|
|
||||||
|
To see the plat_XXX interfaces in TPM reference library, see:
|
||||||
|
- https://github.com/TrustedComputingGroup/TPM/tree/main/TPMCmd/Platform/src
|
||||||
|
|
||||||
|
Copyright (c) 2025, Arm Limited. All rights reserved.<BR>
|
||||||
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
|
|
||||||
|
**/
|
||||||
|
#include <Library/BaseLib.h>
|
||||||
|
#include <Library/PlatformTpmLib.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat__NVNeedsManufacture()
|
||||||
|
|
||||||
|
This function checks whether TPM's NV state needs to be manufactured.
|
||||||
|
|
||||||
|
@return TRUE TPM's NV storage should be manufactured
|
||||||
|
@return FALSE TPM's NV storage is already manufactured
|
||||||
|
|
||||||
|
**/
|
||||||
|
BOOLEAN
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibNVNeedsManufacture (
|
||||||
|
VOID
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat__NVEnable()
|
||||||
|
|
||||||
|
Enable NV memory.
|
||||||
|
|
||||||
|
the NV state would be read in, decrypted and integrity checked if needs.
|
||||||
|
|
||||||
|
The recovery from an integrity failure depends on where the error occurred. It
|
||||||
|
it was in the state that is discarded by TPM Reset, then the error is
|
||||||
|
recoverable if the TPM is reset. Otherwise, the TPM must go into failure mode.
|
||||||
|
|
||||||
|
@param [in] PlatParameter Platform parameter to enable NV storage
|
||||||
|
@param [in] ParamSize Size of PlatParameter
|
||||||
|
|
||||||
|
@return 0 if success
|
||||||
|
@return > 0 if receive recoverable error
|
||||||
|
@return < 0 if unrecoverable error
|
||||||
|
|
||||||
|
**/
|
||||||
|
INT32
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibNVEnable (
|
||||||
|
IN VOID *PlatParameter,
|
||||||
|
IN UINTN ParamSize
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat__NVDisable()
|
||||||
|
|
||||||
|
Disable NV memory.
|
||||||
|
|
||||||
|
**/
|
||||||
|
VOID
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibNVDisable (
|
||||||
|
VOID
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat__GetNvReadyState()
|
||||||
|
|
||||||
|
Check if NV is available.
|
||||||
|
|
||||||
|
@return 0 NV is available
|
||||||
|
@return 1 NV is not available due to write failure
|
||||||
|
@return 2 NV is not available due to rate limit
|
||||||
|
|
||||||
|
**/
|
||||||
|
INT32
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibGetNvReadyState (
|
||||||
|
VOID
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat__NvMemoryRead()
|
||||||
|
|
||||||
|
Read a chunk of NV memory.
|
||||||
|
|
||||||
|
@param [in] StartOffset Read start offset
|
||||||
|
@param [in] Size Size to read
|
||||||
|
@param [out] Data Data buffer
|
||||||
|
|
||||||
|
@return 1 Success to read
|
||||||
|
@return 0 Failed to read
|
||||||
|
|
||||||
|
**/
|
||||||
|
INT32
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibNvMemoryRead (
|
||||||
|
IN UINT32 StartOffset,
|
||||||
|
IN UINT32 Size,
|
||||||
|
OUT VOID *Data
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat__NvGetChangedStatus()
|
||||||
|
|
||||||
|
This function checks to see if the NV is different from the test value
|
||||||
|
so that NV will not be written if it has not changed.
|
||||||
|
|
||||||
|
@param [in] StartOffset Start offset to compare
|
||||||
|
@param [in] Size Size for compare
|
||||||
|
@param [in] Data Data to be compared
|
||||||
|
|
||||||
|
@return NV_HAS_CHANGED(1) the NV location is different from the test value
|
||||||
|
@return NV_IS_SAME(0) the NV location is the same as the test value
|
||||||
|
@return NV_INVALID_LOCATION(-1) the NV location is invalid; also triggers failure mode
|
||||||
|
**/
|
||||||
|
INT32
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibNvGetChangedStatus (
|
||||||
|
IN UINT32 StartOffset,
|
||||||
|
IN UINT32 Size,
|
||||||
|
IN VOID *Data
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat__NvMemoryWrite()
|
||||||
|
|
||||||
|
This function is used to update NV memory. The "write" is to a memory copy of
|
||||||
|
NV. At the end of the current command, any changes are written to
|
||||||
|
the actual NV memory.
|
||||||
|
|
||||||
|
NOTE: A useful optimization would be for this code to compare the current
|
||||||
|
contents of NV with the local copy and note the blocks that have changed. Then
|
||||||
|
only write those blocks when _plat__NvCommit() is called.
|
||||||
|
|
||||||
|
@param [in] StartOffset Start Offset to write
|
||||||
|
@param [in] Size Size to wrrite
|
||||||
|
@param [in] Data Data
|
||||||
|
|
||||||
|
@return 0 Failed to write
|
||||||
|
@return 1 Success to write
|
||||||
|
|
||||||
|
**/
|
||||||
|
INT32
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibNvMemoryWrite (
|
||||||
|
IN UINT32 StartOffset,
|
||||||
|
IN UINT32 Size,
|
||||||
|
IN VOID *Data
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat__NvMemoryClear()
|
||||||
|
|
||||||
|
Function is used to set a range of NV memory bytes to an implementation-dependent
|
||||||
|
value. The value represents the erase state of the memory.
|
||||||
|
|
||||||
|
@param [in] StartOffset Start offset to clear
|
||||||
|
@param [in] SIze Size to be clear
|
||||||
|
|
||||||
|
|
||||||
|
@return 0 Failed to clear
|
||||||
|
@return 1 Success
|
||||||
|
|
||||||
|
**/
|
||||||
|
INT32
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibNvMemoryClear (
|
||||||
|
IN UINT32 StartOffset,
|
||||||
|
IN UINT32 Size
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat__NvMemoryMove()
|
||||||
|
|
||||||
|
Function: Move a chunk of NV memory from source to destination
|
||||||
|
This function should ensure that if there overlap, the original data is
|
||||||
|
copied before it is written.
|
||||||
|
|
||||||
|
@param [in] SourceOffset Source offset to move
|
||||||
|
@param [in] DestOffset Destination offset to move
|
||||||
|
@param [in] Size Size to be moved
|
||||||
|
|
||||||
|
@return 0 Failed to move
|
||||||
|
@return 1 Success
|
||||||
|
|
||||||
|
**/
|
||||||
|
INT32
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibNvMemoryMove (
|
||||||
|
IN UINT32 SourceOffset,
|
||||||
|
IN UINT32 DestOffset,
|
||||||
|
IN UINT32 Size
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat__NvCommit()
|
||||||
|
|
||||||
|
This function writes the local copy of NV to NV for permanent store.
|
||||||
|
It will write TPM_NV_MEMORY_SIZE bytes to NV.
|
||||||
|
|
||||||
|
@return 0 NV write success
|
||||||
|
@return non-0 NV write fail
|
||||||
|
|
||||||
|
**/
|
||||||
|
INT32
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibNvCommit (
|
||||||
|
VOID
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat__SetNvAvail()
|
||||||
|
|
||||||
|
Set the current NV state to available.
|
||||||
|
This function is for testing purpose only.
|
||||||
|
It is not part of the platform NV logic.
|
||||||
|
|
||||||
|
**/
|
||||||
|
VOID
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibSetNvAvail (
|
||||||
|
VOID
|
||||||
|
)
|
||||||
|
{
|
||||||
|
// NV will not be made unavailable on this platform
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat__ClearNvAvail()
|
||||||
|
|
||||||
|
Set the current NV state to unavailable.
|
||||||
|
This function is for testing purpose only.
|
||||||
|
It is not part of the platform NV logic.
|
||||||
|
|
||||||
|
**/
|
||||||
|
VOID
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibClearNvAvail (
|
||||||
|
VOID
|
||||||
|
)
|
||||||
|
{
|
||||||
|
// The anti-set; not on this platform.
|
||||||
|
return;
|
||||||
|
}
|
||||||
42
TcgTpmPkg/Library/PlatformTpmNullLib/PlatformTpmNullLib.inf
Normal file
42
TcgTpmPkg/Library/PlatformTpmNullLib/PlatformTpmNullLib.inf
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
## @file
|
||||||
|
# NULL instance library of the PlatformTpmLib used in TpmLib.
|
||||||
|
#
|
||||||
|
# Copyright (c) 2025, Arm Limited. All rights reserved.<BR>
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
|
##
|
||||||
|
|
||||||
|
[Defines]
|
||||||
|
INF_VERSION = 0x0001001A
|
||||||
|
BASE_NAME = PlatformTpmNullLib
|
||||||
|
FILE_GUID = 14992892-1dc5-11ef-b21c-97fa7f4b3198
|
||||||
|
MODULE_TYPE = BASE
|
||||||
|
VERSION_STRING = 1.0
|
||||||
|
PI_SPECIFICATION_VERSION = 0x00010032
|
||||||
|
LIBRARY_CLASS = PlatformTpmLib
|
||||||
|
|
||||||
|
#
|
||||||
|
# The following information is for reference only and not required by the build tools.
|
||||||
|
#
|
||||||
|
# VALID_ARCHITECTURES = ARM AARCH64
|
||||||
|
#
|
||||||
|
|
||||||
|
[Sources]
|
||||||
|
Clock.c
|
||||||
|
Entropy.c
|
||||||
|
EPS.c
|
||||||
|
ExtraData.c
|
||||||
|
Failure.c
|
||||||
|
Init.c
|
||||||
|
NVMem.c
|
||||||
|
Unique.c
|
||||||
|
VendorInfo.c
|
||||||
|
|
||||||
|
[Packages]
|
||||||
|
MdePkg/MdePkg.dec
|
||||||
|
MdeModulePkg/MdeModulePkg.dec
|
||||||
|
TcgTpmPkg/TcgTpmPkg.dec
|
||||||
|
|
||||||
|
[LibraryClasses]
|
||||||
|
BaseLib
|
||||||
|
BaseMemoryLib
|
||||||
46
TcgTpmPkg/Library/PlatformTpmNullLib/Unique.c
Normal file
46
TcgTpmPkg/Library/PlatformTpmNullLib/Unique.c
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
/** @file
|
||||||
|
In some implementations of the TPM, the hardware can provide a secret
|
||||||
|
value to the TPM. This secret value is statistically unique to the
|
||||||
|
instance of the TPM. Typical uses of this value are to provide
|
||||||
|
personalization to the random number generation and as a shared secret
|
||||||
|
between the TPM and the manufacturer.
|
||||||
|
|
||||||
|
To see the plat_XXX interfaces in TPM reference library, see:
|
||||||
|
- https://github.com/TrustedComputingGroup/TPM/tree/main/TPMCmd/Platform/src
|
||||||
|
|
||||||
|
Copyright (c) 2025, Arm Limited. All rights reserved.<BR>
|
||||||
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
|
|
||||||
|
**/
|
||||||
|
#include <Library/BaseLib.h>
|
||||||
|
#include <Library/PlatformTpmLib.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat__GetUnique()
|
||||||
|
|
||||||
|
This function is used to access the platform-specific unique value.
|
||||||
|
This function places the unique value in the provided buffer
|
||||||
|
and returns the number of bytes transferred. The function will not
|
||||||
|
copy more data than 'Size'.
|
||||||
|
|
||||||
|
NOTE: If a platform unique value has unequal distribution of uniqueness
|
||||||
|
and 'Size' is smaller than the size of the unique value, the 'Size'
|
||||||
|
portion with the most uniqueness should be returned.
|
||||||
|
|
||||||
|
@param [in] Which 0: reserved, 1: permanent vendor unique value.
|
||||||
|
@param [in] Size Size of Buffer
|
||||||
|
@param [out] Buffer Output Buffer
|
||||||
|
|
||||||
|
@return Size of unique value.
|
||||||
|
|
||||||
|
**/
|
||||||
|
UINT32
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibGetUnique (
|
||||||
|
IN UINT32 Which,
|
||||||
|
IN UINT32 Size,
|
||||||
|
OUT UINT8 *Buffer
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
190
TcgTpmPkg/Library/PlatformTpmNullLib/VendorInfo.c
Normal file
190
TcgTpmPkg/Library/PlatformTpmNullLib/VendorInfo.c
Normal file
|
|
@ -0,0 +1,190 @@
|
||||||
|
/** @file
|
||||||
|
Provide vendor-specific version and identifiers to core TPM library
|
||||||
|
for return in capabilities. These may not be compile time constants and
|
||||||
|
therefore are provided by platform callbacks.
|
||||||
|
These platform functions are expected to always be available,
|
||||||
|
even in failure mode.
|
||||||
|
|
||||||
|
Copyright (c) 2025, Arm Limited. All rights reserved.<BR>
|
||||||
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
|
|
||||||
|
**/
|
||||||
|
#include <Library/BaseLib.h>
|
||||||
|
#include <Library/PlatformTpmLib.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat__GetManufacturerCapabilityCode()
|
||||||
|
|
||||||
|
return the 4 character Manufacturer Capability code.
|
||||||
|
This should come from the platform library since
|
||||||
|
that is provided by the manufacturer.
|
||||||
|
|
||||||
|
|
||||||
|
@return Manufacturer capability Code.
|
||||||
|
|
||||||
|
**/
|
||||||
|
UINT32
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibGetManufacturerCapabilityCode (
|
||||||
|
VOID
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return 0x58595A20; // "XYZ "
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat__GetVendorCapabilityCode()
|
||||||
|
|
||||||
|
return the 4 character VendorStrings for Capabilities.
|
||||||
|
Index is ONE-BASED, and may be in the range [1,4] inclusive.
|
||||||
|
Any other index returns all zeros. The return value will be interpreted
|
||||||
|
as an array of 4 ASCII characters (with no null terminator).
|
||||||
|
|
||||||
|
@param[in] Index index
|
||||||
|
|
||||||
|
@return Vendor specific capability code.
|
||||||
|
|
||||||
|
**/
|
||||||
|
UINT32
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibGetVendorCapabilityCode (
|
||||||
|
IN INT32 Index
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat__GetTpmFirmwareVersionHigh()
|
||||||
|
|
||||||
|
return the most-significant 32-bits of the TPM Firmware Version
|
||||||
|
|
||||||
|
@return High 32-bits of TPM Firmware Version.
|
||||||
|
|
||||||
|
**/
|
||||||
|
UINT32
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibGetTpmFirmwareVersionHigh (
|
||||||
|
VOID
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat__GetTpmFirmwareVersionLow()
|
||||||
|
|
||||||
|
return the least-significant 32-bits of the TPM Firmware Version
|
||||||
|
|
||||||
|
@return Low 32-bits of TPM Firmware Version.
|
||||||
|
|
||||||
|
**/
|
||||||
|
UINT32
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibGetTpmFirmwareVersionLow (
|
||||||
|
VOID
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat__GetTpmFirmwareSvn()
|
||||||
|
|
||||||
|
return the TPM Firmware current SVN.
|
||||||
|
|
||||||
|
@return current SVN.
|
||||||
|
|
||||||
|
**/
|
||||||
|
UINT16
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibGetTpmFirmwareSvn (
|
||||||
|
VOID
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat__GetTpmFirmwareMaxSvn()
|
||||||
|
|
||||||
|
return the TPM Firmware maximum SVN.
|
||||||
|
|
||||||
|
@return Maximum SVN.
|
||||||
|
|
||||||
|
**/
|
||||||
|
UINT16
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibGetTpmFirmwareMaxSvn (
|
||||||
|
VOID
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat__GetTpmFirmwareSvnSecret().
|
||||||
|
|
||||||
|
return the TPM Firmware SVN Secret value associated with SVN.
|
||||||
|
|
||||||
|
@param[in] Svn Svn.
|
||||||
|
@param[in] SecretBufferSize Secret Buffer Size.
|
||||||
|
@param[out] SecretBuffer Secret Buffer.
|
||||||
|
@param[out] SecretSize Secret Svn Size.
|
||||||
|
|
||||||
|
@return 0 Success.
|
||||||
|
@return < 0 Error.
|
||||||
|
|
||||||
|
**/
|
||||||
|
INT32
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibGetTpmFirmwareSvnSecret (
|
||||||
|
IN UINT16 Svn,
|
||||||
|
IN UINT16 SecretBufferSize,
|
||||||
|
OUT UINT8 *SecretBuffer,
|
||||||
|
OUT UINT16 *SecretSize
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat__GetTpmFirmwareSecret().
|
||||||
|
|
||||||
|
return the TPM Firmware Secret value associated with SVN.
|
||||||
|
|
||||||
|
@param[in] SecretBufferSize Secret Buffer Size.
|
||||||
|
@param[out] SecretBuffer Secret Buffer.
|
||||||
|
@param[out] SecretSize Secret Svn Size.
|
||||||
|
|
||||||
|
@return 0 Success.
|
||||||
|
@return < 0 Error.
|
||||||
|
|
||||||
|
**/
|
||||||
|
INT32
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibGetTpmFirmwareSecret (
|
||||||
|
IN UINT16 SecretBufferSize,
|
||||||
|
OUT UINT8 *SecretBuffer,
|
||||||
|
OUT UINT16 *SecretSize
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
_plat__GetVendorTpmType().
|
||||||
|
|
||||||
|
return the Platform TPM type.
|
||||||
|
|
||||||
|
@return TPM type.
|
||||||
|
|
||||||
|
**/
|
||||||
|
UINT32
|
||||||
|
EFIAPI
|
||||||
|
PlatformTpmLibGetVendorTpmType (
|
||||||
|
VOID
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return PLATFORM_TPM_TYPE_UNKNOWN;
|
||||||
|
}
|
||||||
75
TcgTpmPkg/TcgTpmPkg.ci.yaml
Normal file
75
TcgTpmPkg/TcgTpmPkg.ci.yaml
Normal file
|
|
@ -0,0 +1,75 @@
|
||||||
|
## @file
|
||||||
|
# CI configuration for TcgTpmPkg
|
||||||
|
#
|
||||||
|
# Copyright (c) 2025, Arm Ltd. All rights reserved.<BR>
|
||||||
|
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
|
##
|
||||||
|
{
|
||||||
|
"PrEval": {
|
||||||
|
"DscPath": "TcgTpmPkg.dsc",
|
||||||
|
},
|
||||||
|
"LicenseCheck": {
|
||||||
|
"IgnoreFiles": [
|
||||||
|
# These directories are symbolic link or submodule
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"EccCheck": {
|
||||||
|
## Exception sample looks like below:
|
||||||
|
## "ExceptionList": [
|
||||||
|
## "<ErrorID>", "<KeyWord>"
|
||||||
|
## ]
|
||||||
|
"ExceptionList": [
|
||||||
|
],
|
||||||
|
## Both file path and directory path are accepted.
|
||||||
|
"IgnoreFiles": [
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"CompilerPlugin": {
|
||||||
|
"DscPath": "TcgTpmPkg.dsc"
|
||||||
|
},
|
||||||
|
## options defined .pytool/Plugin/HostUnitTestCompilerPlugin
|
||||||
|
"HostUnitTestCompilerPlugin": {
|
||||||
|
},
|
||||||
|
"CharEncodingCheck": {
|
||||||
|
"IgnoreFiles": []
|
||||||
|
},
|
||||||
|
"DependencyCheck": {
|
||||||
|
"AcceptableDependencies": [
|
||||||
|
"MdePkg/MdePkg.dec",
|
||||||
|
"MdeModulePkg/MdeModulePkg.dec",
|
||||||
|
"CryptoPkg/CryptoPkg.dec",
|
||||||
|
],
|
||||||
|
# For host based unit tests
|
||||||
|
"AcceptableDependencies-HOST_APPLICATION":[],
|
||||||
|
# For UEFI shell based apps
|
||||||
|
"AcceptableDependencies-UEFI_APPLICATION":[],
|
||||||
|
"IgnoreInf": []
|
||||||
|
},
|
||||||
|
"DscCompleteCheck": {
|
||||||
|
"DscPath": "TcgTpmPkg.dsc",
|
||||||
|
"IgnoreInf": []
|
||||||
|
},
|
||||||
|
"GuidCheck": {
|
||||||
|
"IgnoreGuidName": [],
|
||||||
|
"IgnoreGuidValue": [],
|
||||||
|
"IgnoreFoldersAndFiles": []
|
||||||
|
},
|
||||||
|
"LibraryClassCheck": {
|
||||||
|
"IgnoreHeaderFile": []
|
||||||
|
},
|
||||||
|
|
||||||
|
## options defined ci/Plugin/SpellCheck
|
||||||
|
"SpellCheck": {
|
||||||
|
"skip": True,
|
||||||
|
"IgnoreFiles": [], # use gitignore syntax to ignore errors in matching files
|
||||||
|
"ExtendWords": [], # words to extend to the dictionary for this package
|
||||||
|
"IgnoreStandardPaths": [], # Standard Plugin defined paths that should be ignore
|
||||||
|
"AdditionalIncludePaths": [] # Additional paths to spell check (wildcards supported)
|
||||||
|
},
|
||||||
|
|
||||||
|
# options defined in .pytool/Plugin/UncrustifyCheck
|
||||||
|
"UncrustifyCheck": {
|
||||||
|
"IgnoreFiles": [
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
31
TcgTpmPkg/TcgTpmPkg.dec
Normal file
31
TcgTpmPkg/TcgTpmPkg.dec
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
## @file
|
||||||
|
# Package for TCG TPM modules.
|
||||||
|
#
|
||||||
|
# This Package provides softwared-based TPM libraries using TCG TPM v2.0
|
||||||
|
# Reference Library (https://github.com/TrustedComputingGroup/TPM).
|
||||||
|
#
|
||||||
|
# Copyright (c) 2025, Arm ltd. All rights reserved.<BR>
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
|
#
|
||||||
|
##
|
||||||
|
|
||||||
|
|
||||||
|
[Defines]
|
||||||
|
DEC_SPECIFICATION = 0x00010005
|
||||||
|
PACKAGE_NAME = TcgTpmPkg
|
||||||
|
PACKAGE_UNI_FILE = TcgTpmPkg.uni
|
||||||
|
PACKAGE_GUID = d2140d58-d992-11f0-a174-6718da082438
|
||||||
|
PACKAGE_VERSION = 0.98
|
||||||
|
|
||||||
|
[Includes]
|
||||||
|
Include
|
||||||
|
|
||||||
|
[Includes.Common.Private]
|
||||||
|
|
||||||
|
[LibraryClasses]
|
||||||
|
## @libraryclass Provides platform specific APIs used by TpmLib.
|
||||||
|
#
|
||||||
|
PlatformTpmLib|Include/Library/PlatformTpmLib.h
|
||||||
|
|
||||||
|
[LibraryClasses.common.Private]
|
||||||
91
TcgTpmPkg/TcgTpmPkg.dsc
Normal file
91
TcgTpmPkg/TcgTpmPkg.dsc
Normal file
|
|
@ -0,0 +1,91 @@
|
||||||
|
## @file
|
||||||
|
# TCG TPM Library Package for softwared based TPM.
|
||||||
|
#
|
||||||
|
# Copyright (c) 2025, Arm Ltd. All rights reserved.<BR>
|
||||||
|
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
|
#
|
||||||
|
##
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
#
|
||||||
|
# Defines Section - statements that will be processed to create a Makefile.
|
||||||
|
#
|
||||||
|
################################################################################
|
||||||
|
[Defines]
|
||||||
|
PLATFORM_NAME = TcgTpmPkg
|
||||||
|
PLATFORM_GUID = fbaf24d0-d9a7-11f0-89be-3fbf4120ee76
|
||||||
|
PLATFORM_VERSION = 0.98
|
||||||
|
DSC_SPECIFICATION = 0x00010005
|
||||||
|
SUPPORTED_ARCHITECTURES = AARCH64
|
||||||
|
BUILD_TARGETS = DEBUG|RELEASE|NOOPT
|
||||||
|
SKUID_IDENTIFIER = DEFAULT
|
||||||
|
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
#
|
||||||
|
# Library Class section - list of all Library Classes needed by this Platform.
|
||||||
|
#
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
!include MdePkg/MdeLibs.dsc.inc
|
||||||
|
|
||||||
|
[LibraryClasses]
|
||||||
|
BaseLib|MdePkg/Library/BaseLib/BaseLib.inf
|
||||||
|
BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf
|
||||||
|
DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf
|
||||||
|
SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf
|
||||||
|
SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf
|
||||||
|
TimerLib|MdePkg/Library/BaseTimerLibNullTemplate/BaseTimerLibNullTemplate.inf
|
||||||
|
RngLib|MdePkg/Library/BaseRngLibNull/BaseRngLibNull.inf
|
||||||
|
PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf
|
||||||
|
DebugLib|MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebugLibReportStatusCode.inf
|
||||||
|
DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf
|
||||||
|
OemHookStatusCodeLib|MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHookStatusCodeLibNull.inf
|
||||||
|
HashApiLib|CryptoPkg/Library/BaseHashApiLib/BaseHashApiLib.inf
|
||||||
|
OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLibFull.inf
|
||||||
|
IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
|
||||||
|
|
||||||
|
[LibraryClasses.AARCH64]
|
||||||
|
ArmLib|ArmPkg/Library/ArmLib/ArmBaseLib.inf
|
||||||
|
|
||||||
|
[LibraryClasses.common.SEC]
|
||||||
|
BaseCryptLib|CryptoPkg/Library/BaseCryptLib/SecCryptLib.inf
|
||||||
|
TlsLib|CryptoPkg/Library/TlsLibNull/TlsLibNull.inf
|
||||||
|
|
||||||
|
[LibraryClasses.common.PEIM]
|
||||||
|
PeimEntryPoint|MdePkg/Library/PeimEntryPoint/PeimEntryPoint.inf
|
||||||
|
PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf
|
||||||
|
PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf
|
||||||
|
MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf
|
||||||
|
HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf
|
||||||
|
PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf
|
||||||
|
ReportStatusCodeLib|MdeModulePkg/Library/PeiReportStatusCodeLib/PeiReportStatusCodeLib.inf
|
||||||
|
BaseCryptLib|CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf
|
||||||
|
|
||||||
|
[LibraryClasses.common.DXE_DRIVER]
|
||||||
|
UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf
|
||||||
|
UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf
|
||||||
|
UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf
|
||||||
|
MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
|
||||||
|
ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf
|
||||||
|
PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
|
||||||
|
BaseCryptLib|CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
|
||||||
|
TlsLib|CryptoPkg/Library/TlsLib/TlsLib.inf
|
||||||
|
|
||||||
|
[LibraryClasses.common.MM_STANDALONE]
|
||||||
|
BaseCryptLib|CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf
|
||||||
|
MmServicesTableLib|MdePkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLib.inf
|
||||||
|
StandaloneMmDriverEntryPoint|MdePkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntryPoint.inf
|
||||||
|
PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
|
||||||
|
ReportStatusCodeLib|MdePkg/Library/BaseReportStatusCodeLibNull/BaseReportStatusCodeLibNull.inf
|
||||||
|
MemoryAllocationLib|StandaloneMmPkg/Library/StandaloneMmMemoryAllocationLib/StandaloneMmMemoryAllocationLib.inf
|
||||||
|
|
||||||
|
[Components]
|
||||||
|
#
|
||||||
|
# Build verification of all library instances
|
||||||
|
#
|
||||||
|
TcgTpmPkg/Library/PlatformTpmNullLib/PlatformTpmNullLib.inf
|
||||||
|
|
||||||
|
[BuildOptions]
|
||||||
|
RELEASE_*_*_CC_FLAGS = -DMDEPKG_NDEBUG
|
||||||
|
*_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES
|
||||||
12
TcgTpmPkg/TcgTpmPkg.uni
Normal file
12
TcgTpmPkg/TcgTpmPkg.uni
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
// /** @file
|
||||||
|
// Package for TCG TPM modules.
|
||||||
|
//
|
||||||
|
// This Package provides softwared-based TPM libraries using TCG TPM v2.0
|
||||||
|
// Reference Library (https://github.com/TrustedComputingGroup/TPM).
|
||||||
|
//
|
||||||
|
// Copyright (c) 2025, Arm ltd. All rights reserved.<BR>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
|
//
|
||||||
|
// **/
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue