# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1203343967 0
# Node ID 340565d275f9631c5a19ed1b7c88f3cbe2e19056
# Parent 408acef82ffb5451bca9bd18fb5b3bf151eefc43
ioemu: save 3MB of ioport tables (on 64bit machines)
by keeping then initialized to NULL and check for it in the handlers.
Signed-off-by: Samuel Thibault <samuel.thibault@xxxxxxxxxxxxx>
xen-unstable changeset: 17019:7e189fc27f4ffd0bfcb1727dbbf3b06a1a515705
xen-unstable date: Mon Feb 11 14:47:19 2008 +0000
---
tools/ioemu/vl.c | 60 ++++++++++++++++++++++++++++++++++++-------------------
1 files changed, 40 insertions(+), 20 deletions(-)
diff -r 408acef82ffb -r 340565d275f9 tools/ioemu/vl.c
--- a/tools/ioemu/vl.c Mon Feb 18 14:12:23 2008 +0000
+++ b/tools/ioemu/vl.c Mon Feb 18 14:12:47 2008 +0000
@@ -224,17 +224,29 @@ uint32_t default_ioport_readw(void *opaq
uint32_t default_ioport_readw(void *opaque, uint32_t address)
{
uint32_t data;
- data = ioport_read_table[0][address](ioport_opaque[address], address);
+ IOPortReadFunc *func = ioport_read_table[0][address];
+ if (!func)
+ func = default_ioport_readb;
+ data = func(ioport_opaque[address], address);
address = (address + 1) & (MAX_IOPORTS - 1);
- data |= ioport_read_table[0][address](ioport_opaque[address], address) <<
8;
+ func = ioport_read_table[0][address];
+ if (!func)
+ func = default_ioport_readb;
+ data |= func(ioport_opaque[address], address) << 8;
return data;
}
void default_ioport_writew(void *opaque, uint32_t address, uint32_t data)
{
- ioport_write_table[0][address](ioport_opaque[address], address, data &
0xff);
+ IOPortWriteFunc *func = ioport_write_table[0][address];
+ if (!func)
+ func = default_ioport_writeb;
+ func(ioport_opaque[address], address, data & 0xff);
address = (address + 1) & (MAX_IOPORTS - 1);
- ioport_write_table[0][address](ioport_opaque[address], address, (data >>
8) & 0xff);
+ func = ioport_write_table[0][address];
+ if (!func)
+ func = default_ioport_writeb;
+ func(ioport_opaque[address], address, (data >> 8) & 0xff);
}
uint32_t default_ioport_readl(void *opaque, uint32_t address)
@@ -254,16 +266,6 @@ void default_ioport_writel(void *opaque,
void init_ioports(void)
{
- int i;
-
- for(i = 0; i < MAX_IOPORTS; i++) {
- ioport_read_table[0][i] = default_ioport_readb;
- ioport_write_table[0][i] = default_ioport_writeb;
- ioport_read_table[1][i] = default_ioport_readw;
- ioport_write_table[1][i] = default_ioport_writew;
- ioport_read_table[2][i] = default_ioport_readl;
- ioport_write_table[2][i] = default_ioport_writel;
- }
}
/* size is the word size in byte */
@@ -335,11 +337,14 @@ void isa_unassign_ioport(int start, int
void cpu_outb(CPUState *env, int addr, int val)
{
+ IOPortWriteFunc *func = ioport_write_table[0][addr];
+ if (!func)
+ func = default_ioport_writeb;
#ifdef DEBUG_IOPORT
if (loglevel & CPU_LOG_IOPORT)
fprintf(logfile, "outb: %04x %02x\n", addr, val);
#endif
- ioport_write_table[0][addr](ioport_opaque[addr], addr, val);
+ func(ioport_opaque[addr], addr, val);
#ifdef USE_KQEMU
if (env)
env->last_io_time = cpu_get_time_fast();
@@ -348,11 +353,14 @@ void cpu_outb(CPUState *env, int addr, i
void cpu_outw(CPUState *env, int addr, int val)
{
+ IOPortWriteFunc *func = ioport_write_table[1][addr];
+ if (!func)
+ func = default_ioport_writew;
#ifdef DEBUG_IOPORT
if (loglevel & CPU_LOG_IOPORT)
fprintf(logfile, "outw: %04x %04x\n", addr, val);
#endif
- ioport_write_table[1][addr](ioport_opaque[addr], addr, val);
+ func(ioport_opaque[addr], addr, val);
#ifdef USE_KQEMU
if (env)
env->last_io_time = cpu_get_time_fast();
@@ -361,11 +369,14 @@ void cpu_outw(CPUState *env, int addr, i
void cpu_outl(CPUState *env, int addr, int val)
{
+ IOPortWriteFunc *func = ioport_write_table[2][addr];
+ if (!func)
+ func = default_ioport_writel;
#ifdef DEBUG_IOPORT
if (loglevel & CPU_LOG_IOPORT)
fprintf(logfile, "outl: %04x %08x\n", addr, val);
#endif
- ioport_write_table[2][addr](ioport_opaque[addr], addr, val);
+ func(ioport_opaque[addr], addr, val);
#ifdef USE_KQEMU
if (env)
env->last_io_time = cpu_get_time_fast();
@@ -375,7 +386,10 @@ int cpu_inb(CPUState *env, int addr)
int cpu_inb(CPUState *env, int addr)
{
int val;
- val = ioport_read_table[0][addr](ioport_opaque[addr], addr);
+ IOPortReadFunc *func = ioport_read_table[0][addr];
+ if (!func)
+ func = default_ioport_readb;
+ val = func(ioport_opaque[addr], addr);
#ifdef DEBUG_IOPORT
if (loglevel & CPU_LOG_IOPORT)
fprintf(logfile, "inb : %04x %02x\n", addr, val);
@@ -390,7 +404,10 @@ int cpu_inw(CPUState *env, int addr)
int cpu_inw(CPUState *env, int addr)
{
int val;
- val = ioport_read_table[1][addr](ioport_opaque[addr], addr);
+ IOPortReadFunc *func = ioport_read_table[1][addr];
+ if (!func)
+ func = default_ioport_readw;
+ val = func(ioport_opaque[addr], addr);
#ifdef DEBUG_IOPORT
if (loglevel & CPU_LOG_IOPORT)
fprintf(logfile, "inw : %04x %04x\n", addr, val);
@@ -405,7 +422,10 @@ int cpu_inl(CPUState *env, int addr)
int cpu_inl(CPUState *env, int addr)
{
int val;
- val = ioport_read_table[2][addr](ioport_opaque[addr], addr);
+ IOPortReadFunc *func = ioport_read_table[2][addr];
+ if (!func)
+ func = default_ioport_readl;
+ val = func(ioport_opaque[addr], addr);
#ifdef DEBUG_IOPORT
if (loglevel & CPU_LOG_IOPORT)
fprintf(logfile, "inl : %04x %08x\n", addr, val);
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|