X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=EdkModulePkg%2FUniversal%2FStatusCode%2FDxe%2FDataHubStatusCodeWorker.c;h=737bc8a3a1182dae805e92da46cba68f411fce2c;hb=6f2b45bb6708eb7c06746e1670ccb6520b7bcb5b;hp=11793b52aead2a40c5a75776a1875aad8da0c4b1;hpb=a93763b74df753b3e8de6a49eea5cbd1116b2535;p=mirror_edk2.git diff --git a/EdkModulePkg/Universal/StatusCode/Dxe/DataHubStatusCodeWorker.c b/EdkModulePkg/Universal/StatusCode/Dxe/DataHubStatusCodeWorker.c index 11793b52ae..737bc8a3a1 100644 --- a/EdkModulePkg/Universal/StatusCode/Dxe/DataHubStatusCodeWorker.c +++ b/EdkModulePkg/Universal/StatusCode/Dxe/DataHubStatusCodeWorker.c @@ -1,29 +1,29 @@ /** @file Data Hub status code worker in DXE. - Copyright (c) 2006, 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. + Copyright (c) 2006, 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. Module Name: DataHubStatusCodeWorker.c **/ + +#include #include "DxeStatusCode.h" // // Initialize FIFO to cache records. // -STATIC -EFI_LOCK mFifoLock = EFI_INITIALIZE_LOCK_VARIABLE (EFI_TPL_HIGH_LEVEL); STATIC -LIST_ENTRY mRecordsFifo = INITIALIZE_LIST_HEAD_VARIABLE (mRecordsFifo); +LIST_ENTRY mRecordsFifo = INITIALIZE_LIST_HEAD_VARIABLE (mRecordsFifo); STATIC -UINTN mNumberOfRecords = 0; +LIST_ENTRY mRecordsBuffer = INITIALIZE_LIST_HEAD_VARIABLE (mRecordsBuffer); STATIC EFI_EVENT mLogDataHubEvent; // @@ -34,102 +34,123 @@ EFI_DATA_HUB_PROTOCOL *mDataHubProtocol; /** - Return buffer of length DATAHUB_STATUSCODE_RECORD - + Return one DATAHUB_STATUSCODE_RECORD space. + The size of free record pool would be extend, if the pool is empty. + + @retval NULL Can not allocate free memeory for record. @retval !NULL Point to buffer of record. **/ -DATAHUB_STATUSCODE_RECORD * +STATIC +DATA_HUB_STATUS_CODE_DATA_RECORD * AcquireRecordBuffer ( VOID ) { DATAHUB_STATUSCODE_RECORD *Record; + EFI_TPL CurrentTpl; + LIST_ENTRY *Node; + UINT32 Index; + + CurrentTpl = gBS->RaiseTPL (TPL_HIGH_LEVEL); + + if (!IsListEmpty (&mRecordsBuffer)) { + Node = GetFirstNode (&mRecordsBuffer); + RemoveEntryList (Node); + + Record = _CR (Node, DATAHUB_STATUSCODE_RECORD, Node); + } else { + if (CurrentTpl > TPL_NOTIFY) { + gBS->RestoreTPL (CurrentTpl); + return NULL; + } + + gBS->RestoreTPL (CurrentTpl); + Record = (DATAHUB_STATUSCODE_RECORD *) AllocateZeroPool (sizeof (DATAHUB_STATUSCODE_RECORD) * 16); + if (NULL == Record) { + return NULL; + } - Record = (DATAHUB_STATUSCODE_RECORD *) AllocateZeroPool (sizeof (DATAHUB_STATUSCODE_RECORD)); - if (NULL == Record) { - return NULL; + CurrentTpl = gBS->RaiseTPL (TPL_HIGH_LEVEL); + for (Index = 1; Index < 16; Index++) { + InsertTailList (&mRecordsBuffer, &Record[Index].Node); + } } - Record->Signature = DATAHUB_STATUS_CODE_SIGNATURE; - EfiAcquireLock (&mFifoLock); + Record->Signature = DATAHUB_STATUS_CODE_SIGNATURE; InsertTailList (&mRecordsFifo, &Record->Node); - mNumberOfRecords++; - EfiReleaseLock (&mFifoLock); - return Record; + gBS->RestoreTPL (CurrentTpl); + + return (DATA_HUB_STATUS_CODE_DATA_RECORD *) (Record->Data); } /** - Release a mRecordBuffer entry allocated by AcquirRecordBuffer (). + Retrieve one record from Records FIFO. The record would be removed from FIFO and + release to free record buffer. - @param Record Point to record buffer which is acquired by AcquirRecordBuffer() - - @retval EFI_SUCCESS If DataRecord is valid. - @retval !EFI_SUCCESS The record list has empty. + @return !NULL Point to record, which is ready to be logged. + @return NULL the FIFO of record is empty. **/ -VOID -FreeRecordBuffer ( - IN DATAHUB_STATUSCODE_RECORD *Record +STATIC +DATA_HUB_STATUS_CODE_DATA_RECORD * +RetrieveRecord ( + VOID ) -/*++ - -Routine Description: - - Release a mRecordBuffer entry allocated by AquireEmptyRecordBuffer (). - -Arguments: - - RecordBuffer - Data to free +{ + DATA_HUB_STATUS_CODE_DATA_RECORD *RecordData = NULL; + DATAHUB_STATUSCODE_RECORD *Record; + LIST_ENTRY *Node; + EFI_TPL CurrentTpl; -Returns: + CurrentTpl = gBS->RaiseTPL (TPL_HIGH_LEVEL); - EFI_SUCCESS - If DataRecord is valid - EFI_UNSUPPORTED - The record list has empty + if (!IsListEmpty (&mRecordsFifo)) { + Node = GetFirstNode (&mRecordsFifo); + Record = CR (Node, DATAHUB_STATUSCODE_RECORD, Node, DATAHUB_STATUS_CODE_SIGNATURE); ---*/ -{ - ASSERT (Record != NULL); - ASSERT (mNumberOfRecords != 0); + RemoveEntryList (&Record->Node); + InsertTailList (&mRecordsBuffer, &Record->Node); + Record->Signature = 0; + RecordData = (DATA_HUB_STATUS_CODE_DATA_RECORD *) Record->Data; + } - EfiAcquireLock (&mFifoLock); - RemoveEntryList (&Record->Node); - mNumberOfRecords--; - EfiReleaseLock (&mFifoLock); + gBS->RestoreTPL (CurrentTpl); - FreePool (Record); + return RecordData; } /** Report status code into DataHub. - - @param CodeType Indicates the type of status code being reported. Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions¡± below. - - @param Value Describes the current status of a hardware or software entity. - This included information about the class and subclass that is used to classify the entity - as well as an operation. For progress codes, the operation is the current activity. - For error codes, it is the exception. For debug codes, it is not defined at this time. - Type EFI_STATUS_CODE_VALUE is defined in ¡°Related Definitions¡± below. + + @param CodeType Indicates the type of status code being reported. Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below. + + @param Value Describes the current status of a hardware or software entity. + This included information about the class and subclass that is used to classify the entity + as well as an operation. For progress codes, the operation is the current activity. + For error codes, it is the exception. For debug codes, it is not defined at this time. + Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below. Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification. - - @param Instance The enumeration of a hardware or software entity within the system. - A system may contain multiple entities that match a class/subclass pairing. - The instance differentiates between them. An instance of 0 indicates that instance information is unavailable, + + @param Instance The enumeration of a hardware or software entity within the system. + A system may contain multiple entities that match a class/subclass pairing. + The instance differentiates between them. An instance of 0 indicates that instance information is unavailable, not meaningful, or not relevant. Valid instance numbers start with 1. - @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. + @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. @param Data This optional parameter may be used to pass additional data - + @retval EFI_OUT_OF_RESOURCES Can not acquire record buffer. + @retval EFI_DEVICE_ERROR EFI serial device can not work after ExitBootService() is called . @retval EFI_SUCCESS Success to cache status code and signal log data event. **/ @@ -142,20 +163,20 @@ DataHubStatusCodeReportWorker ( IN EFI_STATUS_CODE_DATA *Data OPTIONAL ) { - DATAHUB_STATUSCODE_RECORD *Record; - UINT32 ErrorLevel; - VA_LIST Marker; - CHAR8 *Format; - UINTN CharCount; + DATA_HUB_STATUS_CODE_DATA_RECORD *Record; + UINT32 ErrorLevel; + VA_LIST Marker; + CHAR8 *Format; + UINTN CharCount; // // See whether in runtime phase or not. // if (EfiAtRuntime ()) { - return EFI_SUCCESS; + return EFI_DEVICE_ERROR; } - Record = (DATAHUB_STATUSCODE_RECORD *) AcquireRecordBuffer (); + Record = AcquireRecordBuffer (); if (Record == NULL) { // // There are no empty record buffer in private buffers @@ -176,7 +197,7 @@ DataHubStatusCodeReportWorker ( if (Data != NULL) { if (ReportStatusCodeExtractDebugInfo (Data, &ErrorLevel, &Marker, &Format)) { CharCount = UnicodeVSPrintAsciiFormat ( - (CHAR16 *) Record->ExtendData, + (CHAR16 *) (Record + 1), EFI_STATUS_CODE_DATA_MAX_SIZE, Format, Marker @@ -184,7 +205,7 @@ DataHubStatusCodeReportWorker ( // // Change record data type from DebugType to String Type. // - CopyGuid (&Record->Data.Type, &gEfiStatusCodeDataTypeStringGuid); + CopyGuid (&Record->Data.Type, &gEfiStatusCodeDataTypeDebugGuid); Record->Data.HeaderSize = Data->HeaderSize; Record->Data.Size = (UINT16) ((CharCount + 1) * sizeof (CHAR16)); } else { @@ -195,8 +216,8 @@ DataHubStatusCodeReportWorker ( if (Data->Size > EFI_STATUS_CODE_DATA_MAX_SIZE) { Record->Data.Size = EFI_STATUS_CODE_DATA_MAX_SIZE; - } - CopyMem (Record->ExtendData, Data + 1, Record->Data.Size); + } + CopyMem ((VOID *) (Record + 1), Data + 1, Record->Data.Size); } } @@ -214,6 +235,7 @@ DataHubStatusCodeReportWorker ( @param Context Context of the event. **/ +STATIC VOID EFIAPI LogDataHubEventCallBack ( @@ -221,24 +243,23 @@ LogDataHubEventCallBack ( IN VOID *Context ) { - DATAHUB_STATUSCODE_RECORD *Record; - UINTN Size; + DATA_HUB_STATUS_CODE_DATA_RECORD *Record; + UINT32 Size; UINT64 DataRecordClass; - LIST_ENTRY *Node; // // Log DataRecord in Data Hub. // Journal records fifo to find all record entry. // - // - for (Node = mRecordsFifo.ForwardLink; Node != &mRecordsFifo;) { - Record = CR (Node, DATAHUB_STATUSCODE_RECORD, Node, DATAHUB_STATUS_CODE_SIGNATURE); - Node = Node->ForwardLink; - + while (1) { + Record = RetrieveRecord (); + if (Record == NULL) { + break; + } // // Add in the size of the header we added. // - Size = sizeof (DATAHUB_STATUSCODE_RECORD) + Record->Data.Size; + Size = sizeof (DATA_HUB_STATUS_CODE_DATA_RECORD) + (UINT32) Record->Data.Size; if ((Record->CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) { DataRecordClass = EFI_DATA_RECORD_CLASS_PROGRESS_CODE; @@ -259,17 +280,16 @@ LogDataHubEventCallBack ( // // Log DataRecord in Data Hub // - + mDataHubProtocol->LogData ( mDataHubProtocol, &gEfiStatusCodeGuid, &gEfiStatusCodeRuntimeProtocolGuid, DataRecordClass, Record, - (UINT32) Size + Size ); - FreeRecordBuffer (Record); } } @@ -277,7 +297,7 @@ LogDataHubEventCallBack ( /** Initialize data hubstatus code. Create a data hub listener. - + @return The function always return EFI_SUCCESS **/ @@ -299,8 +319,8 @@ DataHubStatusCodeInitializeWorker ( // Create a Notify Event to log data in Data Hub // Status = gBS->CreateEvent ( - EFI_EVENT_NOTIFY_SIGNAL, - EFI_TPL_CALLBACK, + EVT_NOTIFY_SIGNAL, + TPL_CALLBACK, LogDataHubEventCallBack, NULL, &mLogDataHubEvent