[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [v2][PATCH 1/5] hw:i386:pc_piix: split pc_init1()
We'd like to split pc_init1 and then we can share something with other stuff. Signed-off-by: Tiejun Chen <tiejun.chen@xxxxxxxxx> --- hw/i386/pc_piix.c | 117 +++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 93 insertions(+), 24 deletions(-) v2: * Fix some coding style diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 9694f88..ab380d5 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -71,36 +71,29 @@ static bool smbios_legacy_mode; static bool gigabyte_align = true; static bool has_reserved_memory = true; -/* PC hardware initialisation */ -static void pc_init1(MachineState *machine, - int pci_enabled, - int kvmclock_enabled) +static ram_addr_t below_4g_mem_size; +static ram_addr_t above_4g_mem_size; +static void pc_machine_base_init(MachineState *machine, + int pci_enabled, + int kvmclock_enabled, + DeviceState **pc_icc_bridge, + MemoryRegion **pc_ram_memory, + MemoryRegion **pc_pci_memory, + qemu_irq **pc_gsi, + GSIState **pc_gsi_state, + FWCfgState **pc_fw_cfg) { PCMachineState *pc_machine = PC_MACHINE(machine); MemoryRegion *system_memory = get_system_memory(); - MemoryRegion *system_io = get_system_io(); - int i; - ram_addr_t below_4g_mem_size, above_4g_mem_size; - PCIBus *pci_bus; - ISABus *isa_bus; - PCII440FXState *i440fx_state; - int piix3_devfn = -1; - qemu_irq *cpu_irq; - qemu_irq *gsi; - qemu_irq *i8259; - qemu_irq *smi_irq; - GSIState *gsi_state; - DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; - BusState *idebus[MAX_IDE_BUS]; - ISADevice *rtc_state; - ISADevice *floppy; - MemoryRegion *ram_memory; - MemoryRegion *pci_memory; MemoryRegion *rom_memory; - DeviceState *icc_bridge; - FWCfgState *fw_cfg = NULL; PcGuestInfo *guest_info; ram_addr_t lowmem; + DeviceState *icc_bridge; + MemoryRegion *ram_memory; + MemoryRegion *pci_memory; + qemu_irq *gsi; + GSIState *gsi_state; + FWCfgState *fw_cfg; /* Check whether RAM fits below 4G (leaving 1/2 GByte for IO memory). * If it doesn't, we need to split it in chunks below and above 4G. @@ -193,6 +186,31 @@ static void pc_init1(MachineState *machine, gsi = qemu_allocate_irqs(gsi_handler, gsi_state, GSI_NUM_PINS); } + *pc_icc_bridge = icc_bridge; + *pc_ram_memory = ram_memory; + *pc_pci_memory = pci_memory; + *pc_gsi = gsi; + *pc_gsi_state = gsi_state; + *pc_fw_cfg = fw_cfg; +} + +static void pc_machine_pci_bus_init(MachineState *machine, + int pci_enabled, + PCII440FXState **pc_i440fx_state, + int *pc_piix3_devfn, + PCIBus **pc_pci_bus, + ISABus **pc_isa_bus, + qemu_irq *gsi, + MemoryRegion *pci_memory, + MemoryRegion *ram_memory) +{ + MemoryRegion *system_memory = get_system_memory(); + MemoryRegion *system_io = get_system_io(); + PCII440FXState *i440fx_state; + int piix3_devfn; + PCIBus *pci_bus; + ISABus *isa_bus; + if (pci_enabled) { pci_bus = i440fx_init(&i440fx_state, &piix3_devfn, &isa_bus, gsi, system_memory, system_io, machine->ram_size, @@ -205,6 +223,33 @@ static void pc_init1(MachineState *machine, isa_bus = isa_bus_new(NULL, system_io); no_hpet = 1; } + + *pc_i440fx_state = i440fx_state; + *pc_piix3_devfn = piix3_devfn; + *pc_pci_bus = pci_bus; + *pc_isa_bus = isa_bus; +} + +static void pc_machine_device_init(MachineState *machine, + int pci_enabled, + GSIState *gsi_state, + DeviceState *icc_bridge, + int piix3_devfn, + FWCfgState *fw_cfg, + PCIBus *pci_bus, + ISABus *isa_bus, + qemu_irq *gsi) +{ + int i; + DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; + BusState *idebus[MAX_IDE_BUS]; + qemu_irq *smi_irq; + PCMachineState *pc_machine = PC_MACHINE(machine); + qemu_irq *cpu_irq; + qemu_irq *i8259; + ISADevice *rtc_state; + ISADevice *floppy; + isa_bus_irqs(isa_bus, gsi); if (kvm_irqchip_in_kernel()) { @@ -292,6 +337,30 @@ static void pc_init1(MachineState *machine, } } +/* PC hardware initialisation */ +static void pc_init1(MachineState *machine, + int pci_enabled, + int kvmclock_enabled) +{ + PCIBus *pci_bus = NULL; + ISABus *isa_bus = NULL; + PCII440FXState *i440fx_state = NULL; + int piix3_devfn = -1; + qemu_irq *gsi = NULL; + GSIState *gsi_state = NULL; + MemoryRegion *ram_memory = NULL; + MemoryRegion *pci_memory = NULL; + DeviceState *icc_bridge = NULL; + FWCfgState *fw_cfg = NULL; + + pc_machine_base_init(machine, pci_enabled, kvmclock_enabled, &icc_bridge, + &ram_memory, &pci_memory, &gsi, &gsi_state, &fw_cfg); + pc_machine_pci_bus_init(machine, pci_enabled, &i440fx_state, &piix3_devfn, + &pci_bus, &isa_bus, gsi, pci_memory, ram_memory); + pc_machine_device_init(machine, pci_enabled, gsi_state, icc_bridge, + piix3_devfn, fw_cfg, pci_bus, isa_bus, gsi); +} + static void pc_init_pci(MachineState *machine) { pc_init1(machine, 1, 1); -- 1.9.1 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |