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