Commit 3ee89922578269b37eedfeada17caeb7f74d9f24
1 parent
e3a79bca
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
Showing
1 changed file
with
16 additions
and
11 deletions
exec.c
| @@ -163,9 +163,9 @@ static int tb_phys_invalidate_count; | @@ -163,9 +163,9 @@ static int tb_phys_invalidate_count; | ||
| 163 | #define SUBPAGE_IDX(addr) ((addr) & ~TARGET_PAGE_MASK) | 163 | #define SUBPAGE_IDX(addr) ((addr) & ~TARGET_PAGE_MASK) |
| 164 | typedef struct subpage_t { | 164 | typedef struct subpage_t { |
| 165 | target_phys_addr_t base; | 165 | target_phys_addr_t base; |
| 166 | - CPUReadMemoryFunc *mem_read[TARGET_PAGE_SIZE][4]; | ||
| 167 | - CPUWriteMemoryFunc *mem_write[TARGET_PAGE_SIZE][4]; | ||
| 168 | - void *opaque[TARGET_PAGE_SIZE]; | 166 | + CPUReadMemoryFunc **mem_read[TARGET_PAGE_SIZE][4]; |
| 167 | + CPUWriteMemoryFunc **mem_write[TARGET_PAGE_SIZE][4]; | ||
| 168 | + void *opaque[TARGET_PAGE_SIZE][2][4]; | ||
| 169 | } subpage_t; | 169 | } subpage_t; |
| 170 | 170 | ||
| 171 | static void page_init(void) | 171 | 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 | ||
| 2316 | printf("%s: subpage %p len %d addr " TARGET_FMT_plx " idx %d\n", __func__, | 2316 | printf("%s: subpage %p len %d addr " TARGET_FMT_plx " idx %d\n", __func__, |
| 2317 | mmio, len, addr, idx); | 2317 | mmio, len, addr, idx); |
| 2318 | #endif | 2318 | #endif |
| 2319 | - ret = (*mmio->mem_read[idx][len])(mmio->opaque[idx], addr); | 2319 | + ret = (**mmio->mem_read[idx][len])(mmio->opaque[idx][0][len], addr); |
| 2320 | 2320 | ||
| 2321 | return ret; | 2321 | return ret; |
| 2322 | } | 2322 | } |
| @@ -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, | ||
| 2331 | printf("%s: subpage %p len %d addr " TARGET_FMT_plx " idx %d value %08x\n", __func__, | 2331 | printf("%s: subpage %p len %d addr " TARGET_FMT_plx " idx %d value %08x\n", __func__, |
| 2332 | mmio, len, addr, idx, value); | 2332 | mmio, len, addr, idx, value); |
| 2333 | #endif | 2333 | #endif |
| 2334 | - (*mmio->mem_write[idx][len])(mmio->opaque[idx], addr, value); | 2334 | + (**mmio->mem_write[idx][len])(mmio->opaque[idx][1][len], addr, value); |
| 2335 | } | 2335 | } |
| 2336 | 2336 | ||
| 2337 | static uint32_t subpage_readb (void *opaque, target_phys_addr_t addr) | 2337 | 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, | ||
| 2417 | memory >>= IO_MEM_SHIFT; | 2417 | memory >>= IO_MEM_SHIFT; |
| 2418 | for (; idx <= eidx; idx++) { | 2418 | for (; idx <= eidx; idx++) { |
| 2419 | for (i = 0; i < 4; i++) { | 2419 | for (i = 0; i < 4; i++) { |
| 2420 | - if (io_mem_read[memory][i]) | ||
| 2421 | - mmio->mem_read[idx][i] = io_mem_read[memory][i]; | ||
| 2422 | - if (io_mem_write[memory][i]) | ||
| 2423 | - mmio->mem_write[idx][i] = io_mem_write[memory][i]; | 2420 | + if (io_mem_read[memory][i]) { |
| 2421 | + mmio->mem_read[idx][i] = &io_mem_read[memory][i]; | ||
| 2422 | + mmio->opaque[idx][0][i] = io_mem_opaque[memory]; | ||
| 2423 | + } | ||
| 2424 | + if (io_mem_write[memory][i]) { | ||
| 2425 | + mmio->mem_write[idx][i] = &io_mem_write[memory][i]; | ||
| 2426 | + mmio->opaque[idx][1][i] = io_mem_opaque[memory]; | ||
| 2427 | + } | ||
| 2424 | } | 2428 | } |
| 2425 | - mmio->opaque[idx] = io_mem_opaque[memory]; | ||
| 2426 | } | 2429 | } |
| 2427 | 2430 | ||
| 2428 | return 0; | 2431 | return 0; |
| @@ -2467,7 +2470,9 @@ static void io_mem_init(void) | @@ -2467,7 +2470,9 @@ static void io_mem_init(void) | ||
| 2467 | 2470 | ||
| 2468 | /* mem_read and mem_write are arrays of functions containing the | 2471 | /* mem_read and mem_write are arrays of functions containing the |
| 2469 | function to access byte (index 0), word (index 1) and dword (index | 2472 | function to access byte (index 0), word (index 1) and dword (index |
| 2470 | - 2). If io_index is non zero, the corresponding io zone is | 2473 | + 2). Functions can be omitted with a NULL function pointer. The |
| 2474 | + registered functions may be modified dynamically later. | ||
| 2475 | + If io_index is non zero, the corresponding io zone is | ||
| 2471 | modified. If it is zero, a new io zone is allocated. The return | 2476 | modified. If it is zero, a new io zone is allocated. The return |
| 2472 | value can be used with cpu_register_physical_memory(). (-1) is | 2477 | value can be used with cpu_register_physical_memory(). (-1) is |
| 2473 | returned if error. */ | 2478 | returned if error. */ |