git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11008
6f19259b-4bc3-4df7-8a09-
765794883524
DATA_HUB_INSTANCE *Private;\r
DATA_HUB_FILTER_DRIVER *FilterDriver;\r
UINT64 ClassFilter;\r
DATA_HUB_INSTANCE *Private;\r
DATA_HUB_FILTER_DRIVER *FilterDriver;\r
UINT64 ClassFilter;\r
- UINT64 FilterMonotonicCount;\r
\r
Private = DATA_HUB_INSTANCE_FROM_THIS (This);\r
\r
FilterDriver = NULL;\r
\r
Private = DATA_HUB_INSTANCE_FROM_THIS (This);\r
\r
FilterDriver = NULL;\r
- FilterMonotonicCount = 0;\r
ClassFilter = EFI_DATA_RECORD_CLASS_DEBUG |\r
EFI_DATA_RECORD_CLASS_ERROR |\r
EFI_DATA_RECORD_CLASS_DATA |\r
EFI_DATA_RECORD_CLASS_PROGRESS_CODE;\r
\r
ClassFilter = EFI_DATA_RECORD_CLASS_DEBUG |\r
EFI_DATA_RECORD_CLASS_ERROR |\r
EFI_DATA_RECORD_CLASS_DATA |\r
EFI_DATA_RECORD_CLASS_PROGRESS_CODE;\r
\r
- if (FilterDriverEvent != NULL) {\r
- //\r
- // For events the beginning is the last unread record. This info is\r
- // stored in the instance structure, so we must look up the event\r
- // to get the data.\r
- //\r
- FilterDriver = FindFilterDriverByEvent (\r
- &Private->FilterDriverListHead,\r
- *FilterDriverEvent\r
- );\r
- if (FilterDriver == NULL) {\r
- return EFI_INVALID_PARAMETER;\r
+ //\r
+ // If FilterDriverEvent is NULL, then return the next record\r
+ //\r
+ if (FilterDriverEvent == NULL) {\r
+ *Record = GetNextDataRecord (&Private->DataListHead, ClassFilter, MonotonicCount);\r
+ if (*Record == NULL) {\r
+ return EFI_NOT_FOUND;\r
- //\r
- // Use the Class filter the event was created with.\r
- //\r
- ClassFilter = FilterDriver->ClassFilter;\r
+ return EFI_SUCCESS;\r
+ }\r
+ \r
+ //\r
+ // For events the beginning is the last unread record. This info is\r
+ // stored in the instance structure, so we must look up the event\r
+ // to get the data.\r
+ //\r
+ FilterDriver = FindFilterDriverByEvent (\r
+ &Private->FilterDriverListHead,\r
+ *FilterDriverEvent\r
+ );\r
+ if (FilterDriver == NULL) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+ //\r
+ // Use the Class filter the event was created with.\r
+ //\r
+ ClassFilter = FilterDriver->ClassFilter;\r
- if (*MonotonicCount == 0) {\r
+ //\r
+ // Retrieve the next record or the first record.\r
+ // \r
+ if (*MonotonicCount != 0 || FilterDriver->GetNextMonotonicCount == 0) { \r
+ *Record = GetNextDataRecord (&Private->DataListHead, ClassFilter, MonotonicCount);\r
+ if (*Record == NULL) {\r
+ return EFI_NOT_FOUND;\r
+ }\r
+ \r
+ if (*MonotonicCount != 0) {\r
- // Use the MTC from the Filter Driver.\r
+ // If this was not the last record then update the count associated with the filter \r
- FilterMonotonicCount = FilterDriver->GetNextMonotonicCount;\r
- \r
+ FilterDriver->GetNextMonotonicCount = *MonotonicCount;\r
+ } else {\r
- // The GetNextMonotonicCount field remembers the last value from the previous time.\r
- // But we already processed this vaule, so we need to find the next one.\r
+ // Save the MonotonicCount of the last record which has been read\r
- *Record = GetNextDataRecord (&Private->DataListHead, ClassFilter, &FilterMonotonicCount);\r
- if (FilterMonotonicCount != 0) {\r
- *MonotonicCount = FilterMonotonicCount;\r
- }\r
- \r
- if ((FilterDriver->GetNextMonotonicCount != 0) && (FilterMonotonicCount == 0)) {\r
- //\r
- // If there is no new record to get exit now.\r
- //\r
- *MonotonicCount = 0;\r
- return EFI_NOT_FOUND;\r
- }\r
+ FilterDriver->GetNextMonotonicCount = (*Record)->LogMonotonicCount;\r
+ // This is a request to read the first record that has not been read yet. \r
+ // Set MonotoicCount to the last record successfuly read\r
+ //\r
+ *MonotonicCount = FilterDriver->GetNextMonotonicCount;\r
+ \r
+ //\r
+ // Retrieve the last record successfuly read again, but do not return it since\r
+ // it has already been returned before.\r
//\r
*Record = GetNextDataRecord (&Private->DataListHead, ClassFilter, MonotonicCount);\r
if (*Record == NULL) {\r
return EFI_NOT_FOUND;\r
}\r
//\r
*Record = GetNextDataRecord (&Private->DataListHead, ClassFilter, MonotonicCount);\r
if (*Record == NULL) {\r
return EFI_NOT_FOUND;\r
}\r
-\r
- if (FilterDriver != NULL) {\r
+ \r
+ if (*MonotonicCount != 0) {\r
- // If we have a filter driver update the records that have been read.\r
- // If MonotonicCount is zero No more reacords left.\r
+ // Update the count associated with the filter \r
- if (*MonotonicCount == 0) {\r
- //\r
- // Save the current Record MonotonicCount.\r
- //\r
- FilterDriver->GetNextMonotonicCount = (*Record)->LogMonotonicCount;\r
- } else {\r
- //\r
- // Point to next undread record\r
- //\r
- FilterDriver->GetNextMonotonicCount = *MonotonicCount;\r
+ FilterDriver->GetNextMonotonicCount = *MonotonicCount;\r
+\r
+ //\r
+ // Retrieve the record after the last record successfuly read \r
+ // \r
+ *Record = GetNextDataRecord (&Private->DataListHead, ClassFilter, MonotonicCount);\r
+ if (*Record == NULL) {\r
+ return EFI_NOT_FOUND;\r
return EFI_SUCCESS;\r
}\r
\r
return EFI_SUCCESS;\r
}\r
\r