2 * i386 TCG cpu class initialization functions specific to sysemu
4 * Copyright (c) 2003 Fabrice Bellard
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
20 #include "qemu/osdep.h"
22 #include "tcg/helper-tcg.h"
24 #include "sysemu/sysemu.h"
25 #include "qemu/units.h"
26 #include "exec/address-spaces.h"
28 #include "tcg/tcg-cpu.h"
30 static void tcg_cpu_machine_done(Notifier
*n
, void *unused
)
32 X86CPU
*cpu
= container_of(n
, X86CPU
, machine_done
);
34 (MemoryRegion
*) object_resolve_path("/machine/smram", NULL
);
37 cpu
->smram
= g_new(MemoryRegion
, 1);
38 memory_region_init_alias(cpu
->smram
, OBJECT(cpu
), "smram",
40 memory_region_set_enabled(cpu
->smram
, true);
41 memory_region_add_subregion_overlap(cpu
->cpu_as_root
, 0,
46 bool tcg_cpu_realizefn(CPUState
*cs
, Error
**errp
)
48 X86CPU
*cpu
= X86_CPU(cs
);
51 * The realize order is important, since x86_cpu_realize() checks if
52 * nothing else has been set by the user (or by accelerators) in
53 * cpu->ucode_rev and cpu->phys_bits, and the memory regions
54 * initialized here are needed for the vcpu initialization.
57 * tcg_cpu -> host_cpu -> x86_cpu
59 cpu
->cpu_as_mem
= g_new(MemoryRegion
, 1);
60 cpu
->cpu_as_root
= g_new(MemoryRegion
, 1);
62 /* Outer container... */
63 memory_region_init(cpu
->cpu_as_root
, OBJECT(cpu
), "memory", ~0ull);
64 memory_region_set_enabled(cpu
->cpu_as_root
, true);
67 * ... with two regions inside: normal system memory with low
70 memory_region_init_alias(cpu
->cpu_as_mem
, OBJECT(cpu
), "memory",
71 get_system_memory(), 0, ~0ull);
72 memory_region_add_subregion_overlap(cpu
->cpu_as_root
, 0, cpu
->cpu_as_mem
, 0);
73 memory_region_set_enabled(cpu
->cpu_as_mem
, true);
76 cpu_address_space_init(cs
, 0, "cpu-memory", cs
->memory
);
77 cpu_address_space_init(cs
, 1, "cpu-smm", cpu
->cpu_as_root
);
79 /* ... SMRAM with higher priority, linked from /machine/smram. */
80 cpu
->machine_done
.notify
= tcg_cpu_machine_done
;
81 qemu_add_machine_init_done_notifier(&cpu
->machine_done
);