STATIC\r
LIST_ENTRY mRecordsBuffer = INITIALIZE_LIST_HEAD_VARIABLE (mRecordsBuffer);\r
STATIC\r
+UINT32 mLogDataHubStatus = 0;\r
+STATIC\r
EFI_EVENT mLogDataHubEvent;\r
//\r
// Cache data hub protocol.\r
Record = _CR (Node, DATAHUB_STATUSCODE_RECORD, Node);\r
} else {\r
if (CurrentTpl > TPL_NOTIFY) {\r
+ //\r
+ // Memory management should work at <=TPL_NOTIFY\r
+ // \r
gBS->RestoreTPL (CurrentTpl);\r
return NULL;\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
\r
RemoveEntryList (&Record->Node);\r
- InsertTailList (&mRecordsBuffer, &Record->Node);\r
- Record->Signature = 0;\r
RecordData = (DATA_HUB_STATUS_CODE_DATA_RECORD *) Record->Data;\r
}\r
\r
return RecordData;\r
}\r
\r
+/**\r
+ Release Records to FIFO.\r
+ \r
+ @param RecordData Point to the record buffer allocated\r
+ from AcquireRecordBuffer.\r
+\r
+**/\r
+STATIC\r
+VOID\r
+ReleaseRecord (\r
+ DATA_HUB_STATUS_CODE_DATA_RECORD *RecordData\r
+ )\r
+{\r
+ DATAHUB_STATUSCODE_RECORD *Record;\r
+ EFI_TPL CurrentTpl;\r
+\r
+ Record = CR (RecordData, DATAHUB_STATUSCODE_RECORD, Data[0], DATAHUB_STATUS_CODE_SIGNATURE);\r
+ ASSERT (NULL != Record);\r
+\r
+ CurrentTpl = gBS->RaiseTPL (TPL_HIGH_LEVEL);\r
+\r
+ InsertTailList (&mRecordsBuffer, &Record->Node);\r
+ Record->Signature = 0;\r
+\r
+ gBS->RestoreTPL (CurrentTpl);\r
+}\r
+\r
+\r
\r
/**\r
Report status code into DataHub.\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
+ return EFI_DEVICE_ERROR;\r
+ }\r
+\r
//\r
// See whether in runtime phase or not.\r
//\r
UINT32 Size;\r
UINT64 DataRecordClass;\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, 1)) {\r
+ return;\r
+ }\r
+\r
//\r
// Log DataRecord in Data Hub.\r
// Journal records fifo to find all record entry.\r
Size\r
);\r
\r
+ ReleaseRecord (Record);\r
}\r
+\r
+ //\r
+ // Restore the nest status of report\r
+ //\r
+ InterlockedCompareExchange32 (&mLogDataHubStatus, 1, 0);\r
}\r
\r
\r