2004-04-13 23:06:45 +02:00
|
|
|
/* getpir.c : This software is released under GPL
|
|
|
|
For Linuxbios use only
|
|
|
|
Aug 26 2001 , Nikolai Vladychevski, <niko@isl.net.mx>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
2004-04-15 00:24:50 +02:00
|
|
|
#include <sys/mman.h>
|
2004-04-13 23:06:45 +02:00
|
|
|
|
2004-04-14 01:19:27 +02:00
|
|
|
#include <arch/pirq_routing.h>
|
2004-04-13 23:06:45 +02:00
|
|
|
|
2004-04-15 00:24:50 +02:00
|
|
|
#define O_RDONLY 0x00
|
2004-04-13 23:06:45 +02:00
|
|
|
|
2004-04-15 00:24:50 +02:00
|
|
|
static struct irq_routing_table *probe_table(int fd_mem)
|
2004-04-13 23:06:45 +02:00
|
|
|
{
|
2004-04-15 00:24:50 +02:00
|
|
|
char *ptr, signature[] = "$PIR";
|
|
|
|
struct irq_routing_table *rt;
|
|
|
|
|
|
|
|
ptr = mmap(0, 0x10000, PROT_READ, MAP_SHARED,
|
|
|
|
fd_mem, (off_t) 0xf0000);
|
|
|
|
|
|
|
|
rt = (struct irq_routing_table *) memmem(ptr, 0xFFFF, signature, 4);
|
2004-04-13 23:06:45 +02:00
|
|
|
|
2004-04-15 00:24:50 +02:00
|
|
|
if (rt != NULL) {
|
|
|
|
printf("Found PCI IRQ Routing table signature at 0x%04x of system memory\n",
|
|
|
|
(char *) rt - ptr + 0xf0000);
|
|
|
|
} else {
|
|
|
|
printf("No PCI IRQ Routing table signature in the memory\n");
|
|
|
|
exit(1);
|
2004-04-13 23:06:45 +02:00
|
|
|
}
|
2004-04-15 00:24:50 +02:00
|
|
|
return rt;
|
2004-04-13 23:06:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
main()
|
|
|
|
{
|
2004-04-15 00:24:50 +02:00
|
|
|
int fd_mem;
|
|
|
|
struct irq_routing_table *rt;
|
2004-04-13 23:06:45 +02:00
|
|
|
|
|
|
|
if (getuid()) {
|
|
|
|
perror("Run me as root, I need access to /dev/mem");
|
|
|
|
exit(1);
|
|
|
|
}
|
2004-04-15 00:24:50 +02:00
|
|
|
fd_mem = open("/dev/mem", O_RDONLY);
|
2004-04-13 23:06:45 +02:00
|
|
|
|
2004-04-15 00:24:50 +02:00
|
|
|
printf("Probing PIRQ table in memory\n");
|
|
|
|
rt = probe_table(fd_mem);
|
2004-04-13 23:06:45 +02:00
|
|
|
|
2004-04-15 00:24:50 +02:00
|
|
|
printf("Validating..\n");
|
|
|
|
if (!calc_checksum(rt))
|
2004-04-13 23:06:45 +02:00
|
|
|
printf("Checksum is ok!\n");
|
|
|
|
|
|
|
|
printf("Creating irq_tables.c .....\n");
|
2004-09-07 23:31:06 +02:00
|
|
|
code_gen("irq_tables.c", rt);
|
2004-04-15 00:24:50 +02:00
|
|
|
|
|
|
|
close(fd_mem);
|
|
|
|
|
2004-04-13 23:06:45 +02:00
|
|
|
printf("Done, you can move the file to the LinuxBios tree now.\n");
|
|
|
|
}
|