| 1 |
|
| 2 |
|
| 3 |
#include <device/device.h> |
| 4 |
#include <arch/smp/mpspec.h> |
| 5 |
#include <arch/ioapic.h> |
| 6 |
|
| 7 |
static void *smp_write_config_table(void *v) |
| 8 |
{ |
| 9 |
struct mp_config_table *mc; |
| 10 |
struct device *riser = nullptr, *firewire = nullptr; |
| 11 |
int firewire_bus = 0, riser_bus = 0, isa_bus; |
| 12 |
|
| 13 |
mc = (void *)(((char *)v) + SMP_FLOATING_TABLE_LEN); |
| 14 |
|
| 15 |
mptable_init(mc); |
| 16 |
|
| 17 |
smp_write_processors(mc); |
| 18 |
|
| 19 |
firewire = dev_find_device(0x104c, 0x8023, 0); |
| 20 |
if (firewire) { |
| 21 |
firewire_bus = firewire->upstream->secondary; |
| 22 |
} |
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
riser = dev_find_device(0x3388, 0x0021, 0); |
| 27 |
if (!riser) |
| 28 |
riser = dev_find_device(0x3388, 0x0022, 0); |
| 29 |
if (riser) { |
| 30 |
riser_bus = riser->downstream->secondary; |
| 31 |
} |
| 32 |
|
| 33 |
mptable_write_buses(mc, nullptr, &isa_bus); |
| 34 |
|
| 35 |
|
| 36 |
u8 ioapic_id = smp_write_ioapic_from_hw(mc, IO_APIC_ADDR); |
| 37 |
|
| 38 |
|
| 39 |
mptable_add_isa_interrupts(mc, isa_bus, ioapic_id, 0); |
| 40 |
|
| 41 |
|
| 42 |
smp_write_pci_intsrc(mc, mp_INT, 0x0, 0x01, 0, ioapic_id, 0x10); |
| 43 |
smp_write_pci_intsrc(mc, mp_INT, 0x0, 0x02, 0, ioapic_id, 0x10); |
| 44 |
smp_write_pci_intsrc(mc, mp_INT, 0x0, 0x1f, 1, ioapic_id, 0x13); |
| 45 |
smp_write_pci_intsrc(mc, mp_INT, 0x0, 0x1d, 0, ioapic_id, 0x17); |
| 46 |
smp_write_pci_intsrc(mc, mp_INT, 0x0, 0x1d, 1, ioapic_id, 0x13); |
| 47 |
smp_write_pci_intsrc(mc, mp_INT, 0x0, 0x1d, 2, ioapic_id, 0x12); |
| 48 |
smp_write_pci_intsrc(mc, mp_INT, 0x0, 0x1d, 3, ioapic_id, 0x10); |
| 49 |
smp_write_pci_intsrc(mc, mp_INT, 0x0, 0x1b, 0, ioapic_id, 0x10); |
| 50 |
smp_write_pci_intsrc(mc, mp_INT, 0x0, 0x1c, 0, ioapic_id, 0x10); |
| 51 |
smp_write_pci_intsrc(mc, mp_INT, 0x0, 0x1c, 1, ioapic_id, 0x11); |
| 52 |
|
| 53 |
|
| 54 |
if (firewire) { |
| 55 |
smp_write_pci_intsrc(mc, mp_INT, firewire_bus, 0x00, 0, ioapic_id, 0x10); |
| 56 |
smp_write_pci_intsrc(mc, mp_INT, firewire_bus, 0x01, 0, ioapic_id, 0x14); |
| 57 |
} |
| 58 |
|
| 59 |
if (riser) { |
| 60 |
|
| 61 |
|
| 62 |
smp_write_pci_intsrc(mc, mp_INT, riser_bus, 0x08, 0, ioapic_id, 0x14); |
| 63 |
|
| 64 |
smp_write_pci_intsrc(mc, mp_INT, riser_bus, 0x09, 0, ioapic_id, 0x15); |
| 65 |
|
| 66 |
smp_write_pci_intsrc(mc, mp_INT, riser_bus, 0x0a, 0, ioapic_id, 0x16); |
| 67 |
|
| 68 |
|
| 69 |
smp_write_pci_intsrc(mc, mp_INT, riser_bus, 0x0c, 0, ioapic_id, 0x14); |
| 70 |
smp_write_pci_intsrc(mc, mp_INT, riser_bus, 0x0d, 0, ioapic_id, 0x15); |
| 71 |
smp_write_pci_intsrc(mc, mp_INT, riser_bus, 0x0e, 0, ioapic_id, 0x16); |
| 72 |
} |
| 73 |
|
| 74 |
|
| 75 |
smp_write_pci_intsrc(mc, mp_INT, 0x1, 0x00, 0, ioapic_id, 0x10); |
| 76 |
smp_write_pci_intsrc(mc, mp_INT, 0x1, 0x00, 1, ioapic_id, 0x11); |
| 77 |
|
| 78 |
|
| 79 |
smp_write_pci_intsrc(mc, mp_INT, 0x2, 0x00, 0, ioapic_id, 0x10); |
| 80 |
|
| 81 |
|
| 82 |
mptable_lintsrc(mc, isa_bus); |
| 83 |
|
| 84 |
|
| 85 |
return mptable_finalize(mc); |
| 86 |
} |
| 87 |
|
| 88 |
unsigned long write_smp_table(unsigned long addr) |
| 89 |
{ |
| 90 |
void *v; |
| 91 |
v = smp_write_floating_table(addr, 1); |
| 92 |
return (unsigned long)smp_write_config_table(v); |
| 93 |
} |