From: Michael Hanselmann <qemu@hansmi.ch>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] Problem with triggering interrupts
Date: Thu, 28 Jun 2007 22:09:53 +0200 [thread overview]
Message-ID: <20070628200953.GA11952@hansmi.ch> (raw)
Hello
I'm trying to implement the “system_powerdown” command for i386/x86_64.
After way too much time, I've now to hope for someone else being able to
help me, I just don't get it anymore. Due to the available
infrastructure, I decided to use an ACPI power button event. You can
find my current patches for qemu and the bochs BIOS below.
The code itself sets the interrupt, but unfortunately, it never reaches
the system inside qemu. For tests, I tried setting sci_level = 1, and
suddenly, it gets received and shuts down the system. Does anyone know
what I'm doing wrong here?
Thanks a lot,
Michael
---
diff -u -b -B -r1.254 vl.h
--- vl.h 25 Jun 2007 10:57:10 -0000 1.254
+++ vl.h 28 Jun 2007 19:56:45 -0000
@@ -136,11 +136,12 @@
void qemu_system_reset_request(void);
void qemu_system_shutdown_request(void);
void qemu_system_powerdown_request(void);
-#if !defined(TARGET_SPARC)
+#if defined(TARGET_I386) || defined(TARGET_X86_64) || \
+ defined(TARGET_SPARC)
+void qemu_system_powerdown(void);
+#else
// Please implement a power failure function to signal the OS
#define qemu_system_powerdown() do{}while(0)
-#else
-void qemu_system_powerdown(void);
#endif
void main_loop_wait(int timeout);
Index: hw/acpi.c
===================================================================
RCS file: /sources/qemu/qemu/hw/acpi.c,v
retrieving revision 1.12
diff -u -b -B -r1.12 acpi.c
--- hw/acpi.c 28 May 2007 21:01:02 -0000 1.12
+++ hw/acpi.c 28 Jun 2007 19:56:45 -0000
@@ -98,6 +98,26 @@
}
}
+#if defined(TARGET_I386) || defined(TARGET_X86_64)
+static PIIX4PMState *powerdown_piix4 = NULL;
+
+void qemu_system_powerdown(void)
+{
+ PIIX4PMState *s;
+
+ if (powerdown_piix4 == NULL) {
+ return;
+ }
+
+ s = powerdown_piix4;
+
+ if (s->pmen & PWRBTN_EN) {
+ s->pmsts |= PWRBTN_EN;
+ pm_update_sci(s);
+ }
+}
+#endif
+
static void pm_tmr_timer(void *opaque)
{
PIIX4PMState *s = opaque;
@@ -495,5 +515,12 @@
register_savevm("piix4_pm", 0, 1, pm_save, pm_load, s);
s->smbus = i2c_init_bus();
+
+#if defined(TARGET_I386) || defined(TARGET_X86_64)
+ if (powerdown_piix4 == NULL) {
+ powerdown_piix4 = s;
+ }
+#endif
+
return s->smbus;
}
diff -rpu bochs-20070617.orig/bios/rombios32.c bochs-20070617/bios/rombios32.c
--- bochs-20070617.orig/bios/rombios32.c 2007-06-17 09:37:11.000000000 +0200
+++ bochs-20070617/bios/rombios32.c 2007-06-28 21:59:18.000000000 +0200
@@ -861,6 +861,11 @@ static void mptable_init(void)
int ioapic_id, i, len;
int mp_config_table_size;
+#ifdef BX_QEMU
+ if (smp_cpus <= 1)
+ return;
+#endif
+
#ifdef BX_USE_EBDA_TABLES
mp_config_table = (uint8_t *)(ram_size - ACPI_DATA_SIZE - MPTABLE_MAX_SIZE);
#else
@@ -1285,6 +1290,7 @@ void acpi_bios_init(void)
rsdp->checksum = acpi_checksum((void *)rsdp, 20);
/* RSDT */
+ memset(rsdt, 0, sizeof(*rsdt));
rsdt->table_offset_entry[0] = cpu_to_le32(fadt_addr);
rsdt->table_offset_entry[1] = cpu_to_le32(madt_addr);
acpi_build_table_header((struct acpi_table_header *)rsdt,
@@ -1310,7 +1316,7 @@ void acpi_bios_init(void)
fadt->plvl3_lat = cpu_to_le16(50);
fadt->plvl3_lat = cpu_to_le16(50);
/* WBINVD + PROC_C1 + PWR_BUTTON + SLP_BUTTON + FIX_RTC */
- fadt->flags = cpu_to_le32((1 << 0) | (1 << 2) | (1 << 4) | (1 << 5) | (1 << 6));
+ fadt->flags = cpu_to_le32((1 << 0) | (1 << 2) | (0 << 4) | (1 << 5) | (1 << 6));
acpi_build_table_header((struct acpi_table_header *)fadt, "FACP",
sizeof(*fadt));
diff -rpu bochs-20070617.orig/bios/rombios.h bochs-20070617/bios/rombios.h
--- bochs-20070617.orig/bios/rombios.h 2007-02-20 10:36:55.000000000 +0100
+++ bochs-20070617/bios/rombios.h 2007-06-17 21:59:46.000000000 +0200
@@ -19,7 +19,7 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
/* define it to include QEMU specific code */
-//#define BX_QEMU
+#define BX_QEMU
#ifndef LEGACY
# define BX_ROMBIOS32 1
reply other threads:[~2007-06-28 20:10 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20070628200953.GA11952@hansmi.ch \
--to=qemu@hansmi.ch \
--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).