ReactOS 0.4.15-dev-8096-ga0eec98
uefivid.c File Reference
#include <uefildr.h>
#include <debug.h>
Include dependency graph for uefivid.c:

Go to the source code of this file.

Macros

#define CHAR_WIDTH   8
 
#define CHAR_HEIGHT   16
 
#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 (char *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 BitmapFont8x16 [256 *16]
 
UCHAR MachDefaultTextColor = COLOR_GRAY
 
REACTOS_INTERNAL_BGCONTEXT framebufferData
 
EFI_GUID EfiGraphicsOutputProtocol = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID
 

Macro Definition Documentation

◆ CHAR_HEIGHT

#define CHAR_HEIGHT   16

Definition at line 14 of file uefivid.c.

◆ CHAR_WIDTH

#define CHAR_WIDTH   8

Definition at line 13 of file uefivid.c.

◆ LOWEST_SUPPORTED_RES

#define LOWEST_SUPPORTED_RES   1

Definition at line 16 of file uefivid.c.

◆ TOP_BOTTOM_LINES

#define TOP_BOTTOM_LINES   0

Definition at line 15 of file uefivid.c.

Function Documentation

◆ DBG_DEFAULT_CHANNEL()

DBG_DEFAULT_CHANNEL ( WARNING  )

◆ UefiInitializeVideo()

EFI_STATUS UefiInitializeVideo ( VOID  )

Definition at line 31 of file uefivid.c.

32{
35
38 if (Status != EFI_SUCCESS)
39 {
40 TRACE("Failed to find GOP with status %d\n", Status);
41 return Status;
42 }
43
44 /* We don't need high resolutions for freeldr */
45 gop->SetMode(gop, LOWEST_SUPPORTED_RES);
46
47 framebufferData.BaseAddress = (ULONG_PTR)gop->Mode->FrameBufferBase;
48 framebufferData.BufferSize = gop->Mode->FrameBufferSize;
49 framebufferData.ScreenWidth = gop->Mode->Info->HorizontalResolution;
50 framebufferData.ScreenHeight = gop->Mode->Info->VerticalResolution;
51 framebufferData.PixelsPerScanLine = gop->Mode->Info->PixelsPerScanLine;
52 framebufferData.PixelFormat = gop->Mode->Info->PixelFormat;
53
54 return Status;
55}
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:26
EFI_SYSTEM_TABLE * GlobalSystemTable
Definition: uefildr.c:16
#define LOWEST_SUPPORTED_RES
Definition: uefivid.c:16
REACTOS_INTERNAL_BGCONTEXT framebufferData
Definition: uefivid.c:25

Referenced by MachInit().

◆ UefiPrintFramebufferData()

VOID UefiPrintFramebufferData ( VOID  )

Definition at line 58 of file uefivid.c.

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

◆ UefiVideoAttrToColors()

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

Definition at line 81 of file uefivid.c.

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

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

◆ UefiVideoAttrToSingleColor()

static ULONG UefiVideoAttrToSingleColor ( UCHAR  Attr)
static

Definition at line 69 of file uefivid.c.

70{
72 Intensity = (0 == (Attr & 0x08) ? 127 : 255);
73
74 return 0xff000000 |
75 (0 == (Attr & 0x04) ? 0 : (Intensity << 16)) |
76 (0 == (Attr & 0x02) ? 0 : (Intensity << 8)) |
77 (0 == (Attr & 0x01) ? 0 : Intensity);
78}
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 107 of file uefivid.c.

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

Referenced by MachInit().

◆ UefiVideoClearScreenColor()

static VOID UefiVideoClearScreenColor ( ULONG  Color,
BOOLEAN  FullScreen 
)
static

Definition at line 89 of file uefivid.c.

90{
92 ULONG Line, Col;
93 PULONG p;
94
95 Delta = (framebufferData.PixelsPerScanLine * 4 + 3) & ~ 0x3;
96 for (Line = 0; Line < framebufferData.ScreenHeight - (FullScreen ? 0 : 2 * TOP_BOTTOM_LINES); Line++)
97 {
98 p = (PULONG) ((char *) framebufferData.BaseAddress + (Line + (FullScreen ? 0 : TOP_BOTTOM_LINES)) * Delta);
99 for (Col = 0; Col < framebufferData.ScreenWidth; Col++)
100 {
101 *p++ = Color;
102 }
103 }
104}
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:15
static ULONG Delta
Definition: xboxvideo.c:33

Referenced by UefiVideoClearScreen().

◆ UefiVideoCopyOffScreenBufferToVRAM()

VOID UefiVideoCopyOffScreenBufferToVRAM ( PVOID  Buffer)

Definition at line 175 of file uefivid.c.

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

Referenced by MachInit().

◆ UefiVideoGetBufferSize()

ULONG UefiVideoGetBufferSize ( VOID  )

Definition at line 169 of file uefivid.c.

Referenced by MachInit().

◆ UefiVideoGetDisplaySize()

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

Definition at line 154 of file uefivid.c.

155{
158 *Depth = 0;
159}
_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 236 of file uefivid.c.

238{
239 /* Not supported */
240}

Referenced by MachInit().

◆ UefiVideoHideShowTextCursor()

VOID UefiVideoHideShowTextCursor ( BOOLEAN  Show)

Definition at line 217 of file uefivid.c.

218{
219 /* We don't have a cursor yet */
220}

Referenced by MachInit().

◆ UefiVideoIsPaletteFixed()

BOOLEAN UefiVideoIsPaletteFixed ( VOID  )

Definition at line 223 of file uefivid.c.

224{
225 return 0;
226}

Referenced by MachInit().

◆ UefiVideoOutputChar()

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

Definition at line 116 of file uefivid.c.

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

Referenced by UefiVideoPutChar().

◆ UefiVideoPutChar()

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

Definition at line 142 of file uefivid.c.

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

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

◆ UefiVideoScrollUp()

VOID UefiVideoScrollUp ( VOID  )

Definition at line 191 of file uefivid.c.

192{
193 ULONG BgColor, Dummy;
194 ULONG Delta;
195 Delta = (framebufferData.PixelsPerScanLine * 4 + 3) & ~ 0x3;
200
202
203 while (PixelCount--)
204 *Dst++ = *Src++;
205
206 for (PixelCount = 0; PixelCount < framebufferData.ScreenWidth * CHAR_HEIGHT; PixelCount++)
207 *Dst++ = BgColor;
208}
#define ATTR(cFore, cBack)
Definition: ui.h:317
#define COLOR_WHITE
Definition: ui.h:338
#define COLOR_BLACK
Definition: ui.h:322
#define Dst
Definition: mesh.h:153

Referenced by UefiConsPutChar().

◆ UefiVideoSetDisplayMode()

VIDEODISPLAYMODE UefiVideoSetDisplayMode ( char DisplayMode,
BOOLEAN  Init 
)

Definition at line 162 of file uefivid.c.

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

Referenced by MachInit().

◆ UefiVideoSetPaletteColor()

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

Definition at line 229 of file uefivid.c.

231{
232 /* Not supported */
233}

Referenced by MachInit().

◆ UefiVideoSetTextCursorPosition()

VOID UefiVideoSetTextCursorPosition ( UCHAR  X,
UCHAR  Y 
)

Definition at line 211 of file uefivid.c.

212{
213 /* We don't have a cursor yet */
214}

Referenced by MachInit().

Variable Documentation

◆ BitmapFont8x16

UCHAR BitmapFont8x16[256 *16]
extern

Definition at line 12 of file vgafont.c.

Referenced by UefiVideoOutputChar().

◆ 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 24 of file uefivid.c.

Referenced by TuiTextToColor().