OpenCore  1.0.4
OpenCore Bootloader
Loading...
Searching...
No Matches
EnableGop.c
Go to the documentation of this file.
1
8#include <Uefi.h>
9
10#include <Library/DxeServicesTableLib.h>
11#include <Library/UefiBootServicesTableLib.h>
12#include <Library/UefiRuntimeServicesTableLib.h>
13
17
18STATIC EFI_GET_MEMORY_SPACE_MAP mOriginalGetMemorySpaceMap;
19
20//
21// Close to a very cut down OcLoadUefiOutputSupport.
22//
23STATIC
24EFI_STATUS
26 VOID
27 )
28{
29 EFI_STATUS Status;
30
31 Status = OcProvideConsoleGop (FALSE);
32 if (EFI_ERROR (Status)) {
33 //
34 // If we've already got console GOP assume it's set up correctly, however enable
35 // GopBurstMode as it can still provide a noticeable speed up (e.g. MP5,1 GT120).
36 //
37 if (Status == EFI_ALREADY_STARTED) {
39 }
40
41 return Status;
42 }
43
45 0,
46 0,
47 0,
48 FALSE
49 );
50
52
53 if (FeaturePcdGet (PcdEnableGopDirect)) {
54 OcUseDirectGop (-1);
55 }
56
60 NULL,
61 NULL,
62 FALSE,
63 FALSE,
64 FALSE,
65 FALSE,
66 0,
67 0
68 );
69
70 return EFI_SUCCESS;
71}
72
73STATIC
74EFI_STATUS
76 VOID
77 )
78{
80
81 return LoadUefiOutputSupport ();
82}
83
84//
85// This memory map access happens twice during PlatformBdsPolicyBehavior, once
86// in the equivalent of efi InitializeMemoryTest at the start of the function,
87// and once during PlatformBdsDiagnostics, slightly later. The second call(s)
88// (there is more than one code path, depending on the boot type) are after
89// the default console has been connected, and therefore ideal for us.
90//
91EFI_STATUS
92EFIAPI
94 OUT UINTN *NumberOfDescriptors,
95 OUT EFI_GCD_MEMORY_SPACE_DESCRIPTOR **MemorySpaceMap
96 )
97{
98 STATIC UINTN mGetMemorySpaceMapAccessCount = 0;
99
100 mGetMemorySpaceMapAccessCount++;
101
102 if (mGetMemorySpaceMapAccessCount == 2) {
103 ProvideGop ();
104 }
105
107 NumberOfDescriptors,
108 MemorySpaceMap
109 );
110}
111
112STATIC
113VOID
115 VOID
116 )
117{
118 mOriginalGetMemorySpaceMap = gDS->GetMemorySpaceMap;
119 gDS->GetMemorySpaceMap = WrappedGetMemorySpaceMap;
120
121 gDS->Hdr.CRC32 = 0;
122 gBS->CalculateCrc32 (gDS, gDS->Hdr.HeaderSize, &gDS->Hdr.CRC32);
123}
124
125//
126// If we execute the entire console setup at Driver#### time then we have to forge UEFI, reload option ROMs
127// and connect them, all at that point.
128// This works on some systems but causes crashes others, or causes an empty picker with question mark folder.
129// Current strategy is:
130// - Forge UEFI early; relatively easy: just do it immediately, as below, and insert this driver either
131// a) anywhere in main firmware volume, or b) in VBIOS anywhere before GOP driver which needs it
132// - Execute rest of payload after option roms have been loaded, _and_ after firmware has already connected
133// them (see WrapGetMemorySpaceMap strategy above).
134// With this strategy we do not need to reload or reconnect any option ROMs, which is much more stable.
135//
136EFI_STATUS
137EFIAPI
139 IN EFI_HANDLE ImageHandle,
140 IN EFI_SYSTEM_TABLE *SystemTable
141 )
142{
143 OcForgeUefiSupport (TRUE, TRUE);
145
146 return EFI_SUCCESS;
147}
@ EfiConsoleControlScreenGraphics
STATIC VOID WrapGetMemorySpaceMap(VOID)
Definition EnableGop.c:114
EFI_STATUS EFIAPI UefiMain(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
Definition EnableGop.c:138
STATIC EFI_GET_MEMORY_SPACE_MAP mOriginalGetMemorySpaceMap
Definition EnableGop.c:18
EFI_STATUS EFIAPI WrappedGetMemorySpaceMap(OUT UINTN *NumberOfDescriptors, OUT EFI_GCD_MEMORY_SPACE_DESCRIPTOR **MemorySpaceMap)
Definition EnableGop.c:93
STATIC EFI_STATUS ProvideGop(VOID)
Definition EnableGop.c:75
STATIC EFI_STATUS LoadUefiOutputSupport(VOID)
Definition EnableGop.c:25
EFI_STATUS OcUnlockAppleFirmwareUI(VOID)
EFI_BOOT_SERVICES * gBS
EFI_STATUS OcSetGopBurstMode(VOID)
Definition GopUtils.c:308
EFI_STATUS OcSetConsoleResolution(IN UINT32 Width OPTIONAL, IN UINT32 Height OPTIONAL, IN UINT32 Bpp OPTIONAL, IN BOOLEAN Force)
EFI_STATUS OcUseDirectGop(IN INT32 CacheType)
Definition ConsoleGop.c:536
VOID OcSetupConsole(IN EFI_CONSOLE_CONTROL_SCREEN_MODE InitialMode, IN OC_CONSOLE_RENDERER Renderer, IN OC_STORAGE_CONTEXT *Storage OPTIONAL, IN CONST CHAR8 *Font OPTIONAL, IN BOOLEAN IgnoreTextOutput, IN BOOLEAN SanitiseClearScreen, IN BOOLEAN ClearScreenOnModeSwitch, IN BOOLEAN ReplaceTabWithSpace, IN UINT32 Width, IN UINT32 Height)
@ OcConsoleRendererBuiltinGraphics
EFI_STATUS OcProvideConsoleGop(IN BOOLEAN Route)
Definition ConsoleGop.c:81
EFI_STATUS OcForgeUefiSupport(IN BOOLEAN Forge, IN BOOLEAN Trash)
Definition ForgeUefi.c:81