Revision: 17081
          http://sourceforge.net/p/edk2/code/17081
Author:   mauricema
Date:     2015-03-31 00:56:01 +0000 (Tue, 31 Mar 2015)
Log Message:
-----------
Pkg-Module: CorebootPayloadPkg

Initial coreboot UEFI payload code check in. It provides UEFI services on top 
of coreboot that allows UEFI OS boot.

CorebootPayloadPkg is source code package of coreboot Payload Modules, Provides 
definitions of payload image's layout and lists the modules required in DSC 
file.

It supports the following features:
  - Support Unified Extensible Firmware Interface (UEFI) specification 2.4.
  - Support Platform Initialization(PI) specification 1.3.
  - Support execution as a coreboot payload.
  - Support USB 3.0
  - Support SATA/ATA devices.
  - Support EFI aware OS boot.

The following features are not supported currently and have not been validated:
  - GCC Tool Chains
  - SMM Execution Environment
  - Security Boot

It was tested on a Intel Bay Trail CRB platform.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Maurice Ma <[email protected]>
Reviewed-by: Prince Agyeman <[email protected]>

Added Paths:
-----------
    trunk/edk2/CorebootPayloadPkg/BuildAndIntegrationInstructions.txt
    trunk/edk2/CorebootPayloadPkg/CorebootPayloadPkg.dec
    trunk/edk2/CorebootPayloadPkg/CorebootPayloadPkg.fdf
    trunk/edk2/CorebootPayloadPkg/CorebootPayloadPkgIA32.dsc
    trunk/edk2/CorebootPayloadPkg/CorebootPayloadPkgX64.dsc
    trunk/edk2/CorebootPayloadPkg/FbGop/
    trunk/edk2/CorebootPayloadPkg/FbGop/ComponentName.c
    trunk/edk2/CorebootPayloadPkg/FbGop/FbGop.c
    trunk/edk2/CorebootPayloadPkg/FbGop/FbGop.h
    trunk/edk2/CorebootPayloadPkg/FbGop/FbGop.inf
    trunk/edk2/CorebootPayloadPkg/Include/
    trunk/edk2/CorebootPayloadPkg/Library/
    trunk/edk2/CorebootPayloadPkg/Library/AcpiTimerLib/
    trunk/edk2/CorebootPayloadPkg/Library/AcpiTimerLib/AcpiTimerLib.c
    trunk/edk2/CorebootPayloadPkg/Library/AcpiTimerLib/AcpiTimerLib.inf
    trunk/edk2/CorebootPayloadPkg/Library/PlatformBdsLib/
    trunk/edk2/CorebootPayloadPkg/Library/PlatformBdsLib/BdsPlatform.c
    trunk/edk2/CorebootPayloadPkg/Library/PlatformBdsLib/BdsPlatform.h
    trunk/edk2/CorebootPayloadPkg/Library/PlatformBdsLib/PlatformBdsLib.inf
    trunk/edk2/CorebootPayloadPkg/Library/PlatformBdsLib/PlatformData.c
    trunk/edk2/CorebootPayloadPkg/Library/ResetSystemLib/
    trunk/edk2/CorebootPayloadPkg/Library/ResetSystemLib/ResetSystemLib.c
    trunk/edk2/CorebootPayloadPkg/Library/ResetSystemLib/ResetSystemLib.inf
    trunk/edk2/CorebootPayloadPkg/Library/SerialPortLib/
    trunk/edk2/CorebootPayloadPkg/Library/SerialPortLib/SerialPortLib.c
    trunk/edk2/CorebootPayloadPkg/Library/SerialPortLib/SerialPortLib.inf
    trunk/edk2/CorebootPayloadPkg/SerialDxe/
    trunk/edk2/CorebootPayloadPkg/SerialDxe/SerialDxe.inf
    trunk/edk2/CorebootPayloadPkg/SerialDxe/SerialIo.c

Added: trunk/edk2/CorebootPayloadPkg/BuildAndIntegrationInstructions.txt
===================================================================
--- trunk/edk2/CorebootPayloadPkg/BuildAndIntegrationInstructions.txt           
                (rev 0)
+++ trunk/edk2/CorebootPayloadPkg/BuildAndIntegrationInstructions.txt   
2015-03-31 00:56:01 UTC (rev 17081)
@@ -0,0 +1,91 @@
+================================================================================
+Build And Integration Instructions
+2014 June 24th
+================================================================================
+
+================================================================================
+DISCLAIMER
+================================================================================
+This release note as well as the software described in it is furnished under 
license
+and may only be used or copied in accordance with the terms of the license. The
+information in this manual is furnished for informational use only, is subject 
to
+change without notice, and should not be construed as a commitment by Intel 
Corporation.
+Intel Corporation assumes no responsibility or liability for any errors or 
inaccuracies
+that may appear in this document or any software that may be provided in 
association
+with this document.
+Except as permitted by such license, no part of this document may be 
reproduced,
+stored in a retrieval system, or transmitted in any form or by any means 
without
+the express written consent of Intel Corporation.
+
+================================================================================
+                                     INDEX
+================================================================================
+A. INTRODUCTION
+B. HOW TO BUILD
+C. HOW TO INTEGRATE 
+
+================================================================================
+A. INTRODUCTION
+================================================================================
+This document provides instructions on how to build Coreboot Uefi Payload and 
+how to integrate it into coreboot firmware.
+
+================================================================================
+B. HOW TO BUILD 
+================================================================================
+1. Run the below two commands in windows command prompt window:
+   edksetup.bat
+   
+   For debug ia32 build:
+   build -a IA32 -p CorebootPayloadPkg\CorebootPayloadPkgIA32.dsc -b DEBUG -t 
<ToolChain>
+   
+   For release ia32 build:
+   build -a IA32 -p CorebootPayloadPkg\CorebootPayloadPkgIA32.dsc -b RELEASE 
-t <ToolChain>
+   
+   For debug X64 build:
+   build -a IA32 -a X64 -p CorebootPayloadPkg\CorebootPayloadPkgX64.dsc -b 
DEBUG -t <ToolChain>
+   
+   For release X64 build:
+   build -a IA32 -a X64 -p CorebootPayloadPkg\CorebootPayloadPkgX64.dsc -b 
RELEASE -t <ToolChain>
+   
+   <ToolChain> is the EDK II build environment on your host. Currently it was 
tested with VS2008x64 toolchain.
+
+   For details about EDK II build steps, refer to 
http://svn.code.sf.net/p/edk2/code/branches/UDK2014/BuildNotes2.txt
+   
+2. If build is successfully, the payload image (UEFIPAYLOAD.fd) will be 
generated inside the folder of Build\CorebootPayloadPkg.
+
+================================================================================
+C. HOW TO INTEGRATE
+================================================================================
+1. Copy the payload image (UEFIPAYLOAD.fd) into the top-level directory of 
Coreboot source tree.
+2. Run "make menuconfig" in linux console to start Coreboot configuration 
surface.
+3. In the Payload section,
+   1) Choose "An ELF executable payload" for the option of "Add a payload".
+   2) Type the path of payload image for the option of "Payload path and 
filename".
+   3) Select the option of "Use LZMA compression for payloads".
+   
+4. If the graphics console is required in Coreboot UEFI payload, running VGA 
option rom should be enabled.
+   For details:
+   1) In the Device section, select the option of "Run VGA Option ROMs".
+   2) In the VGA BIOS section, select the option of "Add a VGA BIOS Image", 
Input the path of vga bios image 
+   for the option of VGA BIOS path and filename, give the values of vendor id 
and device id for the option 
+   of  "VGA device PCI IDs".
+   3) In the Display section,
+      Select the option of "Set framebuffer graphics resolution"
+      Choose a right display mode for the option of "framebuffer graphics 
resolution".
+      Note: If the boot OS is windows, please choose the display mode 
supporting 32 bit color.
+      Select the option of "Keep VESA framebuffer"
+   
+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?",
+   choose Yes.
+   
+6. Run "make" to build the coreboot firmware image.
+
+
+  
+   
+
+            
+            
+   
+   
\ No newline at end of file

Added: trunk/edk2/CorebootPayloadPkg/CorebootPayloadPkg.dec
===================================================================
--- trunk/edk2/CorebootPayloadPkg/CorebootPayloadPkg.dec                        
        (rev 0)
+++ trunk/edk2/CorebootPayloadPkg/CorebootPayloadPkg.dec        2015-03-31 
00:56:01 UTC (rev 17081)
@@ -0,0 +1,57 @@
+## @file
+# Coreboot Payload Package
+#
+# Provides drivers and definitions to create uefi payload for coreboot. 
+#
+# Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>
+# This program and the accompanying materials are licensed and made available 
under 
+# the terms and conditions of the BSD License that accompanies this 
distribution.  
+# The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php.                              
                                            
+# 
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,        
             
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
IMPLIED.  
+#
+##
+
+[Defines]
+  DEC_SPECIFICATION              = 0x00010005
+  PACKAGE_NAME                   = CorebootPayloadPkg
+  PACKAGE_GUID                   = 58ABC905-951E-472e-8590-77BA8A50BE63
+  PACKAGE_VERSION                = 0.1
+  
+[Includes]
+  Include
+  
+[LibraryClasses]
+  
+[Guids]
+  #
+  ## Defines the token space for the Coreboot Payload Package PCDs.
+  #
+  gUEfiCorebootPayloadPkgTokenSpaceGuid  = {0x1d127ea, 0xf6f1, 0x4ef6, {0x94, 
0x15, 0x8a, 0x0, 0x0, 0x93, 0xf8, 0x9d}}  
+  
+  #
+  # Gop Temp
+  #
+  gBmpImageGuid                           = { 0x878AC2CC, 0x5343, 0x46F2, { 
0xB5, 0x63, 0x51, 0xF8, 0x9D, 0xAF, 0x56, 0xBA } }
+
+[Ppis]
+
+[Protocols]
+  #
+  # Gop Temp
+  #
+  gPlatformGOPPolicyGuid                  = { 0xec2e931b, 0x3281, 0x48a5, { 
0x81, 0x07, 0xdf, 0x8a, 0x8b, 0xed, 0x3c, 0x5d } }
+
+################################################################################
+#
+# PCD Declarations section - list of all PCDs Declared by this Package
+#                            Only this package should be providing the
+#                            declaration, other packages should not.
+#
+################################################################################
+[PcdsFixedAtBuild, PcdsPatchableInModule]
+
+[PcdsDynamic, PcdsDynamicEx]
+ 

Added: trunk/edk2/CorebootPayloadPkg/CorebootPayloadPkg.fdf
===================================================================
--- trunk/edk2/CorebootPayloadPkg/CorebootPayloadPkg.fdf                        
        (rev 0)
+++ trunk/edk2/CorebootPayloadPkg/CorebootPayloadPkg.fdf        2015-03-31 
00:56:01 UTC (rev 17081)
@@ -0,0 +1,278 @@
+## @file
+# Coreboot Payload Package
+#
+# Provides drivers and definitions to create uefi payload for coreboot. 
+#
+# Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>
+# This program and the accompanying materials are licensed and made available 
under 
+# the terms and conditions of the BSD License that accompanies this 
distribution.  
+# The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php.                              
                                            
+# 
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,        
             
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
IMPLIED.  
+#
+##
+
+################################################################################
+[FD.UefiPayload]
+BaseAddress   = 
0x800000|gUefiCorebootModulePkgTokenSpaceGuid.PcdPayloadFdMemBase
+Size          = 
0x400000|gUefiCorebootModulePkgTokenSpaceGuid.PcdPayloadFdMemSize
+ErasePolarity = 1
+BlockSize     = 0x1000
+NumBlocks     = 0x400
+
+0x00000000|0x020000
+FV = PEIFV
+
+0x00020000|0x3E0000
+FV = DXEFV
+
+################################################################################
+[FV.PEIFV]
+BlockSize          = 0x1000
+FvAlignment        = 16
+ERASE_POLARITY     = 1
+MEMORY_MAPPED      = TRUE
+STICKY_WRITE       = TRUE
+LOCK_CAP           = TRUE
+LOCK_STATUS        = TRUE
+WRITE_DISABLED_CAP = TRUE
+WRITE_ENABLED_CAP  = TRUE
+WRITE_STATUS       = TRUE
+WRITE_LOCK_CAP     = TRUE
+WRITE_LOCK_STATUS  = TRUE
+READ_DISABLED_CAP  = TRUE
+READ_ENABLED_CAP   = TRUE
+READ_STATUS        = TRUE
+READ_LOCK_CAP      = TRUE
+READ_LOCK_STATUS   = TRUE
+
+INF CorebootModulePkg/SecCore/SecCore.inf
+
+INF MdeModulePkg/Core/Pei/PeiMain.inf
+INF MdeModulePkg/Universal/PCD/Pei/Pcd.inf
+INF IntelFrameworkModulePkg/Universal/StatusCode/Pei/StatusCodePei.inf
+INF CorebootModulePkg/CbSupportPei/CbSupportPei.inf
+INF MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
+
+################################################################################
+
+[FV.DXEFV]
+BlockSize          = 0x1000
+FvAlignment        = 16
+ERASE_POLARITY     = 1
+MEMORY_MAPPED      = TRUE
+STICKY_WRITE       = TRUE
+LOCK_CAP           = TRUE
+LOCK_STATUS        = TRUE
+WRITE_DISABLED_CAP = TRUE
+WRITE_ENABLED_CAP  = TRUE
+WRITE_STATUS       = TRUE
+WRITE_LOCK_CAP     = TRUE
+WRITE_LOCK_STATUS  = TRUE
+READ_DISABLED_CAP  = TRUE
+READ_ENABLED_CAP   = TRUE
+READ_STATUS        = TRUE
+READ_LOCK_CAP      = TRUE
+READ_LOCK_STATUS   = TRUE
+
+#
+# DXE Phase modules
+#
+INF MdeModulePkg/Core/Dxe/DxeMain.inf
+INF MdeModulePkg/Universal/PCD/Dxe/Pcd.inf
+INF 
IntelFrameworkModulePkg/Universal/StatusCode/RuntimeDxe/StatusCodeRuntimeDxe.inf
+
+INF MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
+INF UefiCpuPkg/CpuDxe/CpuDxe.inf
+INF IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.inf
+INF PcAtChipsetPkg/8254TimerDxe/8254Timer.inf
+INF MdeModulePkg/Universal/Metronome/Metronome.inf
+INF MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf
+INF MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf
+INF MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
+INF 
MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf
+INF MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf  
+INF PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf 
+INF MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariableRuntimeDxe.inf
+
+INF UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf
+INF MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf
+INF MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTestDxe.inf
+INF PcAtChipsetPkg/8259InterruptControllerDxe/8259.inf 
+INF MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf
+INF MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf 
+INF MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf
+INF CorebootModulePkg/CbSupportDxe/CbSupportDxe.inf 
+
+INF MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf
+#
+# PCI Support
+#
+INF PcAtChipsetPkg/PciHostBridgeDxe/PciHostBridgeDxe.inf
+INF DuetPkg/PciBusNoEnumerationDxe/PciBusNoEnumeration.inf 
+
+#
+# ISA Support
+#
+INF CorebootPayloadPkg/SerialDxe/SerialDxe.inf
+
+#
+# Console Support
+#
+INF MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf
+INF MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf
+INF MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf
+INF MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf
+
+#
+# SCSI/ATA/IDE/DISK Support
+#
+INF MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf
+INF MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf
+INF MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf
+INF DuetPkg/SataControllerDxe/SataControllerDxe.inf  
+INF MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf
+INF MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf
+INF MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf
+INF MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf
+
+!if $(ARCH) == IA32
+INF RuleOverride = BINARY USE = IA32 FatBinPkg/EnhancedFatDxe/Fat.inf
+!else
+INF RuleOverride = BINARY USE = X64 FatBinPkg/EnhancedFatDxe/Fat.inf
+!endif
+
+#
+# Usb Support
+#
+INF MdeModulePkg/Bus/Pci/UhciDxe/UhciDxe.inf
+INF MdeModulePkg/Bus/Pci/EhciDxe/EhciDxe.inf
+INF MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf
+INF MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBusDxe.inf
+INF MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf
+INF MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf
+
+#
+# Shell
+#
+#!if $(ARCH) == IA32
+#INF  RuleOverride = BINARY USE = IA32 ShellBinPkg/UefiShell/UefiShell.inf
+#!else
+#INF  RuleOverride = BINARY USE = X64 ShellBinPkg/UefiShell/UefiShell.inf
+#!endif
+#
+!if $(ARCH) == IA32
+INF  RuleOverride = BINARY USE = IA32 EdkShellBinPkg/FullShell/FullShell.inf
+!else
+INF  RuleOverride = BINARY USE = X64 EdkShellBinPkg/FullShell/FullShell.inf
+!endif
+
+FILE FREEFORM    = PCD(gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdLogoFile) {
+  SECTION RAW = MdeModulePkg/Logo/Logo.bmp
+}
+
+#
+# Framebuffer Gop 
+#
+INF CorebootPayloadPkg/FbGop/FbGop.inf
+
+################################################################################
+#
+# Rules are use with the [FV] section's module INF type to define
+# how an FFS file is created for a given INF file. The following Rule are the 
default
+# rules for the different module type. User can add the customized rules to 
define the
+# content of the FFS file.
+#
+################################################################################
+
+[Rule.Common.SEC]
+  FILE SEC = $(NAMED_GUID) {
+    PE32     PE32   Align=32    $(INF_OUTPUT)/$(MODULE_NAME).efi
+  }
+
+[Rule.Common.PEI_CORE]
+  FILE PEI_CORE = $(NAMED_GUID) {
+    PE32     PE32   Align=32    $(INF_OUTPUT)/$(MODULE_NAME).efi
+    UI       STRING ="$(MODULE_NAME)" Optional
+    VERSION  STRING ="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
+  }
+
+[Rule.Common.PEIM]
+  FILE PEIM = $(NAMED_GUID) {
+     PEI_DEPEX PEI_DEPEX Optional        $(INF_OUTPUT)/$(MODULE_NAME).depex
+     PE32      PE32   Align=32           $(INF_OUTPUT)/$(MODULE_NAME).efi
+     UI       STRING="$(MODULE_NAME)" Optional
+     VERSION  STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
+  }
+
+[Rule.Common.DXE_CORE]
+  FILE DXE_CORE = $(NAMED_GUID) {
+    PE32     PE32           $(INF_OUTPUT)/$(MODULE_NAME).efi
+    UI       STRING="$(MODULE_NAME)" Optional
+    VERSION  STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
+  }
+
+[Rule.Common.DXE_DRIVER]
+  FILE DRIVER = $(NAMED_GUID) {
+    DXE_DEPEX    DXE_DEPEX Optional      $(INF_OUTPUT)/$(MODULE_NAME).depex
+    PE32     PE32                    $(INF_OUTPUT)/$(MODULE_NAME).efi
+    UI       STRING="$(MODULE_NAME)" Optional
+    VERSION  STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
+  }
+
+[Rule.Common.DXE_RUNTIME_DRIVER]
+  FILE DRIVER = $(NAMED_GUID) {
+    DXE_DEPEX    DXE_DEPEX Optional      $(INF_OUTPUT)/$(MODULE_NAME).depex
+    PE32     PE32                    $(INF_OUTPUT)/$(MODULE_NAME).efi
+    UI       STRING="$(MODULE_NAME)" Optional
+    VERSION  STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
+  }
+
+[Rule.Common.UEFI_DRIVER]
+  FILE DRIVER = $(NAMED_GUID) {
+    DXE_DEPEX    DXE_DEPEX Optional      $(INF_OUTPUT)/$(MODULE_NAME).depex
+    PE32     PE32                    $(INF_OUTPUT)/$(MODULE_NAME).efi
+    UI       STRING="$(MODULE_NAME)" Optional
+    VERSION  STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
+  }
+
+[Rule.Common.UEFI_DRIVER.BINARY]
+  FILE DRIVER = $(NAMED_GUID) {
+    DXE_DEPEX DXE_DEPEX Optional      |.depex
+    PE32      PE32                    |.efi
+    UI        STRING="$(MODULE_NAME)" Optional
+    VERSION   STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
+  }
+
+[Rule.Common.UEFI_APPLICATION]
+  FILE APPLICATION = $(NAMED_GUID) {
+    PE32     PE32                    $(INF_OUTPUT)/$(MODULE_NAME).efi
+    UI       STRING="$(MODULE_NAME)" Optional
+    VERSION  STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
+  }
+
+[Rule.Common.UEFI_APPLICATION.BINARY]
+  FILE APPLICATION = $(NAMED_GUID) {
+    PE32      PE32                    |.efi
+    UI        STRING="$(MODULE_NAME)" Optional
+    VERSION   STRING="$(INF_VERSION)" Optional BUILD_NUM=$(BUILD_NUMBER)
+  }
+
+[Rule.Common.USER_DEFINED.ACPITABLE]
+  FILE FREEFORM = $(NAMED_GUID) {
+    RAW ACPI               |.acpi
+    RAW ASL                |.aml
+  }
+
+[Rule.Common.USER_DEFINED.CSM]
+  FILE FREEFORM = $(NAMED_GUID) {
+    RAW BIN                |.bin
+  }
+
+[Rule.Common.SEC.RESET_VECTOR]
+  FILE RAW = $(NAMED_GUID) {
+    RAW RAW                |.raw
+  }
+

Added: trunk/edk2/CorebootPayloadPkg/CorebootPayloadPkgIA32.dsc
===================================================================
--- trunk/edk2/CorebootPayloadPkg/CorebootPayloadPkgIA32.dsc                    
        (rev 0)
+++ trunk/edk2/CorebootPayloadPkg/CorebootPayloadPkgIA32.dsc    2015-03-31 
00:56:01 UTC (rev 17081)
@@ -0,0 +1,360 @@
+## @file
+# Coreboot Payload Package
+#
+# Provides drivers and definitions to create uefi payload for coreboot. 
+#
+# Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>
+# This program and the accompanying materials are licensed and made available 
under 
+# the terms and conditions of the BSD License that accompanies this 
distribution.  
+# The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php.                              
                                            
+# 
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,        
             
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
IMPLIED.  
+#
+##
+
+################################################################################
+#
+# Defines Section - statements that will be processed to create a Makefile.
+#
+################################################################################
+[Defines]
+  PLATFORM_NAME                       = CorebootPayloadPkg
+  PLATFORM_GUID                       = F71608AB-D63D-4491-B744-A99998C8CD96
+  PLATFORM_VERSION                    = 0.1
+  DSC_SPECIFICATION                   = 0x00010005  
+  SUPPORTED_ARCHITECTURES             = IA32|X64
+  BUILD_TARGETS                       = DEBUG|RELEASE
+  SKUID_IDENTIFIER                    = DEFAULT
+  OUTPUT_DIRECTORY                    = Build/CorebootPayloadPkg
+  FLASH_DEFINITION                    = 
CorebootPayloadPkg/CorebootPayloadPkg.fdf
+  
+  DEFINE SECURE_BOOT_ENABLE      = FALSE
+  DEFINE SOURCE_DEBUG_ENABLE     = FALSE
+  
+[BuildOptions]
+  GCC:*_UNIXGCC_*_CC_FLAGS       = -DMDEPKG_NDEBUG
+  GCC:RELEASE_*_*_CC_FLAGS       = -DMDEPKG_NDEBUG
+  INTEL:RELEASE_*_*_CC_FLAGS     = /D MDEPKG_NDEBUG
+  MSFT:RELEASE_*_*_CC_FLAGS      = /D MDEPKG_NDEBUG
+
+################################################################################
+#
+# SKU Identification section - list of all SKU IDs supported by this Platform.
+#
+################################################################################
+[SkuIds]
+  0|DEFAULT
+
+################################################################################
+#
+# Library Class section - list of all Library Classes needed by this Platform.
+#
+################################################################################
+[LibraryClasses]
+  #
+  # Entry point
+  #
+  PeiCoreEntryPoint|MdePkg/Library/PeiCoreEntryPoint/PeiCoreEntryPoint.inf
+  PeimEntryPoint|MdePkg/Library/PeimEntryPoint/PeimEntryPoint.inf
+  DxeCoreEntryPoint|MdePkg/Library/DxeCoreEntryPoint/DxeCoreEntryPoint.inf
+  
UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf
+  
UefiApplicationEntryPoint|MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.inf
+
+  #
+  # Basic
+  #
+  BaseLib|MdePkg/Library/BaseLib/BaseLib.inf  
+  BaseMemoryLib|MdePkg/Library/BaseMemoryLibRepStr/BaseMemoryLibRepStr.inf
+  
SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf
+  PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf
+  CpuLib|MdePkg/Library/BaseCpuLib/BaseCpuLib.inf
+  IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf
+  PciLib|MdePkg/Library/BasePciLibCf8/BasePciLibCf8.inf
+  PciCf8Lib|MdePkg/Library/BasePciCf8Lib/BasePciCf8Lib.inf
+  PeCoffLib|MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf
+  
PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf
+  
CacheMaintenanceLib|MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf
+  
+  #
+  # UEFI & PI
+  #
+  
UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf
+  
UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf
+  UefiRuntimeLib|MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf
+  UefiLib|MdePkg/Library/UefiLib/UefiLib.inf
+  
UefiHiiServicesLib|MdeModulePkg/Library/UefiHiiServicesLib/UefiHiiServicesLib.inf
+  HiiLib|MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf
+  DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf
+  
UefiDecompressLib|MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.inf
+  
PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointerLibIdt.inf
+  PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf
+  DxeServicesLib|MdePkg/Library/DxeServicesLib/DxeServicesLib.inf
+  
DxeServicesTableLib|MdePkg/Library/DxeServicesTableLib/DxeServicesTableLib.inf
+  UefiCpuLib|UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf
+  
+  #
+  # Generic Modules
+  #
+  UefiUsbLib|MdePkg/Library/UefiUsbLib/UefiUsbLib.inf
+  UefiScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf
+  
OemHookStatusCodeLib|MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHookStatusCodeLibNull.inf
+  CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf
+  
SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.inf
+  GenericBdsLib|IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLib.inf
+  
CustomizedDisplayLib|MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.inf
+  
+  #
+  # CPU
+  #
+  MtrrLib|UefiCpuPkg/Library/MtrrLib/MtrrLib.inf
+  LocalApicLib|UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.inf  
+  
+  #
+  # Platform
+  #
+  TimerLib|CorebootPayloadPkg/Library/AcpiTimerLib/AcpiTimerLib.inf
+  ResetSystemLib|CorebootPayloadPkg/Library/ResetSystemLib/ResetSystemLib.inf
+  SerialPortLib|CorebootPayloadPkg/Library/SerialPortLib/SerialPortLib.inf
+  PlatformBdsLib|CorebootPayloadPkg/Library/PlatformBdsLib/PlatformBdsLib.inf
+  
+  #
+  # Misc
+  #
+  
DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf
+  
PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibNull.inf
+  PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
+!if $(SOURCE_DEBUG_ENABLE) == TRUE
+  
PeCoffExtraActionLib|SourceLevelDebugPkg/Library/PeCoffExtraActionLibDebug/PeCoffExtraActionLibDebug.inf
+  
DebugCommunicationLib|SourceLevelDebugPkg/Library/DebugCommunicationLibSerialPort/DebugCommunicationLibSerialPort.inf
+!else
+  
PeCoffExtraActionLib|MdePkg/Library/BasePeCoffExtraActionLibNull/BasePeCoffExtraActionLibNull.inf
+  DebugAgentLib|MdeModulePkg/Library/DebugAgentLibNull/DebugAgentLibNull.inf  
+!endif
+  CbParseLib|CorebootModulePkg/Library/CbParseLib/CbParseLib.inf
+  
DebugLib|IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebugLibReportStatusCode.inf
+
+[LibraryClasses.IA32.SEC]
+  DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf
+  PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
+  HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf
+  
MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf
+  DebugAgentLib|MdeModulePkg/Library/DebugAgentLibNull/DebugAgentLibNull.inf
+  
ReportStatusCodeLib|MdePkg/Library/BaseReportStatusCodeLibNull/BaseReportStatusCodeLibNull.inf
+
+[LibraryClasses.IA32.PEI_CORE, LibraryClasses.IA32.PEIM]
+  PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf
+  HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf
+  
MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf
+  
ReportStatusCodeLib|MdeModulePkg/Library/PeiReportStatusCodeLib/PeiReportStatusCodeLib.inf
+  
ExtractGuidedSectionLib|MdePkg/Library/PeiExtractGuidedSectionLib/PeiExtractGuidedSectionLib.inf
+!if $(SOURCE_DEBUG_ENABLE)
+  DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgentLib.inf
+!endif
+
+[LibraryClasses.common.DXE_CORE]
+  PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
+  HobLib|MdePkg/Library/DxeCoreHobLib/DxeCoreHobLib.inf
+  
MemoryAllocationLib|MdeModulePkg/Library/DxeCoreMemoryAllocationLib/DxeCoreMemoryAllocationLib.inf
+  
ExtractGuidedSectionLib|MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.inf
+  
ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf
  
+!if $(SOURCE_DEBUG_ENABLE)
+  DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgentLib.inf
+!endif 
+  
CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf
+
+[LibraryClasses.common.DXE_DRIVER]  
+  PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
+  HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
+  
MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
+  
ExtractGuidedSectionLib|MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.inf
+  
ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf
+  
CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf
+  
+[LibraryClasses.common.DXE_RUNTIME_DRIVER]
+  PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
+  HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
+  
MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
+  
ReportStatusCodeLib|MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/RuntimeDxeReportStatusCodeLib.inf
+  
+[LibraryClasses.common.UEFI_DRIVER,LibraryClasses.common.UEFI_APPLICATION]
+  PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
+  
MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
+  
ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf
+  HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf  
+  
+################################################################################
+#
+# Pcd Section - list of all EDK II PCD Entries defined by this Platform.
+#
+################################################################################
+[PcdsFeatureFlag]
+  gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseSerial|TRUE
+  gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseMemory|FALSE
+  gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode|FALSE
+  gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE
+  gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|FALSE
+
+[PcdsFixedAtBuild]
+  gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask|0x7
+  gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x8000004F
+!if $(SOURCE_DEBUG_ENABLE)
+  gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x17
+!else
+  gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x2F
+!endif
+  gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize|0x10000
+  gEfiMdeModulePkgTokenSpaceGuid.PcdMaxHardwareErrorVariableSize|0x8000
+  gEfiMdeModulePkgTokenSpaceGuid.PcdVariableStoreSize|0x10000
+  
+  gEfiMdeModulePkgTokenSpaceGuid.PcdVpdBaseAddress|0x0  
+
+!if $(SOURCE_DEBUG_ENABLE)
+  gEfiSourceLevelDebugPkgTokenSpaceGuid.PcdDebugLoadImageMethod|0x2
+!endif
+
+################################################################################
+#
+# Pcd Dynamic Section - list of all EDK II PCD Entries defined by this Platform
+#
+################################################################################
+
+[PcdsDynamicDefault]
+  gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved|0
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64|0
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase|0
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase|0
+
+
+################################################################################
+#
+# Components Section - list of all EDK II Modules needed by this Platform.
+#
+################################################################################
+[Components.IA32]
+  #
+  # SEC Core
+  #
+  CorebootModulePkg/SecCore/SecCore.inf
+  
+  #
+  # PEI Core
+  #
+  MdeModulePkg/Core/Pei/PeiMain.inf
+  
+  #
+  # PEIM
+  #
+  MdeModulePkg/Universal/PCD/Pei/Pcd.inf {
+    <LibraryClasses>
+      PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
+  }
+  IntelFrameworkModulePkg/Universal/StatusCode/Pei/StatusCodePei.inf
+  
+  CorebootModulePkg/CbSupportPei/CbSupportPei.inf 
+  MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
+
+[Components.IA32]
+  #
+  # DXE Core
+  #
+  MdeModulePkg/Core/Dxe/DxeMain.inf {
+    <LibraryClasses>
+      
NULL|IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf
+  }
+  
+  #
+  # Components that produce the architectural protocols
+  #
+  MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
+  UefiCpuPkg/CpuDxe/CpuDxe.inf
+  IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.inf
+  PcAtChipsetPkg/8254TimerDxe/8254Timer.inf
+  MdeModulePkg/Universal/Metronome/Metronome.inf
+  MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf
+  MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf
+  MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
+  
MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf
+  MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf  
+  PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf 
+  MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariableRuntimeDxe.inf
+  
+  #
+  # Following are the DXE drivers 
+  #
+  MdeModulePkg/Universal/PCD/Dxe/Pcd.inf {
+    <LibraryClasses>
+      PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
+  }
+  
+  
IntelFrameworkModulePkg/Universal/StatusCode/RuntimeDxe/StatusCodeRuntimeDxe.inf
+  UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf
+  MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf
+  MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTestDxe.inf
+  PcAtChipsetPkg/8259InterruptControllerDxe/8259.inf 
+  MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf
+  MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf 
+  MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf
+  
+  CorebootModulePkg/CbSupportDxe/CbSupportDxe.inf 
+  
+  #
+  # SMBIOS Support
+  #
+  MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf
+  
+  #
+  # ACPI Support
+  #
+  MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf  
+  
+  #
+  # PCI Support
+  #
+  PcAtChipsetPkg/PciHostBridgeDxe/PciHostBridgeDxe.inf
+  DuetPkg/PciBusNoEnumerationDxe/PciBusNoEnumeration.inf 
+  
+  #
+  # SCSI/ATA/IDE/DISK Support
+  #
+  MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf
+  MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf
+  MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf
+  DuetPkg/SataControllerDxe/SataControllerDxe.inf  
+  MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf
+  MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf 
+  MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf
+  MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf
+  
+  #
+  # Usb Support
+  #
+  MdeModulePkg/Bus/Pci/UhciDxe/UhciDxe.inf
+  MdeModulePkg/Bus/Pci/EhciDxe/EhciDxe.inf
+  MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf
+  MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBusDxe.inf
+  MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf
+  MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf
+  
+  #
+  # ISA Support
+  #
+  CorebootPayloadPkg/SerialDxe/SerialDxe.inf
+  
+  #
+  # Console Support
+  #
+  MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf
+  MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf
+  MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf
+  MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf
+  
+  
+  #
+  # Framebuffer Gop 
+  #
+  CorebootPayloadPkg/FbGop/FbGop.inf
+  
+     
+ 
\ No newline at end of file

Added: trunk/edk2/CorebootPayloadPkg/CorebootPayloadPkgX64.dsc
===================================================================
--- trunk/edk2/CorebootPayloadPkg/CorebootPayloadPkgX64.dsc                     
        (rev 0)
+++ trunk/edk2/CorebootPayloadPkg/CorebootPayloadPkgX64.dsc     2015-03-31 
00:56:01 UTC (rev 17081)
@@ -0,0 +1,361 @@
+## @file
+# Coreboot Payload Package
+#
+# Provides drivers and definitions to create uefi payload for coreboot. 
+#
+# Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>
+# This program and the accompanying materials are licensed and made available 
under 
+# the terms and conditions of the BSD License that accompanies this 
distribution.  
+# The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php.                              
                                            
+# 
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,        
             
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
IMPLIED.  
+#
+##
+
+################################################################################
+#
+# Defines Section - statements that will be processed to create a Makefile.
+#
+################################################################################
+[Defines]
+  PLATFORM_NAME                       = CorebootPayloadPkg
+  PLATFORM_GUID                       = F71608AB-D63D-4491-B744-A99998C8CD96
+  PLATFORM_VERSION                    = 0.1
+  DSC_SPECIFICATION                   = 0x00010005  
+  SUPPORTED_ARCHITECTURES             = IA32|X64
+  BUILD_TARGETS                       = DEBUG|RELEASE
+  SKUID_IDENTIFIER                    = DEFAULT
+  OUTPUT_DIRECTORY                    = Build/CorebootPayloadPkg
+  FLASH_DEFINITION                    = 
CorebootPayloadPkg/CorebootPayloadPkg.fdf
+  
+  DEFINE SECURE_BOOT_ENABLE      = FALSE
+  DEFINE SOURCE_DEBUG_ENABLE     = FALSE
+  
+[BuildOptions]
+  GCC:*_UNIXGCC_*_CC_FLAGS       = -DMDEPKG_NDEBUG
+  GCC:RELEASE_*_*_CC_FLAGS       = -DMDEPKG_NDEBUG
+  INTEL:RELEASE_*_*_CC_FLAGS     = /D MDEPKG_NDEBUG
+  MSFT:RELEASE_*_*_CC_FLAGS      = /D MDEPKG_NDEBUG
+
+################################################################################
+#
+# SKU Identification section - list of all SKU IDs supported by this Platform.
+#
+################################################################################
+[SkuIds]
+  0|DEFAULT
+
+################################################################################
+#
+# Library Class section - list of all Library Classes needed by this Platform.
+#
+################################################################################
+[LibraryClasses]
+  #
+  # Entry point
+  #
+  PeiCoreEntryPoint|MdePkg/Library/PeiCoreEntryPoint/PeiCoreEntryPoint.inf
+  PeimEntryPoint|MdePkg/Library/PeimEntryPoint/PeimEntryPoint.inf
+  DxeCoreEntryPoint|MdePkg/Library/DxeCoreEntryPoint/DxeCoreEntryPoint.inf
+  
UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf
+  
UefiApplicationEntryPoint|MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.inf
+
+  #
+  # Basic
+  #
+  BaseLib|MdePkg/Library/BaseLib/BaseLib.inf  
+  BaseMemoryLib|MdePkg/Library/BaseMemoryLibRepStr/BaseMemoryLibRepStr.inf
+  
SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf
+  PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf
+  CpuLib|MdePkg/Library/BaseCpuLib/BaseCpuLib.inf
+  IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf
+  PciLib|MdePkg/Library/BasePciLibCf8/BasePciLibCf8.inf
+  PciCf8Lib|MdePkg/Library/BasePciCf8Lib/BasePciCf8Lib.inf
+  PeCoffLib|MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf
+  
PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf
+  
CacheMaintenanceLib|MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf
+  
+  #
+  # UEFI & PI
+  #
+  
UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf
+  
UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf
+  UefiRuntimeLib|MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf
+  UefiLib|MdePkg/Library/UefiLib/UefiLib.inf
+  
UefiHiiServicesLib|MdeModulePkg/Library/UefiHiiServicesLib/UefiHiiServicesLib.inf
+  HiiLib|MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf
+  DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf
+  
UefiDecompressLib|MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.inf
+  
PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointerLibIdt.inf
+  PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf
+  DxeServicesLib|MdePkg/Library/DxeServicesLib/DxeServicesLib.inf
+  
DxeServicesTableLib|MdePkg/Library/DxeServicesTableLib/DxeServicesTableLib.inf
+  UefiCpuLib|UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf
+  
+  #
+  # Generic Modules
+  #
+  UefiUsbLib|MdePkg/Library/UefiUsbLib/UefiUsbLib.inf
+  UefiScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf
+  
OemHookStatusCodeLib|MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHookStatusCodeLibNull.inf
+  CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf
+  
SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.inf
+  GenericBdsLib|IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLib.inf
+  
CustomizedDisplayLib|MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.inf
+  
+  #
+  # CPU
+  #
+  MtrrLib|UefiCpuPkg/Library/MtrrLib/MtrrLib.inf
+  LocalApicLib|UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.inf  
+  
+  #
+  # Platform
+  #
+  TimerLib|CorebootPayloadPkg/Library/AcpiTimerLib/AcpiTimerLib.inf
+  ResetSystemLib|CorebootPayloadPkg/Library/ResetSystemLib/ResetSystemLib.inf
+  SerialPortLib|CorebootPayloadPkg/Library/SerialPortLib/SerialPortLib.inf
+  PlatformBdsLib|CorebootPayloadPkg/Library/PlatformBdsLib/PlatformBdsLib.inf
+  
+  #
+  # Misc
+  #
+  
DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf
+  
PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibNull.inf
+  PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
+!if $(SOURCE_DEBUG_ENABLE) == TRUE
+  
PeCoffExtraActionLib|SourceLevelDebugPkg/Library/PeCoffExtraActionLibDebug/PeCoffExtraActionLibDebug.inf
+  
DebugCommunicationLib|SourceLevelDebugPkg/Library/DebugCommunicationLibSerialPort/DebugCommunicationLibSerialPort.inf
+!else
+  
PeCoffExtraActionLib|MdePkg/Library/BasePeCoffExtraActionLibNull/BasePeCoffExtraActionLibNull.inf
+  DebugAgentLib|MdeModulePkg/Library/DebugAgentLibNull/DebugAgentLibNull.inf  
+!endif
+  CbParseLib|CorebootModulePkg/Library/CbParseLib/CbParseLib.inf
+  
DebugLib|IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/PeiDxeDebugLibReportStatusCode.inf
+  LockBoxLib|MdeModulePkg/Library/LockBoxNullLib/LockBoxNullLib.inf
+
+[LibraryClasses.IA32.SEC]
+  DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf
+  PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
+  HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf
+  
MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf
+  DebugAgentLib|MdeModulePkg/Library/DebugAgentLibNull/DebugAgentLibNull.inf
+  
ReportStatusCodeLib|MdePkg/Library/BaseReportStatusCodeLibNull/BaseReportStatusCodeLibNull.inf
+
+[LibraryClasses.IA32.PEI_CORE, LibraryClasses.IA32.PEIM]
+  PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf
+  HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf
+  
MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf
+  
ReportStatusCodeLib|MdeModulePkg/Library/PeiReportStatusCodeLib/PeiReportStatusCodeLib.inf
+  
ExtractGuidedSectionLib|MdePkg/Library/PeiExtractGuidedSectionLib/PeiExtractGuidedSectionLib.inf
+!if $(SOURCE_DEBUG_ENABLE)
+  DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgentLib.inf
+!endif
+
+[LibraryClasses.common.DXE_CORE]
+  PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
+  HobLib|MdePkg/Library/DxeCoreHobLib/DxeCoreHobLib.inf
+  
MemoryAllocationLib|MdeModulePkg/Library/DxeCoreMemoryAllocationLib/DxeCoreMemoryAllocationLib.inf
+  
ExtractGuidedSectionLib|MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.inf
+  
ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf
  
+!if $(SOURCE_DEBUG_ENABLE)
+  DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgentLib.inf
+!endif 
+  
CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf
+
+[LibraryClasses.common.DXE_DRIVER]  
+  PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
+  HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
+  
MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
+  
ExtractGuidedSectionLib|MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.inf
+  
ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf
+  
CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf
+  
+[LibraryClasses.common.DXE_RUNTIME_DRIVER]
+  PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
+  HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
+  
MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
+  
ReportStatusCodeLib|MdeModulePkg/Library/RuntimeDxeReportStatusCodeLib/RuntimeDxeReportStatusCodeLib.inf
+  
+[LibraryClasses.common.UEFI_DRIVER,LibraryClasses.common.UEFI_APPLICATION]
+  PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
+  
MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
+  
ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf
+  HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf  
+  
+################################################################################
+#
+# Pcd Section - list of all EDK II PCD Entries defined by this Platform.
+#
+################################################################################
+[PcdsFeatureFlag]
+  gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseSerial|TRUE
+  gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseMemory|FALSE
+  gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode|TRUE
+  gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE
+  gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|FALSE
+
+[PcdsFixedAtBuild]
+  gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask|0x7
+  gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x8000004F
+!if $(SOURCE_DEBUG_ENABLE)
+  gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x17
+!else
+  gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x2F
+!endif
+  gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize|0x10000
+  gEfiMdeModulePkgTokenSpaceGuid.PcdMaxHardwareErrorVariableSize|0x8000
+  gEfiMdeModulePkgTokenSpaceGuid.PcdVariableStoreSize|0x10000
+  
+  gEfiMdeModulePkgTokenSpaceGuid.PcdVpdBaseAddress|0x0  
+
+!if $(SOURCE_DEBUG_ENABLE)
+  gEfiSourceLevelDebugPkgTokenSpaceGuid.PcdDebugLoadImageMethod|0x2
+!endif
+
+################################################################################
+#
+# Pcd Dynamic Section - list of all EDK II PCD Entries defined by this Platform
+#
+################################################################################
+
+[PcdsDynamicDefault]
+  gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved|0
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64|0
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase|0
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase|0
+
+
+################################################################################
+#
+# Components Section - list of all EDK II Modules needed by this Platform.
+#
+################################################################################
+[Components.IA32]
+  #
+  # SEC Core
+  #
+  CorebootModulePkg/SecCore/SecCore.inf
+  
+  #
+  # PEI Core
+  #
+  MdeModulePkg/Core/Pei/PeiMain.inf
+  
+  #
+  # PEIM
+  #
+  MdeModulePkg/Universal/PCD/Pei/Pcd.inf {
+    <LibraryClasses>
+      PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
+  }
+  IntelFrameworkModulePkg/Universal/StatusCode/Pei/StatusCodePei.inf
+  
+  CorebootModulePkg/CbSupportPei/CbSupportPei.inf 
+  MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
+
+[Components.X64]
+  #
+  # DXE Core
+  #
+  MdeModulePkg/Core/Dxe/DxeMain.inf {
+    <LibraryClasses>
+      
NULL|IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf
+  }
+  
+  #
+  # Components that produce the architectural protocols
+  #
+  MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
+  UefiCpuPkg/CpuDxe/CpuDxe.inf
+  IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.inf
+  PcAtChipsetPkg/8254TimerDxe/8254Timer.inf
+  MdeModulePkg/Universal/Metronome/Metronome.inf
+  MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf
+  MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf
+  MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
+  
MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf
+  MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf  
+  PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf 
+  MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariableRuntimeDxe.inf
+  
+  #
+  # Following are the DXE drivers 
+  #
+  MdeModulePkg/Universal/PCD/Dxe/Pcd.inf {
+    <LibraryClasses>
+      PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
+  }
+  
+  
IntelFrameworkModulePkg/Universal/StatusCode/RuntimeDxe/StatusCodeRuntimeDxe.inf
+  UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf
+  MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf
+  MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTestDxe.inf
+  PcAtChipsetPkg/8259InterruptControllerDxe/8259.inf 
+  MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf
+  MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf 
+  MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf
+  
+  CorebootModulePkg/CbSupportDxe/CbSupportDxe.inf 
+  
+  #
+  # SMBIOS Support
+  #
+  MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf
+  
+  #
+  # ACPI Support
+  #
+  MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf  
+  
+  #
+  # PCI Support
+  #
+  PcAtChipsetPkg/PciHostBridgeDxe/PciHostBridgeDxe.inf
+  DuetPkg/PciBusNoEnumerationDxe/PciBusNoEnumeration.inf 
+  
+  #
+  # SCSI/ATA/IDE/DISK Support
+  #
+  MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf
+  MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf
+  MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf
+  DuetPkg/SataControllerDxe/SataControllerDxe.inf  
+  MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf
+  MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf 
+  MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf
+  MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf
+  
+  #
+  # Usb Support
+  #
+  MdeModulePkg/Bus/Pci/UhciDxe/UhciDxe.inf
+  MdeModulePkg/Bus/Pci/EhciDxe/EhciDxe.inf
+  MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf
+  MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBusDxe.inf
+  MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf
+  MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf
+  
+  #
+  # ISA Support
+  #
+  CorebootPayloadPkg/SerialDxe/SerialDxe.inf
+  
+  #
+  # Console Support
+  #
+  MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf
+  MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf
+  MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf
+  MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf
+  
+  
+  #
+  # Framebuffer Gop 
+  #
+  CorebootPayloadPkg/FbGop/FbGop.inf
+  
+     
+ 
\ No newline at end of file

Added: trunk/edk2/CorebootPayloadPkg/FbGop/ComponentName.c
===================================================================
--- trunk/edk2/CorebootPayloadPkg/FbGop/ComponentName.c                         
(rev 0)
+++ trunk/edk2/CorebootPayloadPkg/FbGop/ComponentName.c 2015-03-31 00:56:01 UTC 
(rev 17081)
@@ -0,0 +1,313 @@
+/** @file
+
+Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
+
+This program and the accompanying materials
+are licensed and made available under the terms and conditions
+of the BSD License which accompanies this distribution.  The
+full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include "FbGop.h"
+
+//
+// EFI Component Name Functions
+//
+/**
+  Retrieves a Unicode string that is the user readable name of the driver.
+
+  This function retrieves the user readable name of a driver in the form of a
+  Unicode string. If the driver specified by This has a user readable name in
+  the language specified by Language, then a pointer to the driver name is
+  returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
+  by This does not support the language specified by Language,
+  then EFI_UNSUPPORTED is returned.
+
+  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL 
or
+                                EFI_COMPONENT_NAME_PROTOCOL instance.
+
+  @param  Language[in]          A pointer to a Null-terminated ASCII string
+                                array indicating the language. This is the
+                                language of the driver name that the caller is
+                                requesting, and it must match one of the
+                                languages specified in SupportedLanguages. The
+                                number of languages supported by a driver is up
+                                to the driver writer. Language is specified
+                                in RFC 4646 or ISO 639-2 language code format.
+
+  @param  DriverName[out]       A pointer to the Unicode string to return.
+                                This Unicode string is the name of the
+                                driver specified by This in the language
+                                specified by Language.
+
+  @retval EFI_SUCCESS           The Unicode string for the Driver specified by
+                                This and the language specified by Language was
+                                returned in DriverName.
+
+  @retval EFI_INVALID_PARAMETER Language is NULL.
+
+  @retval EFI_INVALID_PARAMETER DriverName is NULL.
+
+  @retval EFI_UNSUPPORTED       The driver specified by This does not support
+                                the language specified by Language.
+
+**/
+EFI_STATUS
+EFIAPI
+FbGopComponentNameGetDriverName (
+  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,
+  IN  CHAR8                        *Language,
+  OUT CHAR16                       **DriverName
+  );
+
+
+/**
+  Retrieves a Unicode string that is the user readable name of the controller
+  that is being managed by a driver.
+
+  This function retrieves the user readable name of the controller specified by
+  ControllerHandle and ChildHandle in the form of a Unicode string. If the
+  driver specified by This has a user readable name in the language specified 
by
+  Language, then a pointer to the controller name is returned in 
ControllerName,
+  and EFI_SUCCESS is returned.  If the driver specified by This is not 
currently
+  managing the controller specified by ControllerHandle and ChildHandle,
+  then EFI_UNSUPPORTED is returned.  If the driver specified by This does not
+  support the language specified by Language, then EFI_UNSUPPORTED is returned.
+
+  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL 
or
+                                EFI_COMPONENT_NAME_PROTOCOL instance.
+
+  @param  ControllerHandle[in]  The handle of a controller that the driver
+                                specified by This is managing.  This handle
+                                specifies the controller whose name is to be
+                                returned.
+
+  @param  ChildHandle[in]       The handle of the child controller to retrieve
+                                the name of.  This is an optional parameter 
that
+                                may be NULL.  It will be NULL for device
+                                drivers.  It will also be NULL for a bus 
drivers
+                                that wish to retrieve the name of the bus
+                                controller.  It will not be NULL for a bus
+                                driver that wishes to retrieve the name of a
+                                child controller.
+
+  @param  Language[in]          A pointer to a Null-terminated ASCII string
+                                array indicating the language.  This is the
+                                language of the driver name that the caller is
+                                requesting, and it must match one of the
+                                languages specified in SupportedLanguages. The
+                                number of languages supported by a driver is up
+                                to the driver writer. Language is specified in
+                                RFC 4646 or ISO 639-2 language code format.
+
+  @param  ControllerName[out]   A pointer to the Unicode string to return.
+                                This Unicode string is the name of the
+                                controller specified by ControllerHandle and
+                                ChildHandle in the language specified by
+                                Language from the point of view of the driver
+                                specified by This.
+
+  @retval EFI_SUCCESS           The Unicode string for the user readable name 
in
+                                the language specified by Language for the
+                                driver specified by This was returned in
+                                DriverName.
+
+  @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
+
+  @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
+                                EFI_HANDLE.
+
+  @retval EFI_INVALID_PARAMETER Language is NULL.
+
+  @retval EFI_INVALID_PARAMETER ControllerName is NULL.
+
+  @retval EFI_UNSUPPORTED       The driver specified by This is not currently
+                                managing the controller specified by
+                                ControllerHandle and ChildHandle.
+
+  @retval EFI_UNSUPPORTED       The driver specified by This does not support
+                                the language specified by Language.
+
+**/
+EFI_STATUS
+EFIAPI
+FbGopComponentNameGetControllerName (
+  IN  EFI_COMPONENT_NAME_PROTOCOL                     *This,
+  IN  EFI_HANDLE                                      ControllerHandle,
+  IN  EFI_HANDLE                                      ChildHandle        
OPTIONAL,
+  IN  CHAR8                                           *Language,
+  OUT CHAR16                                          **ControllerName
+  );
+
+
+//
+// EFI Component Name Protocol
+//
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL  gFbGopComponentName 
= {
+  FbGopComponentNameGetDriverName,
+  FbGopComponentNameGetControllerName,
+  "eng"
+};
+
+//
+// EFI Component Name 2 Protocol
+//
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL 
gFbGopComponentName2 = {
+  (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) FbGopComponentNameGetDriverName,
+  (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) 
FbGopComponentNameGetControllerName,
+  "en"
+};
+
+
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mFbGopDriverNameTable[] 
= {
+  {
+    "eng;en",
+    L"FB GOP Video Driver"
+  },
+  {
+    NULL,
+    NULL
+  }
+};
+
+/**
+  Retrieves a Unicode string that is the user readable name of the driver.
+
+  This function retrieves the user readable name of a driver in the form of a
+  Unicode string. If the driver specified by This has a user readable name in
+  the language specified by Language, then a pointer to the driver name is
+  returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
+  by This does not support the language specified by Language,
+  then EFI_UNSUPPORTED is returned.
+
+  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL 
or
+                                EFI_COMPONENT_NAME_PROTOCOL instance.
+
+  @param  Language[in]          A pointer to a Null-terminated ASCII string
+                                array indicating the language. This is the
+                                language of the driver name that the caller is
+                                requesting, and it must match one of the
+                                languages specified in SupportedLanguages. The
+                                number of languages supported by a driver is up
+                                to the driver writer. Language is specified
+                                in RFC 4646 or ISO 639-2 language code format.
+
+  @param  DriverName[out]       A pointer to the Unicode string to return.
+                                This Unicode string is the name of the
+                                driver specified by This in the language
+                                specified by Language.
+
+  @retval EFI_SUCCESS           The Unicode string for the Driver specified by
+                                This and the language specified by Language was
+                                returned in DriverName.
+
+  @retval EFI_INVALID_PARAMETER Language is NULL.
+
+  @retval EFI_INVALID_PARAMETER DriverName is NULL.
+
+  @retval EFI_UNSUPPORTED       The driver specified by This does not support
+                                the language specified by Language.
+
+**/
+EFI_STATUS
+EFIAPI
+FbGopComponentNameGetDriverName (
+  IN  EFI_COMPONENT_NAME_PROTOCOL  *This,
+  IN  CHAR8                        *Language,
+  OUT CHAR16                       **DriverName
+  )
+{
+  return LookupUnicodeString2 (
+           Language,
+           This->SupportedLanguages,
+           mFbGopDriverNameTable,
+           DriverName,
+           (BOOLEAN)(This == &gFbGopComponentName)
+           );
+}
+
+/**
+  Retrieves a Unicode string that is the user readable name of the controller
+  that is being managed by a driver.
+
+  This function retrieves the user readable name of the controller specified by
+  ControllerHandle and ChildHandle in the form of a Unicode string. If the
+  driver specified by This has a user readable name in the language specified 
by
+  Language, then a pointer to the controller name is returned in 
ControllerName,
+  and EFI_SUCCESS is returned.  If the driver specified by This is not 
currently
+  managing the controller specified by ControllerHandle and ChildHandle,
+  then EFI_UNSUPPORTED is returned.  If the driver specified by This does not
+  support the language specified by Language, then EFI_UNSUPPORTED is returned.
+
+  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL 
or
+                                EFI_COMPONENT_NAME_PROTOCOL instance.
+
+  @param  ControllerHandle[in]  The handle of a controller that the driver
+                                specified by This is managing.  This handle
+                                specifies the controller whose name is to be
+                                returned.
+
+  @param  ChildHandle[in]       The handle of the child controller to retrieve
+                                the name of.  This is an optional parameter 
that
+                                may be NULL.  It will be NULL for device
+                                drivers.  It will also be NULL for a bus 
drivers
+                                that wish to retrieve the name of the bus
+                                controller.  It will not be NULL for a bus
+                                driver that wishes to retrieve the name of a
+                                child controller.
+
+  @param  Language[in]          A pointer to a Null-terminated ASCII string
+                                array indicating the language.  This is the
+                                language of the driver name that the caller is
+                                requesting, and it must match one of the
+                                languages specified in SupportedLanguages. The
+                                number of languages supported by a driver is up
+                                to the driver writer. Language is specified in
+                                RFC 4646 or ISO 639-2 language code format.
+
+  @param  ControllerName[out]   A pointer to the Unicode string to return.
+                                This Unicode string is the name of the
+                                controller specified by ControllerHandle and
+                                ChildHandle in the language specified by
+                                Language from the point of view of the driver
+                                specified by This.
+
+  @retval EFI_SUCCESS           The Unicode string for the user readable name 
in
+                                the language specified by Language for the
+                                driver specified by This was returned in
+                                DriverName.
+
+  @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
+
+  @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
+                                EFI_HANDLE.
+
+  @retval EFI_INVALID_PARAMETER Language is NULL.
+
+  @retval EFI_INVALID_PARAMETER ControllerName is NULL.
+
+  @retval EFI_UNSUPPORTED       The driver specified by This is not currently
+                                managing the controller specified by
+                                ControllerHandle and ChildHandle.
+
+  @retval EFI_UNSUPPORTED       The driver specified by This does not support
+                                the language specified by Language.
+
+**/
+EFI_STATUS
+EFIAPI
+FbGopComponentNameGetControllerName (
+  IN  EFI_COMPONENT_NAME_PROTOCOL                     *This,
+  IN  EFI_HANDLE                                      ControllerHandle,
+  IN  EFI_HANDLE                                      ChildHandle        
OPTIONAL,
+  IN  CHAR8                                           *Language,
+  OUT CHAR16                                          **ControllerName
+  )
+{
+  return EFI_UNSUPPORTED;
+}

Added: trunk/edk2/CorebootPayloadPkg/FbGop/FbGop.c
===================================================================
--- trunk/edk2/CorebootPayloadPkg/FbGop/FbGop.c                         (rev 0)
+++ trunk/edk2/CorebootPayloadPkg/FbGop/FbGop.c 2015-03-31 00:56:01 UTC (rev 
17081)
@@ -0,0 +1,1532 @@
+/** @file
+  ConsoleOut Routines that speak VGA.
+
+Copyright (c) 2007 - 2013, Intel Corporation. All rights reserved.<BR>
+
+This program and the accompanying materials
+are licensed and made available under the terms and conditions
+of the BSD License which accompanies this distribution.  The
+full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include "FbGop.h"
+
+EFI_PIXEL_BITMASK  mPixelBitMask = {0x0000FF, 0x00FF00, 0xFF0000, 0x000000};
+
+//
+// Save controller attributes during first start
+//
+UINT64                         mOriginalPciAttributes;
+BOOLEAN                        mPciAttributesSaved = FALSE;
+
+
+//
+// EFI Driver Binding Protocol Instance
+//
+EFI_DRIVER_BINDING_PROTOCOL gFbGopDriverBinding = {
+  FbGopDriverBindingSupported,
+  FbGopDriverBindingStart,
+  FbGopDriverBindingStop,
+  0x3,
+  NULL,
+  NULL
+};
+
+//
+// Native resolution in EDID DetailedTiming[0]
+//
+UINT32    mNativeModeHorizontal;
+UINT32    mNativeModeVertical;
+
+/**
+  Supported.
+
+  @param  This                   Pointer to driver binding protocol
+  @param  Controller             Controller handle to connect
+  @param  RemainingDevicePath    A pointer to the remaining portion of a device
+                                 path
+
+  @retval EFI_STATUS             EFI_SUCCESS:This controller can be managed by 
this
+                                 driver, Otherwise, this controller cannot be
+                                 managed by this driver
+
+**/
+EFI_STATUS
+EFIAPI
+FbGopDriverBindingSupported (
+  IN EFI_DRIVER_BINDING_PROTOCOL  *This,
+  IN EFI_HANDLE                   Controller,
+  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath
+  )
+{
+  EFI_STATUS                Status;
+  EFI_PCI_IO_PROTOCOL       *PciIo;
+  PCI_TYPE00                Pci;
+  EFI_DEV_PATH              *Node;
+
+  //
+  // Open the IO Abstraction(s) needed to perform the supported test
+  //
+  Status = gBS->OpenProtocol (
+                  Controller,
+                  &gEfiPciIoProtocolGuid,
+                  (VOID **) &PciIo,
+                  This->DriverBindingHandle,
+                  Controller,
+                  EFI_OPEN_PROTOCOL_BY_DRIVER
+                  );
+  if (EFI_ERROR (Status)) {
+    return Status;
+  }
+
+  //
+  // See if this is a PCI Graphics Controller by looking at the Command 
register and
+  // Class Code Register
+  //
+  Status = PciIo->Pci.Read (
+                        PciIo,
+                        EfiPciIoWidthUint32,
+                        0,
+                        sizeof (Pci) / sizeof (UINT32),
+                        &Pci
+                        );
+  if (EFI_ERROR (Status)) {
+    Status = EFI_UNSUPPORTED;
+    goto Done;
+  }
+
+  Status = EFI_UNSUPPORTED;
+  if (Pci.Hdr.ClassCode[2] == 0x03 || (Pci.Hdr.ClassCode[2] == 0x00 && 
Pci.Hdr.ClassCode[1] == 0x01)) {
+
+    Status = EFI_SUCCESS;
+    //
+    // If this is a graphics controller,
+    // go further check RemainingDevicePath validation
+    //
+    if (RemainingDevicePath != NULL) {
+      Node = (EFI_DEV_PATH *) RemainingDevicePath;
+      //
+      // Check if RemainingDevicePath is the End of Device Path Node, 
+      // if yes, return EFI_SUCCESS
+      //
+      if (!IsDevicePathEnd (Node)) {
+        //
+        // If RemainingDevicePath isn't the End of Device Path Node,
+        // check its validation
+        //
+        if (Node->DevPath.Type != ACPI_DEVICE_PATH ||
+            Node->DevPath.SubType != ACPI_ADR_DP ||
+            DevicePathNodeLength(&Node->DevPath) < 
sizeof(ACPI_ADR_DEVICE_PATH)) {
+          Status = EFI_UNSUPPORTED;
+        }
+      }
+    }
+  }
+
+Done:
+  gBS->CloseProtocol (
+         Controller,
+         &gEfiPciIoProtocolGuid,
+         This->DriverBindingHandle,
+         Controller
+         );
+
+  return Status;
+}
+
+
+/**
+  Install Graphics Output Protocol onto VGA device handles.
+
+  @param  This                   Pointer to driver binding protocol
+  @param  Controller             Controller handle to connect
+  @param  RemainingDevicePath    A pointer to the remaining portion of a device
+                                 path
+
+  @return EFI_STATUS
+
+**/
+EFI_STATUS
+EFIAPI
+FbGopDriverBindingStart (
+  IN EFI_DRIVER_BINDING_PROTOCOL  *This,
+  IN EFI_HANDLE                   Controller,
+  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath
+  )
+{
+  EFI_STATUS                Status;
+  EFI_DEVICE_PATH_PROTOCOL  *ParentDevicePath;
+  EFI_PCI_IO_PROTOCOL       *PciIo;  
+  UINT64                    Supports;
+
+  DEBUG ((EFI_D_INFO, "GOP START\n"));
+  
+  //
+  // Initialize local variables
+  //
+  PciIo            = NULL;
+  ParentDevicePath = NULL;
+
+  //
+  // Prepare for status code
+  //
+  Status = gBS->HandleProtocol (
+                  Controller,
+                  &gEfiDevicePathProtocolGuid,
+                  (VOID **) &ParentDevicePath
+                  );
+  if (EFI_ERROR (Status)) {
+    return Status;
+  }
+
+  //
+  // Open the IO Abstraction(s) needed
+  //
+  Status = gBS->OpenProtocol (
+                  Controller,
+                  &gEfiPciIoProtocolGuid,
+                  (VOID **) &PciIo,
+                  This->DriverBindingHandle,
+                  Controller,
+                  EFI_OPEN_PROTOCOL_BY_DRIVER
+                  );
+  if (EFI_ERROR (Status) && (Status != EFI_ALREADY_STARTED)) {
+    return Status;
+  }
+
+  //
+  // Save original PCI attributes
+  //
+  if (!mPciAttributesSaved) {
+    Status = PciIo->Attributes (
+                      PciIo,
+                      EfiPciIoAttributeOperationGet,
+                      0,
+                      &mOriginalPciAttributes
+                      );
+    
+    if (EFI_ERROR (Status)) {
+      goto Done;
+    }
+    mPciAttributesSaved = TRUE;
+  }
+
+  //
+  // Get supported PCI attributes
+  //
+  Status = PciIo->Attributes (
+                    PciIo,
+                    EfiPciIoAttributeOperationSupported,
+                    0,
+                    &Supports
+                    );
+  if (EFI_ERROR (Status)) {
+    goto Done;
+  }
+
+  Supports &= (EFI_PCI_IO_ATTRIBUTE_VGA_IO | EFI_PCI_IO_ATTRIBUTE_VGA_IO_16);
+  if (Supports == 0 || Supports == (EFI_PCI_IO_ATTRIBUTE_VGA_IO | 
EFI_PCI_IO_ATTRIBUTE_VGA_IO_16)) {
+    Status = EFI_UNSUPPORTED;
+    goto Done;
+  }  
+  
+  REPORT_STATUS_CODE_WITH_DEVICE_PATH (
+    EFI_PROGRESS_CODE,
+    EFI_PERIPHERAL_LOCAL_CONSOLE | EFI_P_PC_ENABLE,
+    ParentDevicePath
+    );
+  //
+  // Enable the device and make sure VGA cycles are being forwarded to this 
VGA device
+  //
+  Status = PciIo->Attributes (
+             PciIo,
+             EfiPciIoAttributeOperationEnable,
+             EFI_PCI_DEVICE_ENABLE,
+             NULL
+             );
+  if (EFI_ERROR (Status)) {
+    REPORT_STATUS_CODE_WITH_DEVICE_PATH (
+      EFI_ERROR_CODE | EFI_ERROR_MINOR,
+      EFI_PERIPHERAL_LOCAL_CONSOLE | EFI_P_EC_RESOURCE_CONFLICT,
+      ParentDevicePath
+      );
+    goto Done;
+  }
+
+  if (RemainingDevicePath != NULL) {
+    if (IsDevicePathEnd (RemainingDevicePath)) {
+      //
+      // If RemainingDevicePath is the End of Device Path Node,
+      // don't create any child device and return EFI_SUCESS
+      Status = EFI_SUCCESS;
+      goto Done;
+    }
+  }
+  
+  //
+  // Create child handle and install GraphicsOutputProtocol on it
+  //
+  Status = FbGopChildHandleInstall (
+             This,
+             Controller,
+             PciIo,
+             NULL,
+             ParentDevicePath,
+             RemainingDevicePath
+             );
+  
+Done:
+  if ((EFI_ERROR (Status)) && (Status != EFI_ALREADY_STARTED)) {
+          
+    REPORT_STATUS_CODE_WITH_DEVICE_PATH (
+      EFI_PROGRESS_CODE,
+      EFI_PERIPHERAL_LOCAL_CONSOLE | EFI_P_PC_DISABLE,
+      ParentDevicePath
+      );
+
+    REPORT_STATUS_CODE_WITH_DEVICE_PATH (
+      EFI_PROGRESS_CODE,
+      EFI_PERIPHERAL_LOCAL_CONSOLE | EFI_P_EC_NOT_DETECTED,
+      ParentDevicePath
+      );
+    if (!HasChildHandle (Controller)) {
+      if (mPciAttributesSaved) {
+        //
+        // Restore original PCI attributes
+        //
+        PciIo->Attributes (
+                        PciIo,
+                        EfiPciIoAttributeOperationSet,
+                        mOriginalPciAttributes,
+                        NULL
+                        );
+      }
+    }
+    //
+    // Release PCI I/O Protocols on the controller handle.
+    //
+    gBS->CloseProtocol (
+           Controller,
+           &gEfiPciIoProtocolGuid,
+           This->DriverBindingHandle,
+           Controller
+           );
+  }
+
+  return Status;
+}
+
+
+/**
+  Stop.
+
+  @param  This                   Pointer to driver binding protocol
+  @param  Controller             Controller handle to connect
+  @param  NumberOfChildren       Number of children handle created by this 
driver
+  @param  ChildHandleBuffer      Buffer containing child handle created
+
+  @retval EFI_SUCCESS            Driver disconnected successfully from 
controller
+  @retval EFI_UNSUPPORTED        Cannot find FB_VIDEO_DEV structure
+
+**/
+EFI_STATUS
+EFIAPI
+FbGopDriverBindingStop (
+  IN  EFI_DRIVER_BINDING_PROTOCOL     *This,
+  IN  EFI_HANDLE                      Controller,
+  IN  UINTN                           NumberOfChildren,
+  IN  EFI_HANDLE                      *ChildHandleBuffer
+  )
+{
+  EFI_STATUS                   Status;
+  BOOLEAN                      AllChildrenStopped;
+  UINTN                        Index;
+  EFI_PCI_IO_PROTOCOL          *PciIo;
+
+  AllChildrenStopped = TRUE;
+
+  if (NumberOfChildren == 0) {
+    //
+    // Close PCI I/O protocol on the controller handle
+    //
+    gBS->CloseProtocol (
+           Controller,
+           &gEfiPciIoProtocolGuid,
+           This->DriverBindingHandle,
+           Controller
+           );
+
+    return EFI_SUCCESS;
+  }
+
+  for (Index = 0; Index < NumberOfChildren; Index++) {
+        
+    Status = EFI_SUCCESS;
+
+    FbGopChildHandleUninstall (This, Controller, ChildHandleBuffer[Index]);
+
+    if (EFI_ERROR (Status)) {
+      AllChildrenStopped = FALSE;
+    }
+  }
+
+  if (!AllChildrenStopped) {
+    return EFI_DEVICE_ERROR;
+  }
+
+  if (!HasChildHandle (Controller)) {
+    if (mPciAttributesSaved) {
+      Status = gBS->HandleProtocol (
+                      Controller,
+                      &gEfiPciIoProtocolGuid,
+                      (VOID **) &PciIo
+                      );
+      ASSERT_EFI_ERROR (Status);
+      
+      //
+      // Restore original PCI attributes
+      //
+      Status = PciIo->Attributes (
+                        PciIo,
+                        EfiPciIoAttributeOperationSet,
+                        mOriginalPciAttributes,
+                        NULL
+                        );
+      ASSERT_EFI_ERROR (Status);
+    }
+  }
+
+
+  return EFI_SUCCESS;
+}
+
+
+/**
+  Install child handles if the Handle supports MBR format.
+
+  @param  This                   Calling context.
+  @param  ParentHandle           Parent Handle
+  @param  ParentPciIo            Parent PciIo interface
+  @param  ParentLegacyBios       Parent LegacyBios interface
+  @param  ParentDevicePath       Parent Device Path
+  @param  RemainingDevicePath    Remaining Device Path
+
+  @retval EFI_SUCCESS            If a child handle was added
+  @retval other                  A child handle was not added
+
+**/
+EFI_STATUS
+FbGopChildHandleInstall (
+  IN  EFI_DRIVER_BINDING_PROTOCOL  *This,
+  IN  EFI_HANDLE                   ParentHandle,
+  IN  EFI_PCI_IO_PROTOCOL          *ParentPciIo,
+  IN  VOID                         *ParentLegacyBios,
+  IN  EFI_DEVICE_PATH_PROTOCOL     *ParentDevicePath,
+  IN  EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath
+  )
+{
+  EFI_STATUS               Status;
+  FB_VIDEO_DEV            *FbGopPrivate;
+  PCI_TYPE00               Pci;
+  ACPI_ADR_DEVICE_PATH     AcpiDeviceNode;
+  BOOLEAN                  ProtocolInstalled;
+
+  //
+  // Allocate the private device structure for video device
+  //
+  FbGopPrivate = (FB_VIDEO_DEV *) AllocateZeroPool (
+                                                                               
                                                                                
        sizeof (FB_VIDEO_DEV)
+                                                                               
                                                                                
        );
+  if (NULL == FbGopPrivate) {
+               Status = EFI_OUT_OF_RESOURCES;
+    goto Done;
+  }
+
+  //
+  // See if this is a VGA compatible controller or not
+  //
+  Status = ParentPciIo->Pci.Read (
+                          ParentPciIo,
+                          EfiPciIoWidthUint32,
+                          0,
+                          sizeof (Pci) / sizeof (UINT32),
+                          &Pci
+                          );
+  if (EFI_ERROR (Status)) {
+    REPORT_STATUS_CODE_WITH_DEVICE_PATH (
+      EFI_ERROR_CODE | EFI_ERROR_MINOR,
+      EFI_PERIPHERAL_LOCAL_CONSOLE | EFI_P_EC_CONTROLLER_ERROR,
+      ParentDevicePath
+      );
+    goto Done;
+  }
+  
+  //
+  // Initialize the child private structure
+  //
+  FbGopPrivate->Signature = FB_VIDEO_DEV_SIGNATURE;
+
+  //
+  // Fill in Graphics Output specific mode structures
+  //  
+  FbGopPrivate->ModeData              = NULL;
+    
+  FbGopPrivate->VbeFrameBuffer        = NULL;
+
+  FbGopPrivate->EdidDiscovered.SizeOfEdid  = 0;
+  FbGopPrivate->EdidDiscovered.Edid        = NULL;
+  FbGopPrivate->EdidActive.SizeOfEdid      = 0;
+  FbGopPrivate->EdidActive.Edid            = NULL;
+  
+  //
+  // Fill in the Graphics Output Protocol
+  //
+  FbGopPrivate->GraphicsOutput.QueryMode = FbGopGraphicsOutputQueryMode;
+  FbGopPrivate->GraphicsOutput.SetMode   = FbGopGraphicsOutputSetMode;
+
+
+  //
+  // Allocate buffer for Graphics Output Protocol mode information
+  //
+  FbGopPrivate->GraphicsOutput.Mode = (EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE *) 
AllocatePool (
+                                             sizeof 
(EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE)
+                                             );
+  if (NULL == FbGopPrivate->GraphicsOutput.Mode) {
+    Status = EFI_OUT_OF_RESOURCES;
+    goto Done;
+  }
+
+  FbGopPrivate->GraphicsOutput.Mode->Info = 
(EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *) AllocatePool (
+                                             sizeof 
(EFI_GRAPHICS_OUTPUT_MODE_INFORMATION)
+                                             );
+  if (NULL ==  FbGopPrivate->GraphicsOutput.Mode->Info) {
+    Status = EFI_OUT_OF_RESOURCES;
+    goto Done;
+  }
+
+  //
+  // Set Gop Device Path, here RemainingDevicePath will not be one End of 
Device Path Node.
+  //
+  if ((RemainingDevicePath == NULL) || (!IsDevicePathEnd 
(RemainingDevicePath))) {
+    if (RemainingDevicePath == NULL) {
+      ZeroMem (&AcpiDeviceNode, sizeof (ACPI_ADR_DEVICE_PATH));
+      AcpiDeviceNode.Header.Type = ACPI_DEVICE_PATH;
+      AcpiDeviceNode.Header.SubType = ACPI_ADR_DP;
+      AcpiDeviceNode.ADR = ACPI_DISPLAY_ADR (1, 0, 0, 1, 0, 
ACPI_ADR_DISPLAY_TYPE_VGA, 0, 0);
+      SetDevicePathNodeLength (&AcpiDeviceNode.Header, sizeof 
(ACPI_ADR_DEVICE_PATH));
+    
+      FbGopPrivate->GopDevicePath = AppendDevicePathNode (
+                                          ParentDevicePath,
+                                          (EFI_DEVICE_PATH_PROTOCOL *) 
&AcpiDeviceNode
+                                          );
+    } else {
+      FbGopPrivate->GopDevicePath = AppendDevicePathNode (ParentDevicePath, 
RemainingDevicePath);
+    }
+    
+    //
+    // Creat child handle and device path protocol firstly
+    //
+    FbGopPrivate->Handle = NULL;
+    Status = gBS->InstallMultipleProtocolInterfaces (
+                    &FbGopPrivate->Handle,
+                    &gEfiDevicePathProtocolGuid,
+                    FbGopPrivate->GopDevicePath,
+                    NULL
+                    );
+    if (EFI_ERROR (Status)) {
+      goto Done;
+    }
+  }
+  
+  //
+  // When check for VBE, PCI I/O protocol is needed, so use parent's protocol 
interface temporally
+  //
+  FbGopPrivate->PciIo                 = ParentPciIo;
+
+  //
+  // Check for VESA BIOS Extensions for modes that are compatible with 
Graphics Output
+  //
+  Status = FbGopCheckForVbe (FbGopPrivate);
+  DEBUG ((EFI_D_INFO, "FbGopCheckForVbe - %r\n", Status));
+  
+  if (EFI_ERROR (Status)) {
+    Status = EFI_UNSUPPORTED;
+    //goto Done;    
+  }
+
+  ProtocolInstalled = FALSE;
+  
+  //
+  // Creat child handle and install Graphics Output Protocol,EDID 
Discovered/Active Protocol
+  //
+  Status = gBS->InstallMultipleProtocolInterfaces (
+                  &FbGopPrivate->Handle,
+                  &gEfiGraphicsOutputProtocolGuid,
+                  &FbGopPrivate->GraphicsOutput,  
+                  &gEfiEdidDiscoveredProtocolGuid,
+                  &FbGopPrivate->EdidDiscovered,                               
                     
+                  &gEfiEdidActiveProtocolGuid,
+                  &FbGopPrivate->EdidActive,                  
+                  NULL
+                  );
+
+  if (!EFI_ERROR (Status)) {
+    //
+    // Open the Parent Handle for the child
+    //
+    Status = gBS->OpenProtocol (
+                    ParentHandle,
+                    &gEfiPciIoProtocolGuid,
+                    (VOID **) &FbGopPrivate->PciIo,
+                    This->DriverBindingHandle,
+                    FbGopPrivate->Handle,
+                    EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
+                    );
+    if (EFI_ERROR (Status)) {
+      goto Done;
+    }
+    ProtocolInstalled = TRUE;
+  }
+  
+Done:
+  if (EFI_ERROR (Status)) {
+    //
+    // Free private data structure
+    //
+    FbGopDeviceReleaseResource (FbGopPrivate);
+  }
+
+  return Status;
+}
+
+
+/**
+  Deregister an video child handle and free resources.
+
+  @param  This                   Protocol instance pointer.
+  @param  Controller             Video controller handle
+  @param  Handle                 Video child handle
+
+  @return EFI_STATUS
+
+**/
+EFI_STATUS
+FbGopChildHandleUninstall (
+  EFI_DRIVER_BINDING_PROTOCOL    *This,
+  EFI_HANDLE                     Controller,
+  EFI_HANDLE                     Handle
+  )
+{
+  EFI_STATUS                    Status;
+  EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;  
+  FB_VIDEO_DEV                 *FbGopPrivate;
+  EFI_PCI_IO_PROTOCOL          *PciIo;
+
+  FbGopPrivate     = NULL;
+  GraphicsOutput   = NULL;
+  PciIo            = NULL;
+  Status           = EFI_UNSUPPORTED;
+
+  Status = gBS->OpenProtocol (
+                  Handle,
+                  &gEfiGraphicsOutputProtocolGuid,
+                  (VOID **) &GraphicsOutput,
+                  This->DriverBindingHandle,
+                  Handle,
+                  EFI_OPEN_PROTOCOL_GET_PROTOCOL
+                  );
+  if (!EFI_ERROR (Status)) {
+      FbGopPrivate = FB_VIDEO_DEV_FROM_GRAPHICS_OUTPUT_THIS (GraphicsOutput);
+  }
+  
+  if (FbGopPrivate == NULL) {
+    return EFI_UNSUPPORTED;
+  }
+
+  //
+  // Close PCI I/O protocol that opened by child handle
+  //
+  Status = gBS->CloseProtocol (
+                  Controller,
+                  &gEfiPciIoProtocolGuid,
+                  This->DriverBindingHandle,
+                  Handle
+                  );
+
+  //
+  // Uninstall protocols on child handle
+  //
+  Status = gBS->UninstallMultipleProtocolInterfaces (
+                    FbGopPrivate->Handle,
+                    &gEfiDevicePathProtocolGuid,
+                    FbGopPrivate->GopDevicePath,
+                    &gEfiGraphicsOutputProtocolGuid,
+                    &FbGopPrivate->GraphicsOutput,
+                    NULL
+                    );
+ 
+  if (EFI_ERROR (Status)) {
+    gBS->OpenProtocol (
+           Controller,
+           &gEfiPciIoProtocolGuid,
+           (VOID **) &PciIo,
+           This->DriverBindingHandle,
+           Handle,
+           EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
+           );
+    return Status;
+  }
+  
+  //
+  // Release all allocated resources
+  //
+  FbGopDeviceReleaseResource (FbGopPrivate);
+
+  return EFI_SUCCESS;
+}
+
+
+/**
+  Release resource for biso video instance.
+
+  @param  FbGopPrivate       Video child device private data structure
+
+**/
+VOID
+FbGopDeviceReleaseResource (
+  FB_VIDEO_DEV  *FbGopPrivate
+  )
+{
+  if (FbGopPrivate == NULL) {
+    return ;
+  }
+
+  //
+  // Release all the resourses occupied by the FB_VIDEO_DEV
+  //
+  
+  //
+  // Free VBE Frame Buffer
+  //
+  if (FbGopPrivate->VbeFrameBuffer != NULL) {
+    FreePool (FbGopPrivate->VbeFrameBuffer);
+  }
+  
+  //
+  // Free mode data
+  //
+  if (FbGopPrivate->ModeData != NULL) {
+    FreePool (FbGopPrivate->ModeData);
+  }  
+
+  //
+  // Free graphics output protocol occupied resource
+  //
+  if (FbGopPrivate->GraphicsOutput.Mode != NULL) {
+    if (FbGopPrivate->GraphicsOutput.Mode->Info != NULL) {
+        FreePool (FbGopPrivate->GraphicsOutput.Mode->Info);
+        FbGopPrivate->GraphicsOutput.Mode->Info = NULL;
+    }
+    FreePool (FbGopPrivate->GraphicsOutput.Mode);
+    FbGopPrivate->GraphicsOutput.Mode = NULL;
+  }  
+
+  if (FbGopPrivate->GopDevicePath!= NULL) {
+    FreePool (FbGopPrivate->GopDevicePath);
+  }
+
+  FreePool (FbGopPrivate);
+
+  return ;
+}
+
+
+
+/**
+  Check if all video child handles have been uninstalled.
+
+  @param  Controller             Video controller handle
+
+  @return TRUE                   Child handles exist.
+  @return FALSE                  All video child handles have been uninstalled.
+
+**/
+BOOLEAN
+HasChildHandle (
+  IN EFI_HANDLE  Controller
+  )
+{
+  UINTN                                Index;
+  EFI_OPEN_PROTOCOL_INFORMATION_ENTRY  *OpenInfoBuffer;
+  UINTN                                EntryCount;
+  BOOLEAN                              HasChild;
+  EFI_STATUS                           Status;
+
+  EntryCount = 0;
+  HasChild   = FALSE;
+  Status = gBS->OpenProtocolInformation (
+                  Controller,
+                  &gEfiPciIoProtocolGuid,
+                  &OpenInfoBuffer,
+                  &EntryCount
+                  );
+  for (Index = 0; Index < EntryCount; Index++) {
+    if ((OpenInfoBuffer[Index].Attributes & 
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) {
+      HasChild = TRUE;
+    }
+  }
+  
+  return HasChild;
+}
+
+/**
+  Check for VBE device.
+
+  @param  FbGopPrivate       Pointer to FB_VIDEO_DEV structure
+
+  @retval EFI_SUCCESS            VBE device found
+
+**/
+EFI_STATUS
+FbGopCheckForVbe (
+  IN OUT FB_VIDEO_DEV  *FbGopPrivate
+  )
+{
+  EFI_STATUS                             Status;  
+  FB_VIDEO_MODE_DATA                     *ModeBuffer;
+  FB_VIDEO_MODE_DATA                     *CurrentModeData;  
+  UINTN                                  ModeNumber;  
+  UINTN                                  BitsPerPixel; 
+  UINTN                                  BytesPerScanLine;
+  UINT32                                 HorizontalResolution;
+  UINT32                                 VerticalResolution;
+  EFI_GRAPHICS_OUTPUT_BLT_PIXEL          *VbeFrameBuffer;  
+  EFI_HOB_GUID_TYPE                      *GuidHob;
+  FRAME_BUFFER_INFO                      *pFbInfo;
+  
+  Status = EFI_SUCCESS;
+  //
+  // Find the frame buffer information guid hob
+  //
+  GuidHob = GetFirstGuidHob (&gUefiFrameBufferInfoGuid);
+  ASSERT (GuidHob != NULL);
+  pFbInfo = (FRAME_BUFFER_INFO *)GET_GUID_HOB_DATA (GuidHob);
+  
+  //
+  // Add mode to the list of available modes
+  //
+  VbeFrameBuffer = NULL;
+  ModeBuffer     = NULL;
+  
+  ModeNumber           = 1;  
+  BitsPerPixel         = pFbInfo->BitsPerPixel;
+  HorizontalResolution = pFbInfo->HorizontalResolution;
+  VerticalResolution   = pFbInfo->VerticalResolution;
+  BytesPerScanLine     = HorizontalResolution * (BitsPerPixel / 8);
+  
+  ModeBuffer = (FB_VIDEO_MODE_DATA *) AllocatePool (
+                                                                               
                                                                                
                ModeNumber * sizeof (FB_VIDEO_MODE_DATA)
+                                                                               
                                                                        );
+  if (NULL == ModeBuffer) {
+         Status = EFI_OUT_OF_RESOURCES;
+    goto Done;
+  }
+
+  VbeFrameBuffer =
+                       (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *) AllocatePool (
+                                                                               
                                                                                
        BytesPerScanLine * VerticalResolution
+                                                                               
                                                                                
  );
+  if (NULL == VbeFrameBuffer) {
+         Status = EFI_OUT_OF_RESOURCES;
+    goto Done;
+  }
+       
+  if (FbGopPrivate->ModeData != NULL) {
+    FreePool (FbGopPrivate->ModeData);
+  }
+    
+  if (FbGopPrivate->VbeFrameBuffer != NULL) {
+    FreePool (FbGopPrivate->VbeFrameBuffer);
+  }  
+  
+  CurrentModeData = &ModeBuffer[ModeNumber - 1];
+  CurrentModeData->BytesPerScanLine = (UINT16)BytesPerScanLine;
+  
+  CurrentModeData->Red      = *(FB_VIDEO_COLOR_PLACEMENT *)&(pFbInfo->Red);  
+  CurrentModeData->Blue     = *(FB_VIDEO_COLOR_PLACEMENT *)&(pFbInfo->Blue);   
 
+  CurrentModeData->Green    = *(FB_VIDEO_COLOR_PLACEMENT *)&(pFbInfo->Green);  
  
+  CurrentModeData->Reserved = *(FB_VIDEO_COLOR_PLACEMENT 
*)&(pFbInfo->Reserved);  
+  
+  CurrentModeData->BitsPerPixel    = (UINT32)BitsPerPixel;
+  CurrentModeData->HorizontalResolution = HorizontalResolution;
+  CurrentModeData->VerticalResolution   = VerticalResolution;  
+  CurrentModeData->FrameBufferSize = CurrentModeData->BytesPerScanLine * 
CurrentModeData->VerticalResolution;    
+  CurrentModeData->LinearFrameBuffer = (VOID *) (UINTN) 
pFbInfo->LinearFrameBuffer;
+  CurrentModeData->VbeModeNumber        = 0;
+  CurrentModeData->ColorDepth           = 32;
+  CurrentModeData->RefreshRate          = 60;
+  
+  CurrentModeData->PixelFormat = PixelBitMask;
+  if ((CurrentModeData->BitsPerPixel == 32) &&
+      (CurrentModeData->Red.Mask == 0xff) && (CurrentModeData->Green.Mask == 
0xff) && (CurrentModeData->Blue.Mask == 0xff)) {
+    if ((CurrentModeData->Red.Position == 0) && 
(CurrentModeData->Green.Position == 8) && (CurrentModeData->Blue.Position == 
16)) {
+      CurrentModeData->PixelFormat = PixelRedGreenBlueReserved8BitPerColor;
+    } else if ((CurrentModeData->Blue.Position == 0) && 
(CurrentModeData->Green.Position == 8) && (CurrentModeData->Red.Position == 
16)) {
+      CurrentModeData->PixelFormat = PixelBlueGreenRedReserved8BitPerColor;
+    }
+  }  
+  
+  CopyMem (&(CurrentModeData->PixelBitMask), &mPixelBitMask, sizeof 
(EFI_PIXEL_BITMASK));    
+          
+  FbGopPrivate->ModeData       = ModeBuffer;
+  FbGopPrivate->VbeFrameBuffer = VbeFrameBuffer;
+  
+  //
+  // Assign Gop's Blt function
+  //
+  FbGopPrivate->GraphicsOutput.Blt     = FbGopGraphicsOutputVbeBlt;
+  
+  FbGopPrivate->GraphicsOutput.Mode->MaxMode = 1;
+  FbGopPrivate->GraphicsOutput.Mode->Mode    = 0;      
+  FbGopPrivate->GraphicsOutput.Mode->Info->Version = 0;
+  FbGopPrivate->GraphicsOutput.Mode->Info->HorizontalResolution = 
HorizontalResolution;
+  FbGopPrivate->GraphicsOutput.Mode->Info->VerticalResolution   = 
VerticalResolution;   
+  FbGopPrivate->GraphicsOutput.Mode->Info->PixelFormat = 
CurrentModeData->PixelFormat;
+  CopyMem (&(FbGopPrivate->GraphicsOutput.Mode->Info->PixelInformation), 
&mPixelBitMask, sizeof (EFI_PIXEL_BITMASK));  
+  FbGopPrivate->GraphicsOutput.Mode->Info->PixelsPerScanLine = 
HorizontalResolution;    
+  FbGopPrivate->GraphicsOutput.Mode->SizeOfInfo = 
sizeof(EFI_GRAPHICS_OUTPUT_MODE_INFORMATION);
+  FbGopPrivate->GraphicsOutput.Mode->FrameBufferBase = (EFI_PHYSICAL_ADDRESS) 
(UINTN) CurrentModeData->LinearFrameBuffer;
+  FbGopPrivate->GraphicsOutput.Mode->FrameBufferSize =  
CurrentModeData->FrameBufferSize;
+  
+  //
+  // Find the best mode to initialize
+  //  
+
+Done:
+  //
+  // If there was an error, then free the mode structure
+  //
+  if (EFI_ERROR (Status)) {
+      
+    if (VbeFrameBuffer != NULL) {
+      FreePool (VbeFrameBuffer);
+    }    
+    
+    if (ModeBuffer != NULL) {
+      FreePool (ModeBuffer);
+    }    
+  }
+
+  return Status;
+}
+
+
+//
+// Graphics Output Protocol Member Functions for VESA BIOS Extensions
+//
+
+/**
+  Graphics Output protocol interface to get video mode.
+
+  @param  This                   Protocol instance pointer.
+  @param  ModeNumber             The mode number to return information on.
+  @param  SizeOfInfo             A pointer to the size, in bytes, of the Info
+                                 buffer.
+  @param  Info                   Caller allocated buffer that returns 
information
+                                 about ModeNumber.
+
+  @retval EFI_SUCCESS            Mode information returned.
+  @retval EFI_DEVICE_ERROR       A hardware error occurred trying to retrieve 
the
+                                 video mode.
+  @retval EFI_NOT_STARTED        Video display is not initialized. Call 
SetMode ()
+  @retval EFI_INVALID_PARAMETER  One of the input args was NULL.
+
+**/
+EFI_STATUS
+EFIAPI
+FbGopGraphicsOutputQueryMode (
+  IN  EFI_GRAPHICS_OUTPUT_PROTOCOL          *This,
+  IN  UINT32                                ModeNumber,
+  OUT UINTN                                 *SizeOfInfo,
+  OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION  **Info
+  )
+{
+  FB_VIDEO_DEV        *FbGopPrivate;
+  FB_VIDEO_MODE_DATA  *ModeData;
+
+  FbGopPrivate = FB_VIDEO_DEV_FROM_GRAPHICS_OUTPUT_THIS (This);
+
+  if (This == NULL || Info == NULL || SizeOfInfo == NULL || ModeNumber >= 
This->Mode->MaxMode) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  *Info = (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *) AllocatePool (
+                                                                               
                                                                                
                                                sizeof 
(EFI_GRAPHICS_OUTPUT_MODE_INFORMATION)
+                                                                               
                                                                                
                                                );
+  if (NULL == *Info) {
+    return EFI_OUT_OF_RESOURCES;
+  }
+
+  *SizeOfInfo = sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION);
+
+  ModeData = &FbGopPrivate->ModeData[ModeNumber];
+  (*Info)->Version = 0;
+  (*Info)->HorizontalResolution = ModeData->HorizontalResolution;
+  (*Info)->VerticalResolution   = ModeData->VerticalResolution;
+  (*Info)->PixelFormat = ModeData->PixelFormat;
+  CopyMem (&((*Info)->PixelInformation), &(ModeData->PixelBitMask), 
sizeof(ModeData->PixelBitMask));
+
+  (*Info)->PixelsPerScanLine =  (ModeData->BytesPerScanLine * 8) / 
ModeData->BitsPerPixel;
+
+  return EFI_SUCCESS;
+}
+
+/**
+  Graphics Output protocol interface to set video mode.
+
+  @param  This                   Protocol instance pointer.
+  @param  ModeNumber             The mode number to be set.
+
+  @retval EFI_SUCCESS            Graphics mode was changed.
+  @retval EFI_DEVICE_ERROR       The device had an error and could not 
complete the
+                                 request.
+  @retval EFI_UNSUPPORTED        ModeNumber is not supported by this device.
+
+**/
+EFI_STATUS
+EFIAPI
+FbGopGraphicsOutputSetMode (
+  IN  EFI_GRAPHICS_OUTPUT_PROTOCOL * This,
+  IN  UINT32                       ModeNumber
+  )
+{  
+  FB_VIDEO_DEV          *FbGopPrivate;
+  FB_VIDEO_MODE_DATA    *ModeData;
+  EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background;
+
+  if (This == NULL) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  FbGopPrivate = FB_VIDEO_DEV_FROM_GRAPHICS_OUTPUT_THIS (This);
+
+  ModeData = &FbGopPrivate->ModeData[ModeNumber];
+
+  if (ModeNumber >= This->Mode->MaxMode) {
+    return EFI_UNSUPPORTED;
+  }
+  
+  if (ModeNumber == This->Mode->Mode) {
+    //
+    // Clear screen to black
+    //    
+    ZeroMem (&Background, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
+    FbGopGraphicsOutputVbeBlt (
+                        This,
+                        &Background,
+                        EfiBltVideoFill,
+                        0,
+                        0,
+                        0,
+                        0,
+                        ModeData->HorizontalResolution,
+                        ModeData->VerticalResolution,
+                        0
+    );
+    return EFI_SUCCESS;
+  } else {
+    return EFI_UNSUPPORTED;
+  }
+  
+}
+
+/**
+  Update physical frame buffer, copy 4 bytes block, then copy remaining bytes.
+
+  @param   PciIo              The pointer of EFI_PCI_IO_PROTOCOL
+  @param   VbeBuffer          The data to transfer to screen
+  @param   MemAddress         Physical frame buffer base address
+  @param   DestinationX       The X coordinate of the destination for 
BltOperation
+  @param   DestinationY       The Y coordinate of the destination for 
BltOperation
+  @param   TotalBytes         The total bytes of copy
+  @param   VbePixelWidth      Bytes per pixel
+  @param   BytesPerScanLine   Bytes per scan line
+
+**/
+VOID
+CopyVideoBuffer (
+  IN  EFI_PCI_IO_PROTOCOL   *PciIo,
+  IN  UINT8                 *VbeBuffer,
+  IN  VOID                  *MemAddress,
+  IN  UINTN                 DestinationX,
+  IN  UINTN                 DestinationY,
+  IN  UINTN                 TotalBytes,
+  IN  UINT32                VbePixelWidth,
+  IN  UINTN                 BytesPerScanLine
+  )
+{
+  UINTN                 FrameBufferAddr;
+  UINTN                 CopyBlockNum;
+  UINTN                 RemainingBytes;
+  UINTN                 UnalignedBytes;
+  EFI_STATUS            Status;
+
+  FrameBufferAddr = (UINTN) MemAddress + (DestinationY * BytesPerScanLine) + 
DestinationX * VbePixelWidth;
+
+  //
+  // If TotalBytes is less than 4 bytes, only start byte copy.
+  //
+  if (TotalBytes < 4) {
+    Status = PciIo->Mem.Write (
+                     PciIo,
+                     EfiPciIoWidthUint8,
+                     EFI_PCI_IO_PASS_THROUGH_BAR,
+                     (UINT64) FrameBufferAddr,
+                     TotalBytes,
+                     VbeBuffer
+                     );
+    ASSERT_EFI_ERROR (Status);
+    return;
+  }
+
+  //
+  // If VbeBuffer is not 4-byte aligned, start byte copy.
+  //
+  UnalignedBytes  = (4 - ((UINTN) VbeBuffer & 0x3)) & 0x3;
+
+  if (UnalignedBytes != 0) {
+    Status = PciIo->Mem.Write (
+                     PciIo,
+                     EfiPciIoWidthUint8,
+                     EFI_PCI_IO_PASS_THROUGH_BAR,
+                     (UINT64) FrameBufferAddr,
+                     UnalignedBytes,
+                     VbeBuffer
+                     );
+    ASSERT_EFI_ERROR (Status);
+    FrameBufferAddr += UnalignedBytes;
+    VbeBuffer       += UnalignedBytes;
+  }
+
+  //
+  // Calculate 4-byte block count and remaining bytes.
+  //
+  CopyBlockNum   = (TotalBytes - UnalignedBytes) >> 2;
+  RemainingBytes = (TotalBytes - UnalignedBytes) &  3;
+
+  //
+  // Copy 4-byte block and remaining bytes to physical frame buffer.
+  //
+  if (CopyBlockNum != 0) {
+    Status = PciIo->Mem.Write (
+                    PciIo,
+                    EfiPciIoWidthUint32,
+                    EFI_PCI_IO_PASS_THROUGH_BAR,
+                    (UINT64) FrameBufferAddr,
+                    CopyBlockNum,
+                    VbeBuffer
+                    );
+    ASSERT_EFI_ERROR (Status);
+  }
+
+  if (RemainingBytes != 0) {
+    FrameBufferAddr += (CopyBlockNum << 2);
+    VbeBuffer       += (CopyBlockNum << 2);
+    Status = PciIo->Mem.Write (
+                    PciIo,
+                    EfiPciIoWidthUint8,
+                    EFI_PCI_IO_PASS_THROUGH_BAR,
+                    (UINT64) FrameBufferAddr,
+                    RemainingBytes,
+                    VbeBuffer
+                    );
+    ASSERT_EFI_ERROR (Status);
+  }
+}
+
+/**
+  Worker function to block transfer for VBE device.
+
+  @param  FbGopPrivate       Instance of FB_VIDEO_DEV
+  @param  BltBuffer              The data to transfer to screen
+  @param  BltOperation           The operation to perform
+  @param  SourceX                The X coordinate of the source for 
BltOperation
+  @param  SourceY                The Y coordinate of the source for 
BltOperation
+  @param  DestinationX           The X coordinate of the destination for
+                                 BltOperation
+  @param  DestinationY           The Y coordinate of the destination for
+                                 BltOperation
+  @param  Width                  The width of a rectangle in the blt rectangle 
in
+                                 pixels
+  @param  Height                 The height of a rectangle in the blt 
rectangle in
+                                 pixels
+  @param  Delta                  Not used for EfiBltVideoFill and
+                                 EfiBltVideoToVideo operation. If a Delta of 0 
is
+                                 used, the entire BltBuffer will be operated 
on. If
+                                 a subrectangle of the BltBuffer is used, then
+                                 Delta represents the number of bytes in a row 
of
+                                 the BltBuffer.
+  @param  Mode                   Mode data.
+
+  @retval EFI_INVALID_PARAMETER  Invalid parameter passed in
+  @retval EFI_SUCCESS            Blt operation success
+
+**/
+EFI_STATUS
+FbGopVbeBltWorker (
+  IN  FB_VIDEO_DEV                       *FbGopPrivate,
+  IN  EFI_GRAPHICS_OUTPUT_BLT_PIXEL      *BltBuffer, OPTIONAL
+  IN  EFI_GRAPHICS_OUTPUT_BLT_OPERATION  BltOperation,
+  IN  UINTN                              SourceX,
+  IN  UINTN                              SourceY,
+  IN  UINTN                              DestinationX,
+  IN  UINTN                              DestinationY,
+  IN  UINTN                              Width,
+  IN  UINTN                              Height,
+  IN  UINTN                              Delta,
+  IN  FB_VIDEO_MODE_DATA               *Mode
+  )
+{
+  EFI_PCI_IO_PROTOCOL            *PciIo;
+  EFI_TPL                        OriginalTPL;
+  UINTN                          DstY;
+  UINTN                          SrcY;
+  UINTN                          DstX;
+  EFI_GRAPHICS_OUTPUT_BLT_PIXEL  *Blt;
+  VOID                           *MemAddress;
+  EFI_GRAPHICS_OUTPUT_BLT_PIXEL  *VbeFrameBuffer;
+  UINTN                          BytesPerScanLine;
+  UINTN                          Index;
+  UINT8                          *VbeBuffer;
+  UINT8                          *VbeBuffer1;
+  UINT8                          *BltUint8;
+  UINT32                         VbePixelWidth;
+  UINT32                         Pixel;
+  UINTN                          TotalBytes;
+
+  PciIo             = FbGopPrivate->PciIo;
+
+  VbeFrameBuffer    = FbGopPrivate->VbeFrameBuffer;
+  MemAddress        = Mode->LinearFrameBuffer;
+  BytesPerScanLine  = Mode->BytesPerScanLine;
+  VbePixelWidth     = Mode->BitsPerPixel / 8;
+  BltUint8          = (UINT8 *) BltBuffer;
+  TotalBytes        = Width * VbePixelWidth;
+
+  if (((UINTN) BltOperation) >= EfiGraphicsOutputBltOperationMax) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  if (Width == 0 || Height == 0) {
+    return EFI_INVALID_PARAMETER;
+  }
+  //
+  // We need to fill the Virtual Screen buffer with the blt data.
+  // The virtual screen is upside down, as the first row is the bootom row of
+  // the image.
+  //
+  if (BltOperation == EfiBltVideoToBltBuffer) {
+    //
+    // Video to BltBuffer: Source is Video, destination is BltBuffer
+    //

@@ Diff output truncated at 100000 characters. @@

------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to