Home | History | Annotate | Line # | Download | only in pci
pci_6600.c revision 1.32
      1  1.32   thorpej /* $NetBSD: pci_6600.c,v 1.32 2021/07/04 22:36:43 thorpej Exp $ */
      2   1.1      ross 
      3   1.1      ross /*-
      4   1.1      ross  * Copyright (c) 1999 by Ross Harvey.  All rights reserved.
      5   1.1      ross  *
      6   1.1      ross  * Redistribution and use in source and binary forms, with or without
      7   1.1      ross  * modification, are permitted provided that the following conditions
      8   1.1      ross  * are met:
      9   1.1      ross  * 1. Redistributions of source code must retain the above copyright
     10   1.1      ross  *    notice, this list of conditions and the following disclaimer.
     11   1.1      ross  * 2. Redistributions in binary form must reproduce the above copyright
     12   1.1      ross  *    notice, this list of conditions and the following disclaimer in the
     13   1.1      ross  *    documentation and/or other materials provided with the distribution.
     14   1.1      ross  * 3. All advertising materials mentioning features or use of this software
     15   1.1      ross  *    must display the following acknowledgement:
     16   1.1      ross  *	This product includes software developed by Ross Harvey.
     17   1.1      ross  * 4. The name of Ross Harvey may not be used to endorse or promote products
     18   1.1      ross  *    derived from this software without specific prior written permission.
     19   1.1      ross  *
     20   1.1      ross  * THIS SOFTWARE IS PROVIDED BY ROSS HARVEY ``AS IS'' AND ANY EXPRESS
     21   1.1      ross  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
     22   1.1      ross  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURP0SE
     23   1.1      ross  * ARE DISCLAIMED.  IN NO EVENT SHALL ROSS HARVEY BE LIABLE FOR ANY
     24   1.1      ross  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     25   1.1      ross  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     26   1.1      ross  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     27   1.1      ross  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     28   1.1      ross  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     29   1.1      ross  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     30   1.1      ross  * SUCH DAMAGE.
     31   1.1      ross  *
     32   1.1      ross  */
     33   1.1      ross 
     34   1.1      ross #include <sys/cdefs.h>
     35   1.1      ross 
     36  1.32   thorpej __KERNEL_RCSID(0, "$NetBSD: pci_6600.c,v 1.32 2021/07/04 22:36:43 thorpej Exp $");
     37   1.1      ross 
     38   1.1      ross #include <sys/param.h>
     39   1.1      ross #include <sys/systm.h>
     40   1.1      ross #include <sys/kernel.h>
     41   1.1      ross #include <sys/device.h>
     42   1.1      ross #include <sys/malloc.h>
     43  1.28   thorpej #include <sys/cpu.h>
     44   1.6       mrg 
     45   1.1      ross #include <machine/autoconf.h>
     46   1.1      ross #define _ALPHA_BUS_DMA_PRIVATE
     47  1.23    dyoung #include <sys/bus.h>
     48   1.1      ross #include <machine/rpb.h>
     49   1.1      ross #include <machine/alpha.h>
     50   1.1      ross 
     51   1.1      ross #include <dev/pci/pcireg.h>
     52   1.1      ross #include <dev/pci/pcivar.h>
     53   1.1      ross #include <dev/pci/pciidereg.h>
     54   1.1      ross #include <dev/pci/pciidevar.h>
     55   1.1      ross 
     56   1.1      ross #include <alpha/pci/tsreg.h>
     57   1.1      ross #include <alpha/pci/tsvar.h>
     58   1.1      ross 
     59   1.1      ross #define pci_6600() { Generate ctags(1) key. }
     60   1.1      ross 
     61   1.1      ross #include "sio.h"
     62   1.1      ross #if NSIO
     63   1.1      ross #include <alpha/pci/siovar.h>
     64   1.1      ross #endif
     65   1.1      ross 
     66   1.4   thorpej #define	PCI_NIRQ		64
     67  1.27   thorpej #define	PCI_SIO_IRQ		55
     68   1.1      ross #define	PCI_STRAY_MAX		5
     69   1.1      ross 
     70   1.2   thorpej /*
     71   1.2   thorpej  * Some Tsunami models have a PCI device (the USB controller) with interrupts
     72   1.2   thorpej  * tied to ISA IRQ lines.  The IRQ is encoded as:
     73   1.2   thorpej  *
     74   1.2   thorpej  *	line = 0xe0 | isa_irq;
     75   1.2   thorpej  */
     76   1.2   thorpej #define	DEC_6600_LINE_IS_ISA(line)	((line) >= 0xe0 && (line) <= 0xef)
     77   1.2   thorpej #define	DEC_6600_LINE_ISA_IRQ(line)	((line) & 0x0f)
     78   1.2   thorpej 
     79   1.1      ross static struct tsp_config *sioprimary;
     80   1.1      ross 
     81  1.26   thorpej static void	 dec_6600_intr_disestablish(pci_chipset_tag_t, void *);
     82  1.26   thorpej static void	 *dec_6600_intr_establish(pci_chipset_tag_t, pci_intr_handle_t,
     83  1.26   thorpej 		    int, int (*func)(void *), void *);
     84  1.26   thorpej static const char *dec_6600_intr_string(pci_chipset_tag_t, pci_intr_handle_t,
     85  1.26   thorpej 		    char *, size_t);
     86  1.26   thorpej static const struct evcnt *dec_6600_intr_evcnt(pci_chipset_tag_t,
     87  1.26   thorpej 		    pci_intr_handle_t);
     88  1.26   thorpej static int	dec_6600_intr_map(const struct pci_attach_args *,
     89  1.26   thorpej 		    pci_intr_handle_t *);
     90  1.26   thorpej 
     91  1.26   thorpej static void	 *dec_6600_pciide_compat_intr_establish(device_t,
     92  1.26   thorpej 		    const struct pci_attach_args *, int,
     93  1.26   thorpej 		    int (*)(void *), void *);
     94  1.26   thorpej 
     95  1.26   thorpej static void	dec_6600_intr_enable(pci_chipset_tag_t, int irq);
     96  1.26   thorpej static void	dec_6600_intr_disable(pci_chipset_tag_t, int irq);
     97  1.28   thorpej static void	dec_6600_intr_set_affinity(pci_chipset_tag_t, int,
     98  1.28   thorpej 		    struct cpu_info *);
     99  1.32   thorpej static void	dec_6600_intr_program(pci_chipset_tag_t);
    100   1.1      ross 
    101  1.29   thorpej static void	dec_6600_intr_redistribute(void);
    102  1.29   thorpej 
    103  1.28   thorpej /*
    104  1.28   thorpej  * We keep 2 software copies of the interrupt enables: one global one,
    105  1.28   thorpej  * and one per-CPU for setting the interrupt affinity.
    106  1.28   thorpej  */
    107  1.27   thorpej static uint64_t	dec_6600_intr_enables __read_mostly;
    108  1.28   thorpej static uint64_t dec_6600_cpu_intr_enables[4] __read_mostly;
    109  1.27   thorpej 
    110  1.30   thorpej static void
    111  1.30   thorpej pci_6600_pickintr(void *core, bus_space_tag_t iot, bus_space_tag_t memt,
    112  1.30   thorpej     pci_chipset_tag_t pc)
    113   1.1      ross {
    114  1.28   thorpej 	struct cpu_info *ci;
    115  1.28   thorpej 	CPU_INFO_ITERATOR cii;
    116   1.1      ross 
    117  1.30   thorpej 	pc->pc_intr_v = core;
    118  1.24      matt 	pc->pc_intr_map = dec_6600_intr_map;
    119  1.24      matt 	pc->pc_intr_string = dec_6600_intr_string;
    120   1.3       cgd 	pc->pc_intr_evcnt = dec_6600_intr_evcnt;
    121  1.24      matt 	pc->pc_intr_establish = dec_6600_intr_establish;
    122  1.24      matt 	pc->pc_intr_disestablish = dec_6600_intr_disestablish;
    123  1.26   thorpej 
    124   1.1      ross 	pc->pc_pciide_compat_intr_establish = NULL;
    125   1.1      ross 
    126  1.31   thorpej 	pc->pc_intr_desc = "dec 6600";
    127  1.26   thorpej 	pc->pc_vecbase = 0x900;
    128  1.26   thorpej 	pc->pc_nirq = PCI_NIRQ;
    129  1.26   thorpej 
    130  1.26   thorpej 	pc->pc_intr_enable = dec_6600_intr_enable;
    131  1.26   thorpej 	pc->pc_intr_disable = dec_6600_intr_disable;
    132  1.28   thorpej 	pc->pc_intr_set_affinity = dec_6600_intr_set_affinity;
    133  1.28   thorpej 
    134  1.29   thorpej 	alpha_intr_redistribute = dec_6600_intr_redistribute;
    135  1.29   thorpej 
    136  1.28   thorpej 	/* Note eligible CPUs for interrupt routing purposes. */
    137  1.28   thorpej 	for (CPU_INFO_FOREACH(cii, ci)) {
    138  1.28   thorpej 		KASSERT(ci->ci_cpuid < 4);
    139  1.28   thorpej 		pc->pc_eligible_cpus |= __BIT(ci->ci_cpuid);
    140  1.28   thorpej 	}
    141  1.26   thorpej 
    142   1.1      ross 	/*
    143   1.1      ross 	 * System-wide and Pchip-0-only logic...
    144   1.1      ross 	 */
    145  1.26   thorpej 	if (sioprimary == NULL) {
    146  1.30   thorpej 		sioprimary = core;
    147  1.28   thorpej 		/*
    148  1.28   thorpej 		 * Unless explicitly routed, all interrupts go to the
    149  1.28   thorpej 		 * primary CPU.
    150  1.28   thorpej 		 */
    151  1.28   thorpej 		dec_6600_cpu_intr_enables[cpu_info_primary.ci_cpuid] =
    152  1.28   thorpej 		    __BITS(0,63);
    153   1.1      ross 		pc->pc_pciide_compat_intr_establish =
    154   1.1      ross 		    dec_6600_pciide_compat_intr_establish;
    155  1.32   thorpej 
    156  1.32   thorpej 		KASSERT(dec_6600_intr_enables == 0);
    157  1.32   thorpej 		dec_6600_intr_program(pc);
    158  1.32   thorpej 
    159  1.32   thorpej 		alpha_pci_intr_alloc(pc, PCI_STRAY_MAX);
    160   1.1      ross #if NSIO
    161   1.1      ross 		sio_intr_setup(pc, iot);
    162  1.28   thorpej 
    163  1.28   thorpej 		mutex_enter(&cpu_lock);
    164  1.28   thorpej 		dec_6600_intr_enable(pc, PCI_SIO_IRQ);
    165  1.28   thorpej 		mutex_exit(&cpu_lock);
    166   1.1      ross #endif
    167  1.26   thorpej 	} else {
    168  1.26   thorpej 		pc->pc_shared_intrs = sioprimary->pc_pc.pc_shared_intrs;
    169   1.1      ross 	}
    170   1.1      ross }
    171  1.30   thorpej ALPHA_PCI_INTR_INIT(ST_DEC_6600, pci_6600_pickintr)
    172  1.30   thorpej ALPHA_PCI_INTR_INIT(ST_DEC_TITAN, pci_6600_pickintr)
    173   1.1      ross 
    174  1.26   thorpej static int
    175  1.21    dyoung dec_6600_intr_map(const struct pci_attach_args *pa, pci_intr_handle_t *ihp)
    176   1.1      ross {
    177   1.7  sommerfe 	pcitag_t bustag = pa->pa_intrtag;
    178   1.7  sommerfe 	int buspin = pa->pa_intrpin, line = pa->pa_intrline;
    179   1.7  sommerfe 	pci_chipset_tag_t pc = pa->pa_pc;
    180   1.1      ross 	int bus, device, function;
    181   1.1      ross 
    182   1.1      ross 	if (buspin == 0) {
    183   1.1      ross 		/* No IRQ used. */
    184   1.1      ross 		return 1;
    185   1.1      ross 	}
    186  1.26   thorpej 	if (buspin < 0 || buspin > 4) {
    187   1.1      ross 		printf("intr_map: bad interrupt pin %d\n", buspin);
    188   1.1      ross 		return 1;
    189   1.1      ross 	}
    190   1.1      ross 
    191   1.9   thorpej 	pci_decompose_tag(pc, bustag, &bus, &device, &function);
    192   1.2   thorpej 
    193   1.1      ross 	/*
    194   1.1      ross 	 * The console places the interrupt mapping in the "line" value.
    195   1.1      ross 	 * A value of (char)-1 indicates there is no mapping.
    196   1.1      ross 	 */
    197   1.2   thorpej 	if (line == 0xff) {
    198   1.2   thorpej 		printf("dec_6600_intr_map: no mapping for %d/%d/%d\n",
    199   1.2   thorpej 		    bus, device, function);
    200   1.1      ross 		return (1);
    201   1.1      ross 	}
    202   1.1      ross 
    203   1.2   thorpej #if NSIO == 0
    204   1.2   thorpej 	if (DEC_6600_LINE_IS_ISA(line)) {
    205   1.2   thorpej 		printf("dec_6600_intr_map: ISA IRQ %d for %d/%d/%d\n",
    206   1.2   thorpej 		    DEC_6600_LINE_ISA_IRQ(line), bus, device, function);
    207   1.2   thorpej 		return (1);
    208   1.2   thorpej 	}
    209   1.2   thorpej #endif
    210   1.2   thorpej 
    211   1.4   thorpej 	if (DEC_6600_LINE_IS_ISA(line) == 0 && line >= PCI_NIRQ)
    212  1.10    provos 		panic("dec_6600_intr_map: dec 6600 irq too large (%d)",
    213   1.2   thorpej 		    line);
    214   1.1      ross 
    215  1.26   thorpej 	alpha_pci_intr_handle_init(ihp, line, 0);
    216   1.1      ross 	return (0);
    217   1.1      ross }
    218   1.1      ross 
    219  1.26   thorpej static const char *
    220  1.26   thorpej dec_6600_intr_string(pci_chipset_tag_t const pc, pci_intr_handle_t const ih,
    221  1.26   thorpej     char * const buf, size_t const len)
    222   1.1      ross {
    223  1.26   thorpej #if NSIO
    224  1.26   thorpej 	const u_int irq = alpha_pci_intr_handle_get_irq(&ih);
    225   1.1      ross 
    226  1.26   thorpej 	if (DEC_6600_LINE_IS_ISA(irq))
    227   1.2   thorpej 		return (sio_intr_string(NULL /*XXX*/,
    228  1.26   thorpej 		    DEC_6600_LINE_ISA_IRQ(irq), buf, len));
    229   1.2   thorpej #endif
    230   1.2   thorpej 
    231  1.26   thorpej 	return alpha_pci_generic_intr_string(pc, ih, buf, len);
    232   1.3       cgd }
    233   1.3       cgd 
    234  1.26   thorpej static const struct evcnt *
    235  1.26   thorpej dec_6600_intr_evcnt(pci_chipset_tag_t const pc, pci_intr_handle_t const ih)
    236   1.3       cgd {
    237  1.26   thorpej #if NSIO
    238  1.26   thorpej 	const u_int irq = alpha_pci_intr_handle_get_irq(&ih);
    239   1.3       cgd 
    240  1.26   thorpej 	if (DEC_6600_LINE_IS_ISA(irq))
    241   1.3       cgd 		return (sio_intr_evcnt(NULL /*XXX*/,
    242  1.26   thorpej 		    DEC_6600_LINE_ISA_IRQ(irq)));
    243   1.3       cgd #endif
    244   1.3       cgd 
    245  1.26   thorpej 	return alpha_pci_generic_intr_evcnt(pc, ih);
    246   1.1      ross }
    247   1.1      ross 
    248  1.26   thorpej static void *
    249  1.26   thorpej dec_6600_intr_establish(pci_chipset_tag_t const pc, pci_intr_handle_t const ih,
    250  1.26   thorpej     int const level, int (*func)(void *), void *arg)
    251   1.1      ross {
    252  1.26   thorpej #if NSIO
    253  1.26   thorpej 	const u_int irq = alpha_pci_intr_handle_get_irq(&ih);
    254  1.26   thorpej 	const u_int flags = alpha_pci_intr_handle_get_flags(&ih);
    255   1.1      ross 
    256  1.26   thorpej 	if (DEC_6600_LINE_IS_ISA(irq))
    257   1.2   thorpej 		return (sio_intr_establish(NULL /*XXX*/,
    258  1.26   thorpej 		    DEC_6600_LINE_ISA_IRQ(irq), IST_LEVEL, level, flags,
    259  1.26   thorpej 		    func, arg));
    260   1.2   thorpej #endif
    261   1.2   thorpej 
    262  1.26   thorpej 	return alpha_pci_generic_intr_establish(pc, ih, level, func, arg);
    263   1.1      ross }
    264   1.1      ross 
    265  1.26   thorpej static void
    266  1.26   thorpej dec_6600_intr_disestablish(pci_chipset_tag_t const pc, void * const cookie)
    267   1.1      ross {
    268  1.26   thorpej #if NSIO
    269  1.26   thorpej 	struct alpha_shared_intrhand * const ih = cookie;
    270   1.2   thorpej 
    271   1.2   thorpej 	/*
    272   1.2   thorpej 	 * We have to determine if this is an ISA IRQ or not!  We do this
    273   1.2   thorpej 	 * by checking to see if the intrhand points back to an intrhead
    274   1.2   thorpej 	 * that points to the sioprimary TSP.  If not, it's an ISA IRQ.
    275   1.2   thorpej 	 * Pretty disgusting, eh?
    276   1.2   thorpej 	 */
    277   1.2   thorpej 	if (ih->ih_intrhead->intr_private != sioprimary) {
    278   1.2   thorpej 		sio_intr_disestablish(NULL /*XXX*/, cookie);
    279   1.2   thorpej 		return;
    280   1.2   thorpej 	}
    281   1.2   thorpej #endif
    282  1.24      matt 
    283  1.26   thorpej 	return alpha_pci_generic_intr_disestablish(pc, cookie);
    284   1.1      ross }
    285   1.1      ross 
    286  1.26   thorpej static void
    287  1.28   thorpej dec_6600_intr_program(pci_chipset_tag_t const pc)
    288   1.1      ross {
    289  1.28   thorpej 	unsigned int irq, cpuno, cnt;
    290  1.28   thorpej 
    291  1.28   thorpej 	/*
    292  1.28   thorpej 	 * Validate the configuration before we program it: each enabled
    293  1.28   thorpej 	 * IRQ must be routed to exactly one CPU.
    294  1.28   thorpej 	 */
    295  1.28   thorpej 	for (irq = 0; irq < PCI_NIRQ; irq++) {
    296  1.28   thorpej 		if ((dec_6600_intr_enables & __BIT(irq)) == 0)
    297  1.28   thorpej 			continue;
    298  1.28   thorpej 		for (cpuno = 0, cnt = 0; cpuno < 4; cpuno++) {
    299  1.28   thorpej 			if (dec_6600_cpu_intr_enables[cpuno] != 0 &&
    300  1.28   thorpej 			    (pc->pc_eligible_cpus & __BIT(cpuno)) == 0)
    301  1.28   thorpej 				panic("%s: interrupts enabled on non-existent CPU %u",
    302  1.28   thorpej 				    __func__, cpuno);
    303  1.28   thorpej 			if (dec_6600_cpu_intr_enables[cpuno] & __BIT(irq))
    304  1.28   thorpej 				cnt++;
    305  1.28   thorpej 		}
    306  1.28   thorpej 		if (cnt != 1) {
    307  1.28   thorpej 			panic("%s: irq %u enabled on %u CPUs", __func__,
    308  1.28   thorpej 			    irq, cnt);
    309  1.28   thorpej 		}
    310  1.28   thorpej 	}
    311  1.28   thorpej 
    312  1.28   thorpej 	const uint64_t enab0 =
    313  1.28   thorpej 	    dec_6600_intr_enables & dec_6600_cpu_intr_enables[0];
    314  1.28   thorpej 	const uint64_t enab1 =
    315  1.28   thorpej 	    dec_6600_intr_enables & dec_6600_cpu_intr_enables[1];
    316  1.28   thorpej 	const uint64_t enab2 =
    317  1.28   thorpej 	    dec_6600_intr_enables & dec_6600_cpu_intr_enables[2];
    318  1.28   thorpej 	const uint64_t enab3 =
    319  1.28   thorpej 	    dec_6600_intr_enables & dec_6600_cpu_intr_enables[3];
    320  1.28   thorpej 
    321  1.28   thorpej 	/* Don't touch DIMx registers for non-existent CPUs. */
    322  1.28   thorpej 	uint64_t black_hole;
    323  1.28   thorpej 	volatile uint64_t * const dim0 = (pc->pc_eligible_cpus & __BIT(0)) ?
    324  1.28   thorpej 	    (void *)ALPHA_PHYS_TO_K0SEG(TS_C_DIM0) : &black_hole;
    325  1.28   thorpej 	volatile uint64_t * const dim1 = (pc->pc_eligible_cpus & __BIT(1)) ?
    326  1.28   thorpej 	    (void *)ALPHA_PHYS_TO_K0SEG(TS_C_DIM1) : &black_hole;
    327  1.28   thorpej 	volatile uint64_t * const dim2 = (pc->pc_eligible_cpus & __BIT(2)) ?
    328  1.28   thorpej 	    (void *)ALPHA_PHYS_TO_K0SEG(TS_C_DIM2) : &black_hole;
    329  1.28   thorpej 	volatile uint64_t * const dim3 = (pc->pc_eligible_cpus & __BIT(3)) ?
    330  1.28   thorpej 	    (void *)ALPHA_PHYS_TO_K0SEG(TS_C_DIM3) : &black_hole;
    331  1.28   thorpej 
    332  1.28   thorpej 	const unsigned long psl = alpha_pal_swpipl(ALPHA_PSL_IPL_HIGH);
    333  1.28   thorpej 
    334  1.28   thorpej 	alpha_mb();
    335  1.28   thorpej 	*dim0 = enab0;
    336  1.28   thorpej 	*dim1 = enab1;
    337  1.28   thorpej 	*dim2 = enab2;
    338  1.28   thorpej 	*dim3 = enab3;
    339   1.1      ross 	alpha_mb();
    340  1.28   thorpej 	(void) *dim0;
    341  1.28   thorpej 	(void) *dim1;
    342  1.28   thorpej 	(void) *dim2;
    343  1.28   thorpej 	(void) *dim3;
    344   1.1      ross 	alpha_mb();
    345  1.28   thorpej 
    346  1.28   thorpej 	alpha_pal_swpipl(psl);
    347   1.1      ross }
    348   1.1      ross 
    349  1.26   thorpej static void
    350  1.28   thorpej dec_6600_intr_enable(pci_chipset_tag_t const pc, int const irq)
    351   1.1      ross {
    352  1.28   thorpej 
    353  1.28   thorpej 	KASSERT(mutex_owned(&cpu_lock));
    354  1.28   thorpej 
    355  1.28   thorpej 	dec_6600_intr_enables |= __BIT(irq);
    356  1.28   thorpej 	dec_6600_intr_program(pc);
    357  1.28   thorpej }
    358  1.28   thorpej 
    359  1.28   thorpej static void
    360  1.28   thorpej dec_6600_intr_disable(pci_chipset_tag_t const pc, int const irq)
    361  1.28   thorpej {
    362  1.28   thorpej 
    363  1.28   thorpej 	KASSERT(mutex_owned(&cpu_lock));
    364  1.28   thorpej 
    365  1.28   thorpej 	dec_6600_intr_enables &= ~__BIT(irq);
    366  1.28   thorpej 	dec_6600_intr_program(pc);
    367  1.28   thorpej }
    368  1.28   thorpej 
    369  1.28   thorpej static void
    370  1.28   thorpej dec_6600_intr_set_affinity(pci_chipset_tag_t const pc, int const irq,
    371  1.28   thorpej     struct cpu_info * const ci)
    372  1.28   thorpej {
    373  1.28   thorpej 	const uint64_t intr_bit = __BIT(irq);
    374  1.28   thorpej 	cpuid_t cpuno;
    375  1.28   thorpej 
    376  1.28   thorpej 	KASSERT(mutex_owned(&cpu_lock));
    377  1.28   thorpej 	KASSERT(ci->ci_cpuid < 4);
    378  1.28   thorpej 	KASSERT(pc->pc_eligible_cpus & __BIT(ci->ci_cpuid));
    379  1.28   thorpej 
    380  1.28   thorpej 	for (cpuno = 0; cpuno < 4; cpuno++) {
    381  1.28   thorpej 		if (cpuno == ci->ci_cpuid)
    382  1.28   thorpej 			dec_6600_cpu_intr_enables[cpuno] |= intr_bit;
    383  1.28   thorpej 		else
    384  1.28   thorpej 			dec_6600_cpu_intr_enables[cpuno] &= ~intr_bit;
    385  1.28   thorpej 	}
    386  1.28   thorpej 
    387  1.28   thorpej 	/* Only program the hardware if the irq is enabled. */
    388  1.28   thorpej 	if (dec_6600_intr_enables & intr_bit)
    389  1.28   thorpej 		dec_6600_intr_program(pc);
    390   1.1      ross }
    391   1.1      ross 
    392  1.29   thorpej static void
    393  1.29   thorpej dec_6600_intr_redistribute(void)
    394  1.29   thorpej {
    395  1.29   thorpej 	KASSERT(sioprimary != NULL);
    396  1.29   thorpej 
    397  1.29   thorpej 	pci_chipset_tag_t const pc = &sioprimary->pc_pc;
    398  1.29   thorpej 
    399  1.29   thorpej 	/* ISA interrupts always stay on primary. Shuffle PCI interrupts. */
    400  1.29   thorpej 	alpha_pci_generic_intr_redistribute(pc);
    401  1.29   thorpej }
    402  1.29   thorpej 
    403  1.26   thorpej static void *
    404  1.26   thorpej dec_6600_pciide_compat_intr_establish(device_t dev,
    405  1.21    dyoung     const struct pci_attach_args *pa, int chan, int (*func)(void *), void *arg)
    406   1.1      ross {
    407  1.26   thorpej 	pci_chipset_tag_t const pc = pa->pa_pc;
    408   1.1      ross 
    409   1.2   thorpej 	/*
    410  1.26   thorpej 	 * If this isn't the TSP that holds the PCI-ISA bridge,
    411  1.26   thorpej 	 * all bets are off.
    412   1.2   thorpej 	 */
    413  1.26   thorpej 	if (pc->pc_intr_v != sioprimary)
    414   1.2   thorpej 		return (NULL);
    415   1.1      ross 
    416  1.26   thorpej 	return sio_pciide_compat_intr_establish(dev, pa, chan, func, arg);
    417   1.1      ross }
    418