⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 irq.c

📁 LINUX 2.6.17.4的源码
💻 C
📖 第 1 页 / 共 2 页
字号:
	for (i = 0; i < NR_IRQS; i++) {		irq_desc[i].status = IRQ_DISABLED;		irq_desc[i].action = 0;		irq_desc[i].depth = 1;		if (i < BCM1480_NR_IRQS) {			irq_desc[i].handler = &bcm1480_irq_type;			bcm1480_irq_owner[i] = 0;		} else {			irq_desc[i].handler = &no_irq_type;		}	}}static irqreturn_t bcm1480_dummy_handler(int irq, void *dev_id,	struct pt_regs *regs){	return IRQ_NONE;}static struct irqaction bcm1480_dummy_action = {	.handler = bcm1480_dummy_handler,	.flags   = 0,	.mask    = CPU_MASK_NONE,	.name    = "bcm1480-private",	.next    = NULL,	.dev_id  = 0};int bcm1480_steal_irq(int irq){	irq_desc_t *desc = irq_desc + irq;	unsigned long flags;	int retval = 0;	if (irq >= BCM1480_NR_IRQS)		return -EINVAL;	spin_lock_irqsave(&desc->lock,flags);	/* Don't allow sharing at all for these */	if (desc->action != NULL)		retval = -EBUSY;	else {		desc->action = &bcm1480_dummy_action;		desc->depth = 0;	}	spin_unlock_irqrestore(&desc->lock,flags);	return 0;}/* *  init_IRQ is called early in the boot sequence from init/main.c.  It *  is responsible for setting up the interrupt mapper and installing the *  handler that will be responsible for dispatching interrupts to the *  "right" place. *//* * For now, map all interrupts to IP[2].  We could save * some cycles by parceling out system interrupts to different * IP lines, but keep it simple for bringup.  We'll also direct * all interrupts to a single CPU; we should probably route * PCI and LDT to one cpu and everything else to the other * to balance the load a bit. * * On the second cpu, everything is set to IP5, which is * ignored, EXCEPT the mailbox interrupt.  That one is * set to IP[2] so it is handled.  This is needed so we * can do cross-cpu function calls, as requred by SMP */#define IMR_IP2_VAL	K_BCM1480_INT_MAP_I0#define IMR_IP3_VAL	K_BCM1480_INT_MAP_I1#define IMR_IP4_VAL	K_BCM1480_INT_MAP_I2#define IMR_IP5_VAL	K_BCM1480_INT_MAP_I3#define IMR_IP6_VAL	K_BCM1480_INT_MAP_I4void __init arch_init_irq(void){	unsigned int i, cpu;	u64 tmp;	unsigned int imask = STATUSF_IP4 | STATUSF_IP3 | STATUSF_IP2 |		STATUSF_IP1 | STATUSF_IP0;	/* Default everything to IP2 */	/* Start with _high registers which has no bit 0 interrupt source */	for (i = 1; i < BCM1480_NR_IRQS_HALF; i++) {	/* was I0 */		for (cpu = 0; cpu < 4; cpu++) {			__raw_writeq(IMR_IP2_VAL,				     IOADDR(A_BCM1480_IMR_REGISTER(cpu,								   R_BCM1480_IMR_INTERRUPT_MAP_BASE_H) + (i << 3)));		}	}	/* Now do _low registers */	for (i = 0; i < BCM1480_NR_IRQS_HALF; i++) {		for (cpu = 0; cpu < 4; cpu++) {			__raw_writeq(IMR_IP2_VAL,				     IOADDR(A_BCM1480_IMR_REGISTER(cpu,								   R_BCM1480_IMR_INTERRUPT_MAP_BASE_L) + (i << 3)));		}	}	init_bcm1480_irqs();	/*	 * Map the high 16 bits of mailbox_0 registers to IP[3], for	 * inter-cpu messages	 */	/* Was I1 */	for (cpu = 0; cpu < 4; cpu++) {		__raw_writeq(IMR_IP3_VAL, IOADDR(A_BCM1480_IMR_REGISTER(cpu, R_BCM1480_IMR_INTERRUPT_MAP_BASE_H) +						 (K_BCM1480_INT_MBOX_0_0 << 3)));        }	/* Clear the mailboxes.  The firmware may leave them dirty */	for (cpu = 0; cpu < 4; cpu++) {		__raw_writeq(0xffffffffffffffffULL,			     IOADDR(A_BCM1480_IMR_REGISTER(cpu, R_BCM1480_IMR_MAILBOX_0_CLR_CPU)));		__raw_writeq(0xffffffffffffffffULL,			     IOADDR(A_BCM1480_IMR_REGISTER(cpu, R_BCM1480_IMR_MAILBOX_1_CLR_CPU)));	}	/* Mask everything except the high 16 bit of mailbox_0 registers for all cpus */	tmp = ~((u64) 0) ^ ( (((u64) 1) << K_BCM1480_INT_MBOX_0_0));	for (cpu = 0; cpu < 4; cpu++) {		__raw_writeq(tmp, IOADDR(A_BCM1480_IMR_REGISTER(cpu, R_BCM1480_IMR_INTERRUPT_MASK_H)));	}	tmp = ~((u64) 0);	for (cpu = 0; cpu < 4; cpu++) {		__raw_writeq(tmp, IOADDR(A_BCM1480_IMR_REGISTER(cpu, R_BCM1480_IMR_INTERRUPT_MASK_L)));	}	bcm1480_steal_irq(K_BCM1480_INT_MBOX_0_0);	/*	 * Note that the timer interrupts are also mapped, but this is	 * done in bcm1480_time_init().  Also, the profiling driver	 * does its own management of IP7.	 */#ifdef CONFIG_KGDB	imask |= STATUSF_IP6;#endif	/* Enable necessary IPs, disable the rest */	change_c0_status(ST0_IM, imask);#ifdef CONFIG_KGDB	if (kgdb_flag) {		kgdb_irq = K_BCM1480_INT_UART_0 + kgdb_port;#ifdef CONFIG_SIBYTE_SB1250_DUART		sb1250_duart_present[kgdb_port] = 0;#endif		/* Setup uart 1 settings, mapper */		/* QQQ FIXME */		__raw_writeq(M_DUART_IMR_BRK, IO_SPACE_BASE + A_DUART_IMRREG(kgdb_port));		bcm1480_steal_irq(kgdb_irq);		__raw_writeq(IMR_IP6_VAL,			     IO_SPACE_BASE + A_BCM1480_IMR_REGISTER(0, R_BCM1480_IMR_INTERRUPT_MAP_BASE_H) +			     (kgdb_irq<<3));		bcm1480_unmask_irq(0, kgdb_irq);#ifdef CONFIG_GDB_CONSOLE		register_gdb_console();#endif		prom_printf("Waiting for GDB on UART port %d\n", kgdb_port);		set_debug_traps();		breakpoint();	}#endif}#ifdef CONFIG_KGDB#include <linux/delay.h>#define duart_out(reg, val)     csr_out32(val, IOADDR(A_DUART_CHANREG(kgdb_port,reg)))#define duart_in(reg)           csr_in32(IOADDR(A_DUART_CHANREG(kgdb_port,reg)))void bcm1480_kgdb_interrupt(struct pt_regs *regs){	/*	 * Clear break-change status (allow some time for the remote	 * host to stop the break, since we would see another	 * interrupt on the end-of-break too)	 */	kstat.irqs[smp_processor_id()][kgdb_irq]++;	mdelay(500);	duart_out(R_DUART_CMD, V_DUART_MISC_CMD_RESET_BREAK_INT |				M_DUART_RX_EN | M_DUART_TX_EN);	set_async_breakpoint(&regs->cp0_epc);}#endif 	/* CONFIG_KGDB */static inline int dclz(unsigned long long x){	int lz;	__asm__ (	"	.set	push						\n"	"	.set	mips64						\n"	"	dclz	%0, %1						\n"	"	.set	pop						\n"	: "=r" (lz)	: "r" (x));	return lz;}extern void bcm1480_timer_interrupt(struct pt_regs *regs);extern void bcm1480_mailbox_interrupt(struct pt_regs *regs);extern void bcm1480_kgdb_interrupt(struct pt_regs *regs);asmlinkage void plat_irq_dispatch(struct pt_regs *regs){	unsigned int pending;#ifdef CONFIG_SIBYTE_BCM1480_PROF	/* Set compare to count to silence count/compare timer interrupts */	write_c0_compare(read_c0_count());#endif	pending = read_c0_cause();#ifdef CONFIG_SIBYTE_BCM1480_PROF	if (pending & CAUSEF_IP7)	/* Cpu performance counter interrupt */		sbprof_cpu_intr(exception_epc(regs));#endif	if (pending & CAUSEF_IP4)		bcm1480_timer_interrupt(regs);#ifdef CONFIG_SMP	if (pending & CAUSEF_IP3)		bcm1480_mailbox_interrupt(regs);#endif#ifdef CONFIG_KGDB	if (pending & CAUSEF_IP6)		bcm1480_kgdb_interrupt(regs);		/* KGDB (uart 1) */#endif	if (pending & CAUSEF_IP2) {		unsigned long long mask_h, mask_l;		unsigned long base;		/*		 * Default...we've hit an IP[2] interrupt, which means we've		 * got to check the 1480 interrupt registers to figure out what		 * to do.  Need to detect which CPU we're on, now that		 * smp_affinity is supported.		 */		base = A_BCM1480_IMR_MAPPER(smp_processor_id());		mask_h = __raw_readq(			IOADDR(base + R_BCM1480_IMR_INTERRUPT_STATUS_BASE_H));		mask_l = __raw_readq(			IOADDR(base + R_BCM1480_IMR_INTERRUPT_STATUS_BASE_L));		if (!mask_h) {			if (mask_h ^ 1)				do_IRQ(63 - dclz(mask_h), regs);			else				do_IRQ(127 - dclz(mask_l), regs);		}	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -