Port DriverSample.inf, HiiDatabase.inf and SetupBrowser.inf
[mirror_edk2.git] / IntelFrameworkModulePkg / Universal / SetupBrowserDxe / Setup.h
1 /*++
2
3 Copyright (c) 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
8
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12 Module Name:
13
14 Setup.h
15
16 Abstract:
17
18
19 Revision History
20
21 --*/
22
23 #ifndef _SETUP_H
24 #define _SETUP_H
25
26 //
27 // Include common header file for this module.
28 //
29 #include "CommonHeader.h"
30
31 //
32 // This is the generated header file which includes whatever needs to be exported (strings + IFR)
33 //
34 extern UINT8 SetupBrowserStrings[];
35
36 //
37 // Screen definitions
38 //
39 #define BANNER_HEIGHT 4
40 #define BANNER_COLUMNS 3
41
42 #define FRONT_PAGE_HEADER_HEIGHT 4
43 #define NONE_FRONT_PAGE_HEADER_HEIGHT 3
44 #define LEFT_SKIPPED_COLUMNS 4
45 #define FOOTER_HEIGHT 4
46 #define STATUS_BAR_HEIGHT 1
47 #define SCROLL_ARROW_HEIGHT 1
48 #define POPUP_PAD_SPACE_COUNT 5
49 #define POPUP_FRAME_WIDTH 2
50
51
52 #define EFI_SETUP_APPLICATION_SUBCLASS 0x00
53 #define EFI_GENERAL_APPLICATION_SUBCLASS 0x01
54 #define EFI_FRONT_PAGE_SUBCLASS 0x02
55 #define EFI_SINGLE_USE_SUBCLASS 0x03 // Used to display a single entity and then exit
56 //
57 // Definition for function key setting
58 //
59 #define NONE_FUNCTION_KEY_SETTING 0
60 #define DEFAULT_FUNCTION_KEY_SETTING (FUNCTION_ONE | FUNCTION_TWO | FUNCTION_NINE | FUNCTION_TEN)
61
62 #define FUNCTION_ONE (1 << 0)
63 #define FUNCTION_TWO (1 << 1)
64 #define FUNCTION_NINE (1 << 2)
65 #define FUNCTION_TEN (1 << 3)
66
67 typedef struct {
68 EFI_GUID FormSetGuid;
69 UINTN KeySetting;
70 } FUNCTIION_KEY_SETTING;
71
72 //
73 // Character definitions
74 //
75 #define CHAR_SPACE 0x0020
76 #define UPPER_LOWER_CASE_OFFSET 0x20
77
78 //
79 // Time definitions
80 //
81 #define ONE_SECOND 10000000
82
83 //
84 // Display definitions
85 //
86 #define LEFT_HYPER_DELIMITER L'<'
87 #define RIGHT_HYPER_DELIMITER L'>'
88
89 #define LEFT_ONEOF_DELIMITER L'<'
90 #define RIGHT_ONEOF_DELIMITER L'>'
91
92 #define LEFT_NUMERIC_DELIMITER L'['
93 #define RIGHT_NUMERIC_DELIMITER L']'
94
95 #define LEFT_CHECKBOX_DELIMITER L"["
96 #define RIGHT_CHECKBOX_DELIMITER L"]"
97
98 #define CHECK_ON L"X"
99 #define CHECK_OFF L" "
100
101 #define TIME_SEPARATOR L':'
102 #define DATE_SEPARATOR L'/'
103
104 #define YES_ANSWER L'Y'
105 #define NO_ANSWER L'N'
106
107 //
108 // Up to how many lines does the ordered list display
109 //
110 #define ORDERED_LIST_SIZE 4
111
112 //
113 // This is the Input Error Message
114 //
115 #define INPUT_ERROR 1
116
117 //
118 // This is the NV RAM update required Message
119 //
120 #define NV_UPDATE_REQUIRED 2
121
122 //
123 // Refresh the Status Bar with flags
124 //
125 #define REFRESH_STATUS_BAR 0xff
126
127 //
128 // This width is basically the sum of the prompt and option widths
129 //
130 #define QUESTION_BLOCK_WIDTH 50
131
132 //
133 // Width of the Language Description (Using ISO-639-2 3 ASCII letter standard)
134 //
135 #define LANG_DESC_WIDTH 3
136
137 //
138 // Maximum Number of Binaries we can see
139 //
140 #define MAX_BINARIES 255
141
142 //
143 // Invalid Handle
144 //
145 #define EFI_HII_INVALID_HANDLE 0xFFFF
146
147 //
148 // Invalid Offset Value
149 //
150 #define INVALID_OFFSET_VALUE 0xFFFF
151
152 struct StringPart {
153 struct StringPart *Next;
154 CHAR8 String[QUESTION_BLOCK_WIDTH + 2];
155 };
156
157 //
158 // The tag definition defines the data associated with a tag (an operation
159 // in the IFR lingo). The tag is thus a modified union of all the data
160 // required for tags. The user should be careful to only rely upon information
161 // relevant to that tag as the contents of other fields is undefined.
162 //
163 // The intent here is for this to be all of the data associated with a particular tag.
164 // Some of this data is extracted from the IFR and left alone. Other data will be derived
165 // when the page is selected (since that's the first time we really know what language the
166 // page is to be displayed in) and still other data will vary based on the selection.
167 // If you'd like to consider alternatives, let me know. This structure has grown somewhat organically.
168 // It gets a new item stuffed in it when a new item is needed. When I finally decided I needed the
169 // StringPart structure, items got added here, for example.
170 //
171 typedef struct {
172 UINT8 Operand; // The operand (first byte) of the variable length tag.
173 EFI_GUID GuidValue; // Primarily for FormSet data
174 EFI_PHYSICAL_ADDRESS CallbackHandle;
175 UINT16 Class;
176 UINT16 SubClass;
177 UINT16 NumberOfLines; // The number of lines the tag takes up on the page. Adjusted when we display the page as it can change from language to language.
178 UINT16 PageLine;
179 UINT16 PageColumn;
180 UINT16 OptionWidth; // The option can be wider than the column usually associated with options. This is the width on the last option line
181 STRING_REF Text; // Used for title, subtitle, prompt, etc. This is the string token associated with the string. This token is language independent.
182 STRING_REF TextTwo; // Used for title, subtitle, prompt, etc. This is the string token associated with the string. This token is language independent.
183 STRING_REF Help; // Null means no help Same as above but for languages.
184 UINT16 Consistency; // Do we need to check this opcode against consistency? If > 0, yes.
185 UINT16 Id;
186 UINT16 Id2; // The questions (mainly) have identifiers associated with them. These are filled in from the IFR tags and used by e.g. the RPN calculations. (com1 is set to, versus com2 is set to)
187 //
188 // These are the three values that are created to determine where in the variable the data is stored. This should, in general,
189 // be allocated by the build tool. The one major issue is, once storage is allocated for something, it can't be reallocated or we will get a mess.
190 //
191 UINT16 StorageStart;
192 //
193 // These are the three values that are created to determine where in the variable the data is stored. This should, in general,
194 // be allocated by the build tool. The one major issue is, once storage is allocated for something, it can't be reallocated or we will get a mess.
195 //
196 UINT8 StorageWidth;
197 //
198 // These are the three values that are created to determine where in the variable the data is stored. This should, in general,
199 // be allocated by the build tool. The one major issue is, once storage is allocated for something, it can't be reallocated or we will get a mess.
200 //
201 UINT16 Value;
202 //
203 // (Default or current)
204 //
205 UINT8 Flags;
206 UINT16 Key;
207 //
208 // Used to preserve a value during late consistency checking
209 //
210 UINT16 OldValue;
211 UINT16 Minimum;
212 UINT16 Maximum;
213 UINT16 Step;
214 UINT16 Default;
215 UINT16 NvDataSize;
216 UINT16 ConsistencyId;
217 BOOLEAN GrayOut;
218 BOOLEAN Suppress;
219 UINT16 Encoding; // Data from the tags. The first three are used by the numeric input. Encoding is used by the password stuff (a placeholder today - may go away).
220 UINT16 *IntList; // List of the values possible for a list question
221 //
222 // The string is obtained from the string list and formatted into lines and the lines are held in this linked list.
223 // If we have more than a screen's worth of items, we will end up with cases where we have to display the last couple
224 // lines of a tag's string above the currently selected one, or, display a few lines of a tag at the bottom of a screen.
225 //
226 struct StringPart *StringList;
227 BOOLEAN ResetRequired; // Primarily used to determine if a reset is required by changing this op-code.
228 UINT16 VariableNumber; // Used to define which variable the StorageStart will be pertinent for (0-based) For single variable VFR this will always be 0.
229 //
230 // Used to define which variable the StorageStart will be pertinent for (0-based) This is used for boolean check of ID versus ID
231 // so that a user can compare the value of one variable.field content versus another variable.field content.
232 //
233 UINT16 VariableNumber2;
234 } EFI_TAG;
235
236 #define EFI_FORM_DATA_SIGNATURE EFI_SIGNATURE_32 ('F', 'o', 'r', 'm')
237
238 typedef struct {
239 UINTN Signature;
240
241 EFI_HII_PROTOCOL *Hii;
242 EFI_FORM_BROWSER_PROTOCOL FormConfig;
243 } EFI_FORM_CONFIGURATION_DATA;
244
245 #define EFI_FORM_DATA_FROM_THIS(a) CR (a, EFI_FORM_CONFIGURATION_DATA, FormConfig, EFI_FORM_DATA_SIGNATURE)
246
247 typedef struct _EFI_VARIABLE_DEFINITION {
248 CHAR8 *NvRamMap;
249 CHAR8 *FakeNvRamMap; // This is where the storage for NULL devices go (e.g. RTC)
250 EFI_GUID Guid;
251 UINT16 VariableId;
252 UINT16 VariableSize;
253 UINT16 VariableFakeSize; // For dynamically created and NULL device options, this is the latest size
254 CHAR16 *VariableName;
255 struct _EFI_VARIABLE_DEFINITION *Next;
256 struct _EFI_VARIABLE_DEFINITION *Previous;
257 } EFI_VARIABLE_DEFINITION;
258
259 typedef struct {
260 UINT32 Length; // Length in bytes between beginning of struc and end of Strings
261 CHAR8 LanguageCode[4]; // ISO-639-2 language code with a null-terminator
262 RELOFST PrintableLanguageName; // Translated name of the Language, "English"/"Espanol" etc
263 UINT32 Attributes; // If on, the language is intended to be printed right to left. The default (off) is to print left to right.
264 RELOFST StringsPointers[1]; // Pointing to string offset from beginning of String Binary
265 EFI_STRING Strings[1]; // Array of String Entries. Note the number of entries for Strings and StringsPointers will be the same
266 } EFI_LANGUAGE_SET;
267
268 //
269 // This encapsulates all the pointers associated with found IFR binaries
270 //
271 typedef struct _EFI_IFR_BINARY {
272 struct _EFI_IFR_BINARY *Next;
273 VOID *IfrPackage; // Handy for use in freeing the data later since this is the header of the buffer
274 VOID *FormBinary;
275 EFI_HII_HANDLE Handle;
276 STRING_REF TitleToken;
277 BOOLEAN UnRegisterOnExit;
278 } EFI_IFR_BINARY;
279
280 //
281 // This encapsulates all the questions (tags) for a particular Form Set
282 //
283 typedef struct _EFI_FORM_TAGS {
284 struct _EFI_FORM_TAGS *Next;
285 EFI_TAG *Tags;
286 } EFI_FORM_TAGS;
287
288 //
289 // This is the database of all inconsistency data. Each op-code associated
290 // with inconsistency will be tracked here. This optimizes the search requirement
291 // since we will back mark the main tag structure with the op-codes that have reference
292 // to inconsistency data. This way when parsing the main tag structure and encountering
293 // the inconsistency mark - we can search this database to know what the inconsistency
294 // parameters are for that entry.
295 //
296 typedef struct _EFI_INCONSISTENCY_DATA {
297 struct _EFI_INCONSISTENCY_DATA *Next;
298 struct _EFI_INCONSISTENCY_DATA *Previous;
299 UINT8 Operand;
300 STRING_REF Popup;
301 UINT16 QuestionId1;
302 UINT16 QuestionId2;
303 UINT16 Value;
304 UINT16 ListLength;
305 UINT16 ConsistencyId;
306 UINT16 *ValueList;
307 UINT16 VariableNumber;
308 UINT16 VariableNumber2;
309 UINT8 Width;
310 } EFI_INCONSISTENCY_DATA;
311
312 //
313 // Encapsulating all found Tag information from all sources
314 // Each encapsulation also contains the NvRamMap buffer and the Size of the NV store
315 //
316 typedef struct _EFI_FILE_FORM_TAGS {
317 struct _EFI_FILE_FORM_TAGS *NextFile;
318 EFI_INCONSISTENCY_DATA *InconsistentTags;
319 EFI_VARIABLE_DEFINITION *VariableDefinitions;
320 EFI_FORM_TAGS FormTags;
321 } EFI_FILE_FORM_TAGS;
322
323 typedef struct {
324 STRING_REF Banner[BANNER_HEIGHT][BANNER_COLUMNS];
325 } BANNER_DATA;
326
327 //
328 // Head of the Binary structures
329 //
330 EFI_IFR_BINARY *gBinaryDataHead;
331
332 //
333 // The IFR binary that the user chose to run
334 //
335 UINTN gActiveIfr;
336
337 EFI_HII_PROTOCOL *Hii;
338
339 VOID *CachedNVEntry;
340 BANNER_DATA *BannerData;
341 EFI_HII_HANDLE FrontPageHandle;
342 STRING_REF FrontPageTimeOutTitle;
343 INT16 FrontPageTimeOutValue;
344 UINTN gClassOfVfr;
345 UINTN gFunctionKeySetting;
346 BOOLEAN gResetRequired;
347 BOOLEAN gExitRequired;
348 BOOLEAN gSaveRequired;
349 BOOLEAN gNvUpdateRequired;
350 UINT16 gConsistencyId;
351 UINTN gPriorMenuEntry;
352 EFI_HII_HANDLE gHiiHandle;
353 BOOLEAN gFirstIn;
354 VOID *gPreviousValue;
355 UINT16 gDirection;
356 EFI_SCREEN_DESCRIPTOR gScreenDimensions;
357 BOOLEAN gUpArrow;
358 BOOLEAN gDownArrow;
359 BOOLEAN gTimeOnScreen;
360 BOOLEAN gDateOnScreen;
361
362 //
363 // Browser Global Strings
364 //
365 CHAR16 *gFunctionOneString;
366 CHAR16 *gFunctionTwoString;
367 CHAR16 *gFunctionNineString;
368 CHAR16 *gFunctionTenString;
369 CHAR16 *gEnterString;
370 CHAR16 *gEnterCommitString;
371 CHAR16 *gEscapeString;
372 CHAR16 *gMoveHighlight;
373 CHAR16 *gMakeSelection;
374 CHAR16 *gNumericInput;
375 CHAR16 *gToggleCheckBox;
376 CHAR16 *gPromptForPassword;
377 CHAR16 *gPromptForNewPassword;
378 CHAR16 *gConfirmPassword;
379 CHAR16 *gConfirmError;
380 CHAR16 *gPressEnter;
381 CHAR16 *gEmptyString;
382 CHAR16 *gAreYouSure;
383 CHAR16 *gYesResponse;
384 CHAR16 *gNoResponse;
385 CHAR16 *gMiniString;
386 CHAR16 *gPlusString;
387 CHAR16 *gMinusString;
388 CHAR16 *gAdjustNumber;
389
390 CHAR16 gPromptBlockWidth;
391 CHAR16 gOptionBlockWidth;
392 CHAR16 gHelpBlockWidth;
393
394 //
395 // Global Procedure Defines
396 //
397 VOID
398 InitializeBrowserStrings (
399 VOID
400 )
401 ;
402
403 UINTN
404 Print (
405 IN CHAR16 *fmt,
406 ...
407 )
408 ;
409
410 UINTN
411 PrintString (
412 CHAR16 *String
413 )
414 ;
415
416 UINTN
417 PrintChar (
418 CHAR16 Character
419 )
420 ;
421
422 UINTN
423 PrintAt (
424 IN UINTN Column,
425 IN UINTN Row,
426 IN CHAR16 *fmt,
427 ...
428 )
429 ;
430
431 UINTN
432 PrintStringAt (
433 IN UINTN Column,
434 IN UINTN Row,
435 CHAR16 *String
436 )
437 ;
438
439 UINTN
440 PrintCharAt (
441 IN UINTN Column,
442 IN UINTN Row,
443 CHAR16 Character
444 )
445 ;
446
447 VOID
448 DisplayPageFrame (
449 VOID
450 )
451 ;
452
453 CHAR16 *
454 GetToken (
455 IN STRING_REF IfrBinaryTitle,
456 IN EFI_HII_HANDLE HiiHandle
457 )
458 ;
459
460 VOID
461 GetTagCount (
462 IN UINT8 *RawFormSet,
463 IN OUT UINT16 *NumberOfTags
464 )
465 ;
466
467 VOID
468 GetNumericHeader (
469 IN EFI_TAG *Tag,
470 IN UINT8 *RawFormSet,
471 IN UINT16 Index,
472 IN UINT16 NumberOfLines,
473 IN EFI_FILE_FORM_TAGS *FileFormTags,
474 IN UINT16 CurrentVariable
475 )
476 ;
477
478 VOID
479 GetQuestionHeader (
480 IN EFI_TAG *Tag,
481 IN UINT8 *RawFormSet,
482 IN UINT16 Index,
483 IN EFI_FILE_FORM_TAGS *FileFormTags,
484 IN UINT16 CurrentVariable
485 )
486 ;
487
488 VOID
489 CreateSharedPopUp (
490 IN UINTN RequestedWidth,
491 IN UINTN NumberOfLines,
492 IN CHAR16 **ArrayOfStrings
493 )
494 ;
495
496 EFI_STATUS
497 CreateDialog (
498 IN UINTN NumberOfLines,
499 IN BOOLEAN HotKey,
500 IN UINTN MaximumStringSize,
501 OUT CHAR16 *StringBuffer,
502 OUT EFI_INPUT_KEY *KeyValue,
503 IN CHAR16 *String,
504 ...
505 )
506 ;
507
508 #endif