1    /*
     2     * Copyright (c) 2014, Texas Instruments Incorporated
     3     * All rights reserved.
     4     *
     5     * Redistribution and use in source and binary forms, with or without
     6     * modification, are permitted provided that the following conditions
     7     * are met:
     8     *
     9     * *  Redistributions of source code must retain the above copyright
    10     *    notice, this list of conditions and the following disclaimer.
    11     *
    12     * *  Redistributions in binary form must reproduce the above copyright
    13     *    notice, this list of conditions and the following disclaimer in the
    14     *    documentation and/or other materials provided with the distribution.
    15     *
    16     * *  Neither the name of Texas Instruments Incorporated nor the names of
    17     *    its contributors may be used to endorse or promote products derived
    18     *    from this software without specific prior written permission.
    19     *
    20     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
    21     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
    22     * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
    23     * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
    24     * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
    25     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
    26     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
    27     * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
    28     * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    29     * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
    30     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    31     */
    32    /*
    33     *  ======== Timer.xdc ========
    34     */
    35    
    36    package ti.sysbios.timers.dmtimer;
    37    
    38    import xdc.rov.ViewInfo;
    39    
    40    import xdc.runtime.Assert;
    41    import xdc.runtime.Error;
    42    import xdc.runtime.Types;
    43    import ti.sysbios.interfaces.ITimer;
    44    import ti.sysbios.hal.Hwi;
    45    
    46    /*!
    47     *  ======== Timer ========
    48     *  Timer Peripheral Manager.
    49     *
    50     *  This Timer module manages the Dual Mode timer (dmtimer) peripherals
    51     *  available on the ARM and C6000 devices (see
    52     *  {@link ./doc-files/TimerTables.html Timer Mapping Tables} for supported
    53     *  device information).
    54     *
    55     *  The dmtimer Timer module supports the timer in 'one shot', 'continuous',
    56     *  and 'dynamic' modes.
    57     *
    58     *  In 'one shot' mode, a timer function will "fire" (run) when the timer period
    59     *  expires (counts up to zero). In 'one shot' mode this will only happen
    60     *  once.  
    61     *
    62     *  In 'continuous' mode, the specified timer function will "fire" every
    63     *  time the period expires, throughout the lifetime of the program.  When the
    64     *  period expires in 'continuous mode', the period is then reset to its
    65     *  original value and then begins counting up to zero again.  At this point
    66     *  the timer function will fire again and the cycle repeats itself.
    67     *
    68     *  In 'dynamic' mode, the specified timer function will "fire" every
    69     *  time the period expires.  But the period of the timer can be changed 
    70     *  dynamically, to correspond to the next tick interrupt needed from the
    71     *  timer.  The timer will continually count upwards, and the timer's compare 
    72     *  mode is used to generate an interrupt when a specific threshold count is
    73     *  reached.  This mode is used by the SYS/BIOS Clock module, for implementing
    74     *  dynamic tick suppression, which reduces the number of interrupts from the 
    75     *  timer to the minimum required for currently scheduled timeouts.
    76     *
    77     *  @p(html)
    78     *  <h3> Calling Context </h3>
    79     *  <table border="1" cellpadding="3">
    80     *    <colgroup span="1"></colgroup> <colgroup span="5" align="center">
    81     *  </colgroup>
    82     *
    83     *    <tr><th> Function                 </th><th>  Hwi   </th><th>  Swi   </th>
    84     *  <th>  Task  </th><th>  Main  </th><th>  Startup  </th></tr>
    85     *    <!--                                                          -->
    86     *    <tr><td> {@link #getNumTimers}            </td><td>   Y    </td>
    87     *  <td>   Y    </td><td>   Y    </td><td>   Y    </td><td>   N    </td></tr>
    88     *    <tr><td> {@link #getStatus}               </td><td>   Y    </td>
    89     *  <td>   Y    </td><td>   Y    </td><td>   Y    </td><td>   N    </td></tr>
    90     *    <tr><td> {@link #Params_init}             </td><td>   Y    </td>
    91     *  <td>   Y    </td><td>   Y    </td><td>   Y    </td><td>   N    </td></tr>
    92     *    <tr><td> {@link #construct}               </td><td>   Y    </td>
    93     *  <td>   Y    </td><td>   Y    </td><td>   Y    </td><td>   N    </td></tr>
    94     *    <tr><td> {@link #create}                  </td><td>   N    </td>
    95     *  <td>   N    </td><td>   Y    </td><td>   Y    </td><td>   N    </td></tr>
    96     *    <tr><td> {@link #delete}                  </td><td>   N    </td>
    97     *  <td>   N    </td><td>   Y    </td><td>   Y    </td><td>   N    </td></tr>
    98     *    <tr><td> {@link #destruct}                </td><td>   Y    </td>
    99     *  <td>   Y    </td><td>   Y    </td><td>   Y    </td><td>   N    </td></tr>
   100     *    <tr><td> {@link #getCount}                </td><td>   Y    </td>
   101     *  <td>   Y    </td><td>   Y    </td><td>   N    </td><td>   N    </td></tr>
   102     *    <tr><td> {@link #getFreq}                 </td><td>   Y    </td>
   103     *  <td>   Y    </td><td>   Y    </td><td>   Y    </td><td>   N    </td></tr>
   104     *    <tr><td> {@link #getFunc}                 </td><td>   Y    </td>
   105     *  <td>   Y    </td><td>   Y    </td><td>   Y    </td><td>   N    </td></tr>
   106     *    <tr><td> {@link #getPeriod}               </td><td>   Y    </td>
   107     *  <td>   Y    </td><td>   Y    </td><td>   Y    </td><td>   N    </td></tr>
   108     *    <tr><td> {@link #reconfig}                </td><td>   Y    </td>
   109     *  <td>   Y    </td><td>   Y    </td><td>   Y    </td><td>   N    </td></tr>
   110     *    <tr><td> {@link #setFunc}                 </td><td>   Y    </td>
   111     *  <td>   Y    </td><td>   Y    </td><td>   Y    </td><td>   N    </td></tr>
   112     *    <tr><td> {@link #setPeriod}               </td><td>   Y    </td>
   113     *  <td>   Y    </td><td>   Y    </td><td>   Y    </td><td>   N    </td></tr>
   114     *    <tr><td> {@link #setPeriodMicroSecs}      </td><td>   Y    </td>
   115     *  <td>   Y    </td><td>   Y    </td><td>   Y    </td><td>   N    </td></tr>
   116     *    <tr><td> {@link #start}                   </td><td>   Y    </td>
   117     *  <td>   Y    </td><td>   Y    </td><td>   N    </td><td>   N    </td></tr>
   118     *    <tr><td> {@link #stop}                    </td><td>   Y    </td>
   119     *  <td>   Y    </td><td>   Y    </td><td>   N    </td><td>   N    </td></tr>
   120     *    <tr><td colspan="6"> Definitions: <br />
   121     *       <ul>
   122     *         <li> <b>Hwi</b>: API is callable from a Hwi thread. </li>
   123     *         <li> <b>Swi</b>: API is callable from a Swi thread. </li>
   124     *         <li> <b>Task</b>: API is callable from a Task thread. </li>
   125     *         <li> <b>Main</b>: API is callable during any of these phases: </li>
   126     *           <ul>
   127     *             <li> In your module startup after this module is started 
   128     *  (e.g. Timer_Module_startupDone() returns TRUE). </li>
   129     *             <li> During xdc.runtime.Startup.lastFxns. </li>
   130     *             <li> During main().</li>
   131     *             <li> During BIOS.startupFxns.</li>
   132     *           </ul>
   133     *         <li> <b>Startup</b>: API is callable during any of these phases:</li>
   134     *           <ul>
   135     *             <li> During xdc.runtime.Startup.firstFxns.</li>
   136     *             <li> In your module startup before this module is started 
   137     *  (e.g. Timer_Module_startupDone() returns FALSE).</li>
   138     *           </ul>
   139     *       </ul>
   140     *    </td></tr>
   141     *
   142     *  </table>
   143     *  @p
   144     *
   145     *  @p(html)
   146     *  <h3> Timer Mapping Tables </h3>
   147     *  <p>
   148     *  The Timer module allows the user to use and configure the various timers
   149     *  that exist on a particular device.  This is achieved by specifying a timer
   150     *  ID when calling {@link ti.sysbios.hal.Timer#Timer_create}. 
   151     *  However, the timer ID
   152     *  specified may not always map to that timer; for example, specifying an ID
   153     *  value of 1 does not necessarily mean that this will map to "GPTimer1".
   154     *  These tables are provided to show which timers map to which timer IDs.
   155     *  </p>
   156     *  {@link ./doc-files/TimerTables.html Timer Mapping Tables}
   157     *  @p
   158     */
   159    @ModuleStartup          /* to configure static timers */
   160    @InstanceInitStatic
   161    
   162    module Timer inherits ti.sysbios.interfaces.ITimer
   163    {
   164        /*! override supportsDynamic - this Timer does support RunMode_DYNAMIC */
   165        override metaonly config Bool supportsDynamic = true;
   166    
   167        /*! Max value of Timer period for PeriodType_COUNTS*/
   168        const UInt MAX_PERIOD = 0xffffffff;
   169    
   170        /*! L4 interface Configuration Register (TIOCP_CFG). */
   171        struct TiocpCfg {
   172            Bits8 idlemode;  /*! 0=force-idle;1=no-idle;2=Smart-idle;3=Smart-idle */
   173            Bits8 emufree;   /*! 0=counter frozen; 1=counter free-running */
   174            Bits8 softreset; /*! 0=normal mode; 1=soft reset */
   175        };
   176    
   177        /*! Interrupt Enable Register (TIER). */
   178        struct Tier {
   179            Bits8 mat_it_ena;  /*! Enable match interrupt */
   180            Bits8 ovf_it_ena;  /*! Enable overflow interrupt */
   181            Bits8 tcar_it_ena; /*! Enable capture interrupt */
   182        };
   183    
   184        /*! WakepUp Enable Register (TWER). */
   185        struct Twer {
   186            Bits8 mat_wup_ena;  /*! Enable match wake-up */
   187            Bits8 ovf_wup_ena;  /*! Enable overflow wake-up */
   188            Bits8 tcar_wup_ena; /*! Enable capture wake-up */
   189        };
   190    
   191        /*! Control Register (TCLR). */
   192        struct Tclr {
   193            Bits32 ptv; /*! Trigger output mode */
   194            Bits8 pre;  /*! Prescalar enable */
   195            Bits8 ce;   /*! Compare enable */
   196            Bits8 scpwm;/*! Pulse-width modulation */
   197            Bits16 tcm; /*! Transition capture mode */
   198            Bits16 trg; /*! Trigger output mode */
   199            Bits8 pt;   /*! Pulse or toggle select bit */
   200            Bits8 captmode; /*! Capture mode select bit */
   201            Bits8 gpocfg; /*! PWM output/event detection input pin */
   202        };
   203    
   204        /*! L4 Interface Synchronization Control Register (TSICR). */
   205        struct Tsicr {
   206            Bits8 sft;    /*! Reset software functional registers */
   207            Bits8 posted; /*! Posted mode selection */
   208        };
   209    
   210        /*! Timer Settings. */
   211        metaonly struct TimerSetting {
   212            Bool master;    /*! specifies whether this is the master */
   213            Ptr baseAddr;   /*! specify the base address  */
   214            Int intNum;     /*! specify which interrupt vector */
   215            Int eventId;    /*! specify which event number to use */
   216            String name;    /*! specify the timer name */
   217        };
   218    
   219        /*!
   220         *  ======== BasicView ========
   221         *  @_nodoc
   222         */
   223        metaonly struct BasicView {
   224            Ptr         halTimerHandle;
   225            String      label;
   226            UInt        id;
   227            String      name;
   228            String      startMode;
   229            String      runMode;
   230            UInt        period;
   231            String      periodType;
   232            UInt        intNum;
   233            String      eventId;
   234            String      tickFxn[];
   235            UArg        arg;
   236            String      extFreqLow;
   237            String      extFreqHigh;
   238            String      hwiHandle;
   239        };
   240    
   241        /*!
   242         *  ======== DeviceView ========
   243         *  @_nodoc
   244         */
   245        metaonly struct DeviceView {
   246            UInt        id;
   247            String      deviceAddr;
   248            UInt        intNum;
   249            String      eventId;
   250            String      runMode;
   251            String      timerState;
   252            UInt        period;
   253            String      currCount;
   254            String      remainingCount;
   255        };
   256    
   257        /*!
   258         *  ======== ModuleView ========
   259         *  @_nodoc
   260         */
   261        metaonly struct ModuleView {
   262            String          availMask;      /* avaliable 32-bit timer halves */
   263            String          intFrequency[]; /* internal frequency in Hz */
   264        }
   265    
   266        /*!
   267         *  ======== rovViewInfo ========
   268         *  @_nodoc
   269         */
   270        @Facet
   271        metaonly config ViewInfo.Instance rovViewInfo = 
   272            ViewInfo.create({
   273                viewMap: [
   274                [
   275                    'Basic',
   276                    {
   277                        type: ViewInfo.INSTANCE,
   278                        viewInitFxn: 'viewInitBasic',
   279                        structName: 'BasicView'
   280                    }
   281                ],
   282                [
   283                    'Device',
   284                    {
   285                        type: ViewInfo.INSTANCE,
   286                        viewInitFxn: 'viewInitDevice',
   287                        structName: 'DeviceView'
   288                    }
   289                ],
   290                [
   291                    'Module',
   292                    {
   293                        type: ViewInfo.MODULE,
   294                        viewInitFxn: 'viewInitModule',
   295                        structName: 'ModuleView'
   296                    }
   297                ],
   298                ]
   299            });
   300    
   301        /*!
   302         *  Assert raised when statically created timer is not available
   303         */
   304        config xdc.runtime.Assert.Id A_notAvailable = {
   305            msg: "A_notAvailable: statically created timer not available"
   306        };
   307    
   308        /*!
   309         *  Error raised when timer id specified is not supported.
   310         */
   311        config Error.Id E_invalidTimer = {
   312            msg: "E_invalidTimer: Invalid Timer Id %d"
   313        };
   314    
   315        /*!
   316         *  Error raised when timer requested is in use
   317         */
   318        config Error.Id E_notAvailable  = {
   319            msg: "E_notAvailable: Timer not available %d"
   320        };
   321    
   322        /*!
   323         *  Error raised when period requested is not supported
   324         */
   325        config Error.Id E_cannotSupport = {
   326            msg: "E_cannotSupport: Timer cannot support requested period %d"
   327        };
   328        
   329        /*!
   330         *  Error raised when timer frequency does not match expected frequency
   331         *
   332         *  BIOS does not configure the DMTimer clock source and expects this
   333         *  configuration to be performed via a GEL script or on the host OS.  This
   334         *  error is raised if BIOS detects a mismatch between {@link #intFreq} and
   335         *  the actual operating frequency.  The check is performed by comparing
   336         *  the timestamp operating frequency with the DMTimer frequency.
   337         * 
   338         *  To change the expected timer frequency to match the actual operating 
   339         *  frequency, use the following example configuration:
   340         *  @p(code)
   341         *      var Timer = xdc.useModule('ti.sysbios.timers.dmtimer.Timer');
   342         *      Timer.intFreq.lo = 20000000; //For 20Mhz
   343         *      Timer.intFreq.hi = 0;
   344         *  @p
   345         *
   346         *  This check can be skipped by setting {@link #checkFrequency} to FALSE.
   347         */
   348        config Error.Id E_freqMismatch  = {
   349            msg: "E_freqMismatch: Frequency mismatch: Expected %d Hz, actual: %d Hz.  You need to modify Timer.intFreq.lo to match the actual frequency."
   350        };
   351    
   352        /*!
   353         *  Error raised when intNum not supplied by user or device table
   354         */
   355        config Error.Id E_badIntNum = {
   356            msg: "E_badIntNum: Timer requires a valid intNum. Please use DMTimer module's timerSettings config param to assign a valid intNum for the selected timer."
   357        };
   358    
   359        /*!
   360         *  ======== anyMask ========
   361         *  Available mask to be used when select = Timer_ANY. 
   362         *
   363         *  Default value is device specific.
   364         */
   365        config Bits32 anyMask;
   366    
   367        /*!
   368         *  ======== checkFrequency ========
   369         *  Whether to check the timer operating frequency at startup
   370         *
   371         *  When this flag is set to 'TRUE', the Timer module will verify that the
   372         *  operating frequency equals the frequency at which BIOS expects the 
   373         *  timers to operate.  This check is performed by checking the timer count
   374         *  rate against the {@link xdc.runtime.Timestamp} count rate.
   375         */
   376        config Bool checkFrequency = true;
   377    
   378        /*!
   379         *  ======== timerSettings ========
   380         *  Global Control configuration for each physical timer.
   381         */
   382        metaonly config TimerSetting timerSettings[] = [];
   383        
   384        /*!
   385         *  ======== intFreq ========
   386         *  Default internal timer input clock frequency.
   387         *
   388         *  If intFreq is set, its value will be copied into all
   389         *  {@link #intFreqs}[] array entries except any entry which was
   390         *  explicitly written to in the application's config script.
   391         *
   392         *  For example, if intFreq is set to {hi:0, lo:32768} on a device
   393         *  with 3 timers, it will be copied into intFreqs[0], intFreqs[1] &
   394         *  intFreqs[2]. If the application explicitly sets one of the
   395         *  {@link #intFreqs}[] entries, say intFreqs[1], then intFreq is not
   396         *  copied into intFreqs[1] and intFreqs[1] retains the value it was
   397         *  set to in the config script.
   398         */
   399        metaonly config Types.FreqHz intFreq = {lo: 0, hi: 0};
   400    
   401        /*!
   402         *  ======== intFreqs ========
   403         *  Default internal timer input clock frequency array.
   404         *
   405         *  This array can be used to change the input clock frequency
   406         *  for a particular timer.
   407         *
   408         *  For example, if it is required to change the input clock frequency
   409         *  for timer id 2 to 32768Hz on a device that has 4 timers, the
   410         *  intFreqs[2] config param can be set to {hi:0, lo:32768} in the
   411         *  config script.
   412         *
   413         *  For a list of default timer frequencies for different devices,
   414         *  please refer {@link ./doc-files/TimerTables.html Timer Mapping Tables}.
   415         */
   416        metaonly config Types.FreqHz intFreqs[];
   417        
   418        /*!
   419         *  ======== stub  ========
   420         *  @_nodoc
   421         *  Timer requires acknowledgement
   422         *
   423         *  @param(arg)     timer object passed in as argument.
   424         */
   425        Void stub(UArg arg);
   426    
   427        /*!
   428         *  ======== dynStub  ========
   429         *  @_nodoc
   430         *  Acknowledges timer interrupt and sets next threshold for interrupt.
   431         *
   432         *  @param(arg)     timer object passed in as argument.
   433         */
   434        Void dynStub(UArg arg);
   435    
   436        /*!
   437         *  ======== getHandle ========
   438         *  Get Handle associated with a timer id.
   439         *
   440         *  @param(id)      timer Id
   441         *  @b(returns)     timer handle
   442         */
   443        Handle getHandle(UInt id);
   444    
   445    instance:
   446    
   447        /*! 
   448         *  ======== tiocpCfg ========
   449         *  Initial Timer TIOCP_CFG Register bit settings.
   450         *
   451         *  For a detailed description of this timer register, please
   452         *  refer to your device's Technical Reference Manual.
   453         */
   454        config TiocpCfg tiocpCfg = {idlemode: 0, emufree: 0, softreset: 1};
   455    
   456        /*! 
   457         *  ======== tier ========
   458         *  Initial Timer IRQSTATUS_SET Register bit settings.
   459         *
   460         *  For a detailed description of this timer register, please
   461         *  refer to your device's Technical Reference Manual.
   462         */
   463        config Tier tier = {mat_it_ena: 0, ovf_it_ena: 1, tcar_it_ena: 0};
   464    
   465        /*! 
   466         *  ======== twer ========
   467         *  Initial Timer IRQ Wakeup Enable Register bit settings.
   468         *
   469         *  For a detailed description of this timer register, please
   470         *  refer to your device's Technical Reference Manual.
   471         */
   472        config Twer twer = {mat_wup_ena: 0, ovf_wup_ena: 0, tcar_wup_ena: 0};
   473    
   474        /*! 
   475         *  ======== tclr ========
   476         *  Initial Timer Control Register bit settings.
   477         *
   478         *  For a detailed description of this timer register, please
   479         *  refer to your device's Technical Reference Manual.
   480         */
   481        config Tclr tclr = {ptv: 0, pre: 0, ce: 0, scpwm: 0, tcm: 0, trg: 0,
   482            pt: 0, captmode: 0, gpocfg: 0};
   483        
   484        /*! 
   485         *  ======== tsicr ========
   486         *  Initial Timer Synchronous Interface Control Register bit settings.
   487         *
   488         *  For a detailed description of this timer register, please
   489         *  refer to your device's Technical Reference Manual.
   490         */
   491        config Tsicr tsicr = {sft: 0, posted: 0};
   492    
   493        /*! 
   494         *  ======== tmar ========
   495         *  Initial Timer Match Register setting.
   496         *
   497         *  For a detailed description of this timer register, please
   498         *  refer to your device's Technical Reference Manual.
   499         */
   500        config UInt32 tmar = 0;
   501    
   502        /*! 
   503         *  ======== intNum ========
   504         *  Hwi interrupt number to be used by Timer.
   505         */
   506        config Int intNum = -1;
   507    
   508        /*! 
   509         *  ======== eventId ========
   510         *  Hwi event Id to be used by Timer.
   511         */
   512        config Int eventId = -1;
   513    
   514        /*! Hwi Params for Hwi Object. Default is null. */
   515        config Hwi.Params *hwiParams = null;
   516    
   517        /*!
   518         *  ======== reconfig ========
   519         *  Used to modify static timer instances at runtime.
   520         *
   521         *  @param(timerParams)     timer Params
   522         *  @param(tickFxn)         functions that runs when timer expires
   523         */
   524        Void reconfig(FuncPtr tickFxn, const Params *timerParams, Error.Block *eb);
   525    
   526        /*!
   527         *  ======== getRollovers  ========
   528         *  @_nodoc
   529         *  Returns the total number of timer rollovers since the timer was 
   530         *  started.  This API is used internally for implementing timestamping 
   531         *  when the timer is shared with Clock, and running with RunMode_DYNAMIC.
   532         *  It has no other intended purpose.
   533         *
   534         *  @b(returns)     number of rollovers since timer was started
   535         */
   536        UInt32 getRollovers();
   537    
   538        /*!
   539         *  ======== enableTimestamping  ========
   540         *  @_nodoc
   541         *  Enables the timer to be used for timestamping purposes.  This API is 
   542         *  used internally for enabling timestamping when the timer is shared with
   543         *  Clock, and running with RunMode_DYNAMIC. It has no other intended 
   544         *  purpose.
   545         *
   546         */
   547        Void enableTimestamping();
   548        
   549        /*!
   550         *  ======== restoreRegisters ========
   551         *  Restore timer registers to their nominal state following a power down.
   552         *
   553         *  All registers are restored to their nominal operating state, except
   554         *  for those registers and bits associated with starting the timer.
   555         *  
   556         *  Following a power down, the user should do the following to restore
   557         *  and restart the timer:
   558         *
   559         *  @p(code)
   560         *      Timer_handle timer;
   561         *      Error_Block eb;
   562         *
   563         *      Timer_restoreRegisters(timer, &eb);
   564         *      Timer_start(timer);
   565         *  @p
   566         *
   567         */
   568        Void restoreRegisters(Error.Block *eb);
   569        
   570        /*! @_nodoc
   571         *  ======== getIntNum ========
   572         *  Get Timer's Interrupt number.
   573         *
   574         *  @b(returns)     Timer's Interrupt number
   575         */
   576        Int getIntNum();
   577    
   578    internal:   /* not for client use */
   579        
   580    
   581        /*! Information about timer */
   582        struct TimerDevice {
   583            Int  intNum;
   584            Int  eventId;
   585            Ptr  baseAddr;
   586        };
   587    
   588        /*! Device-specific Timer implementation. */
   589        proxy TimerSupportProxy inherits ti.sysbios.interfaces.ITimerSupport;
   590    
   591        /*!
   592         *  ======== startupNeeded ========
   593         *  This flag is use to prevent Timer_startup code (includes postInit(),
   594         *  deviceConfig(), initDevice() to be brought in un-necessarily.
   595         */
   596        config Bool startupNeeded = false;
   597    
   598        /*!
   599         *  ======== numTimerDevices ========
   600         *  The number of logical timers on a device.
   601         */
   602        config Int numTimerDevices;
   603    
   604        /*
   605         *  ======== deviceConfig ========
   606         *  Configure the timer.
   607         */
   608        Int deviceConfig(Object *timer, Error.Block *eb);
   609    
   610        /*
   611         *  ======== initDevice ========
   612         *  reset timer to its resting state
   613         */
   614        Void initDevice(Object *timer, Error.Block *eb);
   615    
   616        /*
   617         *  ======== initObj ========
   618         *  Initialize the instance state object
   619         */
   620        Void initObj(Object *timer, FuncPtr tickFxn, const Params *timerParams);
   621    
   622        /*
   623         *  ======== postInit ========
   624         *  finish initializing static and dynamic Timers
   625         */
   626        Int postInit(Object *timer, Error.Block *eb);
   627    
   628        /*
   629         *  ======== checkOverflow ========
   630         */
   631        Bool checkOverflow(UInt32 a, UInt32 b);
   632    
   633        /*
   634         *  ======== getNextAvailableTimerId ========
   635         */
   636        UInt getNextAvailableTimerId(Object *timer);
   637    
   638        /*!
   639         *  ======== spinLoop ========
   640         *  used by trigger function.
   641         */
   642        Void spinLoop(UInt count);
   643        
   644        /*!
   645         *  ======== checkFreq ========
   646         *  Used to verify that the DMTimer is operating at the right frequency.
   647         */
   648        Void checkFreq(Timer.Object *obj);
   649    
   650        /*! Instance state structure */
   651        struct Instance_State {
   652            Bool                staticInst;     /* statically created or not */
   653            Int                 id;             /* logical timer id. */
   654            UInt                tiocpCfg;
   655            UInt                tmar;
   656            UInt                tier;
   657            UInt                twer;
   658            UInt                tclr;
   659            UInt                tsicr;
   660            ITimer.RunMode      runMode;        /* timer mode */
   661            ITimer.StartMode    startMode;      /* timer mode */
   662            UInt                period;         /* period */
   663            ITimer.PeriodType   periodType;     /* type (microsecs, inst) */
   664            UInt                intNum;         /* intr num */
   665            Int                 eventId;        /* event Id */
   666            UArg                arg;            /* isrFxn arg */
   667            Hwi.FuncPtr         tickFxn;        /* Timer fxn plugged into Hwi */
   668            Types.FreqHz        extFreq;        /* ext freq */
   669            Hwi.Handle          hwi;            /* hwi inst */
   670            UInt                prevThreshold;  /* previous interrupt thresh */
   671            UInt                rollovers;      /* total timer rollovers */
   672            UInt                savedCurrCount; /* used with setNextTick */
   673            /* 
   674             * Used by Timer Startup to decide whether to use default Event Id 
   675             * from the device Table or use the User provided Event Id 
   676             */
   677            Bool                useDefaultEventId;
   678        }
   679    
   680        /*! Module state structure */
   681        struct Module_State {
   682            Bits32          availMask;      /* avaliable 32-bit timer halves */
   683            Types.FreqHz    intFreqs[];     /* internal frequency in Hz */
   684            TimerDevice     device[];       /* timer device information */
   685            Handle          handles[];      /* handles based on logical id */
   686            Bool            firstInit;
   687        }
   688    }