mptable: Refactor mptable generation some more
[coreboot.git] / src / mainboard / supermicro / x6dhr_ig / mptable.c
index fdf1689fe8d790a4e7bf413f73b439e6bb3a6e62..143138d012c0e0397204441f951780fc1c6bb8bf 100644 (file)
@@ -8,8 +8,7 @@
 static void *smp_write_config_table(void *v)
 {
        struct mp_config_table *mc;
-       unsigned char bus_num;
-       unsigned char bus_isa;
+       int bus_isa;
        unsigned char bus_pxhd_1;
        unsigned char bus_pxhd_2;
        unsigned char bus_pxhd_3;
@@ -18,7 +17,7 @@ static void *smp_write_config_table(void *v)
 
        mc = (void *)(((char *)v) + SMP_FLOATING_TABLE_LEN);
 
-       mptable_init(mc, "X6DHR-iG    ", LAPIC_ADDR);
+       mptable_init(mc, LAPIC_ADDR);
 
        smp_write_processors(mc);
 
@@ -29,14 +28,11 @@ static void *smp_write_config_table(void *v)
                dev = dev_find_slot(0, PCI_DEVFN(0x1e,0));
                if (dev) {
                        bus_ich5r_1 = pci_read_config8(dev, PCI_SECONDARY_BUS);
-                       bus_isa    = pci_read_config8(dev, PCI_SUBORDINATE_BUS);
-                       bus_isa++;
                }
                else {
                        printk(BIOS_DEBUG, "ERROR - could not find PCI 0:1f.0, using defaults\n");
 
                        bus_ich5r_1 = 9;
-                       bus_isa = 10;
                }
                /* pxhd-1 */
                dev = dev_find_slot(2, PCI_DEVFN(0x0,0));
@@ -86,11 +82,7 @@ static void *smp_write_config_table(void *v)
 
        }
 
-       /* define bus and isa numbers */
-       for(bus_num = 0; bus_num < bus_isa; bus_num++) {
-               smp_write_bus(mc, bus_num, "PCI   ");
-       }
-       smp_write_bus(mc, bus_isa, "ISA   ");
+       mptable_write_buses(mc, NULL, &bus_isa);
 
        /* IOAPIC handling */
 
@@ -172,26 +164,18 @@ static void *smp_write_config_table(void *v)
                (bus_isa - 1), 0x04, 0x02, 0x10);
 
        /* Standard local interrupt assignments */
-       smp_write_lintsrc(mc, mp_ExtINT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH,
-               bus_isa, 0x00, MP_APIC_ALL, 0x00);
-       smp_write_lintsrc(mc, mp_NMI, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH,
-               bus_isa, 0x00, MP_APIC_ALL, 0x01);
+       mptable_lintsrc(mc, bus_isa);
 
        /* There is no extension information... */
 
        /* Compute the checksums */
-       mc->mpe_checksum = smp_compute_checksum(smp_next_mpc_entry(mc), mc->mpe_length);
-
-       mc->mpc_checksum = smp_compute_checksum(mc, mc->mpc_length);
-       printk(BIOS_DEBUG, "Wrote the mp table end at: %p - %p\n",
-               mc, smp_next_mpe_entry(mc));
-       return smp_next_mpe_entry(mc);
+       return mptable_finalize(mc);
 }
 
 unsigned long write_smp_table(unsigned long addr)
 {
        void *v;
-       v = smp_write_floating_table(addr);
+       v = smp_write_floating_table(addr, 0);
        return (unsigned long)smp_write_config_table(v);
 }