[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH 17/17] hw/sd: Subtract bootarea size from blk
From: |
Cédric Le Goater |
Subject: |
[RFC PATCH 17/17] hw/sd: Subtract bootarea size from blk |
Date: |
Fri, 18 Mar 2022 14:28:24 +0100 |
From: Joel Stanley <joel@jms.id.au>
The userdata size is derived from the file the user passes on the
command line, but we must take into account the boot areas.
Signed-off-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
hw/sd/sd.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/hw/sd/sd.c b/hw/sd/sd.c
index e975fcf18512..2ac721bea026 100644
--- a/hw/sd/sd.c
+++ b/hw/sd/sd.c
@@ -644,6 +644,7 @@ static inline uint64_t sd_addr_to_wpnum(uint64_t addr)
static void sd_reset(DeviceState *dev)
{
SDState *sd = SD_CARD(dev);
+ SDCardClass *sc = SD_CARD_GET_CLASS(sd);
uint64_t size;
uint64_t sect;
@@ -655,6 +656,11 @@ static void sd_reset(DeviceState *dev)
}
size = sect << 9;
+ if (sc->bootpart_offset) {
+ unsigned int boot_capacity = sd->ext_csd[EXT_CSD_BOOT_MULT] << 17;
+ size -= boot_capacity * 2;
+ }
+
sect = sd_addr_to_wpnum(size) + 1;
sd->state = sd_idle_state;
--
2.34.1
- [RFC PATCH 00/17] hw/sd: Rework models for eMMC support, Cédric Le Goater, 2022/03/18
- [RFC PATCH 02/17] hw/sd: Move proto_name to SDProto structure, Cédric Le Goater, 2022/03/18
- [RFC PATCH 01/17] hw/sd: When card is in wrong state, log which state it is, Cédric Le Goater, 2022/03/18
- [RFC PATCH 12/17] hw/sd: Fix SET_BLOCK_COUNT command argument, Cédric Le Goater, 2022/03/18
- [RFC PATCH 17/17] hw/sd: Subtract bootarea size from blk,
Cédric Le Goater <=
- [RFC PATCH 06/17] hw/sd: Add sd_cmd_GO_IDLE_STATE() handler, Cédric Le Goater, 2022/03/18
- [RFC PATCH 04/17] hw/sd: Add sd_cmd_illegal() handler, Cédric Le Goater, 2022/03/18
- [RFC PATCH 14/17] hw/sd: Add CMD21 tuning sequence, Cédric Le Goater, 2022/03/18
- [RFC PATCH 05/17] hw/sd: Add sd_cmd_unimplemented() handler, Cédric Le Goater, 2022/03/18
- [RFC PATCH 13/17] hw/sd: Update CMD1 definition for MMC, Cédric Le Goater, 2022/03/18
- [RFC PATCH 11/17] hw/sd: Add eMMC support, Cédric Le Goater, 2022/03/18
- [RFC PATCH 07/17] hw/sd: Add sd_cmd_SEND_OP_CMD() handler, Cédric Le Goater, 2022/03/18
- [RFC PATCH 10/17] hw/sd: Add sd_cmd_SEND_TUNING_BLOCK() handler, Cédric Le Goater, 2022/03/18