summaryrefslogtreecommitdiff
path: root/SourceLevelDebugPkg
diff options
context:
space:
mode:
authorvanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>2011-09-30 02:19:28 +0000
committervanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>2011-09-30 02:19:28 +0000
commite21048345b3ca6cede46b0d3db991a214c1f9f7d (patch)
tree30d0ea2385b09fbe05809422e30a4814816dab72 /SourceLevelDebugPkg
parent68085d37f88aaaaad97f071e2d0e60b276592cc5 (diff)
1. Fixed issue that firmware cannot boot if no USB debug cable connection.
2. Fixed issue that Ovmf with debug agent cannot boot if HOST software was not connected. Signed-off-by: vanjeff Reviewed-by: geekboy15a Reviewed-by: erictian git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12486 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'SourceLevelDebugPkg')
-rw-r--r--SourceLevelDebugPkg/Include/TransferProtocol.h4
-rw-r--r--SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugAgent.h3
-rw-r--r--SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgent/SecPeiDebugAgentLib.c72
-rw-r--r--SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgentLib.inf3
-rw-r--r--SourceLevelDebugPkg/Library/DebugCommunicationLibSerialPort/DebugCommunicationLibSerialPort.c10
-rw-r--r--SourceLevelDebugPkg/Library/DebugCommunicationLibSerialPort/DebugCommunicationLibSerialPort.inf3
-rw-r--r--SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugCommunicationLibUsb.c37
-rw-r--r--SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugCommunicationLibUsb.inf1
8 files changed, 95 insertions, 38 deletions
diff --git a/SourceLevelDebugPkg/Include/TransferProtocol.h b/SourceLevelDebugPkg/Include/TransferProtocol.h
index b7e1143aa..e0b3d7e7b 100644
--- a/SourceLevelDebugPkg/Include/TransferProtocol.h
+++ b/SourceLevelDebugPkg/Include/TransferProtocol.h
@@ -2,7 +2,7 @@
Transfer protocol defintions used by debug agent and host. It is only
intended to be used by Debug related module implementation.
- Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -102,7 +102,7 @@ typedef struct {
#define DEBUG_COMMAND_SET_DEBUG_FLAG (DEBUG_COMMAND_REQUEST | 38) // 38
-#define DEBUG_COMMAND_GET_REVISION (DEBUG_COMMAND_REQUEST | 39) // 30
+#define DEBUG_COMMAND_GET_REVISION (DEBUG_COMMAND_REQUEST | 39) // 39
#define DEBUG_COMMAND_GET_EXCEPTION (DEBUG_COMMAND_REQUEST | 40) // 40
diff --git a/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugAgent.h b/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugAgent.h
index 9671ca4ef..263605082 100644
--- a/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugAgent.h
+++ b/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugAgent.h
@@ -1,7 +1,7 @@
/** @file
Command header of for Debug Agent library instance.
- Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -29,6 +29,7 @@
#include <Library/PcdLib.h>
#include <Library/SynchronizationLib.h>
#include <Library/LocalApicLib.h>
+#include <Library/DebugLib.h>
#include <TransferProtocol.h>
#include <ImageDebugSupport.h>
diff --git a/SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgent/SecPeiDebugAgentLib.c b/SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgent/SecPeiDebugAgentLib.c
index 0d4169ccc..b14d6eb92 100644
--- a/SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgent/SecPeiDebugAgentLib.c
+++ b/SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgent/SecPeiDebugAgentLib.c
@@ -1,7 +1,7 @@
/** @file
SEC Core Debug Agent Library instance implementition.
- Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -196,14 +196,36 @@ InitializeDebugAgent (
DEBUG_AGENT_PHASE2_CONTEXT Phase2Context;
DEBUG_AGENT_CONTEXT_POSTMEM_SEC *DebugAgentContext;
- if (InitFlag != DEBUG_AGENT_INIT_PREMEM_SEC &&
- InitFlag != DEBUG_AGENT_INIT_POSTMEM_SEC) {
- return;
- }
-
DisableInterrupts ();
- if (InitFlag == DEBUG_AGENT_INIT_POSTMEM_SEC) {
+ switch (InitFlag) {
+
+ case DEBUG_AGENT_INIT_PREMEM_SEC:
+
+ InitializeDebugIdt ();
+
+ Mailbox = &MailboxInStack;
+ ZeroMem ((VOID *) Mailbox, sizeof (DEBUG_AGENT_MAILBOX));
+
+ //
+ // Get and save debug port handle and set the length of memory block.
+ //
+ SetMailboxPointerInIdtEntry ((VOID *) Mailbox);
+
+ InitializeDebugTimer ();
+
+ Phase2Context.Context = Context;
+ Phase2Context.Function = Function;
+ DebugPortInitialize ((VOID *) &Phase2Context, InitializeDebugAgentPhase2);
+
+ //
+ // If reaches here, it means Debug Port initialization failed.
+ //
+ DEBUG ((EFI_D_ERROR, "Debug Agent: Debug port initialization failed.\n"));
+
+ break;
+
+ case DEBUG_AGENT_INIT_POSTMEM_SEC:
//
// Memory has been ready
@@ -227,31 +249,25 @@ InitializeDebugAgent (
EnableInterrupts ();
- if (Function != NULL) {
- Function (Context);
- }
-
- return;
+ break;
- } else {
-
- InitializeDebugIdt ();
-
- Mailbox = &MailboxInStack;
- ZeroMem ((VOID *) Mailbox, sizeof (DEBUG_AGENT_MAILBOX));
+ default:
//
- // Get and save debug port handle and set the length of memory block.
+ // Only DEBUG_AGENT_INIT_PREMEM_SEC and DEBUG_AGENT_INIT_POSTMEM_SEC are allowed for this
+ // Debug Agent library instance.
//
- SetMailboxPointerInIdtEntry ((VOID *) Mailbox);
+ DEBUG ((EFI_D_ERROR, "Debug Agent: The InitFlag value is not allowed!\n"));
+ CpuDeadLoop ();
+ break;
- InitializeDebugTimer ();
-
- Phase2Context.Context = Context;
- Phase2Context.Function = Function;
- DebugPortInitialize ((VOID *) &Phase2Context, InitializeDebugAgentPhase2);
+ }
- return;
+ //
+ // If Function is not NULL, invoke it always whatever debug agent was initialized sucesssfully or not.
+ //
+ if (Function != NULL) {
+ Function (Context);
}
}
@@ -289,7 +305,7 @@ InitializeDebugAgentPhase2 (
//
Phase2Context = (DEBUG_AGENT_PHASE2_CONTEXT *) Context;
SecCoreData = (EFI_SEC_PEI_HAND_OFF *)Phase2Context->Context;
- if ((UINTN)SecCoreData->TemporaryRamBase < BASE_128MB) {
+ if ((UINTN)SecCoreData->TemporaryRamBase < BASE_128MB && IsHostConnected ()) {
TriggerSoftInterrupt (MEMORY_READY_SIGNATURE);
}
@@ -299,7 +315,7 @@ InitializeDebugAgentPhase2 (
EnableInterrupts ();
//
- // Call continuation function is it is not NULL.
+ // Call continuation function if it is not NULL.
//
if (Phase2Context->Function != NULL) {
Phase2Context->Function (Phase2Context->Context);
diff --git a/SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgentLib.inf b/SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgentLib.inf
index e2b8ad60a..4d8fc71aa 100644
--- a/SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgentLib.inf
+++ b/SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgentLib.inf
@@ -1,7 +1,7 @@
## @file
# Debug Agent library instance for SEC Core and PEI modules.
#
-# Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@@ -71,6 +71,7 @@
DebugCommunicationLib
SynchronizationLib
LocalApicLib
+ DebugLib
[Guids]
gEfiDebugAgentGuid ## PRODUCES ## HOB
diff --git a/SourceLevelDebugPkg/Library/DebugCommunicationLibSerialPort/DebugCommunicationLibSerialPort.c b/SourceLevelDebugPkg/Library/DebugCommunicationLibSerialPort/DebugCommunicationLibSerialPort.c
index ed1a35bd9..dd88e7d69 100644
--- a/SourceLevelDebugPkg/Library/DebugCommunicationLibSerialPort/DebugCommunicationLibSerialPort.c
+++ b/SourceLevelDebugPkg/Library/DebugCommunicationLibSerialPort/DebugCommunicationLibSerialPort.c
@@ -1,7 +1,7 @@
/** @file
Debug Port Library implementation based on serial port.
- Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -17,6 +17,7 @@
#include <Library/DebugCommunicationLib.h>
#include <Library/SerialPortLib.h>
#include <Library/TimerLib.h>
+#include <Library/DebugLib.h>
/**
Initialize the debug port.
@@ -61,7 +62,12 @@ DebugPortInitialize (
IN DEBUG_PORT_CONTINUE Function
)
{
- SerialPortInitialize ();
+ RETURN_STATUS Status;
+
+ Status = SerialPortInitialize ();
+ if (RETURN_ERROR(Status)) {
+ DEBUG ((EFI_D_ERROR, "Debug Serial Port: Initialization failed!\n"));
+ }
if (Function != NULL) {
Function (Context, NULL);
diff --git a/SourceLevelDebugPkg/Library/DebugCommunicationLibSerialPort/DebugCommunicationLibSerialPort.inf b/SourceLevelDebugPkg/Library/DebugCommunicationLibSerialPort/DebugCommunicationLibSerialPort.inf
index dff0fc92b..6d36cefd7 100644
--- a/SourceLevelDebugPkg/Library/DebugCommunicationLibSerialPort/DebugCommunicationLibSerialPort.inf
+++ b/SourceLevelDebugPkg/Library/DebugCommunicationLibSerialPort/DebugCommunicationLibSerialPort.inf
@@ -1,7 +1,7 @@
## @file
# Debug Communication Library instance based on serila port.
#
-# Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@@ -35,4 +35,5 @@
[LibraryClasses]
SerialPortLib
TimerLib
+ DebugLib
diff --git a/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugCommunicationLibUsb.c b/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugCommunicationLibUsb.c
index 3dd1e3a62..7fb671eb4 100644
--- a/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugCommunicationLibUsb.c
+++ b/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugCommunicationLibUsb.c
@@ -22,6 +22,7 @@
#include <Library/DebugCommunicationLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/BaseLib.h>
+#include <Library/DebugLib.h>
#define SETUP_PID 0x2D
#define INPUT_PID 0x69
@@ -108,7 +109,7 @@ typedef struct _USB_DEBUG_PORT_HANDLE{
// The usb debug port memory BAR number in EHCI configuration space.
//
UINT8 DebugPortBarNumber;
- UINT8 Reserved;
+ BOOLEAN Initialized;
//
// The offset of usb debug port registers in EHCI memory range.
//
@@ -723,6 +724,13 @@ DebugPortReadBuffer (
UsbDebugPortHandle = (USB_DEBUG_PORT_HANDLE *)Handle;
}
+ //
+ // Check if debug port is ready
+ //
+ if (!UsbDebugPortHandle->Initialized) {
+ return 0;
+ }
+
if (NeedReinitializeHardware(UsbDebugPortHandle)) {
Status = InitializeUsbDebugHardware (UsbDebugPortHandle);
if (RETURN_ERROR(Status)) {
@@ -868,6 +876,13 @@ DebugPortWriteBuffer (
UsbDebugPortHandle = (USB_DEBUG_PORT_HANDLE *)Handle;
}
+ //
+ // Check if debug port is ready
+ //
+ if (!UsbDebugPortHandle->Initialized) {
+ return 0;
+ }
+
if (NeedReinitializeHardware(UsbDebugPortHandle)) {
Status = InitializeUsbDebugHardware (UsbDebugPortHandle);
if (RETURN_ERROR(Status)) {
@@ -940,6 +955,13 @@ DebugPortPollBuffer (
UsbDebugPortHandle = (USB_DEBUG_PORT_HANDLE *)Handle;
}
+ //
+ // Check if debug port is ready
+ //
+ if (!UsbDebugPortHandle->Initialized) {
+ return 0;
+ }
+
if (NeedReinitializeHardware(UsbDebugPortHandle)) {
Status = InitializeUsbDebugHardware(UsbDebugPortHandle);
if (RETURN_ERROR(Status)) {
@@ -1046,7 +1068,8 @@ DebugPortInitialize (
Status = CalculateUsbDebugPortBar(&Handle.DebugPortOffset, &Handle.DebugPortBarNumber);
if (RETURN_ERROR (Status)) {
- return NULL;
+ DEBUG ((EFI_D_ERROR, "USB Debug Port: EHCI host controller does not support debug port capability!\n"));
+ goto Exit;
}
Handle.EhciMemoryBase = 0xFFFFFC00 & PciRead32(PcdGet32(PcdUsbEhciPciAddress) + PCI_BASE_ADDRESSREG_OFFSET);
@@ -1071,9 +1094,17 @@ DebugPortInitialize (
Status = InitializeUsbDebugHardware (&Handle);
if (RETURN_ERROR(Status)) {
- return NULL;
+ DEBUG ((EFI_D_ERROR, "USB Debug Port: Initialization failed, please check if USB debug cable is plugged into EHCI debug port correctly!\n"));
+ goto Exit;
}
+ //
+ // Set debug port initialized successfully flag
+ //
+ Handle.Initialized = TRUE;
+
+Exit:
+
if (Function != NULL) {
Function (Context, &Handle);
} else {
diff --git a/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugCommunicationLibUsb.inf b/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugCommunicationLibUsb.inf
index bce5659fe..61e8a7f1d 100644
--- a/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugCommunicationLibUsb.inf
+++ b/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugCommunicationLibUsb.inf
@@ -50,4 +50,5 @@
IoLib
PciLib
PcdLib
+ DebugLib