[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 2/7] hw/sd/sdcard: Duplicate WRITE_SINGLE_BLOCK / WRITE_MULTIPLE_
From: |
Philippe Mathieu-Daudé |
Subject: |
[PATCH 2/7] hw/sd/sdcard: Duplicate WRITE_SINGLE_BLOCK / WRITE_MULTIPLE_BLOCK cases |
Date: |
Tue, 25 Jun 2024 09:34:36 +0200 |
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>
---
hw/sd/sd.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/hw/sd/sd.c b/hw/sd/sd.c
index 7fea0afb62..8c30826754 100644
--- a/hw/sd/sd.c
+++ b/hw/sd/sd.c
@@ -1437,6 +1437,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) {
--
2.41.0
- [PATCH 0/7] hw/sd/sd: Introduce sd_cmd_to_receivingdata() / sd_generic_write_byte(), Philippe Mathieu-Daudé, 2024/06/25
- [PATCH 1/7] hw/sd/sdcard: Introduce sd_cmd_to_receivingdata / sd_generic_write_byte, Philippe Mathieu-Daudé, 2024/06/25
- [PATCH 2/7] hw/sd/sdcard: Duplicate WRITE_SINGLE_BLOCK / WRITE_MULTIPLE_BLOCK cases,
Philippe Mathieu-Daudé <=
- [PATCH 3/7] hw/sd/sdcard: Convert WRITE_SINGLE_BLOCK to generic_write_byte (CMD24), Philippe Mathieu-Daudé, 2024/06/25
- [PATCH 4/7] hw/sd/sdcard: Convert PROGRAM_CID to generic_write_byte (CMD26), Philippe Mathieu-Daudé, 2024/06/25
- [PATCH 5/7] hw/sd/sdcard: Convert PROGRAM_CSD to generic_write_byte (CMD27), Philippe Mathieu-Daudé, 2024/06/25
- [PATCH 6/7] hw/sd/sdcard: Convert LOCK_UNLOCK to generic_write_byte (CMD42), Philippe Mathieu-Daudé, 2024/06/25
- [PATCH 7/7] hw/sd/sdcard: Convert GEN_CMD to generic_write_byte (CMD56), Philippe Mathieu-Daudé, 2024/06/25