[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 15/19] hw/sd/sdcard: Factor sd_req_get_address() method out
From: |
Philippe Mathieu-Daudé |
Subject: |
[PULL 15/19] hw/sd/sdcard: Factor sd_req_get_address() method out |
Date: |
Mon, 24 Jun 2024 15:14:36 +0200 |
Extract sd_cmd_get_address() so we can re-use it
in various SDProto handlers. Use CARD_CAPACITY and
HWBLOCK_SHIFT definitions instead of magic values.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Tested-by: Cédric Le Goater <clg@redhat.com>
Message-Id: <20240621080554.18986-17-philmd@linaro.org>
---
hw/sd/sd.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/hw/sd/sd.c b/hw/sd/sd.c
index 912b2f8984..51ab7cd003 100644
--- a/hw/sd/sd.c
+++ b/hw/sd/sd.c
@@ -582,6 +582,14 @@ static void sd_response_r7_make(SDState *sd, uint8_t
*response)
stl_be_p(response, sd->vhs);
}
+static uint64_t sd_req_get_address(SDState *sd, SDRequest req)
+{
+ if (FIELD_EX32(sd->ocr, OCR, CARD_CAPACITY)) {
+ return (uint64_t) req.arg << HWBLOCK_SHIFT;
+ }
+ return req.arg;
+}
+
static inline uint64_t sd_addr_to_wpnum(uint64_t addr)
{
return addr >> (HWBLOCK_SHIFT + SECTOR_SHIFT + WPGROUP_SHIFT);
@@ -1106,7 +1114,7 @@ static sd_rsp_type_t sd_cmd_SET_BLOCK_COUNT(SDState *sd,
SDRequest req)
static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req)
{
uint16_t rca;
- uint64_t addr = (sd->ocr & (1 << 30)) ? (uint64_t) req.arg << 9 : req.arg;
+ uint64_t addr = sd_req_get_address(sd, req);
/* CMD55 precedes an ACMD, so we are not interested in tracing it.
* However there is no ACMD55, so we want to trace this particular case.
--
2.41.0
- [PULL 05/19] hw/sd/sdcard: Fix typo in SEND_OP_COND command name, (continued)
- [PULL 05/19] hw/sd/sdcard: Fix typo in SEND_OP_COND command name, Philippe Mathieu-Daudé, 2024/06/24
- [PULL 06/19] hw/sd/sdcard: Use HWBLOCK_SHIFT definition instead of magic values, Philippe Mathieu-Daudé, 2024/06/24
- [PULL 07/19] hw/sd/sdcard: Use registerfield CSR::CURRENT_STATE definition, Philippe Mathieu-Daudé, 2024/06/24
- [PULL 08/19] hw/sd/sdcard: Use Load/Store API to fill some CID/CSD registers, Philippe Mathieu-Daudé, 2024/06/24
- [PULL 09/19] hw/sd/sdcard: Remove ACMD6 handler for SPI mode, Philippe Mathieu-Daudé, 2024/06/24
- [PULL 10/19] hw/sd/sdcard: Remove explicit entries for illegal commands, Philippe Mathieu-Daudé, 2024/06/24
- [PULL 11/19] hw/sd/sdcard: Trace update of block count (CMD23), Philippe Mathieu-Daudé, 2024/06/24
- [PULL 12/19] hw/sd/sdcard: Have cmd_valid_while_locked() return a boolean value, Philippe Mathieu-Daudé, 2024/06/24
- [PULL 13/19] hw/sd/sdcard: Factor sd_req_get_rca() method out, Philippe Mathieu-Daudé, 2024/06/24
- [PULL 14/19] hw/sd/sdcard: Only call sd_req_get_rca() where RCA is used, Philippe Mathieu-Daudé, 2024/06/24
- [PULL 15/19] hw/sd/sdcard: Factor sd_req_get_address() method out,
Philippe Mathieu-Daudé <=
- [PULL 16/19] hw/sd/sdcard: Only call sd_req_get_address() where address is used, Philippe Mathieu-Daudé, 2024/06/24
- [PULL 17/19] hw/sd/sdcard: Add sd_invalid_mode_for_cmd to report invalid mode switch, Philippe Mathieu-Daudé, 2024/06/24
- [PULL 18/19] hw/sd/sdcard: Inline BLK_READ_BLOCK / BLK_WRITE_BLOCK macros, Philippe Mathieu-Daudé, 2024/06/24
- [PULL 19/19] hw/sd/sdcard: Add comments around registers and commands, Philippe Mathieu-Daudé, 2024/06/24
- Re: [PULL 00/19] SD/MMC patches for 2024-06-24, Richard Henderson, 2024/06/25