ReactOS 0.4.15-dev-8096-ga0eec98
guicons.c File Reference
#include "bl.h"
Include dependency graph for guicons.c:

Go to the source code of this file.

Functions

NTSTATUS ConsoleGraphicalSetTextState (_In_ PBL_GRAPHICS_CONSOLE Console, _In_ ULONG Mask, _In_ PBL_DISPLAY_STATE TextState)
 
NTSTATUS ConsoleGraphicalConstruct (_In_ PBL_GRAPHICS_CONSOLE GraphicsConsole)
 
VOID ConsolepClearBuffer (_In_ PUCHAR FrameBuffer, _In_ ULONG Width, _In_ PUCHAR FillColor, _In_ ULONG Height, _In_ ULONG ScanlineWidth, _In_ ULONG PixelDepth)
 
NTSTATUS ConsolepConvertColorToPixel (_In_ BL_COLOR Color, _Out_ PUCHAR Pixel)
 
NTSTATUS ConsoleGraphicalClearPixels (_In_ PBL_GRAPHICS_CONSOLE Console, _In_ ULONG Color)
 
NTSTATUS ConsoleGraphicalClearText (_In_ PBL_GRAPHICS_CONSOLE Console, _In_ BOOLEAN LineOnly)
 
BOOLEAN ConsoleGraphicalIsEnabled (_In_ PBL_GRAPHICS_CONSOLE Console)
 
VOID ConsoleGraphicalDestruct (_In_ PBL_GRAPHICS_CONSOLE Console)
 
NTSTATUS ConsoleGraphicalReinitialize (_In_ PBL_GRAPHICS_CONSOLE Console)
 
NTSTATUS ConsoleGraphicalEnable (_In_ PBL_GRAPHICS_CONSOLE Console, _In_ BOOLEAN Enable)
 
NTSTATUS ConsoleGraphicalGetGraphicalResolution (_In_ PBL_GRAPHICS_CONSOLE Console, _In_ PBL_DISPLAY_MODE DisplayMode)
 
NTSTATUS ConsoleGraphicalGetOriginalResolution (_In_ PBL_GRAPHICS_CONSOLE Console, _In_ PBL_DISPLAY_MODE DisplayMode)
 

Variables

BL_GRAPHICS_CONSOLE_VTABLE ConsoleGraphicalVtbl
 

Function Documentation

◆ ConsoleGraphicalClearPixels()

NTSTATUS ConsoleGraphicalClearPixels ( _In_ PBL_GRAPHICS_CONSOLE  Console,
_In_ ULONG  Color 
)

Definition at line 275 of file guicons.c.

279{
281
282 /* Check if the text console is active */
283 if (Console->TextConsole.Active)
284 {
285 /* We shouldn't be here */
287 }
288 else
289 {
290 /* Clear it in graphics mode */
292 }
293
294 /* All good */
295 return Status;
296}
CConsole Console
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS ConsoleFirmwareGraphicalClear(_In_ PBL_GRAPHICS_CONSOLE Console, _In_ ULONG Color)
Definition: guicons.c:90
Status
Definition: gdiplustypes.h:25
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132

Referenced by BfClearScreen().

◆ ConsoleGraphicalClearText()

NTSTATUS ConsoleGraphicalClearText ( _In_ PBL_GRAPHICS_CONSOLE  Console,
_In_ BOOLEAN  LineOnly 
)

Definition at line 299 of file guicons.c.

303{
304 /* Is the text console active? */
305 if (Console->TextConsole.Active)
306 {
307 /* Let firmware clear do it */
308 return ConsoleFirmwareTextClear(&Console->TextConsole, LineOnly);
309 }
310
311 /* Are we clearing a line only? */
312 if (LineOnly)
313 {
315 }
316
317 /* Nope -- the whole screen */
318 return BfClearScreen(Console);
319}
NTSTATUS BfClearScreen(_In_ PBL_GRAPHICS_CONSOLE Console)
Definition: font.c:158
NTSTATUS BfClearToEndOfLine(_In_ PBL_GRAPHICS_CONSOLE Console)
Definition: font.c:149
NTSTATUS ConsoleFirmwareTextClear(_In_ PBL_TEXT_CONSOLE Console, _In_ BOOLEAN LineOnly)
Definition: textcons.c:557

◆ ConsoleGraphicalConstruct()

NTSTATUS ConsoleGraphicalConstruct ( _In_ PBL_GRAPHICS_CONSOLE  GraphicsConsole)

Definition at line 58 of file guicons.c.

61{
63
64 /* Create a text console */
65 Status = ConsoleTextLocalConstruct(&GraphicsConsole->TextConsole, FALSE);
66 if (!NT_SUCCESS(Status))
67 {
68 EfiPrintf(L"Text failed: %lx\r\n", Status);
69 return Status;
70 }
71
72 /* But overwrite its callbacks with ours */
73 GraphicsConsole->TextConsole.Callbacks = &ConsoleGraphicalVtbl.Text;
74
75 /* Try to create a GOP console */
77 if (!NT_SUCCESS(Status))
78 {
79 /* That failed, try an older EFI 1.02 UGA console */
80 EfiPrintf(L"GOP open failed!\r\n", Status);
82 if (!NT_SUCCESS(Status))
83 {
84 /* That failed too, give up */
85 EfiPrintf(L"UGA failed!\r\n", Status);
86 ConsoleTextLocalDestruct(&GraphicsConsole->TextConsole);
88 }
89 }
90
91 /* Enable the console */
92 Status = ConsoleFirmwareGraphicalEnable(GraphicsConsole);
93 if (!NT_SUCCESS(Status))
94 {
95 /* Failed to enable it, undo everything */
96 EfiPrintf(L"Enable failed\r\n");
97 ConsoleFirmwareGraphicalClose(GraphicsConsole);
98 ConsoleTextLocalDestruct(&GraphicsConsole->TextConsole);
100 }
101
102 /* Save the graphics text color from the text mode text color */
103 GraphicsConsole->FgColor = GraphicsConsole->TextConsole.State.FgColor;
104 GraphicsConsole->BgColor = GraphicsConsole->TextConsole.State.BgColor;
105 return STATUS_SUCCESS;
106}
VOID ConsoleTextLocalDestruct(_In_ struct _BL_TEXT_CONSOLE *Console)
Definition: textcons.c:30
VOID EfiPrintf(_In_ PWCHAR Format,...)
Definition: firmware.c:126
NTSTATUS ConsoleFirmwareGraphicalEnable(_In_ PBL_GRAPHICS_CONSOLE GraphicsConsole)
Definition: guicons.c:128
NTSTATUS ConsoleEfiGraphicalOpenProtocol(_In_ PBL_GRAPHICS_CONSOLE GraphicsConsole, _In_ BL_GRAPHICS_CONSOLE_TYPE Type)
Definition: guicons.c:34
VOID ConsoleFirmwareGraphicalClose(_In_ PBL_GRAPHICS_CONSOLE GraphicsConsole)
Definition: guicons.c:18
@ BlUgaConsole
Definition: bl.h:1141
@ BlGopConsole
Definition: bl.h:1140
NTSTATUS ConsoleTextLocalConstruct(_In_ PBL_TEXT_CONSOLE TextConsole, _In_ BOOLEAN Activate)
Definition: textcons.c:104
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
BL_GRAPHICS_CONSOLE_VTABLE ConsoleGraphicalVtbl
Definition: guicons.c:15
#define L(x)
Definition: ntvdm.h:50
#define STATUS_SUCCESS
Definition: shellext.h:65
BL_TEXT_CONSOLE_VTABLE Text
Definition: bl.h:1098

Referenced by DsppInitialize().

◆ ConsoleGraphicalDestruct()

VOID ConsoleGraphicalDestruct ( _In_ PBL_GRAPHICS_CONSOLE  Console)

Definition at line 331 of file guicons.c.

334{
335 /* Is the text console active? */
336 if (Console->TextConsole.Active)
337 {
338 /* Disable it */
340 }
341
342 /* Close the firmware protocols */
344
345 /* Destroy the console object */
346 ConsoleTextLocalDestruct(&Console->TextConsole);
347}
VOID ConsoleFirmwareGraphicalDisable(_In_ PBL_GRAPHICS_CONSOLE GraphicsConsole)
Definition: guicons.c:153

◆ ConsoleGraphicalEnable()

NTSTATUS ConsoleGraphicalEnable ( _In_ PBL_GRAPHICS_CONSOLE  Console,
_In_ BOOLEAN  Enable 
)

Definition at line 369 of file guicons.c.

373{
376
377 /* The text mode console state should be the opposite of what we want to do */
378 Active = Console->TextConsole.Active;
379 if (Active == Enable)
380 {
381 /* Are we trying to enable graphics? */
382 if (Enable)
383 {
384 /* Enable the console */
386 if (NT_SUCCESS(Status))
387 {
388 return Status;
389 }
390
391 /* Is the text console active? */
392 if (Console->TextConsole.Active)
393 {
394 /* Turn it off */
395 ConsoleFirmwareTextClose(&Console->TextConsole);
396 Console->TextConsole.Active = FALSE;
397 }
398
399 /* Preserve the text colors */
400 Console->FgColor = Console->TextConsole.State.FgColor;
401 Console->BgColor = Console->TextConsole.State.BgColor;
402 }
403 else
404 {
405 /* We are turning off graphics -- is the text console active? */
406 if (Active != TRUE)
407 {
408 /* It isn't, so let's turn it on */
409 Status = ConsoleFirmwareTextOpen(&Console->TextConsole);
410 if (!NT_SUCCESS(Status))
411 {
412 return Status;
413 }
414
415 /* Remember that it's on */
416 Console->TextConsole.Active = TRUE;
417 }
418
419 /* Disable the graphics console */
421 }
422 }
423
424 /* All good */
425 return STATUS_SUCCESS;
426}
unsigned char BOOLEAN
NTSTATUS ConsoleFirmwareTextOpen(_In_ PBL_TEXT_CONSOLE TextConsole)
Definition: textcons.c:421
VOID ConsoleFirmwareTextClose(_In_ PBL_TEXT_CONSOLE TextConsole)
Definition: textcons.c:398
#define TRUE
Definition: types.h:120
_In_ ULONGLONG _In_ ULONGLONG _In_ BOOLEAN Enable
Definition: ntddpcm.h:142
_In_ ULONG _In_ BOOLEAN Active
Definition: potypes.h:561

◆ ConsoleGraphicalGetGraphicalResolution()

NTSTATUS ConsoleGraphicalGetGraphicalResolution ( _In_ PBL_GRAPHICS_CONSOLE  Console,
_In_ PBL_DISPLAY_MODE  DisplayMode 
)

Definition at line 429 of file guicons.c.

433{
434 /* Is the text console active? */
435 if (Console->TextConsole.Active)
436 {
437 /* There's no graphics resolution then */
438 return STATUS_UNSUCCESSFUL;
439 }
440
441 /* Return the current display mode */
442 *DisplayMode = Console->DisplayMode;
443 return STATUS_SUCCESS;
444}
static VIDEODISPLAYMODE DisplayMode
Definition: pcvideo.c:117

◆ ConsoleGraphicalGetOriginalResolution()

NTSTATUS ConsoleGraphicalGetOriginalResolution ( _In_ PBL_GRAPHICS_CONSOLE  Console,
_In_ PBL_DISPLAY_MODE  DisplayMode 
)

Definition at line 447 of file guicons.c.

451{
452 /* Is the text console active? */
453 if (Console->TextConsole.Active)
454 {
455 /* There's no graphics resolution then */
456 return STATUS_UNSUCCESSFUL;
457 }
458
459 /* Return the current display mode */
460 *DisplayMode = Console->OldDisplayMode;
461 return STATUS_SUCCESS;
462}

◆ ConsoleGraphicalIsEnabled()

BOOLEAN ConsoleGraphicalIsEnabled ( _In_ PBL_GRAPHICS_CONSOLE  Console)

Definition at line 322 of file guicons.c.

325{
326 /* Is the text console active? If so, the graphics console isn't */
327 return !Console->TextConsole.Active;
328}

◆ ConsoleGraphicalReinitialize()

NTSTATUS ConsoleGraphicalReinitialize ( _In_ PBL_GRAPHICS_CONSOLE  Console)

Definition at line 350 of file guicons.c.

353{
354 /* Is the text console active? */
355 if (Console->TextConsole.Active)
356 {
357 /* Reinitialize it */
359 }
360
361 /* Disable the graphics console */
363
364 /* Then bring it back again */
366}
NTSTATUS ConsoleTextLocalReinitialize(_In_ struct _BL_TEXT_CONSOLE *Console)
Definition: textcons.c:38

◆ ConsoleGraphicalSetTextState()

NTSTATUS ConsoleGraphicalSetTextState ( _In_ PBL_GRAPHICS_CONSOLE  Console,
_In_ ULONG  Mask,
_In_ PBL_DISPLAY_STATE  TextState 
)

Definition at line 37 of file guicons.c.

42{
43 /* Is the text console active? */
44 if (Console->TextConsole.Active)
45 {
46 /* Let it handle that */
47 return ConsoleFirmwareTextSetState(&Console->TextConsole,
48 Mask,
49 TextState);
50 }
51
52 /* Not yet */
53 EfiPrintf(L"FFX set not implemented\r\n");
55}
NTSTATUS ConsoleFirmwareTextSetState(_In_ PBL_TEXT_CONSOLE TextConsole, _In_ UCHAR Mask, _In_ PBL_DISPLAY_STATE State)
Definition: textcons.c:198
unsigned int Mask
Definition: fpcontrol.c:82
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:239

◆ ConsolepClearBuffer()

VOID ConsolepClearBuffer ( _In_ PUCHAR  FrameBuffer,
_In_ ULONG  Width,
_In_ PUCHAR  FillColor,
_In_ ULONG  Height,
_In_ ULONG  ScanlineWidth,
_In_ ULONG  PixelDepth 
)

Definition at line 109 of file guicons.c.

117{
118 PUCHAR Scanline, Current, FrameBufferEnd, LineEnd;
119 ULONG LineBytes, WidthBytes, BytesPerPixel;
120
121 /* Get the BPP */
122 BytesPerPixel = PixelDepth / 8;
123
124 /* Using that, calculate the size of a scan line */
125 LineBytes = ScanlineWidth * BytesPerPixel;
126
127 /* And the size of line we'll have to clear */
128 WidthBytes = Width * BytesPerPixel;
129
130 /* Allocate a scanline */
131 Scanline = BlMmAllocateHeap(WidthBytes);
132 if (Scanline)
133 {
134 /* For each remaining pixel on the scanline */
135 Current = Scanline;
136 while (Width--)
137 {
138 /* Copy in the fill color */
139 RtlCopyMemory(Current, FillColor, BytesPerPixel);
140 Current += BytesPerPixel;
141 }
142
143 /* For each scanline in the frame buffer */
144 while (Height--)
145 {
146 /* Copy our constructed scanline */
147 RtlCopyMemory(FrameBuffer, Scanline, WidthBytes);
148 FrameBuffer += LineBytes;
149 }
150 }
151 else
152 {
153 FrameBufferEnd = FrameBuffer + Height * LineBytes;
154 ScanlineWidth = BytesPerPixel * (ScanlineWidth - Width);
155 while (FrameBuffer != FrameBufferEnd)
156 {
157 if (FrameBuffer != (FrameBuffer + WidthBytes))
158 {
159 LineEnd = FrameBuffer + WidthBytes;
160 do
161 {
164 }
165 while (FrameBuffer != LineEnd);
166 }
167
168 FrameBuffer += ScanlineWidth;
169 }
170 }
171}
PVOID BlMmAllocateHeap(_In_ SIZE_T Size)
Definition: heapalloc.c:569
PVOID FrameBuffer
Definition: xboxvideo.c:28
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
unsigned char * PUCHAR
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59
_In_ HFONT _Out_ PUINT _Out_ PUINT Width
Definition: font.h:89
_In_ HFONT _Out_ PUINT Height
Definition: font.h:88
static ULONG BytesPerPixel
Definition: xboxvideo.c:32

Referenced by ConsoleFirmwareGraphicalClear().

◆ ConsolepConvertColorToPixel()

NTSTATUS ConsolepConvertColorToPixel ( _In_ BL_COLOR  Color,
_Out_ PUCHAR  Pixel 
)

Definition at line 174 of file guicons.c.

178{
180
181 /* Assume success */
183
184 /* Convert the color to a pixel value */
185 switch (Color)
186 {
187 case Black:
188 Pixel[1] = 0;
189 Pixel[2] = 0;
190 Pixel[0] = 0;
191 break;
192 case Blue:
193 Pixel[1] = 0;
194 Pixel[2] = 0;
195 Pixel[0] = 0x7F;
196 break;
197 case Green:
198 Pixel[1] = 0x7F;
199 Pixel[2] = 0;
200 Pixel[0] = 0;
201 break;
202 case Cyan:
203 Pixel[1] = 0x7F;
204 Pixel[2] = 0;
205 Pixel[0] = 0x7F;
206 break;
207 case Red:
208 Pixel[1] = 0;
209 Pixel[2] = 0x7F;
210 Pixel[0] = 0x7F;
211 break;
212 case Magenta:
213 Pixel[1] = 0;
214 Pixel[2] = 0x7F;
215 Pixel[0] = 0x7F;
216 break;
217 case Brown:
218 Pixel[1] = 0x3F;
219 Pixel[2] = 0x7F;
220 Pixel[0] = 0;
221 break;
222 case LtGray:
223 Pixel[1] = 0xBFu;
224 Pixel[2] = 0xBFu;
225 *Pixel = 0xBFu;
226 break;
227 case Gray:
228 Pixel[1] = 0x7F;
229 Pixel[2] = 0x7F;
230 Pixel[0] = 0x7F;
231 break;
232 case LtBlue:
233 Pixel[1] = 0;
234 Pixel[2] = 0;
235 Pixel[0] = 0xFF;
236 break;
237 case LtGreen:
238 Pixel[1] = 0xFF;
239 Pixel[2] = 0;
240 Pixel[0] = 0;
241 break;
242 case LtCyan:
243 Pixel[1] = 0xFF;
244 Pixel[2] = 0;
245 Pixel[0] = 0xFF;
246 break;
247 case LtRed:
248 Pixel[1] = 0;
249 Pixel[2] = 0xFF;
250 Pixel[0] = 0;
251 break;
252 case LtMagenta:
253 Pixel[1] = 0;
254 Pixel[2] = 0xFF;
255 Pixel[0] = 0xFF;
256 break;
257 case Yellow:
258 Pixel[1] = 0xFF;
259 Pixel[2] = 0xFF;
260 Pixel[0] = 0;
261 break;
262 case White:
263 Pixel[1] = 0xFF;
264 Pixel[2] = 0xFF;
265 Pixel[0] = 0xFF;
266 break;
267 default:
269 break;
270 }
271 return Status;
272}
@ 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
@ Brown
Definition: bl.h:203
@ Cyan
Definition: bl.h:200
@ Magenta
Definition: bl.h:202
@ White
Definition: bl.h:212
@ Yellow
Definition: bl.h:211
@ Black
Definition: bl.h:197
@ Green
Definition: bl.h:199
@ Red
Definition: bl.h:201
@ Blue
Definition: bl.h:198
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135

Referenced by ConsoleFirmwareGraphicalClear().

Variable Documentation

◆ ConsoleGraphicalVtbl

BL_GRAPHICS_CONSOLE_VTABLE ConsoleGraphicalVtbl
Initial value:
=
{
{
NULL,
NULL,
},
}
NTSTATUS(* PCONSOLE_SET_TEXT_STATE)(_In_ struct _BL_TEXT_CONSOLE *Console, _In_ ULONG Flags, _In_ struct _BL_DISPLAY_STATE *TextState)
Definition: bl.h:500
NTSTATUS(* PCONSOLE_REINITIALIZE)(_In_ struct _BL_TEXT_CONSOLE *Console)
Definition: bl.h:487
NTSTATUS ConsoleTextBaseGetTextState(_In_ struct _BL_TEXT_CONSOLE *Console, _Out_ PBL_DISPLAY_STATE TextState)
Definition: textcons.c:47
NTSTATUS(* PCONSOLE_CLEAR_TEXT)(_In_ struct _BL_TEXT_CONSOLE *Console, _In_ BOOLEAN LineOnly)
Definition: bl.h:523
VOID(* PCONSOLE_DESTRUCT)(_In_ struct _BL_TEXT_CONSOLE *Console)
Definition: bl.h:481
#define NULL
Definition: types.h:112
NTSTATUS ConsoleGraphicalReinitialize(_In_ PBL_GRAPHICS_CONSOLE Console)
Definition: guicons.c:350
NTSTATUS ConsoleGraphicalGetOriginalResolution(_In_ PBL_GRAPHICS_CONSOLE Console, _In_ PBL_DISPLAY_MODE DisplayMode)
Definition: guicons.c:447
VOID ConsoleGraphicalDestruct(_In_ PBL_GRAPHICS_CONSOLE Console)
Definition: guicons.c:331
NTSTATUS ConsoleGraphicalClearText(_In_ PBL_GRAPHICS_CONSOLE Console, _In_ BOOLEAN LineOnly)
Definition: guicons.c:299
BOOLEAN ConsoleGraphicalIsEnabled(_In_ PBL_GRAPHICS_CONSOLE Console)
Definition: guicons.c:322
NTSTATUS ConsoleGraphicalEnable(_In_ PBL_GRAPHICS_CONSOLE Console, _In_ BOOLEAN Enable)
Definition: guicons.c:369
NTSTATUS ConsoleGraphicalSetTextState(_In_ PBL_GRAPHICS_CONSOLE Console, _In_ ULONG Mask, _In_ PBL_DISPLAY_STATE TextState)
Definition: guicons.c:37
NTSTATUS ConsoleGraphicalGetGraphicalResolution(_In_ PBL_GRAPHICS_CONSOLE Console, _In_ PBL_DISPLAY_MODE DisplayMode)
Definition: guicons.c:429

Definition at line 15 of file guicons.c.

Referenced by ConsoleGraphicalConstruct().