blob: 1ac4b3c24e6a65d9a0337c3da81c8259aaf90d91 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
Now let's try to actually save some user input with a form.
For the data we will choose the most simple element - checkbox (https://edk2-docs.gitbook.io/edk-ii-vfr-specification/2_vfr_description_in_bnf/211_vfr_form_definition#2.11.6.5.1-vfr-checkbox-statement-definition)
Crete new application with a form and insert the following code inside:
```
checkbox
prompt = STRING_TOKEN(CHECKBOX_TITLE),
help = STRING_TOKEN(CHECKBOX_HELP),
endcheckbox;
```
This will give you the following element on form
![Checkbox1](Checkbox1.png?raw=true "Checkbox1")
Which you can toggle with a spacebar
![Checkbox2](Checkbox2.png?raw=true "Checkbox2")
The checkbox element will produce `EFI_IFR_CHECKBOX` and `EFI_IFR_END` opcodes:
```
checkbox
>00000039: 06 8E 05 00 06 00 01 00 00 00 FF FF 00 00
prompt = STRING_TOKEN(0x0005),
help = STRING_TOKEN(0x0006),
endcheckbox;
>00000047: 29 02
```
Here is a definition for the `EFI_IFR_CHECKBOX`:
```
EFI_IFR_CHECKBOX
Summary:
Creates a boolean checkbox.
Prototype:
#define EFI_IFR_CHECKBOX_OP 0x06
typedef struct _EFI_IFR_CHECKBOX {
EFI_IFR_OP_HEADER Header;
EFI_IFR_QUESTION_HEADER Question;
UINT8 Flags;
} EFI_IFR_CHECKBOX;
Members:
Header The standard question header, where Header.OpCode = EFI_IFR_CHECKBOX_OP.
Question The standard question header.
Flags Flags that describe the behavior of the question. All undefined bits should be zero.
Description:
Creates a Boolean checkbox question and adds it to the current form. The checkbox has two values:
FALSE if the box is not checked and TRUE if it is.
```
And for its field `EFI_IFR_QUESTION_HEADER`:
```
EFI_IFR_QUESTION_HEADER
Summary:
Standard question header.
Prototype:
typedef struct _EFI_IFR_QUESTION_HEADER {
EFI_IFR_STATEMENT_HEADER Header;
EFI_QUESTION_ID QuestionId;
EFI_VARSTORE_ID VarStoreId;
union {
EFI_STRING_ID VarName;
UINT16 VarOffset;
} VarStoreInfo;
UINT8 Flags;
} EFI_IFR_QUESTION_HEADER;
Members:
Header The standard statement header.
QuestionId The unique value that identifies the particular question being defined by the opcode. The value of zero is reserved.
Flags A bit-mask that determines which unique settings are active for this question.
VarStoreId Specifies the identifier of a previously declared variable store to use when storing the question’s value.
A value of zero indicates no associated variable store.
VarStoreInfo If VarStoreId refers to Buffer Storage (EFI_IFR_VARSTORE or EFI_IFR_VARSTORE_EFI), then VarStoreInfo contains a 16-bit Buffer Storage offset (VarOffset).
If VarStoreId refers to Name/Value Storage (EFI_IFR_VARSTORE_NAME_VALUE), then VarStoreInfo contains the String ID of the name (VarName) for this name/value pair.
Description
This is the standard header for questions.
```
# Creating `efivarstore`
FS0:\> dmpstore -all
```
Variable NV+BS 'EF2ACC91-7B50-4AB9-AB67-2B04F8BC135E:HIIFormCheckboxEfiVarstore' DataSize = 0x01
00000000: 01 *.*
```
FS0:\> dmpstore -guid EF2ACC91-7B50-4AB9-AB67-2B04F8BC135E
Variable NV+BS 'EF2ACC91-7B50-4AB9-AB67-2B04F8BC135E:HIIFormCheckboxEfiVarstore' DataSize = 0x01
00000000: 01 *.*
|