Exemple #1
0
        /// <summary>
        /// Sets up an IN transaction and adds it to the specified transfer.
        /// </summary>
        /// <param name="transfer">The transfer to which the transaction should be added.</param>
        /// <param name="uTransaction">The USB Transaction to convert to an EHCI transaction.</param>
        /// <param name="toggle">The transaction toggle state.</param>
        /// <param name="buffer">The buffer to store the incoming data in.</param>
        /// <param name="length">The length of the buffer.</param>
        protected override void _INTransaction(USBTransfer transfer, USBTransaction uTransaction, bool toggle, void* buffer, ushort length)
        {
            // Create an EHCI-specific object to describe the transaction
            EHCITransaction eTransaction = new EHCITransaction();
            // Store the underlying HC-specific transaction info
            uTransaction.underlyingTz = eTransaction;
            // IN transaction so use the supplied input data buffer
            eTransaction.inBuffer = buffer;
            eTransaction.inLength = length;

#if EHCI_TRACE
            DBGMSG(((FOS_System.String)"IN Transaction : buffer=") + (uint)buffer);

            DBGMSG(((FOS_System.String)"IN Transaction : Before CreateQTD : bufferPtr=&qTDBuffer=") + (uint)buffer);
#endif

            // Create and initialise the IN queue transfer descriptor
            eTransaction.qTD = CreateQTD_IO(null, 1, toggle, length, length);

#if EHCI_TRACE
            DBGMSG(((FOS_System.String)"IN Transaction : After CreateQTD : bufferPtr=&qTDBuffer=") + (uint)buffer + ", Buffer0=" + (uint)eTransaction.qTD.Buffer0);
#endif
            // If the number of existing transactions is greater than 0
            //  i.e. some transactions have already been added. 
            if (transfer.transactions.Count > 0)
            {
                // Get the previous (i.e. last) transaction then the underlying transaction from it
                EHCITransaction eLastTransaction = (EHCITransaction)((USBTransaction)(transfer.transactions[transfer.transactions.Count - 1])).underlyingTz;
                // Create a wrapper for the last transaction (qTD)
                EHCI_qTD lastQTD = eLastTransaction.qTD;
                // Set the Next Transaction (qTD) Pointer on the previous qTD to point to the qTD
                //  we just created. 
                // Note: The NextqTDPointer must be the physical address of qTD data.
                lastQTD.NextqTDPointer = (EHCI_qTD_Struct*)VirtMemManager.GetPhysicalAddress(eTransaction.qTD.qtd);
                // Mark the previous qTD's Next Transaction Pointer as valid.
                lastQTD.NextqTDPointerTerminate = false;
            }
        }
Exemple #2
0
        /// <summary>
        /// Sets up an IN transaction and adds it to the specified transfer.
        /// </summary>
        /// <param name="transfer">The transfer to which the transaction should be added.</param>
        /// <param name="uTransaction">The USB Transaction to convert to an EHCI transaction.</param>
        /// <param name="toggle">The transaction toggle state.</param>
        /// <param name="buffer">The buffer of outgoing data.</param>
        /// <param name="length">The length of the buffer.</param>
        protected override void _OUTTransaction(USBTransfer transfer, USBTransaction uTransaction, bool toggle, void* buffer, ushort length)
        {
            // Create an EHCI-specific object to describe the transaction
            EHCITransaction eTransaction = new EHCITransaction();
            // Store the underlying HC-specific transaction info
            uTransaction.underlyingTz = eTransaction;
            // OUT transaction so there is no input buffer
            eTransaction.inBuffer = null;
            eTransaction.inLength = 0u;

            // Create and initialise the OUT queue transfer descriptor
            EHCI_qTD theQTD = CreateQTD_IO(null, 0, toggle, length, length);
            // Set the qTD structure in the transaction description object
            eTransaction.qTD = theQTD;
            // If there is an output buffer and it has > 0 length:
            if (buffer != null && length != 0)
            {
                // Copy the data from the output buffer to the transaction's output buffer
                // The transaction's output buffer has been allocated so it as aligned correctly
                //  where as there is no guarantee the output buffer passed to us has been so we
                //  must copy the data across.
                Utilities.MemoryUtils.MemCpy_32(theQTD.Buffer0VirtAddr, (byte*)buffer, length);

#if EHCI_TRACE
                BasicConsole.WriteLine("EHCI: OUTTransaction - Buffer0:");
                BasicConsole.DumpMemory(theQTD.Buffer0VirtAddr, length);
#endif
            }

            // If the number of existing transactions is greater than 0
            //  i.e. some transactions have already been added. 
            if (transfer.transactions.Count > 0)
            {
                // Get the previous (i.e. last) transaction then the underlying transaction from it
                EHCITransaction eLastTransaction = (EHCITransaction)((USBTransaction)(transfer.transactions[transfer.transactions.Count - 1])).underlyingTz;
                // Create a wrapper for the last transaction (qTD)
                EHCI_qTD lastQTD = eLastTransaction.qTD;
                // Set the Next Transaction (qTD) Pointer on the previous qTD to point to the qTD
                //  we just created. 
                // Note: The NextqTDPointer must be the physical address of qTD data.
                lastQTD.NextqTDPointer = (EHCI_qTD_Struct*)VirtMemManager.GetPhysicalAddress(eTransaction.qTD.qtd);
                // Mark the previous qTD's Next Transaction Pointer as valid.
                lastQTD.NextqTDPointerTerminate = false;
            }
        }
Exemple #3
0
 /// <summary>
 /// Sets up a SETUP transaction and adds it to the specified transfer.
 /// </summary>
 /// <param name="transfer">The transfer to which the transaction should be added.</param>
 /// <param name="uTransaction">The USB Transaction to convert to an EHCI Transaction.</param>
 /// <param name="toggle">The transaction toggle state.</param>
 /// <param name="tokenBytes">The number of bytes to send.</param>
 /// <param name="type">The type of the USB Request.</param>
 /// <param name="req">The specific USB Request.</param>
 /// <param name="hiVal">The USB Request Hi-Val.</param>
 /// <param name="loVal">The USB Request Lo-Val.</param>
 /// <param name="index">The USB request index.</param>
 /// <param name="length">The length of the USB request.</param>
 protected override void _SETUPTransaction(USBTransfer transfer, USBTransaction uTransaction, bool toggle, ushort tokenBytes,
                                           byte type, byte req, byte hiVal, byte loVal, ushort index, ushort length)
 {
     // Create an EHCI-specific object to describe the transaction
     EHCITransaction eTransaction = new EHCITransaction();
     // Store the underlying HC-specific transaction info
     uTransaction.underlyingTz = eTransaction;
     // SETUP transaction so there is no input buffer
     eTransaction.inBuffer = null;
     eTransaction.inLength = 0u;
     // Create and initialise the SETUP queue transfer descriptor
     eTransaction.qTD = CreateQTD_SETUP(null, toggle, tokenBytes, type, req, hiVal, loVal, index, length);
     
     // If the number of existing transactions is greater than 0
     //  i.e. some transactions have already been added.
     if (transfer.transactions.Count > 0)
     {
         // Get the previous (i.e. last) transaction then the underlying transaction from it
         EHCITransaction eLastTransaction = (EHCITransaction)((USBTransaction)(transfer.transactions[transfer.transactions.Count - 1])).underlyingTz;
         // Create a wrapper for the last transaction (qTD)
         EHCI_qTD lastQTD = eLastTransaction.qTD;
         // Set the Next Transaction (qTD) Pointer on the previous qTD to point to the qTD
         //  we just created. 
         // Note: The NextqTDPointer must be the physical address of qTD data.
         lastQTD.NextqTDPointer = (EHCI_qTD_Struct*)VirtMemManager.GetPhysicalAddress(eTransaction.qTD.qtd);
         // Mark the previous qTD's Next Transaction Pointer as valid.
         lastQTD.NextqTDPointerTerminate = false;
     }
 }