blob: 32528633a0d264c6855c141868918fec5ad7e35f [file] [log] [blame]
Li-Ta Lo6463ae72004-04-14 22:24:50 +00001#include <stdio.h>
2#include <arch/pirq_routing.h>
3
4static char *preamble[] = {
5 "/* This file was generated by getpir.c, do not modify! \n (but if you do, please run checkpir on it to verify)\n",
6 " * Contains the IRQ Routing Table dumped directly from your memory, which BIOS sets up\n",
7 " *\n",
8 " * Documentation at : http://www.microsoft.com/hwdev/busbios/PCIIRQ.HTM\n*/\n\n",
9 "#include <arch/pirq_routing.h>\n\n",
10 "const struct irq_routing_table intel_irq_routing_table = {\n",
11 "\tPIRQ_SIGNATURE, /* u32 signature */\n",
12 "\tPIRQ_VERSION, /* u16 version */\n",
13 0
14};
15
16void code_gen(FILE * fpir, struct irq_routing_table *rt)
17{
18 char **code = preamble;
19 struct irq_info *se_arr = (struct irq_info *) ((char *) rt + 32);
20 int i, ts = (rt->size - 32) / 16;
21
22 while (*code)
23 fprintf(fpir, "%s", *code++);
24
25
26 fprintf(fpir, "\t32+16*%d, /* there can be total %d devices on the bus */\n",
27 ts, ts);
28 fprintf(fpir, "\t0x%02x, /* Where the interrupt router lies (bus) */\n",
29 rt->rtr_bus);
30 fprintf(fpir, "\t(0x%02x<<3)|0x%01x, /* Where the interrupt router lies (dev) */\n",
31 rt->rtr_devfn >> 3, rt->rtr_devfn & 7);
32 fprintf(fpir, "\t%#x, /* IRQs devoted exclusively to PCI usage */\n",
33 rt->exclusive_irqs);
34 fprintf(fpir, "\t%#x, /* Vendor */\n", rt->rtr_vendor);
35 fprintf(fpir, "\t%#x, /* Device */\n", rt->rtr_device);
36 fprintf(fpir, "\t%#x, /* Crap (miniport) */\n",
37 rt->miniport_data);
38 fprintf(fpir, "\t{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* u8 rfu[11] */\n");
39 fprintf(fpir, "\t%#x, /* u8 checksum , this hase to set to some value that would give 0 after the sum of all bytes for this structure (including checksum) */\n",
40 rt->checksum);
41 fprintf(fpir, "\t{\n");
42 fprintf(fpir, "\t\t/* bus, dev|fn, {link, bitmap}, {link, bitmap}, {link, bitmap}, {link, bitmap}, slot, rfu */\n");
43 for (i = 0; i < ts; i++) {
44 fprintf(fpir, "\t\t{0x%02x,(0x%02x<<3)|0x%01x, {{0x%02x, 0x%04x}, {0x%02x, 0x%04x}, {0x%02x, 0x%04x}, {0x%02x, 0x0%04x}}, 0x%x, 0x%x},\n",
45 (se_arr+i)->bus, (se_arr+i)->devfn >> 3,
46 (se_arr+i)->devfn & 7, (se_arr+i)->irq[0].link,
47 (se_arr+i)->irq[0].bitmap, (se_arr+i)->irq[1].link,
48 (se_arr+i)->irq[1].bitmap, (se_arr+i)->irq[2].link,
49 (se_arr+i)->irq[2].bitmap, (se_arr+i)->irq[3].link,
50 (se_arr+i)->irq[3].bitmap, (se_arr+i)->slot,
51 (se_arr+i)->rfu);
52 }
53 fprintf(fpir, "\t}\n");
54 fprintf(fpir, "};\n");
55}