summaryrefslogtreecommitdiff
path: root/EdkModulePkg/Universal/PCD
diff options
context:
space:
mode:
authorqwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524>2006-06-13 10:34:56 +0000
committerqwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524>2006-06-13 10:34:56 +0000
commitc0e96fed1402f44ff4542346865db2a27b979c24 (patch)
tree7e2a155277ed3ba809ce0dfd6972580677cfcefd /EdkModulePkg/Universal/PCD
parent7db4ab705a654e2202b083968e92d5b552007d6b (diff)
downloadedk2-platforms-c0e96fed1402f44ff4542346865db2a27b979c24.tar.xz
Add in HII enable support for PCD.
But the default value has not been enabled. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@498 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'EdkModulePkg/Universal/PCD')
-rw-r--r--EdkModulePkg/Universal/PCD/Dxe/Service.c88
-rw-r--r--EdkModulePkg/Universal/PCD/Dxe/Service.h10
-rw-r--r--EdkModulePkg/Universal/PCD/Pei/Service.c49
3 files changed, 95 insertions, 52 deletions
diff --git a/EdkModulePkg/Universal/PCD/Dxe/Service.c b/EdkModulePkg/Universal/PCD/Dxe/Service.c
index 84bfae7bf0..36e859c779 100644
--- a/EdkModulePkg/Universal/PCD/Dxe/Service.c
+++ b/EdkModulePkg/Universal/PCD/Dxe/Service.c
@@ -95,10 +95,16 @@ GetWorker (
Name = &(StringTable[VariableHead->StringIndex]);
Status = GetHiiVariable (Guid, Name, &Data, &DataSize);
- ASSERT_EFI_ERROR (Status);
- ASSERT (DataSize >= (UINTN) (VariableHead->Offset + Size));
-
- return (UINT8 *) Data + VariableHead->Offset;
+ if (Status == EFI_SUCCESS) {
+ ASSERT (DataSize >= (UINTN) (VariableHead->Offset + Size));
+ return (UINT8 *) Data + VariableHead->Offset;
+ } else {
+ //
+ // BugBug: Need to support default value. The current implementation
+ // will return a memory buffer with ALL ZERO.
+ //
+ return AllocateZeroPool (Size);
+ }
case PCD_TYPE_STRING:
StringTableIdx = (UINT16) *((UINT8 *) PcdDb + Offset);
@@ -343,19 +349,22 @@ GetHiiVariable (
&Size,
NULL
);
- ASSERT (Status == EFI_BUFFER_TOO_SMALL);
+ if (Status == EFI_BUFFER_TOO_SMALL) {
- Buffer = AllocatePool (Size);
+ Buffer = AllocatePool (Size);
- ASSERT (Buffer != NULL);
+ ASSERT (Buffer != NULL);
- Status = EfiGetVariable (
- VariableName,
- VariableGuid,
- NULL,
- &Size,
- Buffer
- );
+ Status = EfiGetVariable (
+ VariableName,
+ VariableGuid,
+ NULL,
+ &Size,
+ Buffer
+ );
+
+ ASSERT (Status == EFI_SUCCESS);
+ }
return Status;
@@ -470,6 +479,7 @@ SetWorker (
UINT16 *StringTable;
EFI_GUID *Guid;
UINT16 *Name;
+ UINTN VariableOffset;
VOID *InternalData;
VARIABLE_HEAD *VariableHead;
UINTN Offset;
@@ -519,7 +529,7 @@ SetWorker (
case PCD_TYPE_STRING:
CopyMem (&StringTable[*((UINT16 *)InternalData)], Data, Size);
- break;
+ return EFI_SUCCESS;
case PCD_TYPE_HII:
//
@@ -532,8 +542,9 @@ SetWorker (
Guid = &(GuidTable[VariableHead->GuidTableIndex]);
Name = &(StringTable[VariableHead->StringIndex]);
+ VariableOffset = VariableHead->Offset;
- return EFI_SUCCESS;
+ return SetHiiVariable (Guid, Name, Data, Size, VariableOffset);
case PCD_TYPE_DATA:
if (PtrType) {
@@ -638,30 +649,41 @@ SetHiiVariable (
NULL
);
- ASSERT (Status == EFI_BUFFER_TOO_SMALL);
+ if (Status == EFI_BUFFER_TOO_SMALL) {
- Buffer = AllocatePool (Size);
+ Buffer = AllocatePool (Size);
- ASSERT (Buffer != NULL);
+ ASSERT (Buffer != NULL);
- Status = EfiGetVariable (
- VariableName,
- VariableGuid,
- &Attribute,
- &Size,
- Buffer
- );
+ Status = EfiGetVariable (
+ VariableName,
+ VariableGuid,
+ &Attribute,
+ &Size,
+ Buffer
+ );
+
+ ASSERT_EFI_ERROR (Status);
+ CopyMem ((UINT8 *)Buffer + Offset, Data, DataSize);
- CopyMem ((UINT8 *)Buffer + Offset, Data, DataSize);
+ } else {
+
+ Attribute = EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS;
+ Size = DataSize + Offset;
+ Buffer = AllocateZeroPool (Size);
+ ASSERT (Buffer != NULL);
+ CopyMem ((UINT8 *)Buffer + Offset, Data, DataSize);
+
+ }
return EfiSetVariable (
- VariableName,
- VariableGuid,
- Attribute,
- Size,
- Buffer
- );
+ VariableName,
+ VariableGuid,
+ Attribute,
+ Size,
+ Buffer
+ );
}
diff --git a/EdkModulePkg/Universal/PCD/Dxe/Service.h b/EdkModulePkg/Universal/PCD/Dxe/Service.h
index 59ec06352e..a1757ed056 100644
--- a/EdkModulePkg/Universal/PCD/Dxe/Service.h
+++ b/EdkModulePkg/Universal/PCD/Dxe/Service.h
@@ -97,6 +97,16 @@ GetHiiVariable (
;
EFI_STATUS
+SetHiiVariable (
+ IN EFI_GUID *VariableGuid,
+ IN UINT16 *VariableName,
+ IN CONST VOID *Data,
+ IN UINTN DataSize,
+ IN UINTN Offset
+ )
+;
+
+EFI_STATUS
DxeRegisterCallBackWorker (
IN UINTN TokenNumber,
IN CONST EFI_GUID *Guid, OPTIONAL
diff --git a/EdkModulePkg/Universal/PCD/Pei/Service.c b/EdkModulePkg/Universal/PCD/Pei/Service.c
index 2de061bdb0..0574ae4042 100644
--- a/EdkModulePkg/Universal/PCD/Pei/Service.c
+++ b/EdkModulePkg/Universal/PCD/Pei/Service.c
@@ -148,7 +148,6 @@ GetHiiVariable (
ASSERT_EFI_ERROR (Status);
Size = 0;
-
Status = VariablePpi->PeiGetVariable (
GetPeiServicesTablePointer (),
VariableName,
@@ -157,25 +156,30 @@ GetHiiVariable (
&Size,
NULL
);
- ASSERT (Status == EFI_BUFFER_TOO_SMALL);
+ if (Status == EFI_BUFFER_TOO_SMALL) {
- Status = PeiServicesAllocatePool (Size, &Buffer);
- ASSERT_EFI_ERROR (Status);
- Status = VariablePpi->PeiGetVariable (
- GetPeiServicesTablePointer (),
- (UINT16 *) VariableName,
- (EFI_GUID *) VariableGuid,
- NULL,
- &Size,
- Buffer
- );
- ASSERT_EFI_ERROR (Status);
+ Status = PeiServicesAllocatePool (Size, &Buffer);
+ ASSERT_EFI_ERROR (Status);
- *VariableSize = Size;
- *VariableData = Buffer;
+ Status = VariablePpi->PeiGetVariable (
+ GetPeiServicesTablePointer (),
+ (UINT16 *) VariableName,
+ (EFI_GUID *) VariableGuid,
+ NULL,
+ &Size,
+ Buffer
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ *VariableSize = Size;
+ *VariableData = Buffer;
+
+ return EFI_SUCCESS;
+ } else {
+ return EFI_NOT_FOUND;
+ }
- return EFI_SUCCESS;
}
@@ -454,10 +458,17 @@ GetWorker (
Name = &StringTable[VariableHead->StringIndex];
Status = GetHiiVariable (Guid, Name, &Data, &DataSize);
- ASSERT_EFI_ERROR (Status);
- ASSERT (DataSize >= (UINTN) (VariableHead->Offset + Size));
- return (VOID *) ((UINT8 *) Data + VariableHead->Offset);
+ if (Status == EFI_SUCCESS) {
+ ASSERT (DataSize >= (UINTN) (VariableHead->Offset + Size));
+ return (VOID *) ((UINT8 *) Data + VariableHead->Offset);
+ } else {
+ //
+ // BugBug: Need to support default value. The current implementation
+ // will return a memory buffer with ALL ZERO.
+ //
+ return AllocateZeroPool (Size);
+ }
}
case PCD_TYPE_DATA: