From f73caa061dada8deb25b84b08af165fc70042865 Mon Sep 17 00:00:00 2001 From: Johannes Anderwald Date: Mon, 30 May 2011 06:55:32 +0000 Subject: [PATCH] [USBOHCI] - More traces to fix isochronous problem - Fix broken assert found by mjmartin svn path=/branches/usb-bringup/; revision=52004 --- drivers/usb/usbohci/hardware.cpp | 33 +++++++++++++++++++++++++---- drivers/usb/usbohci/hardware.h | 5 +++++ drivers/usb/usbohci/usb_queue.cpp | 12 ++++++++++- drivers/usb/usbohci/usb_request.cpp | 11 ++++++++-- 4 files changed, 54 insertions(+), 7 deletions(-) diff --git a/drivers/usb/usbohci/hardware.cpp b/drivers/usb/usbohci/hardware.cpp index e4650c1874e..c21e4c95154 100644 --- a/drivers/usb/usbohci/hardware.cpp +++ b/drivers/usb/usbohci/hardware.cpp @@ -545,12 +545,15 @@ CUSBHardwareDevice::StartController(void) // ASSERT((Control & OHCI_HC_FUNCTIONAL_STATE_MASK) == OHCI_HC_FUNCTIONAL_STATE_OPERATIONAL); ASSERT((Control & OHCI_ENABLE_LIST) == OHCI_ENABLE_LIST); + DPRINT1("Control %x\n", Control); // // get frame interval // - FrameInterval = (READ_REGISTER_ULONG((PULONG)((PUCHAR)m_Base + OHCI_FRAME_INTERVAL_OFFSET)) & OHCI_FRAME_INTERVAL_TOGGLE) ^ OHCI_FRAME_INTERVAL_TOGGLE; + FrameInterval = READ_REGISTER_ULONG((PULONG)((PUCHAR)m_Base + OHCI_FRAME_INTERVAL_OFFSET)); + DPRINT1("FrameInterval %x IntervalValue %x\n", FrameInterval, m_IntervalValue); FrameInterval |= OHCI_FSMPS(m_IntervalValue) | m_IntervalValue; + DPRINT1("FrameInterval %x\n", FrameInterval); // // write frame interval @@ -562,7 +565,7 @@ CUSBHardwareDevice::StartController(void) // Periodic = OHCI_PERIODIC(m_IntervalValue); WRITE_REGISTER_ULONG((PULONG)((PUCHAR)m_Base + OHCI_PERIODIC_START_OFFSET), Periodic); - + DPRINT1("Periodic Start %x\n", Periodic); // // read descriptor @@ -919,6 +922,8 @@ CUSBHardwareDevice::StopController(void) // m_IntervalValue = OHCI_GET_INTERVAL_VALUE(FrameInterval); + DPRINT1("FrameInterval %x Interval %x\n", FrameInterval, m_IntervalValue); + // // now reset controller // @@ -1206,10 +1211,30 @@ VOID CUSBHardwareDevice::GetCurrentFrameNumber( PULONG FrameNumber) { + ULONG Control; + ULONG Number; + + + Number = READ_REGISTER_ULONG((PULONG)((PUCHAR)m_Base + OHCI_FRAME_INTERVAL_NUMBER_OFFSET)); + DPRINT1("FrameNumberInterval %x Frame %x\n", Number, m_HCCA->CurrentFrameNumber); + + // + // remove reserved bits + // + Number &= 0xFFFF; + // // store frame number // - *FrameNumber = m_HCCA->CurrentFrameNumber; + *FrameNumber = Number; + + // + // is the controller started + // + Control = READ_REGISTER_ULONG((PULONG)((PUCHAR)m_Base + OHCI_CONTROL_OFFSET)); + ASSERT((Control & OHCI_ENABLE_LIST) == OHCI_ENABLE_LIST); + + } VOID @@ -1339,7 +1364,7 @@ InterruptServiceRoutine( // // defer processing // - DPRINT("Status %x Acknowledge %x\n", Status, Acknowledge); + DPRINT1("Status %x Acknowledge %x FrameNumber %x\n", Status, Acknowledge, This->m_HCCA->CurrentFrameNumber); KeInsertQueueDpc(&This->m_IntDpcObject, (PVOID)Status, (PVOID)(DoneHead & ~1)); // diff --git a/drivers/usb/usbohci/hardware.h b/drivers/usb/usbohci/hardware.h index 69bcd1978cc..ce6582d6ec8 100644 --- a/drivers/usb/usbohci/hardware.h +++ b/drivers/usb/usbohci/hardware.h @@ -98,6 +98,11 @@ #define OHCI_GET_FS_LARGEST_DATA_PACKET(s) (((s) >> 16) & 0x7fff) #define OHCI_FRAME_INTERVAL_TOGGLE 0x80000000 +// +// frame interval +// +#define OHCI_FRAME_INTERVAL_NUMBER_OFFSET 0x3C + // // periodic start register // diff --git a/drivers/usb/usbohci/usb_queue.cpp b/drivers/usb/usbohci/usb_queue.cpp index af0d8f8c887..a2853fe072f 100644 --- a/drivers/usb/usbohci/usb_queue.cpp +++ b/drivers/usb/usbohci/usb_queue.cpp @@ -278,6 +278,16 @@ CUSBQueue::AddUSBRequest( // CurrentDescriptor = CurrentDescriptor->NextLogicalDescriptor; } + + // + // get current frame number + // + m_Hardware->GetCurrentFrameNumber(&FrameNumber); + + DPRINT1("Hardware 1ms %p Iso %p\n",m_InterruptEndpoints[0], m_IsoHeadEndpointDescriptor); + ASSERT(m_InterruptEndpoints[0]->NextPhysicalEndpoint == m_IsoHeadEndpointDescriptor->PhysicalAddress.LowPart); + + PrintEndpointList(m_IsoHeadEndpointDescriptor); } // @@ -699,7 +709,7 @@ CUSBQueue::FindInterruptEndpointDescriptor( // // sanity check // - ASSERT(InterruptInterval < OHCI_BIGGEST_INTERVAL); + ASSERT(InterruptInterval <= OHCI_BIGGEST_INTERVAL); // // find interrupt index diff --git a/drivers/usb/usbohci/usb_request.cpp b/drivers/usb/usbohci/usb_request.cpp index 77429f65679..f6762c079c1 100644 --- a/drivers/usb/usbohci/usb_request.cpp +++ b/drivers/usb/usbohci/usb_request.cpp @@ -628,7 +628,7 @@ CUSBRequest::CreateIsochronousTransferDescriptor( // // initialize descriptor, hardware part // - Descriptor->Flags = OHCI_ITD_SET_FRAME_COUNT(FrameCount) | OHCI_ITD_SET_DELAY_INTERRUPT(OHCI_TD_INTERRUPT_NONE) | OHCI_TD_SET_CONDITION_CODE(OHCI_TD_CONDITION_NOT_ACCESSED); + Descriptor->Flags = OHCI_ITD_SET_FRAME_COUNT(FrameCount) | OHCI_ITD_SET_DELAY_INTERRUPT(OHCI_TD_INTERRUPT_NONE);// | OHCI_TD_SET_CONDITION_CODE(OHCI_TD_CONDITION_NOT_ACCESSED); Descriptor->BufferPhysical = 0; Descriptor->NextPhysicalDescriptor = 0; Descriptor->LastPhysicalByteAddress = 0; @@ -661,6 +661,7 @@ CUSBRequest::BuildIsochronousEndpoint( PVOID Buffer; PIO_STACK_LOCATION IoStack; PURB Urb; + PHYSICAL_ADDRESS Address; // // get current irp stack location @@ -704,6 +705,10 @@ CUSBRequest::BuildIsochronousEndpoint( // ASSERT(ADDRESS_AND_SIZE_TO_SPAN_PAGES(MmGetMdlVirtualAddress(m_TransferBufferMDL), MmGetMdlByteCount(m_TransferBufferMDL)) <= 2); + Status = m_DmaManager->Allocate(m_TransferBufferLength, &Buffer, &Address); + ASSERT(Status == STATUS_SUCCESS); + + while(Index < Urb->UrbIsochronousTransfer.NumberOfPackets) { // @@ -732,7 +737,7 @@ CUSBRequest::BuildIsochronousEndpoint( // // get page offset // - PageOffset = MmGetMdlByteOffset(m_TransferBufferMDL); + PageOffset = BYTE_OFFSET(Page); // // initialize descriptor @@ -936,6 +941,8 @@ CUSBRequest::AllocateEndpointDescriptor( Descriptor->Flags |= OHCI_ENDPOINT_SET_ENDPOINT_NUMBER(GetEndpointAddress()); Descriptor->Flags |= OHCI_ENDPOINT_SET_MAX_PACKET_SIZE(GetMaxPacketSize()); + DPRINT1("Flags %x DeviceAddress %x EndpointAddress %x PacketSize %x\n", Descriptor->Flags, GetDeviceAddress(), GetEndpointAddress(), GetMaxPacketSize()); + // // is there an endpoint descriptor //