1 /** @file
2 
3   This library class defines a set of interfaces to customize Display module
4 
5 Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>
6 This program and the accompanying materials are licensed and made available under
7 the terms and conditions of the BSD License that accompanies this distribution.
8 The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php.
10 
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT 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 
89 typedef struct {
90   EFI_STRING_ID  Banner[BANNER_HEIGHT][BANNER_COLUMNS];
91 } BANNER_DATA;
92 
93 extern  UINT16                        gClassOfVfr;                 // Formset class information
94 extern  BANNER_DATA                   *gBannerData;
95 extern  EFI_SCREEN_DESCRIPTOR         gScreenDimensions;
96 extern  UINTN                         gFooterHeight;
97 
98 //
99 // Browser Global Strings
100 //
101 extern CHAR16            *gEnterString;
102 extern CHAR16            *gEnterCommitString;
103 extern CHAR16            *gEnterEscapeString;
104 extern CHAR16            *gEscapeString;
105 extern CHAR16            *gMoveHighlight;
106 extern CHAR16            *gDecNumericInput;
107 extern CHAR16            *gHexNumericInput;
108 extern CHAR16            *gToggleCheckBox;
109 extern CHAR16            *gLibEmptyString;
110 extern CHAR16            *gAreYouSure;
111 extern CHAR16            *gYesResponse;
112 extern CHAR16            *gNoResponse;
113 extern CHAR16            *gPlusString;
114 extern CHAR16            *gMinusString;
115 extern CHAR16            *gAdjustNumber;
116 extern CHAR16            *gSaveChanges;
117 extern CHAR16            *gNvUpdateMessage;
118 extern 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 **/
126 VOID
127 PrintBannerInfo (
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 **/
136 VOID
137 PrintFramework (
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 **/
150 EFI_STATUS
151 ScreenDiemensionInfoValidate (
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 **/
165 CHAR16 *
166 LibGetToken (
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 **/
187 UINTN
188 LibGetStringWidth (
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 **/
199 VOID
200 PrintHotKeyHelpString (
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 **/
212 UINT64
213 LibGetFieldFromNum (
214   IN  EFI_IFR_OP_HEADER     *OpCode
215   );
216 
217 /**
218   Initialize the HII String Token to the correct values.
219 
220 **/
221 VOID
222 InitializeLibStrings (
223   VOID
224   );
225 
226 /**
227   Free the HII String.
228 
229 **/
230 VOID
231 FreeLibStrings (
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 **/
243 EFI_STATUS
244 WaitForKeyStroke (
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 **/
256 VOID
257 LibSetUnicodeMem (
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 **/
276 UINTN
277 EFIAPI
278 PrintAt (
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 **/
292 VOID
293 ProcessExternedOpcode (
294   IN FORM_DISPLAY_ENGINE_FORM       *FormData
295   );
296 
297 #endif
298