[SerialICE] New patch to review for serialice: cffc374 Isolate SerialICE protocol for MSR access

Patrick Georgi (patrick@georgi-clan.de) gerrit at coreboot.org
Wed May 30 14:48:45 CEST 2012


Patrick Georgi (patrick at georgi-clan.de) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/1065

-gerrit

commit cffc3745d2410237fa5cf42aedb63850c1c18052
Author: Patrick Georgi <patrick at georgi-clan.de>
Date:   Wed May 30 00:44:37 2012 +0200

    Isolate SerialICE protocol for MSR access
    
    Move the serial protocol handling to a separate function.
    
    Change-Id: Ieaf4ff597b7ef1db51084bcd92a61982e1e4b006
    Signed-off-by: Kyösti Mälkki <kyosti.malkki at gmail.com>
    [pg: Reorganized Kyösti's patch set]
    Signed-off-by: Patrick Georgi <patrick at georgi-clan.de>
---
 qemu-0.15.x/serialice.c |   30 ++++++++++++++++++++----------
 1 files changed, 20 insertions(+), 10 deletions(-)

diff --git a/qemu-0.15.x/serialice.c b/qemu-0.15.x/serialice.c
index 59e01a6..3813a1f 100644
--- a/qemu-0.15.x/serialice.c
+++ b/qemu-0.15.x/serialice.c
@@ -860,6 +860,17 @@ void serialice_outl(uint32_t data, uint16_t port)
     serialice_log(LOG_WRITE | LOG_IO, data, port, 4);
 }
 
+static 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)
+    serialice_command(s->command, 18);
+    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);
+}
+
 uint64_t serialice_rdmsr(uint32_t addr, uint32_t key)
 {
     uint32_t hi, lo;
@@ -868,14 +879,7 @@ uint64_t serialice_rdmsr(uint32_t addr, uint32_t key)
 
     filtered = serialice_msr_filter(FILTER_READ, addr, &hi, &lo);
     if (!filtered) {
-        sprintf(s->command, "*rc%08x.%08x", addr, key);
-
-        // command read back: "\n00000000.00000000" (18 characters)
-        serialice_command(s->command, 18);
-
-        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);
+        serialice_rdmsr_wrapper(addr, key, &hi, &lo);
     }
 
     ret = hi;
@@ -887,6 +891,13 @@ uint64_t serialice_rdmsr(uint32_t addr, uint32_t key)
     return ret;
 }
 
+static void serialice_wrmsr_wrapper(uint32_t addr, uint32_t key,
+                             uint32_t hi, uint32_t lo)
+{
+    sprintf(s->command, "*wc%08x.%08x=%08x.%08x", addr, key, hi, lo);
+    serialice_command(s->command, 0);
+}
+
 void serialice_wrmsr(uint64_t data, uint32_t addr, uint32_t key)
 {
     uint32_t hi, lo;
@@ -898,8 +909,7 @@ void serialice_wrmsr(uint64_t data, uint32_t addr, uint32_t key)
     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_wrmsr_wrapper(addr, key, hi, lo);
     }
 
     serialice_msr_log(LOG_WRITE, addr, hi, lo, filtered);



More information about the SerialICE mailing list