qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 2/2] Add HPET emulation to qemu (v3)
@ 2008-10-17 12:19 Beth Kon
  2008-10-21 15:22 ` [Qemu-devel] " Anthony Liguori
  0 siblings, 1 reply; 2+ messages in thread
From: Beth Kon @ 2008-10-17 12:19 UTC (permalink / raw)
  To: qemu-devel; +Cc: agraf, kvm

[-- Attachment #1: Type: text/plain, Size: 97 bytes --]


-- 
Elizabeth Kon (Beth)
IBM Linux Technology Center
Open Hypervisor Team
email: eak@us.ibm.com

[-- Attachment #2: qemu_hpetv3_bochs.patch --]
[-- Type: text/x-patch, Size: 4337 bytes --]

This patch contains the bochs bios changes needed to support the qemu hpet.

---
 bios/acpi-dsdt.dsl |   18 ++++++++++++++++++
 bios/rombios32.c   |   46 ++++++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 62 insertions(+), 2 deletions(-)

Index: bochs-2.3.7/bios/acpi-dsdt.dsl
===================================================================
--- bochs-2.3.7.orig/bios/acpi-dsdt.dsl	2008-10-15 12:39:14.000000000 -0500
+++ bochs-2.3.7/bios/acpi-dsdt.dsl	2008-10-15 18:50:44.000000000 -0500
@@ -159,6 +159,24 @@
                 Return (MEMP)
             }
         }
+        Device(HPET) {
+            Name(_HID,  EISAID("PNP0103"))
+            Name(_UID, 0)
+            Method (_STA, 0, NotSerialized) {
+                    Return(0x0F)
+            }
+            Name(_CRS, ResourceTemplate() {
+                DWordMemory(
+                    ResourceConsumer, PosDecode, MinFixed, MaxFixed,
+                    NonCacheable, ReadWrite,
+                    0x00000000,
+                    0xFED00000,
+                    0xFED003FF,
+                    0x00000000,
+                    0x00000400 /* 1K memory: FED00000 - FED003FF */
+                )
+            })
+        }
     }
 
     Scope(\_SB.PCI0) {
Index: bochs-2.3.7/bios/rombios32.c
===================================================================
--- bochs-2.3.7.orig/bios/rombios32.c	2008-10-15 12:39:36.000000000 -0500
+++ bochs-2.3.7/bios/rombios32.c	2008-10-16 18:30:40.000000000 -0500
@@ -1087,7 +1087,7 @@
 struct rsdt_descriptor_rev1
 {
 	ACPI_TABLE_HEADER_DEF                           /* ACPI common table header */
-	uint32_t                             table_offset_entry [3]; /* Array of pointers to other */
+	uint32_t                             table_offset_entry [4]; /* Array of pointers to other */
 			 /* ACPI tables */
 };
 
@@ -1227,6 +1227,31 @@
 #endif
 };
 
+/*
+ *  * ACPI 2.0 Generic Address Space definition.
+ *   */
+struct acpi_20_generic_address {
+    uint8_t  address_space_id;
+    uint8_t  register_bit_width;
+    uint8_t  register_bit_offset;
+    uint8_t  reserved;
+    uint64_t address;
+};
+
+/*
+ *  * HPET Description Table
+ *   */
+struct acpi_20_hpet {
+    ACPI_TABLE_HEADER_DEF                           /* ACPI common table header */
+    uint32_t           timer_block_id;
+    struct acpi_20_generic_address addr;
+    uint8_t            hpet_number;
+    uint16_t           min_tick;
+    uint8_t            page_protect;
+};
+#define ACPI_HPET_ADDRESS 0xFED00000UL
+
+
 struct madt_io_apic
 {
 	APIC_HEADER_DEF
@@ -1341,8 +1366,9 @@
     struct fadt_descriptor_rev1 *fadt;
     struct facs_descriptor_rev1 *facs;
     struct multiple_apic_table *madt;
+    struct acpi_20_hpet *hpet;
     uint8_t *dsdt, *ssdt;
-    uint32_t base_addr, rsdt_addr, fadt_addr, addr, facs_addr, dsdt_addr, ssdt_addr;
+    uint32_t base_addr, rsdt_addr, fadt_addr, addr, facs_addr, dsdt_addr, ssdt_addr, hpet_addr;
     uint32_t acpi_tables_size, madt_addr, madt_size;
     int i;
 
@@ -1388,6 +1414,11 @@
     madt = (void *)(addr);
     addr += madt_size;
 
+    addr = (addr + 7) & ~7;
+    hpet_addr = addr;
+    hpet = (void *)(addr);
+    addr += sizeof(*hpet);
+
     acpi_tables_size = addr - base_addr;
 
     BX_INFO("ACPI tables: RSDP addr=0x%08lx ACPI DATA addr=0x%08lx size=0x%x\n",
@@ -1410,6 +1441,7 @@
     rsdt->table_offset_entry[0] = cpu_to_le32(fadt_addr);
     rsdt->table_offset_entry[1] = cpu_to_le32(madt_addr);
     rsdt->table_offset_entry[2] = cpu_to_le32(ssdt_addr);
+    rsdt->table_offset_entry[3] = cpu_to_le32(hpet_addr);
     acpi_build_table_header((struct acpi_table_header *)rsdt,
                             "RSDT", sizeof(*rsdt), 1);
 
@@ -1471,6 +1503,16 @@
         acpi_build_table_header((struct acpi_table_header *)madt,
                                 "APIC", madt_size, 1);
     }
+    /* HPET */
+    memset(hpet, 0, sizeof(*hpet));
+    /* Note timer_block_id value must be kept in sync with value advertised by
+     * emulated hpet
+     */
+    hpet->timer_block_id = cpu_to_le32(0x80868201);
+    hpet->addr.address = cpu_to_le32(ACPI_HPET_ADDRESS);
+    acpi_build_table_header((struct  acpi_table_header *)hpet,
+                             "HPET", sizeof(*hpet), 1);
+
 }
 
 /* SMBIOS entry point -- must be written to a 16-bit aligned address

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Qemu-devel] Re: [PATCH 2/2] Add HPET emulation to qemu (v3)
  2008-10-17 12:19 [Qemu-devel] [PATCH 2/2] Add HPET emulation to qemu (v3) Beth Kon
@ 2008-10-21 15:22 ` Anthony Liguori
  0 siblings, 0 replies; 2+ messages in thread
From: Anthony Liguori @ 2008-10-21 15:22 UTC (permalink / raw)
  To: Beth Kon; +Cc: qemu-devel, kvm, agraf

Beth Kon wrote:
> This patch contains the bochs bios changes needed to support the qemu hpet.
>   

Please wrap the bios changes in #ifdef BX_QEMU.  Also, you need 
Signed-off-by lines.

Regards,

Anthony Liguori

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-10-21 15:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-17 12:19 [Qemu-devel] [PATCH 2/2] Add HPET emulation to qemu (v3) Beth Kon
2008-10-21 15:22 ` [Qemu-devel] " Anthony Liguori

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).