2 #include <arch/pirq_routing.h>
4 static 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",
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",
16 void code_gen(FILE * fpir, struct irq_routing_table *rt)
18 char **code = preamble;
19 struct irq_info *se_arr = (struct irq_info *) ((char *) rt + 32);
20 int i, ts = (rt->size - 32) / 16;
23 fprintf(fpir, "%s", *code++);
26 fprintf(fpir, "\t32+16*%d, /* there can be total %d devices on the bus */\n",
28 fprintf(fpir, "\t0x%02x, /* Where the interrupt router lies (bus) */\n",
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",
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",
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",
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,
53 fprintf(fpir, "\t}\n");
54 fprintf(fpir, "};\n");