summaryrefslogtreecommitdiffstats
path: root/MdeModulePkg/Bus/Pci/EhciDxe/EhciReg.c
diff options
context:
space:
mode:
authorLaszlo Ersek <lersek@redhat.com>2018-09-05 19:06:19 +0200
committerLaszlo Ersek <lersek@redhat.com>2018-09-06 14:07:50 +0200
commitb48ec0e8ab1c881ea584ed76d2da0bac09db38ef (patch)
treeb4093023fd9d7ebf8e74ac290a0f18da676b6a01 /MdeModulePkg/Bus/Pci/EhciDxe/EhciReg.c
parent22cf747fcf75dbfe51e5524ce1f9cf17b19914cd (diff)
downloadedk2-b48ec0e8ab1c881ea584ed76d2da0bac09db38ef.tar.gz
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>
Diffstat (limited to 'MdeModulePkg/Bus/Pci/EhciDxe/EhciReg.c')
-rw-r--r--MdeModulePkg/Bus/Pci/EhciDxe/EhciReg.c55
1 files changed, 54 insertions, 1 deletions
diff --git a/MdeModulePkg/Bus/Pci/EhciDxe/EhciReg.c b/MdeModulePkg/Bus/Pci/EhciDxe/EhciReg.c
index 59752d1bdc..11c36132fd 100644
--- a/MdeModulePkg/Bus/Pci/EhciDxe/EhciReg.c
+++ b/MdeModulePkg/Bus/Pci/EhciDxe/EhciReg.c
@@ -65,7 +65,7 @@ EhcReadCapRegister (
**/
UINT32
EhcReadDbgRegister (
- IN USB2_HC_DEV *Ehc,
+ IN CONST USB2_HC_DEV *Ehc,
IN UINT32 Offset
)
{
@@ -91,6 +91,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.
@param Ehc The EHCI device.