John Davis cde37269aa
VBIOS patching via ForceResolution option (#144)
* BiosVideo: Initial Intel patching functions

* BiosVideo: Implement patch protocol

* BiosVideo: Read EDID from VBE

* BiosVideo: Fix previous commits

* OpenDuet: Fix Windows builds

* BiosVideo: Fix MSVC warnings

* BiosVideo: Pull max resolution from EDID

* BiosVideo: Patch based on PCI vendor ID

* BiosVideo: Fix more MSVC warnings

* OcMiscLib: Try to fix OpenDuet MSVC compilation

* BiosVideo: Fix incorrect return status

* OpenDuet: Create OcDebugLogLibNull library

* Protocol: Rename OC_VBIOS_PATCH_PROTOCOL to OC_FORCE_RESOLUTION_PROTOCOL

* OpenCore: Add ForceResolution option

* BiosVideo: Fix consistency of height/width parameters

* Includes: Mark height/width as optional

* BiosVideo: Cleanup misc issues

* Docs: Add support note
2020-10-26 19:18:06 -05:00

113 lines
2.7 KiB
C

/** @file
Run Apple Boot Picker.
Copyright (c) 2020, vit9696. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include <PiDxe.h>
#include <Guid/AppleFile.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/OcBootManagementLib.h>
#include <Library/OcConsoleLib.h>
#include <Library/OcMiscLib.h>
#include <Library/OcFileLib.h>
#include <Library/UefiApplicationEntryPoint.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiLib.h>
#include <Protocol/DevicePath.h>
#include <Protocol/GraphicsOutput.h>
EFI_STATUS
EFIAPI
UefiMain (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
EFI_GRAPHICS_OUTPUT_PROTOCOL *Gop;
EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION Pixel;
UINTN Index;
gBS->SetWatchdogTimer (0, 0, 0, NULL);
OcProvideConsoleGop (FALSE);
OcSetConsoleResolution (0, 0, 0, FALSE);
Status = gBS->HandleProtocol (
gST->ConsoleOutHandle,
&gEfiGraphicsOutputProtocolGuid,
(VOID **) &Gop
);
if (EFI_ERROR (Status)) {
//
// Note: Ensure that stall value is within UINT32 in nanoseconds.
//
for (Index = 0; Index < 10; ++Index) {
gBS->Stall (SECONDS_TO_MICROSECONDS (1));
}
return Status;
}
Status = OcRunAppleBootPicker ();
Pixel.Raw = 0x0;
if (Status == EFI_NOT_FOUND) {
//
// Red. No BootPicker in firmware or we cannot get it.
//
Pixel.Pixel.Red = 0xFF;
} else if (Status == EFI_UNSUPPORTED) {
//
// Yellow. BootPicker does not start.
//
Pixel.Pixel.Red = 0xFF;
Pixel.Pixel.Green = 0xFF;
} else if (EFI_ERROR (Status) /* Status == EFI_INVALID_PARAMETER */) {
//
// Fuchsia. BootPicker does not load.
//
Pixel.Pixel.Blue = 0xFF;
Pixel.Pixel.Red = 0xFF;
} else {
//
// Green. BootPicker started but returned.
//
Pixel.Pixel.Green = 0xFF;
}
Gop->Blt (
Gop,
&Pixel.Pixel,
EfiBltVideoFill,
0,
0,
0,
0,
Gop->Mode->Info->HorizontalResolution,
Gop->Mode->Info->VerticalResolution,
0
);
//
// Note: Ensure that stall value is within UINT32 in nanoseconds.
//
for (Index = 0; Index < 10; ++Index) {
gBS->Stall (SECONDS_TO_MICROSECONDS (1));
}
return EFI_SUCCESS;
}