ACPI: On the road to cleaning ;)
authorErwan Velu <erwanaliasr1@gmail.com>
Tue, 25 Jan 2011 19:38:39 +0000 (20:38 +0100)
committerErwan Velu <erwanaliasr1@gmail.com>
Tue, 25 Jan 2011 19:38:39 +0000 (20:38 +0100)
20 files changed:
com32/gplinclude/acpi/dsdt.h
com32/gplinclude/acpi/ecdt.h
com32/gplinclude/acpi/facs.h
com32/gplinclude/acpi/fadt.h
com32/gplinclude/acpi/madt.h
com32/gplinclude/acpi/rsdp.h
com32/gplinclude/acpi/rsdt.h
com32/gplinclude/acpi/sbst.h
com32/gplinclude/acpi/ssdt.h
com32/gplinclude/acpi/xsdt.h
com32/gpllib/acpi/dsdt.c
com32/gpllib/acpi/ecdt.c
com32/gpllib/acpi/facs.c
com32/gpllib/acpi/fadt.c
com32/gpllib/acpi/madt.c
com32/gpllib/acpi/rsdp.c
com32/gpllib/acpi/rsdt.c
com32/gpllib/acpi/sbst.c
com32/gpllib/acpi/xsdt.c
com32/hdt/hdt-cli-acpi.c

index fcb6280..a90b5ad 100644 (file)
@@ -18,7 +18,7 @@
 #define DSDT "DSDT"
 
 typedef struct {
-    uint64_t address;
+    uint8_t *address;
     s_acpi_description_header header;
     uint8_t *definition_block;
     bool valid;
index 0f8f3ca..e2a486a 100644 (file)
@@ -21,7 +21,7 @@
 #define EC_ID_OFFSET 65
 
 typedef struct {
-    uint64_t address;
+    uint8_t *address;
     s_acpi_description_header header;
     bool valid;
     uint32_t warning_energy_level;
index 4435eab..0601f1f 100644 (file)
@@ -25,7 +25,7 @@
 #define OWNED 1<<1
 
 typedef struct {
-    uint64_t address;
+    uint8_t *address;
     uint8_t signature[4+1];
     uint8_t length;
     uint32_t hardware_signature;
index 16ee0fa..e71f255 100644 (file)
@@ -61,11 +61,11 @@ enum { PM_UNSPECIFIED = 0,
 #define FORCE_APIC_PHYSICAL_DESTINATION_MODE 1<<19
 
 typedef struct {
-    uint64_t address;
+    uint8_t *address;
     s_acpi_description_header header;
     bool valid;
-    uint32_t firmware_ctrl;
-    uint32_t dsdt_address;
+    uint8_t *firmware_ctrl;
+    uint8_t *dsdt_address;
     uint8_t reserved;
     uint8_t prefered_pm_profile;
     uint16_t sci_int;
@@ -105,8 +105,8 @@ typedef struct {
     s_gas reset_reg;
     uint8_t reset_value;
     uint8_t reserved_3[3];
-    uint64_t x_firmware_ctrl;
-    uint64_t x_dsdt;
+    uint8_t *x_firmware_ctrl;
+    uint8_t *x_dsdt;
     s_gas x_pm1a_evt_blk;
     s_gas x_pm1b_evt_blk;
     s_gas x_pm1a_cnt_blk;
index d918a2f..39c25a7 100644 (file)
@@ -129,7 +129,7 @@ typedef struct {
 } __attribute__ ((packed)) s_local_sapic;
 
 typedef struct {
-    uint64_t address;
+    uint8_t *address;
     s_acpi_description_header header;
     uint32_t local_apic_address;
     uint32_t flags;
index 1d8126c..ea6804f 100644 (file)
 enum { RSDP_TABLE_FOUND };
 
 typedef struct {
-    uint64_t address;
+    uint8_t *address;
     uint8_t signature[8 + 1];
     uint8_t checksum;
     uint8_t oem_id[6 + 1];
     uint8_t revision;
-    uint32_t rsdt_address;
+    uint8_t *rsdt_address;
     uint32_t length;
-    uint32_t xsdt_address;
+    uint8_t *xsdt_address;
     uint8_t extended_checksum;
     bool valid;
 } s_rsdp;
index c3c198c..2c9b9e4 100644 (file)
@@ -20,9 +20,9 @@ enum { RSDT_TABLE_FOUND };
 #define RSDT "RSDT"
 
 typedef struct {
-    uint32_t address;
+    uint8_t *address;
     s_acpi_description_header header;
-    uint32_t entry[255];
+    uint8_t *entry[255];
     uint8_t entry_count;
     bool valid;
 } s_rsdt;
index 6e3aa10..4ae785b 100644 (file)
@@ -18,7 +18,7 @@
 #define SBST "SBST"
 
 typedef struct {
-    uint64_t address;
+    uint8_t *address;
     s_acpi_description_header header;
     bool valid;
     uint32_t warning_energy_level;
index 1ace366..93eb020 100644 (file)
@@ -19,7 +19,7 @@
 #define PSDT "PSDT"
 
 typedef struct {
-    uint64_t address;
+    uint8_t *address;
     s_acpi_description_header header;
     uint8_t *definition_block;
     bool valid;
index a87e2a0..4d4ca0c 100644 (file)
@@ -20,9 +20,9 @@ enum { XSDT_TABLE_FOUND };
 #define XSDT "XSDT"
 
 typedef struct {
-    uint32_t address;
+    uint8_t *address;
     s_acpi_description_header header;
-    uint64_t entry[255];
+    uint8_t *entry[255];
     uint8_t entry_count;
     bool valid;
 } s_xsdt;
index fbc1e2a..7117422 100644 (file)
 void parse_dsdt(s_dsdt * d)
 {
     uint8_t *q;
-    q = (uint64_t *) (d->address+ACPI_HEADER_SIZE);
+    q = (d->address+ACPI_HEADER_SIZE);
 
     /* Searching how much definition blocks we must copy */
     uint32_t definition_block_size=d->header.length-ACPI_HEADER_SIZE;
     if ((d->definition_block=malloc(definition_block_size)) != NULL) {
-       memcpy(d->definition_block,(uint64_t *)(d->address+ACPI_HEADER_SIZE),definition_block_size);
+       memcpy(d->definition_block,(d->address+ACPI_HEADER_SIZE),definition_block_size);
     }
 
 }
index 5cbdd60..41f92e3 100644 (file)
 #include <stdio.h>
 #include <string.h>
 #include <memory.h>
+#include <stdlib.h>
 #include <dprintf.h>
 #include "acpi/acpi.h"
 
 void parse_ecdt(s_ecdt * e)
 {
     uint8_t *q;
-    q = (uint64_t *) (e->address + ACPI_HEADER_SIZE);
+    q = (e->address + ACPI_HEADER_SIZE);
 
     /* Copying remaining structs */
     cp_struct(&e->ec_control);
index 0fc0b6b..3cb5637 100644 (file)
@@ -35,7 +35,7 @@
 void parse_facs(s_facs * f)
 {
     uint8_t *q;
-    q = (uint64_t *) (f->address + ACPI_HEADER_SIZE);
+    q = (f->address + ACPI_HEADER_SIZE);
     if (memcmp(q, FACS, sizeof(FACS) - 1) == 0) {
        f->valid = true;
        cp_str_struct(f->signature);
index 935d208..fafc524 100644 (file)
@@ -41,7 +41,7 @@ void parse_fadt(s_fadt * f)
     memcpy(f->header.signature,FADT,sizeof(FADT));
     
     /* Copying remaining structs */
-    q = (uint64_t *) (f->address+ACPI_HEADER_SIZE);
+    q = (f->address+ACPI_HEADER_SIZE);
     cp_struct(&f->firmware_ctrl);
     cp_struct(&f->dsdt_address);
     cp_struct(&f->reserved);
index c3b7ec5..fa5772a 100644 (file)
@@ -30,6 +30,7 @@
 #include <string.h>
 #include <memory.h>
 #include <dprintf.h>
+#include <stdlib.h>
 #include "acpi/acpi.h"
 
 /* Parse the apic structures */
@@ -156,7 +157,7 @@ void parse_madt(s_acpi * acpi)
     memcpy(m->header.signature, MADT, sizeof(MADT));
 
     /* Copying remaining structs */
-    q = (uint8_t *) (m->address + ACPI_HEADER_SIZE);
+    q = (m->address + ACPI_HEADER_SIZE);
 
     cp_struct(&m->local_apic_address);
     cp_struct(&m->flags);
index 0199cc3..d81ab2c 100644 (file)
 int search_rsdp(s_acpi * acpi)
 {
     /* Let's seach for RSDT table */
-    uint8_t *p, *q;
+    uint8_t *q;
 
     /* Let's start for the base address */
-    p = (uint64_t *) RSDP_MIN_ADDRESS;
-    for (q = p; q < RSDP_MAX_ADDRESS; q += 16) {
+    for (q = (uint8_t *)RSDP_MIN_ADDRESS; q < (uint8_t *)RSDP_MAX_ADDRESS; q+=16 ) {
        /* Searching for RSDP with "RSD PTR" signature */
        if (memcmp(q, RSDP, sizeof(RSDP)-1) == 0) {
            s_rsdp *r = &acpi->rsdp;
            r->valid = true;
-           r->address = (uint64_t) q;
+           r->address = q;
            cp_str_struct(r->signature);
            cp_struct(&r->checksum);
            cp_str_struct(r->oem_id);
@@ -68,13 +67,13 @@ void print_rsdp(s_acpi * acpi)
 
     if (!r->valid)
        return;
-    printf("RSDP Table @ 0x%016llx\n", r->address);
+    printf("RSDP Table @ 0x%p\n", r->address);
     printf(" signature         : %s\n", r->signature);
     printf(" checksum          : %u\n", r->checksum);
     printf(" oem id            : %s\n", r->oem_id);
     printf(" revision          : %u\n", r->revision);
-    printf(" RDST address      : 0x%08x\n", r->rsdt_address);
+    printf(" RDST address      : %p\n", r->rsdt_address);
     printf(" length            : %u\n", r->length);
-    printf(" XSDT address      : 0x%08x\n", r->xsdt_address);
+    printf(" XSDT address      : %p\n", r->xsdt_address);
     printf(" extended checksum : %u\n", r->extended_checksum);
 }
index cfba4d1..53398b2 100644 (file)
@@ -38,17 +38,17 @@ int parse_rsdt(s_rsdt *r)
     uint8_t *q;
 
     /* Let's start for the base address */
-    q = (uint32_t *) r->address;
+    q = r->address;
 
     /* Searching for MADT with APIC signature */
     if (memcmp(q, RSDT, sizeof(RSDT)-1) == 0) {
        r->valid = true;
        get_acpi_description_header(q, &r->header);
 
-       uint32_t *p = NULL;
-       for (p = (uint32_t *) (r->address + ACPI_HEADER_SIZE);
-            p < (uint32_t *) (r->address + r->header.length); p++) {
-           r->entry[r->entry_count] = (uint32_t) * p;
+       uint8_t *p = NULL;
+       for (p = (r->address + ACPI_HEADER_SIZE);
+            p < (r->address + r->header.length); p++) {
+           r->entry[r->entry_count] = p;
            r->entry_count++;
        }
        return RSDT_TABLE_FOUND;
index 6a41168..016b953 100644 (file)
@@ -35,7 +35,7 @@
 void parse_sbst(s_sbst * s)
 {
     uint8_t *q;
-    q = (uint64_t *) (s->address+ACPI_HEADER_SIZE);
+    q = (s->address+ACPI_HEADER_SIZE);
 
     /* Copying remaining structs */
     cp_struct(&s->warning_energy_level);
index ff222b0..d563593 100644 (file)
@@ -38,7 +38,7 @@ int parse_xsdt(s_acpi * acpi)
     uint8_t *q;
 
     /* Let's start for the base address */
-    q = (uint64_t *) acpi->xsdt.address;
+    q = acpi->xsdt.address;
 
     /* Searching for MADT with APIC signature */
     if (memcmp(q, XSDT, sizeof(XSDT) - 1) == 0) {
@@ -47,15 +47,15 @@ int parse_xsdt(s_acpi * acpi)
        get_acpi_description_header(q, &x->header);
 
        /* We now have a set of pointers to some tables */
-       uint64_t *p = NULL;
-       for (p = (uint64_t *) (x->address + ACPI_HEADER_SIZE);
-            p < (uint64_t *) (x->address + x->header.length); p++) {
+       uint8_t *p = NULL;
+       for (p = (x->address + ACPI_HEADER_SIZE);
+            p < (x->address + x->header.length); p++) {
            s_acpi_description_header adh;
            memset(&adh, 0, sizeof(adh));
-           x->entry[x->entry_count] = (uint64_t) * p;
+           x->entry[x->entry_count] = p;
 
            /* Let's grab the pointed table header */
-           get_acpi_description_header((uint8_t *) * p, &adh);
+           get_acpi_description_header(p, &adh);
 
            /* Trying to determine the pointed table */
            /* Looking for FADT */
@@ -65,7 +65,7 @@ int parse_xsdt(s_acpi * acpi)
                s_dsdt *d = &acpi->dsdt;
                /* This structure is valid, let's fill it */
                f->valid = true;
-               f->address = *p;
+               f->address = p;
                memcpy(&f->header, &adh, sizeof(adh));
                parse_fadt(f);
 
@@ -85,7 +85,7 @@ int parse_xsdt(s_acpi * acpi)
                 * FADT points to it, let's try to detect it */
                if (d->valid == false) {
                    s_acpi_description_header new_adh;
-                   get_acpi_description_header((uint8_t *) f->x_dsdt,
+                   get_acpi_description_header(f->x_dsdt,
                                                &new_adh);
                    if (memcmp(new_adh.signature, DSDT, sizeof(DSDT) - 1) == 0) {
                        d->valid = true;
@@ -94,7 +94,7 @@ int parse_xsdt(s_acpi * acpi)
                        parse_dsdt(d);
                    } else {
                        /* Let's try again */
-                       get_acpi_description_header((uint8_t *) f->dsdt_address,
+                       get_acpi_description_header(f->dsdt_address,
                                                    &new_adh);
                        if (memcmp(new_adh.signature, DSDT, sizeof(DSDT) - 1) ==
                            0) {
@@ -110,14 +110,14 @@ int parse_xsdt(s_acpi * acpi)
                s_madt *m = &acpi->madt;
                /* This structure is valid, let's fill it */
                m->valid = true;
-               m->address = *p;
+               m->address = p;
                memcpy(&m->header, &adh, sizeof(adh));
                parse_madt(acpi);
            } else if (memcmp(adh.signature, DSDT, sizeof(DSDT) - 1) == 0) {
                s_dsdt *d = &acpi->dsdt;
                /* This structure is valid, let's fill it */
                d->valid = true;
-               d->address = *p;
+               d->address = p;
                memcpy(&d->header, &adh, sizeof(adh));
                parse_dsdt(d);
                /* PSDT have to be considered as SSDT. Intel ACPI Spec @ 5.2.11.3 */
@@ -134,7 +134,7 @@ int parse_xsdt(s_acpi * acpi)
 
                /* This structure is valid, let's fill it */
                s->valid = true;
-               s->address = *p;
+               s->address = p;
                memcpy(&s->header, &adh, sizeof(adh));
 
                /* Searching how much definition blocks we must copy */
@@ -142,7 +142,7 @@ int parse_xsdt(s_acpi * acpi)
                if ((s->definition_block =
                     malloc(definition_block_size)) != NULL) {
                    memcpy(s->definition_block,
-                          (uint64_t *) (s->address + ACPI_HEADER_SIZE),
+                          (s->address + ACPI_HEADER_SIZE),
                           definition_block_size);
                }
                /* Increment the number of ssdt we have */
@@ -151,14 +151,14 @@ int parse_xsdt(s_acpi * acpi)
                s_sbst *s = &acpi->sbst;
                /* This structure is valid, let's fill it */
                s->valid = true;
-               s->address = *p;
+               s->address = p;
                memcpy(&s->header, &adh, sizeof(adh));
                parse_sbst(s);
            } else if (memcmp(adh.signature, ECDT, sizeof(ECDT) - 1) == 0) {
                s_ecdt *e = &acpi->ecdt;
                /* This structure is valid, let's fill it */
                e->valid = true;
-               e->address = *p;
+               e->address = p;
                memcpy(&e->header, &adh, sizeof(adh));
                parse_ecdt(e);
            }
index 7f4a380..17ec306 100644 (file)
 #include <errno.h>
 #include <acpi/acpi.h>
 
-/* Print ACPI's table header in a defined formating
- * this particular version is made for displaying 32bit addresses*/
-static void show_header_32(uint32_t address, s_acpi_description_header * h)
-{
-    more_printf("%-4s v%03x %-6s %-7s 0x%08x %-4s    0x%08x @ 0x%016x\n",
-               h->signature, h->revision, h->oem_id, h->oem_table_id,
-               h->oem_revision, h->creator_id, h->creator_revision, address)
-}
-
 /* Print ACPI's table header in a defined formating */
-static void show_header(uint64_t address, s_acpi_description_header * h)
+static void show_header(uint8_t *address, s_acpi_description_header * h)
 {
-    more_printf("%-4s v%03x %-6s %-7s 0x%08x %-4s    0x%08x @ 0x%016llx\n",
+    more_printf("%-4s v%03x %-6s %-7s 0x%08x %-4s    0x%08x @ 0x%p\n",
                h->signature, h->revision, h->oem_id, h->oem_table_id,
                h->oem_revision, h->creator_id, h->creator_revision, address)
 }
 
 /* That's an helper to visualize columns*/
-void show_table_separator()
+static void show_table_separator(void)
 {
     more_printf
        ("----|----|------|--------|----------|-------|-----------|--------------------\n");
 }
 
 /* Display the main header before displaying the ACPI tables */
-void show_table_name()
+static void show_table_name(void)
 {
     more_printf
        ("ACPI rev  oem    table_id oem_rev    creator creat_rev  @ address \n");
@@ -84,16 +75,16 @@ void main_show_acpi(int argc __unused, char **argv __unused,
     if (hardware->acpi.rsdp.valid) {
        s_rsdp *r = &hardware->acpi.rsdp;
        more_printf
-           ("RSDP v%03x %-6s                                        @ 0x%016llx\n",
+           ("RSDP v%03x %-6s                                        @ %p\n",
             r->revision, r->oem_id, r->address);
     }
 
     if (hardware->acpi.rsdt.valid)
-       show_header_32(hardware->acpi.rsdt.address,
+       show_header(hardware->acpi.rsdt.address,
                       &hardware->acpi.rsdt.header);
 
     if (hardware->acpi.xsdt.valid)
-       show_header_32(hardware->acpi.xsdt.address,
+       show_header(hardware->acpi.xsdt.address,
                       &hardware->acpi.xsdt.header);
 
     if (hardware->acpi.fadt.valid)
@@ -122,7 +113,7 @@ void main_show_acpi(int argc __unused, char **argv __unused,
     if (hardware->acpi.facs.valid) {
        s_facs *fa = &hardware->acpi.facs;
        more_printf
-           ("FACS                                                     @ 0x%016llx\n",
+           ("FACS                                                     @ 0x%p\n",
             fa->address);
     }
 }