[SerialICE] New patch to review for serialice: 0d60737 SerialICE factoring: new wrappers
Kyösti Mälkki (kyosti.malkki@gmail.com)
gerrit at coreboot.org
Sun May 6 19:05:15 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/1009
-gerrit
commit 0d60737c88cc8e46b99f15e483dd9a1d172980ea
Author: Kyösti Mälkki <kyosti.malkki at gmail.com>
Date: Sat May 5 18:24:14 2012 +0300
SerialICE factoring: new wrappers
Follow-up will fix bad indentation.
Change-Id: I53e2233613a604f5728f934cdd03f208ea7267ea
Signed-off-by: Kyösti Mälkki <kyosti.malkki at gmail.com>
---
qemu-0.15.x/serialice-com.c | 247 ++++++++++---------------------------------
1 files changed, 55 insertions(+), 192 deletions(-)
diff --git a/qemu-0.15.x/serialice-com.c b/qemu-0.15.x/serialice-com.c
index 82d3ce0..478d0d8 100644
--- a/qemu-0.15.x/serialice-com.c
+++ b/qemu-0.15.x/serialice-com.c
@@ -1,179 +1,109 @@
-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 {
+uint32_t serialice_io_read_wrapper(uint16_t port, unsigned int size)
+{
+ uint32_t ret;
+ switch (size) {
+ case 1:
sprintf(s->command, "*ri%04x.b", port);
// command read back: "\n00" (3 characters)
serialice_command(s->command, 3);
ret = (uint8_t) strtoul(s->buffer + 1, (char **)NULL, 16);
- }
-
- 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 ret;
+ case 2:
sprintf(s->command, "*ri%04x.w", port);
// command read back: "\n0000" (5 characters)
serialice_command(s->command, 5);
ret = (uint16_t) strtoul(s->buffer + 1, (char **)NULL, 16);
- }
-
- 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 ret;
+ case 4:
sprintf(s->command, "*ri%04x.l", port);
// command read back: "\n00000000" (9 characters)
serialice_command(s->command, 9);
ret = (uint32_t) strtoul(s->buffer + 1, (char **)NULL, 16);
+ return ret;
+ default:
+ printf("WARNING: unknown read access size %d @%08x\n", size, port);
+ return -1;
}
-
- serialice_log(LOG_READ | LOG_IO, ret, port, 4);
-
- return ret;
}
-void serialice_outb(uint8_t data, uint16_t port)
+void serialice_io_write_wrapper(uint16_t port, unsigned int size, uint32_t data)
{
- 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;
+ switch (size) {
+ case 1:
sprintf(s->command, "*wi%04x.b=%02x", port, data);
serialice_command(s->command, 0);
- }
-
- 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;
+ return;
+ case 2:
sprintf(s->command, "*wi%04x.w=%04x", port, data);
serialice_command(s->command, 0);
- }
-
- 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;
+ return;
+ case 4:
sprintf(s->command, "*wi%04x.l=%08x", port, data);
serialice_command(s->command, 0);
+ return;
+ default:
+ printf("WARNING: unknown write access size %d @%08x\n", size, port);
}
-
- serialice_log(LOG_WRITE | LOG_IO, data, port, 4);
+ return;
}
-uint8_t serialice_readb(uint32_t addr)
+
+uint32_t serialice_load_wrapper(uint32_t addr, unsigned int size)
{
+ uint32_t ret;
+ switch (size) {
+ case 1:
uint8_t ret;
sprintf(s->command, "*rm%08x.b", addr);
// command read back: "\n00" (3 characters)
serialice_command(s->command, 3);
ret = (uint8_t) strtoul(s->buffer + 1, (char **)NULL, 16);
return ret;
-}
-
-uint16_t serialice_readw(uint32_t addr)
-{
- uint16_t ret;
+ case 2:
sprintf(s->command, "*rm%08x.w", addr);
// command read back: "\n0000" (5 characters)
serialice_command(s->command, 5);
ret = (uint16_t) strtoul(s->buffer + 1, (char **)NULL, 16);
return ret;
-}
-
-uint32_t serialice_readl(uint32_t addr)
-{
- uint32_t ret;
+ case 4:
sprintf(s->command, "*rm%08x.l", addr);
// command read back: "\n00000000" (9 characters)
serialice_command(s->command, 9);
ret = (uint32_t) strtoul(s->buffer + 1, (char **)NULL, 16);
return ret;
+ default:
+ printf("WARNING: unknown read access size %d @%08x\n", size, addr);
+ }
+ return 0;
}
-void serialice_writeb(uint8_t data, uint32_t addr)
+void serialice_store_wrapper(uint32_t addr, unsigned int size,
+ uint32_t data)
{
+ switch (size) {
+ case 1:
sprintf(s->command, "*wm%08x.b=%02x", addr, data);
serialice_command(s->command, 0);
-}
-
-void serialice_writew(uint16_t data, uint32_t addr)
-{
+ break;
+ case 2:
sprintf(s->command, "*wm%08x.w=%04x", addr, data);
serialice_command(s->command, 0);
-}
-
-void serialice_writel(uint32_t data, uint32_t addr)
-{
+ break;
+ case 4:
sprintf(s->command, "*wm%08x.l=%08x", addr, data);
serialice_command(s->command, 0);
+ break;
+ default:
+ printf("WARNING: unknown write access size %d @%08x\n", size, addr);
+ }
}
-uint64_t serialice_rdmsr(uint32_t addr, uint32_t key)
-{
- uint32_t hi, lo;
- uint64_t ret;
- int filtered;
- filtered = serialice_msr_filter(FILTER_READ, addr, &hi, &lo);
- if (!filtered) {
+
+void serialice_rdmsr_wrapper(uint32_t addr, uint32_t key,
+ uint32_t *hi, uint32_t *lo)
+{
sprintf(s->command, "*rc%08x.%08x", addr, key);
// command read back: "\n00000000.00000000" (18 characters)
@@ -182,45 +112,18 @@ uint64_t serialice_rdmsr(uint32_t addr, uint32_t key)
s->buffer[9] = 0; // . -> \0
hi = (uint32_t) strtoul(s->buffer + 1, (char **)NULL, 16);
lo = (uint32_t) strtoul(s->buffer + 10, (char **)NULL, 16);
- }
-
- ret = hi;
- ret <<= 32;
- ret |= lo;
-
- serialice_msr_log(LOG_READ, addr, hi, lo, filtered);
-
- return ret;
}
-void serialice_wrmsr(uint64_t data, uint32_t addr, uint32_t key)
+void serialice_wrmsr_wrapper(uint32_t addr, uint32_t key,
+ uint32_t hi, uint32_t lo)
{
- uint32_t hi, lo;
- int filtered;
-
- hi = (data >> 32);
- lo = (data & 0xffffffff);
-
- filtered = serialice_msr_filter(FILTER_WRITE, addr, &hi, &lo);
-
- if (!filtered) {
sprintf(s->command, "*wc%08x.%08x=%08x.%08x", addr, key, hi, lo);
serialice_command(s->command, 0);
- }
-
- serialice_msr_log(LOG_WRITE, addr, hi, lo, filtered);
}
-cpuid_regs_t serialice_cpuid(uint32_t eax, uint32_t ecx)
-{
- cpuid_regs_t ret;
- int filtered;
-
- ret.eax = eax;
- ret.ebx = 0; // either set by filter or by target
- ret.ecx = ecx;
- ret.edx = 0; // either set by filter or by target
+void serialice_cpuid_wrapper(uint32_t eax, uint32_t ecx, cpuid_regs_t ret)
+{
sprintf(s->command, "*ci%08x.%08x", eax, ecx);
// command read back: "\n000006f2.00000000.00001234.12340324"
@@ -234,45 +137,5 @@ cpuid_regs_t serialice_cpuid(uint32_t eax, uint32_t ecx)
ret.ebx = (uint32_t) strtoul(s->buffer + 10, (char **)NULL, 16);
ret.ecx = (uint32_t) strtoul(s->buffer + 19, (char **)NULL, 16);
ret.edx = (uint32_t) strtoul(s->buffer + 28, (char **)NULL, 16);
-
- filtered = serialice_cpuid_filter(eax, ecx, &ret);
-
- serialice_cpuid_log(eax, ecx, ret, filtered);
-
- return ret;
}
-static uint32_t serialice_load_wrapper(uint32_t addr, unsigned int size)
-{
- switch (size) {
- case 1:
- return (uint32_t) serialice_readb(addr);
- case 2:
- return (uint32_t) serialice_readw(addr);
- case 4:
- return (uint32_t) serialice_readl(addr);
- default:
- printf("WARNING: unknown read access size %d @%08x\n", size, addr);
- }
- return 0;
-}
-
-static void serialice_store_wrapper(uint32_t addr, unsigned int size,
- uint32_t data)
-{
- switch (size) {
- case 1:
- serialice_writeb((uint8_t) data, addr);
- break;
- case 2:
- serialice_writew((uint16_t) data, addr);
- break;
- case 4:
- serialice_writel((uint32_t) data, addr);
- break;
- default:
- printf("WARNING: unknown write access size %d @%08x\n", size, addr);
- }
-}
-
-
More information about the SerialICE
mailing list