1 #include <console/console.h>
2 #include <arch/smp/mpspec.h>
3 #include <arch/ioapic.h>
4 #include <device/pci.h>
8 static void *smp_write_config_table(void *v)
10 struct mp_config_table *mc;
11 unsigned char bus_num;
12 unsigned char bus_isa;
13 unsigned char bus_6300;
15 mc = (void *)(((char *)v) + SMP_FLOATING_TABLE_LEN);
17 mptable_init(mc, "X6DAI-G ", LAPIC_ADDR);
19 smp_write_processors(mc);
25 dev = dev_find_slot(0, PCI_DEVFN(0x1e,0));
27 bus_6300 = pci_read_config8(dev, PCI_SECONDARY_BUS);
28 bus_isa = pci_read_config8(dev, PCI_SUBORDINATE_BUS);
32 printk(BIOS_DEBUG, "ERROR - could not find PCI 0:1e.0, using defaults\n");
38 /* define bus and isa numbers */
39 for(bus_num = 0; bus_num < bus_isa; bus_num++) {
40 smp_write_bus(mc, bus_num, "PCI ");
42 smp_write_bus(mc, bus_isa, "ISA ");
46 smp_write_ioapic(mc, 2, 0x20, IO_APIC_ADDR);
47 smp_write_ioapic(mc, 3, 0x20, IO_APIC_ADDR + 0x10000);
49 mptable_add_isa_interrupts(mc, bus_isa, 0x2, 0);
51 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW,
52 0x00, 0x74, 0x02, 0x10);
53 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW,
54 0x00, 0x77, 0x02, 0x17);
55 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW,
56 0x00, 0x75, 0x02, 0x13);
57 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW,
58 0x00, 0x7c, 0x02, 0x12);
59 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW,
60 0x00, 0x7d, 0x02, 0x11);
61 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW,
62 0x00, 0x7d, 0x02, 0x11);
63 /* Slot 1 function 0 */
64 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW,
66 /* Slot 2 function 0 */
67 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW,
69 /* Slot 3 function 0 */
70 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW,
71 bus_6300, 0x20, 0x02, 0x14);
72 /* Slot 4 function 0 */
73 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW,
74 bus_6300, 0x08, 0x02, 0x15);
76 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW,
77 bus_6300, 0x0c, 0x02, 0x16);
79 /* Standard local interrupt assignments */
80 // smp_write_lintsrc(mc, mp_ExtINT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH,
81 // bus_isa, 0x00, MP_APIC_ALL, 0x00);
82 smp_write_lintsrc(mc, mp_NMI, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH,
83 bus_isa, 0x00, MP_APIC_ALL, 0x01);
85 /* There is no extension information... */
87 /* Compute the checksums */
88 mc->mpe_checksum = smp_compute_checksum(smp_next_mpc_entry(mc), mc->mpe_length);
90 mc->mpc_checksum = smp_compute_checksum(mc, mc->mpc_length);
91 printk(BIOS_DEBUG, "Wrote the mp table end at: %p - %p\n",
92 mc, smp_next_mpe_entry(mc));
93 return smp_next_mpe_entry(mc);
96 unsigned long write_smp_table(unsigned long addr)
99 v = smp_write_floating_table(addr);
100 return (unsigned long)smp_write_config_table(v);