|
|
|
|
|
|
|
|
void USBHost::add_qh_to_periodic_schedule(Pipe_t *pipe) |
|
|
void USBHost::add_qh_to_periodic_schedule(Pipe_t *pipe) |
|
|
{ |
|
|
{ |
|
|
// quick hack for testing, just put it into the first table entry |
|
|
// quick hack for testing, just put it into the first table entry |
|
|
println("add_qh_to_periodic_schedule:"); |
|
|
|
|
|
|
|
|
println("add_qh_to_periodic_schedule: ", (uint32_t)pipe, HEX); |
|
|
#if 0 |
|
|
#if 0 |
|
|
pipe->qh.horizontal_link = periodictable[0]; |
|
|
pipe->qh.horizontal_link = periodictable[0]; |
|
|
periodictable[0] = (uint32_t)&(pipe->qh) | 2; // 2=QH |
|
|
periodictable[0] = (uint32_t)&(pipe->qh) | 2; // 2=QH |
|
|
|
|
|
|
|
|
println(" interval = ", interval); |
|
|
println(" interval = ", interval); |
|
|
println(" offset = ", offset); |
|
|
println(" offset = ", offset); |
|
|
|
|
|
|
|
|
// TODO: does this really make an inverted tree like EHCI figure 4-18, page 93 |
|
|
|
|
|
|
|
|
// By an interative miracle, hopefully make an inverted tree of EHCI figure 4-18, page 93 |
|
|
for (uint32_t i=offset; i < PERIODIC_LIST_SIZE; i += interval) { |
|
|
for (uint32_t i=offset; i < PERIODIC_LIST_SIZE; i += interval) { |
|
|
|
|
|
print(" old slot ", i); |
|
|
|
|
|
print(": "); |
|
|
|
|
|
print_qh_list((Pipe_t *)(periodictable[i] & 0xFFFFFFE0)); |
|
|
uint32_t num = periodictable[i]; |
|
|
uint32_t num = periodictable[i]; |
|
|
Pipe_t *node = (Pipe_t *)(num & 0xFFFFFFE0); |
|
|
Pipe_t *node = (Pipe_t *)(num & 0xFFFFFFE0); |
|
|
if ((num & 1) || ((num & 6) == 2 && node->periodic_interval < interval)) { |
|
|
if ((num & 1) || ((num & 6) == 2 && node->periodic_interval < interval)) { |
|
|
|
|
|
|
|
|
println(" traverse list ", i); |
|
|
println(" traverse list ", i); |
|
|
// TODO: skip past iTD, siTD when/if we support isochronous |
|
|
// TODO: skip past iTD, siTD when/if we support isochronous |
|
|
while (node->periodic_interval >= interval) { |
|
|
while (node->periodic_interval >= interval) { |
|
|
|
|
|
if (node == pipe) goto nextslot; |
|
|
|
|
|
print(" num ", num, HEX); |
|
|
|
|
|
print(" node ", (uint32_t)node, HEX); |
|
|
|
|
|
println("->", node->qh.horizontal_link, HEX); |
|
|
if (node->qh.horizontal_link & 1) break; |
|
|
if (node->qh.horizontal_link & 1) break; |
|
|
num = node->qh.horizontal_link; |
|
|
num = node->qh.horizontal_link; |
|
|
node = (Pipe_t *)(num & 0xFFFFFFE0); |
|
|
node = (Pipe_t *)(num & 0xFFFFFFE0); |
|
|
} |
|
|
} |
|
|
pipe->qh.horizontal_link = num; |
|
|
|
|
|
|
|
|
Pipe_t *n = node; |
|
|
|
|
|
do { |
|
|
|
|
|
if (n == pipe) goto nextslot; |
|
|
|
|
|
n = (Pipe_t *)(n->qh.horizontal_link & 0xFFFFFFE0); |
|
|
|
|
|
} while (n != NULL); |
|
|
|
|
|
print(" adding at node ", (uint32_t)node, HEX); |
|
|
|
|
|
print(", num=", num, HEX); |
|
|
|
|
|
println(", node->qh.horizontal_link=", node->qh.horizontal_link, HEX); |
|
|
|
|
|
pipe->qh.horizontal_link = node->qh.horizontal_link; |
|
|
node->qh.horizontal_link = (uint32_t)pipe | 2; // 2=QH |
|
|
node->qh.horizontal_link = (uint32_t)pipe | 2; // 2=QH |
|
|
|
|
|
// TODO: is it really necessary to keep doing the outer |
|
|
|
|
|
// loop? Does adding it here satisfy all cases? If so |
|
|
|
|
|
// we could avoid extra work by just returning here. |
|
|
} |
|
|
} |
|
|
|
|
|
nextslot: |
|
|
|
|
|
print(" new slot ", i); |
|
|
|
|
|
print(": "); |
|
|
|
|
|
print_qh_list((Pipe_t *)(periodictable[i] & 0xFFFFFFE0)); |
|
|
} |
|
|
} |
|
|
#endif |
|
|
#endif |
|
|
#if 1 |
|
|
#if 1 |