/** @file\r
SEC Core Debug Agent Library instance implementition.\r
\r
- Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2010 - 2015, 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
// Try to read the start symbol\r
//\r
- DebugPortReadBuffer (Handle, Data8, 1, 0);\r
+ DebugAgentReadBuffer (Handle, Data8, 1, 0);\r
if (*Data8 == DEBUG_STARTING_SYMBOL_ATTACH) {\r
*BreakSymbol = *Data8;\r
DebugAgentMsgPrint (DEBUG_AGENT_INFO, "Debug Timer attach symbol received %x", *BreakSymbol);\r
UINT64 MailboxLocation;\r
UINT64 *MailboxLocationPointer;\r
EFI_PHYSICAL_ADDRESS Address;\r
+ UINT32 DebugTimerFrequency;\r
\r
DisableInterrupts ();\r
\r
// Save init arch type when debug agent initialized\r
//\r
SetDebugFlag (DEBUG_AGENT_FLAG_INIT_ARCH, DEBUG_ARCH_SYMBOL);\r
-\r
- InitializeDebugTimer ();\r
+ //\r
+ // Initialize Debug Timer hardware and save its frequency\r
+ //\r
+ InitializeDebugTimer (&DebugTimerFrequency, TRUE);\r
+ UpdateMailboxContent (Mailbox, DEBUG_MAILBOX_DEBUG_TIMER_FREQUENCY, DebugTimerFrequency);\r
\r
Phase2Context.InitFlag = InitFlag;\r
Phase2Context.Context = Context;\r
// Build mailbox in HOB and setup Mailbox Set In Pei flag\r
//\r
Mailbox = AllocateZeroPool (sizeof (DEBUG_AGENT_MAILBOX));\r
- MailboxLocation = (UINT64)(UINTN)Mailbox;\r
- MailboxLocationPointer = BuildGuidDataHob (\r
- &gEfiDebugAgentGuid,\r
- &MailboxLocation,\r
- sizeof (UINT64)\r
- );\r
-\r
- InitializeDebugTimer ();\r
- //\r
- // Update IDT entry to save the location pointer saved mailbox pointer\r
- //\r
- SetLocationSavedMailboxPointerInIdtEntry (MailboxLocationPointer);\r
+ if (Mailbox == NULL) {\r
+ DEBUG ((EFI_D_ERROR, "DebugAgent: Failed to allocate memory!\n"));\r
+ CpuDeadLoop ();\r
+ } else {\r
+ MailboxLocation = (UINT64)(UINTN)Mailbox;\r
+ MailboxLocationPointer = BuildGuidDataHob (\r
+ &gEfiDebugAgentGuid,\r
+ &MailboxLocation,\r
+ sizeof (UINT64)\r
+ );\r
+ //\r
+ // Initialize Debug Timer hardware and save its frequency\r
+ //\r
+ InitializeDebugTimer (&DebugTimerFrequency, TRUE);\r
+ UpdateMailboxContent (Mailbox, DEBUG_MAILBOX_DEBUG_TIMER_FREQUENCY, DebugTimerFrequency);\r
+ //\r
+ // Update IDT entry to save the location pointer saved mailbox pointer\r
+ //\r
+ SetLocationSavedMailboxPointerInIdtEntry (MailboxLocationPointer);\r
+ }\r
//\r
// Save init arch type when debug agent initialized\r
//\r
MailboxLocation = GetLocationSavedMailboxPointerInIdtEntry ();\r
Mailbox = (DEBUG_AGENT_MAILBOX *)(UINTN)(*MailboxLocation);\r
BufferSize = PcdGet16(PcdDebugPortHandleBufferSize);\r
- if (Phase2Context->InitFlag == DEBUG_AGENT_INIT_PEI) {\r
+ if (Phase2Context->InitFlag == DEBUG_AGENT_INIT_PEI && BufferSize != 0) {\r
NewDebugPortHandle = (UINT64)(UINTN)AllocateCopyPool (BufferSize, DebugPortHandle);\r
} else {\r
NewDebugPortHandle = (UINT64)(UINTN)DebugPortHandle;\r