Lines Matching refs:td
109 static void uhci_queue_fill(UHCIQueue *q, UHCI_TD *td);
112 static inline int32_t uhci_queue_token(UHCI_TD *td) in uhci_queue_token() argument
114 if ((td->token & (0xf << 15)) == 0) { in uhci_queue_token()
116 return td->token & 0x7ff00; in uhci_queue_token()
119 return td->token & 0x7ffff; in uhci_queue_token()
123 static UHCIQueue *uhci_queue_new(UHCIState *s, uint32_t qh_addr, UHCI_TD *td, in uhci_queue_new() argument
131 queue->token = uhci_queue_token(td); in uhci_queue_new()
156 static UHCIQueue *uhci_queue_find(UHCIState *s, UHCI_TD *td) in uhci_queue_find() argument
158 uint32_t token = uhci_queue_token(td); in uhci_queue_find()
169 static bool uhci_queue_verify(UHCIQueue *queue, uint32_t qh_addr, UHCI_TD *td, in uhci_queue_verify() argument
176 queue->token == uhci_queue_token(td) && in uhci_queue_verify()
178 (queuing || !(td->ctrl & TD_CTRL_ACTIVE) || first == NULL || in uhci_queue_verify()
631 static void uhci_read_td(UHCIState *s, UHCI_TD *td, uint32_t link) in uhci_read_td() argument
633 pci_dma_read(&s->dev, link & ~0xf, td, sizeof(*td)); in uhci_read_td()
634 le32_to_cpus(&td->link); in uhci_read_td()
635 le32_to_cpus(&td->ctrl); in uhci_read_td()
636 le32_to_cpus(&td->token); in uhci_read_td()
637 le32_to_cpus(&td->buffer); in uhci_read_td()
640 static int uhci_handle_td_error(UHCIState *s, UHCI_TD *td, uint32_t td_addr, in uhci_handle_td_error() argument
643 uint32_t queue_token = uhci_queue_token(td); in uhci_handle_td_error()
648 td->ctrl |= TD_CTRL_NAK; in uhci_handle_td_error()
652 td->ctrl |= TD_CTRL_STALL; in uhci_handle_td_error()
658 td->ctrl |= TD_CTRL_BABBLE | TD_CTRL_STALL; in uhci_handle_td_error()
667 td->ctrl |= TD_CTRL_TIMEOUT; in uhci_handle_td_error()
668 td->ctrl &= ~(3 << TD_CTRL_ERROR_SHIFT); in uhci_handle_td_error()
674 td->ctrl &= ~TD_CTRL_ACTIVE; in uhci_handle_td_error()
676 if (td->ctrl & TD_CTRL_IOC) { in uhci_handle_td_error()
683 static int uhci_complete_td(UHCIState *s, UHCI_TD *td, UHCIAsync *async, in uhci_complete_td() argument
689 max_len = ((td->token >> 21) + 1) & 0x7ff; in uhci_complete_td()
690 pid = td->token & 0xff; in uhci_complete_td()
692 if (td->ctrl & TD_CTRL_IOS) { in uhci_complete_td()
693 td->ctrl &= ~TD_CTRL_ACTIVE; in uhci_complete_td()
697 return uhci_handle_td_error(s, td, async->td_addr, in uhci_complete_td()
702 td->ctrl = (td->ctrl & ~0x7ff) | ((len - 1) & 0x7ff); in uhci_complete_td()
709 td->ctrl &= ~(TD_CTRL_ACTIVE | TD_CTRL_NAK); in uhci_complete_td()
710 if (td->ctrl & TD_CTRL_IOC) { in uhci_complete_td()
715 pci_dma_write(&s->dev, td->buffer, async->buf, len); in uhci_complete_td()
716 if ((td->ctrl & TD_CTRL_SPD) && len < max_len) { in uhci_complete_td()
732 UHCI_TD *td, uint32_t td_addr, uint32_t *int_mask) in uhci_handle_td() argument
737 uint8_t pid = td->token & 0xff; in uhci_handle_td()
742 if (uhci_queue_verify(async->queue, qh_addr, td, td_addr, queuing)) { in uhci_handle_td()
752 q = uhci_queue_find(s, td); in uhci_handle_td()
753 if (q && !uhci_queue_verify(q, qh_addr, td, td_addr, queuing)) { in uhci_handle_td()
764 if (!(td->ctrl & TD_CTRL_ACTIVE)) { in uhci_handle_td()
773 if (td->ctrl & TD_CTRL_IOC) { in uhci_handle_td()
827 dev = uhci_find_device(s, (td->token >> 8) & 0x7f); in uhci_handle_td()
829 return uhci_handle_td_error(s, td, td_addr, USB_RET_NODEV, in uhci_handle_td()
832 ep = usb_ep_get(dev, pid, (td->token >> 15) & 0xf); in uhci_handle_td()
833 q = uhci_queue_new(s, qh_addr, td, ep); in uhci_handle_td()
837 max_len = ((td->token >> 21) + 1) & 0x7ff; in uhci_handle_td()
838 spd = (pid == USB_TOKEN_IN && (td->ctrl & TD_CTRL_SPD) != 0); in uhci_handle_td()
840 (td->ctrl & TD_CTRL_IOC) != 0); in uhci_handle_td()
851 pci_dma_read(&s->dev, td->buffer, async->buf, max_len); in uhci_handle_td()
869 uhci_queue_fill(q, td); in uhci_handle_td()
875 ret = uhci_complete_td(s, td, async, int_mask); in uhci_handle_td()
941 static void uhci_queue_fill(UHCIQueue *q, UHCI_TD *td) in uhci_queue_fill() argument
944 uint32_t plink = td->link; in uhci_queue_fill()
973 UHCI_TD td; in uhci_process_frame() local
1036 uhci_read_td(s, &td, link); in uhci_process_frame()
1037 trace_usb_uhci_td_load(curr_qh & ~0xf, link & ~0xf, td.ctrl, td.token); in uhci_process_frame()
1039 old_td_ctrl = td.ctrl; in uhci_process_frame()
1040 ret = uhci_handle_td(s, NULL, curr_qh, &td, link, &int_mask); in uhci_process_frame()
1041 if (old_td_ctrl != td.ctrl) { in uhci_process_frame()
1043 val = cpu_to_le32(td.ctrl); in uhci_process_frame()
1054 link = curr_qh ? qh.link : td.link; in uhci_process_frame()
1059 link = curr_qh ? qh.link : td.link; in uhci_process_frame()
1064 link = td.link; in uhci_process_frame()
1066 s->frame_bytes += (td.ctrl & 0x7ff) + 1; in uhci_process_frame()