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;
12 unsigned char bus_8131_1;
13 unsigned char bus_8131_2;
14 unsigned char bus_8111_1;
16 mc = (void *)(((char *)v) + SMP_FLOATING_TABLE_LEN);
18 mptable_init(mc, LAPIC_ADDR);
20 smp_write_processors(mc);
26 dev = dev_find_slot(1, PCI_DEVFN(0x03,0));
28 bus_8111_1 = pci_read_config8(dev, PCI_SECONDARY_BUS);
31 printk(BIOS_DEBUG, "ERROR - could not find PCI 1:03.0, using defaults\n");
35 dev = dev_find_slot(1, PCI_DEVFN(0x01,0));
37 bus_8131_1 = pci_read_config8(dev, PCI_SECONDARY_BUS);
40 printk(BIOS_DEBUG, "ERROR - could not find PCI 1:01.0, using defaults\n");
44 dev = dev_find_slot(1, PCI_DEVFN(0x02,0));
46 bus_8131_2 = pci_read_config8(dev, PCI_SECONDARY_BUS);
49 printk(BIOS_DEBUG, "ERROR - could not find PCI 1:02.0, using defaults\n");
54 mptable_write_buses(mc, NULL, &bus_isa);
57 smp_write_ioapic(mc, 2, 0x11, IO_APIC_ADDR);
62 dev = dev_find_slot(1, PCI_DEVFN(0x01,1));
64 res = find_resource(dev, PCI_BASE_ADDRESS_0);
66 smp_write_ioapic(mc, 0x03, 0x11, res->base);
70 dev = dev_find_slot(1, PCI_DEVFN(0x02,1));
72 res = find_resource(dev, PCI_BASE_ADDRESS_0);
74 smp_write_ioapic(mc, 0x04, 0x11, res->base);
79 mptable_add_isa_interrupts(mc, bus_isa, 0x2, 0);
81 /* Standard local interrupt assignments */
82 mptable_lintsrc(mc, bus_isa);
86 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_DEFAULT|MP_IRQ_POLARITY_DEFAULT,
87 bus_8131_2, (1<<2)|0, 0x02, 0x11);
88 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_DEFAULT|MP_IRQ_POLARITY_DEFAULT,
89 bus_8131_2, (1<<2)|1, 0x02, 0x12);
90 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_DEFAULT|MP_IRQ_POLARITY_DEFAULT,
91 bus_8131_2, (1<<2)|2, 0x02, 0x13);
92 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_DEFAULT|MP_IRQ_POLARITY_DEFAULT,
93 bus_8131_2, (1<<2)|3, 0x02, 0x10);
96 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_DEFAULT|MP_IRQ_POLARITY_DEFAULT,
97 bus_8131_2, (2<<2)|0, 0x02, 0x12);
98 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_DEFAULT|MP_IRQ_POLARITY_DEFAULT,
99 bus_8131_2, (2<<2)|1, 0x02, 0x13);
100 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_DEFAULT|MP_IRQ_POLARITY_DEFAULT,
101 bus_8131_2, (2<<2)|2, 0x02, 0x10);
102 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_DEFAULT|MP_IRQ_POLARITY_DEFAULT,
103 bus_8131_2, (2<<2)|3, 0x02, 0x11);
106 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_DEFAULT|MP_IRQ_POLARITY_DEFAULT,
107 bus_8131_1, (1<<2)|0, 0x02, 0x11);
108 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_DEFAULT|MP_IRQ_POLARITY_DEFAULT,
109 bus_8131_1, (1<<2)|1, 0x02, 0x12);
110 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_DEFAULT|MP_IRQ_POLARITY_DEFAULT,
111 bus_8131_1, (1<<2)|2, 0x02, 0x13);
112 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_DEFAULT|MP_IRQ_POLARITY_DEFAULT,
113 bus_8131_1, (1<<2)|3, 0x02, 0x10);
116 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_DEFAULT|MP_IRQ_POLARITY_DEFAULT,
117 bus_8131_1, (2<<2)|0, 0x02, 0x12);
118 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_DEFAULT|MP_IRQ_POLARITY_DEFAULT,
119 bus_8131_1, (2<<2)|1, 0x02, 0x13);
120 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_DEFAULT|MP_IRQ_POLARITY_DEFAULT,
121 bus_8131_1, (2<<2)|2, 0x02, 0x10);
122 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_DEFAULT|MP_IRQ_POLARITY_DEFAULT,
123 bus_8131_1, (2<<2)|3, 0x02, 0x11);
126 // FIXME get the irqs right, it's just hacked to work for now
127 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_DEFAULT|MP_IRQ_POLARITY_DEFAULT,
128 bus_8111_1, (5<<2)|0, 0x02, 0x11);
129 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_DEFAULT|MP_IRQ_POLARITY_DEFAULT,
130 bus_8111_1, (5<<2)|1, 0x02, 0x12);
131 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_DEFAULT|MP_IRQ_POLARITY_DEFAULT,
132 bus_8111_1, (5<<2)|2, 0x02, 0x13);
133 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_DEFAULT|MP_IRQ_POLARITY_DEFAULT,
134 bus_8111_1, (5<<2)|3, 0x02, 0x10);
137 // FIXME get the irqs right, it's just hacked to work for now
138 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_DEFAULT|MP_IRQ_POLARITY_DEFAULT,
139 bus_8111_1, (4<<2)|0, 0x02, 0x10);
140 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_DEFAULT|MP_IRQ_POLARITY_DEFAULT,
141 bus_8111_1, (4<<2)|1, 0x02, 0x11);
142 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_DEFAULT|MP_IRQ_POLARITY_DEFAULT,
143 bus_8111_1, (4<<2)|2, 0x02, 0x12);
144 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_DEFAULT|MP_IRQ_POLARITY_DEFAULT,
145 bus_8111_1, (4<<2)|3, 0x02, 0x13);
148 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_DEFAULT|MP_IRQ_POLARITY_DEFAULT,
149 bus_8131_1, (3<<2)|0, 0x02, 0x13);
150 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_DEFAULT|MP_IRQ_POLARITY_DEFAULT,
151 bus_8131_1, (4<<2)|0, 0x02, 0x13);
153 /* There is no extension information... */
155 /* Compute the checksums */
156 mc->mpe_checksum = smp_compute_checksum(smp_next_mpc_entry(mc), mc->mpe_length);
157 mc->mpc_checksum = smp_compute_checksum(mc, mc->mpc_length);
158 printk(BIOS_DEBUG, "Wrote the mp table end at: %p - %p\n",
159 mc, smp_next_mpe_entry(mc));
160 return smp_next_mpe_entry(mc);
163 unsigned long write_smp_table(unsigned long addr)
166 v = smp_write_floating_table(addr, 0);
167 return (unsigned long)smp_write_config_table(v);