[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 0/9] Deprecate sysbus_get_default() and get_system_memory() e
Re: [PATCH 0/9] Deprecate sysbus_get_default() and get_system_memory() et. al
Tue, 20 Sep 2022 22:50:48 +0000
Am 20. September 2022 09:55:37 UTC schrieb Peter Maydell
>On Tue, 20 Sept 2022 at 00:18, Bernhard Beschow <email@example.com> wrote:
>> In address-spaces.h it can be read that get_system_memory() and
>> get_system_io() are temporary interfaces which "should only be used
>> until a proper bus interface is available". This statement certainly extends
>> the address_space_memory and address_space_io singletons.
>This is a long standing "we never really completed a cleanup"...
>> This series attempts
>> to stop further proliferation of their use by turning TYPE_SYSTEM_BUS into an
>> object-oriented, "proper bus interface" inspired by PCIBus.
>> While at it, also the main_system_bus singleton is turned into an attribute
>> MachineState. Together, this resolves five singletons in total, making the
>> ownership relations much more obvious which helps comprehension.
>...but I don't think this is the direction we want to go.
>Overall the reason that the "system memory" and "system IO"
>singletons are weird is that in theory they should not be necessary
>at all -- board code should create devices and map them into an
>entirely arbitrary MemoryRegion or set of MemoryRegions corresponding
>to address space(s) for the CPU and for DMA-capable devices.
My intention was to allow exactly that: By turning sytem memory and system IO
into non-singletons, one could have many of them, thus allowing boards to
create arbitrary mappings of memory and IO. Since QEMU currently assumes one
set (memory and IO) of addresses, I for now instantiated the SysBus once in the
machine class to preserve behavior.
>keep them around because
> (a) there is a ton of legacy code that assumes there's only one
> address space in the system and this is it
> (b) when modelling the kind of board where there really is only
> one address space, having the 'system memory' global makes
> the APIs for creating and connecting devices a lot simpler
Indeed, the APIs may look simpler. The issue I see here though is that devices
may make assumptions about these globals which makes the code hard to change in
the long run. If devices are given their dependencies by the framework, they
must make less assumptions, putting the framework into control. This makes the
code more homogenious and therefore easier to change.
>Retaining the whole-system singleton but shoving it into MachineState
>doesn't really change much, IMHO.
>More generally, sysbus is rather weird because it isn't really a
>bus. Every device in the system of TYPE_SYS_BUS_DEVICE is "on"
>the unique TYPE_SYSTEM_BUS bus, but that doesn't mean they're
>all in the same address space or that in real hardware they'd
>all be on the same bus.
Again, having multiple SysBuses may solve that issue.
>sysbus has essentially degraded into a
>hack for having devices get reset. I really really need to make
>some time to have another look at reset handling. If we get that
>right then I think it's probably possible to collapse the few
>things TYPE_SYS_BUS_DEVICE does that TYPE_DEVICE does not down
>into TYPE_DEVICE and get rid of sysbus altogether...
There are many SysBusDevices which directly access the globals I intended to
deprecate. If those devices could be changed to use the SysBus equivalents
instead, this would put the boards in control of memory mappings.
[PATCH 9/9] exec/address-spaces: Inline legacy functions, Bernhard Beschow, 2022/09/19
Re: [PATCH 0/9] Deprecate sysbus_get_default() and get_system_memory() et. al, Peter Maydell, 2022/09/20
- Re: [PATCH 8/9] softmmu/physmem: Let SysBusState absorb memory region and address space singletons, (continued)