This patch changes following in getpir application.
1 - Moved the check sum validation to probe_table function. 2 - Proper handling of resources allocated. 3 - Signature check is done in 16 byte boundaries. 4 - irq_tables.c file is created only if a valid PIRQ table is found. 5 – Makefile and README file are modified accordingly. Signed-off-by: Mohamed Mansoor <mansoor@iwavesystems.com> Acked-by: Stefan Reinauer <stepan@coresystems.de> git-svn-id: svn://svn.coreboot.org/coreboot/trunk@4680 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
This commit is contained in:
committed by
Stefan Reinauer
parent
5db685fedf
commit
bde683ce9f
@@ -5,8 +5,7 @@
|
|||||||
CC=gcc
|
CC=gcc
|
||||||
CFLAGS=-O2 -D_GNU_SOURCE -DGETPIR -Wall
|
CFLAGS=-O2 -D_GNU_SOURCE -DGETPIR -Wall
|
||||||
|
|
||||||
all: getpir checkpir
|
all: getpir
|
||||||
./checkpir
|
|
||||||
|
|
||||||
getpir: getpir.o checksum.o code_gen.o
|
getpir: getpir.o checksum.o code_gen.o
|
||||||
$(CC) $(CFLAGS) -o getpir $^
|
$(CC) $(CFLAGS) -o getpir $^
|
||||||
|
@@ -1,28 +1,30 @@
|
|||||||
ABOUT:
|
ABOUT:
|
||||||
|
|
||||||
This utility will help to create irq_table.c file, that is very hard to create manually,
|
This utility will help to create irq_table.c file, that is very hard to create
|
||||||
specialy when you are testing new motherboards, changing your hardware often, placing new cards, etc..
|
manually, specialy when you are testing new motherboards, changing your
|
||||||
|
hardware often, placing new cards, etc..
|
||||||
|
|
||||||
INSTALL:
|
|
||||||
|
|
||||||
edit Makefile, define the root to coreboot tree
|
|
||||||
make
|
|
||||||
|
|
||||||
USAGE:
|
USAGE:
|
||||||
|
|
||||||
./getpir
|
Steps
|
||||||
|
1. make distclean;
|
||||||
|
2. make getpir
|
||||||
|
3. ./getpir
|
||||||
|
|
||||||
Will dump irq table to the file called irq_tables.c, ready to use with coreboot. Just move the
|
Will dump irq table to the file called irq_tables.c, ready to use with
|
||||||
file to corresponding place in the linux bios tree.
|
coreboot. Just move the file to corresponding place in the coreboot tree.
|
||||||
|
|
||||||
|
|
||||||
CHECKING CUSTOM irq_tables.c:
|
4. CHECKING CUSTOM irq_tables.c:
|
||||||
|
|
||||||
checkpir.c Will verify the irq_tables.c, currently it only checks the checksum. In case of wrong
|
make checkpir
|
||||||
checksum, a good value is proposed, so you can edit irq_tables.c manualy and replace checksum.
|
./checkpir
|
||||||
Run the command like this:
|
|
||||||
|
|
||||||
make test
|
checkpir.c Will verify the irq_tables.c, currently it only checks the
|
||||||
|
checksum. In case of wrong checksum, a good value is proposed, so you can
|
||||||
|
edit irq_tables.c manualy and replace checksum.
|
||||||
|
|
||||||
|
|
||||||
|
Do not run make checkpir and ./checkpir directly because it needs to be linked
|
||||||
|
to irq_table.o first.
|
||||||
|
|
||||||
Do not run ./checkpir directly because it needs to be linked to irq_table.o first.
|
|
||||||
|
@@ -28,31 +28,45 @@ static struct irq_routing_table *probe_table(int fd_mem)
|
|||||||
{
|
{
|
||||||
char *ptr, signature[] = "$PIR";
|
char *ptr, signature[] = "$PIR";
|
||||||
struct irq_routing_table *rt;
|
struct irq_routing_table *rt;
|
||||||
|
int size = 16;
|
||||||
|
|
||||||
ptr = mmap(0, 0x10000, PROT_READ, MAP_SHARED,
|
ptr = mmap(0, 0x10000, PROT_READ, MAP_SHARED,
|
||||||
fd_mem, (off_t) 0xf0000);
|
fd_mem, (off_t) 0xf0000);
|
||||||
|
|
||||||
if (ptr == MAP_FAILED) {
|
if (ptr == MAP_FAILED) {
|
||||||
perror("Mapping system memory failed: ");
|
perror("Mapping system memory failed: ");
|
||||||
exit(1);
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
rt = (struct irq_routing_table *) memmem(ptr, 0xFFFF, signature, 4);
|
do {
|
||||||
|
rt = (struct irq_routing_table *) memmem(ptr + size, 16, signature, 4);
|
||||||
|
if (rt != NULL) {
|
||||||
|
printf("Found PCI IRQ routing table signature at %p.\n",
|
||||||
|
(void *) ((char *) rt - ptr + 0xf0000));
|
||||||
|
printf("Validating... ");
|
||||||
|
if (!calc_checksum(rt)) {
|
||||||
|
printf("checksum is ok.\n");
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
printf("checksum is wrong.\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
size += 16;
|
||||||
|
} while (size < 0xFFFF);
|
||||||
|
|
||||||
if (rt != NULL) {
|
if (size >= 0xFFFF) {
|
||||||
printf("Found PCI IRQ routing table signature at %p.\n",
|
|
||||||
(void *)((char *)rt - ptr + 0xf0000));
|
|
||||||
} else {
|
|
||||||
printf("No PCI IRQ routing table signature found.\n");
|
printf("No PCI IRQ routing table signature found.\n");
|
||||||
exit(1);
|
munmap(ptr, 0x10000);
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return rt;
|
return rt;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
int fd_mem;
|
int fd_mem;
|
||||||
struct irq_routing_table *rt;
|
struct irq_routing_table *rt;
|
||||||
|
|
||||||
if (getuid()) {
|
if (getuid()) {
|
||||||
fprintf(stderr, "Run me as root, I need access to " MEM_DEV ".\n");
|
fprintf(stderr, "Run me as root, I need access to " MEM_DEV ".\n");
|
||||||
@@ -66,19 +80,14 @@ int main(void)
|
|||||||
|
|
||||||
printf("Probing PIRQ table in memory.\n");
|
printf("Probing PIRQ table in memory.\n");
|
||||||
rt = probe_table(fd_mem);
|
rt = probe_table(fd_mem);
|
||||||
|
if (rt != NULL) {
|
||||||
printf("Validating... ");
|
printf("Creating irq_tables.c ...\n");
|
||||||
if (!calc_checksum(rt))
|
code_gen("irq_tables.c", rt);
|
||||||
printf("checksum is ok.\n");
|
printf
|
||||||
else
|
("Done, you can move the file to the coreboot tree now.\n");
|
||||||
printf("checksum is wrong.\n");
|
}
|
||||||
|
|
||||||
printf("Creating irq_tables.c ...\n");
|
|
||||||
code_gen("irq_tables.c", rt);
|
|
||||||
|
|
||||||
close(fd_mem);
|
close(fd_mem);
|
||||||
|
|
||||||
printf("Done, you can move the file to the coreboot tree now.\n");
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user