]> Git Repo - qemu.git/blobdiff - hw/pl031.c
monitor: Rework modal password input (Jan Kiszka)
[qemu.git] / hw / pl031.c
index 7e8098ba59dee38ad07e3cb0da96c8c7ad7f1144..8c629955c51b8a1c9278ba803f28b9382800c3f3 100644 (file)
@@ -9,7 +9,10 @@
  *
  */
 
-#include"vl.h"
+#include "hw.h"
+#include "primecell.h"
+#include "qemu-timer.h"
+#include "sysemu.h"
 
 //#define DEBUG_PL031
 
@@ -32,9 +35,7 @@ do { printf("pl031: " fmt , ##args); } while (0)
 typedef struct {
     QEMUTimer *timer;
     qemu_irq irq;
-    uint32_t base;
 
-    uint64_t start_time;
     uint32_t tick_offset;
 
     uint32_t mr;
@@ -94,8 +95,6 @@ static uint32_t pl031_read(void *opaque, target_phys_addr_t offset)
 {
     pl031_state *s = (pl031_state *)opaque;
 
-    offset -= s->base;
-
     if (offset >= 0xfe0  &&  offset < 0x1000)
         return pl031_id[(offset - 0xfe0) >> 2];
 
@@ -133,7 +132,6 @@ static void pl031_write(void * opaque, target_phys_addr_t offset,
 {
     pl031_state *s = (pl031_state *)opaque;
 
-    offset -= s->base;
 
     switch (offset) {
     case RTC_LR:
@@ -192,12 +190,9 @@ void pl031_init(uint32_t base, qemu_irq irq)
 {
     int iomemtype;
     pl031_state *s;
-    time_t ti;
-    struct tm *tm;
+    struct tm tm;
 
     s = qemu_mallocz(sizeof(pl031_state));
-    if (!s)
-        cpu_abort(cpu_single_env, "pl031_init: Out of memory\n");
 
     iomemtype = cpu_register_io_memory(0, pl031_readfn, pl031_writefn, s);
     if (iomemtype == -1)
@@ -205,15 +200,10 @@ void pl031_init(uint32_t base, qemu_irq irq)
 
     cpu_register_physical_memory(base, 0x00001000, iomemtype);
 
-    s->base = base;
     s->irq  = irq;
     /* ??? We assume vm_clock is zero at this point.  */
-    time(&ti);
-    if (rtc_utc)
-        tm = gmtime(&ti);
-    else
-        tm = localtime(&ti);
-    s->tick_offset = mktime(tm);
+    qemu_get_timedate(&tm, 0);
+    s->tick_offset = mktimegm(&tm);
 
     s->timer = qemu_new_timer(vm_clock, pl031_interrupt, s);
 }
This page took 0.025059 seconds and 4 git commands to generate.