diff options
author | qwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524> | 2008-04-17 13:28:36 +0000 |
---|---|---|
committer | qwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524> | 2008-04-17 13:28:36 +0000 |
commit | 99a83b4c44791cf3abc426f498699e36a76e5fc6 (patch) | |
tree | 5e4db861464321d6958b94761acbfb81330b68d1 /EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Forms.c | |
parent | dd4047a51c56bae1080b357330ed99dcd286c766 (diff) | |
download | edk2-platforms-99a83b4c44791cf3abc426f498699e36a76e5fc6.tar.xz |
Add in Thunking function for Dynamic Code creation. Only support Text and Subtitle for now).
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5082 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Forms.c')
-rw-r--r-- | EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Forms.c | 155 |
1 files changed, 153 insertions, 2 deletions
diff --git a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Forms.c b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Forms.c index 6cf81c3f8a..7b3aa64d77 100644 --- a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Forms.c +++ b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Forms.c @@ -163,6 +163,128 @@ ThunkUpdateFormCallBack ( return EFI_SUCCESS;
}
+#define LOCAL_UPDATE_DATA_BUFFER_INCREMENTAL 0x1000
+
+EFI_STATUS
+AppendToUpdateBuffer (
+ IN CONST UINT8 *OpCodeBuf,
+ IN UINTN BufSize,
+ OUT EFI_HII_UPDATE_DATA *UefiData
+ )
+{
+ UINT8 * NewBuff;
+
+ if (UefiData->Offset + BufSize > UefiData->BufferSize) {
+ NewBuff = AllocateCopyPool (UefiData->BufferSize + LOCAL_UPDATE_DATA_BUFFER_INCREMENTAL, UefiData->Data);
+ if (NewBuff == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+ UefiData->BufferSize += LOCAL_UPDATE_DATA_BUFFER_INCREMENTAL;
+ FreePool (UefiData->Data);
+ UefiData->Data = NewBuff;
+ }
+
+ CopyMem (UefiData->Data + UefiData->Offset, OpCodeBuf, BufSize);
+ UefiData->Offset += BufSize;
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+Framework2UefiCreateSubtitleOpCode (
+ IN CONST FRAMEWORK_EFI_IFR_SUBTITLE *FwSubTitle,
+ OUT EFI_HII_UPDATE_DATA *UefiData
+ )
+{
+ EFI_IFR_SUBTITLE USubTitle;
+
+ ZeroMem (&USubTitle, sizeof(USubTitle));
+
+ USubTitle.Header.OpCode = EFI_IFR_SUBTITLE_OP;
+ USubTitle.Header.Length = sizeof (EFI_IFR_SUBTITLE);
+
+ USubTitle.Statement.Prompt = FwSubTitle->SubTitle;
+
+ return AppendToUpdateBuffer ((UINT8 *)&USubTitle, sizeof(EFI_IFR_SUBTITLE), UefiData);
+}
+
+EFI_STATUS
+Framework2UefiCreateTextOpCode (
+ IN CONST FRAMEWORK_EFI_IFR_TEXT *FwText,
+ OUT EFI_HII_UPDATE_DATA *UefiData
+ )
+{
+ EFI_IFR_TEXT UText;
+
+ ZeroMem (&UText, sizeof(UText));
+
+ UText.Header.OpCode = EFI_IFR_TEXT_OP;
+ UText.Header.Length = sizeof (EFI_IFR_TEXT);
+
+ UText.Statement.Help = FwText->Help;
+
+ UText.Statement.Prompt = FwText->Text;
+ UText.TextTwo = FwText->TextTwo;
+
+ return AppendToUpdateBuffer ((UINT8 *) &UText, sizeof(EFI_IFR_TEXT), UefiData);
+}
+
+
+EFI_STATUS
+ThunkFrameworkUpdateDataToUefiUpdateData (
+ IN CONST FRAMEWORK_EFI_HII_UPDATE_DATA *Data,
+ IN BOOLEAN AddData,
+ OUT EFI_HII_UPDATE_DATA **UefiData
+ )
+{
+ FRAMEWORK_EFI_IFR_OP_HEADER *FrameworkOpcodeBuffer;
+ EFI_HII_UPDATE_DATA *UefiUpdateDataBuffer;
+ UINTN Index;
+ EFI_STATUS Status;
+
+ UefiUpdateDataBuffer = AllocateZeroPool (sizeof (EFI_HII_UPDATE_DATA));
+ if (UefiUpdateDataBuffer == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ UefiUpdateDataBuffer->Data = AllocateZeroPool (LOCAL_UPDATE_DATA_BUFFER_INCREMENTAL);
+ if (UefiUpdateDataBuffer->Data == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ UefiUpdateDataBuffer->BufferSize = LOCAL_UPDATE_DATA_BUFFER_INCREMENTAL;
+ UefiUpdateDataBuffer->Offset = 0;
+
+ FrameworkOpcodeBuffer = (FRAMEWORK_EFI_IFR_OP_HEADER *) &Data->Data;
+
+ for (Index = 0; Index < Data->DataCount; Index++) {
+ switch (FrameworkOpcodeBuffer->OpCode) {
+ case FRAMEWORK_EFI_IFR_SUBTITLE_OP:
+ Status = Framework2UefiCreateSubtitleOpCode ((FRAMEWORK_EFI_IFR_SUBTITLE *) FrameworkOpcodeBuffer, UefiUpdateDataBuffer);
+ break;
+
+ case FRAMEWORK_EFI_IFR_TEXT_OP:
+ Status = Framework2UefiCreateTextOpCode ((FRAMEWORK_EFI_IFR_TEXT *) FrameworkOpcodeBuffer, UefiUpdateDataBuffer);
+ break;
+
+ default:
+ ASSERT (FALSE);
+ return EFI_UNSUPPORTED;
+ }
+
+ if (EFI_ERROR (Status)) {
+ FreePool (UefiUpdateDataBuffer->Data);
+ FreePool (UefiUpdateDataBuffer);
+ return Status;
+ }
+
+ FrameworkOpcodeBuffer = (FRAMEWORK_EFI_IFR_OP_HEADER *)((UINT8 *) FrameworkOpcodeBuffer + FrameworkOpcodeBuffer->Length);
+ }
+
+ *UefiData = UefiUpdateDataBuffer;
+
+ return EFI_SUCCESS;
+}
EFI_STATUS
EFIAPI
HiiUpdateForm (
@@ -170,7 +292,7 @@ HiiUpdateForm ( IN FRAMEWORK_EFI_HII_HANDLE Handle,
IN EFI_FORM_LABEL Label,
IN BOOLEAN AddData,
- IN EFI_HII_UPDATE_DATA *Data
+ IN FRAMEWORK_EFI_HII_UPDATE_DATA *Data
)
/*++
@@ -193,6 +315,10 @@ Returns: EFI_STATUS Status;
EFI_HII_THUNK_PRIVATE_DATA *Private;
HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY *HandleMapEntry;
+ EFI_HII_UPDATE_DATA *UefiHiiUpdateData;
+ EFI_HII_HANDLE UefiHiiHandle;
+
+ Status = EFI_SUCCESS;
Private = EFI_HII_THUNK_PRIVATE_DATA_FROM_THIS(This);
@@ -208,5 +334,30 @@ Returns: return Status;
}
}
- return EFI_SUCCESS;
+
+ if (Data->DataCount != 0) {
+ if (HandleMapEntry->IsPackageListWithOnlyStringPackages) {
+ UefiHiiHandle = TagGuidToUefiIfrHiiHandle (Private, &HandleMapEntry->TagGuid);
+
+ if (UefiHiiHandle == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+ } else {
+ UefiHiiHandle = HandleMapEntry->UefiHiiHandle;
+ }
+
+ UefiHiiUpdateData = NULL;
+
+ ThunkFrameworkUpdateDataToUefiUpdateData (Data, AddData, &UefiHiiUpdateData);
+
+ Status = IfrLibUpdateForm (UefiHiiHandle, NULL, 0, Label, AddData, UefiHiiUpdateData);
+ ASSERT_EFI_ERROR (Status);
+
+ if (UefiHiiUpdateData != NULL) {
+ SafeFreePool (UefiHiiUpdateData->Data);
+ SafeFreePool (UefiHiiUpdateData);
+ }
+ }
+
+ return Status;
}
|