aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYu Ning <yu.ning@intel.com>2015-01-23 16:40:52 +0800
committerYu Ning <yu.ning@intel.com>2015-02-03 16:47:59 +0800
commit16a8f17dd053291895a8f8b13e2694842333d343 (patch)
tree98b473305d10903f56af6375536bdde488a8b608
parentc41beafed8b0b2dd50915f9cd8ef3467297183ee (diff)
downloadqemu-android-16a8f17dd053291895a8f8b13e2694842333d343.tar.gz
hw/i386: Enable goldfish battery
Enable the goldfish battery device in the default QEMU machine for x86/ x86_64 guests by doing the following: 1. Modify the source files (.dsl) for the ACPI tables and add an ASL Device object for goldfish battery. 2. Update the pre-generated files (.hex.generated) for the ACPI tables. 3. Instantiate the qdev for goldfish battery during initialization of the machine. Change-Id: I8dd0953fd3ea8c32321c0d4b7505b1af4620d703 Signed-off-by: Yu Ning <yu.ning@intel.com>
-rw-r--r--default-configs/i386-softmmu.mak5
-rw-r--r--default-configs/x86_64-softmmu.mak5
-rw-r--r--hw/i386/acpi-dsdt-goldfish.dsl36
-rw-r--r--hw/i386/acpi-dsdt.dsl3
-rw-r--r--hw/i386/acpi-dsdt.hex.generated115
-rw-r--r--hw/i386/pc_piix.c8
-rw-r--r--include/hw/acpi/goldfish_defs.h30
7 files changed, 197 insertions, 5 deletions
diff --git a/default-configs/i386-softmmu.mak b/default-configs/i386-softmmu.mak
index 8e08841760..e7040725b4 100644
--- a/default-configs/i386-softmmu.mak
+++ b/default-configs/i386-softmmu.mak
@@ -45,3 +45,8 @@ CONFIG_IOAPIC=y
CONFIG_ICC_BUS=y
CONFIG_PVPANIC=y
CONFIG_MEM_HOTPLUG=y
+
+# Android emulator-specific options
+CONFIG_GOLDFISH=y
+CONFIG_FRAMEBUFFER=y
+CONFIG_ANDROID_PIPE=y
diff --git a/default-configs/x86_64-softmmu.mak b/default-configs/x86_64-softmmu.mak
index 66557ac590..8567e04510 100644
--- a/default-configs/x86_64-softmmu.mak
+++ b/default-configs/x86_64-softmmu.mak
@@ -45,3 +45,8 @@ CONFIG_IOAPIC=y
CONFIG_ICC_BUS=y
CONFIG_PVPANIC=y
CONFIG_MEM_HOTPLUG=y
+
+# Android emulator-specific options
+CONFIG_GOLDFISH=y
+CONFIG_FRAMEBUFFER=y
+CONFIG_ANDROID_PIPE=y
diff --git a/hw/i386/acpi-dsdt-goldfish.dsl b/hw/i386/acpi-dsdt-goldfish.dsl
new file mode 100644
index 0000000000..42aacaae9b
--- /dev/null
+++ b/hw/i386/acpi-dsdt-goldfish.dsl
@@ -0,0 +1,36 @@
+/*
+** Copyright (c) 2015, Intel Corporation
+**
+** This software is licensed under the terms of the GNU General Public
+** License version 2, as published by the Free Software Foundation, and
+** may be copied, distributed, and modified under those terms.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+*/
+
+/****************************************************************
+ * Android-specific virtual hardware (goldfish devices)
+ ****************************************************************/
+
+#include "hw/acpi/goldfish_defs.h"
+
+Scope(\_SB) {
+
+ /* Battery */
+ Device(GFBY) {
+ Name(_HID, "GFSH0001")
+ Name(_STR, Unicode("goldfish battery"))
+ Name(_CRS, ResourceTemplate() {
+ Memory32Fixed(ReadWrite,
+ GF_BATTERY_IOMEM_BASE,
+ GF_BATTERY_IOMEM_SIZE
+ )
+ Interrupt(, Edge, ActiveHigh) {
+ GF_BATTERY_IRQ
+ }
+ })
+ }
+}
diff --git a/hw/i386/acpi-dsdt.dsl b/hw/i386/acpi-dsdt.dsl
index a611e07ec8..8326a9623a 100644
--- a/hw/i386/acpi-dsdt.dsl
+++ b/hw/i386/acpi-dsdt.dsl
@@ -31,6 +31,9 @@ DefinitionBlock (
#include "acpi-dsdt-dbug.dsl"
+/* Definitions for Android-specific virtual hardware */
+#include "acpi-dsdt-goldfish.dsl"
+
/****************************************************************
* PCI Bus definition
diff --git a/hw/i386/acpi-dsdt.hex.generated b/hw/i386/acpi-dsdt.hex.generated
index 875570e5b1..b95d01e5fb 100644
--- a/hw/i386/acpi-dsdt.hex.generated
+++ b/hw/i386/acpi-dsdt.hex.generated
@@ -3,12 +3,12 @@ static unsigned char AcpiDsdtAmlCode[] = {
0x53,
0x44,
0x54,
-0x8,
+0x71,
0xe,
0x0,
0x0,
0x1,
-0xfc,
+0xfb,
0x42,
0x58,
0x50,
@@ -31,8 +31,8 @@ static unsigned char AcpiDsdtAmlCode[] = {
0x4e,
0x54,
0x4c,
-0x28,
-0x8,
+0x14,
+0x2,
0x14,
0x20,
0x10,
@@ -110,6 +110,111 @@ static unsigned char AcpiDsdtAmlCode[] = {
0x47,
0x42,
0x10,
+0x48,
+0x6,
+0x5f,
+0x53,
+0x42,
+0x5f,
+0x5b,
+0x82,
+0x40,
+0x6,
+0x47,
+0x46,
+0x42,
+0x59,
+0x8,
+0x5f,
+0x48,
+0x49,
+0x44,
+0xd,
+0x47,
+0x46,
+0x53,
+0x48,
+0x30,
+0x30,
+0x30,
+0x31,
+0x0,
+0x8,
+0x5f,
+0x53,
+0x54,
+0x52,
+0x11,
+0x25,
+0xa,
+0x22,
+0x67,
+0x0,
+0x6f,
+0x0,
+0x6c,
+0x0,
+0x64,
+0x0,
+0x66,
+0x0,
+0x69,
+0x0,
+0x73,
+0x0,
+0x68,
+0x0,
+0x20,
+0x0,
+0x62,
+0x0,
+0x61,
+0x0,
+0x74,
+0x0,
+0x74,
+0x0,
+0x65,
+0x0,
+0x72,
+0x0,
+0x79,
+0x0,
+0x0,
+0x0,
+0x8,
+0x5f,
+0x43,
+0x52,
+0x53,
+0x11,
+0x1a,
+0xa,
+0x17,
+0x86,
+0x9,
+0x0,
+0x1,
+0x0,
+0x0,
+0x1,
+0xff,
+0x0,
+0x10,
+0x0,
+0x0,
+0x89,
+0x6,
+0x0,
+0x3,
+0x1,
+0x10,
+0x0,
+0x0,
+0x0,
+0x79,
+0x0,
+0x10,
0x22,
0x5f,
0x53,
@@ -3593,5 +3698,5 @@ static unsigned char AcpiDsdtAmlCode[] = {
0x0
};
static unsigned short piix_dsdt_applesmc_sta[] = {
-0x353
+0x3bc
};
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 85ed3c8785..cbe9dd112a 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -52,6 +52,9 @@
#ifdef CONFIG_XEN
# include <xen/hvm/hvm_info_table.h>
#endif
+#if 1 /* #ifdef CONFIG_ANDROID */
+# include "hw/acpi/goldfish_defs.h"
+#endif /* CONFIG_ANDROID */
#define MAX_IDE_BUS 2
@@ -232,6 +235,11 @@ static void pc_init1(MachineState *machine,
pc_register_ferr_irq(gsi[13]);
+#if 1 /* #ifdef CONFIG_ANDROID */
+ sysbus_create_simple("goldfish_battery", GF_BATTERY_IOMEM_BASE,
+ gsi[GF_BATTERY_IRQ]);
+#endif /* CONFIG_ANDROID */
+
pc_vga_init(isa_bus, pci_enabled ? pci_bus : NULL);
assert(pc_machine->vmport != ON_OFF_AUTO_MAX);
diff --git a/include/hw/acpi/goldfish_defs.h b/include/hw/acpi/goldfish_defs.h
new file mode 100644
index 0000000000..2c74790168
--- /dev/null
+++ b/include/hw/acpi/goldfish_defs.h
@@ -0,0 +1,30 @@
+/*
+** Copyright (c) 2015, Intel Corporation
+**
+** This software is licensed under the terms of the GNU General Public
+** License version 2, as published by the Free Software Foundation, and
+** may be copied, distributed, and modified under those terms.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+*/
+
+/* Defines I/O resources (memory regions, interrupts, etc.) required by Android-
+ * specific virtual hardware for x86/x86_64 emulation. Shared between ASL and C
+ * code.
+ *
+ * For I/O memory, we use 0xff001000 and above.
+ * For interrupts, we use lines 16 through 23.
+ */
+
+#ifndef ACPI_GOLDFISH_DEFS_H
+#define ACPI_GOLDFISH_DEFS_H
+
+/* goldfish battery */
+#define GF_BATTERY_IOMEM_BASE 0xff010000
+#define GF_BATTERY_IOMEM_SIZE 0x00001000
+#define GF_BATTERY_IRQ 16
+
+#endif /* !ACPI_GOLDFISH_DEFS_H */