2006-04-22 00:54:32 +02:00
|
|
|
/** @file
|
|
|
|
Private functions used by PCD DXE driver.s
|
|
|
|
|
|
|
|
Copyright (c) 2006, 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
|
|
|
|
http://opensource.org/licenses/bsd-license.php
|
|
|
|
|
|
|
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|
|
|
|
|
|
|
|
|
|
|
Module Name: Service.c
|
|
|
|
|
|
|
|
**/
|
|
|
|
#include "Service.h"
|
|
|
|
|
|
|
|
|
2006-05-24 10:16:20 +02:00
|
|
|
//
|
|
|
|
// Build Tool will generate DXE_PCD_DB_INIT_VALUE in Autogen.h
|
|
|
|
// Compression Algorithm will take care of the size optimization.
|
|
|
|
//
|
2006-04-22 00:54:32 +02:00
|
|
|
|
2006-05-24 10:16:20 +02:00
|
|
|
/*
|
|
|
|
DXE_PCD_DATABASE_INIT gDXEPcdDbInit = {
|
|
|
|
DXE_PCD_DB_INIT_VALUE
|
|
|
|
};
|
|
|
|
*/
|
2006-04-22 00:54:32 +02:00
|
|
|
|
2006-05-24 10:16:20 +02:00
|
|
|
PCD_DATABASE * gPcdDatabase;
|
2006-04-22 00:54:32 +02:00
|
|
|
|
2006-05-24 10:16:20 +02:00
|
|
|
VOID *
|
|
|
|
GetWorkerByLocalTokenNumber (
|
|
|
|
UINT32 LocalTokenNumber,
|
|
|
|
BOOLEAN IsPeiDb,
|
|
|
|
UINTN Size
|
|
|
|
)
|
2006-04-22 00:54:32 +02:00
|
|
|
{
|
2006-05-24 10:16:20 +02:00
|
|
|
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;
|
|
|
|
|
|
|
|
if ((LocalTokenNumber & PCD_TYPE_SKU_ENABLED) == PCD_TYPE_SKU_ENABLED) {
|
|
|
|
LocalTokenNumber = GetSkuEnabledTokenNumber (LocalTokenNumber & ~PCD_TYPE_SKU_ENABLED, Size, IsPeiDb);
|
|
|
|
}
|
|
|
|
|
|
|
|
PcdDb = IsPeiDb ? ((UINT8 *) &gPcdDatabase->PeiDb) : ((UINT8 *) &gPcdDatabase->DxeDb);
|
|
|
|
StringTable = IsPeiDb ? gPcdDatabase->PeiDb.Init.StringTable :
|
|
|
|
gPcdDatabase->DxeDb.Init.StringTable;
|
|
|
|
|
|
|
|
Offset = LocalTokenNumber & PCD_DATABASE_OFFSET_MASK;
|
|
|
|
|
|
|
|
switch (LocalTokenNumber & ~PCD_DATABASE_OFFSET_MASK) {
|
|
|
|
case PCD_TYPE_VPD:
|
|
|
|
VpdHead = (VPD_HEAD *) ((UINT8 *) PcdDb + Offset);
|
|
|
|
return (VOID *) (FixedPcdGet32(PcdVpdBaseAddress) + VpdHead->Offset);
|
|
|
|
|
|
|
|
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]);
|
2006-04-22 00:54:32 +02:00
|
|
|
|
2006-05-24 10:16:20 +02:00
|
|
|
Status = GetHiiVariable (Guid, Name, &Data, &DataSize);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
ASSERT (DataSize >= (UINTN) (VariableHead->Offset + Size));
|
2006-04-22 00:54:32 +02:00
|
|
|
|
2006-05-24 10:16:20 +02:00
|
|
|
return (UINT8 *) Data + VariableHead->Offset;
|
2006-04-22 00:54:32 +02:00
|
|
|
|
2006-05-24 10:16:20 +02:00
|
|
|
case PCD_TYPE_STRING:
|
|
|
|
StringTableIdx = (UINT16) *((UINT8 *) PcdDb + Offset);
|
|
|
|
return (VOID *) &StringTable[StringTableIdx];
|
2006-04-22 00:54:32 +02:00
|
|
|
|
2006-05-24 10:16:20 +02:00
|
|
|
case PCD_TYPE_DATA:
|
|
|
|
return (VOID *) ((UINT8 *) PcdDb + Offset);
|
|
|
|
break;
|
2006-04-22 00:54:32 +02:00
|
|
|
|
2006-05-24 10:16:20 +02:00
|
|
|
default:
|
|
|
|
ASSERT (FALSE);
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
2006-04-22 00:54:32 +02:00
|
|
|
|
2006-05-24 10:16:20 +02:00
|
|
|
ASSERT (FALSE);
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
VOID *
|
|
|
|
GetWorker (
|
|
|
|
UINTN TokenNumber
|
2006-04-22 00:54:32 +02:00
|
|
|
)
|
|
|
|
{
|
2006-05-24 10:16:20 +02:00
|
|
|
UINT32 *LocalTokenNumberTable;
|
|
|
|
UINT16 *SizeTable;
|
|
|
|
BOOLEAN IsPeiDb;
|
2006-04-22 00:54:32 +02:00
|
|
|
|
2006-05-24 10:16:20 +02:00
|
|
|
ASSERT (TokenNumber < PCD_TOTAL_TOKEN_NUMBER);
|
|
|
|
|
|
|
|
IsPeiDb = (TokenNumber <= PEI_LOCAL_TOKEN_NUMBER) ? TRUE : FALSE;
|
2006-04-22 00:54:32 +02:00
|
|
|
|
2006-05-24 10:16:20 +02:00
|
|
|
LocalTokenNumberTable = IsPeiDb ? gPcdDatabase->PeiDb.Init.LocalTokenNumberTable :
|
|
|
|
gPcdDatabase->DxeDb.Init.LocalTokenNumberTable;
|
2006-04-22 00:54:32 +02:00
|
|
|
|
2006-05-24 10:16:20 +02:00
|
|
|
SizeTable = IsPeiDb ? gPcdDatabase->PeiDb.Init.SizeTable:
|
|
|
|
gPcdDatabase->DxeDb.Init.SizeTable;
|
2006-04-22 00:54:32 +02:00
|
|
|
|
2006-05-24 10:16:20 +02:00
|
|
|
TokenNumber = IsPeiDb ? TokenNumber :
|
|
|
|
TokenNumber - PEI_LOCAL_TOKEN_NUMBER;
|
|
|
|
return GetWorkerByLocalTokenNumber (LocalTokenNumberTable[TokenNumber], IsPeiDb, SizeTable[TokenNumber]);
|
|
|
|
}
|
2006-04-22 00:54:32 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
2006-05-24 10:16:20 +02:00
|
|
|
EFI_STATUS
|
|
|
|
DxeRegisterCallBackWorker (
|
|
|
|
IN UINTN TokenNumber,
|
|
|
|
IN CONST GUID *Guid, OPTIONAL
|
|
|
|
IN PCD_PROTOCOL_CALLBACK CallBackFunction,
|
|
|
|
IN BOOLEAN Register
|
|
|
|
)
|
|
|
|
{
|
|
|
|
|
|
|
|
return EFI_SUCCESS;
|
2006-04-22 00:54:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-05-24 10:16:20 +02:00
|
|
|
EFI_STATUS
|
|
|
|
DxeGetNextTokenWorker (
|
|
|
|
IN OUT UINTN *TokenNumber,
|
|
|
|
IN CONST GUID *Guid OPTIONAL
|
2006-04-22 00:54:32 +02:00
|
|
|
)
|
|
|
|
{
|
2006-05-24 10:16:20 +02:00
|
|
|
return EFI_SUCCESS;
|
2006-04-22 00:54:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-05-24 10:16:20 +02:00
|
|
|
VOID
|
|
|
|
BuildPcdDxeDataBase (
|
|
|
|
VOID
|
|
|
|
)
|
2006-04-22 00:54:32 +02:00
|
|
|
{
|
2006-05-24 10:16:20 +02:00
|
|
|
PEI_PCD_DATABASE *PeiDatabase;
|
|
|
|
EFI_HOB_GUID_TYPE *GuidHob;
|
2006-04-22 00:54:32 +02:00
|
|
|
|
2006-05-24 10:16:20 +02:00
|
|
|
gPcdDatabase = AllocateZeroPool (sizeof(PCD_DATABASE));
|
|
|
|
ASSERT (gPcdDatabase != NULL);
|
2006-04-22 00:54:32 +02:00
|
|
|
|
2006-05-24 10:16:20 +02:00
|
|
|
GuidHob = GetFirstGuidHob (&gPcdDataBaseHobGuid);
|
|
|
|
ASSERT (GuidHob != NULL);
|
2006-04-22 00:54:32 +02:00
|
|
|
|
2006-05-24 10:16:20 +02:00
|
|
|
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;
|
2006-04-22 00:54:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-05-24 10:16:20 +02:00
|
|
|
EFI_STATUS
|
|
|
|
GetHiiVariable (
|
|
|
|
IN EFI_GUID *VariableGuid,
|
|
|
|
IN UINT16 *VariableName,
|
|
|
|
OUT VOID ** VariableData,
|
|
|
|
OUT UINTN *VariableSize
|
2006-04-22 00:54:32 +02:00
|
|
|
)
|
|
|
|
{
|
2006-05-24 10:16:20 +02:00
|
|
|
UINTN Size;
|
|
|
|
EFI_STATUS Status;
|
|
|
|
VOID *Buffer;
|
2006-04-22 00:54:32 +02:00
|
|
|
|
2006-05-24 10:16:20 +02:00
|
|
|
Status = EfiGetVariable (
|
|
|
|
(UINT16 *)VariableName,
|
|
|
|
VariableGuid,
|
|
|
|
NULL,
|
|
|
|
&Size,
|
|
|
|
NULL
|
|
|
|
);
|
|
|
|
ASSERT (Status == EFI_BUFFER_TOO_SMALL);
|
2006-04-22 00:54:32 +02:00
|
|
|
|
2006-05-24 10:16:20 +02:00
|
|
|
Buffer = AllocatePool (Size);
|
2006-04-22 00:54:32 +02:00
|
|
|
|
2006-05-24 10:16:20 +02:00
|
|
|
ASSERT (Buffer != NULL);
|
2006-04-22 00:54:32 +02:00
|
|
|
|
2006-05-24 10:16:20 +02:00
|
|
|
Status = EfiGetVariable (
|
|
|
|
VariableName,
|
|
|
|
VariableGuid,
|
|
|
|
NULL,
|
|
|
|
&Size,
|
|
|
|
Buffer
|
|
|
|
);
|
2006-04-22 00:54:32 +02:00
|
|
|
|
2006-05-24 10:16:20 +02:00
|
|
|
return Status;
|
2006-04-22 00:54:32 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-05-24 10:16:20 +02:00
|
|
|
UINT32
|
|
|
|
GetSkuEnabledTokenNumber (
|
|
|
|
UINT32 LocalTokenNumber,
|
|
|
|
UINTN Size,
|
|
|
|
BOOLEAN IsPeiDb
|
|
|
|
)
|
|
|
|
{
|
|
|
|
SKU_HEAD *SkuHead;
|
|
|
|
SKU_ID *SkuIdTable;
|
|
|
|
INTN i;
|
|
|
|
UINT8 *Value;
|
|
|
|
SKU_ID *PhaseSkuIdTable;
|
|
|
|
UINT8 *PcdDb;
|
2006-04-22 00:54:32 +02:00
|
|
|
|
2006-05-24 10:16:20 +02:00
|
|
|
ASSERT ((LocalTokenNumber & PCD_TYPE_SKU_ENABLED) == 0);
|
2006-04-22 00:54:32 +02:00
|
|
|
|
2006-05-24 10:16:20 +02:00
|
|
|
PcdDb = IsPeiDb ? (UINT8 *) &gPcdDatabase->PeiDb : (UINT8 *) &gPcdDatabase->DxeDb;
|
2006-04-22 00:54:32 +02:00
|
|
|
|
2006-05-24 10:16:20 +02:00
|
|
|
SkuHead = (SKU_HEAD *) (PcdDb + (LocalTokenNumber & PCD_DATABASE_OFFSET_MASK));
|
|
|
|
Value = (UINT8 *) (PcdDb + SkuHead->SkuDataStartOffset);
|
2006-04-22 00:54:32 +02:00
|
|
|
|
2006-05-24 10:16:20 +02:00
|
|
|
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;
|
2006-04-22 00:54:32 +02:00
|
|
|
}
|
|
|
|
}
|
2006-05-24 10:16:20 +02:00
|
|
|
ASSERT (i < SkuIdTable[0]);
|
2006-04-22 00:54:32 +02:00
|
|
|
|
2006-05-24 10:16:20 +02:00
|
|
|
switch (LocalTokenNumber & ~PCD_DATABASE_OFFSET_MASK) {
|
|
|
|
case PCD_TYPE_VPD:
|
|
|
|
Value = (UINT8 *) &(((VPD_HEAD *) Value)[i]);
|
|
|
|
return ((Value - PcdDb) | PCD_TYPE_VPD);
|
2006-04-22 00:54:32 +02:00
|
|
|
|
2006-05-24 10:16:20 +02:00
|
|
|
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;
|
2006-04-22 00:54:32 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-05-24 10:16:20 +02:00
|
|
|
VOID
|
|
|
|
InvokeCallbackOnSet (
|
|
|
|
UINT32 ExTokenNumber,
|
|
|
|
CONST EFI_GUID *Guid, OPTIONAL
|
|
|
|
UINTN TokenNumber,
|
|
|
|
VOID *Data,
|
|
|
|
UINTN Size
|
|
|
|
)
|
|
|
|
{
|
|
|
|
return;
|
2006-04-22 00:54:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-05-24 10:16:20 +02:00
|
|
|
|
2006-04-22 00:54:32 +02:00
|
|
|
EFI_STATUS
|
2006-05-24 10:16:20 +02:00
|
|
|
SetWorker (
|
|
|
|
UINTN TokenNumber,
|
|
|
|
VOID *Data,
|
|
|
|
UINTN Size,
|
|
|
|
BOOLEAN PtrType
|
2006-04-22 00:54:32 +02:00
|
|
|
)
|
|
|
|
{
|
2006-05-24 10:16:20 +02:00
|
|
|
UINT32 *LocalTokenNumberTable;
|
|
|
|
BOOLEAN IsPeiDb;
|
2006-04-22 00:54:32 +02:00
|
|
|
|
|
|
|
|
2006-05-24 10:16:20 +02:00
|
|
|
ASSERT (TokenNumber < PCD_TOTAL_TOKEN_NUMBER);
|
2006-04-22 00:54:32 +02:00
|
|
|
|
2006-05-24 10:16:20 +02:00
|
|
|
if (PtrType) {
|
|
|
|
ASSERT (Size <= DxePcdGetSize (TokenNumber));
|
|
|
|
} else {
|
|
|
|
ASSERT (Size == DxePcdGetSize (TokenNumber));
|
2006-04-22 00:54:32 +02:00
|
|
|
}
|
|
|
|
|
2006-05-24 10:16:20 +02:00
|
|
|
IsPeiDb = (TokenNumber <= PEI_LOCAL_TOKEN_NUMBER) ? TRUE : FALSE;
|
2006-04-22 00:54:32 +02:00
|
|
|
|
2006-05-24 10:16:20 +02:00
|
|
|
LocalTokenNumberTable = IsPeiDb ? gPcdDatabase->PeiDb.Init.LocalTokenNumberTable :
|
|
|
|
gPcdDatabase->DxeDb.Init.LocalTokenNumberTable;
|
2006-04-22 00:54:32 +02:00
|
|
|
|
2006-05-24 10:16:20 +02:00
|
|
|
TokenNumber = IsPeiDb ? TokenNumber
|
|
|
|
: TokenNumber - PEI_LOCAL_TOKEN_NUMBER;
|
2006-04-22 00:54:32 +02:00
|
|
|
|
2006-05-24 10:16:20 +02:00
|
|
|
InvokeCallbackOnSet (0, NULL, TokenNumber, Data, Size);
|
2006-04-22 00:54:32 +02:00
|
|
|
|
2006-05-24 10:16:20 +02:00
|
|
|
return SetWorkerByLocalTokenNumber (LocalTokenNumberTable[TokenNumber], Data, Size, PtrType, IsPeiDb);
|
2006-04-22 00:54:32 +02:00
|
|
|
|
2006-05-24 10:16:20 +02:00
|
|
|
}
|
2006-04-22 00:54:32 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-05-24 10:16:20 +02:00
|
|
|
VOID *
|
|
|
|
ExGetWorker (
|
|
|
|
IN CONST EFI_GUID *Guid,
|
|
|
|
IN UINTN ExTokenNumber,
|
|
|
|
IN UINTN GetSize
|
|
|
|
)
|
2006-04-22 00:54:32 +02:00
|
|
|
{
|
2006-05-24 10:16:20 +02:00
|
|
|
EX_PCD_ENTRY_ATTRIBUTE Attr;
|
2006-04-22 00:54:32 +02:00
|
|
|
|
2006-05-24 10:16:20 +02:00
|
|
|
GetExPcdTokenAttributes (Guid, ExTokenNumber, &Attr);
|
2006-04-22 00:54:32 +02:00
|
|
|
|
2006-05-24 10:16:20 +02:00
|
|
|
ASSERT ((GetSize == Attr.Size) || (GetSize == 0));
|
2006-04-22 00:54:32 +02:00
|
|
|
|
2006-05-24 10:16:20 +02:00
|
|
|
return GetWorkerByLocalTokenNumber (Attr.LocalTokenNumberAlias,
|
|
|
|
Attr.IsPeiDb,
|
|
|
|
Attr.Size
|
|
|
|
);
|
2006-04-22 00:54:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-05-24 10:16:20 +02:00
|
|
|
|
|
|
|
|
2006-04-22 00:54:32 +02:00
|
|
|
EFI_STATUS
|
2006-05-24 10:16:20 +02:00
|
|
|
ExSetWorker (
|
|
|
|
IN UINT32 ExTokenNumber,
|
|
|
|
IN CONST EFI_GUID *Guid,
|
|
|
|
VOID *Data,
|
|
|
|
UINTN SetSize,
|
|
|
|
BOOLEAN PtrType
|
2006-04-22 00:54:32 +02:00
|
|
|
)
|
|
|
|
{
|
2006-05-24 10:16:20 +02:00
|
|
|
EX_PCD_ENTRY_ATTRIBUTE Attr;
|
2006-04-22 00:54:32 +02:00
|
|
|
|
2006-05-24 10:16:20 +02:00
|
|
|
GetExPcdTokenAttributes (Guid, ExTokenNumber, &Attr);
|
2006-04-22 00:54:32 +02:00
|
|
|
|
2006-05-24 10:16:20 +02:00
|
|
|
ASSERT (!PtrType && (SetSize == Attr.Size));
|
2006-04-22 00:54:32 +02:00
|
|
|
|
2006-05-24 10:16:20 +02:00
|
|
|
ASSERT (PtrType && (SetSize <= Attr.Size));
|
2006-04-22 00:54:32 +02:00
|
|
|
|
2006-05-24 10:16:20 +02:00
|
|
|
InvokeCallbackOnSet (ExTokenNumber, Guid, Attr.TokenNumber, Data, Attr.Size);
|
2006-04-22 00:54:32 +02:00
|
|
|
|
2006-05-24 10:16:20 +02:00
|
|
|
SetWorkerByLocalTokenNumber (Attr.LocalTokenNumberAlias, Data, Attr.Size, PtrType, Attr.IsPeiDb);
|
2006-04-22 00:54:32 +02:00
|
|
|
|
2006-05-24 10:16:20 +02:00
|
|
|
return EFI_SUCCESS;
|
|
|
|
|
|
|
|
}
|
2006-04-22 00:54:32 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-05-24 10:16:20 +02:00
|
|
|
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);
|
|
|
|
}
|
2006-04-22 00:54:32 +02:00
|
|
|
|
2006-05-24 10:16:20 +02:00
|
|
|
Offset = LocalTokenNumber & PCD_DATABASE_OFFSET_MASK;
|
2006-04-22 00:54:32 +02:00
|
|
|
|
2006-05-24 10:16:20 +02:00
|
|
|
PcdDb = IsPeiDb ? ((UINT8 *) &gPcdDatabase->PeiDb) : ((UINT8 *) &gPcdDatabase->DxeDb);
|
2006-04-22 00:54:32 +02:00
|
|
|
|
2006-05-24 10:16:20 +02:00
|
|
|
StringTable = IsPeiDb ? gPcdDatabase->PeiDb.Init.StringTable :
|
|
|
|
gPcdDatabase->DxeDb.Init.StringTable;
|
|
|
|
|
|
|
|
InternalData = PcdDb + Offset;
|
2006-04-22 00:54:32 +02:00
|
|
|
|
2006-05-24 10:16:20 +02:00
|
|
|
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;
|
2006-04-22 00:54:32 +02:00
|
|
|
|
2006-05-24 10:16:20 +02:00
|
|
|
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]);
|
2006-04-22 00:54:32 +02:00
|
|
|
|
2006-05-24 10:16:20 +02:00
|
|
|
return EFI_SUCCESS;
|
2006-04-22 00:54:32 +02:00
|
|
|
|
2006-05-24 10:16:20 +02:00
|
|
|
case PCD_TYPE_DATA:
|
|
|
|
if (PtrType) {
|
|
|
|
CopyMem (InternalData, Data, Size);
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
2006-04-22 00:54:32 +02:00
|
|
|
|
2006-05-24 10:16:20 +02:00
|
|
|
switch (Size) {
|
|
|
|
case sizeof(UINT8):
|
|
|
|
*((UINT8 *) InternalData) = *((UINT8 *) Data);
|
|
|
|
return EFI_SUCCESS;
|
2006-04-22 00:54:32 +02:00
|
|
|
|
2006-05-24 10:16:20 +02:00
|
|
|
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;
|
2006-04-22 00:54:32 +02:00
|
|
|
|
2006-05-24 10:16:20 +02:00
|
|
|
default:
|
|
|
|
ASSERT (FALSE);
|
|
|
|
return EFI_NOT_FOUND;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
ASSERT (FALSE);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
ASSERT (FALSE);
|
|
|
|
return EFI_NOT_FOUND;
|
2006-04-22 00:54:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EFI_STATUS
|
|
|
|
SetHiiVariable (
|
|
|
|
IN EFI_GUID *VariableGuid,
|
|
|
|
IN UINT16 *VariableName,
|
|
|
|
IN CONST VOID *Data,
|
|
|
|
IN UINTN DataSize,
|
|
|
|
IN UINTN Offset
|
|
|
|
)
|
|
|
|
{
|
2006-05-24 10:16:20 +02:00
|
|
|
UINTN Size;
|
|
|
|
VOID *Buffer;
|
|
|
|
EFI_STATUS Status;
|
|
|
|
UINT32 Attribute;
|
2006-04-22 00:54:32 +02:00
|
|
|
|
|
|
|
Size = 0;
|
|
|
|
|
|
|
|
Status = EfiGetVariable (
|
|
|
|
(UINT16 *)VariableName,
|
|
|
|
VariableGuid,
|
2006-05-24 10:16:20 +02:00
|
|
|
&Attribute,
|
2006-04-22 00:54:32 +02:00
|
|
|
&Size,
|
|
|
|
NULL
|
|
|
|
);
|
|
|
|
|
|
|
|
ASSERT (Status == EFI_BUFFER_TOO_SMALL);
|
|
|
|
|
|
|
|
Buffer = AllocatePool (Size);
|
|
|
|
|
|
|
|
ASSERT (Buffer != NULL);
|
|
|
|
|
|
|
|
Status = EfiGetVariable (
|
|
|
|
VariableName,
|
|
|
|
VariableGuid,
|
2006-05-24 10:16:20 +02:00
|
|
|
&Attribute,
|
2006-04-22 00:54:32 +02:00
|
|
|
&Size,
|
|
|
|
Buffer
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
CopyMem ((UINT8 *)Buffer + Offset, Data, DataSize);
|
|
|
|
|
|
|
|
return EfiSetVariable (
|
|
|
|
VariableName,
|
|
|
|
VariableGuid,
|
2006-05-24 10:16:20 +02:00
|
|
|
Attribute,
|
2006-04-22 00:54:32 +02:00
|
|
|
Size,
|
|
|
|
Buffer
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2006-05-24 10:16:20 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|