* [Qemu-devel] [PATCH 0/6] ioport related clean ups. V3
@ 2009-07-10 9:13 Isaku Yamahata
2009-07-10 9:13 ` [Qemu-devel] [PATCH 1/6] split out ioport related stuffs from vl.c into ioport.c Isaku Yamahata
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: Isaku Yamahata @ 2009-07-10 9:13 UTC (permalink / raw)
To: qemu-devel; +Cc: yamahata
This patch series cleans up io port emulation
sliming down bloated vl.c a bit and consolidated
ones used for user emulation.
Changes from v2:
- fixed the definition of DEBUG_UNUSED_IOPORT.
- changed signatures of cpu_{in, out}[bwl]()
void cpu_out[bwl](CPUState *env, uint16_t addr, uint{8, 16, 32}_t val);
uint{8, 16, 32}_t cpu_in[bwl](CPUState *env, uint16_t addr);
Changes from v1:
- removed unintended stderr.
- use uint{32, 16, 8}_t instead of uint32_t.
Isaku Yamahata (6):
split out ioport related stuffs from vl.c into ioport.c.
use constant IOPORTS_MASK instead of 0xffff.
ioport: consolidate duplicated logic in register_ioport_{read,
write}().
ioport: remove some #ifdef DEBUG_UNUSED_IOPORT.
consolidate user cpu_{in, out}[bwl] into ioport-user.c
use uint{32, 16, 8}_t for ioport value and uint16_t for ioport
address.
Makefile.target | 9 +-
bsd-user/main.c | 33 -------
cpu-all.h | 12 +--
darwin-user/main.c | 33 -------
hw/apb_pci.c | 12 +-
hw/hw.h | 5 +-
hw/isa.h | 8 +-
hw/isa_mmio.c | 12 +-
ioport-user.c | 59 ++++++++++++
ioport.c | 259 ++++++++++++++++++++++++++++++++++++++++++++++++++++
ioport.h | 55 +++++++++++
linux-user/main.c | 33 -------
monitor.c | 2 +-
tests/Makefile | 4 +-
tests/qruncom.c | 33 -------
vl.c | 226 ---------------------------------------------
16 files changed, 397 insertions(+), 398 deletions(-)
create mode 100644 ioport-user.c
create mode 100644 ioport.c
create mode 100644 ioport.h
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Qemu-devel] [PATCH 1/6] split out ioport related stuffs from vl.c into ioport.c.
2009-07-10 9:13 [Qemu-devel] [PATCH 0/6] ioport related clean ups. V3 Isaku Yamahata
@ 2009-07-10 9:13 ` Isaku Yamahata
2009-07-10 9:13 ` [Qemu-devel] [PATCH 2/6] use constant IOPORTS_MASK instead of 0xffff Isaku Yamahata
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Isaku Yamahata @ 2009-07-10 9:13 UTC (permalink / raw)
To: qemu-devel; +Cc: yamahata
split out ioport related stuffs from vl.c into ioport.c.
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
---
Makefile.target | 2 +-
cpu-all.h | 12 +---
hw/hw.h | 5 +-
hw/isa.h | 8 +--
ioport.c | 258 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
ioport.h | 54 ++++++++++++
vl.c | 226 ------------------------------------------------
7 files changed, 317 insertions(+), 248 deletions(-)
create mode 100644 ioport.c
create mode 100644 ioport.h
diff --git a/Makefile.target b/Makefile.target
index a593503..7f7c167 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -489,7 +489,7 @@ endif #CONFIG_BSD_USER
ifndef CONFIG_USER_ONLY
obj-y = vl.o osdep.o monitor.o pci.o loader.o isa_mmio.o machine.o \
- gdbstub.o gdbstub-xml.o msix.o
+ gdbstub.o gdbstub-xml.o msix.o ioport.o
# virtio has to be here due to weird dependency between PCI and virtio-net.
# need to fix this properly
obj-y += virtio-blk.o virtio-balloon.o virtio-net.o virtio-console.o
diff --git a/cpu-all.h b/cpu-all.h
index 97a224d..bb27830 100644
--- a/cpu-all.h
+++ b/cpu-all.h
@@ -836,17 +836,7 @@ void cpu_set_log_filename(const char *filename);
int cpu_str_to_log_mask(const char *str);
/* IO ports API */
-
-/* NOTE: as these functions may be even used when there is an isa
- brige on non x86 targets, we always defined them */
-#ifndef NO_CPU_IO_DEFS
-void cpu_outb(CPUState *env, int addr, int val);
-void cpu_outw(CPUState *env, int addr, int val);
-void cpu_outl(CPUState *env, int addr, int val);
-int cpu_inb(CPUState *env, int addr);
-int cpu_inw(CPUState *env, int addr);
-int cpu_inl(CPUState *env, int addr);
-#endif
+#include "ioport.h"
/* memory API */
diff --git a/hw/hw.h b/hw/hw.h
index 2e43c1f..a424d28 100644
--- a/hw/hw.h
+++ b/hw/hw.h
@@ -10,6 +10,7 @@
#include "cpu-common.h"
#endif
+#include "ioport.h"
#include "irq.h"
/* VM Load/Save */
@@ -266,8 +267,4 @@ void qemu_register_reset(QEMUResetHandler *func, void *opaque);
typedef int QEMUBootSetHandler(void *opaque, const char *boot_device);
void qemu_register_boot_set(QEMUBootSetHandler *func, void *opaque);
-/* 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);
-typedef uint32_t (IOPortReadFunc)(void *opaque, uint32_t address);
-
#endif
diff --git a/hw/isa.h b/hw/isa.h
index a8c1a56..f126ecc 100644
--- a/hw/isa.h
+++ b/hw/isa.h
@@ -2,13 +2,9 @@
#define HW_ISA_H
/* ISA bus */
-extern target_phys_addr_t isa_mem_base;
+#include "ioport.h"
-int register_ioport_read(int start, int length, int size,
- IOPortReadFunc *func, void *opaque);
-int register_ioport_write(int start, int length, int size,
- IOPortWriteFunc *func, void *opaque);
-void isa_unassign_ioport(int start, int length);
+extern target_phys_addr_t isa_mem_base;
void isa_mmio_init(target_phys_addr_t base, target_phys_addr_t size);
diff --git a/ioport.c b/ioport.c
new file mode 100644
index 0000000..d875209
--- /dev/null
+++ b/ioport.c
@@ -0,0 +1,258 @@
+/*
+ * QEMU System Emulator
+ *
+ * Copyright (c) 2003-2008 Fabrice Bellard
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+/*
+ * splitted out ioport related stuffs from vl.c.
+ */
+
+#include "ioport.h"
+
+/***********************************************************/
+/* IO Port */
+
+//#define DEBUG_UNUSED_IOPORT
+//#define DEBUG_IOPORT
+
+#ifdef DEBUG_IOPORT
+# define LOG_IOPORT(...) qemu_log_mask(CPU_LOG_IOPORT, ## __VA_ARGS__)
+#else
+# define LOG_IOPORT(...) do { } while (0)
+#endif
+
+/* XXX: use a two level table to limit memory usage */
+
+static void *ioport_opaque[MAX_IOPORTS];
+static IOPortReadFunc *ioport_read_table[3][MAX_IOPORTS];
+static IOPortWriteFunc *ioport_write_table[3][MAX_IOPORTS];
+
+static IOPortReadFunc default_ioport_readb, default_ioport_readw, default_ioport_readl;
+static IOPortWriteFunc default_ioport_writeb, default_ioport_writew, default_ioport_writel;
+
+static uint32_t ioport_read(int index, uint32_t address)
+{
+ static IOPortReadFunc *default_func[3] = {
+ default_ioport_readb,
+ default_ioport_readw,
+ default_ioport_readl
+ };
+ IOPortReadFunc *func = ioport_read_table[index][address];
+ if (!func)
+ func = default_func[index];
+ return func(ioport_opaque[address], address);
+}
+
+static void ioport_write(int index, uint32_t address, uint32_t data)
+{
+ static IOPortWriteFunc *default_func[3] = {
+ default_ioport_writeb,
+ default_ioport_writew,
+ default_ioport_writel
+ };
+ IOPortWriteFunc *func = ioport_write_table[index][address];
+ if (!func)
+ func = default_func[index];
+ func(ioport_opaque[address], address, data);
+}
+
+static uint32_t default_ioport_readb(void *opaque, uint32_t address)
+{
+#ifdef DEBUG_UNUSED_IOPORT
+ fprintf(stderr, "unused inb: port=0x%04x\n", address);
+#endif
+ return 0xff;
+}
+
+static void default_ioport_writeb(void *opaque, uint32_t address, uint32_t data)
+{
+#ifdef DEBUG_UNUSED_IOPORT
+ fprintf(stderr, "unused outb: port=0x%04x data=0x%02x\n", address, data);
+#endif
+}
+
+/* default is to make two byte accesses */
+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);
+ data |= ioport_read(0, address) << 8;
+ return data;
+}
+
+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);
+ ioport_write(0, address, (data >> 8) & 0xff);
+}
+
+static uint32_t default_ioport_readl(void *opaque, uint32_t address)
+{
+#ifdef DEBUG_UNUSED_IOPORT
+ fprintf(stderr, "unused inl: port=0x%04x\n", address);
+#endif
+ return 0xffffffff;
+}
+
+static void default_ioport_writel(void *opaque, uint32_t address, uint32_t data)
+{
+#ifdef DEBUG_UNUSED_IOPORT
+ fprintf(stderr, "unused outl: port=0x%04x data=0x%02x\n", address, data);
+#endif
+}
+
+/* size is the word size in byte */
+int register_ioport_read(int start, int length, int size,
+ IOPortReadFunc *func, void *opaque)
+{
+ int i, bsize;
+
+ if (size == 1) {
+ bsize = 0;
+ } else if (size == 2) {
+ bsize = 1;
+ } else if (size == 4) {
+ bsize = 2;
+ } else {
+ hw_error("register_ioport_read: invalid size");
+ return -1;
+ }
+ for(i = start; i < start + length; i += size) {
+ ioport_read_table[bsize][i] = func;
+ if (ioport_opaque[i] != NULL && ioport_opaque[i] != opaque)
+ hw_error("register_ioport_read: invalid opaque");
+ ioport_opaque[i] = opaque;
+ }
+ return 0;
+}
+
+/* size is the word size in byte */
+int register_ioport_write(int start, int length, int size,
+ IOPortWriteFunc *func, void *opaque)
+{
+ int i, bsize;
+
+ if (size == 1) {
+ bsize = 0;
+ } else if (size == 2) {
+ bsize = 1;
+ } else if (size == 4) {
+ bsize = 2;
+ } else {
+ hw_error("register_ioport_write: invalid size");
+ return -1;
+ }
+ for(i = start; i < start + length; i += size) {
+ ioport_write_table[bsize][i] = func;
+ if (ioport_opaque[i] != NULL && ioport_opaque[i] != opaque)
+ hw_error("register_ioport_write: invalid opaque");
+ ioport_opaque[i] = opaque;
+ }
+ return 0;
+}
+
+void isa_unassign_ioport(int start, int length)
+{
+ int i;
+
+ for(i = start; i < start + length; i++) {
+ ioport_read_table[0][i] = default_ioport_readb;
+ ioport_read_table[1][i] = default_ioport_readw;
+ ioport_read_table[2][i] = default_ioport_readl;
+
+ ioport_write_table[0][i] = default_ioport_writeb;
+ ioport_write_table[1][i] = default_ioport_writew;
+ ioport_write_table[2][i] = default_ioport_writel;
+
+ ioport_opaque[i] = NULL;
+ }
+}
+
+/***********************************************************/
+
+void cpu_outb(CPUState *env, int addr, int val)
+{
+ LOG_IOPORT("outb: %04x %02x\n", addr, val);
+ ioport_write(0, addr, val);
+#ifdef CONFIG_KQEMU
+ if (env)
+ env->last_io_time = cpu_get_time_fast();
+#endif
+}
+
+void cpu_outw(CPUState *env, int addr, int val)
+{
+ LOG_IOPORT("outw: %04x %04x\n", addr, val);
+ ioport_write(1, addr, val);
+#ifdef CONFIG_KQEMU
+ if (env)
+ env->last_io_time = cpu_get_time_fast();
+#endif
+}
+
+void cpu_outl(CPUState *env, int addr, int val)
+{
+ LOG_IOPORT("outl: %04x %08x\n", addr, val);
+ ioport_write(2, addr, val);
+#ifdef CONFIG_KQEMU
+ if (env)
+ env->last_io_time = cpu_get_time_fast();
+#endif
+}
+
+int cpu_inb(CPUState *env, int addr)
+{
+ int val;
+ val = ioport_read(0, addr);
+ LOG_IOPORT("inb : %04x %02x\n", addr, val);
+#ifdef CONFIG_KQEMU
+ if (env)
+ env->last_io_time = cpu_get_time_fast();
+#endif
+ return val;
+}
+
+int cpu_inw(CPUState *env, int addr)
+{
+ int val;
+ val = ioport_read(1, addr);
+ LOG_IOPORT("inw : %04x %04x\n", addr, val);
+#ifdef CONFIG_KQEMU
+ if (env)
+ env->last_io_time = cpu_get_time_fast();
+#endif
+ return val;
+}
+
+int cpu_inl(CPUState *env, int addr)
+{
+ int val;
+ val = ioport_read(2, addr);
+ LOG_IOPORT("inl : %04x %08x\n", addr, val);
+#ifdef CONFIG_KQEMU
+ if (env)
+ env->last_io_time = cpu_get_time_fast();
+#endif
+ return val;
+}
+
diff --git a/ioport.h b/ioport.h
new file mode 100644
index 0000000..309a402
--- /dev/null
+++ b/ioport.h
@@ -0,0 +1,54 @@
+/*
+ * defines ioport related functions
+ *
+ * Copyright (c) 2003 Fabrice Bellard
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA
+ */
+
+/**************************************************************************
+ * IO ports API
+ */
+
+#ifndef IOPORT_H
+#define IOPORT_H
+
+#include "qemu-common.h"
+
+#define MAX_IOPORTS (64 * 1024)
+
+/* 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);
+typedef uint32_t (IOPortReadFunc)(void *opaque, uint32_t address);
+
+int register_ioport_read(int start, int length, int size,
+ IOPortReadFunc *func, void *opaque);
+int register_ioport_write(int start, int length, int size,
+ IOPortWriteFunc *func, void *opaque);
+void isa_unassign_ioport(int start, int length);
+
+
+/* NOTE: as these functions may be even used when there is an isa
+ brige on non x86 targets, we always defined them */
+#if !defined(NO_CPU_IO_DEFS) && defined(NEED_CPU_H)
+void cpu_outb(CPUState *env, int addr, int val);
+void cpu_outw(CPUState *env, int addr, int val);
+void cpu_outl(CPUState *env, int addr, int val);
+int cpu_inb(CPUState *env, int addr);
+int cpu_inw(CPUState *env, int addr);
+int cpu_inl(CPUState *env, int addr);
+#endif
+
+#endif /* IOPORT_H */
diff --git a/vl.c b/vl.c
index 7b7489c..7ae3a2c 100644
--- a/vl.c
+++ b/vl.c
@@ -167,18 +167,9 @@ int main(int argc, char **argv)
#include "slirp/libslirp.h"
-//#define DEBUG_UNUSED_IOPORT
-//#define DEBUG_IOPORT
//#define DEBUG_NET
//#define DEBUG_SLIRP
-
-#ifdef DEBUG_IOPORT
-# define LOG_IOPORT(...) qemu_log_mask(CPU_LOG_IOPORT, ## __VA_ARGS__)
-#else
-# define LOG_IOPORT(...) do { } while (0)
-#endif
-
#define DEFAULT_RAM_SIZE 128
/* Max number of USB devices that can be specified on the commandline. */
@@ -187,14 +178,8 @@ int main(int argc, char **argv)
/* Max number of bluetooth switches on the commandline. */
#define MAX_BT_CMDLINE 10
-/* XXX: use a two level table to limit memory usage */
-#define MAX_IOPORTS 65536
-
static const char *data_dir;
const char *bios_name = NULL;
-static void *ioport_opaque[MAX_IOPORTS];
-static IOPortReadFunc *ioport_read_table[3][MAX_IOPORTS];
-static IOPortWriteFunc *ioport_write_table[3][MAX_IOPORTS];
/* Note: drives_table[MAX_DRIVES] is a dummy block driver if none available
to store the VM snapshots */
DriveInfo drives_table[MAX_DRIVES+1];
@@ -294,217 +279,6 @@ uint8_t qemu_uuid[16];
target_phys_addr_t isa_mem_base = 0;
PicState2 *isa_pic;
-static IOPortReadFunc default_ioport_readb, default_ioport_readw, default_ioport_readl;
-static IOPortWriteFunc default_ioport_writeb, default_ioport_writew, default_ioport_writel;
-
-static uint32_t ioport_read(int index, uint32_t address)
-{
- static IOPortReadFunc *default_func[3] = {
- default_ioport_readb,
- default_ioport_readw,
- default_ioport_readl
- };
- IOPortReadFunc *func = ioport_read_table[index][address];
- if (!func)
- func = default_func[index];
- return func(ioport_opaque[address], address);
-}
-
-static void ioport_write(int index, uint32_t address, uint32_t data)
-{
- static IOPortWriteFunc *default_func[3] = {
- default_ioport_writeb,
- default_ioport_writew,
- default_ioport_writel
- };
- IOPortWriteFunc *func = ioport_write_table[index][address];
- if (!func)
- func = default_func[index];
- func(ioport_opaque[address], address, data);
-}
-
-static uint32_t default_ioport_readb(void *opaque, uint32_t address)
-{
-#ifdef DEBUG_UNUSED_IOPORT
- fprintf(stderr, "unused inb: port=0x%04x\n", address);
-#endif
- return 0xff;
-}
-
-static void default_ioport_writeb(void *opaque, uint32_t address, uint32_t data)
-{
-#ifdef DEBUG_UNUSED_IOPORT
- fprintf(stderr, "unused outb: port=0x%04x data=0x%02x\n", address, data);
-#endif
-}
-
-/* default is to make two byte accesses */
-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);
- data |= ioport_read(0, address) << 8;
- return data;
-}
-
-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);
- ioport_write(0, address, (data >> 8) & 0xff);
-}
-
-static uint32_t default_ioport_readl(void *opaque, uint32_t address)
-{
-#ifdef DEBUG_UNUSED_IOPORT
- fprintf(stderr, "unused inl: port=0x%04x\n", address);
-#endif
- return 0xffffffff;
-}
-
-static void default_ioport_writel(void *opaque, uint32_t address, uint32_t data)
-{
-#ifdef DEBUG_UNUSED_IOPORT
- fprintf(stderr, "unused outl: port=0x%04x data=0x%02x\n", address, data);
-#endif
-}
-
-/* size is the word size in byte */
-int register_ioport_read(int start, int length, int size,
- IOPortReadFunc *func, void *opaque)
-{
- int i, bsize;
-
- if (size == 1) {
- bsize = 0;
- } else if (size == 2) {
- bsize = 1;
- } else if (size == 4) {
- bsize = 2;
- } else {
- hw_error("register_ioport_read: invalid size");
- return -1;
- }
- for(i = start; i < start + length; i += size) {
- ioport_read_table[bsize][i] = func;
- if (ioport_opaque[i] != NULL && ioport_opaque[i] != opaque)
- hw_error("register_ioport_read: invalid opaque");
- ioport_opaque[i] = opaque;
- }
- return 0;
-}
-
-/* size is the word size in byte */
-int register_ioport_write(int start, int length, int size,
- IOPortWriteFunc *func, void *opaque)
-{
- int i, bsize;
-
- if (size == 1) {
- bsize = 0;
- } else if (size == 2) {
- bsize = 1;
- } else if (size == 4) {
- bsize = 2;
- } else {
- hw_error("register_ioport_write: invalid size");
- return -1;
- }
- for(i = start; i < start + length; i += size) {
- ioport_write_table[bsize][i] = func;
- if (ioport_opaque[i] != NULL && ioport_opaque[i] != opaque)
- hw_error("register_ioport_write: invalid opaque");
- ioport_opaque[i] = opaque;
- }
- return 0;
-}
-
-void isa_unassign_ioport(int start, int length)
-{
- int i;
-
- for(i = start; i < start + length; i++) {
- ioport_read_table[0][i] = default_ioport_readb;
- ioport_read_table[1][i] = default_ioport_readw;
- ioport_read_table[2][i] = default_ioport_readl;
-
- ioport_write_table[0][i] = default_ioport_writeb;
- ioport_write_table[1][i] = default_ioport_writew;
- ioport_write_table[2][i] = default_ioport_writel;
-
- ioport_opaque[i] = NULL;
- }
-}
-
-/***********************************************************/
-
-void cpu_outb(CPUState *env, int addr, int val)
-{
- LOG_IOPORT("outb: %04x %02x\n", addr, val);
- ioport_write(0, addr, val);
-#ifdef CONFIG_KQEMU
- if (env)
- env->last_io_time = cpu_get_time_fast();
-#endif
-}
-
-void cpu_outw(CPUState *env, int addr, int val)
-{
- LOG_IOPORT("outw: %04x %04x\n", addr, val);
- ioport_write(1, addr, val);
-#ifdef CONFIG_KQEMU
- if (env)
- env->last_io_time = cpu_get_time_fast();
-#endif
-}
-
-void cpu_outl(CPUState *env, int addr, int val)
-{
- LOG_IOPORT("outl: %04x %08x\n", addr, val);
- ioport_write(2, addr, val);
-#ifdef CONFIG_KQEMU
- if (env)
- env->last_io_time = cpu_get_time_fast();
-#endif
-}
-
-int cpu_inb(CPUState *env, int addr)
-{
- int val;
- val = ioport_read(0, addr);
- LOG_IOPORT("inb : %04x %02x\n", addr, val);
-#ifdef CONFIG_KQEMU
- if (env)
- env->last_io_time = cpu_get_time_fast();
-#endif
- return val;
-}
-
-int cpu_inw(CPUState *env, int addr)
-{
- int val;
- val = ioport_read(1, addr);
- LOG_IOPORT("inw : %04x %04x\n", addr, val);
-#ifdef CONFIG_KQEMU
- if (env)
- env->last_io_time = cpu_get_time_fast();
-#endif
- return val;
-}
-
-int cpu_inl(CPUState *env, int addr)
-{
- int val;
- val = ioport_read(2, addr);
- LOG_IOPORT("inl : %04x %08x\n", addr, val);
-#ifdef CONFIG_KQEMU
- if (env)
- env->last_io_time = cpu_get_time_fast();
-#endif
- return val;
-}
-
/***********************************************************/
void hw_error(const char *fmt, ...)
{
--
1.6.0.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [Qemu-devel] [PATCH 2/6] use constant IOPORTS_MASK instead of 0xffff.
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 1/6] split out ioport related stuffs from vl.c into ioport.c Isaku Yamahata
@ 2009-07-10 9:13 ` Isaku Yamahata
2009-07-10 9:13 ` [Qemu-devel] [PATCH 3/6] ioport: consolidate duplicated logic in register_ioport_{read, write}() Isaku Yamahata
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Isaku Yamahata @ 2009-07-10 9:13 UTC (permalink / raw)
To: qemu-devel; +Cc: yamahata
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
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [Qemu-devel] [PATCH 3/6] ioport: consolidate duplicated logic in register_ioport_{read, write}().
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 1/6] split out ioport related stuffs from vl.c into ioport.c Isaku Yamahata
2009-07-10 9:13 ` [Qemu-devel] [PATCH 2/6] use constant IOPORTS_MASK instead of 0xffff Isaku Yamahata
@ 2009-07-10 9:13 ` Isaku Yamahata
2009-07-10 9:13 ` [Qemu-devel] [PATCH 4/6] ioport: remove some #ifdef DEBUG_UNUSED_IOPORT Isaku Yamahata
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Isaku Yamahata @ 2009-07-10 9:13 UTC (permalink / raw)
To: qemu-devel; +Cc: yamahata
consolidate duplicated logic in register_ioport_{read, write}().
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
---
ioport.c | 30 ++++++++++++++++--------------
1 files changed, 16 insertions(+), 14 deletions(-)
diff --git a/ioport.c b/ioport.c
index 04bffc4..01cfaf7 100644
--- a/ioport.c
+++ b/ioport.c
@@ -121,19 +121,27 @@ static void default_ioport_writel(void *opaque, uint32_t address, uint32_t data)
#endif
}
+static int ioport_bsize(int size, int *bsize)
+{
+ if (size == 1) {
+ *bsize = 0;
+ } else if (size == 2) {
+ *bsize = 1;
+ } else if (size == 4) {
+ *bsize = 2;
+ } else {
+ return -1;
+ }
+ return 0;
+}
+
/* size is the word size in byte */
int register_ioport_read(int start, int length, int size,
IOPortReadFunc *func, void *opaque)
{
int i, bsize;
- if (size == 1) {
- bsize = 0;
- } else if (size == 2) {
- bsize = 1;
- } else if (size == 4) {
- bsize = 2;
- } else {
+ if (ioport_bsize(size, &bsize)) {
hw_error("register_ioport_read: invalid size");
return -1;
}
@@ -152,13 +160,7 @@ int register_ioport_write(int start, int length, int size,
{
int i, bsize;
- if (size == 1) {
- bsize = 0;
- } else if (size == 2) {
- bsize = 1;
- } else if (size == 4) {
- bsize = 2;
- } else {
+ if (ioport_bsize(size, &bsize)) {
hw_error("register_ioport_write: invalid size");
return -1;
}
--
1.6.0.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [Qemu-devel] [PATCH 4/6] ioport: remove some #ifdef DEBUG_UNUSED_IOPORT.
2009-07-10 9:13 [Qemu-devel] [PATCH 0/6] ioport related clean ups. V3 Isaku Yamahata
` (2 preceding siblings ...)
2009-07-10 9:13 ` [Qemu-devel] [PATCH 3/6] ioport: consolidate duplicated logic in register_ioport_{read, write}() Isaku Yamahata
@ 2009-07-10 9:13 ` Isaku Yamahata
2009-07-10 9:13 ` [Qemu-devel] [PATCH 5/6] consolidate user cpu_{in, out}[bwl] into ioport-user.c Isaku Yamahata
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Isaku Yamahata @ 2009-07-10 9:13 UTC (permalink / raw)
To: qemu-devel; +Cc: yamahata, Paolo Bonzini
remove some #ifdef DEBUG_UNUSED_IOPORT in ioport.c
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Cc: Anthony Liguori <anthony@codemonkey.ws>
Cc: Paolo Bonzini <pbonzini@redhat.com>
---
ioport.c | 24 ++++++++++++------------
1 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/ioport.c b/ioport.c
index 01cfaf7..60c4202 100644
--- a/ioport.c
+++ b/ioport.c
@@ -33,6 +33,12 @@
//#define DEBUG_UNUSED_IOPORT
//#define DEBUG_IOPORT
+#ifdef DEBUG_UNUSED_IOPORT
+# define LOG_UNUSED_IOPORT(fmt, ...) fprintf(stderr, fmt, ## __VA_ARGS__)
+#else
+# define LOG_UNUSED_IOPORT(fmt, ...) do{ } while (0)
+#endif
+
#ifdef DEBUG_IOPORT
# define LOG_IOPORT(...) qemu_log_mask(CPU_LOG_IOPORT, ## __VA_ARGS__)
#else
@@ -76,17 +82,14 @@ static void ioport_write(int index, uint32_t address, uint32_t data)
static uint32_t default_ioport_readb(void *opaque, uint32_t address)
{
-#ifdef DEBUG_UNUSED_IOPORT
- fprintf(stderr, "unused inb: port=0x%04x\n", address);
-#endif
+ LOG_UNUSED_IOPORT("unused inb: port=0x%04x\n", address);
return 0xff;
}
static void default_ioport_writeb(void *opaque, uint32_t address, uint32_t data)
{
-#ifdef DEBUG_UNUSED_IOPORT
- fprintf(stderr, "unused outb: port=0x%04x data=0x%02x\n", address, data);
-#endif
+ LOG_UNUSED_IOPORT("unused outb: port=0x%04x data=0x%02x\n",
+ address, data);
}
/* default is to make two byte accesses */
@@ -108,17 +111,14 @@ static void default_ioport_writew(void *opaque, uint32_t address, uint32_t data)
static uint32_t default_ioport_readl(void *opaque, uint32_t address)
{
-#ifdef DEBUG_UNUSED_IOPORT
- fprintf(stderr, "unused inl: port=0x%04x\n", address);
-#endif
+ LOG_UNUSED_IOPORT("unused inl: port=0x%04x\n", address);
return 0xffffffff;
}
static void default_ioport_writel(void *opaque, uint32_t address, uint32_t data)
{
-#ifdef DEBUG_UNUSED_IOPORT
- fprintf(stderr, "unused outl: port=0x%04x data=0x%02x\n", address, data);
-#endif
+ LOG_UNUSED_IOPORT("unused outl: port=0x%04x data=0x%02x\n",
+ address, data);
}
static int ioport_bsize(int size, int *bsize)
--
1.6.0.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [Qemu-devel] [PATCH 5/6] consolidate user cpu_{in, out}[bwl] into ioport-user.c
2009-07-10 9:13 [Qemu-devel] [PATCH 0/6] ioport related clean ups. V3 Isaku Yamahata
` (3 preceding siblings ...)
2009-07-10 9:13 ` [Qemu-devel] [PATCH 4/6] ioport: remove some #ifdef DEBUG_UNUSED_IOPORT Isaku Yamahata
@ 2009-07-10 9:13 ` Isaku Yamahata
2009-07-10 9:13 ` [Qemu-devel] [PATCH 6/6] use uint{32, 16, 8}_t for ioport value and uint16_t for ioport address Isaku Yamahata
2009-07-10 13:00 ` [Qemu-devel] [PATCH 0/6] ioport related clean ups. V3 Anthony Liguori
6 siblings, 0 replies; 8+ messages in thread
From: Isaku Yamahata @ 2009-07-10 9:13 UTC (permalink / raw)
To: qemu-devel; +Cc: yamahata
consolidate user cpu_{in, out}[bwl] into ioport-user.c
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
---
Makefile.target | 7 +++--
bsd-user/main.c | 33 -----------------------------
darwin-user/main.c | 33 -----------------------------
ioport-user.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++
linux-user/main.c | 33 -----------------------------
tests/Makefile | 4 +-
tests/qruncom.c | 33 -----------------------------
7 files changed, 65 insertions(+), 137 deletions(-)
create mode 100644 ioport-user.c
diff --git a/Makefile.target b/Makefile.target
index 7f7c167..1a71f3a 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -321,7 +321,8 @@ CFLAGS+=-p
endif
obj-y = main.o syscall.o strace.o mmap.o signal.o path.o thunk.o \
- elfload.o linuxload.o uaccess.o envlist.o gdbstub.o gdbstub-xml.o
+ elfload.o linuxload.o uaccess.o envlist.o gdbstub.o gdbstub-xml.o \
+ ioport-user.o
LIBS+= $(PTHREADLIBS)
LIBS+= $(CLOCKLIBS)
obj-$(TARGET_HAS_BFLT) += flatload.o
@@ -372,7 +373,7 @@ LDFLAGS+=-Wl,-segaddr,__STD_PROG_ZONE,0x1000 -image_base 0x0e000000
LIBS+=-lmx
obj-y = main.o commpage.o machload.o mmap.o signal.o syscall.o thunk.o \
- gdbstub.o gdbstub-xml.o
+ gdbstub.o gdbstub-xml.o ioport-user.o
# Note: this is a workaround. The real fix is to avoid compiling
# cpu_signal_handler() in cpu-exec.c.
@@ -471,7 +472,7 @@ endif
endif
obj-y = main.o bsdload.o elfload.o mmap.o path.o signal.o strace.o syscall.o \
- gdbstub.o gdbstub-xml.o
+ gdbstub.o gdbstub-xml.o ioport-user.o
obj-y += uaccess.o
# Note: this is a workaround. The real fix is to avoid compiling
diff --git a/bsd-user/main.c b/bsd-user/main.c
index 827c9c3..e4a6255 100644
--- a/bsd-user/main.c
+++ b/bsd-user/main.c
@@ -55,39 +55,6 @@ void gemu_log(const char *fmt, ...)
va_end(ap);
}
-void cpu_outb(CPUState *env, int addr, int val)
-{
- fprintf(stderr, "outb: port=0x%04x, data=%02x\n", addr, val);
-}
-
-void cpu_outw(CPUState *env, int addr, int val)
-{
- fprintf(stderr, "outw: port=0x%04x, data=%04x\n", addr, val);
-}
-
-void cpu_outl(CPUState *env, int addr, int val)
-{
- fprintf(stderr, "outl: port=0x%04x, data=%08x\n", addr, val);
-}
-
-int cpu_inb(CPUState *env, int addr)
-{
- fprintf(stderr, "inb: port=0x%04x\n", addr);
- return 0;
-}
-
-int cpu_inw(CPUState *env, int addr)
-{
- fprintf(stderr, "inw: port=0x%04x\n", addr);
- return 0;
-}
-
-int cpu_inl(CPUState *env, int addr)
-{
- fprintf(stderr, "inl: port=0x%04x\n", addr);
- return 0;
-}
-
#if defined(TARGET_I386)
int cpu_get_pic_interrupt(CPUState *env)
{
diff --git a/darwin-user/main.c b/darwin-user/main.c
index 5e3c48d..27c7284 100644
--- a/darwin-user/main.c
+++ b/darwin-user/main.c
@@ -72,39 +72,6 @@ void gemu_log(const char *fmt, ...)
va_end(ap);
}
-void cpu_outb(CPUState *env, int addr, int val)
-{
- fprintf(stderr, "outb: port=0x%04x, data=%02x\n", addr, val);
-}
-
-void cpu_outw(CPUState *env, int addr, int val)
-{
- fprintf(stderr, "outw: port=0x%04x, data=%04x\n", addr, val);
-}
-
-void cpu_outl(CPUState *env, int addr, int val)
-{
- fprintf(stderr, "outl: port=0x%04x, data=%08x\n", addr, val);
-}
-
-int cpu_inb(CPUState *env, int addr)
-{
- fprintf(stderr, "inb: port=0x%04x\n", addr);
- return 0;
-}
-
-int cpu_inw(CPUState *env, int addr)
-{
- fprintf(stderr, "inw: port=0x%04x\n", addr);
- return 0;
-}
-
-int cpu_inl(CPUState *env, int addr)
-{
- fprintf(stderr, "inl: port=0x%04x\n", addr);
- return 0;
-}
-
int cpu_get_pic_interrupt(CPUState *env)
{
return -1;
diff --git a/ioport-user.c b/ioport-user.c
new file mode 100644
index 0000000..fe8567f
--- /dev/null
+++ b/ioport-user.c
@@ -0,0 +1,59 @@
+/*
+ * qemu user ioport functions
+ *
+ * Copyright (c) 2003-2008 Fabrice Bellard
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+
+#include <stdio.h>
+
+#include "qemu.h"
+#include "qemu-common.h"
+#include "ioport.h"
+
+void cpu_outb(CPUState *env, int addr, int val)
+{
+ fprintf(stderr, "outb: port=0x%04x, data=%02x\n", addr, val);
+}
+
+void cpu_outw(CPUState *env, int addr, int val)
+{
+ fprintf(stderr, "outw: port=0x%04x, data=%04x\n", addr, val);
+}
+
+void cpu_outl(CPUState *env, int addr, int val)
+{
+ fprintf(stderr, "outl: port=0x%04x, data=%08x\n", addr, val);
+}
+
+int cpu_inb(CPUState *env, int addr)
+{
+ fprintf(stderr, "inb: port=0x%04x\n", addr);
+ return 0;
+}
+
+int cpu_inw(CPUState *env, int addr)
+{
+ fprintf(stderr, "inw: port=0x%04x\n", addr);
+ return 0;
+}
+
+int cpu_inl(CPUState *env, int addr)
+{
+ fprintf(stderr, "inl: port=0x%04x\n", addr);
+ return 0;
+}
diff --git a/linux-user/main.c b/linux-user/main.c
index 7eabd0c..ef448a4 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -85,39 +85,6 @@ void gemu_log(const char *fmt, ...)
va_end(ap);
}
-void cpu_outb(CPUState *env, int addr, int val)
-{
- fprintf(stderr, "outb: port=0x%04x, data=%02x\n", addr, val);
-}
-
-void cpu_outw(CPUState *env, int addr, int val)
-{
- fprintf(stderr, "outw: port=0x%04x, data=%04x\n", addr, val);
-}
-
-void cpu_outl(CPUState *env, int addr, int val)
-{
- fprintf(stderr, "outl: port=0x%04x, data=%08x\n", addr, val);
-}
-
-int cpu_inb(CPUState *env, int addr)
-{
- fprintf(stderr, "inb: port=0x%04x\n", addr);
- return 0;
-}
-
-int cpu_inw(CPUState *env, int addr)
-{
- fprintf(stderr, "inw: port=0x%04x\n", addr);
- return 0;
-}
-
-int cpu_inl(CPUState *env, int addr)
-{
- fprintf(stderr, "inl: port=0x%04x\n", addr);
- return 0;
-}
-
#if defined(TARGET_I386)
int cpu_get_pic_interrupt(CPUState *env)
{
diff --git a/tests/Makefile b/tests/Makefile
index 326b733..69092e5 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -78,9 +78,9 @@ runcom: runcom.c
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $<
# NOTE: -fomit-frame-pointer is currently needed : this is a bug in libqemu
-qruncom: qruncom.c ../i386-user/libqemu.a
+qruncom: qruncom.c ../ioport-user.c ../i386-user/libqemu.a
$(CC) $(CFLAGS) -fomit-frame-pointer $(LDFLAGS) -I../target-i386 -I.. -I../i386-user -I../fpu \
- -o $@ $< -L../i386-user -lqemu -lm
+ -o $@ $(filter %.c, $^) -L../i386-user -lqemu -lm
# arm test
hello-arm: hello-arm.o
diff --git a/tests/qruncom.c b/tests/qruncom.c
index 5e503bc..a8d0ef6 100644
--- a/tests/qruncom.c
+++ b/tests/qruncom.c
@@ -16,39 +16,6 @@
//#define SIGTEST
-void cpu_outb(CPUState *env, int addr, int val)
-{
- fprintf(stderr, "outb: port=0x%04x, data=%02x\n", addr, val);
-}
-
-void cpu_outw(CPUState *env, int addr, int val)
-{
- fprintf(stderr, "outw: port=0x%04x, data=%04x\n", addr, val);
-}
-
-void cpu_outl(CPUState *env, int addr, int val)
-{
- fprintf(stderr, "outl: port=0x%04x, data=%08x\n", addr, val);
-}
-
-int cpu_inb(CPUState *env, int addr)
-{
- fprintf(stderr, "inb: port=0x%04x\n", addr);
- return 0;
-}
-
-int cpu_inw(CPUState *env, int addr)
-{
- fprintf(stderr, "inw: port=0x%04x\n", addr);
- return 0;
-}
-
-int cpu_inl(CPUState *env, int addr)
-{
- fprintf(stderr, "inl: port=0x%04x\n", addr);
- return 0;
-}
-
int cpu_get_pic_interrupt(CPUState *env)
{
return -1;
--
1.6.0.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [Qemu-devel] [PATCH 6/6] use uint{32, 16, 8}_t for ioport value and uint16_t for ioport address.
2009-07-10 9:13 [Qemu-devel] [PATCH 0/6] ioport related clean ups. V3 Isaku Yamahata
` (4 preceding siblings ...)
2009-07-10 9:13 ` [Qemu-devel] [PATCH 5/6] consolidate user cpu_{in, out}[bwl] into ioport-user.c Isaku Yamahata
@ 2009-07-10 9:13 ` Isaku Yamahata
2009-07-10 13:00 ` [Qemu-devel] [PATCH 0/6] ioport related clean ups. V3 Anthony Liguori
6 siblings, 0 replies; 8+ messages in thread
From: Isaku Yamahata @ 2009-07-10 9:13 UTC (permalink / raw)
To: qemu-devel; +Cc: yamahata, Samuel Thibault
use uint{32, 16, 8}_t for ioport value and uint16_t for ioport address.
uint{32, 16, 8}_t are appropriate for byte, word and long.
uint16_t is appropriate for 64Kbyte ioport.
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Cc: Stuart Brady <sdbrady@ntlworld.com>
Cc: Anthony Liguori <anthony@codemonkey.ws>
Cc: Samuel Thibault <samuel.thibault@gnu.org>
---
ioport-user.c | 24 ++++++++++++------------
ioport.c | 45 ++++++++++++++++++++++-----------------------
ioport.h | 18 +++++++++---------
3 files changed, 43 insertions(+), 44 deletions(-)
diff --git a/ioport-user.c b/ioport-user.c
index fe8567f..95e1059 100644
--- a/ioport-user.c
+++ b/ioport-user.c
@@ -25,35 +25,35 @@
#include "qemu-common.h"
#include "ioport.h"
-void cpu_outb(CPUState *env, int addr, int val)
+void cpu_outb(CPUState *env, uint16_t addr, uint8_t val)
{
- fprintf(stderr, "outb: port=0x%04x, data=%02x\n", addr, val);
+ fprintf(stderr, "outb: port=0x%04"PRIx16", data=%02"PRIx8"\n", addr, val);
}
-void cpu_outw(CPUState *env, int addr, int val)
+void cpu_outw(CPUState *env, uint16_t addr, uint16_t val)
{
- fprintf(stderr, "outw: port=0x%04x, data=%04x\n", addr, val);
+ fprintf(stderr, "outw: port=0x%04"PRIx16", data=%04"PRIx16"\n", addr, val);
}
-void cpu_outl(CPUState *env, int addr, int val)
+void cpu_outl(CPUState *env, uint16_t addr, uint32_t val)
{
- fprintf(stderr, "outl: port=0x%04x, data=%08x\n", addr, val);
+ fprintf(stderr, "outl: port=0x%04"PRIx16", data=%08"PRIx32"\n", addr, val);
}
-int cpu_inb(CPUState *env, int addr)
+uint8_t cpu_inb(CPUState *env, uint16_t addr)
{
- fprintf(stderr, "inb: port=0x%04x\n", addr);
+ fprintf(stderr, "inb: port=0x%04"PRIx16"\n", addr);
return 0;
}
-int cpu_inw(CPUState *env, int addr)
+uint16_t cpu_inw(CPUState *env, uint16_t addr)
{
- fprintf(stderr, "inw: port=0x%04x\n", addr);
+ fprintf(stderr, "inw: port=0x%04"PRIx16"\n", addr);
return 0;
}
-int cpu_inl(CPUState *env, int addr)
+uint32_t cpu_inl(CPUState *env, uint16_t addr)
{
- fprintf(stderr, "inl: port=0x%04x\n", addr);
+ fprintf(stderr, "inl: port=0x%04"PRIx16"\n", addr);
return 0;
}
diff --git a/ioport.c b/ioport.c
index 60c4202..d381d27 100644
--- a/ioport.c
+++ b/ioport.c
@@ -82,13 +82,13 @@ static void ioport_write(int index, uint32_t address, uint32_t data)
static uint32_t default_ioport_readb(void *opaque, uint32_t address)
{
- LOG_UNUSED_IOPORT("unused inb: port=0x%04x\n", address);
+ LOG_UNUSED_IOPORT("unused inb: port=0x%04"PRIx32"\n", address);
return 0xff;
}
static void default_ioport_writeb(void *opaque, uint32_t address, uint32_t data)
{
- LOG_UNUSED_IOPORT("unused outb: port=0x%04x data=0x%02x\n",
+ LOG_UNUSED_IOPORT("unused outb: port=0x%04"PRIx32" data=0x%02"PRIx32"\n",
address, data);
}
@@ -111,13 +111,13 @@ static void default_ioport_writew(void *opaque, uint32_t address, uint32_t data)
static uint32_t default_ioport_readl(void *opaque, uint32_t address)
{
- LOG_UNUSED_IOPORT("unused inl: port=0x%04x\n", address);
+ LOG_UNUSED_IOPORT("unused inl: port=0x%04"PRIx32"\n", address);
return 0xffffffff;
}
static void default_ioport_writel(void *opaque, uint32_t address, uint32_t data)
{
- LOG_UNUSED_IOPORT("unused outl: port=0x%04x data=0x%02x\n",
+ LOG_UNUSED_IOPORT("unused outl: port=0x%04"PRIx32" data=0x%02"PRIx32"\n",
address, data);
}
@@ -136,7 +136,7 @@ static int ioport_bsize(int size, int *bsize)
}
/* size is the word size in byte */
-int register_ioport_read(int start, int length, int size,
+int register_ioport_read(uint32_t start, int length, int size,
IOPortReadFunc *func, void *opaque)
{
int i, bsize;
@@ -155,7 +155,7 @@ int register_ioport_read(int start, int length, int size,
}
/* size is the word size in byte */
-int register_ioport_write(int start, int length, int size,
+int register_ioport_write(uint32_t start, int length, int size,
IOPortWriteFunc *func, void *opaque)
{
int i, bsize;
@@ -173,7 +173,7 @@ int register_ioport_write(int start, int length, int size,
return 0;
}
-void isa_unassign_ioport(int start, int length)
+void isa_unassign_ioport(uint32_t start, int length)
{
int i;
@@ -192,9 +192,9 @@ void isa_unassign_ioport(int start, int length)
/***********************************************************/
-void cpu_outb(CPUState *env, int addr, int val)
+void cpu_outb(CPUState *env, uint16_t addr, uint8_t val)
{
- LOG_IOPORT("outb: %04x %02x\n", addr, val);
+ LOG_IOPORT("outb: %04"PRIx16" %02"PRIx8"\n", addr, val);
ioport_write(0, addr, val);
#ifdef CONFIG_KQEMU
if (env)
@@ -202,9 +202,9 @@ void cpu_outb(CPUState *env, int addr, int val)
#endif
}
-void cpu_outw(CPUState *env, int addr, int val)
+void cpu_outw(CPUState *env, uint16_t addr, uint16_t val)
{
- LOG_IOPORT("outw: %04x %04x\n", addr, val);
+ LOG_IOPORT("outw: %04"PRIx16" %04"PRIx16"\n", addr, val);
ioport_write(1, addr, val);
#ifdef CONFIG_KQEMU
if (env)
@@ -212,9 +212,9 @@ void cpu_outw(CPUState *env, int addr, int val)
#endif
}
-void cpu_outl(CPUState *env, int addr, int val)
+void cpu_outl(CPUState *env, uint16_t addr, uint32_t val)
{
- LOG_IOPORT("outl: %04x %08x\n", addr, val);
+ LOG_IOPORT("outl: %04"PRIx16" %08"PRIx32"\n", addr, val);
ioport_write(2, addr, val);
#ifdef CONFIG_KQEMU
if (env)
@@ -222,11 +222,11 @@ void cpu_outl(CPUState *env, int addr, int val)
#endif
}
-int cpu_inb(CPUState *env, int addr)
+uint8_t cpu_inb(CPUState *env, uint16_t addr)
{
- int val;
+ uint8_t val;
val = ioport_read(0, addr);
- LOG_IOPORT("inb : %04x %02x\n", addr, val);
+ LOG_IOPORT("inb : %04"PRIx16" %02"PRIx8"\n", addr, val);
#ifdef CONFIG_KQEMU
if (env)
env->last_io_time = cpu_get_time_fast();
@@ -234,11 +234,11 @@ int cpu_inb(CPUState *env, int addr)
return val;
}
-int cpu_inw(CPUState *env, int addr)
+uint16_t cpu_inw(CPUState *env, uint16_t addr)
{
- int val;
+ uint16_t val;
val = ioport_read(1, addr);
- LOG_IOPORT("inw : %04x %04x\n", addr, val);
+ LOG_IOPORT("inw : %04"PRIx16" %04"PRIx16"\n", addr, val);
#ifdef CONFIG_KQEMU
if (env)
env->last_io_time = cpu_get_time_fast();
@@ -246,15 +246,14 @@ int cpu_inw(CPUState *env, int addr)
return val;
}
-int cpu_inl(CPUState *env, int addr)
+uint32_t cpu_inl(CPUState *env, uint16_t addr)
{
- int val;
+ uint32_t val;
val = ioport_read(2, addr);
- LOG_IOPORT("inl : %04x %08x\n", addr, val);
+ LOG_IOPORT("inl : %04"PRIx16" %08"PRIx32"\n", addr, val);
#ifdef CONFIG_KQEMU
if (env)
env->last_io_time = cpu_get_time_fast();
#endif
return val;
}
-
diff --git a/ioport.h b/ioport.h
index 4cb59e9..e20baaa 100644
--- a/ioport.h
+++ b/ioport.h
@@ -34,22 +34,22 @@
typedef void (IOPortWriteFunc)(void *opaque, uint32_t address, uint32_t data);
typedef uint32_t (IOPortReadFunc)(void *opaque, uint32_t address);
-int register_ioport_read(int start, int length, int size,
+int register_ioport_read(uint32_t start, int length, int size,
IOPortReadFunc *func, void *opaque);
-int register_ioport_write(int start, int length, int size,
+int register_ioport_write(uint32_t start, int length, int size,
IOPortWriteFunc *func, void *opaque);
-void isa_unassign_ioport(int start, int length);
+void isa_unassign_ioport(uint32_t start, int length);
/* NOTE: as these functions may be even used when there is an isa
brige on non x86 targets, we always defined them */
#if !defined(NO_CPU_IO_DEFS) && defined(NEED_CPU_H)
-void cpu_outb(CPUState *env, int addr, int val);
-void cpu_outw(CPUState *env, int addr, int val);
-void cpu_outl(CPUState *env, int addr, int val);
-int cpu_inb(CPUState *env, int addr);
-int cpu_inw(CPUState *env, int addr);
-int cpu_inl(CPUState *env, int addr);
+void cpu_outb(CPUState *env, uint16_t addr, uint8_t val);
+void cpu_outw(CPUState *env, uint16_t addr, uint16_t val);
+void cpu_outl(CPUState *env, uint16_t addr, uint32_t val);
+uint8_t cpu_inb(CPUState *env, uint16_t addr);
+uint16_t cpu_inw(CPUState *env, uint16_t addr);
+uint32_t cpu_inl(CPUState *env, uint16_t addr);
#endif
#endif /* IOPORT_H */
--
1.6.0.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [PATCH 0/6] ioport related clean ups. V3
2009-07-10 9:13 [Qemu-devel] [PATCH 0/6] ioport related clean ups. V3 Isaku Yamahata
` (5 preceding siblings ...)
2009-07-10 9:13 ` [Qemu-devel] [PATCH 6/6] use uint{32, 16, 8}_t for ioport value and uint16_t for ioport address Isaku Yamahata
@ 2009-07-10 13:00 ` Anthony Liguori
6 siblings, 0 replies; 8+ messages in thread
From: Anthony Liguori @ 2009-07-10 13:00 UTC (permalink / raw)
To: Isaku Yamahata; +Cc: qemu-devel
Isaku Yamahata wrote:
> This patch series cleans up io port emulation
> sliming down bloated vl.c a bit and consolidated
> ones used for user emulation.
>
You should rebase again because some of these patches are in git already.
Regards,
Anthony Liguori
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2009-07-10 13:00 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 1/6] split out ioport related stuffs from vl.c into ioport.c Isaku Yamahata
2009-07-10 9:13 ` [Qemu-devel] [PATCH 2/6] use constant IOPORTS_MASK instead of 0xffff Isaku Yamahata
2009-07-10 9:13 ` [Qemu-devel] [PATCH 3/6] ioport: consolidate duplicated logic in register_ioport_{read, write}() Isaku Yamahata
2009-07-10 9:13 ` [Qemu-devel] [PATCH 4/6] ioport: remove some #ifdef DEBUG_UNUSED_IOPORT Isaku Yamahata
2009-07-10 9:13 ` [Qemu-devel] [PATCH 5/6] consolidate user cpu_{in, out}[bwl] into ioport-user.c Isaku Yamahata
2009-07-10 9:13 ` [Qemu-devel] [PATCH 6/6] use uint{32, 16, 8}_t for ioport value and uint16_t for ioport address Isaku Yamahata
2009-07-10 13:00 ` [Qemu-devel] [PATCH 0/6] ioport related clean ups. V3 Anthony Liguori
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.