#endif
#ifndef GRUB_DSDT_TEST
+#include <grub/mm.h>
#include <grub/misc.h>
#include <grub/time.h>
#include <grub/cpu/io.h>
ptr += skip_name_string (ptr, end);
ptr++;
break;
+ case GRUB_ACPI_EXTOPCODE_EVENT_OP:
+ ptr++;
+ ptr += skip_name_string (ptr, end);
+ break;
case GRUB_ACPI_EXTOPCODE_OPERATION_REGION:
ptr++;
ptr += skip_name_string (ptr, end);
return 0;
break;
case GRUB_ACPI_EXTOPCODE_FIELD_OP:
+ case GRUB_ACPI_EXTOPCODE_DEVICE_OP:
+ case GRUB_ACPI_EXTOPCODE_PROCESSOR_OP:
+ case GRUB_ACPI_EXTOPCODE_POWER_RES_OP:
+ case GRUB_ACPI_EXTOPCODE_THERMAL_ZONE_OP:
case GRUB_ACPI_EXTOPCODE_INDEX_FIELD_OP:
+ case GRUB_ACPI_EXTOPCODE_BANK_FIELD_OP:
ptr++;
ptr += decode_length (ptr, 0);
break;
}
static int
-get_sleep_type (grub_uint8_t *table, grub_uint8_t *end)
+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 *ptr, *prev = table;
- int sleep_type = -1;
+ grub_uint8_t *prev = table;
+ int sleep_type = -2;
- ptr = table + sizeof (struct grub_acpi_table_header);
+ if (!ptr)
+ ptr = table + sizeof (struct grub_acpi_table_header);
while (ptr < end && prev < ptr)
{
int add;
}
case GRUB_ACPI_OPCODE_NAME:
ptr++;
- if (memcmp (ptr, "_S5_", 4) == 0 || memcmp (ptr, "\\_S5_", 4) == 0)
+ if ((!scope || memcmp (scope, "\\", scope_len) == 0) &&
+ (memcmp (ptr, "_S5_", 4) == 0 || memcmp (ptr, "\\_S5_", 4) == 0))
{
int ll;
grub_uint8_t *ptr2 = ptr;
return -1;
break;
case GRUB_ACPI_OPCODE_SCOPE:
+ {
+ int scope_sleep_type;
+ int ll;
+ grub_uint8_t *name;
+ int name_len;
+
+ ptr++;
+ add = decode_length (ptr, &ll);
+ name = ptr + ll;
+ name_len = skip_name_string (name, ptr + add);
+ if (!name_len)
+ return -1;
+ scope_sleep_type = get_sleep_type (table, name + name_len,
+ ptr + add, name, name_len);
+ if (scope_sleep_type != -2)
+ return scope_sleep_type;
+ ptr += add;
+ break;
+ }
case GRUB_ACPI_OPCODE_IF:
case GRUB_ACPI_OPCODE_METHOD:
{
return 2;
}
- printf ("Sleep type = %d\n", get_sleep_type (buf, buf + len));
+ printf ("Sleep type = %d\n", get_sleep_type (buf, NULL, buf + len, NULL, 0));
free (buf);
fclose (f);
return 0;
{
struct grub_acpi_rsdp_v20 *rsdp2;
struct grub_acpi_rsdp_v10 *rsdp1;
- struct grub_acpi_table_header *rsdt;
- grub_uint32_t *entry_ptr;
+ struct grub_acpi_table_header *rsdt;
+ grub_uint32_t *entry_ptr;
+ grub_uint32_t port = 0;
+ int sleep_type = -1;
rsdp2 = grub_acpi_get_rsdpv2 ();
if (rsdp2)
{
if (grub_memcmp ((void *) (grub_addr_t) *entry_ptr, "FACP", 4) == 0)
{
- grub_uint32_t port;
struct grub_acpi_fadt *fadt
= ((struct grub_acpi_fadt *) (grub_addr_t) *entry_ptr);
struct grub_acpi_table_header *dsdt
= (struct grub_acpi_table_header *) (grub_addr_t) fadt->dsdt_addr;
- int sleep_type = -1;
+ grub_uint8_t *buf = (grub_uint8_t *) dsdt;
port = fadt->pm1a;
grub_dprintf ("acpi", "PM1a port=%x\n", port);
if (grub_memcmp (dsdt->signature, "DSDT",
- sizeof (dsdt->signature)) != 0)
- break;
+ sizeof (dsdt->signature)) == 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)
+ {
+ struct grub_acpi_table_header *ssdt
+ = (struct grub_acpi_table_header *) (grub_addr_t) *entry_ptr;
+ grub_uint8_t *buf = (grub_uint8_t *) ssdt;
- sleep_type = get_sleep_type ((grub_uint8_t *) dsdt,
- (grub_uint8_t *) dsdt + dsdt->length);
+ grub_dprintf ("acpi", "SSDT = %p\n", ssdt);
- if (sleep_type < 0 || sleep_type >= 8)
- break;
+ sleep_type = get_sleep_type (buf, NULL, buf + ssdt->length, NULL, 0);
+ }
+ }
- 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);