2440 5.0BSP之OEMInterruptHandler函数

     因为先前已经有了KernelIOControl把物理中断转换成系统中断了,我就以为不会再用OEMInterruptHandler了,后来发现必须用,这样才能在中断产生之后在线程结束之前屏蔽中断,明天加点打印信息就知道怎么回事了。OEMInterruptHandlerC:\WINCE500\PRIVATE\WINCEOS\COREOS\NK\KERNEL\ARM\armtrap.s(1381)被调用了。

 

ContractedBlock.gif ExpandedBlockStart.gif Function: OEMInterruptHandler
  1 //------------------------------------------------------------------------------
  2 //C:\WINCE500\PLATFORM\SMDK2440A\Src\Common\Intr\intr.c
  3 //  Function:  OEMInterruptHandler
  4 //  这个函数和4.2BSP的同名函数实现原理相同
  5 ULONG OEMInterruptHandler(ULONG ra)
  6 {
  7     UINT32 sysIntr = SYSINTR_NOP;
  8     UINT32 irq, irq2, mask;
  9 
 10     // Get pending interrupt(s)
 11     irq = INREG32(&g_pIntrRegs->INTOFFSET);
 12 
 13     g_oalLastSysIntr = TRUE;    //c ksk 20060404
 14 
 15     // System timer interrupt?
 16     if (irq == IRQ_TIMER4) {
 17 
 18         // Clear the interrupt
 19         OUTREG32(&g_pIntrRegs->SRCPND, 1 << IRQ_TIMER4);
 20         OUTREG32(&g_pIntrRegs->INTPND, 1 << IRQ_TIMER4);
 21 
 22         // Rest is on timer interrupt handler
 23         sysIntr = OALTimerIntrHandler();
 24     }    
 25     // Profiling timer interrupt?
 26     else if (irq == IRQ_TIMER2)
 27     {
 28         // Mask and Clear the interrupt.
 29         mask = 1 << irq;
 30         SETREG32(&g_pIntrRegs->INTMSK, mask);
 31         OUTREG32(&g_pIntrRegs->SRCPND, mask);
 32         OUTREG32(&g_pIntrRegs->INTPND, mask);
 33 
 34         // The rest is up to the profiling interrupt handler (if profiling
 35         // is enabled).
 36         //
 37         if (g_pProfilerISR)
 38         {
 39             sysIntr = g_pProfilerISR(ra);
 40         }
 41     }
 42     else if (irq == IRQ_EINT2)        // Softreset
 43     {
 44         RETAILMSG(1, (TEXT("OEMInterruptHandler: irq = %d \r\n"), irq));
 45         OALIoCtlHalReboot(IOCTL_HAL_REBOOT,NULL,0,NULL,0,NULL);
 46         sysIntr = SYSINTR_NOP;
 47     }
 48     else 
 49     {
 50 
 51 #ifdef OAL_ILTIMING
 52         if (g_oalILT.active) {
 53             g_oalILT.isrTime1 = OALTimerCountsSinceSysTick();
 54             g_oalILT.savedPC = 0;
 55             g_oalILT.interrupts++;
 56         }        
 57 #endif
 58     
 59         if (irq == IRQ_EINT4_7 || irq == IRQ_EINT8_23) { // 4 or 5
 60 
 61             // Find external interrupt number
 62             mask = INREG32(&g_pPortRegs->EINTPEND);
 63             mask &= ~INREG32(&g_pPortRegs->EINTMASK);
 64             mask = (mask ^ (mask - 1)) >> 5;
 65             irq2 = IRQ_EINT4;
 66             while (mask != 0) {
 67                 mask >>= 1;
 68                 irq2++;
 69             }
 70 
 71             // Mask and clear interrupt
 72             mask = 1 << (irq2 - IRQ_EINT4 + 4);
 73             SETREG32(&g_pPortRegs->EINTMASK, mask);
 74             OUTREG32(&g_pPortRegs->EINTPEND, mask);
 75 
 76             // Clear primary interrupt
 77             mask = 1 << irq;
 78             OUTREG32(&g_pIntrRegs->SRCPND, mask);
 79             OUTREG32(&g_pIntrRegs->INTPND, mask);
 80 
 81             // From now we care about this irq
 82             irq = irq2;
 83 
 84         }  
 85       else if(irq == IRQ_CAM)
 86         {
 87             if(INREG32(&g_pIntrRegs->SUBSRCPND) & (1<<IRQ_SUB_CAM_C))
 88             {
 89               SETREG32(&g_pIntrRegs->INTSUBMSK, (1<<IRQ_SUB_CAM_C));
 90               SETREG32(&g_pIntrRegs->INTMSK, (1<<IRQ_CAM));
 91               OUTREG32(&g_pIntrRegs->SUBSRCPND, (1<<IRQ_SUB_CAM_C));
 92               OUTREG32(&g_pIntrRegs->SRCPND, (1<<IRQ_CAM));
 93               OUTREG32(&g_pIntrRegs->INTPND,(1<<IRQ_CAM));
 94               //RETAILMSG(1,(TEXT("IRQ_CAM Codec\r\n")));
 95             }
 96             
 97             else if(INREG32(&g_pIntrRegs->SUBSRCPND) & (1<<IRQ_SUB_CAM_P))
 98              {
 99               SETREG32(&g_pIntrRegs->INTSUBMSK, (1<<IRQ_SUB_CAM_P));
100               SETREG32(&g_pIntrRegs->INTMSK, (1<<IRQ_CAM));
101               OUTREG32(&g_pIntrRegs->SUBSRCPND, (1<<IRQ_SUB_CAM_P));
102               OUTREG32(&g_pIntrRegs->SRCPND, (1<<IRQ_CAM));
103               OUTREG32(&g_pIntrRegs->INTPND,(1<<IRQ_CAM));
104               //RETAILMSG(1,(TEXT("PreView\r\n")));
105             }
106             
107             else
108             {
109                 SETREG32(&g_pIntrRegs->INTSUBMSK, (1<<IRQ_SUB_CAM_C)|(1<<IRQ_SUB_CAM_P)); 
110                 SETREG32(&g_pIntrRegs->INTMSK, (1<<IRQ_CAM));
111                 SETREG32(&g_pIntrRegs->SUBSRCPND, (1<<IRQ_SUB_CAM_C)|(1<<IRQ_SUB_CAM_P));             
112                 OUTREG32(&g_pIntrRegs->SRCPND, (1<<IRQ_CAM));
113                 OUTREG32(&g_pIntrRegs->INTPND,(1<<IRQ_CAM));
114                     //RETAILMSG(1,(TEXT("nop\r\n")));                
115                 return SYSINTR_NOP; 
116             }
117         }
118             
119     
120     else {
121 
122             // Mask and clear interrupt
123             mask = 1 << irq;
124             SETREG32(&g_pIntrRegs->INTMSK, mask);
125             OUTREG32(&g_pIntrRegs->SRCPND, mask);
126             OUTREG32(&g_pIntrRegs->INTPND, mask);
127 
128         }
129 
130         // First find if IRQ is claimed by chain
131         sysIntr = NKCallIntChain((UCHAR)irq);
132         if (sysIntr == SYSINTR_CHAIN || !NKIsSysIntrValid(sysIntr)) {
133             // IRQ wasn't claimed, use static mapping
134             sysIntr = OALIntrTranslateIrq(irq);//如果上面没有考虑到,就在这里静态映射
135         }
136     }
137 
138     //g_oalLastSysIntr = sysIntr;
139     return sysIntr;
140 }
141 
142 //------------------------------------------------------------------------------
143 

转载于:https://www.cnblogs.com/wogoyixikexie/archive/2009/02/05/1384793.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值