提交 3ee89922 编写于 作者: B blueswir1

Fix dynamically changed memory callbacks and passed opaque parameter


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3884 c046a42c-6fe2-441c-8c8c-71466251a162
上级 e3a79bca
...@@ -163,9 +163,9 @@ static int tb_phys_invalidate_count; ...@@ -163,9 +163,9 @@ static int tb_phys_invalidate_count;
#define SUBPAGE_IDX(addr) ((addr) & ~TARGET_PAGE_MASK) #define SUBPAGE_IDX(addr) ((addr) & ~TARGET_PAGE_MASK)
typedef struct subpage_t { typedef struct subpage_t {
target_phys_addr_t base; target_phys_addr_t base;
CPUReadMemoryFunc *mem_read[TARGET_PAGE_SIZE][4]; CPUReadMemoryFunc **mem_read[TARGET_PAGE_SIZE][4];
CPUWriteMemoryFunc *mem_write[TARGET_PAGE_SIZE][4]; CPUWriteMemoryFunc **mem_write[TARGET_PAGE_SIZE][4];
void *opaque[TARGET_PAGE_SIZE]; void *opaque[TARGET_PAGE_SIZE][2][4];
} subpage_t; } subpage_t;
static void page_init(void) static void page_init(void)
...@@ -2316,7 +2316,7 @@ static inline uint32_t subpage_readlen (subpage_t *mmio, target_phys_addr_t addr ...@@ -2316,7 +2316,7 @@ static inline uint32_t subpage_readlen (subpage_t *mmio, target_phys_addr_t addr
printf("%s: subpage %p len %d addr " TARGET_FMT_plx " idx %d\n", __func__, printf("%s: subpage %p len %d addr " TARGET_FMT_plx " idx %d\n", __func__,
mmio, len, addr, idx); mmio, len, addr, idx);
#endif #endif
ret = (*mmio->mem_read[idx][len])(mmio->opaque[idx], addr); ret = (**mmio->mem_read[idx][len])(mmio->opaque[idx][0][len], addr);
return ret; return ret;
} }
...@@ -2331,7 +2331,7 @@ static inline void subpage_writelen (subpage_t *mmio, target_phys_addr_t addr, ...@@ -2331,7 +2331,7 @@ static inline void subpage_writelen (subpage_t *mmio, target_phys_addr_t addr,
printf("%s: subpage %p len %d addr " TARGET_FMT_plx " idx %d value %08x\n", __func__, printf("%s: subpage %p len %d addr " TARGET_FMT_plx " idx %d value %08x\n", __func__,
mmio, len, addr, idx, value); mmio, len, addr, idx, value);
#endif #endif
(*mmio->mem_write[idx][len])(mmio->opaque[idx], addr, value); (**mmio->mem_write[idx][len])(mmio->opaque[idx][1][len], addr, value);
} }
static uint32_t subpage_readb (void *opaque, target_phys_addr_t addr) static uint32_t subpage_readb (void *opaque, target_phys_addr_t addr)
...@@ -2417,12 +2417,15 @@ static int subpage_register (subpage_t *mmio, uint32_t start, uint32_t end, ...@@ -2417,12 +2417,15 @@ static int subpage_register (subpage_t *mmio, uint32_t start, uint32_t end,
memory >>= IO_MEM_SHIFT; memory >>= IO_MEM_SHIFT;
for (; idx <= eidx; idx++) { for (; idx <= eidx; idx++) {
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
if (io_mem_read[memory][i]) if (io_mem_read[memory][i]) {
mmio->mem_read[idx][i] = io_mem_read[memory][i]; mmio->mem_read[idx][i] = &io_mem_read[memory][i];
if (io_mem_write[memory][i]) mmio->opaque[idx][0][i] = io_mem_opaque[memory];
mmio->mem_write[idx][i] = io_mem_write[memory][i]; }
if (io_mem_write[memory][i]) {
mmio->mem_write[idx][i] = &io_mem_write[memory][i];
mmio->opaque[idx][1][i] = io_mem_opaque[memory];
}
} }
mmio->opaque[idx] = io_mem_opaque[memory];
} }
return 0; return 0;
...@@ -2467,7 +2470,9 @@ static void io_mem_init(void) ...@@ -2467,7 +2470,9 @@ static void io_mem_init(void)
/* mem_read and mem_write are arrays of functions containing the /* mem_read and mem_write are arrays of functions containing the
function to access byte (index 0), word (index 1) and dword (index function to access byte (index 0), word (index 1) and dword (index
2). If io_index is non zero, the corresponding io zone is 2). Functions can be omitted with a NULL function pointer. The
registered functions may be modified dynamically later.
If io_index is non zero, the corresponding io zone is
modified. If it is zero, a new io zone is allocated. The return modified. If it is zero, a new io zone is allocated. The return
value can be used with cpu_register_physical_memory(). (-1) is value can be used with cpu_register_physical_memory(). (-1) is
returned if error. */ returned if error. */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册