Kyösti Mälkki (kyosti.malkki@gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/1466
-gerrit
commit 1bbb7f5ad7819dc0a30d1cdb9653fed9bd3d0732 Author: Kyösti Mälkki kyosti.malkki@gmail.com Date: Sun Aug 19 13:52:39 2012 +0300
SerialICE: Separate read and write loggers for IO and MEM
Use of the flags parameter looked ugly and obscure to me.
Change-Id: I1f7fb952a74df19200efd1ec0b216846fc474cdf Signed-off-by: Kyösti Mälkki kyosti.malkki@gmail.com --- qemu-0.15.x/serialice-lua.c | 38 ++++++++++++++++++++++++++++---------- qemu-0.15.x/serialice.c | 16 ++++++++-------- qemu-0.15.x/serialice.h | 3 ++- 3 files changed, 38 insertions(+), 19 deletions(-)
diff --git a/qemu-0.15.x/serialice-lua.c b/qemu-0.15.x/serialice-lua.c index eecb866..ba6e01e 100644 --- a/qemu-0.15.x/serialice-lua.c +++ b/qemu-0.15.x/serialice-lua.c @@ -436,17 +436,13 @@ int serialice_cpuid_filter(uint32_t eax, uint32_t ecx,
/* SerialICE output loggers */
-void serialice_log(int flags, uint32_t data, uint32_t addr, int size) +void serialice_read_log(int flags, uint32_t data, uint32_t addr, int size) { int result;
- if ((flags & LOG_WRITE) && (flags & LOG_MEMORY)) { - lua_getglobal(L, "SerialICE_memory_write_log"); - } else if (!(flags & LOG_WRITE) && (flags & LOG_MEMORY)) { + if (flags & LOG_MEMORY) { lua_getglobal(L, "SerialICE_memory_read_log"); - } else if ((flags & LOG_WRITE) && !(flags & LOG_MEMORY)) { - lua_getglobal(L, "SerialICE_io_write_log"); - } else { // if (!(flags & LOG_WRITE) && !(flags & LOG_MEMORY)) + } else { lua_getglobal(L, "SerialICE_io_read_log"); }
@@ -457,9 +453,31 @@ void serialice_log(int flags, uint32_t data, uint32_t addr, int size)
result = lua_pcall(L, 4, 0, 0); if (result) { - fprintf(stderr, "Failed to run function SerialICE_%s_%s_log: %s\n", - (flags & LOG_MEMORY) ? "memory" : "io", - (flags & LOG_WRITE) ? "write" : "read", lua_tostring(L, -1)); + fprintf(stderr, "Failed to run function SerialICE_%s_read_log: %s\n", + (flags & LOG_MEMORY) ? "memory" : "io", lua_tostring(L, -1)); + exit(1); + } +} + +void serialice_write_log(int flags, uint32_t data, uint32_t addr, int size) +{ + int result; + + if (flags & LOG_MEMORY) { + lua_getglobal(L, "SerialICE_memory_write_log"); + } else { + lua_getglobal(L, "SerialICE_io_write_log"); + } + + lua_pushinteger(L, addr); // addr/port + lua_pushinteger(L, size); // datasize + lua_pushinteger(L, data); // data + lua_pushboolean(L, ((flags & LOG_TARGET) != 0)); + + result = lua_pcall(L, 4, 0, 0); + if (result) { + fprintf(stderr, "Failed to run function SerialICE_%s_write_log: %s\n", + (flags & LOG_MEMORY) ? "memory" : "io", lua_tostring(L, -1)); exit(1); } } diff --git a/qemu-0.15.x/serialice.c b/qemu-0.15.x/serialice.c index 32dc0ca..0e90a0d 100644 --- a/qemu-0.15.x/serialice.c +++ b/qemu-0.15.x/serialice.c @@ -167,10 +167,10 @@ void serialice_log_load(int caught, uint32_t addr, uint32_t result, unsigned int data_size) { if (caught) { - serialice_log(LOG_READ | LOG_MEMORY | LOG_TARGET, result, addr, + serialice_read_log(LOG_MEMORY | LOG_TARGET, result, addr, data_size); } else { - serialice_log(LOG_READ | LOG_MEMORY, result, addr, data_size); + serialice_read_log(LOG_MEMORY, result, addr, data_size); } }
@@ -206,10 +206,10 @@ static void serialice_log_store(int caught, uint32_t addr, uint32_t val, unsigned int data_size) { if (caught) { - serialice_log(LOG_WRITE | LOG_MEMORY | LOG_TARGET, val, addr, + serialice_write_log(LOG_MEMORY | LOG_TARGET, val, addr, data_size); } else { - serialice_log(LOG_WRITE | LOG_MEMORY, val, addr, data_size); + serialice_write_log(LOG_MEMORY, val, addr, data_size); } }
@@ -247,11 +247,11 @@ uint32_t serialice_io_read(uint16_t port, unsigned int size)
filtered = serialice_io_read_filter(&data, port, size); if (!filtered) { - return serialice_io_read_wrapper(port, size); + return serialice_io_read_wrapper(port, size); }
data = mask_data(data, size); - serialice_log(LOG_READ | LOG_IO, data, port, size); + serialice_read_log(LOG_IO, data, port, size); return data; }
@@ -266,10 +266,10 @@ void serialice_io_write(uint16_t port, unsigned int size, uint32 data) data = mask_data(filtered_data, size); } else { data = mask_data(filtered_data, size); - serialice_io_write_wrapper(port, size, data); + serialice_io_write_wrapper(port, size, data); }
- serialice_log(LOG_WRITE | LOG_IO, data, port, size); + serialice_write_log(LOG_IO, data, port, size); }
// ************************************************************************** diff --git a/qemu-0.15.x/serialice.h b/qemu-0.15.x/serialice.h index 4a64284..c281981 100644 --- a/qemu-0.15.x/serialice.h +++ b/qemu-0.15.x/serialice.h @@ -96,7 +96,8 @@ int serialice_cpuid_filter(uint32_t eax, uint32_t ecx, cpuid_regs_t * regs); int serialice_rdmsr_filter(uint32_t addr, uint32_t * hi, uint32_t * lo); int serialice_wrmsr_filter(uint32_t addr, uint32_t * hi, uint32_t * lo);
-void serialice_log(int flags, uint32_t data, uint32_t addr, int size); +void serialice_read_log(int flags, uint32_t data, uint32_t addr, int size); +void serialice_write_log(int flags, uint32_t data, uint32_t addr, int size); void serialice_rdmsr_log(uint32_t addr, uint32_t hi, uint32_t lo, int filtered); void serialice_wrmsr_log(uint32_t addr, uint32_t hi, uint32_t lo, int filtered); void serialice_cpuid_log(uint32_t eax, uint32_t ecx, cpuid_regs_t res, int filtered);