From d03724c8fc726c9add02ed19984d66077edd56ef Mon Sep 17 00:00:00 2001 From: Konstantin Aladyshev Date: Wed, 10 Nov 2021 17:30:32 +0300 Subject: Add lesson 57 Signed-off-by: Konstantin Aladyshev --- UefiLessonsPkg/HIISimpleForm/Form.vfr | 11 ++++++ UefiLessonsPkg/HIISimpleForm/HIISimpleForm.c | 53 ++++++++++++++++++++++++++ UefiLessonsPkg/HIISimpleForm/HIISimpleForm.inf | 30 +++++++++++++++ UefiLessonsPkg/HIISimpleForm/Strings.uni | 11 ++++++ UefiLessonsPkg/UefiLessonsPkg.dsc | 1 + 5 files changed, 106 insertions(+) create mode 100644 UefiLessonsPkg/HIISimpleForm/Form.vfr create mode 100644 UefiLessonsPkg/HIISimpleForm/HIISimpleForm.c create mode 100644 UefiLessonsPkg/HIISimpleForm/HIISimpleForm.inf create mode 100644 UefiLessonsPkg/HIISimpleForm/Strings.uni (limited to 'UefiLessonsPkg') diff --git a/UefiLessonsPkg/HIISimpleForm/Form.vfr b/UefiLessonsPkg/HIISimpleForm/Form.vfr new file mode 100644 index 0000000..0671b15 --- /dev/null +++ b/UefiLessonsPkg/HIISimpleForm/Form.vfr @@ -0,0 +1,11 @@ +#define HIISIMPLEFORM_FORMSET_GUID {0xef2acc91, 0x7b50, 0x4ab9, {0xab, 0x67, 0x2b, 0x4, 0xf8, 0xbc, 0x13, 0x5e}} + +formset + guid = HIISIMPLEFORM_FORMSET_GUID, + title = STRING_TOKEN(HIISIMPLEFORM_FORMSET_TITLE), + help = STRING_TOKEN(HIISIMPLEFORM_FORMSET_HELP), + form + formid = 1, + title = STRING_TOKEN(HIISIMPLEFORM_FORMID1_TITLE); + endform; +endformset; diff --git a/UefiLessonsPkg/HIISimpleForm/HIISimpleForm.c b/UefiLessonsPkg/HIISimpleForm/HIISimpleForm.c new file mode 100644 index 0000000..3aa401e --- /dev/null +++ b/UefiLessonsPkg/HIISimpleForm/HIISimpleForm.c @@ -0,0 +1,53 @@ +/* + * 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, + HIISimpleFormStrings, + 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/UefiLessonsPkg/HIISimpleForm/HIISimpleForm.inf b/UefiLessonsPkg/HIISimpleForm/HIISimpleForm.inf new file mode 100644 index 0000000..4def985 --- /dev/null +++ b/UefiLessonsPkg/HIISimpleForm/HIISimpleForm.inf @@ -0,0 +1,30 @@ +## +# Copyright (c) 2021, Konstantin Aladyshev +# +# SPDX-License-Identifier: MIT +## + +[Defines] + INF_VERSION = 1.25 + BASE_NAME = HIISimpleForm + FILE_GUID = df2f1465-2bf1-492c-af6c-232ac40bdf82 + MODULE_TYPE = UEFI_APPLICATION + VERSION_STRING = 1.0 + ENTRY_POINT = UefiMain + +[Sources] + HIISimpleForm.c + Strings.uni + Form.vfr + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + +[LibraryClasses] + UefiApplicationEntryPoint + UefiLib + HiiLib + +[Protocols] + gEfiFormBrowser2ProtocolGuid diff --git a/UefiLessonsPkg/HIISimpleForm/Strings.uni b/UefiLessonsPkg/HIISimpleForm/Strings.uni new file mode 100644 index 0000000..e54db41 --- /dev/null +++ b/UefiLessonsPkg/HIISimpleForm/Strings.uni @@ -0,0 +1,11 @@ +// +// Copyright (c) 2021, Konstantin Aladyshev +// +// SPDX-License-Identifier: MIT +// + +#langdef en-US "English" + +#string HIISIMPLEFORM_FORMSET_TITLE #language en-US "Simple Formset" +#string HIISIMPLEFORM_FORMSET_HELP #language en-US "This is a very simple formset" +#string HIISIMPLEFORM_FORMID1_TITLE #language en-US "Simple Form" diff --git a/UefiLessonsPkg/UefiLessonsPkg.dsc b/UefiLessonsPkg/UefiLessonsPkg.dsc index 85ea19a..aec7768 100644 --- a/UefiLessonsPkg/UefiLessonsPkg.dsc +++ b/UefiLessonsPkg/UefiLessonsPkg.dsc @@ -72,6 +72,7 @@ UefiLessonsPkg/HIIAddRussianFont/HIIAddRussianFont.inf UefiLessonsPkg/HIIAddLocalization/HIIAddLocalization.inf UefiLessonsPkg/AddNewLanguage/AddNewLanguage.inf + UefiLessonsPkg/HIISimpleForm/HIISimpleForm.inf [PcdsFixedAtBuild] gUefiLessonsPkgTokenSpaceGuid.PcdMyVar32_2|44 -- cgit v1.2.3-18-g5258