mirror of https://gitee.com/openkylin/qemu.git
memory: move unassigned_mem_ops to memory.c
reservation_ops is already doing the same thing. Reviewed-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
149f54b53b
commit
d197063fcf
12
exec.c
12
exec.c
|
@ -50,7 +50,6 @@
|
||||||
|
|
||||||
#include "exec/memory-internal.h"
|
#include "exec/memory-internal.h"
|
||||||
|
|
||||||
//#define DEBUG_UNASSIGNED
|
|
||||||
//#define DEBUG_SUBPAGE
|
//#define DEBUG_SUBPAGE
|
||||||
|
|
||||||
#if !defined(CONFIG_USER_ONLY)
|
#if !defined(CONFIG_USER_ONLY)
|
||||||
|
@ -1402,17 +1401,6 @@ ram_addr_t qemu_ram_addr_from_host_nofail(void *ptr)
|
||||||
return ram_addr;
|
return ram_addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool unassigned_mem_accepts(void *opaque, hwaddr addr,
|
|
||||||
unsigned size, bool is_write)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const MemoryRegionOps unassigned_mem_ops = {
|
|
||||||
.valid.accepts = unassigned_mem_accepts,
|
|
||||||
.endianness = DEVICE_NATIVE_ENDIAN,
|
|
||||||
};
|
|
||||||
|
|
||||||
static void notdirty_mem_write(void *opaque, hwaddr ram_addr,
|
static void notdirty_mem_write(void *opaque, hwaddr ram_addr,
|
||||||
uint64_t val, unsigned size)
|
uint64_t val, unsigned size)
|
||||||
{
|
{
|
||||||
|
|
|
@ -43,6 +43,8 @@ struct AddressSpaceDispatch {
|
||||||
void address_space_init_dispatch(AddressSpace *as);
|
void address_space_init_dispatch(AddressSpace *as);
|
||||||
void address_space_destroy_dispatch(AddressSpace *as);
|
void address_space_destroy_dispatch(AddressSpace *as);
|
||||||
|
|
||||||
|
extern const MemoryRegionOps unassigned_mem_ops;
|
||||||
|
|
||||||
ram_addr_t qemu_ram_alloc_from_ptr(ram_addr_t size, void *host,
|
ram_addr_t qemu_ram_alloc_from_ptr(ram_addr_t size, void *host,
|
||||||
MemoryRegion *mr);
|
MemoryRegion *mr);
|
||||||
ram_addr_t qemu_ram_alloc(ram_addr_t size, MemoryRegion *mr);
|
ram_addr_t qemu_ram_alloc(ram_addr_t size, MemoryRegion *mr);
|
||||||
|
|
44
memory.c
44
memory.c
|
@ -22,6 +22,8 @@
|
||||||
|
|
||||||
#include "exec/memory-internal.h"
|
#include "exec/memory-internal.h"
|
||||||
|
|
||||||
|
//#define DEBUG_UNASSIGNED
|
||||||
|
|
||||||
static unsigned memory_region_transaction_depth;
|
static unsigned memory_region_transaction_depth;
|
||||||
static bool memory_region_update_pending;
|
static bool memory_region_update_pending;
|
||||||
static bool global_dirty_log = false;
|
static bool global_dirty_log = false;
|
||||||
|
@ -837,6 +839,17 @@ static void unassigned_mem_write(void *opaque, hwaddr addr,
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool unassigned_mem_accepts(void *opaque, hwaddr addr,
|
||||||
|
unsigned size, bool is_write)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const MemoryRegionOps unassigned_mem_ops = {
|
||||||
|
.valid.accepts = unassigned_mem_accepts,
|
||||||
|
.endianness = DEVICE_NATIVE_ENDIAN,
|
||||||
|
};
|
||||||
|
|
||||||
static bool memory_region_access_valid(MemoryRegion *mr,
|
static bool memory_region_access_valid(MemoryRegion *mr,
|
||||||
hwaddr addr,
|
hwaddr addr,
|
||||||
unsigned size,
|
unsigned size,
|
||||||
|
@ -1001,40 +1014,11 @@ void memory_region_init_rom_device(MemoryRegion *mr,
|
||||||
mr->ram_addr = qemu_ram_alloc(size, mr);
|
mr->ram_addr = qemu_ram_alloc(size, mr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint64_t invalid_read(void *opaque, hwaddr addr,
|
|
||||||
unsigned size)
|
|
||||||
{
|
|
||||||
MemoryRegion *mr = opaque;
|
|
||||||
|
|
||||||
if (!mr->warning_printed) {
|
|
||||||
fprintf(stderr, "Invalid read from memory region %s\n", mr->name);
|
|
||||||
mr->warning_printed = true;
|
|
||||||
}
|
|
||||||
return -1U;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void invalid_write(void *opaque, hwaddr addr, uint64_t data,
|
|
||||||
unsigned size)
|
|
||||||
{
|
|
||||||
MemoryRegion *mr = opaque;
|
|
||||||
|
|
||||||
if (!mr->warning_printed) {
|
|
||||||
fprintf(stderr, "Invalid write to memory region %s\n", mr->name);
|
|
||||||
mr->warning_printed = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static const MemoryRegionOps reservation_ops = {
|
|
||||||
.read = invalid_read,
|
|
||||||
.write = invalid_write,
|
|
||||||
.endianness = DEVICE_NATIVE_ENDIAN,
|
|
||||||
};
|
|
||||||
|
|
||||||
void memory_region_init_reservation(MemoryRegion *mr,
|
void memory_region_init_reservation(MemoryRegion *mr,
|
||||||
const char *name,
|
const char *name,
|
||||||
uint64_t size)
|
uint64_t size)
|
||||||
{
|
{
|
||||||
memory_region_init_io(mr, &reservation_ops, mr, name, size);
|
memory_region_init_io(mr, &unassigned_mem_ops, mr, name, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void memory_region_destroy(MemoryRegion *mr)
|
void memory_region_destroy(MemoryRegion *mr)
|
||||||
|
|
Loading…
Reference in New Issue