[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 09/17] pc.c: remove a global variable, RTCState *rtc
From: |
Isaku Yamahata |
Subject: |
[Qemu-devel] [PATCH 09/17] pc.c: remove a global variable, RTCState *rtc_state. |
Date: |
Tue, 7 Jul 2009 15:35:52 +0900 |
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 <address@hidden>
---
hw/pc.c | 25 ++++++++++++++++---------
hw/pc.h | 6 ++++++
2 files changed, 22 insertions(+), 9 deletions(-)
diff --git a/hw/pc.c b/hw/pc.c
index 6958b8f..ebbe2ab 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -57,8 +57,6 @@
#define MAX_IDE_BUS 2
-static RTCState *rtc_state;
-
typedef struct rom_reset_data {
uint8_t *data;
target_phys_addr_t addr;
@@ -202,9 +200,9 @@ static int cmos_get_fd_drive_type(int fd0)
return val;
}
-static void cmos_init_hd(int type_ofs, int info_ofs, BlockDriverState *hd)
+static void cmos_init_hd(int type_ofs, int info_ofs, BlockDriverState *hd,
+ RTCState *s)
{
- RTCState *s = rtc_state;
int cylinders, heads, sectors;
bdrv_get_geometry_hint(hd, &cylinders, &heads, §ors);
rtc_set_memory(s, type_ofs, 47);
@@ -267,9 +265,8 @@ static int pc_boot_set(void *opaque, const char
*boot_device)
/* hd_table must contain 4 block drivers */
static void cmos_init(ram_addr_t ram_size, ram_addr_t above_4g_mem_size,
const char *boot_device, BlockDriverState **hd_table,
- fdctrl_t *floppy_controller)
+ fdctrl_t *floppy_controller, RTCState *s)
{
- RTCState *s = rtc_state;
int nbds, bds[3] = { 0, };
int val;
int fd0, fd1, nb;
@@ -358,9 +355,9 @@ static void cmos_init(ram_addr_t ram_size, ram_addr_t
above_4g_mem_size,
rtc_set_memory(s, 0x12, (hd_table[0] ? 0xf0 : 0) | (hd_table[1] ? 0x0f :
0));
if (hd_table[0])
- cmos_init_hd(0x19, 0x1b, hd_table[0]);
+ cmos_init_hd(0x19, 0x1b, hd_table[0], s);
if (hd_table[1])
- cmos_init_hd(0x1a, 0x24, hd_table[1]);
+ cmos_init_hd(0x1a, 0x24, hd_table[1], s);
val = 0;
for (i = 0; i < 4; i++) {
@@ -1115,6 +1112,7 @@ static void pc_init1(ram_addr_t ram_size,
int using_vga = cirrus_vga_enabled || std_vga_enabled || vmsvga_enabled;
void *fw_cfg;
fdctrl_t *floppy_controller;
+ RTCState *rtc_state;
PITState *pit;
IOAPICState *ioapic = NULL;
@@ -1290,6 +1288,7 @@ static void pc_init1(ram_addr_t ram_size,
}
rtc_state = rtc_init(0x70, i8259[8], 2000);
+ cmos_set_s3_resume_init(rtc_state);
qemu_register_boot_set(pc_boot_set, rtc_state);
@@ -1373,7 +1372,7 @@ static void pc_init1(ram_addr_t ram_size,
floppy_controller = fdctrl_init(i8259[6], 2, 0, 0x3f0, fd);
cmos_init(below_4g_mem_size, above_4g_mem_size, boot_device, hd,
- floppy_controller);
+ floppy_controller, rtc_state);
if (pci_enabled && usb_enabled) {
usb_uhci_piix3_init(pci_bus, piix3_devfn + 2);
@@ -1461,13 +1460,21 @@ static void pc_init_isa(ram_addr_t ram_size,
initrd_filename, 0, cpu_model);
}
+#if defined(TARGET_I386)
/* set CMOS shutdown status register (index 0xF) as S3_resume(0xFE)
BIOS will read it and start S3 resume at POST Entry */
+static RTCState *rtc_state;
+void cmos_set_s3_resume_init(RTCState *s)
+{
+ rtc_state = s;
+}
+
void cmos_set_s3_resume(void)
{
if (rtc_state)
rtc_set_memory(rtc_state, 0xF, 0xFE);
}
+#endif
static QEMUMachine pc_machine = {
.name = "pc",
diff --git a/hw/pc.h b/hw/pc.h
index bd711ce..a18e558 100644
--- a/hw/pc.h
+++ b/hw/pc.h
@@ -95,7 +95,13 @@ RTCState *rtc_mm_init(target_phys_addr_t base, int it_shift,
qemu_irq irq,
int base_year);
void rtc_set_memory(RTCState *s, int addr, int val);
void rtc_set_date(RTCState *s, const struct tm *tm);
+#if defined(TARGET_I386)
+void cmos_set_s3_resume_init(RTCState *s);
void cmos_set_s3_resume(void);
+#else
+static inline void cmos_set_s3_resume_init(RTCState *s) {}
+static inline void cmos_set_s3_resume(void) {}
+#endif
/* pc.c */
extern int fd_bootchk;
--
1.6.0.2
- [Qemu-devel] [PATCH 00/17] split out piix specific part from pc emulator. v3, Isaku Yamahata, 2009/07/07
- [Qemu-devel] [PATCH 01/17] acpi.c: split out pc smbus routines from acpi.c into pc_smbus.c, Isaku Yamahata, 2009/07/07
- [Qemu-devel] [PATCH 04/17] acpi: add acpi constants from linux header files and use them., Isaku Yamahata, 2009/07/07
- [Qemu-devel] [PATCH 17/17] pc.c: split out piix specific part from pc.c into pc_piix.c, Isaku Yamahata, 2009/07/07
- [Qemu-devel] [PATCH 07/17] pc.c: remove unnecessary global variables, pit and ioapic.., Isaku Yamahata, 2009/07/07
- [Qemu-devel] [PATCH 02/17] acpi.c: split out apm register emulation., Isaku Yamahata, 2009/07/07
- [Qemu-devel] [PATCH 11/17] pc.c: make pc_init1() not refer ferr_irq directly., Isaku Yamahata, 2009/07/07
- [Qemu-devel] [PATCH 03/17] acpi.c: make qemu_system_powerdown() piix independent., Isaku Yamahata, 2009/07/07
- [Qemu-devel] [PATCH 13/17] pc.c: split out memory allocation from pc_init1() into pc_memory_init(), Isaku Yamahata, 2009/07/07
- [Qemu-devel] [PATCH 09/17] pc.c: remove a global variable, RTCState *rtc_state.,
Isaku Yamahata <=
- [Qemu-devel] [PATCH 14/17] pc.c: split out vga initialization from pc_init1() into pc_vga_init()., Isaku Yamahata, 2009/07/07
- [Qemu-devel] [PATCH 06/17] pc.c: Make smm enable/disable function i440fx independent., Isaku Yamahata, 2009/07/07
- [Qemu-devel] [PATCH 05/17] acpi.c: split acpi.c into the common part and the piix4 part., Isaku Yamahata, 2009/07/07
- [Qemu-devel] [PATCH 08/17] pc.c: remove a global variable, floppy_controller., Isaku Yamahata, 2009/07/07
- [Qemu-devel] [PATCH 12/17] pc.c: split out cpu initialization from pc_init1() into pc_cpus_init()., Isaku Yamahata, 2009/07/07
- [Qemu-devel] [PATCH 10/17] pc.c: introduce a function to allocate cpu irq., Isaku Yamahata, 2009/07/07
- [Qemu-devel] [PATCH 15/17] pc.c: split out basic device init from pc_init1() into pc_basic_device_init(), Isaku Yamahata, 2009/07/07
- [Qemu-devel] [PATCH 16/17] pc.c: split out pci device init from pc_init1() into pc_pci_device_init(), Isaku Yamahata, 2009/07/07