qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/7] Misc fixes from maemo qemu
@ 2009-12-03 13:56 riku.voipio
  2009-12-03 13:56 ` [Qemu-devel] [PATCH 1/7] Fix win32 log file location riku.voipio
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: riku.voipio @ 2009-12-03 13:56 UTC (permalink / raw)
  To: qemu-devel; +Cc: Riku Voipio

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 754 bytes --]

From: Riku Voipio <riku.voipio@nokia.com>

Collection of lingering qemu fixes from maemo qemu. probably
worth pushing to 0.12

Juha Riihimäki (4):
  Fix win32 log file location
  fix pidfile option to work in WIN32
  handle SD CMD5 without error messages
  fix networking on win32 host

Riku Voipio (3):
  Give a error when running out of iomem areas.
  Make devices self-powered
  usb-musb: convert fifo to 8bit and add more registers

 exec.c        |    6 ++-
 hw/sd.c       |    4 ++
 hw/usb-hid.c  |    2 +-
 hw/usb-hub.c  |    2 +-
 hw/usb-musb.c |  164 +++++++++++++++++++++++++++++++++++++--------------------
 osdep.c       |   13 +----
 slirp/ip.h    |   14 +++---
 vl.c          |    4 +-
 8 files changed, 130 insertions(+), 79 deletions(-)

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Qemu-devel] [PATCH 1/7] Fix win32 log file location
  2009-12-03 13:56 [Qemu-devel] [PATCH 0/7] Misc fixes from maemo qemu riku.voipio
@ 2009-12-03 13:56 ` riku.voipio
  2009-12-03 13:56 ` [Qemu-devel] [PATCH 2/7] fix pidfile option to work in WIN32 riku.voipio
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: riku.voipio @ 2009-12-03 13:56 UTC (permalink / raw)
  To: qemu-devel; +Cc: Riku Voipio, Juha Riihimäki

From: Juha Riihimäki <juha.riihimaki@nokia.com>

/tmp doesn't exist under win32. Ease the pain of win32 development slightly.

From: Juha Riihimäki <juha.riihimaki@nokia.com>
Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
---
 exec.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/exec.c b/exec.c
index eb1ee51..3f33b08 100644
--- a/exec.c
+++ b/exec.c
@@ -192,7 +192,11 @@ static int io_mem_watch;
 #endif
 
 /* log support */
+#ifdef WIN32
+static const char *logfilename = "qemu.log";
+#else
 static const char *logfilename = "/tmp/qemu.log";
+#endif
 FILE *logfile;
 int loglevel;
 static int log_append = 0;
-- 
1.6.3.3

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Qemu-devel] [PATCH 2/7] fix pidfile option to work in WIN32
  2009-12-03 13:56 [Qemu-devel] [PATCH 0/7] Misc fixes from maemo qemu riku.voipio
  2009-12-03 13:56 ` [Qemu-devel] [PATCH 1/7] Fix win32 log file location riku.voipio
@ 2009-12-03 13:56 ` riku.voipio
  2009-12-03 13:56 ` [Qemu-devel] [PATCH 3/7] fix networking on win32 host riku.voipio
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: riku.voipio @ 2009-12-03 13:56 UTC (permalink / raw)
  To: qemu-devel; +Cc: Riku Voipio, Juha Riihimäki

From: Juha Riihimäki <juha.riihimaki@nokia.com>

Excplicit read/write locking pidfile under WIN32 is bit extreme
nobody get the chance to read the pidfile. Convert to a write-only lock.

Also, creating pidfile was disabled along with daemonize under
WIN32. Enable it, but do not enable daemon support which doesn't
exist under WIN32 atm.

From: Juha Riihimäki <juha.riihimaki@nokia.com>
Signed-off-by: Juha Riihimäki <juha.riihimaki@nokia.com>
Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
---
 osdep.c |   13 ++-----------
 vl.c    |    4 +++-
 2 files changed, 5 insertions(+), 12 deletions(-)

diff --git a/osdep.c b/osdep.c
index fd8bbd7..2ecffab 100644
--- a/osdep.c
+++ b/osdep.c
@@ -133,25 +133,16 @@ int qemu_create_pidfile(const char *filename)
         return -1;
 #else
     HANDLE file;
-    DWORD flags;
     OVERLAPPED overlap;
     BOOL ret;
+    memset(&overlap, 0, sizeof(overlap));
 
-    /* Open for writing with no sharing. */
-    file = CreateFile(filename, GENERIC_WRITE, 0, NULL,
+    file = CreateFile(filename, GENERIC_WRITE, FILE_SHARE_READ, NULL,
 		      OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
 
     if (file == INVALID_HANDLE_VALUE)
       return -1;
 
-    flags = LOCKFILE_EXCLUSIVE_LOCK | LOCKFILE_FAIL_IMMEDIATELY;
-    overlap.hEvent = 0;
-    /* Lock 1 byte. */
-    ret = LockFileEx(file, flags, 0, 0, 1, &overlap);
-    if (ret == 0)
-      return -1;
-
-    /* Write PID to file. */
     len = snprintf(buffer, sizeof(buffer), "%ld\n", (long)getpid());
     ret = WriteFileEx(file, (LPCVOID)buffer, (DWORD)len,
 		      &overlap, NULL);
diff --git a/vl.c b/vl.c
index 44763af..11f6ad0 100644
--- a/vl.c
+++ b/vl.c
@@ -5471,16 +5471,18 @@ int main(int argc, char **argv, char **envp)
         signal(SIGTTOU, SIG_IGN);
         signal(SIGTTIN, SIG_IGN);
     }
+#endif
 
     if (pid_file && qemu_create_pidfile(pid_file) != 0) {
+#ifndef _WIN32
         if (daemonize) {
             uint8_t status = 1;
             write(fds[1], &status, 1);
         } else
+#endif
             fprintf(stderr, "Could not acquire pid file: %s\n", strerror(errno));
         exit(1);
     }
-#endif
 
     if (kvm_enabled()) {
         int ret;
-- 
1.6.3.3

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Qemu-devel] [PATCH 3/7] fix networking on win32 host
  2009-12-03 13:56 [Qemu-devel] [PATCH 0/7] Misc fixes from maemo qemu riku.voipio
  2009-12-03 13:56 ` [Qemu-devel] [PATCH 1/7] Fix win32 log file location riku.voipio
  2009-12-03 13:56 ` [Qemu-devel] [PATCH 2/7] fix pidfile option to work in WIN32 riku.voipio
@ 2009-12-03 13:56 ` riku.voipio
  2009-12-03 13:56 ` [Qemu-devel] [PATCH 4/7] Give a error when running out of iomem areas riku.voipio
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: riku.voipio @ 2009-12-03 13:56 UTC (permalink / raw)
  To: qemu-devel; +Cc: Riku Voipio, Juha Riihimäki

From: Juha Riihimäki <juha.riihimaki@nokia.com>

At least under some mingw compilers slirp networking fails without declaring
these fields packed.

From: Juha Riihimäki <juha.riihimaki@nokia.com>
Signed-off-by: Juha Riihimäki <juha.riihimaki@nokia.com>
Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
---
 slirp/ip.h |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/slirp/ip.h b/slirp/ip.h
index 5074e33..8d185a1 100644
--- a/slirp/ip.h
+++ b/slirp/ip.h
@@ -91,7 +91,7 @@ struct ip {
 	u_int8_t ip_p;			/* protocol */
 	u_int16_t	ip_sum;			/* checksum */
 	struct	in_addr ip_src,ip_dst;	/* source and dest address */
-};
+} __attribute__((packed));
 
 #define	IP_MAXPACKET	65535		/* maximum packet size */
 
@@ -153,7 +153,7 @@ struct	ip_timestamp {
 			n_long ipt_time;
 		} ipt_ta[1];
 	} ipt_timestamp;
-};
+} __attribute__((packed));
 
 /* flag bits for ipt_flg */
 #define	IPOPT_TS_TSONLY		0		/* timestamps only */
@@ -183,11 +183,11 @@ struct	ip_timestamp {
 struct mbuf_ptr {
 	struct mbuf *mptr;
 	uint32_t dummy;
-};
+} __attribute__((packed));
 #else
 struct mbuf_ptr {
 	struct mbuf *mptr;
-};
+} __attribute__((packed));
 #endif
 struct qlink {
 	void *next, *prev;
@@ -219,7 +219,7 @@ struct ipq {
 	u_int8_t	ipq_p;			/* protocol of this fragment */
 	u_int16_t	ipq_id;			/* sequence id for reassembly */
 	struct	in_addr ipq_src,ipq_dst;
-};
+} __attribute__((packed));
 
 /*
  * Ip header, when holding a fragment.
@@ -229,7 +229,7 @@ struct ipq {
 struct	ipasfrag {
 	struct qlink ipf_link;
 	struct ip ipf_ip;
-};
+} __attribute__((packed));
 
 #define ipf_off      ipf_ip.ip_off
 #define ipf_tos      ipf_ip.ip_tos
@@ -248,6 +248,6 @@ struct	ipasfrag {
 struct ipoption {
 	struct	in_addr ipopt_dst;	/* first-hop dst if source routed */
 	int8_t	ipopt_list[MAX_IPOPTLEN];	/* options proper */
-};
+} __attribute__((packed));
 
 #endif
-- 
1.6.3.3

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Qemu-devel] [PATCH 4/7] Give a error when running out of iomem areas.
  2009-12-03 13:56 [Qemu-devel] [PATCH 0/7] Misc fixes from maemo qemu riku.voipio
                   ` (2 preceding siblings ...)
  2009-12-03 13:56 ` [Qemu-devel] [PATCH 3/7] fix networking on win32 host riku.voipio
@ 2009-12-03 13:56 ` riku.voipio
  2009-12-03 13:56 ` [Qemu-devel] [PATCH 5/7] Make USB hid devices self-powered riku.voipio
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: riku.voipio @ 2009-12-03 13:56 UTC (permalink / raw)
  To: qemu-devel; +Cc: Riku Voipio

From: Riku Voipio <riku.voipio@nokia.com>

The limit of iomem areas is quite low. Without the
debug print, it is quite hard to figure out why more
devices are not getting registered.

Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
---
 exec.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/exec.c b/exec.c
index 3f33b08..befbcb7 100644
--- a/exec.c
+++ b/exec.c
@@ -2913,7 +2913,7 @@ static int get_free_io_mem_idx(void)
             io_mem_used[i] = 1;
             return i;
         }
-
+    fprintf(stderr, "RAN out out io_mem_idx, max %d !\n", IO_MEM_NB_ENTRIES);
     return -1;
 }
 
-- 
1.6.3.3

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Qemu-devel] [PATCH 5/7] Make USB hid devices self-powered
  2009-12-03 13:56 [Qemu-devel] [PATCH 0/7] Misc fixes from maemo qemu riku.voipio
                   ` (3 preceding siblings ...)
  2009-12-03 13:56 ` [Qemu-devel] [PATCH 4/7] Give a error when running out of iomem areas riku.voipio
@ 2009-12-03 13:56 ` riku.voipio
  2009-12-03 13:56 ` [Qemu-devel] [PATCH 6/7] handle SD CMD5 without error messages riku.voipio
  2009-12-03 13:56 ` [Qemu-devel] [PATCH 7/7] usb-musb: convert fifo to 8bit and add more registers riku.voipio
  6 siblings, 0 replies; 8+ messages in thread
From: riku.voipio @ 2009-12-03 13:56 UTC (permalink / raw)
  To: qemu-devel; +Cc: Riku Voipio

From: Riku Voipio <riku.voipio@nokia.com>

Simplifies power budget negotiation.

Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
---
 hw/usb-hid.c |    2 +-
 hw/usb-hub.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/usb-hid.c b/hw/usb-hid.c
index f4a2a48..b099ae7 100644
--- a/hw/usb-hid.c
+++ b/hw/usb-hid.c
@@ -100,7 +100,7 @@ static const uint8_t qemu_mouse_config_descriptor[] = {
 	0x01,       /*  u8  bNumInterfaces; (1) */
 	0x01,       /*  u8  bConfigurationValue; */
 	0x04,       /*  u8  iConfiguration; */
-	0xa0,       /*  u8  bmAttributes;
+	0xe0,       /*  u8  bmAttributes;
 				 Bit 7: must be set,
 				     6: Self-powered,
 				     5: Remote wakeup,
diff --git a/hw/usb-hub.c b/hw/usb-hub.c
index e5a0938..f252301 100644
--- a/hw/usb-hub.c
+++ b/hw/usb-hub.c
@@ -113,7 +113,7 @@ static const uint8_t qemu_hub_config_descriptor[] = {
 	0x01,       /*  u8  bNumInterfaces; (1) */
 	0x01,       /*  u8  bConfigurationValue; */
 	0x00,       /*  u8  iConfiguration; */
-	0xc0,       /*  u8  bmAttributes;
+	0xe0,       /*  u8  bmAttributes;
 				 Bit 7: must be set,
 				     6: Self-powered,
 				     5: Remote wakeup,
-- 
1.6.3.3

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Qemu-devel] [PATCH 6/7] handle SD CMD5 without error messages
  2009-12-03 13:56 [Qemu-devel] [PATCH 0/7] Misc fixes from maemo qemu riku.voipio
                   ` (4 preceding siblings ...)
  2009-12-03 13:56 ` [Qemu-devel] [PATCH 5/7] Make USB hid devices self-powered riku.voipio
@ 2009-12-03 13:56 ` riku.voipio
  2009-12-03 13:56 ` [Qemu-devel] [PATCH 7/7] usb-musb: convert fifo to 8bit and add more registers riku.voipio
  6 siblings, 0 replies; 8+ messages in thread
From: riku.voipio @ 2009-12-03 13:56 UTC (permalink / raw)
  To: qemu-devel; +Cc: Riku Voipio, Juha Riihimäki

From: Juha Riihimäki <juha.riihimaki@nokia.com>

From: Juha Riihimäki <juha.riihimaki@nokia.com>
Signed-off-by: Juha Riihimäki <juha.riihimaki@nokia.com>
Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
---
 hw/sd.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/hw/sd.c b/hw/sd.c
index 7b345e7..cc2839d 100644
--- a/hw/sd.c
+++ b/hw/sd.c
@@ -669,6 +669,10 @@ static sd_rsp_type_t sd_normal_command(SDState *sd,
         }
         break;
 
+    case 5: /* CMD5: reserved for SDIO cards */
+        sd->card_status |= ILLEGAL_COMMAND;
+        return sd_r0;
+
     case 6:	/* CMD6:   SWITCH_FUNCTION */
         if (sd->spi)
             goto bad_cmd;
-- 
1.6.3.3

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Qemu-devel] [PATCH 7/7] usb-musb: convert fifo to 8bit and add more registers
  2009-12-03 13:56 [Qemu-devel] [PATCH 0/7] Misc fixes from maemo qemu riku.voipio
                   ` (5 preceding siblings ...)
  2009-12-03 13:56 ` [Qemu-devel] [PATCH 6/7] handle SD CMD5 without error messages riku.voipio
@ 2009-12-03 13:56 ` riku.voipio
  6 siblings, 0 replies; 8+ messages in thread
From: riku.voipio @ 2009-12-03 13:56 UTC (permalink / raw)
  To: qemu-devel; +Cc: Riku Voipio

From: Riku Voipio <riku.voipio@nokia.com>

Convert musb fifo to 8bit to allow 8/16/32bit access

MUSB allows reading and writing to the fifo in 32/16/8 bit
width. The Linux kernel does this sometimes, most usually at
the end of writing the packet to allow packet to end at a
odd bytecount.

Convert the fifo to 8bit allows removing lots of shifts
which shows that the fifo is more natural as 8bit.

While at it, add multiple missing register definitions and
and cleanup debug prints.

Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
---
 hw/usb-musb.c |  164 +++++++++++++++++++++++++++++++++++++--------------------
 1 files changed, 107 insertions(+), 57 deletions(-)

diff --git a/hw/usb-musb.c b/hw/usb-musb.c
index 09ec5a1..7f15842 100644
--- a/hw/usb-musb.c
+++ b/hw/usb-musb.c
@@ -24,6 +24,7 @@
 #include "qemu-timer.h"
 #include "usb.h"
 #include "irq.h"
+#include "hw.h"
 
 /* Common USB registers */
 #define MUSB_HDRC_FADDR		0x00	/* 8-bit */
@@ -248,6 +249,16 @@
 #define MGC_M_ULPI_REGCTL_COMPLETE	0x02
 #define MGC_M_ULPI_REGCTL_REG		0x01
 
+/* #define MUSB_DEBUG */
+
+#ifdef MUSB_DEBUG
+#define TRACE(fmt,...) fprintf(stderr, "%s@%d: " fmt "\n", __FUNCTION__, \
+                               __LINE__, ##__VA_ARGS__)
+#else
+#define TRACE(...)
+#endif
+
+
 static void musb_attach(USBPort *port, USBDevice *dev);
 
 typedef struct {
@@ -263,7 +274,7 @@ typedef struct {
     uint8_t fifosize;
     int timeout[2];	/* Always in microframes */
 
-    uint32_t *buf[2];
+    uint8_t *buf[2];
     int fifolen[2];
     int fifostart[2];
     int fifoaddr[2];
@@ -299,7 +310,7 @@ struct MUSBState {
     int setup_len;
     int session;
 
-    uint32_t buf[0x2000];
+    uint8_t buf[0x8000];
 
         /* Duplicating the world since 2008!...  probably we should have 32
          * logical, single endpoints instead.  */
@@ -774,7 +785,7 @@ static void musb_tx_rdy(MUSBState *s, int epnum)
     MUSBEndPoint *ep = s->ep + epnum;
     int pid;
     int total, valid = 0;
-
+    TRACE("start %d, len %d",  ep->fifostart[0], ep->fifolen[0] );
     ep->fifostart[0] += ep->fifolen[0];
     ep->fifolen[0] = 0;
 
@@ -789,18 +800,18 @@ static void musb_tx_rdy(MUSBState *s, int epnum)
     }
 
     /* If the packet is not fully ready yet, wait for a next segment.  */
-    if (epnum && (ep->fifostart[0] << 2) < total)
+    if (epnum && (ep->fifostart[0]) < total)
         return;
 
     if (!valid)
-        total = ep->fifostart[0] << 2;
+        total = ep->fifostart[0];
 
     pid = USB_TOKEN_OUT;
     if (!epnum && (ep->csr[0] & MGC_M_CSR0_H_SETUPPKT)) {
         pid = USB_TOKEN_SETUP;
-        if (total != 8)
-            printf("%s: illegal SETUPPKT length of %i bytes\n",
-                            __FUNCTION__, total);
+        if (total != 8) {
+            TRACE("illegal SETUPPKT length of %i bytes", total);
+        }
         /* Controller should retry SETUP packets three times on errors
          * but it doesn't make sense for us to do that.  */
     }
@@ -817,12 +828,13 @@ static void musb_rx_req(MUSBState *s, int epnum)
     /* If we already have a packet, which didn't fit into the
      * 64 bytes of the FIFO, only move the FIFO start and return. (Obsolete) */
     if (ep->packey[1].pid == USB_TOKEN_IN && ep->status[1] >= 0 &&
-                    (ep->fifostart[1] << 2) + ep->rxcount <
+                    (ep->fifostart[1]) + ep->rxcount <
                     ep->packey[1].len) {
-        ep->fifostart[1] += ep->rxcount >> 2;
+        TRACE("0x%08x, %d",  ep->fifostart[1], ep->rxcount );
+        ep->fifostart[1] += ep->rxcount;
         ep->fifolen[1] = 0;
 
-        ep->rxcount = MIN(ep->packey[0].len - (ep->fifostart[1] << 2),
+        ep->rxcount = MIN(ep->packey[0].len - (ep->fifostart[1]),
                         ep->maxp[1]);
 
         ep->csr[1] &= ~MGC_M_RXCSR_H_REQPKT;
@@ -872,6 +884,36 @@ static void musb_rx_req(MUSBState *s, int epnum)
                     total, musb_rx_packet_complete, 1);
 }
 
+static uint8_t musb_read_fifo(MUSBEndPoint *ep)
+{
+    uint8_t value;
+    if (ep->fifolen[1] >= 64) {
+        /* We have a FIFO underrun */
+        TRACE("EP%d FIFO is now empty, stop reading", ep->epnum);
+        return 0x00000000;
+    }
+    /* In DMA mode clear RXPKTRDY and set REQPKT automatically
+     * (if AUTOREQ is set) */
+
+    ep->csr[1] &= ~MGC_M_RXCSR_FIFOFULL;
+    value=ep->buf[1][ep->fifostart[1] + ep->fifolen[1] ++];
+    TRACE("EP%d 0x%02x, %d", ep->epnum, value, ep->fifolen[1] );
+    return value;
+}
+
+static void musb_write_fifo(MUSBEndPoint *ep, uint8_t value)
+{
+    TRACE("EP%d = %02x", ep->epnum, value);
+    if (ep->fifolen[0] >= 64) {
+        /* We have a FIFO overrun */
+        TRACE("EP%d FIFO exceeded 64 bytes, stop feeding data", ep->epnum);
+        return;
+     }
+
+     ep->buf[0][ep->fifostart[0] + ep->fifolen[0] ++] = value;
+     ep->csr[0] |= MGC_M_TXCSR_FIFONOTEMPTY;
+}
+
 static void musb_ep_frame_cancel(MUSBEndPoint *ep, int dir)
 {
     if (ep->intv_timer[dir])
@@ -895,7 +937,7 @@ static uint8_t musb_busctl_readb(void *opaque, int ep, int addr)
         return s->ep[ep].hport[1];
 
     default:
-        printf("%s: unknown register at %02x\n", __FUNCTION__, addr);
+        TRACE("unknown register 0x%02x", addr);
         return 0x00;
     };
 }
@@ -905,6 +947,12 @@ static void musb_busctl_writeb(void *opaque, int ep, int addr, uint8_t value)
     MUSBState *s = (MUSBState *) opaque;
 
     switch (addr) {
+    case MUSB_HDRC_TXFUNCADDR:
+        s->ep[ep].faddr[0] = value;
+        break;
+    case MUSB_HDRC_RXFUNCADDR:
+        s->ep[ep].faddr[1] = value;
+        break;
     case MUSB_HDRC_TXHUBADDR:
         s->ep[ep].haddr[0] = value;
         break;
@@ -919,7 +967,8 @@ static void musb_busctl_writeb(void *opaque, int ep, int addr, uint8_t value)
         break;
 
     default:
-        printf("%s: unknown register at %02x\n", __FUNCTION__, addr);
+        TRACE("unknown register 0x%02x", addr);
+        break;
     };
 }
 
@@ -975,9 +1024,11 @@ static uint8_t musb_ep_readb(void *opaque, int ep, int addr)
         return 0x00;
     case MUSB_HDRC_FIFOSIZE:
         return ep ? s->ep[ep].fifosize : s->ep[ep].config;
+    case MUSB_HDRC_RXCOUNT:
+        return s->ep[ep].rxcount;
 
     default:
-        printf("%s: unknown register at %02x\n", __FUNCTION__, addr);
+        TRACE("unknown register 0x%02x", addr);
         return 0x00;
     };
 }
@@ -1004,13 +1055,12 @@ static void musb_ep_writeb(void *opaque, int ep, int addr, uint8_t value)
     case (MUSB_HDRC_FIFOSIZE & ~1):
         break;
     case MUSB_HDRC_FIFOSIZE:
-        printf("%s: somebody messes with fifosize (now %i bytes)\n",
-                        __FUNCTION__, value);
+        TRACE("somebody messes with fifosize (now %i bytes)", value);
         s->ep[ep].fifosize = value;
         break;
-
     default:
-        printf("%s: unknown register at %02x\n", __FUNCTION__, addr);
+        TRACE("unknown register 0x%02x", addr);
+        break;
     };
 }
 
@@ -1194,8 +1244,12 @@ static uint32_t musb_readb(void *opaque, target_phys_addr_t addr)
         ep = (addr >> 4) & 0xf;
         return musb_ep_readb(s, ep, addr & 0xf);
 
+    case MUSB_HDRC_FIFO ... (MUSB_HDRC_FIFO + 0x3f):
+        ep = ((addr - MUSB_HDRC_FIFO) >> 2) & 0xf;
+        return musb_read_fifo(s->ep + ep);
+
     default:
-        printf("%s: unknown register at %02x\n", __FUNCTION__, (int) addr);
+        TRACE("unknown register 0x%02x", (int) addr);
         return 0x00;
     };
 }
@@ -1276,8 +1330,14 @@ static void musb_writeb(void *opaque, target_phys_addr_t addr, uint32_t value)
         musb_ep_writeb(s, ep, addr & 0xf, value);
         break;
 
+    case MUSB_HDRC_FIFO ... (MUSB_HDRC_FIFO + 0x3f):
+        ep = ((addr - MUSB_HDRC_FIFO) >> 2) & 0xf;
+        musb_write_fifo(s->ep + ep, value & 0xff);
+        break;
+
     default:
-        printf("%s: unknown register at %02x\n", __FUNCTION__, (int) addr);
+        TRACE("unknown register 0x%02x", (int) addr);
+        break;
     };
 }
 
@@ -1326,6 +1386,10 @@ static uint32_t musb_readh(void *opaque, target_phys_addr_t addr)
         ep = (addr >> 4) & 0xf;
         return musb_ep_readh(s, ep, addr & 0xf);
 
+    case MUSB_HDRC_FIFO ... (MUSB_HDRC_FIFO + 0x3f):
+        ep = ((addr - MUSB_HDRC_FIFO) >> 2) & 0xf;
+        return (musb_read_fifo(s->ep + ep) | musb_read_fifo(s->ep + ep) << 8);
+
     default:
         return musb_readb(s, addr) | (musb_readb(s, addr | 1) << 8);
     };
@@ -1353,12 +1417,12 @@ static void musb_writeh(void *opaque, target_phys_addr_t addr, uint32_t value)
     case MUSB_HDRC_TXFIFOADDR:
         s->ep[s->idx].fifoaddr[0] = value;
         s->ep[s->idx].buf[0] =
-                s->buf + ((value << 1) & (sizeof(s->buf) / 4 - 1));
+                s->buf + ((value << 3) & 0x7ff );
         break;
     case MUSB_HDRC_RXFIFOADDR:
         s->ep[s->idx].fifoaddr[1] = value;
         s->ep[s->idx].buf[1] =
-                s->buf + ((value << 1) & (sizeof(s->buf) / 4 - 1));
+                s->buf + ((value << 3) & 0x7ff);
         break;
 
     case MUSB_HDRC_EP_IDX ... (MUSB_HDRC_EP_IDX + 0xf):
@@ -1375,6 +1439,12 @@ static void musb_writeh(void *opaque, target_phys_addr_t addr, uint32_t value)
         musb_ep_writeh(s, ep, addr & 0xf, value);
         break;
 
+    case MUSB_HDRC_FIFO ... (MUSB_HDRC_FIFO + 0x3f):
+        ep = ((addr - MUSB_HDRC_FIFO) >> 2) & 0xf;
+        musb_write_fifo(s->ep + ep, value & 0xff);
+        musb_write_fifo(s->ep + ep, (value >> 8) & 0xff);
+        break;
+
     default:
         musb_writeb(s, addr, value & 0xff);
         musb_writeb(s, addr | 1, value >> 8);
@@ -1384,28 +1454,17 @@ static void musb_writeh(void *opaque, target_phys_addr_t addr, uint32_t value)
 static uint32_t musb_readw(void *opaque, target_phys_addr_t addr)
 {
     MUSBState *s = (MUSBState *) opaque;
-    MUSBEndPoint *ep;
-    int epnum;
+    int ep;
 
     switch (addr) {
     case MUSB_HDRC_FIFO ... (MUSB_HDRC_FIFO + 0x3f):
-        epnum = ((addr - MUSB_HDRC_FIFO) >> 2) & 0xf;
-        ep = s->ep + epnum;
-
-        if (ep->fifolen[1] >= 16) {
-            /* We have a FIFO underrun */
-            printf("%s: EP%i FIFO is now empty, stop reading\n",
-                            __FUNCTION__, epnum);
-            return 0x00000000;
-        }
-        /* In DMA mode clear RXPKTRDY and set REQPKT automatically
-         * (if AUTOREQ is set) */
-
-        ep->csr[1] &= ~MGC_M_RXCSR_FIFOFULL;
-        return ep->buf[1][ep->fifostart[1] + ep->fifolen[1] ++];
-
+        ep = ((addr - MUSB_HDRC_FIFO) >> 2) & 0xf;
+        return ( musb_read_fifo(s->ep + ep)       |
+                 musb_read_fifo(s->ep + ep) << 8  |
+                 musb_read_fifo(s->ep + ep) << 16 |
+                 musb_read_fifo(s->ep + ep) << 24 );
     default:
-        printf("%s: unknown register at %02x\n", __FUNCTION__, (int) addr);
+        TRACE("unknown register 0x%02x", (int) addr);
         return 0x00000000;
     };
 }
@@ -1413,28 +1472,19 @@ static uint32_t musb_readw(void *opaque, target_phys_addr_t addr)
 static void musb_writew(void *opaque, target_phys_addr_t addr, uint32_t value)
 {
     MUSBState *s = (MUSBState *) opaque;
-    MUSBEndPoint *ep;
-    int epnum;
+    int ep;
 
     switch (addr) {
     case MUSB_HDRC_FIFO ... (MUSB_HDRC_FIFO + 0x3f):
-        epnum = ((addr - MUSB_HDRC_FIFO) >> 2) & 0xf;
-        ep = s->ep + epnum;
-
-        if (ep->fifolen[0] >= 16) {
-            /* We have a FIFO overrun */
-            printf("%s: EP%i FIFO exceeded 64 bytes, stop feeding data\n",
-                            __FUNCTION__, epnum);
+        ep = ((addr - MUSB_HDRC_FIFO) >> 2) & 0xf;
+        musb_write_fifo(s->ep + ep, value & 0xff);
+        musb_write_fifo(s->ep + ep, (value >> 8 ) & 0xff);
+        musb_write_fifo(s->ep + ep, (value >> 16) & 0xff);
+        musb_write_fifo(s->ep + ep, (value >> 24) & 0xff);
             break;
-        }
-
-        ep->buf[0][ep->fifostart[0] + ep->fifolen[0] ++] = value;
-        if (epnum)
-            ep->csr[0] |= MGC_M_TXCSR_FIFONOTEMPTY;
-        break;
-
     default:
-        printf("%s: unknown register at %02x\n", __FUNCTION__, (int) addr);
+        TRACE("unknown register 0x%02x", (int) addr);
+        break;
     };
 }
 
-- 
1.6.3.3

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2009-12-03 13:57 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-03 13:56 [Qemu-devel] [PATCH 0/7] Misc fixes from maemo qemu riku.voipio
2009-12-03 13:56 ` [Qemu-devel] [PATCH 1/7] Fix win32 log file location riku.voipio
2009-12-03 13:56 ` [Qemu-devel] [PATCH 2/7] fix pidfile option to work in WIN32 riku.voipio
2009-12-03 13:56 ` [Qemu-devel] [PATCH 3/7] fix networking on win32 host riku.voipio
2009-12-03 13:56 ` [Qemu-devel] [PATCH 4/7] Give a error when running out of iomem areas riku.voipio
2009-12-03 13:56 ` [Qemu-devel] [PATCH 5/7] Make USB hid devices self-powered riku.voipio
2009-12-03 13:56 ` [Qemu-devel] [PATCH 6/7] handle SD CMD5 without error messages riku.voipio
2009-12-03 13:56 ` [Qemu-devel] [PATCH 7/7] usb-musb: convert fifo to 8bit and add more registers riku.voipio

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).