Author: janderwald
Date: Mon May 30 06:55:32 2011
New Revision: 52004
URL: 
http://svn.reactos.org/svn/reactos?rev=52004&view=rev
Log:
[USBOHCI]
- More traces to fix isochronous problem
- Fix broken assert found by mjmartin
Modified:
    branches/usb-bringup/drivers/usb/usbohci/hardware.cpp
    branches/usb-bringup/drivers/usb/usbohci/hardware.h
    branches/usb-bringup/drivers/usb/usbohci/usb_queue.cpp
    branches/usb-bringup/drivers/usb/usbohci/usb_request.cpp
Modified: branches/usb-bringup/drivers/usb/usbohci/hardware.cpp
URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbohci…
==============================================================================
--- branches/usb-bringup/drivers/usb/usbohci/hardware.cpp [iso-8859-1] (original)
+++ branches/usb-bringup/drivers/usb/usbohci/hardware.cpp [iso-8859-1] Mon May 30 06:55:32
2011
@@ -545,12 +545,15 @@
     //
     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 @@
     //
     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
@@ -918,6 +921,8 @@
     // store interval value for later
     //
     m_IntervalValue = OHCI_GET_INTERVAL_VALUE(FrameInterval);
+
+    DPRINT1("FrameInterval %x Interval %x\n", FrameInterval, m_IntervalValue);
     //
     // now reset controller
@@ -1206,10 +1211,30 @@
 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 @@
     //
     // 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));
     //
Modified: branches/usb-bringup/drivers/usb/usbohci/hardware.h
URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbohci…
==============================================================================
--- branches/usb-bringup/drivers/usb/usbohci/hardware.h [iso-8859-1] (original)
+++ branches/usb-bringup/drivers/usb/usbohci/hardware.h [iso-8859-1] Mon May 30 06:55:32
2011
@@ -99,6 +99,11 @@
 #define OHCI_FRAME_INTERVAL_TOGGLE          0x80000000
 //
+// frame interval
+//
+#define OHCI_FRAME_INTERVAL_NUMBER_OFFSET          0x3C
+
+//
 // periodic start register
 //
 #define OHCI_PERIODIC_START_OFFSET             0x40
Modified: branches/usb-bringup/drivers/usb/usbohci/usb_queue.cpp
URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbohci…
==============================================================================
--- branches/usb-bringup/drivers/usb/usbohci/usb_queue.cpp [iso-8859-1] (original)
+++ branches/usb-bringup/drivers/usb/usbohci/usb_queue.cpp [iso-8859-1] Mon May 30
06:55:32 2011
@@ -278,6 +278,16 @@
             //
             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 @@
     //
     // sanity check
     //
-    ASSERT(InterruptInterval < OHCI_BIGGEST_INTERVAL);
+    ASSERT(InterruptInterval <= OHCI_BIGGEST_INTERVAL);
     //
     // find interrupt index
Modified: branches/usb-bringup/drivers/usb/usbohci/usb_request.cpp
URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbohci…
==============================================================================
--- branches/usb-bringup/drivers/usb/usbohci/usb_request.cpp [iso-8859-1] (original)
+++ branches/usb-bringup/drivers/usb/usbohci/usb_request.cpp [iso-8859-1] Mon May 30
06:55:32 2011
@@ -628,7 +628,7 @@
     //
     // 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 @@
     PVOID Buffer;
     PIO_STACK_LOCATION IoStack;
     PURB Urb;
+    PHYSICAL_ADDRESS Address;
     //
     // get current irp stack location
@@ -704,6 +705,10 @@
     //
     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 @@
         //
         // get page offset
         //
-        PageOffset = MmGetMdlByteOffset(m_TransferBufferMDL);
+        PageOffset = BYTE_OFFSET(Page);
         //
         // initialize descriptor
@@ -935,6 +940,8 @@
     Descriptor->Flags |= OHCI_ENDPOINT_SET_DEVICE_ADDRESS(GetDeviceAddress());
     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