1 #include <console/console.h>
2 #include <arch/smp/mpspec.h>
3 #include <device/pci.h>
6 #if CONFIG_LOGICAL_CPUS==1
7 #include <cpu/amd/dualcore.h>
10 #include <cpu/amd/amdk8_sysconf.h>
11 #include "mb_sysconf.h"
13 extern void get_bus_conf(void);
15 void *smp_write_config_table(void *v)
17 static const char sig[4] = "PCMP";
18 static const char oem[8] = "AMD ";
19 static const char productid[12] = "SERENGETI ";
20 struct mp_config_table *mc;
22 unsigned char bus_num;
24 struct mb_sysconf_t *m;
26 mc = (void *)(((char *)v) + SMP_FLOATING_TABLE_LEN);
27 memset(mc, 0, sizeof(*mc));
29 memcpy(mc->mpc_signature, sig, sizeof(sig));
30 mc->mpc_length = sizeof(*mc); /* initially just the header */
32 mc->mpc_checksum = 0; /* not yet computed */
33 memcpy(mc->mpc_oem, oem, sizeof(oem));
34 memcpy(mc->mpc_productid, productid, sizeof(productid));
37 mc->mpc_entry_count = 0; /* No entries yet... */
38 mc->mpc_lapic = LAPIC_ADDR;
43 smp_write_processors(mc);
50 /* define bus and isa numbers */
51 for(bus_num = 0; bus_num < m->bus_isa; bus_num++) {
52 smp_write_bus(mc, bus_num, "PCI ");
54 smp_write_bus(mc, m->bus_isa, "ISA ");
56 /*I/O APICs: APIC ID Version State Address*/
57 smp_write_ioapic(mc, m->apicid_8111, 0x11, 0xfec00000); //8111
61 dev = dev_find_slot(m->bus_8132_0, PCI_DEVFN(m->sbdn3, 1));
63 res = find_resource(dev, PCI_BASE_ADDRESS_0);
65 smp_write_ioapic(mc, m->apicid_8132_1, 0x11, res->base);
68 dev = dev_find_slot(m->bus_8132_0, PCI_DEVFN(m->sbdn3+1, 1));
70 res = find_resource(dev, PCI_BASE_ADDRESS_0);
72 smp_write_ioapic(mc, m->apicid_8132_2, 0x11, res->base);
77 /*I/O Ints: Type Polarity Trigger Bus ID IRQ APIC ID PIN# */
78 smp_write_intsrc(mc, mp_ExtINT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH, m->bus_isa, 0x0, m->apicid_8111, 0x0);
79 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH, m->bus_isa, 0x1, m->apicid_8111, 0x1);
80 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH, m->bus_isa, 0x0, m->apicid_8111, 0x2);
81 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH, m->bus_isa, 0x3, m->apicid_8111, 0x3);
82 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH, m->bus_isa, 0x4, m->apicid_8111, 0x4);
83 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH, m->bus_isa, 0x5, m->apicid_8111, 0x5);
84 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH, m->bus_isa, 0x6, m->apicid_8111, 0x6);
85 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH, m->bus_isa, 0x7, m->apicid_8111, 0x7);
86 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH, m->bus_isa, 0x8, m->apicid_8111, 0x8);
87 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH, m->bus_isa, 0x9, m->apicid_8111, 0x9);
88 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH, m->bus_isa, 0xc, m->apicid_8111, 0xc);
89 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH, m->bus_isa, 0xd, m->apicid_8111, 0xd);
90 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH, m->bus_isa, 0xe, m->apicid_8111, 0xe);
91 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH, m->bus_isa, 0xf, m->apicid_8111, 0xf);
93 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, m->bus_8111_0, ((sysconf.sbdn+1)<<2)|3, m->apicid_8111, 0x13);
96 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, m->bus_8111_1, (0<<2)|3, m->apicid_8111, 0x13);
98 if(sysconf.pci1234[1] & 0xf) {
100 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, m->bus_8151_1, 0x0, m->apicid_8111, 0x11);
105 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, m->bus_8111_1, (5<<2)|i, m->apicid_8111, 0x10 + (1+i)%4); //16
111 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, m->bus_8111_1, (4<<2)|i, m->apicid_8111, 0x10 + (0+i)%4); //16
115 //Slot 1 PCI-X 133/100/66
117 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, m->bus_8132_2, (1<<2)|i, m->apicid_8132_2, (0+i)%4); //
121 //Slot 2 PCI-X 133/100/66
123 smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, m->bus_8132_1, (1<<2)|i, m->apicid_8132_1, (1+i)%4); //25
127 /*Local Ints: Type Polarity Trigger Bus ID IRQ APIC ID PIN#*/
128 smp_write_intsrc(mc, mp_ExtINT, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH, m->bus_isa, 0x0, MP_APIC_ALL, 0x0);
129 smp_write_intsrc(mc, mp_NMI, MP_IRQ_TRIGGER_EDGE|MP_IRQ_POLARITY_HIGH, m->bus_isa, 0x0, MP_APIC_ALL, 0x1);
130 /* There is no extension information... */
132 /* Compute the checksums */
133 mc->mpe_checksum = smp_compute_checksum(smp_next_mpc_entry(mc), mc->mpe_length);
134 mc->mpc_checksum = smp_compute_checksum(mc, mc->mpc_length);
135 printk_debug("Wrote the mp table end at: %p - %p\n",
136 mc, smp_next_mpe_entry(mc));
137 return smp_next_mpe_entry(mc);
140 unsigned long write_smp_table(unsigned long addr)
143 v = smp_write_floating_table(addr);
144 return (unsigned long)smp_write_config_table(v);