Oskar Enoksson | 37106a7 | 2010-08-20 20:37:27 +0000 | [diff] [blame^] | 1 | /* This file was generated by getpir.c, do not modify! |
| 2 | (but if you do, please run checkpir on it to verify) |
| 3 | Contains the IRQ Routing Table dumped directly from your memory , wich BIOS sets up |
| 4 | |
| 5 | Documentation at : http://www.microsoft.com/hwdev/busbios/PCIIRQ.HTM |
| 6 | */ |
| 7 | #include <console/console.h> |
| 8 | #include <device/pci.h> |
| 9 | #include <string.h> |
| 10 | #include <stdint.h> |
| 11 | #include <arch/pirq_routing.h> |
| 12 | |
| 13 | #include <cpu/amd/amdk8_sysconf.h> |
| 14 | |
| 15 | static void write_pirq_info(struct irq_info *pirq_info, uint8_t bus, uint8_t devfn, uint8_t link0, uint16_t bitmap0, |
| 16 | uint8_t link1, uint16_t bitmap1, uint8_t link2, uint16_t bitmap2,uint8_t link3, uint16_t bitmap3, |
| 17 | uint8_t slot, uint8_t rfu) |
| 18 | { |
| 19 | pirq_info->bus = bus; |
| 20 | pirq_info->devfn = devfn; |
| 21 | pirq_info->irq[0].link = link0; |
| 22 | pirq_info->irq[0].bitmap = bitmap0; |
| 23 | pirq_info->irq[1].link = link1; |
| 24 | pirq_info->irq[1].bitmap = bitmap1; |
| 25 | pirq_info->irq[2].link = link2; |
| 26 | pirq_info->irq[2].bitmap = bitmap2; |
| 27 | pirq_info->irq[3].link = link3; |
| 28 | pirq_info->irq[3].bitmap = bitmap3; |
| 29 | pirq_info->slot = slot; |
| 30 | pirq_info->rfu = rfu; |
| 31 | } |
| 32 | |
| 33 | extern unsigned char bus_8131_0; |
| 34 | extern unsigned char bus_8131_1; |
| 35 | extern unsigned char bus_8131_2; |
| 36 | extern unsigned char bus_8111_0; |
| 37 | extern unsigned char bus_8111_1; |
| 38 | |
| 39 | extern unsigned sbdn3; |
| 40 | |
| 41 | |
| 42 | |
| 43 | unsigned long write_pirq_routing_table(unsigned long addr) |
| 44 | { |
| 45 | |
| 46 | struct irq_routing_table *pirq; |
| 47 | struct irq_info *pirq_info; |
| 48 | unsigned slot_num; |
| 49 | uint8_t *v; |
| 50 | |
| 51 | uint8_t sum=0; |
| 52 | int i; |
| 53 | |
| 54 | get_bus_conf(); // it will find out all bus num and apic that share with mptable.c and mptable.c and acpi_tables.c |
| 55 | |
| 56 | /* Align the table to be 16 byte aligned. */ |
| 57 | addr += 15; |
| 58 | addr &= ~15; |
| 59 | |
| 60 | /* This table must be betweeen 0xf0000 & 0x100000 */ |
| 61 | printk(BIOS_INFO, "Writing IRQ routing tables to 0x%lx...", addr); |
| 62 | |
| 63 | pirq = (void *)(addr); |
| 64 | v = (uint8_t *)(addr); |
| 65 | |
| 66 | pirq->signature = PIRQ_SIGNATURE; |
| 67 | pirq->version = PIRQ_VERSION; |
| 68 | |
| 69 | pirq->rtr_bus = bus_8111_0; |
| 70 | pirq->rtr_devfn = ((sysconf.sbdn+1)<<3)|0; |
| 71 | |
| 72 | pirq->exclusive_irqs = 0; |
| 73 | |
| 74 | pirq->rtr_vendor = 0x1022; |
| 75 | pirq->rtr_device = 0x746b; |
| 76 | |
| 77 | pirq->miniport_data = 0; |
| 78 | |
| 79 | memset(pirq->rfu, 0, sizeof(pirq->rfu)); |
| 80 | |
| 81 | pirq_info = (void *) ( &pirq->checksum + 1); |
| 82 | slot_num = 0; |
| 83 | //pci bridge |
| 84 | write_pirq_info(pirq_info, bus_8111_0, ((sysconf.sbdn+1)<<3)|0, 0x1, 0xdef8, 0x2, 0xdef8, 0x3, 0xdef8, 0x4, 0xdef8, 0, 0); |
| 85 | pirq_info++; slot_num++; |
| 86 | //pcix bridge |
| 87 | // write_pirq_info(pirq_info, bus_8131_0, (sbdn3<<3)|0, 0x1, 0xdef8, 0x2, 0xdef8, 0x3, 0xdef8, 0x4, 0xdef8, 0, 0); |
| 88 | // pirq_info++; slot_num++; |
| 89 | |
| 90 | pirq_info++; slot_num++; |
| 91 | |
| 92 | pirq->size = 32 + 16 * slot_num; |
| 93 | |
| 94 | for (i = 0; i < pirq->size; i++) |
| 95 | sum += v[i]; |
| 96 | |
| 97 | sum = pirq->checksum - sum; |
| 98 | |
| 99 | if (sum != pirq->checksum) { |
| 100 | pirq->checksum = sum; |
| 101 | } |
| 102 | |
| 103 | printk(BIOS_INFO, "done.\n"); |
| 104 | |
| 105 | return (unsigned long) pirq_info; |
| 106 | |
| 107 | } |