aboutsummaryrefslogtreecommitdiff
path: root/hw/pflash_cfi02.c
diff options
context:
space:
mode:
authorMichael S. Tsirkin <mst@redhat.com>2011-05-05 16:39:47 +0300
committerMichael S. Tsirkin <mst@redhat.com>2011-05-05 16:39:47 +0300
commit5300f1a5487f67f0bde8ee1081b799108668cb1d (patch)
tree5274ff496f2665487736a4eec23bf76601e4da44 /hw/pflash_cfi02.c
parent8d4c78e7c8adf0a4440a8de92738b3820fc8215a (diff)
parentd2d979c628e4b2c4a3cb71a31841875795c79043 (diff)
Merge remote branch 'origin/master' into pci
Conflicts: exec.c
Diffstat (limited to 'hw/pflash_cfi02.c')
-rw-r--r--hw/pflash_cfi02.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/hw/pflash_cfi02.c b/hw/pflash_cfi02.c
index 30c8aa4e4f..14bbc34e16 100644
--- a/hw/pflash_cfi02.c
+++ b/hw/pflash_cfi02.c
@@ -50,6 +50,8 @@ do { \
#define DPRINTF(fmt, ...) do { } while (0)
#endif
+#define PFLASH_LAZY_ROMD_THRESHOLD 42
+
struct pflash_t {
BlockDriverState *bs;
target_phys_addr_t base;
@@ -70,6 +72,7 @@ struct pflash_t {
ram_addr_t off;
int fl_mem;
int rom_mode;
+ int read_counter; /* used for lazy switch-back to rom mode */
void *storage;
};
@@ -112,10 +115,10 @@ static uint32_t pflash_read (pflash_t *pfl, target_phys_addr_t offset,
DPRINTF("%s: offset " TARGET_FMT_plx "\n", __func__, offset);
ret = -1;
- if (pfl->rom_mode) {
- /* Lazy reset of to ROMD mode */
- if (pfl->wcycle == 0)
- pflash_register_memory(pfl, 1);
+ /* Lazy reset to ROMD mode after a certain amount of read accesses */
+ if (!pfl->rom_mode && pfl->wcycle == 0 &&
+ ++pfl->read_counter > PFLASH_LAZY_ROMD_THRESHOLD) {
+ pflash_register_memory(pfl, 1);
}
offset &= pfl->chip_len - 1;
boff = offset & 0xFF;
@@ -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 */
if (pfl->rom_mode)
pflash_register_memory(pfl, 0);
+ pfl->read_counter = 0;
/* We're in read mode */
check_unlock0:
if (boff == 0x55 && cmd == 0x98) {