From patchwork Wed Jan 6 02:39:44 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Isaku Yamahata X-Patchwork-Id: 42265 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 6E3EAB6EF0 for ; Wed, 6 Jan 2010 14:17:05 +1100 (EST) Received: from localhost ([127.0.0.1]:51981 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NSMOM-0005bp-3b for incoming@patchwork.ozlabs.org; Tue, 05 Jan 2010 22:17:02 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NSLof-0004Ph-H8 for qemu-devel@nongnu.org; Tue, 05 Jan 2010 21:40:09 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NSLoT-0004Gt-1G for qemu-devel@nongnu.org; Tue, 05 Jan 2010 21:40:01 -0500 Received: from [199.232.76.173] (port=54788 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NSLoS-0004Gd-2G for qemu-devel@nongnu.org; Tue, 05 Jan 2010 21:39:56 -0500 Received: from mail.valinux.co.jp ([210.128.90.3]:60927) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NSLoP-0003kX-Tj for qemu-devel@nongnu.org; Tue, 05 Jan 2010 21:39:55 -0500 Received: from ps.local.valinux.co.jp (vagw.valinux.co.jp [210.128.90.14]) by mail.valinux.co.jp (Postfix) with SMTP id AFA5C1829C; Wed, 6 Jan 2010 11:39:44 +0900 (JST) Received: (nullmailer pid 28766 invoked by uid 1000); Wed, 06 Jan 2010 02:39:52 -0000 From: Isaku Yamahata To: qemu-devel@nongnu.org, kraxel@redhat.com, aurelien@aurel32.net Date: Wed, 6 Jan 2010 11:39:44 +0900 Message-Id: <1262745591-28697-21-git-send-email-yamahata@valinux.co.jp> X-Mailer: git-send-email 1.6.5.4 In-Reply-To: <1262745591-28697-1-git-send-email-yamahata@valinux.co.jp> References: <1262745591-28697-1-git-send-email-yamahata@valinux.co.jp> X-Virus-Scanned: clamav-milter 0.95.2 at va-mail.local.valinux.co.jp X-Virus-Status: Clean X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) Cc: yamahata@valinux.co.jp Subject: [Qemu-devel] [PATCH V12 20/27] rtc: make rtc_xxx accept/return ISADevice instead of RTCState. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org To match rtc_xxx with qdev, make rtc_xxx accept and return ISADevice instead of RTCState. Signed-off-by: Isaku Yamahata Acked-by: Gerd Hoffmann --- hw/mc146818rtc.c | 26 +++++++++++++++----------- hw/mc146818rtc.h | 8 ++++---- hw/mips_jazz.c | 1 + hw/mips_malta.c | 3 ++- hw/mips_r4k.c | 3 ++- hw/pc.c | 11 ++++++----- hw/pc.h | 5 ++--- hw/pc_piix.c | 2 +- hw/ppc_prep.c | 1 + 9 files changed, 34 insertions(+), 26 deletions(-) diff --git a/hw/mc146818rtc.c b/hw/mc146818rtc.c index e4d55c7..1eb991c 100644 --- a/hw/mc146818rtc.c +++ b/hw/mc146818rtc.c @@ -27,6 +27,7 @@ #include "pc.h" #include "isa.h" #include "hpet_emul.h" +#include "mc146818rtc.h" //#define DEBUG_CMOS @@ -64,7 +65,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; @@ -84,7 +85,7 @@ struct RTCState { QEMUTimer *coalesced_timer; QEMUTimer *second_timer; QEMUTimer *second_timer2; -}; +} RTCState; static void rtc_irq_raise(qemu_irq irq) { @@ -489,14 +490,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); } @@ -505,18 +508,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) @@ -588,7 +592,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 @@ -611,14 +615,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 7211dae..6f46a68 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 94ebd36..cd63fc9 100644 --- a/hw/mips_jazz.c +++ b/hw/mips_jazz.c @@ -34,6 +34,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 a507bc7..8f33e74 100644 --- a/hw/mips_malta.c +++ b/hw/mips_malta.c @@ -43,6 +43,7 @@ #include "ide.h" #include "loader.h" #include "elf.h" +#include "mc146818rtc.h" //#define DEBUG_BOARD_INIT @@ -779,7 +780,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_t *floppy_controller; MaltaFPGAState *malta_fpga; qemu_irq *i8259; diff --git a/hw/mips_r4k.c b/hw/mips_r4k.c index b69d7c3..104cf29 100644 --- a/hw/mips_r4k.c +++ b/hw/mips_r4k.c @@ -20,6 +20,7 @@ #include "ide.h" #include "loader.h" #include "elf.h" +#include "mc146818rtc.h" #define PHYS_TO_VIRT(x) ((x) | ~(target_ulong)0x7fffffff) @@ -167,7 +168,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 12afaf2..bf8d272 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -44,6 +44,7 @@ #include "ide.h" #include "loader.h" #include "elf.h" +#include "mc146818rtc.h" /* output Bochs bios info messages */ //#define DEBUG_BIOS @@ -189,7 +190,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); @@ -228,7 +229,7 @@ static int pc_boot_set(void *opaque, const char *boot_device) { Monitor *mon = cur_mon; #define PC_MAX_BOOT_DEVICES 3 - RTCState *s = (RTCState *)opaque; + ISADevice *s = opaque; int nbds, bds[3] = { 0, }; int i; @@ -253,7 +254,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_t *floppy_controller, RTCState *s) + fdctrl_t *floppy_controller, ISADevice *s) { int nbds, bds[3] = { 0, }; int val; @@ -1134,7 +1135,7 @@ void pc_vga_init(PCIBus *pci_bus) void pc_basic_device_init(qemu_irq *isa_irq, ISADevice **isa_dev, fdctrl_t **floppy_controller, - RTCState **rtc_state) + ISADevice **rtc_state) { int i; DriveInfo *fd[MAX_FD]; @@ -1200,6 +1201,6 @@ void pc_pci_device_init(PCIBus *pci_bus) BIOS will read it and start S3 resume at POST Entry */ void cmos_set_s3_resume_fn(void *opaque, int n, int level) { - RTCState *rtc_state = opaque; + ISADevice *rtc_state = opaque; rtc_set_memory(rtc_state, 0xF, 0xFE); } diff --git a/hw/pc.h b/hw/pc.h index b748615..2088cfd 100644 --- a/hw/pc.h +++ b/hw/pc.h @@ -3,7 +3,6 @@ #include "qemu-common.h" #include "isa.h" -#include "mc146818rtc.h" /* PC-style peripherals (also used by other machines). */ @@ -110,14 +109,14 @@ struct fdctrl_t; void pc_basic_device_init(qemu_irq *isa_irq, ISADevice **isa_dev, struct fdctrl_t **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, - struct fdctrl_t *floppy_controller, RTCState *s); + struct fdctrl_t *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 69ba02b..682b64c 100644 --- a/hw/pc_piix.c +++ b/hw/pc_piix.c @@ -69,7 +69,7 @@ static void pc_init1(ram_addr_t ram_size, DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; void *fw_cfg; fdctrl_t *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 eb758f2..cf0db83 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