这两天照着ZLG的2410的WINCE中断按键驱动源码,在自己的2440开发板上也搞鼓成功了,但是有如下的问题不甚了解,盼各位高手指导一下:
1,WINCE中断的具体流程,也就是从中断触发,到中断处理结束,依次调用了那些函数(OAL、BSP、OEM)?
2,物理中断和wince的逻辑中断的映射表在什么地方定义的?
谢谢了!:)
借花献佛
第一个问题:
参照
http://blog.eeworld.net/chenyt2007/archive/2008/04/16/2297481.aspx
第二个问题:
5.0及以后的版本要分动态和静态映射的
沙发,哈哈
1、申请系统中断号:KernelIoControl(IOCTL_HAL_REQUEST_SYSINTR, &Irq, sizeof(UINT32), &m_dwSysintrEINT12, sizeof(UINT32), NULL)
2、创建事件:g_keyevtSignal =CreateEvent(NULL, FALSE, FALSE, NULL);
3、将事件与系统中断关联:InterruptInitialize(m_dwSysintrEINT12, g_keyevtSignal, NULL, 0))
4、创建中断线程:CreateThread((LPSECURITY_ATTRIBUTES)NULL,0, (LPTHREAD_START_ROUTINE)InterruptThreadKey,0,0, NULL);
5、线程中等待中断事件:WaitForSingleObject(g_keyevtSignal, INFINITE);
KernelIoControl(IOCTL_HAL_REQUEST_SYSINTR会调用OAL中的OALIoCtlHalRequestSysIntr
wince500\PLATFORM\COMMON\SRC\COMMON\INTR
/*硬件IRQ与系统中断号sysyintr是一对一的,是用如下两张表记录对应关系,*/
static UINT32 g_oalSysIntr2Irq[SYSINTR_MAXIMUM];
static UINT32 g_oalIrq2SysIntr[OAL_INTR_IRQ_MAXIMUM];
主要是map.c里面,有静态及动态的映射
引用: 引用 2 楼 veabol 的回复:
1、申请系统中断号:KernelIoControl(IOCTL_HAL_REQUEST_SYSINTR, &Irq, sizeof(UINT32), &m_dwSysintrEINT12, sizeof(UINT32), NULL)
2、创建事件:g_keyevtSignal =CreateEvent(NULL, FALSE, FALSE, NULL);
3、将事件与系统中断关联:InterruptInitialize(m_dwSysintrEINT12, g_keyevtSignal, NULL, 0))
4、创建中断线程:CreateThread((LPSECURITY_ATTRIBUTES)NULL,0, (LPTHREAD_START_ROUTINE)InterruptThreadKey,0,0, NULL);
5、线程中等待中断事件:WaitForSingleObject(g_keyevtSignal, INFINITE);
KernelIoControl(IOCTL_HAL_REQUEST_SYSINTR会调用OAL中的OALIoCtlHalRequestSysIntr
比较详细。
楼主请看我的博客收藏
http://so.eeworld.net/BlogSearchResult.aspx?q=%E4%B8%AD%E6%96%AD%20username:gooogleman
呵呵,谢谢各位热心的回复,我还有一个小小的疑问,就是WINCE中的中断静态映射和静态映射的区别。
是否静态映射表示物理中断和逻辑中断是一一对应的,比如 物理5号中断对应逻辑5号中断?
而动态映射的话是使用时动态申请,比如 物理5号中断可以对应5号逻辑中断,也可以对应6号中断,关键看申
请到的逻辑中断序号?
其实无论动态映射和静态映射,逻辑与物理中断号都是一一对应的,你可以参照common csp里面的代码分析一下
静态映射是以前版本的ce遗留下来的一种映射方法,动态映射为软件系统了更好的移植性
to:而动态映射的话是使用时动态申请,比如 物理5号中断可以对应5号逻辑中断,也可以对应6号中断,关键看申
请到的逻辑中断序号?
对 ,就是这样
呵呵,谢谢GUOPEIXIN这么热心:D,
在各位的指导下,今天上午仔细看了OAL的一些源码,
在头文件nkintr.h中:
#define SYSINTR_UNDEFINED (-1) // SysIntr not defined for IRQ <-> SYSINTR mapping
#define SYSINTR_NOP 0 /* no processing required */
#define SYSINTR_RESCHED 1 /* set "reschedule flag" */
#define SYSINTR_BREAK 2 /* break into debugger */
#define SYSINTR_CHAIN 3 /* continue to next handler */
// SYSINTR_DEVICES is the base for any non-OAL system interrupts
#define SYSINTR_DEVICES 8
#define SYSINTR_PROFILE (SYSINTR_DEVICES+1) // System Profiling
#define SYSINTR_TIMING (SYSINTR_DEVICES+2) // Latency Analysis
#define SYSINTR_RTC_ALARM (SYSINTR_DEVICES+5) // real-time clock alarm
#define SYSINTR_NETWORK_SHARED (SYSINTR_DEVICES+6) // Combined interrupts for network
#define SYSINTR_VMINI (SYSINTR_DEVICES+7) // VMini RX interrupt.
// SYSINTR_FIRMWARE is the base for any interrupts defined in the OAL
#define SYSINTR_FIRMWARE (SYSINTR_DEVICES+8)
#define SYSINTR_MAX_DEVICES 64
#define SYSINTR_MAXIMUM (SYSINTR_DEVICES+SYSINTR_MAX_DEVICES)
红色这句就是定义了在OAL中的中断起始逻辑终端号,而在MAP.C文件中:
// Function: OALIntrRequestSysIntr
//
// This function allocate new SYSINTR for given IRQ and it there isn't
// static mapping for this IRQ it will create it.
//
UINT32 OALIntrRequestSysIntr(UINT32 count, const UINT32 *pIrqs, UINT32 flags)
{
UINT32 irq, sysIntr;
OALMSG(OAL_INTR&&OAL_FUNC, (
L"+OALIntrRequestSysIntr(%d, 0x%08x, 0x%08x)\r\n", count, pIrqs, flags
));
// Valid IRQ?
if (count != 1 || pIrqs[0] >= OAL_INTR_IRQ_MAXIMUM) {
sysIntr = SYSINTR_UNDEFINED;
goto cleanUp;
}
irq = pIrqs[0];
// If there is mapping for given irq check for special cases
if (g_oalIrq2SysIntr[irq] != SYSINTR_UNDEFINED) {
// If static mapping is requested we fail
if ((flags & OAL_INTR_STATIC) != 0) {
OALMSG(OAL_ERROR, (L"ERROR: OALIntrRequestSysIntr: "
L"Static mapping for IRQ %d already assigned\r\n", irq
));
sysIntr = SYSINTR_UNDEFINED;
goto cleanUp;
}
// If we should translate, return existing SYSINTR
if ((flags & OAL_INTR_TRANSLATE) != 0) {
sysIntr = g_oalIrq2SysIntr[irq];
goto cleanUp;
}
}
// Find next available SYSINTR value...
for (sysIntr = SYSINTR_FIRMWARE; sysIntr < SYSINTR_MAXIMUM; sysIntr++) {
if (g_oalSysIntr2Irq[sysIntr] == OAL_INTR_IRQ_UNDEFINED) break; }
// Any available SYSINTRs left?
if (sysIntr >= SYSINTR_MAXIMUM) {
OALMSG(OAL_ERROR, (L"ERROR: OALIntrRequestSysIntr: "
L"No avaiable SYSINTR found\r\n"
));
sysIntr = SYSINTR_UNDEFINED;
goto cleanUp;
}
// Make SYSINTR -> IRQ association.
g_oalSysIntr2Irq[sysIntr] = irq;
// Make IRQ -> SYSINTR association if required
if ((flags & OAL_INTR_DYNAMIC) != 0) goto cleanUp;
if (
g_oalIrq2SysIntr[irq] == SYSINTR_UNDEFINED ||
(flags & OAL_INTR_FORCE_STATIC) != 0
) {
g_oalIrq2SysIntr[irq] = sysIntr;
}
cleanUp:
OALMSG(OAL_INTR&&OAL_FUNC, (
L"-OALIntrRequestSysIntr(sysIntr = %d)\r\n", sysIntr
));
return sysIntr;
}
这个函数就是为物理中断指派相应的逻辑中断号,而红色那句就是指派一个空的逻辑中断号!
呵呵,谢谢大家的热心帮助,结贴啦:D