X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=IntelFrameworkModulePkg%2FUniversal%2FStatusCode%2FDxe%2FDataHubStatusCodeWorker.c;h=0936c093eba2a2fa0f26581370e6c5483e0f7496;hb=8a7d75b0625cffee0c67b85afe56763f93d86481;hp=d72884d73db61727df05aed6e372f0f057aed9cd;hpb=6f2b45bb6708eb7c06746e1670ccb6520b7bcb5b;p=mirror_edk2.git diff --git a/IntelFrameworkModulePkg/Universal/StatusCode/Dxe/DataHubStatusCodeWorker.c b/IntelFrameworkModulePkg/Universal/StatusCode/Dxe/DataHubStatusCodeWorker.c index d72884d73d..0936c093eb 100644 --- a/IntelFrameworkModulePkg/Universal/StatusCode/Dxe/DataHubStatusCodeWorker.c +++ b/IntelFrameworkModulePkg/Universal/StatusCode/Dxe/DataHubStatusCodeWorker.c @@ -10,8 +10,6 @@ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - Module Name: DataHubStatusCodeWorker.c - **/ #include "DxeStatusCode.h" @@ -24,6 +22,8 @@ LIST_ENTRY mRecordsFifo = INITIALIZE_LIST_HEAD_VARIABLE STATIC LIST_ENTRY mRecordsBuffer = INITIALIZE_LIST_HEAD_VARIABLE (mRecordsBuffer); STATIC +UINT32 mLogDataHubStatus = 0; +STATIC EFI_EVENT mLogDataHubEvent; // // Cache data hub protocol. @@ -61,6 +61,9 @@ AcquireRecordBuffer ( Record = _CR (Node, DATAHUB_STATUSCODE_RECORD, Node); } else { if (CurrentTpl > TPL_NOTIFY) { + // + // Memory management should work at <=TPL_NOTIFY + // gBS->RestoreTPL (CurrentTpl); return NULL; } @@ -110,10 +113,9 @@ RetrieveRecord ( if (!IsListEmpty (&mRecordsFifo)) { Node = GetFirstNode (&mRecordsFifo); Record = CR (Node, DATAHUB_STATUSCODE_RECORD, Node, DATAHUB_STATUS_CODE_SIGNATURE); + ASSERT (NULL != Record); RemoveEntryList (&Record->Node); - InsertTailList (&mRecordsBuffer, &Record->Node); - Record->Signature = 0; RecordData = (DATA_HUB_STATUS_CODE_DATA_RECORD *) Record->Data; } @@ -122,6 +124,34 @@ RetrieveRecord ( return RecordData; } +/** + Release Records to FIFO. + + @param RecordData Point to the record buffer allocated + from AcquireRecordBuffer. + +**/ +STATIC +VOID +ReleaseRecord ( + DATA_HUB_STATUS_CODE_DATA_RECORD *RecordData + ) +{ + DATAHUB_STATUSCODE_RECORD *Record; + EFI_TPL CurrentTpl; + + Record = CR (RecordData, DATAHUB_STATUSCODE_RECORD, Data[0], DATAHUB_STATUS_CODE_SIGNATURE); + ASSERT (NULL != Record); + + CurrentTpl = gBS->RaiseTPL (TPL_HIGH_LEVEL); + + InsertTailList (&mRecordsBuffer, &Record->Node); + Record->Signature = 0; + + gBS->RestoreTPL (CurrentTpl); +} + + /** Report status code into DataHub. @@ -143,7 +173,7 @@ RetrieveRecord ( @param CallerId This optional parameter may be used to identify the caller. This parameter allows the status code driver to apply different rules to different callers. - Type EFI_GUID is defined in InstallProtocolInterface() in the EFI 1.10 Specification. + Type EFI_GUID is defined in InstallProtocolInterface() in the UEFI 2.0 Specification. @param Data This optional parameter may be used to pass additional data @@ -168,6 +198,15 @@ DataHubStatusCodeReportWorker ( CHAR8 *Format; UINTN CharCount; + + // + // Use atom operation to avoid the reentant of report. + // If current status is not zero, then the function is reentrancy. + // + if (1 == InterlockedCompareExchange32 (&mLogDataHubStatus, 0, 0)) { + return EFI_DEVICE_ERROR; + } + // // See whether in runtime phase or not. // @@ -247,6 +286,14 @@ LogDataHubEventCallBack ( UINT32 Size; UINT64 DataRecordClass; + // + // Use atom operation to avoid the reentant of report. + // If current status is not zero, then the function is reentrancy. + // + if (1 == InterlockedCompareExchange32 (&mLogDataHubStatus, 0, 1)) { + return; + } + // // Log DataRecord in Data Hub. // Journal records fifo to find all record entry. @@ -283,14 +330,20 @@ LogDataHubEventCallBack ( mDataHubProtocol->LogData ( mDataHubProtocol, - &gEfiStatusCodeGuid, + &gEfiDataHubStatusCodeRecordGuid, &gEfiStatusCodeRuntimeProtocolGuid, DataRecordClass, Record, Size ); + ReleaseRecord (Record); } + + // + // Restore the nest status of report + // + InterlockedCompareExchange32 (&mLogDataHubStatus, 1, 0); }