+ int next_frame = (inw(Cont->IOBase + FRNUM) + 2) & (1024-1);
+ tPAddr td_pool_base = MM_GetPhysAddr( (tVAddr)gaUHCI_TDPool );
+ tUHCI_TD *prev_td;
+ Uint32 link;
+
+ // TODO: How to handle FRNUM incrementing while we are in this function?
+
+ // Empty list
+ if( Cont->FrameList[next_frame] & 1 )
+ {
+ // TODO: Ensure 32-bit paddr
+ Cont->FrameList[next_frame] = MM_GetPhysAddr( (tVAddr)TD );
+ LOG("next_frame = %i", next_frame);
+ return;
+ }
+
+ // Find the end of the list
+ link = Cont->FrameList[next_frame];
+ do {
+ // TODO: Fix this to work with a non-contiguous pool
+ prev_td = gaUHCI_TDPool + (link - td_pool_base) / sizeof(gaUHCI_TDPool[0]);
+ link = prev_td->Link;
+ } while( !(link & 1) );
+
+ // Append
+ prev_td->Link = MM_GetPhysAddr( (tVAddr)TD );
+
+ LOG("next_frame = %i, prev_td = %p", next_frame, prev_td);