UEFIStarter
a simple UEFI framework
|
CLI initialization and I/O helpers. More...
Go to the source code of this file.
Functions | |
EFI_STATUS EFIAPI | init (INTN argc, CHAR16 **argv, UINTN arg_group_count,...) |
Initializes an UEFIStarter application. More... | |
void | shutdown () |
Shuts the UEFIStarter internals down. More... | |
void | print_console_modes () |
Prints the list of available console modes. More... | |
EFI_STATUS | set_console_mode (unsigned int requested_mode) |
Sets a new text mode. More... | |
void EFIAPI | color_print (UINTN color, CHAR16 *fmt,...) |
Prints a text with the given color. More... | |
void | drain_key_buffer () |
Empties the keyboard input buffer. More... | |
void | wait_for_key () |
Waits for any keystroke. More... | |
CLI initialization and I/O helpers.
EFI_STATUS EFIAPI init | ( | INTN | argc, |
CHAR16 ** | argv, | ||
UINTN | arg_group_count, | ||
... | |||
) |
Initializes an UEFIStarter application.
Call this as early as possible to gain access to the memory tracking, logging and other features.
If this function returns error/warning codes the exact code should tell what went wrong; usually there are log entries as well.
Keep in mind that the RV_HELP return code isn't an error per se, it's just to indicate that the user wanted (and received) the help screen.
argc | the number of command-line arguments |
argv | the list of command-line arguments, as UTF-16 |
arg_group_count | the number of command-line argument groups |
... | the list of command-line argument groups (cmdline_argument_group_t *) |
void shutdown | ( | ) |
Shuts the UEFIStarter internals down.
This will stop the memory tracker, upon which any unfreed memory gets reported.
Unfreed memory will continue to use up memory in the UEFI environment even after the application stopped. If you didn't keep the pages allocated on purpose you'll probably want to free them before calling this.
If you're keeping the pages allocated on purpose (e.g. because you need to mark memory as reserved) you can disable tracking (and thus reporting) for them by using allocate_pages_ex() with track=FALSE (if you make it accessible with "extern"). Alternatively you can just use UEFI's AllocatePages() function, it doesn't track allocated pages at all.
void print_console_modes | ( | ) |
Prints the list of available console modes.
Keep in mind that UEFI requires all systems to list modes 0 and 1, but only 0 and any listed 2+ have to work.
EFI_STATUS set_console_mode | ( | unsigned int | requested_mode | ) |
Sets a new text mode.
Keep in mind that the graphics mode takes precedence: if, for example, you set graphics mode 640x480 and then change to a text mode that would require 960x700 pixels you'll get the requested console size but the window will remain at 640x480!
requested_mode | the graphics mode to set |
void EFIAPI color_print | ( | UINTN | color, |
CHAR16 * | fmt, | ||
... | |||
) |
Prints a text with the given color.
Takes the same format strings as EDK's print functions.
color | the color value to print with, as a 4-bit number |
fmt | the format string, as UTF-16 |
... | any parameters to the print function |
void drain_key_buffer | ( | ) |
Empties the keyboard input buffer.
Use this e.g. before and after waiting for the much sought after "any" key to prevent previous keystrokes from canceling the wait and the new keystrokes from triggering later input events.
void wait_for_key | ( | ) |
Waits for any keystroke.
Note that if you're in a virtualized environment some keystrokes will not trigger this, depending on your input method, terminal emulation, console multiplexers and so on. This is most apparent with the Escape key: under some circumstances it just won't register as an individual keystroke.