mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-05 16:53:55 -06:00
hw/i386: split PCMachineState deriving X86MachineState from it
Split up PCMachineState and PCMachineClass and derive X86MachineState and X86MachineClass from them. This allows sharing code with non-PC x86 machine types. Signed-off-by: Sergio Lopez <slp@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
549e984e67
commit
f0bb276bf8
12 changed files with 326 additions and 230 deletions
|
@ -74,6 +74,7 @@ static void pc_init1(MachineState *machine,
|
|||
{
|
||||
PCMachineState *pcms = PC_MACHINE(machine);
|
||||
PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms);
|
||||
X86MachineState *x86ms = X86_MACHINE(machine);
|
||||
MemoryRegion *system_memory = get_system_memory();
|
||||
MemoryRegion *system_io = get_system_io();
|
||||
int i;
|
||||
|
@ -126,11 +127,11 @@ static void pc_init1(MachineState *machine,
|
|||
if (xen_enabled()) {
|
||||
xen_hvm_init(pcms, &ram_memory);
|
||||
} else {
|
||||
if (!pcms->max_ram_below_4g) {
|
||||
pcms->max_ram_below_4g = 0xe0000000; /* default: 3.5G */
|
||||
if (!x86ms->max_ram_below_4g) {
|
||||
x86ms->max_ram_below_4g = 0xe0000000; /* default: 3.5G */
|
||||
}
|
||||
lowmem = pcms->max_ram_below_4g;
|
||||
if (machine->ram_size >= pcms->max_ram_below_4g) {
|
||||
lowmem = x86ms->max_ram_below_4g;
|
||||
if (machine->ram_size >= x86ms->max_ram_below_4g) {
|
||||
if (pcmc->gigabyte_align) {
|
||||
if (lowmem > 0xc0000000) {
|
||||
lowmem = 0xc0000000;
|
||||
|
@ -139,17 +140,17 @@ static void pc_init1(MachineState *machine,
|
|||
warn_report("Large machine and max_ram_below_4g "
|
||||
"(%" PRIu64 ") not a multiple of 1G; "
|
||||
"possible bad performance.",
|
||||
pcms->max_ram_below_4g);
|
||||
x86ms->max_ram_below_4g);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (machine->ram_size >= lowmem) {
|
||||
pcms->above_4g_mem_size = machine->ram_size - lowmem;
|
||||
pcms->below_4g_mem_size = lowmem;
|
||||
x86ms->above_4g_mem_size = machine->ram_size - lowmem;
|
||||
x86ms->below_4g_mem_size = lowmem;
|
||||
} else {
|
||||
pcms->above_4g_mem_size = 0;
|
||||
pcms->below_4g_mem_size = machine->ram_size;
|
||||
x86ms->above_4g_mem_size = 0;
|
||||
x86ms->below_4g_mem_size = machine->ram_size;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -191,19 +192,19 @@ static void pc_init1(MachineState *machine,
|
|||
gsi_state = g_malloc0(sizeof(*gsi_state));
|
||||
if (kvm_ioapic_in_kernel()) {
|
||||
kvm_pc_setup_irq_routing(pcmc->pci_enabled);
|
||||
pcms->gsi = qemu_allocate_irqs(kvm_pc_gsi_handler, gsi_state,
|
||||
x86ms->gsi = qemu_allocate_irqs(kvm_pc_gsi_handler, gsi_state,
|
||||
GSI_NUM_PINS);
|
||||
} else {
|
||||
pcms->gsi = qemu_allocate_irqs(gsi_handler, gsi_state, GSI_NUM_PINS);
|
||||
x86ms->gsi = qemu_allocate_irqs(gsi_handler, gsi_state, GSI_NUM_PINS);
|
||||
}
|
||||
|
||||
if (pcmc->pci_enabled) {
|
||||
pci_bus = i440fx_init(host_type,
|
||||
pci_type,
|
||||
&i440fx_state, &piix3_devfn, &isa_bus, pcms->gsi,
|
||||
&i440fx_state, &piix3_devfn, &isa_bus, x86ms->gsi,
|
||||
system_memory, system_io, machine->ram_size,
|
||||
pcms->below_4g_mem_size,
|
||||
pcms->above_4g_mem_size,
|
||||
x86ms->below_4g_mem_size,
|
||||
x86ms->above_4g_mem_size,
|
||||
pci_memory, ram_memory);
|
||||
pcms->bus = pci_bus;
|
||||
} else {
|
||||
|
@ -213,7 +214,7 @@ static void pc_init1(MachineState *machine,
|
|||
&error_abort);
|
||||
no_hpet = 1;
|
||||
}
|
||||
isa_bus_irqs(isa_bus, pcms->gsi);
|
||||
isa_bus_irqs(isa_bus, x86ms->gsi);
|
||||
|
||||
if (kvm_pic_in_kernel()) {
|
||||
i8259 = kvm_i8259_init(isa_bus);
|
||||
|
@ -231,7 +232,7 @@ static void pc_init1(MachineState *machine,
|
|||
ioapic_init_gsi(gsi_state, "i440fx");
|
||||
}
|
||||
|
||||
pc_register_ferr_irq(pcms->gsi[13]);
|
||||
pc_register_ferr_irq(x86ms->gsi[13]);
|
||||
|
||||
pc_vga_init(isa_bus, pcmc->pci_enabled ? pci_bus : NULL);
|
||||
|
||||
|
@ -241,7 +242,7 @@ static void pc_init1(MachineState *machine,
|
|||
}
|
||||
|
||||
/* init basic PC hardware */
|
||||
pc_basic_device_init(isa_bus, pcms->gsi, &rtc_state, true,
|
||||
pc_basic_device_init(isa_bus, x86ms->gsi, &rtc_state, true,
|
||||
(pcms->vmport != ON_OFF_AUTO_ON), pcms->pit_enabled,
|
||||
0x4);
|
||||
|
||||
|
@ -288,7 +289,7 @@ else {
|
|||
smi_irq = qemu_allocate_irq(pc_acpi_smi_interrupt, first_cpu, 0);
|
||||
/* TODO: Populate SPD eeprom data. */
|
||||
pcms->smbus = piix4_pm_init(pci_bus, piix3_devfn + 3, 0xb100,
|
||||
pcms->gsi[9], smi_irq,
|
||||
x86ms->gsi[9], smi_irq,
|
||||
pc_machine_is_smm_enabled(pcms),
|
||||
&piix4_pm);
|
||||
smbus_eeprom_init(pcms->smbus, 8, NULL, 0);
|
||||
|
@ -304,7 +305,7 @@ else {
|
|||
|
||||
if (machine->nvdimms_state->is_enabled) {
|
||||
nvdimm_init_acpi_state(machine->nvdimms_state, system_io,
|
||||
pcms->fw_cfg, OBJECT(pcms));
|
||||
x86ms->fw_cfg, OBJECT(pcms));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -729,7 +730,7 @@ DEFINE_I440FX_MACHINE(v1_4, "pc-i440fx-1.4", pc_compat_1_4_fn,
|
|||
|
||||
static void pc_i440fx_1_3_machine_options(MachineClass *m)
|
||||
{
|
||||
PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
|
||||
X86MachineClass *x86mc = X86_MACHINE_CLASS(m);
|
||||
static GlobalProperty compat[] = {
|
||||
PC_CPU_MODEL_IDS("1.3.0")
|
||||
{ "usb-tablet", "usb_version", "1" },
|
||||
|
@ -740,7 +741,7 @@ static void pc_i440fx_1_3_machine_options(MachineClass *m)
|
|||
|
||||
pc_i440fx_1_4_machine_options(m);
|
||||
m->hw_version = "1.3.0";
|
||||
pcmc->compat_apic_id_mode = true;
|
||||
x86mc->compat_apic_id_mode = true;
|
||||
compat_props_add(m->compat_props, compat, G_N_ELEMENTS(compat));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue