1 #include <console/console.h>
2 #include <arch/smp/mpspec.h>
3 #include <device/pci.h>
7 #include <cpu/amd/amdk8_sysconf.h>
9 extern unsigned char bus_isa;
10 extern unsigned char bus_8131_0;
11 extern unsigned char bus_8131_1;
12 extern unsigned char bus_8131_2;
13 extern unsigned char bus_8111_0;
14 extern unsigned char bus_8111_1;
15 extern unsigned apicid_8111;
16 extern unsigned apicid_8131_1;
17 extern unsigned apicid_8131_2;
19 extern unsigned sbdn3;
23 static void *smp_write_config_table(void *v)
25 static const char sig[4] = "PCMP";
26 static const char oem[8] = "COREBOOT";
27 static const char productid[12] = "S2881 ";
28 struct mp_config_table *mc;
30 unsigned char bus_num;
34 mc = (void *)(((char *)v) + SMP_FLOATING_TABLE_LEN);
35 memset(mc, 0, sizeof(*mc));
37 memcpy(mc->mpc_signature, sig, sizeof(sig));
38 mc->mpc_length = sizeof(*mc); /* initially just the header */
40 mc->mpc_checksum = 0; /* not yet computed */
41 memcpy(mc->mpc_oem, oem, sizeof(oem));
42 memcpy(mc->mpc_productid, productid, sizeof(productid));
45 mc->mpc_entry_count = 0; /* No entries yet... */
46 mc->mpc_lapic = LAPIC_ADDR;
51 smp_write_processors(mc);
57 /* define bus and isa numbers */
58 for(bus_num = 0; bus_num < bus_isa; bus_num++) {
59 smp_write_bus(mc, bus_num, "PCI ");
61 smp_write_bus(mc, bus_isa, "ISA ");
64 /*I/O APICs: APIC ID Version State Address*/
65 smp_write_ioapic(mc, apicid_8111, 0x11, 0xfec00000);
69 dev = dev_find_slot(bus_8131_0, PCI_DEVFN(sbdn3,1));
71 res = find_resource(dev, PCI_BASE_ADDRESS_0);
73 smp_write_ioapic(mc, apicid_8131_1, 0x11, res->base);
76 dev = dev_find_slot(bus_8131_0, PCI_DEVFN(sbdn3+1,1));
78 res = find_resource(dev, PCI_BASE_ADDRESS_0);
80 smp_write_ioapic(mc, apicid_8131_2, 0x11, res->base);
86 /*I/O Ints: Type Polarity Trigger Bus ID IRQ APIC ID PIN#
87 */ smp_write_intsrc(mc, mp_ExtINT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH, bus_isa, 0x0, apicid_8111, 0x0);
88 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH, bus_isa, 0x1, apicid_8111, 0x1);
89 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH, bus_isa, 0x0, apicid_8111, 0x2);
90 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH, bus_isa, 0x3, apicid_8111, 0x3);
91 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH, bus_isa, 0x4, apicid_8111, 0x4);
92 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH, bus_isa, 0x6, apicid_8111, 0x6);
93 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH, bus_isa, 0x7, apicid_8111, 0x7);
94 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH, bus_isa, 0x8, apicid_8111, 0x8);
95 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH, bus_isa, 0xc, apicid_8111, 0xc);
96 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH, bus_isa, 0xd, apicid_8111, 0xd);
97 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH, bus_isa, 0xe, apicid_8111, 0xe);
98 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH, bus_isa, 0xf, apicid_8111, 0xf);
101 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, bus_8111_0, ((sysconf.sbdn+1)<<2)|0, apicid_8111, 0x13);
103 //On Board AMD USB ???
104 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, bus_8111_1, (0<<2)|3, apicid_8111, 0x13);
106 //On Board ATI Display Adapter
107 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, bus_8111_1, (6<<2)|0, apicid_8111, 0x12);
109 //On Board SI Serial ATA
110 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, bus_8111_1, (5<<2)|0, apicid_8111, 0x11);
114 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, bus_8131_1, (8<<2)|i, apicid_8131_1, (3+i)%4); //27
117 //On Board NIC and adaptec scsi
119 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, bus_8131_1, (9<<2)|i, apicid_8131_1, (0+i)%4); //24
120 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, bus_8131_1, (0xa<<2)|i, apicid_8131_1, (0+i)%4); //24
123 //Slot 1 PCI-X 133/100/66 or Side 1 on raiser card
125 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, bus_8131_2, (3<<2)|i, apicid_8131_2, (0+i)%4); //28
128 //Slot 1 PCI-X 133/100/66, Side 2 on raiser card
131 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, bus_8131_2, (4<<2)|i, apicid_8131_2, (1+i)%4); //28
136 /*Local Ints: Type Polarity Trigger Bus ID IRQ APIC ID PIN#*/
137 smp_write_intsrc(mc, mp_ExtINT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH, bus_isa, 0x0, MP_APIC_ALL, 0x0);
138 smp_write_intsrc(mc, mp_NMI, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH, bus_isa, 0x0, MP_APIC_ALL, 0x1);
139 /* There is no extension information... */
141 /* Compute the checksums */
142 mc->mpe_checksum = smp_compute_checksum(smp_next_mpc_entry(mc), mc->mpe_length);
143 mc->mpc_checksum = smp_compute_checksum(mc, mc->mpc_length);
144 printk(BIOS_DEBUG, "Wrote the mp table end at: %p - %p\n",
145 mc, smp_next_mpe_entry(mc));
146 return smp_next_mpe_entry(mc);
149 unsigned long write_smp_table(unsigned long addr)
152 v = smp_write_floating_table(addr);
153 return (unsigned long)smp_write_config_table(v);