Received: from eggs.gnu.org ([2001:4830:134:3::10]:51164) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c2beD-0002ge-P3 for qemu-devel@nongnu.org; Fri, 04 Nov 2016 06:23:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c2beA-0006yH-Fb for qemu-devel@nongnu.org; Fri, 04 Nov 2016 06:22:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47304) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1c2beA-0006wX-80 for qemu-devel@nongnu.org; Fri, 04 Nov 2016 06:22:54 -0400 From: Markus Armbruster References: <1476678204-11511-1-git-send-email-david@gibson.dropbear.id.au> <1476678204-11511-4-git-send-email-david@gibson.dropbear.id.au> Date: Fri, 04 Nov 2016 11:22:49 +0100 In-Reply-To: <1476678204-11511-4-git-send-email-david@gibson.dropbear.id.au> (David Gibson's message of "Mon, 17 Oct 2016 15:23:24 +1100") Message-ID: <878tszr1c6.fsf@dusky.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 3/3] Split ISA and sysbus versions of m48t59 device List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: David Gibson Cc: mst@redhat.com, pbonzini@redhat.com, qemu-devel@nongnu.org Needs a rebase. First error: CC hw/timer/m48t59.o In file included from /work/armbru/qemu/include/exec/cpu-common.h:7:0, from /work/armbru/qemu/include/exec/memory.h:24, from /work/armbru/qemu/include/hw/isa/isa.h:6, from /work/armbru/qemu/hw/timer/m48t59-isa.c:25: /work/armbru/qemu/include/exec/hwaddr.h:11:9: error: unknown type name =E2= =80=98uint64_t=E2=80=99 typedef uint64_t hwaddr; ^ David Gibson writes: > The m48t59 device supports both ISA and direct sysbus attached versions of > the device in the one .c file. This can be awkward for some embedded > machine types which need the sysbus M48T59, but don't want to pull in the > ISA bus code and its other dependencies. > > Therefore, this patch splits out the code for the ISA attached M48T59 into > its own C file. It will be built when both CONFIG_M48T59 and > CONFIG_ISA_BUS are enabled. > > Signed-off-by: David Gibson > --- > hw/timer/Makefile.objs | 3 + > hw/timer/m48t59-internal.h | 82 ++++++++++++++++ > hw/timer/m48t59-isa.c | 180 +++++++++++++++++++++++++++++++++++ > hw/timer/m48t59.c | 228 ++++-----------------------------------= ------ > 4 files changed, 283 insertions(+), 210 deletions(-) > create mode 100644 hw/timer/m48t59-internal.h > create mode 100644 hw/timer/m48t59-isa.c > > diff --git a/hw/timer/Makefile.objs b/hw/timer/Makefile.objs > index 7ba8c23..bf3ea3c 100644 > --- a/hw/timer/Makefile.objs > +++ b/hw/timer/Makefile.objs > @@ -6,6 +6,9 @@ common-obj-$(CONFIG_DS1338) +=3D ds1338.o > common-obj-$(CONFIG_HPET) +=3D hpet.o > common-obj-$(CONFIG_I8254) +=3D i8254_common.o i8254.o > common-obj-$(CONFIG_M48T59) +=3D m48t59.o > +ifeq ($(CONFIG_ISA_BUS),y) > +common-obj-$(CONFIG_M48T59) +=3D m48t59-isa.o > +endif > common-obj-$(CONFIG_PL031) +=3D pl031.o > common-obj-$(CONFIG_PUV3) +=3D puv3_ost.o > common-obj-$(CONFIG_TWL92230) +=3D twl92230.o > diff --git a/hw/timer/m48t59-internal.h b/hw/timer/m48t59-internal.h > new file mode 100644 > index 0000000..c50f134 > --- /dev/null > +++ b/hw/timer/m48t59-internal.h > @@ -0,0 +1,82 @@ > +/* > + * QEMU M48T59 and M48T08 NVRAM emulation (common header) > + * > + * Copyright (c) 2003-2005, 2007 Jocelyn Mayer > + * Copyright (c) 2013 Herv=C3=A9 Poussineau > + * > + * Permission is hereby granted, free of charge, to any person obtaining= a copy > + * of this software and associated documentation files (the "Software"),= to deal > + * in the Software without restriction, including without limitation the= rights > + * to use, copy, modify, merge, publish, distribute, sublicense, and/or = sell > + * copies of the Software, and to permit persons to whom the Software is > + * furnished to do so, subject to the following conditions: > + * > + * The above copyright notice and this permission notice shall be includ= ed in > + * all copies or substantial portions of the Software. > + * > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRE= SS OR > + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILI= TY, > + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHA= LL > + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR = OTHER > + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISI= NG FROM, > + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALING= S IN > + * THE SOFTWARE. > + */ > +#ifndef HW_M48T59_H > +#define HW_M48T59_H 1 > + > +//#define DEBUG_NVRAM > + > +#if defined(DEBUG_NVRAM) > +#define NVRAM_PRINTF(fmt, ...) do { printf(fmt , ## __VA_ARGS__); } whil= e (0) > +#else > +#define NVRAM_PRINTF(fmt, ...) do { } while (0) > +#endif > + > +/* > + * The M48T02, M48T08 and M48T59 chips are very similar. The newer '59 h= as > + * alarm and a watchdog timer and related control registers. In the > + * PPC platform there is also a nvram lock function. > + */ > + > +typedef struct M48txxInfo { > + const char *bus_name; > + uint32_t model; /* 2 =3D m48t02, 8 =3D m48t08, 59 =3D m48t59 */ > + uint32_t size; > +} M48txxInfo; > + > +typedef struct M48t59State { > + /* Hardware parameters */ > + qemu_irq IRQ; > + MemoryRegion iomem; > + uint32_t size; > + int32_t base_year; > + /* RTC management */ > + time_t time_offset; > + time_t stop_time; > + /* Alarm & watchdog */ > + struct tm alarm; > + QEMUTimer *alrm_timer; > + QEMUTimer *wd_timer; > + /* NVRAM storage */ > + uint8_t *buffer; > + /* Model parameters */ > + uint32_t model; /* 2 =3D m48t02, 8 =3D m48t08, 59 =3D m48t59 */ > + /* NVRAM storage */ > + uint16_t addr; > + uint8_t lock; > +} M48t59State; > + > +uint32_t m48t59_read(M48t59State *NVRAM, uint32_t addr); > +void m48t59_write(M48t59State *NVRAM, uint32_t addr, uint32_t val); > +void m48t59_reset_common(M48t59State *NVRAM); > +void m48t59_realize_common(M48t59State *s, Error **errp); > + > +static inline void m48t59_toggle_lock(M48t59State *NVRAM, int lock) > +{ > + NVRAM->lock ^=3D 1 << lock; > +} > + > +extern const MemoryRegionOps m48t59_io_ops; > + > +#endif /* HW_M48T59_H */ > diff --git a/hw/timer/m48t59-isa.c b/hw/timer/m48t59-isa.c > new file mode 100644 > index 0000000..3a521dc > --- /dev/null > +++ b/hw/timer/m48t59-isa.c > @@ -0,0 +1,180 @@ > +/* > + * QEMU M48T59 and M48T08 NVRAM emulation (ISA bus interface > + * > + * Copyright (c) 2003-2005, 2007 Jocelyn Mayer > + * Copyright (c) 2013 Herv=C3=A9 Poussineau > + * > + * Permission is hereby granted, free of charge, to any person obtaining= a copy > + * of this software and associated documentation files (the "Software"),= to deal > + * in the Software without restriction, including without limitation the= rights > + * to use, copy, modify, merge, publish, distribute, sublicense, and/or = sell > + * copies of the Software, and to permit persons to whom the Software is > + * furnished to do so, subject to the following conditions: > + * > + * The above copyright notice and this permission notice shall be includ= ed in > + * all copies or substantial portions of the Software. > + * > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRE= SS OR > + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILI= TY, > + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHA= LL > + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR = OTHER > + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISI= NG FROM, > + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALING= S IN > + * THE SOFTWARE. > + */ > +#include "hw/isa/isa.h" > +#include "hw/timer/m48t59.h" > +#include "m48t59-internal.h" > + > +#define TYPE_M48TXX_ISA "isa-m48txx" > +#define M48TXX_ISA_GET_CLASS(obj) \ > + OBJECT_GET_CLASS(M48txxISADeviceClass, (obj), TYPE_M48TXX_ISA) > +#define M48TXX_ISA_CLASS(klass) \ > + OBJECT_CLASS_CHECK(M48txxISADeviceClass, (klass), TYPE_M48TXX_ISA) > +#define M48TXX_ISA(obj) \ > + OBJECT_CHECK(M48txxISAState, (obj), TYPE_M48TXX_ISA) > + > +typedef struct M48txxISAState { > + ISADevice parent_obj; > + M48t59State state; > + uint32_t io_base; > + MemoryRegion io; > +} M48txxISAState; > + > +typedef struct M48txxISADeviceClass { > + ISADeviceClass parent_class; > + M48txxInfo info; > +} M48txxISADeviceClass; > + > +static M48txxInfo m48txx_isa_info[] =3D { > + { > + .bus_name =3D "isa-m48t59", > + .model =3D 59, > + .size =3D 0x2000, > + } > +}; > + > +Nvram *m48t59_init_isa(ISABus *bus, uint32_t io_base, uint16_t size, > + int base_year, int model) > +{ > + DeviceState *dev; > + int i; > + > + for (i =3D 0; i < ARRAY_SIZE(m48txx_isa_info); i++) { > + if (m48txx_isa_info[i].size !=3D size || > + m48txx_isa_info[i].model !=3D model) { > + continue; > + } > + > + dev =3D DEVICE(isa_create(bus, m48txx_isa_info[i].bus_name)); isa_create()'s second argument is a device model name, not a bus name. Please rename .bus_name accordingly. > + qdev_prop_set_uint32(dev, "iobase", io_base); > + qdev_prop_set_int32(dev, "base-year", base_year); > + qdev_init_nofail(dev); > + return NVRAM(dev); > + } > + > + assert(false); > + return NULL; > +} [...]