Move generation of mptable entries for ISA to generic code.
[coreboot.git] / src / mainboard / via / epia-n / mptable.c
1 /* generated by MPTable, version 2.0.15*/
2 /* as modified by RGM for coreboot */
3 #include <console/console.h>
4 #include <arch/smp/mpspec.h>
5 #include <device/pci.h>
6 #include <string.h>
7 #include <stdint.h>
8
9 static void *smp_write_config_table(void *v)
10 {
11         static const char sig[4] = "PCMP";
12         static const char oem[8] = "COREBOOT";
13         static const char productid[12] = "P4DPE       ";
14         struct mp_config_table *mc;
15
16         mc = (void *)(((char *)v) + SMP_FLOATING_TABLE_LEN);
17         memset(mc, 0, sizeof(*mc));
18
19         memcpy(mc->mpc_signature, sig, sizeof(sig));
20         mc->mpc_length = sizeof(*mc); /* initially just the header */
21         mc->mpc_spec = 0x04;
22         mc->mpc_checksum = 0; /* not yet computed */
23         memcpy(mc->mpc_oem, oem, sizeof(oem));
24         memcpy(mc->mpc_productid, productid, sizeof(productid));
25         mc->mpc_oemptr = 0;
26         mc->mpc_oemsize = 0;
27         mc->mpc_entry_count = 0; /* No entries yet... */
28         mc->mpc_lapic = LAPIC_ADDR;
29         mc->mpe_length = 0;
30         mc->mpe_checksum = 0;
31         mc->reserved = 0;
32
33         smp_write_processors(mc);
34
35
36 /*Bus:          Bus ID  Type*/
37         smp_write_bus(mc, 0, "PCI   ");
38         smp_write_bus(mc, 1, "PCI   ");
39         smp_write_bus(mc, 2, "ISA   ");
40 /*I/O APICs:    APIC ID Version State           Address*/
41         smp_write_ioapic(mc, 2, 0x20, 0xfec00000);
42         {
43                 device_t dev;
44                 struct resource *res;
45                 dev = dev_find_slot(1, PCI_DEVFN(0x1e,0));
46                 if (dev) {
47                         res = find_resource(dev, PCI_BASE_ADDRESS_0);
48                         if (res) {
49                                 smp_write_ioapic(mc, 3, 0x20, res->base);
50                         }
51                 }
52                 dev = dev_find_slot(1, PCI_DEVFN(0x1c,0));
53                 if (dev) {
54                         res = find_resource(dev, PCI_BASE_ADDRESS_0);
55                         if (res) {
56                                 smp_write_ioapic(mc, 4, 0x20, res->base);
57                         }
58                 }
59                 dev = dev_find_slot(4, PCI_DEVFN(0x1e,0));
60                 if (dev) {
61                         res = find_resource(dev, PCI_BASE_ADDRESS_0);
62                         if (res) {
63                                 smp_write_ioapic(mc, 5, 0x20, res->base);
64                         }
65                 }
66                 dev = dev_find_slot(4, PCI_DEVFN(0x1c,0));
67                 if (dev) {
68                         res = find_resource(dev, PCI_BASE_ADDRESS_0);
69                         if (res) {
70                                 smp_write_ioapic(mc, 8, 0x20, res->base);
71                         }
72                 }
73         }
74         mptable_add_isa_interrupts(mc, 0x2, 0x2, 0);
75
76 /*I/O Ints:     Type    Polarity    Trigger     Bus ID   IRQ    APIC ID PIN# */
77         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x0, 0x40, 0x2, 0x15);
78         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x0, 0x40, 0x2, 0x15);
79         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x0, 0x41, 0x2, 0x15);
80         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x0, 0x41, 0x2, 0x15);
81         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x0, 0x42, 0x2, 0x15);
82         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x0, 0x46, 0x2, 0x16);
83         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x1, 0x0, 0x2, 0x10);
84         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x0, 0x48, 0x2, 0x17);
85         smp_write_intsrc(mc, mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW, 0x0, 0x3d, 0x2, 0x14);
86 /*Local Ints:   Type    Polarity    Trigger     Bus ID   IRQ    APIC ID PIN#*/
87         smp_write_intsrc(mc, mp_ExtINT, MP_IRQ_TRIGGER_DEFAULT|MP_IRQ_POLARITY_DEFAULT, 0x0, 0x0, MP_APIC_ALL, 0x0);
88         smp_write_intsrc(mc, mp_NMI, MP_IRQ_TRIGGER_DEFAULT|MP_IRQ_POLARITY_DEFAULT, 0x0, 0x0, MP_APIC_ALL, 0x1);
89         /* There is no extension information... */
90
91         /* Compute the checksums */
92         mc->mpe_checksum = smp_compute_checksum(smp_next_mpc_entry(mc), mc->mpe_length);
93         mc->mpc_checksum = smp_compute_checksum(mc, mc->mpc_length);
94         printk(BIOS_DEBUG, "Wrote the mp table end at: %p - %p\n",
95                 mc, smp_next_mpe_entry(mc));
96         return smp_next_mpe_entry(mc);
97 }
98
99 unsigned long write_smp_table(unsigned long addr)
100 {
101         void *v;
102         v = smp_write_floating_table(addr);
103         return (unsigned long)smp_write_config_table(v);
104 }