aboutsummaryrefslogtreecommitdiffstats
path: root/com32/gpllib
diff options
context:
space:
mode:
authorErwan Velu <erwanaliasr1@gmail.com>2011-01-26 22:14:20 +0100
committerErwan Velu <erwanaliasr1@gmail.com>2011-01-26 22:14:20 +0100
commitb1bb2511d86ae7350d82e3da1865621404d921f9 (patch)
treef469ab38159a0c2595de0f40d6f615b6b8202d19 /com32/gpllib
parenta91be03264cb2656ea4680bd87b3d886acbd5da9 (diff)
downloadsyslinux-b1bb2511d86ae7350d82e3da1865621404d921f9.tar.gz
syslinux-b1bb2511d86ae7350d82e3da1865621404d921f9.tar.xz
syslinux-b1bb2511d86ae7350d82e3da1865621404d921f9.zip
ACPI: Fixing pointer arithmetic
Several adjustements were necessary ;o)
Diffstat (limited to 'com32/gpllib')
-rw-r--r--com32/gpllib/acpi/acpi.c1
-rw-r--r--com32/gpllib/acpi/dsdt.c5
-rw-r--r--com32/gpllib/acpi/ecdt.c3
-rw-r--r--com32/gpllib/acpi/facs.c4
-rw-r--r--com32/gpllib/acpi/fadt.c5
-rw-r--r--com32/gpllib/acpi/madt.c12
-rw-r--r--com32/gpllib/acpi/sbst.c3
-rw-r--r--com32/gpllib/acpi/xsdt.c46
8 files changed, 50 insertions, 29 deletions
diff --git a/com32/gpllib/acpi/acpi.c b/com32/gpllib/acpi/acpi.c
index 2f8f7dad..d6b16906 100644
--- a/com32/gpllib/acpi/acpi.c
+++ b/com32/gpllib/acpi/acpi.c
@@ -73,4 +73,5 @@ void get_acpi_description_header(uint8_t * q, s_acpi_description_header * adh)
cp_struct(&adh->oem_revision);
cp_str_struct(adh->creator_id);
cp_struct(&adh->creator_revision);
+ DEBUG_PRINT(("acpi_header at %p = %s | %s | %s\n", q, adh->signature,adh->oem_id, adh->creator_id ));
}
diff --git a/com32/gpllib/acpi/dsdt.c b/com32/gpllib/acpi/dsdt.c
index 71174223..dbade359 100644
--- a/com32/gpllib/acpi/dsdt.c
+++ b/com32/gpllib/acpi/dsdt.c
@@ -36,12 +36,13 @@
void parse_dsdt(s_dsdt * d)
{
uint8_t *q;
- q = (d->address+ACPI_HEADER_SIZE);
+ q = (uint8_t *)d->address;
+ q += 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,(d->address+ACPI_HEADER_SIZE),definition_block_size);
+ memcpy(d->definition_block,q,definition_block_size);
}
}
diff --git a/com32/gpllib/acpi/ecdt.c b/com32/gpllib/acpi/ecdt.c
index 41f92e35..ecd42f7b 100644
--- a/com32/gpllib/acpi/ecdt.c
+++ b/com32/gpllib/acpi/ecdt.c
@@ -36,7 +36,8 @@
void parse_ecdt(s_ecdt * e)
{
uint8_t *q;
- q = (e->address + ACPI_HEADER_SIZE);
+ q = (uint8_t *)e->address;
+ q += ACPI_HEADER_SIZE;
/* Copying remaining structs */
cp_struct(&e->ec_control);
diff --git a/com32/gpllib/acpi/facs.c b/com32/gpllib/acpi/facs.c
index 3cb5637f..f3e95252 100644
--- a/com32/gpllib/acpi/facs.c
+++ b/com32/gpllib/acpi/facs.c
@@ -35,7 +35,9 @@
void parse_facs(s_facs * f)
{
uint8_t *q;
- q = (f->address + ACPI_HEADER_SIZE);
+ q = (uint8_t *) f->address;
+
+ DEBUG_PRINT(("Searching FACS at %p\n",q));
if (memcmp(q, FACS, sizeof(FACS) - 1) == 0) {
f->valid = true;
cp_str_struct(f->signature);
diff --git a/com32/gpllib/acpi/fadt.c b/com32/gpllib/acpi/fadt.c
index fafc524c..35cdb8e8 100644
--- a/com32/gpllib/acpi/fadt.c
+++ b/com32/gpllib/acpi/fadt.c
@@ -41,7 +41,10 @@ void parse_fadt(s_fadt * f)
memcpy(f->header.signature,FADT,sizeof(FADT));
/* Copying remaining structs */
- q = (f->address+ACPI_HEADER_SIZE);
+ q = (uint8_t *)f->address;
+ q += ACPI_HEADER_SIZE;
+ DEBUG_PRINT(("- Parsing FADT at %p\n",q));
+
cp_struct(&f->firmware_ctrl);
cp_struct(&f->dsdt_address);
cp_struct(&f->reserved);
diff --git a/com32/gpllib/acpi/madt.c b/com32/gpllib/acpi/madt.c
index fa5772a4..d93e4be2 100644
--- a/com32/gpllib/acpi/madt.c
+++ b/com32/gpllib/acpi/madt.c
@@ -140,7 +140,7 @@ static uint8_t *add_apic_structure(s_acpi * acpi, uint8_t * q)
madt->local_sapic_count++;
break;
default:
- printf("APIC structure type %u, size=%u \n", type, length);
+ printf("Unkown APIC structure type %u, size=%u \n", type, length);
q += length - 2;
break;
}
@@ -150,19 +150,23 @@ static uint8_t *add_apic_structure(s_acpi * acpi, uint8_t * q)
void parse_madt(s_acpi * acpi)
{
/* Let's seach for FADT table */
- uint8_t *q;
+ uint8_t *q, *max_address;
s_madt *m = &acpi->madt;
/* Fixing table name */
memcpy(m->header.signature, MADT, sizeof(MADT));
/* Copying remaining structs */
- q = (m->address + ACPI_HEADER_SIZE);
+ q = (uint8_t *)m->address;
+ q += ACPI_HEADER_SIZE;
+
+ max_address = (uint8_t *)m->address;
+ max_address += m->header.length;
cp_struct(&m->local_apic_address);
cp_struct(&m->flags);
- while (q < (m->address + m->header.length)) {
+ while (q < max_address) {
q = add_apic_structure(acpi, q);
}
}
diff --git a/com32/gpllib/acpi/sbst.c b/com32/gpllib/acpi/sbst.c
index 016b953c..036a5a9f 100644
--- a/com32/gpllib/acpi/sbst.c
+++ b/com32/gpllib/acpi/sbst.c
@@ -35,7 +35,8 @@
void parse_sbst(s_sbst * s)
{
uint8_t *q;
- q = (s->address+ACPI_HEADER_SIZE);
+ q = (uint8_t *)s->address;
+ q += ACPI_HEADER_SIZE;
/* Copying remaining structs */
cp_struct(&s->warning_energy_level);
diff --git a/com32/gpllib/acpi/xsdt.c b/com32/gpllib/acpi/xsdt.c
index 698874ab..3ccc5143 100644
--- a/com32/gpllib/acpi/xsdt.c
+++ b/com32/gpllib/acpi/xsdt.c
@@ -42,21 +42,28 @@ 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);
+ DEBUG_PRINT(("XSDT table found at %p : length=%d\n",x->address,x->header.length));
+ DEBUG_PRINT(("Expected Tables = %d\n",(x->header.length-ACPI_HEADER_SIZE)/8));
/* We now have a set of pointers to some tables */
- uint8_t *p = NULL;
- for (p = (x->address + ACPI_HEADER_SIZE);
- p < (x->address + x->header.length); p++) {
+ uint64_t *p = NULL;
+ for (p = ((uint64_t *)(x->address + ACPI_HEADER_SIZE));
+ p < ((uint64_t *)(x->address + x->header.length)); p++) {
+ DEBUG_PRINT((" Looking for HEADER at %p = %x\n",p,*p));
+
s_acpi_description_header adh;
memset(&adh, 0, sizeof(adh));
- x->entry[x->entry_count] = p;
/* Let's grab the pointed table header */
- get_acpi_description_header(p, &adh);
+ char address[16] = { 0 };
+ sprintf(address, "%llx", *p);
+ uint64_t *pointed_address = (uint64_t *)strtoul(address, NULL, 16);
+
+ x->entry[x->entry_count] = pointed_address;
+ get_acpi_description_header((uint8_t *)pointed_address, &adh);
/* Trying to determine the pointed table */
/* Looking for FADT */
@@ -67,18 +74,18 @@ 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 = pointed_address;
memcpy(&f->header, &adh, sizeof(adh));
parse_fadt(f);
/* FACS wasn't already detected
* FADT points to it, let's try to detect it */
if (fa->valid == false) {
- fa->address = f->x_firmware_ctrl;
+ fa->address = (uint64_t *)f->x_firmware_ctrl;
parse_facs(fa);
if (fa->valid == false) {
/* Let's try again */
- fa->address = f->firmware_ctrl;
+ fa->address = (uint64_t *)f->firmware_ctrl;
parse_facs(fa);
}
}
@@ -87,22 +94,23 @@ 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(f->x_dsdt,
+ get_acpi_description_header((uint8_t *)f->x_dsdt,
&new_adh);
if (memcmp(new_adh.signature, DSDT, sizeof(DSDT) - 1) == 0) {
- DEBUG_PRINT(("DSDT table found\n"));
+ DEBUG_PRINT(("DSDT table found via x_dsdt\n"));
d->valid = true;
- d->address = f->x_dsdt;
+ d->address = (uint64_t *)f->x_dsdt;
memcpy(&d->header, &new_adh, sizeof(new_adh));
parse_dsdt(d);
} else {
/* Let's try again */
- get_acpi_description_header(f->dsdt_address,
+ get_acpi_description_header((uint8_t *)f->dsdt_address,
&new_adh);
if (memcmp(new_adh.signature, DSDT, sizeof(DSDT) - 1) ==
0) {
+ DEBUG_PRINT(("DSDT table found via dsdt_address\n"));
d->valid = true;
- d->address = f->dsdt_address;
+ d->address = (uint64_t *)f->dsdt_address;
memcpy(&d->header, &new_adh, sizeof(new_adh));
parse_dsdt(d);
}
@@ -114,7 +122,7 @@ 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 = pointed_address;
memcpy(&m->header, &adh, sizeof(adh));
parse_madt(acpi);
} else if (memcmp(adh.signature, DSDT, sizeof(DSDT) - 1) == 0) {
@@ -122,7 +130,7 @@ int parse_xsdt(s_acpi * acpi)
s_dsdt *d = &acpi->dsdt;
/* This structure is valid, let's fill it */
d->valid = true;
- d->address = p;
+ d->address = pointed_address;
memcpy(&d->header, &adh, sizeof(adh));
parse_dsdt(d);
/* PSDT have to be considered as SSDT. Intel ACPI Spec @ 5.2.11.3 */
@@ -142,7 +150,7 @@ int parse_xsdt(s_acpi * acpi)
/* This structure is valid, let's fill it */
s->valid = true;
- s->address = p;
+ s->address = pointed_address;
memcpy(&s->header, &adh, sizeof(adh));
/* Searching how much definition blocks we must copy */
@@ -160,7 +168,7 @@ 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 = pointed_address;
memcpy(&s->header, &adh, sizeof(adh));
parse_sbst(s);
} else if (memcmp(adh.signature, ECDT, sizeof(ECDT) - 1) == 0) {
@@ -168,7 +176,7 @@ int parse_xsdt(s_acpi * acpi)
s_ecdt *e = &acpi->ecdt;
/* This structure is valid, let's fill it */
e->valid = true;
- e->address = p;
+ e->address = pointed_address;
memcpy(&e->header, &adh, sizeof(adh));
parse_ecdt(e);
}