ReactOS  0.4.14-dev-323-g6fe6a88
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 
17 VOID
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);
58  return STATUS_UNSUCCESSFUL;
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 */
86  return STATUS_UNSUCCESSFUL;
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 
127 NTSTATUS
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 
152 VOID
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 }
VOID ConsoleFirmwareGraphicalDisable(_In_ PBL_GRAPHICS_CONSOLE GraphicsConsole)
Definition: guicons.c:153
NTSTATUS ConsoleEfiUgaSetResolution(_In_ PBL_GRAPHICS_CONSOLE GraphicsConsole, _In_ PBL_DISPLAY_MODE DisplayMode, _In_ ULONG DisplayModeCount)
Definition: uga.c:35
NTSTATUS EfiLocateHandleBuffer(_In_ EFI_LOCATE_SEARCH_TYPE SearchType, _In_ EFI_GUID *Protocol, _Inout_ PULONG HandleCount, _Inout_ EFI_HANDLE **Buffer)
Definition: firmware.c:1399
Type
Definition: Type.h:6
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
LONG NTSTATUS
Definition: precomp.h:26
EFI_GUID EfiUgaDrawProtocol
Definition: firmware.c:29
NTSTATUS ConsoleEfiUgaOpen(_In_ PBL_GRAPHICS_CONSOLE GraphicsConsole)
Definition: uga.c:18
NTSTATUS ConsolepConvertColorToPixel(_In_ BL_COLOR Color, _Out_ PUCHAR Pixel)
Definition: guicons.c:174
NTSTATUS EfiOpenProtocol(_In_ EFI_HANDLE Handle, _In_ EFI_GUID *Protocol, _Out_ PVOID *Interface)
smooth NULL
Definition: ftsmooth.c:416
enum _BL_GRAPHICS_CONSOLE_TYPE BL_GRAPHICS_CONSOLE_TYPE
NTSTATUS EfiCloseProtocol(_In_ EFI_HANDLE Handle, _In_ EFI_GUID *Protocol)
Definition: firmware.c:581
_In_ HANDLE Handle
Definition: extypes.h:390
IN PVOID IN PVOID IN USHORT IN USHORT IN PINTERFACE Interface
Definition: pci.h:359
NTSTATUS ConsoleEfiGraphicalOpenProtocol(_In_ PBL_GRAPHICS_CONSOLE GraphicsConsole, _In_ BL_GRAPHICS_CONSOLE_TYPE Type)
Definition: guicons.c:34
VOID ConsoleEfiGopClose(_In_ PBL_GRAPHICS_CONSOLE GraphicsConsole)
Definition: gop.c:177
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
VOID ConsoleFirmwareGraphicalClose(_In_ PBL_GRAPHICS_CONSOLE GraphicsConsole)
Definition: guicons.c:18
NTSTATUS BlMmUnmapVirtualAddressEx(_In_ PVOID VirtualAddress, _In_ ULONGLONG Size)
Definition: mm.c:487
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
NTSTATUS ConsoleFirmwareGraphicalEnable(_In_ PBL_GRAPHICS_CONSOLE GraphicsConsole)
Definition: guicons.c:128
unsigned char UCHAR
Definition: xmlstorage.h:181
static const WCHAR L[]
Definition: oid.c:1250
VOID ConsolepClearBuffer(_In_ PUCHAR FrameBuffer, _In_ ULONG Width, _In_ PUCHAR FillColor, _In_ ULONG Height, _In_ ULONG ScanlineWidth, _In_ ULONG PixelDepth)
Definition: guicons.c:109
EFI_GUID EfiDevicePathProtocol
Definition: firmware.c:31
Status
Definition: gdiplustypes.h:24
#define _In_
Definition: no_sal2.h:204
EFI_GUID EfiGraphicsOutputProtocol
Definition: firmware.c:28
VOID EfiPrintf(_In_ PWCHAR Format,...)
Definition: firmware.c:126
CConsole Console
NTSTATUS ConsoleEfiGopOpen(_In_ PBL_GRAPHICS_CONSOLE GraphicsConsole)
Definition: gop.c:198
unsigned int ULONG
Definition: retypes.h:1
NTSTATUS ConsoleEfiGopEnable(_In_ PBL_GRAPHICS_CONSOLE GraphicsConsole)
Definition: gop.c:88
VOID ConsoleEfiUgaClose(_In_ PBL_GRAPHICS_CONSOLE GraphicsConsole)
Definition: uga.c:27
return STATUS_SUCCESS
Definition: btrfs.c:2938
NTSTATUS ConsoleFirmwareGraphicalClear(_In_ PBL_GRAPHICS_CONSOLE Console, _In_ ULONG Color)
Definition: guicons.c:90