<div dir="ltr"><div><div><div><div><div>(2nd try: Already sent this, but it never came through on the list.)<br><br><br></div><div>Hello,<br><br></div>We have a vxWorks driver for a VME IRIG-B time provider card (Bancomm bc635/bc637) which we want to port to  RTEMS.<br><br></div>The
 ISR of the current vxWorks driver disables the system clock via 
sysClkDisable() in order to take over providing ticks to the kernel via 
tickAnnounce(). <br><br></div>rtems_clock_tick() seems to be a direct 
replacement for the tickAnnounce() function, but what is the strategy 
for disabling/reenabling the system clock?<br><br></div>Surely someone else has implemented something similar.<br><br><br></div>Here is our vxWorks ISR:<br><br><div><font size="1"><span style="font-family:monospace,monospace">void isr_bc635</span></font></div><div><font size="1"><span style="font-family:monospace,monospace">(</span></font></div><div><font size="1"><span style="font-family:monospace,monospace"> void *parg</span></font></div><div><font size="1"><span style="font-family:monospace,monospace"> )</span></font></div><div><font size="1"><span style="font-family:monospace,monospace">{</span></font></div><div><font size="1"><span style="font-family:monospace,monospace">   register short intnum;</span></font></div><div><font size="1"><span style="font-family:monospace,monospace">   register unsigned short tmask, bcistatus, bcimask;</span></font></div><div><font size="1"><span style="font-family:monospace,monospace"><br></span></font></div><div><font size="1"><span style="font-family:monospace,monospace">   bcistatus = pbc635->intstat;<span style="white-space:pre-wrap">                        </span>/* Save copy of status register */</span></font></div><div><font size="1"><span style="font-family:monospace,monospace">   bcimask   = pbc635->mask;<span style="white-space:pre-wrap">                      </span>/* Save copy of interrupt mask */</span></font></div><div><font size="1"><span style="font-family:monospace,monospace">   /* First check for periodic interrupt */</span></font></div><div><font size="1"><span style="font-family:monospace,monospace">   if ( ((bcistatus & 0x02) & bcimask) != 0)</span></font></div><div><font size="1"><span style="font-family:monospace,monospace">   {</span></font></div><div><font size="1"><span style="font-family:monospace,monospace">      if (bcUseper)<span style="white-space:pre-wrap">                                </span>/* Using BC periodics for system clock? */</span></font></div><div><font size="1"><span style="font-family:monospace,monospace">      {</span></font></div><div><font size="1"><span style="font-family:monospace,monospace">         if (!HadPerint)<span style="white-space:pre-wrap">                   </span>/* First Periodic Interrupt? */</span></font></div><div><font size="1"><span style="font-family:monospace,monospace">         {</span></font></div><div><font size="1"><span style="font-family:monospace,monospace">            HadPerint = TRUE;<span style="white-space:pre-wrap">   </span></span></font></div><div><font size="1"><span style="font-family:monospace,monospace">            sysClkDisable();<span style="white-space:pre-wrap">                </span>/* Turn off system clock interrupts */</span></font></div><div><font size="1"><span style="font-family:monospace,monospace">            sysClkRateSet(tickFrequency);<span style="white-space:pre-wrap">     </span>/* set clock rate */</span></font></div><div><font size="1"><span style="font-family:monospace,monospace">         }</span></font></div><div><font size="1"><span style="font-family:monospace,monospace">         bcIntCounter++;<span style="white-space:pre-wrap">                            </span>/* Increment interrupt count */</span></font></div><div><font size="1"><span style="font-family:monospace,monospace">         if (bcUsrClock != NULL) (*bcUsrClock)(bcIntCounter);<span style="white-space:pre-wrap"> </span>/* Call user routine */</span></font></div><div><font size="1"><span style="font-family:monospace,monospace">         if (bcIntCounter%bcIntPerTick == 0)<span style="white-space:pre-wrap">  </span>/* If right number of ticks */</span></font></div><div><font size="1"><span style="font-family:monospace,monospace">            tickAnnounce();<span style="white-space:pre-wrap">                   </span>/* Announce system clock tick */</span></font></div><div><font size="1"><span style="font-family:monospace,monospace">      }</span></font></div><div><font size="1"><span style="font-family:monospace,monospace">      pbc635->intstat = pbc635->intstat | 0x02;<span style="white-space:pre-wrap">  </span>/* Clear interrupt status bit */</span></font></div><div><font size="1"><span style="font-family:monospace,monospace">   }</span></font></div><div><font size="1"><span style="font-family:monospace,monospace">   /* Other interrupts - not periodic pulse */</span></font></div><div><font size="1"><span style="font-family:monospace,monospace">   for (intnum = 1; intnum < 5; intnum++)</span></font></div><div><font size="1"><span style="font-family:monospace,monospace">   {</span></font></div><div><font size="1"><span style="font-family:monospace,monospace">      if (intnum != 2)</span></font></div><div><font size="1"><span style="font-family:monospace,monospace">      {</span></font></div><div><font size="1"><span style="font-family:monospace,monospace">         tmask = 0x01 << (intnum - 1);<span style="white-space:pre-wrap">                </span>/* Test value for interrupt */</span></font></div><div><font size="1"><span style="font-family:monospace,monospace">         /* Check for interrupt bit set - request I/O scan, but only if ioscanpvt is valid */</span></font></div><div><font size="1"><span style="font-family:monospace,monospace">         if ( ((bcistatus & tmask) & bcimask) != 0)</span></font></div><div><font size="1"><span style="font-family:monospace,monospace">         {</span></font></div><div><font size="1"><span style="font-family:monospace,monospace">            if (ioscanpvt[intnum-1] != NULL)</span></font></div><div><font size="1"><span style="font-family:monospace,monospace">               scanIoRequest(ioscanpvt[</span></font><font size="1"><span style="font-family:monospace,monospace">intnum-1]);</span></font></div><div><font size="1"><span style="font-family:monospace,monospace">            pbc635->intstat = pbc635->intstat | tmask;   /* Clear interrupt status bit */</span></font></div><div><font size="1"><span style="font-family:monospace,monospace">         }</span></font></div><div><font size="1"><span style="font-family:monospace,monospace">      }</span></font></div><div><font size="1"><span style="font-family:monospace,monospace">   }</span></font></div><div><font size="1"><span style="font-family:monospace,monospace">}</span></font></div><br clear="all"><br>-- <br><div class="gmail_signature"><div dir="ltr"><div>Mike Westfall<br></div>Gemini Observatory<br></div></div>
</div>