From: Kamala Narasimhan Date: Wed, 18 Feb 2009 21:08:50 +0000 (-0500) Subject: Sleep button support for guest. X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=d06d6210f2bc01e822a8b306a6aca0165b446083;p=xenclient%2Fioemu.git Sleep button support for guest. --- diff --git a/hw/pc.h b/hw/pc.h index a4ffc389..6c4a2fd6 100644 --- a/hw/pc.h +++ b/hw/pc.h @@ -104,6 +104,7 @@ void acpi_php_add(int); void acpi_php_del(int); void acpi_ac_adapter_state_changed(void); void acpi_power_button_pressed(void); +void acpi_sleep_button_pressed(void); void acpi_lid_state_changed(void); void acpi_oem_event(void); diff --git a/hw/piix4acpi.c b/hw/piix4acpi.c index c661fa65..e39a3497 100644 --- a/hw/piix4acpi.c +++ b/hw/piix4acpi.c @@ -56,6 +56,7 @@ #define ACPI_PHP_GPE_BIT 3 #define ACPI_AC_POWER_STATE_BIT 0x1c #define ACPI_POWER_BUTTON_BIT 0x1 +#define ACPI_SLEEP_BUTTON_BIT 0x0 #define ACPI_LID_STATE_BIT 0x17 #define ACPI_OEM_EVENT_BIT 0x18 #define ACPI_PHP_SLOT_NUM PHP_SLOT_LEN @@ -238,6 +239,18 @@ void acpi_power_button_pressed(void) } } +void acpi_sleep_button_pressed(void) +{ + GPEState *s = &gpe_state; + + if ( !test_bit(&s->gpe0_sts[0], ACPI_SLEEP_BUTTON_BIT) && + test_bit(&s->gpe0_en[0], ACPI_SLEEP_BUTTON_BIT) ) { + set_bit(&s->gpe0_sts[0], ACPI_SLEEP_BUTTON_BIT); + s->sci_asserted = 1; + qemu_irq_raise(sci_irq); + } +} + void acpi_lid_state_changed(void) { GPEState *s = &gpe_state; diff --git a/xenstore.c b/xenstore.c index 6b577b2b..b73c346b 100644 --- a/xenstore.c +++ b/xenstore.c @@ -861,6 +861,10 @@ void xenstore_process_event(void *opaque) goto out; } + if (!strcmp(vec[XS_WATCH_TOKEN], "slpbuttonpressedevt")) { + acpi_sleep_button_pressed(); + } + if (!strcmp(vec[XS_WATCH_TOKEN], "lidstatechangeevt")) { acpi_lid_state_changed(); goto out; @@ -1290,6 +1294,7 @@ void xenstore_register_for_pm_events(void) xs_watch(xsh, "/pm/events/acadapterstatechanged", "acadapterstatechangeevt"); xs_watch(xsh, "/pm/events/lidstatechanged", "lidstatechangeevt"); xs_watch(xsh, "/pm/events/powerbuttonpressed", "pwrbuttonpressedevt"); + xs_watch(xsh, "/pm/events/sleepbuttonpressed", "slpbuttonpressedevt"); } void xenstore_register_for_oem_events(void)