From c25ac9da7d848f722ee7b9ba6121639480030a82 Mon Sep 17 00:00:00 2001 From: Konstantin Aladyshev Date: Tue, 13 Jul 2021 17:13:34 +0300 Subject: Add information about escape sequences in QEMU 'nographic' mode Signed-off-by: Konstantin Aladyshev --- Lessons/Lesson_18/PageUp.png | Bin 0 -> 2088 bytes Lessons/Lesson_18/README.md | 41 +++++++++++++++++++++++++++++++++++++++-- 2 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 Lessons/Lesson_18/PageUp.png (limited to 'Lessons') diff --git a/Lessons/Lesson_18/PageUp.png b/Lessons/Lesson_18/PageUp.png new file mode 100644 index 0000000..4ed626a Binary files /dev/null and b/Lessons/Lesson_18/PageUp.png differ diff --git a/Lessons/Lesson_18/README.md b/Lessons/Lesson_18/README.md index 228b311..cb566dc 100644 --- a/Lessons/Lesson_18/README.md +++ b/Lessons/Lesson_18/README.md @@ -101,8 +101,17 @@ Correct! FS0:\> ``` -With this app you can also look at how special keys are handled. -This is the output from "PageUp" key: +# Differences in keystroke handling with and without `-nographic` option in QEMU + +In our lessons we launch QEMU with a `-nographic` option: +``` +qemu-system-x86_64 \ + -drive if=pflash,format=raw,file=Build/OvmfX64/RELEASE_GCC5/FV/OVMF.fd \ + -drive format=raw,file=fat:rw:~/UEFI_disk \ + -nographic +``` + +With our app now you can observe how special keys are handled in this mode. For example this is the output from the "PageUp" key: ``` ScanCode = 0017, UnicodeChar = 0000 ( ) Wrong! @@ -113,4 +122,32 @@ Wrong! ScanCode = 0000, UnicodeChar = 007E (~) Wrong! ``` +But according to the UEFI spec and edk2 header for the `SimpleTextIn` protocol (https://github.com/tianocore/edk2/blob/master/MdePkg/Include/Protocol/SimpleTextIn.h) "PageUp" key should be displayed as a diferrent scan code, not as 4 symbols starting with the escape scan code: +``` +#define SCAN_PAGE_UP 0x0009 +... +#define SCAN_ESC 0x0017 +``` + +The problem is in the `-nographic` QEMU option. With it QEMU transforms all special keys to escape sequences like it happens in any console terminal. + +If you want to see 'native' behaviour you should run QEMU in graphic mode: +``` +qemu-system-x86_64 \ + -drive if=pflash,format=raw,file=Build/OvmfX64/RELEASE_GCC5/FV/OVMF.fd \ + -drive format=raw,file=fat:rw:~/UEFI_disk +``` +If your system doesn't support native graphics, you can run QEMU with a VNC option. QEMU will create a VNC server on the port that you've provided, and you can connect to that port via VNC client app (like VNC viewer for example https://www.realvnc.com/en/connect/download/viewer/). + +This command would produce VNC server on a `127.0.0.1:1` address: +``` +qemu-system-x86_64 \ + -drive if=pflash,format=raw,file=Build/OvmfX64/RELEASE_GCC5/FV/OVMF.fd \ + -drive format=raw,file=fat:rw:~/UEFI_disk \ + -vnc :1 +``` + +If you connect to QEMU launched with graphics you can observe that the "PageUp" press produces expected code: + +![PageUp](PageUp.png?raw=true "PageUp scan code on QEMU with graphics") -- cgit v1.2.3-18-g5258