2003-04-22 21:02:15 +02:00
|
|
|
#include <console/console.h>
|
|
|
|
#include <arch/pirq_routing.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2004-03-23 18:41:15 +01:00
|
|
|
#if (DEBUG==1 && HAVE_PIRQ_TABLE==1)
|
2004-06-07 12:25:42 +02:00
|
|
|
static void check_pirq_routing_table(struct irq_routing_table *rt)
|
2003-04-22 21:02:15 +02:00
|
|
|
{
|
2004-06-07 12:25:42 +02:00
|
|
|
uint8_t *addr = (uint8_t *)rt;
|
|
|
|
uint8_t sum=0;
|
2003-04-22 21:02:15 +02:00
|
|
|
int i;
|
|
|
|
|
2004-06-07 12:25:42 +02:00
|
|
|
printk_info("Checking IRQ routing table consistency...\n");
|
2003-04-22 21:02:15 +02:00
|
|
|
|
2003-04-24 08:56:37 +02:00
|
|
|
#if defined(IRQ_SLOT_COUNT)
|
2004-06-07 12:25:42 +02:00
|
|
|
if (sizeof(struct irq_routing_table) != rt->size) {
|
2003-10-28 18:02:10 +01:00
|
|
|
printk_warning("Inconsistent IRQ routing table size (0x%x/0x%x)\n",
|
2004-06-07 12:25:42 +02:00
|
|
|
sizeof(struct irq_routing_table),
|
|
|
|
rt->size
|
2004-04-15 19:33:21 +02:00
|
|
|
);
|
2004-06-07 12:25:42 +02:00
|
|
|
rt->size=sizeof(struct irq_routing_table);
|
2003-04-22 21:02:15 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
for (i = 0; i < rt->size; i++)
|
|
|
|
sum += addr[i];
|
|
|
|
|
2005-01-19 15:06:41 +01:00
|
|
|
printk_debug("%s() - irq_routing_table located at: 0x%p\n",
|
|
|
|
__FUNCTION__, addr);
|
2003-04-22 21:02:15 +02:00
|
|
|
|
2003-04-25 04:02:25 +02:00
|
|
|
|
|
|
|
sum = rt->checksum - sum;
|
2003-04-22 21:02:15 +02:00
|
|
|
|
|
|
|
if (sum != rt->checksum) {
|
|
|
|
printk_warning("%s:%6d:%s() - "
|
2004-04-15 19:33:21 +02:00
|
|
|
"checksum is: 0x%02x but should be: 0x%02x\n",
|
|
|
|
__FILE__, __LINE__, __FUNCTION__, rt->checksum, sum);
|
2003-10-28 18:02:10 +01:00
|
|
|
rt->checksum = sum;
|
2003-04-22 21:02:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (rt->signature != PIRQ_SIGNATURE || rt->version != PIRQ_VERSION ||
|
2004-06-07 12:25:42 +02:00
|
|
|
rt->size % 16 ) {
|
2003-04-22 21:02:15 +02:00
|
|
|
printk_warning("%s:%6d:%s() - "
|
2004-04-15 19:33:21 +02:00
|
|
|
"Interrupt Routing Table not valid\n",
|
|
|
|
__FILE__, __LINE__, __FUNCTION__);
|
2003-04-22 21:02:15 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
sum = 0;
|
|
|
|
for (i=0; i<rt->size; i++)
|
|
|
|
sum += addr[i];
|
|
|
|
|
|
|
|
if (sum) {
|
|
|
|
printk_warning("%s:%6d:%s() - "
|
2004-04-15 19:33:21 +02:00
|
|
|
"checksum error in irq routing table\n",
|
|
|
|
__FILE__, __LINE__, __FUNCTION__);
|
2003-04-22 21:02:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
printk_info("done.\n");
|
|
|
|
}
|
|
|
|
|
2004-06-07 12:25:42 +02:00
|
|
|
static int verify_copy_pirq_routing_table(unsigned long addr)
|
2003-04-22 21:02:15 +02:00
|
|
|
{
|
|
|
|
int i;
|
2003-04-24 08:56:37 +02:00
|
|
|
uint8_t *rt_orig, *rt_curr;
|
2003-04-22 21:02:15 +02:00
|
|
|
|
2003-04-24 08:56:37 +02:00
|
|
|
rt_curr = (uint8_t*)addr;
|
|
|
|
rt_orig = (uint8_t*)&intel_irq_routing_table;
|
2004-01-26 11:54:44 +01:00
|
|
|
printk_info("Verifing copy of IRQ routing tables at 0x%x...", addr);
|
2003-04-22 21:02:15 +02:00
|
|
|
for (i = 0; i < intel_irq_routing_table.size; i++) {
|
|
|
|
if (*(rt_curr + i) != *(rt_orig + i)) {
|
|
|
|
printk_info("failed\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
2004-01-26 11:54:44 +01:00
|
|
|
printk_info("done\n");
|
2004-06-07 12:25:42 +02:00
|
|
|
|
|
|
|
check_pirq_routing_table((struct irq_routing_table *)addr);
|
|
|
|
|
2003-04-22 21:02:15 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
#define verify_copy_pirq_routing_table(addr)
|
|
|
|
#endif
|
|
|
|
|
2004-03-23 18:41:15 +01:00
|
|
|
#if HAVE_PIRQ_TABLE==1
|
2003-04-22 21:02:15 +02:00
|
|
|
unsigned long copy_pirq_routing_table(unsigned long addr)
|
|
|
|
{
|
|
|
|
/* Align the table to be 16 byte aligned. */
|
|
|
|
addr += 15;
|
|
|
|
addr &= ~15;
|
|
|
|
|
|
|
|
/* This table must be betweeen 0xf0000 & 0x100000 */
|
|
|
|
printk_info("Copying IRQ routing tables to 0x%x...", addr);
|
|
|
|
memcpy((void *)addr, &intel_irq_routing_table, intel_irq_routing_table.size);
|
|
|
|
printk_info("done.\n");
|
|
|
|
verify_copy_pirq_routing_table(addr);
|
|
|
|
return addr + intel_irq_routing_table.size;
|
|
|
|
}
|
2004-03-23 18:41:15 +01:00
|
|
|
#endif
|