summaryrefslogtreecommitdiff
path: root/src/arch/i386/boot/acpi.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/arch/i386/boot/acpi.c')
-rw-r--r--src/arch/i386/boot/acpi.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/arch/i386/boot/acpi.c b/src/arch/i386/boot/acpi.c
index 6afcd9c276..271de845de 100644
--- a/src/arch/i386/boot/acpi.c
+++ b/src/arch/i386/boot/acpi.c
@@ -26,7 +26,7 @@ static u8 acpi_checksum(u8 *table, u32 length)
ret += *table;
table++;
}
- return ret;
+ return -ret;
}
static void acpi_add_table(acpi_rsdt_t *rsdt, void *table)
@@ -42,7 +42,7 @@ static void acpi_add_table(acpi_rsdt_t *rsdt, void *table)
rsdt->header.checksum=acpi_checksum((u8 *)rsdt,
rsdt->header.length);
- printk_debug("ACPI: added table %d/8\n",i);
+ printk_debug("ACPI: added table %d/8\n",i+1);
return;
}
}
@@ -56,6 +56,8 @@ static void acpi_create_hpet(acpi_hpet_t *hpet)
acpi_header_t *header=&(hpet->header);
acpi_addr_t *addr=&(hpet->addr);
+ memset((void *)hpet, 0, sizeof(acpi_hpet_t));
+
/* fill out header fields */
memcpy(header->signature, HPET_NAME, 4);
memcpy(header->oem_id, OEM_ID, 6);
@@ -76,6 +78,7 @@ static void acpi_create_hpet(acpi_hpet_t *hpet)
hpet->number = 0;
hpet->min_tick = 4096;
+ header->checksum = acpi_checksum((void *)hpet, sizeof(acpi_hpet_t));
}
static void acpi_write_rsdt(acpi_rsdt_t *rsdt)
@@ -107,17 +110,22 @@ static void acpi_write_rsdp(acpi_rsdp_t *rsdp, acpi_rsdt_t *rsdt)
rsdp->length = sizeof(acpi_rsdp_t);
rsdp->rsdt_address = (u32)rsdt;
- rsdp->checksum = acpi_checksum((void *)rsdp, sizeof(acpi_rsdp_t));
+ rsdp->checksum = acpi_checksum((void *)rsdp, 20);
+ rsdp->ext_checksum = acpi_checksum((void *)rsdp, sizeof(acpi_rsdp_t));
}
unsigned long write_acpi_tables(unsigned long start)
{
- unsigned long current = start;
+ unsigned long current;
acpi_rsdp_t *rsdp;
acpi_rsdt_t *rsdt;
acpi_hpet_t *hpet;
+ /* Align ACPI tables to 16byte */
+ start = ( start + 0x0f ) & -0x10;
+ current = start;
+
printk_info("ACPI: Writing ACPI tables at %lx...\n", start);
/* We need at least an RSDP and an RSDT Table */
@@ -141,7 +149,6 @@ unsigned long write_acpi_tables(unsigned long start)
hpet = (acpi_hpet_t *) current;
current += sizeof(acpi_hpet_t);
-
acpi_create_hpet(hpet);
acpi_add_table(rsdt,hpet);
#endif