On 10/29/2015 09:27 AM, Shannon Zhao wrote: > Add power button device in ACPI DSDT table. > > Signed-off-by: Shannon Zhao <zhaoshengl...@huawei.com> > Signed-off-by: Shannon Zhao <shannon.z...@linaro.org> > --- > hw/arm/virt-acpi-build.c | 13 +++++++++++++ > 1 file changed, 13 insertions(+) > > diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c > index ffb9b91..80ce51c 100644 > --- a/hw/arm/virt-acpi-build.c > +++ b/hw/arm/virt-acpi-build.c > @@ -339,6 +339,18 @@ static void acpi_dsdt_add_gpio(Aml *scope, const > MemMapEntry *gpio_memmap, > aml_append(scope, dev); > } > > +static void acpi_dsdt_add_power_button(Aml *scope) > +{ > + Aml *dev = aml_device("PWRB"); > + aml_append(dev, aml_name_decl("_HID", aml_string("PNP0C0C"))); > + aml_append(dev, aml_name_decl("_ADR", aml_int(0))); > + aml_append(dev, aml_name_decl("_UID", aml_int(0))); > + Aml *method = aml_method("_STA", 0); > + aml_append(method, aml_return(aml_int(0x0F)));
_STA returns 0x0F means PWRB is a functional device; that is good for OSPM. Plus I have tested the whole thing using ACPI-enabled guest VM; that means PWRB was probed correctly. So, Reviewed-by: Wei Huang <w...@redhat.com> > + aml_append(dev, method); > + aml_append(scope, dev); > +} > + > /* RSDP */ > static GArray * > build_rsdp(GArray *rsdp_table, GArray *linker, unsigned rsdt) > @@ -553,6 +565,7 @@ build_dsdt(GArray *table_data, GArray *linker, > VirtGuestInfo *guest_info) > guest_info->use_highmem); > acpi_dsdt_add_gpio(scope, &memmap[VIRT_GPIO], > (irqmap[VIRT_GPIO] + ARM_SPI_BASE)); > + acpi_dsdt_add_power_button(scope); > > aml_append(dsdt, scope); > >