From: Artyom Tarasenko <atar4qemu@gmail.com>
To: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Cc: qemu-ppc@nongnu.org, qemu-devel <qemu-devel@nongnu.org>,
"Andreas Färber" <afaerber@suse.de>,
"Alexander Graf" <agraf@suse.de>
Subject: Re: [Qemu-devel] [PATCH 1/2] m48t59: introduce new year_offset qdev property
Date: Mon, 19 Jan 2015 13:06:34 +0100 [thread overview]
Message-ID: <CACXAS8C2m0upSDMn-pp141E-TfA1EDZHOBQhsko2fLE-PghFuA@mail.gmail.com> (raw)
In-Reply-To: <1421667328-11800-2-git-send-email-mark.cave-ayland@ilande.co.uk>
On Mon, Jan 19, 2015 at 12:35 PM, Mark Cave-Ayland
<mark.cave-ayland@ilande.co.uk> wrote:
> Currently the m48t59 device uses the hardware model in order to determine
> 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 <mark.cave-ayland@ilande.co.uk>
> ---
> 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 | 35 ++++++++++++++++-------------------
> include/hw/timer/m48t59.h | 5 +++--
> 6 files changed, 23 insertions(+), 25 deletions(-)
>
> diff --git a/hw/ppc/ppc405_boards.c b/hw/ppc/ppc405_boards.c
> index 1dcea77..2d8d2aa 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, 68, 8);
> /* Load kernel */
> linux_boot = (kernel_filename != NULL);
> if (linux_boot) {
> diff --git a/hw/ppc/prep.c b/hw/ppc/prep.c
> index 15df7f3..378a368 100644
> --- a/hw/ppc/prep.c
> +++ b/hw/ppc/prep.c
> @@ -543,7 +543,7 @@ static void ppc_prep_init(MachineState *machine)
> pci_create_simple(pci_bus, -1, "pci-ohci");
> }
>
> - m48t59 = m48t59_init_isa(isa_bus, 0x0074, NVRAM_SIZE, 59);
> + m48t59 = m48t59_init_isa(isa_bus, 0x0074, NVRAM_SIZE, 0, 59);
> if (m48t59 == NULL)
> return;
> sysctrl->nvram = m48t59;
> diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c
> index ecd9dc1..cde4a87 100644
> --- a/hw/sparc/sun4m.c
> +++ b/hw/sparc/sun4m.c
> @@ -1012,7 +1012,7 @@ static void sun4m_hw_init(const struct sun4m_hwdef *hwdef,
>
> lance_init(&nd_table[0], hwdef->le_base, ledma, ledma_irq);
>
> - nvram = m48t59_init(slavio_irq[0], hwdef->nvram_base, 0, 0x2000, 8);
> + nvram = 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 3ff5bd8..6b46511 100644
> --- a/hw/sparc64/sun4u.c
> +++ b/hw/sparc64/sun4u.c
> @@ -873,7 +873,7 @@ static void sun4uv_init(MemoryRegion *address_space_mem,
> fd[i] = drive_get(IF_FLOPPY, 0, i);
> }
> fdctrl_init_isa(isa_bus, fd);
> - nvram = m48t59_init_isa(isa_bus, 0x0074, NVRAM_SIZE, 59);
> + nvram = m48t59_init_isa(isa_bus, 0x0074, NVRAM_SIZE, 0, 59);
>
> initrd_size = 0;
> initrd_addr = 0;
> diff --git a/hw/timer/m48t59.c b/hw/timer/m48t59.c
> index 31509d5..0a05100 100644
> --- a/hw/timer/m48t59.c
> +++ b/hw/timer/m48t59.c
> @@ -56,6 +56,7 @@ struct M48t59State {
> MemoryRegion iomem;
> uint32_t io_base;
> uint32_t size;
> + uint32_t year_offset;
> /* RTC management */
> time_t time_offset;
> time_t stop_time;
> @@ -346,11 +347,7 @@ void m48t59_write (void *opaque, uint32_t addr, uint32_t val)
> tmp = from_bcd(val);
> if (tmp >= 0 && tmp <= 99) {
> get_time(NVRAM, &tm);
> - if (NVRAM->model == 8) {
> - tm.tm_year = from_bcd(val) + 68; // Base year is 1968
> - } else {
> - tm.tm_year = from_bcd(val);
> - }
> + tm.tm_year = from_bcd(val) + NVRAM->year_offset;
> set_time(NVRAM, &tm);
> }
> break;
> @@ -453,11 +450,7 @@ uint32_t m48t59_read (void *opaque, uint32_t addr)
> case 0x07FF:
> /* year */
> get_time(NVRAM, &tm);
> - if (NVRAM->model == 8) {
> - retval = to_bcd(tm.tm_year - 68); // Base year is 1968
> - } else {
> - retval = to_bcd(tm.tm_year);
> - }
> + retval = to_bcd(tm.tm_year - NVRAM->year_offset);
> break;
> default:
> /* Check lock registers state */
> @@ -641,8 +634,8 @@ static const MemoryRegionOps m48t59_io_ops = {
> };
>
> /* Initialisation routine */
> -M48t59State *m48t59_init(qemu_irq IRQ, hwaddr mem_base,
> - uint32_t io_base, uint16_t size, int model)
> +M48t59State *m48t59_init(qemu_irq IRQ, hwaddr mem_base, uint32_t io_base,
> + uint16_t size, uint32_t year_offset, int model)
> {
> DeviceState *dev;
> SysBusDevice *s;
> @@ -653,6 +646,7 @@ M48t59State *m48t59_init(qemu_irq IRQ, hwaddr mem_base,
> qdev_prop_set_uint32(dev, "model", model);
> qdev_prop_set_uint32(dev, "size", size);
> qdev_prop_set_uint32(dev, "io_base", io_base);
> + qdev_prop_set_uint32(dev, "year_offset", year_offset);
> qdev_init_nofail(dev);
> s = SYS_BUS_DEVICE(dev);
> d = SYSBUS_M48T59(dev);
> @@ -671,7 +665,7 @@ M48t59State *m48t59_init(qemu_irq IRQ, hwaddr mem_base,
> }
>
> M48t59State *m48t59_init_isa(ISABus *bus, uint32_t io_base, uint16_t size,
> - int model)
> + uint32_t year_offset, int model)
> {
> M48t59ISAState *d;
> ISADevice *isadev;
> @@ -683,6 +677,7 @@ M48t59State *m48t59_init_isa(ISABus *bus, uint32_t io_base, uint16_t size,
> qdev_prop_set_uint32(dev, "model", model);
> qdev_prop_set_uint32(dev, "size", size);
> qdev_prop_set_uint32(dev, "io_base", io_base);
> + qdev_prop_set_uint32(dev, "year_offset", year_offset);
> qdev_init_nofail(dev);
> d = ISA_M48T59(isadev);
> s = &d->state;
> @@ -738,9 +733,10 @@ static int m48t59_init1(SysBusDevice *dev)
> }
>
> static Property m48t59_isa_properties[] = {
> - DEFINE_PROP_UINT32("size", M48t59ISAState, state.size, -1),
> - DEFINE_PROP_UINT32("model", M48t59ISAState, state.model, -1),
> - DEFINE_PROP_UINT32("io_base", M48t59ISAState, state.io_base, 0),
> + DEFINE_PROP_UINT32("size", M48t59ISAState, state.size, -1),
> + DEFINE_PROP_UINT32("model", M48t59ISAState, state.model, -1),
> + DEFINE_PROP_UINT32("io_base", M48t59ISAState, state.io_base, 0),
Formatting-only change?
> + DEFINE_PROP_UINT32("year_offset", M48t59ISAState, state.year_offset, 0),
> DEFINE_PROP_END_OF_LIST(),
> };
>
> @@ -763,9 +759,10 @@ static const TypeInfo m48t59_isa_info = {
> };
>
> static Property m48t59_properties[] = {
> - DEFINE_PROP_UINT32("size", M48t59SysBusState, state.size, -1),
> - DEFINE_PROP_UINT32("model", M48t59SysBusState, state.model, -1),
> - DEFINE_PROP_UINT32("io_base", M48t59SysBusState, state.io_base, 0),
> + DEFINE_PROP_UINT32("size", M48t59SysBusState, state.size, -1),
> + DEFINE_PROP_UINT32("model", M48t59SysBusState, state.model, -1),
> + DEFINE_PROP_UINT32("io_base", M48t59SysBusState, state.io_base, 0),
> + DEFINE_PROP_UINT32("year_offset", M48t59SysBusState, state.year_offset, 0),
> DEFINE_PROP_END_OF_LIST(),
> };
>
> diff --git a/include/hw/timer/m48t59.h b/include/hw/timer/m48t59.h
> index 8217522..08252b6 100644
> --- a/include/hw/timer/m48t59.h
> +++ b/include/hw/timer/m48t59.h
> @@ -30,8 +30,9 @@ void m48t59_write (void *private, uint32_t addr, uint32_t val);
> uint32_t m48t59_read (void *private, uint32_t addr);
> void m48t59_toggle_lock (void *private, int lock);
> M48t59State *m48t59_init_isa(ISABus *bus, uint32_t io_base, uint16_t size,
> - int type);
> + uint32_t year_offset, int type);
> M48t59State *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_offset, int type);
>
> #endif /* !NVRAM_H */
> --
> 1.7.10.4
>
--
Regards,
Artyom Tarasenko
SPARC and PPC PReP under qemu blog: http://tyom.blogspot.com/search/label/qemu
next prev parent reply other threads:[~2015-01-19 12:07 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-19 11:35 [Qemu-devel] [PATCH 0/2] m48t59: add year offset and MMIO ISA mapping Mark Cave-Ayland
2015-01-19 11:35 ` [Qemu-devel] [PATCH 1/2] m48t59: introduce new year_offset qdev property Mark Cave-Ayland
2015-01-19 12:06 ` Artyom Tarasenko [this message]
2015-01-19 12:20 ` Mark Cave-Ayland
2015-01-19 11:35 ` [Qemu-devel] [PATCH 2/2] m48t59: add mem_base value to m48t59_init_isa() Mark Cave-Ayland
2015-01-19 12:45 ` Paolo Bonzini
2015-01-19 12:57 ` Artyom Tarasenko
2015-01-19 12:59 ` Paolo Bonzini
2015-01-19 13:12 ` Artyom Tarasenko
2015-01-19 15:01 ` Andreas Färber
2015-01-19 15:22 ` Artyom Tarasenko
2015-01-19 15:31 ` Paolo Bonzini
2015-01-19 15:38 ` Andreas Färber
2015-01-19 16:01 ` Paolo Bonzini
2015-01-19 16:17 ` Artyom Tarasenko
2015-01-19 16:34 ` Paolo Bonzini
2015-01-19 18:17 ` Maciej W. Rozycki
2015-01-19 16:57 ` Mark Cave-Ayland
2015-01-19 16:55 ` Mark Cave-Ayland
2015-01-19 20:03 ` Andreas Färber
2015-01-20 9:54 ` Artyom Tarasenko
2015-01-19 16:42 ` Mark Cave-Ayland
2015-01-19 21:16 ` Hervé Poussineau
2015-01-19 15:04 ` Peter Maydell
2015-01-19 16:48 ` Mark Cave-Ayland
2015-01-19 16:50 ` Peter Maydell
2015-01-19 12:09 ` [Qemu-devel] [PATCH 0/2] m48t59: add year offset and MMIO ISA mapping Artyom Tarasenko
2015-01-19 21:59 ` Hervé Poussineau
2015-01-20 10:16 ` Artyom Tarasenko
2015-01-20 14:19 ` Mark Cave-Ayland
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=CACXAS8C2m0upSDMn-pp141E-TfA1EDZHOBQhsko2fLE-PghFuA@mail.gmail.com \
--to=atar4qemu@gmail.com \
--cc=afaerber@suse.de \
--cc=agraf@suse.de \
--cc=mark.cave-ayland@ilande.co.uk \
--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).