/** @file\r
- Data Hub status code worker in DXE.\r
+ Data Hub status code worker.\r
\r
- Copyright (c) 2006, Intel Corporation\r
+ Copyright (c) 2006 - 2009, Intel Corporation\r
All rights reserved. This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
\r
\r
/**\r
- Return one DATAHUB_STATUSCODE_RECORD space.\r
- The size of free record pool would be extend, if the pool is empty.\r
+ Retrieve one record of from free record buffer. This record is removed from\r
+ free record buffer.\r
\r
+ This function retrieves one record from free record buffer.\r
+ If the pool has been exhausted, then new memory would be allocated for it.\r
\r
- @retval NULL Can not allocate free memeory for record.\r
- @retval !NULL Point to buffer of record.\r
+ @return Pointer to the free record.\r
+ NULL means failure to allocate new memeory for free record buffer.\r
\r
**/\r
DATA_HUB_STATUS_CODE_DATA_RECORD *\r
CurrentTpl = gBS->RaiseTPL (TPL_HIGH_LEVEL);\r
\r
if (!IsListEmpty (&mRecordsBuffer)) {\r
+ //\r
+ // Strip one entry from free record buffer.\r
+ //\r
Node = GetFirstNode (&mRecordsBuffer);\r
RemoveEntryList (Node);\r
\r
return NULL;\r
}\r
\r
+ //\r
+ // If free record buffer is exhausted, then allocate 16 new records for it.\r
+ //\r
gBS->RestoreTPL (CurrentTpl);\r
Record = (DATAHUB_STATUSCODE_RECORD *) AllocateZeroPool (sizeof (DATAHUB_STATUSCODE_RECORD) * 16);\r
- if (NULL == Record) {\r
+ if (Record == NULL) {\r
return NULL;\r
}\r
\r
CurrentTpl = gBS->RaiseTPL (TPL_HIGH_LEVEL);\r
+ //\r
+ // Here we only insert 15 new records to the free record buffer, for the first record\r
+ // will be returned immediately.\r
+ //\r
for (Index = 1; Index < 16; Index++) {\r
InsertTailList (&mRecordsBuffer, &Record[Index].Node);\r
}\r
\r
\r
/**\r
- Retrieve one record from Records FIFO. The record would be removed from FIFO and\r
- release to free record buffer.\r
+ Retrieve one record from Records FIFO. The record would be removed from FIFO.\r
\r
- @return !NULL Point to record, which is ready to be logged.\r
- @return NULL the FIFO of record is empty.\r
+ @return Point to record, which is ready to be logged.\r
+ NULL means the FIFO of record is empty.\r
\r
**/\r
DATA_HUB_STATUS_CODE_DATA_RECORD *\r
VOID\r
)\r
{\r
- DATA_HUB_STATUS_CODE_DATA_RECORD *RecordData = NULL;\r
+ DATA_HUB_STATUS_CODE_DATA_RECORD *RecordData;\r
DATAHUB_STATUSCODE_RECORD *Record;\r
LIST_ENTRY *Node;\r
EFI_TPL CurrentTpl;\r
\r
+ RecordData = NULL;\r
+\r
CurrentTpl = gBS->RaiseTPL (TPL_HIGH_LEVEL);\r
\r
if (!IsListEmpty (&mRecordsFifo)) {\r
Node = GetFirstNode (&mRecordsFifo);\r
Record = CR (Node, DATAHUB_STATUSCODE_RECORD, Node, DATAHUB_STATUS_CODE_SIGNATURE);\r
- ASSERT (NULL != Record);\r
+ ASSERT (Record != NULL);\r
\r
RemoveEntryList (&Record->Node);\r
RecordData = (DATA_HUB_STATUS_CODE_DATA_RECORD *) Record->Data;\r
}\r
\r
/**\r
- Release Records to FIFO.\r
+ Release given record and return it to free record buffer.\r
\r
- @param RecordData Point to the record buffer allocated\r
- from AcquireRecordBuffer.\r
+ @param RecordData Pointer to the record to release.\r
\r
**/\r
VOID\r
EFI_TPL CurrentTpl;\r
\r
Record = CR (RecordData, DATAHUB_STATUSCODE_RECORD, Data[0], DATAHUB_STATUS_CODE_SIGNATURE);\r
- ASSERT (NULL != Record);\r
+ ASSERT (Record != NULL);\r
\r
CurrentTpl = gBS->RaiseTPL (TPL_HIGH_LEVEL);\r
\r
gBS->RestoreTPL (CurrentTpl);\r
}\r
\r
-\r
-\r
/**\r
Report status code into DataHub.\r
\r
- @param CodeType Indicates the type of status code being reported. Type EFI_STATUS_CODE_TYPE is defined in "Related Definitions" below.\r
-\r
- @param Value Describes the current status of a hardware or software entity.\r
- This included information about the class and subclass that is used to classify the entity\r
- as well as an operation. For progress codes, the operation is the current activity.\r
- For error codes, it is the exception. For debug codes, it is not defined at this time.\r
- Type EFI_STATUS_CODE_VALUE is defined in "Related Definitions" below.\r
- Specific values are discussed in the Intel? Platform Innovation Framework for EFI Status Code Specification.\r
-\r
- @param Instance The enumeration of a hardware or software entity within the system.\r
- A system may contain multiple entities that match a class/subclass pairing.\r
- The instance differentiates between them. An instance of 0 indicates that instance information is unavailable,\r
- not meaningful, or not relevant. Valid instance numbers start with 1.\r
-\r
-\r
- @param CallerId This optional parameter may be used to identify the caller.\r
- This parameter allows the status code driver to apply different rules to different callers.\r
- Type EFI_GUID is defined in InstallProtocolInterface() in the UEFI 2.0 Specification.\r
-\r
-\r
- @param Data This optional parameter may be used to pass additional data\r
-\r
- @retval EFI_OUT_OF_RESOURCES Can not acquire record buffer.\r
- @retval EFI_DEVICE_ERROR EFI serial device can not work after ExitBootService() is called .\r
- @retval EFI_SUCCESS Success to cache status code and signal log data event.\r
+ @param CodeType Indicates the type of status code being reported.\r
+ @param Value Describes the current status of a hardware or software entity.\r
+ This included information about the class and subclass that is used to\r
+ classify the entity as well as an operation.\r
+ @param Instance The enumeration of a hardware or software entity within\r
+ the system. Valid instance numbers start with 1.\r
+ @param CallerId This optional parameter may be used to identify the caller.\r
+ This parameter allows the status code driver to apply different rules to\r
+ different callers.\r
+ @param Data This optional parameter may be used to pass additional data.\r
+\r
+ @retval EFI_SUCCESS The function completed successfully.\r
+ @retval EFI_DEVICE_ERROR Function is reentered.\r
+ @retval EFI_DEVICE_ERROR Function is called at runtime.\r
+ @retval EFI_OUT_OF_RESOURCES Fail to allocate memory for free record buffer.\r
\r
**/\r
EFI_STATUS\r
CHAR8 *Format;\r
UINTN CharCount;\r
\r
-\r
//\r
// Use atom operation to avoid the reentant of report.\r
// If current status is not zero, then the function is reentrancy.\r
//\r
- if (1 == InterlockedCompareExchange32 (&mLogDataHubStatus, 0, 0)) {\r
+ if (InterlockedCompareExchange32 (&mLogDataHubStatus, 0, 0) == 1) {\r
return EFI_DEVICE_ERROR;\r
}\r
\r
Marker\r
);\r
//\r
- // Change record data type from DebugType to String Type.\r
+ // Change record data type to DebugType.\r
//\r
CopyGuid (&Record->Data.Type, &gEfiStatusCodeDataTypeDebugGuid);\r
Record->Data.HeaderSize = Data->HeaderSize;\r
// Use atom operation to avoid the reentant of report.\r
// If current status is not zero, then the function is reentrancy.\r
//\r
- if (1 == InterlockedCompareExchange32 (&mLogDataHubStatus, 0, 1)) {\r
+ if (InterlockedCompareExchange32 (&mLogDataHubStatus, 0, 1) == 1) {\r
return;\r
}\r
\r
// Log DataRecord in Data Hub.\r
// Journal records fifo to find all record entry.\r
//\r
- while (1) {\r
+ while (TRUE) {\r
+ //\r
+ // Retrieve record from record FIFO until no more record can be retrieved.\r
+ //\r
Record = RetrieveRecord ();\r
if (Record == NULL) {\r
break;\r
//\r
// Log DataRecord in Data Hub\r
//\r
-\r
mDataHubProtocol->LogData (\r
mDataHubProtocol,\r
&gEfiDataHubStatusCodeRecordGuid,\r
\r
\r
/**\r
- Initialize data hubstatus code.\r
- Create a data hub listener.\r
+ Locate Data Hub Protocol and create event for logging data\r
+ as initialization for data hub status code worker.\r
\r
- @return The function always return EFI_SUCCESS\r
+ @retval EFI_SUCCESS Initialization is successful.\r
\r
**/\r
EFI_STATUS\r