qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 6/6] use uint{32, 16, 8}_t for ioport value and uint


From: Isaku Yamahata
Subject: [Qemu-devel] [PATCH 6/6] use uint{32, 16, 8}_t for ioport value and uint16_t for ioport address.
Date: Fri, 10 Jul 2009 18:13:25 +0900

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 <address@hidden>
Cc: Stuart Brady <address@hidden>
Cc: Anthony Liguori <address@hidden>
Cc: Samuel Thibault <address@hidden>
---
 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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]