aboutsummaryrefslogtreecommitdiffstats
path: root/UefiLessonsPkg/HIIStaticForm/HIIStaticForm.c
blob: 45d992a62c7c362a8cfb86f9f297d6c61fa30e7b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
 * Copyright (c) 2021, Konstantin Aladyshev <aladyshev22@gmail.com>
 *
 * SPDX-License-Identifier: MIT
 */

#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiLib.h>

#include <Library/HiiLib.h>
#include <Protocol/FormBrowser2.h>

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