diff mbox series

[26/32] hw/sd: Fix SET_BLOCK_COUNT command argument

Message ID 20230703132509.2474225-27-clg@kaod.org
State New
Headers show
Series hw/sd: eMMC support | expand

Commit Message

Cédric Le Goater July 3, 2023, 1:25 p.m. UTC
The number of blocks is defined in the lower bits [15:0].

TODO: This needs to be more precise on the spec version.

Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
 hw/sd/sd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Philippe Mathieu-Daudé June 12, 2024, 10:23 p.m. UTC | #1
On 3/7/23 15:25, Cédric Le Goater wrote:
> The number of blocks is defined in the lower bits [15:0].
> 
> TODO: This needs to be more precise on the spec version.
> 
> Signed-off-by: Cédric Le Goater <clg@kaod.org>
> ---
>   hw/sd/sd.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/hw/sd/sd.c b/hw/sd/sd.c
> index c4c9e9ee7999..7f07d0e99d15 100644
> --- a/hw/sd/sd.c
> +++ b/hw/sd/sd.c
> @@ -1282,7 +1282,7 @@ static sd_rsp_type_t sd_cmd_SET_BLOCK_COUNT(SDState *sd, SDRequest req)
>               return sd_invalid_state_for_cmd(sd, req);
>           }
>   
> -        sd->multi_blk_cnt = req.arg;
> +        sd->multi_blk_cnt = req.arg & 0xFFFF;

On the SD Physical Layer spec v9.10 this field is still 32-bit
(see table 4-24, p. 104).

Should we use a sd_is_emmc() helper similar to sd_is_spi()?

>   
>           return sd_r1;
>   }
diff mbox series

Patch

diff --git a/hw/sd/sd.c b/hw/sd/sd.c
index c4c9e9ee7999..7f07d0e99d15 100644
--- a/hw/sd/sd.c
+++ b/hw/sd/sd.c
@@ -1282,7 +1282,7 @@  static sd_rsp_type_t sd_cmd_SET_BLOCK_COUNT(SDState *sd, SDRequest req)
             return sd_invalid_state_for_cmd(sd, req);
         }
 
-        sd->multi_blk_cnt = req.arg;
+        sd->multi_blk_cnt = req.arg & 0xFFFF;
 
         return sd_r1;
 }