aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
Diffstat (limited to 'hw')
-rw-r--r--hw/mc146818rtc.c26
-rw-r--r--hw/mc146818rtc.h8
-rw-r--r--hw/mips_jazz.c1
-rw-r--r--hw/mips_malta.c3
-rw-r--r--hw/mips_r4k.c3
-rw-r--r--hw/pc.c11
-rw-r--r--hw/pc.h5
-rw-r--r--hw/pc_piix.c2
-rw-r--r--hw/ppc_prep.c1
9 files changed, 34 insertions, 26 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 = {
diff --git a/hw/mc146818rtc.h b/hw/mc146818rtc.h
index 7211dae37e..6f46a68e02 100644
--- a/hw/mc146818rtc.h
+++ b/hw/mc146818rtc.h
@@ -1,10 +1,10 @@
#ifndef MC146818RTC_H
#define MC146818RTC_H
-typedef struct RTCState RTCState;
+#include "isa.h"
-RTCState *rtc_init(int base_year);
-void rtc_set_memory(RTCState *s, int addr, int val);
-void rtc_set_date(RTCState *s, const struct tm *tm);
+ISADevice *rtc_init(int base_year);
+void rtc_set_memory(ISADevice *dev, int addr, int val);
+void rtc_set_date(ISADevice *dev, const struct tm *tm);
#endif /* !MC146818RTC_H */
diff --git a/hw/mips_jazz.c b/hw/mips_jazz.c
index 560959777b..6e0ec8fd36 100644
--- a/hw/mips_jazz.c
+++ b/hw/mips_jazz.c
@@ -35,6 +35,7 @@
#include "esp.h"
#include "mips-bios.h"
#include "loader.h"
+#include "mc146818rtc.h"
enum jazz_model_e
{
diff --git a/hw/mips_malta.c b/hw/mips_malta.c
index 586c1c3b2f..792709bf5a 100644
--- a/hw/mips_malta.c
+++ b/hw/mips_malta.c
@@ -44,6 +44,7 @@
#include "ide.h"
#include "loader.h"
#include "elf.h"
+#include "mc146818rtc.h"
//#define DEBUG_BOARD_INIT
@@ -776,7 +777,7 @@ void mips_malta_init (ram_addr_t ram_size,
PCIBus *pci_bus;
ISADevice *isa_dev;
CPUState *env;
- RTCState *rtc_state;
+ ISADevice *rtc_state;
FDCtrl *floppy_controller;
MaltaFPGAState *malta_fpga;
qemu_irq *i8259;
diff --git a/hw/mips_r4k.c b/hw/mips_r4k.c
index 0d5e2a626a..f1fcfcd2ed 100644
--- a/hw/mips_r4k.c
+++ b/hw/mips_r4k.c
@@ -21,6 +21,7 @@
#include "ide.h"
#include "loader.h"
#include "elf.h"
+#include "mc146818rtc.h"
#define MAX_IDE_BUS 2
@@ -165,7 +166,7 @@ void mips_r4k_init (ram_addr_t ram_size,
int bios_size;
CPUState *env;
ResetData *reset_info;
- RTCState *rtc_state;
+ ISADevice *rtc_state;
int i;
qemu_irq *i8259;
DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
diff --git a/hw/pc.c b/hw/pc.c
index 4f650498c7..20dc7fdb51 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -34,6 +34,7 @@
#include "loader.h"
#include "elf.h"
#include "multiboot.h"
+#include "mc146818rtc.h"
/* output Bochs bios info messages */
//#define DEBUG_BIOS
@@ -192,7 +193,7 @@ static int cmos_get_fd_drive_type(int fd0)
}
static void cmos_init_hd(int type_ofs, int info_ofs, BlockDriverState *hd,
- RTCState *s)
+ ISADevice *s)
{
int cylinders, heads, sectors;
bdrv_get_geometry_hint(hd, &cylinders, &heads, &sectors);
@@ -225,7 +226,7 @@ static int boot_device2nibble(char boot_device)
return 0;
}
-static int set_boot_dev(RTCState *s, const char *boot_device, int fd_bootchk)
+static int set_boot_dev(ISADevice *s, const char *boot_device, int fd_bootchk)
{
#define PC_MAX_BOOT_DEVICES 3
int nbds, bds[3] = { 0, };
@@ -257,7 +258,7 @@ static int pc_boot_set(void *opaque, const char *boot_device)
/* hd_table must contain 4 block drivers */
void pc_cmos_init(ram_addr_t ram_size, ram_addr_t above_4g_mem_size,
const char *boot_device, DriveInfo **hd_table,
- FDCtrl *floppy_controller, RTCState *s)
+ FDCtrl *floppy_controller, ISADevice *s)
{
int val;
int fd0, fd1, nb;
@@ -752,7 +753,7 @@ int cpu_is_bsp(CPUState *env)
BIOS will read it and start S3 resume at POST Entry */
void pc_cmos_set_s3_resume(void *opaque, int irq, int level)
{
- RTCState *s = opaque;
+ ISADevice *s = opaque;
if (level) {
rtc_set_memory(s, 0xF, 0xFE);
@@ -929,7 +930,7 @@ void pc_vga_init(PCIBus *pci_bus)
void pc_basic_device_init(qemu_irq *isa_irq,
FDCtrl **floppy_controller,
- RTCState **rtc_state)
+ ISADevice **rtc_state)
{
int i;
DriveInfo *fd[MAX_FD];
diff --git a/hw/pc.h b/hw/pc.h
index e3cc0a58bd..2e2f4e2e1b 100644
--- a/hw/pc.h
+++ b/hw/pc.h
@@ -5,7 +5,6 @@
#include "ioport.h"
#include "isa.h"
#include "fdc.h"
-#include "mc146818rtc.h"
/* PC-style peripherals (also used by other machines). */
@@ -95,14 +94,14 @@ qemu_irq *pc_allocate_cpu_irq(void);
void pc_vga_init(PCIBus *pci_bus);
void pc_basic_device_init(qemu_irq *isa_irq,
FDCtrl **floppy_controller,
- RTCState **rtc_state);
+ ISADevice **rtc_state);
void pc_init_ne2k_isa(NICInfo *nd);
#ifdef HAS_AUDIO
void pc_audio_init (PCIBus *pci_bus, qemu_irq *pic);
#endif
void pc_cmos_init(ram_addr_t ram_size, ram_addr_t above_4g_mem_size,
const char *boot_device, DriveInfo **hd_table,
- FDCtrl *floppy_controller, RTCState *s);
+ FDCtrl *floppy_controller, ISADevice *s);
void pc_pci_device_init(PCIBus *pci_bus);
void ioport_set_a20(int enable);
diff --git a/hw/pc_piix.c b/hw/pc_piix.c
index 52d8591d6a..a0ed7ad5d2 100644
--- a/hw/pc_piix.c
+++ b/hw/pc_piix.c
@@ -61,7 +61,7 @@ static void pc_init1(ram_addr_t ram_size,
IsaIrqState *isa_irq_state;
DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
FDCtrl *floppy_controller;
- RTCState *rtc_state;
+ ISADevice *rtc_state;
pc_cpus_init(cpu_model);
diff --git a/hw/ppc_prep.c b/hw/ppc_prep.c
index a5e25b57fd..09a98819d1 100644
--- a/hw/ppc_prep.c
+++ b/hw/ppc_prep.c
@@ -36,6 +36,7 @@
#include "qemu-log.h"
#include "ide.h"
#include "loader.h"
+#include "mc146818rtc.h"
//#define HARD_DEBUG_PPC_IO
//#define DEBUG_PPC_IO