X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=EdkModulePkg%2FUniversal%2FPCD%2FDxe%2FService.c;h=51e16624efcd51aa35eab70c9c34d12b98a84bfe;hp=a2706d0bd3949c166845d50ead7f86bc16a1297e;hb=d57d21b5ba5a044778a2b1b4cf7b1762eaf68992;hpb=4f914125e83bc2fa88862432b8194c4e2485189f diff --git a/EdkModulePkg/Universal/PCD/Dxe/Service.c b/EdkModulePkg/Universal/PCD/Dxe/Service.c index a2706d0bd3..51e16624ef 100644 --- a/EdkModulePkg/Universal/PCD/Dxe/Service.c +++ b/EdkModulePkg/Universal/PCD/Dxe/Service.c @@ -1,7 +1,7 @@ /** @file -Private functions used by PCD DXE driver.s +Private functions used by PCD DXE driver. -Copyright (c) 2006, Intel Corporation +Copyright (c) 2006 - 2007, Intel Corporation All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -17,11 +17,6 @@ Module Name: Service.c #include "Service.h" -// -// Build Tool will generate DXE_PCD_DB_INIT_VALUE in Autogen.h -// Compression Algorithm will take care of the size optimization. -// - PCD_DATABASE * mPcdDatabase; LIST_ENTRY *mCallbackFnTable; @@ -34,24 +29,31 @@ GetWorker ( { UINT32 *LocalTokenNumberTable; UINT16 *SizeTable; - BOOLEAN IsPeiDb; - UINT32 Offset; EFI_GUID *GuidTable; UINT16 *StringTable; EFI_GUID *Guid; UINT16 *Name; VARIABLE_HEAD *VariableHead; UINT8 *VaraiableDefaultBuffer; - EFI_STATUS Status; - UINTN DataSize; UINT8 *Data; VPD_HEAD *VpdHead; UINT8 *PcdDb; - UINT16 StringTableIdx; - UINT32 LocalTokenNumber; + VOID *RetPtr; UINTN MaxSize; UINTN TmpTokenNumber; + UINTN DataSize; + EFI_STATUS Status; + UINT32 LocalTokenNumber; + UINT32 Offset; + UINT16 StringTableIdx; + BOOLEAN IsPeiDb; + + // + // Aquire lock to prevent reentrance from TPL_CALLBACK level + // + EfiAcquireLock (&mPcdDatabaseLock); + RetPtr = NULL; // // TokenNumber Zero is reserved as PCD_INVALID_TOKEN_NUMBER. // We have to decrement TokenNumber by 1 to make it usable @@ -105,7 +107,8 @@ GetWorker ( switch (LocalTokenNumber & PCD_TYPE_ALL_SET) { case PCD_TYPE_VPD: VpdHead = (VPD_HEAD *) ((UINT8 *) PcdDb + Offset); - return (VOID *) (UINTN) (FixedPcdGet32(PcdVpdBaseAddress) + VpdHead->Offset); + RetPtr = (VOID *) (UINTN) (FixedPcdGet32(PcdVpdBaseAddress) + VpdHead->Offset); + break; case PCD_TYPE_HII: GuidTable = IsPeiDb ? mPcdDatabase->PeiDb.Init.GuidTable : @@ -124,7 +127,7 @@ GetWorker ( // It is a pointer type. So get the MaxSize reserved for // this PCD entry. // - GetPtrTypeSize (TokenNumber, &GetSize); + GetPtrTypeSize (TmpTokenNumber, &GetSize); } CopyMem (VaraiableDefaultBuffer, Data + VariableHead->Offset, GetSize); FreePool (Data); @@ -139,14 +142,16 @@ GetWorker ( // Return 1) either the default value specified by Platform Integrator // 2) Or the value Set by a PCD set operation. // - return (VOID *) VaraiableDefaultBuffer; + RetPtr = (VOID *) VaraiableDefaultBuffer; + break; case PCD_TYPE_STRING: StringTableIdx = (UINT16) *((UINT8 *) PcdDb + Offset); - return (VOID *) &StringTable[StringTableIdx]; + RetPtr = (VOID *) &StringTable[StringTableIdx]; + break; case PCD_TYPE_DATA: - return (VOID *) ((UINT8 *) PcdDb + Offset); + RetPtr = (VOID *) ((UINT8 *) PcdDb + Offset); break; default: @@ -155,9 +160,9 @@ GetWorker ( } - ASSERT (FALSE); - - return NULL; + EfiReleaseLock (&mPcdDatabaseLock); + + return RetPtr; } @@ -341,7 +346,6 @@ BuildPcdDxeDataBase ( ASSERT (mPcdDatabase != NULL); GuidHob = GetFirstGuidHob (&gPcdDataBaseHobGuid); - if (GuidHob != NULL) { // @@ -566,6 +570,11 @@ 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 @@ -627,20 +636,23 @@ SetWorker ( switch (LocalTokenNumber & PCD_TYPE_ALL_SET) { case PCD_TYPE_VPD: ASSERT (FALSE); - return EFI_INVALID_PARAMETER; + Status = EFI_INVALID_PARAMETER; + break; case PCD_TYPE_STRING: - if (SetPtrTypeSize (TokenNumber, Size)) { + if (SetPtrTypeSize (TmpTokenNumber, Size)) { CopyMem (&StringTable[*((UINT16 *)InternalData)], Data, *Size); - return EFI_SUCCESS; + Status = EFI_SUCCESS; } else { - return EFI_INVALID_PARAMETER; + Status = EFI_INVALID_PARAMETER; } + break; case PCD_TYPE_HII: if (PtrType) { - if (!SetPtrTypeSize (TokenNumber, Size)) { - return EFI_INVALID_PARAMETER; + if (!SetPtrTypeSize (TmpTokenNumber, Size)) { + Status = EFI_INVALID_PARAMETER; + break; } } @@ -657,54 +669,55 @@ SetWorker ( if (EFI_NOT_FOUND == Status) { CopyMem (PcdDb + VariableHead->DefaultValueOffset, Data, *Size); - return EFI_SUCCESS; - } else { - return Status; - } + Status = EFI_SUCCESS; + } + break; - // - // Bug Bug: Please implement this - // - case PCD_TYPE_DATA: if (PtrType) { - if (SetPtrTypeSize (TokenNumber, Size)) { + if (SetPtrTypeSize (TmpTokenNumber, Size)) { CopyMem (InternalData, Data, *Size); - return EFI_SUCCESS; + Status = EFI_SUCCESS; } else { - return EFI_INVALID_PARAMETER; + Status = EFI_INVALID_PARAMETER; } + break; } + Status = EFI_SUCCESS; switch (*Size) { case sizeof(UINT8): *((UINT8 *) InternalData) = *((UINT8 *) Data); - return EFI_SUCCESS; + break; case sizeof(UINT16): *((UINT16 *) InternalData) = *((UINT16 *) Data); - return EFI_SUCCESS; + break; case sizeof(UINT32): *((UINT32 *) InternalData) = *((UINT32 *) Data); - return EFI_SUCCESS; + break; case sizeof(UINT64): *((UINT64 *) InternalData) = *((UINT64 *) Data); - return EFI_SUCCESS; + break; default: ASSERT (FALSE); - return EFI_NOT_FOUND; + Status = EFI_NOT_FOUND; + break; } + break; default: ASSERT (FALSE); + Status = EFI_NOT_FOUND; break; } - - ASSERT (FALSE); - return EFI_NOT_FOUND; + + EfiReleaseLock (&mPcdDatabaseLock); + + return Status; } @@ -777,7 +790,7 @@ SetHiiVariable ( Status = gRT->GetVariable ( (UINT16 *)VariableName, VariableGuid, - &Attribute, + NULL, &Size, NULL );