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/SwitchableGraphics/SgTpv/MXM30 | |
download | zprj-b7c51c9cf4864df6aabb99a1ae843becd577237c.tar.xz |
Diffstat (limited to 'Board/EM/SwitchableGraphics/SgTpv/MXM30')
-rw-r--r-- | Board/EM/SwitchableGraphics/SgTpv/MXM30/MXM30.cif | 18 | ||||
-rw-r--r-- | Board/EM/SwitchableGraphics/SgTpv/MXM30/MXM30.mak | 161 | ||||
-rw-r--r-- | Board/EM/SwitchableGraphics/SgTpv/MXM30/MXM30.sdl | 135 | ||||
-rw-r--r-- | Board/EM/SwitchableGraphics/SgTpv/MXM30/Mxm30Dxe.c | 377 | ||||
-rw-r--r-- | Board/EM/SwitchableGraphics/SgTpv/MXM30/Mxm30Dxe.dxs | 105 | ||||
-rw-r--r-- | Board/EM/SwitchableGraphics/SgTpv/MXM30/Mxm30Efi.c | 425 | ||||
-rw-r--r-- | Board/EM/SwitchableGraphics/SgTpv/MXM30/Mxm30ElkCreek4.mxm | bin | 0 -> 102 bytes | |||
-rw-r--r-- | Board/EM/SwitchableGraphics/SgTpv/MXM30/Mxm30ElkCreekIII.mxm | bin | 0 -> 85 bytes | |||
-rw-r--r-- | Board/EM/SwitchableGraphics/SgTpv/MXM30/MxmInt15.asm | 553 | ||||
-rw-r--r-- | Board/EM/SwitchableGraphics/SgTpv/MXM30/NBCIEfi.c | 367 |
10 files changed, 2141 insertions, 0 deletions
diff --git a/Board/EM/SwitchableGraphics/SgTpv/MXM30/MXM30.cif b/Board/EM/SwitchableGraphics/SgTpv/MXM30/MXM30.cif new file mode 100644 index 0000000..02fd8c4 --- /dev/null +++ b/Board/EM/SwitchableGraphics/SgTpv/MXM30/MXM30.cif @@ -0,0 +1,18 @@ +<component> + name = "Sg nVidia API" + category = ModulePart + LocalRoot = "Board\EM\SwitchableGraphics\SgTpv\MXM30" + RefName = "MXM_NBCI" +[files] +"MXM30.sdl" +"MXM30.mak" +"Mxm30Dxe.dxs" +"Mxm30Dxe.c" +"Mxm30Efi.c" +"NBCIEfi.c" +"MxmInt15.asm" +"Mxm30ElkCreek4.mxm" +"Mxm30ElkCreekIII.mxm" +[parts] +"MXM_Protocol" +<endComponent> diff --git a/Board/EM/SwitchableGraphics/SgTpv/MXM30/MXM30.mak b/Board/EM/SwitchableGraphics/SgTpv/MXM30/MXM30.mak new file mode 100644 index 0000000..2ac9f97 --- /dev/null +++ b/Board/EM/SwitchableGraphics/SgTpv/MXM30/MXM30.mak @@ -0,0 +1,161 @@ +#************************************************************************* +#************************************************************************* +#** ** +#** (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/SwitchableGraphics/Sg TPV/Sg nVidia API/MXM30.mak 2 9/09/12 11:12p Joshchou $ +# +# $Revision: 2 $ +# +# $Date: 9/09/12 11:12p $ +#************************************************************************* +# Revision History +# ---------------- +# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/SwitchableGraphics/Sg TPV/Sg nVidia API/MXM30.mak $ +# +# 2 9/09/12 11:12p Joshchou +# [TAG] None +# [Category] Improvement +# [Description] Tpv module support for sharkbay. +# [Files] MXM30.mak +# Mxm30Dxe.dxs +# Mxm30Dxe.c +# Mxm30Efi.c +# NBCIEfi.c +# MxmInt15.asm +# MXM30.cif +# +# 1 6/27/11 5:25a Alanlin +# [TAG] EIP61848 +# [Category] New Feature +# [Description] Initial check-in.Integrated SwitchableGraphics Intel +# Reference code 0.6.0 +# [Files] MXM30.cif +# MXM30.sdl +# MXM30.mak +# Mxm30Dxe.dxs +# Mxm30Dxe.c +# Mxm30Efi.c +# NBCIEfi.c +# MxmInt15.asm +# Mxm30ElkCreek4.mxm +# Mxm30ElkCreekIII.mxm +# +# +# 2 9/23/10 1:04p Alexp +# change the build target +# +# 1 9/17/10 1:15p Alexp +# [TAG] EIP43103 +# [Category] Function Request +# [Severity] Normal +# [Symptom] Initial check-in of SgTPV module +# [RootCause] Request to implement SG reference code . +# [Solution] Initial check-in. +# [Files] +# Mxm30.cif;*.sdl;*.mak; +# Mxm30Dxe.c;*.dxs +# Mxm30efi.c +# MxmInt15.asm +# NbciEfi.c +# Mxm30ElkCreek3(4).mxm +# +#************************************************************************* +#<AMI_FHDR_START> +# +# Name: MXM30.mak +# +# Description: Make file to build Switchable Graphics MXM component +# +#<AMI_FHDR_END> +#************************************************************************* +SgTpv: MXM30 + +MXM30 : $(BUILD_DIR)\MXM30.mak Mxm30DxeBin $(BUILD_DIR)\MXMdat.ffs + +$(BUILD_DIR)\MXM30.mak : $(MXM30_DIR)\MXM30.cif $(MXM30_DIR)\MXM30.mak $(BUILD_RULES) + $(CIF2MAK) $(MXM30_DIR)\MXM30.cif $(CIF2MAK_DEFAULTS) + +#-------------------------------------------------------------------------- +# 1. +#-------------------------------------------------------------------------- +BUILD_MXM_DIR = $(BUILD_DIR)\$(MXM30_DIR) + +##SGDxeBin : $(BUILD_MXM_DIR)\Mxm30Efi.obj $(BUILD_MXM_DIR)\NbciEfi.obj +#SGDxeBin : $(BUILD_MXM_DIR)\Mxm30Efi.obj + +##$(BUILD_MXM_DIR)\Mxm30Efi.obj $(BUILD_MXM_DIR)\NbciEfi.obj: $(MXM30_DIR)\Mxm30Efi.c $(MXM30_DIR)\NbciEfi.c +#$(BUILD_MXM_DIR)\Mxm30Efi.obj: $(MXM30_DIR)\Mxm30Efi.c +# $(CC) $(CFLAGS) $(MXM_INCLUDES) /I$(MXM30_DIR) /Fo$@ $(MXM30_DIR)\$(@F) + +MXM_DXE_OBJECTS = \ +$(BUILD_MXM_DIR)\Mxm30Dxe.obj\ +$(BUILD_MXM_DIR)\Mxm30Efi.obj\ + +#$(BUILD_MXM_DIR)\Nbci.obj\ + +MXM_INCLUDES= \ + /I $(MXM30_DIR)\ + /I$(CORE_DIR)\ + $(INTEL_MPG_INCLUDES)\ + $(INTEL_MCH_INCLUDES)\ + $(INTEL_PCH_INCLUDES)\ + /I$(NB_BOARD_DIR)\ + /I$(SB_BOARD_DIR) + +Mxm30DxeBin : $(AMIDXELIB) $(AMICSPLib) + $(MAKE) /$(MAKEFLAGS) $(BUILD_DEFAULTS)\ + /f $(BUILD_DIR)\MXM30.mak all\ + NAME=Mxm30Dxe\ + MAKEFILE=$(BUILD_DIR)\MXM30.mak \ + GUID=31A0B6EF-A400-4419-8327-0FB134AA59E7 \ + ENTRY_POINT=MxmDriverEntryPoint\ + DEPEX1=$(MXM30_DIR)\Mxm30Dxe.DXS DEPEX1_TYPE=EFI_SECTION_DXE_DEPEX\ + "MY_INCLUDES=$(MXM_INCLUDES)"\ + "OBJECTS=$(MXM_DXE_OBJECTS)"\ + TYPE=RT_DRIVER\ + COMPRESS=1 + +#-------------------------------------------------------------------------- +# 2. +#-------------------------------------------------------------------------- +$(BUILD_DIR)\MXMint15.obj: $(MXM30_DIR)\MXMint15.asm + $(ASM16) $(AFLAGS16) /Fo$(BUILD_DIR)\ $(MXM30_DIR)\$(@B).asm + +#-------------------------------------------------------------------------- +# 3. +#--------------------------------------------------------------------------- +# Build Mxm block file. In case external utils want to update Mxm +# Don't change the GUID. LocateMXMffs expects this GUID. +#--------------------------------------------------------------------------- +$(BUILD_DIR)\MXMdat.ffs : $(MXM30_DIR)\$(MXM_FILE_NAME) + $(MAKE) /f Core\FFS.mak \ + NAME=$(@B) \ + BUILD_DIR=$(BUILD_DIR) SOURCE_DIR=$(MXM30_DIR) \ + GUID=6707536E-46AF-42d3-8F6C-15F2F202C234 \ + TYPE=EFI_FV_FILETYPE_FREEFORM \ + BINFILE=$** FFSFILE=$@ COMPRESS=1 NAME=$(**B) + +#************************************************************************* +#************************************************************************* +#** ** +#** (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/SwitchableGraphics/SgTpv/MXM30/MXM30.sdl b/Board/EM/SwitchableGraphics/SgTpv/MXM30/MXM30.sdl new file mode 100644 index 0000000..9562308 --- /dev/null +++ b/Board/EM/SwitchableGraphics/SgTpv/MXM30/MXM30.sdl @@ -0,0 +1,135 @@ +TOKEN + Name = "MXM30_SUPPORT" + Value = "1" + Help = "Main switch to enable MXM30 Legacy int15, Efi and Acpi interfaces" + TokenType = Boolean + TargetEQU = Yes + TargetMAK = Yes + TargetH = Yes + Master = Yes +End + +TOKEN + Name = "MXM_REVISION" + Value = "3" + Help = "1: Support MXM rev2.0, 2: Support MXM rev2.1, 3: Support MXM rev3.0." + TokenType = Integer + TargetEQU = Yes + TargetMAK = Yes +End + +TOKEN + Name = "MXM_REV_SUPPORTED" + Value = "30h" + Help = "the revision of the MXM software specification that is supported by the MXM module\Format is binary coded decimal, for example: 0x30 = 3.0, etc." + TokenType = Integer + TargetEQU = Yes + TargetH = Yes +End + +TOKEN + Name = "MXM_FUNC_SUPPORTED" + Value = "3" + Help = "the bit map of function list supported by the MXM module\Bit 0 = `1' MxmReturnSpecLevel method is required\Bit 1 = `1' MxmReturnStucture is also required" + TokenType = Integer + TargetEQU = Yes + TargetH = Yes +End + +TOKEN + Name = "NBCI_REVISION" + Value = "1" + Help = "1: Support NBCI rev1.1" + TokenType = Integer + TargetEQU = Yes + TargetMAK = Yes +End + +TOKEN + Name = "NBCI_REV_SUPPORTED" + Value = "11h" + Help = "the revision of the NBCI software specification that is supported by the NBCI module\Format is binary coded decimal, for example: 0x11 = 1.1, etc." + TokenType = Integer + TargetEQU = Yes + TargetH = Yes +End + +TOKEN + Name = "NBCI_FUNC_SUPPORTED" + Value = "3" + Help = "the bit map of function list supported by the Nbci module\Bit 0 = `1' NbciReturnSpecLevel method is required\Bit 1 = `1' NbciReturnStucture is also required" + TokenType = Integer + TargetEQU = Yes + TargetH = Yes +End + +TOKEN + Name = "MXM_ROM_MAX_SIZE" + Value = "200" + Help = "Max size of MXM module data structure" + TokenType = Integer + TargetEQU = Yes + TargetH = Yes +End + +TOKEN + Name = "MXM_ROM_MAX_SIZE_bits" + Value = "$(MXM_ROM_MAX_SIZE)*8" + Help = "Max size of MXM module data structure 1600" + TokenType = Integer + TargetH = Yes +End + +TOKEN + Name = "MXMOEM1_GUID" + Value = "{0x6707536e, 0x46af, 0x42d3, 0x8f, 0x6c, 0x15, 0xf2, 0xf2, 0x2, 0xc2, 0x34}" + Help = "MXM module FFS file" + TokenType = Expression + TargetH = Yes +End + +TOKEN + Name = "MXM_FILE_NAME" + Value = "Mxm30ElkCreek4.mxm" + Help = "MXM module file name" + TokenType = Expression + TargetMAK = Yes +End + +PATH + Name = "MXM30_DIR" + Help = "Path to MXM30 Module in Project" +End + +MODULE + Help = "Includes MXM30.mak to Project" + File = "MXM30.mak" +End + +ELINK + Name = "$(BUILD_DIR)\mxmint15.obj" + Parent = "CSM_OEMINT_OBJS" + Priority = 10 + InvokeOrder = AfterParent +End + +ELINK + Name = "MXMINT15Proc" + Parent = "CsmOemInterrupts" + ProcID = 015h + SrcFile = "Board\em\mxm30\mxmint15.asm" + InvokeOrder = AfterParent +End + +ELINK + Name = "$(BUILD_DIR)\Mxm30Dxe.ffs" + Parent = "FV_MAIN" + InvokeOrder = AfterParent +End + +ELINK + Name = "$(BUILD_DIR)\MXMdat.ffs" + Parent = "FV_MAIN" + InvokeOrder = AfterParent +End + diff --git a/Board/EM/SwitchableGraphics/SgTpv/MXM30/Mxm30Dxe.c b/Board/EM/SwitchableGraphics/SgTpv/MXM30/Mxm30Dxe.c new file mode 100644 index 0000000..83ec3e6 --- /dev/null +++ b/Board/EM/SwitchableGraphics/SgTpv/MXM30/Mxm30Dxe.c @@ -0,0 +1,377 @@ +//********************************************************************** +//********************************************************************** +//** ** +//** (C)Copyright 1985-2012, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Pkwy, Suite 200, Norcross, GA 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//********************************************************************** +//********************************************************************** +//********************************************************************** +// $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/SwitchableGraphics/Sg TPV/Sg nVidia API/Mxm30Dxe.c 2 9/09/12 11:12p Joshchou $ +// +// $Revision: 2 $ +// +// $Date: 9/09/12 11:12p $ +//********************************************************************** +// Revision History +// ---------------- +// $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/SwitchableGraphics/Sg TPV/Sg nVidia API/Mxm30Dxe.c $ +// +// 2 9/09/12 11:12p Joshchou +// [TAG] None +// [Category] Improvement +// [Description] Tpv module support for sharkbay. +// [Files] MXM30.mak +// Mxm30Dxe.dxs +// Mxm30Dxe.c +// Mxm30Efi.c +// NBCIEfi.c +// MxmInt15.asm +// MXM30.cif +// +// 3 4/11/12 4:06a Alanlin +// Nvidia Optimus support when CSM module is disabled or CSM is never on +// setup menu. +// +// 2 12/12/11 9:19p Alanlin +// [TAG] EIP74169 +// [Category] Improvement +// [Description] Add OEMSSDT module part. Token "SGOEMSSDT_SUPPORT" to +// create OEM SSDT for discrete VGA card. +// When Primarydisplay = Auto or PEG, it can report OEM SSDT talbes for +// AMD or nVidia dGPU VGA card. +// +// 1 6/27/11 5:25a Alanlin +// [TAG] EIP61848 +// [Category] New Feature +// [Description] Initial check-in.Integrated SwitchableGraphics Intel +// Reference code 0.6.0 +// [Files] MXM30.cif +// MXM30.sdl +// MXM30.mak +// Mxm30Dxe.dxs +// Mxm30Dxe.c +// Mxm30Efi.c +// NBCIEfi.c +// MxmInt15.asm +// Mxm30ElkCreek4.mxm +// Mxm30ElkCreekIII.mxm +// +// +// 2 9/23/10 1:04p Alexp +// comment out unused BDS callback defines +// +// 1 9/17/10 1:16p Alexp +// [TAG] EIP43103 +// [Category] Function Request +// [Severity] Normal +// [Symptom] Initial check-in of SgTPV module +// [RootCause] Request to implement SG reference code . +// [Solution] Initial check-in. +// [Files] +// Mxm30.cif;*.sdl;*.mak; +// Mxm30Dxe.c;*.dxs +// Mxm30efi.c +// MxmInt15.asm +// NbciEfi.c +// Mxm30ElkCreek3(4).mxm +// +//********************************************************************** +//<AMI_FHDR_START> +//---------------------------------------------------------------------------- +// +// Name: Mxm30DXE.c +// +// Description: This file contains the etry point of EFI MXM30 Support driver +// The function istalls MXM EFI, Legacy and Acpi interfaces if +// enabled in Setup +// Installs Acpi Tables for Switchable Graphics +// +// Notes: MAKE SURE NO PEI OR DXE SPECIFIC CODE IS NEEDED +// +//---------------------------------------------------------------------------- +//<AMI_FHDR_END> +#include <Token.h> +#include <AmiDxeLib.h> +#include <DXE.h> +#include "SB.h" +#include "Setup.h" +#include <Protocol\Mxm30.h> +#if defined(CsmOptOut_SUPPORT) && (CsmOptOut_SUPPORT == 1) +#include <AmiLoadCsmPolicy.h> +#endif + +#if ( defined(CSM_SUPPORT) && (CSM_SUPPORT != 0) ) +#include <Protocol\LegacyBios.h> +#include <Protocol\LegacyRegion.h> +#include <Protocol\LegacyBiosExt.h> +#endif +#if defined(CsmOptOut_SUPPORT) && (CsmOptOut_SUPPORT == 1) +AMI_OPROM_POLICY_PROTOCOL *gAmiOpRomPolicyProtocol = NULL; +EFI_GUID gAmiOpromPolicyProtocolGuid = AMI_OPROM_POLICY_PROTOCOL_GUID; +#endif + +extern EFI_BOOT_SERVICES *pBS; +extern EFI_RUNTIME_SERVICES *pRS; + +VOID *gMxmLegMemAddr = NULL; +UINTN gMxmLegMemSize = 0; + +//#define BDS_ALL_DRIVERS_CONNECTED_PROTOCOL_GUID \ +// {0xdbc9fd21, 0xfad8, 0x45b0, 0x9e, 0x78, 0x27, 0x15, 0x88, 0x67, 0xcc, 0x93} + +//EFI_EVENT mMxmEvent; +//VOID *mMxmReg; +//EFI_GUID gBdsAllDriversConnectedProtocolGuid = BDS_ALL_DRIVERS_CONNECTED_PROTOCOL_GUID; + +// extern functions +EFI_STATUS MXM30Interfaces (EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable); +//EFI_STATUS NBCIInterfaces (EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable); + +#if ( defined(CSM_SUPPORT) && (CSM_SUPPORT != 0) ) +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: UpdateInt15MxMData +// +// Description: Get the address of MXM data buffer in legacy bios region +// +// Input: EFI_LEGACY_BIOS_PROTOCOL *LegacyBiosProtocol; +// +// +// Output: EFI_STATUS +// +// Modified: +// +// Referrals: +// +// Notes: +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +EFI_STATUS +UpdateInt15MxmSISData ( + IN EFI_LEGACY_BIOS_PROTOCOL *LegacyBiosProtocol +) +{ + EFI_STATUS Status; + UINT32 Addr16; + EFI_IA32_REGISTER_SET RegSet; + UINT32 *ivt = (UINT32*)0; + + // Get the Data Pointer to MXM Structure within Int15 MXM handler + MemSet(&RegSet, sizeof (EFI_IA32_REGISTER_SET), 0); + RegSet.X.AX = 0x5f80; + RegSet.X.BX = 0xFF01; + RegSet.X.CX = EFI30_DataBlockID; + RegSet.X.ES = 0; + RegSet.X.DI = 0; + Addr16 = ivt[0x15]; + Status = LegacyBiosProtocol->FarCall86 (LegacyBiosProtocol, + (UINT16)(Addr16 >> 16), + (UINT16)Addr16, + &RegSet, 0, 0); + Status = (RegSet.X.AX == 0x5F80 || RegSet.X.ES == 0)? EFI_UNSUPPORTED : EFI_SUCCESS; + ASSERT_EFI_ERROR(Status); + +// return updated address + gMxmLegMemAddr = (UINT8*)((RegSet.X.ES << 4) + (RegSet.X.DI)); + +// TO DO. Expand the routine to obtain the address of _DOD buffer(MXM Int15 5f80, Func 9) + + return Status; +} +#endif + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: MxmDriverEntryPoint +// +// Description: Entry point of EFI MXM Support driver. The function istalls +// 1. Install MXM protocol; +// 2. Update data structure to be passed to Int15 binary +// must support multiple MXM data modules. Dependent on controller's handle +// Load MXM data block <1Mb area. +// a. Copy MXM Structure below 1MB +// 1. Allocate Legacy mem space for MXM dat <1MB +// OR +// 2. Update the MXM data by the pointer returned by Int15 5F80 Func01(default) +// b. Update the pointer to MXM data in EFI Protocol API +// c. Create an ACPI SSDT table and copy MXM block there (ASL MXM logic must handle different MXM modules...) +// +// Input: EFI_HANDLE ImageHandle, +// EFI_SYSTEM_TABLE *SystemTable +// +// Output: EFI_STATUS +// +// Modified: +// +// Referrals: +// +// Notes: +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +EFI_STATUS +MxmDriverEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable +) +{ + EFI_STATUS Status = EFI_SUCCESS; + SETUP_DATA SetupData; + EFI_GUID SetupGuid = SETUP_GUID;//SYSTEM_CONFIGURATION_GUID; + EFI_GUID EfiMxmStructGuid = MXMOEM1_GUID; +// MXM_STRUCT_HDR *MxmHdr; + +#if ( defined(CSM_SUPPORT) && (CSM_SUPPORT != 0) ) + EFI_LEGACY_BIOS_EXT_PROTOCOL *BiosExtensions = NULL; + EFI_LEGACY_BIOS_PROTOCOL *LegacyBiosProtocol = NULL; +#endif + VOID *MxmData; + UINTN ImageSize, Size; +#if ( defined(CSM_SUPPORT) && (CSM_SUPPORT != 0) ) + UINT32 LockUnlockAddr, LockUnlockSize; +#endif + EFI_STATUS CsmOptOutStatus = EFI_SUCCESS; + + InitAmiLib(ImageHandle, SystemTable); + TRACE((-1, "==============MxmDriverEntryPoint============\n")); + // + // Check if the module is enabled in Setup; if not - return EFI_UNSUPPORTED + // + Size = sizeof(SETUP_DATA); + Status = pRS->GetVariable(L"Setup", + &SetupGuid, + NULL, + &Size, + &SetupData); + if (EFI_ERROR(Status)) return Status; + + // Check to see if Primary Display is set to enable SG + // + if ((SetupData.PrimaryDisplay == 1)|| //PEG + (SetupData.PrimaryDisplay == 3)|| //AUTO + (SetupData.PrimaryDisplay == 4)) //SG + { } + else + return EFI_UNSUPPORTED; +#if ( defined(CSM_SUPPORT) && (CSM_SUPPORT != 0) ) + #if defined(CsmOptOut_SUPPORT) && (CsmOptOut_SUPPORT == 1) + CsmOptOutStatus = pBS->LocateProtocol(&gAmiOpromPolicyProtocolGuid, NULL, &gAmiOpRomPolicyProtocol); + #endif + if (!EFI_ERROR(CsmOptOutStatus)){ + Status = pBS->LocateProtocol(&gEfiLegacyBiosProtocolGuid, NULL, &LegacyBiosProtocol); + if (EFI_ERROR(Status)) return Status; + + Status = pBS->LocateProtocol(&gEfiLegacyBiosExtProtocolGuid, NULL, &BiosExtensions); + if (EFI_ERROR(Status)) return Status; + } +#endif +// TBD. Proper Mxm structure block can be loaded based on matching dGPU's PCI Dev`ice/Vendor ID with the file Guid +// e.g. EfiMxmStructGuid = Nvidia Mxm, AMD Mxm etc. +// Also, multiple Mxm structure can be loaded if design supports 2 or more Mxm cards plugged in simultaneusly +// Latter scenario will require MxmInt15.asm changes + + Status = LoadFile(&EfiMxmStructGuid, &MxmData, &ImageSize); + ASSERT_EFI_ERROR(Status); + if (EFI_ERROR(Status)) return Status; + // just in case we'll need to change MXM data + // MxmHdr = (MXM_STRUCT_HDR*)MxmData; + // if(Strcmp(MxmHdr->Sig,"*MXM_")) + // return EFI_UNSUPPORTED; + + gMxmLegMemAddr = (UINT8*)0xE0000; + Size = 0x20000; + +#if ( defined(CSM_SUPPORT) && (CSM_SUPPORT != 0) ) + if (!EFI_ERROR(CsmOptOutStatus)){ + BiosExtensions->UnlockShadow( + (UINT8*)gMxmLegMemAddr, Size, + &LockUnlockAddr, &LockUnlockSize); + } +#endif + + gMxmLegMemAddr = MxmData; + // Int15 may update gMxmLegMemAddr +#if ( defined(CSM_SUPPORT) && (CSM_SUPPORT != 0) ) + if (!EFI_ERROR(CsmOptOutStatus)){ + // will copy MXM struct to the address returned by Int15 5F80, Func01 + Status = UpdateInt15MxmSISData(LegacyBiosProtocol); + if (EFI_ERROR(Status)) { + return Status; + } +/* +#else + // + // Allocate MXM and E000:0 area + // + Address = 0xE0000; + Status = pBS->AllocatePages ( + AllocateAddress, + EfiBootServicesCode, + ImageSize, + &gMxmLegMemAddr); +#endif +*/ + if (EFI_ERROR(Status)) { + BiosExtensions->LockShadow(LockUnlockAddr, LockUnlockSize); + return Status; + } + + gMxmLegMemSize = ImageSize; + // + // Copy the image into the shadow. + // + pBS->CopyMem(gMxmLegMemAddr, MxmData, gMxmLegMemSize); + + BiosExtensions->LockShadow(LockUnlockAddr, LockUnlockSize); + + } // (!EFI_ERROR(CsmOptOutStatus)) +#endif // ( defined(CSM_SUPPORT) && (CSM_SUPPORT != 0) ) +// Install NBCI & MXM3_EFI_PROTOCOL only if Primary Display is set to enable SG +#if SGOEMSSDT_SUPPORT + if ((SetupData.PrimaryDisplay == 4) || (SetupData.PrimaryDisplay == 1) || (SetupData.PrimaryDisplay == 3)) //SG +#else + if (SetupData.PrimaryDisplay == 4) //SG +#endif + { + +// Install NBCI_EFI_PROTOCOL, Int15 5F80 handle +// Status = NBCIInterfaces(ImageHandle, SystemTable); +// Install MXM_EFI_PROTOCOL, Int15 5F80 handle + Status = MXM30Interfaces(ImageHandle, SystemTable); + ASSERT_EFI_ERROR (Status); + if (EFI_ERROR(Status)) return Status; + +// wait till Mxm PEG Card is enumerated in BDS +/* + Status = RegisterProtocolCallback( + &gBdsAllDriversConnectedProtocolGuid, + // Function is linked from MxmAcpiTable.c. Contains OEM implementation for Mxm Acpi table load + LoadAcpiTables, + NULL, + &mMxmEvent, + &mMxmReg + ); + +*/ + } + return Status; +} + +//********************************************************************** +//********************************************************************** +//** ** +//** (C)Copyright 1985-2012, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Pkwy, Suite 200, Norcross, GA 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//********************************************************************** +//********************************************************************** diff --git a/Board/EM/SwitchableGraphics/SgTpv/MXM30/Mxm30Dxe.dxs b/Board/EM/SwitchableGraphics/SgTpv/MXM30/Mxm30Dxe.dxs new file mode 100644 index 0000000..a4ef880 --- /dev/null +++ b/Board/EM/SwitchableGraphics/SgTpv/MXM30/Mxm30Dxe.dxs @@ -0,0 +1,105 @@ +//**************************************************************************** +//**************************************************************************** +//** ** +//** (C)Copyright 1985-2012, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Pkwy, Suite 200, Norcross, GA 30093 ** +//** ** +//** Phone (770)-246-8600 ** +//** ** +//**************************************************************************** +//**************************************************************************** +//********************************************************************** +// $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/SwitchableGraphics/Sg TPV/Sg nVidia API/Mxm30Dxe.dxs 2 9/09/12 11:12p Joshchou $ +// +// $Revision: 2 $ +// +// $Date: 9/09/12 11:12p $ +//********************************************************************** +// Revision History +// ---------------- +// $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/SwitchableGraphics/Sg TPV/Sg nVidia API/Mxm30Dxe.dxs $ +// +// 2 9/09/12 11:12p Joshchou +// [TAG] None +// [Category] Improvement +// [Description] Tpv module support for sharkbay. +// [Files] MXM30.mak +// Mxm30Dxe.dxs +// Mxm30Dxe.c +// Mxm30Efi.c +// NBCIEfi.c +// MxmInt15.asm +// MXM30.cif +// +// 2 4/11/12 4:07a Alanlin +// Nvidia Optimus support when CSM module is disabled or CSM is never on +// setup menu. +// +// 1 6/27/11 5:25a Alanlin +// [TAG] EIP61848 +// [Category] New Feature +// [Description] Initial check-in.Integrated SwitchableGraphics Intel +// Reference code 0.6.0 +// [Files] MXM30.cif +// MXM30.sdl +// MXM30.mak +// Mxm30Dxe.dxs +// Mxm30Dxe.c +// Mxm30Efi.c +// NBCIEfi.c +// MxmInt15.asm +// Mxm30ElkCreek4.mxm +// Mxm30ElkCreekIII.mxm +// +// +// 1 9/17/10 1:16p Alexp +// [TAG] EIP43103 +// [Category] Function Request +// [Severity] Normal +// [Symptom] Initial check-in of SgTPV module +// [RootCause] Request to implement SG reference code . +// [Solution] Initial check-in. +// [Files] +// Mxm30.cif;*.sdl;*.mak; +// Mxm30Dxe.c;*.dxs +// Mxm30efi.c +// MxmInt15.asm +// NbciEfi.c +// Mxm30ElkCreek3(4).mxm +// +// 2 6/03/10 3:08p Alexp +// +// 1 6/03/10 2:54p Alexp +// +//********************************************************************** +#include <Token.h> +#include <protocol\PciRootBridgeIo.h> +#include <protocol\AcpiSupport.h> +#if ( defined(CSM_SUPPORT) && (CSM_SUPPORT != 0) ) +#include <Protocol\CsmPlatform.h> +#endif + +DEPENDENCY_START +#if ( defined(CSM_SUPPORT) && (CSM_SUPPORT != 0) ) + AMI_CSM_DRIVER_STARTED_GUID AND +#endif + EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_GUID AND + EFI_ACPI_SUPPORT_GUID +DEPENDENCY_END + +//**************************************************************************** +//**************************************************************************** +//** ** +//** (C)Copyright 1985-2012, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Pkwy, Suite 200, Norcross, GA 30093 ** +//** ** +//** Phone (770)-246-8600 ** +//** ** +//**************************************************************************** +//****************************************************************************
\ No newline at end of file diff --git a/Board/EM/SwitchableGraphics/SgTpv/MXM30/Mxm30Efi.c b/Board/EM/SwitchableGraphics/SgTpv/MXM30/Mxm30Efi.c new file mode 100644 index 0000000..b0aa207 --- /dev/null +++ b/Board/EM/SwitchableGraphics/SgTpv/MXM30/Mxm30Efi.c @@ -0,0 +1,425 @@ +//********************************************************************** +//********************************************************************** +//** ** +//** (C)Copyright 1985-2012, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Pkwy, Suite 200, Norcross, GA 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//********************************************************************** +//********************************************************************** +//********************************************************************** +// $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/SwitchableGraphics/Sg TPV/Sg nVidia API/Mxm30Efi.c 2 9/09/12 11:12p Joshchou $ +// +// $Revision: 2 $ +// +// $Date: 9/09/12 11:12p $ +//********************************************************************** +// Revision History +// ---------------- +// $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/SwitchableGraphics/Sg TPV/Sg nVidia API/Mxm30Efi.c $ +// +// 2 9/09/12 11:12p Joshchou +// [TAG] None +// [Category] Improvement +// [Description] Tpv module support for sharkbay. +// [Files] MXM30.mak +// Mxm30Dxe.dxs +// Mxm30Dxe.c +// Mxm30Efi.c +// NBCIEfi.c +// MxmInt15.asm +// MXM30.cif +// +// 1 6/27/11 5:25a Alanlin +// [TAG] EIP61848 +// [Category] New Feature +// [Description] Initial check-in.Integrated SwitchableGraphics Intel +// Reference code 0.6.0 +// [Files] MXM30.cif +// MXM30.sdl +// MXM30.mak +// Mxm30Dxe.dxs +// Mxm30Dxe.c +// Mxm30Efi.c +// NBCIEfi.c +// MxmInt15.asm +// Mxm30ElkCreek4.mxm +// Mxm30ElkCreekIII.mxm +// +// +// 1 9/17/10 1:16p Alexp +// [TAG] EIP43103 +// [Category] Function Request +// [Severity] Normal +// [Symptom] Initial check-in of SgTPV module +// [RootCause] Request to implement SG reference code . +// [Solution] Initial check-in. +// [Files] +// Mxm30.cif;*.sdl;*.mak; +// Mxm30Dxe.c;*.dxs +// Mxm30efi.c +// MxmInt15.asm +// NbciEfi.c +// Mxm30ElkCreek3(4).mxm +// +// 1 6/08/10 3:43p Alexp +// +//********************************************************************** +//<AMI_FHDR_START> +//---------------------------------------------------------------------------- +// +// Name: Mxm30Efi.c +// +// Description: This file installs +// 1)Mxm EFI protocol +// 2)Mxm Legacy Int15 and +// 3)Acpi interfaces for Switchable Graphics +// +// Notes: MAKE SURE NO PEI OR DXE SPECIFIC CODE IS NEEDED +// +//---------------------------------------------------------------------------- +//<AMI_FHDR_END> +#include <Token.h> +#include <AmiDxeLib.h> +#include <DXE.h> + +#include <Protocol\Mxm30.h> + +extern EFI_BOOT_SERVICES *pBS; +extern EFI_RUNTIME_SERVICES *pRS; + +// Defined in Mxm30Dxe.c +extern VOID *gMxmLegMemAddr; +extern UINTN gMxmLegMemSize; +///////////////////////////////////////// +// MXM EFI PROTOCOL PROTOTYPES // +///////////////////////////////////////// + +EFI_STATUS MxmReturnSpecLevel ( + IN MXM3_EFI_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN OUT CHAR16 usStructSize, + IN OUT CHAR8 *pucRevisionLevel, + OUT UINTN *puSupportFuncs +); + +EFI_STATUS MxmReturnStructure ( + IN MXM3_EFI_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN OUT CHAR16 *usStructSize, + IN CHAR16 usDataBlockID, + OUT CHAR8 **pMxmStruct +); + +EFI_STATUS MxmSelectOutputDevice ( + IN MXM3_EFI_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN OUT CHAR16 usStructSize, + IN EFI_HANDLE ChildHandle, + IN CHAR8 ucOutputSetting +); + +EFI_STATUS MxmCheckOutputDevice ( + IN MXM3_EFI_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN OUT CHAR16 usStructSize, + IN EFI_HANDLE ChildHandle, + OUT CHAR8 ucDisplayAvailable +); + +MXM3_EFI_PROTOCOL Mxm30Protocol = { + MxmReturnSpecLevel, + MxmReturnStructure, + MxmSelectOutputDevice, + MxmCheckOutputDevice +}; + +//////////////////////////////// +// MXM EFI PROTOCOL FUNCTIONS // +//////////////////////////////// + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: MxmReturnSpecLevel +// +// Description: Caller provides pointer to location, which on call contains the Module requested Spec Revision +// Level, and which on exit, will contain the Platform's preferred Revision Level and Bit Field of +// supported functions. +// +// Input: UINT8 *This +// EFI_HANDLE ControllerHandle +// UCHAR16 usStructSize +// +// Output: EFI_STATUS = +// EFI_SUCCESS, EFI_UNSUPPORTED, EFI_INVALID_PARAMETER, EFI_BUFFER_TOO_SMALL +// +// Modified: +// +// Referrals: +// +// Notes: +// Where the integer value passed in uSupportFuncs indicates supported functions: +// Bit 0 = `1' (this method is required) +// Bit 1 = `1' (MxmReturnStucture is also required) +// Bit 2 = `1' if MxmSelectOutputDevice is supported, `0' if not +// Bit 3 = `1' if MxmCheckOutputDevice is supported, `0' if not +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +EFI_STATUS MxmReturnSpecLevel ( + IN MXM3_EFI_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN OUT CHAR16 usStructSize, + IN OUT CHAR8 *pucRevisionLevel, + OUT UINTN *puSupportFuncs +){ + EFI_STATUS Status = EFI_SUCCESS; + + *pucRevisionLevel = EFI30_DataBlockID; + *puSupportFuncs = EFI30_SupportFuncs; + + return Status; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: MxmReturnStructure +// +// Description: Caller provides expected MXM Interface Revision Level and a pointer which, +// on return will contain the MXM structure. +// +// Input: UINT8 *This +// EFI_HANDLE ControllerHandle +// UCHAR16 usStructSize +// +// Output: EFI_STATUS = +// EFI_SUCCESS, EFI_UNSUPPORTED, EFI_INVALID_PARAMETER, EFI_BUFFER_TOO_SMALL +// +// Modified: +// +// Referrals: +// +// Notes: +// ControllerHandle - used to differentiate which MXM module is being referenced. +// This is the EFI handle for the PCI device. ChildHandle where used, is the output device (the display). +// usStructSize - set to the size of the supplied buffer by the caller, and on return should contain the +// actual size of the structure. If the structure is larger than the buffer, EFI_BUFFER_TOO_SMALL +// should be returned as the status of the call +// usDataBlockID - Identifier for the data block to return. To obtain the MXM information structure, use usDataBlockID[0..7] to specify the revision +// of the MXM software specification that is supported by the MXM module.Format is binary coded decimal, for example: 0030h = 3.0, etc. +// To obtain an additional vendor specific data block, use lower 8 bits to specify an identifier in the range 0x80-0x8F. +// If the system BIOS does not contain MXM Graphics Module Software Specification Version 3.0 such a data block, it should return an error. +// Graphics vendors should not assume a specific assignment within this range - the SBIOS can store +// the data for different vendors in any order in the 0x80-0x8F identifier range +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +EFI_STATUS MxmReturnStructure ( + IN MXM3_EFI_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN OUT CHAR16 *usStructSize, + IN CHAR16 usDataBlockID, + OUT CHAR8 **pMxmStruct +){ + EFI_STATUS Status = EFI_SUCCESS; +// Only supports Rev 3.0 + if(usDataBlockID != EFI30_DataBlockID) + return EFI_UNSUPPORTED; + +// TO DO: calculate the offset within *pMxmStruct by comparing the DevID in the MXM Header with given controller handle DevID + *pMxmStruct = gMxmLegMemAddr; + *usStructSize = (CHAR16)gMxmLegMemSize; + + return Status; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: MxmSelectOutputDevice +// +// Description: Select Output Device Channel. +// Caller provides the handle of the target adapter, the handle of the display and the output setting +// +// Input: UINT8 *This +// EFI_HANDLE ControllerHandle +// UCHAR16 usStructSize +// +// Output: EFI_STATUS = +// EFI_SUCCESS, EFI_UNSUPPORTED, EFI_INVALID_PARAMETER, EFI_BUFFER_TOO_SMALL +// +// Modified: +// +// Referrals: +// +// Notes: +// Where the value passed in ucOutputSetting may indicate one of the following actions: +// 0 - Acquire shared Display DDC +// 1 - Enable this Display Output +// 3 - Enable this Display - Both Output and DDC +// 4 - Release shared Display DDC +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +EFI_STATUS MxmSelectOutputDevice ( + IN MXM3_EFI_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN OUT CHAR16 usStructSize, + IN EFI_HANDLE ChildHandle, + IN CHAR8 ucOutputSetting +){ + + return EFI_UNSUPPORTED; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: MxmCheckOutputDevice +// +// Description: Check Availability of Output Device. Caller provides the handle of +// the target adapter and the handle of the display +// +// Input: UINT8 *This +// EFI_HANDLE ControllerHandle +// UCHAR16 usStructSize +// +// Output: EFI_STATUS = +// EFI_SUCCESS, EFI_UNSUPPORTED, EFI_INVALID_PARAMETER, EFI_BUFFER_TOO_SMALL +// UCHAR8 ucDisplayAvailable +// +// Modified: +// +// Referrals: +// +// Notes: The returned value ucDisplayAvailable will be one of the following values: +// 0 - Connector is currently available +// 1 - Connector is not currently available +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +EFI_STATUS MxmCheckOutputDevice ( + IN MXM3_EFI_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN OUT CHAR16 usStructSize, + IN EFI_HANDLE ChildHandle, + OUT CHAR8 ucDisplayAvailable +){ + + return EFI_UNSUPPORTED; +} + +/////////////////////////////////////// +// END of MXM EFI PROTOCOL FUNCTIONS // +/////////////////////////////////////// + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: LoadFile +// +// Description: Reads the file with the given GUID. +// +// Input: +// IN EFI_GUID *Guid, +// IN VOID **Buffer +// IN UINTN *BufferSize +// +// Output: +// EFI_STATUS +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +EFI_STATUS LoadFile( + EFI_GUID *Guid, + VOID **Buffer, + UINTN *BufferSize +) +{ + EFI_STATUS Status; + UINTN NumHandles; + EFI_HANDLE *HandleBuffer; + EFI_FIRMWARE_VOLUME_PROTOCOL *Fv; + UINT32 FvStatus; + UINTN i; + EFI_GUID EfiFVProtocolGuid = EFI_FIRMWARE_VOLUME_PROTOCOL_GUID; + + *Buffer = 0; + *BufferSize = 0; + + Status = pBS->LocateHandleBuffer(ByProtocol,&EfiFVProtocolGuid,NULL,&NumHandles,&HandleBuffer); + if (EFI_ERROR(Status)) return Status; + + for (i = 0; i < NumHandles; ++i) { + Status = pBS->HandleProtocol(HandleBuffer[i],&EfiFVProtocolGuid,&Fv); + if (EFI_ERROR(Status)) continue; + Status = Fv->ReadSection(Fv,Guid,EFI_SECTION_RAW,0,Buffer,BufferSize,&FvStatus); + if (Status == EFI_SUCCESS) break; + } + + pBS->FreePool(HandleBuffer); + return Status; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: MXM30Interfaces +// +// Description: Entry point of EFI MXM Support driver. The function istalls +// 1. Install MXM protocol; +// 2. Update data structure to be passed to Int15 binary +// must support multiple MXM data modules. Dependent on controller's handle +// Load MXM data block <1Mb area. +// a. Copy MXM Structure below 1MB +// 1. Allocate Legacy mem space for MXM dat <1MB +// OR +// 2. Update the MXM data by the pointer returned by Int15 5F80 Func01(default) +// b. Update the pointer to MXM data in EFI Protocol API +// c. Create an ACPI SSDT table and copy MXM block there (ASL MXM logic must handle different MXM modules...) +// +// Input: EFI_HANDLE ImageHandle, +// EFI_SYSTEM_TABLE *SystemTable +// +// Output: EFI_STATUS +// +// Modified: +// +// Referrals: +// +// Notes: +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +EFI_STATUS +MXM30Interfaces ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable +) +{ + EFI_STATUS Status; + EFI_GUID gEfiMxm3ProtocolGuid = MXM3_EFI_GUID; + + Status = pBS->InstallProtocolInterface ( + &ImageHandle, + &gEfiMxm3ProtocolGuid, + EFI_NATIVE_INTERFACE, + &Mxm30Protocol + ); + ASSERT_EFI_ERROR (Status); + + return Status; +} + + +//********************************************************************** +//********************************************************************** +//** ** +//** (C)Copyright 1985-2012, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Pkwy, Suite 200, Norcross, GA 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//********************************************************************** +//********************************************************************** diff --git a/Board/EM/SwitchableGraphics/SgTpv/MXM30/Mxm30ElkCreek4.mxm b/Board/EM/SwitchableGraphics/SgTpv/MXM30/Mxm30ElkCreek4.mxm Binary files differnew file mode 100644 index 0000000..a5712b1 --- /dev/null +++ b/Board/EM/SwitchableGraphics/SgTpv/MXM30/Mxm30ElkCreek4.mxm diff --git a/Board/EM/SwitchableGraphics/SgTpv/MXM30/Mxm30ElkCreekIII.mxm b/Board/EM/SwitchableGraphics/SgTpv/MXM30/Mxm30ElkCreekIII.mxm Binary files differnew file mode 100644 index 0000000..3eebd74 --- /dev/null +++ b/Board/EM/SwitchableGraphics/SgTpv/MXM30/Mxm30ElkCreekIII.mxm diff --git a/Board/EM/SwitchableGraphics/SgTpv/MXM30/MxmInt15.asm b/Board/EM/SwitchableGraphics/SgTpv/MXM30/MxmInt15.asm new file mode 100644 index 0000000..ad7ea06 --- /dev/null +++ b/Board/EM/SwitchableGraphics/SgTpv/MXM30/MxmInt15.asm @@ -0,0 +1,553 @@ + + TITLE MXMINT15.ASM -- OEM INTERRUPT IMPLEMENTATION + +;********************************************************************** +;********************************************************************** +;** ** +;** (C)Copyright 1985-2012, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Pkwy, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;********************************************************************** +;********************************************************************** +;********************************************************************** +; $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/SwitchableGraphics/Sg TPV/Sg nVidia API/MxmInt15.asm 2 9/09/12 11:12p Joshchou $ +; +; $Revision: 2 $ +; +; $Date: 9/09/12 11:12p $ +;********************************************************************** +; Revision History +; ---------------- +; $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/SwitchableGraphics/Sg TPV/Sg nVidia API/MxmInt15.asm $ +; +; 2 9/09/12 11:12p Joshchou +; [TAG] None +; [Category] Improvement +; [Description] Tpv module support for sharkbay. +; [Files] MXM30.mak +; Mxm30Dxe.dxs +; Mxm30Dxe.c +; Mxm30Efi.c +; NBCIEfi.c +; MxmInt15.asm +; MXM30.cif +; +; 1 6/27/11 5:25a Alanlin +; [TAG] EIP61848 +; [Category] New Feature +; [Description] Initial check-in.Integrated SwitchableGraphics Intel +; Reference code 0.6.0 +; [Files] MXM30.cif +; MXM30.sdl +; MXM30.mak +; Mxm30Dxe.dxs +; Mxm30Dxe.c +; Mxm30Efi.c +; NBCIEfi.c +; MxmInt15.asm +; Mxm30ElkCreek4.mxm +; Mxm30ElkCreekIII.mxm +; +; +; 1 9/17/10 1:16p Alexp +; [TAG] EIP43103 +; [Category] Function Request +; [Severity] Normal +; [Symptom] Initial check-in of SgTPV module +; [RootCause] Request to implement SG reference code . +; [Solution] Initial check-in. +; [Files] +; Mxm30.cif;*.sdl;*.mak; +; Mxm30Dxe.c;*.dxs +; Mxm30efi.c +; MxmInt15.asm +; NbciEfi.c +; Mxm30ElkCreek3(4).mxm +; +; 2 6/03/10 3:07p Alexp +; +; 1 6/03/10 2:54p Alexp +; +; +;********************************************************************** +INCLUDE Token.equ +.386p + +CSMOEM_CSEG SEGMENT PARA PUBLIC 'CODE' USE16 + ASSUME cs:CSMOEM_CSEG, ds:CSMOEM_CSEG + +OldIntHandler LABEL DWORD + IntSegSav dw 0 + IntOfsSav dw 0 + +;<AMI_FHDR_START> +;--------------------------------------------------------------------------- +; +; Name: MXMINT15Proc +; +; Description: MXM INT15 function implememtation +; + nVidia's NBCI Int15 supplement functions +; +;--------------------------------------------------------------------------- +;<AMI_FHDR_END> + +MXMINT15Proc PROC NEAR PUBLIC + + cmp ax, 5f80h + je igd_mxmcall +; cmp ax, 5f14h ; NVidia Vbios is calling this method. Keeping it commented out since the call is not documented +; je igd_misccall + jmp DWORD PTR cs:[OldIntHandler] + +;;igd_misccall: +;; Output Spec Support Level +;; BX = 078Fh, Get Miscellaneous Status +; cmp bx, 078fh +; jne notSupported +;; CL = Bit map of dock, lid and AC status: +;; Bits 7 - 3 = Reserved +;; Bit 2 = 0, no AC power +;; = 1, AC power active +;; Bit 1 = 0, lid open +;; = 1, lid closed +;; Bit 0 = 0, not docked +;; = 1, docked +; mov cl, 00000100b ; Bitmap of supported functions. +; jmp short mxmExit + +igd_mxmcall: + +; MXM rev3.0 <=9 +; NBCI <=9 +; Optimus 13 + cmp bl, 13 + ja short notSupported + + push si + movzx si, bl + shl si, 1 + stc ; default->not supported + call WORD PTR cs:[mxmFuncTable+si] ; Call this function. + pop si + jc short notSupported +mxmExit: + + mov ax, 05fh + +notSupported: +; sti + clc + retf 0002 +; iret + +MXMINT15Proc ENDP + +mxmFuncTable:: + DW OFFSET mxmInt15Fun0 + DW OFFSET mxmInt15Fun1 + DW OFFSET mxmInt15Fun2 + DW OFFSET mxmInt15Fun3 + DW OFFSET mxmInt15Fun4 + DW OFFSET mxmnotSupported ; mxmInt15Fun5 + DW OFFSET mxmnotSupported ; mxmInt15Fun6 + DW OFFSET mxmInt15Fun7 + DW OFFSET mxmInt15Fun8 + DW OFFSET mxmInt15Fun9 + DW OFFSET mxmnotSupported ; mxmInt15FunA + DW OFFSET mxmnotSupported ; mxmInt15FunB + DW OFFSET mxmnotSupported ; mxmInt15FunC + DW OFFSET mxmInt15FunD ; OptimusInt15FunD + +mxmDODTable:: ; table must be consistent with _DOD method return in ASL + DD 80000100h ; CRT + DD 80000400h ; LVDS + DD 80006300h ; DP_B + DD 80008301h ; dP->HDMI B interop dongle + DD 80008302h ; dP->HDMI C interop dongle + DD 80006303h ; DP_D + +DODCount EQU (($ - mxmDODTable) / 4) + +mxmFunc4String:: + DB 'MXM 3.0 VBIOS: AMI Int15 5F80 Interface', 0dh, 0ah, 0 + +;<AMI_PHDR_START> +;---------------------------------------------------------------------------- +; Procedure: mxmnotSupported +; Input: +; Output: +;---------------------------------------------------------------------------- +;<AMI_PHDR_END> +mxmnotSupported PROC NEAR + ret +mxmnotSupported ENDP + +;<AMI_PHDR_START> +;---------------------------------------------------------------------------- +; Procedure: mxmInt15Fun0 +; Description: Function 0 Output Specification Support Level +; Input: +; AX = 5F80h ; MXM2.0, MXM2.1, MXM3.0 +; BL = 00h ; MXM2.0, MXM2.1, MXM3.0 +; BH = Adapter Index ; MXM2.0, MXM2.1 +; 0 = Primary MXM adapter (default) ; MXM2.0, MXM2.1 +; 1 = Secondary MXM adapter ; MXM2.0, MXM2.1 +; BH = FFh ; MXM3.0 +; EBX[31:16] = Adapter ID ; MXM3.0 +; Bits [31:24] Bus ; MXM3.0 +; Bits [23:19] Device ; MXM3.0 +; Bits [18:16] Function ; MXM3.0 +; CL = Revision of the MXM software specification that is supported by the MXM module ; MXM2.0, MXM2.1 +; Format is binary coded decimal, for example: +; 10h = 1.0, 11h = 1.1, 20h = 2.0, etc. +; CX = Revision of the MXM software specification that is supported by the MXM module. ; MXM3.0 +; Format is binary coded decimal, for example: 0030h = 3.0, etc +; CX = 'OP' 4F50h Optimus Interface +; CX = 'NB' 4E42h NBCI Interface +; Output: +; AX = 005Fh to indicate that the system bios supports this function ; MXM2.0, MXM2.1, MXM3.0 +; BL = Revision of the MXM software specification that is supported by the system ; MXM2.0, MXM2.1, MXM3.0 +; Format is binary coded decimal, for example: +; 10h = 1.0, 11h = 1.1, 20h = 2.0, etc. +; CX = MXM functions supported ; MXM2.0, MXM2.1, MXM3.0 +; Bit 0 = 1 +; Bit 1 = 1 if Function 1 is supported, 0 if not supported ; MXM2.0, MXM2.1, MXM3.0 +; Bit 2 = 1 if Function 2 is supported, 0 if not supported ; MXM2.0, MXM2.1, MXM3.0 +; Bit 3 = 1 if Function 3 is supported, 0 if not supported ; MXM2.0, MXM2.1, MXM3.0 +; Bit 4 = 1 if Function 4 is supported, 0 if not supported ; MXM2.1, MXM3.0 +; Bit 7 = 1 if Function 7 is supported, 0 if not supported ; MXM3.0 +; Bit 8 = 1 if Function 8 is supported, 0 if not supported ; MXM3.0 +; Bit 9 = 1 if Function 9 is supported, 0 if not supported ; MXM3.0 +;---------------------------------------------------------------------------- +;<AMI_PHDR_END> + +mxmInt15Fun0 PROC NEAR +; Check signature if Optimus, Mxm or NBCI + cmp cx, 'OP' + je OptimusFun1 +; MXM rev3.0 + mov bl, 030h ; Support 3.0 + mov cx, 0000010011b ; Support funcion 0,1,4 + jmp short @F +; mov cx, 1100001011b ; Support funcion 0,1,3,8,9 +; mov cx, 11 0001 1011b ; Support funcion 0,1,3,4,8,9 +; mov cx, 1110011111b ; Support funcion 0,1,2,3,4,7,8,9. +OptimusFun1: + mov bl, 011h ; rev 1.1 + mov cx, 2001h ; Support funcion 0,13 +@@: + clc + ret +mxmInt15Fun0 ENDP + +;<AMI_PHDR_START> +;---------------------------------------------------------------------------- +; Procedure: mxmInt15Fun1 +; Description: Function 1 Output a Pointer to the MXM Structure +; Input: +; AX = 5F80h ; MXM2.0, MXM2.1, MXM3.0 +; BL = 01h ; MXM2.0, MXM2.1, MXM3.0 +; BH = FFh ; MXM3.0 +; EBX[31:16] = Adapter ID ; MXM3.0 +; Bits [31:24] Bus ; MXM3.0 +; Bits [23:19] Device ; MXM3.0 +; Bits [18:16] Function ; MXM3.0 +; CL = Revision of the MXM software specification that is supported by the MXM module ; MXM2.0, MXM2.1 +; CX = Identifier for the data block to return ; MXM3.0 +; Output: +; AX = 005Fh to indicate that the system bios supports this function ; MXM2.0, MXM2.1, MXM3.0 +; BX = Vendor ID of data block if CX = 0x80-0x8F, else 0. ; MXM3.0 +; ES:DI = Pointer to the MXM structure in real mode memory (< 1MB) ; MXM2.0, MXM2.1, MXM3.0 +;---------------------------------------------------------------------------- +;<AMI_PHDR_END> + +mxmInt15Fun1 PROC NEAR + +; MXM rev3.0 + mov di, OFFSET mxm30Struc + cmp cl, 030h ; Assume this DI for 3.0 MXM. + jz short returnMxmStruc + + jmp short exit + +returnMxmStruc: + mov bx, 0 + mov ax, cs ; Get ES for MXM structure. + mov es, ax + clc +exit: + ret +mxmInt15Fun1 ENDP + +;<AMI_PHDR_START> +;---------------------------------------------------------------------------- +; Procedure: mxmInt15Fun2 +; Description: Function 2 Output a Pointer to the EDID Structure for the Internal Panel +; Input: +; AX = 5F80h ; MXM2.0, MXM2.1, MXM3.0 +; BL = 02h ; MXM2.0, MXM2.1, MXM3.0 +; BH = Adapter Index ; MXM2.0, MXM2.1 +; 0 = Primary MXM adapter (default) +; 1 = Secondary MXM adapter +; BH = FFh ; MXM3.0 +; EBX[31:16] = Adapter ID ; MXM3.0 +; Bits [31:24] Bus +; Bits [23:19] Device +; Bits [18:16] Function +; EDX = Display device identifier (32-bit value as used in _DOD) ; MXM3.0 +; Output: +; AX = 005Fh to indicate that the system bios supports this function ; MXM2.0, MXM2.1, MXM3.0 +; BL = EDID structures returned ; MXM2.1, MXM3.0 +; 00 = 128byte EDID 1.3 followed by a 128byte DI-EXT block. +; 02 = 128byte EDID 1.3 structure only +; ES:DI = Pointer to the EDID structure in real mode memory (< 1MB) ; MXM2.0, MXM2.1, MXM3.0 +;---------------------------------------------------------------------------- +;<AMI_PHDR_END> + +mxmInt15Fun2 PROC NEAR + ret +mxmInt15Fun2 ENDP + +;<AMI_PHDR_START> +;---------------------------------------------------------------------------- +; Procedure: mxmInt15Fun3 +; Description: Function 3 Select Output Device Channel +; Input: +; AX = 5F80h ; MXM2.0, MXM2.1, MXM3.0 +; BL = 03h ; MXM2.0, MXM2.1, MXM3.0 +; BH = Adapter Index ; MXM2.0, MXM2.1 +; 0 = Primary MXM adapter (default) +; 1 = Secondary MXM adapter +; BH = FFh ; MXM3.0 +; EBX[31:16] = Adapter ID ; MXM3.0 +; Bits [31:24] Bus +; Bits [23:19] Device +; Bits [18:16] Function +; CL = Selection ; MXM2.0, MXM2.1, MXM3.0 +; 0 - Acquire shared Display DDC +; 1 - Display Output +; 3 - Both +; 4 - Release shared Display DDC +; CH = Device index (range 0 - 7) ; MXM2.0, MXM2.1 +; according to the order in which the MXM Output Device Structure +; for this device appears in the MXM Data Structure. +; EDX = Display device identifier (32-bit value as used in _DOD) ; MXM3.0 +; Output: +; AX = 005Fh to indicate that the SBIOS supports this function ; MXM2.0, MXM2.1, MXM3.0 +; BL For CL=0 the SBIOS shall return a 0h if the mutex was successfully acquired. ; MXM2.0, MXM2.1, MXM3.0 +; When non-zero the mutex was not aquired. +;---------------------------------------------------------------------------- +;<AMI_PHDR_END> + +mxmInt15Fun3 PROC NEAR +;; mov bl, 0 ; Display DDC acquired +;; mov cl, 0 ; Display DDC acquired + mov bl, cl ; temp fix. actual mutex lock implementation is needed + clc + ret +mxmInt15Fun3 ENDP + +;<AMI_PHDR_START> +;---------------------------------------------------------------------------- +; Procedure: mxmInt15Fun4 +; Description: Function 4 Boot Message +; Input: +; AX = 5F80h ; MXM2.1, MXM3.0 +; BL = 04h ; MXM2.1, MXM3.0 +; Output: +; AX = 005Fh to indicate that the SBIOS supports this function ; MXM2.1, MXM3.0 +; BL = Mode If zero then the Pointer is a (zero-terminated) Sign-On Text String. ; MXM2.1 +; BX = Mode If zero then the Pointer is a (zero-terminated) Sign-On Text String. ; MXM3.0 +; ES:DI = Pointer String/Image in real mode memory (< 1MB). ; MXM2.1, MXM3.0 +; A zero length string indicates the normal sign-on message should be suppressed +; e.g. to support a graphical splash screen. +;---------------------------------------------------------------------------- +;<AMI_PHDR_END> + +mxmInt15Fun4 PROC NEAR +; Note. Nvidia Vbios replaces normal Vbios POST messages with the boot string + mov di, OFFSET mxmFunc4String + mov bx, 0 + mov ax, cs ; Get ES for MXM structure. + mov es, ax + clc + ret +mxmInt15Fun4 ENDP + +;<AMI_PHDR_START> +;---------------------------------------------------------------------------- +; Procedure: mxmInt15Fun7 +; Description: Function 7 Returns a Pointer to the VBIOS Image for ROM-Less Adapters +; Input: +; AX = 5F80h ; MXM3.0 +; BL = 07h ; MXM3.0 +; BH = FFh ; MXM3.0 +; EBX[31:16] = Adapter ID ; MXM3.0 +; Bits [31:24] Bus +; Bits [23:19] Device +; Bits [18:16] Function +; Output: +; AX = 005Fh to indicate that the SBIOS supports this function ; MXM3.0 +; ES:DI = Pointer to the requested VBIOS image in real mode memory (< 1MB). ; MXM3.0 +;---------------------------------------------------------------------------- +;<AMI_PHDR_END> + +mxmInt15Fun7 PROC NEAR + ret +mxmInt15Fun7 ENDP + +;<AMI_PHDR_START> +;---------------------------------------------------------------------------- +; Procedure: mxmInt15Fun8 +; Description: Function 8 Check Availability of Output Device +; Input: +; AX = 5F80h ; MXM3.0 +; BL = 08h ; MXM3.0 +; BH = FFh ; MXM3.0 +; EBX[31:16] = Adapter ID ; MXM3.0 +; Bits [31:24] Bus +; Bits [23:19] Device +; Bits [18:16] Function +; EDX = Display device identifier (32-bit value as used in _DOD) ; MXM3.0 +; Output: +; AX = 005Fh to indicate that the SBIOS supports this function ; MXM3.0 +; BL = Available ; MXM3.0 +; BL = 0 indicates the connector is currently available. +; BL = 1 indicates the connector is not currently available +; and no display detection should occur on it. +;---------------------------------------------------------------------------- +;<AMI_PHDR_END> + +mxmInt15Fun8 PROC NEAR + + cmp bh, 0ffh + jne invalidDOD + mov si, 0 + mov cx, DODCount ; no of entries +@@: cmp edx, DWORD PTR cs:[mxmDODTable+si] ; Call this function. + je goodDOD + add si, 4 ; dword offset + loop @B + +invalidDOD: + stc ; default->not supported + mov bl, 1 ; connector is not currently available + ret + +goodDOD: + mov bl, 0 ; connector is available + clc + ret +mxmInt15Fun8 ENDP + +;<AMI_PHDR_START> +;---------------------------------------------------------------------------- +; Procedure: mxmInt15Fun9 +; Description: Function 9 Identify Output Devices +; Input: +; AX = 5F80h ; MXM3.0 +; BL = 09h ; MXM3.0 +; BH = 00h ; MXM3.0 +; Output: +; AX = 005Fh to indicate that the SBIOS supports this function; MXM3.0 +; BL = Number of entries in table. ; MXM3.0 +; ES:DI = Pointer to the table. ; MXM3.0 +; This is a table of 32-bit values identical to the buffer returned by _DOD. ; MXM3.0 +;---------------------------------------------------------------------------- +;<AMI_PHDR_END> + +mxmInt15Fun9 PROC NEAR + + cmp bh, 0 + jne invalidFunc9 + mov di, OFFSET mxmDODTable + mov bl, DODCount ; number of entries + mov ax, cs + mov es, ax + clc +invalidFunc9: + ret +mxmInt15Fun9 ENDP + +;<AMI_PHDR_START> +;---------------------------------------------------------------------------- +; Procedure: mxmInt15FunD +; Description: Optimus: Discrete graphics subsystem power control +; Input: +; AX = 5F80h +; BL = 0Dh +; BH = FFh +; EBX[31:16] = Adapter ID +; Bits [31:24] Bus +; Bits [23:19] Device +; Bits [18:16] Function +; CL = Request GPU subsystem state (0 = Powered off/1 = Powered on) +; Output: +; AX = 005Fh to indicate that the system bios supports this function and it completed successfully +; BL = GPU power state which has been set +;---------------------------------------------------------------------------- +;<AMI_PHDR_END> +mxmInt15FunD PROC NEAR +;!!!! EmeraldLake specific + mov dx, 0538h ; DX = mux register + cmp cl, 0 + je dGPU_off + cmp cl, 1 + je dGPU_on + ret + +dGPU_off: + in eax, dx + or eax, 00400000h + out dx, eax + mov bl, cl + jmp short OK_FuncD + +dGPU_on: + in eax, dx + and eax, NOT (00400000h) + out dx, eax + mov bl, cl +;!!!! EmeraldLake specific + +OK_FuncD: + clc + ret +mxmInt15FunD ENDP + + PUBLIC mxmStrucSrart +mxmStrucSrart: + +;---------------------------------------------------------------------------- +; MXM rev3.0 data structure +;---------------------------------------------------------------------------- +mxm30Struc: +; include MXM30.INC ; First SIS is for first MXM in single MXM config (instance index 0) + MxmTbl db MKF_MXM_ROM_MAX_SIZE dup (0dbh) + + PUBLIC mxmStrucEnd +mxmStrucEnd: + + +CSMOEM_CSEG ENDS +END + + +;********************************************************************** +;********************************************************************** +;** ** +;** (C)Copyright 1985-2012, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Pkwy, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;********************************************************************** +;********************************************************************** diff --git a/Board/EM/SwitchableGraphics/SgTpv/MXM30/NBCIEfi.c b/Board/EM/SwitchableGraphics/SgTpv/MXM30/NBCIEfi.c new file mode 100644 index 0000000..eeaf289 --- /dev/null +++ b/Board/EM/SwitchableGraphics/SgTpv/MXM30/NBCIEfi.c @@ -0,0 +1,367 @@ +//********************************************************************** +//********************************************************************** +//** ** +//** (C)Copyright 1985-2012, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Pkwy, Suite 200, Norcross, GA 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//********************************************************************** +//********************************************************************** +//********************************************************************** +// $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/SwitchableGraphics/Sg TPV/Sg nVidia API/NBCIEfi.c 2 9/09/12 11:12p Joshchou $ +// +// $Revision: 2 $ +// +// $Date: 9/09/12 11:12p $ +//********************************************************************** +// Revision History +// ---------------- +// $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/SwitchableGraphics/Sg TPV/Sg nVidia API/NBCIEfi.c $ +// +// 2 9/09/12 11:12p Joshchou +// [TAG] None +// [Category] Improvement +// [Description] Tpv module support for sharkbay. +// [Files] MXM30.mak +// Mxm30Dxe.dxs +// Mxm30Dxe.c +// Mxm30Efi.c +// NBCIEfi.c +// MxmInt15.asm +// MXM30.cif +// +// 1 6/27/11 5:25a Alanlin +// [TAG] EIP61848 +// [Category] New Feature +// [Description] Initial check-in.Integrated SwitchableGraphics Intel +// Reference code 0.6.0 +// [Files] MXM30.cif +// MXM30.sdl +// MXM30.mak +// Mxm30Dxe.dxs +// Mxm30Dxe.c +// Mxm30Efi.c +// NBCIEfi.c +// MxmInt15.asm +// Mxm30ElkCreek4.mxm +// Mxm30ElkCreekIII.mxm +// +// +// 1 9/17/10 1:16p Alexp +// [TAG] EIP43103 +// [Category] Function Request +// [Severity] Normal +// [Symptom] Initial check-in of SgTPV module +// [RootCause] Request to implement SG reference code . +// [Solution] Initial check-in. +// [Files] +// Mxm30.cif;*.sdl;*.mak; +// Mxm30Dxe.c;*.dxs +// Mxm30efi.c +// MxmInt15.asm +// NbciEfi.c +// Mxm30ElkCreek3(4).mxm +// +//********************************************************************** +//<AMI_FHDR_START> +//---------------------------------------------------------------------------- +// +// Name: NBCIEfi.c +// +// Description: This file installs +// Nbci EFI protocol +// +// Notes: MAKE SURE NO PEI OR DXE SPECIFIC CODE IS NEEDED +// +//---------------------------------------------------------------------------- +//<AMI_FHDR_END> +#include <Token.h> +#include <AmiDxeLib.h> +#include <DXE.h> + +#include <Protocol\NBCI.h> + +extern EFI_BOOT_SERVICES *pBS; +extern EFI_RUNTIME_SERVICES *pRS; + +// Defined in Mxm30Dxe.c +extern VOID *gMxmLegMemAddr; +extern UINTN gMxmLegMemSize; +///////////////////////////////////////// +// Nbci EFI PROTOCOL PROTOTYPES // +///////////////////////////////////////// + +EFI_STATUS NbciReturnSpecLevel ( + IN NBCI_EFI_PROTOCOL *This, + IN OUT CHAR8 *pucRevisionLevel, + OUT UINTN *puSupportFuncs +); + +EFI_STATUS NbciReturnStructure ( + IN NBCI_EFI_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN OUT CHAR16 usStructSize, + IN CHAR16 usDataBlockID, + OUT CHAR8 *pNbciStruct +); + +EFI_STATUS NbciSelectOutputDevice ( + IN NBCI_EFI_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN OUT CHAR16 usStructSize, + IN EFI_HANDLE ChildHandle, + IN CHAR8 ucOutputSetting +); + +EFI_STATUS NbciCheckOutputDevice ( + IN NBCI_EFI_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN OUT CHAR16 usStructSize, + IN EFI_HANDLE ChildHandle, + OUT CHAR8 ucDisplayAvailable +); + +NBCI_EFI_PROTOCOL NBCIProtocol = { + NbciReturnSpecLevel, + NbciReturnStructure, + NbciSelectOutputDevice, + NbciCheckOutputDevice +}; + +// Auxilary Functions. Defined in Mxm30Efi.c +EFI_STATUS UpdateInt15MxmSISData ( + IN EFI_LEGACY_BIOS_PROTOCOL *LegacyBiosProtocol +); + +//////////////////////////////// +// Nbci EFI PROTOCOL FUNCTIONS // +//////////////////////////////// + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: NbciReturnSpecLevel +// +// Description: Caller provides pointer to location, which on call contains the Module requested Spec Revision +// Level, and which on exit, will contain the Platform's preferred Revision Level and Bit Field of +// supported functions. +// +// Input: +// CHAR8 *pucRevisionLevel +// UINTN *puSupportFuncs +// +// Output: EFI_STATUS = +// EFI_SUCCESS, EFI_UNSUPPORTED, EFI_INVALID_PARAMETER, EFI_BUFFER_TOO_SMALL +// +// Modified: +// +// Referrals: +// +// Notes: +// Where the integer value passed in uSupportFuncs indicates supported functions: +// Bit 0 = `1' (this method is required) +// Bit 1 = `1' (NbciReturnStucture is also required) +// Bit 2 = `1' if NbciSelectOutputDevice is supported, `0' if not +// Bit 3 = `1' if NbciCheckOutputDevice is supported, `0' if not +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +EFI_STATUS NbciReturnSpecLevel ( + IN NBCI_EFI_PROTOCOL *This, + IN OUT CHAR8 *pucRevisionLevel, + OUT UINTN *puSupportFuncs +){ + EFI_STATUS Status = EFI_SUCCESS; + + *pucRevisionLevel = EFI_NBCI_DataBlockID; + *puSupportFuncs = EFI_NBCI_SupportFuncs; + + return Status; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: NbciReturnStructure +// +// Description: Caller provides expected Nbci Interface Revision Level and a pointer which, +// on return will contain the Nbci structure. +// +// Input: UINT8 *This +// EFI_HANDLE ControllerHandle +// UCHAR16 usStructSize +// +// Output: EFI_STATUS = +// EFI_SUCCESS, EFI_UNSUPPORTED, EFI_INVALID_PARAMETER, EFI_BUFFER_TOO_SMALL +// +// Modified: +// +// Referrals: +// +// Notes: +// ControllerHandle - used to differentiate which Nbci module is being referenced. +// This is the EFI handle for the PCI device. ChildHandle where used, is the output device (the display). +// usStructSize - set to the size of the supplied buffer by the caller, and on return should contain the +// actual size of the structure. If the structure is larger than the buffer, EFI_BUFFER_TOO_SMALL +// should be returned as the status of the call +// usDataBlockID - Identifier for the data block to return. To obtain the Nbci information structure, use usDataBlockID[0..7] to specify the revision +// of the Nbci software specification that is supported by the Nbci module.Format is binary coded decimal, for example: 0030h = 3.0, etc. +// To obtain an additional vendor specific data block, use lower 8 bits to specify an identifier in the range 0x80-0x8F. +// If the system BIOS does not contain Nbci Graphics Module Software Specification Version 3.0 such a data block, it should return an error. +// Graphics vendors should not assume a specific assignment within this range - the SBIOS can store +// the data for different vendors in any order in the 0x80-0x8F identifier range +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +EFI_STATUS NbciReturnStructure ( + IN NBCI_EFI_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN OUT CHAR16 *usStructSize, + IN CHAR16 usDataBlockID, + OUT CHAR8 **pNbciStruct +){ + EFI_STATUS Status = EFI_SUCCESS; +// Only supports Rev 3.0 + if(usDataBlockID != EFI_NBCI_DataBlockID) + return EFI_UNSUPPORTED; + + UpdateInt15MxmSISData(This); + +// TO DO: calculate the offset within *pNbciStruct by comparing the DevID in the Nbci Header with given controller handle DevID + *pNbciStruct = (CHAR8*)gMxmLegMemAddr; + *usStructSize = (CHAR16)gMxmLegMemSize; + + return Status; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: NbciSelectOutputDevice +// +// Description: Select Output Device Channel. +// Caller provides the handle of the target adapter, the handle of the display and the output setting +// +// Input: UINT8 *This +// EFI_HANDLE ControllerHandle +// UCHAR16 usStructSize +// +// Output: EFI_STATUS = +// EFI_SUCCESS, EFI_UNSUPPORTED, EFI_INVALID_PARAMETER, EFI_BUFFER_TOO_SMALL +// +// Modified: +// +// Referrals: +// +// Notes: +// Where the value passed in ucOutputSetting may indicate one of the following actions: +// 0 - Acquire shared Display DDC +// 1 - Enable this Display Output +// 3 - Enable this Display - Both Output and DDC +// 4 - Release shared Display DDC +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +EFI_STATUS NbciSelectOutputDevice ( + IN NBCI_EFI_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN OUT CHAR16 usStructSize, + IN EFI_HANDLE ChildHandle, + IN CHAR8 ucOutputSetting +){ + + return EFI_UNSUPPORTED; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: NbciCheckOutputDevice +// +// Description: Check Availability of Output Device. Caller provides the handle of +// the target adapter and the handle of the display +// +// Input: UINT8 *This +// EFI_HANDLE ControllerHandle +// UCHAR16 usStructSize +// +// Output: EFI_STATUS = +// EFI_SUCCESS, EFI_UNSUPPORTED, EFI_INVALID_PARAMETER, EFI_BUFFER_TOO_SMALL +// UCHAR8 ucDisplayAvailable +// +// Modified: +// +// Referrals: +// +// Notes: The returned value ucDisplayAvailable will be one of the following values: +// 0 - Connector is currently available +// 1 - Connector is not currently available +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +EFI_STATUS NbciCheckOutputDevice ( + IN NBCI_EFI_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN OUT CHAR16 usStructSize, + IN EFI_HANDLE ChildHandle, + OUT CHAR8 ucDisplayAvailable +){ + + return EFI_UNSUPPORTED; +} + +/////////////////////////////////////// +// END of Nbci EFI PROTOCOL FUNCTIONS // +/////////////////////////////////////// + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: NBCIInterfaces +// +// Description: Common entry point to install: +// 1. Install Nbci protocol; +// +// Input: EFI_HANDLE ImageHandle +// +// Output: EFI_STATUS +// +// Modified: +// +// Referrals: +// +// Notes: +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> +EFI_STATUS +NBCIInterfaces ( + IN EFI_HANDLE ImageHandle +) +{ + EFI_STATUS Status; + EFI_GUID gEfiNBCIProtocolGuid = NBCI_EFI_GUID; + +// Install NBCI_EFI_PROTOCOL + Status = pBS->InstallProtocolInterface ( + &ImageHandle, + &gEfiNbciProtocolGuid, + EFI_NATIVE_INTERFACE, + &NBCIProtocol + ); + ASSERT_EFI_ERROR (Status); + + return Status; +} + + +//********************************************************************** +//********************************************************************** +//** ** +//** (C)Copyright 1985-2012, American Megatrends, Inc. ** +//** ** +//** All Rights Reserved. ** +//** ** +//** 5555 Oakbrook Pkwy, Suite 200, Norcross, GA 30093 ** +//** ** +//** Phone: (770)-246-8600 ** +//** ** +//********************************************************************** +//********************************************************************** |