X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=EdkModulePkg%2FUniversal%2FStatusCode%2FDxe%2FDataHubStatusCodeWorker.c;h=28714365a67b11a36a997bc719378fdf5fd97c2c;hp=03095c38198378abf82bcb8ec235300036b21345;hb=35d4cd92bd21a3538f6c300723b715b1df6911bb;hpb=161c26a7aaff23ba632527cbfb79845a20b9fab0 diff --git a/EdkModulePkg/Universal/StatusCode/Dxe/DataHubStatusCodeWorker.c b/EdkModulePkg/Universal/StatusCode/Dxe/DataHubStatusCodeWorker.c index 03095c3819..28714365a6 100644 --- a/EdkModulePkg/Universal/StatusCode/Dxe/DataHubStatusCodeWorker.c +++ b/EdkModulePkg/Universal/StatusCode/Dxe/DataHubStatusCodeWorker.c @@ -18,19 +18,23 @@ // // Initialize FIFO to cache records. // -EFI_LOCK mFifoLock = EFI_INITIALIZE_LOCK_VARIABLE (EFI_TPL_HIGH_LEVEL); -LIST_ENTRY mRecordsFifo = INITIALIZE_LIST_HEAD_VARIABLE (mRecordsFifo); -UINTN mNumberOfRecords = 0; - +STATIC +LIST_ENTRY mRecordsFifo = INITIALIZE_LIST_HEAD_VARIABLE (mRecordsFifo); +STATIC +LIST_ENTRY mRecordsBuffer = INITIALIZE_LIST_HEAD_VARIABLE (mRecordsBuffer); +STATIC EFI_EVENT mLogDataHubEvent; // // Cache data hub protocol. // +STATIC 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. @@ -42,17 +46,39 @@ AcquireRecordBuffer ( ) { DATAHUB_STATUSCODE_RECORD *Record; + EFI_TPL CurrentTpl; + LIST_ENTRY *Node; + UINT32 Index; + + CurrentTpl = gBS->RaiseTPL (EFI_TPL_HIGH_LEVEL); + + if (!IsListEmpty (&mRecordsBuffer)) { + Node = GetFirstNode (&mRecordsBuffer); + RemoveEntryList (Node); + + Record = CR (Node, DATAHUB_STATUSCODE_RECORD, Node, DATAHUB_STATUS_CODE_SIGNATURE); + } else { + if (CurrentTpl > EFI_TPL_NOTIFY) { + gBS->RestoreTPL (CurrentTpl); + return NULL; + } - Record = (DATAHUB_STATUSCODE_RECORD *) AllocateZeroPool (sizeof (DATAHUB_STATUSCODE_RECORD)); - if (NULL == Record) { - return NULL; + gBS->RestoreTPL (CurrentTpl); + Record = (DATAHUB_STATUSCODE_RECORD *) AllocateZeroPool (sizeof (DATAHUB_STATUSCODE_RECORD) * 16); + if (NULL == Record) { + return NULL; + } + + CurrentTpl = gBS->RaiseTPL (EFI_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); + + gBS->RestoreTPL (CurrentTpl); return Record; } @@ -63,53 +89,35 @@ AcquireRecordBuffer ( @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. - **/ VOID FreeRecordBuffer ( IN DATAHUB_STATUSCODE_RECORD *Record ) -/*++ - -Routine Description: - - Release a mRecordBuffer entry allocated by AquireEmptyRecordBuffer (). - -Arguments: - - RecordBuffer - Data to free - -Returns: - - EFI_SUCCESS - If DataRecord is valid - EFI_UNSUPPORTED - The record list has empty - ---*/ { + EFI_TPL CurrentTpl; + ASSERT (Record != NULL); - ASSERT (mNumberOfRecords != 0); - EfiAcquireLock (&mFifoLock); + CurrentTpl = gBS->RaiseTPL (EFI_TPL_HIGH_LEVEL); + RemoveEntryList (&Record->Node); - mNumberOfRecords--; - EfiReleaseLock (&mFifoLock); + InsertTailList (&mRecordsBuffer, &Record->Node); - FreePool (Record); + gBS->RestoreTPL (CurrentTpl); } /** 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 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. + 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. @@ -126,6 +134,7 @@ Returns: @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. **/ @@ -148,10 +157,10 @@ DataHubStatusCodeReportWorker ( // 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 @@ -218,15 +227,18 @@ LogDataHubEventCallBack ( ) { DATAHUB_STATUSCODE_RECORD *Record; - UINTN Size; + UINT32 Size; UINT64 DataRecordClass; LIST_ENTRY *Node; + EFI_TPL CurrentTpl; // // Log DataRecord in Data Hub. // Journal records fifo to find all record entry. // // + CurrentTpl = gBS->RaiseTPL (EFI_TPL_HIGH_LEVEL); + for (Node = mRecordsFifo.ForwardLink; Node != &mRecordsFifo;) { Record = CR (Node, DATAHUB_STATUSCODE_RECORD, Node, DATAHUB_STATUS_CODE_SIGNATURE); Node = Node->ForwardLink; @@ -234,7 +246,7 @@ LogDataHubEventCallBack ( // // Add in the size of the header we added. // - Size = sizeof (DATAHUB_STATUSCODE_RECORD) + Record->Data.Size; + Size = sizeof (DATAHUB_STATUSCODE_RECORD) + (UINT32) Record->Data.Size; if ((Record->CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) { DataRecordClass = EFI_DATA_RECORD_CLASS_PROGRESS_CODE; @@ -262,11 +274,15 @@ LogDataHubEventCallBack ( &gEfiStatusCodeRuntimeProtocolGuid, DataRecordClass, Record, - (UINT32) Size + Size ); + + FreeRecordBuffer (Record); } + + gBS->RestoreTPL (CurrentTpl); }