blob: 7342b508b06e39b6c2598b5cc37944ce494dfc8c [file] [log] [blame]
Vishal Bhoj82c80712015-12-15 21:13:33 +05301/** @file
2
3 This library class defines a set of interfaces to customize Display module
4
5Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>
6This program and the accompanying materials are licensed and made available under
7the terms and conditions of the BSD License that accompanies this distribution.
8The full text of the license may be found at
9http://opensource.org/licenses/bsd-license.php.
10
11THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13
14**/
15
16#ifndef __CUSTOMIZED_DISPLAY_LIB_INTERNAL_H__
17#define __CUSTOMIZED_DISPLAY_LIB_INTERNAL_H__
18
19
20
21#include <PiDxe.h>
22
23#include <Protocol/SimpleTextOut.h>
24#include <Protocol/SimpleTextIn.h>
25#include <Protocol/FormBrowser2.h>
26#include <Protocol/FormBrowserEx2.h>
27#include <Protocol/DisplayProtocol.h>
28#include <Protocol/DevicePath.h>
29#include <Protocol/UnicodeCollation.h>
30#include <Protocol/HiiConfigAccess.h>
31#include <Protocol/HiiConfigRouting.h>
32#include <Protocol/HiiDatabase.h>
33#include <Protocol/HiiString.h>
34#include <Protocol/UserManager.h>
35#include <Protocol/DevicePathFromText.h>
36
37#include <Guid/MdeModuleHii.h>
38#include <Guid/HiiPlatformSetupFormset.h>
39#include <Guid/HiiFormMapMethodGuid.h>
40
41#include <Library/PrintLib.h>
42#include <Library/DebugLib.h>
43#include <Library/BaseMemoryLib.h>
44#include <Library/UefiRuntimeServicesTableLib.h>
45#include <Library/UefiDriverEntryPoint.h>
46#include <Library/UefiBootServicesTableLib.h>
47#include <Library/BaseLib.h>
48#include <Library/MemoryAllocationLib.h>
49#include <Library/HiiLib.h>
50#include <Library/PcdLib.h>
51#include <Library/DevicePathLib.h>
52#include <Library/CustomizedDisplayLib.h>
53
54#include "Colors.h"
55
56
57
58#define FORMSET_CLASS_PLATFORM_SETUP 0x0001
59#define FORMSET_CLASS_FRONT_PAGE 0x0002
60
61
62#define FRONT_PAGE_HEADER_HEIGHT 6
63#define NONE_FRONT_PAGE_HEADER_HEIGHT 3
64#define FOOTER_HEIGHT 4
65#define STATUS_BAR_HEIGHT 1
66
67//
68// Screen definitions
69//
70#define BANNER_HEIGHT 6
71#define BANNER_COLUMNS 3
72#define BANNER_LEFT_COLUMN_INDENT 1
73
74//
75// Character definitions
76//
77#define UPPER_LOWER_CASE_OFFSET 0x20
78
79//
80// This is the Input Error Message
81//
82#define INPUT_ERROR 1
83
84//
85// This is the NV RAM update required Message
86//
87#define NV_UPDATE_REQUIRED 2
88
89typedef struct {
90 EFI_STRING_ID Banner[BANNER_HEIGHT][BANNER_COLUMNS];
91} BANNER_DATA;
92
93extern UINT16 gClassOfVfr; // Formset class information
94extern BANNER_DATA *gBannerData;
95extern EFI_SCREEN_DESCRIPTOR gScreenDimensions;
96extern UINTN gFooterHeight;
97
98//
99// Browser Global Strings
100//
101extern CHAR16 *gEnterString;
102extern CHAR16 *gEnterCommitString;
103extern CHAR16 *gEnterEscapeString;
104extern CHAR16 *gEscapeString;
105extern CHAR16 *gMoveHighlight;
106extern CHAR16 *gDecNumericInput;
107extern CHAR16 *gHexNumericInput;
108extern CHAR16 *gToggleCheckBox;
109extern CHAR16 *gLibEmptyString;
110extern CHAR16 *gAreYouSure;
111extern CHAR16 *gYesResponse;
112extern CHAR16 *gNoResponse;
113extern CHAR16 *gPlusString;
114extern CHAR16 *gMinusString;
115extern CHAR16 *gAdjustNumber;
116extern CHAR16 *gSaveChanges;
117extern CHAR16 *gNvUpdateMessage;
118extern CHAR16 *gInputErrorMessage;
119/**
120
121 Print banner info for front page.
122
123 @param[in] FormData Form Data to be shown in Page
124
125**/
126VOID
127PrintBannerInfo (
128 IN FORM_DISPLAY_ENGINE_FORM *FormData
129 );
130
131/**
132 Print framework and form title for a page.
133
134 @param[in] FormData Form Data to be shown in Page
135**/
136VOID
137PrintFramework (
138 IN FORM_DISPLAY_ENGINE_FORM *FormData
139 );
140
141/**
142 Validate the input screen diemenstion info.
143
144 @param FormData The input form data info.
145
146 @return EFI_SUCCESS The input screen info is acceptable.
147 @return EFI_INVALID_PARAMETER The input screen info is not acceptable.
148
149**/
150EFI_STATUS
151ScreenDiemensionInfoValidate (
152 IN FORM_DISPLAY_ENGINE_FORM *FormData
153 );
154
155/**
156 Get the string based on the StringId and HII Package List Handle.
157
158 @param Token The String's ID.
159 @param HiiHandle The package list in the HII database to search for
160 the specified string.
161
162 @return The output string.
163
164**/
165CHAR16 *
166LibGetToken (
167 IN EFI_STRING_ID Token,
168 IN EFI_HII_HANDLE HiiHandle
169 );
170
171/**
172 Count the storage space of a Unicode string.
173
174 This function handles the Unicode string with NARROW_CHAR
175 and WIDE_CHAR control characters. NARROW_HCAR and WIDE_CHAR
176 does not count in the resultant output. If a WIDE_CHAR is
177 hit, then 2 Unicode character will consume an output storage
178 space with size of CHAR16 till a NARROW_CHAR is hit.
179
180 If String is NULL, then ASSERT ().
181
182 @param String The input string to be counted.
183
184 @return Storage space for the input string.
185
186**/
187UINTN
188LibGetStringWidth (
189 IN CHAR16 *String
190 );
191
192/**
193 Show all registered HotKey help strings on bottom Rows.
194
195 @param FormData The curent input form data info.
196 @param SetState Set HotKey or Clear HotKey
197
198**/
199VOID
200PrintHotKeyHelpString (
201 IN FORM_DISPLAY_ENGINE_FORM *FormData,
202 IN BOOLEAN SetState
203 );
204
205/**
206 Get step info from numeric opcode.
207
208 @param[in] OpCode The input numeric op code.
209
210 @return step info for this opcode.
211**/
212UINT64
213LibGetFieldFromNum (
214 IN EFI_IFR_OP_HEADER *OpCode
215 );
216
217/**
218 Initialize the HII String Token to the correct values.
219
220**/
221VOID
222InitializeLibStrings (
223 VOID
224 );
225
226/**
227 Free the HII String.
228
229**/
230VOID
231FreeLibStrings (
232 VOID
233 );
234
235/**
236 Wait for a key to be pressed by user.
237
238 @param Key The key which is pressed by user.
239
240 @retval EFI_SUCCESS The function always completed successfully.
241
242**/
243EFI_STATUS
244WaitForKeyStroke (
245 OUT EFI_INPUT_KEY *Key
246 );
247
248/**
249 Set Buffer to Value for Size bytes.
250
251 @param Buffer Memory to set.
252 @param Size Number of bytes to set
253 @param Value Value of the set operation.
254
255**/
256VOID
257LibSetUnicodeMem (
258 IN VOID *Buffer,
259 IN UINTN Size,
260 IN CHAR16 Value
261 );
262
263/**
264 Prints a formatted unicode string to the default console, at
265 the supplied cursor position.
266
267 @param Width Width of String to be printed.
268 @param Column The cursor position to print the string at.
269 @param Row The cursor position to print the string at.
270 @param Fmt Format string.
271 @param ... Variable argument list for format string.
272
273 @return Length of string printed to the console
274
275**/
276UINTN
277EFIAPI
278PrintAt (
279 IN UINTN Width,
280 IN UINTN Column,
281 IN UINTN Row,
282 IN CHAR16 *Fmt,
283 ...
284 );
285
286/**
287 Process some op codes which is out side of current form.
288
289 @param FormData Pointer to the form data.
290
291**/
292VOID
293ProcessExternedOpcode (
294 IN FORM_DISPLAY_ENGINE_FORM *FormData
295 );
296
297#endif