printk_foo -> printk(BIOS_FOO, ...)
[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 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_hpet_t *hpet;
46         acpi_madt_t *madt;
47         acpi_fadt_t *fadt;
48         acpi_facs_t *facs;
49         acpi_header_t *dsdt;
50         
51         /* Align ACPI tables to 16byte */
52         start   = ( start + 0x0f ) & -0x10;
53         current = start;
54         
55         printk(BIOS_INFO, "ACPI: Writing ACPI tables at %lx...\n", start);
56
57         /* We need at least an RSDP and an RSDT Table */
58         rsdp = (acpi_rsdp_t *) current;
59         current += sizeof(acpi_rsdp_t);
60         rsdt = (acpi_rsdt_t *) current;
61         current += sizeof(acpi_rsdt_t);
62
63         /* clear all table memory */
64         memset((void *)start, 0, current - start);
65         
66         acpi_write_rsdp(rsdp, rsdt, NULL);
67         acpi_write_rsdt(rsdt);
68         
69         /*
70          * We explicitly add these tables later on:
71          */
72         printk(BIOS_DEBUG, "ACPI:     * FACS\n");
73         facs = (acpi_facs_t *) current;
74         current += sizeof(acpi_facs_t);
75         acpi_create_facs(facs);
76
77         dsdt = (acpi_header_t *)current;
78         current += ((acpi_header_t *)AmlCode)->length;
79         memcpy((void *)dsdt,(void *)AmlCode, ((acpi_header_t *)AmlCode)->length);
80         dsdt->checksum = 0; // don't trust intel iasl compiler to get this right
81         dsdt->checksum = acpi_checksum(dsdt,dsdt->length);
82         printk(BIOS_DEBUG, "ACPI:     * DSDT @ %p Length %x\n",dsdt,dsdt->length);
83         printk(BIOS_DEBUG, "ACPI:     * FADT\n");
84
85         fadt = (acpi_fadt_t *) current;
86         current += sizeof(acpi_fadt_t);
87
88         acpi_create_fadt(fadt,facs,dsdt);
89         acpi_add_table(rsdp,fadt);
90
91         printk(BIOS_INFO, "ACPI: done.\n");
92         return current;
93 }
94