From 463dcadca3ad69967db09af6858080db382eb8bb Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Wed, 22 Feb 2012 16:02:03 +0100 Subject: [PATCH] * include/grub/acpi.h (GRUB_ASCII_OPCODE): Add GRUB_ACPI_OPCODE_STRING_CONST, GRUB_ACPI_OPCODE_BUFFER, GRUB_ACPI_OPCODE_CREATE_WORD_FIELD and GRUB_ACPI_OPCODE_CREATE_BYTE_FIELD. * grub-core/commands/acpihalt.c [GRUB_DSDT_TEST]: Replace include of i18n with gettext no-op. (skip_data_ref_object): Support GRUB_ACPI_OPCODE_BUFFER and GRUB_ACPI_OPCODE_STRING_CONST. (get_sleep_type): Support GRUB_ACPI_OPCODE_CREATE_WORD_FIELD and GRUB_ACPI_OPCODE_CREATE_BYTE_FIELD. Add handling of unknown opcodes. --- ChangeLog | 13 +++++++++++++ grub-core/commands/acpihalt.c | 28 ++++++++++++++++++++++++++++ include/grub/acpi.h | 10 ++++++++-- 3 files changed, 49 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index aaf2bf7b2..2d2ee21ae 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2012-02-22 Vladimir Serbinenko + + * include/grub/acpi.h (GRUB_ASCII_OPCODE): Add + GRUB_ACPI_OPCODE_STRING_CONST, GRUB_ACPI_OPCODE_BUFFER, + GRUB_ACPI_OPCODE_CREATE_WORD_FIELD + and GRUB_ACPI_OPCODE_CREATE_BYTE_FIELD. + * grub-core/commands/acpihalt.c [GRUB_DSDT_TEST]: Replace include of + i18n with gettext no-op. + (skip_data_ref_object): Support GRUB_ACPI_OPCODE_BUFFER and + GRUB_ACPI_OPCODE_STRING_CONST. + (get_sleep_type): Support GRUB_ACPI_OPCODE_CREATE_WORD_FIELD and + GRUB_ACPI_OPCODE_CREATE_BYTE_FIELD. Add handling of unknown opcodes. + 2012-02-22 Vladimir Serbinenko * po/POTFILES.in: Regenerate. diff --git a/grub-core/commands/acpihalt.c b/grub-core/commands/acpihalt.c index 177ec15f0..66972d99b 100644 --- a/grub-core/commands/acpihalt.c +++ b/grub-core/commands/acpihalt.c @@ -33,7 +33,12 @@ typedef uint8_t grub_uint8_t; #endif #include +#ifndef GRUB_DSDT_TEST #include +#else +#define _(x) x +#define N_(x) x +#endif #ifndef GRUB_DSDT_TEST #include @@ -99,6 +104,7 @@ skip_data_ref_object (const grub_uint8_t *ptr, const grub_uint8_t *end) switch (*ptr) { case GRUB_ACPI_OPCODE_PACKAGE: + case GRUB_ACPI_OPCODE_BUFFER: return 1 + decode_length (ptr + 1, 0); case GRUB_ACPI_OPCODE_ZERO: case GRUB_ACPI_OPCODE_ONES: @@ -110,6 +116,14 @@ skip_data_ref_object (const grub_uint8_t *ptr, const grub_uint8_t *end) return 3; case GRUB_ACPI_OPCODE_DWORD_CONST: return 5; + case GRUB_ACPI_OPCODE_STRING_CONST: + { + const grub_uint8_t *ptr0 = ptr; + for (ptr++; ptr < end && *ptr; ptr++); + if (ptr == end) + return 0; + return ptr - ptr0 + 1; + } default: if (*ptr == '^' || *ptr == '\\' || *ptr == '_' || (*ptr >= 'A' && *ptr <= 'Z')) @@ -176,6 +190,17 @@ get_sleep_type (grub_uint8_t *table, grub_uint8_t *end) if (!add) return -1; break; + case GRUB_ACPI_OPCODE_CREATE_WORD_FIELD: + case GRUB_ACPI_OPCODE_CREATE_BYTE_FIELD: + { + int ll; + ptr += 5; + ptr += add = skip_data_ref_object (ptr, end); + if (!add) + return -1; + ptr += 4; + break; + } case GRUB_ACPI_OPCODE_NAME: ptr++; if (memcmp (ptr, "_S5_", 4) == 0 || memcmp (ptr, "\\_S5_", 4) == 0) @@ -224,6 +249,9 @@ get_sleep_type (grub_uint8_t *table, grub_uint8_t *end) ptr += decode_length (ptr, 0); break; } + default: + grub_printf ("Unknown opcode 0x%x\n", *ptr); + return -1; } } diff --git a/include/grub/acpi.h b/include/grub/acpi.h index c843a0621..ee0a108f1 100644 --- a/include/grub/acpi.h +++ b/include/grub/acpi.h @@ -160,9 +160,15 @@ enum { GRUB_ACPI_OPCODE_ZERO = 0, GRUB_ACPI_OPCODE_ONE = 1, GRUB_ACPI_OPCODE_NAME = 8, GRUB_ACPI_OPCODE_BYTE_CONST = 0x0a, - GRUB_ACPI_OPCODE_WORD_CONST = 0x0b, GRUB_ACPI_OPCODE_DWORD_CONST = 0x0c, - GRUB_ACPI_OPCODE_SCOPE = 0x10, GRUB_ACPI_OPCODE_PACKAGE = 0x12, + GRUB_ACPI_OPCODE_WORD_CONST = 0x0b, + GRUB_ACPI_OPCODE_DWORD_CONST = 0x0c, + GRUB_ACPI_OPCODE_STRING_CONST = 0x0d, + GRUB_ACPI_OPCODE_SCOPE = 0x10, + GRUB_ACPI_OPCODE_BUFFER = 0x11, + GRUB_ACPI_OPCODE_PACKAGE = 0x12, GRUB_ACPI_OPCODE_METHOD = 0x14, GRUB_ACPI_OPCODE_EXTOP = 0x5b, + GRUB_ACPI_OPCODE_CREATE_WORD_FIELD = 0x8b, + GRUB_ACPI_OPCODE_CREATE_BYTE_FIELD = 0x8c, GRUB_ACPI_OPCODE_IF = 0xa0, GRUB_ACPI_OPCODE_ONES = 0xff }; enum