1 // Coreboot interface support.
3 // Copyright (C) 2008,2009 Kevin O'Connor <kevin@koconnor.net>
5 // This file may be distributed under the terms of the GNU LGPLv3 license.
7 #include "config.h" // CONFIG_*
8 #include "util.h" // dprintf
9 #include "pci.h" // struct pir_header
10 #include "acpi.h" // struct rsdp_descriptor
11 #include "mptable.h" // MPTABLE_SIGNATURE
12 #include "smbios.h" // struct smbios_entry_point
17 struct pir_header *p = pos;
18 if (p->signature != PIR_SIGNATURE)
22 if (p->size < sizeof(*p))
24 if (checksum(pos, p->size) != 0)
26 void *newpos = malloc_fseg(p->size);
31 dprintf(1, "Copying PIR from %p to %p\n", pos, newpos);
32 memcpy(newpos, pos, p->size);
33 PirOffset = (u32)newpos - BUILD_BIOS_ADDR;
37 copy_mptable(void *pos)
39 struct mptable_floating_s *p = pos;
40 if (p->signature != MPTABLE_SIGNATURE)
44 if (checksum(pos, sizeof(*p)) != 0)
46 u32 length = p->length * 16;
47 u16 mpclength = ((struct mptable_config_s *)p->physaddr)->length;
48 struct mptable_floating_s *newpos = malloc_fseg(length + mpclength);
53 dprintf(1, "Copying MPTABLE from %p/%x to %p\n", pos, p->physaddr, newpos);
54 memcpy(newpos, pos, length);
55 newpos->physaddr = (u32)newpos + length;
56 newpos->checksum -= checksum(newpos, sizeof(*newpos));
57 memcpy((void*)newpos + length, (void*)p->physaddr, mpclength);
61 copy_acpi_rsdp(void *pos)
65 struct rsdp_descriptor *p = pos;
66 if (p->signature != RSDP_SIGNATURE)
69 if (checksum(pos, length) != 0)
71 if (p->revision > 1) {
73 if (checksum(pos, length) != 0)
76 void *newpos = malloc_fseg(length);
81 dprintf(1, "Copying ACPI RSDP from %p to %p\n", pos, newpos);
82 memcpy(newpos, pos, length);
87 copy_smbios(void *pos)
91 struct smbios_entry_point *p = pos;
92 if (memcmp(p->anchor_string, "_SM_", 4))
94 if (checksum(pos, 0x10) != 0)
96 if (memcmp(p->intermediate_anchor_string, "_DMI_", 5))
98 if (checksum(pos+0x10, p->length-0x10) != 0)
100 struct smbios_entry_point *newpos = malloc_fseg(p->length);
105 dprintf(1, "Copying SMBIOS entry point from %p to %p\n", pos, newpos);
106 memcpy(newpos, pos, p->length);