ReactOS 0.4.15-dev-5666-gc548b97
textcons.c File Reference
#include "bl.h"
Include dependency graph for textcons.c:

Go to the source code of this file.

Functions

BL_COLOR ConsoleEfiTextGetColorForeground (_In_ UINT32 Attributes)
 
BL_COLOR ConsoleEfiTextGetColorBackground (_In_ UINT32 Attributes)
 
ULONG ConsoleEfiTextGetEfiColorBackground (_In_ BL_COLOR Color)
 
ULONG ConsoleEfiTextGetEfiColorForeground (_In_ BL_COLOR Color)
 
ULONG ConsoleEfiTextGetAttribute (BL_COLOR BgColor, BL_COLOR FgColor)
 
VOID ConsoleEfiTextGetStateFromMode (_In_ EFI_SIMPLE_TEXT_OUTPUT_MODE *Mode, _Out_ PBL_DISPLAY_STATE State)
 
NTSTATUS ConsoleFirmwareTextSetState (_In_ PBL_TEXT_CONSOLE TextConsole, _In_ UCHAR Mask, _In_ PBL_DISPLAY_STATE State)
 
NTSTATUS ConsoleEfiTextFindModeFromAllowed (_In_ SIMPLE_TEXT_OUTPUT_INTERFACE *TextProtocol, _In_ PBL_DISPLAY_MODE SupportedModes, _In_ ULONG MaxIndex, _Out_ PULONG SupportedMode)
 
VOID ConsoleFirmwareTextClose (_In_ PBL_TEXT_CONSOLE TextConsole)
 
NTSTATUS ConsoleFirmwareTextOpen (_In_ PBL_TEXT_CONSOLE TextConsole)
 
NTSTATUS ConsoleInputBaseEraseBuffer (_In_ PBL_INPUT_CONSOLE Console, _In_opt_ PULONG FillValue)
 
NTSTATUS ConsoleInputLocalEraseBuffer (_In_ PBL_INPUT_CONSOLE Console, _In_opt_ PULONG FillValue)
 
NTSTATUS ConsoleFirmwareTextClear (_In_ PBL_TEXT_CONSOLE Console, _In_ BOOLEAN LineOnly)
 

Function Documentation

◆ ConsoleEfiTextFindModeFromAllowed()

NTSTATUS ConsoleEfiTextFindModeFromAllowed ( _In_ SIMPLE_TEXT_OUTPUT_INTERFACE TextProtocol,
_In_ PBL_DISPLAY_MODE  SupportedModes,
_In_ ULONG  MaxIndex,
_Out_ PULONG  SupportedMode 
)

Definition at line 318 of file textcons.c.

324{
326 ULONG MaxMode, MaxQueriedMode, Mode, i, MatchingMode;
327 UINTN HRes, VRes;
328 ULONGLONG ModeListSize;
329 PBL_DISPLAY_MODE ModeEntry, ModeList, SupportedModeEntry;
331
332 /* Read information on the current mode */
333 EfiConOutReadCurrentMode(TextProtocol, &ModeInfo);
334
335 /* Figure out the max mode, and how many modes we'll have to read */
336 MaxMode = ModeInfo.MaxMode;
337 ModeListSize = sizeof(*ModeEntry) * ModeInfo.MaxMode;
338 if (ModeListSize > MAXULONG)
339 {
341 }
342
343 /* Allocate a list for all the supported EFI modes */
344 ModeList = BlMmAllocateHeap(ModeListSize);
345 if (!ModeList)
346 {
348 }
349
350 /* Scan all the EFI modes */
351 EfiPrintf(L"Scanning through %d modes\r\n", MaxMode);
352 for (MaxQueriedMode = 0, Mode = 0; Mode < MaxMode; Mode++)
353 {
354 /* Query information on this mode */
355 ModeEntry = &ModeList[MaxQueriedMode];
356 if (NT_SUCCESS(EfiConOutQueryMode(TextProtocol,
357 Mode,
358 &HRes,
359 &VRes)))
360 {
361 /* This mode was successfully queried. Save the data */
362 EfiPrintf(L"EFI Firmware Supported Mode %d is H: %d V: %d\r\n", Mode, HRes, VRes);
363 ModeEntry->HRes = HRes;
364 ModeEntry->VRes = VRes;
365 ModeEntry->HRes2 = HRes;
366 MaxQueriedMode = Mode + 1;
367 }
368 }
369
370 /* Loop all the supported mode entries */
371 for (i = 0; i < MaxIndex; i++)
372 {
373 /* Loop all the UEFI queried modes */
374 SupportedModeEntry = &SupportedModes[i];
375 for (MatchingMode = 0; MatchingMode < MaxQueriedMode; MatchingMode++)
376 {
377 /* Check if the UEFI mode is compatible with our supported mode */
378 ModeEntry = &ModeList[MatchingMode];
379 EfiPrintf(L"H1: %d V1: %d - H2: %d - V2: %d\r\n", ModeEntry->HRes, ModeEntry->VRes, SupportedModeEntry->HRes, SupportedModeEntry->VRes);
380 if ((ModeEntry->HRes == SupportedModeEntry->HRes) &&
381 (ModeEntry->VRes == SupportedModeEntry->VRes))
382 {
383 /* Yep -- free the mode list and return this mode */
384 BlMmFreeHeap(ModeList);
385 *SupportedMode = MatchingMode;
386 return STATUS_SUCCESS;
387 }
388 }
389 }
390
391 /* We can't do anything -- there are no matching modes */
393 BlMmFreeHeap(ModeList);
394 return Status;
395}
UINT32 UINTN
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS EfiConOutQueryMode(_In_ SIMPLE_TEXT_OUTPUT_INTERFACE *TextInterface, _In_ ULONG Mode, _In_ UINTN *Columns, _In_ UINTN *Rows)
Definition: firmware.c:1032
VOID EfiPrintf(_In_ PWCHAR Format,...)
Definition: firmware.c:126
PVOID BlMmAllocateHeap(_In_ SIZE_T Size)
Definition: heapalloc.c:569
VOID EfiConOutReadCurrentMode(_In_ SIMPLE_TEXT_OUTPUT_INTERFACE *TextInterface, _Out_ EFI_SIMPLE_TEXT_OUTPUT_MODE *Mode)
Definition: firmware.c:1227
NTSTATUS BlMmFreeHeap(_In_ PVOID Buffer)
Definition: heapalloc.c:663
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
Status
Definition: gdiplustypes.h:25
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
_In_ ULONG Mode
Definition: hubbusif.h:303
unsigned int ULONG
Definition: retypes.h:1
#define STATUS_INTEGER_OVERFLOW
Definition: ntstatus.h:385
#define L(x)
Definition: ntvdm.h:50
#define STATUS_SUCCESS
Definition: shellext.h:65
ULONG HRes2
Definition: bl.h:1081
ULONG HRes
Definition: bl.h:1079
ULONG VRes
Definition: bl.h:1080
#define MAXULONG
Definition: typedefs.h:251
uint64_t ULONGLONG
Definition: typedefs.h:67
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158

Referenced by ConsoleFirmwareTextOpen().

◆ ConsoleEfiTextGetAttribute()

ULONG ConsoleEfiTextGetAttribute ( BL_COLOR  BgColor,
BL_COLOR  FgColor 
)

Definition at line 170 of file textcons.c.

174{
175 /* Convert each part and OR into a single attribute */
178}
ULONG ConsoleEfiTextGetEfiColorForeground(_In_ BL_COLOR Color)
Definition: textcons.c:126
ULONG ConsoleEfiTextGetEfiColorBackground(_In_ BL_COLOR Color)
Definition: textcons.c:90

Referenced by ConsoleFirmwareTextSetState().

◆ ConsoleEfiTextGetColorBackground()

BL_COLOR ConsoleEfiTextGetColorBackground ( _In_ UINT32  Attributes)

Definition at line 62 of file textcons.c.

65{
66 /* Read the background color attribute and convert to CGA color index */
67 switch (Attributes & 0xF0)
68 {
70 return Magenta;
72 return Brown;
74 return White;
76 default:
77 return Black;
79 return Red;
81 return Green;
83 return Cyan;
85 return Blue;
86 }
87}
#define EFI_BACKGROUND_LIGHTGRAY
#define EFI_BACKGROUND_BLUE
#define EFI_BACKGROUND_BROWN
#define EFI_BACKGROUND_RED
#define EFI_BACKGROUND_BLACK
#define EFI_BACKGROUND_CYAN
#define EFI_BACKGROUND_MAGENTA
#define EFI_BACKGROUND_GREEN
@ Brown
Definition: bl.h:203
@ Cyan
Definition: bl.h:200
@ Magenta
Definition: bl.h:202
@ White
Definition: bl.h:212
@ Black
Definition: bl.h:197
@ Green
Definition: bl.h:199
@ Red
Definition: bl.h:201
@ Blue
Definition: bl.h:198
_Must_inspect_result_ _In_ WDFDMAENABLER _In_ _In_opt_ PWDF_OBJECT_ATTRIBUTES Attributes

Referenced by ConsoleEfiTextGetStateFromMode().

◆ ConsoleEfiTextGetColorForeground()

BL_COLOR ConsoleEfiTextGetColorForeground ( _In_ UINT32  Attributes)

Definition at line 18 of file textcons.c.

21{
22 /* Read the foreground color attribute and convert to CGA color index */
23 switch (Attributes & 0x0F)
24 {
25 case EFI_BLACK:
26 return Black;
27 case EFI_BLUE:
28 return Blue;
29 case EFI_GREEN:
30 return Green;
31 case EFI_RED:
32 return Red;
33 case EFI_CYAN:
34 return Cyan;
35 case EFI_MAGENTA:
36 return Magenta;
37 case EFI_BROWN:
38 return Brown;
39 case EFI_LIGHTGRAY:
40 return LtGray;
41 case EFI_DARKGRAY:
42 return Gray;
43 case EFI_LIGHTBLUE:
44 return LtBlue;
45 case EFI_LIGHTGREEN:
46 return LtGreen;
47 case EFI_LIGHTCYAN:
48 return LtCyan;
49 case EFI_LIGHTRED:
50 return LtRed;
52 return LtMagenta;
53 case EFI_YELLOW:
54 return Yellow;
55 case EFI_WHITE:
56 default:
57 return White;
58 }
59}
#define EFI_LIGHTRED
#define EFI_LIGHTBLUE
#define EFI_RED
#define EFI_CYAN
#define EFI_DARKGRAY
#define EFI_LIGHTGRAY
#define EFI_BROWN
#define EFI_MAGENTA
#define EFI_LIGHTGREEN
#define EFI_BLUE
#define EFI_BLACK
#define EFI_YELLOW
#define EFI_GREEN
#define EFI_LIGHTMAGENTA
#define EFI_WHITE
#define EFI_LIGHTCYAN
@ LtRed
Definition: bl.h:209
@ LtMagenta
Definition: bl.h:210
@ LtBlue
Definition: bl.h:206
@ LtCyan
Definition: bl.h:208
@ LtGreen
Definition: bl.h:207
@ Gray
Definition: bl.h:205
@ LtGray
Definition: bl.h:204
@ Yellow
Definition: bl.h:211

Referenced by ConsoleEfiTextGetStateFromMode().

◆ ConsoleEfiTextGetEfiColorBackground()

ULONG ConsoleEfiTextGetEfiColorBackground ( _In_ BL_COLOR  Color)

Definition at line 90 of file textcons.c.

93{
94 /* Convert the CGA color index into an EFI background attribute */
95 switch (Color)
96 {
97 case Blue:
98 case LtBlue:
100 case Green:
101 case LtGreen:
103 case Cyan:
104 case LtCyan:
105 return EFI_BACKGROUND_CYAN;
106 case Red:
107 case LtRed:
108 return EFI_BACKGROUND_RED;
109 case Magenta:
110 case LtMagenta:
112 case Brown:
113 case Yellow:
115 case LtGray:
116 case White:
118 case Black:
119 case Gray:
120 default:
122 }
123}

Referenced by ConsoleEfiTextGetAttribute().

◆ ConsoleEfiTextGetEfiColorForeground()

ULONG ConsoleEfiTextGetEfiColorForeground ( _In_ BL_COLOR  Color)

Definition at line 126 of file textcons.c.

129{
130 /* Convert the CGA color index into an EFI foreground attribute */
131 switch (Color)
132 {
133 case Black:
134 return EFI_BLACK;
135 case Blue:
136 return EFI_BLUE;
137 case Green:
138 return EFI_GREEN;
139 case Cyan:
140 return EFI_CYAN;
141 case Red:
142 return EFI_RED;
143 case Magenta:
144 return EFI_MAGENTA;
145 case Brown:
146 return EFI_BROWN;
147 case LtGray:
148 return EFI_LIGHTGRAY;
149 case Gray:
150 return EFI_DARKGRAY;
151 case LtBlue:
152 return EFI_LIGHTBLUE;
153 case LtGreen:
154 return EFI_LIGHTGREEN;
155 case LtCyan:
156 return EFI_LIGHTCYAN;
157 case LtRed:
158 return EFI_LIGHTRED;
159 case LtMagenta:
160 return EFI_LIGHTMAGENTA;
161 case Yellow:
162 return EFI_YELLOW;
163 case White:
164 default:
165 return EFI_WHITE;
166 }
167}

Referenced by ConsoleEfiTextGetAttribute().

◆ ConsoleEfiTextGetStateFromMode()

VOID ConsoleEfiTextGetStateFromMode ( _In_ EFI_SIMPLE_TEXT_OUTPUT_MODE Mode,
_Out_ PBL_DISPLAY_STATE  State 
)

Definition at line 181 of file textcons.c.

185{
186 ULONG TextWidth, TextHeight;
187
188 /* Get all the EFI data and convert it into our own structure */
189 BlDisplayGetTextCellResolution(&TextWidth, &TextHeight);
190 State->FgColor = ConsoleEfiTextGetColorForeground(Mode->Attribute);
191 State->BgColor = ConsoleEfiTextGetColorBackground(Mode->Attribute);
192 State->XPos = Mode->CursorColumn * TextWidth;
193 State->YPos = Mode->CursorRow * TextHeight;
194 State->CursorVisible = Mode->CursorVisible != FALSE;
195}
VOID BlDisplayGetTextCellResolution(_Out_ PULONG TextWidth, _Out_ PULONG TextHeight)
Definition: display.c:603
#define FALSE
Definition: types.h:117
BL_COLOR ConsoleEfiTextGetColorBackground(_In_ UINT32 Attributes)
Definition: textcons.c:62
BL_COLOR ConsoleEfiTextGetColorForeground(_In_ UINT32 Attributes)
Definition: textcons.c:18

Referenced by ConsoleFirmwareTextClose(), and ConsoleFirmwareTextOpen().

◆ ConsoleFirmwareTextClear()

NTSTATUS ConsoleFirmwareTextClear ( _In_ PBL_TEXT_CONSOLE  Console,
_In_ BOOLEAN  LineOnly 
)

Definition at line 557 of file textcons.c.

561{
562 BL_ARCH_MODE OldMode;
563 EFI_STATUS EfiStatus;
565 ULONG i, Column, Row, TextWidth, TextHeight;
566
567 /* Get the text resolution */
568 BlDisplayGetTextCellResolution(&TextWidth, &TextHeight);
569
570 /* Are we just clearing a line? */
571 if (LineOnly)
572 {
573 /* Get the current column and row */
574 Column = Console->State.XPos / TextWidth;
575 Row = Console->State.YPos / TextHeight;
576
577 /* Loop over every remaining character */
578 for (i = 0; i < Console->DisplayMode.HRes - Column - 1; i++)
579 {
580 /* Write a space on top of it */
581 Status = EfiConOutOutputString(Console->Protocol, L" ");
582 if (!NT_SUCCESS(Status))
583 {
584 break;
585 }
586 }
587
588 /* And reset the cursor back at the initial position */
590 Column,
591 Row);
592 }
593 else
594 {
595 /* Are we in protected mode? */
596 OldMode = CurrentExecutionContext->Mode;
597 if (OldMode != BlRealMode)
598 {
599 /* FIXME: Not yet implemented */
601 }
602
603 /* Clear the screen */
604 EfiStatus = Console->Protocol->ClearScreen(Console->Protocol);
605
606 /* Switch back to protected mode if we came from there */
607 if (OldMode != BlRealMode)
608 {
609 BlpArchSwitchContext(OldMode);
610 }
611
612 /* Conver to NT status -- did that work? */
613 Status = EfiGetNtStatusCode(EfiStatus);
614 if (NT_SUCCESS(Status))
615 {
616 /* Reset current positions */
617 Console->State.XPos = 0;
618 Console->State.YPos = 0;
619 }
620 }
621
622 /* All done */
623 return Status;
624}
CConsole Console
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:31
NTSTATUS EfiGetNtStatusCode(_In_ EFI_STATUS EfiStatus)
Definition: firmware.c:2539
VOID BlpArchSwitchContext(_In_ BL_ARCH_MODE NewMode)
Definition: arch.c:166
PBL_ARCH_CONTEXT CurrentExecutionContext
Definition: arch.c:17
NTSTATUS EfiConOutSetCursorPosition(_In_ SIMPLE_TEXT_OUTPUT_INTERFACE *TextInterface, _In_ ULONG Column, _In_ ULONG Row)
Definition: firmware.c:1130
NTSTATUS EfiConOutOutputString(_In_ SIMPLE_TEXT_OUTPUT_INTERFACE *TextInterface, _In_ PWCHAR String)
Definition: firmware.c:1195
@ BlRealMode
Definition: bl.h:239
enum _BL_ARCH_MODE BL_ARCH_MODE
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:239
BL_ARCH_MODE Mode
Definition: bl.h:999

Referenced by ConsoleGraphicalClearText(), and ConsoleTextLocalClearText().

◆ ConsoleFirmwareTextClose()

VOID ConsoleFirmwareTextClose ( _In_ PBL_TEXT_CONSOLE  TextConsole)

Definition at line 398 of file textcons.c.

401{
402 ULONG Mode;
403 BL_DISPLAY_STATE DisplayState;
404
405 /* Read the original mode, and see if it's different than the one now */
406 Mode = TextConsole->OldMode.Mode;
407 if (Mode != TextConsole->Mode)
408 {
409 /* Restore to the original mode */
410 EfiConOutSetMode(TextConsole->Protocol, Mode);
411 }
412
413 /* Read the EFI settings for the original mode */
414 ConsoleEfiTextGetStateFromMode(&TextConsole->OldMode, &DisplayState);
415
416 /* Set the original settings */
417 ConsoleFirmwareTextSetState(TextConsole, 0xF, &DisplayState);
418}
NTSTATUS EfiConOutSetMode(_In_ SIMPLE_TEXT_OUTPUT_INTERFACE *TextInterface, _In_ ULONG Mode)
Definition: firmware.c:1066
VOID ConsoleEfiTextGetStateFromMode(_In_ EFI_SIMPLE_TEXT_OUTPUT_MODE *Mode, _Out_ PBL_DISPLAY_STATE State)
Definition: textcons.c:181
NTSTATUS ConsoleFirmwareTextSetState(_In_ PBL_TEXT_CONSOLE TextConsole, _In_ UCHAR Mask, _In_ PBL_DISPLAY_STATE State)
Definition: textcons.c:198

Referenced by ConsoleGraphicalEnable(), and ConsoleTextLocalConstruct().

◆ ConsoleFirmwareTextOpen()

NTSTATUS ConsoleFirmwareTextOpen ( _In_ PBL_TEXT_CONSOLE  TextConsole)

Definition at line 421 of file textcons.c.

424{
426 EFI_SIMPLE_TEXT_OUTPUT_MODE CurrentMode, NewMode;
427 UINTN HRes, VRes;
428 ULONG Mode;
430
431 /* Read the current mode and its settings */
432 EfiConOutReadCurrentMode(EfiConOut, &CurrentMode);
433 Status = EfiConOutQueryMode(EfiConOut, CurrentMode.Mode, &HRes, &VRes);
434 if (!NT_SUCCESS(Status))
435 {
436 return Status;
437 }
438
439 /* Save the current mode and its settings */
440 NewMode = CurrentMode;
441 DisplayMode.VRes = VRes;
442 DisplayMode.HRes = HRes;
443 DisplayMode.HRes2 = HRes;
444
445 /* Check if the current mode is compatible with one of our modes */
447 {
448 /* It isn't -- find a matching EFI mode for what we need */
449 EfiPrintf(L"In incorrect mode, scanning for right one\r\n");
452 1,
453 &Mode);
454 if (!NT_SUCCESS(Status))
455 {
456 EfiPrintf(L"Failed to find mode: %lx\r\n", Status);
457 return Status;
458 }
459
460 /* Set the new EFI mode */
461 EfiPrintf(L"Setting new mode: %d\r\n", Mode);
463 if (!NT_SUCCESS(Status))
464 {
465 return Status;
466 }
467
468 /* Read the current mode and its settings */
470 Status = EfiConOutQueryMode(EfiConOut, Mode, &HRes, &VRes);
471 if (!NT_SUCCESS(Status))
472 {
473 EfiConOutSetMode(EfiConOut, CurrentMode.Mode);
474 return Status;
475 }
476
477 /* Save the current mode and its settings */
478 DisplayMode.HRes = HRes;
479 DisplayMode.VRes = VRes;
480 DisplayMode.HRes2 = HRes;
481 }
482
483 /* Capture all the current settings */
484 ConsoleEfiTextGetStateFromMode(&NewMode, &TextConsole->State);
485 TextConsole->Mode = NewMode.Mode;
486 TextConsole->DisplayMode = DisplayMode;
487 TextConsole->Protocol = EfiConOut;
488 TextConsole->OldMode = CurrentMode;
489 return STATUS_SUCCESS;
490}
BL_DISPLAY_MODE ConsoleTextResolutionList[]
Definition: display.c:30
BOOLEAN ConsolepFindResolution(_In_ PBL_DISPLAY_MODE Mode, _In_ PBL_DISPLAY_MODE List, _In_ ULONG MaxIndex)
Definition: textcons.c:159
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL * EfiConOut
Definition: firmware.c:23
NTSTATUS ConsoleEfiTextFindModeFromAllowed(_In_ SIMPLE_TEXT_OUTPUT_INTERFACE *TextProtocol, _In_ PBL_DISPLAY_MODE SupportedModes, _In_ ULONG MaxIndex, _Out_ PULONG SupportedMode)
Definition: textcons.c:318
static VIDEODISPLAYMODE DisplayMode
Definition: pcvideo.c:117

Referenced by ConsoleGraphicalEnable(), and ConsoleTextLocalConstruct().

◆ ConsoleFirmwareTextSetState()

NTSTATUS ConsoleFirmwareTextSetState ( _In_ PBL_TEXT_CONSOLE  TextConsole,
_In_ UCHAR  Mask,
_In_ PBL_DISPLAY_STATE  State 
)

Definition at line 198 of file textcons.c.

203{
205 ULONG FgColor, BgColor, Attribute, XPos, YPos, TextHeight, TextWidth;
206 BOOLEAN Visible;
207
208 /* Check if foreground state is being set */
209 if (Mask & 1)
210 {
211 /* Check if there's a difference from current */
212 FgColor = State->FgColor;
213 if (TextConsole->State.FgColor != FgColor)
214 {
215 /* Ignore invalid color */
216 if (FgColor > White)
217 {
219 }
220
221 /* Convert from NT/CGA format to EFI, and then set the attribute */
222 Attribute = ConsoleEfiTextGetAttribute(TextConsole->State.BgColor,
223 FgColor);
224 Status = EfiConOutSetAttribute(TextConsole->Protocol, Attribute);
225 if (!NT_SUCCESS(Status))
226 {
227 return Status;
228 }
229
230 /* Update cached state */
231 TextConsole->State.FgColor = FgColor;
232 }
233 }
234
235 /* Check if background state is being set */
236 if (Mask & 2)
237 {
238 /* Check if there's a difference from current */
239 BgColor = State->BgColor;
240 if (TextConsole->State.BgColor != BgColor)
241 {
242 /* Ignore invalid color */
243 if (BgColor > White)
244 {
246 }
247
248 /* Convert from NT/CGA format to EFI, and then set the attribute */
249 Attribute = ConsoleEfiTextGetAttribute(BgColor,
250 TextConsole->State.FgColor);
251 Status = EfiConOutSetAttribute(TextConsole->Protocol, Attribute);
252
253 if (!NT_SUCCESS(Status))
254 {
255 return Status;
256 }
257
258 /* Update cached state */
259 TextConsole->State.BgColor = BgColor;
260 }
261 }
262
263 /* Check if position state is being set */
264 if (Mask & 4)
265 {
266 /* Check if there's a difference from current */
267 XPos = State->XPos;
268 YPos = State->YPos;
269 if ((TextConsole->State.XPos != XPos) ||
270 (TextConsole->State.YPos != YPos))
271 {
272 /* Set the new cursor position */
273 BlDisplayGetTextCellResolution(&TextWidth, &TextHeight);
274 Status = EfiConOutSetCursorPosition(TextConsole->Protocol,
275 XPos/ TextWidth,
276 YPos / TextHeight);
277 if (!NT_SUCCESS(Status))
278 {
279 return Status;
280 }
281
282 /* Update cached state */
283 TextConsole->State.XPos = XPos;
284 TextConsole->State.YPos = YPos;
285 }
286 }
287
288 /* Check if cursor state is being set */
289 if (Mask & 8)
290 {
291 /* Check if there's a difference from current */
292 Visible = State->CursorVisible;
293 if (TextConsole->State.CursorVisible != Visible)
294 {
295 /* Ignore invalid state */
296 if (Visible >= 3)
297 {
299 }
300
301 /* Set the new cursor state */
302 Status = EfiConOutEnableCursor(TextConsole->Protocol, Visible);
303 if (!NT_SUCCESS(Status))
304 {
305 return Status;
306 }
307
308 /* Update cached status */
309 TextConsole->State.CursorVisible = Visible;
310 }
311 }
312
313 /* Return success */
314 return STATUS_SUCCESS;
315}
unsigned char BOOLEAN
NTSTATUS EfiConOutSetAttribute(_In_ SIMPLE_TEXT_OUTPUT_INTERFACE *TextInterface, _In_ ULONG Attribute)
Definition: firmware.c:1098
NTSTATUS EfiConOutEnableCursor(_In_ SIMPLE_TEXT_OUTPUT_INTERFACE *TextInterface, _In_ BOOLEAN Visible)
Definition: firmware.c:1163
ULONG ConsoleEfiTextGetAttribute(BL_COLOR BgColor, BL_COLOR FgColor)
Definition: textcons.c:170
unsigned int Mask
Definition: fpcontrol.c:82
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135

Referenced by ConsoleFirmwareTextClose(), ConsoleGraphicalSetTextState(), ConsoleTextLocalConstruct(), and ConsoleTextLocalSetTextState().

◆ ConsoleInputBaseEraseBuffer()

NTSTATUS ConsoleInputBaseEraseBuffer ( _In_ PBL_INPUT_CONSOLE  Console,
_In_opt_ PULONG  FillValue 
)

Definition at line 493 of file textcons.c.

497{
498 ULONG ValueToFill;
499 PULONG i;
500
501 /* Check if we should fill with a particular value */
502 if (FillValue)
503 {
504 /* Use it */
505 ValueToFill = *FillValue;
506 }
507 else
508 {
509 /* Otherwise, use default */
510 ValueToFill = 0x10020;
511 }
512
513 /* Set the input buffer to its last location */
514 Console->DataStart = Console->DataEnd;
515
516 /* Fill the buffer with the value */
517 for (i = Console->Buffer; i < Console->EndBuffer; i++)
518 {
519 *i = ValueToFill;
520 }
521
522 /* All done */
523 return STATUS_SUCCESS;
524}
unsigned int * PULONG
Definition: retypes.h:1

Referenced by ConsoleInputLocalEraseBuffer().

◆ ConsoleInputLocalEraseBuffer()

NTSTATUS ConsoleInputLocalEraseBuffer ( _In_ PBL_INPUT_CONSOLE  Console,
_In_opt_ PULONG  FillValue 
)

Definition at line 527 of file textcons.c.

531{
532 NTSTATUS Status, EfiStatus;
533
534 /* Erase the software buffer */
536
537 /* Reset the hardware console */
538 EfiStatus = EfiConInEx ? EfiConInExReset() : EfiConInReset();
539 if (!NT_SUCCESS(EfiStatus))
540 {
541 /* Normalize the failure code */
542 EfiStatus = STATUS_UNSUCCESSFUL;
543 }
544
545 /* Check if software reset worked */
546 if (NT_SUCCESS(Status))
547 {
548 /* Then return the firmware code */
549 Status = EfiStatus;
550 }
551
552 /* All done */
553 return Status;
554}
EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL * EfiConInEx
Definition: firmware.c:25
NTSTATUS EfiConInExReset(VOID)
Definition: firmware.c:825
NTSTATUS EfiConInReset(VOID)
Definition: firmware.c:794
NTSTATUS ConsoleInputBaseEraseBuffer(_In_ PBL_INPUT_CONSOLE Console, _In_opt_ PULONG FillValue)
Definition: textcons.c:493

Referenced by ConsoleInputLocalDestruct().