android: Add x86/x86_64 ranchu virtual board for Android emulation.
diff --git a/hw/i386/acpi-dsdt-goldfish.dsl b/hw/i386/acpi-dsdt-goldfish.dsl
new file mode 100644
index 0000000..24cf696
--- /dev/null
+++ b/hw/i386/acpi-dsdt-goldfish.dsl
@@ -0,0 +1,111 @@
+/*
+** 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
+            }
+        })
+    }
+
+    /* Events */
+    Device(GFEV) {
+        Name(_HID, "GFSH0002")
+        Name(_STR, Unicode("goldfish events"))
+        Name(_CRS, ResourceTemplate() {
+            Memory32Fixed(ReadWrite,
+                GF_EVENTS_IOMEM_BASE,
+                GF_EVENTS_IOMEM_SIZE
+                )
+            Interrupt(, Edge, ActiveHigh) {
+                GF_EVENTS_IRQ
+            }
+        })
+    }
+
+    /* Pipe */
+    Device(GFPP) {
+        Name(_HID, "GFSH0003")
+        Name(_STR, Unicode("android pipe"))
+        Name(_CRS, ResourceTemplate() {
+            Memory32Fixed(ReadWrite,
+                GF_PIPE_IOMEM_BASE,
+                GF_PIPE_IOMEM_SIZE
+                )
+            Interrupt(, Edge, ActiveHigh) {
+                GF_PIPE_IRQ
+            }
+        })
+    }
+
+    /* Framebuffer */
+    Device(GFFB) {
+        Name(_HID, "GFSH0004")
+        Name(_STR, Unicode("goldfish framebuffer"))
+        Name(_CRS, ResourceTemplate() {
+            Memory32Fixed(ReadWrite,
+                GF_FB_IOMEM_BASE,
+                GF_FB_IOMEM_SIZE
+                )
+            Interrupt(, Edge, ActiveHigh) {
+                GF_FB_IRQ
+            }
+        })
+    }
+
+    /* Audio */
+    Device(GFAU) {
+        Name(_HID, "GFSH0005")
+        Name(_STR, Unicode("goldfish audio"))
+        Name(_CRS, ResourceTemplate() {
+            Memory32Fixed(ReadWrite,
+                GF_AUDIO_IOMEM_BASE,
+                GF_AUDIO_IOMEM_SIZE
+                )
+            Interrupt(, Edge, ActiveHigh) {
+                GF_AUDIO_IRQ
+            }
+        })
+    }
+
+    /* RTC */
+    Device(GFRT) {
+        Name(_HID, "GFSH0007")
+        Name(_STR, Unicode("goldfish rtc"))
+        Name(_CRS, ResourceTemplate() {
+            Memory32Fixed(ReadWrite,
+                GF_RTC_IOMEM_BASE,
+                GF_RTC_IOMEM_SIZE
+                )
+            Interrupt(, Edge, ActiveHigh) {
+                GF_RTC_IRQ
+            }
+        })
+    }
+}
diff --git a/hw/i386/acpi-dsdt.dsl b/hw/i386/acpi-dsdt.dsl
index a611e07..8326a96 100644
--- a/hw/i386/acpi-dsdt.dsl
+++ b/hw/i386/acpi-dsdt.dsl
@@ -31,6 +31,9 @@
 
 #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 875570e..e52990f 100644
--- a/hw/i386/acpi-dsdt.hex.generated
+++ b/hw/i386/acpi-dsdt.hex.generated
@@ -3,12 +3,12 @@
 0x53,
 0x44,
 0x54,
-0x8,
-0xe,
+0x4d,
+0x10,
 0x0,
 0x0,
 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89,
+0x6,
+0x0,
+0x3,
+0x1,
+0x14,
+0x0,
+0x0,
+0x0,
+0x79,
+0x0,
+0x5b,
+0x82,
+0x48,
+0x5,
+0x47,
+0x46,
+0x52,
+0x54,
+0x8,
+0x5f,
+0x48,
+0x49,
+0x44,
+0xd,
+0x47,
+0x46,
+0x53,
+0x48,
+0x30,
+0x30,
+0x30,
+0x37,
+0x0,
+0x8,
+0x5f,
+0x53,
+0x54,
+0x52,
+0x11,
+0x1d,
+0xa,
+0x1a,
+0x67,
+0x0,
+0x6f,
+0x0,
+0x6c,
+0x0,
+0x64,
+0x0,
+0x66,
+0x0,
+0x69,
+0x0,
+0x73,
+0x0,
+0x68,
+0x0,
+0x20,
+0x0,
+0x72,
+0x0,
+0x74,
+0x0,
+0x63,
+0x0,
+0x0,
+0x0,
+0x8,
+0x5f,
+0x43,
+0x52,
+0x53,
+0x11,
+0x1a,
+0xa,
+0x17,
+0x86,
+0x9,
+0x0,
+0x1,
+0x0,
+0x60,
+0x1,
+0xff,
+0x0,
+0x10,
+0x0,
+0x0,
+0x89,
+0x6,
+0x0,
+0x3,
+0x1,
+0x16,
+0x0,
+0x0,
+0x0,
+0x79,
+0x0,
+0x10,
 0x22,
 0x5f,
 0x53,
@@ -3593,5 +4174,5 @@
 0x0
 };
 static unsigned short piix_dsdt_applesmc_sta[] = {
-0x353
+0x598
 };
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 008f599..e3b00f8 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -55,6 +55,10 @@
 // android related header
 
 #ifdef CONFIG_ANDROID
+#include "hw/acpi/goldfish_defs.h"
+
+#include "android/constants.h"
+#include "android/android.h"
 #include "android/error-messages.h"
 #endif  // CONFIG_ANDROID
 
@@ -244,6 +248,17 @@
 
     pc_register_ferr_irq(gsi[13]);
 
+#if defined(CONFIG_ANDROID)
+    sysbus_create_simple("goldfish_battery", GF_BATTERY_IOMEM_BASE,
+                         gsi[GF_BATTERY_IRQ]);
+    sysbus_create_simple("goldfish-events", GF_EVENTS_IOMEM_BASE,
+                         gsi[GF_EVENTS_IRQ]);
+    sysbus_create_simple("android_pipe", GF_PIPE_IOMEM_BASE, gsi[GF_PIPE_IRQ]);
+    sysbus_create_simple("goldfish_fb", GF_FB_IOMEM_BASE, gsi[GF_FB_IRQ]);
+    sysbus_create_simple("goldfish_audio", GF_AUDIO_IOMEM_BASE, gsi[GF_AUDIO_IRQ]);
+    sysbus_create_simple("goldfish_rtc", GF_RTC_IOMEM_BASE, gsi[GF_RTC_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 0000000..2fa5124
--- /dev/null
+++ b/include/hw/acpi/goldfish_defs.h
@@ -0,0 +1,55 @@
+/*
+** 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
+
+/* goldfish events */
+#define GF_EVENTS_IOMEM_BASE    0xff011000
+#define GF_EVENTS_IOMEM_SIZE    0x00001000
+#define GF_EVENTS_IRQ           17
+
+/* android pipe */
+#define GF_PIPE_IOMEM_BASE      0xff001000
+#define GF_PIPE_IOMEM_SIZE      0x00002000
+#define GF_PIPE_IRQ             18
+
+/* goldfish framebuffer */
+#define GF_FB_IOMEM_BASE        0xff012000
+#define GF_FB_IOMEM_SIZE        0x00000100
+#define GF_FB_IRQ               19
+
+/* goldfish audio */
+#define GF_AUDIO_IOMEM_BASE     0xff013000
+#define GF_AUDIO_IOMEM_SIZE     0x00000100
+#define GF_AUDIO_IRQ            20
+
+/* goldfish rtc */
+#define GF_RTC_IOMEM_BASE       0xff016000
+#define GF_RTC_IOMEM_SIZE       0x00001000
+#define GF_RTC_IRQ              22
+
+#endif  /* !ACPI_GOLDFISH_DEFS_H */