ReactOS 0.4.15-dev-7942-gd23573b
textcons.c
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING.ARM in the top level directory
3 * PROJECT: ReactOS UEFI Boot Library
4 * FILE: boot/environ/lib/io/display/textcons.c
5 * PURPOSE: Boot Library Text Console Routines
6 * PROGRAMMER: Alex Ionescu (alex.ionescu@reactos.org)
7 */
8
9/* INCLUDES ******************************************************************/
10
11#include "bl.h"
12
13/* DATA VARIABLES ************************************************************/
14
16{
25};
26
27/* FUNCTIONS *****************************************************************/
28
29VOID
32 )
33{
34
35}
36
40 )
41{
42 EfiPrintf(L"Not active yet!\r\n");
44}
45
49 _Out_ PBL_DISPLAY_STATE TextState
50 )
51{
53}
54
59 _In_ PBL_DISPLAY_STATE TextState
60 )
61{
62 return ConsoleFirmwareTextSetState(Console, Mask, TextState);
63}
64
69 )
70{
72}
73
77 _In_ ULONG NewTextResolution,
78 _Out_ PULONG OldTextResolution
79 )
80{
82}
83
87 _In_ BOOLEAN LineOnly
88 )
89{
90 return ConsoleFirmwareTextClear(Console, LineOnly);
91}
92
97 _In_ ULONG Attribute
98 )
99{
101}
102
105 _In_ PBL_TEXT_CONSOLE TextConsole,
106 _In_ BOOLEAN Activate
107 )
108{
110 BL_DISPLAY_STATE TextState;
111
112 /* Set our callbacks */
113 TextConsole->Callbacks = &ConsoleTextLocalVtbl;
114
115 /* Are we activating this console? */
116 if (Activate)
117 {
118 /* Call firmware to activate it */
119 Status = ConsoleFirmwareTextOpen(TextConsole);
120 if (!NT_SUCCESS(Status))
121 {
122 EfiPrintf(L"Failed to activate console: %lx\r\n", Status);
123 return Status;
124 }
125 }
126
127 /* Set default text state */
128 TextState.BgColor = 0;
129 TextState.XPos = 0;
130 TextState.YPos = 0;
131 TextState.CursorVisible = FALSE;
132 TextState.FgColor = White;
133
134 /* Are we activating? */
135 if (Activate)
136 {
137 /* Call firmware to set it */
138 Status = ConsoleFirmwareTextSetState(TextConsole, 0xF, &TextState);
139 if (!NT_SUCCESS(Status))
140 {
141 /* We failed, back down */
142 EfiPrintf(L"Failed to set console state: %lx\r\n", Status);
143 ConsoleFirmwareTextClose(TextConsole);
144 return Status;
145 }
146 }
147 else
148 {
149 /* Just save the state for now, someone else can activate later */
150 TextConsole->State = TextState;
151 }
152
153 /* Remember if we activated it */
154 TextConsole->Active = Activate;
155 return STATUS_SUCCESS;
156}
157
162 _In_ ULONG MaxIndex
163 )
164{
166
167 /* Loop until we hit the maximum supported list index */
168 ListEnd = &List[MaxIndex];
169 while (List != ListEnd)
170 {
171 /* Does this resolution match? */
172 if ((Mode->HRes == List->HRes) && (Mode->VRes == List->VRes))
173 {
174 /* Yep -- we got a match */
175 return TRUE;
176
177 }
178
179 /* Try another one*/
180 List++;
181 }
182
183 /* No matches were found */
184 return FALSE;
185}
186
188{
191};
192
193VOID
196 )
197{
198 /* Erase the current input buffer, and tear down the console */
200 BlMmFreeHeap(Console->Buffer);
201}
202
206 )
207{
209
210 /* Allocate a new 512 byte buffer */
212 Console->Buffer = Buffer;
213 if (!Buffer)
214 {
216 }
217
218 /* Set the current buffer pointers to it */
219 Console->DataStart = Buffer;
220 Console->DataEnd = Buffer;
221
222 /* Set the end 128 data entries into the buffer */
223 Console->EndBuffer = Buffer + 128;
224 return STATUS_SUCCESS;
225}
226
230 )
231{
233
234 /* Reset all the buffer pointers to the current buffer */
235 Buffer = Console->Buffer;
236 Console->DataStart = Buffer;
237 Console->DataEnd = Buffer;
238 Console->EndBuffer = Buffer + 128;
239 return STATUS_SUCCESS;
240}
241
244 VOID
245 )
246{
247 PBL_INPUT_CONSOLE InputConsole;
249
250 /* Allocate the input console */
251 InputConsole = BlMmAllocateHeap(sizeof(*InputConsole));
252 if (!InputConsole)
253 {
255 }
256
257 /* Construct it */
258 Status = ConsoleInputBaseConstruct(InputConsole);
259 if (!NT_SUCCESS(Status))
260 {
261 /* Tear down on failure */
262 BlMmFreeHeap(InputConsole);
263 return Status;
264 }
265
266 /* Set the callback table, and set us as the local input console */
267 InputConsole->Callbacks = &ConsoleInputLocalVtbl;
268 DspLocalInputConsole = InputConsole;
269 return STATUS_SUCCESS;
270}
unsigned char BOOLEAN
CConsole Console
LONG NTSTATUS
Definition: precomp.h:26
VOID EfiPrintf(_In_ PWCHAR Format,...)
Definition: firmware.c:126
NTSTATUS(* PCONSOLE_REINITIALIZE)(_In_ struct _BL_TEXT_CONSOLE *Console)
Definition: bl.h:487
PVOID BlMmAllocateHeap(_In_ SIZE_T Size)
Definition: heapalloc.c:569
PVOID DspLocalInputConsole
Definition: display.c:38
BOOLEAN ConsolepFindResolution(_In_ PBL_DISPLAY_MODE Mode, _In_ PBL_DISPLAY_MODE List, _In_ ULONG MaxIndex)
Definition: textcons.c:159
@ White
Definition: bl.h:212
NTSTATUS BlMmFreeHeap(_In_ PVOID Buffer)
Definition: heapalloc.c:663
VOID(* PCONSOLE_DESTRUCT)(_In_ struct _BL_TEXT_CONSOLE *Console)
Definition: bl.h:481
Definition: bufpool.h:45
char * Text
Definition: combotst.c:136
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTATUS ConsoleFirmwareTextOpen(_In_ PBL_TEXT_CONSOLE TextConsole)
Definition: textcons.c:421
VOID ConsoleFirmwareTextClose(_In_ PBL_TEXT_CONSOLE TextConsole)
Definition: textcons.c:398
NTSTATUS ConsoleInputLocalEraseBuffer(_In_ PBL_INPUT_CONSOLE Console, _In_opt_ PULONG FillValue)
Definition: textcons.c:527
NTSTATUS ConsoleFirmwareTextSetState(_In_ PBL_TEXT_CONSOLE TextConsole, _In_ UCHAR Mask, _In_ PBL_DISPLAY_STATE State)
Definition: textcons.c:198
NTSTATUS ConsoleFirmwareTextClear(_In_ PBL_TEXT_CONSOLE Console, _In_ BOOLEAN LineOnly)
Definition: textcons.c:557
unsigned int Mask
Definition: fpcontrol.c:82
Status
Definition: gdiplustypes.h:25
_In_ ULONG Mode
Definition: hubbusif.h:303
#define _Out_
Definition: ms_sal.h:345
#define _In_
Definition: ms_sal.h:308
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:239
#define L(x)
Definition: ntvdm.h:50
#define STATUS_SUCCESS
Definition: shellext.h:65
ULONG YPos
Definition: bl.h:1073
ULONG FgColor
Definition: bl.h:1071
ULONG BgColor
Definition: bl.h:1070
ULONG CursorVisible
Definition: bl.h:1074
ULONG XPos
Definition: bl.h:1072
PBL_INPUT_CONSOLE_VTABLE Callbacks
Definition: bl.h:1131
static COORD TextResolution
Definition: video.c:48
BL_TEXT_CONSOLE_VTABLE ConsoleTextLocalVtbl
Definition: textcons.c:15
VOID ConsoleTextLocalDestruct(_In_ struct _BL_TEXT_CONSOLE *Console)
Definition: textcons.c:30
NTSTATUS ConsoleTextLocalWriteText(_In_ struct _BL_TEXT_CONSOLE *Console, _In_ PCHAR Text, _In_ ULONG Attribute)
Definition: textcons.c:94
NTSTATUS ConsoleTextLocalSetTextResolution(_In_ struct _BL_TEXT_CONSOLE *Console, _In_ ULONG NewTextResolution, _Out_ PULONG OldTextResolution)
Definition: textcons.c:75
NTSTATUS ConsoleTextLocalSetTextState(_In_ struct _BL_TEXT_CONSOLE *Console, _In_ ULONG Mask, _In_ PBL_DISPLAY_STATE TextState)
Definition: textcons.c:56
NTSTATUS ConsoleCreateLocalInputConsole(VOID)
Definition: textcons.c:243
NTSTATUS ConsoleTextBaseGetTextState(_In_ struct _BL_TEXT_CONSOLE *Console, _Out_ PBL_DISPLAY_STATE TextState)
Definition: textcons.c:47
NTSTATUS ConsoleTextLocalConstruct(_In_ PBL_TEXT_CONSOLE TextConsole, _In_ BOOLEAN Activate)
Definition: textcons.c:104
NTSTATUS ConsoleTextLocalReinitialize(_In_ struct _BL_TEXT_CONSOLE *Console)
Definition: textcons.c:38
NTSTATUS ConsoleInputBaseReinitialize(_In_ PBL_INPUT_CONSOLE Console)
Definition: textcons.c:228
BL_INPUT_CONSOLE_VTABLE ConsoleInputLocalVtbl
Definition: textcons.c:187
NTSTATUS ConsoleTextBaseGetTextResolution(_In_ struct _BL_TEXT_CONSOLE *Console, _Out_ PULONG TextResolution)
Definition: textcons.c:66
NTSTATUS ConsoleTextLocalClearText(_In_ struct _BL_TEXT_CONSOLE *Console, _In_ BOOLEAN LineOnly)
Definition: textcons.c:85
NTSTATUS ConsoleInputBaseConstruct(_In_ PBL_INPUT_CONSOLE Console)
Definition: textcons.c:204
VOID ConsoleInputLocalDestruct(_In_ PBL_INPUT_CONSOLE Console)
Definition: textcons.c:194
uint32_t * PULONG
Definition: typedefs.h:59
uint32_t ULONG
Definition: typedefs.h:59
char * PCHAR
Definition: typedefs.h:51
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY ListEnd
Definition: exfuncs.h:1224