OpenCore  1.0.4
OpenCore Bootloader
Loading...
Searching...
No Matches
OutputStGop.c
Go to the documentation of this file.
1
8#include <Uefi.h>
9
10#include <Protocol/GraphicsOutput.h>
11
12#include <Library/DebugLib.h>
13#include <Library/MemoryAllocationLib.h>
14#include <Library/UefiBootServicesTableLib.h>
15
16#include "../GuiIo.h"
17
18#define MIN_RESOLUTION_HORIZONTAL 640U
19#define MIN_RESOLUTION_VERTICAL 480U
20
22 EFI_GRAPHICS_OUTPUT_PROTOCOL *Gop;
23};
24
25STATIC
26EFI_GRAPHICS_OUTPUT_PROTOCOL *
28 VOID
29 )
30{
31 EFI_STATUS Status;
32 EFI_GRAPHICS_OUTPUT_PROTOCOL *Gop;
33
34 Status = gBS->HandleProtocol (
35 gST->ConsoleOutHandle,
37 (VOID **)&Gop
38 );
39 if (EFI_ERROR (Status)) {
40 //
41 // Do not fall back to other GOP instances to match AppleEvent.
42 //
43 return NULL;
44 }
45
46 return Gop;
47}
48
51 IN UINT32 Scale
52 )
53{
54 // TODO: alloc on the fly?
55 STATIC GUI_OUTPUT_CONTEXT Context;
56
57 EFI_GRAPHICS_OUTPUT_PROTOCOL *Gop;
58
60 if (Gop == NULL) {
61 return NULL;
62 }
63
64 if ( (Gop->Mode->Info->HorizontalResolution < MIN_RESOLUTION_HORIZONTAL * Scale)
65 || (Gop->Mode->Info->VerticalResolution < MIN_RESOLUTION_VERTICAL * Scale))
66 {
67 DEBUG ((
68 DEBUG_WARN,
69 "OCUI: Expected at least %dx%d for resolution, actual %dx%d\n",
72 Gop->Mode->Info->HorizontalResolution,
73 Gop->Mode->Info->VerticalResolution
74 ));
75 return NULL;
76 }
77
78 Context.Gop = Gop;
79 return &Context;
80}
81
82EFI_STATUS
83EFIAPI
85 IN GUI_OUTPUT_CONTEXT *Context,
86 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer OPTIONAL,
87 IN EFI_GRAPHICS_OUTPUT_BLT_OPERATION BltOperation,
88 IN UINTN SourceX,
89 IN UINTN SourceY,
90 IN UINTN DestinationX,
91 IN UINTN DestinationY,
92 IN UINTN Width,
93 IN UINTN Height,
94 IN UINTN Delta OPTIONAL
95 )
96{
97 return Context->Gop->Blt (
98 Context->Gop,
99 BltBuffer,
100 BltOperation,
101 SourceX,
102 SourceY,
103 DestinationX,
104 DestinationY,
105 Width,
106 Height,
107 Delta
108 );
109}
110
111CONST EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *
113 IN GUI_OUTPUT_CONTEXT *Context
114 )
115{
116 return Context->Gop->Mode->Info;
117}
118
119VOID
121 IN GUI_OUTPUT_CONTEXT *Context
122 )
123{
124 ASSERT (Context != NULL);
125 ZeroMem (Context, sizeof (*Context));
126}
EFI_SYSTEM_TABLE * gST
EFI_BOOT_SERVICES * gBS
VOID GuiOutputDestruct(IN GUI_OUTPUT_CONTEXT *Context)
#define MIN_RESOLUTION_HORIZONTAL
Definition OutputStGop.c:18
#define MIN_RESOLUTION_VERTICAL
Definition OutputStGop.c:19
CONST EFI_GRAPHICS_OUTPUT_MODE_INFORMATION * GuiOutputGetInfo(IN GUI_OUTPUT_CONTEXT *Context)
STATIC EFI_GRAPHICS_OUTPUT_PROTOCOL * InternalGuiOutputLocateGop(VOID)
Definition OutputStGop.c:27
GUI_OUTPUT_CONTEXT * GuiOutputConstruct(IN UINT32 Scale)
Definition OutputStGop.c:50
EFI_STATUS EFIAPI GuiOutputBlt(IN GUI_OUTPUT_CONTEXT *Context, IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer OPTIONAL, IN EFI_GRAPHICS_OUTPUT_BLT_OPERATION BltOperation, IN UINTN SourceX, IN UINTN SourceY, IN UINTN DestinationX, IN UINTN DestinationY, IN UINTN Width, IN UINTN Height, IN UINTN Delta OPTIONAL)
Definition OutputStGop.c:84
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
EFI_GUID gEfiGraphicsOutputProtocolGuid
#define ASSERT(x)
Definition coder.h:55
EFI_GRAPHICS_OUTPUT_PROTOCOL * Gop
Definition OutputStGop.c:22