iPXE
efi_hii.c File Reference
#include <stdlib.h>
#include <stddef.h>
#include <stdarg.h>
#include <string.h>
#include <ipxe/efi/efi.h>
#include <ipxe/efi/efi_strings.h>
#include <ipxe/efi/efi_hii.h>

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 FILE_SECBOOT (PERMITTED)
unsigned int efi_ifr_string (struct efi_ifr_builder *ifr, const char *fmt,...)
 Add string to IFR builder.
static void * efi_ifr_op (struct efi_ifr_builder *ifr, unsigned int opcode, size_t len)
 Add IFR opcode to IFR builder.
void efi_ifr_end_op (struct efi_ifr_builder *ifr)
 Add end opcode to IFR builder.
void efi_ifr_false_op (struct efi_ifr_builder *ifr)
 Add false opcode to IFR builder.
unsigned int efi_ifr_form_op (struct efi_ifr_builder *ifr, unsigned int title_id)
 Add form opcode to IFR builder.
void efi_ifr_form_set_op (struct efi_ifr_builder *ifr, const EFI_GUID *guid, unsigned int title_id, unsigned int help_id,...)
 Add formset opcode to IFR builder.
void efi_ifr_get_op (struct efi_ifr_builder *ifr, unsigned int varstore_id, unsigned int varstore_info, unsigned int varstore_type)
 Add get opcode to IFR builder.
void efi_ifr_guid_class_op (struct efi_ifr_builder *ifr, unsigned int class)
 Add GUID class opcode to IFR builder.
void efi_ifr_guid_subclass_op (struct efi_ifr_builder *ifr, unsigned int subclass)
 Add GUID subclass opcode to IFR builder.
void efi_ifr_numeric_op (struct efi_ifr_builder *ifr, unsigned int prompt_id, unsigned int help_id, unsigned int question_id, unsigned int varstore_id, unsigned int varstore_info, unsigned int vflags, unsigned long min_value, unsigned long max_value, unsigned int step, unsigned int flags)
 Add numeric opcode to IFR builder.
void efi_ifr_string_op (struct efi_ifr_builder *ifr, unsigned int prompt_id, unsigned int help_id, unsigned int question_id, unsigned int varstore_id, unsigned int varstore_info, unsigned int vflags, unsigned int min_size, unsigned int max_size, unsigned int flags)
 Add string opcode to IFR builder.
void efi_ifr_suppress_if_op (struct efi_ifr_builder *ifr)
 Add suppress-if opcode to IFR builder.
void efi_ifr_text_op (struct efi_ifr_builder *ifr, unsigned int prompt_id, unsigned int help_id, unsigned int text_id)
 Add text opcode to IFR builder.
void efi_ifr_true_op (struct efi_ifr_builder *ifr)
 Add true opcode to IFR builder.
unsigned int efi_ifr_varstore_name_value_op (struct efi_ifr_builder *ifr, const EFI_GUID *guid)
 Add name/value store opcode to IFR builder.
void efi_ifr_free (struct efi_ifr_builder *ifr)
 Free memory used by IFR builder.
EFI_HII_PACKAGE_LIST_HEADERefi_ifr_package (struct efi_ifr_builder *ifr, const EFI_GUID *guid, const char *language, unsigned int language_id)
 Construct package list from IFR builder.

Variables

static const EFI_GUID tiano_guid = EFI_IFR_TIANO_GUID
 Tiano GUID.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )

◆ FILE_SECBOOT()

FILE_SECBOOT ( PERMITTED )

◆ efi_ifr_string()

unsigned int efi_ifr_string ( struct efi_ifr_builder * ifr,
const char * fmt,
... )

Add string to IFR builder.

Parameters
ifrIFR builder
fmtFormat string
...Arguments
Return values
string_idString identifier, or zero on failure

Definition at line 46 of file efi_hii.c.

47 {
48 EFI_HII_STRING_BLOCK *new_strings;
50 size_t new_strings_len;
51 va_list args;
52 size_t len;
53 unsigned int string_id;
54
55 /* Do nothing if a previous allocation has failed */
56 if ( ifr->failed )
57 return 0;
58
59 /* Calculate string length */
60 va_start ( args, fmt );
61 len = ( efi_vsnprintf ( NULL, 0, fmt, args ) + 1 /* wNUL */ );
62 va_end ( args );
63
64 /* Reallocate strings */
65 new_strings_len = ( ifr->strings_len +
66 offsetof ( typeof ( *ucs2 ), StringText ) +
67 ( len * sizeof ( ucs2->StringText[0] ) ) );
68 new_strings = realloc ( ifr->strings, new_strings_len );
69 if ( ! new_strings ) {
70 ifr->failed = 1;
71 return 0;
72 }
73 ucs2 = ( ( ( void * ) new_strings ) + ifr->strings_len );
74 ifr->strings = new_strings;
75 ifr->strings_len = new_strings_len;
76
77 /* Fill in string */
79 va_start ( args, fmt );
80 efi_vsnprintf ( ucs2->StringText, len, fmt, args );
81 va_end ( args );
82
83 /* Allocate string ID */
84 string_id = ++(ifr->string_id);
85
86 DBGC ( ifr, "IFR %p string %#04x is \"%ls\"\n",
87 ifr, string_id, ucs2->StringText );
88 return string_id;
89}
#define NULL
NULL pointer (VOID *)
Definition Base.h:322
struct _EFI_HII_SIBT_STRING_UCS2_BLOCK EFI_HII_SIBT_STRING_UCS2_BLOCK
#define EFI_HII_SIBT_STRING_UCS2
typeof(acpi_finder=acpi_find)
ACPI table finder.
Definition acpi.c:48
ring len
Length.
Definition dwmac.h:226
int efi_vsnprintf(wchar_t *wbuf, size_t wsize, const char *fmt, va_list args)
Write a formatted string to a wide-character buffer.
Definition efi_strings.c:75
#define DBGC(...)
Definition compiler.h:505
void * realloc(void *old_ptr, size_t new_size)
Reallocate memory.
Definition malloc.c:607
#define va_end(ap)
Definition stdarg.h:10
#define va_start(ap, last)
Definition stdarg.h:8
__builtin_va_list va_list
Definition stdarg.h:7
#define offsetof(type, field)
Get offset of a field within a structure.
Definition stddef.h:25
EFI_HII_STRING_BLOCK * strings
Strings.
Definition efi_hii.h:28
unsigned int string_id
Current string identifier.
Definition efi_hii.h:32
int failed
An allocation has failed.
Definition efi_hii.h:38
size_t strings_len
Length of strings.
Definition efi_hii.h:30
int ssize_t const char * fmt
Definition vsprintf.h:73

References EFI_HII_STRING_BLOCK::BlockType, DBGC, EFI_HII_SIBT_STRING_UCS2, efi_vsnprintf(), efi_ifr_builder::failed, fmt, _EFI_HII_SIBT_STRING_UCS2_BLOCK::Header, len, NULL, offsetof, realloc(), efi_ifr_builder::string_id, efi_ifr_builder::strings, efi_ifr_builder::strings_len, _EFI_HII_SIBT_STRING_UCS2_BLOCK::StringText, typeof(), va_end, and va_start.

Referenced by efi_snp_hii_package_list(), and efi_snp_hii_questions().

◆ efi_ifr_op()

void * efi_ifr_op ( struct efi_ifr_builder * ifr,
unsigned int opcode,
size_t len )
static

Add IFR opcode to IFR builder.

Parameters
ifrIFR builder
opcodeOpcode
lenOpcode length
Return values
opOpcode, or NULL

Definition at line 99 of file efi_hii.c.

100 {
101 EFI_IFR_OP_HEADER *new_ops;
103 size_t new_ops_len;
104
105 /* Do nothing if a previous allocation has failed */
106 if ( ifr->failed )
107 return NULL;
108
109 /* Reallocate opcodes */
110 new_ops_len = ( ifr->ops_len + len );
111 new_ops = realloc ( ifr->ops, new_ops_len );
112 if ( ! new_ops ) {
113 ifr->failed = 1;
114 return NULL;
115 }
116 op = ( ( ( void * ) new_ops ) + ifr->ops_len );
117 ifr->ops = new_ops;
118 ifr->ops_len = new_ops_len;
119
120 /* Fill in opcode header */
121 memset ( op, 0, len );
122 op->OpCode = opcode;
123 op->Length = len;
124
125 return op;
126}
struct _EFI_IFR_OP_HEADER EFI_IFR_OP_HEADER
uint8_t opcode
Opcode.
Definition ena.h:5
void * memset(void *dest, int character, size_t len) __nonnull
static uint16_t struct vmbus_xfer_pages_operations * op
Definition netvsc.h:327
EFI_IFR_OP_HEADER * ops
IFR opcodes.
Definition efi_hii.h:24
size_t ops_len
Length of IFR opcodes.
Definition efi_hii.h:26

References efi_ifr_builder::failed, len, memset(), NULL, op, opcode, efi_ifr_builder::ops, efi_ifr_builder::ops_len, and realloc().

Referenced by efi_ifr_end_op(), efi_ifr_false_op(), efi_ifr_form_op(), efi_ifr_form_set_op(), efi_ifr_get_op(), efi_ifr_guid_class_op(), efi_ifr_guid_subclass_op(), efi_ifr_numeric_op(), efi_ifr_string_op(), efi_ifr_suppress_if_op(), efi_ifr_text_op(), efi_ifr_true_op(), and efi_ifr_varstore_name_value_op().

◆ efi_ifr_end_op()

void efi_ifr_end_op ( struct efi_ifr_builder * ifr)

Add end opcode to IFR builder.

Parameters
ifrIFR builder

Definition at line 133 of file efi_hii.c.

133 {
134 size_t dispaddr = ifr->ops_len;
136
137 /* Add opcode */
138 end = efi_ifr_op ( ifr, EFI_IFR_END_OP, sizeof ( *end ) );
139
140 DBGC ( ifr, "IFR %p end\n", ifr );
141 DBGC2_HDA ( ifr, dispaddr, end, sizeof ( *end ) );
142}
struct _EFI_IFR_END EFI_IFR_END
static void * efi_ifr_op(struct efi_ifr_builder *ifr, unsigned int opcode, size_t len)
Add IFR opcode to IFR builder.
Definition efi_hii.c:99
#define DBGC2_HDA(...)
Definition compiler.h:523
uint32_t end
Ending offset.
Definition netvsc.h:7

References DBGC, DBGC2_HDA, EFI_IFR_END_OP, efi_ifr_op(), end, and efi_ifr_builder::ops_len.

Referenced by efi_snp_hii_package_list().

◆ efi_ifr_false_op()

void efi_ifr_false_op ( struct efi_ifr_builder * ifr)

Add false opcode to IFR builder.

Parameters
ifrIFR builder

Definition at line 149 of file efi_hii.c.

149 {
150 size_t dispaddr = ifr->ops_len;
152
153 /* Add opcode */
154 op = efi_ifr_op ( ifr, EFI_IFR_FALSE_OP, sizeof ( *op ) );
155
156 DBGC ( ifr, "IFR %p false\n", ifr );
157 DBGC2_HDA ( ifr, dispaddr, op, sizeof ( *op ) );
158}
struct _EFI_IFR_FALSE EFI_IFR_FALSE
#define EFI_IFR_FALSE_OP

References DBGC, DBGC2_HDA, EFI_IFR_FALSE_OP, efi_ifr_op(), op, and efi_ifr_builder::ops_len.

◆ efi_ifr_form_op()

unsigned int efi_ifr_form_op ( struct efi_ifr_builder * ifr,
unsigned int title_id )

Add form opcode to IFR builder.

Parameters
ifrIFR builder
title_idTitle string identifier
Return values
form_idForm identifier

Definition at line 167 of file efi_hii.c.

168 {
169 size_t dispaddr = ifr->ops_len;
171
172 /* Add opcode */
173 form = efi_ifr_op ( ifr, EFI_IFR_FORM_OP, sizeof ( *form ) );
174 if ( ! form )
175 return 0;
176 form->Header.Scope = 1;
177 form->FormId = ++(ifr->form_id);
178 form->FormTitle = title_id;
179
180 DBGC ( ifr, "IFR %p name/value store %#04x title %#04x\n",
181 ifr, form->FormId, title_id );
182 DBGC2_HDA ( ifr, dispaddr, form, sizeof ( *form ) );
183 return form->FormId;
184}
struct _EFI_IFR_FORM EFI_IFR_FORM
#define EFI_IFR_FORM_OP
unsigned int form_id
Current form identifier.
Definition efi_hii.h:36
A form.
Definition form_ui.c:65

References DBGC, DBGC2_HDA, EFI_IFR_FORM_OP, efi_ifr_op(), efi_ifr_builder::form_id, and efi_ifr_builder::ops_len.

Referenced by efi_snp_hii_package_list().

◆ efi_ifr_form_set_op()

void efi_ifr_form_set_op ( struct efi_ifr_builder * ifr,
const EFI_GUID * guid,
unsigned int title_id,
unsigned int help_id,
... )

Add formset opcode to IFR builder.

Parameters
ifrIFR builder
guidGUID
title_idTitle string identifier
help_idHelp string identifier
...Class GUIDs (terminated by NULL)

Definition at line 195 of file efi_hii.c.

196 {
197 size_t dispaddr = ifr->ops_len;
198 EFI_IFR_FORM_SET *formset;
199 EFI_GUID *class_guid;
200 unsigned int num_class_guids = 0;
201 size_t len;
202 va_list args;
203
204 /* Count number of class GUIDs */
205 va_start ( args, help_id );
206 while ( va_arg ( args, const EFI_GUID * ) != NULL )
207 num_class_guids++;
208 va_end ( args );
209
210 /* Add opcode */
211 len = ( sizeof ( *formset ) +
212 ( num_class_guids * sizeof ( *class_guid ) ) );
213 formset = efi_ifr_op ( ifr, EFI_IFR_FORM_SET_OP, len );
214 if ( ! formset )
215 return;
216 formset->Header.Scope = 1;
217 memcpy ( &formset->Guid, guid, sizeof ( formset->Guid ) );
218 formset->FormSetTitle = title_id;
219 formset->Help = help_id;
220 formset->Flags = num_class_guids;
221
222 /* Add class GUIDs */
223 class_guid = ( ( ( void * ) formset ) + sizeof ( *formset ) );
224 va_start ( args, help_id );
225 while ( num_class_guids-- ) {
226 memcpy ( class_guid++, va_arg ( args, const EFI_GUID * ),
227 sizeof ( *class_guid ) );
228 }
229 va_end ( args );
230
231 DBGC ( ifr, "IFR %p formset title %#04x help %#04x\n",
232 ifr, title_id, help_id );
233 DBGC2_HDA ( ifr, dispaddr, formset, len );
234}
GUID EFI_GUID
128-bit buffer containing a unique identifier value.
struct _EFI_IFR_FORM_SET EFI_IFR_FORM_SET
#define EFI_IFR_FORM_SET_OP
uint64_t guid
GUID.
Definition edd.h:1
void * memcpy(void *dest, const void *src, size_t len) __nonnull
#define va_arg(ap, type)
Definition stdarg.h:9

References DBGC, DBGC2_HDA, EFI_IFR_FORM_SET_OP, efi_ifr_op(), _EFI_IFR_FORM_SET::Flags, _EFI_IFR_FORM_SET::FormSetTitle, _EFI_IFR_FORM_SET::Guid, guid, _EFI_IFR_FORM_SET::Header, _EFI_IFR_FORM_SET::Help, len, memcpy(), NULL, efi_ifr_builder::ops_len, _EFI_IFR_OP_HEADER::Scope, va_arg, va_end, and va_start.

Referenced by efi_snp_hii_package_list().

◆ efi_ifr_get_op()

void efi_ifr_get_op ( struct efi_ifr_builder * ifr,
unsigned int varstore_id,
unsigned int varstore_info,
unsigned int varstore_type )

Add get opcode to IFR builder.

Parameters
ifrIFR builder
varstore_idVariable store identifier
varstore_infoVariable string identifier or offset
varstore_typeVariable type

Definition at line 244 of file efi_hii.c.

245 {
246 size_t dispaddr = ifr->ops_len;
247 EFI_IFR_GET *get;
248
249 /* Add opcode */
250 get = efi_ifr_op ( ifr, EFI_IFR_GET_OP, sizeof ( *get ) );
251 get->VarStoreId = varstore_id;
252 get->VarStoreInfo.VarName = varstore_info;
253 get->VarStoreType = varstore_type;
254
255 DBGC ( ifr, "IFR %p get varstore %#04x:%#04x type %#02x\n",
256 ifr, varstore_id, varstore_info, varstore_type );
257 DBGC2_HDA ( ifr, dispaddr, get, sizeof ( *get ) );
258}
struct _EFI_IFR_GET EFI_IFR_GET
EFI_VARSTORE_ID VarStoreId
Specifies the identifier of a previously declared variable store to use when retrieving the value.
UINT8 VarStoreType
Specifies the type used for storage.
union _EFI_IFR_GET::@057331140221305217137163215360174155306102160175 VarStoreInfo
EFI_STRING_ID VarName
A 16-bit Buffer Storage offset.

References DBGC, DBGC2_HDA, EFI_IFR_GET_OP, efi_ifr_op(), efi_ifr_builder::ops_len, _EFI_IFR_GET::VarName, _EFI_IFR_GET::VarStoreId, _EFI_IFR_GET::VarStoreInfo, and _EFI_IFR_GET::VarStoreType.

◆ efi_ifr_guid_class_op()

void efi_ifr_guid_class_op ( struct efi_ifr_builder * ifr,
unsigned int class )

Add GUID class opcode to IFR builder.

Parameters
ifrIFR builder
classClass

Definition at line 266 of file efi_hii.c.

266 {
267 size_t dispaddr = ifr->ops_len;
268 EFI_IFR_GUID_CLASS *guid_class;
269
270 /* Add opcode */
271 guid_class = efi_ifr_op ( ifr, EFI_IFR_GUID_OP,
272 sizeof ( *guid_class ) );
273 if ( ! guid_class )
274 return;
275 memcpy ( &guid_class->Guid, &tiano_guid, sizeof ( guid_class->Guid ) );
277 guid_class->Class = class;
278
279 DBGC ( ifr, "IFR %p GUID class %#02x\n", ifr, class );
280 DBGC2_HDA ( ifr, dispaddr, guid_class, sizeof ( *guid_class ) );
281}
#define EFI_IFR_EXTEND_OP_CLASS
struct _EFI_IFR_GUID_CLASS EFI_IFR_GUID_CLASS
Device Class opcode.
#define EFI_IFR_GUID_OP
static const EFI_GUID tiano_guid
Tiano GUID.
Definition efi_hii.c:36
UINT16 Class
Device Class from the above.
UINT8 ExtendOpCode
EFI_IFR_EXTEND_OP_CLASS.
EFI_GUID Guid
EFI_IFR_TIANO_GUID.

References _EFI_IFR_GUID_CLASS::Class, DBGC, DBGC2_HDA, EFI_IFR_EXTEND_OP_CLASS, EFI_IFR_GUID_OP, efi_ifr_op(), _EFI_IFR_GUID_CLASS::ExtendOpCode, _EFI_IFR_GUID_CLASS::Guid, memcpy(), efi_ifr_builder::ops_len, and tiano_guid.

Referenced by efi_snp_hii_package_list().

◆ efi_ifr_guid_subclass_op()

void efi_ifr_guid_subclass_op ( struct efi_ifr_builder * ifr,
unsigned int subclass )

Add GUID subclass opcode to IFR builder.

Parameters
ifrIFR builder
subclassSubclass

Definition at line 289 of file efi_hii.c.

290 {
291 size_t dispaddr = ifr->ops_len;
292 EFI_IFR_GUID_SUBCLASS *guid_subclass;
293
294 /* Add opcode */
295 guid_subclass = efi_ifr_op ( ifr, EFI_IFR_GUID_OP,
296 sizeof ( *guid_subclass ) );
297 if ( ! guid_subclass )
298 return;
299 memcpy ( &guid_subclass->Guid, &tiano_guid,
300 sizeof ( guid_subclass->Guid ) );
302 guid_subclass->SubClass = subclass;
303
304 DBGC ( ifr, "IFR %p GUID subclass %#02x\n", ifr, subclass );
305 DBGC2_HDA ( ifr, dispaddr, guid_subclass, sizeof ( *guid_subclass ) );
306}
struct _EFI_IFR_GUID_SUBCLASS EFI_IFR_GUID_SUBCLASS
SubClass opcode.
#define EFI_IFR_EXTEND_OP_SUBCLASS
UINT8 ExtendOpCode
EFI_IFR_EXTEND_OP_SUBCLASS.
UINT16 SubClass
Sub Class type from the above.
EFI_GUID Guid
EFI_IFR_TIANO_GUID.

References DBGC, DBGC2_HDA, EFI_IFR_EXTEND_OP_SUBCLASS, EFI_IFR_GUID_OP, efi_ifr_op(), _EFI_IFR_GUID_SUBCLASS::ExtendOpCode, _EFI_IFR_GUID_SUBCLASS::Guid, memcpy(), efi_ifr_builder::ops_len, _EFI_IFR_GUID_SUBCLASS::SubClass, and tiano_guid.

Referenced by efi_snp_hii_package_list().

◆ efi_ifr_numeric_op()

void efi_ifr_numeric_op ( struct efi_ifr_builder * ifr,
unsigned int prompt_id,
unsigned int help_id,
unsigned int question_id,
unsigned int varstore_id,
unsigned int varstore_info,
unsigned int vflags,
unsigned long min_value,
unsigned long max_value,
unsigned int step,
unsigned int flags )

Add numeric opcode to IFR builder.

Parameters
ifrIFR builder
prompt_idPrompt string identifier
help_idHelp string identifier
question_idQuestion identifier
varstore_idVariable store identifier
varstore_infoVariable string identifier or offset
vflagsVariable flags
min_valueMinimum value
max_valueMaximum value
stepStep
flagsFlags

Definition at line 323 of file efi_hii.c.

328 {
329 size_t dispaddr = ifr->ops_len;
330 EFI_IFR_NUMERIC *numeric;
331 unsigned int size;
332
333 /* Add opcode */
334 numeric = efi_ifr_op ( ifr, EFI_IFR_NUMERIC_OP, sizeof ( *numeric ) );
335 if ( ! numeric )
336 return;
337 numeric->Question.Header.Prompt = prompt_id;
338 numeric->Question.Header.Help = help_id;
339 numeric->Question.QuestionId = question_id;
340 numeric->Question.VarStoreId = varstore_id;
341 numeric->Question.VarStoreInfo.VarName = varstore_info;
342 numeric->Question.Flags = vflags;
344 switch ( size ) {
346 numeric->data.u8.MinValue = min_value;
347 numeric->data.u8.MaxValue = max_value;
348 numeric->data.u8.Step = step;
349 break;
351 numeric->data.u16.MinValue = min_value;
352 numeric->data.u16.MaxValue = max_value;
353 numeric->data.u16.Step = step;
354 break;
356 numeric->data.u32.MinValue = min_value;
357 numeric->data.u32.MaxValue = max_value;
358 numeric->data.u32.Step = step;
359 break;
361 numeric->data.u64.MinValue = min_value;
362 numeric->data.u64.MaxValue = max_value;
363 numeric->data.u64.Step = step;
364 break;
365 }
366
367 DBGC ( ifr, "IFR %p numeric prompt %#04x help %#04x question %#04x "
368 "varstore %#04x:%#04x\n", ifr, prompt_id, help_id, question_id,
369 varstore_id, varstore_info );
370 DBGC2_HDA ( ifr, dispaddr, numeric, sizeof ( *numeric ) );
371}
#define EFI_IFR_NUMERIC_OP
#define EFI_IFR_NUMERIC_SIZE_1
#define EFI_IFR_NUMERIC_SIZE_2
#define EFI_IFR_NUMERIC_SIZE_8
#define EFI_IFR_NUMERIC_SIZE_4
struct _EFI_IFR_NUMERIC EFI_IFR_NUMERIC
#define EFI_IFR_NUMERIC_SIZE
uint8_t flags
Flags.
Definition ena.h:7
uint16_t size
Buffer size.
Definition dwmac.h:3
void step(void)
Single-step a single process.
Definition process.c:99
EFI_IFR_QUESTION_HEADER Question
union _EFI_IFR_QUESTION_HEADER::@270154056040045031072026335247250302177356064274 VarStoreInfo
struct MINMAXSTEP_DATA::@351360203335317317250076130200223010310342122364 u16
struct MINMAXSTEP_DATA::@334327320232144303077314054114150307232166204006 u32
struct MINMAXSTEP_DATA::@362102240126042025052050342114312021126367237216 u64
struct MINMAXSTEP_DATA::@143057012352020007201145157012147372150257204151 u8

References _EFI_IFR_NUMERIC::data, DBGC, DBGC2_HDA, EFI_IFR_NUMERIC_OP, EFI_IFR_NUMERIC_SIZE, EFI_IFR_NUMERIC_SIZE_1, EFI_IFR_NUMERIC_SIZE_2, EFI_IFR_NUMERIC_SIZE_4, EFI_IFR_NUMERIC_SIZE_8, efi_ifr_op(), _EFI_IFR_QUESTION_HEADER::Flags, flags, _EFI_IFR_QUESTION_HEADER::Header, _EFI_IFR_STATEMENT_HEADER::Help, MINMAXSTEP_DATA::MaxValue, MINMAXSTEP_DATA::MinValue, efi_ifr_builder::ops_len, _EFI_IFR_STATEMENT_HEADER::Prompt, _EFI_IFR_NUMERIC::Question, _EFI_IFR_QUESTION_HEADER::QuestionId, size, MINMAXSTEP_DATA::Step, step(), MINMAXSTEP_DATA::u16, MINMAXSTEP_DATA::u32, MINMAXSTEP_DATA::u64, MINMAXSTEP_DATA::u8, _EFI_IFR_QUESTION_HEADER::VarName, _EFI_IFR_QUESTION_HEADER::VarStoreId, and _EFI_IFR_QUESTION_HEADER::VarStoreInfo.

◆ efi_ifr_string_op()

void efi_ifr_string_op ( struct efi_ifr_builder * ifr,
unsigned int prompt_id,
unsigned int help_id,
unsigned int question_id,
unsigned int varstore_id,
unsigned int varstore_info,
unsigned int vflags,
unsigned int min_size,
unsigned int max_size,
unsigned int flags )

Add string opcode to IFR builder.

Parameters
ifrIFR builder
prompt_idPrompt string identifier
help_idHelp string identifier
question_idQuestion identifier
varstore_idVariable store identifier
varstore_infoVariable string identifier or offset
vflagsVariable flags
min_sizeMinimum size
max_sizeMaximum size
flagsFlags

Definition at line 387 of file efi_hii.c.

391 {
392 size_t dispaddr = ifr->ops_len;
394
395 /* Add opcode */
396 string = efi_ifr_op ( ifr, EFI_IFR_STRING_OP, sizeof ( *string ) );
397 if ( ! string )
398 return;
399 string->Question.Header.Prompt = prompt_id;
400 string->Question.Header.Help = help_id;
401 string->Question.QuestionId = question_id;
402 string->Question.VarStoreId = varstore_id;
403 string->Question.VarStoreInfo.VarName = varstore_info;
404 string->Question.Flags = vflags;
405 string->MinSize = min_size;
406 string->MaxSize = max_size;
407 string->Flags = flags;
408
409 DBGC ( ifr, "IFR %p string prompt %#04x help %#04x question %#04x "
410 "varstore %#04x:%#04x\n", ifr, prompt_id, help_id, question_id,
411 varstore_id, varstore_info );
412 DBGC2_HDA ( ifr, dispaddr, string, sizeof ( *string ) );
413}
#define EFI_IFR_STRING_OP
struct _EFI_IFR_STRING EFI_IFR_STRING
uint32_t string
Definition multiboot.h:2

References DBGC, DBGC2_HDA, efi_ifr_op(), EFI_IFR_STRING_OP, flags, efi_ifr_builder::ops_len, and string.

Referenced by efi_snp_hii_questions().

◆ efi_ifr_suppress_if_op()

void efi_ifr_suppress_if_op ( struct efi_ifr_builder * ifr)

Add suppress-if opcode to IFR builder.

Parameters
ifrIFR builder

Definition at line 420 of file efi_hii.c.

420 {
421 size_t dispaddr = ifr->ops_len;
422 EFI_IFR_SUPPRESS_IF *suppress_if;
423
424 /* Add opcode */
425 suppress_if = efi_ifr_op ( ifr, EFI_IFR_SUPPRESS_IF_OP,
426 sizeof ( *suppress_if ) );
427 suppress_if->Header.Scope = 1;
428
429 DBGC ( ifr, "IFR %p suppress-if\n", ifr );
430 DBGC2_HDA ( ifr, dispaddr, suppress_if, sizeof ( *suppress_if ) );
431}
#define EFI_IFR_SUPPRESS_IF_OP
struct _EFI_IFR_SUPPRESS_IF EFI_IFR_SUPPRESS_IF

References DBGC, DBGC2_HDA, efi_ifr_op(), EFI_IFR_SUPPRESS_IF_OP, _EFI_IFR_SUPPRESS_IF::Header, efi_ifr_builder::ops_len, and _EFI_IFR_OP_HEADER::Scope.

◆ efi_ifr_text_op()

void efi_ifr_text_op ( struct efi_ifr_builder * ifr,
unsigned int prompt_id,
unsigned int help_id,
unsigned int text_id )

Add text opcode to IFR builder.

Parameters
ifrIFR builder
prompt_idPrompt string identifier
help_idHelp string identifier
text_idText string identifier

Definition at line 441 of file efi_hii.c.

442 {
443 size_t dispaddr = ifr->ops_len;
444 EFI_IFR_TEXT *text;
445
446 /* Add opcode */
447 text = efi_ifr_op ( ifr, EFI_IFR_TEXT_OP, sizeof ( *text ) );
448 if ( ! text )
449 return;
450 text->Statement.Prompt = prompt_id;
451 text->Statement.Help = help_id;
452 text->TextTwo = text_id;
453
454 DBGC ( ifr, "IFR %p text prompt %#04x help %#04x text %#04x\n",
455 ifr, prompt_id, help_id, text_id );
456 DBGC2_HDA ( ifr, dispaddr, text, sizeof ( *text ) );
457}
#define EFI_IFR_TEXT_OP
struct _EFI_IFR_TEXT EFI_IFR_TEXT
EFI_IFR_STATEMENT_HEADER Statement

References DBGC, DBGC2_HDA, efi_ifr_op(), EFI_IFR_TEXT_OP, _EFI_IFR_STATEMENT_HEADER::Help, efi_ifr_builder::ops_len, _EFI_IFR_STATEMENT_HEADER::Prompt, _EFI_IFR_TEXT::Statement, and _EFI_IFR_TEXT::TextTwo.

Referenced by efi_snp_hii_package_list().

◆ efi_ifr_true_op()

void efi_ifr_true_op ( struct efi_ifr_builder * ifr)

Add true opcode to IFR builder.

Parameters
ifrIFR builder

Definition at line 464 of file efi_hii.c.

464 {
465 size_t dispaddr = ifr->ops_len;
467
468 /* Add opcode */
469 op = efi_ifr_op ( ifr, EFI_IFR_TRUE_OP, sizeof ( *op ) );
470
471 DBGC ( ifr, "IFR %p true\n", ifr );
472 DBGC2_HDA ( ifr, dispaddr, op, sizeof ( *op ) );
473}
struct _EFI_IFR_TRUE EFI_IFR_TRUE
#define EFI_IFR_TRUE_OP

References DBGC, DBGC2_HDA, efi_ifr_op(), EFI_IFR_TRUE_OP, op, and efi_ifr_builder::ops_len.

◆ efi_ifr_varstore_name_value_op()

unsigned int efi_ifr_varstore_name_value_op ( struct efi_ifr_builder * ifr,
const EFI_GUID * guid )

Add name/value store opcode to IFR builder.

Parameters
ifrIFR builder
guidGUID
Return values
varstore_idVariable store identifier, or 0 on failure

Definition at line 482 of file efi_hii.c.

483 {
484 size_t dispaddr = ifr->ops_len;
486
487 /* Add opcode */
489 sizeof ( *varstore ) );
490 if ( ! varstore )
491 return 0;
492 varstore->VarStoreId = ++(ifr->varstore_id);
493 memcpy ( &varstore->Guid, guid, sizeof ( varstore->Guid ) );
494
495 DBGC ( ifr, "IFR %p name/value store %#04x\n",
496 ifr, varstore->VarStoreId );
497 DBGC2_HDA ( ifr, dispaddr, varstore, sizeof ( *varstore ) );
498 return varstore->VarStoreId;
499}
struct _EFI_IFR_VARSTORE_NAME_VALUE EFI_IFR_VARSTORE_NAME_VALUE
#define EFI_IFR_VARSTORE_NAME_VALUE_OP
unsigned int varstore_id
Current variable store identifier.
Definition efi_hii.h:34

References DBGC, DBGC2_HDA, efi_ifr_op(), EFI_IFR_VARSTORE_NAME_VALUE_OP, _EFI_IFR_VARSTORE_NAME_VALUE::Guid, guid, memcpy(), efi_ifr_builder::ops_len, efi_ifr_builder::varstore_id, and _EFI_IFR_VARSTORE_NAME_VALUE::VarStoreId.

Referenced by efi_snp_hii_package_list().

◆ efi_ifr_free()

void efi_ifr_free ( struct efi_ifr_builder * ifr)

Free memory used by IFR builder.

Parameters
ifrIFR builder

Definition at line 506 of file efi_hii.c.

506 {
507
508 free ( ifr->ops );
509 free ( ifr->strings );
510 memset ( ifr, 0, sizeof ( *ifr ) );
511}
static void(* free)(struct refcnt *refcnt))
Definition refcnt.h:55

References free, memset(), efi_ifr_builder::ops, and efi_ifr_builder::strings.

Referenced by efi_snp_hii_package_list().

◆ efi_ifr_package()

EFI_HII_PACKAGE_LIST_HEADER * efi_ifr_package ( struct efi_ifr_builder * ifr,
const EFI_GUID * guid,
const char * language,
unsigned int language_id )

Construct package list from IFR builder.

Parameters
ifrIFR builder
guidPackage GUID
languageLanguage
language_idLanguage string ID
Return values
packagePackage list, or NULL

The package list is allocated using malloc(), and must eventually be freed by the caller. (The caller must also call efi_ifr_free() to free the temporary storage used during construction.)

Definition at line 526 of file efi_hii.c.

529 {
530 struct {
532 struct {
534 uint8_t data[ifr->ops_len];
535 } __attribute__ (( packed )) ops;
536 struct {
537 union {
540 Language) +
541 strlen ( language ) + 1 /* NUL */ ];
542 } __attribute__ (( packed )) header;
545 } __attribute__ (( packed )) strings;
547 } __attribute__ (( packed )) *package;
548
549 /* Fail if any previous allocation failed */
550 if ( ifr->failed )
551 return NULL;
552
553 /* Allocate package list */
554 package = zalloc ( sizeof ( *package ) );
555 if ( ! package )
556 return NULL;
557
558 /* Populate package list */
559 package->header.PackageLength = sizeof ( *package );
560 memcpy ( &package->header.PackageListGuid, guid,
561 sizeof ( package->header.PackageListGuid ) );
562 package->ops.header.Length = sizeof ( package->ops );
563 package->ops.header.Type = EFI_HII_PACKAGE_FORMS;
564 memcpy ( package->ops.data, ifr->ops, sizeof ( package->ops.data ) );
565 package->strings.header.header.Header.Length =
566 sizeof ( package->strings );
567 package->strings.header.header.Header.Type =
569 package->strings.header.header.HdrSize =
570 sizeof ( package->strings.header );
571 package->strings.header.header.StringInfoOffset =
572 sizeof ( package->strings.header );
573 package->strings.header.header.LanguageName = language_id;
574 strcpy ( package->strings.header.header.Language, language );
575 memcpy ( package->strings.data, ifr->strings,
576 sizeof ( package->strings.data ) );
577 package->strings.end.BlockType = EFI_HII_SIBT_END;
578 package->end.Type = EFI_HII_PACKAGE_END;
579 package->end.Length = sizeof ( package->end );
580
581 return &package->header;
582}
#define EFI_HII_PACKAGE_STRINGS
#define EFI_HII_SIBT_END
#define EFI_HII_PACKAGE_FORMS
struct _EFI_HII_STRING_PACKAGE_HDR EFI_HII_STRING_PACKAGE_HDR
The fixed header consists of a standard record header and then the string identifiers contained in th...
#define EFI_HII_PACKAGE_END
u32 pad[9]
Padding.
Definition ar9003_mac.h:23
unsigned char uint8_t
Definition stdint.h:10
uint8_t data[48]
Additional event data.
Definition ena.h:11
struct ena_llq_option header
Header locations.
Definition ena.h:5
#define __attribute__(x)
Definition compiler.h:10
char * strcpy(char *dest, const char *src)
Copy string.
Definition string.c:347
size_t strlen(const char *src)
Get length of string.
Definition string.c:244
The header found at the start of each package.
The header found at the start of each package list.

References __attribute__, data, EFI_HII_PACKAGE_END, EFI_HII_PACKAGE_FORMS, EFI_HII_PACKAGE_STRINGS, EFI_HII_SIBT_END, end, efi_ifr_builder::failed, guid, header, memcpy(), NULL, offsetof, efi_ifr_builder::ops, efi_ifr_builder::ops_len, pad, strcpy(), efi_ifr_builder::strings, efi_ifr_builder::strings_len, and strlen().

Variable Documentation

◆ tiano_guid

const EFI_GUID tiano_guid = EFI_IFR_TIANO_GUID
static

Tiano GUID.

Definition at line 36 of file efi_hii.c.

Referenced by efi_ifr_guid_class_op(), and efi_ifr_guid_subclass_op().