mirror of
https://github.com/yuzu-emu/unicorn
synced 2024-11-24 19:48:12 +00:00
qom/cpu: Add MemoryRegion property
Add a MemoryRegion property, which if set is used to construct the CPU's initial (default) AddressSpace. Backports commit 6731d864f80938e404dc3e5eb7f6b76b891e3e43 from qemu
This commit is contained in:
parent
6d5f465449
commit
ce997e1caf
4 changed files with 26 additions and 1 deletions
|
@ -88,8 +88,11 @@ int qemu_init_vcpu(CPUState *cpu)
|
|||
/* If the target cpu hasn't set up any address spaces itself,
|
||||
* give it the default one.
|
||||
*/
|
||||
AddressSpace *as = address_space_init_shareable(cpu->uc,
|
||||
cpu->memory,
|
||||
"cpu-memory");
|
||||
cpu->num_ases = 1;
|
||||
cpu_address_space_init(cpu, &cpu->uc->as, 0);
|
||||
cpu_address_space_init(cpu, as, 0);
|
||||
}
|
||||
|
||||
if (tcg_enabled(cpu->uc)) {
|
||||
|
|
19
qemu/exec.c
19
qemu/exec.c
|
@ -451,6 +451,25 @@ void cpu_exec_init(CPUState *cpu, void *opaque)
|
|||
|
||||
// TODO: assert uc does not already have a cpu?
|
||||
uc->cpu = cpu;
|
||||
|
||||
#ifndef CONFIG_USER_ONLY
|
||||
|
||||
// Unicorn: commented out
|
||||
/* This is a softmmu CPU object, so create a property for it
|
||||
* so users can wire up its memory. (This can't go in qom/cpu.c
|
||||
* because that file is compiled only once for both user-mode
|
||||
* and system builds.) The default if no link is set up is to use
|
||||
* the system address space.
|
||||
*/
|
||||
/*object_property_add_link(OBJECT(cpu), "memory", TYPE_MEMORY_REGION,
|
||||
(Object **)&cpu->memory,
|
||||
qdev_prop_allow_set_link_before_realize,
|
||||
OBJ_PROP_LINK_UNREF_ON_RELEASE,
|
||||
&error_abort);*/
|
||||
cpu->memory = uc->system_memory;
|
||||
// Unicorn: commented out
|
||||
/*object_ref(OBJECT(cpu->memory)); */
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(CONFIG_USER_ONLY)
|
||||
|
|
|
@ -264,6 +264,7 @@ struct CPUState {
|
|||
CPUAddressSpace *cpu_ases;
|
||||
int num_ases;
|
||||
AddressSpace *as;
|
||||
MemoryRegion *memory;
|
||||
|
||||
void *env_ptr; /* CPUArchState */
|
||||
struct TranslationBlock *current_tb;
|
||||
|
|
|
@ -44,6 +44,8 @@ static void release_common(void *t)
|
|||
|
||||
// TODO(danghvu): these function is not available outside qemu
|
||||
// so we keep them here instead of outside uc_close.
|
||||
phys_mem_clean(&s->uc->as);
|
||||
address_space_destroy(&s->uc->as);
|
||||
for (i = 0; i < s->uc->cpu->num_ases; i++) {
|
||||
AddressSpace *as = s->uc->cpu->cpu_ases[i].as;
|
||||
phys_mem_clean(as);
|
||||
|
|
Loading…
Reference in a new issue