qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "M. Warner Losh" <imp@bsdimp.com>
To: qemu-devel@nongnu.org, sdbrady@ntlworld.com
Subject: Re: [Qemu-devel] [RESEND][PATCH] Support epoch of 1980 in RTC emulation for MIPS Magnum
Date: Sun, 18 Jan 2009 10:33:17 -0700 (MST)	[thread overview]
Message-ID: <20090118.103317.1324555335.imp@bsdimp.com> (raw)
In-Reply-To: <20090118135141.GA17928@miranda.arrow>

In message: <20090118135141.GA17928@miranda.arrow>
            Stuart Brady <sdbrady@ntlworld.com> writes:
: On the MIPS Magnum, the time that is held in the RTC's NVRAM should be
: relative to midnight on 1980-01-01.  This patch adds an extra parameter
: to rtc_init(), allowing different epochs to be used.  For the Magnum,
: 1980 is specified, and for all other machines, 2000 is specified.
: 
: I've not modified the handling of the century byte, as with an epoch of
: 1980 and a year of 2009, one could argue that it should hold either
: 0, 1, 19 or 20.  NT 3.50 on MIPS does not read the century byte.

I've also confirmed that neither NetBSD/arc nor the one version of
OpenBSD/arc that I could find read this byte.  Linux also supports
this machine, but I can't imagine they'd read this byte in that code.
I've not had the energy to track that down.

Warner

: Signed-off-by: Stuart Brady <stuart.brady@gmail.com>
: 
: Index: hw/ppc_prep.c
: ===================================================================
: --- hw/ppc_prep.c	(revision 6360)
: +++ hw/ppc_prep.c	(working copy)
: @@ -659,7 +659,7 @@
:                   vga_ram_size, 0, 0);
:      //    openpic = openpic_init(0x00000000, 0xF0000000, 1);
:      //    pit = pit_init(0x40, i8259[0]);
: -    rtc_init(0x70, i8259[8]);
: +    rtc_init(0x70, i8259[8], 2000);
:  
:      serial_init(0x3f8, i8259[4], 115200, serial_hds[0]);
:      nb_nics1 = nb_nics;
: Index: hw/mc146818rtc.c
: ===================================================================
: --- hw/mc146818rtc.c	(revision 6360)
: +++ hw/mc146818rtc.c	(working copy)
: @@ -60,6 +60,7 @@
:      uint8_t cmos_data[128];
:      uint8_t cmos_index;
:      struct tm current_tm;
: +    int base_year;
:      qemu_irq irq;
:      int it_shift;
:      /* periodic timer */
: @@ -235,7 +236,7 @@
:      tm->tm_wday = from_bcd(s, s->cmos_data[RTC_DAY_OF_WEEK]) - 1;
:      tm->tm_mday = from_bcd(s, s->cmos_data[RTC_DAY_OF_MONTH]);
:      tm->tm_mon = from_bcd(s, s->cmos_data[RTC_MONTH]) - 1;
: -    tm->tm_year = from_bcd(s, s->cmos_data[RTC_YEAR]) + 100;
: +    tm->tm_year = from_bcd(s, s->cmos_data[RTC_YEAR]) + s->base_year - 1900;
:  }
:  
:  static void rtc_copy_date(RTCState *s)
: @@ -256,7 +257,8 @@
:      s->cmos_data[RTC_DAY_OF_WEEK] = to_bcd(s, tm->tm_wday + 1);
:      s->cmos_data[RTC_DAY_OF_MONTH] = to_bcd(s, tm->tm_mday);
:      s->cmos_data[RTC_MONTH] = to_bcd(s, tm->tm_mon + 1);
: -    s->cmos_data[RTC_YEAR] = to_bcd(s, tm->tm_year % 100);
: +    s->cmos_data[RTC_YEAR] = to_bcd(s, (tm->tm_year + 10000 - s->base_year)
: +                                       % 100);
:  }
:  
:  /* month is between 0 and 11. */
: @@ -522,7 +524,7 @@
:  }
:  #endif
:  
: -RTCState *rtc_init(int base, qemu_irq irq)
: +RTCState *rtc_init(int base, qemu_irq irq, int base_year)
:  {
:      RTCState *s;
:  
: @@ -536,6 +538,7 @@
:      s->cmos_data[RTC_REG_C] = 0x00;
:      s->cmos_data[RTC_REG_D] = 0x80;
:  
: +    s->base_year = base_year;
:      rtc_set_date_from_host(s);
:  
:      s->periodic_timer = qemu_new_timer(vm_clock,
: @@ -631,7 +634,8 @@
:      &cmos_mm_writel,
:  };
:  
: -RTCState *rtc_mm_init(target_phys_addr_t base, int it_shift, qemu_irq irq)
: +RTCState *rtc_mm_init(target_phys_addr_t base, int it_shift, qemu_irq irq,
: +                      int base_year)
:  {
:      RTCState *s;
:      int io_memory;
: @@ -646,6 +650,7 @@
:      s->cmos_data[RTC_REG_C] = 0x00;
:      s->cmos_data[RTC_REG_D] = 0x80;
:  
: +    s->base_year = base_year;
:      rtc_set_date_from_host(s);
:  
:      s->periodic_timer = qemu_new_timer(vm_clock,
: Index: hw/mips_jazz.c
: ===================================================================
: --- hw/mips_jazz.c	(revision 6360)
: +++ hw/mips_jazz.c	(working copy)
: @@ -241,7 +241,7 @@
:      fdctrl_init(rc4030[1], 0, 1, 0x80003000, fds);
:  
:      /* Real time clock */
: -    rtc_init(0x70, i8259[8]);
: +    rtc_init(0x70, i8259[8], 1980);
:      s_rtc = cpu_register_io_memory(0, rtc_read, rtc_write, env);
:      cpu_register_physical_memory(0x80004000, 0x00001000, s_rtc);
:  
: Index: hw/mips_malta.c
: ===================================================================
: --- hw/mips_malta.c	(revision 6360)
: +++ hw/mips_malta.c	(working copy)
: @@ -913,7 +913,7 @@
:  
:      /* Super I/O */
:      i8042_init(i8259[1], i8259[12], 0x60);
: -    rtc_state = rtc_init(0x70, i8259[8]);
: +    rtc_state = rtc_init(0x70, i8259[8], 2000);
:      if (serial_hds[0])
:          serial_init(0x3f8, i8259[4], 115200, serial_hds[0]);
:      if (serial_hds[1])
: Index: hw/pc.c
: ===================================================================
: --- hw/pc.c	(revision 6360)
: +++ hw/pc.c	(working copy)
: @@ -968,7 +968,7 @@
:          }
:      }
:  
: -    rtc_state = rtc_init(0x70, i8259[8]);
: +    rtc_state = rtc_init(0x70, i8259[8], 2000);
:  
:      qemu_register_boot_set(pc_boot_set, rtc_state);
:  
: Index: hw/pc.h
: ===================================================================
: --- hw/pc.h	(revision 6360)
: +++ hw/pc.h	(working copy)
: @@ -83,8 +83,9 @@
:  
:  typedef struct RTCState RTCState;
:  
: -RTCState *rtc_init(int base, qemu_irq irq);
: -RTCState *rtc_mm_init(target_phys_addr_t base, int it_shift, qemu_irq irq);
: +RTCState *rtc_init(int base, qemu_irq irq, int base_year);
: +RTCState *rtc_mm_init(target_phys_addr_t base, int it_shift, qemu_irq irq,
: +                      int base_year);
:  void rtc_set_memory(RTCState *s, int addr, int val);
:  void rtc_set_date(RTCState *s, const struct tm *tm);
:  void cmos_set_s3_resume(void);
: Index: hw/mips_r4k.c
: ===================================================================
: --- hw/mips_r4k.c	(revision 6360)
: +++ hw/mips_r4k.c	(working copy)
: @@ -229,7 +229,7 @@
:      /* The PIC is attached to the MIPS CPU INT0 pin */
:      i8259 = i8259_init(env->irq[2]);
:  
: -    rtc_state = rtc_init(0x70, i8259[8]);
: +    rtc_state = rtc_init(0x70, i8259[8], 2000);
:  
:      /* Register 64 KB of ISA IO space at 0x14000000 */
:      isa_mmio_init(0x14000000, 0x00010000);
: -- 
: Stuart Brady
: 
: 
: 

  reply	other threads:[~2009-01-18 17:35 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-18 13:51 [Qemu-devel] [RESEND][PATCH] Support epoch of 1980 in RTC emulation for MIPS Magnum Stuart Brady
2009-01-18 17:33 ` M. Warner Losh [this message]
2009-01-24 18:06 ` Aurelien Jarno

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=20090118.103317.1324555335.imp@bsdimp.com \
    --to=imp@bsdimp.com \
    --cc=qemu-devel@nongnu.org \
    --cc=sdbrady@ntlworld.com \
    /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).