aboutsummaryrefslogtreecommitdiffstats
path: root/Library/UefiShellUfmCommandLib/tbi/screen.c
blob: daca9c989e1867c356e63982f403b2f2d671110a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <Uefi.h>
#include <Library/DebugLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/UefiBootServicesTableLib.h>

#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)
	);
	scr->attr = gST->ConOut->Mode->Attribute;

	return scr;
}

VOID forget_screen(struct screen *scr)
{
	ASSERT(scr != NULL);

	FreePool(scr);
}

VOID screen_clear(struct screen *scr)
{
	ASSERT(scr != NULL);

	scr->stdout->ClearScreen(scr->stdout);
}