1. Added EFI_MEDIA_CHANGED and EFI_INVALID_PARAMETER returns in UsbMassReadBlocks().

2. Use DEBUG () to replace some native debug function in USB stack modules.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@4689 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
vanjeff 2008-02-13 09:08:24 +00:00
parent d1f076304d
commit 1c61953576
17 changed files with 236 additions and 589 deletions

View File

@ -81,7 +81,7 @@ EhcGetCapability (
*PortNumber = (UINT8) (Ehc->HcStructParams & HCSP_NPORTS); *PortNumber = (UINT8) (Ehc->HcStructParams & HCSP_NPORTS);
*Is64BitCapable = (UINT8) (Ehc->HcCapParams & HCCP_64BIT); *Is64BitCapable = (UINT8) (Ehc->HcCapParams & HCCP_64BIT);
EHC_DEBUG (("EhcGetCapability: %d ports, 64 bit %d\n", *PortNumber, *Is64BitCapable)); DEBUG ((EFI_D_INFO, "EhcGetCapability: %d ports, 64 bit %d\n", *PortNumber, *Is64BitCapable));
gBS->RestoreTPL (OldTpl); gBS->RestoreTPL (OldTpl);
return EFI_SUCCESS; return EFI_SUCCESS;
@ -161,7 +161,7 @@ EhcReset (
} }
ON_EXIT: ON_EXIT:
EHC_DEBUG (("EhcReset: exit status %r\n", Status)); DEBUG ((EFI_D_INFO, "EhcReset: exit status %r\n", Status));
gBS->RestoreTPL (OldTpl); gBS->RestoreTPL (OldTpl);
return Status; return Status;
} }
@ -206,7 +206,7 @@ EhcGetState (
gBS->RestoreTPL (OldTpl); gBS->RestoreTPL (OldTpl);
EHC_DEBUG (("EhcGetState: current state %d\n", *State)); DEBUG ((EFI_D_INFO, "EhcGetState: current state %d\n", *State));
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -281,7 +281,7 @@ EhcSetState (
Status = EFI_INVALID_PARAMETER; Status = EFI_INVALID_PARAMETER;
} }
EHC_DEBUG (("EhcSetState: exit status %r\n", Status)); DEBUG ((EFI_D_INFO, "EhcSetState: exit status %r\n", Status));
gBS->RestoreTPL (OldTpl); gBS->RestoreTPL (OldTpl);
return Status; return Status;
} }
@ -450,7 +450,7 @@ EhcSetRootHubPortFeature (
Status = EhcRunHC (Ehc, EHC_GENERIC_TIMEOUT); Status = EhcRunHC (Ehc, EHC_GENERIC_TIMEOUT);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
EHC_DEBUG (("EhcSetRootHubPortFeature :failed to start HC - %r\n", Status)); DEBUG ((EFI_D_INFO, "EhcSetRootHubPortFeature :failed to start HC - %r\n", Status));
break; break;
} }
} }
@ -480,7 +480,7 @@ EhcSetRootHubPortFeature (
} }
ON_EXIT: ON_EXIT:
EHC_DEBUG (("EhcSetRootHubPortFeature: exit status %r\n", Status)); DEBUG ((EFI_D_INFO, "EhcSetRootHubPortFeature: exit status %r\n", Status));
gBS->RestoreTPL (OldTpl); gBS->RestoreTPL (OldTpl);
return Status; return Status;
@ -608,7 +608,7 @@ EhcClearRootHubPortFeature (
} }
ON_EXIT: ON_EXIT:
EHC_DEBUG (("EhcClearRootHubPortFeature: exit status %r\n", Status)); DEBUG ((EFI_D_INFO, "EhcClearRootHubPortFeature: exit status %r\n", Status));
gBS->RestoreTPL (OldTpl); gBS->RestoreTPL (OldTpl);
return Status; return Status;
} }
@ -700,7 +700,7 @@ EhcControlTransfer (
*TransferResult = EFI_USB_ERR_SYSTEM; *TransferResult = EFI_USB_ERR_SYSTEM;
if (EhcIsHalt (Ehc) || EhcIsSysError (Ehc)) { if (EhcIsHalt (Ehc) || EhcIsSysError (Ehc)) {
EHC_ERROR (("EhcControlTransfer: HC halted at entrance\n")); DEBUG ((EFI_D_ERROR, "EhcControlTransfer: HC halted at entrance\n"));
EhcAckAllInterrupt (Ehc); EhcAckAllInterrupt (Ehc);
goto ON_EXIT; goto ON_EXIT;
@ -736,7 +736,7 @@ EhcControlTransfer (
); );
if (Urb == NULL) { if (Urb == NULL) {
EHC_ERROR (("EhcControlTransfer: failed to create URB")); DEBUG ((EFI_D_ERROR, "EhcControlTransfer: failed to create URB"));
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
goto ON_EXIT; goto ON_EXIT;
@ -765,7 +765,7 @@ ON_EXIT:
gBS->RestoreTPL (OldTpl); gBS->RestoreTPL (OldTpl);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
EHC_ERROR (("EhcControlTransfer: error - %r, transfer - %x\n", Status, *TransferResult)); DEBUG ((EFI_D_ERROR, "EhcControlTransfer: error - %r, transfer - %x\n", Status, *TransferResult));
} }
return Status; return Status;
@ -851,7 +851,7 @@ EhcBulkTransfer (
Status = EFI_DEVICE_ERROR; Status = EFI_DEVICE_ERROR;
if (EhcIsHalt (Ehc) || EhcIsSysError (Ehc)) { if (EhcIsHalt (Ehc) || EhcIsSysError (Ehc)) {
EHC_ERROR (("EhcBulkTransfer: HC is halted\n")); DEBUG ((EFI_D_ERROR, "EhcBulkTransfer: HC is halted\n"));
EhcAckAllInterrupt (Ehc); EhcAckAllInterrupt (Ehc);
goto ON_EXIT; goto ON_EXIT;
@ -881,7 +881,7 @@ EhcBulkTransfer (
); );
if (Urb == NULL) { if (Urb == NULL) {
EHC_ERROR (("EhcBulkTransfer: failed to create URB\n")); DEBUG ((EFI_D_ERROR, "EhcBulkTransfer: failed to create URB\n"));
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
goto ON_EXIT; goto ON_EXIT;
@ -907,7 +907,7 @@ ON_EXIT:
gBS->RestoreTPL (OldTpl); gBS->RestoreTPL (OldTpl);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
EHC_ERROR (("EhcBulkTransfer: error - %r, transfer - %x\n", Status, *TransferResult)); DEBUG ((EFI_D_ERROR, "EhcBulkTransfer: error - %r, transfer - %x\n", Status, *TransferResult));
} }
return Status; return Status;
@ -998,14 +998,14 @@ EhcAsyncInterruptTransfer (
if (!IsNewTransfer) { if (!IsNewTransfer) {
Status = EhciDelAsyncIntTransfer (Ehc, DeviceAddress, EndPointAddress, DataToggle); Status = EhciDelAsyncIntTransfer (Ehc, DeviceAddress, EndPointAddress, DataToggle);
EHC_DEBUG (("EhcAsyncInterruptTransfer: remove old transfer - %r\n", Status)); DEBUG ((EFI_D_INFO, "EhcAsyncInterruptTransfer: remove old transfer - %r\n", Status));
goto ON_EXIT; goto ON_EXIT;
} }
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
if (EhcIsHalt (Ehc) || EhcIsSysError (Ehc)) { if (EhcIsHalt (Ehc) || EhcIsSysError (Ehc)) {
EHC_ERROR (("EhcAsyncInterruptTransfer: HC is halt\n")); DEBUG ((EFI_D_ERROR, "EhcAsyncInterruptTransfer: HC is halt\n"));
EhcAckAllInterrupt (Ehc); EhcAckAllInterrupt (Ehc);
Status = EFI_DEVICE_ERROR; Status = EFI_DEVICE_ERROR;
@ -1017,7 +1017,7 @@ EhcAsyncInterruptTransfer (
Data = AllocatePool (DataLength); Data = AllocatePool (DataLength);
if (Data == NULL) { if (Data == NULL) {
EHC_ERROR (("EhcAsyncInterruptTransfer: failed to allocate buffer\n")); DEBUG ((EFI_D_ERROR, "EhcAsyncInterruptTransfer: failed to allocate buffer\n"));
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
goto ON_EXIT; goto ON_EXIT;
@ -1041,7 +1041,7 @@ EhcAsyncInterruptTransfer (
); );
if (Urb == NULL) { if (Urb == NULL) {
EHC_ERROR (("EhcAsyncInterruptTransfer: failed to create URB\n")); DEBUG ((EFI_D_ERROR, "EhcAsyncInterruptTransfer: failed to create URB\n"));
gBS->FreePool (Data); gBS->FreePool (Data);
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
@ -1141,7 +1141,7 @@ EhcSyncInterruptTransfer (
Status = EFI_DEVICE_ERROR; Status = EFI_DEVICE_ERROR;
if (EhcIsHalt (Ehc) || EhcIsSysError (Ehc)) { if (EhcIsHalt (Ehc) || EhcIsSysError (Ehc)) {
EHC_ERROR (("EhcSyncInterruptTransfer: HC is halt\n")); DEBUG ((EFI_D_ERROR, "EhcSyncInterruptTransfer: HC is halt\n"));
EhcAckAllInterrupt (Ehc); EhcAckAllInterrupt (Ehc);
goto ON_EXIT; goto ON_EXIT;
@ -1167,7 +1167,7 @@ EhcSyncInterruptTransfer (
); );
if (Urb == NULL) { if (Urb == NULL) {
EHC_ERROR (("EhcSyncInterruptTransfer: failed to create URB\n")); DEBUG ((EFI_D_ERROR, "EhcSyncInterruptTransfer: failed to create URB\n"));
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
goto ON_EXIT; goto ON_EXIT;
@ -1190,7 +1190,7 @@ ON_EXIT:
gBS->RestoreTPL (OldTpl); gBS->RestoreTPL (OldTpl);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
EHC_ERROR (("EhcSyncInterruptTransfer: error - %r, transfer - %x\n", Status, *TransferResult)); DEBUG ((EFI_D_ERROR, "EhcSyncInterruptTransfer: error - %r, transfer - %x\n", Status, *TransferResult));
} }
return Status; return Status;
@ -1448,7 +1448,7 @@ EhcCreateUsb2Hc (
Ehc->HcCapParams = EhcReadCapRegister (Ehc, EHC_HCCPARAMS_OFFSET); Ehc->HcCapParams = EhcReadCapRegister (Ehc, EHC_HCCPARAMS_OFFSET);
Ehc->CapLen = EhcReadCapRegister (Ehc, EHC_CAPLENGTH_OFFSET) & 0x0FF; Ehc->CapLen = EhcReadCapRegister (Ehc, EHC_CAPLENGTH_OFFSET) & 0x0FF;
EHC_DEBUG (("EhcCreateUsb2Hc: capability length %d\n", Ehc->CapLen)); DEBUG ((EFI_D_INFO, "EhcCreateUsb2Hc: capability length %d\n", Ehc->CapLen));
// //
// Create AsyncRequest Polling Timer // Create AsyncRequest Polling Timer
@ -1511,7 +1511,7 @@ EhcDriverBindingStart (
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
EHC_ERROR (("EhcDriverBindingStart: failed to open PCI_IO\n")); DEBUG ((EFI_D_ERROR, "EhcDriverBindingStart: failed to open PCI_IO\n"));
return EFI_DEVICE_ERROR; return EFI_DEVICE_ERROR;
} }
@ -1548,7 +1548,7 @@ EhcDriverBindingStart (
} }
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
EHC_ERROR (("EhcDriverBindingStart: failed to enable controller\n")); DEBUG ((EFI_D_ERROR, "EhcDriverBindingStart: failed to enable controller\n"));
goto CLOSE_PCIIO; goto CLOSE_PCIIO;
} }
@ -1558,7 +1558,7 @@ EhcDriverBindingStart (
Ehc = EhcCreateUsb2Hc (PciIo, OriginalPciAttributes); Ehc = EhcCreateUsb2Hc (PciIo, OriginalPciAttributes);
if (Ehc == NULL) { if (Ehc == NULL) {
EHC_ERROR (("EhcDriverBindingStart: failed to create USB2_HC\n")); DEBUG ((EFI_D_ERROR, "EhcDriverBindingStart: failed to create USB2_HC\n"));
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
goto CLOSE_PCIIO; goto CLOSE_PCIIO;
@ -1572,7 +1572,7 @@ EhcDriverBindingStart (
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
EHC_ERROR (("EhcDriverBindingStart: failed to install USB2_HC Protocol\n")); DEBUG ((EFI_D_ERROR, "EhcDriverBindingStart: failed to install USB2_HC Protocol\n"));
goto FREE_POOL; goto FREE_POOL;
} }
@ -1585,7 +1585,7 @@ EhcDriverBindingStart (
Status = EhcInitHC (Ehc); Status = EhcInitHC (Ehc);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
EHC_ERROR (("EhcDriverBindingStart: failed to init host controller\n")); DEBUG ((EFI_D_ERROR, "EhcDriverBindingStart: failed to init host controller\n"));
goto UNINSTALL_USBHC; goto UNINSTALL_USBHC;
} }
@ -1595,7 +1595,7 @@ EhcDriverBindingStart (
Status = gBS->SetTimer (Ehc->PollTimer, TimerPeriodic, EHC_ASYNC_POLL_INTERVAL); Status = gBS->SetTimer (Ehc->PollTimer, TimerPeriodic, EHC_ASYNC_POLL_INTERVAL);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
EHC_ERROR (("EhcDriverBindingStart: failed to start async interrupt monitor\n")); DEBUG ((EFI_D_ERROR, "EhcDriverBindingStart: failed to start async interrupt monitor\n"));
EhcHaltHC (Ehc, EHC_GENERIC_TIMEOUT); EhcHaltHC (Ehc, EHC_GENERIC_TIMEOUT);
goto UNINSTALL_USBHC; goto UNINSTALL_USBHC;
@ -1621,7 +1621,7 @@ EhcDriverBindingStart (
); );
EHC_DEBUG (("EhcDriverBindingStart: EHCI started for controller @ %x\n", Controller)); DEBUG ((EFI_D_INFO, "EhcDriverBindingStart: EHCI started for controller @ %x\n", Controller));
return EFI_SUCCESS; return EFI_SUCCESS;
UNINSTALL_USBHC: UNINSTALL_USBHC:

View File

@ -15,8 +15,6 @@ Module Name:
Abstract: Abstract:
This file provides the information dump support for EHCI when in debug mode. This file provides the information dump support for EHCI when in debug mode.
You can dynamically adjust the debug level by changing variable mEhcDebugLevel
and mEhcErrorLevel.
Revision History Revision History
@ -25,100 +23,11 @@ Revision History
#include "Ehci.h" #include "Ehci.h"
#ifdef EFI_DEBUG
UINTN mEhcDebugMask = USB_DEBUG_FORCE_OUTPUT;
/**
EHCI's debug output function. It determines whether
to output by the mask and level
@param Level The output level
@param Format The format parameters to the print
@param ... The variable length parameters after format
@return None
**/
VOID
EhciDebugPrint (
IN UINTN Level,
IN CHAR8 *Format,
...
)
{
VA_LIST Marker;
VA_START (Marker, Format);
if (Level & mEhcDebugMask) {
if (mEhcDebugMask & USB_DEBUG_FORCE_OUTPUT) {
DebugVPrint (DEBUG_ERROR, Format, Marker);
} else {
DebugVPrint (DEBUG_INFO, Format, Marker);
}
}
VA_END (Marker);
}
/**
EHCI's debug output function. It determines whether
to output by the mask and level
@param Format The format parameters to the print
@param ... The variable length parameters after format
@return None
**/
VOID
EhcDebug (
IN CHAR8 *Format,
...
)
{
VA_LIST Marker;
VA_START (Marker, Format);
DebugVPrint (DEBUG_INFO, Format, Marker);
VA_END (Marker);
}
/**
EHCI's error output function. It determines whether
to output by the mask and level
@param Format The format parameters to the print
@param ... The variable length parameters after format
@return None
**/
VOID
EhcError (
IN CHAR8 *Format,
...
)
{
VA_LIST Marker;
VA_START (Marker, Format);
DebugVPrint (DEBUG_ERROR, Format, Marker);
VA_END (Marker);
}
/** /**
Dump the status byte in QTD/QH to a more friendly Dump the status byte in QTD/QH to a more friendly
format format
@param State The state in the QTD/QH @param State The state in the QTD/QH
@param Level The output level
@return None @return None
@ -126,43 +35,42 @@ EhcError (
STATIC STATIC
VOID VOID
EhcDumpStatus ( EhcDumpStatus (
IN UINT32 State, IN UINT32 State
IN UINTN Level
) )
{ {
if (EHC_BIT_IS_SET (State, QTD_STAT_DO_PING)) { if (EHC_BIT_IS_SET (State, QTD_STAT_DO_PING)) {
EhciDebugPrint (Level, " Do_Ping"); DEBUG ((EFI_D_INFO, " Do_Ping"));
} else { } else {
EhciDebugPrint (Level, " Do_Out"); DEBUG ((EFI_D_INFO, " Do_Out"));
} }
if (EHC_BIT_IS_SET (State, QTD_STAT_DO_CS)) { if (EHC_BIT_IS_SET (State, QTD_STAT_DO_CS)) {
EhciDebugPrint (Level, " Do_CS"); DEBUG ((EFI_D_INFO, " Do_CS"));
} else { } else {
EhciDebugPrint (Level, " Do_SS"); DEBUG ((EFI_D_INFO, " Do_SS"));
} }
if (EHC_BIT_IS_SET (State, QTD_STAT_TRANS_ERR)) { if (EHC_BIT_IS_SET (State, QTD_STAT_TRANS_ERR)) {
EhciDebugPrint (Level, " Transfer_Error"); DEBUG ((EFI_D_INFO, " Transfer_Error"));
} }
if (EHC_BIT_IS_SET (State, QTD_STAT_BABBLE_ERR)) { if (EHC_BIT_IS_SET (State, QTD_STAT_BABBLE_ERR)) {
EhciDebugPrint (Level, " Babble_Error"); DEBUG ((EFI_D_INFO, " Babble_Error"));
} }
if (EHC_BIT_IS_SET (State, QTD_STAT_BUFF_ERR)) { if (EHC_BIT_IS_SET (State, QTD_STAT_BUFF_ERR)) {
EhciDebugPrint (Level, " Buffer_Error"); DEBUG ((EFI_D_INFO, " Buffer_Error"));
} }
if (EHC_BIT_IS_SET (State, QTD_STAT_HALTED)) { if (EHC_BIT_IS_SET (State, QTD_STAT_HALTED)) {
EhciDebugPrint (Level, " Halted"); DEBUG ((EFI_D_INFO, " Halted"));
} }
if (EHC_BIT_IS_SET (State, QTD_STAT_ACTIVE)) { if (EHC_BIT_IS_SET (State, QTD_STAT_ACTIVE)) {
EhciDebugPrint (Level, " Active"); DEBUG ((EFI_D_INFO, " Active"));
} }
EhciDebugPrint (Level, "\n"); DEBUG ((EFI_D_INFO, "\n"));
} }
@ -178,47 +86,44 @@ EhcDumpStatus (
VOID VOID
EhcDumpQtd ( EhcDumpQtd (
IN EHC_QTD *Qtd, IN EHC_QTD *Qtd,
IN UINT8 *Msg IN CHAR8 *Msg
) )
{ {
QTD_HW *QtdHw; QTD_HW *QtdHw;
UINTN Index; UINTN Index;
UINTN Level;
Level = EHC_DEBUG_QTD;
if (Msg != NULL) { if (Msg != NULL) {
EhciDebugPrint (Level, Msg); DEBUG ((EFI_D_INFO, Msg));
} }
EhciDebugPrint (Level, "Queue TD @ 0x%x, data length %d\n", Qtd, Qtd->DataLen); DEBUG ((EFI_D_INFO, "Queue TD @ 0x%x, data length %d\n", Qtd, Qtd->DataLen));
QtdHw = &Qtd->QtdHw; QtdHw = &Qtd->QtdHw;
EhciDebugPrint (Level, "Next QTD : %x\n", QtdHw->NextQtd); DEBUG ((EFI_D_INFO, "Next QTD : %x\n", QtdHw->NextQtd));
EhciDebugPrint (Level, "AltNext QTD : %x\n", QtdHw->AltNext); DEBUG ((EFI_D_INFO, "AltNext QTD : %x\n", QtdHw->AltNext));
EhciDebugPrint (Level, "Status : %x\n", QtdHw->Status); DEBUG ((EFI_D_INFO, "Status : %x\n", QtdHw->Status));
EhcDumpStatus (QtdHw->Status, Level); EhcDumpStatus (QtdHw->Status);
if (QtdHw->Pid == QTD_PID_SETUP) { if (QtdHw->Pid == QTD_PID_SETUP) {
EhciDebugPrint (Level, "PID : Setup\n"); DEBUG ((EFI_D_INFO, "PID : Setup\n"));
} else if (QtdHw->Pid == QTD_PID_INPUT) { } else if (QtdHw->Pid == QTD_PID_INPUT) {
EhciDebugPrint (Level, "PID : IN\n"); DEBUG ((EFI_D_INFO, "PID : IN\n"));
} else if (QtdHw->Pid == QTD_PID_OUTPUT) { } else if (QtdHw->Pid == QTD_PID_OUTPUT) {
EhciDebugPrint (Level, "PID : OUT\n"); DEBUG ((EFI_D_INFO, "PID : OUT\n"));
} }
EhciDebugPrint (Level, "Error Count : %d\n", QtdHw->ErrCnt); DEBUG ((EFI_D_INFO, "Error Count : %d\n", QtdHw->ErrCnt));
EhciDebugPrint (Level, "Current Page : %d\n", QtdHw->CurPage); DEBUG ((EFI_D_INFO, "Current Page : %d\n", QtdHw->CurPage));
EhciDebugPrint (Level, "IOC : %d\n", QtdHw->IOC); DEBUG ((EFI_D_INFO, "IOC : %d\n", QtdHw->IOC));
EhciDebugPrint (Level, "Total Bytes : %d\n", QtdHw->TotalBytes); DEBUG ((EFI_D_INFO, "Total Bytes : %d\n", QtdHw->TotalBytes));
EhciDebugPrint (Level, "Data Toggle : %d\n", QtdHw->DataToggle); DEBUG ((EFI_D_INFO, "Data Toggle : %d\n", QtdHw->DataToggle));
for (Index = 0; Index < 5; Index++) { for (Index = 0; Index < 5; Index++) {
EhciDebugPrint (Level, "Page[%d] : 0x%x\n", Index, QtdHw->Page[Index]); DEBUG ((EFI_D_INFO, "Page[%d] : 0x%x\n", Index, QtdHw->Page[Index]));
} }
} }
@ -236,7 +141,7 @@ EhcDumpQtd (
VOID VOID
EhcDumpQh ( EhcDumpQh (
IN EHC_QH *Qh, IN EHC_QH *Qh,
IN UINT8 *Msg, IN CHAR8 *Msg,
IN BOOLEAN DumpBuf IN BOOLEAN DumpBuf
) )
{ {
@ -244,64 +149,62 @@ EhcDumpQh (
QH_HW *QhHw; QH_HW *QhHw;
LIST_ENTRY *Entry; LIST_ENTRY *Entry;
UINTN Index; UINTN Index;
UINTN Level;
Level = EHC_DEBUG_QH;
if (Msg != NULL) { if (Msg != NULL) {
EhciDebugPrint (Level, Msg); DEBUG ((EFI_D_INFO, Msg));
} }
EhciDebugPrint (Level, "Queue head @ 0x%x, interval %d, next qh %x\n", DEBUG ((EFI_D_INFO, "Queue head @ 0x%x, interval %d, next qh %x\n",
Qh, Qh->Interval, Qh->NextQh); Qh, Qh->Interval, Qh->NextQh));
QhHw = &Qh->QhHw; QhHw = &Qh->QhHw;
EhciDebugPrint (Level, "Hoziontal link: %x\n", QhHw->HorizonLink); DEBUG ((EFI_D_INFO, "Hoziontal link: %x\n", QhHw->HorizonLink));
EhciDebugPrint (Level, "Device address: %d\n", QhHw->DeviceAddr); DEBUG ((EFI_D_INFO, "Device address: %d\n", QhHw->DeviceAddr));
EhciDebugPrint (Level, "Inactive : %d\n", QhHw->Inactive); DEBUG ((EFI_D_INFO, "Inactive : %d\n", QhHw->Inactive));
EhciDebugPrint (Level, "EP number : %d\n", QhHw->EpNum); DEBUG ((EFI_D_INFO, "EP number : %d\n", QhHw->EpNum));
EhciDebugPrint (Level, "EP speed : %d\n", QhHw->EpSpeed); DEBUG ((EFI_D_INFO, "EP speed : %d\n", QhHw->EpSpeed));
EhciDebugPrint (Level, "DT control : %d\n", QhHw->DtCtrl); DEBUG ((EFI_D_INFO, "DT control : %d\n", QhHw->DtCtrl));
EhciDebugPrint (Level, "Reclaim head : %d\n", QhHw->ReclaimHead); DEBUG ((EFI_D_INFO, "Reclaim head : %d\n", QhHw->ReclaimHead));
EhciDebugPrint (Level, "Max packet len: %d\n", QhHw->MaxPacketLen); DEBUG ((EFI_D_INFO, "Max packet len: %d\n", QhHw->MaxPacketLen));
EhciDebugPrint (Level, "Ctrl EP : %d\n", QhHw->CtrlEp); DEBUG ((EFI_D_INFO, "Ctrl EP : %d\n", QhHw->CtrlEp));
EhciDebugPrint (Level, "Nak reload : %d\n", QhHw->NakReload); DEBUG ((EFI_D_INFO, "Nak reload : %d\n", QhHw->NakReload));
EhciDebugPrint (Level, "SMask : %x\n", QhHw->SMask); DEBUG ((EFI_D_INFO, "SMask : %x\n", QhHw->SMask));
EhciDebugPrint (Level, "CMask : %x\n", QhHw->CMask); DEBUG ((EFI_D_INFO, "CMask : %x\n", QhHw->CMask));
EhciDebugPrint (Level, "Hub address : %d\n", QhHw->HubAddr); DEBUG ((EFI_D_INFO, "Hub address : %d\n", QhHw->HubAddr));
EhciDebugPrint (Level, "Hub port : %d\n", QhHw->PortNum); DEBUG ((EFI_D_INFO, "Hub port : %d\n", QhHw->PortNum));
EhciDebugPrint (Level, "Multiplier : %d\n", QhHw->Multiplier); DEBUG ((EFI_D_INFO, "Multiplier : %d\n", QhHw->Multiplier));
EhciDebugPrint (Level, "Cur QTD : %x\n", QhHw->CurQtd); DEBUG ((EFI_D_INFO, "Cur QTD : %x\n", QhHw->CurQtd));
EhciDebugPrint (Level, "Next QTD : %x\n", QhHw->NextQtd); DEBUG ((EFI_D_INFO, "Next QTD : %x\n", QhHw->NextQtd));
EhciDebugPrint (Level, "AltNext QTD : %x\n", QhHw->AltQtd); DEBUG ((EFI_D_INFO, "AltNext QTD : %x\n", QhHw->AltQtd));
EhciDebugPrint (Level, "Status : %x\n", QhHw->Status); DEBUG ((EFI_D_INFO, "Status : %x\n", QhHw->Status));
EhcDumpStatus (QhHw->Status, Level);
EhcDumpStatus (QhHw->Status);
if (QhHw->Pid == QTD_PID_SETUP) { if (QhHw->Pid == QTD_PID_SETUP) {
EhciDebugPrint (Level, "PID : Setup\n"); DEBUG ((EFI_D_INFO, "PID : Setup\n"));
} else if (QhHw->Pid == QTD_PID_INPUT) { } else if (QhHw->Pid == QTD_PID_INPUT) {
EhciDebugPrint (Level, "PID : IN\n"); DEBUG ((EFI_D_INFO, "PID : IN\n"));
} else if (QhHw->Pid == QTD_PID_OUTPUT) { } else if (QhHw->Pid == QTD_PID_OUTPUT) {
EhciDebugPrint (Level, "PID : OUT\n"); DEBUG ((EFI_D_INFO, "PID : OUT\n"));
} }
EhciDebugPrint (Level, "Error Count : %d\n", QhHw->ErrCnt); DEBUG ((EFI_D_INFO, "Error Count : %d\n", QhHw->ErrCnt));
EhciDebugPrint (Level, "Current Page : %d\n", QhHw->CurPage); DEBUG ((EFI_D_INFO, "Current Page : %d\n", QhHw->CurPage));
EhciDebugPrint (Level, "IOC : %d\n", QhHw->IOC); DEBUG ((EFI_D_INFO, "IOC : %d\n", QhHw->IOC));
EhciDebugPrint (Level, "Total Bytes : %d\n", QhHw->TotalBytes); DEBUG ((EFI_D_INFO, "Total Bytes : %d\n", QhHw->TotalBytes));
EhciDebugPrint (Level, "Data Toggle : %d\n", QhHw->DataToggle); DEBUG ((EFI_D_INFO, "Data Toggle : %d\n", QhHw->DataToggle));
for (Index = 0; Index < 5; Index++) { for (Index = 0; Index < 5; Index++) {
EhciDebugPrint (Level, "Page[%d] : 0x%x\n", Index, QhHw->Page[Index]); DEBUG ((EFI_D_INFO, "Page[%d] : 0x%x\n", Index, QhHw->Page[Index]));
} }
EhciDebugPrint (Level, "\n"); DEBUG ((EFI_D_INFO, "\n"));
EFI_LIST_FOR_EACH (Entry, &Qh->Qtds) { EFI_LIST_FOR_EACH (Entry, &Qh->Qtds) {
Qtd = EFI_LIST_CONTAINER (Entry, EHC_QTD, QtdList); Qtd = EFI_LIST_CONTAINER (Entry, EHC_QTD, QtdList);
@ -333,13 +236,11 @@ EhcDumpBuf (
for (Index = 0; Index < Len; Index++) { for (Index = 0; Index < Len; Index++) {
if (Index % 16 == 0) { if (Index % 16 == 0) {
EhciDebugPrint (EHC_DEBUG_BUF, "\n"); DEBUG ((EFI_D_INFO,"\n"));
} }
EhciDebugPrint (EHC_DEBUG_BUF, "%02x ", Buf[Index]); DEBUG ((EFI_D_INFO, "%02x ", Buf[Index]));
} }
EhciDebugPrint (EHC_DEBUG_BUF, "\n"); DEBUG ((EFI_D_INFO, "\n"));
} }
#endif

View File

@ -25,73 +25,6 @@ Revision History
#define _EFI_EHCI_DEBUG_H_ #define _EFI_EHCI_DEBUG_H_
enum {
USB_DEBUG_FORCE_OUTPUT = (UINTN)(1 << 0),
EHC_DEBUG_QH = (UINTN)(1 << 8),
EHC_DEBUG_QTD = (UINTN)(1 << 9),
EHC_DEBUG_BUF = (UINTN)(1 << 10)
};
/**
EHCI's debug output function. It determines whether
to output by the mask and level
@param Level The output level
@param Format The format parameters to the print
@param ... The variable length parameters after format
@return None
**/
VOID
EhciDebugPrint (
IN UINTN Level,
IN CHAR8 *Format,
...
)
;
/**
EHCI's debug output function. It determines whether
to output by the mask and level
@param Format The format parameters to the print
@param ... The variable length parameters after format
@return None
**/
VOID
EhcDebug (
IN CHAR8 *Format,
...
)
;
/**
EHCI's error output function. It determines whether
to output by the mask and level
@param Format The format parameters to the print
@param ... The variable length parameters after format
@return None
**/
VOID
EhcError (
IN CHAR8 *Format,
...
)
;
/** /**
Dump the fields of a QTD Dump the fields of a QTD
@ -104,7 +37,7 @@ EhcError (
VOID VOID
EhcDumpQtd ( EhcDumpQtd (
IN EHC_QTD *Qtd, IN EHC_QTD *Qtd,
IN UINT8 *Msg IN CHAR8 *Msg
) )
; ;
@ -123,7 +56,7 @@ EhcDumpQtd (
VOID VOID
EhcDumpQh ( EhcDumpQh (
IN EHC_QH *Qh, IN EHC_QH *Qh,
IN UINT8 *Msg, IN CHAR8 *Msg,
IN BOOLEAN DumpBuf IN BOOLEAN DumpBuf
) )
; ;
@ -146,18 +79,4 @@ EhcDumpBuf (
) )
; ;
#ifdef EFI_DEBUG
#define EHC_DEBUG(arg) EhcDebug arg
#define EHC_ERROR(arg) EhcError arg
#define EHC_DUMP_QH(arg) EhcDumpQh arg
#define EHC_DUMP_QTD(arg) EhcDumpQtd arg
#define EHC_DUMP_BUF(arg) EhcDumpBuf arg
#else
#define EHC_DEBUG(arg)
#define EHC_ERROR(arg)
#define EHC_DUMP_QH(arg)
#define EHC_DUMP_QTD(arg)
#define EHC_DUMP_BUF(arg)
#endif
#endif #endif

View File

@ -54,7 +54,7 @@ EhcReadCapRegister (
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
EHC_ERROR (("EhcReadCapRegister: Pci Io read error - %r at %d\n", Status, Offset)); DEBUG ((EFI_D_ERROR, "EhcReadCapRegister: Pci Io read error - %r at %d\n", Status, Offset));
Data = 0xFFFF; Data = 0xFFFF;
} }
@ -92,7 +92,7 @@ EhcReadOpReg (
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
EHC_ERROR (("EhcReadOpReg: Pci Io Read error - %r at %d\n", Status, Offset)); DEBUG ((EFI_D_ERROR, "EhcReadOpReg: Pci Io Read error - %r at %d\n", Status, Offset));
Data = 0xFFFF; Data = 0xFFFF;
} }
@ -131,7 +131,7 @@ EhcWriteOpReg (
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
EHC_ERROR (("EhcWriteOpReg: Pci Io Write error: %r at %d\n", Status, Offset)); DEBUG ((EFI_D_ERROR, "EhcWriteOpReg: Pci Io Write error: %r at %d\n", Status, Offset));
} }
} }
@ -245,7 +245,7 @@ EhcClearLegacySupport (
UINT32 Value; UINT32 Value;
UINT32 TimeOut; UINT32 TimeOut;
EHC_DEBUG (("EhcClearLegacySupport: called to clear legacy support\n")); DEBUG ((EFI_D_INFO, "EhcClearLegacySupport: called to clear legacy support\n"));
PciIo = Ehc->PciIo; PciIo = Ehc->PciIo;
ExtendCap = (Ehc->HcCapParams >> 8) & 0xFF; ExtendCap = (Ehc->HcCapParams >> 8) & 0xFF;
@ -622,14 +622,14 @@ EhcInitHC (
Status = EhcEnablePeriodSchd (Ehc, EHC_GENERIC_TIMEOUT); Status = EhcEnablePeriodSchd (Ehc, EHC_GENERIC_TIMEOUT);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
EHC_ERROR (("EhcInitHC: failed to enable period schedule\n")); DEBUG ((EFI_D_ERROR, "EhcInitHC: failed to enable period schedule\n"));
return Status; return Status;
} }
Status = EhcEnableAsyncSchd (Ehc, EHC_GENERIC_TIMEOUT); Status = EhcEnableAsyncSchd (Ehc, EHC_GENERIC_TIMEOUT);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
EHC_ERROR (("EhcInitHC: failed to enable async schedule\n")); DEBUG ((EFI_D_ERROR, "EhcInitHC: failed to enable async schedule\n"));
return Status; return Status;
} }

View File

@ -345,7 +345,7 @@ EhcUnlinkQhFromAsync (
Status = EhcSetAndWaitDoorBell (Ehc, EHC_GENERIC_TIMEOUT); Status = EhcSetAndWaitDoorBell (Ehc, EHC_GENERIC_TIMEOUT);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
EHC_ERROR (("EhcUnlinkQhFromAsync: Failed to synchronize with doorbell\n")); DEBUG ((EFI_D_ERROR, "EhcUnlinkQhFromAsync: Failed to synchronize with doorbell\n"));
} }
} }
@ -598,7 +598,7 @@ EhcCheckUrbResult (
} }
if ((QtdHw->TotalBytes != 0) && (QtdHw->Pid == QTD_PID_INPUT)) { if ((QtdHw->TotalBytes != 0) && (QtdHw->Pid == QTD_PID_INPUT)) {
EHC_DUMP_QH ((Urb->Qh, "Short packet read", FALSE)); EhcDumpQh (Urb->Qh, "Short packet read", FALSE);
// //
// Short packet read condition. If it isn't a setup transfer, // Short packet read condition. If it isn't a setup transfer,
@ -607,13 +607,13 @@ EhcCheckUrbResult (
// Status Stage of the setup transfer to get the finial result // Status Stage of the setup transfer to get the finial result
// //
if (QtdHw->AltNext == QTD_LINK (Ehc->ShortReadStop, FALSE)) { if (QtdHw->AltNext == QTD_LINK (Ehc->ShortReadStop, FALSE)) {
EHC_DEBUG (("EhcCheckUrbResult: Short packet read, break\n")); DEBUG ((EFI_D_INFO, "EhcCheckUrbResult: Short packet read, break\n"));
Finished = TRUE; Finished = TRUE;
goto ON_EXIT; goto ON_EXIT;
} }
EHC_DEBUG (("EhcCheckUrbResult: Short packet read, continue\n")); DEBUG ((EFI_D_INFO, "EhcCheckUrbResult: Short packet read, continue\n"));
} }
} }
} }
@ -673,14 +673,14 @@ EhcExecTransfer (
} }
if (!Finished) { if (!Finished) {
EHC_ERROR (("EhcExecTransfer: transfer not finished in %dms\n", TimeOut)); DEBUG ((EFI_D_ERROR, "EhcExecTransfer: transfer not finished in %dms\n", TimeOut));
EHC_DUMP_QH ((Urb->Qh, NULL, FALSE)); EhcDumpQh (Urb->Qh, NULL, FALSE);
Status = EFI_TIMEOUT; Status = EFI_TIMEOUT;
} else if (Urb->Result != EFI_USB_NOERROR) { } else if (Urb->Result != EFI_USB_NOERROR) {
EHC_ERROR (("EhcExecTransfer: transfer failed with %x\n", Urb->Result)); DEBUG ((EFI_D_ERROR, "EhcExecTransfer: transfer failed with %x\n", Urb->Result));
EHC_DUMP_QH ((Urb->Qh, NULL, FALSE)); EhcDumpQh (Urb->Qh, NULL, FALSE);
Status = EFI_DEVICE_ERROR; Status = EFI_DEVICE_ERROR;
} }
@ -958,7 +958,7 @@ EhcMoniteAsyncRequests (
// //
Status = EhcFlushAsyncIntMap (Ehc, Urb); Status = EhcFlushAsyncIntMap (Ehc, Urb);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
EHC_ERROR (("EhcMoniteAsyncRequests: Fail to Flush AsyncInt Mapped Memeory\n")); DEBUG ((EFI_D_ERROR, "EhcMoniteAsyncRequests: Fail to Flush AsyncInt Mapped Memeory\n"));
} }
// //

View File

@ -24,9 +24,6 @@ Revision History
#include "Ehci.h" #include "Ehci.h"
UINTN mUsbHcDebugLevel = DEBUG_INFO;
/** /**
Allocate a block of memory to be used by the buffer pool Allocate a block of memory to be used by the buffer pool
@ -117,9 +114,6 @@ UsbHcAllocMemBlock (
Block->Buf = (UINT8 *) ((UINTN) MappedAddr); Block->Buf = (UINT8 *) ((UINTN) MappedAddr);
Block->Mapping = Mapping; Block->Mapping = Mapping;
DEBUG ((mUsbHcDebugLevel, "UsbHcAllocMemBlock: block %x created with buffer %x\n",
Block, Block->Buf));
return Block; return Block;
FREE_BUFFER: FREE_BUFFER:
@ -455,7 +449,7 @@ UsbHcAllocateMem (
NewBlock = UsbHcAllocMemBlock (Pool, Pages); NewBlock = UsbHcAllocMemBlock (Pool, Pages);
if (NewBlock == NULL) { if (NewBlock == NULL) {
DEBUG ((mUsbHcDebugLevel, "UsbHcAllocateMem: failed to allocate block\n")); DEBUG ((EFI_D_INFO, "UsbHcAllocateMem: failed to allocate block\n"));
return NULL; return NULL;
} }
@ -539,8 +533,6 @@ UsbHcFreeMem (
// Release the current memory block if it is empty and not the head // Release the current memory block if it is empty and not the head
// //
if ((Block != Head) && UsbHcIsMemBlockEmpty (Block)) { if ((Block != Head) && UsbHcIsMemBlockEmpty (Block)) {
DEBUG ((mUsbHcDebugLevel, "UsbHcFreeMem: block %x is empty, recycle\n", Block));
UsbHcUnlinkMemBlock (Head, Block); UsbHcUnlinkMemBlock (Head, Block);
UsbHcFreeMemBlock (Pool, Block); UsbHcFreeMemBlock (Pool, Block);
} }

View File

@ -320,7 +320,7 @@ Uhci2GetCapability (
Uhc->RootPorts = *PortNumber; Uhc->RootPorts = *PortNumber;
UHCI_DEBUG (("Uhci2GetCapability: %d ports\n", Uhc->RootPorts)); DEBUG ((EFI_D_INFO, "Uhci2GetCapability: %d ports\n", Uhc->RootPorts));
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -376,7 +376,7 @@ Uhci2GetRootHubPortStatus (
} }
if (PortSC & USBPORTSC_SUSP) { if (PortSC & USBPORTSC_SUSP) {
UHCI_DEBUG (("Uhci2GetRootHubPortStatus: port %d is suspended\n", PortNumber)); DEBUG ((EFI_D_INFO, "Uhci2GetRootHubPortStatus: port %d is suspended\n", PortNumber));
PortStatus->PortStatus |= USB_PORT_STAT_SUSPEND; PortStatus->PortStatus |= USB_PORT_STAT_SUSPEND;
} }

View File

@ -16,8 +16,6 @@ Module Name:
Abstract: Abstract:
This file provides the information dump support for Uhci when in debug mode. This file provides the information dump support for Uhci when in debug mode.
You can dynamically adjust the debug level by changing variable gEHCDebugLevel
and gEHCErrorLevel.
Revision History Revision History
@ -27,87 +25,6 @@ Revision History
#include "Uhci.h" #include "Uhci.h"
#include "UhciDebug.h" #include "UhciDebug.h"
#ifdef EFI_DEBUG
UINTN mUhciDebugMask = USB_DEBUG_FORCE_OUTPUT;
/**
Debug debug print interface for UHCI
@param Format String to use for the print, followed by print arguments
@return None
**/
VOID
UhciDebug (
IN CHAR8 *Format,
...
)
{
VA_LIST Marker;
VA_START (Marker, Format);
DebugVPrint (DEBUG_INFO, Format, Marker);
VA_END (Marker);
}
/**
Debug error print interface for UHCI
@param Format String to use for the print, followed by print arguments
@return None
**/
VOID
UhciError (
IN CHAR8 *Format,
...
)
{
VA_LIST Marker;
VA_START (Marker, Format);
DebugVPrint (DEBUG_ERROR, Format, Marker);
VA_END (Marker);
}
/**
Debug print interface for UHCI
@param Level Level to control debug print
@param Format String to use for the print, followed by print arguments
@return None
**/
VOID
UhciDebugPrint (
IN UINTN Level,
IN CHAR8 *Format,
...
)
{
VA_LIST Marker;
VA_START (Marker, Format);
if (Level & mUhciDebugMask) {
if (mUhciDebugMask & USB_DEBUG_FORCE_OUTPUT) {
DebugVPrint (DEBUG_ERROR, Format, Marker);
} else {
DebugVPrint (DEBUG_INFO, Format, Marker);
}
}
VA_END (Marker);
}
/** /**
Dump the content of QH structure Dump the content of QH structure
@ -122,16 +39,12 @@ UhciDumpQh (
IN UHCI_QH_SW *QhSw IN UHCI_QH_SW *QhSw
) )
{ {
UINTN Level; DEBUG ((EFI_D_INFO, "&QhSw @ 0x%x\n", QhSw));
DEBUG ((EFI_D_INFO, "QhSw.NextQh - 0x%x\n", QhSw->NextQh));
Level = UHCI_DEBUG_QH; DEBUG ((EFI_D_INFO, "QhSw.TDs - 0x%x\n", QhSw->TDs));
DEBUG ((EFI_D_INFO, "QhSw.QhHw:\n"));
UhciDebugPrint (Level, "&QhSw @ 0x%x\n", QhSw); DEBUG ((EFI_D_INFO, " Horizon Link - %x\n", QhSw->QhHw.HorizonLink));
UhciDebugPrint (Level, "QhSw.NextQh - 0x%x\n", QhSw->NextQh); DEBUG ((EFI_D_INFO, " Vertical Link - %x\n\n", QhSw->QhHw.VerticalLink));
UhciDebugPrint (Level, "QhSw.TDs - 0x%x\n", QhSw->TDs);
UhciDebugPrint (Level, "QhSw.QhHw:\n");
UhciDebugPrint (Level, " Horizon Link - %x\n", QhSw->QhHw.HorizonLink);
UhciDebugPrint (Level, " Vertical Link - %x\n\n", QhSw->QhHw.VerticalLink);
} }
@ -150,34 +63,31 @@ UhciDumpTds (
) )
{ {
UHCI_TD_SW *CurTdSw; UHCI_TD_SW *CurTdSw;
UINTN Level;
Level = UHCI_DEBUG_TD;
CurTdSw = TdSw; CurTdSw = TdSw;
while (CurTdSw != NULL) { while (CurTdSw != NULL) {
UhciDebugPrint (Level, "TdSw @ 0x%x\n", CurTdSw); DEBUG ((EFI_D_INFO, "TdSw @ 0x%x\n", CurTdSw));
UhciDebugPrint (Level, "TdSw.NextTd - 0x%x\n", CurTdSw->NextTd); DEBUG ((EFI_D_INFO, "TdSw.NextTd - 0x%x\n", CurTdSw->NextTd));
UhciDebugPrint (Level, "TdSw.DataLen - %d\n", CurTdSw->DataLen); DEBUG ((EFI_D_INFO, "TdSw.DataLen - %d\n", CurTdSw->DataLen));
UhciDebugPrint (Level, "TdSw.Data - 0x%x\n", CurTdSw->Data); DEBUG ((EFI_D_INFO, "TdSw.Data - 0x%x\n", CurTdSw->Data));
UhciDebugPrint (Level, "TdHw:\n"); DEBUG ((EFI_D_INFO, "TdHw:\n"));
UhciDebugPrint (Level, " NextLink - 0x%x\n", CurTdSw->TdHw.NextLink); DEBUG ((EFI_D_INFO, " NextLink - 0x%x\n", CurTdSw->TdHw.NextLink));
UhciDebugPrint (Level, " ActualLen - %d\n", CurTdSw->TdHw.ActualLen); DEBUG ((EFI_D_INFO, " ActualLen - %d\n", CurTdSw->TdHw.ActualLen));
UhciDebugPrint (Level, " Status - 0x%x\n", CurTdSw->TdHw.Status); DEBUG ((EFI_D_INFO, " Status - 0x%x\n", CurTdSw->TdHw.Status));
UhciDebugPrint (Level, " IOC - %d\n", CurTdSw->TdHw.IntOnCpl); DEBUG ((EFI_D_INFO, " IOC - %d\n", CurTdSw->TdHw.IntOnCpl));
UhciDebugPrint (Level, " IsIsoCh - %d\n", CurTdSw->TdHw.IsIsoch); DEBUG ((EFI_D_INFO, " IsIsoCh - %d\n", CurTdSw->TdHw.IsIsoch));
UhciDebugPrint (Level, " LowSpeed - %d\n", CurTdSw->TdHw.LowSpeed); DEBUG ((EFI_D_INFO, " LowSpeed - %d\n", CurTdSw->TdHw.LowSpeed));
UhciDebugPrint (Level, " ErrorCount - %d\n", CurTdSw->TdHw.ErrorCount); DEBUG ((EFI_D_INFO, " ErrorCount - %d\n", CurTdSw->TdHw.ErrorCount));
UhciDebugPrint (Level, " ShortPacket - %d\n", CurTdSw->TdHw.ShortPacket); DEBUG ((EFI_D_INFO, " ShortPacket - %d\n", CurTdSw->TdHw.ShortPacket));
UhciDebugPrint (Level, " PidCode - 0x%x\n", CurTdSw->TdHw.PidCode); DEBUG ((EFI_D_INFO, " PidCode - 0x%x\n", CurTdSw->TdHw.PidCode));
UhciDebugPrint (Level, " DevAddr - %d\n", CurTdSw->TdHw.DeviceAddr); DEBUG ((EFI_D_INFO, " DevAddr - %d\n", CurTdSw->TdHw.DeviceAddr));
UhciDebugPrint (Level, " EndPoint - %d\n", CurTdSw->TdHw.EndPoint); DEBUG ((EFI_D_INFO, " EndPoint - %d\n", CurTdSw->TdHw.EndPoint));
UhciDebugPrint (Level, " DataToggle - %d\n", CurTdSw->TdHw.DataToggle); DEBUG ((EFI_D_INFO, " DataToggle - %d\n", CurTdSw->TdHw.DataToggle));
UhciDebugPrint (Level, " MaxPacketLen - %d\n", CurTdSw->TdHw.MaxPacketLen); DEBUG ((EFI_D_INFO, " MaxPacketLen - %d\n", CurTdSw->TdHw.MaxPacketLen));
UhciDebugPrint (Level, " DataBuffer - 0x%x\n\n",CurTdSw->TdHw.DataBuffer); DEBUG ((EFI_D_INFO, " DataBuffer - 0x%x\n\n",CurTdSw->TdHw.DataBuffer));
CurTdSw = CurTdSw->NextTd; CurTdSw = CurTdSw->NextTd;
} }
} }
#endif

View File

@ -25,69 +25,6 @@ Revision History
#ifndef _EFI_UHCI_DEBUG_H_ #ifndef _EFI_UHCI_DEBUG_H_
#define _EFI_UHCI_DEBUG_H_ #define _EFI_UHCI_DEBUG_H_
//
// DEBUG support
//
#define USB_DEBUG_FORCE_OUTPUT (UINTN) (1 << 0)
#define UHCI_DEBUG_QH (UINTN) (1 << 2)
#define UHCI_DEBUG_TD (UINTN) (1 << 3)
VOID
UhciDebugPrint (
IN UINTN Level,
IN CHAR8 *Format,
...
)
/*++
Routine Description:
Debug print interface for UHCI
Arguments:
Level - Level to control debug print
Format - String to use for the print, followed by print arguments
Returns:
None
--*/
;
/**
Debug print interface for UHCI
@param Format String to use for the print, followed by print arguments
@return None
**/
VOID
UhciDebug (
IN CHAR8 *Format,
...
)
;
/**
Debug error print interface for UHCI
@param Format String to use for the print, followed by print arguments
@return None
**/
VOID
UhciError (
IN CHAR8 *Format,
...
)
;
/** /**
Dump the content of QH structure Dump the content of QH structure
@ -118,17 +55,4 @@ UhciDumpTds (
) )
; ;
#ifdef EFI_DEBUG
#define UHCI_DEBUG(arg) UhciDebug arg
#define UHCI_ERROR(arg) UhciError arg
#define UHCI_DUMP_TDS(arg) UhciDumpTds arg
#define UHCI_DUMP_QH(arg) UhciDumpQh arg
#else
#define UHCI_DEBUG(arg)
#define UHCI_ERROR(arg)
#define UHCI_DUMP_TDS(arg)
#define UHCI_DUMP_QH(arg)
#endif
#endif #endif

View File

@ -53,7 +53,7 @@ UhciReadReg (
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
UHCI_ERROR (("UhciReadReg: PciIo Io.Read error: %r at offset %d\n", Status, Offset)); DEBUG ((EFI_D_ERROR, "UhciReadReg: PciIo Io.Read error: %r at offset %d\n", Status, Offset));
Data = 0xFFFF; Data = 0xFFFF;
} }
@ -91,7 +91,7 @@ UhciWriteReg (
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
UHCI_ERROR (("UhciWriteReg: PciIo Io.Write error: %r at offset %d\n", Status, Offset)); DEBUG ((EFI_D_ERROR, "UhciWriteReg: PciIo Io.Write error: %r at offset %d\n", Status, Offset));
} }
} }
@ -167,7 +167,7 @@ UhciAckAllInterrupt (
// is a temporary error status. // is a temporary error status.
// //
if (!UhciIsHcWorking (Uhc->PciIo)) { if (!UhciIsHcWorking (Uhc->PciIo)) {
UHCI_ERROR (("UhciAckAllInterrupt: re-enable the UHCI from system error\n")); DEBUG ((EFI_D_ERROR, "UhciAckAllInterrupt: re-enable the UHCI from system error\n"));
Uhc->Usb2Hc.SetState (&Uhc->Usb2Hc, EfiUsbHcStateOperational); Uhc->Usb2Hc.SetState (&Uhc->Usb2Hc, EfiUsbHcStateOperational);
} }
} }
@ -232,7 +232,7 @@ UhciIsHcWorking (
UsbSts = UhciReadReg (PciIo, USBSTS_OFFSET); UsbSts = UhciReadReg (PciIo, USBSTS_OFFSET);
if (UsbSts & (USBSTS_HCPE | USBSTS_HSE | USBSTS_HCH)) { if (UsbSts & (USBSTS_HCPE | USBSTS_HSE | USBSTS_HCH)) {
UHCI_ERROR (("UhciIsHcWorking: current USB state is %x\n", UsbSts)); DEBUG ((EFI_D_ERROR, "UhciIsHcWorking: current USB state is %x\n", UsbSts));
return FALSE; return FALSE;
} }
@ -271,7 +271,7 @@ UhciSetFrameListBaseAddr (
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
UHCI_ERROR (("UhciSetFrameListBaseAddr: PciIo Io.Write error: %r\n", Status)); DEBUG ((EFI_D_ERROR, "UhciSetFrameListBaseAddr: PciIo Io.Write error: %r\n", Status));
} }
} }

View File

@ -121,11 +121,7 @@ UhciInitFrameList (
// in supporting the full speed bandwidth reclamation in the previous // in supporting the full speed bandwidth reclamation in the previous
// mentioned form. Most new platforms don't suffer it. // mentioned form. Most new platforms don't suffer it.
// //
#ifdef UHCI_NO_BW_RECLAMATION
Uhc->BulkQh->QhHw.HorizonLink = QH_HLINK (NULL, TRUE);
#else
Uhc->BulkQh->QhHw.HorizonLink = QH_HLINK (Uhc->BulkQh, FALSE); Uhc->BulkQh->QhHw.HorizonLink = QH_HLINK (Uhc->BulkQh, FALSE);
#endif
Uhc->BulkQh->NextQh = NULL; Uhc->BulkQh->NextQh = NULL;
@ -515,7 +511,7 @@ UhciCheckTdStatus (
// terminate the transfer // terminate the transfer
// //
if (!IsLow && (TdHw->ShortPacket == 1) && (Len < Td->DataLen)) { if (!IsLow && (TdHw->ShortPacket == 1) && (Len < Td->DataLen)) {
UHCI_DEBUG (("UhciCheckTdStatus: short packet read occured\n")); DEBUG ((EFI_D_INFO, "UhciCheckTdStatus: short packet read occured\n"));
Finished = TRUE; Finished = TRUE;
goto ON_EXIT; goto ON_EXIT;
@ -591,16 +587,16 @@ UhciExecuteTransfer (
} }
if (!Finished) { if (!Finished) {
UHCI_ERROR (("UhciExecuteTransfer: execution not finished for %dms\n", TimeOut)); DEBUG ((EFI_D_ERROR, "UhciExecuteTransfer: execution not finished for %dms\n", TimeOut));
UHCI_DUMP_QH ((Qh)); UhciDumpQh (Qh);
UHCI_DUMP_TDS ((Td)); UhciDumpTds (Td);
Status = EFI_TIMEOUT; Status = EFI_TIMEOUT;
} else if (QhResult->Result != EFI_USB_NOERROR) { } else if (QhResult->Result != EFI_USB_NOERROR) {
UHCI_ERROR (("UhciExecuteTransfer: execution failed with result %x\n", QhResult->Result)); DEBUG ((EFI_D_ERROR, "UhciExecuteTransfer: execution failed with result %x\n", QhResult->Result));
UHCI_DUMP_QH ((Qh)); UhciDumpQh (Qh);
UHCI_DUMP_TDS ((Td)); UhciDumpTds (Td);
Status = EFI_DEVICE_ERROR; Status = EFI_DEVICE_ERROR;
} }

View File

@ -23,9 +23,6 @@ Revision History
#include "Uhci.h" #include "Uhci.h"
UINTN mUsbHcDebugLevel = DEBUG_INFO;
/** /**
Allocate a block of memory to be used by the buffer pool Allocate a block of memory to be used by the buffer pool
@ -116,9 +113,6 @@ UsbHcAllocMemBlock (
Block->Buf = (UINT8 *) ((UINTN) MappedAddr); Block->Buf = (UINT8 *) ((UINTN) MappedAddr);
Block->Mapping = Mapping; Block->Mapping = Mapping;
DEBUG ((mUsbHcDebugLevel, "UsbHcAllocMemBlock: block %x created with buffer %x\n",
Block, Block->Buf));
return Block; return Block;
FREE_BUFFER: FREE_BUFFER:
@ -454,7 +448,7 @@ UsbHcAllocateMem (
NewBlock = UsbHcAllocMemBlock (Pool, Pages); NewBlock = UsbHcAllocMemBlock (Pool, Pages);
if (NewBlock == NULL) { if (NewBlock == NULL) {
DEBUG ((mUsbHcDebugLevel, "UsbHcAllocateMem: failed to allocate block\n")); DEBUG ((EFI_D_INFO, "UsbHcAllocateMem: failed to allocate block\n"));
return NULL; return NULL;
} }
@ -538,8 +532,6 @@ UsbHcFreeMem (
// Release the current memory block if it is empty and not the head // Release the current memory block if it is empty and not the head
// //
if ((Block != Head) && UsbHcIsMemBlockEmpty (Block)) { if ((Block != Head) && UsbHcIsMemBlockEmpty (Block)) {
DEBUG ((mUsbHcDebugLevel, "UsbHcFreeMem: block %x is empty, recycle\n", Block));
UsbHcUnlinkMemBlock (Head, Block); UsbHcUnlinkMemBlock (Head, Block);
UsbHcFreeMemBlock (Pool, Block); UsbHcFreeMemBlock (Pool, Block);
} }

View File

@ -62,7 +62,7 @@ enum {
USB_MASS_STORE_RBC = 0x01, // Reduced Block Commands USB_MASS_STORE_RBC = 0x01, // Reduced Block Commands
USB_MASS_STORE_8020I = 0x02, // SFF-8020i, typically a CD/DVD device USB_MASS_STORE_8020I = 0x02, // SFF-8020i, typically a CD/DVD device
USB_MASS_STORE_QIC = 0x03, // Typically a tape device USB_MASS_STORE_QIC = 0x03, // Typically a tape device
USB_MASS_STORE_UFI = 0x04, // Typically a floopy disk driver device USB_MASS_STORE_UFI = 0x04, // Typically a floppy disk driver device
USB_MASS_STORE_8070I = 0x05, // SFF-8070i, typically a floppy disk driver device. USB_MASS_STORE_8070I = 0x05, // SFF-8070i, typically a floppy disk driver device.
USB_MASS_STORE_SCSI = 0x06, // SCSI transparent command set USB_MASS_STORE_SCSI = 0x06, // SCSI transparent command set
@ -138,6 +138,4 @@ UsbClearEndpointStall (
IN UINT8 EndpointAddress IN UINT8 EndpointAddress
); );
extern UINTN mUsbMscInfo;
extern UINTN mUsbMscError;
#endif #endif

View File

@ -167,7 +167,7 @@ UsbBootRequestSense (
&CmdResult &CmdResult
); );
if (EFI_ERROR (Status) || CmdResult != USB_MASS_CMD_SUCCESS) { if (EFI_ERROR (Status) || CmdResult != USB_MASS_CMD_SUCCESS) {
DEBUG ((mUsbMscError, "UsbBootRequestSense: (%r) CmdResult=0x%x\n", Status, CmdResult)); DEBUG ((EFI_D_ERROR, "UsbBootRequestSense: (%r) CmdResult=0x%x\n", Status, CmdResult));
return Status; return Status;
} }
@ -225,7 +225,7 @@ UsbBootRequestSense (
break; break;
} }
DEBUG ((mUsbMscInfo, "UsbBootRequestSense: (%r) with sense key %x/%x/%x\n", DEBUG ((EFI_D_INFO, "UsbBootRequestSense: (%r) with sense key %x/%x/%x\n",
Status, Status,
USB_BOOT_SENSE_KEY (SenseData.SenseKey), USB_BOOT_SENSE_KEY (SenseData.SenseKey),
SenseData.ASC, SenseData.ASC,
@ -291,7 +291,7 @@ UsbBootExecCmd (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
DEBUG ((mUsbMscInfo, "UsbBootExecCmd: Fail to Exec 0x%x Cmd /w %r\n", DEBUG ((EFI_D_INFO, "UsbBootExecCmd: Fail to Exec 0x%x Cmd /w %r\n",
*(UINT8 *)Cmd ,Status)); *(UINT8 *)Cmd ,Status));
return UsbBootRequestSense (UsbMass); return UsbBootRequestSense (UsbMass);
@ -349,7 +349,7 @@ UsbBootExecCmdWithRetry (
DataDir, DataDir,
Data, Data,
DataLen, DataLen,
Timeout * (Index + 1) Timeout
); );
if (Status == EFI_SUCCESS || if (Status == EFI_SUCCESS ||
Status == EFI_MEDIA_CHANGED) { Status == EFI_MEDIA_CHANGED) {
@ -513,7 +513,7 @@ UsbBootReadCapacity (
return EFI_NOT_READY; return EFI_NOT_READY;
} }
DEBUG ((mUsbMscInfo, "UsbBootReadCapacity Success LBA=%ld BlockSize=%d\n", DEBUG ((EFI_D_INFO, "UsbBootReadCapacity Success LBA=%ld BlockSize=%d\n",
Media->LastBlock, Media->BlockSize)); Media->LastBlock, Media->BlockSize));
return EFI_SUCCESS; return EFI_SUCCESS;
@ -603,7 +603,7 @@ UsbBootGetParams (
Status = UsbBootInquiry (UsbMass); Status = UsbBootInquiry (UsbMass);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((mUsbMscError, "UsbBootGetParams: UsbBootInquiry (%r)\n", Status)); DEBUG ((EFI_D_ERROR, "UsbBootGetParams: UsbBootInquiry (%r)\n", Status));
return Status; return Status;
} }
@ -670,7 +670,7 @@ UsbBootDetectMedia (
Status = UsbBootIsUnitReady (UsbMass); Status = UsbBootIsUnitReady (UsbMass);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((mUsbMscError, "UsbBootDetectMedia: UsbBootIsUnitReady (%r)\n", Status)); DEBUG ((EFI_D_ERROR, "UsbBootDetectMedia: UsbBootIsUnitReady (%r)\n", Status));
goto ON_ERROR; goto ON_ERROR;
} }
@ -687,7 +687,7 @@ UsbBootDetectMedia (
Status = UsbBootReadCapacity (UsbMass); Status = UsbBootReadCapacity (UsbMass);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((mUsbMscError, "UsbBootDetectMedia: UsbBootReadCapacity (%r)\n", Status)); DEBUG ((EFI_D_ERROR, "UsbBootDetectMedia: UsbBootReadCapacity (%r)\n", Status));
goto ON_ERROR; goto ON_ERROR;
} }
@ -709,7 +709,7 @@ ON_ERROR:
(Media->LastBlock != OldMedia.LastBlock)) { (Media->LastBlock != OldMedia.LastBlock)) {
OldTpl = UsbGetCurrentTpl (); OldTpl = UsbGetCurrentTpl ();
DEBUG ((mUsbMscError, "UsbBootDetectMedia: TPL before reinstall BlockIoProtocol is %d\n", OldTpl)); DEBUG ((EFI_D_ERROR, "UsbBootDetectMedia: TPL before reinstall BlockIoProtocol is %d\n", OldTpl));
gBS->RestoreTPL (TPL_CALLBACK); gBS->RestoreTPL (TPL_CALLBACK);
@ -720,7 +720,7 @@ ON_ERROR:
&UsbMass->BlockIo &UsbMass->BlockIo
); );
DEBUG ((mUsbMscError, "UsbBootDetectMedia: TPL after reinstall is %d\n", UsbGetCurrentTpl())); DEBUG ((EFI_D_ERROR, "UsbBootDetectMedia: TPL after reinstall is %d\n", UsbGetCurrentTpl()));
ASSERT (UsbGetCurrentTpl () == TPL_CALLBACK); ASSERT (UsbGetCurrentTpl () == TPL_CALLBACK);
gBS->RaiseTPL (OldTpl); gBS->RaiseTPL (OldTpl);

View File

@ -25,9 +25,6 @@ Revision History
#include "UsbMass.h" #include "UsbMass.h"
#include "UsbMassBot.h" #include "UsbMassBot.h"
UINTN mUsbBotInfo = DEBUG_INFO;
UINTN mUsbBotError = DEBUG_ERROR;
STATIC STATIC
EFI_STATUS EFI_STATUS
UsbBotResetDevice ( UsbBotResetDevice (
@ -83,7 +80,7 @@ UsbBotInit (
Status = UsbIo->UsbGetInterfaceDescriptor (UsbIo, &UsbBot->Interface); Status = UsbIo->UsbGetInterfaceDescriptor (UsbIo, &UsbBot->Interface);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((mUsbBotError, "UsbBotInit: Get invalid BOT interface (%r)\n", Status)); DEBUG ((EFI_D_ERROR, "UsbBotInit: Get invalid BOT interface (%r)\n", Status));
goto ON_ERROR; goto ON_ERROR;
} }
@ -120,7 +117,7 @@ UsbBotInit (
} }
if ((UsbBot->BulkInEndpoint == NULL) || (UsbBot->BulkOutEndpoint == NULL)) { if ((UsbBot->BulkInEndpoint == NULL) || (UsbBot->BulkOutEndpoint == NULL)) {
DEBUG ((mUsbBotError, "UsbBotInit: In/Out Endpoint invalid\n")); DEBUG ((EFI_D_ERROR, "UsbBotInit: In/Out Endpoint invalid\n"));
Status = EFI_UNSUPPORTED; Status = EFI_UNSUPPORTED;
goto ON_ERROR; goto ON_ERROR;
} }
@ -277,9 +274,9 @@ UsbBotDataTransfer (
&Result &Result
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((mUsbBotError, "UsbBotDataTransfer: (%r)\n", Status)); DEBUG ((EFI_D_ERROR, "UsbBotDataTransfer: (%r)\n", Status));
if (USB_IS_ERROR (Result, EFI_USB_ERR_STALL)) { if (USB_IS_ERROR (Result, EFI_USB_ERR_STALL)) {
DEBUG ((mUsbBotError, "UsbBotDataTransfer: DataIn Stall\n")); DEBUG ((EFI_D_ERROR, "UsbBotDataTransfer: DataIn Stall\n"));
UsbClearEndpointStall (UsbBot->UsbIo, Endpoint->EndpointAddress); UsbClearEndpointStall (UsbBot->UsbIo, Endpoint->EndpointAddress);
} else if (USB_IS_ERROR (Result, EFI_USB_ERR_NAK)) { } else if (USB_IS_ERROR (Result, EFI_USB_ERR_NAK)) {
Status = EFI_NOT_READY; Status = EFI_NOT_READY;
@ -346,9 +343,9 @@ UsbBotGetStatus (
&Result &Result
); );
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
DEBUG ((mUsbBotError, "UsbBotGetStatus (%r)\n", Status)); DEBUG ((EFI_D_ERROR, "UsbBotGetStatus (%r)\n", Status));
if (USB_IS_ERROR (Result, EFI_USB_ERR_STALL)) { if (USB_IS_ERROR (Result, EFI_USB_ERR_STALL)) {
DEBUG ((mUsbBotError, "UsbBotGetStatus: DataIn Stall\n")); DEBUG ((EFI_D_ERROR, "UsbBotGetStatus: DataIn Stall\n"));
UsbClearEndpointStall (UsbIo, Endpoint); UsbClearEndpointStall (UsbIo, Endpoint);
} }
continue; continue;
@ -358,13 +355,13 @@ UsbBotGetStatus (
// //
// Invalid Csw need perform reset recovery // Invalid Csw need perform reset recovery
// //
DEBUG ((mUsbBotError, "UsbBotGetStatus: Device return a invalid signature\n")); DEBUG ((EFI_D_ERROR, "UsbBotGetStatus: Device return a invalid signature\n"));
Status = UsbBotResetDevice (UsbBot, FALSE); Status = UsbBotResetDevice (UsbBot, FALSE);
} else if (Csw.CmdStatus == USB_BOT_COMMAND_ERROR) { } else if (Csw.CmdStatus == USB_BOT_COMMAND_ERROR) {
// //
// Respond phase error need perform reset recovery // Respond phase error need perform reset recovery
// //
DEBUG ((mUsbBotError, "UsbBotGetStatus: Device return a phase error\n")); DEBUG ((EFI_D_ERROR, "UsbBotGetStatus: Device return a phase error\n"));
Status = UsbBotResetDevice (UsbBot, FALSE); Status = UsbBotResetDevice (UsbBot, FALSE);
} else { } else {
@ -426,7 +423,7 @@ UsbBotExecCommand (
// //
Status = UsbBotSendCommand (UsbBot, Cmd, CmdLen, DataDir, DataLen); Status = UsbBotSendCommand (UsbBot, Cmd, CmdLen, DataDir, DataLen);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((mUsbBotError, "UsbBotExecCommand: UsbBotSendCommand (%r)\n", Status)); DEBUG ((EFI_D_ERROR, "UsbBotExecCommand: UsbBotSendCommand (%r)\n", Status));
return Status; return Status;
} }
@ -443,7 +440,7 @@ UsbBotExecCommand (
// //
Status = UsbBotGetStatus (UsbBot, DataLen, &Result); Status = UsbBotGetStatus (UsbBot, DataLen, &Result);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((mUsbBotError, "UsbBotExecCommand: UsbBotGetStatus (%r)\n", Status)); DEBUG ((EFI_D_ERROR, "UsbBotExecCommand: UsbBotGetStatus (%r)\n", Status));
return Status; return Status;
} }
@ -512,7 +509,7 @@ UsbBotResetDevice (
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((mUsbBotError, "UsbBotResetDevice: (%r)\n", Status)); DEBUG ((EFI_D_ERROR, "UsbBotResetDevice: (%r)\n", Status));
return Status; return Status;
} }

View File

@ -27,9 +27,6 @@ Revision History
#include "UsbMass.h" #include "UsbMass.h"
#include "UsbMassCbi.h" #include "UsbMassCbi.h"
UINTN mUsbCbiInfo = DEBUG_INFO;
UINTN mUsbCbiError = DEBUG_ERROR;
STATIC STATIC
EFI_STATUS EFI_STATUS
UsbCbiResetDevice ( UsbCbiResetDevice (
@ -450,7 +447,7 @@ UsbCbiExecCommand (
// //
Status = UsbCbiSendCommand (UsbCbi, Cmd, CmdLen, Timeout); Status = UsbCbiSendCommand (UsbCbi, Cmd, CmdLen, Timeout);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((mUsbCbiError, "UsbCbiExecCommand: UsbCbiSendCommand (%r)\n",Status)); DEBUG ((EFI_D_ERROR, "UsbCbiExecCommand: UsbCbiSendCommand (%r)\n",Status));
return Status; return Status;
} }
@ -462,7 +459,7 @@ UsbCbiExecCommand (
Status = UsbCbiDataTransfer (UsbCbi, DataDir, Data, &TransLen, Timeout); Status = UsbCbiDataTransfer (UsbCbi, DataDir, Data, &TransLen, Timeout);
if (UsbCbi->InterruptEndpoint == NULL) { if (UsbCbi->InterruptEndpoint == NULL) {
DEBUG ((mUsbCbiError, "UsbCbiExecCommand: UsbCbiDataTransfer (%r)\n",Status)); DEBUG ((EFI_D_ERROR, "UsbCbiExecCommand: UsbCbiDataTransfer (%r)\n",Status));
return Status; return Status;
} }
@ -471,7 +468,7 @@ UsbCbiExecCommand (
// //
Status = UsbCbiGetStatus (UsbCbi, Timeout, &Result); Status = UsbCbiGetStatus (UsbCbi, Timeout, &Result);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((mUsbCbiError, "UsbCbiExecCommand: UsbCbiGetStatus (%r)\n",Status)); DEBUG ((EFI_D_ERROR, "UsbCbiExecCommand: UsbCbiGetStatus (%r)\n",Status));
return EFI_DEVICE_ERROR; return EFI_DEVICE_ERROR;
} }

View File

@ -40,10 +40,6 @@ USB_MASS_TRANSPORT *mUsbMassTransport[] = {
NULL NULL
}; };
UINTN mUsbMscInfo = DEBUG_INFO;
UINTN mUsbMscError = DEBUG_ERROR;
/** /**
Retrieve the media parameters such as disk gemotric for the Retrieve the media parameters such as disk gemotric for the
device's BLOCK IO protocol. device's BLOCK IO protocol.
@ -84,6 +80,7 @@ UsbMassInitMedia (
Media->ReadOnly = FALSE; Media->ReadOnly = FALSE;
Media->WriteCaching = FALSE; Media->WriteCaching = FALSE;
Media->IoAlign = 0; Media->IoAlign = 0;
Media->MediaId = 1;
// //
// Some device may spend several seconds before it is ready. // Some device may spend several seconds before it is ready.
@ -122,6 +119,7 @@ UsbMassInitMedia (
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI
UsbMassReset ( UsbMassReset (
IN EFI_BLOCK_IO_PROTOCOL *This, IN EFI_BLOCK_IO_PROTOCOL *This,
IN BOOLEAN ExtendedVerification IN BOOLEAN ExtendedVerification
@ -162,6 +160,7 @@ UsbMassReset (
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI
UsbMassReadBlocks ( UsbMassReadBlocks (
IN EFI_BLOCK_IO_PROTOCOL *This, IN EFI_BLOCK_IO_PROTOCOL *This,
IN UINT32 MediaId, IN UINT32 MediaId,
@ -197,7 +196,7 @@ UsbMassReadBlocks (
if (Media->RemovableMedia == TRUE) { if (Media->RemovableMedia == TRUE) {
Status = UsbBootDetectMedia (UsbMass); Status = UsbBootDetectMedia (UsbMass);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((mUsbMscError, "UsbMassReadBlocks: UsbBootDetectMedia (%r)\n", Status)); DEBUG ((EFI_D_ERROR, "UsbMassReadBlocks: UsbBootDetectMedia (%r)\n", Status));
goto ON_EXIT; goto ON_EXIT;
} }
} }
@ -213,13 +212,23 @@ UsbMassReadBlocks (
TotalBlock = BufferSize / Media->BlockSize; TotalBlock = BufferSize / Media->BlockSize;
if (Lba + TotalBlock - 1 > Media->LastBlock) { if (Lba + TotalBlock - 1 > Media->LastBlock) {
Status = EFI_BAD_BUFFER_SIZE; Status = EFI_INVALID_PARAMETER;
goto ON_EXIT;
}
if (!(Media->MediaPresent)) {
Status = EFI_NO_MEDIA;
goto ON_EXIT;
}
if (MediaId != Media->MediaId) {
Status = EFI_MEDIA_CHANGED;
goto ON_EXIT; goto ON_EXIT;
} }
Status = UsbBootReadBlocks (UsbMass, (UINT32) Lba, TotalBlock, Buffer); Status = UsbBootReadBlocks (UsbMass, (UINT32) Lba, TotalBlock, Buffer);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((mUsbMscError, "UsbMassReadBlocks: UsbBootReadBlocks (%r) -> Reset\n", Status)); DEBUG ((EFI_D_ERROR, "UsbMassReadBlocks: UsbBootReadBlocks (%r) -> Reset\n", Status));
UsbMassReset (This, TRUE); UsbMassReset (This, TRUE);
} }
@ -249,6 +258,7 @@ ON_EXIT:
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI
UsbMassWriteBlocks ( UsbMassWriteBlocks (
IN EFI_BLOCK_IO_PROTOCOL *This, IN EFI_BLOCK_IO_PROTOCOL *This,
IN UINT32 MediaId, IN UINT32 MediaId,
@ -284,7 +294,7 @@ UsbMassWriteBlocks (
if (Media->RemovableMedia == TRUE) { if (Media->RemovableMedia == TRUE) {
Status = UsbBootDetectMedia (UsbMass); Status = UsbBootDetectMedia (UsbMass);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((mUsbMscError, "UsbMassWriteBlocks: UsbBootDetectMedia (%r)\n", Status)); DEBUG ((EFI_D_ERROR, "UsbMassWriteBlocks: UsbBootDetectMedia (%r)\n", Status));
goto ON_EXIT; goto ON_EXIT;
} }
} }
@ -300,7 +310,17 @@ UsbMassWriteBlocks (
TotalBlock = BufferSize / Media->BlockSize; TotalBlock = BufferSize / Media->BlockSize;
if (Lba + TotalBlock - 1 > Media->LastBlock) { if (Lba + TotalBlock - 1 > Media->LastBlock) {
Status = EFI_BAD_BUFFER_SIZE; Status = EFI_INVALID_PARAMETER;
goto ON_EXIT;
}
if (!(Media->MediaPresent)) {
Status = EFI_NO_MEDIA;
goto ON_EXIT;
}
if (MediaId != Media->MediaId) {
Status = EFI_MEDIA_CHANGED;
goto ON_EXIT; goto ON_EXIT;
} }
@ -310,7 +330,7 @@ UsbMassWriteBlocks (
// //
Status = UsbBootWriteBlocks (UsbMass, (UINT32) Lba, TotalBlock, Buffer); Status = UsbBootWriteBlocks (UsbMass, (UINT32) Lba, TotalBlock, Buffer);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((mUsbMscError, "UsbMassWriteBlocks: UsbBootWriteBlocks (%r) -> Reset\n", Status)); DEBUG ((EFI_D_ERROR, "UsbMassWriteBlocks: UsbBootWriteBlocks (%r) -> Reset\n", Status));
UsbMassReset (This, TRUE); UsbMassReset (This, TRUE);
} }
@ -330,6 +350,7 @@ ON_EXIT:
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI
UsbMassFlushBlocks ( UsbMassFlushBlocks (
IN EFI_BLOCK_IO_PROTOCOL *This IN EFI_BLOCK_IO_PROTOCOL *This
) )
@ -402,7 +423,7 @@ USBMassDriverBindingSupported (
} }
} }
DEBUG ((mUsbMscInfo, "Found a USB mass store device %r\n", Status)); DEBUG ((EFI_D_INFO, "Found a USB mass store device %r\n", Status));
ON_EXIT: ON_EXIT:
gBS->CloseProtocol ( gBS->CloseProtocol (
@ -467,7 +488,7 @@ USBMassDriverBindingStart (
// //
Status = UsbIo->UsbGetInterfaceDescriptor (UsbIo, &Interface); Status = UsbIo->UsbGetInterfaceDescriptor (UsbIo, &Interface);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((mUsbMscError, "USBMassDriverBindingStart: UsbIo->UsbGetInterfaceDescriptor (%r)\n", Status)); DEBUG ((EFI_D_ERROR, "USBMassDriverBindingStart: UsbIo->UsbGetInterfaceDescriptor (%r)\n", Status));
goto ON_ERROR; goto ON_ERROR;
} }
@ -484,7 +505,7 @@ USBMassDriverBindingStart (
} }
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((mUsbMscError, "USBMassDriverBindingStart: Transport->Init (%r)\n", Status)); DEBUG ((EFI_D_ERROR, "USBMassDriverBindingStart: Transport->Init (%r)\n", Status));
goto ON_ERROR; goto ON_ERROR;
} }
@ -508,11 +529,11 @@ USBMassDriverBindingStart (
(UsbMass->Pdt != USB_PDT_CDROM) && (UsbMass->Pdt != USB_PDT_CDROM) &&
(UsbMass->Pdt != USB_PDT_OPTICAL) && (UsbMass->Pdt != USB_PDT_OPTICAL) &&
(UsbMass->Pdt != USB_PDT_SIMPLE_DIRECT)) { (UsbMass->Pdt != USB_PDT_SIMPLE_DIRECT)) {
DEBUG ((mUsbMscError, "USBMassDriverBindingStart: Found an unsupported peripheral type[%d]\n", UsbMass->Pdt)); DEBUG ((EFI_D_ERROR, "USBMassDriverBindingStart: Found an unsupported peripheral type[%d]\n", UsbMass->Pdt));
goto ON_ERROR; goto ON_ERROR;
} }
} else if (Status != EFI_NO_MEDIA){ } else if (Status != EFI_NO_MEDIA){
DEBUG ((mUsbMscError, "USBMassDriverBindingStart: UsbMassInitMedia (%r)\n", Status)); DEBUG ((EFI_D_ERROR, "USBMassDriverBindingStart: UsbMassInitMedia (%r)\n", Status));
goto ON_ERROR; goto ON_ERROR;
} }