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
This commit is contained in:
vanjeff 2011-09-30 02:19:28 +00:00
parent 68085d37f8
commit e21048345b
8 changed files with 95 additions and 38 deletions

View File

@ -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

View File

@ -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>

View File

@ -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);
}
break;
return;
} 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);

View File

@ -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

View File

@ -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);

View File

@ -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

View File

@ -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 {

View File

@ -50,4 +50,5 @@
IoLib
PciLib
PcdLib
DebugLib