ReactOS 0.4.16-dev-2354-g16de117
uefivid.c File Reference
#include <uefildr.h>
#include "../vidfb.h"
#include <debug.h>
Include dependency graph for uefivid.c:

Go to the source code of this file.

Macros

#define LOWEST_SUPPORTED_RES   1
 

Functions

 DBG_DEFAULT_CHANNEL (UI)
 
static EFI_STATUS UefiInitializeGop (VOID)
 
static EFI_STATUS UefiInitializeAppleGraphics (VOID)
 
EFI_STATUS UefiInitializeVideo (VOID)
 
VOID UefiVideoClearScreen (UCHAR Attr)
 
VOID UefiVideoPutChar (int Ch, UCHAR Attr, unsigned X, unsigned Y)
 
VOID UefiVideoGetDisplaySize (PULONG Width, PULONG Height, PULONG Depth)
 
VIDEODISPLAYMODE UefiVideoSetDisplayMode (PCSTR DisplayMode, BOOLEAN Init)
 
ULONG UefiVideoGetBufferSize (VOID)
 
VOID UefiVideoCopyOffScreenBufferToVRAM (PVOID Buffer)
 
VOID UefiVideoSetTextCursorPosition (UCHAR X, UCHAR Y)
 
VOID UefiVideoHideShowTextCursor (BOOLEAN Show)
 
BOOLEAN UefiVideoIsPaletteFixed (VOID)
 
VOID UefiVideoSetPaletteColor (UCHAR Color, UCHAR Red, UCHAR Green, UCHAR Blue)
 
VOID UefiVideoGetPaletteColor (UCHAR Color, UCHAR *Red, UCHAR *Green, UCHAR *Blue)
 

Variables

EFI_SYSTEM_TABLEGlobalSystemTable
 
EFI_HANDLE GlobalImageHandle
 
EFI_GUID EfiGraphicsOutputProtocol = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID
 
EFI_GUID AppleGraphInfoProtocol = APPLE_GRAPH_INFO_PROTOCOL_GUID
 
ULONG_PTR VramAddress
 
ULONG VramSize
 
PCM_FRAMEBUF_DEVICE_DATA FrameBufferData = NULL
 

Macro Definition Documentation

◆ LOWEST_SUPPORTED_RES

#define LOWEST_SUPPORTED_RES   1

Definition at line 25 of file uefivid.c.

Function Documentation

◆ DBG_DEFAULT_CHANNEL()

DBG_DEFAULT_CHANNEL ( UI  )

◆ UefiInitializeAppleGraphics()

static EFI_STATUS UefiInitializeAppleGraphics ( VOID  )
static

Definition at line 135 of file uefivid.c.

136{
138 APPLE_GRAPH_INFO_PROTOCOL *AppleGraph = NULL;
139 EFI_PIXEL_BITMASK* pPixelBitmask;
140
142 UINT32 BytesPerRow, Width, Height, Depth;
143
145 if (Status != EFI_SUCCESS)
146 {
147 ERR("Failed to find Apple Graphics Info with status %d\n", Status);
148 return Status;
149 }
150
151 Status = AppleGraph->GetInfo(AppleGraph,
154 &BytesPerRow,
155 &Width,
156 &Height,
157 &Depth);
158
159 if (Status != EFI_SUCCESS)
160 {
161 ERR("Failed to get graphics info from Apple Scren Info: %d\n", Status);
162 return Status;
163 }
164
165 /* All devices requiring Apple Graphics Info use PixelBlueGreenRedReserved8BitPerColor. */
166 pPixelBitmask = &EfiPixelMasks[PixelBlueGreenRedReserved8BitPerColor];
167
172 VramSize,
173 Width,
174 Height,
175 (BytesPerRow / 4),
176 Depth,
177 (PPIXEL_BITMASK)pPixelBitmask))
178 {
179 ERR("Couldn't initialize video framebuffer\n");
181 }
182
183 return Status;
184}
@ PixelBlueGreenRedReserved8BitPerColor
#define EFI_UNSUPPORTED
Definition: UefiBaseType.h:123
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:31
#define EFI_SUCCESS
Definition: UefiBaseType.h:120
COMPILER_DEPENDENT_UINT64 UINT64
Definition: actypes.h:131
#define ERR(fmt,...)
Definition: precomp.h:57
#define NULL
Definition: types.h:112
#define ULONG_PTR
Definition: config.h:101
Status
Definition: gdiplustypes.h:25
ULONG FrameBufferSize
Definition: xboxvideo.c:30
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
Definition: mmfuncs.h:404
EFI_LOCATE_PROTOCOL LocateProtocol
Definition: UefiSpec.h:1873
EFI_BOOT_SERVICES * BootServices
Definition: UefiSpec.h:1959
uint32_t UINT32
Definition: typedefs.h:59
uint32_t ULONG
Definition: typedefs.h:59
ULONG_PTR VramAddress
Definition: uefivid.c:21
EFI_SYSTEM_TABLE * GlobalSystemTable
Definition: uefildr.c:16
EFI_GUID AppleGraphInfoProtocol
Definition: uefivid.c:19
PCM_FRAMEBUF_DEVICE_DATA FrameBufferData
Definition: uefivid.c:23
ULONG VramSize
Definition: uefivid.c:22
_In_ HFONT _Out_ PUINT _Out_ PUINT Width
Definition: font.h:89
_In_ HFONT _Out_ PUINT Height
Definition: font.h:88
BOOLEAN VidFbInitializeVideo(_Out_opt_ PCM_FRAMEBUF_DEVICE_DATA *pFbData, _In_ ULONG_PTR BaseAddress, _In_ ULONG BufferSize, _In_ UINT32 ScreenWidth, _In_ UINT32 ScreenHeight, _In_ UINT32 PixelsPerScanLine, _In_ UINT32 BitsPerPixel, _In_opt_ PPIXEL_BITMASK PixelMasks)
Initializes internal framebuffer information based on the given parameters.
Definition: vidfb.c:99
struct _PIXEL_BITMASK * PPIXEL_BITMASK
_In_opt_ PALLOCATE_FUNCTION _In_opt_ PFREE_FUNCTION _In_ ULONG _In_ SIZE_T _In_ ULONG _In_ USHORT Depth
Definition: exfuncs.h:819

Referenced by UefiInitializeVideo().

◆ UefiInitializeGop()

static EFI_STATUS UefiInitializeGop ( VOID  )
static

Definition at line 58 of file uefivid.c.

59{
62
64 EFI_PIXEL_BITMASK* pPixelBitmask;
65 ULONG BitsPerPixel;
66
68 if (Status != EFI_SUCCESS)
69 {
70 TRACE("Failed to find GOP with status %d\n", Status);
71 return Status;
72 }
73
74 /* We don't need high resolutions for freeldr */
75 gop->SetMode(gop, LOWEST_SUPPORTED_RES);
76
77 /* Physical format of the pixel */
78 PixelFormat = gop->Mode->Info->PixelFormat;
79 switch (PixelFormat)
80 {
83 {
84 pPixelBitmask = &EfiPixelMasks[PixelFormat];
86 break;
87 }
88
89 case PixelBitMask:
90 {
91 /*
92 * When the GOP pixel format is given by PixelBitMask, the pixel
93 * element size _may be_ different from 4 bytes.
94 * See UEFI Spec Rev.2.10 Section 12.9 "Graphics Output Protocol":
95 * example code "GetPixelElementSize()" function.
96 */
97 pPixelBitmask = &gop->Mode->Info->PixelInformation;
98 BitsPerPixel =
99 PixelBitmasksToBpp(pPixelBitmask->RedMask,
100 pPixelBitmask->GreenMask,
101 pPixelBitmask->BlueMask,
102 pPixelBitmask->ReservedMask);
103 break;
104 }
105
106 case PixelBltOnly:
107 default:
108 {
109 ERR("Unsupported UEFI GOP format %lu\n", PixelFormat);
110 pPixelBitmask = NULL;
111 BitsPerPixel = 0;
112 break;
113 }
114 }
115
116 VramAddress = (ULONG_PTR)gop->Mode->FrameBufferBase;
117 VramSize = gop->Mode->FrameBufferSize;
120 VramSize,
121 gop->Mode->Info->HorizontalResolution,
122 gop->Mode->Info->VerticalResolution,
123 gop->Mode->Info->PixelsPerScanLine,
124 BitsPerPixel,
125 (PPIXEL_BITMASK)pPixelBitmask))
126 {
127 ERR("Couldn't initialize video framebuffer\n");
129 }
130 return Status;
131}
EFI_GRAPHICS_PIXEL_FORMAT
@ PixelBitMask
@ PixelRedGreenBlueReserved8BitPerColor
@ PixelBltOnly
INT PixelFormat
if(dx< 0)
Definition: linetemp.h:194
#define RTL_BITS_OF(sizeOfArg)
Definition: ntbasedef.h:680
#define TRACE(s)
Definition: solgame.cpp:4
Physical format of an RGB pixel, specified with per-component bit-masks. A bit being set defines thos...
Definition: vidfb.h:22
EFI_GUID EfiGraphicsOutputProtocol
Definition: uefivid.c:18
#define LOWEST_SUPPORTED_RES
Definition: uefivid.c:25
FORCEINLINE ULONG PixelBitmasksToBpp(_In_ ULONG RedMask, _In_ ULONG GreenMask, _In_ ULONG BlueMask, _In_ ULONG ReservedMask)
Calculates the number of bits per pixel ("PixelDepth") for the given pixel format,...
Definition: vidfb.h:41

Referenced by UefiInitializeVideo().

◆ UefiInitializeVideo()

EFI_STATUS UefiInitializeVideo ( VOID  )

Definition at line 187 of file uefivid.c.

188{
190
191 /* First, try GOP */
193 if (Status == EFI_SUCCESS)
194 return Status;
195
196 /* Try Apple Graphics Info if that fails */
197 TRACE("Failed to detect GOP, trying Apple Graphics Info\n");
199 if (Status == EFI_SUCCESS)
200 return Status;
201
202 /* We didn't find GOP or Apple Graphics Info, probably a UGA-only system */
203 ERR("Cannot find framebuffer!\n");
204 return Status;
205}
static EFI_STATUS UefiInitializeAppleGraphics(VOID)
Definition: uefivid.c:135
static EFI_STATUS UefiInitializeGop(VOID)
Definition: uefivid.c:58

Referenced by MachInit().

◆ UefiVideoClearScreen()

VOID UefiVideoClearScreen ( UCHAR  Attr)

Definition at line 209 of file uefivid.c.

210{
211 FbConsClearScreen(Attr);
212}
VOID FbConsClearScreen(_In_ UCHAR Attr)
Definition: vidfb.c:413

Referenced by MachInit().

◆ UefiVideoCopyOffScreenBufferToVRAM()

VOID UefiVideoCopyOffScreenBufferToVRAM ( PVOID  Buffer)

Definition at line 240 of file uefivid.c.

241{
243}
Definition: bufpool.h:45
VOID FbConsCopyOffScreenBufferToVRAM(_In_ PVOID Buffer)
Copies a full text-mode CGA-style character buffer rectangle to the console.
Definition: vidfb.c:492

Referenced by MachInit().

◆ UefiVideoGetBufferSize()

ULONG UefiVideoGetBufferSize ( VOID  )

Definition at line 234 of file uefivid.c.

235{
236 return FbConsGetBufferSize();
237}
ULONG FbConsGetBufferSize(VOID)
Returns the size in bytes, of a full text-mode CGA-style character buffer rectangle that can fill the...
Definition: vidfb.c:481

Referenced by MachInit().

◆ UefiVideoGetDisplaySize()

VOID UefiVideoGetDisplaySize ( PULONG  Width,
PULONG  Height,
PULONG  Depth 
)

Definition at line 221 of file uefivid.c.

222{
224}
VOID FbConsGetDisplaySize(_Out_ PULONG Width, _Out_ PULONG Height, _Out_ PULONG Depth)
Returns the width and height in number of CGA characters/attributes, of a full text-mode CGA-style ch...
Definition: vidfb.c:462

Referenced by MachInit(), and UefiConsPutChar().

◆ UefiVideoGetPaletteColor()

VOID UefiVideoGetPaletteColor ( UCHAR  Color,
UCHAR Red,
UCHAR Green,
UCHAR Blue 
)

Definition at line 271 of file uefivid.c.

273{
274 /* Not supported */
275}

Referenced by MachInit().

◆ UefiVideoHideShowTextCursor()

VOID UefiVideoHideShowTextCursor ( BOOLEAN  Show)

Definition at line 252 of file uefivid.c.

253{
254 /* We don't have a cursor yet */
255}

Referenced by MachInit().

◆ UefiVideoIsPaletteFixed()

BOOLEAN UefiVideoIsPaletteFixed ( VOID  )

Definition at line 258 of file uefivid.c.

259{
260 return 0;
261}

Referenced by MachInit().

◆ UefiVideoPutChar()

VOID UefiVideoPutChar ( int  Ch,
UCHAR  Attr,
unsigned  X,
unsigned  Y 
)

Definition at line 215 of file uefivid.c.

216{
217 FbConsPutChar(Ch, Attr, X, Y);
218}
#define Y(I)
#define Ch(x, y, z)
Definition: sha2.c:141
VOID FbConsPutChar(_In_ UCHAR Char, _In_ UCHAR Attr, _In_ ULONG Column, _In_ ULONG Row)
Displays a character with specific text attributes at a given position.
Definition: vidfb.c:445

Referenced by MachInit(), and UefiConsPutChar().

◆ UefiVideoSetDisplayMode()

VIDEODISPLAYMODE UefiVideoSetDisplayMode ( PCSTR  DisplayMode,
BOOLEAN  Init 
)

Definition at line 227 of file uefivid.c.

228{
229 /* We only have one mode, semi-text */
230 return VideoTextMode;
231}
@ VideoTextMode
Definition: machine.h:35

Referenced by MachInit().

◆ UefiVideoSetPaletteColor()

VOID UefiVideoSetPaletteColor ( UCHAR  Color,
UCHAR  Red,
UCHAR  Green,
UCHAR  Blue 
)

Definition at line 264 of file uefivid.c.

266{
267 /* Not supported */
268}

Referenced by MachInit().

◆ UefiVideoSetTextCursorPosition()

VOID UefiVideoSetTextCursorPosition ( UCHAR  X,
UCHAR  Y 
)

Definition at line 246 of file uefivid.c.

247{
248 /* We don't have a cursor yet */
249}

Referenced by MachInit().

Variable Documentation

◆ AppleGraphInfoProtocol

EFI_GUID AppleGraphInfoProtocol = APPLE_GRAPH_INFO_PROTOCOL_GUID

Definition at line 19 of file uefivid.c.

Referenced by UefiInitializeAppleGraphics().

◆ EfiGraphicsOutputProtocol

EFI_GUID EfiGraphicsOutputProtocol = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID

Definition at line 18 of file uefivid.c.

Referenced by UefiInitializeGop().

◆ FrameBufferData

PCM_FRAMEBUF_DEVICE_DATA FrameBufferData = NULL

◆ GlobalImageHandle

EFI_HANDLE GlobalImageHandle
extern

Definition at line 15 of file uefildr.c.

Referenced by EfiEntry().

◆ GlobalSystemTable

EFI_SYSTEM_TABLE* GlobalSystemTable
extern

Definition at line 16 of file uefildr.c.

Referenced by EfiEntry(), UefiInitializeAppleGraphics(), and UefiInitializeGop().

◆ VramAddress

◆ VramSize