--- /dev/null
+================================================================================\r
+Build And Integration Instructions\r
+2014 June 24th\r
+================================================================================\r
+\r
+================================================================================\r
+DISCLAIMER\r
+================================================================================\r
+This release note as well as the software described in it is furnished under license\r
+and may only be used or copied in accordance with the terms of the license. The\r
+information in this manual is furnished for informational use only, is subject to\r
+change without notice, and should not be construed as a commitment by Intel Corporation.\r
+Intel Corporation assumes no responsibility or liability for any errors or inaccuracies\r
+that may appear in this document or any software that may be provided in association\r
+with this document.\r
+Except as permitted by such license, no part of this document may be reproduced,\r
+stored in a retrieval system, or transmitted in any form or by any means without\r
+the express written consent of Intel Corporation.\r
+\r
+================================================================================\r
+ INDEX\r
+================================================================================\r
+A. INTRODUCTION\r
+B. HOW TO BUILD\r
+C. HOW TO INTEGRATE \r
+\r
+================================================================================\r
+A. INTRODUCTION\r
+================================================================================\r
+This document provides instructions on how to build Coreboot Uefi Payload and \r
+how to integrate it into coreboot firmware.\r
+\r
+================================================================================\r
+B. HOW TO BUILD \r
+================================================================================\r
+1. Run the below two commands in windows command prompt window:\r
+ edksetup.bat\r
+ \r
+ For debug ia32 build:\r
+ build -a IA32 -p CorebootPayloadPkg\CorebootPayloadPkgIA32.dsc -b DEBUG -t <ToolChain>\r
+ \r
+ For release ia32 build:\r
+ build -a IA32 -p CorebootPayloadPkg\CorebootPayloadPkgIA32.dsc -b RELEASE -t <ToolChain>\r
+ \r
+ For debug X64 build:\r
+ build -a IA32 -a X64 -p CorebootPayloadPkg\CorebootPayloadPkgX64.dsc -b DEBUG -t <ToolChain>\r
+ \r
+ For release X64 build:\r
+ build -a IA32 -a X64 -p CorebootPayloadPkg\CorebootPayloadPkgX64.dsc -b RELEASE -t <ToolChain>\r
+ \r
+ <ToolChain> is the EDK II build environment on your host. Currently it was tested with VS2008x64 toolchain.\r
+\r
+ For details about EDK II build steps, refer to http://svn.code.sf.net/p/edk2/code/branches/UDK2014/BuildNotes2.txt\r
+ \r
+2. If build is successfully, the payload image (UEFIPAYLOAD.fd) will be generated inside the folder of Build\CorebootPayloadPkg.\r
+\r
+================================================================================\r
+C. HOW TO INTEGRATE\r
+================================================================================\r
+1. Copy the payload image (UEFIPAYLOAD.fd) into the top-level directory of Coreboot source tree.\r
+2. Run "make menuconfig" in linux console to start Coreboot configuration surface.\r
+3. In the Payload section,\r
+ 1) Choose "An ELF executable payload" for the option of "Add a payload".\r
+ 2) Type the path of payload image for the option of "Payload path and filename".\r
+ 3) Select the option of "Use LZMA compression for payloads".\r
+ \r
+4. If the graphics console is required in Coreboot UEFI payload, running VGA option rom should be enabled.\r
+ For details:\r
+ 1) In the Device section, select the option of "Run VGA Option ROMs".\r
+ 2) In the VGA BIOS section, select the option of "Add a VGA BIOS Image", Input the path of vga bios image \r
+ for the option of VGA BIOS path and filename, give the values of vendor id and device id for the option \r
+ of "VGA device PCI IDs".\r
+ 3) In the Display section,\r
+ Select the option of "Set framebuffer graphics resolution"\r
+ Choose a right display mode for the option of "framebuffer graphics resolution".\r
+ Note: If the boot OS is windows, please choose the display mode supporting 32 bit color.\r
+ Select the option of "Keep VESA framebuffer"\r
+ \r
+5. Press ESC key to exit the Coreboot configuration surface. If there is a question prompted like "Do you wish to save your new configuration?",\r
+ choose Yes.\r
+ \r
+6. Run "make" to build the coreboot firmware image.\r
+\r
+\r
+ \r
+ \r
+\r
+ \r
+ \r
+ \r
+
\ No newline at end of file
--- /dev/null
+## @file\r
+# Coreboot Payload Package\r
+#\r
+# Provides drivers and definitions to create uefi payload for coreboot. \r
+#\r
+# Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>\r
+# This program and the accompanying materials are licensed and made available under \r
+# the terms and conditions of the BSD License that accompanies this distribution. \r
+# The full text of the license may be found at\r
+# http://opensource.org/licenses/bsd-license.php. \r
+# \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
+#\r
+##\r
+\r
+[Defines]\r
+ DEC_SPECIFICATION = 0x00010005\r
+ PACKAGE_NAME = CorebootPayloadPkg\r
+ PACKAGE_GUID = 58ABC905-951E-472e-8590-77BA8A50BE63\r
+ PACKAGE_VERSION = 0.1\r
+ \r
+[Includes]\r
+ Include\r
+ \r
+[LibraryClasses]\r
+ \r
+[Guids]\r
+ #\r
+ ## Defines the token space for the Coreboot Payload Package PCDs.\r
+ #\r
+ gUEfiCorebootPayloadPkgTokenSpaceGuid = {0x1d127ea, 0xf6f1, 0x4ef6, {0x94, 0x15, 0x8a, 0x0, 0x0, 0x93, 0xf8, 0x9d}} \r
+ \r
+ #\r
+ # Gop Temp\r
+ #\r
+ gBmpImageGuid = { 0x878AC2CC, 0x5343, 0x46F2, { 0xB5, 0x63, 0x51, 0xF8, 0x9D, 0xAF, 0x56, 0xBA } }\r
+\r
+[Ppis]\r
+\r
+[Protocols]\r
+ #\r
+ # Gop Temp\r
+ #\r
+ gPlatformGOPPolicyGuid = { 0xec2e931b, 0x3281, 0x48a5, { 0x81, 0x07, 0xdf, 0x8a, 0x8b, 0xed, 0x3c, 0x5d } }\r
+\r
+################################################################################\r
+#\r
+# PCD Declarations section - list of all PCDs Declared by this Package\r
+# Only this package should be providing the\r
+# declaration, other packages should not.\r
+#\r
+################################################################################\r
+[PcdsFixedAtBuild, PcdsPatchableInModule]\r
+\r
+[PcdsDynamic, PcdsDynamicEx]\r
+ \r
--- /dev/null
+## @file\r
+# Coreboot Payload Package\r
+#\r
+# Provides drivers and definitions to create uefi payload for coreboot. \r
+#\r
+# Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>\r
+# This program and the accompanying materials are licensed and made available under \r
+# the terms and conditions of the BSD License that accompanies this distribution. \r
+# The full text of the license may be found at\r
+# http://opensource.org/licenses/bsd-license.php. \r
+# \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
+#\r
+##\r
+\r
+################################################################################\r
+[FD.UefiPayload]\r
+BaseAddress = 0x800000|gUefiCorebootModulePkgTokenSpaceGuid.PcdPayloadFdMemBase\r
+Size = 0x400000|gUefiCorebootModulePkgTokenSpaceGuid.PcdPayloadFdMemSize\r
+ErasePolarity = 1\r
+BlockSize = 0x1000\r
+NumBlocks = 0x400\r
+\r
+0x00000000|0x020000\r
+FV = PEIFV\r
+\r
+0x00020000|0x3E0000\r
+FV = DXEFV\r
+\r
+################################################################################\r
+[FV.PEIFV]\r
+BlockSize = 0x1000\r
+FvAlignment = 16\r
+ERASE_POLARITY = 1\r
+MEMORY_MAPPED = TRUE\r
+STICKY_WRITE = TRUE\r
+LOCK_CAP = TRUE\r
+LOCK_STATUS = TRUE\r
+WRITE_DISABLED_CAP = TRUE\r
+WRITE_ENABLED_CAP = TRUE\r
+WRITE_STATUS = TRUE\r
+WRITE_LOCK_CAP = TRUE\r
+WRITE_LOCK_STATUS = TRUE\r
+READ_DISABLED_CAP = TRUE\r
+READ_ENABLED_CAP = TRUE\r
+READ_STATUS = TRUE\r
+READ_LOCK_CAP = TRUE\r
+READ_LOCK_STATUS = TRUE\r
+\r
+INF CorebootModulePkg/SecCore/SecCore.inf\r
+\r
+INF MdeModulePkg/Core/Pei/PeiMain.inf\r
+INF MdeModulePkg/Universal/PCD/Pei/Pcd.inf\r
+INF IntelFrameworkModulePkg/Universal/StatusCode/Pei/StatusCodePei.inf\r
+INF CorebootModulePkg/CbSupportPei/CbSupportPei.inf\r
+INF MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf\r
+\r
+################################################################################\r
+\r
+[FV.DXEFV]\r
+BlockSize = 0x1000\r
+FvAlignment = 16\r
+ERASE_POLARITY = 1\r
+MEMORY_MAPPED = TRUE\r
+STICKY_WRITE = TRUE\r
+LOCK_CAP = TRUE\r
+LOCK_STATUS = TRUE\r
+WRITE_DISABLED_CAP = TRUE\r
+WRITE_ENABLED_CAP = TRUE\r
+WRITE_STATUS = TRUE\r
+WRITE_LOCK_CAP = TRUE\r
+WRITE_LOCK_STATUS = TRUE\r
+READ_DISABLED_CAP = TRUE\r
+READ_ENABLED_CAP = TRUE\r
+READ_STATUS = TRUE\r
+READ_LOCK_CAP = TRUE\r
+READ_LOCK_STATUS = TRUE\r
+\r
+#\r
+# DXE Phase modules\r
+#\r
+INF MdeModulePkg/Core/Dxe/DxeMain.inf\r
+INF MdeModulePkg/Universal/PCD/Dxe/Pcd.inf\r
+INF IntelFrameworkModulePkg/Universal/StatusCode/RuntimeDxe/StatusCodeRuntimeDxe.inf\r
+\r
+INF MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf\r
+INF UefiCpuPkg/CpuDxe/CpuDxe.inf\r
+INF IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.inf\r
+INF PcAtChipsetPkg/8254TimerDxe/8254Timer.inf\r
+INF MdeModulePkg/Universal/Metronome/Metronome.inf\r
+INF MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf\r
+INF MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf\r
+INF MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf\r
+INF MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf\r
+INF MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf \r
+INF PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf \r
+INF MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariableRuntimeDxe.inf\r
+\r
+INF UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf\r
+INF MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf\r
+INF MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTestDxe.inf\r
+INF PcAtChipsetPkg/8259InterruptControllerDxe/8259.inf \r
+INF MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf\r
+INF MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf \r
+INF MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf\r
+INF CorebootModulePkg/CbSupportDxe/CbSupportDxe.inf \r
+\r
+INF MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf\r
+#\r
+# PCI Support\r
+#\r
+INF PcAtChipsetPkg/PciHostBridgeDxe/PciHostBridgeDxe.inf\r
+INF DuetPkg/PciBusNoEnumerationDxe/PciBusNoEnumeration.inf \r
+\r
+#\r
+# ISA Support\r
+#\r
+INF CorebootPayloadPkg/SerialDxe/SerialDxe.inf\r
+\r
+#\r
+# Console Support\r
+#\r
+INF MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf\r
+INF MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf\r
+INF MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf\r
+INF MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf\r
+\r
+#\r
+# SCSI/ATA/IDE/DISK Support\r
+#\r
+INF MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf\r
+INF MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf\r
+INF MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf\r
+INF DuetPkg/SataControllerDxe/SataControllerDxe.inf \r
+INF MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf\r
+INF MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf\r
+INF MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf\r
+INF MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf\r
+\r
+!if $(ARCH) == IA32\r
+INF RuleOverride = BINARY USE = IA32 FatBinPkg/EnhancedFatDxe/Fat.inf\r
+!else\r
+INF RuleOverride = BINARY USE = X64 FatBinPkg/EnhancedFatDxe/Fat.inf\r
+!endif\r
+\r
+#\r
+# Usb Support\r
+#\r
+INF MdeModulePkg/Bus/Pci/UhciDxe/UhciDxe.inf\r
+INF MdeModulePkg/Bus/Pci/EhciDxe/EhciDxe.inf\r
+INF MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf\r
+INF MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBusDxe.inf\r
+INF MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf\r
+INF MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf\r
+\r
+#\r
+# Shell\r
+#\r
+#!if $(ARCH) == IA32\r
+#INF RuleOverride = BINARY USE = IA32 ShellBinPkg/UefiShell/UefiShell.inf\r
+#!else\r
+#INF RuleOverride = BINARY USE = X64 ShellBinPkg/UefiShell/UefiShell.inf\r
+#!endif\r
+#\r
+!if $(ARCH) == IA32\r
+INF RuleOverride = BINARY USE = IA32 EdkShellBinPkg/FullShell/FullShell.inf\r
+!else\r
+INF RuleOverride = BINARY USE = X64 EdkShellBinPkg/FullShell/FullShell.inf\r
+!endif\r
+\r
+FILE FREEFORM = PCD(gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdLogoFile) {\r
+ SECTION RAW = MdeModulePkg/Logo/Logo.bmp\r
+}\r
+\r
+#\r
+# Framebuffer Gop \r
+#\r
+INF CorebootPayloadPkg/FbGop/FbGop.inf\r
+\r
+################################################################################\r
+#\r
+# Rules are use with the [FV] section's module INF type to define\r
+# how an FFS file is created for a given INF file. The following Rule are the default\r
+# rules for the different module type. User can add the customized rules to define the\r
+# content of the FFS file.\r
+#\r
+################################################################################\r
+\r
+[Rule.Common.SEC]\r
+ FILE SEC = $(NAMED_GUID) {\r
+ PE32 PE32 Align=32 $(INF_OUTPUT)/$(MODULE_NAME).efi\r
+ }\r
+\r
+[Rule.Common.PEI_CORE]\r
+ FILE PEI_CORE = $(NAMED_GUID) {\r
+ PE32 PE32 Align=32 $(INF_OUTPUT)/$(MODULE_NAME).efi\r
+ UI STRING ="$(MODULE_NAME)" Optional\r
+ VERSION STRING ="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)\r
+ }\r
+\r
+[Rule.Common.PEIM]\r
+ FILE PEIM = $(NAMED_GUID) {\r
+ PEI_DEPEX PEI_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex\r
+ PE32 PE32 Align=32 $(INF_OUTPUT)/$(MODULE_NAME).efi\r
+ UI STRING="$(MODULE_NAME)" Optional\r
+ VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)\r
+ }\r
+\r
+[Rule.Common.DXE_CORE]\r
+ FILE DXE_CORE = $(NAMED_GUID) {\r
+ PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi\r
+ UI STRING="$(MODULE_NAME)" Optional\r
+ VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)\r
+ }\r
+\r
+[Rule.Common.DXE_DRIVER]\r
+ FILE DRIVER = $(NAMED_GUID) {\r
+ DXE_DEPEX DXE_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex\r
+ PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi\r
+ UI STRING="$(MODULE_NAME)" Optional\r
+ VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)\r
+ }\r
+\r
+[Rule.Common.DXE_RUNTIME_DRIVER]\r
+ FILE DRIVER = $(NAMED_GUID) {\r
+ DXE_DEPEX DXE_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex\r
+ PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi\r
+ UI STRING="$(MODULE_NAME)" Optional\r
+ VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)\r
+ }\r
+\r
+[Rule.Common.UEFI_DRIVER]\r
+ FILE DRIVER = $(NAMED_GUID) {\r
+ DXE_DEPEX DXE_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex\r
+ PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi\r
+ UI STRING="$(MODULE_NAME)" Optional\r
+ VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)\r
+ }\r
+\r
+[Rule.Common.UEFI_DRIVER.BINARY]\r
+ FILE DRIVER = $(NAMED_GUID) {\r
+ DXE_DEPEX DXE_DEPEX Optional |.depex\r
+ PE32 PE32 |.efi\r
+ UI STRING="$(MODULE_NAME)" Optional\r
+ VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)\r
+ }\r
+\r
+[Rule.Common.UEFI_APPLICATION]\r
+ FILE APPLICATION = $(NAMED_GUID) {\r
+ PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi\r
+ UI STRING="$(MODULE_NAME)" Optional\r
+ VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)\r
+ }\r
+\r
+[Rule.Common.UEFI_APPLICATION.BINARY]\r
+ FILE APPLICATION = $(NAMED_GUID) {\r
+ PE32 PE32 |.efi\r
+ UI STRING="$(MODULE_NAME)" Optional\r
+ VERSION STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)\r
+ }\r
+\r
+[Rule.Common.USER_DEFINED.ACPITABLE]\r
+ FILE FREEFORM = $(NAMED_GUID) {\r
+ RAW ACPI |.acpi\r
+ RAW ASL |.aml\r
+ }\r
+\r
+[Rule.Common.USER_DEFINED.CSM]\r
+ FILE FREEFORM = $(NAMED_GUID) {\r
+ RAW BIN |.bin\r
+ }\r
+\r
+[Rule.Common.SEC.RESET_VECTOR]\r
+ FILE RAW = $(NAMED_GUID) {\r
+ RAW RAW |.raw\r
+ }\r
+\r
--- /dev/null
+## @file\r
+# Coreboot Payload Package\r
+#\r
+# Provides drivers and definitions to create uefi payload for coreboot. \r
+#\r
+# Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>\r
+# This program and the accompanying materials are licensed and made available under \r
+# the terms and conditions of the BSD License that accompanies this distribution. \r
+# The full text of the license may be found at\r
+# http://opensource.org/licenses/bsd-license.php. \r
+# \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
+#\r
+##\r
+\r
+################################################################################\r
+#\r
+# Defines Section - statements that will be processed to create a Makefile.\r
+#\r
+################################################################################\r
+[Defines]\r
+ PLATFORM_NAME = CorebootPayloadPkg\r
+ PLATFORM_GUID = F71608AB-D63D-4491-B744-A99998C8CD96\r
+ PLATFORM_VERSION = 0.1\r
+ DSC_SPECIFICATION = 0x00010005 \r
+ SUPPORTED_ARCHITECTURES = IA32|X64\r
+ BUILD_TARGETS = DEBUG|RELEASE\r
+ SKUID_IDENTIFIER = DEFAULT\r
+ OUTPUT_DIRECTORY = Build/CorebootPayloadPkg\r
+ FLASH_DEFINITION = CorebootPayloadPkg/CorebootPayloadPkg.fdf\r
+ \r
+ DEFINE SECURE_BOOT_ENABLE = FALSE\r
+ DEFINE SOURCE_DEBUG_ENABLE = FALSE\r
+ \r
+[BuildOptions]\r
+ GCC:*_UNIXGCC_*_CC_FLAGS = -DMDEPKG_NDEBUG\r
+ GCC:RELEASE_*_*_CC_FLAGS = -DMDEPKG_NDEBUG\r
+ INTEL:RELEASE_*_*_CC_FLAGS = /D MDEPKG_NDEBUG\r
+ MSFT:RELEASE_*_*_CC_FLAGS = /D MDEPKG_NDEBUG\r
+\r
+################################################################################\r
+#\r
+# SKU Identification section - list of all SKU IDs supported by this Platform.\r
+#\r
+################################################################################\r
+[SkuIds]\r
+ 0|DEFAULT\r
+\r
+################################################################################\r
+#\r
+# Library Class section - list of all Library Classes needed by this Platform.\r
+#\r
+################################################################################\r
+[LibraryClasses]\r
+ #\r
+ # Entry point\r
+ #\r
+ PeiCoreEntryPoint|MdePkg/Library/PeiCoreEntryPoint/PeiCoreEntryPoint.inf\r
+ PeimEntryPoint|MdePkg/Library/PeimEntryPoint/PeimEntryPoint.inf\r
+ DxeCoreEntryPoint|MdePkg/Library/DxeCoreEntryPoint/DxeCoreEntryPoint.inf\r
+ UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf\r
+ UefiApplicationEntryPoint|MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.inf\r
+\r
+ #\r
+ # Basic\r
+ #\r
+ BaseLib|MdePkg/Library/BaseLib/BaseLib.inf \r
+ BaseMemoryLib|MdePkg/Library/BaseMemoryLibRepStr/BaseMemoryLibRepStr.inf\r
+ SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf\r
+ PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf\r
+ CpuLib|MdePkg/Library/BaseCpuLib/BaseCpuLib.inf\r
+ IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf\r
+ PciLib|MdePkg/Library/BasePciLibCf8/BasePciLibCf8.inf\r
+ PciCf8Lib|MdePkg/Library/BasePciCf8Lib/BasePciCf8Lib.inf\r
+ PeCoffLib|MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf\r
+ PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf\r
+ CacheMaintenanceLib|MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf\r
+ \r
+ #\r
+ # UEFI & PI\r
+ #\r
+ UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf\r
+ UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf\r
+ UefiRuntimeLib|MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf\r
+ UefiLib|MdePkg/Library/UefiLib/UefiLib.inf\r
+ UefiHiiServicesLib|MdeModulePkg/Library/UefiHiiServicesLib/UefiHiiServicesLib.inf\r
+ HiiLib|MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf\r
+ DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf\r
+ UefiDecompressLib|MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.inf\r
+ PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointerLibIdt.inf\r
+ PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf\r
+ DxeServicesLib|MdePkg/Library/DxeServicesLib/DxeServicesLib.inf\r
+ DxeServicesTableLib|MdePkg/Library/DxeServicesTableLib/DxeServicesTableLib.inf\r
+ UefiCpuLib|UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf\r
+ \r
+ #\r
+ # Generic Modules\r
+ #\r
+ UefiUsbLib|MdePkg/Library/UefiUsbLib/UefiUsbLib.inf\r
+ UefiScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf\r
+ OemHookStatusCodeLib|MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHookStatusCodeLibNull.inf\r
+ CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf\r
+ SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.inf\r
+ GenericBdsLib|IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLib.inf\r
+ CustomizedDisplayLib|MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.inf\r
+ \r
+ #\r
+ # CPU\r
+ #\r
+ MtrrLib|UefiCpuPkg/Library/MtrrLib/MtrrLib.inf\r
+ LocalApicLib|UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.inf \r
+ \r
+ #\r
+ # Platform\r
+ #\r
+ TimerLib|CorebootPayloadPkg/Library/AcpiTimerLib/AcpiTimerLib.inf\r
+ ResetSystemLib|CorebootPayloadPkg/Library/ResetSystemLib/ResetSystemLib.inf\r
+ SerialPortLib|CorebootPayloadPkg/Library/SerialPortLib/SerialPortLib.inf\r
+ PlatformBdsLib|CorebootPayloadPkg/Library/PlatformBdsLib/PlatformBdsLib.inf\r
+ \r
+ #\r
+ # Misc\r
+ #\r
+ DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf\r
+ PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibNull.inf\r
+ PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf\r
+!if $(SOURCE_DEBUG_ENABLE) == TRUE\r
+ PeCoffExtraActionLib|SourceLevelDebugPkg/Library/PeCoffExtraActionLibDebug/PeCoffExtraActionLibDebug.inf\r
+ DebugCommunicationLib|SourceLevelDebugPkg/Library/DebugCommunicationLibSerialPort/DebugCommunicationLibSerialPort.inf\r
+!else\r
+ PeCoffExtraActionLib|MdePkg/Library/BasePeCoffExtraActionLibNull/BasePeCoffExtraActionLibNull.inf\r
+ DebugAgentLib|MdeModulePkg/Library/DebugAgentLibNull/DebugAgentLibNull.inf \r
+!endif\r
+ CbParseLib|CorebootModulePkg/Library/CbParseLib/CbParseLib.inf\r
+ DebugLib|IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebugLibReportStatusCode.inf\r
+\r
+[LibraryClasses.IA32.SEC]\r
+ DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf\r
+ PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf\r
+ HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf\r
+ MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf\r
+ DebugAgentLib|MdeModulePkg/Library/DebugAgentLibNull/DebugAgentLibNull.inf\r
+ ReportStatusCodeLib|MdePkg/Library/BaseReportStatusCodeLibNull/BaseReportStatusCodeLibNull.inf\r
+\r
+[LibraryClasses.IA32.PEI_CORE, LibraryClasses.IA32.PEIM]\r
+ PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf\r
+ HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf\r
+ MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf\r
+ ReportStatusCodeLib|MdeModulePkg/Library/PeiReportStatusCodeLib/PeiReportStatusCodeLib.inf\r
+ ExtractGuidedSectionLib|MdePkg/Library/PeiExtractGuidedSectionLib/PeiExtractGuidedSectionLib.inf\r
+!if $(SOURCE_DEBUG_ENABLE)\r
+ DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgentLib.inf\r
+!endif\r
+\r
+[LibraryClasses.common.DXE_CORE]\r
+ PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf\r
+ HobLib|MdePkg/Library/DxeCoreHobLib/DxeCoreHobLib.inf\r
+ MemoryAllocationLib|MdeModulePkg/Library/DxeCoreMemoryAllocationLib/DxeCoreMemoryAllocationLib.inf\r
+ ExtractGuidedSectionLib|MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.inf\r
+ ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf \r
+!if $(SOURCE_DEBUG_ENABLE)\r
+ DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgentLib.inf\r
+!endif \r
+ CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf\r
+\r
+[LibraryClasses.common.DXE_DRIVER] \r
+ PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf\r
+ HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf\r
+ MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf\r
+ ExtractGuidedSectionLib|MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.inf\r
+ ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf\r
+ CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf\r
+ \r
+[LibraryClasses.common.DXE_RUNTIME_DRIVER]\r
+ PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf\r
+ HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf\r
+ MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf\r
+ ReportStatusCodeLib|MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/RuntimeDxeReportStatusCodeLib.inf\r
+ \r
+[LibraryClasses.common.UEFI_DRIVER,LibraryClasses.common.UEFI_APPLICATION]\r
+ PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf\r
+ MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf\r
+ ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf\r
+ HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf \r
+ \r
+################################################################################\r
+#\r
+# Pcd Section - list of all EDK II PCD Entries defined by this Platform.\r
+#\r
+################################################################################\r
+[PcdsFeatureFlag]\r
+ gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseSerial|TRUE\r
+ gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseMemory|FALSE\r
+ gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode|FALSE\r
+ gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE\r
+ gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|FALSE\r
+\r
+[PcdsFixedAtBuild]\r
+ gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask|0x7\r
+ gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x8000004F\r
+!if $(SOURCE_DEBUG_ENABLE)\r
+ gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x17\r
+!else\r
+ gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x2F\r
+!endif\r
+ gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize|0x10000\r
+ gEfiMdeModulePkgTokenSpaceGuid.PcdMaxHardwareErrorVariableSize|0x8000\r
+ gEfiMdeModulePkgTokenSpaceGuid.PcdVariableStoreSize|0x10000\r
+ \r
+ gEfiMdeModulePkgTokenSpaceGuid.PcdVpdBaseAddress|0x0 \r
+\r
+!if $(SOURCE_DEBUG_ENABLE)\r
+ gEfiSourceLevelDebugPkgTokenSpaceGuid.PcdDebugLoadImageMethod|0x2\r
+!endif\r
+\r
+################################################################################\r
+#\r
+# Pcd Dynamic Section - list of all EDK II PCD Entries defined by this Platform\r
+#\r
+################################################################################\r
+\r
+[PcdsDynamicDefault]\r
+ gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved|0\r
+ gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64|0\r
+ gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase|0\r
+ gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase|0\r
+\r
+\r
+################################################################################\r
+#\r
+# Components Section - list of all EDK II Modules needed by this Platform.\r
+#\r
+################################################################################\r
+[Components.IA32]\r
+ #\r
+ # SEC Core\r
+ #\r
+ CorebootModulePkg/SecCore/SecCore.inf\r
+ \r
+ #\r
+ # PEI Core\r
+ #\r
+ MdeModulePkg/Core/Pei/PeiMain.inf\r
+ \r
+ #\r
+ # PEIM\r
+ #\r
+ MdeModulePkg/Universal/PCD/Pei/Pcd.inf {\r
+ <LibraryClasses>\r
+ PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf\r
+ }\r
+ IntelFrameworkModulePkg/Universal/StatusCode/Pei/StatusCodePei.inf\r
+ \r
+ CorebootModulePkg/CbSupportPei/CbSupportPei.inf \r
+ MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf\r
+\r
+[Components.IA32]\r
+ #\r
+ # DXE Core\r
+ #\r
+ MdeModulePkg/Core/Dxe/DxeMain.inf {\r
+ <LibraryClasses>\r
+ NULL|IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf\r
+ }\r
+ \r
+ #\r
+ # Components that produce the architectural protocols\r
+ #\r
+ MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf\r
+ UefiCpuPkg/CpuDxe/CpuDxe.inf\r
+ IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.inf\r
+ PcAtChipsetPkg/8254TimerDxe/8254Timer.inf\r
+ MdeModulePkg/Universal/Metronome/Metronome.inf\r
+ MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf\r
+ MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf\r
+ MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf\r
+ MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf\r
+ MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf \r
+ PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf \r
+ MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariableRuntimeDxe.inf\r
+ \r
+ #\r
+ # Following are the DXE drivers \r
+ #\r
+ MdeModulePkg/Universal/PCD/Dxe/Pcd.inf {\r
+ <LibraryClasses>\r
+ PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf\r
+ }\r
+ \r
+ IntelFrameworkModulePkg/Universal/StatusCode/RuntimeDxe/StatusCodeRuntimeDxe.inf\r
+ UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf\r
+ MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf\r
+ MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTestDxe.inf\r
+ PcAtChipsetPkg/8259InterruptControllerDxe/8259.inf \r
+ MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf\r
+ MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf \r
+ MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf\r
+ \r
+ CorebootModulePkg/CbSupportDxe/CbSupportDxe.inf \r
+ \r
+ #\r
+ # SMBIOS Support\r
+ #\r
+ MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf\r
+ \r
+ #\r
+ # ACPI Support\r
+ #\r
+ MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf \r
+ \r
+ #\r
+ # PCI Support\r
+ #\r
+ PcAtChipsetPkg/PciHostBridgeDxe/PciHostBridgeDxe.inf\r
+ DuetPkg/PciBusNoEnumerationDxe/PciBusNoEnumeration.inf \r
+ \r
+ #\r
+ # SCSI/ATA/IDE/DISK Support\r
+ #\r
+ MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf\r
+ MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf\r
+ MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf\r
+ DuetPkg/SataControllerDxe/SataControllerDxe.inf \r
+ MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf\r
+ MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf \r
+ MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf\r
+ MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf\r
+ \r
+ #\r
+ # Usb Support\r
+ #\r
+ MdeModulePkg/Bus/Pci/UhciDxe/UhciDxe.inf\r
+ MdeModulePkg/Bus/Pci/EhciDxe/EhciDxe.inf\r
+ MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf\r
+ MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBusDxe.inf\r
+ MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf\r
+ MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf\r
+ \r
+ #\r
+ # ISA Support\r
+ #\r
+ CorebootPayloadPkg/SerialDxe/SerialDxe.inf\r
+ \r
+ #\r
+ # Console Support\r
+ #\r
+ MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf\r
+ MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf\r
+ MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf\r
+ MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf\r
+ \r
+ \r
+ #\r
+ # Framebuffer Gop \r
+ #\r
+ CorebootPayloadPkg/FbGop/FbGop.inf\r
+ \r
+ \r
+
\ No newline at end of file
--- /dev/null
+## @file\r
+# Coreboot Payload Package\r
+#\r
+# Provides drivers and definitions to create uefi payload for coreboot. \r
+#\r
+# Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>\r
+# This program and the accompanying materials are licensed and made available under \r
+# the terms and conditions of the BSD License that accompanies this distribution. \r
+# The full text of the license may be found at\r
+# http://opensource.org/licenses/bsd-license.php. \r
+# \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
+#\r
+##\r
+\r
+################################################################################\r
+#\r
+# Defines Section - statements that will be processed to create a Makefile.\r
+#\r
+################################################################################\r
+[Defines]\r
+ PLATFORM_NAME = CorebootPayloadPkg\r
+ PLATFORM_GUID = F71608AB-D63D-4491-B744-A99998C8CD96\r
+ PLATFORM_VERSION = 0.1\r
+ DSC_SPECIFICATION = 0x00010005 \r
+ SUPPORTED_ARCHITECTURES = IA32|X64\r
+ BUILD_TARGETS = DEBUG|RELEASE\r
+ SKUID_IDENTIFIER = DEFAULT\r
+ OUTPUT_DIRECTORY = Build/CorebootPayloadPkg\r
+ FLASH_DEFINITION = CorebootPayloadPkg/CorebootPayloadPkg.fdf\r
+ \r
+ DEFINE SECURE_BOOT_ENABLE = FALSE\r
+ DEFINE SOURCE_DEBUG_ENABLE = FALSE\r
+ \r
+[BuildOptions]\r
+ GCC:*_UNIXGCC_*_CC_FLAGS = -DMDEPKG_NDEBUG\r
+ GCC:RELEASE_*_*_CC_FLAGS = -DMDEPKG_NDEBUG\r
+ INTEL:RELEASE_*_*_CC_FLAGS = /D MDEPKG_NDEBUG\r
+ MSFT:RELEASE_*_*_CC_FLAGS = /D MDEPKG_NDEBUG\r
+\r
+################################################################################\r
+#\r
+# SKU Identification section - list of all SKU IDs supported by this Platform.\r
+#\r
+################################################################################\r
+[SkuIds]\r
+ 0|DEFAULT\r
+\r
+################################################################################\r
+#\r
+# Library Class section - list of all Library Classes needed by this Platform.\r
+#\r
+################################################################################\r
+[LibraryClasses]\r
+ #\r
+ # Entry point\r
+ #\r
+ PeiCoreEntryPoint|MdePkg/Library/PeiCoreEntryPoint/PeiCoreEntryPoint.inf\r
+ PeimEntryPoint|MdePkg/Library/PeimEntryPoint/PeimEntryPoint.inf\r
+ DxeCoreEntryPoint|MdePkg/Library/DxeCoreEntryPoint/DxeCoreEntryPoint.inf\r
+ UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf\r
+ UefiApplicationEntryPoint|MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.inf\r
+\r
+ #\r
+ # Basic\r
+ #\r
+ BaseLib|MdePkg/Library/BaseLib/BaseLib.inf \r
+ BaseMemoryLib|MdePkg/Library/BaseMemoryLibRepStr/BaseMemoryLibRepStr.inf\r
+ SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf\r
+ PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf\r
+ CpuLib|MdePkg/Library/BaseCpuLib/BaseCpuLib.inf\r
+ IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf\r
+ PciLib|MdePkg/Library/BasePciLibCf8/BasePciLibCf8.inf\r
+ PciCf8Lib|MdePkg/Library/BasePciCf8Lib/BasePciCf8Lib.inf\r
+ PeCoffLib|MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf\r
+ PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf\r
+ CacheMaintenanceLib|MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf\r
+ \r
+ #\r
+ # UEFI & PI\r
+ #\r
+ UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf\r
+ UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf\r
+ UefiRuntimeLib|MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf\r
+ UefiLib|MdePkg/Library/UefiLib/UefiLib.inf\r
+ UefiHiiServicesLib|MdeModulePkg/Library/UefiHiiServicesLib/UefiHiiServicesLib.inf\r
+ HiiLib|MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf\r
+ DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf\r
+ UefiDecompressLib|MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.inf\r
+ PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointerLibIdt.inf\r
+ PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf\r
+ DxeServicesLib|MdePkg/Library/DxeServicesLib/DxeServicesLib.inf\r
+ DxeServicesTableLib|MdePkg/Library/DxeServicesTableLib/DxeServicesTableLib.inf\r
+ UefiCpuLib|UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf\r
+ \r
+ #\r
+ # Generic Modules\r
+ #\r
+ UefiUsbLib|MdePkg/Library/UefiUsbLib/UefiUsbLib.inf\r
+ UefiScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf\r
+ OemHookStatusCodeLib|MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHookStatusCodeLibNull.inf\r
+ CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf\r
+ SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.inf\r
+ GenericBdsLib|IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLib.inf\r
+ CustomizedDisplayLib|MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.inf\r
+ \r
+ #\r
+ # CPU\r
+ #\r
+ MtrrLib|UefiCpuPkg/Library/MtrrLib/MtrrLib.inf\r
+ LocalApicLib|UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.inf \r
+ \r
+ #\r
+ # Platform\r
+ #\r
+ TimerLib|CorebootPayloadPkg/Library/AcpiTimerLib/AcpiTimerLib.inf\r
+ ResetSystemLib|CorebootPayloadPkg/Library/ResetSystemLib/ResetSystemLib.inf\r
+ SerialPortLib|CorebootPayloadPkg/Library/SerialPortLib/SerialPortLib.inf\r
+ PlatformBdsLib|CorebootPayloadPkg/Library/PlatformBdsLib/PlatformBdsLib.inf\r
+ \r
+ #\r
+ # Misc\r
+ #\r
+ DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf\r
+ PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibNull.inf\r
+ PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf\r
+!if $(SOURCE_DEBUG_ENABLE) == TRUE\r
+ PeCoffExtraActionLib|SourceLevelDebugPkg/Library/PeCoffExtraActionLibDebug/PeCoffExtraActionLibDebug.inf\r
+ DebugCommunicationLib|SourceLevelDebugPkg/Library/DebugCommunicationLibSerialPort/DebugCommunicationLibSerialPort.inf\r
+!else\r
+ PeCoffExtraActionLib|MdePkg/Library/BasePeCoffExtraActionLibNull/BasePeCoffExtraActionLibNull.inf\r
+ DebugAgentLib|MdeModulePkg/Library/DebugAgentLibNull/DebugAgentLibNull.inf \r
+!endif\r
+ CbParseLib|CorebootModulePkg/Library/CbParseLib/CbParseLib.inf\r
+ DebugLib|IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebugLibReportStatusCode.inf\r
+ LockBoxLib|MdeModulePkg/Library/LockBoxNullLib/LockBoxNullLib.inf\r
+\r
+[LibraryClasses.IA32.SEC]\r
+ DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf\r
+ PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf\r
+ HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf\r
+ MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf\r
+ DebugAgentLib|MdeModulePkg/Library/DebugAgentLibNull/DebugAgentLibNull.inf\r
+ ReportStatusCodeLib|MdePkg/Library/BaseReportStatusCodeLibNull/BaseReportStatusCodeLibNull.inf\r
+\r
+[LibraryClasses.IA32.PEI_CORE, LibraryClasses.IA32.PEIM]\r
+ PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf\r
+ HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf\r
+ MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf\r
+ ReportStatusCodeLib|MdeModulePkg/Library/PeiReportStatusCodeLib/PeiReportStatusCodeLib.inf\r
+ ExtractGuidedSectionLib|MdePkg/Library/PeiExtractGuidedSectionLib/PeiExtractGuidedSectionLib.inf\r
+!if $(SOURCE_DEBUG_ENABLE)\r
+ DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgentLib.inf\r
+!endif\r
+\r
+[LibraryClasses.common.DXE_CORE]\r
+ PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf\r
+ HobLib|MdePkg/Library/DxeCoreHobLib/DxeCoreHobLib.inf\r
+ MemoryAllocationLib|MdeModulePkg/Library/DxeCoreMemoryAllocationLib/DxeCoreMemoryAllocationLib.inf\r
+ ExtractGuidedSectionLib|MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.inf\r
+ ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf \r
+!if $(SOURCE_DEBUG_ENABLE)\r
+ DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgentLib.inf\r
+!endif \r
+ CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf\r
+\r
+[LibraryClasses.common.DXE_DRIVER] \r
+ PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf\r
+ HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf\r
+ MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf\r
+ ExtractGuidedSectionLib|MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.inf\r
+ ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf\r
+ CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf\r
+ \r
+[LibraryClasses.common.DXE_RUNTIME_DRIVER]\r
+ PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf\r
+ HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf\r
+ MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf\r
+ ReportStatusCodeLib|MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/RuntimeDxeReportStatusCodeLib.inf\r
+ \r
+[LibraryClasses.common.UEFI_DRIVER,LibraryClasses.common.UEFI_APPLICATION]\r
+ PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf\r
+ MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf\r
+ ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf\r
+ HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf \r
+ \r
+################################################################################\r
+#\r
+# Pcd Section - list of all EDK II PCD Entries defined by this Platform.\r
+#\r
+################################################################################\r
+[PcdsFeatureFlag]\r
+ gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseSerial|TRUE\r
+ gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseMemory|FALSE\r
+ gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode|TRUE\r
+ gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE\r
+ gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|FALSE\r
+\r
+[PcdsFixedAtBuild]\r
+ gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask|0x7\r
+ gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x8000004F\r
+!if $(SOURCE_DEBUG_ENABLE)\r
+ gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x17\r
+!else\r
+ gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x2F\r
+!endif\r
+ gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize|0x10000\r
+ gEfiMdeModulePkgTokenSpaceGuid.PcdMaxHardwareErrorVariableSize|0x8000\r
+ gEfiMdeModulePkgTokenSpaceGuid.PcdVariableStoreSize|0x10000\r
+ \r
+ gEfiMdeModulePkgTokenSpaceGuid.PcdVpdBaseAddress|0x0 \r
+\r
+!if $(SOURCE_DEBUG_ENABLE)\r
+ gEfiSourceLevelDebugPkgTokenSpaceGuid.PcdDebugLoadImageMethod|0x2\r
+!endif\r
+\r
+################################################################################\r
+#\r
+# Pcd Dynamic Section - list of all EDK II PCD Entries defined by this Platform\r
+#\r
+################################################################################\r
+\r
+[PcdsDynamicDefault]\r
+ gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved|0\r
+ gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64|0\r
+ gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase|0\r
+ gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase|0\r
+\r
+\r
+################################################################################\r
+#\r
+# Components Section - list of all EDK II Modules needed by this Platform.\r
+#\r
+################################################################################\r
+[Components.IA32]\r
+ #\r
+ # SEC Core\r
+ #\r
+ CorebootModulePkg/SecCore/SecCore.inf\r
+ \r
+ #\r
+ # PEI Core\r
+ #\r
+ MdeModulePkg/Core/Pei/PeiMain.inf\r
+ \r
+ #\r
+ # PEIM\r
+ #\r
+ MdeModulePkg/Universal/PCD/Pei/Pcd.inf {\r
+ <LibraryClasses>\r
+ PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf\r
+ }\r
+ IntelFrameworkModulePkg/Universal/StatusCode/Pei/StatusCodePei.inf\r
+ \r
+ CorebootModulePkg/CbSupportPei/CbSupportPei.inf \r
+ MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf\r
+\r
+[Components.X64]\r
+ #\r
+ # DXE Core\r
+ #\r
+ MdeModulePkg/Core/Dxe/DxeMain.inf {\r
+ <LibraryClasses>\r
+ NULL|IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf\r
+ }\r
+ \r
+ #\r
+ # Components that produce the architectural protocols\r
+ #\r
+ MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf\r
+ UefiCpuPkg/CpuDxe/CpuDxe.inf\r
+ IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.inf\r
+ PcAtChipsetPkg/8254TimerDxe/8254Timer.inf\r
+ MdeModulePkg/Universal/Metronome/Metronome.inf\r
+ MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf\r
+ MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf\r
+ MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf\r
+ MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf\r
+ MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf \r
+ PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf \r
+ MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariableRuntimeDxe.inf\r
+ \r
+ #\r
+ # Following are the DXE drivers \r
+ #\r
+ MdeModulePkg/Universal/PCD/Dxe/Pcd.inf {\r
+ <LibraryClasses>\r
+ PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf\r
+ }\r
+ \r
+ IntelFrameworkModulePkg/Universal/StatusCode/RuntimeDxe/StatusCodeRuntimeDxe.inf\r
+ UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf\r
+ MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf\r
+ MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTestDxe.inf\r
+ PcAtChipsetPkg/8259InterruptControllerDxe/8259.inf \r
+ MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf\r
+ MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf \r
+ MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf\r
+ \r
+ CorebootModulePkg/CbSupportDxe/CbSupportDxe.inf \r
+ \r
+ #\r
+ # SMBIOS Support\r
+ #\r
+ MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf\r
+ \r
+ #\r
+ # ACPI Support\r
+ #\r
+ MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf \r
+ \r
+ #\r
+ # PCI Support\r
+ #\r
+ PcAtChipsetPkg/PciHostBridgeDxe/PciHostBridgeDxe.inf\r
+ DuetPkg/PciBusNoEnumerationDxe/PciBusNoEnumeration.inf \r
+ \r
+ #\r
+ # SCSI/ATA/IDE/DISK Support\r
+ #\r
+ MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf\r
+ MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf\r
+ MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf\r
+ DuetPkg/SataControllerDxe/SataControllerDxe.inf \r
+ MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf\r
+ MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf \r
+ MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf\r
+ MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf\r
+ \r
+ #\r
+ # Usb Support\r
+ #\r
+ MdeModulePkg/Bus/Pci/UhciDxe/UhciDxe.inf\r
+ MdeModulePkg/Bus/Pci/EhciDxe/EhciDxe.inf\r
+ MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf\r
+ MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBusDxe.inf\r
+ MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf\r
+ MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf\r
+ \r
+ #\r
+ # ISA Support\r
+ #\r
+ CorebootPayloadPkg/SerialDxe/SerialDxe.inf\r
+ \r
+ #\r
+ # Console Support\r
+ #\r
+ MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf\r
+ MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf\r
+ MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf\r
+ MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf\r
+ \r
+ \r
+ #\r
+ # Framebuffer Gop \r
+ #\r
+ CorebootPayloadPkg/FbGop/FbGop.inf\r
+ \r
+ \r
+
\ No newline at end of file
--- /dev/null
+/** @file\r
+\r
+Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
+\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions\r
+of the BSD License which accompanies this distribution. The\r
+full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "FbGop.h"\r
+\r
+//\r
+// EFI Component Name Functions\r
+//\r
+/**\r
+ Retrieves a Unicode string that is the user readable name of the driver.\r
+\r
+ This function retrieves the user readable name of a driver in the form of a\r
+ Unicode string. If the driver specified by This has a user readable name in\r
+ the language specified by Language, then a pointer to the driver name is\r
+ returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
+ by This does not support the language specified by Language,\r
+ then EFI_UNSUPPORTED is returned.\r
+\r
+ @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
+ EFI_COMPONENT_NAME_PROTOCOL instance.\r
+\r
+ @param Language[in] A pointer to a Null-terminated ASCII string\r
+ array indicating the language. This is the\r
+ language of the driver name that the caller is\r
+ requesting, and it must match one of the\r
+ languages specified in SupportedLanguages. The\r
+ number of languages supported by a driver is up\r
+ to the driver writer. Language is specified\r
+ in RFC 4646 or ISO 639-2 language code format.\r
+\r
+ @param DriverName[out] A pointer to the Unicode string to return.\r
+ This Unicode string is the name of the\r
+ driver specified by This in the language\r
+ specified by Language.\r
+\r
+ @retval EFI_SUCCESS The Unicode string for the Driver specified by\r
+ This and the language specified by Language was\r
+ returned in DriverName.\r
+\r
+ @retval EFI_INVALID_PARAMETER Language is NULL.\r
+\r
+ @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
+\r
+ @retval EFI_UNSUPPORTED The driver specified by This does not support\r
+ the language specified by Language.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FbGopComponentNameGetDriverName (\r
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
+ IN CHAR8 *Language,\r
+ OUT CHAR16 **DriverName\r
+ );\r
+\r
+\r
+/**\r
+ Retrieves a Unicode string that is the user readable name of the controller\r
+ that is being managed by a driver.\r
+\r
+ This function retrieves the user readable name of the controller specified by\r
+ ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
+ driver specified by This has a user readable name in the language specified by\r
+ Language, then a pointer to the controller name is returned in ControllerName,\r
+ and EFI_SUCCESS is returned. If the driver specified by This is not currently\r
+ managing the controller specified by ControllerHandle and ChildHandle,\r
+ then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r
+ support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
+\r
+ @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
+ EFI_COMPONENT_NAME_PROTOCOL instance.\r
+\r
+ @param ControllerHandle[in] The handle of a controller that the driver\r
+ specified by This is managing. This handle\r
+ specifies the controller whose name is to be\r
+ returned.\r
+\r
+ @param ChildHandle[in] The handle of the child controller to retrieve\r
+ the name of. This is an optional parameter that\r
+ may be NULL. It will be NULL for device\r
+ drivers. It will also be NULL for a bus drivers\r
+ that wish to retrieve the name of the bus\r
+ controller. It will not be NULL for a bus\r
+ driver that wishes to retrieve the name of a\r
+ child controller.\r
+\r
+ @param Language[in] A pointer to a Null-terminated ASCII string\r
+ array indicating the language. This is the\r
+ language of the driver name that the caller is\r
+ requesting, and it must match one of the\r
+ languages specified in SupportedLanguages. The\r
+ number of languages supported by a driver is up\r
+ to the driver writer. Language is specified in\r
+ RFC 4646 or ISO 639-2 language code format.\r
+\r
+ @param ControllerName[out] A pointer to the Unicode string to return.\r
+ This Unicode string is the name of the\r
+ controller specified by ControllerHandle and\r
+ ChildHandle in the language specified by\r
+ Language from the point of view of the driver\r
+ specified by This.\r
+\r
+ @retval EFI_SUCCESS The Unicode string for the user readable name in\r
+ the language specified by Language for the\r
+ driver specified by This was returned in\r
+ DriverName.\r
+\r
+ @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
+\r
+ @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
+ EFI_HANDLE.\r
+\r
+ @retval EFI_INVALID_PARAMETER Language is NULL.\r
+\r
+ @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
+\r
+ @retval EFI_UNSUPPORTED The driver specified by This is not currently\r
+ managing the controller specified by\r
+ ControllerHandle and ChildHandle.\r
+\r
+ @retval EFI_UNSUPPORTED The driver specified by This does not support\r
+ the language specified by Language.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FbGopComponentNameGetControllerName (\r
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN EFI_HANDLE ChildHandle OPTIONAL,\r
+ IN CHAR8 *Language,\r
+ OUT CHAR16 **ControllerName\r
+ );\r
+\r
+\r
+//\r
+// EFI Component Name Protocol\r
+//\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gFbGopComponentName = {\r
+ FbGopComponentNameGetDriverName,\r
+ FbGopComponentNameGetControllerName,\r
+ "eng"\r
+};\r
+\r
+//\r
+// EFI Component Name 2 Protocol\r
+//\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gFbGopComponentName2 = {\r
+ (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) FbGopComponentNameGetDriverName,\r
+ (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) FbGopComponentNameGetControllerName,\r
+ "en"\r
+};\r
+\r
+\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mFbGopDriverNameTable[] = {\r
+ {\r
+ "eng;en",\r
+ L"FB GOP Video Driver"\r
+ },\r
+ {\r
+ NULL,\r
+ NULL\r
+ }\r
+};\r
+\r
+/**\r
+ Retrieves a Unicode string that is the user readable name of the driver.\r
+\r
+ This function retrieves the user readable name of a driver in the form of a\r
+ Unicode string. If the driver specified by This has a user readable name in\r
+ the language specified by Language, then a pointer to the driver name is\r
+ returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
+ by This does not support the language specified by Language,\r
+ then EFI_UNSUPPORTED is returned.\r
+\r
+ @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
+ EFI_COMPONENT_NAME_PROTOCOL instance.\r
+\r
+ @param Language[in] A pointer to a Null-terminated ASCII string\r
+ array indicating the language. This is the\r
+ language of the driver name that the caller is\r
+ requesting, and it must match one of the\r
+ languages specified in SupportedLanguages. The\r
+ number of languages supported by a driver is up\r
+ to the driver writer. Language is specified\r
+ in RFC 4646 or ISO 639-2 language code format.\r
+\r
+ @param DriverName[out] A pointer to the Unicode string to return.\r
+ This Unicode string is the name of the\r
+ driver specified by This in the language\r
+ specified by Language.\r
+\r
+ @retval EFI_SUCCESS The Unicode string for the Driver specified by\r
+ This and the language specified by Language was\r
+ returned in DriverName.\r
+\r
+ @retval EFI_INVALID_PARAMETER Language is NULL.\r
+\r
+ @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
+\r
+ @retval EFI_UNSUPPORTED The driver specified by This does not support\r
+ the language specified by Language.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FbGopComponentNameGetDriverName (\r
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
+ IN CHAR8 *Language,\r
+ OUT CHAR16 **DriverName\r
+ )\r
+{\r
+ return LookupUnicodeString2 (\r
+ Language,\r
+ This->SupportedLanguages,\r
+ mFbGopDriverNameTable,\r
+ DriverName,\r
+ (BOOLEAN)(This == &gFbGopComponentName)\r
+ );\r
+}\r
+\r
+/**\r
+ Retrieves a Unicode string that is the user readable name of the controller\r
+ that is being managed by a driver.\r
+\r
+ This function retrieves the user readable name of the controller specified by\r
+ ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
+ driver specified by This has a user readable name in the language specified by\r
+ Language, then a pointer to the controller name is returned in ControllerName,\r
+ and EFI_SUCCESS is returned. If the driver specified by This is not currently\r
+ managing the controller specified by ControllerHandle and ChildHandle,\r
+ then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r
+ support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
+\r
+ @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
+ EFI_COMPONENT_NAME_PROTOCOL instance.\r
+\r
+ @param ControllerHandle[in] The handle of a controller that the driver\r
+ specified by This is managing. This handle\r
+ specifies the controller whose name is to be\r
+ returned.\r
+\r
+ @param ChildHandle[in] The handle of the child controller to retrieve\r
+ the name of. This is an optional parameter that\r
+ may be NULL. It will be NULL for device\r
+ drivers. It will also be NULL for a bus drivers\r
+ that wish to retrieve the name of the bus\r
+ controller. It will not be NULL for a bus\r
+ driver that wishes to retrieve the name of a\r
+ child controller.\r
+\r
+ @param Language[in] A pointer to a Null-terminated ASCII string\r
+ array indicating the language. This is the\r
+ language of the driver name that the caller is\r
+ requesting, and it must match one of the\r
+ languages specified in SupportedLanguages. The\r
+ number of languages supported by a driver is up\r
+ to the driver writer. Language is specified in\r
+ RFC 4646 or ISO 639-2 language code format.\r
+\r
+ @param ControllerName[out] A pointer to the Unicode string to return.\r
+ This Unicode string is the name of the\r
+ controller specified by ControllerHandle and\r
+ ChildHandle in the language specified by\r
+ Language from the point of view of the driver\r
+ specified by This.\r
+\r
+ @retval EFI_SUCCESS The Unicode string for the user readable name in\r
+ the language specified by Language for the\r
+ driver specified by This was returned in\r
+ DriverName.\r
+\r
+ @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
+\r
+ @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
+ EFI_HANDLE.\r
+\r
+ @retval EFI_INVALID_PARAMETER Language is NULL.\r
+\r
+ @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
+\r
+ @retval EFI_UNSUPPORTED The driver specified by This is not currently\r
+ managing the controller specified by\r
+ ControllerHandle and ChildHandle.\r
+\r
+ @retval EFI_UNSUPPORTED The driver specified by This does not support\r
+ the language specified by Language.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FbGopComponentNameGetControllerName (\r
+ IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN EFI_HANDLE ChildHandle OPTIONAL,\r
+ IN CHAR8 *Language,\r
+ OUT CHAR16 **ControllerName\r
+ )\r
+{\r
+ return EFI_UNSUPPORTED;\r
+}\r
--- /dev/null
+/** @file\r
+ ConsoleOut Routines that speak VGA.\r
+\r
+Copyright (c) 2007 - 2013, Intel Corporation. All rights reserved.<BR>\r
+\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions\r
+of the BSD License which accompanies this distribution. The\r
+full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "FbGop.h"\r
+\r
+EFI_PIXEL_BITMASK mPixelBitMask = {0x0000FF, 0x00FF00, 0xFF0000, 0x000000};\r
+\r
+//\r
+// Save controller attributes during first start\r
+//\r
+UINT64 mOriginalPciAttributes;\r
+BOOLEAN mPciAttributesSaved = FALSE;\r
+\r
+\r
+//\r
+// EFI Driver Binding Protocol Instance\r
+//\r
+EFI_DRIVER_BINDING_PROTOCOL gFbGopDriverBinding = {\r
+ FbGopDriverBindingSupported,\r
+ FbGopDriverBindingStart,\r
+ FbGopDriverBindingStop,\r
+ 0x3,\r
+ NULL,\r
+ NULL\r
+};\r
+\r
+//\r
+// Native resolution in EDID DetailedTiming[0]\r
+//\r
+UINT32 mNativeModeHorizontal;\r
+UINT32 mNativeModeVertical;\r
+\r
+/**\r
+ Supported.\r
+\r
+ @param This Pointer to driver binding protocol\r
+ @param Controller Controller handle to connect\r
+ @param RemainingDevicePath A pointer to the remaining portion of a device\r
+ path\r
+\r
+ @retval EFI_STATUS EFI_SUCCESS:This controller can be managed by this\r
+ driver, Otherwise, this controller cannot be\r
+ managed by this driver\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FbGopDriverBindingSupported (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE Controller,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_PCI_IO_PROTOCOL *PciIo;\r
+ PCI_TYPE00 Pci;\r
+ EFI_DEV_PATH *Node;\r
+\r
+ //\r
+ // Open the IO Abstraction(s) needed to perform the supported test\r
+ //\r
+ Status = gBS->OpenProtocol (\r
+ Controller,\r
+ &gEfiPciIoProtocolGuid,\r
+ (VOID **) &PciIo,\r
+ This->DriverBindingHandle,\r
+ Controller,\r
+ EFI_OPEN_PROTOCOL_BY_DRIVER\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+\r
+ //\r
+ // See if this is a PCI Graphics Controller by looking at the Command register and\r
+ // Class Code Register\r
+ //\r
+ Status = PciIo->Pci.Read (\r
+ PciIo,\r
+ EfiPciIoWidthUint32,\r
+ 0,\r
+ sizeof (Pci) / sizeof (UINT32),\r
+ &Pci\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ Status = EFI_UNSUPPORTED;\r
+ goto Done;\r
+ }\r
+\r
+ Status = EFI_UNSUPPORTED;\r
+ if (Pci.Hdr.ClassCode[2] == 0x03 || (Pci.Hdr.ClassCode[2] == 0x00 && Pci.Hdr.ClassCode[1] == 0x01)) {\r
+\r
+ Status = EFI_SUCCESS;\r
+ //\r
+ // If this is a graphics controller,\r
+ // go further check RemainingDevicePath validation\r
+ //\r
+ if (RemainingDevicePath != NULL) {\r
+ Node = (EFI_DEV_PATH *) RemainingDevicePath;\r
+ //\r
+ // Check if RemainingDevicePath is the End of Device Path Node, \r
+ // if yes, return EFI_SUCCESS\r
+ //\r
+ if (!IsDevicePathEnd (Node)) {\r
+ //\r
+ // If RemainingDevicePath isn't the End of Device Path Node,\r
+ // check its validation\r
+ //\r
+ if (Node->DevPath.Type != ACPI_DEVICE_PATH ||\r
+ Node->DevPath.SubType != ACPI_ADR_DP ||\r
+ DevicePathNodeLength(&Node->DevPath) < sizeof(ACPI_ADR_DEVICE_PATH)) {\r
+ Status = EFI_UNSUPPORTED;\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
+Done:\r
+ gBS->CloseProtocol (\r
+ Controller,\r
+ &gEfiPciIoProtocolGuid,\r
+ This->DriverBindingHandle,\r
+ Controller\r
+ );\r
+\r
+ return Status;\r
+}\r
+\r
+\r
+/**\r
+ Install Graphics Output Protocol onto VGA device handles.\r
+\r
+ @param This Pointer to driver binding protocol\r
+ @param Controller Controller handle to connect\r
+ @param RemainingDevicePath A pointer to the remaining portion of a device\r
+ path\r
+\r
+ @return EFI_STATUS\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FbGopDriverBindingStart (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE Controller,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;\r
+ EFI_PCI_IO_PROTOCOL *PciIo; \r
+ UINT64 Supports;\r
+\r
+ DEBUG ((EFI_D_INFO, "GOP START\n"));\r
+ \r
+ //\r
+ // Initialize local variables\r
+ //\r
+ PciIo = NULL;\r
+ ParentDevicePath = NULL;\r
+\r
+ //\r
+ // Prepare for status code\r
+ //\r
+ Status = gBS->HandleProtocol (\r
+ Controller,\r
+ &gEfiDevicePathProtocolGuid,\r
+ (VOID **) &ParentDevicePath\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+\r
+ //\r
+ // Open the IO Abstraction(s) needed\r
+ //\r
+ Status = gBS->OpenProtocol (\r
+ Controller,\r
+ &gEfiPciIoProtocolGuid,\r
+ (VOID **) &PciIo,\r
+ This->DriverBindingHandle,\r
+ Controller,\r
+ EFI_OPEN_PROTOCOL_BY_DRIVER\r
+ );\r
+ if (EFI_ERROR (Status) && (Status != EFI_ALREADY_STARTED)) {\r
+ return Status;\r
+ }\r
+\r
+ //\r
+ // Save original PCI attributes\r
+ //\r
+ if (!mPciAttributesSaved) {\r
+ Status = PciIo->Attributes (\r
+ PciIo,\r
+ EfiPciIoAttributeOperationGet,\r
+ 0,\r
+ &mOriginalPciAttributes\r
+ );\r
+ \r
+ if (EFI_ERROR (Status)) {\r
+ goto Done;\r
+ }\r
+ mPciAttributesSaved = TRUE;\r
+ }\r
+\r
+ //\r
+ // Get supported PCI attributes\r
+ //\r
+ Status = PciIo->Attributes (\r
+ PciIo,\r
+ EfiPciIoAttributeOperationSupported,\r
+ 0,\r
+ &Supports\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ goto Done;\r
+ }\r
+\r
+ Supports &= (EFI_PCI_IO_ATTRIBUTE_VGA_IO | EFI_PCI_IO_ATTRIBUTE_VGA_IO_16);\r
+ if (Supports == 0 || Supports == (EFI_PCI_IO_ATTRIBUTE_VGA_IO | EFI_PCI_IO_ATTRIBUTE_VGA_IO_16)) {\r
+ Status = EFI_UNSUPPORTED;\r
+ goto Done;\r
+ } \r
+ \r
+ REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
+ EFI_PROGRESS_CODE,\r
+ EFI_PERIPHERAL_LOCAL_CONSOLE | EFI_P_PC_ENABLE,\r
+ ParentDevicePath\r
+ );\r
+ //\r
+ // Enable the device and make sure VGA cycles are being forwarded to this VGA device\r
+ //\r
+ Status = PciIo->Attributes (\r
+ PciIo,\r
+ EfiPciIoAttributeOperationEnable,\r
+ EFI_PCI_DEVICE_ENABLE,\r
+ NULL\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
+ EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
+ EFI_PERIPHERAL_LOCAL_CONSOLE | EFI_P_EC_RESOURCE_CONFLICT,\r
+ ParentDevicePath\r
+ );\r
+ goto Done;\r
+ }\r
+\r
+ if (RemainingDevicePath != NULL) {\r
+ if (IsDevicePathEnd (RemainingDevicePath)) {\r
+ //\r
+ // If RemainingDevicePath is the End of Device Path Node,\r
+ // don't create any child device and return EFI_SUCESS\r
+ Status = EFI_SUCCESS;\r
+ goto Done;\r
+ }\r
+ }\r
+ \r
+ //\r
+ // Create child handle and install GraphicsOutputProtocol on it\r
+ //\r
+ Status = FbGopChildHandleInstall (\r
+ This,\r
+ Controller,\r
+ PciIo,\r
+ NULL,\r
+ ParentDevicePath,\r
+ RemainingDevicePath\r
+ );\r
+ \r
+Done:\r
+ if ((EFI_ERROR (Status)) && (Status != EFI_ALREADY_STARTED)) {\r
+ \r
+ REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
+ EFI_PROGRESS_CODE,\r
+ EFI_PERIPHERAL_LOCAL_CONSOLE | EFI_P_PC_DISABLE,\r
+ ParentDevicePath\r
+ );\r
+\r
+ REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
+ EFI_PROGRESS_CODE,\r
+ EFI_PERIPHERAL_LOCAL_CONSOLE | EFI_P_EC_NOT_DETECTED,\r
+ ParentDevicePath\r
+ );\r
+ if (!HasChildHandle (Controller)) {\r
+ if (mPciAttributesSaved) {\r
+ //\r
+ // Restore original PCI attributes\r
+ //\r
+ PciIo->Attributes (\r
+ PciIo,\r
+ EfiPciIoAttributeOperationSet,\r
+ mOriginalPciAttributes,\r
+ NULL\r
+ );\r
+ }\r
+ }\r
+ //\r
+ // Release PCI I/O Protocols on the controller handle.\r
+ //\r
+ gBS->CloseProtocol (\r
+ Controller,\r
+ &gEfiPciIoProtocolGuid,\r
+ This->DriverBindingHandle,\r
+ Controller\r
+ );\r
+ }\r
+\r
+ return Status;\r
+}\r
+\r
+\r
+/**\r
+ Stop.\r
+\r
+ @param This Pointer to driver binding protocol\r
+ @param Controller Controller handle to connect\r
+ @param NumberOfChildren Number of children handle created by this driver\r
+ @param ChildHandleBuffer Buffer containing child handle created\r
+\r
+ @retval EFI_SUCCESS Driver disconnected successfully from controller\r
+ @retval EFI_UNSUPPORTED Cannot find FB_VIDEO_DEV structure\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FbGopDriverBindingStop (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE Controller,\r
+ IN UINTN NumberOfChildren,\r
+ IN EFI_HANDLE *ChildHandleBuffer\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ BOOLEAN AllChildrenStopped;\r
+ UINTN Index;\r
+ EFI_PCI_IO_PROTOCOL *PciIo;\r
+\r
+ AllChildrenStopped = TRUE;\r
+\r
+ if (NumberOfChildren == 0) {\r
+ //\r
+ // Close PCI I/O protocol on the controller handle\r
+ //\r
+ gBS->CloseProtocol (\r
+ Controller,\r
+ &gEfiPciIoProtocolGuid,\r
+ This->DriverBindingHandle,\r
+ Controller\r
+ );\r
+\r
+ return EFI_SUCCESS;\r
+ }\r
+\r
+ for (Index = 0; Index < NumberOfChildren; Index++) {\r
+ \r
+ Status = EFI_SUCCESS;\r
+\r
+ FbGopChildHandleUninstall (This, Controller, ChildHandleBuffer[Index]);\r
+\r
+ if (EFI_ERROR (Status)) {\r
+ AllChildrenStopped = FALSE;\r
+ }\r
+ }\r
+\r
+ if (!AllChildrenStopped) {\r
+ return EFI_DEVICE_ERROR;\r
+ }\r
+\r
+ if (!HasChildHandle (Controller)) {\r
+ if (mPciAttributesSaved) {\r
+ Status = gBS->HandleProtocol (\r
+ Controller,\r
+ &gEfiPciIoProtocolGuid,\r
+ (VOID **) &PciIo\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+ \r
+ //\r
+ // Restore original PCI attributes\r
+ //\r
+ Status = PciIo->Attributes (\r
+ PciIo,\r
+ EfiPciIoAttributeOperationSet,\r
+ mOriginalPciAttributes,\r
+ NULL\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+ }\r
+ }\r
+\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+\r
+/**\r
+ Install child handles if the Handle supports MBR format.\r
+\r
+ @param This Calling context.\r
+ @param ParentHandle Parent Handle\r
+ @param ParentPciIo Parent PciIo interface\r
+ @param ParentLegacyBios Parent LegacyBios interface\r
+ @param ParentDevicePath Parent Device Path\r
+ @param RemainingDevicePath Remaining Device Path\r
+\r
+ @retval EFI_SUCCESS If a child handle was added\r
+ @retval other A child handle was not added\r
+\r
+**/\r
+EFI_STATUS\r
+FbGopChildHandleInstall (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE ParentHandle,\r
+ IN EFI_PCI_IO_PROTOCOL *ParentPciIo,\r
+ IN VOID *ParentLegacyBios,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ FB_VIDEO_DEV *FbGopPrivate;\r
+ PCI_TYPE00 Pci;\r
+ ACPI_ADR_DEVICE_PATH AcpiDeviceNode;\r
+ BOOLEAN ProtocolInstalled;\r
+\r
+ //\r
+ // Allocate the private device structure for video device\r
+ //\r
+ FbGopPrivate = (FB_VIDEO_DEV *) AllocateZeroPool (\r
+ sizeof (FB_VIDEO_DEV)\r
+ );\r
+ if (NULL == FbGopPrivate) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
+ goto Done;\r
+ }\r
+\r
+ //\r
+ // See if this is a VGA compatible controller or not\r
+ //\r
+ Status = ParentPciIo->Pci.Read (\r
+ ParentPciIo,\r
+ EfiPciIoWidthUint32,\r
+ 0,\r
+ sizeof (Pci) / sizeof (UINT32),\r
+ &Pci\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ REPORT_STATUS_CODE_WITH_DEVICE_PATH (\r
+ EFI_ERROR_CODE | EFI_ERROR_MINOR,\r
+ EFI_PERIPHERAL_LOCAL_CONSOLE | EFI_P_EC_CONTROLLER_ERROR,\r
+ ParentDevicePath\r
+ );\r
+ goto Done;\r
+ }\r
+ \r
+ //\r
+ // Initialize the child private structure\r
+ //\r
+ FbGopPrivate->Signature = FB_VIDEO_DEV_SIGNATURE;\r
+\r
+ //\r
+ // Fill in Graphics Output specific mode structures\r
+ // \r
+ FbGopPrivate->ModeData = NULL;\r
+ \r
+ FbGopPrivate->VbeFrameBuffer = NULL;\r
+\r
+ FbGopPrivate->EdidDiscovered.SizeOfEdid = 0;\r
+ FbGopPrivate->EdidDiscovered.Edid = NULL;\r
+ FbGopPrivate->EdidActive.SizeOfEdid = 0;\r
+ FbGopPrivate->EdidActive.Edid = NULL;\r
+ \r
+ //\r
+ // Fill in the Graphics Output Protocol\r
+ //\r
+ FbGopPrivate->GraphicsOutput.QueryMode = FbGopGraphicsOutputQueryMode;\r
+ FbGopPrivate->GraphicsOutput.SetMode = FbGopGraphicsOutputSetMode;\r
+\r
+\r
+ //\r
+ // Allocate buffer for Graphics Output Protocol mode information\r
+ //\r
+ FbGopPrivate->GraphicsOutput.Mode = (EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE *) AllocatePool (\r
+ sizeof (EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE)\r
+ );\r
+ if (NULL == FbGopPrivate->GraphicsOutput.Mode) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
+ goto Done;\r
+ }\r
+\r
+ FbGopPrivate->GraphicsOutput.Mode->Info = (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *) AllocatePool (\r
+ sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION)\r
+ );\r
+ if (NULL == FbGopPrivate->GraphicsOutput.Mode->Info) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
+ goto Done;\r
+ }\r
+\r
+ //\r
+ // Set Gop Device Path, here RemainingDevicePath will not be one End of Device Path Node.\r
+ //\r
+ if ((RemainingDevicePath == NULL) || (!IsDevicePathEnd (RemainingDevicePath))) {\r
+ if (RemainingDevicePath == NULL) {\r
+ ZeroMem (&AcpiDeviceNode, sizeof (ACPI_ADR_DEVICE_PATH));\r
+ AcpiDeviceNode.Header.Type = ACPI_DEVICE_PATH;\r
+ AcpiDeviceNode.Header.SubType = ACPI_ADR_DP;\r
+ AcpiDeviceNode.ADR = ACPI_DISPLAY_ADR (1, 0, 0, 1, 0, ACPI_ADR_DISPLAY_TYPE_VGA, 0, 0);\r
+ SetDevicePathNodeLength (&AcpiDeviceNode.Header, sizeof (ACPI_ADR_DEVICE_PATH));\r
+ \r
+ FbGopPrivate->GopDevicePath = AppendDevicePathNode (\r
+ ParentDevicePath,\r
+ (EFI_DEVICE_PATH_PROTOCOL *) &AcpiDeviceNode\r
+ );\r
+ } else {\r
+ FbGopPrivate->GopDevicePath = AppendDevicePathNode (ParentDevicePath, RemainingDevicePath);\r
+ }\r
+ \r
+ //\r
+ // Creat child handle and device path protocol firstly\r
+ //\r
+ FbGopPrivate->Handle = NULL;\r
+ Status = gBS->InstallMultipleProtocolInterfaces (\r
+ &FbGopPrivate->Handle,\r
+ &gEfiDevicePathProtocolGuid,\r
+ FbGopPrivate->GopDevicePath,\r
+ NULL\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ goto Done;\r
+ }\r
+ }\r
+ \r
+ //\r
+ // When check for VBE, PCI I/O protocol is needed, so use parent's protocol interface temporally\r
+ //\r
+ FbGopPrivate->PciIo = ParentPciIo;\r
+\r
+ //\r
+ // Check for VESA BIOS Extensions for modes that are compatible with Graphics Output\r
+ //\r
+ Status = FbGopCheckForVbe (FbGopPrivate);\r
+ DEBUG ((EFI_D_INFO, "FbGopCheckForVbe - %r\n", Status));\r
+ \r
+ if (EFI_ERROR (Status)) {\r
+ Status = EFI_UNSUPPORTED;\r
+ //goto Done; \r
+ }\r
+\r
+ ProtocolInstalled = FALSE;\r
+ \r
+ //\r
+ // Creat child handle and install Graphics Output Protocol,EDID Discovered/Active Protocol\r
+ //\r
+ Status = gBS->InstallMultipleProtocolInterfaces (\r
+ &FbGopPrivate->Handle,\r
+ &gEfiGraphicsOutputProtocolGuid,\r
+ &FbGopPrivate->GraphicsOutput, \r
+ &gEfiEdidDiscoveredProtocolGuid,\r
+ &FbGopPrivate->EdidDiscovered, \r
+ &gEfiEdidActiveProtocolGuid,\r
+ &FbGopPrivate->EdidActive, \r
+ NULL\r
+ );\r
+\r
+ if (!EFI_ERROR (Status)) {\r
+ //\r
+ // Open the Parent Handle for the child\r
+ //\r
+ Status = gBS->OpenProtocol (\r
+ ParentHandle,\r
+ &gEfiPciIoProtocolGuid,\r
+ (VOID **) &FbGopPrivate->PciIo,\r
+ This->DriverBindingHandle,\r
+ FbGopPrivate->Handle,\r
+ EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ goto Done;\r
+ }\r
+ ProtocolInstalled = TRUE;\r
+ }\r
+ \r
+Done:\r
+ if (EFI_ERROR (Status)) {\r
+ //\r
+ // Free private data structure\r
+ //\r
+ FbGopDeviceReleaseResource (FbGopPrivate);\r
+ }\r
+\r
+ return Status;\r
+}\r
+\r
+\r
+/**\r
+ Deregister an video child handle and free resources.\r
+\r
+ @param This Protocol instance pointer.\r
+ @param Controller Video controller handle\r
+ @param Handle Video child handle\r
+\r
+ @return EFI_STATUS\r
+\r
+**/\r
+EFI_STATUS\r
+FbGopChildHandleUninstall (\r
+ EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ EFI_HANDLE Controller,\r
+ EFI_HANDLE Handle\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput; \r
+ FB_VIDEO_DEV *FbGopPrivate;\r
+ EFI_PCI_IO_PROTOCOL *PciIo;\r
+\r
+ FbGopPrivate = NULL;\r
+ GraphicsOutput = NULL;\r
+ PciIo = NULL;\r
+ Status = EFI_UNSUPPORTED;\r
+\r
+ Status = gBS->OpenProtocol (\r
+ Handle,\r
+ &gEfiGraphicsOutputProtocolGuid,\r
+ (VOID **) &GraphicsOutput,\r
+ This->DriverBindingHandle,\r
+ Handle,\r
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+ );\r
+ if (!EFI_ERROR (Status)) {\r
+ FbGopPrivate = FB_VIDEO_DEV_FROM_GRAPHICS_OUTPUT_THIS (GraphicsOutput);\r
+ }\r
+ \r
+ if (FbGopPrivate == NULL) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
+ //\r
+ // Close PCI I/O protocol that opened by child handle\r
+ //\r
+ Status = gBS->CloseProtocol (\r
+ Controller,\r
+ &gEfiPciIoProtocolGuid,\r
+ This->DriverBindingHandle,\r
+ Handle\r
+ );\r
+\r
+ //\r
+ // Uninstall protocols on child handle\r
+ //\r
+ Status = gBS->UninstallMultipleProtocolInterfaces (\r
+ FbGopPrivate->Handle,\r
+ &gEfiDevicePathProtocolGuid,\r
+ FbGopPrivate->GopDevicePath,\r
+ &gEfiGraphicsOutputProtocolGuid,\r
+ &FbGopPrivate->GraphicsOutput,\r
+ NULL\r
+ );\r
+ \r
+ if (EFI_ERROR (Status)) {\r
+ gBS->OpenProtocol (\r
+ Controller,\r
+ &gEfiPciIoProtocolGuid,\r
+ (VOID **) &PciIo,\r
+ This->DriverBindingHandle,\r
+ Handle,\r
+ EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r
+ );\r
+ return Status;\r
+ }\r
+ \r
+ //\r
+ // Release all allocated resources\r
+ //\r
+ FbGopDeviceReleaseResource (FbGopPrivate);\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+\r
+/**\r
+ Release resource for biso video instance.\r
+\r
+ @param FbGopPrivate Video child device private data structure\r
+\r
+**/\r
+VOID\r
+FbGopDeviceReleaseResource (\r
+ FB_VIDEO_DEV *FbGopPrivate\r
+ )\r
+{\r
+ if (FbGopPrivate == NULL) {\r
+ return ;\r
+ }\r
+\r
+ //\r
+ // Release all the resourses occupied by the FB_VIDEO_DEV\r
+ //\r
+ \r
+ //\r
+ // Free VBE Frame Buffer\r
+ //\r
+ if (FbGopPrivate->VbeFrameBuffer != NULL) {\r
+ FreePool (FbGopPrivate->VbeFrameBuffer);\r
+ }\r
+ \r
+ //\r
+ // Free mode data\r
+ //\r
+ if (FbGopPrivate->ModeData != NULL) {\r
+ FreePool (FbGopPrivate->ModeData);\r
+ } \r
+\r
+ //\r
+ // Free graphics output protocol occupied resource\r
+ //\r
+ if (FbGopPrivate->GraphicsOutput.Mode != NULL) {\r
+ if (FbGopPrivate->GraphicsOutput.Mode->Info != NULL) {\r
+ FreePool (FbGopPrivate->GraphicsOutput.Mode->Info);\r
+ FbGopPrivate->GraphicsOutput.Mode->Info = NULL;\r
+ }\r
+ FreePool (FbGopPrivate->GraphicsOutput.Mode);\r
+ FbGopPrivate->GraphicsOutput.Mode = NULL;\r
+ } \r
+\r
+ if (FbGopPrivate->GopDevicePath!= NULL) {\r
+ FreePool (FbGopPrivate->GopDevicePath);\r
+ }\r
+\r
+ FreePool (FbGopPrivate);\r
+\r
+ return ;\r
+}\r
+\r
+\r
+\r
+/**\r
+ Check if all video child handles have been uninstalled.\r
+\r
+ @param Controller Video controller handle\r
+\r
+ @return TRUE Child handles exist.\r
+ @return FALSE All video child handles have been uninstalled.\r
+\r
+**/\r
+BOOLEAN\r
+HasChildHandle (\r
+ IN EFI_HANDLE Controller\r
+ )\r
+{\r
+ UINTN Index;\r
+ EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *OpenInfoBuffer;\r
+ UINTN EntryCount;\r
+ BOOLEAN HasChild;\r
+ EFI_STATUS Status;\r
+\r
+ EntryCount = 0;\r
+ HasChild = FALSE;\r
+ Status = gBS->OpenProtocolInformation (\r
+ Controller,\r
+ &gEfiPciIoProtocolGuid,\r
+ &OpenInfoBuffer,\r
+ &EntryCount\r
+ );\r
+ for (Index = 0; Index < EntryCount; Index++) {\r
+ if ((OpenInfoBuffer[Index].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) {\r
+ HasChild = TRUE;\r
+ }\r
+ }\r
+ \r
+ return HasChild;\r
+}\r
+\r
+/**\r
+ Check for VBE device.\r
+\r
+ @param FbGopPrivate Pointer to FB_VIDEO_DEV structure\r
+\r
+ @retval EFI_SUCCESS VBE device found\r
+\r
+**/\r
+EFI_STATUS\r
+FbGopCheckForVbe (\r
+ IN OUT FB_VIDEO_DEV *FbGopPrivate\r
+ )\r
+{\r
+ EFI_STATUS Status; \r
+ FB_VIDEO_MODE_DATA *ModeBuffer;\r
+ FB_VIDEO_MODE_DATA *CurrentModeData; \r
+ UINTN ModeNumber; \r
+ UINTN BitsPerPixel; \r
+ UINTN BytesPerScanLine;\r
+ UINT32 HorizontalResolution;\r
+ UINT32 VerticalResolution;\r
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL *VbeFrameBuffer; \r
+ EFI_HOB_GUID_TYPE *GuidHob;\r
+ FRAME_BUFFER_INFO *pFbInfo;\r
+ \r
+ Status = EFI_SUCCESS;\r
+ //\r
+ // Find the frame buffer information guid hob\r
+ //\r
+ GuidHob = GetFirstGuidHob (&gUefiFrameBufferInfoGuid);\r
+ ASSERT (GuidHob != NULL);\r
+ pFbInfo = (FRAME_BUFFER_INFO *)GET_GUID_HOB_DATA (GuidHob);\r
+ \r
+ //\r
+ // Add mode to the list of available modes\r
+ //\r
+ VbeFrameBuffer = NULL;\r
+ ModeBuffer = NULL;\r
+ \r
+ ModeNumber = 1; \r
+ BitsPerPixel = pFbInfo->BitsPerPixel;\r
+ HorizontalResolution = pFbInfo->HorizontalResolution;\r
+ VerticalResolution = pFbInfo->VerticalResolution;\r
+ BytesPerScanLine = HorizontalResolution * (BitsPerPixel / 8);\r
+ \r
+ ModeBuffer = (FB_VIDEO_MODE_DATA *) AllocatePool (\r
+ ModeNumber * sizeof (FB_VIDEO_MODE_DATA)\r
+ );\r
+ if (NULL == ModeBuffer) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
+ goto Done;\r
+ }\r
+\r
+ VbeFrameBuffer =\r
+ (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) AllocatePool (\r
+ BytesPerScanLine * VerticalResolution\r
+ );\r
+ if (NULL == VbeFrameBuffer) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
+ goto Done;\r
+ }\r
+ \r
+ if (FbGopPrivate->ModeData != NULL) {\r
+ FreePool (FbGopPrivate->ModeData);\r
+ }\r
+ \r
+ if (FbGopPrivate->VbeFrameBuffer != NULL) {\r
+ FreePool (FbGopPrivate->VbeFrameBuffer);\r
+ } \r
+ \r
+ CurrentModeData = &ModeBuffer[ModeNumber - 1];\r
+ CurrentModeData->BytesPerScanLine = (UINT16)BytesPerScanLine;\r
+ \r
+ CurrentModeData->Red = *(FB_VIDEO_COLOR_PLACEMENT *)&(pFbInfo->Red); \r
+ CurrentModeData->Blue = *(FB_VIDEO_COLOR_PLACEMENT *)&(pFbInfo->Blue); \r
+ CurrentModeData->Green = *(FB_VIDEO_COLOR_PLACEMENT *)&(pFbInfo->Green); \r
+ CurrentModeData->Reserved = *(FB_VIDEO_COLOR_PLACEMENT *)&(pFbInfo->Reserved); \r
+ \r
+ CurrentModeData->BitsPerPixel = (UINT32)BitsPerPixel;\r
+ CurrentModeData->HorizontalResolution = HorizontalResolution;\r
+ CurrentModeData->VerticalResolution = VerticalResolution; \r
+ CurrentModeData->FrameBufferSize = CurrentModeData->BytesPerScanLine * CurrentModeData->VerticalResolution; \r
+ CurrentModeData->LinearFrameBuffer = (VOID *) (UINTN) pFbInfo->LinearFrameBuffer;\r
+ CurrentModeData->VbeModeNumber = 0;\r
+ CurrentModeData->ColorDepth = 32;\r
+ CurrentModeData->RefreshRate = 60;\r
+ \r
+ CurrentModeData->PixelFormat = PixelBitMask;\r
+ if ((CurrentModeData->BitsPerPixel == 32) &&\r
+ (CurrentModeData->Red.Mask == 0xff) && (CurrentModeData->Green.Mask == 0xff) && (CurrentModeData->Blue.Mask == 0xff)) {\r
+ if ((CurrentModeData->Red.Position == 0) && (CurrentModeData->Green.Position == 8) && (CurrentModeData->Blue.Position == 16)) {\r
+ CurrentModeData->PixelFormat = PixelRedGreenBlueReserved8BitPerColor;\r
+ } else if ((CurrentModeData->Blue.Position == 0) && (CurrentModeData->Green.Position == 8) && (CurrentModeData->Red.Position == 16)) {\r
+ CurrentModeData->PixelFormat = PixelBlueGreenRedReserved8BitPerColor;\r
+ }\r
+ } \r
+ \r
+ CopyMem (&(CurrentModeData->PixelBitMask), &mPixelBitMask, sizeof (EFI_PIXEL_BITMASK)); \r
+ \r
+ FbGopPrivate->ModeData = ModeBuffer;\r
+ FbGopPrivate->VbeFrameBuffer = VbeFrameBuffer;\r
+ \r
+ //\r
+ // Assign Gop's Blt function\r
+ //\r
+ FbGopPrivate->GraphicsOutput.Blt = FbGopGraphicsOutputVbeBlt;\r
+ \r
+ FbGopPrivate->GraphicsOutput.Mode->MaxMode = 1;\r
+ FbGopPrivate->GraphicsOutput.Mode->Mode = 0; \r
+ FbGopPrivate->GraphicsOutput.Mode->Info->Version = 0;\r
+ FbGopPrivate->GraphicsOutput.Mode->Info->HorizontalResolution = HorizontalResolution;\r
+ FbGopPrivate->GraphicsOutput.Mode->Info->VerticalResolution = VerticalResolution; \r
+ FbGopPrivate->GraphicsOutput.Mode->Info->PixelFormat = CurrentModeData->PixelFormat;\r
+ CopyMem (&(FbGopPrivate->GraphicsOutput.Mode->Info->PixelInformation), &mPixelBitMask, sizeof (EFI_PIXEL_BITMASK)); \r
+ FbGopPrivate->GraphicsOutput.Mode->Info->PixelsPerScanLine = HorizontalResolution; \r
+ FbGopPrivate->GraphicsOutput.Mode->SizeOfInfo = sizeof(EFI_GRAPHICS_OUTPUT_MODE_INFORMATION);\r
+ FbGopPrivate->GraphicsOutput.Mode->FrameBufferBase = (EFI_PHYSICAL_ADDRESS) (UINTN) CurrentModeData->LinearFrameBuffer;\r
+ FbGopPrivate->GraphicsOutput.Mode->FrameBufferSize = CurrentModeData->FrameBufferSize;\r
+ \r
+ //\r
+ // Find the best mode to initialize\r
+ // \r
+\r
+Done:\r
+ //\r
+ // If there was an error, then free the mode structure\r
+ //\r
+ if (EFI_ERROR (Status)) {\r
+ \r
+ if (VbeFrameBuffer != NULL) {\r
+ FreePool (VbeFrameBuffer);\r
+ } \r
+ \r
+ if (ModeBuffer != NULL) {\r
+ FreePool (ModeBuffer);\r
+ } \r
+ }\r
+\r
+ return Status;\r
+}\r
+\r
+\r
+//\r
+// Graphics Output Protocol Member Functions for VESA BIOS Extensions\r
+//\r
+\r
+/**\r
+ Graphics Output protocol interface to get video mode.\r
+\r
+ @param This Protocol instance pointer.\r
+ @param ModeNumber The mode number to return information on.\r
+ @param SizeOfInfo A pointer to the size, in bytes, of the Info\r
+ buffer.\r
+ @param Info Caller allocated buffer that returns information\r
+ about ModeNumber.\r
+\r
+ @retval EFI_SUCCESS Mode information returned.\r
+ @retval EFI_DEVICE_ERROR A hardware error occurred trying to retrieve the\r
+ video mode.\r
+ @retval EFI_NOT_STARTED Video display is not initialized. Call SetMode ()\r
+ @retval EFI_INVALID_PARAMETER One of the input args was NULL.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FbGopGraphicsOutputQueryMode (\r
+ IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,\r
+ IN UINT32 ModeNumber,\r
+ OUT UINTN *SizeOfInfo,\r
+ OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION **Info\r
+ )\r
+{\r
+ FB_VIDEO_DEV *FbGopPrivate;\r
+ FB_VIDEO_MODE_DATA *ModeData;\r
+\r
+ FbGopPrivate = FB_VIDEO_DEV_FROM_GRAPHICS_OUTPUT_THIS (This);\r
+\r
+ if (This == NULL || Info == NULL || SizeOfInfo == NULL || ModeNumber >= This->Mode->MaxMode) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ *Info = (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *) AllocatePool (\r
+ sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION)\r
+ );\r
+ if (NULL == *Info) {\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
+\r
+ *SizeOfInfo = sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION);\r
+\r
+ ModeData = &FbGopPrivate->ModeData[ModeNumber];\r
+ (*Info)->Version = 0;\r
+ (*Info)->HorizontalResolution = ModeData->HorizontalResolution;\r
+ (*Info)->VerticalResolution = ModeData->VerticalResolution;\r
+ (*Info)->PixelFormat = ModeData->PixelFormat;\r
+ CopyMem (&((*Info)->PixelInformation), &(ModeData->PixelBitMask), sizeof(ModeData->PixelBitMask));\r
+\r
+ (*Info)->PixelsPerScanLine = (ModeData->BytesPerScanLine * 8) / ModeData->BitsPerPixel;\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+ Graphics Output protocol interface to set video mode.\r
+\r
+ @param This Protocol instance pointer.\r
+ @param ModeNumber The mode number to be set.\r
+\r
+ @retval EFI_SUCCESS Graphics mode was changed.\r
+ @retval EFI_DEVICE_ERROR The device had an error and could not complete the\r
+ request.\r
+ @retval EFI_UNSUPPORTED ModeNumber is not supported by this device.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FbGopGraphicsOutputSetMode (\r
+ IN EFI_GRAPHICS_OUTPUT_PROTOCOL * This,\r
+ IN UINT32 ModeNumber\r
+ )\r
+{ \r
+ FB_VIDEO_DEV *FbGopPrivate;\r
+ FB_VIDEO_MODE_DATA *ModeData;\r
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background;\r
+\r
+ if (This == NULL) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ FbGopPrivate = FB_VIDEO_DEV_FROM_GRAPHICS_OUTPUT_THIS (This);\r
+\r
+ ModeData = &FbGopPrivate->ModeData[ModeNumber];\r
+\r
+ if (ModeNumber >= This->Mode->MaxMode) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+ \r
+ if (ModeNumber == This->Mode->Mode) {\r
+ //\r
+ // Clear screen to black\r
+ // \r
+ ZeroMem (&Background, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));\r
+ FbGopGraphicsOutputVbeBlt (\r
+ This,\r
+ &Background,\r
+ EfiBltVideoFill,\r
+ 0,\r
+ 0,\r
+ 0,\r
+ 0,\r
+ ModeData->HorizontalResolution,\r
+ ModeData->VerticalResolution,\r
+ 0\r
+ );\r
+ return EFI_SUCCESS;\r
+ } else {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+ \r
+}\r
+\r
+/**\r
+ Update physical frame buffer, copy 4 bytes block, then copy remaining bytes.\r
+\r
+ @param PciIo The pointer of EFI_PCI_IO_PROTOCOL\r
+ @param VbeBuffer The data to transfer to screen\r
+ @param MemAddress Physical frame buffer base address\r
+ @param DestinationX The X coordinate of the destination for BltOperation\r
+ @param DestinationY The Y coordinate of the destination for BltOperation\r
+ @param TotalBytes The total bytes of copy\r
+ @param VbePixelWidth Bytes per pixel\r
+ @param BytesPerScanLine Bytes per scan line\r
+\r
+**/\r
+VOID\r
+CopyVideoBuffer (\r
+ IN EFI_PCI_IO_PROTOCOL *PciIo,\r
+ IN UINT8 *VbeBuffer,\r
+ IN VOID *MemAddress,\r
+ IN UINTN DestinationX,\r
+ IN UINTN DestinationY,\r
+ IN UINTN TotalBytes,\r
+ IN UINT32 VbePixelWidth,\r
+ IN UINTN BytesPerScanLine\r
+ )\r
+{\r
+ UINTN FrameBufferAddr;\r
+ UINTN CopyBlockNum;\r
+ UINTN RemainingBytes;\r
+ UINTN UnalignedBytes;\r
+ EFI_STATUS Status;\r
+\r
+ FrameBufferAddr = (UINTN) MemAddress + (DestinationY * BytesPerScanLine) + DestinationX * VbePixelWidth;\r
+\r
+ //\r
+ // If TotalBytes is less than 4 bytes, only start byte copy.\r
+ //\r
+ if (TotalBytes < 4) {\r
+ Status = PciIo->Mem.Write (\r
+ PciIo,\r
+ EfiPciIoWidthUint8,\r
+ EFI_PCI_IO_PASS_THROUGH_BAR,\r
+ (UINT64) FrameBufferAddr,\r
+ TotalBytes,\r
+ VbeBuffer\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+ return;\r
+ }\r
+\r
+ //\r
+ // If VbeBuffer is not 4-byte aligned, start byte copy.\r
+ //\r
+ UnalignedBytes = (4 - ((UINTN) VbeBuffer & 0x3)) & 0x3;\r
+\r
+ if (UnalignedBytes != 0) {\r
+ Status = PciIo->Mem.Write (\r
+ PciIo,\r
+ EfiPciIoWidthUint8,\r
+ EFI_PCI_IO_PASS_THROUGH_BAR,\r
+ (UINT64) FrameBufferAddr,\r
+ UnalignedBytes,\r
+ VbeBuffer\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+ FrameBufferAddr += UnalignedBytes;\r
+ VbeBuffer += UnalignedBytes;\r
+ }\r
+\r
+ //\r
+ // Calculate 4-byte block count and remaining bytes.\r
+ //\r
+ CopyBlockNum = (TotalBytes - UnalignedBytes) >> 2;\r
+ RemainingBytes = (TotalBytes - UnalignedBytes) & 3;\r
+\r
+ //\r
+ // Copy 4-byte block and remaining bytes to physical frame buffer.\r
+ //\r
+ if (CopyBlockNum != 0) {\r
+ Status = PciIo->Mem.Write (\r
+ PciIo,\r
+ EfiPciIoWidthUint32,\r
+ EFI_PCI_IO_PASS_THROUGH_BAR,\r
+ (UINT64) FrameBufferAddr,\r
+ CopyBlockNum,\r
+ VbeBuffer\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+ }\r
+\r
+ if (RemainingBytes != 0) {\r
+ FrameBufferAddr += (CopyBlockNum << 2);\r
+ VbeBuffer += (CopyBlockNum << 2);\r
+ Status = PciIo->Mem.Write (\r
+ PciIo,\r
+ EfiPciIoWidthUint8,\r
+ EFI_PCI_IO_PASS_THROUGH_BAR,\r
+ (UINT64) FrameBufferAddr,\r
+ RemainingBytes,\r
+ VbeBuffer\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+ }\r
+}\r
+\r
+/**\r
+ Worker function to block transfer for VBE device.\r
+\r
+ @param FbGopPrivate Instance of FB_VIDEO_DEV\r
+ @param BltBuffer The data to transfer to screen\r
+ @param BltOperation The operation to perform\r
+ @param SourceX The X coordinate of the source for BltOperation\r
+ @param SourceY The Y coordinate of the source for BltOperation\r
+ @param DestinationX The X coordinate of the destination for\r
+ BltOperation\r
+ @param DestinationY The Y coordinate of the destination for\r
+ BltOperation\r
+ @param Width The width of a rectangle in the blt rectangle in\r
+ pixels\r
+ @param Height The height of a rectangle in the blt rectangle in\r
+ pixels\r
+ @param Delta Not used for EfiBltVideoFill and\r
+ EfiBltVideoToVideo operation. If a Delta of 0 is\r
+ used, the entire BltBuffer will be operated on. If\r
+ a subrectangle of the BltBuffer is used, then\r
+ Delta represents the number of bytes in a row of\r
+ the BltBuffer.\r
+ @param Mode Mode data.\r
+\r
+ @retval EFI_INVALID_PARAMETER Invalid parameter passed in\r
+ @retval EFI_SUCCESS Blt operation success\r
+\r
+**/\r
+EFI_STATUS\r
+FbGopVbeBltWorker (\r
+ IN FB_VIDEO_DEV *FbGopPrivate,\r
+ IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer, OPTIONAL\r
+ IN EFI_GRAPHICS_OUTPUT_BLT_OPERATION BltOperation,\r
+ IN UINTN SourceX,\r
+ IN UINTN SourceY,\r
+ IN UINTN DestinationX,\r
+ IN UINTN DestinationY,\r
+ IN UINTN Width,\r
+ IN UINTN Height,\r
+ IN UINTN Delta,\r
+ IN FB_VIDEO_MODE_DATA *Mode\r
+ )\r
+{\r
+ EFI_PCI_IO_PROTOCOL *PciIo;\r
+ EFI_TPL OriginalTPL;\r
+ UINTN DstY;\r
+ UINTN SrcY;\r
+ UINTN DstX;\r
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Blt;\r
+ VOID *MemAddress;\r
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL *VbeFrameBuffer;\r
+ UINTN BytesPerScanLine;\r
+ UINTN Index;\r
+ UINT8 *VbeBuffer;\r
+ UINT8 *VbeBuffer1;\r
+ UINT8 *BltUint8;\r
+ UINT32 VbePixelWidth;\r
+ UINT32 Pixel;\r
+ UINTN TotalBytes;\r
+\r
+ PciIo = FbGopPrivate->PciIo;\r
+\r
+ VbeFrameBuffer = FbGopPrivate->VbeFrameBuffer;\r
+ MemAddress = Mode->LinearFrameBuffer;\r
+ BytesPerScanLine = Mode->BytesPerScanLine;\r
+ VbePixelWidth = Mode->BitsPerPixel / 8;\r
+ BltUint8 = (UINT8 *) BltBuffer;\r
+ TotalBytes = Width * VbePixelWidth;\r
+\r
+ if (((UINTN) BltOperation) >= EfiGraphicsOutputBltOperationMax) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ if (Width == 0 || Height == 0) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+ //\r
+ // We need to fill the Virtual Screen buffer with the blt data.\r
+ // The virtual screen is upside down, as the first row is the bootom row of\r
+ // the image.\r
+ //\r
+ if (BltOperation == EfiBltVideoToBltBuffer) {\r
+ //\r
+ // Video to BltBuffer: Source is Video, destination is BltBuffer\r
+ //\r
+ if (SourceY + Height > Mode->VerticalResolution) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ if (SourceX + Width > Mode->HorizontalResolution) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+ } else {\r
+ //\r
+ // BltBuffer to Video: Source is BltBuffer, destination is Video\r
+ //\r
+ if (DestinationY + Height > Mode->VerticalResolution) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ if (DestinationX + Width > Mode->HorizontalResolution) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+ }\r
+ //\r
+ // If Delta is zero, then the entire BltBuffer is being used, so Delta\r
+ // is the number of bytes in each row of BltBuffer. Since BltBuffer is Width pixels size,\r
+ // the number of bytes in each row can be computed.\r
+ //\r
+ if (Delta == 0) {\r
+ Delta = Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL);\r
+ }\r
+ //\r
+ // We have to raise to TPL Notify, so we make an atomic write the frame buffer.\r
+ // We would not want a timer based event (Cursor, ...) to come in while we are\r
+ // doing this operation.\r
+ //\r
+ OriginalTPL = gBS->RaiseTPL (TPL_NOTIFY);\r
+\r
+ switch (BltOperation) {\r
+ case EfiBltVideoToBltBuffer:\r
+ for (SrcY = SourceY, DstY = DestinationY; DstY < (Height + DestinationY); SrcY++, DstY++) {\r
+ Blt = (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) (BltUint8 + DstY * Delta + DestinationX * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));\r
+ //\r
+ // Shuffle the packed bytes in the hardware buffer to match EFI_GRAPHICS_OUTPUT_BLT_PIXEL\r
+ //\r
+ VbeBuffer = ((UINT8 *) VbeFrameBuffer + (SrcY * BytesPerScanLine + SourceX * VbePixelWidth));\r
+ for (DstX = DestinationX; DstX < (Width + DestinationX); DstX++) {\r
+ Pixel = VbeBuffer[0] | VbeBuffer[1] << 8 | VbeBuffer[2] << 16 | VbeBuffer[3] << 24;\r
+ Blt->Red = (UINT8) ((Pixel >> Mode->Red.Position) & Mode->Red.Mask);\r
+ Blt->Blue = (UINT8) ((Pixel >> Mode->Blue.Position) & Mode->Blue.Mask);\r
+ Blt->Green = (UINT8) ((Pixel >> Mode->Green.Position) & Mode->Green.Mask);\r
+ Blt->Reserved = 0;\r
+ Blt++;\r
+ VbeBuffer += VbePixelWidth;\r
+ }\r
+\r
+ }\r
+ break;\r
+\r
+ case EfiBltVideoToVideo:\r
+ for (Index = 0; Index < Height; Index++) {\r
+ if (DestinationY <= SourceY) {\r
+ SrcY = SourceY + Index;\r
+ DstY = DestinationY + Index;\r
+ } else {\r
+ SrcY = SourceY + Height - Index - 1;\r
+ DstY = DestinationY + Height - Index - 1;\r
+ }\r
+\r
+ VbeBuffer = ((UINT8 *) VbeFrameBuffer + DstY * BytesPerScanLine + DestinationX * VbePixelWidth);\r
+ VbeBuffer1 = ((UINT8 *) VbeFrameBuffer + SrcY * BytesPerScanLine + SourceX * VbePixelWidth);\r
+\r
+ gBS->CopyMem (\r
+ VbeBuffer,\r
+ VbeBuffer1,\r
+ TotalBytes\r
+ );\r
+\r
+ //\r
+ // Update physical frame buffer.\r
+ //\r
+ CopyVideoBuffer (\r
+ PciIo,\r
+ VbeBuffer,\r
+ MemAddress,\r
+ DestinationX,\r
+ DstY,\r
+ TotalBytes,\r
+ VbePixelWidth,\r
+ BytesPerScanLine\r
+ );\r
+ }\r
+ break;\r
+\r
+ case EfiBltVideoFill:\r
+ VbeBuffer = (UINT8 *) ((UINTN) VbeFrameBuffer + (DestinationY * BytesPerScanLine) + DestinationX * VbePixelWidth);\r
+ Blt = (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) BltUint8;\r
+ //\r
+ // Shuffle the RGB fields in EFI_GRAPHICS_OUTPUT_BLT_PIXEL to match the hardware buffer\r
+ //\r
+ Pixel = ((Blt->Red & Mode->Red.Mask) << Mode->Red.Position) |\r
+ (\r
+ (Blt->Green & Mode->Green.Mask) <<\r
+ Mode->Green.Position\r
+ ) |\r
+ ((Blt->Blue & Mode->Blue.Mask) << Mode->Blue.Position);\r
+\r
+ for (Index = 0; Index < Width; Index++) {\r
+ gBS->CopyMem (\r
+ VbeBuffer,\r
+ &Pixel,\r
+ VbePixelWidth\r
+ );\r
+ VbeBuffer += VbePixelWidth;\r
+ }\r
+\r
+ VbeBuffer = (UINT8 *) ((UINTN) VbeFrameBuffer + (DestinationY * BytesPerScanLine) + DestinationX * VbePixelWidth);\r
+ for (DstY = DestinationY + 1; DstY < (Height + DestinationY); DstY++) {\r
+ gBS->CopyMem (\r
+ (VOID *) ((UINTN) VbeFrameBuffer + (DstY * BytesPerScanLine) + DestinationX * VbePixelWidth),\r
+ VbeBuffer,\r
+ TotalBytes\r
+ );\r
+ }\r
+\r
+ for (DstY = DestinationY; DstY < (Height + DestinationY); DstY++) {\r
+ //\r
+ // Update physical frame buffer.\r
+ //\r
+ CopyVideoBuffer (\r
+ PciIo,\r
+ VbeBuffer,\r
+ MemAddress,\r
+ DestinationX,\r
+ DstY,\r
+ TotalBytes,\r
+ VbePixelWidth,\r
+ BytesPerScanLine\r
+ );\r
+ }\r
+ break;\r
+\r
+ case EfiBltBufferToVideo:\r
+ for (SrcY = SourceY, DstY = DestinationY; SrcY < (Height + SourceY); SrcY++, DstY++) {\r
+ Blt = (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) (BltUint8 + (SrcY * Delta) + (SourceX) * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));\r
+ VbeBuffer = ((UINT8 *) VbeFrameBuffer + (DstY * BytesPerScanLine + DestinationX * VbePixelWidth));\r
+ for (DstX = DestinationX; DstX < (Width + DestinationX); DstX++) {\r
+ //\r
+ // Shuffle the RGB fields in EFI_GRAPHICS_OUTPUT_BLT_PIXEL to match the hardware buffer\r
+ //\r
+ Pixel = ((Blt->Red & Mode->Red.Mask) << Mode->Red.Position) |\r
+ ((Blt->Green & Mode->Green.Mask) << Mode->Green.Position) |\r
+ ((Blt->Blue & Mode->Blue.Mask) << Mode->Blue.Position);\r
+ gBS->CopyMem (\r
+ VbeBuffer,\r
+ &Pixel,\r
+ VbePixelWidth\r
+ );\r
+ Blt++;\r
+ VbeBuffer += VbePixelWidth;\r
+ }\r
+\r
+ VbeBuffer = ((UINT8 *) VbeFrameBuffer + (DstY * BytesPerScanLine + DestinationX * VbePixelWidth));\r
+\r
+ //\r
+ // Update physical frame buffer.\r
+ //\r
+ CopyVideoBuffer (\r
+ PciIo,\r
+ VbeBuffer,\r
+ MemAddress,\r
+ DestinationX,\r
+ DstY,\r
+ TotalBytes,\r
+ VbePixelWidth,\r
+ BytesPerScanLine\r
+ );\r
+ }\r
+ break;\r
+\r
+ default: ;\r
+ }\r
+\r
+ gBS->RestoreTPL (OriginalTPL);\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+ Graphics Output protocol instance to block transfer for VBE device.\r
+\r
+ @param This Pointer to Graphics Output protocol instance\r
+ @param BltBuffer The data to transfer to screen\r
+ @param BltOperation The operation to perform\r
+ @param SourceX The X coordinate of the source for BltOperation\r
+ @param SourceY The Y coordinate of the source for BltOperation\r
+ @param DestinationX The X coordinate of the destination for\r
+ BltOperation\r
+ @param DestinationY The Y coordinate of the destination for\r
+ BltOperation\r
+ @param Width The width of a rectangle in the blt rectangle in\r
+ pixels\r
+ @param Height The height of a rectangle in the blt rectangle in\r
+ pixels\r
+ @param Delta Not used for EfiBltVideoFill and\r
+ EfiBltVideoToVideo operation. If a Delta of 0 is\r
+ used, the entire BltBuffer will be operated on. If\r
+ a subrectangle of the BltBuffer is used, then\r
+ Delta represents the number of bytes in a row of\r
+ the BltBuffer.\r
+\r
+ @retval EFI_INVALID_PARAMETER Invalid parameter passed in\r
+ @retval EFI_SUCCESS Blt operation success\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FbGopGraphicsOutputVbeBlt (\r
+ IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,\r
+ IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer, OPTIONAL\r
+ IN EFI_GRAPHICS_OUTPUT_BLT_OPERATION BltOperation,\r
+ IN UINTN SourceX,\r
+ IN UINTN SourceY,\r
+ IN UINTN DestinationX,\r
+ IN UINTN DestinationY,\r
+ IN UINTN Width,\r
+ IN UINTN Height,\r
+ IN UINTN Delta\r
+ )\r
+{\r
+ FB_VIDEO_DEV *FbGopPrivate;\r
+ FB_VIDEO_MODE_DATA *Mode;\r
+\r
+ if (This == NULL) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ FbGopPrivate = FB_VIDEO_DEV_FROM_GRAPHICS_OUTPUT_THIS (This);\r
+ Mode = &FbGopPrivate->ModeData[This->Mode->Mode];\r
+\r
+ return FbGopVbeBltWorker (\r
+ FbGopPrivate,\r
+ BltBuffer,\r
+ BltOperation,\r
+ SourceX,\r
+ SourceY,\r
+ DestinationX,\r
+ DestinationY,\r
+ Width,\r
+ Height,\r
+ Delta,\r
+ Mode\r
+ );\r
+}\r
+\r
+\r
+/**\r
+ The user Entry Point for module UefiFbGop. The user code starts with this function.\r
+\r
+ @param[in] ImageHandle The firmware allocated handle for the EFI image.\r
+ @param[in] SystemTable A pointer to the EFI System Table.\r
+\r
+ @retval EFI_SUCCESS The entry point is executed successfully.\r
+ @retval other Some error occurs when executing this entry point.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FbGopEntryPoint(\r
+ IN EFI_HANDLE ImageHandle,\r
+ IN EFI_SYSTEM_TABLE *SystemTable\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_HOB_GUID_TYPE *GuidHob;\r
+ \r
+ //\r
+ // Find the frame buffer information guid hob\r
+ //\r
+ GuidHob = GetFirstGuidHob (&gUefiFrameBufferInfoGuid);\r
+ if (GuidHob != NULL) { \r
+ //\r
+ // Install driver model protocol(s).\r
+ //\r
+ Status = EfiLibInstallDriverBindingComponentName2 (\r
+ ImageHandle,\r
+ SystemTable,\r
+ &gFbGopDriverBinding,\r
+ ImageHandle,\r
+ &gFbGopComponentName,\r
+ &gFbGopComponentName2\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+ } else {\r
+ DEBUG ((EFI_D_ERROR, "No FrameBuffer information from coreboot. NO GOP driver !!!\n"));\r
+ Status = EFI_ABORTED;\r
+ }\r
+ return Status; \r
+}\r
+\r
--- /dev/null
+/** @file\r
+\r
+Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
+\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions\r
+of the BSD License which accompanies this distribution. The\r
+full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#ifndef _FB_GOP_H_\r
+#define _FB_GOP_H_\r
+\r
+#include <Protocol/PciIo.h>\r
+#include <Protocol/DevicePath.h>\r
+#include <Protocol/GraphicsOutput.h>\r
+#include <Protocol/EdidActive.h>\r
+#include <Protocol/EdidDiscovered.h>\r
+\r
+#include <Guid/StatusCodeDataTypeId.h>\r
+#include <Guid/EventGroup.h>\r
+#include <Guid/FrameBufferInfoGuid.h>\r
+\r
+#include <Library/PcdLib.h>\r
+#include <Library/HobLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/ReportStatusCodeLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/UefiDriverEntryPoint.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/UefiLib.h>\r
+#include <Library/DevicePathLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+\r
+#include <IndustryStandard/Pci.h>\r
+\r
+//\r
+// Packed format support: The number of bits reserved for each of the colors and the actual\r
+// position of RGB in the frame buffer is specified in the VBE Mode information\r
+//\r
+typedef struct {\r
+ UINT8 Position; // Position of the color\r
+ UINT8 Mask; // The number of bits expressed as a mask\r
+} FB_VIDEO_COLOR_PLACEMENT;\r
+\r
+//\r
+// BIOS Graphics Output Graphical Mode Data\r
+//\r
+typedef struct {\r
+ UINT16 VbeModeNumber;\r
+ UINT16 BytesPerScanLine;\r
+ VOID *LinearFrameBuffer;\r
+ UINTN FrameBufferSize;\r
+ UINT32 HorizontalResolution;\r
+ UINT32 VerticalResolution;\r
+ UINT32 ColorDepth;\r
+ UINT32 RefreshRate;\r
+ UINT32 BitsPerPixel;\r
+ FB_VIDEO_COLOR_PLACEMENT Red;\r
+ FB_VIDEO_COLOR_PLACEMENT Green;\r
+ FB_VIDEO_COLOR_PLACEMENT Blue;\r
+ FB_VIDEO_COLOR_PLACEMENT Reserved;\r
+ EFI_GRAPHICS_PIXEL_FORMAT PixelFormat;\r
+ EFI_PIXEL_BITMASK PixelBitMask;\r
+} FB_VIDEO_MODE_DATA;\r
+\r
+//\r
+// BIOS video child handle private data Structure\r
+//\r
+#define FB_VIDEO_DEV_SIGNATURE SIGNATURE_32 ('B', 'V', 'M', 'p')\r
+\r
+typedef struct {\r
+ UINTN Signature;\r
+ EFI_HANDLE Handle;\r
+\r
+ //\r
+ // Consumed Protocols\r
+ //\r
+ EFI_PCI_IO_PROTOCOL *PciIo; \r
+\r
+ //\r
+ // Produced Protocols\r
+ //\r
+ EFI_GRAPHICS_OUTPUT_PROTOCOL GraphicsOutput;\r
+ EFI_EDID_DISCOVERED_PROTOCOL EdidDiscovered;\r
+ EFI_EDID_ACTIVE_PROTOCOL EdidActive;\r
+\r
+ //\r
+ // Graphics Output Protocol related fields\r
+ //\r
+ UINTN CurrentMode;\r
+ UINTN MaxMode;\r
+ FB_VIDEO_MODE_DATA *ModeData;\r
+ \r
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL *VbeFrameBuffer;\r
+ \r
+ //\r
+ // Status code\r
+ //\r
+ EFI_DEVICE_PATH_PROTOCOL *GopDevicePath;\r
+ \r
+} FB_VIDEO_DEV;\r
+\r
+#define FB_VIDEO_DEV_FROM_PCI_IO_THIS(a) CR (a, FB_VIDEO_DEV, PciIo, FB_VIDEO_DEV_SIGNATURE)\r
+#define FB_VIDEO_DEV_FROM_GRAPHICS_OUTPUT_THIS(a) CR (a, FB_VIDEO_DEV, GraphicsOutput, FB_VIDEO_DEV_SIGNATURE)\r
+\r
+#define GRAPHICS_OUTPUT_INVALIDE_MODE_NUMBER 0xffff\r
+\r
+//\r
+// Global Variables\r
+//\r
+extern EFI_DRIVER_BINDING_PROTOCOL gFbGopDriverBinding;\r
+extern EFI_COMPONENT_NAME_PROTOCOL gFbGopComponentName;\r
+extern EFI_COMPONENT_NAME2_PROTOCOL gFbGopComponentName2;\r
+\r
+//\r
+// Driver Binding Protocol functions\r
+//\r
+\r
+/**\r
+ Supported.\r
+\r
+ @param This Pointer to driver binding protocol\r
+ @param Controller Controller handle to connect\r
+ @param RemainingDevicePath A pointer to the remaining portion of a device\r
+ path\r
+\r
+ @retval EFI_STATUS EFI_SUCCESS:This controller can be managed by this\r
+ driver, Otherwise, this controller cannot be\r
+ managed by this driver\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FbGopDriverBindingSupported (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE Controller,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
+ );\r
+\r
+\r
+/**\r
+ Install Graphics Output Protocol onto VGA device handles.\r
+\r
+ @param This Pointer to driver binding protocol\r
+ @param Controller Controller handle to connect\r
+ @param RemainingDevicePath A pointer to the remaining portion of a device\r
+ path\r
+\r
+ @return EFI_STATUS\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FbGopDriverBindingStart (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE Controller,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
+ );\r
+\r
+\r
+/**\r
+ Stop.\r
+\r
+ @param This Pointer to driver binding protocol\r
+ @param Controller Controller handle to connect\r
+ @param NumberOfChildren Number of children handle created by this driver\r
+ @param ChildHandleBuffer Buffer containing child handle created\r
+\r
+ @retval EFI_SUCCESS Driver disconnected successfully from controller\r
+ @retval EFI_UNSUPPORTED Cannot find FB_VIDEO_DEV structure\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FbGopDriverBindingStop (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE Controller,\r
+ IN UINTN NumberOfChildren,\r
+ IN EFI_HANDLE *ChildHandleBuffer\r
+ );\r
+\r
+//\r
+// Private worker functions\r
+//\r
+\r
+/**\r
+ Check for VBE device.\r
+\r
+ @param FbGopPrivate Pointer to FB_VIDEO_DEV structure\r
+\r
+ @retval EFI_SUCCESS VBE device found\r
+\r
+**/\r
+EFI_STATUS\r
+FbGopCheckForVbe (\r
+ IN OUT FB_VIDEO_DEV *FbGopPrivate\r
+ );\r
+\r
+\r
+\r
+/**\r
+ Release resource for biso video instance.\r
+\r
+ @param FbGopPrivate Video child device private data structure\r
+\r
+**/\r
+VOID\r
+FbGopDeviceReleaseResource (\r
+ FB_VIDEO_DEV *FbGopPrivate\r
+ );\r
+\r
+//\r
+// BIOS Graphics Output Protocol functions\r
+//\r
+\r
+/**\r
+ Graphics Output protocol interface to get video mode.\r
+\r
+ @param This Protocol instance pointer.\r
+ @param ModeNumber The mode number to return information on.\r
+ @param SizeOfInfo A pointer to the size, in bytes, of the Info\r
+ buffer.\r
+ @param Info Caller allocated buffer that returns information\r
+ about ModeNumber.\r
+\r
+ @retval EFI_SUCCESS Mode information returned.\r
+ @retval EFI_BUFFER_TOO_SMALL The Info buffer was too small.\r
+ @retval EFI_DEVICE_ERROR A hardware error occurred trying to retrieve the\r
+ video mode.\r
+ @retval EFI_NOT_STARTED Video display is not initialized. Call SetMode ()\r
+ @retval EFI_INVALID_PARAMETER One of the input args was NULL.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FbGopGraphicsOutputQueryMode (\r
+ IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,\r
+ IN UINT32 ModeNumber,\r
+ OUT UINTN *SizeOfInfo,\r
+ OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION **Info\r
+ );\r
+\r
+\r
+/**\r
+ Graphics Output protocol interface to set video mode.\r
+\r
+ @param This Protocol instance pointer.\r
+ @param ModeNumber The mode number to be set.\r
+\r
+ @retval EFI_SUCCESS Graphics mode was changed.\r
+ @retval EFI_DEVICE_ERROR The device had an error and could not complete the\r
+ request.\r
+ @retval EFI_UNSUPPORTED ModeNumber is not supported by this device.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FbGopGraphicsOutputSetMode (\r
+ IN EFI_GRAPHICS_OUTPUT_PROTOCOL * This,\r
+ IN UINT32 ModeNumber\r
+ );\r
+\r
+\r
+/**\r
+ Graphics Output protocol instance to block transfer for VBE device.\r
+\r
+ @param This Pointer to Graphics Output protocol instance\r
+ @param BltBuffer The data to transfer to screen\r
+ @param BltOperation The operation to perform\r
+ @param SourceX The X coordinate of the source for BltOperation\r
+ @param SourceY The Y coordinate of the source for BltOperation\r
+ @param DestinationX The X coordinate of the destination for\r
+ BltOperation\r
+ @param DestinationY The Y coordinate of the destination for\r
+ BltOperation\r
+ @param Width The width of a rectangle in the blt rectangle in\r
+ pixels\r
+ @param Height The height of a rectangle in the blt rectangle in\r
+ pixels\r
+ @param Delta Not used for EfiBltVideoFill and\r
+ EfiBltVideoToVideo operation. If a Delta of 0 is\r
+ used, the entire BltBuffer will be operated on. If\r
+ a subrectangle of the BltBuffer is used, then\r
+ Delta represents the number of bytes in a row of\r
+ the BltBuffer.\r
+\r
+ @retval EFI_INVALID_PARAMETER Invalid parameter passed in\r
+ @retval EFI_SUCCESS Blt operation success\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FbGopGraphicsOutputVbeBlt (\r
+ IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,\r
+ IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer, OPTIONAL\r
+ IN EFI_GRAPHICS_OUTPUT_BLT_OPERATION BltOperation,\r
+ IN UINTN SourceX,\r
+ IN UINTN SourceY,\r
+ IN UINTN DestinationX,\r
+ IN UINTN DestinationY,\r
+ IN UINTN Width,\r
+ IN UINTN Height,\r
+ IN UINTN Delta\r
+ );\r
+\r
+\r
+/**\r
+ Grahpics Output protocol instance to block transfer for VGA device.\r
+\r
+ @param This Pointer to Grahpics Output protocol instance\r
+ @param BltBuffer The data to transfer to screen\r
+ @param BltOperation The operation to perform\r
+ @param SourceX The X coordinate of the source for BltOperation\r
+ @param SourceY The Y coordinate of the source for BltOperation\r
+ @param DestinationX The X coordinate of the destination for\r
+ BltOperation\r
+ @param DestinationY The Y coordinate of the destination for\r
+ BltOperation\r
+ @param Width The width of a rectangle in the blt rectangle in\r
+ pixels\r
+ @param Height The height of a rectangle in the blt rectangle in\r
+ pixels\r
+ @param Delta Not used for EfiBltVideoFill and\r
+ EfiBltVideoToVideo operation. If a Delta of 0 is\r
+ used, the entire BltBuffer will be operated on. If\r
+ a subrectangle of the BltBuffer is used, then\r
+ Delta represents the number of bytes in a row of\r
+ the BltBuffer.\r
+\r
+ @retval EFI_INVALID_PARAMETER Invalid parameter passed in\r
+ @retval EFI_SUCCESS Blt operation success\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FbGopGraphicsOutputVgaBlt (\r
+ IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,\r
+ IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer, OPTIONAL\r
+ IN EFI_GRAPHICS_OUTPUT_BLT_OPERATION BltOperation,\r
+ IN UINTN SourceX,\r
+ IN UINTN SourceY,\r
+ IN UINTN DestinationX,\r
+ IN UINTN DestinationY,\r
+ IN UINTN Width,\r
+ IN UINTN Height,\r
+ IN UINTN Delta\r
+ );\r
+\r
+/**\r
+ Install child handles if the Handle supports MBR format.\r
+\r
+ @param This Calling context.\r
+ @param ParentHandle Parent Handle\r
+ @param ParentPciIo Parent PciIo interface\r
+ @param ParentLegacyBios Parent LegacyBios interface\r
+ @param ParentDevicePath Parent Device Path\r
+ @param RemainingDevicePath Remaining Device Path\r
+\r
+ @retval EFI_SUCCESS If a child handle was added\r
+ @retval other A child handle was not added\r
+\r
+**/\r
+EFI_STATUS\r
+FbGopChildHandleInstall (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE ParentHandle,\r
+ IN EFI_PCI_IO_PROTOCOL *ParentPciIo,\r
+ IN VOID *ParentLegacyBios,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
+ );\r
+\r
+/**\r
+ Deregister an video child handle and free resources.\r
+\r
+ @param This Protocol instance pointer.\r
+ @param Controller Video controller handle\r
+ @param Handle Video child handle\r
+\r
+ @return EFI_STATUS\r
+\r
+**/\r
+EFI_STATUS\r
+FbGopChildHandleUninstall (\r
+ EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ EFI_HANDLE Controller,\r
+ EFI_HANDLE Handle\r
+ );\r
+\r
+/**\r
+ Release resource for biso video instance.\r
+\r
+ @param FbGopPrivate Video child device private data structure\r
+\r
+**/\r
+VOID\r
+FbGopDeviceReleaseResource (\r
+ FB_VIDEO_DEV *FbGopPrivate\r
+ );\r
+\r
+/**\r
+ Check if all video child handles have been uninstalled.\r
+\r
+ @param Controller Video controller handle\r
+\r
+ @return TRUE Child handles exist.\r
+ @return FALSE All video child handles have been uninstalled.\r
+\r
+**/\r
+BOOLEAN\r
+HasChildHandle (\r
+ IN EFI_HANDLE Controller\r
+ );\r
+#endif\r
--- /dev/null
+## @file\r
+# Video driver based on legacy bios.\r
+#\r
+# This driver by using Legacy Bios protocol service to support csm Video\r
+# and produce Graphics Output Protocol.\r
+#\r
+# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>\r
+#\r
+# This program and the accompanying materials\r
+# are licensed and made available under the terms and conditions\r
+# of the BSD License which accompanies this distribution. The\r
+# full text of the license may be found at\r
+# http://opensource.org/licenses/bsd-license.php\r
+#\r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+##\r
+\r
+[Defines]\r
+ INF_VERSION = 0x00010005\r
+ BASE_NAME = FbGop\r
+ FILE_GUID = 0B04B2ED-861C-42cd-A22F-C3AAFACCB896\r
+ MODULE_TYPE = UEFI_DRIVER\r
+ VERSION_STRING = 1.0\r
+\r
+ ENTRY_POINT = FbGopEntryPoint\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+# VALID_ARCHITECTURES = IA32 X64 IPF EBC\r
+#\r
+# DRIVER_BINDING = gBiosVideoDriverBinding\r
+# COMPONENT_NAME = gBiosVideoComponentName\r
+#\r
+\r
+[Sources]\r
+ FbGop.c\r
+ FbGop.h\r
+ ComponentName.c\r
+ \r
+\r
+[Packages] \r
+ MdePkg/MdePkg.dec\r
+ MdeModulePkg/MdeModulePkg.dec\r
+ CorebootModulePkg/CorebootModulePkg.dec \r
+\r
+[LibraryClasses]\r
+ MemoryAllocationLib\r
+ DevicePathLib\r
+ UefiLib\r
+ UefiBootServicesTableLib\r
+ UefiDriverEntryPoint\r
+ BaseMemoryLib\r
+ ReportStatusCodeLib\r
+ DebugLib\r
+ PcdLib\r
+ HobLib\r
+ \r
+[Guids]\r
+ gUefiFrameBufferInfoGuid\r
+ \r
+[Protocols]\r
+ gEfiGraphicsOutputProtocolGuid # PROTOCOL BY_START\r
+ gEfiPciIoProtocolGuid # PROTOCOL TO_START\r
+ gEfiDevicePathProtocolGuid # PROTOCOL TO_START\r
+ gEfiEdidDiscoveredProtocolGuid\r
+ gEfiEdidActiveProtocolGuid\r
+ \r
+[Pcd]\r
+ gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution\r
+ gEfiMdeModulePkgTokenSpaceGuid.PcdVideoVerticalResolution \r
--- /dev/null
+/** @file\r
+ ACPI Timer implements one instance of Timer Library.\r
+\r
+ Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>\r
+ This program and the accompanying materials are\r
+ licensed and made available under the terms and conditions of the BSD License\r
+ which accompanies this distribution. The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php\r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include <PiPei.h>\r
+#include <Library/TimerLib.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/IoLib.h>\r
+#include <Library/HobLib.h>\r
+#include <Library/DebugLib.h>\r
+\r
+#include <Guid/AcpiBoardInfoGuid.h>\r
+#include <IndustryStandard/Acpi.h>\r
+\r
+#define ACPI_TIMER_COUNT_SIZE BIT24\r
+\r
+UINTN mPmTimerReg = 0;\r
+\r
+/**\r
+ The constructor function enables ACPI IO space.\r
+\r
+ If ACPI I/O space not enabled, this function will enable it.\r
+ It will always return RETURN_SUCCESS.\r
+\r
+ @retval EFI_SUCCESS The constructor always returns RETURN_SUCCESS.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+AcpiTimerLibConstructor (\r
+ VOID\r
+ )\r
+{\r
+ EFI_HOB_GUID_TYPE *GuidHob;\r
+ ACPI_BOARD_INFO *pAcpiBoardInfo; \r
+ \r
+ //\r
+ // Find the acpi board information guid hob\r
+ //\r
+ GuidHob = GetFirstGuidHob (&gUefiAcpiBoardInfoGuid);\r
+ ASSERT (GuidHob != NULL);\r
+ \r
+ pAcpiBoardInfo = (ACPI_BOARD_INFO *)GET_GUID_HOB_DATA (GuidHob); \r
+ \r
+ mPmTimerReg = (UINTN)pAcpiBoardInfo->PmTimerRegBase;\r
+ \r
+ return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+ Internal function to read the current tick counter of ACPI.\r
+\r
+ Internal function to read the current tick counter of ACPI.\r
+\r
+ @return The tick counter read.\r
+\r
+**/\r
+UINT32\r
+InternalAcpiGetTimerTick (\r
+ VOID\r
+ )\r
+{\r
+ if (mPmTimerReg == 0)\r
+ AcpiTimerLibConstructor ();\r
+ \r
+ return IoRead32 (mPmTimerReg);\r
+}\r
+\r
+/**\r
+ Stalls the CPU for at least the given number of ticks.\r
+\r
+ Stalls the CPU for at least the given number of ticks. It's invoked by\r
+ MicroSecondDelay() and NanoSecondDelay().\r
+\r
+ @param Delay A period of time to delay in ticks.\r
+\r
+**/\r
+VOID\r
+InternalAcpiDelay (\r
+ IN UINT32 Delay\r
+ )\r
+{\r
+ UINT32 Ticks;\r
+ UINT32 Times;\r
+\r
+ Times = Delay >> 22;\r
+ Delay &= BIT22 - 1;\r
+ do {\r
+ //\r
+ // The target timer count is calculated here\r
+ //\r
+ Ticks = InternalAcpiGetTimerTick () + Delay;\r
+ Delay = BIT22;\r
+ //\r
+ // Wait until time out\r
+ // Delay >= 2^23 could not be handled by this function\r
+ // Timer wrap-arounds are handled correctly by this function\r
+ //\r
+ while (((Ticks - InternalAcpiGetTimerTick ()) & BIT23) == 0) {\r
+ CpuPause ();\r
+ }\r
+ } while (Times-- > 0);\r
+}\r
+\r
+/**\r
+ Stalls the CPU for at least the given number of microseconds.\r
+\r
+ Stalls the CPU for the number of microseconds specified by MicroSeconds.\r
+\r
+ @param MicroSeconds The minimum number of microseconds to delay.\r
+\r
+ @return MicroSeconds\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+MicroSecondDelay (\r
+ IN UINTN MicroSeconds\r
+ )\r
+{\r
+ InternalAcpiDelay (\r
+ (UINT32)DivU64x32 (\r
+ MultU64x32 (\r
+ MicroSeconds,\r
+ ACPI_TIMER_FREQUENCY\r
+ ),\r
+ 1000000u\r
+ )\r
+ );\r
+ return MicroSeconds;\r
+}\r
+\r
+/**\r
+ Stalls the CPU for at least the given number of nanoseconds.\r
+\r
+ Stalls the CPU for the number of nanoseconds specified by NanoSeconds.\r
+\r
+ @param NanoSeconds The minimum number of nanoseconds to delay.\r
+\r
+ @return NanoSeconds\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+NanoSecondDelay (\r
+ IN UINTN NanoSeconds\r
+ )\r
+{\r
+ InternalAcpiDelay (\r
+ (UINT32)DivU64x32 (\r
+ MultU64x32 (\r
+ NanoSeconds,\r
+ ACPI_TIMER_FREQUENCY\r
+ ),\r
+ 1000000000u\r
+ )\r
+ );\r
+ return NanoSeconds;\r
+}\r
+\r
+/**\r
+ Retrieves the current value of a 64-bit free running performance counter.\r
+\r
+ Retrieves the current value of a 64-bit free running performance counter. The\r
+ counter can either count up by 1 or count down by 1. If the physical\r
+ performance counter counts by a larger increment, then the counter values\r
+ must be translated. The properties of the counter can be retrieved from\r
+ GetPerformanceCounterProperties().\r
+\r
+ @return The current value of the free running performance counter.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+GetPerformanceCounter (\r
+ VOID\r
+ )\r
+{\r
+ return (UINT64)InternalAcpiGetTimerTick ();\r
+}\r
+\r
+/**\r
+ Retrieves the 64-bit frequency in Hz and the range of performance counter\r
+ values.\r
+\r
+ If StartValue is not NULL, then the value that the performance counter starts\r
+ with immediately after is it rolls over is returned in StartValue. If\r
+ EndValue is not NULL, then the value that the performance counter end with\r
+ immediately before it rolls over is returned in EndValue. The 64-bit\r
+ frequency of the performance counter in Hz is always returned. If StartValue\r
+ is less than EndValue, then the performance counter counts up. If StartValue\r
+ is greater than EndValue, then the performance counter counts down. For\r
+ example, a 64-bit free running counter that counts up would have a StartValue\r
+ of 0 and an EndValue of 0xFFFFFFFFFFFFFFFF. A 24-bit free running counter\r
+ that counts down would have a StartValue of 0xFFFFFF and an EndValue of 0.\r
+\r
+ @param StartValue The value the performance counter starts with when it\r
+ rolls over.\r
+ @param EndValue The value that the performance counter ends with before\r
+ it rolls over.\r
+\r
+ @return The frequency in Hz.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+GetPerformanceCounterProperties (\r
+ OUT UINT64 *StartValue, OPTIONAL\r
+ OUT UINT64 *EndValue OPTIONAL\r
+ )\r
+{\r
+ if (StartValue != NULL) {\r
+ *StartValue = 0;\r
+ }\r
+\r
+ if (EndValue != NULL) {\r
+ *EndValue = ACPI_TIMER_COUNT_SIZE - 1;\r
+ }\r
+\r
+ return ACPI_TIMER_FREQUENCY;\r
+}\r
+\r
+/**\r
+ Converts elapsed ticks of performance counter to time in nanoseconds.\r
+\r
+ This function converts the elapsed ticks of running performance counter to\r
+ time value in unit of nanoseconds.\r
+\r
+ @param Ticks The number of elapsed ticks of running performance counter.\r
+\r
+ @return The elapsed time in nanoseconds.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+GetTimeInNanoSecond (\r
+ IN UINT64 Ticks\r
+ )\r
+{\r
+ UINT64 Frequency;\r
+ UINT64 NanoSeconds;\r
+ UINT64 Remainder;\r
+ INTN Shift;\r
+\r
+ Frequency = GetPerformanceCounterProperties (NULL, NULL);\r
+\r
+ //\r
+ // Ticks\r
+ // Time = --------- x 1,000,000,000\r
+ // Frequency\r
+ //\r
+ NanoSeconds = MultU64x32 (DivU64x64Remainder (Ticks, Frequency, &Remainder), 1000000000u);\r
+\r
+ //\r
+ // Ensure (Remainder * 1,000,000,000) will not overflow 64-bit.\r
+ // Since 2^29 < 1,000,000,000 = 0x3B9ACA00 < 2^30, Remainder should < 2^(64-30) = 2^34,\r
+ // i.e. highest bit set in Remainder should <= 33.\r
+ //\r
+ Shift = MAX (0, HighBitSet64 (Remainder) - 33);\r
+ Remainder = RShiftU64 (Remainder, (UINTN) Shift);\r
+ Frequency = RShiftU64 (Frequency, (UINTN) Shift);\r
+ NanoSeconds += DivU64x64Remainder (MultU64x32 (Remainder, 1000000000u), Frequency, NULL);\r
+\r
+ return NanoSeconds;\r
+}\r
+\r
--- /dev/null
+## @file\r
+# ACPI Timer Library Instance.\r
+#\r
+# Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>\r
+# This program and the accompanying materials\r
+# are licensed and made available under the terms and conditions of the BSD License\r
+# which accompanies this distribution. The full text of the license may be found at\r
+# http://opensource.org/licenses/bsd-license.php\r
+#\r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+##\r
+\r
+[Defines]\r
+ INF_VERSION = 0x00010005\r
+ BASE_NAME = AcpiTimerLib\r
+ FILE_GUID = A41BF616-EF77-4658-9992-D813071C34CF\r
+ MODULE_TYPE = BASE\r
+ VERSION_STRING = 1.0\r
+ LIBRARY_CLASS = TimerLib\r
+\r
+ CONSTRUCTOR = AcpiTimerLibConstructor\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+# VALID_ARCHITECTURES = IA32 X64 IPF EBC\r
+#\r
+\r
+[Sources]\r
+ AcpiTimerLib.c\r
+\r
+[Packages]\r
+ MdePkg/MdePkg.dec\r
+ MdeModulePkg/MdeModulePkg.dec\r
+ CorebootModulePkg/CorebootModulePkg.dec\r
+\r
+[LibraryClasses] \r
+ BaseLib\r
+ IoLib\r
+ HobLib\r
+ DebugLib\r
+ \r
+[Guids] \r
+ gUefiAcpiBoardInfoGuid
\ No newline at end of file
--- /dev/null
+/** @file\r
+ This file include all platform action which can be customized by IBV/OEM.\r
+\r
+Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution. The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "BdsPlatform.h"\r
+\r
+//\r
+// Global data\r
+//\r
+BOOLEAN mDetectVgaOnly;\r
+\r
+\r
+//\r
+// Type definitions\r
+//\r
+\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *PROTOCOL_INSTANCE_CALLBACK)(\r
+ IN EFI_HANDLE Handle,\r
+ IN VOID *Instance,\r
+ IN VOID *Context\r
+ );\r
+\r
+/**\r
+ @param[in] Handle - Handle of PCI device instance\r
+ @param[in] PciIo - PCI IO protocol instance\r
+ @param[in] Pci - PCI Header register block\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *VISIT_PCI_INSTANCE_CALLBACK)(\r
+ IN EFI_HANDLE Handle,\r
+ IN EFI_PCI_IO_PROTOCOL *PciIo,\r
+ IN PCI_TYPE00 *Pci\r
+ );\r
+\r
+\r
+//\r
+// Function prototypes\r
+//\r
+\r
+EFI_STATUS\r
+VisitAllInstancesOfProtocol (\r
+ IN EFI_GUID *Id,\r
+ IN PROTOCOL_INSTANCE_CALLBACK CallBackFunction,\r
+ IN VOID *Context\r
+ );\r
+\r
+EFI_STATUS\r
+VisitAllPciInstancesOfProtocol (\r
+ IN VISIT_PCI_INSTANCE_CALLBACK CallBackFunction\r
+ );\r
+ \r
+ \r
+//\r
+// BDS Platform Functions\r
+//\r
+\r
+/**\r
+ Platform Bds init. Include the platform firmware vendor, revision\r
+ and so crc check.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+PlatformBdsInit (\r
+ VOID\r
+ )\r
+{\r
+}\r
+\r
+\r
+EFI_STATUS\r
+PrepareLpcBridgeDevicePath (\r
+ IN EFI_HANDLE DeviceHandle\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Add IsaKeyboard to ConIn,\r
+ add IsaSerial to ConOut, ConIn, ErrOut.\r
+ LPC Bridge: 06 01 00\r
+\r
+Arguments:\r
+\r
+ DeviceHandle - Handle of PCIIO protocol.\r
+\r
+Returns:\r
+\r
+ EFI_SUCCESS - LPC bridge is added to ConOut, ConIn, and ErrOut.\r
+ EFI_STATUS - No LPC bridge is added.\r
+\r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
+ EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;\r
+ CHAR16 *DevPathStr;\r
+\r
+ DevicePath = NULL;\r
+ Status = gBS->HandleProtocol (\r
+ DeviceHandle,\r
+ &gEfiDevicePathProtocolGuid,\r
+ (VOID*)&DevicePath\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+ TempDevicePath = DevicePath;\r
+\r
+ //\r
+ // Register COM1\r
+ // \r
+ DevicePath = AppendDevicePathNode ((EFI_DEVICE_PATH_PROTOCOL *)NULL, (EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceVenderNode);\r
+ DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceNode);\r
+ DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gTerminalTypeDeviceNode);\r
+\r
+ //\r
+ // Print Device Path\r
+ //\r
+ DevPathStr = DevicePathToStr(DevicePath);\r
+ DEBUG((\r
+ EFI_D_INFO,\r
+ "BdsPlatform.c+%d: COM%d DevPath: %s\n",\r
+ __LINE__,\r
+ gPnp16550ComPortDeviceNode.UID + 1,\r
+ DevPathStr\r
+ ));\r
+ FreePool(DevPathStr);\r
+\r
+ BdsLibUpdateConsoleVariable (VarConsoleOut, DevicePath, NULL);\r
+ BdsLibUpdateConsoleVariable (VarConsoleInp, DevicePath, NULL);\r
+ BdsLibUpdateConsoleVariable (VarErrorOut, DevicePath, NULL);\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+GetGopDevicePath (\r
+ IN EFI_DEVICE_PATH_PROTOCOL *PciDevicePath,\r
+ OUT EFI_DEVICE_PATH_PROTOCOL **GopDevicePath\r
+ )\r
+{\r
+ UINTN Index;\r
+ EFI_STATUS Status;\r
+ EFI_HANDLE PciDeviceHandle;\r
+ EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;\r
+ EFI_DEVICE_PATH_PROTOCOL *TempPciDevicePath;\r
+ UINTN GopHandleCount;\r
+ EFI_HANDLE *GopHandleBuffer;\r
+\r
+ if (PciDevicePath == NULL || GopDevicePath == NULL) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ //\r
+ // Initialize the GopDevicePath to be PciDevicePath\r
+ //\r
+ *GopDevicePath = PciDevicePath;\r
+ TempPciDevicePath = PciDevicePath;\r
+\r
+ Status = gBS->LocateDevicePath (\r
+ &gEfiDevicePathProtocolGuid,\r
+ &TempPciDevicePath,\r
+ &PciDeviceHandle\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+\r
+ //\r
+ // Try to connect this handle, so that GOP dirver could start on this\r
+ // device and create child handles with GraphicsOutput Protocol installed\r
+ // on them, then we get device paths of these child handles and select\r
+ // them as possible console device.\r
+ //\r
+#if 0\r
+ gBS->ConnectController (PciDeviceHandle, NULL, NULL, FALSE);\r
+#else \r
+ {\r
+ ACPI_ADR_DEVICE_PATH AcpiAdr;\r
+ EFI_DEVICE_PATH_PROTOCOL *MyDevicePath = NULL; \r
+ \r
+ AcpiAdr.Header.Type = ACPI_DEVICE_PATH;\r
+ AcpiAdr.Header.SubType = ACPI_ADR_DP;\r
+ //AcpiAdr.ADR= ACPI_DISPLAY_ADR (1, 0, 0, 1, 0, ACPI_ADR_DISPLAY_TYPE_VGA, 6, 0); //on bayleybay, CRT Device\r
+ AcpiAdr.ADR= ACPI_DISPLAY_ADR (1, 0, 0, 1, 0, ACPI_ADR_DISPLAY_TYPE_INTERNAL_DIGITAL, 8, 0); ; // on rambi, eDP C\r
+\r
+ SetDevicePathNodeLength (&AcpiAdr.Header, sizeof (ACPI_ADR_DEVICE_PATH));\r
+\r
+ MyDevicePath = AppendDevicePathNode(MyDevicePath, (EFI_DEVICE_PATH_PROTOCOL*)&AcpiAdr);\r
+\r
+ gBS->ConnectController (PciDeviceHandle, NULL, MyDevicePath, FALSE);\r
+ \r
+ FreePool(MyDevicePath);\r
+ }\r
+#endif\r
+\r
+ Status = gBS->LocateHandleBuffer (\r
+ ByProtocol,\r
+ &gEfiGraphicsOutputProtocolGuid,\r
+ NULL,\r
+ &GopHandleCount,\r
+ &GopHandleBuffer\r
+ );\r
+ if (!EFI_ERROR (Status)) {\r
+ //\r
+ // Add all the child handles as possible Console Device\r
+ //\r
+ for (Index = 0; Index < GopHandleCount; Index++) {\r
+ Status = gBS->HandleProtocol (GopHandleBuffer[Index], &gEfiDevicePathProtocolGuid, (VOID*)&TempDevicePath);\r
+ if (EFI_ERROR (Status)) {\r
+ continue;\r
+ }\r
+ if (CompareMem (\r
+ PciDevicePath,\r
+ TempDevicePath,\r
+ GetDevicePathSize (PciDevicePath) - END_DEVICE_PATH_LENGTH\r
+ ) == 0) {\r
+ //\r
+ // In current implementation, we only enable one of the child handles\r
+ // as console device, i.e. sotre one of the child handle's device\r
+ // path to variable "ConOut"\r
+ // In futhure, we could select all child handles to be console device\r
+ //\r
+\r
+ *GopDevicePath = TempDevicePath;\r
+\r
+ //\r
+ // Delete the PCI device's path that added by GetPlugInPciVgaDevicePath()\r
+ // Add the integrity GOP device path.\r
+ //\r
+ BdsLibUpdateConsoleVariable (VarConsoleOutDev, NULL, PciDevicePath);\r
+ BdsLibUpdateConsoleVariable (VarConsoleOutDev, TempDevicePath, NULL);\r
+ }\r
+ }\r
+ gBS->FreePool (GopHandleBuffer);\r
+ }\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+PreparePciVgaDevicePath (\r
+ IN EFI_HANDLE DeviceHandle\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Add PCI VGA to ConOut.\r
+ PCI VGA: 03 00 00\r
+\r
+Arguments:\r
+\r
+ DeviceHandle - Handle of PCIIO protocol.\r
+\r
+Returns:\r
+\r
+ EFI_SUCCESS - PCI VGA is added to ConOut.\r
+ EFI_STATUS - No PCI VGA device is added.\r
+\r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
+ EFI_DEVICE_PATH_PROTOCOL *GopDevicePath;\r
+\r
+ DevicePath = NULL;\r
+ Status = gBS->HandleProtocol (\r
+ DeviceHandle,\r
+ &gEfiDevicePathProtocolGuid,\r
+ (VOID*)&DevicePath\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+\r
+ GetGopDevicePath (DevicePath, &GopDevicePath);\r
+ DevicePath = GopDevicePath;\r
+\r
+ BdsLibUpdateConsoleVariable (VarConsoleOut, DevicePath, NULL);\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+PreparePciSerialDevicePath (\r
+ IN EFI_HANDLE DeviceHandle\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Add PCI Serial to ConOut, ConIn, ErrOut.\r
+ PCI Serial: 07 00 02\r
+\r
+Arguments:\r
+\r
+ DeviceHandle - Handle of PCIIO protocol.\r
+\r
+Returns:\r
+\r
+ EFI_SUCCESS - PCI Serial is added to ConOut, ConIn, and ErrOut.\r
+ EFI_STATUS - No PCI Serial device is added.\r
+\r
+--*/\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
+\r
+ DevicePath = NULL;\r
+ Status = gBS->HandleProtocol (\r
+ DeviceHandle,\r
+ &gEfiDevicePathProtocolGuid,\r
+ (VOID*)&DevicePath\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+\r
+ DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceNode);\r
+ DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&gTerminalTypeDeviceNode);\r
+\r
+ BdsLibUpdateConsoleVariable (VarConsoleOut, DevicePath, NULL);\r
+ BdsLibUpdateConsoleVariable (VarConsoleInp, DevicePath, NULL);\r
+ BdsLibUpdateConsoleVariable (VarErrorOut, DevicePath, NULL);\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+VisitAllInstancesOfProtocol (\r
+ IN EFI_GUID *Id,\r
+ IN PROTOCOL_INSTANCE_CALLBACK CallBackFunction,\r
+ IN VOID *Context\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ UINTN HandleCount;\r
+ EFI_HANDLE *HandleBuffer;\r
+ UINTN Index;\r
+ VOID *Instance;\r
+\r
+ //\r
+ // Start to check all the PciIo to find all possible device\r
+ //\r
+ HandleCount = 0;\r
+ HandleBuffer = NULL;\r
+ Status = gBS->LocateHandleBuffer (\r
+ ByProtocol,\r
+ Id,\r
+ NULL,\r
+ &HandleCount,\r
+ &HandleBuffer\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+\r
+ for (Index = 0; Index < HandleCount; Index++) {\r
+ Status = gBS->HandleProtocol (HandleBuffer[Index], Id, &Instance);\r
+ if (EFI_ERROR (Status)) {\r
+ continue;\r
+ }\r
+\r
+ Status = (*CallBackFunction) (\r
+ HandleBuffer[Index],\r
+ Instance,\r
+ Context\r
+ );\r
+ }\r
+\r
+ gBS->FreePool (HandleBuffer);\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+VisitingAPciInstance (\r
+ IN EFI_HANDLE Handle,\r
+ IN VOID *Instance,\r
+ IN VOID *Context\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_PCI_IO_PROTOCOL *PciIo;\r
+ PCI_TYPE00 Pci;\r
+\r
+ PciIo = (EFI_PCI_IO_PROTOCOL*) Instance;\r
+\r
+ //\r
+ // Check for all PCI device\r
+ //\r
+ Status = PciIo->Pci.Read (\r
+ PciIo,\r
+ EfiPciIoWidthUint32,\r
+ 0,\r
+ sizeof (Pci) / sizeof (UINT32),\r
+ &Pci\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+\r
+ return (*(VISIT_PCI_INSTANCE_CALLBACK)(UINTN) Context) (\r
+ Handle,\r
+ PciIo,\r
+ &Pci\r
+ );\r
+\r
+}\r
+\r
+\r
+\r
+EFI_STATUS\r
+VisitAllPciInstances (\r
+ IN VISIT_PCI_INSTANCE_CALLBACK CallBackFunction\r
+ )\r
+{\r
+ return VisitAllInstancesOfProtocol (\r
+ &gEfiPciIoProtocolGuid,\r
+ VisitingAPciInstance,\r
+ (VOID*)(UINTN) CallBackFunction\r
+ );\r
+}\r
+\r
+\r
+/**\r
+ Do platform specific PCI Device check and add them to\r
+ ConOut, ConIn, ErrOut.\r
+\r
+ @param[in] Handle - Handle of PCI device instance\r
+ @param[in] PciIo - PCI IO protocol instance\r
+ @param[in] Pci - PCI Header register block\r
+\r
+ @retval EFI_SUCCESS - PCI Device check and Console variable update successfully.\r
+ @retval EFI_STATUS - PCI Device check or Console variable update fail.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+DetectAndPreparePlatformPciDevicePath (\r
+ IN EFI_HANDLE Handle,\r
+ IN EFI_PCI_IO_PROTOCOL *PciIo,\r
+ IN PCI_TYPE00 *Pci\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+\r
+ Status = PciIo->Attributes (\r
+ PciIo,\r
+ EfiPciIoAttributeOperationEnable,\r
+ EFI_PCI_DEVICE_ENABLE,\r
+ NULL\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ if (!mDetectVgaOnly) {\r
+ //\r
+ // Here we decide whether it is LPC Bridge\r
+ //\r
+ if ((IS_PCI_LPC (Pci)) ||\r
+ ((IS_PCI_ISA_PDECODE (Pci)) &&\r
+ (Pci->Hdr.VendorId == 0x8086) \r
+ )\r
+ ) {\r
+ //\r
+ // Add IsaKeyboard to ConIn,\r
+ // add IsaSerial to ConOut, ConIn, ErrOut\r
+ //\r
+ DEBUG ((EFI_D_INFO, "Found LPC Bridge device\n"));\r
+ PrepareLpcBridgeDevicePath (Handle);\r
+ return EFI_SUCCESS;\r
+ }\r
+ //\r
+ // Here we decide which Serial device to enable in PCI bus\r
+ //\r
+ if (IS_PCI_16550SERIAL (Pci)) {\r
+ //\r
+ // Add them to ConOut, ConIn, ErrOut.\r
+ //\r
+ DEBUG ((EFI_D_INFO, "Found PCI 16550 SERIAL device\n"));\r
+ PreparePciSerialDevicePath (Handle);\r
+ return EFI_SUCCESS;\r
+ }\r
+ }\r
+\r
+ //\r
+ // Here we decide which VGA device to enable in PCI bus\r
+ //\r
+ if (IS_PCI_VGA (Pci)) {\r
+ //\r
+ // Add them to ConOut.\r
+ //\r
+ DEBUG ((EFI_D_INFO, "Found PCI VGA device\n"));\r
+ PreparePciVgaDevicePath (Handle);\r
+ return EFI_SUCCESS;\r
+ }\r
+\r
+ return Status;\r
+}\r
+\r
+\r
+/**\r
+ Do platform specific PCI Device check and add them to ConOut, ConIn, ErrOut\r
+\r
+ @param[in] DetectVgaOnly - Only detect VGA device if it's TRUE.\r
+\r
+ @retval EFI_SUCCESS - PCI Device check and Console variable update successfully.\r
+ @retval EFI_STATUS - PCI Device check or Console variable update fail.\r
+\r
+**/\r
+EFI_STATUS\r
+DetectAndPreparePlatformPciDevicePaths (\r
+ BOOLEAN DetectVgaOnly\r
+ )\r
+{\r
+ mDetectVgaOnly = DetectVgaOnly;\r
+ return VisitAllPciInstances (DetectAndPreparePlatformPciDevicePath);\r
+}\r
+\r
+/**\r
+ Connect the predefined platform default console device. Always try to find\r
+ and enable the vga device if have.\r
+\r
+ @param PlatformConsole Predefined platform default console device array.\r
+\r
+ @retval EFI_SUCCESS Success connect at least one ConIn and ConOut\r
+ device, there must have one ConOut device is\r
+ active vga device.\r
+ @return Return the status of BdsLibConnectAllDefaultConsoles ()\r
+\r
+**/\r
+EFI_STATUS\r
+PlatformBdsConnectConsole (\r
+ IN BDS_CONSOLE_CONNECT_ENTRY *PlatformConsole\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ UINTN Index;\r
+ EFI_DEVICE_PATH_PROTOCOL *VarConout;\r
+ EFI_DEVICE_PATH_PROTOCOL *VarConin;\r
+ UINTN DevicePathSize;\r
+\r
+ //\r
+ // Connect RootBridge\r
+ //\r
+ VarConout = BdsLibGetVariableAndSize (\r
+ VarConsoleOut,\r
+ &gEfiGlobalVariableGuid,\r
+ &DevicePathSize\r
+ );\r
+ VarConin = BdsLibGetVariableAndSize (\r
+ VarConsoleInp,\r
+ &gEfiGlobalVariableGuid,\r
+ &DevicePathSize\r
+ );\r
+\r
+ if (VarConout == NULL || VarConin == NULL) {\r
+ //\r
+ // Do platform specific PCI Device check and add them to ConOut, ConIn, ErrOut\r
+ //\r
+ DetectAndPreparePlatformPciDevicePaths (FALSE);\r
+\r
+ //\r
+ // Have chance to connect the platform default console,\r
+ // the platform default console is the minimue device group\r
+ // the platform should support\r
+ //\r
+ for (Index = 0; PlatformConsole[Index].DevicePath != NULL; ++Index) {\r
+ //\r
+ // Update the console variable with the connect type\r
+ //\r
+ if ((PlatformConsole[Index].ConnectType & CONSOLE_IN) == CONSOLE_IN) {\r
+ BdsLibUpdateConsoleVariable (VarConsoleInp, PlatformConsole[Index].DevicePath, NULL);\r
+ }\r
+ if ((PlatformConsole[Index].ConnectType & CONSOLE_OUT) == CONSOLE_OUT) {\r
+ BdsLibUpdateConsoleVariable (VarConsoleOut, PlatformConsole[Index].DevicePath, NULL);\r
+ }\r
+ if ((PlatformConsole[Index].ConnectType & STD_ERROR) == STD_ERROR) {\r
+ BdsLibUpdateConsoleVariable (VarErrorOut, PlatformConsole[Index].DevicePath, NULL);\r
+ }\r
+ }\r
+ } else {\r
+ //\r
+ // Only detect VGA device and add them to ConOut\r
+ //\r
+ DetectAndPreparePlatformPciDevicePaths (TRUE);\r
+ }\r
+\r
+ //\r
+ // Connect the all the default console with current cosole variable\r
+ //\r
+ Status = BdsLibConnectAllDefaultConsoles ();\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+ Connect with predefined platform connect sequence,\r
+ the OEM/IBV can customize with their own connect sequence.\r
+**/\r
+VOID\r
+PlatformBdsConnectSequence (\r
+ VOID\r
+ )\r
+{\r
+ UINTN Index;\r
+ \r
+ DEBUG ((EFI_D_INFO, "PlatformBdsConnectSequence\n"));\r
+ Index = 0;\r
+\r
+ //\r
+ // Here we can get the customized platform connect sequence\r
+ // Notes: we can connect with new variable which record the\r
+ // last time boots connect device path sequence\r
+ //\r
+ while (gPlatformConnectSequence[Index] != NULL) {\r
+ //\r
+ // Build the platform boot option\r
+ //\r
+ BdsLibConnectDevicePath (gPlatformConnectSequence[Index]);\r
+ Index++;\r
+ }\r
+}\r
+\r
+/**\r
+ Load the predefined driver option, OEM/IBV can customize this\r
+ to load their own drivers\r
+\r
+ @param BdsDriverLists - The header of the driver option link list.\r
+\r
+**/\r
+VOID\r
+PlatformBdsGetDriverOption (\r
+ IN OUT LIST_ENTRY *BdsDriverLists\r
+ )\r
+{\r
+ UINTN Index;\r
+ \r
+ Index = 0;\r
+ \r
+ DEBUG ((EFI_D_INFO, "PlatformBdsGetDriverOption\n"));\r
+\r
+ \r
+ //\r
+ // Here we can get the customized platform driver option\r
+ //\r
+ while (gPlatformDriverOption[Index] != NULL) {\r
+\r
+ //\r
+ // Build the platform boot option\r
+ //\r
+ BdsLibRegisterNewOption (BdsDriverLists, gPlatformDriverOption[Index], NULL, L"DriverOrder");\r
+ Index ++;\r
+ }\r
+}\r
+\r
+/**\r
+ Perform the platform diagnostic, such like test memory. OEM/IBV also\r
+ can customize this function to support specific platform diagnostic.\r
+\r
+ @param MemoryTestLevel The memory test intensive level\r
+ @param QuietBoot Indicate if need to enable the quiet boot\r
+ @param BaseMemoryTest A pointer to BdsMemoryTest()\r
+\r
+**/\r
+VOID\r
+PlatformBdsDiagnostics (\r
+ IN EXTENDMEM_COVERAGE_LEVEL MemoryTestLevel,\r
+ IN BOOLEAN QuietBoot,\r
+ IN BASEM_MEMORY_TEST BaseMemoryTest\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ \r
+ DEBUG ((EFI_D_INFO, "PlatformBdsDiagnostics\n"));\r
+ //\r
+ // Here we can decide if we need to show\r
+ // the diagnostics screen\r
+ // Notes: this quiet boot code should be remove\r
+ // from the graphic lib\r
+ //\r
+ if (QuietBoot) {\r
+ EnableQuietBoot (PcdGetPtr(PcdLogoFile));\r
+\r
+ //\r
+ // Perform system diagnostic\r
+ //\r
+ Status = BaseMemoryTest (MemoryTestLevel);\r
+ if (EFI_ERROR (Status)) {\r
+ DisableQuietBoot ();\r
+ }\r
+\r
+ return;\r
+ }\r
+ \r
+ //\r
+ // Perform system diagnostic\r
+ //\r
+ Status = BaseMemoryTest (MemoryTestLevel);\r
+}\r
+\r
+\r
+/**\r
+ The function will connect root bridge\r
+\r
+ @return EFI_SUCCESS Connect RootBridge successfully.\r
+\r
+**/\r
+EFI_STATUS\r
+ConnectRootBridge (\r
+ VOID\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_HANDLE RootHandle;\r
+\r
+ //\r
+ // Make all the PCI_IO protocols on PCI Seg 0 show up\r
+ //\r
+ BdsLibConnectDevicePath (gPlatformRootBridges[0]);\r
+\r
+ Status = gBS->LocateDevicePath (\r
+ &gEfiDevicePathProtocolGuid,\r
+ &gPlatformRootBridges[0],\r
+ &RootHandle\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+\r
+ Status = gBS->ConnectController (RootHandle, NULL, NULL, FALSE);\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+ The function will execute with as the platform policy, current policy\r
+ is driven by boot mode. IBV/OEM can customize this code for their specific\r
+ policy action.\r
+\r
+ @param DriverOptionList The header of the driver option link list\r
+ @param BootOptionList The header of the boot option link list\r
+ @param ProcessCapsules A pointer to ProcessCapsules()\r
+ @param BaseMemoryTest A pointer to BaseMemoryTest()\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+PlatformBdsPolicyBehavior (\r
+ IN LIST_ENTRY *DriverOptionList,\r
+ IN LIST_ENTRY *BootOptionList,\r
+ IN PROCESS_CAPSULES ProcessCapsules,\r
+ IN BASEM_MEMORY_TEST BaseMemoryTest\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ UINT16 Timeout;\r
+ EFI_EVENT UserInputDurationTime;\r
+ LIST_ENTRY *Link;\r
+ BDS_COMMON_OPTION *BootOption;\r
+ UINTN Index;\r
+ EFI_INPUT_KEY Key;\r
+ EFI_TPL OldTpl;\r
+ EFI_BOOT_MODE BootMode;\r
+\r
+ DEBUG ((EFI_D_INFO, "PlatformBdsPolicyBehavior\n"));\r
+ \r
+ ConnectRootBridge ();\r
+\r
+ //\r
+ // Init the time out value\r
+ //\r
+ Timeout = PcdGet16 (PcdPlatformBootTimeOut);\r
+\r
+ //\r
+ // Load the driver option as the driver option list\r
+ //\r
+ PlatformBdsGetDriverOption (DriverOptionList);\r
+\r
+ //\r
+ // Get current Boot Mode\r
+ //\r
+ Status = BdsLibGetBootMode (&BootMode);\r
+ DEBUG ((EFI_D_ERROR, "Boot Mode:%x\n", BootMode));\r
+\r
+ //\r
+ // Go the different platform policy with different boot mode\r
+ // Notes: this part code can be change with the table policy\r
+ //\r
+ ASSERT (BootMode == BOOT_WITH_FULL_CONFIGURATION);\r
+ //\r
+ // Connect platform console\r
+ //\r
+ Status = PlatformBdsConnectConsole (gPlatformConsole);\r
+ if (EFI_ERROR (Status)) {\r
+ //\r
+ // Here OEM/IBV can customize with defined action\r
+ //\r
+ PlatformBdsNoConsoleAction ();\r
+ }\r
+ //\r
+ // Create a 300ms duration event to ensure user has enough input time to enter Setup\r
+ //\r
+ Status = gBS->CreateEvent (\r
+ EVT_TIMER,\r
+ 0,\r
+ NULL,\r
+ NULL,\r
+ &UserInputDurationTime\r
+ );\r
+ ASSERT (Status == EFI_SUCCESS);\r
+ Status = gBS->SetTimer (UserInputDurationTime, TimerRelative, 3000000);\r
+ ASSERT (Status == EFI_SUCCESS);\r
+ //\r
+ // Memory test and Logo show\r
+ //\r
+ PlatformBdsDiagnostics (IGNORE, TRUE, BaseMemoryTest);\r
+\r
+ //\r
+ // Perform some platform specific connect sequence\r
+ //\r
+ PlatformBdsConnectSequence ();\r
+\r
+ //\r
+ // In BOOT_WITH_FULL_CONFIGURATION boot mode, should always connect every device\r
+ // and do enumerate all the default boot options. But in development system board, the boot mode\r
+ // cannot be BOOT_ASSUMING_NO_CONFIGURATION_CHANGES because the machine box\r
+ // is always open. So the following code only do the ConnectAll and EnumerateAll at first boot.\r
+ //\r
+ Status = BdsLibBuildOptionFromVar (BootOptionList, L"BootOrder");\r
+ if (EFI_ERROR(Status)) {\r
+ //\r
+ // If cannot find "BootOrder" variable, it may be first boot.\r
+ // Try to connect all devices and enumerate all boot options here.\r
+ //\r
+ BdsLibConnectAll ();\r
+ BdsLibEnumerateAllBootOption (BootOptionList);\r
+ }\r
+\r
+ //\r
+ // To give the User a chance to enter Setup here, if user set TimeOut is 0.\r
+ // BDS should still give user a chance to enter Setup\r
+ //\r
+ // Connect first boot option, and then check user input before exit\r
+ //\r
+ for (Link = BootOptionList->ForwardLink; Link != BootOptionList;Link = Link->ForwardLink) {\r
+ BootOption = CR (Link, BDS_COMMON_OPTION, Link, BDS_LOAD_OPTION_SIGNATURE);\r
+ if (!IS_LOAD_OPTION_TYPE (BootOption->Attribute, LOAD_OPTION_ACTIVE)) {\r
+ //\r
+ // skip the header of the link list, becuase it has no boot option\r
+ //\r
+ continue;\r
+ } else {\r
+ //\r
+ // Make sure the boot option device path connected, but ignore the BBS device path\r
+ //\r
+ if (DevicePathType (BootOption->DevicePath) != BBS_DEVICE_PATH) {\r
+ BdsLibConnectDevicePath (BootOption->DevicePath);\r
+ }\r
+ break;\r
+ }\r
+ }\r
+\r
+ //\r
+ // Check whether the user input after the duration time has expired\r
+ //\r
+ OldTpl = EfiGetCurrentTpl();\r
+ gBS->RestoreTPL (TPL_APPLICATION);\r
+ gBS->WaitForEvent (1, &UserInputDurationTime, &Index);\r
+ gBS->CloseEvent (UserInputDurationTime);\r
+ Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);\r
+ gBS->RaiseTPL (OldTpl);\r
+\r
+ if (!EFI_ERROR (Status)) {\r
+ //\r
+ // Enter Setup if user input\r
+ //\r
+ Timeout = 0xffff;\r
+ PlatformBdsEnterFrontPage (Timeout, FALSE);\r
+ }\r
+}\r
+\r
+/**\r
+ Hook point after a boot attempt succeeds. We don't expect a boot option to\r
+ return, so the UEFI 2.0 specification defines that you will default to an\r
+ interactive mode and stop processing the BootOrder list in this case. This\r
+ is also a platform implementation and can be customized by IBV/OEM.\r
+\r
+ @param Option Pointer to Boot Option that succeeded to boot.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+PlatformBdsBootSuccess (\r
+ IN BDS_COMMON_OPTION *Option\r
+ )\r
+{\r
+ CHAR16 *TmpStr;\r
+ DEBUG ((EFI_D_INFO, "PlatformBdsBootSuccess\n"));\r
+ \r
+ //\r
+ // If Boot returned with EFI_SUCCESS and there is not in the boot device\r
+ // select loop then we need to pop up a UI and wait for user input.\r
+ //\r
+ TmpStr = Option->StatusString;\r
+ if (TmpStr != NULL) {\r
+ BdsLibOutputStrings (gST->ConOut, TmpStr, Option->Description, L"\n\r", NULL);\r
+ FreePool (TmpStr);\r
+ }\r
+}\r
+\r
+/**\r
+ Hook point after a boot attempt fails.\r
+\r
+ @param Option Pointer to Boot Option that failed to boot.\r
+ @param Status Status returned from failed boot.\r
+ @param ExitData Exit data returned from failed boot.\r
+ @param ExitDataSize Exit data size returned from failed boot.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+PlatformBdsBootFail (\r
+ IN BDS_COMMON_OPTION *Option,\r
+ IN EFI_STATUS Status,\r
+ IN CHAR16 *ExitData,\r
+ IN UINTN ExitDataSize\r
+ )\r
+{\r
+ CHAR16 *TmpStr;\r
+ DEBUG ((EFI_D_INFO, "PlatformBdsBootFail\n"));\r
+\r
+ //\r
+ // If Boot returned with failed status then we need to pop up a UI and wait\r
+ // for user input.\r
+ //\r
+ TmpStr = Option->StatusString;\r
+ if (TmpStr != NULL) {\r
+ BdsLibOutputStrings (gST->ConOut, TmpStr, Option->Description, L"\n\r", NULL);\r
+ FreePool (TmpStr);\r
+ }\r
+}\r
+\r
+/**\r
+ This function is remained for IBV/OEM to do some platform action,\r
+ if there no console device can be connected.\r
+\r
+ @return EFI_SUCCESS Direct return success now.\r
+\r
+**/\r
+EFI_STATUS\r
+PlatformBdsNoConsoleAction (\r
+ VOID\r
+ )\r
+{\r
+ DEBUG ((EFI_D_INFO, "PlatformBdsNoConsoleAction\n"));\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+ This function locks platform flash that is not allowed to be updated during normal boot path.\r
+ The flash layout is platform specific.\r
+**/\r
+VOID\r
+EFIAPI\r
+PlatformBdsLockNonUpdatableFlash (\r
+ VOID\r
+ )\r
+{\r
+ DEBUG ((EFI_D_INFO, "PlatformBdsLockNonUpdatableFlash\n"));\r
+ return ;\r
+}\r
+\r
+\r
+/**\r
+ Lock the ConsoleIn device in system table. All key\r
+ presses will be ignored until the Password is typed in. The only way to\r
+ disable the password is to type it in to a ConIn device.\r
+\r
+ @param Password Password used to lock ConIn device.\r
+\r
+ @retval EFI_SUCCESS lock the Console In Spliter virtual handle successfully.\r
+ @retval EFI_UNSUPPORTED Password not found\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+LockKeyboards (\r
+ IN CHAR16 *Password\r
+ )\r
+{\r
+ return EFI_UNSUPPORTED;\r
+}\r
--- /dev/null
+/** @file\r
+ Head file for BDS Platform specific code\r
+\r
+Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution. The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#ifndef _PLATFORM_SPECIFIC_BDS_PLATFORM_H_\r
+#define _PLATFORM_SPECIFIC_BDS_PLATFORM_H_\r
+\r
+#include <PiDxe.h>\r
+#include <IndustryStandard/Pci.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/PcdLib.h>\r
+#include <Library/GenericBdsLib.h>\r
+#include <Library/PlatformBdsLib.h>\r
+#include <Library/UefiLib.h>\r
+#include <Library/DevicePathLib.h>\r
+\r
+#include <Protocol/PciIo.h>\r
+#include <Protocol/SerialIo.h>\r
+\r
+#include <Guid/GlobalVariable.h>\r
+extern BDS_CONSOLE_CONNECT_ENTRY gPlatformConsole[];\r
+extern EFI_DEVICE_PATH_PROTOCOL *gPlatformConnectSequence[];\r
+extern EFI_DEVICE_PATH_PROTOCOL *gPlatformDriverOption[];\r
+extern EFI_DEVICE_PATH_PROTOCOL *gPlatformRootBridges[];\r
+extern ACPI_HID_DEVICE_PATH gPnp16550ComPortDeviceNode;\r
+extern UART_DEVICE_PATH gUartDeviceNode;\r
+extern VENDOR_DEVICE_PATH gTerminalTypeDeviceNode;\r
+extern VENDOR_DEVICE_PATH gUartDeviceVenderNode;\r
+\r
+//\r
+//\r
+//\r
+#define VarConsoleInpDev L"ConInDev"\r
+#define VarConsoleInp L"ConIn"\r
+#define VarConsoleOutDev L"ConOutDev"\r
+#define VarConsoleOut L"ConOut"\r
+#define VarErrorOutDev L"ErrOutDev"\r
+#define VarErrorOut L"ErrOut"\r
+\r
+#define PCI_DEVICE_PATH_NODE(Func, Dev) \\r
+ { \\r
+ { \\r
+ HARDWARE_DEVICE_PATH, \\r
+ HW_PCI_DP, \\r
+ { \\r
+ (UINT8) (sizeof (PCI_DEVICE_PATH)), \\r
+ (UINT8) ((sizeof (PCI_DEVICE_PATH)) >> 8) \\r
+ } \\r
+ }, \\r
+ (Func), \\r
+ (Dev) \\r
+ }\r
+\r
+#define PNPID_DEVICE_PATH_NODE(PnpId) \\r
+ { \\r
+ { \\r
+ ACPI_DEVICE_PATH, \\r
+ ACPI_DP, \\r
+ { \\r
+ (UINT8) (sizeof (ACPI_HID_DEVICE_PATH)), \\r
+ (UINT8) ((sizeof (ACPI_HID_DEVICE_PATH)) >> 8) \\r
+ }, \\r
+ }, \\r
+ EISA_PNP_ID((PnpId)), \\r
+ 0 \\r
+ }\r
+\r
+#define gPciRootBridge \\r
+ PNPID_DEVICE_PATH_NODE(0x0A03)\r
+#define gPnp16550ComPort \\r
+ PNPID_DEVICE_PATH_NODE(0x0501)\r
+\r
+#define gUartVender \\r
+ { \\r
+ { \\r
+ HARDWARE_DEVICE_PATH, \\r
+ HW_VENDOR_DP, \\r
+ { \\r
+ (UINT8) (sizeof (VENDOR_DEVICE_PATH)), \\r
+ (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8) \\r
+ } \\r
+ }, \\r
+ EFI_SERIAL_IO_PROTOCOL_GUID \\r
+ }\r
+ \r
+#define gUart \\r
+ { \\r
+ { \\r
+ MESSAGING_DEVICE_PATH, \\r
+ MSG_UART_DP, \\r
+ { \\r
+ (UINT8) (sizeof (UART_DEVICE_PATH)), \\r
+ (UINT8) ((sizeof (UART_DEVICE_PATH)) >> 8) \\r
+ } \\r
+ }, \\r
+ 0, \\r
+ 115200, \\r
+ 8, \\r
+ 1, \\r
+ 1 \\r
+ }\r
+\r
+#define gPcAnsiTerminal \\r
+ { \\r
+ { \\r
+ MESSAGING_DEVICE_PATH, \\r
+ MSG_VENDOR_DP, \\r
+ { \\r
+ (UINT8) (sizeof (VENDOR_DEVICE_PATH)), \\r
+ (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8) \\r
+ } \\r
+ }, \\r
+ DEVICE_PATH_MESSAGING_PC_ANSI \\r
+ }\r
+\r
+#define gEndEntire \\r
+ { \\r
+ END_DEVICE_PATH_TYPE, \\r
+ END_ENTIRE_DEVICE_PATH_SUBTYPE, \\r
+ { \\r
+ END_DEVICE_PATH_LENGTH, \\r
+ 0 \\r
+ } \\r
+ }\r
+#define PCI_CLASS_SCC 0x07\r
+#define PCI_SUBCLASS_SERIAL 0x00\r
+#define PCI_IF_16550 0x02\r
+#define IS_PCI_16550SERIAL(_p) IS_CLASS3 (_p, PCI_CLASS_SCC, PCI_SUBCLASS_SERIAL, PCI_IF_16550)\r
+\r
+#define IS_PCI_ISA_PDECODE(_p) IS_CLASS3 (_p, PCI_CLASS_BRIDGE, PCI_CLASS_BRIDGE_ISA_PDECODE, 0)\r
+\r
+//\r
+// Platform Root Bridge\r
+//\r
+typedef struct {\r
+ ACPI_HID_DEVICE_PATH PciRootBridge;\r
+ EFI_DEVICE_PATH_PROTOCOL End;\r
+} PLATFORM_ROOT_BRIDGE_DEVICE_PATH;\r
+EFI_STATUS\r
+PlatformBdsNoConsoleAction (\r
+ VOID\r
+ );\r
+VOID\r
+PlatformBdsEnterFrontPage (\r
+ IN UINT16 TimeoutDefault,\r
+ IN BOOLEAN ConnectAllHappened\r
+ );\r
+#endif // _PLATFORM_SPECIFIC_BDS_PLATFORM_H_\r
--- /dev/null
+## @file\r
+# Platform BDS customizations library.\r
+#\r
+# Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>\r
+# This program and the accompanying materials\r
+# are licensed and made available under the terms and conditions of the BSD License\r
+# which accompanies this distribution. The full text of the license may be found at\r
+# http://opensource.org/licenses/bsd-license.php\r
+#\r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+# \r
+##\r
+\r
+[Defines]\r
+ INF_VERSION = 0x00010005\r
+ BASE_NAME = PlatformBdsLib\r
+ FILE_GUID = CE70284F-9D7A-4c22-8769-E199387F40FC\r
+ MODULE_TYPE = DXE_DRIVER\r
+ VERSION_STRING = 1.0\r
+ LIBRARY_CLASS = PlatformBdsLib|DXE_DRIVER \r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+# VALID_ARCHITECTURES = IA32 X64 IPF EBC\r
+#\r
+\r
+[Sources]\r
+ BdsPlatform.c\r
+ PlatformData.c\r
+ BdsPlatform.h\r
+\r
+[Packages]\r
+ MdePkg/MdePkg.dec\r
+ MdeModulePkg/MdeModulePkg.dec\r
+ IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec\r
+ CorebootPayloadPkg/CorebootPayloadPkg.dec\r
+ \r
+[LibraryClasses]\r
+ BaseLib\r
+ MemoryAllocationLib\r
+ UefiBootServicesTableLib\r
+ BaseMemoryLib\r
+ DebugLib\r
+ PcdLib\r
+ GenericBdsLib\r
+[Pcd]\r
+ gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdPlatformBootTimeOut\r
+ gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdLogoFile\r
--- /dev/null
+/** @file\r
+ Defined the platform specific device path which will be used by\r
+ platform Bbd to perform the platform policy connect.\r
+\r
+Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution. The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "BdsPlatform.h"\r
+\r
+//\r
+// Predefined platform default time out value\r
+//\r
+UINT16 gPlatformBootTimeOutDefault = 5;\r
+\r
+ACPI_HID_DEVICE_PATH gPnp16550ComPortDeviceNode = gPnp16550ComPort;\r
+UART_DEVICE_PATH gUartDeviceNode = gUart;\r
+VENDOR_DEVICE_PATH gTerminalTypeDeviceNode = gPcAnsiTerminal;\r
+VENDOR_DEVICE_PATH gUartDeviceVenderNode = gUartVender;\r
+//\r
+// Predefined platform root bridge\r
+//\r
+PLATFORM_ROOT_BRIDGE_DEVICE_PATH gPlatformRootBridge0 = {\r
+ gPciRootBridge,\r
+ gEndEntire\r
+};\r
+\r
+EFI_DEVICE_PATH_PROTOCOL *gPlatformRootBridges[] = {\r
+ (EFI_DEVICE_PATH_PROTOCOL *) &gPlatformRootBridge0,\r
+ NULL\r
+};\r
+\r
+//\r
+// Platform specific keyboard device path\r
+//\r
+\r
+///\r
+/// Predefined platform default console device path\r
+///\r
+BDS_CONSOLE_CONNECT_ENTRY gPlatformConsole[] = {\r
+ {\r
+ NULL,\r
+ 0\r
+ }\r
+};\r
+\r
+///\r
+/// Predefined platform specific driver option\r
+///\r
+EFI_DEVICE_PATH_PROTOCOL *gPlatformDriverOption[] = { NULL };\r
+\r
+///\r
+/// Predefined platform connect sequence\r
+///\r
+EFI_DEVICE_PATH_PROTOCOL *gPlatformConnectSequence[] = { NULL };\r
--- /dev/null
+/** @file\r
+ Reset System Library functions for coreboot\r
+\r
+ Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>\r
+ This program and the accompanying materials\r
+ are licensed and made available under the terms and conditions of the BSD License\r
+ which accompanies this distribution. The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php\r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include <PiDxe.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/IoLib.h>\r
+#include <Library/HobLib.h>\r
+\r
+#include <Guid/AcpiBoardInfoGuid.h>\r
+\r
+VOID\r
+AcpiPmControl (\r
+ UINTN SuspendType\r
+ )\r
+{\r
+ EFI_HOB_GUID_TYPE *GuidHob;\r
+ ACPI_BOARD_INFO *pAcpiBoardInfo; \r
+ UINTN PmCtrlReg = 0;\r
+ \r
+ ASSERT (SuspendType <= 7); \r
+ //\r
+ // Find the acpi board information guid hob\r
+ //\r
+ GuidHob = GetFirstGuidHob (&gUefiAcpiBoardInfoGuid);\r
+ ASSERT (GuidHob != NULL);\r
+ pAcpiBoardInfo = (ACPI_BOARD_INFO *)GET_GUID_HOB_DATA (GuidHob); \r
+ \r
+ PmCtrlReg = (UINTN)pAcpiBoardInfo->PmCtrlRegBase; \r
+ IoAndThenOr16 (PmCtrlReg, (UINT16) ~0x3c00, (UINT16) (SuspendType << 10));\r
+ IoOr16 (PmCtrlReg, BIT13);\r
+ CpuDeadLoop ();\r
+}\r
+\r
+/**\r
+ Calling this function causes a system-wide reset. This sets\r
+ all circuitry within the system to its initial state. This type of reset\r
+ is asynchronous to system operation and operates without regard to\r
+ cycle boundaries.\r
+\r
+ System reset should not return, if it returns, it means the system does\r
+ not support cold reset.\r
+**/\r
+VOID\r
+EFIAPI\r
+ResetCold (\r
+ VOID\r
+ )\r
+{\r
+ EFI_HOB_GUID_TYPE *GuidHob;\r
+ ACPI_BOARD_INFO *pAcpiBoardInfo; \r
+ \r
+ //\r
+ // Find the acpi board information guid hob\r
+ //\r
+ GuidHob = GetFirstGuidHob (&gUefiAcpiBoardInfoGuid);\r
+ ASSERT (GuidHob != NULL);\r
+ pAcpiBoardInfo = (ACPI_BOARD_INFO *)GET_GUID_HOB_DATA (GuidHob); \r
+ \r
+ IoWrite8 ((UINTN)pAcpiBoardInfo->ResetRegAddress, pAcpiBoardInfo->ResetValue);\r
+ CpuDeadLoop ();\r
+}\r
+\r
+/**\r
+ Calling this function causes a system-wide initialization. The processors\r
+ are set to their initial state, and pending cycles are not corrupted.\r
+\r
+ System reset should not return, if it returns, it means the system does\r
+ not support warm reset.\r
+**/\r
+VOID\r
+EFIAPI\r
+ResetWarm (\r
+ VOID\r
+ )\r
+{\r
+ EFI_HOB_GUID_TYPE *GuidHob;\r
+ ACPI_BOARD_INFO *pAcpiBoardInfo; \r
+ \r
+ //\r
+ // Find the acpi board information guid hob\r
+ //\r
+ GuidHob = GetFirstGuidHob (&gUefiAcpiBoardInfoGuid);\r
+ ASSERT (GuidHob != NULL);\r
+ pAcpiBoardInfo = (ACPI_BOARD_INFO *)GET_GUID_HOB_DATA (GuidHob); \r
+ \r
+ IoWrite8 ((UINTN)pAcpiBoardInfo->ResetRegAddress, pAcpiBoardInfo->ResetValue);\r
+ CpuDeadLoop ();\r
+}\r
+\r
+/**\r
+ Calling this function causes the system to enter a power state equivalent\r
+ to the ACPI G2/S5 or G3 states.\r
+\r
+ System shutdown should not return, if it returns, it means the system does\r
+ not support shut down reset.\r
+**/\r
+VOID\r
+EFIAPI\r
+ResetShutdown (\r
+ VOID\r
+ )\r
+{\r
+ AcpiPmControl (7);\r
+ ASSERT (FALSE);\r
+}\r
+\r
+\r
+/**\r
+ Calling this function causes the system to enter a power state for capsule\r
+ update.\r
+\r
+ Reset update should not return, if it returns, it means the system does\r
+ not support capsule update.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+EnterS3WithImmediateWake (\r
+ VOID\r
+ )\r
+{\r
+ AcpiPmControl (5);\r
+ ASSERT (FALSE);\r
+}\r
--- /dev/null
+## @file\r
+# Library instance for ResetSystem library class for coreboot\r
+#\r
+# Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>\r
+# This program and the accompanying materials\r
+# are licensed and made available under the terms and conditions of the BSD License\r
+# which accompanies this distribution. The full text of the license may be found at\r
+# http://opensource.org/licenses/bsd-license.php\r
+#\r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+##\r
+\r
+[Defines]\r
+ INF_VERSION = 0x00010005\r
+ BASE_NAME = ResetSystemLib\r
+ FILE_GUID = C5CD4EEE-527F-47df-9C92-B41414AF7479\r
+ MODULE_TYPE = BASE\r
+ VERSION_STRING = 1.0\r
+ LIBRARY_CLASS = ResetSystemLib\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+# VALID_ARCHITECTURES = IA32 X64 IPF\r
+#\r
+\r
+[Sources]\r
+ ResetSystemLib.c\r
+\r
+[Packages]\r
+ MdePkg/MdePkg.dec\r
+ MdeModulePkg/MdeModulePkg.dec\r
+ CorebootModulePkg/CorebootModulePkg.dec\r
+ \r
+[LibraryClasses]\r
+ DebugLib\r
+ IoLib\r
+ HobLib\r
+ \r
+[Guids] \r
+ gUefiAcpiBoardInfoGuid\r
+\r
--- /dev/null
+/** @file\r
+ SerialPortLib instance for UART device upon coreboot\r
+\r
+ Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>\r
+ This program and the accompanying materials\r
+ are licensed and made available under the terms and conditions of the BSD License\r
+ which accompanies this distribution. The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php\r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include <Uefi/UefiBaseType.h>\r
+#include <Library/SerialPortLib.h>\r
+#include <Library/PcdLib.h>\r
+#include <Library/IoLib.h>\r
+#include <Library/CbParseLib.h>\r
+\r
+//\r
+// 16550 UART register offsets and bitfields\r
+//\r
+#define R_UART_RXBUF 0\r
+#define R_UART_TXBUF 0\r
+#define R_UART_BAUD_LOW 0\r
+#define R_UART_BAUD_HIGH 1\r
+#define R_UART_FCR 2\r
+#define B_UART_FCR_FIFOE BIT0\r
+#define B_UART_FCR_FIFO64 BIT5\r
+#define R_UART_LCR 3\r
+#define B_UART_LCR_DLAB BIT7\r
+#define R_UART_MCR 4\r
+#define B_UART_MCR_RTS BIT1\r
+#define R_UART_LSR 5\r
+#define B_UART_LSR_RXRDY BIT0\r
+#define B_UART_LSR_TXRDY BIT5\r
+#define B_UART_LSR_TEMT BIT6\r
+#define R_UART_MSR 6\r
+#define B_UART_MSR_CTS BIT4\r
+#define B_UART_MSR_DSR BIT5\r
+\r
+UINT32 mSerialRegBase = 0;\r
+UINT32 mSerialRegAccessType = 0;\r
+\r
+/**\r
+ Read an 8-bit 16550 register. If PcdSerialUseMmio is TRUE, then the value is read from \r
+ MMIO space. If PcdSerialUseMmio is FALSE, then the value is read from I/O space. The\r
+ parameter Offset is added to the base address of the 16550 registers that is specified \r
+ by PcdSerialRegisterBase. \r
+ \r
+ @param Offset The offset of the 16550 register to read.\r
+\r
+ @return The value read from the 16550 register.\r
+\r
+**/\r
+UINT8\r
+SerialPortReadRegister (\r
+ UINTN Offset\r
+ )\r
+{\r
+ if (mSerialRegAccessType == 2) { //MMIO\r
+ return MmioRead8 (mSerialRegBase + Offset);\r
+ } else { //IO\r
+ return IoRead8 ((UINT16)mSerialRegBase + Offset);\r
+ }\r
+}\r
+\r
+/**\r
+ Write an 8-bit 16550 register. If PcdSerialUseMmio is TRUE, then the value is written to\r
+ MMIO space. If PcdSerialUseMmio is FALSE, then the value is written to I/O space. The\r
+ parameter Offset is added to the base address of the 16550 registers that is specified \r
+ by PcdSerialRegisterBase. \r
+ \r
+ @param Offset The offset of the 16550 register to write.\r
+ @param Value The value to write to the 16550 register specified by Offset.\r
+\r
+ @return The value written to the 16550 register.\r
+\r
+**/\r
+UINT8\r
+SerialPortWriteRegister (\r
+ UINTN Offset,\r
+ UINT8 Value\r
+ )\r
+{\r
+ if (mSerialRegAccessType == 2) { //MMIO\r
+ return MmioWrite8 (mSerialRegBase + Offset, Value);\r
+ } else {// IO\r
+ return IoWrite8 ((UINT16)mSerialRegBase + Offset, Value);\r
+ }\r
+}\r
+\r
+/**\r
+ Initialize the serial device hardware.\r
+ \r
+ If no initialization is required, then return RETURN_SUCCESS.\r
+ If the serial device was successfully initialized, then return RETURN_SUCCESS.\r
+ If the serial device could not be initialized, then return RETURN_DEVICE_ERROR.\r
+ \r
+ @retval RETURN_SUCCESS The serial device was initialized.\r
+ @retval RETURN_DEVICE_ERROR The serial device could not be initialized.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+SerialPortInitialize (\r
+ VOID\r
+ )\r
+{\r
+ RETURN_STATUS Status;\r
+ UINTN Divisor;\r
+ BOOLEAN Initialized;\r
+ \r
+ Status = CbParseSerialInfo (&mSerialRegBase, &mSerialRegAccessType, NULL);\r
+ if (RETURN_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+\r
+ //\r
+ // See if the serial port is already initialized\r
+ //\r
+ Initialized = TRUE;\r
+ if ((SerialPortReadRegister (R_UART_FCR) & (B_UART_FCR_FIFOE | B_UART_FCR_FIFO64)) !=\r
+ (PcdGet8 (PcdSerialFifoControl) & (B_UART_FCR_FIFOE | B_UART_FCR_FIFO64)) ) {\r
+ Initialized = FALSE;\r
+ }\r
+\r
+ if ((SerialPortReadRegister (R_UART_LCR) & 0x3F) != (PcdGet8 (PcdSerialLineControl) & 0x3F)) {\r
+ Initialized = FALSE;\r
+ }\r
+ SerialPortWriteRegister (R_UART_LCR, (UINT8)(SerialPortReadRegister (R_UART_LCR) | B_UART_LCR_DLAB));\r
+ Divisor = SerialPortReadRegister (R_UART_BAUD_HIGH) << 8;\r
+ Divisor |= SerialPortReadRegister (R_UART_BAUD_LOW);\r
+ SerialPortWriteRegister (R_UART_LCR, (UINT8)(SerialPortReadRegister (R_UART_LCR) & ~B_UART_LCR_DLAB));\r
+ if (Divisor != 115200 / PcdGet32 (PcdSerialBaudRate)) {\r
+ Initialized = FALSE;\r
+ }\r
+ if (Initialized) {\r
+ return RETURN_SUCCESS;\r
+ }\r
+ \r
+ //\r
+ // Configure baud rate\r
+ //\r
+ Divisor = 115200 / PcdGet32 (PcdSerialBaudRate);\r
+ SerialPortWriteRegister (R_UART_LCR, B_UART_LCR_DLAB);\r
+ SerialPortWriteRegister (R_UART_BAUD_HIGH, (UINT8) (Divisor >> 8));\r
+ SerialPortWriteRegister (R_UART_BAUD_LOW, (UINT8) (Divisor & 0xff));\r
+\r
+ //\r
+ // Clear DLAB and configure Data Bits, Parity, and Stop Bits.\r
+ // Strip reserved bits from PcdSerialLineControl\r
+ //\r
+ SerialPortWriteRegister (R_UART_LCR, (UINT8)(PcdGet8 (PcdSerialLineControl) & 0x3F));\r
+\r
+ //\r
+ // Enable and reset FIFOs\r
+ // Strip reserved bits from PcdSerialFifoControl\r
+ //\r
+ SerialPortWriteRegister (R_UART_FCR, (UINT8)(PcdGet8 (PcdSerialFifoControl) & 0x27));\r
+\r
+ //\r
+ // Put Modem Control Register(MCR) into its reset state of 0x00.\r
+ // \r
+ SerialPortWriteRegister (R_UART_MCR, 0x00);\r
+ \r
+ return RETURN_SUCCESS;\r
+}\r
+\r
+/**\r
+ Write data from buffer to serial device. \r
+ \r
+ Writes NumberOfBytes data bytes from Buffer to the serial device. \r
+ The number of bytes actually written to the serial device is returned.\r
+ If the return value is less than NumberOfBytes, then the write operation failed.\r
+\r
+ If Buffer is NULL, then ASSERT(). \r
+\r
+ If NumberOfBytes is zero, then return 0.\r
+\r
+ @param Buffer Pointer to the data buffer to be written.\r
+ @param NumberOfBytes Number of bytes to written to the serial device.\r
+\r
+ @retval 0 NumberOfBytes is 0.\r
+ @retval >0 The number of bytes written to the serial device. \r
+ If this value is less than NumberOfBytes, then the read operation failed.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+SerialPortWrite (\r
+ IN UINT8 *Buffer,\r
+ IN UINTN NumberOfBytes\r
+)\r
+{\r
+ UINTN Result;\r
+ UINTN Index;\r
+ UINTN FifoSize;\r
+\r
+ if (Buffer == NULL) {\r
+ return 0;\r
+ }\r
+\r
+ if (NumberOfBytes == 0) {\r
+ //\r
+ // Flush the hardware\r
+ //\r
+\r
+ //\r
+ // Wait for both the transmit FIFO and shift register empty.\r
+ //\r
+ while ((SerialPortReadRegister (R_UART_LSR) & B_UART_LSR_TEMT) == 0);\r
+\r
+ return 0;\r
+ }\r
+\r
+ //\r
+ // Compute the maximum size of the Tx FIFO\r
+ //\r
+ FifoSize = 1;\r
+ if ((PcdGet8 (PcdSerialFifoControl) & B_UART_FCR_FIFOE) != 0) {\r
+ if ((PcdGet8 (PcdSerialFifoControl) & B_UART_FCR_FIFO64) == 0) {\r
+ FifoSize = 16;\r
+ } else {\r
+ FifoSize = 64;\r
+ }\r
+ }\r
+\r
+ Result = NumberOfBytes;\r
+ while (NumberOfBytes != 0) {\r
+ //\r
+ // Wait for the serial port to be ready, to make sure both the transmit FIFO\r
+ // and shift register empty.\r
+ //\r
+ while ((SerialPortReadRegister (R_UART_LSR) & B_UART_LSR_TEMT) == 0);\r
+\r
+ //\r
+ // Fill then entire Tx FIFO\r
+ //\r
+ for (Index = 0; Index < FifoSize && NumberOfBytes != 0; Index++, NumberOfBytes--, Buffer++) {\r
+\r
+ //\r
+ // Write byte to the transmit buffer.\r
+ //\r
+ SerialPortWriteRegister (R_UART_TXBUF, *Buffer);\r
+ }\r
+ }\r
+ return Result;\r
+}\r
+\r
+/**\r
+ Reads data from a serial device into a buffer.\r
+\r
+ @param Buffer Pointer to the data buffer to store the data read from the serial device.\r
+ @param NumberOfBytes Number of bytes to read from the serial device.\r
+\r
+ @retval 0 NumberOfBytes is 0.\r
+ @retval >0 The number of bytes read from the serial device. \r
+ If this value is less than NumberOfBytes, then the read operation failed.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+SerialPortRead (\r
+ OUT UINT8 *Buffer,\r
+ IN UINTN NumberOfBytes\r
+)\r
+{\r
+ UINTN Result;\r
+\r
+ if (NULL == Buffer) {\r
+ return 0;\r
+ }\r
+ \r
+ for (Result = 0; NumberOfBytes-- != 0; Result++, Buffer++) {\r
+ //\r
+ // Wait for the serial port to have some data.\r
+ //\r
+ while ((SerialPortReadRegister (R_UART_LSR) & B_UART_LSR_RXRDY) == 0);\r
+ \r
+ //\r
+ // Read byte from the receive buffer.\r
+ //\r
+ *Buffer = SerialPortReadRegister (R_UART_RXBUF);\r
+ }\r
+ \r
+ return Result;\r
+}\r
+\r
+/**\r
+ Polls a serial device to see if there is any data waiting to be read.\r
+\r
+ Polls aserial device to see if there is any data waiting to be read.\r
+ If there is data waiting to be read from the serial device, then TRUE is returned.\r
+ If there is no data waiting to be read from the serial device, then FALSE is returned.\r
+\r
+ @retval TRUE Data is waiting to be read from the serial device.\r
+ @retval FALSE There is no data waiting to be read from the serial device.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+SerialPortPoll (\r
+ VOID\r
+ )\r
+{\r
+ //\r
+ // Read the serial port status\r
+ //\r
+ if ((SerialPortReadRegister (R_UART_LSR) & B_UART_LSR_RXRDY) != 0) {\r
+ return TRUE;\r
+ } \r
+ \r
+ return FALSE;\r
+}\r
--- /dev/null
+## @file\r
+# SerialPortLib instance for UART device upon coreboot\r
+#\r
+# Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>\r
+# This program and the accompanying materials\r
+# are licensed and made available under the terms and conditions of the BSD License\r
+# which accompanies this distribution. The full text of the license may be found at\r
+# http://opensource.org/licenses/bsd-license.php\r
+#\r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+##\r
+\r
+[Defines]\r
+ INF_VERSION = 0x00010005\r
+ BASE_NAME = SerialPortLib\r
+ FILE_GUID = 40A2CBC6-CFB8-447b-A90E-198E88FD345E\r
+ MODULE_TYPE = BASE\r
+ VERSION_STRING = 1.0\r
+ LIBRARY_CLASS = SerialPortLib\r
+ \r
+ CONSTRUCTOR = SerialPortInitialize\r
+ \r
+[Sources]\r
+ SerialPortLib.c\r
+ \r
+[Packages]\r
+ MdePkg/MdePkg.dec\r
+ MdeModulePkg/MdeModulePkg.dec\r
+ CorebootModulePkg/CorebootModulePkg.dec\r
+\r
+[LibraryClasses]\r
+ BaseLib\r
+ PcdLib\r
+ IoLib\r
+ CbParseLib\r
+ \r
+[Pcd]\r
+ gEfiMdeModulePkgTokenSpaceGuid.PcdSerialBaudRate\r
+ gEfiMdeModulePkgTokenSpaceGuid.PcdSerialLineControl\r
+ gEfiMdeModulePkgTokenSpaceGuid.PcdSerialFifoControl
\ No newline at end of file
--- /dev/null
+#/** @file\r
+# \r
+# Convert SerialLib into SerialIo protocol\r
+# \r
+# Copyright (c) 2008 - 2014, Intel Corporation. All rights reserved.<BR>\r
+# This program and the accompanying materials\r
+# are licensed and made available under the terms and conditions of the BSD License\r
+# which accompanies this distribution. The full text of the license may be found at\r
+# http://opensource.org/licenses/bsd-license.php\r
+# \r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+# \r
+#**/\r
+\r
+[Defines]\r
+ INF_VERSION = 0x00010005\r
+ BASE_NAME = SerialDxe\r
+ FILE_GUID = D3987D4B-971A-435F-8CAF-4967EB627241\r
+ MODULE_TYPE = DXE_DRIVER\r
+ VERSION_STRING = 1.0\r
+\r
+ ENTRY_POINT = SerialDxeInitialize\r
+\r
+[Sources.common]\r
+ SerialIo.c\r
+\r
+[Packages]\r
+ MdePkg/MdePkg.dec\r
+ MdeModulePkg/MdeModulePkg.dec\r
+\r
+[LibraryClasses]\r
+ BaseLib\r
+ ReportStatusCodeLib\r
+ MemoryAllocationLib\r
+ UefiLib\r
+ UefiBootServicesTableLib\r
+ BaseMemoryLib\r
+ DebugLib\r
+ UefiDriverEntryPoint\r
+ SerialPortLib\r
+ \r
+\r
+[Protocols]\r
+ gEfiSerialIoProtocolGuid \r
+ gEfiDevicePathProtocolGuid\r
+\r
+[FixedPcd]\r
+ gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate\r
+ gEfiMdePkgTokenSpaceGuid.PcdUartDefaultDataBits\r
+ gEfiMdePkgTokenSpaceGuid.PcdUartDefaultParity\r
+ gEfiMdePkgTokenSpaceGuid.PcdUartDefaultStopBits\r
+\r
+[Depex] \r
+ TRUE\r
--- /dev/null
+/** @file\r
+ Serial IO Abstraction for GDB stub. This allows an EFI consoles that shows up on the system \r
+ running GDB. One console for error information and another console for user input/output.\r
+ \r
+ Basic packet format is $packet-data#checksum. So every command has 4 bytes of overhead: $,\r
+ #, 0, 0. The 0 and 0 are the ascii characters for the checksum. \r
+ \r
+\r
+ Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
+ Copyright (c) 2013, ARM Ltd. All rights reserved.<BR>\r
+ Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>\r
+ \r
+ This program and the accompanying materials\r
+ are licensed and made available under the terms and conditions of the BSD License\r
+ which accompanies this distribution. The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php\r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include <PiDxe.h>\r
+#include <Library/UefiLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/SerialPortLib.h>\r
+#include <Library/PcdLib.h>\r
+\r
+#include <Protocol/SerialIo.h>\r
+\r
+typedef struct {\r
+ VENDOR_DEVICE_PATH Guid;\r
+ UART_DEVICE_PATH Uart;\r
+ EFI_DEVICE_PATH_PROTOCOL End;\r
+} SIMPLE_TEXT_OUT_DEVICE_PATH;\r
+\r
+SIMPLE_TEXT_OUT_DEVICE_PATH mDevicePath = {\r
+ {\r
+ { HARDWARE_DEVICE_PATH, HW_VENDOR_DP, sizeof (VENDOR_DEVICE_PATH), 0},\r
+ EFI_SERIAL_IO_PROTOCOL_GUID // Use the drivers GUID\r
+ },\r
+ {\r
+ { MESSAGING_DEVICE_PATH, MSG_UART_DP, sizeof (UART_DEVICE_PATH), 0},\r
+ 0, // Reserved\r
+ FixedPcdGet64 (PcdUartDefaultBaudRate), // BaudRate\r
+ FixedPcdGet8 (PcdUartDefaultDataBits), // DataBits\r
+ FixedPcdGet8 (PcdUartDefaultParity), // Parity (N)\r
+ FixedPcdGet8 (PcdUartDefaultStopBits) // StopBits\r
+ },\r
+ { END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE, sizeof (EFI_DEVICE_PATH_PROTOCOL), 0}\r
+};\r
+\r
+EFI_HANDLE gHandle = NULL;\r
+\r
+/**\r
+ Reset the serial device.\r
+\r
+ @param This Protocol instance pointer.\r
+ \r
+ @retval EFI_SUCCESS The device was reset.\r
+ @retval EFI_DEVICE_ERROR The serial device could not be reset.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+SerialReset (\r
+ IN EFI_SERIAL_IO_PROTOCOL *This\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_TPL Tpl;\r
+\r
+ Status = SerialPortInitialize ();\r
+ if (EFI_ERROR(Status)) {\r
+ return Status;\r
+ }\r
+\r
+ //\r
+ // Set the Serial I/O mode and update the device path\r
+ //\r
+\r
+ Tpl = gBS->RaiseTPL (TPL_NOTIFY);\r
+\r
+ //\r
+ // Set the Serial I/O mode\r
+ //\r
+ This->Mode->ReceiveFifoDepth = 0;\r
+ This->Mode->Timeout = 1000000;\r
+ This->Mode->BaudRate = PcdGet64 (PcdUartDefaultBaudRate);\r
+ This->Mode->DataBits = (UINT32)PcdGet8 (PcdUartDefaultDataBits);\r
+ This->Mode->Parity = (UINT32)PcdGet8 (PcdUartDefaultParity);\r
+ This->Mode->StopBits = (UINT32)PcdGet8 (PcdUartDefaultStopBits);\r
+\r
+ //\r
+ // Check if the device path has actually changed\r
+ //\r
+ if (mDevicePath.Uart.BaudRate == This->Mode->BaudRate &&\r
+ mDevicePath.Uart.DataBits == (UINT8)This->Mode->DataBits &&\r
+ mDevicePath.Uart.Parity == (UINT8)This->Mode->Parity &&\r
+ mDevicePath.Uart.StopBits == (UINT8)This->Mode->StopBits\r
+ ) {\r
+ gBS->RestoreTPL (Tpl);\r
+ return EFI_SUCCESS;\r
+ }\r
+\r
+ //\r
+ // Update the device path\r
+ //\r
+ mDevicePath.Uart.BaudRate = This->Mode->BaudRate;\r
+ mDevicePath.Uart.DataBits = (UINT8)This->Mode->DataBits;\r
+ mDevicePath.Uart.Parity = (UINT8)This->Mode->Parity;\r
+ mDevicePath.Uart.StopBits = (UINT8)This->Mode->StopBits;\r
+\r
+ Status = gBS->ReinstallProtocolInterface (\r
+ gHandle,\r
+ &gEfiDevicePathProtocolGuid,\r
+ &mDevicePath,\r
+ &mDevicePath\r
+ );\r
+\r
+ gBS->RestoreTPL (Tpl);\r
+\r
+ return Status;\r
+}\r
+\r
+\r
+/**\r
+ Sets the baud rate, receive FIFO depth, transmit/receive time out, parity,\r
+ data buts, and stop bits on a serial device.\r
+\r
+ @param This Protocol instance pointer.\r
+ @param BaudRate The requested baud rate. A BaudRate value of 0 will use the the\r
+ device's default interface speed.\r
+ @param ReceiveFifoDepth The requested depth of the FIFO on the receive side of the\r
+ serial interface. A ReceiveFifoDepth value of 0 will use\r
+ the device's default FIFO depth.\r
+ @param Timeout The requested time out for a single character in microseconds.\r
+ This timeout applies to both the transmit and receive side of the\r
+ interface. A Timeout value of 0 will use the device's default time\r
+ out value.\r
+ @param Parity The type of parity to use on this serial device. A Parity value of\r
+ DefaultParity will use the device's default parity value.\r
+ @param DataBits The number of data bits to use on the serial device. A DataBits\r
+ value of 0 will use the device's default data bit setting.\r
+ @param StopBits The number of stop bits to use on this serial device. A StopBits\r
+ value of DefaultStopBits will use the device's default number of\r
+ stop bits.\r
+\r
+ @retval EFI_SUCCESS The device was reset.\r
+ @retval EFI_DEVICE_ERROR The serial device could not be reset.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+SerialSetAttributes (\r
+ IN EFI_SERIAL_IO_PROTOCOL *This,\r
+ IN UINT64 BaudRate,\r
+ IN UINT32 ReceiveFifoDepth,\r
+ IN UINT32 Timeout,\r
+ IN EFI_PARITY_TYPE Parity,\r
+ IN UINT8 DataBits,\r
+ IN EFI_STOP_BITS_TYPE StopBits\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_TPL Tpl;\r
+\r
+ //\r
+ // Set the Serial I/O mode and update the device path\r
+ //\r
+\r
+ Tpl = gBS->RaiseTPL (TPL_NOTIFY);\r
+\r
+ //\r
+ // Set the Serial I/O mode\r
+ //\r
+ This->Mode->BaudRate = BaudRate;\r
+ This->Mode->ReceiveFifoDepth = ReceiveFifoDepth;\r
+ This->Mode->Timeout = Timeout;\r
+ This->Mode->Parity = (UINT32)Parity;\r
+ This->Mode->DataBits = (UINT32)DataBits;\r
+ This->Mode->StopBits = (UINT32)StopBits;\r
+\r
+ //\r
+ // Check if the device path has actually changed\r
+ //\r
+ if (mDevicePath.Uart.BaudRate == BaudRate &&\r
+ mDevicePath.Uart.Parity == (UINT8)Parity &&\r
+ mDevicePath.Uart.DataBits == DataBits &&\r
+ mDevicePath.Uart.StopBits == (UINT8)StopBits\r
+ ) {\r
+ gBS->RestoreTPL (Tpl);\r
+ return EFI_SUCCESS;\r
+ }\r
+\r
+ //\r
+ // Update the device path\r
+ //\r
+ mDevicePath.Uart.BaudRate = BaudRate;\r
+ mDevicePath.Uart.DataBits = DataBits;\r
+ mDevicePath.Uart.Parity = (UINT8) Parity;\r
+ mDevicePath.Uart.StopBits = (UINT8) StopBits;\r
+\r
+ Status = gBS->ReinstallProtocolInterface (\r
+ gHandle,\r
+ &gEfiDevicePathProtocolGuid,\r
+ &mDevicePath,\r
+ &mDevicePath\r
+ );\r
+\r
+ gBS->RestoreTPL (Tpl);\r
+\r
+ return Status;\r
+}\r
+\r
+\r
+/**\r
+ Set the control bits on a serial device\r
+\r
+ @param This Protocol instance pointer.\r
+ @param Control Set the bits of Control that are settable.\r
+\r
+ @retval EFI_SUCCESS The new control bits were set on the serial device.\r
+ @retval EFI_UNSUPPORTED The serial device does not support this operation.\r
+ @retval EFI_DEVICE_ERROR The serial device is not functioning correctly.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+SerialSetControl (\r
+ IN EFI_SERIAL_IO_PROTOCOL *This,\r
+ IN UINT32 Control\r
+ )\r
+{\r
+ return EFI_UNSUPPORTED;\r
+}\r
+\r
+\r
+/**\r
+ Retrieves the status of the control bits on a serial device\r
+\r
+ @param This Protocol instance pointer.\r
+ @param Control A pointer to return the current Control signals from the serial device.\r
+ \r
+ @retval EFI_SUCCESS The control bits were read from the serial device.\r
+ @retval EFI_DEVICE_ERROR The serial device is not functioning correctly.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+SerialGetControl (\r
+ IN EFI_SERIAL_IO_PROTOCOL *This,\r
+ OUT UINT32 *Control\r
+ )\r
+{\r
+ if (SerialPortPoll ()) {\r
+ // If a character is pending don't set EFI_SERIAL_INPUT_BUFFER_EMPTY\r
+ *Control = EFI_SERIAL_OUTPUT_BUFFER_EMPTY;\r
+ } else {\r
+ *Control = EFI_SERIAL_INPUT_BUFFER_EMPTY | EFI_SERIAL_OUTPUT_BUFFER_EMPTY;\r
+ }\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+\r
+/**\r
+ Writes data to a serial device.\r
+\r
+ @param This Protocol instance pointer.\r
+ @param BufferSize On input, the size of the Buffer. On output, the amount of\r
+ data actually written.\r
+ @param Buffer The buffer of data to write\r
+\r
+ @retval EFI_SUCCESS The data was written.\r
+ @retval EFI_DEVICE_ERROR The device reported an error.\r
+ @retval EFI_TIMEOUT The data write was stopped due to a timeout.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+SerialWrite (\r
+ IN EFI_SERIAL_IO_PROTOCOL *This,\r
+ IN OUT UINTN *BufferSize,\r
+ IN VOID *Buffer\r
+ )\r
+{\r
+ UINTN Count;\r
+ \r
+ Count = SerialPortWrite (Buffer, *BufferSize);\r
+\r
+ if (Count != *BufferSize) {\r
+ *BufferSize = Count;\r
+ return EFI_TIMEOUT;\r
+ }\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+ Reads data from a serial device.\r
+\r
+ @param This Protocol instance pointer.\r
+ @param BufferSize On input, the size of the Buffer. On output, the amount of\r
+ data returned in Buffer.\r
+ @param Buffer The buffer to return the data into.\r
+\r
+ @retval EFI_SUCCESS The data was read.\r
+ @retval EFI_DEVICE_ERROR The device reported an error.\r
+ @retval EFI_TIMEOUT The data write was stopped due to a timeout.\r
+\r
+**/\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+SerialRead (\r
+ IN EFI_SERIAL_IO_PROTOCOL *This,\r
+ IN OUT UINTN *BufferSize,\r
+ OUT VOID *Buffer\r
+ )\r
+{\r
+ UINTN Count = 0;\r
+\r
+ if (SerialPortPoll()) {\r
+ Count = SerialPortRead (Buffer, *BufferSize);\r
+ }\r
+\r
+ if (Count != *BufferSize) {\r
+ *BufferSize = Count;\r
+ return EFI_TIMEOUT;\r
+ }\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+// \r
+// Template used to initialize the GDB Serial IO protocols\r
+//\r
+EFI_SERIAL_IO_MODE gSerialIoMode = {\r
+ 0, // ControlMask\r
+ 0, // Timeout\r
+ FixedPcdGet64 (PcdUartDefaultBaudRate), // BaudRate\r
+ 1, // ReceiveFifoDepth\r
+ FixedPcdGet8 (PcdUartDefaultDataBits), // DataBits\r
+ FixedPcdGet8 (PcdUartDefaultParity), // Parity\r
+ FixedPcdGet8 (PcdUartDefaultStopBits) // StopBits\r
+};\r
+\r
+\r
+EFI_SERIAL_IO_PROTOCOL gSerialIoTemplate = {\r
+ SERIAL_IO_INTERFACE_REVISION,\r
+ SerialReset,\r
+ SerialSetAttributes,\r
+ SerialSetControl,\r
+ SerialGetControl,\r
+ SerialWrite,\r
+ SerialRead,\r
+ &gSerialIoMode\r
+};\r
+\r
+/**\r
+ Initialize the state information for the Serial Io Protocol\r
+\r
+ @param ImageHandle of the loaded driver\r
+ @param SystemTable Pointer to the System Table\r
+\r
+ @retval EFI_SUCCESS Protocol registered\r
+ @retval EFI_OUT_OF_RESOURCES Cannot allocate protocol data structure\r
+ @retval EFI_DEVICE_ERROR Hardware problems\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+SerialDxeInitialize (\r
+ IN EFI_HANDLE ImageHandle,\r
+ IN EFI_SYSTEM_TABLE *SystemTable\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+\r
+ // Make a new handle with Serial IO protocol and its device path on it.\r
+ Status = gBS->InstallMultipleProtocolInterfaces (\r
+ &gHandle, \r
+ &gEfiSerialIoProtocolGuid, &gSerialIoTemplate,\r
+ &gEfiDevicePathProtocolGuid, &mDevicePath, \r
+ NULL\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+ \r
+ return Status;\r
+}\r
+\r