aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKonstantin Aladyshev <aladyshev22@gmail.com>2022-03-24 13:02:29 +0300
committerKonstantin Aladyshev <aladyshev22@gmail.com>2022-03-24 13:02:29 +0300
commit8c7b971a3f161bdf8c3dbb90759cd9d8eb39a251 (patch)
tree771a5bd852eb5d19954e2736a3fb1c10ffc6a14c
parent55746a0f328cfd7acef6a04f3f96ee0157d9fd91 (diff)
downloadUEFI-Lessons-8c7b971a3f161bdf8c3dbb90759cd9d8eb39a251.tar.gz
UEFI-Lessons-8c7b971a3f161bdf8c3dbb90759cd9d8eb39a251.tar.bz2
UEFI-Lessons-8c7b971a3f161bdf8c3dbb90759cd9d8eb39a251.zip
Add lesson 71
Signed-off-by: Konstantin Aladyshev <aladyshev22@gmail.com>
-rw-r--r--Lessons/Lesson_71/README.md128
-rw-r--r--README.md2
2 files changed, 130 insertions, 0 deletions
diff --git a/Lessons/Lesson_71/README.md b/Lessons/Lesson_71/README.md
new file mode 100644
index 0000000..43a5c84
--- /dev/null
+++ b/Lessons/Lesson_71/README.md
@@ -0,0 +1,128 @@
+# stringref
+
+https://edk2-docs.gitbook.io/edk-ii-vfr-specification/2_vfr_description_in_bnf/212_vfr_expression_statement_definition#2.12.11.4.7-stringref
+
+`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".
+
+# toupper/tolower
+
+https://edk2-docs.gitbook.io/edk-ii-vfr-specification/2_vfr_description_in_bnf/212_vfr_expression_statement_definition#2.12.11.6.8-toupper
+
+https://edk2-docs.gitbook.io/edk-ii-vfr-specification/2_vfr_description_in_bnf/212_vfr_expression_statement_definition#2.12.11.6.9-tolower
+
+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;
+```
+
+# length
+
+https://edk2-docs.gitbook.io/edk-ii-vfr-specification/2_vfr_description_in_bnf/212_vfr_expression_statement_definition#2.12.11.6.1-length
+
+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;
+```
+
+# More advanced atring builtins
+
+
+| keyword | IFR opcode | link |
+| ------------- | ------------- |
+| `catenate` | `EFI_IFR_CATENATE` | https://edk2-docs.gitbook.io/edk-ii-vfr-specification/2_vfr_description_in_bnf/212_vfr_expression_statement_definition#2.12.11.1-catenate |
+| `match` | `EFI_IFR_MATCH` | https://edk2-docs.gitbook.io/edk-ii-vfr-specification/2_vfr_description_in_bnf/212_vfr_expression_statement_definition#2.12.11.2-match |
+| `match2` | `EFI_IFR_MATCH2` | https://edk2-docs.gitbook.io/edk-ii-vfr-specification/2_vfr_description_in_bnf/212_vfr_expression_statement_definition#2.12.11.9-match2 |
+| `find` | `EFI_IFR_FIND` | https://edk2-docs.gitbook.io/edk-ii-vfr-specification/2_vfr_description_in_bnf/212_vfr_expression_statement_definition#2.12.11.7.2-find |
+| `mid` | `EFI_IFR_MID` | https://edk2-docs.gitbook.io/edk-ii-vfr-specification/2_vfr_description_in_bnf/212_vfr_expression_statement_definition#2.12.11.7.3-mid |
+| `token` | `EFI_IFR_TOKEN` | https://edk2-docs.gitbook.io/edk-ii-vfr-specification/2_vfr_description_in_bnf/212_vfr_expression_statement_definition#2.12.11.7.4-tok |
+| `span` | `EFI_IFR_SPAN` | https://edk2-docs.gitbook.io/edk-ii-vfr-specification/2_vfr_description_in_bnf/212_vfr_expression_statement_definition#2.12.11.7.5-span |
+
diff --git a/README.md b/README.md
index a408197..04e9571 100644
--- a/README.md
+++ b/README.md
@@ -73,6 +73,8 @@ These series of lessons are intendend to get you started with UEFI programming i
- [Lesson 67](Lessons/Lesson_67): More VFR input elements - Part 3: `date` and `time`
- [Lesson 68](Lessons/Lesson_68): More VFR input elements - Part 4: `oneof` and `orderedlist`
- [Lesson 69](Lessons/Lesson_69): Conditional keywords in VFR: `suppressif`/`grayoutif`/`disableif`/`warningif`/`nosubmitif`/`inconsistentif`
+- [Lesson 70](Lessons/Lesson_70): Constants and operators in VFR. Basic condition statements with builtins `ideqval`/`ideqvallist`/`ideqid`/`questionref`/`pushthis`
+- [Lesson 71](Lessons/Lesson_71): Basic VFR builtins for strings: `stringref`/`toupper`/`tolower`/`length`
_____