summaryrefslogtreecommitdiff
path: root/util/getpir/checkpir.c
blob: efcc9182ccad6dcb428072ba91a8aafe45e76587 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/* checkpir.c : This software is released under GPL
   For Linuxbios use only
   Aug 26 2001 , Nikolai Vladychevski, <niko@isl.net.mx>
*/

#include <stdio.h>

#include <device/pci.h>
#include <arch/pirq_routing.h>

struct irq_info se_arr[50];
struct irq_routing_table *rt;

int calc_checksum(struct irq_routing_table *rt)
{
	long sum = 0, i;
	uint8_t *addr, sum2 = 0;

	addr = (uint8_t *) rt;
	for (i = 0; i < rt->size; i++)
		sum2 += addr[i];
	return (sum2);
}

main()
{
	uint8_t sum, newsum;

	rt = (struct irq_routing_table *) &intel_irq_routing_table;
	sum = calc_checksum(rt);

	printf("Validating checksum, file: irq_tables.c that was in ./ at compile time...\n");
	printf("(no other tests are done)\n");

	if (!sum) {
		printf("Checksum for IRQ Routing table is ok. You can use it in LinuxBios now\n");
	} else {
		newsum = rt->checksum - sum;
		printf("BAD CHECKSUM for IRQ Routing table !!!!\n");
		printf("If you want to make it valid, change the checksum to: %#x\n",
		       newsum);
	}
}