MdeModulePkg/EhciDxe: factor out EhcIsDebugPortInUse()
The EhcReset(), EhcGetRootHubPortStatus() and EhcDriverBindingStart() functions need to see whether the host controller (or a specific port on the host controller) can be accessed, dependent on the controller having (or the specific port being) an in-use debug port. Because the condition isn't simple, extract it to a separate function. Cc: Ruiyu Ni <ruiyu.ni@intel.com> Cc: Star Zeng <star.zeng@intel.com> Suggested-by: Star Zeng <star.zeng@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Star Zeng <star.zeng@intel.com>
This commit is contained in:
@@ -65,7 +65,7 @@ EhcReadCapRegister (
|
||||
**/
|
||||
UINT32
|
||||
EhcReadDbgRegister (
|
||||
IN USB2_HC_DEV *Ehc,
|
||||
IN CONST USB2_HC_DEV *Ehc,
|
||||
IN UINT32 Offset
|
||||
)
|
||||
{
|
||||
@@ -90,6 +90,59 @@ EhcReadDbgRegister (
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Check whether the host controller has an in-use debug port.
|
||||
|
||||
@param[in] Ehc The Enhanced Host Controller to query.
|
||||
|
||||
@param[in] PortNumber If PortNumber is not NULL, then query whether
|
||||
PortNumber is an in-use debug port on Ehc. (PortNumber
|
||||
is taken in UEFI notation, i.e., zero-based.)
|
||||
Otherwise, query whether Ehc has any in-use debug
|
||||
port.
|
||||
|
||||
@retval TRUE PortNumber is an in-use debug port on Ehc (if PortNumber is
|
||||
not NULL), or some port on Ehc is an in-use debug port
|
||||
(otherwise).
|
||||
|
||||
@retval FALSE PortNumber is not an in-use debug port on Ehc (if PortNumber
|
||||
is not NULL), or no port on Ehc is an in-use debug port
|
||||
(otherwise).
|
||||
**/
|
||||
BOOLEAN
|
||||
EhcIsDebugPortInUse (
|
||||
IN CONST USB2_HC_DEV *Ehc,
|
||||
IN CONST UINT8 *PortNumber OPTIONAL
|
||||
)
|
||||
{
|
||||
UINT32 State;
|
||||
|
||||
if (Ehc->DebugPortNum == 0) {
|
||||
//
|
||||
// The host controller has no debug port.
|
||||
//
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//
|
||||
// The Debug Port Number field in HCSPARAMS is one-based.
|
||||
//
|
||||
if (PortNumber != NULL && *PortNumber != Ehc->DebugPortNum - 1) {
|
||||
//
|
||||
// The caller specified a port, but it's not the debug port of the host
|
||||
// controller.
|
||||
//
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//
|
||||
// Deduce usage from the Control Register.
|
||||
//
|
||||
State = EhcReadDbgRegister(Ehc, 0);
|
||||
return (State & USB_DEBUG_PORT_IN_USE_MASK) == USB_DEBUG_PORT_IN_USE_MASK;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Read EHCI Operation register.
|
||||
|
||||
|
Reference in New Issue
Block a user