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

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