iPXE
Functions | Variables
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)
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 ( GPL2_OR_LATER_OR_UBDL  )
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.

References EFI_HII_STRING_BLOCK::BlockType, DBGC, EFI_HII_SIBT_STRING_UCS2, efi_vsnprintf(), efi_ifr_builder::failed, _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, va_end, and va_start.

Referenced by efi_snp_hii_package_list(), and efi_snp_hii_questions().

                                    {
        EFI_HII_STRING_BLOCK *new_strings;
        EFI_HII_SIBT_STRING_UCS2_BLOCK *ucs2;
        size_t new_strings_len;
        va_list args;
        size_t len;
        unsigned int string_id;

        /* Do nothing if a previous allocation has failed */
        if ( ifr->failed )
                return 0;

        /* Calculate string length */
        va_start ( args, fmt );
        len = ( efi_vsnprintf ( NULL, 0, fmt, args ) + 1 /* wNUL */ );
        va_end ( args );

        /* Reallocate strings */
        new_strings_len = ( ifr->strings_len +
                            offsetof ( typeof ( *ucs2 ), StringText ) +
                            ( len * sizeof ( ucs2->StringText[0] ) ) );
        new_strings = realloc ( ifr->strings, new_strings_len );
        if ( ! new_strings ) {
                ifr->failed = 1;
                return 0;
        }
        ucs2 = ( ( ( void * ) new_strings ) + ifr->strings_len );
        ifr->strings = new_strings;
        ifr->strings_len = new_strings_len;

        /* Fill in string */
        ucs2->Header.BlockType = EFI_HII_SIBT_STRING_UCS2;
        va_start ( args, fmt );
        efi_vsnprintf ( ucs2->StringText, len, fmt, args );
        va_end ( args );

        /* Allocate string ID */
        string_id = ++(ifr->string_id);

        DBGC ( ifr, "IFR %p string %#04x is \"%ls\"\n",
               ifr, string_id, ucs2->StringText );
        return string_id;
}
static 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 98 of file efi_hii.c.

References efi_ifr_builder::failed, len, _EFI_IFR_OP_HEADER::Length, memset(), NULL, op, opcode, _EFI_IFR_OP_HEADER::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_OP_HEADER *new_ops;
        EFI_IFR_OP_HEADER *op;
        size_t new_ops_len;

        /* Do nothing if a previous allocation has failed */
        if ( ifr->failed )
                return NULL;

        /* Reallocate opcodes */
        new_ops_len = ( ifr->ops_len + len );
        new_ops = realloc ( ifr->ops, new_ops_len );
        if ( ! new_ops ) {
                ifr->failed = 1;
                return NULL;
        }
        op = ( ( ( void * ) new_ops ) + ifr->ops_len );
        ifr->ops = new_ops;
        ifr->ops_len = new_ops_len;

        /* Fill in opcode header */
        memset ( op, 0, len );
        op->OpCode = opcode;
        op->Length = len;

        return 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.

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

                                                    {
        size_t dispaddr = ifr->ops_len;
        EFI_IFR_END *end;

        /* Add opcode */
        end = efi_ifr_op ( ifr, EFI_IFR_END_OP, sizeof ( *end ) );

        DBGC ( ifr, "IFR %p end\n", ifr );
        DBGC2_HDA ( ifr, dispaddr, end, sizeof ( *end ) );
}
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.

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

                                                      {
        size_t dispaddr = ifr->ops_len;
        EFI_IFR_FALSE *false;

        /* Add opcode */
        false = efi_ifr_op ( ifr, EFI_IFR_FALSE_OP, sizeof ( *false ) );

        DBGC ( ifr, "IFR %p false\n", ifr );
        DBGC2_HDA ( ifr, dispaddr, false, sizeof ( *false ) );
}
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.

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

                                                       {
        size_t dispaddr = ifr->ops_len;
        EFI_IFR_FORM *form;

        /* Add opcode */
        form = efi_ifr_op ( ifr, EFI_IFR_FORM_OP, sizeof ( *form ) );
        if ( ! form )
                return 0;
        form->Header.Scope = 1;
        form->FormId = ++(ifr->form_id);
        form->FormTitle = title_id;

        DBGC ( ifr, "IFR %p name/value store %#04x title %#04x\n",
               ifr, form->FormId, title_id );
        DBGC2_HDA ( ifr, dispaddr, form, sizeof ( *form ) );
        return form->FormId;
}
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.

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

                                                                              {
        size_t dispaddr = ifr->ops_len;
        EFI_IFR_FORM_SET *formset;
        EFI_GUID *class_guid;
        unsigned int num_class_guids = 0;
        size_t len;
        va_list args;

        /* Count number of class GUIDs */
        va_start ( args, help_id );
        while ( va_arg ( args, const EFI_GUID * ) != NULL )
                num_class_guids++;
        va_end ( args );

        /* Add opcode */
        len = ( sizeof ( *formset ) +
                ( num_class_guids * sizeof ( *class_guid ) ) );
        formset = efi_ifr_op ( ifr, EFI_IFR_FORM_SET_OP, len );
        if ( ! formset )
                return;
        formset->Header.Scope = 1;
        memcpy ( &formset->Guid, guid, sizeof ( formset->Guid ) );
        formset->FormSetTitle = title_id;
        formset->Help = help_id;
        formset->Flags = num_class_guids;

        /* Add class GUIDs */
        class_guid = ( ( ( void * ) formset ) + sizeof ( *formset ) );
        va_start ( args, help_id );
        while ( num_class_guids-- ) {
                memcpy ( class_guid++, va_arg ( args, const EFI_GUID * ),
                         sizeof ( *class_guid ) );
        }
        va_end ( args );

        DBGC ( ifr, "IFR %p formset title %#04x help %#04x\n",
               ifr, title_id, help_id );
        DBGC2_HDA ( ifr, dispaddr, formset, len );
}
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.

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

                                                                               {
        size_t dispaddr = ifr->ops_len;
        EFI_IFR_GET *get;

        /* Add opcode */
        get = efi_ifr_op ( ifr, EFI_IFR_GET_OP, sizeof ( *get ) );
        get->VarStoreId = varstore_id;
        get->VarStoreInfo.VarName = varstore_info;
        get->VarStoreType = varstore_type;

        DBGC ( ifr, "IFR %p get varstore %#04x:%#04x type %#02x\n",
               ifr, varstore_id, varstore_info, varstore_type );
        DBGC2_HDA ( ifr, dispaddr, get, sizeof ( *get ) );
}
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.

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(), and efi_ifr_builder::ops_len.

Referenced by efi_snp_hii_package_list().

                                                                               {
        size_t dispaddr = ifr->ops_len;
        EFI_IFR_GUID_CLASS *guid_class;

        /* Add opcode */
        guid_class = efi_ifr_op ( ifr, EFI_IFR_GUID_OP,
                                  sizeof ( *guid_class ) );
        if ( ! guid_class )
                return;
        memcpy ( &guid_class->Guid, &tiano_guid, sizeof ( guid_class->Guid ) );
        guid_class->ExtendOpCode = EFI_IFR_EXTEND_OP_CLASS;
        guid_class->Class = class;

        DBGC ( ifr, "IFR %p GUID class %#02x\n", ifr, class );
        DBGC2_HDA ( ifr, dispaddr, guid_class, sizeof ( *guid_class ) );
}
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.

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, and _EFI_IFR_GUID_SUBCLASS::SubClass.

Referenced by efi_snp_hii_package_list().

                                                        {
        size_t dispaddr = ifr->ops_len;
        EFI_IFR_GUID_SUBCLASS *guid_subclass;

        /* Add opcode */
        guid_subclass = efi_ifr_op ( ifr, EFI_IFR_GUID_OP,
                                     sizeof ( *guid_subclass ) );
        if ( ! guid_subclass )
                return;
        memcpy ( &guid_subclass->Guid, &tiano_guid,
                 sizeof ( guid_subclass->Guid ) );
        guid_subclass->ExtendOpCode = EFI_IFR_EXTEND_OP_SUBCLASS;
        guid_subclass->SubClass = subclass;

        DBGC ( ifr, "IFR %p GUID subclass %#02x\n", ifr, subclass );
        DBGC2_HDA ( ifr, dispaddr, guid_subclass, sizeof ( *guid_subclass ) );
}
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.

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, _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.

                                               {
        size_t dispaddr = ifr->ops_len;
        EFI_IFR_NUMERIC *numeric;
        unsigned int size;

        /* Add opcode */
        numeric = efi_ifr_op ( ifr, EFI_IFR_NUMERIC_OP, sizeof ( *numeric ) );
        if ( ! numeric )
                return;
        numeric->Question.Header.Prompt = prompt_id;
        numeric->Question.Header.Help = help_id;
        numeric->Question.QuestionId = question_id;
        numeric->Question.VarStoreId = varstore_id;
        numeric->Question.VarStoreInfo.VarName = varstore_info;
        numeric->Question.Flags = vflags;
        size = ( flags & EFI_IFR_NUMERIC_SIZE );
        switch ( size ) {
        case EFI_IFR_NUMERIC_SIZE_1 :
                numeric->data.u8.MinValue = min_value;
                numeric->data.u8.MaxValue = max_value;
                numeric->data.u8.Step = step;
                break;
        case EFI_IFR_NUMERIC_SIZE_2 :
                numeric->data.u16.MinValue = min_value;
                numeric->data.u16.MaxValue = max_value;
                numeric->data.u16.Step = step;
                break;
        case EFI_IFR_NUMERIC_SIZE_4 :
                numeric->data.u32.MinValue = min_value;
                numeric->data.u32.MaxValue = max_value;
                numeric->data.u32.Step = step;
                break;
        case EFI_IFR_NUMERIC_SIZE_8 :
                numeric->data.u64.MinValue = min_value;
                numeric->data.u64.MaxValue = max_value;
                numeric->data.u64.Step = step;
                break;
        }

        DBGC ( ifr, "IFR %p numeric prompt %#04x help %#04x question %#04x "
               "varstore %#04x:%#04x\n", ifr, prompt_id, help_id, question_id,
               varstore_id, varstore_info );
        DBGC2_HDA ( ifr, dispaddr, numeric, sizeof ( *numeric ) );
}
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.

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

                                                                     {
        size_t dispaddr = ifr->ops_len;
        EFI_IFR_STRING *string;

        /* Add opcode */
        string = efi_ifr_op ( ifr, EFI_IFR_STRING_OP, sizeof ( *string ) );
        if ( ! string )
                return;
        string->Question.Header.Prompt = prompt_id;
        string->Question.Header.Help = help_id;
        string->Question.QuestionId = question_id;
        string->Question.VarStoreId = varstore_id;
        string->Question.VarStoreInfo.VarName = varstore_info;
        string->Question.Flags = vflags;
        string->MinSize = min_size;
        string->MaxSize = max_size;
        string->Flags = flags;

        DBGC ( ifr, "IFR %p string prompt %#04x help %#04x question %#04x "
               "varstore %#04x:%#04x\n", ifr, prompt_id, help_id, question_id,
               varstore_id, varstore_info );
        DBGC2_HDA ( ifr, dispaddr, string, sizeof ( *string ) );
}
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.

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.

                                                            {
        size_t dispaddr = ifr->ops_len;
        EFI_IFR_SUPPRESS_IF *suppress_if;

        /* Add opcode */
        suppress_if = efi_ifr_op ( ifr, EFI_IFR_SUPPRESS_IF_OP,
                                   sizeof ( *suppress_if ) );
        suppress_if->Header.Scope = 1;

        DBGC ( ifr, "IFR %p suppress-if\n", ifr );
        DBGC2_HDA ( ifr, dispaddr, suppress_if, sizeof ( *suppress_if ) );
}
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.

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

                                                                    {
        size_t dispaddr = ifr->ops_len;
        EFI_IFR_TEXT *text;

        /* Add opcode */
        text = efi_ifr_op ( ifr, EFI_IFR_TEXT_OP, sizeof ( *text ) );
        if ( ! text )
                return;
        text->Statement.Prompt = prompt_id;
        text->Statement.Help = help_id;
        text->TextTwo = text_id;

        DBGC ( ifr, "IFR %p text prompt %#04x help %#04x text %#04x\n",
               ifr, prompt_id, help_id, text_id );
        DBGC2_HDA ( ifr, dispaddr, text, sizeof ( *text ) );
}
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.

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

                                                     {
        size_t dispaddr = ifr->ops_len;
        EFI_IFR_TRUE *true;

        /* Add opcode */
        true = efi_ifr_op ( ifr, EFI_IFR_TRUE_OP, sizeof ( *true ) );

        DBGC ( ifr, "IFR %p true\n", ifr );
        DBGC2_HDA ( ifr, dispaddr, true, sizeof ( *true ) );
}
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.

References DBGC, DBGC2_HDA, efi_ifr_op(), EFI_IFR_VARSTORE_NAME_VALUE_OP, _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().

                                                                     {
        size_t dispaddr = ifr->ops_len;
        EFI_IFR_VARSTORE_NAME_VALUE *varstore;

        /* Add opcode */
        varstore = efi_ifr_op ( ifr, EFI_IFR_VARSTORE_NAME_VALUE_OP,
                                sizeof ( *varstore ) );
        if ( ! varstore )
                return 0;
        varstore->VarStoreId = ++(ifr->varstore_id);
        memcpy ( &varstore->Guid, guid, sizeof ( varstore->Guid ) );

        DBGC ( ifr, "IFR %p name/value store %#04x\n",
               ifr, varstore->VarStoreId );
        DBGC2_HDA ( ifr, dispaddr, varstore, sizeof ( *varstore ) );
        return varstore->VarStoreId;
}
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.

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

Referenced by efi_snp_hii_package_list().

                                                  {

        free ( ifr->ops );
        free ( ifr->strings );
        memset ( ifr, 0, sizeof ( *ifr ) );
}
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.

References __attribute__, data, EFI_HII_PACKAGE_END, EFI_HII_PACKAGE_FORMS, EFI_HII_PACKAGE_STRINGS, EFI_HII_SIBT_END, end, efi_ifr_builder::failed, 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().

                                                                           {
        struct {
                EFI_HII_PACKAGE_LIST_HEADER header;
                struct {
                        EFI_HII_PACKAGE_HEADER header;
                        uint8_t data[ifr->ops_len];
                } __attribute__ (( packed )) ops;
                struct {
                        union {
                                EFI_HII_STRING_PACKAGE_HDR header;
                                uint8_t pad[offsetof(EFI_HII_STRING_PACKAGE_HDR,
                                                     Language) +
                                            strlen ( language ) + 1 /* NUL */ ];
                        } __attribute__ (( packed )) header;
                        uint8_t data[ifr->strings_len];
                        EFI_HII_STRING_BLOCK end;
                } __attribute__ (( packed )) strings;
                EFI_HII_PACKAGE_HEADER end;
        } __attribute__ (( packed )) *package;

        /* Fail if any previous allocation failed */
        if ( ifr->failed )
                return NULL;

        /* Allocate package list */
        package = zalloc ( sizeof ( *package ) );
        if ( ! package )
                return NULL;

        /* Populate package list */
        package->header.PackageLength = sizeof ( *package );
        memcpy ( &package->header.PackageListGuid, guid,
                 sizeof ( package->header.PackageListGuid ) );
        package->ops.header.Length = sizeof ( package->ops );
        package->ops.header.Type = EFI_HII_PACKAGE_FORMS;
        memcpy ( package->ops.data, ifr->ops, sizeof ( package->ops.data ) );
        package->strings.header.header.Header.Length =
                sizeof ( package->strings );
        package->strings.header.header.Header.Type =
                EFI_HII_PACKAGE_STRINGS;
        package->strings.header.header.HdrSize =
                sizeof ( package->strings.header );
        package->strings.header.header.StringInfoOffset =
                sizeof ( package->strings.header );
        package->strings.header.header.LanguageName = language_id;
        strcpy ( package->strings.header.header.Language, language );
        memcpy ( package->strings.data, ifr->strings,
                 sizeof ( package->strings.data ) );
        package->strings.end.BlockType = EFI_HII_SIBT_END;
        package->end.Type = EFI_HII_PACKAGE_END;
        package->end.Length = sizeof ( package->end );

        return &package->header;
}

Variable Documentation

Tiano GUID.

Definition at line 35 of file efi_hii.c.