From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KGnQq-00027T-St for qemu-devel@nongnu.org; Thu, 10 Jul 2008 00:07:00 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KGnQq-00026R-4P for qemu-devel@nongnu.org; Thu, 10 Jul 2008 00:07:00 -0400 Received: from [199.232.76.173] (port=39493 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KGnQp-00026F-WD for qemu-devel@nongnu.org; Thu, 10 Jul 2008 00:07:00 -0400 Received: from e6.ny.us.ibm.com ([32.97.182.146]:47603) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KGnQp-0007bh-TQ for qemu-devel@nongnu.org; Thu, 10 Jul 2008 00:07:00 -0400 Received: from d01relay02.pok.ibm.com (d01relay02.pok.ibm.com [9.56.227.234]) by e6.ny.us.ibm.com (8.13.8/8.13.8) with ESMTP id m6A49C6H009369 for ; Thu, 10 Jul 2008 00:09:12 -0400 Received: from d01av03.pok.ibm.com (d01av03.pok.ibm.com [9.56.224.217]) by d01relay02.pok.ibm.com (8.13.8/8.13.8/NCO v9.0) with ESMTP id m6A46ccC178940 for ; Thu, 10 Jul 2008 00:06:38 -0400 Received: from d01av03.pok.ibm.com (loopback [127.0.0.1]) by d01av03.pok.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id m6A46cQc011175 for ; Thu, 10 Jul 2008 00:06:38 -0400 From: Beth Kon Content-Type: text/plain Date: Thu, 10 Jul 2008 00:06:29 -0400 Message-Id: <1215662789.9862.41.camel@beth-ubuntu> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [PATCH] Add HPET support to BIOS Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: kvm@vger.kernel.org Cc: Ryan Harper , qemu-devel@nongnu.org This patch, written by Ryan Harper, adds HPET support to BIOS. Signed-off-by: Beth Kon diff --git a/bios/Makefile b/bios/Makefile index 48022ea..3e73fb5 100644 --- a/bios/Makefile +++ b/bios/Makefile @@ -40,7 +40,7 @@ LIBS = -lm RANLIB = ranlib BCC = bcc -GCC = gcc -m32 +GCC = gcc -m32 -fno-stack-protector HOST_CC = gcc AS86 = as86 diff --git a/bios/acpi-dsdt.dsl b/bios/acpi-dsdt.dsl index d1bfa2c..1548c86 100755 --- a/bios/acpi-dsdt.dsl +++ b/bios/acpi-dsdt.dsl @@ -262,6 +262,24 @@ DefinitionBlock ( Return (MEMP) } } + Device(HPET) { + Name(_HID, EISAID("PNP0103")) + Name(_UID, 0) + Method (_STA, 0, NotSerialized) { + Return(0x00) + } + Name(_CRS, ResourceTemplate() { + DWordMemory( + ResourceConsumer, PosDecode, MinFixed, MaxFixed, + NonCacheable, ReadWrite, + 0x00000000, + 0xFED00000, + 0xFED003FF, + 0x00000000, + 0x00000400 /* 1K memory: FED00000 - FED003FF */ + ) + }) + } } Scope(\_SB.PCI0) { @@ -628,7 +646,7 @@ DefinitionBlock ( { Or (PRQ3, 0x80, PRQ3) } - Method (_CRS, 0, NotSerialized) + Method (_CRS, 1, NotSerialized) { Name (PRR0, ResourceTemplate () { diff --git a/bios/rombios32.c b/bios/rombios32.c index 2dc1d25..c1ec015 100755 --- a/bios/rombios32.c +++ b/bios/rombios32.c @@ -1182,7 +1182,7 @@ struct rsdp_descriptor /* Root System Descriptor Pointer */ struct rsdt_descriptor_rev1 { ACPI_TABLE_HEADER_DEF /* ACPI common table header */ - uint32_t table_offset_entry [2]; /* Array of pointers to other */ + uint32_t table_offset_entry [3]; /* Array of pointers to other */ /* ACPI tables */ }; @@ -1322,6 +1322,30 @@ struct madt_processor_apic #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 @@ -1393,8 +1417,9 @@ void acpi_bios_init(void) struct fadt_descriptor_rev1 *fadt; struct facs_descriptor_rev1 *facs; struct multiple_apic_table *madt; + struct acpi_20_hpet *hpet; uint8_t *dsdt; - uint32_t base_addr, rsdt_addr, fadt_addr, addr, facs_addr, dsdt_addr; + uint32_t base_addr, rsdt_addr, fadt_addr, addr, facs_addr, dsdt_addr, hpet_addr; uint32_t acpi_tables_size, madt_addr, madt_size; int i; @@ -1436,6 +1461,11 @@ void acpi_bios_init(void) 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", @@ -1457,6 +1487,7 @@ void acpi_bios_init(void) 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); + rsdt->table_offset_entry[2] = cpu_to_le32(hpet_addr); acpi_build_table_header((struct acpi_table_header *)rsdt, "RSDT", sizeof(*rsdt), 1); @@ -1540,6 +1571,15 @@ void acpi_bios_init(void) acpi_build_table_header((struct acpi_table_header *)madt, "APIC", madt_size, 1); } + + /* HPET */ + memset(hpet, 0, sizeof(*hpet)); + hpet->timer_block_id = cpu_to_le32(0x8086a201); + // hpet->timer_block_id = cpu_to_le32(0x80862201); + 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 -- Elizabeth Kon (Beth) IBM Linux Technology Center Open Hypervisor Team email: eak@us.ibm.com