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