1 /** @file
2 Private structures definitions in HiiDatabase.
3 
4 Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution.  The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9 
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12 
13 **/
14 
15 #ifndef __HII_DATABASE_PRIVATE_H__
16 #define __HII_DATABASE_PRIVATE_H__
17 
18 #include <Uefi.h>
19 
20 #include <Protocol/DevicePath.h>
21 #include <Protocol/HiiFont.h>
22 #include <Protocol/HiiImage.h>
23 #include <Protocol/HiiString.h>
24 #include <Protocol/HiiDatabase.h>
25 #include <Protocol/HiiConfigRouting.h>
26 #include <Protocol/HiiConfigAccess.h>
27 #include <Protocol/HiiConfigKeyword.h>
28 #include <Protocol/SimpleTextOut.h>
29 
30 #include <Guid/HiiKeyBoardLayout.h>
31 #include <Guid/GlobalVariable.h>
32 
33 
34 #include <Library/DebugLib.h>
35 #include <Library/BaseMemoryLib.h>
36 #include <Library/UefiDriverEntryPoint.h>
37 #include <Library/UefiBootServicesTableLib.h>
38 #include <Library/BaseLib.h>
39 #include <Library/DevicePathLib.h>
40 #include <Library/MemoryAllocationLib.h>
41 #include <Library/UefiLib.h>
42 #include <Library/PcdLib.h>
43 #include <Library/UefiRuntimeServicesTableLib.h>
44 #include <Library/PrintLib.h>
45 
46 #define MAX_STRING_LENGTH                  1024
47 #define MAX_FONT_NAME_LEN                  256
48 #define NARROW_BASELINE                    15
49 #define WIDE_BASELINE                      14
50 #define SYS_FONT_INFO_MASK                 0x37
51 #define REPLACE_UNKNOWN_GLYPH              0xFFFD
52 #define PROPORTIONAL_GLYPH                 0x80
53 #define NARROW_GLYPH                       0x40
54 
55 #define BITMAP_LEN_1_BIT(Width, Height)  (((Width) + 7) / 8 * (Height))
56 #define BITMAP_LEN_4_BIT(Width, Height)  (((Width) + 1) / 2 * (Height))
57 #define BITMAP_LEN_8_BIT(Width, Height)  ((Width) * (Height))
58 #define BITMAP_LEN_24_BIT(Width, Height) ((Width) * (Height) * 3)
59 
60 //
61 // IFR data structure
62 //
63 // BASE_CR (a, IFR_DEFAULT_VALUE_DATA, Entry) to get the whole structure.
64 
65 typedef struct {
66   LIST_ENTRY          Entry;             // Link to VarStorage
67   EFI_GUID            Guid;
68   CHAR16              *Name;
69   UINT16              Size;
70   UINT8               Type;
71   LIST_ENTRY          BlockEntry;        // Link to its Block array
72 } IFR_VARSTORAGE_DATA;
73 
74 typedef struct {
75   LIST_ENTRY          Entry;             // Link to Block array
76   UINT16              Offset;
77   UINT16              Width;
78   EFI_QUESTION_ID     QuestionId;
79   UINT8               OpCode;
80   UINT8               Scope;
81   LIST_ENTRY          DefaultValueEntry; // Link to its default value array
82   CHAR16              *Name;
83 } IFR_BLOCK_DATA;
84 
85 //
86 // Get default value from IFR data.
87 //
88 typedef enum {
89   DefaultValueFromDefault = 0,     // Get from the minimum or first one when not set default value.
90   DefaultValueFromFlag,            // Get default value from the defalut flag.
91   DefaultValueFromOpcode           // Get default value from default opcode, highest priority.
92 } DEFAULT_VALUE_TYPE;
93 
94 typedef struct {
95   LIST_ENTRY          Entry;
96   DEFAULT_VALUE_TYPE  Type;
97   BOOLEAN             Cleaned;       // Whether this value is cleaned
98                                      // TRUE  Cleaned, the value can't be used
99                                      // FALSE Not cleaned, the value can  be used.
100   UINT16              DefaultId;
101   EFI_IFR_TYPE_VALUE  Value;
102 } IFR_DEFAULT_DATA;
103 
104 //
105 // Storage types
106 //
107 #define EFI_HII_VARSTORE_BUFFER              0
108 #define EFI_HII_VARSTORE_NAME_VALUE          1
109 #define EFI_HII_VARSTORE_EFI_VARIABLE        2
110 #define EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER 3
111 
112 //
113 // Keyword handler protocol filter type.
114 //
115 #define EFI_KEYWORD_FILTER_READONY           0x01
116 #define EFI_KEYWORD_FILTER_REAWRITE          0x02
117 #define EFI_KEYWORD_FILTER_BUFFER            0x10
118 #define EFI_KEYWORD_FILTER_NUMERIC           0x20
119 #define EFI_KEYWORD_FILTER_NUMERIC_1         0x30
120 #define EFI_KEYWORD_FILTER_NUMERIC_2         0x40
121 #define EFI_KEYWORD_FILTER_NUMERIC_4         0x50
122 #define EFI_KEYWORD_FILTER_NUMERIC_8         0x60
123 
124 
125 #define HII_FORMSET_STORAGE_SIGNATURE           SIGNATURE_32 ('H', 'S', 'T', 'G')
126 typedef struct {
127   UINTN               Signature;
128   LIST_ENTRY          Entry;
129 
130   EFI_HII_HANDLE      HiiHandle;
131   EFI_HANDLE          DriverHandle;
132 
133   UINT8               Type;   // EFI_HII_VARSTORE_BUFFER, EFI_HII_VARSTORE_NAME_VALUE, EFI_HII_VARSTORE_EFI_VARIABLE
134   EFI_GUID            Guid;
135   CHAR16              *Name;
136   UINT16              Size;
137 } HII_FORMSET_STORAGE;
138 
139 
140 //
141 // String Package definitions
142 //
143 #define HII_STRING_PACKAGE_SIGNATURE    SIGNATURE_32 ('h','i','s','p')
144 typedef struct _HII_STRING_PACKAGE_INSTANCE {
145   UINTN                                 Signature;
146   EFI_HII_STRING_PACKAGE_HDR            *StringPkgHdr;
147   UINT8                                 *StringBlock;
148   LIST_ENTRY                            StringEntry;
149   LIST_ENTRY                            FontInfoList;  // local font info list
150   UINT8                                 FontId;
151   EFI_STRING_ID                         MaxStringId;   // record StringId
152 } HII_STRING_PACKAGE_INSTANCE;
153 
154 //
155 // Form Package definitions
156 //
157 #define HII_IFR_PACKAGE_SIGNATURE       SIGNATURE_32 ('h','f','r','p')
158 typedef struct _HII_IFR_PACKAGE_INSTANCE {
159   UINTN                                 Signature;
160   EFI_HII_PACKAGE_HEADER                FormPkgHdr;
161   UINT8                                 *IfrData;
162   LIST_ENTRY                            IfrEntry;
163 } HII_IFR_PACKAGE_INSTANCE;
164 
165 //
166 // Simple Font Package definitions
167 //
168 #define HII_S_FONT_PACKAGE_SIGNATURE    SIGNATURE_32 ('h','s','f','p')
169 typedef struct _HII_SIMPLE_FONT_PACKAGE_INSTANCE {
170   UINTN                                 Signature;
171   EFI_HII_SIMPLE_FONT_PACKAGE_HDR       *SimpleFontPkgHdr;
172   LIST_ENTRY                            SimpleFontEntry;
173 } HII_SIMPLE_FONT_PACKAGE_INSTANCE;
174 
175 //
176 // Font Package definitions
177 //
178 #define HII_FONT_PACKAGE_SIGNATURE      SIGNATURE_32 ('h','i','f','p')
179 typedef struct _HII_FONT_PACKAGE_INSTANCE {
180   UINTN                                 Signature;
181   EFI_HII_FONT_PACKAGE_HDR              *FontPkgHdr;
182   UINT16                                Height;
183   UINT16                                BaseLine;
184   UINT8                                 *GlyphBlock;
185   LIST_ENTRY                            FontEntry;
186   LIST_ENTRY                            GlyphInfoList;
187 } HII_FONT_PACKAGE_INSTANCE;
188 
189 #define HII_GLYPH_INFO_SIGNATURE        SIGNATURE_32 ('h','g','i','s')
190 typedef struct _HII_GLYPH_INFO {
191   UINTN                                 Signature;
192   LIST_ENTRY                            Entry;
193   CHAR16                                CharId;
194   EFI_HII_GLYPH_INFO                    Cell;
195 } HII_GLYPH_INFO;
196 
197 #define HII_FONT_INFO_SIGNATURE         SIGNATURE_32 ('h','l','f','i')
198 typedef struct _HII_FONT_INFO {
199   UINTN                                 Signature;
200   LIST_ENTRY                            Entry;
201   LIST_ENTRY                            *GlobalEntry;
202   UINT8                                 FontId;
203 } HII_FONT_INFO;
204 
205 #define HII_GLOBAL_FONT_INFO_SIGNATURE  SIGNATURE_32 ('h','g','f','i')
206 typedef struct _HII_GLOBAL_FONT_INFO {
207   UINTN                                 Signature;
208   LIST_ENTRY                            Entry;
209   HII_FONT_PACKAGE_INSTANCE             *FontPackage;
210   UINTN                                 FontInfoSize;
211   EFI_FONT_INFO                         *FontInfo;
212 } HII_GLOBAL_FONT_INFO;
213 
214 //
215 // Image Package definitions
216 //
217 
218 #define HII_PIXEL_MASK                  0x80
219 
220 typedef struct _HII_IMAGE_PACKAGE_INSTANCE {
221   EFI_HII_IMAGE_PACKAGE_HDR             ImagePkgHdr;
222   UINT32                                ImageBlockSize;
223   UINT32                                PaletteInfoSize;
224   UINT8                                 *ImageBlock;
225   UINT8                                 *PaletteBlock;
226 } HII_IMAGE_PACKAGE_INSTANCE;
227 
228 //
229 // Keyboard Layout Pacakge definitions
230 //
231 #define HII_KB_LAYOUT_PACKAGE_SIGNATURE SIGNATURE_32 ('h','k','l','p')
232 typedef struct _HII_KEYBOARD_LAYOUT_PACKAGE_INSTANCE {
233   UINTN                                 Signature;
234   UINT8                                 *KeyboardPkg;
235   LIST_ENTRY                            KeyboardEntry;
236 } HII_KEYBOARD_LAYOUT_PACKAGE_INSTANCE;
237 
238 //
239 // Guid Package definitions
240 //
241 #define HII_GUID_PACKAGE_SIGNATURE      SIGNATURE_32 ('h','i','g','p')
242 typedef struct _HII_GUID_PACKAGE_INSTANCE {
243   UINTN                                 Signature;
244   UINT8                                 *GuidPkg;
245   LIST_ENTRY                            GuidEntry;
246 } HII_GUID_PACKAGE_INSTANCE;
247 
248 //
249 // A package list can contain only one or less than one device path package.
250 // This rule also applies to image package since ImageId can not be duplicate.
251 //
252 typedef struct _HII_DATABASE_PACKAGE_LIST_INSTANCE {
253   EFI_HII_PACKAGE_LIST_HEADER           PackageListHdr;
254   LIST_ENTRY                            GuidPkgHdr;
255   LIST_ENTRY                            FormPkgHdr;
256   LIST_ENTRY                            KeyboardLayoutHdr;
257   LIST_ENTRY                            StringPkgHdr;
258   LIST_ENTRY                            FontPkgHdr;
259   HII_IMAGE_PACKAGE_INSTANCE            *ImagePkg;
260   LIST_ENTRY                            SimpleFontPkgHdr;
261   UINT8                                 *DevicePathPkg;
262 } HII_DATABASE_PACKAGE_LIST_INSTANCE;
263 
264 #define HII_HANDLE_SIGNATURE            SIGNATURE_32 ('h','i','h','l')
265 
266 typedef struct {
267   UINTN               Signature;
268   LIST_ENTRY          Handle;
269   UINTN               Key;
270 } HII_HANDLE;
271 
272 #define HII_DATABASE_RECORD_SIGNATURE   SIGNATURE_32 ('h','i','d','r')
273 
274 typedef struct _HII_DATABASE_RECORD {
275   UINTN                                 Signature;
276   HII_DATABASE_PACKAGE_LIST_INSTANCE    *PackageList;
277   EFI_HANDLE                            DriverHandle;
278   EFI_HII_HANDLE                        Handle;
279   LIST_ENTRY                            DatabaseEntry;
280 } HII_DATABASE_RECORD;
281 
282 #define HII_DATABASE_NOTIFY_SIGNATURE   SIGNATURE_32 ('h','i','d','n')
283 
284 typedef struct _HII_DATABASE_NOTIFY {
285   UINTN                                 Signature;
286   EFI_HANDLE                            NotifyHandle;
287   UINT8                                 PackageType;
288   EFI_GUID                              *PackageGuid;
289   EFI_HII_DATABASE_NOTIFY               PackageNotifyFn;
290   EFI_HII_DATABASE_NOTIFY_TYPE          NotifyType;
291   LIST_ENTRY                            DatabaseNotifyEntry;
292 } HII_DATABASE_NOTIFY;
293 
294 #define HII_DATABASE_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('H', 'i', 'D', 'p')
295 
296 typedef struct _HII_DATABASE_PRIVATE_DATA {
297   UINTN                                 Signature;
298   LIST_ENTRY                            DatabaseList;
299   LIST_ENTRY                            DatabaseNotifyList;
300   EFI_HII_FONT_PROTOCOL                 HiiFont;
301   EFI_HII_IMAGE_PROTOCOL                HiiImage;
302   EFI_HII_STRING_PROTOCOL               HiiString;
303   EFI_HII_DATABASE_PROTOCOL             HiiDatabase;
304   EFI_HII_CONFIG_ROUTING_PROTOCOL       ConfigRouting;
305   EFI_CONFIG_KEYWORD_HANDLER_PROTOCOL   ConfigKeywordHandler;
306   LIST_ENTRY                            HiiHandleList;
307   INTN                                  HiiHandleCount;
308   LIST_ENTRY                            FontInfoList;  // global font info list
309   UINTN                                 Attribute;     // default system color
310   EFI_GUID                              CurrentLayoutGuid;
311   EFI_HII_KEYBOARD_LAYOUT               *CurrentLayout;
312 } HII_DATABASE_PRIVATE_DATA;
313 
314 #define HII_FONT_DATABASE_PRIVATE_DATA_FROM_THIS(a) \
315   CR (a, \
316       HII_DATABASE_PRIVATE_DATA, \
317       HiiFont, \
318       HII_DATABASE_PRIVATE_DATA_SIGNATURE \
319       )
320 
321 #define HII_IMAGE_DATABASE_PRIVATE_DATA_FROM_THIS(a) \
322   CR (a, \
323       HII_DATABASE_PRIVATE_DATA, \
324       HiiImage, \
325       HII_DATABASE_PRIVATE_DATA_SIGNATURE \
326       )
327 
328 #define HII_STRING_DATABASE_PRIVATE_DATA_FROM_THIS(a) \
329   CR (a, \
330       HII_DATABASE_PRIVATE_DATA, \
331       HiiString, \
332       HII_DATABASE_PRIVATE_DATA_SIGNATURE \
333       )
334 
335 #define HII_DATABASE_DATABASE_PRIVATE_DATA_FROM_THIS(a) \
336   CR (a, \
337       HII_DATABASE_PRIVATE_DATA, \
338       HiiDatabase, \
339       HII_DATABASE_PRIVATE_DATA_SIGNATURE \
340       )
341 
342 #define CONFIG_ROUTING_DATABASE_PRIVATE_DATA_FROM_THIS(a) \
343   CR (a, \
344       HII_DATABASE_PRIVATE_DATA, \
345       ConfigRouting, \
346       HII_DATABASE_PRIVATE_DATA_SIGNATURE \
347       )
348 
349 #define CONFIG_KEYWORD_HANDLER_DATABASE_PRIVATE_DATA_FROM_THIS(a) \
350   CR (a, \
351       HII_DATABASE_PRIVATE_DATA, \
352       ConfigKeywordHandler, \
353       HII_DATABASE_PRIVATE_DATA_SIGNATURE \
354       )
355 
356 //
357 // Internal function prototypes.
358 //
359 
360 /**
361   Generate a sub string then output it.
362 
363   This is a internal function.
364 
365   @param  String                 A constant string which is the prefix of the to be
366                                  generated string, e.g. GUID=
367 
368   @param  BufferLen              The length of the Buffer in bytes.
369 
370   @param  Buffer                 Points to a buffer which will be converted to be the
371                                  content of the generated string.
372 
373   @param  Flag                   If 1, the buffer contains data for the value of GUID or PATH stored in
374                                  UINT8 *; if 2, the buffer contains unicode string for the value of NAME;
375                                  if 3, the buffer contains other data.
376 
377   @param  SubStr                 Points to the output string. It's caller's
378                                  responsibility to free this buffer.
379 
380 
381 **/
382 VOID
383 GenerateSubStr (
384   IN CONST EFI_STRING              String,
385   IN  UINTN                        BufferLen,
386   IN  VOID                         *Buffer,
387   IN  UINT8                        Flag,
388   OUT EFI_STRING                   *SubStr
389   );
390 
391 /**
392   This function checks whether a handle is a valid EFI_HII_HANDLE.
393 
394   @param  Handle                  Pointer to a EFI_HII_HANDLE
395 
396   @retval TRUE                    Valid
397   @retval FALSE                   Invalid
398 
399 **/
400 BOOLEAN
401 IsHiiHandleValid (
402   EFI_HII_HANDLE Handle
403   );
404 
405 
406 /**
407   This function checks whether EFI_FONT_INFO exists in current database. If
408   FontInfoMask is specified, check what options can be used to make a match.
409   Note that the masks relate to where the system default should be supplied
410   are ignored by this function.
411 
412   @param  Private                 Hii database private structure.
413   @param  FontInfo                Points to EFI_FONT_INFO structure.
414   @param  FontInfoMask            If not NULL, describes what options can be used
415                                   to make a match between the font requested and
416                                   the font available. The caller must guarantee
417                                   this mask is valid.
418   @param  FontHandle              On entry, Points to the font handle returned by a
419                                   previous  call to GetFontInfo() or NULL to start
420                                   with the first font.
421   @param  GlobalFontInfo          If not NULL, output the corresponding globa font
422                                   info.
423 
424   @retval TRUE                    Existed
425   @retval FALSE                   Not existed
426 
427 **/
428 BOOLEAN
429 IsFontInfoExisted (
430   IN  HII_DATABASE_PRIVATE_DATA *Private,
431   IN  EFI_FONT_INFO             *FontInfo,
432   IN  EFI_FONT_INFO_MASK        *FontInfoMask,   OPTIONAL
433   IN  EFI_FONT_HANDLE           FontHandle,      OPTIONAL
434   OUT HII_GLOBAL_FONT_INFO      **GlobalFontInfo OPTIONAL
435   );
436 
437 /**
438 
439    This function invokes the matching registered function.
440 
441    @param  Private           HII Database driver private structure.
442    @param  NotifyType        The type of change concerning the database.
443    @param  PackageInstance   Points to the package referred to by the notification.
444    @param  PackageType       Package type
445    @param  Handle            The handle of the package list which contains the specified package.
446 
447    @retval EFI_SUCCESS            Already checked all registered function and invoked
448                                   if matched.
449    @retval EFI_INVALID_PARAMETER  Any input parameter is not valid.
450 
451 **/
452 EFI_STATUS
453 InvokeRegisteredFunction (
454   IN HII_DATABASE_PRIVATE_DATA    *Private,
455   IN EFI_HII_DATABASE_NOTIFY_TYPE NotifyType,
456   IN VOID                         *PackageInstance,
457   IN UINT8                        PackageType,
458   IN EFI_HII_HANDLE               Handle
459   )
460 ;
461 
462 /**
463   Retrieve system default font and color.
464 
465   @param  Private                 HII database driver private data.
466   @param  FontInfo                Points to system default font output-related
467                                   information. It's caller's responsibility to free
468                                   this buffer.
469   @param  FontInfoSize            If not NULL, output the size of buffer FontInfo.
470 
471   @retval EFI_SUCCESS             Cell information is added to the GlyphInfoList.
472   @retval EFI_OUT_OF_RESOURCES    The system is out of resources to accomplish the
473                                   task.
474   @retval EFI_INVALID_PARAMETER   Any input parameter is invalid.
475 
476 **/
477 EFI_STATUS
478 GetSystemFont (
479   IN  HII_DATABASE_PRIVATE_DATA      *Private,
480   OUT EFI_FONT_DISPLAY_INFO          **FontInfo,
481   OUT UINTN                          *FontInfoSize OPTIONAL
482   );
483 
484 
485 /**
486   Parse all string blocks to find a String block specified by StringId.
487   If StringId = (EFI_STRING_ID) (-1), find out all EFI_HII_SIBT_FONT blocks
488   within this string package and backup its information. If LastStringId is
489   specified, the string id of last string block will also be output.
490   If StringId = 0, output the string id of last string block (EFI_HII_SIBT_STRING).
491 
492   @param  Private                 Hii database private structure.
493   @param  StringPackage           Hii string package instance.
494   @param  StringId                The string's id, which is unique within
495                                   PackageList.
496   @param  BlockType               Output the block type of found string block.
497   @param  StringBlockAddr         Output the block address of found string block.
498   @param  StringTextOffset        Offset, relative to the found block address, of
499                                   the  string text information.
500   @param  LastStringId            Output the last string id when StringId = 0 or StringId = -1.
501   @param  StartStringId           The first id in the skip block which StringId in the block.
502 
503   @retval EFI_SUCCESS             The string text and font is retrieved
504                                   successfully.
505   @retval EFI_NOT_FOUND           The specified text or font info can not be found
506                                   out.
507   @retval EFI_OUT_OF_RESOURCES    The system is out of resources to accomplish the
508                                   task.
509 
510 **/
511 EFI_STATUS
512 FindStringBlock (
513   IN HII_DATABASE_PRIVATE_DATA        *Private,
514   IN  HII_STRING_PACKAGE_INSTANCE     *StringPackage,
515   IN  EFI_STRING_ID                   StringId,
516   OUT UINT8                           *BlockType, OPTIONAL
517   OUT UINT8                           **StringBlockAddr, OPTIONAL
518   OUT UINTN                           *StringTextOffset, OPTIONAL
519   OUT EFI_STRING_ID                   *LastStringId, OPTIONAL
520   OUT EFI_STRING_ID                   *StartStringId OPTIONAL
521   );
522 
523 
524 /**
525   Parse all glyph blocks to find a glyph block specified by CharValue.
526   If CharValue = (CHAR16) (-1), collect all default character cell information
527   within this font package and backup its information.
528 
529   @param  FontPackage             Hii string package instance.
530   @param  CharValue               Unicode character value, which identifies a glyph
531                                   block.
532   @param  GlyphBuffer             Output the corresponding bitmap data of the found
533                                   block. It is the caller's responsiblity to free
534                                   this buffer.
535   @param  Cell                    Output cell information of the encoded bitmap.
536   @param  GlyphBufferLen          If not NULL, output the length of GlyphBuffer.
537 
538   @retval EFI_SUCCESS             The bitmap data is retrieved successfully.
539   @retval EFI_NOT_FOUND           The specified CharValue does not exist in current
540                                   database.
541   @retval EFI_OUT_OF_RESOURCES    The system is out of resources to accomplish the
542                                   task.
543 
544 **/
545 EFI_STATUS
546 FindGlyphBlock (
547   IN  HII_FONT_PACKAGE_INSTANCE      *FontPackage,
548   IN  CHAR16                         CharValue,
549   OUT UINT8                          **GlyphBuffer, OPTIONAL
550   OUT EFI_HII_GLYPH_INFO             *Cell, OPTIONAL
551   OUT UINTN                          *GlyphBufferLen OPTIONAL
552   );
553 
554 /**
555   This function exports Form packages to a buffer.
556   This is a internal function.
557 
558   @param  Private                Hii database private structure.
559   @param  Handle                 Identification of a package list.
560   @param  PackageList            Pointer to a package list which will be exported.
561   @param  UsedSize               The length of buffer be used.
562   @param  BufferSize             Length of the Buffer.
563   @param  Buffer                 Allocated space for storing exported data.
564   @param  ResultSize             The size of the already exported content of  this
565                                  package list.
566 
567   @retval EFI_SUCCESS            Form Packages are exported successfully.
568   @retval EFI_INVALID_PARAMETER  Any input parameter is invalid.
569 
570 **/
571 EFI_STATUS
572 ExportFormPackages (
573   IN HII_DATABASE_PRIVATE_DATA          *Private,
574   IN EFI_HII_HANDLE                     Handle,
575   IN HII_DATABASE_PACKAGE_LIST_INSTANCE *PackageList,
576   IN UINTN                              UsedSize,
577   IN UINTN                              BufferSize,
578   IN OUT VOID                           *Buffer,
579   IN OUT UINTN                          *ResultSize
580   );
581 
582 //
583 // EFI_HII_FONT_PROTOCOL protocol interfaces
584 //
585 
586 
587 /**
588   Renders a string to a bitmap or to the display.
589 
590   @param  This                    A pointer to the EFI_HII_FONT_PROTOCOL instance.
591   @param  Flags                   Describes how the string is to be drawn.
592   @param  String                  Points to the null-terminated string to be
593                                   displayed.
594   @param  StringInfo              Points to the string output information,
595                                   including the color and font.  If NULL, then the
596                                   string will be output in the default system font
597                                   and color.
598   @param  Blt                     If this points to a non-NULL on entry, this
599                                   points to the image, which is Width pixels   wide
600                                   and Height pixels high. The string will be drawn
601                                   onto this image and
602                                   EFI_HII_OUT_FLAG_CLIP is implied. If this points
603                                   to a NULL on entry, then a              buffer
604                                   will be allocated to hold the generated image and
605                                   the pointer updated on exit. It is the caller's
606                                   responsibility to free this buffer.
607   @param  BltX                    Together with BltX, Specifies the offset from the left and top edge
608                                   of the image of the first character cell in the
609                                   image.
610   @param  BltY                    Together with BltY, Specifies the offset from the left and top edge
611                                   of the image of the first character cell in the
612                                   image.
613   @param  RowInfoArray            If this is non-NULL on entry, then on exit, this
614                                   will point to an allocated buffer    containing
615                                   row information and RowInfoArraySize will be
616                                   updated to contain the        number of elements.
617                                   This array describes the characters which were at
618                                   least partially drawn and the heights of the
619                                   rows. It is the caller's responsibility to free
620                                   this buffer.
621   @param  RowInfoArraySize        If this is non-NULL on entry, then on exit it
622                                   contains the number of elements in RowInfoArray.
623   @param  ColumnInfoArray         If this is non-NULL, then on return it will be
624                                   filled with the horizontal offset for each
625                                   character in the string on the row where it is
626                                   displayed. Non-printing characters will     have
627                                   the offset ~0. The caller is responsible to
628                                   allocate a buffer large enough so that    there
629                                   is one entry for each character in the string,
630                                   not including the null-terminator. It is possible
631                                   when character display is normalized that some
632                                   character cells overlap.
633 
634   @retval EFI_SUCCESS             The string was successfully rendered.
635   @retval EFI_OUT_OF_RESOURCES    Unable to allocate an output buffer for
636                                   RowInfoArray or Blt.
637   @retval EFI_INVALID_PARAMETER The String or Blt.
638   @retval EFI_INVALID_PARAMETER Flags were invalid combination..
639 
640 **/
641 EFI_STATUS
642 EFIAPI
643 HiiStringToImage (
644   IN  CONST EFI_HII_FONT_PROTOCOL    *This,
645   IN  EFI_HII_OUT_FLAGS              Flags,
646   IN  CONST EFI_STRING               String,
647   IN  CONST EFI_FONT_DISPLAY_INFO    *StringInfo       OPTIONAL,
648   IN  OUT EFI_IMAGE_OUTPUT           **Blt,
649   IN  UINTN                          BltX,
650   IN  UINTN                          BltY,
651   OUT EFI_HII_ROW_INFO               **RowInfoArray    OPTIONAL,
652   OUT UINTN                          *RowInfoArraySize OPTIONAL,
653   OUT UINTN                          *ColumnInfoArray  OPTIONAL
654   );
655 
656 
657 /**
658   Render a string to a bitmap or the screen containing the contents of the specified string.
659 
660   @param  This                    A pointer to the EFI_HII_FONT_PROTOCOL instance.
661   @param  Flags                   Describes how the string is to be drawn.
662   @param  PackageList             The package list in the HII database to search
663                                   for the specified string.
664   @param  StringId                The string's id, which is unique within
665                                   PackageList.
666   @param  Language                Points to the language for the retrieved string.
667                                   If NULL, then the current system language is
668                                   used.
669   @param  StringInfo              Points to the string output information,
670                                   including the color and font.  If NULL, then the
671                                   string will be output in the default system font
672                                   and color.
673   @param  Blt                     If this points to a non-NULL on entry, this
674                                   points to the image, which is Width pixels   wide
675                                   and Height pixels high. The string will be drawn
676                                   onto this image and
677                                   EFI_HII_OUT_FLAG_CLIP is implied. If this points
678                                   to a NULL on entry, then a              buffer
679                                   will be allocated to hold the generated image and
680                                   the pointer updated on exit. It is the caller's
681                                   responsibility to free this buffer.
682   @param  BltX                    Together with BltX, Specifies the offset from the left and top edge
683                                   of the image of the first character cell in the
684                                   image.
685   @param  BltY                    Together with BltY, Specifies the offset from the left and top edge
686                                   of the image of the first character cell in the
687                                   image.
688   @param  RowInfoArray            If this is non-NULL on entry, then on exit, this
689                                   will point to an allocated buffer    containing
690                                   row information and RowInfoArraySize will be
691                                   updated to contain the        number of elements.
692                                   This array describes the characters which were at
693                                   least partially drawn and the heights of the
694                                   rows. It is the caller's responsibility to free
695                                   this buffer.
696   @param  RowInfoArraySize        If this is non-NULL on entry, then on exit it
697                                   contains the number of elements in RowInfoArray.
698   @param  ColumnInfoArray         If this is non-NULL, then on return it will be
699                                   filled with the horizontal offset for each
700                                   character in the string on the row where it is
701                                   displayed. Non-printing characters will     have
702                                   the offset ~0. The caller is responsible to
703                                   allocate a buffer large enough so that    there
704                                   is one entry for each character in the string,
705                                   not including the null-terminator. It is possible
706                                   when character display is normalized that some
707                                   character cells overlap.
708 
709   @retval EFI_SUCCESS             The string was successfully rendered.
710   @retval EFI_OUT_OF_RESOURCES    Unable to allocate an output buffer for
711                                   RowInfoArray or Blt.
712   @retval EFI_INVALID_PARAMETER The Blt or PackageList was NULL.
713   @retval EFI_INVALID_PARAMETER Flags were invalid combination.
714   @retval EFI_NOT_FOUND         The specified PackageList is not in the Database or the stringid is not
715                           in the specified PackageList.
716 
717 **/
718 EFI_STATUS
719 EFIAPI
720 HiiStringIdToImage (
721   IN  CONST EFI_HII_FONT_PROTOCOL    *This,
722   IN  EFI_HII_OUT_FLAGS              Flags,
723   IN  EFI_HII_HANDLE                 PackageList,
724   IN  EFI_STRING_ID                  StringId,
725   IN  CONST CHAR8*                   Language,
726   IN  CONST EFI_FONT_DISPLAY_INFO    *StringInfo       OPTIONAL,
727   IN  OUT EFI_IMAGE_OUTPUT           **Blt,
728   IN  UINTN                          BltX,
729   IN  UINTN                          BltY,
730   OUT EFI_HII_ROW_INFO               **RowInfoArray    OPTIONAL,
731   OUT UINTN                          *RowInfoArraySize OPTIONAL,
732   OUT UINTN                          *ColumnInfoArray  OPTIONAL
733   );
734 
735 
736 /**
737   Convert the glyph for a single character into a bitmap.
738 
739   @param  This                    A pointer to the EFI_HII_FONT_PROTOCOL instance.
740   @param  Char                    Character to retrieve.
741   @param  StringInfo              Points to the string font and color information
742                                   or NULL if the string should use the default
743                                   system font and color.
744   @param  Blt                     Thus must point to a NULL on entry. A buffer will
745                                   be allocated to hold the output and the pointer
746                                   updated on exit. It is the caller's
747                                   responsibility to free this buffer.
748   @param  Baseline                Number of pixels from the bottom of the bitmap to
749                                   the baseline.
750 
751   @retval EFI_SUCCESS             Glyph bitmap created.
752   @retval EFI_OUT_OF_RESOURCES    Unable to allocate the output buffer Blt.
753   @retval EFI_WARN_UNKNOWN_GLYPH  The glyph was unknown and was replaced with the
754                                   glyph for Unicode character 0xFFFD.
755   @retval EFI_INVALID_PARAMETER   Blt is NULL or *Blt is not NULL.
756 
757 **/
758 EFI_STATUS
759 EFIAPI
760 HiiGetGlyph (
761   IN  CONST EFI_HII_FONT_PROTOCOL    *This,
762   IN  CHAR16                         Char,
763   IN  CONST EFI_FONT_DISPLAY_INFO    *StringInfo,
764   OUT EFI_IMAGE_OUTPUT               **Blt,
765   OUT UINTN                          *Baseline OPTIONAL
766   );
767 
768 
769 /**
770   This function iterates through fonts which match the specified font, using
771   the specified criteria. If String is non-NULL, then all of the characters in
772   the string must exist in order for a candidate font to be returned.
773 
774   @param  This                    A pointer to the EFI_HII_FONT_PROTOCOL instance.
775   @param  FontHandle              On entry, points to the font handle returned by a
776                                    previous call to GetFontInfo() or NULL to start
777                                   with the  first font. On return, points to the
778                                   returned font handle or points to NULL if there
779                                   are no more matching fonts.
780   @param  StringInfoIn            Upon entry, points to the font to return information
781                                   about. If NULL, then the information about the system
782                                   default font will be returned.
783   @param  StringInfoOut           Upon return, contains the matching font's information.
784                                   If NULL, then no information is returned. This buffer
785                                   is allocated with a call to the Boot Service AllocatePool().
786                                   It is the caller's responsibility to call the Boot
787                                   Service FreePool() when the caller no longer requires
788                                   the contents of StringInfoOut.
789   @param  String                  Points to the string which will be tested to
790                                   determine  if all characters are available. If
791                                   NULL, then any font  is acceptable.
792 
793   @retval EFI_SUCCESS             Matching font returned successfully.
794   @retval EFI_NOT_FOUND           No matching font was found.
795   @retval EFI_INVALID_PARAMETER   StringInfoIn is NULL.
796   @retval EFI_INVALID_PARAMETER   StringInfoIn->FontInfoMask is an invalid combination.
797   @retval EFI_OUT_OF_RESOURCES    There were insufficient resources to complete the
798                                   request.
799 **/
800 EFI_STATUS
801 EFIAPI
802 HiiGetFontInfo (
803   IN  CONST EFI_HII_FONT_PROTOCOL    *This,
804   IN  OUT   EFI_FONT_HANDLE          *FontHandle,
805   IN  CONST EFI_FONT_DISPLAY_INFO    *StringInfoIn, OPTIONAL
806   OUT       EFI_FONT_DISPLAY_INFO    **StringInfoOut,
807   IN  CONST EFI_STRING               String OPTIONAL
808   );
809 
810 //
811 // EFI_HII_IMAGE_PROTOCOL interfaces
812 //
813 
814 
815 /**
816   This function adds the image Image to the group of images owned by PackageList, and returns
817   a new image identifier (ImageId).
818 
819   @param  This                    A pointer to the EFI_HII_IMAGE_PROTOCOL instance.
820   @param  PackageList             Handle of the package list where this image will
821                                   be added.
822   @param  ImageId                 On return, contains the new image id, which is
823                                   unique within PackageList.
824   @param  Image                   Points to the image.
825 
826   @retval EFI_SUCCESS             The new image was added successfully.
827   @retval EFI_NOT_FOUND           The specified PackageList could not be found in
828                                   database.
829   @retval EFI_OUT_OF_RESOURCES    Could not add the image due to lack of resources.
830   @retval EFI_INVALID_PARAMETER   Image is NULL or ImageId is NULL.
831 
832 **/
833 EFI_STATUS
834 EFIAPI
835 HiiNewImage (
836   IN  CONST EFI_HII_IMAGE_PROTOCOL   *This,
837   IN  EFI_HII_HANDLE                 PackageList,
838   OUT EFI_IMAGE_ID                   *ImageId,
839   IN  CONST EFI_IMAGE_INPUT          *Image
840   );
841 
842 
843 /**
844   This function retrieves the image specified by ImageId which is associated with
845   the specified PackageList and copies it into the buffer specified by Image.
846 
847   @param  This                    A pointer to the EFI_HII_IMAGE_PROTOCOL instance.
848   @param  PackageList             Handle of the package list where this image will
849                                   be searched.
850   @param  ImageId                 The image's id,, which is unique within
851                                   PackageList.
852   @param  Image                   Points to the image.
853 
854   @retval EFI_SUCCESS             The new image was returned successfully.
855   @retval EFI_NOT_FOUND           The image specified by ImageId is not available.
856                                                  The specified PackageList is not in the database.
857   @retval EFI_BUFFER_TOO_SMALL    The buffer specified by ImageSize is too small to
858                                   hold the image.
859   @retval EFI_INVALID_PARAMETER   The Image or ImageSize was NULL.
860   @retval EFI_OUT_OF_RESOURCES   The bitmap could not be retrieved because there was not
861                                                        enough memory.
862 
863 **/
864 EFI_STATUS
865 EFIAPI
866 HiiGetImage (
867   IN  CONST EFI_HII_IMAGE_PROTOCOL   *This,
868   IN  EFI_HII_HANDLE                 PackageList,
869   IN  EFI_IMAGE_ID                   ImageId,
870   OUT EFI_IMAGE_INPUT                *Image
871   );
872 
873 
874 /**
875   This function updates the image specified by ImageId in the specified PackageListHandle to
876   the image specified by Image.
877 
878   @param  This                    A pointer to the EFI_HII_IMAGE_PROTOCOL instance.
879   @param  PackageList             The package list containing the images.
880   @param  ImageId                 The image's id,, which is unique within
881                                   PackageList.
882   @param  Image                   Points to the image.
883 
884   @retval EFI_SUCCESS             The new image was updated successfully.
885   @retval EFI_NOT_FOUND           The image specified by ImageId is not in the
886                                                 database. The specified PackageList is not in the database.
887   @retval EFI_INVALID_PARAMETER   The Image was NULL.
888 
889 **/
890 EFI_STATUS
891 EFIAPI
892 HiiSetImage (
893   IN CONST EFI_HII_IMAGE_PROTOCOL    *This,
894   IN EFI_HII_HANDLE                  PackageList,
895   IN EFI_IMAGE_ID                    ImageId,
896   IN CONST EFI_IMAGE_INPUT           *Image
897   );
898 
899 
900 /**
901   This function renders an image to a bitmap or the screen using the specified
902   color and options. It draws the image on an existing bitmap, allocates a new
903   bitmap or uses the screen. The images can be clipped.
904 
905   @param  This                    A pointer to the EFI_HII_IMAGE_PROTOCOL instance.
906   @param  Flags                   Describes how the image is to be drawn.
907   @param  Image                   Points to the image to be displayed.
908   @param  Blt                     If this points to a non-NULL on entry, this
909                                   points to the image, which is Width pixels wide
910                                   and Height pixels high.  The image will be drawn
911                                   onto this image and  EFI_HII_DRAW_FLAG_CLIP is
912                                   implied. If this points to a  NULL on entry, then
913                                   a buffer will be allocated to hold  the generated
914                                   image and the pointer updated on exit. It is the
915                                   caller's responsibility to free this buffer.
916   @param  BltX                    Specifies the offset from the left and top edge
917                                   of the  output image of the first pixel in the
918                                   image.
919   @param  BltY                    Specifies the offset from the left and top edge
920                                   of the  output image of the first pixel in the
921                                   image.
922 
923   @retval EFI_SUCCESS             The image was successfully drawn.
924   @retval EFI_OUT_OF_RESOURCES    Unable to allocate an output buffer for Blt.
925   @retval EFI_INVALID_PARAMETER   The Image or Blt was NULL.
926   @retval EFI_INVALID_PARAMETER   Any combination of Flags is invalid.
927 
928 **/
929 EFI_STATUS
930 EFIAPI
931 HiiDrawImage (
932   IN CONST EFI_HII_IMAGE_PROTOCOL    *This,
933   IN EFI_HII_DRAW_FLAGS              Flags,
934   IN CONST EFI_IMAGE_INPUT           *Image,
935   IN OUT EFI_IMAGE_OUTPUT            **Blt,
936   IN UINTN                           BltX,
937   IN UINTN                           BltY
938   );
939 
940 
941 /**
942   This function renders an image to a bitmap or the screen using the specified
943   color and options. It draws the image on an existing bitmap, allocates a new
944   bitmap or uses the screen. The images can be clipped.
945 
946   @param  This                    A pointer to the EFI_HII_IMAGE_PROTOCOL instance.
947   @param  Flags                   Describes how the image is to be drawn.
948   @param  PackageList             The package list in the HII database to search
949                                   for the  specified image.
950   @param  ImageId                 The image's id, which is unique within
951                                   PackageList.
952   @param  Blt                     If this points to a non-NULL on entry, this
953                                   points to the image, which is Width pixels wide
954                                   and Height pixels high. The image will be drawn
955                                   onto this image and
956                                   EFI_HII_DRAW_FLAG_CLIP is implied. If this points
957                                   to a  NULL on entry, then a buffer will be
958                                   allocated to hold  the generated image and the
959                                   pointer updated on exit. It is the caller's
960                                   responsibility to free this buffer.
961   @param  BltX                    Specifies the offset from the left and top edge
962                                   of the  output image of the first pixel in the
963                                   image.
964   @param  BltY                    Specifies the offset from the left and top edge
965                                   of the  output image of the first pixel in the
966                                   image.
967 
968   @retval EFI_SUCCESS             The image was successfully drawn.
969   @retval EFI_OUT_OF_RESOURCES    Unable to allocate an output buffer for Blt.
970   @retval EFI_INVALID_PARAMETER  The Blt was NULL.
971   @retval EFI_NOT_FOUND          The image specified by ImageId is not in the database.
972                            The specified PackageList is not in the database.
973 
974 **/
975 EFI_STATUS
976 EFIAPI
977 HiiDrawImageId (
978   IN CONST EFI_HII_IMAGE_PROTOCOL    *This,
979   IN EFI_HII_DRAW_FLAGS              Flags,
980   IN EFI_HII_HANDLE                  PackageList,
981   IN EFI_IMAGE_ID                    ImageId,
982   IN OUT EFI_IMAGE_OUTPUT            **Blt,
983   IN UINTN                           BltX,
984   IN UINTN                           BltY
985   )
986 
987 ;
988 
989 //
990 // EFI_HII_STRING_PROTOCOL
991 //
992 
993 
994 /**
995   This function adds the string String to the group of strings owned by PackageList, with the
996   specified font information StringFontInfo and returns a new string id.
997 
998   @param  This                    A pointer to the EFI_HII_STRING_PROTOCOL
999                                   instance.
1000   @param  PackageList             Handle of the package list where this string will
1001                                   be added.
1002   @param  StringId                On return, contains the new strings id, which is
1003                                   unique within PackageList.
1004   @param  Language                Points to the language for the new string.
1005   @param  LanguageName            Points to the printable language name to
1006                                   associate with the passed in  Language field.If
1007                                   LanguageName is not NULL and the string package
1008                                   header's LanguageName  associated with a given
1009                                   Language is not zero, the LanguageName being
1010                                   passed  in will be ignored.
1011   @param  String                  Points to the new null-terminated string.
1012   @param  StringFontInfo          Points to the new string's font information or
1013                                   NULL if the string should have the default system
1014                                   font, size and style.
1015 
1016   @retval EFI_SUCCESS             The new string was added successfully.
1017   @retval EFI_NOT_FOUND           The specified PackageList could not be found in
1018                                   database.
1019   @retval EFI_OUT_OF_RESOURCES    Could not add the string due to lack of
1020                                   resources.
1021   @retval EFI_INVALID_PARAMETER   String is NULL or StringId is NULL or Language is
1022                                   NULL.
1023 
1024 **/
1025 EFI_STATUS
1026 EFIAPI
1027 HiiNewString (
1028   IN  CONST EFI_HII_STRING_PROTOCOL   *This,
1029   IN  EFI_HII_HANDLE                  PackageList,
1030   OUT EFI_STRING_ID                   *StringId,
1031   IN  CONST CHAR8                     *Language,
1032   IN  CONST CHAR16                    *LanguageName, OPTIONAL
1033   IN  CONST EFI_STRING                String,
1034   IN  CONST EFI_FONT_INFO             *StringFontInfo OPTIONAL
1035   );
1036 
1037 
1038 /**
1039   This function retrieves the string specified by StringId which is associated
1040   with the specified PackageList in the language Language and copies it into
1041   the buffer specified by String.
1042 
1043   @param  This                    A pointer to the EFI_HII_STRING_PROTOCOL
1044                                   instance.
1045   @param  Language                Points to the language for the retrieved string.
1046   @param  PackageList             The package list in the HII database to search
1047                                   for the  specified string.
1048   @param  StringId                The string's id, which is unique within
1049                                   PackageList.
1050   @param  String                  Points to the new null-terminated string.
1051   @param  StringSize              On entry, points to the size of the buffer
1052                                   pointed to by  String, in bytes. On return,
1053                                   points to the length of the string, in bytes.
1054   @param  StringFontInfo          If not NULL, points to the string's font
1055                                   information.  It's caller's responsibility to
1056                                   free this buffer.
1057 
1058   @retval EFI_SUCCESS             The string was returned successfully.
1059   @retval EFI_NOT_FOUND           The string specified by StringId is not
1060                                   available.
1061                                   The specified PackageList is not in the database.
1062   @retval EFI_INVALID_LANGUAGE    The string specified by StringId is available but
1063                                   not in the specified language.
1064   @retval EFI_BUFFER_TOO_SMALL    The buffer specified by StringSize is too small
1065                                   to  hold the string.
1066   @retval EFI_INVALID_PARAMETER   The Language or StringSize was NULL.
1067   @retval EFI_INVALID_PARAMETER   The value referenced by StringSize was not zero
1068                                   and String was NULL.
1069   @retval EFI_OUT_OF_RESOURCES    There were insufficient resources to complete the
1070                                    request.
1071 
1072 **/
1073 EFI_STATUS
1074 EFIAPI
1075 HiiGetString (
1076   IN  CONST EFI_HII_STRING_PROTOCOL   *This,
1077   IN  CONST CHAR8                     *Language,
1078   IN  EFI_HII_HANDLE                  PackageList,
1079   IN  EFI_STRING_ID                   StringId,
1080   OUT EFI_STRING                      String,
1081   IN  OUT UINTN                       *StringSize,
1082   OUT EFI_FONT_INFO                   **StringFontInfo OPTIONAL
1083   );
1084 
1085 
1086 /**
1087   This function updates the string specified by StringId in the specified PackageList to the text
1088   specified by String and, optionally, the font information specified by StringFontInfo.
1089 
1090   @param  This                    A pointer to the EFI_HII_STRING_PROTOCOL
1091                                   instance.
1092   @param  PackageList             The package list containing the strings.
1093   @param  StringId                The string's id, which is unique within
1094                                   PackageList.
1095   @param  Language                Points to the language for the updated string.
1096   @param  String                  Points to the new null-terminated string.
1097   @param  StringFontInfo          Points to the string's font information or NULL
1098                                   if the string font information is not changed.
1099 
1100   @retval EFI_SUCCESS             The string was updated successfully.
1101   @retval EFI_NOT_FOUND           The string specified by StringId is not in the
1102                                   database.
1103   @retval EFI_INVALID_PARAMETER   The String or Language was NULL.
1104   @retval EFI_OUT_OF_RESOURCES    The system is out of resources to accomplish the
1105                                   task.
1106 
1107 **/
1108 EFI_STATUS
1109 EFIAPI
1110 HiiSetString (
1111   IN CONST EFI_HII_STRING_PROTOCOL    *This,
1112   IN EFI_HII_HANDLE                   PackageList,
1113   IN EFI_STRING_ID                    StringId,
1114   IN CONST CHAR8                      *Language,
1115   IN CONST EFI_STRING                 String,
1116   IN CONST EFI_FONT_INFO              *StringFontInfo OPTIONAL
1117   );
1118 
1119 
1120 /**
1121   This function returns the list of supported languages, in the format specified
1122   in Appendix M of UEFI 2.1 spec.
1123 
1124   @param  This                    A pointer to the EFI_HII_STRING_PROTOCOL
1125                                   instance.
1126   @param  PackageList             The package list to examine.
1127   @param  Languages               Points to the buffer to hold the returned
1128                                   null-terminated ASCII string.
1129   @param  LanguagesSize           On entry, points to the size of the buffer
1130                                   pointed to by  Languages, in bytes. On  return,
1131                                   points to the length of Languages, in bytes.
1132 
1133   @retval EFI_SUCCESS             The languages were returned successfully.
1134   @retval EFI_INVALID_PARAMETER   The LanguagesSize was NULL.
1135   @retval EFI_INVALID_PARAMETER   The value referenced by LanguagesSize is not zero and Languages is NULL.
1136   @retval EFI_BUFFER_TOO_SMALL    The LanguagesSize is too small to hold the list
1137                                   of  supported languages. LanguageSize is updated
1138                                   to contain the required size.
1139   @retval EFI_NOT_FOUND           Could not find string package in specified
1140                                   packagelist.
1141 
1142 **/
1143 EFI_STATUS
1144 EFIAPI
1145 HiiGetLanguages (
1146   IN CONST EFI_HII_STRING_PROTOCOL    *This,
1147   IN EFI_HII_HANDLE                   PackageList,
1148   IN OUT CHAR8                        *Languages,
1149   IN OUT UINTN                        *LanguagesSize
1150   );
1151 
1152 
1153 /**
1154   Each string package has associated with it a single primary language and zero
1155   or more secondary languages. This routine returns the secondary languages
1156   associated with a package list.
1157 
1158   @param  This                    A pointer to the EFI_HII_STRING_PROTOCOL
1159                                   instance.
1160   @param  PackageList             The package list to examine.
1161   @param  PrimaryLanguage         Points to the null-terminated ASCII string that specifies
1162                                   the primary language. Languages are specified in the
1163                                   format specified in Appendix M of the UEFI 2.0 specification.
1164   @param  SecondaryLanguages      Points to the buffer to hold the returned null-terminated
1165                                   ASCII string that describes the list of
1166                                   secondary languages for the specified
1167                                   PrimaryLanguage. If there are no secondary
1168                                   languages, the function returns successfully,
1169                                   but this is set to NULL.
1170   @param  SecondaryLanguagesSize  On entry, points to the size of the buffer
1171                                   pointed to by SecondaryLanguages, in bytes. On
1172                                   return, points to the length of SecondaryLanguages
1173                                   in bytes.
1174 
1175   @retval EFI_SUCCESS             Secondary languages were correctly returned.
1176   @retval EFI_INVALID_PARAMETER   PrimaryLanguage or SecondaryLanguagesSize was NULL.
1177   @retval EFI_INVALID_PARAMETER   The value referenced by SecondaryLanguagesSize is not
1178                                   zero and SecondaryLanguages is NULL.
1179   @retval EFI_BUFFER_TOO_SMALL    The buffer specified by SecondaryLanguagesSize is
1180                                   too small to hold the returned information.
1181                                   SecondaryLanguageSize is updated to hold the size of
1182                                   the buffer required.
1183   @retval EFI_INVALID_LANGUAGE    The language specified by PrimaryLanguage is not
1184                                   present in the specified package list.
1185   @retval EFI_NOT_FOUND           The specified PackageList is not in the Database.
1186 
1187 **/
1188 EFI_STATUS
1189 EFIAPI
1190 HiiGetSecondaryLanguages (
1191   IN CONST EFI_HII_STRING_PROTOCOL   *This,
1192   IN EFI_HII_HANDLE                  PackageList,
1193   IN CONST CHAR8                     *PrimaryLanguage,
1194   IN OUT CHAR8                       *SecondaryLanguages,
1195   IN OUT UINTN                       *SecondaryLanguagesSize
1196   );
1197 
1198 //
1199 // EFI_HII_DATABASE_PROTOCOL protocol interfaces
1200 //
1201 
1202 
1203 /**
1204   This function adds the packages in the package list to the database and returns a handle. If there is a
1205   EFI_DEVICE_PATH_PROTOCOL associated with the DriverHandle, then this function will
1206   create a package of type EFI_PACKAGE_TYPE_DEVICE_PATH and add it to the package list.
1207 
1208   @param  This                    A pointer to the EFI_HII_DATABASE_PROTOCOL
1209                                   instance.
1210   @param  PackageList             A pointer to an EFI_HII_PACKAGE_LIST_HEADER
1211                                   structure.
1212   @param  DriverHandle            Associate the package list with this EFI handle.
1213                                   If a NULL is specified, this data will not be associate
1214                                   with any drivers and cannot have a callback induced.
1215   @param  Handle                  A pointer to the EFI_HII_HANDLE instance.
1216 
1217   @retval EFI_SUCCESS             The package list associated with the Handle was
1218                                   added to the HII database.
1219   @retval EFI_OUT_OF_RESOURCES    Unable to allocate necessary resources for the
1220                                   new database contents.
1221   @retval EFI_INVALID_PARAMETER   PackageList is NULL or Handle is NULL.
1222 
1223 **/
1224 EFI_STATUS
1225 EFIAPI
1226 HiiNewPackageList (
1227   IN CONST EFI_HII_DATABASE_PROTOCOL    *This,
1228   IN CONST EFI_HII_PACKAGE_LIST_HEADER  *PackageList,
1229   IN CONST EFI_HANDLE                   DriverHandle, OPTIONAL
1230   OUT EFI_HII_HANDLE                    *Handle
1231   );
1232 
1233 
1234 /**
1235   This function removes the package list that is associated with a handle Handle
1236   from the HII database. Before removing the package, any registered functions
1237   with the notification type REMOVE_PACK and the same package type will be called.
1238 
1239   @param  This                    A pointer to the EFI_HII_DATABASE_PROTOCOL
1240                                   instance.
1241   @param  Handle                  The handle that was registered to the data that
1242                                   is requested  for removal.
1243 
1244   @retval EFI_SUCCESS             The data associated with the Handle was removed
1245                                   from  the HII database.
1246   @retval EFI_NOT_FOUND           The specified Handle is not in database.
1247 
1248 **/
1249 EFI_STATUS
1250 EFIAPI
1251 HiiRemovePackageList (
1252   IN CONST EFI_HII_DATABASE_PROTOCOL    *This,
1253   IN EFI_HII_HANDLE                     Handle
1254   );
1255 
1256 
1257 /**
1258   This function updates the existing package list (which has the specified Handle)
1259   in the HII databases, using the new package list specified by PackageList.
1260 
1261   @param  This                    A pointer to the EFI_HII_DATABASE_PROTOCOL
1262                                   instance.
1263   @param  Handle                  The handle that was registered to the data that
1264                                   is  requested to be updated.
1265   @param  PackageList             A pointer to an EFI_HII_PACKAGE_LIST_HEADER
1266                                   package.
1267 
1268   @retval EFI_SUCCESS             The HII database was successfully updated.
1269   @retval EFI_OUT_OF_RESOURCES    Unable to allocate enough memory for the updated
1270                                   database.
1271   @retval EFI_INVALID_PARAMETER  PackageList was NULL.
1272   @retval EFI_NOT_FOUND          The specified Handle is not in database.
1273 
1274 **/
1275 EFI_STATUS
1276 EFIAPI
1277 HiiUpdatePackageList (
1278   IN CONST EFI_HII_DATABASE_PROTOCOL    *This,
1279   IN EFI_HII_HANDLE                     Handle,
1280   IN CONST EFI_HII_PACKAGE_LIST_HEADER  *PackageList
1281   );
1282 
1283 
1284 /**
1285   This function returns a list of the package handles of the specified type
1286   that are currently active in the database. The pseudo-type
1287   EFI_HII_PACKAGE_TYPE_ALL will cause all package handles to be listed.
1288 
1289   @param  This                    A pointer to the EFI_HII_DATABASE_PROTOCOL
1290                                   instance.
1291   @param  PackageType             Specifies the package type of the packages to
1292                                   list or EFI_HII_PACKAGE_TYPE_ALL for all packages
1293                                   to be listed.
1294   @param  PackageGuid             If PackageType is EFI_HII_PACKAGE_TYPE_GUID, then
1295                                   this  is the pointer to the GUID which must match
1296                                   the Guid field of EFI_HII_GUID_PACKAGE_GUID_HDR.
1297                                   Otherwise,  it must be NULL.
1298   @param  HandleBufferLength      On input, a pointer to the length of the handle
1299                                   buffer.  On output, the length of the handle
1300                                   buffer that is required for the handles found.
1301   @param  Handle                  An array of EFI_HII_HANDLE instances returned.
1302 
1303   @retval EFI_SUCCESS             The matching handles are outputed successfully.
1304                                   HandleBufferLength is updated with the actual length.
1305   @retval EFI_BUFFER_TO_SMALL     The HandleBufferLength parameter indicates that
1306                                   Handle is too small to support the number of
1307                                   handles. HandleBufferLength is updated with a
1308                                   value that will  enable the data to fit.
1309   @retval EFI_NOT_FOUND           No matching handle could not be found in
1310                                   database.
1311   @retval EFI_INVALID_PARAMETER   HandleBufferLength was NULL.
1312   @retval EFI_INVALID_PARAMETER   The value referenced by HandleBufferLength was not
1313                                   zero and Handle was NULL.
1314   @retval EFI_INVALID_PARAMETER   PackageType is not a EFI_HII_PACKAGE_TYPE_GUID but
1315                                   PackageGuid is not NULL, PackageType is a EFI_HII_
1316                                   PACKAGE_TYPE_GUID but PackageGuid is NULL.
1317 
1318 **/
1319 EFI_STATUS
1320 EFIAPI
1321 HiiListPackageLists (
1322   IN  CONST EFI_HII_DATABASE_PROTOCOL   *This,
1323   IN  UINT8                             PackageType,
1324   IN  CONST EFI_GUID                    *PackageGuid,
1325   IN  OUT UINTN                         *HandleBufferLength,
1326   OUT EFI_HII_HANDLE                    *Handle
1327   );
1328 
1329 
1330 /**
1331   This function will export one or all package lists in the database to a buffer.
1332   For each package list exported, this function will call functions registered
1333   with EXPORT_PACK and then copy the package list to the buffer.
1334 
1335   @param  This                    A pointer to the EFI_HII_DATABASE_PROTOCOL
1336                                   instance.
1337   @param  Handle                  An EFI_HII_HANDLE that corresponds to the desired
1338                                   package list in the HII database to export or
1339                                   NULL to indicate  all package lists should be
1340                                   exported.
1341   @param  BufferSize              On input, a pointer to the length of the buffer.
1342                                   On output, the length of the buffer that is
1343                                   required for the exported data.
1344   @param  Buffer                  A pointer to a buffer that will contain the
1345                                   results of  the export function.
1346 
1347   @retval EFI_SUCCESS             Package exported.
1348   @retval EFI_BUFFER_TO_SMALL     The HandleBufferLength parameter indicates that
1349                                   Handle is too small to support the number of
1350                                   handles.      HandleBufferLength is updated with
1351                                   a value that will enable the data to fit.
1352   @retval EFI_NOT_FOUND           The specifiecd Handle could not be found in the
1353                                   current database.
1354   @retval EFI_INVALID_PARAMETER   BufferSize was NULL.
1355   @retval EFI_INVALID_PARAMETER   The value referenced by BufferSize was not zero
1356                                   and Buffer was NULL.
1357 
1358 **/
1359 EFI_STATUS
1360 EFIAPI
1361 HiiExportPackageLists (
1362   IN  CONST EFI_HII_DATABASE_PROTOCOL   *This,
1363   IN  EFI_HII_HANDLE                    Handle,
1364   IN  OUT UINTN                         *BufferSize,
1365   OUT EFI_HII_PACKAGE_LIST_HEADER       *Buffer
1366   );
1367 
1368 
1369 /**
1370   This function registers a function which will be called when specified actions related to packages of
1371   the specified type occur in the HII database. By registering a function, other HII-related drivers are
1372   notified when specific package types are added, removed or updated in the HII database.
1373   Each driver or application which registers a notification should use
1374   EFI_HII_DATABASE_PROTOCOL.UnregisterPackageNotify() before exiting.
1375 
1376   @param  This                    A pointer to the EFI_HII_DATABASE_PROTOCOL
1377                                   instance.
1378   @param  PackageType             Specifies the package type of the packages to
1379                                   list or EFI_HII_PACKAGE_TYPE_ALL for all packages
1380                                   to be listed.
1381   @param  PackageGuid             If PackageType is EFI_HII_PACKAGE_TYPE_GUID, then
1382                                   this is the pointer to the GUID which must match
1383                                   the Guid field of
1384                                   EFI_HII_GUID_PACKAGE_GUID_HDR. Otherwise, it must
1385                                   be NULL.
1386   @param  PackageNotifyFn         Points to the function to be called when the
1387                                   event specified by
1388                                   NotificationType occurs.
1389   @param  NotifyType              Describes the types of notification which this
1390                                   function will be receiving.
1391   @param  NotifyHandle            Points to the unique handle assigned to the
1392                                   registered notification. Can be used in
1393                                   EFI_HII_DATABASE_PROTOCOL.UnregisterPackageNotify()
1394                                   to stop notifications.
1395 
1396   @retval EFI_SUCCESS             Notification registered successfully.
1397   @retval EFI_OUT_OF_RESOURCES    Unable to allocate necessary data structures
1398   @retval EFI_INVALID_PARAMETER   NotifyHandle is NULL.
1399   @retval EFI_INVALID_PARAMETER   PackageGuid is not NULL when PackageType is not
1400                                   EFI_HII_PACKAGE_TYPE_GUID.
1401   @retval EFI_INVALID_PARAMETER   PackageGuid is NULL when PackageType is
1402                                   EFI_HII_PACKAGE_TYPE_GUID.
1403 
1404 **/
1405 EFI_STATUS
1406 EFIAPI
1407 HiiRegisterPackageNotify (
1408   IN  CONST EFI_HII_DATABASE_PROTOCOL   *This,
1409   IN  UINT8                             PackageType,
1410   IN  CONST EFI_GUID                    *PackageGuid,
1411   IN  CONST EFI_HII_DATABASE_NOTIFY     PackageNotifyFn,
1412   IN  EFI_HII_DATABASE_NOTIFY_TYPE      NotifyType,
1413   OUT EFI_HANDLE                        *NotifyHandle
1414   );
1415 
1416 
1417 /**
1418   Removes the specified HII database package-related notification.
1419 
1420   @param  This                    A pointer to the EFI_HII_DATABASE_PROTOCOL
1421                                   instance.
1422   @param  NotificationHandle      The handle of the notification function being
1423                                   unregistered.
1424 
1425   @retval EFI_SUCCESS             Notification is unregistered successfully.
1426   @retval EFI_NOT_FOUND          The incoming notification handle does not exist
1427                            in current hii database.
1428 
1429 **/
1430 EFI_STATUS
1431 EFIAPI
1432 HiiUnregisterPackageNotify (
1433   IN CONST EFI_HII_DATABASE_PROTOCOL    *This,
1434   IN EFI_HANDLE                         NotificationHandle
1435   );
1436 
1437 
1438 /**
1439   This routine retrieves an array of GUID values for each keyboard layout that
1440   was previously registered in the system.
1441 
1442   @param  This                    A pointer to the EFI_HII_DATABASE_PROTOCOL
1443                                   instance.
1444   @param  KeyGuidBufferLength     On input, a pointer to the length of the keyboard
1445                                   GUID  buffer. On output, the length of the handle
1446                                   buffer  that is required for the handles found.
1447   @param  KeyGuidBuffer           An array of keyboard layout GUID instances
1448                                   returned.
1449 
1450   @retval EFI_SUCCESS             KeyGuidBuffer was updated successfully.
1451   @retval EFI_BUFFER_TOO_SMALL    The KeyGuidBufferLength parameter indicates
1452                                   that KeyGuidBuffer is too small to support the
1453                                   number of GUIDs. KeyGuidBufferLength is
1454                                   updated with a value that will enable the data to
1455                                   fit.
1456   @retval EFI_INVALID_PARAMETER   The KeyGuidBufferLength is NULL.
1457   @retval EFI_INVALID_PARAMETER   The value referenced by KeyGuidBufferLength is not
1458                                   zero and KeyGuidBuffer is NULL.
1459   @retval EFI_NOT_FOUND           There was no keyboard layout.
1460 
1461 **/
1462 EFI_STATUS
1463 EFIAPI
1464 HiiFindKeyboardLayouts (
1465   IN  CONST EFI_HII_DATABASE_PROTOCOL   *This,
1466   IN  OUT UINT16                        *KeyGuidBufferLength,
1467   OUT EFI_GUID                          *KeyGuidBuffer
1468   );
1469 
1470 
1471 /**
1472   This routine retrieves the requested keyboard layout. The layout is a physical description of the keys
1473   on a keyboard and the character(s) that are associated with a particular set of key strokes.
1474 
1475   @param  This                    A pointer to the EFI_HII_DATABASE_PROTOCOL
1476                                   instance.
1477   @param  KeyGuid                 A pointer to the unique ID associated with a
1478                                   given keyboard layout. If KeyGuid is NULL then
1479                                   the current layout will be retrieved.
1480   @param  KeyboardLayoutLength    On input, a pointer to the length of the
1481                                   KeyboardLayout buffer.  On output, the length of
1482                                   the data placed into KeyboardLayout.
1483   @param  KeyboardLayout          A pointer to a buffer containing the retrieved
1484                                   keyboard layout.
1485 
1486   @retval EFI_SUCCESS             The keyboard layout was retrieved successfully.
1487   @retval EFI_NOT_FOUND           The requested keyboard layout was not found.
1488   @retval EFI_INVALID_PARAMETER   The KeyboardLayout or KeyboardLayoutLength was
1489                                   NULL.
1490 
1491 **/
1492 EFI_STATUS
1493 EFIAPI
1494 HiiGetKeyboardLayout (
1495   IN  CONST EFI_HII_DATABASE_PROTOCOL   *This,
1496   IN  CONST EFI_GUID                          *KeyGuid,
1497   IN OUT UINT16                         *KeyboardLayoutLength,
1498   OUT EFI_HII_KEYBOARD_LAYOUT           *KeyboardLayout
1499   );
1500 
1501 
1502 /**
1503   This routine sets the default keyboard layout to the one referenced by KeyGuid. When this routine
1504   is called, an event will be signaled of the EFI_HII_SET_KEYBOARD_LAYOUT_EVENT_GUID
1505   group type. This is so that agents which are sensitive to the current keyboard layout being changed
1506   can be notified of this change.
1507 
1508   @param  This                    A pointer to the EFI_HII_DATABASE_PROTOCOL
1509                                   instance.
1510   @param  KeyGuid                 A pointer to the unique ID associated with a
1511                                   given keyboard layout.
1512 
1513   @retval EFI_SUCCESS             The current keyboard layout was successfully set.
1514   @retval EFI_NOT_FOUND           The referenced keyboard layout was not found, so
1515                                   action was taken.
1516   @retval EFI_INVALID_PARAMETER   The KeyGuid was NULL.
1517 
1518 **/
1519 EFI_STATUS
1520 EFIAPI
1521 HiiSetKeyboardLayout (
1522   IN CONST EFI_HII_DATABASE_PROTOCOL          *This,
1523   IN CONST EFI_GUID                           *KeyGuid
1524   );
1525 
1526 
1527 /**
1528   Return the EFI handle associated with a package list.
1529 
1530   @param  This                    A pointer to the EFI_HII_DATABASE_PROTOCOL
1531                                   instance.
1532   @param  PackageListHandle       An EFI_HII_HANDLE that corresponds to the desired
1533                                   package list in the HIIdatabase.
1534   @param  DriverHandle            On return, contains the EFI_HANDLE which was
1535                                   registered with the package list in
1536                                   NewPackageList().
1537 
1538   @retval EFI_SUCCESS             The DriverHandle was returned successfully.
1539   @retval EFI_INVALID_PARAMETER   The PackageListHandle was not valid or
1540                                   DriverHandle was NULL.
1541 
1542 **/
1543 EFI_STATUS
1544 EFIAPI
1545 HiiGetPackageListHandle (
1546   IN  CONST EFI_HII_DATABASE_PROTOCOL         *This,
1547   IN  EFI_HII_HANDLE                    PackageListHandle,
1548   OUT EFI_HANDLE                        *DriverHandle
1549   );
1550 
1551 //
1552 // EFI_HII_CONFIG_ROUTING_PROTOCOL interfaces
1553 //
1554 
1555 
1556 /**
1557   This function allows a caller to extract the current configuration
1558   for one or more named elements from one or more drivers.
1559 
1560   @param  This                    A pointer to the EFI_HII_CONFIG_ROUTING_PROTOCOL
1561                                   instance.
1562   @param  Request                 A null-terminated Unicode string in
1563                                   <MultiConfigRequest> format.
1564   @param  Progress                On return, points to a character in the Request
1565                                   string. Points to the string's null terminator if
1566                                   request was successful. Points to the most recent
1567                                   & before the first failing name / value pair (or
1568                                   the beginning of the string if the failure is in
1569                                   the first name / value pair) if the request was
1570                                   not successful.
1571   @param  Results                 Null-terminated Unicode string in
1572                                   <MultiConfigAltResp> format which has all values
1573                                   filled in for the names in the Request string.
1574                                   String to be allocated by the called function.
1575 
1576   @retval EFI_SUCCESS             The Results string is filled with the values
1577                                   corresponding to all requested names.
1578   @retval EFI_OUT_OF_RESOURCES    Not enough memory to store the parts of the
1579                                   results that must be stored awaiting possible
1580                                   future        protocols.
1581   @retval EFI_NOT_FOUND           Routing data doesn't match any known driver.
1582                                      Progress set to the "G" in "GUID" of the
1583                                   routing  header that doesn't match. Note: There
1584                                   is no         requirement that all routing data
1585                                   be validated before any configuration extraction.
1586   @retval EFI_INVALID_PARAMETER   For example, passing in a NULL for the Request
1587                                   parameter would result in this type of error. The
1588                                   Progress parameter is set to NULL.
1589   @retval EFI_INVALID_PARAMETER   Illegal syntax. Progress set to most recent &
1590                                   before the error or the beginning of the string.
1591   @retval EFI_INVALID_PARAMETER   Unknown name. Progress points to the & before the
1592                                   name in question.
1593 
1594 **/
1595 EFI_STATUS
1596 EFIAPI
1597 HiiConfigRoutingExtractConfig (
1598   IN  CONST EFI_HII_CONFIG_ROUTING_PROTOCOL  *This,
1599   IN  CONST EFI_STRING                       Request,
1600   OUT EFI_STRING                             *Progress,
1601   OUT EFI_STRING                             *Results
1602   );
1603 
1604 
1605 /**
1606   This function allows the caller to request the current configuration for the
1607   entirety of the current HII database and returns the data in a null-terminated Unicode string.
1608 
1609   @param  This                    A pointer to the EFI_HII_CONFIG_ROUTING_PROTOCOL
1610                                   instance.
1611   @param  Results                 Null-terminated Unicode string in
1612                                   <MultiConfigAltResp> format which has all values
1613                                   filled in for the entirety of the current HII
1614                                   database. String to be allocated by the  called
1615                                   function. De-allocation is up to the caller.
1616 
1617   @retval EFI_SUCCESS             The Results string is filled with the values
1618                                   corresponding to all requested names.
1619   @retval EFI_OUT_OF_RESOURCES    Not enough memory to store the parts of the
1620                                   results that must be stored awaiting possible
1621                                   future        protocols.
1622   @retval EFI_INVALID_PARAMETER   For example, passing in a NULL for the Results
1623                                   parameter would result in this type of error.
1624 
1625 **/
1626 EFI_STATUS
1627 EFIAPI
1628 HiiConfigRoutingExportConfig (
1629   IN  CONST EFI_HII_CONFIG_ROUTING_PROTOCOL  *This,
1630   OUT EFI_STRING                             *Results
1631   );
1632 
1633 
1634 /**
1635   This function processes the results of processing forms and routes it to the
1636   appropriate handlers or storage.
1637 
1638   @param  This                    A pointer to the EFI_HII_CONFIG_ROUTING_PROTOCOL
1639                                   instance.
1640   @param  Configuration           A null-terminated Unicode string in
1641                                   <MulltiConfigResp> format.
1642   @param  Progress                A pointer to a string filled in with the offset
1643                                   of the most recent & before the first failing
1644                                   name / value pair (or the beginning of the string
1645                                   if the failure is in the first name / value pair)
1646                                   or the terminating NULL if all was successful.
1647 
1648   @retval EFI_SUCCESS             The results have been distributed or are awaiting
1649                                   distribution.
1650   @retval EFI_OUT_OF_RESOURCES    Not enough memory to store the parts of the
1651                                   results that must be stored awaiting possible
1652                                   future        protocols.
1653   @retval EFI_INVALID_PARAMETER   Passing in a NULL for the Configuration parameter
1654                                   would result in this type of error.
1655   @retval EFI_NOT_FOUND           Target for the specified routing data was not
1656                                   found.
1657 
1658 **/
1659 EFI_STATUS
1660 EFIAPI
1661 HiiConfigRoutingRouteConfig (
1662   IN  CONST EFI_HII_CONFIG_ROUTING_PROTOCOL  *This,
1663   IN  CONST EFI_STRING                       Configuration,
1664   OUT EFI_STRING                             *Progress
1665   );
1666 
1667 
1668 
1669 /**
1670   This helper function is to be called by drivers to map configuration data stored
1671   in byte array ("block") formats such as UEFI Variables into current configuration strings.
1672 
1673   @param  This                    A pointer to the EFI_HII_CONFIG_ROUTING_PROTOCOL
1674                                   instance.
1675   @param  ConfigRequest           A null-terminated Unicode string in
1676                                   <ConfigRequest> format.
1677   @param  Block                   Array of bytes defining the block's
1678                                   configuration.
1679   @param  BlockSize               Length in bytes of Block.
1680   @param  Config                  Filled-in configuration string. String allocated
1681                                   by  the function. Returned only if call is
1682                                   successful.
1683   @param  Progress                A pointer to a string filled in with the offset
1684                                   of  the most recent & before the first failing
1685                                   name/value pair (or the beginning of the string
1686                                   if the failure is in the first name / value pair)
1687                                   or the terminating NULL if all was successful.
1688 
1689   @retval EFI_SUCCESS             The request succeeded. Progress points to the
1690                                   null terminator at the end of the ConfigRequest
1691                                         string.
1692   @retval EFI_OUT_OF_RESOURCES    Not enough memory to allocate Config.
1693                                   Progress points to the first character of
1694                                   ConfigRequest.
1695   @retval EFI_INVALID_PARAMETER   Passing in a NULL for the ConfigRequest or
1696                                   Block parameter would result in this type of
1697                                   error. Progress points to the first character of
1698                                   ConfigRequest.
1699   @retval EFI_NOT_FOUND           Target for the specified routing data was not
1700                                   found. Progress points to the "G" in "GUID" of
1701                                   the      errant routing data.
1702   @retval EFI_DEVICE_ERROR        Block not large enough. Progress undefined.
1703   @retval EFI_INVALID_PARAMETER   Encountered non <BlockName> formatted string.
1704                                        Block is left updated and Progress points at
1705                                   the '&' preceding the first non-<BlockName>.
1706 
1707 **/
1708 EFI_STATUS
1709 EFIAPI
1710 HiiBlockToConfig (
1711   IN  CONST EFI_HII_CONFIG_ROUTING_PROTOCOL  *This,
1712   IN  CONST EFI_STRING                       ConfigRequest,
1713   IN  CONST UINT8                            *Block,
1714   IN  CONST UINTN                            BlockSize,
1715   OUT EFI_STRING                             *Config,
1716   OUT EFI_STRING                             *Progress
1717   );
1718 
1719 
1720 /**
1721   This helper function is to be called by drivers to map configuration strings
1722   to configurations stored in byte array ("block") formats such as UEFI Variables.
1723 
1724   @param  This                    A pointer to the EFI_HII_CONFIG_ROUTING_PROTOCOL
1725                                   instance.
1726   @param  ConfigResp              A null-terminated Unicode string in <ConfigResp>
1727                                   format.
1728   @param  Block                   A possibly null array of bytes representing the
1729                                   current  block. Only bytes referenced in the
1730                                   ConfigResp string  in the block are modified. If
1731                                   this parameter is null or if the *BlockSize
1732                                   parameter is (on input) shorter than required by
1733                                   the Configuration string, only the BlockSize
1734                                   parameter is updated and an appropriate status
1735                                   (see below)  is returned.
1736   @param  BlockSize               The length of the Block in units of UINT8.  On
1737                                   input, this is the size of the Block. On output,
1738                                   if successful, contains the largest index of the
1739                                   modified byte in the Block, or the required buffer
1740                                   size if the Block is not large enough.
1741   @param  Progress                On return, points to an element of the ConfigResp
1742                                    string filled in with the offset of the most
1743                                   recent '&' before the first failing name / value
1744                                   pair (or  the beginning of the string if the
1745                                   failure is in the  first name / value pair) or
1746                                   the terminating NULL if all was successful.
1747 
1748   @retval EFI_SUCCESS             The request succeeded. Progress points to the
1749                                   null terminator at the end of the ConfigResp
1750                                   string.
1751   @retval EFI_OUT_OF_RESOURCES    Not enough memory to allocate Config.
1752                                   Progress points to the first character of
1753                                   ConfigResp.
1754   @retval EFI_INVALID_PARAMETER   Passing in a NULL for the ConfigResp or
1755                                   Block parameter would result in this type of
1756                                   error. Progress points to the first character of
1757                                            ConfigResp.
1758   @retval EFI_NOT_FOUND           Target for the specified routing data was not
1759                                   found. Progress points to the "G" in "GUID" of
1760                                   the      errant routing data.
1761   @retval EFI_INVALID_PARAMETER   Encountered non <BlockName> formatted name /
1762                                   value pair. Block is left updated and
1763                                   Progress points at the '&' preceding the first
1764                                   non-<BlockName>.
1765   @retval EFI_BUFFER_TOO_SMALL    Block not large enough. Progress undefined.
1766                                   BlockSize is updated with the required buffer size.
1767 
1768 **/
1769 EFI_STATUS
1770 EFIAPI
1771 HiiConfigToBlock (
1772   IN     CONST EFI_HII_CONFIG_ROUTING_PROTOCOL *This,
1773   IN     CONST EFI_STRING                      ConfigResp,
1774   IN OUT UINT8                                 *Block,
1775   IN OUT UINTN                                 *BlockSize,
1776   OUT    EFI_STRING                            *Progress
1777   );
1778 
1779 
1780 /**
1781   This helper function is to be called by drivers to extract portions of
1782   a larger configuration string.
1783 
1784   @param  This                    A pointer to the EFI_HII_CONFIG_ROUTING_PROTOCOL
1785                                   instance.
1786   @param  Configuration           A null-terminated Unicode string in
1787                                   <MultiConfigAltResp> format.
1788   @param  Guid                    A pointer to the GUID value to search for in the
1789                                   routing portion of the ConfigResp string when
1790                                   retrieving  the requested data. If Guid is NULL,
1791                                   then all GUID  values will be searched for.
1792   @param  Name                    A pointer to the NAME value to search for in the
1793                                   routing portion of the ConfigResp string when
1794                                   retrieving  the requested data. If Name is NULL,
1795                                   then all Name  values will be searched for.
1796   @param  DevicePath              A pointer to the PATH value to search for in the
1797                                   routing portion of the ConfigResp string when
1798                                   retrieving  the requested data. If DevicePath is
1799                                   NULL, then all  DevicePath values will be
1800                                   searched for.
1801   @param  AltCfgId                A pointer to the ALTCFG value to search for in
1802                                   the  routing portion of the ConfigResp string
1803                                   when retrieving  the requested data.  If this
1804                                   parameter is NULL,  then the current setting will
1805                                   be retrieved.
1806   @param  AltCfgResp              A pointer to a buffer which will be allocated by
1807                                   the  function which contains the retrieved string
1808                                   as requested.   This buffer is only allocated if
1809                                   the call was successful.
1810 
1811   @retval EFI_SUCCESS             The request succeeded. The requested data was
1812                                   extracted  and placed in the newly allocated
1813                                   AltCfgResp buffer.
1814   @retval EFI_OUT_OF_RESOURCES    Not enough memory to allocate AltCfgResp.
1815   @retval EFI_INVALID_PARAMETER   Any parameter is invalid.
1816   @retval EFI_NOT_FOUND           Target for the specified routing data was not
1817                                   found.
1818 
1819 **/
1820 EFI_STATUS
1821 EFIAPI
1822 HiiGetAltCfg (
1823   IN  CONST EFI_HII_CONFIG_ROUTING_PROTOCOL    *This,
1824   IN  CONST EFI_STRING                         Configuration,
1825   IN  CONST EFI_GUID                           *Guid,
1826   IN  CONST EFI_STRING                         Name,
1827   IN  CONST EFI_DEVICE_PATH_PROTOCOL           *DevicePath,
1828   IN  CONST UINT16                             *AltCfgId,
1829   OUT EFI_STRING                               *AltCfgResp
1830   );
1831 
1832 /**
1833 
1834   This function accepts a <MultiKeywordResp> formatted string, finds the associated
1835   keyword owners, creates a <MultiConfigResp> string from it and forwards it to the
1836   EFI_HII_ROUTING_PROTOCOL.RouteConfig function.
1837 
1838   If there is an issue in resolving the contents of the KeywordString, then the
1839   function returns an error and also sets the Progress and ProgressErr with the
1840   appropriate information about where the issue occurred and additional data about
1841   the nature of the issue.
1842 
1843   In the case when KeywordString containing multiple keywords, when an EFI_NOT_FOUND
1844   error is generated during processing the second or later keyword element, the system
1845   storage associated with earlier keywords is not modified. All elements of the
1846   KeywordString must successfully pass all tests for format and access prior to making
1847   any modifications to storage.
1848 
1849   In the case when EFI_DEVICE_ERROR is returned from the processing of a KeywordString
1850   containing multiple keywords, the state of storage associated with earlier keywords
1851   is undefined.
1852 
1853 
1854   @param This             Pointer to the EFI_KEYWORD_HANDLER _PROTOCOL instance.
1855 
1856   @param KeywordString    A null-terminated string in <MultiKeywordResp> format.
1857 
1858   @param Progress         On return, points to a character in the KeywordString.
1859                           Points to the string's NULL terminator if the request
1860                           was successful. Points to the most recent '&' before
1861                           the first failing string element if the request was
1862                           not successful.
1863 
1864   @param ProgressErr      If during the processing of the KeywordString there was
1865                           a failure, this parameter gives additional information
1866                           about the possible source of the problem. The various
1867                           errors are defined in "Related Definitions" below.
1868 
1869 
1870   @retval EFI_SUCCESS             The specified action was completed successfully.
1871 
1872   @retval EFI_INVALID_PARAMETER   One or more of the following are TRUE:
1873                                   1. KeywordString is NULL.
1874                                   2. Parsing of the KeywordString resulted in an
1875                                      error. See Progress and ProgressErr for more data.
1876 
1877   @retval EFI_NOT_FOUND           An element of the KeywordString was not found.
1878                                   See ProgressErr for more data.
1879 
1880   @retval EFI_OUT_OF_RESOURCES    Required system resources could not be allocated.
1881                                   See ProgressErr for more data.
1882 
1883   @retval EFI_ACCESS_DENIED       The action violated system policy. See ProgressErr
1884                                   for more data.
1885 
1886   @retval EFI_DEVICE_ERROR        An unexpected system error occurred. See ProgressErr
1887                                   for more data.
1888 
1889 **/
1890 EFI_STATUS
1891 EFIAPI
1892 EfiConfigKeywordHandlerSetData (
1893   IN EFI_CONFIG_KEYWORD_HANDLER_PROTOCOL *This,
1894   IN CONST EFI_STRING                    KeywordString,
1895   OUT EFI_STRING                         *Progress,
1896   OUT UINT32                             *ProgressErr
1897   );
1898 
1899 /**
1900 
1901   This function accepts a <MultiKeywordRequest> formatted string, finds the underlying
1902   keyword owners, creates a <MultiConfigRequest> string from it and forwards it to the
1903   EFI_HII_ROUTING_PROTOCOL.ExtractConfig function.
1904 
1905   If there is an issue in resolving the contents of the KeywordString, then the function
1906   returns an EFI_INVALID_PARAMETER and also set the Progress and ProgressErr with the
1907   appropriate information about where the issue occurred and additional data about the
1908   nature of the issue.
1909 
1910   In the case when KeywordString is NULL, or contains multiple keywords, or when
1911   EFI_NOT_FOUND is generated while processing the keyword elements, the Results string
1912   contains values returned for all keywords processed prior to the keyword generating the
1913   error but no values for the keyword with error or any following keywords.
1914 
1915 
1916   @param This           Pointer to the EFI_KEYWORD_HANDLER _PROTOCOL instance.
1917 
1918   @param NameSpaceId    A null-terminated string containing the platform configuration
1919                         language to search through in the system. If a NULL is passed
1920                         in, then it is assumed that any platform configuration language
1921                         with the prefix of "x-UEFI-" are searched.
1922 
1923   @param KeywordString  A null-terminated string in <MultiKeywordRequest> format. If a
1924                         NULL is passed in the KeywordString field, all of the known
1925                         keywords in the system for the NameSpaceId specified are
1926                         returned in the Results field.
1927 
1928   @param Progress       On return, points to a character in the KeywordString. Points
1929                         to the string's NULL terminator if the request was successful.
1930                         Points to the most recent '&' before the first failing string
1931                         element if the request was not successful.
1932 
1933   @param ProgressErr    If during the processing of the KeywordString there was a
1934                         failure, this parameter gives additional information about the
1935                         possible source of the problem. See the definitions in SetData()
1936                         for valid value definitions.
1937 
1938   @param Results        A null-terminated string in <MultiKeywordResp> format is returned
1939                         which has all the values filled in for the keywords in the
1940                         KeywordString. This is a callee-allocated field, and must be freed
1941                         by the caller after being used.
1942 
1943   @retval EFI_SUCCESS             The specified action was completed successfully.
1944 
1945   @retval EFI_INVALID_PARAMETER   One or more of the following are TRUE:
1946                                   1.Progress, ProgressErr, or Resuts is NULL.
1947                                   2.Parsing of the KeywordString resulted in an error. See
1948                                     Progress and ProgressErr for more data.
1949 
1950 
1951   @retval EFI_NOT_FOUND           An element of the KeywordString was not found. See
1952                                   ProgressErr for more data.
1953 
1954   @retval EFI_NOT_FOUND           The NamespaceId specified was not found.  See ProgressErr
1955                                   for more data.
1956 
1957   @retval EFI_OUT_OF_RESOURCES    Required system resources could not be allocated.  See
1958                                   ProgressErr for more data.
1959 
1960   @retval EFI_ACCESS_DENIED       The action violated system policy.  See ProgressErr for
1961                                   more data.
1962 
1963   @retval EFI_DEVICE_ERROR        An unexpected system error occurred.  See ProgressErr
1964                                   for more data.
1965 
1966 **/
1967 EFI_STATUS
1968 EFIAPI
1969 EfiConfigKeywordHandlerGetData (
1970   IN EFI_CONFIG_KEYWORD_HANDLER_PROTOCOL  *This,
1971   IN CONST EFI_STRING                     NameSpaceId, OPTIONAL
1972   IN CONST EFI_STRING                     KeywordString, OPTIONAL
1973   OUT EFI_STRING                          *Progress,
1974   OUT UINT32                              *ProgressErr,
1975   OUT EFI_STRING                          *Results
1976   );
1977 
1978 /**
1979   Compare whether two names of languages are identical.
1980 
1981   @param  Language1              Name of language 1 from StringPackage
1982   @param  Language2              Name of language 2 to be compared with language 1.
1983 
1984   @retval TRUE                   same
1985   @retval FALSE                  not same
1986 
1987 **/
1988 BOOLEAN
1989 HiiCompareLanguage (
1990   IN  CHAR8  *Language1,
1991   IN  CHAR8  *Language2
1992   )
1993 ;
1994 
1995 /**
1996   Retrieves a pointer to the a Null-terminated ASCII string containing the list
1997   of languages that an HII handle in the HII Database supports.  The returned
1998   string is allocated using AllocatePool().  The caller is responsible for freeing
1999   the returned string using FreePool().  The format of the returned string follows
2000   the language format assumed the HII Database.
2001 
2002   If HiiHandle is NULL, then ASSERT().
2003 
2004   @param[in]  HiiHandle  A handle that was previously registered in the HII Database.
2005 
2006   @retval NULL   HiiHandle is not registered in the HII database
2007   @retval NULL   There are not enough resources available to retrieve the suported
2008                  languages.
2009   @retval NULL   The list of suported languages could not be retrieved.
2010   @retval Other  A pointer to the Null-terminated ASCII string of supported languages.
2011 
2012 **/
2013 CHAR8 *
2014 GetSupportedLanguages (
2015   IN EFI_HII_HANDLE           HiiHandle
2016   );
2017 
2018 //
2019 // Global variables
2020 //
2021 extern EFI_EVENT gHiiKeyboardLayoutChanged;
2022 #endif
2023