public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] MdeModulePkg: Remove dead code in .c and .h files
@ 2018-08-06  7:49 shenglei
  2018-08-06 13:11 ` Laszlo Ersek
  0 siblings, 1 reply; 6+ messages in thread
From: shenglei @ 2018-08-06  7:49 UTC (permalink / raw)
  To: edk2-devel; +Cc: Star Zeng, Eric Dong

Some dead code has been removed in .c and .h files.
https://bugzilla.tianocore.org/show_bug.cgi?id=1062

Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: shenglei <shenglei.zhang@intel.com>
---
 .../Application/CapsuleApp/CapsuleDump.c      |  31 ---
 MdeModulePkg/Application/UiApp/FrontPage.c    |  40 ---
 MdeModulePkg/Application/UiApp/Ui.h           |  30 --
 .../Bus/Ata/AtaAtapiPassThru/AhciMode.c       | 104 -------
 .../Bus/Ata/AtaAtapiPassThru/IdeMode.c        | 257 ------------------
 .../Bus/Isa/Ps2KeyboardDxe/Ps2KbdCtrller.c    |  26 --
 .../Bus/Isa/Ps2KeyboardDxe/Ps2Keyboard.h      |  12 -
 MdeModulePkg/Bus/Pci/EhciDxe/EhciDebug.c      |  27 --
 MdeModulePkg/Bus/Pci/EhciDxe/EhciDebug.h      |  11 -
 MdeModulePkg/Bus/Pci/EhciDxe/EhciReg.c        |  44 ---
 .../Bus/Pci/NvmExpressDxe/NvmExpressHci.c     | 110 --------
 .../Bus/Pci/PciBusDxe/PciDeviceSupport.c      |  80 ------
 .../Bus/Pci/PciBusDxe/PciDeviceSupport.h      |  17 --
 MdeModulePkg/Bus/Pci/PciBusDxe/PciIo.c        |  41 ---
 MdeModulePkg/Bus/Pci/PciBusDxe/PciIo.h        |  21 --
 MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdDevice.c |  94 -------
 MdeModulePkg/Bus/Pci/UhciPei/DmaMem.c         |  22 --
 MdeModulePkg/Bus/Pci/UhciPei/UhcPeim.c        | 125 ---------
 MdeModulePkg/Bus/Pci/UhciPei/UhcPeim.h        |  78 ------
 MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.c        |  66 -----
 MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.h        |  28 --
 MdeModulePkg/Bus/Pci/XhciPei/UsbHcMem.c       |  24 --
 MdeModulePkg/Bus/Pci/XhciPei/XhcPeim.c        |  22 --
 MdeModulePkg/Bus/Pci/XhciPei/XhciReg.h        |  14 -
 .../Bus/Sd/EmmcBlockIoPei/EmmcHcMem.c         |  24 --
 MdeModulePkg/Bus/Sd/SdBlockIoPei/SdHcMem.c    |  24 --
 .../Bus/Ufs/UfsBlockIoPei/UfsBlockIoPei.c     | 101 -------
 MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsHcMem.c |  24 --
 MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsHci.c   | 180 ------------
 .../Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c   |  49 ----
 MdeModulePkg/Bus/Usb/UsbBotPei/PeiUsbLib.c    | 190 -------------
 MdeModulePkg/Bus/Usb/UsbBotPei/PeiUsbLib.h    |  98 -------
 MdeModulePkg/Bus/Usb/UsbBusDxe/UsbHub.c       |  68 -----
 MdeModulePkg/Bus/Usb/UsbBusDxe/UsbUtility.c   | 146 ----------
 MdeModulePkg/Bus/Usb/UsbBusDxe/UsbUtility.h   | 114 --------
 MdeModulePkg/Bus/Usb/UsbBusPei/HubPeim.c      |  39 ---
 MdeModulePkg/Bus/Usb/UsbBusPei/HubPeim.h      |  18 --
 MdeModulePkg/Bus/Usb/UsbBusPei/PeiUsbLib.c    |  77 ------
 MdeModulePkg/Bus/Usb/UsbBusPei/PeiUsbLib.h    |  35 ---
 MdeModulePkg/Core/Dxe/DxeMain.h               |  13 -
 MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c       |  23 --
 MdeModulePkg/Core/Dxe/Mem/HeapGuard.c         |  78 ------
 MdeModulePkg/Core/PiSmmCore/HeapGuard.c       | 166 -----------
 .../Core/PiSmmCore/MemoryAttributesTable.c    | 131 ---------
 MdeModulePkg/Core/PiSmmCore/Page.c            | 121 ---------
 .../Universal/Console/TerminalDxe/Terminal.h  |  12 -
 .../Console/TerminalDxe/TerminalConIn.c       |  25 --
 .../Universal/HiiDatabaseDxe/ConfigRouting.c  |  47 ----
 .../Universal/Network/IScsiDxe/IScsiProto.c   |  31 ---
 .../Universal/Network/Ip4Dxe/Ip4Config2Impl.c |  16 --
 .../Universal/Network/Tcp4Dxe/SockImpl.c      |  35 ---
 .../Universal/Network/Tcp4Dxe/SockInterface.c |  41 ---
 .../Universal/Network/Tcp4Dxe/Socket.h        |  32 ---
 .../Universal/Network/Tcp4Dxe/Tcp4Option.c    |  28 --
 .../Universal/Network/Tcp4Dxe/Tcp4Option.h    |  15 -
 .../Universal/SetupBrowserDxe/IfrParse.c      |  33 ---
 56 files changed, 3358 deletions(-)

diff --git a/MdeModulePkg/Application/CapsuleApp/CapsuleDump.c b/MdeModulePkg/Application/CapsuleApp/CapsuleDump.c
index 45c3ecd050..7a3eb94362 100644
--- a/MdeModulePkg/Application/CapsuleApp/CapsuleDump.c
+++ b/MdeModulePkg/Application/CapsuleApp/CapsuleDump.c
@@ -106,37 +106,6 @@ DumpUxCapsule (
   Print(L"  OffsetY          - 0x%x\n", DisplayCapsule->ImagePayload.OffsetY);
 }
 
-/**
-  Dump FMP image authentication information.
-
-  @param[in] Image      The FMP capsule image
-  @param[in] ImageSize  The size of the FMP capsule image in bytes.
-
-  @return the size of FMP authentication.
-**/
-UINTN
-DumpImageAuthentication (
-  IN VOID   *Image,
-  IN UINTN  ImageSize
-  )
-{
-  EFI_FIRMWARE_IMAGE_AUTHENTICATION             *ImageAuthentication;
-
-  ImageAuthentication = Image;
-  if (CompareGuid(&ImageAuthentication->AuthInfo.CertType, &gEfiCertPkcs7Guid) ||
-      CompareGuid(&ImageAuthentication->AuthInfo.CertType, &gEfiCertTypeRsa2048Sha256Guid)) {
-    Print(L"[ImageAuthentication]\n");
-    Print(L"  MonotonicCount   - 0x%lx\n", ImageAuthentication->MonotonicCount);
-    Print(L"WIN_CERTIFICATE:\n");
-    Print(L"  dwLength         - 0x%x\n", ImageAuthentication->AuthInfo.Hdr.dwLength);
-    Print(L"  wRevision        - 0x%x\n", ImageAuthentication->AuthInfo.Hdr.wRevision);
-    Print(L"  wCertificateType - 0x%x\n", ImageAuthentication->AuthInfo.Hdr.wCertificateType);
-    Print(L"  CertType         - %g\n", &ImageAuthentication->AuthInfo.CertType);
-    return sizeof(ImageAuthentication->MonotonicCount) + ImageAuthentication->AuthInfo.Hdr.dwLength;
-  } else {
-    return 0;
-  }
-}
 
 /**
   Dump a non-nested FMP capsule.
diff --git a/MdeModulePkg/Application/UiApp/FrontPage.c b/MdeModulePkg/Application/UiApp/FrontPage.c
index 2403aad9d9..f0513deb51 100644
--- a/MdeModulePkg/Application/UiApp/FrontPage.c
+++ b/MdeModulePkg/Application/UiApp/FrontPage.c
@@ -1042,34 +1042,7 @@ UiEntry (
 //
 
 
-/**
-  Enable the setup browser reset reminder feature.
-  This routine is used in platform tip. If the platform policy need the feature, use the routine to enable it.
 
-**/
-VOID
-EFIAPI
-EnableResetReminderFeature (
-  VOID
-  )
-{
-  mFeaturerSwitch = TRUE;
-}
-
-
-/**
-  Disable the setup browser reset reminder feature.
-  This routine is used in platform tip. If the platform policy do not want the feature, use the routine to disable it.
-
-**/
-VOID
-EFIAPI
-DisableResetReminderFeature (
-  VOID
-  )
-{
-  mFeaturerSwitch = FALSE;
-}
 
 
 /**
@@ -1087,19 +1060,6 @@ EnableResetRequired (
 }
 
 
-/**
-  Record the info that  no reset is required.
-  A  module boolean variable is used to record whether a reset is required.
-
-**/
-VOID
-EFIAPI
-DisableResetRequired (
-  VOID
-  )
-{
-  mResetRequired = FALSE;
-}
 
 
 /**
diff --git a/MdeModulePkg/Application/UiApp/Ui.h b/MdeModulePkg/Application/UiApp/Ui.h
index a9c30b0c56..7be164570c 100644
--- a/MdeModulePkg/Application/UiApp/Ui.h
+++ b/MdeModulePkg/Application/UiApp/Ui.h
@@ -53,27 +53,7 @@ typedef struct {
 //
 //The interface functions related to the Setup Browser Reset Reminder feature
 //
-/**
-  Enable the setup browser reset reminder feature.
-  This routine is used in a platform tip. If the platform policy needs the feature, use the routine to enable it.
 
-**/
-VOID
-EFIAPI
-EnableResetReminderFeature (
-  VOID
-  );
-
-/**
-  Disable the setup browser reset reminder feature.
-  This routine is used in a platform tip. If the platform policy does not want the feature, use the routine to disable it.
-
-**/
-VOID
-EFIAPI
-DisableResetReminderFeature (
-  VOID
-  );
 
 /**
   Record the info that a reset is required.
@@ -87,16 +67,6 @@ EnableResetRequired (
   );
 
 
-/**
-  Record the info that no reset is required.
-  A module boolean variable is used to record whether a reset is required.
-
-**/
-VOID
-EFIAPI
-DisableResetRequired (
-  VOID
-  );
 
 /**
   Check whether platform policy enables the reset reminder feature. The default is enabled.
diff --git a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
index 79ae11bd20..d7a8b29666 100644
--- a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
+++ b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AhciMode.c
@@ -294,41 +294,6 @@ AhciCheckMemSet (
   }
 }
 
-/**
-  Check if the device is still on port. It also checks if the AHCI controller
-  supports the address and data count will be transferred.
-
-  @param  PciIo            The PCI IO protocol instance.
-  @param  Port             The number of port.
-
-  @retval EFI_SUCCESS      The device is attached to port and the transfer data is
-                           supported by AHCI controller.
-  @retval EFI_UNSUPPORTED  The transfer address and count is not supported by AHCI
-                           controller.
-  @retval EFI_NOT_READY    The physical communication between AHCI controller and device
-                           is not ready.
-
-**/
-EFI_STATUS
-EFIAPI
-AhciCheckDeviceStatus (
-  IN  EFI_PCI_IO_PROTOCOL    *PciIo,
-  IN  UINT8                  Port
-  )
-{
-  UINT32      Data;
-  UINT32      Offset;
-
-  Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_SSTS;
-
-  Data   = AhciReadReg (PciIo, Offset) & EFI_AHCI_PORT_SSTS_DET_MASK;
-
-  if (Data == EFI_AHCI_PORT_SSTS_DET_PCE) {
-    return EFI_SUCCESS;
-  }
-
-  return EFI_NOT_READY;
-}
 
 /**
 
@@ -1361,75 +1326,6 @@ AhciStartCommand (
   return EFI_SUCCESS;
 }
 
-/**
-  Do AHCI port reset.
-
-  @param  PciIo              The PCI IO protocol instance.
-  @param  Port               The number of port.
-  @param  Timeout            The timeout value of reset, uses 100ns as a unit.
-
-  @retval EFI_DEVICE_ERROR   The port reset unsuccessfully
-  @retval EFI_TIMEOUT        The reset operation is time out.
-  @retval EFI_SUCCESS        The port reset successfully.
-
-**/
-EFI_STATUS
-EFIAPI
-AhciPortReset (
-  IN  EFI_PCI_IO_PROTOCOL       *PciIo,
-  IN  UINT8                     Port,
-  IN  UINT64                    Timeout
-  )
-{
-  EFI_STATUS      Status;
-  UINT32          Offset;
-
-  AhciClearPortStatus (PciIo, Port);
-
-  AhciStopCommand (PciIo, Port, Timeout);
-
-  AhciDisableFisReceive (PciIo, Port, Timeout);
-
-  AhciEnableFisReceive (PciIo, Port, Timeout);
-
-  Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_SCTL;
-
-  AhciOrReg (PciIo, Offset, EFI_AHCI_PORT_SCTL_DET_INIT);
-
-  //
-  // wait 5 millisecond before de-assert DET
-  //
-  MicroSecondDelay (5000);
-
-  AhciAndReg (PciIo, Offset, (UINT32)EFI_AHCI_PORT_SCTL_MASK);
-
-  //
-  // wait 5 millisecond before de-assert DET
-  //
-  MicroSecondDelay (5000);
-
-  //
-  // Wait for communication to be re-established
-  //
-  Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_SSTS;
-  Status = AhciWaitMmioSet (
-             PciIo,
-             Offset,
-             EFI_AHCI_PORT_SSTS_DET_MASK,
-             EFI_AHCI_PORT_SSTS_DET_PCE,
-             Timeout
-             );
-
-  if (EFI_ERROR (Status)) {
-    DEBUG ((EFI_D_ERROR, "Port %d COMRESET failed: %r\n", Port, Status));
-    return Status;
-  }
-
-  Offset = EFI_AHCI_PORT_START + Port * EFI_AHCI_PORT_REG_WIDTH + EFI_AHCI_PORT_SERR;
-  AhciOrReg (PciIo, Offset, EFI_AHCI_PORT_ERR_CLEAR);
-
-  return EFI_SUCCESS;
-}
 
 /**
   Do AHCI HBA reset.
diff --git a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/IdeMode.c b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/IdeMode.c
index 6478f7be07..79142c330d 100644
--- a/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/IdeMode.c
+++ b/MdeModulePkg/Bus/Ata/AtaAtapiPassThru/IdeMode.c
@@ -627,146 +627,8 @@ DRQReady2 (
   return EFI_TIMEOUT;
 }
 
-/**
-  This function is used to poll for the DRDY bit set in the Status Register. DRDY
-  bit is set when the device is ready to accept command. Most ATA commands must be
-  sent after DRDY set except the ATAPI Packet Command.
-
-  @param PciIo            A pointer to EFI_PCI_IO_PROTOCOL data structure.
-  @param IdeRegisters     A pointer to EFI_IDE_REGISTERS data structure.
-  @param Timeout          The time to complete the command, uses 100ns as a unit.
-
-  @retval EFI_SUCCESS         DRDY bit set within the time out.
-  @retval EFI_TIMEOUT         DRDY bit not set within the time out.
-
-  @note  Read Status Register will clear interrupt status.
-**/
-EFI_STATUS
-EFIAPI
-DRDYReady (
-  IN  EFI_PCI_IO_PROTOCOL  *PciIo,
-  IN  EFI_IDE_REGISTERS    *IdeRegisters,
-  IN  UINT64               Timeout
-  )
-{
-  UINT64  Delay;
-  UINT8   StatusRegister;
-  UINT8   ErrorRegister;
-  BOOLEAN InfiniteWait;
-
-  ASSERT (PciIo != NULL);
-  ASSERT (IdeRegisters != NULL);
-
-  if (Timeout == 0) {
-    InfiniteWait = TRUE;
-  } else {
-    InfiniteWait = FALSE;
-  }
-
-  Delay = DivU64x32(Timeout, 1000) + 1;
-  do {
-    StatusRegister = IdeReadPortB (PciIo, IdeRegisters->CmdOrStatus);
-    //
-    // Wait for BSY == 0, then judge if DRDY is set or ERR is set
-    //
-    if ((StatusRegister & ATA_STSREG_BSY) == 0) {
-      if ((StatusRegister & ATA_STSREG_ERR) == ATA_STSREG_ERR) {
-        ErrorRegister = IdeReadPortB (PciIo, IdeRegisters->ErrOrFeature);
-
-        if ((ErrorRegister & ATA_ERRREG_ABRT) == ATA_ERRREG_ABRT) {
-          return EFI_ABORTED;
-        }
-        return EFI_DEVICE_ERROR;
-      }
-
-      if ((StatusRegister & ATA_STSREG_DRDY) == ATA_STSREG_DRDY) {
-        return EFI_SUCCESS;
-      } else {
-        return EFI_DEVICE_ERROR;
-      }
-    }
-
-    //
-    // Stall for 100 microseconds.
-    //
-    MicroSecondDelay (100);
-
-    Delay--;
-  } while (InfiniteWait || (Delay > 0));
-
-  return EFI_TIMEOUT;
-}
-
-/**
-  This function is used to poll for the DRDY bit set in the Alternate Status Register.
-  DRDY bit is set when the device is ready to accept command. Most ATA commands must
-  be sent after DRDY set except the ATAPI Packet Command.
-
-  @param PciIo            A pointer to EFI_PCI_IO_PROTOCOL data structure.
-  @param IdeRegisters     A pointer to EFI_IDE_REGISTERS data structure.
-  @param Timeout          The time to complete the command, uses 100ns as a unit.
-
-  @retval EFI_SUCCESS      DRDY bit set within the time out.
-  @retval EFI_TIMEOUT      DRDY bit not set within the time out.
-
-  @note  Read Alternate Status Register will clear interrupt status.
-
-**/
-EFI_STATUS
-EFIAPI
-DRDYReady2 (
-  IN  EFI_PCI_IO_PROTOCOL  *PciIo,
-  IN  EFI_IDE_REGISTERS    *IdeRegisters,
-  IN  UINT64               Timeout
-  )
-{
-  UINT64  Delay;
-  UINT8   AltRegister;
-  UINT8   ErrorRegister;
-  BOOLEAN InfiniteWait;
-
-  ASSERT (PciIo != NULL);
-  ASSERT (IdeRegisters != NULL);
-
-  if (Timeout == 0) {
-    InfiniteWait = TRUE;
-  } else {
-    InfiniteWait = FALSE;
-  }
-
-  Delay = DivU64x32(Timeout, 1000) + 1;
-  do {
-    AltRegister = IdeReadPortB (PciIo, IdeRegisters->AltOrDev);
-    //
-    // Wait for BSY == 0, then judge if DRDY is set or ERR is set
-    //
-    if ((AltRegister & ATA_STSREG_BSY) == 0) {
-      if ((AltRegister & ATA_STSREG_ERR) == ATA_STSREG_ERR) {
-        ErrorRegister = IdeReadPortB (PciIo, IdeRegisters->ErrOrFeature);
-
-        if ((ErrorRegister & ATA_ERRREG_ABRT) == ATA_ERRREG_ABRT) {
-          return EFI_ABORTED;
-        }
-        return EFI_DEVICE_ERROR;
-      }
-
-      if ((AltRegister & ATA_STSREG_DRDY) == ATA_STSREG_DRDY) {
-        return EFI_SUCCESS;
-      } else {
-        return EFI_DEVICE_ERROR;
-      }
-    }
-
-    //
-    // Stall for 100 microseconds.
-    //
-    MicroSecondDelay (100);
 
-    Delay--;
-  } while (InfiniteWait || (Delay > 0));
 
-  return EFI_TIMEOUT;
-}
 
 /**
   This function is used to poll for the BSY bit clear in the Status Register. BSY
@@ -822,59 +684,6 @@ WaitForBSYClear (
   return EFI_TIMEOUT;
 }
 
-/**
-  This function is used to poll for the BSY bit clear in the Status Register. BSY
-  is clear when the device is not busy. Every command must be sent after device is not busy.
-
-  @param PciIo            A pointer to ATA_ATAPI_PASS_THRU_INSTANCE data structure.
-  @param IdeRegisters     A pointer to EFI_IDE_REGISTERS data structure.
-  @param Timeout          The time to complete the command, uses 100ns as a unit.
-
-  @retval EFI_SUCCESS          BSY bit clear within the time out.
-  @retval EFI_TIMEOUT          BSY bit not clear within the time out.
-
-  @note Read Status Register will clear interrupt status.
-**/
-EFI_STATUS
-EFIAPI
-WaitForBSYClear2 (
-  IN  EFI_PCI_IO_PROTOCOL  *PciIo,
-  IN  EFI_IDE_REGISTERS    *IdeRegisters,
-  IN  UINT64               Timeout
-  )
-{
-  UINT64  Delay;
-  UINT8   AltStatusRegister;
-  BOOLEAN InfiniteWait;
-
-  ASSERT (PciIo != NULL);
-  ASSERT (IdeRegisters != NULL);
-
-  if (Timeout == 0) {
-    InfiniteWait = TRUE;
-  } else {
-    InfiniteWait = FALSE;
-  }
-
-  Delay = DivU64x32(Timeout, 1000) + 1;
-  do {
-    AltStatusRegister = IdeReadPortB (PciIo, IdeRegisters->AltOrDev);
-
-    if ((AltStatusRegister & ATA_STSREG_BSY) == 0x00) {
-      return EFI_SUCCESS;
-    }
-
-    //
-    // Stall for 100 microseconds.
-    //
-    MicroSecondDelay (100);
-
-    Delay--;
-
-  } while (InfiniteWait || (Delay > 0));
-
-  return EFI_TIMEOUT;
-}
 
 /**
   Get IDE i/o port registers' base addresses by mode.
@@ -1017,72 +826,6 @@ GetIdeRegisterIoAddr (
   return EFI_SUCCESS;
 }
 
-/**
-  This function is used to implement the Soft Reset on the specified device. But,
-  the ATA Soft Reset mechanism is so strong a reset method that it will force
-  resetting on both devices connected to the same cable.
-
-  It is called by IdeBlkIoReset(), a interface function of Block
-  I/O protocol.
-
-  This function can also be used by the ATAPI device to perform reset when
-  ATAPI Reset command is failed.
-
-  @param PciIo            A pointer to ATA_ATAPI_PASS_THRU_INSTANCE data structure.
-  @param IdeRegisters     A pointer to EFI_IDE_REGISTERS data structure.
-  @param Timeout          The time to complete the command, uses 100ns as a unit.
-
-  @retval EFI_SUCCESS       Soft reset completes successfully.
-  @retval EFI_DEVICE_ERROR  Any step during the reset process is failed.
-
-  @note  The registers initial values after ATA soft reset are different
-         to the ATA device and ATAPI device.
-**/
-EFI_STATUS
-EFIAPI
-AtaSoftReset (
-  IN  EFI_PCI_IO_PROTOCOL  *PciIo,
-  IN  EFI_IDE_REGISTERS    *IdeRegisters,
-  IN  UINT64               Timeout
-  )
-{
-  UINT8 DeviceControl;
-
-  DeviceControl = 0;
-  //
-  // disable Interrupt and set SRST bit to initiate soft reset
-  //
-  DeviceControl = ATA_CTLREG_SRST | ATA_CTLREG_IEN_L;
-
-  IdeWritePortB (PciIo, IdeRegisters->AltOrDev, DeviceControl);
-
-  //
-  // SRST should assert for at least 5 us, we use 10 us for
-  // better compatibility
-  //
-  MicroSecondDelay (10);
-
-  //
-  // Enable interrupt to support UDMA, and clear SRST bit
-  //
-  DeviceControl = 0;
-  IdeWritePortB (PciIo, IdeRegisters->AltOrDev, DeviceControl);
-
-  //
-  // Wait for at least 10 ms to check BSY status, we use 10 ms
-  // for better compatibility
-  //
-  MicroSecondDelay (10000);
-
-  //
-  // slave device needs at most 31ms to clear BSY
-  //
-  if (WaitForBSYClear (PciIo, IdeRegisters, Timeout) == EFI_TIMEOUT) {
-    return EFI_DEVICE_ERROR;
-  }
-
-  return EFI_SUCCESS;
-}
 
 /**
   Send ATA Ext command into device with NON_DATA protocol.
diff --git a/MdeModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdCtrller.c b/MdeModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdCtrller.c
index 4def6d9271..2ee293d64d 100644
--- a/MdeModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdCtrller.c
+++ b/MdeModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdCtrller.c
@@ -1812,32 +1812,6 @@ Done:
 
 }
 
-/**
-  Disable the keyboard interface of the 8042 controller.
-
-  @param ConsoleIn   The device instance
-
-  @return status of issuing disable command
-
-**/
-EFI_STATUS
-DisableKeyboard (
-  IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn
-  )
-{
-  EFI_STATUS  Status;
-
-  //
-  // Disable keyboard interface
-  //
-  Status = KeyboardCommand (ConsoleIn, KEYBOARD_8042_COMMAND_DISABLE_KEYBOARD_INTERFACE);
-  if (EFI_ERROR (Status)) {
-    KeyboardError (ConsoleIn, L"\n\r");
-    return EFI_DEVICE_ERROR;
-  }
-
-  return Status;
-}
 
 /**
   Check whether there is Ps/2 Keyboard device in system by 0xF4 Keyboard Command
diff --git a/MdeModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2Keyboard.h b/MdeModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2Keyboard.h
index b6a4f3c6b9..e0950ce113 100644
--- a/MdeModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2Keyboard.h
+++ b/MdeModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2Keyboard.h
@@ -300,18 +300,6 @@ InitKeyboard (
   IN BOOLEAN                     ExtendedVerification
   );
 
-/**
-  Disable the keyboard interface of the 8042 controller.
-
-  @param ConsoleIn   - the device instance
-
-  @return status of issuing disable command
-
-**/
-EFI_STATUS
-DisableKeyboard (
-  IN KEYBOARD_CONSOLE_IN_DEV *ConsoleIn
-  );
 
 /**
   Timer event handler: read a series of scancodes from 8042
diff --git a/MdeModulePkg/Bus/Pci/EhciDxe/EhciDebug.c b/MdeModulePkg/Bus/Pci/EhciDxe/EhciDebug.c
index 76368b4748..71755d421b 100644
--- a/MdeModulePkg/Bus/Pci/EhciDxe/EhciDebug.c
+++ b/MdeModulePkg/Bus/Pci/EhciDxe/EhciDebug.c
@@ -228,31 +228,4 @@ EhcDumpBuf (
   DEBUG ((EFI_D_VERBOSE, "\n"));
 }
 
-/**
-  Dump the EHCI status registers.
-
-  @param  Ehc    USB EHCI Host Controller instance
 
-**/
-VOID
-EhcDumpRegs (
-  IN  USB2_HC_DEV         *Ehc
-  )
-{
-  UINT8   Index;
-
-  DEBUG ((EFI_D_VERBOSE, "  EHC_CAPLENGTH_OFFSET   = 0x%08x\n", EhcReadCapRegister (Ehc, EHC_CAPLENGTH_OFFSET)));
-  DEBUG ((EFI_D_VERBOSE, "  EHC_HCSPARAMS_OFFSET   = 0x%08x\n", EhcReadCapRegister (Ehc, EHC_HCSPARAMS_OFFSET)));
-  DEBUG ((EFI_D_VERBOSE, "  EHC_HCCPARAMS_OFFSET   = 0x%08x\n", EhcReadCapRegister (Ehc, EHC_HCCPARAMS_OFFSET)));
-  DEBUG ((EFI_D_VERBOSE, "  EHC_USBCMD_OFFSET      = 0x%08x\n", EhcReadOpReg (Ehc, EHC_USBCMD_OFFSET)));
-  DEBUG ((EFI_D_VERBOSE, "  EHC_USBSTS_OFFSET      = 0x%08x\n", EhcReadOpReg (Ehc, EHC_USBSTS_OFFSET)));
-  DEBUG ((EFI_D_VERBOSE, "  EHC_USBINTR_OFFSET     = 0x%08x\n", EhcReadOpReg (Ehc, EHC_USBINTR_OFFSET)));
-  DEBUG ((EFI_D_VERBOSE, "  EHC_FRINDEX_OFFSET     = 0x%08x\n", EhcReadOpReg (Ehc, EHC_FRINDEX_OFFSET)));
-  DEBUG ((EFI_D_VERBOSE, "  EHC_CTRLDSSEG_OFFSET   = 0x%08x\n", EhcReadOpReg (Ehc,  EHC_CTRLDSSEG_OFFSET)));
-  DEBUG ((EFI_D_VERBOSE, "  EHC_FRAME_BASE_OFFSET  = 0x%08x\n", EhcReadOpReg (Ehc,  EHC_FRAME_BASE_OFFSET)));
-  DEBUG ((EFI_D_VERBOSE, "  EHC_ASYNC_HEAD_OFFSET  = 0x%08x\n", EhcReadOpReg (Ehc, EHC_ASYNC_HEAD_OFFSET)));
-  DEBUG ((EFI_D_VERBOSE, "  EHC_CONFIG_FLAG_OFFSET = 0x%08x\n", EhcReadOpReg (Ehc, EHC_CONFIG_FLAG_OFFSET)));
-  for (Index = 0; Index < (UINT8) (Ehc->HcStructParams & HCSP_NPORTS); Index++) {
-    DEBUG ((EFI_D_VERBOSE, "  EHC_PORT_STAT_OFFSET(%d)  = 0x%08x\n", Index, EhcReadOpReg (Ehc, EHC_PORT_STAT_OFFSET + (4 * Index))));
-  }
-}
diff --git a/MdeModulePkg/Bus/Pci/EhciDxe/EhciDebug.h b/MdeModulePkg/Bus/Pci/EhciDxe/EhciDebug.h
index bc84bb7864..a64b0551a0 100644
--- a/MdeModulePkg/Bus/Pci/EhciDxe/EhciDebug.h
+++ b/MdeModulePkg/Bus/Pci/EhciDxe/EhciDebug.h
@@ -61,15 +61,4 @@ EhcDumpBuf (
   );
 
 
-/**
-  Dump the EHCI status registers.
-
-  @param  Ehc    USB EHCI Host Controller instance
-
-**/
-VOID
-EhcDumpRegs (
-  IN  USB2_HC_DEV         *Ehc
-  );
-
 #endif
diff --git a/MdeModulePkg/Bus/Pci/EhciDxe/EhciReg.c b/MdeModulePkg/Bus/Pci/EhciDxe/EhciReg.c
index 34836eccf5..59752d1bdc 100644
--- a/MdeModulePkg/Bus/Pci/EhciDxe/EhciReg.c
+++ b/MdeModulePkg/Bus/Pci/EhciDxe/EhciReg.c
@@ -372,29 +372,7 @@ EhcEnablePeriodSchd (
 }
 
 
-/**
-  Disable periodic schedule.
 
-  @param  Ehc               The EHCI device.
-  @param  Timeout           Time to wait before abort (in millisecond, ms).
-
-  @retval EFI_SUCCESS       Periodic schedule is disabled.
-  @retval EFI_DEVICE_ERROR  Fail to disable periodic schedule.
-
-**/
-EFI_STATUS
-EhcDisablePeriodSchd (
-  IN USB2_HC_DEV          *Ehc,
-  IN UINT32               Timeout
-  )
-{
-  EFI_STATUS              Status;
-
-  EhcClearOpRegBit (Ehc, EHC_USBCMD_OFFSET, USBCMD_ENABLE_PERIOD);
-
-  Status = EhcWaitOpRegBit (Ehc, EHC_USBSTS_OFFSET, USBSTS_PERIOD_ENABLED, FALSE, Timeout);
-  return Status;
-}
 
 
 
@@ -424,29 +402,7 @@ EhcEnableAsyncSchd (
 
 
 
-/**
-  Disable asynchrounous schedule.
 
-  @param  Ehc          The EHCI device.
-  @param  Timeout      Time to wait before abort (in millisecond, ms).
-
-  @retval EFI_SUCCESS  The asynchronous schedule is disabled.
-  @return Others       Failed to disable the asynchronous schedule.
-
-**/
-EFI_STATUS
-EhcDisableAsyncSchd (
-  IN USB2_HC_DEV          *Ehc,
-  IN UINT32               Timeout
-  )
-{
-  EFI_STATUS  Status;
-
-  EhcClearOpRegBit (Ehc, EHC_USBCMD_OFFSET, USBCMD_ENABLE_ASYNC);
-
-  Status = EhcWaitOpRegBit (Ehc, EHC_USBSTS_OFFSET, USBSTS_ASYNC_ENABLED, FALSE, Timeout);
-  return Status;
-}
 
 
 
diff --git a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressHci.c b/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressHci.c
index 30ade3a589..421561f16d 100644
--- a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressHci.c
+++ b/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressHci.c
@@ -183,43 +183,7 @@ ReadNvmeControllerStatus (
   return EFI_SUCCESS;
 }
 
-/**
-  Read Nvm Express admin queue attributes register.
-
-  @param  Private          The pointer to the NVME_CONTROLLER_PRIVATE_DATA data structure.
-  @param  Aqa              The buffer used to store admin queue attributes register content.
-
-  @return EFI_SUCCESS      Successfully read the admin queue attributes register content.
-  @return EFI_DEVICE_ERROR Fail to read the admin queue attributes register.
-
-**/
-EFI_STATUS
-ReadNvmeAdminQueueAttributes (
-  IN NVME_CONTROLLER_PRIVATE_DATA     *Private,
-  IN NVME_AQA                         *Aqa
-  )
-{
-  EFI_PCI_IO_PROTOCOL   *PciIo;
-  EFI_STATUS            Status;
-  UINT32                Data;
-
-  PciIo  = Private->PciIo;
-  Status = PciIo->Mem.Read (
-                        PciIo,
-                        EfiPciIoWidthUint32,
-                        NVME_BAR,
-                        NVME_AQA_OFFSET,
-                        1,
-                        &Data
-                        );
-
-  if (EFI_ERROR(Status)) {
-    return Status;
-  }
 
-  WriteUnaligned32 ((UINT32*)Aqa, Data);
-  return EFI_SUCCESS;
-}
 
 /**
   Write Nvm Express admin queue attributes register.
@@ -262,43 +226,6 @@ WriteNvmeAdminQueueAttributes (
   return EFI_SUCCESS;
 }
 
-/**
-  Read Nvm Express admin submission queue base address register.
-
-  @param  Private          The pointer to the NVME_CONTROLLER_PRIVATE_DATA data structure.
-  @param  Asq              The buffer used to store admin submission queue base address register content.
-
-  @return EFI_SUCCESS      Successfully read the admin submission queue base address register content.
-  @return EFI_DEVICE_ERROR Fail to read the admin submission queue base address register.
-
-**/
-EFI_STATUS
-ReadNvmeAdminSubmissionQueueBaseAddress (
-  IN NVME_CONTROLLER_PRIVATE_DATA     *Private,
-  IN NVME_ASQ                         *Asq
-  )
-{
-  EFI_PCI_IO_PROTOCOL   *PciIo;
-  EFI_STATUS            Status;
-  UINT64                Data;
-
-  PciIo  = Private->PciIo;
-  Status = PciIo->Mem.Read (
-                        PciIo,
-                        EfiPciIoWidthUint32,
-                        NVME_BAR,
-                        NVME_ASQ_OFFSET,
-                        2,
-                        &Data
-                        );
-
-  if (EFI_ERROR(Status)) {
-    return Status;
-  }
-
-  WriteUnaligned64 ((UINT64*)Asq, Data);
-  return EFI_SUCCESS;
-}
 
 /**
   Write Nvm Express admin submission queue base address register.
@@ -341,44 +268,7 @@ WriteNvmeAdminSubmissionQueueBaseAddress (
   return EFI_SUCCESS;
 }
 
-/**
-  Read Nvm Express admin completion queue base address register.
-
-  @param  Private          The pointer to the NVME_CONTROLLER_PRIVATE_DATA data structure.
-  @param  Acq              The buffer used to store admin completion queue base address register content.
-
-  @return EFI_SUCCESS      Successfully read the admin completion queue base address register content.
-  @return EFI_DEVICE_ERROR Fail to read the admin completion queue base address register.
-
-**/
-EFI_STATUS
-ReadNvmeAdminCompletionQueueBaseAddress (
-  IN NVME_CONTROLLER_PRIVATE_DATA     *Private,
-  IN NVME_ACQ                         *Acq
-  )
-{
-  EFI_PCI_IO_PROTOCOL   *PciIo;
-  EFI_STATUS            Status;
-  UINT64                Data;
-
-  PciIo  = Private->PciIo;
 
-  Status = PciIo->Mem.Read (
-                        PciIo,
-                        EfiPciIoWidthUint32,
-                        NVME_BAR,
-                        NVME_ACQ_OFFSET,
-                        2,
-                        &Data
-                        );
-
-  if (EFI_ERROR(Status)) {
-    return Status;
-  }
-
-  WriteUnaligned64 ((UINT64*)Acq, Data);
-  return EFI_SUCCESS;
-}
 
 /**
   Write Nvm Express admin completion queue base address register.
diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c b/MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c
index 48cf57a24f..f7039da992 100644
--- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c
+++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c
@@ -1061,85 +1061,5 @@ ActiveVGADeviceOnTheRootBridge (
 }
 
 
-/**
-  Get HPC PCI address according to its device path.
-
-  @param RootBridge           Root bridege Io instance.
-  @param RemainingDevicePath  Given searching device path.
-  @param PciAddress           Buffer holding searched result.
-
-  @retval EFI_SUCCESS         PCI address was stored in PciAddress
-  @retval EFI_NOT_FOUND       Can not find the specific device path.
-
-**/
-EFI_STATUS
-GetHpcPciAddressFromRootBridge (
-  IN  PCI_IO_DEVICE                    *RootBridge,
-  IN  EFI_DEVICE_PATH_PROTOCOL         *RemainingDevicePath,
-  OUT UINT64                           *PciAddress
-  )
-{
-  EFI_DEV_PATH_PTR          Node;
-  PCI_IO_DEVICE             *Temp;
-  EFI_DEVICE_PATH_PROTOCOL  *CurrentDevicePath;
-  LIST_ENTRY                *CurrentLink;
-  BOOLEAN                   MisMatch;
-
-  MisMatch          = FALSE;
-
-  CurrentDevicePath = RemainingDevicePath;
-  Node.DevPath      = CurrentDevicePath;
-  Temp              = NULL;
-
-  while (!IsDevicePathEnd (CurrentDevicePath)) {
-
-    CurrentLink   = RootBridge->ChildList.ForwardLink;
-    Node.DevPath  = CurrentDevicePath;
-
-    while (CurrentLink != NULL && CurrentLink != &RootBridge->ChildList) {
-      Temp = PCI_IO_DEVICE_FROM_LINK (CurrentLink);
-
-      if (Node.Pci->Device   == Temp->DeviceNumber &&
-          Node.Pci->Function == Temp->FunctionNumber) {
-        RootBridge = Temp;
-        break;
-      }
-
-      CurrentLink = CurrentLink->ForwardLink;
-    }
-
-    //
-    // Check if we find the bridge
-    //
-    if (CurrentLink == &RootBridge->ChildList) {
-
-      MisMatch = TRUE;
-      break;
-
-    }
-
-    CurrentDevicePath = NextDevicePathNode (CurrentDevicePath);
-  }
-
-  if (MisMatch) {
-
-    CurrentDevicePath = NextDevicePathNode (CurrentDevicePath);
-
-    if (IsDevicePathEnd (CurrentDevicePath)) {
-      *PciAddress = EFI_PCI_ADDRESS (RootBridge->BusNumber, Node.Pci->Device, Node.Pci->Function, 0);
-      return EFI_SUCCESS;
-    }
-
-    return EFI_NOT_FOUND;
-  }
 
-  if (Temp != NULL) {
-    *PciAddress = EFI_PCI_ADDRESS (Temp->BusNumber, Temp->DeviceNumber, Temp->FunctionNumber, 0);
-  } else {
-    return EFI_NOT_FOUND;
-  }
-
-  return EFI_SUCCESS;
-
-}
 
diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.h b/MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.h
index 1a01e72b1e..c282381f85 100644
--- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.h
+++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.h
@@ -255,23 +255,6 @@ ActiveVGADeviceOnTheRootBridge (
   IN PCI_IO_DEVICE        *RootBridge
   );
 
-/**
-  Get HPC PCI address according to its device path.
-
-  @param RootBridge           Root bridege Io instance.
-  @param RemainingDevicePath  Given searching device path.
-  @param PciAddress           Buffer holding searched result.
-
-  @retval EFI_SUCCESS         PCI address was stored in PciAddress.
-  @retval EFI_NOT_FOUND       Can not find the specific device path.
-
-**/
-EFI_STATUS
-GetHpcPciAddressFromRootBridge (
-  IN  PCI_IO_DEVICE                    *RootBridge,
-  IN  EFI_DEVICE_PATH_PROTOCOL         *RemainingDevicePath,
-  OUT UINT64                           *PciAddress
-  );
 
 /**
   Destroy a pci device node.
diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciIo.c b/MdeModulePkg/Bus/Pci/PciBusDxe/PciIo.c
index 87b0b9884a..291578c63c 100644
--- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciIo.c
+++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciIo.c
@@ -2061,47 +2061,6 @@ PciIoSetBarAttributes (
   return EFI_SUCCESS;
 }
 
-/**
-  Program parent bridge's attribute recurrently.
-
-  @param PciIoDevice  Child Pci device instance
-  @param Operation    The operation to perform on the attributes for this PCI controller.
-  @param Attributes   The mask of attributes that are used for Set, Enable, and Disable
-                      operations.
-
-  @retval EFI_SUCCESS           The operation on the PCI controller's attributes was completed.
-  @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
-  @retval EFI_UNSUPPORTED       one or more of the bits set in
-                                Attributes are not supported by this PCI controller or one of
-                                its parent bridges when Operation is Set, Enable or Disable.
-
-**/
-EFI_STATUS
-UpStreamBridgesAttributes (
-  IN PCI_IO_DEVICE                            *PciIoDevice,
-  IN EFI_PCI_IO_PROTOCOL_ATTRIBUTE_OPERATION  Operation,
-  IN UINT64                                   Attributes
-  )
-{
-  PCI_IO_DEVICE       *Parent;
-  EFI_PCI_IO_PROTOCOL *PciIo;
-
-  Parent = PciIoDevice->Parent;
-
-  while (Parent != NULL && IS_PCI_BRIDGE (&Parent->Pci)) {
-
-    //
-    // Get the PciIo Protocol
-    //
-    PciIo = &Parent->PciIo;
-
-    PciIo->Attributes (PciIo, Operation, Attributes, NULL);
-
-    Parent = Parent->Parent;
-  }
-
-  return EFI_SUCCESS;
-}
 
 /**
   Test whether two Pci devices has same parent bridge.
diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciIo.h b/MdeModulePkg/Bus/Pci/PciBusDxe/PciIo.h
index b7e38ded3f..69e7c32881 100644
--- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciIo.h
+++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciIo.h
@@ -646,27 +646,6 @@ PciIoSetBarAttributes (
   IN OUT UINT64                       *Length
   );
 
-/**
-  Program parent bridge's attribute recurrently.
-
-  @param PciIoDevice  Child Pci device instance
-  @param Operation    The operation to perform on the attributes for this PCI controller.
-  @param Attributes   The mask of attributes that are used for Set, Enable, and Disable
-                      operations.
-
-  @retval EFI_SUCCESS           The operation on the PCI controller's attributes was completed.
-  @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
-  @retval EFI_UNSUPPORTED       one or more of the bits set in
-                                Attributes are not supported by this PCI controller or one of
-                                its parent bridges when Operation is Set, Enable or Disable.
-
-**/
-EFI_STATUS
-UpStreamBridgesAttributes (
-  IN PCI_IO_DEVICE                            *PciIoDevice,
-  IN EFI_PCI_IO_PROTOCOL_ATTRIBUTE_OPERATION  Operation,
-  IN UINT64                                   Attributes
-  );
 
 /**
   Test whether two Pci devices has same parent bridge.
diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdDevice.c b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdDevice.c
index 9e70de956f..27909f44d8 100644
--- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdDevice.c
+++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdDevice.c
@@ -318,59 +318,7 @@ SdCardSetRca (
   return Status;
 }
 
-/**
-  Send command SEND_CSD to the SD device to get the data of the CSD register.
-
-  Refer to SD Physical Layer Simplified Spec 4.1 Section 4.7 for details.
-
-  @param[in]  PassThru      A pointer to the EFI_SD_MMC_PASS_THRU_PROTOCOL instance.
-  @param[in]  Slot          The slot number of the SD card to send the command to.
-  @param[in]  Rca           The relative device address of selected device.
-  @param[out] Csd           The buffer to store the content of the CSD register.
-                            Note the caller should ignore the lowest byte of this
-                            buffer as the content of this byte is meaningless even
-                            if the operation succeeds.
-
-  @retval EFI_SUCCESS       The operation is done correctly.
-  @retval Others            The operation fails.
 
-**/
-EFI_STATUS
-SdCardGetCsd (
-  IN     EFI_SD_MMC_PASS_THRU_PROTOCOL  *PassThru,
-  IN     UINT8                          Slot,
-  IN     UINT16                         Rca,
-     OUT SD_CSD                         *Csd
-  )
-{
-  EFI_SD_MMC_COMMAND_BLOCK              SdMmcCmdBlk;
-  EFI_SD_MMC_STATUS_BLOCK               SdMmcStatusBlk;
-  EFI_SD_MMC_PASS_THRU_COMMAND_PACKET   Packet;
-  EFI_STATUS                            Status;
-
-  ZeroMem (&SdMmcCmdBlk, sizeof (SdMmcCmdBlk));
-  ZeroMem (&SdMmcStatusBlk, sizeof (SdMmcStatusBlk));
-  ZeroMem (&Packet, sizeof (Packet));
-
-  Packet.SdMmcCmdBlk    = &SdMmcCmdBlk;
-  Packet.SdMmcStatusBlk = &SdMmcStatusBlk;
-  Packet.Timeout        = SD_MMC_HC_GENERIC_TIMEOUT;
-
-  SdMmcCmdBlk.CommandIndex = SD_SEND_CSD;
-  SdMmcCmdBlk.CommandType  = SdMmcCommandTypeAc;
-  SdMmcCmdBlk.ResponseType = SdMmcResponseTypeR2;
-  SdMmcCmdBlk.CommandArgument = (UINT32)Rca << 16;
-
-  Status = SdMmcPassThruPassThru (PassThru, Slot, &Packet, NULL);
-  if (!EFI_ERROR (Status)) {
-    //
-    // For details, refer to SD Host Controller Simplified Spec 3.0 Table 2-12.
-    //
-    CopyMem (((UINT8*)Csd) + 1, &SdMmcStatusBlk.Resp0, sizeof (SD_CSD) - 1);
-  }
-
-  return Status;
-}
 
 /**
   Send command SEND_CSD to the SD device to get the data of the CSD register.
@@ -386,48 +334,6 @@ SdCardGetCsd (
   @retval Others            The operation fails.
 
 **/
-EFI_STATUS
-SdCardGetScr (
-  IN     EFI_SD_MMC_PASS_THRU_PROTOCOL  *PassThru,
-  IN     UINT8                          Slot,
-  IN     UINT16                         Rca,
-     OUT SD_SCR                         *Scr
-  )
-{
-  EFI_SD_MMC_COMMAND_BLOCK              SdMmcCmdBlk;
-  EFI_SD_MMC_STATUS_BLOCK               SdMmcStatusBlk;
-  EFI_SD_MMC_PASS_THRU_COMMAND_PACKET   Packet;
-  EFI_STATUS                            Status;
-
-  ZeroMem (&SdMmcCmdBlk, sizeof (SdMmcCmdBlk));
-  ZeroMem (&SdMmcStatusBlk, sizeof (SdMmcStatusBlk));
-  ZeroMem (&Packet, sizeof (Packet));
-
-  Packet.SdMmcCmdBlk    = &SdMmcCmdBlk;
-  Packet.SdMmcStatusBlk = &SdMmcStatusBlk;
-  Packet.Timeout        = SD_MMC_HC_GENERIC_TIMEOUT;
-
-  SdMmcCmdBlk.CommandIndex = SD_APP_CMD;
-  SdMmcCmdBlk.CommandType  = SdMmcCommandTypeAc;
-  SdMmcCmdBlk.ResponseType = SdMmcResponseTypeR1;
-  SdMmcCmdBlk.CommandArgument = (UINT32)Rca << 16;
-
-  Status = SdMmcPassThruPassThru (PassThru, Slot, &Packet, NULL);
-  if (EFI_ERROR (Status)) {
-    return Status;
-  }
-
-  SdMmcCmdBlk.CommandIndex = SD_SEND_SCR;
-  SdMmcCmdBlk.CommandType  = SdMmcCommandTypeAdtc;
-  SdMmcCmdBlk.ResponseType = SdMmcResponseTypeR1;
-
-  Packet.InDataBuffer     = Scr;
-  Packet.InTransferLength = sizeof (SD_SCR);
-
-  Status = SdMmcPassThruPassThru (PassThru, Slot, &Packet, NULL);
-
-  return Status;
-}
 
 /**
   Send command SELECT_DESELECT_CARD to the SD device to select/deselect it.
diff --git a/MdeModulePkg/Bus/Pci/UhciPei/DmaMem.c b/MdeModulePkg/Bus/Pci/UhciPei/DmaMem.c
index c92bee4298..f4202ba6e6 100644
--- a/MdeModulePkg/Bus/Pci/UhciPei/DmaMem.c
+++ b/MdeModulePkg/Bus/Pci/UhciPei/DmaMem.c
@@ -205,29 +205,7 @@ IoMmuAllocateBuffer (
   return Status;
 }
 
-/**
-  Frees memory that was allocated with AllocateBuffer().
-
-  @param IoMmu              Pointer to IOMMU PPI.
-  @param Pages              The number of pages to free.
-  @param HostAddress        The base system memory address of the allocated range.
-  @param Mapping            The mapping value returned from Map().
 
-**/
-VOID
-IoMmuFreeBuffer (
-  IN EDKII_IOMMU_PPI        *IoMmu,
-  IN UINTN                  Pages,
-  IN VOID                   *HostAddress,
-  IN VOID                   *Mapping
-  )
-{
-  if (IoMmu != NULL) {
-    IoMmu->SetAttribute (IoMmu, Mapping, 0);
-    IoMmu->Unmap (IoMmu, Mapping);
-    IoMmu->FreeBuffer (IoMmu, Pages, HostAddress);
-  }
-}
 
 /**
   Initialize IOMMU.
diff --git a/MdeModulePkg/Bus/Pci/UhciPei/UhcPeim.c b/MdeModulePkg/Bus/Pci/UhciPei/UhcPeim.c
index ec2daf1649..645c946f29 100644
--- a/MdeModulePkg/Bus/Pci/UhciPei/UhcPeim.c
+++ b/MdeModulePkg/Bus/Pci/UhciPei/UhcPeim.c
@@ -1252,26 +1252,7 @@ IsStatusOK (
   }
 }
 
-/**
-  Get Current Frame Number.
-
-  @param  UhcDev          The UHCI device.
-  @param  FrameNumberAddr The address of frame list register.
-
-  @retval The content of the frame list register.
 
-**/
-UINT16
-GetCurrentFrameNumber (
-  IN USB_UHC_DEV   *UhcDev,
-  IN UINT32        FrameNumberAddr
-  )
-{
-  //
-  // Gets value in the USB frame number register.
-  //
-  return (UINT16) (USBReadPortW (UhcDev, FrameNumberAddr) & 0x03FF);
-}
 
 /**
   Set Frame List Base Address.
@@ -1349,25 +1330,7 @@ SetQHHorizontalLinkPtr (
   PtrQH->QueueHead.QHHorizontalPtr = (UINT32) (UINTN) PtrNext >> 4;
 }
 
-/**
-  Get the horizontal link pointer in QH.
-
-  @param  PtrQH     Place to store QH_STRUCT pointer.
 
-  @retval The horizontal link pointer in QH.
-
-**/
-VOID *
-GetQHHorizontalLinkPtr (
-  IN QH_STRUCT  *PtrQH
-  )
-{
-  //
-  // Restore the 28bit address to 32bit address
-  // (take 32bit address as an example)
-  //
-  return (VOID *) (UINTN) ((PtrQH->QueueHead.QHHorizontalPtr) << 4);
-}
 
 /**
   Set a QH or TD horizontally to be connected with a specific QH.
@@ -1470,25 +1433,7 @@ SetQHVerticalValidorInvalid (
   PtrQH->QueueHead.QHVerticalTerminate = IsValid ? 0 : 1;
 }
 
-/**
-  Get the vertical validor bit in QH.
 
-  @param  PtrQH      Place to store QH_STRUCT pointer.
-
-  @retval The vertical linker is valid or not.
-
-**/
-BOOLEAN
-GetQHHorizontalValidorInvalid (
-  IN QH_STRUCT  *PtrQH
-  )
-{
-  //
-  // If TRUE, meaning the Horizontal Link Pointer field is valid,
-  // else, the field is invalid.
-  //
-  return (BOOLEAN) (!(PtrQH->QueueHead.QHHorizontalTerminate));
-}
 
 /**
   Allocate TD or QH Struct.
@@ -2000,26 +1945,7 @@ GetTDLinkPtr (
   return (VOID *) (UINTN) ((PtrTDStruct->TDData.TDLinkPtr) << 4);
 }
 
-/**
-  Get the information about whether the Link Pointer field pointing to
-  a QH or a TD.
 
-  @param  PtrTDStruct     Place to store TD_STRUCT pointer.
-
-  @retval whether the Link Pointer field pointing to a QH or a TD.
-
-**/
-BOOLEAN
-IsTDLinkPtrQHOrTD (
-  IN  TD_STRUCT *PtrTDStruct
-  )
-{
-  //
-  // Get the information about whether the Link Pointer field pointing to
-  // a QH or a TD.
-  //
-  return (BOOLEAN) (PtrTDStruct->TDData.TDLinkPtrQSelect);
-}
 
 /**
   Enable/Disable short packet detection mechanism.
@@ -3239,60 +3165,9 @@ InsertMemoryHeaderToList (
   }
 }
 
-/**
-  Judge the memory block in the memory header is empty or not.
-
-  @param  MemoryHeaderPtr   A pointer to the memory header list.
-
-  @retval Whether the memory block in the memory header is empty or not.
-
-**/
-BOOLEAN
-IsMemoryBlockEmptied (
-  IN MEMORY_MANAGE_HEADER  *MemoryHeaderPtr
-  )
-{
-  UINTN Index;
-
-  for (Index = 0; Index < MemoryHeaderPtr->BitArraySizeInBytes; Index++) {
-    if (MemoryHeaderPtr->BitArrayPtr[Index] != 0) {
-      return FALSE;
-    }
-  }
-
-  return TRUE;
-}
-
-/**
-  remove a memory header from list.
 
-  @param  FirstMemoryHeader   A pointer to the memory header list.
-  @param  FreeMemoryHeader    A memory header to be removed into the list.
 
-**/
-VOID
-DelinkMemoryBlock (
-  IN MEMORY_MANAGE_HEADER    *FirstMemoryHeader,
-  IN MEMORY_MANAGE_HEADER    *FreeMemoryHeader
-  )
-{
-  MEMORY_MANAGE_HEADER  *TempHeaderPtr;
 
-  if ((FirstMemoryHeader == NULL) || (FreeMemoryHeader == NULL)) {
-    return ;
-  }
-
-  for (TempHeaderPtr = FirstMemoryHeader; TempHeaderPtr != NULL; TempHeaderPtr = TempHeaderPtr->Next) {
-
-    if (TempHeaderPtr->Next == FreeMemoryHeader) {
-      //
-      // Link the before and after
-      //
-      TempHeaderPtr->Next = FreeMemoryHeader->Next;
-      break;
-    }
-  }
-}
 
 /**
   Map address of request structure buffer.
diff --git a/MdeModulePkg/Bus/Pci/UhciPei/UhcPeim.h b/MdeModulePkg/Bus/Pci/UhciPei/UhcPeim.h
index 33d4f2f65f..01a9782d76 100644
--- a/MdeModulePkg/Bus/Pci/UhciPei/UhcPeim.h
+++ b/MdeModulePkg/Bus/Pci/UhciPei/UhcPeim.h
@@ -472,21 +472,6 @@ IsStatusOK (
   IN UINT32          StatusRegAddr
   );
 
-/**
-  Get Current Frame Number.
-
-  @param  UhcDev          The UHCI device.
-  @param  FrameNumberAddr The address of frame list register.
-
-  @retval The content of the frame list register.
-
-**/
-UINT16
-GetCurrentFrameNumber (
-  IN USB_UHC_DEV   *UhcDev,
-  IN UINT32        FrameNumberAddr
-  );
-
 /**
   Set Frame List Base Address.
 
@@ -531,19 +516,6 @@ SetQHHorizontalLinkPtr (
   IN VOID       *PtrNext
   );
 
-/**
-  Get the horizontal link pointer in QH.
-
-  @param  PtrQH     Place to store QH_STRUCT pointer.
-
-  @retval The horizontal link pointer in QH.
-
-**/
-VOID  *
-GetQHHorizontalLinkPtr (
-  IN QH_STRUCT  *PtrQH
-  );
-
 /**
   Set a QH or TD horizontally to be connected with a specific QH.
 
@@ -609,18 +581,6 @@ SetQHVerticalValidorInvalid (
   IN BOOLEAN    IsValid
   );
 
-/**
-  Get the vertical validor bit in QH.
-
-  @param  PtrQH      Place to store QH_STRUCT pointer.
-
-  @retval The vertical linker is valid or not.
-
-**/
-BOOLEAN
-GetQHHorizontalValidorInvalid (
-  IN QH_STRUCT  *PtrQH
-  );
 
 /**
   Allocate TD or QH Struct.
@@ -805,19 +765,6 @@ GetTDLinkPtr (
   IN  TD_STRUCT *PtrTDStruct
   );
 
-/**
-  Get the information about whether the Link Pointer field pointing to
-  a QH or a TD.
-
-  @param  PtrTDStruct     Place to store TD_STRUCT pointer.
-
-  @retval whether the Link Pointer field pointing to a QH or a TD.
-
-**/
-BOOLEAN
-IsTDLinkPtrQHOrTD (
-  IN  TD_STRUCT *PtrTDStruct
-  );
 
 /**
   Enable/Disable short packet detection mechanism.
@@ -1317,31 +1264,6 @@ InsertMemoryHeaderToList (
   IN MEMORY_MANAGE_HEADER  *NewMemoryHeader
   );
 
-/**
-  Judge the memory block in the memory header is empty or not.
-
-  @param  MemoryHeaderPtr   A pointer to the memory header list.
-
-  @retval Whether the memory block in the memory header is empty or not.
-
-**/
-BOOLEAN
-IsMemoryBlockEmptied (
-  IN MEMORY_MANAGE_HEADER  *MemoryHeaderPtr
-  );
-
-/**
-  remove a memory header from list.
-
-  @param  FirstMemoryHeader   A pointer to the memory header list.
-  @param  FreeMemoryHeader    A memory header to be removed into the list.
-
-**/
-VOID
-DelinkMemoryBlock (
-  IN MEMORY_MANAGE_HEADER    *FirstMemoryHeader,
-  IN MEMORY_MANAGE_HEADER    *FreeMemoryHeader
-  );
 
 /**
   Map address of request structure buffer.
diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.c b/MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.c
index 4d5937de53..5f0736a516 100644
--- a/MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.c
+++ b/MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.c
@@ -158,75 +158,9 @@ XhcWriteOpReg (
   }
 }
 
-/**
-  Write the data to the 2-bytes width XHCI operational register.
 
-  @param  Xhc          The XHCI Instance.
-  @param  Offset       The offset of the 2-bytes width operational register.
-  @param  Data         The data to write.
 
-**/
-VOID
-XhcWriteOpReg16 (
-  IN USB_XHCI_INSTANCE    *Xhc,
-  IN UINT32               Offset,
-  IN UINT16               Data
-  )
-{
-  EFI_STATUS              Status;
-
-  ASSERT (Xhc->CapLength != 0);
-
-  Status = Xhc->PciIo->Mem.Write (
-                             Xhc->PciIo,
-                             EfiPciIoWidthUint16,
-                             XHC_BAR_INDEX,
-                             Xhc->CapLength + Offset,
-                             1,
-                             &Data
-                             );
-
-  if (EFI_ERROR (Status)) {
-    DEBUG ((EFI_D_ERROR, "XhcWriteOpReg16: Pci Io Write error: %r at %d\n", Status, Offset));
-  }
-}
-
-/**
-  Read XHCI door bell register.
-
-  @param  Xhc          The XHCI Instance.
-  @param  Offset       The offset of the door bell register.
 
-  @return The register content read
-
-**/
-UINT32
-XhcReadDoorBellReg (
-  IN  USB_XHCI_INSTANCE   *Xhc,
-  IN  UINT32              Offset
-  )
-{
-  UINT32                  Data;
-  EFI_STATUS              Status;
-
-  ASSERT (Xhc->DBOff != 0);
-
-  Status = Xhc->PciIo->Mem.Read (
-                             Xhc->PciIo,
-                             EfiPciIoWidthUint32,
-                             XHC_BAR_INDEX,
-                             Xhc->DBOff + Offset,
-                             1,
-                             &Data
-                             );
-
-  if (EFI_ERROR (Status)) {
-    DEBUG ((EFI_D_ERROR, "XhcReadDoorBellReg: Pci Io Read error - %r at %d\n", Status, Offset));
-    Data = 0xFFFFFFFF;
-  }
-
-  return Data;
-}
 
 /**
   Write the data to the XHCI door bell register.
diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.h b/MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.h
index 838a44628c..20e7ac0e8f 100644
--- a/MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.h
+++ b/MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.h
@@ -286,20 +286,6 @@ XhcWriteOpReg (
   IN UINT32               Data
   );
 
-/**
-  Write the data to the 2-bytes width XHCI operational register.
-
-  @param  Xhc          The XHCI Instance.
-  @param  Offset       The offset of the 2-bytes width operational register.
-  @param  Data         The data to write.
-
-**/
-VOID
-XhcWriteOpReg16 (
-  IN USB_XHCI_INSTANCE    *Xhc,
-  IN UINT32               Offset,
-  IN UINT16               Data
-  );
 
 /**
   Read XHCI runtime register.
@@ -331,20 +317,6 @@ XhcWriteRuntimeReg (
   IN UINT32               Data
   );
 
-/**
-  Read XHCI door bell register.
-
-  @param  Xhc          The XHCI Instance.
-  @param  Offset       The offset of the door bell register.
-
-  @return The register content read
-
-**/
-UINT32
-XhcReadDoorBellReg (
-  IN  USB_XHCI_INSTANCE   *Xhc,
-  IN  UINT32              Offset
-  );
 
 /**
   Write the data to the XHCI door bell register.
diff --git a/MdeModulePkg/Bus/Pci/XhciPei/UsbHcMem.c b/MdeModulePkg/Bus/Pci/XhciPei/UsbHcMem.c
index 5d0232ca56..442a613095 100644
--- a/MdeModulePkg/Bus/Pci/XhciPei/UsbHcMem.c
+++ b/MdeModulePkg/Bus/Pci/XhciPei/UsbHcMem.c
@@ -328,31 +328,7 @@ UsbHcIsMemBlockEmpty (
   return TRUE;
 }
 
-/**
-  Unlink the memory block from the pool's list.
-
-  @param  Head          The block list head of the memory's pool.
-  @param  BlockToUnlink The memory block to unlink.
 
-**/
-VOID
-UsbHcUnlinkMemBlock (
-  IN USBHC_MEM_BLOCK    *Head,
-  IN USBHC_MEM_BLOCK    *BlockToUnlink
-  )
-{
-  USBHC_MEM_BLOCK       *Block;
-
-  ASSERT ((Head != NULL) && (BlockToUnlink != NULL));
-
-  for (Block = Head; Block != NULL; Block = Block->Next) {
-    if (Block->Next == BlockToUnlink) {
-      Block->Next         = BlockToUnlink->Next;
-      BlockToUnlink->Next = NULL;
-      break;
-    }
-  }
-}
 
 /**
   Initialize the memory management pool for the host controller.
diff --git a/MdeModulePkg/Bus/Pci/XhciPei/XhcPeim.c b/MdeModulePkg/Bus/Pci/XhciPei/XhcPeim.c
index c5631e87ca..ee4d1f97bd 100644
--- a/MdeModulePkg/Bus/Pci/XhciPei/XhcPeim.c
+++ b/MdeModulePkg/Bus/Pci/XhciPei/XhcPeim.c
@@ -211,29 +211,7 @@ XhcPeiReadCapRegister (
   return Data;
 }
 
-/**
-  Read XHCI door bell register.
-
-  @param  Xhc       The XHCI device.
-  @param  Offset    The offset of the door bell register.
-
-  @return The register content read
 
-**/
-UINT32
-XhcPeiReadDoorBellReg (
-  IN  PEI_XHC_DEV       *Xhc,
-  IN  UINT32            Offset
-  )
-{
-  UINT32                  Data;
-
-  ASSERT (Xhc->DBOff != 0);
-
-  Data = MmioRead32 (Xhc->UsbHostControllerBaseAddress + Xhc->DBOff + Offset);
-
-  return Data;
-}
 
 /**
   Write the data to the XHCI door bell register.
diff --git a/MdeModulePkg/Bus/Pci/XhciPei/XhciReg.h b/MdeModulePkg/Bus/Pci/XhciPei/XhciReg.h
index 0297072ffd..3787aeccf5 100644
--- a/MdeModulePkg/Bus/Pci/XhciPei/XhciReg.h
+++ b/MdeModulePkg/Bus/Pci/XhciPei/XhciReg.h
@@ -302,20 +302,6 @@ XhcPeiWaitOpRegBit (
   IN UINT32             Timeout
   );
 
-/**
-  Read XHCI door bell register.
-
-  @param  Xhc           The XHCI device.
-  @param  Offset        The offset of the door bell register.
-
-  @return The register content read
-
-**/
-UINT32
-XhcPeiReadDoorBellReg (
-  IN  PEI_XHC_DEV       *Xhc,
-  IN  UINT32            Offset
-  );
 
 /**
   Write the data to the XHCI door bell register.
diff --git a/MdeModulePkg/Bus/Sd/EmmcBlockIoPei/EmmcHcMem.c b/MdeModulePkg/Bus/Sd/EmmcBlockIoPei/EmmcHcMem.c
index a6f188f385..217736c1a6 100644
--- a/MdeModulePkg/Bus/Sd/EmmcBlockIoPei/EmmcHcMem.c
+++ b/MdeModulePkg/Bus/Sd/EmmcBlockIoPei/EmmcHcMem.c
@@ -219,31 +219,7 @@ EmmcPeimIsMemBlockEmpty (
   return TRUE;
 }
 
-/**
-  Unlink the memory block from the pool's list.
-
-  @param  Head           The block list head of the memory's pool.
-  @param  BlockToUnlink  The memory block to unlink.
 
-**/
-VOID
-EmmcPeimUnlinkMemBlock (
-  IN EMMC_PEIM_MEM_BLOCK      *Head,
-  IN EMMC_PEIM_MEM_BLOCK      *BlockToUnlink
-  )
-{
-  EMMC_PEIM_MEM_BLOCK         *Block;
-
-  ASSERT ((Head != NULL) && (BlockToUnlink != NULL));
-
-  for (Block = Head; Block != NULL; Block = Block->Next) {
-    if (Block->Next == BlockToUnlink) {
-      Block->Next         = BlockToUnlink->Next;
-      BlockToUnlink->Next = NULL;
-      break;
-    }
-  }
-}
 
 /**
   Initialize the memory management pool for the host controller.
diff --git a/MdeModulePkg/Bus/Sd/SdBlockIoPei/SdHcMem.c b/MdeModulePkg/Bus/Sd/SdBlockIoPei/SdHcMem.c
index 24ad3dc6c2..0c3a424e3b 100644
--- a/MdeModulePkg/Bus/Sd/SdBlockIoPei/SdHcMem.c
+++ b/MdeModulePkg/Bus/Sd/SdBlockIoPei/SdHcMem.c
@@ -219,31 +219,7 @@ SdPeimIsMemBlockEmpty (
   return TRUE;
 }
 
-/**
-  Unlink the memory block from the pool's list.
-
-  @param  Head           The block list head of the memory's pool.
-  @param  BlockToUnlink  The memory block to unlink.
 
-**/
-VOID
-SdPeimUnlinkMemBlock (
-  IN SD_PEIM_MEM_BLOCK      *Head,
-  IN SD_PEIM_MEM_BLOCK      *BlockToUnlink
-  )
-{
-  SD_PEIM_MEM_BLOCK         *Block;
-
-  ASSERT ((Head != NULL) && (BlockToUnlink != NULL));
-
-  for (Block = Head; Block != NULL; Block = Block->Next) {
-    if (Block->Next == BlockToUnlink) {
-      Block->Next         = BlockToUnlink->Next;
-      BlockToUnlink->Next = NULL;
-      break;
-    }
-  }
-}
 
 /**
   Initialize the memory management pool for the host controller.
diff --git a/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsBlockIoPei.c b/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsBlockIoPei.c
index 505b92cfc1..204e456413 100644
--- a/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsBlockIoPei.c
+++ b/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsBlockIoPei.c
@@ -137,53 +137,7 @@ UFS_PEIM_HC_PRIVATE_DATA   gUfsHcPeimTemplate = {
   }
 };
 
-/**
-  Execute Request Sense SCSI command on a specific UFS device.
-
-  @param[in]  Private              A pointer to UFS_PEIM_HC_PRIVATE_DATA data structure.
-  @param[in]  Lun                  The lun on which the SCSI cmd executed.
-  @param[out] DataBuffer           A pointer to output sense data.
-  @param[out] DataBufferLength     The length of output sense data.
-
-  @retval EFI_SUCCESS              The command executed successfully.
-  @retval EFI_DEVICE_ERROR         A device error occurred while attempting to send SCSI Request Packet.
-  @retval EFI_TIMEOUT              A timeout occurred while waiting for the SCSI Request Packet to execute.
-
-**/
-EFI_STATUS
-UfsPeimRequestSense (
-  IN     UFS_PEIM_HC_PRIVATE_DATA        *Private,
-  IN     UINTN                           Lun,
-     OUT VOID                            *DataBuffer,
-     OUT UINT32                          *DataBufferLength
-  )
-{
-  UFS_SCSI_REQUEST_PACKET                Packet;
-  UINT8                                  Cdb[UFS_SCSI_OP_LENGTH_SIX];
-  EFI_STATUS                             Status;
 
-  ZeroMem (&Packet, sizeof (UFS_SCSI_REQUEST_PACKET));
-  ZeroMem (Cdb, sizeof (Cdb));
-
-  Cdb[0]  = EFI_SCSI_OP_REQUEST_SENSE;
-
-  Packet.Timeout          = UFS_TIMEOUT;
-  Packet.Cdb              = Cdb;
-  Packet.CdbLength        = sizeof (Cdb);
-  Packet.DataDirection    = UfsDataIn;
-  Packet.InDataBuffer     = DataBuffer;
-  Packet.InTransferLength = *DataBufferLength;
-  Packet.SenseData        = NULL;
-  Packet.SenseDataLength  = 0;
-
-  Status = UfsExecScsiCmds (Private,(UINT8)Lun, &Packet);
-
-  if (!EFI_ERROR (Status)) {
-    *DataBufferLength = Packet.InTransferLength;
-  }
-
-  return Status;
-}
 
 /**
   Execute TEST UNITY READY SCSI command on a specific UFS device.
@@ -231,62 +185,7 @@ UfsPeimTestUnitReady (
   return Status;
 }
 
-/**
-  Execute INQUIRY SCSI command on a specific UFS device.
-
-  @param[in]  Private              A pointer to UFS_PEIM_HC_PRIVATE_DATA data structure.
-  @param[in]  Lun                  The lun on which the SCSI cmd executed.
-  @param[out] Inquiry              A pointer to Inquiry data buffer.
-  @param[out] InquiryLengths       The length of output Inquiry data.
-  @param[out] SenseData            A pointer to output sense data.
-  @param[out] SenseDataLength      The length of output sense data.
-
-  @retval EFI_SUCCESS              The command executed successfully.
-  @retval EFI_DEVICE_ERROR         A device error occurred while attempting to send SCSI Request Packet.
-  @retval EFI_TIMEOUT              A timeout occurred while waiting for the SCSI Request Packet to execute.
-
-**/
-EFI_STATUS
-UfsPeimInquiry (
-  IN     UFS_PEIM_HC_PRIVATE_DATA     *Private,
-  IN     UINTN                        Lun,
-     OUT VOID                         *Inquiry,
-     OUT UINT32                       *InquiryLength,
-     OUT VOID                         *SenseData,  OPTIONAL
-     OUT UINT8                        *SenseDataLength
-  )
-{
-  UFS_SCSI_REQUEST_PACKET             Packet;
-  UINT8                               Cdb[UFS_SCSI_OP_LENGTH_SIX];
-  EFI_STATUS                          Status;
-
-  ZeroMem (&Packet, sizeof (UFS_SCSI_REQUEST_PACKET));
-  ZeroMem (Cdb, sizeof (Cdb));
 
-  Cdb[0]  = EFI_SCSI_OP_INQUIRY;
-  Cdb[4]  = sizeof (EFI_SCSI_INQUIRY_DATA);
-
-  Packet.Timeout          = UFS_TIMEOUT;
-  Packet.Cdb              = Cdb;
-  Packet.CdbLength        = sizeof (Cdb);
-  Packet.InDataBuffer     = Inquiry;
-  Packet.InTransferLength = *InquiryLength;
-  Packet.DataDirection    = UfsDataIn;
-  Packet.SenseData        = SenseData;
-  Packet.SenseDataLength  = *SenseDataLength;
-
-  Status = UfsExecScsiCmds (Private, (UINT8)Lun, &Packet);
-
-  if (*SenseDataLength != 0) {
-    *SenseDataLength = Packet.SenseDataLength;
-  }
-
-  if (!EFI_ERROR (Status)) {
-    *InquiryLength = Packet.InTransferLength;
-  }
-
-  return Status;
-}
 
 /**
   Execute READ CAPACITY(10) SCSI command on a specific UFS device.
diff --git a/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsHcMem.c b/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsHcMem.c
index d69e6e7227..d334faa0bb 100644
--- a/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsHcMem.c
+++ b/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsHcMem.c
@@ -219,31 +219,7 @@ UfsPeimIsMemBlockEmpty (
   return TRUE;
 }
 
-/**
-  Unlink the memory block from the pool's list.
-
-  @param  Head           The block list head of the memory's pool.
-  @param  BlockToUnlink  The memory block to unlink.
 
-**/
-VOID
-UfsPeimUnlinkMemBlock (
-  IN UFS_PEIM_MEM_BLOCK      *Head,
-  IN UFS_PEIM_MEM_BLOCK      *BlockToUnlink
-  )
-{
-  UFS_PEIM_MEM_BLOCK         *Block;
-
-  ASSERT ((Head != NULL) && (BlockToUnlink != NULL));
-
-  for (Block = Head; Block != NULL; Block = Block->Next) {
-    if (Block->Next == BlockToUnlink) {
-      Block->Next         = BlockToUnlink->Next;
-      BlockToUnlink->Next = NULL;
-      break;
-    }
-  }
-}
 
 /**
   Initialize the memory management pool for the host controller.
diff --git a/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsHci.c b/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsHci.c
index e36ff8c02a..936f25da5e 100644
--- a/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsHci.c
+++ b/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsHci.c
@@ -694,31 +694,7 @@ UfsFindAvailableSlotInTrl (
   return EFI_SUCCESS;
 }
 
-/**
-  Find out available slot in task management transfer list of a UFS device.
-
-  @param[in]  Private       The pointer to the UFS_PEIM_HC_PRIVATE_DATA data structure.
-  @param[out] Slot          The available slot.
-
-  @retval EFI_SUCCESS       The available slot was found successfully.
-
-**/
-EFI_STATUS
-UfsFindAvailableSlotInTmrl (
-  IN     UFS_PEIM_HC_PRIVATE_DATA     *Private,
-     OUT UINT8                        *Slot
-  )
-{
-  ASSERT ((Private != NULL) && (Slot != NULL));
-
-  //
-  // The simplest algo to always use slot 0.
-  // TODO: enhance it to support async transfer with multiple slot.
-  //
-  *Slot = 0;
 
-  return EFI_SUCCESS;
-}
 
 /**
   Start specified slot in transfer list of a UFS device.
@@ -897,113 +873,7 @@ Exit:
   return Status;
 }
 
-/**
-  Read or write specified attribute of a UFS device.
-
-  @param[in]      Private       The pointer to the UFS_PEIM_HC_PRIVATE_DATA data structure.
-  @param[in]      Read          The boolean variable to show r/w direction.
-  @param[in]      AttrId        The ID of Attribute.
-  @param[in]      Index         The Index of Attribute.
-  @param[in]      Selector      The Selector of Attribute.
-  @param[in, out] Attributes    The value of Attribute to be read or written.
-
-  @retval EFI_SUCCESS           The Attribute was read/written successfully.
-  @retval EFI_DEVICE_ERROR      A device error occurred while attempting to r/w the Attribute.
-  @retval EFI_TIMEOUT           A timeout occurred while waiting for the completion of r/w the Attribute.
-
-**/
-EFI_STATUS
-UfsRwAttributes (
-  IN     UFS_PEIM_HC_PRIVATE_DATA     *Private,
-  IN     BOOLEAN                      Read,
-  IN     UINT8                        AttrId,
-  IN     UINT8                        Index,
-  IN     UINT8                        Selector,
-  IN OUT UINT32                       *Attributes
-  )
-{
-  EFI_STATUS                           Status;
-  UFS_DEVICE_MANAGEMENT_REQUEST_PACKET Packet;
-  UINT8                                Slot;
-  UTP_TRD                              *Trd;
-  UINTN                                Address;
-  UTP_QUERY_RESP_UPIU                  *QueryResp;
-  UINT8                                *CmdDescBase;
-  UINT32                               CmdDescSize;
-  UINT32                               ReturnData;
-
-  ZeroMem (&Packet, sizeof (UFS_DEVICE_MANAGEMENT_REQUEST_PACKET));
-
-  if (Read) {
-    Packet.DataDirection     = UfsDataIn;
-    Packet.Opcode            = UtpQueryFuncOpcodeRdAttr;
-  } else {
-    Packet.DataDirection     = UfsDataOut;
-    Packet.Opcode            = UtpQueryFuncOpcodeWrAttr;
-  }
-  Packet.DescId              = AttrId;
-  Packet.Index               = Index;
-  Packet.Selector            = Selector;
-  Packet.Timeout             = UFS_TIMEOUT;
-
-  //
-  // Find out which slot of transfer request list is available.
-  //
-  Status = UfsFindAvailableSlotInTrl (Private, &Slot);
-  if (EFI_ERROR (Status)) {
-    return Status;
-  }
-
-  Trd = ((UTP_TRD*)Private->UtpTrlBase) + Slot;
-  //
-  // Fill transfer request descriptor to this slot.
-  //
-  Status = UfsCreateDMCommandDesc (Private, &Packet, Trd);
-  if (EFI_ERROR (Status)) {
-    return Status;
-  }
-
-  //
-  // Check the transfer request result.
-  //
-  CmdDescBase = (UINT8 *)(UINTN)(LShiftU64 ((UINT64)Trd->UcdBaU, 32) | LShiftU64 ((UINT64)Trd->UcdBa, 7));
-  QueryResp   = (UTP_QUERY_RESP_UPIU*)(CmdDescBase + Trd->RuO * sizeof (UINT32));
-  CmdDescSize = Trd->RuO * sizeof (UINT32) + Trd->RuL * sizeof (UINT32);
-
-  //
-  // Start to execute the transfer request.
-  //
-  UfsStartExecCmd (Private, Slot);
-
-  //
-  // Wait for the completion of the transfer request.
-  //
-  Address = Private->UfsHcBase + UFS_HC_UTRLDBR_OFFSET;
-  Status = UfsWaitMemSet (Address, BIT0 << Slot, 0, Packet.Timeout);
-  if (EFI_ERROR (Status)) {
-    goto Exit;
-  }
-
-  if (QueryResp->QueryResp != 0) {
-    DumpQueryResponseResult (QueryResp->QueryResp);
-    Status = EFI_DEVICE_ERROR;
-    goto Exit;
-  }
-
-  if (Trd->Ocs == 0) {
-    ReturnData = QueryResp->Tsf.Value;
-    SwapLittleEndianToBigEndian ((UINT8*)&ReturnData, sizeof (UINT32));
-    *Attributes = ReturnData;
-  } else {
-    Status = EFI_DEVICE_ERROR;
-  }
-
-Exit:
-  UfsStopExecCmd (Private, Slot);
-  UfsPeimFreeMem (Private->Pool, CmdDescBase, CmdDescSize);
 
-  return Status;
-}
 
 /**
   Read or write specified flag of a UFS device.
@@ -1143,57 +1013,7 @@ UfsSetFlag (
   return Status;
 }
 
-/**
-  Clear specified flag to 0 on a UFS device.
-
-  @param[in]  Private           The pointer to the UFS_PEIM_HC_PRIVATE_DATA data structure.
-  @param[in]  FlagId            The ID of flag to be cleared.
-
-  @retval EFI_SUCCESS           The flag was cleared successfully.
-  @retval EFI_DEVICE_ERROR      A device error occurred while attempting to clear the flag.
-  @retval EFI_TIMEOUT           A timeout occurred while waiting for the completion of clearing the flag.
-
-**/
-EFI_STATUS
-UfsClearFlag (
-  IN  UFS_PEIM_HC_PRIVATE_DATA     *Private,
-  IN  UINT8                        FlagId
-  )
-{
-  EFI_STATUS             Status;
-  UINT8                  Value;
-
-  Value  = 0;
-  Status = UfsRwFlags (Private, FALSE, FlagId, &Value);
-
-  return Status;
-}
-
-/**
-  Read specified flag from a UFS device.
-
-  @param[in]  Private           The pointer to the UFS_PEIM_HC_PRIVATE_DATA data structure.
-  @param[in]  FlagId            The ID of flag to be read.
-  @param[out] Value             The flag's value.
-
-  @retval EFI_SUCCESS           The flag was read successfully.
-  @retval EFI_DEVICE_ERROR      A device error occurred while attempting to read the flag.
-  @retval EFI_TIMEOUT           A timeout occurred while waiting for the completion of reading the flag.
-
-**/
-EFI_STATUS
-UfsReadFlag (
-  IN     UFS_PEIM_HC_PRIVATE_DATA     *Private,
-  IN     UINT8                        FlagId,
-     OUT UINT8                        *Value
-  )
-{
-  EFI_STATUS                           Status;
-
-  Status = UfsRwFlags (Private, TRUE, FlagId, Value);
 
-  return Status;
-}
 
 /**
   Sends NOP IN cmd to a UFS device for initialization process request.
diff --git a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c
index e868c8c07e..5756f637fd 100644
--- a/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c
+++ b/MdeModulePkg/Bus/Ufs/UfsPassThruDxe/UfsPassThruHci.c
@@ -753,31 +753,6 @@ UfsFindAvailableSlotInTrl (
   return EFI_NOT_READY;
 }
 
-/**
-  Find out available slot in task management transfer list of a UFS device.
-
-  @param[in]  Private       The pointer to the UFS_PASS_THRU_PRIVATE_DATA data structure.
-  @param[out] Slot          The available slot.
-
-  @retval EFI_SUCCESS       The available slot was found successfully.
-
-**/
-EFI_STATUS
-UfsFindAvailableSlotInTmrl (
-  IN     UFS_PASS_THRU_PRIVATE_DATA   *Private,
-     OUT UINT8                        *Slot
-  )
-{
-  ASSERT ((Private != NULL) && (Slot != NULL));
-
-  //
-  // The simplest algo to always use slot 0.
-  // TODO: enhance it to support async transfer with multiple slot.
-  //
-  *Slot = 0;
-
-  return EFI_SUCCESS;
-}
 
 /**
   Start specified slot in transfer list of a UFS device.
@@ -1229,31 +1204,7 @@ UfsSetFlag (
   return Status;
 }
 
-/**
-  Clear specified flag to 0 on a UFS device.
-
-  @param[in]  Private           The pointer to the UFS_PASS_THRU_PRIVATE_DATA data structure.
-  @param[in]  FlagId            The ID of flag to be cleared.
-
-  @retval EFI_SUCCESS           The flag was cleared successfully.
-  @retval EFI_DEVICE_ERROR      A device error occurred while attempting to clear the flag.
-  @retval EFI_TIMEOUT           A timeout occurred while waiting for the completion of clearing the flag.
-
-**/
-EFI_STATUS
-UfsClearFlag (
-  IN  UFS_PASS_THRU_PRIVATE_DATA   *Private,
-  IN  UINT8                        FlagId
-  )
-{
-  EFI_STATUS             Status;
-  UINT8                  Value;
-
-  Value  = 0;
-  Status = UfsRwFlags (Private, FALSE, FlagId, &Value);
 
-  return Status;
-}
 
 /**
   Read specified flag from a UFS device.
diff --git a/MdeModulePkg/Bus/Usb/UsbBotPei/PeiUsbLib.c b/MdeModulePkg/Bus/Usb/UsbBotPei/PeiUsbLib.c
index 4f20c71144..cd765c40c5 100644
--- a/MdeModulePkg/Bus/Usb/UsbBotPei/PeiUsbLib.c
+++ b/MdeModulePkg/Bus/Usb/UsbBotPei/PeiUsbLib.c
@@ -17,92 +17,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include "UsbPeim.h"
 #include "PeiUsbLib.h"
 
-/**
-  Get a given usb descriptor.
-
-  @param  PeiServices        General-purpose services that are available to every PEIM.
-  @param  UsbIoPpi           Indicates the PEI_USB_IO_PPI instance.
-  @param  Value              Request Value.
-  @param  Index              Request Index.
-  @param  DescriptorLength   Request descriptor Length.
-  @param  Descriptor         Request descriptor.
-
-
-  @retval EFI_SUCCESS        Usb descriptor is obtained successfully.
-  @retval EFI_DEVICE_ERROR   Cannot get the usb descriptor due to a hardware error.
-  @retval Others             Other failure occurs.
-
-**/
-EFI_STATUS
-PeiUsbGetDescriptor (
-  IN  EFI_PEI_SERVICES         **PeiServices,
-  IN  PEI_USB_IO_PPI           *UsbIoPpi,
-  IN  UINT16                   Value,
-  IN  UINT16                   Index,
-  IN  UINT16                   DescriptorLength,
-  OUT VOID                     *Descriptor
-  )
-{
-  EFI_USB_DEVICE_REQUEST  DevReq;
-
-  ASSERT (UsbIoPpi != NULL);
-
-  DevReq.RequestType  = USB_DEV_GET_DESCRIPTOR_REQ_TYPE;
-  DevReq.Request      = USB_DEV_GET_DESCRIPTOR;
-  DevReq.Value        = Value;
-  DevReq.Index        = Index;
-  DevReq.Length       = DescriptorLength;
-
-  return UsbIoPpi->UsbControlTransfer (
-                     PeiServices,
-                     UsbIoPpi,
-                     &DevReq,
-                     EfiUsbDataIn,
-                     PcdGet32 (PcdUsbTransferTimeoutValue),
-                     Descriptor,
-                     DescriptorLength
-                     );
-}
-
-/**
-  Set a usb device with a specified address.
-
-  @param  PeiServices        General-purpose services that are available to every PEIM.
-  @param  UsbIoPpi           Indicates the PEI_USB_IO_PPI instance.
-  @param  AddressValue       The address to assign.
-
-  @retval EFI_SUCCESS        Usb device address is set successfully.
-  @retval EFI_DEVICE_ERROR   Cannot set the usb address due to a hardware error.
-  @retval Others             Other failure occurs.
-
-**/
-EFI_STATUS
-PeiUsbSetDeviceAddress (
-  IN EFI_PEI_SERVICES         **PeiServices,
-  IN PEI_USB_IO_PPI           *UsbIoPpi,
-  IN UINT16                   AddressValue
-  )
-{
-  EFI_USB_DEVICE_REQUEST  DevReq;
-
-  ASSERT (UsbIoPpi != NULL);
-
-  DevReq.RequestType  = USB_DEV_SET_ADDRESS_REQ_TYPE;
-  DevReq.Request      = USB_DEV_SET_ADDRESS;
-  DevReq.Value        = AddressValue;
-  DevReq.Index        = 0;
-  DevReq.Length       = 0;
-
-  return UsbIoPpi->UsbControlTransfer (
-                     PeiServices,
-                     UsbIoPpi,
-                     &DevReq,
-                     EfiUsbNoData,
-                     PcdGet32 (PcdUsbTransferTimeoutValue),
-                     NULL,
-                     0
-                     );
-}
 
 /**
   Clear a given usb feature.
@@ -161,40 +75,6 @@ PeiUsbClearDeviceFeature (
                      );
 }
 
-/**
-  Configure a usb device to Configuration 1.
-
-  @param  PeiServices        General-purpose services that are available to every PEIM.
-  @param  UsbIoPpi           Indicates the PEI_USB_IO_PPI instance.
-
-  @retval EFI_SUCCESS       Usb device is set to use Configuration 1 successfully.
-  @retval EFI_DEVICE_ERROR  Cannot set the usb device due to a hardware error.
-  @retval Others            Other failure occurs.
-
-**/
-EFI_STATUS
-PeiUsbSetConfiguration (
-  IN EFI_PEI_SERVICES         **PeiServices,
-  IN PEI_USB_IO_PPI           *UsbIoPpi
-  )
-{
-  EFI_USB_DEVICE_REQUEST  DevReq;
-  ZeroMem (&DevReq, sizeof (EFI_USB_DEVICE_REQUEST));
-
-  DevReq.RequestType  = USB_DEV_SET_CONFIGURATION_REQ_TYPE;
-  DevReq.Request      = USB_DEV_SET_CONFIGURATION;
-  DevReq.Value        = 1;
-
-  return UsbIoPpi->UsbControlTransfer (
-                     PeiServices,
-                     UsbIoPpi,
-                     &DevReq,
-                     EfiUsbNoData,
-                     PcdGet32 (PcdUsbTransferTimeoutValue),
-                     NULL,
-                     0
-                     );
-}
 
 /**
   Clear Endpoint Halt.
@@ -258,74 +138,4 @@ PeiUsbClearEndpointHalt (
   return Status;
 }
 
-/**
-  Judge if the port is connected with a usb device or not.
-
-  @param  PortStatus  The usb port status gotten.
 
-  @retval TRUE        A usb device is connected with the port.
-  @retval FALSE       No usb device is connected with the port.
-
-**/
-BOOLEAN
-IsPortConnect (
-  IN UINT16  PortStatus
-  )
-{
-  //
-  // return the bit 0 value of PortStatus
-  //
-  if ((PortStatus & USB_PORT_STAT_CONNECTION) != 0) {
-    return TRUE;
-  } else {
-    return FALSE;
-  }
-}
-
-/**
-  Judge if the port is connected with a low-speed usb device or not.
-
-  @param  PortStatus  The usb port status gotten.
-
-  @retval TRUE        A low-speed usb device is connected with the port.
-  @retval FALSE       No low-speed usb device is connected with the port.
-
-**/
-BOOLEAN
-IsPortLowSpeedDeviceAttached (
-  IN UINT16  PortStatus
-  )
-{
-  //
-  // return the bit 9 value of PortStatus
-  //
-  if ((PortStatus & USB_PORT_STAT_LOW_SPEED) != 0) {
-    return TRUE;
-  } else {
-    return FALSE;
-  }
-}
-
-/**
-  Judge if the port is in "connection change" status or not.
-
-  @param  PortChangeStatus  The usb port change status gotten.
-
-  @retval TRUE              The port is in "connection change" status.
-  @retval FALSE             The port is NOT in "connection change" status.
-
-**/
-BOOLEAN
-IsPortConnectChange (
-  IN UINT16  PortChangeStatus
-  )
-{
-  //
-  // return the bit 0 value of PortChangeStatus
-  //
-  if ((PortChangeStatus & USB_PORT_STAT_C_CONNECTION) != 0) {
-    return TRUE;
-  } else {
-    return FALSE;
-  }
-}
diff --git a/MdeModulePkg/Bus/Usb/UsbBotPei/PeiUsbLib.h b/MdeModulePkg/Bus/Usb/UsbBotPei/PeiUsbLib.h
index 6d39b764eb..a160146cae 100644
--- a/MdeModulePkg/Bus/Usb/UsbBotPei/PeiUsbLib.h
+++ b/MdeModulePkg/Bus/Usb/UsbBotPei/PeiUsbLib.h
@@ -100,50 +100,6 @@ typedef enum {
   EfiUsbEndpoint
 } EFI_USB_RECIPIENT;
 
-/**
-  Get a given usb descriptor.
-
-  @param  PeiServices        General-purpose services that are available to every PEIM.
-  @param  UsbIoPpi           Indicates the PEI_USB_IO_PPI instance.
-  @param  Value              Request Value.
-  @param  Index              Request Index.
-  @param  DescriptorLength   Request descriptor Length.
-  @param  Descriptor         Request descriptor.
-
-
-  @retval EFI_SUCCESS       Usb descriptor is obtained successfully.
-  @retval EFI_DEVICE_ERROR  Cannot get the usb descriptor due to a hardware error.
-  @retval Others            Other failure occurs.
-
-**/
-EFI_STATUS
-PeiUsbGetDescriptor (
-  IN  EFI_PEI_SERVICES         **PeiServices,
-  IN  PEI_USB_IO_PPI           *UsbIoPpi,
-  IN  UINT16                   Value,
-  IN  UINT16                   Index,
-  IN  UINT16                   DescriptorLength,
-  OUT VOID                     *Descriptor
-  );
-
-/**
-  Set a usb device with a specified address.
-
-  @param  PeiServices        General-purpose services that are available to every PEIM.
-  @param  UsbIoPpi           Indicates the PEI_USB_IO_PPI instance.
-  @param  AddressValue       The address to assign.
-
-  @retval EFI_SUCCESS        Usb device address is set successfully.
-  @retval EFI_DEVICE_ERROR   Cannot set the usb address due to a hardware error.
-  @retval Others             Other failure occurs.
-
-**/
-EFI_STATUS
-PeiUsbSetDeviceAddress (
-  IN EFI_PEI_SERVICES         **PeiServices,
-  IN PEI_USB_IO_PPI           *UsbIoPpi,
-  IN UINT16                   AddressValue
-  );
 
 /**
   Clear a given usb feature.
@@ -168,22 +124,6 @@ PeiUsbClearDeviceFeature (
   IN UINT16                   Target
   );
 
-/**
-  Configure a usb device to Configuration 1.
-
-  @param  PeiServices        General-purpose services that are available to every PEIM.
-  @param  UsbIoPpi           Indicates the PEI_USB_IO_PPI instance.
-
-  @retval EFI_SUCCESS        Usb device is set to use Configuration 1 successfully.
-  @retval EFI_DEVICE_ERROR   Cannot set the usb device due to a hardware error.
-  @retval Others             Other failure occurs.
-
-**/
-EFI_STATUS
-PeiUsbSetConfiguration (
-  IN EFI_PEI_SERVICES         **PeiServices,
-  IN PEI_USB_IO_PPI           *UsbIoPpi
-  );
 
 /**
   Clear Endpoint Halt.
@@ -204,45 +144,7 @@ PeiUsbClearEndpointHalt (
   IN UINT8                    EndpointAddress
   );
 
-/**
-  Judge if the port is connected with a usb device or not.
-
-  @param  PortStatus  The usb port status gotten.
-
-  @retval TRUE        A usb device is connected with the port.
-  @retval FALSE       No usb device is connected with the port.
-
-**/
-BOOLEAN
-IsPortConnect (
-  IN UINT16  PortStatus
-  );
-
-/**
-  Judge if the port is connected with a low-speed usb device or not.
-
-  @param  PortStatus  The usb port status gotten.
 
-  @retval TRUE        A low-speed usb device is connected with the port.
-  @retval FALSE       No low-speed usb device is connected with the port.
 
-**/
-BOOLEAN
-IsPortLowSpeedDeviceAttached (
-  IN UINT16  PortStatus
-  );
 
-/**
-  Judge if the port is in "connection change" status or not.
-
-  @param  PortChangeStatus  The usb port change status gotten.
-
-  @retval TRUE              The port is in "connection change" status.
-  @retval FALSE             The port is NOT in "connection change" status.
-
-**/
-BOOLEAN
-IsPortConnectChange (
-  IN UINT16  PortChangeStatus
-  );
 #endif
diff --git a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbHub.c b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbHub.c
index 2ce5726e63..fdb3276a82 100644
--- a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbHub.c
+++ b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbHub.c
@@ -317,74 +317,6 @@ UsbHubCtrlGetPortStatus (
 }
 
 
-/**
-  Usb hub control transfer to reset the TT (Transaction Transaltor).
-
-  @param  HubDev                The hub device.
-  @param  Port                  The port of the hub.
-
-  @retval EFI_SUCCESS           The TT of the hub is reset.
-  @retval Others                Failed to reset the port.
-
-**/
-EFI_STATUS
-UsbHubCtrlResetTT (
-  IN  USB_DEVICE          *HubDev,
-  IN  UINT8               Port
-  )
-{
-  EFI_STATUS              Status;
-
-  Status = UsbCtrlRequest (
-             HubDev,
-             EfiUsbNoData,
-             USB_REQ_TYPE_CLASS,
-             USB_HUB_TARGET_HUB,
-             USB_HUB_REQ_RESET_TT,
-             0,
-             (UINT16) (Port + 1),
-             NULL,
-             0
-             );
-
-  return Status;
-}
-
-
-/**
-  Usb hub control transfer to set the hub feature.
-
-  @param  HubDev                The hub device.
-  @param  Feature               The feature to set.
-
-  @retval EFI_SUCESS            The feature is set for the hub.
-  @retval Others                Failed to set the feature.
-
-**/
-EFI_STATUS
-UsbHubCtrlSetHubFeature (
-  IN  USB_DEVICE          *HubDev,
-  IN  UINT8               Feature
-  )
-{
-  EFI_STATUS              Status;
-
-  Status = UsbCtrlRequest (
-             HubDev,
-             EfiUsbNoData,
-             USB_REQ_TYPE_CLASS,
-             USB_HUB_TARGET_HUB,
-             USB_HUB_REQ_SET_FEATURE,
-             Feature,
-             0,
-             NULL,
-             0
-             );
-
-  return Status;
-}
-
-
 /**
   Usb hub control transfer to set the port feature.
 
diff --git a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbUtility.c b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbUtility.c
index e9b5fefb9a..e405edfd4a 100644
--- a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbUtility.c
+++ b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbUtility.c
@@ -90,90 +90,12 @@ UsbHcGetCapability (
 }
 
 
-/**
-  Reset the host controller.
 
-  @param  UsbBus                The usb bus driver.
-  @param  Attributes            The reset type, only global reset is used by this driver.
 
-  @retval EFI_SUCCESS           The reset operation succeeded.
-  @retval EFI_INVALID_PARAMETER Attributes is not valid.
-  @retval EFI_UNSUPPOURTED      The type of reset specified by Attributes is
-                                not currently supported by the host controller.
-  @retval EFI_DEVICE_ERROR      Host controller isn't halted to reset.
-**/
-EFI_STATUS
-UsbHcReset (
-  IN USB_BUS              *UsbBus,
-  IN UINT16               Attributes
-  )
-{
-  EFI_STATUS              Status;
 
-  if (UsbBus->Usb2Hc != NULL) {
-    Status = UsbBus->Usb2Hc->Reset (UsbBus->Usb2Hc, Attributes);
-  } else {
-    Status = UsbBus->UsbHc->Reset (UsbBus->UsbHc, Attributes);
-  }
 
-  return Status;
-}
 
 
-/**
-  Get the current operation state of the host controller.
-
-  @param  UsbBus           The USB bus driver.
-  @param  State            The host controller operation state.
-
-  @retval EFI_SUCCESS      The operation state is returned in State.
-  @retval Others           Failed to get the host controller state.
-
-**/
-EFI_STATUS
-UsbHcGetState (
-  IN  USB_BUS             *UsbBus,
-  OUT EFI_USB_HC_STATE    *State
-  )
-{
-  EFI_STATUS              Status;
-
-  if (UsbBus->Usb2Hc != NULL) {
-    Status = UsbBus->Usb2Hc->GetState (UsbBus->Usb2Hc, State);
-  } else {
-    Status = UsbBus->UsbHc->GetState (UsbBus->UsbHc, State);
-  }
-
-  return Status;
-}
-
-
-/**
-  Set the host controller operation state.
-
-  @param  UsbBus           The USB bus driver.
-  @param  State            The state to set.
-
-  @retval EFI_SUCCESS      The host controller is now working at State.
-  @retval Others           Failed to set operation state.
-
-**/
-EFI_STATUS
-UsbHcSetState (
-  IN USB_BUS              *UsbBus,
-  IN EFI_USB_HC_STATE     State
-  )
-{
-  EFI_STATUS              Status;
-
-  if (UsbBus->Usb2Hc != NULL) {
-    Status = UsbBus->Usb2Hc->SetState (UsbBus->Usb2Hc, State);
-  } else {
-    Status = UsbBus->UsbHc->SetState (UsbBus->UsbHc, State);
-  }
-
-  return Status;
-}
 
 
 /**
@@ -563,78 +485,10 @@ UsbHcSyncInterruptTransfer (
 }
 
 
-/**
-  Execute a synchronous Isochronous USB transfer.
-
-  @param  UsbBus           The USB bus driver.
-  @param  DevAddr          The target device address.
-  @param  EpAddr           The target endpoint address, with direction encoded in
-                           bit 7.
-  @param  DevSpeed         The device's speed.
-  @param  MaxPacket        The endpoint's max packet size.
-  @param  BufferNum        The number of data buffer.
-  @param  Data             Array of pointers to data buffer.
-  @param  DataLength       The length of data buffer.
-  @param  Translator       The transaction translator for low/full speed device.
-  @param  UsbResult        The result of USB execution.
-
-  @retval EFI_UNSUPPORTED  The isochronous transfer isn't supported now.
-
-**/
-EFI_STATUS
-UsbHcIsochronousTransfer (
-  IN  USB_BUS                             *UsbBus,
-  IN  UINT8                               DevAddr,
-  IN  UINT8                               EpAddr,
-  IN  UINT8                               DevSpeed,
-  IN  UINTN                               MaxPacket,
-  IN  UINT8                               BufferNum,
-  IN  OUT VOID                            *Data[EFI_USB_MAX_ISO_BUFFER_NUM],
-  IN  UINTN                               DataLength,
-  IN  EFI_USB2_HC_TRANSACTION_TRANSLATOR  *Translator,
-  OUT UINT32                              *UsbResult
-  )
-{
-  return EFI_UNSUPPORTED;
-}
 
 
-/**
-  Queue an asynchronous isochronous transfer.
 
-  @param  UsbBus           The USB bus driver.
-  @param  DevAddr          The target device address.
-  @param  EpAddr           The target endpoint address, with direction encoded in
-                           bit 7.
-  @param  DevSpeed         The device's speed.
-  @param  MaxPacket        The endpoint's max packet size.
-  @param  BufferNum        The number of data buffer.
-  @param  Data             Array of pointers to data buffer.
-  @param  DataLength       The length of data buffer.
-  @param  Translator       The transaction translator for low/full speed device.
-  @param  Callback         The function to call when data is transferred.
-  @param  Context          The context to the callback function.
-
-  @retval EFI_UNSUPPORTED  The asynchronous isochronous transfer isn't supported.
 
-**/
-EFI_STATUS
-UsbHcAsyncIsochronousTransfer (
-  IN  USB_BUS                             *UsbBus,
-  IN  UINT8                               DevAddr,
-  IN  UINT8                               EpAddr,
-  IN  UINT8                               DevSpeed,
-  IN  UINTN                               MaxPacket,
-  IN  UINT8                               BufferNum,
-  IN OUT VOID                             *Data[EFI_USB_MAX_ISO_BUFFER_NUM],
-  IN  UINTN                               DataLength,
-  IN  EFI_USB2_HC_TRANSACTION_TRANSLATOR  *Translator,
-  IN  EFI_ASYNC_USB_TRANSFER_CALLBACK     Callback,
-  IN  VOID                                *Context
-  )
-{
-  return EFI_UNSUPPORTED;
-}
 
 
 /**
diff --git a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbUtility.h b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbUtility.h
index 26709caa36..ef19e77c40 100644
--- a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbUtility.h
+++ b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbUtility.h
@@ -36,55 +36,6 @@ UsbHcGetCapability (
   OUT UINT8               *Is64BitCapable
   );
 
-/**
-  Reset the host controller.
-
-  @param  UsbBus                The usb bus driver.
-  @param  Attributes            The reset type, only global reset is used by this driver.
-
-  @retval EFI_SUCCESS           The reset operation succeeded.
-  @retval EFI_INVALID_PARAMETER Attributes is not valid.
-  @retval EFI_UNSUPPOURTED      The type of reset specified by Attributes is
-                                not currently supported by the host controller.
-  @retval EFI_DEVICE_ERROR      Host controller isn't halted to reset.
-**/
-EFI_STATUS
-UsbHcReset (
-  IN USB_BUS              *UsbBus,
-  IN UINT16               Attributes
-  );
-
-/**
-  Get the current operation state of the host controller.
-
-  @param  UsbBus           The USB bus driver.
-  @param  State            The host controller operation state.
-
-  @retval EFI_SUCCESS      The operation state is returned in State.
-  @retval Others           Failed to get the host controller state.
-
-**/
-EFI_STATUS
-UsbHcGetState (
-  IN  USB_BUS             *UsbBus,
-  OUT EFI_USB_HC_STATE    *State
-  );
-
-/**
-  Set the host controller operation state.
-
-  @param  UsbBus           The USB bus driver.
-  @param  State            The state to set.
-
-  @retval EFI_SUCCESS      The host controller is now working at State.
-  @retval Others           Failed to set operation state.
-
-**/
-EFI_STATUS
-UsbHcSetState (
-  IN  USB_BUS             *UsbBus,
-  IN EFI_USB_HC_STATE     State
-  );
 
 /**
   Get the root hub port state.
@@ -286,71 +237,6 @@ UsbHcSyncInterruptTransfer (
   OUT UINT32                              *UsbResult
   );
 
-/**
-  Execute a synchronous Isochronous USB transfer.
-
-  @param  UsbBus           The USB bus driver.
-  @param  DevAddr          The target device address.
-  @param  EpAddr           The target endpoint address, with direction encoded in
-                           bit 7.
-  @param  DevSpeed         The device's speed.
-  @param  MaxPacket        The endpoint's max packet size.
-  @param  BufferNum        The number of data buffer.
-  @param  Data             Array of pointers to data buffer.
-  @param  DataLength       The length of data buffer.
-  @param  Translator       The transaction translator for low/full speed device.
-  @param  UsbResult        The result of USB execution.
-
-  @retval EFI_UNSUPPORTED  The isochronous transfer isn't supported now.
-
-**/
-EFI_STATUS
-UsbHcIsochronousTransfer (
-  IN  USB_BUS                             *UsbBus,
-  IN  UINT8                               DevAddr,
-  IN  UINT8                               EpAddr,
-  IN  UINT8                               DevSpeed,
-  IN  UINTN                               MaxPacket,
-  IN  UINT8                               BufferNum,
-  IN  OUT VOID                            *Data[EFI_USB_MAX_ISO_BUFFER_NUM],
-  IN  UINTN                               DataLength,
-  IN  EFI_USB2_HC_TRANSACTION_TRANSLATOR  *Translator,
-  OUT UINT32                              *UsbResult
-  );
-
-/**
-  Queue an asynchronous isochronous transfer.
-
-  @param  UsbBus           The USB bus driver.
-  @param  DevAddr          The target device address.
-  @param  EpAddr           The target endpoint address, with direction encoded in
-                           bit 7.
-  @param  DevSpeed         The device's speed.
-  @param  MaxPacket        The endpoint's max packet size.
-  @param  BufferNum        The number of data buffer.
-  @param  Data             Array of pointers to data buffer.
-  @param  DataLength       The length of data buffer.
-  @param  Translator       The transaction translator for low/full speed device.
-  @param  Callback         The function to call when data is transferred.
-  @param  Context          The context to the callback function.
-
-  @retval EFI_UNSUPPORTED  The asynchronous isochronous transfer isn't supported.
-
-**/
-EFI_STATUS
-UsbHcAsyncIsochronousTransfer (
-  IN  USB_BUS                             *UsbBus,
-  IN  UINT8                               DevAddr,
-  IN  UINT8                               EpAddr,
-  IN  UINT8                               DevSpeed,
-  IN  UINTN                               MaxPacket,
-  IN  UINT8                               BufferNum,
-  IN OUT VOID                             *Data[EFI_USB_MAX_ISO_BUFFER_NUM],
-  IN  UINTN                               DataLength,
-  IN  EFI_USB2_HC_TRANSACTION_TRANSLATOR  *Translator,
-  IN  EFI_ASYNC_USB_TRANSFER_CALLBACK     Callback,
-  IN  VOID                                *Context
-  );
 
 /**
   Open the USB host controller protocol BY_CHILD.
diff --git a/MdeModulePkg/Bus/Usb/UsbBusPei/HubPeim.c b/MdeModulePkg/Bus/Usb/UsbBusPei/HubPeim.c
index 806602511c..5607c65b13 100644
--- a/MdeModulePkg/Bus/Usb/UsbBusPei/HubPeim.c
+++ b/MdeModulePkg/Bus/Usb/UsbBusPei/HubPeim.c
@@ -193,46 +193,7 @@ PeiHubGetHubStatus (
                      );
 }
 
-/**
-  Set specified feature to a given hub.
-
-  @param  PeiServices   General-purpose services that are available to every PEIM.
-  @param  UsbIoPpi      Indicates the PEI_USB_IO_PPI instance.
-  @param  Value         New feature value.
-
-  @retval EFI_SUCCESS       Port feature is set successfully.
-  @retval EFI_DEVICE_ERROR  Cannot set the port feature due to a hardware error.
-  @retval Others            Other failure occurs.
-
-**/
-EFI_STATUS
-PeiHubSetHubFeature (
-  IN EFI_PEI_SERVICES    **PeiServices,
-  IN PEI_USB_IO_PPI      *UsbIoPpi,
-  IN UINT8               Value
-  )
-{
-  EFI_USB_DEVICE_REQUEST      DeviceRequest;
 
-  ZeroMem (&DeviceRequest, sizeof (EFI_USB_DEVICE_REQUEST));
-
-  //
-  // Fill Device request packet
-  //
-  DeviceRequest.RequestType = USB_HUB_SET_HUB_FEATURE_REQ_TYPE;
-  DeviceRequest.Request     = USB_HUB_SET_HUB_FEATURE;
-  DeviceRequest.Value       = Value;
-
-  return UsbIoPpi->UsbControlTransfer (
-                     PeiServices,
-                     UsbIoPpi,
-                     &DeviceRequest,
-                     EfiUsbNoData,
-                     PcdGet32 (PcdUsbTransferTimeoutValue),
-                     NULL,
-                     0
-                     );
-}
 
 /**
   Clear specified feature on a given hub.
diff --git a/MdeModulePkg/Bus/Usb/UsbBusPei/HubPeim.h b/MdeModulePkg/Bus/Usb/UsbBusPei/HubPeim.h
index 385a14ec0d..d21057c349 100644
--- a/MdeModulePkg/Bus/Usb/UsbBusPei/HubPeim.h
+++ b/MdeModulePkg/Bus/Usb/UsbBusPei/HubPeim.h
@@ -145,24 +145,6 @@ PeiHubSetPortFeature (
   IN  UINT8                 Value
   );
 
-/**
-  Set specified feature to a given hub.
-
-  @param  PeiServices   General-purpose services that are available to every PEIM.
-  @param  UsbIoPpi      Indicates the PEI_USB_IO_PPI instance.
-  @param  Value         New feature value.
-
-  @retval EFI_SUCCESS       Port feature is set successfully.
-  @retval EFI_DEVICE_ERROR  Cannot set the port feature due to a hardware error.
-  @retval Others            Other failure occurs.
-
-**/
-EFI_STATUS
-PeiHubSetHubFeature (
-  IN EFI_PEI_SERVICES       **PeiServices,
-  IN PEI_USB_IO_PPI         *UsbIoPpi,
-  IN  UINT8                 Value
-  );
 
 /**
   Get a given hub status.
diff --git a/MdeModulePkg/Bus/Usb/UsbBusPei/PeiUsbLib.c b/MdeModulePkg/Bus/Usb/UsbBusPei/PeiUsbLib.c
index c5e599e2f7..73a163e7a0 100644
--- a/MdeModulePkg/Bus/Usb/UsbBusPei/PeiUsbLib.c
+++ b/MdeModulePkg/Bus/Usb/UsbBusPei/PeiUsbLib.c
@@ -104,62 +104,7 @@ PeiUsbSetDeviceAddress (
                      );
 }
 
-/**
-  Clear a given usb feature.
-
-  @param  PeiServices       General-purpose services that are available to every PEIM.
-  @param  UsbIoPpi          Indicates the PEI_USB_IO_PPI instance.
-  @param  Recipient         The recipient of ClearFeature Request, should be one of Device/Interface/Endpoint.
-  @param  Value             Request Value.
-  @param  Target            Request Index.
-
-  @retval EFI_SUCCESS       Usb feature is cleared successfully.
-  @retval EFI_DEVICE_ERROR  Cannot clear the usb feature due to a hardware error.
-  @retval Others            Other failure occurs.
 
-**/
-EFI_STATUS
-PeiUsbClearDeviceFeature (
-  IN EFI_PEI_SERVICES         **PeiServices,
-  IN PEI_USB_IO_PPI           *UsbIoPpi,
-  IN EFI_USB_RECIPIENT        Recipient,
-  IN UINT16                   Value,
-  IN UINT16                   Target
-  )
-{
-  EFI_USB_DEVICE_REQUEST  DevReq;
-
-  ASSERT (UsbIoPpi != NULL);
-
-  switch (Recipient) {
-  case EfiUsbDevice:
-    DevReq.RequestType = USB_DEV_CLEAR_FEATURE_REQ_TYPE_D;
-    break;
-
-  case EfiUsbInterface:
-    DevReq.RequestType = USB_DEV_CLEAR_FEATURE_REQ_TYPE_I;
-    break;
-
-  case EfiUsbEndpoint:
-    DevReq.RequestType = USB_DEV_CLEAR_FEATURE_REQ_TYPE_E;
-    break;
-  }
-
-  DevReq.Request      = USB_DEV_CLEAR_FEATURE;
-  DevReq.Value        = Value;
-  DevReq.Index        = Target;
-  DevReq.Length       = 0;
-
-  return UsbIoPpi->UsbControlTransfer (
-                     PeiServices,
-                     UsbIoPpi,
-                     &DevReq,
-                     EfiUsbNoData,
-                     PcdGet32 (PcdUsbTransferTimeoutValue),
-                     NULL,
-                     0
-                     );
-}
 
 /**
   Configure a usb device to Configuration 1.
@@ -244,26 +189,4 @@ PeiUsbGetDeviceSpeed (
   }
 }
 
-/**
-  Judge if the port is in "connection change" status or not.
-
-  @param  PortChangeStatus  The usb port change status gotten.
-
-  @retval TRUE              The port is in "connection change" status.
-  @retval FALSE             The port is NOT in "connection change" status.
 
-**/
-BOOLEAN
-IsPortConnectChange (
-  IN UINT16  PortChangeStatus
-  )
-{
-  //
-  // return the bit 0 value of PortChangeStatus
-  //
-  if ((PortChangeStatus & USB_PORT_STAT_C_CONNECTION) != 0) {
-    return TRUE;
-  } else {
-    return FALSE;
-  }
-}
diff --git a/MdeModulePkg/Bus/Usb/UsbBusPei/PeiUsbLib.h b/MdeModulePkg/Bus/Usb/UsbBusPei/PeiUsbLib.h
index 35f47a35ec..e3afee6e84 100644
--- a/MdeModulePkg/Bus/Usb/UsbBusPei/PeiUsbLib.h
+++ b/MdeModulePkg/Bus/Usb/UsbBusPei/PeiUsbLib.h
@@ -148,28 +148,6 @@ PeiUsbSetDeviceAddress (
   IN UINT16                   AddressValue
   );
 
-/**
-  Clear a given usb feature.
-
-  @param  PeiServices       General-purpose services that are available to every PEIM.
-  @param  UsbIoPpi          Indicates the PEI_USB_IO_PPI instance.
-  @param  Recipient         The recipient of ClearFeature Request, should be one of Device/Interface/Endpoint.
-  @param  Value             Request Value.
-  @param  Target            Request Index.
-
-  @retval EFI_SUCCESS       Usb feature is cleared successfully.
-  @retval EFI_DEVICE_ERROR  Cannot clear the usb feature due to a hardware error.
-  @retval Others            Other failure occurs.
-
-**/
-EFI_STATUS
-PeiUsbClearDeviceFeature (
-  IN EFI_PEI_SERVICES         **PeiServices,
-  IN PEI_USB_IO_PPI           *UsbIoPpi,
-  IN EFI_USB_RECIPIENT        Recipient,
-  IN UINT16                   Value,
-  IN UINT16                   Target
-  );
 
 /**
   Configure a usb device to Configuration 1.
@@ -215,17 +193,4 @@ PeiUsbGetDeviceSpeed (
   IN UINT16 PortStatus
   );
 
-/**
-  Judge if the port is in "connection change" status or not.
-
-  @param  PortChangeStatus  The usb port change status gotten.
-
-  @retval TRUE              The port is in "connection change" status.
-  @retval FALSE             The port is NOT in "connection change" status.
-
-**/
-BOOLEAN
-IsPortConnectChange (
-  IN UINT16  PortChangeStatus
-  );
 #endif
diff --git a/MdeModulePkg/Core/Dxe/DxeMain.h b/MdeModulePkg/Core/Dxe/DxeMain.h
index 7ec82388a3..8f0b28d095 100644
--- a/MdeModulePkg/Core/Dxe/DxeMain.h
+++ b/MdeModulePkg/Core/Dxe/DxeMain.h
@@ -2178,19 +2178,6 @@ CoreDisplayDiscoveredNotDispatched (
   );
 
 
-/**
-  Place holder function until all the Boot Services and Runtime Services are
-  available.
-
-  @return EFI_NOT_AVAILABLE_YET
-
-**/
-EFI_STATUS
-EFIAPI
-CoreEfiNotAvailableYetArg0 (
-  VOID
-  );
-
 
 /**
   Place holder function until all the Boot Services and Runtime Services are
diff --git a/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c b/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c
index fc46022c3c..312131f1c2 100644
--- a/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c
+++ b/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c
@@ -560,29 +560,6 @@ DxeMain (
 
 
 
-/**
-  Place holder function until all the Boot Services and Runtime Services are
-  available.
-
-  @return EFI_NOT_AVAILABLE_YET
-
-**/
-EFI_STATUS
-EFIAPI
-CoreEfiNotAvailableYetArg0 (
-  VOID
-  )
-{
-  //
-  // This function should never be executed.  If it does, then the architectural protocols
-  // have not been designed correctly.  The CpuBreakpoint () is commented out for now until the
-  // DXE Core and all the Architectural Protocols are complete.
-  //
-
-  return EFI_NOT_AVAILABLE_YET;
-}
-
-
 /**
   Place holder function until all the Boot Services and Runtime Services are
   available.
diff --git a/MdeModulePkg/Core/Dxe/Mem/HeapGuard.c b/MdeModulePkg/Core/Dxe/Mem/HeapGuard.c
index 447c56bb11..663f969c0d 100644
--- a/MdeModulePkg/Core/Dxe/Mem/HeapGuard.c
+++ b/MdeModulePkg/Core/Dxe/Mem/HeapGuard.c
@@ -443,51 +443,6 @@ GetGuardMapBit (
   return 0;
 }
 
-/**
-  Set the bit in bitmap table for the given address.
-
-  @param[in]  Address     The address to set for.
-
-  @return VOID.
-**/
-VOID
-EFIAPI
-SetGuardMapBit (
-  IN EFI_PHYSICAL_ADDRESS    Address
-  )
-{
-  UINT64        *GuardMap;
-  UINT64        BitMask;
-
-  FindGuardedMemoryMap (Address, TRUE, &GuardMap);
-  if (GuardMap != NULL) {
-    BitMask = LShiftU64 (1, GUARDED_HEAP_MAP_ENTRY_BIT_INDEX (Address));
-    *GuardMap |= BitMask;
-  }
-}
-
-/**
-  Clear the bit in bitmap table for the given address.
-
-  @param[in]  Address     The address to clear for.
-
-  @return VOID.
-**/
-VOID
-EFIAPI
-ClearGuardMapBit (
-  IN EFI_PHYSICAL_ADDRESS    Address
-  )
-{
-  UINT64        *GuardMap;
-  UINT64        BitMask;
-
-  FindGuardedMemoryMap (Address, TRUE, &GuardMap);
-  if (GuardMap != NULL) {
-    BitMask = LShiftU64 (1, GUARDED_HEAP_MAP_ENTRY_BIT_INDEX (Address));
-    *GuardMap &= ~BitMask;
-  }
-}
 
 /**
   Check to see if the page at the given address is a Guard page or not.
@@ -514,39 +469,6 @@ IsGuardPage (
   return ((BitMap == BIT0) || (BitMap == BIT2) || (BitMap == (BIT2 | BIT0)));
 }
 
-/**
-  Check to see if the page at the given address is a head Guard page or not.
-
-  @param[in]  Address     The address to check for
-
-  @return TRUE  The page at Address is a head Guard page
-  @return FALSE The page at Address is not a head Guard page
-**/
-BOOLEAN
-EFIAPI
-IsHeadGuard (
-  IN EFI_PHYSICAL_ADDRESS    Address
-  )
-{
-  return (GetGuardedMemoryBits (Address, 2) == BIT1);
-}
-
-/**
-  Check to see if the page at the given address is a tail Guard page or not.
-
-  @param[in]  Address     The address to check for.
-
-  @return TRUE  The page at Address is a tail Guard page.
-  @return FALSE The page at Address is not a tail Guard page.
-**/
-BOOLEAN
-EFIAPI
-IsTailGuard (
-  IN EFI_PHYSICAL_ADDRESS    Address
-  )
-{
-  return (GetGuardedMemoryBits (Address - EFI_PAGE_SIZE, 2) == BIT0);
-}
 
 /**
   Check to see if the page at the given address is guarded or not.
diff --git a/MdeModulePkg/Core/PiSmmCore/HeapGuard.c b/MdeModulePkg/Core/PiSmmCore/HeapGuard.c
index d9e54b96cb..f7ae9ae286 100644
--- a/MdeModulePkg/Core/PiSmmCore/HeapGuard.c
+++ b/MdeModulePkg/Core/PiSmmCore/HeapGuard.c
@@ -455,51 +455,6 @@ GetGuardMapBit (
   return 0;
 }
 
-/**
-  Set the bit in bitmap table for the given address.
-
-  @param[in]  Address     The address to set for.
-
-  @return VOID.
-**/
-VOID
-EFIAPI
-SetGuardMapBit (
-  IN EFI_PHYSICAL_ADDRESS    Address
-  )
-{
-  UINT64        *GuardMap;
-  UINT64        BitMask;
-
-  FindGuardedMemoryMap (Address, TRUE, &GuardMap);
-  if (GuardMap != NULL) {
-    BitMask = LShiftU64 (1, GUARDED_HEAP_MAP_ENTRY_BIT_INDEX (Address));
-    *GuardMap |= BitMask;
-  }
-}
-
-/**
-  Clear the bit in bitmap table for the given address.
-
-  @param[in]  Address     The address to clear for.
-
-  @return VOID.
-**/
-VOID
-EFIAPI
-ClearGuardMapBit (
-  IN EFI_PHYSICAL_ADDRESS    Address
-  )
-{
-  UINT64        *GuardMap;
-  UINT64        BitMask;
-
-  FindGuardedMemoryMap (Address, TRUE, &GuardMap);
-  if (GuardMap != NULL) {
-    BitMask = LShiftU64 (1, GUARDED_HEAP_MAP_ENTRY_BIT_INDEX (Address));
-    *GuardMap &= ~BitMask;
-  }
-}
 
 /**
   Check to see if the page at the given address is a Guard page or not.
@@ -526,39 +481,7 @@ IsGuardPage (
   return ((BitMap == BIT0) || (BitMap == BIT2) || (BitMap == (BIT2 | BIT0)));
 }
 
-/**
-  Check to see if the page at the given address is a head Guard page or not.
 
-  @param[in]  Address     The address to check for.
-
-  @return TRUE  The page at Address is a head Guard page.
-  @return FALSE The page at Address is not a head Guard page.
-**/
-BOOLEAN
-EFIAPI
-IsHeadGuard (
-  IN EFI_PHYSICAL_ADDRESS    Address
-  )
-{
-  return (GetGuardedMemoryBits (Address, 2) == BIT1);
-}
-
-/**
-  Check to see if the page at the given address is a tail Guard page or not.
-
-  @param[in]  Address     The address to check for.
-
-  @return TRUE  The page at Address is a tail Guard page.
-  @return FALSE The page at Address is not a tail Guard page.
-**/
-BOOLEAN
-EFIAPI
-IsTailGuard (
-  IN EFI_PHYSICAL_ADDRESS    Address
-  )
-{
-  return (GetGuardedMemoryBits (Address - EFI_PAGE_SIZE, 2) == BIT0);
-}
 
 /**
   Check to see if the page at the given address is guarded or not.
@@ -864,66 +787,7 @@ UnsetGuardForMemory (
   ClearGuardedMemoryBits(Memory, NumberOfPages);
 }
 
-/**
-  Adjust address of free memory according to existing and/or required Guard.
-
-  This function will check if there're existing Guard pages of adjacent
-  memory blocks, and try to use it as the Guard page of the memory to be
-  allocated.
 
-  @param[in]  Start           Start address of free memory block.
-  @param[in]  Size            Size of free memory block.
-  @param[in]  SizeRequested   Size of memory to allocate.
-
-  @return The end address of memory block found.
-  @return 0 if no enough space for the required size of memory and its Guard.
-**/
-UINT64
-AdjustMemoryS (
-  IN UINT64                  Start,
-  IN UINT64                  Size,
-  IN UINT64                  SizeRequested
-  )
-{
-  UINT64  Target;
-
-  //
-  // UEFI spec requires that allocated pool must be 8-byte aligned. If it's
-  // indicated to put the pool near the Tail Guard, we need extra bytes to
-  // make sure alignment of the returned pool address.
-  //
-  if ((PcdGet8 (PcdHeapGuardPropertyMask) & BIT7) == 0) {
-    SizeRequested = ALIGN_VALUE(SizeRequested, 8);
-  }
-
-  Target = Start + Size - SizeRequested;
-  ASSERT (Target >= Start);
-  if (Target == 0) {
-    return 0;
-  }
-
-  if (!IsGuardPage (Start + Size)) {
-    // No Guard at tail to share. One more page is needed.
-    Target -= EFI_PAGES_TO_SIZE (1);
-  }
-
-  // Out of range?
-  if (Target < Start) {
-    return 0;
-  }
-
-  // At the edge?
-  if (Target == Start) {
-    if (!IsGuardPage (Target - EFI_PAGES_TO_SIZE (1))) {
-      // No enough space for a new head Guard if no Guard at head to share.
-      return 0;
-    }
-  }
-
-  // OK, we have enough pages for memory and its Guards. Return the End of the
-  // free space.
-  return Target + SizeRequested - 1;
-}
 
 /**
   Adjust the start address and number of pages to free according to Guard.
@@ -1049,36 +913,6 @@ AdjustMemoryF (
   *NumberOfPages  = PagesToFree;
 }
 
-/**
-  Adjust the base and number of pages to really allocate according to Guard.
-
-  @param[in,out]  Memory          Base address of free memory.
-  @param[in,out]  NumberOfPages   Size of memory to allocate.
-
-  @return VOID.
-**/
-VOID
-AdjustMemoryA (
-  IN OUT EFI_PHYSICAL_ADDRESS    *Memory,
-  IN OUT UINTN                   *NumberOfPages
-  )
-{
-  //
-  // FindFreePages() has already taken the Guard into account. It's safe to
-  // adjust the start address and/or number of pages here, to make sure that
-  // the Guards are also "allocated".
-  //
-  if (!IsGuardPage (*Memory + EFI_PAGES_TO_SIZE (*NumberOfPages))) {
-    // No tail Guard, add one.
-    *NumberOfPages += 1;
-  }
-
-  if (!IsGuardPage (*Memory - EFI_PAGE_SIZE)) {
-    // No head Guard, add one.
-    *Memory        -= EFI_PAGE_SIZE;
-    *NumberOfPages += 1;
-  }
-}
 
 /**
   Adjust the pool head position to make sure the Guard page is adjavent to
diff --git a/MdeModulePkg/Core/PiSmmCore/MemoryAttributesTable.c b/MdeModulePkg/Core/PiSmmCore/MemoryAttributesTable.c
index 36ccf65fa3..1682d0f9e4 100644
--- a/MdeModulePkg/Core/PiSmmCore/MemoryAttributesTable.c
+++ b/MdeModulePkg/Core/PiSmmCore/MemoryAttributesTable.c
@@ -114,34 +114,6 @@ EfiSizeToPages (
   return RShiftU64 (Size, EFI_PAGE_SHIFT) + ((((UINTN)Size) & EFI_PAGE_MASK) ? 1 : 0);
 }
 
-/**
-  Check the consistency of Smm memory attributes table.
-
-  @param[in] MemoryAttributesTable  PI SMM memory attributes table
-**/
-VOID
-SmmMemoryAttributesTableConsistencyCheck (
-  IN EDKII_PI_SMM_MEMORY_ATTRIBUTES_TABLE *MemoryAttributesTable
-  )
-{
-  EFI_MEMORY_DESCRIPTOR                     *MemoryMap;
-  UINTN                                     MemoryMapEntryCount;
-  UINTN                                     DescriptorSize;
-  UINTN                                     Index;
-  UINT64                                    Address;
-
-  Address = 0;
-  MemoryMapEntryCount = MemoryAttributesTable->NumberOfEntries;
-  DescriptorSize = MemoryAttributesTable->DescriptorSize;
-  MemoryMap = (EFI_MEMORY_DESCRIPTOR *)(MemoryAttributesTable + 1);
-  for (Index = 0; Index < MemoryMapEntryCount; Index++) {
-    if (Address != 0) {
-      ASSERT (Address == MemoryMap->PhysicalStart);
-    }
-    Address = MemoryMap->PhysicalStart + EfiPagesToSize(MemoryMap->NumberOfPages);
-    MemoryMap = NEXT_MEMORY_DESCRIPTOR(MemoryMap, DescriptorSize);
-  }
-}
 
 /**
   Sort memory map entries based upon PhysicalStart, from low to high.
@@ -1224,85 +1196,6 @@ Finish:
   return ;
 }
 
-/**
-  Find image record according to image base and size.
-
-  @param[in]  ImageBase    Base of PE image
-  @param[in]  ImageSize    Size of PE image
-
-  @return image record
-**/
-STATIC
-IMAGE_PROPERTIES_RECORD *
-FindImageRecord (
-  IN EFI_PHYSICAL_ADDRESS  ImageBase,
-  IN UINT64                ImageSize
-  )
-{
-  IMAGE_PROPERTIES_RECORD    *ImageRecord;
-  LIST_ENTRY                 *ImageRecordLink;
-  LIST_ENTRY                 *ImageRecordList;
-
-  ImageRecordList = &mImagePropertiesPrivateData.ImageRecordList;
-
-  for (ImageRecordLink = ImageRecordList->ForwardLink;
-       ImageRecordLink != ImageRecordList;
-       ImageRecordLink = ImageRecordLink->ForwardLink) {
-    ImageRecord = CR (
-                    ImageRecordLink,
-                    IMAGE_PROPERTIES_RECORD,
-                    Link,
-                    IMAGE_PROPERTIES_RECORD_SIGNATURE
-                    );
-
-    if ((ImageBase == ImageRecord->ImageBase) &&
-        (ImageSize == ImageRecord->ImageSize)) {
-      return ImageRecord;
-    }
-  }
-
-  return NULL;
-}
-
-/**
-  Remove Image record.
-
-  @param[in]  DriverEntry    Driver information
-**/
-VOID
-SmmRemoveImageRecord (
-  IN EFI_SMM_DRIVER_ENTRY  *DriverEntry
-  )
-{
-  IMAGE_PROPERTIES_RECORD              *ImageRecord;
-  LIST_ENTRY                           *CodeSegmentListHead;
-  IMAGE_PROPERTIES_RECORD_CODE_SECTION *ImageRecordCodeSection;
-
-  DEBUG ((DEBUG_VERBOSE, "SMM RemoveImageRecord - 0x%x\n", DriverEntry));
-  DEBUG ((DEBUG_VERBOSE, "SMM RemoveImageRecord - 0x%016lx - 0x%016lx\n", DriverEntry->ImageBuffer, DriverEntry->NumberOfPage));
-
-  ImageRecord = FindImageRecord (DriverEntry->ImageBuffer, EfiPagesToSize(DriverEntry->NumberOfPage));
-  if (ImageRecord == NULL) {
-    DEBUG ((DEBUG_ERROR, "SMM !!!!!!!! ImageRecord not found !!!!!!!!\n"));
-    return ;
-  }
-
-  CodeSegmentListHead = &ImageRecord->CodeSegmentList;
-  while (!IsListEmpty (CodeSegmentListHead)) {
-    ImageRecordCodeSection = CR (
-                               CodeSegmentListHead->ForwardLink,
-                               IMAGE_PROPERTIES_RECORD_CODE_SECTION,
-                               Link,
-                               IMAGE_PROPERTIES_RECORD_CODE_SECTION_SIGNATURE
-                               );
-    RemoveEntryList (&ImageRecordCodeSection->Link);
-    FreePool (ImageRecordCodeSection);
-  }
-
-  RemoveEntryList (&ImageRecord->Link);
-  FreePool (ImageRecord);
-  mImagePropertiesPrivateData.ImageRecordCount--;
-}
 
 /**
   Publish MemoryAttributesTable to SMM configuration table.
@@ -1386,30 +1279,6 @@ PublishMemoryAttributesTable (
   ASSERT_EFI_ERROR (Status);
 }
 
-/**
-  This function returns if image is inside SMRAM.
-
-  @param[in] LoadedImage LoadedImage protocol instance for an image.
-
-  @retval TRUE  the image is inside SMRAM.
-  @retval FALSE the image is outside SMRAM.
-**/
-BOOLEAN
-IsImageInsideSmram (
-  IN EFI_LOADED_IMAGE_PROTOCOL   *LoadedImage
-  )
-{
-  UINTN  Index;
-
-  for (Index = 0; Index < mFullSmramRangeCount; Index++) {
-    if ((mFullSmramRanges[Index].PhysicalStart <= (UINTN)LoadedImage->ImageBase)&&
-        (mFullSmramRanges[Index].PhysicalStart + mFullSmramRanges[Index].PhysicalSize >= (UINTN)LoadedImage->ImageBase + LoadedImage->ImageSize)) {
-      return TRUE;
-    }
-  }
-
-  return FALSE;
-}
 
 /**
   This function installs all SMM image record information.
diff --git a/MdeModulePkg/Core/PiSmmCore/Page.c b/MdeModulePkg/Core/PiSmmCore/Page.c
index 3699af7424..cd7d7ece0c 100644
--- a/MdeModulePkg/Core/PiSmmCore/Page.c
+++ b/MdeModulePkg/Core/PiSmmCore/Page.c
@@ -451,128 +451,7 @@ GetSmmMemoryMapEntryCount (
   return Count;
 }
 
-/**
-  Dump Smm memory map entry.
-**/
-VOID
-DumpSmmMemoryMapEntry (
-  VOID
-  )
-{
-  LIST_ENTRY               *Link;
-  MEMORY_MAP               *Entry;
-  EFI_PHYSICAL_ADDRESS     Last;
-
-  Last = 0;
-  DEBUG ((DEBUG_INFO, "DumpSmmMemoryMapEntry:\n"));
-  Link = gMemoryMap.ForwardLink;
-  while (Link != &gMemoryMap) {
-    Entry = CR (Link, MEMORY_MAP, Link, MEMORY_MAP_SIGNATURE);
-    Link  = Link->ForwardLink;
-
-    if ((Last != 0) && (Last != (UINT64)-1)) {
-      if (Last + 1 != Entry->Start) {
-        Last = (UINT64)-1;
-      } else {
-        Last = Entry->End;
-      }
-    } else if (Last == 0) {
-      Last = Entry->End;
-    }
-
-    DEBUG ((DEBUG_INFO, "Entry (Link - 0x%x)\n", &Entry->Link));
-    DEBUG ((DEBUG_INFO, "  Signature         - 0x%x\n", Entry->Signature));
-    DEBUG ((DEBUG_INFO, "  Link.ForwardLink  - 0x%x\n", Entry->Link.ForwardLink));
-    DEBUG ((DEBUG_INFO, "  Link.BackLink     - 0x%x\n", Entry->Link.BackLink));
-    DEBUG ((DEBUG_INFO, "  Type              - 0x%x\n", Entry->Type));
-    DEBUG ((DEBUG_INFO, "  Start             - 0x%016lx\n", Entry->Start));
-    DEBUG ((DEBUG_INFO, "  End               - 0x%016lx\n", Entry->End));
-  }
-
-  ASSERT (Last != (UINT64)-1);
-}
-
-/**
-  Dump Smm memory map.
-**/
-VOID
-DumpSmmMemoryMap (
-  VOID
-  )
-{
-  LIST_ENTRY      *Node;
-  FREE_PAGE_LIST  *Pages;
-
-  DEBUG ((DEBUG_INFO, "DumpSmmMemoryMap\n"));
-
-  Pages = NULL;
-  Node = mSmmMemoryMap.ForwardLink;
-  while (Node != &mSmmMemoryMap) {
-    Pages = BASE_CR (Node, FREE_PAGE_LIST, Link);
-    DEBUG ((DEBUG_INFO, "Pages - 0x%x\n", Pages));
-    DEBUG ((DEBUG_INFO, "Pages->NumberOfPages - 0x%x\n", Pages->NumberOfPages));
-    Node = Node->ForwardLink;
-  }
-}
 
-/**
-  Check if a Smm base~length is in Smm memory map.
-
-  @param[in] Base   The base address of Smm memory to be checked.
-  @param[in] Length THe length of Smm memory to be checked.
-
-  @retval TRUE  Smm base~length is in smm memory map.
-  @retval FALSE Smm base~length is in smm memory map.
-**/
-BOOLEAN
-SmmMemoryMapConsistencyCheckRange (
-  IN EFI_PHYSICAL_ADDRESS Base,
-  IN UINTN                Length
-  )
-{
-  LIST_ENTRY               *Link;
-  MEMORY_MAP               *Entry;
-  BOOLEAN                  Result;
-
-  Result = FALSE;
-  Link = gMemoryMap.ForwardLink;
-  while (Link != &gMemoryMap) {
-    Entry = CR (Link, MEMORY_MAP, Link, MEMORY_MAP_SIGNATURE);
-    Link  = Link->ForwardLink;
-
-    if (Entry->Type != EfiConventionalMemory) {
-      continue;
-    }
-    if (Entry->Start == Base && Entry->End == Base + Length - 1) {
-      Result = TRUE;
-      break;
-    }
-  }
-
-  return Result;
-}
-
-/**
-  Check the consistency of Smm memory map.
-**/
-VOID
-SmmMemoryMapConsistencyCheck (
-  VOID
-  )
-{
-  LIST_ENTRY      *Node;
-  FREE_PAGE_LIST  *Pages;
-  BOOLEAN         Result;
-
-  Pages = NULL;
-  Node = mSmmMemoryMap.ForwardLink;
-  while (Node != &mSmmMemoryMap) {
-    Pages = BASE_CR (Node, FREE_PAGE_LIST, Link);
-    Result = SmmMemoryMapConsistencyCheckRange ((EFI_PHYSICAL_ADDRESS)(UINTN)Pages, (UINTN)EFI_PAGES_TO_SIZE(Pages->NumberOfPages));
-    ASSERT (Result);
-    Node = Node->ForwardLink;
-  }
-}
 
 /**
   Internal Function. Allocate n pages from given free page node.
diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
index a4543fc8de..84808d55a0 100644
--- a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h
@@ -1131,18 +1131,6 @@ IsUnicodeFiFoFull (
   TERMINAL_DEV  *TerminalDevice
   );
 
-/**
-  Count Unicode FIFO buffer.
-
-  @param  TerminalDevice       Terminal driver private structure
-
-  @return The count in bytes of Unicode FIFO.
-
-**/
-UINT8
-UnicodeFiFoGetKeyCount (
-  TERMINAL_DEV    *TerminalDevice
-  );
 
 /**
   Translate raw data into Unicode (according to different encode), and
diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c
index 80c4f6b483..33f9b6e585 100644
--- a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c
+++ b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c
@@ -1200,31 +1200,6 @@ IsUnicodeFiFoFull (
   return FALSE;
 }
 
-/**
-  Count Unicode FIFO buffer.
-
-  @param  TerminalDevice       Terminal driver private structure
-
-  @return The count in bytes of Unicode FIFO.
-
-**/
-UINT8
-UnicodeFiFoGetKeyCount (
-  TERMINAL_DEV    *TerminalDevice
-  )
-{
-  UINT8 Tail;
-  UINT8 Head;
-
-  Tail  = TerminalDevice->UnicodeFiFo->Tail;
-  Head  = TerminalDevice->UnicodeFiFo->Head;
-
-  if (Tail >= Head) {
-    return (UINT8) (Tail - Head);
-  } else {
-    return (UINT8) (Tail + FIFO_MAX_NUMBER + 1 - Head);
-  }
-}
 
 /**
   Update the Unicode characters from a terminal input device into EFI Keys FIFO.
diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c
index c778cd92f8..39e1811e69 100644
--- a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c
+++ b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c
@@ -3590,53 +3590,6 @@ Done:
   return Status;
 }
 
-/**
-  Get Data buffer size based on data type.
-
-  @param      ValueType             The input data type.
-
-  @retval     The data buffer size for the input type.
-**/
-UINT16
-GetStorageWidth (
-  IN UINT8       ValueType
-  )
-{
-  UINT16         StorageWidth;
-
-  switch (ValueType) {
-  case EFI_IFR_NUMERIC_SIZE_1:
-  case EFI_IFR_TYPE_BOOLEAN:
-    StorageWidth = (UINT16) sizeof (UINT8);
-    break;
-
-  case EFI_IFR_NUMERIC_SIZE_2:
-    StorageWidth = (UINT16) sizeof (UINT16);
-    break;
-
-  case EFI_IFR_NUMERIC_SIZE_4:
-    StorageWidth = (UINT16) sizeof (UINT32);
-    break;
-
-  case EFI_IFR_NUMERIC_SIZE_8:
-    StorageWidth = (UINT16) sizeof (UINT64);
-    break;
-
-  case EFI_IFR_TYPE_TIME:
-    StorageWidth = (UINT16) sizeof (EFI_IFR_TIME);
-    break;
-
-  case EFI_IFR_TYPE_DATE:
-    StorageWidth = (UINT16) sizeof (EFI_IFR_DATE);
-    break;
-
-  default:
-    StorageWidth = 0;
-    break;
-  }
-
-  return StorageWidth;
-}
 
 /**
   Update the default value in the block data which is used as bit var store.
diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiProto.c b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiProto.c
index 9fb848080a..b4a5c2d024 100644
--- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiProto.c
+++ b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiProto.c
@@ -1738,37 +1738,6 @@ IScsiDelTcb (
   FreePool (Tcb);
 }
 
-/**
-  Find the task control block by the initator task tag.
-
-  @param[in]  TcbList         The tcb list.
-  @param[in]  InitiatorTaskTag The initiator task tag.
-
-  @return The task control block found.
-**/
-ISCSI_TCB *
-IScsiFindTcbByITT (
-  IN LIST_ENTRY      *TcbList,
-  IN UINT32          InitiatorTaskTag
-  )
-{
-  ISCSI_TCB       *Tcb;
-  LIST_ENTRY      *Entry;
-
-  Tcb = NULL;
-
-  NET_LIST_FOR_EACH (Entry, TcbList) {
-    Tcb = NET_LIST_USER_STRUCT (Entry, ISCSI_TCB, Link);
-
-    if (Tcb->InitiatorTaskTag == InitiatorTaskTag) {
-      break;
-    }
-
-    Tcb = NULL;
-  }
-
-  return Tcb;
-}
 
 /**
   Create a data segment, pad it and calculate the CRC if needed.
diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c
index 043341d6e9..c19a72730e 100644
--- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c
+++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c
@@ -1628,22 +1628,6 @@ Ip4Config2InitIfInfo (
   CopyMem (&IfInfo->HwAddress, &IpSb->SnpMode.CurrentAddress, IfInfo->HwAddressSize);
 }
 
-/**
-  The event handle routine when DHCPv4 process is finished or is updated.
-
-  @param[in]     Event         Not used.
-  @param[in]     Context       The pointer to the IP4 configuration instance data.
-
-**/
-VOID
-EFIAPI
-Ip4Config2OnDhcp4Event (
-  IN EFI_EVENT  Event,
-  IN VOID       *Context
-  )
-{
-  return ;
-}
 
 
 /**
diff --git a/MdeModulePkg/Universal/Network/Tcp4Dxe/SockImpl.c b/MdeModulePkg/Universal/Network/Tcp4Dxe/SockImpl.c
index 0476077c20..adb5aa35cd 100644
--- a/MdeModulePkg/Universal/Network/Tcp4Dxe/SockImpl.c
+++ b/MdeModulePkg/Universal/Network/Tcp4Dxe/SockImpl.c
@@ -1107,41 +1107,6 @@ SockGetFreeSpace (
 }
 
 
-/**
-  Signal the receive token with the specific error or
-  set socket error code after error is received.
-
-  @param  Sock                  Pointer to the socket.
-  @param  Error                 The error code received.
-
-**/
-VOID
-SockRcvdErr (
-  IN OUT SOCKET       *Sock,
-  IN     EFI_STATUS   Error
-  )
-{
-  SOCK_TOKEN  *SockToken;
-
-  if (!IsListEmpty (&Sock->RcvTokenList)) {
-
-    SockToken = NET_LIST_HEAD (
-                  &Sock->RcvTokenList,
-                  SOCK_TOKEN,
-                  TokenList
-                  );
-
-    RemoveEntryList (&SockToken->TokenList);
-
-    SIGNAL_TOKEN (SockToken->Token, Error);
-
-    FreePool (SockToken);
-  } else {
-
-    SOCK_ERROR (Sock, Error);
-  }
-}
-
 
 /**
   Called by the low layer protocol to indicate that there will be no more data
diff --git a/MdeModulePkg/Universal/Network/Tcp4Dxe/SockInterface.c b/MdeModulePkg/Universal/Network/Tcp4Dxe/SockInterface.c
index 6dbabc4e51..cd20b8bcb2 100644
--- a/MdeModulePkg/Universal/Network/Tcp4Dxe/SockInterface.c
+++ b/MdeModulePkg/Universal/Network/Tcp4Dxe/SockInterface.c
@@ -938,48 +938,7 @@ SockGetMode (
 }
 
 
-/**
-  Configure the low level protocol to join a multicast group for
-  this socket's connection.
-
-  @param  Sock                 Pointer to the socket of the connection to join the
-                               specific multicast group.
-  @param  GroupInfo            Pointer to the multicast group info.
-
-  @retval EFI_SUCCESS          The configuration is done successfully.
-  @retval EFI_ACCESS_DENIED    Failed to get the lock to access the socket.
-  @retval EFI_NOT_STARTED      The socket is not configured.
-
-**/
-EFI_STATUS
-SockGroup (
-  IN SOCKET *Sock,
-  IN VOID   *GroupInfo
-  )
-{
-  EFI_STATUS  Status;
-
-  Status = EfiAcquireLockOrFail (&(Sock->Lock));
-
-  if (EFI_ERROR (Status)) {
 
-    DEBUG ((EFI_D_ERROR, "SockGroup: Get the access for socket"
-      " failed with %r", Status));
-
-    return EFI_ACCESS_DENIED;
-  }
-
-  if (SOCK_IS_UNCONFIGURED (Sock)) {
-    Status = EFI_NOT_STARTED;
-    goto Exit;
-  }
-
-  Status = Sock->ProtoHandler (Sock, SOCK_GROUP, GroupInfo);
-
-Exit:
-  EfiReleaseLock (&(Sock->Lock));
-  return Status;
-}
 
 
 /**
diff --git a/MdeModulePkg/Universal/Network/Tcp4Dxe/Socket.h b/MdeModulePkg/Universal/Network/Tcp4Dxe/Socket.h
index 7ff2fc565e..650a7dd865 100644
--- a/MdeModulePkg/Universal/Network/Tcp4Dxe/Socket.h
+++ b/MdeModulePkg/Universal/Network/Tcp4Dxe/Socket.h
@@ -550,19 +550,6 @@ SockClone (
   IN SOCKET *Sock
   );
 
-/**
-  Signal the receive token with the specific error or
-  set socket error code after error is received.
-
-  @param  Sock                  Pointer to the socket.
-  @param  Error                 The error code received.
-
-**/
-VOID
-SockRcvdErr (
-  IN OUT SOCKET       *Sock,
-  IN     EFI_STATUS   Error
-  );
 
 ///
 /// Proto type of the create callback
@@ -909,25 +896,6 @@ SockGetMode (
   IN OUT VOID   *Mode
   );
 
-/**
-  Configure the low level protocol to join a multicast group for
-  this socket's connection.
-
-  @param  Sock                 Pointer to the socket of the connection to join the
-                               specific multicast group.
-  @param  GroupInfo            Pointer to the multicast group info.
-
-  @retval EFI_SUCCESS          The configuration is done successfully.
-  @retval EFI_ACCESS_DENIED    Failed to get the lock to access the socket.
-  @retval EFI_NOT_STARTED      The socket is not configured.
-
-**/
-EFI_STATUS
-SockGroup (
-  IN SOCKET *Sock,
-  IN VOID   *GroupInfo
-  );
-
 /**
   Add or remove route information in IP route table associated
   with this socket.
diff --git a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Option.c b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Option.c
index 2817b80295..e84310f6c6 100644
--- a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Option.c
+++ b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Option.c
@@ -350,31 +350,3 @@ TcpParseOption (
 }
 
 
-/**
-  Check the segment against PAWS.
-
-  @param  Tcb     Pointer to the TCP_CB of this TCP instance.
-  @param  TSVal   The timestamp value.
-
-  @retval 1       The segment passed the PAWS check.
-  @retval 0       The segment failed to pass the PAWS check.
-
-**/
-UINT32
-TcpPawsOK (
-  IN TCP_CB *Tcb,
-  IN UINT32 TSVal
-  )
-{
-  //
-  // PAWS as defined in RFC1323, buggy...
-  //
-  if (TCP_TIME_LT (TSVal, Tcb->TsRecent) &&
-      TCP_TIME_LT (Tcb->TsRecentAge + TCP_PAWS_24DAY, mTcpTick)) {
-
-    return 0;
-
-  }
-
-  return 1;
-}
diff --git a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Option.h b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Option.h
index 5185aecea8..f9782cb598 100644
--- a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Option.h
+++ b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Option.h
@@ -126,20 +126,5 @@ TcpParseOption (
   IN OUT TCP_OPTION *Option
   );
 
-/**
-  Check the segment against PAWS.
-
-  @param  Tcb     Pointer to the TCP_CB of this TCP instance.
-  @param  TSVal   The timestamp value.
-
-  @retval 1       The segment passed the PAWS check.
-  @retval 0       The segment failed to pass the PAWS check.
-
-**/
-UINT32
-TcpPawsOK (
-  IN TCP_CB *Tcb,
-  IN UINT32 TSVal
-  );
 
 #endif
diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c b/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c
index 3d28e7aa50..042bd4b30d 100644
--- a/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c
+++ b/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c
@@ -452,39 +452,6 @@ IntializeBrowserStorage (
   }
 }
 
-/**
-  Check whether exist device path info in the ConfigHdr string.
-
-  @param  String                 UEFI configuration string
-
-  @retval TRUE                   Device Path exist.
-  @retval FALSE                  Not exist device path info.
-
-**/
-BOOLEAN
-IsDevicePathExist (
-  IN  EFI_STRING                   String
-  )
-{
-  UINTN                    Length;
-
-  for (; (*String != 0 && StrnCmp (String, L"PATH=", StrLen (L"PATH=")) != 0); String++);
-  if (*String == 0) {
-    return FALSE;
-  }
-
-  String += StrLen (L"PATH=");
-  if (*String == 0) {
-    return FALSE;
-  }
-
-  for (Length = 0; *String != 0 && *String != L'&'; String++, Length++);
-  if (((Length + 1) / 2) < sizeof (EFI_DEVICE_PATH_PROTOCOL)) {
-    return FALSE;
-  }
-
-  return TRUE;
-}
 
 /**
   Allocate a FORMSET_STORAGE data structure and insert to FormSet Storage List.
-- 
2.18.0.windows.1



^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-08-06 17:37 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-08-06  7:49 [PATCH] MdeModulePkg: Remove dead code in .c and .h files shenglei
2018-08-06 13:11 ` Laszlo Ersek
2018-08-06 14:54   ` Gao, Liming
2018-08-06 15:37     ` Laszlo Ersek
2018-08-06 15:58       ` Ard Biesheuvel
2018-08-06 17:36   ` Kinney, Michael D

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox