qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: BALATON Zoltan <balaton@eik.bme.hu>
To: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
Cc: Peter Maydell <peter.maydell@linaro.org>,
	Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>,
	Laurent Vivier <laurent@vivier.eu>,
	qemu-devel@nongnu.org, qemu-ppc@nongnu.org,
	Paolo Bonzini <pbonzini@redhat.com>,
	David Gibson <david@gibson.dropbear.id.au>
Subject: Re: [PATCH v7 0/8] Pegasos2 emulation
Date: Tue, 16 Mar 2021 15:48:04 +0100 (CET)	[thread overview]
Message-ID: <c1579f1-1ef-9d53-aea8-6d975f70634e@eik.bme.hu> (raw)
In-Reply-To: <276e8961-d058-c47e-82dd-1715881607d5@amsat.org>

Another arrempt to explain patch 1. This is the via-superio class that's a 
subclass of ISA superio:

https://github.com/patchew-project/qemu/blob/ca5d88d2fee0016f939e91ae8b32c18e682064fa/hw/isa/vt82c686.c#L255

#define TYPE_VIA_SUPERIO "via-superio"
OBJECT_DECLARE_SIMPLE_TYPE(ViaSuperIOState, VIA_SUPERIO)

struct ViaSuperIOState {
     ISASuperIODevice superio;
     uint8_t regs[0x100];
     const MemoryRegionOps *io_ops;
     MemoryRegion io;
     MemoryRegion *serial_io[SUPERIO_MAX_SERIAL_PORTS];
};

[...]

static void via_superio_realize(DeviceState *d, Error **errp)
{
     ViaSuperIOState *s = VIA_SUPERIO(d);
     ISASuperIOClass *ic = ISA_SUPERIO_GET_CLASS(s);
     Error *local_err = NULL;
     int i;

     assert(s->io_ops);
     ic->parent_realize(d, &local_err);
     if (local_err) {
         error_propagate(errp, local_err);
         return;
     }
     /* Grab io regions of serial devices so we can control them */
     for (i = 0; i < ic->serial.count; i++) {
         ISADevice *sd = s->superio.serial[i];
         MemoryRegion *io = isa_address_space_io(sd);
         MemoryRegion *mr = find_subregion(sd, io, sd->ioport_id);
         if (!mr) {
             error_setg(errp, "Could not get io region for serial %d", i);
             return;
         }
         s->serial_io[i] = mr;
     }

     memory_region_init_io(&s->io, OBJECT(d), s->io_ops, s, "via-superio", 2);
     memory_region_set_enabled(&s->io, false);
     /* The floppy also uses 0x3f0 and 0x3f1 but this seems to work anyway */
     memory_region_add_subregion(isa_address_space_io(ISA_DEVICE(s)), 0x3f0,
                                 &s->io);
}

In realize we grab pointers to the MemoryRegions of the isa-serial devices 
created by the ISA superio class. This is ISA superio:

https://github.com/patchew-project/qemu/blob/ca5d88d2fee0016f939e91ae8b32c18e682064fa/include/hw/isa/superio.h#L23

#define SUPERIO_MAX_SERIAL_PORTS 4

struct ISASuperIODevice {
     /*< private >*/
     ISADevice parent_obj;
     /*< public >*/

     ISADevice *parallel[MAX_PARALLEL_PORTS];
     ISADevice *serial[SUPERIO_MAX_SERIAL_PORTS];
     ISADevice *floppy;
     ISADevice *kbc;
     ISADevice *ide;
};

The serial members we access are even public so this should be OK (other 
models to that too) but we need to get their MemoryRegion as we need to 
configure that based on VIA superio registers. ISADevice is defined in:

https://github.com/patchew-project/qemu/blob/patchew/cover.1615345138.git.balaton%40eik.bme.hu/include/hw/isa/isa.h

but it does not store a reference to its memory regions:

struct ISADevice {
     /*< private >*/
     DeviceState parent_obj;
     /*< public >*/

     int8_t isairq[2];      /* -1 = unassigned */
     int nirqs;
     int ioport_id;
};

only an ioport_id which is the address of its first io region so we have 
to get the actual MemoryRegion based on that. This works for isa-serial 
that has a single mem region but would not for parallel or FDC that have 
multiple regions. Those are created with isa_register_portio_list() I 
think but we don't care about parallel and FDC only about serial.

This may be possible to clean up but that would need changes to ISA 
emulation that I don't want to change so the patch tries to achieve what's 
needed without changing how ISA devices are emulated currently. I think 
the solution proposed in patch 1 is relatively clean and by not changing 
anything than vt82c686 it avoids any possible breakage to other machines 
using ISA devices so unless there's a reason not to accept it this should 
solve the problem and allow pegasos2 firmware to boot.

Regards,
BALATON Zoltan


  parent reply	other threads:[~2021-03-16 14:50 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-10  2:58 [PATCH v7 0/8] Pegasos2 emulation BALATON Zoltan
2021-03-10  2:58 ` [PATCH v7 3/8] vt82c686: Add VT8231_SUPERIO based on VIA_SUPERIO BALATON Zoltan
2021-03-10  2:58 ` [PATCH v7 2/8] vt82c686: QOM-ify superio related functionality BALATON Zoltan
2021-03-11 23:50   ` Philippe Mathieu-Daudé
2021-03-12  0:32     ` BALATON Zoltan
2021-03-10  2:58 ` [PATCH v7 1/8] vt82c686: Implement control of serial port io ranges via config regs BALATON Zoltan
2021-03-11 23:47   ` Philippe Mathieu-Daudé
2021-03-12  1:20     ` David Gibson
2021-03-23 12:54   ` BALATON Zoltan
2021-03-23 21:58     ` Mark Cave-Ayland
2021-03-23 23:13       ` BALATON Zoltan
2021-03-10  2:58 ` [PATCH v7 8/8] hw/ppc: Add emulation of Genesi/bPlan Pegasos II BALATON Zoltan
2021-03-10  2:58 ` [PATCH v7 7/8] hw/pci-host: Add emulation of Marvell MV64361 PPC system controller BALATON Zoltan
2021-03-10  2:58 ` [PATCH v7 5/8] vt82c686: Add emulation of VT8231 south bridge BALATON Zoltan
2021-03-10  2:58 ` [PATCH v7 4/8] vt82c686: Introduce abstract TYPE_VIA_ISA and base vt82c686b_isa on it BALATON Zoltan
2021-03-10  2:58 ` [PATCH v7 6/8] hw/isa/Kconfig: Add missing dependency VIA VT82C686 -> APM BALATON Zoltan
2021-03-13 13:27 ` [PATCH v7 0/8] Pegasos2 emulation BALATON Zoltan
2021-03-15 12:33   ` BALATON Zoltan
2021-03-16  9:01     ` Laurent Vivier
2021-03-16 11:49       ` Philippe Mathieu-Daudé
2021-03-16 12:11         ` Laurent Vivier
2021-03-16 12:24           ` BALATON Zoltan
2021-03-16 12:55             ` Laurent Vivier
2021-03-16 13:06               ` BALATON Zoltan
2021-03-16 16:21                 ` Mark Cave-Ayland
2021-03-16 17:25                   ` BALATON Zoltan
2021-03-16 20:00                     ` Mark Cave-Ayland
2021-03-16 21:49                       ` BALATON Zoltan
2021-03-16 22:12                         ` BALATON Zoltan
2021-03-16 14:17         ` BALATON Zoltan
2021-03-16 14:48         ` BALATON Zoltan [this message]
2021-03-16 12:21       ` BALATON Zoltan

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=c1579f1-1ef-9d53-aea8-6d975f70634e@eik.bme.hu \
    --to=balaton@eik.bme.hu \
    --cc=david@gibson.dropbear.id.au \
    --cc=f4bug@amsat.org \
    --cc=laurent@vivier.eu \
    --cc=mark.cave-ayland@ilande.co.uk \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@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).