22.3.4 QueryMode() Implementation

The QueryMode() function returns information supported modes. The UEFI Driver is required to return the number of Rows and number of Columns for each supported ModeNumber. ModeNumber must be less than Mode->MaxMode.


Note: All devices that support the Simple Text Output Protocol must minimally support an 80 x 25 character mode. Additional modes are optional. This means a basic Simple Text Output Protocol implementation supports a single ModeNumber of 0 with a geometry of 80 Columns and 25 Rows, and reports a Mode->MaxMode value of 1.


The QueryMode() function is typically used one of two ways:

1. Query for the geometry of the current mode. The following line populates the Columns and Rows variables with the geometry of the currently active console output.

Example 228-Query current Simple Text Output Mode
#include <Uefi.h>
#include <Protocol/SimpleTextOut.h>

EFI_STATUS Status;
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *SimpleTextOutput;
UINTN Columns;
UINTN Rows;

Status = SimpleTextOutput->QueryMode (
                             SimpleTextOutput,
                             SimpleTextOutput->Mode->Mode,
                             &Columns,
                             &Rows
                             );

2. Loop through all valid geometries that a given console can support. The following line populates (repeatedly) the Column and Row variables with the geometry of the each supported output mode.

Example 229-Query all Simple Text Output Modes
#include <Uefi.h>
#include <Protocol/SimpleTextOut.h>

EFI_STATUS Status;
UINTN Index;
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *SimpleTextOutput;
UINTN Columns;
UINTN Rows;

for (Index = 0 ; Index < SimpleTextOutput->Mode->MaxMode ; Index++) {
  Status = SimpleTextOutput->QueryMode (
                               SimpleTextOutput,
                               Index,
                               &Columns,
                               &Rows
                               );
}