X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=MdeModulePkg%2FUniversal%2FPCD%2FDxe%2FService.c;fp=MdeModulePkg%2FUniversal%2FPCD%2FDxe%2FService.c;h=05171523662b3af8f612181af537e1ee78a74bd1;hp=1e487f04c3bdcfdee65ed7c491a8485111508e2a;hb=d1102dba7210b95e41d06c2338a22ba6af248645;hpb=ca79bab7af4770c5eb578f6d495af01705aedb79 diff --git a/MdeModulePkg/Universal/PCD/Dxe/Service.c b/MdeModulePkg/Universal/PCD/Dxe/Service.c index 1e487f04c3..0517152366 100644 --- a/MdeModulePkg/Universal/PCD/Dxe/Service.c +++ b/MdeModulePkg/Universal/PCD/Dxe/Service.c @@ -2,7 +2,7 @@ Help functions used by PCD DXE driver. Copyright (c) 2014, Hewlett-Packard Development Company, L.P.
-Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
(C) Copyright 2016 Hewlett Packard Enterprise Development LP
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License @@ -19,23 +19,23 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. PCD_DATABASE mPcdDatabase; -UINT32 mPcdTotalTokenCount; -UINT32 mPeiLocalTokenCount; -UINT32 mDxeLocalTokenCount; -UINT32 mPeiNexTokenCount; -UINT32 mDxeNexTokenCount; +UINT32 mPcdTotalTokenCount; +UINT32 mPeiLocalTokenCount; +UINT32 mDxeLocalTokenCount; +UINT32 mPeiNexTokenCount; +UINT32 mDxeNexTokenCount; UINT32 mPeiExMapppingTableSize; UINT32 mDxeExMapppingTableSize; UINT32 mPeiGuidTableSize; UINT32 mDxeGuidTableSize; -BOOLEAN mPeiExMapTableEmpty; -BOOLEAN mDxeExMapTableEmpty; +BOOLEAN mPeiExMapTableEmpty; +BOOLEAN mDxeExMapTableEmpty; BOOLEAN mPeiDatabaseEmpty; LIST_ENTRY *mCallbackFnTable; EFI_GUID **TmpTokenSpaceBuffer; -UINTN TmpTokenSpaceBufferCount; +UINTN TmpTokenSpaceBufferCount; UINTN mPeiPcdDbSize = 0; PEI_PCD_DATABASE *mPeiPcdDbBinary = NULL; @@ -66,7 +66,7 @@ GetLocalTokenNumber ( // TokenNumber--; - LocalTokenNumberTable = IsPeiDb ? (UINT32 *)((UINT8 *)mPcdDatabase.PeiDb + mPcdDatabase.PeiDb->LocalTokenNumberTableOffset) : + LocalTokenNumberTable = IsPeiDb ? (UINT32 *)((UINT8 *)mPcdDatabase.PeiDb + mPcdDatabase.PeiDb->LocalTokenNumberTableOffset) : (UINT32 *)((UINT8 *)mPcdDatabase.DxeDb + mPcdDatabase.DxeDb->LocalTokenNumberTableOffset); TokenNumber = IsPeiDb ? TokenNumber : TokenNumber - mPeiLocalTokenCount; @@ -133,7 +133,7 @@ GetPcdName ( CHAR8 *Name; // - // Return NULL when PCD name table is absent. + // Return NULL when PCD name table is absent. // if (IsPeiDb) { if (mPcdDatabase.PeiDb->PcdNameTableOffset == 0) { @@ -181,7 +181,7 @@ GetPcdName ( // AsciiStrCatS (Name, NameSize, TokenSpaceName); Name[AsciiStrSize (TokenSpaceName) - sizeof (CHAR8)] = '.'; - AsciiStrCatS (Name, NameSize, PcdName); + AsciiStrCatS (Name, NameSize, PcdName); } return Name; @@ -198,7 +198,7 @@ GetPcdName ( @param[in] Guid The 128-bit unique value that designates the namespace from which to extract the value. @param[in] TokenNumber The PCD token number. @param[out] PcdInfo The returned information associated with the requested TokenNumber. - The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName. + The caller is responsible for freeing the buffer that is allocated by callee for PcdInfo->PcdName. @retval EFI_SUCCESS The PCD information was returned successfully @retval EFI_NOT_FOUND The PCD service could not find the requested token number. @@ -247,7 +247,7 @@ ExGetPcdInfo ( PcdInfo->PcdSize = 0; // // Here use one representative in the token space to get the TokenSpaceCName. - // + // PcdInfo->PcdName = GetPcdName (TRUE, IsPeiDb, ExMapTable[Index].TokenNumber); return EFI_SUCCESS; } else if (ExMapTable[Index].ExTokenNumber == TokenNumber) { @@ -352,10 +352,10 @@ DxeGetPcdInfo ( /** Get the PCD entry pointer in PCD database. - + This routine will visit PCD database to find the PCD entry according to given - token number. The given token number is autogened by build tools and it will be - translated to local token number. Local token number contains PCD's type and + token number. The given token number is autogened by build tools and it will be + translated to local token number. Local token number contains PCD's type and offset of PCD entry in PCD database. @param TokenNumber Token's number, it is autogened by build tools @@ -385,7 +385,7 @@ GetWorker ( EFI_STATUS Status; UINT32 LocalTokenNumber; UINT32 Offset; - STRING_HEAD StringTableIdx; + STRING_HEAD StringTableIdx; BOOLEAN IsPeiDb; // @@ -407,7 +407,7 @@ GetWorker ( // // EBC compiler is very choosy. It may report warning about comparison - // between UINTN and 0 . So we add 1 in each size of the + // between UINTN and 0 . So we add 1 in each size of the // comparison. // ASSERT (TokenNumber + 1 < mPcdTotalTokenCount + 1); @@ -415,14 +415,14 @@ GetWorker ( ASSERT ((GetSize == DxePcdGetSize (TokenNumber + 1)) || (GetSize == 0)); // EBC compiler is very choosy. It may report warning about comparison - // between UINTN and 0 . So we add 1 in each size of the + // between UINTN and 0 . So we add 1 in each size of the // comparison. IsPeiDb = (BOOLEAN) ((TokenNumber + 1 < mPeiLocalTokenCount + 1) ? TRUE : FALSE); LocalTokenNumber = GetLocalTokenNumber (IsPeiDb, TokenNumber + 1); PcdDb = IsPeiDb ? ((UINT8 *) mPcdDatabase.PeiDb) : ((UINT8 *) mPcdDatabase.DxeDb); - + if (IsPeiDb) { StringTable = (UINT8 *) ((UINT8 *)mPcdDatabase.PeiDb + mPcdDatabase.PeiDb->StringTableOffset); } else { @@ -453,11 +453,11 @@ GetWorker ( if ((LocalTokenNumber & PCD_TYPE_ALL_SET) == (PCD_TYPE_HII|PCD_TYPE_STRING)) { // - // If a HII type PCD's datum type is VOID*, the DefaultValueOffset is the index of + // If a HII type PCD's datum type is VOID*, the DefaultValueOffset is the index of // string array in string table. // - StringTableIdx = *(STRING_HEAD*)((UINT8 *) PcdDb + VariableHead->DefaultValueOffset); - VaraiableDefaultBuffer = (UINT8 *) (StringTable + StringTableIdx); + StringTableIdx = *(STRING_HEAD*)((UINT8 *) PcdDb + VariableHead->DefaultValueOffset); + VaraiableDefaultBuffer = (UINT8 *) (StringTable + StringTableIdx); } else { VaraiableDefaultBuffer = (UINT8 *) PcdDb + VariableHead->DefaultValueOffset; } @@ -501,7 +501,7 @@ GetWorker ( default: ASSERT (FALSE); break; - + } EfiReleaseLock (&mPcdDatabaseLock); @@ -515,9 +515,9 @@ GetWorker ( This routine will register a callback function to a PCD entry by given token number and token space guid. - + @param TokenNumber PCD token's number, it is autogened by build tools. - @param Guid PCD token space's guid, + @param Guid PCD token space's guid, if not NULL, this PCD is dynamicEx type PCD. @param CallBackFunction Callback function pointer @@ -565,7 +565,7 @@ DxeRegisterCallBackWorker ( FnTableEntry->CallbackFn = CallBackFunction; InsertTailList (ListHead, &FnTableEntry->Node); - + return EFI_SUCCESS; } @@ -617,7 +617,7 @@ DxeUnRegisterCallBackWorker ( // RemoveEntryList (ListNode); FreePool (FnTableEntry); - + return EFI_SUCCESS; } ListNode = GetNextNode (ListHead, ListNode); @@ -628,16 +628,16 @@ DxeUnRegisterCallBackWorker ( /** Get next token number in given token space. - + This routine is used for dynamicEx type PCD. It will firstly scan token space - table to get token space according to given token space guid. Then scan given - token number in found token space, if found, then return next token number in + table to get token space according to given token space guid. Then scan given + token number in found token space, if found, then return next token number in this token space. - @param Guid Token space guid. Next token number will be scaned in + @param Guid Token space guid. Next token number will be scaned in this token space. - @param TokenNumber Token number. - If PCD_INVALID_TOKEN_NUMBER, return first token number in + @param TokenNumber Token number. + If PCD_INVALID_TOKEN_NUMBER, return first token number in token space table. If not PCD_INVALID_TOKEN_NUMBER, return next token number in token space table. @@ -668,8 +668,8 @@ ExGetNextTokeNumber ( UINTN ExMapTableCount; // - // Scan token space guid - // + // Scan token space guid + // MatchGuid = ScanGuid (GuidTable, SizeOfGuidTable, Guid); if (MatchGuid == NULL) { return EFI_NOT_FOUND; @@ -734,12 +734,12 @@ ExGetNextTokeNumber ( DXE_PCD_DATABASE * LocateExPcdBinary ( VOID -) +) { EFI_STATUS Status; - + // - // Search the External Pcd database from one section of current FFS, + // Search the External Pcd database from one section of current FFS, // and read it to memory // Status = GetSectionFromFfs ( @@ -838,7 +838,7 @@ UpdatePcdDatabase ( /** Initialize the PCD database in DXE phase. - + PCD database in DXE phase also contains PCD database in PEI phase which is copied from GUID Hob. @@ -869,7 +869,7 @@ BuildPcdDxeDataBase ( GuidHob = GetFirstGuidHob (&gPcdDataBaseHobGuid); if (GuidHob != NULL) { - // + // // If no PEIMs use dynamic Pcd Entry, the Pcd Service PEIM // should not be included at all. So the GuidHob could // be NULL. If it is NULL, we just copy over the DXE Default @@ -916,7 +916,7 @@ BuildPcdDxeDataBase ( mPcdTotalTokenCount = mPeiLocalTokenCount + mDxeLocalTokenCount; mPeiNexTokenCount = mPeiLocalTokenCount - mPcdDatabase.PeiDb->ExTokenCount; - mDxeNexTokenCount = mDxeLocalTokenCount - mPcdDatabase.DxeDb->ExTokenCount; + mDxeNexTokenCount = mDxeLocalTokenCount - mPcdDatabase.DxeDb->ExTokenCount; mPeiExMapTableEmpty = (mPcdDatabase.PeiDb->ExTokenCount == 0) ? TRUE : FALSE; mDxeExMapTableEmpty = (mPcdDatabase.DxeDb->ExTokenCount == 0) ? TRUE : FALSE; @@ -933,7 +933,7 @@ BuildPcdDxeDataBase ( // // EBC compiler is very choosy. It may report warning about comparison - // between UINTN and 0 . So we add 1 in each size of the + // between UINTN and 0 . So we add 1 in each size of the // comparison. // for (Index = 0; Index + 1 < mPcdTotalTokenCount + 1; Index++) { @@ -946,7 +946,7 @@ BuildPcdDxeDataBase ( @param VariableGuid Variable's guid @param VariableName Variable's unicode name string - @param VariableData Variable's data pointer, + @param VariableData Variable's data pointer, @param VariableSize Variable's size. @return the status of gRT->GetVariable @@ -965,7 +965,7 @@ GetHiiVariable ( Size = 0; Buffer = NULL; - + // // Firstly get the real size of HII variable // @@ -976,7 +976,7 @@ GetHiiVariable ( &Size, Buffer ); - + // // Allocate buffer to hold whole variable data according to variable size. // @@ -998,7 +998,7 @@ GetHiiVariable ( *VariableSize = Size; } else { // - // Use Default Data only when variable is not found. + // Use Default Data only when variable is not found. // For other error status, correct data can't be got, and trig ASSERT(). // ASSERT (Status == EFI_NOT_FOUND); @@ -1008,7 +1008,7 @@ GetHiiVariable ( } /** - Invoke the callback function when dynamic PCD entry was set, if this PCD entry + Invoke the callback function when dynamic PCD entry was set, if this PCD entry has registered callback function. @param ExTokenNumber DynamicEx PCD's token number, if this PCD entry is dyanmicEx @@ -1044,14 +1044,14 @@ InvokeCallbackOnSet ( while (ListNode != ListHead) { FnTableEntry = CR_FNENTRY_FROM_LISTNODE (ListNode, CALLBACK_FN_ENTRY, Node); - FnTableEntry->CallbackFn(Guid, + FnTableEntry->CallbackFn(Guid, (Guid == NULL) ? TokenNumber : ExTokenNumber, Data, Size); - + ListNode = GetNextNode (ListHead, ListNode); } - + return; } @@ -1088,10 +1088,10 @@ SetValueWorker ( @retval EFI_INVALID_PARAMETER If this PCD type is VPD, VPD PCD can not be set. @retval EFI_INVALID_PARAMETER If Size can not be set to size table. - @retval EFI_INVALID_PARAMETER If Size of non-Ptr type PCD does not match the size information in PCD database. + @retval EFI_INVALID_PARAMETER If Size of non-Ptr type PCD does not match the size information in PCD database. @retval EFI_NOT_FOUND If value type of PCD entry is intergrate, but not in range of UINT8, UINT16, UINT32, UINT64 - @retval EFI_NOT_FOUND Can not find the PCD type according to token number. + @retval EFI_NOT_FOUND Can not find the PCD type according to token number. **/ EFI_STATUS SetWorker ( @@ -1125,10 +1125,10 @@ SetWorker ( TokenNumber--; TmpTokenNumber = TokenNumber; - + // // EBC compiler is very choosy. It may report warning about comparison - // between UINTN and 0 . So we add 1 in each size of the + // between UINTN and 0 . So we add 1 in each size of the // comparison. // ASSERT (TokenNumber + 1 < mPcdTotalTokenCount + 1); @@ -1150,7 +1150,7 @@ SetWorker ( // // EBC compiler is very choosy. It may report warning about comparison - // between UINTN and 0 . So we add 1 in each size of the + // between UINTN and 0 . So we add 1 in each size of the // comparison. // if ((TokenNumber + 1 < mPeiNexTokenCount + 1) || @@ -1165,7 +1165,7 @@ SetWorker ( // // EBC compiler is very choosy. It may report warning about comparison - // between UINTN and 0 . So we add 1 in each size of the + // between UINTN and 0 . So we add 1 in each size of the // comparison. // IsPeiDb = (BOOLEAN) ((TokenNumber + 1 < mPeiLocalTokenCount + 1) ? TRUE : FALSE); @@ -1182,7 +1182,7 @@ SetWorker ( StringTable = (UINT8 *) ((UINT8 *)mPcdDatabase.DxeDb + mPcdDatabase.DxeDb->StringTableOffset); } - + InternalData = PcdDb + Offset; switch (LocalTokenNumber & PCD_TYPE_ALL_SET) { @@ -1190,7 +1190,7 @@ SetWorker ( ASSERT (FALSE); Status = EFI_INVALID_PARAMETER; break; - + case PCD_TYPE_STRING: if (SetPtrTypeSize (TmpTokenNumber, Size)) { CopyMem (StringTable + *((STRING_HEAD *)InternalData), Data, *Size); @@ -1223,7 +1223,7 @@ SetWorker ( Attributes = VariableHead->Attributes; Status = SetHiiVariable (Guid, Name, Attributes, Data, *Size, VariableOffset); break; - + case PCD_TYPE_DATA: if (PtrType) { if (SetPtrTypeSize (TmpTokenNumber, Size)) { @@ -1267,7 +1267,7 @@ SetWorker ( } EfiReleaseLock (&mPcdDatabaseLock); - + return Status; } @@ -1286,7 +1286,7 @@ ExGetWorker ( IN CONST EFI_GUID *Guid, IN UINTN ExTokenNumber, IN UINTN GetSize - ) + ) { return GetWorker(GetExPcdTokenNumber (Guid, (UINT32) ExTokenNumber), GetSize); } @@ -1315,12 +1315,12 @@ ExSetValueWorker ( /** Set value for a dynamic-ex PCD entry. - - This routine find the local token number according to dynamic-ex PCD's token + + This routine find the local token number according to dynamic-ex PCD's token space guid and token number firstly, and invoke callback function if this PCD entry registered callback function. Finally, invoken general SetWorker to set PCD value. - + @param ExTokenNumber Dynamic-ex PCD token number. @param Guid Token space guid for dynamic-ex PCD. @param Data PCD value want to be set @@ -1341,7 +1341,7 @@ ExSetWorker ( ) { UINTN TokenNumber; - + TokenNumber = GetExPcdTokenNumber (Guid, (UINT32) ExTokenNumber); InvokeCallbackOnSet ((UINT32) ExTokenNumber, Guid, TokenNumber, Data, *SetSize); @@ -1431,9 +1431,9 @@ GetVariableSizeAndDataFromHiiPcd ( /** Set value for HII-type PCD. - A HII-type PCD's value is stored in a variable. Setting/Getting the value of + A HII-type PCD's value is stored in a variable. Setting/Getting the value of HII-type PCD is to visit this variable. - + @param VariableGuid Guid of variable which stored value of a HII-type PCD. @param VariableName Unicode name of variable which stored value of a HII-type PCD. @param SetAttributes Attributes bitmask to set for the variable. @@ -1473,7 +1473,7 @@ SetHiiVariable ( &Size, NULL ); - + if (Status == EFI_BUFFER_TOO_SMALL) { // // Patch new PCD's value to offset in given HII variable. @@ -1493,7 +1493,7 @@ SetHiiVariable ( &Size, Buffer ); - + ASSERT_EFI_ERROR (Status); CopyMem ((UINT8 *)Buffer + Offset, Data, DataSize); @@ -1543,9 +1543,9 @@ SetHiiVariable ( ); FreePool (Buffer); - return Status; + return Status; } - + // // If we drop to here, the value is failed to be written in to variable area. // @@ -1558,14 +1558,14 @@ SetHiiVariable ( A dynamic-ex type PCD, developer must provide pair of token space guid: token number in DEC file. PCD database maintain a mapping table that translate pair of {token space guid: token number} to Token Number. - + @param Guid Token space guid for dynamic-ex PCD entry. @param ExTokenNumber Dynamic-ex PCD token number. @return Token Number for dynamic-ex PCD. **/ -UINTN +UINTN GetExPcdTokenNumber ( IN CONST EFI_GUID *Guid, IN UINT32 ExTokenNumber @@ -1622,7 +1622,7 @@ GetExPcdTokenNumber ( /** Wrapper function of getting index of PCD entry in size table. - + @param LocalTokenNumberTableIdx Index of this PCD in local token number table. @param IsPeiDb If TRUE, the pcd entry is initialized in PEI phase, If FALSE, the pcd entry is initialized in DXE phase. @@ -1639,7 +1639,7 @@ GetSizeTableIndex ( UINTN LocalTokenNumber; UINTN Index; UINTN SizeTableIdx; - + if (IsPeiDb) { LocalTokenNumberTable = (UINT32 *)((UINT8 *)mPcdDatabase.PeiDb + mPcdDatabase.PeiDb->LocalTokenNumberTableOffset); } else { @@ -1653,7 +1653,7 @@ GetSizeTableIndex ( if ((LocalTokenNumber & PCD_DATUM_TYPE_ALL_SET) == PCD_DATUM_TYPE_POINTER) { // - // SizeTable only contain record for PCD_DATUM_TYPE_POINTER type + // SizeTable only contain record for PCD_DATUM_TYPE_POINTER type // PCD entry. // if ((LocalTokenNumber & PCD_TYPE_VPD) != 0) { @@ -1676,7 +1676,7 @@ GetSizeTableIndex ( } - return SizeTableIdx; + return SizeTableIdx; } /** @@ -1701,7 +1701,7 @@ GetPtrTypeSize ( UINT32 *LocalTokenNumberTable; // EBC compiler is very choosy. It may report warning about comparison - // between UINTN and 0 . So we add 1 in each size of the + // between UINTN and 0 . So we add 1 in each size of the // comparison. IsPeiDb = (BOOLEAN) (LocalTokenNumberTableIdx + 1 < mPeiLocalTokenCount + 1); @@ -1718,12 +1718,12 @@ GetPtrTypeSize ( LocalTokenNumber = LocalTokenNumberTable[LocalTokenNumberTableIdx]; ASSERT ((LocalTokenNumber & PCD_DATUM_TYPE_ALL_SET) == PCD_DATUM_TYPE_POINTER); - + SizeTableIdx = GetSizeTableIndex (LocalTokenNumberTableIdx, IsPeiDb); *MaxSize = SizeTable[SizeTableIdx]; // - // SizeTable only contain record for PCD_DATUM_TYPE_POINTER type + // SizeTable only contain record for PCD_DATUM_TYPE_POINTER type // PCD entry. // if ((LocalTokenNumber & PCD_TYPE_VPD) != 0) { @@ -1769,7 +1769,7 @@ SetPtrTypeSize ( // // EBC compiler is very choosy. It may report warning about comparison - // between UINTN and 0 . So we add 1 in each size of the + // between UINTN and 0 . So we add 1 in each size of the // comparison. // IsPeiDb = (BOOLEAN) (LocalTokenNumberTableIdx + 1 < mPeiLocalTokenCount + 1); @@ -1786,12 +1786,12 @@ SetPtrTypeSize ( LocalTokenNumber = LocalTokenNumberTable[LocalTokenNumberTableIdx]; ASSERT ((LocalTokenNumber & PCD_DATUM_TYPE_ALL_SET) == PCD_DATUM_TYPE_POINTER); - + SizeTableIdx = GetSizeTableIndex (LocalTokenNumberTableIdx, IsPeiDb); MaxSize = SizeTable[SizeTableIdx]; // - // SizeTable only contain record for PCD_DATUM_TYPE_POINTER type + // SizeTable only contain record for PCD_DATUM_TYPE_POINTER type // PCD entry. // if ((LocalTokenNumber & PCD_TYPE_VPD) != 0) { @@ -1805,8 +1805,8 @@ SetPtrTypeSize ( (*CurrentSize == MAX_ADDRESS)) { *CurrentSize = MaxSize; return FALSE; - } - + } + // // We have only two entry for Non-Sku enabled PCD entry: // 1) MAX SIZE @@ -1833,7 +1833,7 @@ VariableLockDynamicHiiPcd ( { EFI_STATUS Status; PCD_DATABASE_INIT *Database; - UINT32 LocalTokenCount; + UINT32 LocalTokenCount; UINTN TokenNumber; UINT32 LocalTokenNumber; UINTN Offset;