mirror of https://github.com/acidanthera/audk.git
Fix bug in DataHub where it would skip the first record in a set when a filter is being used. Also add comments and update source code logic to make it easier to understand and maintain.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11008 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
3e516e5e0f
commit
d2720e0ce8
|
@ -286,18 +286,26 @@ DataHubGetNextRecord (
|
||||||
DATA_HUB_INSTANCE *Private;
|
DATA_HUB_INSTANCE *Private;
|
||||||
DATA_HUB_FILTER_DRIVER *FilterDriver;
|
DATA_HUB_FILTER_DRIVER *FilterDriver;
|
||||||
UINT64 ClassFilter;
|
UINT64 ClassFilter;
|
||||||
UINT64 FilterMonotonicCount;
|
|
||||||
|
|
||||||
Private = DATA_HUB_INSTANCE_FROM_THIS (This);
|
Private = DATA_HUB_INSTANCE_FROM_THIS (This);
|
||||||
|
|
||||||
FilterDriver = NULL;
|
FilterDriver = NULL;
|
||||||
FilterMonotonicCount = 0;
|
|
||||||
ClassFilter = EFI_DATA_RECORD_CLASS_DEBUG |
|
ClassFilter = EFI_DATA_RECORD_CLASS_DEBUG |
|
||||||
EFI_DATA_RECORD_CLASS_ERROR |
|
EFI_DATA_RECORD_CLASS_ERROR |
|
||||||
EFI_DATA_RECORD_CLASS_DATA |
|
EFI_DATA_RECORD_CLASS_DATA |
|
||||||
EFI_DATA_RECORD_CLASS_PROGRESS_CODE;
|
EFI_DATA_RECORD_CLASS_PROGRESS_CODE;
|
||||||
|
|
||||||
if (FilterDriverEvent != NULL) {
|
//
|
||||||
|
// If FilterDriverEvent is NULL, then return the next record
|
||||||
|
//
|
||||||
|
if (FilterDriverEvent == NULL) {
|
||||||
|
*Record = GetNextDataRecord (&Private->DataListHead, ClassFilter, MonotonicCount);
|
||||||
|
if (*Record == NULL) {
|
||||||
|
return EFI_NOT_FOUND;
|
||||||
|
}
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// For events the beginning is the last unread record. This info is
|
// For events the beginning is the last unread record. This info is
|
||||||
// stored in the instance structure, so we must look up the event
|
// stored in the instance structure, so we must look up the event
|
||||||
|
@ -315,53 +323,56 @@ DataHubGetNextRecord (
|
||||||
//
|
//
|
||||||
ClassFilter = FilterDriver->ClassFilter;
|
ClassFilter = FilterDriver->ClassFilter;
|
||||||
|
|
||||||
if (*MonotonicCount == 0) {
|
|
||||||
//
|
//
|
||||||
// Use the MTC from the Filter Driver.
|
// Retrieve the next record or the first record.
|
||||||
//
|
//
|
||||||
FilterMonotonicCount = FilterDriver->GetNextMonotonicCount;
|
if (*MonotonicCount != 0 || FilterDriver->GetNextMonotonicCount == 0) {
|
||||||
|
*Record = GetNextDataRecord (&Private->DataListHead, ClassFilter, MonotonicCount);
|
||||||
//
|
if (*Record == NULL) {
|
||||||
// The GetNextMonotonicCount field remembers the last value from the previous time.
|
|
||||||
// But we already processed this vaule, so we need to find the next one.
|
|
||||||
//
|
|
||||||
*Record = GetNextDataRecord (&Private->DataListHead, ClassFilter, &FilterMonotonicCount);
|
|
||||||
if (FilterMonotonicCount != 0) {
|
|
||||||
*MonotonicCount = FilterMonotonicCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((FilterDriver->GetNextMonotonicCount != 0) && (FilterMonotonicCount == 0)) {
|
|
||||||
//
|
|
||||||
// If there is no new record to get exit now.
|
|
||||||
//
|
|
||||||
*MonotonicCount = 0;
|
|
||||||
return EFI_NOT_FOUND;
|
return EFI_NOT_FOUND;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
if (*MonotonicCount != 0) {
|
||||||
//
|
//
|
||||||
// Return the record
|
// If this was not the last record then update the count associated with the filter
|
||||||
|
//
|
||||||
|
FilterDriver->GetNextMonotonicCount = *MonotonicCount;
|
||||||
|
} else {
|
||||||
|
//
|
||||||
|
// Save the MonotonicCount of the last record which has been read
|
||||||
|
//
|
||||||
|
FilterDriver->GetNextMonotonicCount = (*Record)->LogMonotonicCount;
|
||||||
|
}
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// This is a request to read the first record that has not been read yet.
|
||||||
|
// Set MonotoicCount to the last record successfuly read
|
||||||
|
//
|
||||||
|
*MonotonicCount = FilterDriver->GetNextMonotonicCount;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Retrieve the last record successfuly read again, but do not return it since
|
||||||
|
// it has already been returned before.
|
||||||
//
|
//
|
||||||
*Record = GetNextDataRecord (&Private->DataListHead, ClassFilter, MonotonicCount);
|
*Record = GetNextDataRecord (&Private->DataListHead, ClassFilter, MonotonicCount);
|
||||||
if (*Record == NULL) {
|
if (*Record == NULL) {
|
||||||
return EFI_NOT_FOUND;
|
return EFI_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FilterDriver != NULL) {
|
if (*MonotonicCount != 0) {
|
||||||
//
|
//
|
||||||
// If we have a filter driver update the records that have been read.
|
// Update the count associated with the filter
|
||||||
// If MonotonicCount is zero No more reacords left.
|
|
||||||
//
|
|
||||||
if (*MonotonicCount == 0) {
|
|
||||||
//
|
|
||||||
// Save the current Record MonotonicCount.
|
|
||||||
//
|
|
||||||
FilterDriver->GetNextMonotonicCount = (*Record)->LogMonotonicCount;
|
|
||||||
} else {
|
|
||||||
//
|
|
||||||
// Point to next undread record
|
|
||||||
//
|
//
|
||||||
FilterDriver->GetNextMonotonicCount = *MonotonicCount;
|
FilterDriver->GetNextMonotonicCount = *MonotonicCount;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Retrieve the record after the last record successfuly read
|
||||||
|
//
|
||||||
|
*Record = GetNextDataRecord (&Private->DataListHead, ClassFilter, MonotonicCount);
|
||||||
|
if (*Record == NULL) {
|
||||||
|
return EFI_NOT_FOUND;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue