From: Jason Wang <jasowang@redhat.com>
To: aliguori@us.ibm.com, stefanha@linux.vnet.ibm.com, mst@redhat.com,
qemu-devel@nongnu.org, benjamin.poirier@gmail.com,
aurelien@aurel32.net
Subject: [Qemu-devel] [PATCH 3/6] rtl8139: support byte read to TxStatus registers
Date: Mon, 05 Mar 2012 11:08:42 +0800 [thread overview]
Message-ID: <20120305030842.8515.5931.stgit@jason-ThinkPad-T400> (raw)
In-Reply-To: <20120305030824.8515.53602.stgit@jason-ThinkPad-T400>
Some drivers (such as win7) use byte read for TxStatus registers, so we need to
support this to let guest driver behave correctly.
For writing, only double-word access is allowed by spec.
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
hw/rtl8139.c | 33 +++++++++++++++++++++++++++++----
1 files changed, 29 insertions(+), 4 deletions(-)
diff --git a/hw/rtl8139.c b/hw/rtl8139.c
index ca613ae..a946e79 100644
--- a/hw/rtl8139.c
+++ b/hw/rtl8139.c
@@ -2495,11 +2495,30 @@ static void rtl8139_TxStatus_write(RTL8139State *s, uint32_t txRegOffset, uint32
rtl8139_transmit(s);
}
-static uint32_t rtl8139_TxStatus_read(RTL8139State *s, uint32_t txRegOffset)
+static uint32_t rtl8139_TxStatus_read(RTL8139State *s, uint8_t addr, int size)
{
- uint32_t ret = s->TxStatus[txRegOffset/4];
+ uint32_t reg = (addr - TxStatus0) / 4;
+ uint32_t offset = addr & 0x3;
+ uint32_t ret = 0;
+
+ if (addr & (size - 1)) {
+ DPRINTF("not implemented read for TxStatus addr=0x%x size=0x%x\n", addr,
+ size);
+ return ret;
+ }
- DPRINTF("TxStatus read offset=0x%x val=0x%08x\n", txRegOffset, ret);
+ switch (size) {
+ case 1: /* fall through */
+ case 2: /* fall through */
+ case 4:
+ ret = (s->TxStatus[reg] >> offset * 8) & ((1 << (size * 8)) - 1);
+ DPRINTF("TxStatus[%d] read addr=0x%x size=0x%x val=0x%08x\n", reg, addr,
+ size, ret);
+ break;
+ default:
+ DPRINTF("unsupported size 0x%x of TxStatus reading\n", size);
+ break;
+ }
return ret;
}
@@ -2970,6 +2989,9 @@ static uint32_t rtl8139_io_readb(void *opaque, uint8_t addr)
case MAR0 ... MAR0+7:
ret = s->mult[addr - MAR0];
break;
+ case TxStatus0 ... TxStatus0+4*4-1:
+ ret = rtl8139_TxStatus_read(s, addr, 1);
+ break;
case ChipCmd:
ret = rtl8139_ChipCmd_read(s);
break;
@@ -3033,6 +3055,9 @@ static uint32_t rtl8139_io_readw(void *opaque, uint8_t addr)
switch (addr)
{
+ case TxAddr0 ... TxAddr0+4*4-1:
+ ret = rtl8139_TxStatus_read(s, addr, 2);
+ break;
case IntrMask:
ret = rtl8139_IntrMask_read(s);
break;
@@ -3123,7 +3148,7 @@ static uint32_t rtl8139_io_readl(void *opaque, uint8_t addr)
break;
case TxStatus0 ... TxStatus0+4*4-1:
- ret = rtl8139_TxStatus_read(s, addr-TxStatus0);
+ ret = rtl8139_TxStatus_read(s, addr, 4);
break;
case TxAddr0 ... TxAddr0+4*4-1:
next prev parent reply other threads:[~2012-03-05 3:09 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-05 3:08 [Qemu-devel] [PATCH 1/6] rtl8139: limit transmission buffer size in c+ mode Jason Wang
2012-03-05 3:08 ` [Qemu-devel] [PATCH 2/6] rtl8139: remove unused marco Jason Wang
2012-03-05 3:08 ` Jason Wang [this message]
2012-03-05 3:08 ` [Qemu-devel] [PATCH 4/6] net: move compute_mcast_idx() to net.h Jason Wang
2012-03-05 3:08 ` [Qemu-devel] [PATCH 5/6] rtl8139: correctly check the opmode Jason Wang
2012-03-05 3:09 ` [Qemu-devel] [PATCH 6/6] rtl8139: do the network/host communication only in normal operating mode Jason Wang
2012-03-05 8:31 ` [Qemu-devel] [PATCH 1/6] rtl8139: limit transmission buffer size in c+ mode Stefan Hajnoczi
2012-03-07 3:17 ` [Qemu-devel] [1/6 V2 PATCH] " Jason Wang
2012-03-07 8:13 ` Stefan Hajnoczi
2012-03-15 23:01 ` Michael S. Tsirkin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120305030842.8515.5931.stgit@jason-ThinkPad-T400 \
--to=jasowang@redhat.com \
--cc=aliguori@us.ibm.com \
--cc=aurelien@aurel32.net \
--cc=benjamin.poirier@gmail.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@linux.vnet.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).