qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v2 24/25] hw/sd: Subtract bootarea size from blk


From: Philippe Mathieu-Daudé
Subject: [PATCH v2 24/25] hw/sd: Subtract bootarea size from blk
Date: Mon, 30 May 2022 21:38:15 +0200

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>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/sd/sd.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/hw/sd/sd.c b/hw/sd/sd.c
index 05e77f128f..26ddf3e92d 100644
--- a/hw/sd/sd.c
+++ b/hw/sd/sd.c
@@ -668,6 +668,7 @@ static unsigned sd_boot_capacity_bytes(SDState *sd)
 static void sd_reset(DeviceState *dev)
 {
     SDState *sd = SD_CARD(dev);
+    SDCardClass *sc = SD_CARD_GET_CLASS(sd);
     uint64_t size;
     uint64_t sect;
 
@@ -679,6 +680,10 @@ static void sd_reset(DeviceState *dev)
     }
     size = sect << 9;
 
+    if (sc->bootpart_offset) {
+        size -= sd_boot_capacity_bytes(sd) * 2;
+    }
+
     sect = sd_addr_to_wpnum(size) + 1;
 
     sd->state = sd_idle_state;
-- 
2.36.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]