String.c 5.0 KB

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