From nobody Tue Feb 10 01:31:08 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+111080+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+111080+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699660758; cv=none; d=zohomail.com; s=zohoarc; b=LYFyMFXmHPiPVsu0E926SRe/joXmh8XYXxbvSuSnS8MVsgu+CMvOg64jKdGeRCXmo4lp8+ZemyPHzMRYEIrfTYnDfqSNR2LoVdTn3chjQd+Mfw/mgliVn7w04xE6OrZdozabr0qCCU+M3wb8ivJtymFIrtTce36SaWJljA5zWOQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699660758; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=Qdd1BHErJ9rUOyBPvhTp3cm1uilA2pcoEfv46JDwQy8=; b=TvxstexwAP/6i7r9DObrpc7ciNWiZTD9fTD1yH/uUSLJhFmYBHr/eqWrfG7sRZzmq9rdhP+BiGVO/AWQnXf/rs1pXu9xc3k7+0gS55EIC0drcMuPcv0UAKmVMjhEoVMwW3sv0YrnqvmO/OlV/A0Ol9PLaylnozUT+mrgI+wzAuc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+111080+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1699660758633483.5188955789715; Fri, 10 Nov 2023 15:59:18 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=Qdd1BHErJ9rUOyBPvhTp3cm1uilA2pcoEfv46JDwQy8=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding:Content-Type; s=20140610; t=1699660758; v=1; b=rwHvbPEW3M+qyxtWbuLJ8ug0HZ4w9NpHHrhZJXE0W+wQvC8U7oKyKQtKYWXk3y01UTzjh572 0oUV0TT1yfI6gj7YOs3mTQ51A+YcF1jbQdf3MD0XZcDxPwsnwXWQB3uVqaaJuPt8DTDblVPu+3u GqgwouMZ1DCJwaXR5hjYUtjo= X-Received: by 127.0.0.2 with SMTP id QcLhYY1788612xvjeno8lJQS; Fri, 10 Nov 2023 15:59:18 -0800 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.groups.io with SMTP id smtpd.web11.42825.1699660756967789959 for ; Fri, 10 Nov 2023 15:59:17 -0800 X-Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-695-HNFFaV-3OYG_GBDueFLBYw-1; Fri, 10 Nov 2023 18:59:13 -0500 X-MC-Unique: HNFFaV-3OYG_GBDueFLBYw-1 X-Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4E7B43C0C485; Fri, 10 Nov 2023 23:59:13 +0000 (UTC) X-Received: from lacos-laptop-9.usersys.redhat.com (unknown [10.39.192.173]) by smtp.corp.redhat.com (Postfix) with ESMTP id 32FD9C1596F; Fri, 10 Nov 2023 23:59:12 +0000 (UTC) From: "Laszlo Ersek" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Gerd Hoffmann , Jiewen Yao Subject: [edk2-devel] [PATCH 09/37] OvmfPkg: remove Csm/BiosThunk/VideoDxe Date: Sat, 11 Nov 2023 00:57:52 +0100 Message-Id: <20231110235820.644381-10-lersek@redhat.com> In-Reply-To: <20231110235820.644381-1-lersek@redhat.com> References: <20231110235820.644381-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,lersek@redhat.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: oe5aS4TJHIgzwzwlAyJOaj8Ux1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1699660759933100029 Content-Type: text/plain; charset="utf-8"; x-default="true" Csm/BiosThunk/VideoDxe is not used by any platform at this point, remove it. This patch removes mentions of the following CSM resources from the source code: - GUIDs (protocols or otherwise): - gEfiLegacyBiosGuid - gEfiLegacyBiosProtocolGuid - gEfiVgaMiniPortProtocolGuid - headers: - FrameworkDxe.h - Guid/LegacyBios.h - Protocol/LegacyBios.h - Protocol/VgaMiniPort.h - PCDs: - PcdBiosVideoCheckVbeEnable - PcdBiosVideoCheckVgaEnable - PcdBiosVideoSetTextVgaModeEnable which extends the list of resources scheduled for removal to: - GUIDs (protocols or otherwise): - gEfiLegacyBiosGuid - gEfiLegacyBiosProtocolGuid - gEfiVgaMiniPortProtocolGuid - headers: - FrameworkDxe.h - Guid/LegacyBios.h - Protocol/LegacyBios.h - Protocol/VgaMiniPort.h - PCDs: - PcdBiosVideoCheckVbeEnable - PcdBiosVideoCheckVgaEnable - PcdBiosVideoSetTextVgaModeEnable Cc: Ard Biesheuvel Cc: Gerd Hoffmann Cc: Jiewen Yao Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4588 Signed-off-by: Laszlo Ersek --- OvmfPkg/Csm/BiosThunk/VideoDxe/BiosVideoDxe.uni | 17 - OvmfPkg/Csm/BiosThunk/VideoDxe/BiosVideoDxeExtra.uni | 14 - OvmfPkg/Csm/BiosThunk/VideoDxe/VideoDxe.inf | 78 - OvmfPkg/Csm/BiosThunk/VideoDxe/BiosVideo.h | 524 --- OvmfPkg/Csm/BiosThunk/VideoDxe/VesaBiosExtensions.h | 459 --- OvmfPkg/Csm/BiosThunk/VideoDxe/BiosVideo.c | 3357 --------------= ------ OvmfPkg/Csm/BiosThunk/VideoDxe/ComponentName.c | 304 -- 7 files changed, 4753 deletions(-) diff --git a/OvmfPkg/Csm/BiosThunk/VideoDxe/BiosVideoDxe.uni b/OvmfPkg/Csm/= BiosThunk/VideoDxe/BiosVideoDxe.uni deleted file mode 100644 index 326d9de8220f..000000000000 --- a/OvmfPkg/Csm/BiosThunk/VideoDxe/BiosVideoDxe.uni +++ /dev/null @@ -1,17 +0,0 @@ -// /** @file -// Video driver based on legacy bios. -// -// This driver by using Legacy Bios protocol service to support csm Video -// and produce Graphics Output Protocol. -// -// Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
-// -// SPDX-License-Identifier: BSD-2-Clause-Patent -// -// **/ - - -#string STR_MODULE_ABSTRACT #language en-US "Video driver base= d on legacy bios" - -#string STR_MODULE_DESCRIPTION #language en-US "This driver uses = the Legacy Bios protocol service to utilize the CSM Video Support and produ= ce the Graphics Output Protocol." - diff --git a/OvmfPkg/Csm/BiosThunk/VideoDxe/BiosVideoDxeExtra.uni b/OvmfPkg= /Csm/BiosThunk/VideoDxe/BiosVideoDxeExtra.uni deleted file mode 100644 index 23fb8fe0b0ba..000000000000 --- a/OvmfPkg/Csm/BiosThunk/VideoDxe/BiosVideoDxeExtra.uni +++ /dev/null @@ -1,14 +0,0 @@ -// /** @file -// BiosVideoDxe Localized Strings and Content -// -// Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.
-// -// SPDX-License-Identifier: BSD-2-Clause-Patent -// -// **/ - -#string STR_PROPERTIES_MODULE_NAME -#language en-US -"Legacy Video DXE Driver" - - diff --git a/OvmfPkg/Csm/BiosThunk/VideoDxe/VideoDxe.inf b/OvmfPkg/Csm/Bios= Thunk/VideoDxe/VideoDxe.inf deleted file mode 100644 index 1ed4020661fa..000000000000 --- a/OvmfPkg/Csm/BiosThunk/VideoDxe/VideoDxe.inf +++ /dev/null @@ -1,78 +0,0 @@ -## @file -# Video driver based on legacy bios. -# -# This driver by using Legacy Bios protocol service to support csm Video -# and produce Graphics Output Protocol. -# -# Copyright (c) 2007 - 2019, Intel Corporation. All rights reserved.
-# -# SPDX-License-Identifier: BSD-2-Clause-Patent -# -## - -[Defines] - INF_VERSION =3D 0x00010005 - BASE_NAME =3D BiosVideoDxe - MODULE_UNI_FILE =3D BiosVideoDxe.uni - FILE_GUID =3D 8669E6C9-842B-4B49-BCC3-32C96D244750 - MODULE_TYPE =3D UEFI_DRIVER - VERSION_STRING =3D 1.0 - - ENTRY_POINT =3D BiosVideoEntryPoint - -# -# The following information is for reference only and not required by the = build tools. -# -# VALID_ARCHITECTURES =3D IA32 X64 EBC -# -# DRIVER_BINDING =3D gBiosVideoDriverBinding -# COMPONENT_NAME =3D gBiosVideoComponentName -# - -[Sources] - BiosVideo.c - BiosVideo.h - ComponentName.c - VesaBiosExtensions.h - -[Packages] - MdePkg/MdePkg.dec - MdeModulePkg/MdeModulePkg.dec - OvmfPkg/OvmfPkg.dec - -[LibraryClasses] - MemoryAllocationLib - DevicePathLib - UefiLib - UefiBootServicesTableLib - UefiDriverEntryPoint - BaseMemoryLib - ReportStatusCodeLib - DebugLib - PcdLib - - -[Guids] - gEfiLegacyBiosGuid ## PRODUCES ##GUID # Inst= all Legacy BIOS GUID to mark this driver as a BIOS Thunk Driver - gEfiEventExitBootServicesGuid ## CONSUMES ##Event - -[Protocols] - gEfiVgaMiniPortProtocolGuid ## BY_START - gEfiEdidDiscoveredProtocolGuid ## BY_START - gEfiGraphicsOutputProtocolGuid ## BY_START - gEfiEdidActiveProtocolGuid ## BY_START - gEfiLegacyBiosProtocolGuid ## CONSUMES - gEfiPciIoProtocolGuid ## TO_START - gEfiDevicePathProtocolGuid ## TO_START - gEfiDevicePathProtocolGuid ## BY_START - gEfiEdidOverrideProtocolGuid ## SOMETIMES_CONSUMES - -[Pcd] - gUefiOvmfPkgTokenSpaceGuid.PcdBiosVideoSetTextVgaModeEnable = ## CONSUMES - gUefiOvmfPkgTokenSpaceGuid.PcdBiosVideoCheckVbeEnable = ## CONSUMES - gUefiOvmfPkgTokenSpaceGuid.PcdBiosVideoCheckVgaEnable = ## SOMETIMES_CONSUMES - gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution = ## SOMETIMES_CONSUMES - gEfiMdeModulePkgTokenSpaceGuid.PcdVideoVerticalResolution = ## SOMETIMES_CONSUMES - -[UserExtensions.TianoCore."ExtraFiles"] - BiosVideoDxeExtra.uni diff --git a/OvmfPkg/Csm/BiosThunk/VideoDxe/BiosVideo.h b/OvmfPkg/Csm/BiosT= hunk/VideoDxe/BiosVideo.h deleted file mode 100644 index a2cb624d5a9a..000000000000 --- a/OvmfPkg/Csm/BiosThunk/VideoDxe/BiosVideo.h +++ /dev/null @@ -1,524 +0,0 @@ -/** @file - -Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.
- -SPDX-License-Identifier: BSD-2-Clause-Patent - -**/ - -#ifndef _BIOS_GRAPHICS_OUTPUT_H_ -#define _BIOS_GRAPHICS_OUTPUT_H_ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include "VesaBiosExtensions.h" - -// -// Packed format support: The number of bits reserved for each of the colo= rs and the actual -// position of RGB in the frame buffer is specified in the VBE Mode inform= ation -// -typedef struct { - UINT8 Position; // Position of the color - UINT8 Mask; // The number of bits expressed as a mask -} BIOS_VIDEO_COLOR_PLACEMENT; - -// -// BIOS Graphics Output Graphical Mode Data -// -typedef struct { - UINT16 VbeModeNumber; - UINT16 BytesPerScanLine; - VOID *LinearFrameBuffer; - UINTN FrameBufferSize; - UINT32 HorizontalResolution; - UINT32 VerticalResolution; - UINT32 ColorDepth; - UINT32 RefreshRate; - UINT32 BitsPerPixel; - BIOS_VIDEO_COLOR_PLACEMENT Red; - BIOS_VIDEO_COLOR_PLACEMENT Green; - BIOS_VIDEO_COLOR_PLACEMENT Blue; - BIOS_VIDEO_COLOR_PLACEMENT Reserved; - EFI_GRAPHICS_PIXEL_FORMAT PixelFormat; - EFI_PIXEL_BITMASK PixelBitMask; -} BIOS_VIDEO_MODE_DATA; - -// -// BIOS video child handle private data Structure -// -#define BIOS_VIDEO_DEV_SIGNATURE SIGNATURE_32 ('B', 'V', 'M', 'p') - -typedef struct { - UINTN Signature; - EFI_HANDLE Handle; - - // - // Consumed Protocols - // - EFI_PCI_IO_PROTOCOL *PciIo; - EFI_LEGACY_BIOS_PROTOCOL *LegacyBios; - - // - // Produced Protocols - // - EFI_GRAPHICS_OUTPUT_PROTOCOL GraphicsOutput; - EFI_EDID_DISCOVERED_PROTOCOL EdidDiscovered; - EFI_EDID_ACTIVE_PROTOCOL EdidActive; - EFI_VGA_MINI_PORT_PROTOCOL VgaMiniPort; - - // - // General fields - // - BOOLEAN VgaCompatible; - BOOLEAN ProduceGraphicsOutput; - - // - // Graphics Output Protocol related fields - // - BOOLEAN HardwareNeedsStarting; - UINTN CurrentMode; - UINTN MaxMode; - BIOS_VIDEO_MODE_DATA *ModeData; - UINT8 *LineBuffer; - EFI_GRAPHICS_OUTPUT_BLT_PIXEL *VbeFrameBuffer; - UINT8 *VgaFrameBuffer; - - // - // VESA Bios Extensions related fields - // - UINTN NumberOfPagesBelow1MB; = // Number of 4KB pages in PagesBelow1MB - EFI_PHYSICAL_ADDRESS PagesBelow1MB; = // Buffer for all VBE Information Blocks - VESA_BIOS_EXTENSIONS_INFORMATION_BLOCK *VbeInformationBlock; = // 0x200 bytes. Must be allocated below 1MB - VESA_BIOS_EXTENSIONS_MODE_INFORMATION_BLOCK *VbeModeInformationBlock;= // 0x100 bytes. Must be allocated below 1MB - VESA_BIOS_EXTENSIONS_EDID_DATA_BLOCK *VbeEdidDataBlock; = // 0x80 bytes. Must be allocated below 1MB - VESA_BIOS_EXTENSIONS_CRTC_INFORMATION_BLOCK *VbeCrtcInformationBlock;= // 59 bytes. Must be allocated below 1MB - UINTN VbeSaveRestorePages; = // Number of 4KB pages in VbeSaveRestoreBuffer - EFI_PHYSICAL_ADDRESS VbeSaveRestoreBuffer; = // Must be allocated below 1MB - // - // Status code - // - EFI_DEVICE_PATH_PROTOCOL *GopDevicePath; - - EFI_EVENT ExitBootServicesEvent; -} BIOS_VIDEO_DEV; - -#define BIOS_VIDEO_DEV_FROM_PCI_IO_THIS(a) CR (a, BIOS_VIDEO_DEV= , PciIo, BIOS_VIDEO_DEV_SIGNATURE) -#define BIOS_VIDEO_DEV_FROM_GRAPHICS_OUTPUT_THIS(a) CR (a, BIOS_VIDEO_DEV= , GraphicsOutput, BIOS_VIDEO_DEV_SIGNATURE) -#define BIOS_VIDEO_DEV_FROM_VGA_MINI_PORT_THIS(a) CR (a, BIOS_VIDEO_DEV= , VgaMiniPort, BIOS_VIDEO_DEV_SIGNATURE) - -#define GRAPHICS_OUTPUT_INVALIDE_MODE_NUMBER 0xffff - -// -// Global Variables -// -extern EFI_DRIVER_BINDING_PROTOCOL gBiosVideoDriverBinding; -extern EFI_COMPONENT_NAME_PROTOCOL gBiosVideoComponentName; -extern EFI_COMPONENT_NAME2_PROTOCOL gBiosVideoComponentName2; - -// -// Driver Binding Protocol functions -// - -/** - Supported. - - @param This Pointer to driver binding protocol - @param Controller Controller handle to connect - @param RemainingDevicePath A pointer to the remaining portion of a d= evice - path - - @retval EFI_STATUS EFI_SUCCESS:This controller can be manage= d by this - driver, Otherwise, this controller cannot= be - managed by this driver - -**/ -EFI_STATUS -EFIAPI -BiosVideoDriverBindingSupported ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE Controller, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath - ); - -/** - Install Graphics Output Protocol onto VGA device handles. - - @param This Pointer to driver binding protocol - @param Controller Controller handle to connect - @param RemainingDevicePath A pointer to the remaining portion of a d= evice - path - - @return EFI_STATUS - -**/ -EFI_STATUS -EFIAPI -BiosVideoDriverBindingStart ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE Controller, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath - ); - -/** - Stop. - - @param This Pointer to driver binding protocol - @param Controller Controller handle to connect - @param NumberOfChildren Number of children handle created by this= driver - @param ChildHandleBuffer Buffer containing child handle created - - @retval EFI_SUCCESS Driver disconnected successfully from con= troller - @retval EFI_UNSUPPORTED Cannot find BIOS_VIDEO_DEV structure - -**/ -EFI_STATUS -EFIAPI -BiosVideoDriverBindingStop ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE Controller, - IN UINTN NumberOfChildren, - IN EFI_HANDLE *ChildHandleBuffer - ); - -// -// Private worker functions -// - -/** - Check for VBE device. - - @param BiosVideoPrivate Pointer to BIOS_VIDEO_DEV structure - - @retval EFI_SUCCESS VBE device found - -**/ -EFI_STATUS -BiosVideoCheckForVbe ( - IN OUT BIOS_VIDEO_DEV *BiosVideoPrivate - ); - -/** - Check for VGA device. - - @param BiosVideoPrivate Pointer to BIOS_VIDEO_DEV structure - - @retval EFI_SUCCESS Standard VGA device found - -**/ -EFI_STATUS -BiosVideoCheckForVga ( - IN OUT BIOS_VIDEO_DEV *BiosVideoPrivate - ); - -/** - Release resource for BIOS video instance. - - @param BiosVideoPrivate Video child device private data structure - -**/ -VOID -BiosVideoDeviceReleaseResource ( - BIOS_VIDEO_DEV *BiosVideoPrivate - ); - -// -// BIOS Graphics Output Protocol functions -// - -/** - Graphics Output protocol interface to get video mode. - - @param This Protocol instance pointer. - @param ModeNumber The mode number to return information on. - @param SizeOfInfo A pointer to the size, in bytes, of the I= nfo - buffer. - @param Info Caller allocated buffer that returns info= rmation - about ModeNumber. - - @retval EFI_SUCCESS Mode information returned. - @retval EFI_BUFFER_TOO_SMALL The Info buffer was too small. - @retval EFI_DEVICE_ERROR A hardware error occurred trying to retri= eve the - video mode. - @retval EFI_NOT_STARTED Video display is not initialized. Call Se= tMode () - @retval EFI_INVALID_PARAMETER One of the input args was NULL. - -**/ -EFI_STATUS -EFIAPI -BiosVideoGraphicsOutputQueryMode ( - IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This, - IN UINT32 ModeNumber, - OUT UINTN *SizeOfInfo, - OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION **Info - ); - -/** - Graphics Output protocol interface to set video mode. - - @param This Protocol instance pointer. - @param ModeNumber The mode number to be set. - - @retval EFI_SUCCESS Graphics mode was changed. - @retval EFI_DEVICE_ERROR The device had an error and could not com= plete the - request. - @retval EFI_UNSUPPORTED ModeNumber is not supported by this devic= e. - -**/ -EFI_STATUS -EFIAPI -BiosVideoGraphicsOutputSetMode ( - IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This, - IN UINT32 ModeNumber - ); - -/** - Graphics Output protocol instance to block transfer for VBE device. - - @param This Pointer to Graphics Output protocol insta= nce - @param BltBuffer The data to transfer to screen - @param BltOperation The operation to perform - @param SourceX The X coordinate of the source for BltOpe= ration - @param SourceY The Y coordinate of the source for BltOpe= ration - @param DestinationX The X coordinate of the destination for - BltOperation - @param DestinationY The Y coordinate of the destination for - BltOperation - @param Width The width of a rectangle in the blt recta= ngle in - pixels - @param Height The height of a rectangle in the blt rect= angle in - pixels - @param Delta Not used for EfiBltVideoFill and - EfiBltVideoToVideo operation. If a Delta = of 0 is - used, the entire BltBuffer will be operat= ed on. If - a subrectangle of the BltBuffer is used, = then - Delta represents the number of bytes in a= row of - the BltBuffer. - - @retval EFI_INVALID_PARAMETER Invalid parameter passed in - @retval EFI_SUCCESS Blt operation success - -**/ -EFI_STATUS -EFIAPI -BiosVideoGraphicsOutputVbeBlt ( - IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This, - 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 - ); - -/** - Graphics Output protocol instance to block transfer for VGA device. - - @param This Pointer to Graphics Output protocol insta= nce - @param BltBuffer The data to transfer to screen - @param BltOperation The operation to perform - @param SourceX The X coordinate of the source for BltOpe= ration - @param SourceY The Y coordinate of the source for BltOpe= ration - @param DestinationX The X coordinate of the destination for - BltOperation - @param DestinationY The Y coordinate of the destination for - BltOperation - @param Width The width of a rectangle in the blt recta= ngle in - pixels - @param Height The height of a rectangle in the blt rect= angle in - pixels - @param Delta Not used for EfiBltVideoFill and - EfiBltVideoToVideo operation. If a Delta = of 0 is - used, the entire BltBuffer will be operat= ed on. If - a subrectangle of the BltBuffer is used, = then - Delta represents the number of bytes in a= row of - the BltBuffer. - - @retval EFI_INVALID_PARAMETER Invalid parameter passed in - @retval EFI_SUCCESS Blt operation success - -**/ -EFI_STATUS -EFIAPI -BiosVideoGraphicsOutputVgaBlt ( - IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This, - 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 - ); - -// -// BIOS VGA Mini Port Protocol functions -// - -/** - VgaMiniPort protocol interface to set mode. - - @param This Pointer to VgaMiniPort protocol instance - @param ModeNumber The index of the mode - - @retval EFI_UNSUPPORTED The requested mode is not supported - @retval EFI_SUCCESS The requested mode is set successfully - -**/ -EFI_STATUS -EFIAPI -BiosVideoVgaMiniPortSetMode ( - IN EFI_VGA_MINI_PORT_PROTOCOL *This, - IN UINTN ModeNumber - ); - -/** - Event handler for Exit Boot Service. - - @param Event The event that be signalled when exiting boot servic= e. - @param Context Pointer to instance of BIOS_VIDEO_DEV. - -**/ -VOID -EFIAPI -BiosVideoNotifyExitBootServices ( - IN EFI_EVENT Event, - IN VOID *Context - ); - -// -// Standard VGA Definitions -// -#define VGA_HORIZONTAL_RESOLUTION 640 -#define VGA_VERTICAL_RESOLUTION 480 -#define VGA_NUMBER_OF_BIT_PLANES 4 -#define VGA_PIXELS_PER_BYTE 8 -#define VGA_BYTES_PER_SCAN_LINE (VGA_HORIZONTAL_RESOLUTION / VGA_PIXELS= _PER_BYTE) -#define VGA_BYTES_PER_BIT_PLANE (VGA_VERTICAL_RESOLUTION * VGA_BYTES_PE= R_SCAN_LINE) - -#define VGA_GRAPHICS_CONTROLLER_ADDRESS_REGISTER 0x3ce -#define VGA_GRAPHICS_CONTROLLER_DATA_REGISTER 0x3cf - -#define VGA_GRAPHICS_CONTROLLER_SET_RESET_REGISTER 0x00 - -#define VGA_GRAPHICS_CONTROLLER_ENABLE_SET_RESET_REGISTER 0x01 - -#define VGA_GRAPHICS_CONTROLLER_COLOR_COMPARE_REGISTER 0x02 - -#define VGA_GRAPHICS_CONTROLLER_DATA_ROTATE_REGISTER 0x03 -#define VGA_GRAPHICS_CONTROLLER_FUNCTION_REPLACE 0x00 -#define VGA_GRAPHICS_CONTROLLER_FUNCTION_AND 0x08 -#define VGA_GRAPHICS_CONTROLLER_FUNCTION_OR 0x10 -#define VGA_GRAPHICS_CONTROLLER_FUNCTION_XOR 0x18 - -#define VGA_GRAPHICS_CONTROLLER_READ_MAP_SELECT_REGISTER 0x04 - -#define VGA_GRAPHICS_CONTROLLER_MODE_REGISTER 0x05 -#define VGA_GRAPHICS_CONTROLLER_READ_MODE_0 0x00 -#define VGA_GRAPHICS_CONTROLLER_READ_MODE_1 0x08 -#define VGA_GRAPHICS_CONTROLLER_WRITE_MODE_0 0x00 -#define VGA_GRAPHICS_CONTROLLER_WRITE_MODE_1 0x01 -#define VGA_GRAPHICS_CONTROLLER_WRITE_MODE_2 0x02 -#define VGA_GRAPHICS_CONTROLLER_WRITE_MODE_3 0x03 - -#define VGA_GRAPHICS_CONTROLLER_MISCELLANEOUS_REGISTER 0x06 - -#define VGA_GRAPHICS_CONTROLLER_COLOR_DONT_CARE_REGISTER 0x07 - -#define VGA_GRAPHICS_CONTROLLER_BIT_MASK_REGISTER 0x08 - -/** - Install child handles if the Handle supports MBR format. - - @param This Calling context. - @param ParentHandle Parent Handle - @param ParentPciIo Parent PciIo interface - @param ParentLegacyBios Parent LegacyBios interface - @param ParentDevicePath Parent Device Path - @param RemainingDevicePath Remaining Device Path - - @retval EFI_SUCCESS If a child handle was added - @retval other A child handle was not added - -**/ -EFI_STATUS -BiosVideoChildHandleInstall ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE ParentHandle, - IN EFI_PCI_IO_PROTOCOL *ParentPciIo, - IN EFI_LEGACY_BIOS_PROTOCOL *ParentLegacyBios, - IN EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath - ); - -/** - Deregister an video child handle and free resources. - - @param This Protocol instance pointer. - @param Controller Video controller handle - @param Handle Video child handle - - @return EFI_STATUS - -**/ -EFI_STATUS -BiosVideoChildHandleUninstall ( - EFI_DRIVER_BINDING_PROTOCOL *This, - EFI_HANDLE Controller, - EFI_HANDLE Handle - ); - -/** - Release resource for BIOS video instance. - - @param BiosVideoPrivate Video child device private data structure - -**/ -VOID -BiosVideoDeviceReleaseResource ( - BIOS_VIDEO_DEV *BiosVideoPrivate - ); - -/** - Check if all video child handles have been uninstalled. - - @param Controller Video controller handle - - @return TRUE Child handles exist. - @return FALSE All video child handles have been uninsta= lled. - -**/ -BOOLEAN -HasChildHandle ( - IN EFI_HANDLE Controller - ); - -#endif diff --git a/OvmfPkg/Csm/BiosThunk/VideoDxe/VesaBiosExtensions.h b/OvmfPkg/= Csm/BiosThunk/VideoDxe/VesaBiosExtensions.h deleted file mode 100644 index 0c8e62c0641e..000000000000 --- a/OvmfPkg/Csm/BiosThunk/VideoDxe/VesaBiosExtensions.h +++ /dev/null @@ -1,459 +0,0 @@ -/** @file - -Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.
- -SPDX-License-Identifier: BSD-2-Clause-Patent - -**/ - -#ifndef _VESA_BIOS_EXTENSIONS_H_ -#define _VESA_BIOS_EXTENSIONS_H_ - -// -// Turn on byte packing of data structures -// -#pragma pack(1) -// -// VESA BIOS Extensions status codes -// -#define VESA_BIOS_EXTENSIONS_STATUS_SUCCESS 0x004f - -// -// VESA BIOS Extensions Services -// -#define VESA_BIOS_EXTENSIONS_RETURN_CONTROLLER_INFORMATION 0x4f00 - -/*++ - - Routine Description: - Function 00 : Return Controller Information - - Arguments: - Inputs: - AX =3D 0x4f00 - ES:DI =3D Pointer to buffer to place VESA_BIOS_EXTENSIONS_INFORMATIO= N_BLOCK structure - Outputs: - AX =3D Return Status - ---*/ -#define VESA_BIOS_EXTENSIONS_RETURN_MODE_INFORMATION 0x4f01 - -/*++ - - Routine Description: - Function 01 : Return Mode Information - - Arguments: - Inputs: - AX =3D 0x4f01 - CX =3D Mode Number - ES:DI =3D Pointer to buffer to place VESA_BIOS_EXTENSIONS_MODE_INFOR= MATION_BLOCK structure - Outputs: - AX =3D Return Status - ---*/ -#define VESA_BIOS_EXTENSIONS_SET_MODE 0x4f02 - -/*++ - - Routine Description: - Function 02 : Set Mode - - Arguments: - Inputs: - AX =3D 0x4f02 - BX =3D Desired mode to set - D0-D8 =3D Mode Number - D9-D10 =3D Reserved (must be 0) - D11 =3D 0 - Use current default refresh rate - =3D 1 - Use user specfieid CRTC values for refresh rate - D12-D13 =3D Reserved (must be 0) - D14 =3D 0 - Use windowed frame buffer model - =3D 1 - Use linear/flat frame buffer model - D15 =3D 0 - Clear display memory - =3D 1 - Don't clear display memory - ES:DI =3D Pointer to buffer to the VESA_BIOS_EXTENSIONS_CRTC_INFORMA= TION_BLOCK structure - Outputs: - AX =3D Return Status - ---*/ -#define VESA_BIOS_EXTENSIONS_RETURN_CURRENT_MODE 0x4f03 - -/*++ - - Routine Description: - Function 03 : Return Current Mode - - Arguments: - Inputs: - AX =3D 0x4f03 - Outputs: - AX =3D Return Status - BX =3D Current mode - D0-D13 =3D Mode Number - D14 =3D 0 - Windowed frame buffer model - =3D 1 - Linear/flat frame buffer model - D15 =3D 0 - Memory cleared at last mode set - =3D 1 - Memory not cleared at last mode set - ---*/ -#define VESA_BIOS_EXTENSIONS_SAVE_RESTORE_STATE 0x4f04 - -/*++ - - Routine Description: - Function 04 : Save/Restore State - - Arguments: - Inputs: - AX =3D 0x4f03 - DL =3D 0x00 - Return Save/Restore State buffer size - =3D 0x01 - Save State - =3D 0x02 - Restore State - CX =3D Requested Status - D0 =3D Save/Restore controller hardware state - D1 =3D Save/Restore BIOS data state - D2 =3D Save/Restore DAC state - D3 =3D Save/Restore Regsiter state - ES:BX =3D Pointer to buffer if DL=3D1 or DL=3D2 - Outputs: - AX =3D Return Status - BX =3D Number of 64 byte blocks to hold the state buffer if DL=3D0 - ---*/ -#define VESA_BIOS_EXTENSIONS_EDID 0x4f15 - -/*++ - - Routine Description: - Function 15 : implement VBE/DDC service - - Arguments: - Inputs: - AX =3D 0x4f15 - BL =3D 0x00 - Report VBE/DDC Capabilities - CX =3D 0x00 - Controller unit number (00 =3D primary controller) - ES:DI =3D Null pointer, must be 0:0 in version 1.0 - Outputs: - AX =3D Return Status - BH =3D Approx. time in seconds, rounded up, to transfer one EDID = block(128 bytes) - BL =3D DDC level supported - D0 =3D 0 DDC1 not supported - =3D 1 DDC1 supported - D1 =3D 0 DDC2 not supported - =3D 1 DDC2 supported - D2 =3D 0 Screen not blanked during data transfer - =3D 1 Screen blanked during data transfer - - Inputs: - AX =3D 0x4f15 - BL =3D 0x01 - Read EDID - CX =3D 0x00 - Controller unit number (00 =3D primary controller) - DX =3D 0x00 - EDID block number - ES:DI =3D Pointer to buffer in which the EDID block is returned - Outputs: - AX =3D Return Status ---*/ - -// -// Timing data from EDID data block -// -#define VESA_BIOS_EXTENSIONS_EDID_BLOCK_SIZE 128 -#define VESA_BIOS_EXTENSIONS_EDID_ESTABLISHED_TIMING_MAX_NUMBER 17 - -// -// Established Timings: 24 possible resolutions -// Standard Timings: 8 possible resolutions -// Detailed Timings: 4 possible resolutions -// -#define VESA_BIOS_EXTENSIONS_EDID_TIMING_MAX_NUMBER 36 - -// -// Timing data size for Established Timings, Standard Timings and Detailed= Timings -// -#define VESA_BIOS_EXTENSIONS_ESTABLISHED_TIMING_SIZE 3 -#define VESA_BIOS_EXTENSIONS_STANDARD_TIMING_SIZE 16 -#define VESA_BIOS_EXTENSIONS_DETAILED_TIMING_EACH_DESCRIPTOR_SIZE 18 -#define VESA_BIOS_EXTENSIONS_DETAILED_TIMING_DESCRIPTOR_MAX_SIZE 72 - -typedef struct { - UINT16 HorizontalResolution; - UINT16 VerticalResolution; - UINT16 RefreshRate; -} VESA_BIOS_EXTENSIONS_EDID_TIMING; - -typedef struct { - UINT32 ValidNumber; - UINT32 Key[VESA_BIOS_EXTENSIONS_EDID_TIMING_MAX_NUMBER]; -} VESA_BIOS_EXTENSIONS_VALID_EDID_TIMING; - -typedef struct { - UINT8 Header[8]; // EDID header "00 FF FF FF FF= FF FF 00" - UINT16 ManufactureName; // EISA 3-character ID - UINT16 ProductCode; // Vendor assigned code - UINT32 SerialNumber; // 32-bit serial number - UINT8 WeekOfManufacture; // Week number - UINT8 YearOfManufacture; // Year - UINT8 EdidVersion; // EDID Structure Version - UINT8 EdidRevision; // EDID Structure Revision - UINT8 VideoInputDefinition; - UINT8 MaxHorizontalImageSize; // cm - UINT8 MaxVerticalImageSize; // cm - UINT8 DisplayTransferCharacteristic; - UINT8 FeatureSupport; - UINT8 RedGreenLowBits; // Rx1 Rx0 Ry1 Ry0 Gx1 Gx0 Gy1= Gy0 - UINT8 BlueWhiteLowBits; // Bx1 Bx0 By1 By0 Wx1 Wx0 Wy1= Wy0 - UINT8 RedX; // Red-x Bits 9 - 2 - UINT8 RedY; // Red-y Bits 9 - 2 - UINT8 GreenX; // Green-x Bits 9 - 2 - UINT8 GreenY; // Green-y Bits 9 - 2 - UINT8 BlueX; // Blue-x Bits 9 - 2 - UINT8 BlueY; // Blue-y Bits 9 - 2 - UINT8 WhiteX; // White-x Bits 9 - 2 - UINT8 WhiteY; // White-x Bits 9 - 2 - UINT8 EstablishedTimings[VESA_BIOS_EXTENSIONS_ESTABLISHED_TIMING_SIZ= E]; - UINT8 StandardTimingIdentification[VESA_BIOS_EXTENSIONS_STANDARD_TIM= ING_SIZE]; - UINT8 DetailedTimingDescriptions[VESA_BIOS_EXTENSIONS_DETAILED_TIMIN= G_DESCRIPTOR_MAX_SIZE]; - UINT8 ExtensionFlag; // Number of (optional) 128-by= te EDID extension blocks to follow - UINT8 Checksum; -} VESA_BIOS_EXTENSIONS_EDID_DATA_BLOCK; - -// -// Super VGA Information Block -// -typedef struct { - UINT32 VESASignature; // 'VESA' 4 byte signature - UINT16 VESAVersion; // VBE version number - UINT32 OEMStringPtr; // Pointer to OEM string - UINT32 Capabilities; // Capabilities of video card - UINT32 VideoModePtr; // Pointer to an array of 16-bit supported = modes values terminated by 0xFFFF - UINT16 TotalMemory; // Number of 64kb memory blocks - UINT16 OemSoftwareRev; // VBE implementation Software revision - UINT32 OemVendorNamePtr; // VbeFarPtr to Vendor Name String - UINT32 OemProductNamePtr; // VbeFarPtr to Product Name String - UINT32 OemProductRevPtr; // VbeFarPtr to Product Revision String - UINT8 Reserved[222]; // Reserved for VBE implementation scratch = area - UINT8 OemData[256]; // Data area for OEM strings. Pad to 512 b= yte block size -} VESA_BIOS_EXTENSIONS_INFORMATION_BLOCK; - -// -// Super VGA Information Block VESASignature values -// -#define VESA_BIOS_EXTENSIONS_VESA_SIGNATURE SIGNATURE_32 ('V', 'E', 'S', = 'A') -#define VESA_BIOS_EXTENSIONS_VBE2_SIGNATURE SIGNATURE_32 ('V', 'B', 'E', = '2') - -// -// Super VGA Information Block VESAVersion values -// -#define VESA_BIOS_EXTENSIONS_VERSION_1_2 0x0102 -#define VESA_BIOS_EXTENSIONS_VERSION_2_0 0x0200 -#define VESA_BIOS_EXTENSIONS_VERSION_3_0 0x0300 - -// -// Super VGA Information Block Capabilities field bit definitions -// -#define VESA_BIOS_EXTENSIONS_CAPABILITY_8_BIT_DAC 0x01 // 0: DAC width is= fixed at 6 bits/color -// 1: DAC width switchable to 8 bits/color -// -#define VESA_BIOS_EXTENSIONS_CAPABILITY_NOT_VGA 0x02 // 0: Controller is = VGA compatible -// 1: Controller is not VGA compatible -// -#define VESA_BIOS_EXTENSIONS_CAPABILITY_NOT_NORMAL_RAMDAC 0x04 // 0: Norm= al RAMDAC operation -// 1: Use blank bit in function 9 to program RAMDAC -// -#define VESA_BIOS_EXTENSIONS_CAPABILITY_STEREOSCOPIC 0x08 // 0: No hardw= are stereoscopic signal support -// 1: Hardware stereoscopic signal support -// -#define VESA_BIOS_EXTENSIONS_CAPABILITY_VESA_EVC 0x10 // 0: Stero signal= ing supported via external VESA stereo connector -// 1: Stero signaling supported via VESA EVC connector -// -// Super VGA mode number bite field definitions -// -#define VESA_BIOS_EXTENSIONS_MODE_NUMBER_VESA 0x0100 // 0: Not a VESA def= ined VBE mode -// 1: A VESA defined VBE mode -// -#define VESA_BIOS_EXTENSIONS_MODE_NUMBER_REFRESH_CONTROL_USER 0x0800 // 0= : Use current BIOS default referesh rate -// 1: Use the user specified CRTC values for refresh rate -// -#define VESA_BIOS_EXTENSIONS_MODE_NUMBER_LINEAR_FRAME_BUFFER 0x4000 // 0= : Use a banked/windowed frame buffer -// 1: Use a linear/flat frame buffer -// -#define VESA_BIOS_EXTENSIONS_MODE_NUMBER_PRESERVE_MEMORY 0x8000 // 0: Cl= ear display memory -// 1: Preseve display memory -// -// Super VGA Information Block mode list terminator value -// -#define VESA_BIOS_EXTENSIONS_END_OF_MODE_LIST 0xffff - -// -// Window Function -// -typedef -VOID -(*VESA_BIOS_EXTENSIONS_WINDOW_FUNCTION) ( - VOID - ); - -// -// Super VGA Mode Information Block -// -typedef struct { - // - // Manadory fields for all VESA Bios Extensions revisions - // - UINT16 ModeAttributes; // Mode attribut= es - UINT8 WinAAttributes; // Window A attr= ibutes - UINT8 WinBAttributes; // Window B attr= ibutes - UINT16 WinGranularity; // Window granul= arity in k - UINT16 WinSize; // Window size i= n k - UINT16 WinASegment; // Window A segm= ent - UINT16 WinBSegment; // Window B segm= ent - UINT32 WindowFunction; // Pointer to wi= ndow function - UINT16 BytesPerScanLine; // Bytes per sca= nline - // - // Manadory fields for VESA Bios Extensions 1.2 and above - // - UINT16 XResolution; // Horizonta= l resolution - UINT16 YResolution; // Vertical = resolution - UINT8 XCharSize; // Character= cell width - UINT8 YCharSize; // Character= cell height - UINT8 NumberOfPlanes; // Number of= memory planes - UINT8 BitsPerPixel; // Bits per = pixel - UINT8 NumberOfBanks; // Number of= CGA style banks - UINT8 MemoryModel; // Memory mo= del type - UINT8 BankSize; // Size of C= GA style banks - UINT8 NumberOfImagePages; // Number of= images pages - UINT8 Reserved1; // Reserved - UINT8 RedMaskSize; // Size of d= irect color red mask - UINT8 RedFieldPosition; // Bit posn = of lsb of red mask - UINT8 GreenMaskSize; // Size of d= irect color green mask - UINT8 GreenFieldPosition; // Bit posn = of lsb of green mask - UINT8 BlueMaskSize; // Size of d= irect color blue mask - UINT8 BlueFieldPosition; // Bit posn = of lsb of blue mask - UINT8 RsvdMaskSize; // Size of d= irect color res mask - UINT8 RsvdFieldPosition; // Bit posn = of lsb of res mask - UINT8 DirectColorModeInfo; // Direct co= lor mode attributes - // - // Manadory fields for VESA Bios Extensions 2.0 and above - // - UINT32 PhysBasePtr; // Physical Address = for flat memory frame buffer - UINT32 Reserved2; // Reserved - UINT16 Reserved3; // Reserved - // - // Manadory fields for VESA Bios Extensions 3.0 and above - // - UINT16 LinBytesPerScanLine; // Bytes/s= can line for linear modes - UINT8 BnkNumberOfImagePages; // Number = of images for banked modes - UINT8 LinNumberOfImagePages; // Number = of images for linear modes - UINT8 LinRedMaskSize; // Size of= direct color red mask (linear mode) - UINT8 LinRedFieldPosition; // Bit pos= iiton of lsb of red mask (linear modes) - UINT8 LinGreenMaskSize; // Size of= direct color green mask (linear mode) - UINT8 LinGreenFieldPosition; // Bit pos= iiton of lsb of green mask (linear modes) - UINT8 LinBlueMaskSize; // Size of= direct color blue mask (linear mode) - UINT8 LinBlueFieldPosition; // Bit pos= iiton of lsb of blue mask (linear modes) - UINT8 LinRsvdMaskSize; // Size of= direct color reserved mask (linear mode) - UINT8 LinRsvdFieldPosition; // Bit pos= iiton of lsb of reserved mask (linear modes) - UINT32 MaxPixelClock; // Maximum= pixel clock (in Hz) for graphics mode - UINT8 Pad[190]; // Pad to = 256 byte block size -} VESA_BIOS_EXTENSIONS_MODE_INFORMATION_BLOCK; - -// -// Super VGA Mode Information Block ModeAttributes field bit definitions -// -#define VESA_BIOS_EXTENSIONS_MODE_ATTRIBUTE_HARDWARE 0x0001 // 0: Mode n= ot supported in handware -// 1: Mode supported in handware -// -#define VESA_BIOS_EXTENSIONS_MODE_ATTRIBUTE_TTY 0x0004 // 0: TTY Output f= unctions not supported by BIOS -// 1: TTY Output functions supported by BIOS -// -#define VESA_BIOS_EXTENSIONS_MODE_ATTRIBUTE_COLOR 0x0008 // 0: Monochrome= mode -// 1: Color mode -// -#define VESA_BIOS_EXTENSIONS_MODE_ATTRIBUTE_GRAPHICS 0x0010 // 0: Text m= ode -// 1: Graphics mode -// -#define VESA_BIOS_EXTENSIONS_MODE_ATTRIBUTE_NOT_VGA 0x0020 // 0: VGA comp= atible mode -// 1: Not a VGA compatible mode -// -#define VESA_BIOS_EXTENSIONS_MODE_ATTRIBUTE_NOT_WINDOWED 0x0040 // 0: VG= A compatible windowed memory mode -// 1: Not a VGA compatible windowed memory mode -// -#define VESA_BIOS_EXTENSIONS_MODE_ATTRIBUTE_LINEAR_FRAME_BUFFER 0x0080 //= 0: No linear fram buffer mode available -// 1: Linear frame buffer mode available -// -#define VESA_BIOS_EXTENSIONS_MODE_ATTRIBUTE_DOUBLE_SCAN 0x0100 // 0: No d= ouble scan mode available -// 1: Double scan mode available -// -#define VESA_BIOS_EXTENSIONS_MODE_ATTRIBUTE_INTERLACED 0x0200 // 0: No i= nterlaced mode is available -// 1: Interlaced mode is available -// -#define VESA_BIOS_EXTENSIONS_MODE_ATTRIBUTE_NO_TRIPPLE_BUFFER 0x0400 // 0= : No hardware triple buffer mode support available -// 1: Hardware triple buffer mode support available -// -#define VESA_BIOS_EXTENSIONS_MODE_ATTRIBUTE_STEREOSCOPIC 0x0800 // 0: No= hardware steroscopic display support -// 1: Hardware steroscopic display support -// -#define VESA_BIOS_EXTENSIONS_MODE_ATTRIBUTE_DUAL_DISPLAY 0x1000 // 0: No= dual display start address support -// 1: Dual display start address support -// -// Super VGA Mode Information Block WinAAttribite/WinBAttributes field bit= definitions -// -#define VESA_BIOS_EXTENSIONS_WINX_ATTRIBUTE_RELOCATABLE 0x01 // 0: Single= non-relocatable window only -// 1: Relocatable window(s) are supported -// -#define VESA_BIOS_EXTENSIONS_WINX_ATTRIBUTE_READABLE 0x02 // 0: Window i= s not readable -// 1: Window is readable -// -#define VESA_BIOS_EXTENSIONS_WINX_ATTRIBUTE_WRITABLE 0x04 // 0: Window i= s not writable -// 1: Window is writable -// -// Super VGA Mode Information Block DirectColorMode field bit definitions -// -#define VESA_BIOS_EXTENSIONS_DIRECT_COLOR_MODE_PROG_COLOR_RAMP 0x01 // 0= : Color ram is fixed -// 1: Color ramp is programmable -// -#define VESA_BIOS_EXTENSIONS_DIRECT_COLOR_MODE_RSVD_USABLE 0x02 // 0: Bi= ts in Rsvd field are reserved -// 1: Bits in Rsdv field are usable -// -// Super VGA Memory Models -// -typedef enum { - MemPL =3D 3, // Planar memory model - MemPK =3D 4, // Packed pixel memory model - MemRGB =3D 6, // Direct color RGB memory model - MemYUV =3D 7 // Direct color YUV memory model -} VESA_BIOS_EXTENSIONS_MEMORY_MODELS; - -// -// Super VGA CRTC Information Block -// -typedef struct { - UINT16 HorizontalTotal; // Horizontal total in pixels - UINT16 HorizontalSyncStart; // Horizontal sync start in pixels - UINT16 HorizontalSyncEnd; // Horizontal sync end in pixels - UINT16 VericalTotal; // Vertical total in pixels - UINT16 VericalSyncStart; // Vertical sync start in pixels - UINT16 VericalSyncEnd; // Vertical sync end in pixels - UINT8 Flags; // Flags (Interlaced/DoubleScan/etc). - UINT32 PixelClock; // Pixel clock in units of Hz - UINT16 RefreshRate; // Refresh rate in units of 0.01 Hz - UINT8 Reserved[40]; // Pad -} VESA_BIOS_EXTENSIONS_CRTC_INFORMATION_BLOCK; - -#define VESA_BIOS_EXTENSIONS_CRTC_FLAGS_DOUBLE_SCAN 0x01 // 0: Graphics m= ode is not souble scanned -// 1: Graphics mode is double scanned -// -#define VESA_BIOS_EXTENSIONS_CRTC_FLAGSINTERLACED 0x02 // 0: Graphics mod= e is not interlaced -// 1: Graphics mode is interlaced -// -#define VESA_BIOS_EXTENSIONS_CRTC_HORIZONTAL_SYNC_NEGATIVE 0x04 // 0: Ho= rizontal sync polarity is positive(+) -// 0: Horizontal sync polarity is negative(-) -// -#define VESA_BIOS_EXTENSIONS_CRTC_VERITICAL_SYNC_NEGATIVE 0x08 // 0: Veri= cal sync polarity is positive(+) -// 0: Verical sync polarity is negative(-) -// -// Turn off byte packing of data structures -// -#pragma pack() - -#endif diff --git a/OvmfPkg/Csm/BiosThunk/VideoDxe/BiosVideo.c b/OvmfPkg/Csm/BiosT= hunk/VideoDxe/BiosVideo.c deleted file mode 100644 index 35a4a24f3404..000000000000 --- a/OvmfPkg/Csm/BiosThunk/VideoDxe/BiosVideo.c +++ /dev/null @@ -1,3357 +0,0 @@ -/** @file - ConsoleOut Routines that speak VGA. - -Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
- -SPDX-License-Identifier: BSD-2-Clause-Patent - -**/ - -#include "BiosVideo.h" - -// -// EFI Driver Binding Protocol Instance -// -EFI_DRIVER_BINDING_PROTOCOL gBiosVideoDriverBinding =3D { - BiosVideoDriverBindingSupported, - BiosVideoDriverBindingStart, - BiosVideoDriverBindingStop, - 0x3, - NULL, - NULL -}; - -// -// Global lookup tables for VGA graphics modes -// -UINT8 mVgaLeftMaskTable[] =3D { 0xff, 0x7f, 0x3f, 0x1f, 0x0f, 0x07, 0x03,= 0x01 }; - -UINT8 mVgaRightMaskTable[] =3D { 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe= , 0xff }; - -UINT8 mVgaBitMaskTable[] =3D { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, = 0x01 }; - -// -// Save controller attributes during first start -// -UINT64 mOriginalPciAttributes; -BOOLEAN mPciAttributesSaved =3D FALSE; - -EFI_GRAPHICS_OUTPUT_BLT_PIXEL mVgaColorToGraphicsOutputColor[] =3D { - { 0x00, 0x00, 0x00, 0x00 }, - { 0x98, 0x00, 0x00, 0x00 }, - { 0x00, 0x98, 0x00, 0x00 }, - { 0x98, 0x98, 0x00, 0x00 }, - { 0x00, 0x00, 0x98, 0x00 }, - { 0x98, 0x00, 0x98, 0x00 }, - { 0x00, 0x98, 0x98, 0x00 }, - { 0x98, 0x98, 0x98, 0x00 }, - { 0x10, 0x10, 0x10, 0x00 }, - { 0xff, 0x10, 0x10, 0x00 }, - { 0x10, 0xff, 0x10, 0x00 }, - { 0xff, 0xff, 0x10, 0x00 }, - { 0x10, 0x10, 0xff, 0x00 }, - { 0xf0, 0x10, 0xff, 0x00 }, - { 0x10, 0xff, 0xff, 0x00 }, - { 0xff, 0xff, 0xff, 0x00 } -}; - -// -// Standard timing defined by VESA EDID -// -VESA_BIOS_EXTENSIONS_EDID_TIMING mEstablishedEdidTiming[] =3D { - // - // Established Timing I - // - { 800, 600, 60 }, - { 800, 600, 56 }, - { 640, 480, 75 }, - { 640, 480, 72 }, - { 640, 480, 67 }, - { 640, 480, 60 }, - { 720, 400, 88 }, - { 720, 400, 70 }, - // - // Established Timing II - // - { 1280, 1024, 75 }, - { 1024, 768, 75 }, - { 1024, 768, 70 }, - { 1024, 768, 60 }, - { 1024, 768, 87 }, - { 832, 624, 75 }, - { 800, 600, 75 }, - { 800, 600, 72 }, - // - // Established Timing III - // - { 1152, 870, 75 } -}; - -/** - Supported. - - @param This Pointer to driver binding protocol - @param Controller Controller handle to connect - @param RemainingDevicePath A pointer to the remaining portion of a d= evice - path - - @retval EFI_STATUS EFI_SUCCESS:This controller can be manage= d by this - driver, Otherwise, this controller cannot= be - managed by this driver - -**/ -EFI_STATUS -EFIAPI -BiosVideoDriverBindingSupported ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE Controller, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath - ) -{ - EFI_STATUS Status; - EFI_LEGACY_BIOS_PROTOCOL *LegacyBios; - EFI_PCI_IO_PROTOCOL *PciIo; - PCI_TYPE00 Pci; - EFI_DEV_PATH *Node; - - // - // See if the Legacy BIOS Protocol is available - // - Status =3D gBS->LocateProtocol (&gEfiLegacyBiosProtocolGuid, NULL, (VOID= **)&LegacyBios); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Open the IO Abstraction(s) needed to perform the supported test - // - Status =3D gBS->OpenProtocol ( - Controller, - &gEfiPciIoProtocolGuid, - (VOID **)&PciIo, - This->DriverBindingHandle, - Controller, - EFI_OPEN_PROTOCOL_BY_DRIVER - ); - if (EFI_ERROR (Status) && (Status !=3D EFI_ALREADY_STARTED)) { - return Status; - } - - if (Status =3D=3D EFI_ALREADY_STARTED) { - // - // If VgaMiniPort protocol is installed, EFI_ALREADY_STARTED indicates= failure, - // because VgaMiniPort protocol is installed on controller handle dire= ctly. - // - Status =3D gBS->OpenProtocol ( - Controller, - &gEfiVgaMiniPortProtocolGuid, - NULL, - NULL, - NULL, - EFI_OPEN_PROTOCOL_TEST_PROTOCOL - ); - if (!EFI_ERROR (Status)) { - return EFI_ALREADY_STARTED; - } - } - - // - // See if this is a PCI Graphics Controller by looking at the Command re= gister and - // Class Code Register - // - Status =3D PciIo->Pci.Read ( - PciIo, - EfiPciIoWidthUint32, - 0, - sizeof (Pci) / sizeof (UINT32), - &Pci - ); - if (EFI_ERROR (Status)) { - Status =3D EFI_UNSUPPORTED; - goto Done; - } - - Status =3D EFI_UNSUPPORTED; - if ((Pci.Hdr.ClassCode[2] =3D=3D 0x03) || ((Pci.Hdr.ClassCode[2] =3D=3D = 0x00) && (Pci.Hdr.ClassCode[1] =3D=3D 0x01))) { - Status =3D EFI_SUCCESS; - // - // If this is a graphics controller, - // go further check RemainingDevicePath validation - // - if (RemainingDevicePath !=3D NULL) { - Node =3D (EFI_DEV_PATH *)RemainingDevicePath; - // - // Check if RemainingDevicePath is the End of Device Path Node, - // if yes, return EFI_SUCCESS - // - if (!IsDevicePathEnd (Node)) { - // - // If RemainingDevicePath isn't the End of Device Path Node, - // check its validation - // - if ((Node->DevPath.Type !=3D ACPI_DEVICE_PATH) || - (Node->DevPath.SubType !=3D ACPI_ADR_DP) || - (DevicePathNodeLength (&Node->DevPath) < sizeof (ACPI_ADR_DEVI= CE_PATH))) - { - Status =3D EFI_UNSUPPORTED; - } - } - } - } - -Done: - gBS->CloseProtocol ( - Controller, - &gEfiPciIoProtocolGuid, - This->DriverBindingHandle, - Controller - ); - - return Status; -} - -/** - Install Graphics Output Protocol onto VGA device handles. - - @param This Pointer to driver binding protocol - @param Controller Controller handle to connect - @param RemainingDevicePath A pointer to the remaining portion of a d= evice - path - - @return EFI_STATUS - -**/ -EFI_STATUS -EFIAPI -BiosVideoDriverBindingStart ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE Controller, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath - ) -{ - EFI_STATUS Status; - EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath; - EFI_PCI_IO_PROTOCOL *PciIo; - EFI_LEGACY_BIOS_PROTOCOL *LegacyBios; - UINTN Flags; - UINT64 Supports; - - // - // Initialize local variables - // - PciIo =3D NULL; - ParentDevicePath =3D NULL; - - // - // - // See if the Legacy BIOS Protocol is available - // - Status =3D gBS->LocateProtocol (&gEfiLegacyBiosProtocolGuid, NULL, (VOID= **)&LegacyBios); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Prepare for status code - // - Status =3D gBS->HandleProtocol ( - Controller, - &gEfiDevicePathProtocolGuid, - (VOID **)&ParentDevicePath - ); - if (EFI_ERROR (Status)) { - return Status; - } - - // - // Open the IO Abstraction(s) needed - // - Status =3D gBS->OpenProtocol ( - Controller, - &gEfiPciIoProtocolGuid, - (VOID **)&PciIo, - This->DriverBindingHandle, - Controller, - EFI_OPEN_PROTOCOL_BY_DRIVER - ); - if (EFI_ERROR (Status) && (Status !=3D EFI_ALREADY_STARTED)) { - return Status; - } - - // - // Save original PCI attributes - // - if (!mPciAttributesSaved) { - Status =3D PciIo->Attributes ( - PciIo, - EfiPciIoAttributeOperationGet, - 0, - &mOriginalPciAttributes - ); - - if (EFI_ERROR (Status)) { - goto Done; - } - - mPciAttributesSaved =3D TRUE; - } - - // - // Get supported PCI attributes - // - Status =3D PciIo->Attributes ( - PciIo, - EfiPciIoAttributeOperationSupported, - 0, - &Supports - ); - if (EFI_ERROR (Status)) { - goto Done; - } - - Supports &=3D (UINT64)(EFI_PCI_IO_ATTRIBUTE_VGA_IO | EFI_PCI_IO_ATTRIBUT= E_VGA_IO_16); - if ((Supports =3D=3D 0) || (Supports =3D=3D (EFI_PCI_IO_ATTRIBUTE_VGA_IO= | EFI_PCI_IO_ATTRIBUTE_VGA_IO_16))) { - Status =3D EFI_UNSUPPORTED; - goto Done; - } - - REPORT_STATUS_CODE_WITH_DEVICE_PATH ( - EFI_PROGRESS_CODE, - EFI_PERIPHERAL_LOCAL_CONSOLE | EFI_P_PC_ENABLE, - ParentDevicePath - ); - // - // Enable the device and make sure VGA cycles are being forwarded to thi= s VGA device - // - Status =3D PciIo->Attributes ( - PciIo, - EfiPciIoAttributeOperationEnable, - EFI_PCI_DEVICE_ENABLE | EFI_PCI_IO_ATTRIBUTE_VGA_MEMOR= Y | Supports, - NULL - ); - if (EFI_ERROR (Status)) { - REPORT_STATUS_CODE_WITH_DEVICE_PATH ( - EFI_ERROR_CODE | EFI_ERROR_MINOR, - EFI_PERIPHERAL_LOCAL_CONSOLE | EFI_P_EC_RESOURCE_CONFLICT, - ParentDevicePath - ); - goto Done; - } - - // - // Check to see if there is a legacy option ROM image associated with th= is PCI device - // - Status =3D LegacyBios->CheckPciRom ( - LegacyBios, - Controller, - NULL, - NULL, - &Flags - ); - if (EFI_ERROR (Status)) { - goto Done; - } - - // - // Post the legacy option ROM if it is available. - // - REPORT_STATUS_CODE_WITH_DEVICE_PATH ( - EFI_PROGRESS_CODE, - EFI_P_PC_RESET, - ParentDevicePath - ); - Status =3D LegacyBios->InstallPciRom ( - LegacyBios, - Controller, - NULL, - &Flags, - NULL, - NULL, - NULL, - NULL - ); - if (EFI_ERROR (Status)) { - REPORT_STATUS_CODE_WITH_DEVICE_PATH ( - EFI_ERROR_CODE | EFI_ERROR_MINOR, - EFI_PERIPHERAL_LOCAL_CONSOLE | EFI_P_EC_CONTROLLER_ERROR, - ParentDevicePath - ); - goto Done; - } - - if (RemainingDevicePath !=3D NULL) { - if (IsDevicePathEnd (RemainingDevicePath) && - (FeaturePcdGet (PcdBiosVideoCheckVbeEnable) || FeaturePcdGet (PcdB= iosVideoCheckVgaEnable))) - { - // - // If RemainingDevicePath is the End of Device Path Node, - // don't create any child device and return EFI_SUCCESS - Status =3D EFI_SUCCESS; - goto Done; - } - } - - // - // Create child handle and install GraphicsOutputProtocol on it - // - Status =3D BiosVideoChildHandleInstall ( - This, - Controller, - PciIo, - LegacyBios, - ParentDevicePath, - RemainingDevicePath - ); - -Done: - if ((EFI_ERROR (Status)) && (Status !=3D EFI_ALREADY_STARTED)) { - REPORT_STATUS_CODE_WITH_DEVICE_PATH ( - EFI_PROGRESS_CODE, - EFI_PERIPHERAL_LOCAL_CONSOLE | EFI_P_PC_DISABLE, - ParentDevicePath - ); - - REPORT_STATUS_CODE_WITH_DEVICE_PATH ( - EFI_PROGRESS_CODE, - EFI_PERIPHERAL_LOCAL_CONSOLE | EFI_P_EC_NOT_DETECTED, - ParentDevicePath - ); - if (!HasChildHandle (Controller)) { - if (mPciAttributesSaved) { - // - // Restore original PCI attributes - // - PciIo->Attributes ( - PciIo, - EfiPciIoAttributeOperationSet, - mOriginalPciAttributes, - NULL - ); - } - } - - // - // Release PCI I/O Protocols on the controller handle. - // - gBS->CloseProtocol ( - Controller, - &gEfiPciIoProtocolGuid, - This->DriverBindingHandle, - Controller - ); - } - - return Status; -} - -/** - Stop. - - @param This Pointer to driver binding protocol - @param Controller Controller handle to connect - @param NumberOfChildren Number of children handle created by this= driver - @param ChildHandleBuffer Buffer containing child handle created - - @retval EFI_SUCCESS Driver disconnected successfully from con= troller - @retval EFI_UNSUPPORTED Cannot find BIOS_VIDEO_DEV structure - -**/ -EFI_STATUS -EFIAPI -BiosVideoDriverBindingStop ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE Controller, - IN UINTN NumberOfChildren, - IN EFI_HANDLE *ChildHandleBuffer - ) -{ - EFI_STATUS Status; - BOOLEAN AllChildrenStopped; - UINTN Index; - EFI_PCI_IO_PROTOCOL *PciIo; - - AllChildrenStopped =3D TRUE; - - if (NumberOfChildren =3D=3D 0) { - // - // Close PCI I/O protocol on the controller handle - // - gBS->CloseProtocol ( - Controller, - &gEfiPciIoProtocolGuid, - This->DriverBindingHandle, - Controller - ); - - return EFI_SUCCESS; - } - - for (Index =3D 0; Index < NumberOfChildren; Index++) { - Status =3D BiosVideoChildHandleUninstall (This, Controller, ChildHandl= eBuffer[Index]); - - if (EFI_ERROR (Status)) { - AllChildrenStopped =3D FALSE; - } - } - - if (!AllChildrenStopped) { - return EFI_DEVICE_ERROR; - } - - if (!HasChildHandle (Controller)) { - if (mPciAttributesSaved) { - Status =3D gBS->HandleProtocol ( - Controller, - &gEfiPciIoProtocolGuid, - (VOID **)&PciIo - ); - ASSERT_EFI_ERROR (Status); - - // - // Restore original PCI attributes - // - Status =3D PciIo->Attributes ( - PciIo, - EfiPciIoAttributeOperationSet, - mOriginalPciAttributes, - NULL - ); - ASSERT_EFI_ERROR (Status); - } - } - - return EFI_SUCCESS; -} - -/** - Install child handles if the Handle supports MBR format. - - @param This Calling context. - @param ParentHandle Parent Handle - @param ParentPciIo Parent PciIo interface - @param ParentLegacyBios Parent LegacyBios interface - @param ParentDevicePath Parent Device Path - @param RemainingDevicePath Remaining Device Path - - @retval EFI_SUCCESS If a child handle was added - @retval other A child handle was not added - -**/ -EFI_STATUS -BiosVideoChildHandleInstall ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE ParentHandle, - IN EFI_PCI_IO_PROTOCOL *ParentPciIo, - IN EFI_LEGACY_BIOS_PROTOCOL *ParentLegacyBios, - IN EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath - ) -{ - EFI_STATUS Status; - BIOS_VIDEO_DEV *BiosVideoPrivate; - PCI_TYPE00 Pci; - ACPI_ADR_DEVICE_PATH AcpiDeviceNode; - BOOLEAN ProtocolInstalled; - - // - // Allocate the private device structure for video device - // - BiosVideoPrivate =3D (BIOS_VIDEO_DEV *)AllocateZeroPool ( - sizeof (BIOS_VIDEO_DEV) - ); - if (NULL =3D=3D BiosVideoPrivate) { - Status =3D EFI_OUT_OF_RESOURCES; - goto Done; - } - - // - // See if this is a VGA compatible controller or not - // - Status =3D ParentPciIo->Pci.Read ( - ParentPciIo, - EfiPciIoWidthUint32, - 0, - sizeof (Pci) / sizeof (UINT32), - &Pci - ); - if (EFI_ERROR (Status)) { - REPORT_STATUS_CODE_WITH_DEVICE_PATH ( - EFI_ERROR_CODE | EFI_ERROR_MINOR, - EFI_PERIPHERAL_LOCAL_CONSOLE | EFI_P_EC_CONTROLLER_ERROR, - ParentDevicePath - ); - goto Done; - } - - BiosVideoPrivate->VgaCompatible =3D FALSE; - if ((Pci.Hdr.ClassCode[2] =3D=3D 0x00) && (Pci.Hdr.ClassCode[1] =3D=3D 0= x01)) { - BiosVideoPrivate->VgaCompatible =3D TRUE; - } - - if ((Pci.Hdr.ClassCode[2] =3D=3D 0x03) && (Pci.Hdr.ClassCode[1] =3D=3D 0= x00) && (Pci.Hdr.ClassCode[0] =3D=3D 0x00)) { - BiosVideoPrivate->VgaCompatible =3D TRUE; - } - - if (PcdGetBool (PcdBiosVideoSetTextVgaModeEnable)) { - // - // Create EXIT_BOOT_SERIVES Event - // - Status =3D gBS->CreateEventEx ( - EVT_NOTIFY_SIGNAL, - TPL_NOTIFY, - BiosVideoNotifyExitBootServices, - BiosVideoPrivate, - &gEfiEventExitBootServicesGuid, - &BiosVideoPrivate->ExitBootServicesEvent - ); - if (EFI_ERROR (Status)) { - goto Done; - } - } - - // - // Initialize the child private structure - // - BiosVideoPrivate->Signature =3D BIOS_VIDEO_DEV_SIGNATURE; - - // - // Fill in Graphics Output specific mode structures - // - BiosVideoPrivate->HardwareNeedsStarting =3D TRUE; - BiosVideoPrivate->ModeData =3D NULL; - BiosVideoPrivate->LineBuffer =3D NULL; - BiosVideoPrivate->VgaFrameBuffer =3D NULL; - BiosVideoPrivate->VbeFrameBuffer =3D NULL; - - // - // Fill in the Graphics Output Protocol - // - BiosVideoPrivate->GraphicsOutput.QueryMode =3D BiosVideoGraphicsOutputQu= eryMode; - BiosVideoPrivate->GraphicsOutput.SetMode =3D BiosVideoGraphicsOutputSe= tMode; - - // - // Allocate buffer for Graphics Output Protocol mode information - // - BiosVideoPrivate->GraphicsOutput.Mode =3D (EFI_GRAPHICS_OUTPUT_PROTOCOL_= MODE *)AllocatePool ( - = sizeof (EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE) - = ); - if (NULL =3D=3D BiosVideoPrivate->GraphicsOutput.Mode) { - Status =3D EFI_OUT_OF_RESOURCES; - goto Done; - } - - BiosVideoPrivate->GraphicsOutput.Mode->Info =3D (EFI_GRAPHICS_OUTPUT_MOD= E_INFORMATION *)AllocatePool ( - = sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION) - = ); - if (NULL =3D=3D BiosVideoPrivate->GraphicsOutput.Mode->Info) { - Status =3D EFI_OUT_OF_RESOURCES; - goto Done; - } - - // - // Assume that Graphics Output Protocol will be produced until proven ot= herwise - // - BiosVideoPrivate->ProduceGraphicsOutput =3D TRUE; - - // - // Set Gop Device Path, here RemainingDevicePath will not be one End of = Device Path Node. - // - if ((RemainingDevicePath =3D=3D NULL) || (!IsDevicePathEnd (RemainingDev= icePath))) { - if (RemainingDevicePath =3D=3D NULL) { - ZeroMem (&AcpiDeviceNode, sizeof (ACPI_ADR_DEVICE_PATH)); - AcpiDeviceNode.Header.Type =3D ACPI_DEVICE_PATH; - AcpiDeviceNode.Header.SubType =3D ACPI_ADR_DP; - AcpiDeviceNode.ADR =3D ACPI_DISPLAY_ADR (1, 0, 0, 1, 0, A= CPI_ADR_DISPLAY_TYPE_VGA, 0, 0); - SetDevicePathNodeLength (&AcpiDeviceNode.Header, sizeof (ACPI_ADR_DE= VICE_PATH)); - - BiosVideoPrivate->GopDevicePath =3D AppendDevicePathNode ( - ParentDevicePath, - (EFI_DEVICE_PATH_PROTOCOL *)&Acp= iDeviceNode - ); - } else { - BiosVideoPrivate->GopDevicePath =3D AppendDevicePathNode (ParentDevi= cePath, RemainingDevicePath); - } - - // - // Creat child handle and device path protocol firstly - // - BiosVideoPrivate->Handle =3D NULL; - Status =3D gBS->InstallMultipleProtocolInterfaces ( - &BiosVideoPrivate->Handle, - &gEfiDevicePathProtocolGuid, - BiosVideoPrivate->GopDevicePath, - NULL - ); - if (EFI_ERROR (Status)) { - goto Done; - } - } - - // - // Fill in the VGA Mini Port Protocol fields - // - BiosVideoPrivate->VgaMiniPort.SetMode =3D BiosVideoVga= MiniPortSetMode; - BiosVideoPrivate->VgaMiniPort.VgaMemoryOffset =3D 0xb8000; - BiosVideoPrivate->VgaMiniPort.CrtcAddressRegisterOffset =3D 0x3d4; - BiosVideoPrivate->VgaMiniPort.CrtcDataRegisterOffset =3D 0x3d5; - BiosVideoPrivate->VgaMiniPort.VgaMemoryBar =3D EFI_PCI_IO_P= ASS_THROUGH_BAR; - BiosVideoPrivate->VgaMiniPort.CrtcAddressRegisterBar =3D EFI_PCI_IO_P= ASS_THROUGH_BAR; - BiosVideoPrivate->VgaMiniPort.CrtcDataRegisterBar =3D EFI_PCI_IO_P= ASS_THROUGH_BAR; - - // - // Child handle need to consume the Legacy Bios protocol - // - BiosVideoPrivate->LegacyBios =3D ParentLegacyBios; - - // - // When check for VBE, PCI I/O protocol is needed, so use parent's proto= col interface temporally - // - BiosVideoPrivate->PciIo =3D ParentPciIo; - - // - // Check for VESA BIOS Extensions for modes that are compatible with Gra= phics Output - // - if (FeaturePcdGet (PcdBiosVideoCheckVbeEnable)) { - Status =3D BiosVideoCheckForVbe (BiosVideoPrivate); - DEBUG ((DEBUG_INFO, "BiosVideoCheckForVbe - %r\n", Status)); - } else { - Status =3D EFI_UNSUPPORTED; - } - - if (EFI_ERROR (Status)) { - // - // The VESA BIOS Extensions are not compatible with Graphics Output, s= o check for support - // for the standard 640x480 16 color VGA mode - // - DEBUG ((DEBUG_INFO, "VgaCompatible - %x\n", BiosVideoPrivate->VgaCompa= tible)); - if (BiosVideoPrivate->VgaCompatible) { - if (FeaturePcdGet (PcdBiosVideoCheckVgaEnable)) { - Status =3D BiosVideoCheckForVga (BiosVideoPrivate); - DEBUG ((DEBUG_INFO, "BiosVideoCheckForVga - %r\n", Status)); - } else { - Status =3D EFI_UNSUPPORTED; - } - } - - if (EFI_ERROR (Status)) { - // - // Free GOP mode structure if it is not freed before - // VgaMiniPort does not need this structure any more - // - if (BiosVideoPrivate->GraphicsOutput.Mode !=3D NULL) { - if (BiosVideoPrivate->GraphicsOutput.Mode->Info !=3D NULL) { - FreePool (BiosVideoPrivate->GraphicsOutput.Mode->Info); - BiosVideoPrivate->GraphicsOutput.Mode->Info =3D NULL; - } - - FreePool (BiosVideoPrivate->GraphicsOutput.Mode); - BiosVideoPrivate->GraphicsOutput.Mode =3D NULL; - } - - // - // Neither VBE nor the standard 640x480 16 color VGA mode are suppor= ted, so do - // not produce the Graphics Output protocol. Instead, produce the V= GA MiniPort Protocol. - // - BiosVideoPrivate->ProduceGraphicsOutput =3D FALSE; - - // - // INT services are available, so on the 80x25 and 80x50 text mode a= re supported - // - BiosVideoPrivate->VgaMiniPort.MaxMode =3D 2; - } - } - - ProtocolInstalled =3D FALSE; - - if (BiosVideoPrivate->ProduceGraphicsOutput) { - // - // Creat child handle and install Graphics Output Protocol,EDID Discov= ered/Active Protocol - // - Status =3D gBS->InstallMultipleProtocolInterfaces ( - &BiosVideoPrivate->Handle, - &gEfiGraphicsOutputProtocolGuid, - &BiosVideoPrivate->GraphicsOutput, - &gEfiEdidDiscoveredProtocolGuid, - &BiosVideoPrivate->EdidDiscovered, - &gEfiEdidActiveProtocolGuid, - &BiosVideoPrivate->EdidActive, - NULL - ); - - if (!EFI_ERROR (Status)) { - // - // Open the Parent Handle for the child - // - Status =3D gBS->OpenProtocol ( - ParentHandle, - &gEfiPciIoProtocolGuid, - (VOID **)&BiosVideoPrivate->PciIo, - This->DriverBindingHandle, - BiosVideoPrivate->Handle, - EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER - ); - if (EFI_ERROR (Status)) { - goto Done; - } - - ProtocolInstalled =3D TRUE; - } - } - - if (!ProtocolInstalled) { - // - // Install VGA Mini Port Protocol - // - Status =3D gBS->InstallMultipleProtocolInterfaces ( - &ParentHandle, - &gEfiVgaMiniPortProtocolGuid, - &BiosVideoPrivate->VgaMiniPort, - NULL - ); - } - -Done: - if (EFI_ERROR (Status)) { - if ((BiosVideoPrivate !=3D NULL) && (BiosVideoPrivate->ExitBootService= sEvent !=3D NULL)) { - gBS->CloseEvent (BiosVideoPrivate->ExitBootServicesEvent); - } - - // - // Free private data structure - // - BiosVideoDeviceReleaseResource (BiosVideoPrivate); - } - - return Status; -} - -/** - Deregister an video child handle and free resources. - - @param This Protocol instance pointer. - @param Controller Video controller handle - @param Handle Video child handle - - @return EFI_STATUS - -**/ -EFI_STATUS -BiosVideoChildHandleUninstall ( - EFI_DRIVER_BINDING_PROTOCOL *This, - EFI_HANDLE Controller, - EFI_HANDLE Handle - ) -{ - EFI_STATUS Status; - EFI_IA32_REGISTER_SET Regs; - EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput; - EFI_VGA_MINI_PORT_PROTOCOL *VgaMiniPort; - BIOS_VIDEO_DEV *BiosVideoPrivate; - EFI_PCI_IO_PROTOCOL *PciIo; - - BiosVideoPrivate =3D NULL; - GraphicsOutput =3D NULL; - PciIo =3D NULL; - Status =3D EFI_UNSUPPORTED; - - Status =3D gBS->OpenProtocol ( - Handle, - &gEfiGraphicsOutputProtocolGuid, - (VOID **)&GraphicsOutput, - This->DriverBindingHandle, - Handle, - EFI_OPEN_PROTOCOL_GET_PROTOCOL - ); - if (!EFI_ERROR (Status)) { - BiosVideoPrivate =3D BIOS_VIDEO_DEV_FROM_GRAPHICS_OUTPUT_THIS (Graphic= sOutput); - } - - if (EFI_ERROR (Status)) { - Status =3D gBS->OpenProtocol ( - Handle, - &gEfiVgaMiniPortProtocolGuid, - (VOID **)&VgaMiniPort, - This->DriverBindingHandle, - Handle, - EFI_OPEN_PROTOCOL_GET_PROTOCOL - ); - if (!EFI_ERROR (Status)) { - BiosVideoPrivate =3D BIOS_VIDEO_DEV_FROM_VGA_MINI_PORT_THIS (VgaMini= Port); - } - } - - if (BiosVideoPrivate =3D=3D NULL) { - return EFI_UNSUPPORTED; - } - - // - // Set the 80x25 Text VGA Mode - // - Regs.H.AH =3D 0x00; - Regs.H.AL =3D 0x03; - BiosVideoPrivate->LegacyBios->Int86 (BiosVideoPrivate->LegacyBios, 0x10,= &Regs); - - Regs.H.AH =3D 0x11; - Regs.H.AL =3D 0x14; - Regs.H.BL =3D 0; - BiosVideoPrivate->LegacyBios->Int86 (BiosVideoPrivate->LegacyBios, 0x10,= &Regs); - - // - // Close PCI I/O protocol that opened by child handle - // - Status =3D gBS->CloseProtocol ( - Controller, - &gEfiPciIoProtocolGuid, - This->DriverBindingHandle, - Handle - ); - - // - // Uninstall protocols on child handle - // - if (BiosVideoPrivate->ProduceGraphicsOutput) { - Status =3D gBS->UninstallMultipleProtocolInterfaces ( - BiosVideoPrivate->Handle, - &gEfiDevicePathProtocolGuid, - BiosVideoPrivate->GopDevicePath, - &gEfiGraphicsOutputProtocolGuid, - &BiosVideoPrivate->GraphicsOutput, - &gEfiEdidDiscoveredProtocolGuid, - &BiosVideoPrivate->EdidDiscovered, - &gEfiEdidActiveProtocolGuid, - &BiosVideoPrivate->EdidActive, - NULL - ); - } - - if (!BiosVideoPrivate->ProduceGraphicsOutput) { - Status =3D gBS->UninstallMultipleProtocolInterfaces ( - Controller, - &gEfiVgaMiniPortProtocolGuid, - &BiosVideoPrivate->VgaMiniPort, - NULL - ); - } - - if (EFI_ERROR (Status)) { - gBS->OpenProtocol ( - Controller, - &gEfiPciIoProtocolGuid, - (VOID **)&PciIo, - This->DriverBindingHandle, - Handle, - EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER - ); - return Status; - } - - if (PcdGetBool (PcdBiosVideoSetTextVgaModeEnable)) { - // - // Close EXIT_BOOT_SERIVES Event - // - gBS->CloseEvent (BiosVideoPrivate->ExitBootServicesEvent); - } - - // - // Release all allocated resources - // - BiosVideoDeviceReleaseResource (BiosVideoPrivate); - - return EFI_SUCCESS; -} - -/** - Release resource for biso video instance. - - @param BiosVideoPrivate Video child device private data structure - -**/ -VOID -BiosVideoDeviceReleaseResource ( - BIOS_VIDEO_DEV *BiosVideoPrivate - ) -{ - if (BiosVideoPrivate =3D=3D NULL) { - return; - } - - // - // Release all the resourses occupied by the BIOS_VIDEO_DEV - // - - // - // Free VGA Frame Buffer - // - if (BiosVideoPrivate->VgaFrameBuffer !=3D NULL) { - FreePool (BiosVideoPrivate->VgaFrameBuffer); - } - - // - // Free VBE Frame Buffer - // - if (BiosVideoPrivate->VbeFrameBuffer !=3D NULL) { - FreePool (BiosVideoPrivate->VbeFrameBuffer); - } - - // - // Free line buffer - // - if (BiosVideoPrivate->LineBuffer !=3D NULL) { - FreePool (BiosVideoPrivate->LineBuffer); - } - - // - // Free mode data - // - if (BiosVideoPrivate->ModeData !=3D NULL) { - FreePool (BiosVideoPrivate->ModeData); - } - - // - // Free memory allocated below 1MB - // - if (BiosVideoPrivate->PagesBelow1MB !=3D 0) { - gBS->FreePages (BiosVideoPrivate->PagesBelow1MB, BiosVideoPrivate->Num= berOfPagesBelow1MB); - } - - if (BiosVideoPrivate->VbeSaveRestorePages !=3D 0) { - gBS->FreePages (BiosVideoPrivate->VbeSaveRestoreBuffer, BiosVideoPriva= te->VbeSaveRestorePages); - } - - // - // Free graphics output protocol occupied resource - // - if (BiosVideoPrivate->GraphicsOutput.Mode !=3D NULL) { - if (BiosVideoPrivate->GraphicsOutput.Mode->Info !=3D NULL) { - FreePool (BiosVideoPrivate->GraphicsOutput.Mode->Info); - BiosVideoPrivate->GraphicsOutput.Mode->Info =3D NULL; - } - - FreePool (BiosVideoPrivate->GraphicsOutput.Mode); - BiosVideoPrivate->GraphicsOutput.Mode =3D NULL; - } - - // - // Free EDID discovered protocol occupied resource - // - if (BiosVideoPrivate->EdidDiscovered.Edid !=3D NULL) { - FreePool (BiosVideoPrivate->EdidDiscovered.Edid); - } - - // - // Free EDID active protocol occupied resource - // - if (BiosVideoPrivate->EdidActive.Edid !=3D NULL) { - FreePool (BiosVideoPrivate->EdidActive.Edid); - } - - if (BiosVideoPrivate->GopDevicePath !=3D NULL) { - FreePool (BiosVideoPrivate->GopDevicePath); - } - - FreePool (BiosVideoPrivate); - - return; -} - -/** - Generate a search key for a specified timing data. - - @param EdidTiming Pointer to EDID timing - - @return The 32 bit unique key for search. - -**/ -UINT32 -CalculateEdidKey ( - VESA_BIOS_EXTENSIONS_EDID_TIMING *EdidTiming - ) -{ - UINT32 Key; - - // - // Be sure no conflicts for all standard timing defined by VESA. - // - Key =3D (EdidTiming->HorizontalResolution * 2) + EdidTiming->VerticalRes= olution; - return Key; -} - -/** - Parse the Established Timing and Standard Timing in EDID data block. - - @param EdidBuffer Pointer to EDID data block - @param ValidEdidTiming Valid EDID timing information - - @retval TRUE The EDID data is valid. - @retval FALSE The EDID data is invalid. - -**/ -BOOLEAN -ParseEdidData ( - UINT8 *EdidBuffer, - VESA_BIOS_EXTENSIONS_VALID_EDID_TIMING *ValidEdidTiming - ) -{ - UINT8 CheckSum; - UINT32 Index; - UINT32 ValidNumber; - UINT32 TimingBits; - UINT8 *BufferIndex; - UINT16 HorizontalResolution; - UINT16 VerticalResolution; - UINT8 AspectRatio; - UINT8 RefreshRate; - VESA_BIOS_EXTENSIONS_EDID_TIMING TempTiming; - VESA_BIOS_EXTENSIONS_EDID_DATA_BLOCK *EdidDataBlock; - - EdidDataBlock =3D (VESA_BIOS_EXTENSIONS_EDID_DATA_BLOCK *)EdidBuffer; - - // - // Check the checksum of EDID data - // - CheckSum =3D 0; - for (Index =3D 0; Index < VESA_BIOS_EXTENSIONS_EDID_BLOCK_SIZE; Index++)= { - CheckSum =3D (UINT8)(CheckSum + EdidBuffer[Index]); - } - - if (CheckSum !=3D 0) { - return FALSE; - } - - ValidNumber =3D 0; - gBS->SetMem (ValidEdidTiming, sizeof (VESA_BIOS_EXTENSIONS_VALID_EDID_TI= MING), 0); - - if ((EdidDataBlock->EstablishedTimings[0] !=3D 0) || - (EdidDataBlock->EstablishedTimings[1] !=3D 0) || - (EdidDataBlock->EstablishedTimings[2] !=3D 0) - ) - { - // - // Established timing data - // - TimingBits =3D EdidDataBlock->EstablishedTimings[0] | - (EdidDataBlock->EstablishedTimings[1] << 8) | - ((EdidDataBlock->EstablishedTimings[2] & 0x80) << 9); - for (Index =3D 0; Index < VESA_BIOS_EXTENSIONS_EDID_ESTABLISHED_TIMING= _MAX_NUMBER; Index++) { - if ((TimingBits & 0x1) !=3D 0) { - DEBUG (( - DEBUG_INFO, - "Established Timing: %d x %d\n", - mEstablishedEdidTiming[Index].HorizontalResolution, - mEstablishedEdidTiming[Index].VerticalResolution - )); - ValidEdidTiming->Key[ValidNumber] =3D CalculateEdidKey (&mEstablis= hedEdidTiming[Index]); - ValidNumber++; - } - - TimingBits =3D TimingBits >> 1; - } - } - - // - // Parse the standard timing data - // - BufferIndex =3D &EdidDataBlock->StandardTimingIdentification[0]; - for (Index =3D 0; Index < 8; Index++) { - // - // Check if this is a valid Standard Timing entry - // VESA documents unused fields should be set to 01h - // - if ((BufferIndex[0] !=3D 0x1) && (BufferIndex[1] !=3D 0x1)) { - // - // A valid Standard Timing - // - HorizontalResolution =3D (UINT16)(BufferIndex[0] * 8 + 248); - AspectRatio =3D (UINT8)(BufferIndex[1] >> 6); - switch (AspectRatio) { - case 0: - VerticalResolution =3D (UINT16)(HorizontalResolution / 16 * 10); - break; - case 1: - VerticalResolution =3D (UINT16)(HorizontalResolution / 4 * 3); - break; - case 2: - VerticalResolution =3D (UINT16)(HorizontalResolution / 5 * 4); - break; - case 3: - VerticalResolution =3D (UINT16)(HorizontalResolution / 16 * 9); - break; - default: - VerticalResolution =3D (UINT16)(HorizontalResolution / 4 * 3); - break; - } - - RefreshRate =3D (UINT8)((BufferIndex[1] & 0x1f) + 60); - DEBUG ((DEBUG_INFO, "Standard Timing: %d x %d\n", HorizontalResoluti= on, VerticalResolution)); - TempTiming.HorizontalResolution =3D HorizontalResolution; - TempTiming.VerticalResolution =3D VerticalResolution; - TempTiming.RefreshRate =3D RefreshRate; - ValidEdidTiming->Key[ValidNumber] =3D CalculateEdidKey (&TempTiming); - ValidNumber++; - } - - BufferIndex +=3D 2; - } - - // - // Parse the Detailed Timing data - // - BufferIndex =3D &EdidDataBlock->DetailedTimingDescriptions[0]; - for (Index =3D 0; Index < 4; Index++, BufferIndex +=3D VESA_BIOS_EXTENSI= ONS_DETAILED_TIMING_EACH_DESCRIPTOR_SIZE) { - if ((BufferIndex[0] =3D=3D 0x0) && (BufferIndex[1] =3D=3D 0x0)) { - // - // Check if this is a valid Detailed Timing Descriptor - // If first 2 bytes are zero, it is monitor descriptor other than de= tailed timing descriptor - // - continue; - } - - // - // Calculate Horizontal and Vertical resolution - // - TempTiming.HorizontalResolution =3D ((UINT16)(BufferIndex[4] & 0xF0) <= < 4) | (BufferIndex[2]); - TempTiming.VerticalResolution =3D ((UINT16)(BufferIndex[7] & 0xF0) <= < 4) | (BufferIndex[5]); - DEBUG (( - DEBUG_INFO, - "Detailed Timing %d: %d x %d\n", - Index, - TempTiming.HorizontalResolution, - TempTiming.VerticalResolution - )); - ValidEdidTiming->Key[ValidNumber] =3D CalculateEdidKey (&TempTiming); - ValidNumber++; - } - - ValidEdidTiming->ValidNumber =3D ValidNumber; - return TRUE; -} - -/** - Search a specified Timing in all the valid EDID timings. - - @param ValidEdidTiming All valid EDID timing information. - @param EdidTiming The Timing to search for. - - @retval TRUE Found. - @retval FALSE Not found. - -**/ -BOOLEAN -SearchEdidTiming ( - VESA_BIOS_EXTENSIONS_VALID_EDID_TIMING *ValidEdidTiming, - VESA_BIOS_EXTENSIONS_EDID_TIMING *EdidTiming - ) -{ - UINT32 Index; - UINT32 Key; - - Key =3D CalculateEdidKey (EdidTiming); - - for (Index =3D 0; Index < ValidEdidTiming->ValidNumber; Index++) { - if (Key =3D=3D ValidEdidTiming->Key[Index]) { - return TRUE; - } - } - - return FALSE; -} - -/** - Check if all video child handles have been uninstalled. - - @param Controller Video controller handle - - @return TRUE Child handles exist. - @return FALSE All video child handles have been uninsta= lled. - -**/ -BOOLEAN -HasChildHandle ( - IN EFI_HANDLE Controller - ) -{ - UINTN Index; - EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *OpenInfoBuffer; - UINTN EntryCount; - BOOLEAN HasChild; - - EntryCount =3D 0; - HasChild =3D FALSE; - gBS->OpenProtocolInformation ( - Controller, - &gEfiPciIoProtocolGuid, - &OpenInfoBuffer, - &EntryCount - ); - for (Index =3D 0; Index < EntryCount; Index++) { - if ((OpenInfoBuffer[Index].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CON= TROLLER) !=3D 0) { - HasChild =3D TRUE; - } - } - - return HasChild; -} - -/** - Check for VBE device. - - @param BiosVideoPrivate Pointer to BIOS_VIDEO_DEV structure - - @retval EFI_SUCCESS VBE device found - -**/ -EFI_STATUS -BiosVideoCheckForVbe ( - IN OUT BIOS_VIDEO_DEV *BiosVideoPrivate - ) -{ - EFI_STATUS Status; - EFI_IA32_REGISTER_SET Regs; - UINT16 *ModeNumberPtr; - UINT16 VbeModeNumber; - BOOLEAN ModeFound; - BOOLEAN EdidFound; - BIOS_VIDEO_MODE_DATA *ModeBuffer; - BIOS_VIDEO_MODE_DATA *CurrentModeData; - UINTN PreferMode; - UINTN ModeNumber; - VESA_BIOS_EXTENSIONS_EDID_TIMING Timing; - VESA_BIOS_EXTENSIONS_VALID_EDID_TIMING ValidEdidTiming; - EFI_EDID_OVERRIDE_PROTOCOL *EdidOverride; - UINT32 EdidAttributes; - BOOLEAN EdidOverrideFound; - UINTN EdidOverrideDataSize; - UINT8 *EdidOverrideDataBlock; - UINTN EdidActiveDataSize; - UINT8 *EdidActiveDataBlock; - UINT32 HighestHorizontalResolution; - UINT32 HighestVerticalResolution; - UINTN HighestResolutionMode; - - EdidFound =3D TRUE; - EdidOverrideFound =3D FALSE; - EdidOverrideDataBlock =3D NULL; - EdidActiveDataSize =3D 0; - EdidActiveDataBlock =3D NULL; - HighestHorizontalResolution =3D 0; - HighestVerticalResolution =3D 0; - HighestResolutionMode =3D 0; - - // - // Allocate buffer under 1MB for VBE data structures - // - BiosVideoPrivate->NumberOfPagesBelow1MB =3D EFI_SIZE_TO_PAGES ( - sizeof (VESA_BIOS_EXTENSIONS= _INFORMATION_BLOCK) + - sizeof (VESA_BIOS_EXTENSIONS= _MODE_INFORMATION_BLOCK) + - sizeof (VESA_BIOS_EXTENSIONS= _EDID_DATA_BLOCK) + - sizeof (VESA_BIOS_EXTENSIONS= _CRTC_INFORMATION_BLOCK) - ); - - BiosVideoPrivate->PagesBelow1MB =3D 0x00100000 - 1; - - Status =3D gBS->AllocatePages ( - AllocateMaxAddress, - EfiBootServicesData, - BiosVideoPrivate->NumberOfPagesBelow1MB, - &BiosVideoPrivate->PagesBelow1MB - ); - if (EFI_ERROR (Status)) { - return Status; - } - - ZeroMem (&ValidEdidTiming, sizeof (VESA_BIOS_EXTENSIONS_VALID_EDID_TIMIN= G)); - - // - // Fill in the VBE related data structures - // - BiosVideoPrivate->VbeInformationBlock =3D (VESA_BIOS_EXTENSIONS_INFO= RMATION_BLOCK *)(UINTN)(BiosVideoPrivate->PagesBelow1MB); - BiosVideoPrivate->VbeModeInformationBlock =3D (VESA_BIOS_EXTENSIONS_MODE= _INFORMATION_BLOCK *)(BiosVideoPrivate->VbeInformationBlock + 1); - BiosVideoPrivate->VbeEdidDataBlock =3D (VESA_BIOS_EXTENSIONS_EDID= _DATA_BLOCK *)(BiosVideoPrivate->VbeModeInformationBlock + 1); - BiosVideoPrivate->VbeCrtcInformationBlock =3D (VESA_BIOS_EXTENSIONS_CRTC= _INFORMATION_BLOCK *)(BiosVideoPrivate->VbeEdidDataBlock + 1); - BiosVideoPrivate->VbeSaveRestorePages =3D 0; - BiosVideoPrivate->VbeSaveRestoreBuffer =3D 0; - - // - // Test to see if the Video Adapter is compliant with VBE 3.0 - // - gBS->SetMem (&Regs, sizeof (Regs), 0); - Regs.X.AX =3D VESA_BIOS_EXTENSIONS_RETURN_CONTROLLER_INFORMATION; - gBS->SetMem (BiosVideoPrivate->VbeInformationBlock, sizeof (VESA_BIOS_EX= TENSIONS_INFORMATION_BLOCK), 0); - BiosVideoPrivate->VbeInformationBlock->VESASignature =3D VESA_BIOS_EXTEN= SIONS_VBE2_SIGNATURE; - Regs.X.ES =3D EFI_SEGMENT ((U= INTN)BiosVideoPrivate->VbeInformationBlock); - Regs.X.DI =3D EFI_OFFSET ((UI= NTN)BiosVideoPrivate->VbeInformationBlock); - - BiosVideoPrivate->LegacyBios->Int86 (BiosVideoPrivate->LegacyBios, 0x10,= &Regs); - - Status =3D EFI_DEVICE_ERROR; - - // - // See if the VESA call succeeded - // - if (Regs.X.AX !=3D VESA_BIOS_EXTENSIONS_STATUS_SUCCESS) { - return Status; - } - - // - // Check for 'VESA' signature - // - if (BiosVideoPrivate->VbeInformationBlock->VESASignature !=3D VESA_BIOS_= EXTENSIONS_VESA_SIGNATURE) { - return Status; - } - - // - // Check to see if this is VBE 2.0 or higher - // - if (BiosVideoPrivate->VbeInformationBlock->VESAVersion < VESA_BIOS_EXTEN= SIONS_VERSION_2_0) { - return Status; - } - - EdidFound =3D FALSE; - EdidAttributes =3D 0xff; - EdidOverrideDataSize =3D 0; - - // - // Find EDID Override protocol firstly, this protocol is installed by pl= atform if needed. - // - Status =3D gBS->LocateProtocol ( - &gEfiEdidOverrideProtocolGuid, - NULL, - (VOID **)&EdidOverride - ); - if (!EFI_ERROR (Status)) { - // - // Allocate double size of VESA_BIOS_EXTENSIONS_EDID_BLOCK_SIZE to avo= id overflow - // - EdidOverrideDataBlock =3D AllocatePool (VESA_BIOS_EXTENSIONS_EDID_BLOC= K_SIZE * 2); - if (NULL =3D=3D EdidOverrideDataBlock) { - Status =3D EFI_OUT_OF_RESOURCES; - goto Done; - } - - Status =3D EdidOverride->GetEdid ( - EdidOverride, - BiosVideoPrivate->Handle, - &EdidAttributes, - &EdidOverrideDataSize, - (UINT8 **)&EdidOverrideDataBlock - ); - if (!EFI_ERROR (Status) && - (EdidAttributes =3D=3D 0) && - (EdidOverrideDataSize !=3D 0)) - { - // - // Succeeded to get EDID Override Data - // - EdidOverrideFound =3D TRUE; - } - } - - if (!EdidOverrideFound || (EdidAttributes =3D=3D EFI_EDID_OVERRIDE_DONT_= OVERRIDE)) { - // - // If EDID Override data doesn't exist or EFI_EDID_OVERRIDE_DONT_OVERR= IDE returned, - // read EDID information through INT10 call - // - - gBS->SetMem (&Regs, sizeof (Regs), 0); - Regs.X.AX =3D VESA_BIOS_EXTENSIONS_EDID; - Regs.X.BX =3D 1; - Regs.X.CX =3D 0; - Regs.X.DX =3D 0; - Regs.X.ES =3D EFI_SEGMENT ((UINTN)BiosVideoPrivate->VbeEdidDataBlock); - Regs.X.DI =3D EFI_OFFSET ((UINTN)BiosVideoPrivate->VbeEdidDataBlock); - - BiosVideoPrivate->LegacyBios->Int86 (BiosVideoPrivate->LegacyBios, 0x1= 0, &Regs); - // - // See if the VESA call succeeded - // - if (Regs.X.AX =3D=3D VESA_BIOS_EXTENSIONS_STATUS_SUCCESS) { - // - // Set EDID Discovered Data - // - BiosVideoPrivate->EdidDiscovered.SizeOfEdid =3D VESA_BIOS_EXTENSIONS= _EDID_BLOCK_SIZE; - BiosVideoPrivate->EdidDiscovered.Edid =3D (UINT8 *)AllocateCop= yPool ( - VESA_BIOS_E= XTENSIONS_EDID_BLOCK_SIZE, - BiosVideoPr= ivate->VbeEdidDataBlock - ); - - if (NULL =3D=3D BiosVideoPrivate->EdidDiscovered.Edid) { - Status =3D EFI_OUT_OF_RESOURCES; - goto Done; - } - - EdidFound =3D TRUE; - } - } - - if (EdidFound) { - EdidActiveDataSize =3D VESA_BIOS_EXTENSIONS_EDID_BLOCK_SIZE; - EdidActiveDataBlock =3D BiosVideoPrivate->EdidDiscovered.Edid; - } else if (EdidOverrideFound) { - EdidActiveDataSize =3D EdidOverrideDataSize; - EdidActiveDataBlock =3D EdidOverrideDataBlock; - EdidFound =3D TRUE; - } - - if (EdidFound) { - // - // Parse EDID data structure to retrieve modes supported by monitor - // - if (ParseEdidData ((UINT8 *)EdidActiveDataBlock, &ValidEdidTiming)) { - // - // Copy EDID Override Data to EDID Active Data - // - BiosVideoPrivate->EdidActive.SizeOfEdid =3D (UINT32)EdidActiveDataSi= ze; - BiosVideoPrivate->EdidActive.Edid =3D (UINT8 *)AllocateCopyPoo= l ( - EdidActiveDataS= ize, - EdidActiveDataB= lock - ); - if (NULL =3D=3D BiosVideoPrivate->EdidActive.Edid) { - Status =3D EFI_OUT_OF_RESOURCES; - goto Done; - } - } - } else { - BiosVideoPrivate->EdidActive.SizeOfEdid =3D 0; - BiosVideoPrivate->EdidActive.Edid =3D NULL; - EdidFound =3D FALSE; - } - - // - // Walk through the mode list to see if there is at least one mode the i= s compatible with the EDID mode - // - ModeNumberPtr =3D (UINT16 *) - ( - (((UINTN)BiosVideoPrivate->VbeInformationBlock->VideoMo= dePtr & 0xffff0000) >> 12) | - ((UINTN)BiosVideoPrivate->VbeInformationBlock->VideoMod= ePtr & 0x0000ffff) - ); - - PreferMode =3D 0; - ModeNumber =3D 0; - - // - // ModeNumberPtr may be not 16-byte aligned, so ReadUnaligned16 is used = to access the buffer pointed by ModeNumberPtr. - // - for (VbeModeNumber =3D ReadUnaligned16 (ModeNumberPtr); - VbeModeNumber !=3D VESA_BIOS_EXTENSIONS_END_OF_MODE_LIST; - VbeModeNumber =3D ReadUnaligned16 (++ModeNumberPtr)) - { - // - // Make sure this is a mode number defined by the VESA VBE specificati= on. If it isn'tm then skip this mode number. - // - if ((VbeModeNumber & VESA_BIOS_EXTENSIONS_MODE_NUMBER_VESA) =3D=3D 0) { - continue; - } - - // - // Get the information about the mode - // - gBS->SetMem (&Regs, sizeof (Regs), 0); - Regs.X.AX =3D VESA_BIOS_EXTENSIONS_RETURN_MODE_INFORMATION; - Regs.X.CX =3D VbeModeNumber; - gBS->SetMem (BiosVideoPrivate->VbeModeInformationBlock, sizeof (VESA_B= IOS_EXTENSIONS_MODE_INFORMATION_BLOCK), 0); - Regs.X.ES =3D EFI_SEGMENT ((UINTN)BiosVideoPrivate->VbeModeInformation= Block); - Regs.X.DI =3D EFI_OFFSET ((UINTN)BiosVideoPrivate->VbeModeInformationB= lock); - - BiosVideoPrivate->LegacyBios->Int86 (BiosVideoPrivate->LegacyBios, 0x1= 0, &Regs); - - // - // See if the call succeeded. If it didn't, then try the next mode. - // - if (Regs.X.AX !=3D VESA_BIOS_EXTENSIONS_STATUS_SUCCESS) { - continue; - } - - // - // See if the mode supports color. If it doesn't then try the next mo= de. - // - if ((BiosVideoPrivate->VbeModeInformationBlock->ModeAttributes & VESA_= BIOS_EXTENSIONS_MODE_ATTRIBUTE_COLOR) =3D=3D 0) { - continue; - } - - // - // See if the mode supports graphics. If it doesn't then try the next= mode. - // - if ((BiosVideoPrivate->VbeModeInformationBlock->ModeAttributes & VESA_= BIOS_EXTENSIONS_MODE_ATTRIBUTE_GRAPHICS) =3D=3D 0) { - continue; - } - - // - // See if the mode supports a linear frame buffer. If it doesn't then= try the next mode. - // - if ((BiosVideoPrivate->VbeModeInformationBlock->ModeAttributes & VESA_= BIOS_EXTENSIONS_MODE_ATTRIBUTE_LINEAR_FRAME_BUFFER) =3D=3D 0) { - continue; - } - - // - // See if the mode supports 32 bit color. If it doesn't then try the = next mode. - // 32 bit mode can be implemented by 24 Bits Per Pixels. Also make sur= e the - // number of bits per pixel is a multiple of 8 or more than 32 bits pe= r pixel - // - if (BiosVideoPrivate->VbeModeInformationBlock->BitsPerPixel < 24) { - continue; - } - - if (BiosVideoPrivate->VbeModeInformationBlock->BitsPerPixel > 32) { - continue; - } - - if ((BiosVideoPrivate->VbeModeInformationBlock->BitsPerPixel % 8) !=3D= 0) { - continue; - } - - // - // See if the physical base pointer for the linear mode is valid. If = it isn't then try the next mode. - // - if (BiosVideoPrivate->VbeModeInformationBlock->PhysBasePtr =3D=3D 0) { - continue; - } - - DEBUG (( - DEBUG_INFO, - "Video Controller Mode 0x%x: %d x %d\n", - VbeModeNumber, - BiosVideoPrivate->VbeModeInformationBlock->XResolution, - BiosVideoPrivate->VbeModeInformationBlock->YResolution - )); - - if (EdidFound && (ValidEdidTiming.ValidNumber > 0)) { - // - // EDID exist, check whether this mode match with any mode in EDID - // - Timing.HorizontalResolution =3D BiosVideoPrivate->VbeModeInformation= Block->XResolution; - Timing.VerticalResolution =3D BiosVideoPrivate->VbeModeInformation= Block->YResolution; - if (!SearchEdidTiming (&ValidEdidTiming, &Timing)) { - // - // When EDID comes from INT10 call, EDID does not include 800x600,= 640x480 and 1024x768, - // but INT10 can support these modes, we add them into GOP mode. - // - if ((BiosVideoPrivate->EdidDiscovered.SizeOfEdid !=3D 0) && - !(((Timing.HorizontalResolution) =3D=3D 1024) && (Timing.Verti= calResolution =3D=3D 768)) && - !(((Timing.HorizontalResolution) =3D=3D 800) && (Timing.Vertic= alResolution =3D=3D 600)) && - !(((Timing.HorizontalResolution) =3D=3D 640) && (Timing.Vertic= alResolution =3D=3D 480))) - { - continue; - } - } - } - - // - // Select a reasonable mode to be set for current display mode - // - ModeFound =3D FALSE; - - if ((BiosVideoPrivate->VbeModeInformationBlock->XResolution =3D=3D 102= 4) && - (BiosVideoPrivate->VbeModeInformationBlock->YResolution =3D=3D 768) - ) - { - ModeFound =3D TRUE; - } - - if ((BiosVideoPrivate->VbeModeInformationBlock->XResolution =3D=3D 800= ) && - (BiosVideoPrivate->VbeModeInformationBlock->YResolution =3D=3D 600) - ) - { - ModeFound =3D TRUE; - PreferMode =3D ModeNumber; - } - - if ((BiosVideoPrivate->VbeModeInformationBlock->XResolution =3D=3D 640= ) && - (BiosVideoPrivate->VbeModeInformationBlock->YResolution =3D=3D 480) - ) - { - ModeFound =3D TRUE; - } - - if ((!EdidFound) && (!ModeFound)) { - // - // When no EDID exist, only select three possible resolutions, i.e. = 1024x768, 800x600, 640x480 - // - continue; - } - - // - // Record the highest resolution mode to set later - // - if ((BiosVideoPrivate->VbeModeInformationBlock->XResolution > HighestH= orizontalResolution) || - ((BiosVideoPrivate->VbeModeInformationBlock->XResolution =3D=3D Hi= ghestHorizontalResolution) && - (BiosVideoPrivate->VbeModeInformationBlock->YResolution > Highest= VerticalResolution))) - { - HighestHorizontalResolution =3D BiosVideoPrivate->VbeModeInformation= Block->XResolution; - HighestVerticalResolution =3D BiosVideoPrivate->VbeModeInformation= Block->YResolution; - HighestResolutionMode =3D ModeNumber; - } - - // - // Add mode to the list of available modes - // - ModeNumber++; - ModeBuffer =3D (BIOS_VIDEO_MODE_DATA *)AllocatePool ( - ModeNumber * sizeof (BIOS_VIDEO= _MODE_DATA) - ); - if (NULL =3D=3D ModeBuffer) { - Status =3D EFI_OUT_OF_RESOURCES; - goto Done; - } - - if (ModeNumber > 1) { - CopyMem ( - ModeBuffer, - BiosVideoPrivate->ModeData, - (ModeNumber - 1) * sizeof (BIOS_VIDEO_MODE_DATA) - ); - } - - if (BiosVideoPrivate->ModeData !=3D NULL) { - FreePool (BiosVideoPrivate->ModeData); - } - - CurrentModeData =3D &ModeBuffer[ModeNumber - 1]; - CurrentModeData->VbeModeNumber =3D VbeModeNumber; - if (BiosVideoPrivate->VbeInformationBlock->VESAVersion >=3D VESA_BIOS_= EXTENSIONS_VERSION_3_0) { - CurrentModeData->BytesPerScanLine =3D BiosVideoPrivate->VbeModeInfo= rmationBlock->LinBytesPerScanLine; - CurrentModeData->Red.Position =3D BiosVideoPrivate->VbeModeInfo= rmationBlock->LinRedFieldPosition; - CurrentModeData->Red.Mask =3D (UINT8)((1 << BiosVideoPrivat= e->VbeModeInformationBlock->LinRedMaskSize) - 1); - CurrentModeData->Blue.Position =3D BiosVideoPrivate->VbeModeInfo= rmationBlock->LinBlueFieldPosition; - CurrentModeData->Blue.Mask =3D (UINT8)((1 << BiosVideoPrivat= e->VbeModeInformationBlock->LinBlueMaskSize) - 1); - CurrentModeData->Green.Position =3D BiosVideoPrivate->VbeModeInfo= rmationBlock->LinGreenFieldPosition; - CurrentModeData->Green.Mask =3D (UINT8)((1 << BiosVideoPrivat= e->VbeModeInformationBlock->LinGreenMaskSize) - 1); - CurrentModeData->Reserved.Position =3D BiosVideoPrivate->VbeModeInfo= rmationBlock->LinRsvdFieldPosition; - CurrentModeData->Reserved.Mask =3D (UINT8)((1 << BiosVideoPrivat= e->VbeModeInformationBlock->LinRsvdMaskSize) - 1); - } else { - CurrentModeData->BytesPerScanLine =3D BiosVideoPrivate->VbeModeInfo= rmationBlock->BytesPerScanLine; - CurrentModeData->Red.Position =3D BiosVideoPrivate->VbeModeInfo= rmationBlock->RedFieldPosition; - CurrentModeData->Red.Mask =3D (UINT8)((1 << BiosVideoPrivat= e->VbeModeInformationBlock->RedMaskSize) - 1); - CurrentModeData->Blue.Position =3D BiosVideoPrivate->VbeModeInfo= rmationBlock->BlueFieldPosition; - CurrentModeData->Blue.Mask =3D (UINT8)((1 << BiosVideoPrivat= e->VbeModeInformationBlock->BlueMaskSize) - 1); - CurrentModeData->Green.Position =3D BiosVideoPrivate->VbeModeInfo= rmationBlock->GreenFieldPosition; - CurrentModeData->Green.Mask =3D (UINT8)((1 << BiosVideoPrivat= e->VbeModeInformationBlock->GreenMaskSize) - 1); - CurrentModeData->Reserved.Position =3D BiosVideoPrivate->VbeModeInfo= rmationBlock->RsvdFieldPosition; - CurrentModeData->Reserved.Mask =3D (UINT8)((1 << BiosVideoPrivat= e->VbeModeInformationBlock->RsvdMaskSize) - 1); - } - - CurrentModeData->PixelFormat =3D PixelBitMask; - if ((BiosVideoPrivate->VbeModeInformationBlock->BitsPerPixel =3D=3D 32= ) && - (CurrentModeData->Red.Mask =3D=3D 0xff) && (CurrentModeData->Green= .Mask =3D=3D 0xff) && (CurrentModeData->Blue.Mask =3D=3D 0xff)) - { - if ((CurrentModeData->Red.Position =3D=3D 0) && (CurrentModeData->Gr= een.Position =3D=3D 8) && (CurrentModeData->Blue.Position =3D=3D 16)) { - CurrentModeData->PixelFormat =3D PixelRedGreenBlueReserved8BitPerC= olor; - } else if ((CurrentModeData->Blue.Position =3D=3D 0) && (CurrentMode= Data->Green.Position =3D=3D 8) && (CurrentModeData->Red.Position =3D=3D 16)= ) { - CurrentModeData->PixelFormat =3D PixelBlueGreenRedReserved8BitPerC= olor; - } - } - - CurrentModeData->PixelBitMask.RedMask =3D ((UINT32)CurrentModeDat= a->Red.Mask) << CurrentModeData->Red.Position; - CurrentModeData->PixelBitMask.GreenMask =3D ((UINT32)CurrentModeDat= a->Green.Mask) << CurrentModeData->Green.Position; - CurrentModeData->PixelBitMask.BlueMask =3D ((UINT32)CurrentModeDat= a->Blue.Mask) << CurrentModeData->Blue.Position; - CurrentModeData->PixelBitMask.ReservedMask =3D ((UINT32)CurrentModeDat= a->Reserved.Mask) << CurrentModeData->Reserved.Position; - - CurrentModeData->LinearFrameBuffer =3D (VOID *)(UINTN)BiosVideoPriv= ate->VbeModeInformationBlock->PhysBasePtr; - CurrentModeData->HorizontalResolution =3D BiosVideoPrivate->VbeModeInf= ormationBlock->XResolution; - CurrentModeData->VerticalResolution =3D BiosVideoPrivate->VbeModeInf= ormationBlock->YResolution; - - CurrentModeData->BitsPerPixel =3D BiosVideoPrivate->VbeModeInformat= ionBlock->BitsPerPixel; - CurrentModeData->FrameBufferSize =3D CurrentModeData->BytesPerScanLine= * CurrentModeData->VerticalResolution; - // - // Make sure the FrameBufferSize does not exceed the max available fra= me buffer size reported by VEB. - // - ASSERT (CurrentModeData->FrameBufferSize <=3D ((UINT32)BiosVideoPrivat= e->VbeInformationBlock->TotalMemory * 64 * 1024)); - - BiosVideoPrivate->ModeData =3D ModeBuffer; - } - - // - // Check to see if we found any modes that are compatible with GRAPHICS = OUTPUT - // - if (ModeNumber =3D=3D 0) { - Status =3D EFI_DEVICE_ERROR; - goto Done; - } - - // - // Assign Gop's Blt function - // - BiosVideoPrivate->GraphicsOutput.Blt =3D BiosVideoGraphicsOutputVbeBlt; - - BiosVideoPrivate->GraphicsOutput.Mode->MaxMode =3D (UINT32)ModeNumber; - // - // Current mode is unknow till now, set it to an invalid mode. - // - BiosVideoPrivate->GraphicsOutput.Mode->Mode =3D GRAPHICS_OUTPUT_INVALIDE= _MODE_NUMBER; - - // - // Find the best mode to initialize - // - if ((PcdGet32 (PcdVideoHorizontalResolution) =3D=3D 0x0) || (PcdGet32 (P= cdVideoVerticalResolution) =3D=3D 0x0)) { - DEBUG_CODE ( - BIOS_VIDEO_MODE_DATA *ModeData; - ModeData =3D &BiosVideoPrivate->ModeData[HighestResolutionMode]; - DEBUG (( - DEBUG_INFO, - "BiosVideo set highest resolution %d x %d\n", - ModeData->HorizontalResolution, - ModeData->VerticalResolution - )); - ); - PreferMode =3D HighestResolutionMode; - } - - Status =3D BiosVideoGraphicsOutputSetMode (&BiosVideoPrivate->GraphicsOu= tput, (UINT32)PreferMode); - if (EFI_ERROR (Status)) { - for (PreferMode =3D 0; PreferMode < ModeNumber; PreferMode++) { - Status =3D BiosVideoGraphicsOutputSetMode ( - &BiosVideoPrivate->GraphicsOutput, - (UINT32)PreferMode - ); - if (!EFI_ERROR (Status)) { - break; - } - } - - if (PreferMode =3D=3D ModeNumber) { - // - // None mode is set successfully. - // - goto Done; - } - } - -Done: - // - // If there was an error, then free the mode structure - // - if (EFI_ERROR (Status)) { - if (BiosVideoPrivate->ModeData !=3D NULL) { - FreePool (BiosVideoPrivate->ModeData); - BiosVideoPrivate->ModeData =3D NULL; - BiosVideoPrivate->MaxMode =3D 0; - } - - if (EdidOverrideDataBlock !=3D NULL) { - FreePool (EdidOverrideDataBlock); - } - } - - return Status; -} - -/** - Check for VGA device. - - @param BiosVideoPrivate Pointer to BIOS_VIDEO_DEV structure - - @retval EFI_SUCCESS Standard VGA device found - -**/ -EFI_STATUS -BiosVideoCheckForVga ( - IN OUT BIOS_VIDEO_DEV *BiosVideoPrivate - ) -{ - EFI_STATUS Status; - BIOS_VIDEO_MODE_DATA *ModeBuffer; - - Status =3D EFI_UNSUPPORTED; - - // - // Assign Gop's Blt function - // - BiosVideoPrivate->GraphicsOutput.Blt =3D BiosVideoGraphicsOutputVgaBlt; - - // - // Add mode to the list of available modes - // caller should guarantee that Mode has been allocated. - // - ASSERT (BiosVideoPrivate->GraphicsOutput.Mode !=3D NULL); - BiosVideoPrivate->GraphicsOutput.Mode->MaxMode =3D 1; - - ModeBuffer =3D (BIOS_VIDEO_MODE_DATA *)AllocatePool ( - sizeof (BIOS_VIDEO_MODE_DATA) - ); - if (NULL =3D=3D ModeBuffer) { - Status =3D EFI_OUT_OF_RESOURCES; - goto Done; - } - - ModeBuffer->VbeModeNumber =3D 0x0012; - ModeBuffer->BytesPerScanLine =3D 640; - ModeBuffer->LinearFrameBuffer =3D (VOID *)(UINTN)(0xa0000); - ModeBuffer->HorizontalResolution =3D 640; - ModeBuffer->VerticalResolution =3D 480; - ModeBuffer->PixelFormat =3D PixelBltOnly; - ModeBuffer->BitsPerPixel =3D 8; - ModeBuffer->ColorDepth =3D 32; - ModeBuffer->RefreshRate =3D 60; - - BiosVideoPrivate->ModeData =3D ModeBuffer; - - // - // Test to see if the Video Adapter support the 640x480 16 color mode - // - BiosVideoPrivate->GraphicsOutput.Mode->Mode =3D GRAPHICS_OUTPUT_INVALIDE= _MODE_NUMBER; - Status =3D BiosVideoGraphicsOutputS= etMode (&BiosVideoPrivate->GraphicsOutput, 0); - -Done: - // - // If there was an error, then free the mode structure - // - if (EFI_ERROR (Status)) { - if (BiosVideoPrivate->ModeData !=3D NULL) { - FreePool (BiosVideoPrivate->ModeData); - BiosVideoPrivate->ModeData =3D NULL; - } - - if (BiosVideoPrivate->GraphicsOutput.Mode !=3D NULL) { - if (BiosVideoPrivate->GraphicsOutput.Mode->Info !=3D NULL) { - FreePool (BiosVideoPrivate->GraphicsOutput.Mode->Info); - BiosVideoPrivate->GraphicsOutput.Mode->Info =3D NULL; - } - - FreePool (BiosVideoPrivate->GraphicsOutput.Mode); - BiosVideoPrivate->GraphicsOutput.Mode =3D NULL; - } - } - - return Status; -} - -// -// Graphics Output Protocol Member Functions for VESA BIOS Extensions -// - -/** - Graphics Output protocol interface to get video mode. - - @param This Protocol instance pointer. - @param ModeNumber The mode number to return information on. - @param SizeOfInfo A pointer to the size, in bytes, of the I= nfo - buffer. - @param Info Caller allocated buffer that returns info= rmation - about ModeNumber. - - @retval EFI_SUCCESS Mode information returned. - @retval EFI_DEVICE_ERROR A hardware error occurred trying to retri= eve the - video mode. - @retval EFI_NOT_STARTED Video display is not initialized. Call Se= tMode () - @retval EFI_INVALID_PARAMETER One of the input args was NULL. - -**/ -EFI_STATUS -EFIAPI -BiosVideoGraphicsOutputQueryMode ( - IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This, - IN UINT32 ModeNumber, - OUT UINTN *SizeOfInfo, - OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION **Info - ) -{ - BIOS_VIDEO_DEV *BiosVideoPrivate; - BIOS_VIDEO_MODE_DATA *ModeData; - - BiosVideoPrivate =3D BIOS_VIDEO_DEV_FROM_GRAPHICS_OUTPUT_THIS (This); - - if (BiosVideoPrivate->HardwareNeedsStarting) { - REPORT_STATUS_CODE_WITH_DEVICE_PATH ( - EFI_ERROR_CODE | EFI_ERROR_MINOR, - EFI_PERIPHERAL_LOCAL_CONSOLE | EFI_P_EC_OUTPUT_ERROR, - BiosVideoPrivate->GopDevicePath - ); - return EFI_NOT_STARTED; - } - - if ((This =3D=3D NULL) || (Info =3D=3D NULL) || (SizeOfInfo =3D=3D NULL)= || (ModeNumber >=3D This->Mode->MaxMode)) { - return EFI_INVALID_PARAMETER; - } - - *Info =3D (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *)AllocatePool ( - sizeof (EFI_GRAPHICS_O= UTPUT_MODE_INFORMATION) - ); - if (NULL =3D=3D *Info) { - return EFI_OUT_OF_RESOURCES; - } - - *SizeOfInfo =3D sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION); - - ModeData =3D &BiosVideoPrivate->ModeData[ModeNumber= ]; - (*Info)->Version =3D 0; - (*Info)->HorizontalResolution =3D ModeData->HorizontalResolution; - (*Info)->VerticalResolution =3D ModeData->VerticalResolution; - (*Info)->PixelFormat =3D ModeData->PixelFormat; - CopyMem (&((*Info)->PixelInformation), &(ModeData->PixelBitMask), sizeof= (ModeData->PixelBitMask)); - - (*Info)->PixelsPerScanLine =3D (ModeData->BytesPerScanLine * 8) / ModeD= ata->BitsPerPixel; - - return EFI_SUCCESS; -} - -/** - Worker function to set video mode. - - @param BiosVideoPrivate Instance of BIOS_VIDEO_DEV. - @param ModeData The mode data to be set. - @param DevicePath Pointer to Device Path Protocol. - - @retval EFI_SUCCESS Graphics mode was changed. - @retval EFI_DEVICE_ERROR The device had an error and could not com= plete the - request. - @retval EFI_UNSUPPORTED ModeNumber is not supported by this devic= e. - -**/ -EFI_STATUS -BiosVideoSetModeWorker ( - IN BIOS_VIDEO_DEV *BiosVideoPrivate, - IN BIOS_VIDEO_MODE_DATA *ModeData, - IN EFI_DEVICE_PATH_PROTOCOL *DevicePath - ) -{ - EFI_STATUS Status; - EFI_IA32_REGISTER_SET Regs; - - if (BiosVideoPrivate->LineBuffer !=3D NULL) { - FreePool (BiosVideoPrivate->LineBuffer); - } - - if (BiosVideoPrivate->VgaFrameBuffer !=3D NULL) { - FreePool (BiosVideoPrivate->VgaFrameBuffer); - } - - if (BiosVideoPrivate->VbeFrameBuffer !=3D NULL) { - FreePool (BiosVideoPrivate->VbeFrameBuffer); - } - - BiosVideoPrivate->LineBuffer =3D (UINT8 *)AllocatePool ( - ModeData->BytesPerScanLine - ); - if (NULL =3D=3D BiosVideoPrivate->LineBuffer) { - return EFI_OUT_OF_RESOURCES; - } - - // - // Clear all registers - // - ZeroMem (&Regs, sizeof (Regs)); - - if (ModeData->VbeModeNumber < 0x100) { - // - // Allocate a working buffer for BLT operations to the VGA frame buffer - // - BiosVideoPrivate->VgaFrameBuffer =3D (UINT8 *)AllocatePool (4 * 480 * = 80); - if (NULL =3D=3D BiosVideoPrivate->VgaFrameBuffer) { - return EFI_OUT_OF_RESOURCES; - } - - // - // Set VGA Mode - // - Regs.X.AX =3D ModeData->VbeModeNumber; - BiosVideoPrivate->LegacyBios->Int86 (BiosVideoPrivate->LegacyBios, 0x1= 0, &Regs); - } else { - // - // Allocate a working buffer for BLT operations to the VBE frame buffer - // - BiosVideoPrivate->VbeFrameBuffer =3D - (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *)AllocatePool ( - ModeData->BytesPerScanLine * Mode= Data->VerticalResolution - ); - if (NULL =3D=3D BiosVideoPrivate->VbeFrameBuffer) { - return EFI_OUT_OF_RESOURCES; - } - - // - // Set VBE mode - // - Regs.X.AX =3D VESA_BIOS_EXTENSIONS_SET_MODE; - Regs.X.BX =3D (UINT16)(ModeData->VbeModeNumber | VESA_BIOS_EXTENSIONS_= MODE_NUMBER_LINEAR_FRAME_BUFFER); - ZeroMem (BiosVideoPrivate->VbeCrtcInformationBlock, sizeof (VESA_BIOS_= EXTENSIONS_CRTC_INFORMATION_BLOCK)); - Regs.X.ES =3D EFI_SEGMENT ((UINTN)BiosVideoPrivate->VbeCrtcInformation= Block); - Regs.X.DI =3D EFI_OFFSET ((UINTN)BiosVideoPrivate->VbeCrtcInformationB= lock); - BiosVideoPrivate->LegacyBios->Int86 (BiosVideoPrivate->LegacyBios, 0x1= 0, &Regs); - - // - // Check to see if the call succeeded - // - if (Regs.X.AX !=3D VESA_BIOS_EXTENSIONS_STATUS_SUCCESS) { - REPORT_STATUS_CODE_WITH_DEVICE_PATH ( - EFI_ERROR_CODE | EFI_ERROR_MINOR, - EFI_PERIPHERAL_LOCAL_CONSOLE | EFI_P_EC_OUTPUT_ERROR, - DevicePath - ); - return EFI_DEVICE_ERROR; - } - - // - // Initialize the state of the VbeFrameBuffer - // - Status =3D BiosVideoPrivate->PciIo->Mem.Read ( - BiosVideoPrivate->PciIo, - EfiPciIoWidthUint32, - EFI_PCI_IO_PASS_THROUGH_BAR, - (UINT64)(UINTN)ModeData->Linea= rFrameBuffer, - (ModeData->BytesPerScanLine * = ModeData->VerticalResolution) >> 2, - BiosVideoPrivate->VbeFrameBuff= er - ); - if (EFI_ERROR (Status)) { - return Status; - } - } - - return EFI_SUCCESS; -} - -/** - Graphics Output protocol interface to set video mode. - - @param This Protocol instance pointer. - @param ModeNumber The mode number to be set. - - @retval EFI_SUCCESS Graphics mode was changed. - @retval EFI_DEVICE_ERROR The device had an error and could not com= plete the - request. - @retval EFI_UNSUPPORTED ModeNumber is not supported by this devic= e. - -**/ -EFI_STATUS -EFIAPI -BiosVideoGraphicsOutputSetMode ( - IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This, - IN UINT32 ModeNumber - ) -{ - EFI_STATUS Status; - BIOS_VIDEO_DEV *BiosVideoPrivate; - BIOS_VIDEO_MODE_DATA *ModeData; - EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background; - - if (This =3D=3D NULL) { - return EFI_INVALID_PARAMETER; - } - - BiosVideoPrivate =3D BIOS_VIDEO_DEV_FROM_GRAPHICS_OUTPUT_THIS (This); - - ModeData =3D &BiosVideoPrivate->ModeData[ModeNumber]; - - if (ModeNumber >=3D This->Mode->MaxMode) { - return EFI_UNSUPPORTED; - } - - if (ModeNumber =3D=3D This->Mode->Mode) { - // - // Clear screen to black - // - ZeroMem (&Background, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)); - BiosVideoGraphicsOutputVbeBlt ( - This, - &Background, - EfiBltVideoFill, - 0, - 0, - 0, - 0, - ModeData->HorizontalResolution, - ModeData->VerticalResolution, - 0 - ); - return EFI_SUCCESS; - } - - Status =3D BiosVideoSetModeWorker (BiosVideoPrivate, ModeData, BiosVideo= Private->GopDevicePath); - if (EFI_ERROR (Status)) { - return Status; - } - - This->Mode->Mode =3D ModeNumber; - This->Mode->Info->Version =3D 0; - This->Mode->Info->HorizontalResolution =3D ModeData->HorizontalResolutio= n; - This->Mode->Info->VerticalResolution =3D ModeData->VerticalResolution; - This->Mode->Info->PixelFormat =3D ModeData->PixelFormat; - CopyMem (&(This->Mode->Info->PixelInformation), &(ModeData->PixelBitMask= ), sizeof (ModeData->PixelBitMask)); - This->Mode->Info->PixelsPerScanLine =3D (ModeData->BytesPerScanLine * 8= ) / ModeData->BitsPerPixel; - This->Mode->SizeOfInfo =3D sizeof (EFI_GRAPHICS_OUTPUT_MODE= _INFORMATION); - This->Mode->FrameBufferSize =3D ModeData->FrameBufferSize; - This->Mode->FrameBufferBase =3D (EFI_PHYSICAL_ADDRESS)(UINTN)Mod= eData->LinearFrameBuffer; - - BiosVideoPrivate->HardwareNeedsStarting =3D FALSE; - - return EFI_SUCCESS; -} - -/** - Update physical frame buffer, copy 4 bytes block, then copy remaining by= tes. - - @param PciIo The pointer of EFI_PCI_IO_PROTOCOL - @param VbeBuffer The data to transfer to screen - @param MemAddress Physical frame buffer base address - @param DestinationX The X coordinate of the destination for BltO= peration - @param DestinationY The Y coordinate of the destination for BltO= peration - @param TotalBytes The total bytes of copy - @param VbePixelWidth Bytes per pixel - @param BytesPerScanLine Bytes per scan line - -**/ -VOID -CopyVideoBuffer ( - IN EFI_PCI_IO_PROTOCOL *PciIo, - IN UINT8 *VbeBuffer, - IN VOID *MemAddress, - IN UINTN DestinationX, - IN UINTN DestinationY, - IN UINTN TotalBytes, - IN UINT32 VbePixelWidth, - IN UINTN BytesPerScanLine - ) -{ - UINTN FrameBufferAddr; - UINTN CopyBlockNum; - UINTN RemainingBytes; - UINTN UnalignedBytes; - EFI_STATUS Status; - - FrameBufferAddr =3D (UINTN)MemAddress + (DestinationY * BytesPerScanLine= ) + DestinationX * VbePixelWidth; - - // - // If TotalBytes is less than 4 bytes, only start byte copy. - // - if (TotalBytes < 4) { - Status =3D PciIo->Mem.Write ( - PciIo, - EfiPciIoWidthUint8, - EFI_PCI_IO_PASS_THROUGH_BAR, - (UINT64)FrameBufferAddr, - TotalBytes, - VbeBuffer - ); - ASSERT_EFI_ERROR (Status); - return; - } - - // - // If VbeBuffer is not 4-byte aligned, start byte copy. - // - UnalignedBytes =3D (4 - ((UINTN)VbeBuffer & 0x3)) & 0x3; - - if (UnalignedBytes !=3D 0) { - Status =3D PciIo->Mem.Write ( - PciIo, - EfiPciIoWidthUint8, - EFI_PCI_IO_PASS_THROUGH_BAR, - (UINT64)FrameBufferAddr, - UnalignedBytes, - VbeBuffer - ); - ASSERT_EFI_ERROR (Status); - FrameBufferAddr +=3D UnalignedBytes; - VbeBuffer +=3D UnalignedBytes; - } - - // - // Calculate 4-byte block count and remaining bytes. - // - CopyBlockNum =3D (TotalBytes - UnalignedBytes) >> 2; - RemainingBytes =3D (TotalBytes - UnalignedBytes) & 3; - - // - // Copy 4-byte block and remaining bytes to physical frame buffer. - // - if (CopyBlockNum !=3D 0) { - Status =3D PciIo->Mem.Write ( - PciIo, - EfiPciIoWidthUint32, - EFI_PCI_IO_PASS_THROUGH_BAR, - (UINT64)FrameBufferAddr, - CopyBlockNum, - VbeBuffer - ); - ASSERT_EFI_ERROR (Status); - } - - if (RemainingBytes !=3D 0) { - FrameBufferAddr +=3D (CopyBlockNum << 2); - VbeBuffer +=3D (CopyBlockNum << 2); - Status =3D PciIo->Mem.Write ( - PciIo, - EfiPciIoWidthUint8, - EFI_PCI_IO_PASS_THROUGH_BAR, - (UINT64)FrameBufferAddr, - RemainingBytes, - VbeBuffer - ); - ASSERT_EFI_ERROR (Status); - } -} - -/** - Worker function to block transfer for VBE device. - - @param BiosVideoPrivate Instance of BIOS_VIDEO_DEV - @param BltBuffer The data to transfer to screen - @param BltOperation The operation to perform - @param SourceX The X coordinate of the source for BltOpe= ration - @param SourceY The Y coordinate of the source for BltOpe= ration - @param DestinationX The X coordinate of the destination for - BltOperation - @param DestinationY The Y coordinate of the destination for - BltOperation - @param Width The width of a rectangle in the blt recta= ngle in - pixels - @param Height The height of a rectangle in the blt rect= angle in - pixels - @param Delta Not used for EfiBltVideoFill and - EfiBltVideoToVideo operation. If a Delta = of 0 is - used, the entire BltBuffer will be operat= ed on. If - a subrectangle of the BltBuffer is used, = then - Delta represents the number of bytes in a= row of - the BltBuffer. - @param Mode Mode data. - - @retval EFI_INVALID_PARAMETER Invalid parameter passed in - @retval EFI_SUCCESS Blt operation success - -**/ -EFI_STATUS -BiosVideoVbeBltWorker ( - IN BIOS_VIDEO_DEV *BiosVideoPrivate, - 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, - IN BIOS_VIDEO_MODE_DATA *Mode - ) -{ - EFI_PCI_IO_PROTOCOL *PciIo; - EFI_TPL OriginalTPL; - UINTN DstY; - UINTN SrcY; - UINTN DstX; - EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Blt; - VOID *MemAddress; - EFI_GRAPHICS_OUTPUT_BLT_PIXEL *VbeFrameBuffer; - UINTN BytesPerScanLine; - UINTN Index; - UINT8 *VbeBuffer; - UINT8 *VbeBuffer1; - UINT8 *BltUint8; - UINT32 VbePixelWidth; - UINT32 Pixel; - UINTN TotalBytes; - - PciIo =3D BiosVideoPrivate->PciIo; - - VbeFrameBuffer =3D BiosVideoPrivate->VbeFrameBuffer; - MemAddress =3D Mode->LinearFrameBuffer; - BytesPerScanLine =3D Mode->BytesPerScanLine; - VbePixelWidth =3D Mode->BitsPerPixel / 8; - BltUint8 =3D (UINT8 *)BltBuffer; - TotalBytes =3D Width * VbePixelWidth; - - if (((UINTN)BltOperation) >=3D EfiGraphicsOutputBltOperationMax) { - return EFI_INVALID_PARAMETER; - } - - if ((Width =3D=3D 0) || (Height =3D=3D 0)) { - return EFI_INVALID_PARAMETER; - } - - // - // We need to fill the Virtual Screen buffer with the blt data. - // The virtual screen is upside down, as the first row is the bootom row= of - // the image. - // - if (BltOperation =3D=3D EfiBltVideoToBltBuffer) { - // - // Video to BltBuffer: Source is Video, destination is BltBuffer - // - if (SourceY + Height > Mode->VerticalResolution) { - return EFI_INVALID_PARAMETER; - } - - if (SourceX + Width > Mode->HorizontalResolution) { - return EFI_INVALID_PARAMETER; - } - } else { - // - // BltBuffer to Video: Source is BltBuffer, destination is Video - // - if (DestinationY + Height > Mode->VerticalResolution) { - return EFI_INVALID_PARAMETER; - } - - if (DestinationX + Width > Mode->HorizontalResolution) { - return EFI_INVALID_PARAMETER; - } - } - - // - // If Delta is zero, then the entire BltBuffer is being used, so Delta - // is the number of bytes in each row of BltBuffer. Since BltBuffer is = Width pixels size, - // the number of bytes in each row can be computed. - // - if (Delta =3D=3D 0) { - Delta =3D Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL); - } - - // - // We have to raise to TPL Notify, so we make an atomic write the frame = buffer. - // We would not want a timer based event (Cursor, ...) to come in while = we are - // doing this operation. - // - OriginalTPL =3D gBS->RaiseTPL (TPL_NOTIFY); - - switch (BltOperation) { - case EfiBltVideoToBltBuffer: - for (SrcY =3D SourceY, DstY =3D DestinationY; DstY < (Height + Desti= nationY); SrcY++, DstY++) { - Blt =3D (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *)(BltUint8 + DstY * Delta = + DestinationX * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)); - // - // Shuffle the packed bytes in the hardware buffer to match EFI_GR= APHICS_OUTPUT_BLT_PIXEL - // - VbeBuffer =3D ((UINT8 *)VbeFrameBuffer + (SrcY * BytesPerScanLine = + SourceX * VbePixelWidth)); - for (DstX =3D DestinationX; DstX < (Width + DestinationX); DstX++)= { - Pixel =3D VbeBuffer[0] | VbeBuffer[1] << 8 | VbeBuffer[2= ] << 16 | VbeBuffer[3] << 24; - Blt->Red =3D (UINT8)((Pixel >> Mode->Red.Position) & Mode->= Red.Mask); - Blt->Blue =3D (UINT8)((Pixel >> Mode->Blue.Position) & Mode-= >Blue.Mask); - Blt->Green =3D (UINT8)((Pixel >> Mode->Green.Position) & Mode= ->Green.Mask); - Blt->Reserved =3D 0; - Blt++; - VbeBuffer +=3D VbePixelWidth; - } - } - - break; - - case EfiBltVideoToVideo: - for (Index =3D 0; Index < Height; Index++) { - if (DestinationY <=3D SourceY) { - SrcY =3D SourceY + Index; - DstY =3D DestinationY + Index; - } else { - SrcY =3D SourceY + Height - Index - 1; - DstY =3D DestinationY + Height - Index - 1; - } - - VbeBuffer =3D ((UINT8 *)VbeFrameBuffer + DstY * BytesPerScanLine = + DestinationX * VbePixelWidth); - VbeBuffer1 =3D ((UINT8 *)VbeFrameBuffer + SrcY * BytesPerScanLine = + SourceX * VbePixelWidth); - - gBS->CopyMem ( - VbeBuffer, - VbeBuffer1, - TotalBytes - ); - - // - // Update physical frame buffer. - // - CopyVideoBuffer ( - PciIo, - VbeBuffer, - MemAddress, - DestinationX, - DstY, - TotalBytes, - VbePixelWidth, - BytesPerScanLine - ); - } - - break; - - case EfiBltVideoFill: - VbeBuffer =3D (UINT8 *)((UINTN)VbeFrameBuffer + (DestinationY * Byte= sPerScanLine) + DestinationX * VbePixelWidth); - Blt =3D (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *)BltUint8; - // - // Shuffle the RGB fields in EFI_GRAPHICS_OUTPUT_BLT_PIXEL to match = the hardware buffer - // - Pixel =3D ((Blt->Red & Mode->Red.Mask) << Mode->Red.Position) | - ( - (Blt->Green & Mode->Green.Mask) << - Mode->Green.Position - ) | - ((Blt->Blue & Mode->Blue.Mask) << Mode->Blue.Position); - - for (Index =3D 0; Index < Width; Index++) { - gBS->CopyMem ( - VbeBuffer, - &Pixel, - VbePixelWidth - ); - VbeBuffer +=3D VbePixelWidth; - } - - VbeBuffer =3D (UINT8 *)((UINTN)VbeFrameBuffer + (DestinationY * Byte= sPerScanLine) + DestinationX * VbePixelWidth); - for (DstY =3D DestinationY + 1; DstY < (Height + DestinationY); DstY= ++) { - gBS->CopyMem ( - (VOID *)((UINTN)VbeFrameBuffer + (DstY * BytesPerScanLine) = + DestinationX * VbePixelWidth), - VbeBuffer, - TotalBytes - ); - } - - for (DstY =3D DestinationY; DstY < (Height + DestinationY); DstY++) { - // - // Update physical frame buffer. - // - CopyVideoBuffer ( - PciIo, - VbeBuffer, - MemAddress, - DestinationX, - DstY, - TotalBytes, - VbePixelWidth, - BytesPerScanLine - ); - } - - break; - - case EfiBltBufferToVideo: - for (SrcY =3D SourceY, DstY =3D DestinationY; SrcY < (Height + Sourc= eY); SrcY++, DstY++) { - Blt =3D (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *)(BltUint8 + (SrcY *= Delta) + (SourceX) * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)); - VbeBuffer =3D ((UINT8 *)VbeFrameBuffer + (DstY * BytesPerScanLine = + DestinationX * VbePixelWidth)); - for (DstX =3D DestinationX; DstX < (Width + DestinationX); DstX++)= { - // - // Shuffle the RGB fields in EFI_GRAPHICS_OUTPUT_BLT_PIXEL to ma= tch the hardware buffer - // - Pixel =3D ((Blt->Red & Mode->Red.Mask) << Mode->Red.Position) | - ((Blt->Green & Mode->Green.Mask) << Mode->Green.Position= ) | - ((Blt->Blue & Mode->Blue.Mask) << Mode->Blue.Position); - gBS->CopyMem ( - VbeBuffer, - &Pixel, - VbePixelWidth - ); - Blt++; - VbeBuffer +=3D VbePixelWidth; - } - - VbeBuffer =3D ((UINT8 *)VbeFrameBuffer + (DstY * BytesPerScanLine = + DestinationX * VbePixelWidth)); - - // - // Update physical frame buffer. - // - CopyVideoBuffer ( - PciIo, - VbeBuffer, - MemAddress, - DestinationX, - DstY, - TotalBytes, - VbePixelWidth, - BytesPerScanLine - ); - } - - break; - - default:; - } - - gBS->RestoreTPL (OriginalTPL); - - return EFI_SUCCESS; -} - -/** - Graphics Output protocol instance to block transfer for VBE device. - - @param This Pointer to Graphics Output protocol insta= nce - @param BltBuffer The data to transfer to screen - @param BltOperation The operation to perform - @param SourceX The X coordinate of the source for BltOpe= ration - @param SourceY The Y coordinate of the source for BltOpe= ration - @param DestinationX The X coordinate of the destination for - BltOperation - @param DestinationY The Y coordinate of the destination for - BltOperation - @param Width The width of a rectangle in the blt recta= ngle in - pixels - @param Height The height of a rectangle in the blt rect= angle in - pixels - @param Delta Not used for EfiBltVideoFill and - EfiBltVideoToVideo operation. If a Delta = of 0 is - used, the entire BltBuffer will be operat= ed on. If - a subrectangle of the BltBuffer is used, = then - Delta represents the number of bytes in a= row of - the BltBuffer. - - @retval EFI_INVALID_PARAMETER Invalid parameter passed in - @retval EFI_SUCCESS Blt operation success - -**/ -EFI_STATUS -EFIAPI -BiosVideoGraphicsOutputVbeBlt ( - IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This, - 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 - ) -{ - BIOS_VIDEO_DEV *BiosVideoPrivate; - BIOS_VIDEO_MODE_DATA *Mode; - - if (This =3D=3D NULL) { - return EFI_INVALID_PARAMETER; - } - - BiosVideoPrivate =3D BIOS_VIDEO_DEV_FROM_GRAPHICS_OUTPUT_THIS (This); - Mode =3D &BiosVideoPrivate->ModeData[This->Mode->Mode]; - - return BiosVideoVbeBltWorker ( - BiosVideoPrivate, - BltBuffer, - BltOperation, - SourceX, - SourceY, - DestinationX, - DestinationY, - Width, - Height, - Delta, - Mode - ); -} - -/** - Write graphics controller registers. - - @param PciIo Pointer to PciIo protocol instance of the - controller - @param Address Register address - @param Data Data to be written to register - - @return None - -**/ -VOID -WriteGraphicsController ( - IN EFI_PCI_IO_PROTOCOL *PciIo, - IN UINTN Address, - IN UINTN Data - ) -{ - Address =3D Address | (Data << 8); - PciIo->Io.Write ( - PciIo, - EfiPciIoWidthUint16, - EFI_PCI_IO_PASS_THROUGH_BAR, - VGA_GRAPHICS_CONTROLLER_ADDRESS_REGISTER, - 1, - &Address - ); -} - -/** - Read the four bit plane of VGA frame buffer. - - @param PciIo Pointer to PciIo protocol instance of the - controller - @param HardwareBuffer Hardware VGA frame buffer address - @param MemoryBuffer Memory buffer address - @param WidthInBytes Number of bytes in a line to read - @param Height Height of the area to read - - @return None - -**/ -VOID -VgaReadBitPlanes ( - EFI_PCI_IO_PROTOCOL *PciIo, - UINT8 *HardwareBuffer, - UINT8 *MemoryBuffer, - UINTN WidthInBytes, - UINTN Height - ) -{ - UINTN BitPlane; - UINTN Rows; - UINTN FrameBufferOffset; - UINT8 *Source; - UINT8 *Destination; - - // - // Program the Mode Register Write mode 0, Read mode 0 - // - WriteGraphicsController ( - PciIo, - VGA_GRAPHICS_CONTROLLER_MODE_REGISTER, - VGA_GRAPHICS_CONTROLLER_READ_MODE_0 | VGA_GRAPHICS_CONTROLLER_WRITE_MO= DE_0 - ); - - for (BitPlane =3D 0, FrameBufferOffset =3D 0; - BitPlane < VGA_NUMBER_OF_BIT_PLANES; - BitPlane++, FrameBufferOffset +=3D VGA_BYTES_PER_BIT_PLANE - ) - { - // - // Program the Read Map Select Register to select the correct bit plane - // - WriteGraphicsController ( - PciIo, - VGA_GRAPHICS_CONTROLLER_READ_MAP_SELECT_REGISTER, - BitPlane - ); - - Source =3D HardwareBuffer; - Destination =3D MemoryBuffer + FrameBufferOffset; - - for (Rows =3D 0; Rows < Height; Rows++, Source +=3D VGA_BYTES_PER_SCAN= _LINE, Destination +=3D VGA_BYTES_PER_SCAN_LINE) { - PciIo->Mem.Read ( - PciIo, - EfiPciIoWidthUint8, - EFI_PCI_IO_PASS_THROUGH_BAR, - (UINT64)(UINTN)Source, - WidthInBytes, - (VOID *)Destination - ); - } - } -} - -/** - Internal routine to convert VGA color to Grahpics Output color. - - @param MemoryBuffer Buffer containing VGA color - @param CoordinateX The X coordinate of pixel on screen - @param CoordinateY The Y coordinate of pixel on screen - @param BltBuffer Buffer to contain converted Grahpics Outp= ut color - - @return None - -**/ -VOID -VgaConvertToGraphicsOutputColor ( - UINT8 *MemoryBuffer, - UINTN CoordinateX, - UINTN CoordinateY, - EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer - ) -{ - UINTN Mask; - UINTN Bit; - UINTN Color; - - MemoryBuffer +=3D ((CoordinateY << 6) + (CoordinateY << 4) + (Coordinate= X >> 3)); - Mask =3D mVgaBitMaskTable[CoordinateX & 0x07]; - for (Bit =3D 0x01, Color =3D 0; Bit < 0x10; Bit <<=3D 1, MemoryBuffer += =3D VGA_BYTES_PER_BIT_PLANE) { - if ((*MemoryBuffer & Mask) !=3D 0) { - Color |=3D Bit; - } - } - - *BltBuffer =3D mVgaColorToGraphicsOutputColor[Color]; -} - -/** - Internal routine to convert Grahpics Output color to VGA color. - - @param BltBuffer buffer containing Grahpics Output color - - @return Converted VGA color - -**/ -UINT8 -VgaConvertColor ( - IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer - ) -{ - UINT8 Color; - - Color =3D (UINT8)((BltBuffer->Blue >> 7) | ((BltBuffer->Green >> 6) & 0x= 02) | ((BltBuffer->Red >> 5) & 0x04)); - if ((BltBuffer->Red + BltBuffer->Green + BltBuffer->Blue) > 0x180) { - Color |=3D 0x08; - } - - return Color; -} - -/** - Grahpics Output protocol instance to block transfer for VGA device. - - @param This Pointer to Grahpics Output protocol insta= nce - @param BltBuffer The data to transfer to screen - @param BltOperation The operation to perform - @param SourceX The X coordinate of the source for BltOpe= ration - @param SourceY The Y coordinate of the source for BltOpe= ration - @param DestinationX The X coordinate of the destination for - BltOperation - @param DestinationY The Y coordinate of the destination for - BltOperation - @param Width The width of a rectangle in the blt recta= ngle in - pixels - @param Height The height of a rectangle in the blt rect= angle in - pixels - @param Delta Not used for EfiBltVideoFill and - EfiBltVideoToVideo operation. If a Delta = of 0 is - used, the entire BltBuffer will be operat= ed on. If - a subrectangle of the BltBuffer is used, = then - Delta represents the number of bytes in a= row of - the BltBuffer. - - @retval EFI_INVALID_PARAMETER Invalid parameter passed in - @retval EFI_SUCCESS Blt operation success - -**/ -EFI_STATUS -EFIAPI -BiosVideoGraphicsOutputVgaBlt ( - IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This, - 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 - ) -{ - BIOS_VIDEO_DEV *BiosVideoPrivate; - EFI_TPL OriginalTPL; - UINT8 *MemAddress; - UINTN BytesPerScanLine; - UINTN Bit; - UINTN Index; - UINTN Index1; - UINTN StartAddress; - UINTN Bytes; - UINTN Offset; - UINT8 LeftMask; - UINT8 RightMask; - UINTN Address; - UINTN AddressFix; - UINT8 *Address1; - UINT8 *SourceAddress; - UINT8 *DestinationAddress; - EFI_PCI_IO_PROTOCOL *PciIo; - UINT8 Data; - UINT8 PixelColor; - UINT8 *VgaFrameBuffer; - UINTN SourceOffset; - UINTN SourceWidth; - UINTN Rows; - UINTN Columns; - UINTN CoordinateX; - UINTN CoordinateY; - UINTN CurrentMode; - - if ((This =3D=3D NULL) || (((UINTN)BltOperation) >=3D EfiGraphicsOutputB= ltOperationMax)) { - return EFI_INVALID_PARAMETER; - } - - BiosVideoPrivate =3D BIOS_VIDEO_DEV_FROM_GRAPHICS_OUTPUT_THIS (This); - - CurrentMode =3D This->Mode->Mode; - PciIo =3D BiosVideoPrivate->PciIo; - MemAddress =3D BiosVideoPrivate->ModeData[CurrentMode].LinearFrame= Buffer; - BytesPerScanLine =3D BiosVideoPrivate->ModeData[CurrentMode].BytesPerSca= nLine >> 3; - VgaFrameBuffer =3D BiosVideoPrivate->VgaFrameBuffer; - - if ((Width =3D=3D 0) || (Height =3D=3D 0)) { - return EFI_INVALID_PARAMETER; - } - - // - // We need to fill the Virtual Screen buffer with the blt data. - // The virtual screen is upside down, as the first row is the bootom row= of - // the image. - // - if (BltOperation =3D=3D EfiBltVideoToBltBuffer) { - // - // Video to BltBuffer: Source is Video, destination is BltBuffer - // - if (SourceY + Height > BiosVideoPrivate->ModeData[CurrentMode].Vertica= lResolution) { - return EFI_INVALID_PARAMETER; - } - - if (SourceX + Width > BiosVideoPrivate->ModeData[CurrentMode].Horizont= alResolution) { - return EFI_INVALID_PARAMETER; - } - } else { - // - // BltBuffer to Video: Source is BltBuffer, destination is Video - // - if (DestinationY + Height > BiosVideoPrivate->ModeData[CurrentMode].Ve= rticalResolution) { - return EFI_INVALID_PARAMETER; - } - - if (DestinationX + Width > BiosVideoPrivate->ModeData[CurrentMode].Hor= izontalResolution) { - return EFI_INVALID_PARAMETER; - } - } - - // - // If Delta is zero, then the entire BltBuffer is being used, so Delta - // is the number of bytes in each row of BltBuffer. Since BltBuffer is = Width pixels size, - // the number of bytes in each row can be computed. - // - if (Delta =3D=3D 0) { - Delta =3D Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL); - } - - // - // We have to raise to TPL Notify, so we make an atomic write the frame = buffer. - // We would not want a timer based event (Cursor, ...) to come in while = we are - // doing this operation. - // - OriginalTPL =3D gBS->RaiseTPL (TPL_NOTIFY); - - // - // Compute some values we need for VGA - // - switch (BltOperation) { - case EfiBltVideoToBltBuffer: - - SourceOffset =3D (SourceY << 6) + (SourceY << 4) + (SourceX >> 3); - SourceWidth =3D ((SourceX + Width - 1) >> 3) - (SourceX >> 3) + 1; - - // - // Read all the pixels in the 4 bit planes into a memory buffer that= looks like the VGA buffer - // - VgaReadBitPlanes ( - PciIo, - MemAddress + SourceOffset, - VgaFrameBuffer + SourceOffset, - SourceWidth, - Height - ); - - // - // Convert VGA Bit Planes to a Graphics Output 32-bit color value - // - BltBuffer +=3D (DestinationY * (Delta >> 2) + DestinationX); - for (Rows =3D 0, CoordinateY =3D SourceY; Rows < Height; Rows++, Coo= rdinateY++, BltBuffer +=3D (Delta >> 2)) { - for (Columns =3D 0, CoordinateX =3D SourceX; Columns < Width; Colu= mns++, CoordinateX++, BltBuffer++) { - VgaConvertToGraphicsOutputColor (VgaFrameBuffer, CoordinateX, Co= ordinateY, BltBuffer); - } - - BltBuffer -=3D Width; - } - - break; - - case EfiBltVideoToVideo: - // - // Check for an aligned Video to Video operation - // - if (((SourceX & 0x07) =3D=3D 0x00) && ((DestinationX & 0x07) =3D=3D = 0x00) && ((Width & 0x07) =3D=3D 0x00)) { - // - // Program the Mode Register Write mode 1, Read mode 0 - // - WriteGraphicsController ( - PciIo, - VGA_GRAPHICS_CONTROLLER_MODE_REGISTER, - VGA_GRAPHICS_CONTROLLER_READ_MODE_0 | VGA_GRAPHICS_CONTROLLER_WR= ITE_MODE_1 - ); - - SourceAddress =3D (UINT8 *)(MemAddress + (SourceY << 6) + (So= urceY << 4) + (SourceX >> 3)); - DestinationAddress =3D (UINT8 *)(MemAddress + (DestinationY << 6) = + (DestinationY << 4) + (DestinationX >> 3)); - Bytes =3D Width >> 3; - for (Index =3D 0, Offset =3D 0; Index < Height; Index++, Offset += =3D BytesPerScanLine) { - PciIo->CopyMem ( - PciIo, - EfiPciIoWidthUint8, - EFI_PCI_IO_PASS_THROUGH_BAR, - (UINT64)(UINTN)(DestinationAddress + Offset), - EFI_PCI_IO_PASS_THROUGH_BAR, - (UINT64)(UINTN)(SourceAddress + Offset), - Bytes - ); - } - } else { - SourceOffset =3D (SourceY << 6) + (SourceY << 4) + (SourceX >> 3); - SourceWidth =3D ((SourceX + Width - 1) >> 3) - (SourceX >> 3) + 1; - - // - // Read all the pixels in the 4 bit planes into a memory buffer th= at looks like the VGA buffer - // - VgaReadBitPlanes ( - PciIo, - MemAddress + SourceOffset, - VgaFrameBuffer + SourceOffset, - SourceWidth, - Height - ); - } - - break; - - case EfiBltVideoFill: - StartAddress =3D (UINTN)(MemAddress + (DestinationY << 6) + (Destina= tionY << 4) + (DestinationX >> 3)); - Bytes =3D ((DestinationX + Width - 1) >> 3) - (DestinationX >= > 3); - LeftMask =3D mVgaLeftMaskTable[DestinationX & 0x07]; - RightMask =3D mVgaRightMaskTable[(DestinationX + Width - 1) & 0x0= 7]; - if (Bytes =3D=3D 0) { - LeftMask =3D (UINT8)(LeftMask & RightMask); - RightMask =3D 0; - } - - if (LeftMask =3D=3D 0xff) { - StartAddress--; - Bytes++; - LeftMask =3D 0; - } - - if (RightMask =3D=3D 0xff) { - Bytes++; - RightMask =3D 0; - } - - PixelColor =3D VgaConvertColor (BltBuffer); - - // - // Program the Mode Register Write mode 2, Read mode 0 - // - WriteGraphicsController ( - PciIo, - VGA_GRAPHICS_CONTROLLER_MODE_REGISTER, - VGA_GRAPHICS_CONTROLLER_READ_MODE_0 | VGA_GRAPHICS_CONTROLLER_WRIT= E_MODE_2 - ); - - // - // Program the Data Rotate/Function Select Register to replace - // - WriteGraphicsController ( - PciIo, - VGA_GRAPHICS_CONTROLLER_DATA_ROTATE_REGISTER, - VGA_GRAPHICS_CONTROLLER_FUNCTION_REPLACE - ); - - if (LeftMask !=3D 0) { - // - // Program the BitMask register with the Left column mask - // - WriteGraphicsController ( - PciIo, - VGA_GRAPHICS_CONTROLLER_BIT_MASK_REGISTER, - LeftMask - ); - - for (Index =3D 0, Address =3D StartAddress; Index < Height; Index+= +, Address +=3D BytesPerScanLine) { - // - // Read data from the bit planes into the latches - // - PciIo->Mem.Read ( - PciIo, - EfiPciIoWidthUint8, - EFI_PCI_IO_PASS_THROUGH_BAR, - (UINT64)(UINTN)Address, - 1, - &Data - ); - // - // Write the lower 4 bits of PixelColor to the bit planes in the= pixels enabled by BitMask - // - PciIo->Mem.Write ( - PciIo, - EfiPciIoWidthUint8, - EFI_PCI_IO_PASS_THROUGH_BAR, - (UINT64)(UINTN)Address, - 1, - &PixelColor - ); - } - } - - if (Bytes > 1) { - // - // Program the BitMask register with the middle column mask of 0xff - // - WriteGraphicsController ( - PciIo, - VGA_GRAPHICS_CONTROLLER_BIT_MASK_REGISTER, - 0xff - ); - - for (Index =3D 0, Address =3D StartAddress + 1; Index < Height; In= dex++, Address +=3D BytesPerScanLine) { - PciIo->Mem.Write ( - PciIo, - EfiPciIoWidthFillUint8, - EFI_PCI_IO_PASS_THROUGH_BAR, - (UINT64)(UINTN)Address, - Bytes - 1, - &PixelColor - ); - } - } - - if (RightMask !=3D 0) { - // - // Program the BitMask register with the Right column mask - // - WriteGraphicsController ( - PciIo, - VGA_GRAPHICS_CONTROLLER_BIT_MASK_REGISTER, - RightMask - ); - - for (Index =3D 0, Address =3D StartAddress + Bytes; Index < Height= ; Index++, Address +=3D BytesPerScanLine) { - // - // Read data from the bit planes into the latches - // - PciIo->Mem.Read ( - PciIo, - EfiPciIoWidthUint8, - EFI_PCI_IO_PASS_THROUGH_BAR, - (UINT64)(UINTN)Address, - 1, - &Data - ); - // - // Write the lower 4 bits of PixelColor to the bit planes in the= pixels enabled by BitMask - // - PciIo->Mem.Write ( - PciIo, - EfiPciIoWidthUint8, - EFI_PCI_IO_PASS_THROUGH_BAR, - (UINT64)(UINTN)Address, - 1, - &PixelColor - ); - } - } - - break; - - case EfiBltBufferToVideo: - StartAddress =3D (UINTN)(MemAddress + (DestinationY << 6) + (Destina= tionY << 4) + (DestinationX >> 3)); - LeftMask =3D mVgaBitMaskTable[DestinationX & 0x07]; - - // - // Program the Mode Register Write mode 2, Read mode 0 - // - WriteGraphicsController ( - PciIo, - VGA_GRAPHICS_CONTROLLER_MODE_REGISTER, - VGA_GRAPHICS_CONTROLLER_READ_MODE_0 | VGA_GRAPHICS_CONTROLLER_WRIT= E_MODE_2 - ); - - // - // Program the Data Rotate/Function Select Register to replace - // - WriteGraphicsController ( - PciIo, - VGA_GRAPHICS_CONTROLLER_DATA_ROTATE_REGISTER, - VGA_GRAPHICS_CONTROLLER_FUNCTION_REPLACE - ); - - for (Index =3D 0, Address =3D StartAddress; Index < Height; Index++,= Address +=3D BytesPerScanLine) { - for (Index1 =3D 0; Index1 < Width; Index1++) { - BiosVideoPrivate->LineBuffer[Index1] =3D VgaConvertColor (&BltBu= ffer[(SourceY + Index) * (Delta >> 2) + SourceX + Index1]); - } - - AddressFix =3D Address; - - for (Bit =3D 0; Bit < 8; Bit++) { - // - // Program the BitMask register with the Left column mask - // - WriteGraphicsController ( - PciIo, - VGA_GRAPHICS_CONTROLLER_BIT_MASK_REGISTER, - LeftMask - ); - - for (Index1 =3D Bit, Address1 =3D (UINT8 *)AddressFix; Index1 < = Width; Index1 +=3D 8, Address1++) { - // - // Read data from the bit planes into the latches - // - PciIo->Mem.Read ( - PciIo, - EfiPciIoWidthUint8, - EFI_PCI_IO_PASS_THROUGH_BAR, - (UINT64)(UINTN)Address1, - 1, - &Data - ); - - PciIo->Mem.Write ( - PciIo, - EfiPciIoWidthUint8, - EFI_PCI_IO_PASS_THROUGH_BAR, - (UINT64)(UINTN)Address1, - 1, - &BiosVideoPrivate->LineBuffer[Index1] - ); - } - - LeftMask =3D (UINT8)(LeftMask >> 1); - if (LeftMask =3D=3D 0) { - LeftMask =3D 0x80; - AddressFix++; - } - } - } - - break; - - default:; - } - - gBS->RestoreTPL (OriginalTPL); - - return EFI_SUCCESS; -} - -// -// VGA Mini Port Protocol Functions -// - -/** - VgaMiniPort protocol interface to set mode. - - @param This Pointer to VgaMiniPort protocol instance - @param ModeNumber The index of the mode - - @retval EFI_UNSUPPORTED The requested mode is not supported - @retval EFI_SUCCESS The requested mode is set successfully - -**/ -EFI_STATUS -EFIAPI -BiosVideoVgaMiniPortSetMode ( - IN EFI_VGA_MINI_PORT_PROTOCOL *This, - IN UINTN ModeNumber - ) -{ - BIOS_VIDEO_DEV *BiosVideoPrivate; - EFI_IA32_REGISTER_SET Regs; - - if (This =3D=3D NULL) { - return EFI_INVALID_PARAMETER; - } - - // - // Make sure the ModeNumber is a valid value - // - if (ModeNumber >=3D This->MaxMode) { - return EFI_UNSUPPORTED; - } - - // - // Get the device structure for this device - // - BiosVideoPrivate =3D BIOS_VIDEO_DEV_FROM_VGA_MINI_PORT_THIS (This); - - switch (ModeNumber) { - case 0: - // - // Set the 80x25 Text VGA Mode - // - Regs.H.AH =3D 0x00; - Regs.H.AL =3D 0x83; - BiosVideoPrivate->LegacyBios->Int86 (BiosVideoPrivate->LegacyBios, 0= x10, &Regs); - - Regs.H.AH =3D 0x11; - Regs.H.AL =3D 0x14; - Regs.H.BL =3D 0; - BiosVideoPrivate->LegacyBios->Int86 (BiosVideoPrivate->LegacyBios, 0= x10, &Regs); - break; - - case 1: - // - // Set the 80x50 Text VGA Mode - // - Regs.H.AH =3D 0x00; - Regs.H.AL =3D 0x83; - BiosVideoPrivate->LegacyBios->Int86 (BiosVideoPrivate->LegacyBios, 0= x10, &Regs); - Regs.H.AH =3D 0x11; - Regs.H.AL =3D 0x12; - Regs.H.BL =3D 0; - BiosVideoPrivate->LegacyBios->Int86 (BiosVideoPrivate->LegacyBios, 0= x10, &Regs); - break; - - default: - return EFI_UNSUPPORTED; - } - - return EFI_SUCCESS; -} - -/** - Event handler for Exit Boot Service. - - @param Event The event that be signalled when exiting boot servic= e. - @param Context Pointer to instance of BIOS_VIDEO_DEV. - -**/ -VOID -EFIAPI -BiosVideoNotifyExitBootServices ( - IN EFI_EVENT Event, - IN VOID *Context - ) -{ - BIOS_VIDEO_DEV *BiosVideoPrivate; - EFI_IA32_REGISTER_SET Regs; - - BiosVideoPrivate =3D (BIOS_VIDEO_DEV *)Context; - - // - // Set the 80x25 Text VGA Mode - // - Regs.H.AH =3D 0x00; - Regs.H.AL =3D 0x03; - BiosVideoPrivate->LegacyBios->Int86 (BiosVideoPrivate->LegacyBios, 0x10,= &Regs); - - Regs.H.AH =3D 0x00; - Regs.H.AL =3D 0x83; - BiosVideoPrivate->LegacyBios->Int86 (BiosVideoPrivate->LegacyBios, 0x10,= &Regs); - - Regs.H.AH =3D 0x11; - Regs.H.AL =3D 0x04; - Regs.H.BL =3D 0; - BiosVideoPrivate->LegacyBios->Int86 (BiosVideoPrivate->LegacyBios, 0x10,= &Regs); -} - -/** - The user Entry Point for module UefiBiosVideo. The user code starts with= this function. - - @param[in] ImageHandle The firmware allocated handle for the EFI imag= e. - @param[in] SystemTable A pointer to the EFI System Table. - - @retval EFI_SUCCESS The entry point is executed successfully. - @retval other Some error occurs when executing this entry po= int. - -**/ -EFI_STATUS -EFIAPI -BiosVideoEntryPoint ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -{ - EFI_STATUS Status; - - // - // Install driver model protocol(s). - // - Status =3D EfiLibInstallDriverBindingComponentName2 ( - ImageHandle, - SystemTable, - &gBiosVideoDriverBinding, - ImageHandle, - &gBiosVideoComponentName, - &gBiosVideoComponentName2 - ); - ASSERT_EFI_ERROR (Status); - - // - // Install Legacy BIOS GUID to mark this driver as a BIOS Thunk Driver - // - return gBS->InstallMultipleProtocolInterfaces ( - &ImageHandle, - &gEfiLegacyBiosGuid, - NULL, - NULL - ); -} diff --git a/OvmfPkg/Csm/BiosThunk/VideoDxe/ComponentName.c b/OvmfPkg/Csm/B= iosThunk/VideoDxe/ComponentName.c deleted file mode 100644 index c401ed943b19..000000000000 --- a/OvmfPkg/Csm/BiosThunk/VideoDxe/ComponentName.c +++ /dev/null @@ -1,304 +0,0 @@ -/** @file - -Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.
- -SPDX-License-Identifier: BSD-2-Clause-Patent - -**/ - -#include "BiosVideo.h" - -// -// EFI Component Name Functions -// - -/** - Retrieves a Unicode string that is the user readable name of the driver. - - This function retrieves the user readable name of a driver in the form o= f a - Unicode string. If the driver specified by This has a user readable name= in - the language specified by Language, then a pointer to the driver name is - returned in DriverName, and EFI_SUCCESS is returned. If the driver speci= fied - by This does not support the language specified by Language, - then EFI_UNSUPPORTED is returned. - - @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTO= COL or - EFI_COMPONENT_NAME_PROTOCOL instance. - - @param Language[in] A pointer to a Null-terminated ASCII string - array indicating the language. This is the - language of the driver name that the calle= r is - requesting, and it must match one of the - languages specified in SupportedLanguages.= The - number of languages supported by a driver = is up - to the driver writer. Language is specified - in RFC 4646 or ISO 639-2 language code for= mat. - - @param DriverName[out] A pointer to the Unicode string to return. - This Unicode string is the name of the - driver specified by This in the language - specified by Language. - - @retval EFI_SUCCESS The Unicode string for the Driver specifie= d by - This and the language specified by Languag= e was - returned in DriverName. - - @retval EFI_INVALID_PARAMETER Language is NULL. - - @retval EFI_INVALID_PARAMETER DriverName is NULL. - - @retval EFI_UNSUPPORTED The driver specified by This does not supp= ort - the language specified by Language. - -**/ -EFI_STATUS -EFIAPI -BiosVideoComponentNameGetDriverName ( - IN EFI_COMPONENT_NAME_PROTOCOL *This, - IN CHAR8 *Language, - OUT CHAR16 **DriverName - ); - -/** - Retrieves a Unicode string that is the user readable name of the control= ler - that is being managed by a driver. - - This function retrieves the user readable name of the controller specifi= ed by - ControllerHandle and ChildHandle in the form of a Unicode string. If the - driver specified by This has a user readable name in the language specif= ied by - Language, then a pointer to the controller name is returned in Controlle= rName, - and EFI_SUCCESS is returned. If the driver specified by This is not cur= rently - managing the controller specified by ControllerHandle and ChildHandle, - then EFI_UNSUPPORTED is returned. If the driver specified by This does = not - support the language specified by Language, then EFI_UNSUPPORTED is retu= rned. - - @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTO= COL or - EFI_COMPONENT_NAME_PROTOCOL instance. - - @param ControllerHandle[in] The handle of a controller that the driver - specified by This is managing. This handle - specifies the controller whose name is to = be - returned. - - @param ChildHandle[in] The handle of the child controller to retr= ieve - the name of. This is an optional paramete= r that - may be NULL. It will be NULL for device - drivers. It will also be NULL for a bus d= rivers - that wish to retrieve the name of the bus - controller. It will not be NULL for a bus - driver that wishes to retrieve the name of= a - child controller. - - @param Language[in] A pointer to a Null-terminated ASCII string - array indicating the language. This is the - language of the driver name that the calle= r is - requesting, and it must match one of the - languages specified in SupportedLanguages.= The - number of languages supported by a driver = is up - to the driver writer. Language is specifie= d in - RFC 4646 or ISO 639-2 language code format. - - @param ControllerName[out] A pointer to the Unicode string to return. - This Unicode string is the name of the - controller specified by ControllerHandle a= nd - ChildHandle in the language specified by - Language from the point of view of the dri= ver - specified by This. - - @retval EFI_SUCCESS The Unicode string for the user readable n= ame in - the language specified by Language for the - driver specified by This was returned in - DriverName. - - @retval EFI_INVALID_PARAMETER ControllerHandle is NULL. - - @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a va= lid - EFI_HANDLE. - - @retval EFI_INVALID_PARAMETER Language is NULL. - - @retval EFI_INVALID_PARAMETER ControllerName is NULL. - - @retval EFI_UNSUPPORTED The driver specified by This is not curren= tly - managing the controller specified by - ControllerHandle and ChildHandle. - - @retval EFI_UNSUPPORTED The driver specified by This does not supp= ort - the language specified by Language. - -**/ -EFI_STATUS -EFIAPI -BiosVideoComponentNameGetControllerName ( - IN EFI_COMPONENT_NAME_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_HANDLE ChildHandle OPTIONAL, - IN CHAR8 *Language, - OUT CHAR16 **ControllerName - ); - -// -// EFI Component Name Protocol -// -GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gBiosVideoCompo= nentName =3D { - BiosVideoComponentNameGetDriverName, - BiosVideoComponentNameGetControllerName, - "eng" -}; - -// -// EFI Component Name 2 Protocol -// -GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gBiosVideoComp= onentName2 =3D { - (EFI_COMPONENT_NAME2_GET_DRIVER_NAME)BiosVideoComponentNameGetDriverName, - (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)BiosVideoComponentNameGetContro= llerName, - "en" -}; - -GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mBiosVideoDriverNa= meTable[] =3D { - { - "eng;en", - L"BIOS[INT10] Video Driver" - }, - { - NULL, - NULL - } -}; - -/** - Retrieves a Unicode string that is the user readable name of the driver. - - This function retrieves the user readable name of a driver in the form o= f a - Unicode string. If the driver specified by This has a user readable name= in - the language specified by Language, then a pointer to the driver name is - returned in DriverName, and EFI_SUCCESS is returned. If the driver speci= fied - by This does not support the language specified by Language, - then EFI_UNSUPPORTED is returned. - - @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTO= COL or - EFI_COMPONENT_NAME_PROTOCOL instance. - - @param Language[in] A pointer to a Null-terminated ASCII string - array indicating the language. This is the - language of the driver name that the calle= r is - requesting, and it must match one of the - languages specified in SupportedLanguages.= The - number of languages supported by a driver = is up - to the driver writer. Language is specified - in RFC 4646 or ISO 639-2 language code for= mat. - - @param DriverName[out] A pointer to the Unicode string to return. - This Unicode string is the name of the - driver specified by This in the language - specified by Language. - - @retval EFI_SUCCESS The Unicode string for the Driver specifie= d by - This and the language specified by Languag= e was - returned in DriverName. - - @retval EFI_INVALID_PARAMETER Language is NULL. - - @retval EFI_INVALID_PARAMETER DriverName is NULL. - - @retval EFI_UNSUPPORTED The driver specified by This does not supp= ort - the language specified by Language. - -**/ -EFI_STATUS -EFIAPI -BiosVideoComponentNameGetDriverName ( - IN EFI_COMPONENT_NAME_PROTOCOL *This, - IN CHAR8 *Language, - OUT CHAR16 **DriverName - ) -{ - return LookupUnicodeString2 ( - Language, - This->SupportedLanguages, - mBiosVideoDriverNameTable, - DriverName, - (BOOLEAN)(This =3D=3D &gBiosVideoComponentName) - ); -} - -/** - Retrieves a Unicode string that is the user readable name of the control= ler - that is being managed by a driver. - - This function retrieves the user readable name of the controller specifi= ed by - ControllerHandle and ChildHandle in the form of a Unicode string. If the - driver specified by This has a user readable name in the language specif= ied by - Language, then a pointer to the controller name is returned in Controlle= rName, - and EFI_SUCCESS is returned. If the driver specified by This is not cur= rently - managing the controller specified by ControllerHandle and ChildHandle, - then EFI_UNSUPPORTED is returned. If the driver specified by This does = not - support the language specified by Language, then EFI_UNSUPPORTED is retu= rned. - - @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTO= COL or - EFI_COMPONENT_NAME_PROTOCOL instance. - - @param ControllerHandle[in] The handle of a controller that the driver - specified by This is managing. This handle - specifies the controller whose name is to = be - returned. - - @param ChildHandle[in] The handle of the child controller to retr= ieve - the name of. This is an optional paramete= r that - may be NULL. It will be NULL for device - drivers. It will also be NULL for a bus d= rivers - that wish to retrieve the name of the bus - controller. It will not be NULL for a bus - driver that wishes to retrieve the name of= a - child controller. - - @param Language[in] A pointer to a Null-terminated ASCII string - array indicating the language. This is the - language of the driver name that the calle= r is - requesting, and it must match one of the - languages specified in SupportedLanguages.= The - number of languages supported by a driver = is up - to the driver writer. Language is specifie= d in - RFC 4646 or ISO 639-2 language code format. - - @param ControllerName[out] A pointer to the Unicode string to return. - This Unicode string is the name of the - controller specified by ControllerHandle a= nd - ChildHandle in the language specified by - Language from the point of view of the dri= ver - specified by This. - - @retval EFI_SUCCESS The Unicode string for the user readable n= ame in - the language specified by Language for the - driver specified by This was returned in - DriverName. - - @retval EFI_INVALID_PARAMETER ControllerHandle is NULL. - - @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a va= lid - EFI_HANDLE. - - @retval EFI_INVALID_PARAMETER Language is NULL. - - @retval EFI_INVALID_PARAMETER ControllerName is NULL. - - @retval EFI_UNSUPPORTED The driver specified by This is not curren= tly - managing the controller specified by - ControllerHandle and ChildHandle. - - @retval EFI_UNSUPPORTED The driver specified by This does not supp= ort - the language specified by Language. - -**/ -EFI_STATUS -EFIAPI -BiosVideoComponentNameGetControllerName ( - IN EFI_COMPONENT_NAME_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_HANDLE ChildHandle OPTIONAL, - IN CHAR8 *Language, - OUT CHAR16 **ControllerName - ) -{ - return EFI_UNSUPPORTED; -} -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#111080): https://edk2.groups.io/g/devel/message/111080 Mute This Topic: https://groups.io/mt/102518647/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/leave/3901457/1787277/102458076= /xyzzy [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-