pc: Move {above,below}_4g_mem_size variables to PCMachineState
This will make the info readily available for the other initialization functions, and will allow us to simplify their argument list. Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
62b160c02c
commit
c0aa4e1ecb
|
@ -82,7 +82,6 @@ static void pc_init1(MachineState *machine)
|
||||||
MemoryRegion *system_memory = get_system_memory();
|
MemoryRegion *system_memory = get_system_memory();
|
||||||
MemoryRegion *system_io = get_system_io();
|
MemoryRegion *system_io = get_system_io();
|
||||||
int i;
|
int i;
|
||||||
ram_addr_t below_4g_mem_size, above_4g_mem_size;
|
|
||||||
PCIBus *pci_bus;
|
PCIBus *pci_bus;
|
||||||
ISABus *isa_bus;
|
ISABus *isa_bus;
|
||||||
PCII440FXState *i440fx_state;
|
PCII440FXState *i440fx_state;
|
||||||
|
@ -128,14 +127,15 @@ static void pc_init1(MachineState *machine)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (machine->ram_size >= lowmem) {
|
if (machine->ram_size >= lowmem) {
|
||||||
above_4g_mem_size = machine->ram_size - lowmem;
|
pcms->above_4g_mem_size = machine->ram_size - lowmem;
|
||||||
below_4g_mem_size = lowmem;
|
pcms->below_4g_mem_size = lowmem;
|
||||||
} else {
|
} else {
|
||||||
above_4g_mem_size = 0;
|
pcms->above_4g_mem_size = 0;
|
||||||
below_4g_mem_size = machine->ram_size;
|
pcms->below_4g_mem_size = machine->ram_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (xen_enabled() && xen_hvm_init(&below_4g_mem_size, &above_4g_mem_size,
|
if (xen_enabled() && xen_hvm_init(&pcms->below_4g_mem_size,
|
||||||
|
&pcms->above_4g_mem_size,
|
||||||
&ram_memory) != 0) {
|
&ram_memory) != 0) {
|
||||||
fprintf(stderr, "xen hardware virtual machine initialisation failed\n");
|
fprintf(stderr, "xen hardware virtual machine initialisation failed\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -160,7 +160,8 @@ static void pc_init1(MachineState *machine)
|
||||||
rom_memory = system_memory;
|
rom_memory = system_memory;
|
||||||
}
|
}
|
||||||
|
|
||||||
guest_info = pc_guest_info_init(below_4g_mem_size, above_4g_mem_size);
|
guest_info = pc_guest_info_init(pcms->below_4g_mem_size,
|
||||||
|
pcms->above_4g_mem_size);
|
||||||
|
|
||||||
guest_info->has_acpi_build = has_acpi_build;
|
guest_info->has_acpi_build = has_acpi_build;
|
||||||
guest_info->legacy_acpi_table_size = legacy_acpi_table_size;
|
guest_info->legacy_acpi_table_size = legacy_acpi_table_size;
|
||||||
|
@ -179,14 +180,14 @@ static void pc_init1(MachineState *machine)
|
||||||
/* allocate ram and load rom/bios */
|
/* allocate ram and load rom/bios */
|
||||||
if (!xen_enabled()) {
|
if (!xen_enabled()) {
|
||||||
pc_memory_init(pcms, system_memory,
|
pc_memory_init(pcms, system_memory,
|
||||||
below_4g_mem_size, above_4g_mem_size,
|
pcms->below_4g_mem_size, pcms->above_4g_mem_size,
|
||||||
rom_memory, &ram_memory, guest_info);
|
rom_memory, &ram_memory, guest_info);
|
||||||
} else if (machine->kernel_filename != NULL) {
|
} else if (machine->kernel_filename != NULL) {
|
||||||
/* For xen HVM direct kernel boot, load linux here */
|
/* For xen HVM direct kernel boot, load linux here */
|
||||||
xen_load_linux(machine->kernel_filename,
|
xen_load_linux(machine->kernel_filename,
|
||||||
machine->kernel_cmdline,
|
machine->kernel_cmdline,
|
||||||
machine->initrd_filename,
|
machine->initrd_filename,
|
||||||
below_4g_mem_size,
|
pcms->below_4g_mem_size,
|
||||||
guest_info);
|
guest_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -202,8 +203,8 @@ static void pc_init1(MachineState *machine)
|
||||||
if (pci_enabled) {
|
if (pci_enabled) {
|
||||||
pci_bus = i440fx_init(&i440fx_state, &piix3_devfn, &isa_bus, gsi,
|
pci_bus = i440fx_init(&i440fx_state, &piix3_devfn, &isa_bus, gsi,
|
||||||
system_memory, system_io, machine->ram_size,
|
system_memory, system_io, machine->ram_size,
|
||||||
below_4g_mem_size,
|
pcms->below_4g_mem_size,
|
||||||
above_4g_mem_size,
|
pcms->above_4g_mem_size,
|
||||||
pci_memory, ram_memory);
|
pci_memory, ram_memory);
|
||||||
} else {
|
} else {
|
||||||
pci_bus = NULL;
|
pci_bus = NULL;
|
||||||
|
@ -272,7 +273,8 @@ static void pc_init1(MachineState *machine)
|
||||||
}
|
}
|
||||||
|
|
||||||
pc_cmos_init(pcms,
|
pc_cmos_init(pcms,
|
||||||
below_4g_mem_size, above_4g_mem_size, machine->boot_order,
|
pcms->below_4g_mem_size, pcms->above_4g_mem_size,
|
||||||
|
machine->boot_order,
|
||||||
idebus[0], idebus[1], rtc_state);
|
idebus[0], idebus[1], rtc_state);
|
||||||
|
|
||||||
if (pci_enabled && usb_enabled()) {
|
if (pci_enabled && usb_enabled()) {
|
||||||
|
|
|
@ -66,7 +66,6 @@ static bool has_reserved_memory = true;
|
||||||
static void pc_q35_init(MachineState *machine)
|
static void pc_q35_init(MachineState *machine)
|
||||||
{
|
{
|
||||||
PCMachineState *pcms = PC_MACHINE(machine);
|
PCMachineState *pcms = PC_MACHINE(machine);
|
||||||
ram_addr_t below_4g_mem_size, above_4g_mem_size;
|
|
||||||
Q35PCIHost *q35_host;
|
Q35PCIHost *q35_host;
|
||||||
PCIHostState *phb;
|
PCIHostState *phb;
|
||||||
PCIBus *host_bus;
|
PCIBus *host_bus;
|
||||||
|
@ -119,14 +118,15 @@ static void pc_q35_init(MachineState *machine)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (machine->ram_size >= lowmem) {
|
if (machine->ram_size >= lowmem) {
|
||||||
above_4g_mem_size = machine->ram_size - lowmem;
|
pcms->above_4g_mem_size = machine->ram_size - lowmem;
|
||||||
below_4g_mem_size = lowmem;
|
pcms->below_4g_mem_size = lowmem;
|
||||||
} else {
|
} else {
|
||||||
above_4g_mem_size = 0;
|
pcms->above_4g_mem_size = 0;
|
||||||
below_4g_mem_size = machine->ram_size;
|
pcms->below_4g_mem_size = machine->ram_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (xen_enabled() && xen_hvm_init(&below_4g_mem_size, &above_4g_mem_size,
|
if (xen_enabled() && xen_hvm_init(&pcms->below_4g_mem_size,
|
||||||
|
&pcms->above_4g_mem_size,
|
||||||
&ram_memory) != 0) {
|
&ram_memory) != 0) {
|
||||||
fprintf(stderr, "xen hardware virtual machine initialisation failed\n");
|
fprintf(stderr, "xen hardware virtual machine initialisation failed\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -151,7 +151,8 @@ static void pc_q35_init(MachineState *machine)
|
||||||
rom_memory = get_system_memory();
|
rom_memory = get_system_memory();
|
||||||
}
|
}
|
||||||
|
|
||||||
guest_info = pc_guest_info_init(below_4g_mem_size, above_4g_mem_size);
|
guest_info = pc_guest_info_init(pcms->below_4g_mem_size,
|
||||||
|
pcms->above_4g_mem_size);
|
||||||
guest_info->isapc_ram_fw = false;
|
guest_info->isapc_ram_fw = false;
|
||||||
guest_info->has_acpi_build = has_acpi_build;
|
guest_info->has_acpi_build = has_acpi_build;
|
||||||
guest_info->has_reserved_memory = has_reserved_memory;
|
guest_info->has_reserved_memory = has_reserved_memory;
|
||||||
|
@ -171,7 +172,7 @@ static void pc_q35_init(MachineState *machine)
|
||||||
/* allocate ram and load rom/bios */
|
/* allocate ram and load rom/bios */
|
||||||
if (!xen_enabled()) {
|
if (!xen_enabled()) {
|
||||||
pc_memory_init(pcms, get_system_memory(),
|
pc_memory_init(pcms, get_system_memory(),
|
||||||
below_4g_mem_size, above_4g_mem_size,
|
pcms->below_4g_mem_size, pcms->above_4g_mem_size,
|
||||||
rom_memory, &ram_memory, guest_info);
|
rom_memory, &ram_memory, guest_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,8 +194,8 @@ static void pc_q35_init(MachineState *machine)
|
||||||
q35_host->mch.pci_address_space = pci_memory;
|
q35_host->mch.pci_address_space = pci_memory;
|
||||||
q35_host->mch.system_memory = get_system_memory();
|
q35_host->mch.system_memory = get_system_memory();
|
||||||
q35_host->mch.address_space_io = get_system_io();
|
q35_host->mch.address_space_io = get_system_io();
|
||||||
q35_host->mch.below_4g_mem_size = below_4g_mem_size;
|
q35_host->mch.below_4g_mem_size = pcms->below_4g_mem_size;
|
||||||
q35_host->mch.above_4g_mem_size = above_4g_mem_size;
|
q35_host->mch.above_4g_mem_size = pcms->above_4g_mem_size;
|
||||||
q35_host->mch.guest_info = guest_info;
|
q35_host->mch.guest_info = guest_info;
|
||||||
/* pci */
|
/* pci */
|
||||||
qdev_init_nofail(DEVICE(q35_host));
|
qdev_init_nofail(DEVICE(q35_host));
|
||||||
|
@ -277,7 +278,8 @@ static void pc_q35_init(MachineState *machine)
|
||||||
8, NULL, 0);
|
8, NULL, 0);
|
||||||
|
|
||||||
pc_cmos_init(pcms,
|
pc_cmos_init(pcms,
|
||||||
below_4g_mem_size, above_4g_mem_size, machine->boot_order,
|
pcms->below_4g_mem_size, pcms->above_4g_mem_size,
|
||||||
|
machine->boot_order,
|
||||||
idebus[0], idebus[1], rtc_state);
|
idebus[0], idebus[1], rtc_state);
|
||||||
|
|
||||||
/* the rest devices to which pci devfn is automatically assigned */
|
/* the rest devices to which pci devfn is automatically assigned */
|
||||||
|
|
|
@ -40,6 +40,7 @@ struct PCMachineState {
|
||||||
OnOffAuto vmport;
|
OnOffAuto vmport;
|
||||||
OnOffAuto smm;
|
OnOffAuto smm;
|
||||||
bool enforce_aligned_dimm;
|
bool enforce_aligned_dimm;
|
||||||
|
ram_addr_t below_4g_mem_size, above_4g_mem_size;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define PC_MACHINE_ACPI_DEVICE_PROP "acpi-device"
|
#define PC_MACHINE_ACPI_DEVICE_PROP "acpi-device"
|
||||||
|
|
Loading…
Reference in New Issue