Skip to contentSkip to conversation

Add HPET support to BIOS

PATCH In review Beth Kon 3 participants 5 messages Jul 10, 2008 KVM

lore
Share & tools
lore

Beth Kon

author
#0 lore raw

PATCH 1/1 Add HPET support to BIOS

This patch, written by Ryan Harper, adds HPET support to BIOS.

bios/Makefile +1 -1
index 48022ea..3e73fb5 100644
@@ -40,7 +40,7 @@ LIBS =  -lm
 RANLIB = ranlib
 
 BCC = bcc
-GCC = gcc -m32
+GCC = gcc -m32 -fno-stack-protector
 HOST_CC = gcc
 AS86 = as86
 
bios/acpi-dsdt.dsl +19 -1
index d1bfa2c..1548c86 100755
@@ -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 ()
                     {
bios/rombios32.c +0 -0
index 2dc1d25..c1ec015 100755
@@ -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

Signature · 4 lines
Elizabeth Kon (Beth)
IBM Linux Technology Center
Open Hypervisor Team
email: [email protected]
#2 lore raw
In reply to Beth Kon
Quoted 22 lines · Beth Kon

This patch, written by Ryan Harper, adds HPET support to BIOS.

bios/Makefile +0 -0
index 48022ea..3e73fb5 100644
@@ -40,7 +40,7 @@ LIBS =  -lm

RANLIB = ranlib

BCC = bcc

bios/Makefile +1 -1
-GCC = gcc -m32
+GCC = gcc -m32 -fno-stack-protector

HOST_CC = gcc
AS86 = as86

bios/acpi-dsdt.dsl +0 -0
index d1bfa2c..1548c86 100755

bios/acpi-dsdt.dsl DefinitionBlock ( · line 267

Quoted 6 lines
bios/acpi-dsdt.dsl +3 -0
@@ -262,6 +262,24 @@ DefinitionBlock (
                Return (MEMP)
            }
        }
+        Device(HPET) {
+            Name(_HID,  EISAID("PNP0103"))
+            Name(_UID, 0)

_UID is optional if only one timer block is present.

bios/acpi-dsdt.dsl DefinitionBlock ( · line 269

Quoted 2 lines
bios/acpi-dsdt.dsl +2 -0
+            Method (_STA, 0, NotSerialized) {
+                    Return(0x00)

Not present?

Quoted 17 lines
bios/acpi-dsdt.dsl +13 -0
+            }
+            Name(_CRS, ResourceTemplate() {
+                DWordMemory(
+                    ResourceConsumer, PosDecode, MinFixed, MaxFixed,
+                    NonCacheable, ReadWrite,
+                    0x00000000,
+                    0xFED00000,
+                    0xFED003FF,
+                    0x00000000,
+                    0x00000400 /* 1K memory: FED00000 - FED003FF */
+                )
+            })
+        }
    }
 
    Scope(\_SB.PCI0) {

bios/acpi-dsdt.dsl DefinitionBlock ( · line 652

Quoted 8 lines
bios/acpi-dsdt.dsl +1 -1
@@ -628,7 +646,7 @@ DefinitionBlock (
                {
                    Or (PRQ3, 0x80, PRQ3)
                }
-                Method (_CRS, 0, NotSerialized)
+                Method (_CRS, 1, NotSerialized)
                {
                    Name (PRR0, ResourceTemplate ()
                    {

Is this change related?

Quoted 84 lines
bios/rombios32.c +0 -0
index 2dc1d25..c1ec015 100755
@@ -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 */
};

bios/rombios32.c +16 -0
@@ -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 */

bios/rombios32.c +8 -0
+    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

bios/rombios32.c +2 -1
@@ -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;
bios/rombios32.c +5 -0
@@ -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",

bios/rombios32.c +1 -0
@@ -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);
 

bios/rombios32.c void acpi_bios_init(void) · line 1578

Quoted 8 lines
bios/rombios32.c +5 -0
@@ -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);

This "magic value" could need some explanation so people don't have to look it up. Something like:
8086 = pci vendor id
a201 = 1010001000000001
1 LegacyReplacement IRQ Routing Capable
0 reserved
1 COUNT_SIZE_CAP counter size
00010 Number of Comparators
00000001 Hardwave revision id

Also add a comment that it should be kept in sync with the emulation (hpet.c).

- Sebastian

Quoted 10 lines
bios/rombios32.c +4 -0
+    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
#3 lore raw

* Sebastian Herbszt <[email protected]> [2008-07-10 10:46]:

Hey Sebastian,

Thanks for the review,

Quoted 18 lines
Quoted 17 lines · Beth Kon

This patch, written by Ryan Harper, adds HPET support to BIOS.

bios/Makefile +0 -0
index 48022ea..3e73fb5 100644
@@ -40,7 +40,7 @@ LIBS =  -lm

RANLIB = ranlib

BCC = bcc

bios/Makefile +1 -1
-GCC = gcc -m32
+GCC = gcc -m32 -fno-stack-protector

HOST_CC = gcc
AS86 = as86

Quoted 13 lines

bios/acpi-dsdt.dsl DefinitionBlock ( · line 267

Quoted 11 lines
bios/acpi-dsdt.dsl +3 -0
index d1bfa2c..1548c86 100755
@@ -262,6 +262,24 @@ DefinitionBlock (
               Return (MEMP)
           }
       }
+        Device(HPET) {
+            Name(_HID,  EISAID("PNP0103"))
+            Name(_UID, 0)

_UID is optional if only one timer block is present.

OK

Quoted 5 lines

bios/acpi-dsdt.dsl DefinitionBlock ( · line 269

Quoted 3 lines
bios/acpi-dsdt.dsl +2 -0
+            Method (_STA, 0, NotSerialized) {
+                    Return(0x00)

Not present?

Was playing around with this when trying to get Linux to see the device in the ACPI tables. AFAICT, Linux doesn't care about this value. Should be 1 here then?

Quoted 16 lines
Quoted 16 lines
bios/acpi-dsdt.dsl +13 -0
+            }
+            Name(_CRS, ResourceTemplate() {
+                DWordMemory(
+                    ResourceConsumer, PosDecode, MinFixed, MaxFixed,
+                    NonCacheable, ReadWrite,
+                    0x00000000,
+                    0xFED00000,
+                    0xFED003FF,
+                    0x00000000,
+                    0x00000400 /* 1K memory: FED00000 - FED003FF */
+                )
+            })
+        }
   }
 
Quoted 12 lines

bios/acpi-dsdt.dsl DefinitionBlock ( · line 652

Quoted 10 lines
bios/acpi-dsdt.dsl +1 -1
   Scope(\_SB.PCI0) {
@@ -628,7 +646,7 @@ DefinitionBlock (
               {
                   Or (PRQ3, 0x80, PRQ3)
               }
-                Method (_CRS, 0, NotSerialized)
+                Method (_CRS, 1, NotSerialized)
               {
                   Name (PRR0, ResourceTemplate ()
                   {

Is this change related?

Doubtful, I'll confirm whether or not it is needed.

Quoted 96 lines
Quoted 85 lines
bios/rombios32.c +0 -0
index 2dc1d25..c1ec015 100755
@@ -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 */
};

bios/rombios32.c +16 -0
@@ -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 */

bios/rombios32.c +8 -0
+    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

bios/rombios32.c +2 -1
@@ -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;
bios/rombios32.c +5 -0
@@ -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",

bios/rombios32.c +1 -0
@@ -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);
 

bios/rombios32.c void acpi_bios_init(void) · line 1578

Quoted 8 lines
bios/rombios32.c +5 -0
@@ -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);

This "magic value" could need some explanation so people don't have to look it up.

Quoted 8 lines

Something like:
8086 = pci vendor id
a201 = 1010001000000001
1 LegacyReplacement IRQ Routing Capable
0 reserved
1 COUNT_SIZE_CAP counter size
00010 Number of Comparators
00000001 Hardwave revision id

That's a fair point though one needs the spec to make any sort of intelligent change anyhow.

Quoted 3 lines

Also add a comment that it should be kept in sync with the emulation (hpet.c).

Yeah, this is an important point as they do need to agree.

Quoted 13 lines

- Sebastian

Quoted 10 lines
bios/rombios32.c +4 -0
+    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
Signature · 5 lines
Ryan Harper
Software Engineer; Linux Technology Center
IBM Corp., Austin, Tx
(512) 838-9253   T/L: 678-9253
[email protected]
#4 lore raw
Quoted 39 lines · Ryan Harper

Hey Sebastian,

Thanks for the review,

Quoted 18 lines
Quoted 17 lines · Beth Kon

This patch, written by Ryan Harper, adds HPET support to BIOS.

bios/Makefile +0 -0
index 48022ea..3e73fb5 100644
@@ -40,7 +40,7 @@ LIBS =  -lm

RANLIB = ranlib

BCC = bcc

bios/Makefile +1 -1
-GCC = gcc -m32
+GCC = gcc -m32 -fno-stack-protector

HOST_CC = gcc
AS86 = as86

Quoted 13 lines

bios/acpi-dsdt.dsl DefinitionBlock ( · line 267

Quoted 11 lines
bios/acpi-dsdt.dsl +3 -0
index d1bfa2c..1548c86 100755
@@ -262,6 +262,24 @@ DefinitionBlock (
               Return (MEMP)
           }
       }
+        Device(HPET) {
+            Name(_HID,  EISAID("PNP0103"))
+            Name(_UID, 0)

_UID is optional if only one timer block is present.

OK

Quoted 1 line
Quoted 8 lines
Quoted 4 lines

bios/acpi-dsdt.dsl DefinitionBlock ( · line 269

Quoted 2 lines
bios/acpi-dsdt.dsl +2 -0
+            Method (_STA, 0, NotSerialized) {
+                    Return(0x00)

Not present?

Was playing around with this when trying to get Linux to see the device in the ACPI tables. AFAICT, Linux doesn't care about this value. Should be 1 here then?

I would suggest 0x0F (present, enabled and "more").

It would be nice to runtime detect the presence of the hpet and return the proper value, e.g. 0x0 if not present and skip the HPET ACPI table creation. The Xen DSDT does it with the help of a bios info table which gets created at runtime. It detects the hpet by reading the vendor id from HPET_BASE. Something like this might also be possible inside the DSDT (OperationRegion, Field and LEqual).

Quoted 135 lines
Quoted 16 lines
Quoted 16 lines
bios/acpi-dsdt.dsl +13 -0
+            }
+            Name(_CRS, ResourceTemplate() {
+                DWordMemory(
+                    ResourceConsumer, PosDecode, MinFixed, MaxFixed,
+                    NonCacheable, ReadWrite,
+                    0x00000000,
+                    0xFED00000,
+                    0xFED003FF,
+                    0x00000000,
+                    0x00000400 /* 1K memory: FED00000 - FED003FF */
+                )
+            })
+        }
   }
 
Quoted 12 lines

bios/acpi-dsdt.dsl DefinitionBlock ( · line 652

Quoted 10 lines
bios/acpi-dsdt.dsl +1 -1
   Scope(\_SB.PCI0) {
@@ -628,7 +646,7 @@ DefinitionBlock (
               {
                   Or (PRQ3, 0x80, PRQ3)
               }
-                Method (_CRS, 0, NotSerialized)
+                Method (_CRS, 1, NotSerialized)
               {
                   Name (PRR0, ResourceTemplate ()
                   {

Is this change related?

Doubtful, I'll confirm whether or not it is needed.

Quoted 95 lines
Quoted 85 lines
bios/rombios32.c +0 -0
index 2dc1d25..c1ec015 100755
@@ -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 */
};

bios/rombios32.c +16 -0
@@ -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 */

bios/rombios32.c +8 -0
+    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

bios/rombios32.c +2 -1
@@ -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;
bios/rombios32.c +5 -0
@@ -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",

bios/rombios32.c +1 -0
@@ -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);
 

bios/rombios32.c void acpi_bios_init(void) · line 1578

Quoted 8 lines
bios/rombios32.c +5 -0
@@ -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);

This "magic value" could need some explanation so people don't have to look it up.

Quoted 8 lines

Something like:
8086 = pci vendor id
a201 = 1010001000000001
1 LegacyReplacement IRQ Routing Capable
0 reserved
1 COUNT_SIZE_CAP counter size
00010 Number of Comparators
00000001 Hardwave revision id

Quoted 2 lines

That's a fair point though one needs the spec to make any sort of intelligent change anyhow.

True.

Quoted 6 lines
Quoted 2 lines

Also add a comment that it should be kept in sync with the emulation (hpet.c).

Yeah, this is an important point as they do need to agree.

- Sebastian

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
bios/rombios32.c +4 -0
+    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