wince5.0 标准三星BSPOAL详细分析

来源:互联网 发布:南昌泰豪软件 编辑:程序博客网 时间:2024/05/17 04:58

首先看如下函数,是OAL的初始化函数,我看后大吃一惊,因为和4.2升级到5.0的BSP相差太大了。

  1. //------------------------------------------------------------------------------
  2. //
  3. //  Function:  OEMInit
  4. //
  5. //  This is Windows CE OAL initialization function. It is called from kernel
  6. //  after basic initialization is made.
  7. //
  8. void OEMInit()
  9. {
  10.     OALMSG(OAL_FUNC, (L"+OEMInit/r/n"));//连串口打印函都变了
  11.     CEProcessorType=PROCESSOR_STRONGARM;
  12.     // Set memory size for DrWatson kernel support
  13.     dwNKDrWatsonSize = 128 * 1024;
  14.     // Initilize cache globals
  15.     OALCacheGlobalsInit();
  16.     OALLogSerial(
  17.         L"DCache: %d sets, %d ways, %d line size, %d size/r/n"
  18.         g_oalCacheInfo.L1DSetsPerWay, g_oalCacheInfo.L1DNumWays,
  19.         g_oalCacheInfo.L1DLineSize, g_oalCacheInfo.L1DSize
  20.     );
  21.     OALLogSerial(
  22.         L"ICache: %d sets, %d ways, %d line size, %d size/r/n"
  23.         g_oalCacheInfo.L1ISetsPerWay, g_oalCacheInfo.L1INumWays,
  24.         g_oalCacheInfo.L1ILineSize, g_oalCacheInfo.L1ISize
  25.     );
  26.     
  27.     // Initialize interrupts
  28.     if (!OALIntrInit()) {
  29.         OALMSG(OAL_ERROR, (
  30.             L"ERROR: OEMInit: failed to initialize interrupts/r/n"
  31.         ));
  32.     }
  33.     // Initialize system clock
  34.     OALTimerInit(1, 17, 0); //S3C2440A_PCLK/245/16/1000=16.992
  35.     ConfigureGPIO();
  36.     InitDisplay();
  37.     // Initialize the KITL connection if required
  38.     OALKitlStart();
  39.     OALMSG(OAL_FUNC, (L"-OEMInit/r/n"));
  40. }

再看看这个中断转换函数

  1. //------------------------------------------------------------------------------
  2. //
  3. //  Function:  OEMInterruptHandler
  4. //
  5. ULONG OEMInterruptHandler(ULONG ra)
  6. {
  7.     UINT32 sysIntr = SYSINTR_NOP;
  8.     UINT32 irq, irq2, mask;
  9.     // Get pending interrupt(s)
  10.     irq = INREG32(&g_pIntrRegs->INTOFFSET);
  11.     // System timer interrupt?
  12.     if (irq == IRQ_TIMER4) {
  13.         // Clear the interrupt
  14.         OUTREG32(&g_pIntrRegs->SRCPND, 1 << IRQ_TIMER4);
  15.         OUTREG32(&g_pIntrRegs->INTPND, 1 << IRQ_TIMER4);
  16.         // Rest is on timer interrupt handler
  17.         sysIntr = OALTimerIntrHandler();
  18.     }    
  19.     // Profiling timer interrupt?
  20.     else if (irq == IRQ_TIMER2)
  21.     {
  22.         // Mask and Clear the interrupt.
  23.         mask = 1 << irq;
  24.         SETREG32(&g_pIntrRegs->INTMSK, mask);
  25.         OUTREG32(&g_pIntrRegs->SRCPND, mask);
  26.         OUTREG32(&g_pIntrRegs->INTPND, mask);
  27.         // The rest is up to the profiling interrupt handler (if profiling
  28.         // is enabled).
  29.         //
  30.         if (g_pProfilerISR)
  31.         {
  32.             sysIntr = g_pProfilerISR(ra);
  33.         }
  34.     }
  35.     else 
  36.     {
  37. #ifdef OAL_ILTIMING
  38.         if (g_oalILT.active) {
  39.             g_oalILT.isrTime1 = OALTimerCountsSinceSysTick();
  40.             g_oalILT.savedPC = 0;
  41.             g_oalILT.interrupts++;
  42.         }        
  43. #endif
  44.     
  45.         if (irq == IRQ_EINT4_7 || irq == IRQ_EINT8_23) { // 4 or 5
  46.             // Find external interrupt number
  47.             mask = INREG32(&g_pPortRegs->EINTPEND);
  48.             mask &= ~INREG32(&g_pPortRegs->EINTMASK);
  49.             mask = (mask ^ (mask - 1)) >> 5;
  50.             irq2 = IRQ_EINT4;
  51.             while (mask != 0) {
  52.                 mask >>= 1;
  53.                 irq2++;
  54.             }
  55.             // Mask and clear interrupt
  56.             mask = 1 << (irq2 - IRQ_EINT4 + 4);
  57.             SETREG32(&g_pPortRegs->EINTMASK, mask);
  58.             OUTREG32(&g_pPortRegs->EINTPEND, mask);
  59.             // Clear primary interrupt
  60.             mask = 1 << irq;
  61.             OUTREG32(&g_pIntrRegs->SRCPND, mask);
  62.             OUTREG32(&g_pIntrRegs->INTPND, mask);
  63.             // From now we care about this irq
  64.             irq = irq2;
  65.         }  else {
  66.             // Mask and clear interrupt
  67.             mask = 1 << irq;
  68.             SETREG32(&g_pIntrRegs->INTMSK, mask);
  69.             OUTREG32(&g_pIntrRegs->SRCPND, mask);
  70.             OUTREG32(&g_pIntrRegs->INTPND, mask);
  71.         }
  72.         // First find if IRQ is claimed by chain
  73.         sysIntr = NKCallIntChain((UCHAR)irq);
  74.         if (sysIntr == SYSINTR_CHAIN || !NKIsSysIntrValid(sysIntr)) {
  75.             // IRQ wasn't claimed, use static mapping
  76.             sysIntr = OALIntrTranslateIrq(irq);
  77.         }
  78.     }
  79.     g_oalLastSysIntr = sysIntr;
  80.     return sysIntr;
  81. }
  82. //------------------------------------------------------------------------------