ppc: QOM'ify 405 board
v4 cover ppc: QOM'ify 405 board
Hello,
Here is large series QOM'ifying the PPC405 board. It introduces a new generic machine and SoC models, converts the current device models to QOM and populates the SoC. The process is quite mechanical without too much issues to handle. The noisy part is the initial patch introducing the SoC realize routine.
Thanks,
C.
Changes in v4 :
- Attempt to QOM'ify SDRAM controller, with 2 initialized banks at the SoC level
- Report errors to the user for invalid RAM config
- Moved CPU reset in PPC405 model
- user_creatable comments
- Renamed FPGA device model
- Various small cleanups
Changes in v3 :
- New device model Ppc4xxDcrDeviceState
- Removal of ppc4xx_mal_init(), ppc4xx_plb_init() and ppc405_ebc_init()
- Fixes for some reset issues
- Kept 2 RAM banks at the Soc level but only one is initialized.
- Moved SRAM under the machine. It's not part of the SoC according to the 405 specs
Changes in v2 :
- docs/about/removed-features.rst update
- Fix compile breakage (uic)
- Fix CPU reset, which breaking u-boot boot
- Changed prefix of memory regions to "ppc405"
- Reduced the number of RAM banks to 1. Second was a dummy one to please ppc405ep_init()
Cédric Le Goater (24):
ppc/ppc405: Remove taihu machine
ppc/ppc405: Introduce a PPC405 generic machine ppc/ppc405: Move devices under the ref405ep machine ppc/ppc405: Move SRAM under the ref405ep machine ppc/ppc405: Introduce a PPC405 SoC ppc/ppc405: Start QOMification of the SoC ppc/ppc405: QOM'ify CPU
ppc/ppc4xx: Introduce a DCR device model ppc/ppc405: QOM'ify CPC
ppc/ppc405: QOM'ify GPT
ppc/ppc405: QOM'ify OCM
ppc/ppc405: QOM'ify GPIO
ppc/ppc405: QOM'ify DMA
ppc/ppc405: QOM'ify EBC
ppc/ppc405: QOM'ify OPBA
ppc/ppc405: QOM'ify POB
ppc/ppc405: QOM'ify PLB
ppc/ppc405: QOM'ify MAL
ppc/ppc405: QOM'ify FPGA
ppc/ppc405: Use an embedded PPCUIC model in SoC state ppc/ppc405: Use an explicit I2C object ppc/ppc4xx: Fix sdram trace events ppc/ppc405: QOM'ify SDRAM
ppc/ppc405: Add check on minimum RAM size
docs/about/deprecated.rst | 9 - docs/about/removed-features.rst | 6 + docs/system/ppc/embedded.rst | 1 - hw/ppc/ppc405.h | 196 +++++++- include/hw/ppc/ppc4xx.h | 82 ++- hw/ppc/ppc405_boards.c | 381 ++++---------- hw/ppc/ppc405_uc.c | 859 +++++++++++++++++--------------- hw/ppc/ppc4xx_devs.c | 326 +++++++----- hw/ppc/sam460ex.c | 24 +- MAINTAINERS | 2 +- hw/ppc/trace-events | 3 - 11 files changed, 1042 insertions(+), 847 deletions(-)
Signature · 1 line
2.37.1
PATCH v4 1/24 ppc/ppc405: Remove taihu machine
It has been deprecated since 7.0.
--- docs/about/deprecated.rst | 9 -- docs/about/removed-features.rst | 6 + docs/system/ppc/embedded.rst | 1 - hw/ppc/ppc405_boards.c | 232 -------------------------------- MAINTAINERS | 2 +- 5 files changed, 7 insertions(+), 243 deletions(-)
docs/about/deprecated.rst +0 -9
@@ -233,15 +233,6 @@ deprecated; use the new name ``dtb-randomness`` instead. The new name better reflects the way this property affects all random data within the device tree blob, not just the ``kaslr-seed`` node. -PPC 405 ``taihu`` machine (since 7.0) -''''''''''''''''''''''''''''''''''''' - -The PPC 405 CPU is a system-on-a-chip, so all 405 machines are very similar, -except for some external periphery. However, the periphery of the ``taihu`` -machine is hardly emulated at all (e.g. neither the LCD nor the USB part had -been implemented), so there is not much value added by this board. Use the -``ref405ep`` machine instead. - ``pc-i440fx-1.4`` up to ``pc-i440fx-1.7`` (since 7.0) '''''''''''''''''''''''''''''''''''''''''''''''''''''
docs/about/removed-features.rst +6 -0
@@ -668,6 +668,12 @@ Aspeed ``swift-bmc`` machine (removed in 7.0) This machine was removed because it was unused. Alternative AST2500 based OpenPOWER machines are ``witherspoon-bmc`` and ``romulus-bmc``. +ppc ``taihu`` machine (removed in 7.2) +''''''''''''''''''''''''''''''''''''''''''''' + +This machine was removed because it was partially emulated and 405 +machines are very similar. Use the ``ref405ep`` machine instead. + linux-user mode CPUs --------------------
docs/system/ppc/embedded.rst +0 -1
@@ -6,5 +6,4 @@ Embedded family boards - ``ppce500`` generic paravirt e500 platform - ``ref405ep`` ref405ep - ``sam460ex`` aCube Sam460ex -- ``taihu`` taihu - ``virtex-ml507`` Xilinx Virtex ML507 reference design
hw/ppc/ppc405_boards.c +0 -232
241 lines not on this page · raw message
MAINTAINERS +1 -1
@@ -1282,7 +1282,7 @@ F: hw/openrisc/openrisc_sim.c PowerPC Machines ---------------- -405 (ref405ep and taihu) +405 (ref405ep) L: [email protected] S: Orphan F: hw/ppc/ppc405_boards.c
Signature · 1 line
2.37.1
PATCH v4 2/24 ppc/ppc405: Introduce a PPC405 generic machine
In reply to Cédric Le GoaterWe will use this machine as a base to define the ref405ep and possibly the PPC405 hotfoot board as found in the Linux kernel.
--- hw/ppc/ppc405_boards.c | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-)
hw/ppc/ppc405_boards.c +28 -3
@@ -50,6 +50,15 @@#define USE_FLASH_BIOS +#define TYPE_PPC405_MACHINE MACHINE_TYPE_NAME("ppc405") +OBJECT_DECLARE_SIMPLE_TYPE (Ppc405MachineState,PPC405_MACHINE ); + +struct Ppc405MachineState { +/* Private */ +MachineState parent_obj; +/* Public */ +}; +/*****************************************************************************/ /* PPC405EP reference board (IBM) */ /* Standalone board with:
@@ -332,18 +341,34 @@ static void ref405ep_class_init(ObjectClass *oc, void *data) mc->desc ="ref405ep" ; mc->init = ref405ep_init; - mc->default_ram_size =0x08000000 ; - mc->default_ram_id ="ef405ep.ram" ; }static const TypeInfo ref405ep_type = { .name =MACHINE_TYPE_NAME ("ref405ep" ), - .parent =TYPE_MACHINE , + .parent =TYPE_PPC405_MACHINE , .class_init = ref405ep_class_init, }; +static void ppc405_machine_class_init (ObjectClass *oc,void *data) +{ +MachineClass *mc =MACHINE_CLASS (oc); + + mc->desc ="PPC405 generic machine" ; + mc->default_ram_size =128 * MiB; + mc->default_ram_id ="ppc405.ram" ; +} + +static const TypeInfo ppc405_machine_type = { + .name =TYPE_PPC405_MACHINE , + .parent =TYPE_MACHINE , + .instance_size =sizeof (Ppc405MachineState), + .class_init = ppc405_machine_class_init, + .abstract = true, +}; +static void ppc405_machine_init (void ) { +type_register_static (&ppc405_machine_type);type_register_static (&ref405ep_type); }
Signature · 1 line
2.37.1
PATCH v4 3/24 ppc/ppc405: Move devices under the ref405ep machine
In reply to Cédric Le Goater--- hw/ppc/ppc405_boards.c | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-)
hw/ppc/ppc405_boards.c +19 -12
@@ -230,13 +230,11 @@ static void boot_from_kernel(MachineState *machine, PowerPCCPU *cpu) env->load_info = &boot_info; } -static void ref405ep_init (MachineState *machine) +static void ppc405_init (MachineState *machine) {MachineClass *mc =MACHINE_GET_CLASS (machine);const char *kernel_filename = machine->kernel_filename;PowerPCCPU *cpu; -DeviceState *dev; -SysBusDevice *s;MemoryRegion *sram =g_new (MemoryRegion,1 );MemoryRegion *ram_memories =g_new (MemoryRegion,2 );hwaddr ram_bases[2 ], ram_sizes[2 ];
@@ -294,15 +292,6 @@ static void ref405ep_init(MachineState *machine)memory_region_add_subregion (sysmem, (uint32_t )(-bios_size), bios); } -/* Register FPGA */ -ref405ep_fpga_init (sysmem,PPC405EP_FPGA_BASE ); -/* Register NVRAM */ - dev =qdev_new ("sysbus-m48t08" ); -qdev_prop_set_int32 (dev,"base-year" ,1968 ); - s =SYS_BUS_DEVICE (dev); -sysbus_realize_and_unref (s, &error_fatal); -sysbus_mmio_map (s,0 ,PPC405EP_NVRAM_BASE ); -/* Load kernel and initrd using U-Boot images */ if (kernel_filename && machine->firmware) {target_ulong kernel_base, initrd_base;
@@ -335,6 +324,23 @@ static void ref405ep_init(MachineState *machine) } } +static void ref405ep_init (MachineState *machine) +{ +DeviceState *dev; +SysBusDevice *s; + +ppc405_init (machine); + +/* Register FPGA */ +ref405ep_fpga_init (get_system_memory (),PPC405EP_FPGA_BASE ); +/* Register NVRAM */ + dev =qdev_new ("sysbus-m48t08" ); +qdev_prop_set_int32 (dev,"base-year" ,1968 ); + s =SYS_BUS_DEVICE (dev); +sysbus_realize_and_unref (s, &error_fatal); +sysbus_mmio_map (s,0 ,PPC405EP_NVRAM_BASE ); +} +static void ref405ep_class_init (ObjectClass *oc,void *data) {MachineClass *mc =MACHINE_CLASS (oc);
@@ -354,6 +360,7 @@ static void ppc405_machine_class_init(ObjectClass *oc, void *data)MachineClass *mc =MACHINE_CLASS (oc); mc->desc ="PPC405 generic machine" ; + mc->init = ppc405_init; mc->default_ram_size =128 * MiB; mc->default_ram_id ="ppc405.ram" ; }
Signature · 1 line
2.37.1
PATCH v4 4/24 ppc/ppc405: Move SRAM under the ref405ep machine
In reply to Cédric Le GoaterIt doesn't belong to the generic machine nor the SoC. Fix a typo in the name while we are at it.
--- hw/ppc/ppc405_boards.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
hw/ppc/ppc405_boards.c +6 -6
@@ -235,7 +235,6 @@ static void ppc405_init(MachineState *machine)MachineClass *mc =MACHINE_GET_CLASS (machine);const char *kernel_filename = machine->kernel_filename;PowerPCCPU *cpu; -MemoryRegion *sram =g_new (MemoryRegion,1 );MemoryRegion *ram_memories =g_new (MemoryRegion,2 );hwaddr ram_bases[2 ], ram_sizes[2 ];MemoryRegion *sysmem =get_system_memory ();
@@ -260,11 +259,6 @@ static void ppc405_init(MachineState *machine) cpu =ppc405ep_init (sysmem, ram_memories, ram_bases, ram_sizes,33333333 , &uicdev, kernel_filename ==NULL ?0 :1 ); -/* allocate SRAM */ -memory_region_init_ram (sram,NULL ,"ef405ep.sram" ,PPC405EP_SRAM_SIZE , - &error_fatal); -memory_region_add_subregion (sysmem,PPC405EP_SRAM_BASE , sram); -/* allocate and load BIOS */ if (machine->firmware) {MemoryRegion *bios =g_new (MemoryRegion,1 );
@@ -328,9 +322,15 @@ static void ref405ep_init(MachineState *machine) {DeviceState *dev;SysBusDevice *s; +MemoryRegion *sram =g_new (MemoryRegion,1 );ppc405_init (machine); +/* allocate SRAM */ +memory_region_init_ram (sram,NULL ,"ref405ep.sram" ,PPC405EP_SRAM_SIZE , + &error_fatal); +memory_region_add_subregion (get_system_memory (),PPC405EP_SRAM_BASE , sram); +/* Register FPGA */ ref405ep_fpga_init (get_system_memory (),PPC405EP_FPGA_BASE );/* Register NVRAM */
Signature · 1 line
2.37.1
Re: [PATCH v4 04/24] ppc/ppc405: Move SRAM under the ref405ep machine
Quoted 21 lines · Cédric Le Goater
It doesn't belong to the generic machine nor the SoC. Fix a typo in the name while we are at it.
Signed-off-by Cédric Le Goater <[email protected]>---
hw/ppc/ppc405_boards.c| 12 ++++++------1 file changed, 6 insertions(+), 6 deletions(-)hw/ppc/ppc405_boards.c +0
-1@@ -235,7 +235,6 @@ static void ppc405_init(MachineState *machine)MachineClass *mc =MACHINE_GET_CLASS (machine);const char *kernel_filename = machine->kernel_filename;PowerPCCPU *cpu; -MemoryRegion *sram =g_new (MemoryRegion,1 );MemoryRegion *ram_memories =g_new (MemoryRegion,2 );hwaddr ram_bases[2 ], ram_sizes[2 ];MemoryRegion *sysmem =get_system_memory ();
hw/ppc/ppc405_boards.c static void ppc405_init(MachineState *machine) · line 265
Quoted 6 lines
hw/ppc/ppc405_boards.c +0
-3@@ -260,11 +259,6 @@ static void ppc405_init(MachineState *machine) cpu =ppc405ep_init (sysmem, ram_memories, ram_bases, ram_sizes,33333333 , &uicdev, kernel_filename ==NULL ?0 :1 ); -/* allocate SRAM */ -memory_region_init_ram (sram,NULL ,"ef405ep.sram" ,PPC405EP_SRAM_SIZE , - &error_fatal);
Do you need to set an owner while at it? Anyway,
Regards,
BALATON Zoltan
Quoted 22 lines
hw/ppc/ppc405_boards.c +6
-2-memory_region_add_subregion (sysmem,PPC405EP_SRAM_BASE , sram); -/* allocate and load BIOS */ if (machine->firmware) {MemoryRegion *bios =g_new (MemoryRegion,1 );@@ -328,9 +322,15 @@ static void ref405ep_init(MachineState *machine) {DeviceState *dev;SysBusDevice *s; +MemoryRegion *sram =g_new (MemoryRegion,1 );ppc405_init (machine); +/* allocate SRAM */ +memory_region_init_ram (sram,NULL ,"ref405ep.sram" ,PPC405EP_SRAM_SIZE , + &error_fatal); +memory_region_add_subregion (get_system_memory (),PPC405EP_SRAM_BASE , sram); +/* Register FPGA */ ref405ep_fpga_init (get_system_memory (),PPC405EP_FPGA_BASE );/* Register NVRAM */
Re: [PATCH v4 04/24] ppc/ppc405: Move SRAM under the ref405ep machine
Quoted 25 lines · BALATON Zoltan
Quoted 24 lines · Cédric Le Goater
It doesn't belong to the generic machine nor the SoC. Fix a typo in the name while we are at it.
Signed-off-by Cédric Le Goater <[email protected]>---
hw/ppc/ppc405_boards.c| 12 ++++++------1 file changed, 6 insertions(+), 6 deletions(-)hw/ppc/ppc405_boards.c +0
-1@@ -235,7 +235,6 @@ static void ppc405_init(MachineState *machine) MachineClass *mc = MACHINE_GET_CLASS(machine); const char *kernel_filename = machine->kernel_filename; PowerPCCPU *cpu; - MemoryRegion *sram = g_new(MemoryRegion, 1); MemoryRegion *ram_memories = g_new(MemoryRegion, 2); hwaddr ram_bases[2], ram_sizes[2]; MemoryRegion *sysmem = get_system_memory();@@ -260,11 +259,6 @@ static void ppc405_init(MachineState *machine) cpu = ppc405ep_init(sysmem, ram_memories, ram_bases, ram_sizes, 33333333, &uicdev, kernel_filename == NULL ? 0 : 1);
Quoted 5 lines
hw/ppc/ppc405_boards.c static void ppc405_init(MachineState *machine) · line 265
Quoted 3 lines
hw/ppc/ppc405_boards.c +0
-3- /* allocate SRAM */ - memory_region_init_ram(sram, NULL, "ef405ep.sram", PPC405EP_SRAM_SIZE, - &error_fatal);Do you need to set an owner while at it? Anyway,
A machine is not a device and :
/* This will assert if owner is neither NULL nor a DeviceState.
* We only want the owner here for the purposes of defining a
* unique name for migration. TODO: Ideally we should implement
* a naming scheme for Objects which are not DeviceStates, in
* which case we can relax this restriction.
*/
owner_dev = DEVICE(owner);
Thanks,
C.
Quoted 28 lines
Reviewed-by BALATON Zoltan <[email protected]>Regards,
BALATON ZoltanQuoted 22 lines
hw/ppc/ppc405_boards.c +6
-2- memory_region_add_subregion(sysmem, PPC405EP_SRAM_BASE, sram); - /* allocate and load BIOS */ if (machine->firmware) { MemoryRegion *bios = g_new(MemoryRegion, 1);@@ -328,9 +322,15 @@ static void ref405ep_init(MachineState *machine) { DeviceState *dev; SysBusDevice *s; + MemoryRegion *sram = g_new(MemoryRegion, 1); ppc405_init(machine); + /* allocate SRAM */ + memory_region_init_ram(sram, NULL, "ref405ep.sram", PPC405EP_SRAM_SIZE, + &error_fatal); + memory_region_add_subregion(get_system_memory(), PPC405EP_SRAM_BASE, sram); + /* Register FPGA */ ref405ep_fpga_init(get_system_memory(), PPC405EP_FPGA_BASE); /* Register NVRAM */
PATCH v4 5/24 ppc/ppc405: Introduce a PPC405 SoC
In reply to Cédric Le GoaterIt is an initial model to start QOMification of the PPC405 board. QOM'ified devices will be reintroduced one by one. Start with the memory regions, which name prefix is changed to "ppc405".
Also, initialize only one RAM bank. The second bank is a dummy one (zero size) which is here to match the hard coded number of banks in ppc405ep_init().
--- hw/ppc/ppc405.h | 16 ++++++++++++++++ hw/ppc/ppc405_boards.c | 23 ++++++++++++----------- hw/ppc/ppc405_uc.c | 40 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+), 11 deletions(-)
hw/ppc/ppc405.h +16 -0
@@ -25,6 +25,7 @@#ifndef PPC405_H #define PPC405_H +#include "qom/object.h" #include "hw/ppc/ppc4xx.h" #define PPC405EP_SDRAM_BASE 0x00000000
@@ -62,6 +63,21 @@ struct ppc4xx_bd_info_t {uint32_t bi_iic_fast[2 ]; }; +#define TYPE_PPC405_SOC "ppc405-soc" +OBJECT_DECLARE_SIMPLE_TYPE (Ppc405SoCState,PPC405_SOC ); + +struct Ppc405SoCState { +/* Private */ +DeviceState parent_obj; + +/* Public */ +MemoryRegion ram_banks[2 ]; +hwaddr ram_bases[2 ], ram_sizes[2 ]; + +MemoryRegion *dram_mr; +hwaddr ram_size; +}; +/* PowerPC 405 core */ ram_addr_t ppc405_set_bootinfo (CPUPPCState *env,ram_addr_t ram_size);
hw/ppc/ppc405_boards.c +12 -11
@@ -57,6 +57,8 @@ struct Ppc405MachineState {/* Private */ MachineState parent_obj;/* Public */ + +Ppc405SoCState soc; };/*****************************************************************************/
@@ -232,11 +234,10 @@ static void boot_from_kernel(MachineState *machine, PowerPCCPU *cpu)static void ppc405_init (MachineState *machine) { +Ppc405MachineState *ppc405 =PPC405_MACHINE (machine);MachineClass *mc =MACHINE_GET_CLASS (machine);const char *kernel_filename = machine->kernel_filename;PowerPCCPU *cpu; -MemoryRegion *ram_memories =g_new (MemoryRegion,2 ); -hwaddr ram_bases[2 ], ram_sizes[2 ];MemoryRegion *sysmem =get_system_memory ();DeviceState *uicdev;
@@ -247,16 +248,16 @@ static void ppc405_init(MachineState *machine)exit (EXIT_FAILURE ); } -/* XXX: fix this */ -memory_region_init_alias (&ram_memories[0 ],NULL ,"ef405ep.ram.alias" , - machine->ram,0 , machine->ram_size); - ram_bases[0 ] =0 ; - ram_sizes[0 ] = machine->ram_size; -memory_region_init (&ram_memories[1 ],NULL ,"ef405ep.ram1" ,0 ); - ram_bases[1 ] =0x00000000 ; - ram_sizes[1 ] =0x00000000 ; +object_initialize_child (OBJECT (machine),"soc" , &ppc405->soc, +TYPE_PPC405_SOC ); +object_property_set_uint (OBJECT (&ppc405->soc),"ram-size" , + machine->ram_size, &error_fatal); +object_property_set_link (OBJECT (&ppc405->soc),"dram" , +OBJECT (machine->ram), &error_abort); +qdev_realize (DEVICE (&ppc405->soc),NULL , &error_fatal); - cpu =ppc405ep_init (sysmem, ram_memories, ram_bases, ram_sizes, + cpu =ppc405ep_init (sysmem, ppc405->soc.ram_banks, ppc405->soc.ram_bases, + ppc405->soc.ram_sizes,33333333 , &uicdev, kernel_filename ==NULL ?0 :1 );/* allocate and load BIOS */
hw/ppc/ppc405_uc.c +40 -0
@@ -30,6 +30,7 @@#include "hw/ppc/ppc.h" #include "hw/i2c/ppc4xx_i2c.h" #include "hw/irq.h" +#include "hw/qdev-properties.h" #include "ppc405.h" #include "hw/char/serial.h" #include "qemu/timer.h"
@@ -1530,3 +1531,42 @@ PowerPCCPU *ppc405ep_init(MemoryRegion *address_space_mem,return cpu; } + +static void ppc405_soc_realize (DeviceState *dev,Error **errp) +{ +Ppc405SoCState *s =PPC405_SOC (dev); + +/* Initialize only one bank */ + s->ram_bases[0 ] =0 ; + s->ram_sizes[0 ] = s->ram_size; +memory_region_init_alias (&s->ram_banks[0 ],OBJECT (s), +"ppc405.sdram0" , s->dram_mr, + s->ram_bases[0 ], s->ram_sizes[0 ]); +} + +static Property ppc405_soc_properties[] = { +DEFINE_PROP_LINK ("dram" , Ppc405SoCState, dram_mr,TYPE_MEMORY_REGION , + MemoryRegion *), +DEFINE_PROP_UINT64 ("ram-size" , Ppc405SoCState, ram_size,0 ), +DEFINE_PROP_END_OF_LIST (), +}; + +static void ppc405_soc_class_init (ObjectClass *oc,void *data) +{ +DeviceClass *dc =DEVICE_CLASS (oc); + + dc->realize = ppc405_soc_realize; + dc->user_creatable = false; +device_class_set_props (dc, ppc405_soc_properties); +} + +static const TypeInfo ppc405_types[] = { + { + .name =TYPE_PPC405_SOC , + .parent =TYPE_DEVICE , + .instance_size =sizeof (Ppc405SoCState), + .class_init = ppc405_soc_class_init, + } +}; + +DEFINE_TYPES (ppc405_types)
Signature · 1 line
2.37.1
Re: [PATCH v4 05/24] ppc/ppc405: Introduce a PPC405 SoC
Quoted 10 lines · Cédric Le Goater
It is an initial model to start QOMification of the PPC405 board. QOM'ified devices will be reintroduced one by one. Start with the memory regions, which name prefix is changed to "ppc405".
Also, initialize only one RAM bank. The second bank is a dummy one (zero size) which is here to match the hard coded number of banks in
ppc405ep_init().Reviewed-by Daniel Henrique Barboza <[email protected]>Signed-off-by Cédric Le Goater <[email protected]>
Quoted 148 lines
---
hw/ppc/ppc405.h | 16 ++++++++++++++++ hw/ppc/ppc405_boards.c | 23 ++++++++++++----------- hw/ppc/ppc405_uc.c | 40 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+), 11 deletions(-)hw/ppc/ppc405.h +16
-0@@ -25,6 +25,7 @@#ifndef PPC405_H #define PPC405_H +#include "qom/object.h" #include "hw/ppc/ppc4xx.h" #define PPC405EP_SDRAM_BASE 0x00000000@@ -62,6 +63,21 @@ struct ppc4xx_bd_info_t {uint32_t bi_iic_fast[2 ]; }; +#define TYPE_PPC405_SOC "ppc405-soc" +OBJECT_DECLARE_SIMPLE_TYPE (Ppc405SoCState,PPC405_SOC ); + +struct Ppc405SoCState { +/* Private */ +DeviceState parent_obj; + +/* Public */ +MemoryRegion ram_banks[2 ]; +hwaddr ram_bases[2 ], ram_sizes[2 ]; + +MemoryRegion *dram_mr; +hwaddr ram_size; +}; +/* PowerPC 405 core */ ram_addr_t ppc405_set_bootinfo (CPUPPCState *env,ram_addr_t ram_size);hw/ppc/ppc405_boards.c +12
-11@@ -57,6 +57,8 @@ struct Ppc405MachineState {/* Private */ MachineState parent_obj;/* Public */ + +Ppc405SoCState soc; };/*****************************************************************************/ @@ -232,11 +234,10 @@ static void boot_from_kernel(MachineState *machine, PowerPCCPU *cpu)static void ppc405_init (MachineState *machine) { +Ppc405MachineState *ppc405 =PPC405_MACHINE (machine);MachineClass *mc =MACHINE_GET_CLASS (machine);const char *kernel_filename = machine->kernel_filename;PowerPCCPU *cpu; -MemoryRegion *ram_memories =g_new (MemoryRegion,2 ); -hwaddr ram_bases[2 ], ram_sizes[2 ];MemoryRegion *sysmem =get_system_memory ();DeviceState *uicdev;@@ -247,16 +248,16 @@ static void ppc405_init(MachineState *machine)exit (EXIT_FAILURE ); } -/* XXX: fix this */ -memory_region_init_alias (&ram_memories[0 ],NULL ,"ef405ep.ram.alias" , - machine->ram,0 , machine->ram_size); - ram_bases[0 ] =0 ; - ram_sizes[0 ] = machine->ram_size; -memory_region_init (&ram_memories[1 ],NULL ,"ef405ep.ram1" ,0 ); - ram_bases[1 ] =0x00000000 ; - ram_sizes[1 ] =0x00000000 ; +object_initialize_child (OBJECT (machine),"soc" , &ppc405->soc, +TYPE_PPC405_SOC ); +object_property_set_uint (OBJECT (&ppc405->soc),"ram-size" , + machine->ram_size, &error_fatal); +object_property_set_link (OBJECT (&ppc405->soc),"dram" , +OBJECT (machine->ram), &error_abort); +qdev_realize (DEVICE (&ppc405->soc),NULL , &error_fatal); - cpu =ppc405ep_init (sysmem, ram_memories, ram_bases, ram_sizes, + cpu =ppc405ep_init (sysmem, ppc405->soc.ram_banks, ppc405->soc.ram_bases, + ppc405->soc.ram_sizes,33333333 , &uicdev, kernel_filename ==NULL ?0 :1 );/* allocate and load BIOS */ hw/ppc/ppc405_uc.c +40
-0@@ -30,6 +30,7 @@#include "hw/ppc/ppc.h" #include "hw/i2c/ppc4xx_i2c.h" #include "hw/irq.h" +#include "hw/qdev-properties.h" #include "ppc405.h" #include "hw/char/serial.h" #include "qemu/timer.h" @@ -1530,3 +1531,42 @@ PowerPCCPU *ppc405ep_init(MemoryRegion *address_space_mem,return cpu; } + +static void ppc405_soc_realize (DeviceState *dev,Error **errp) +{ +Ppc405SoCState *s =PPC405_SOC (dev); + +/* Initialize only one bank */ + s->ram_bases[0 ] =0 ; + s->ram_sizes[0 ] = s->ram_size; +memory_region_init_alias (&s->ram_banks[0 ],OBJECT (s), +"ppc405.sdram0" , s->dram_mr, + s->ram_bases[0 ], s->ram_sizes[0 ]); +} + +static Property ppc405_soc_properties[] = { +DEFINE_PROP_LINK ("dram" , Ppc405SoCState, dram_mr,TYPE_MEMORY_REGION , + MemoryRegion *), +DEFINE_PROP_UINT64 ("ram-size" , Ppc405SoCState, ram_size,0 ), +DEFINE_PROP_END_OF_LIST (), +}; + +static void ppc405_soc_class_init (ObjectClass *oc,void *data) +{ +DeviceClass *dc =DEVICE_CLASS (oc); + + dc->realize = ppc405_soc_realize; + dc->user_creatable = false; +device_class_set_props (dc, ppc405_soc_properties); +} + +static const TypeInfo ppc405_types[] = { + { + .name =TYPE_PPC405_SOC , + .parent =TYPE_DEVICE , + .instance_size =sizeof (Ppc405SoCState), + .class_init = ppc405_soc_class_init, + } +}; + +DEFINE_TYPES (ppc405_types)
PATCH v4 6/24 ppc/ppc405: Start QOMification of the SoC
In reply to Cédric Le GoaterThis moves all the code previously done in the ppc405ep_init() routine under ppc405_soc_realize(). We can also adjust the number of banks now that we have control on ppc4xx_sdram_init().
--- hw/ppc/ppc405.h | 12 ++-- hw/ppc/ppc405_boards.c | 12 ++-- hw/ppc/ppc405_uc.c | 124 ++++++++++++++++++++--------------------- 3 files changed, 71 insertions(+), 77 deletions(-)
hw/ppc/ppc405.h +5 -7
@@ -73,9 +73,14 @@ struct Ppc405SoCState {/* Public */ MemoryRegion ram_banks[2 ];hwaddr ram_bases[2 ], ram_sizes[2 ]; +bool do_dram_init;MemoryRegion *dram_mr;hwaddr ram_size; + +uint32_t sysclk; +PowerPCCPU *cpu; +DeviceState *uic; };/* PowerPC 405 core */
@@ -84,11 +89,4 @@ ram_addr_t ppc405_set_bootinfo(CPUPPCState *env, ram_addr_t ram_size);void ppc4xx_plb_init (CPUPPCState *env);void ppc405_ebc_init (CPUPPCState *env); -PowerPCCPU *ppc405ep_init (MemoryRegion *address_space_mem, -MemoryRegion ram_memories[2 ], -hwaddr ram_bases[2 ], -hwaddr ram_sizes[2 ], -uint32_t sysclk,DeviceState **uicdev, -int do_init); -#endif /* PPC405_H */
hw/ppc/ppc405_boards.c +5 -7
@@ -237,9 +237,7 @@ static void ppc405_init(MachineState *machine)Ppc405MachineState *ppc405 =PPC405_MACHINE (machine);MachineClass *mc =MACHINE_GET_CLASS (machine);const char *kernel_filename = machine->kernel_filename; -PowerPCCPU *cpu;MemoryRegion *sysmem =get_system_memory (); -DeviceState *uicdev;if (machine->ram_size != mc->default_ram_size) {char *sz =size_to_str (mc->default_ram_size);
@@ -254,12 +252,12 @@ static void ppc405_init(MachineState *machine) machine->ram_size, &error_fatal);object_property_set_link (OBJECT (&ppc405->soc),"dram" ,OBJECT (machine->ram), &error_abort); +object_property_set_bool (OBJECT (&ppc405->soc),"dram-init" , + kernel_filename !=NULL , &error_abort); +object_property_set_uint (OBJECT (&ppc405->soc),"sys-clk" ,33333333 , + &error_abort);qdev_realize (DEVICE (&ppc405->soc),NULL , &error_fatal); - cpu =ppc405ep_init (sysmem, ppc405->soc.ram_banks, ppc405->soc.ram_bases, - ppc405->soc.ram_sizes, -33333333 , &uicdev, kernel_filename ==NULL ?0 :1 ); -/* allocate and load BIOS */ if (machine->firmware) {MemoryRegion *bios =g_new (MemoryRegion,1 );
@@ -315,7 +313,7 @@ static void ppc405_init(MachineState *machine)/* Load ELF kernel and rootfs.cpio */ }else if (kernel_filename && !machine->firmware) { -boot_from_kernel (machine, cpu); +boot_from_kernel (machine, ppc405->soc.cpu); } }
hw/ppc/ppc405_uc.c +61 -63
188 lines not on this page · raw message
Signature · 1 line
2.37.1
Re: [PATCH v4 06/24] ppc/ppc405: Start QOMification of the SoC
Quoted 5 lines · Cédric Le Goater
This moves all the code previously done in the
ppc405ep_init()routine underppc405_soc_realize(). We can also adjust the number of banks now that we have control onppc4xx_sdram_init().Signed-off-by Cédric Le Goater <[email protected]>
Quoted 272 lines
---
hw/ppc/ppc405.h | 12 ++-- hw/ppc/ppc405_boards.c | 12 ++-- hw/ppc/ppc405_uc.c | 124 ++++++++++++++++++++--------------------- 3 files changed, 71 insertions(+), 77 deletions(-)hw/ppc/ppc405.h +5
-7@@ -73,9 +73,14 @@ struct Ppc405SoCState {/* Public */ MemoryRegion ram_banks[2 ];hwaddr ram_bases[2 ], ram_sizes[2 ]; +bool do_dram_init;MemoryRegion *dram_mr;hwaddr ram_size; + +uint32_t sysclk; +PowerPCCPU *cpu; +DeviceState *uic; };/* PowerPC 405 core */ @@ -84,11 +89,4 @@ ram_addr_t ppc405_set_bootinfo(CPUPPCState *env, ram_addr_t ram_size);void ppc4xx_plb_init (CPUPPCState *env);void ppc405_ebc_init (CPUPPCState *env); -PowerPCCPU *ppc405ep_init (MemoryRegion *address_space_mem, -MemoryRegion ram_memories[2 ], -hwaddr ram_bases[2 ], -hwaddr ram_sizes[2 ], -uint32_t sysclk,DeviceState **uicdev, -int do_init); -#endif /* PPC405_H */ hw/ppc/ppc405_boards.c +5
-7@@ -237,9 +237,7 @@ static void ppc405_init(MachineState *machine)Ppc405MachineState *ppc405 =PPC405_MACHINE (machine);MachineClass *mc =MACHINE_GET_CLASS (machine);const char *kernel_filename = machine->kernel_filename; -PowerPCCPU *cpu;MemoryRegion *sysmem =get_system_memory (); -DeviceState *uicdev;if (machine->ram_size != mc->default_ram_size) {char *sz =size_to_str (mc->default_ram_size);@@ -254,12 +252,12 @@ static void ppc405_init(MachineState *machine) machine->ram_size, &error_fatal);object_property_set_link (OBJECT (&ppc405->soc),"dram" ,OBJECT (machine->ram), &error_abort); +object_property_set_bool (OBJECT (&ppc405->soc),"dram-init" , + kernel_filename !=NULL , &error_abort); +object_property_set_uint (OBJECT (&ppc405->soc),"sys-clk" ,33333333 , + &error_abort);qdev_realize (DEVICE (&ppc405->soc),NULL , &error_fatal); - cpu =ppc405ep_init (sysmem, ppc405->soc.ram_banks, ppc405->soc.ram_bases, - ppc405->soc.ram_sizes, -33333333 , &uicdev, kernel_filename ==NULL ?0 :1 ); -/* allocate and load BIOS */ if (machine->firmware) {MemoryRegion *bios =g_new (MemoryRegion,1 );@@ -315,7 +313,7 @@ static void ppc405_init(MachineState *machine)/* Load ELF kernel and rootfs.cpio */ }else if (kernel_filename && !machine->firmware) { -boot_from_kernel (machine, cpu); +boot_from_kernel (machine, ppc405->soc.cpu); } }hw/ppc/ppc405_uc.c +61
-63@@ -1432,121 +1432,118 @@ static void ppc405ep_cpc_init (CPUPPCState *env, clk_setup_t clk_setup[8],#endif } -PowerPCCPU *ppc405ep_init (MemoryRegion *address_space_mem, -MemoryRegion ram_memories[2 ], -hwaddr ram_bases[2 ], -hwaddr ram_sizes[2 ], -uint32_t sysclk,DeviceState **uicdevp, -int do_init) +static void ppc405_soc_realize (DeviceState *dev,Error **errp) { +Ppc405SoCState *s =PPC405_SOC (dev);clk_setup_t clk_setup[PPC405EP_CLK_NB ], tlb_clk_setup;qemu_irq dma_irqs[4 ], gpt_irqs[5 ], mal_irqs[4 ]; -PowerPCCPU *cpu;CPUPPCState *env; -DeviceState *uicdev; -SysBusDevice *uicsbd;memset (clk_setup,0 ,sizeof (clk_setup)); +/* init CPUs */ - cpu =ppc4xx_init (POWERPC_CPU_TYPE_NAME ("405ep" ), + s->cpu =ppc4xx_init (POWERPC_CPU_TYPE_NAME ("405ep" ), &clk_setup[PPC405EP_CPU_CLK ], - &tlb_clk_setup, sysclk); - env = &cpu->env; + &tlb_clk_setup, s->sysclk); + env = &s->cpu->env; clk_setup[PPC405EP_CPU_CLK ].cb = tlb_clk_setup.cb; clk_setup[PPC405EP_CPU_CLK ].opaque = tlb_clk_setup.opaque; -/* Internal devices init */ -/* Memory mapped devices registers */ + +/* CPU control */ +ppc405ep_cpc_init (env, clk_setup, s->sysclk); +/* PLB arbitrer */ ppc4xx_plb_init (env); +/* PLB to OPB bridge */ ppc4xx_pob_init (env); +/* OBP arbitrer */ ppc4xx_opba_init (0xef600600 ); +/* Universal interrupt controller */ - uicdev =qdev_new (TYPE_PPC_UIC ); - uicsbd =SYS_BUS_DEVICE (uicdev); + s->uic =qdev_new (TYPE_PPC_UIC ); -object_property_set_link (OBJECT (uicdev),"cpu" ,OBJECT (cpu), +object_property_set_link (OBJECT (s->uic),"cpu" ,OBJECT (s->cpu), &error_fatal); -sysbus_realize_and_unref (uicsbd, &error_fatal); - -sysbus_connect_irq (uicsbd,PPCUIC_OUTPUT_INT , -qdev_get_gpio_in (DEVICE (cpu), PPC40x_INPUT_INT)); -sysbus_connect_irq (uicsbd,PPCUIC_OUTPUT_CINT , -qdev_get_gpio_in (DEVICE (cpu), PPC40x_INPUT_CINT)); +if (!sysbus_realize (SYS_BUS_DEVICE (s->uic), errp)) { +return ; + } - *uicdevp = uicdev; +sysbus_connect_irq (SYS_BUS_DEVICE (s->uic),PPCUIC_OUTPUT_INT , +qdev_get_gpio_in (DEVICE (s->cpu), PPC40x_INPUT_INT)); +sysbus_connect_irq (SYS_BUS_DEVICE (s->uic),PPCUIC_OUTPUT_CINT , +qdev_get_gpio_in (DEVICE (s->cpu), PPC40x_INPUT_CINT));/* SDRAM controller */ /* XXX 405EP has no ECC interrupt */ -ppc4xx_sdram_init (env,qdev_get_gpio_in (uicdev,17 ),2 , ram_memories, - ram_bases, ram_sizes, do_init); + s->ram_bases[0 ] =0 ; + s->ram_sizes[0 ] = s->ram_size; +memory_region_init_alias (&s->ram_banks[0 ],OBJECT (s), +"ppc405.sdram0" , s->dram_mr, + s->ram_bases[0 ], s->ram_sizes[0 ]); + +ppc4xx_sdram_init (env,qdev_get_gpio_in (s->uic,17 ),1 , + s->ram_banks, s->ram_bases, s->ram_sizes, + s->do_dram_init); +/* External bus controller */ ppc405_ebc_init (env); +/* DMA controller */ - dma_irqs[0 ] =qdev_get_gpio_in (uicdev,5 ); - dma_irqs[1 ] =qdev_get_gpio_in (uicdev,6 ); - dma_irqs[2 ] =qdev_get_gpio_in (uicdev,7 ); - dma_irqs[3 ] =qdev_get_gpio_in (uicdev,8 ); + dma_irqs[0 ] =qdev_get_gpio_in (s->uic,5 ); + dma_irqs[1 ] =qdev_get_gpio_in (s->uic,6 ); + dma_irqs[2 ] =qdev_get_gpio_in (s->uic,7 ); + dma_irqs[3 ] =qdev_get_gpio_in (s->uic,8 );ppc405_dma_init (env, dma_irqs); -/* IIC controller */ + +/* I2C controller */ sysbus_create_simple (TYPE_PPC4xx_I2C,0xef600500 , -qdev_get_gpio_in (uicdev,2 )); +qdev_get_gpio_in (s->uic,2 ));/* GPIO */ ppc405_gpio_init (0xef600700 ); +/* Serial ports */ if (serial_hd (0 ) !=NULL ) { -serial_mm_init (address_space_mem,0xef600300 ,0 , -qdev_get_gpio_in (uicdev,0 ), +serial_mm_init (get_system_memory (),0xef600300 ,0 , +qdev_get_gpio_in (s->uic,0 ),PPC_SERIAL_MM_BAUDBASE ,serial_hd (0 ),DEVICE_BIG_ENDIAN ); }if (serial_hd (1 ) !=NULL ) { -serial_mm_init (address_space_mem,0xef600400 ,0 , -qdev_get_gpio_in (uicdev,1 ), +serial_mm_init (get_system_memory (),0xef600400 ,0 , +qdev_get_gpio_in (s->uic,1 ),PPC_SERIAL_MM_BAUDBASE ,serial_hd (1 ),DEVICE_BIG_ENDIAN ); } +/* OCM */ ppc405_ocm_init (env); +/* GPT */ - gpt_irqs[0 ] =qdev_get_gpio_in (uicdev,19 ); - gpt_irqs[1 ] =qdev_get_gpio_in (uicdev,20 ); - gpt_irqs[2 ] =qdev_get_gpio_in (uicdev,21 ); - gpt_irqs[3 ] =qdev_get_gpio_in (uicdev,22 ); - gpt_irqs[4 ] =qdev_get_gpio_in (uicdev,23 ); + gpt_irqs[0 ] =qdev_get_gpio_in (s->uic,19 ); + gpt_irqs[1 ] =qdev_get_gpio_in (s->uic,20 ); + gpt_irqs[2 ] =qdev_get_gpio_in (s->uic,21 ); + gpt_irqs[3 ] =qdev_get_gpio_in (s->uic,22 ); + gpt_irqs[4 ] =qdev_get_gpio_in (s->uic,23 );ppc4xx_gpt_init (0xef600000 , gpt_irqs); -/* PCI */ -/* Uses UIC IRQs 3, 16, 18 */ +/* MAL */ - mal_irqs[0 ] =qdev_get_gpio_in (uicdev,11 ); - mal_irqs[1 ] =qdev_get_gpio_in (uicdev,12 ); - mal_irqs[2 ] =qdev_get_gpio_in (uicdev,13 ); - mal_irqs[3 ] =qdev_get_gpio_in (uicdev,14 ); + mal_irqs[0 ] =qdev_get_gpio_in (s->uic,11 ); + mal_irqs[1 ] =qdev_get_gpio_in (s->uic,12 ); + mal_irqs[2 ] =qdev_get_gpio_in (s->uic,13 ); + mal_irqs[3 ] =qdev_get_gpio_in (s->uic,14 );ppc4xx_mal_init (env,4 ,2 , mal_irqs); +/* Ethernet */ /* Uses UIC IRQs 9, 15, 17 */ -/* CPU control */ -ppc405ep_cpc_init (env, clk_setup, sysclk); - -return cpu; -} - -static void ppc405_soc_realize (DeviceState *dev,Error **errp) -{ -Ppc405SoCState *s =PPC405_SOC (dev); - -/* Initialize only one bank */ - s->ram_bases[0 ] =0 ; - s->ram_sizes[0 ] = s->ram_size; -memory_region_init_alias (&s->ram_banks[0 ],OBJECT (s), -"ppc405.sdram0" , s->dram_mr, - s->ram_bases[0 ], s->ram_sizes[0 ]); }static Property ppc405_soc_properties[] = {DEFINE_PROP_LINK ("dram" , Ppc405SoCState, dram_mr,TYPE_MEMORY_REGION , MemoryRegion *), +DEFINE_PROP_UINT32 ("sys-clk" , Ppc405SoCState, sysclk,0 ), +DEFINE_PROP_BOOL ("dram-init" , Ppc405SoCState, do_dram_init,0 ),DEFINE_PROP_UINT64 ("ram-size" , Ppc405SoCState, ram_size,0 ),DEFINE_PROP_END_OF_LIST (), };@@ -1556,6 +1553,7 @@ static void ppc405_soc_class_init(ObjectClass *oc, void *data)DeviceClass *dc =DEVICE_CLASS (oc); dc->realize = ppc405_soc_realize; +/* Reason: only works as part of a ppc405 board/machine */ dc->user_creatable = false;device_class_set_props (dc, ppc405_soc_properties); }
PATCH v4 7/24 ppc/ppc405: QOM'ify CPU
In reply to Cédric Le GoaterDrop the use of ppc4xx_init() and duplicate a bit of code related to clocks in the SoC realize routine. We will clean that up in the following patches.
ppc_dcr_init() simply allocates default DCR handlers for the CPU. Maybe this could be done in model initializer of the CPU families needing it.
--- hw/ppc/ppc405.h | 2 +- include/hw/ppc/ppc4xx.h | 5 ----- hw/ppc/ppc405_boards.c | 2 +- hw/ppc/ppc405_uc.c | 40 ++++++++++++++++++++++++++++++---------- hw/ppc/ppc4xx_devs.c | 32 -------------------------------- 5 files changed, 32 insertions(+), 49 deletions(-)
hw/ppc/ppc405.h +1 -1
@@ -79,7 +79,7 @@ struct Ppc405SoCState {hwaddr ram_size;uint32_t sysclk; -PowerPCCPU *cpu; +PowerPCCPU cpu;DeviceState *uic; };
include/hw/ppc/ppc4xx.h +0 -5
@@ -28,11 +28,6 @@#include "hw/ppc/ppc.h" #include "exec/memory.h" -/* PowerPC 4xx core initialization */ -PowerPCCPU *ppc4xx_init (const char *cpu_model, -clk_setup_t *cpu_clk,clk_setup_t *tb_clk, -uint32_t sysclk); - void ppc4xx_sdram_banks(MemoryRegion *ram, int nr_banks, MemoryRegion ram_memories[], hwaddr ram_bases[], hwaddr ram_sizes[],
hw/ppc/ppc405_boards.c +1 -1
@@ -313,7 +313,7 @@ static void ppc405_init(MachineState *machine)/* Load ELF kernel and rootfs.cpio */ }else if (kernel_filename && !machine->firmware) { -boot_from_kernel (machine, ppc405->soc.cpu); +boot_from_kernel (machine, &ppc405->soc.cpu); } }
hw/ppc/ppc405_uc.c +30 -10
@@ -1432,22 +1432,41 @@ static void ppc405ep_cpc_init (CPUPPCState *env, clk_setup_t clk_setup[8],#endif } +static void ppc405_soc_instance_init (Object *obj) +{ +Ppc405SoCState *s =PPC405_SOC (obj); + +object_initialize_child (obj,"cpu" , &s->cpu, +POWERPC_CPU_TYPE_NAME ("405ep" )); +} + +static void ppc405_reset (void *opaque) +{ +cpu_reset (CPU (opaque)); +} +static void ppc405_soc_realize (DeviceState *dev,Error **errp) {Ppc405SoCState *s =PPC405_SOC (dev); -clk_setup_t clk_setup[PPC405EP_CLK_NB ], tlb_clk_setup; +clk_setup_t clk_setup[PPC405EP_CLK_NB ];qemu_irq dma_irqs[4 ], gpt_irqs[5 ], mal_irqs[4 ];CPUPPCState *env;memset (clk_setup,0 ,sizeof (clk_setup));/* init CPUs */ - s->cpu =ppc4xx_init (POWERPC_CPU_TYPE_NAME ("405ep" ), - &clk_setup[PPC405EP_CPU_CLK ], - &tlb_clk_setup, s->sysclk); - env = &s->cpu->env; - clk_setup[PPC405EP_CPU_CLK ].cb = tlb_clk_setup.cb; - clk_setup[PPC405EP_CPU_CLK ].opaque = tlb_clk_setup.opaque; +if (!qdev_realize (DEVICE (&s->cpu),NULL , errp)) { +return ; + } +qemu_register_reset (ppc405_reset, &s->cpu); + + env = &s->cpu.env; + + clk_setup[PPC405EP_CPU_CLK ].cb = +ppc_40x_timers_init (env, s->sysclk,PPC_INTERRUPT_PIT ); + clk_setup[PPC405EP_CPU_CLK ].opaque = env; + +ppc_dcr_init (env,NULL ,NULL );/* CPU control */ ppc405ep_cpc_init (env, clk_setup, s->sysclk);
@@ -1464,16 +1483,16 @@ static void ppc405_soc_realize(DeviceState *dev, Error **errp)/* Universal interrupt controller */ s->uic =qdev_new (TYPE_PPC_UIC ); -object_property_set_link (OBJECT (s->uic),"cpu" ,OBJECT (s->cpu), +object_property_set_link (OBJECT (s->uic),"cpu" ,OBJECT (&s->cpu), &error_fatal);if (!sysbus_realize (SYS_BUS_DEVICE (s->uic), errp)) {return ; }sysbus_connect_irq (SYS_BUS_DEVICE (s->uic),PPCUIC_OUTPUT_INT , -qdev_get_gpio_in (DEVICE (s->cpu), PPC40x_INPUT_INT)); +qdev_get_gpio_in (DEVICE (&s->cpu), PPC40x_INPUT_INT));sysbus_connect_irq (SYS_BUS_DEVICE (s->uic),PPCUIC_OUTPUT_CINT , -qdev_get_gpio_in (DEVICE (s->cpu), PPC40x_INPUT_CINT)); +qdev_get_gpio_in (DEVICE (&s->cpu), PPC40x_INPUT_CINT));/* SDRAM controller */ /* XXX 405EP has no ECC interrupt */
@@ -1563,6 +1582,7 @@ static const TypeInfo ppc405_types[] = { .name = TYPE_PPC405_SOC, .parent = TYPE_DEVICE, .instance_size = sizeof(Ppc405SoCState), + .instance_init = ppc405_soc_instance_init, .class_init = ppc405_soc_class_init, } };
hw/ppc/ppc4xx_devs.c +0 -32
@@ -37,38 +37,6 @@#include "qapi/error.h" #include "trace.h" -static void ppc4xx_reset (void *opaque) -{ -PowerPCCPU *cpu = opaque; - -cpu_reset (CPU (cpu)); -} - -/*****************************************************************************/ -/* Generic PowerPC 4xx processor instantiation */ -PowerPCCPU *ppc4xx_init (const char *cpu_type, -clk_setup_t *cpu_clk,clk_setup_t *tb_clk, -uint32_t sysclk) -{ -PowerPCCPU *cpu; -CPUPPCState *env; - -/* init CPUs */ - cpu =POWERPC_CPU (cpu_create (cpu_type)); - env = &cpu->env; - - cpu_clk->cb =NULL ;/* We don't care about CPU clock frequency changes */ - cpu_clk->opaque = env; -/* Set time-base frequency to sysclk */ - tb_clk->cb =ppc_40x_timers_init (env, sysclk,PPC_INTERRUPT_PIT ); - tb_clk->opaque = env; -ppc_dcr_init (env,NULL ,NULL ); -/* Register qemu callbacks */ -qemu_register_reset (ppc4xx_reset, cpu); - -return cpu; -} -/*****************************************************************************/ /* SDRAM controller */ typedef struct ppc4xx_sdram_t ppc4xx_sdram_t ;
Signature · 1 line
2.37.1
Re: [PATCH v4 07/24] ppc/ppc405: QOM'ify CPU
Quoted 9 lines · Cédric Le Goater
Drop the use of
ppc4xx_init()and duplicate a bit of code related to clocks in the SoC realize routine. We will clean that up in the following patches.
ppc_dcr_init()simply allocates default DCR handlers for the CPU. Maybe this could be done in model initializer of the CPU families needing it.Reviewed-by Daniel Henrique Barboza <[email protected]>Signed-off-by Cédric Le Goater <[email protected]>
Quoted 175 lines
---
hw/ppc/ppc405.h | 2 +- include/hw/ppc/ppc4xx.h | 5 ----- hw/ppc/ppc405_boards.c | 2 +- hw/ppc/ppc405_uc.c | 40 ++++++++++++++++++++++++++++++---------- hw/ppc/ppc4xx_devs.c | 32 -------------------------------- 5 files changed, 32 insertions(+), 49 deletions(-)hw/ppc/ppc405.h +1
-1@@ -79,7 +79,7 @@ struct Ppc405SoCState {hwaddr ram_size;uint32_t sysclk; -PowerPCCPU *cpu; +PowerPCCPU cpu;DeviceState *uic; };include/hw/ppc/ppc4xx.h +0
-5@@ -28,11 +28,6 @@#include "hw/ppc/ppc.h" #include "exec/memory.h" -/* PowerPC 4xx core initialization */ -PowerPCCPU *ppc4xx_init (const char *cpu_model, -clk_setup_t *cpu_clk,clk_setup_t *tb_clk, -uint32_t sysclk); - void ppc4xx_sdram_banks(MemoryRegion *ram, int nr_banks, MemoryRegion ram_memories[], hwaddr ram_bases[], hwaddr ram_sizes[],hw/ppc/ppc405_boards.c +1
-1@@ -313,7 +313,7 @@ static void ppc405_init(MachineState *machine)/* Load ELF kernel and rootfs.cpio */ }else if (kernel_filename && !machine->firmware) { -boot_from_kernel (machine, ppc405->soc.cpu); +boot_from_kernel (machine, &ppc405->soc.cpu); } }hw/ppc/ppc405_uc.c +30
-10@@ -1432,22 +1432,41 @@ static void ppc405ep_cpc_init (CPUPPCState *env, clk_setup_t clk_setup[8],#endif } +static void ppc405_soc_instance_init (Object *obj) +{ +Ppc405SoCState *s =PPC405_SOC (obj); + +object_initialize_child (obj,"cpu" , &s->cpu, +POWERPC_CPU_TYPE_NAME ("405ep" )); +} + +static void ppc405_reset (void *opaque) +{ +cpu_reset (CPU (opaque)); +} +static void ppc405_soc_realize (DeviceState *dev,Error **errp) {Ppc405SoCState *s =PPC405_SOC (dev); -clk_setup_t clk_setup[PPC405EP_CLK_NB ], tlb_clk_setup; +clk_setup_t clk_setup[PPC405EP_CLK_NB ];qemu_irq dma_irqs[4 ], gpt_irqs[5 ], mal_irqs[4 ];CPUPPCState *env;memset (clk_setup,0 ,sizeof (clk_setup));/* init CPUs */ - s->cpu =ppc4xx_init (POWERPC_CPU_TYPE_NAME ("405ep" ), - &clk_setup[PPC405EP_CPU_CLK ], - &tlb_clk_setup, s->sysclk); - env = &s->cpu->env; - clk_setup[PPC405EP_CPU_CLK ].cb = tlb_clk_setup.cb; - clk_setup[PPC405EP_CPU_CLK ].opaque = tlb_clk_setup.opaque; +if (!qdev_realize (DEVICE (&s->cpu),NULL , errp)) { +return ; + } +qemu_register_reset (ppc405_reset, &s->cpu); + + env = &s->cpu.env; + + clk_setup[PPC405EP_CPU_CLK ].cb = +ppc_40x_timers_init (env, s->sysclk,PPC_INTERRUPT_PIT ); + clk_setup[PPC405EP_CPU_CLK ].opaque = env; + +ppc_dcr_init (env,NULL ,NULL );/* CPU control */ ppc405ep_cpc_init (env, clk_setup, s->sysclk);@@ -1464,16 +1483,16 @@ static void ppc405_soc_realize(DeviceState *dev, Error **errp)/* Universal interrupt controller */ s->uic =qdev_new (TYPE_PPC_UIC ); -object_property_set_link (OBJECT (s->uic),"cpu" ,OBJECT (s->cpu), +object_property_set_link (OBJECT (s->uic),"cpu" ,OBJECT (&s->cpu), &error_fatal);if (!sysbus_realize (SYS_BUS_DEVICE (s->uic), errp)) {return ; }sysbus_connect_irq (SYS_BUS_DEVICE (s->uic),PPCUIC_OUTPUT_INT , -qdev_get_gpio_in (DEVICE (s->cpu), PPC40x_INPUT_INT)); +qdev_get_gpio_in (DEVICE (&s->cpu), PPC40x_INPUT_INT));sysbus_connect_irq (SYS_BUS_DEVICE (s->uic),PPCUIC_OUTPUT_CINT , -qdev_get_gpio_in (DEVICE (s->cpu), PPC40x_INPUT_CINT)); +qdev_get_gpio_in (DEVICE (&s->cpu), PPC40x_INPUT_CINT));/* SDRAM controller */ /* XXX 405EP has no ECC interrupt */ @@ -1563,6 +1582,7 @@ static const TypeInfo ppc405_types[] = { .name = TYPE_PPC405_SOC, .parent = TYPE_DEVICE, .instance_size = sizeof(Ppc405SoCState), + .instance_init = ppc405_soc_instance_init, .class_init = ppc405_soc_class_init, } };hw/ppc/ppc4xx_devs.c +0
-32@@ -37,38 +37,6 @@#include "qapi/error.h" #include "trace.h" -static void ppc4xx_reset (void *opaque) -{ -PowerPCCPU *cpu = opaque; - -cpu_reset (CPU (cpu)); -} - -/*****************************************************************************/ -/* Generic PowerPC 4xx processor instantiation */ -PowerPCCPU *ppc4xx_init (const char *cpu_type, -clk_setup_t *cpu_clk,clk_setup_t *tb_clk, -uint32_t sysclk) -{ -PowerPCCPU *cpu; -CPUPPCState *env; - -/* init CPUs */ - cpu =POWERPC_CPU (cpu_create (cpu_type)); - env = &cpu->env; - - cpu_clk->cb =NULL ;/* We don't care about CPU clock frequency changes */ - cpu_clk->opaque = env; -/* Set time-base frequency to sysclk */ - tb_clk->cb =ppc_40x_timers_init (env, sysclk,PPC_INTERRUPT_PIT ); - tb_clk->opaque = env; -ppc_dcr_init (env,NULL ,NULL ); -/* Register qemu callbacks */ -qemu_register_reset (ppc4xx_reset, cpu); - -return cpu; -} -/*****************************************************************************/ /* SDRAM controller */ typedef struct ppc4xx_sdram_t ppc4xx_sdram_t ;
Re: [PATCH v4 07/24] ppc/ppc405: QOM'ify CPU
In reply to Cédric Le GoaterSince maybe there will be another version, this patch is still misnamed, I think it's not QOMifying but embeds the cpu in the soc.
Regards,
BALATON Zoltan
Quoted 184 lines · Cédric Le Goater
Drop the use of
ppc4xx_init()and duplicate a bit of code related to clocks in the SoC realize routine. We will clean that up in the following patches.
ppc_dcr_init()simply allocates default DCR handlers for the CPU. Maybe this could be done in model initializer of the CPU families needing it.Reviewed-by Daniel Henrique Barboza <[email protected]>Signed-off-by Cédric Le Goater <[email protected]>---
hw/ppc/ppc405.h | 2 +- include/hw/ppc/ppc4xx.h | 5 ----- hw/ppc/ppc405_boards.c | 2 +- hw/ppc/ppc405_uc.c | 40 ++++++++++++++++++++++++++++++---------- hw/ppc/ppc4xx_devs.c | 32 -------------------------------- 5 files changed, 32 insertions(+), 49 deletions(-)hw/ppc/ppc405.h +1
-1@@ -79,7 +79,7 @@ struct Ppc405SoCState {hwaddr ram_size;uint32_t sysclk; -PowerPCCPU *cpu; +PowerPCCPU cpu;DeviceState *uic; };include/hw/ppc/ppc4xx.h +0
-5@@ -28,11 +28,6 @@#include "hw/ppc/ppc.h" #include "exec/memory.h" -/* PowerPC 4xx core initialization */ -PowerPCCPU *ppc4xx_init (const char *cpu_model, -clk_setup_t *cpu_clk,clk_setup_t *tb_clk, -uint32_t sysclk); - void ppc4xx_sdram_banks(MemoryRegion *ram, int nr_banks, MemoryRegion ram_memories[], hwaddr ram_bases[], hwaddr ram_sizes[],hw/ppc/ppc405_boards.c +1
-1@@ -313,7 +313,7 @@ static void ppc405_init(MachineState *machine)/* Load ELF kernel and rootfs.cpio */ }else if (kernel_filename && !machine->firmware) { -boot_from_kernel (machine, ppc405->soc.cpu); +boot_from_kernel (machine, &ppc405->soc.cpu); } }hw/ppc/ppc405_uc.c +30
-10@@ -1432,22 +1432,41 @@ static void ppc405ep_cpc_init (CPUPPCState *env, clk_setup_t clk_setup[8],#endif } +static void ppc405_soc_instance_init (Object *obj) +{ +Ppc405SoCState *s =PPC405_SOC (obj); + +object_initialize_child (obj,"cpu" , &s->cpu, +POWERPC_CPU_TYPE_NAME ("405ep" )); +} + +static void ppc405_reset (void *opaque) +{ +cpu_reset (CPU (opaque)); +} +static void ppc405_soc_realize (DeviceState *dev,Error **errp) {Ppc405SoCState *s =PPC405_SOC (dev); -clk_setup_t clk_setup[PPC405EP_CLK_NB ], tlb_clk_setup; +clk_setup_t clk_setup[PPC405EP_CLK_NB ];qemu_irq dma_irqs[4 ], gpt_irqs[5 ], mal_irqs[4 ];CPUPPCState *env;memset (clk_setup,0 ,sizeof (clk_setup));/* init CPUs */ - s->cpu =ppc4xx_init (POWERPC_CPU_TYPE_NAME ("405ep" ), - &clk_setup[PPC405EP_CPU_CLK ], - &tlb_clk_setup, s->sysclk); - env = &s->cpu->env; - clk_setup[PPC405EP_CPU_CLK ].cb = tlb_clk_setup.cb; - clk_setup[PPC405EP_CPU_CLK ].opaque = tlb_clk_setup.opaque; +if (!qdev_realize (DEVICE (&s->cpu),NULL , errp)) { +return ; + } +qemu_register_reset (ppc405_reset, &s->cpu); + + env = &s->cpu.env; + + clk_setup[PPC405EP_CPU_CLK ].cb = +ppc_40x_timers_init (env, s->sysclk,PPC_INTERRUPT_PIT ); + clk_setup[PPC405EP_CPU_CLK ].opaque = env; + +ppc_dcr_init (env,NULL ,NULL );/* CPU control */ ppc405ep_cpc_init (env, clk_setup, s->sysclk);@@ -1464,16 +1483,16 @@ static void ppc405_soc_realize(DeviceState *dev, Error **errp)/* Universal interrupt controller */ s->uic =qdev_new (TYPE_PPC_UIC ); -object_property_set_link (OBJECT (s->uic),"cpu" ,OBJECT (s->cpu), +object_property_set_link (OBJECT (s->uic),"cpu" ,OBJECT (&s->cpu), &error_fatal);if (!sysbus_realize (SYS_BUS_DEVICE (s->uic), errp)) {return ; }sysbus_connect_irq (SYS_BUS_DEVICE (s->uic),PPCUIC_OUTPUT_INT , -qdev_get_gpio_in (DEVICE (s->cpu), PPC40x_INPUT_INT)); +qdev_get_gpio_in (DEVICE (&s->cpu), PPC40x_INPUT_INT));sysbus_connect_irq (SYS_BUS_DEVICE (s->uic),PPCUIC_OUTPUT_CINT , -qdev_get_gpio_in (DEVICE (s->cpu), PPC40x_INPUT_CINT)); +qdev_get_gpio_in (DEVICE (&s->cpu), PPC40x_INPUT_CINT));/* SDRAM controller */ /* XXX 405EP has no ECC interrupt */ @@ -1563,6 +1582,7 @@ static const TypeInfo ppc405_types[] = { .name = TYPE_PPC405_SOC, .parent = TYPE_DEVICE, .instance_size = sizeof(Ppc405SoCState), + .instance_init = ppc405_soc_instance_init, .class_init = ppc405_soc_class_init, } };hw/ppc/ppc4xx_devs.c +0
-32@@ -37,38 +37,6 @@#include "qapi/error.h" #include "trace.h" -static void ppc4xx_reset (void *opaque) -{ -PowerPCCPU *cpu = opaque; - -cpu_reset (CPU (cpu)); -} - -/*****************************************************************************/ -/* Generic PowerPC 4xx processor instantiation */ -PowerPCCPU *ppc4xx_init (const char *cpu_type, -clk_setup_t *cpu_clk,clk_setup_t *tb_clk, -uint32_t sysclk) -{ -PowerPCCPU *cpu; -CPUPPCState *env; - -/* init CPUs */ - cpu =POWERPC_CPU (cpu_create (cpu_type)); - env = &cpu->env; - - cpu_clk->cb =NULL ;/* We don't care about CPU clock frequency changes */ - cpu_clk->opaque = env; -/* Set time-base frequency to sysclk */ - tb_clk->cb =ppc_40x_timers_init (env, sysclk,PPC_INTERRUPT_PIT ); - tb_clk->opaque = env; -ppc_dcr_init (env,NULL ,NULL ); -/* Register qemu callbacks */ -qemu_register_reset (ppc4xx_reset, cpu); - -return cpu; -} -/*****************************************************************************/ /* SDRAM controller */ typedef struct ppc4xx_sdram_t ppc4xx_sdram_t ;
PATCH v4 8/24 ppc/ppc4xx: Introduce a DCR device model
In reply to Cédric Le GoaterThe Device Control Registers (DCR) of on-SoC devices are accessed by software through the use of the mtdcr and mfdcr instructions. These are converted in transactions on a side band bus, the DCR bus, which connects the on-SoC devices to the CPU.
Ideally, we should model these accesses with a DCR namespace and DCR memory regions but today the DCR handlers are installed in a DCR table under the CPU. Instead introduce a little device model wrapper to hold a CPU link and handle registration of DCR handlers.
The DCR device inherits from SysBus because most of these devices also have MMIO regions and/or IRQs. Being a SysBusDevice makes things easier to install the device model in the overall SoC.
The "cpu" link should be considered as modeling the piece of HW logic connecting the device to the DCR bus.
--- include/hw/ppc/ppc4xx.h | 17 ++++++++++++++++ hw/ppc/ppc4xx_devs.c | 44 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+)
include/hw/ppc/ppc4xx.h +17 -0
@@ -27,6 +27,7 @@#include "hw/ppc/ppc.h" #include "exec/memory.h" +#include "hw/sysbus.h" void ppc4xx_sdram_banks(MemoryRegion *ram, int nr_banks, MemoryRegion ram_memories[],
@@ -44,4 +45,20 @@ void ppc4xx_mal_init(CPUPPCState *env, uint8_t txcnum, uint8_t rxcnum,#define TYPE_PPC4xx_PCI_HOST_BRIDGE "ppc4xx-pcihost" +/* +* Generic DCR device +*/ +#define TYPE_PPC4xx_DCR_DEVICE "ppc4xx-dcr-device" +OBJECT_DECLARE_SIMPLE_TYPE (Ppc4xxDcrDeviceState, PPC4xx_DCR_DEVICE); +struct Ppc4xxDcrDeviceState { +SysBusDevice parent_obj; + +PowerPCCPU *cpu; +}; + +void ppc4xx_dcr_register (Ppc4xxDcrDeviceState *dev,int dcrn, +dcr_read_cb dcr_read,dcr_write_cb dcr_write); +bool ppc4xx_dcr_realize (Ppc4xxDcrDeviceState *dev,PowerPCCPU *cpu, +Error **errp); +#endif /* PPC4XX_H */
hw/ppc/ppc4xx_devs.c +44 -0
47 lines not on this page · raw message
Signature · 1 line
2.37.1
Re: [PATCH v4 08/24] ppc/ppc4xx: Introduce a DCR device model
Quoted 61 lines · Cédric Le Goater
The Device Control Registers (DCR) of on-SoC devices are accessed by software through the use of the mtdcr and mfdcr instructions. These are converted in transactions on a side band bus, the DCR bus, which connects the on-SoC devices to the CPU.
Ideally, we should model these accesses with a DCR namespace and DCR memory regions but today the DCR handlers are installed in a DCR table under the CPU. Instead introduce a little device model wrapper to hold a CPU link and handle registration of DCR handlers.
The DCR device inherits from SysBus because most of these devices also have MMIO regions and/or IRQs. Being a SysBusDevice makes things easier to install the device model in the overall SoC.
The "cpu" link should be considered as modeling the piece of HW logic connecting the device to the DCR bus.
Signed-off-by Cédric Le Goater <[email protected]>---
include/hw/ppc/ppc4xx.h| 17 ++++++++++++++++hw/ppc/ppc4xx_devs.c| 44 +++++++++++++++++++++++++++++++++++++++++2 files changed, 61 insertions(+)include/hw/ppc/ppc4xx.h +17
-0@@ -27,6 +27,7 @@#include "hw/ppc/ppc.h" #include "exec/memory.h" +#include "hw/sysbus.h" void ppc4xx_sdram_banks(MemoryRegion *ram, int nr_banks, MemoryRegion ram_memories[],@@ -44,4 +45,20 @@ void ppc4xx_mal_init(CPUPPCState *env, uint8_t txcnum, uint8_t rxcnum,#define TYPE_PPC4xx_PCI_HOST_BRIDGE "ppc4xx-pcihost" +/* +* Generic DCR device +*/ +#define TYPE_PPC4xx_DCR_DEVICE "ppc4xx-dcr-device" +OBJECT_DECLARE_SIMPLE_TYPE (Ppc4xxDcrDeviceState, PPC4xx_DCR_DEVICE); +struct Ppc4xxDcrDeviceState { +SysBusDevice parent_obj; + +PowerPCCPU *cpu; +}; + +void ppc4xx_dcr_register (Ppc4xxDcrDeviceState *dev,int dcrn, +dcr_read_cb dcr_read,dcr_write_cb dcr_write); +bool ppc4xx_dcr_realize (Ppc4xxDcrDeviceState *dev,PowerPCCPU *cpu, +Error **errp); +#endif /* PPC4XX_H */ hw/ppc/ppc4xx_devs.c +0
-0
hw/ppc/ppc4xx_devs.c void ppc4xx_mal_init(CPUPPCState *env, uint8_t txcnum, uint8_t rxcnum, · line 669
Quoted 6 lines
hw/ppc/ppc4xx_devs.c +3
-0@@ -664,3 +664,47 @@ void ppc4xx_mal_init(CPUPPCState *env, uint8_t txcnum, uint8_t rxcnum, mal, &dcr_read_mal, &dcr_write_mal); } } + +void ppc4xx_dcr_register (Ppc4xxDcrDeviceState *dev,int dcrn, +dcr_read_cb dcr_read,dcr_write_cb dcr_write)
I still think this should have a separate void *opaque parameter for the callbacks and not pass dev for that as the callbacks could use anything they wish for that parameter. (Additionally this allows dropping a lot of QOM casts. If you want to see how often these are accessed, you can try -trace enable="ppc_dcr*"; on the machines and OS I've tested some are read/written frequently so I'd not add unnecessary overhead without a good reason.)
Otherwise:
Regards,
BALATOn Zoltan
Quoted 42 lines
hw/ppc/ppc4xx_devs.c +41
-0+{ +CPUPPCState *env; + +assert (dev->cpu); + + env = &dev->cpu->env; + +ppc_dcr_register (env, dcrn, dev, dcr_read, dcr_write); +} + +bool ppc4xx_dcr_realize (Ppc4xxDcrDeviceState *dev,PowerPCCPU *cpu, +Error **errp) +{ +object_property_set_link (OBJECT (dev),"cpu" ,OBJECT (cpu), &error_abort); +return sysbus_realize (SYS_BUS_DEVICE (dev), errp); +} + +static Property ppc4xx_dcr_properties[] = { +DEFINE_PROP_LINK ("cpu" , Ppc4xxDcrDeviceState, cpu,TYPE_POWERPC_CPU , + PowerPCCPU *), +DEFINE_PROP_END_OF_LIST (), +}; + +static void ppc4xx_dcr_class_init (ObjectClass *oc,void *data) +{ +DeviceClass *dc =DEVICE_CLASS (oc); + +device_class_set_props (dc, ppc4xx_dcr_properties); +} + +static const TypeInfo ppc4xx_types[] = { + { + .name = TYPE_PPC4xx_DCR_DEVICE, + .parent =TYPE_SYS_BUS_DEVICE , + .instance_size =sizeof (Ppc4xxDcrDeviceState), + .class_init = ppc4xx_dcr_class_init, + .abstract = true, + } +}; + +DEFINE_TYPES (ppc4xx_types)
Re: [PATCH v4 08/24] ppc/ppc4xx: Introduce a DCR device model
Quoted 62 lines · BALATON Zoltan
Quoted 61 lines · Cédric Le Goater
The Device Control Registers (DCR) of on-SoC devices are accessed by software through the use of the mtdcr and mfdcr instructions. These are converted in transactions on a side band bus, the DCR bus, which connects the on-SoC devices to the CPU.
Ideally, we should model these accesses with a DCR namespace and DCR memory regions but today the DCR handlers are installed in a DCR table under the CPU. Instead introduce a little device model wrapper to hold a CPU link and handle registration of DCR handlers.
The DCR device inherits from SysBus because most of these devices also have MMIO regions and/or IRQs. Being a SysBusDevice makes things easier to install the device model in the overall SoC.
The "cpu" link should be considered as modeling the piece of HW logic connecting the device to the DCR bus.
Signed-off-by Cédric Le Goater <[email protected]>---
include/hw/ppc/ppc4xx.h| 17 ++++++++++++++++ hw/ppc/ppc4xx_devs.c | 44 +++++++++++++++++++++++++++++++++++++++++2 files changed, 61 insertions(+)include/hw/ppc/ppc4xx.h +17
-0@@ -27,6 +27,7 @@#include "hw/ppc/ppc.h" #include "exec/memory.h" +#include "hw/sysbus.h" void ppc4xx_sdram_banks(MemoryRegion *ram, int nr_banks, MemoryRegion ram_memories[],@@ -44,4 +45,20 @@ void ppc4xx_mal_init(CPUPPCState *env, uint8_t txcnum, uint8_t rxcnum,#define TYPE_PPC4xx_PCI_HOST_BRIDGE "ppc4xx-pcihost" +/* +* Generic DCR device +*/ +#define TYPE_PPC4xx_DCR_DEVICE "ppc4xx-dcr-device" +OBJECT_DECLARE_SIMPLE_TYPE (Ppc4xxDcrDeviceState, PPC4xx_DCR_DEVICE); +struct Ppc4xxDcrDeviceState { + SysBusDevice parent_obj; + + PowerPCCPU *cpu; +}; + +void ppc4xx_dcr_register (Ppc4xxDcrDeviceState *dev,int dcrn, + dcr_read_cb dcr_read, dcr_write_cb dcr_write); +bool ppc4xx_dcr_realize (Ppc4xxDcrDeviceState *dev,PowerPCCPU *cpu, + Error **errp); +#endif /* PPC4XX_H */ hw/ppc/ppc4xx_devs.c +0
-0@@ -664,3 +664,47 @@ void ppc4xx_mal_init(CPUPPCState *env, uint8_t txcnum, uint8_t rxcnum,
Quoted 8 lines
hw/ppc/ppc4xx_devs.c void ppc4xx_mal_init(CPUPPCState *env, uint8_t txcnum, uint8_t rxcnum, · line 669
Quoted 6 lines
hw/ppc/ppc4xx_devs.c +3
-0mal, &dcr_read_mal, &dcr_write_mal); } } + +void ppc4xx_dcr_register (Ppc4xxDcrDeviceState *dev,int dcrn, + dcr_read_cb dcr_read, dcr_write_cb dcr_write)I still think this should have a separate void *opaque parameter for the callbacks and not pass dev for that as the callbacks could use anything they wish for that parameter. (Additionally this allows dropping a lot of QOM casts. If you want to see how often these are accessed, you can try -trace enable="ppc_dcr*"; on the machines and OS I've tested some are read/written frequently so I'd not add unnecessary overhead without a good reason.)
This machine has been abandoned for 15 years and broken for maybe 10. I think it is fine for now. We will see if further needs arise.
Thanks,
C.
Quoted 50 lines
Otherwise:
Reviewed-by BALATON Zoltan <[email protected]>Regards,
BALATOn ZoltanQuoted 42 lines
hw/ppc/ppc4xx_devs.c +41
-0+{ + CPUPPCState *env; + + assert(dev->cpu); + + env = &dev->cpu->env; + + ppc_dcr_register(env, dcrn, dev, dcr_read, dcr_write); +} + +bool ppc4xx_dcr_realize (Ppc4xxDcrDeviceState *dev,PowerPCCPU *cpu, + Error **errp) +{ + object_property_set_link(OBJECT(dev), "cpu", OBJECT(cpu), &error_abort); + return sysbus_realize(SYS_BUS_DEVICE(dev), errp); +} + +static Property ppc4xx_dcr_properties[] = { + DEFINE_PROP_LINK("cpu", Ppc4xxDcrDeviceState, cpu, TYPE_POWERPC_CPU, + PowerPCCPU *), + DEFINE_PROP_END_OF_LIST(), +}; + +static void ppc4xx_dcr_class_init (ObjectClass *oc,void *data) +{ + DeviceClass *dc = DEVICE_CLASS(oc); + + device_class_set_props(dc, ppc4xx_dcr_properties); +} + +static const TypeInfo ppc4xx_types[] = { + { + .name = TYPE_PPC4xx_DCR_DEVICE, + .parent = TYPE_SYS_BUS_DEVICE, + .instance_size = sizeof(Ppc4xxDcrDeviceState), + .class_init = ppc4xx_dcr_class_init, + .abstract = true, + } +}; + +DEFINE_TYPES (ppc4xx_types)
Re: [PATCH v4 08/24] ppc/ppc4xx: Introduce a DCR device model
Quoted 76 lines · Cédric Le Goater
Quoted 66 lines · BALATON Zoltan
Quoted 65 lines · Cédric Le Goater
The Device Control Registers (DCR) of on-SoC devices are accessed by software through the use of the mtdcr and mfdcr instructions. These are converted in transactions on a side band bus, the DCR bus, which connects the on-SoC devices to the CPU.
Ideally, we should model these accesses with a DCR namespace and DCR memory regions but today the DCR handlers are installed in a DCR table under the CPU. Instead introduce a little device model wrapper to hold a CPU link and handle registration of DCR handlers.
The DCR device inherits from SysBus because most of these devices also have MMIO regions and/or IRQs. Being a SysBusDevice makes things easier to install the device model in the overall SoC.
The "cpu" link should be considered as modeling the piece of HW logic connecting the device to the DCR bus.
Signed-off-by Cédric Le Goater <[email protected]>---
include/hw/ppc/ppc4xx.h| 17 ++++++++++++++++ hw/ppc/ppc4xx_devs.c | 44 +++++++++++++++++++++++++++++++++++++++++2 files changed, 61 insertions(+)include/hw/ppc/ppc4xx.h +17
-0@@ -27,6 +27,7 @@#include "hw/ppc/ppc.h" #include "exec/memory.h" +#include "hw/sysbus.h" void ppc4xx_sdram_banks(MemoryRegion *ram, int nr_banks, MemoryRegion ram_memories[],@@ -44,4 +45,20 @@ void ppc4xx_mal_init(CPUPPCState *env, uint8_t txcnum, uint8_t rxcnum,#define TYPE_PPC4xx_PCI_HOST_BRIDGE "ppc4xx-pcihost" +/* +* Generic DCR device +*/ +#define TYPE_PPC4xx_DCR_DEVICE "ppc4xx-dcr-device" +OBJECT_DECLARE_SIMPLE_TYPE (Ppc4xxDcrDeviceState, PPC4xx_DCR_DEVICE); +struct Ppc4xxDcrDeviceState { + SysBusDevice parent_obj; + + PowerPCCPU *cpu; +}; + +void ppc4xx_dcr_register (Ppc4xxDcrDeviceState *dev,int dcrn, + dcr_read_cb dcr_read, dcr_write_cb dcr_write); +bool ppc4xx_dcr_realize (Ppc4xxDcrDeviceState *dev,PowerPCCPU *cpu, + Error **errp); +#endif /*
PPC4XX_H*/hw/ppc/ppc4xx_devs.c +0
-0@@ -664,3 +664,47 @@ void ppc4xx_mal_init(CPUPPCState *env, uint8_t txcnum, uint8_t rxcnum, mal, &dcr_read_mal, &dcr_write_mal); }Quoted 8 lines
hw/ppc/ppc4xx_devs.c void ppc4xx_mal_init(CPUPPCState *env, uint8_t txcnum, uint8_t rxcnum, · line 669
Quoted 4 lines
}
hw/ppc/ppc4xx_devs.c +3
-0+ +void ppc4xx_dcr_register (Ppc4xxDcrDeviceState *dev,int dcrn, + dcr_read_cb dcr_read, dcr_write_cb dcr_write)I still think this should have a separate void *opaque parameter for the callbacks and not pass dev for that as the callbacks could use anything they wish for that parameter. (Additionally this allows dropping a lot of QOM casts. If you want to see how often these are accessed, you can try -trace enable="ppc_dcr*"; on the machines and OS I've tested some are
read/written frequently so I'd not add unnecessary overhead without a good reason.)
Quoted 2 lines
This machine has been abandoned for 15 years and broken for maybe 10. I think it is fine for now. We will see if further needs arise.
It will arise as I'd like to keep at least the devices used by sam460ex somewhat sane so if you don't change this now I'd likely want to change it back. I undetstand it's a hassle to do in a rebase now but keeping the opaque parameter means just a search replace from the old ppc_dcr_register to ppc4xx_dcr_register so maybe not that hard to do at this point. Once you apply this patch it will be more difficult to revert it.
Regards,
BALATON Zoltan
Quoted 58 lines
Thanks,
C.
Quoted 51 lines
Otherwise:
Reviewed-by BALATON Zoltan <[email protected]>Regards,
BALATOn ZoltanQuoted 43 lines
hw/ppc/ppc4xx_devs.c +14
-0+{ + CPUPPCState *env; + + assert(dev->cpu); + + env = &dev->cpu->env; + + ppc_dcr_register(env, dcrn, dev, dcr_read, dcr_write); +} + +bool ppc4xx_dcr_realize (Ppc4xxDcrDeviceState *dev,PowerPCCPU *cpu, + Error **errp) +{ + object_property_set_link(OBJECT(dev), "cpu", OBJECT(cpu),
&error_abort);
+ returnsysbus_realize(SYS_BUS_DEVICE(dev), errp);hw/ppc/ppc4xx_devs.c +26
-0+} + +static Property ppc4xx_dcr_properties[] = { + DEFINE_PROP_LINK("cpu", Ppc4xxDcrDeviceState, cpu, TYPE_POWERPC_CPU, + PowerPCCPU *), + DEFINE_PROP_END_OF_LIST(), +}; + +static void ppc4xx_dcr_class_init (ObjectClass *oc,void *data) +{ + DeviceClass *dc = DEVICE_CLASS(oc); + + device_class_set_props(dc, ppc4xx_dcr_properties); +} + +static const TypeInfo ppc4xx_types[] = { + { + .name = TYPE_PPC4xx_DCR_DEVICE, + .parent = TYPE_SYS_BUS_DEVICE, + .instance_size = sizeof(Ppc4xxDcrDeviceState), + .class_init = ppc4xx_dcr_class_init, + .abstract = true, + } +}; + +DEFINE_TYPES (ppc4xx_types)
Re: [PATCH v4 08/24] ppc/ppc4xx: Introduce a DCR device model
Quoted 73 lines · BALATON Zoltan
Quoted 72 lines · Cédric Le Goater
Quoted 70 lines · BALATON Zoltan
Quoted 61 lines · Cédric Le Goater
The Device Control Registers (DCR) of on-SoC devices are accessed by software through the use of the mtdcr and mfdcr instructions. These are converted in transactions on a side band bus, the DCR bus, which connects the on-SoC devices to the CPU.
Ideally, we should model these accesses with a DCR namespace and DCR memory regions but today the DCR handlers are installed in a DCR table under the CPU. Instead introduce a little device model wrapper to hold a CPU link and handle registration of DCR handlers.
The DCR device inherits from SysBus because most of these devices also have MMIO regions and/or IRQs. Being a SysBusDevice makes things easier to install the device model in the overall SoC.
The "cpu" link should be considered as modeling the piece of HW logic connecting the device to the DCR bus.
Signed-off-by Cédric Le Goater <[email protected]>---
include/hw/ppc/ppc4xx.h| 17 ++++++++++++++++ hw/ppc/ppc4xx_devs.c | 44 +++++++++++++++++++++++++++++++++++++++++2 files changed, 61 insertions(+)include/hw/ppc/ppc4xx.h +17
-0@@ -27,6 +27,7 @@#include "hw/ppc/ppc.h" #include "exec/memory.h" +#include "hw/sysbus.h" void ppc4xx_sdram_banks(MemoryRegion *ram, int nr_banks, MemoryRegion ram_memories[],@@ -44,4 +45,20 @@ void ppc4xx_mal_init(CPUPPCState *env, uint8_t txcnum, uint8_t rxcnum,#define TYPE_PPC4xx_PCI_HOST_BRIDGE "ppc4xx-pcihost" +/* +* Generic DCR device +*/ +#define TYPE_PPC4xx_DCR_DEVICE "ppc4xx-dcr-device" +OBJECT_DECLARE_SIMPLE_TYPE (Ppc4xxDcrDeviceState, PPC4xx_DCR_DEVICE); +struct Ppc4xxDcrDeviceState { + SysBusDevice parent_obj; + + PowerPCCPU *cpu; +}; + +void ppc4xx_dcr_register (Ppc4xxDcrDeviceState *dev,int dcrn, + dcr_read_cb dcr_read, dcr_write_cb dcr_write); +bool ppc4xx_dcr_realize (Ppc4xxDcrDeviceState *dev,PowerPCCPU *cpu, + Error **errp); +#endif /* PPC4XX_H */ hw/ppc/ppc4xx_devs.c +0
-0hw/ppc/ppc4xx_devs.c void ppc4xx_mal_init(CPUPPCState *env, uint8_t txcnum, uint8_t rxcnum, · line 669
Quoted 6 lines
hw/ppc/ppc4xx_devs.c +3
-0@@ -664,3 +664,47 @@ void ppc4xx_mal_init(CPUPPCState *env, uint8_t txcnum, uint8_t rxcnum, mal, &dcr_read_mal, &dcr_write_mal); } } + +void ppc4xx_dcr_register (Ppc4xxDcrDeviceState *dev,int dcrn, + dcr_read_cb dcr_read, dcr_write_cb dcr_write)I still think this should have a separate void *opaque parameter for the callbacks and not pass dev for that as the callbacks could use anything they wish for that parameter. (Additionally this allows dropping a lot of QOM casts. If you want to see how often these are accessed, you can try -trace enable="ppc_dcr*"; on the machines and OS I've tested some are read/written frequently so I'd not add unnecessary overhead without a good reason.)
Quoted 4 lines
Quoted 2 lines
This machine has been abandoned for 15 years and broken for maybe 10. I think it is fine for now. We will see if further needs arise.
It will arise as I'd like to keep at least the devices used by sam460ex somewhat sane
What do you mean by somewhat sane ? If it is the QOM casts, I don't understand why you worry so much about it because QOM cast debugging is not enabled by default. So it really should not impact performance as you think it would.
C.
Quoted 62 lines
so if you don't change this now I'd likely want to change it back. I undetstand it's a hassle to do in a rebase now but keeping the opaque parameter means just a search replace from the old
ppc_dcr_registertoppc4xx_dcr_registerso maybe not that hard to do at this point. Once you apply this patch it will be more difficult to revert it.Regards,
BALATON ZoltanQuoted 57 lines
Thanks,
C.
Quoted 50 lines
Otherwise:
Reviewed-by BALATON Zoltan <[email protected]>Regards,
BALATOn ZoltanQuoted 42 lines
hw/ppc/ppc4xx_devs.c +41
-0+{ + CPUPPCState *env; + + assert(dev->cpu); + + env = &dev->cpu->env; + + ppc_dcr_register(env, dcrn, dev, dcr_read, dcr_write); +} + +bool ppc4xx_dcr_realize (Ppc4xxDcrDeviceState *dev,PowerPCCPU *cpu, + Error **errp) +{ + object_property_set_link(OBJECT(dev), "cpu", OBJECT(cpu), &error_abort); + return sysbus_realize(SYS_BUS_DEVICE(dev), errp); +} + +static Property ppc4xx_dcr_properties[] = { + DEFINE_PROP_LINK("cpu", Ppc4xxDcrDeviceState, cpu, TYPE_POWERPC_CPU, + PowerPCCPU *), + DEFINE_PROP_END_OF_LIST(), +}; + +static void ppc4xx_dcr_class_init (ObjectClass *oc,void *data) +{ + DeviceClass *dc = DEVICE_CLASS(oc); + + device_class_set_props(dc, ppc4xx_dcr_properties); +} + +static const TypeInfo ppc4xx_types[] = { + { + .name = TYPE_PPC4xx_DCR_DEVICE, + .parent = TYPE_SYS_BUS_DEVICE, + .instance_size = sizeof(Ppc4xxDcrDeviceState), + .class_init = ppc4xx_dcr_class_init, + .abstract = true, + } +}; + +DEFINE_TYPES (ppc4xx_types)
Re: [PATCH v4 08/24] ppc/ppc4xx: Introduce a DCR device model
Quoted 81 lines · Cédric Le Goater
Quoted 80 lines · BALATON Zoltan
Quoted 78 lines · Cédric Le Goater
Quoted 66 lines · BALATON Zoltan
Quoted 65 lines · Cédric Le Goater
The Device Control Registers (DCR) of on-SoC devices are accessed by software through the use of the mtdcr and mfdcr instructions. These are converted in transactions on a side band bus, the DCR bus, which connects the on-SoC devices to the CPU.
Ideally, we should model these accesses with a DCR namespace and DCR memory regions but today the DCR handlers are installed in a DCR table under the CPU. Instead introduce a little device model wrapper to hold a CPU link and handle registration of DCR handlers.
The DCR device inherits from SysBus because most of these devices also have MMIO regions and/or IRQs. Being a SysBusDevice makes things easier to install the device model in the overall SoC.
The "cpu" link should be considered as modeling the piece of HW logic connecting the device to the DCR bus.
Signed-off-by Cédric Le Goater <[email protected]>---
include/hw/ppc/ppc4xx.h| 17 ++++++++++++++++ hw/ppc/ppc4xx_devs.c | 44 +++++++++++++++++++++++++++++++++++++++++2 files changed, 61 insertions(+)include/hw/ppc/ppc4xx.h +17
-0@@ -27,6 +27,7 @@#include "hw/ppc/ppc.h" #include "exec/memory.h" +#include "hw/sysbus.h" void ppc4xx_sdram_banks(MemoryRegion *ram, int nr_banks, MemoryRegion ram_memories[],@@ -44,4 +45,20 @@ void ppc4xx_mal_init(CPUPPCState *env, uint8_t txcnum, uint8_t rxcnum,#define TYPE_PPC4xx_PCI_HOST_BRIDGE "ppc4xx-pcihost" +/* +* Generic DCR device +*/ +#define TYPE_PPC4xx_DCR_DEVICE "ppc4xx-dcr-device" +OBJECT_DECLARE_SIMPLE_TYPE (Ppc4xxDcrDeviceState, PPC4xx_DCR_DEVICE); +struct Ppc4xxDcrDeviceState { + SysBusDevice parent_obj; + + PowerPCCPU *cpu; +}; + +void ppc4xx_dcr_register (Ppc4xxDcrDeviceState *dev,int dcrn, + dcr_read_cb dcr_read, dcr_write_cb dcr_write); +bool ppc4xx_dcr_realize (Ppc4xxDcrDeviceState *dev,PowerPCCPU *cpu, + Error **errp); +#endif /*
PPC4XX_H*/hw/ppc/ppc4xx_devs.c +0
-0@@ -664,3 +664,47 @@ void ppc4xx_mal_init(CPUPPCState *env, uint8_t txcnum, uint8_t rxcnum, mal, &dcr_read_mal, &dcr_write_mal); }Quoted 8 lines
hw/ppc/ppc4xx_devs.c void ppc4xx_mal_init(CPUPPCState *env, uint8_t txcnum, uint8_t rxcnum, · line 669
Quoted 4 lines
}
hw/ppc/ppc4xx_devs.c +3
-0+ +void ppc4xx_dcr_register (Ppc4xxDcrDeviceState *dev,int dcrn, + dcr_read_cb dcr_read, dcr_write_cb dcr_write)I still think this should have a separate void *opaque parameter for the callbacks and not pass dev for that as the callbacks could use anything they wish for that parameter. (Additionally this allows dropping a lot of QOM casts. If you want to see how often these are accessed, you can try -trace enable="ppc_dcr*"; on the machines and OS I've tested some are
read/written frequently so I'd not add unnecessary overhead without a good reason.)This machine has been abandoned for 15 years and broken for maybe 10. I think it is fine for now. We will see if further needs arise.
Quoted 6 lines
Quoted 1 line
It will arise as I'd like to keep at least the devices used by sam460ex somewhat sane
What do you mean by somewhat sane ? If it is the QOM casts, I don't understand why you worry so much about it because QOM cast debugging is not enabled by default. So it really should not impact performance as you think it would.
I think it is enabled by default unless you explicitly disable it which is not done by most distros so it's generally may impact performance (or if it's already slow for other reasons then it just increase inefficiency needlessly). If it's simple to avoid like here why not avoid it? Also conceptually the opaque parameter is a closure for the callback functions while dev is a self pointer for the method and you're now mixing these two. I think it's cleaner to keep them separate and not impose a restiction on the callbacks.
Sorry but I have strong feeling on this one. I think the simplest way to rebase and revert this is to do an interactive rebase editing each patch and do interactive revert of just the lines changing ppc4xx_dcr_register followed by a search replace of "ppc_dcr_register(" with "ppc4xx_dcr_register(dcr, ". That should not be too difficult to do now. (It could be done afterwatds too but I'd appreciate and would be less chutn if you did that now.)
Regards,
BALATON Zoltan
Quoted 69 lines
C.
Quoted 64 lines
so if you don't change this now I'd likely want to change it back. I undetstand it's a hassle to do in a rebase now but keeping the opaque parameter means just a search replace from the old
ppc_dcr_registertoppc4xx_dcr_registerso maybe not that hard to do at this point. Once you apply this patch it will be more difficult to revert it.Regards,
BALATON ZoltanQuoted 59 lines
Thanks,
C.
Quoted 52 lines
Otherwise:
Reviewed-by BALATON Zoltan <[email protected]>Regards,
BALATOn ZoltanQuoted 44 lines
hw/ppc/ppc4xx_devs.c +14
-0+{ + CPUPPCState *env; + + assert(dev->cpu); + + env = &dev->cpu->env; + + ppc_dcr_register(env, dcrn, dev, dcr_read, dcr_write); +} + +bool ppc4xx_dcr_realize (Ppc4xxDcrDeviceState *dev,PowerPCCPU *cpu, + Error **errp) +{ + object_property_set_link(OBJECT(dev), "cpu", OBJECT(cpu),
&error_abort);
+ returnsysbus_realize(SYS_BUS_DEVICE(dev), errp);hw/ppc/ppc4xx_devs.c +4
-0+} + +static Property ppc4xx_dcr_properties[] = { + DEFINE_PROP_LINK("cpu", Ppc4xxDcrDeviceState, cpu,
TYPE_POWERPC_CPU,
+ PowerPCCPU *),
+DEFINE_PROP_END_OF_LIST(),hw/ppc/ppc4xx_devs.c +20
-0+}; + +static void ppc4xx_dcr_class_init (ObjectClass *oc,void *data) +{ + DeviceClass *dc = DEVICE_CLASS(oc); + + device_class_set_props(dc, ppc4xx_dcr_properties); +} + +static const TypeInfo ppc4xx_types[] = { + { + .name = TYPE_PPC4xx_DCR_DEVICE, + .parent = TYPE_SYS_BUS_DEVICE, + .instance_size = sizeof(Ppc4xxDcrDeviceState), + .class_init = ppc4xx_dcr_class_init, + .abstract = true, + } +}; + +DEFINE_TYPES (ppc4xx_types)
Re: [PATCH v4 08/24] ppc/ppc4xx: Introduce a DCR device model
Quoted 85 lines · BALATON Zoltan
Quoted 77 lines · Cédric Le Goater
Quoted 76 lines · BALATON Zoltan
Quoted 74 lines · Cédric Le Goater
Quoted 62 lines · BALATON Zoltan
Quoted 61 lines · Cédric Le Goater
The Device Control Registers (DCR) of on-SoC devices are accessed by software through the use of the mtdcr and mfdcr instructions. These are converted in transactions on a side band bus, the DCR bus, which connects the on-SoC devices to the CPU.
Ideally, we should model these accesses with a DCR namespace and DCR memory regions but today the DCR handlers are installed in a DCR table under the CPU. Instead introduce a little device model wrapper to hold a CPU link and handle registration of DCR handlers.
The DCR device inherits from SysBus because most of these devices also have MMIO regions and/or IRQs. Being a SysBusDevice makes things easier to install the device model in the overall SoC.
The "cpu" link should be considered as modeling the piece of HW logic connecting the device to the DCR bus.
Signed-off-by Cédric Le Goater <[email protected]>---
include/hw/ppc/ppc4xx.h| 17 ++++++++++++++++ hw/ppc/ppc4xx_devs.c | 44 +++++++++++++++++++++++++++++++++++++++++2 files changed, 61 insertions(+)include/hw/ppc/ppc4xx.h +17
-0@@ -27,6 +27,7 @@#include "hw/ppc/ppc.h" #include "exec/memory.h" +#include "hw/sysbus.h" void ppc4xx_sdram_banks(MemoryRegion *ram, int nr_banks, MemoryRegion ram_memories[],@@ -44,4 +45,20 @@ void ppc4xx_mal_init(CPUPPCState *env, uint8_t txcnum, uint8_t rxcnum,#define TYPE_PPC4xx_PCI_HOST_BRIDGE "ppc4xx-pcihost" +/* +* Generic DCR device +*/ +#define TYPE_PPC4xx_DCR_DEVICE "ppc4xx-dcr-device" +OBJECT_DECLARE_SIMPLE_TYPE (Ppc4xxDcrDeviceState, PPC4xx_DCR_DEVICE); +struct Ppc4xxDcrDeviceState { + SysBusDevice parent_obj; + + PowerPCCPU *cpu; +}; + +void ppc4xx_dcr_register (Ppc4xxDcrDeviceState *dev,int dcrn, + dcr_read_cb dcr_read, dcr_write_cb dcr_write); +bool ppc4xx_dcr_realize (Ppc4xxDcrDeviceState *dev,PowerPCCPU *cpu, + Error **errp); +#endif /* PPC4XX_H */ hw/ppc/ppc4xx_devs.c +0
-0@@ -664,3 +664,47 @@ void ppc4xx_mal_init(CPUPPCState *env, uint8_t txcnum, uint8_t rxcnum,Quoted 8 lines
hw/ppc/ppc4xx_devs.c void ppc4xx_mal_init(CPUPPCState *env, uint8_t txcnum, uint8_t rxcnum, · line 669
Quoted 6 lines
hw/ppc/ppc4xx_devs.c +3
-0mal, &dcr_read_mal, &dcr_write_mal); } } + +void ppc4xx_dcr_register (Ppc4xxDcrDeviceState *dev,int dcrn, + dcr_read_cb dcr_read, dcr_write_cb dcr_write)I still think this should have a separate void *opaque parameter for the callbacks and not pass dev for that as the callbacks could use anything they wish for that parameter. (Additionally this allows dropping a lot of QOM casts. If you want to see how often these are accessed, you can try -trace enable="ppc_dcr*"; on the machines and OS I've tested some are read/written frequently so I'd not add unnecessary overhead without a good reason.)
This machine has been abandoned for 15 years and broken for maybe 10. I think it is fine for now. We will see if further needs arise.
Quoted 6 lines
Quoted 1 line
It will arise as I'd like to keep at least the devices used by sam460ex somewhat sane
What do you mean by somewhat sane ? If it is the QOM casts, I don't understand why you worry so much about it because QOM cast debugging is not enabled by default. So it really should not impact performance as you think it would.
Quoted 4 lines
I think it is enabled by default unless you explicitly disable> it which is not done by most distros so it's generally may impact performance (or if it's already slow for other reasons
then it just increase inefficiency needlessly). If it's simple
to avoid like here why not avoid it?
It is not. you need to add '--enable-qom-cast-debug' to configure.
Quoted 7 lines
Also conceptually the
opaque parameter is a closure for the callback functions while dev is a self pointer for the method and you're now mixing these two. I think it's cleaner to keep them separate and not impose a restiction on the callbacks.Sorry but I have strong feeling on this one.
Sorry but I don't think it is well justified.
Quoted 7 lines
I think the simplest way to rebase and revert this is to do an interactive rebase editing each patch and do interactive revert of just the lines changing
ppc4xx_dcr_registerfollowed by a search replace of "ppc_dcr_register("
with "ppc4xx_dcr_register(dcr, ". That should not be too difficult to do now. (It could be done afterwatds too but I'd appreciate and would be less chutn if you did that now.)
The simplest way for me is to come back the initial proposal, remove the Ppc4xxDcrDeviceState model and reintroduce the explicit "cpu" link for each device which was less controversial. Expect that in v5 and that will be all for me.
Thanks,
C.
Re: [PATCH v4 08/24] ppc/ppc4xx: Introduce a DCR device model
Quoted 115 lines · Cédric Le Goater
Quoted 89 lines · BALATON Zoltan
Quoted 81 lines · Cédric Le Goater
Quoted 80 lines · BALATON Zoltan
Quoted 78 lines · Cédric Le Goater
Quoted 66 lines · BALATON Zoltan
Quoted 65 lines · Cédric Le Goater
The Device Control Registers (DCR) of on-SoC devices are accessed by software through the use of the mtdcr and mfdcr instructions. These are converted in transactions on a side band bus, the DCR bus, which connects the on-SoC devices to the CPU.
Ideally, we should model these accesses with a DCR namespace and DCR memory regions but today the DCR handlers are installed in a DCR table under the CPU. Instead introduce a little device model wrapper to hold a CPU link and handle registration of DCR handlers.
The DCR device inherits from SysBus because most of these devices also have MMIO regions and/or IRQs. Being a SysBusDevice makes things easier to install the device model in the overall SoC.
The "cpu" link should be considered as modeling the piece of HW logic connecting the device to the DCR bus.
Signed-off-by Cédric Le Goater <[email protected]>---
include/hw/ppc/ppc4xx.h| 17 ++++++++++++++++ hw/ppc/ppc4xx_devs.c | 44 +++++++++++++++++++++++++++++++++++++++++2 files changed, 61 insertions(+)include/hw/ppc/ppc4xx.h +14
-0@@ -27,6 +27,7 @@#include "hw/ppc/ppc.h" #include "exec/memory.h" +#include "hw/sysbus.h" void ppc4xx_sdram_banks(MemoryRegion *ram, int nr_banks, MemoryRegion ram_memories[],@@ -44,4 +45,20 @@ void ppc4xx_mal_init(CPUPPCState *env, uint8_t txcnum, uint8_t rxcnum,#define TYPE_PPC4xx_PCI_HOST_BRIDGE "ppc4xx-pcihost" +/* +* Generic DCR device +*/ +#define TYPE_PPC4xx_DCR_DEVICE "ppc4xx-dcr-device" +OBJECT_DECLARE_SIMPLE_TYPE (Ppc4xxDcrDeviceState, PPC4xx_DCR_DEVICE); +struct Ppc4xxDcrDeviceState { + SysBusDevice parent_obj; + + PowerPCCPU *cpu; +}; + +void ppc4xx_dcr_register (Ppc4xxDcrDeviceState *dev,int dcrn, + dcr_read_cb dcr_read, dcr_write_cb
dcr_write);include/hw/ppc/ppc4xx.h +3
-0+bool ppc4xx_dcr_realize (Ppc4xxDcrDeviceState *dev,PowerPCCPU *cpu, + Error **errp); +#endif /*
PPC4XX_H*/hw/ppc/ppc4xx_devs.c +0
-0@@ -664,3 +664,47 @@ void ppc4xx_mal_init(CPUPPCState *env, uint8_t txcnum, uint8_t rxcnum, mal, &dcr_read_mal, &dcr_write_mal);Quoted 8 lines
Quoted 6 lines
hw/ppc/ppc4xx_devs.c +0
-0}}
hw/ppc/ppc4xx_devs.c +3
-0+ +void ppc4xx_dcr_register (Ppc4xxDcrDeviceState *dev,int dcrn, + dcr_read_cb dcr_read, dcr_write_cb
dcr_write)I still think this should have a separate void *opaque parameter for the callbacks and not pass dev for that as the callbacks could use anything they wish for that parameter. (Additionally this allows dropping a lot of QOM casts. If you want to see how often these are accessed, you can try -trace enable="ppc_dcr*"; on the machines and OS I've tested some are read/written frequently so I'd not add unnecessary overhead without a good reason.)
This machine has been abandoned for 15 years and broken for maybe 10. I think it is fine for now. We will see if further needs arise.
Quoted 6 lines
Quoted 1 line
It will arise as I'd like to keep at least the devices used by sam460ex somewhat sane
What do you mean by somewhat sane ? If it is the QOM casts, I don't understand why you worry so much about it because QOM cast debugging is not enabled by default. So it really should not impact performance as you think it would.
Quoted 4 lines
I think it is enabled by default unless you explicitly disable> it which is not done by most distros so it's generally may impact performance (or if it's already slow for other reasons
then it just increase inefficiency needlessly). If it's simple
to avoid like here why not avoid it?It is not. you need to add '--enable-qom-cast-debug' to configure.
Quoted 7 lines
Also conceptually the
opaque parameter is a closure for the callback functions while dev is a self pointer for the method and you're now mixing these two. I think it's cleaner to keep them separate and not impose a restiction on the callbacks.Sorry but I have strong feeling on this one.
Sorry but I don't think it is well justified.
Quoted 7 lines
I think the simplest way to rebase and revert this is to do an interactive rebase editing each patch and do interactive revert of just the lines changing
ppc4xx_dcr_registerfollowed by a search replace of "ppc_dcr_register("
with "ppc4xx_dcr_register(dcr, ". That should not be too difficult to do now. (It could be done afterwatds too but I'd appreciate and would be less chutn if you did that now.)
Quoted 4 lines
The simplest way for me is to come back the initial proposal, remove the Ppc4xxDcrDeviceState model and reintroduce the explicit "cpu" link for each device which was less controversial. Expect that in v5 and that will be all for me.
Don't drop Ppc4xxDcrDeviceState, that simplifies it a lot. If you don't want to make mote changes, let me take your series and make a version with my proposed changes.
Regards,
BALATON Zoltan
Re: [PATCH v4 08/24] ppc/ppc4xx: Introduce a DCR device model
Quoted 2 lines
Don't drop Ppc4xxDcrDeviceState, that simplifies it a lot. If you don't want to make mote changes, let me take your series and make a version with my proposed changes.
Patch 1-7 are already merged. You can grab the rest here :
https://github.com/legoater/qemu/tree/ppc-ref405ep
I have done the minor fixes already.
Thanks,
C.
Re: [PATCH v4 08/24] ppc/ppc4xx: Introduce a DCR device model
Quoted 7 lines · Cédric Le Goater
Quoted 1 line
Don't drop Ppc4xxDcrDeviceState, that simplifies it a lot. If you don't want to make mote changes, let me take your series and make a version with my proposed changes.
Patch 1-7 are already merged. You can grab the rest here :
https://github.com/legoater/qemu/tree/ppc-ref405ep
I have done the minor fixes already.
OK, thanks. I'll send an updated version in the weekend.
Regards,
BALATON Zoltan
PATCH v4 9/24 ppc/ppc405: QOM'ify CPC
In reply to Cédric Le GoaterThe CPC controller is currently modeled as a DCR device.
Now that all clock settings are handled at the CPC level, change the SoC "sys-clk" property to be an alias on the same property in the CPC model.
--- hw/ppc/ppc405.h | 35 ++++++++++++- hw/ppc/ppc405_uc.c | 123 +++++++++++++++++++-------------------------- 2 files changed, 87 insertions(+), 71 deletions(-)
hw/ppc/ppc405.h +34 -1
@@ -63,6 +63,39 @@ struct ppc4xx_bd_info_t {uint32_t bi_iic_fast[2 ]; }; +#define TYPE_PPC405_CPC "ppc405-cpc" +OBJECT_DECLARE_SIMPLE_TYPE (Ppc405CpcState,PPC405_CPC ); + +enum { +PPC405EP_CPU_CLK =0 , +PPC405EP_PLB_CLK =1 , +PPC405EP_OPB_CLK =2 , +PPC405EP_EBC_CLK =3 , +PPC405EP_MAL_CLK =4 , +PPC405EP_PCI_CLK =5 , +PPC405EP_UART0_CLK =6 , +PPC405EP_UART1_CLK =7 , +PPC405EP_CLK_NB =8 , +}; + +struct Ppc405CpcState { +Ppc4xxDcrDeviceState parent_obj; + +uint32_t sysclk; +clk_setup_t clk_setup[PPC405EP_CLK_NB ]; +uint32_t boot; +uint32_t epctl; +uint32_t pllmr[2 ]; +uint32_t ucr; +uint32_t srr; +uint32_t jtagid; +uint32_t pci; +/* Clock and power management */ +uint32_t er; +uint32_t fr; +uint32_t sr; +}; +#define TYPE_PPC405_SOC "ppc405-soc"OBJECT_DECLARE_SIMPLE_TYPE (Ppc405SoCState,PPC405_SOC );
@@ -78,9 +111,9 @@ struct Ppc405SoCState {MemoryRegion *dram_mr;hwaddr ram_size; -uint32_t sysclk;PowerPCCPU cpu;DeviceState *uic; +Ppc405CpcState cpc; };/* PowerPC 405 core */
hw/ppc/ppc405_uc.c +53 -70
207 lines not on this page · raw message
Signature · 1 line
2.37.1
PATCH v4 10/24 ppc/ppc405: QOM'ify GPT
In reply to Cédric Le GoaterThe GPT controller is currently modeled as a SysBus device with a unique memory region, a couple of IRQs and a timer.
--- hw/ppc/ppc405.h | 22 +++++++++++ hw/ppc/ppc405_uc.c | 91 +++++++++++++++++++++++---------------------- hw/ppc/trace-events | 1 - 3 files changed, 68 insertions(+), 46 deletions(-)
hw/ppc/ppc405.h +22 -0
@@ -63,6 +63,27 @@ struct ppc4xx_bd_info_t {uint32_t bi_iic_fast[2 ]; }; +/* General purpose timers */ +#define TYPE_PPC405_GPT "ppc405-gpt" +OBJECT_DECLARE_SIMPLE_TYPE (Ppc405GptState,PPC405_GPT ); +struct Ppc405GptState { +SysBusDevice parent_obj; + +MemoryRegion iomem; + +int64_t tb_offset; +uint32_t tb_freq; +QEMUTimer *timer; +qemu_irq irqs[5 ]; +uint32_t oe; +uint32_t ol; +uint32_t im; +uint32_t is; +uint32_t ie; +uint32_t comp[5 ]; +uint32_t mask[5 ]; +}; +#define TYPE_PPC405_CPC "ppc405-cpc"OBJECT_DECLARE_SIMPLE_TYPE (Ppc405CpcState,PPC405_CPC );
@@ -114,6 +135,7 @@ struct Ppc405SoCState {PowerPCCPU cpu;DeviceState *uic;Ppc405CpcState cpc; +Ppc405GptState gpt; };/* PowerPC 405 core */
hw/ppc/ppc405_uc.c +46 -45
181 lines not on this page · raw message
hw/ppc/trace-events +0 -1
@@ -162,7 +162,6 @@ ocm_unmap(const char* prefix, uint32_t isarc) "OCM unmap %s 0x%08" PRIx32 ppc4xx_gpt_read(uint64_t addr, uint32_t size) "addr 0x%" PRIx64 " size %d" ppc4xx_gpt_write(uint64_t addr, uint32_t size, uint64_t val) "addr 0x%" PRIx64 " size %d = 0x%" PRIx64 -ppc4xx_gpt_init(uint64_t addr) "offet 0x%" PRIx64 ppc405ep_clocks_compute(const char *param, uint32_t param2, uint32_t val) "%s 0x%1" PRIx32 " %d" ppc405ep_clocks_setup(const char *trace) "%s"
Signature · 1 line
2.37.1
PATCH v4 11/24 ppc/ppc405: QOM'ify OCM
In reply to Cédric Le GoaterThe OCM controller is currently modeled as a simple DCR device with a couple of memory regions.
--- hw/ppc/ppc405.h | 16 ++++++++++ hw/ppc/ppc405_uc.c | 73 +++++++++++++++++++++++----------------------- 2 files changed, 53 insertions(+), 36 deletions(-)
hw/ppc/ppc405.h +16 -0
@@ -63,6 +63,21 @@ struct ppc4xx_bd_info_t {uint32_t bi_iic_fast[2 ]; }; +/* On Chip Memory */ +#define TYPE_PPC405_OCM "ppc405-ocm" +OBJECT_DECLARE_SIMPLE_TYPE (Ppc405OcmState,PPC405_OCM ); +struct Ppc405OcmState { +Ppc4xxDcrDeviceState parent_obj; + +MemoryRegion ram; +MemoryRegion isarc_ram; +MemoryRegion dsarc_ram; +uint32_t isarc; +uint32_t isacntl; +uint32_t dsarc; +uint32_t dsacntl; +}; +/* General purpose timers */ #define TYPE_PPC405_GPT "ppc405-gpt"OBJECT_DECLARE_SIMPLE_TYPE (Ppc405GptState,PPC405_GPT );
@@ -136,6 +151,7 @@ struct Ppc405SoCState {DeviceState *uic;Ppc405CpcState cpc;Ppc405GptState gpt; +Ppc405OcmState ocm; };/* PowerPC 405 core */
hw/ppc/ppc405_uc.c +37 -36
133 lines not on this page · raw message
Signature · 1 line
2.37.1
PATCH v4 12/24 ppc/ppc405: QOM'ify GPIO
In reply to Cédric Le GoaterThe GPIO controller is currently modeled as a simple SysBus device with a unique memory region.
--- hw/ppc/ppc405.h | 21 +++++++++++++++++++ hw/ppc/ppc405_uc.c | 51 +++++++++++++++++++++------------------------ hw/ppc/trace-events | 1 - 3 files changed, 45 insertions(+), 28 deletions(-)
hw/ppc/ppc405.h +21 -0
@@ -63,6 +63,26 @@ struct ppc4xx_bd_info_t {uint32_t bi_iic_fast[2 ]; }; +/* GPIO */ +#define TYPE_PPC405_GPIO "ppc405-gpio" +OBJECT_DECLARE_SIMPLE_TYPE (Ppc405GpioState,PPC405_GPIO ); +struct Ppc405GpioState { +SysBusDevice parent_obj; + +MemoryRegion io; +uint32_t or; +uint32_t tcr; +uint32_t osrh; +uint32_t osrl; +uint32_t tsrh; +uint32_t tsrl; +uint32_t odr; +uint32_t ir; +uint32_t rr1; +uint32_t isr1h; +uint32_t isr1l; +}; +/* On Chip Memory */ #define TYPE_PPC405_OCM "ppc405-ocm"OBJECT_DECLARE_SIMPLE_TYPE (Ppc405OcmState,PPC405_OCM );
@@ -152,6 +172,7 @@ struct Ppc405SoCState {Ppc405CpcState cpc;Ppc405GptState gpt;Ppc405OcmState ocm; +Ppc405GpioState gpio; };/* PowerPC 405 core */
hw/ppc/ppc405_uc.c +24 -27
87 lines not on this page · raw message
hw/ppc/trace-events +0 -1
@@ -154,7 +154,6 @@ opba_init(uint64_t addr) "offet 0x%" PRIx64 ppc405_gpio_read(uint64_t addr, uint32_t size) "addr 0x%" PRIx64 " size %d" ppc405_gpio_write(uint64_t addr, uint32_t size, uint64_t val) "addr 0x%" PRIx64 " size %d = 0x%" PRIx64 -ppc405_gpio_init(uint64_t addr) "offet 0x%" PRIx64 ocm_update_mappings(uint32_t isarc, uint32_t isacntl, uint32_t dsarc, uint32_t dsacntl, uint32_t ocm_isarc, uint32_t ocm_isacntl, uint32_t ocm_dsarc, uint32_t ocm_dsacntl) "OCM update ISA 0x%08" PRIx32 " 0x%08" PRIx32 " (0x%08" PRIx32" 0x%08" PRIx32 ") DSA 0x%08" PRIx32 " 0x%08" PRIx32" (0x%08" PRIx32 " 0x%08" PRIx32 ")" ocm_map(const char* prefix, uint32_t isarc) "OCM map %s 0x%08" PRIx32
Signature · 1 line
2.37.1
PATCH v4 13/24 ppc/ppc405: QOM'ify DMA
In reply to Cédric Le GoaterThe DMA controller is currently modeled as a DCR device with a couple of IRQs.
--- hw/ppc/ppc405.h | 19 ++++++ hw/ppc/ppc405_uc.c | 142 ++++++++++++++++++++------------------------- 2 files changed, 82 insertions(+), 79 deletions(-)
hw/ppc/ppc405.h +19 -0
@@ -63,6 +63,24 @@ struct ppc4xx_bd_info_t {uint32_t bi_iic_fast[2 ]; }; +/* DMA controller */ +#define TYPE_PPC405_DMA "ppc405-dma" +OBJECT_DECLARE_SIMPLE_TYPE (Ppc405DmaState,PPC405_DMA ); +struct Ppc405DmaState { +Ppc4xxDcrDeviceState parent_obj; + +qemu_irq irqs[4 ]; +uint32_t cr[4 ]; +uint32_t ct[4 ]; +uint32_t da[4 ]; +uint32_t sa[4 ]; +uint32_t sg[4 ]; +uint32_t sr; +uint32_t sgc; +uint32_t slp; +uint32_t pol; +}; +/* GPIO */ #define TYPE_PPC405_GPIO "ppc405-gpio"OBJECT_DECLARE_SIMPLE_TYPE (Ppc405GpioState,PPC405_GPIO );
@@ -173,6 +191,7 @@ struct Ppc405SoCState {Ppc405GptState gpt;Ppc405OcmState ocm;Ppc405GpioState gpio; +Ppc405DmaState dma; };/* PowerPC 405 core */
hw/ppc/ppc405_uc.c +63 -79
189 lines not on this page · raw message
Signature · 1 line
2.37.1
PATCH v4 14/24 ppc/ppc405: QOM'ify EBC
In reply to Cédric Le GoaterEBC is currently modeled as a DCR device. Also drop the ppc405_ebc_init() helper and adapt the sam460ex machine.
--- hw/ppc/ppc405.h | 17 +++++++++++++- hw/ppc/ppc405_uc.c | 57 +++++++++++++++++++++++----------------------- hw/ppc/sam460ex.c | 4 +++- 3 files changed, 48 insertions(+), 30 deletions(-)
hw/ppc/ppc405.h +16 -1
@@ -63,6 +63,21 @@ struct ppc4xx_bd_info_t {uint32_t bi_iic_fast[2 ]; }; +/* Peripheral controller */ +#define TYPE_PPC405_EBC "ppc405-ebc" +OBJECT_DECLARE_SIMPLE_TYPE (Ppc405EbcState,PPC405_EBC ); +struct Ppc405EbcState { +Ppc4xxDcrDeviceState parent_obj; + +uint32_t addr; +uint32_t bcr[8 ]; +uint32_t bap[8 ]; +uint32_t bear; +uint32_t besr0; +uint32_t besr1; +uint32_t cfg; +}; +/* DMA controller */ #define TYPE_PPC405_DMA "ppc405-dma"OBJECT_DECLARE_SIMPLE_TYPE (Ppc405DmaState,PPC405_DMA );
@@ -192,12 +207,12 @@ struct Ppc405SoCState {Ppc405OcmState ocm;Ppc405GpioState gpio;Ppc405DmaState dma; + Ppc405EbcState ebc; };/* PowerPC 405 core */ ram_addr_t ppc405_set_bootinfo (CPUPPCState *env,ram_addr_t ram_size);void ppc4xx_plb_init (CPUPPCState *env); -void ppc405_ebc_init (CPUPPCState *env);#endif /* PPC405_H */
hw/ppc/ppc405_uc.c +29 -28
112 lines not on this page · raw message
hw/ppc/sam460ex.c +3 -1
@@ -371,7 +371,9 @@ static void sam460ex_init(MachineState *machine) qdev_get_gpio_in(uic[0], 3));/* External bus controller */ -ppc405_ebc_init (env); + dev =qdev_new (TYPE_PPC405_EBC ); +ppc4xx_dcr_realize (PPC4xx_DCR_DEVICE (dev), cpu, &error_fatal); +object_unref (OBJECT (dev));/* CPR */ ppc4xx_cpr_init (env);
Signature · 1 line
2.37.1
PATCH v4 15/24 ppc/ppc405: QOM'ify OPBA
In reply to Cédric Le GoaterThe OPB arbitrer is currently modeled as a simple SysBus device with a unique memory region.
--- hw/ppc/ppc405.h | 12 ++++++++++++ hw/ppc/ppc405_uc.c | 48 +++++++++++++++++++++++++++------------------ hw/ppc/trace-events | 1 - 3 files changed, 41 insertions(+), 20 deletions(-)
hw/ppc/ppc405.h +12 -0
@@ -63,6 +63,17 @@ struct ppc4xx_bd_info_t {uint32_t bi_iic_fast[2 ]; }; +/* OPB arbitrer */ +#define TYPE_PPC405_OPBA "ppc405-opba" +OBJECT_DECLARE_SIMPLE_TYPE (Ppc405OpbaState,PPC405_OPBA ); +struct Ppc405OpbaState { +SysBusDevice parent_obj; + +MemoryRegion io; +uint8_t cr; +uint8_t pr; +}; +/* Peripheral controller */ #define TYPE_PPC405_EBC "ppc405-ebc"OBJECT_DECLARE_SIMPLE_TYPE (Ppc405EbcState,PPC405_EBC );
@@ -208,6 +219,7 @@ struct Ppc405SoCState {Ppc405GpioState gpio;Ppc405DmaState dma;Ppc405EbcState ebc; +Ppc405OpbaState opba; };/* PowerPC 405 core */
hw/ppc/ppc405_uc.c +29 -19
96 lines not on this page · raw message
hw/ppc/trace-events +0 -1
@@ -150,7 +150,6 @@ ppc440_pcix_reg_write(uint64_t addr, uint32_t val, uint32_t size) "addr 0x%" PRI # ppc405_boards.c opba_readb(uint64_t addr, uint32_t val) "addr 0x%" PRIx64 " = 0x%" PRIx32 opba_writeb(uint64_t addr, uint64_t val) "addr 0x%" PRIx64 " = 0x%" PRIx64 -opba_init(uint64_t addr) "offet 0x%" PRIx64 ppc405_gpio_read(uint64_t addr, uint32_t size) "addr 0x%" PRIx64 " size %d" ppc405_gpio_write(uint64_t addr, uint32_t size, uint64_t val) "addr 0x%" PRIx64 " size %d = 0x%" PRIx64
Signature · 1 line
2.37.1
PATCH v4 16/24 ppc/ppc405: QOM'ify POB
In reply to Cédric Le GoaterPOB is currently modeled as a simple DCR device.
--- hw/ppc/ppc405.h | 12 +++++++++++ hw/ppc/ppc405_uc.c | 51 ++++++++++++++++++++++++++-------------------- 2 files changed, 41 insertions(+), 22 deletions(-)
hw/ppc/ppc405.h +12 -0
@@ -63,6 +63,17 @@ struct ppc4xx_bd_info_t {uint32_t bi_iic_fast[2 ]; }; +/* PLB to OPB bridge */ +#define TYPE_PPC405_POB "ppc405-pob" +OBJECT_DECLARE_SIMPLE_TYPE (Ppc405PobState,PPC405_POB ); +struct Ppc405PobState { +Ppc4xxDcrDeviceState parent_obj; + +uint32_t bear; +uint32_t besr0; +uint32_t besr1; +}; +/* OPB arbitrer */ #define TYPE_PPC405_OPBA "ppc405-opba"OBJECT_DECLARE_SIMPLE_TYPE (Ppc405OpbaState,PPC405_OPBA );
@@ -220,6 +231,7 @@ struct Ppc405SoCState {Ppc405DmaState dma;Ppc405EbcState ebc;Ppc405OpbaState opba; +Ppc405PobState pob; };/* PowerPC 405 core */
hw/ppc/ppc405_uc.c +29 -22
102 lines not on this page · raw message
Signature · 1 line
2.37.1
PATCH v4 17/24 ppc/ppc405: QOM'ify PLB
In reply to Cédric Le GoaterPLB is currently modeled as a simple DCR device. Also drop the ppc4xx_plb_init() helper and adapt the sam460ex machine.
--- hw/ppc/ppc405.h | 14 +++++++++-- hw/ppc/ppc405_uc.c | 59 ++++++++++++++++++++++++++-------------------- hw/ppc/sam460ex.c | 4 +++- 3 files changed, 48 insertions(+), 29 deletions(-)
hw/ppc/ppc405.h +12 -2
@@ -63,6 +63,17 @@ struct ppc4xx_bd_info_t {uint32_t bi_iic_fast[2 ]; }; +/* Peripheral local bus arbitrer */ +#define TYPE_PPC405_PLB "ppc405-plb" +OBJECT_DECLARE_SIMPLE_TYPE (Ppc405PlbState,PPC405_PLB ); +struct Ppc405PlbState { +Ppc4xxDcrDeviceState parent_obj; + +uint32_t acr; +uint32_t bear; +uint32_t besr; +}; +/* PLB to OPB bridge */ #define TYPE_PPC405_POB "ppc405-pob"OBJECT_DECLARE_SIMPLE_TYPE (Ppc405PobState,PPC405_POB );
@@ -232,11 +243,10 @@ struct Ppc405SoCState {Ppc405EbcState ebc;Ppc405OpbaState opba;Ppc405PobState pob; + Ppc405PlbState plb; };/* PowerPC 405 core */ ram_addr_t ppc405_set_bootinfo (CPUPPCState *env,ram_addr_t ram_size); -void ppc4xx_plb_init (CPUPPCState *env); -#endif /* PPC405_H */
hw/ppc/ppc405_uc.c +33 -26
108 lines not on this page · raw message
hw/ppc/sam460ex.c +3 -1
@@ -309,7 +309,9 @@ static void sam460ex_init(MachineState *machine)ppc_dcr_init (env,NULL ,NULL );/* PLB arbitrer */ -ppc4xx_plb_init (env); + dev =qdev_new (TYPE_PPC405_PLB ); +ppc4xx_dcr_realize (PPC4xx_DCR_DEVICE (dev), cpu, &error_fatal); +object_unref (OBJECT (dev));/* interrupt controllers */ for (i =0 ; i <ARRAY_SIZE (uic); i++) {
Signature · 1 line
2.37.1
PATCH v4 18/24 ppc/ppc405: QOM'ify MAL
In reply to Cédric Le GoaterThe Memory Access Layer (MAL) controller is currently modeled as a DCR device with 4 IRQs. Also drop the ppc4xx_mal_init() helper and adapt the sam460ex machine.
--- hw/ppc/ppc405.h | 1 + include/hw/ppc/ppc4xx.h | 32 +++++++++- hw/ppc/ppc405_uc.c | 18 ++++-- hw/ppc/ppc4xx_devs.c | 135 ++++++++++++++++++---------------------- hw/ppc/sam460ex.c | 16 +++-- 5 files changed, 116 insertions(+), 86 deletions(-)
hw/ppc/ppc405.h +1 -0
@@ -244,6 +244,7 @@ struct Ppc405SoCState {Ppc405OpbaState opba;Ppc405PobState pob;Ppc405PlbState plb; +Ppc4xxMalState mal; };/* PowerPC 405 core */
include/hw/ppc/ppc4xx.h +29 -3
@@ -26,6 +26,7 @@#define PPC4XX_H #include "hw/ppc/ppc.h" +#include "hw/sysbus.h" #include "exec/memory.h" #include "hw/sysbus.h"
@@ -40,9 +41,6 @@ void ppc4xx_sdram_init (CPUPPCState *env, qemu_irq irq, int nbanks,hwaddr *ram_sizes, int do_init); -void ppc4xx_mal_init (CPUPPCState *env,uint8_t txcnum,uint8_t rxcnum, -qemu_irq irqs[4 ]); -#define TYPE_PPC4xx_PCI_HOST_BRIDGE "ppc4xx-pcihost"/*
@@ -61,4 +59,32 @@ void ppc4xx_dcr_register(Ppc4xxDcrDeviceState *dev, int dcrn,bool ppc4xx_dcr_realize (Ppc4xxDcrDeviceState *dev,PowerPCCPU *cpu,Error **errp); +/* Memory Access Layer (MAL) */ +#define TYPE_PPC4xx_MAL "ppc4xx-mal" +OBJECT_DECLARE_SIMPLE_TYPE (Ppc4xxMalState, PPC4xx_MAL); +struct Ppc4xxMalState { +Ppc4xxDcrDeviceState parent_obj; + +qemu_irq irqs[4 ]; +uint32_t cfg; +uint32_t esr; +uint32_t ier; +uint32_t txcasr; +uint32_t txcarr; +uint32_t txeobisr; +uint32_t txdeir; +uint32_t rxcasr; +uint32_t rxcarr; +uint32_t rxeobisr; +uint32_t rxdeir; +uint32_t *txctpr; +uint32_t *rxctpr; +uint32_t *rcbs; +uint8_t txcnum; +uint8_t rxcnum; +}; + +void ppc4xx_mal_init (CPUPPCState *env,uint8_t txcnum,uint8_t rxcnum, +qemu_irq irqs[4 ]); +#endif /* PPC4XX_H */
hw/ppc/ppc405_uc.c +12 -6
@@ -1368,6 +1368,8 @@ static void ppc405_soc_instance_init(Object *obj)object_initialize_child (obj,"pob" , &s->pob,TYPE_PPC405_POB );object_initialize_child (obj,"plb" , &s->plb,TYPE_PPC405_PLB ); + +object_initialize_child (obj,"mal" , &s->mal, TYPE_PPC4xx_MAL); }static void ppc405_reset (void *opaque)
@@ -1378,7 +1380,6 @@ static void ppc405_reset(void *opaque)static void ppc405_soc_realize (DeviceState *dev,Error **errp) {Ppc405SoCState *s =PPC405_SOC (dev); -qemu_irq mal_irqs[4 ];CPUPPCState *env;int i;
@@ -1495,11 +1496,16 @@ static void ppc405_soc_realize(DeviceState *dev, Error **errp) }/* MAL */ - mal_irqs[0 ] =qdev_get_gpio_in (s->uic,11 ); - mal_irqs[1 ] =qdev_get_gpio_in (s->uic,12 ); - mal_irqs[2 ] =qdev_get_gpio_in (s->uic,13 ); - mal_irqs[3 ] =qdev_get_gpio_in (s->uic,14 ); -ppc4xx_mal_init (env,4 ,2 , mal_irqs); +object_property_set_int (OBJECT (&s->mal),"txc-num" ,4 , &error_abort); +object_property_set_int (OBJECT (&s->mal),"rxc-num" ,2 , &error_abort); +if (!ppc4xx_dcr_realize (PPC4xx_DCR_DEVICE (&s->mal), &s->cpu, errp)) { +return ; + } + +for (i =0 ; i <ARRAY_SIZE (s->mal.irqs); i++) { +sysbus_connect_irq (SYS_BUS_DEVICE (&s->mal), i, +qdev_get_gpio_in (s->uic,11 + i)); + }/* Ethernet */ /* Uses UIC IRQs 9, 15, 17 */
hw/ppc/ppc4xx_devs.c +62 -73
182 lines not on this page · raw message
hw/ppc/sam460ex.c +12 -4
@@ -280,7 +280,7 @@ static void sam460ex_init(MachineState *machine)hwaddr ram_sizes[SDRAM_NR_BANKS ] = {0 };MemoryRegion *l2cache_ram =g_new (MemoryRegion,1 );DeviceState *uic[4 ]; -qemu_irq mal_irqs[4 ]; +Ppc4xxMalState *mal;int i;PCIBus *pci_bus;PowerPCCPU *cpu;
@@ -387,10 +387,18 @@ static void sam460ex_init(MachineState *machine)ppc4xx_sdr_init (env);/* MAL */ -for (i =0 ; i <ARRAY_SIZE (mal_irqs); i++) { - mal_irqs[i] =qdev_get_gpio_in (uic[2 ],3 + i); + dev =qdev_new (TYPE_PPC4xx_MAL); + mal =PPC4xx_MAL (dev); + +qdev_prop_set_uint32 (dev,"txc-num" ,4 ); +qdev_prop_set_uint32 (dev,"rxc-num" ,16 ); +ppc4xx_dcr_realize (PPC4xx_DCR_DEVICE (mal), cpu, &error_fatal); +object_unref (OBJECT (mal)); + +for (i =0 ; i <ARRAY_SIZE (mal->irqs); i++) { +sysbus_connect_irq (SYS_BUS_DEVICE (dev), i, +qdev_get_gpio_in (uic[2 ],3 + i)); } -ppc4xx_mal_init (env,4 ,16 , mal_irqs);/* DMA */ ppc4xx_dma_init (env,0x200 );
Signature · 1 line
2.37.1
Re: [PATCH v4 18/24] ppc/ppc405: QOM'ify MAL
Quoted 31 lines · Cédric Le Goater
The Memory Access Layer (MAL) controller is currently modeled as a DCR device with 4 IRQs. Also drop the
ppc4xx_mal_init()helper and adapt the sam460ex machine.Reviewed-by Daniel Henrique Barboza <[email protected]>Signed-off-by Cédric Le Goater <[email protected]>---
hw/ppc/ppc405.h | 1 + include/hw/ppc/ppc4xx.h | 32 +++++++++- hw/ppc/ppc405_uc.c | 18 ++++-- hw/ppc/ppc4xx_devs.c | 135 ++++++++++++++++++---------------------- hw/ppc/sam460ex.c | 16 +++-- 5 files changed, 116 insertions(+), 86 deletions(-)hw/ppc/ppc405.h +1
-0@@ -244,6 +244,7 @@ struct Ppc405SoCState {Ppc405OpbaState opba;Ppc405PobState pob;Ppc405PlbState plb; +Ppc4xxMalState mal; };/* PowerPC 405 core */ include/hw/ppc/ppc4xx.h +0
-0
include/hw/ppc/ppc4xx.h line 29
Quoted 4 lines
include/hw/ppc/ppc4xx.h +1
-0@@ -26,6 +26,7 @@#define PPC4XX_H #include "hw/ppc/ppc.h" +#include "hw/sysbus.h"
This looks odd to me as no line added below seems to need it. Does this hunk belong to an earlier patch? (Have you verified that each step compiles so it can be bisected?)
Regards,
BALATON Zoltan
Quoted 316 lines
include/hw/ppc/ppc4xx.h +28
-3#include "exec/memory.h" #include "hw/sysbus.h" @@ -40,9 +41,6 @@ void ppc4xx_sdram_init (CPUPPCState *env, qemu_irq irq, int nbanks,hwaddr *ram_sizes, int do_init); -void ppc4xx_mal_init (CPUPPCState *env,uint8_t txcnum,uint8_t rxcnum, -qemu_irq irqs[4 ]); -#define TYPE_PPC4xx_PCI_HOST_BRIDGE "ppc4xx-pcihost"/* @@ -61,4 +59,32 @@ void ppc4xx_dcr_register(Ppc4xxDcrDeviceState *dev, int dcrn,bool ppc4xx_dcr_realize (Ppc4xxDcrDeviceState *dev,PowerPCCPU *cpu,Error **errp); +/* Memory Access Layer (MAL) */ +#define TYPE_PPC4xx_MAL "ppc4xx-mal" +OBJECT_DECLARE_SIMPLE_TYPE (Ppc4xxMalState, PPC4xx_MAL); +struct Ppc4xxMalState { +Ppc4xxDcrDeviceState parent_obj; + +qemu_irq irqs[4 ]; +uint32_t cfg; +uint32_t esr; +uint32_t ier; +uint32_t txcasr; +uint32_t txcarr; +uint32_t txeobisr; +uint32_t txdeir; +uint32_t rxcasr; +uint32_t rxcarr; +uint32_t rxeobisr; +uint32_t rxdeir; +uint32_t *txctpr; +uint32_t *rxctpr; +uint32_t *rcbs; +uint8_t txcnum; +uint8_t rxcnum; +}; + +void ppc4xx_mal_init (CPUPPCState *env,uint8_t txcnum,uint8_t rxcnum, +qemu_irq irqs[4 ]); +#endif /* PPC4XX_H */ hw/ppc/ppc405_uc.c +12
-6@@ -1368,6 +1368,8 @@ static void ppc405_soc_instance_init(Object *obj)object_initialize_child (obj,"pob" , &s->pob,TYPE_PPC405_POB );object_initialize_child (obj,"plb" , &s->plb,TYPE_PPC405_PLB ); + +object_initialize_child (obj,"mal" , &s->mal, TYPE_PPC4xx_MAL); }static void ppc405_reset (void *opaque)@@ -1378,7 +1380,6 @@ static void ppc405_reset(void *opaque)static void ppc405_soc_realize (DeviceState *dev,Error **errp) {Ppc405SoCState *s =PPC405_SOC (dev); -qemu_irq mal_irqs[4 ];CPUPPCState *env;int i;@@ -1495,11 +1496,16 @@ static void ppc405_soc_realize(DeviceState *dev, Error **errp) }/* MAL */ - mal_irqs[0 ] =qdev_get_gpio_in (s->uic,11 ); - mal_irqs[1 ] =qdev_get_gpio_in (s->uic,12 ); - mal_irqs[2 ] =qdev_get_gpio_in (s->uic,13 ); - mal_irqs[3 ] =qdev_get_gpio_in (s->uic,14 ); -ppc4xx_mal_init (env,4 ,2 , mal_irqs); +object_property_set_int (OBJECT (&s->mal),"txc-num" ,4 , &error_abort); +object_property_set_int (OBJECT (&s->mal),"rxc-num" ,2 , &error_abort); +if (!ppc4xx_dcr_realize (PPC4xx_DCR_DEVICE (&s->mal), &s->cpu, errp)) { +return ; + } + +for (i =0 ; i <ARRAY_SIZE (s->mal.irqs); i++) { +sysbus_connect_irq (SYS_BUS_DEVICE (&s->mal), i, +qdev_get_gpio_in (s->uic,11 + i)); + }/* Ethernet */ /* Uses UIC IRQs 9, 15, 17 */ hw/ppc/ppc4xx_devs.c +62
-73@@ -459,32 +459,10 @@ enum { MAL0_RCBS1 = 0x1E1, }; -typedef struct ppc4xx_mal_t ppc4xx_mal_t ; -struct ppc4xx_mal_t { -qemu_irq irqs[4 ]; -uint32_t cfg; -uint32_t esr; -uint32_t ier; -uint32_t txcasr; -uint32_t txcarr; -uint32_t txeobisr; -uint32_t txdeir; -uint32_t rxcasr; -uint32_t rxcarr; -uint32_t rxeobisr; -uint32_t rxdeir; -uint32_t *txctpr; -uint32_t *rxctpr; -uint32_t *rcbs; -uint8_t txcnum; -uint8_t rxcnum; -}; - -static void ppc4xx_mal_reset (void *opaque) +static void ppc4xx_mal_reset (DeviceState *dev) { -ppc4xx_mal_t *mal; +Ppc4xxMalState *mal =PPC4xx_MAL (dev); - mal = opaque; mal->cfg =0x0007C000 ; mal->esr =0x00000000 ; mal->ier =0x00000000 ;@@ -498,10 +476,9 @@ static void ppc4xx_mal_reset(void *opaque)static uint32_t dcr_read_mal (void *opaque,int dcrn) { -ppc4xx_mal_t *mal; +Ppc4xxMalState *mal =PPC4xx_MAL (opaque);uint32_t ret; - mal = opaque;switch (dcrn) {case MAL0_CFG : ret = mal->cfg;@@ -555,13 +532,12 @@ static uint32_t dcr_read_mal(void *opaque, int dcrn)static void dcr_write_mal (void *opaque,int dcrn,uint32_t val) { -ppc4xx_mal_t *mal; +Ppc4xxMalState *mal =PPC4xx_MAL (opaque); - mal = opaque;switch (dcrn) {case MAL0_CFG :if (val &0x80000000 ) { -ppc4xx_mal_reset (mal); +ppc4xx_mal_reset (DEVICE (mal)); } mal->cfg = val &0x00FFC087 ;break ;@@ -612,59 +588,67 @@ static void dcr_write_mal(void *opaque, int dcrn, uint32_t val) } } -void ppc4xx_mal_init (CPUPPCState *env,uint8_t txcnum,uint8_t rxcnum, -qemu_irq irqs[4 ]) +static void ppc4xx_mal_realize (DeviceState *dev,Error **errp) { -ppc4xx_mal_t *mal; +Ppc4xxMalState *mal =PPC4xx_MAL (dev); +Ppc4xxDcrDeviceState *dcr =PPC4xx_DCR_DEVICE (dev);int i; -assert (txcnum <=32 && rxcnum <=32 ); - mal =g_malloc0 (sizeof (*mal)); - mal->txcnum = txcnum; - mal->rxcnum = rxcnum; - mal->txctpr =g_new0 (uint32_t, txcnum); - mal->rxctpr =g_new0 (uint32_t, rxcnum); - mal->rcbs =g_new0 (uint32_t, rxcnum); -for (i =0 ; i <4 ; i++) { - mal->irqs[i] = irqs[i]; +if (mal->txcnum >32 || mal->rxcnum >32 ) { +error_setg (errp,"invalid TXC/RXC number" ); +return ; + } + + mal->txctpr =g_new0 (uint32_t, mal->txcnum); + mal->rxctpr =g_new0 (uint32_t, mal->rxcnum); + mal->rcbs =g_new0 (uint32_t, mal->rxcnum); + +for (i =0 ; i <ARRAY_SIZE (mal->irqs); i++) { +sysbus_init_irq (SYS_BUS_DEVICE (dev), &mal->irqs[i]); } -qemu_register_reset (&ppc4xx_mal_reset, mal); -ppc_dcr_register (env,MAL0_CFG , - mal, &dcr_read_mal, &dcr_write_mal); -ppc_dcr_register (env,MAL0_ESR , - mal, &dcr_read_mal, &dcr_write_mal); -ppc_dcr_register (env,MAL0_IER , - mal, &dcr_read_mal, &dcr_write_mal); -ppc_dcr_register (env,MAL0_TXCASR , - mal, &dcr_read_mal, &dcr_write_mal); -ppc_dcr_register (env,MAL0_TXCARR , - mal, &dcr_read_mal, &dcr_write_mal); -ppc_dcr_register (env,MAL0_TXEOBISR , - mal, &dcr_read_mal, &dcr_write_mal); -ppc_dcr_register (env,MAL0_TXDEIR , - mal, &dcr_read_mal, &dcr_write_mal); -ppc_dcr_register (env,MAL0_RXCASR , - mal, &dcr_read_mal, &dcr_write_mal); -ppc_dcr_register (env,MAL0_RXCARR , - mal, &dcr_read_mal, &dcr_write_mal); -ppc_dcr_register (env,MAL0_RXEOBISR , - mal, &dcr_read_mal, &dcr_write_mal); -ppc_dcr_register (env,MAL0_RXDEIR , - mal, &dcr_read_mal, &dcr_write_mal); -for (i =0 ; i < txcnum; i++) { -ppc_dcr_register (env,MAL0_TXCTP0R + i, - mal, &dcr_read_mal, &dcr_write_mal); + +ppc4xx_dcr_register (dcr,MAL0_CFG , &dcr_read_mal, &dcr_write_mal); +ppc4xx_dcr_register (dcr,MAL0_ESR , &dcr_read_mal, &dcr_write_mal); +ppc4xx_dcr_register (dcr,MAL0_IER , &dcr_read_mal, &dcr_write_mal); +ppc4xx_dcr_register (dcr,MAL0_TXCASR , &dcr_read_mal, &dcr_write_mal); +ppc4xx_dcr_register (dcr,MAL0_TXCARR , &dcr_read_mal, &dcr_write_mal); +ppc4xx_dcr_register (dcr,MAL0_TXEOBISR , &dcr_read_mal, &dcr_write_mal); +ppc4xx_dcr_register (dcr,MAL0_TXDEIR , &dcr_read_mal, &dcr_write_mal); +ppc4xx_dcr_register (dcr,MAL0_RXCASR , &dcr_read_mal, &dcr_write_mal); +ppc4xx_dcr_register (dcr,MAL0_RXCARR , &dcr_read_mal, &dcr_write_mal); +ppc4xx_dcr_register (dcr,MAL0_RXEOBISR , &dcr_read_mal, &dcr_write_mal); +ppc4xx_dcr_register (dcr,MAL0_RXDEIR , &dcr_read_mal, &dcr_write_mal); +for (i =0 ; i < mal->txcnum; i++) { +ppc4xx_dcr_register (dcr,MAL0_TXCTP0R + i, + &dcr_read_mal, &dcr_write_mal); } -for (i =0 ; i < rxcnum; i++) { -ppc_dcr_register (env,MAL0_RXCTP0R + i, - mal, &dcr_read_mal, &dcr_write_mal); +for (i =0 ; i < mal->rxcnum; i++) { +ppc4xx_dcr_register (dcr,MAL0_RXCTP0R + i, + &dcr_read_mal, &dcr_write_mal); } -for (i =0 ; i < rxcnum; i++) { -ppc_dcr_register (env,MAL0_RCBS0 + i, - mal, &dcr_read_mal, &dcr_write_mal); +for (i =0 ; i < mal->rxcnum; i++) { +ppc4xx_dcr_register (dcr,MAL0_RCBS0 + i, + &dcr_read_mal, &dcr_write_mal); } } +static Property ppc4xx_mal_properties[] = { +DEFINE_PROP_UINT8 ("txc-num" , Ppc4xxMalState, txcnum,0 ), +DEFINE_PROP_UINT8 ("rxc-num" , Ppc4xxMalState, rxcnum,0 ), +DEFINE_PROP_END_OF_LIST (), +}; + +static void ppc4xx_mal_class_init (ObjectClass *oc,void *data) +{ +DeviceClass *dc =DEVICE_CLASS (oc); + + dc->realize = ppc4xx_mal_realize; + dc->user_creatable = false; +/* Reason: only works as function of a ppc4xx SoC */ + dc->reset = ppc4xx_mal_reset; +device_class_set_props (dc, ppc4xx_mal_properties); +} +void ppc4xx_dcr_register (Ppc4xxDcrDeviceState *dev,int dcrn,dcr_read_cb dcr_read,dcr_write_cb dcr_write) {@@ -699,6 +683,11 @@ static void ppc4xx_dcr_class_init(ObjectClass *oc, void *data)static const TypeInfo ppc4xx_types[] = { { + .name = TYPE_PPC4xx_MAL, + .parent = TYPE_PPC4xx_DCR_DEVICE, + .instance_size =sizeof (Ppc4xxMalState), + .class_init = ppc4xx_mal_class_init, + }, { .name = TYPE_PPC4xx_DCR_DEVICE, .parent =TYPE_SYS_BUS_DEVICE , .instance_size =sizeof (Ppc4xxDcrDeviceState),hw/ppc/sam460ex.c +12
-4@@ -280,7 +280,7 @@ static void sam460ex_init(MachineState *machine)hwaddr ram_sizes[SDRAM_NR_BANKS ] = {0 };MemoryRegion *l2cache_ram =g_new (MemoryRegion,1 );DeviceState *uic[4 ]; -qemu_irq mal_irqs[4 ]; +Ppc4xxMalState *mal;int i;PCIBus *pci_bus;PowerPCCPU *cpu;@@ -387,10 +387,18 @@ static void sam460ex_init(MachineState *machine)ppc4xx_sdr_init (env);/* MAL */ -for (i =0 ; i <ARRAY_SIZE (mal_irqs); i++) { - mal_irqs[i] =qdev_get_gpio_in (uic[2 ],3 + i); + dev =qdev_new (TYPE_PPC4xx_MAL); + mal =PPC4xx_MAL (dev); + +qdev_prop_set_uint32 (dev,"txc-num" ,4 ); +qdev_prop_set_uint32 (dev,"rxc-num" ,16 ); +ppc4xx_dcr_realize (PPC4xx_DCR_DEVICE (mal), cpu, &error_fatal); +object_unref (OBJECT (mal)); + +for (i =0 ; i <ARRAY_SIZE (mal->irqs); i++) { +sysbus_connect_irq (SYS_BUS_DEVICE (dev), i, +qdev_get_gpio_in (uic[2 ],3 + i)); } -ppc4xx_mal_init (env,4 ,16 , mal_irqs);/* DMA */ ppc4xx_dma_init (env,0x200 );
Re: [PATCH v4 18/24] ppc/ppc405: QOM'ify MAL
Quoted 34 lines · BALATON Zoltan
Quoted 33 lines · Cédric Le Goater
The Memory Access Layer (MAL) controller is currently modeled as a DCR device with 4 IRQs. Also drop the
ppc4xx_mal_init()helper and adapt the sam460ex machine.Reviewed-by Daniel Henrique Barboza <[email protected]>Signed-off-by Cédric Le Goater <[email protected]>---
hw/ppc/ppc405.h | 1 +include/hw/ppc/ppc4xx.h| 32 +++++++++-
hw/ppc/ppc405_uc.c | 18 ++++--
hw/ppc/ppc4xx_devs.c | 135 ++++++++++++++++++---------------------- hw/ppc/sam460ex.c | 16 +++--5 files changed, 116 insertions(+), 86 deletions(-)hw/ppc/ppc405.h +1
-0@@ -244,6 +244,7 @@ struct Ppc405SoCState { Ppc405OpbaState opba; Ppc405PobState pob; Ppc405PlbState plb; + Ppc4xxMalState mal; };/* PowerPC 405 core */ include/hw/ppc/ppc4xx.h +0
-0@@ -26,6 +26,7 @@#define PPC4XX_H
Quoted 4 lines
include/hw/ppc/ppc4xx.h line 29
Quoted 2 lines
include/hw/ppc/ppc4xx.h +1
-0#include "hw/ppc/ppc.h" +#include "hw/sysbus.h" This looks odd to me as no line added below seems to need it.
It is a leftover.
Thanks,
C.
Re: [PATCH v4 18/24] ppc/ppc405: QOM'ify MAL
In reply to Cédric Le GoaterQuoted 31 lines · Cédric Le Goater
The Memory Access Layer (MAL) controller is currently modeled as a DCR device with 4 IRQs. Also drop the
ppc4xx_mal_init()helper and adapt the sam460ex machine.Reviewed-by Daniel Henrique Barboza <[email protected]>Signed-off-by Cédric Le Goater <[email protected]>---
hw/ppc/ppc405.h | 1 + include/hw/ppc/ppc4xx.h | 32 +++++++++- hw/ppc/ppc405_uc.c | 18 ++++-- hw/ppc/ppc4xx_devs.c | 135 ++++++++++++++++++---------------------- hw/ppc/sam460ex.c | 16 +++-- 5 files changed, 116 insertions(+), 86 deletions(-)hw/ppc/ppc405.h +1
-0@@ -244,6 +244,7 @@ struct Ppc405SoCState {Ppc405OpbaState opba;Ppc405PobState pob;Ppc405PlbState plb; +Ppc4xxMalState mal; };/* PowerPC 405 core */ include/hw/ppc/ppc4xx.h +0
-0
include/hw/ppc/ppc4xx.h line 29
Quoted 4 lines
include/hw/ppc/ppc4xx.h +1
-0@@ -26,6 +26,7 @@#define PPC4XX_H #include "hw/ppc/ppc.h" +#include "hw/sysbus.h"
Is this needed?
Quoted 34 lines
include/hw/ppc/ppc4xx.h +17
-3#include "exec/memory.h" #include "hw/sysbus.h" @@ -40,9 +41,6 @@ void ppc4xx_sdram_init (CPUPPCState *env, qemu_irq irq, int nbanks,hwaddr *ram_sizes, int do_init); -void ppc4xx_mal_init (CPUPPCState *env,uint8_t txcnum,uint8_t rxcnum, -qemu_irq irqs[4 ]); -#define TYPE_PPC4xx_PCI_HOST_BRIDGE "ppc4xx-pcihost"/* @@ -61,4 +59,32 @@ void ppc4xx_dcr_register(Ppc4xxDcrDeviceState *dev, int dcrn,bool ppc4xx_dcr_realize (Ppc4xxDcrDeviceState *dev,PowerPCCPU *cpu,Error **errp); +/* Memory Access Layer (MAL) */ +#define TYPE_PPC4xx_MAL "ppc4xx-mal" +OBJECT_DECLARE_SIMPLE_TYPE (Ppc4xxMalState, PPC4xx_MAL); +struct Ppc4xxMalState { +Ppc4xxDcrDeviceState parent_obj; + +qemu_irq irqs[4 ]; +uint32_t cfg; +uint32_t esr; +uint32_t ier; +uint32_t txcasr; +uint32_t txcarr; +uint32_t txeobisr; +uint32_t txdeir; +uint32_t rxcasr; +uint32_t rxcarr; +uint32_t rxeobisr;
include/hw/ppc/ppc4xx.h void ppc4xx_dcr_register(Ppc4xxDcrDeviceState *dev, int dcrn, · line 88
Quoted 10 lines
include/hw/ppc/ppc4xx.h +10
-0+uint32_t rxdeir; +uint32_t *txctpr; +uint32_t *rxctpr; +uint32_t *rcbs; +uint8_t txcnum; +uint8_t rxcnum; +}; + +void ppc4xx_mal_init (CPUPPCState *env,uint8_t txcnum,uint8_t rxcnum, +qemu_irq irqs[4 ]);
The ppc4xx_mal_init func is gone so this declaration should also be dropped.
Regards,
BALATON Zoltan
Quoted 272 lines
include/hw/ppc/ppc4xx.h +1
-0+#endif /* PPC4XX_H */ hw/ppc/ppc405_uc.c +12
-6@@ -1368,6 +1368,8 @@ static void ppc405_soc_instance_init(Object *obj)object_initialize_child (obj,"pob" , &s->pob,TYPE_PPC405_POB );object_initialize_child (obj,"plb" , &s->plb,TYPE_PPC405_PLB ); + +object_initialize_child (obj,"mal" , &s->mal, TYPE_PPC4xx_MAL); }static void ppc405_reset (void *opaque)@@ -1378,7 +1380,6 @@ static void ppc405_reset(void *opaque)static void ppc405_soc_realize (DeviceState *dev,Error **errp) {Ppc405SoCState *s =PPC405_SOC (dev); -qemu_irq mal_irqs[4 ];CPUPPCState *env;int i;@@ -1495,11 +1496,16 @@ static void ppc405_soc_realize(DeviceState *dev, Error **errp) }/* MAL */ - mal_irqs[0 ] =qdev_get_gpio_in (s->uic,11 ); - mal_irqs[1 ] =qdev_get_gpio_in (s->uic,12 ); - mal_irqs[2 ] =qdev_get_gpio_in (s->uic,13 ); - mal_irqs[3 ] =qdev_get_gpio_in (s->uic,14 ); -ppc4xx_mal_init (env,4 ,2 , mal_irqs); +object_property_set_int (OBJECT (&s->mal),"txc-num" ,4 , &error_abort); +object_property_set_int (OBJECT (&s->mal),"rxc-num" ,2 , &error_abort); +if (!ppc4xx_dcr_realize (PPC4xx_DCR_DEVICE (&s->mal), &s->cpu, errp)) { +return ; + } + +for (i =0 ; i <ARRAY_SIZE (s->mal.irqs); i++) { +sysbus_connect_irq (SYS_BUS_DEVICE (&s->mal), i, +qdev_get_gpio_in (s->uic,11 + i)); + }/* Ethernet */ /* Uses UIC IRQs 9, 15, 17 */ hw/ppc/ppc4xx_devs.c +62
-73@@ -459,32 +459,10 @@ enum { MAL0_RCBS1 = 0x1E1, }; -typedef struct ppc4xx_mal_t ppc4xx_mal_t ; -struct ppc4xx_mal_t { -qemu_irq irqs[4 ]; -uint32_t cfg; -uint32_t esr; -uint32_t ier; -uint32_t txcasr; -uint32_t txcarr; -uint32_t txeobisr; -uint32_t txdeir; -uint32_t rxcasr; -uint32_t rxcarr; -uint32_t rxeobisr; -uint32_t rxdeir; -uint32_t *txctpr; -uint32_t *rxctpr; -uint32_t *rcbs; -uint8_t txcnum; -uint8_t rxcnum; -}; - -static void ppc4xx_mal_reset (void *opaque) +static void ppc4xx_mal_reset (DeviceState *dev) { -ppc4xx_mal_t *mal; +Ppc4xxMalState *mal =PPC4xx_MAL (dev); - mal = opaque; mal->cfg =0x0007C000 ; mal->esr =0x00000000 ; mal->ier =0x00000000 ;@@ -498,10 +476,9 @@ static void ppc4xx_mal_reset(void *opaque)static uint32_t dcr_read_mal (void *opaque,int dcrn) { -ppc4xx_mal_t *mal; +Ppc4xxMalState *mal =PPC4xx_MAL (opaque);uint32_t ret; - mal = opaque;switch (dcrn) {case MAL0_CFG : ret = mal->cfg;@@ -555,13 +532,12 @@ static uint32_t dcr_read_mal(void *opaque, int dcrn)static void dcr_write_mal (void *opaque,int dcrn,uint32_t val) { -ppc4xx_mal_t *mal; +Ppc4xxMalState *mal =PPC4xx_MAL (opaque); - mal = opaque;switch (dcrn) {case MAL0_CFG :if (val &0x80000000 ) { -ppc4xx_mal_reset (mal); +ppc4xx_mal_reset (DEVICE (mal)); } mal->cfg = val &0x00FFC087 ;break ;@@ -612,59 +588,67 @@ static void dcr_write_mal(void *opaque, int dcrn, uint32_t val) } } -void ppc4xx_mal_init (CPUPPCState *env,uint8_t txcnum,uint8_t rxcnum, -qemu_irq irqs[4 ]) +static void ppc4xx_mal_realize (DeviceState *dev,Error **errp) { -ppc4xx_mal_t *mal; +Ppc4xxMalState *mal =PPC4xx_MAL (dev); +Ppc4xxDcrDeviceState *dcr =PPC4xx_DCR_DEVICE (dev);int i; -assert (txcnum <=32 && rxcnum <=32 ); - mal =g_malloc0 (sizeof (*mal)); - mal->txcnum = txcnum; - mal->rxcnum = rxcnum; - mal->txctpr =g_new0 (uint32_t, txcnum); - mal->rxctpr =g_new0 (uint32_t, rxcnum); - mal->rcbs =g_new0 (uint32_t, rxcnum); -for (i =0 ; i <4 ; i++) { - mal->irqs[i] = irqs[i]; +if (mal->txcnum >32 || mal->rxcnum >32 ) { +error_setg (errp,"invalid TXC/RXC number" ); +return ; + } + + mal->txctpr =g_new0 (uint32_t, mal->txcnum); + mal->rxctpr =g_new0 (uint32_t, mal->rxcnum); + mal->rcbs =g_new0 (uint32_t, mal->rxcnum); + +for (i =0 ; i <ARRAY_SIZE (mal->irqs); i++) { +sysbus_init_irq (SYS_BUS_DEVICE (dev), &mal->irqs[i]); } -qemu_register_reset (&ppc4xx_mal_reset, mal); -ppc_dcr_register (env,MAL0_CFG , - mal, &dcr_read_mal, &dcr_write_mal); -ppc_dcr_register (env,MAL0_ESR , - mal, &dcr_read_mal, &dcr_write_mal); -ppc_dcr_register (env,MAL0_IER , - mal, &dcr_read_mal, &dcr_write_mal); -ppc_dcr_register (env,MAL0_TXCASR , - mal, &dcr_read_mal, &dcr_write_mal); -ppc_dcr_register (env,MAL0_TXCARR , - mal, &dcr_read_mal, &dcr_write_mal); -ppc_dcr_register (env,MAL0_TXEOBISR , - mal, &dcr_read_mal, &dcr_write_mal); -ppc_dcr_register (env,MAL0_TXDEIR , - mal, &dcr_read_mal, &dcr_write_mal); -ppc_dcr_register (env,MAL0_RXCASR , - mal, &dcr_read_mal, &dcr_write_mal); -ppc_dcr_register (env,MAL0_RXCARR , - mal, &dcr_read_mal, &dcr_write_mal); -ppc_dcr_register (env,MAL0_RXEOBISR , - mal, &dcr_read_mal, &dcr_write_mal); -ppc_dcr_register (env,MAL0_RXDEIR , - mal, &dcr_read_mal, &dcr_write_mal); -for (i =0 ; i < txcnum; i++) { -ppc_dcr_register (env,MAL0_TXCTP0R + i, - mal, &dcr_read_mal, &dcr_write_mal); + +ppc4xx_dcr_register (dcr,MAL0_CFG , &dcr_read_mal, &dcr_write_mal); +ppc4xx_dcr_register (dcr,MAL0_ESR , &dcr_read_mal, &dcr_write_mal); +ppc4xx_dcr_register (dcr,MAL0_IER , &dcr_read_mal, &dcr_write_mal); +ppc4xx_dcr_register (dcr,MAL0_TXCASR , &dcr_read_mal, &dcr_write_mal); +ppc4xx_dcr_register (dcr,MAL0_TXCARR , &dcr_read_mal, &dcr_write_mal); +ppc4xx_dcr_register (dcr,MAL0_TXEOBISR , &dcr_read_mal, &dcr_write_mal); +ppc4xx_dcr_register (dcr,MAL0_TXDEIR , &dcr_read_mal, &dcr_write_mal); +ppc4xx_dcr_register (dcr,MAL0_RXCASR , &dcr_read_mal, &dcr_write_mal); +ppc4xx_dcr_register (dcr,MAL0_RXCARR , &dcr_read_mal, &dcr_write_mal); +ppc4xx_dcr_register (dcr,MAL0_RXEOBISR , &dcr_read_mal, &dcr_write_mal); +ppc4xx_dcr_register (dcr,MAL0_RXDEIR , &dcr_read_mal, &dcr_write_mal); +for (i =0 ; i < mal->txcnum; i++) { +ppc4xx_dcr_register (dcr,MAL0_TXCTP0R + i, + &dcr_read_mal, &dcr_write_mal); } -for (i =0 ; i < rxcnum; i++) { -ppc_dcr_register (env,MAL0_RXCTP0R + i, - mal, &dcr_read_mal, &dcr_write_mal); +for (i =0 ; i < mal->rxcnum; i++) { +ppc4xx_dcr_register (dcr,MAL0_RXCTP0R + i, + &dcr_read_mal, &dcr_write_mal); } -for (i =0 ; i < rxcnum; i++) { -ppc_dcr_register (env,MAL0_RCBS0 + i, - mal, &dcr_read_mal, &dcr_write_mal); +for (i =0 ; i < mal->rxcnum; i++) { +ppc4xx_dcr_register (dcr,MAL0_RCBS0 + i, + &dcr_read_mal, &dcr_write_mal); } } +static Property ppc4xx_mal_properties[] = { +DEFINE_PROP_UINT8 ("txc-num" , Ppc4xxMalState, txcnum,0 ), +DEFINE_PROP_UINT8 ("rxc-num" , Ppc4xxMalState, rxcnum,0 ), +DEFINE_PROP_END_OF_LIST (), +}; + +static void ppc4xx_mal_class_init (ObjectClass *oc,void *data) +{ +DeviceClass *dc =DEVICE_CLASS (oc); + + dc->realize = ppc4xx_mal_realize; + dc->user_creatable = false; +/* Reason: only works as function of a ppc4xx SoC */ + dc->reset = ppc4xx_mal_reset; +device_class_set_props (dc, ppc4xx_mal_properties); +} +void ppc4xx_dcr_register (Ppc4xxDcrDeviceState *dev,int dcrn,dcr_read_cb dcr_read,dcr_write_cb dcr_write) {@@ -699,6 +683,11 @@ static void ppc4xx_dcr_class_init(ObjectClass *oc, void *data)static const TypeInfo ppc4xx_types[] = { { + .name = TYPE_PPC4xx_MAL, + .parent = TYPE_PPC4xx_DCR_DEVICE, + .instance_size =sizeof (Ppc4xxMalState), + .class_init = ppc4xx_mal_class_init, + }, { .name = TYPE_PPC4xx_DCR_DEVICE, .parent =TYPE_SYS_BUS_DEVICE , .instance_size =sizeof (Ppc4xxDcrDeviceState),hw/ppc/sam460ex.c +12
-4@@ -280,7 +280,7 @@ static void sam460ex_init(MachineState *machine)hwaddr ram_sizes[SDRAM_NR_BANKS ] = {0 };MemoryRegion *l2cache_ram =g_new (MemoryRegion,1 );DeviceState *uic[4 ]; -qemu_irq mal_irqs[4 ]; +Ppc4xxMalState *mal;int i;PCIBus *pci_bus;PowerPCCPU *cpu;@@ -387,10 +387,18 @@ static void sam460ex_init(MachineState *machine)ppc4xx_sdr_init (env);/* MAL */ -for (i =0 ; i <ARRAY_SIZE (mal_irqs); i++) { - mal_irqs[i] =qdev_get_gpio_in (uic[2 ],3 + i); + dev =qdev_new (TYPE_PPC4xx_MAL); + mal =PPC4xx_MAL (dev); + +qdev_prop_set_uint32 (dev,"txc-num" ,4 ); +qdev_prop_set_uint32 (dev,"rxc-num" ,16 ); +ppc4xx_dcr_realize (PPC4xx_DCR_DEVICE (mal), cpu, &error_fatal); +object_unref (OBJECT (mal)); + +for (i =0 ; i <ARRAY_SIZE (mal->irqs); i++) { +sysbus_connect_irq (SYS_BUS_DEVICE (dev), i, +qdev_get_gpio_in (uic[2 ],3 + i)); } -ppc4xx_mal_init (env,4 ,16 , mal_irqs);/* DMA */ ppc4xx_dma_init (env,0x200 );
PATCH v4 19/24 ppc/ppc405: QOM'ify FPGA
In reply to Cédric Le Goater--- hw/ppc/ppc405_boards.c | 55 +++++++++++++++++++++++++++++------------- 1 file changed, 38 insertions(+), 17 deletions(-)
hw/ppc/ppc405_boards.c +38 -17
@@ -71,18 +71,23 @@ struct Ppc405MachineState {* - NVRAM (0xF0000000) * - FPGA (0xF0300000) */ -typedef struct ref405ep_fpga_t ref405ep_fpga_t ; -struct ref405ep_fpga_t { + +#define TYPE_REF405EP_FPGA "ref405ep-fpga" +OBJECT_DECLARE_SIMPLE_TYPE (Ref405epFpgaState,REF405EP_FPGA ); +struct Ref405epFpgaState { +SysBusDevice parent_obj; + +MemoryRegion iomem; +uint8_t reg0;uint8_t reg1; };static uint64_t ref405ep_fpga_readb (void *opaque,hwaddr addr,unsigned size) { -ref405ep_fpga_t *fpga; +Ref405epFpgaState *fpga =REF405EP_FPGA (opaque);uint32_t ret; - fpga = opaque;switch (addr) {case 0x0 : ret = fpga->reg0;
@@ -101,9 +106,8 @@ static uint64_t ref405ep_fpga_readb(void *opaque, hwaddr addr, unsigned size)static void ref405ep_fpga_writeb (void *opaque,hwaddr addr,uint64_t value,unsigned size) { -ref405ep_fpga_t *fpga; +Ref405epFpgaState *fpga =REF405EP_FPGA (opaque); - fpga = opaque;switch (addr) {case 0x0 :/* Read only */
@@ -126,27 +130,39 @@ static const MemoryRegionOps ref405ep_fpga_ops = { .endianness = DEVICE_BIG_ENDIAN, }; -static void ref405ep_fpga_reset (void *opaque) +static void ref405ep_fpga_reset (DeviceState *dev) { -ref405ep_fpga_t *fpga; +Ref405epFpgaState *fpga =REF405EP_FPGA (dev); - fpga = opaque; fpga->reg0 =0x00 ; fpga->reg1 =0x0F ; } -static void ref405ep_fpga_init (MemoryRegion *sysmem,uint32_t base) +static void ref405ep_fpga_realize (DeviceState *dev,Error **errp) { -ref405ep_fpga_t *fpga; -MemoryRegion *fpga_memory =g_new (MemoryRegion,1 ); +Ref405epFpgaState *s =REF405EP_FPGA (dev); - fpga =g_new0 (ref405ep_fpga_t,1 ); -memory_region_init_io (fpga_memory,NULL , &ref405ep_fpga_ops, fpga, +memory_region_init_io (&s->iomem,OBJECT (s), &ref405ep_fpga_ops, s,"fpga" ,0x00000100 ); -memory_region_add_subregion (sysmem, base, fpga_memory); -qemu_register_reset (&ref405ep_fpga_reset, fpga); +sysbus_init_mmio (SYS_BUS_DEVICE (s), &s->iomem); +} + +static void ref405ep_fpga_class_init (ObjectClass *oc,void *data) +{ +DeviceClass *dc =DEVICE_CLASS (oc); + + dc->realize = ref405ep_fpga_realize; + dc->user_creatable = false; + dc->reset = ref405ep_fpga_reset; } +static const TypeInfo ref405ep_fpga_type = { + .name =TYPE_REF405EP_FPGA , + .parent =TYPE_SYS_BUS_DEVICE , + .instance_size =sizeof (Ref405epFpgaState), + .class_init = ref405ep_fpga_class_init, +}; +/* * CPU reset handler when booting directly from a loaded kernel */
@@ -331,7 +347,11 @@ static void ref405ep_init(MachineState *machine)memory_region_add_subregion (get_system_memory (),PPC405EP_SRAM_BASE , sram);/* Register FPGA */ -ref405ep_fpga_init (get_system_memory (),PPC405EP_FPGA_BASE ); + dev =qdev_new (TYPE_REF405EP_FPGA ); +object_property_add_child (OBJECT (machine),"fpga" ,OBJECT (dev)); +sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal); +sysbus_mmio_map (SYS_BUS_DEVICE (dev),0 ,PPC405EP_FPGA_BASE ); +/* Register NVRAM */ dev =qdev_new ("sysbus-m48t08" );qdev_prop_set_int32 (dev,"base-year" ,1968 );
@@ -376,6 +396,7 @@ static void ppc405_machine_init(void) {type_register_static (&ppc405_machine_type);type_register_static (&ref405ep_type); +type_register_static (&ref405ep_fpga_type); }type_init (ppc405_machine_init)
Signature · 1 line
2.37.1
Re: [PATCH v4 19/24] ppc/ppc405: QOM'ify FPGA
Quoted 76 lines · Cédric Le Goater
Reviewed-by Daniel Henrique Barboza <[email protected]>Signed-off-by Cédric Le Goater <[email protected]>---
hw/ppc/ppc405_boards.c| 55 +++++++++++++++++++++++++++++-------------1 file changed, 38 insertions(+), 17 deletions(-)hw/ppc/ppc405_boards.c +15
-15@@ -71,18 +71,23 @@ struct Ppc405MachineState {* - NVRAM (0xF0000000) * - FPGA (0xF0300000) */ -typedef struct ref405ep_fpga_t ref405ep_fpga_t ; -struct ref405ep_fpga_t { + +#define TYPE_REF405EP_FPGA "ref405ep-fpga" +OBJECT_DECLARE_SIMPLE_TYPE (Ref405epFpgaState,REF405EP_FPGA ); +struct Ref405epFpgaState { +SysBusDevice parent_obj; + +MemoryRegion iomem; +uint8_t reg0;uint8_t reg1; };static uint64_t ref405ep_fpga_readb (void *opaque,hwaddr addr,unsigned size) { -ref405ep_fpga_t *fpga; +Ref405epFpgaState *fpga =REF405EP_FPGA (opaque);uint32_t ret; - fpga = opaque;switch (addr) {case 0x0 : ret = fpga->reg0;@@ -101,9 +106,8 @@ static uint64_t ref405ep_fpga_readb(void *opaque, hwaddr addr, unsigned size)static void ref405ep_fpga_writeb (void *opaque,hwaddr addr,uint64_t value,unsigned size) { -ref405ep_fpga_t *fpga; +Ref405epFpgaState *fpga =REF405EP_FPGA (opaque); - fpga = opaque;switch (addr) {case 0x0 :/* Read only */ @@ -126,27 +130,39 @@ static const MemoryRegionOps ref405ep_fpga_ops = { .endianness = DEVICE_BIG_ENDIAN, }; -static void ref405ep_fpga_reset (void *opaque) +static void ref405ep_fpga_reset (DeviceState *dev) { -ref405ep_fpga_t *fpga; +Ref405epFpgaState *fpga =REF405EP_FPGA (dev); - fpga = opaque; fpga->reg0 =0x00 ; fpga->reg1 =0x0F ; } -static void ref405ep_fpga_init (MemoryRegion *sysmem,uint32_t base) +static void ref405ep_fpga_realize (DeviceState *dev,Error **errp) { -ref405ep_fpga_t *fpga; -MemoryRegion *fpga_memory =g_new (MemoryRegion,1 ); +Ref405epFpgaState *s =REF405EP_FPGA (dev); - fpga =g_new0 (ref405ep_fpga_t,1 ); -memory_region_init_io (fpga_memory,NULL , &ref405ep_fpga_ops, fpga, +memory_region_init_io (&s->iomem,OBJECT (s), &ref405ep_fpga_ops, s,"fpga" ,0x00000100 ); -memory_region_add_subregion (sysmem, base, fpga_memory);
hw/ppc/ppc405_boards.c static const MemoryRegionOps ref405ep_fpga_ops = { · line 155
Quoted 10 lines
hw/ppc/ppc405_boards.c +9
-1-qemu_register_reset (&ref405ep_fpga_reset, fpga); +sysbus_init_mmio (SYS_BUS_DEVICE (s), &s->iomem); +} + +static void ref405ep_fpga_class_init (ObjectClass *oc,void *data) +{ +DeviceClass *dc =DEVICE_CLASS (oc); + + dc->realize = ref405ep_fpga_realize; + dc->user_creatable = false;
Comment missing (and I'd drop unnecessary QOM casts) but otherwise:
Regards,
BALATON Zoltan
Quoted 35 lines
hw/ppc/ppc405_boards.c +14
-1+ dc->reset = ref405ep_fpga_reset; } +static const TypeInfo ref405ep_fpga_type = { + .name =TYPE_REF405EP_FPGA , + .parent =TYPE_SYS_BUS_DEVICE , + .instance_size =sizeof (Ref405epFpgaState), + .class_init = ref405ep_fpga_class_init, +}; +/* * CPU reset handler when booting directly from a loaded kernel */ @@ -331,7 +347,11 @@ static void ref405ep_init(MachineState *machine)memory_region_add_subregion (get_system_memory (),PPC405EP_SRAM_BASE , sram);/* Register FPGA */ -ref405ep_fpga_init (get_system_memory (),PPC405EP_FPGA_BASE ); + dev =qdev_new (TYPE_REF405EP_FPGA ); +object_property_add_child (OBJECT (machine),"fpga" ,OBJECT (dev)); +sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal); +sysbus_mmio_map (SYS_BUS_DEVICE (dev),0 ,PPC405EP_FPGA_BASE ); +/* Register NVRAM */ dev =qdev_new ("sysbus-m48t08" );qdev_prop_set_int32 (dev,"base-year" ,1968 );@@ -376,6 +396,7 @@ static void ppc405_machine_init(void) {type_register_static (&ppc405_machine_type);type_register_static (&ref405ep_type); +type_register_static (&ref405ep_fpga_type); }type_init (ppc405_machine_init)
Re: [PATCH v4 19/24] ppc/ppc405: QOM'ify FPGA
Quoted 81 lines · BALATON Zoltan
Quoted 80 lines · Cédric Le Goater
Reviewed-by Daniel Henrique Barboza <[email protected]>Signed-off-by Cédric Le Goater <[email protected]>---
hw/ppc/ppc405_boards.c| 55 +++++++++++++++++++++++++++++-------------1 file changed, 38 insertions(+), 17 deletions(-)hw/ppc/ppc405_boards.c +9
-4@@ -71,18 +71,23 @@ struct Ppc405MachineState {* - NVRAM (0xF0000000) * - FPGA (0xF0300000) */ -typedef struct ref405ep_fpga_t ref405ep_fpga_t ; -struct ref405ep_fpga_t { + +#define TYPE_REF405EP_FPGA "ref405ep-fpga" +OBJECT_DECLARE_SIMPLE_TYPE (Ref405epFpgaState,REF405EP_FPGA ); +struct Ref405epFpgaState { + SysBusDevice parent_obj; + + MemoryRegion iomem; + uint8_t reg0; uint8_t reg1; };static uint64_t ref405ep_fpga_readb (void *opaque,hwaddr addr,unsigned size) { - ref405ep_fpga_t *fpga; + Ref405epFpgaState *fpga = REF405EP_FPGA(opaque); uint32_t ret; - fpga = opaque; switch (addr) {case
0x0:
ret =fpga->reg0;hw/ppc/ppc405_boards.c +1
-2@@ -101,9 +106,8 @@ static uint64_t ref405ep_fpga_readb(void *opaque, hwaddr addr, unsigned size)static void ref405ep_fpga_writeb (void *opaque,hwaddr addr,uint64_t value, unsigned size) { - ref405ep_fpga_t *fpga; + Ref405epFpgaState *fpga = REF405EP_FPGA(opaque); - fpga = opaque; switch (addr) {case
0x0:
/* Read only */hw/ppc/ppc405_boards.c +8
-10@@ -126,27 +130,39 @@ static const MemoryRegionOps ref405ep_fpga_ops = { .endianness = DEVICE_BIG_ENDIAN, }; -static void ref405ep_fpga_reset (void *opaque) +static void ref405ep_fpga_reset (DeviceState *dev) { - ref405ep_fpga_t *fpga; + Ref405epFpgaState *fpga = REF405EP_FPGA(dev); - fpga = opaque; fpga->reg0 = 0x00; fpga->reg1 = 0x0F; } -static void ref405ep_fpga_init (MemoryRegion *sysmem,uint32_t base) +static void ref405ep_fpga_realize (DeviceState *dev,Error **errp) { - ref405ep_fpga_t *fpga; - MemoryRegion *fpga_memory = g_new(MemoryRegion, 1); + Ref405epFpgaState *s = REF405EP_FPGA(dev); - fpga = g_new0(ref405ep_fpga_t, 1); - memory_region_init_io(fpga_memory, NULL, &ref405ep_fpga_ops, fpga, + memory_region_init_io(&s->iomem, OBJECT(s), &ref405ep_fpga_ops, s, "fpga", 0x00000100); - memory_region_add_subregion(sysmem, base, fpga_memory); - qemu_register_reset(&ref405ep_fpga_reset, fpga); + sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->iomem); +} +
Quoted 8 lines
hw/ppc/ppc405_boards.c static const MemoryRegionOps ref405ep_fpga_ops = { · line 155
Quoted 6 lines
hw/ppc/ppc405_boards.c +6
-0+static void ref405ep_fpga_class_init (ObjectClass *oc,void *data) +{ + DeviceClass *dc = DEVICE_CLASS(oc); + + dc->realize = ref405ep_fpga_realize; + dc->user_creatable = false;Comment missing (and I'd drop unnecessary QOM casts) but otherwise:
Ah yes. I don't think it is worth a v5 for that. I will send a patch fixing the missing comments. There are a few: SoC, MAL, FPGA, SDRAM. Unless Daniel is willing to amend the patches.
Thanks,
C.
Quoted 41 lines
Reviewed-by BALATON Zoltan <[email protected]>Regards,
BALATON ZoltanQuoted 35 lines
hw/ppc/ppc405_boards.c +14
-1+ dc->reset = ref405ep_fpga_reset; } +static const TypeInfo ref405ep_fpga_type = { + .name = TYPE_REF405EP_FPGA, + .parent = TYPE_SYS_BUS_DEVICE, + .instance_size = sizeof(Ref405epFpgaState), + .class_init = ref405ep_fpga_class_init, +}; +/* * CPU reset handler when booting directly from a loaded kernel */ @@ -331,7 +347,11 @@ static void ref405ep_init(MachineState *machine) memory_region_add_subregion(get_system_memory(), PPC405EP_SRAM_BASE, sram); /* Register FPGA */ - ref405ep_fpga_init(get_system_memory(), PPC405EP_FPGA_BASE); + dev = qdev_new(TYPE_REF405EP_FPGA); + object_property_add_child(OBJECT(machine), "fpga", OBJECT(dev)); + sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); + sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, PPC405EP_FPGA_BASE); + /* Register NVRAM */ dev = qdev_new("sysbus-m48t08"); qdev_prop_set_int32(dev, "base-year", 1968);@@ -376,6 +396,7 @@ static void ppc405_machine_init(void) { type_register_static(&ppc405_machine_type); type_register_static(&ref405ep_type); + type_register_static(&ref405ep_fpga_type); }type_init (ppc405_machine_init)
Re: [PATCH v4 19/24] ppc/ppc405: QOM'ify FPGA
Quoted 92 lines · Cédric Le Goater
Quoted 82 lines · BALATON Zoltan
Quoted 81 lines · Cédric Le Goater
Reviewed-by Daniel Henrique Barboza <[email protected]>Signed-off-by Cédric Le Goater <[email protected]>---
hw/ppc/ppc405_boards.c| 55 +++++++++++++++++++++++++++++-------------1 file changed, 38 insertions(+), 17 deletions(-)hw/ppc/ppc405_boards.c +9
-4@@ -71,18 +71,23 @@ struct Ppc405MachineState {* - NVRAM (0xF0000000) * - FPGA (0xF0300000) */ -typedef struct ref405ep_fpga_t ref405ep_fpga_t ; -struct ref405ep_fpga_t { + +#define TYPE_REF405EP_FPGA "ref405ep-fpga" +OBJECT_DECLARE_SIMPLE_TYPE (Ref405epFpgaState,REF405EP_FPGA ); +struct Ref405epFpgaState { + SysBusDevice parent_obj; + + MemoryRegion iomem; + uint8_t reg0; uint8_t reg1; };static uint64_t ref405ep_fpga_readb (void *opaque,hwaddr addr,unsigned size) { - ref405ep_fpga_t *fpga; + Ref405epFpgaState *fpga = REF405EP_FPGA(opaque); uint32_t ret; - fpga = opaque; switch (addr) {case
0x0:
ret =fpga->reg0;hw/ppc/ppc405_boards.c +1
-2@@ -101,9 +106,8 @@ static uint64_t ref405ep_fpga_readb(void *opaque, hwaddr addr, unsigned size) static void ref405ep_fpga_writeb(void *opaque, hwaddr addr, uint64_t value, unsigned size) { - ref405ep_fpga_t *fpga; + Ref405epFpgaState *fpga = REF405EP_FPGA(opaque); - fpga = opaque; switch (addr) {case
0x0:
/* Read only */hw/ppc/ppc405_boards.c +8
-10@@ -126,27 +130,39 @@ static const MemoryRegionOps ref405ep_fpga_ops = { .endianness = DEVICE_BIG_ENDIAN, }; -static void ref405ep_fpga_reset (void *opaque) +static void ref405ep_fpga_reset (DeviceState *dev) { - ref405ep_fpga_t *fpga; + Ref405epFpgaState *fpga = REF405EP_FPGA(dev); - fpga = opaque; fpga->reg0 = 0x00; fpga->reg1 = 0x0F; } -static void ref405ep_fpga_init (MemoryRegion *sysmem,uint32_t base) +static void ref405ep_fpga_realize (DeviceState *dev,Error **errp) { - ref405ep_fpga_t *fpga; - MemoryRegion *fpga_memory = g_new(MemoryRegion, 1); + Ref405epFpgaState *s = REF405EP_FPGA(dev); - fpga = g_new0(ref405ep_fpga_t, 1); - memory_region_init_io(fpga_memory, NULL, &ref405ep_fpga_ops, fpga, + memory_region_init_io(&s->iomem, OBJECT(s), &ref405ep_fpga_ops, s, "fpga", 0x00000100); - memory_region_add_subregion(sysmem, base, fpga_memory); - qemu_register_reset(&ref405ep_fpga_reset, fpga); + sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->iomem); +} +Quoted 8 lines
hw/ppc/ppc405_boards.c static const MemoryRegionOps ref405ep_fpga_ops = { · line 155
Quoted 6 lines
hw/ppc/ppc405_boards.c +6
-0+static void ref405ep_fpga_class_init (ObjectClass *oc,void *data) +{ + DeviceClass *dc = DEVICE_CLASS(oc); + + dc->realize = ref405ep_fpga_realize; + dc->user_creatable = false;Comment missing (and I'd drop unnecessary QOM casts) but otherwise:
Quoted 3 lines
Ah yes. I don't think it is worth a v5 for that. I will send a patch fixing the missing comments. There are a few: SoC, MAL, FPGA, SDRAM. Unless Daniel is willing to amend the patches.
I think you'll need a v5 for other changes anyway so it's easier if you update it too.
Regards,
BALATON Zoltan
Quoted 48 lines
Thanks,
C.
Quoted 41 lines
Reviewed-by BALATON Zoltan <[email protected]>Regards,
BALATON ZoltanQuoted 35 lines
hw/ppc/ppc405_boards.c +14
-1+ dc->reset = ref405ep_fpga_reset; } +static const TypeInfo ref405ep_fpga_type = { + .name = TYPE_REF405EP_FPGA, + .parent = TYPE_SYS_BUS_DEVICE, + .instance_size = sizeof(Ref405epFpgaState), + .class_init = ref405ep_fpga_class_init, +}; +/* * CPU reset handler when booting directly from a loaded kernel */ @@ -331,7 +347,11 @@ static void ref405ep_init(MachineState *machine) memory_region_add_subregion(get_system_memory(), PPC405EP_SRAM_BASE, sram); /* Register FPGA */ - ref405ep_fpga_init(get_system_memory(), PPC405EP_FPGA_BASE); + dev = qdev_new(TYPE_REF405EP_FPGA); + object_property_add_child(OBJECT(machine), "fpga", OBJECT(dev)); + sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); + sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, PPC405EP_FPGA_BASE); + /* Register NVRAM */ dev = qdev_new("sysbus-m48t08"); qdev_prop_set_int32(dev, "base-year", 1968);@@ -376,6 +396,7 @@ static void ppc405_machine_init(void) { type_register_static(&ppc405_machine_type); type_register_static(&ref405ep_type); + type_register_static(&ref405ep_fpga_type); }type_init (ppc405_machine_init)
Re: [PATCH v4 19/24] ppc/ppc405: QOM'ify FPGA
In reply to BALATON ZoltanQuoted 81 lines · BALATON Zoltan
Quoted 80 lines · Cédric Le Goater
Reviewed-by Daniel Henrique Barboza <[email protected]>Signed-off-by Cédric Le Goater <[email protected]>---
hw/ppc/ppc405_boards.c| 55 +++++++++++++++++++++++++++++-------------1 file changed, 38 insertions(+), 17 deletions(-)hw/ppc/ppc405_boards.c +9
-4@@ -71,18 +71,23 @@ struct Ppc405MachineState {* - NVRAM (0xF0000000) * - FPGA (0xF0300000) */ -typedef struct ref405ep_fpga_t ref405ep_fpga_t ; -struct ref405ep_fpga_t { + +#define TYPE_REF405EP_FPGA "ref405ep-fpga" +OBJECT_DECLARE_SIMPLE_TYPE (Ref405epFpgaState,REF405EP_FPGA ); +struct Ref405epFpgaState { + SysBusDevice parent_obj; + + MemoryRegion iomem; + uint8_t reg0; uint8_t reg1; };static uint64_t ref405ep_fpga_readb (void *opaque,hwaddr addr,unsigned size) { - ref405ep_fpga_t *fpga; + Ref405epFpgaState *fpga = REF405EP_FPGA(opaque); uint32_t ret; - fpga = opaque; switch (addr) {case
0x0:
ret =fpga->reg0;hw/ppc/ppc405_boards.c +1
-2@@ -101,9 +106,8 @@ static uint64_t ref405ep_fpga_readb(void *opaque, hwaddr addr, unsigned size)static void ref405ep_fpga_writeb (void *opaque,hwaddr addr,uint64_t value, unsigned size) { - ref405ep_fpga_t *fpga; + Ref405epFpgaState *fpga = REF405EP_FPGA(opaque); - fpga = opaque; switch (addr) {case
0x0:
/* Read only */hw/ppc/ppc405_boards.c +8
-10@@ -126,27 +130,39 @@ static const MemoryRegionOps ref405ep_fpga_ops = { .endianness = DEVICE_BIG_ENDIAN, }; -static void ref405ep_fpga_reset (void *opaque) +static void ref405ep_fpga_reset (DeviceState *dev) { - ref405ep_fpga_t *fpga; + Ref405epFpgaState *fpga = REF405EP_FPGA(dev); - fpga = opaque; fpga->reg0 = 0x00; fpga->reg1 = 0x0F; } -static void ref405ep_fpga_init (MemoryRegion *sysmem,uint32_t base) +static void ref405ep_fpga_realize (DeviceState *dev,Error **errp) { - ref405ep_fpga_t *fpga; - MemoryRegion *fpga_memory = g_new(MemoryRegion, 1); + Ref405epFpgaState *s = REF405EP_FPGA(dev); - fpga = g_new0(ref405ep_fpga_t, 1); - memory_region_init_io(fpga_memory, NULL, &ref405ep_fpga_ops, fpga, + memory_region_init_io(&s->iomem, OBJECT(s), &ref405ep_fpga_ops, s, "fpga", 0x00000100); - memory_region_add_subregion(sysmem, base, fpga_memory); - qemu_register_reset(&ref405ep_fpga_reset, fpga); + sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->iomem); +} +
Quoted 8 lines
hw/ppc/ppc405_boards.c static const MemoryRegionOps ref405ep_fpga_ops = { · line 155
Quoted 6 lines
hw/ppc/ppc405_boards.c +6
-0+static void ref405ep_fpga_class_init (ObjectClass *oc,void *data) +{ + DeviceClass *dc = DEVICE_CLASS(oc); + + dc->realize = ref405ep_fpga_realize; + dc->user_creatable = false;Comment missing (and I'd drop unnecessary QOM casts) but otherwise:
Which QOM casts are you referring to?
Daniel
Quoted 41 lines
Reviewed-by BALATON Zoltan <[email protected]>Regards,
BALATON ZoltanQuoted 35 lines
hw/ppc/ppc405_boards.c +14
-1+ dc->reset = ref405ep_fpga_reset; } +static const TypeInfo ref405ep_fpga_type = { + .name = TYPE_REF405EP_FPGA, + .parent = TYPE_SYS_BUS_DEVICE, + .instance_size = sizeof(Ref405epFpgaState), + .class_init = ref405ep_fpga_class_init, +}; +/* * CPU reset handler when booting directly from a loaded kernel */ @@ -331,7 +347,11 @@ static void ref405ep_init(MachineState *machine) memory_region_add_subregion(get_system_memory(), PPC405EP_SRAM_BASE, sram); /* Register FPGA */ - ref405ep_fpga_init(get_system_memory(), PPC405EP_FPGA_BASE); + dev = qdev_new(TYPE_REF405EP_FPGA); + object_property_add_child(OBJECT(machine), "fpga", OBJECT(dev)); + sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); + sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, PPC405EP_FPGA_BASE); + /* Register NVRAM */ dev = qdev_new("sysbus-m48t08"); qdev_prop_set_int32(dev, "base-year", 1968);@@ -376,6 +396,7 @@ static void ppc405_machine_init(void) { type_register_static(&ppc405_machine_type); type_register_static(&ref405ep_type); + type_register_static(&ref405ep_fpga_type); }type_init (ppc405_machine_init)
Re: [PATCH v4 19/24] ppc/ppc405: QOM'ify FPGA
Quoted 92 lines · Daniel Henrique Barboza
Quoted 82 lines · BALATON Zoltan
Quoted 81 lines · Cédric Le Goater
Reviewed-by Daniel Henrique Barboza <[email protected]>Signed-off-by Cédric Le Goater <[email protected]>---
hw/ppc/ppc405_boards.c| 55 +++++++++++++++++++++++++++++-------------1 file changed, 38 insertions(+), 17 deletions(-)hw/ppc/ppc405_boards.c +9
-4@@ -71,18 +71,23 @@ struct Ppc405MachineState {* - NVRAM (0xF0000000) * - FPGA (0xF0300000) */ -typedef struct ref405ep_fpga_t ref405ep_fpga_t ; -struct ref405ep_fpga_t { + +#define TYPE_REF405EP_FPGA "ref405ep-fpga" +OBJECT_DECLARE_SIMPLE_TYPE (Ref405epFpgaState,REF405EP_FPGA ); +struct Ref405epFpgaState { + SysBusDevice parent_obj; + + MemoryRegion iomem; + uint8_t reg0; uint8_t reg1; };static uint64_t ref405ep_fpga_readb (void *opaque,hwaddr addr,unsigned size) { - ref405ep_fpga_t *fpga; + Ref405epFpgaState *fpga = REF405EP_FPGA(opaque); uint32_t ret; - fpga = opaque; switch (addr) {case
0x0:
ret =fpga->reg0;hw/ppc/ppc405_boards.c +1
-2@@ -101,9 +106,8 @@ static uint64_t ref405ep_fpga_readb(void *opaque, hwaddr addr, unsigned size) static void ref405ep_fpga_writeb(void *opaque, hwaddr addr, uint64_t value, unsigned size) { - ref405ep_fpga_t *fpga; + Ref405epFpgaState *fpga = REF405EP_FPGA(opaque); - fpga = opaque; switch (addr) {case
0x0:
/* Read only */hw/ppc/ppc405_boards.c +8
-10@@ -126,27 +130,39 @@ static const MemoryRegionOps ref405ep_fpga_ops = { .endianness = DEVICE_BIG_ENDIAN, }; -static void ref405ep_fpga_reset (void *opaque) +static void ref405ep_fpga_reset (DeviceState *dev) { - ref405ep_fpga_t *fpga; + Ref405epFpgaState *fpga = REF405EP_FPGA(dev); - fpga = opaque; fpga->reg0 = 0x00; fpga->reg1 = 0x0F; } -static void ref405ep_fpga_init (MemoryRegion *sysmem,uint32_t base) +static void ref405ep_fpga_realize (DeviceState *dev,Error **errp) { - ref405ep_fpga_t *fpga; - MemoryRegion *fpga_memory = g_new(MemoryRegion, 1); + Ref405epFpgaState *s = REF405EP_FPGA(dev); - fpga = g_new0(ref405ep_fpga_t, 1); - memory_region_init_io(fpga_memory, NULL, &ref405ep_fpga_ops, fpga, + memory_region_init_io(&s->iomem, OBJECT(s), &ref405ep_fpga_ops, s, "fpga", 0x00000100); - memory_region_add_subregion(sysmem, base, fpga_memory); - qemu_register_reset(&ref405ep_fpga_reset, fpga); + sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->iomem); +} +Quoted 8 lines
hw/ppc/ppc405_boards.c static const MemoryRegionOps ref405ep_fpga_ops = { · line 155
Quoted 6 lines
hw/ppc/ppc405_boards.c +6
-0+static void ref405ep_fpga_class_init (ObjectClass *oc,void *data) +{ + DeviceClass *dc = DEVICE_CLASS(oc); + + dc->realize = ref405ep_fpga_realize; + dc->user_creatable = false;Comment missing (and I'd drop unnecessary QOM casts) but otherwise:
Quoted 1 line
Which QOM casts are you referring to?
Those that I've discussed in other patches, it's all QOMify patches not only this one. Cédric knows what I mean. But there are other small chnages elsewhere that probably need another version anyway so I think you don't need to do anything with this patch.
Regards,
BALATON Zoltan
Quoted 46 lines
Daniel
Quoted 41 lines
Reviewed-by BALATON Zoltan <[email protected]>Regards,
BALATON ZoltanQuoted 35 lines
hw/ppc/ppc405_boards.c +14
-1+ dc->reset = ref405ep_fpga_reset; } +static const TypeInfo ref405ep_fpga_type = { + .name = TYPE_REF405EP_FPGA, + .parent = TYPE_SYS_BUS_DEVICE, + .instance_size = sizeof(Ref405epFpgaState), + .class_init = ref405ep_fpga_class_init, +}; +/* * CPU reset handler when booting directly from a loaded kernel */ @@ -331,7 +347,11 @@ static void ref405ep_init(MachineState *machine) memory_region_add_subregion(get_system_memory(), PPC405EP_SRAM_BASE, sram); /* Register FPGA */ - ref405ep_fpga_init(get_system_memory(), PPC405EP_FPGA_BASE); + dev = qdev_new(TYPE_REF405EP_FPGA); + object_property_add_child(OBJECT(machine), "fpga", OBJECT(dev)); + sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); + sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, PPC405EP_FPGA_BASE); + /* Register NVRAM */ dev = qdev_new("sysbus-m48t08"); qdev_prop_set_int32(dev, "base-year", 1968);@@ -376,6 +396,7 @@ static void ppc405_machine_init(void) { type_register_static(&ppc405_machine_type); type_register_static(&ref405ep_type); + type_register_static(&ref405ep_fpga_type); }type_init (ppc405_machine_init)
PATCH v4 20/24 ppc/ppc405: Use an embedded PPCUIC model in SoC state
In reply to Cédric Le Goater--- hw/ppc/ppc405.h | 3 ++- hw/ppc/ppc405_uc.c | 26 +++++++++++++------------- 2 files changed, 15 insertions(+), 14 deletions(-)
hw/ppc/ppc405.h +2 -1
@@ -27,6 +27,7 @@#include "qom/object.h" #include "hw/ppc/ppc4xx.h" +#include "hw/intc/ppc-uic.h" #define PPC405EP_SDRAM_BASE 0x00000000#define PPC405EP_NVRAM_BASE 0xF0000000
@@ -234,7 +235,7 @@ struct Ppc405SoCState {hwaddr ram_size;PowerPCCPU cpu; -DeviceState *uic; +PPCUIC uic;Ppc405CpcState cpc;Ppc405GptState gpt;Ppc405OcmState ocm;
hw/ppc/ppc405_uc.c +13 -13
@@ -1350,6 +1350,8 @@ static void ppc405_soc_instance_init(Object *obj)object_initialize_child (obj,"cpu" , &s->cpu,POWERPC_CPU_TYPE_NAME ("405ep" )); +object_initialize_child (obj,"uic" , &s->uic,TYPE_PPC_UIC ); +object_initialize_child (obj,"cpc" , &s->cpc,TYPE_PPC405_CPC );object_property_add_alias (obj,"sys-clk" ,OBJECT (&s->cpc),"sys-clk" );
@@ -1415,17 +1417,15 @@ static void ppc405_soc_realize(DeviceState *dev, Error **errp)sysbus_mmio_map (SYS_BUS_DEVICE (&s->opba),0 ,0xef600600 );/* Universal interrupt controller */ - s->uic =qdev_new (TYPE_PPC_UIC ); - -object_property_set_link (OBJECT (s->uic),"cpu" ,OBJECT (&s->cpu), +object_property_set_link (OBJECT (&s->uic),"cpu" ,OBJECT (&s->cpu), &error_fatal); -if (!sysbus_realize (SYS_BUS_DEVICE (s->uic), errp)) { +if (!sysbus_realize (SYS_BUS_DEVICE (&s->uic), errp)) {return ; } -sysbus_connect_irq (SYS_BUS_DEVICE (s->uic),PPCUIC_OUTPUT_INT , +sysbus_connect_irq (SYS_BUS_DEVICE (&s->uic),PPCUIC_OUTPUT_INT ,qdev_get_gpio_in (DEVICE (&s->cpu), PPC40x_INPUT_INT)); -sysbus_connect_irq (SYS_BUS_DEVICE (s->uic),PPCUIC_OUTPUT_CINT , +sysbus_connect_irq (SYS_BUS_DEVICE (&s->uic),PPCUIC_OUTPUT_CINT ,qdev_get_gpio_in (DEVICE (&s->cpu), PPC40x_INPUT_CINT));/* SDRAM controller */
@@ -1436,7 +1436,7 @@ static void ppc405_soc_realize(DeviceState *dev, Error **errp)"ppc405.sdram0" , s->dram_mr, s->ram_bases[0], s->ram_sizes[0]); -ppc4xx_sdram_init (env,qdev_get_gpio_in (s->uic,17 ),1 , +ppc4xx_sdram_init (env,qdev_get_gpio_in (DEVICE (&s->uic),17 ),1 , s->ram_banks, s->ram_bases, s->ram_sizes, s->do_dram_init);
@@ -1452,12 +1452,12 @@ static void ppc405_soc_realize(DeviceState *dev, Error **errp)for (i =0 ; i <ARRAY_SIZE (s->dma.irqs); i++) {sysbus_connect_irq (SYS_BUS_DEVICE (&s->dma), i, -qdev_get_gpio_in (s->uic,5 + i)); +qdev_get_gpio_in (DEVICE (&s->uic),5 + i)); }/* I2C controller */ sysbus_create_simple (TYPE_PPC4xx_I2C,0xef600500 , -qdev_get_gpio_in (s->uic,2 )); +qdev_get_gpio_in (DEVICE (&s->uic),2 ));/* GPIO */ if (!sysbus_realize (SYS_BUS_DEVICE (&s->gpio), errp)) {
@@ -1468,13 +1468,13 @@ static void ppc405_soc_realize(DeviceState *dev, Error **errp)/* Serial ports */ if (serial_hd (0 ) !=NULL ) {serial_mm_init (get_system_memory (),0xef600300 ,0 , -qdev_get_gpio_in (s->uic,0 ), +qdev_get_gpio_in (DEVICE (&s->uic),0 ),PPC_SERIAL_MM_BAUDBASE ,serial_hd (0 ),DEVICE_BIG_ENDIAN ); }if (serial_hd (1 ) !=NULL ) {serial_mm_init (get_system_memory (),0xef600400 ,0 , -qdev_get_gpio_in (s->uic,1 ), +qdev_get_gpio_in (DEVICE (&s->uic),1 ),PPC_SERIAL_MM_BAUDBASE ,serial_hd (1 ),DEVICE_BIG_ENDIAN ); }
@@ -1492,7 +1492,7 @@ static void ppc405_soc_realize(DeviceState *dev, Error **errp)for (i =0 ; i <ARRAY_SIZE (s->gpt.irqs); i++) {sysbus_connect_irq (SYS_BUS_DEVICE (&s->gpt), i, -qdev_get_gpio_in (s->uic,19 + i)); +qdev_get_gpio_in (DEVICE (&s->uic),19 + i)); }/* MAL */
@@ -1504,7 +1504,7 @@ static void ppc405_soc_realize(DeviceState *dev, Error **errp)for (i =0 ; i <ARRAY_SIZE (s->mal.irqs); i++) {sysbus_connect_irq (SYS_BUS_DEVICE (&s->mal), i, -qdev_get_gpio_in (s->uic,11 + i)); +qdev_get_gpio_in (DEVICE (&s->uic),11 + i)); }/* Ethernet */
Signature · 1 line
2.37.1
Re: [PATCH v4 20/24] ppc/ppc405: Use an embedded PPCUIC model in SoC state
Quoted 2 lines · Cédric Le Goater
Reviewed-by Daniel Henrique Barboza <[email protected]>Signed-off-by Cédric Le Goater <[email protected]>
Quoted 120 lines
---
hw/ppc/ppc405.h| 3 ++-hw/ppc/ppc405_uc.c| 26 +++++++++++++-------------2 files changed, 15 insertions(+), 14 deletions(-)hw/ppc/ppc405.h +2
-1@@ -27,6 +27,7 @@#include "qom/object.h" #include "hw/ppc/ppc4xx.h" +#include "hw/intc/ppc-uic.h" #define PPC405EP_SDRAM_BASE 0x00000000#define PPC405EP_NVRAM_BASE 0xF0000000@@ -234,7 +235,7 @@ struct Ppc405SoCState {hwaddr ram_size;PowerPCCPU cpu; -DeviceState *uic; +PPCUIC uic;Ppc405CpcState cpc;Ppc405GptState gpt;Ppc405OcmState ocm;hw/ppc/ppc405_uc.c +13
-13@@ -1350,6 +1350,8 @@ static void ppc405_soc_instance_init(Object *obj)object_initialize_child (obj,"cpu" , &s->cpu,POWERPC_CPU_TYPE_NAME ("405ep" )); +object_initialize_child (obj,"uic" , &s->uic,TYPE_PPC_UIC ); +object_initialize_child (obj,"cpc" , &s->cpc,TYPE_PPC405_CPC );object_property_add_alias (obj,"sys-clk" ,OBJECT (&s->cpc),"sys-clk" );@@ -1415,17 +1417,15 @@ static void ppc405_soc_realize(DeviceState *dev, Error **errp)sysbus_mmio_map (SYS_BUS_DEVICE (&s->opba),0 ,0xef600600 );/* Universal interrupt controller */ - s->uic =qdev_new (TYPE_PPC_UIC ); - -object_property_set_link (OBJECT (s->uic),"cpu" ,OBJECT (&s->cpu), +object_property_set_link (OBJECT (&s->uic),"cpu" ,OBJECT (&s->cpu), &error_fatal); -if (!sysbus_realize (SYS_BUS_DEVICE (s->uic), errp)) { +if (!sysbus_realize (SYS_BUS_DEVICE (&s->uic), errp)) {return ; } -sysbus_connect_irq (SYS_BUS_DEVICE (s->uic),PPCUIC_OUTPUT_INT , +sysbus_connect_irq (SYS_BUS_DEVICE (&s->uic),PPCUIC_OUTPUT_INT ,qdev_get_gpio_in (DEVICE (&s->cpu), PPC40x_INPUT_INT)); -sysbus_connect_irq (SYS_BUS_DEVICE (s->uic),PPCUIC_OUTPUT_CINT , +sysbus_connect_irq (SYS_BUS_DEVICE (&s->uic),PPCUIC_OUTPUT_CINT ,qdev_get_gpio_in (DEVICE (&s->cpu), PPC40x_INPUT_CINT));/* SDRAM controller */ @@ -1436,7 +1436,7 @@ static void ppc405_soc_realize(DeviceState *dev, Error **errp)"ppc405.sdram0" , s->dram_mr, s->ram_bases[0], s->ram_sizes[0]); -ppc4xx_sdram_init (env,qdev_get_gpio_in (s->uic,17 ),1 , +ppc4xx_sdram_init (env,qdev_get_gpio_in (DEVICE (&s->uic),17 ),1 , s->ram_banks, s->ram_bases, s->ram_sizes, s->do_dram_init);@@ -1452,12 +1452,12 @@ static void ppc405_soc_realize(DeviceState *dev, Error **errp)for (i =0 ; i <ARRAY_SIZE (s->dma.irqs); i++) {sysbus_connect_irq (SYS_BUS_DEVICE (&s->dma), i, -qdev_get_gpio_in (s->uic,5 + i)); +qdev_get_gpio_in (DEVICE (&s->uic),5 + i)); }/* I2C controller */ sysbus_create_simple (TYPE_PPC4xx_I2C,0xef600500 , -qdev_get_gpio_in (s->uic,2 )); +qdev_get_gpio_in (DEVICE (&s->uic),2 ));/* GPIO */ if (!sysbus_realize (SYS_BUS_DEVICE (&s->gpio), errp)) {@@ -1468,13 +1468,13 @@ static void ppc405_soc_realize(DeviceState *dev, Error **errp)/* Serial ports */ if (serial_hd (0 ) !=NULL ) {serial_mm_init (get_system_memory (),0xef600300 ,0 , -qdev_get_gpio_in (s->uic,0 ), +qdev_get_gpio_in (DEVICE (&s->uic),0 ),PPC_SERIAL_MM_BAUDBASE ,serial_hd (0 ),DEVICE_BIG_ENDIAN ); }if (serial_hd (1 ) !=NULL ) {serial_mm_init (get_system_memory (),0xef600400 ,0 , -qdev_get_gpio_in (s->uic,1 ), +qdev_get_gpio_in (DEVICE (&s->uic),1 ),PPC_SERIAL_MM_BAUDBASE ,serial_hd (1 ),DEVICE_BIG_ENDIAN ); }@@ -1492,7 +1492,7 @@ static void ppc405_soc_realize(DeviceState *dev, Error **errp)for (i =0 ; i <ARRAY_SIZE (s->gpt.irqs); i++) {sysbus_connect_irq (SYS_BUS_DEVICE (&s->gpt), i, -qdev_get_gpio_in (s->uic,19 + i)); +qdev_get_gpio_in (DEVICE (&s->uic),19 + i)); }/* MAL */ @@ -1504,7 +1504,7 @@ static void ppc405_soc_realize(DeviceState *dev, Error **errp)for (i =0 ; i <ARRAY_SIZE (s->mal.irqs); i++) {sysbus_connect_irq (SYS_BUS_DEVICE (&s->mal), i, -qdev_get_gpio_in (s->uic,11 + i)); +qdev_get_gpio_in (DEVICE (&s->uic),11 + i)); }/* Ethernet */
PATCH v4 21/24 ppc/ppc405: Use an explicit I2C object
In reply to Cédric Le GoaterHaving an explicit I2C model object will help if one day we want to add I2C devices on the bus from the machine init routine.
--- hw/ppc/ppc405.h | 2 ++ hw/ppc/ppc405_uc.c | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-)
hw/ppc/ppc405.h +2 -0
@@ -28,6 +28,7 @@#include "qom/object.h" #include "hw/ppc/ppc4xx.h" #include "hw/intc/ppc-uic.h" +#include "hw/i2c/ppc4xx_i2c.h" #define PPC405EP_SDRAM_BASE 0x00000000#define PPC405EP_NVRAM_BASE 0xF0000000
@@ -241,6 +242,7 @@ struct Ppc405SoCState {Ppc405OcmState ocm;Ppc405GpioState gpio;Ppc405DmaState dma; +PPC4xxI2CState i2c;Ppc405EbcState ebc;Ppc405OpbaState opba;Ppc405PobState pob;
hw/ppc/ppc405_uc.c +8 -2
@@ -1363,6 +1363,8 @@ static void ppc405_soc_instance_init(Object *obj)object_initialize_child (obj,"dma" , &s->dma,TYPE_PPC405_DMA ); +object_initialize_child (obj,"i2c" , &s->i2c, TYPE_PPC4xx_I2C); +object_initialize_child (obj,"ebc" , &s->ebc,TYPE_PPC405_EBC );object_initialize_child (obj,"opba" , &s->opba,TYPE_PPC405_OPBA );
@@ -1456,8 +1458,12 @@ static void ppc405_soc_realize(DeviceState *dev, Error **errp) }/* I2C controller */ -sysbus_create_simple (TYPE_PPC4xx_I2C,0xef600500 , -qdev_get_gpio_in (DEVICE (&s->uic),2 )); +if (!sysbus_realize (SYS_BUS_DEVICE (&s->i2c), errp)) { +return ; + } +sysbus_mmio_map (SYS_BUS_DEVICE (&s->i2c),0 ,0xef600500 ); +sysbus_connect_irq (SYS_BUS_DEVICE (&s->i2c),0 , +qdev_get_gpio_in (DEVICE (&s->uic),2 ));/* GPIO */ if (!sysbus_realize (SYS_BUS_DEVICE (&s->gpio), errp)) {
Signature · 1 line
2.37.1
Re: [PATCH v4 21/24] ppc/ppc405: Use an explicit I2C object
Quoted 9 lines · Cédric Le Goater
Having an explicit I2C model object will help if one day we want to add I2C devices on the bus from the machine init routine.
Reviewed-by Daniel Henrique Barboza <[email protected]>Signed-off-by Cédric Le Goater <[email protected]>---
hw/ppc/ppc405.h| 2 ++hw/ppc/ppc405_uc.c| 10 ++++++++--2 files changed, 10 insertions(+), 2 deletions(-)
This just seems to turn 2 lines into 10 for no apparent reason so I don't see what is this patch is good for but I don't really mind. I this is really needed to add an i2c device then maybe we have a problem in QEMU which makes it more difficult to access things than it should be. There should be a way to get a bus without havnig to have a pointer to the controller or again we need a way to navigate the qom three here.
But this is only a comment not a complaint as I've said above I don't mind.
Regards,
BALATON Zoltan
Quoted 50 lines
hw/ppc/ppc405.h +2
-0@@ -28,6 +28,7 @@#include "qom/object.h" #include "hw/ppc/ppc4xx.h" #include "hw/intc/ppc-uic.h" +#include "hw/i2c/ppc4xx_i2c.h" #define PPC405EP_SDRAM_BASE 0x00000000#define PPC405EP_NVRAM_BASE 0xF0000000@@ -241,6 +242,7 @@ struct Ppc405SoCState {Ppc405OcmState ocm;Ppc405GpioState gpio;Ppc405DmaState dma; +PPC4xxI2CState i2c;Ppc405EbcState ebc;Ppc405OpbaState opba;Ppc405PobState pob;hw/ppc/ppc405_uc.c +8
-2@@ -1363,6 +1363,8 @@ static void ppc405_soc_instance_init(Object *obj)object_initialize_child (obj,"dma" , &s->dma,TYPE_PPC405_DMA ); +object_initialize_child (obj,"i2c" , &s->i2c, TYPE_PPC4xx_I2C); +object_initialize_child (obj,"ebc" , &s->ebc,TYPE_PPC405_EBC );object_initialize_child (obj,"opba" , &s->opba,TYPE_PPC405_OPBA );@@ -1456,8 +1458,12 @@ static void ppc405_soc_realize(DeviceState *dev, Error **errp) }/* I2C controller */ -sysbus_create_simple (TYPE_PPC4xx_I2C,0xef600500 , -qdev_get_gpio_in (DEVICE (&s->uic),2 )); +if (!sysbus_realize (SYS_BUS_DEVICE (&s->i2c), errp)) { +return ; + } +sysbus_mmio_map (SYS_BUS_DEVICE (&s->i2c),0 ,0xef600500 ); +sysbus_connect_irq (SYS_BUS_DEVICE (&s->i2c),0 , +qdev_get_gpio_in (DEVICE (&s->uic),2 ));/* GPIO */ if (!sysbus_realize (SYS_BUS_DEVICE (&s->gpio), errp)) {
PATCH v4 22/24 ppc/ppc4xx: Fix sdram trace events
In reply to Cédric Le Goater--- hw/ppc/ppc4xx_devs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/ppc/ppc4xx_devs.c +1 -1
@@ -143,7 +143,7 @@ static void sdram_set_bcr(ppc4xx_sdram_t *sdram, int i, } sdram->bcr[i] = bcr &0xFFDEE001 ;if (enabled && (bcr &0x00000001 )) { -trace_ppc4xx_sdram_unmap (sdram_base (bcr),sdram_size (bcr)); +trace_ppc4xx_sdram_map (sdram_base (bcr),sdram_size (bcr));memory_region_init (&sdram->containers[i],NULL ,"sdram-containers" ,sdram_size (bcr)); memory_region_add_subregion(&sdram->containers[i], 0,
Signature · 1 line
2.37.1
Re: [PATCH v4 22/24] ppc/ppc4xx: Fix sdram trace events
Quoted 1 line · Cédric Le Goater
Signed-off-by Cédric Le Goater <[email protected]>
Quoted 18 lines
---
hw/ppc/ppc4xx_devs.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)hw/ppc/ppc4xx_devs.c +1
-1@@ -143,7 +143,7 @@ static void sdram_set_bcr(ppc4xx_sdram_t *sdram, int i, } sdram->bcr[i] = bcr &0xFFDEE001 ;if (enabled && (bcr &0x00000001 )) { -trace_ppc4xx_sdram_unmap (sdram_base (bcr),sdram_size (bcr)); +trace_ppc4xx_sdram_map (sdram_base (bcr),sdram_size (bcr));memory_region_init (&sdram->containers[i],NULL ,"sdram-containers" ,sdram_size (bcr)); memory_region_add_subregion(&sdram->containers[i], 0,
PATCH v4 23/24 ppc/ppc405: QOM'ify SDRAM
In reply to Cédric Le GoaterThis is an initial change of the SDRAM controller preserving the compatibility with the current modeling. Further cleanup will be possible after conversion of the ppc4xx_sdram_banks() and ppc4xx_sdram_init() routines of the sam460ex and bamboo machines.
The size and base address of the RAM banks are now set using QOM property arrays. RAM is equally distributed on each bank at the SoC level depending on the number of banks we want to initialize (default is 2). Each RAM memory region representing a RAM bank is initialized in the realize routine of the SDRAM model after a minimal check on the RAM size value with the sdram_bcr() routine. This has the benefit of reporting an error to the user if the requested RAM size is invalid for the SDRAM controller.
--- hw/ppc/ppc405.h | 6 +-- include/hw/ppc/ppc4xx.h | 32 ++++++++++++ hw/ppc/ppc405_uc.c | 34 ++++++++---- hw/ppc/ppc4xx_devs.c | 113 ++++++++++++++++++++++++++++------------ 4 files changed, 140 insertions(+), 45 deletions(-)
hw/ppc/ppc405.h +2 -4
@@ -228,12 +228,9 @@ struct Ppc405SoCState {DeviceState parent_obj;/* Public */ -MemoryRegion ram_banks[2 ]; -hwaddr ram_bases[2 ], ram_sizes[2 ]; -bool do_dram_init; -MemoryRegion *dram_mr;hwaddr ram_size; +uint32_t nr_banks;PowerPCCPU cpu;PPCUIC uic;
@@ -241,6 +238,7 @@ struct Ppc405SoCState {Ppc405GptState gpt;Ppc405OcmState ocm;Ppc405GpioState gpio; +Ppc4xxSdramState sdram;Ppc405DmaState dma;PPC4xxI2CState i2c;Ppc405EbcState ebc;
include/hw/ppc/ppc4xx.h +32 -0
@@ -87,4 +87,36 @@ struct Ppc4xxMalState {void ppc4xx_mal_init (CPUPPCState *env,uint8_t txcnum,uint8_t rxcnum,qemu_irq irqs[4 ]); +/* SDRAM controller */ +#define TYPE_PPC4xx_SDRAM "ppc4xx-sdram" +OBJECT_DECLARE_SIMPLE_TYPE (Ppc4xxSdramState, PPC4xx_SDRAM); +struct Ppc4xxSdramState { +Ppc4xxDcrDeviceState parent_obj; + +MemoryRegion *dram_mr; +bool dram_init; + +MemoryRegion containers[4 ];/* used for clipping */ +MemoryRegion *ram_memories; +hwaddr *ram_bases; +hwaddr *ram_sizes; +uint32_t nb_ram_bases; +uint32_t nb_ram_sizes; +uint32_t nbanks;/* Redundant */ + +uint32_t addr; +uint32_t besr0; +uint32_t besr1; +uint32_t bear; +uint32_t cfg; +uint32_t status; +uint32_t rtr; +uint32_t pmit; +uint32_t bcr[4 ]; +uint32_t tr; +uint32_t ecccfg; +uint32_t eccesr; +qemu_irq irq; +}; +#endif /* PPC4XX_H */
hw/ppc/ppc405_uc.c +25 -9
@@ -1361,6 +1361,9 @@ static void ppc405_soc_instance_init(Object *obj)object_initialize_child (obj,"gpio" , &s->gpio,TYPE_PPC405_GPIO ); +object_initialize_child (obj,"sdram" , &s->sdram, TYPE_PPC4xx_SDRAM); +object_property_add_alias (obj,"dram-init" ,OBJECT (&s->sdram),"dram-init" ); +object_initialize_child (obj,"dma" , &s->dma,TYPE_PPC405_DMA );object_initialize_child (obj,"i2c" , &s->i2c, TYPE_PPC4xx_I2C);
@@ -1432,15 +1435,28 @@ static void ppc405_soc_realize(DeviceState *dev, Error **errp)/* SDRAM controller */ /* XXX 405EP has no ECC interrupt */ - s->ram_bases[0 ] =0 ; - s->ram_sizes[0 ] = s->ram_size; -memory_region_init_alias (&s->ram_banks[0 ],OBJECT (s), -"ppc405.sdram0" , s->dram_mr, - s->ram_bases[0 ], s->ram_sizes[0 ]); +object_property_set_link (OBJECT (&s->sdram),"dram" ,OBJECT (s->dram_mr), + &error_abort); + +qdev_prop_set_uint32 (DEVICE (&s->sdram),"len-ram-sizes" , s->nr_banks); +qdev_prop_set_uint32 (DEVICE (&s->sdram),"len-ram-bases" , s->nr_banks); -ppc4xx_sdram_init (env,qdev_get_gpio_in (DEVICE (&s->uic),17 ),1 , - s->ram_banks, s->ram_bases, s->ram_sizes, - s->do_dram_init); +for (i =0 ; i < s->nr_banks; i++) { +char name[32 ]; +snprintf (name,sizeof (name),"ram-bases[%d]" , i); +qdev_prop_set_uint32 (DEVICE (&s->sdram), name, + i * s->ram_size / s->nr_banks); + +snprintf (name,sizeof (name),"ram-sizes[%d]" , i); +qdev_prop_set_uint32 (DEVICE (&s->sdram), name, + s->ram_size / s->nr_banks); + } + +if (!ppc4xx_dcr_realize (PPC4xx_DCR_DEVICE (&s->sdram), &s->cpu, errp)) { +return ; + } +sysbus_connect_irq (SYS_BUS_DEVICE (&s->sdram),0 , +qdev_get_gpio_in (DEVICE (&s->uic),17 ));/* External bus controller */ if (!ppc4xx_dcr_realize (PPC4xx_DCR_DEVICE (&s->ebc), &s->cpu, errp)) {
@@ -1520,7 +1536,7 @@ static void ppc405_soc_realize(DeviceState *dev, Error **errp)static Property ppc405_soc_properties[] = {DEFINE_PROP_LINK ("dram" , Ppc405SoCState, dram_mr,TYPE_MEMORY_REGION , MemoryRegion *), -DEFINE_PROP_BOOL ("dram-init" , Ppc405SoCState, do_dram_init,0 ), +DEFINE_PROP_UINT32 ("nr-banks" , Ppc405SoCState, nr_banks,2 ),DEFINE_PROP_UINT64 ("ram-size" , Ppc405SoCState, ram_size,0 ),DEFINE_PROP_END_OF_LIST (), };
hw/ppc/ppc4xx_devs.c +81 -32
182 lines not on this page · raw message
Signature · 1 line
2.37.1
Re: [PATCH v4 23/24] ppc/ppc405: QOM'ify SDRAM
Quoted 5 lines · Cédric Le Goater
This is an initial change of the SDRAM controller preserving the compatibility with the current modeling. Further cleanup will be possible after conversion of the
ppc4xx_sdram_banks()andppc4xx_sdram_init()routines of the sam460ex and bamboo machines.
Quoted 8 lines
The size and base address of the RAM banks are now set using QOM property arrays. RAM is equally distributed on each bank at the SoC level depending on the number of banks we want to initialize (default is 2). Each RAM memory region representing a RAM bank is initialized in the realize routine of the SDRAM model after a minimal check on the RAM size value with the
sdram_bcr()routine. This has the benefit of reporting an error to the user if the requested RAM size is invalid for the SDRAM controller.
Haven't looked at it in detail yet but I think we have two versions of this (one in ppc4xx_devs.c and another in ppc440_uc.c) that are slightly different due to the differences of the memory controllers of later SoCs. I'm not sure how to clean this up and forgot most of the details about this.
Regards,
BALATON Zoltan
Quoted 331 lines
Signed-off-by Cédric Le Goater <[email protected]>---
hw/ppc/ppc405.h | 6 +-- include/hw/ppc/ppc4xx.h | 32 ++++++++++++ hw/ppc/ppc405_uc.c | 34 ++++++++---- hw/ppc/ppc4xx_devs.c | 113 ++++++++++++++++++++++++++++------------ 4 files changed, 140 insertions(+), 45 deletions(-)hw/ppc/ppc405.h +2
-4@@ -228,12 +228,9 @@ struct Ppc405SoCState {DeviceState parent_obj;/* Public */ -MemoryRegion ram_banks[2 ]; -hwaddr ram_bases[2 ], ram_sizes[2 ]; -bool do_dram_init; -MemoryRegion *dram_mr;hwaddr ram_size; +uint32_t nr_banks;PowerPCCPU cpu;PPCUIC uic;@@ -241,6 +238,7 @@ struct Ppc405SoCState {Ppc405GptState gpt;Ppc405OcmState ocm;Ppc405GpioState gpio; +Ppc4xxSdramState sdram;Ppc405DmaState dma;PPC4xxI2CState i2c;Ppc405EbcState ebc;include/hw/ppc/ppc4xx.h +32
-0@@ -87,4 +87,36 @@ struct Ppc4xxMalState {void ppc4xx_mal_init (CPUPPCState *env,uint8_t txcnum,uint8_t rxcnum,qemu_irq irqs[4 ]); +/* SDRAM controller */ +#define TYPE_PPC4xx_SDRAM "ppc4xx-sdram" +OBJECT_DECLARE_SIMPLE_TYPE (Ppc4xxSdramState, PPC4xx_SDRAM); +struct Ppc4xxSdramState { +Ppc4xxDcrDeviceState parent_obj; + +MemoryRegion *dram_mr; +bool dram_init; + +MemoryRegion containers[4 ];/* used for clipping */ +MemoryRegion *ram_memories; +hwaddr *ram_bases; +hwaddr *ram_sizes; +uint32_t nb_ram_bases; +uint32_t nb_ram_sizes; +uint32_t nbanks;/* Redundant */ + +uint32_t addr; +uint32_t besr0; +uint32_t besr1; +uint32_t bear; +uint32_t cfg; +uint32_t status; +uint32_t rtr; +uint32_t pmit; +uint32_t bcr[4 ]; +uint32_t tr; +uint32_t ecccfg; +uint32_t eccesr; +qemu_irq irq; +}; +#endif /* PPC4XX_H */ hw/ppc/ppc405_uc.c +25
-9@@ -1361,6 +1361,9 @@ static void ppc405_soc_instance_init(Object *obj)object_initialize_child (obj,"gpio" , &s->gpio,TYPE_PPC405_GPIO ); +object_initialize_child (obj,"sdram" , &s->sdram, TYPE_PPC4xx_SDRAM); +object_property_add_alias (obj,"dram-init" ,OBJECT (&s->sdram),"dram-init" ); +object_initialize_child (obj,"dma" , &s->dma,TYPE_PPC405_DMA );object_initialize_child (obj,"i2c" , &s->i2c, TYPE_PPC4xx_I2C);@@ -1432,15 +1435,28 @@ static void ppc405_soc_realize(DeviceState *dev, Error **errp)/* SDRAM controller */ /* XXX 405EP has no ECC interrupt */ - s->ram_bases[0 ] =0 ; - s->ram_sizes[0 ] = s->ram_size; -memory_region_init_alias (&s->ram_banks[0 ],OBJECT (s), -"ppc405.sdram0" , s->dram_mr, - s->ram_bases[0 ], s->ram_sizes[0 ]); +object_property_set_link (OBJECT (&s->sdram),"dram" ,OBJECT (s->dram_mr), + &error_abort); + +qdev_prop_set_uint32 (DEVICE (&s->sdram),"len-ram-sizes" , s->nr_banks); +qdev_prop_set_uint32 (DEVICE (&s->sdram),"len-ram-bases" , s->nr_banks); -ppc4xx_sdram_init (env,qdev_get_gpio_in (DEVICE (&s->uic),17 ),1 , - s->ram_banks, s->ram_bases, s->ram_sizes, - s->do_dram_init); +for (i =0 ; i < s->nr_banks; i++) { +char name[32 ]; +snprintf (name,sizeof (name),"ram-bases[%d]" , i); +qdev_prop_set_uint32 (DEVICE (&s->sdram), name, + i * s->ram_size / s->nr_banks); + +snprintf (name,sizeof (name),"ram-sizes[%d]" , i); +qdev_prop_set_uint32 (DEVICE (&s->sdram), name, + s->ram_size / s->nr_banks); + } + +if (!ppc4xx_dcr_realize (PPC4xx_DCR_DEVICE (&s->sdram), &s->cpu, errp)) { +return ; + } +sysbus_connect_irq (SYS_BUS_DEVICE (&s->sdram),0 , +qdev_get_gpio_in (DEVICE (&s->uic),17 ));/* External bus controller */ if (!ppc4xx_dcr_realize (PPC4xx_DCR_DEVICE (&s->ebc), &s->cpu, errp)) {@@ -1520,7 +1536,7 @@ static void ppc405_soc_realize(DeviceState *dev, Error **errp)static Property ppc405_soc_properties[] = {DEFINE_PROP_LINK ("dram" , Ppc405SoCState, dram_mr,TYPE_MEMORY_REGION , MemoryRegion *), -DEFINE_PROP_BOOL ("dram-init" , Ppc405SoCState, do_dram_init,0 ), +DEFINE_PROP_UINT32 ("nr-banks" , Ppc405SoCState, nr_banks,2 ),DEFINE_PROP_UINT64 ("ram-size" , Ppc405SoCState, ram_size,0 ),DEFINE_PROP_END_OF_LIST (), };hw/ppc/ppc4xx_devs.c +81
-32@@ -39,28 +39,6 @@/*****************************************************************************/ /* SDRAM controller */ -typedef struct ppc4xx_sdram_t ppc4xx_sdram_t ; -struct ppc4xx_sdram_t { -uint32_t addr; -int nbanks; -MemoryRegion containers[4 ];/* used for clipping */ -MemoryRegion *ram_memories; -hwaddr ram_bases[4 ]; -hwaddr ram_sizes[4 ]; -uint32_t besr0; -uint32_t besr1; -uint32_t bear; -uint32_t cfg; -uint32_t status; -uint32_t rtr; -uint32_t pmit; -uint32_t bcr[4 ]; -uint32_t tr; -uint32_t ecccfg; -uint32_t eccesr; -qemu_irq irq; -}; -enum {SDRAM0_CFGADDR =0x010 ,SDRAM0_CFGDATA =0x011 ,@@ -128,7 +106,7 @@ static target_ulong sdram_size (uint32_t bcr)return size; } -static void sdram_set_bcr (ppc4xx_sdram_t *sdram,int i, +static void sdram_set_bcr (Ppc4xxSdramState *sdram,int i,uint32_t bcr,int enabled) {if (sdram->bcr[i] &0x00000001 ) {@@ -154,7 +132,7 @@ static void sdram_set_bcr(ppc4xx_sdram_t *sdram, int i, } } -static void sdram_map_bcr (ppc4xx_sdram_t *sdram) +static void sdram_map_bcr (Ppc4xxSdramState *sdram) {int i;@@ -168,7 +146,7 @@ static void sdram_map_bcr (ppc4xx_sdram_t *sdram) } } -static void sdram_unmap_bcr (ppc4xx_sdram_t *sdram) +static void sdram_unmap_bcr (Ppc4xxSdramState *sdram) {int i;@@ -182,7 +160,7 @@ static void sdram_unmap_bcr (ppc4xx_sdram_t *sdram)static uint32_t dcr_read_sdram (void *opaque,int dcrn) { -ppc4xx_sdram_t *sdram; +Ppc4xxSdramState *sdram;uint32_t ret; sdram = opaque;@@ -250,7 +228,7 @@ static uint32_t dcr_read_sdram (void *opaque, int dcrn)static void dcr_write_sdram (void *opaque,int dcrn,uint32_t val) { -ppc4xx_sdram_t *sdram; +Ppc4xxSdramState *sdram; sdram = opaque;switch (dcrn) {@@ -329,11 +307,10 @@ static void dcr_write_sdram (void *opaque, int dcrn, uint32_t val) } } -static void sdram_reset (void *opaque) +static void ppc4xx_sdram_reset (DeviceState *dev) { -ppc4xx_sdram_t *sdram; +Ppc4xxSdramState *sdram = (Ppc4xxSdramState *) dev; - sdram = opaque; sdram->addr =0x00000000 ; sdram->bear =0x00000000 ; sdram->besr0 =0x00000000 ;/* No error */ @@ -349,21 +326,88 @@ static void sdram_reset (void *opaque) sdram->cfg =0x00800000 ; } +static void sdram_reset (void *opaque) +{ +ppc4xx_sdram_reset (opaque); +} + +static void ppc4xx_sdram_realize (DeviceState *dev,Error **errp) +{ +Ppc4xxSdramState *s =PPC4xx_SDRAM (dev); +Ppc4xxDcrDeviceState *dcr =PPC4xx_DCR_DEVICE (dev); +int i; + +sysbus_init_irq (SYS_BUS_DEVICE (dev), &s->irq); + +ppc4xx_dcr_register (dcr,SDRAM0_CFGADDR , &dcr_read_sdram, &dcr_write_sdram); +ppc4xx_dcr_register (dcr,SDRAM0_CFGDATA , &dcr_read_sdram, &dcr_write_sdram); + +if (!s->nb_ram_bases || s->nb_ram_bases != s->nb_ram_sizes) { +error_setg (errp,"Invalid number of RAM banks" ); +return ; + } + + s->ram_memories =g_new0 (MemoryRegion, s->nb_ram_bases); +for (i =0 ; i < s->nb_ram_bases; i++) { + g_autofree char *name = g_strdup_printf(TYPE_PPC4xx_SDRAM "%d", i); + +if (!sdram_bcr (s->ram_bases[i], s->ram_sizes[i])) { +error_setg (errp,"Invalid RAM size 0x%" HWADDR_PRIx, + s->ram_sizes[i]); +return ; + } + +memory_region_init_alias (&s->ram_memories[i],OBJECT (s), name, + s->dram_mr, s->ram_bases[i], s->ram_sizes[i]); + } + + s->nbanks = s->nb_ram_sizes; +if (s->dram_init) { +sdram_map_bcr (s); + } +} + +static Property ppc4xx_sdram_properties[] = { +DEFINE_PROP_LINK ("dram" , Ppc4xxSdramState, dram_mr,TYPE_MEMORY_REGION , + MemoryRegion *), +DEFINE_PROP_BOOL ("dram-init" , Ppc4xxSdramState, dram_init, false), +DEFINE_PROP_ARRAY ("ram-sizes" , Ppc4xxSdramState, nb_ram_sizes, + ram_sizes, qdev_prop_uint64, uint64_t), +DEFINE_PROP_ARRAY ("ram-bases" , Ppc4xxSdramState, nb_ram_bases, + ram_bases, qdev_prop_uint64, uint64_t), +DEFINE_PROP_END_OF_LIST (), +}; + +static void ppc4xx_sdram_class_init (ObjectClass *oc,void *data) +{ +DeviceClass *dc =DEVICE_CLASS (oc); + + dc->realize = ppc4xx_sdram_realize; + dc->user_creatable = false; + dc->reset = ppc4xx_sdram_reset; +device_class_set_props (dc, ppc4xx_sdram_properties); +} +void ppc4xx_sdram_init (CPUPPCState *env,qemu_irq irq,int nbanks,MemoryRegion *ram_memories,hwaddr *ram_bases,hwaddr *ram_sizes,int do_init) { -ppc4xx_sdram_t *sdram; +Ppc4xxSdramState *sdram; - sdram =g_new0 (ppc4xx_sdram_t,1 ); + sdram =g_new0 (Ppc4xxSdramState,1 ); sdram->irq = irq; sdram->nbanks = nbanks; sdram->ram_memories = ram_memories; + + sdram->ram_bases =g_new0 (hwaddr,4 ); +memset (sdram->ram_bases,0 ,4 *sizeof (hwaddr));memcpy (sdram->ram_bases, ram_bases, nbanks *sizeof (hwaddr)); + + sdram->ram_sizes =g_new0 (hwaddr,4 );memset (sdram->ram_sizes,0 ,4 *sizeof (hwaddr));memcpy (sdram->ram_sizes, ram_sizes, nbanks *sizeof (hwaddr));@@ -683,6 +727,11 @@ static void ppc4xx_dcr_class_init(ObjectClass *oc, void *data)static const TypeInfo ppc4xx_types[] = { { + .name = TYPE_PPC4xx_SDRAM, + .parent = TYPE_PPC4xx_DCR_DEVICE, + .instance_size =sizeof (Ppc4xxSdramState), + .class_init = ppc4xx_sdram_class_init, + }, { .name = TYPE_PPC4xx_MAL, .parent = TYPE_PPC4xx_DCR_DEVICE, .instance_size =sizeof (Ppc4xxMalState),
Re: [PATCH v4 23/24] ppc/ppc405: QOM'ify SDRAM
Quoted 15 lines · BALATON Zoltan
Quoted 5 lines · Cédric Le Goater
This is an initial change of the SDRAM controller preserving the compatibility with the current modeling. Further cleanup will be possible after conversion of the
ppc4xx_sdram_banks()andppc4xx_sdram_init()routines of the sam460ex and bamboo machines.Quoted 8 lines
The size and base address of the RAM banks are now set using QOM property arrays. RAM is equally distributed on each bank at the SoC level depending on the number of banks we want to initialize (default is 2). Each RAM memory region representing a RAM bank is initialized in the realize routine of the SDRAM model after a minimal check on the RAM size value with the
sdram_bcr()routine. This has the benefit of reporting an error to the user if the requested RAM size is invalid for the SDRAM controller.
Quoted 1 line
Haven't looked at it in detail yet but I think we have two versions of this (one in
ppc4xx_devs.cand another inppc440_uc.c) that are slightly different due to the differences of the memory controllers of later SoCs. I'm not sure how to clean this up and forgot most of the details about this.
AFAICT We need a Ppc4xxSdramClass to abstract the differences.
Thanks,
C.
Quoted 335 lines
Regards,
BALATON ZoltanQuoted 331 lines
Signed-off-by Cédric Le Goater <[email protected]>---
hw/ppc/ppc405.h | 6 +--include/hw/ppc/ppc4xx.h| 32 ++++++++++++ hw/ppc/ppc405_uc.c | 34 ++++++++---- hw/ppc/ppc4xx_devs.c | 113 ++++++++++++++++++++++++++++------------4 files changed, 140 insertions(+), 45 deletions(-)hw/ppc/ppc405.h +2
-4@@ -228,12 +228,9 @@ struct Ppc405SoCState { DeviceState parent_obj; /* Public */ - MemoryRegion ram_banks[2]; - hwaddr ram_bases[2], ram_sizes[2]; - bool do_dram_init; - MemoryRegion *dram_mr; hwaddr ram_size; + uint32_t nr_banks; PowerPCCPU cpu; PPCUIC uic;@@ -241,6 +238,7 @@ struct Ppc405SoCState { Ppc405GptState gpt; Ppc405OcmState ocm; Ppc405GpioState gpio; + Ppc4xxSdramState sdram; Ppc405DmaState dma; PPC4xxI2CState i2c; Ppc405EbcState ebc;include/hw/ppc/ppc4xx.h +32
-0@@ -87,4 +87,36 @@ struct Ppc4xxMalState {void ppc4xx_mal_init (CPUPPCState *env,uint8_t txcnum,uint8_t rxcnum, qemu_irq irqs[4]); +/* SDRAM controller */ +#define TYPE_PPC4xx_SDRAM "ppc4xx-sdram" +OBJECT_DECLARE_SIMPLE_TYPE (Ppc4xxSdramState, PPC4xx_SDRAM); +struct Ppc4xxSdramState { + Ppc4xxDcrDeviceState parent_obj; + + MemoryRegion *dram_mr; + bool dram_init; + + MemoryRegion containers[4]; /* used for clipping */ + MemoryRegion *ram_memories; + hwaddr *ram_bases; + hwaddr *ram_sizes; + uint32_t nb_ram_bases; + uint32_t nb_ram_sizes; + uint32_t nbanks; /* Redundant */ + + uint32_t addr; + uint32_t besr0; + uint32_t besr1; + uint32_t bear; + uint32_t cfg; + uint32_t status; + uint32_t rtr; + uint32_t pmit; + uint32_t bcr[4]; + uint32_t tr; + uint32_t ecccfg; + uint32_t eccesr; + qemu_irq irq; +}; +#endif /* PPC4XX_H */ hw/ppc/ppc405_uc.c +25
-9@@ -1361,6 +1361,9 @@ static void ppc405_soc_instance_init(Object *obj) object_initialize_child(obj, "gpio", &s->gpio, TYPE_PPC405_GPIO); + object_initialize_child(obj, "sdram", &s->sdram, TYPE_PPC4xx_SDRAM); + object_property_add_alias(obj, "dram-init", OBJECT(&s->sdram), "dram-init"); + object_initialize_child(obj, "dma", &s->dma, TYPE_PPC405_DMA); object_initialize_child(obj, "i2c", &s->i2c, TYPE_PPC4xx_I2C);@@ -1432,15 +1435,28 @@ static void ppc405_soc_realize(DeviceState *dev, Error **errp) /* SDRAM controller */ /* XXX 405EP has no ECC interrupt */ - s->ram_bases[0] = 0; - s->ram_sizes[0] = s->ram_size; - memory_region_init_alias(&s->ram_banks[0], OBJECT(s), - "ppc405.sdram0", s->dram_mr, - s->ram_bases[0], s->ram_sizes[0]); + object_property_set_link(OBJECT(&s->sdram), "dram", OBJECT(s->dram_mr), + &error_abort); + + qdev_prop_set_uint32(DEVICE(&s->sdram), "len-ram-sizes", s->nr_banks); + qdev_prop_set_uint32(DEVICE(&s->sdram), "len-ram-bases", s->nr_banks); - ppc4xx_sdram_init(env, qdev_get_gpio_in(DEVICE(&s->uic), 17), 1, - s->ram_banks, s->ram_bases, s->ram_sizes, - s->do_dram_init); + for (i = 0; i < s->nr_banks; i++) { + char name[32]; + snprintf(name, sizeof(name), "ram-bases[%d]", i); + qdev_prop_set_uint32(DEVICE(&s->sdram), name, + i * s->ram_size / s->nr_banks); + + snprintf(name, sizeof(name), "ram-sizes[%d]", i); + qdev_prop_set_uint32(DEVICE(&s->sdram), name, + s->ram_size / s->nr_banks); + } + + if (!ppc4xx_dcr_realize(PPC4xx_DCR_DEVICE(&s->sdram), &s->cpu, errp)) { + return; + } + sysbus_connect_irq(SYS_BUS_DEVICE(&s->sdram), 0, + qdev_get_gpio_in(DEVICE(&s->uic), 17)); /* External bus controller */ if (!ppc4xx_dcr_realize(PPC4xx_DCR_DEVICE(&s->ebc), &s->cpu, errp)) {@@ -1520,7 +1536,7 @@ static void ppc405_soc_realize(DeviceState *dev, Error **errp)static Property ppc405_soc_properties[] = { DEFINE_PROP_LINK("dram", Ppc405SoCState, dram_mr, TYPE_MEMORY_REGION, MemoryRegion *), - DEFINE_PROP_BOOL("dram-init", Ppc405SoCState, do_dram_init, 0), + DEFINE_PROP_UINT32("nr-banks", Ppc405SoCState, nr_banks, 2), DEFINE_PROP_UINT64("ram-size", Ppc405SoCState, ram_size, 0), DEFINE_PROP_END_OF_LIST(), };hw/ppc/ppc4xx_devs.c +7
-30@@ -39,28 +39,6 @@/*****************************************************************************/ /* SDRAM controller */ -typedef struct ppc4xx_sdram_t ppc4xx_sdram_t ; -struct ppc4xx_sdram_t { - uint32_t addr; - int nbanks; - MemoryRegion containers[4]; /* used for clipping */ - MemoryRegion *ram_memories; - hwaddr ram_bases[4]; - hwaddr ram_sizes[4]; - uint32_t besr0; - uint32_t besr1; - uint32_t bear; - uint32_t cfg; - uint32_t status; - uint32_t rtr; - uint32_t pmit; - uint32_t bcr[4]; - uint32_t tr; - uint32_t ecccfg; - uint32_t eccesr; - qemu_irq irq; -}; -enum { SDRAM0_CFGADDR = 0x010, SDRAM0_CFGDATA = 0x011,@@ -128,7 +106,7 @@ static target_ulong sdram_size (uint32_t bcr) return size; } -static void sdram_set_bcr (ppc4xx_sdram_t *sdram,int i, +static void sdram_set_bcr (Ppc4xxSdramState *sdram,int i, uint32_t bcr, int enabled) { if (sdram->bcr[i] & 0x00000001) {@@ -154,7 +132,7 @@ static void sdram_set_bcr(ppc4xx_sdram_t *sdram, int i, } } -static void sdram_map_bcr (ppc4xx_sdram_t *sdram) +static void sdram_map_bcr (Ppc4xxSdramState *sdram) { int i;@@ -168,7 +146,7 @@ static void sdram_map_bcr (ppc4xx_sdram_t *sdram) } } -static void sdram_unmap_bcr (ppc4xx_sdram_t *sdram) +static void sdram_unmap_bcr (Ppc4xxSdramState *sdram) { int i;@@ -182,7 +160,7 @@ static void sdram_unmap_bcr (ppc4xx_sdram_t *sdram)static uint32_t dcr_read_sdram (void *opaque,int dcrn) { - ppc4xx_sdram_t *sdram; + Ppc4xxSdramState *sdram; uint32_t ret; sdram = opaque;@@ -250,7 +228,7 @@ static uint32_t dcr_read_sdram (void *opaque, int dcrn)static void dcr_write_sdram (void *opaque,int dcrn,uint32_t val) { - ppc4xx_sdram_t *sdram; + Ppc4xxSdramState *sdram; sdram = opaque; switch (dcrn) {@@ -329,11 +307,10 @@ static void dcr_write_sdram (void *opaque, int dcrn, uint32_t val) } } -static void sdram_reset (void *opaque) +static void ppc4xx_sdram_reset (DeviceState *dev) { - ppc4xx_sdram_t *sdram; + Ppc4xxSdramState *sdram = (Ppc4xxSdramState *) dev; - sdram = opaque; sdram->addr = 0x00000000; sdram->bear = 0x00000000;
sdram->besr0=0x00000000; /* No error */hw/ppc/ppc4xx_devs.c +74
-2@@ -349,21 +326,88 @@ static void sdram_reset (void *opaque) sdram->cfg = 0x00800000; } +static void sdram_reset (void *opaque) +{ + ppc4xx_sdram_reset(opaque); +} + +static void ppc4xx_sdram_realize (DeviceState *dev,Error **errp) +{ + Ppc4xxSdramState *s = PPC4xx_SDRAM(dev); + Ppc4xxDcrDeviceState *dcr = PPC4xx_DCR_DEVICE(dev); + int i; + + sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->irq); + + ppc4xx_dcr_register(dcr, SDRAM0_CFGADDR, &dcr_read_sdram, &dcr_write_sdram); + ppc4xx_dcr_register(dcr, SDRAM0_CFGDATA, &dcr_read_sdram, &dcr_write_sdram); + + if (!s->nb_ram_bases || s->nb_ram_bases != s->nb_ram_sizes) { + error_setg(errp, "Invalid number of RAM banks"); + return; + } + + s->ram_memories = g_new0(MemoryRegion, s->nb_ram_bases); + for (i = 0; i < s->nb_ram_bases; i++) { + g_autofree char *name = g_strdup_printf(TYPE_PPC4xx_SDRAM "%d", i); + + if (!sdram_bcr(s->ram_bases[i], s->ram_sizes[i])) { + error_setg(errp, "Invalid RAM size 0x%" HWADDR_PRIx, + s->ram_sizes[i]); + return; + } + + memory_region_init_alias(&s->ram_memories[i], OBJECT(s), name, + s->dram_mr, s->ram_bases[i], s->ram_sizes[i]); + } + + s->nbanks = s->nb_ram_sizes; + if (s->dram_init) { + sdram_map_bcr(s); + } +} + +static Property ppc4xx_sdram_properties[] = { + DEFINE_PROP_LINK("dram", Ppc4xxSdramState, dram_mr, TYPE_MEMORY_REGION, + MemoryRegion *), + DEFINE_PROP_BOOL("dram-init", Ppc4xxSdramState, dram_init, false), + DEFINE_PROP_ARRAY("ram-sizes", Ppc4xxSdramState, nb_ram_sizes, + ram_sizes, qdev_prop_uint64, uint64_t), + DEFINE_PROP_ARRAY("ram-bases", Ppc4xxSdramState, nb_ram_bases, + ram_bases, qdev_prop_uint64, uint64_t), + DEFINE_PROP_END_OF_LIST(), +}; + +static void ppc4xx_sdram_class_init (ObjectClass *oc,void *data) +{ + DeviceClass *dc = DEVICE_CLASS(oc); + + dc->realize = ppc4xx_sdram_realize; + dc->user_creatable = false; + dc->reset = ppc4xx_sdram_reset; + device_class_set_props(dc, ppc4xx_sdram_properties); +} +void ppc4xx_sdram_init (CPUPPCState *env,qemu_irq irq,int nbanks, MemoryRegion *ram_memories, hwaddr *ram_bases, hwaddr *ram_sizes, int do_init) { - ppc4xx_sdram_t *sdram; + Ppc4xxSdramState *sdram; - sdram = g_new0(ppc4xx_sdram_t, 1); + sdram = g_new0(Ppc4xxSdramState, 1); sdram->irq = irq; sdram->nbanks = nbanks; sdram->ram_memories = ram_memories; + + sdram->ram_bases = g_new0(hwaddr, 4); + memset(sdram->ram_bases, 0, 4 * sizeof(hwaddr)); memcpy(sdram->ram_bases, ram_bases, nbanks * sizeof(hwaddr)); + + sdram->ram_sizes = g_new0(hwaddr, 4); memset(sdram->ram_sizes, 0, 4 * sizeof(hwaddr)); memcpy(sdram->ram_sizes, ram_sizes, nbanks * sizeof(hwaddr));@@ -683,6 +727,11 @@ static void ppc4xx_dcr_class_init(ObjectClass *oc, void *data)static const TypeInfo ppc4xx_types[] = { { + .name = TYPE_PPC4xx_SDRAM, + .parent = TYPE_PPC4xx_DCR_DEVICE, + .instance_size = sizeof(Ppc4xxSdramState), + .class_init = ppc4xx_sdram_class_init, + }, { .name = TYPE_PPC4xx_MAL, .parent = TYPE_PPC4xx_DCR_DEVICE, .instance_size = sizeof(Ppc4xxMalState),
Re: [PATCH v4 23/24] ppc/ppc405: QOM'ify SDRAM
Quoted 16 lines · Cédric Le Goater
Quoted 15 lines · BALATON Zoltan
Quoted 13 lines · Cédric Le Goater
This is an initial change of the SDRAM controller preserving the compatibility with the current modeling. Further cleanup will be possible after conversion of the
ppc4xx_sdram_banks()andppc4xx_sdram_init()routines of the sam460ex and bamboo machines.The size and base address of the RAM banks are now set using QOM property arrays. RAM is equally distributed on each bank at the SoC level depending on the number of banks we want to initialize (default is 2). Each RAM memory region representing a RAM bank is initialized in the realize routine of the SDRAM model after a minimal check on the RAM size value with the
sdram_bcr()routine. This has the benefit of reporting an error to the user if the requested RAM size is invalid for the SDRAM controller.
Quoted 3 lines
Quoted 1 line
Haven't looked at it in detail yet but I think we have two versions of this (one in
ppc4xx_devs.cand another inppc440_uc.c) that are slightly different due to the differences of the memory controllers of later SoCs. I'm not sure how to clean this up and forgot most of the details about this.AFAICT We need a Ppc4xxSdramClass to abstract the differences.
So maybe this one in this patch is beter named 405 then. Some devices are common to both 405 and 440 which should be named 4xx then where there are differences we should use 405 and 440 (or 40x and 44x if we have different SoCs of the same family). This wasn't followed strictly before so there's some naming to clean up.
Regards,
BALATON Zoltan
Quoted 358 lines
Thanks,
C.
Quoted 351 lines
Regards,
BALATON ZoltanQuoted 347 lines
Signed-off-by Cédric Le Goater <[email protected]>---
hw/ppc/ppc405.h | 6 +--include/hw/ppc/ppc4xx.h| 32 ++++++++++++ hw/ppc/ppc405_uc.c | 34 ++++++++---- hw/ppc/ppc4xx_devs.c | 113 ++++++++++++++++++++++++++++------------4 files changed, 140 insertions(+), 45 deletions(-)hw/ppc/ppc405.h +2
-4@@ -228,12 +228,9 @@ struct Ppc405SoCState { DeviceState parent_obj; /* Public */ - MemoryRegion ram_banks[2]; - hwaddr ram_bases[2], ram_sizes[2]; - bool do_dram_init; - MemoryRegion *dram_mr; hwaddr ram_size; + uint32_t nr_banks; PowerPCCPU cpu; PPCUIC uic;@@ -241,6 +238,7 @@ struct Ppc405SoCState { Ppc405GptState gpt; Ppc405OcmState ocm; Ppc405GpioState gpio; + Ppc4xxSdramState sdram; Ppc405DmaState dma; PPC4xxI2CState i2c; Ppc405EbcState ebc;include/hw/ppc/ppc4xx.h +32
-0@@ -87,4 +87,36 @@ struct Ppc4xxMalState {void ppc4xx_mal_init (CPUPPCState *env,uint8_t txcnum,uint8_t rxcnum, qemu_irq irqs[4]); +/* SDRAM controller */ +#define TYPE_PPC4xx_SDRAM "ppc4xx-sdram" +OBJECT_DECLARE_SIMPLE_TYPE (Ppc4xxSdramState, PPC4xx_SDRAM); +struct Ppc4xxSdramState { + Ppc4xxDcrDeviceState parent_obj; + + MemoryRegion *dram_mr; + bool dram_init; + + MemoryRegion containers[4]; /* used for clipping */ + MemoryRegion *ram_memories; + hwaddr *ram_bases; + hwaddr *ram_sizes; + uint32_t nb_ram_bases; + uint32_t nb_ram_sizes; + uint32_t nbanks; /* Redundant */ + + uint32_t addr; + uint32_t besr0; + uint32_t besr1; + uint32_t bear; + uint32_t cfg; + uint32_t status; + uint32_t rtr; + uint32_t pmit; + uint32_t bcr[4]; + uint32_t tr; + uint32_t ecccfg; + uint32_t eccesr; + qemu_irq irq; +}; +#endif /* PPC4XX_H */ hw/ppc/ppc405_uc.c +3
-0@@ -1361,6 +1361,9 @@ static void ppc405_soc_instance_init(Object *obj) object_initialize_child(obj, "gpio", &s->gpio, TYPE_PPC405_GPIO); + object_initialize_child(obj, "sdram", &s->sdram, TYPE_PPC4xx_SDRAM); + object_property_add_alias(obj, "dram-init", OBJECT(&s->sdram),"dram-init" ); + object_initialize_child(obj, "dma", &s->dma, TYPE_PPC405_DMA);
object_initialize_child(obj, "i2c", &s->i2c, TYPE_PPC4xx_I2C);hw/ppc/ppc405_uc.c +17
-8@@ -1432,15 +1435,28 @@ static void ppc405_soc_realize(DeviceState *dev, Error **errp) /* SDRAM controller */ /* XXX 405EP has no ECC interrupt */ - s->ram_bases[0] = 0; - s->ram_sizes[0] = s->ram_size; - memory_region_init_alias(&s->ram_banks[0], OBJECT(s), - "ppc405.sdram0", s->dram_mr, - s->ram_bases[0], s->ram_sizes[0]); + object_property_set_link(OBJECT(&s->sdram), "dram", OBJECT(s->dram_mr), + &error_abort); + + qdev_prop_set_uint32(DEVICE(&s->sdram), "len-ram-sizes", s->nr_banks); + qdev_prop_set_uint32(DEVICE(&s->sdram), "len-ram-bases", s->nr_banks); - ppc4xx_sdram_init(env, qdev_get_gpio_in(DEVICE(&s->uic), 17), 1, - s->ram_banks, s->ram_bases, s->ram_sizes, - s->do_dram_init); + for (i = 0; i < s->nr_banks; i++) { + char name[32]; + snprintf(name, sizeof(name), "ram-bases[%d]", i); + qdev_prop_set_uint32(DEVICE(&s->sdram), name, + i * s->ram_size / s->nr_banks); + + snprintf(name, sizeof(name), "ram-sizes[%d]", i); + qdev_prop_set_uint32(DEVICE(&s->sdram), name, + s->ram_size / s->nr_banks); + } + + if (!ppc4xx_dcr_realize(PPC4xx_DCR_DEVICE(&s->sdram), &s->cpu, errp)){
+ return;
+ }
+ sysbus_connect_irq(SYS_BUS_DEVICE(&s->sdram), 0, +qdev_get_gpio_in(DEVICE(&s->uic), 17));/* External bus controller */
if (!ppc4xx_dcr_realize(PPC4xx_DCR_DEVICE(&s->ebc),&s->cpu, errp)) {hw/ppc/ppc405_uc.c +1
-1@@ -1520,7 +1536,7 @@ static void ppc405_soc_realize(DeviceState *dev, Error **errp)static Property ppc405_soc_properties[] = { DEFINE_PROP_LINK("dram", Ppc405SoCState, dram_mr, TYPE_MEMORY_REGION, MemoryRegion *), - DEFINE_PROP_BOOL("dram-init", Ppc405SoCState, do_dram_init, 0), + DEFINE_PROP_UINT32("nr-banks", Ppc405SoCState, nr_banks, 2), DEFINE_PROP_UINT64("ram-size", Ppc405SoCState, ram_size, 0), DEFINE_PROP_END_OF_LIST(),};
hw/ppc/ppc4xx_devs.c +5
-27@@ -39,28 +39,6 @@/*****************************************************************************/ /* SDRAM controller */ -typedef struct ppc4xx_sdram_t ppc4xx_sdram_t ; -struct ppc4xx_sdram_t { - uint32_t addr; - int nbanks; - MemoryRegion containers[4]; /* used for clipping */ - MemoryRegion *ram_memories; - hwaddr ram_bases[4]; - hwaddr ram_sizes[4]; - uint32_t besr0; - uint32_t besr1; - uint32_t bear; - uint32_t cfg; - uint32_t status; - uint32_t rtr; - uint32_t pmit; - uint32_t bcr[4]; - uint32_t tr; - uint32_t ecccfg; - uint32_t eccesr; - qemu_irq irq; -}; -enum { SDRAM0_CFGADDR = 0x010, SDRAM0_CFGDATA = 0x011,@@ -128,7 +106,7 @@ static target_ulong sdram_size (uint32_t bcr) return size; } -static void sdram_set_bcr (ppc4xx_sdram_t *sdram,int i, +static void sdram_set_bcr (Ppc4xxSdramState *sdram,int i, uint32_t bcr, int enabled) { if (sdram->bcr[i] & 0x00000001) {@@ -154,7 +132,7 @@ static void sdram_set_bcr(ppc4xx_sdram_t *sdram, int i, } } -static void sdram_map_bcr (ppc4xx_sdram_t *sdram) +static void sdram_map_bcr (Ppc4xxSdramState *sdram) { int i;@@ -168,7 +146,7 @@ static void sdram_map_bcr (ppc4xx_sdram_t *sdram) } } -static void sdram_unmap_bcr (ppc4xx_sdram_t *sdram) +static void sdram_unmap_bcr (Ppc4xxSdramState *sdram) { int i;@@ -182,7 +160,7 @@ static void sdram_unmap_bcr (ppc4xx_sdram_t *sdram)static uint32_t dcr_read_sdram (void *opaque,int dcrn) { - ppc4xx_sdram_t *sdram; + Ppc4xxSdramState *sdram; uint32_t ret; sdram = opaque;@@ -250,7 +228,7 @@ static uint32_t dcr_read_sdram (void *opaque, int dcrn) static void dcr_write_sdram (void *opaque, int dcrn, uint32_t val) { - ppc4xx_sdram_t *sdram; + Ppc4xxSdramState *sdram; sdram = opaque;switch (dcrn) {
hw/ppc/ppc4xx_devs.c +2
-3@@ -329,11 +307,10 @@ static void dcr_write_sdram (void *opaque, int dcrn, uint32_t val) } } -static void sdram_reset (void *opaque) +static void ppc4xx_sdram_reset (DeviceState *dev) { - ppc4xx_sdram_t *sdram; + Ppc4xxSdramState *sdram = (Ppc4xxSdramState *) dev; - sdram = opaque; sdram->addr = 0x00000000; sdram->bear = 0x00000000;
sdram->besr0=0x00000000; /* No error */hw/ppc/ppc4xx_devs.c +67
-2@@ -349,21 +326,88 @@ static void sdram_reset (void *opaque) sdram->cfg = 0x00800000; } +static void sdram_reset (void *opaque) +{ + ppc4xx_sdram_reset(opaque); +} + +static void ppc4xx_sdram_realize (DeviceState *dev,Error **errp) +{ + Ppc4xxSdramState *s = PPC4xx_SDRAM(dev); + Ppc4xxDcrDeviceState *dcr = PPC4xx_DCR_DEVICE(dev); + int i; + + sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->irq); + + ppc4xx_dcr_register(dcr, SDRAM0_CFGADDR, &dcr_read_sdram, &dcr_write_sdram); + ppc4xx_dcr_register(dcr, SDRAM0_CFGDATA, &dcr_read_sdram, &dcr_write_sdram); + + if (!s->nb_ram_bases || s->nb_ram_bases != s->nb_ram_sizes) { + error_setg(errp, "Invalid number of RAM banks"); + return; + } + + s->ram_memories = g_new0(MemoryRegion, s->nb_ram_bases); + for (i = 0; i < s->nb_ram_bases; i++) { + g_autofree char *name = g_strdup_printf(TYPE_PPC4xx_SDRAM "%d", i); + + if (!sdram_bcr(s->ram_bases[i], s->ram_sizes[i])) { + error_setg(errp, "Invalid RAM size 0x%" HWADDR_PRIx, + s->ram_sizes[i]); + return; + } + + memory_region_init_alias(&s->ram_memories[i], OBJECT(s), name, + s->dram_mr, s->ram_bases[i], s->ram_sizes[i]); + } + + s->nbanks = s->nb_ram_sizes; + if (s->dram_init) { + sdram_map_bcr(s); + } +} + +static Property ppc4xx_sdram_properties[] = { + DEFINE_PROP_LINK("dram", Ppc4xxSdramState, dram_mr,TYPE_MEMORY_REGION , + MemoryRegion *), + DEFINE_PROP_BOOL("dram-init", Ppc4xxSdramState, dram_init, false), + DEFINE_PROP_ARRAY("ram-sizes", Ppc4xxSdramState, nb_ram_sizes, + ram_sizes, qdev_prop_uint64, uint64_t), + DEFINE_PROP_ARRAY("ram-bases", Ppc4xxSdramState, nb_ram_bases, + ram_bases, qdev_prop_uint64, uint64_t), + DEFINE_PROP_END_OF_LIST(), +}; + +static void ppc4xx_sdram_class_init (ObjectClass *oc,void *data) +{ + DeviceClass *dc = DEVICE_CLASS(oc); + + dc->realize = ppc4xx_sdram_realize; + dc->user_creatable = false; + dc->reset = ppc4xx_sdram_reset; + device_class_set_props(dc, ppc4xx_sdram_properties); +} +void ppc4xx_sdram_init (CPUPPCState *env,qemu_irq irq,int nbanks, MemoryRegion *ram_memories, hwaddr *ram_bases, hwaddr *ram_sizes, int do_init) { - ppc4xx_sdram_t *sdram; + Ppc4xxSdramState *sdram; - sdram = g_new0(ppc4xx_sdram_t, 1); + sdram = g_new0(Ppc4xxSdramState, 1); sdram->irq = irq; sdram->nbanks = nbanks; sdram->ram_memories = ram_memories; + + sdram->ram_bases = g_new0(hwaddr, 4); + memset(sdram->ram_bases, 0, 4 * sizeof(hwaddr));
memcpy(sdram->ram_bases, ram_bases, nbanks * sizeof(hwaddr));
+
+sdram->ram_sizes=g_new0(hwaddr, 4);memset(sdram->ram_sizes, 0, 4 * sizeof(hwaddr));memcpy(sdram->ram_sizes, ram_sizes, nbanks * sizeof(hwaddr));hw/ppc/ppc4xx_devs.c +5
-0@@ -683,6 +727,11 @@ static void ppc4xx_dcr_class_init(ObjectClass *oc, void *data)static const TypeInfo ppc4xx_types[] = { { + .name = TYPE_PPC4xx_SDRAM, + .parent = TYPE_PPC4xx_DCR_DEVICE, + .instance_size = sizeof(Ppc4xxSdramState), + .class_init = ppc4xx_sdram_class_init, + }, { .name = TYPE_PPC4xx_MAL, .parent = TYPE_PPC4xx_DCR_DEVICE,.instance_size = sizeof(Ppc4xxMalState),
PATCH v4 24/24 ppc/ppc405: Add check on minimum RAM size
In reply to Cédric Le GoaterThe check on invalid RAM size is now performed in the SDRAM controller but not all values will boot a machine. A minimum of 2*16 is required.
--- hw/ppc/ppc405_boards.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
hw/ppc/ppc405_boards.c +2 -5
@@ -251,14 +251,11 @@ static void boot_from_kernel(MachineState *machine, PowerPCCPU *cpu)static void ppc405_init (MachineState *machine) {Ppc405MachineState *ppc405 =PPC405_MACHINE (machine); -MachineClass *mc =MACHINE_GET_CLASS (machine);const char *kernel_filename = machine->kernel_filename;MemoryRegion *sysmem =get_system_memory (); -if (machine->ram_size != mc->default_ram_size) { -char *sz =size_to_str (mc->default_ram_size); -error_report ("Invalid RAM size, should be %s" , sz); -g_free (sz); +if (machine->ram_size <16 * MiB) { +error_report ("Not enough RAM !" );exit (EXIT_FAILURE ); }
Signature · 1 line
2.37.1
Re: [PATCH v4 24/24] ppc/ppc405: Add check on minimum RAM size
Quoted 2 lines · Cédric Le Goater
The check on invalid RAM size is now performed in the SDRAM controller but not all values will boot a machine. A minimum of 2*16 is required.
2*16 or 16 MiB? The code has the latter which does not match commit message.
Regards,
BALATON Zoltan
Quoted 28 lines
Signed-off-by Cédric Le Goater <[email protected]>---
hw/ppc/ppc405_boards.c| 7 ++-----1 file changed, 2 insertions(+), 5 deletions(-)hw/ppc/ppc405_boards.c +2
-5@@ -251,14 +251,11 @@ static void boot_from_kernel(MachineState *machine, PowerPCCPU *cpu)static void ppc405_init (MachineState *machine) {Ppc405MachineState *ppc405 =PPC405_MACHINE (machine); -MachineClass *mc =MACHINE_GET_CLASS (machine);const char *kernel_filename = machine->kernel_filename;MemoryRegion *sysmem =get_system_memory (); -if (machine->ram_size != mc->default_ram_size) { -char *sz =size_to_str (mc->default_ram_size); -error_report ("Invalid RAM size, should be %s" , sz); -g_free (sz); +if (machine->ram_size <16 * MiB) { +error_report ("Not enough RAM !" );exit (EXIT_FAILURE ); }
Re: [PATCH v4 24/24] ppc/ppc405: Add check on minimum RAM size
Quoted 5 lines · BALATON Zoltan
Quoted 2 lines · Cédric Le Goater
The check on invalid RAM size is now performed in the SDRAM controller but not all values will boot a machine. A minimum of 2*16 is required.
2*16 or 16 MiB? The code has the latter which does not match commit message.
Indeed. It should be 32MB below.
Thanks,
C.
Quoted 32 lines
Regards,
BALATON ZoltanQuoted 28 lines
Signed-off-by Cédric Le Goater <[email protected]>---
hw/ppc/ppc405_boards.c| 7 ++-----1 file changed, 2 insertions(+), 5 deletions(-)hw/ppc/ppc405_boards.c +2
-5@@ -251,14 +251,11 @@ static void boot_from_kernel(MachineState *machine, PowerPCCPU *cpu)static void ppc405_init (MachineState *machine) { Ppc405MachineState *ppc405 = PPC405_MACHINE(machine); - MachineClass *mc = MACHINE_GET_CLASS(machine); const char *kernel_filename = machine->kernel_filename; MemoryRegion *sysmem = get_system_memory(); - if (machine->ram_size != mc->default_ram_size) { - char *sz = size_to_str(mc->default_ram_size); - error_report("Invalid RAM size, should be %s", sz); - g_free(sz); + if (machine->ram_size < 16 * MiB) { + error_report("Not enough RAM !"); exit(EXIT_FAILURE); }
Cedric,
I pushed patches 1-7 to gitlab.com/danielhb/qemu/tree/ppc-7.2. This way you have 7 less patches to worry about for the next versions.
Thanks,
Daniel
Quoted 79 lines · Cédric Le Goater
Hello,
Here is large series QOM'ifying the PPC405 board. It introduces a new generic machine and SoC models, converts the current device models to QOM and populates the SoC. The process is quite mechanical without too much issues to handle. The noisy part is the initial patch introducing the SoC realize routine.
Thanks,
C.
Changes in v4 :
- Attempt to QOM'ify SDRAM controller, with 2 initialized banks at the SoC level
- Report errors to the user for invalid RAM config
- Moved CPU reset in PPC405 model
-user_creatablecomments
- Renamed FPGA device model
- Various small cleanupsChanges in v3 :
- New device model Ppc4xxDcrDeviceState
- Removal ofppc4xx_mal_init(),ppc4xx_plb_init()andppc405_ebc_init()
- Fixes for some reset issues
- Kept 2 RAM banks at the Soc level but only one is initialized.
- Moved SRAM under the machine. It's not part of the SoC according to the 405 specsChanges in v2 :
-
docs/about/removed-features.rstupdate
- Fix compile breakage (uic)
- Fix CPU reset, which breaking u-boot boot
- Changed prefix of memory regions to "ppc405"
- Reduced the number of RAM banks to 1. Second was a dummy one toplease ppc405ep_init()Cédric Le Goater (24):
ppc/ppc405: Remove taihu machine
ppc/ppc405: Introduce a PPC405 generic machine ppc/ppc405: Move devices under the ref405ep machine ppc/ppc405: Move SRAM under the ref405ep machine ppc/ppc405: Introduce a PPC405 SoC ppc/ppc405: Start QOMification of the SoC ppc/ppc405: QOM'ify CPU
ppc/ppc4xx: Introduce a DCR device model ppc/ppc405: QOM'ify CPC
ppc/ppc405: QOM'ify GPT
ppc/ppc405: QOM'ify OCM
ppc/ppc405: QOM'ify GPIO
ppc/ppc405: QOM'ify DMA
ppc/ppc405: QOM'ify EBC
ppc/ppc405: QOM'ify OPBA
ppc/ppc405: QOM'ify POB
ppc/ppc405: QOM'ify PLB
ppc/ppc405: QOM'ify MAL
ppc/ppc405: QOM'ify FPGA
ppc/ppc405: Use an embedded PPCUIC model in SoC state ppc/ppc405: Use an explicit I2C object ppc/ppc4xx: Fix sdram trace events ppc/ppc405: QOM'ify SDRAM
ppc/ppc405: Add check on minimum RAM sizedocs/about/deprecated.rst | 9 - docs/about/removed-features.rst | 6 + docs/system/ppc/embedded.rst | 1 - hw/ppc/ppc405.h | 196 +++++++- include/hw/ppc/ppc4xx.h | 82 ++- hw/ppc/ppc405_boards.c | 381 ++++---------- hw/ppc/ppc405_uc.c | 859 +++++++++++++++++--------------- hw/ppc/ppc4xx_devs.c | 326 +++++++----- hw/ppc/sam460ex.c | 24 +- MAINTAINERS | 2 +- hw/ppc/trace-events | 3 - 11 files changed, 1042 insertions(+), 847 deletions(-)
Quoted 4 lines · Daniel Henrique Barboza
Cedric,
I pushed patches 1-7 to gitlab.com/danielhb/qemu/tree/ppc-7.2. This way you have 7 less patches to worry about for the next versions.
Thanks Daniel,
C.