From 4eac397f2fb90763d34b54812e28c3db4d2a95ce Mon Sep 17 00:00:00 2001 From: christos Date: Fri, 30 Apr 2004 02:45:37 +0000 Subject: [PATCH] Add code to deal with the losing Libretto L2/L3 pcibios. From Masanori Kanaoka. I've been sitting on this code for 3 years, and have not done anything better with it. It is ugly, it needs to be handled better, but it is better to have it #ifdef'ed out rather than nothing. --- sys/arch/i386/pci/pcibios.c | 56 +++++++++++++++++++++++++++++++++++-- 1 file changed, 54 insertions(+), 2 deletions(-) diff --git a/sys/arch/i386/pci/pcibios.c b/sys/arch/i386/pci/pcibios.c index d2eef741d99b..475b3a1e46f4 100644 --- a/sys/arch/i386/pci/pcibios.c +++ b/sys/arch/i386/pci/pcibios.c @@ -1,4 +1,4 @@ -/* $NetBSD: pcibios.c,v 1.17 2004/04/24 15:09:54 uwe Exp $ */ +/* $NetBSD: pcibios.c,v 1.18 2004/04/30 02:45:37 christos Exp $ */ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc. @@ -67,7 +67,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pcibios.c,v 1.17 2004/04/24 15:09:54 uwe Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pcibios.c,v 1.18 2004/04/30 02:45:37 christos Exp $"); #include "opt_pcibios.h" @@ -119,6 +119,20 @@ int pcibios_get_intr_routing(struct pcibios_intr_routing *, int pcibios_return_code(u_int16_t, const char *); void pcibios_print_exclirq(void); + +#ifdef PCIBIOS_LIBRETTO_FIXUP +/* for Libretto L2/L3 hack */ +static void pcibios_fixup_pir_table(void); +static void pcibios_fixup_pir_table_mask(struct pcibios_linkmap *); + +struct pcibios_linkmap pir_mask[] = { + { 2, 0x0040 }, + { 7, 0x0080 }, + { 8, 0x0020 }, + { 0, 0x0000 } +}; +#endif + #ifdef PCIINTR_DEBUG void pcibios_print_pir_table(void); #endif @@ -301,6 +315,11 @@ pcibios_pir_init() } printf("\n"); pcibios_print_exclirq(); + +#ifdef PCIBIOS_LIBRETTO_FIXUP + /* for Libretto L2/L3 hack */ + pcibios_fixup_pir_table(); +#endif #ifdef PCIINTR_DEBUG pcibios_print_pir_table(); #endif @@ -333,6 +352,11 @@ pcibios_pir_init() printf("PCI BIOS has %d Interrupt Routing table entries\n", pcibios_pir_table_nentries); pcibios_print_exclirq(); + +#ifdef PCIBIOS_LIBRETTO_FIXUP + /* for Libretto L2/L3 hack */ + pcibios_fixup_pir_table(); +#endif #ifdef PCIINTR_DEBUG pcibios_print_pir_table(); #endif @@ -474,6 +498,34 @@ pcibios_print_exclirq() } } +#ifdef PCIBIOS_LIBRETTO_FIXUP +/* for Libretto L2/L3 hack */ +static void +pcibios_fixup_pir_table() +{ + struct pcibios_linkmap *m; + + for (m = pir_mask; m->link != 0; m++) + pcibios_fixup_pir_table_mask(m); +} + +void +pcibios_fixup_pir_table_mask(mask) + struct pcibios_linkmap *mask; +{ + int i, j; + + for (i = 0; i < pcibios_pir_table_nentries; i++) { + for (j = 0; j < 4; j++) { + if (pcibios_pir_table[i].linkmap[j].link == mask->link) { + pcibios_pir_table[i].linkmap[j].bitmap + &= mask->bitmap; + } + } + } +} +#endif + #ifdef PCIINTR_DEBUG void pcibios_print_pir_table()