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)
 
 FILE_SECBOOT (PERMITTED)
 
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 17 of file efi_hii.h.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ FILE_SECBOOT()

FILE_SECBOOT ( PERMITTED  )

◆ 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 49 of file efi_hii.h.

49  {
50  memset ( ifr, 0, sizeof ( *ifr ) );
51 }
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 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 va_end(ap)
Definition: stdarg.h:10
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
#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
ring len
Length.
Definition: dwmac.h:231
unsigned int string_id
Current string identifier.
Definition: efi_hii.h:32
size_t strings_len
Length of strings.
Definition: efi_hii.h:30
int failed
An allocation has failed.
Definition: efi_hii.h:38
__builtin_va_list va_list
Definition: stdarg.h:7
#define EFI_HII_SIBT_STRING_UCS2
int ssize_t const char * fmt
Definition: vsprintf.h:73
void * realloc(void *old_ptr, size_t new_size)
Reallocate memory.
Definition: malloc.c:607
typeof(acpi_finder=acpi_find)
ACPI table finder.
Definition: acpi.c:48
#define va_start(ap, last)
Definition: stdarg.h:8
#define NULL
NULL pointer (VOID *)
Definition: Base.h:322

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

133  {
134  size_t dispaddr = ifr->ops_len;
135  EFI_IFR_END *end;
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 }
#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:99
#define DBGC2_HDA(...)
Definition: compiler.h:523
size_t ops_len
Length of IFR opcodes.
Definition: efi_hii.h:26
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 149 of file efi_hii.c.

149  {
150  size_t dispaddr = ifr->ops_len;
151  EFI_IFR_FALSE *op;
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 }
#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:99
#define DBGC2_HDA(...)
Definition: compiler.h:523
size_t ops_len
Length of IFR opcodes.
Definition: efi_hii.h:26
static uint16_t struct vmbus_xfer_pages_operations * op
Definition: netvsc.h:327

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 }
#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:99
A form.
Definition: form_ui.c:65
#define DBGC2_HDA(...)
Definition: compiler.h:523
size_t ops_len
Length of IFR opcodes.
Definition: efi_hii.h:26
unsigned int form_id
Current form identifier.
Definition: efi_hii.h:36
#define EFI_IFR_FORM_OP

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 }
#define va_end(ap)
Definition: stdarg.h:10
128 bit buffer containing a unique identifier value.
Definition: Base.h:216
#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:99
#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:9
ring len
Length.
Definition: dwmac.h:231
#define DBGC2_HDA(...)
Definition: compiler.h:523
size_t ops_len
Length of IFR opcodes.
Definition: efi_hii.h:26
uint64_t guid
GUID.
Definition: edd.h:31
__builtin_va_list va_list
Definition: stdarg.h:7
#define va_start(ap, last)
Definition: stdarg.h:8
#define NULL
NULL pointer (VOID *)
Definition: Base.h:322

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 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 }
#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:99
#define DBGC2_HDA(...)
Definition: compiler.h:523
size_t ops_len
Length of IFR opcodes.
Definition: efi_hii.h:26
UINT8 VarStoreType
Specifies the type used for storage.
union _EFI_IFR_GET::@600 VarStoreInfo
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 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 }
static const EFI_GUID tiano_guid
Tiano GUID.
Definition: efi_hii.c:36
#define DBGC(...)
Definition: compiler.h:505
UINT16 Class
Device Class from the above.
Definition: MdeModuleHii.h:120
UINT8 ExtendOpCode
EFI_IFR_EXTEND_OP_CLASS.
Definition: MdeModuleHii.h:119
EFI_GUID Guid
EFI_IFR_TIANO_GUID.
Definition: MdeModuleHii.h:115
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
void * memcpy(void *dest, const void *src, size_t len) __nonnull
Device Class opcode.
Definition: MdeModuleHii.h:110
#define DBGC2_HDA(...)
Definition: compiler.h:523
size_t ops_len
Length of IFR opcodes.
Definition: efi_hii.h:26
#define EFI_IFR_GUID_OP
#define EFI_IFR_EXTEND_OP_CLASS
Definition: MdeModuleHii.h:39

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 ) );
301  guid_subclass->ExtendOpCode = EFI_IFR_EXTEND_OP_SUBCLASS;
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 }
UINT16 SubClass
Sub Class type from the above.
Definition: MdeModuleHii.h:141
static const EFI_GUID tiano_guid
Tiano GUID.
Definition: efi_hii.c:36
UINT8 ExtendOpCode
EFI_IFR_EXTEND_OP_SUBCLASS.
Definition: MdeModuleHii.h:140
#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:99
void * memcpy(void *dest, const void *src, size_t len) __nonnull
#define EFI_IFR_EXTEND_OP_SUBCLASS
Definition: MdeModuleHii.h:40
#define DBGC2_HDA(...)
Definition: compiler.h:523
size_t ops_len
Length of IFR opcodes.
Definition: efi_hii.h:26
SubClass opcode.
Definition: MdeModuleHii.h:131
#define EFI_IFR_GUID_OP
EFI_GUID Guid
EFI_IFR_TIANO_GUID.
Definition: MdeModuleHii.h:136

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_SIZE_8
#define EFI_IFR_NUMERIC_OP
#define EFI_IFR_NUMERIC_SIZE_4
uint16_t size
Buffer size.
Definition: dwmac.h:14
#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:99
struct MINMAXSTEP_DATA::@596 u16
EFI_IFR_QUESTION_HEADER Question
#define EFI_IFR_NUMERIC_SIZE_2
#define DBGC2_HDA(...)
Definition: compiler.h:523
uint8_t flags
Flags.
Definition: ena.h:18
size_t ops_len
Length of IFR opcodes.
Definition: efi_hii.h:26
union _EFI_IFR_QUESTION_HEADER::@594 VarStoreInfo
#define EFI_IFR_NUMERIC_SIZE
#define EFI_IFR_NUMERIC_SIZE_1
void step(void)
Single-step a single process.
Definition: process.c:99
struct MINMAXSTEP_DATA::@597 u32
struct MINMAXSTEP_DATA::@598 u64
struct MINMAXSTEP_DATA::@595 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(), 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 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
#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:99
#define DBGC2_HDA(...)
Definition: compiler.h:523
uint8_t flags
Flags.
Definition: ena.h:18
size_t ops_len
Length of IFR opcodes.
Definition: efi_hii.h:26

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 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:99
#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:26

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 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:99
#define DBGC2_HDA(...)
Definition: compiler.h:523
EFI_IFR_STATEMENT_HEADER Statement
size_t ops_len
Length of IFR opcodes.
Definition: efi_hii.h:26
#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 464 of file efi_hii.c.

464  {
465  size_t dispaddr = ifr->ops_len;
466  EFI_IFR_TRUE *op;
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 }
#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:99
#define DBGC2_HDA(...)
Definition: compiler.h:523
size_t ops_len
Length of IFR opcodes.
Definition: efi_hii.h:26
static uint16_t struct vmbus_xfer_pages_operations * op
Definition: netvsc.h:327

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;
485  EFI_IFR_VARSTORE_NAME_VALUE *varstore;
486 
487  /* Add opcode */
488  varstore = efi_ifr_op ( ifr, EFI_IFR_VARSTORE_NAME_VALUE_OP,
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 }
#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:99
void * memcpy(void *dest, const void *src, size_t len) __nonnull
unsigned int varstore_id
Current variable store identifier.
Definition: efi_hii.h:34
#define DBGC2_HDA(...)
Definition: compiler.h:523
size_t ops_len
Length of IFR opcodes.
Definition: efi_hii.h:26
#define EFI_IFR_VARSTORE_NAME_VALUE_OP
uint64_t guid
GUID.
Definition: edd.h:31

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

506  {
507 
508  free ( ifr->ops );
509  free ( ifr->strings );
510  memset ( ifr, 0, sizeof ( *ifr ) );
511 }
EFI_HII_STRING_BLOCK * strings
Strings.
Definition: efi_hii.h:28
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:55
EFI_IFR_OP_HEADER * ops
IFR opcodes.
Definition: efi_hii.h:24
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 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;
543  uint8_t data[ifr->strings_len];
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 __attribute__(x)
Definition: compiler.h:10
const void * data
Read-only data.
Definition: image.h:51
#define EFI_HII_SIBT_END
#define offsetof(type, field)
Get offset of a field within a structure.
Definition: stddef.h:25
u32 pad[9]
Padding.
Definition: ar9003_mac.h:47
EFI_HII_STRING_BLOCK * strings
Strings.
Definition: efi_hii.h:28
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:347
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:30
size_t ops_len
Length of IFR opcodes.
Definition: efi_hii.h:26
size_t strlen(const char *src)
Get length of string.
Definition: string.c:244
unsigned char uint8_t
Definition: stdint.h:10
int failed
An allocation has failed.
Definition: efi_hii.h:38
EFI_IFR_OP_HEADER * ops
IFR opcodes.
Definition: efi_hii.h:24
uint64_t guid
GUID.
Definition: edd.h:31
The header found at the start of each package.
struct ena_llq_option header
Header locations.
Definition: ena.h:16
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:322

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