@@ -16,11 +16,6 @@
*/
/*
- * Each system port implementing ACPI has to provide two functions:
- *
- * write_acpi_tables()
- * acpi_dump_apics()
- *
* See Kontron 986LCD-M port for a good example of an ACPI implementation
* in coreboot.
*/
@@ -465,6 +460,101 @@ void acpi_write_rsdp(acpi_rsdp_t *rsdp, acpi_rsdt_t *rsdt, acpi_xsdt_t *xsdt)
rsdp->ext_checksum = acpi_checksum((void *)rsdp, sizeof(acpi_rsdp_t));
}
+
+
+void acpi_write_dsdt(acpi_header_t *dsdt, const unsigned char AmlCode[], unsigned long *current)
+{
+ *current = ALIGN(*current, 64);
+ printk(BIOS_DEBUG, "ACPI: * DSDT at %lx\n", *current);
+ dsdt = (acpi_header_t *) *current; // it will used by fadt
+ memcpy(dsdt, &AmlCode, sizeof(acpi_header_t));
+ *current += dsdt->length;
+ memcpy(dsdt, &AmlCode, dsdt->length);
+ printk(BIOS_DEBUG, "ACPI: * DSDT @ %p Length %x\n",dsdt,dsdt->length);
+}
+
+void acpi_write_facs(acpi_facs_t *facs, unsigned long *current)
+{
+ /* FACS */ // it needs 64 bit alignment
+ *current = ALIGN(*current, 64);
+ printk(BIOS_DEBUG, "ACPI: * FACS at %lx\n", *current);
+ facs = (acpi_facs_t *) *current; // it will be used by fadt
+ *current += sizeof(acpi_facs_t);
+ acpi_create_facs(facs);
+}
+
+
+void acpi_write_fadt(acpi_fadt_t *fadt, acpi_facs_t *facs, acpi_header_t *dsdt, acpi_rsdp_t *rsdp, unsigned long *current)
+{
+ *current = ALIGN(*current, 64);
+ printk(BIOS_DEBUG, "ACPI: * FADT at %lx\n", *current);
+ fadt = (acpi_fadt_t *) *current;
+ *current += sizeof(acpi_fadt_t);
+ acpi_create_fadt(fadt, facs, dsdt);
+ acpi_add_table(rsdp, fadt);
+}
+
+void acpi_write_hpet(acpi_hpet_t *hpet, acpi_rsdp_t *rsdp, unsigned long *current)
+{
+ *current = ALIGN(*current, 64);
+ printk(BIOS_DEBUG, "ACPI: * HPET at %lx\n", *current);
+ hpet = (acpi_hpet_t *) *current;
+ *current += sizeof(acpi_hpet_t);
+ acpi_create_hpet(hpet);
+ acpi_add_table(rsdp, hpet);
+}
+
+void acpi_write_madt(acpi_madt_t *madt, acpi_rsdp_t *rsdp, unsigned long *current)
+{
+ *current = ALIGN(*current, 64);
+ printk(BIOS_DEBUG, "ACPI: * MADT at %lx\n", *current);
+ madt = (acpi_madt_t *) *current;
+ acpi_create_madt(madt);
+ *current += madt->header.length;
+ acpi_add_table(rsdp, madt);
+}
+
+void acpi_write_srat(acpi_srat_t *srat, acpi_rsdp_t *rsdp, unsigned long *current)
+{
+ *current = ALIGN(*current, 64);
+ printk(BIOS_DEBUG, "ACPI: * SRAT at %lx\n", *current);
+ srat = (acpi_srat_t *) *current;
+ acpi_create_srat(srat);
+ *current += srat->header.length;
+ acpi_add_table(rsdp, srat);
+}
+
+void acpi_write_slit(acpi_slit_t *slit, acpi_rsdp_t *rsdp, unsigned long *current)
+{
+ *current = ALIGN(*current, 64);
+ printk(BIOS_DEBUG, "ACPI: * SLIT at %lx\n", *current);
+ slit = (acpi_slit_t *) *current;
+ acpi_create_slit(slit);
+ *current += slit->header.length;
+ acpi_add_table(rsdp, slit);
+}
+void acpi_write_mcfg(acpi_mcfg_t *mcfg, acpi_rsdp_t *rsdp, unsigned long *current)
+{
+ *current = ALIGN(*current, 64);
+ printk(BIOS_DEBUG, "ACPI: * MCFG at %lx\n", *current);
+ mcfg = (acpi_mcfg_t *) *current;
+ acpi_create_mcfg(mcfg);
+ current += mcfg->header.length;
+ acpi_add_table(rsdp, mcfg);
+}
+
+void acpi_write_ssdt_generated(acpi_header_t *ssdt, acpi_rsdp_t *rsdp, unsigned long *current)
+{
+ printk(BIOS_DEBUG, "ACPI: * SSDT\n");
+ ssdt = (acpi_header_t *)current;
+
+ acpi_create_ssdt_generator(ssdt, "DYNADATA");
+ current += ssdt->length;
+ acpi_add_table(rsdp, ssdt);
+
+}
+
+
#if CONFIG_HAVE_ACPI_RESUME == 1
void suspend_resume(void)
{
@@ -357,8 +357,9 @@ typedef struct acpi_ecdt {
u8 ec_id[]; /* EC ID */
} __attribute__ ((packed)) acpi_ecdt_t;
-/* These are implemented by the target port or north/southbridge. */
+/* This is implemented by the target port or north/southbridge. */
unsigned long write_acpi_tables(unsigned long addr);
+
unsigned long acpi_fill_madt(unsigned long current);
unsigned long acpi_fill_mcfg(unsigned long current);
unsigned long acpi_fill_srat(unsigned long current);
@@ -411,6 +412,15 @@ unsigned long acpi_create_slic(unsigned long current);
void acpi_write_rsdt(acpi_rsdt_t *rsdt);
void acpi_write_xsdt(acpi_xsdt_t *xsdt);
void acpi_write_rsdp(acpi_rsdp_t *rsdp, acpi_rsdt_t *rsdt, acpi_xsdt_t *xsdt);
+void acpi_write_dsdt(acpi_header_t *dsdt, const unsigned char AmlCode[], unsigned long *current);
+void acpi_write_facs(acpi_facs_t *facs, unsigned long *current);
+void acpi_write_fadt(acpi_fadt_t *fadt, acpi_facs_t *facs, acpi_header_t *dsdt, acpi_rsdp_t *rsdp, unsigned long *current);
+void acpi_write_hpet(acpi_hpet_t *hpet, acpi_rsdp_t *rsdp, unsigned long *current);
+void acpi_write_madt(acpi_madt_t *madt, acpi_rsdp_t *rsdp, unsigned long *current);
+void acpi_write_srat(acpi_srat_t *srat, acpi_rsdp_t *rsdp, unsigned long *current);
+void acpi_write_slit(acpi_slit_t *slit, acpi_rsdp_t *rsdp, unsigned long *current);
+void acpi_write_ssdt_generated(acpi_header_t *ssdt, acpi_rsdp_t *rsdp, unsigned long *current);
+void acpi_write_mcfg(acpi_mcfg_t *mcfg, acpi_rsdp_t *rsdp, unsigned long *current);
#if CONFIG_HAVE_ACPI_RESUME
/* 0 = S0, 1 = S1 ...*/
@@ -95,17 +95,17 @@ unsigned long acpi_fill_ssdt_generator(unsigned long current, const char *oem_ta
unsigned long write_acpi_tables(unsigned long start)
{
unsigned long current;
- acpi_rsdp_t *rsdp;
- acpi_srat_t *srat;
- acpi_rsdt_t *rsdt;
- acpi_mcfg_t *mcfg;
- acpi_hpet_t *hpet;
- acpi_madt_t *madt;
- acpi_fadt_t *fadt;
- acpi_facs_t *facs;
- acpi_slit_t *slit;
- acpi_header_t *ssdt;
- acpi_header_t *dsdt;
+ acpi_rsdp_t *rsdp = NULL;
+ acpi_srat_t *srat = NULL;
+ acpi_rsdt_t *rsdt = NULL;
+ acpi_mcfg_t *mcfg = NULL;
+ acpi_hpet_t *hpet = NULL;
+ acpi_madt_t *madt = NULL;
+ acpi_fadt_t *fadt = NULL;
+ acpi_facs_t *facs = NULL;
+ acpi_slit_t *slit = NULL;
+ acpi_header_t *ssdt = NULL;
+ acpi_header_t *dsdt = NULL;
/* Align ACPI tables to 16 byte. */
start = (start + 0x0f) & -0x10;
@@ -125,71 +125,20 @@ unsigned long write_acpi_tables(unsigned long start)
acpi_write_rsdp(rsdp, rsdt, NULL);
acpi_write_rsdt(rsdt);
- /* We explicitly add these tables later on: */
- printk(BIOS_DEBUG, "ACPI: * FACS\n");
-
- /* we should align FACS to 64B as per ACPI specs */
-
- current = ALIGN(current, 64);
- facs = (acpi_facs_t *) current;
- current += sizeof(acpi_facs_t);
- acpi_create_facs(facs);
-
- dsdt = (acpi_header_t *) current;
- memcpy(dsdt, &AmlCode, sizeof(acpi_header_t));
- current += dsdt->length;
- memcpy(dsdt, &AmlCode, dsdt->length);
- dsdt->checksum = 0; /* Don't trust iasl to get this right. */
- dsdt->checksum = acpi_checksum((u8*)dsdt, dsdt->length);
- printk(BIOS_DEBUG, "ACPI: * DSDT @ %p Length %x\n", dsdt,
- dsdt->length);
- printk(BIOS_DEBUG, "ACPI: * FADT\n");
-
- fadt = (acpi_fadt_t *) current;
- current += sizeof(acpi_fadt_t);
-
- acpi_create_fadt(fadt, facs, dsdt);
- acpi_add_table(rsdp, fadt);
-
- printk(BIOS_DEBUG, "ACPI: * HPET\n");
- hpet = (acpi_hpet_t *) current;
- current += sizeof(acpi_hpet_t);
- acpi_create_hpet(hpet);
- acpi_add_table(rsdp, hpet);
-
- /* If we want to use HPET timers Linux wants an MADT. */
- printk(BIOS_DEBUG, "ACPI: * MADT\n");
- madt = (acpi_madt_t *) current;
- acpi_create_madt(madt);
- current += madt->header.length;
- acpi_add_table(rsdp, madt);
-
- printk(BIOS_DEBUG, "ACPI: * MCFG\n");
- mcfg = (acpi_mcfg_t *) current;
- acpi_create_mcfg(mcfg);
- current += mcfg->header.length;
- acpi_add_table(rsdp, mcfg);
-
- printk(BIOS_DEBUG, "ACPI: * SRAT\n");
- srat = (acpi_srat_t *) current;
- acpi_create_srat(srat);
- current += srat->header.length;
- acpi_add_table(rsdp, srat);
-
- /* SLIT */
- printk(BIOS_DEBUG, "ACPI: * SLIT\n");
- slit = (acpi_slit_t *) current;
- acpi_create_slit(slit);
- current+=slit->header.length;
- acpi_add_table(rsdp,slit);
-
- /* SSDT */
- printk(BIOS_DEBUG, "ACPI: * SSDT\n");
- ssdt = (acpi_header_t *)current;
-
- acpi_create_ssdt_generator(ssdt, "DYNADATA");
- current += ssdt->length;
- acpi_add_table(rsdp, ssdt);
+ acpi_write_dsdt(dsdt, AmlCode , ¤t);
+ acpi_write_facs(facs, ¤t);
+ acpi_write_fadt(fadt, facs, dsdt, rsdp, ¤t);
+ acpi_write_hpet(hpet, rsdp, ¤t);
+
+ /* If we want to use HPET Timers Linux wants an MADT */
+ acpi_write_madt(madt, rsdp, ¤t);
+
+ acpi_write_mcfg(mcfg, rsdp, ¤t);
+
+ acpi_write_srat(srat, rsdp, ¤t);
+ acpi_write_slit(slit, rsdp, ¤t);
+
+ acpi_write_ssdt_generated(ssdt, rsdp, ¤t);
printk(BIOS_INFO, "ACPI: done.\n");
return current;