[PATCH] acpi: add in a tool to dump GPE information (LP: #1283473)
Colin Ian King
colin.king at canonical.com
Wed Feb 26 09:36:44 UTC 2014
On 26/02/14 06:28, IvanHu wrote:
> On 02/23/2014 12:50 AM, Colin King wrote:
>> From: Colin Ian King <colin.king at canonical.com>
>>
>> It can be useful to be able to extract the internal GPE configuration
>> from ACPICA and dump it out.
>>
>> Signed-off-by: Colin Ian King <colin.king at canonical.com>
>> ---
>> src/Makefile.am | 1 +
>> src/acpi/gpedump/gpedump.c | 181
>> +++++++++++++++++++++++++++++++++++++++++++++
>> 2 files changed, 182 insertions(+)
>> create mode 100644 src/acpi/gpedump/gpedump.c
>>
>> diff --git a/src/Makefile.am b/src/Makefile.am
>> index d3c1f45..155cba1 100644
>> --- a/src/Makefile.am
>> +++ b/src/Makefile.am
>> @@ -37,6 +37,7 @@ fwts_SOURCES = main.c \
>> acpi/dmar/dmar.c \
>> acpi/fadt/fadt.c \
>> acpi/fan/fan.c \
>> + acpi/gpedump/gpedump.c \
>> acpi/lid/lid.c \
>> acpi/mcfg/mcfg.c \
>> acpi/method/method.c \
>> diff --git a/src/acpi/gpedump/gpedump.c b/src/acpi/gpedump/gpedump.c
>> new file mode 100644
>> index 0000000..45404f4
>> --- /dev/null
>> +++ b/src/acpi/gpedump/gpedump.c
>> @@ -0,0 +1,181 @@
>> +/*
>> + * Copyright (C) 2014 Canonical
>> + *
>> + * This program is free software; you can redistribute it and/or
>> + * modify it under the terms of the GNU General Public License
>> + * as published by the Free Software Foundation; either version 2
>> + * of the License, or (at your option) any later version.
>> + *
>> + * This program is distributed in the hope that it will be useful,
>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
>> + * GNU General Public License for more details.
>> + *
>> + * You should have received a copy of the GNU General Public License
>> + * along with this program; if not, write to the Free Software
>> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
>> 02110-1301, USA.
>> + *
>> + */
>> +#include "fwts.h"
>> +#include <stdint.h>
>> +#include <stdbool.h>
>> +#include <unistd.h>
>
> build error for the gcc version 4.6.3,
> May need to add
> #include <inttypes.h>
>
> acpi/gpedump/gpedump.c: In function ‘gpu_dump_gpes’:
> acpi/gpedump/gpedump.c:85:43: error: expected ‘)’ before ‘PRIu32’
> acpi/gpedump/gpedump.c:85:43: error: spurious trailing ‘%’ in format
> [-Werror=format]
> acpi/gpedump/gpedump.c:85:43: error: spurious trailing ‘%’ in format
> [-Werror=format]
> acpi/gpedump/gpedump.c:88:3: error: expected ‘)’ before ‘PRIx8’
> acpi/gpedump/gpedump.c:88:3: error: conversion lacks type at end of
> format [-Werror=format]
> acpi/gpedump/gpedump.c:90:3: error: expected ‘)’ before ‘PRIx8’
> acpi/gpedump/gpedump.c:90:3: error: conversion lacks type at end of
> format [-Werror=format]
> acpi/gpedump/gpedump.c: In function ‘gpedump_block’:
> acpi/gpedump/gpedump.c:117:2: error: expected ‘)’ before ‘PRIu32’
> acpi/gpedump/gpedump.c:117:2: error: spurious trailing ‘%’ in format
> [-Werror=format]
> acpi/gpedump/gpedump.c:123:2: error: expected ‘)’ before ‘PRIx8’
> acpi/gpedump/gpedump.c:123:2: error: conversion lacks type at end of
> format [-Werror=format]
> acpi/gpedump/gpedump.c:127:2: error: expected ‘)’ before ‘PRIu32’
> acpi/gpedump/gpedump.c:127:2: error: spurious trailing ‘%’ in format
> [-Werror=format]
> acpi/gpedump/gpedump.c:135:3: error: expected ‘)’ before ‘PRIu32’
> acpi/gpedump/gpedump.c:135:3: error: spurious trailing ‘%’ in format
> [-Werror=format]
> acpi/gpedump/gpedump.c:140:3: error: expected ‘)’ before ‘PRIx8’
> acpi/gpedump/gpedump.c:140:3: error: conversion lacks type at end of
> format [-Werror=format]
> acpi/gpedump/gpedump.c:142:3: error: expected ‘)’ before ‘PRIx8’
> acpi/gpedump/gpedump.c:142:3: error: conversion lacks type at end of
> format [-Werror=format]
> acpi/gpedump/gpedump.c:144:3: error: expected ‘)’ before ‘PRIx64’
> acpi/gpedump/gpedump.c:144:3: error: conversion lacks type at end of
> format [-Werror=format]
> acpi/gpedump/gpedump.c:146:3: error: expected ‘)’ before ‘PRIx64’
> acpi/gpedump/gpedump.c:146:3: error: conversion lacks type at end of
> format [-Werror=format]
> acpi/gpedump/gpedump.c:132:27: error: unused variable ‘gpe_reg_info’
> [-Werror=unused-variable]
> acpi/gpedump/gpedump.c:100:23: error: unused parameter ‘gpe_xrupt_info’
> [-Werror=unused-parameter]
> acpi/gpedump/gpedump.c:102:11: error: unused parameter ‘block’
> [-Werror=unused-parameter]
> cc1: all warnings being treated as errors
> make[3]: *** [acpi/gpedump/fwts-gpedump.o] Error 1
> make[3]: Leaving directory `/home/work/fwts/src'
> make[2]: *** [all-recursive] Error 1
> make[2]: Leaving directory `/home/work/fwts/src'
> make[1]: *** [all-recursive] Error 1
> make[1]: Leaving directory `/home/work/fwts'
> make: *** [all] Error 2
>
>
>> +
>> +/* acpica headers */
>> +#include "acpi.h"
>> +#include "aclocal.h"
>> +#include "acobject.h"
>> +#include "acstruct.h"
>> +#include "acglobal.h"
>> +#include "fwts_acpi_object_eval.h"
>> +
>> +/*
>> + * gpedump_init()
>> + * initialize ACPI
>> + */
>> +static int gpedump_init(fwts_framework *fw)
>> +{
>> + if (fwts_acpi_init(fw) != FWTS_OK) {
>> + fwts_log_error(fw, "Cannot initialise ACPI.");
>> + return FWTS_ERROR;
>> + }
>> +
>> + return FWTS_OK;
>> +}
>> +
>> +/*
>> + * gpedump_deinit
>> + * de-intialize ACPI
>> + */
>> +static int gpedump_deinit(fwts_framework *fw)
>> +{
>> + return fwts_acpi_deinit(fw);
>> +}
>> +
>> +static void gpu_dump_gpes(
>> + fwts_framework *fw,
>> + uint32_t reg,
>> + ACPI_GPE_BLOCK_INFO *gpe_block_info)
>> +{
>> + uint32_t i, gpe = ACPI_GPE_REGISTER_WIDTH * reg;
>> +
>> + for (i = 0; i < ACPI_GPE_REGISTER_WIDTH; i++, gpe++) {
>> + char buf[80];
>> + uint32_t n;
>> + ACPI_GPE_NOTIFY_INFO *notify_info;
>> + ACPI_GPE_EVENT_INFO *GpeEventInfo =
>> &gpe_block_info->EventInfo[gpe];
>> +
>> + if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) ==
>> ACPI_GPE_DISPATCH_NONE)
>> + continue;
>> +
>> + switch (GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) {
>> + case ACPI_GPE_DISPATCH_NONE:
>> + strncpy(buf, "none", sizeof(buf));
>> + break;
>> + case ACPI_GPE_DISPATCH_HANDLER:
>> + strncpy(buf, "handler", sizeof(buf));
>> + break;
>> + case ACPI_GPE_DISPATCH_METHOD:
>> + strncpy(buf, "method", sizeof(buf));
>> + break;
>> + case ACPI_GPE_DISPATCH_NOTIFY:
>> + for (n = 0, notify_info =
>> GpeEventInfo->Dispatch.NotifyList; notify_info; notify_info =
>> notify_info->Next)
>> + n++;
>> + snprintf(buf, sizeof(buf), "notifes %" PRIu32 " devices",
>> n);
>> + break;
>> + }
>> + fwts_log_info_verbatum(fw, " GPE 0x%2.2" PRIx8 ":",
>> + gpe_block_info->BlockBaseNumber + gpe);
>> + fwts_log_info_verbatum(fw, " Flags: 0x%2.2" PRIx8 "
>> (trigger: %s, wake: %s)",
>> + GpeEventInfo->Flags,
>> + GpeEventInfo->Flags & ACPI_GPE_LEVEL_TRIGGERED ? "level"
>> : "edge",
>> + GpeEventInfo->Flags & ACPI_GPE_CAN_WAKE ? "can wake" :
>> "run only");
>> + fwts_log_info_verbatum(fw, " Dispatch: %s", buf);
>> + }
>> +}
>> +
>> +static void gpedump_block(
>> + fwts_framework *fw,
>> + ACPI_GPE_XRUPT_INFO *gpe_xrupt_info,
>> + ACPI_GPE_BLOCK_INFO *gpe_block_info,
>> + uint32_t block)
>> +{
>> + ACPI_BUFFER buffer;
>> + ACPI_STATUS Status;
>> + uint32_t reg;
>> + char name[128];
>> +
>> + buffer.Length = sizeof(name);
>> + buffer.Pointer = name;
>> +
>> + Status = AcpiGetName (gpe_block_info->Node, ACPI_FULL_PATHNAME,
>> &buffer);
>> + if (ACPI_FAILURE (Status))
>> + strncpy(name, "unknown", sizeof(name));
>> +
>> + fwts_log_nl(fw);
>> + fwts_log_info_verbatum(fw, "Block %" PRIu32": DeviceNode %s (%s)\n",
>> + block, name,
>> + gpe_block_info->Node == AcpiGbl_FadtGpeDevice ?
>> + "FADT Defined GPE Block" :
>> + "GPE Block Device");
>> +
>> + fwts_log_info_verbatum(fw, " GPE range: 0x%2.2" PRIx8 " to
>> 0x%2.2" PRIx8 " on interrupt %" PRIu32 "\n",
>> + (uint8_t)gpe_block_info->BlockBaseNumber,
>> + (uint8_t)gpe_block_info->BlockBaseNumber +
>> (gpe_block_info->GpeCount - 1),
>> + (uint32_t)gpe_xrupt_info->InterruptNumber);
>> + fwts_log_info_verbatum(fw, " GPE count: %" PRIu32 " (%" PRIu32 "
>> registers)\n",
>> + (uint32_t)gpe_block_info->GpeCount,
>> + (uint32_t)gpe_block_info->RegisterCount);
>> +
>> + for (reg = 0; reg < gpe_block_info->RegisterCount; reg++) {
>> + ACPI_GPE_REGISTER_INFO *gpe_reg_info =
>> &gpe_block_info->RegisterInfo[reg];
>> +
>> + fwts_log_nl(fw);
>> + fwts_log_info_verbatum(fw,
>> + " Register %" PRIu32 ": (GPE 0x%2.2" PRIx8 "-0x%2.2"
>> PRIx8 ")",
>> + reg,
>> + gpe_reg_info->BaseGpeNumber,
>> + gpe_reg_info->BaseGpeNumber + (ACPI_GPE_REGISTER_WIDTH -
>> 1));
>> + fwts_log_info_verbatum(fw, " Run Enable: 0x%2.2" PRIx8,
>> + gpe_reg_info->EnableForRun);
>> + fwts_log_info_verbatum(fw, " Wake Enable: 0x%2.2" PRIx8,
>> + gpe_reg_info->EnableForWake);
>> + fwts_log_info_verbatum(fw, " Status Address: 0x%8.8"
>> PRIx64,
>> + (uint64_t)gpe_reg_info->StatusAddress.Address);
>> + fwts_log_info_verbatum(fw, " Enable Address: 0x%8.8"
>> PRIx64,
>> + (uint64_t)gpe_reg_info->EnableAddress.Address);
>> +
>> + gpu_dump_gpes(fw, reg, gpe_block_info);
>> + }
>> +}
>> +
>> +static int gpedump_test1(fwts_framework *fw)
>> +{
>> + ACPI_GPE_BLOCK_INFO *gpe_block_info;
>> + ACPI_GPE_XRUPT_INFO *gpe_xrupt_info;
>> + uint32_t block = 0;
>> +
>> + gpe_xrupt_info = AcpiGbl_GpeXruptListHead;
>> +
>> + for (gpe_xrupt_info = AcpiGbl_GpeXruptListHead; gpe_xrupt_info;
>> gpe_xrupt_info = gpe_xrupt_info->Next) {
>> + for (gpe_block_info = gpe_xrupt_info->GpeBlockListHead;
>> gpe_block_info; gpe_block_info = gpe_block_info->Next) {
>> + gpedump_block(fw, gpe_xrupt_info, gpe_block_info, block);
>> + block++;
>> + }
>> + }
>> + return FWTS_OK;
>> +}
>> +
>> +static fwts_framework_minor_test gpedump_tests[] = {
>> + { gpedump_test1, "Dump GPEs." },
>> + { NULL, NULL }
>> +};
>> +
>> +static fwts_framework_ops gpedump_ops = {
>> + .description = "Dump GPEs.",
>> + .init = gpedump_init,
>> + .deinit = gpedump_deinit,
>> + .minor_tests = gpedump_tests
>> +};
>> +
>> +FWTS_REGISTER("gpedump", &gpedump_ops, FWTS_TEST_ANYTIME,
>> FWTS_FLAG_UTILS);
>>
>
> please also help to check why I got the exceptions on ACPICA, when run
> gpedump tool.
>
> gpedump: Dump GPEs.
> --------------------------------------------------------------------------------
>
> ACPICA Exception AE_NOT_EXIST during execution at module level (table load)
> ACPICA Exception AE_NOT_EXIST during execution at module level (table load)
> ACPICA Exception AE_NOT_EXIST during execution of method _STA
> ACPICA Exception AE_NOT_EXIST during execution of method _STA
> ACPICA Exception AE_NOT_EXIST during execution of method _STA
> ACPICA Exception AE_NOT_EXIST during execution of method _STA
> ACPICA Exception AE_NOT_EXIST during execution of method _STA
> ACPICA Exception AE_NOT_EXIST during execution of method _STA
> Test 1 of 1: Dump GPEs.
>
>
> Cheers,
> Ivan
>
>
>
Ivan, send me a copy of your ACPI tables and I will debug this
More information about the fwts-devel
mailing list