From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MQn9X-0004L6-Pz for qemu-devel@nongnu.org; Tue, 14 Jul 2009 14:54:59 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MQn9T-0004Ds-Q6 for qemu-devel@nongnu.org; Tue, 14 Jul 2009 14:54:59 -0400 Received: from [199.232.76.173] (port=54825 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MQn9T-0004DX-Iw for qemu-devel@nongnu.org; Tue, 14 Jul 2009 14:54:55 -0400 Received: from mail-fx0-f211.google.com ([209.85.220.211]:41088) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MQn9T-00008r-07 for qemu-devel@nongnu.org; Tue, 14 Jul 2009 14:54:55 -0400 Received: by fxm7 with SMTP id 7so2683619fxm.34 for ; Tue, 14 Jul 2009 11:54:52 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: Date: Tue, 14 Jul 2009 21:54:52 +0300 Message-ID: From: Blue Swirl Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: [PATCH] Sparc32/PPC: convert escc to qdev List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Juan Quintela Cc: Paul Brook , qemu-devel On 7/14/09, Juan Quintela wrote: > Blue Swirl 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.