ReactOS 0.4.15-dev-7906-g1b85a5f
guicons.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/efi/guicons.c
5 * PURPOSE: Boot Library EFI GUI Console Routines
6 * PROGRAMMER: Alex Ionescu (alex.ionescu@reactos.org)
7 */
8
9/* INCLUDES ******************************************************************/
10
11#include "bl.h"
12
13/* DATA VARIABLES ************************************************************/
14
15/* FUNCTIONS *****************************************************************/
16
17VOID
19 _In_ PBL_GRAPHICS_CONSOLE GraphicsConsole
20 )
21{
22 /* Call the correct close routine based on the console mode */
23 if (GraphicsConsole->Type == BlUgaConsole)
24 {
25 ConsoleEfiUgaClose(GraphicsConsole);
26 }
27 else
28 {
29 ConsoleEfiGopClose(GraphicsConsole);
30 }
31}
32
35 _In_ PBL_GRAPHICS_CONSOLE GraphicsConsole,
37 )
38{
39 ULONG HandleIndex, HandleCount;
40 EFI_HANDLE* HandleArray;
44
45 /* Find a device handle that implements either GOP or UGA */
46 HandleCount = 0;
47 HandleArray = NULL;
49 (Type == BlGopConsole) ?
52 &HandleCount,
53 &HandleArray);
54 if (!NT_SUCCESS(Status))
55 {
56 /* Nothing supports this (no video card?) */
57 EfiPrintf(L"Status: %lx Count: %d\r\n", Status, HandleCount);
59 }
60
61 /* Scan through the handles we received */
62 for (HandleIndex = 0; HandleIndex < HandleCount; HandleIndex++)
63 {
64 /* Try to open each one */
65 GraphicsConsole->Handle = HandleArray[HandleIndex];
66 Handle = HandleArray[HandleIndex];
68 if (NT_SUCCESS(Status))
69 {
70 /* Test worked, close the protocol */
72
73 /* Now open the real protocol we want, either UGA or GOP */
74 Status = Type ? ConsoleEfiUgaOpen(GraphicsConsole) :
75 ConsoleEfiGopOpen(GraphicsConsole);
76 if (NT_SUCCESS(Status))
77 {
78 /* It worked -- store the type of console this is */
79 GraphicsConsole->Type = Type;
80 return STATUS_SUCCESS;
81 }
82 }
83 }
84
85 /* We failed to find a working GOP/UGA protocol provider */
87}
88
93 )
94{
96 UCHAR Pixel[4] = { 0 };
97
98 /* Convert the standard color to a firmware pixel color */
100 if (!NT_SUCCESS(Status))
101 {
102 return Status;
103 }
104
105 /* Check if this is GOP or UGA */
106 if (Console->Type == BlUgaConsole)
107 {
108 EfiPrintf(L"Uga not supported\r\n");
110 }
111 else
112 {
113 /* For GOP, just fill the screen */
114 ConsolepClearBuffer(Console->FrameBuffer,
115 Console->DisplayMode.HRes,
116 Pixel,
117 Console->DisplayMode.VRes,
118 Console->PixelsPerScanLine,
119 Console->PixelDepth);
121 }
122
123 /* All clear */
124 return Status;
125}
126
129 _In_ PBL_GRAPHICS_CONSOLE GraphicsConsole
130 )
131{
133
134 /* Check what type of console this is */
135 if (GraphicsConsole->Type == BlUgaConsole)
136 {
137 /* Handle UGA */
138 Status = ConsoleEfiUgaSetResolution(GraphicsConsole,
139 &GraphicsConsole->DisplayMode,
140 1);
141 }
142 else
143 {
144 /* Handle GOP */
145 Status = ConsoleEfiGopEnable(GraphicsConsole);
146 }
147
148 /* Return back to caller */
149 return Status;
150}
151
152VOID
154 _In_ PBL_GRAPHICS_CONSOLE GraphicsConsole
155 )
156{
157 /* Is this a GOP console? */
158 if (GraphicsConsole->Type == BlGopConsole)
159 {
160 /* Did we map a framebuffer? */
161 if (GraphicsConsole->FrameBuffer)
162 {
163 /* Unmap it */
164 BlMmUnmapVirtualAddressEx(GraphicsConsole->FrameBuffer,
165 GraphicsConsole->FrameBufferSize);
166 }
167 }
168}
CConsole Console
Type
Definition: Type.h:7
@ ByProtocol
Definition: UefiSpec.h:1428
LONG NTSTATUS
Definition: precomp.h:26
EFI_GUID EfiGraphicsOutputProtocol
Definition: firmware.c:28
NTSTATUS ConsoleEfiUgaSetResolution(_In_ PBL_GRAPHICS_CONSOLE GraphicsConsole, _In_ PBL_DISPLAY_MODE DisplayMode, _In_ ULONG DisplayModeCount)
Definition: uga.c:35
NTSTATUS EfiCloseProtocol(_In_ EFI_HANDLE Handle, _In_ EFI_GUID *Protocol)
Definition: firmware.c:581
VOID EfiPrintf(_In_ PWCHAR Format,...)
Definition: firmware.c:126
NTSTATUS ConsolepConvertColorToPixel(_In_ BL_COLOR Color, _Out_ PUCHAR Pixel)
Definition: guicons.c:174
EFI_GUID EfiDevicePathProtocol
Definition: firmware.c:31
NTSTATUS EfiOpenProtocol(_In_ EFI_HANDLE Handle, _In_ EFI_GUID *Protocol, _Out_ PVOID *Interface)
NTSTATUS BlMmUnmapVirtualAddressEx(_In_ PVOID VirtualAddress, _In_ ULONGLONG Size)
Definition: mm.c:487
enum _BL_GRAPHICS_CONSOLE_TYPE BL_GRAPHICS_CONSOLE_TYPE
NTSTATUS ConsoleEfiGopEnable(_In_ PBL_GRAPHICS_CONSOLE GraphicsConsole)
Definition: gop.c:88
VOID ConsoleEfiUgaClose(_In_ PBL_GRAPHICS_CONSOLE GraphicsConsole)
Definition: uga.c:27
@ BlUgaConsole
Definition: bl.h:1141
@ BlGopConsole
Definition: bl.h:1140
NTSTATUS ConsoleEfiGopOpen(_In_ PBL_GRAPHICS_CONSOLE GraphicsConsole)
Definition: gop.c:198
EFI_GUID EfiUgaDrawProtocol
Definition: firmware.c:29
NTSTATUS ConsoleEfiUgaOpen(_In_ PBL_GRAPHICS_CONSOLE GraphicsConsole)
Definition: uga.c:18
NTSTATUS EfiLocateHandleBuffer(_In_ EFI_LOCATE_SEARCH_TYPE SearchType, _In_ EFI_GUID *Protocol, _Inout_ PULONG HandleCount, _Inout_ EFI_HANDLE **Buffer)
Definition: firmware.c:1399
VOID ConsoleEfiGopClose(_In_ PBL_GRAPHICS_CONSOLE GraphicsConsole)
Definition: gop.c:177
VOID ConsolepClearBuffer(_In_ PUCHAR FrameBuffer, _In_ ULONG Width, _In_ PUCHAR FillColor, _In_ ULONG Height, _In_ ULONG ScanlineWidth, _In_ ULONG PixelDepth)
Definition: guicons.c:109
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTATUS ConsoleFirmwareGraphicalClear(_In_ PBL_GRAPHICS_CONSOLE Console, _In_ ULONG Color)
Definition: guicons.c:90
VOID ConsoleFirmwareGraphicalDisable(_In_ PBL_GRAPHICS_CONSOLE GraphicsConsole)
Definition: guicons.c:153
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
ULONG Handle
Definition: gdb_input.c:15
Status
Definition: gdiplustypes.h:25
#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
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE Interface
Definition: wdffdo.h:465
unsigned char UCHAR
Definition: xmlstorage.h:181