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
This commit is contained in:
qwang12 2006-06-13 10:34:56 +00:00
parent 7db4ab705a
commit c0e96fed14
3 changed files with 95 additions and 52 deletions

View File

@ -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
);
}

View File

@ -96,6 +96,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,

View File

@ -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: