kerneltest/e32test/nkernsa/interrupts.h
changeset 0 a41df078684a
equal deleted inserted replaced
-1:000000000000 0:a41df078684a
       
     1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of the License "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // \e32test\nkernsa\interrupts.h
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file
       
    20  @internalTechnology
       
    21 */
       
    22 
       
    23 #ifndef __INTERRUPTS_H__
       
    24 #define __INTERRUPTS_H__
       
    25 #include <e32err.h>
       
    26 
       
    27 #undef IMPORT_C
       
    28 #define IMPORT_C /* */
       
    29 
       
    30 /*************************************************
       
    31  * Interrupt handling
       
    32  *************************************************/
       
    33 typedef void (*TIsr)(TAny*);
       
    34 
       
    35 
       
    36 
       
    37 
       
    38 /**
       
    39 A class that exports interrupt functionality to device drivers and
       
    40 other kernel-side code.
       
    41 
       
    42 Although Symbian OS defines this class, it does not implement it;
       
    43 an implementation for each of the functions defined by this class must
       
    44 be provided by the Variant in the baseport.
       
    45 
       
    46 Note that the class only provides the public API for using interrupts,
       
    47 not for dispatching them.
       
    48 */
       
    49 class Interrupt
       
    50 	{
       
    51 public:
       
    52 
       
    53 
       
    54     /**
       
    55     Associates the specified interrupt service routine (ISR) function with
       
    56     the specified interrupt Id.
       
    57     
       
    58     This is also known as binding the interrupt.
       
    59         
       
    60     When the ISR is called, the value aPtr is passed as the argument.
       
    61     ISR may either be a bare function or a static class member, taking TAny* parameter:
       
    62     @code
       
    63     void Isr(TAny* aParam)
       
    64     @endcode
       
    65 
       
    66     Note that you must call Interrupt::Enable() before you can start
       
    67     receiving interrupts.
       
    68      
       
    69     @param anId  The interrupt Id.
       
    70     @param anIsr The address of the ISR function. 
       
    71     @param aPtr  32-bit value that is passed to the ISR.
       
    72                  This is designated a TAny* type as it is usually a pointer to
       
    73                  the owning class or data to be used in the ISR, although
       
    74                  it can be any 32-bit value.
       
    75                  
       
    76     @return 	 KErrNone, if successful; KErrArgument, if anId is invalid;
       
    77                  KErrInUse, if the ISR is already bound to this interrupt.
       
    78     */
       
    79 	IMPORT_C static TInt Bind(TInt anId, TIsr anIsr, TAny* aPtr);
       
    80 
       
    81 
       
    82     /**
       
    83     Unbinds the interrupt service routine (ISR) function from
       
    84     the specified interrupt id.
       
    85     
       
    86     @param anId The interrupt Id.
       
    87     
       
    88     @return 	KErrNone, if successful; KErrArgument, if anId is invalid;
       
    89                 KErrGeneral, if there is no ISR bound to this interrupt.
       
    90     */
       
    91 	IMPORT_C static TInt Unbind(TInt anId);
       
    92 
       
    93 
       
    94     /**
       
    95     Enables the specified interrupt.
       
    96     
       
    97     After enabling the interrupt, the ISR will run if the interrupt signals.
       
    98     
       
    99     @param anId The interrupt Id.
       
   100     
       
   101     @return 	KErrNone, if successful; KErrArgument, if anId is invalid;
       
   102                 KErrGeneral, if there is no ISR bound to this interrupt.
       
   103     */
       
   104 	IMPORT_C static TInt Enable(TInt anId);
       
   105 
       
   106 
       
   107     /**
       
   108     Disables the specified interrupt.
       
   109     
       
   110     After calling this function, the interrupt source cannot generate
       
   111     an interrupt to the CPU.
       
   112     
       
   113     @param anId The interrupt Id.
       
   114     
       
   115     @return 	KErrNone, if successful; KErrArgument, if anId is invalid;
       
   116                 KErrGeneral, if there is no ISR bound to this interrupt.
       
   117     */
       
   118 	IMPORT_C static TInt Disable(TInt anId);
       
   119 
       
   120 
       
   121     /**
       
   122     Clears any pending signal on the specified interrupt.
       
   123     
       
   124     @param anId The interrupt Id.
       
   125     
       
   126     @return 	KErrNone, if successful; KErrArgument, if anId is invalid;
       
   127                 KErrGeneral, if there is no ISR bound to this interrupt.
       
   128     */
       
   129 	IMPORT_C static TInt Clear(TInt anId);
       
   130 
       
   131 
       
   132     /**
       
   133     Changes the priority of the specified interrupt to the new specified value.
       
   134     
       
   135     The meaning of the priority value is determined by the baseport.
       
   136     The function returns KErrNotSupported if the hardware or the baseport
       
   137     does not support configurable interrupt priorities.
       
   138 
       
   139     @param anId      The interrupt Id.
       
   140     @param aPriority The new priority value.
       
   141     
       
   142     @return 	KErrNone, if successful; KErrArgument, if anId is invalid;
       
   143                 KErrNotSuppported, if configurable interrupt priorities
       
   144                 are not supported.
       
   145     */
       
   146 	IMPORT_C static TInt SetPriority(TInt anId, TInt aPriority);
       
   147 	};
       
   148 
       
   149 struct SInterruptHandler
       
   150 	{
       
   151 	TAny* iPtr;
       
   152 	TIsr iIsr;
       
   153 	};
       
   154 
       
   155 #endif