1    /* 
     2     * Copyright (c) 2012, 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     *  ======== IHwi.xdc ========
    34     *
    35     */
    36    
    37    import xdc.runtime.Error;
    38    
    39    
    40    /*!
    41     *  ======== Hwi ========
    42     *  Hardware Interrupt Support Module.
    43     *
    44     *  The IHwi interface specifies APIs for globally enabling, disabling, and
    45     *  restoring interrupts.
    46     *
    47     *  Additionally, management of individual, device-specific hardware 
    48     *  interrupts is provided.
    49     *
    50     *  The user can statically or dynamically assign routines that run when 
    51     *  specific hardware interrupts occur. 
    52     *
    53     *  Dynamic assignment of Hwi routines to interrupts at run-time is done 
    54     *  using the Hwi_create function.
    55     *
    56     *  Interrupt routines can be written completely in C, completely in 
    57     *  assembly, or in a mix of C and assembly. In order to support interrupt
    58     *  routines
    59     *  written completely in C, an interrupt dispatcher is provided that performs
    60     *  the requisite prolog and epilog for an interrupt routine.
    61     *
    62     *  Some routines are assigned to interrupts by the other SYS/BIOS
    63     *  modules. For example, the Clock module configures its own timer interrupt
    64     *  handler. See the Clock Module for more details.
    65     *
    66     *  @a(Runtime Hwi Creation)
    67     *
    68     *  Below is an example of configuring an interrupt at runtime. 
    69     *  Usually this code would be placed in main().
    70     *
    71     *  @p(code)
    72     *  #include <xdc/runtime/Error.h>
    73     *  #include <ti/sysbios/hal/Hwi.h>
    74     *  
    75     *  Hwi_Handle myHwi;
    76     *  
    77     *  Int main(Int argc, char* argv[])
    78     *  {
    79     *      Hwi_Params hwiParams;
    80     *      Error_Block eb;
    81     *   
    82     *      Hwi_Params_init(&hwiParams);
    83     *      Error_init(&eb);
    84     *  
    85     *      // set the argument you want passed to your ISR function
    86     *      hwiParams.arg = 1;        
    87     *   
    88     *      // set the event id of the peripheral assigned to this interrupt
    89     *      hwiParams.eventId = 10;   
    90     *   
    91     *      // don't allow this interrupt to nest itself
    92     *      hwiParams.maskSetting = Hwi_MaskingOption_SELF;
    93     *   
    94     *      // 
    95     *      // Configure interrupt 5 to invoke "myIsr".
    96     *      // Automatically enables interrupt 5 by default
    97     *      // set params.enableInt = FALSE if you want to control
    98     *      // when the interrupt is enabled using Hwi_enableInterrupt()
    99     *      //
   100     *   
   101     *      myHwi = Hwi_create(5, myIsr, &hwiParams, &eb);
   102     *   
   103     *      if (Error_check(&eb)) {
   104     *          // handle the error
   105     *      }
   106     *  }
   107     *   
   108     *  Void myIsr(UArg arg)
   109     *  {
   110     *      // here when interrupt #5 goes off
   111     *  }
   112     *  @p
   113     *
   114     *  @a(Hook Functions)
   115     *
   116     *  Sets of hook functions can be specified for the Hwi module
   117     *  using the configuration tool.  Each set contains these hook
   118     *  functions:
   119     *  @p(blist)
   120     *  -Register:  A function called before any statically-created Hwis
   121     *      are initialized at runtime.  The register hook is called at boot time
   122     *      before main() and before interrupts are enabled.
   123     *  -Create:    A function that is called when a Hwi is created.
   124     *      This includes hwis that are created statically and those
   125     *      created dynamically using {@link #create Hwi_create}.
   126     *  -Begin:     A function that is called just prior to running a Hwi.
   127     *  -End:       A function that is called just after a Hwi finishes.
   128     *  -Delete:    A function that is called when a Hwi is deleted at
   129     *      run-time with {@link #delete Hwi_delete}.
   130     *  @p
   131     *
   132     *  Register Function
   133     *
   134     *  The Register function is provided to allow a hook set to store its
   135     *  hookset ID.  This id can be passed to 
   136     *  {@link #setHookContext Hwi_setHookContext} and
   137     *  {@link #getHookContext Hwi_getHookContext} to set or get 
   138     *  hookset-specific context.  The
   139     *  Register function must be specified if the hook implementation
   140     *  needs to use {@link #setHookContext  Hwi_setHookContext} or 
   141     *  {@link #getHookContext  Hwi_getHookContext}.
   142     *  The registerFxn hook function is called during system initialization
   143     *  before interrupts have been enabled.
   144     *
   145     *  @p(code)
   146     *  Void myRegisterFxn(Int id);
   147     *  @p
   148     *
   149     *  Create and Delete Functions
   150     * 
   151     *  The create and delete functions are called whenever a Hwi is created
   152     *  or deleted.  They are called with interrupts enabled (unless called 
   153     *  at boot time or from main()).
   154     *
   155     *  @p(code)
   156     *  Void myCreateFxn(Hwi_Handle hwi, Error_Block *eb);
   157     *  @p
   158     *
   159     *  @p(code)
   160     *  Void myDeleteFxn(Hwi_Handle hwi);
   161     *  @p
   162     *
   163     *  Begin and End Functions
   164     *
   165     *  The beginFxn and endFxn function hooks are called with interrupts
   166     *  globally disabled, therefore any hook processing function will contribute
   167     *  to the overall system interrupt response latency.  In order to minimize
   168     *  this impact, carefully consider the processing time spent in an Hwi
   169     *  beginFxn or endFxn function hook.
   170     *
   171     *  @p(code)
   172     *  Void myBeginFxn(Hwi_Handle hwi);
   173     *  @p
   174     *
   175     *  @p(code)
   176     *  Void myEndFxn(Hwi_Handle hwi);
   177     *  @p
   178     *
   179     *  Hook functions can only be configured statically.
   180     */
   181    
   182    @InstanceFinalize
   183    @InstanceInitError
   184    
   185    interface IHwi {
   186    
   187        // -------- Module Types --------
   188    
   189        /*! Hwi create function type definition. */
   190        typedef Void (*FuncPtr)(UArg);
   191        
   192        /*! 
   193         * Interrupt Return Pointer.
   194         *
   195         * This is the address of the interrupted instruction.
   196         */
   197        typedef UArg Irp;
   198       
   199        /*! 
   200         *  Hwi hook set type definition. 
   201         *
   202         *  The functions that make up a hookSet have certain restrictions. They
   203         *  cannot call any Hwi instance functions other than Hwi_getHookContext()
   204         *  and Hwi_setHookContext(). For all practical purposes, they should treat
   205         *  the Hwi_Handle passed to these functions as an opaque handle.
   206         */
   207        struct HookSet {
   208            Void (*registerFxn)(Int);
   209            Void (*createFxn)(Handle, Error.Block *);
   210            Void (*beginFxn)(Handle);
   211            Void (*endFxn)(Handle);
   212            Void (*deleteFxn)(Handle);
   213        };
   214        
   215        /*!
   216         *  ======== MaskingOption ========
   217         *  Shorthand interrupt masking options
   218         *
   219         *  @value(MaskingOption_NONE)      No interrupts are disabled
   220         *
   221         *  @value(MaskingOption_ALL)       All interrupts are disabled
   222         *
   223         *  @value(MaskingOption_SELF)      Only this interrupt is disabled
   224         *
   225         *  @value(MaskingOption_BITMASK)   User supplies interrupt enable masks
   226         *
   227         *  @value(MaskingOption_LOWER)     All current and lower priority
   228         *                                  interrupts are disabled.
   229         *
   230         *                                  Only a few targets/devices truly
   231         *                                  support this masking option. For those
   232         *                                  that don't, this setting is treated
   233         *                                  the same as MaskingOption_SELF.
   234         */
   235        enum MaskingOption {
   236            MaskingOption_NONE,
   237            MaskingOption_ALL, 
   238            MaskingOption_SELF,
   239            MaskingOption_BITMASK,
   240            MaskingOption_LOWER
   241        };
   242    
   243        /*!
   244         *  ======== StackInfo ========
   245         *  Structure contains Hwi stack usage info 
   246         *
   247         *  Used by getStackInfo() and viewGetStackInfo() functions
   248         */
   249        struct StackInfo {
   250            SizeT hwiStackPeak;
   251            SizeT hwiStackSize;
   252            Ptr hwiStackBase;
   253        };
   254    
   255        // -------- Module Parameters --------
   256    
   257        /*!
   258         *  Include interrupt nesting logic in interrupt dispatcher?
   259         *
   260         *  Default is true.
   261         *
   262         *  This option provides the user with the ability to optimize
   263         *  interrupt dispatcher performance when support for interrupt
   264         *  nesting is not required.
   265         *
   266         *  Setting this parameter to false will disable the logic in
   267         *  the interrupt dispatcher that manipulates interrupt mask
   268         *  registers and enables and disables interrupts before and
   269         *  after invoking the user's Hwi function. 
   270         *
   271         *  Set this parameter to false if you don't need interrupts 
   272         *  enabled during the execution of your Hwi functions.
   273         */
   274        config Bool dispatcherAutoNestingSupport = true;
   275    
   276        /*!
   277         *  Include Swi scheduling logic in interrupt dispatcher?
   278         *
   279         *  Default is inherited from {@link ti.sysbios.BIOS#swiEnabled 
   280         *  BIOS.swiEnabled}, which is true by default.
   281         *
   282         *  This option provides the user with the ability to optimize
   283         *  interrupt dispatcher performance when it is known that Swis
   284         *  will not be posted from any of their Hwi threads.
   285         *
   286         *  Setting this parameter to false will disable the logic in
   287         *  the interrupt dispatcher that invokes the Swi scheduler
   288         *  prior to returning from an interrupt.
   289         */
   290        config Bool dispatcherSwiSupport;
   291    
   292        /*!
   293         *  Include Task scheduling logic in interrupt dispatcher?
   294         *
   295         *  Default is inherited from {@link ti.sysbios.BIOS#taskEnabled 
   296         *  BIOS.taskEnabled}, which is true by default.
   297         *
   298         *  This option provides the user with the ability to optimize
   299         *  interrupt dispatcher performance when it is known that no
   300         *  Task scheduling APIs (ie {@link ti.sysbios.knl.Semaphore#post 
   301         *  Semaphore_post()}) will be executed from any of their Hwi threads.
   302         *
   303         *  Setting this parameter to false will disable the logic in
   304         *  the interrupt dispatcher that invokes the Task scheduler
   305         *  prior to returning from an interrupt.
   306         */
   307        config Bool dispatcherTaskSupport;
   308    
   309        /*!
   310         *  Controls whether the
   311         *  dispatcher retains the interrupted thread's return address.
   312         *
   313         *  This option is enabled by default.
   314         *
   315         *  Setting this parameter to false will disable the logic in
   316         *  the interrupt dispatcher that keeps track of the interrupt's
   317         *  return address and provide a small savings in interrupt latency.
   318         *
   319         *  The application can get an interrupt's most recent return
   320         *  address using the {@link #getIrp} API.
   321         */
   322        config Bool dispatcherIrpTrackingSupport = true;
   323    
   324        // -------- Module Functions --------
   325    
   326        /*!
   327         *  ======== addHookSet ========
   328         *  addHookSet is used in a config file to add a hook set (defined
   329         *  by struct HookSet).
   330         *
   331         *  HookSet structure elements may be omitted, in which case those
   332         *  elements will not exist.
   333         *
   334         *  @param(hook)    structure of type HookSet
   335         */
   336        metaonly Void addHookSet(HookSet hook);
   337    
   338        /*!
   339         *  ======== viewGetStackInfo ========
   340         *  @_nodoc
   341         *  Returns the Hwi stack usage info. Used at ROV time.
   342         *
   343         *  @b(returns)     Hwi stack base, size, peak
   344         */
   345        metaonly StackInfo viewGetStackInfo();
   346    
   347        /*!
   348         *  ======== getStackInfo ========
   349         *  Get Hwi stack usage Info.
   350         *
   351         *  getStackInfo returns the Hwi stack usage info to its calling 
   352         *  function by filling stack base address, stack size and stack
   353         *  peak fields in the {@link #StackInfo} structure.
   354         *
   355         *  getStackInfo accepts two arguments, a pointer to a structure
   356         *  of type {@link #StackInfo} and a boolean. If the boolean is set
   357         *  to true, the function computes the stack depth and fills the 
   358         *  stack peak field in the StackInfo structure. If a stack overflow
   359         *  is detected, the stack depth is not computed. If the boolean is 
   360         *  set to false, the function only checks for a stack overflow.
   361         *
   362         *  The isr stack is always checked for an overflow and a boolean
   363         *  is returned to indicate whether an overflow occured.
   364         *
   365         *  Below is an example of calling getStackInfo() API:
   366         *
   367         *  @p(code)
   368         *  #include <ti/sysbios/BIOS.h>
   369         *  #include <ti/sysbios/hal/Hwi.h>
   370         *  #include <ti/sysbios/knl/Swi.h>
   371         *  #include <ti/sysbios/knl/Task.h>
   372         *
   373         *  Swi_Handle swi0;
   374         *  volatile Bool swiStackOverflow = FALSE;
   375         *
   376         *  Void swi0Fxn(UArg arg1, UArg arg2)
   377         *  {
   378         *      Hwi_StackInfo stkInfo;
   379         *
   380         *      // Request stack depth
   381         *      swiStackOverflow = Hwi_getStackInfo(&stkInfo, TRUE);
   382         * 
   383         *      // Alternately, we can omit the request for stack depth and 
   384         *      // request only the stack base and stack size (the check for
   385         *      // stack overflow is always performed):
   386         *      //
   387         *      // swiStackOverflow = Hwi_getStackInfo(&stkInfo, FALSE);
   388         *
   389         *      if (swiStackOverflow) {
   390         *          // isr Stack Overflow detected
   391         *      }
   392         *  }
   393         *
   394         *  Void idleTask()
   395         *  {
   396         *      Swi_post(swi0);
   397         *  }
   398         *
   399         *  Int main(Int argc, char* argv[])
   400         *  {
   401         *      swi0 = Swi_create(swi0Fxn, NULL, NULL);
   402         *
   403         *      BIOS_start();
   404         *      return (0);
   405         *  }
   406         *  @p
   407         *
   408         *  @param(stkInfo) pointer to structure of type {@link #StackInfo}
   409         *  @param(computeStackDepth)       decides whether to compute stack depth
   410         *
   411         *  @b(returns)     boolean to indicate a stack overflow
   412         */
   413        Bool getStackInfo(StackInfo *stkInfo, Bool computeStackDepth);
   414    
   415        /*!
   416         *  ======== startup ========
   417         *  Initially enable interrupts
   418         *
   419         *  Called within BIOS_start
   420         */
   421        @DirectCall
   422        Void startup();
   423    
   424        /*!
   425         *  ======== disable ========
   426         *  Globally disable interrupts.
   427         *
   428         *  Hwi_disable globally disables hardware interrupts and returns an
   429         *  opaque key indicating whether interrupts were globally enabled or
   430         *  disabled on entry to Hwi_disable(). 
   431         *  The actual value of the key is target/device specific and is meant 
   432         *  to be passed to Hwi_restore(). 
   433         *
   434         *  Call Hwi_disable before a portion of a function that needs
   435         *  to run without interruption. When critical processing is complete, call
   436         *  Hwi_restore or Hwi_enable to reenable hardware interrupts.
   437         *
   438         *  Servicing of interrupts that occur while interrupts are disabled is
   439         *  postponed until interrupts are reenabled. However, if the same type 
   440         *  of interrupt occurs several times while interrupts are disabled, 
   441         *  the interrupt's function is executed only once when interrupts are 
   442         *  reenabled.
   443         *
   444         *  A context switch can occur when calling Hwi_enable or Hwi_restore if
   445         *  an enabled interrupt occurred while interrupts are disabled.
   446         *
   447         *  Hwi_disable may be called from main(). However, since Hwi interrupts
   448         *  are already disabled in main(), such a call has no effect.
   449         *
   450         *  @a(constraints)
   451         *  If a Task switching API such as 
   452         *  {@link ti.sysbios.knl.Semaphore#pend Semaphore_pend()}, 
   453         *  {@link ti.sysbios.knl.Semaphore#post Semaphore_post()},
   454         *  {@link ti.sysbios.knl.Task#sleep Task_sleep()}, or
   455         *  {@link ti.sysbios.knl.Task#yield Task_yield()} 
   456         *  is invoked which results in a context switch while
   457         *  interrupts are disabled, an embedded call to 
   458         *  {@link #enable Hwi_enable} occurs
   459         *  on the way to the new thread context which unconditionally re-enables
   460         *  interrupts. Interrupts will remain enabled until a subsequent 
   461         *  {@link #disable Hwi_disable}
   462         *  invocation.
   463         *
   464         *  Swis always run with interrupts enabled.
   465         *  See {@link ti.sysbios.knl.Swi#post Swi_post()} for a discussion Swis and
   466         *  interrupts.
   467         *
   468         *  @b(returns)     opaque key for use by Hwi_restore()
   469         */
   470        UInt disable();
   471    
   472        /*!
   473         *  ======== enable ========
   474         *  Globally enable interrupts.
   475         *
   476         *  Hwi_enable globally enables hardware interrupts and returns an
   477         *  opaque key indicating whether interrupts were globally enabled or
   478         *  disabled on entry to Hwi_enable(). 
   479         *  The actual value of the key is target/device specific and is meant 
   480         *  to be passed to Hwi_restore(). 
   481         *
   482         *
   483         *  This function is 
   484         *  called as part of SYS/BIOS Startup_POST_APP_MAIN phase.
   485         *
   486         *  Hardware interrupts are enabled unless a call to Hwi_disable disables
   487         *  them. 
   488         *
   489         *  Servicing of interrupts that occur while interrupts are disabled is
   490         *  postponed until interrupts are reenabled. However, if the same type 
   491         *  of interrupt occurs several times while interrupts are disabled, 
   492         *  the interrupt's function is executed only once when interrupts are 
   493         *  reenabled.
   494         *
   495         *  A context switch can occur when calling Hwi_enable or Hwi_restore if
   496         *  an enabled interrupt occurred while interrupts are disabled.
   497         *
   498         *  Any call to Hwi_enable enables interrupts, even if Hwi_disable has 
   499         *  been called several times.
   500         *
   501         *  Hwi_enable must not be called from main().
   502         *
   503         *  @b(returns)     opaque key for use by Hwi_restore()
   504         */
   505        UInt enable();
   506    
   507        /*!
   508         *  ======== restore ========
   509         *  Globally restore interrupts.
   510         *
   511         *  Hwi_restore globally restores interrupts to the state determined 
   512         *  by the key argument provided by a previous invocation of Hwi_disable.
   513         *
   514         *  A context switch may occur when calling Hwi_restore if Hwi_restore
   515         *  reenables interrupts and another Hwi occurred while interrupts were 
   516         *  disabled.
   517         *
   518         *  Hwi_restore may be called from main(). However, since Hwi_enable
   519         *  cannot be called from main(), interrupts are always disabled in 
   520         *  main(), and a call to Hwi_restore has no effect.
   521         *
   522         *  @param(key)     enable/disable state to restore
   523         */
   524        Void restore(UInt key);
   525    
   526        /*!
   527         *  @_nodoc
   528         *  ======== switchFromBootStack ========
   529         *  Indicate that we are leaving the boot stack and
   530         *  are about to switch to a task stack.
   531         *  Used by Task_startup()
   532         */
   533        @DirectCall
   534        Void switchFromBootStack();
   535    
   536        /*!
   537         *  @_nodoc
   538         *  ======== post ========
   539         *  Generate an interrupt for test purposes.
   540         *
   541         *  @param(intNum)      ID of interrupt to generate
   542         */
   543        @DirectCall
   544        Void post(UInt intNum);
   545    
   546        /*!
   547         *  @_nodoc
   548         *  ======== getTaskSP ========
   549         *  retrieve interrupted task's SP
   550         *
   551         *  Used for benchmarking the SYS/BIOS Hwi dispatcher's task 
   552         *  stack utilization.
   553         *
   554         *  @b(returns)     interrupted task's SP
   555         */
   556        @DirectCall
   557        Char *getTaskSP();
   558    
   559        /*
   560         *  @_nodoc
   561         *  The following two target-unique Hwi APIs must be called
   562         *  directly in order to work properly. Thus they are not
   563         *  published here in order to bypass the multi-layered indirect function
   564         *  calls (__E, __F) that would arise if they appeared in this spec file.
   565         *
   566         *  These APIs must be implemented by the target Hwi modules and must be
   567         *  given these EXACT names.
   568         *
   569         *  The two functions, switchToIsrStack() and switchToTaskStack() must
   570         *  work in tandem to insure that only the first order (ie non nested) 
   571         *  invocation of these APIs result in the switch to the ISR stack and 
   572         *  the switch back to the task stack. The opaque char * token returned 
   573         *  by switchToIsrStack() and passed to switchToTaskStack() is provided
   574         *  purely for implementation efficiency and thus can have implementation
   575         *  dependent definitions.
   576         */
   577    
   578        /*
   579         *  @_nodoc
   580         *  ======== switchToIsrStack ========
   581         *  If not on ISR stack already, switch to it.
   582         *  Used by the Swi scheduler and interrupt dispatcher.
   583         *
   584         *  This function must be implemented by all Hwi modules
   585         *  name) because it can't be _E and _F'd due to its
   586         *  inherent stack switching behavior.
   587         *  
   588         *  @b(returns)     token to use with 
   589         *                  switchToTaskStack()
   590         */
   591        /*  Char *ti_bios_family_xxx_Hwi_switchToIsrStack(); */
   592    
   593        /*
   594         *  @_nodoc
   595         *  ======== switchToTaskStack ========
   596         *  If at bottom of ISR stack, switch to Task stack.
   597         *  Used by the Swi scheduler and interrupt dispatcher.
   598         *  
   599         *  This function must be implemented by all Hwi modules
   600         *  and be given this exact name (without a target-specific
   601         *  name) because it can't be _E and _F'd due to its
   602         *  inherent stack switching behavior.
   603         *  
   604         *  @param(key)     token returned by
   605         *                  switchToIsrStack()
   606         */
   607        /*  Void ti_bios_family_xxx_Hwi_switchToTaskStack(Char *key); */
   608    
   609        /*!
   610         *  ======== disableInterrupt ========
   611         *  Disable a specific interrupt.
   612         *
   613         *  Disable a specific interrupt identified by an interrupt number.
   614         *
   615         *  @param(intNum)  interrupt number to disable
   616         *  @b(returns)     key to restore previous enable/disable state
   617         */
   618        @DirectCall
   619        UInt disableInterrupt(UInt intNum);
   620    
   621        /*!
   622         *  ======== enableInterrupt ========
   623         *  Enable a specific interrupt.
   624         *
   625         *  Enables a specific interrupt identified by an interrupt number.
   626         *
   627         *  @param(intNum)  interrupt number to enable
   628         *  @b(returns)     key to restore previous enable/disable state
   629         */
   630        @DirectCall
   631        UInt enableInterrupt(UInt intNum);
   632    
   633        /*!
   634         *  ======== restoreInterrupt ========
   635         *  Restore a specific interrupt's enabled/disabled state.
   636         *
   637         *  Restores a specific interrupt identified by an interrupt number.
   638         *  restoreInterrupt is generally used to restore an interrupt to its state
   639         *  before {@link #disableInterrupt} or {@link #enableInterrupt} was
   640         *  invoked
   641         *
   642         *  @param(intNum)  interrupt number to restore
   643         *  @param(key)     key returned from enableInt or disableInt
   644         */
   645        @DirectCall
   646        Void restoreInterrupt(UInt intNum, UInt key);
   647    
   648        /*!
   649         *  ======== clearInterrupt ========
   650         *  Clear a specific interrupt.
   651         *
   652         *  Clears a specific interrupt's pending status.
   653         *  The implementation is family-specific.
   654         *
   655         *  @param(intNum)  interrupt number to clear
   656         */
   657        @DirectCall
   658        Void clearInterrupt(UInt intNum);
   659    
   660    instance:
   661    
   662        /*!
   663         *  Create a dispatched interrupt.
   664         *
   665         *  A Hwi dispatcher table entry is created and filled with the 
   666         *  function specified by the fxn parameter and the attributes 
   667         *  specified by the params parameter.
   668         *
   669         *  If params is NULL, the Hwi's dispatcher properties are assigned a 
   670         *  default set of values. Otherwise, the following properties
   671         *  are specified by a structure of type Hwi_Params.
   672         *
   673         *  @p(blist)
   674         *  - The arg element is a generic argument that is passed to the plugged
   675         *  function as its only parameter. The default value is 0.
   676         *  - The enableInt element determines whether the interrupt should be
   677         *  enabled in the IER by create.
   678         *  - The maskSetting element defines the dispatcherAutoNestingSupport 
   679         *  behavior of the interrupt.
   680         *  @p
   681         *  
   682         *  Hwi_create returns a pointer to the created Hwi object.
   683         *
   684         *  @param(intNum)  interrupt number
   685         *  @param(hwiFxn)  pointer to ISR function
   686         *
   687         */
   688        @DirectCall
   689        create(Int intNum, FuncPtr hwiFxn);
   690    
   691        /*! maskSetting. Default is {@link #MaskingOption Hwi_MaskingOption_SELF} */
   692        config MaskingOption maskSetting = MaskingOption_SELF;
   693    
   694        /*! ISR function argument. Default is 0. */
   695        config UArg arg = 0;
   696    
   697        /*! Enable this interrupt when object is created? Default is true. */
   698        config Bool enableInt = true;
   699        
   700        /*! 
   701         *  Interrupt event ID (Interrupt Selection Number)
   702         *
   703         *  Default is -1. 
   704         *  Not all targets/devices support this instance parameter. 
   705         *  On those that don't, this parameter is ignored.
   706         */
   707        config Int eventId = -1;
   708    
   709        /*! 
   710         *  Interrupt priority.
   711         *
   712         *  Default is -1.
   713         *  Not all targets/devices support this instance parameter. 
   714         *  On those that don't, this parameter is ignored.
   715         */
   716        config Int priority = -1;
   717    
   718        /*!
   719         *  ======== getFunc ========
   720         *  Get Hwi function and arg
   721         *
   722         *  @param(arg)     pointer for returning hwi's ISR function argument
   723         *  @b(returns)     hwi's ISR function
   724         */
   725        @DirectCall
   726        FuncPtr getFunc(UArg *arg);
   727    
   728        /*!
   729         *  ======== setFunc ========
   730         *  Overwrite Hwi function and arg
   731         *
   732         *  Replaces a Hwi object's hwiFxn function originally
   733         *  provided in {@link #create}.
   734         *
   735         *  @param(fxn)     pointer to ISR function
   736         *  @param(arg)     argument to ISR function
   737         */
   738        @DirectCall
   739        Void setFunc(FuncPtr fxn, UArg arg);
   740    
   741        /*!
   742         *  ======== getHookContext ========
   743         *  Get hook instance's context for a Hwi.
   744         *
   745         *  @b(returns)     hook instance's context for hwi
   746         */
   747        @DirectCall
   748        Ptr getHookContext(Int id);
   749    
   750        /*!
   751         *  ======== setHookContext ========
   752         *  Set hook instance's context for a Hwi.
   753         *
   754         *  @param(id)            hook instance's ID
   755         *  @param(hookContext)   value to write to context
   756         */
   757        @DirectCall
   758        Void setHookContext(Int id, Ptr hookContext);
   759    
   760        /*!
   761         *  ======== getIrp ========
   762         *  Get address of interrupted instruction.
   763         *
   764         *  @b(returns)     most current IRP of a Hwi
   765         */
   766        @DirectCall
   767        Irp getIrp();
   768    }
   769    /*
   770     *  @(#) ti.sysbios.interfaces; 2, 0, 0, 0,542; 2-24-2012 11:40:50; /db/vtree/library/trees/avala/avala-q28x/src/ xlibrary
   771    
   772     */
   773