From c909d52e5fa89bffa83f7109856d82dc07c56b82 Mon Sep 17 00:00:00 2001 From: Konstantin Aladyshev Date: Thu, 11 Nov 2021 16:08:26 +0300 Subject: Add lesson 58 Signed-off-by: Konstantin Aladyshev --- .../UefiLessonsPkg/HIIStaticForm/Form.vfr | 37 +++++++++++++++ .../UefiLessonsPkg/HIIStaticForm/HIIStaticForm.c | 54 ++++++++++++++++++++++ .../UefiLessonsPkg/HIIStaticForm/HIIStaticForm.inf | 30 ++++++++++++ .../UefiLessonsPkg/HIIStaticForm/Strings.uni | 25 ++++++++++ 4 files changed, 146 insertions(+) create mode 100644 Lessons/Lesson_58/UefiLessonsPkg/HIIStaticForm/Form.vfr create mode 100644 Lessons/Lesson_58/UefiLessonsPkg/HIIStaticForm/HIIStaticForm.c create mode 100644 Lessons/Lesson_58/UefiLessonsPkg/HIIStaticForm/HIIStaticForm.inf create mode 100644 Lessons/Lesson_58/UefiLessonsPkg/HIIStaticForm/Strings.uni (limited to 'Lessons/Lesson_58/UefiLessonsPkg/HIIStaticForm') diff --git a/Lessons/Lesson_58/UefiLessonsPkg/HIIStaticForm/Form.vfr b/Lessons/Lesson_58/UefiLessonsPkg/HIIStaticForm/Form.vfr new file mode 100644 index 0000000..68a8ef0 --- /dev/null +++ b/Lessons/Lesson_58/UefiLessonsPkg/HIIStaticForm/Form.vfr @@ -0,0 +1,37 @@ +#define HIISTATICFORM_FORMSET_GUID {0x32783cc5, 0xe551, 0x4b61, {0xb7, 0xbd, 0x41, 0xba, 0x71, 0x7f, 0xba, 0x81}} + +formset + guid = HIISTATICFORM_FORMSET_GUID, + title = STRING_TOKEN(HIISTATICFORM_FORMSET_TITLE), + help = STRING_TOKEN(HIISTATICFORM_FORMSET_HELP), + form + formid = 1, + title = STRING_TOKEN(HIISTATICFORM_FORMID1_TITLE); + + subtitle text = STRING_TOKEN(SUBTITLE1); + subtitle text = STRING_TOKEN(SUBTITLE2); + + subtitle + text = STRING_TOKEN(SUBTITLE3), + + subtitle text = STRING_TOKEN(SUBTITLE4); + subtitle text = STRING_TOKEN(SUBTITLE5); + endsubtitle; + + subtitle text = STRING_TOKEN(STR_NULL); + subtitle text = STRING_TOKEN(SUBTITLE6); + + text + help = STRING_TOKEN(TEXT1_HELP), + text = STRING_TOKEN(TEXT1_TEXT); + + text + help = STRING_TOKEN(TEXT2_HELP), + text = STRING_TOKEN(TEXT2_TEXT); + + text + help = STRING_TOKEN(TEXT3_HELP), + text = STRING_TOKEN(TEXT3_TEXT), + text = STRING_TOKEN(TEXT3_TEXT_TWO); + endform; +endformset; diff --git a/Lessons/Lesson_58/UefiLessonsPkg/HIIStaticForm/HIIStaticForm.c b/Lessons/Lesson_58/UefiLessonsPkg/HIIStaticForm/HIIStaticForm.c new file mode 100644 index 0000000..45d992a --- /dev/null +++ b/Lessons/Lesson_58/UefiLessonsPkg/HIIStaticForm/HIIStaticForm.c @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2021, Konstantin Aladyshev + * + * SPDX-License-Identifier: MIT + */ + +#include +#include + +#include +#include + +extern UINT8 FormBin[]; + + +EFI_STATUS +EFIAPI +UefiMain ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_HII_HANDLE Handle = HiiAddPackages( + &gEfiCallerIdGuid, + NULL, + HIIStaticFormStrings, + FormBin, + NULL + ); + if (Handle == NULL) { + return EFI_OUT_OF_RESOURCES; + } + + EFI_STATUS Status; + EFI_FORM_BROWSER2_PROTOCOL* FormBrowser2; + Status = gBS->LocateProtocol(&gEfiFormBrowser2ProtocolGuid, NULL, (VOID**)&FormBrowser2); + if (EFI_ERROR(Status)) { + return Status; + } + + Status = FormBrowser2->SendForm ( + FormBrowser2, + &Handle, + 1, + NULL, + 0, + NULL, + NULL + ); + + HiiRemovePackages(Handle); + + return EFI_SUCCESS; +} diff --git a/Lessons/Lesson_58/UefiLessonsPkg/HIIStaticForm/HIIStaticForm.inf b/Lessons/Lesson_58/UefiLessonsPkg/HIIStaticForm/HIIStaticForm.inf new file mode 100644 index 0000000..9aca4a8 --- /dev/null +++ b/Lessons/Lesson_58/UefiLessonsPkg/HIIStaticForm/HIIStaticForm.inf @@ -0,0 +1,30 @@ +## +# Copyright (c) 2021, Konstantin Aladyshev +# +# SPDX-License-Identifier: MIT +## + +[Defines] + INF_VERSION = 1.25 + BASE_NAME = HIIStaticForm + FILE_GUID = 8f21815a-958f-4215-abff-bee9ae16a436 + MODULE_TYPE = UEFI_APPLICATION + VERSION_STRING = 1.0 + ENTRY_POINT = UefiMain + +[Sources] + HIIStaticForm.c + Strings.uni + Form.vfr + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + +[LibraryClasses] + UefiApplicationEntryPoint + UefiLib + HiiLib + +[Protocols] + gEfiFormBrowser2ProtocolGuid diff --git a/Lessons/Lesson_58/UefiLessonsPkg/HIIStaticForm/Strings.uni b/Lessons/Lesson_58/UefiLessonsPkg/HIIStaticForm/Strings.uni new file mode 100644 index 0000000..3bada64 --- /dev/null +++ b/Lessons/Lesson_58/UefiLessonsPkg/HIIStaticForm/Strings.uni @@ -0,0 +1,25 @@ +// +// Copyright (c) 2021, Konstantin Aladyshev +// +// SPDX-License-Identifier: MIT +// + +#langdef en-US "English" + +#string HIISTATICFORM_FORMSET_TITLE #language en-US "Static Formset" +#string HIISTATICFORM_FORMSET_HELP #language en-US "This is a static formset" +#string HIISTATICFORM_FORMID1_TITLE #language en-US "Static Form" +#string SUBTITLE1 #language en-US "Subtitle1" +#string SUBTITLE2 #language en-US "Subtitle2" +#string SUBTITLE3 #language en-US "Subtitle3" +#string SUBTITLE4 #language en-US "Subtitle4" +#string SUBTITLE5 #language en-US "Subtitle5" +#string SUBTITLE6 #language en-US "Subtitle6" +#string STR_NULL #language en-US "" +#string TEXT1_TEXT #language en-US "Text1 title" +#string TEXT1_HELP #language en-US "Text1 help" +#string TEXT2_TEXT #language en-US "Text2 title" +#string TEXT2_HELP #language en-US "Text2 help" +#string TEXT3_TEXT #language en-US "Text3 title" +#string TEXT3_TEXT_TWO #language en-US "Text3 value" +#string TEXT3_HELP #language en-US "Text3 help" -- cgit v1.2.3-18-g5258