Add constants for fast path resume copying
[coreboot.git] / src / mainboard / amd / dbm690t / irq_tables.c
1 /*
2  * This file is part of the coreboot project.
3  *
4  * Copyright (C) 2008 Advanced Micro Devices, Inc.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; version 2 of the License.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
18  */
19
20 /* This file was generated by getpir.c, do not modify!
21    (but if you do, please run checkpir on it to verify)
22    Contains the IRQ Routing Table dumped directly from your memory , wich BIOS sets up
23
24    Documentation at : http://www.microsoft.com/hwdev/busbios/PCIIRQ.HTM
25 */
26 #include <console/console.h>
27 #include <device/pci.h>
28 #include <string.h>
29 #include <stdint.h>
30 #include <arch/pirq_routing.h>
31
32 #include <cpu/amd/amdk8_sysconf.h>
33
34
35
36 static void write_pirq_info(struct irq_info *pirq_info, u8 bus, u8 devfn,
37                             u8 link0, u16 bitmap0, u8 link1, u16 bitmap1,
38                             u8 link2, u16 bitmap2, u8 link3, u16 bitmap3,
39                             u8 slot, u8 rfu)
40 {
41         pirq_info->bus = bus;
42         pirq_info->devfn = devfn;
43         pirq_info->irq[0].link = link0;
44         pirq_info->irq[0].bitmap = bitmap0;
45         pirq_info->irq[1].link = link1;
46         pirq_info->irq[1].bitmap = bitmap1;
47         pirq_info->irq[2].link = link2;
48         pirq_info->irq[2].bitmap = bitmap2;
49         pirq_info->irq[3].link = link3;
50         pirq_info->irq[3].bitmap = bitmap3;
51         pirq_info->slot = slot;
52         pirq_info->rfu = rfu;
53 }
54 extern u8 bus_rs690[8];
55 extern u8 bus_sb600[2];
56 extern unsigned long sbdn_sb600;
57
58 unsigned long write_pirq_routing_table(unsigned long addr)
59 {
60         struct irq_routing_table *pirq;
61         struct irq_info *pirq_info;
62         u32 slot_num;
63         u8 *v;
64
65         u8 sum = 0;
66         int i;
67
68         get_bus_conf();         /* it will find out all bus num and apic that share with mptable.c and mptable.c and acpi_tables.c */
69
70         /* Align the table to be 16 byte aligned. */
71         addr += 15;
72         addr &= ~15;
73
74         /* This table must be betweeen 0xf0000 & 0x100000 */
75         printk(BIOS_INFO, "Writing IRQ routing tables to 0x%lx...", addr);
76
77         pirq = (void *)(addr);
78         v = (u8 *) (addr);
79
80         pirq->signature = PIRQ_SIGNATURE;
81         pirq->version = PIRQ_VERSION;
82
83         pirq->rtr_bus = bus_sb600[0];
84         pirq->rtr_devfn = ((sbdn_sb600 + 0x14) << 3) | 4;
85
86         pirq->exclusive_irqs = 0;
87
88         pirq->rtr_vendor = 0x1002;
89         pirq->rtr_device = 0x4384;
90
91         pirq->miniport_data = 0;
92
93         memset(pirq->rfu, 0, sizeof(pirq->rfu));
94
95         pirq_info = (void *)(&pirq->checksum + 1);
96         slot_num = 0;
97
98         /* pci bridge */
99         write_pirq_info(pirq_info, bus_sb600[0], ((sbdn_sb600 + 0x14) << 3) | 4,
100                         0x1, 0xdef8, 0x2, 0xdef8, 0x3, 0xdef8, 0x4, 0xdef8, 0,
101                         0);
102         pirq_info++;
103         slot_num++;
104
105         pirq->size = 32 + 16 * slot_num;
106
107         for (i = 0; i < pirq->size; i++)
108                 sum += v[i];
109
110         sum = pirq->checksum - sum;
111         if (sum != pirq->checksum) {
112                 pirq->checksum = sum;
113         }
114
115         printk(BIOS_INFO, "write_pirq_routing_table done.\n");
116
117         return (unsigned long)pirq_info;
118 }