You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

efi_hii.c 16KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581
  1. /*
  2. * Copyright (C) 2012 Michael Brown <mbrown@fensystems.co.uk>.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License as
  6. * published by the Free Software Foundation; either version 2 of the
  7. * License, or any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful, but
  10. * WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  17. * 02110-1301, USA.
  18. *
  19. * You can also choose to distribute this program under the terms of
  20. * the Unmodified Binary Distribution Licence (as given in the file
  21. * COPYING.UBDL), provided that you have satisfied its requirements.
  22. */
  23. FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
  24. #include <stdlib.h>
  25. #include <stddef.h>
  26. #include <stdarg.h>
  27. #include <string.h>
  28. #include <ipxe/efi/efi.h>
  29. #include <ipxe/efi/efi_strings.h>
  30. #include <ipxe/efi/efi_hii.h>
  31. /** Tiano GUID */
  32. static const EFI_GUID tiano_guid = EFI_IFR_TIANO_GUID;
  33. /**
  34. * Add string to IFR builder
  35. *
  36. * @v ifr IFR builder
  37. * @v fmt Format string
  38. * @v ... Arguments
  39. * @ret string_id String identifier, or zero on failure
  40. */
  41. unsigned int efi_ifr_string ( struct efi_ifr_builder *ifr, const char *fmt,
  42. ... ) {
  43. EFI_HII_STRING_BLOCK *new_strings;
  44. EFI_HII_SIBT_STRING_UCS2_BLOCK *ucs2;
  45. size_t new_strings_len;
  46. va_list args;
  47. size_t len;
  48. unsigned int string_id;
  49. /* Do nothing if a previous allocation has failed */
  50. if ( ifr->failed )
  51. return 0;
  52. /* Calculate string length */
  53. va_start ( args, fmt );
  54. len = ( efi_vsnprintf ( NULL, 0, fmt, args ) + 1 /* wNUL */ );
  55. va_end ( args );
  56. /* Reallocate strings */
  57. new_strings_len = ( ifr->strings_len +
  58. offsetof ( typeof ( *ucs2 ), StringText ) +
  59. ( len * sizeof ( ucs2->StringText[0] ) ) );
  60. new_strings = realloc ( ifr->strings, new_strings_len );
  61. if ( ! new_strings ) {
  62. ifr->failed = 1;
  63. return 0;
  64. }
  65. ucs2 = ( ( ( void * ) new_strings ) + ifr->strings_len );
  66. ifr->strings = new_strings;
  67. ifr->strings_len = new_strings_len;
  68. /* Fill in string */
  69. ucs2->Header.BlockType = EFI_HII_SIBT_STRING_UCS2;
  70. va_start ( args, fmt );
  71. efi_vsnprintf ( ucs2->StringText, len, fmt, args );
  72. va_end ( args );
  73. /* Allocate string ID */
  74. string_id = ++(ifr->string_id);
  75. DBGC ( ifr, "IFR %p string %#04x is \"%ls\"\n",
  76. ifr, string_id, ucs2->StringText );
  77. return string_id;
  78. }
  79. /**
  80. * Add IFR opcode to IFR builder
  81. *
  82. * @v ifr IFR builder
  83. * @v opcode Opcode
  84. * @v len Opcode length
  85. * @ret op Opcode, or NULL
  86. */
  87. static void * efi_ifr_op ( struct efi_ifr_builder *ifr, unsigned int opcode,
  88. size_t len ) {
  89. EFI_IFR_OP_HEADER *new_ops;
  90. EFI_IFR_OP_HEADER *op;
  91. size_t new_ops_len;
  92. /* Do nothing if a previous allocation has failed */
  93. if ( ifr->failed )
  94. return NULL;
  95. /* Reallocate opcodes */
  96. new_ops_len = ( ifr->ops_len + len );
  97. new_ops = realloc ( ifr->ops, new_ops_len );
  98. if ( ! new_ops ) {
  99. ifr->failed = 1;
  100. return NULL;
  101. }
  102. op = ( ( ( void * ) new_ops ) + ifr->ops_len );
  103. ifr->ops = new_ops;
  104. ifr->ops_len = new_ops_len;
  105. /* Fill in opcode header */
  106. op->OpCode = opcode;
  107. op->Length = len;
  108. return op;
  109. }
  110. /**
  111. * Add end opcode to IFR builder
  112. *
  113. * @v ifr IFR builder
  114. */
  115. void efi_ifr_end_op ( struct efi_ifr_builder *ifr ) {
  116. size_t dispaddr = ifr->ops_len;
  117. EFI_IFR_END *end;
  118. /* Add opcode */
  119. end = efi_ifr_op ( ifr, EFI_IFR_END_OP, sizeof ( *end ) );
  120. DBGC ( ifr, "IFR %p end\n", ifr );
  121. DBGC2_HDA ( ifr, dispaddr, end, sizeof ( *end ) );
  122. }
  123. /**
  124. * Add false opcode to IFR builder
  125. *
  126. * @v ifr IFR builder
  127. */
  128. void efi_ifr_false_op ( struct efi_ifr_builder *ifr ) {
  129. size_t dispaddr = ifr->ops_len;
  130. EFI_IFR_FALSE *false;
  131. /* Add opcode */
  132. false = efi_ifr_op ( ifr, EFI_IFR_FALSE_OP, sizeof ( *false ) );
  133. DBGC ( ifr, "IFR %p false\n", ifr );
  134. DBGC2_HDA ( ifr, dispaddr, false, sizeof ( *false ) );
  135. }
  136. /**
  137. * Add form opcode to IFR builder
  138. *
  139. * @v ifr IFR builder
  140. * @v title_id Title string identifier
  141. * @ret form_id Form identifier
  142. */
  143. unsigned int efi_ifr_form_op ( struct efi_ifr_builder *ifr,
  144. unsigned int title_id ) {
  145. size_t dispaddr = ifr->ops_len;
  146. EFI_IFR_FORM *form;
  147. /* Add opcode */
  148. form = efi_ifr_op ( ifr, EFI_IFR_FORM_OP, sizeof ( *form ) );
  149. if ( ! form )
  150. return 0;
  151. form->Header.Scope = 1;
  152. form->FormId = ++(ifr->form_id);
  153. form->FormTitle = title_id;
  154. DBGC ( ifr, "IFR %p name/value store %#04x title %#04x\n",
  155. ifr, form->FormId, title_id );
  156. DBGC2_HDA ( ifr, dispaddr, form, sizeof ( *form ) );
  157. return form->FormId;
  158. }
  159. /**
  160. * Add formset opcode to IFR builder
  161. *
  162. * @v ifr IFR builder
  163. * @v guid GUID
  164. * @v title_id Title string identifier
  165. * @v help_id Help string identifier
  166. * @v ... Class GUIDs (terminated by NULL)
  167. */
  168. void efi_ifr_form_set_op ( struct efi_ifr_builder *ifr, const EFI_GUID *guid,
  169. unsigned int title_id, unsigned int help_id, ... ) {
  170. size_t dispaddr = ifr->ops_len;
  171. EFI_IFR_FORM_SET *formset;
  172. EFI_GUID *class_guid;
  173. unsigned int num_class_guids = 0;
  174. size_t len;
  175. va_list args;
  176. /* Count number of class GUIDs */
  177. va_start ( args, help_id );
  178. while ( va_arg ( args, const EFI_GUID * ) != NULL )
  179. num_class_guids++;
  180. va_end ( args );
  181. /* Add opcode */
  182. len = ( sizeof ( *formset ) +
  183. ( num_class_guids * sizeof ( *class_guid ) ) );
  184. formset = efi_ifr_op ( ifr, EFI_IFR_FORM_SET_OP, len );
  185. if ( ! formset )
  186. return;
  187. formset->Header.Scope = 1;
  188. memcpy ( &formset->Guid, guid, sizeof ( formset->Guid ) );
  189. formset->FormSetTitle = title_id;
  190. formset->Help = help_id;
  191. formset->Flags = num_class_guids;
  192. /* Add class GUIDs */
  193. class_guid = ( ( ( void * ) formset ) + sizeof ( *formset ) );
  194. va_start ( args, help_id );
  195. while ( num_class_guids-- ) {
  196. memcpy ( class_guid++, va_arg ( args, const EFI_GUID * ),
  197. sizeof ( *class_guid ) );
  198. }
  199. va_end ( args );
  200. DBGC ( ifr, "IFR %p formset title %#04x help %#04x\n",
  201. ifr, title_id, help_id );
  202. DBGC2_HDA ( ifr, dispaddr, formset, len );
  203. }
  204. /**
  205. * Add get opcode to IFR builder
  206. *
  207. * @v ifr IFR builder
  208. * @v varstore_id Variable store identifier
  209. * @v varstore_info Variable string identifier or offset
  210. * @v varstore_type Variable type
  211. */
  212. void efi_ifr_get_op ( struct efi_ifr_builder *ifr, unsigned int varstore_id,
  213. unsigned int varstore_info, unsigned int varstore_type ) {
  214. size_t dispaddr = ifr->ops_len;
  215. EFI_IFR_GET *get;
  216. /* Add opcode */
  217. get = efi_ifr_op ( ifr, EFI_IFR_GET_OP, sizeof ( *get ) );
  218. get->VarStoreId = varstore_id;
  219. get->VarStoreInfo.VarName = varstore_info;
  220. get->VarStoreType = varstore_type;
  221. DBGC ( ifr, "IFR %p get varstore %#04x:%#04x type %#02x\n",
  222. ifr, varstore_id, varstore_info, varstore_type );
  223. DBGC2_HDA ( ifr, dispaddr, get, sizeof ( *get ) );
  224. }
  225. /**
  226. * Add GUID class opcode to IFR builder
  227. *
  228. * @v ifr IFR builder
  229. * @v class Class
  230. */
  231. void efi_ifr_guid_class_op ( struct efi_ifr_builder *ifr, unsigned int class ) {
  232. size_t dispaddr = ifr->ops_len;
  233. EFI_IFR_GUID_CLASS *guid_class;
  234. /* Add opcode */
  235. guid_class = efi_ifr_op ( ifr, EFI_IFR_GUID_OP,
  236. sizeof ( *guid_class ) );
  237. if ( ! guid_class )
  238. return;
  239. memcpy ( &guid_class->Guid, &tiano_guid, sizeof ( guid_class->Guid ) );
  240. guid_class->ExtendOpCode = EFI_IFR_EXTEND_OP_CLASS;
  241. guid_class->Class = class;
  242. DBGC ( ifr, "IFR %p GUID class %#02x\n", ifr, class );
  243. DBGC2_HDA ( ifr, dispaddr, guid_class, sizeof ( *guid_class ) );
  244. }
  245. /**
  246. * Add GUID subclass opcode to IFR builder
  247. *
  248. * @v ifr IFR builder
  249. * @v subclass Subclass
  250. */
  251. void efi_ifr_guid_subclass_op ( struct efi_ifr_builder *ifr,
  252. unsigned int subclass ) {
  253. size_t dispaddr = ifr->ops_len;
  254. EFI_IFR_GUID_SUBCLASS *guid_subclass;
  255. /* Add opcode */
  256. guid_subclass = efi_ifr_op ( ifr, EFI_IFR_GUID_OP,
  257. sizeof ( *guid_subclass ) );
  258. if ( ! guid_subclass )
  259. return;
  260. memcpy ( &guid_subclass->Guid, &tiano_guid,
  261. sizeof ( guid_subclass->Guid ) );
  262. guid_subclass->ExtendOpCode = EFI_IFR_EXTEND_OP_SUBCLASS;
  263. guid_subclass->SubClass = subclass;
  264. DBGC ( ifr, "IFR %p GUID subclass %#02x\n", ifr, subclass );
  265. DBGC2_HDA ( ifr, dispaddr, guid_subclass, sizeof ( *guid_subclass ) );
  266. }
  267. /**
  268. * Add numeric opcode to IFR builder
  269. *
  270. * @v ifr IFR builder
  271. * @v prompt_id Prompt string identifier
  272. * @v help_id Help string identifier
  273. * @v question_id Question identifier
  274. * @v varstore_id Variable store identifier
  275. * @v varstore_info Variable string identifier or offset
  276. * @v vflags Variable flags
  277. * @v min_value Minimum value
  278. * @v max_value Maximum value
  279. * @v step Step
  280. * @v flags Flags
  281. */
  282. void efi_ifr_numeric_op ( struct efi_ifr_builder *ifr, unsigned int prompt_id,
  283. unsigned int help_id, unsigned int question_id,
  284. unsigned int varstore_id, unsigned int varstore_info,
  285. unsigned int vflags, unsigned long min_value,
  286. unsigned long max_value, unsigned int step,
  287. unsigned int flags ) {
  288. size_t dispaddr = ifr->ops_len;
  289. EFI_IFR_NUMERIC *numeric;
  290. unsigned int size;
  291. /* Add opcode */
  292. numeric = efi_ifr_op ( ifr, EFI_IFR_NUMERIC_OP, sizeof ( *numeric ) );
  293. if ( ! numeric )
  294. return;
  295. numeric->Question.Header.Prompt = prompt_id;
  296. numeric->Question.Header.Help = help_id;
  297. numeric->Question.QuestionId = question_id;
  298. numeric->Question.VarStoreId = varstore_id;
  299. numeric->Question.VarStoreInfo.VarName = varstore_info;
  300. numeric->Question.Flags = vflags;
  301. size = ( flags & EFI_IFR_NUMERIC_SIZE );
  302. switch ( size ) {
  303. case EFI_IFR_NUMERIC_SIZE_1 :
  304. numeric->data.u8.MinValue = min_value;
  305. numeric->data.u8.MaxValue = max_value;
  306. numeric->data.u8.Step = step;
  307. break;
  308. case EFI_IFR_NUMERIC_SIZE_2 :
  309. numeric->data.u16.MinValue = min_value;
  310. numeric->data.u16.MaxValue = max_value;
  311. numeric->data.u16.Step = step;
  312. break;
  313. case EFI_IFR_NUMERIC_SIZE_4 :
  314. numeric->data.u32.MinValue = min_value;
  315. numeric->data.u32.MaxValue = max_value;
  316. numeric->data.u32.Step = step;
  317. break;
  318. case EFI_IFR_NUMERIC_SIZE_8 :
  319. numeric->data.u64.MinValue = min_value;
  320. numeric->data.u64.MaxValue = max_value;
  321. numeric->data.u64.Step = step;
  322. break;
  323. }
  324. DBGC ( ifr, "IFR %p numeric prompt %#04x help %#04x question %#04x "
  325. "varstore %#04x:%#04x\n", ifr, prompt_id, help_id, question_id,
  326. varstore_id, varstore_info );
  327. DBGC2_HDA ( ifr, dispaddr, numeric, sizeof ( *numeric ) );
  328. }
  329. /**
  330. * Add string opcode to IFR builder
  331. *
  332. * @v ifr IFR builder
  333. * @v prompt_id Prompt string identifier
  334. * @v help_id Help string identifier
  335. * @v question_id Question identifier
  336. * @v varstore_id Variable store identifier
  337. * @v varstore_info Variable string identifier or offset
  338. * @v vflags Variable flags
  339. * @v min_size Minimum size
  340. * @v max_size Maximum size
  341. * @v flags Flags
  342. */
  343. void efi_ifr_string_op ( struct efi_ifr_builder *ifr, unsigned int prompt_id,
  344. unsigned int help_id, unsigned int question_id,
  345. unsigned int varstore_id, unsigned int varstore_info,
  346. unsigned int vflags, unsigned int min_size,
  347. unsigned int max_size, unsigned int flags ) {
  348. size_t dispaddr = ifr->ops_len;
  349. EFI_IFR_STRING *string;
  350. /* Add opcode */
  351. string = efi_ifr_op ( ifr, EFI_IFR_STRING_OP, sizeof ( *string ) );
  352. if ( ! string )
  353. return;
  354. string->Question.Header.Prompt = prompt_id;
  355. string->Question.Header.Help = help_id;
  356. string->Question.QuestionId = question_id;
  357. string->Question.VarStoreId = varstore_id;
  358. string->Question.VarStoreInfo.VarName = varstore_info;
  359. string->Question.Flags = vflags;
  360. string->MinSize = min_size;
  361. string->MaxSize = max_size;
  362. string->Flags = flags;
  363. DBGC ( ifr, "IFR %p string prompt %#04x help %#04x question %#04x "
  364. "varstore %#04x:%#04x\n", ifr, prompt_id, help_id, question_id,
  365. varstore_id, varstore_info );
  366. DBGC2_HDA ( ifr, dispaddr, string, sizeof ( *string ) );
  367. }
  368. /**
  369. * Add suppress-if opcode to IFR builder
  370. *
  371. * @v ifr IFR builder
  372. */
  373. void efi_ifr_suppress_if_op ( struct efi_ifr_builder *ifr ) {
  374. size_t dispaddr = ifr->ops_len;
  375. EFI_IFR_SUPPRESS_IF *suppress_if;
  376. /* Add opcode */
  377. suppress_if = efi_ifr_op ( ifr, EFI_IFR_SUPPRESS_IF_OP,
  378. sizeof ( *suppress_if ) );
  379. suppress_if->Header.Scope = 1;
  380. DBGC ( ifr, "IFR %p suppress-if\n", ifr );
  381. DBGC2_HDA ( ifr, dispaddr, suppress_if, sizeof ( *suppress_if ) );
  382. }
  383. /**
  384. * Add text opcode to IFR builder
  385. *
  386. * @v ifr IFR builder
  387. * @v prompt_id Prompt string identifier
  388. * @v help_id Help string identifier
  389. * @v text_id Text string identifier
  390. */
  391. void efi_ifr_text_op ( struct efi_ifr_builder *ifr, unsigned int prompt_id,
  392. unsigned int help_id, unsigned int text_id ) {
  393. size_t dispaddr = ifr->ops_len;
  394. EFI_IFR_TEXT *text;
  395. /* Add opcode */
  396. text = efi_ifr_op ( ifr, EFI_IFR_TEXT_OP, sizeof ( *text ) );
  397. if ( ! text )
  398. return;
  399. text->Statement.Prompt = prompt_id;
  400. text->Statement.Help = help_id;
  401. text->TextTwo = text_id;
  402. DBGC ( ifr, "IFR %p text prompt %#04x help %#04x text %#04x\n",
  403. ifr, prompt_id, help_id, text_id );
  404. DBGC2_HDA ( ifr, dispaddr, text, sizeof ( *text ) );
  405. }
  406. /**
  407. * Add true opcode to IFR builder
  408. *
  409. * @v ifr IFR builder
  410. */
  411. void efi_ifr_true_op ( struct efi_ifr_builder *ifr ) {
  412. size_t dispaddr = ifr->ops_len;
  413. EFI_IFR_TRUE *true;
  414. /* Add opcode */
  415. true = efi_ifr_op ( ifr, EFI_IFR_TRUE_OP, sizeof ( *true ) );
  416. DBGC ( ifr, "IFR %p true\n", ifr );
  417. DBGC2_HDA ( ifr, dispaddr, true, sizeof ( *true ) );
  418. }
  419. /**
  420. * Add name/value store opcode to IFR builder
  421. *
  422. * @v ifr IFR builder
  423. * @v guid GUID
  424. * @ret varstore_id Variable store identifier, or 0 on failure
  425. */
  426. unsigned int efi_ifr_varstore_name_value_op ( struct efi_ifr_builder *ifr,
  427. const EFI_GUID *guid ) {
  428. size_t dispaddr = ifr->ops_len;
  429. EFI_IFR_VARSTORE_NAME_VALUE *varstore;
  430. /* Add opcode */
  431. varstore = efi_ifr_op ( ifr, EFI_IFR_VARSTORE_NAME_VALUE_OP,
  432. sizeof ( *varstore ) );
  433. if ( ! varstore )
  434. return 0;
  435. varstore->VarStoreId = ++(ifr->varstore_id);
  436. memcpy ( &varstore->Guid, guid, sizeof ( varstore->Guid ) );
  437. DBGC ( ifr, "IFR %p name/value store %#04x\n",
  438. ifr, varstore->VarStoreId );
  439. DBGC2_HDA ( ifr, dispaddr, varstore, sizeof ( *varstore ) );
  440. return varstore->VarStoreId;
  441. }
  442. /**
  443. * Free memory used by IFR builder
  444. *
  445. * @v ifr IFR builder
  446. */
  447. void efi_ifr_free ( struct efi_ifr_builder *ifr ) {
  448. free ( ifr->ops );
  449. free ( ifr->strings );
  450. memset ( ifr, 0, sizeof ( *ifr ) );
  451. }
  452. /**
  453. * Construct package list from IFR builder
  454. *
  455. * @v ifr IFR builder
  456. * @v guid Package GUID
  457. * @v language Language
  458. * @v language_id Language string ID
  459. * @ret package Package list, or NULL
  460. *
  461. * The package list is allocated using malloc(), and must eventually
  462. * be freed by the caller. (The caller must also call efi_ifr_free()
  463. * to free the temporary storage used during construction.)
  464. */
  465. EFI_HII_PACKAGE_LIST_HEADER * efi_ifr_package ( struct efi_ifr_builder *ifr,
  466. const EFI_GUID *guid,
  467. const char *language,
  468. unsigned int language_id ) {
  469. struct {
  470. EFI_HII_PACKAGE_LIST_HEADER header;
  471. struct {
  472. EFI_HII_PACKAGE_HEADER header;
  473. uint8_t data[ifr->ops_len];
  474. } __attribute__ (( packed )) ops;
  475. struct {
  476. union {
  477. EFI_HII_STRING_PACKAGE_HDR header;
  478. uint8_t pad[offsetof(EFI_HII_STRING_PACKAGE_HDR,
  479. Language) +
  480. strlen ( language ) + 1 /* NUL */ ];
  481. } __attribute__ (( packed )) header;
  482. uint8_t data[ifr->strings_len];
  483. EFI_HII_STRING_BLOCK end;
  484. } __attribute__ (( packed )) strings;
  485. EFI_HII_PACKAGE_HEADER end;
  486. } __attribute__ (( packed )) *package;
  487. /* Fail if any previous allocation failed */
  488. if ( ifr->failed )
  489. return NULL;
  490. /* Allocate package list */
  491. package = zalloc ( sizeof ( *package ) );
  492. if ( ! package )
  493. return NULL;
  494. /* Populate package list */
  495. package->header.PackageLength = sizeof ( *package );
  496. memcpy ( &package->header.PackageListGuid, guid,
  497. sizeof ( package->header.PackageListGuid ) );
  498. package->ops.header.Length = sizeof ( package->ops );
  499. package->ops.header.Type = EFI_HII_PACKAGE_FORMS;
  500. memcpy ( package->ops.data, ifr->ops, sizeof ( package->ops.data ) );
  501. package->strings.header.header.Header.Length =
  502. sizeof ( package->strings );
  503. package->strings.header.header.Header.Type =
  504. EFI_HII_PACKAGE_STRINGS;
  505. package->strings.header.header.HdrSize =
  506. sizeof ( package->strings.header );
  507. package->strings.header.header.StringInfoOffset =
  508. sizeof ( package->strings.header );
  509. package->strings.header.header.LanguageName = language_id;
  510. strcpy ( package->strings.header.header.Language, language );
  511. memcpy ( package->strings.data, ifr->strings,
  512. sizeof ( package->strings.data ) );
  513. package->strings.end.BlockType = EFI_HII_SIBT_END;
  514. package->end.Type = EFI_HII_PACKAGE_END;
  515. package->end.Length = sizeof ( package->end );
  516. return &package->header;
  517. }