#define DSDT "DSDT"
typedef struct {
- uint64_t address;
+ uint8_t *address;
s_acpi_description_header header;
uint8_t *definition_block;
bool valid;
#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;
#define OWNED 1<<1
typedef struct {
- uint64_t address;
+ uint8_t *address;
uint8_t signature[4+1];
uint8_t length;
uint32_t hardware_signature;
#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;
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;
} __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;
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;
#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;
#define SBST "SBST"
typedef struct {
- uint64_t address;
+ uint8_t *address;
s_acpi_description_header header;
bool valid;
uint32_t warning_energy_level;
#define PSDT "PSDT"
typedef struct {
- uint64_t address;
+ uint8_t *address;
s_acpi_description_header header;
uint8_t *definition_block;
bool valid;
#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;
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);
}
}
#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);
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);
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);
#include <string.h>
#include <memory.h>
#include <dprintf.h>
+#include <stdlib.h>
#include "acpi/acpi.h"
/* Parse the apic structures */
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);
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);
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);
}
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;
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);
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) {
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 */
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);
* 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;
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) {
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 */
/* 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 */
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 */
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);
}
#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");
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)
if (hardware->acpi.facs.valid) {
s_facs *fa = &hardware->acpi.facs;
more_printf
- ("FACS @ 0x%016llx\n",
+ ("FACS @ 0x%p\n",
fa->address);
}
}