首先看如下函数,是OAL的初始化函数,我看后大吃一惊,因为和4.2升级到5.0的BSP相差太大了。
- //------------------------------------------------------------------------------
- //
- // Function: OEMInit
- //
- // This is Windows CE OAL initialization function. It is called from kernel
- // after basic initialization is made.
- //
- void OEMInit()
- {
- OALMSG(OAL_FUNC, (L"+OEMInit/r/n"));//连串口打印函都变了
- CEProcessorType=PROCESSOR_STRONGARM;
- // Set memory size for DrWatson kernel support
- dwNKDrWatsonSize = 128 * 1024;
- // Initilize cache globals
- OALCacheGlobalsInit();
- OALLogSerial(
- L"DCache: %d sets, %d ways, %d line size, %d size/r/n",
- g_oalCacheInfo.L1DSetsPerWay, g_oalCacheInfo.L1DNumWays,
- g_oalCacheInfo.L1DLineSize, g_oalCacheInfo.L1DSize
- );
- OALLogSerial(
- L"ICache: %d sets, %d ways, %d line size, %d size/r/n",
- g_oalCacheInfo.L1ISetsPerWay, g_oalCacheInfo.L1INumWays,
- g_oalCacheInfo.L1ILineSize, g_oalCacheInfo.L1ISize
- );
- // Initialize interrupts
- if (!OALIntrInit()) {
- OALMSG(OAL_ERROR, (
- L"ERROR: OEMInit: failed to initialize interrupts/r/n"
- ));
- }
- // Initialize system clock
- OALTimerInit(1, 17, 0); //S3C2440A_PCLK/245/16/1000=16.992
- ConfigureGPIO();
- InitDisplay();
- // Initialize the KITL connection if required
- OALKitlStart();
- OALMSG(OAL_FUNC, (L"-OEMInit/r/n"));
- }
再看看这个中断转换函数
- //------------------------------------------------------------------------------
- //
- // Function: OEMInterruptHandler
- //
- ULONG OEMInterruptHandler(ULONG ra)
- {
- UINT32 sysIntr = SYSINTR_NOP;
- UINT32 irq, irq2, mask;
- // Get pending interrupt(s)
- irq = INREG32(&g_pIntrRegs->INTOFFSET);
- // System timer interrupt?
- if (irq == IRQ_TIMER4) {
- // Clear the interrupt
- OUTREG32(&g_pIntrRegs->SRCPND, 1 << IRQ_TIMER4);
- OUTREG32(&g_pIntrRegs->INTPND, 1 << IRQ_TIMER4);
- // Rest is on timer interrupt handler
- sysIntr = OALTimerIntrHandler();
- }
- // Profiling timer interrupt?
- else if (irq == IRQ_TIMER2)
- {
- // Mask and Clear the interrupt.
- mask = 1 << irq;
- SETREG32(&g_pIntrRegs->INTMSK, mask);
- OUTREG32(&g_pIntrRegs->SRCPND, mask);
- OUTREG32(&g_pIntrRegs->INTPND, mask);
- // The rest is up to the profiling interrupt handler (if profiling
- // is enabled).
- //
- if (g_pProfilerISR)
- {
- sysIntr = g_pProfilerISR(ra);
- }
- }
- else
- {
- #ifdef OAL_ILTIMING
- if (g_oalILT.active) {
- g_oalILT.isrTime1 = OALTimerCountsSinceSysTick();
- g_oalILT.savedPC = 0;
- g_oalILT.interrupts++;
- }
- #endif
- if (irq == IRQ_EINT4_7 || irq == IRQ_EINT8_23) { // 4 or 5
- // Find external interrupt number
- mask = INREG32(&g_pPortRegs->EINTPEND);
- mask &= ~INREG32(&g_pPortRegs->EINTMASK);
- mask = (mask ^ (mask - 1)) >> 5;
- irq2 = IRQ_EINT4;
- while (mask != 0) {
- mask >>= 1;
- irq2++;
- }
- // Mask and clear interrupt
- mask = 1 << (irq2 - IRQ_EINT4 + 4);
- SETREG32(&g_pPortRegs->EINTMASK, mask);
- OUTREG32(&g_pPortRegs->EINTPEND, mask);
- // Clear primary interrupt
- mask = 1 << irq;
- OUTREG32(&g_pIntrRegs->SRCPND, mask);
- OUTREG32(&g_pIntrRegs->INTPND, mask);
- // From now we care about this irq
- irq = irq2;
- } else {
- // Mask and clear interrupt
- mask = 1 << irq;
- SETREG32(&g_pIntrRegs->INTMSK, mask);
- OUTREG32(&g_pIntrRegs->SRCPND, mask);
- OUTREG32(&g_pIntrRegs->INTPND, mask);
- }
- // First find if IRQ is claimed by chain
- sysIntr = NKCallIntChain((UCHAR)irq);
- if (sysIntr == SYSINTR_CHAIN || !NKIsSysIntrValid(sysIntr)) {
- // IRQ wasn't claimed, use static mapping
- sysIntr = OALIntrTranslateIrq(irq);
- }
- }
- g_oalLastSysIntr = sysIntr;
- return sysIntr;
- }
- //------------------------------------------------------------------------------
本文介绍了 Windows CE 操作系统中 OEMInit 函数的详细实现过程,该函数负责系统的初始化工作,包括处理器类型设置、内存配置、缓存初始化等。此外,还深入解析了 OEMInterruptHandler 函数,它用于处理不同类型的中断请求,如定时器中断、外部中断等。
1660

被折叠的 条评论
为什么被折叠?



