1 /* getpir.c : This software is released under GPL
2 * For coreboot use only
3 * Aug 26 2001 , Nikolai Vladychevski, <niko@isl.net.mx>
4 * 2007.04.09 Jeremy Jackson <jerj@coplanar.net>
5 * updated for amd64 and general 64 bit portability
14 #include <sys/types.h>
17 #include "pirq_routing.h"
21 #if defined (__sun) && (defined(__i386) || defined(__amd64))
22 # define MEM_DEV "/dev/xsvc"
24 # define MEM_DEV "/dev/mem"
27 static struct irq_routing_table *probe_table(int fd_mem)
29 char *ptr, signature[] = "$PIR";
30 struct irq_routing_table *rt;
32 ptr = mmap(0, 0x10000, PROT_READ, MAP_SHARED,
33 fd_mem, (off_t) 0xf0000);
35 if (ptr == MAP_FAILED) {
36 perror("Mapping system memory failed: ");
40 rt = (struct irq_routing_table *) memmem(ptr, 0xFFFF, signature, 4);
43 printf("Found PCI IRQ routing table signature at %p.\n",
44 (void *)((char *)rt - ptr + 0xf0000));
46 printf("No PCI IRQ routing table signature found.\n");
55 struct irq_routing_table *rt;
58 fprintf(stderr, "Run me as root, I need access to " MEM_DEV ".\n");
61 fd_mem = open(MEM_DEV, O_RDONLY);
63 perror("Could not open " MEM_DEV ":");
67 printf("Probing PIRQ table in memory.\n");
68 rt = probe_table(fd_mem);
70 printf("Validating... ");
71 if (!calc_checksum(rt))
72 printf("checksum is ok.\n");
74 printf("checksum is wrong.\n");
76 printf("Creating irq_tables.c ...\n");
77 code_gen("irq_tables.c", rt);
81 printf("Done, you can move the file to the coreboot tree now.\n");