From 4fd42c53f333d7090936e4170e316a452ff242c2 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Thu, 30 May 2013 21:32:01 +0200 Subject: [PATCH] * grub-core/commands/acpihalt.c: Fix handling of DSDT in presence of SSDT. --- ChangeLog | 5 +++++ grub-core/commands/acpihalt.c | 31 +++++++++++++------------------ 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index e2e38f307..02bdf6fd2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2013-05-30 Vladimir Serbinenko + + * grub-core/commands/acpihalt.c: Fix handling of DSDT in presence of + SSDT. + 2013-05-15 Radosław Szymczyszyn * grub-core/partmap/dfly.c: New partition map. diff --git a/grub-core/commands/acpihalt.c b/grub-core/commands/acpihalt.c index 6f156fd05..a6c8db659 100644 --- a/grub-core/commands/acpihalt.c +++ b/grub-core/commands/acpihalt.c @@ -22,6 +22,7 @@ #include #include #include +#include #define grub_dprintf(cond, args...) printf ( args ) #define grub_printf printf @@ -184,7 +185,6 @@ get_sleep_type (grub_uint8_t *table, grub_uint8_t *ptr, grub_uint8_t *end, grub_uint8_t *scope, int scope_len) { grub_uint8_t *prev = table; - int sleep_type = -2; if (!ptr) ptr = table + sizeof (struct grub_acpi_table_header); @@ -233,14 +233,11 @@ get_sleep_type (grub_uint8_t *table, grub_uint8_t *ptr, grub_uint8_t *end, switch (*ptr2) { case GRUB_ACPI_OPCODE_ZERO: - sleep_type = 0; - break; + return 0; case GRUB_ACPI_OPCODE_ONE: - sleep_type = 1; - break; + return 1; case GRUB_ACPI_OPCODE_BYTE_CONST: - sleep_type = ptr2[1]; - break; + return ptr2[1]; default: grub_printf ("Unknown data type in _S5: 0x%x\n", *ptr2); return -1; @@ -286,8 +283,7 @@ get_sleep_type (grub_uint8_t *table, grub_uint8_t *ptr, grub_uint8_t *end, } } - grub_dprintf ("acpi", "TYP = %d\n", sleep_type); - return sleep_type; + return -2; } #ifdef GRUB_DSDT_TEST @@ -317,7 +313,7 @@ main (int argc, char **argv) } if (fread (buf, 1, len, f) != len) { - printf (_("cannot read `%s': %s"), strerror (errno)); + printf (_("cannot read `%s': %s"), argv[1], strerror (errno)); free (buf); fclose (f); return 2; @@ -369,11 +365,13 @@ grub_acpi_halt (void) grub_dprintf ("acpi", "PM1a port=%x\n", port); if (grub_memcmp (dsdt->signature, "DSDT", - sizeof (dsdt->signature)) == 0) + sizeof (dsdt->signature)) == 0 + && sleep_type < 0) sleep_type = get_sleep_type (buf, NULL, buf + dsdt->length, NULL, 0); } - else if (grub_memcmp ((void *) (grub_addr_t) *entry_ptr, "SSDT", 4) == 0) + else if (grub_memcmp ((void *) (grub_addr_t) *entry_ptr, "SSDT", 4) == 0 + && sleep_type < 0) { struct grub_acpi_table_header *ssdt = (struct grub_acpi_table_header *) (grub_addr_t) *entry_ptr; @@ -385,13 +383,10 @@ grub_acpi_halt (void) } } + grub_dprintf ("acpi", "SLP_TYP = %d, port = 0x%x\n", sleep_type, port); if (port && sleep_type >= 0 && sleep_type < 8) - { - grub_dprintf ("acpi", "SLP_TYP = %d, port = 0x%x\n", sleep_type, port); - - grub_outw (GRUB_ACPI_SLP_EN | (sleep_type << GRUB_ACPI_SLP_TYP_OFFSET), - port & 0xffff); - } + grub_outw (GRUB_ACPI_SLP_EN | (sleep_type << GRUB_ACPI_SLP_TYP_OFFSET), + port & 0xffff); grub_millisleep (1500);