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

📄 int.c

📁 mmc_qspi.tar.gz mmc block driver code for uClinux
💻 C
字号:
#include <linux/kernel.h>#include <linux/sched.h>#include <linux/interrupt.h>#include "int.h"#include "klog.h"/* function who permit to enable an interrupt vector */int enable_interrupt_vector (struct irq_info *irq_info){        unsigned int retval = 0;        unsigned int int_num;        volatile unsigned char *icrp;        volatile unsigned long *imrh;        volatile unsigned long *imrl;        if ((irq_info->vector >= INTC0_VECT_MIN) &&                (irq_info->vector <= INTC0_VECT_MAX))        {                int_num = irq_info->vector - INTC0_VECT_MIN;                icrp = (volatile unsigned char *)                          (MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_ICR0);                imrh = (volatile unsigned long *)                          (MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_IMRH);                imrl = (volatile unsigned long *)                        (MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_IMRL);        }        else if ((irq_info->vector >= INTC1_VECT_MIN) &&                (irq_info->vector <= INTC1_VECT_MAX))        {                int_num = irq_info->vector - INTC1_VECT_MIN;                icrp = (volatile unsigned char *)                          (MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_ICR0);                imrh = (volatile unsigned long *)                          (MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_IMRH);                imrl = (volatile unsigned long *)                        (MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_IMRL);        }        else        {                err("can't request an illegal vector : %d\n", 				irq_info->vector);                return (-1);        }               if ((retval = request_irq (irq_info->vector, irq_info->handler,                                        SA_INTERRUPT, irq_info->name,                                        irq_info->dev_id)))        {                err("unable to request irq %d\n",				irq_info->vector);                return retval;        }        /* set level and priority for our interrupt vector */        icrp[int_num] = (irq_info->level > IRQ_LEVEL_MAX)?                IRQ_LEVEL_DFLT : irq_info->level;        /* disable the mask for this irq vector */        if (int_num >= 32)        {                *imrh &= ~(1 << (int_num - 32));        }        else        {                *imrl &= ~(1 << int_num);        }        *imrl &= ~1;        info("register and enable irq vector %d (level : 0x%x)\n", 			irq_info->vector, (icrp[int_num] & 0xff));        return (0);}/* function who permit to free an interrupt vector */int disable_interrupt_vector (struct irq_info *irq_info){        unsigned int int_num;        volatile unsigned long *imrh;        volatile unsigned long *imrl;        if ((irq_info->vector >= INTC0_VECT_MIN) &&                (irq_info->vector <= INTC0_VECT_MAX))        {                int_num = irq_info->vector - INTC0_VECT_MIN;                imrh = (volatile unsigned long *)                        (MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_IMRH);                imrl = (volatile unsigned long *)                        (MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_IMRL);        }        else if ((irq_info->vector >= INTC1_VECT_MIN) &&                (irq_info->vector <= INTC1_VECT_MAX))        {                int_num = irq_info->vector - INTC1_VECT_MIN;                imrh = (volatile unsigned long *)                        (MCF_IPSBAR + MCFICM_INTC1 + MCFINTC_IMRH);                imrl = (volatile unsigned long *)                        (MCF_IPSBAR + MCFICM_INTC1 + MCFINTC_IMRL);        }        else        {                err("can't free an illegal vector : %d\n", 				irq_info->vector);                return (-1);        }        /* unregister our interrupt handler for irq_vector */        free_irq (irq_info->vector, irq_info->dev_id);        /* disable this interrupt vector with a mask... 	 * just set to 1 the corresponding bit in the interrupt 	 * mask register */        if (int_num >= 32)        {                *imrh |= (1 << (int_num - 32));        }        else        {                *imrl |= (1 << int_num);        }        info("unregister and disable irq vector %d\n", 			irq_info->vector);        return (0);}

⌨️ 快捷键说明

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