From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55312) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YI0ab-0000PI-5t for qemu-devel@nongnu.org; Sun, 01 Feb 2015 14:53:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YI0aW-0002EI-0h for qemu-devel@nongnu.org; Sun, 01 Feb 2015 14:53:49 -0500 Received: from smtp2-g21.free.fr ([212.27.42.2]:27496) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YI0aV-0002Dp-OE for qemu-devel@nongnu.org; Sun, 01 Feb 2015 14:53:43 -0500 Message-ID: <54CE839C.5030600@reactos.org> Date: Sun, 01 Feb 2015 20:50:52 +0100 From: =?windows-1252?Q?Herv=E9_Poussineau?= MIME-Version: 1.0 References: <1422815953-12919-1-git-send-email-mark.cave-ayland@ilande.co.uk> <1422815953-12919-2-git-send-email-mark.cave-ayland@ilande.co.uk> In-Reply-To: <1422815953-12919-2-git-send-email-mark.cave-ayland@ilande.co.uk> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCHv2 1/2] m48t59: introduce new year_offset qdev property List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Mark Cave-Ayland , qemu-devel@nongnu.org, atar4qemu@gmail.com Le 01/02/2015 19:39, Mark Cave-Ayland a =E9crit : > Currently the m48t59 device uses the hardware model in order to determi= ne > whether the year value is offset from the hardware value. As this will > soon be required by the x59 model, change the year offset to a qdev > property and update the callers appropriately. > > Signed-off-by: Mark Cave-Ayland Hi, Is it possible to use a 'base_year' property, like in the mc146818rtc dev= ice? Usual values will be 0 (for year 2000) and 1968 (for sun4m). Regards, Herv=E9 > --- > hw/ppc/ppc405_boards.c | 2 +- > hw/ppc/prep.c | 2 +- > hw/sparc/sun4m.c | 2 +- > hw/sparc64/sun4u.c | 2 +- > hw/timer/m48t59.c | 27 +++++++++++++++------------ > include/hw/timer/m48t59.h | 5 +++-- > 6 files changed, 22 insertions(+), 18 deletions(-) > > diff --git a/hw/ppc/ppc405_boards.c b/hw/ppc/ppc405_boards.c > index 1dcea77..c0c154f 100644 > --- a/hw/ppc/ppc405_boards.c > +++ b/hw/ppc/ppc405_boards.c > @@ -283,7 +283,7 @@ static void ref405ep_init(MachineState *machine) > #ifdef DEBUG_BOARD_INIT > printf("%s: register NVRAM\n", __func__); > #endif > - m48t59_init(NULL, 0xF0000000, 0, 8192, 8); > + m48t59_init(NULL, 0xF0000000, 0, 8192, 0, 8); > /* Load kernel */ > linux_boot =3D (kernel_filename !=3D NULL); > if (linux_boot) { > diff --git a/hw/ppc/prep.c b/hw/ppc/prep.c > index 9290846..55e23e3 100644 > --- a/hw/ppc/prep.c > +++ b/hw/ppc/prep.c > @@ -684,7 +684,7 @@ static void ppc_prep_init(MachineState *machine) > pci_create_simple(pci_bus, -1, "pci-ohci"); > } > > - m48t59 =3D m48t59_init_isa(isa_bus, 0x0074, NVRAM_SIZE, 59); > + m48t59 =3D m48t59_init_isa(isa_bus, 0x0074, NVRAM_SIZE, 0, 59); > if (m48t59 =3D=3D NULL) > return; > sysctrl->nvram =3D m48t59; > diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c > index 5ff7c5b..d5b2966 100644 > --- a/hw/sparc/sun4m.c > +++ b/hw/sparc/sun4m.c > @@ -1014,7 +1014,7 @@ static void sun4m_hw_init(const struct sun4m_hwde= f *hwdef, > > lance_init(&nd_table[0], hwdef->le_base, ledma, ledma_irq); > > - nvram =3D m48t59_init(slavio_irq[0], hwdef->nvram_base, 0, 0x2000,= 8); > + nvram =3D m48t59_init(slavio_irq[0], hwdef->nvram_base, 0, 0x2000,= 68, 8); > > slavio_timer_init_all(hwdef->counter_base, slavio_irq[19], slavio= _cpu_irq, smp_cpus); > > diff --git a/hw/sparc64/sun4u.c b/hw/sparc64/sun4u.c > index 5833484..0dbc654 100644 > --- a/hw/sparc64/sun4u.c > +++ b/hw/sparc64/sun4u.c > @@ -876,7 +876,7 @@ static void sun4uv_init(MemoryRegion *address_space= _mem, > fd[i] =3D drive_get(IF_FLOPPY, 0, i); > } > fdctrl_init_isa(isa_bus, fd); > - nvram =3D m48t59_init_isa(isa_bus, 0x0074, NVRAM_SIZE, 59); > + nvram =3D m48t59_init_isa(isa_bus, 0x0074, NVRAM_SIZE, 0, 59); > > initrd_size =3D 0; > initrd_addr =3D 0; > diff --git a/hw/timer/m48t59.c b/hw/timer/m48t59.c > index 08f0d57..ec420bd 100644 > --- a/hw/timer/m48t59.c > +++ b/hw/timer/m48t59.c > @@ -79,6 +79,7 @@ typedef struct M48t59State { > qemu_irq IRQ; > MemoryRegion iomem; > uint32_t size; > + uint32_t year_offset; > /* RTC management */ > time_t time_offset; > time_t stop_time; > @@ -387,11 +388,7 @@ static void m48t59_write(M48t59State *NVRAM, uint3= 2_t addr, uint32_t val) > tmp =3D from_bcd(val); > if (tmp >=3D 0 && tmp <=3D 99) { > get_time(NVRAM, &tm); > - if (NVRAM->model =3D=3D 8) { > - tm.tm_year =3D from_bcd(val) + 68; // Base year is 196= 8 > - } else { > - tm.tm_year =3D from_bcd(val); > - } > + tm.tm_year =3D from_bcd(val) + NVRAM->year_offset; > set_time(NVRAM, &tm); > } > break; > @@ -493,11 +490,7 @@ static uint32_t m48t59_read(M48t59State *NVRAM, ui= nt32_t addr) > case 0x07FF: > /* year */ > get_time(NVRAM, &tm); > - if (NVRAM->model =3D=3D 8) { > - retval =3D to_bcd(tm.tm_year - 68); // Base year is 1968 > - } else { > - retval =3D to_bcd(tm.tm_year); > - } > + retval =3D to_bcd(tm.tm_year - NVRAM->year_offset); > break; > default: > /* Check lock registers state */ > @@ -680,7 +673,8 @@ static const MemoryRegionOps m48t59_io_ops =3D { > > /* Initialisation routine */ > Nvram *m48t59_init(qemu_irq IRQ, hwaddr mem_base, > - uint32_t io_base, uint16_t size, int model) > + uint32_t io_base, uint16_t size, uint32_t year_offs= et, > + int model) > { > DeviceState *dev; > SysBusDevice *s; > @@ -694,6 +688,7 @@ Nvram *m48t59_init(qemu_irq IRQ, hwaddr mem_base, > } > > dev =3D qdev_create(NULL, m48txx_info[i].sysbus_name); > + qdev_prop_set_uint32(dev, "year_offset", year_offset); > qdev_init_nofail(dev); > s =3D SYS_BUS_DEVICE(dev); > sysbus_connect_irq(s, 0, IRQ); > @@ -713,7 +708,7 @@ Nvram *m48t59_init(qemu_irq IRQ, hwaddr mem_base, > } > > Nvram *m48t59_init_isa(ISABus *bus, uint32_t io_base, uint16_t size, > - int model) > + uint32_t year_offset, int model) > { > DeviceState *dev; > int i; > @@ -727,6 +722,7 @@ Nvram *m48t59_init_isa(ISABus *bus, uint32_t io_bas= e, uint16_t size, > > dev =3D DEVICE(isa_create(bus, m48txx_info[i].isa_name)); > qdev_prop_set_uint32(dev, "iobase", io_base); > + qdev_prop_set_uint32(dev, "year_offset", year_offset); > qdev_init_nofail(dev); > return NVRAM(dev); > } > @@ -809,6 +805,7 @@ static void m48txx_isa_toggle_lock(Nvram *obj, int = lock) > } > > static Property m48t59_isa_properties[] =3D { > + DEFINE_PROP_UINT32("year_offset", M48txxISAState, state.year_offse= t, 0), > DEFINE_PROP_UINT32("iobase", M48txxISAState, io_base, 0x74), > DEFINE_PROP_END_OF_LIST(), > }; > @@ -852,6 +849,11 @@ static void m48txx_sysbus_toggle_lock(Nvram *obj, = int lock) > m48t59_toggle_lock(&d->state, lock); > } > > +static Property m48t59_sysbus_properties[] =3D { > + DEFINE_PROP_UINT32("year_offset", M48txxSysBusState, state.year_of= fset, 0), > + DEFINE_PROP_END_OF_LIST(), > +}; > + > static void m48txx_sysbus_class_init(ObjectClass *klass, void *data) > { > DeviceClass *dc =3D DEVICE_CLASS(klass); > @@ -860,6 +862,7 @@ static void m48txx_sysbus_class_init(ObjectClass *k= lass, void *data) > > k->init =3D m48t59_init1; > dc->reset =3D m48t59_reset_sysbus; > + dc->props =3D m48t59_sysbus_properties; > nc->read =3D m48txx_sysbus_read; > nc->write =3D m48txx_sysbus_write; > nc->toggle_lock =3D m48txx_sysbus_toggle_lock; > diff --git a/include/hw/timer/m48t59.h b/include/hw/timer/m48t59.h > index cf80d20..00277fb 100644 > --- a/include/hw/timer/m48t59.h > +++ b/include/hw/timer/m48t59.h > @@ -26,8 +26,9 @@ typedef struct NvramClass { > } NvramClass; > > Nvram *m48t59_init_isa(ISABus *bus, uint32_t io_base, uint16_t size, > - int type); > + uint32_t year_offset, int type); > Nvram *m48t59_init(qemu_irq IRQ, hwaddr mem_base, > - uint32_t io_base, uint16_t size, int type); > + uint32_t io_base, uint16_t size, uint32_t year_offs= et, > + int type); > > #endif /* !NVRAM_H */ >