diff mbox

[45/74] pc: acpi: move HPET from DSDT to SSDT

Message ID 1449704528-289297-46-git-send-email-imammedo@redhat.com
State New
Headers show

Commit Message

Igor Mammedov Dec. 9, 2015, 11:41 p.m. UTC
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 hw/i386/acpi-build.c       | 53 ++++++++++++++++++++++++++++++++++++++++++++++
 hw/i386/acpi-dsdt-hpet.dsl | 48 -----------------------------------------
 hw/i386/acpi-dsdt.dsl      |  2 --
 hw/i386/q35-acpi-dsdt.dsl  |  3 ---
 hw/timer/hpet.c            |  2 +-
 include/hw/timer/hpet.h    |  1 +
 6 files changed, 55 insertions(+), 54 deletions(-)
 delete mode 100644 hw/i386/acpi-dsdt-hpet.dsl

Comments

Michael S. Tsirkin Dec. 19, 2015, 7:50 p.m. UTC | #1
On Thu, Dec 10, 2015 at 12:41:39AM +0100, Igor Mammedov wrote:
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> ---
>  hw/i386/acpi-build.c       | 53 ++++++++++++++++++++++++++++++++++++++++++++++
>  hw/i386/acpi-dsdt-hpet.dsl | 48 -----------------------------------------
>  hw/i386/acpi-dsdt.dsl      |  2 --
>  hw/i386/q35-acpi-dsdt.dsl  |  3 ---
>  hw/timer/hpet.c            |  2 +-
>  include/hw/timer/hpet.h    |  1 +
>  6 files changed, 55 insertions(+), 54 deletions(-)
>  delete mode 100644 hw/i386/acpi-dsdt-hpet.dsl
> 
> diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> index 72883ad..62f932e 100644
> --- a/hw/i386/acpi-build.c
> +++ b/hw/i386/acpi-build.c
> @@ -50,6 +50,7 @@
>  #include "hw/pci/pci_bus.h"
>  #include "hw/pci-host/q35.h"
>  #include "hw/i386/intel_iommu.h"
> +#include "hw/timer/hpet.h"
>  
>  #include "hw/i386/q35-acpi-dsdt.hex"
>  #include "hw/i386/acpi-dsdt.hex"
> @@ -1119,6 +1120,57 @@ static void build_memory_devices(Aml *sb_scope, int nr_mem,
>      aml_append(sb_scope, method);
>  }
>  
> +static void build_hpet_aml(Aml *table)
> +{
> +    Aml *crs;
> +    Aml *field;
> +    Aml *method;
> +    Aml *if_ctx;
> +    Aml *scope = aml_scope("_SB");
> +    Aml *dev = aml_device("HPET");
> +    Aml *a_zero = aml_int(0);
> +    Aml *a_id = aml_local(0);
> +    Aml *a_period = aml_local(1);

This one really jumps out, but it's all over the place.
Please drop these a_ prefixes all over, they don't help.

> +
> +    aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0103")));
> +    aml_append(dev, aml_name_decl("_UID", a_zero));
> +
> +    aml_append(dev, aml_operation_region("HPTM", AML_SYSTEM_MEMORY,
> +                                         HPET_BASE, HPET_LEN));
> +    field = aml_field("HPTM", AML_DWORD_ACC, AML_LOCK, AML_PRESERVE);
> +    aml_append(field, aml_named_field("VEND", 32));
> +    aml_append(field, aml_named_field("PRD", 32));
> +    aml_append(dev, field);
> +
> +    method = aml_method("_STA", 0, AML_NOTSERIALIZED);
> +    aml_append(method, aml_store(aml_name("VEND"), a_id));
> +    aml_append(method, aml_store(aml_name("PRD"), a_period));
> +    aml_append(method, aml_shiftright(a_id, aml_int(16), a_id));
> +    if_ctx = aml_if(aml_lor(
> +                            aml_equal(a_id, a_zero),
> +                            aml_equal(a_id, aml_int(0xffff))));
> +    aml_append(if_ctx, aml_return(a_zero));
> +    aml_append(method, if_ctx);
> +
> +    if_ctx = aml_if(aml_lor(

Don't split lines like this please.

> +                            aml_equal(a_period, a_zero),
> +                            aml_lgreater(a_period, aml_int(100000000))));
> +    aml_append(if_ctx, aml_return(a_zero));
> +    aml_append(method, if_ctx);
> +
> +    aml_append(method, aml_return(aml_int(0x0F)));
> +    aml_append(dev, method);
> +
> +    crs = aml_resource_template();
> +    aml_append(crs,
> +        aml_memory32_fixed(HPET_BASE, HPET_LEN, AML_READ_ONLY)
> +    );
> +    aml_append(dev, aml_name_decl("_CRS", crs));
> +
> +    aml_append(scope, dev);
> +    aml_append(table, scope);
> +}
> +
>  static void
>  build_ssdt(GArray *table_data, GArray *linker,
>             AcpiCpuInfo *cpu, AcpiPmInfo *pm, AcpiMiscInfo *misc,
> @@ -1139,6 +1191,7 @@ build_ssdt(GArray *table_data, GArray *linker,
>      /* Reserve space for header */
>      acpi_data_push(ssdt->buf, sizeof(AcpiTableHeader));
>  
> +    build_hpet_aml(ssdt);
>      build_cpu_hotplug_aml(ssdt);
>      build_memory_hotplug_aml(ssdt, nr_mem, pm->mem_hp_io_base,
>                               pm->mem_hp_io_len);
> diff --git a/hw/i386/acpi-dsdt-hpet.dsl b/hw/i386/acpi-dsdt-hpet.dsl
> deleted file mode 100644
> index 44961b8..0000000
> --- a/hw/i386/acpi-dsdt-hpet.dsl
> +++ /dev/null
> @@ -1,48 +0,0 @@
> -/*
> - * This program is free software; you can redistribute it and/or modify
> - * it under the terms of the GNU General Public License as published by
> - * the Free Software Foundation; either version 2 of the License, or
> - * (at your option) any later version.
> -
> - * 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.
> -
> - * You should have received a copy of the GNU General Public License along
> - * with this program; if not, see <http://www.gnu.org/licenses/>.
> - */
> -
> -/****************************************************************
> - * HPET
> - ****************************************************************/
> -
> -Scope(\_SB) {
> -    Device(HPET) {
> -        Name(_HID, EISAID("PNP0103"))
> -        Name(_UID, 0)
> -        OperationRegion(HPTM, SystemMemory, 0xFED00000, 0x400)
> -        Field(HPTM, DWordAcc, Lock, Preserve) {
> -            VEND, 32,
> -            PRD, 32,
> -        }
> -        Method(_STA, 0, NotSerialized) {
> -            Store(VEND, Local0)
> -            Store(PRD, Local1)
> -            ShiftRight(Local0, 16, Local0)
> -            If (LOr(LEqual(Local0, 0), LEqual(Local0, 0xffff))) {
> -                Return (0x0)
> -            }
> -            If (LOr(LEqual(Local1, 0), LGreater(Local1, 100000000))) {
> -                Return (0x0)
> -            }
> -            Return (0x0F)
> -        }
> -        Name(_CRS, ResourceTemplate() {
> -            Memory32Fixed(ReadOnly,
> -                0xFED00000,         // Address Base
> -                0x00000400,         // Address Length
> -                )
> -        })
> -    }
> -}
> diff --git a/hw/i386/acpi-dsdt.dsl b/hw/i386/acpi-dsdt.dsl
> index 007d3c9..aa7f549 100644
> --- a/hw/i386/acpi-dsdt.dsl
> +++ b/hw/i386/acpi-dsdt.dsl
> @@ -41,8 +41,6 @@ DefinitionBlock (
>          }
>      }
>  
> -#include "acpi-dsdt-hpet.dsl"
> -
>  /****************************************************************
>   * PIIX4 PM
>   ****************************************************************/
> diff --git a/hw/i386/q35-acpi-dsdt.dsl b/hw/i386/q35-acpi-dsdt.dsl
> index 0511e26..e57adb8 100644
> --- a/hw/i386/q35-acpi-dsdt.dsl
> +++ b/hw/i386/q35-acpi-dsdt.dsl
> @@ -115,9 +115,6 @@ DefinitionBlock (
>          }
>      }
>  
> -#include "acpi-dsdt-hpet.dsl"
> -
> -
>  /****************************************************************
>   * LPC ISA bridge
>   ****************************************************************/
> diff --git a/hw/timer/hpet.c b/hw/timer/hpet.c
> index 7f0391c..d9d039b 100644
> --- a/hw/timer/hpet.c
> +++ b/hw/timer/hpet.c
> @@ -713,7 +713,7 @@ static void hpet_init(Object *obj)
>      HPETState *s = HPET(obj);
>  
>      /* HPET Area */
> -    memory_region_init_io(&s->iomem, obj, &hpet_ram_ops, s, "hpet", 0x400);
> +    memory_region_init_io(&s->iomem, obj, &hpet_ram_ops, s, "hpet", HPET_LEN);
>      sysbus_init_mmio(sbd, &s->iomem);
>  }
>  
> diff --git a/include/hw/timer/hpet.h b/include/hw/timer/hpet.h
> index d872909..f38bcfe 100644
> --- a/include/hw/timer/hpet.h
> +++ b/include/hw/timer/hpet.h
> @@ -16,6 +16,7 @@
>  #include "qom/object.h"
>  
>  #define HPET_BASE               0xfed00000
> +#define HPET_LEN                0x400
>  #define HPET_CLK_PERIOD         10 /* 10 ns*/
>  
>  #define FS_PER_NS 1000000       /* 1000000 femtoseconds == 1 ns */
> -- 
> 1.8.3.1
>
Igor Mammedov Dec. 21, 2015, 11:02 a.m. UTC | #2
On Sat, 19 Dec 2015 21:50:41 +0200
"Michael S. Tsirkin" <mst@redhat.com> wrote:

> On Thu, Dec 10, 2015 at 12:41:39AM +0100, Igor Mammedov wrote:
> > Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> > ---
> >  hw/i386/acpi-build.c       | 53 ++++++++++++++++++++++++++++++++++++++++++++++
> >  hw/i386/acpi-dsdt-hpet.dsl | 48 -----------------------------------------
> >  hw/i386/acpi-dsdt.dsl      |  2 --
> >  hw/i386/q35-acpi-dsdt.dsl  |  3 ---
> >  hw/timer/hpet.c            |  2 +-
> >  include/hw/timer/hpet.h    |  1 +
> >  6 files changed, 55 insertions(+), 54 deletions(-)
> >  delete mode 100644 hw/i386/acpi-dsdt-hpet.dsl
> > 
> > diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> > index 72883ad..62f932e 100644
> > --- a/hw/i386/acpi-build.c
> > +++ b/hw/i386/acpi-build.c
> > @@ -50,6 +50,7 @@
> >  #include "hw/pci/pci_bus.h"
> >  #include "hw/pci-host/q35.h"
> >  #include "hw/i386/intel_iommu.h"
> > +#include "hw/timer/hpet.h"
> >  
> >  #include "hw/i386/q35-acpi-dsdt.hex"
> >  #include "hw/i386/acpi-dsdt.hex"
> > @@ -1119,6 +1120,57 @@ static void build_memory_devices(Aml *sb_scope, int nr_mem,
> >      aml_append(sb_scope, method);
> >  }
> >  
> > +static void build_hpet_aml(Aml *table)
> > +{
> > +    Aml *crs;
> > +    Aml *field;
> > +    Aml *method;
> > +    Aml *if_ctx;
> > +    Aml *scope = aml_scope("_SB");
> > +    Aml *dev = aml_device("HPET");
> > +    Aml *a_zero = aml_int(0);
> > +    Aml *a_id = aml_local(0);
> > +    Aml *a_period = aml_local(1);
> 
> This one really jumps out, but it's all over the place.
> Please drop these a_ prefixes all over, they don't help.
sure

> 
> > +
> > +    aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0103")));
> > +    aml_append(dev, aml_name_decl("_UID", a_zero));
> > +
> > +    aml_append(dev, aml_operation_region("HPTM", AML_SYSTEM_MEMORY,
> > +                                         HPET_BASE, HPET_LEN));
> > +    field = aml_field("HPTM", AML_DWORD_ACC, AML_LOCK, AML_PRESERVE);
> > +    aml_append(field, aml_named_field("VEND", 32));
> > +    aml_append(field, aml_named_field("PRD", 32));
> > +    aml_append(dev, field);
> > +
> > +    method = aml_method("_STA", 0, AML_NOTSERIALIZED);
> > +    aml_append(method, aml_store(aml_name("VEND"), a_id));
> > +    aml_append(method, aml_store(aml_name("PRD"), a_period));
> > +    aml_append(method, aml_shiftright(a_id, aml_int(16), a_id));
> > +    if_ctx = aml_if(aml_lor(
> > +                            aml_equal(a_id, a_zero),
> > +                            aml_equal(a_id, aml_int(0xffff))));
> > +    aml_append(if_ctx, aml_return(a_zero));
> > +    aml_append(method, if_ctx);
> > +
> > +    if_ctx = aml_if(aml_lor(
> 
> Don't split lines like this please.
What style would you prefer?

> 
> > +                            aml_equal(a_period, a_zero),
> > +                            aml_lgreater(a_period, aml_int(100000000))));
> > +    aml_append(if_ctx, aml_return(a_zero));
> > +    aml_append(method, if_ctx);
> > +
> > +    aml_append(method, aml_return(aml_int(0x0F)));
> > +    aml_append(dev, method);
> > +
> > +    crs = aml_resource_template();
> > +    aml_append(crs,
> > +        aml_memory32_fixed(HPET_BASE, HPET_LEN, AML_READ_ONLY)
> > +    );
> > +    aml_append(dev, aml_name_decl("_CRS", crs));
> > +
> > +    aml_append(scope, dev);
> > +    aml_append(table, scope);
> > +}
> > +
> >  static void
> >  build_ssdt(GArray *table_data, GArray *linker,
> >             AcpiCpuInfo *cpu, AcpiPmInfo *pm, AcpiMiscInfo *misc,
> > @@ -1139,6 +1191,7 @@ build_ssdt(GArray *table_data, GArray *linker,
> >      /* Reserve space for header */
> >      acpi_data_push(ssdt->buf, sizeof(AcpiTableHeader));
> >  
> > +    build_hpet_aml(ssdt);
> >      build_cpu_hotplug_aml(ssdt);
> >      build_memory_hotplug_aml(ssdt, nr_mem, pm->mem_hp_io_base,
> >                               pm->mem_hp_io_len);
> > diff --git a/hw/i386/acpi-dsdt-hpet.dsl b/hw/i386/acpi-dsdt-hpet.dsl
> > deleted file mode 100644
> > index 44961b8..0000000
> > --- a/hw/i386/acpi-dsdt-hpet.dsl
> > +++ /dev/null
> > @@ -1,48 +0,0 @@
> > -/*
> > - * This program is free software; you can redistribute it and/or modify
> > - * it under the terms of the GNU General Public License as published by
> > - * the Free Software Foundation; either version 2 of the License, or
> > - * (at your option) any later version.
> > -
> > - * 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.
> > -
> > - * You should have received a copy of the GNU General Public License along
> > - * with this program; if not, see <http://www.gnu.org/licenses/>.
> > - */
> > -
> > -/****************************************************************
> > - * HPET
> > - ****************************************************************/
> > -
> > -Scope(\_SB) {
> > -    Device(HPET) {
> > -        Name(_HID, EISAID("PNP0103"))
> > -        Name(_UID, 0)
> > -        OperationRegion(HPTM, SystemMemory, 0xFED00000, 0x400)
> > -        Field(HPTM, DWordAcc, Lock, Preserve) {
> > -            VEND, 32,
> > -            PRD, 32,
> > -        }
> > -        Method(_STA, 0, NotSerialized) {
> > -            Store(VEND, Local0)
> > -            Store(PRD, Local1)
> > -            ShiftRight(Local0, 16, Local0)
> > -            If (LOr(LEqual(Local0, 0), LEqual(Local0, 0xffff))) {
> > -                Return (0x0)
> > -            }
> > -            If (LOr(LEqual(Local1, 0), LGreater(Local1, 100000000))) {
> > -                Return (0x0)
> > -            }
> > -            Return (0x0F)
> > -        }
> > -        Name(_CRS, ResourceTemplate() {
> > -            Memory32Fixed(ReadOnly,
> > -                0xFED00000,         // Address Base
> > -                0x00000400,         // Address Length
> > -                )
> > -        })
> > -    }
> > -}
> > diff --git a/hw/i386/acpi-dsdt.dsl b/hw/i386/acpi-dsdt.dsl
> > index 007d3c9..aa7f549 100644
> > --- a/hw/i386/acpi-dsdt.dsl
> > +++ b/hw/i386/acpi-dsdt.dsl
> > @@ -41,8 +41,6 @@ DefinitionBlock (
> >          }
> >      }
> >  
> > -#include "acpi-dsdt-hpet.dsl"
> > -
> >  /****************************************************************
> >   * PIIX4 PM
> >   ****************************************************************/
> > diff --git a/hw/i386/q35-acpi-dsdt.dsl b/hw/i386/q35-acpi-dsdt.dsl
> > index 0511e26..e57adb8 100644
> > --- a/hw/i386/q35-acpi-dsdt.dsl
> > +++ b/hw/i386/q35-acpi-dsdt.dsl
> > @@ -115,9 +115,6 @@ DefinitionBlock (
> >          }
> >      }
> >  
> > -#include "acpi-dsdt-hpet.dsl"
> > -
> > -
> >  /****************************************************************
> >   * LPC ISA bridge
> >   ****************************************************************/
> > diff --git a/hw/timer/hpet.c b/hw/timer/hpet.c
> > index 7f0391c..d9d039b 100644
> > --- a/hw/timer/hpet.c
> > +++ b/hw/timer/hpet.c
> > @@ -713,7 +713,7 @@ static void hpet_init(Object *obj)
> >      HPETState *s = HPET(obj);
> >  
> >      /* HPET Area */
> > -    memory_region_init_io(&s->iomem, obj, &hpet_ram_ops, s, "hpet", 0x400);
> > +    memory_region_init_io(&s->iomem, obj, &hpet_ram_ops, s, "hpet", HPET_LEN);
> >      sysbus_init_mmio(sbd, &s->iomem);
> >  }
> >  
> > diff --git a/include/hw/timer/hpet.h b/include/hw/timer/hpet.h
> > index d872909..f38bcfe 100644
> > --- a/include/hw/timer/hpet.h
> > +++ b/include/hw/timer/hpet.h
> > @@ -16,6 +16,7 @@
> >  #include "qom/object.h"
> >  
> >  #define HPET_BASE               0xfed00000
> > +#define HPET_LEN                0x400
> >  #define HPET_CLK_PERIOD         10 /* 10 ns*/
> >  
> >  #define FS_PER_NS 1000000       /* 1000000 femtoseconds == 1 ns */
> > -- 
> > 1.8.3.1
> >
Michael S. Tsirkin Dec. 21, 2015, 11:42 a.m. UTC | #3
On Mon, Dec 21, 2015 at 12:02:52PM +0100, Igor Mammedov wrote:
> > > +
> > > +    if_ctx = aml_if(aml_lor(
> > 
> > Don't split lines like this please.
> What style would you prefer?

break after a comma:

    if_ctx = aml_if(aml_lor(aml_equal(a_period, a_zero),


> > 
> > > +                            aml_equal(a_period, a_zero),
> > > +                            aml_lgreater(a_period, aml_int(100000000))));
diff mbox

Patch

diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 72883ad..62f932e 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -50,6 +50,7 @@ 
 #include "hw/pci/pci_bus.h"
 #include "hw/pci-host/q35.h"
 #include "hw/i386/intel_iommu.h"
+#include "hw/timer/hpet.h"
 
 #include "hw/i386/q35-acpi-dsdt.hex"
 #include "hw/i386/acpi-dsdt.hex"
@@ -1119,6 +1120,57 @@  static void build_memory_devices(Aml *sb_scope, int nr_mem,
     aml_append(sb_scope, method);
 }
 
+static void build_hpet_aml(Aml *table)
+{
+    Aml *crs;
+    Aml *field;
+    Aml *method;
+    Aml *if_ctx;
+    Aml *scope = aml_scope("_SB");
+    Aml *dev = aml_device("HPET");
+    Aml *a_zero = aml_int(0);
+    Aml *a_id = aml_local(0);
+    Aml *a_period = aml_local(1);
+
+    aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0103")));
+    aml_append(dev, aml_name_decl("_UID", a_zero));
+
+    aml_append(dev, aml_operation_region("HPTM", AML_SYSTEM_MEMORY,
+                                         HPET_BASE, HPET_LEN));
+    field = aml_field("HPTM", AML_DWORD_ACC, AML_LOCK, AML_PRESERVE);
+    aml_append(field, aml_named_field("VEND", 32));
+    aml_append(field, aml_named_field("PRD", 32));
+    aml_append(dev, field);
+
+    method = aml_method("_STA", 0, AML_NOTSERIALIZED);
+    aml_append(method, aml_store(aml_name("VEND"), a_id));
+    aml_append(method, aml_store(aml_name("PRD"), a_period));
+    aml_append(method, aml_shiftright(a_id, aml_int(16), a_id));
+    if_ctx = aml_if(aml_lor(
+                            aml_equal(a_id, a_zero),
+                            aml_equal(a_id, aml_int(0xffff))));
+    aml_append(if_ctx, aml_return(a_zero));
+    aml_append(method, if_ctx);
+
+    if_ctx = aml_if(aml_lor(
+                            aml_equal(a_period, a_zero),
+                            aml_lgreater(a_period, aml_int(100000000))));
+    aml_append(if_ctx, aml_return(a_zero));
+    aml_append(method, if_ctx);
+
+    aml_append(method, aml_return(aml_int(0x0F)));
+    aml_append(dev, method);
+
+    crs = aml_resource_template();
+    aml_append(crs,
+        aml_memory32_fixed(HPET_BASE, HPET_LEN, AML_READ_ONLY)
+    );
+    aml_append(dev, aml_name_decl("_CRS", crs));
+
+    aml_append(scope, dev);
+    aml_append(table, scope);
+}
+
 static void
 build_ssdt(GArray *table_data, GArray *linker,
            AcpiCpuInfo *cpu, AcpiPmInfo *pm, AcpiMiscInfo *misc,
@@ -1139,6 +1191,7 @@  build_ssdt(GArray *table_data, GArray *linker,
     /* Reserve space for header */
     acpi_data_push(ssdt->buf, sizeof(AcpiTableHeader));
 
+    build_hpet_aml(ssdt);
     build_cpu_hotplug_aml(ssdt);
     build_memory_hotplug_aml(ssdt, nr_mem, pm->mem_hp_io_base,
                              pm->mem_hp_io_len);
diff --git a/hw/i386/acpi-dsdt-hpet.dsl b/hw/i386/acpi-dsdt-hpet.dsl
deleted file mode 100644
index 44961b8..0000000
--- a/hw/i386/acpi-dsdt-hpet.dsl
+++ /dev/null
@@ -1,48 +0,0 @@ 
-/*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
-
- * 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.
-
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, see <http://www.gnu.org/licenses/>.
- */
-
-/****************************************************************
- * HPET
- ****************************************************************/
-
-Scope(\_SB) {
-    Device(HPET) {
-        Name(_HID, EISAID("PNP0103"))
-        Name(_UID, 0)
-        OperationRegion(HPTM, SystemMemory, 0xFED00000, 0x400)
-        Field(HPTM, DWordAcc, Lock, Preserve) {
-            VEND, 32,
-            PRD, 32,
-        }
-        Method(_STA, 0, NotSerialized) {
-            Store(VEND, Local0)
-            Store(PRD, Local1)
-            ShiftRight(Local0, 16, Local0)
-            If (LOr(LEqual(Local0, 0), LEqual(Local0, 0xffff))) {
-                Return (0x0)
-            }
-            If (LOr(LEqual(Local1, 0), LGreater(Local1, 100000000))) {
-                Return (0x0)
-            }
-            Return (0x0F)
-        }
-        Name(_CRS, ResourceTemplate() {
-            Memory32Fixed(ReadOnly,
-                0xFED00000,         // Address Base
-                0x00000400,         // Address Length
-                )
-        })
-    }
-}
diff --git a/hw/i386/acpi-dsdt.dsl b/hw/i386/acpi-dsdt.dsl
index 007d3c9..aa7f549 100644
--- a/hw/i386/acpi-dsdt.dsl
+++ b/hw/i386/acpi-dsdt.dsl
@@ -41,8 +41,6 @@  DefinitionBlock (
         }
     }
 
-#include "acpi-dsdt-hpet.dsl"
-
 /****************************************************************
  * PIIX4 PM
  ****************************************************************/
diff --git a/hw/i386/q35-acpi-dsdt.dsl b/hw/i386/q35-acpi-dsdt.dsl
index 0511e26..e57adb8 100644
--- a/hw/i386/q35-acpi-dsdt.dsl
+++ b/hw/i386/q35-acpi-dsdt.dsl
@@ -115,9 +115,6 @@  DefinitionBlock (
         }
     }
 
-#include "acpi-dsdt-hpet.dsl"
-
-
 /****************************************************************
  * LPC ISA bridge
  ****************************************************************/
diff --git a/hw/timer/hpet.c b/hw/timer/hpet.c
index 7f0391c..d9d039b 100644
--- a/hw/timer/hpet.c
+++ b/hw/timer/hpet.c
@@ -713,7 +713,7 @@  static void hpet_init(Object *obj)
     HPETState *s = HPET(obj);
 
     /* HPET Area */
-    memory_region_init_io(&s->iomem, obj, &hpet_ram_ops, s, "hpet", 0x400);
+    memory_region_init_io(&s->iomem, obj, &hpet_ram_ops, s, "hpet", HPET_LEN);
     sysbus_init_mmio(sbd, &s->iomem);
 }
 
diff --git a/include/hw/timer/hpet.h b/include/hw/timer/hpet.h
index d872909..f38bcfe 100644
--- a/include/hw/timer/hpet.h
+++ b/include/hw/timer/hpet.h
@@ -16,6 +16,7 @@ 
 #include "qom/object.h"
 
 #define HPET_BASE               0xfed00000
+#define HPET_LEN                0x400
 #define HPET_CLK_PERIOD         10 /* 10 ns*/
 
 #define FS_PER_NS 1000000       /* 1000000 femtoseconds == 1 ns */