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

Go to the source code of this file.

Classes

struct  _UEFI_BGRT_LOGO
 
struct  _BMP_FILE_HEADER
 
struct  _BMP_INFO_HEADER
 

Macros

#define BMP_SIGNATURE   0x4D42
 
#define BI_RGB   0
 
#define BGRT_STATUS_ORIENTATION_MASK   (0x3 << 1)
 
#define BGRT_ORIENTATION_0   0
 
#define BGRT_ORIENTATION_90   1
 
#define BGRT_ORIENTATION_180   2
 
#define BGRT_ORIENTATION_270   3
 
#define LOWEST_SUPPORTED_RES   1
 

Typedefs

typedef struct _UEFI_BGRT_LOGO UEFI_BGRT_LOGO
 
typedef struct _UEFI_BGRT_LOGOPUEFI_BGRT_LOGO
 
typedef struct _BMP_FILE_HEADER BMP_FILE_HEADER
 
typedef struct _BMP_FILE_HEADERPBMP_FILE_HEADER
 
typedef struct _BMP_INFO_HEADER BMP_INFO_HEADER
 
typedef struct _BMP_INFO_HEADERPBMP_INFO_HEADER
 

Functions

 DBG_DEFAULT_CHANNEL (UI)
 
 C_ASSERT (sizeof(BMP_FILE_HEADER)==14)
 
 C_ASSERT (sizeof(BMP_INFO_HEADER)==40)
 
BOOLEAN UefiCalculateBmpRowStride (_In_ ULONG Width, _In_ USHORT BitsPerPixel, _Out_ PULONG RowStride)
 
static VOID UefiPrepareCenteredLogoAxis (_In_ ULONG BitmapSize, _In_ ULONG ScreenSize, _Out_ PULONG SourceOffset, _Out_ PULONG DestinationOffset, _Out_ PULONG DrawSize)
 
static VOID UefiPreparePositionedLogoAxis (_In_ ULONG BitmapSize, _In_ ULONG ScreenSize, _In_ ULONG RequestedOffset, _Out_ PULONG SourceOffset, _Out_ PULONG DestinationOffset, _Out_ PULONG DrawSize)
 
static VOID UefiGetRotatedLogoSize (_In_ PUEFI_BGRT_LOGO Logo, _Out_ PULONG Width, _Out_ PULONG Height)
 
static VOID UefiGetLogoSourceCoordinates (_In_ PUEFI_BGRT_LOGO Logo, _In_ ULONG X, _In_ ULONG Y, _Out_ PULONG SourceX, _Out_ PULONG SourceY)
 
static __inline PUCHAR UefiGetLogoPixelAddress (_In_ PUEFI_BGRT_LOGO Logo, _In_ ULONG X, _In_ ULONG Y)
 
static VOID UefiInitializeBgrtLogo (VOID)
 
static VOID UefiDrawBgrtLogo (VOID)
 
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
 
static UEFI_BGRT_LOGO UefiBgrtLogo = {0}
 

Macro Definition Documentation

◆ BGRT_ORIENTATION_0

#define BGRT_ORIENTATION_0   0

Definition at line 49 of file uefivid.c.

◆ BGRT_ORIENTATION_180

#define BGRT_ORIENTATION_180   2

Definition at line 51 of file uefivid.c.

◆ BGRT_ORIENTATION_270

#define BGRT_ORIENTATION_270   3

Definition at line 52 of file uefivid.c.

◆ BGRT_ORIENTATION_90

#define BGRT_ORIENTATION_90   1

Definition at line 50 of file uefivid.c.

◆ BGRT_STATUS_ORIENTATION_MASK

#define BGRT_STATUS_ORIENTATION_MASK   (0x3 << 1)

Definition at line 48 of file uefivid.c.

◆ BI_RGB

#define BI_RGB   0

◆ BMP_SIGNATURE

#define BMP_SIGNATURE   0x4D42

Definition at line 45 of file uefivid.c.

◆ LOWEST_SUPPORTED_RES

#define LOWEST_SUPPORTED_RES   1

Definition at line 54 of file uefivid.c.

Typedef Documentation

◆ BMP_FILE_HEADER

◆ BMP_INFO_HEADER

◆ PBMP_FILE_HEADER

◆ PBMP_INFO_HEADER

◆ PUEFI_BGRT_LOGO

◆ UEFI_BGRT_LOGO

Function Documentation

◆ C_ASSERT() [1/2]

C_ASSERT ( sizeof(BMP_FILE_HEADER = =14)

◆ C_ASSERT() [2/2]

C_ASSERT ( sizeof(BMP_INFO_HEADER = =40)

◆ DBG_DEFAULT_CHANNEL()

DBG_DEFAULT_CHANNEL ( UI  )

◆ UefiCalculateBmpRowStride()

BOOLEAN UefiCalculateBmpRowStride ( _In_ ULONG  Width,
_In_ USHORT  BitsPerPixel,
_Out_ PULONG  RowStride 
)

Definition at line 115 of file uefivid.c.

119{
120 ULONGLONG BitsPerRow, Stride;
121
122 BitsPerRow = (ULONGLONG)Width * BitsPerPixel;
123 Stride = ROUND_UP(BitsPerRow, 32) / 8;
124 if (Stride > MAXULONG)
125 return FALSE;
126
127 *RowStride = (ULONG)Stride;
128 return TRUE;
129}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define ROUND_UP(n, align)
Definition: eventvwr.h:34
#define MAXULONG
Definition: typedefs.h:251
uint32_t ULONG
Definition: typedefs.h:59
uint64_t ULONGLONG
Definition: typedefs.h:67
_In_ HFONT _Out_ PUINT _Out_ PUINT Width
Definition: font.h:89

Referenced by UefiInitializeBgrtLogo().

◆ UefiDrawBgrtLogo()

static VOID UefiDrawBgrtLogo ( VOID  )
static

Definition at line 433 of file uefivid.c.

434{
435 PUCHAR VramBase;
436 ULONG BytesPerPixel, Pitch;
437 ULONG Row, Col;
438
440 return;
441
442 if ((UefiBgrtLogo.DrawWidth == 0) || (UefiBgrtLogo.DrawHeight == 0))
443 return;
444
446 return;
447
450 VramBase = (PUCHAR)VramAddress;
451
452 for (Row = 0; Row < UefiBgrtLogo.DrawHeight; ++Row)
453 {
454 PULONG DestinationRow;
455
456 DestinationRow = (PULONG)(VramBase +
457 (UefiBgrtLogo.PositionY + Row) * Pitch +
459
460 for (Col = 0; Col < UefiBgrtLogo.DrawWidth; ++Col)
461 {
462 ULONG SourceX, SourceY;
463 PUCHAR SourcePixel;
464
466 UefiBgrtLogo.SourceX + Col,
467 UefiBgrtLogo.SourceY + Row,
468 &SourceX,
469 &SourceY);
470
471 SourcePixel = UefiGetLogoPixelAddress(&UefiBgrtLogo, SourceX, SourceY);
472
473 DestinationRow[Col] = 0xFF000000 |
474 (SourcePixel[2] << 16) |
475 (SourcePixel[1] << 8) |
476 SourcePixel[0];
477 }
478 }
479}
UI_PROGRESS_BAR UiProgressBar
Definition: ui.c:62
#define NULL
Definition: types.h:112
static UCHAR BytesPerPixel
Definition: bootvid.c:37
ULONG BitsPerPixel
Pixel depth.
Definition: framebuf.h:51
ULONG PixelsPerScanLine
Pitch/stride in pixels.
Definition: framebuf.h:50
ULONG SourceX
Definition: uefivid.c:35
ULONG DrawHeight
Definition: uefivid.c:40
BOOLEAN Valid
Definition: uefivid.c:27
ULONG PositionX
Definition: uefivid.c:37
ULONG DrawWidth
Definition: uefivid.c:39
ULONG PositionY
Definition: uefivid.c:38
ULONG SourceY
Definition: uefivid.c:36
BOOLEAN Show
Definition: ui.h:142
uint32_t * PULONG
Definition: typedefs.h:59
unsigned char * PUCHAR
Definition: typedefs.h:53
ULONG_PTR VramAddress
Definition: uefivid.c:21
static __inline PUCHAR UefiGetLogoPixelAddress(_In_ PUEFI_BGRT_LOGO Logo, _In_ ULONG X, _In_ ULONG Y)
Definition: uefivid.c:231
static UEFI_BGRT_LOGO UefiBgrtLogo
Definition: uefivid.c:43
PCM_FRAMEBUF_DEVICE_DATA FrameBufferData
Definition: uefivid.c:23
static VOID UefiGetLogoSourceCoordinates(_In_ PUEFI_BGRT_LOGO Logo, _In_ ULONG X, _In_ ULONG Y, _Out_ PULONG SourceX, _Out_ PULONG SourceY)
Definition: uefivid.c:196

Referenced by UefiVideoCopyOffScreenBufferToVRAM().

◆ UefiGetLogoPixelAddress()

static __inline PUCHAR UefiGetLogoPixelAddress ( _In_ PUEFI_BGRT_LOGO  Logo,
_In_ ULONG  X,
_In_ ULONG  Y 
)
static

Definition at line 231 of file uefivid.c.

235{
236 ULONG SourceRowIndex;
237
238 SourceRowIndex = (Logo->TopDown ? Y : (Logo->Height - 1 - Y));
239 return Logo->PixelData +
240 SourceRowIndex * Logo->RowStride +
241 X * (Logo->BitsPerPixel / 8);
242}
#define Y(I)

Referenced by UefiDrawBgrtLogo().

◆ UefiGetLogoSourceCoordinates()

static VOID UefiGetLogoSourceCoordinates ( _In_ PUEFI_BGRT_LOGO  Logo,
_In_ ULONG  X,
_In_ ULONG  Y,
_Out_ PULONG  SourceX,
_Out_ PULONG  SourceY 
)
static

Definition at line 196 of file uefivid.c.

202{
203 switch (Logo->Orientation)
204 {
206 *SourceX = Y;
207 *SourceY = Logo->Height - 1 - X;
208 break;
209
211 *SourceX = Logo->Width - 1 - X;
212 *SourceY = Logo->Height - 1 - Y;
213 break;
214
216 *SourceX = Logo->Width - 1 - Y;
217 *SourceY = X;
218 break;
219
221 default:
222 *SourceX = X;
223 *SourceY = Y;
224 break;
225 }
226}
#define X(b, s)
#define BGRT_ORIENTATION_270
Definition: uefivid.c:52
#define BGRT_ORIENTATION_180
Definition: uefivid.c:51
#define BGRT_ORIENTATION_90
Definition: uefivid.c:50
#define BGRT_ORIENTATION_0
Definition: uefivid.c:49

Referenced by UefiDrawBgrtLogo().

◆ UefiGetRotatedLogoSize()

static VOID UefiGetRotatedLogoSize ( _In_ PUEFI_BGRT_LOGO  Logo,
_Out_ PULONG  Width,
_Out_ PULONG  Height 
)
static

Definition at line 177 of file uefivid.c.

181{
182 if ((Logo->Orientation == BGRT_ORIENTATION_90) ||
183 (Logo->Orientation == BGRT_ORIENTATION_270))
184 {
185 *Width = Logo->Height;
186 *Height = Logo->Width;
187 return;
188 }
189
190 *Width = Logo->Width;
191 *Height = Logo->Height;
192}
_In_ HFONT _Out_ PUINT Height
Definition: font.h:88

Referenced by UefiInitializeBgrtLogo().

◆ UefiInitializeAppleGraphics()

static EFI_STATUS UefiInitializeAppleGraphics ( VOID  )
static

Definition at line 564 of file uefivid.c.

565{
567 APPLE_GRAPH_INFO_PROTOCOL *AppleGraph = NULL;
568 EFI_PIXEL_BITMASK* pPixelBitmask;
569
571 UINT32 BytesPerRow, Width, Height, Depth;
572
574 if (Status != EFI_SUCCESS)
575 {
576 ERR("Failed to find Apple Graphics Info with status %d\n", Status);
577 return Status;
578 }
579
580 Status = AppleGraph->GetInfo(AppleGraph,
583 &BytesPerRow,
584 &Width,
585 &Height,
586 &Depth);
587
588 if (Status != EFI_SUCCESS)
589 {
590 ERR("Failed to get graphics info from Apple Scren Info: %d\n", Status);
591 return Status;
592 }
593
594 /* All devices requiring Apple Graphics Info use PixelBlueGreenRedReserved8BitPerColor. */
595 pPixelBitmask = &EfiPixelMasks[PixelBlueGreenRedReserved8BitPerColor];
596
601 VramSize,
602 Width,
603 Height,
604 (BytesPerRow / 4),
605 Depth,
606 (PPIXEL_BITMASK)pPixelBitmask))
607 {
608 ERR("Couldn't initialize video framebuffer\n");
610 }
611 else
612 {
614 }
615
616 return Status;
617}
@ 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 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
static VOID UefiInitializeBgrtLogo(VOID)
Definition: uefivid.c:246
EFI_SYSTEM_TABLE * GlobalSystemTable
Definition: uefildr.c:16
EFI_GUID AppleGraphInfoProtocol
Definition: uefivid.c:19
ULONG VramSize
Definition: uefivid.c:22
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().

◆ UefiInitializeBgrtLogo()

static VOID UefiInitializeBgrtLogo ( VOID  )
static

Definition at line 246 of file uefivid.c.

247{
248 PBGRT_TABLE BgrtTable;
249 PBMP_FILE_HEADER FileHeader;
250 PBMP_INFO_HEADER InfoHeader;
251 ULONG RowStride, HeaderSize;
253 ULONG RotatedWidth, RotatedHeight;
254 ULONGLONG ImageSize;
255 LONGLONG SignedHeight;
256 BOOLEAN UseFirmwarePlacement;
257
259
260 if ((FrameBufferData == NULL) ||
261 (FrameBufferData->BitsPerPixel != 32) ||
264 {
265 return;
266 }
267
269 if (BgrtTable == NULL)
270 {
271 TRACE("No BGRT table found\n");
272 return;
273 }
274
275 if (BgrtTable->Header.Length < sizeof(*BgrtTable))
276 {
277 WARN("BGRT table is too small (%lu)\n", BgrtTable->Header.Length);
278 return;
279 }
280
281 if ((BgrtTable->Status & BGRT_STATUS_IMAGE_VALID) == 0)
282 {
283 TRACE("BGRT image is not marked valid\n");
284 return;
285 }
286
287 if (BgrtTable->ImageType != BgrtImageTypeBitmap)
288 {
289 WARN("Unsupported BGRT image type %u\n", BgrtTable->ImageType);
290 return;
291 }
292
293 if ((BgrtTable->LogoAddress == 0) ||
294 (BgrtTable->LogoAddress != (ULONGLONG)(ULONG_PTR)BgrtTable->LogoAddress))
295 {
296 WARN("Unsupported BGRT logo address 0x%llx\n", BgrtTable->LogoAddress);
297 return;
298 }
299
300 FileHeader = (PBMP_FILE_HEADER)(ULONG_PTR)BgrtTable->LogoAddress;
301 if (FileHeader->Type != BMP_SIGNATURE)
302 {
303 WARN("BGRT logo does not contain a BMP signature\n");
304 return;
305 }
306
307 if (FileHeader->Size < sizeof(*FileHeader) + sizeof(*InfoHeader))
308 {
309 WARN("BGRT BMP is too small for a BITMAPINFOHEADER (%lu)\n",
310 FileHeader->Size);
311 return;
312 }
313
314 InfoHeader = (PBMP_INFO_HEADER)(FileHeader + 1);
315 if ((InfoHeader->Size < sizeof(*InfoHeader)) ||
316 (InfoHeader->Size > FileHeader->Size - sizeof(*FileHeader)))
317 {
318 WARN("Unsupported BMP info header size %lu\n", InfoHeader->Size);
319 return;
320 }
321
322 SignedHeight = (LONGLONG)InfoHeader->Height;
323 if ((InfoHeader->Width <= 0) || (SignedHeight == 0))
324 {
325 WARN("Unsupported BMP dimensions %ld x %ld\n",
326 InfoHeader->Width, InfoHeader->Height);
327 return;
328 }
329
330 if (InfoHeader->Planes != 1)
331 {
332 WARN("Unsupported BMP plane count %u\n", InfoHeader->Planes);
333 return;
334 }
335
336 if ((InfoHeader->BitCount != 24) && (InfoHeader->BitCount != 32))
337 {
338 WARN("Unsupported BMP bit depth %u\n", InfoHeader->BitCount);
339 return;
340 }
341
342 if (InfoHeader->Compression != BI_RGB)
343 {
344 WARN("Unsupported BMP compression %lu\n", InfoHeader->Compression);
345 return;
346 }
347
348 Width = (ULONG)InfoHeader->Width;
349 Height = (ULONG)ABS(SignedHeight);
350
351 if (!UefiCalculateBmpRowStride(Width, InfoHeader->BitCount, &RowStride))
352 {
353 WARN("BMP row stride overflows\n");
354 return;
355 }
356
357 if (InfoHeader->Size > MAXULONG - sizeof(*FileHeader))
358 {
359 WARN("BMP header size overflows\n");
360 return;
361 }
362
363 HeaderSize = sizeof(*FileHeader) + InfoHeader->Size;
364 ImageSize = (ULONGLONG)RowStride * Height;
365
366 if ((FileHeader->BitsOffset < HeaderSize) ||
367 (FileHeader->Size < FileHeader->BitsOffset) ||
368 (ImageSize > (ULONGLONG)FileHeader->Size - FileHeader->BitsOffset))
369 {
370 WARN("BGRT BMP image bounds are invalid\n");
371 return;
372 }
373
375 UefiBgrtLogo.TopDown = (SignedHeight < 0);
376 UefiBgrtLogo.PixelData = (PUCHAR)FileHeader + FileHeader->BitsOffset;
379 UefiBgrtLogo.RowStride = RowStride;
380 UefiBgrtLogo.BitsPerPixel = InfoHeader->BitCount;
382 (UCHAR)((BgrtTable->Status & BGRT_STATUS_ORIENTATION_MASK) >> 1);
383
384 UefiGetRotatedLogoSize(&UefiBgrtLogo, &RotatedWidth, &RotatedHeight);
385
386 UseFirmwarePlacement =
387 (RotatedWidth <= FrameBufferData->ScreenWidth) &&
388 (RotatedHeight <= FrameBufferData->ScreenHeight) &&
389 (BgrtTable->OffsetX <= FrameBufferData->ScreenWidth - RotatedWidth) &&
390 (BgrtTable->OffsetY <= FrameBufferData->ScreenHeight - RotatedHeight);
391
392 if (UseFirmwarePlacement)
393 {
396 BgrtTable->OffsetX,
400
401 UefiPreparePositionedLogoAxis(RotatedHeight,
403 BgrtTable->OffsetY,
407 }
408 else
409 {
410 UefiPrepareCenteredLogoAxis(RotatedWidth,
415
416 UefiPrepareCenteredLogoAxis(RotatedHeight,
421 }
422
423 TRACE("BGRT logo ready: %lux%lu rot=%u @ (%lu,%lu), crop (%lu,%lu) -> %lux%lu\n",
429}
unsigned char BOOLEAN
Definition: actypes.h:127
#define WARN(fmt,...)
Definition: precomp.h:61
#define ABS(x)
Definition: geom.h:69
if(dx< 0)
Definition: linetemp.h:194
static ULONG ScreenHeight
Definition: pcvideo.c:117
@ BgrtImageTypeBitmap
Definition: acpi.h:60
#define BGRT_STATUS_IMAGE_VALID
Definition: acpi.h:53
#define BGRT_SIGNATURE
Definition: acpi.h:43
struct _BGRT_TABLE * PBGRT_TABLE
#define TRACE(s)
Definition: solgame.cpp:4
ULONG OffsetX
Definition: acpi.h:264
UCHAR ImageType
Definition: acpi.h:262
DESCRIPTION_HEADER Header
Definition: acpi.h:259
ULONGLONG LogoAddress
Definition: acpi.h:263
UCHAR Status
Definition: acpi.h:261
ULONG OffsetY
Definition: acpi.h:265
ULONG BitsOffset
Definition: uefivid.c:63
USHORT Type
Definition: uefivid.c:59
USHORT Planes
Definition: uefivid.c:71
USHORT BitCount
Definition: uefivid.c:72
ULONG Compression
Definition: uefivid.c:73
USHORT BitsPerPixel
Definition: uefivid.c:34
ULONG Width
Definition: uefivid.c:31
UCHAR Orientation
Definition: uefivid.c:29
BOOLEAN TopDown
Definition: uefivid.c:28
ULONG Height
Definition: uefivid.c:32
PUCHAR PixelData
Definition: uefivid.c:30
ULONG RowStride
Definition: uefivid.c:33
unsigned char UCHAR
Definition: typedefs.h:53
int64_t LONGLONG
Definition: typedefs.h:68
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint32_t ULONG_PTR
Definition: typedefs.h:65
PDESCRIPTION_HEADER UefiFindAcpiTable(_In_ ULONG Signature)
Definition: uefihw.c:94
struct _BMP_INFO_HEADER * PBMP_INFO_HEADER
#define BI_RGB
Definition: uefivid.c:46
static VOID UefiPreparePositionedLogoAxis(_In_ ULONG BitmapSize, _In_ ULONG ScreenSize, _In_ ULONG RequestedOffset, _Out_ PULONG SourceOffset, _Out_ PULONG DestinationOffset, _Out_ PULONG DrawSize)
Definition: uefivid.c:155
struct _BMP_FILE_HEADER * PBMP_FILE_HEADER
#define BMP_SIGNATURE
Definition: uefivid.c:45
#define BGRT_STATUS_ORIENTATION_MASK
Definition: uefivid.c:48
static VOID UefiPrepareCenteredLogoAxis(_In_ ULONG BitmapSize, _In_ ULONG ScreenSize, _Out_ PULONG SourceOffset, _Out_ PULONG DestinationOffset, _Out_ PULONG DrawSize)
Definition: uefivid.c:133
static VOID UefiGetRotatedLogoSize(_In_ PUEFI_BGRT_LOGO Logo, _Out_ PULONG Width, _Out_ PULONG Height)
Definition: uefivid.c:177
BOOLEAN UefiCalculateBmpRowStride(_In_ ULONG Width, _In_ USHORT BitsPerPixel, _Out_ PULONG RowStride)
Definition: uefivid.c:115

Referenced by UefiInitializeAppleGraphics(), and UefiInitializeGop().

◆ UefiInitializeGop()

static EFI_STATUS UefiInitializeGop ( VOID  )
static

Definition at line 483 of file uefivid.c.

484{
487
489 EFI_PIXEL_BITMASK* pPixelBitmask;
490 ULONG BitsPerPixel;
491
493 if (Status != EFI_SUCCESS)
494 {
495 TRACE("Failed to find GOP with status %d\n", Status);
496 return Status;
497 }
498
499 /* We don't need high resolutions for freeldr */
500 gop->SetMode(gop, LOWEST_SUPPORTED_RES);
501
502 /* Physical format of the pixel */
503 PixelFormat = gop->Mode->Info->PixelFormat;
504 switch (PixelFormat)
505 {
508 {
509 pPixelBitmask = &EfiPixelMasks[PixelFormat];
511 break;
512 }
513
514 case PixelBitMask:
515 {
516 /*
517 * When the GOP pixel format is given by PixelBitMask, the pixel
518 * element size _may be_ different from 4 bytes.
519 * See UEFI Spec Rev.2.10 Section 12.9 "Graphics Output Protocol":
520 * example code "GetPixelElementSize()" function.
521 */
522 pPixelBitmask = &gop->Mode->Info->PixelInformation;
523 BitsPerPixel =
524 PixelBitmasksToBpp(pPixelBitmask->RedMask,
525 pPixelBitmask->GreenMask,
526 pPixelBitmask->BlueMask,
527 pPixelBitmask->ReservedMask);
528 break;
529 }
530
531 case PixelBltOnly:
532 default:
533 {
534 ERR("Unsupported UEFI GOP format %lu\n", PixelFormat);
535 pPixelBitmask = NULL;
536 BitsPerPixel = 0;
537 break;
538 }
539 }
540
541 VramAddress = (ULONG_PTR)gop->Mode->FrameBufferBase;
542 VramSize = gop->Mode->FrameBufferSize;
545 VramSize,
546 gop->Mode->Info->HorizontalResolution,
547 gop->Mode->Info->VerticalResolution,
548 gop->Mode->Info->PixelsPerScanLine,
549 BitsPerPixel,
550 (PPIXEL_BITMASK)pPixelBitmask))
551 {
552 ERR("Couldn't initialize video framebuffer\n");
554 }
555 else
556 {
558 }
559 return Status;
560}
EFI_GRAPHICS_PIXEL_FORMAT
@ PixelBitMask
@ PixelRedGreenBlueReserved8BitPerColor
@ PixelBltOnly
INT PixelFormat
#define RTL_BITS_OF(sizeOfArg)
Definition: ntbasedef.h:680
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:54
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 620 of file uefivid.c.

621{
623
624 /* First, try GOP */
626 if (Status == EFI_SUCCESS)
627 return Status;
628
629 /* Try Apple Graphics Info if that fails */
630 TRACE("Failed to detect GOP, trying Apple Graphics Info\n");
632 if (Status == EFI_SUCCESS)
633 return Status;
634
635 /* We didn't find GOP or Apple Graphics Info, probably a UGA-only system */
636 ERR("Cannot find framebuffer!\n");
637 return Status;
638}
static EFI_STATUS UefiInitializeAppleGraphics(VOID)
Definition: uefivid.c:564
static EFI_STATUS UefiInitializeGop(VOID)
Definition: uefivid.c:483

Referenced by MachInit().

◆ UefiPrepareCenteredLogoAxis()

static VOID UefiPrepareCenteredLogoAxis ( _In_ ULONG  BitmapSize,
_In_ ULONG  ScreenSize,
_Out_ PULONG  SourceOffset,
_Out_ PULONG  DestinationOffset,
_Out_ PULONG  DrawSize 
)
static

Definition at line 133 of file uefivid.c.

139{
140 if (BitmapSize >= ScreenSize)
141 {
142 *SourceOffset = (BitmapSize - ScreenSize) / 2;
144 *DrawSize = ScreenSize;
145 return;
146 }
147
148 *SourceOffset = 0;
149 *DrawSize = BitmapSize;
150 *DestinationOffset = (ScreenSize - BitmapSize) / 2;
151}
_Must_inspect_result_ _In_ WDFMEMORY _In_ size_t SourceOffset
Definition: wdfmemory.h:320
_Must_inspect_result_ _In_ WDFMEMORY _In_ size_t DestinationOffset
Definition: wdfmemory.h:361

Referenced by UefiInitializeBgrtLogo().

◆ UefiPreparePositionedLogoAxis()

static VOID UefiPreparePositionedLogoAxis ( _In_ ULONG  BitmapSize,
_In_ ULONG  ScreenSize,
_In_ ULONG  RequestedOffset,
_Out_ PULONG  SourceOffset,
_Out_ PULONG  DestinationOffset,
_Out_ PULONG  DrawSize 
)
static

Definition at line 155 of file uefivid.c.

162{
163 *SourceOffset = 0;
164 *DestinationOffset = RequestedOffset;
165
166 if (RequestedOffset >= ScreenSize)
167 {
168 *DrawSize = 0;
169 return;
170 }
171
172 *DrawSize = min(BitmapSize, ScreenSize - RequestedOffset);
173}
#define min(a, b)
Definition: monoChain.cc:55

Referenced by UefiInitializeBgrtLogo().

◆ UefiVideoClearScreen()

VOID UefiVideoClearScreen ( UCHAR  Attr)

Definition at line 642 of file uefivid.c.

643{
644 FbConsClearScreen(Attr);
645}
VOID FbConsClearScreen(_In_ UCHAR Attr)
Definition: vidfb.c:413

Referenced by MachInit().

◆ UefiVideoCopyOffScreenBufferToVRAM()

VOID UefiVideoCopyOffScreenBufferToVRAM ( PVOID  Buffer)

Definition at line 673 of file uefivid.c.

674{
677}
Definition: bufpool.h:45
static VOID UefiDrawBgrtLogo(VOID)
Definition: uefivid.c:433
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 667 of file uefivid.c.

668{
669 return FbConsGetBufferSize();
670}
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 654 of file uefivid.c.

655{
657}
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 705 of file uefivid.c.

707{
708 /* Not supported */
709}

Referenced by MachInit().

◆ UefiVideoHideShowTextCursor()

VOID UefiVideoHideShowTextCursor ( BOOLEAN  Show)

Definition at line 686 of file uefivid.c.

687{
688 /* We don't have a cursor yet */
689}

Referenced by MachInit().

◆ UefiVideoIsPaletteFixed()

BOOLEAN UefiVideoIsPaletteFixed ( VOID  )

Definition at line 692 of file uefivid.c.

693{
694 return 0;
695}

Referenced by MachInit().

◆ UefiVideoPutChar()

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

Definition at line 648 of file uefivid.c.

649{
650 FbConsPutChar(Ch, Attr, X, Y);
651}
#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 660 of file uefivid.c.

661{
662 /* We only have one mode, semi-text */
663 return VideoTextMode;
664}
@ VideoTextMode
Definition: machine.h:35

Referenced by MachInit().

◆ UefiVideoSetPaletteColor()

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

Definition at line 698 of file uefivid.c.

700{
701 /* Not supported */
702}

Referenced by MachInit().

◆ UefiVideoSetTextCursorPosition()

VOID UefiVideoSetTextCursorPosition ( UCHAR  X,
UCHAR  Y 
)

Definition at line 680 of file uefivid.c.

681{
682 /* We don't have a cursor yet */
683}

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

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

◆ UefiBgrtLogo

UEFI_BGRT_LOGO UefiBgrtLogo = {0}
static

Definition at line 43 of file uefivid.c.

Referenced by UefiDrawBgrtLogo(), and UefiInitializeBgrtLogo().

◆ VramAddress

◆ VramSize