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_pxhd_1;
13 unsigned char bus_pxhd_2;
14 unsigned char bus_pxhd_3;
15 unsigned char bus_pxhd_4;
16 unsigned char bus_ich5r_1;
18 mc = (void *)(((char *)v) + SMP_FLOATING_TABLE_LEN);
20 mptable_init(mc, "X6DHR-iG ", LAPIC_ADDR);
22 smp_write_processors(mc);
28 dev = dev_find_slot(0, PCI_DEVFN(0x1e,0));
30 bus_ich5r_1 = pci_read_config8(dev, PCI_SECONDARY_BUS);
33 printk(BIOS_DEBUG, "ERROR - could not find PCI 0:1f.0, using defaults\n");
38 dev = dev_find_slot(2, PCI_DEVFN(0x0,0));
40 bus_pxhd_1 = pci_read_config8(dev, PCI_SECONDARY_BUS);
44 printk(BIOS_DEBUG, "ERROR - could not find PCI 1:00.1, using defaults\n");
49 dev = dev_find_slot(2, PCI_DEVFN(0x00,2));
51 bus_pxhd_2 = pci_read_config8(dev, PCI_SECONDARY_BUS);
55 printk(BIOS_DEBUG, "ERROR - could not find PCI 1:02.0, using defaults\n");
61 dev = dev_find_slot(5, PCI_DEVFN(0x0,0));
63 bus_pxhd_3 = pci_read_config8(dev, PCI_SECONDARY_BUS);
67 printk(BIOS_DEBUG, "ERROR - could not find PCI 1:00.1, using defaults\n");
72 dev = dev_find_slot(5, PCI_DEVFN(0x00,2));
74 bus_pxhd_4 = pci_read_config8(dev, PCI_SECONDARY_BUS);
78 printk(BIOS_DEBUG, "ERROR - could not find PCI 1:02.0, using defaults\n");
85 mptable_write_buses(mc, NULL, &bus_isa);
89 smp_write_ioapic(mc, 2, 0x20, IO_APIC_ADDR);
94 dev = dev_find_slot(2, PCI_DEVFN(0x00,1));
96 res = find_resource(dev, PCI_BASE_ADDRESS_0);
98 smp_write_ioapic(mc, 0x03, 0x20, res->base);
102 printk(BIOS_DEBUG, "ERROR - could not find IOAPIC PCI 2:00.1\n");
105 dev = dev_find_slot(2, PCI_DEVFN(0x00,3));
107 res = find_resource(dev, PCI_BASE_ADDRESS_0);
109 smp_write_ioapic(mc, 0x04, 0x20, res->base);
113 printk(BIOS_DEBUG, "ERROR - could not find IOAPIC PCI 2:00.3\n");
116 dev = dev_find_slot(5, PCI_DEVFN(0x00,1));
118 res = find_resource(dev, PCI_BASE_ADDRESS_0);
120 smp_write_ioapic(mc, 0x05, 0x20, res->base);
124 printk(BIOS_DEBUG, "ERROR - could not find IOAPIC PCI 5:00.1\n");
127 dev = dev_find_slot(5, PCI_DEVFN(0x00,3));
129 res = find_resource(dev, PCI_BASE_ADDRESS_0);
131 smp_write_ioapic(mc, 0x08, 0x20, res->base);
135 printk(BIOS_DEBUG, "ERROR - could not find IOAPIC PCI 5:00.3\n");
139 mptable_add_isa_interrupts(mc, bus_isa, 0x2, 0);
141 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW,
142 0x00, 0x74, 0x02, 0x10);
143 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW,
144 0x00, 0x76, 0x02, 0x12);
145 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW,
146 0x00, 0x77, 0x02, 0x17);
147 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW,
148 0x00, 0x75, 0x02, 0x13);
149 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW,
150 0x00, 0x74, 0x02, 0x10);
151 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW,
152 0x00, 0x7c, 0x02, 0x12);
153 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW,
154 0x00, 0x7d, 0x02, 0x11);
155 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW,
156 bus_pxhd_2, 0x08, 0x04, 0x06);
157 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW,
158 bus_pxhd_2, 0x09, 0x04, 0x07);
159 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW,
160 bus_pxhd_3, 0x08, 0x05, 0x00);
161 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW,
162 bus_pxhd_4, 0x08, 0x08, 0x00);
163 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW,
164 (bus_isa - 1), 0x04, 0x02, 0x10);
166 /* Standard local interrupt assignments */
167 smp_write_lintsrc(mc, mp_ExtINT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH,
168 bus_isa, 0x00, MP_APIC_ALL, 0x00);
169 smp_write_lintsrc(mc, mp_NMI, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH,
170 bus_isa, 0x00, MP_APIC_ALL, 0x01);
172 /* There is no extension information... */
174 /* Compute the checksums */
175 mc->mpe_checksum = smp_compute_checksum(smp_next_mpc_entry(mc), mc->mpe_length);
177 mc->mpc_checksum = smp_compute_checksum(mc, mc->mpc_length);
178 printk(BIOS_DEBUG, "Wrote the mp table end at: %p - %p\n",
179 mc, smp_next_mpe_entry(mc));
180 return smp_next_mpe_entry(mc);
183 unsigned long write_smp_table(unsigned long addr)
186 v = smp_write_floating_table(addr);
187 return (unsigned long)smp_write_config_table(v);