diff mbox series

[Aspeed,v47,17/19] hw/sd/sdcard: Subtract bootarea size from blk

Message ID 20240709152556.52896-18-philmd@linaro.org
State New
Headers show
Series [v47,01/19] hw/sd/sdcard: Basis for eMMC support | expand

Commit Message

Philippe Mathieu-Daudé July 9, 2024, 3:25 p.m. UTC
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é <philmd@linaro.org>
---
Squash in previous?
---
 hw/sd/sd.c | 4 ++++
 1 file changed, 4 insertions(+)
diff mbox series

Patch

diff --git a/hw/sd/sd.c b/hw/sd/sd.c
index 5830725629..291497468f 100644
--- a/hw/sd/sd.c
+++ b/hw/sd/sd.c
@@ -814,6 +814,10 @@  static void sd_reset(DeviceState *dev)
     }
     size = sect << HWBLOCK_SHIFT;
 
+    if (sc->bootpart_offset) {
+        size -= sd_bootpart_offset(sd);
+    }
+
     sect = sd_addr_to_wpnum(size) + 1;
 
     sd->reset_time_ns = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);