*
* Only host-mode and non-DMA accesses are currently supported.
*/
-#include "qemu-common.h"
-#include "qemu-timer.h"
+#include "qemu/osdep.h"
+#include "qemu/timer.h"
#include "hw/usb.h"
#include "hw/irq.h"
#include "hw/hw.h"
/* #define MUSB_DEBUG */
#ifdef MUSB_DEBUG
-#define TRACE(fmt,...) fprintf(stderr, "%s@%d: " fmt "\n", __FUNCTION__, \
- __LINE__, ##__VA_ARGS__)
+#define TRACE(fmt, ...) fprintf(stderr, "%s@%d: " fmt "\n", __func__, \
+ __LINE__, ##__VA_ARGS__)
#else
#define TRACE(...)
#endif
musb_reset(s);
- usb_bus_new(&s->bus, &musb_bus_ops, parent_device);
+ usb_bus_new(&s->bus, sizeof(s->bus), &musb_bus_ops, parent_device);
usb_register_port(&s->bus, &s->port, s, 0, &musb_port_ops,
USB_SPEED_MASK_LOW | USB_SPEED_MASK_FULL);
timeout = ep->timeout[dir];
else if (ep->interrupt[dir])
timeout = 8;
- else
- return musb_cb_tick(ep);
+ else {
+ musb_cb_tick(ep);
+ return;
+ }
if (!ep->intv_timer[dir])
- ep->intv_timer[dir] = qemu_new_timer_ns(vm_clock, musb_cb_tick, ep);
+ ep->intv_timer[dir] = timer_new_ns(QEMU_CLOCK_VIRTUAL, musb_cb_tick, ep);
- qemu_mod_timer(ep->intv_timer[dir], qemu_get_clock_ns(vm_clock) +
- muldiv64(timeout, get_ticks_per_sec(), 8000));
+ timer_mod(ep->intv_timer[dir], qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) +
+ muldiv64(timeout, NANOSECONDS_PER_SECOND, 8000));
}
static int musb_timeout(int ttype, int speed, int val)
USBDevice *dev;
USBEndpoint *uep;
int idx = epnum && dir;
+ int id;
int ttype;
/* ep->type[0,1] contains:
/* A wild guess on the FADDR semantics... */
dev = usb_find_device(&s->port, ep->faddr[idx]);
+ if (dev == NULL) {
+ return;
+ }
uep = usb_ep_get(dev, pid, ep->type[idx] & 0xf);
- usb_packet_setup(&ep->packey[dir].p, pid, uep,
- (dev->addr << 16) | (uep->nr << 8) | pid, false, true);
+ id = pid | (dev->addr << 16) | (uep->nr << 8);
+ usb_packet_setup(&ep->packey[dir].p, pid, uep, 0, id, false, true);
usb_packet_addbuf(&ep->packey[dir].p, ep->buf[idx], len);
ep->packey[dir].ep = ep;
ep->packey[dir].dir = dir;
/* NAK timeouts are only generated in Bulk transfers and
* Data-errors in Isochronous. */
- if (ep->interrupt[1])
- return musb_packet(s, ep, epnum, USB_TOKEN_IN,
- packey->iov.size, musb_rx_packet_complete, 1);
+ if (ep->interrupt[1]) {
+ musb_packet(s, ep, epnum, USB_TOKEN_IN,
+ packey->iov.size, musb_rx_packet_complete, 1);
+ return;
+ }
ep->csr[1] |= MGC_M_RXCSR_DATAERROR;
if (!epnum)
* but it doesn't make sense for us to do that. */
}
- return musb_packet(s, ep, epnum, pid,
- total, musb_tx_packet_complete, 0);
+ musb_packet(s, ep, epnum, pid, total, musb_tx_packet_complete, 0);
}
static void musb_rx_req(MUSBState *s, int epnum)
}
#endif
- return musb_packet(s, ep, epnum, USB_TOKEN_IN,
- total, musb_rx_packet_complete, 1);
+ musb_packet(s, ep, epnum, USB_TOKEN_IN, total, musb_rx_packet_complete, 1);
}
static uint8_t musb_read_fifo(MUSBEndPoint *ep)
static void musb_ep_frame_cancel(MUSBEndPoint *ep, int dir)
{
if (ep->intv_timer[dir])
- qemu_del_timer(ep->intv_timer[dir]);
+ timer_del(ep->intv_timer[dir]);
}
/* Bus control */