hw/ppc: Convert UIC device to QOM
v2 cover hw/ppc: Convert UIC device to QOM
This patchseries converts the PPC UIC "Universal Interrupt Controller" to a QOM device. My main reason for doing it is that this fixes a couple of long-standing trivial Coverity issues -- the current ppcuic_init() function allocates an array of qemu_irqs which the callers then leak. (The leak is trivial because it happens once when QEMU starts.)
The first half of v1 is in master now, so this is just a respin of the last four patches.
Changes v1->v2:
* fixed the bug in the sam460ex conversion handling of CINT (tested that this now boots AROS OK to a desktop)
* other minor code style tweaks to patch 1 as per review
thanks
-- PMM
Peter Maydell (4):
hw/ppc/sam460ex: Drop use of ppcuic_init()
hw/ppc: Delete unused ppc405cr_init() code
hw/ppc/ppc405_uc: Drop use of ppcuic_init()
hw/ppc: Remove unused ppcuic_init()
hw/ppc/ppc405.h | 8 +- include/hw/intc/ppc-uic.h | 7 + include/hw/ppc/ppc4xx.h | 9 - hw/ppc/ppc405_boards.c | 8 +- hw/ppc/ppc405_uc.c | 415 ++++---------------------------------- hw/ppc/ppc4xx_devs.c | 38 ---- hw/ppc/sam460ex.c | 69 +++++-- 7 files changed, 107 insertions(+), 447 deletions(-)
Signature · 1 line
2.20.1
PATCH v2 1/4 hw/ppc/sam460ex: Drop use of ppcuic_init()
Switch the sam460ex board to directly creating and configuring the UIC, rather than doing it via the old ppcuic_init() helper function.
---v1->v2 changes:
* fix typo in UIC 0 CINT wiring
* move local var declarations up
* drop unnecessary TODO comment
* improve comment about what the input_ints[] array is doing
--- hw/ppc/sam460ex.c | 69 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 53 insertions(+), 16 deletions(-)
hw/ppc/sam460ex.c +53 -16
@@ -39,6 +39,7 @@#include "hw/usb/hcd-ehci.h" #include "hw/ppc/fdt.h" #include "hw/qdev-properties.h" +#include "hw/intc/ppc-uic.h" #include <libfdt.h>
@@ -281,7 +282,9 @@ static void sam460ex_init(MachineState *machine)hwaddr ram_bases[SDRAM_NR_BANKS ] = {0 };hwaddr ram_sizes[SDRAM_NR_BANKS ] = {0 };MemoryRegion *l2cache_ram =g_new (MemoryRegion,1 ); -qemu_irq *irqs, *uic[4 ]; +DeviceState *uic[4 ]; +qemu_irq mal_irqs[4 ]; +int i;PCIBus *pci_bus;PowerPCCPU *cpu;CPUPPCState *env;
@@ -312,13 +315,38 @@ static void sam460ex_init(MachineState *machine)ppc4xx_plb_init (env);/* interrupt controllers */ - irqs =g_new0 (qemu_irq,PPCUIC_OUTPUT_NB ); - irqs[PPCUIC_OUTPUT_INT ] = ((qemu_irq *)env->irq_inputs)[PPC40x_INPUT_INT]; - irqs[PPCUIC_OUTPUT_CINT ] = ((qemu_irq *)env->irq_inputs)[PPC40x_INPUT_CINT]; - uic[0 ] =ppcuic_init (env, irqs,0xc0 ,0 ,1 ); - uic[1 ] =ppcuic_init (env, &uic[0 ][30 ],0xd0 ,0 ,1 ); - uic[2 ] =ppcuic_init (env, &uic[0 ][10 ],0xe0 ,0 ,1 ); - uic[3 ] =ppcuic_init (env, &uic[0 ][16 ],0xf0 ,0 ,1 ); +for (i =0 ; i <ARRAY_SIZE (uic); i++) { +SysBusDevice *sbd; +/* +* UICs 1, 2 and 3 are cascaded through UIC 0. +* input_ints[n] is the interrupt number on UIC 0 which +* the INT output of UIC n is connected to. The CINT output +* of UIC n connects to input_ints[n] + 1. +* The entry in input_ints[] for UIC 0 is ignored, because UIC 0's +* INT and CINT outputs are connected to the CPU. +*/ +const int input_ints[] = {-1 ,30 ,10 ,16 }; + + uic[i] =qdev_new (TYPE_PPC_UIC ); + sbd =SYS_BUS_DEVICE (uic[i]); + +qdev_prop_set_uint32 (uic[i],"dcr-base" ,0xc0 + i *0x10 ); +object_property_set_link (OBJECT (uic[i]),"cpu" ,OBJECT (cpu), + &error_fatal); +sysbus_realize_and_unref (sbd, &error_fatal); + +if (i ==0 ) { +sysbus_connect_irq (sbd,PPCUIC_OUTPUT_INT , + ((qemu_irq *)env->irq_inputs)[PPC40x_INPUT_INT]); +sysbus_connect_irq (sbd,PPCUIC_OUTPUT_CINT , + ((qemu_irq *)env->irq_inputs)[PPC40x_INPUT_CINT]); + }else { +sysbus_connect_irq (sbd,PPCUIC_OUTPUT_INT , +qdev_get_gpio_in (uic[0 ], input_ints[i])); +sysbus_connect_irq (sbd,PPCUIC_OUTPUT_CINT , +qdev_get_gpio_in (uic[0 ], input_ints[i] +1 )); + } + }/* SDRAM controller */ /* put all RAM on first bank because board has one slot
@@ -331,7 +359,8 @@ static void sam460ex_init(MachineState *machine) ram_bases, ram_sizes, 1);/* IIC controllers and devices */ - dev =sysbus_create_simple (TYPE_PPC4xx_I2C,0x4ef600700 , uic[0 ][2 ]); + dev =sysbus_create_simple (TYPE_PPC4xx_I2C,0x4ef600700 , +qdev_get_gpio_in (uic[0 ],2 )); i2c =PPC4xx_I2C (dev)->bus;/* SPD EEPROM on RAM module */ spd_data = spd_data_generate(ram_sizes[0] < 128 * MiB ? DDR : DDR2,
@@ -341,7 +370,8 @@ static void sam460ex_init(MachineState *machine)/* RTC */ i2c_slave_create_simple (i2c,"m41t80" ,0x68 ); - dev =sysbus_create_simple (TYPE_PPC4xx_I2C,0x4ef600800 , uic[0 ][3 ]); + dev =sysbus_create_simple (TYPE_PPC4xx_I2C,0x4ef600800 , +qdev_get_gpio_in (uic[0 ],3 ));/* External bus controller */ ppc405_ebc_init (env);
@@ -356,7 +386,10 @@ static void sam460ex_init(MachineState *machine)ppc4xx_sdr_init (env);/* MAL */ -ppc4xx_mal_init (env,4 ,16 , &uic[2 ][3 ]); +for (i =0 ; i <ARRAY_SIZE (mal_irqs); i++) { + mal_irqs[0 ] =qdev_get_gpio_in (uic[2 ],3 + i); + } +ppc4xx_mal_init (env,4 ,16 , mal_irqs);/* DMA */ ppc4xx_dma_init (env,0x200 );
@@ -369,21 +402,23 @@ static void sam460ex_init(MachineState *machine)memory_region_add_subregion (address_space_mem,0x400000000LL , l2cache_ram);/* USB */ -sysbus_create_simple (TYPE_PPC4xx_EHCI,0x4bffd0400 , uic[2 ][29 ]); +sysbus_create_simple (TYPE_PPC4xx_EHCI,0x4bffd0400 , +qdev_get_gpio_in (uic[2 ],29 )); dev =qdev_new ("sysbus-ohci" );qdev_prop_set_string (dev,"masterbus" ,"usb-bus.0" );qdev_prop_set_uint32 (dev,"num-ports" ,6 ); sbdev =SYS_BUS_DEVICE (dev);sysbus_realize_and_unref (sbdev, &error_fatal);sysbus_mmio_map (sbdev,0 ,0x4bffd0000 ); -sysbus_connect_irq (sbdev,0 , uic[2 ][30 ]); +sysbus_connect_irq (sbdev,0 ,qdev_get_gpio_in (uic[2 ],30 ));usb_create_simple (usb_bus_find (-1 ),"usb-kbd" );usb_create_simple (usb_bus_find (-1 ),"usb-mouse" );/* PCI bus */ ppc460ex_pcie_init (env);/* All PCI irqs are connected to the same UIC pin (cf. UBoot source) */ - dev =sysbus_create_simple ("ppc440-pcix-host" ,0xc0ec00000 , uic[1 ][0 ]); + dev =sysbus_create_simple ("ppc440-pcix-host" ,0xc0ec00000 , +qdev_get_gpio_in (uic[1 ],0 )); pci_bus = (PCIBus *)qdev_get_child_bus (dev,"pci.0" );if (!pci_bus) {error_report ("couldn't create PCI controller!" );
@@ -405,12 +440,14 @@ static void sam460ex_init(MachineState *machine)/* SoC has 4 UARTs * but board has only one wired and two are present in fdt */ if (serial_hd (0 ) !=NULL ) { -serial_mm_init (address_space_mem,0x4ef600300 ,0 , uic[1 ][1 ], +serial_mm_init (address_space_mem,0x4ef600300 ,0 , +qdev_get_gpio_in (uic[1 ],1 ),PPC_SERIAL_MM_BAUDBASE ,serial_hd (0 ),DEVICE_BIG_ENDIAN ); }if (serial_hd (1 ) !=NULL ) { -serial_mm_init (address_space_mem,0x4ef600400 ,0 , uic[0 ][1 ], +serial_mm_init (address_space_mem,0x4ef600400 ,0 , +qdev_get_gpio_in (uic[0 ],1 ),PPC_SERIAL_MM_BAUDBASE ,serial_hd (1 ),DEVICE_BIG_ENDIAN ); }
Signature · 1 line
2.20.1
Re: [PATCH v2 1/4] hw/ppc/sam460ex: Drop use of ppcuic_init()
Quoted 4 lines · Peter Maydell
Switch the sam460ex board to directly creating and configuring the UIC, rather than doing it via the old
ppcuic_init()helper function.Signed-off-by Peter Maydell <[email protected]>
Regards,
BALATON Zoltan
Quoted 156 lines
---
v1->v2changes:
* fix typo in UIC 0 CINT wiring
* move local var declarations up
* drop unnecessary TODO comment
* improve comment about what the input_ints[] array is doing
---hw/ppc/sam460ex.c| 69 ++++++++++++++++++++++++++++++++++++-----------1 file changed, 53 insertions(+), 16 deletions(-)hw/ppc/sam460ex.c +53
-16@@ -39,6 +39,7 @@#include "hw/usb/hcd-ehci.h" #include "hw/ppc/fdt.h" #include "hw/qdev-properties.h" +#include "hw/intc/ppc-uic.h" #include <libfdt.h> @@ -281,7 +282,9 @@ static void sam460ex_init(MachineState *machine)hwaddr ram_bases[SDRAM_NR_BANKS ] = {0 };hwaddr ram_sizes[SDRAM_NR_BANKS ] = {0 };MemoryRegion *l2cache_ram =g_new (MemoryRegion,1 ); -qemu_irq *irqs, *uic[4 ]; +DeviceState *uic[4 ]; +qemu_irq mal_irqs[4 ]; +int i;PCIBus *pci_bus;PowerPCCPU *cpu;CPUPPCState *env;@@ -312,13 +315,38 @@ static void sam460ex_init(MachineState *machine)ppc4xx_plb_init (env);/* interrupt controllers */ - irqs =g_new0 (qemu_irq,PPCUIC_OUTPUT_NB ); - irqs[PPCUIC_OUTPUT_INT ] = ((qemu_irq *)env->irq_inputs)[PPC40x_INPUT_INT]; - irqs[PPCUIC_OUTPUT_CINT ] = ((qemu_irq *)env->irq_inputs)[PPC40x_INPUT_CINT]; - uic[0 ] =ppcuic_init (env, irqs,0xc0 ,0 ,1 ); - uic[1 ] =ppcuic_init (env, &uic[0 ][30 ],0xd0 ,0 ,1 ); - uic[2 ] =ppcuic_init (env, &uic[0 ][10 ],0xe0 ,0 ,1 ); - uic[3 ] =ppcuic_init (env, &uic[0 ][16 ],0xf0 ,0 ,1 ); +for (i =0 ; i <ARRAY_SIZE (uic); i++) { +SysBusDevice *sbd; +/* +* UICs 1, 2 and 3 are cascaded through UIC 0. +* input_ints[n] is the interrupt number on UIC 0 which +* the INT output of UIC n is connected to. The CINT output +* of UIC n connects to input_ints[n] + 1. +* The entry in input_ints[] for UIC 0 is ignored, because UIC 0's +* INT and CINT outputs are connected to the CPU. +*/ +const int input_ints[] = {-1 ,30 ,10 ,16 }; + + uic[i] =qdev_new (TYPE_PPC_UIC ); + sbd =SYS_BUS_DEVICE (uic[i]); + +qdev_prop_set_uint32 (uic[i],"dcr-base" ,0xc0 + i *0x10 ); +object_property_set_link (OBJECT (uic[i]),"cpu" ,OBJECT (cpu), + &error_fatal); +sysbus_realize_and_unref (sbd, &error_fatal); + +if (i ==0 ) { +sysbus_connect_irq (sbd,PPCUIC_OUTPUT_INT , + ((qemu_irq *)env->irq_inputs)[PPC40x_INPUT_INT]); +sysbus_connect_irq (sbd,PPCUIC_OUTPUT_CINT , + ((qemu_irq *)env->irq_inputs)[PPC40x_INPUT_CINT]); + }else { +sysbus_connect_irq (sbd,PPCUIC_OUTPUT_INT , +qdev_get_gpio_in (uic[0 ], input_ints[i])); +sysbus_connect_irq (sbd,PPCUIC_OUTPUT_CINT , +qdev_get_gpio_in (uic[0 ], input_ints[i] +1 )); + } + }/* SDRAM controller */ /* put all RAM on first bank because board has one slot @@ -331,7 +359,8 @@ static void sam460ex_init(MachineState *machine) ram_bases, ram_sizes, 1);/* IIC controllers and devices */ - dev =sysbus_create_simple (TYPE_PPC4xx_I2C,0x4ef600700 , uic[0 ][2 ]); + dev =sysbus_create_simple (TYPE_PPC4xx_I2C,0x4ef600700 , +qdev_get_gpio_in (uic[0 ],2 )); i2c =PPC4xx_I2C (dev)->bus;/* SPD EEPROM on RAM module */ spd_data = spd_data_generate(ram_sizes[0] < 128 * MiB ? DDR : DDR2,@@ -341,7 +370,8 @@ static void sam460ex_init(MachineState *machine)/* RTC */ i2c_slave_create_simple (i2c,"m41t80" ,0x68 ); - dev =sysbus_create_simple (TYPE_PPC4xx_I2C,0x4ef600800 , uic[0 ][3 ]); + dev =sysbus_create_simple (TYPE_PPC4xx_I2C,0x4ef600800 , +qdev_get_gpio_in (uic[0 ],3 ));/* External bus controller */ ppc405_ebc_init (env);@@ -356,7 +386,10 @@ static void sam460ex_init(MachineState *machine)ppc4xx_sdr_init (env);/* MAL */ -ppc4xx_mal_init (env,4 ,16 , &uic[2 ][3 ]); +for (i =0 ; i <ARRAY_SIZE (mal_irqs); i++) { + mal_irqs[0 ] =qdev_get_gpio_in (uic[2 ],3 + i); + } +ppc4xx_mal_init (env,4 ,16 , mal_irqs);/* DMA */ ppc4xx_dma_init (env,0x200 );@@ -369,21 +402,23 @@ static void sam460ex_init(MachineState *machine)memory_region_add_subregion (address_space_mem,0x400000000LL , l2cache_ram);/* USB */ -sysbus_create_simple (TYPE_PPC4xx_EHCI,0x4bffd0400 , uic[2 ][29 ]); +sysbus_create_simple (TYPE_PPC4xx_EHCI,0x4bffd0400 , +qdev_get_gpio_in (uic[2 ],29 )); dev =qdev_new ("sysbus-ohci" );qdev_prop_set_string (dev,"masterbus" ,"usb-bus.0" );qdev_prop_set_uint32 (dev,"num-ports" ,6 ); sbdev =SYS_BUS_DEVICE (dev);sysbus_realize_and_unref (sbdev, &error_fatal);sysbus_mmio_map (sbdev,0 ,0x4bffd0000 ); -sysbus_connect_irq (sbdev,0 , uic[2 ][30 ]); +sysbus_connect_irq (sbdev,0 ,qdev_get_gpio_in (uic[2 ],30 ));usb_create_simple (usb_bus_find (-1 ),"usb-kbd" );usb_create_simple (usb_bus_find (-1 ),"usb-mouse" );/* PCI bus */ ppc460ex_pcie_init (env);/* All PCI irqs are connected to the same UIC pin (cf. UBoot source) */ - dev =sysbus_create_simple ("ppc440-pcix-host" ,0xc0ec00000 , uic[1 ][0 ]); + dev =sysbus_create_simple ("ppc440-pcix-host" ,0xc0ec00000 , +qdev_get_gpio_in (uic[1 ],0 )); pci_bus = (PCIBus *)qdev_get_child_bus (dev,"pci.0" );if (!pci_bus) {error_report ("couldn't create PCI controller!" );@@ -405,12 +440,14 @@ static void sam460ex_init(MachineState *machine)/* SoC has 4 UARTs * but board has only one wired and two are present in fdt */ if (serial_hd (0 ) !=NULL ) { -serial_mm_init (address_space_mem,0x4ef600300 ,0 , uic[1 ][1 ], +serial_mm_init (address_space_mem,0x4ef600300 ,0 , +qdev_get_gpio_in (uic[1 ],1 ),PPC_SERIAL_MM_BAUDBASE ,serial_hd (0 ),DEVICE_BIG_ENDIAN ); }if (serial_hd (1 ) !=NULL ) { -serial_mm_init (address_space_mem,0x4ef600400 ,0 , uic[0 ][1 ], +serial_mm_init (address_space_mem,0x4ef600400 ,0 , +qdev_get_gpio_in (uic[0 ],1 ),PPC_SERIAL_MM_BAUDBASE ,serial_hd (1 ),DEVICE_BIG_ENDIAN ); }
PATCH v2 2/4 hw/ppc: Delete unused ppc405cr_init() code
In reply to Peter MaydellThe function ppc405cr_init() has apparently been unused since it was added in commit 8ecc7913525ecb in 2007.
Remove this dead code, so we don't have to convert it away from using ppcuic_init().
--- hw/ppc/ppc405.h | 6 - hw/ppc/ppc405_uc.c | 345 --------------------------------------------- 2 files changed, 351 deletions(-)
hw/ppc/ppc405.h +0 -6
@@ -62,12 +62,6 @@ ram_addr_t ppc405_set_bootinfo (CPUPPCState *env, ppc4xx_bd_info_t *bd,void ppc4xx_plb_init (CPUPPCState *env);void ppc405_ebc_init (CPUPPCState *env); -CPUPPCState *ppc405cr_init (MemoryRegion *address_space_mem, -MemoryRegion ram_memories[4 ], -hwaddr ram_bases[4 ], -hwaddr ram_sizes[4 ], -uint32_t sysclk,qemu_irq **picp, -int do_init); CPUPPCState *ppc405ep_init(MemoryRegion *address_space_mem, MemoryRegion ram_memories[2], hwaddr ram_bases[2],
hw/ppc/ppc405_uc.c +0 -345
351 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH v2 3/4 hw/ppc/ppc405_uc: Drop use of ppcuic_init()
In reply to Peter MaydellSwitch the ppc405_uc boards to directly creating and configuring the UIC, rather than doing it via the old ppcuic_init() helper function.
We retain the API feature of ppc405ep_init() where it passes back something allowing the callers to wire up devices to the UIC if they need to, even though neither of the callsites currently makes use of this ability -- instead of passing back the qemu_irq array we pass back the UIC DeviceState.
This fixes a trivial Coverity-detected memory leak where we were leaking the array of IRQs returned by ppcuic_init().
--- hw/ppc/ppc405.h | 2 +- hw/ppc/ppc405_boards.c | 8 ++--- hw/ppc/ppc405_uc.c | 70 +++++++++++++++++++++++++----------------- 3 files changed, 47 insertions(+), 33 deletions(-)
hw/ppc/ppc405.h +1 -1
@@ -66,7 +66,7 @@ CPUPPCState *ppc405ep_init(MemoryRegion *address_space_mem,MemoryRegion ram_memories[2 ], hwaddr ram_bases[2], hwaddr ram_sizes[2], - uint32_t sysclk, qemu_irq **picp, + uint32_t sysclk, DeviceState **uicdev, int do_init);#endif /* PPC405_H */
hw/ppc/ppc405_boards.c +4 -4
@@ -151,7 +151,6 @@ static void ref405ep_init(MachineState *machine)CPUPPCState *env;DeviceState *dev;SysBusDevice *s; -qemu_irq *pic;MemoryRegion *bios;MemoryRegion *sram =g_new (MemoryRegion,1 );ram_addr_t bdloc;
@@ -167,6 +166,7 @@ static void ref405ep_init(MachineState *machine)int len;DriveInfo *dinfo;MemoryRegion *sysmem =get_system_memory (); +DeviceState *uicdev;if (machine->ram_size != mc->default_ram_size) {char *sz =size_to_str (mc->default_ram_size);
@@ -184,7 +184,7 @@ static void ref405ep_init(MachineState *machine) ram_bases[1 ] =0x00000000 ; ram_sizes[1 ] =0x00000000 ; env =ppc405ep_init (sysmem, ram_memories, ram_bases, ram_sizes, -33333333 , &pic, kernel_filename ==NULL ?0 :1 ); +33333333 , &uicdev, kernel_filename ==NULL ?0 :1 );/* allocate SRAM */ sram_size =512 * KiB; memory_region_init_ram(sram, NULL, "ef405ep.sram", sram_size,
@@ -429,7 +429,6 @@ static void taihu_405ep_init(MachineState *machine)const char *kernel_filename = machine->kernel_filename;const char *initrd_filename = machine->initrd_filename;char *filename; -qemu_irq *pic;MemoryRegion *sysmem =get_system_memory ();MemoryRegion *bios;MemoryRegion *ram_memories =g_new (MemoryRegion,2 );
@@ -440,6 +439,7 @@ static void taihu_405ep_init(MachineState *machine)int linux_boot;int fl_idx;DriveInfo *dinfo; +DeviceState *uicdev;if (machine->ram_size != mc->default_ram_size) {char *sz =size_to_str (mc->default_ram_size);
@@ -459,7 +459,7 @@ static void taihu_405ep_init(MachineState *machine)"taihu_405ep.ram-1" , machine->ram, ram_bases[1 ], ram_sizes[1]);ppc405ep_init (sysmem, ram_memories, ram_bases, ram_sizes, -33333333 , &pic, kernel_filename ==NULL ?0 :1 ); +33333333 , &uicdev, kernel_filename ==NULL ?0 :1 );/* allocate and load BIOS */ fl_idx =0 ;#if defined(USE_FLASH_BIOS )
hw/ppc/ppc405_uc.c +42 -28
121 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH v2 4/4 hw/ppc: Remove unused ppcuic_init()
In reply to Peter MaydellNow we've converted all the callsites to directly create the QOM UIC device themselves, the ppcuic_init() function is unused and can be removed. The enum defining PPCUIC symbolic constants can be moved to the ppc-uic.h header where it more naturally belongs.
--- include/hw/intc/ppc-uic.h | 7 +++++++ include/hw/ppc/ppc4xx.h | 9 --------- hw/ppc/ppc4xx_devs.c | 38 -------------------------------------- 3 files changed, 7 insertions(+), 47 deletions(-)
include/hw/intc/ppc-uic.h +7 -0
@@ -47,6 +47,13 @@ OBJECT_DECLARE_SIMPLE_TYPE(PPCUIC, PPC_UIC)#define UIC_MAX_IRQ 32 +/* Symbolic constants for the sysbus IRQ outputs */ +enum { +PPCUIC_OUTPUT_INT =0 , +PPCUIC_OUTPUT_CINT =1 , +PPCUIC_OUTPUT_NB , +}; +struct PPCUIC {/*< private >*/ SysBusDevice parent_obj;
include/hw/ppc/ppc4xx.h +0 -9
@@ -33,15 +33,6 @@ PowerPCCPU *ppc4xx_init(const char *cpu_model, clk_setup_t *cpu_clk, clk_setup_t *tb_clk, uint32_t sysclk); -/* PowerPC 4xx universal interrupt controller */ -enum { -PPCUIC_OUTPUT_INT =0 , -PPCUIC_OUTPUT_CINT =1 , -PPCUIC_OUTPUT_NB , -}; -qemu_irq *ppcuic_init (CPUPPCState *env,qemu_irq *irqs, -uint32_t dcr_base,int has_ssr,int has_vr); - void ppc4xx_sdram_banks(MemoryRegion *ram, int nr_banks, MemoryRegion ram_memories[], hwaddr ram_bases[], hwaddr ram_sizes[],
hw/ppc/ppc4xx_devs.c +0 -38
@@ -77,44 +77,6 @@ PowerPCCPU *ppc4xx_init(const char *cpu_type,return cpu; } -/*****************************************************************************/ -/* "Universal" Interrupt controller */ - -qemu_irq *ppcuic_init (CPUPPCState *env,qemu_irq *irqs, -uint32_t dcr_base,int has_ssr,int has_vr) -{ -DeviceState *uicdev =qdev_new (TYPE_PPC_UIC ); -SysBusDevice *uicsbd =SYS_BUS_DEVICE (uicdev); -qemu_irq *uic_irqs; -int i; - -qdev_prop_set_uint32 (uicdev,"dcr-base" , dcr_base); -qdev_prop_set_bit (uicdev,"use-vectors" , has_vr); -object_property_set_link (OBJECT (uicdev),"cpu" ,OBJECT (env_cpu (env)), - &error_fatal); -sysbus_realize_and_unref (uicsbd, &error_fatal); - -sysbus_connect_irq (uicsbd,PPCUIC_OUTPUT_INT , irqs[PPCUIC_OUTPUT_INT ]); -sysbus_connect_irq (uicsbd,PPCUIC_OUTPUT_CINT , irqs[PPCUIC_OUTPUT_CINT ]); - -/* -* Return an allocated array of the UIC's input IRQ lines. -* This is an ugly temporary API to retain compatibility with -* the ppcuic_init() interface from the pre-QOM-conversion UIC. -* None of the callers free this array, so it is leaked -- but -* so was the array allocated by qemu_allocate_irqs() in the -* old code. -* -* The callers should just instantiate the UIC and wire it up -* themselves rather than passing qemu_irq* in and out of this function. -*/ - uic_irqs =g_new0 (qemu_irq,UIC_MAX_IRQ ); -for (i =0 ; i <UIC_MAX_IRQ ; i++) { - uic_irqs[i] =qdev_get_gpio_in (uicdev, i); - } -return uic_irqs; -} -/*****************************************************************************/ /* SDRAM controller */ typedef struct ppc4xx_sdram_t ppc4xx_sdram_t ;
Signature · 1 line
2.20.1
David Gibson
AppliedQuoted 7 lines · Peter Maydell
This patchseries converts the PPC UIC "Universal Interrupt Controller" to a QOM device. My main reason for doing it is that this fixes a couple of long-standing trivial Coverity issues -- the current
ppcuic_init()function allocates an array ofqemu_irqswhich the callers then leak. (The leak is trivial because it happens once when QEMU starts.)
Quoted 7 lines
The first half of v1 is in master now, so this is just a respin of the last four patches.
Changes
v1->v2:
* fixed the bug in the sam460ex conversion handling of CINT (tested that this now boots AROS OK to a desktop)
* other minor code style tweaks to patch 1 as per review
Applied to ppc-for-6.0, thanks.
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson