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

📄 open_pic.c

📁 microwindows移植到S3C44B0的源码
💻 C
📖 第 1 页 / 共 2 页
字号:
	 * the ISU array is setup in chrp_pci.c in ibm_add_bridges	 * as a result	 * -- tgall         */	/* basically each ISU is a bus, and this assumes that	 * open_pic_isu_count interrupts per bus are possible 	 * ISU == Interrupt Source	 */	NumSources = NumISUs * 0x10;	openpic_vec_ipi = NumSources + open_pic_irq_offset;	openpic_vec_timer = openpic_vec_ipi + OPENPIC_NUM_IPI; 	openpic_vec_spurious = openpic_vec_timer + OPENPIC_NUM_TIMERS;}static inline void openpic_reset(void){	openpic_setfield(&OpenPIC->Global.Global_Configuration0,			 OPENPIC_CONFIG_RESET);}static inline void openpic_enable_8259_pass_through(void){	openpic_clearfield(&OpenPIC->Global.Global_Configuration0,			   OPENPIC_CONFIG_8259_PASSTHROUGH_DISABLE);}static void openpic_disable_8259_pass_through(void){	openpic_setfield(&OpenPIC->Global.Global_Configuration0,			 OPENPIC_CONFIG_8259_PASSTHROUGH_DISABLE);}/* *  Find out the current interrupt */static u_int openpic_irq(void){	u_int vec;	DECL_THIS_CPU;	CHECK_THIS_CPU;	vec = openpic_readfield(&OpenPIC->THIS_CPU.Interrupt_Acknowledge,				OPENPIC_VECTOR_MASK);	return vec;}static void openpic_eoi(void){	DECL_THIS_CPU;	CHECK_THIS_CPU;	openpic_write(&OpenPIC->THIS_CPU.EOI, 0);	/* Handle PCI write posting */	(void)openpic_read(&OpenPIC->THIS_CPU.EOI);}static inline u_int openpic_get_priority(void){	DECL_THIS_CPU;	CHECK_THIS_CPU;	return openpic_readfield(&OpenPIC->THIS_CPU.Current_Task_Priority,				 OPENPIC_CURRENT_TASK_PRIORITY_MASK);}static void openpic_set_priority(u_int pri){	DECL_THIS_CPU;	CHECK_THIS_CPU;	check_arg_pri(pri);	openpic_writefield(&OpenPIC->THIS_CPU.Current_Task_Priority,			   OPENPIC_CURRENT_TASK_PRIORITY_MASK, pri);}/* *  Get/set the spurious vector */static inline u_int openpic_get_spurious(void){	return openpic_readfield(&OpenPIC->Global.Spurious_Vector,				 OPENPIC_VECTOR_MASK);}static void openpic_set_spurious(u_int vec){	check_arg_vec(vec);	openpic_writefield(&OpenPIC->Global.Spurious_Vector, OPENPIC_VECTOR_MASK,			   vec);}/* * Convert a cpu mask from logical to physical cpu numbers. */static inline u32 physmask(u32 cpumask){	int i;	u32 mask = 0;	for (i = 0; i < smp_num_cpus; ++i, cpumask >>= 1)		mask |= (cpumask & 1) << get_hard_smp_processor_id(i);	return mask;}void openpic_init_processor(u_int cpumask){	openpic_write(&OpenPIC->Global.Processor_Initialization,		      physmask(cpumask));}#ifdef CONFIG_SMP/* *  Initialize an interprocessor interrupt (and disable it) * *  ipi: OpenPIC interprocessor interrupt number *  pri: interrupt source priority *  vec: the vector it will produce */static void __init openpic_initipi(u_int ipi, u_int pri, u_int vec){	check_arg_ipi(ipi);	check_arg_pri(pri);	check_arg_vec(vec);	openpic_safe_writefield_IPI(&OpenPIC->Global.IPI_Vector_Priority(ipi),				OPENPIC_PRIORITY_MASK | OPENPIC_VECTOR_MASK,				(pri << OPENPIC_PRIORITY_SHIFT) | vec);}/* *  Send an IPI to one or more CPUs *   *  Externally called, however, it takes an IPI number (0...OPENPIC_NUM_IPI) *  and not a system-wide interrupt number */void openpic_cause_IPI(u_int ipi, u_int cpumask){	DECL_THIS_CPU;	CHECK_THIS_CPU;	check_arg_ipi(ipi);	openpic_write(&OpenPIC->THIS_CPU.IPI_Dispatch(ipi),		      physmask(cpumask));}void openpic_request_IPIs(void){	int i;		/*	 * Make sure this matches what is defined in smp.c for 	 * smp_message_{pass|recv}() or what shows up in 	 * /proc/interrupts will be wrong!!! --Troy */		if (OpenPIC == NULL)		return;	request_irq(openpic_vec_ipi,		    openpic_ipi_action, 0, "IPI0 (call function)", 0);	request_irq(openpic_vec_ipi+1,		    openpic_ipi_action, 0, "IPI1 (reschedule)", 0);	request_irq(openpic_vec_ipi+2,		    openpic_ipi_action, 0, "IPI2 (invalidate tlb)", 0);	request_irq(openpic_vec_ipi+3,		    openpic_ipi_action, 0, "IPI3 (xmon break)", 0);	for ( i = 0; i < OPENPIC_NUM_IPI ; i++ )		openpic_enable_ipi(openpic_vec_ipi+i);}/* * Do per-cpu setup for SMP systems. * * Get IPI's working and start taking interrupts. *   -- Cort */static spinlock_t openpic_setup_lock __initdata = SPIN_LOCK_UNLOCKED;void __init do_openpic_setup_cpu(void){#ifdef CONFIG_IRQ_ALL_CPUS 	int i;	u32 msk = 1 << hard_smp_processor_id();#endif	spin_lock(&openpic_setup_lock);#ifdef CONFIG_IRQ_ALL_CPUS 	/* let the openpic know we want intrs. default affinity 	 * is 0xffffffff until changed via /proc 	 * That's how it's done on x86. If we want it differently, then 	 * we should make sure we also change the default values of irq_affinity 	 * in irq.c. 	 */ 	for (i = 0; i < NumSources ; i++)		openpic_mapirq(i, openpic_read(&GET_ISU(i).Destination) | msk);#endif /* CONFIG_IRQ_ALL_CPUS */ 	openpic_set_priority(0);	spin_unlock(&openpic_setup_lock);}#endif /* CONFIG_SMP *//* *  Initialize a timer interrupt (and disable it) * *  timer: OpenPIC timer number *  pri: interrupt source priority *  vec: the vector it will produce */static void __init openpic_inittimer(u_int timer, u_int pri, u_int vec){	check_arg_timer(timer);	check_arg_pri(pri);	check_arg_vec(vec);	openpic_safe_writefield(&OpenPIC->Global.Timer[timer].Vector_Priority,				OPENPIC_PRIORITY_MASK | OPENPIC_VECTOR_MASK,				(pri << OPENPIC_PRIORITY_SHIFT) | vec);}/* *  Map a timer interrupt to one or more CPUs */static void __init openpic_maptimer(u_int timer, u_int cpumask){	check_arg_timer(timer);	openpic_write(&OpenPIC->Global.Timer[timer].Destination,		      physmask(cpumask));}/* * * All functions below take an offset'ed irq argument * *//* *  Enable/disable an external interrupt source * *  Externally called, irq is an offseted system-wide interrupt number */static void openpic_enable_irq(u_int irq){	unsigned int loops = 100000;	check_arg_irq(irq);	openpic_clearfield(&GET_ISU(irq - open_pic_irq_offset).Vector_Priority, OPENPIC_MASK);	/* make sure mask gets to controller before we return to user */	do {		if (!loops--) {			printk(KERN_ERR "openpic_enable_irq timeout\n");			break;		}		mb(); /* sync is probably useless here */	} while(openpic_readfield(&GET_ISU(irq - open_pic_irq_offset).Vector_Priority,			OPENPIC_MASK));}static void openpic_disable_irq(u_int irq){	u32 vp;	unsigned int loops = 100000;		check_arg_irq(irq);	openpic_setfield(&GET_ISU(irq - open_pic_irq_offset).Vector_Priority, OPENPIC_MASK);	/* make sure mask gets to controller before we return to user */	do {		if (!loops--) {			printk(KERN_ERR "openpic_disable_irq timeout\n");			break;		}		mb();  /* sync is probably useless here */		vp = openpic_readfield(&GET_ISU(irq - open_pic_irq_offset).Vector_Priority,    			OPENPIC_MASK | OPENPIC_ACTIVITY);	} while((vp & OPENPIC_ACTIVITY) && !(vp & OPENPIC_MASK));}#ifdef CONFIG_SMP/* *  Enable/disable an IPI interrupt source *   *  Externally called, irq is an offseted system-wide interrupt number */void openpic_enable_ipi(u_int irq){	irq -= openpic_vec_ipi;	check_arg_ipi(irq);	openpic_clearfield_IPI(&OpenPIC->Global.IPI_Vector_Priority(irq), OPENPIC_MASK);}void openpic_disable_ipi(u_int irq){   /* NEVER disable an IPI... that's just plain wrong! */}#endif/* *  Initialize an interrupt source (and disable it!) * *  irq: OpenPIC interrupt number *  pri: interrupt source priority *  vec: the vector it will produce *  pol: polarity (1 for positive, 0 for negative) *  sense: 1 for level, 0 for edge */static void openpic_initirq(u_int irq, u_int pri, u_int vec, int pol, int sense){	openpic_safe_writefield(&GET_ISU(irq).Vector_Priority,				OPENPIC_PRIORITY_MASK | OPENPIC_VECTOR_MASK |				OPENPIC_SENSE_MASK | OPENPIC_POLARITY_MASK,				(pri << OPENPIC_PRIORITY_SHIFT) | vec |				(pol ? OPENPIC_POLARITY_POSITIVE :			    		OPENPIC_POLARITY_NEGATIVE) |				(sense ? OPENPIC_SENSE_LEVEL : OPENPIC_SENSE_EDGE));}/* *  Map an interrupt source to one or more CPUs */static void openpic_mapirq(u_int irq, u_int physmask){	openpic_write(&GET_ISU(irq).Destination, physmask);}/* *  Set the sense for an interrupt source (and disable it!) * *  sense: 1 for level, 0 for edge */static inline void openpic_set_sense(u_int irq, int sense){	openpic_safe_writefield(&GET_ISU(irq).Vector_Priority,				OPENPIC_SENSE_LEVEL,				(sense ? OPENPIC_SENSE_LEVEL : 0));}/* No spinlocks, should not be necessary with the OpenPIC * (1 register = 1 interrupt and we have the desc lock). */static void openpic_ack_irq(unsigned int irq_nr){}static void openpic_end_irq(unsigned int irq_nr){	if ((irq_desc[irq_nr].status & IRQ_LEVEL) != 0)		openpic_eoi();}static void openpic_set_affinity(unsigned int irq_nr, unsigned long cpumask){	openpic_mapirq(irq_nr - open_pic_irq_offset, physmask(cpumask));}#ifdef CONFIG_SMPstatic void openpic_ack_ipi(unsigned int irq_nr){}static void openpic_end_ipi(unsigned int irq_nr){	/* IPIs are marked IRQ_PER_CPU. This has the side effect of	 * preventing the IRQ_PENDING/IRQ_INPROGRESS logic from	 * applying to them. We EOI them late to avoid re-entering.	 * however, I'm wondering if we could simply let them have the	 * SA_INTERRUPT flag and let them execute with all interrupts OFF.	 * This would have the side effect of either running cross-CPU	 * functions with interrupts off, or we can re-enable them explicitely	 * with a __sti() in smp_call_function_interrupt(), since	 * smp_call_function() is protected by a spinlock.	 * Or maybe we shouldn't set the IRQ_PER_CPU flag on cross-CPU	 * function calls IPI at all but that would make a special case.	 */	openpic_eoi();}static void openpic_ipi_action(int cpl, void *dev_id, struct pt_regs *regs){	smp_message_recv(cpl-openpic_vec_ipi, regs);}#endif /* CONFIG_SMP */int openpic_get_irq(struct pt_regs *regs){	extern int i8259_irq(int cpu);	int irq = openpic_irq();	/* Management of the cascade should be moved out of here */        if (open_pic_irq_offset && irq == open_pic_irq_offset)        {                /*                 * This magic address generates a PCI IACK cycle.                 */		if ( chrp_int_ack_special )			irq = *chrp_int_ack_special;		else			irq = i8259_irq( smp_processor_id() );		openpic_eoi();        }	if (irq == openpic_vec_spurious)		irq = -1;	return irq;}

⌨️ 快捷键说明

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