3 #include "pirq_routing.h"
5 static char *preamble[] = {
6 "/* This file was generated by getpir.c, do not modify!\n",
7 " * (but if you do, please run checkpir on it to verify)\n",
9 " * Contains the IRQ Routing Table dumped directly from your\n",
10 " * memory, which BIOS sets up.\n",
12 " * Documentation at: http://www.microsoft.com/whdc/archive/pciirq.mspx\n */\n\n",
14 "#include \"pirq_routing.h\"\n",
16 "#include <arch/pirq_routing.h>\n",
18 "const struct irq_routing_table intel_irq_routing_table = {\n",
19 "\tPIRQ_SIGNATURE, /* u32 signature */\n",
20 "\tPIRQ_VERSION, /* u16 version */\n",
24 void code_gen(char *filename, struct irq_routing_table *rt)
26 char **code = preamble;
27 struct irq_info *se_arr = (struct irq_info *) ((char *) rt + 32);
28 int i, ts = (rt->size - 32) / 16;
31 if ((fpir = fopen(filename, "w")) == NULL) {
32 printf("Failed creating file!\n");
37 fprintf(fpir, "%s", *code++);
39 fprintf(fpir, "\t32+16*%d, /* There can be total %d devices on the bus */\n",
41 fprintf(fpir, "\t0x%02x, /* Where the interrupt router lies (bus) */\n",
43 fprintf(fpir, "\t(0x%02x<<3)|0x%01x, /* Where the interrupt router lies (dev) */\n",
44 rt->rtr_devfn >> 3, rt->rtr_devfn & 7);
45 fprintf(fpir, "\t%#x, /* IRQs devoted exclusively to PCI usage */\n",
47 fprintf(fpir, "\t%#x, /* Vendor */\n", rt->rtr_vendor);
48 fprintf(fpir, "\t%#x, /* Device */\n", rt->rtr_device);
49 fprintf(fpir, "\t%#x, /* Crap (miniport) */\n",
51 fprintf(fpir, "\t{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* u8 rfu[11] */\n");
52 fprintf(fpir, "\t%#x, /* u8 checksum. This has to be set to some\n value that would give 0 after the sum of all\n bytes for this structure (including checksum) */\n",
54 fprintf(fpir, "\t{\n");
55 fprintf(fpir, "\t\t/* bus, dev|fn, {link, bitmap}, {link, bitmap}, {link, bitmap}, {link, bitmap}, slot, rfu */\n");
56 for (i = 0; i < ts; i++) {
57 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",
58 (se_arr+i)->bus, (se_arr+i)->devfn >> 3,
59 (se_arr+i)->devfn & 7, (se_arr+i)->irq[0].link,
60 (se_arr+i)->irq[0].bitmap, (se_arr+i)->irq[1].link,
61 (se_arr+i)->irq[1].bitmap, (se_arr+i)->irq[2].link,
62 (se_arr+i)->irq[2].bitmap, (se_arr+i)->irq[3].link,
63 (se_arr+i)->irq[3].bitmap, (se_arr+i)->slot,
66 fprintf(fpir, "\t}\n");
67 fprintf(fpir, "};\n");