From: Paolo Bonzini <pbonzini@redhat.com>
To: Juan Quintela <quintela@redhat.com>
Cc: Blue Swirl <blauwirbel@gmail.com>, Jan Kiszka <jan.kiszka@web.de>,
Paul Brook <paul@codesourcery.com>,
qemu-devel@nongnu.org
Subject: [Qemu-devel] Re: [PATCH 0/6] Make hpet a compile time option
Date: Tue, 25 May 2010 10:38:38 +0200 [thread overview]
Message-ID: <4BFB8C8E.4070602@redhat.com> (raw)
In-Reply-To: <m3ocg5uqvz.fsf@trasno.mitica>
[-- Attachment #1: Type: text/plain, Size: 480 bytes --]
On 05/24/2010 07:54 PM, Juan Quintela wrote:
> But for the other call, what do you propose?
>
> My best try was to hide the availability of hpet inside hpet_emul.h
> with:
>
> #ifdef CONFIG_HPET
> uint32_t hpet_in_legacy_mode(void);
> else
> uint32_t hpet_in_legacy_mode(void) { return 0;}
> #endif
Change this to a global variable rtc_disable_interrupts in
hw/mc146818rtc.c? (You didn't say it would need to be particularly
pretty...).
Not tested beyond compilation.
Paolo
[-- Attachment #2: hpet-hack.patch --]
[-- Type: text/plain, Size: 3157 bytes --]
diff --git a/hw/hpet.c b/hw/hpet.c
index 8729fb2..c2615c1 100644
--- a/hw/hpet.c
+++ b/hw/hpet.c
@@ -29,6 +29,7 @@
#include "console.h"
#include "qemu-timer.h"
#include "hpet_emul.h"
+#include "mc146818rtc.h"
//#define HPET_DEBUG
#ifdef HPET_DEBUG
@@ -39,14 +40,6 @@
static HPETState *hpet_statep;
-uint32_t hpet_in_legacy_mode(void)
-{
- if (hpet_statep)
- return hpet_statep->config & HPET_CFG_LEGACY;
- else
- return 0;
-}
-
static uint32_t timer_int_route(struct HPETTimer *timer)
{
uint32_t route;
@@ -139,7 +132,7 @@ static void update_irq(struct HPETTimer *timer)
qemu_irq irq;
int route;
- if (timer->tn <= 1 && hpet_in_legacy_mode()) {
+ if (timer->tn <= 1 && (timer->state->config & HPET_CFG_LEGACY)) {
/* if LegacyReplacementRoute bit is set, HPET specification requires
* timer0 be routed to IRQ0 in NON-APIC or IRQ2 in the I/O APIC,
* timer1 be routed to IRQ8 in NON-APIC or IRQ8 in the I/O APIC.
@@ -474,8 +467,10 @@ static void hpet_ram_writel(void *opaque, target_phys_addr_t addr,
/* i8254 and RTC are disabled when HPET is in legacy mode */
if (activating_bit(old_val, new_val, HPET_CFG_LEGACY)) {
hpet_pit_disable();
+ rtc_disable_interrupts = 1;
} else if (deactivating_bit(old_val, new_val, HPET_CFG_LEGACY)) {
hpet_pit_enable();
+ rtc_disable_interrupts = 0;
}
break;
case HPET_CFG + 4:
diff --git a/hw/mc146818rtc.c b/hw/mc146818rtc.c
index 571c593..61d5980 100644
--- a/hw/mc146818rtc.c
+++ b/hw/mc146818rtc.c
@@ -94,6 +94,9 @@ typedef struct RTCState {
QEMUTimer *second_timer2;
} RTCState;
+
+int rtc_disable_interrupts = 0;
+
static void rtc_irq_raise(qemu_irq irq)
{
/* When HPET is operating in legacy mode, RTC interrupts are disabled
@@ -101,9 +104,7 @@ static void rtc_irq_raise(qemu_irq irq)
* mode is established while interrupt is raised. We want it to
* be lowered in any case
*/
-#if defined TARGET_I386
- if (!hpet_in_legacy_mode())
-#endif
+ if (!rtc_disable_interrupts)
qemu_irq_raise(irq);
}
@@ -148,14 +149,10 @@ static void rtc_timer_update(RTCState *s, int64_t current_time)
int enable_pie;
period_code = s->cmos_data[RTC_REG_A] & 0x0f;
-#if defined TARGET_I386
/* disable periodic timer if hpet is in legacy mode, since interrupts are
* disabled anyway.
*/
- enable_pie = !hpet_in_legacy_mode();
-#else
- enable_pie = 1;
-#endif
+ enable_pie = !rtc_disable_interrupts;
if (period_code != 0
&& (((s->cmos_data[RTC_REG_B] & REG_B_PIE) && enable_pie)
|| ((s->cmos_data[RTC_REG_B] & REG_B_SQWE) && s->sqw_irq))) {
diff --git a/hw/mc146818rtc.h b/hw/mc146818rtc.h
index 6f46a68..ff4bcda 100644
--- a/hw/mc146818rtc.h
+++ b/hw/mc146818rtc.h
@@ -3,6 +3,7 @@
#include "isa.h"
+extern int rtc_disable_interrupts;
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);
next prev parent reply other threads:[~2010-05-25 8:38 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-24 15:18 [Qemu-devel] [PATCH 0/6] Make hpet a compile time option Juan Quintela
2010-05-24 15:18 ` [Qemu-devel] [PATCH 1/6] Create again config-device.h and config.devices.h Juan Quintela
2010-05-24 15:18 ` [Qemu-devel] [PATCH 2/6] Move no_hpet declaration to hpet_emul.h Juan Quintela
2010-05-24 15:18 ` [Qemu-devel] [PATCH 3/6] Move no_hpet test to inside hpet_init() Juan Quintela
2010-05-24 15:18 ` [Qemu-devel] [PATCH 4/6] Make hpet_in_legacy_mode() return 0 for !TARGET_I386 Juan Quintela
2010-05-24 15:18 ` [Qemu-devel] [PATCH 5/6] make hpet_in_legacy_mode() return a bool Juan Quintela
2010-05-24 15:18 ` [Qemu-devel] [PATCH 6/6] Create CONFIG_HPET Juan Quintela
2010-05-24 15:20 ` [Qemu-devel] Re: [PATCH 0/6] Make hpet a compile time option Juan Quintela
2010-05-24 15:43 ` Jan Kiszka
2010-05-24 15:57 ` Juan Quintela
2010-05-24 16:20 ` Jan Kiszka
2010-05-24 18:08 ` Juan Quintela
2010-05-24 20:11 ` Jan Kiszka
2010-05-24 16:32 ` Paul Brook
2010-05-24 16:49 ` Anthony Liguori
2010-05-24 17:11 ` Paul Brook
2010-05-24 17:37 ` Anthony Liguori
2010-05-24 17:54 ` Juan Quintela
2010-05-24 18:03 ` Anthony Liguori
2010-05-24 18:15 ` Jan Kiszka
2010-05-24 20:16 ` Blue Swirl
2010-05-24 18:10 ` Jan Kiszka
2010-05-25 8:38 ` Paolo Bonzini [this message]
2010-05-25 9:05 ` Jan Kiszka
2010-05-25 9:56 ` Paolo Bonzini
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=4BFB8C8E.4070602@redhat.com \
--to=pbonzini@redhat.com \
--cc=blauwirbel@gmail.com \
--cc=jan.kiszka@web.de \
--cc=paul@codesourcery.com \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.