oneof
varid = FormData.OneOfValue,
prompt = STRING_TOKEN(ONEOF_PROMPT),
help = STRING_TOKEN(ONEOF_HELP),
option text = STRING_TOKEN(ONEOF_OPTION1), value = 0x00, flags = DEFAULT;
option text = STRING_TOKEN(ONEOF_OPTION2), value = 0x33, flags = 0;
option text = STRING_TOKEN(ONEOF_OPTION3), value = 0x55, flags = 0;
endoneof;
Strings.uni에 새 문자열 토근을 추가해주자.
#string ONEOF_PROMPT #language en-US "OneOf list prompt"
#string ONEOF_HELP #language en-US "OneOf list help"
#string ONEOF_OPTION1 #language en-US "OneOf list option 1"
#string ONEOF_OPTION2 #language en-US "OneOf list option 2"
#string ONEOF_OPTION3 #language en-US "OneOf list option 3"
마지막으로 Data.h에 값을 넣어주자.
이를 Build 후 실행 시 아래와 같은 결과가 나타난다.
사용 가능한 옵션 중 하나를 선택 가능하다.
옵션 2를 선택하면 아래와 같이 뜬다. 옵션 2는 위에서 value 값을 0x33으로 설정했다. 그렇기 때문에 dmpstore 명령으로 해당 변수의 값을 확인하면 0x33이 있는 것 확인 가능하다.
IFR 코드는 아래와 같다
(Build/UefiLessonsPkg/RELEASE_GCC5/X64/UefiLessonsPkg/HIIFormDataElements/HIIFormDataElements/DEBUG/Form.lst):
첫 번째 opcode는 아래와 같다.
옵션 opcode에 대한 정의는 다음과 같다.
설명에 따르면 Value 필드의 내용은 Type 필드의 값에 따라 달라진다. 다음은 해당 type 플래그의 주석이 있는 모든 가능한 value type이다.
우리는 구조에서 데이터를 UINT8 OneOf로 선언했다. 따라서 컴파일러는 type 플래그를 EFI_IFR_TYPE_NUM_SIZE_8로 자동으로 공제했다. 이를 UINT16 OneOf로 변경하면 컴파일러는 type 필드 값을 EFI_IFR_TYPE_NUM_SIZE_16으로 변경한다.
아래의 출력을 이전의 출력과 비교해보자.
예를 들어 type을 EFI_HII_DATE OneOfValue로 설정하려고 하면 EFI_IFR_TYPE_VALUE가 숫자외에 많은 값을 가질 수 있지만 오류가 발생한다.
EFI_IFR_ONE_OF
Summary:
Creates a select-one-of question.
Prototype:
#define EFI_IFR_ONE_OF_OP 0x05
typedef struct _EFI_IFR_ONE_OF {
EFI_IFR_OP_HEADER Header;
EFI_IFR_QUESTION_HEADER Question;
UINT8 Flags;
union {
struct {
UINT8 MinValue;
UINT8 MaxValue;
UINT8 Step;
} u8;
struct {
UINT16 MinValue;
UINT16 MaxValue;
UINT16 Step;
} u16;
struct {
UINT32 MinValue;
UINT32 MaxValue;
UINT32 Step;
} u32;
struct {
UINT64 MinValue;
UINT64 MaxValue;
UINT64 Step;
} u64;
} data;
} EFI_IFR_ONE_OF;
Members:
Header The sequence that defines the type of opcode as well as the length of the opcode being defined.
Header.OpCode = EFI_IFR_ONE_OF_OP.
Question The standard question header.
Flags Specifies flags related to the numeric question.
MinValue The minimum value to be accepted by the browser for this opcode.
The size of the data field may vary from 8 to 64 bits, depending on the size specified in Flags
MaxValue The maximum value to be accepted by the browser for this opcode.
The size of the data field may vary from 8 to 64 bits, depending on the size specified in Flags
Step Defines the amount to increment or decrement the value each time a user requests a value change.
If the step value is 0, then the input mechanism for the numeric value is to be free-form
and require the user to type in the actual value.
The size of the data field may vary from 8 to 64 bits, depending on the size specified in Flags
Description:
This opcode creates a select-on-of object, where the user must select from one of the nested options.
This is identical to EFI_IFR_NUMERIC.
EFI_IFR_ONE_OF_OPTION
Summary:
Creates a pre-defined option for a question.
Prototype:
#define EFI_IFR_ONE_OF_OPTION_OP 0x09
typedef struct _EFI_IFR_ONE_OF_OPTION {
EFI_IFR_OP_HEADER Header;
EFI_STRING_ID Option;
UINT8 Flags;
UINT8 Type;
EFI_IFR_TYPE_VALUE Value;
} EFI_IFR_ONE_OF_OPTION;
Members:
Header The sequence that defines the type of opcode as well as the length of the opcode being defined.
Header.OpCode = EFI_IFR_ONE_OF_OPTION_OP.
Option The string token reference to the option description string for this particular opcode.
Flags Specifies the flags associated with the current option (EFI_IFR_OPTION_x)
Type Specifies the type of the option’s value (See EFI_IFR_TYPE)
Value The union of all of the different possible values. The actual contents (and size)
of the field depends on Type.
EFI_IFR_ORDERED_LIST
Summary:
Creates a set question using an ordered list.
#define EFI_IFR_ORDERED_LIST_OP 0x23
typedef struct _EFI_IFR_ORDERED_LIST {
EFI_IFR_OP_HEADER Header;
EFI_IFR_QUESTION_HEADER Question;
UINT8 MaxContainers;
UINT8 Flags;
} EFI_IFR_ORDERED_LIST;
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_ORDERED_LIST_OP.
Question The standard question header.
MaxContainers The maximum number of entries for which this tag will maintain an order.
This value also identifies the size of the storage associated with this tag’s ordering array.
Flags A bit-mask that determines which unique settings are active for this opcode.
Description:
Create an ordered list question in the current form. One thing to note is that valid values for the options
in ordered lists should never be a 0.
UINT8 MaxContainers; // 0x03
UINT8 Flags; // 0x00
UINT16 OrderedListValue[3];
0B 00 0A 00 0C 00
EFI_HII_DATE OrderedListValue[3];
orderedlist
varid = FormData.OrderedListValue,
prompt = STRING_TOKEN(ORDERED_LIST_PROMPT),
help = STRING_TOKEN(ORDERED_LIST_HELP),
option text = STRING_TOKEN(ORDERED_LIST_OPTION1), value = 2021/7/4, flags = 0;
option text = STRING_TOKEN(ORDERED_LIST_OPTION2), value = 2022/8/5, flags = 0;
option text = STRING_TOKEN(ORDERED_LIST_OPTION3), value = 2023/9/6, flags = 0;
endlist;