17#include <Library/DebugLib.h> 
   18#include <Library/MemoryAllocationLib.h> 
   19#include <Library/UefiBootServicesTableLib.h> 
   27  IN  EFI_UGA_DRAW_PROTOCOL  *This,
 
   28  OUT UINT32                 *HorizontalResolution,
 
   29  OUT UINT32                 *VerticalResolution,
 
   30  OUT UINT32                 *ColorDepth,
 
   31  OUT UINT32                 *RefreshRate
 
   35  EFI_GRAPHICS_OUTPUT_MODE_INFORMATION  *Info;
 
   37  DEBUG ((DEBUG_INFO, 
"OCC: OcUgaDrawGetMode %p\n", This));
 
   40     || (HorizontalResolution == NULL)
 
   41     || (VerticalResolution == NULL)
 
   42     || (ColorDepth == NULL)
 
   43     || (RefreshRate == NULL))
 
   45    return EFI_INVALID_PARAMETER;
 
   53    "OCC: OcUgaDrawGetMode Info is %ux%u (%u)\n",
 
   54    Info->HorizontalResolution,
 
   55    Info->VerticalResolution,
 
   59  if ((Info->HorizontalResolution == 0) || (Info->VerticalResolution == 0)) {
 
   60    return EFI_NOT_STARTED;
 
   63  *HorizontalResolution = Info->HorizontalResolution;
 
   64  *VerticalResolution   = Info->VerticalResolution;
 
 
   75  IN  EFI_UGA_DRAW_PROTOCOL  *This,
 
   76  IN  UINT32                 HorizontalResolution,
 
   77  IN  UINT32                 VerticalResolution,
 
   87    "OCC: OcUgaDrawSetMode %p %ux%u@%u/%u\n",
 
  104  DEBUG ((DEBUG_INFO, 
"OCC: UGA SetConsoleResolutionOnHandle attempt - %r\n", Status));
 
  106  if (EFI_ERROR (Status)) {
 
  113    DEBUG ((DEBUG_INFO, 
"OCC: UGA SetConsoleResolutionOnHandle max attempt - %r\n", Status));
 
 
  123  IN  EFI_UGA_DRAW_PROTOCOL  *This,
 
  124  IN  EFI_UGA_PIXEL          *BltBuffer OPTIONAL,
 
  125  IN  EFI_UGA_BLT_OPERATION  BltOperation,
 
  128  IN  UINTN                  DestinationX,
 
  129  IN  UINTN                  DestinationY,
 
  132  IN  UINTN                  Delta      OPTIONAL
 
  141                                      (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *)BltBuffer,
 
  142                                      (EFI_GRAPHICS_OUTPUT_BLT_OPERATION)BltOperation,
 
 
  160  EFI_HANDLE                    *HandleBuffer;
 
  162  EFI_GRAPHICS_OUTPUT_PROTOCOL  *GraphicsOutput;
 
  163  EFI_UGA_DRAW_PROTOCOL         *UgaDraw;
 
  178  Status = 
gBS->LocateHandleBuffer (
 
  185  if (EFI_ERROR (Status)) {
 
  186    DEBUG ((DEBUG_INFO, 
"OCC: Failed to find handles with GOP - %r\n", Status));
 
  190  DEBUG ((DEBUG_INFO, 
"OCC: Found %u handles with GOP for UGA check\n", (UINT32)HandleCount));
 
  191  for (Index = 0; Index < HandleCount; ++Index) {
 
  192    DEBUG ((DEBUG_INFO, 
"OCC: Trying handle %u - %p\n", (UINT32)Index, HandleBuffer[Index]));
 
  194    Status = 
gBS->HandleProtocol (
 
  197                    (VOID **)&GraphicsOutput
 
  199    if (EFI_ERROR (Status)) {
 
  200      DEBUG ((DEBUG_INFO, 
"OCC: No GOP protocol - %r\n", Status));
 
  204    Status = 
gBS->HandleProtocol (
 
  209    if (!EFI_ERROR (Status)) {
 
  210      DEBUG ((DEBUG_INFO, 
"OCC: Skipping UGA proxying as it is already present on handle %u - %p\n", (UINT32)Index, HandleBuffer[Index]));
 
  214    OcUgaDraw = AllocateZeroPool (
sizeof (*OcUgaDraw));
 
  215    if (OcUgaDraw == NULL) {
 
  216      DEBUG ((DEBUG_INFO, 
"OCC: Failed to allocate UGA protocol\n"));
 
  225    Status = 
gBS->InstallMultipleProtocolInterfaces (
 
  226                    &HandleBuffer[Index],
 
  231    if (EFI_ERROR (Status)) {
 
  232      FreePool (OcUgaDraw);
 
  237      "OCC: Installed UGA protocol - %r (Handle %u - %p)\n",
 
  244  FreePool (HandleBuffer);
 
 
EFI_STATUS OcSetConsoleResolutionForProtocol(IN EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput, IN UINT32 Width OPTIONAL, IN UINT32 Height OPTIONAL, IN UINT32 Bpp OPTIONAL)
#define DEFAULT_REFRESH_RATE
#define DEFAULT_COLOUR_DEPTH
UINTN OcCountProtocolInstances(IN EFI_GUID *Protocol)
STATIC EFI_STATUS EFIAPI OcUgaDrawBlt(IN EFI_UGA_DRAW_PROTOCOL *This, IN EFI_UGA_PIXEL *BltBuffer OPTIONAL, IN EFI_UGA_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)
STATIC EFI_STATUS EFIAPI OcUgaDrawGetMode(IN EFI_UGA_DRAW_PROTOCOL *This, OUT UINT32 *HorizontalResolution, OUT UINT32 *VerticalResolution, OUT UINT32 *ColorDepth, OUT UINT32 *RefreshRate)
STATIC EFI_STATUS EFIAPI OcUgaDrawSetMode(IN EFI_UGA_DRAW_PROTOCOL *This, IN UINT32 HorizontalResolution, IN UINT32 VerticalResolution, IN UINT32 ColorDepth, IN UINT32 RefreshRate)
EFI_STATUS OcProvideUgaPassThrough(VOID)
EFI_GUID gEfiUgaDrawProtocolGuid
EFI_GUID gEfiGraphicsOutputProtocolGuid
EFI_GRAPHICS_OUTPUT_PROTOCOL * GraphicsOutput
EFI_UGA_DRAW_PROTOCOL Uga