summaryrefslogtreecommitdiff
path: root/IntelFrameworkModulePkg/Universal/SetupBrowserDxe/Setup.h
blob: 6cfcf68c3a2f020d02b465d5e27ef04bba0aaabc (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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
/*++

Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution.  The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php

THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.

Module Name:

  Setup.h

Abstract:


Revision History

--*/

#ifndef _SETUP_H
#define _SETUP_H

//
// Include common header file for this module.
//
#include "CommonHeader.h"

//
// This is the generated header file which includes whatever needs to be exported (strings + IFR)
//
extern UINT8  SetupBrowserStrings[];

//
// Screen definitions
//
#define BANNER_HEIGHT                 4
#define BANNER_COLUMNS                3

#define FRONT_PAGE_HEADER_HEIGHT      4
#define NONE_FRONT_PAGE_HEADER_HEIGHT 3
#define LEFT_SKIPPED_COLUMNS          4
#define FOOTER_HEIGHT                 4
#define STATUS_BAR_HEIGHT             1
#define SCROLL_ARROW_HEIGHT           1
#define POPUP_PAD_SPACE_COUNT         5
#define POPUP_FRAME_WIDTH             2


#define EFI_SETUP_APPLICATION_SUBCLASS    0x00
#define EFI_GENERAL_APPLICATION_SUBCLASS  0x01
#define EFI_FRONT_PAGE_SUBCLASS           0x02
#define EFI_SINGLE_USE_SUBCLASS           0x03  // Used to display a single entity and then exit
//
// Definition for function key setting
//
#define NONE_FUNCTION_KEY_SETTING     0
#define DEFAULT_FUNCTION_KEY_SETTING  (FUNCTION_ONE | FUNCTION_TWO | FUNCTION_NINE | FUNCTION_TEN)

#define FUNCTION_ONE                  (1 << 0)
#define FUNCTION_TWO                  (1 << 1)
#define FUNCTION_NINE                 (1 << 2)
#define FUNCTION_TEN                  (1 << 3)

typedef struct {
  EFI_GUID  FormSetGuid;
  UINTN     KeySetting;
} FUNCTIION_KEY_SETTING;

//
// Character definitions
//
#define CHAR_SPACE              0x0020
#define UPPER_LOWER_CASE_OFFSET 0x20

//
// Time definitions
//
#define ONE_SECOND  10000000

//
// Display definitions
//
#define LEFT_HYPER_DELIMITER      L'<'
#define RIGHT_HYPER_DELIMITER     L'>'

#define LEFT_ONEOF_DELIMITER      L'<'
#define RIGHT_ONEOF_DELIMITER     L'>'

#define LEFT_NUMERIC_DELIMITER    L'['
#define RIGHT_NUMERIC_DELIMITER   L']'

#define LEFT_CHECKBOX_DELIMITER   L"["
#define RIGHT_CHECKBOX_DELIMITER  L"]"

#define CHECK_ON                  L"X"
#define CHECK_OFF                 L" "

#define TIME_SEPARATOR            L':'
#define DATE_SEPARATOR            L'/'

#define YES_ANSWER                L'Y'
#define NO_ANSWER                 L'N'

//
// Up to how many lines does the ordered list display
//
#define ORDERED_LIST_SIZE 4

//
// This is the Input Error Message
//
#define INPUT_ERROR 1

//
// This is the NV RAM update required Message
//
#define NV_UPDATE_REQUIRED  2

//
// Refresh the Status Bar with flags
//
#define REFRESH_STATUS_BAR  0xff

//
// This width is basically the sum of the prompt and option widths
//
#define QUESTION_BLOCK_WIDTH  50

//
// Width of the Language Description (Using ISO-639-2 3 ASCII letter standard)
//
#define LANG_DESC_WIDTH 3

//
// Maximum Number of Binaries we can see
//
#define MAX_BINARIES  255

//
// Invalid Handle
//
#define EFI_HII_INVALID_HANDLE  0xFFFF

//
// Invalid Offset Value
//
#define INVALID_OFFSET_VALUE  0xFFFF

struct StringPart {
  struct StringPart *Next;
  CHAR8             String[QUESTION_BLOCK_WIDTH + 2];
};

//
// The tag definition defines the data associated with a tag (an operation
// in the IFR lingo).  The tag is thus a modified union of all the data
// required for tags.  The user should be careful to only rely upon information
// relevant to that tag as the contents of other fields is undefined.
//
// The intent here is for this to be all of the data associated with a particular tag.
// Some of this data is extracted from the IFR and left alone.  Other data will be derived
// when the page is selected (since that's the first time we really know what language the
// page is to be displayed in) and still other data will vary based on the selection.
// If you'd like to consider alternatives, let me know.  This structure has grown somewhat organically.
// It gets a new item stuffed in it when a new item is needed.  When I finally decided I needed the
// StringPart structure, items got added here, for example.
//
typedef struct {
  UINT8                 Operand;        // The operand (first byte) of the variable length tag.
  EFI_GUID              GuidValue;      // Primarily for FormSet data
  EFI_PHYSICAL_ADDRESS  CallbackHandle;
  UINT16                Class;
  UINT16                SubClass;
  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.
  UINT16                PageLine;
  UINT16                PageColumn;
  UINT16                OptionWidth;    // The option can be wider than the column usually associated with options.  This is the width on the last option line
  STRING_REF            Text;           // Used for title, subtitle, prompt, etc.  This is the string token associated with the string.  This token is language independent.
  STRING_REF            TextTwo;        // Used for title, subtitle, prompt, etc.  This is the string token associated with the string.  This token is language independent.
  STRING_REF            Help;           // Null means no help  Same as above but for languages.
  UINT16                Consistency;    // Do we need to check this opcode against consistency?  If > 0, yes.
  UINT16                Id;
  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)
  //
  // These are the three values that are created to determine where in the variable the data is stored.  This should, in general,
  // 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.
  //
  UINT16                StorageStart;
  //
  // These are the three values that are created to determine where in the variable the data is stored.  This should, in general,
  // 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.
  //
  UINT8                 StorageWidth;
  //
  // These are the three values that are created to determine where in the variable the data is stored.  This should, in general,
  // 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.
  //
  UINT16                Value;
  //
  // (Default or current)
  //
  UINT8                 Flags;
  UINT16                Key;
  //
  // Used to preserve a value during late consistency checking
  //
  UINT16                OldValue;
  UINT16                Minimum;
  UINT16                Maximum;
  UINT16                Step;
  UINT16                Default;
  UINT16                NvDataSize;
  UINT16                ConsistencyId;
  BOOLEAN               GrayOut;
  BOOLEAN               Suppress;
  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).
  UINT16                *IntList;     // List of the values possible for a list question
  //
  // The string is obtained from the string list and formatted into lines and the lines are held in this linked list.
  // 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
  // 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.
  //
  struct StringPart     *StringList;
  BOOLEAN               ResetRequired;    // Primarily used to determine if a reset is required by changing this op-code.
  UINT16                VariableNumber;   // Used to define which variable the StorageStart will be pertinent for (0-based)  For single variable VFR this will always be 0.
  //
  // Used to define which variable the StorageStart will be pertinent for (0-based)  This is used for boolean check of ID versus ID
  // so that a user can compare the value of one variable.field content versus another variable.field content.
  //
  UINT16                VariableNumber2;
} EFI_TAG;

#define EFI_FORM_DATA_SIGNATURE EFI_SIGNATURE_32 ('F', 'o', 'r', 'm')

typedef struct {
  UINTN                     Signature;

  EFI_HII_PROTOCOL          *Hii;
  EFI_FORM_BROWSER_PROTOCOL FormConfig;
} EFI_FORM_CONFIGURATION_DATA;

#define EFI_FORM_DATA_FROM_THIS(a)  CR (a, EFI_FORM_CONFIGURATION_DATA, FormConfig, EFI_FORM_DATA_SIGNATURE)

typedef struct _EFI_VARIABLE_DEFINITION {
  CHAR8                           *NvRamMap;
  CHAR8                           *FakeNvRamMap;    // This is where the storage for NULL devices go (e.g. RTC)
  EFI_GUID                        Guid;
  UINT16                          VariableId;
  UINT16                          VariableSize;
  UINT16                          VariableFakeSize; // For dynamically created and NULL device options, this is the latest size
  CHAR16                          *VariableName;
  struct _EFI_VARIABLE_DEFINITION *Next;
  struct _EFI_VARIABLE_DEFINITION *Previous;
} EFI_VARIABLE_DEFINITION;

typedef struct {
  UINT32      Length;                               // Length in bytes between beginning of struc and end of Strings
  CHAR8       LanguageCode[4];                      // ISO-639-2 language code with a null-terminator
  RELOFST     PrintableLanguageName;                // Translated name of the Language, "English"/"Espanol" etc
  UINT32      Attributes;                           // If on, the language is intended to be printed right to left.  The default (off) is to print left to right.
  RELOFST     StringsPointers[1];                   // Pointing to string offset from beginning of String Binary
  EFI_STRING  Strings[1];                           // Array of String Entries.  Note the number of entries for Strings and StringsPointers will be the same
} EFI_LANGUAGE_SET;

//
// This encapsulates all the pointers associated with found IFR binaries
//
typedef struct _EFI_IFR_BINARY {
  struct _EFI_IFR_BINARY  *Next;
  VOID                    *IfrPackage;  // Handy for use in freeing the data later since this is the header of the buffer
  VOID                    *FormBinary;
  EFI_HII_HANDLE          Handle;
  STRING_REF              TitleToken;
  BOOLEAN                 UnRegisterOnExit;
} EFI_IFR_BINARY;

//
// This encapsulates all the questions (tags) for a particular Form Set
//
typedef struct _EFI_FORM_TAGS {
  struct _EFI_FORM_TAGS *Next;
  EFI_TAG               *Tags;
} EFI_FORM_TAGS;

//
// This is the database of all inconsistency data.  Each op-code associated
// with inconsistency will be tracked here.  This optimizes the search requirement
// since we will back mark the main tag structure with the op-codes that have reference
// to inconsistency data.  This way when parsing the main tag structure and encountering
// the inconsistency mark - we can search this database to know what the inconsistency
// parameters are for that entry.
//
typedef struct _EFI_INCONSISTENCY_DATA {
  struct _EFI_INCONSISTENCY_DATA  *Next;
  struct _EFI_INCONSISTENCY_DATA  *Previous;
  UINT8                           Operand;
  STRING_REF                      Popup;
  UINT16                          QuestionId1;
  UINT16                          QuestionId2;
  UINT16                          Value;
  UINT16                          ListLength;
  UINT16                          ConsistencyId;
  UINT16                          *ValueList;
  UINT16                          VariableNumber;
  UINT16                          VariableNumber2;
  UINT8                           Width;
} EFI_INCONSISTENCY_DATA;

//
// Encapsulating all found Tag information from all sources
// Each encapsulation also contains the NvRamMap buffer and the Size of the NV store
//
typedef struct _EFI_FILE_FORM_TAGS {
  struct _EFI_FILE_FORM_TAGS  *NextFile;
  EFI_INCONSISTENCY_DATA      *InconsistentTags;
  EFI_VARIABLE_DEFINITION     *VariableDefinitions;
  EFI_FORM_TAGS               FormTags;
} EFI_FILE_FORM_TAGS;

typedef struct {
  STRING_REF  Banner[BANNER_HEIGHT][BANNER_COLUMNS];
} BANNER_DATA;

//
// Head of the Binary structures
//
EFI_IFR_BINARY    *gBinaryDataHead;

//
// The IFR binary that the user chose to run
//
UINTN             gActiveIfr;

EFI_HII_PROTOCOL  *Hii;

VOID              *CachedNVEntry;
BANNER_DATA       *BannerData;
EFI_HII_HANDLE    FrontPageHandle;
STRING_REF        FrontPageTimeOutTitle;
INT16             FrontPageTimeOutValue;
UINTN             gClassOfVfr;
UINTN             gFunctionKeySetting;
BOOLEAN           gResetRequired;
BOOLEAN           gExitRequired;
BOOLEAN           gSaveRequired;
BOOLEAN           gNvUpdateRequired;
UINT16            gConsistencyId;
UINTN             gPriorMenuEntry;
EFI_HII_HANDLE    gHiiHandle;
BOOLEAN           gFirstIn;
VOID              *gPreviousValue;
UINT16            gDirection;
EFI_SCREEN_DESCRIPTOR gScreenDimensions;
BOOLEAN           gUpArrow;
BOOLEAN           gDownArrow;
BOOLEAN           gTimeOnScreen;
BOOLEAN           gDateOnScreen;

//
// Browser Global Strings
//
CHAR16            *gFunctionOneString;
CHAR16            *gFunctionTwoString;
CHAR16            *gFunctionNineString;
CHAR16            *gFunctionTenString;
CHAR16            *gEnterString;
CHAR16            *gEnterCommitString;
CHAR16            *gEscapeString;
CHAR16            *gMoveHighlight;
CHAR16            *gMakeSelection;
CHAR16            *gNumericInput;
CHAR16            *gToggleCheckBox;
CHAR16            *gPromptForPassword;
CHAR16            *gPromptForNewPassword;
CHAR16            *gConfirmPassword;
CHAR16            *gConfirmError;
CHAR16            *gPressEnter;
CHAR16            *gEmptyString;
CHAR16            *gAreYouSure;
CHAR16            *gYesResponse;
CHAR16            *gNoResponse;
CHAR16            *gMiniString;
CHAR16            *gPlusString;
CHAR16            *gMinusString;
CHAR16            *gAdjustNumber;

CHAR16            gPromptBlockWidth;
CHAR16            gOptionBlockWidth;
CHAR16            gHelpBlockWidth;

//
// Global Procedure Defines
//
VOID
InitializeBrowserStrings (
  VOID
  )
;

UINTN
Print (
  IN CHAR16                         *fmt,
  ...
  )
;

UINTN
PrintString (
  CHAR16       *String
  )
;

UINTN
PrintChar (
  CHAR16       Character
  )
;

UINTN
PrintAt (
  IN UINTN     Column,
  IN UINTN     Row,
  IN CHAR16    *fmt,
  ...
  )
;

UINTN
PrintStringAt (
  IN UINTN     Column,
  IN UINTN     Row,
  CHAR16       *String
  )
;

UINTN
PrintCharAt (
  IN UINTN     Column,
  IN UINTN     Row,
  CHAR16       Character
  )
;

VOID
DisplayPageFrame (
  VOID
  )
;

CHAR16            *
GetToken (
  IN  STRING_REF                              IfrBinaryTitle,
  IN  EFI_HII_HANDLE                          HiiHandle
  )
;

VOID
GetTagCount (
  IN      UINT8                                 *RawFormSet,
  IN OUT  UINT16                                *NumberOfTags
  )
;

VOID
GetNumericHeader (
  IN  EFI_TAG             *Tag,
  IN  UINT8               *RawFormSet,
  IN  UINT16              Index,
  IN  UINT16              NumberOfLines,
  IN  EFI_FILE_FORM_TAGS  *FileFormTags,
  IN  UINT16              CurrentVariable
  )
;

VOID
GetQuestionHeader (
  IN  EFI_TAG             *Tag,
  IN  UINT8               *RawFormSet,
  IN  UINT16              Index,
  IN  EFI_FILE_FORM_TAGS  *FileFormTags,
  IN  UINT16              CurrentVariable
  )
;

VOID
CreateSharedPopUp (
  IN  UINTN                       RequestedWidth,
  IN  UINTN                       NumberOfLines,
  IN  CHAR16                      **ArrayOfStrings
  )
;

EFI_STATUS
CreateDialog (
  IN  UINTN                       NumberOfLines,
  IN  BOOLEAN                     HotKey,
  IN  UINTN                       MaximumStringSize,
  OUT CHAR16                      *StringBuffer,
  OUT EFI_INPUT_KEY               *KeyValue,
  IN  CHAR16                      *String,
  ...
  )
;

#endif