Check in the Pcd service Driver/PEIM according to the new way of generating PCD Database

LIMITATION:

1) ONLY dynamic type PCD is supported for now. DynamicEx is not supported.
2) HII enable and VPD is not tested.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@253 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
qwang12 2006-05-24 08:16:20 +00:00
parent dbdaaec45c
commit 52e1905d39
8 changed files with 1648 additions and 1359 deletions

View File

@ -304,6 +304,15 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
<MsaFile>
<Filename>Universal/Network/Snp32_64/Dxe/SNP.msa</Filename>
</MsaFile>
<MsaFile>
<Filename>Universal/PCD/Pei/Pcd.msa</Filename>
</MsaFile>
<MsaFile>
<Filename>Universal/PCD/Test/PeiPcdTest.msa</Filename>
</MsaFile>
<MsaFile>
<Filename>Universal/PCD/Dxe/Pcd.msa</Filename>
</MsaFile>
<MsaFile>
<Filename>Universal/Runtime/RuntimeDxe/Runtime.msa</Filename>
</MsaFile>
@ -347,6 +356,14 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
<IncludeHeader ModuleType="UEFI_DRIVER">Include/EdkDxe.h</IncludeHeader>
</PackageHeaders>
<GuidDeclarations>
<Entry Name="PcdDataBaseHob">
<C_Name>gPcdDataBaseHobGuid</C_Name>
<Guid>0xea296d92, 0xb69, 0x423c, 0x8c, 0x28, 0x33, 0xb4, 0xe0, 0xa9, 0x12, 0x68</Guid>
</Entry>
<Entry Name="PcdPeiCallbackFnTable">
<C_Name>gPcdPeiCallbackFnTableHobGuid</C_Name>
<Guid>0xc625f4b2, 0xea09, 0x4675, 0x82, 0xd7, 0xba, 0x36, 0x82, 0x15, 0x7a, 0x14</Guid>
</Entry>
<Entry Name="PeiPeCoffLoader">
<C_Name>gEfiPeiPeCoffLoaderGuid</C_Name>
<Guid>0xd8117cff, 0x94a6, 0x11d4, 0x9a, 0x3a, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d</Guid>
@ -665,5 +682,38 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
<DatumType>UINT8</DatumType>
<DefaultValue>0</DefaultValue>
</PcdEntry>
<PcdEntry ItemType="FIXED_AT_BUILD">
<C_Name>PcdMaxPcdCallBackNumber</C_Name>
<Token>0x0001000f</Token>
<DatumType>UINT32</DatumType>
<DefaultValue>0</DefaultValue>
</PcdEntry>
<PcdEntry ItemType="DYNAMIC">
<C_Name>PcdTestDynamicUint8</C_Name>
<Token>0x00011000</Token>
<DatumType>UINT8</DatumType>
<DefaultValue>0x01</DefaultValue>
</PcdEntry>
<PcdEntry ItemType="DYNAMIC">
<C_Name>PcdTestDynamicUint16</C_Name>
<Token>0x00011001</Token>
<DatumType>UINT16</DatumType>
<DefaultValue>0x1234</DefaultValue>
</PcdEntry>
<PcdEntry ItemType="DYNAMIC">
<C_Name>PcdTestDynamicUint32</C_Name>
<Token>0x00011002</Token>
<DatumType>UINT32</DatumType>
</PcdEntry>
<PcdEntry ItemType="DYNAMIC">
<C_Name>PcdTestDynamicUint64</C_Name>
<Token>0x00011003</Token>
<DatumType>UINT64</DatumType>
</PcdEntry>
<PcdEntry ItemType="DYNAMIC">
<C_Name>PcdTestDynamicBoolean</C_Name>
<Token>0x00011004</Token>
<DatumType>BOOLEAN</DatumType>
</PcdEntry>
</PcdDefinitions>
</PackageSurfaceArea>

View File

@ -15,7 +15,6 @@ Module Name: Pcd.c
**/
#include "../Common/PcdCommon.h"
#include "Service.h"
@ -70,9 +69,19 @@ PcdDxeInit (
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
EFI_STATUS Status;
//
// Make sure the Pcd Protocol is not already installed in the system
//
InitPcdDxeDataBase ();
ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gPcdProtocolGuid);
BuildPcdDxeDataBase ();
//
// BugBug Check if PcdDatabase is already installed.
//
Status = gBS->InstallProtocolInterface (
&NewHandle,
@ -91,10 +100,10 @@ PcdDxeInit (
EFI_STATUS
EFIAPI
DxePcdSetSku (
IN UINTN SkuId
IN UINTN SkuId
)
{
return DxeSetSku(SkuId);
return gPcdDatabase->PeiDb.Init.SystemSkuId = (SKU_ID) SkuId;
}
@ -102,10 +111,12 @@ DxePcdSetSku (
UINT8
EFIAPI
DxePcdGet8 (
IN UINTN TokenNumber
IN UINTN TokenNumber
)
{
return DxePcdGet8Ex (NULL, TokenNumber);
ASSERT (sizeof (UINT8) == DxePcdGetSize (TokenNumber));
return *((UINT8 *) GetWorker (TokenNumber));
}
@ -113,10 +124,12 @@ DxePcdGet8 (
UINT16
EFIAPI
DxePcdGet16 (
IN UINTN TokenNumber
IN UINTN TokenNumber
)
{
return DxePcdGet16Ex (NULL, TokenNumber);
ASSERT (sizeof (UINT16) == DxePcdGetSize (TokenNumber));
return ReadUnaligned16 (GetWorker (TokenNumber));
}
@ -124,10 +137,12 @@ DxePcdGet16 (
UINT32
EFIAPI
DxePcdGet32 (
IN UINTN TokenNumber
IN UINTN TokenNumber
)
{
return DxePcdGet32Ex (NULL, TokenNumber);
ASSERT (sizeof (UINT32) == DxePcdGetSize (TokenNumber));
return ReadUnaligned32 (GetWorker (TokenNumber));
}
@ -135,10 +150,12 @@ DxePcdGet32 (
UINT64
EFIAPI
DxePcdGet64 (
IN UINTN TokenNumber
IN UINTN TokenNumber
)
{
return DxePcdGet32Ex (NULL, TokenNumber);
ASSERT (sizeof (UINT64) == DxePcdGetSize (TokenNumber));
return ReadUnaligned64(GetWorker (TokenNumber));
}
@ -146,10 +163,10 @@ DxePcdGet64 (
VOID *
EFIAPI
DxePcdGetPtr (
IN UINTN TokenNumber
IN UINTN TokenNumber
)
{
return DxePcdGetPtrEx (NULL, TokenNumber);
return GetWorker (TokenNumber);
}
@ -157,10 +174,12 @@ DxePcdGetPtr (
BOOLEAN
EFIAPI
DxePcdGetBool (
IN UINTN TokenNumber
IN UINTN TokenNumber
)
{
return DxePcdGetBoolEx (NULL, TokenNumber);
ASSERT (sizeof (BOOLEAN) == DxePcdGetSize (TokenNumber));
return *((BOOLEAN *) GetWorker (TokenNumber));
}
@ -168,10 +187,18 @@ DxePcdGetBool (
UINTN
EFIAPI
DxePcdGetSize (
IN UINTN TokenNumber
IN UINTN TokenNumber
)
{
return DxePcdGetSizeEx (NULL, TokenNumber);
UINT16 * SizeTable;
SizeTable = (TokenNumber < PEI_LOCAL_TOKEN_NUMBER) ? gPcdDatabase->PeiDb.Init.SizeTable :
gPcdDatabase->DxeDb.Init.SizeTable;
TokenNumber = (TokenNumber < PEI_LOCAL_TOKEN_NUMBER) ? TokenNumber : (TokenNumber - PEI_LOCAL_TOKEN_NUMBER);
return SizeTable[TokenNumber];
}
@ -179,15 +206,11 @@ DxePcdGetSize (
UINT8
EFIAPI
DxePcdGet8Ex (
IN CONST EFI_GUID *Guid,
IN UINTN TokenNumber
IN CONST EFI_GUID *Guid,
IN UINTN ExTokenNumber
)
{
UINT8 Data;
DxeGetPcdEntryWorker (TokenNumber, Guid, PcdByte8, &Data);
return Data;
return *((UINT8 *) ExGetWorker (Guid, ExTokenNumber, sizeof(UINT8)));
}
@ -196,14 +219,10 @@ UINT16
EFIAPI
DxePcdGet16Ex (
IN CONST EFI_GUID *Guid,
IN UINTN TokenNumber
IN UINTN ExTokenNumber
)
{
UINT16 Data;
DxeGetPcdEntryWorker (TokenNumber, Guid, PcdByte16, &Data);
return Data;
return *((UINT16 *) ExGetWorker (Guid, ExTokenNumber, sizeof(UINT16)));
}
@ -212,14 +231,10 @@ UINT32
EFIAPI
DxePcdGet32Ex (
IN CONST EFI_GUID *Guid,
IN UINTN TokenNumber
IN UINTN ExTokenNumber
)
{
UINT32 Data;
DxeGetPcdEntryWorker (TokenNumber, Guid, PcdByte32, &Data);
return Data;
return *((UINT32 *) ExGetWorker (Guid, ExTokenNumber, sizeof(UINT32)));
}
@ -228,14 +243,13 @@ UINT64
EFIAPI
DxePcdGet64Ex (
IN CONST EFI_GUID *Guid,
IN UINTN TokenNumber
IN UINTN ExTokenNumber
)
{
UINT64 Data;
DxeGetPcdEntryWorker (TokenNumber, Guid, PcdByte64, &Data);
return Data;
//
// BugBug: Must be changed to ReadUnaligned64
//
return *((UINT64 *) ExGetWorker (Guid, ExTokenNumber, sizeof(UINT64)));
}
@ -244,14 +258,10 @@ VOID *
EFIAPI
DxePcdGetPtrEx (
IN CONST EFI_GUID *Guid,
IN UINTN TokenNumber
IN UINTN ExTokenNumber
)
{
VOID *Data;
DxeGetPcdEntryWorker (TokenNumber, Guid, PcdPointer, &Data);
return Data;
return ExGetWorker (Guid, ExTokenNumber, 0);
}
@ -260,12 +270,10 @@ BOOLEAN
EFIAPI
DxePcdGetBoolEx (
IN CONST EFI_GUID *Guid,
IN UINTN TokenNumber
IN UINTN ExTokenNumber
)
{
BOOLEAN Data;
DxeGetPcdEntryWorker (TokenNumber, Guid, PcdBoolean, &Data);
return Data;
return *((BOOLEAN *) ExGetWorker (Guid, ExTokenNumber, sizeof(BOOLEAN)));
}
@ -274,10 +282,14 @@ UINTN
EFIAPI
DxePcdGetSizeEx (
IN CONST EFI_GUID *Guid,
IN UINTN TokenNumber
IN UINTN ExTokenNumber
)
{
return DxeGetPcdEntrySizeWorker (TokenNumber, Guid);
EX_PCD_ENTRY_ATTRIBUTE Attr;
GetExPcdTokenAttributes (Guid, ExTokenNumber, &Attr);
return Attr.Size;
}
@ -285,11 +297,11 @@ DxePcdGetSizeEx (
EFI_STATUS
EFIAPI
DxePcdSet8 (
IN UINTN TokenNumber,
IN UINT8 Value
IN UINTN TokenNumber,
IN UINT8 Value
)
{
return DxePcdSet8Ex (NULL, TokenNumber, Value);
return SetWorker (TokenNumber, &Value, sizeof (Value), FALSE);
}
@ -297,11 +309,11 @@ DxePcdSet8 (
EFI_STATUS
EFIAPI
DxePcdSet16 (
IN UINTN TokenNumber,
IN UINTN TokenNumber,
IN UINT16 Value
)
{
return DxePcdSet16Ex (NULL, TokenNumber, Value);
return SetWorker (TokenNumber, &Value, sizeof (Value), FALSE);
}
@ -309,11 +321,11 @@ DxePcdSet16 (
EFI_STATUS
EFIAPI
DxePcdSet32 (
IN UINTN TokenNumber,
IN UINTN TokenNumber,
IN UINT32 Value
)
{
return DxePcdSet32Ex (NULL, TokenNumber, Value);
return SetWorker (TokenNumber, &Value, sizeof (Value), FALSE);
}
@ -321,11 +333,11 @@ DxePcdSet32 (
EFI_STATUS
EFIAPI
DxePcdSet64 (
IN UINTN TokenNumber,
IN UINT64 Value
IN UINTN TokenNumber,
IN UINT64 Value
)
{
return DxePcdSet64Ex (NULL, TokenNumber, Value);
return SetWorker (TokenNumber, &Value, sizeof (Value), FALSE);
}
@ -333,11 +345,16 @@ DxePcdSet64 (
EFI_STATUS
EFIAPI
DxePcdSetPtr (
IN UINTN TokenNumber,
IN CONST VOID *Value
IN UINTN TokenNumber,
IN CONST VOID *Value
)
{
return DxePcdSetPtrEx (NULL, TokenNumber, Value);
//
// BugBug, please change the Size to Input size when sync with spec
//
//ASSERT (sizeof (Value) == DxePcdGetSize (TokenNumber));
return SetWorker (TokenNumber, (VOID *)Value, DxePcdGetSize (TokenNumber), TRUE);
}
@ -345,11 +362,11 @@ DxePcdSetPtr (
EFI_STATUS
EFIAPI
DxePcdSetBool (
IN UINTN TokenNumber,
IN BOOLEAN Value
IN UINTN TokenNumber,
IN BOOLEAN Value
)
{
return DxePcdSetBoolEx (NULL, TokenNumber, Value);
return SetWorker (TokenNumber, &Value, sizeof (Value), FALSE);
}
@ -358,11 +375,17 @@ EFI_STATUS
EFIAPI
DxePcdSet8Ex (
IN CONST EFI_GUID *Guid,
IN UINTN TokenNumber,
IN UINT8 Value
IN UINTN ExTokenNumber,
IN UINT8 Value
)
{
return DxeSetPcdEntryWorker (TokenNumber, Guid, PcdByte8, &Value);
return ExSetWorker(
ExTokenNumber,
Guid,
&Value,
sizeof (Value),
FALSE
);
}
@ -371,11 +394,17 @@ EFI_STATUS
EFIAPI
DxePcdSet16Ex (
IN CONST EFI_GUID *Guid,
IN UINTN TokenNumber,
IN UINTN ExTokenNumber,
IN UINT16 Value
)
{
return DxeSetPcdEntryWorker (TokenNumber, Guid, PcdByte16, &Value);
return ExSetWorker(
ExTokenNumber,
Guid,
&Value,
sizeof (Value),
FALSE
);
}
@ -384,11 +413,17 @@ EFI_STATUS
EFIAPI
DxePcdSet32Ex (
IN CONST EFI_GUID *Guid,
IN UINTN TokenNumber,
IN UINTN ExTokenNumber,
IN UINT32 Value
)
{
return DxeSetPcdEntryWorker (TokenNumber, Guid, PcdByte32, &Value);
return ExSetWorker(
ExTokenNumber,
Guid,
&Value,
sizeof (Value),
FALSE
);
}
@ -397,11 +432,17 @@ EFI_STATUS
EFIAPI
DxePcdSet64Ex (
IN CONST EFI_GUID *Guid,
IN UINTN TokenNumber,
IN UINTN ExTokenNumber,
IN UINT64 Value
)
{
return DxeSetPcdEntryWorker (TokenNumber, Guid, PcdByte64, &Value);
return ExSetWorker(
ExTokenNumber,
Guid,
&Value,
sizeof (Value),
FALSE
);
}
@ -410,11 +451,17 @@ EFI_STATUS
EFIAPI
DxePcdSetPtrEx (
IN CONST EFI_GUID *Guid,
IN UINTN TokenNumber,
IN UINTN ExTokenNumber,
IN CONST VOID *Value
)
{
return DxeSetPcdEntryWorker (TokenNumber, Guid, PcdPointer, Value);
return ExSetWorker(
ExTokenNumber,
Guid,
(VOID *) Value,
sizeof (Value),
TRUE
);
}
@ -423,12 +470,17 @@ EFI_STATUS
EFIAPI
DxePcdSetBoolEx (
IN CONST EFI_GUID *Guid,
IN UINTN TokenNumber,
IN UINTN ExTokenNumber,
IN BOOLEAN Value
)
{
return DxeSetPcdEntryWorker (TokenNumber, Guid, PcdBoolean, &Value);
return ExSetWorker(
ExTokenNumber,
Guid,
&Value,
sizeof (Value),
TRUE
);
}

View File

@ -14,300 +14,113 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name: Service.c
**/
#include "../Common/PcdCommon.h"
#include "Service.h"
static PCD_DATABASE *PrivatePcdDxeDatabase;
static LIST_ENTRY mPcdDatabaseListHead = INITIALIZE_LIST_HEAD_VARIABLE(mPcdDatabaseListHead);
LIST_ENTRY *
GetPcdDatabaseListHead (
VOID
)
//
// Build Tool will generate DXE_PCD_DB_INIT_VALUE in Autogen.h
// Compression Algorithm will take care of the size optimization.
//
/*
DXE_PCD_DATABASE_INIT gDXEPcdDbInit = {
DXE_PCD_DB_INIT_VALUE
};
*/
PCD_DATABASE * gPcdDatabase;
VOID *
GetWorkerByLocalTokenNumber (
UINT32 LocalTokenNumber,
BOOLEAN IsPeiDb,
UINTN Size
)
{
return &mPcdDatabaseListHead;
}
UINT32 Offset;
EFI_GUID *GuidTable;
UINT16 *StringTable;
EFI_GUID *Guid;
UINT16 *Name;
VARIABLE_HEAD *VariableHead;
EFI_STATUS Status;
UINTN DataSize;
VOID *Data;
VPD_HEAD *VpdHead;
UINT8 *PcdDb;
UINT16 StringTableIdx;
PCD_DATABASE *
GetPcdDxeDataBaseInstance (
VOID
)
{
return PrivatePcdDxeDatabase;
}
PCD_DATABASE *
SetPcdDxeDataBaseInstance (
PCD_DATABASE *PcdDatabase
)
{
return PrivatePcdDxeDatabase = PcdDatabase;
}
VOID
DxeGetPcdEntryWorker (
IN UINTN TokenNumber,
IN CONST GUID *Guid, OPTIONAL
IN PCD_DATA_TYPE Type,
OUT VOID *Data
)
{
PCD_DATABASE *Database;
Database = GetPcdDxeDataBaseInstance ();
GetPcdEntryWorker ( &Database->Info,
TokenNumber,
Guid,
Type,
Data
);
return;
}
EFI_STATUS
DxeSetPcdEntryWorker (
IN UINTN TokenNumber,
IN CONST GUID *Guid, OPTIONAL
IN PCD_DATA_TYPE Type,
IN CONST VOID *Data
)
{
PCD_DATABASE *Database;
PCD_INDEX *PcdIndex;
EFI_STATUS Status;
Database = GetPcdDxeDataBaseInstance ();
ASSERT (Data != NULL);
PcdIndex = FindPcdIndex (TokenNumber, Guid, &Database->Info, NULL);
ASSERT (PcdIndex != NULL);
ASSERT (PcdIndex->StateByte.DataType == Type);
//
// Invoke the callback function.
//
Status = SetPcdData (PcdIndex, &Database->Info, Data);
return Status;
}
UINTN
DxeGetPcdEntrySizeWorker (
IN UINTN TokenNumber,
IN CONST GUID *Guid OPTIONAL
)
{
PCD_DATABASE *Database;
Database = GetPcdDxeDataBaseInstance ();
return GetPcdEntrySizeWorker (&Database->Info,
TokenNumber,
Guid
);
}
LIST_ENTRY *
InsertToGuidSpaceListI (
IN LIST_ENTRY *GuidSpaceListHead,
IN CONST EFI_GUID *Guid
)
{
PCD_GUID_SPACE *GuidSpaceEntry;
GuidSpaceEntry = AllocatePool (sizeof (PCD_GUID_SPACE));
ASSERT (GuidSpaceEntry != NULL);
GuidSpaceEntry->GuidSpace= Guid;
InitializeListHead (&GuidSpaceEntry->TokenSpaceHead);
InsertTailList (GuidSpaceListHead, &GuidSpaceEntry->ListNode);
return &GuidSpaceEntry->TokenSpaceHead;
}
LIST_ENTRY *
InsertToTokenSpaceListI (
IN LIST_ENTRY *TokenSpaceListHead,
IN UINTN TokenNumber
)
{
PCD_TOKEN_SPACE *TokenSpaceEntry;
TokenSpaceEntry = AllocatePool (sizeof (PCD_TOKEN_SPACE));
ASSERT (TokenSpaceEntry != NULL);
TokenSpaceEntry->TokeNumber = TokenNumber;
InitializeListHead (&TokenSpaceEntry->CallbackListHead);
InsertTailList (TokenSpaceListHead, &TokenSpaceEntry->ListNode);
return &TokenSpaceEntry->CallbackListHead;
}
VOID
InsertToCallbackListI (
IN LIST_ENTRY *CallbackListHead,
IN PCD_PROTOCOL_CALLBACK CallBackFunction
)
{
PCD_CALLBACK_ENTRY *CallbackEntry;
CallbackEntry = AllocatePool (sizeof (PCD_CALLBACK_ENTRY));
ASSERT (CallbackEntry != NULL);
CallbackEntry->CallbackFunction = CallBackFunction;
InsertTailList (CallbackListHead, &CallbackEntry->ListNode);
return;
}
VOID
InsertToCallbackList (
IN UINTN TokenNumber,
IN CONST EFI_GUID *Guid,
IN PCD_PROTOCOL_CALLBACK CallBackFunction
)
{
LIST_ENTRY *GuidListNode;
LIST_ENTRY *GuidListHead;
LIST_ENTRY *TokenListNode;
LIST_ENTRY *TokenListHead;
LIST_ENTRY *CallbackListHead;
PCD_GUID_SPACE *GuidSpaceEntry;
PCD_TOKEN_SPACE *TokenSpaceEntry;
GuidListHead = GetPcdDatabaseListHead ();
GuidListNode = GetFirstNode (GuidListHead);
while (!IsNull (GuidListNode, GuidListHead)) {
GuidSpaceEntry = PCD_GUID_SPACE_FROM_LISTNODE(GuidListNode);
if (CompareGuid (GuidSpaceEntry->GuidSpace, Guid)) {
TokenListHead = &GuidSpaceEntry->TokenSpaceHead;
TokenListNode = GetFirstNode (TokenListHead);
while (!IsNull (TokenListNode, TokenListHead)) {
TokenSpaceEntry = PCD_TOKEN_SPACE_FROM_LISTNODE(TokenListNode);
if (TokenSpaceEntry->TokeNumber == TokenNumber) {
InsertToCallbackListI (&TokenSpaceEntry->CallbackListHead , CallBackFunction);
}
}
//
// No TokenNumber match input found in this GuidSpace
//
CallbackListHead = InsertToTokenSpaceListI (TokenListHead, TokenNumber);
InsertToCallbackListI (CallbackListHead , CallBackFunction);
}
GuidListNode = GetNextNode (GuidListHead, GuidListNode);
if ((LocalTokenNumber & PCD_TYPE_SKU_ENABLED) == PCD_TYPE_SKU_ENABLED) {
LocalTokenNumber = GetSkuEnabledTokenNumber (LocalTokenNumber & ~PCD_TYPE_SKU_ENABLED, Size, IsPeiDb);
}
//
// No GuidSpace match the input Guid, so build the GuidSpace, TokenNumberSpace and Callback
//
TokenListHead = InsertToGuidSpaceListI (GuidListHead, Guid);
CallbackListHead = InsertToTokenSpaceListI (TokenListHead, TokenNumber);
InsertToCallbackListI (CallbackListHead , CallBackFunction);
return;
PcdDb = IsPeiDb ? ((UINT8 *) &gPcdDatabase->PeiDb) : ((UINT8 *) &gPcdDatabase->DxeDb);
StringTable = IsPeiDb ? gPcdDatabase->PeiDb.Init.StringTable :
gPcdDatabase->DxeDb.Init.StringTable;
}
EFI_STATUS
RemoveFromCallbackListI (
IN LIST_ENTRY *CallbackListHead,
IN PCD_PROTOCOL_CALLBACK CallBackFunction
)
{
LIST_ENTRY *ListNode;
PCD_CALLBACK_ENTRY *CallbackEntry;
ListNode = GetFirstNode (CallbackListHead);
while (!IsNull(CallbackListHead, ListNode)) {
CallbackEntry = PCD_CALLBACK_ENTRY_FROM_LISTNODE(ListNode);
if (CallbackEntry->CallbackFunction == CallBackFunction) {
RemoveEntryList (ListNode);
FreePool (CallbackEntry);
return EFI_SUCCESS;
}
ListNode = GetNextNode (CallbackListHead, ListNode);
}
return EFI_NOT_FOUND;
}
EFI_STATUS
RemoveFromCallbackList (
IN UINTN TokenNumber,
IN CONST GUID *Guid,
IN PCD_PROTOCOL_CALLBACK CallBackFunction
)
{
LIST_ENTRY *GuidListNode;
LIST_ENTRY *GuidListHead;
LIST_ENTRY *TokenListNode;
LIST_ENTRY *TokenListHead;
PCD_GUID_SPACE *GuidSpaceEntry;
PCD_TOKEN_SPACE *TokenSpaceEntry;
Offset = LocalTokenNumber & PCD_DATABASE_OFFSET_MASK;
GuidListHead = GetPcdDatabaseListHead ();
GuidListNode = GetFirstNode (GuidListHead);
while (!IsNull (GuidListNode, GuidListHead)) {
GuidSpaceEntry = PCD_GUID_SPACE_FROM_LISTNODE(GuidListNode);
if (CompareGuid (GuidSpaceEntry->GuidSpace, Guid)) {
switch (LocalTokenNumber & ~PCD_DATABASE_OFFSET_MASK) {
case PCD_TYPE_VPD:
VpdHead = (VPD_HEAD *) ((UINT8 *) PcdDb + Offset);
return (VOID *) (FixedPcdGet32(PcdVpdBaseAddress) + VpdHead->Offset);
TokenListHead = &GuidSpaceEntry->TokenSpaceHead;
TokenListNode = GetFirstNode (TokenListHead);
while (!IsNull (TokenListNode, TokenListHead)) {
TokenSpaceEntry = PCD_TOKEN_SPACE_FROM_LISTNODE(TokenListNode);
if (TokenSpaceEntry->TokeNumber == TokenNumber) {
return RemoveFromCallbackListI (&TokenSpaceEntry->CallbackListHead , CallBackFunction);
}
}
case PCD_TYPE_HII:
GuidTable = IsPeiDb ? gPcdDatabase->PeiDb.Init.GuidTable :
gPcdDatabase->DxeDb.Init.GuidTable;
VariableHead = (VARIABLE_HEAD *) (PcdDb + Offset);
Guid = &(GuidTable[VariableHead->GuidTableIndex]);
Name = &(StringTable[VariableHead->StringIndex]);
//
// No TokenNumber match input found in this GuidSpace
//
return EFI_NOT_FOUND;
}
GuidListNode = GetNextNode (GuidListHead, GuidListNode);
Status = GetHiiVariable (Guid, Name, &Data, &DataSize);
ASSERT_EFI_ERROR (Status);
ASSERT (DataSize >= (UINTN) (VariableHead->Offset + Size));
return (UINT8 *) Data + VariableHead->Offset;
case PCD_TYPE_STRING:
StringTableIdx = (UINT16) *((UINT8 *) PcdDb + Offset);
return (VOID *) &StringTable[StringTableIdx];
case PCD_TYPE_DATA:
return (VOID *) ((UINT8 *) PcdDb + Offset);
break;
default:
ASSERT (FALSE);
break;
}
return EFI_NOT_FOUND;
ASSERT (FALSE);
return NULL;
}
VOID *
GetWorker (
UINTN TokenNumber
)
{
UINT32 *LocalTokenNumberTable;
UINT16 *SizeTable;
BOOLEAN IsPeiDb;
ASSERT (TokenNumber < PCD_TOTAL_TOKEN_NUMBER);
IsPeiDb = (TokenNumber <= PEI_LOCAL_TOKEN_NUMBER) ? TRUE : FALSE;
LocalTokenNumberTable = IsPeiDb ? gPcdDatabase->PeiDb.Init.LocalTokenNumberTable :
gPcdDatabase->DxeDb.Init.LocalTokenNumberTable;
SizeTable = IsPeiDb ? gPcdDatabase->PeiDb.Init.SizeTable:
gPcdDatabase->DxeDb.Init.SizeTable;
TokenNumber = IsPeiDb ? TokenNumber :
TokenNumber - PEI_LOCAL_TOKEN_NUMBER;
return GetWorkerByLocalTokenNumber (LocalTokenNumberTable[TokenNumber], IsPeiDb, SizeTable[TokenNumber]);
}
@ -320,81 +133,47 @@ DxeRegisterCallBackWorker (
IN BOOLEAN Register
)
{
PCD_DATABASE *Database;
PCD_INDEX *PcdIndex;
Database = GetPcdDxeDataBaseInstance ();
PcdIndex = FindPcdIndex (TokenNumber, Guid, &Database->Info, NULL);
if (PcdIndex == NULL) {
return EFI_NOT_FOUND;
}
if (Register) {
InsertToCallbackList (TokenNumber, Guid, CallBackFunction);
return EFI_SUCCESS;
} else {
return RemoveFromCallbackList (TokenNumber, Guid, CallBackFunction);
}
}
EFI_STATUS
DxeSetSku (
UINTN Id
)
{
PCD_DATABASE * Database;
Database = GetPcdDxeDataBaseInstance ();
return Database->Info.SkuId = Id;
return EFI_SUCCESS;
}
EFI_STATUS
DxeGetNextTokenWorker (
IN OUT UINTN *TokenNumber,
IN CONST GUID *Guid OPTIONAL
)
{
PCD_DATABASE * Database;
Database = GetPcdDxeDataBaseInstance ();
return GetNextTokenWorker (&Database->Info,
TokenNumber,
Guid
);
return EFI_SUCCESS;
}
VOID
InitPcdDxeDataBase (
BuildPcdDxeDataBase (
VOID
)
{
PCD_DATABASE *PeiDatabase;
PCD_DATABASE *DxeDatabase;
PEI_PCD_DATABASE *PeiDatabase;
EFI_HOB_GUID_TYPE *GuidHob;
gPcdDatabase = AllocateZeroPool (sizeof(PCD_DATABASE));
ASSERT (gPcdDatabase != NULL);
GuidHob = GetFirstGuidHob (&gPcdDataBaseHobGuid);
ASSERT (GuidHob != NULL);
PeiDatabase = (PCD_DATABASE *) GET_GUID_HOB_DATA (GuidHob);
DxeDatabase = AllocateCopyPool (PeiDatabase->Info.DatabaseLen, PeiDatabase);
ASSERT (DxeDatabase != NULL);
SetPcdDxeDataBaseInstance (DxeDatabase);
PeiDatabase = (PEI_PCD_DATABASE *) GET_GUID_HOB_DATA (GuidHob);
//
// Copy PCD Entries refereneced in PEI phase to PCD DATABASE
//
CopyMem (&gPcdDatabase->PeiDb, PeiDatabase, sizeof (PEI_PCD_DATABASE));
//
// Copy PCD Entries with default value to PCD DATABASE
//
CopyMem (&gPcdDatabase->DxeDb.Init, &gDXEPcdDbInit, sizeof(DXE_PCD_DATABASE_INIT));
return;
}
@ -438,6 +217,263 @@ GetHiiVariable (
}
UINT32
GetSkuEnabledTokenNumber (
UINT32 LocalTokenNumber,
UINTN Size,
BOOLEAN IsPeiDb
)
{
SKU_HEAD *SkuHead;
SKU_ID *SkuIdTable;
INTN i;
UINT8 *Value;
SKU_ID *PhaseSkuIdTable;
UINT8 *PcdDb;
ASSERT ((LocalTokenNumber & PCD_TYPE_SKU_ENABLED) == 0);
PcdDb = IsPeiDb ? (UINT8 *) &gPcdDatabase->PeiDb : (UINT8 *) &gPcdDatabase->DxeDb;
SkuHead = (SKU_HEAD *) (PcdDb + (LocalTokenNumber & PCD_DATABASE_OFFSET_MASK));
Value = (UINT8 *) (PcdDb + SkuHead->SkuDataStartOffset);
PhaseSkuIdTable = IsPeiDb ? gPcdDatabase->PeiDb.Init.SkuIdTable :
gPcdDatabase->DxeDb.Init.SkuIdTable;
SkuIdTable = &PhaseSkuIdTable[SkuHead->SkuIdTableOffset];
for (i = 0; i < SkuIdTable[0]; i++) {
if (gPcdDatabase->PeiDb.Init.SystemSkuId == SkuIdTable[i + 1]) {
break;
}
}
ASSERT (i < SkuIdTable[0]);
switch (LocalTokenNumber & ~PCD_DATABASE_OFFSET_MASK) {
case PCD_TYPE_VPD:
Value = (UINT8 *) &(((VPD_HEAD *) Value)[i]);
return ((Value - PcdDb) | PCD_TYPE_VPD);
case PCD_TYPE_HII:
Value = (UINT8 *) &(((VARIABLE_HEAD *) Value)[i]);
return ((Value - PcdDb) | PCD_TYPE_HII);
case PCD_TYPE_DATA:
Value += Size * i;
return (Value - PcdDb);
default:
ASSERT (FALSE);
}
ASSERT (FALSE);
return 0;
}
VOID
InvokeCallbackOnSet (
UINT32 ExTokenNumber,
CONST EFI_GUID *Guid, OPTIONAL
UINTN TokenNumber,
VOID *Data,
UINTN Size
)
{
return;
}
EFI_STATUS
SetWorker (
UINTN TokenNumber,
VOID *Data,
UINTN Size,
BOOLEAN PtrType
)
{
UINT32 *LocalTokenNumberTable;
BOOLEAN IsPeiDb;
ASSERT (TokenNumber < PCD_TOTAL_TOKEN_NUMBER);
if (PtrType) {
ASSERT (Size <= DxePcdGetSize (TokenNumber));
} else {
ASSERT (Size == DxePcdGetSize (TokenNumber));
}
IsPeiDb = (TokenNumber <= PEI_LOCAL_TOKEN_NUMBER) ? TRUE : FALSE;
LocalTokenNumberTable = IsPeiDb ? gPcdDatabase->PeiDb.Init.LocalTokenNumberTable :
gPcdDatabase->DxeDb.Init.LocalTokenNumberTable;
TokenNumber = IsPeiDb ? TokenNumber
: TokenNumber - PEI_LOCAL_TOKEN_NUMBER;
InvokeCallbackOnSet (0, NULL, TokenNumber, Data, Size);
return SetWorkerByLocalTokenNumber (LocalTokenNumberTable[TokenNumber], Data, Size, PtrType, IsPeiDb);
}
VOID *
ExGetWorker (
IN CONST EFI_GUID *Guid,
IN UINTN ExTokenNumber,
IN UINTN GetSize
)
{
EX_PCD_ENTRY_ATTRIBUTE Attr;
GetExPcdTokenAttributes (Guid, ExTokenNumber, &Attr);
ASSERT ((GetSize == Attr.Size) || (GetSize == 0));
return GetWorkerByLocalTokenNumber (Attr.LocalTokenNumberAlias,
Attr.IsPeiDb,
Attr.Size
);
}
EFI_STATUS
ExSetWorker (
IN UINT32 ExTokenNumber,
IN CONST EFI_GUID *Guid,
VOID *Data,
UINTN SetSize,
BOOLEAN PtrType
)
{
EX_PCD_ENTRY_ATTRIBUTE Attr;
GetExPcdTokenAttributes (Guid, ExTokenNumber, &Attr);
ASSERT (!PtrType && (SetSize == Attr.Size));
ASSERT (PtrType && (SetSize <= Attr.Size));
InvokeCallbackOnSet (ExTokenNumber, Guid, Attr.TokenNumber, Data, Attr.Size);
SetWorkerByLocalTokenNumber (Attr.LocalTokenNumberAlias, Data, Attr.Size, PtrType, Attr.IsPeiDb);
return EFI_SUCCESS;
}
EFI_STATUS
SetWorkerByLocalTokenNumber (
UINT32 LocalTokenNumber,
VOID *Data,
UINTN Size,
BOOLEAN PtrType,
BOOLEAN IsPeiDb
)
{
EFI_GUID *GuidTable;
UINT16 *StringTable;
EFI_GUID *Guid;
UINT16 *Name;
VOID *InternalData;
VARIABLE_HEAD *VariableHead;
UINTN Offset;
UINT8 *PcdDb;
if ((LocalTokenNumber & PCD_TYPE_SKU_ENABLED) == PCD_TYPE_SKU_ENABLED) {
LocalTokenNumber = GetSkuEnabledTokenNumber (LocalTokenNumber & ~PCD_TYPE_SKU_ENABLED, Size, IsPeiDb);
}
Offset = LocalTokenNumber & PCD_DATABASE_OFFSET_MASK;
PcdDb = IsPeiDb ? ((UINT8 *) &gPcdDatabase->PeiDb) : ((UINT8 *) &gPcdDatabase->DxeDb);
StringTable = IsPeiDb ? gPcdDatabase->PeiDb.Init.StringTable :
gPcdDatabase->DxeDb.Init.StringTable;
InternalData = PcdDb + Offset;
switch (LocalTokenNumber & ~PCD_DATABASE_OFFSET_MASK) {
case PCD_TYPE_VPD:
ASSERT (FALSE);
return EFI_INVALID_PARAMETER;
case PCD_TYPE_STRING:
CopyMem (&StringTable[*((UINT16 *)InternalData)], Data, Size);
break;
case PCD_TYPE_HII:
//
// Bug Bug: Please implement this
//
GuidTable = IsPeiDb ? gPcdDatabase->PeiDb.Init.GuidTable :
gPcdDatabase->DxeDb.Init.GuidTable;
VariableHead = (VARIABLE_HEAD *) (PcdDb + Offset);
Guid = &(GuidTable[VariableHead->GuidTableIndex]);
Name = &(StringTable[VariableHead->StringIndex]);
return EFI_SUCCESS;
case PCD_TYPE_DATA:
if (PtrType) {
CopyMem (InternalData, Data, Size);
return EFI_SUCCESS;
}
switch (Size) {
case sizeof(UINT8):
*((UINT8 *) InternalData) = *((UINT8 *) Data);
return EFI_SUCCESS;
case sizeof(UINT16):
*((UINT16 *) InternalData) = *((UINT16 *) Data);
return EFI_SUCCESS;
case sizeof(UINT32):
*((UINT32 *) InternalData) = *((UINT32 *) Data);
return EFI_SUCCESS;
case sizeof(UINT64):
*((UINT64 *) InternalData) = *((UINT64 *) Data);
return EFI_SUCCESS;
default:
ASSERT (FALSE);
return EFI_NOT_FOUND;
}
default:
ASSERT (FALSE);
break;
}
ASSERT (FALSE);
return EFI_NOT_FOUND;
}
EFI_STATUS
SetHiiVariable (
@ -448,16 +484,17 @@ SetHiiVariable (
IN UINTN Offset
)
{
UINTN Size;
VOID *Buffer;
EFI_STATUS Status;
UINTN Size;
VOID *Buffer;
EFI_STATUS Status;
UINT32 Attribute;
Size = 0;
Status = EfiGetVariable (
(UINT16 *)VariableName,
VariableGuid,
NULL,
&Attribute,
&Size,
NULL
);
@ -471,7 +508,7 @@ SetHiiVariable (
Status = EfiGetVariable (
VariableName,
VariableGuid,
NULL,
&Attribute,
&Size,
Buffer
);
@ -482,10 +519,67 @@ SetHiiVariable (
return EfiSetVariable (
VariableName,
VariableGuid,
0,
Attribute,
Size,
Buffer
);
}
VOID
GetExPcdTokenAttributes (
IN CONST EFI_GUID *Guid,
IN UINT32 ExTokenNumber,
OUT EX_PCD_ENTRY_ATTRIBUTE *ExAttr
)
{
UINT32 i;
DYNAMICEX_MAPPING *ExMap;
EFI_GUID *GuidTable;
UINT16 *SizeTable;
ExMap = gPcdDatabase->PeiDb.Init.ExMapTable;
GuidTable = gPcdDatabase->PeiDb.Init.GuidTable;
SizeTable = gPcdDatabase->PeiDb.Init.SizeTable;
for (i = 0; i < PEI_EXMAPPING_TABLE_SIZE; i++) {
if ((ExTokenNumber == ExMap[i].ExTokenNumber) &&
CompareGuid (Guid, (CONST EFI_GUID *) &GuidTable[ExMap[i].ExGuidIndex])
) {
ExAttr->IsPeiDb = TRUE;
ExAttr->Size = SizeTable[i + PEI_NEX_TOKEN_NUMBER];
ExAttr->TokenNumber = i + PEI_NEX_TOKEN_NUMBER;
ExAttr->LocalTokenNumberAlias = ExMap[i].LocalTokenNumber;
return;
}
}
ExMap = gPcdDatabase->DxeDb.Init.ExMapTable;
GuidTable = gPcdDatabase->DxeDb.Init.GuidTable;
SizeTable = gPcdDatabase->DxeDb.Init.SizeTable;
for (i = 0; i < DXE_EXMAPPING_TABLE_SIZE; i++) {
if ((ExTokenNumber == ExMap[i].ExTokenNumber) &&
CompareGuid (Guid, (CONST EFI_GUID *) &GuidTable[ExMap[i].ExGuidIndex])
) {
ExAttr->IsPeiDb = FALSE;
ExAttr->Size = SizeTable[i + DXE_NEX_TOKEN_NUMBER];
ExAttr->TokenNumber = i + DXE_NEX_TOKEN_NUMBER;
ExAttr->LocalTokenNumberAlias = ExMap[i].LocalTokenNumber;
return;
}
}
ASSERT (FALSE);
return;
}

View File

@ -18,27 +18,251 @@ Module Name: Service.h
#ifndef _SERVICE_H
#define _SERVICE_H
VOID
DxeGetPcdEntryWorker (
IN UINTN Token,
IN CONST EFI_GUID *Guid, OPTIONAL
IN PCD_DATA_TYPE Type,
OUT VOID *Data
);
#define USE_AUTOGEN
EFI_STATUS
DxeSetPcdEntryWorker (
IN UINTN Token,
IN CONST EFI_GUID *Guid, OPTIONAL
IN PCD_DATA_TYPE Type,
IN CONST VOID *Data
);
#ifndef USE_AUTOGEN
//
// The following definition will be generated by build tool
//
UINTN
DxeGetPcdEntrySizeWorker (
IN UINTN Token,
IN CONST EFI_GUID *Guid OPTIONAL
);
//
// Common definitions
//
#define PCD_TYPE_SHIFT 24
#define PCD_TYPE_DATA (0x00 << PCD_TYPE_SHIFT)
#define PCD_TYPE_HII (0x80 << PCD_TYPE_SHIFT)
#define PCD_TYPE_VPD (0x40 << PCD_TYPE_SHIFT)
#define PCD_TYPE_SKU_ENABLED (0x20 << PCD_TYPE_SHIFT)
#define PCD_DATABASE_OFFSET_MASK (~(PCD_TYPE_HII | PCD_TYPE_VPD | PCD_TYPE_SKU_ENABLED))
typedef struct {
UINT32 ExTokenNumber;
UINT32 LocalTokenNumber; // PCD Number of this particular platform build
UINT16 ExGuidIndex; // Index of GuidTable
} DYNAMICEX_MAPPING;
typedef struct {
UINT32 SkuDataStartOffset; //We have to use offsetof MACRO as we don't know padding done by compiler
UINT32 SkuIdTableOffset; //Offset from the PCD_DB
} SKU_HEAD;
typedef struct {
UINT16 GuidTableIndex; // Offset in Guid Table in units of GUID.
UINT16 StringIndex; // Offset in String Table in units of UINT16.
UINT16 Offset; // Offset in Variable
} VARIABLE_HEAD ;
typedef struct {
UINT32 Offset;
} VPD_HEAD;
typedef struct {
UINT32 LocalTokenNumber;
UINT16 TokenNumber;
UINT16 Size;
} SIZEINFO;
#define offsetof(s,m) (UINT32)&(((s *)0)->m)
//
// C Structure generate for PEI PCD Database
//
#define PEI_EXMAPPING_TABLE_SIZE 1
#define PEI_GUID_TABLE_SIZE 1
#define PEI_LOCAL_TOKEN_NUMBER 1
#define PEI_EXTOKEN_NUMBER 1
#define PEI_STRING_TABLE_SIZE 2
#define PEI_SKUID_TABLE_SIZE 3
#define PEI_SIZE_TABLE_SIZE 1
#define PEI_DATABASE_EMPTRY FALSE
#define PEI_DYNAMICEX_MAPPING_EMPTY FALSE
#define PEI_GUID_TABLE_EMPTY FALSE
#define PEI_STRINGTABLE_EMPTY FALSE
#define PEI_SIZETABLE_EMPTY FALSE
#define PEI_SKUID_TABLE_EMPTY FALSE
typedef struct {
DYNAMICEX_MAPPING ExMapTable[PEI_EXMAPPING_TABLE_SIZE];
EFI_GUID GuidTable[PEI_GUID_TABLE_SIZE];
UINT32 LocalTokenNumberTable[PEI_LOCAL_TOKEN_NUMBER];
UINT16 StringTable[PEI_STRING_TABLE_SIZE];
UINT16 SizeTable[PEI_LOCAL_TOKEN_NUMBER];
SKU_ID SkuIdTable[PEI_SKUID_TABLE_SIZE];
SKU_ID SystemSkuId;
} PEI_PCD_DATABASE_INIT;
typedef struct {
UINT8 Dummy;
} PEI_PCD_DATABASE_UNINIT;
//
// Following code should be generated for PCD DXE driver
//
#define DXE_EXMAPPING_TABLE_SIZE 1
#define DXE_GUID_TABLE_SIZE 1
#define DXE_TOKEN_NUMBER 1
#define DXE_EXTOKEN_NUMBER 1
#define DXE_STRING_TABLE_SIZE 2
#define DXE_SKUID_TABLE_SIZE 3
#define DXE_SIZE_TABLE_SIZE 1
#define DXE_DATABASE_EMPTRY FALSE
#define DXE_DYNAMICEX_MAPPING_EMPTY FALSE
#define DXE_GUID_TABLE_EMPTY FALSE
#define DXE_STRINGTABLE_EMPTY FALSE
#define DXE_SIZETABLE_EMPTY FALSE
#define DXE_SKUID_TABLE_EMPTY FALSE
typedef struct {
DYNAMICEX_MAPPING ExMapTable[DXE_EXMAPPING_TABLE_SIZE];
EFI_GUID GuidTable[DXE_GUID_TABLE_SIZE];
UINT32 LocalTokenNumberTable[DXE_TOKEN_NUMBER];
UINT16 StringTable[DXE_STRING_TABLE_SIZE];
UINT16 SizeTable[DXE_TOKEN_NUMBER];
SKU_ID SkuIdTable[DXE_SKUID_TABLE_SIZE];
} DXE_PCD_DATABASE_INIT;
typedef struct {
UINT8 Dummy;
} DXE_PCD_DATABASE_UNINIT;
#define DXE_PCD_DB_INIT_VALUE \
/* ExMapTable */ \
{ \
{ /* ExTokenNumber */ 0x00000001, /* LocalTokenNumberIndex */ 0, /* ExGuidIndex */ 0} \
}, \
\
/* GuidTable */ \
{ \
{ 0xBB25CF6F, 0xF1D4, 0x11D2, {0x9A, 0x0C, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0xFD }} \
}, \
\
/* LocalTokenNumberTable */ \
{ \
0 \
}, \
\
/* StringTable */ \
{ \
L"\0" \
}, \
\
/* SizeTable */ \
{ \
4 \
}, \
\
/* SkuIdTable */ \
{ \
/*MaxSku*/ 2, /*SkuId*/ 100, /*SkuId*/200 \
},\
\
//
// End of Autogen Code
//
#endif
/*
typedef struct {
PEI_PCD_DATABASE_INIT Init;
PEI_PCD_DATABASE_UNINIT Uninit;
} PEI_PCD_DATABASE;
typedef struct {
DXE_PCD_DATABASE_INIT Init;
DXE_PCD_DATABASE_UNINIT Uninit;
} DXE_PCD_DATABASE;
typedef struct {
PEI_PCD_DATABASE PeiDb;
DXE_PCD_DATABASE DxeDb;
} PCD_DATABASE;
*/
//
// Internal Functions
//
EFI_STATUS
SetWorker (
UINTN TokenNumber,
VOID *Data,
UINTN Size,
BOOLEAN PtrType
)
;
EFI_STATUS
ExSetWorker (
IN UINT32 ExTokenNumber,
IN CONST EFI_GUID *Guid,
VOID *Data,
UINTN Size,
BOOLEAN PtrType
)
;
VOID *
GetWorker (
UINTN TokenNumber
)
;
VOID *
ExGetWorker (
IN CONST EFI_GUID *Guid,
IN UINTN ExTokenNumber,
IN UINTN GetSize
)
;
UINT32
GetSkuEnabledTokenNumber (
UINT32 LocalTokenNumber,
UINTN Size,
BOOLEAN IsPeiDb
)
;
EFI_STATUS
GetHiiVariable (
IN EFI_GUID *VariableGuid,
IN UINT16 *VariableName,
OUT VOID ** VariableData,
OUT UINTN *VariableSize
)
;
EFI_STATUS
DxeRegisterCallBackWorker (
@ -48,11 +272,6 @@ DxeRegisterCallBackWorker (
IN BOOLEAN Reigster
);
EFI_STATUS
DxeSetSku (
UINTN Id
);
EFI_STATUS
DxeGetNextTokenWorker (
IN OUT UINTN *Token,
@ -60,10 +279,26 @@ DxeGetNextTokenWorker (
);
VOID
InitPcdDxeDataBase (
BuildPcdDxeDataBase (
VOID
);
typedef struct {
UINTN TokenNumber;
UINTN Size;
UINT32 LocalTokenNumberAlias;
BOOLEAN IsPeiDb;
} EX_PCD_ENTRY_ATTRIBUTE;
VOID
GetExPcdTokenAttributes (
IN CONST EFI_GUID *Guid,
IN UINT32 ExTokenNumber,
OUT EX_PCD_ENTRY_ATTRIBUTE *ExAttr
)
;
//
// Protocol Interface function declaration.
//
@ -339,61 +574,20 @@ DxePcdGetNextToken (
)
;
EFI_STATUS
SetWorkerByLocalTokenNumber (
UINT32 LocalTokenNumber,
VOID *Data,
UINTN Size,
BOOLEAN PtrType,
BOOLEAN IsPeiDb
)
;
/*
This DXE_PCD_DATABASE layout. The difference of DXE_PCD_DATABASE
and PEI_PCD_DATABASE is as follows:
extern EFI_GUID gPcdDataBaseHobGuid;
1) No PCD_CALL_BACK_TABLE; DXE_PCD_DATABASE maintain a LinkList for the
callback function registered.
extern PCD_DATABASE * gPcdDatabase;
---------------------------
| LIST_ENTRY GuidSpaceHead|
---------------------------
| PCD_DATABASE_HEADER |
---------------------------
| GUID_TABLE | Aligned on GUID (128 bits)
---------------------------
| PCD_INDEX_TABLE | Aligned on PCD_INDEX (see PCD_INDEX's declaration)
---------------------------
| IMAGE_STRING_TABLE | Aligned on 16 Bits
---------------------------
| IMAGE_PCD_INDEX | Unaligned
---------------------------
| Data Defaults | Unaligned
---------------------------
| Data Buffer |
| for entries without |
| defaults |
---------------------------
*/
typedef struct {
LIST_ENTRY ListNode;
LIST_ENTRY TokenSpaceHead;
CONST EFI_GUID *GuidSpace;
} PCD_GUID_SPACE;
typedef struct {
LIST_ENTRY ListNode;
LIST_ENTRY CallbackListHead;
UINTN TokeNumber;
} PCD_TOKEN_SPACE;
typedef struct {
LIST_ENTRY ListNode;
PCD_PROTOCOL_CALLBACK CallbackFunction;
} PCD_CALLBACK_ENTRY;
#define PCD_GUID_SPACE_FROM_LISTNODE(a) \
_CR(a, PCD_GUID_SPACE, ListNode)
#define PCD_TOKEN_SPACE_FROM_LISTNODE(a) \
_CR(a, PCD_TOKEN_SPACE, ListNode)
#define PCD_CALLBACK_ENTRY_FROM_LISTNODE(a) \
_CR(a, PCD_CALLBACK_ENTRY, ListNode)
extern DXE_PCD_DATABASE_INIT gDXEPcdDbInit;
#endif

View File

@ -1,5 +1,4 @@
/** @file
PCD PEIM
/** @file PCD PEIM
Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials
@ -15,7 +14,7 @@ Module Name: Pcd.c
**/
#include "../Common/PcdCommon.h"
#include "PcdCommon.h"
#include "Service.h"
@ -75,12 +74,9 @@ PcdPeimInit (
)
{
EFI_STATUS Status;
UINT8 *PcdImage;
PcdImage = (UINT8 *) LocatePcdImage ();
BuildPcdDatabase (PcdImage);
BuildPcdDatabase ();
Status = PeiCoreInstallPpi (&mPpiPCD);
ASSERT_EFI_ERROR (Status);
@ -88,25 +84,16 @@ PcdPeimInit (
return EFI_SUCCESS;
}
EFI_STATUS
EFIAPI
PeiPcdSetSku (
IN UINTN SkuId
)
{
PCD_DATABASE *Database;
EFI_HOB_GUID_TYPE *GuidHob;
GuidHob = GetFirstGuidHob (&gPcdDataBaseHobGuid);
ASSERT (GuidHob != NULL);
Database = (PCD_DATABASE *) GET_GUID_HOB_DATA (GuidHob);
GetPcdDatabase()->Init.SystemSkuId = (SKU_ID) SkuId;
Database->Info.SkuId = SkuId;
return SkuId;
return EFI_SUCCESS;
}
@ -117,7 +104,7 @@ PeiPcdGet8 (
IN UINTN TokenNumber
)
{
return PeiPcdGet8Ex (NULL, TokenNumber);
return *((UINT8 *) GetWorker (TokenNumber, sizeof (UINT8)));
}
@ -128,7 +115,7 @@ PeiPcdGet16 (
IN UINTN TokenNumber
)
{
return PeiPcdGet16Ex (NULL, TokenNumber);
return ReadUnaligned16 (GetWorker (TokenNumber, sizeof (UINT16)));
}
@ -139,7 +126,7 @@ PeiPcdGet32 (
IN UINTN TokenNumber
)
{
return PeiPcdGet32Ex (NULL, TokenNumber);
return ReadUnaligned32 (GetWorker (TokenNumber, sizeof (UINT32)));
}
@ -150,7 +137,7 @@ PeiPcdGet64 (
IN UINTN TokenNumber
)
{
return PeiPcdGet64Ex (NULL, TokenNumber);
return ReadUnaligned64 (GetWorker (TokenNumber, sizeof (UINT64)));
}
@ -161,7 +148,7 @@ PeiPcdGetPtr (
IN UINTN TokenNumber
)
{
return PeiPcdGetPtrEx (NULL, TokenNumber);
return GetWorker (TokenNumber, 0);
}
@ -172,7 +159,7 @@ PeiPcdGetBool (
IN UINTN TokenNumber
)
{
return PeiPcdGetBoolEx (NULL, TokenNumber);
return *((BOOLEAN *) GetWorker (TokenNumber, sizeof (BOOLEAN)));
}
@ -183,7 +170,9 @@ PeiPcdGetSize (
IN UINTN TokenNumber
)
{
return PeiPcdGetSizeEx (NULL, TokenNumber);
ASSERT (TokenNumber < PEI_LOCAL_TOKEN_NUMBER);
return GetPcdDatabase()->Init.SizeTable[TokenNumber];
}
@ -192,14 +181,10 @@ UINT8
EFIAPI
PeiPcdGet8Ex (
IN CONST EFI_GUID *Guid,
IN UINTN TokenNumber
IN UINTN ExTokenNumber
)
{
UINT8 Data;
PeiGetPcdEntryWorker (TokenNumber, Guid, PcdByte8, &Data);
return Data;
return *((UINT8 *) ExGetWorker (Guid, ExTokenNumber, sizeof (UINT8)));
}
@ -208,14 +193,10 @@ UINT16
EFIAPI
PeiPcdGet16Ex (
IN CONST EFI_GUID *Guid,
IN UINTN TokenNumber
IN UINTN ExTokenNumber
)
{
UINT16 Data;
PeiGetPcdEntryWorker (TokenNumber, Guid, PcdByte16, &Data);
return Data;
return ReadUnaligned16 (ExGetWorker (Guid, ExTokenNumber, sizeof (UINT16)));
}
@ -224,14 +205,10 @@ UINT32
EFIAPI
PeiPcdGet32Ex (
IN CONST EFI_GUID *Guid,
IN UINTN TokenNumber
IN UINTN ExTokenNumber
)
{
UINT32 Data;
PeiGetPcdEntryWorker (TokenNumber, Guid, PcdByte32, &Data);
return Data;
return ReadUnaligned32 (ExGetWorker (Guid, ExTokenNumber, sizeof (UINT32)));
}
@ -240,14 +217,10 @@ UINT64
EFIAPI
PeiPcdGet64Ex (
IN CONST EFI_GUID *Guid,
IN UINTN TokenNumber
IN UINTN ExTokenNumber
)
{
UINT64 Data;
PeiGetPcdEntryWorker (TokenNumber, Guid, PcdByte64, &Data);
return Data;
return ReadUnaligned64 (ExGetWorker (Guid, ExTokenNumber, sizeof (UINT64)));
}
@ -256,14 +229,10 @@ VOID *
EFIAPI
PeiPcdGetPtrEx (
IN CONST EFI_GUID *Guid,
IN UINTN TokenNumber
IN UINTN ExTokenNumber
)
{
VOID *Data;
PeiGetPcdEntryWorker (TokenNumber, Guid, PcdPointer, &Data);
return Data;
return ExGetWorker (Guid, ExTokenNumber, 0);
}
@ -272,14 +241,10 @@ BOOLEAN
EFIAPI
PeiPcdGetBoolEx (
IN CONST EFI_GUID *Guid,
IN UINTN TokenNumber
IN UINTN ExTokenNumber
)
{
BOOLEAN Data;
PeiGetPcdEntryWorker (TokenNumber, Guid, PcdBoolean, &Data);
return Data;
return *((BOOLEAN *) ExGetWorker (Guid, ExTokenNumber, sizeof (BOOLEAN)));
}
@ -288,10 +253,14 @@ UINTN
EFIAPI
PeiPcdGetSizeEx (
IN CONST EFI_GUID *Guid,
IN UINTN TokenNumber
IN UINTN ExTokenNumber
)
{
return PeiGetPcdEntrySizeWorker (TokenNumber, Guid);
EX_PCD_ENTRY_ATTRIBUTE Attr;
GetExPcdTokenAttributes (Guid, ExTokenNumber, &Attr);
return Attr.Size;
}
@ -303,7 +272,7 @@ PeiPcdSet8 (
IN UINT8 Value
)
{
return PeiPcdSet8Ex (NULL, TokenNumber, Value);
return SetWorker (TokenNumber, &Value, sizeof (Value), FALSE);
}
@ -315,7 +284,7 @@ PeiPcdSet16 (
IN UINT16 Value
)
{
return PeiPcdSet16Ex (NULL, TokenNumber, Value);
return SetWorker (TokenNumber, &Value, sizeof (Value), FALSE);
}
@ -327,7 +296,7 @@ PeiPcdSet32 (
IN UINT32 Value
)
{
return PeiPcdSet32Ex (NULL, TokenNumber, Value);
return SetWorker (TokenNumber, &Value, sizeof (Value), FALSE);
}
@ -339,7 +308,7 @@ PeiPcdSet64 (
IN UINT64 Value
)
{
return PeiPcdSet64Ex (NULL, TokenNumber, Value);
return SetWorker (TokenNumber, &Value, sizeof (Value), FALSE);
}
@ -350,7 +319,12 @@ PeiPcdSetPtr (
IN CONST VOID *Value
)
{
return PeiPcdSetPtrEx (NULL, TokenNumber, Value);
//
// BugBug, please change the Size to Input size when sync with spec
//
//ASSERT (sizeof (Value) == GetPcdDatabase()->Init.SizeTable[TokenNumber]);
return SetWorker (TokenNumber, (VOID *) Value, GetPcdDatabase()->Init.SizeTable[TokenNumber], TRUE);
}
@ -362,7 +336,7 @@ PeiPcdSetBool (
IN BOOLEAN Value
)
{
return PeiPcdSetBoolEx (NULL, TokenNumber, Value);
return SetWorker (TokenNumber, &Value, sizeof (Value), FALSE);
}
@ -371,11 +345,17 @@ EFI_STATUS
EFIAPI
PeiPcdSet8Ex (
IN CONST EFI_GUID *Guid,
IN UINTN TokenNumber,
IN UINTN ExTokenNumber,
IN UINT8 Value
)
{
return PeiSetPcdEntryWorker (TokenNumber, Guid, PcdByte8, &Value);
return ExSetWorker(
ExTokenNumber,
Guid,
&Value,
sizeof (Value),
FALSE
);
}
@ -384,11 +364,17 @@ EFI_STATUS
EFIAPI
PeiPcdSet16Ex (
IN CONST EFI_GUID *Guid,
IN UINTN TokenNumber,
IN UINTN ExTokenNumber,
IN UINT16 Value
)
{
return PeiSetPcdEntryWorker (TokenNumber, Guid, PcdByte16, &Value);
return ExSetWorker(
ExTokenNumber,
Guid,
&Value,
sizeof (Value),
FALSE
);
}
@ -397,11 +383,17 @@ EFI_STATUS
EFIAPI
PeiPcdSet32Ex (
IN CONST EFI_GUID *Guid,
IN UINTN TokenNumber,
IN UINTN ExTokenNumber,
IN UINT32 Value
)
{
return PeiSetPcdEntryWorker (TokenNumber, Guid, PcdByte32, &Value);
return ExSetWorker(
ExTokenNumber,
Guid,
&Value,
sizeof (Value),
FALSE
);
}
@ -410,11 +402,17 @@ EFI_STATUS
EFIAPI
PeiPcdSet64Ex (
IN CONST EFI_GUID *Guid,
IN UINTN TokenNumber,
IN UINTN ExTokenNumber,
IN UINT64 Value
)
{
return PeiSetPcdEntryWorker (TokenNumber, Guid, PcdByte64, &Value);
return ExSetWorker(
ExTokenNumber,
Guid,
&Value,
sizeof (Value),
FALSE
);
}
@ -423,11 +421,17 @@ EFI_STATUS
EFIAPI
PeiPcdSetPtrEx (
IN CONST EFI_GUID *Guid,
IN UINTN TokenNumber,
IN UINTN ExTokenNumber,
IN CONST VOID *Value
)
{
return PeiSetPcdEntryWorker (TokenNumber, Guid, PcdPointer, (VOID *)Value);
return ExSetWorker(
ExTokenNumber,
Guid,
(VOID *) Value,
sizeof (Value),
TRUE
);
}
@ -436,12 +440,17 @@ EFI_STATUS
EFIAPI
PeiPcdSetBoolEx (
IN CONST EFI_GUID *Guid,
IN UINTN TokenNumber,
IN UINTN ExTokenNumber,
IN BOOLEAN Value
)
{
return PeiSetPcdEntryWorker (TokenNumber, Guid, PcdBoolean, &Value);
return ExSetWorker(
ExTokenNumber,
Guid,
&Value,
sizeof (Value),
FALSE
);
}
@ -450,12 +459,12 @@ PeiPcdSetBoolEx (
EFI_STATUS
EFIAPI
PcdRegisterCallBackOnSet (
IN UINTN TokenNumber,
IN UINTN ExTokenNumber,
IN CONST EFI_GUID *Guid, OPTIONAL
IN PCD_PPI_CALLBACK CallBackFunction
)
{
return PeiRegisterCallBackWorker (TokenNumber, Guid, CallBackFunction, TRUE);
return PeiRegisterCallBackWorker (ExTokenNumber, Guid, CallBackFunction, TRUE);
}
@ -463,12 +472,12 @@ PcdRegisterCallBackOnSet (
EFI_STATUS
EFIAPI
PcdUnRegisterCallBackOnSet (
IN UINTN TokenNumber,
IN UINTN ExTokenNumber,
IN CONST EFI_GUID *Guid, OPTIONAL
IN PCD_PPI_CALLBACK CallBackFunction
)
{
return PeiRegisterCallBackWorker (TokenNumber, Guid, CallBackFunction, FALSE);
return PeiRegisterCallBackWorker (ExTokenNumber, Guid, CallBackFunction, FALSE);
}
@ -480,7 +489,19 @@ PeiPcdGetNextToken (
IN OUT UINTN *TokenNumber
)
{
return PeiGetNextTokenWorker (TokenNumber, Guid);
if (Guid == NULL) {
*TokenNumber++;
if (*TokenNumber >= PEI_LOCAL_TOKEN_NUMBER) {
*TokenNumber = 0;
}
}
//
// BugBug: Haven't implemented the portion to get Next Token for GuidSpace is not Local GuidSpace.
//
return EFI_SUCCESS;
}

File diff suppressed because it is too large Load Diff

View File

@ -18,53 +18,213 @@ Module Name: Service.h
#ifndef _SERVICE_H
#define _SERVICE_H
//
// Offset of StateByte
//
#define PCD_STATEBYTE_HIIENABLE 0x01
#define PCD_STATEBYTE_SKUENABLE 0x02
#define PCD_STATEBYTE_VPDENABLE 0x04
#define PCD_STATEBYTE_SKUDATAARRAYENABLE 0x08
#define PCD_STATEBYTE_DATUMTYPE 0x70
#define PCD_STATEBYTE_EXTENDEDGUIDPRESENT 0x80
#define USE_AUTOGEN
#define PCD_DATUMTYPE_OFFSET 4
#ifndef USE_AUTOGEN
//
// The following definition will be generated by build tool
//
//
// The definitions for interpreting DatumType
// Common definitions that is shared by PEI and DXE PCD database
//
#define PCD_BYTE8 (0x00 << PCD_DATUMTYPE_OFFSET)
#define PCD_BYTE16 (0x01 << PCD_DATUMTYPE_OFFSET)
#define PCD_BYTE32 (0x02 << PCD_DATUMTYPE_OFFSET)
#define PCD_BYTE64 (0x03 << PCD_DATUMTYPE_OFFSET)
#define PCD_POINTER (0x04 << PCD_DATUMTYPE_OFFSET)
#define PCD_BOOLEAN (0x05 << PCD_DATUMTYPE_OFFSET)
#define PCD_TYPE_SHIFT 24
extern GUID gEfiPcdImageHobGuid;
#define PCD_TYPE_DATA (0x00 << PCD_TYPE_SHIFT)
#define PCD_TYPE_HII (0x80 << PCD_TYPE_SHIFT)
#define PCD_TYPE_VPD (0x40 << PCD_TYPE_SHIFT)
#define PCD_TYPE_SKU_ENABLED (0x20 << PCD_TYPE_SHIFT)
#define PCD_DATABASE_OFFSET_MASK (~(PCD_TYPE_HII | PCD_TYPE_VPD | PCD_TYPE_SKU_ENABLED))
typedef struct {
UINT32 ExTokenNumber;
UINT32 LocalTokenNumber; // PCD Number of this particular platform build
UINT16 ExGuidIndex; // Index of GuidTable
} DYNAMICEX_MAPPING;
typedef struct {
UINT32 SkuDataStartOffset; //We have to use offsetof MACRO as we don't know padding done by compiler
UINT32 SkuIdTableOffset; //Offset from the PCD_DB
} SKU_HEAD;
typedef struct {
UINT16 GuidTableIndex; // Offset in Guid Table in units of GUID.
UINT16 StringIndex; // Offset in String Table in units of UINT16.
UINT16 Offset; // Offset in Variable
} VARIABLE_HEAD ;
typedef struct {
UINT32 Offset;
} VPD_HEAD;
typedef struct {
UINT32 LocalTokenNumber;
UINT16 TokenNumber;
UINT16 Size;
} SIZEINFO;
#define offsetof(s,m) (UINT32)&(((s *)0)->m)
//
// C Structure generate for PEI PCD Database
//
#define PEI_EXMAPPING_TABLE_SIZE 1
#define PEI_GUID_TABLE_SIZE 1
#define PEI_LOCAL_TOKEN_NUMBER 1
#define PEI_STRING_TABLE_SIZE 2
#define PEI_SKUID_TABLE_SIZE 3
#define PEI_DATABASE_EMPTRY FALSE
#define PEI_EXMAP_TABLE_EMPTY FALSE
#define PEI_GUID_TABLE_EMPTY FALSE
#define PEI_STRINGTABLE_EMPTY FALSE
#define PEI_SIZETABLE_EMPTY FALSE
#define PEI_SKUID_TABLE_EMPTY FALSE
typedef struct {
DYNAMICEX_MAPPING ExMapTable[PEI_EXMAPPING_TABLE_SIZE];
EFI_GUID GuidTable[PEI_GUID_TABLE_SIZE];
UINT32 LocalTokenNumberTable[PEI_LOCAL_TOKEN_NUMBER];
UINT16 StringTable[PEI_STRING_TABLE_SIZE];
UINT16 SizeTable[PEI_LOCAL_TOKEN_NUMBER];
UINT8 SkuIdTable[PEI_SKUID_TABLE_SIZE];
SKU_ID SystemSkuId;
} PEI_PCD_DATABASE_INIT;
typedef struct {
UINT8 Dummy;
} PEI_PCD_DATABASE_UNINIT;
#define PEI_PCD_DB_INIT_VALUE \
/* ExMapTable */ \
{ \
{ /* ExTokenNumber */ 0x00000001, /* LocalTokenNumberIndex */ 0, /* ExGuidIndex */ 0} \
}, \
\
/* GuidTable */ \
{ \
{ 0xBB25CF6F, 0xF1D4, 0x11D2, {0x9A, 0x0C, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0xFD }} \
}, \
\
/* LocalTokenNumberTable */ \
{ \
0 \
}, \
\
/* StringTable */ \
{ \
L"\0" \
}, \
\
/* SizeTable */ \
{ \
4 \
}, \
\
/* SkuIdTable */ \
{ \
/*MaxSku*/ 2, /*SkuId*/ 100, /*SkuId*/200 \
},\
\
/* SystemSkuId */ \
0 \
//
// End of Autogen Code
//
#endif
/*
typedef struct {
PEI_PCD_DATABASE_INIT Init;
PEI_PCD_DATABASE_UNINIT Uninit;
} PEI_PCD_DATABASE;
*/
/* Internal Function definitions */
VOID
PeiGetPcdEntryWorker (
IN UINTN Token,
IN CONST GUID *Guid, OPTIONAL
IN PCD_DATA_TYPE Type,
OUT VOID *Data
);
PEI_PCD_DATABASE *
GetPcdDatabase (
VOID
)
;
EFI_STATUS
PeiSetPcdEntryWorker (
IN UINTN Token,
IN CONST GUID *Guid, OPTIONAL
IN PCD_DATA_TYPE Type,
IN VOID *Data
);
SetWorker (
IN UINTN TokenNumber,
IN VOID *Data,
IN UINTN Size,
IN BOOLEAN PtrType
)
;
UINTN
PeiGetPcdEntrySizeWorker (
IN UINTN Token,
IN CONST GUID *Guid OPTIONAL
);
EFI_STATUS
SetWorkerByLocalTokenNumber (
UINT32 LocalTokenNumber,
VOID *Data,
UINTN Size,
BOOLEAN PtrType
)
;
EFI_STATUS
ExSetWorker (
IN UINT32 ExTokenNumber,
IN CONST EFI_GUID *Guid,
VOID *Data,
UINTN Size,
BOOLEAN PtrType
)
;
VOID *
GetWorker (
UINTN TokenNumber,
UINTN GetSize
)
;
VOID *
ExGetWorker (
IN CONST EFI_GUID *Guid,
IN UINT32 ExTokenNumber,
IN UINTN GetSize
)
;
typedef struct {
UINTN TokenNumber;
UINTN Size;
UINT32 LocalTokenNumberAlias;
} EX_PCD_ENTRY_ATTRIBUTE;
VOID
GetExPcdTokenAttributes (
IN CONST EFI_GUID *Guid,
IN UINT32 ExTokenNumber,
OUT EX_PCD_ENTRY_ATTRIBUTE *ExAttr
)
;
EFI_STATUS
PeiRegisterCallBackWorker (
@ -74,25 +234,9 @@ PeiRegisterCallBackWorker (
IN BOOLEAN Register
);
EFI_STATUS
PeiSetSku (
UINTN Id
);
EFI_STATUS
PeiGetNextTokenWorker (
IN OUT UINTN *Token,
IN CONST GUID *Guid OPTIONAL
);
UINT8 *
LocatePcdImage (
VOID
);
VOID
BuildPcdDatabase (
UINT8 *PcdImageOnFlash
VOID
)
;
@ -368,4 +512,11 @@ PeiPcdGetNextToken (
IN OUT UINTN *TokenNumber
)
;
extern EFI_GUID gPcdDataBaseHobGuid;
extern EFI_GUID gPcdPeiCallbackFnTableHobGuid;
extern PEI_PCD_DATABASE_INIT gPEIPcdDbInit;
#endif

View File

@ -38,59 +38,25 @@ DoTest(
VOID
)
{
PCD_TOKEN_NUMBER tn;
UINTN Size;
VOID * Ptr;
UINT32 Uint32;
UINT32 Uint32a;
UINT64 Uint64;
UINT64 Uint64a;
INTN i;
UINT8 u8;
UINT16 u16;
UINT32 u32;
UINT64 u64;
u32 = 0xafafafaf;
PcdSet32(PcdTestDynamicUint32, u32);
tn = 0x00001000;
u64 = 0xafafafaf00000000;
PcdSet64(PcdTestDynamicUint64, u64);
Size = LibPcdGetSize (tn);
Ptr = LibPcdGetPtr (tn); /* a:RW;2880;512!e:RW;262144;512 */
tn = 0x00001001;
Size = LibPcdGetSize (tn); /* FW;40960;512 */
tn = 0x00001002;
Size = LibPcdGetSize (tn); /* FW;40960;512 */
Ptr = LibPcdGetPtr (tn);
LibPcdSetSku (0x0a);
tn = 0x2233;
Uint64 = LibPcdGet64 (tn);
LibPcdSetSku (0x0b);
Uint64 = LibPcdGet64 (tn);
LibPcdSetSku (0x0c);
Uint64a = LibPcdGet64 (tn);
LibPcdSetSku (0);
tn = 0x2233;
Uint64 = LibPcdGet64 (tn);
tn = 0xfaceface;
Size = LibPcdGetExSize (&Guid1, tn);
Uint32 = LibPcdGetEx32 (&Guid1, tn);
LibPcdCallBackOnSet (&Guid1, tn, OnsetCallback1);
LibPcdCancelCallBackOnSet (&Guid1, tn, OnsetCallback1);
for (i = 0; i < 2; i++) {
Uint32a = LibPcdSetEx32 (&Guid1, tn, Uint32 + i);
DebugPrint (0x80000000, "%x\n", Uint32a);
}
Uint32 = LibPcdGet32 (tn);
u8 = PcdGet8(PcdTestDynamicUint8);
u16 = PcdGet16(PcdTestDynamicUint16);
ASSERT (u8 == 0x01);
ASSERT (u16 == 0x1234);
ASSERT (u64 == PcdGet64(PcdTestDynamicUint64));
ASSERT (u32 == PcdGet32(PcdTestDynamicUint32));
return;
}