ReactOS  r76032
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 
29 VOID
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 
58  _In_ ULONG Mask,
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 
96  _In_ PCHAR Text,
98  )
99 {
100  return STATUS_NOT_IMPLEMENTED;
101 }
102 
103 NTSTATUS
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 
158 BOOLEAN
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 
193 VOID
196  )
197 {
198  /* Erase the current input buffer, and tear down the console */
200  BlMmFreeHeap(Console->Buffer);
201 }
202 
203 NTSTATUS
206  )
207 {
208  PULONG Buffer;
209 
210  /* Allocate a new 512 byte buffer */
211  Buffer = BlMmAllocateHeap(512);
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 
227 NTSTATUS
230  )
231 {
232  PULONG Buffer;
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 
242 NTSTATUS
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 }
signed char * PCHAR
Definition: retypes.h:7
NTSTATUS ConsoleFirmwareTextClear(_In_ PBL_TEXT_CONSOLE Console, _In_ BOOLEAN LineOnly)
Definition: textcons.c:557
VOID ConsoleInputLocalDestruct(_In_ PBL_INPUT_CONSOLE Console)
Definition: textcons.c:194
UINTN Attribute
Definition: acefiex.h:227
#define TRUE
Definition: types.h:120
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ ULONG Mode
Definition: hubbusif.h:303
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY ListEnd
Definition: exfuncs.h:1015
Definition: bidi.c:75
return STATUS_SUCCESS
Definition: btrfs.c:2664
NTSTATUS ConsoleInputBaseConstruct(_In_ PBL_INPUT_CONSOLE Console)
Definition: textcons.c:204
PBL_INPUT_CONSOLE_VTABLE Callbacks
Definition: bl.h:1054
static COORD TextResolution
Definition: video.c:48
NTSTATUS BlMmFreeHeap(_In_ PVOID Buffer)
Definition: heapalloc.c:663
NTSTATUS ConsoleTextLocalSetTextState(_In_ struct _BL_TEXT_CONSOLE *Console, _In_ ULONG Mask, _In_ PBL_DISPLAY_STATE TextState)
Definition: textcons.c:56
Definition: bl.h:213
ULONG FgColor
Definition: bl.h:994
#define FALSE
Definition: types.h:117
NTSTATUS ConsoleTextBaseGetTextResolution(_In_ struct _BL_TEXT_CONSOLE *Console, _Out_ PULONG TextResolution)
Definition: textcons.c:66
NTSTATUS ConsoleTextLocalConstruct(_In_ PBL_TEXT_CONSOLE TextConsole, _In_ BOOLEAN Activate)
Definition: textcons.c:104
NTSTATUS ConsoleInputLocalEraseBuffer(_In_ PBL_INPUT_CONSOLE Console, _In_opt_ PULONG FillValue)
Definition: textcons.c:527
smooth NULL
Definition: ftsmooth.c:557
#define _Out_
Definition: no_sal2.h:323
NTSTATUS(* PCONSOLE_REINITIALIZE)(_In_ struct _BL_TEXT_CONSOLE *Console)
Definition: bl.h:488
NTSTATUS ConsoleTextLocalSetTextResolution(_In_ struct _BL_TEXT_CONSOLE *Console, _In_ ULONG NewTextResolution, _Out_ PULONG OldTextResolution)
Definition: textcons.c:75
unsigned char BOOLEAN
NTSTATUS ConsoleFirmwareTextOpen(_In_ PBL_TEXT_CONSOLE TextConsole)
Definition: textcons.c:421
LIST_ENTRY List
Definition: psmgr.c:57
BL_INPUT_CONSOLE_VTABLE ConsoleInputLocalVtbl
Definition: textcons.c:187
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
NTSTATUS ConsoleFirmwareTextSetState(_In_ PBL_TEXT_CONSOLE TextConsole, _In_ UCHAR Mask, _In_ PBL_DISPLAY_STATE State)
Definition: textcons.c:198
UINTN VOID * Buffer
Definition: acefiex.h:370
VOID ConsoleFirmwareTextClose(_In_ PBL_TEXT_CONSOLE TextConsole)
Definition: textcons.c:398
ULONG BgColor
Definition: bl.h:993
VOID(* PCONSOLE_DESTRUCT)(_In_ struct _BL_TEXT_CONSOLE *Console)
Definition: bl.h:482
Status
Definition: gdiplustypes.h:24
#define _In_
Definition: no_sal2.h:204
BOOLEAN ConsolepFindResolution(_In_ PBL_DISPLAY_MODE Mode, _In_ PBL_DISPLAY_MODE List, _In_ ULONG MaxIndex)
Definition: textcons.c:159
LONG NTSTATUS
Definition: DriverTester.h:11
PVOID DspLocalInputConsole
Definition: display.c:38
NTSTATUS ConsoleTextLocalWriteText(_In_ struct _BL_TEXT_CONSOLE *Console, _In_ PCHAR Text, _In_ ULONG Attribute)
Definition: textcons.c:94
unsigned int * PULONG
Definition: retypes.h:1
VOID EfiPrintf(_In_ PWCHAR Format,...)
Definition: firmware.c:126
VOID ConsoleTextLocalDestruct(_In_ struct _BL_TEXT_CONSOLE *Console)
Definition: textcons.c:30
CConsole Console
ULONG XPos
Definition: bl.h:995
NTSTATUS ConsoleTextLocalClearText(_In_ struct _BL_TEXT_CONSOLE *Console, _In_ BOOLEAN LineOnly)
Definition: textcons.c:85
unsigned int ULONG
Definition: retypes.h:1
ULONG YPos
Definition: bl.h:996
NTSTATUS ConsoleTextLocalReinitialize(_In_ struct _BL_TEXT_CONSOLE *Console)
Definition: textcons.c:38
PVOID BlMmAllocateHeap(_In_ ULONG Size)
Definition: heapalloc.c:569
NTSTATUS ConsoleTextBaseGetTextState(_In_ struct _BL_TEXT_CONSOLE *Console, _Out_ PBL_DISPLAY_STATE TextState)
Definition: textcons.c:47
char * Text
Definition: combotst.c:136
BL_TEXT_CONSOLE_VTABLE ConsoleTextLocalVtbl
Definition: textcons.c:15
ULONG CursorVisible
Definition: bl.h:997
NTSTATUS ConsoleCreateLocalInputConsole(VOID)
Definition: textcons.c:243
NTSTATUS ConsoleInputBaseReinitialize(_In_ PBL_INPUT_CONSOLE Console)
Definition: textcons.c:228