码迷,mamicode.com
首页 > 其他好文 > 详细

自定义注解+拦截器实现权限控制

时间:2014-05-15 23:10:58      阅读:448      评论:0      收藏:0      [点我收藏+]

标签:style   c   tar   color   int   a   

根据5.2中的讲解,当监控high priority queue的PDSP channel设定好后,那么与之对应的event就知道了(PDSP channel与event一一对应)(注意5.x讲的是中断的配置,并不是exception的配置,4.x讲的是exception)

中断event与ISR配置代码如下,目的是使event与ISR建立联系:

        /*Configure event*/
       EventCombinerEventConfig( systemEvent,  (TEventCombinerCallback)SysComC2CIsr, GLO_NULL));

因为中断的event combiner将event 4~127分为4个group,所以在EventCombinerEventConfig函数中要判断systemEevent属于哪个group以及group的哪一位,然后判断该event之前没有被exception使用过;有没有被其他的中断使用过;有没有配置到vector上,若有一个条件成立,则该systemEvent不能再次使用:

  u32 vectorIndex;
  evtVector = systemEvent >> 5;
  evtBit        = systemEvent & 31;
  evtMask   = 1<<(systemEvent & 31);

  /* (0100) Check if the event is an exception. */
  u32 eventIsException = (~gCorePacINTCRegs->EXPMASK[evtVector]) & evtMask; //EXPMASK是exception mask寄存器,若相应位为0,表示该event已被exception使用
  u32 eventIsInterrupt = 0;

  /* (0200) Check if the event is already combined. */
  u32 eventIsCombined = (~gCorePacINTCRegs->EVTMASK[evtVector]) & evtMask;//EVTMASK是中断mask寄存器,若相应位为0,表示该event已被其他中断使用
  EEventCombinerRetVal retVal;

  /* (0300) Check if the event is an interrupt. */
  for(vectorIndex = 15; vectorIndex >= 4; vectorIndex--) //因为CPU有12个中断输入INT4~15,所以有12个vector.
  {
          /* Check all the vectors to ensure nobody uses the event ID*/
          if (gPdb.startUpInfo.eventAtIntVector[DNUM][vectorIndex] == systemEvent) //DNUM是cpu编号,对于Nyquist,DNUM=0,1,2,3.
          {
                  /* The event is already in use */
                  eventIsInterrupt = 1;  //若找到有vector与该systemEvent有联系,表明该event已被设置过.
                  break;
          }
  }
  retVal = (eventIsException | eventIsInterrupt | eventIsCombined) ? EEventCombinerRetVal_AlreadyReserved: EEventCombinerRetVal_NoError;

  if (retVal == EEventCombinerRetVal_NoError)

  {

         /* (0400) Register event for being combined. */
         gCorePacINTCRegs->EVTMASK[evtVector] &= ~(1 << evtBit);//向EVTMASK寄存器注册该event,表明该event已经被该中断使用,其他的中断或exception不能再次使用

          /* (0500) Register callback. */
         gEventCombinerCallbacks[systemEvent].cb   = callback; //注册ISR,如文中提到的SysComC2CIsr就是callback
         gEventCombinerCallbacks[systemEvent].data = callbackData;

  }

对寄存器或者某些全局变量的操作一定要在中断disable的情况下进行,这里并没有给出代码。5.5中将会讲解ISR什么时候会被调用。

自定义注解+拦截器实现权限控制,布布扣,bubuko.com

自定义注解+拦截器实现权限控制

标签:style   c   tar   color   int   a   

原文地址:http://blog.csdn.net/v123411739/article/details/25899693

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!