72
} EHCI_STATES;
73
74
/* macros for accessing fields within next link pointer entry */
75
-#define NLPTR_GET(x) ((x) & 0xffffffe0)
75
+#define NLPTR_GET(x) ((x) & ~0x1fULL)
76
#define NLPTR_TYPE_GET(x) (((x) >> 1) & 3)
77
#define NLPTR_TBIT(x) ((x) & 1) /* 1=invalid, 0=valid */
78
287
return async ? s->astate : s->pstate;
288
}
289
290
-static void ehci_set_fetch_addr(EHCIState *s, int async, uint32_t addr)
290
+static void ehci_set_fetch_addr(EHCIState *s, int async, uint64_t addr)
291
{
292
if (async) {
293
s->a_fetch_addr = addr;
296
}
297
}
298
299
-static int ehci_get_fetch_addr(EHCIState *s, int async)
299
+static uint64_t ehci_get_fetch_addr(EHCIState *s, int async)
300
{
301
return async ? s->a_fetch_addr : s->p_fetch_addr;
302
}
373
}
374
375
/* Get an array of dwords from main memory */
376
-static inline int get_dwords(EHCIState *ehci, uint32_t addr,
376
+static inline int get_dwords(EHCIState *ehci, uint64_t addr,
377
uint32_t *buf, int num)
378
{
379
int i;
395
}
396
397
/* Put an array of dwords in to main memory */
398
-static inline int put_dwords(EHCIState *ehci, uint32_t addr,
398
+static inline int put_dwords(EHCIState *ehci, uint64_t addr,
399
uint32_t *buf, int num)
400
{
401
int i;
549
550
/* queue management */
551
552
-static EHCIQueue *ehci_alloc_queue(EHCIState *ehci, uint32_t addr, int async)
552
+static EHCIQueue *ehci_alloc_queue(EHCIState *ehci, uint64_t addr, int async)
553
{
554
EHCIQueueHead *head = async ? &ehci->aqueues : &ehci->pqueues;
555
EHCIQueue *q;
622
g_free(q);
623
}
624
625
-static EHCIQueue *ehci_find_queue_by_qh(EHCIState *ehci, uint32_t addr,
625
+static EHCIQueue *ehci_find_queue_by_qh(EHCIState *ehci, uint64_t addr,
626
int async)
627
{
628
EHCIQueueHead *head = async ? &ehci->aqueues : &ehci->pqueues;
1135
{
1136
uint32_t *qh = (uint32_t *) &q->qh;
1137
uint32_t dwords = sizeof(EHCIqh) >> 2;
1138
- uint32_t addr = NLPTR_GET(q->qhaddr);
1138
+ uint64_t addr = NLPTR_GET(q->qhaddr);
1139
1140
put_dwords(q->ehci, addr + 3 * sizeof(uint32_t), qh + 3, dwords - 3);
1141
}
1406
/* 4.7.2 */
1407
static int ehci_process_itd(EHCIState *ehci,
1408
EHCIitd *itd,
1409
- uint32_t addr)
1409
+ uint64_t addr)
1410
{
1411
USBDevice *dev;
1412
USBEndpoint *ep;
1413
uint32_t i, len, pid, dir, devaddr, endp;
1414
- uint32_t pg, off, ptr1, ptr2, max, mult;
1414
+ uint32_t pg, off, max, mult;
1415
+ uint64_t ptr1, ptr2;
1416
1417
ehci->periodic_sched_active = PERIODIC_ACTIVE;
1418
1529
EHCIqh qh;
1530
int i = 0;
1531
int again = 0;
1531
- uint32_t entry = ehci->asynclistaddr;
1532
+ uint64_t entry = ehci->asynclistaddr;
1533
1534
/* set reclamation flag at start event (4.8.6) */
1535
if (async) {
1579
static int ehci_state_fetchentry(EHCIState *ehci, int async)
1580
{
1581
int again = 0;
1581
- uint32_t entry = ehci_get_fetch_addr(ehci, async);
1582
+ uint64_t entry = ehci_get_fetch_addr(ehci, async);
1583
1584
if (NLPTR_TBIT(entry)) {
1585
ehci_set_state(ehci, async, EST_ACTIVE);
1612
default:
1613
/* TODO: handle FSTN type */
1614
qemu_log_mask(LOG_GUEST_ERROR,
1614
- "FETCHENTRY: entry at 0x%x is of type %u "
1615
- "which is not supported yet\n",
1615
+ "FETCHENTRY: entry at %" PRIx64 " is of type %" PRIu64
1616
+ " which is not supported yet\n",
1617
entry, NLPTR_TYPE_GET(entry));
1618
return -1;
1619
}
1624
1625
static EHCIQueue *ehci_state_fetchqh(EHCIState *ehci, int async)
1626
{
1626
- uint32_t entry;
1627
+ uint64_t entry;
1628
EHCIQueue *q;
1629
EHCIqh qh;
1630
1713
1714
static int ehci_state_fetchitd(EHCIState *ehci, int async)
1715
{
1715
- uint32_t entry;
1716
+ uint64_t entry;
1717
EHCIitd itd;
1718
1719
assert(!async);
1739
1740
static int ehci_state_fetchsitd(EHCIState *ehci, int async)
1741
{
1741
- uint32_t entry;
1742
+ uint64_t entry;
1743
EHCIsitd sitd;
1744
1745
assert(!async);
1803
EHCIqtd qtd;
1804
EHCIPacket *p;
1805
int again = 1;
1805
- uint32_t addr;
1806
+ uint64_t addr;
1807
1808
addr = NLPTR_GET(q->qtdaddr);
1809
if (get_dwords(q->ehci, addr + 8, &qtd.token, 1) < 0) {
1886
USBEndpoint *ep = p->packet.ep;
1887
EHCIQueue *q = p->queue;
1888
EHCIqtd qtd = p->qtd;
1888
- uint32_t qtdaddr;
1889
+ uint64_t qtdaddr;
1890
1891
for (;;) {
1892
if (NLPTR_TBIT(qtd.next) != 0) {
2009
static int ehci_state_writeback(EHCIQueue *q)
2010
{
2011
EHCIPacket *p = QTAILQ_FIRST(&q->packets);
2011
- uint32_t *qtd, addr;
2012
+ uint32_t *qtd;
2013
+ uint64_t addr;
2014
int again = 0;
2015
2016
/* Write back the QTD from the QH area */
2416
.wakeup_endpoint = ehci_wakeup_endpoint,
2417
};
2418
2419
+static bool ehci_fetch_addr_64_needed(void *opaque, int version_id)
2420
+{
2421
+ EHCIState *s = opaque;
2422
+
2423
+ return s->migrate_fetch_addr_64bit;
2424
+}
2425
+
2426
+static bool ehci_fetch_addr_32_needed(void *opaque, int version_id)
2427
+{
2428
+ return !ehci_fetch_addr_64_needed(opaque, version_id);
2429
+}
2430
+
2431
static int usb_ehci_pre_save(void *opaque)
2432
{
2433
EHCIState *ehci = opaque;
2438
ehci->last_run_ns -= (ehci->frindex - new_frindex) * UFRAME_TIMER_NS;
2439
ehci->frindex = new_frindex;
2440
2441
+ if (!ehci->migrate_fetch_addr_64bit) {
2442
+ ehci->migrate_a_fetch_addr = ehci->a_fetch_addr;
2443
+ ehci->migrate_p_fetch_addr = ehci->p_fetch_addr;
2444
+ }
2445
+
2446
return 0;
2447
}
2448
2463
}
2464
}
2465
2466
+ if (!s->migrate_fetch_addr_64bit) {
2467
+ s->a_fetch_addr = s->migrate_a_fetch_addr;
2468
+ s->p_fetch_addr = s->migrate_p_fetch_addr;
2469
+ }
2470
+
2471
return 0;
2472
}
2473
2528
/* schedule state */
2529
VMSTATE_UINT32(astate, EHCIState),
2530
VMSTATE_UINT32(pstate, EHCIState),
2507
- VMSTATE_UINT32(a_fetch_addr, EHCIState),
2508
- VMSTATE_UINT32(p_fetch_addr, EHCIState),
2531
+ VMSTATE_UINT32_TEST(migrate_a_fetch_addr, EHCIState,
2532
+ ehci_fetch_addr_32_needed),
2533
+ VMSTATE_UINT32_TEST(migrate_p_fetch_addr, EHCIState,
2534
+ ehci_fetch_addr_32_needed),
2535
+ VMSTATE_UINT64_TEST(a_fetch_addr, EHCIState,
2536
+ ehci_fetch_addr_64_needed),
2537
+ VMSTATE_UINT64_TEST(p_fetch_addr, EHCIState,
2538
+ ehci_fetch_addr_64_needed),
2539
VMSTATE_END_OF_LIST()
2540
}
2541
};