edk2/EdkCompatibilityPkg/Foundation/Protocol/Performance/Performance.h:
[mirror_edk2.git] / MdeModulePkg / Universal / HiiDatabaseDxe / HiiDatabase.h
CommitLineData
93e3992d 1/** @file
2
3Copyright (c) 2007, Intel Corporation
4All rights reserved. This program and the accompanying materials
5are licensed and made available under the terms and conditions of the BSD License
6which accompanies this distribution. The full text of the license may be found at
7http://opensource.org/licenses/bsd-license.php
8
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12Module Name:
13
14 HiiDatabase.h
15
16Abstract:
17
18 Private structures definitions in HiiDatabase.
19
20Revision History
21
22
23**/
24
25#ifndef __HII_DATABASE_PRIVATE_H__
26#define __HII_DATABASE_PRIVATE_H__
27
28#include <PiDxe.h>
29
30#include <Protocol/ConsoleControl.h>
31#include <Protocol/DevicePath.h>
32#include <Protocol/HiiFont.h>
33#include <Protocol/HiiImage.h>
34#include <Protocol/HiiString.h>
35#include <Protocol/HiiDatabase.h>
36#include <Protocol/HiiConfigRouting.h>
37#include <Protocol/HiiConfigAccess.h>
38#include <Protocol/SimpleTextOut.h>
39
40#include <Guid/HiiKeyBoardLayout.h>
41
42
43#include <Library/DebugLib.h>
44#include <Library/BaseMemoryLib.h>
45#include <Library/UefiDriverEntryPoint.h>
46#include <Library/UefiBootServicesTableLib.h>
47#include <Library/BaseLib.h>
48#include <Library/DevicePathLib.h>
49#include <Library/MemoryAllocationLib.h>
50
51#define HII_DATABASE_NOTIFY_GUID \
52 { \
30d27d15 53 0xc1c76, 0xd79e, 0x42fe, {0x86, 0xb, 0x8b, 0xe8, 0x7b, 0x3e, 0x7a, 0x78} \
93e3992d 54 }
55
56#define MAX_STRING_LENGTH 1024
57#define MAX_FONT_NAME_LEN 256
58#define NARROW_BASELINE 15
59#define WIDE_BASELINE 14
60#define SYS_FONT_INFO_MASK 0x37
61#define REPLACE_UNKNOWN_GLYPH 0xFFFD
62#define PROPORTIONAL_GLYPH 0x80
63#define NARROW_GLYPH 0x40
64
65#define BITMAP_LEN_1_BIT(Width, Height) (((Width) + 7) / 8 * (Height))
66#define BITMAP_LEN_4_BIT(Width, Height) (((Width) + 1) / 2 * (Height))
67#define BITMAP_LEN_8_BIT(Width, Height) ((Width) * (Height))
68#define BITMAP_LEN_24_BIT(Width, Height) ((Width) * (Height) * 3)
69
70//
71// Storage types
72//
73#define EFI_HII_VARSTORE_BUFFER 0
74#define EFI_HII_VARSTORE_NAME_VALUE 1
75#define EFI_HII_VARSTORE_EFI_VARIABLE 2
76
77#define HII_FORMSET_STORAGE_SIGNATURE EFI_SIGNATURE_32 ('H', 'S', 'T', 'G')
78typedef struct {
79 UINTN Signature;
80 LIST_ENTRY Entry;
81
82 EFI_HII_HANDLE HiiHandle;
83 EFI_HANDLE DriverHandle;
84
85 UINT8 Type; // EFI_HII_VARSTORE_BUFFER, EFI_HII_VARSTORE_NAME_VALUE, EFI_HII_VARSTORE_EFI_VARIABLE
86 EFI_GUID Guid;
87 CHAR16 *Name;
88 UINT16 Size;
89} HII_FORMSET_STORAGE;
90
91#define HII_FORMSET_STORAGE_FROM_LINK(a) CR (a, HII_FORMSET_STORAGE, Link, HII_FORMSET_STORAGE_SIGNATURE)
92
93
94//
95// String Package definitions
96//
97#define HII_STRING_PACKAGE_SIGNATURE EFI_SIGNATURE_32 ('h','i','s','p')
98typedef struct _HII_STRING_PACKAGE_INSTANCE {
99 UINTN Signature;
100 EFI_HII_STRING_PACKAGE_HDR *StringPkgHdr;
101 UINT8 *StringBlock;
102 LIST_ENTRY StringEntry;
103 LIST_ENTRY FontInfoList; // local font info list
104 UINT8 FontId;
105} HII_STRING_PACKAGE_INSTANCE;
106
107//
108// Form Package definitions
109//
110#define HII_IFR_PACKAGE_SIGNATURE EFI_SIGNATURE_32 ('h','f','r','p')
111typedef struct _HII_IFR_PACKAGE_INSTANCE {
112 UINTN Signature;
113 EFI_HII_PACKAGE_HEADER FormPkgHdr;
114 UINT8 *IfrData;
115 LIST_ENTRY IfrEntry;
116} HII_IFR_PACKAGE_INSTANCE;
117
118//
119// Simple Font Package definitions
120//
121#define HII_S_FONT_PACKAGE_SIGNATURE EFI_SIGNATURE_32 ('h','s','f','p')
122typedef struct _HII_SIMPLE_FONT_PACKAGE_INSTANCE {
123 UINTN Signature;
124 EFI_HII_SIMPLE_FONT_PACKAGE_HDR *SimpleFontPkgHdr;
125 LIST_ENTRY SimpleFontEntry;
126} HII_SIMPLE_FONT_PACKAGE_INSTANCE;
127
128//
129// Font Package definitions
130//
131#define HII_FONT_PACKAGE_SIGNATURE EFI_SIGNATURE_32 ('h','i','f','p')
132typedef struct _HII_FONT_PACKAGE_INSTANCE {
133 UINTN Signature;
134 EFI_HII_FONT_PACKAGE_HDR *FontPkgHdr;
135 UINT8 *GlyphBlock;
136 LIST_ENTRY FontEntry;
137 LIST_ENTRY GlyphInfoList;
138} HII_FONT_PACKAGE_INSTANCE;
139
140#define HII_GLYPH_INFO_SIGNATURE EFI_SIGNATURE_32 ('h','g','i','s')
141typedef struct _HII_GLYPH_INFO {
142 UINTN Signature;
143 LIST_ENTRY Entry;
144 CHAR16 CharId;
145 EFI_HII_GLYPH_INFO Cell;
146} HII_GLYPH_INFO;
147
148#define HII_FONT_INFO_SIGNATURE EFI_SIGNATURE_32 ('h','l','f','i')
149typedef struct _HII_FONT_INFO {
150 UINTN Signature;
151 LIST_ENTRY Entry;
152 LIST_ENTRY *GlobalEntry;
153 UINT8 FontId;
154} HII_FONT_INFO;
155
156#define HII_GLOBAL_FONT_INFO_SIGNATURE EFI_SIGNATURE_32 ('h','g','f','i')
157typedef struct _HII_GLOBAL_FONT_INFO {
158 UINTN Signature;
159 LIST_ENTRY Entry;
160 HII_FONT_PACKAGE_INSTANCE *FontPackage;
161 UINTN FontInfoSize;
162 EFI_FONT_INFO *FontInfo;
163} HII_GLOBAL_FONT_INFO;
164
165//
166// Image Package definitions
167//
168
169#define HII_PIXEL_MASK 0x80
170
171typedef struct _HII_IMAGE_PACKAGE_INSTANCE {
172 EFI_HII_IMAGE_PACKAGE_HDR ImagePkgHdr;
173 UINT32 ImageBlockSize;
174 UINT32 PaletteInfoSize;
175 UINT8 *ImageBlock;
176 UINT8 *PaletteBlock;
177} HII_IMAGE_PACKAGE_INSTANCE;
178
179//
180// Keyboard Layout Pacakge definitions
181//
182#define HII_KB_LAYOUT_PACKAGE_SIGNATURE EFI_SIGNATURE_32 ('h','k','l','p')
183typedef struct _HII_KEYBOARD_LAYOUT_PACKAGE_INSTANCE {
184 UINTN Signature;
185 UINT8 *KeyboardPkg;
186 LIST_ENTRY KeyboardEntry;
187} HII_KEYBOARD_LAYOUT_PACKAGE_INSTANCE;
188
189//
190// Guid Package definitions
191//
192#define HII_GUID_PACKAGE_SIGNATURE EFI_SIGNATURE_32 ('h','i','g','p')
193typedef struct _HII_GUID_PACKAGE_INSTANCE {
194 UINTN Signature;
195 UINT8 *GuidPkg;
196 LIST_ENTRY GuidEntry;
197} HII_GUID_PACKAGE_INSTANCE;
198
199//
200// A package list can contain only one or less than one device path package.
201// This rule also applies to image package since ImageId can not be duplicate.
202//
203typedef struct _HII_DATABASE_PACKAGE_LIST_INSTANCE {
204 EFI_HII_PACKAGE_LIST_HEADER PackageListHdr;
205 LIST_ENTRY GuidPkgHdr;
206 LIST_ENTRY FormPkgHdr;
207 LIST_ENTRY KeyboardLayoutHdr;
208 LIST_ENTRY StringPkgHdr;
209 LIST_ENTRY FontPkgHdr;
210 HII_IMAGE_PACKAGE_INSTANCE *ImagePkg;
211 LIST_ENTRY SimpleFontPkgHdr;
212 UINT8 *DevicePathPkg;
213} HII_DATABASE_PACKAGE_LIST_INSTANCE;
214
215#define HII_HANDLE_SIGNATURE EFI_SIGNATURE_32 ('h','i','h','l')
216
217typedef struct {
218 UINTN Signature;
219 LIST_ENTRY Handle;
220 UINTN Key;
221} HII_HANDLE;
222
223#define HII_DATABASE_RECORD_SIGNATURE EFI_SIGNATURE_32 ('h','i','d','r')
224
225typedef struct _HII_DATABASE_RECORD {
226 UINTN Signature;
227 HII_DATABASE_PACKAGE_LIST_INSTANCE *PackageList;
228 EFI_HANDLE DriverHandle;
229 EFI_HII_HANDLE Handle;
230 LIST_ENTRY DatabaseEntry;
231} HII_DATABASE_RECORD;
232
233#define HII_DATABASE_NOTIFY_SIGNATURE EFI_SIGNATURE_32 ('h','i','d','n')
234
235typedef struct _HII_DATABASE_NOTIFY {
236 UINTN Signature;
237 EFI_HANDLE NotifyHandle;
238 UINT8 PackageType;
239 EFI_GUID *PackageGuid;
240 EFI_HII_DATABASE_NOTIFY PackageNotifyFn;
241 EFI_HII_DATABASE_NOTIFY_TYPE NotifyType;
242 LIST_ENTRY DatabaseNotifyEntry;
243} HII_DATABASE_NOTIFY;
244
245#define HII_DATABASE_PRIVATE_DATA_SIGNATURE EFI_SIGNATURE_32 ('H', 'i', 'D', 'p')
246
247typedef struct _HII_DATABASE_PRIVATE_DATA {
248 UINTN Signature;
249 LIST_ENTRY DatabaseList;
250 LIST_ENTRY DatabaseNotifyList;
251 EFI_HII_FONT_PROTOCOL HiiFont;
252#ifndef DISABLE_UNUSED_HII_PROTOCOLS
253 EFI_HII_IMAGE_PROTOCOL HiiImage;
254#endif
255 EFI_HII_STRING_PROTOCOL HiiString;
256 EFI_HII_DATABASE_PROTOCOL HiiDatabase;
257 EFI_HII_CONFIG_ROUTING_PROTOCOL ConfigRouting;
258 LIST_ENTRY HiiHandleList;
259 INTN HiiHandleCount;
260 LIST_ENTRY FontInfoList; // global font info list
261 UINTN Attribute; // default system color
262 EFI_GUID CurrentLayoutGuid;
263 EFI_HII_KEYBOARD_LAYOUT *CurrentLayout;
264} HII_DATABASE_PRIVATE_DATA;
265
266#define HII_FONT_DATABASE_PRIVATE_DATA_FROM_THIS(a) \
267 CR (a, \
268 HII_DATABASE_PRIVATE_DATA, \
269 HiiFont, \
270 HII_DATABASE_PRIVATE_DATA_SIGNATURE \
271 )
272
273#define HII_IMAGE_DATABASE_PRIVATE_DATA_FROM_THIS(a) \
274 CR (a, \
275 HII_DATABASE_PRIVATE_DATA, \
276 HiiImage, \
277 HII_DATABASE_PRIVATE_DATA_SIGNATURE \
278 )
279
280#define HII_STRING_DATABASE_PRIVATE_DATA_FROM_THIS(a) \
281 CR (a, \
282 HII_DATABASE_PRIVATE_DATA, \
283 HiiString, \
284 HII_DATABASE_PRIVATE_DATA_SIGNATURE \
285 )
286
287#define HII_DATABASE_DATABASE_PRIVATE_DATA_FROM_THIS(a) \
288 CR (a, \
289 HII_DATABASE_PRIVATE_DATA, \
290 HiiDatabase, \
291 HII_DATABASE_PRIVATE_DATA_SIGNATURE \
292 )
293
294#define CONFIG_ROUTING_DATABASE_PRIVATE_DATA_FROM_THIS(a) \
295 CR (a, \
296 HII_DATABASE_PRIVATE_DATA, \
297 ConfigRouting, \
298 HII_DATABASE_PRIVATE_DATA_SIGNATURE \
299 )
300
301//
302// Internal function prototypes.
303//
304
305/**
306 This function checks whether a handle is a valid EFI_HII_HANDLE
307
308 @param Handle Pointer to a EFI_HII_HANDLE
309
310 @retval TRUE Valid
311 @retval FALSE Invalid
312
313**/
314BOOLEAN
315IsHiiHandleValid (
316 EFI_HII_HANDLE Handle
317 )
318;
319
320
321/**
322 This function checks whether EFI_FONT_INFO exists in current database. If
323 FontInfoMask is specified, check what options can be used to make a match.
324 Note that the masks relate to where the system default should be supplied
325 are ignored by this function.
326
327 @param Private Hii database private structure.
328 @param FontInfo Points to EFI_FONT_INFO structure.
329 @param FontInfoMask If not NULL, describes what options can be used
330 to make a match between the font requested and
331 the font available. The caller must guarantee
332 this mask is valid.
333 @param FontHandle On entry, Points to the font handle returned by a
334 previous call to GetFontInfo() or NULL to start
335 with the first font.
336 @param GlobalFontInfo If not NULL, output the corresponding globa font
337 info.
338
339 @retval TRUE Existed
340 @retval FALSE Not existed
341
342**/
343BOOLEAN
344IsFontInfoExisted (
345 IN HII_DATABASE_PRIVATE_DATA *Private,
346 IN EFI_FONT_INFO *FontInfo,
347 IN EFI_FONT_INFO_MASK *FontInfoMask, OPTIONAL
348 IN EFI_FONT_HANDLE FontHandle, OPTIONAL
349 OUT HII_GLOBAL_FONT_INFO **GlobalFontInfo OPTIONAL
350 )
351;
352
353
354/**
355 Retrieve system default font and color.
356
357 @param Private HII database driver private data.
358 @param FontInfo Points to system default font output-related
359 information. It's caller's responsibility to free
360 this buffer.
361 @param FontInfoSize If not NULL, output the size of buffer FontInfo.
362
363 @retval EFI_SUCCESS Cell information is added to the GlyphInfoList.
364 @retval EFI_OUT_OF_RESOURCES The system is out of resources to accomplish the
365 task.
366 @retval EFI_INVALID_PARAMETER Any input parameter is invalid.
367
368**/
369EFI_STATUS
370GetSystemFont (
371 IN HII_DATABASE_PRIVATE_DATA *Private,
372 OUT EFI_FONT_DISPLAY_INFO **FontInfo,
373 OUT UINTN *FontInfoSize OPTIONAL
374 )
375;
376
377
378/**
379 Parse all string blocks to find a String block specified by StringId.
380 If StringId = (EFI_STRING_ID) (-1), find out all EFI_HII_SIBT_FONT blocks
381 within this string package and backup its information.
382 If StringId = 0, output the string id of last string block (EFI_HII_SIBT_END).
383
384 @param Private Hii database private structure.
385 @param StringPackage Hii string package instance.
386