18GUID gUsb3DbgGuid = USB3_DBG_GUID;
52 VOID *RegistrationLocal;
54 ASSERT (Name !=
NULL);
56 ASSERT (NotifyTpl <= TPL_HIGH_LEVEL);
61 Status =
gBS->CreateEvent (
73 Status =
gBS->RegisterProtocolNotify (
103 HostAddress = (VOID *)(
UINTN)Address;
104 Status = PciIo->Map (
131 Instance->UrbIn.Data,
132 XHCI_DEBUG_DEVICE_MAX_PACKET_SIZE * 2 + USB3_DEBUG_PORT_WRITE_MAX_PACKET_SIZE
137 Instance->TransferRingIn.RingSeg0,
143 Instance->TransferRingOut.RingSeg0,
149 Instance->EventRing.EventRingSeg0,
155 Instance->EventRing.ERSTBase,
161 Instance->DebugCapabilityContext,
167 ((
XHC_DC_CONTEXT *)(
UINTN)Instance->DebugCapabilityContext)->DbcInfoContext.String0DescAddress,
168 STRING0_DESC_LEN + MANU_DESC_LEN + PRODUCT_DESC_LEN + SERIAL_DESC_LEN
189 DEBUG ((DEBUG_INFO,
"%a()\n", __func__));
192 ASSERT (Instance !=
NULL);
194 Instance->InNotify =
TRUE;
209 Instance->InNotify =
FALSE;
210 gBS->CloseEvent (Event);
228 Status =
gBS->LocateProtocol (
233 if (!EFI_ERROR (Status) && (IoMmu !=
NULL)) {
256 UINTN PciIoHandleCount;
262 UINTN PciDeviceNumber;
263 UINTN PciFunctionNumber;
268 Status =
gBS->LocateHandleBuffer (
270 &gEfiPciIoProtocolGuid,
275 if (!EFI_ERROR (Status) &&
276 (PciIoHandleBuffer !=
NULL) &&
277 (PciIoHandleCount != 0))
279 for (Index = 0; Index < PciIoHandleCount; Index++) {
280 Status =
gBS->HandleProtocol (
281 PciIoHandleBuffer[Index],
282 &gEfiPciIoProtocolGuid,
286 Status = PciIo->GetLocation (PciIo, &PciSegment, &PciBusNumber, &PciDeviceNumber, &PciFunctionNumber);
288 PciAddress = (UINT32)((PciBusNumber << 20) | (PciDeviceNumber << 15) | (PciFunctionNumber << 12));
289 if (PciAddress ==
PcdGet32 (PcdUsbXhciPciAddress)) {
293 DEBUG ((DEBUG_INFO,
"%a()\n", __func__));
296 ASSERT (Instance !=
NULL);
297 if (Instance->Ready) {
298 Instance->InNotify =
TRUE;
300 Instance->InNotify =
FALSE;
302 if (Instance->FromHob) {
305 &gEfiDxeSmmReadyToLockProtocolGuid,
314 gBS->CloseEvent (Event);
319 gBS->FreePool (PciIoHandleBuffer);
332 if (mUsb3InstanceAddrPtr ==
NULL) {
337 mUsb3InstanceAddrPtr = &mUsb3InstanceAddr;
340 return mUsb3InstanceAddrPtr;
369 Status = PciIo->AllocateBuffer (
377 if (!EFI_ERROR (Status)) {
408 if (mUsb3PciIo !=
NULL) {
415 TmpAddr = 0xFFFFFFFF;
416 Status =
gBS->AllocatePages (
422 if (!EFI_ERROR (Status)) {
423 Buf = (VOID *)(
UINTN)TmpAddr;
454 if (EFI_ERROR (Status) || (AddrPtr ==
NULL)) {
460 Status =
gBS->AllocatePages (
466 if (EFI_ERROR (Status)) {
476 Status =
gBS->InstallConfigurationTable (&gUsb3DbgGuid, AddrPtr);
477 if (EFI_ERROR (Status)) {
482 if (mUsb3InstanceAddrPtr !=
NULL) {
483 *AddrPtr = *mUsb3InstanceAddrPtr;
486 mUsb3InstanceAddrPtr = AddrPtr;
489 ASSERT (Instance !=
NULL);
491 if (Instance->PciIoEvent == 0) {
493 &gEfiPciIoProtocolGuid,
498 if (!EFI_ERROR (Status)) {
525 ASSERT (Instance !=
NULL);
527 if (Instance->PciIoEvent != 0) {
532 Instance->PciIoEvent = 0;
UINTN EFIAPI MicroSecondDelay(IN UINTN MicroSeconds)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
USB3_DEBUG_PORT_HANDLE * GetUsb3DebugPortInstance(VOID)
VOID Usb3MapDmaBuffers(IN USB3_DEBUG_PORT_HANDLE *Instance, IN EFI_PCI_IO_PROTOCOL *PciIo)
VOID * AllocateAlignBuffer(IN UINTN BufferSize)
EDKII_IOMMU_PROTOCOL * Usb3GetIoMmu(VOID)
EFI_PHYSICAL_ADDRESS * GetUsb3DebugPortInstanceAddrPtr(VOID)
VOID Usb3MapOneDmaBuffer(IN EFI_PCI_IO_PROTOCOL *PciIo, IN EFI_PHYSICAL_ADDRESS Address, IN UINTN NumberOfBytes)
VOID EFIAPI Usb3PciIoNotify(IN EFI_EVENT Event, IN VOID *Context)
EFI_STATUS Usb3AllocateDmaBuffer(IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINTN Pages, OUT VOID **Address)
VOID EFIAPI Usb3DxeSmmReadyToLockNotify(IN EFI_EVENT Event, IN VOID *Context)
EFI_STATUS EFIAPI Usb3NamedEventListen(IN CONST EFI_GUID *Name, IN EFI_TPL NotifyTpl, IN EFI_EVENT_NOTIFY NotifyFunction, IN EFI_EVENT *Event)
EFI_STATUS EFIAPI DebugCommunicationUsb3DxeConstructor(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
EFI_STATUS EFIAPI DebugCommunicationUsb3DxeDestructor(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
RETURN_STATUS EFIAPI InitializeUsbDebugHardware(IN USB_DEBUG_PORT_HANDLE *Handle)
#define ASSERT_EFI_ERROR(StatusParameter)
#define DEBUG(Expression)
@ EfiPciIoOperationBusMasterCommonBuffer
#define PcdGet32(TokenName)
EFI_GUID gEdkiiIoMmuProtocolGuid
VOID EFIAPI NotifyFunction(IN EFI_EVENT Event, IN VOID *Context)
UINT64 EFI_PHYSICAL_ADDRESS
#define EFI_PAGES_TO_SIZE(Pages)
#define EFI_SIZE_TO_PAGES(Size)
EFI_STATUS EFIAPI EfiGetSystemConfigurationTable(IN EFI_GUID *TableGuid, OUT VOID **Table)
VOID(EFIAPI * EFI_EVENT_NOTIFY)(IN EFI_EVENT Event, IN VOID *Context)