summaryrefslogtreecommitdiff
path: root/hw/mc146818rtc.c
diff options
context:
space:
mode:
authorIsaku Yamahata <yamahata@valinux.co.jp>2010-05-14 16:29:17 +0900
committerBlue Swirl <blauwirbel@gmail.com>2010-05-15 16:21:49 +0000
commit1d914fa0af66024faee8cc6fa3043a935f95f775 (patch)
tree76fe5f88cb67e1f4e5f322fda4c44eb81b3a4859 /hw/mc146818rtc.c
parente1460e4707cd80982add597f5cb421289db84e4e (diff)
rtc: make rtc_xxx accept/return ISADevice instead of RTCState.
To match rtc_xxx with qdev, make rtc_xxx accept and return ISADevice instead of RTCState. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Acked-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Diffstat (limited to 'hw/mc146818rtc.c')
-rw-r--r--hw/mc146818rtc.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/hw/mc146818rtc.c b/hw/mc146818rtc.c
index 905e67016c..450d218509 100644
--- a/hw/mc146818rtc.c
+++ b/hw/mc146818rtc.c
@@ -28,6 +28,7 @@
#include "apic.h"
#include "isa.h"
#include "hpet_emul.h"
+#include "mc146818rtc.h"
//#define DEBUG_CMOS
@@ -65,7 +66,7 @@
#define REG_C_PF 0x40
#define REG_C_AF 0x20
-struct RTCState {
+typedef struct RTCState {
ISADevice dev;
uint8_t cmos_data[128];
uint8_t cmos_index;
@@ -85,7 +86,7 @@ struct RTCState {
QEMUTimer *coalesced_timer;
QEMUTimer *second_timer;
QEMUTimer *second_timer2;
-};
+} RTCState;
static void rtc_irq_raise(qemu_irq irq)
{
@@ -492,14 +493,16 @@ static uint32_t cmos_ioport_read(void *opaque, uint32_t addr)
}
}
-void rtc_set_memory(RTCState *s, int addr, int val)
+void rtc_set_memory(ISADevice *dev, int addr, int val)
{
+ RTCState *s = DO_UPCAST(RTCState, dev, dev);
if (addr >= 0 && addr <= 127)
s->cmos_data[addr] = val;
}
-void rtc_set_date(RTCState *s, const struct tm *tm)
+void rtc_set_date(ISADevice *dev, const struct tm *tm)
{
+ RTCState *s = DO_UPCAST(RTCState, dev, dev);
s->current_tm = *tm;
rtc_copy_date(s);
}
@@ -508,18 +511,19 @@ void rtc_set_date(RTCState *s, const struct tm *tm)
#define REG_IBM_CENTURY_BYTE 0x32
#define REG_IBM_PS2_CENTURY_BYTE 0x37
-static void rtc_set_date_from_host(RTCState *s)
+static void rtc_set_date_from_host(ISADevice *dev)
{
+ RTCState *s = DO_UPCAST(RTCState, dev, dev);
struct tm tm;
int val;
/* set the CMOS date */
qemu_get_timedate(&tm, 0);
- rtc_set_date(s, &tm);
+ rtc_set_date(dev, &tm);
val = rtc_to_bcd(s, (tm.tm_year / 100) + 19);
- rtc_set_memory(s, REG_IBM_CENTURY_BYTE, val);
- rtc_set_memory(s, REG_IBM_PS2_CENTURY_BYTE, val);
+ rtc_set_memory(dev, REG_IBM_CENTURY_BYTE, val);
+ rtc_set_memory(dev, REG_IBM_PS2_CENTURY_BYTE, val);
}
static int rtc_post_load(void *opaque, int version_id)
@@ -591,7 +595,7 @@ static int rtc_initfn(ISADevice *dev)
s->cmos_data[RTC_REG_C] = 0x00;
s->cmos_data[RTC_REG_D] = 0x80;
- rtc_set_date_from_host(s);
+ rtc_set_date_from_host(dev);
s->periodic_timer = qemu_new_timer(rtc_clock, rtc_periodic_timer, s);
#ifdef TARGET_I386
@@ -614,14 +618,14 @@ static int rtc_initfn(ISADevice *dev)
return 0;
}
-RTCState *rtc_init(int base_year)
+ISADevice *rtc_init(int base_year)
{
ISADevice *dev;
dev = isa_create("mc146818rtc");
qdev_prop_set_int32(&dev->qdev, "base_year", base_year);
qdev_init_nofail(&dev->qdev);
- return DO_UPCAST(RTCState, dev, dev);
+ return dev;
}
static ISADeviceInfo mc146818rtc_info = {