From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=47950 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OGpev-0002Za-RD for qemu-devel@nongnu.org; Tue, 25 May 2010 04:38:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OGpeu-0003NB-H8 for qemu-devel@nongnu.org; Tue, 25 May 2010 04:38:45 -0400 Received: from mail-wy0-f173.google.com ([74.125.82.173]:62611) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OGpeu-0003Mu-6z for qemu-devel@nongnu.org; Tue, 25 May 2010 04:38:44 -0400 Received: by wyb39 with SMTP id 39so666639wyb.4 for ; Tue, 25 May 2010 01:38:42 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <4BFB8C8E.4070602@redhat.com> Date: Tue, 25 May 2010 10:38:38 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <201005241732.46988.paul@codesourcery.com> <4BFAAE22.5040900@codemonkey.ws> <201005241811.10219.paul@codesourcery.com> In-Reply-To: Content-Type: multipart/mixed; boundary="------------010308010702000608010709" Subject: [Qemu-devel] Re: [PATCH 0/6] Make hpet a compile time option List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Juan Quintela Cc: Blue Swirl , Jan Kiszka , Paul Brook , qemu-devel@nongnu.org This is a multi-part message in MIME format. --------------010308010702000608010709 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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 --------------010308010702000608010709 Content-Type: text/plain; name="hpet-hack.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="hpet-hack.patch" 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); --------------010308010702000608010709--