[SerialICE] New patch to review for serialice: ca33e70 SerialICE: Unify IO and memory handling
Kyösti Mälkki (kyosti.malkki@gmail.com)
gerrit at coreboot.org
Mon Aug 20 23:03:51 CEST 2012
Kyösti Mälkki (kyosti.malkki at gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/1464
-gerrit
commit ca33e70a15ec8a291fda10335044c2bd63f95870
Author: Kyösti Mälkki <kyosti.malkki at gmail.com>
Date: Sun Aug 19 21:26:21 2012 +0300
SerialICE: Unify IO and memory handling
There are no separate handlers for 8/16/32 bit memory access,
make IO access work in similar fashion.
Change-Id: I0407240a4495fbf723272b48b23e3863a97e7d1e
Signed-off-by: Kyösti Mälkki <kyosti.malkki at gmail.com>
---
qemu-0.15.x/serialice.c | 142 +++++++++---------------------------
qemu-0.15.x/serialice.h | 9 +--
qemu-0.15.x/target-i386/op_helper.c | 12 +--
3 files changed, 42 insertions(+), 121 deletions(-)
diff --git a/qemu-0.15.x/serialice.c b/qemu-0.15.x/serialice.c
index 1e677bf..aaf69b0 100644
--- a/qemu-0.15.x/serialice.c
+++ b/qemu-0.15.x/serialice.c
@@ -105,114 +105,6 @@ static void serialice_screen(void)
// **************************************************************************
// high level communication with the SerialICE shell
-uint8_t serialice_inb(uint16_t port)
-{
- uint8_t ret;
- uint32_t data;
- int filtered;
-
- filtered = serialice_io_read_filter(&data, port, 1);
-
- if (filtered) {
- ret = data & 0xff;
- } else {
- return serialice_io_read_wrapper(port, 1);
- }
-
- serialice_log(LOG_READ | LOG_IO, ret, port, 1);
-
- return ret;
-}
-
-uint16_t serialice_inw(uint16_t port)
-{
- uint16_t ret;
- uint32_t data;
- int filtered;
-
- filtered = serialice_io_read_filter(&data, port, 2);
-
- if (filtered) {
- ret = data & 0xffff;
- } else {
- return serialice_io_read_wrapper(port, 2);
- }
-
- serialice_log(LOG_READ | LOG_IO, ret, port, 2);
-
- return ret;
-}
-
-uint32_t serialice_inl(uint16_t port)
-{
- uint32_t ret;
- uint32_t data;
- int filtered;
-
- filtered = serialice_io_read_filter(&data, port, 4);
-
- if (filtered) {
- ret = data;
- } else {
- return serialice_io_read_wrapper(port, 4);
- }
-
- serialice_log(LOG_READ | LOG_IO, ret, port, 4);
-
- return ret;
-}
-
-void serialice_outb(uint8_t data, uint16_t port)
-{
- uint32_t filtered_data = (uint32_t) data;
- int filtered;
-
- filtered = serialice_io_write_filter(&filtered_data, port, 1);
-
- if (filtered) {
- data = (uint8_t) filtered_data;
- } else {
- data = (uint8_t) filtered_data;
- serialice_io_write_wrapper(port, 1, data);
- }
-
- serialice_log(LOG_WRITE | LOG_IO, data, port, 1);
-}
-
-void serialice_outw(uint16_t data, uint16_t port)
-{
- uint32_t filtered_data = (uint32_t) data;
- int filtered;
-
- filtered = serialice_io_write_filter(&filtered_data, port, 2);
-
- if (filtered) {
- data = (uint16_t) filtered_data;
- } else {
- data = (uint16_t) filtered_data;
- serialice_io_write_wrapper(port, 2, data);
- }
-
- serialice_log(LOG_WRITE | LOG_IO, data, port, 2);
-}
-
-void serialice_outl(uint32_t data, uint16_t port)
-{
- uint32_t filtered_data = data;
- int filtered;
-
- filtered = serialice_io_write_filter(&filtered_data, port, 4);
-
- if (filtered) {
- data = filtered_data;
- } else {
- data = filtered_data;
- serialice_io_write_wrapper(port, 4, data);
- }
-
- serialice_log(LOG_WRITE | LOG_IO, data, port, 4);
-}
-
uint64_t serialice_rdmsr(uint32_t addr, uint32_t key)
{
uint32_t hi, lo;
@@ -346,6 +238,40 @@ int serialice_handle_store(uint32_t addr, uint32_t val, unsigned int data_size)
return (write_to_qemu == 0);
}
+#define mask_data(val,bytes) (val & (((uint64_t)1<<(bytes*8))-1))
+
+uint32_t serialice_io_read(uint16_t port, unsigned int size)
+{
+ uint32_t data = 0;
+ int filtered;
+
+ filtered = serialice_io_read_filter(&data, port, size);
+ if (!filtered) {
+ return serialice_io_read_wrapper(port, size);
+ }
+
+ data = mask_data(data, size);
+ serialice_log(LOG_READ | LOG_IO, data, port, size);
+ return data;
+}
+
+void serialice_io_write(uint16_t port, unsigned int size, uint32 data)
+{
+ uint32_t filtered_data = mask_data(data, size);
+ int filtered;
+
+ filtered = serialice_io_write_filter(&filtered_data, port, size);
+
+ if (filtered) {
+ data = mask_data(filtered_data, size);
+ } else {
+ data = mask_data(filtered_data, size);
+ serialice_io_write_wrapper(port, size, data);
+ }
+
+ serialice_log(LOG_WRITE | LOG_IO, data, port, size);
+}
+
// **************************************************************************
// initialization and exit
diff --git a/qemu-0.15.x/serialice.h b/qemu-0.15.x/serialice.h
index 27e9eb5..e9558f8 100644
--- a/qemu-0.15.x/serialice.h
+++ b/qemu-0.15.x/serialice.h
@@ -61,13 +61,8 @@ void serialice_command(const char *command, int reply_len);
void serialice_get_version(void);
void serialice_get_mainboard(void);
-uint8_t serialice_inb(uint16_t port);
-uint16_t serialice_inw(uint16_t port);
-uint32_t serialice_inl(uint16_t port);
-
-void serialice_outb(uint8_t data, uint16_t port);
-void serialice_outw(uint16_t data, uint16_t port);
-void serialice_outl(uint32_t data, uint16_t port);
+uint32_t serialice_io_read(uint16_t port, unsigned int size);
+void serialice_io_write(uint16_t port, unsigned int size, uint32_t data);
uint64_t serialice_rdmsr(uint32_t addr, uint32_t key);
void serialice_wrmsr(uint64_t data, uint32_t addr, uint32_t key);
diff --git a/qemu-0.15.x/target-i386/op_helper.c b/qemu-0.15.x/target-i386/op_helper.c
index 2f6b8b3..1823c74 100644
--- a/qemu-0.15.x/target-i386/op_helper.c
+++ b/qemu-0.15.x/target-i386/op_helper.c
@@ -559,7 +559,7 @@ void helper_outb(uint32_t port, uint32_t data)
{
#ifdef CONFIG_SERIALICE
if (serialice_active) {
- serialice_outb(data & 0xff, port);
+ serialice_io_write(port, 1, data);
return;
}
#endif
@@ -570,7 +570,7 @@ target_ulong helper_inb(uint32_t port)
{
#ifdef CONFIG_SERIALICE
if (serialice_active) {
- return (target_ulong) serialice_inb(port);
+ return (target_ulong) serialice_io_read(port, 1);
}
#endif
return cpu_inb(port);
@@ -580,7 +580,7 @@ void helper_outw(uint32_t port, uint32_t data)
{
#ifdef CONFIG_SERIALICE
if (serialice_active) {
- serialice_outw(data & 0xffff, port);
+ serialice_io_write(port, 2, data);
return;
}
#endif
@@ -591,7 +591,7 @@ target_ulong helper_inw(uint32_t port)
{
#ifdef CONFIG_SERIALICE
if (serialice_active) {
- return (target_ulong) serialice_inw(port);
+ return (target_ulong) serialice_io_read(port, 2);
}
#endif
return cpu_inw(port);
@@ -601,7 +601,7 @@ void helper_outl(uint32_t port, uint32_t data)
{
#ifdef CONFIG_SERIALICE
if (serialice_active) {
- serialice_outl(data & 0xffffffff, port);
+ serialice_io_write(port, 4, data);
return;
}
#endif
@@ -612,7 +612,7 @@ target_ulong helper_inl(uint32_t port)
{
#ifdef CONFIG_SERIALICE
if (serialice_active) {
- return (target_ulong) serialice_inl(port);
+ return (target_ulong) serialice_io_read(port, 4);
}
#endif
return cpu_inl(port);
More information about the SerialICE
mailing list