qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Blue Swirl <blauwirbel@gmail.com>
To: Juan Quintela <quintela@trasno.org>
Cc: Paul Brook <paul@codesourcery.com>, qemu-devel <qemu-devel@nongnu.org>
Subject: [Qemu-devel] Re: [PATCH] Sparc32/PPC: convert escc to qdev
Date: Tue, 14 Jul 2009 21:54:52 +0300	[thread overview]
Message-ID: <f43fc5580907141154q4206f8b9s408e475b3f94846a@mail.gmail.com> (raw)
In-Reply-To: <m3k52c8evv.fsf@neno.mitica>

On 7/14/09, Juan Quintela <quintela@trasno.org> wrote:
> Blue Swirl <blauwirbel@gmail.com> wrote:
>  > Hi,
>  >
>  > This patch would convert escc to qdev. Sparc32 works fine, but there
>  > is a problem with PPC, it crashes when the device is remapped by
>  > macio.c.
>  > Any ideas?
>
>
> From my ignorance:
>
>
>  > -        s->chn[i].chn = 1 - i;
>  > -        s->chn[i].type = ser;
>  > -        s->chn[i].clock = clock / 2;
>
>  clock = clock /2
>
>  > -        if (s->chn[i].chr) {
>  > -            qemu_chr_add_handlers(s->chn[i].chr, serial_can_receive,
>  > -                                  serial_receive1, serial_event, &s->chn[i]);
>  > -        }
>  > +    DeviceState *dev;
>  > +    SysBusDevice *s;
>  > +
>  > +    dev = qdev_create(NULL, "escc");
>  > +    qdev_set_prop_int(dev, "disabled", 0);
>  > +    qdev_set_prop_int(dev, "frequency", clock);
>
>
> we set frequency with clock value (notice not clock/2)
>
>
>  > +    qdev_set_prop_int(dev, "it_shift", it_shift);
>  > +    qdev_set_prop_ptr(dev, "chrB", chrB);
>  > +    qdev_set_prop_ptr(dev, "chrA", chrA);
>  > +    qdev_set_prop_int(dev, "chnBtype", ser);
>  > +    qdev_set_prop_int(dev, "chnAtype", ser);
>  > +    qdev_init(dev);
>  > +    s = sysbus_from_qdev(dev);
>  > +    sysbus_connect_irq(s, 0, irqA);
>  > +    sysbus_connect_irq(s, 1, irqB);
>  > +    if (base) {
>  > +        sysbus_mmio_map(s, 0, base);
>  >      }
>  > -    s->chn[0].otherchn = &s->chn[1];
>  > -    s->chn[1].otherchn = &s->chn[0];
>  > -    if (base)
>  > -        register_savevm("escc", base, 2, escc_save, escc_load, s);
>  > -    else
>  > -        register_savevm("escc", -1, 2, escc_save, escc_load, s);
>  > -    qemu_register_reset(escc_reset, s);
>  > -    escc_reset(s);
>  > -    return escc_io_memory;
>  > +
>  > +    return s;
>  >  }
>  >
>  >  static const uint8_t keycodes[128] = {
>  > @@ -903,35 +888,86 @@ static void sunmouse_event(void *opaque,
>  >  void slavio_serial_ms_kbd_init(target_phys_addr_t base, qemu_irq irq,
>  >                                 int disabled, int clock, int it_shift)
>  >  {
>  > -    int slavio_serial_io_memory, i;
>  > -    SerialState *s;
>  > -
>  > -    s = qemu_mallocz(sizeof(SerialState));
>  > +    DeviceState *dev;
>  > +    SysBusDevice *s;
>  > +
>  > +    dev = qdev_create(NULL, "escc");
>  > +    qdev_set_prop_int(dev, "disabled", disabled);
>  > +    qdev_set_prop_int(dev, "frequency", clock);
>
>
> We set frequency with clock value (not clock/2 either)
>
>
>  > +    qdev_set_prop_int(dev, "it_shift", it_shift);
>  > +    qdev_set_prop_ptr(dev, "chrB", NULL);
>  > +    qdev_set_prop_ptr(dev, "chrA", NULL);
>  > +    qdev_set_prop_int(dev, "chnBtype", mouse);
>  > +    qdev_set_prop_int(dev, "chnAtype", kbd);
>  > +    qdev_init(dev);
>  > +    s = sysbus_from_qdev(dev);
>  > +    sysbus_connect_irq(s, 0, irq);
>  > +    sysbus_connect_irq(s, 1, irq);
>  > +    sysbus_mmio_map(s, 0, base);
>  > +}
>  >
>  > -    s->it_shift = it_shift;
>  > +static void escc_init1(SysBusDevice *dev)
>  > +{
>  > +    SerialState *s = FROM_SYSBUS(SerialState, dev);
>  > +    int io;
>  > +    unsigned int i;
>  > +    uint32_t clock, disabled;
>  > +
>  > +    s->it_shift = qdev_get_prop_int(&dev->qdev, "it_shift", 0);
>  > +    clock = qdev_get_prop_int(&dev->qdev, "clock", 0);
>
>
> We get in clock the "clock" value not the "frequency" one, and no hint
>  of the /2

The division is performed a few lines later. Actually we should do the
division in compile time, the numbers are fixed constants.

> > +    .qdev.props = (DevicePropList[]) {
>  > +        {.name = "frequency", .type = PROP_TYPE_INT},
>
>
> It is really called "frequency".

I don't know, it's the crystal frequency for serial baud rate
generator, different for PPC and Sparc. The property is not visible in
OpenFirmware tree so we can pick up any name. Timer speeds are often
exported with "clock-frequency" property, maybe that's more
consistent.

  parent reply	other threads:[~2009-07-14 18:54 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-13 19:32 [Qemu-devel] [PATCH] Sparc32/PPC: convert escc to qdev Blue Swirl
     [not found] ` <m3k52c8evv.fsf@neno.mitica>
2009-07-14 18:54   ` Blue Swirl [this message]
2009-07-14 22:03     ` [Qemu-devel] " Juan Quintela
2009-07-15 14:47       ` Blue Swirl
2009-07-15 15:37         ` Gerd Hoffmann

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=f43fc5580907141154q4206f8b9s408e475b3f94846a@mail.gmail.com \
    --to=blauwirbel@gmail.com \
    --cc=paul@codesourcery.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@trasno.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).