Commit 0e0df1e2 authored by Avi Kivity's avatar Avi Kivity

Convert IO_MEM_{RAM,ROM,UNASSIGNED,NOTDIRTY} to MemoryRegions

Convert the fixed-address IO_MEM_RAM, IO_MEM_ROM, IO_MEM_UNASSIGNED,
and IO_MEM_NOTDIRTY io handlers to MemoryRegions.  These aren't real
regions, since they are never added to the memory hierarchy, but they
allow reuse of the dispatch functionality.
Signed-off-by: default avatarAvi Kivity <avi@redhat.com>
Reviewed-by: default avatarRichard Henderson <rth@twiddle.net>
parent d39e8222
......@@ -109,10 +109,10 @@ void cpu_physical_memory_write_rom(target_phys_addr_t addr,
#define IO_MEM_SHIFT 3
#define IO_MEM_RAM (0 << IO_MEM_SHIFT) /* hardcoded offset */
#define IO_MEM_ROM (1 << IO_MEM_SHIFT) /* hardcoded offset */
#define IO_MEM_UNASSIGNED (2 << IO_MEM_SHIFT)
#define IO_MEM_NOTDIRTY (3 << IO_MEM_SHIFT)
extern struct MemoryRegion io_mem_ram;
extern struct MemoryRegion io_mem_rom;
extern struct MemoryRegion io_mem_unassigned;
extern struct MemoryRegion io_mem_notdirty;
#define IO_MEM_SUBPAGE_RAM (4 << IO_MEM_SHIFT)
/* Acts like a ROM when read and like a device when written. */
......
This diff is collapsed.
......@@ -312,8 +312,7 @@ static void as_memory_range_add(AddressSpace *as, FlatRange *fr)
/* cpu_register_physical_memory_log() wants region_offset for
* mmio, but prefers offseting phys_offset for RAM. Humour it.
*/
if ((phys_offset & ~TARGET_PAGE_MASK) == IO_MEM_RAM
|| (phys_offset & ~TARGET_PAGE_MASK) == IO_MEM_ROM) {
if (memory_region_is_ram(fr->mr)) {
phys_offset += region_offset;
region_offset = 0;
}
......@@ -323,7 +322,7 @@ static void as_memory_range_add(AddressSpace *as, FlatRange *fr)
}
if (fr->readonly) {
phys_offset |= IO_MEM_ROM;
phys_offset |= io_mem_rom.ram_addr;
}
cpu_register_physical_memory_log(int128_get64(fr->addr.start),
......@@ -337,7 +336,7 @@ static void as_memory_range_del(AddressSpace *as, FlatRange *fr)
{
cpu_register_physical_memory(int128_get64(fr->addr.start),
int128_get64(fr->addr.size),
IO_MEM_UNASSIGNED);
io_mem_unassigned.ram_addr);
}
static void as_memory_log_start(AddressSpace *as, FlatRange *fr)
......
......@@ -22,6 +22,7 @@
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
#include "qemu-timer.h"
#include "memory.h"
#define DATA_SIZE (1 << SHIFT)
......@@ -65,8 +66,9 @@ static inline DATA_TYPE glue(io_read, SUFFIX)(target_phys_addr_t physaddr,
index = (physaddr >> IO_MEM_SHIFT) & (IO_MEM_NB_ENTRIES - 1);
physaddr = (physaddr & TARGET_PAGE_MASK) + addr;
env->mem_io_pc = (unsigned long)retaddr;
if (index != IO_MEM_RAM && index != IO_MEM_ROM
&& index != IO_MEM_UNASSIGNED && index != IO_MEM_NOTDIRTY
if (index != io_mem_ram.ram_addr && index != io_mem_rom.ram_addr
&& index != io_mem_unassigned.ram_addr
&& index != io_mem_notdirty.ram_addr
&& !can_do_io(env)) {
cpu_io_recompile(env, retaddr);
}
......@@ -208,8 +210,9 @@ static inline void glue(io_write, SUFFIX)(target_phys_addr_t physaddr,
int index;
index = (physaddr >> IO_MEM_SHIFT) & (IO_MEM_NB_ENTRIES - 1);
physaddr = (physaddr & TARGET_PAGE_MASK) + addr;
if (index != IO_MEM_RAM && index != IO_MEM_ROM
&& index != IO_MEM_UNASSIGNED && index != IO_MEM_NOTDIRTY
if (index != io_mem_ram.ram_addr && index != io_mem_rom.ram_addr
&& index != io_mem_unassigned.ram_addr
&& index != io_mem_notdirty.ram_addr
&& !can_do_io(env)) {
cpu_io_recompile(env, retaddr);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment