]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Application/UiApp/String.c
MdeModulePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdeModulePkg / Application / UiApp / String.c
1 /** @file
2 String support
3
4 Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7 **/
8
9 #include "Ui.h"
10 #include "FrontPage.h"
11
12 EFI_HII_HANDLE gStringPackHandle;
13
14 EFI_GUID mUiStringPackGuid = {
15 0x136a3048, 0x752a, 0x4bf6, { 0xa7, 0x57, 0x9, 0x36, 0x11, 0x95, 0x38, 0xed }
16 };
17
18 EFI_GUID mFontPackageGuid = {
19 0x78941450, 0x90ab, 0x4fb1, {0xb7, 0x5f, 0x58, 0x92, 0x14, 0xe2, 0x4a, 0xc}
20 };
21
22 #define NARROW_GLYPH_NUMBER 8
23 #define WIDE_GLYPH_NUMBER 75
24
25 typedef struct {
26 ///
27 /// This 4-bytes total array length is required by HiiAddPackages()
28 ///
29 UINT32 Length;
30
31 //
32 // This is the Font package definition
33 //
34 EFI_HII_PACKAGE_HEADER Header;
35 UINT16 NumberOfNarrowGlyphs;
36 UINT16 NumberOfWideGlyphs;
37 EFI_NARROW_GLYPH NarrowArray[NARROW_GLYPH_NUMBER];
38 EFI_WIDE_GLYPH WideArray[WIDE_GLYPH_NUMBER];
39 } FONT_PACK_BIN;
40
41 FONT_PACK_BIN mFontBin = {
42 sizeof (FONT_PACK_BIN),
43 {
44 sizeof (FONT_PACK_BIN) - sizeof (UINT32),
45 EFI_HII_PACKAGE_SIMPLE_FONTS,
46 },
47 NARROW_GLYPH_NUMBER,
48 0,
49 { // Narrow Glyphs
50 {
51 0x05d0,
52 0x00,
53 {
54 0x00,
55 0x00,
56 0x00,
57 0x4E,
58 0x6E,
59 0x62,
60 0x32,
61 0x32,
62 0x3C,
63 0x68,
64 0x4C,
65 0x4C,
66 0x46,
67 0x76,
68 0x72,
69 0x00,
70 0x00,
71 0x00,
72 0x00
73 }
74 },
75 {
76 0x05d1,
77 0x00,
78 {
79 0x00,
80 0x00,
81 0x00,
82 0x78,
83 0x7C,
84 0x0C,
85 0x0C,
86 0x0C,
87 0x0C,
88 0x0C,
89 0x0C,
90 0x0C,
91 0x0C,
92 0x7E,
93 0x7E,
94 0x00,
95 0x00,
96 0x00,
97 0x00
98 }
99 },
100 {
101 0x05d2,
102 0x00,
103 {
104 0x00,
105 0x00,
106 0x00,
107 0x78,
108 0x7C,
109 0x0C,
110 0x0C,
111 0x0C,
112 0x0C,
113 0x0C,
114 0x0C,
115 0x1C,
116 0x3E,
117 0x66,
118 0x66,
119 0x00,
120 0x00,
121 0x00,
122 0x00
123 }
124 },
125 {
126 0x05d3,
127 0x00,
128 {
129 0x00,
130 0x00,
131 0x00,
132 0x7E,
133 0x7E,
134 0x0C,
135 0x0C,
136 0x0C,
137 0x0C,
138 0x0C,
139 0x0C,
140 0x0C,
141 0x0C,
142 0x0C,
143 0x0C,
144 0x00,
145 0x00,
146 0x00,
147 0x00
148 }
149 },
150 {
151 0x05d4,
152 0x00,
153 {
154 0x00,
155 0x00,
156 0x00,
157 0x7C,
158 0x7E,
159 0x06,
160 0x06,
161 0x06,
162 0x06,
163 0x66,
164 0x66,
165 0x66,
166 0x66,
167 0x66,
168 0x66,
169 0x00,
170 0x00,
171 0x00,
172 0x00
173 }
174 },
175 {
176 0x05d5,
177 0x00,
178 {
179 0x00,
180 0x00,
181 0x00,
182 0x3C,
183 0x3C,
184 0x0C,
185 0x0C,
186 0x0C,
187 0x0C,
188 0x0C,
189 0x0C,
190 0x0C,
191 0x0C,
192 0x0C,
193 0x0C,
194 0x00,
195 0x00,
196 0x00,
197 0x00
198 }
199 },
200 {
201 0x05d6,
202 0x00,
203 {
204 0x00,
205 0x00,
206 0x00,
207 0x38,
208 0x38,
209 0x1E,
210 0x1E,
211 0x18,
212 0x18,
213 0x18,
214 0x18,
215 0x18,
216 0x18,
217 0x18,
218 0x18,
219 0x00,
220 0x00,
221 0x00,
222 0x00
223 }
224 },
225 {
226 0x0000,
227 0x00,
228 {
229 0x00,
230 0x00,
231 0x00,
232 0x00,
233 0x00,
234 0x00,
235 0x00,
236 0x00,
237 0x00,
238 0x00,
239 0x00,
240 0x00,
241 0x00,
242 0x00,
243 0x00,
244 0x00,
245 0x00,
246 0x00,
247 0x00
248 }
249 }
250 }
251 };
252
253 /**
254 Initialize HII global accessor for string support.
255
256 **/
257 VOID
258 InitializeStringSupport (
259 VOID
260 )
261 {
262 gStringPackHandle = HiiAddPackages (
263 &mUiStringPackGuid,
264 gImageHandle,
265 UiAppStrings,
266 NULL
267 );
268 ASSERT (gStringPackHandle != NULL);
269 }
270
271 /**
272 Remove the string package.
273
274 **/
275 VOID
276 UninitializeStringSupport (
277 VOID
278 )
279 {
280 HiiRemovePackages (gStringPackHandle);
281 }
282
283 /**
284 Get string by string id from HII Interface
285
286
287 @param Id String ID.
288
289 @retval CHAR16 * String from ID.
290 @retval NULL If error occurs.
291
292 **/
293 CHAR16 *
294 GetStringById (
295 IN EFI_STRING_ID Id
296 )
297 {
298 return HiiGetString (gStringPackHandle, Id, NULL);
299 }
300
301 /**
302 Routine to export glyphs to the HII database. This is in addition to whatever is defined in the Graphics Console driver.
303
304 **/
305 EFI_HII_HANDLE
306 ExportFonts (
307 VOID
308 )
309 {
310 return HiiAddPackages (
311 &mFontPackageGuid,
312 gImageHandle,
313 &mFontBin,
314 NULL
315 );
316 }