iPXE
Data Structures | Macros | Functions
efi_hii.h File Reference

EFI human interface infrastructure. More...

#include <string.h>
#include <ipxe/efi/Uefi/UefiInternalFormRepresentation.h>
#include <ipxe/efi/Guid/MdeModuleHii.h>

Go to the source code of this file.

Data Structures

struct  efi_ifr_builder
 An EFI IFR builder. More...
 

Macros

#define EFI_HII_IBM_UCM_COMPLIANT_FORMSET_GUID
 GUID indicating formset compliance for IBM Unified Configuration Manager. More...
 

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
static void efi_ifr_init (struct efi_ifr_builder *ifr)
 Initialise IFR builder. More...
 
unsigned int efi_ifr_string (struct efi_ifr_builder *ifr, const char *fmt,...)
 Add string to IFR builder. More...
 
void efi_ifr_end_op (struct efi_ifr_builder *ifr)
 Add end opcode to IFR builder. More...
 
void efi_ifr_false_op (struct efi_ifr_builder *ifr)
 Add false opcode to IFR builder. More...
 
unsigned int efi_ifr_form_op (struct efi_ifr_builder *ifr, unsigned int title_id)
 Add form opcode to IFR builder. More...
 
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. More...
 
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. More...
 
void efi_ifr_guid_class_op (struct efi_ifr_builder *ifr, unsigned int class)
 Add GUID class opcode to IFR builder. More...
 
void efi_ifr_guid_subclass_op (struct efi_ifr_builder *ifr, unsigned int subclass)
 Add GUID subclass opcode to IFR builder. More...
 
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. More...
 
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. More...
 
void efi_ifr_suppress_if_op (struct efi_ifr_builder *ifr)
 Add suppress-if opcode to IFR builder. More...
 
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. More...
 
void efi_ifr_true_op (struct efi_ifr_builder *ifr)
 Add true opcode to IFR builder. More...
 
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. More...
 
void efi_ifr_free (struct efi_ifr_builder *ifr)
 Free memory used by IFR builder. More...
 
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. More...
 

Detailed Description

EFI human interface infrastructure.

Definition in file efi_hii.h.

Macro Definition Documentation

◆ EFI_HII_IBM_UCM_COMPLIANT_FORMSET_GUID

#define EFI_HII_IBM_UCM_COMPLIANT_FORMSET_GUID
Value:
{ 0x5c8e9746, 0xa5f7, 0x4593, \
{ 0xaf, 0x1f, 0x66, 0xa8, 0x2a, 0xa1, 0x9c, 0xb1 } }

GUID indicating formset compliance for IBM Unified Configuration Manager.

Definition at line 16 of file efi_hii.h.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ efi_ifr_init()

static void efi_ifr_init ( struct efi_ifr_builder ifr)
inlinestatic

Initialise IFR builder.

Parameters
ifrIFR builder

The caller must eventually call efi_ifr_free() to free the dynamic storage associated with the IFR builder.

Definition at line 48 of file efi_hii.h.

48  {
49  memset ( ifr, 0, sizeof ( *ifr ) );
50 }
void * memset(void *dest, int character, size_t len) __nonnull

References memset().

Referenced by efi_snp_hii_package_list().

◆ 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 45 of file efi_hii.c.

46  {
47  EFI_HII_STRING_BLOCK *new_strings;
49  size_t new_strings_len;
50  va_list args;
51  size_t len;
52  unsigned int string_id;
53 
54  /* Do nothing if a previous allocation has failed */
55  if ( ifr->failed )
56  return 0;
57 
58  /* Calculate string length */
59  va_start ( args, fmt );
60  len = ( efi_vsnprintf ( NULL, 0, fmt, args ) + 1 /* wNUL */ );
61  va_end ( args );
62 
63  /* Reallocate strings */
64  new_strings_len = ( ifr->strings_len +
65  offsetof ( typeof ( *ucs2 ), StringText ) +
66  ( len * sizeof ( ucs2->StringText[0] ) ) );
67  new_strings = realloc ( ifr->strings, new_strings_len );
68  if ( ! new_strings ) {
69  ifr->failed = 1;
70  return 0;
71  }
72  ucs2 = ( ( ( void * ) new_strings ) + ifr->strings_len );
73  ifr->strings = new_strings;
74  ifr->strings_len = new_strings_len;
75 
76  /* Fill in string */
78  va_start ( args, fmt );
79  efi_vsnprintf ( ucs2->StringText, len, fmt, args );
80  va_end ( args );
81 
82  /* Allocate string ID */
83  string_id = ++(ifr->string_id);
84 
85  DBGC ( ifr, "IFR %p string %#04x is \"%ls\"\n",
86  ifr, string_id, ucs2->StringText );
87  return string_id;
88 }
#define va_end(ap)
Definition: stdarg.h:9
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:74
#define DBGC(...)
Definition: compiler.h:505
#define offsetof(type, field)
Get offset of a field within a structure.
Definition: stddef.h:24
EFI_HII_STRING_BLOCK * strings
Strings.
Definition: efi_hii.h:27
unsigned int string_id
Current string identifier.
Definition: efi_hii.h:31
size_t strings_len
Length of strings.
Definition: efi_hii.h:29
int failed
An allocation has failed.
Definition: efi_hii.h:37
uint32_t len
Length.
Definition: ena.h:14
__builtin_va_list va_list
Definition: stdarg.h:6
#define EFI_HII_SIBT_STRING_UCS2
int ssize_t const char * fmt
Definition: vsprintf.h:72
void * realloc(void *old_ptr, size_t new_size)
Reallocate memory.
Definition: malloc.c:521
typeof(acpi_finder=acpi_find)
ACPI table finder.
Definition: acpi.c:45
#define va_start(ap, last)
Definition: stdarg.h:7
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

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_end_op()

void efi_ifr_end_op ( struct efi_ifr_builder ifr)

Add end opcode to IFR builder.

Parameters
ifrIFR builder

Definition at line 132 of file efi_hii.c.

132  {
133  size_t dispaddr = ifr->ops_len;
134  EFI_IFR_END *end;
135 
136  /* Add opcode */
137  end = efi_ifr_op ( ifr, EFI_IFR_END_OP, sizeof ( *end ) );
138 
139  DBGC ( ifr, "IFR %p end\n", ifr );
140  DBGC2_HDA ( ifr, dispaddr, end, sizeof ( *end ) );
141 }
#define EFI_IFR_END_OP
#define DBGC(...)
Definition: compiler.h:505
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:98
#define DBGC2_HDA(...)
Definition: compiler.h:523
size_t ops_len
Length of IFR opcodes.
Definition: efi_hii.h:25
uint32_t end
Ending offset.
Definition: netvsc.h:18

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 148 of file efi_hii.c.

148  {
149  size_t dispaddr = ifr->ops_len;
150  EFI_IFR_FALSE *false;
151 
152  /* Add opcode */
153  false = efi_ifr_op ( ifr, EFI_IFR_FALSE_OP, sizeof ( *false ) );
154 
155  DBGC ( ifr, "IFR %p false\n", ifr );
156  DBGC2_HDA ( ifr, dispaddr, false, sizeof ( *false ) );
157 }
#define EFI_IFR_FALSE_OP
#define DBGC(...)
Definition: compiler.h:505
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:98
#define DBGC2_HDA(...)
Definition: compiler.h:523
size_t ops_len
Length of IFR opcodes.
Definition: efi_hii.h:25

References DBGC, DBGC2_HDA, EFI_IFR_FALSE_OP, efi_ifr_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 166 of file efi_hii.c.

167  {
168  size_t dispaddr = ifr->ops_len;
169  EFI_IFR_FORM *form;
170 
171  /* Add opcode */
172  form = efi_ifr_op ( ifr, EFI_IFR_FORM_OP, sizeof ( *form ) );
173  if ( ! form )
174  return 0;
175  form->Header.Scope = 1;
176  form->FormId = ++(ifr->form_id);
177  form->FormTitle = title_id;
178 
179  DBGC ( ifr, "IFR %p name/value store %#04x title %#04x\n",
180  ifr, form->FormId, title_id );
181  DBGC2_HDA ( ifr, dispaddr, form, sizeof ( *form ) );
182  return form->FormId;
183 }
#define DBGC(...)
Definition: compiler.h:505
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:98
#define DBGC2_HDA(...)
Definition: compiler.h:523
size_t ops_len
Length of IFR opcodes.
Definition: efi_hii.h:25
unsigned int form_id
Current form identifier.
Definition: efi_hii.h:35
#define EFI_IFR_FORM_OP

References DBGC, DBGC2_HDA, EFI_IFR_FORM_OP, efi_ifr_op(), efi_ifr_builder::form_id, _EFI_IFR_FORM::FormId, _EFI_IFR_FORM::FormTitle, _EFI_IFR_FORM::Header, efi_ifr_builder::ops_len, and _EFI_IFR_OP_HEADER::Scope.

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 194 of file efi_hii.c.

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

References DBGC, DBGC2_HDA, EFI_IFR_FORM_SET_OP, efi_ifr_op(), _EFI_IFR_FORM_SET::Flags, _EFI_IFR_FORM_SET::FormSetTitle, guid, _EFI_IFR_FORM_SET::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 243 of file efi_hii.c.

244  {
245  size_t dispaddr = ifr->ops_len;
246  EFI_IFR_GET *get;
247 
248  /* Add opcode */
249  get = efi_ifr_op ( ifr, EFI_IFR_GET_OP, sizeof ( *get ) );
250  get->VarStoreId = varstore_id;
251  get->VarStoreInfo.VarName = varstore_info;
252  get->VarStoreType = varstore_type;
253 
254  DBGC ( ifr, "IFR %p get varstore %#04x:%#04x type %#02x\n",
255  ifr, varstore_id, varstore_info, varstore_type );
256  DBGC2_HDA ( ifr, dispaddr, get, sizeof ( *get ) );
257 }
#define DBGC(...)
Definition: compiler.h:505
EFI_STRING_ID VarName
A 16-bit Buffer Storage offset.
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:98
union _EFI_IFR_GET::@537 VarStoreInfo
#define DBGC2_HDA(...)
Definition: compiler.h:523
size_t ops_len
Length of IFR opcodes.
Definition: efi_hii.h:25
UINT8 VarStoreType
Specifies the type used for storage.
EFI_VARSTORE_ID VarStoreId
Specifies the identifier of a previously declared variable store to use when retrieving the value.
#define EFI_IFR_GET_OP

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 265 of file efi_hii.c.

265  {
266  size_t dispaddr = ifr->ops_len;
267  EFI_IFR_GUID_CLASS *guid_class;
268 
269  /* Add opcode */
270  guid_class = efi_ifr_op ( ifr, EFI_IFR_GUID_OP,
271  sizeof ( *guid_class ) );
272  if ( ! guid_class )
273  return;
274  memcpy ( &guid_class->Guid, &tiano_guid, sizeof ( guid_class->Guid ) );
276  guid_class->Class = class;
277 
278  DBGC ( ifr, "IFR %p GUID class %#02x\n", ifr, class );
279  DBGC2_HDA ( ifr, dispaddr, guid_class, sizeof ( *guid_class ) );
280 }
static const EFI_GUID tiano_guid
Tiano GUID.
Definition: efi_hii.c:35
#define DBGC(...)
Definition: compiler.h:505
UINT16 Class
Device Class from the above.
Definition: MdeModuleHii.h:119
UINT8 ExtendOpCode
EFI_IFR_EXTEND_OP_CLASS.
Definition: MdeModuleHii.h:118
EFI_GUID Guid
EFI_IFR_TIANO_GUID.
Definition: MdeModuleHii.h:114
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:98
void * memcpy(void *dest, const void *src, size_t len) __nonnull
Device Class opcode.
Definition: MdeModuleHii.h:109
#define DBGC2_HDA(...)
Definition: compiler.h:523
size_t ops_len
Length of IFR opcodes.
Definition: efi_hii.h:25
#define EFI_IFR_GUID_OP
#define EFI_IFR_EXTEND_OP_CLASS
Definition: MdeModuleHii.h:38

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 288 of file efi_hii.c.

289  {
290  size_t dispaddr = ifr->ops_len;
291  EFI_IFR_GUID_SUBCLASS *guid_subclass;
292 
293  /* Add opcode */
294  guid_subclass = efi_ifr_op ( ifr, EFI_IFR_GUID_OP,
295  sizeof ( *guid_subclass ) );
296  if ( ! guid_subclass )
297  return;
298  memcpy ( &guid_subclass->Guid, &tiano_guid,
299  sizeof ( guid_subclass->Guid ) );
300  guid_subclass->ExtendOpCode = EFI_IFR_EXTEND_OP_SUBCLASS;
301  guid_subclass->SubClass = subclass;
302 
303  DBGC ( ifr, "IFR %p GUID subclass %#02x\n", ifr, subclass );
304  DBGC2_HDA ( ifr, dispaddr, guid_subclass, sizeof ( *guid_subclass ) );
305 }
UINT16 SubClass
Sub Class type from the above.
Definition: MdeModuleHii.h:140
static const EFI_GUID tiano_guid
Tiano GUID.
Definition: efi_hii.c:35
UINT8 ExtendOpCode
EFI_IFR_EXTEND_OP_SUBCLASS.
Definition: MdeModuleHii.h:139
#define DBGC(...)
Definition: compiler.h:505
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:98
void * memcpy(void *dest, const void *src, size_t len) __nonnull
#define EFI_IFR_EXTEND_OP_SUBCLASS
Definition: MdeModuleHii.h:39
#define DBGC2_HDA(...)
Definition: compiler.h:523
size_t ops_len
Length of IFR opcodes.
Definition: efi_hii.h:25
SubClass opcode.
Definition: MdeModuleHii.h:130
#define EFI_IFR_GUID_OP
EFI_GUID Guid
EFI_IFR_TIANO_GUID.
Definition: MdeModuleHii.h:135

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 322 of file efi_hii.c.

327  {
328  size_t dispaddr = ifr->ops_len;
329  EFI_IFR_NUMERIC *numeric;
330  unsigned int size;
331 
332  /* Add opcode */
333  numeric = efi_ifr_op ( ifr, EFI_IFR_NUMERIC_OP, sizeof ( *numeric ) );
334  if ( ! numeric )
335  return;
336  numeric->Question.Header.Prompt = prompt_id;
337  numeric->Question.Header.Help = help_id;
338  numeric->Question.QuestionId = question_id;
339  numeric->Question.VarStoreId = varstore_id;
340  numeric->Question.VarStoreInfo.VarName = varstore_info;
341  numeric->Question.Flags = vflags;
343  switch ( size ) {
345  numeric->data.u8.MinValue = min_value;
346  numeric->data.u8.MaxValue = max_value;
347  numeric->data.u8.Step = step;
348  break;
350  numeric->data.u16.MinValue = min_value;
351  numeric->data.u16.MaxValue = max_value;
352  numeric->data.u16.Step = step;
353  break;
355  numeric->data.u32.MinValue = min_value;
356  numeric->data.u32.MaxValue = max_value;
357  numeric->data.u32.Step = step;
358  break;
360  numeric->data.u64.MinValue = min_value;
361  numeric->data.u64.MaxValue = max_value;
362  numeric->data.u64.Step = step;
363  break;
364  }
365 
366  DBGC ( ifr, "IFR %p numeric prompt %#04x help %#04x question %#04x "
367  "varstore %#04x:%#04x\n", ifr, prompt_id, help_id, question_id,
368  varstore_id, varstore_info );
369  DBGC2_HDA ( ifr, dispaddr, numeric, sizeof ( *numeric ) );
370 }
#define EFI_IFR_NUMERIC_SIZE_8
#define EFI_IFR_NUMERIC_OP
#define EFI_IFR_NUMERIC_SIZE_4
#define DBGC(...)
Definition: compiler.h:505
struct MINMAXSTEP_DATA::@535 u64
union _EFI_IFR_QUESTION_HEADER::@531 VarStoreInfo
struct MINMAXSTEP_DATA::@534 u32
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:98
EFI_IFR_QUESTION_HEADER Question
#define EFI_IFR_NUMERIC_SIZE_2
#define DBGC2_HDA(...)
Definition: compiler.h:523
size_t ops_len
Length of IFR opcodes.
Definition: efi_hii.h:25
struct MINMAXSTEP_DATA::@532 u8
#define EFI_IFR_NUMERIC_SIZE
#define EFI_IFR_NUMERIC_SIZE_1
void step(void)
Single-step a single process.
Definition: process.c:98
struct MINMAXSTEP_DATA::@533 u16
uint8_t size
Entry size (in 32-bit words)
Definition: ena.h:16
uint8_t flags
Flags.
Definition: ena.h:18

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(), flags, _EFI_IFR_QUESTION_HEADER::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, step(), MINMAXSTEP_DATA::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 386 of file efi_hii.c.

390  {
391  size_t dispaddr = ifr->ops_len;
393 
394  /* Add opcode */
395  string = efi_ifr_op ( ifr, EFI_IFR_STRING_OP, sizeof ( *string ) );
396  if ( ! string )
397  return;
398  string->Question.Header.Prompt = prompt_id;
399  string->Question.Header.Help = help_id;
400  string->Question.QuestionId = question_id;
401  string->Question.VarStoreId = varstore_id;
402  string->Question.VarStoreInfo.VarName = varstore_info;
403  string->Question.Flags = vflags;
404  string->MinSize = min_size;
405  string->MaxSize = max_size;
406  string->Flags = flags;
407 
408  DBGC ( ifr, "IFR %p string prompt %#04x help %#04x question %#04x "
409  "varstore %#04x:%#04x\n", ifr, prompt_id, help_id, question_id,
410  varstore_id, varstore_info );
411  DBGC2_HDA ( ifr, dispaddr, string, sizeof ( *string ) );
412 }
#define EFI_IFR_STRING_OP
#define DBGC(...)
Definition: compiler.h:505
uint32_t string
Definition: multiboot.h:14
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:98
#define DBGC2_HDA(...)
Definition: compiler.h:523
size_t ops_len
Length of IFR opcodes.
Definition: efi_hii.h:25
uint8_t flags
Flags.
Definition: ena.h:18

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 419 of file efi_hii.c.

419  {
420  size_t dispaddr = ifr->ops_len;
421  EFI_IFR_SUPPRESS_IF *suppress_if;
422 
423  /* Add opcode */
424  suppress_if = efi_ifr_op ( ifr, EFI_IFR_SUPPRESS_IF_OP,
425  sizeof ( *suppress_if ) );
426  suppress_if->Header.Scope = 1;
427 
428  DBGC ( ifr, "IFR %p suppress-if\n", ifr );
429  DBGC2_HDA ( ifr, dispaddr, suppress_if, sizeof ( *suppress_if ) );
430 }
#define DBGC(...)
Definition: compiler.h:505
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:98
#define EFI_IFR_SUPPRESS_IF_OP
#define DBGC2_HDA(...)
Definition: compiler.h:523
size_t ops_len
Length of IFR opcodes.
Definition: efi_hii.h:25

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 440 of file efi_hii.c.

441  {
442  size_t dispaddr = ifr->ops_len;
443  EFI_IFR_TEXT *text;
444 
445  /* Add opcode */
446  text = efi_ifr_op ( ifr, EFI_IFR_TEXT_OP, sizeof ( *text ) );
447  if ( ! text )
448  return;
449  text->Statement.Prompt = prompt_id;
450  text->Statement.Help = help_id;
451  text->TextTwo = text_id;
452 
453  DBGC ( ifr, "IFR %p text prompt %#04x help %#04x text %#04x\n",
454  ifr, prompt_id, help_id, text_id );
455  DBGC2_HDA ( ifr, dispaddr, text, sizeof ( *text ) );
456 }
#define DBGC(...)
Definition: compiler.h:505
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:98
#define DBGC2_HDA(...)
Definition: compiler.h:523
EFI_IFR_STATEMENT_HEADER Statement
size_t ops_len
Length of IFR opcodes.
Definition: efi_hii.h:25
#define EFI_IFR_TEXT_OP

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 463 of file efi_hii.c.

463  {
464  size_t dispaddr = ifr->ops_len;
465  EFI_IFR_TRUE *true;
466 
467  /* Add opcode */
468  true = efi_ifr_op ( ifr, EFI_IFR_TRUE_OP, sizeof ( *true ) );
469 
470  DBGC ( ifr, "IFR %p true\n", ifr );
471  DBGC2_HDA ( ifr, dispaddr, true, sizeof ( *true ) );
472 }
#define DBGC(...)
Definition: compiler.h:505
#define EFI_IFR_TRUE_OP
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:98
#define DBGC2_HDA(...)
Definition: compiler.h:523
size_t ops_len
Length of IFR opcodes.
Definition: efi_hii.h:25

References DBGC, DBGC2_HDA, efi_ifr_op(), EFI_IFR_TRUE_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 481 of file efi_hii.c.

482  {
483  size_t dispaddr = ifr->ops_len;
484  EFI_IFR_VARSTORE_NAME_VALUE *varstore;
485 
486  /* Add opcode */
487  varstore = efi_ifr_op ( ifr, EFI_IFR_VARSTORE_NAME_VALUE_OP,
488  sizeof ( *varstore ) );
489  if ( ! varstore )
490  return 0;
491  varstore->VarStoreId = ++(ifr->varstore_id);
492  memcpy ( &varstore->Guid, guid, sizeof ( varstore->Guid ) );
493 
494  DBGC ( ifr, "IFR %p name/value store %#04x\n",
495  ifr, varstore->VarStoreId );
496  DBGC2_HDA ( ifr, dispaddr, varstore, sizeof ( *varstore ) );
497  return varstore->VarStoreId;
498 }
#define DBGC(...)
Definition: compiler.h:505
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:98
void * memcpy(void *dest, const void *src, size_t len) __nonnull
unsigned int varstore_id
Current variable store identifier.
Definition: efi_hii.h:33
#define DBGC2_HDA(...)
Definition: compiler.h:523
size_t ops_len
Length of IFR opcodes.
Definition: efi_hii.h:25
#define EFI_IFR_VARSTORE_NAME_VALUE_OP
uint64_t guid
GUID.
Definition: edd.h:30

References DBGC, DBGC2_HDA, efi_ifr_op(), EFI_IFR_VARSTORE_NAME_VALUE_OP, guid, _EFI_IFR_VARSTORE_NAME_VALUE::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 505 of file efi_hii.c.

505  {
506 
507  free ( ifr->ops );
508  free ( ifr->strings );
509  memset ( ifr, 0, sizeof ( *ifr ) );
510 }
EFI_HII_STRING_BLOCK * strings
Strings.
Definition: efi_hii.h:27
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
EFI_IFR_OP_HEADER * ops
IFR opcodes.
Definition: efi_hii.h:23
void * memset(void *dest, int character, size_t len) __nonnull

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 525 of file efi_hii.c.

528  {
529  struct {
531  struct {
533  uint8_t data[ifr->ops_len];
534  } __attribute__ (( packed )) ops;
535  struct {
536  union {
539  Language) +
540  strlen ( language ) + 1 /* NUL */ ];
541  } __attribute__ (( packed )) header;
542  uint8_t data[ifr->strings_len];
544  } __attribute__ (( packed )) strings;
546  } __attribute__ (( packed )) *package;
547 
548  /* Fail if any previous allocation failed */
549  if ( ifr->failed )
550  return NULL;
551 
552  /* Allocate package list */
553  package = zalloc ( sizeof ( *package ) );
554  if ( ! package )
555  return NULL;
556 
557  /* Populate package list */
558  package->header.PackageLength = sizeof ( *package );
559  memcpy ( &package->header.PackageListGuid, guid,
560  sizeof ( package->header.PackageListGuid ) );
561  package->ops.header.Length = sizeof ( package->ops );
562  package->ops.header.Type = EFI_HII_PACKAGE_FORMS;
563  memcpy ( package->ops.data, ifr->ops, sizeof ( package->ops.data ) );
564  package->strings.header.header.Header.Length =
565  sizeof ( package->strings );
566  package->strings.header.header.Header.Type =
568  package->strings.header.header.HdrSize =
569  sizeof ( package->strings.header );
570  package->strings.header.header.StringInfoOffset =
571  sizeof ( package->strings.header );
572  package->strings.header.header.LanguageName = language_id;
573  strcpy ( package->strings.header.header.Language, language );
574  memcpy ( package->strings.data, ifr->strings,
575  sizeof ( package->strings.data ) );
576  package->strings.end.BlockType = EFI_HII_SIBT_END;
577  package->end.Type = EFI_HII_PACKAGE_END;
578  package->end.Length = sizeof ( package->end );
579 
580  return &package->header;
581 }
#define __attribute__(x)
Definition: compiler.h:10
userptr_t data
Raw file image.
Definition: image.h:41
#define EFI_HII_SIBT_END
#define offsetof(type, field)
Get offset of a field within a structure.
Definition: stddef.h:24
u32 pad[9]
Padding.
Definition: ar9003_mac.h:90
EFI_HII_STRING_BLOCK * strings
Strings.
Definition: efi_hii.h:27
void * memcpy(void *dest, const void *src, size_t len) __nonnull
#define EFI_HII_PACKAGE_FORMS
#define EFI_HII_PACKAGE_STRINGS
char * strcpy(char *dest, const char *src)
Copy string.
Definition: string.c:326
The fixed header consists of a standard record header and then the string identifiers contained in th...
#define EFI_HII_PACKAGE_END
size_t strings_len
Length of strings.
Definition: efi_hii.h:29
size_t ops_len
Length of IFR opcodes.
Definition: efi_hii.h:25
size_t strlen(const char *src)
Get length of string.
Definition: string.c:243
unsigned char uint8_t
Definition: stdint.h:10
int failed
An allocation has failed.
Definition: efi_hii.h:37
EFI_IFR_OP_HEADER * ops
IFR opcodes.
Definition: efi_hii.h:23
uint64_t guid
GUID.
Definition: edd.h:30
The header found at the start of each package.
struct ena_aq_header header
Header.
Definition: ena.h:12
uint32_t end
Ending offset.
Definition: netvsc.h:18
The header found at the start of each package list.
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References __attribute__, image::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().