MdeModulePkg: Add ATTRIBUTE (+/-RT, RO) support in PCD declaration in DSC file.
Also update PCD_SERVICE_PEI_VERSION and PCD_SERVICE_DXE_VERSION to match with the new PcdDataBase binary generated by BaseTools. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Star Zeng <star.zeng@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com> Reviewed-by: Jiewen Yao <jiewen.yao@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17161 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
@ -1,7 +1,7 @@
|
|||||||
/** @file
|
/** @file
|
||||||
Guid for Pcd DataBase Signature.
|
Guid for Pcd DataBase Signature.
|
||||||
|
|
||||||
Copyright (c) 2012 - 2013, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2012 - 2015, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials are licensed and made available under
|
This program and the accompanying materials are licensed and made available under
|
||||||
the terms and conditions of the BSD License that accompanies this distribution.
|
the terms and conditions of the BSD License that accompanies this distribution.
|
||||||
The full text of the license may be found at
|
The full text of the license may be found at
|
||||||
@ -71,6 +71,9 @@ typedef struct {
|
|||||||
UINT32 DefaultValueOffset; // Offset of the Default Value.
|
UINT32 DefaultValueOffset; // Offset of the Default Value.
|
||||||
UINT16 GuidTableIndex; // Offset in Guid Table in units of GUID.
|
UINT16 GuidTableIndex; // Offset in Guid Table in units of GUID.
|
||||||
UINT16 Offset; // Offset in Variable.
|
UINT16 Offset; // Offset in Variable.
|
||||||
|
UINT32 Attributes; // Variable attributes.
|
||||||
|
UINT16 Property; // Variable property.
|
||||||
|
UINT16 Reserved;
|
||||||
} VARIABLE_HEAD;
|
} VARIABLE_HEAD;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
produce the implementation of native PCD protocol and EFI_PCD_PROTOCOL defined in
|
produce the implementation of native PCD protocol and EFI_PCD_PROTOCOL defined in
|
||||||
PI 1.2 Vol3.
|
PI 1.2 Vol3.
|
||||||
|
|
||||||
Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
@ -129,6 +129,7 @@ PcdDxeInit (
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
|
VOID *Registration;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Make sure the Pcd Protocol is not already installed in the system
|
// Make sure the Pcd Protocol is not already installed in the system
|
||||||
@ -167,6 +168,18 @@ PcdDxeInit (
|
|||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Register callback function upon VariableLockProtocol
|
||||||
|
// to lock the variables referenced by DynamicHii PCDs with RO property set in *.dsc.
|
||||||
|
//
|
||||||
|
EfiCreateProtocolNotifyEvent (
|
||||||
|
&gEdkiiVariableLockProtocolGuid,
|
||||||
|
TPL_CALLBACK,
|
||||||
|
VariableLockCallBack,
|
||||||
|
NULL,
|
||||||
|
&Registration
|
||||||
|
);
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -279,7 +279,7 @@
|
|||||||
# - Variable GUID for HII type PCD
|
# - Variable GUID for HII type PCD
|
||||||
# - Token space GUID for dynamicex type PCD
|
# - Token space GUID for dynamicex type PCD
|
||||||
#
|
#
|
||||||
# Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
|
# Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
|
||||||
#
|
#
|
||||||
# This program and the accompanying materials
|
# This program and the accompanying materials
|
||||||
# are licensed and made available under the terms and conditions of the BSD License
|
# are licensed and made available under the terms and conditions of the BSD License
|
||||||
@ -338,6 +338,9 @@
|
|||||||
gEfiPcdProtocolGuid ## PRODUCES
|
gEfiPcdProtocolGuid ## PRODUCES
|
||||||
gGetPcdInfoProtocolGuid ## SOMETIMES_PRODUCES
|
gGetPcdInfoProtocolGuid ## SOMETIMES_PRODUCES
|
||||||
gEfiGetPcdInfoProtocolGuid ## SOMETIMES_PRODUCES
|
gEfiGetPcdInfoProtocolGuid ## SOMETIMES_PRODUCES
|
||||||
|
## NOTIFY
|
||||||
|
## SOMETIMES_CONSUMES
|
||||||
|
gEdkiiVariableLockProtocolGuid
|
||||||
|
|
||||||
[Pcd]
|
[Pcd]
|
||||||
gEfiMdeModulePkgTokenSpaceGuid.PcdVpdBaseAddress ## SOMETIMES_CONSUMES
|
gEfiMdeModulePkgTokenSpaceGuid.PcdVpdBaseAddress ## SOMETIMES_CONSUMES
|
||||||
|
@ -1112,6 +1112,7 @@ SetWorker (
|
|||||||
EFI_GUID *Guid;
|
EFI_GUID *Guid;
|
||||||
UINT16 *Name;
|
UINT16 *Name;
|
||||||
UINTN VariableOffset;
|
UINTN VariableOffset;
|
||||||
|
UINT32 Attributes;
|
||||||
VOID *InternalData;
|
VOID *InternalData;
|
||||||
VARIABLE_HEAD *VariableHead;
|
VARIABLE_HEAD *VariableHead;
|
||||||
UINTN Offset;
|
UINTN Offset;
|
||||||
@ -1223,20 +1224,8 @@ SetWorker (
|
|||||||
Guid = GuidTable + VariableHead->GuidTableIndex;
|
Guid = GuidTable + VariableHead->GuidTableIndex;
|
||||||
Name = (UINT16*) (StringTable + VariableHead->StringIndex);
|
Name = (UINT16*) (StringTable + VariableHead->StringIndex);
|
||||||
VariableOffset = VariableHead->Offset;
|
VariableOffset = VariableHead->Offset;
|
||||||
Status = SetHiiVariable (Guid, Name, Data, *Size, VariableOffset);
|
Attributes = VariableHead->Attributes;
|
||||||
|
Status = SetHiiVariable (Guid, Name, Attributes, Data, *Size, VariableOffset);
|
||||||
if (EFI_NOT_FOUND == Status) {
|
|
||||||
if ((LocalTokenNumber & PCD_TYPE_ALL_SET) == (PCD_TYPE_HII|PCD_TYPE_STRING)) {
|
|
||||||
CopyMem (
|
|
||||||
StringTable + *(STRING_HEAD *)(PcdDb + VariableHead->DefaultValueOffset),
|
|
||||||
Data,
|
|
||||||
*Size
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
CopyMem (PcdDb + VariableHead->DefaultValueOffset, Data, *Size);
|
|
||||||
}
|
|
||||||
Status = EFI_SUCCESS;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PCD_TYPE_DATA:
|
case PCD_TYPE_DATA:
|
||||||
@ -1373,6 +1362,7 @@ ExSetWorker (
|
|||||||
|
|
||||||
@param VariableGuid Guid of variable which stored value of a HII-type PCD.
|
@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 VariableName Unicode name of variable which stored value of a HII-type PCD.
|
||||||
|
@param SetAttributes Attributes bitmask to set for the variable.
|
||||||
@param Data Value want to be set.
|
@param Data Value want to be set.
|
||||||
@param DataSize Size of value
|
@param DataSize Size of value
|
||||||
@param Offset Value offset of HII-type PCD in variable.
|
@param Offset Value offset of HII-type PCD in variable.
|
||||||
@ -1384,6 +1374,7 @@ EFI_STATUS
|
|||||||
SetHiiVariable (
|
SetHiiVariable (
|
||||||
IN EFI_GUID *VariableGuid,
|
IN EFI_GUID *VariableGuid,
|
||||||
IN UINT16 *VariableName,
|
IN UINT16 *VariableName,
|
||||||
|
IN UINT32 SetAttributes,
|
||||||
IN CONST VOID *Data,
|
IN CONST VOID *Data,
|
||||||
IN UINTN DataSize,
|
IN UINTN DataSize,
|
||||||
IN UINTN Offset
|
IN UINTN Offset
|
||||||
@ -1433,10 +1424,14 @@ SetHiiVariable (
|
|||||||
|
|
||||||
CopyMem ((UINT8 *)Buffer + Offset, Data, DataSize);
|
CopyMem ((UINT8 *)Buffer + Offset, Data, DataSize);
|
||||||
|
|
||||||
|
if (SetAttributes == 0) {
|
||||||
|
SetAttributes = Attribute;
|
||||||
|
}
|
||||||
|
|
||||||
Status = gRT->SetVariable (
|
Status = gRT->SetVariable (
|
||||||
VariableName,
|
VariableName,
|
||||||
VariableGuid,
|
VariableGuid,
|
||||||
Attribute,
|
SetAttributes,
|
||||||
SetSize,
|
SetSize,
|
||||||
Buffer
|
Buffer
|
||||||
);
|
);
|
||||||
@ -1455,10 +1450,14 @@ SetHiiVariable (
|
|||||||
|
|
||||||
CopyMem ((UINT8 *)Buffer + Offset, Data, DataSize);
|
CopyMem ((UINT8 *)Buffer + Offset, Data, DataSize);
|
||||||
|
|
||||||
|
if (SetAttributes == 0) {
|
||||||
|
SetAttributes = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE;
|
||||||
|
}
|
||||||
|
|
||||||
Status = gRT->SetVariable (
|
Status = gRT->SetVariable (
|
||||||
VariableName,
|
VariableName,
|
||||||
VariableGuid,
|
VariableGuid,
|
||||||
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
|
SetAttributes,
|
||||||
Size,
|
Size,
|
||||||
Buffer
|
Buffer
|
||||||
);
|
);
|
||||||
@ -1468,8 +1467,7 @@ SetHiiVariable (
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// If we drop to here, the value is failed to be written in to variable area
|
// If we drop to here, the value is failed to be written in to variable area.
|
||||||
// So, we will save the data in the PCD Database's volatile area.
|
|
||||||
//
|
//
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
@ -1820,3 +1818,91 @@ SetPtrTypeSize (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
VariableLock DynamicHiiPcd.
|
||||||
|
|
||||||
|
@param[in] IsPeiDb If TRUE, the pcd entry is initialized in PEI phase,
|
||||||
|
If FALSE, the pcd entry is initialized in DXE phase.
|
||||||
|
@param[in] VariableLock Pointer to VariableLockProtocol.
|
||||||
|
|
||||||
|
**/
|
||||||
|
VOID
|
||||||
|
VariableLockDynamicHiiPcd (
|
||||||
|
IN BOOLEAN IsPeiDb,
|
||||||
|
IN EDKII_VARIABLE_LOCK_PROTOCOL *VariableLock
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
PCD_DATABASE_INIT *Database;
|
||||||
|
UINT32 LocalTokenCount;
|
||||||
|
UINTN TokenNumber;
|
||||||
|
UINT32 LocalTokenNumber;
|
||||||
|
UINTN Offset;
|
||||||
|
EFI_GUID *GuidTable;
|
||||||
|
UINT8 *StringTable;
|
||||||
|
VARIABLE_HEAD *VariableHead;
|
||||||
|
EFI_GUID *Guid;
|
||||||
|
UINT16 *Name;
|
||||||
|
|
||||||
|
Database = IsPeiDb ? mPcdDatabase.PeiDb: mPcdDatabase.DxeDb;
|
||||||
|
LocalTokenCount = IsPeiDb ? mPeiLocalTokenCount: mDxeLocalTokenCount;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Go through PCD database to find out DynamicHii PCDs.
|
||||||
|
//
|
||||||
|
for (TokenNumber = 0; TokenNumber < LocalTokenCount; TokenNumber++) {
|
||||||
|
if (IsPeiDb) {
|
||||||
|
LocalTokenNumber = GetLocalTokenNumber (TRUE, TokenNumber);
|
||||||
|
} else {
|
||||||
|
LocalTokenNumber = GetLocalTokenNumber (FALSE, TokenNumber + mPeiLocalTokenCount);
|
||||||
|
}
|
||||||
|
if ((LocalTokenNumber & PCD_TYPE_HII) != 0) {
|
||||||
|
Offset = LocalTokenNumber & PCD_DATABASE_OFFSET_MASK;
|
||||||
|
VariableHead = (VARIABLE_HEAD *) ((UINT8 *) Database + Offset);
|
||||||
|
//
|
||||||
|
// Why not to set property by VarCheckProtocol with Attributes and Property directly here?
|
||||||
|
// It is because that set property by VarCheckProtocol will indicate the variable to
|
||||||
|
// be a system variable, but the unknown max size of the variable is dangerous to
|
||||||
|
// the system variable region.
|
||||||
|
//
|
||||||
|
if ((VariableHead->Property & VAR_CHECK_VARIABLE_PROPERTY_READ_ONLY) != 0) {
|
||||||
|
//
|
||||||
|
// DynamicHii PCD with RO property set in *.dsc.
|
||||||
|
//
|
||||||
|
StringTable = (UINT8 *) ((UINT8 *) Database + Database->StringTableOffset);
|
||||||
|
GuidTable = (EFI_GUID *) ((UINT8 *) Database + Database->GuidTableOffset);
|
||||||
|
Guid = GuidTable + VariableHead->GuidTableIndex;
|
||||||
|
Name = (UINT16*) (StringTable + VariableHead->StringIndex);
|
||||||
|
Status = VariableLock->RequestToLock (VariableLock, Name, Guid);
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
VariableLockProtocol callback
|
||||||
|
to lock the variables referenced by DynamicHii PCDs with RO property set in *.dsc.
|
||||||
|
|
||||||
|
@param[in] Event Event whose notification function is being invoked.
|
||||||
|
@param[in] Context Pointer to the notification function's context.
|
||||||
|
|
||||||
|
**/
|
||||||
|
VOID
|
||||||
|
EFIAPI
|
||||||
|
VariableLockCallBack (
|
||||||
|
IN EFI_EVENT Event,
|
||||||
|
IN VOID *Context
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
EDKII_VARIABLE_LOCK_PROTOCOL *VariableLock;
|
||||||
|
|
||||||
|
Status = gBS->LocateProtocol (&gEdkiiVariableLockProtocolGuid, NULL, (VOID **) &VariableLock);
|
||||||
|
if (!EFI_ERROR (Status)) {
|
||||||
|
VariableLockDynamicHiiPcd (TRUE, VariableLock);
|
||||||
|
VariableLockDynamicHiiPcd (FALSE, VariableLock);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/** @file
|
/** @file
|
||||||
Private functions used by PCD DXE driver.
|
Private functions used by PCD DXE driver.
|
||||||
|
|
||||||
Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
@ -22,6 +22,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||||||
#include <Protocol/PiPcd.h>
|
#include <Protocol/PiPcd.h>
|
||||||
#include <Protocol/PcdInfo.h>
|
#include <Protocol/PcdInfo.h>
|
||||||
#include <Protocol/PiPcdInfo.h>
|
#include <Protocol/PiPcdInfo.h>
|
||||||
|
#include <Protocol/VarCheck.h>
|
||||||
|
#include <Protocol/VariableLock.h>
|
||||||
#include <Library/BaseLib.h>
|
#include <Library/BaseLib.h>
|
||||||
#include <Library/DebugLib.h>
|
#include <Library/DebugLib.h>
|
||||||
#include <Library/UefiLib.h>
|
#include <Library/UefiLib.h>
|
||||||
@ -37,7 +39,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||||||
// Please make sure the PCD Serivce DXE Version is consistent with
|
// Please make sure the PCD Serivce DXE Version is consistent with
|
||||||
// the version of the generated DXE PCD Database by build tool.
|
// the version of the generated DXE PCD Database by build tool.
|
||||||
//
|
//
|
||||||
#define PCD_SERVICE_DXE_VERSION 4
|
#define PCD_SERVICE_DXE_VERSION 5
|
||||||
|
|
||||||
//
|
//
|
||||||
// PCD_DXE_SERVICE_DRIVER_VERSION is defined in Autogen.h.
|
// PCD_DXE_SERVICE_DRIVER_VERSION is defined in Autogen.h.
|
||||||
@ -1003,6 +1005,7 @@ GetHiiVariable (
|
|||||||
|
|
||||||
@param VariableGuid Guid of variable which stored value of a HII-type PCD.
|
@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 VariableName Unicode name of variable which stored value of a HII-type PCD.
|
||||||
|
@param SetAttributes Attributes bitmask to set for the variable.
|
||||||
@param Data Value want to be set.
|
@param Data Value want to be set.
|
||||||
@param DataSize Size of value
|
@param DataSize Size of value
|
||||||
@param Offset Value offset of HII-type PCD in variable.
|
@param Offset Value offset of HII-type PCD in variable.
|
||||||
@ -1014,6 +1017,7 @@ EFI_STATUS
|
|||||||
SetHiiVariable (
|
SetHiiVariable (
|
||||||
IN EFI_GUID *VariableGuid,
|
IN EFI_GUID *VariableGuid,
|
||||||
IN UINT16 *VariableName,
|
IN UINT16 *VariableName,
|
||||||
|
IN UINT32 SetAttributes,
|
||||||
IN CONST VOID *Data,
|
IN CONST VOID *Data,
|
||||||
IN UINTN DataSize,
|
IN UINTN DataSize,
|
||||||
IN UINTN Offset
|
IN UINTN Offset
|
||||||
@ -1158,6 +1162,21 @@ SetPtrTypeSize (
|
|||||||
IN OUT UINTN *CurrentSize
|
IN OUT UINTN *CurrentSize
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
VariableLockProtocol callback
|
||||||
|
to lock the variables referenced by DynamicHii PCDs with RO property set in *.dsc.
|
||||||
|
|
||||||
|
@param[in] Event Event whose notification function is being invoked.
|
||||||
|
@param[in] Context Pointer to the notification function's context.
|
||||||
|
|
||||||
|
**/
|
||||||
|
VOID
|
||||||
|
EFIAPI
|
||||||
|
VariableLockCallBack (
|
||||||
|
IN EFI_EVENT Event,
|
||||||
|
IN VOID *Context
|
||||||
|
);
|
||||||
|
|
||||||
extern PCD_DATABASE mPcdDatabase;
|
extern PCD_DATABASE mPcdDatabase;
|
||||||
|
|
||||||
extern UINT32 mPcdTotalTokenCount;
|
extern UINT32 mPcdTotalTokenCount;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/** @file
|
/** @file
|
||||||
The internal header file declares the private functions used by PeiPcd driver.
|
The internal header file declares the private functions used by PeiPcd driver.
|
||||||
|
|
||||||
Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
@ -36,7 +36,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||||||
// Please make sure the PCD Serivce PEIM Version is consistent with
|
// Please make sure the PCD Serivce PEIM Version is consistent with
|
||||||
// the version of the generated PEIM PCD Database by build tool.
|
// the version of the generated PEIM PCD Database by build tool.
|
||||||
//
|
//
|
||||||
#define PCD_SERVICE_PEIM_VERSION 4
|
#define PCD_SERVICE_PEIM_VERSION 5
|
||||||
|
|
||||||
//
|
//
|
||||||
// PCD_PEI_SERVICE_DRIVER_VERSION is defined in Autogen.h.
|
// PCD_PEI_SERVICE_DRIVER_VERSION is defined in Autogen.h.
|
||||||
|
Reference in New Issue
Block a user