1    /*
     2     * Copyright (c) 2015, 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     *  ======== Hwi.xdc ========
    34     *
    35     */
    36    
    37    package ti.sysbios.family.c64p;
    38    
    39    import xdc.rov.ViewInfo;
    40    
    41    import xdc.runtime.Diags;
    42    import xdc.runtime.Error;
    43    import xdc.runtime.Log;
    44    
    45    /*!
    46     *  ======== Hwi ========
    47     *  C64+ Hardware Interrupt Support Module.
    48     *
    49     *  This Hwi module provides C64+ family-specific implementations of the
    50     *  APIs defined in {@link ti.sysbios.interfaces.IHwi IHwi}.
    51     *
    52     *  Additional C64+ device-specific APIs are also provided.
    53     *
    54     *  An example of creating a Hwi instance:
    55     *
    56     *  @p(code)
    57     *
    58     *  Int intNum;
    59     *  Hwi_Params params;
    60     *  Error_Block eb;
    61     *
    62     *  // Initialize the error block
    63     *  Error_init(&eb);
    64     *
    65     *  // Initialize the Hwi parameters
    66     *  Hwi_Params_init(&params);
    67     *
    68     *  // Set the GEM event id in the params
    69     *  params.eventId = 78
    70     *
    71     *  // Specify the interrupt vector number
    72     *  intNum = 8;
    73     *
    74     *  // create the Hwi for the specified interrupt number and params
    75     *  Hwi_create(intNum, myIsr, &params, &eb);
    76     *
    77     *  @p
    78     *
    79     *  @a(NOTE)
    80     *  In this Hwi module implementation, the instance config parameter value
    81     *  {@link #MaskingOption_LOWER} is equivalent to {@link #MaskingOption_SELF}.
    82     *  Statically configuring a Hwi object's {@link #Params.maskSetting} to
    83     *  {@link #MaskingOption_LOWER} will result in the generation of a benign
    84     *  build warning. Dynamic usages of {@link #MaskingOption_LOWER} will be
    85     *  silently converted to {@link #MaskingOption_SELF}.
    86     *
    87     *  @p(html)
    88     *  <h3> Calling Context </h3>
    89     *  <table border="1" cellpadding="3">
    90     *    <colgroup span="1"></colgroup> <colgroup span="5" align="center"></colgroup>
    91     *
    92     *    <tr><th> Function                 </th><th>  Hwi   </th><th>  Swi   </th><th>  Task  </th><th>  Main  </th><th>  Startup  </th></tr>
    93     *    <!--                                                                                                                 -->
    94     *    <tr><td> {@link #clearInterrupt}   </td><td>   Y    </td><td>   Y    </td><td>   Y    </td><td>   Y    </td><td>   Y    </td></tr>
    95     *    <tr><td> {@link #create}           </td><td>   N    </td><td>   N    </td><td>   Y    </td><td>   Y    </td><td>   N    </td></tr>
    96     *    <tr><td> {@link #disable}          </td><td>   Y    </td><td>   Y    </td><td>   Y    </td><td>   Y    </td><td>   Y    </td></tr>
    97     *    <tr><td> {@link #disableIER}       </td><td>   Y    </td><td>   Y    </td><td>   Y    </td><td>   Y    </td><td>   N    </td></tr>
    98     *    <tr><td> {@link #disableInterrupt} </td><td>   Y    </td><td>   Y    </td><td>   Y    </td><td>   Y    </td><td>   N    </td></tr>
    99     *    <tr><td> {@link #enable}           </td><td>   Y    </td><td>   Y    </td><td>   Y    </td><td>   N    </td><td>   N    </td></tr>
   100     *    <tr><td> {@link #enableIER}        </td><td>   Y    </td><td>   Y    </td><td>   Y    </td><td>   Y    </td><td>   N    </td></tr>
   101     *    <tr><td> {@link #enableInterrupt}  </td><td>   Y    </td><td>   Y    </td><td>   Y    </td><td>   Y    </td><td>   N    </td></tr>
   102     *    <tr><td> {@link #eventMap}         </td><td>   Y    </td><td>   Y    </td><td>   Y    </td><td>   Y    </td><td>   N    </td></tr>
   103     *    <tr><td> {@link #getEventId}       </td><td>   Y    </td><td>   Y    </td><td>   Y    </td><td>   Y    </td><td>   N    </td></tr>
   104     *    <tr><td> {@link #getHandle}        </td><td>   Y    </td><td>   Y    </td><td>   Y    </td><td>   Y    </td><td>   N    </td></tr>
   105     *    <tr><td> {@link #Params_init}      </td><td>   Y    </td><td>   Y    </td><td>   Y    </td><td>   Y    </td><td>   Y    </td></tr>
   106     *    <tr><td> {@link #restore}          </td><td>   Y    </td><td>   Y    </td><td>   Y    </td><td>   Y    </td><td>   Y    </td></tr>
   107     *    <tr><td> {@link #restoreIER}       </td><td>   Y    </td><td>   Y    </td><td>   Y    </td><td>   Y    </td><td>   N    </td></tr>
   108     *    <tr><td> {@link #restoreInterrupt} </td><td>   Y    </td><td>   Y    </td><td>   Y    </td><td>   Y    </td><td>   Y    </td></tr>
   109     *    <tr><td> {@link #construct}        </td><td>   N    </td><td>   N    </td><td>   Y    </td><td>   Y    </td><td>   N    </td></tr>
   110     *    <tr><td> {@link #delete}           </td><td>   N    </td><td>   N    </td><td>   Y    </td><td>   Y    </td><td>   N    </td></tr>
   111     *    <tr><td> {@link #destruct}         </td><td>   N    </td><td>   N    </td><td>   Y    </td><td>   Y    </td><td>   N    </td></tr>
   112     *    <tr><td> {@link #getHookContext}   </td><td>   Y    </td><td>   Y    </td><td>   Y    </td><td>   Y    </td><td>   N    </td></tr>
   113     *    <tr><td> {@link #reconfig}         </td><td>   Y    </td><td>   Y    </td><td>   Y    </td><td>   Y    </td><td>   N    </td></tr>
   114     *    <tr><td> {@link #setFunc}          </td><td>   Y    </td><td>   Y    </td><td>   Y    </td><td>   Y    </td><td>   N    </td></tr>
   115     *    <tr><td> {@link #setHookContext}   </td><td>   Y    </td><td>   Y    </td><td>   Y    </td><td>   Y    </td><td>   N    </td></tr>
   116     *    <tr><td colspan="6"> Definitions: <br />
   117     *       <ul>
   118     *         <li> <b>Hwi</b>: API is callable from a Hwi thread. </li>
   119     *         <li> <b>Swi</b>: API is callable from a Swi thread. </li>
   120     *         <li> <b>Task</b>: API is callable from a Task thread. </li>
   121     *         <li> <b>Main</b>: API is callable during any of these phases: </li>
   122     *           <ul>
   123     *             <li> In your module startup after this module is started (e.g. Hwi_Module_startupDone() returns TRUE). </li>
   124     *             <li> During xdc.runtime.Startup.lastFxns. </li>
   125     *             <li> During main().</li>
   126     *             <li> During BIOS.startupFxns.</li>
   127     *           </ul>
   128     *         <li> <b>Startup</b>: API is callable during any of these phases:</li>
   129     *           <ul>
   130     *             <li> During xdc.runtime.Startup.firstFxns.</li>
   131     *             <li> In your module startup before this module is started (e.g. Hwi_Module_startupDone() returns FALSE).</li>
   132     *           </ul>
   133     *       </ul>
   134     *    </td></tr>
   135     *
   136     *  </table>
   137     *  @p
   138     */
   139    
   140    @Template("./Hwi.xdt")  /* generates the vector table and the dispatcher */
   141    @ModuleStartup          /* generate a call to Hwi_init at startup */
   142    @InstanceInitStatic     /* allow constructs in static only systems */
   143    
   144    module Hwi inherits ti.sysbios.interfaces.IHwi
   145    {
   146        // -------- Module Constants --------
   147    
   148        /*! C64+ supports 16 interrupts. */
   149        const Int NUM_INTERRUPTS = 16;
   150    
   151        // -------- Module Types --------
   152    
   153        /*! @_nodoc Hwi plug function type definition. */
   154        typedef Void (*PlugFuncPtr)(void);
   155    
   156        /*!
   157         *  ======== BasicView ========
   158         *  @_nodoc
   159         */
   160        metaonly struct BasicView {
   161            Ptr     halHwiHandle;
   162            String  label;
   163            UInt    intNum;
   164            String  fxn;
   165            UArg    arg;           // Argument to Hwi function.
   166            Ptr     irp;
   167            UInt    eventId;
   168            String  disableMask;   // Interrupts to mask during ISR.
   169            String  restoreMask;   // Interrupts to restore after ISR.
   170        };
   171    
   172        /*!
   173         *  ======== ModuleView ========
   174         *  @_nodoc
   175         */
   176        metaonly struct ModuleView {
   177            String  options[4];
   178            String  hwiStackPeak;
   179            SizeT   hwiStackSize;
   180            Ptr     hwiStackBase;
   181        };
   182    
   183        /*!
   184         *  ======== rovViewInfo ========
   185         *  @_nodoc
   186         */
   187        @Facet
   188        metaonly config ViewInfo.Instance rovViewInfo =
   189            ViewInfo.create({
   190                viewMap: [
   191                    ['Basic',    {type: ViewInfo.INSTANCE, viewInitFxn: 'viewInitBasic',    structName: 'BasicView'}],
   192                    ['Module',   {type: ViewInfo.MODULE,   viewInitFxn: 'viewInitModule',   structName: 'ModuleView'}]
   193                ]
   194            });
   195    
   196        // -------- Module Parameters --------
   197    
   198        /*!
   199         *  non-dispatched interrupt object.
   200         *  provided so that XGCONF users can easily plug non-dispatched interrupts
   201         */
   202        metaonly struct NonDispatchedInterrupt {
   203            Int         intNum;
   204            PlugFuncPtr fxn;        /*! "Hwi_plug'd" ISR function. */
   205            Bool        enableInt;
   206            Int         eventId;
   207        };
   208    
   209        /*!
   210         *  non-dispatched interrupt array.
   211         *  provided so that XGCONF users can easily plug non-dispatched interrupts
   212         */
   213        metaonly config NonDispatchedInterrupt nonDispatchedInterrupts[string];
   214    
   215        /*!
   216         *  Alternate reset vector address. Default is undefined.
   217         *
   218         *  if initialized by the user then an additional reset vector
   219         *  is created and placed in the ".resetVector" section.
   220         *  To place the .resetVector section into a specific memory section,
   221         *  add the following command to your config script:
   222         *  @p(code)
   223         *  Program.sectMap[".resetVector"] = YourMemorySection;
   224         *  @p
   225         */
   226        metaonly config Ptr resetVectorAddress;
   227    
   228        /*!
   229         *  Error raised when Hwi is already defined
   230         */
   231        config Error.Id E_alreadyDefined = {
   232            msg: "E_alreadyDefined: Hwi already defined: intr# %d"
   233        };
   234    
   235        /*!
   236         *  Error raised when Hwi handle referenced in Hwi_delete()
   237         *  is not found in the Hwi dispatch table
   238         */
   239        config Error.Id E_handleNotFound = {
   240            msg: "E_handleNotFound: Hwi handle not found: 0x%x"
   241        };
   242    
   243        /*!
   244         *  Error raised when a secure context failed to be allocated
   245         */
   246        config Error.Id E_allocSCFailed = {
   247            msg: "E_allocSCFailed: Alloc secure context failed"
   248        };
   249    
   250        /*!
   251         *  Error raised when a secure context failed to be registered
   252         */
   253        config Error.Id E_registerSCFailed = {
   254            msg: "E_registerSCFailed: Register secure context failed"
   255        };
   256    
   257        /*!
   258         *  Error raised when an invalid interrupt number is passed in
   259         */
   260        config Error.Id E_invalidIntNum = {
   261            msg: "E_invalidIntNum: Invalid interrupt number: intr# %d"
   262        };
   263    
   264        /*!
   265         *  Issued just prior to Hwi function invocation (with interrupts disabled)
   266         */
   267        config Log.Event LM_begin = {
   268            mask: Diags.USER1 | Diags.USER2,
   269            msg: "LM_begin: hwi: 0x%x, func: 0x%x, preThread: %d, intNum: %d, irp: 0x%x"
   270        };
   271    
   272        /*!
   273         *  Issued just after return from Hwi function (with interrupts disabled)
   274         */
   275        config Log.Event LD_end = {
   276            mask: Diags.USER2,
   277            msg: "LD_end: hwi: 0x%x"
   278        };
   279    
   280        /*!
   281         *  enable Exception module for exception processing.
   282         */
   283        config Bool enableException = true;
   284    
   285        // -------- Module Functions --------
   286    
   287        /*!
   288         *  ======== disable ========
   289         *  Globally disable interrupts.
   290         *
   291         *  Hwi_disable globally disables hardware interrupts and returns an
   292         *  opaque key indicating whether interrupts were globally enabled or
   293         *  disabled on entry to Hwi_disable(). 
   294         *  The actual value of the key is target/device specific and is meant 
   295         *  to be passed to Hwi_restore(). 
   296         *
   297         *  Call Hwi_disable before a portion of a function that needs
   298         *  to run without interruption. When critical processing is complete, call
   299         *  Hwi_restore or Hwi_enable to reenable hardware interrupts.
   300         *
   301         *  Servicing of interrupts that occur while interrupts are disabled is
   302         *  postponed until interrupts are reenabled. However, if the same type 
   303         *  of interrupt occurs several times while interrupts are disabled, 
   304         *  the interrupt's function is executed only once when interrupts are 
   305         *  reenabled.
   306         *
   307         *  A context switch can occur when calling Hwi_enable or Hwi_restore if
   308         *  an enabled interrupt occurred while interrupts are disabled.
   309         *
   310         *  Hwi_disable may be called from main(). However, since Hwi interrupts
   311         *  are already disabled in main(), such a call has no effect.
   312         *
   313         *  @a(constraints)
   314         *  If a Task switching API such as 
   315         *  {@link ti.sysbios.knl.Semaphore#pend Semaphore_pend()}, 
   316         *  {@link ti.sysbios.knl.Semaphore#post Semaphore_post()},
   317         *  {@link ti.sysbios.knl.Task#sleep Task_sleep()}, or
   318         *  {@link ti.sysbios.knl.Task#yield Task_yield()} 
   319         *  is invoked which results in a context switch while
   320         *  interrupts are disabled, an embedded call to 
   321         *  {@link #enable Hwi_enable} occurs
   322         *  on the way to the new thread context which unconditionally re-enables
   323         *  interrupts. Interrupts will remain enabled until a subsequent 
   324         *  {@link #disable Hwi_disable}
   325         *  invocation.
   326         *
   327         *  Swis always run with interrupts enabled.
   328         *  See {@link ti.sysbios.knl.Swi#post Swi_post()} for a discussion Swis and
   329         *  interrupts.
   330         *
   331         *  @b(returns)     opaque key for use by Hwi_restore()
   332         */
   333        @Macro
   334        override UInt disable();
   335    
   336        /*!
   337         *  ======== enable ========
   338         */
   339        @Macro
   340        override UInt enable();
   341    
   342        /*!
   343         *  ======== restore ========
   344         */
   345        @Macro
   346        override Void restore(UInt key);
   347    
   348        /*!
   349         *  ======== inUseMeta ========
   350         *  @_nodoc
   351         *  Check for Hwi already in use.
   352         *  For internal SYS/BIOS use only.
   353         *  Should be called prior to any internal Hwi.create().
   354         *
   355         *  @param(intNum)  interrupt number
   356         */
   357        metaonly Bool inUseMeta(UInt intNum);
   358    
   359        /*!
   360         *  ======== eventMap ========
   361         *  Maps a GEM event to interrupt number
   362         *
   363         *  Function maps a GEM event to an interrupt number so that the
   364         *  event is the interrupt source of the vector.
   365         *
   366         *  @p(code)
   367         *      // Maps GEM event #65 as the interrupt source of int vector #7
   368         *      Hwi_eventMap(7, 65);
   369         *  @p
   370         *
   371         *  @param(intNum)  interrupt number
   372         *  @param(eventId) event ID
   373         */
   374        Void eventMap(Int intNum, Int eventId);
   375    
   376        /*!
   377         *  ======== eventMapMeta ========
   378         *  Maps GEM Event to interrupt number statically
   379         *
   380         *  Function maps a GEM event to an interrupt number so that the
   381         *  event is the interrupt source of the vector.
   382         *
   383         *  @p(code)
   384         *      // Maps GEM event #65 as the interrupt source of int vector #7
   385         *      Hwi.eventMapMeta(7, 65);
   386         *  @p
   387         *
   388         *  @param(intNum)      interrupt number
   389         *  @param(eventId)     event Id
   390         */
   391        metaonly Void eventMapMeta(Int intNum, Int eventId);
   392    
   393        /*!
   394         *  ======== plug ========
   395         *  Plug an interrupt vector with an ISR address.
   396         *
   397         *  Hwi_plug writes an Interrupt Service Fetch Packet (ISFP) into the
   398         *  Interrupt Service Table (IST), at the address corresponding to intNum
   399         *  The op-codes written in the ISFP create a branch to the function
   400         *  entry  point specified by fxn:
   401         *
   402         *  @p(code)
   403         *          stw     b0, *SP--[1]
   404         *          mvk     fxn, b0
   405         *          mvkh    fxn, b0
   406         *          b       b0
   407         *          ldw     *++SP[1],b0
   408         *          nop     4
   409         *  @p
   410         *
   411         *  Hwi_plug hooks up the specified function as the branch target of a
   412         *  hardware interrupt (fielded by the CPU) at the vector address
   413         *  specified in intNum. Hwi_plug does not enable the interrupt.
   414         *  Use Hwi_enableIER to enable specific interrupts.
   415         *
   416         *  AN ISR PLUGGED WITH THIS API IS NOT SERVICED BY THE INTERRUPT
   417         *  DISPATCHER. CONSEQUENTLY, IT SHOULD NOT INVOKE ANY SYS/BIOS APIs
   418         *  (ie Semaphore_post())!!!
   419         *
   420         *  @a(constraints)
   421         *  o interrupt function MUST NOT INTERACT WITH SYS/BIOS.
   422         *    (ie do not call Semaphore_post())
   423         *
   424         *  o vecid must be a valid interrupt ID in the range of 0-15.
   425         *
   426         *  @param(intNum)  interrupt number
   427         *  @param(fxn)     pointer to ISR function
   428         */
   429        Void plug(UInt intNum, PlugFuncPtr fxn);
   430    
   431        /*!
   432         *  ======== plugMeta ========
   433         *  Statically plug an interrupt vector with an ISR address.
   434         *
   435         *  @param(intNum)  interrupt number
   436         *  @param(fxn)     pointer to ISR function
   437         */
   438        metaonly Void plugMeta(UInt intNum, PlugFuncPtr fxn);
   439    
   440        /*!
   441         *  ======== getEventId ========
   442         *  Returns event id associated with interrupt number
   443         *
   444         *  If a bad interrupt number is passed in, it will return -1.
   445         *
   446         *  @param(intNum)  interrupt number
   447         *  @b(returns)     event id associated with intNum
   448         */
   449        Int getEventId(UInt intNum);
   450    
   451        /*!
   452         *  ======== getHandle ========
   453         *  Returns Hwi_handle associated with interrupt number
   454         *
   455         *  @param(intNum)  interrupt number
   456         *  @b(returns)     handle associated with intNum
   457         */
   458        Handle getHandle(UInt intNum);
   459    
   460        /*!
   461         *  ======== disableIER ========
   462         *  Disable certain maskable interrupts.
   463         *
   464         *  Atomically disables specific interrupts by clearing the bits
   465         *  specified by mask in the Interrupt Enable Register (IER).
   466         *
   467         *  The IER bits to be cleared should be set to 1 in the mask.
   468         *
   469         *  @param(mask)    bitmask of interrupts to disable
   470         *  @b(returns)     previous IER settings bitmask
   471         */
   472        Bits16 disableIER(Bits16 mask);
   473    
   474        /*!
   475         *  ======== enableIER ========
   476         *  Enable certain maskable interrupts.
   477         *
   478         *  Atomically enables specific interrupts by setting the bits
   479         *  specified by mask in the Interrupt Enable Register (IER).
   480         *
   481         *  The IER bits to be set should be set to 1 in the mask.
   482         *
   483         *  @param(mask)    bitmask of interrupts to enable
   484         *  @b(returns)     previous IER settings bitmask
   485         */
   486        Bits16 enableIER(Bits16 mask);
   487    
   488        /*!
   489         *  ======== restoreIER ========
   490         *  Restore maskable interrupts to the state they were in
   491         *  when either disableIER() or enableIER() was called.
   492         *
   493         *  Atomically writes the given mask to the IER register. Typically used
   494         *  to restore the IER register to the state returned from a call to
   495         *  either {@link #disableIER()} or {@link #enableIER()}.
   496         *
   497         *  @param(mask)    bitmask of interrupts to restore
   498         *  @b(returns)     previous IER settings bitmask
   499         */
   500        Bits16 restoreIER(Bits16 mask);
   501    
   502    instance:
   503    
   504        /*!
   505         *  Dispatcher auto-nesting interrupt disable mask.
   506         *
   507         *  When the dispatcher's auto interrupt nesting support feature
   508         *  is enabled (see {@link #dispatcherAutoNestingSupport}),
   509         *  this mask defines which IER bits are disabled prior to invoking
   510         *  the user's ISR function with GIE = 1.
   511         *
   512         *  disableMask bits set to 1 correspond to IER bits that will be cleared
   513         *  prior to invoking the ISR.
   514         *
   515         *  The value of this mask is normally auto-calculated based on the
   516         *  value of the maskSetting. However, manual setting of this
   517         *  mask is enabled by setting the maskSetting to
   518         *  {@link #MaskingOption MaskingOption_BITMASK}.
   519         *
   520         *  The default value is derived from the
   521         *  {@link #MaskingOption MaskingOption_SELF}
   522         *  maskSetting.
   523         */
   524        config Bits16 disableMask = 0;
   525    
   526        /*!
   527         *  Dispatcher auto-nesting interrupt restore mask.
   528         *
   529         *  When the dispatcher's auto interrupt nesting support feature
   530         *  is enabled (see {@link #dispatcherAutoNestingSupport}),
   531         *  this mask defines which IER bits are restored to their previous
   532         *  setting upon return from the user's ISR function.
   533         *
   534         *  restoreMask bits set to 1 correspond to IER bits that will be restored.
   535         *
   536         *  The value of this mask is normally auto-calculated based on the
   537         *  value of the maskSetting. However, manual setting of this
   538         *  mask is enabled by setting the maskSetting to
   539         *  {@link #MaskingOption MaskingOption_BITMASK}.
   540         *
   541         *  The default value is derived from the
   542         *  {@link #MaskingOption MaskingOption_SELF}
   543         *  maskSetting.
   544         */
   545        config Bits16 restoreMask = 0;
   546    
   547        /*!
   548         *  Interrupt priority. Not supported on this target.
   549         */
   550        override config Int priority = 0;
   551    
   552        /*!
   553         *  ======== reconfig ========
   554         *  Reconfigures a dispatched interrupt.
   555         *
   556         *  This function reconfigures the dispatched interrupt so the
   557         *  specified function is called with the specified parameters.
   558         *
   559         *  @param(fxn)     pointer to ISR function
   560         *  @param(params)  pointer to Hwi parameter structure
   561         */
   562        Void reconfig(FuncPtr fxn, const Params *params);
   563    
   564    internal:   /* not for client use */
   565    
   566        /*
   567         * Swi and Task module function pointers.
   568         * Used to decouple Hwi from Swi and Task when
   569         * dispatcherSwiSupport or
   570         * dispatcherTaskSupport is false.
   571         */
   572        config UInt (*swiDisable)();
   573        config Void (*swiRestoreHwi)(UInt);
   574        config UInt (*taskDisable)();
   575        config Void (*taskRestoreHwi)(UInt);
   576    
   577        /*
   578         *  ======== getIsrStackAddress ========
   579         *  Returns initial isrStack address.
   580         *  This API was developed solely for the Exception module
   581         *  to allow removal of the Hwi_link.xdt template definition
   582         *  of ti_sysbios_family_c64p_Hwi_isrStack which was not
   583         *  ROM-able
   584         */
   585        Char *getIsrStackAddress();
   586    
   587        /* Interrupt Dispatcher */
   588        Void dispatchC(Int intNum);
   589    
   590        /* Interrupt dispatcher core */
   591        Void dispatchCore(Int intNum);
   592    
   593        /* unPlugged interrupt handler */
   594        Void unPluggedInterrupt();
   595    
   596        /* assembly language code that switches SP and calls dispatchCore */
   597        Void switchAndDispatch(Int intNum);
   598    
   599        /* setup a secure context */
   600        Void setupSC();
   601    
   602        /*
   603         *  ======== postInit ========
   604         */
   605        Int postInit(Object *hwi, Error.Block *eb);
   606    
   607        /*!
   608         *  const array to hold all HookSet objects.
   609         */
   610        config HookSet hooks[length] = [];
   611    
   612        /*! Meta World Only Hwi Configuration Object. */
   613        metaonly struct InterruptObj {
   614            String name;        /* symbol used for vector table entry */
   615            Bool used;          /* Interrupt already defined? */
   616            Bool useDispatcher; /* Should dispatcher handle this Int? */
   617            FuncPtr fxn;        /* Dispatched ISR function */
   618            PlugFuncPtr pfxn;   /* "Hwi_plug'd" ISR function. */
   619        };
   620    
   621        /*!
   622         * Meta-only array of interrupt objects.
   623         * This meta-only array of Hwi config objects is initialized
   624         * in Hwi.xs:module$meta$init().
   625         */
   626        metaonly config InterruptObj interrupt[NUM_INTERRUPTS];
   627    
   628        struct Instance_State {
   629            Bits16  disableMask;    // Interrupts to mask during ISR.
   630            Bits16  restoreMask;    // Interrupts to restore after ISR.
   631            UArg    arg;            // Argument to Hwi function.
   632            FuncPtr fxn;            // Hwi function.
   633            Irp     irp;            // current IRP
   634            Ptr     hookEnv[];
   635        };
   636    
   637        struct Module_State {
   638            Char        intEvents[16];  // Initial event mapping
   639            Bits16      ierMask;        // Initial IER mask
   640            volatile Int intNum;        // Interrupt number
   641            Char        *taskSP;        // temporary storage of interrupted
   642                                        // Task's SP during ISR execution
   643            /* ROM */
   644            Char        *isrStack;      // Points to isrStack address
   645            Ptr         vectorTableBase;// ti_sysbios_family_c64_Hwi0
   646            Ptr         bss;            // bss address
   647            Int         scw;            // secure context word
   648    
   649            Handle      dispatchTable[NUM_INTERRUPTS];  // dispatch table
   650        };
   651    }