diff options
author | raywu <raywu0301@gmail.com> | 2018-06-15 00:00:50 +0800 |
---|---|---|
committer | raywu <raywu0301@gmail.com> | 2018-06-15 00:00:50 +0800 |
commit | b7c51c9cf4864df6aabb99a1ae843becd577237c (patch) | |
tree | eebe9b0d0ca03062955223097e57da84dd618b9a /Board/EM/Platform/EfiCombineImage | |
download | zprj-b7c51c9cf4864df6aabb99a1ae843becd577237c.tar.xz |
Diffstat (limited to 'Board/EM/Platform/EfiCombineImage')
-rw-r--r-- | Board/EM/Platform/EfiCombineImage/EfiCombineImage.c | 223 | ||||
-rw-r--r-- | Board/EM/Platform/EfiCombineImage/EfiCombineImage.cif | 10 | ||||
-rw-r--r-- | Board/EM/Platform/EfiCombineImage/EfiCombineImage.mak | 105 | ||||
-rw-r--r-- | Board/EM/Platform/EfiCombineImage/EfiCombineImage.sdl | 203 |
4 files changed, 541 insertions, 0 deletions
diff --git a/Board/EM/Platform/EfiCombineImage/EfiCombineImage.c b/Board/EM/Platform/EfiCombineImage/EfiCombineImage.c new file mode 100644 index 0000000..34dd321 --- /dev/null +++ b/Board/EM/Platform/EfiCombineImage/EfiCombineImage.c @@ -0,0 +1,223 @@ +//************************************************************************* +//************************************************************************* +//** ** +//** (C)Copyright 1985-2012, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//************************************************************************* +//************************************************************************* + +//************************************************************************* +// $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/Platform/EfiCombineImage/EfiCombineImage.c 1 12/18/12 11:10p Alanlin $ +// +// $Revision: 1 $ +// +// $Date: 12/18/12 11:10p $ +//************************************************************************* +// Revision History +// ---------------- +// $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/Platform/EfiCombineImage/EfiCombineImage.c $ +// +// 1 12/18/12 11:10p Alanlin +// +// +//************************************************************************* +//<AMI_FHDR_START> +// +// Name: +// +// Description: +// +//<AMI_FHDR_END> +//************************************************************************* + +// Include(s) + +#include "Efi.h" +#include "token.h" +#include <AmiLib.h> +#include <AmiCspLib.h> +#include <AmiDxeLib.h> +#include <Pci.h> +#include <Setup.h> +#include <Protocol\PciIo.h> + +// Constant Definition(s) + +// Macro Definition(s) + +// Type Definition(s) + +// Function Prototype(s) + + +// Variable Declaration(s) + +// GUID Definition(s) +#if (PI_SPECIFICATION_VERSION < 0x00010000) +EFI_GUID gFvProtocolGuid = EFI_FIRMWARE_VOLUME_PROTOCOL_GUID; +#else +EFI_GUID gFvProtocolGuid = EFI_FIRMWARE_VOLUME2_PROTOCOL_GUID; +#endif + +#if NVidia_Optimus_dGPU == 1 +EFI_GUID gEfiCombineImageGuid = NVidia_dGPU_HEADER_GUID; +#endif +#if AMD_PX_CHELSEA_dGPU == 1 +EFI_GUID gEfiCombineImageGuid1 = AMD_CHELSEA_HEADER_GUID; +#endif +#if AMD_PX_THAMES_dGPU == 1 +EFI_GUID gEfiCombineImageGuid2 = AMD_THAMES_HEADER_GUID; +#endif + +// Protocol Definition(s) + +// External Declaration(s) + +// Function Definition(s) + + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Name: GetEfiCombineImage +// +// Description: None. +// +// Input: None. +// +// Output: None. +// +// Notes: None. +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +EFI_STATUS GetEfiCombineImage ( + IN PCI_DEV_INFO *Device, + OUT VOID *RomImage, + OUT UINT64 RomSize +) +{ + EFI_STATUS Status; + UINTN FvProtocolCount; + EFI_HANDLE *FvHandles = NULL; +#if (PI_SPECIFICATION_VERSION < 0x00010000) + EFI_FIRMWARE_VOLUME_PROTOCOL *Fv; +#else + EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv; +#endif + UINTN Index; + UINT32 AuthenticationStatus; + UINT8 *Buffer = NULL; + UINTN BufferSize; + + Status = pBS->LocateHandleBuffer ( + ByProtocol, + &gFvProtocolGuid, + NULL, + &FvProtocolCount, + &FvHandles + ); + if (!EFI_ERROR (Status)) { + for (Index = 0; Index < FvProtocolCount; Index++) { + Status = pBS->HandleProtocol ( + FvHandles[Index], + &gFvProtocolGuid, + (VOID **) &Fv + ); + if (!EFI_ERROR (Status)) { + + switch (Device->DevVenId.DevId) + { +#if NVidia_Optimus_dGPU == 1 + case NVidia_dGPU_DID : + Status = Fv->ReadSection( + Fv,&gEfiCombineImageGuid, + EFI_SECTION_RAW,0, + &Buffer,&BufferSize, + &AuthenticationStatus + ); + break; +#endif + +#if AMD_PX_CHELSEA_dGPU == 1 + case AMD_CHELSEA_DID : + Status = Fv->ReadSection( + Fv,&gEfiCombineImageGuid1, + EFI_SECTION_RAW,0, + &Buffer,&BufferSize, + &AuthenticationStatus + ); + break; +#endif + +#if AMD_PX_THAMES_dGPU == 1 + case AMD_THAMES_DID : + Status = Fv->ReadSection( + Fv,&gEfiCombineImageGuid2, + EFI_SECTION_RAW,0, + &Buffer,&BufferSize, + &AuthenticationStatus + ); + break; +#endif + default : + break; + } + + if (!EFI_ERROR (Status)) { + if(Device->PciIo.RomImage != NULL) { + pBS->FreePool (Device->PciIo.RomImage); + Device->PciIo.RomImage = NULL; + Device->PciIo.RomSize = 0; + } + //Check if Embeded Op ROM is valid... + if(*((UINT16*)Buffer)!=PCI_OPT_ROM_SIG) Status=EFI_NOT_FOUND; + else{ + //Allocate buffer for ROM Image. + Device->PciIo.RomImage = Malloc (BufferSize); + if(Device->PciIo.RomImage == NULL) Status = EFI_OUT_OF_RESOURCES; + else { + MemCpy (Device->PciIo.RomImage, Buffer, BufferSize); + Device->PciIo.RomSize = BufferSize; + Device->Capab |= (EFI_PCI_IO_ATTRIBUTE_EMBEDDED_DEVICE + EFI_PCI_IO_ATTRIBUTE_EMBEDDED_ROM); + Device->Attrib |= (EFI_PCI_IO_ATTRIBUTE_EMBEDDED_DEVICE + EFI_PCI_IO_ATTRIBUTE_EMBEDDED_ROM); + Status = EFI_SUCCESS; + } + } + break; + } + } + } + } + else { + Status = EFI_NOT_FOUND; + } + + if (FvHandles != NULL) { + pBS->FreePool (FvHandles); + FvHandles = NULL; + } + + return Status; +} + + +//************************************************************************* +//************************************************************************* +//** ** +//** (C)Copyright 1985-2012, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//************************************************************************* +//************************************************************************* diff --git a/Board/EM/Platform/EfiCombineImage/EfiCombineImage.cif b/Board/EM/Platform/EfiCombineImage/EfiCombineImage.cif new file mode 100644 index 0000000..3debf25 --- /dev/null +++ b/Board/EM/Platform/EfiCombineImage/EfiCombineImage.cif @@ -0,0 +1,10 @@ +<component> + name = "EFI Combine Image" + category = ModulePart + LocalRoot = "Board\EM\Platform\EfiCombineImage\" + RefName = "EfiCombineImage" +[files] +"EfiCombineImage.sdl" +"EfiCombineImage.mak" +"EfiCombineImage.c" +<endComponent> diff --git a/Board/EM/Platform/EfiCombineImage/EfiCombineImage.mak b/Board/EM/Platform/EfiCombineImage/EfiCombineImage.mak new file mode 100644 index 0000000..a95b067 --- /dev/null +++ b/Board/EM/Platform/EfiCombineImage/EfiCombineImage.mak @@ -0,0 +1,105 @@ +#************************************************************************* +#************************************************************************* +#** ** +#** (C)Copyright 1985-2012, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#************************************************************************* +#************************************************************************* + +#************************************************************************* +# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/Platform/EfiCombineImage/EfiCombineImage.mak 1 12/18/12 11:10p Alanlin $ +# +# $Revision: 1 $ +# +# $Date: 12/18/12 11:10p $ +#************************************************************************* +# Revision History +# ---------------- +# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/Platform/EfiCombineImage/EfiCombineImage.mak $ +# +# 1 12/18/12 11:10p Alanlin +# +# +#************************************************************************* +#<AMI_FHDR_START> +# +# Name: +# +# Description: +# +#<AMI_FHDR_END> +#************************************************************************* +all : EfiCombineImage EfiCombineImage1 EfiCombineImage2 + +EfiCombineImage: \ +!IF "$(NVidia_Optimus_dGPU)" == "1" +$(BUILD_DIR)\EfiCombineImageFile.ffs +!ENDIF + +EfiCombineImage1: \ +!IF "$(AMD_PX_CHELSEA_dGPU)" == "1" +$(BUILD_DIR)\EfiCombineImageFile1.ffs +!ENDIF + +EfiCombineImage2: \ +!IF "$(AMD_PX_THAMES_dGPU)" == "1" +$(BUILD_DIR)\EfiCombineImageFile2.ffs +!ENDIF + +$(BUILD_DIR)\EfiCombineImage.mak : $(EfiCombineImage_DIR)\$(@B).cif $(EfiCombineImage_DIR)\$(@B).mak $(BUILD_RULES) + $(CIF2MAK) $(EfiCombineImage_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS) + +AMI_CSP_LIB_OBJS = $(AMI_CSP_LIB_OBJS) \ +$(BUILD_DIR)\EfiCombineImage.obj + +{$(EfiCombineImage_DIR)}.c{$(BUILD_DIR)}.obj:: + $(CC) $(CFLAGS) /Fo$(BUILD_DIR)\ $< + +$(BUILD_DIR)\EfiCombineImage.obj : $(EfiCombineImage_DIR)\EfiCombineImage.c + +!IF "$(NVidia_Optimus_dGPU)" == "1" +$(BUILD_DIR)\EfiCombineImageFile.ffs : $(EfiCombineImageFile) + $(MAKE) /f Core\FFS.mak \ + BUILD_DIR=$(BUILD_DIR) \ + GUID=$(NVidia_dGPU_MAKFILE_GUID) \ + TYPE=EFI_FV_FILETYPE_FREEFORM \ + BINFILE=$** FFSFILE=$@ COMPRESS=1 NAME=$(**B) +!ENDIF + +!IF "$(AMD_PX_CHELSEA_dGPU)" == "1" +$(BUILD_DIR)\EfiCombineImageFile1.ffs : $(EfiCombineImageFile1) + $(MAKE) /f Core\FFS.mak \ + BUILD_DIR=$(BUILD_DIR) \ + GUID=$(AMD_CHELSEA_MAKFILE_GUID) \ + TYPE=EFI_FV_FILETYPE_FREEFORM \ + BINFILE=$** FFSFILE=$@ COMPRESS=1 NAME=$(**B) +!ENDIF + +!IF "$(AMD_PX_THAMES_dGPU)" == "1" +$(BUILD_DIR)\EfiCombineImageFile2.ffs : $(EfiCombineImageFile2) + $(MAKE) /f Core\FFS.mak \ + BUILD_DIR=$(BUILD_DIR) \ + GUID=$(AMD_THAMES_MAKFILE_GUID) \ + TYPE=EFI_FV_FILETYPE_FREEFORM \ + BINFILE=$** FFSFILE=$@ COMPRESS=1 NAME=$(**B) +!ENDIF + +#************************************************************************* +#************************************************************************* +#** ** +#** (C)Copyright 1985-2012, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#************************************************************************* +#************************************************************************* diff --git a/Board/EM/Platform/EfiCombineImage/EfiCombineImage.sdl b/Board/EM/Platform/EfiCombineImage/EfiCombineImage.sdl new file mode 100644 index 0000000..91ddf21 --- /dev/null +++ b/Board/EM/Platform/EfiCombineImage/EfiCombineImage.sdl @@ -0,0 +1,203 @@ +TOKEN + Name = "EfiCombineImage" + Value = "0" + Help = "Main Switch to Enable Efi Combine Image" + TokenType = Boolean + TargetEQU = Yes + TargetMAK = Yes + TargetH = Yes + Master = Yes +End + +TOKEN + Name = "NVidia_Optimus_dGPU" + Value = "1" + TokenType = Boolean + TargetMAK = Yes + TargetH = Yes +End + +TOKEN + Name = "AMD_PX_CHELSEA_dGPU" + Value = "1" + TokenType = Boolean + TargetMAK = Yes + TargetH = Yes +End + +TOKEN + Name = "AMD_PX_THAMES_dGPU" + Value = "1" + TokenType = Boolean + TargetMAK = Yes + TargetH = Yes +End + +TOKEN + Name = "NVidia_dGPU_DID" + Value = "0x0FD2" + TokenType = Integer + TargetMAK = Yes + TargetH = Yes + Token = "NVidia_Optimus_dGPU" "=" "1" +End + +TOKEN + Name = "NVidia_dGPU_MAKFILE_GUID" + Value = "C5D7EAAD-B218-482c-A909-E3B8CDB00E94" + TokenType = Expression + TargetMAK = Yes + TargetH = Yes + Range = "GUID" + Token = "NVidia_Optimus_dGPU" "=" "1" +End + +TOKEN + Name = "NVidia_dGPU_HEADER_GUID" + Value = "{0xC5D7EAAD,0xB218,0x482c,0xA9,0x09,0xE3,0xB8,0xCD,0xB0,0x0E,0x94}" + TokenType = Expression + TargetMAK = Yes + TargetH = Yes + Range = "GUID" + Token = "NVidia_Optimus_dGPU" "=" "1" +End + +TOKEN + Name = "AMD_CHELSEA_DID" + Value = "0x682F" + TokenType = Integer + TargetMAK = Yes + TargetH = Yes + Token = "AMD_PX_CHELSEA_dGPU" "=" "1" +End + +TOKEN + Name = "AMD_CHELSEA_MAKFILE_GUID" + Value = "B9C6D5AB-5914-4b1b-B33D-B10D9D0075BE" + TokenType = Expression + TargetMAK = Yes + TargetH = Yes + Range = "GUID" + Token = "AMD_PX_CHELSEA_dGPU" "=" "1" +End + +TOKEN + Name = "AMD_CHELSEA_HEADER_GUID" + Value = "{0XB9C6D5AB,0X5914,0X4b1b,0XB3,0X3D,0XB1,0X0D,0X9D,0X00,0X75,0XBE}" + TokenType = Expression + TargetMAK = Yes + TargetH = Yes + Range = "GUID" + Token = "AMD_PX_CHELSEA_dGPU" "=" "1" +End + +TOKEN + Name = "AMD_THAMES_DID" + Value = "0x6840" + TokenType = Integer + TargetMAK = Yes + TargetH = Yes + Token = "AMD_PX_THAMES_dGPU" "=" "1" +End + +TOKEN + Name = "AMD_THAMES_MAKFILE_GUID" + Value = "633657DB-777F-4038-8D72-3E581518E03A" + TokenType = Expression + TargetMAK = Yes + TargetH = Yes + Range = "GUID" + Token = "AMD_PX_THAMES_dGPU" "=" "1" +End + +TOKEN + Name = "AMD_THAMES_HEADER_GUID" + Value = "{0X633657DB,0X777F,0X4038,0X8D,0X72,0X3E,0X58,0X15,0X18,0XE0,0X3A}" + TokenType = Expression + TargetMAK = Yes + TargetH = Yes + Range = "GUID" + Token = "AMD_PX_THAMES_dGPU" "=" "1" +End + +TOKEN + Name = "EfiCombineImageFile" + Value = "Chipset\NB\GOP\SandyBridge\vbt_edp.bin" + Help = "It is a sample, please modify to your VGA Oprom path." + TokenType = Expression + TargetMAK = Yes + Token = "NVidia_Optimus_dGPU" "=" "1" +End + +TOKEN + Name = "EfiCombineImageFile1" + Value = "Chipset\NB\GOP\SandyBridge\vbt_edp.bin" + Help = "It is a sample, please modify to your VGA Oprom path." + TokenType = Expression + TargetMAK = Yes + Token = "AMD_PX_CHELSEA_dGPU" "=" "1" +End + +TOKEN + Name = "EfiCombineImageFile2" + Value = "Chipset\NB\GOP\SandyBridge\vbt_edp.bin" + Help = "It is a sample, please modify to your VGA Oprom path." + TokenType = Expression + TargetMAK = Yes + Token = "AMD_PX_THAMES_dGPU" "=" "1" +End + +PATH + Name = "EfiCombineImage_DIR" +End + +MODULE + Help = "Includes EfiCombineImage.mak to Project" + File = "EfiCombineImage.mak" +End + +ELINK + Name = "OEM_PCI_DEVICE_CALLBACK(0x10DE, NVidia_dGPU_DID, GetEfiCombineImage)," + Parent = "OEM_PCI_DEVICE_GET_OPT_ROM" + Help = "It is a sample(Nvidia Optims), please change DID and VID depend on your device." + Token = "NVidia_Optimus_dGPU" "=" "1" + InvokeOrder = AfterParent +End + +ELINK + Name = "OEM_PCI_DEVICE_CALLBACK(0x1002, AMD_CHELSEA_DID, GetEfiCombineImage)," + Parent = "OEM_PCI_DEVICE_GET_OPT_ROM" + Help = "It is a sample(AMD Chelsea), please change DID and VID depend on your device." + Token = "AMD_PX_CHELSEA_dGPU" "=" "1" + InvokeOrder = AfterParent +End + +ELINK + Name = "OEM_PCI_DEVICE_CALLBACK(0x1002, AMD_THAMES_DID, GetEfiCombineImage)," + Parent = "OEM_PCI_DEVICE_GET_OPT_ROM" + Help = "It is a sample(AMD Thames), please change DID and VID depend on your device." + Token = "AMD_PX_THAMES_dGPU" "=" "1" + InvokeOrder = AfterParent +End + +ELINK + Name = "$(BUILD_DIR)\EfiCombineImageFile.ffs" + Parent = "FV_MAIN" + Token = "NVidia_Optimus_dGPU" "=" "1" + InvokeOrder = AfterParent +End + +ELINK + Name = "$(BUILD_DIR)\EfiCombineImageFile1.ffs" + Parent = "FV_MAIN" + Token = "AMD_PX_CHELSEA_dGPU" "=" "1" + InvokeOrder = AfterParent +End + +ELINK + Name = "$(BUILD_DIR)\EfiCombineImageFile2.ffs" + Parent = "FV_MAIN" + Token = "AMD_PX_THAMES_dGPU" "=" "1" + InvokeOrder = AfterParent +End + |