@@ -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] = {
@@ -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"
and his sd_state_name() companion to pretty-print the SDCardState. Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> --- hw/sd/sd.c | 24 +++++++++++++++++++++++- hw/sd/trace-events | 1 + 2 files changed, 24 insertions(+), 1 deletion(-)