104
* must not read or write past that boundary.
105
*/
106
#define EHCI_QH_DWORDS_32 (offsetof(EHCIqh, bufptr_hi) / sizeof(uint32_t))
107
+#define EHCI_QTD_DWORDS_32 (offsetof(EHCIqtd, bufptr_hi) / sizeof(uint32_t))
108
109
static const char *ehci_state_names[] = {
110
[EST_INACTIVE] = "INACTIVE",
179
return s->caps_64bit_addr ? (sizeof(EHCIqh) >> 2) : EHCI_QH_DWORDS_32;
180
}
181
182
+static uint32_t ehci_qtd_dwords(const EHCIState *s)
183
+{
184
+ return s->caps_64bit_addr ? (sizeof(EHCIqtd) >> 2) : EHCI_QTD_DWORDS_32;
185
+}
186
+
187
static void ehci_trace_usbsts(uint32_t mask, int state)
188
{
189
/* interrupts */
492
(p->qtd.next != qtd->next)) ||
493
(!NLPTR_TBIT(p->qtd.altnext) && (p->qtd.altnext != qtd->altnext)) ||
494
p->qtd.token != qtd->token ||
489
- p->qtd.bufptr[0] != qtd->bufptr[0]) {
495
+ p->qtd.bufptr[0] != qtd->bufptr[0] ||
496
+ p->qtd.bufptr_hi[0] != qtd->bufptr_hi[0]) {
497
return false;
498
} else {
499
return true;
526
527
/* Verify the qh + qtd, like we do when going through fetchqh & fetchqtd */
528
memset(&qh, 0, sizeof(qh));
529
+ memset(&qtd, 0, sizeof(qtd));
530
get_dwords(q->ehci, NLPTR_GET(q->qhaddr),
531
(uint32_t *) &qh, ehci_qh_dwords(q->ehci));
532
get_dwords(q->ehci, NLPTR_GET(q->qtdaddr),
525
- (uint32_t *) &qtd, sizeof(EHCIqtd) >> 2);
533
+ (uint32_t *) &qtd, ehci_qtd_dwords(q->ehci));
534
if (!ehci_verify_qh(q, &qh) || !ehci_verify_qtd(p, &qtd)) {
535
p->async = EHCI_ASYNC_INITIALIZED;
536
ehci_free_packet(p);
1223
1224
for (i = 0; i < 5; i++) {
1225
q->qh.bufptr[i] = p->qtd.bufptr[i];
1226
+ q->qh.bufptr_hi[i] = p->qtd.bufptr_hi[i];
1227
}
1228
1229
if (!(q->qh.epchar & QH_EPCHAR_DTC)) {
1257
return -1;
1258
}
1259
1251
- page = p->qtd.bufptr[cpage] & QTD_BUFPTR_MASK;
1260
+ page = ehci_get_buf_addr(p->queue->ehci, p->qtd.bufptr_hi[cpage],
1261
+ p->qtd.bufptr[cpage], QTD_BUFPTR_MASK);
1262
page += offset;
1263
plen = bytes;
1264
if (plen > 4096 - offset) {
1754
} else if ((q->qh.token & QTD_TOKEN_ACTIVE) &&
1755
(NLPTR_TBIT(q->qh.current_qtd) == 0) &&
1756
(q->qh.current_qtd != 0)) {
1747
- q->qtdaddr = q->qh.current_qtd;
1757
+ q->qtdaddr = ehci_get_desc_addr(ehci, q->qh.current_qtd);
1758
ehci_set_state(ehci, async, EST_FETCHQTD);
1759
1760
} else {
1832
*/
1833
if (((q->qh.token & QTD_TOKEN_TBYTES_MASK) != 0) &&
1834
(NLPTR_TBIT(q->qh.altnext_qtd) == 0)) {
1825
- q->qtdaddr = q->qh.altnext_qtd;
1835
+ q->qtdaddr = ehci_get_desc_addr(q->ehci, q->qh.altnext_qtd);
1836
ehci_set_state(q->ehci, q->async, EST_FETCHQTD);
1837
1838
/*
1839
* next qTD is valid
1840
*/
1841
} else if (NLPTR_TBIT(q->qh.next_qtd) == 0) {
1832
- q->qtdaddr = q->qh.next_qtd;
1842
+ q->qtdaddr = ehci_get_desc_addr(q->ehci, q->qh.next_qtd);
1843
ehci_set_state(q->ehci, q->async, EST_FETCHQTD);
1844
1845
/*
1865
return 0;
1866
}
1867
barrier();
1868
+ memset(qtd.bufptr_hi, 0, sizeof(qtd.bufptr_hi));
1869
if (get_dwords(q->ehci, addr + 0, &qtd.next, 1) < 0 ||
1870
get_dwords(q->ehci, addr + 4, &qtd.altnext, 1) < 0 ||
1871
get_dwords(q->ehci, addr + 12, qtd.bufptr,
1861
- ARRAY_SIZE(qtd.bufptr)) < 0) {
1872
+ ARRAY_SIZE(qtd.bufptr)) < 0 ||
1873
+ (q->ehci->caps_64bit_addr &&
1874
+ get_dwords(q->ehci, addr + offsetof(EHCIqtd, bufptr_hi),
1875
+ qtd.bufptr_hi, ARRAY_SIZE(qtd.bufptr_hi)) < 0)) {
1876
return 0;
1877
}
1878
ehci_trace_qtd(q, NLPTR_GET(q->qtdaddr), &qtd);
1953
if (NLPTR_TBIT(qtd.next) != 0) {
1954
break;
1955
}
1942
- qtdaddr = qtd.next;
1956
+ qtdaddr = ehci_get_desc_addr(q->ehci, qtd.next);
1957
/*
1958
* Detect circular td lists, Windows creates these, counting on the
1959
* active bit going low after execution to make the queue stop.
1963
goto leave;
1964
}
1965
}
1966
+ memset(qtd.bufptr_hi, 0, sizeof(qtd.bufptr_hi));
1967
if (get_dwords(q->ehci, NLPTR_GET(qtdaddr),
1953
- (uint32_t *) &qtd, sizeof(EHCIqtd) >> 2) < 0) {
1968
+ (uint32_t *) &qtd, ehci_qtd_dwords(q->ehci)) < 0) {
1969
return -1;
1970
}
1971
ehci_trace_qtd(q, NLPTR_GET(qtdaddr), &qtd);