From: Artyom Tarasenko <atar4qemu@gmail.com>
To: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
Cc: Peter Maydell <peter.maydell@linaro.org>,
Aleksandar Rikalo <arikalo@wavecomp.com>,
Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>,
qemu-devel <qemu-devel@nongnu.org>,
Aleksandar Markovic <amarkovic@wavecomp.com>,
Aurelien Jarno <aurelien@aurel32.net>
Subject: Re: [Qemu-devel] [PATCH 8/9] hw/sparc/sun4m: Simplify the RAM creation
Date: Tue, 25 Jun 2019 09:14:43 +0200 [thread overview]
Message-ID: <CACXAS8C=D+Jf9SPiW9SMTj6VMTcjeAQS+VXhpgUtKPPSfFrg5w@mail.gmail.com> (raw)
In-Reply-To: <20190624220056.25861-9-f4bug@amsat.org>
On Tue, Jun 25, 2019 at 12:01 AM Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>
> Now than the empty_slot device can be overlapped, use it to cover
> the maximum memory range.
Whilie this is true for SS-5, the SS-20 does trap on missing RAM, so
empty_slot_init must be conditional.
nack.
> We can simplify now the main RAM is created.
> The TYPE_SUN4M_MEMORY is not migratable, simply remove it.
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
> hw/sparc/sun4m.c | 85 ++++++++----------------------------------------
> 1 file changed, 13 insertions(+), 72 deletions(-)
>
> diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c
> index 0df5a8edfc..d55753d5cb 100644
> --- a/hw/sparc/sun4m.c
> +++ b/hw/sparc/sun4m.c
> @@ -767,71 +767,6 @@ static const TypeInfo prom_info = {
> .class_init = prom_class_init,
> };
>
> -#define TYPE_SUN4M_MEMORY "memory"
> -#define SUN4M_RAM(obj) OBJECT_CHECK(RamDevice, (obj), TYPE_SUN4M_MEMORY)
> -
> -typedef struct RamDevice {
> - SysBusDevice parent_obj;
> -
> - MemoryRegion ram;
> - uint64_t size;
> -} RamDevice;
> -
> -/* System RAM */
> -static void ram_realize(DeviceState *dev, Error **errp)
> -{
> - RamDevice *d = SUN4M_RAM(dev);
> - SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
> -
> - memory_region_allocate_system_memory(&d->ram, OBJECT(d), "sun4m.ram",
> - d->size);
> - sysbus_init_mmio(sbd, &d->ram);
> -}
> -
> -static void ram_init(hwaddr addr, ram_addr_t RAM_size,
> - uint64_t max_mem)
> -{
> - DeviceState *dev;
> - SysBusDevice *s;
> - RamDevice *d;
> -
> - /* allocate RAM */
> - if ((uint64_t)RAM_size > max_mem) {
> - error_report("Too much memory for this machine: %" PRId64 ","
> - " maximum %" PRId64,
> - RAM_size / MiB, max_mem / MiB);
> - exit(1);
> - }
> - dev = qdev_create(NULL, "memory");
> - s = SYS_BUS_DEVICE(dev);
> -
> - d = SUN4M_RAM(dev);
> - d->size = RAM_size;
> - qdev_init_nofail(dev);
> -
> - sysbus_mmio_map(s, 0, addr);
> -}
> -
> -static Property ram_properties[] = {
> - DEFINE_PROP_UINT64("size", RamDevice, size, 0),
> - DEFINE_PROP_END_OF_LIST(),
> -};
> -
> -static void ram_class_init(ObjectClass *klass, void *data)
> -{
> - DeviceClass *dc = DEVICE_CLASS(klass);
> -
> - dc->realize = ram_realize;
> - dc->props = ram_properties;
> -}
> -
> -static const TypeInfo ram_info = {
> - .name = TYPE_SUN4M_MEMORY,
> - .parent = TYPE_SYS_BUS_DEVICE,
> - .instance_size = sizeof(RamDevice),
> - .class_init = ram_class_init,
> -};
> -
> static void cpu_devinit(const char *cpu_type, unsigned int id,
> uint64_t prom_addr, qemu_irq **cpu_irqs)
> {
> @@ -872,6 +807,19 @@ static void sun4m_hw_init(const struct sun4m_hwdef *hwdef,
> FWCfgState *fw_cfg;
> DeviceState *dev;
> SysBusDevice *s;
> + MemoryRegion ram;
> +
> + if ((uint64_t)machine->ram_size > hwdef->max_mem) {
> + error_report("Too much memory for this machine: %" PRId64 ","
> + " maximum %" PRId64,
> + machine->ram_size / MiB, hwdef->max_mem / MiB);
> + exit(1);
> + }
> + memory_region_allocate_system_memory(&ram, OBJECT(machine), "sun4m.ram",
> + machine->ram_size);
> + memory_region_add_subregion(get_system_memory(), 0x00000000, &ram);
> + /* models without ECC don't trap when missing ram is accessed */
> + empty_slot_init(0x00000000, hwdef->max_mem);
>
> /* init CPUs */
> for(i = 0; i < smp_cpus; i++) {
> @@ -881,13 +829,7 @@ static void sun4m_hw_init(const struct sun4m_hwdef *hwdef,
> for (i = smp_cpus; i < MAX_CPUS; i++)
> cpu_irqs[i] = qemu_allocate_irqs(dummy_cpu_set_irq, NULL, MAX_PILS);
>
> -
> /* set up devices */
> - ram_init(0, machine->ram_size, hwdef->max_mem);
> - /* models without ECC don't trap when missing ram is accessed */
> - if (!hwdef->ecc_base) {
> - empty_slot_init(machine->ram_size, hwdef->max_mem - machine->ram_size);
> - }
>
> prom_init(hwdef->slavio_base, bios_name);
>
> @@ -1561,7 +1503,6 @@ static void sun4m_register_types(void)
> type_register_static(&idreg_info);
> type_register_static(&afx_info);
> type_register_static(&prom_info);
> - type_register_static(&ram_info);
>
> type_register_static(&ss5_type);
> type_register_static(&ss10_type);
> --
> 2.19.1
>
--
Regards,
Artyom Tarasenko
SPARC and PPC PReP under qemu blog: http://tyom.blogspot.com/search/label/qemu
next prev parent reply other threads:[~2019-06-25 7:17 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-24 22:00 [Qemu-devel] [PATCH 0/9] hw/misc: Clean the empty_slot device Philippe Mathieu-Daudé
2019-06-24 22:00 ` [Qemu-devel] [PATCH 1/9] hw/misc: Move the 'empty_slot' device to hw/misc/ Philippe Mathieu-Daudé
2019-06-25 7:09 ` Artyom Tarasenko
2019-06-24 22:00 ` [Qemu-devel] [RFC PATCH 2/9] MAINTAINERS: Add the 'empty_slot' device with the 'unimp' one Philippe Mathieu-Daudé
2019-06-25 7:06 ` Artyom Tarasenko
2019-06-24 22:00 ` [Qemu-devel] [PATCH 3/9] hw/misc/empty_slot: Allow overide by device with higher priority Philippe Mathieu-Daudé
2019-06-25 7:08 ` Artyom Tarasenko
2019-06-24 22:00 ` [Qemu-devel] [PATCH 4/9] hw/misc/empty_slot: Add a qdev property 'size' Philippe Mathieu-Daudé
2019-06-25 7:09 ` Artyom Tarasenko
2019-06-24 22:00 ` [Qemu-devel] [PATCH 5/9] hw/misc/empty_slot: Add a qdev property 'name' Philippe Mathieu-Daudé
2019-06-25 7:05 ` Artyom Tarasenko
2019-06-24 22:00 ` [Qemu-devel] [PATCH 6/9] hw/misc/empty_slot: Convert debug printf()s to trace events Philippe Mathieu-Daudé
2019-06-25 7:04 ` Artyom Tarasenko
2019-06-24 22:00 ` [Qemu-devel] [PATCH 7/9] hw/sparc/sun4m: Mark some devices as 'unimplemented' Philippe Mathieu-Daudé
2019-06-25 7:16 ` Artyom Tarasenko
2019-06-24 22:00 ` [Qemu-devel] [PATCH 8/9] hw/sparc/sun4m: Simplify the RAM creation Philippe Mathieu-Daudé
2019-06-25 7:14 ` Artyom Tarasenko [this message]
2019-06-25 8:14 ` Philippe Mathieu-Daudé
2019-06-24 22:00 ` [Qemu-devel] [PATCH 9/9] hw/misc/empty_slot: Pass the slot name as argument Philippe Mathieu-Daudé
2019-06-25 7:03 ` Artyom Tarasenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CACXAS8C=D+Jf9SPiW9SMTj6VMTcjeAQS+VXhpgUtKPPSfFrg5w@mail.gmail.com' \
--to=atar4qemu@gmail.com \
--cc=amarkovic@wavecomp.com \
--cc=arikalo@wavecomp.com \
--cc=aurelien@aurel32.net \
--cc=f4bug@amsat.org \
--cc=mark.cave-ayland@ilande.co.uk \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).