Since some people disapprove of white space cleanups mixed in regular commits
[coreboot.git] / src / mainboard / via / epia-m / acpi_tables.c
1 /*
2  * coreboot ACPI Table support
3  * written by Stefan Reinauer <stepan@openbios.org>
4  * ACPI FADT, FACS, and DSDT table support added by
5  * Nick Barker <nick.barker9@btinternet.com>, and those portions
6  * (C) Copyright 2004 Nick Barker
7  * (C) Copyright 2005 Stefan Reinauer
8  */
9
10 #include <console/console.h>
11 #include <string.h>
12 #include <arch/acpi.h>
13
14 extern const unsigned char AmlCode[];
15
16 unsigned long acpi_fill_mcfg(unsigned long current)
17 {
18         /* Nothing to do */
19         return current;
20 }
21
22 unsigned long acpi_fill_slit(unsigned long current)
23 {
24         // Not implemented
25         return current;
26 }
27
28 unsigned long acpi_fill_madt(unsigned long current)
29 {
30         /* Nothing to do */
31         return current;
32 }
33
34 unsigned long acpi_fill_srat(unsigned long current)
35 {
36         /* No NUMA, no SRAT */
37         return current;
38 }
39
40 unsigned long write_acpi_tables(unsigned long start)
41 {
42         unsigned long current;
43         acpi_rsdp_t *rsdp;
44         acpi_rsdt_t *rsdt;
45         acpi_fadt_t *fadt;
46         acpi_facs_t *facs;
47         acpi_header_t *dsdt;
48
49         /* Align ACPI tables to 16byte */
50         start   = ( start + 0x0f ) & -0x10;
51         current = start;
52
53         printk(BIOS_INFO, "ACPI: Writing ACPI tables at %lx...\n", start);
54
55         /* We need at least an RSDP and an RSDT Table */
56         rsdp = (acpi_rsdp_t *) current;
57         current += sizeof(acpi_rsdp_t);
58         rsdt = (acpi_rsdt_t *) current;
59         current += sizeof(acpi_rsdt_t);
60
61         /* clear all table memory */
62         memset((void *)start, 0, current - start);
63
64         acpi_write_rsdp(rsdp, rsdt, NULL);
65         acpi_write_rsdt(rsdt);
66
67         /*
68          * We explicitly add these tables later on:
69          */
70         printk(BIOS_DEBUG, "ACPI:     * FACS\n");
71         facs = (acpi_facs_t *) current;
72         current += sizeof(acpi_facs_t);
73         acpi_create_facs(facs);
74
75         dsdt = (acpi_header_t *)current;
76         memcpy(dsdt, &AmlCode, sizeof(acpi_header_t));
77         current += dsdt->length;
78         memcpy(dsdt, &AmlCode, dsdt->length);
79         dsdt->checksum = 0; // don't trust intel iasl compiler to get this right
80         dsdt->checksum = acpi_checksum((u8*)dsdt, dsdt->length);
81         printk(BIOS_DEBUG, "ACPI:     * DSDT @ %p Length %x\n",dsdt,dsdt->length);
82         printk(BIOS_DEBUG, "ACPI:     * FADT\n");
83
84         fadt = (acpi_fadt_t *) current;
85         current += sizeof(acpi_fadt_t);
86
87         acpi_create_fadt(fadt,facs,dsdt);
88         acpi_add_table(rsdp,fadt);
89
90         printk(BIOS_INFO, "ACPI: done.\n");
91         return current;
92 }
93