在這個章節中會探討Console Services的觀念及使用
主要可以分為三大類
在裡面有六個主要的entries主要可以分為三大類
- Input
- Output
- Errors
Console 主要是使用下面兩個Protocols
- EFI Simple Text Input :定義了最小的Input require給指定的ConIn Device
- Reset
- ReadKeyStroke
- WaitForKey
- EFI Simple Text Output :定義了最小的Output require給指定的ConOut & StdOut Device
typedef EFI_STATUS (EFIAPI *EFI_INPUT_READ_KEY)( IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This, OUT EFI_INPUT_KEY *Key ); typedef EFI_STATUS (EFIAPI *EFI_INPUT_RESET)( IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This, IN BOOLEAN ExtendedVerification ); /// /// The EFI_SIMPLE_TEXT_INPUT_PROTOCOL is used on the ConsoleIn device. /// It is the minimum required protocol for ConsoleIn. /// struct _EFI_SIMPLE_TEXT_INPUT_PROTOCOL { EFI_INPUT_RESET Reset; EFI_INPUT_READ_KEY ReadKeyStroke; /// /// Event to use with WaitForEvent() to wait for a key to be available /// EFI_EVENT WaitForKey; };
EFI_SIMPLE_TEXT_INPUT_PROTOCOL SimpleInput; EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL SimpleTextOutput; EFI_SIMPLE_TEXT_OUTPUT_MODE SimpleTextOutputMode; SimpleInput.Reset (&TerminalDevice->SimpleInput, FALSE ); if (TerminalDevice->SimpleInput.WaitForKey != NULL)在讀取key的時後有支援Scan code & Unicode
struct _EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL { EFI_TEXT_RESET Reset; EFI_TEXT_STRING OutputString; EFI_TEXT_TEST_STRING TestString; EFI_TEXT_QUERY_MODE QueryMode; EFI_TEXT_SET_MODE SetMode; EFI_TEXT_SET_ATTRIBUTE SetAttribute; EFI_TEXT_CLEAR_SCREEN ClearScreen; EFI_TEXT_SET_CURSOR_POSITION SetCursorPosition; EFI_TEXT_ENABLE_CURSOR EnableCursor; /// /// Pointer to SIMPLE_TEXT_OUTPUT_MODE data. /// EFI_SIMPLE_TEXT_OUTPUT_MODE *Mode; };
圖6.1中,介紹Input 跟 Output 之間互動的關係
而它們的定義是在SystemTable
路徑為 /MdePkg/Include/Uefi/UefiSpec.h /// /// EFI System Table /// typedef struct { /// /// The table header for the EFI System Table. /// EFI_TABLE_HEADER Hdr; /// /// A pointer to a null terminated string that identifies the vendor /// that produces the system firmware for the platform. /// CHAR16 *FirmwareVendor; /// /// A firmware vendor specific value that identifies the revision /// of the system firmware for the platform. /// UINT32 FirmwareRevision; /// /// The handle for the active console input device. This handle must support /// EFI_SIMPLE_TEXT_INPUT_PROTOCOL and EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL. /// EFI_HANDLE ConsoleInHandle; /// /// A pointer to the EFI_SIMPLE_TEXT_INPUT_PROTOCOL interface that is /// associated with ConsoleInHandle. /// EFI_SIMPLE_TEXT_INPUT_PROTOCOL *ConIn; /// /// The handle for the active console output device. /// EFI_HANDLE ConsoleOutHandle; /// /// A pointer to the EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL interface /// that is associated with ConsoleOutHandle. /// EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *ConOut; /// /// The handle for the active standard error console device. /// This handle must support the EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL. /// EFI_HANDLE StandardErrorHandle; /// /// A pointer to the EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL interface /// that is associated with StandardErrorHandle. /// EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *StdErr; /// /// A pointer to the EFI Runtime Services Table. /// EFI_RUNTIME_SERVICES *RuntimeServices; /// /// A pointer to the EFI Boot Services Table. /// EFI_BOOT_SERVICES *BootServices; /// /// The number of system configuration tables in the buffer ConfigurationTable. /// UINTN NumberOfTableEntries; /// /// A pointer to the system configuration tables. /// The number of entries in the table is NumberOfTableEntries. /// EFI_CONFIGURATION_TABLE *ConfigurationTable; } EFI_SYSTEM_TABLE;
- ConsoleInHandle – The handle for the active console input device.This handle must support the EFI Simple TextInput protocol
- ConIn – A pointer to the EFI Simple Text Input protocol interface that is associated with ConsoleInHandle.
- ConsoleOutHandle – The handle for the active console output device. This handle must support the EFI Simple Text output protocol
- ConOut – A pointer to the EFI Simple Text Output protocol interface that is associated with ConsoleOutHandle.
- StandardErrorHandle – The handle for the active standard error console device. This handle must support the EFI Simple Text output protocol
- StdErr – A pointer to the EFI Simple Text Output protocol interface that is associated with StandardErrorHandle.
在下面的表格中有解釋相關的意思
(#另外的Attribute的解釋可以看這篇文章 http://william30101.blogspot.com/2012/05/uefi-framework-5-efi-runtime.html )
- ConIn
- ConOut
- ErrOut
- ConInDev
- ConOutDev
- ErrOutDev
用法像code所示
gST->ConOut->SetAttribute(gST->ConOut, EFI_WHITE|EFI_BACKGROUND_GREEN); if(gST->ConIn->ReadKeyStroke(gST->ConIn, &inputSelection) != EFI_NOT_READY )
留言
張貼留言