ReactOS 0.4.16-dev-1990-gfa5cf28
uefivid.c File Reference
#include <uefildr.h>
#include "../vgafont.h"
#include <debug.h>
Include dependency graph for uefivid.c:

Go to the source code of this file.

Macros

#define TOP_BOTTOM_LINES   0
 
#define LOWEST_SUPPORTED_RES   1
 

Functions

 DBG_DEFAULT_CHANNEL (WARNING)
 
EFI_STATUS UefiInitializeVideo (VOID)
 
VOID UefiPrintFramebufferData (VOID)
 
static ULONG UefiVideoAttrToSingleColor (UCHAR Attr)
 
static VOID UefiVideoAttrToColors (UCHAR Attr, ULONG *FgColor, ULONG *BgColor)
 
static VOID UefiVideoClearScreenColor (ULONG Color, BOOLEAN FullScreen)
 
VOID UefiVideoClearScreen (UCHAR Attr)
 
VOID UefiVideoOutputChar (UCHAR Char, unsigned X, unsigned Y, ULONG FgColor, ULONG BgColor)
 
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 UefiVideoScrollUp (VOID)
 
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
 
UCHAR MachDefaultTextColor = COLOR_GRAY
 
REACTOS_INTERNAL_BGCONTEXT framebufferData
 
EFI_GUID EfiGraphicsOutputProtocol = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID
 

Macro Definition Documentation

◆ LOWEST_SUPPORTED_RES

#define LOWEST_SUPPORTED_RES   1

Definition at line 15 of file uefivid.c.

◆ TOP_BOTTOM_LINES

#define TOP_BOTTOM_LINES   0

Definition at line 14 of file uefivid.c.

Function Documentation

◆ DBG_DEFAULT_CHANNEL()

DBG_DEFAULT_CHANNEL ( WARNING  )

◆ UefiInitializeVideo()

EFI_STATUS UefiInitializeVideo ( VOID  )

Definition at line 29 of file uefivid.c.

30{
33
36 if (Status != EFI_SUCCESS)
37 {
38 TRACE("Failed to find GOP with status %d\n", Status);
39 return Status;
40 }
41
42 /* We don't need high resolutions for freeldr */
43 gop->SetMode(gop, LOWEST_SUPPORTED_RES);
44
45 framebufferData.BaseAddress = (ULONG_PTR)gop->Mode->FrameBufferBase;
46 framebufferData.BufferSize = gop->Mode->FrameBufferSize;
47 framebufferData.ScreenWidth = gop->Mode->Info->HorizontalResolution;
48 framebufferData.ScreenHeight = gop->Mode->Info->VerticalResolution;
49 framebufferData.PixelsPerScanLine = gop->Mode->Info->PixelsPerScanLine;
50 framebufferData.PixelFormat = gop->Mode->Info->PixelFormat;
51
52 return Status;
53}
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:31
#define EFI_SUCCESS
Definition: UefiBaseType.h:120
#define NULL
Definition: types.h:112
#define ULONG_PTR
Definition: config.h:101
Status
Definition: gdiplustypes.h:25
#define TRACE(s)
Definition: solgame.cpp:4
EFI_LOCATE_PROTOCOL LocateProtocol
Definition: UefiSpec.h:1873
EFI_BOOT_SERVICES * BootServices
Definition: UefiSpec.h:1959
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
EFI_GUID EfiGraphicsOutputProtocol
Definition: uefivid.c:24
EFI_SYSTEM_TABLE * GlobalSystemTable
Definition: uefildr.c:16
#define LOWEST_SUPPORTED_RES
Definition: uefivid.c:15
REACTOS_INTERNAL_BGCONTEXT framebufferData
Definition: uefivid.c:23

Referenced by MachInit().

◆ UefiPrintFramebufferData()

VOID UefiPrintFramebufferData ( VOID  )

Definition at line 56 of file uefivid.c.

57{
58 TRACE("Framebuffer BaseAddress : %X\n", framebufferData.BaseAddress);
59 TRACE("Framebuffer BufferSize : %X\n", framebufferData.BufferSize);
60 TRACE("Framebuffer ScreenWidth : %d\n", framebufferData.ScreenWidth);
61 TRACE("Framebuffer ScreenHeight : %d\n", framebufferData.ScreenHeight);
62 TRACE("Framebuffer PixelsPerScanLine : %d\n", framebufferData.PixelsPerScanLine);
63 TRACE("Framebuffer PixelFormat : %d\n", framebufferData.PixelFormat);
64}

◆ UefiVideoAttrToColors()

static VOID UefiVideoAttrToColors ( UCHAR  Attr,
ULONG FgColor,
ULONG BgColor 
)
static

Definition at line 79 of file uefivid.c.

80{
81 *FgColor = UefiVideoAttrToSingleColor(Attr & 0xf);
82 *BgColor = UefiVideoAttrToSingleColor((Attr >> 4) & 0xf);
83}
static ULONG UefiVideoAttrToSingleColor(UCHAR Attr)
Definition: uefivid.c:67

Referenced by UefiVideoClearScreen(), UefiVideoPutChar(), and UefiVideoScrollUp().

◆ UefiVideoAttrToSingleColor()

static ULONG UefiVideoAttrToSingleColor ( UCHAR  Attr)
static

Definition at line 67 of file uefivid.c.

68{
70 Intensity = (0 == (Attr & 0x08) ? 127 : 255);
71
72 return 0xff000000 |
73 (0 == (Attr & 0x04) ? 0 : (Intensity << 16)) |
74 (0 == (Attr & 0x02) ? 0 : (Intensity << 8)) |
75 (0 == (Attr & 0x01) ? 0 : Intensity);
76}
static WORD Intensity(RGBQUAD clr)
Definition: msrle32.c:44
unsigned char UCHAR
Definition: xmlstorage.h:181

Referenced by UefiVideoAttrToColors().

◆ UefiVideoClearScreen()

VOID UefiVideoClearScreen ( UCHAR  Attr)

Definition at line 105 of file uefivid.c.

106{
107 ULONG FgColor, BgColor;
108
109 UefiVideoAttrToColors(Attr, &FgColor, &BgColor);
111}
#define FALSE
Definition: types.h:117
uint32_t ULONG
Definition: typedefs.h:59
static VOID UefiVideoClearScreenColor(ULONG Color, BOOLEAN FullScreen)
Definition: uefivid.c:87
static VOID UefiVideoAttrToColors(UCHAR Attr, ULONG *FgColor, ULONG *BgColor)
Definition: uefivid.c:79

Referenced by MachInit().

◆ UefiVideoClearScreenColor()

static VOID UefiVideoClearScreenColor ( ULONG  Color,
BOOLEAN  FullScreen 
)
static

Definition at line 87 of file uefivid.c.

88{
90 ULONG Line, Col;
91 PULONG p;
92
93 Delta = (framebufferData.PixelsPerScanLine * 4 + 3) & ~ 0x3;
94 for (Line = 0; Line < framebufferData.ScreenHeight - (FullScreen ? 0 : 2 * TOP_BOTTOM_LINES); Line++)
95 {
96 p = (PULONG) ((char *) framebufferData.BaseAddress + (Line + (FullScreen ? 0 : TOP_BOTTOM_LINES)) * Delta);
97 for (Col = 0; Col < framebufferData.ScreenWidth; Col++)
98 {
99 *p++ = Color;
100 }
101 }
102}
GLfloat GLfloat p
Definition: glext.h:8902
Definition: ncftp.h:79
uint32_t * PULONG
Definition: typedefs.h:59
#define TOP_BOTTOM_LINES
Definition: uefivid.c:14
static ULONG Delta
Definition: xboxvideo.c:34

Referenced by UefiVideoClearScreen().

◆ UefiVideoCopyOffScreenBufferToVRAM()

VOID UefiVideoCopyOffScreenBufferToVRAM ( PVOID  Buffer)

Definition at line 173 of file uefivid.c.

174{
175 PUCHAR OffScreenBuffer = (PUCHAR)Buffer;
176
177 ULONG Col, Line;
179 {
180 for (Col = 0; Col < framebufferData.ScreenWidth / CHAR_WIDTH; Col++)
181 {
182 UefiVideoPutChar(OffScreenBuffer[0], OffScreenBuffer[1], Col, Line);
183 OffScreenBuffer += 2;
184 }
185 }
186}
Definition: bufpool.h:45
unsigned char * PUCHAR
Definition: typedefs.h:53
VOID UefiVideoPutChar(int Ch, UCHAR Attr, unsigned X, unsigned Y)
Definition: uefivid.c:140
#define CHAR_WIDTH
Definition: vgafont.h:10
#define CHAR_HEIGHT
Definition: vgafont.h:11

Referenced by MachInit().

◆ UefiVideoGetBufferSize()

ULONG UefiVideoGetBufferSize ( VOID  )

Definition at line 167 of file uefivid.c.

Referenced by MachInit().

◆ UefiVideoGetDisplaySize()

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

Definition at line 152 of file uefivid.c.

153{
156 *Depth = 0;
157}
_In_ HFONT _Out_ PUINT _Out_ PUINT Width
Definition: font.h:89
_In_ HFONT _Out_ PUINT Height
Definition: font.h:88
_In_opt_ PALLOCATE_FUNCTION _In_opt_ PFREE_FUNCTION _In_ ULONG _In_ SIZE_T _In_ ULONG _In_ USHORT Depth
Definition: exfuncs.h:819

Referenced by MachInit(), and UefiConsPutChar().

◆ UefiVideoGetPaletteColor()

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

Definition at line 234 of file uefivid.c.

236{
237 /* Not supported */
238}

Referenced by MachInit().

◆ UefiVideoHideShowTextCursor()

VOID UefiVideoHideShowTextCursor ( BOOLEAN  Show)

Definition at line 215 of file uefivid.c.

216{
217 /* We don't have a cursor yet */
218}

Referenced by MachInit().

◆ UefiVideoIsPaletteFixed()

BOOLEAN UefiVideoIsPaletteFixed ( VOID  )

Definition at line 221 of file uefivid.c.

222{
223 return 0;
224}

Referenced by MachInit().

◆ UefiVideoOutputChar()

VOID UefiVideoOutputChar ( UCHAR  Char,
unsigned  X,
unsigned  Y,
ULONG  FgColor,
ULONG  BgColor 
)

Definition at line 114 of file uefivid.c.

115{
116 const UCHAR* FontPtr;
117 PULONG Pixel;
118 UCHAR Mask;
119 unsigned Line;
120 unsigned Col;
121 ULONG Delta;
122 Delta = (framebufferData.PixelsPerScanLine * 4 + 3) & ~ 0x3;
123 FontPtr = BitmapFont8x16 + Char * CHAR_HEIGHT;
124 Pixel = (PULONG) ((char *) framebufferData.BaseAddress +
126
127 for (Line = 0; Line < CHAR_HEIGHT; Line++)
128 {
129 Mask = 0x80;
130 for (Col = 0; Col < CHAR_WIDTH; Col++)
131 {
132 Pixel[Col] = (0 != (FontPtr[Line] & Mask) ? FgColor : BgColor);
133 Mask = Mask >> 1;
134 }
135 Pixel = (PULONG) ((char *) Pixel + Delta);
136 }
137}
#define Y(I)
unsigned int Mask
Definition: fpcontrol.c:82
const UCHAR BitmapFont8x16[256 *CHAR_HEIGHT]
Definition: vgafont.c:13

Referenced by UefiVideoPutChar().

◆ UefiVideoPutChar()

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

Definition at line 140 of file uefivid.c.

141{
142 ULONG FgColor = 0;
143 ULONG BgColor = 0;
144 if (Ch != 0)
145 {
146 UefiVideoAttrToColors(Attr, &FgColor, &BgColor);
147 UefiVideoOutputChar(Ch, X, Y, FgColor, BgColor);
148 }
149}
#define Ch(x, y, z)
Definition: sha2.c:141
VOID UefiVideoOutputChar(UCHAR Char, unsigned X, unsigned Y, ULONG FgColor, ULONG BgColor)
Definition: uefivid.c:114

Referenced by MachInit(), UefiConsPutChar(), and UefiVideoCopyOffScreenBufferToVRAM().

◆ UefiVideoScrollUp()

VOID UefiVideoScrollUp ( VOID  )

Definition at line 189 of file uefivid.c.

190{
191 ULONG BgColor, Dummy;
192 ULONG Delta;
193 Delta = (framebufferData.PixelsPerScanLine * 4 + 3) & ~ 0x3;
198
200
201 while (PixelCount--)
202 *Dst++ = *Src++;
203
204 for (PixelCount = 0; PixelCount < framebufferData.ScreenWidth * CHAR_HEIGHT; PixelCount++)
205 *Dst++ = BgColor;
206}
#define ATTR(cFore, cBack)
Definition: ui.h:323
#define COLOR_WHITE
Definition: ui.h:344
#define COLOR_BLACK
Definition: ui.h:328
#define Dst
Definition: mesh.h:153

Referenced by UefiConsPutChar().

◆ UefiVideoSetDisplayMode()

VIDEODISPLAYMODE UefiVideoSetDisplayMode ( PCSTR  DisplayMode,
BOOLEAN  Init 
)

Definition at line 160 of file uefivid.c.

161{
162 /* We only have one mode, semi-text */
163 return VideoTextMode;
164}
@ VideoTextMode
Definition: machine.h:35

Referenced by MachInit().

◆ UefiVideoSetPaletteColor()

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

Definition at line 227 of file uefivid.c.

229{
230 /* Not supported */
231}

Referenced by MachInit().

◆ UefiVideoSetTextCursorPosition()

VOID UefiVideoSetTextCursorPosition ( UCHAR  X,
UCHAR  Y 
)

Definition at line 209 of file uefivid.c.

210{
211 /* We don't have a cursor yet */
212}

Referenced by MachInit().

Variable Documentation

◆ EfiGraphicsOutputProtocol

◆ framebufferData

◆ 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(), and UefiInitializeVideo().

◆ MachDefaultTextColor

UCHAR MachDefaultTextColor = COLOR_GRAY

Definition at line 22 of file uefivid.c.

Referenced by TuiTextToColor().