[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 14/25] hw/nvram/eeprom_at24c: Make reset behavior more like hardwa
From: |
Cédric Le Goater |
Subject: |
[PULL 14/25] hw/nvram/eeprom_at24c: Make reset behavior more like hardware |
Date: |
Tue, 7 Feb 2023 11:07:33 +0100 |
From: Peter Delevoryas <peter@pjd.dev>
EEPROM's are a form of non-volatile memory. After power-cycling an EEPROM,
I would expect the I2C state machine to be reset to default values, but I
wouldn't really expect the memory to change at all.
The current implementation of the at24c EEPROM resets its internal memory on
reset. This matches the specification in docs/devel/reset.rst:
Cold reset is supported by every resettable object. In QEMU, it means we reset
to the initial state corresponding to the start of QEMU; this might differ
from what is a real hardware cold reset. It differs from other resets (like
warm or bus resets) which may keep certain parts untouched.
But differs from my intuition. For example, if someone writes some information
to an EEPROM, then AC power cycles their board, they would expect the EEPROM to
retain that information. It's very useful to be able to test things like this
in QEMU as well, to verify software instrumentation like determining the cause
of a reboot.
Fixes: 5d8424dbd3e8 ("nvram: add AT24Cx i2c eeprom")
Signed-off-by: Peter Delevoryas <peter@pjd.dev>
Reviewed-by: Joel Stanley <joel@jms.id.au>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Reviewed-by: Corey Minyard <cminyard@mvista.com>
Link: https://lore.kernel.org/r/20230128060543.95582-6-peter@pjd.dev
Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
hw/nvram/eeprom_at24c.c | 22 ++++++++++------------
1 file changed, 10 insertions(+), 12 deletions(-)
diff --git a/hw/nvram/eeprom_at24c.c b/hw/nvram/eeprom_at24c.c
index 05598699dc..3328c32814 100644
--- a/hw/nvram/eeprom_at24c.c
+++ b/hw/nvram/eeprom_at24c.c
@@ -184,18 +184,6 @@ static void at24c_eeprom_realize(DeviceState *dev, Error
**errp)
}
ee->mem = g_malloc0(ee->rsize);
-
-}
-
-static
-void at24c_eeprom_reset(DeviceState *state)
-{
- EEPROMState *ee = AT24C_EE(state);
-
- ee->changed = false;
- ee->cur = 0;
- ee->haveaddr = 0;
-
memset(ee->mem, 0, ee->rsize);
if (ee->init_rom) {
@@ -213,6 +201,16 @@ void at24c_eeprom_reset(DeviceState *state)
}
}
+static
+void at24c_eeprom_reset(DeviceState *state)
+{
+ EEPROMState *ee = AT24C_EE(state);
+
+ ee->changed = false;
+ ee->cur = 0;
+ ee->haveaddr = 0;
+}
+
static Property at24c_eeprom_props[] = {
DEFINE_PROP_UINT32("rom-size", EEPROMState, rsize, 0),
DEFINE_PROP_BOOL("writable", EEPROMState, writable, true),
--
2.39.1
- [PULL 01/25] tests/avocado: Introduce file_truncate(), (continued)
- [PULL 01/25] tests/avocado: Introduce file_truncate(), Cédric Le Goater, 2023/02/07
- [PULL 02/25] tests/avocado: Truncate M2S-FG484 SOM SPI flash to 16MiB, Cédric Le Goater, 2023/02/07
- [PULL 03/25] aspeed: Add Supermicro X11 SPI machine type, Cédric Le Goater, 2023/02/07
- [PULL 04/25] hw/net: Fix read of uninitialized memory in ftgmac100, Cédric Le Goater, 2023/02/07
- [PULL 05/25] avocado/boot_linux_console.py: Update ast2600 test, Cédric Le Goater, 2023/02/07
- [PULL 09/25] hw/core/loader: Remove declarations of option_rom_has_mr/rom_file_has_mr, Cédric Le Goater, 2023/02/07
- [PULL 06/25] m25p80: Add the is25wp256 SFPD table, Cédric Le Goater, 2023/02/07
- [PULL 07/25] tests/avocado/machine_aspeed.py: update buildroot tests, Cédric Le Goater, 2023/02/07
- [PULL 10/25] hw/arm: Extract at24c_eeprom_init helper from Aspeed and Nuvoton boards, Cédric Le Goater, 2023/02/07
- [PULL 13/25] hw/arm/aspeed: Add aspeed_eeprom.c, Cédric Le Goater, 2023/02/07
- [PULL 14/25] hw/nvram/eeprom_at24c: Make reset behavior more like hardware,
Cédric Le Goater <=
- [PULL 17/25] hw/watchdog/wdt_aspeed: Log unimplemented registers as UNIMP level, Cédric Le Goater, 2023/02/07
- [PULL 16/25] hw/watchdog/wdt_aspeed: Extend MMIO range to cover more registers, Cédric Le Goater, 2023/02/07
- [PULL 19/25] hw/arm/aspeed_ast10x0: Add various unimplemented peripherals, Cédric Le Goater, 2023/02/07
- [PULL 21/25] hw/arm/aspeed_ast10x0: Map the secure SRAM, Cédric Le Goater, 2023/02/07
- [PULL 22/25] hw/arm/aspeed_ast10x0: Map HACE peripheral, Cédric Le Goater, 2023/02/07
- [PULL 23/25] hw/arm/aspeed_ast10x0: Add TODO comment to use Cortex-M4F, Cédric Le Goater, 2023/02/07
- [PULL 08/25] tests/avocado/machine_aspeed.py: Mask systemd services to speed up SDK boot, Cédric Le Goater, 2023/02/07
- [PULL 11/25] hw/arm/aspeed: Replace aspeed_eeprom_init with at24c_eeprom_init, Cédric Le Goater, 2023/02/07
- [PULL 12/25] hw/nvram/eeprom_at24c: Add init_rom field and at24c_eeprom_init_rom helper, Cédric Le Goater, 2023/02/07
- [PULL 15/25] hw/watchdog/wdt_aspeed: Rename MMIO region size as 'iosize', Cédric Le Goater, 2023/02/07