Fold is_ram_rom and is_ram_rom_romd() into callers.
Change is_romd() and section_addr() to take MemoryRegion
instead of MemoryRegionSection for consistency and
use memory_region_ prefix.
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
- if (!is_ram_rom_romd(section)) {
+ if (!(memory_region_is_ram(section->mr) ||
+ memory_region_is_romd(section->mr))) {
/* IO memory case (romd handled later) */
address |= TLB_MMIO;
}
/* IO memory case (romd handled later) */
address |= TLB_MMIO;
}
- if (is_ram_rom_romd(section)) {
+ if (memory_region_is_ram(section->mr) ||
+ memory_region_is_romd(section->mr)) {
addend = (uintptr_t)memory_region_get_ram_ptr(section->mr)
addend = (uintptr_t)memory_region_get_ram_ptr(section->mr)
- + section_addr(section, paddr);
+ + memory_region_section_addr(section, paddr);
}
if (prot & PAGE_WRITE) {
if ((memory_region_is_ram(section->mr) && section->readonly)
}
if (prot & PAGE_WRITE) {
if ((memory_region_is_ram(section->mr) && section->readonly)
+ || memory_region_is_romd(section->mr)) {
/* Write access calls the I/O callback. */
te->addr_write = address | TLB_MMIO;
} else if (memory_region_is_ram(section->mr)
&& !cpu_physical_memory_is_dirty(
section->mr->ram_addr
/* Write access calls the I/O callback. */
te->addr_write = address | TLB_MMIO;
} else if (memory_region_is_ram(section->mr)
&& !cpu_physical_memory_is_dirty(
section->mr->ram_addr
- + section_addr(section, paddr))) {
+ + memory_region_section_addr(section, paddr))) {
te->addr_write = address | TLB_NOTDIRTY;
} else {
te->addr_write = address;
te->addr_write = address | TLB_NOTDIRTY;
} else {
te->addr_write = address;
extern int tlb_flush_count;
/* exec.c */
extern int tlb_flush_count;
/* exec.c */
-target_phys_addr_t section_addr(MemoryRegionSection *section,
- target_phys_addr_t addr);
+target_phys_addr_t memory_region_section_addr(MemoryRegionSection *section,
+ target_phys_addr_t addr);
void tb_flush_jmp_cache(CPUArchState *env, target_ulong addr);
target_phys_addr_t memory_region_section_get_iotlb(CPUArchState *env,
MemoryRegionSection *section,
void tb_flush_jmp_cache(CPUArchState *env, target_ulong addr);
target_phys_addr_t memory_region_section_get_iotlb(CPUArchState *env,
MemoryRegionSection *section,
target_ulong *address);
bool memory_region_is_unassigned(MemoryRegion *mr);
target_ulong *address);
bool memory_region_is_unassigned(MemoryRegion *mr);
-static inline bool is_ram_rom(MemoryRegionSection *s)
+static inline bool memory_region_is_romd(MemoryRegion *mr)
- return memory_region_is_ram(s->mr);
-}
-
-static inline bool is_romd(MemoryRegionSection *s)
-{
- MemoryRegion *mr = s->mr;
-
return mr->rom_device && mr->readable;
}
return mr->rom_device && mr->readable;
}
-static inline bool is_ram_rom_romd(MemoryRegionSection *s)
-{
- return is_ram_rom(s) || is_romd(s);
-}
-
&& mr != &io_mem_watch;
}
&& mr != &io_mem_watch;
}
-target_phys_addr_t section_addr(MemoryRegionSection *section,
- target_phys_addr_t addr)
+target_phys_addr_t memory_region_section_addr(MemoryRegionSection *section,
+ target_phys_addr_t addr)
{
addr -= section->offset_within_address_space;
addr += section->offset_within_region;
{
addr -= section->offset_within_address_space;
addr += section->offset_within_region;
return;
}
ram_addr = (memory_region_get_ram_addr(section->mr) & TARGET_PAGE_MASK)
return;
}
ram_addr = (memory_region_get_ram_addr(section->mr) & TARGET_PAGE_MASK)
- + section_addr(section, addr);
+ + memory_region_section_addr(section, addr);
tb_invalidate_phys_page_range(ram_addr, ram_addr + 1, 0);
}
tb_invalidate_phys_page_range(ram_addr, ram_addr + 1, 0);
}
target_phys_addr_t iotlb;
CPUWatchpoint *wp;
target_phys_addr_t iotlb;
CPUWatchpoint *wp;
- if (is_ram_rom(section)) {
+ if (memory_region_is_ram(section->mr)) {
/* Normal RAM. */
iotlb = (memory_region_get_ram_addr(section->mr) & TARGET_PAGE_MASK)
/* Normal RAM. */
iotlb = (memory_region_get_ram_addr(section->mr) & TARGET_PAGE_MASK)
- + section_addr(section, paddr);
+ + memory_region_section_addr(section, paddr);
if (!section->readonly) {
iotlb |= phys_section_notdirty;
} else {
if (!section->readonly) {
iotlb |= phys_section_notdirty;
} else {
We can't use the high bits of pd for this because
IO_MEM_ROMD uses these as a ram address. */
iotlb = section - phys_sections;
We can't use the high bits of pd for this because
IO_MEM_ROMD uses these as a ram address. */
iotlb = section - phys_sections;
- iotlb += section_addr(section, paddr);
+ iotlb += memory_region_section_addr(section, paddr);
}
/* Make accesses to pages with watchpoints go via the
}
/* Make accesses to pages with watchpoints go via the
if (is_write) {
if (!memory_region_is_ram(section->mr)) {
target_phys_addr_t addr1;
if (is_write) {
if (!memory_region_is_ram(section->mr)) {
target_phys_addr_t addr1;
- addr1 = section_addr(section, addr);
+ addr1 = memory_region_section_addr(section, addr);
/* XXX: could force cpu_single_env to NULL to avoid
potential bugs */
if (l >= 4 && ((addr1 & 3) == 0)) {
/* XXX: could force cpu_single_env to NULL to avoid
potential bugs */
if (l >= 4 && ((addr1 & 3) == 0)) {
} else if (!section->readonly) {
ram_addr_t addr1;
addr1 = memory_region_get_ram_addr(section->mr)
} else if (!section->readonly) {
ram_addr_t addr1;
addr1 = memory_region_get_ram_addr(section->mr)
- + section_addr(section, addr);
+ + memory_region_section_addr(section, addr);
/* RAM case */
ptr = qemu_get_ram_ptr(addr1);
memcpy(ptr, buf, l);
/* RAM case */
ptr = qemu_get_ram_ptr(addr1);
memcpy(ptr, buf, l);
qemu_put_ram_ptr(ptr);
}
} else {
qemu_put_ram_ptr(ptr);
}
} else {
- if (!is_ram_rom_romd(section)) {
+ if (!(memory_region_is_ram(section->mr) ||
+ memory_region_is_romd(section->mr))) {
target_phys_addr_t addr1;
/* I/O case */
target_phys_addr_t addr1;
/* I/O case */
- addr1 = section_addr(section, addr);
+ addr1 = memory_region_section_addr(section, addr);
if (l >= 4 && ((addr1 & 3) == 0)) {
/* 32 bit read access */
val = io_mem_read(section->mr, addr1, 4);
if (l >= 4 && ((addr1 & 3) == 0)) {
/* 32 bit read access */
val = io_mem_read(section->mr, addr1, 4);
} else {
/* RAM case */
ptr = qemu_get_ram_ptr(section->mr->ram_addr
} else {
/* RAM case */
ptr = qemu_get_ram_ptr(section->mr->ram_addr
- + section_addr(section, addr));
+ + memory_region_section_addr(section,
+ addr));
memcpy(buf, ptr, l);
qemu_put_ram_ptr(ptr);
}
memcpy(buf, ptr, l);
qemu_put_ram_ptr(ptr);
}
l = len;
section = phys_page_find(page >> TARGET_PAGE_BITS);
l = len;
section = phys_page_find(page >> TARGET_PAGE_BITS);
- if (!is_ram_rom_romd(section)) {
+ if (!(memory_region_is_ram(section->mr) ||
+ memory_region_is_romd(section->mr))) {
/* do nothing */
} else {
unsigned long addr1;
addr1 = memory_region_get_ram_addr(section->mr)
/* do nothing */
} else {
unsigned long addr1;
addr1 = memory_region_get_ram_addr(section->mr)
- + section_addr(section, addr);
+ + memory_region_section_addr(section, addr);
/* ROM/RAM case */
ptr = qemu_get_ram_ptr(addr1);
memcpy(ptr, buf, l);
/* ROM/RAM case */
ptr = qemu_get_ram_ptr(addr1);
memcpy(ptr, buf, l);
}
if (!todo) {
raddr = memory_region_get_ram_addr(section->mr)
}
if (!todo) {
raddr = memory_region_get_ram_addr(section->mr)
- + section_addr(section, addr);
+ + memory_region_section_addr(section, addr);
section = phys_page_find(addr >> TARGET_PAGE_BITS);
section = phys_page_find(addr >> TARGET_PAGE_BITS);
- if (!is_ram_rom_romd(section)) {
+ if (!(memory_region_is_ram(section->mr) ||
+ memory_region_is_romd(section->mr))) {
- addr = section_addr(section, addr);
+ addr = memory_region_section_addr(section, addr);
val = io_mem_read(section->mr, addr, 4);
#if defined(TARGET_WORDS_BIGENDIAN)
if (endian == DEVICE_LITTLE_ENDIAN) {
val = io_mem_read(section->mr, addr, 4);
#if defined(TARGET_WORDS_BIGENDIAN)
if (endian == DEVICE_LITTLE_ENDIAN) {
/* RAM case */
ptr = qemu_get_ram_ptr((memory_region_get_ram_addr(section->mr)
& TARGET_PAGE_MASK)
/* RAM case */
ptr = qemu_get_ram_ptr((memory_region_get_ram_addr(section->mr)
& TARGET_PAGE_MASK)
- + section_addr(section, addr));
+ + memory_region_section_addr(section, addr));
switch (endian) {
case DEVICE_LITTLE_ENDIAN:
val = ldl_le_p(ptr);
switch (endian) {
case DEVICE_LITTLE_ENDIAN:
val = ldl_le_p(ptr);
section = phys_page_find(addr >> TARGET_PAGE_BITS);
section = phys_page_find(addr >> TARGET_PAGE_BITS);
- if (!is_ram_rom_romd(section)) {
+ if (!(memory_region_is_ram(section->mr) ||
+ memory_region_is_romd(section->mr))) {
- addr = section_addr(section, addr);
+ addr = memory_region_section_addr(section, addr);
/* XXX This is broken when device endian != cpu endian.
Fix and add "endian" variable check */
/* XXX This is broken when device endian != cpu endian.
Fix and add "endian" variable check */
/* RAM case */
ptr = qemu_get_ram_ptr((memory_region_get_ram_addr(section->mr)
& TARGET_PAGE_MASK)
/* RAM case */
ptr = qemu_get_ram_ptr((memory_region_get_ram_addr(section->mr)
& TARGET_PAGE_MASK)
- + section_addr(section, addr));
+ + memory_region_section_addr(section, addr));
switch (endian) {
case DEVICE_LITTLE_ENDIAN:
val = ldq_le_p(ptr);
switch (endian) {
case DEVICE_LITTLE_ENDIAN:
val = ldq_le_p(ptr);
section = phys_page_find(addr >> TARGET_PAGE_BITS);
section = phys_page_find(addr >> TARGET_PAGE_BITS);
- if (!is_ram_rom_romd(section)) {
+ if (!(memory_region_is_ram(section->mr) ||
+ memory_region_is_romd(section->mr))) {
- addr = section_addr(section, addr);
+ addr = memory_region_section_addr(section, addr);
val = io_mem_read(section->mr, addr, 2);
#if defined(TARGET_WORDS_BIGENDIAN)
if (endian == DEVICE_LITTLE_ENDIAN) {
val = io_mem_read(section->mr, addr, 2);
#if defined(TARGET_WORDS_BIGENDIAN)
if (endian == DEVICE_LITTLE_ENDIAN) {
/* RAM case */
ptr = qemu_get_ram_ptr((memory_region_get_ram_addr(section->mr)
& TARGET_PAGE_MASK)
/* RAM case */
ptr = qemu_get_ram_ptr((memory_region_get_ram_addr(section->mr)
& TARGET_PAGE_MASK)
- + section_addr(section, addr));
+ + memory_region_section_addr(section, addr));
switch (endian) {
case DEVICE_LITTLE_ENDIAN:
val = lduw_le_p(ptr);
switch (endian) {
case DEVICE_LITTLE_ENDIAN:
val = lduw_le_p(ptr);
section = phys_page_find(addr >> TARGET_PAGE_BITS);
if (!memory_region_is_ram(section->mr) || section->readonly) {
section = phys_page_find(addr >> TARGET_PAGE_BITS);
if (!memory_region_is_ram(section->mr) || section->readonly) {
- addr = section_addr(section, addr);
+ addr = memory_region_section_addr(section, addr);
if (memory_region_is_ram(section->mr)) {
section = &phys_sections[phys_section_rom];
}
if (memory_region_is_ram(section->mr)) {
section = &phys_sections[phys_section_rom];
}
} else {
unsigned long addr1 = (memory_region_get_ram_addr(section->mr)
& TARGET_PAGE_MASK)
} else {
unsigned long addr1 = (memory_region_get_ram_addr(section->mr)
& TARGET_PAGE_MASK)
- + section_addr(section, addr);
+ + memory_region_section_addr(section, addr);
ptr = qemu_get_ram_ptr(addr1);
stl_p(ptr, val);
ptr = qemu_get_ram_ptr(addr1);
stl_p(ptr, val);
section = phys_page_find(addr >> TARGET_PAGE_BITS);
if (!memory_region_is_ram(section->mr) || section->readonly) {
section = phys_page_find(addr >> TARGET_PAGE_BITS);
if (!memory_region_is_ram(section->mr) || section->readonly) {
- addr = section_addr(section, addr);
+ addr = memory_region_section_addr(section, addr);
if (memory_region_is_ram(section->mr)) {
section = &phys_sections[phys_section_rom];
}
if (memory_region_is_ram(section->mr)) {
section = &phys_sections[phys_section_rom];
}
} else {
ptr = qemu_get_ram_ptr((memory_region_get_ram_addr(section->mr)
& TARGET_PAGE_MASK)
} else {
ptr = qemu_get_ram_ptr((memory_region_get_ram_addr(section->mr)
& TARGET_PAGE_MASK)
- + section_addr(section, addr));
+ + memory_region_section_addr(section, addr));
section = phys_page_find(addr >> TARGET_PAGE_BITS);
if (!memory_region_is_ram(section->mr) || section->readonly) {
section = phys_page_find(addr >> TARGET_PAGE_BITS);
if (!memory_region_is_ram(section->mr) || section->readonly) {
- addr = section_addr(section, addr);
+ addr = memory_region_section_addr(section, addr);
if (memory_region_is_ram(section->mr)) {
section = &phys_sections[phys_section_rom];
}
if (memory_region_is_ram(section->mr)) {
section = &phys_sections[phys_section_rom];
}
} else {
unsigned long addr1;
addr1 = (memory_region_get_ram_addr(section->mr) & TARGET_PAGE_MASK)
} else {
unsigned long addr1;
addr1 = (memory_region_get_ram_addr(section->mr) & TARGET_PAGE_MASK)
- + section_addr(section, addr);
+ + memory_region_section_addr(section, addr);
/* RAM case */
ptr = qemu_get_ram_ptr(addr1);
switch (endian) {
/* RAM case */
ptr = qemu_get_ram_ptr(addr1);
switch (endian) {
section = phys_page_find(addr >> TARGET_PAGE_BITS);
if (!memory_region_is_ram(section->mr) || section->readonly) {
section = phys_page_find(addr >> TARGET_PAGE_BITS);
if (!memory_region_is_ram(section->mr) || section->readonly) {
- addr = section_addr(section, addr);
+ addr = memory_region_section_addr(section, addr);
if (memory_region_is_ram(section->mr)) {
section = &phys_sections[phys_section_rom];
}
if (memory_region_is_ram(section->mr)) {
section = &phys_sections[phys_section_rom];
}
} else {
unsigned long addr1;
addr1 = (memory_region_get_ram_addr(section->mr) & TARGET_PAGE_MASK)
} else {
unsigned long addr1;
addr1 = (memory_region_get_ram_addr(section->mr) & TARGET_PAGE_MASK)
- + section_addr(section, addr);
+ + memory_region_section_addr(section, addr);
/* RAM case */
ptr = qemu_get_ram_ptr(addr1);
switch (endian) {
/* RAM case */
ptr = qemu_get_ram_ptr(addr1);
switch (endian) {