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