Unify Local APIC address definitions
[coreboot.git] / src / mainboard / iwill / dk8s2 / mptable.c
index 382bf908f0c1e6137fe66c58c8ecef81797daa0c..f22fd9d669af1994d40db017adedbf46f5fd865e 100644 (file)
@@ -8,15 +8,14 @@
 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_8131_1;
        unsigned char bus_8131_2;
        unsigned char bus_8111_1;
 
        mc = (void *)(((char *)v) + SMP_FLOATING_TABLE_LEN);
 
-       mptable_init(mc, "DK8S2       ", LAPIC_ADDR);
+       mptable_init(mc, LOCAL_APIC_ADDR);
 
        smp_write_processors(mc);
 
@@ -27,44 +26,32 @@ static void *smp_write_config_table(void *v)
                dev = dev_find_slot(1, PCI_DEVFN(0x03,0));
                if (dev) {
                        bus_8111_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 1:03.0, using defaults\n");
-
                        bus_8111_1 = 4;
-                       bus_isa = 5;
                }
                /* 8131-1 */
                dev = dev_find_slot(1, PCI_DEVFN(0x01,0));
                if (dev) {
                        bus_8131_1 = pci_read_config8(dev, PCI_SECONDARY_BUS);
-
                }
                else {
                        printk(BIOS_DEBUG, "ERROR - could not find PCI 1:01.0, using defaults\n");
-
                        bus_8131_1 = 2;
                }
                /* 8131-2 */
                dev = dev_find_slot(1, PCI_DEVFN(0x02,0));
                if (dev) {
                        bus_8131_2 = pci_read_config8(dev, PCI_SECONDARY_BUS);
-
                }
                else {
                        printk(BIOS_DEBUG, "ERROR - could not find PCI 1:02.0, using defaults\n");
-
                        bus_8131_2 = 3;
                }
        }
 
-       /* 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 */
        smp_write_ioapic(mc, 2, 0x11, IO_APIC_ADDR);
@@ -92,10 +79,7 @@ static void *smp_write_config_table(void *v)
        mptable_add_isa_interrupts(mc, bus_isa, 0x2, 0);
 
        /* Standard local interrupt assignments */
-       smp_write_lintsrc(mc, mp_ExtINT, MP_IRQ_TRIGGER_DEFAULT|MP_IRQ_POLARITY_DEFAULT,
-               bus_isa, 0x00, MP_APIC_ALL, 0x00);
-       smp_write_lintsrc(mc, mp_NMI, MP_IRQ_TRIGGER_DEFAULT|MP_IRQ_POLARITY_DEFAULT,
-               bus_isa, 0x00, MP_APIC_ALL, 0x01);
+       mptable_lintsrc(mc, bus_isa);
 
 
        /* PCI Slot 1 */
@@ -169,17 +153,13 @@ static void *smp_write_config_table(void *v)
        /* 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);
 }