From: Isaku Yamahata <yamahata@valinux.co.jp>
To: qemu-devel@nongnu.org
Cc: yamahata@valinux.co.jp
Subject: [Qemu-devel] [PATCH 2/6] use constant IOPORTS_MASK instead of 0xffff.
Date: Fri, 3 Jul 2009 13:42:35 +0900 [thread overview]
Message-ID: <1246596159-16126-3-git-send-email-yamahata@valinux.co.jp> (raw)
In-Reply-To: <1246596159-16126-1-git-send-email-yamahata@valinux.co.jp>
use constant IOPORTS_MASK instead of 0xffff.
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
---
hw/apb_pci.c | 12 ++++++------
hw/isa_mmio.c | 12 ++++++------
ioport.c | 4 ++--
ioport.h | 1 +
monitor.c | 2 +-
5 files changed, 16 insertions(+), 15 deletions(-)
diff --git a/hw/apb_pci.c b/hw/apb_pci.c
index b63ccd1..9f2a44d 100644
--- a/hw/apb_pci.c
+++ b/hw/apb_pci.c
@@ -148,26 +148,26 @@ static CPUReadMemoryFunc *pci_apb_read[] = {
static void pci_apb_iowriteb (void *opaque, target_phys_addr_t addr,
uint32_t val)
{
- cpu_outb(NULL, addr & 0xffff, val);
+ cpu_outb(NULL, addr & IOPORTS_MASK, val);
}
static void pci_apb_iowritew (void *opaque, target_phys_addr_t addr,
uint32_t val)
{
- cpu_outw(NULL, addr & 0xffff, val);
+ cpu_outw(NULL, addr & IOPORTS_MASK, val);
}
static void pci_apb_iowritel (void *opaque, target_phys_addr_t addr,
uint32_t val)
{
- cpu_outl(NULL, addr & 0xffff, val);
+ cpu_outl(NULL, addr & IOPORTS_MASK, val);
}
static uint32_t pci_apb_ioreadb (void *opaque, target_phys_addr_t addr)
{
uint32_t val;
- val = cpu_inb(NULL, addr & 0xffff);
+ val = cpu_inb(NULL, addr & IOPORTS_MASK);
return val;
}
@@ -175,7 +175,7 @@ static uint32_t pci_apb_ioreadw (void *opaque, target_phys_addr_t addr)
{
uint32_t val;
- val = cpu_inw(NULL, addr & 0xffff);
+ val = cpu_inw(NULL, addr & IOPORTS_MASK);
return val;
}
@@ -183,7 +183,7 @@ static uint32_t pci_apb_ioreadl (void *opaque, target_phys_addr_t addr)
{
uint32_t val;
- val = cpu_inl(NULL, addr & 0xffff);
+ val = cpu_inl(NULL, addr & IOPORTS_MASK);
return val;
}
diff --git a/hw/isa_mmio.c b/hw/isa_mmio.c
index 1d5e8dc..868c7b0 100644
--- a/hw/isa_mmio.c
+++ b/hw/isa_mmio.c
@@ -28,7 +28,7 @@
static void isa_mmio_writeb (void *opaque, target_phys_addr_t addr,
uint32_t val)
{
- cpu_outb(NULL, addr & 0xffff, val);
+ cpu_outb(NULL, addr & IOPORTS_MASK, val);
}
static void isa_mmio_writew (void *opaque, target_phys_addr_t addr,
@@ -37,7 +37,7 @@ static void isa_mmio_writew (void *opaque, target_phys_addr_t addr,
#ifdef TARGET_WORDS_BIGENDIAN
val = bswap16(val);
#endif
- cpu_outw(NULL, addr & 0xffff, val);
+ cpu_outw(NULL, addr & IOPORTS_MASK, val);
}
static void isa_mmio_writel (void *opaque, target_phys_addr_t addr,
@@ -46,14 +46,14 @@ static void isa_mmio_writel (void *opaque, target_phys_addr_t addr,
#ifdef TARGET_WORDS_BIGENDIAN
val = bswap32(val);
#endif
- cpu_outl(NULL, addr & 0xffff, val);
+ cpu_outl(NULL, addr & IOPORTS_MASK, val);
}
static uint32_t isa_mmio_readb (void *opaque, target_phys_addr_t addr)
{
uint32_t val;
- val = cpu_inb(NULL, addr & 0xffff);
+ val = cpu_inb(NULL, addr & IOPORTS_MASK);
return val;
}
@@ -61,7 +61,7 @@ static uint32_t isa_mmio_readw (void *opaque, target_phys_addr_t addr)
{
uint32_t val;
- val = cpu_inw(NULL, addr & 0xffff);
+ val = cpu_inw(NULL, addr & IOPORTS_MASK);
#ifdef TARGET_WORDS_BIGENDIAN
val = bswap16(val);
#endif
@@ -72,7 +72,7 @@ static uint32_t isa_mmio_readl (void *opaque, target_phys_addr_t addr)
{
uint32_t val;
- val = cpu_inl(NULL, addr & 0xffff);
+ val = cpu_inl(NULL, addr & IOPORTS_MASK);
#ifdef TARGET_WORDS_BIGENDIAN
val = bswap32(val);
#endif
diff --git a/ioport.c b/ioport.c
index d875209..04bffc4 100644
--- a/ioport.c
+++ b/ioport.c
@@ -94,7 +94,7 @@ static uint32_t default_ioport_readw(void *opaque, uint32_t address)
{
uint32_t data;
data = ioport_read(0, address);
- address = (address + 1) & (MAX_IOPORTS - 1);
+ address = (address + 1) & IOPORTS_MASK;
data |= ioport_read(0, address) << 8;
return data;
}
@@ -102,7 +102,7 @@ static uint32_t default_ioport_readw(void *opaque, uint32_t address)
static void default_ioport_writew(void *opaque, uint32_t address, uint32_t data)
{
ioport_write(0, address, data & 0xff);
- address = (address + 1) & (MAX_IOPORTS - 1);
+ address = (address + 1) & IOPORTS_MASK;
ioport_write(0, address, (data >> 8) & 0xff);
}
diff --git a/ioport.h b/ioport.h
index 309a402..4cb59e9 100644
--- a/ioport.h
+++ b/ioport.h
@@ -28,6 +28,7 @@
#include "qemu-common.h"
#define MAX_IOPORTS (64 * 1024)
+#define IOPORTS_MASK (MAX_IOPORTS - 1)
/* These should really be in isa.h, but are here to make pc.h happy. */
typedef void (IOPortWriteFunc)(void *opaque, uint32_t address, uint32_t data);
diff --git a/monitor.c b/monitor.c
index bad79fe..eaceee5 100644
--- a/monitor.c
+++ b/monitor.c
@@ -1161,7 +1161,7 @@ static void do_ioport_read(Monitor *mon, int count, int format, int size,
int suffix;
if (has_index) {
- cpu_outb(NULL, addr & 0xffff, index & 0xff);
+ cpu_outb(NULL, addr & IOPORTS_MASK, index & 0xff);
addr++;
}
addr &= 0xffff;
--
1.6.0.2
next prev parent reply other threads:[~2009-07-03 4:44 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-03 4:42 [Qemu-devel] [PATCH 0/6] ioport related clean ups Isaku Yamahata
2009-07-03 4:42 ` [Qemu-devel] [PATCH 1/6] split out ioport related stuffs from vl.c into ioport.c Isaku Yamahata
2009-07-03 4:42 ` Isaku Yamahata [this message]
2009-07-03 4:42 ` [Qemu-devel] [PATCH 3/6] ioport: consolidate duplicated logic in register_ioport_{read, write}() Isaku Yamahata
2009-07-03 4:42 ` [Qemu-devel] [PATCH 4/6] ioport: remove some #ifdef DEBUG_UNUSED_IOPORT Isaku Yamahata
2009-07-09 19:10 ` Anthony Liguori
2009-07-09 22:06 ` [Qemu-devel] " Paolo Bonzini
2009-07-09 22:07 ` Anthony Liguori
2009-07-03 4:42 ` [Qemu-devel] [PATCH 5/6] consolidate user cpu_{in, out}[bwl] into ioport-user.c Isaku Yamahata
2009-07-03 4:42 ` [Qemu-devel] [PATCH 6/6] use uint{32, 16, 8}_t for ioport port and value instead of int Isaku Yamahata
-- strict thread matches above, loose matches on Subject: below --
2009-07-10 9:13 [Qemu-devel] [PATCH 0/6] ioport related clean ups. V3 Isaku Yamahata
2009-07-10 9:13 ` [Qemu-devel] [PATCH 2/6] use constant IOPORTS_MASK instead of 0xffff Isaku Yamahata
2009-07-02 10:32 [Qemu-devel] [PATCH 0/6] ioport related clean ups Isaku Yamahata
2009-07-02 10:32 ` [Qemu-devel] [PATCH 2/6] use constant IOPORTS_MASK instead of 0xffff Isaku Yamahata
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=1246596159-16126-3-git-send-email-yamahata@valinux.co.jp \
--to=yamahata@valinux.co.jp \
--cc=qemu-devel@nongnu.org \
/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).