From 37d0e16d87fb520921f7465dc11d2726f6d6f163 Mon Sep 17 00:00:00 2001 From: Erwan Velu Date: Tue, 25 Jan 2011 22:15:01 +0100 Subject: [PATCH] ACPI: Adding DEBUG_PRINT Adding a function to debug & print for ACPI. --- com32/gplinclude/acpi/acpi.h | 6 ++++++ com32/gpllib/acpi/acpi.c | 8 ++++++++ com32/gpllib/acpi/rsdt.c | 1 + com32/gpllib/acpi/xsdt.c | 10 ++++++++++ 4 files changed, 25 insertions(+) diff --git a/com32/gplinclude/acpi/acpi.h b/com32/gplinclude/acpi/acpi.h index 664306b..ed1bf9b 100644 --- a/com32/gplinclude/acpi/acpi.h +++ b/com32/gplinclude/acpi/acpi.h @@ -12,6 +12,12 @@ #ifndef ACPI_H #define ACPI_H + +#define DEBUG_ACPI 0 + +void dbg_printf(const char *fmt, ...); +#define DEBUG_PRINT(x) do { if (DEBUG_ACPI) dbg_printf x; } while (0) + #include #include #include diff --git a/com32/gpllib/acpi/acpi.c b/com32/gpllib/acpi/acpi.c index c5a76a9..2f8f7da 100644 --- a/com32/gpllib/acpi/acpi.c +++ b/com32/gpllib/acpi/acpi.c @@ -31,6 +31,14 @@ #include #include "acpi/acpi.h" +void dbg_printf(const char *fmt, ...) +{ + va_list args; + va_start(args, fmt); + vfprintf(stderr, fmt, args); + va_end(args); +} + void init_acpi(s_acpi * acpi) { memset(acpi, 0, sizeof(s_acpi)); diff --git a/com32/gpllib/acpi/rsdt.c b/com32/gpllib/acpi/rsdt.c index 53398b2..5391799 100644 --- a/com32/gpllib/acpi/rsdt.c +++ b/com32/gpllib/acpi/rsdt.c @@ -42,6 +42,7 @@ int parse_rsdt(s_rsdt *r) /* Searching for MADT with APIC signature */ if (memcmp(q, RSDT, sizeof(RSDT)-1) == 0) { + DEBUG_PRINT(("RSDT table found\n")); r->valid = true; get_acpi_description_header(q, &r->header); diff --git a/com32/gpllib/acpi/xsdt.c b/com32/gpllib/acpi/xsdt.c index 3e1b5ab..698874a 100644 --- a/com32/gpllib/acpi/xsdt.c +++ b/com32/gpllib/acpi/xsdt.c @@ -42,6 +42,7 @@ int parse_xsdt(s_acpi * acpi) /* Searching for MADT with APIC signature */ if (memcmp(q, XSDT, sizeof(XSDT) - 1) == 0) { + DEBUG_PRINT(("XSDT table found\n")); s_xsdt *x = &acpi->xsdt; x->valid = true; get_acpi_description_header(q, &x->header); @@ -60,6 +61,7 @@ int parse_xsdt(s_acpi * acpi) /* Trying to determine the pointed table */ /* Looking for FADT */ if (memcmp(adh.signature, FACP, sizeof(FACP) - 1) == 0) { + DEBUG_PRINT(("FACP table found\n")); s_fadt *f = &acpi->fadt; s_facs *fa = &acpi->facs; s_dsdt *d = &acpi->dsdt; @@ -88,6 +90,7 @@ int parse_xsdt(s_acpi * acpi) get_acpi_description_header(f->x_dsdt, &new_adh); if (memcmp(new_adh.signature, DSDT, sizeof(DSDT) - 1) == 0) { + DEBUG_PRINT(("DSDT table found\n")); d->valid = true; d->address = f->x_dsdt; memcpy(&d->header, &new_adh, sizeof(new_adh)); @@ -107,6 +110,7 @@ int parse_xsdt(s_acpi * acpi) } } /* Looking for MADT */ else if (memcmp(adh.signature, APIC, sizeof(APIC) - 1) == 0) { + DEBUG_PRINT(("MADT table found\n")); s_madt *m = &acpi->madt; /* This structure is valid, let's fill it */ m->valid = true; @@ -114,6 +118,7 @@ int parse_xsdt(s_acpi * acpi) memcpy(&m->header, &adh, sizeof(adh)); parse_madt(acpi); } else if (memcmp(adh.signature, DSDT, sizeof(DSDT) - 1) == 0) { + DEBUG_PRINT(("DSDT table found\n")); s_dsdt *d = &acpi->dsdt; /* This structure is valid, let's fill it */ d->valid = true; @@ -123,6 +128,9 @@ int parse_xsdt(s_acpi * acpi) /* PSDT have to be considered as SSDT. Intel ACPI Spec @ 5.2.11.3 */ } else if ((memcmp(adh.signature, SSDT, sizeof(SSDT) - 1) == 0) || (memcmp(adh.signature, PSDT, sizeof(PSDT) - 1) == 0)) { + + DEBUG_PRINT(("SSDT table found with %s \n",adh.signature)); + if ((acpi->ssdt_count >= MAX_SSDT - 1)) break; @@ -148,6 +156,7 @@ int parse_xsdt(s_acpi * acpi) /* Increment the number of ssdt we have */ acpi->ssdt_count++; } else if (memcmp(adh.signature, SBST, sizeof(SBST) - 1) == 0) { + DEBUG_PRINT(("SBST table found\n")); s_sbst *s = &acpi->sbst; /* This structure is valid, let's fill it */ s->valid = true; @@ -155,6 +164,7 @@ int parse_xsdt(s_acpi * acpi) memcpy(&s->header, &adh, sizeof(adh)); parse_sbst(s); } else if (memcmp(adh.signature, ECDT, sizeof(ECDT) - 1) == 0) { + DEBUG_PRINT(("ECDT table found\n")); s_ecdt *e = &acpi->ecdt; /* This structure is valid, let's fill it */ e->valid = true; -- 2.7.4