mirror of https://github.com/acidanthera/audk.git
Pass the correct TokenNumber into a CallbackOnSet notification function. The value being passed in was off by 1.
This would not normally cause an issue because the correct notification function was being called. There is only an issue if the same notification function is being used for multiple tokens, and the notification function needs to use the TokenNumber parameter to determine which token setting caused the callback function to be called. Update the logic so the CallbackOnSet notification functions are not called with the internal PCD database lock in the acquired state. This allows other PCD Get/Set operations to be performed from within a CallbackOnSet notification. Update logic so the PCD database lock is not left in the acquired state when SetWorker() returns EFI_INVALID_PARAMETER. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9981 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
736c5dd580
commit
b07a5b68ad
|
@ -213,11 +213,9 @@ DxeRegisterCallBackWorker (
|
|||
//
|
||||
// TokenNumber Zero is reserved as PCD_INVALID_TOKEN_NUMBER.
|
||||
// We have to decrement TokenNumber by 1 to make it usable
|
||||
// as the array index.
|
||||
// as the array index of mCallbackFnTable[].
|
||||
//
|
||||
TokenNumber--;
|
||||
|
||||
ListHead = &mCallbackFnTable[TokenNumber];
|
||||
ListHead = &mCallbackFnTable[TokenNumber - 1];
|
||||
ListNode = GetFirstNode (ListHead);
|
||||
|
||||
while (ListNode != ListHead) {
|
||||
|
@ -274,11 +272,9 @@ DxeUnRegisterCallBackWorker (
|
|||
//
|
||||
// TokenNumber Zero is reserved as PCD_INVALID_TOKEN_NUMBER.
|
||||
// We have to decrement TokenNumber by 1 to make it usable
|
||||
// as the array index.
|
||||
// as the array index of mCallbackFnTable[].
|
||||
//
|
||||
TokenNumber--;
|
||||
|
||||
ListHead = &mCallbackFnTable[TokenNumber];
|
||||
ListHead = &mCallbackFnTable[TokenNumber - 1];
|
||||
ListNode = GetFirstNode (ListHead);
|
||||
|
||||
while (ListNode != ListHead) {
|
||||
|
@ -624,11 +620,9 @@ InvokeCallbackOnSet (
|
|||
//
|
||||
// TokenNumber Zero is reserved as PCD_INVALID_TOKEN_NUMBER.
|
||||
// We have to decrement TokenNumber by 1 to make it usable
|
||||
// as the array index.
|
||||
// as the array index of mCallbackFnTable[].
|
||||
//
|
||||
TokenNumber--;
|
||||
|
||||
ListHead = &mCallbackFnTable[TokenNumber];
|
||||
ListHead = &mCallbackFnTable[TokenNumber - 1];
|
||||
ListNode = GetFirstNode (ListHead);
|
||||
|
||||
while (ListNode != ListHead) {
|
||||
|
@ -707,11 +701,6 @@ SetWorker (
|
|||
UINTN MaxSize;
|
||||
UINTN TmpTokenNumber;
|
||||
|
||||
//
|
||||
// Aquire lock to prevent reentrance from TPL_CALLBACK level
|
||||
//
|
||||
EfiAcquireLock (&mPcdDatabaseLock);
|
||||
|
||||
//
|
||||
// TokenNumber Zero is reserved as PCD_INVALID_TOKEN_NUMBER.
|
||||
// We have to decrement TokenNumber by 1 to make it usable
|
||||
|
@ -737,20 +726,25 @@ SetWorker (
|
|||
// between UINTN and 0 . So we add 1 in each size of the
|
||||
// comparison.
|
||||
//
|
||||
IsPeiDb = (BOOLEAN) ((TokenNumber + 1 < PEI_LOCAL_TOKEN_NUMBER + 1) ? TRUE : FALSE);
|
||||
if ((TokenNumber + 1 < PEI_NEX_TOKEN_NUMBER + 1) ||
|
||||
(TokenNumber + 1 >= PEI_LOCAL_TOKEN_NUMBER + 1 || TokenNumber + 1 < (PEI_LOCAL_TOKEN_NUMBER + DXE_NEX_TOKEN_NUMBER + 1))) {
|
||||
InvokeCallbackOnSet (0, NULL, TokenNumber + 1, Data, *Size);
|
||||
}
|
||||
|
||||
LocalTokenNumberTable = IsPeiDb ? mPcdDatabase->PeiDb.Init.LocalTokenNumberTable :
|
||||
mPcdDatabase->DxeDb.Init.LocalTokenNumberTable;
|
||||
//
|
||||
// Aquire lock to prevent reentrance from TPL_CALLBACK level
|
||||
//
|
||||
EfiAcquireLock (&mPcdDatabaseLock);
|
||||
|
||||
//
|
||||
// EBC compiler is very choosy. It may report warning about comparison
|
||||
// between UINTN and 0 . So we add 1 in each size of the
|
||||
// comparison.
|
||||
//
|
||||
if ((TokenNumber + 1 < PEI_NEX_TOKEN_NUMBER + 1) ||
|
||||
(TokenNumber + 1 >= PEI_LOCAL_TOKEN_NUMBER + 1 || TokenNumber + 1 < (PEI_LOCAL_TOKEN_NUMBER + DXE_NEX_TOKEN_NUMBER + 1))) {
|
||||
InvokeCallbackOnSet (0, NULL, TokenNumber + 1, Data, *Size);
|
||||
}
|
||||
IsPeiDb = (BOOLEAN) ((TokenNumber + 1 < PEI_LOCAL_TOKEN_NUMBER + 1) ? TRUE : FALSE);
|
||||
|
||||
LocalTokenNumberTable = IsPeiDb ? mPcdDatabase->PeiDb.Init.LocalTokenNumberTable :
|
||||
mPcdDatabase->DxeDb.Init.LocalTokenNumberTable;
|
||||
|
||||
TokenNumber = IsPeiDb ? TokenNumber
|
||||
: TokenNumber - PEI_LOCAL_TOKEN_NUMBER;
|
||||
|
|
Loading…
Reference in New Issue