socsvn commit: r253725 - in soc2013/syuu/bhyve_usb/usr.sbin/bhyve/usb: . include/hw

syuu at FreeBSD.org syuu at FreeBSD.org
Sun Jun 30 10:01:31 UTC 2013


Author: syuu
Date: Sun Jun 30 10:01:30 2013
New Revision: 253725
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=253725

Log:
  uncomment tracer, IOVector

Modified:
  soc2013/syuu/bhyve_usb/usr.sbin/bhyve/usb/core.c
  soc2013/syuu/bhyve_usb/usr.sbin/bhyve/usb/hcd-uhci.c
  soc2013/syuu/bhyve_usb/usr.sbin/bhyve/usb/include/hw/usb.h

Modified: soc2013/syuu/bhyve_usb/usr.sbin/bhyve/usb/core.c
==============================================================================
--- soc2013/syuu/bhyve_usb/usr.sbin/bhyve/usb/core.c	Sun Jun 30 08:59:33 2013	(r253724)
+++ soc2013/syuu/bhyve_usb/usr.sbin/bhyve/usb/core.c	Sun Jun 30 10:01:30 2013	(r253725)
@@ -24,10 +24,20 @@
  * THE SOFTWARE.
  */
 #include <string.h>
+#include <stdlib.h>
+#include <sys/socket.h>
 #include "hw/usb.h"
 
 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
 
+#define trace_usb_packet_state_fault(busnr, path, nr, p, state, expected) \
+    fprintf(stderr, "%s:%d trace_usb_packet_state_fault busnr=%d path=%s nr=%d p=%p state=%s expected=%s\n", \
+	__func__, __LINE__, busnr, path, nr, p, state, expected)
+#define trace_usb_packet_state_change(busnr, path, nr, p, state, expected) \
+    fprintf(stderr, "%s:%d trace_usb_packet_state_change busnr=%d path=%s nr=%d p=%p state=%s expected=%s\n", \
+	__func__, __LINE__, busnr, path, nr, p, state, expected)
+
+
 void usb_attach(USBPort *port)
 {
     USBDevice *dev = port->dev;
@@ -101,14 +111,12 @@
 {
     int request, value, index;
 
-#if 0
     if (p->iov.size != 8) {
         p->status = USB_RET_STALL;
         return;
     }
 
     usb_packet_copy(p, s->setup_buf, p->iov.size);
-#endif
     p->actual_length = 0;
     s->setup_len   = (s->setup_buf[7] << 8) | s->setup_buf[6];
     s->setup_index = 0;
@@ -174,11 +182,9 @@
     case SETUP_STATE_DATA:
         if (s->setup_buf[0] & USB_DIR_IN) {
             int len = s->setup_len - s->setup_index;
-#if 0
             if (len > p->iov.size) {
                 len = p->iov.size;
             }
-#endif
             usb_packet_copy(p, s->data_buf + s->setup_index, len);
             s->setup_index += len;
             if (s->setup_index >= s->setup_len) {
@@ -212,11 +218,9 @@
     case SETUP_STATE_DATA:
         if (!(s->setup_buf[0] & USB_DIR_IN)) {
             int len = s->setup_len - s->setup_index;
-#if 0
             if (len > p->iov.size) {
                 len = p->iov.size;
             }
-#endif
             usb_packet_copy(p, s->data_buf + s->setup_index, len);
             s->setup_index += len;
             if (s->setup_index >= s->setup_len) {
@@ -445,12 +449,10 @@
     assert(QTAILQ_FIRST(&ep->queue) == p);
     assert(p->status != USB_RET_ASYNC && p->status != USB_RET_NAK);
 
-#if 0
     if (p->status != USB_RET_SUCCESS ||
             (p->short_not_ok && (p->actual_length < p->iov.size))) {
         ep->halted = true;
     }
-#endif
     usb_packet_set_state(p, USB_PACKET_COMPLETE);
     QTAILQ_REMOVE(&ep->queue, p, queue);
     dev->port->ops->complete(dev->port, p);
@@ -504,7 +506,9 @@
 
 void usb_packet_init(USBPacket *p)
 {
-//    qemu_iovec_init(&p->iov, 1);
+	p->iov.iov = (struct iovec *)calloc(sizeof(struct iovec), 1);
+	p->iov.niov = p->iov.size = 0;
+	p->iov.nalloc = 1;
 }
 
 static const char *usb_packet_state_name(USBPacketState state)
@@ -533,30 +537,24 @@
     }
     dev = p->ep->dev;
     bus = usb_bus_from_device(dev);
-#if 0
     trace_usb_packet_state_fault(bus->busnr, dev->port->path, p->ep->nr, p,
                                  usb_packet_state_name(p->state),
                                  usb_packet_state_name(expected));
-#endif
     assert(!"usb packet state check failed");
 }
 
 void usb_packet_set_state(USBPacket *p, USBPacketState state)
 {
     if (p->ep) {
-#if 0
         USBDevice *dev = p->ep->dev;
         USBBus *bus = usb_bus_from_device(dev);
         trace_usb_packet_state_change(bus->busnr, dev->port->path, p->ep->nr, p,
                                       usb_packet_state_name(p->state),
                                       usb_packet_state_name(state));
-#endif
     } else {
-#if 0
         trace_usb_packet_state_change(-1, "", -1, p,
                                       usb_packet_state_name(p->state),
                                       usb_packet_state_name(state));
-#endif
     }
     p->state = state;
 }
@@ -566,7 +564,7 @@
                       uint64_t id, bool short_not_ok, bool int_req)
 {
     assert(!usb_packet_is_inflight(p));
-//    assert(p->iov.iov != NULL);
+    assert(p->iov.iov != NULL);
     p->id = id;
     p->pid = pid;
     p->ep = ep;
@@ -577,64 +575,72 @@
     p->short_not_ok = short_not_ok;
     p->int_req = int_req;
     p->combined = NULL;
-//    qemu_iovec_reset(&p->iov);
+    assert(p->iov.nalloc != -1);
+    p->iov.niov = 0;
+    p->iov.size = 0;
     usb_packet_set_state(p, USB_PACKET_SETUP);
 }
 
 void usb_packet_addbuf(USBPacket *p, void *ptr, size_t len)
 {
-//    qemu_iovec_add(&p->iov, ptr, len);
+	assert(p->iov.nalloc != -1);
+
+	if (p->iov.niov == p->iov.nalloc) {
+		p->iov.nalloc = 2 * p->iov.nalloc + 1;
+		p->iov.iov = (struct iovec *)realloc(p->iov.iov, sizeof(struct iovec) * p->iov.nalloc);
+	}
+	p->iov.iov[p->iov.niov].iov_base = ptr;
+	p->iov.iov[p->iov.niov].iov_len = len;
+	p->iov.size += len;
+	++p->iov.niov;
 }
 
 void usb_packet_copy(USBPacket *p, void *ptr, size_t bytes)
 {
-#if 0
-    QEMUIOVector *iov = p->combined ? &p->combined->iov : &p->iov;
+    IOVector *iov = p->combined ? &p->combined->iov : &p->iov;
 
     assert(p->actual_length >= 0);
     assert(p->actual_length + bytes <= iov->size);
     switch (p->pid) {
     case USB_TOKEN_SETUP:
     case USB_TOKEN_OUT:
-        iov_to_buf(iov->iov, iov->niov, p->actual_length, ptr, bytes);
+//        iov_to_buf(iov->iov, iov->niov, p->actual_length, ptr, bytes);
         break;
     case USB_TOKEN_IN:
-        iov_from_buf(iov->iov, iov->niov, p->actual_length, ptr, bytes);
+//        iov_from_buf(iov->iov, iov->niov, p->actual_length, ptr, bytes);
         break;
     default:
         fprintf(stderr, "%s: invalid pid: %x\n", __func__, p->pid);
         abort();
     }
     p->actual_length += bytes;
-#endif
 }
 
 void usb_packet_skip(USBPacket *p, size_t bytes)
 {
-#if 0
-    QEMUIOVector *iov = p->combined ? &p->combined->iov : &p->iov;
+    IOVector *iov = p->combined ? &p->combined->iov : &p->iov;
 
     assert(p->actual_length >= 0);
     assert(p->actual_length + bytes <= iov->size);
     if (p->pid == USB_TOKEN_IN) {
-        iov_memset(iov->iov, iov->niov, p->actual_length, 0, bytes);
+//        iov_memset(iov->iov, iov->niov, p->actual_length, 0, bytes);
     }
     p->actual_length += bytes;
-#endif
 }
 
 size_t usb_packet_size(USBPacket *p)
 {
-#if 0
     return p->combined ? p->combined->iov.size : p->iov.size;
-#endif
-    return 0;
 }
 
 void usb_packet_cleanup(USBPacket *p)
 {
     assert(!usb_packet_is_inflight(p));
-//    qemu_iovec_destroy(&p->iov);
+    assert(p->iov.nalloc != -1);
+
+    free(p->iov.iov);
+    p->iov.size = p->iov.niov = p->iov.nalloc = 0;
+    p->iov.iov = NULL;
 }
 
 void usb_ep_reset(USBDevice *dev)

Modified: soc2013/syuu/bhyve_usb/usr.sbin/bhyve/usb/hcd-uhci.c
==============================================================================
--- soc2013/syuu/bhyve_usb/usr.sbin/bhyve/usb/hcd-uhci.c	Sun Jun 30 08:59:33 2013	(r253724)
+++ soc2013/syuu/bhyve_usb/usr.sbin/bhyve/usb/hcd-uhci.c	Sun Jun 30 10:01:30 2013	(r253725)
@@ -28,10 +28,111 @@
 #include "hw/usb.h"
 #include <sys/endian.h>
 #include <stdlib.h>
+#include <dev/pci/pcireg.h>
 
 #define le32_to_cpus(x) le32toh(x)
 #define cpu_to_le32(x) htole32(x)
 
+#define PCI_CLASS_PROG PCIR_PROGIF
+
+#define PCI_VENDOR_ID_INTEL 0x8086
+#define PCI_DEVICE_ID_INTEL_82801I_UHCI3 0x2936
+#define PCI_DEVICE_ID_INTEL_82801I_UHCI4 0x2937
+#define PCI_DEVICE_ID_INTEL_82801I_UHCI5 0x2938
+#define PCI_DEVICE_ID_INTEL_82801I_UHCI6 0x2939
+#define PCI_DEVICE_ID_INTEL_82371SB_2 0x7020
+#define PCI_DEVICE_ID_INTEL_82371AB_2 0x7112
+
+struct PCIDevice {
+	uint8_t *config;
+};
+struct PCIDeviceClass {
+};
+struct MemoryRegion {
+};
+typedef struct PCIDevice PCIDevice;
+typedef struct PCIDeviceClass PCIDeviceClass;
+typedef struct MemoryRegion MemoryRegion;
+
+#define trace_usb_uhci_queue_add(token) \
+    fprintf(stderr, "%s:%d trace_usb_uhci_queue_add token=%x\n", \
+	__func__, __LINE__, token)
+#define trace_usb_uhci_queue_del(token, reason) \
+    fprintf(stderr, "%s:%d trace_usb_uhci_queue_del token=%x reason=%s\n", \
+	__func__, __LINE__, token, reason)
+#define trace_usb_uhci_packet_add(token, td_addr) \
+    fprintf(stderr, "%s:%d trace_usb_uhci_packet_add token=%x td_addr=%x\n", \
+	__func__, __LINE__, token, td_addr)
+#define trace_usb_uhci_packet_cancel(token, td_addr, done) \
+    fprintf(stderr, "%s:%d trace_usb_uhci_packet_cancel token=%x td_addr=%x done=%x\n", \
+	__func__, __LINE__, token, td_addr, done)
+#define trace_usb_uhci_packet_link_async(token, td_addr) \
+    fprintf(stderr, "%s:%d trace_usb_uhci_packet_link_async token=%x td_addr=%x\n", \
+	__func__, __LINE__, token, td_addr)
+#define trace_usb_uhci_packet_unlink_async(token, td_addr) \
+    fprintf(stderr, "%s:%d trace_usb_uhci_packet_unlink_async token=%x td_addr=%x\n", \
+	__func__, __LINE__, token, td_addr)
+#define trace_usb_uhci_reset() \
+    fprintf(stderr, "%s:%d trace_usb_uhci_reset\n", \
+	__func__, __LINE__)
+#define trace_usb_uhci_mmio_writew(addr, val) \
+    fprintf(stderr, "%s:%d trace_usb_uhci_mmio_writew addr=%lx val=%lx\n", \
+	__func__, __LINE__, addr, val)
+#define trace_usb_uhci_mmio_readw(addr, val) \
+    fprintf(stderr, "%s:%d trace_usb_uhci_mmio_readw addr=%lx val=%x\n", \
+	__func__, __LINE__, addr, val)
+#define trace_usb_uhci_schedule_start() \
+    fprintf(stderr, "%s:%d trace_usb_uhci_schedule_start\n", \
+	__func__, __LINE__)
+#define trace_usb_uhci_packet_complete_stall(token, td_addr) \
+    fprintf(stderr, "%s:%d trace_usb_uhci_packet_complete_stall token=%x td_addr=%x\n", \
+	__func__, __LINE__, token, td_addr)
+#define trace_usb_uhci_packet_complete_babble(token, td_addr) \
+    fprintf(stderr, "%s:%d trace_usb_uhci_packet_complete_babble token=%x td_addr=%x\n", \
+	__func__, __LINE__, token, td_addr)
+#define trace_usb_uhci_packet_complete_error(token, td_addr) \
+    fprintf(stderr, "%s:%d trace_usb_uhci_packet_complete_error token=%x td_addr=%x\n", \
+	__func__, __LINE__, token, td_addr)
+#define trace_usb_uhci_packet_complete_shortxfer(token, td_addr) \
+    fprintf(stderr, "%s:%d trace_usb_uhci_packet_complete_shortxfer token=%x td_addr=%x\n", \
+	__func__, __LINE__, token, td_addr)
+#define trace_usb_uhci_packet_complete_success(token, td_addr) \
+    fprintf(stderr, "%s:%d trace_usb_uhci_packet_complete_success token=%x td_addr=%x\n", \
+	__func__, __LINE__, token, td_addr)
+#define trace_usb_uhci_td_queue(link, ctrl, token) \
+    fprintf(stderr, "%s:%d trace_usb_uhci_td_queue link=%x ctrl=%x token=%x\n", \
+	__func__, __LINE__, link, ctrl, token)
+#define trace_usb_uhci_frame_stop_bandwidth() \
+    fprintf(stderr, "%s:%d trace_usb_uhci_frame_stop_bandwidth\n", \
+	__func__, __LINE__)
+#define trace_usb_uhci_qh_load(link) \
+    fprintf(stderr, "%s:%d trace_usb_uhci_qh_load link=%x\n", \
+	__func__, __LINE__, link)
+#define trace_usb_uhci_frame_loop_stop_idle() \
+    fprintf(stderr, "%s:%d trace_usb_uhci_frame_loop_stop_idle\n", \
+	__func__, __LINE__)
+#define trace_usb_uhci_frame_loop_continue() \
+    fprintf(stderr, "%s:%d trace_usb_uhci_frame_loop_continue\n", \
+	__func__, __LINE__)
+#define trace_usb_uhci_td_load(qh, link, ctrl, token) \
+    fprintf(stderr, "%s:%d trace_usb_uhci_td_load qh=%x link=%x ctrl=%x token=%x\n", \
+	__func__, __LINE__, qh, link, ctrl, token)
+#define trace_usb_uhci_td_nextqh(qh, link) \
+    fprintf(stderr, "%s:%d trace_usb_uhci_td_nextqh qh=%x link=%x\n", \
+	__func__, __LINE__, qh, link)
+#define trace_usb_uhci_td_async(qh, link) \
+    fprintf(stderr, "%s:%d trace_usb_uhci_td_async qh=%x link=%x\n", \
+	__func__, __LINE__, qh, link)
+#define trace_usb_uhci_td_complete(qh, link) \
+    fprintf(stderr, "%s:%d trace_usb_uhci_td_complete qh=%x link=%x\n", \
+	__func__, __LINE__, qh, link)
+#define trace_usb_uhci_schedule_stop() \
+    fprintf(stderr, "%s:%d trace_usb_uhci_schedule_stop\n", \
+	__func__, __LINE__)
+#define trace_usb_uhci_frame_start(num) \
+    fprintf(stderr, "%s:%d trace_usb_uhci_frame_start num=%d\n", \
+	__func__, __LINE__, num)
+
 //#define DEBUG
 //#define DEBUG_DUMP_DATA
 
@@ -101,12 +202,12 @@
     uint16_t   device_id;
     uint8_t    revision;
     uint8_t    irq_pin;
-//    int        (*initfn)(PCIDevice *dev);
+    int        (*initfn)(PCIDevice *dev);
     bool       unplug;
 };
 
 struct UHCIPCIDeviceClass {
-//    PCIDeviceClass parent_class;
+    PCIDeviceClass parent_class;
     UHCIInfo       info;
 };
 
@@ -142,8 +243,8 @@
 } UHCIPort;
 
 struct UHCIState {
-//    PCIDevice dev;
-//    MemoryRegion io_bar;
+    PCIDevice dev;
+    MemoryRegion io_bar;
     USBBus bus; /* Note unused when we're a companion controller */
     uint16_t cmd; /* cmd register */
     uint16_t status;
@@ -213,7 +314,7 @@
     QTAILQ_INIT(&queue->asyncs);
     QTAILQ_INSERT_HEAD(&s->queues, queue, next);
     queue->valid = QH_VALID;
-//    trace_usb_uhci_queue_add(queue->token);
+    trace_usb_uhci_queue_add(queue->token);
     return queue;
 }
 
@@ -228,7 +329,7 @@
     }
     usb_device_ep_stopped(queue->ep->dev, queue->ep);
 
-//    trace_usb_uhci_queue_del(queue->token, reason);
+    trace_usb_uhci_queue_del(queue->token, reason);
     QTAILQ_REMOVE(&s->queues, queue, next);
     free(queue);
 }
@@ -264,7 +365,7 @@
     async->queue = queue;
     async->td_addr = td_addr;
     usb_packet_init(&async->packet);
-//    trace_usb_uhci_packet_add(async->queue->token, async->td_addr);
+    trace_usb_uhci_packet_add(async->queue->token, async->td_addr);
 
     return async;
 }
@@ -283,21 +384,21 @@
 {
     UHCIQueue *queue = async->queue;
     QTAILQ_INSERT_TAIL(&queue->asyncs, async, next);
-//    trace_usb_uhci_packet_link_async(async->queue->token, async->td_addr);
+    trace_usb_uhci_packet_link_async(async->queue->token, async->td_addr);
 }
 
 static void uhci_async_unlink(UHCIAsync *async)
 {
     UHCIQueue *queue = async->queue;
     QTAILQ_REMOVE(&queue->asyncs, async, next);
-//    trace_usb_uhci_packet_unlink_async(async->queue->token, async->td_addr);
+    trace_usb_uhci_packet_unlink_async(async->queue->token, async->td_addr);
 }
 
 static void uhci_async_cancel(UHCIAsync *async)
 {
     uhci_async_unlink(async);
-//    trace_usb_uhci_packet_cancel(async->queue->token, async->td_addr,
-//                                 async->done);
+    trace_usb_uhci_packet_cancel(async->queue->token, async->td_addr,
+                                 async->done);
     if (!async->done)
         usb_cancel_packet(&async->packet);
     uhci_async_free(async);
@@ -388,9 +489,9 @@
     int i;
     UHCIPort *port;
 
-//    trace_usb_uhci_reset();
+    trace_usb_uhci_reset();
 
- //   pci_conf = s->dev.config;
+    pci_conf = s->dev.config;
 
     pci_conf[0x6a] = 0x01; /* usb clock */
     pci_conf[0x6b] = 0x00;
@@ -472,13 +573,13 @@
 {
     UHCIState *s = opaque;
 
-//    trace_usb_uhci_mmio_writew(addr, val);
+    trace_usb_uhci_mmio_writew(addr, val);
 
     switch(addr) {
     case 0x00:
         if ((val & UHCI_CMD_RS) && !(s->cmd & UHCI_CMD_RS)) {
             /* start frame processing */
-//            trace_usb_uhci_schedule_start();
+            trace_usb_uhci_schedule_start();
 //            s->expire_time = qemu_get_clock_ns(vm_clock) +
 //                (get_ticks_per_sec() / FRAME_TIMER_FREQ);
 //            qemu_mod_timer(s->frame_timer, s->expire_time);
@@ -606,7 +707,7 @@
         break;
     }
 
-//    trace_usb_uhci_mmio_readw(addr, val);
+    trace_usb_uhci_mmio_readw(addr, val);
 
     return val;
 }
@@ -713,7 +814,7 @@
 static int uhci_handle_td_error(UHCIState *s, UHCI_TD *td, uint32_t td_addr,
                                 int status, uint32_t *int_mask)
 {
-//    uint32_t queue_token = uhci_queue_token(td);
+    uint32_t queue_token /*= uhci_queue_token(td) */;
     int ret;
 
     switch (status) {
@@ -723,14 +824,14 @@
 
     case USB_RET_STALL:
         td->ctrl |= TD_CTRL_STALL;
-//        trace_usb_uhci_packet_complete_stall(queue_token, td_addr);
+        trace_usb_uhci_packet_complete_stall(queue_token, td_addr);
         ret = TD_RESULT_NEXT_QH;
         break;
 
     case USB_RET_BABBLE:
         td->ctrl |= TD_CTRL_BABBLE | TD_CTRL_STALL;
         /* frame interrupted */
-//        trace_usb_uhci_packet_complete_babble(queue_token, td_addr);
+        trace_usb_uhci_packet_complete_babble(queue_token, td_addr);
         ret = TD_RESULT_STOP_FRAME;
         break;
 
@@ -739,7 +840,7 @@
     default:
         td->ctrl |= TD_CTRL_TIMEOUT;
         td->ctrl &= ~(3 << TD_CTRL_ERROR_SHIFT);
-//        trace_usb_uhci_packet_complete_error(queue_token, td_addr);
+        trace_usb_uhci_packet_complete_error(queue_token, td_addr);
         ret = TD_RESULT_NEXT_QH;
         break;
     }
@@ -784,19 +885,15 @@
         if ((td->ctrl & TD_CTRL_SPD) && len < max_len) {
             *int_mask |= 0x02;
             /* short packet: do not update QH */
-#if 0
             trace_usb_uhci_packet_complete_shortxfer(async->queue->token,
                                                      async->td_addr);
-#endif
             return TD_RESULT_NEXT_QH;
         }
     }
 
     /* success */
-#if 0
     trace_usb_uhci_packet_complete_success(async->queue->token,
                                            async->td_addr);
-#endif
     return TD_RESULT_COMPLETE;
 }
 
@@ -1008,7 +1105,7 @@
         if (uhci_queue_token(&ptd) != q->token) {
             break;
         }
-//        trace_usb_uhci_td_queue(plink & ~0xf, ptd.ctrl, ptd.token);
+        trace_usb_uhci_td_queue(plink & ~0xf, ptd.ctrl, ptd.token);
         ret = uhci_handle_td(q->uhci, q, q->qh_addr, &ptd, plink, &int_mask);
         if (ret == TD_RESULT_ASYNC_CONT) {
             break;
@@ -1043,12 +1140,12 @@
         if (!s->completions_only && s->frame_bytes >= s->frame_bandwidth) {
             /* We've reached the usb 1.1 bandwidth, which is
                1280 bytes/frame, stop processing */
-//            trace_usb_uhci_frame_stop_bandwidth();
+            trace_usb_uhci_frame_stop_bandwidth();
             break;
         }
         if (is_qh(link)) {
             /* QH */
-//            trace_usb_uhci_qh_load(link & ~0xf);
+            trace_usb_uhci_qh_load(link & ~0xf);
 
             if (qhdb_insert(&qhdb, link)) {
                 /*
@@ -1059,10 +1156,10 @@
                  * since we've been here last time.
                  */
                 if (td_count == 0) {
-//                    trace_usb_uhci_frame_loop_stop_idle();
+                    trace_usb_uhci_frame_loop_stop_idle();
                     break;
                 } else {
-//                    trace_usb_uhci_frame_loop_continue();
+                    trace_usb_uhci_frame_loop_continue();
                     td_count = 0;
                     qhdb_reset(&qhdb);
                     qhdb_insert(&qhdb, link);
@@ -1087,7 +1184,7 @@
 
         /* TD */
         uhci_read_td(s, &td, link);
-//        trace_usb_uhci_td_load(curr_qh & ~0xf, link & ~0xf, td.ctrl, td.token);
+        trace_usb_uhci_td_load(curr_qh & ~0xf, link & ~0xf, td.ctrl, td.token);
 
         old_td_ctrl = td.ctrl;
         ret = uhci_handle_td(s, NULL, curr_qh, &td, link, &int_mask);
@@ -1103,17 +1200,17 @@
 
         case TD_RESULT_NEXT_QH:
         case TD_RESULT_ASYNC_CONT:
-//            trace_usb_uhci_td_nextqh(curr_qh & ~0xf, link & ~0xf);
+            trace_usb_uhci_td_nextqh(curr_qh & ~0xf, link & ~0xf);
             link = curr_qh ? qh.link : td.link;
             continue;
 
         case TD_RESULT_ASYNC_START:
-//            trace_usb_uhci_td_async(curr_qh & ~0xf, link & ~0xf);
+            trace_usb_uhci_td_async(curr_qh & ~0xf, link & ~0xf);
             link = curr_qh ? qh.link : td.link;
             continue;
 
         case TD_RESULT_COMPLETE:
-//            trace_usb_uhci_td_complete(curr_qh & ~0xf, link & ~0xf);
+            trace_usb_uhci_td_complete(curr_qh & ~0xf, link & ~0xf);
             link = td.link;
             td_count++;
             s->frame_bytes += (td.ctrl & 0x7ff) + 1;
@@ -1161,7 +1258,7 @@
 
     if (!(s->cmd & UHCI_CMD_RS)) {
         /* Full stop */
-//        trace_usb_uhci_schedule_stop();
+        trace_usb_uhci_schedule_stop();
 //        qemu_del_timer(s->frame_timer);
         uhci_async_cancel_all(s);
         /* set hchalted bit in status - UHCI11D 2.1.2 */
@@ -1187,7 +1284,7 @@
 
     for (i = 0; i < frames; i++) {
         s->frame_bytes = 0;
-//        trace_usb_uhci_frame_start(s->frnum);
+        trace_usb_uhci_frame_start(s->frnum);
         uhci_async_validate_begin(s);
         uhci_process_frame(s);
         uhci_async_validate_end(s);
@@ -1226,15 +1323,14 @@
     .wakeup = uhci_wakeup,
     .complete = uhci_async_complete,
 };
-*/
 
-#if 0
 static USBBusOps uhci_bus_ops = {
 };
+*/
 static int usb_uhci_common_initfn(PCIDevice *dev)
 {
-    PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(dev);
-    UHCIPCIDeviceClass *u = container_of(pc, UHCIPCIDeviceClass, parent_class);
+//    PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(dev);
+//    UHCIPCIDeviceClass *u = container_of(pc, UHCIPCIDeviceClass, parent_class);
     UHCIState *s = DO_UPCAST(UHCIState, dev, dev);
     uint8_t *pci_conf = s->dev.config;
     int i;
@@ -1243,8 +1339,8 @@
     /* TODO: reset value should be 0. */
     pci_conf[USB_SBRN] = USB_RELEASE_1; // release number
 
-    s->irq_pin = u->info.irq_pin;
-    pci_config_set_interrupt_pin(pci_conf, s->irq_pin + 1);
+//    s->irq_pin = u->info.irq_pin;
+//    pci_config_set_interrupt_pin(pci_conf, s->irq_pin + 1);
 
     if (s->masterbus) {
         USBPort *ports[NB_PORTS];
@@ -1252,32 +1348,31 @@
             ports[i] = &s->ports[i].port;
         }
         if (usb_register_companion(s->masterbus, ports, NB_PORTS,
-                s->firstport, s, &uhci_port_ops,
+                s->firstport, s, /*&uhci_port_ops*/ NULL,
                 USB_SPEED_MASK_LOW | USB_SPEED_MASK_FULL) != 0) {
             return -1;
         }
     } else {
-        usb_bus_new(&s->bus, &uhci_bus_ops, &s->dev.qdev);
+//        usb_bus_new(&s->bus, &uhci_bus_ops, &s->dev.qdev);
         for (i = 0; i < NB_PORTS; i++) {
-            usb_register_port(&s->bus, &s->ports[i].port, s, i, &uhci_port_ops,
+            usb_register_port(&s->bus, &s->ports[i].port, s, i, /*&uhci_port_ops*/NULL,
                               USB_SPEED_MASK_LOW | USB_SPEED_MASK_FULL);
         }
     }
-    s->bh = qemu_bh_new(uhci_bh, s);
-    s->frame_timer = qemu_new_timer_ns(vm_clock, uhci_frame_timer, s);
+//    s->bh = qemu_bh_new(uhci_bh, s);
+//    s->frame_timer = qemu_new_timer_ns(vm_clock, uhci_frame_timer, s);
     s->num_ports_vmstate = NB_PORTS;
     QTAILQ_INIT(&s->queues);
 
-    qemu_register_reset(uhci_reset, s);
+//    qemu_register_reset(uhci_reset, s);
 
-    memory_region_init_io(&s->io_bar, &uhci_ioport_ops, s, "uhci", 0x20);
+//    memory_region_init_io(&s->io_bar, &uhci_ioport_ops, s, "uhci", 0x20);
     /* Use region 4 for consistency with real hardware.  BSD guests seem
        to rely on this.  */
-    pci_register_bar(&s->dev, 4, PCI_BASE_ADDRESS_SPACE_IO, &s->io_bar);
+//    pci_register_bar(&s->dev, 4, PCI_BASE_ADDRESS_SPACE_IO, &s->io_bar);
 
     return 0;
 }
-#endif
 #if 0
 static int usb_uhci_vt82c686b_initfn(PCIDevice *dev)
 {
@@ -1295,14 +1390,14 @@
 }
 #endif
 
-#if 0
 static void usb_uhci_exit(PCIDevice *dev)
 {
+#if 0
     UHCIState *s = DO_UPCAST(UHCIState, dev, dev);
 
     memory_region_destroy(&s->io_bar);
-}
 #endif
+}
 
 #if 0
 static Property uhci_properties[] = {

Modified: soc2013/syuu/bhyve_usb/usr.sbin/bhyve/usb/include/hw/usb.h
==============================================================================
--- soc2013/syuu/bhyve_usb/usr.sbin/bhyve/usb/include/hw/usb.h	Sun Jun 30 08:59:33 2013	(r253724)
+++ soc2013/syuu/bhyve_usb/usr.sbin/bhyve/usb/include/hw/usb.h	Sun Jun 30 10:01:30 2013	(r253725)
@@ -30,8 +30,12 @@
 #include <stdint.h>
 #include <stdbool.h>
 #include <assert.h>
+#include <stddef.h>
 #include "qemu/queue.h"
 
+#define container_of(p, stype, field) ((stype *)(((uint8_t *)(p)) - offsetof(stype, field)))
+#define DO_UPCAST(type, field, dev) container_of(dev, type, field)
+
 typedef uint64_t hwaddr;
 
 /* Constants related to the USB / PCI interaction */
@@ -363,6 +367,14 @@
     USB_PACKET_CANCELED,
 } USBPacketState;
 
+struct IOVector {
+    struct iovec *iov;
+    int niov;
+    int nalloc;
+    size_t size;
+};
+typedef struct IOVector IOVector;
+
 /* Structure used to hold information about an active USB packet.  */
 struct USBPacket {
     /* Data fields for use by the driver.  */
@@ -370,7 +382,7 @@
     uint64_t id;
     USBEndpoint *ep;
     unsigned int stream;
-//    QEMUIOVector iov;
+    struct IOVector iov;
     uint64_t parameter; /* control transfers */
     bool short_not_ok;
     bool int_req;
@@ -386,7 +398,7 @@
 struct USBCombinedPacket {
     USBPacket *first;
     QTAILQ_HEAD(packets_head, USBPacket) packets;
-//    QEMUIOVector iov;
+    IOVector iov;
 };
 
 void usb_packet_init(USBPacket *p);


More information about the svn-soc-all mailing list