piix_pci: factor out pam, smram logic
PATCH 1/2 pc/piix_pci: factor out smram/pam logic
In reply to Isaku YamahataFactor out smram/pam logic for later use. Which will be used by q35 too.
Signed-off-by Isaku Yamahata <[email protected]>
--- Makefile.target | 2 +- hw/pam.c | 128 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ hw/pam.h | 96 +++++++++++++++++++++++++++++++++++++++++ hw/piix_pci.c | 71 +++++-------------------------- 4 files changed, 236 insertions(+), 61 deletions(-) create mode 100644 hw/pam.c create mode 100644 hw/pam.h
Makefile.target +1 -1
@@ -214,7 +214,7 @@ obj-$(CONFIG_KVM) += ivshmem.o # Hardware support obj-i386-y += vga.o obj-i386-y += mc146818rtc.o i8259.o pc.o -obj-i386-y += cirrus_vga.o apic.o ioapic.o piix_pci.o +obj-i386-y += cirrus_vga.o apic.o ioapic.o piix_pci.o pam.o obj-i386-y += vmport.o obj-i386-y += device-hotplug.o pci-hotplug.o smbios.o wdt_ib700.o obj-i386-y += debugcon.o multiboot.o
hw/pam.c new file +128 -0
128 lines not on this page · raw message
hw/pam.h new file +96 -0
96 lines not on this page · raw message
hw/piix_pci.c +11 -60
114 lines not on this page · raw message
Signature · 1 line
1.7.1.1
PATCH 2/2 pc, i440fx: simplify i440fx initialization
In reply to Isaku Yamahatasimplify i440fx initialization by eliminatingi440fx_init_memory_mappings().
Signed-off-by Isaku Yamahata <[email protected]>
--- hw/pc.h | 2 +- hw/pc_piix.c | 8 +------- hw/piix_pci.c | 15 ++++++--------- 3 files changed, 8 insertions(+), 17 deletions(-)
hw/pc.h +1 -1
@@ -175,7 +175,7 @@ int pcspk_audio_init(qemu_irq *pic);struct PCII440FXState ;typedef struct PCII440FXState PCII440FXState ; -PCIBus *i440fx_init (PCII440FXState **pi440fx_state,int *piix_devfn,qemu_irq *pic,ram_addr_t ram_size); +PCIBus *i440fx_init (int *piix_devfn,qemu_irq *pic,ram_addr_t ram_size);void i440fx_init_memory_mappings (PCII440FXState *d);/* piix4.c */
hw/pc_piix.c +1 -7
@@ -74,7 +74,6 @@ static void pc_init1(ram_addr_t ram_size,int i;ram_addr_t below_4g_mem_size, above_4g_mem_size;PCIBus *pci_bus; -PCII440FXState *i440fx_state;int piix3_devfn =-1 ;qemu_irq *cpu_irq;qemu_irq *isa_irq;
@@ -106,10 +105,9 @@ static void pc_init1(ram_addr_t ram_size, isa_irq =qemu_allocate_irqs (isa_irq_handler, isa_irq_state,24 );if (pci_enabled) { - pci_bus =i440fx_init (&i440fx_state, &piix3_devfn, isa_irq, ram_size); + pci_bus =i440fx_init (&piix3_devfn, isa_irq, ram_size); }else { pci_bus =NULL ; - i440fx_state =NULL ;isa_bus_new (NULL ); }isa_bus_irqs (isa_irq);
@@ -166,10 +164,6 @@ static void pc_init1(ram_addr_t ram_size,smbus_eeprom_init (smbus,8 ,NULL ,0 ); } -if (i440fx_state) { -i440fx_init_memory_mappings (i440fx_state); - } -if (pci_enabled) {pc_pci_device_init (pci_bus); }
hw/piix_pci.c +6 -9
@@ -84,11 +84,6 @@ static void i440fx_set_smm(int val, void *arg)smram_set_smm (&d->pam, val, d->dev.config[I440FX_SMRAM ]); } -void i440fx_init_memory_mappings (PCII440FXState *d) -{ -pam_init_memory_mappings (&d->pam); -} -static void i440fx_write_config (PCIDevice *dev,uint32_t address,uint32_t val,int len) {
@@ -164,15 +159,17 @@ static int i440fx_initfn(PCIDevice *dev) d->dev.config[I440FX_SMRAM ] =0x02 ;cpu_smm_register (&i440fx_set_smm, d); +pam_init_memory_mappings (&d->pam);return 0 ; } -PCIBus *i440fx_init (PCII440FXState **pi440fx_state,int *piix3_devfn,qemu_irq *pic,ram_addr_t ram_size) +PCIBus *i440fx_init (int *piix3_devfn,qemu_irq *pic,ram_addr_t ram_size) {DeviceState *dev;PCIBus *b;PCIDevice *d;I440FXState *s; +PCII440FXState *i440fx_state;PIIX3State *piix3; dev =qdev_create (NULL ,"i440FX-pcihost" );
@@ -182,20 +179,20 @@ PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix3_devfn, qemu_irq *qdev_init_nofail (dev); d =pci_create_simple (b,0 ,"i440FX" ); - *pi440fx_state =DO_UPCAST (PCII440FXState, dev, d); + i440fx_state =DO_UPCAST (PCII440FXState, dev, d); piix3 =DO_UPCAST (PIIX3State, dev,pci_create_simple_multifunction (b,-1 , true,"PIIX3" )); piix3->pic = pic;pci_bus_irqs (b, piix3_set_irq, pci_slot_get_pirq, piix3,4 ); - (*pi440fx_state)->piix3 = piix3; + i440fx_state->piix3 = piix3; *piix3_devfn = piix3->dev.devfn; ram_size = ram_size /8 /1024 /1024 ;if (ram_size >255 ) ram_size =255 ; - (*pi440fx_state)->dev.config[0x57 ]=ram_size; + i440fx_state->dev.config[0x57 ] = ram_size;return b; }
Signature · 1 line
1.7.1.1
cover piix_pci: factor out pam, smram logic
Factor out PC pam, smram logic. which will also be used for q35 later. All the magic numbers are replaced with symbolic constants at the same. As by product, pc_piix initalization is simplified a bit.
Isaku Yamahata (2):
pc/piix_pci: factor out smram/pam logic
pc, i440fx: simplify i440fx initialization
Makefile.target | 2 +- hw/pam.c | 128 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ hw/pam.h | 96 +++++++++++++++++++++++++++++++++++++++++ hw/pc.h | 2 +- hw/pc_piix.c | 8 +--- hw/piix_pci.c | 84 +++++++----------------------------- 6 files changed, 243 insertions(+), 77 deletions(-) create mode 100644 hw/pam.c create mode 100644 hw/pam.h