qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Bin Meng" <bmeng.cn@gmail.com>, "Zheyu Ma" <zheyuma97@gmail.com>,
	qemu-block@nongnu.org,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: [PATCH-for-9.1 1/5] hw/sd/sdcard: Explicit dummy byte value
Date: Tue, 30 Jul 2024 11:21:34 +0200	[thread overview]
Message-ID: <20240730092138.32443-2-philmd@linaro.org> (raw)
In-Reply-To: <20240730092138.32443-1-philmd@linaro.org>

On error the DAT lines are left unmodified to their
previous states. QEMU returns 0x00 for convenience.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/sd/sd.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/hw/sd/sd.c b/hw/sd/sd.c
index 07cb97d88c..c02f04f1ea 100644
--- a/hw/sd/sd.c
+++ b/hw/sd/sd.c
@@ -2478,20 +2478,22 @@ void sd_write_byte(SDState *sd, uint8_t value)
 uint8_t sd_read_byte(SDState *sd)
 {
     /* TODO: Append CRCs */
+    static const uint8_t dummy_byte = 0x00;
     uint8_t ret;
     uint32_t io_len;
 
     if (!sd->blk || !blk_is_inserted(sd->blk) || !sd->enable)
-        return 0x00;
+        return dummy_byte;
 
     if (sd->state != sd_sendingdata_state) {
         qemu_log_mask(LOG_GUEST_ERROR,
                       "%s: not in Sending-Data state\n", __func__);
-        return 0x00;
+        return dummy_byte;
     }
 
-    if (sd->card_status & (ADDRESS_ERROR | WP_VIOLATION))
-        return 0x00;
+    if (sd->card_status & (ADDRESS_ERROR | WP_VIOLATION)) {
+        return dummy_byte;
+    }
 
     io_len = sd_blk_len(sd);
 
@@ -2517,7 +2519,7 @@ uint8_t sd_read_byte(SDState *sd)
         if (sd->data_offset == 0) {
             if (!address_in_range(sd, "READ_MULTIPLE_BLOCK",
                                   sd->data_start, io_len)) {
-                return 0x00;
+                return dummy_byte;
             }
             sd_blk_read(sd, sd->data_start, io_len);
         }
-- 
2.45.2



  reply	other threads:[~2024-07-30  9:23 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-30  9:21 [PATCH-for-9.1 0/5] hw/sd: SDcard & SDHCI fixes Philippe Mathieu-Daudé
2024-07-30  9:21 ` Philippe Mathieu-Daudé [this message]
2024-07-31  4:29   ` [PATCH-for-9.1 1/5] hw/sd/sdcard: Explicit dummy byte value Richard Henderson
2024-07-30  9:21 ` [PATCH-for-9.1 2/5] hw/sd/sdcard: Do not abort when reading DAT lines on invalid cmd state Philippe Mathieu-Daudé
2024-07-31  4:30   ` Richard Henderson
2024-07-30  9:21 ` [PATCH-for-9.1 3/5] hw/sd/sdhci: Reset @data_count index on invalid ADMA transfers Philippe Mathieu-Daudé
2024-07-31  4:31   ` Richard Henderson
2024-07-30  9:21 ` [PATCH-for-9.1 4/5] hw/sd/sdhci: Trace ADMA descriptors Philippe Mathieu-Daudé
2024-07-31  4:32   ` Richard Henderson
2024-07-30  9:21 ` [PATCH-for-9.1 5/5] hw/sd/sdhci: Check ADMA descriptors can be accessed Philippe Mathieu-Daudé
2024-07-31 16:49   ` Philippe Mathieu-Daudé
2024-08-06  7:30 ` [PATCH-for-9.1 0/5] hw/sd: SDcard & SDHCI fixes Philippe Mathieu-Daudé

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240730092138.32443-2-philmd@linaro.org \
    --to=philmd@linaro.org \
    --cc=bmeng.cn@gmail.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=zheyuma97@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).