summaryrefslogtreecommitdiff
path: root/ArmPkg
diff options
context:
space:
mode:
Diffstat (limited to 'ArmPkg')
-rw-r--r--ArmPkg/Include/IndustryStandard/ArmTransferList.h20
-rw-r--r--ArmPkg/Include/Library/ArmTransferListLib.h37
-rw-r--r--ArmPkg/Library/ArmTransferListLib/ArmTransferListLib.c89
-rw-r--r--ArmPkg/Library/ArmTransferListLib/ArmTransferListLib.inf3
4 files changed, 149 insertions, 0 deletions
diff --git a/ArmPkg/Include/IndustryStandard/ArmTransferList.h b/ArmPkg/Include/IndustryStandard/ArmTransferList.h
index 303384622f..2bc0d80177 100644
--- a/ArmPkg/Include/IndustryStandard/ArmTransferList.h
+++ b/ArmPkg/Include/IndustryStandard/ArmTransferList.h
@@ -74,6 +74,12 @@
#define TRANSFER_LIST_FL_HAS_CHECKSUM BIT0
/*
+ * Flag values for TPM event log table entry layout XFERLIST_EVLOG->Flags,
+ * see https://github.com/FirmwareHandoff/firmware_handoff/blob/main/source/transfer_list.rst#tpm-event-log-table-entry-layout-xferlist_evlog
+ */
+#define TRANSFER_LIST_EVENTLOG_FL_NEED_TO_REPLAY BIT0 /* Need to replay */
+
+/*
* Operation codes indicating the validity of the Transfer List.
*/
typedef enum {
@@ -137,4 +143,18 @@ typedef struct TransferEntryHeader {
UINT32 DataSize;
} TRANSFER_ENTRY_HEADER;
+/*
+ * TPM event log information entry,
+ * see Section 'TPM event log table entry layout (XFERLIST_EVLOG)' in
+ * the Firmware Handoff specification.
+ */
+typedef struct TransferListEventLog {
+ /// See the TRANSFER_LIST_EVENT_LOG_FL_*
+ UINT32 Flags;
+
+ /// TPM event log as much as
+ /// TRNASFER_ENTRY_HEADER->DataSize - sizeof (TRANSFER_LIST_EVENTLOG)->Flags
+ UINT8 EventLog[];
+} TRANSFER_LIST_EVENTLOG;
+
#endif // ARM_TRANSFER_LIST_
diff --git a/ArmPkg/Include/Library/ArmTransferListLib.h b/ArmPkg/Include/Library/ArmTransferListLib.h
index fb0c69972e..09ade9f4a1 100644
--- a/ArmPkg/Include/Library/ArmTransferListLib.h
+++ b/ArmPkg/Include/Library/ArmTransferListLib.h
@@ -19,6 +19,21 @@
#include <Pi/PiHob.h>
/**
+ Get the TransferList from HOB list.
+
+ @param[out] TransferList TransferList
+
+ @retval EFI_SUCCESS TransferList is found.
+ @retval EFI_NOT_FOUND TransferList is not found.
+
+**/
+EFI_STATUS
+EFIAPI
+TransferListGetFromHobList (
+ OUT TRANSFER_LIST_HEADER **TransferList
+ );
+
+/**
Return the first Transfer Entry Node in the Transfer List.
@param [in] TransferListHeader Pointer to the Transfer List Header.
@@ -157,4 +172,26 @@ TransferListFindEntry (
IN UINT16 TagId
);
+/**
+ Get TPM event log from TransferList
+
+ @param [in] TransferListHeader Pointer to the Transfer List Header
+ @param [out] EventLog Pointer to Eventlog in TransferList
+ @param [out] EventLogSize Size of Event log
+ @param [out] EventLogFlags Flags for Event log
+
+ @return EFI_SUCCESS
+ @return EFI_NOT_FOUND No Event log in TransferListHeader
+ @return EFI_INVALID_PARAMETER Invalid parameters
+
+**/
+EFI_STATUS
+EFIAPI
+TransferListGetEventLog (
+ IN TRANSFER_LIST_HEADER *TransferListHeader,
+ OUT VOID **EventLog,
+ OUT UINTN *EventLogSize,
+ OUT UINT32 *EventLogFlags OPTIONAL
+ );
+
#endif // ARM_TRANSFER_LIST_LIB_
diff --git a/ArmPkg/Library/ArmTransferListLib/ArmTransferListLib.c b/ArmPkg/Library/ArmTransferListLib/ArmTransferListLib.c
index af8170e67f..06d66292b4 100644
--- a/ArmPkg/Library/ArmTransferListLib/ArmTransferListLib.c
+++ b/ArmPkg/Library/ArmTransferListLib/ArmTransferListLib.c
@@ -13,6 +13,45 @@
#include <Library/ArmTransferListLib.h>
#include <Library/BaseLib.h>
#include <Library/DebugLib.h>
+#include <Library/HobLib.h>
+
+/**
+ Get the TransferList from HOB list.
+
+ @param[out] TransferList TransferList
+
+ @retval EFI_SUCCESS TransferList is found.
+ @retval EFI_NOT_FOUND TransferList is not found.
+
+**/
+EFI_STATUS
+EFIAPI
+TransferListGetFromHobList (
+ OUT TRANSFER_LIST_HEADER **TransferList
+ )
+{
+ VOID *HobList;
+ EFI_HOB_GUID_TYPE *GuidHob;
+ UINTN *GuidHobData;
+
+ *TransferList = NULL;
+
+ HobList = GetHobList ();
+ if (HobList == NULL) {
+ return EFI_NOT_FOUND;
+ }
+
+ GuidHob = GetNextGuidHob (&gArmTransferListHobGuid, HobList);
+ if (GuidHob == NULL) {
+ return EFI_NOT_FOUND;
+ }
+
+ GuidHobData = GET_GUID_HOB_DATA (GuidHob);
+
+ *TransferList = (TRANSFER_LIST_HEADER *)(*GuidHobData);
+
+ return EFI_SUCCESS;
+}
/**
This function verifies the checksum of the Transfer List.
@@ -275,6 +314,56 @@ TransferListFindEntry (
}
/**
+ Get TPM event log from TransferList
+
+ @param [in] TransferListHeader Pointer to the Transfer List Header
+ @param [out] EventLog Pointer to Eventlog in TransferList
+ @param [out] EventLogSize Size of Event log
+ @param [out] EventLogFlags Flags for Event log
+
+ @return EFI_SUCCESS
+ @return EFI_NOT_FOUND No Event log in TransferListHeader
+ @return EFI_INVALID_PARAMETER Invalid parameters
+
+**/
+EFI_STATUS
+EFIAPI
+TransferListGetEventLog (
+ IN TRANSFER_LIST_HEADER *TransferListHeader,
+ OUT VOID **EventLog,
+ OUT UINTN *EventLogSize,
+ OUT UINT32 *EventLogFlags OPTIONAL
+ )
+{
+ TRANSFER_ENTRY_HEADER *Entry;
+ TRANSFER_LIST_EVENTLOG *EntryData;
+
+ if ((TransferListHeader == NULL) || (EventLog == NULL) || (EventLogSize == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ *EventLog = NULL;
+ *EventLogSize = 0;
+
+ Entry = TransferListFindFirstEntry (TransferListHeader, TRANSFER_ENTRY_TAG_ID_TPM_EVENT_LOG);
+ if ((Entry == NULL) || (Entry->DataSize == 0) ||
+ ((Entry->DataSize - OFFSET_OF (TRANSFER_LIST_EVENTLOG, EventLog)) == 0))
+ {
+ return EFI_NOT_FOUND;
+ }
+
+ EntryData = TransferListGetEntryData (Entry);
+ if (EventLogFlags != NULL) {
+ *EventLogFlags = EntryData->Flags;
+ }
+
+ *EventLogSize = Entry->DataSize - OFFSET_OF (TRANSFER_LIST_EVENTLOG, EventLog);
+ *EventLog = (VOID *)&EntryData->EventLog;
+
+ return EFI_SUCCESS;
+}
+
+/**
Dump the transfer list to the debug output.
@param [in] TransferListHeader Pointer to the Transfer List Header
diff --git a/ArmPkg/Library/ArmTransferListLib/ArmTransferListLib.inf b/ArmPkg/Library/ArmTransferListLib/ArmTransferListLib.inf
index b1eeb8a1f7..5ffb1a4d9c 100644
--- a/ArmPkg/Library/ArmTransferListLib/ArmTransferListLib.inf
+++ b/ArmPkg/Library/ArmTransferListLib/ArmTransferListLib.inf
@@ -25,3 +25,6 @@
[LibraryClasses]
BaseLib
+
+[Guids]
+ gArmTransferListHobGuid