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>
This commit is contained in:
parent
e1460e4707
commit
1d914fa0af
@ -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 = {
|
||||
|
@ -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 */
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include "esp.h"
|
||||
#include "mips-bios.h"
|
||||
#include "loader.h"
|
||||
#include "mc146818rtc.h"
|
||||
|
||||
enum jazz_model_e
|
||||
{
|
||||
|
@ -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;
|
||||
|
@ -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];
|
||||
|
11
hw/pc.c
11
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, §ors);
|
||||
@ -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];
|
||||
|
5
hw/pc.h
5
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);
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user