aboutsummaryrefslogtreecommitdiff
path: root/hw/sd/sd.c
diff options
context:
space:
mode:
authorPhilippe Mathieu-Daudé <philmd@linaro.org>2024-06-25 09:14:09 +0200
committerPhilippe Mathieu-Daudé <philmd@linaro.org>2024-07-02 10:08:32 +0200
commitdba4b37b38317ed5f91e04ca95f3731c946dba5d (patch)
tree15803d87853775512a2d50c5a53d7227ee765b75 /hw/sd/sd.c
parent740d51d1a3132c31594f3ff5fb63d6fcc22607ef (diff)
downloadqemu-dba4b37b38317ed5f91e04ca95f3731c946dba5d.zip
qemu-dba4b37b38317ed5f91e04ca95f3731c946dba5d.tar.gz
qemu-dba4b37b38317ed5f91e04ca95f3731c946dba5d.tar.bz2
hw/sd/sdcard: Duplicate WRITE_SINGLE_BLOCK / WRITE_MULTIPLE_BLOCK cases
In order to modify the WRITE_SINGLE_BLOCK case in the next commit, duplicate it first. Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Tested-by: Cédric Le Goater <clg@redhat.com> Reviewed-by: Cédric Le Goater <clg@redhat.com> Message-Id: <20240628070216.92609-31-philmd@linaro.org>
Diffstat (limited to 'hw/sd/sd.c')
-rw-r--r--hw/sd/sd.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/hw/sd/sd.c b/hw/sd/sd.c
index 990f038..b1acddc 100644
--- a/hw/sd/sd.c
+++ b/hw/sd/sd.c
@@ -1453,6 +1453,35 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req)
/* Block write commands (Class 4) */
case 24: /* CMD24: WRITE_SINGLE_BLOCK */
+ addr = sd_req_get_address(sd, req);
+ switch (sd->state) {
+ case sd_transfer_state:
+
+ if (!address_in_range(sd, "WRITE_SINGLE_BLOCK", addr,
+ sd->blk_len)) {
+ return sd_r1;
+ }
+
+ sd->state = sd_receivingdata_state;
+ sd->data_start = addr;
+ sd->data_offset = 0;
+
+ if (sd->size <= SDSC_MAX_CAPACITY) {
+ if (sd_wp_addr(sd, sd->data_start)) {
+ sd->card_status |= WP_VIOLATION;
+ }
+ }
+ if (sd->csd[14] & 0x30) {
+ sd->card_status |= WP_VIOLATION;
+ }
+ sd->blk_written = 0;
+ return sd_r1;
+
+ default:
+ break;
+ }
+ break;
+
case 25: /* CMD25: WRITE_MULTIPLE_BLOCK */
addr = sd_req_get_address(sd, req);
switch (sd->state) {