qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Isaku Yamahata <yamahata@valinux.co.jp>
To: Gerd Hoffmann <kraxel@redhat.com>
Cc: blauwirbel@gmail.com, Paolo Bonzini <bonzini@gnu.org>,
	qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH V8 09/18] pc: remove a global variable, RTCState *rtc_state.
Date: Wed, 9 Dec 2009 11:44:12 +0900	[thread overview]
Message-ID: <20091209024412.GL3670@valinux.co.jp> (raw)
In-Reply-To: <4B1CC7A5.60803@redhat.com>

On Mon, Dec 07, 2009 at 10:15:17AM +0100, Gerd Hoffmann wrote:
> On 12/04/09 06:50, Isaku Yamahata wrote:
>> remove a global variable, RTCState *rtc_state.
>> Only the cmos_set_s3_resume_init() needs it global.
>> So introduce a registering function and make it local.
>> As for other function which references the variable, pass it
>> as a function argument.
>>
>> Signed-off-by: Isaku Yamahata<yamahata@valinux.co.jp>
>> Cc: Paolo Bonzini<bonzini@gnu.org>
>
>> --- a/hw/pc.c
>> +++ b/hw/pc.c
>> @@ -64,8 +64,6 @@
> [ ... ]
>> -static RTCState *rtc_state;
> [ ... ]
>> +static RTCState *rtc_state;
> [ ... ]
>
> Hmm?  Patch description says something else ...

How about the following patch?
(This is on top of V9 patch.)

>From 60499ae68c2e187374393534ce85a68ef4095cab Mon Sep 17 00:00:00 2001
From: Isaku Yamahata <yamahata@valinux.co.jp>
Date: Wed, 9 Dec 2009 11:34:13 +0900
Subject: [PATCH] pc: remove global variable rtc_state by using qemu_irq.

Following d9c3231019a0fbacbe15dcb26a0e3708b726af77 which uses qemu_irq
for powerdown to eliminate nasty #ifdef (TARGET_xxx),
this patch removes #ifdef(TARGET_I386) and global variable rtc_state.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
---
 hw/acpi_piix4.c |    8 ++++----
 hw/mips_malta.c |    3 ++-
 hw/pc.c         |   15 +++------------
 hw/pc.h         |    5 ++---
 hw/pc_piix.c    |    5 ++++-
 5 files changed, 15 insertions(+), 21 deletions(-)

diff --git a/hw/acpi_piix4.c b/hw/acpi_piix4.c
index 2b913c7..fb892a2 100644
--- a/hw/acpi_piix4.c
+++ b/hw/acpi_piix4.c
@@ -51,6 +51,7 @@ typedef struct PIIX4PMState {
     PCSMBus smb;
 
     qemu_irq irq;
+    qemu_irq cmos_s3_resume;
 } PIIX4PMState;
 
 #define ACPI_ENABLE 0xf1
@@ -146,9 +147,7 @@ static void pm_ioport_writew(void *opaque, uint32_t addr, uint32_t val)
                     s->pmsts |= (ACPI_BITMASK_WAKE_STATUS |
                                  ACPI_BITMASK_POWER_BUTTON_STATUS);
                     qemu_system_reset_request();
-#if defined(TARGET_I386)
-                    cmos_set_s3_resume();
-#endif
+                    qemu_irq_raise(s->cmos_s3_resume);
                 default:
                     break;
                 }
@@ -313,7 +312,7 @@ static void piix4_powerdown(void *opaque, int irq, int power_failing)
 }
 
 i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
-                       qemu_irq sci_irq)
+                       qemu_irq sci_irq, qemu_irq cmos_s3_resume)
 {
     PIIX4PMState *s;
     uint8_t *pci_conf;
@@ -367,6 +366,7 @@ i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
 
     pc_smbus_init(&s->smb);
     s->irq = sci_irq;
+    s->cmos_s3_resume = cmos_s3_resume;
     qemu_register_reset(piix4_reset, s);
 
     return s->smb.smbus;
diff --git a/hw/mips_malta.c b/hw/mips_malta.c
index 7cff0c0..8f33e74 100644
--- a/hw/mips_malta.c
+++ b/hw/mips_malta.c
@@ -928,7 +928,8 @@ void mips_malta_init (ram_addr_t ram_size,
     isa_bus_irqs(i8259);
     pci_piix4_ide_init(pci_bus, hd, piix4_devfn + 1);
     usb_uhci_piix4_init(pci_bus, piix4_devfn + 2);
-    smbus = piix4_pm_init(pci_bus, piix4_devfn + 3, 0x1100, isa_reserve_irq(9));
+    smbus = piix4_pm_init(pci_bus, piix4_devfn + 3, 0x1100,
+                          isa_reserve_irq(9), NULL);
     eeprom_buf = qemu_mallocz(8 * 256); /* XXX: make this persistent */
     for (i = 0; i < 8; i++) {
         /* TODO: Populate SPD eeprom data.  */
diff --git a/hw/pc.c b/hw/pc.c
index 6f25ba8..7cb4f14 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -1135,7 +1135,6 @@ void pc_basic_device_init(qemu_irq *isa_irq,
     register_ioport_write(0xf0, 1, 1, ioportF0_write, NULL);
 
     *rtc_state = rtc_init(2000);
-    cmos_set_s3_resume_init(*rtc_state);
 
     qemu_register_boot_set(pc_boot_set, *rtc_state);
 
@@ -1189,16 +1188,8 @@ void pc_pci_device_init(PCIBus *pci_bus)
 
 /* set CMOS shutdown status register (index 0xF) as S3_resume(0xFE)
    BIOS will read it and start S3 resume at POST Entry */
-static ISADevice *rtc_state; /* RTCState device */
-void cmos_set_s3_resume_init(ISADevice *s)
+void cmos_set_s3_resume_fn(void *opaque, int n, int level)
 {
-    rtc_state = s;
-}
-
-void cmos_set_s3_resume(void)
-{
-#if defined(TARGET_I386)
-    if (rtc_state)
-        rtc_set_memory(rtc_state, 0xF, 0xFE);
-#endif
+    ISADevice *rtc_state = opaque;
+    rtc_set_memory(rtc_state, 0xF, 0xFE);
 }
diff --git a/hw/pc.h b/hw/pc.h
index be5230e..74f551e 100644
--- a/hw/pc.h
+++ b/hw/pc.h
@@ -89,8 +89,7 @@ void i8042_mm_init(qemu_irq kbd_irq, qemu_irq mouse_irq,
                    target_phys_addr_t mask);
 
 /* pc.c */
-void cmos_set_s3_resume_init(ISADevice *s);
-void cmos_set_s3_resume(void);
+void cmos_set_s3_resume_fn(void *opaque, int n, int level);
 
 extern int fd_bootchk;
 
@@ -139,7 +138,7 @@ int acpi_table_add(const char *table_desc);
 
 /* acpi_piix.c */
 i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
-                       qemu_irq sci_irq);
+                       qemu_irq sci_irq, qemu_irq cmos_set_s3_resume);
 void piix4_smbus_register_device(SMBusDevice *dev, uint8_t addr);
 void piix4_acpi_system_hot_add_init(PCIBus *bus);
 
diff --git a/hw/pc_piix.c b/hw/pc_piix.c
index 2f776f8..a20d052 100644
--- a/hw/pc_piix.c
+++ b/hw/pc_piix.c
@@ -143,9 +143,12 @@ static void pc_init1(ram_addr_t ram_size,
         uint8_t *eeprom_buf = qemu_mallocz(8 * 256); /* XXX: make this persistent */
         i2c_bus *smbus;
 
+        qemu_irq cmos_s3_resume =
+            *qemu_allocate_irqs(cmos_set_s3_resume_fn, rtc_state, 1);
+
         /* TODO: Populate SPD eeprom data.  */
         smbus = piix4_pm_init(pci_bus, piix3_devfn + 3, 0xb100,
-                              isa_reserve_irq(9));
+                              isa_reserve_irq(9), cmos_s3_resume);
         for (i = 0; i < 8; i++) {
             DeviceState *eeprom;
             eeprom = qdev_create((BusState *)smbus, "smbus-eeprom");
-- 
1.6.5.4




-- 
yamahata

  reply	other threads:[~2009-12-09  2:44 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-04  5:50 [Qemu-devel] [PATCH V8 00/18] split out piix specific part from pc emulator Isaku Yamahata
2009-12-04  5:50 ` [Qemu-devel] [PATCH V8 01/18] acpi: split out pc smbus routines from acpi.c into pc_smbus.c Isaku Yamahata
2009-12-04  5:50 ` [Qemu-devel] [PATCH V8 02/18] acpi: split out apm register emulation from acpi.c Isaku Yamahata
2009-12-07  9:07   ` [Qemu-devel] " Michael S. Tsirkin
2009-12-04  5:50 ` [Qemu-devel] [PATCH V8 03/18] acpi: add acpi constants from linux header files and use them Isaku Yamahata
2009-12-04  5:50 ` [Qemu-devel] [PATCH V8 04/18] acpi: split acpi.c into the common part and the piix4 part Isaku Yamahata
2009-12-04  5:50 ` [Qemu-devel] [PATCH V8 05/18] acpi_piix4: remove unused variable in get_pmsts() Isaku Yamahata
2009-12-04  5:50 ` [Qemu-devel] [PATCH V8 06/18] pc, i440fx: Make smm enable/disable function i440fx independent Isaku Yamahata
2009-12-04  5:50 ` [Qemu-devel] [PATCH V8 07/18] pc: make an unnecessary global variable, pit, local Isaku Yamahata
2009-12-04  5:50 ` [Qemu-devel] [PATCH V8 08/18] pc: remove a global variable, floppy_controller Isaku Yamahata
2009-12-04  5:50 ` [Qemu-devel] [PATCH V8 09/18] pc: remove a global variable, RTCState *rtc_state Isaku Yamahata
2009-12-07  9:15   ` Gerd Hoffmann
2009-12-09  2:44     ` Isaku Yamahata [this message]
2009-12-04  5:50 ` [Qemu-devel] [PATCH V8 10/18] pc: introduce a function to allocate cpu irq Isaku Yamahata
2009-12-04  5:50 ` [Qemu-devel] [PATCH V8 11/18] pc: make pc_init1() not refer ferr_irq directly Isaku Yamahata
2009-12-04  5:50 ` [Qemu-devel] [PATCH V8 12/18] pc: split out cpu initialization from pc_init1() into pc_cpus_init() Isaku Yamahata
2009-12-04  5:51 ` [Qemu-devel] [PATCH V8 13/18] pc: split out memory allocation from pc_init1() into pc_memory_init() Isaku Yamahata
2009-12-04  5:51 ` [Qemu-devel] [PATCH V8 14/18] pc: split out vga initialization from pc_init1() into pc_vga_init() Isaku Yamahata
2009-12-04  5:51 ` [Qemu-devel] [PATCH V8 15/18] pc: split out basic device init from pc_init1() into pc_basic_device_init() Isaku Yamahata
2009-12-04  5:51 ` [Qemu-devel] [PATCH V8 16/18] pc: split out pci device init from pc_init1() into pc_pci_device_init() Isaku Yamahata
2009-12-04  5:51 ` [Qemu-devel] [PATCH V8 17/18] pc: split out piix specific part from pc.c into pc_piix.c Isaku Yamahata
2009-12-04  5:51 ` [Qemu-devel] [PATCH V8 18/18] pc_piix: initialize ioapic before use Isaku Yamahata
2009-12-07  9:23   ` Gerd Hoffmann
2009-12-04 14:09 ` [Qemu-devel] [PATCH V8 00/18] split out piix specific part from pc emulator Anthony Liguori
2009-12-05  0:20   ` Isaku Yamahata
2009-12-07  9:40     ` Gerd Hoffmann
2009-12-07  9:07   ` [Qemu-devel] " Michael S. Tsirkin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20091209024412.GL3670@valinux.co.jp \
    --to=yamahata@valinux.co.jp \
    --cc=blauwirbel@gmail.com \
    --cc=bonzini@gnu.org \
    --cc=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).