2013-08-12 02:19:56 +00:00
|
|
|
/** @file
|
|
|
|
|
|
|
|
|
|
This library class defines a set of interfaces to customize Display module
|
|
|
|
|
|
2018-06-27 21:08:52 +08:00
|
|
|
Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>
|
2019-04-03 16:05:13 -07:00
|
|
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
2013-08-12 02:19:56 +00:00
|
|
|
|
|
|
|
|
**/
|
|
|
|
|
|
MdeModulePkg: Replace include guards with #pragma once
Replace traditional `#ifndef`/`#define`/`#endif` include guards with
`#pragma` once.
`#pragma once` is a widely supported preprocessor directive that
prevents header files from being included multiple times. It is
supported by all toolchains used to build edk2: GCC, Clang/LLVM, and
MSVC.
Compared to macro-based include guards, `#pragma once`:
- Eliminates the risk of macro name collisions or copy/paste errors
where two headers inadvertently use the same guard macro.
- Eliminate inconsistency in the way include guard macros are named
(e.g., some files use `__FILE_H__`, others use `FILE_H_`, etc.).
- Reduces boilerplate (three lines replaced by one).
- Avoids polluting the macro namespace with guard symbols.
- Can improve build times as the preprocessor can skip re-opening the
file entirely, rather than re-reading it to find the matching
`#endif` ("multiple-include optimization").
- Note that some compilers may already optimize traditional include
guards, by recognzining the idiomatic pattern.
This change is made acknowledging that overall portability of the
code will technically be reduced, as `#pragma once` is not part of the
C/C++ standards.
However, this is considered acceptable given:
1. edk2 already defines a subset of supported compilers in
BaseTools/Conf/tools_def.template, all of which have supported
`#pragma once` for over two decades.
2. There have been concerns raised to the project about inconsistent
include guard naming and potential macro collisions.
Approximate compiler support dates:
- MSVC: Supported since Visual C++ 4.2 (1996)
- GCC: Supported since 3.4 (2004)
(http://gnu.ist.utl.pt/software/gcc/gcc-3.4/changes.html)
- Clang (LLVM based): Since initial release in 2007
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
2026-02-03 13:48:28 -05:00
|
|
|
#pragma once
|
2013-08-12 02:19:56 +00:00
|
|
|
|
|
|
|
|
#include <PiDxe.h>
|
|
|
|
|
|
|
|
|
|
#include <Protocol/SimpleTextOut.h>
|
|
|
|
|
#include <Protocol/SimpleTextIn.h>
|
|
|
|
|
#include <Protocol/FormBrowser2.h>
|
|
|
|
|
#include <Protocol/FormBrowserEx2.h>
|
|
|
|
|
#include <Protocol/DisplayProtocol.h>
|
|
|
|
|
#include <Protocol/DevicePath.h>
|
|
|
|
|
#include <Protocol/UnicodeCollation.h>
|
|
|
|
|
#include <Protocol/HiiConfigAccess.h>
|
|
|
|
|
#include <Protocol/HiiConfigRouting.h>
|
|
|
|
|
#include <Protocol/HiiDatabase.h>
|
|
|
|
|
#include <Protocol/HiiString.h>
|
|
|
|
|
#include <Protocol/UserManager.h>
|
|
|
|
|
#include <Protocol/DevicePathFromText.h>
|
|
|
|
|
|
|
|
|
|
#include <Guid/MdeModuleHii.h>
|
|
|
|
|
#include <Guid/HiiPlatformSetupFormset.h>
|
|
|
|
|
#include <Guid/HiiFormMapMethodGuid.h>
|
|
|
|
|
|
|
|
|
|
#include <Library/PrintLib.h>
|
|
|
|
|
#include <Library/DebugLib.h>
|
|
|
|
|
#include <Library/BaseMemoryLib.h>
|
|
|
|
|
#include <Library/UefiRuntimeServicesTableLib.h>
|
|
|
|
|
#include <Library/UefiDriverEntryPoint.h>
|
|
|
|
|
#include <Library/UefiBootServicesTableLib.h>
|
|
|
|
|
#include <Library/BaseLib.h>
|
|
|
|
|
#include <Library/MemoryAllocationLib.h>
|
|
|
|
|
#include <Library/HiiLib.h>
|
|
|
|
|
#include <Library/PcdLib.h>
|
|
|
|
|
#include <Library/DevicePathLib.h>
|
|
|
|
|
#include <Library/CustomizedDisplayLib.h>
|
|
|
|
|
|
|
|
|
|
#include "Colors.h"
|
|
|
|
|
|
|
|
|
|
#define FORMSET_CLASS_PLATFORM_SETUP 0x0001
|
|
|
|
|
#define FORMSET_CLASS_FRONT_PAGE 0x0002
|
|
|
|
|
|
|
|
|
|
#define FRONT_PAGE_HEADER_HEIGHT 6
|
|
|
|
|
#define NONE_FRONT_PAGE_HEADER_HEIGHT 3
|
|
|
|
|
#define FOOTER_HEIGHT 4
|
|
|
|
|
#define STATUS_BAR_HEIGHT 1
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Screen definitions
|
|
|
|
|
//
|
|
|
|
|
#define BANNER_HEIGHT 6
|
|
|
|
|
#define BANNER_COLUMNS 3
|
|
|
|
|
#define BANNER_LEFT_COLUMN_INDENT 1
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Character definitions
|
|
|
|
|
//
|
|
|
|
|
#define UPPER_LOWER_CASE_OFFSET 0x20
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// This is the Input Error Message
|
|
|
|
|
//
|
|
|
|
|
#define INPUT_ERROR 1
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// This is the NV RAM update required Message
|
|
|
|
|
//
|
|
|
|
|
#define NV_UPDATE_REQUIRED 2
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
EFI_STRING_ID Banner[BANNER_HEIGHT][BANNER_COLUMNS];
|
|
|
|
|
} BANNER_DATA;
|
|
|
|
|
|
|
|
|
|
extern UINT16 gClassOfVfr; // Formset class information
|
|
|
|
|
extern BANNER_DATA *gBannerData;
|
|
|
|
|
extern EFI_SCREEN_DESCRIPTOR gScreenDimensions;
|
|
|
|
|
extern UINTN gFooterHeight;
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Browser Global Strings
|
|
|
|
|
//
|
|
|
|
|
extern CHAR16 *gEnterString;
|
|
|
|
|
extern CHAR16 *gEnterCommitString;
|
|
|
|
|
extern CHAR16 *gEnterEscapeString;
|
|
|
|
|
extern CHAR16 *gEscapeString;
|
|
|
|
|
extern CHAR16 *gMoveHighlight;
|
|
|
|
|
extern CHAR16 *gDecNumericInput;
|
|
|
|
|
extern CHAR16 *gHexNumericInput;
|
|
|
|
|
extern CHAR16 *gToggleCheckBox;
|
|
|
|
|
extern CHAR16 *gLibEmptyString;
|
|
|
|
|
extern CHAR16 *gAreYouSure;
|
|
|
|
|
extern CHAR16 *gYesResponse;
|
|
|
|
|
extern CHAR16 *gNoResponse;
|
|
|
|
|
extern CHAR16 *gPlusString;
|
|
|
|
|
extern CHAR16 *gMinusString;
|
|
|
|
|
extern CHAR16 *gAdjustNumber;
|
|
|
|
|
extern CHAR16 *gSaveChanges;
|
|
|
|
|
extern CHAR16 *gNvUpdateMessage;
|
|
|
|
|
extern CHAR16 *gInputErrorMessage;
|
2021-12-05 14:54:02 -08:00
|
|
|
|
2013-08-12 02:19:56 +00:00
|
|
|
/**
|
|
|
|
|
|
|
|
|
|
Print banner info for front page.
|
|
|
|
|
|
|
|
|
|
@param[in] FormData Form Data to be shown in Page
|
2018-06-27 21:08:52 +08:00
|
|
|
|
2013-08-12 02:19:56 +00:00
|
|
|
**/
|
|
|
|
|
VOID
|
2018-06-27 21:08:52 +08:00
|
|
|
PrintBannerInfo (
|
2013-08-12 02:19:56 +00:00
|
|
|
IN FORM_DISPLAY_ENGINE_FORM *FormData
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
/**
|
2013-08-12 04:49:48 +00:00
|
|
|
Print framework and form title for a page.
|
2013-08-12 02:19:56 +00:00
|
|
|
|
2013-08-12 04:49:48 +00:00
|
|
|
@param[in] FormData Form Data to be shown in Page
|
2013-08-12 02:19:56 +00:00
|
|
|
**/
|
|
|
|
|
VOID
|
|
|
|
|
PrintFramework (
|
|
|
|
|
IN FORM_DISPLAY_ENGINE_FORM *FormData
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
/**
|
2025-05-06 17:25:18 +08:00
|
|
|
Validate the input screen dimension info.
|
2013-08-12 02:19:56 +00:00
|
|
|
|
|
|
|
|
@param FormData The input form data info.
|
|
|
|
|
|
|
|
|
|
@return EFI_SUCCESS The input screen info is acceptable.
|
|
|
|
|
@return EFI_INVALID_PARAMETER The input screen info is not acceptable.
|
|
|
|
|
|
|
|
|
|
**/
|
2018-06-27 21:08:52 +08:00
|
|
|
EFI_STATUS
|
2025-05-06 17:25:18 +08:00
|
|
|
ScreenDimensionInfoValidate (
|
2013-08-12 02:19:56 +00:00
|
|
|
IN FORM_DISPLAY_ENGINE_FORM *FormData
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
Get the string based on the StringId and HII Package List Handle.
|
|
|
|
|
|
|
|
|
|
@param Token The String's ID.
|
|
|
|
|
@param HiiHandle The package list in the HII database to search for
|
|
|
|
|
the specified string.
|
|
|
|
|
|
|
|
|
|
@return The output string.
|
|
|
|
|
|
|
|
|
|
**/
|
|
|
|
|
CHAR16 *
|
|
|
|
|
LibGetToken (
|
|
|
|
|
IN EFI_STRING_ID Token,
|
|
|
|
|
IN EFI_HII_HANDLE HiiHandle
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
Count the storage space of a Unicode string.
|
|
|
|
|
|
|
|
|
|
This function handles the Unicode string with NARROW_CHAR
|
|
|
|
|
and WIDE_CHAR control characters. NARROW_HCAR and WIDE_CHAR
|
|
|
|
|
does not count in the resultant output. If a WIDE_CHAR is
|
|
|
|
|
hit, then 2 Unicode character will consume an output storage
|
|
|
|
|
space with size of CHAR16 till a NARROW_CHAR is hit.
|
|
|
|
|
|
|
|
|
|
If String is NULL, then ASSERT ().
|
|
|
|
|
|
|
|
|
|
@param String The input string to be counted.
|
|
|
|
|
|
|
|
|
|
@return Storage space for the input string.
|
|
|
|
|
|
|
|
|
|
**/
|
|
|
|
|
UINTN
|
|
|
|
|
LibGetStringWidth (
|
|
|
|
|
IN CHAR16 *String
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
Show all registered HotKey help strings on bottom Rows.
|
|
|
|
|
|
|
|
|
|
@param FormData The curent input form data info.
|
2013-09-27 12:19:51 +00:00
|
|
|
@param SetState Set HotKey or Clear HotKey
|
2013-08-12 02:19:56 +00:00
|
|
|
|
|
|
|
|
**/
|
|
|
|
|
VOID
|
|
|
|
|
PrintHotKeyHelpString (
|
2013-09-27 12:19:51 +00:00
|
|
|
IN FORM_DISPLAY_ENGINE_FORM *FormData,
|
|
|
|
|
IN BOOLEAN SetState
|
2013-08-12 02:19:56 +00:00
|
|
|
);
|
2018-06-27 21:08:52 +08:00
|
|
|
|
2013-08-12 02:19:56 +00:00
|
|
|
/**
|
|
|
|
|
Get step info from numeric opcode.
|
2018-06-27 21:08:52 +08:00
|
|
|
|
2013-08-12 02:19:56 +00:00
|
|
|
@param[in] OpCode The input numeric op code.
|
|
|
|
|
|
|
|
|
|
@return step info for this opcode.
|
|
|
|
|
**/
|
|
|
|
|
UINT64
|
|
|
|
|
LibGetFieldFromNum (
|
|
|
|
|
IN EFI_IFR_OP_HEADER *OpCode
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
Initialize the HII String Token to the correct values.
|
|
|
|
|
|
|
|
|
|
**/
|
|
|
|
|
VOID
|
|
|
|
|
InitializeLibStrings (
|
|
|
|
|
VOID
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
Free the HII String.
|
|
|
|
|
|
|
|
|
|
**/
|
|
|
|
|
VOID
|
|
|
|
|
FreeLibStrings (
|
|
|
|
|
VOID
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
Wait for a key to be pressed by user.
|
|
|
|
|
|
|
|
|
|
@param Key The key which is pressed by user.
|
|
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS The function always completed successfully.
|
|
|
|
|
|
|
|
|
|
**/
|
|
|
|
|
EFI_STATUS
|
|
|
|
|
WaitForKeyStroke (
|
|
|
|
|
OUT EFI_INPUT_KEY *Key
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
Set Buffer to Value for Size bytes.
|
|
|
|
|
|
|
|
|
|
@param Buffer Memory to set.
|
|
|
|
|
@param Size Number of bytes to set
|
|
|
|
|
@param Value Value of the set operation.
|
|
|
|
|
|
|
|
|
|
**/
|
|
|
|
|
VOID
|
|
|
|
|
LibSetUnicodeMem (
|
|
|
|
|
IN VOID *Buffer,
|
|
|
|
|
IN UINTN Size,
|
|
|
|
|
IN CHAR16 Value
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
Prints a formatted unicode string to the default console, at
|
|
|
|
|
the supplied cursor position.
|
|
|
|
|
|
|
|
|
|
@param Width Width of String to be printed.
|
|
|
|
|
@param Column The cursor position to print the string at.
|
|
|
|
|
@param Row The cursor position to print the string at.
|
|
|
|
|
@param Fmt Format string.
|
|
|
|
|
@param ... Variable argument list for format string.
|
|
|
|
|
|
|
|
|
|
@return Length of string printed to the console
|
|
|
|
|
|
|
|
|
|
**/
|
|
|
|
|
UINTN
|
|
|
|
|
EFIAPI
|
|
|
|
|
PrintAt (
|
|
|
|
|
IN UINTN Width,
|
|
|
|
|
IN UINTN Column,
|
|
|
|
|
IN UINTN Row,
|
|
|
|
|
IN CHAR16 *Fmt,
|
|
|
|
|
...
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
Process some op codes which is out side of current form.
|
2018-06-27 21:08:52 +08:00
|
|
|
|
2013-08-12 02:19:56 +00:00
|
|
|
@param FormData Pointer to the form data.
|
|
|
|
|
|
|
|
|
|
**/
|
|
|
|
|
VOID
|
|
|
|
|
ProcessExternedOpcode (
|
|
|
|
|
IN FORM_DISPLAY_ENGINE_FORM *FormData
|
|
|
|
|
);
|