read/write debug packet to communication with HOST based on transfer\r
protocol.\r
\r
- Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2010 - 2017, Intel Corporation. All rights reserved.<BR>\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
)\r
{\r
UINTN Pe32Data;\r
- EFI_IMAGE_DOS_HEADER *DosHdr;\r
- EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr;\r
PE_COFF_LOADER_IMAGE_CONTEXT ImageContext;\r
\r
//\r
// Find Image Base\r
//\r
- Pe32Data = ((UINTN)mErrorMsgVersionAlert) & ~(AlignSize - 1);\r
- while (Pe32Data != 0) {\r
- DosHdr = (EFI_IMAGE_DOS_HEADER *) Pe32Data;\r
- if (DosHdr->e_magic == EFI_IMAGE_DOS_SIGNATURE) {\r
- //\r
- // DOS image header is present, so read the PE header after the DOS image header.\r
- //\r
- Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)(Pe32Data + (UINTN) ((DosHdr->e_lfanew) & 0x0ffff));\r
- //\r
- // Make sure PE header address does not overflow and is less than the initial address.\r
- //\r
- if (((UINTN)Hdr.Pe32 > Pe32Data) && ((UINTN)Hdr.Pe32 < (UINTN)mErrorMsgVersionAlert)) {\r
- if (Hdr.Pe32->Signature == EFI_IMAGE_NT_SIGNATURE) {\r
- //\r
- // It's PE image.\r
- //\r
- break;\r
- }\r
- }\r
- } else {\r
- //\r
- // DOS image header is not present, TE header is at the image base.\r
- //\r
- Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)Pe32Data;\r
- if ((Hdr.Te->Signature == EFI_TE_IMAGE_HEADER_SIGNATURE) &&\r
- ((Hdr.Te->Machine == IMAGE_FILE_MACHINE_I386) || Hdr.Te->Machine == IMAGE_FILE_MACHINE_X64)) {\r
- //\r
- // It's TE image, it TE header and Machine type match\r
- //\r
- break;\r
- }\r
- }\r
-\r
- //\r
- // Not found the image base, check the previous aligned address\r
- //\r
- Pe32Data -= AlignSize;\r
+ Pe32Data = PeCoffSearchImageBase ((UINTN) mErrorMsgVersionAlert);\r
+ if (Pe32Data != 0) {\r
+ ImageContext.ImageAddress = Pe32Data;\r
+ ImageContext.PdbPointer = PeCoffLoaderGetPdbPointer ((VOID*) (UINTN) ImageContext.ImageAddress);\r
+ PeCoffLoaderRelocateImageExtraAction (&ImageContext);\r
}\r
-\r
- ImageContext.ImageAddress = Pe32Data;\r
- ImageContext.PdbPointer = PeCoffLoaderGetPdbPointer ((VOID*) (UINTN) ImageContext.ImageAddress);\r
- PeCoffLoaderRelocateImageExtraAction (&ImageContext);\r
}\r
\r
/**\r
// Compression/decompression support was added since revision 0.4.\r
// Revision 0.3 shouldn't compress the packet.\r
//\r
- if (DEBUG_AGENT_REVISION >= DEBUG_AGENT_REVISION_04) {\r
+ if (PcdGet32(PcdTransferProtocolRevision) >= DEBUG_AGENT_REVISION_04) {\r
//\r
// Get the compressed data size without modifying the packet.\r
//\r
}\r
if (IncompatibilityFlag) {\r
//\r
- // If the incompatible Debug Packet received, the HOST should be running transfer protocol before DEBUG_AGENT_REVISION.\r
+ // If the incompatible Debug Packet received, the HOST should be running transfer protocol before PcdTransferProtocolRevision.\r
// It could be UDK Debugger for Windows v1.1/v1.2 or for Linux v0.8/v1.2.\r
//\r
DebugPortWriteBuffer (Handle, (UINT8 *) mErrorMsgVersionAlert, AsciiStrLen (mErrorMsgVersionAlert));\r
DEBUG_DATA_SET_VIEWPOINT *SetViewPoint;\r
BOOLEAN HaltDeferred;\r
UINT32 ProcessorIndex;\r
- DEBUG_PORT_HANDLE Handle;\r
DEBUG_AGENT_EXCEPTION_BUFFER AgentExceptionBuffer;\r
UINT32 IssuedViewPoint;\r
DEBUG_AGENT_MAILBOX *Mailbox;\r
SetDebugFlag (DEBUG_AGENT_FLAG_AGENT_IN_PROGRESS, 1);\r
}\r
\r
- Handle = GetDebugPortHandle();\r
-\r
while (TRUE) {\r
\r
if (MultiProcessorDebugSupport()) {\r
break;\r
\r
case DEBUG_COMMAND_GET_REVISION:\r
- DebugAgentRevision.Revision = DEBUG_AGENT_REVISION;\r
+ DebugAgentRevision.Revision = PcdGet32(PcdTransferProtocolRevision);\r
DebugAgentRevision.Capabilities = DEBUG_AGENT_CAPABILITIES;\r
Status = SendDataResponsePacket ((UINT8 *) &DebugAgentRevision, (UINT16) sizeof (DEBUG_DATA_RESPONSE_GET_REVISION), DebugHeader);\r
break;\r