qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 09/26] sdcard: add a sdcard_set_state() trace event


From: Philippe Mathieu-Daudé
Subject: [Qemu-devel] [PATCH 09/26] sdcard: add a sdcard_set_state() trace event
Date: Wed, 13 Dec 2017 20:20:08 -0300

and his sd_state_name() companion to pretty-print the SDCardState.

Signed-off-by: Philippe Mathieu-Daudé <address@hidden>
---
 hw/sd/sd.c         | 24 +++++++++++++++++++++++-
 hw/sd/trace-events |  1 +
 2 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/hw/sd/sd.c b/hw/sd/sd.c
index f67c9ff49c..bd4a896cba 100644
--- a/hw/sd/sd.c
+++ b/hw/sd/sd.c
@@ -139,6 +139,25 @@ static const char *sd_mode_name(enum SDCardModes mode)
     return mode_name[mode];
 }
 
+static const char *sd_state_name(enum SDCardStates state)
+{
+    static const char *state_name[] = {
+        [sd_idle_state]             = "idle",
+        [sd_ready_state]            = "ready",
+        [sd_identification_state]   = "identification",
+        [sd_standby_state]          = "standby",
+        [sd_transfer_state]         = "transfer",
+        [sd_sendingdata_state]      = "sendingdata",
+        [sd_receivingdata_state]    = "receivingdata",
+        [sd_programming_state]      = "programming",
+        [sd_disconnect_state]       = "disconnect",
+    };
+    if (state == sd_inactive_state) {
+        return "inactive";
+    }
+    return state_name[state];
+}
+
 static void sd_set_mode(SDState *sd, enum SDCardModes mode)
 {
     if (sd->mode != mode) {
@@ -173,7 +192,10 @@ static void sd_update_mode(SDState *sd)
 
 static void sd_set_state(SDState *sd, enum SDCardStates state)
 {
-    sd->state = state;
+    if (sd->state != state) {
+        trace_sdcard_set_state(sd_state_name(sd->state), sd_state_name(state));
+        sd->state = state;
+    }
 }
 
 static const sd_cmd_type_t sd_cmd_type[64] = {
diff --git a/hw/sd/trace-events b/hw/sd/trace-events
index 369d258d10..2677c2195d 100644
--- a/hw/sd/trace-events
+++ b/hw/sd/trace-events
@@ -23,6 +23,7 @@ sdhci_led(bool state) "LED: %u"
 
 # hw/sd/sd.c
 sdcard_set_mode(const char *current_mode, const char *new_mode) "%s -> %s"
+sdcard_set_state(const char *current_state, const char *new_state) "%s -> %s"
 
 # hw/sd/milkymist-memcard.c
 milkymist_memcard_memory_read(uint32_t addr, uint32_t value) "addr 0x%08x 
value 0x%08x"
-- 
2.15.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]