stringref
statement helps to get string values to the VFR code:
EFI_IFR_STRING_REF1
Summary:
Push a string on the expression stack.
Prototype:
#define EFI_IFR_STRING_REF1_OP 0x4e
typedef struct _EFI_IFR_STRING_REF1 {
EFI_IFR_OP_HEADER Header;
EFI_STRING_ID StringId;
} EFI_IFR_STRING_REF1;
Members:
Header The byte sequence that defines the type of opcode as well as the length of the opcode being defined.
Header.OpCode = EFI_IFR_STRING_REF1_OP.
StringId The string’s identifier, which must be unique within the package list.
Description:
Push the string specified by StringId on to the expression stack. If the string does not exist, then push an empty string.
For example this condition in a suppressif
statement is TRUE only if a string element has a specific data in itself:
string
name = StringQuestion,
...
endstring;
suppressif questionref(StringQuestion) == stringref(STRING_TOKEN(TEST_STRING));
...
endif;
Off course you need to define this new token that we use here for comparision:
#string TEST_STRING #language en-US "EDKII"
Another example of potential stringref
usage:
string
varid = FormData.StringValue,
prompt = STRING_TOKEN(STRING_PROMPT),
help = STRING_TOKEN(STRING_HELP),
minsize = 5,
maxsize = 10,
warningif
prompt = STRING_TOKEN(WARNING_IF_PROMPT),
pushthis == stringref(STRING_TOKEN(TEST_STRING))
endif;
endstring;
This code outputs a warning message if input string is equal to "EDKII".
The toupper
and tolower
builtin functions are encoded in EFI_IFR_TO_UPPER
(=0x21) and EFI_IFR_TO_LOWER
(=0x20) opcodes and help to change case-register of the string data.
For example this code will output warning on "EDKII" input as well as on "Edkii", "EDkii", "EDKii", "eDKii" and so on:
string
varid = FormData.StringValue,
prompt = STRING_TOKEN(STRING_PROMPT),
help = STRING_TOKEN(STRING_HELP),
minsize = 5,
maxsize = 10,
warningif
prompt = STRING_TOKEN(WARNING_IF_PROMPT),
toupper(pushthis) == stringref(STRING_TOKEN(TEST_STRING))
endif;
endstring;
And this code outputs warning only on "edkii" input:
string
name = StringQuestion,
varid = FormData.StringValue,
prompt = STRING_TOKEN(STRING_PROMPT),
help = STRING_TOKEN(STRING_HELP),
minsize = 5,
maxsize = 10,
warningif
prompt = STRING_TOKEN(WARNING_IF_PROMPT),
pushthis == tolower(stringref(STRING_TOKEN(TEST_STRING)))
endif;
endstring;
The length
keyword help get length of a buffer or a string. It is encoded with the EFI_IFR_LENGTH_OP = 0x56
opcode.
For example here the code suppressed only if the string question data is a string exactly of 7 symbols:
suppressif length(questionref(StringQuestion)) == 7;
...
endif;