summaryrefslogtreecommitdiffstats
path: root/ShellPkg/DynamicCommand/VariablePolicyDynamicCommand/VariablePolicyApp.c
blob: f3ab45de6ae83788723e9ea4d071121de4e93113 (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
55
56
57
58
59
/** @file
  Functionality specific for standalone UEFI application support.

  This application can provide detailed UEFI variable policy configuration
  information in the UEFI shell.

  Copyright (c) Microsoft Corporation.
  SPDX-License-Identifier: BSD-2-Clause-Patent

**/

#include "VariablePolicy.h"

#include <Library/BaseLib.h>
#include <Library/HiiLib.h>

extern EFI_HII_HANDLE  mVarPolicyShellCommandHiiHandle;

//
// String token ID of help message text.
// Shell supports finding the help message in the resource section of an
// application image if a .MAN file is not found. This global variable is added
// to make the build tool recognize that the help string is consumed by the user and
// then the build tool will add the string into the resource section. Thus the
// application can use '-?' option to show help message in Shell.
//
GLOBAL_REMOVE_IF_UNREFERENCED EFI_STRING_ID  mStringHelpTokenId = STRING_TOKEN (STR_GET_HELP_VAR_POLICY);

/**
  Entry of the UEFI variable policy application.

  @param ImageHandle            The image handle of the process.
  @param SystemTable            The EFI System Table pointer.

  @retval EFI_SUCCESS           The application successfully initialized.
  @retval EFI_ABORTED           The application failed to initialize.
  @retval Others                A different error occurred.

**/
EFI_STATUS
EFIAPI
VariablePolicyAppInitialize (
  IN EFI_HANDLE        ImageHandle,
  IN EFI_SYSTEM_TABLE  *SystemTable
  )
{
  EFI_STATUS  Status;

  mVarPolicyShellCommandHiiHandle = InitializeHiiPackage (ImageHandle);
  if (mVarPolicyShellCommandHiiHandle == NULL) {
    return EFI_ABORTED;
  }

  Status = (EFI_STATUS)RunVarPolicy (ImageHandle, SystemTable);

  HiiRemovePackages (mVarPolicyShellCommandHiiHandle);

  return Status;
}