mirror of https://github.com/xemu-project/xemu.git
pflash: Restore & fix lazy ROMD switching
Commit 5145b3d1cc
revealed a bug in the lazy ROMD switch-back logic, but
resolved it by breaking that feature. This approach addresses the issue
by switching back to ROMD after a certain amount of read accesses
without further unlock sequences.
Signed-off-by: Jan Kiszka <jan.kiszka@web.de>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
This commit is contained in:
parent
70afb8ff90
commit
661bfc80e8
|
@ -50,6 +50,8 @@ do { \
|
||||||
#define DPRINTF(fmt, ...) do { } while (0)
|
#define DPRINTF(fmt, ...) do { } while (0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define PFLASH_LAZY_ROMD_THRESHOLD 42
|
||||||
|
|
||||||
struct pflash_t {
|
struct pflash_t {
|
||||||
BlockDriverState *bs;
|
BlockDriverState *bs;
|
||||||
target_phys_addr_t base;
|
target_phys_addr_t base;
|
||||||
|
@ -70,6 +72,7 @@ struct pflash_t {
|
||||||
ram_addr_t off;
|
ram_addr_t off;
|
||||||
int fl_mem;
|
int fl_mem;
|
||||||
int rom_mode;
|
int rom_mode;
|
||||||
|
int read_counter; /* used for lazy switch-back to rom mode */
|
||||||
void *storage;
|
void *storage;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -112,9 +115,9 @@ static uint32_t pflash_read (pflash_t *pfl, target_phys_addr_t offset,
|
||||||
|
|
||||||
DPRINTF("%s: offset " TARGET_FMT_plx "\n", __func__, offset);
|
DPRINTF("%s: offset " TARGET_FMT_plx "\n", __func__, offset);
|
||||||
ret = -1;
|
ret = -1;
|
||||||
if (!pfl->rom_mode) {
|
/* Lazy reset to ROMD mode after a certain amount of read accesses */
|
||||||
/* Lazy reset of to ROMD mode */
|
if (!pfl->rom_mode && pfl->wcycle == 0 &&
|
||||||
if (pfl->wcycle == 0)
|
++pfl->read_counter > PFLASH_LAZY_ROMD_THRESHOLD) {
|
||||||
pflash_register_memory(pfl, 1);
|
pflash_register_memory(pfl, 1);
|
||||||
}
|
}
|
||||||
offset &= pfl->chip_len - 1;
|
offset &= pfl->chip_len - 1;
|
||||||
|
@ -254,6 +257,7 @@ static void pflash_write (pflash_t *pfl, target_phys_addr_t offset,
|
||||||
/* Set the device in I/O access mode if required */
|
/* Set the device in I/O access mode if required */
|
||||||
if (pfl->rom_mode)
|
if (pfl->rom_mode)
|
||||||
pflash_register_memory(pfl, 0);
|
pflash_register_memory(pfl, 0);
|
||||||
|
pfl->read_counter = 0;
|
||||||
/* We're in read mode */
|
/* We're in read mode */
|
||||||
check_unlock0:
|
check_unlock0:
|
||||||
if (boff == 0x55 && cmd == 0x98) {
|
if (boff == 0x55 && cmd == 0x98) {
|
||||||
|
|
Loading…
Reference in New Issue