Message ID | 20230110164406.94366-1-philmd@linaro.org |
---|---|
Headers | show |
Series | hw/arm: Move various objects to softmmu_ss to build them once (part 1) | expand |
On Tue, 10 Jan 2023 at 16:45, Philippe Mathieu-Daudé <philmd@linaro.org> wrote: > > Replace the ARMCPU field in DigicState by a reference to > an allocated ARMCPU. Instead of initializing the field > with object_initialize(), allocate it with object_new(). > > As we don't access ARMCPU internal fields or size, we can > move digic.c from arm_ss[] to the more generic softmmu_ss[]. I'm not really a fan of this, because it moves away from a standard coding pattern we've been using for new QOM 'container' devices, where all the sub-components of the device are structs embedded in the device's own struct. This is as opposed to the old style which tended to use "allocate memory for the sub-component and have pointers to it". It means the CPU object is now being treated differently from all the timers, UARTs, etc. thanks -- PMM
On 10/1/23 17:52, Peter Maydell wrote: > On Tue, 10 Jan 2023 at 16:45, Philippe Mathieu-Daudé <philmd@linaro.org> wrote: >> >> Replace the ARMCPU field in DigicState by a reference to >> an allocated ARMCPU. Instead of initializing the field >> with object_initialize(), allocate it with object_new(). >> >> As we don't access ARMCPU internal fields or size, we can >> move digic.c from arm_ss[] to the more generic softmmu_ss[]. > > I'm not really a fan of this, because it moves away > from a standard coding pattern we've been using for > new QOM 'container' devices, where all the sub-components > of the device are structs embedded in the device's own > struct. This is as opposed to the old style which tended > to use "allocate memory for the sub-component and have > pointers to it". It means the CPU object is now being > treated differently from all the timers, UARTs, etc. OK, at least you don't object on patches 1-11/13 :) I might still post the other parts of this current approach to not lose them in case I can't find a better way. Thanks, Phil.
Peter Maydell <peter.maydell@linaro.org> writes: > On Tue, 10 Jan 2023 at 16:45, Philippe Mathieu-Daudé <philmd@linaro.org> wrote: >> >> Replace the ARMCPU field in DigicState by a reference to >> an allocated ARMCPU. Instead of initializing the field >> with object_initialize(), allocate it with object_new(). >> >> As we don't access ARMCPU internal fields or size, we can >> move digic.c from arm_ss[] to the more generic softmmu_ss[]. > > I'm not really a fan of this, because it moves away > from a standard coding pattern we've been using for > new QOM 'container' devices, where all the sub-components > of the device are structs embedded in the device's own > struct. This is as opposed to the old style which tended > to use "allocate memory for the sub-component and have > pointers to it". It means the CPU object is now being > treated differently from all the timers, UARTs, etc. I think you can certainly make the argument that CPU's have always been treated separately because we pass it around as an anonymous pointer all the time. We currently can't support two concrete CPU types in the same structure. For example zyncmp has: struct XlnxZynqMPState { /*< private >*/ DeviceState parent_obj; /*< public >*/ CPUClusterState apu_cluster; CPUClusterState rpu_cluster; ARMCPU apu_cpu[XLNX_ZYNQMP_NUM_APU_CPUS]; ARMCPU rpu_cpu[XLNX_ZYNQMP_NUM_RPU_CPUS]; which only works because A/R cpus are the same underlying type. However when we want to add Microblaze how would we do it? Is the main problem preventing us from including multiple cpu.h definitions that we overload CPUArch and CPUArchState? What are the implications if we convert them to fully anonymous pointer types? > > thanks > -- PMM
On Wed, 25 Jan 2023 at 12:14, Alex Bennée <alex.bennee@linaro.org> wrote: > Peter Maydell <peter.maydell@linaro.org> writes: > > I'm not really a fan of this, because it moves away > > from a standard coding pattern we've been using for > > new QOM 'container' devices, where all the sub-components > > of the device are structs embedded in the device's own > > struct. This is as opposed to the old style which tended > > to use "allocate memory for the sub-component and have > > pointers to it". It means the CPU object is now being > > treated differently from all the timers, UARTs, etc. > > I think you can certainly make the argument that CPU's have always been > treated separately because we pass it around as an anonymous pointer all > the time. We currently can't support two concrete CPU types in the same > structure. For example zyncmp has: > > struct XlnxZynqMPState { > /*< private >*/ > DeviceState parent_obj; > > /*< public >*/ > CPUClusterState apu_cluster; > CPUClusterState rpu_cluster; > ARMCPU apu_cpu[XLNX_ZYNQMP_NUM_APU_CPUS]; > ARMCPU rpu_cpu[XLNX_ZYNQMP_NUM_RPU_CPUS]; > > which only works because A/R cpus are the same underlying type. However > when we want to add Microblaze how would we do it? You'd add fields MicroBlazeCPU other_cpu; As you note, at the moment that doesn't work because cpu.h is magic and embeds an assumption that it's only included in compile-per-target objects and therefore any given source file only includes one of them at once. I think we should be aiming to remove those assumptions, not work around them. thanks -- PMM