Scan for and relocate mptable when using coreboot.
authorKevin O'Connor <kevin@koconnor.net>
Sat, 21 Jun 2008 23:46:43 +0000 (19:46 -0400)
committerKevin O'Connor <kevin@koconnor.net>
Sat, 21 Jun 2008 23:46:43 +0000 (19:46 -0400)
src/acpi.h
src/coreboot.c

index ab1f75d3408af8c5686e58f40c3d205b12bff7cc..50ba135c96fcbc243012ddb092ce0065fd83f33f 100644 (file)
@@ -8,6 +8,8 @@ void acpi_bios_init(void);
 // XXX - move to better header.
 extern int smp_cpus;
 
+#define RSDP_SIGNATURE 0x2052545020445352LL // "RSD PTR "
+
 struct rsdp_descriptor         /* Root System Descriptor Pointer */
 {
        u8                            signature [8];          /* ACPI signature, contains "RSD PTR " */
@@ -21,4 +23,18 @@ struct rsdp_descriptor         /* Root System Descriptor Pointer */
        u8                            reserved [3];           /* Reserved field must be 0 */
 };
 
+// XXX - not really part of acpi.
+struct mptable_floating_s {
+    u32 signature;
+    u32 physaddr;
+    u8 length;
+    u8 spec_rev;
+    u8 checksum;
+    u8 feature1;
+    u8 feature2;
+    u8 reserved[3];
+};
+
+#define MPTABLE_SIGNAURE 0x5f504d5f  // "_MP_"
+
 #endif // acpi.h
index 635c2f683d699ff3a3f318bc5a4bb95538d95345..534a3c04a8189cb3ce2e890a21eca9073fc8469c 100644 (file)
@@ -37,7 +37,27 @@ copy_pir(void *pos)
     bios_table_cur_addr += p->size;
 }
 
-#define RSDP_SIGNATURE 0x2052545020445352LL // "RSD PTR "
+static void
+copy_mptable(void *pos)
+{
+    struct mptable_floating_s *p = pos;
+    if (p->signature != MPTABLE_SIGNAURE)
+        return;
+    if (!p->physaddr)
+        return;
+    if (checksum(pos, sizeof(*p)) != 0)
+        return;
+    u32 length = p->length * 16;
+    bios_table_cur_addr = ALIGN(bios_table_cur_addr, 16);
+    if (bios_table_cur_addr + length > bios_table_end_addr) {
+        dprintf(1, "No room to copy MPTABLE!\n");
+        return;
+    }
+    dprintf(1, "Copying MPTABLE from %p to %x\n", pos, bios_table_cur_addr);
+    memcpy((void*)bios_table_cur_addr, pos, length);
+    SET_EBDA(pir_loc, bios_table_cur_addr);
+    bios_table_cur_addr += length;
+}
 
 static void
 copy_acpi_rsdp(void *pos)
@@ -72,6 +92,7 @@ scan_tables(u32 start, u32 size)
     void *end = (void*)start + size;
     for (; p<end; p += 16) {
         copy_pir(p);
+        copy_mptable(p);
         copy_acpi_rsdp(p);
     }
 }