! '''Note'''
 
! '''Note'''
 
| See usb.pas for the documentation of this interface of the Host Controller Driver
 
| See usb.pas for the documentation of this interface of the Host Controller Driver
This Host Controller Driver implements this interface asynchronously, as intended. Furthermore, it uses a simplistic scheduling algorithm where it places requests into a single queue and executes them in the order they were submitted.  Transfers that need to be retried, including periodic transfers that receive a NAK reply and split transactions that receive a NYET reply when doing the Complete Split transaction, are scheduled to be retried at an appropriate time by separate code that shortcuts the main queue when the timer expires
+
This Host Controller Driver implements this interface asynchronously, as intended. Furthermore, it uses a simplistic scheduling algorithm where it places requests into a single queue and executes them in the order they were submitted.  Transfers that need to be retried, including periodic transfers that receive a NAK reply and split transactions that receive a NYET reply when doing the Complete Split transaction, are scheduled to be retried at an appropriate time by separate code that shortcuts the main queue when the timer expires.
<br />Caller must hold the device lock
+
<br />Caller must hold the device lock.
 
|-
 
|-
 
|}
 
|}
 
! '''Note'''
 
! '''Note'''
 
| For periodic transfers (e.g. polling an interrupt endpoint), the exact time at which the transfer must be retried is specified by the bInterval member of the endpoint descriptor. For low and full-speed devices, bInterval specifies the number of millisconds to wait before the next poll, while for high-speed devices it specifies the exponent (plus one) of a power-of-two number of milliseconds to wait before the next poll.
 
| For periodic transfers (e.g. polling an interrupt endpoint), the exact time at which the transfer must be retried is specified by the bInterval member of the endpoint descriptor. For low and full-speed devices, bInterval specifies the number of millisconds to wait before the next poll, while for high-speed devices it specifies the exponent (plus one) of a power-of-two number of milliseconds to wait before the next poll.
<br />To actually implement delaying a transfer, we associate each transfer with a thread created on-demand. Each such thread simply enters a loop where it calls sleep() for the appropriate number of milliseconds, then retries the transfer.  A semaphore is needed to make the thread do nothing until the request has actually been resubmitted.
+
To actually implement delaying a transfer, we associate each transfer with a thread created on-demand. Each such thread simply enters a loop where it calls sleep() for the appropriate number of milliseconds, then retries the transfer.  A semaphore is needed to make the thread do nothing until the request has actually been resubmitted.
 
<br />This code gets used to scheduling polling of IN interrupt endpoints, including those on hubs and HID devices. Thus, polling of these devices for status changes (in the case of hubs) or new input (in the case of HID devices) is done in software. This wakes up the CPU a lot and wastes time and energy. But with USB 2.0, there is no way around this, other than by suspending the USB device which we don't support.
 
<br />This code gets used to scheduling polling of IN interrupt endpoints, including those on hubs and HID devices. Thus, polling of these devices for status changes (in the case of hubs) or new input (in the case of HID devices) is done in software. This wakes up the CPU a lot and wastes time and energy. But with USB 2.0, there is no way around this, other than by suspending the USB device which we don't support.
 
|-
 
|-
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<pre style="border: 0; padding-bottom:0px;">function DWCHostSetupDMA(Host:PDWCUSBHost):LongWord;</pre>
 
<pre style="border: 0; padding-bottom:0px;">function DWCHostSetupDMA(Host:PDWCUSBHost):LongWord;</pre>
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Set up the DWC OTG USB Host Controller for DMA (direct memory access). This makes it possible for the Host Controller to directly access in-memory buffers when performing USB transfers</div>
+
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Set up the DWC OTG USB Host Controller for DMA (direct memory access). This makes it possible for the Host Controller to directly access in-memory buffers when performing USB transfers.</div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<pre style="border: 0; padding-bottom:0px;">function DWCHostPortGetStatus(Host:PDWCUSBHost):LongWord;</pre>
 
<pre style="border: 0; padding-bottom:0px;">function DWCHostPortGetStatus(Host:PDWCUSBHost):LongWord;</pre>
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Read the Host Port Control and Status register with the intention of modifying it. Due to the inconsistent design of the bits in this register, this requires zeroing the write-clear bits so they aren't unintentionally cleared by writing back 1's to them</div>
+
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Read the Host Port Control and Status register with the intention of modifying it. Due to the inconsistent design of the bits in this register, this requires zeroing the write-clear bits so they aren't unintentionally cleared by writing back 1's to them.</div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
 
! '''Note'''
 
! '''Note'''
| This thread receives requests that have been submitted and schedules them on the next available channel
+
| This thread receives requests that have been submitted and schedules them on the next available channel.
This is a very simplistic scheduler that does not take into account bandwidth requirements or which endpoint a transfer is for
+
This is a very simplistic scheduler that does not take into account bandwidth requirements or which endpoint a transfer is for.
 
|-
 
|-
 
|}
 
|}
 
|-
 
|-
 
! '''Note'''
 
! '''Note'''
| This thread receives completed requests which have either succeeded or failed and calls the completion handler which will call the registered callback for the request
+
| This thread receives completed requests which have either succeeded or failed and calls the completion handler which will call the registered callback for the request.
This thread also receives requests that need to be resubmitted and resubmits them for later processing by another thread
+
This thread also receives requests that need to be resubmitted and resubmits them for later processing by another thread.
 
<br />Message contents are as follows:
 
<br />Message contents are as follows:
 
<br />Msg = Request to be completed
 
<br />Msg = Request to be completed
 
|-
 
|-
 
! '''Note'''
 
! '''Note'''
Exception encountered, of type "Error"