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 /Core/EM/AMIDebugRx/binaries/LIBS/StatusCodeLib | |
download | zprj-b7c51c9cf4864df6aabb99a1ae843becd577237c.tar.xz |
Diffstat (limited to 'Core/EM/AMIDebugRx/binaries/LIBS/StatusCodeLib')
15 files changed, 498 insertions, 0 deletions
diff --git a/Core/EM/AMIDebugRx/binaries/LIBS/StatusCodeLib/DbgrHelp.c b/Core/EM/AMIDebugRx/binaries/LIBS/StatusCodeLib/DbgrHelp.c new file mode 100644 index 0000000..7d75b33 --- /dev/null +++ b/Core/EM/AMIDebugRx/binaries/LIBS/StatusCodeLib/DbgrHelp.c @@ -0,0 +1,260 @@ +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +//** **// +//** (C)Copyright 2009, American Megatrends, Inc. **// +//** **// +//** All Rights Reserved. **// +//** **// +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **// +//** **// +//** Phone (770)-246-8600 **// +//** **// +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +// $Header: /Alaska/BIN/Modules/AMIDebugRx/binaries/LIBS/StatusCodeLib/DbgrHelp.c 5 3/17/11 7:54a Sudhirv $ +// +// $Revision: 5 $ +// +// $Date: 3/17/11 7:54a $ +//***************************************************************** +//***************************************************************** +//********************************************************************** +// Revision History +// ---------------- +// $Log: /Alaska/BIN/Modules/AMIDebugRx/binaries/LIBS/StatusCodeLib/DbgrHelp.c $ +// +// 5 3/17/11 7:54a Sudhirv +// Support to Boot with S3 Resume in Core_4.6.5.0 +// +// 4 3/11/11 8:41a Sudhirv +// Added support to return Database Address correctly with Cores older +// than 4.6.4x +// +// 3 3/09/11 8:18a Sudhirv +// EIP 53658 - AMIDebugRx\Debugger support for PI 1.1 +// +// 2 7/17/09 7:15p Madhans +// DebugRx 1.30.0022 +// +// 4 7/16/09 3:07p Madhans +// To fix the Serial Debugger issuel and To do cleanup. +// +// 3 7/15/09 5:56p Madhans +// Release mode binaries. With S3 resume Off. +// +// 2 7/13/09 2:46p Sudhirv +// Update with Coding Standards +// +// 1 7/07/09 4:46p Sudhirv +// Restructure Binaries Created +// +// 1 5/01/09 7:48p Madhans +// AMIDebug Rx Module. Intial Checkin. +// +// 1 4/29/09 7:51a Sudhirv +// AMI Debug Rx module created +// +// 13 12/12/08 5:14p Madhans +// USB Redirecion Module. +// +// 11 6/26/08 3:09p Sudhirv +// Uploaded after checking coding standards +// +// 10 8/29/07 3:49p Madhans +// To resolve AMD Platfrom issues. +// +// 9 8/29/07 12:44p Madhans +// Common code for 4.x and 3.x +// +// 8 6/13/07 3:16p Madhans +// Copyright Year updated. +// +// 7 3/12/07 6:19p Madhans +// !!!coding standards!!!! +// +// 6 3/10/07 2:22p Madhans +// For non PEI debuggers it should return 0. +// +// 5 3/01/07 10:44a Madhans +// token.h included +// +// 4 1/22/07 11:36a Madhans +// Modification made for Binary Release 1.04.0003. +// +// 3 1/05/07 1:05p Ashrafj +// Latest version 1.04.0001 Beta +// Known issues from previous 1.04.000 Beta release has been fixed. +// +//***************************************************************** + +//********************************************************************** +//<AMI_FHDR_START> +// +// Name: DbgrHelp.c +// +// Description: File containing the globals for CAR base address & size. +// +//<AMI_FHDR_END> +//********************************************************************** + +#include <EFI.h> +#include <AmiPeiLib.h> + +#include "misc.h" +#include "AMIPeiDebug.h" +#ifdef ALASKA_SUPPORT +#include "token.h" +#else +#include "tokens.h" +#endif + +//********************************************************************** +#if defined (PI_SPECIFICATION_VERSION) && (PI_SPECIFICATION_VERSION >= 0x00010000) +UINTN AMI_PEIDEBUGGER_DS_BASEADDRESS = 0; +UINTN AMI_PEIDEBUGGER_DS_SIZE = 0x2048; +#else +const UINTN AMI_PEIDEBUGGER_DS_BASEADDRESS = PEI_DEBUG_DATASECTION_BASEADDRESS; +const UINTN AMI_PEIDEBUGGER_DS_SIZE = PEI_DEBUG_DATASECTION_SIZE; +#endif +volatile UINT16 gS3ResumeSupport = AMI_DEBUG_RX_IN_S3_SUPPORT; + +VOID CPULib_SaveIdt(DESCRIPTOR_TABLE); + +UINTN GetCARBaseAddress() +{ +#if defined (PI_SPECIFICATION_VERSION) && (PI_SPECIFICATION_VERSION >= 0x00010000) + EFI_PEI_SERVICES **PeiServices; + VOID *PeiDbgData; + EFI_GUID mPeiDbgBasePpiGuid = EFI_PEI_DBG_BASEADDRESS_PPI_GUID; + EFI_STATUS Status; + IDTBASE Idtr; + +#ifndef EFIx64 + _asm{ + sidt fword ptr Idtr + } +#else + CPULib_SaveIdt(&Idtr); +#endif + PeiServices = (EFI_PEI_SERVICES **) (*(UINTN*)(Idtr.IDTBaseAddr - sizeof (UINTN))); + + if (PeiServices == NULL) + return (Idtr.IDTBaseAddr); //Point to the area after PEI Services + else + { + Status = (**PeiServices).LocatePpi( + PeiServices, + &mPeiDbgBasePpiGuid, // GUID + 0, // INSTANCE + NULL, // EFI_PEI_PPI_DESCRIPTOR + &PeiDbgData // PPI + ); + if (!EFI_ERROR(Status)) + return *((UINTN*)PeiDbgData); + else + return (Idtr.IDTBaseAddr); + } +#else + return AMI_PEIDEBUGGER_DS_BASEADDRESS; +#endif + +} + +//<AMI_PHDR_START> +//-------------------------------------------------------------------- +// Procedure: IsAmiDbgrBaseValid +// +// Description: It is a function that helps to behave the status +// code redirection through debugger differently +// based in SDL tokens in different cases. +// +// Input: void +// +// Output: UINT8 +// +//-------------------------------------------------------------------- +//<AMI_PHDR_END> + +UINT8 IsAmiDbgrBaseValid(void) +{ + +#if REDIRECTION_ONLY_MODE + return 1; +#else +#ifndef AMI_PEI_DEBUG_SUPPORT + return 0; +#else +// if PEI Debugger is enabled +#ifdef EFIx64 + return 0; +#else + IDTBASE Idtr; + _asm{ + sidt fword ptr Idtr + } +#if defined (PI_SPECIFICATION_VERSION) && (PI_SPECIFICATION_VERSION >= 0x00010000) + // Doubtful code recheck again + if(Idtr.IDTBaseAddr != NULL) +#else + if(Idtr.IDTBaseAddr == AMI_PEIDEBUGGER_DS_BASEADDRESS) +#endif + return 1; + else + return 0; +#endif +#endif +#endif +} + +//<AMI_PHDR_START> +//-------------------------------------------------------------------- +// Procedure: IsBsp() +// +// Description: +// +// Input: void +// +// Output: UINT8 +// +//-------------------------------------------------------------------- +//<AMI_PHDR_END> +UINT8 IsBsp(void) +{ +#ifdef EFIx64 + return 1; +#else + UINT8 IsBsp = 1; +#define MSR_XAPIC_BASE 0x1B +#define XAPIC_BASE_BSP_BIT 8 +#define XAPIC_BASE_BSP_BIT_MASK (1 << XAPIC_BASE_BSP_BIT) + _asm + { + mov ecx,MSR_XAPIC_BASE + rdmsr + and eax,0x100 + cmp eax,0x100 + je BSP + mov IsBsp,0 +BSP: + } + return IsBsp; +#endif +} + +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +//** **// +//** (C)Copyright 2009, American Megatrends, Inc. **// +//** **// +//** All Rights Reserved. **// +//** **// +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **// +//** **// +//** Phone (770)-246-8600 **// +//** **// +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// diff --git a/Core/EM/AMIDebugRx/binaries/LIBS/StatusCodeLib/HostConStatus.c b/Core/EM/AMIDebugRx/binaries/LIBS/StatusCodeLib/HostConStatus.c new file mode 100644 index 0000000..d782224 --- /dev/null +++ b/Core/EM/AMIDebugRx/binaries/LIBS/StatusCodeLib/HostConStatus.c @@ -0,0 +1,213 @@ +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +//** **// +//** (C)Copyright 2010, American Megatrends, Inc. **// +//** **// +//** All Rights Reserved. **// +//** **// +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **// +//** **// +//** Phone (770)-246-8600 **// +//** **// +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +// $Header: /Alaska/BIN/Modules/AMIDebugRx/binaries/LIBS/StatusCodeLib/HostConStatus.c 2 4/15/11 7:09p Madhans $ +// +// $Revision: 2 $ +// +// $Date: 4/15/11 7:09p $ +// +//********************************************************************* +// Revision History +// ---------------- +// $Log: /Alaska/BIN/Modules/AMIDebugRx/binaries/LIBS/StatusCodeLib/HostConStatus.c $ +// +// 2 4/15/11 7:09p Madhans +// [TAG] EIP58122 +// [Category] Bug Fix +// [Severity] Minor +// [Symptom] IsAMIDebugRxConnected() CSPLIB function used in PEI gives +// build issues. +// [RootCause] IsAMIDebugRxConnected in PEI case code is incomplete. +// [Solution] IsAMIDebugRxConnected fixed. +// [Files] HostConStatus.c +// +// 1 3/14/11 9:13p Madhans +// To contribute CSPLib tO check if DebugRx is connected or Not. +// +//********************************************************************* +//<AMI_FHDR_START> +//---------------------------------------------------------------------------- +// +// Name: HostConStatus.C +// +// Description: Checks whether the target is connected with host or not. +// +//---------------------------------------------------------------------------- +//<AMI_FHDR_END> + +#include "efi.h" +#include "pei.h" +#include "amidxelib.h" +#include "Hob.h" +#ifndef EFIx64 +#include "AMIPeiDebug.h" +#else +#include "AMIPeiDebugX64.h" +#endif + + +BOOLEAN CheckForHostConnectedinPEI (EFI_PEI_SERVICES **PeiServices); +#define PEI_DBGSUPPORT_DATA_GUID \ + {0x41cac730, 0xe64e, 0x463b, 0x89, 0x72, 0x25, 0x5e, 0xec, 0x55, 0x55, 0xc2} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: GetEfiConfigurationTableLocal +// +// Description: Gets the efi configuration table +// +// Input: EFI_SYSTEM_TABLE *, EFI_GUID * +// +// Output: void * +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +VOID * GetEfiConfigurationTableLocal( + IN EFI_SYSTEM_TABLE *SystemTable, + IN EFI_GUID *Guid + ) +{ + EFI_CONFIGURATION_TABLE *Table = SystemTable->ConfigurationTable; + UINTN i = SystemTable->NumberOfTableEntries; + + for (;i;--i,++Table) + { + if (guidcmp(&Table->VendorGuid,Guid)==0) return Table->VendorTable; + } + return 0; +} + + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: IsAMIDebugRxConnected +// +// Description: checks whether the target is connected with host or not. +// +// Input: EFI_PEI_SERVICES **, EFI_SYSTEM_TABLE * +// +// Output: BOOLEAN +// TRUE: If host is connected +// FALSE : If host is not connected +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +BOOLEAN IsAMIDebugRxConnected (EFI_PEI_SERVICES **PeiServices, EFI_SYSTEM_TABLE *ST) +{ + EFI_STATUS Status = EFI_NOT_FOUND; + BOOLEAN RetStatus = FALSE; + EFI_GUID HobListGuid = HOB_LIST_GUID; + EFI_GUID mPeiDebugDataGuid = PEI_DBGSUPPORT_DATA_GUID; + EFI_HOB_MEMORY_ALLOCATION *MemoryHob = NULL; + PEIDebugData_T *pPeiDbgDataSection; + EFI_PHYSICAL_ADDRESS DSMemoryBaseAddress = 0; + SerXPortGblData_T *pSerXPortGblData_T = NULL; + + if (PeiServices == NULL) //For DXE check + { + MemoryHob = (EFI_HOB_MEMORY_ALLOCATION*)GetEfiConfigurationTableLocal (ST,&HobListGuid); + if (MemoryHob) + { + //Status = FindNextHobByGuid(&mPeiDebugDataGuid,(VOID**)&MemoryHob); + for(;;){ + Status = FindNextHobByType (EFI_HOB_TYPE_MEMORY_ALLOCATION,&MemoryHob); + if (EFI_ERROR(Status)) break; + if (!guidcmp(&MemoryHob->AllocDescriptor.Name,&mPeiDebugDataGuid)) { + DSMemoryBaseAddress = MemoryHob->AllocDescriptor.MemoryBaseAddress; + pPeiDbgDataSection = (PEIDebugData_T*) DSMemoryBaseAddress; + pSerXPortGblData_T = (SerXPortGblData_T *)pPeiDbgDataSection->XportLocalVar; + if (pSerXPortGblData_T->m_IsHostConnected) + { + RetStatus = TRUE; + break; + } + } + } + } + } + else //For PEI Check + { + RetStatus = CheckForHostConnectedinPEI (PeiServices); + } + return RetStatus; +} + +//<AMI_PHDR_START> +//---------------------------------------------------------------------------- +// Procedure: CheckForHostConnectedinPEI +// +// Description: checks whether the target is connected with host in PEI +// +// Input: void +// +// Output: BOOLEAN +// TRUE: If host is connected +// FALSE : If host is not connected +// +//---------------------------------------------------------------------------- +//<AMI_PHDR_END> + +BOOLEAN CheckForHostConnectedinPEI (EFI_PEI_SERVICES **PeiServices) +{ + PEIDebugData_T *pData; + SerXPortGblData_T *SerData; + VOID *FirstHob = NULL; + EFI_HOB_MEMORY_ALLOCATION *Hob = NULL; + EFI_GUID mPeiDebugDataGuid = PEI_DBGSUPPORT_DATA_GUID; + + //Find PEI Debugger Data section by HOB + for((*PeiServices)->GetHobList(PeiServices,&FirstHob); + !EFI_ERROR(FindNextHobByType(EFI_HOB_TYPE_MEMORY_ALLOCATION,&FirstHob)); + ) + { + Hob = (EFI_HOB_MEMORY_ALLOCATION *) FirstHob; + + if (guidcmp (&mPeiDebugDataGuid, &Hob->AllocDescriptor.Name) == 0) { + pData = (PEIDebugData_T *)Hob->AllocDescriptor.MemoryBaseAddress; + break; + } + } + if(pData == NULL) + return FALSE; + + SerData = (SerXPortGblData_T *)(pData->XportLocalVar); + + if(SerData->m_IsHostConnected) + { + return TRUE; + } + else + { + return FALSE; + } +} +//*****************************************************************// +//*****************************************************************// +//*****************************************************************// +//** **// +//** (C)Copyright 2010, American Megatrends, Inc. **// +//** **// +//** All Rights Reserved. **// +//** **// +//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **// +//** **// +//** Phone (770)-246-8600 **// +//** **// +//*****************************************************************// +//*****************************************************************// +//*****************************************************************//
\ No newline at end of file diff --git a/Core/EM/AMIDebugRx/binaries/LIBS/StatusCodeLib/ia32/AMIDbgPortStatusCodeDxe.obj b/Core/EM/AMIDebugRx/binaries/LIBS/StatusCodeLib/ia32/AMIDbgPortStatusCodeDxe.obj Binary files differnew file mode 100644 index 0000000..97f4622 --- /dev/null +++ b/Core/EM/AMIDebugRx/binaries/LIBS/StatusCodeLib/ia32/AMIDbgPortStatusCodeDxe.obj diff --git a/Core/EM/AMIDebugRx/binaries/LIBS/StatusCodeLib/ia32/AMIDbgPortStatusCodePei.obj b/Core/EM/AMIDebugRx/binaries/LIBS/StatusCodeLib/ia32/AMIDbgPortStatusCodePei.obj Binary files differnew file mode 100644 index 0000000..4f01b7d --- /dev/null +++ b/Core/EM/AMIDebugRx/binaries/LIBS/StatusCodeLib/ia32/AMIDbgPortStatusCodePei.obj diff --git a/Core/EM/AMIDebugRx/binaries/LIBS/StatusCodeLib/ia32/DummyAmiSerialIO.obj b/Core/EM/AMIDebugRx/binaries/LIBS/StatusCodeLib/ia32/DummyAmiSerialIO.obj Binary files differnew file mode 100644 index 0000000..e89056e --- /dev/null +++ b/Core/EM/AMIDebugRx/binaries/LIBS/StatusCodeLib/ia32/DummyAmiSerialIO.obj diff --git a/Core/EM/AMIDebugRx/binaries/LIBS/StatusCodeLib/ia32/GetDbgInterfaceDxe.obj b/Core/EM/AMIDebugRx/binaries/LIBS/StatusCodeLib/ia32/GetDbgInterfaceDxe.obj Binary files differnew file mode 100644 index 0000000..f6e3ddc --- /dev/null +++ b/Core/EM/AMIDebugRx/binaries/LIBS/StatusCodeLib/ia32/GetDbgInterfaceDxe.obj diff --git a/Core/EM/AMIDebugRx/binaries/LIBS/StatusCodeLib/ia32/GetDbgInterfacePei.obj b/Core/EM/AMIDebugRx/binaries/LIBS/StatusCodeLib/ia32/GetDbgInterfacePei.obj Binary files differnew file mode 100644 index 0000000..9cf6a2f --- /dev/null +++ b/Core/EM/AMIDebugRx/binaries/LIBS/StatusCodeLib/ia32/GetDbgInterfacePei.obj diff --git a/Core/EM/AMIDebugRx/binaries/LIBS/StatusCodeLib/ia32/PeiDbgStatusCode.obj b/Core/EM/AMIDebugRx/binaries/LIBS/StatusCodeLib/ia32/PeiDbgStatusCode.obj Binary files differnew file mode 100644 index 0000000..fae0606 --- /dev/null +++ b/Core/EM/AMIDebugRx/binaries/LIBS/StatusCodeLib/ia32/PeiDbgStatusCode.obj diff --git a/Core/EM/AMIDebugRx/binaries/LIBS/StatusCodeLib/ia32/StsCodeObjsIA32Rx.cif b/Core/EM/AMIDebugRx/binaries/LIBS/StatusCodeLib/ia32/StsCodeObjsIA32Rx.cif new file mode 100644 index 0000000..0bdcb20 --- /dev/null +++ b/Core/EM/AMIDebugRx/binaries/LIBS/StatusCodeLib/ia32/StsCodeObjsIA32Rx.cif @@ -0,0 +1,13 @@ +<component> + name = "StsCodeObjsIa32Rx" + category = ModulePart + LocalRoot = "Core\em\AMIDebugRx\binaries\LIBS\StatusCodeLib\ia32" + RefName = "StsCodeObjsIa32Rx" +[files] +"PeiDbgStatusCode.obj" +"GetDbgInterfaceDxe.obj" +"GetDbgInterfacePei.obj" +"DummyAmiSerialIO.obj" +"AMIDbgPortStatusCodePei.obj" +"AMIDbgPortStatusCodeDxe.obj" +<endComponent> diff --git a/Core/EM/AMIDebugRx/binaries/LIBS/StatusCodeLib/x64/AMIDbgPortStatusCodeDxe.obj b/Core/EM/AMIDebugRx/binaries/LIBS/StatusCodeLib/x64/AMIDbgPortStatusCodeDxe.obj Binary files differnew file mode 100644 index 0000000..960321c --- /dev/null +++ b/Core/EM/AMIDebugRx/binaries/LIBS/StatusCodeLib/x64/AMIDbgPortStatusCodeDxe.obj diff --git a/Core/EM/AMIDebugRx/binaries/LIBS/StatusCodeLib/x64/AMIDbgPortStatusCodePei.obj b/Core/EM/AMIDebugRx/binaries/LIBS/StatusCodeLib/x64/AMIDbgPortStatusCodePei.obj Binary files differnew file mode 100644 index 0000000..e1d01bf --- /dev/null +++ b/Core/EM/AMIDebugRx/binaries/LIBS/StatusCodeLib/x64/AMIDbgPortStatusCodePei.obj diff --git a/Core/EM/AMIDebugRx/binaries/LIBS/StatusCodeLib/x64/DummyAmiSerialIO.obj b/Core/EM/AMIDebugRx/binaries/LIBS/StatusCodeLib/x64/DummyAmiSerialIO.obj Binary files differnew file mode 100644 index 0000000..02fac5f --- /dev/null +++ b/Core/EM/AMIDebugRx/binaries/LIBS/StatusCodeLib/x64/DummyAmiSerialIO.obj diff --git a/Core/EM/AMIDebugRx/binaries/LIBS/StatusCodeLib/x64/GetDbgInterfaceDxe.obj b/Core/EM/AMIDebugRx/binaries/LIBS/StatusCodeLib/x64/GetDbgInterfaceDxe.obj Binary files differnew file mode 100644 index 0000000..015cc2f --- /dev/null +++ b/Core/EM/AMIDebugRx/binaries/LIBS/StatusCodeLib/x64/GetDbgInterfaceDxe.obj diff --git a/Core/EM/AMIDebugRx/binaries/LIBS/StatusCodeLib/x64/PeiDbgStatusCode.obj b/Core/EM/AMIDebugRx/binaries/LIBS/StatusCodeLib/x64/PeiDbgStatusCode.obj Binary files differnew file mode 100644 index 0000000..01a5ccc --- /dev/null +++ b/Core/EM/AMIDebugRx/binaries/LIBS/StatusCodeLib/x64/PeiDbgStatusCode.obj diff --git a/Core/EM/AMIDebugRx/binaries/LIBS/StatusCodeLib/x64/StsCodeObjsx64Rx.cif b/Core/EM/AMIDebugRx/binaries/LIBS/StatusCodeLib/x64/StsCodeObjsx64Rx.cif new file mode 100644 index 0000000..e10ed22 --- /dev/null +++ b/Core/EM/AMIDebugRx/binaries/LIBS/StatusCodeLib/x64/StsCodeObjsx64Rx.cif @@ -0,0 +1,12 @@ +<component> + name = "StsCodeObjsx64Rx" + category = ModulePart + LocalRoot = "Core\em\AMIDebugRx\binaries\LIBS\StatusCodeLib\x64" + RefName = "StsCodeObjsx64Rx" +[files] +"PeiDbgStatusCode.obj" +"GetDbgInterfaceDxe.obj" +"DummyAmiSerialIO.obj" +"AMIDbgPortStatusCodePei.obj" +"AMIDbgPortStatusCodeDxe.obj" +<endComponent> |