From 79e990add09938e91be560869157ef77edf4df58 Mon Sep 17 00:00:00 2001 From: Joursoir Date: Tue, 12 Oct 2021 20:33:29 +0000 Subject: tbi: add sub-module 'screen' --- lib/tbi/screen.c | 35 +++++++++++++++++++++++++++++++++++ lib/tbi/screen.h | 30 ++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 lib/tbi/screen.c create mode 100644 lib/tbi/screen.h (limited to 'lib/tbi') diff --git a/lib/tbi/screen.c b/lib/tbi/screen.c new file mode 100644 index 0000000..7eb9ac2 --- /dev/null +++ b/lib/tbi/screen.c @@ -0,0 +1,35 @@ +#include +#include +#include +#include +#include + +#include "screen.h" + +struct screen *prepare_screen(VOID) +{ + struct screen *scr; + scr = AllocateZeroPool(sizeof(struct screen)); + if(!scr) + return NULL; + + scr->stdin = gST->ConIn; + scr->stdout = gST->ConOut; + scr->stderr = gST->StdErr; + + gST->ConOut->QueryMode( + gST->ConOut, + gST->ConOut->Mode->Mode, + &(scr->columns), + &(scr->lines) + ); + + return scr; +} + +VOID forget_screen(struct screen *scr) +{ + ASSERT(scr != NULL); + + FreePool(scr); +} diff --git a/lib/tbi/screen.h b/lib/tbi/screen.h new file mode 100644 index 0000000..ae25640 --- /dev/null +++ b/lib/tbi/screen.h @@ -0,0 +1,30 @@ +#ifndef UFM_TBI_SCREEN_H +#define UFM_TBI_SCREEN_H + +#include + +struct screen +{ + EFI_SIMPLE_TEXT_INPUT_PROTOCOL *stdin; + EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *stdout; + EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *stderr; + UINTN columns, lines; // current screen size +}; + +/* + * Prepares a structure with information about screen + * + * return: A pointer to the allocated structure or NULL if allocation fails +*/ +struct screen *prepare_screen(VOID); + +/* + * Frees the structure of the screen + * + * scr: the screen on which to operate + * + * return: VOID +*/ +VOID forget_screen(struct screen *scr); + +#endif /* UFM_TBI_SCREEN_H */ -- cgit v1.2.3-18-g5258