Patchwork Small fix for qemu APIC for Mac OS X support

login
register
mail settings
Submitter Isaku Yamahata
Date Nov. 26, 2010, 12:39 p.m.
Message ID <20101126123934.GE14105@valinux.co.jp>
Download mbox | patch
Permalink /patch/73170/
State New
Headers show

Comments

Isaku Yamahata - Nov. 26, 2010, 12:39 p.m.
On Thu, Nov 25, 2010 at 08:18:45PM +0000, adq wrote:
> On 25 November 2010 11:28, Isaku Yamahata <yamahata@valinux.co.jp> wrote:
> > On Wed, Nov 24, 2010 at 02:08:16PM +0000, adq wrote:
> >> > Interesting. I was also thinking that maybe we can leverage overriding mechanisms that are already available. Maybe it's possible to squeeze the HPET node into an SSDT. Maybe we need to override the whole DSDT from the command line.
> >>
> >> We'll definitely need to override the DSDT for the applesmc device. I
> >> was thinking something along the lines of an additional DSDT binary
> >> supplied with QEMU for use when emulating apple hardware as you
> >> suggest.
> >
> > The patches for qemu and seabios have been floating around.
> > I wrote them for Q35 chipset support, but no one has gotten interested in it.
> > But now, you are there. I'm willing to rebase/resend them.
> 
> I'd definitely be interested to see those!

Here is qemu part. I rebased and just compiled it.

From df45b74ca7217d40981cd8895fb1b270fb8039ec Mon Sep 17 00:00:00 2001
Message-Id: <df45b74ca7217d40981cd8895fb1b270fb8039ec.1290775119.git.yamahata@valinux.co.jp>
In-Reply-To: <cover.1290775119.git.yamahata@valinux.co.jp>
References: <cover.1290775119.git.yamahata@valinux.co.jp>
From: Isaku Yamahata <yamahata@valinux.co.jp>
Date: Fri, 26 Nov 2010 21:25:26 +0900
Subject: [PATCH 1/1] acpi: add option, load_header, for -acpitable to load acpi header

This patch adds load_header option to -acpitable to load acpi
table which includes acpi header.
With this option and with seabios patches, alternative dsdt table
can be passed to BIOS.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
---
 hw/acpi.c       |   26 +++++++++++++++++++++++---
 qemu-options.hx |    2 ++
 2 files changed, 25 insertions(+), 3 deletions(-)

Patch

diff --git a/hw/acpi.c b/hw/acpi.c
index 8071e7b..fe9bede 100644
--- a/hw/acpi.c
+++ b/hw/acpi.c
@@ -47,6 +47,7 @@  static int acpi_checksum(const uint8_t *data, int len)
 int acpi_table_add(const char *t)
 {
     static const char *dfl_id = "QEMUQEMU";
+    bool load_header = false;
     char buf[1024], *p, *f;
     struct acpi_table_header acpi_hdr;
     unsigned long val;
@@ -54,6 +55,17 @@  int acpi_table_add(const char *t)
     struct acpi_table_header *acpi_hdr_p;
     size_t off;
 
+    if (strncmp(t, "load_header", strlen("load_header")) == 0) {
+        /* the files includes acpi header to load.
+         * the acpi header options, sig, rev, ... will be ignored.
+         */
+        load_header = true;
+        t += strlen("load_header");
+        if (*t == ',') {
+            t++;
+        }
+    }
+
     memset(&acpi_hdr, 0, sizeof(acpi_hdr));
   
     if (get_param_value(buf, sizeof(buf), "sig", t)) {
@@ -110,7 +122,11 @@  int acpi_table_add(const char *t)
          buf[0] = '\0';
     }
 
-    length = sizeof(acpi_hdr);
+    if (load_header) {
+        length = 0;
+    } else {
+        length = sizeof(acpi_hdr);
+    }
 
     f = buf;
     while (buf[0]) {
@@ -140,8 +156,12 @@  int acpi_table_add(const char *t)
 
     *(uint16_t*)p = cpu_to_le32(length);
     p += sizeof(uint16_t);
-    memcpy(p, &acpi_hdr, sizeof(acpi_hdr));
-    off = sizeof(acpi_hdr);
+    if (load_header) {
+        off = 0;
+    } else {
+        off = sizeof(acpi_hdr);
+        memcpy(p, &acpi_hdr, sizeof(acpi_hdr));
+    }
 
     f = buf;
     while (buf[0]) {
diff --git a/qemu-options.hx b/qemu-options.hx
index 4d99a58..c30eb2a 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -981,9 +981,11 @@  ETEXI
 
 DEF("acpitable", HAS_ARG, QEMU_OPTION_acpitable,
     "-acpitable [sig=str][,rev=n][,oem_id=str][,oem_table_id=str][,oem_rev=n][,asl_compiler_id=str][,asl_compiler_rev=n][,data=file1[:file2]...]\n"
+    "-acpitable [load_header][,data=file1[:file2]...]\n"
     "                ACPI table description\n", QEMU_ARCH_I386)
 STEXI
 @item -acpitable [sig=@var{str}][,rev=@var{n}][,oem_id=@var{str}][,oem_table_id=@var{str}][,oem_rev=@var{n}] [,asl_compiler_id=@var{str}][,asl_compiler_rev=@var{n}][,data=@var{file1}[:@var{file2}]...]
+@item -acpitable [load_header][,data=@var{file1}[:@var{file2}]...]
 @findex -acpitable
 Add ACPI table with specified header fields and context from specified files.
 ETEXI