From: Paolo Bonzini <pbonzini@redhat.com>
To: "H. Peter Anvin" <hpa@zytor.com>
Cc: Kevin O'Connor <kevin@koconnor.net>,
David Woodhouse <dwmw2@infradead.org>,
qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [RFC PATCH 3/3] mc146818rtc: export the timezone information
Date: Mon, 25 Mar 2013 10:05:13 +0100 [thread overview]
Message-ID: <51501349.8010702@redhat.com> (raw)
In-Reply-To: <1362017554-1260-3-git-send-email-hpa@zytor.com>
Il 28/02/2013 03:12, H. Peter Anvin ha scritto:
> From: "H. Peter Anvin" <hpa@zytor.com>
>
> There is no standard method for storing timezone information
> associated with the classic PC/AT RTC, however, there are standard
> methods in ACPI (Time and Alarm Device) and EFI (GetTime/SetTime) for
> getting this information.
>
> Since these are abstract methods, it is qreally firmware-specific how
> it is stored, however, since Qemu initializes the RTC in the virtual
> environment that information needs to come from Qemu in the first
> place.
>
> Non-PC platforms that use the MC146181 RTC may have their own
> firmware-specific methods as well.
>
> The most logical place to stash this information is in the RTC CMOS;
> not only is it logically co-located with the relevant information, but
> it is also very easy to access from ACPI bytecode. Thus, save the
> timezone information in two bytes in CMOS that have no known standard
> definition, but are yet within the 64 bytes that even the most basic
> RTC CMOS implementations including the original MC146181 support.
>
> Note: all timezones currently in use in the world are on 15-minutes
> boundaries, which would allow this information to be stored in a
> single signed byte. However, both EFI and ACPI use a minute-granular
> interface (specified as -1440 to +1440 with 2047 used to mean
> "unknown", this requires a minimum of 12 bits to represent); this
> follows that model.
Interesting, do you have SeaBIOS and/or OVMF patches for this?
Paolo
> Signed-off-by: H. Peter Anvin <hpa@zytor.com>
> Cc: "Kevin O'Connor" <kevin@koconnor.net>
> Cc: David Woodhouse <dwmw2@infradead.org>
> ---
> hw/mc146818rtc.c | 6 ++++++
> hw/mc146818rtc_regs.h | 2 ++
> 2 files changed, 8 insertions(+)
>
> diff --git a/hw/mc146818rtc.c b/hw/mc146818rtc.c
> index 2fb11f6..72541dd 100644
> --- a/hw/mc146818rtc.c
> +++ b/hw/mc146818rtc.c
> @@ -681,6 +681,7 @@ static void rtc_set_date_from_host(ISADevice *dev)
> {
> RTCState *s = DO_UPCAST(RTCState, dev, dev);
> struct tm tm;
> + int minuteseast;
>
> qemu_get_timedate(&tm, 0);
>
> @@ -690,6 +691,11 @@ static void rtc_set_date_from_host(ISADevice *dev)
>
> /* set the CMOS date */
> rtc_set_cmos(s, &tm);
> +
> + /* Set the timezone information as a signed 16-bit number of minutes */
> + minuteseast = ((int64_t)s->base_rtc - (int64_t)mktime(&tm)) / 60;
> + s->cmos_data[RTC_TIMEZONE_L] = (uint8_t)(minuteseast);
> + s->cmos_data[RTC_TIMEZONE_H] = (uint8_t)(minuteseast >> 8);
> }
>
> static int rtc_post_load(void *opaque, int version_id)
> diff --git a/hw/mc146818rtc_regs.h b/hw/mc146818rtc_regs.h
> index ccdee42..7dd5e0d 100644
> --- a/hw/mc146818rtc_regs.h
> +++ b/hw/mc146818rtc_regs.h
> @@ -47,6 +47,8 @@
> /* PC cmos mappings */
> #define RTC_CENTURY 0x32
> #define RTC_IBM_PS2_CENTURY_BYTE 0x37
> +#define RTC_TIMEZONE_L 0x3e
> +#define RTC_TIMEZONE_H 0x3f
>
> #define REG_A_UIP 0x80
>
>
next prev parent reply other threads:[~2013-03-25 9:05 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1362017554-1260-1-git-send-email-hpa@zytor.com>
2013-03-24 5:06 ` [Qemu-devel] [RFC PATCH 1/3] target-i386: Add 486sx, old486, and old486sx CPU models H. Peter Anvin
2013-03-25 9:06 ` Paolo Bonzini
2013-03-25 9:23 ` Andreas Färber
[not found] ` <1362017554-1260-3-git-send-email-hpa@zytor.com>
2013-03-25 9:05 ` Paolo Bonzini [this message]
2013-03-25 15:47 ` [Qemu-devel] [RFC PATCH 3/3] mc146818rtc: export the timezone information H. Peter Anvin
2013-03-25 15:51 ` Paolo Bonzini
2013-03-25 9:39 ` [Qemu-devel] [RFC PATCH 1/3] target-i386: Add 486sx, old486, and old486sx CPU models Andreas Färber
2013-03-25 15:15 ` Igor Mammedov
2013-03-25 18:44 ` H. Peter Anvin
2013-03-25 19:05 ` Eduardo Habkost
2013-03-25 20:45 ` H. Peter Anvin
2013-03-25 20:56 ` Eduardo Habkost
2013-03-25 20:56 ` H. Peter Anvin
2014-01-07 5:53 ` H. Peter Anvin
2014-01-07 9:08 ` Igor Mammedov
2013-03-25 20:47 ` H. Peter Anvin
2013-03-25 19:01 ` Eduardo Habkost
[not found] ` <1362017554-1260-2-git-send-email-hpa@zytor.com>
2013-03-28 19:15 ` [Qemu-devel] [RFC PATCH 2/3] target-i386: Raise #UD on accessing non-existent control registers Aurelien Jarno
2013-03-28 19:15 ` [Qemu-devel] [RFC PATCH 1/3] target-i386: Add 486sx, old486, and old486sx CPU models Aurelien Jarno
2013-03-28 20:02 ` H. Peter Anvin
2013-03-28 20:12 ` H. Peter Anvin
2013-03-29 5:10 ` Rob Landley
2013-03-29 5:25 ` H. Peter Anvin
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=51501349.8010702@redhat.com \
--to=pbonzini@redhat.com \
--cc=dwmw2@infradead.org \
--cc=hpa@zytor.com \
--cc=kevin@koconnor.net \
--cc=qemu-devel@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).