sl@0: // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // \e32test\nkernsa\interrupts.h sl@0: // sl@0: // sl@0: sl@0: /** sl@0: @file sl@0: @internalTechnology sl@0: */ sl@0: sl@0: #ifndef __INTERRUPTS_H__ sl@0: #define __INTERRUPTS_H__ sl@0: #include sl@0: sl@0: #undef IMPORT_C sl@0: #define IMPORT_C /* */ sl@0: sl@0: /************************************************* sl@0: * Interrupt handling sl@0: *************************************************/ sl@0: typedef void (*TIsr)(TAny*); sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: A class that exports interrupt functionality to device drivers and sl@0: other kernel-side code. sl@0: sl@0: Although Symbian OS defines this class, it does not implement it; sl@0: an implementation for each of the functions defined by this class must sl@0: be provided by the Variant in the baseport. sl@0: sl@0: Note that the class only provides the public API for using interrupts, sl@0: not for dispatching them. sl@0: */ sl@0: class Interrupt sl@0: { sl@0: public: sl@0: sl@0: sl@0: /** sl@0: Associates the specified interrupt service routine (ISR) function with sl@0: the specified interrupt Id. sl@0: sl@0: This is also known as binding the interrupt. sl@0: sl@0: When the ISR is called, the value aPtr is passed as the argument. sl@0: ISR may either be a bare function or a static class member, taking TAny* parameter: sl@0: @code sl@0: void Isr(TAny* aParam) sl@0: @endcode sl@0: sl@0: Note that you must call Interrupt::Enable() before you can start sl@0: receiving interrupts. sl@0: sl@0: @param anId The interrupt Id. sl@0: @param anIsr The address of the ISR function. sl@0: @param aPtr 32-bit value that is passed to the ISR. sl@0: This is designated a TAny* type as it is usually a pointer to sl@0: the owning class or data to be used in the ISR, although sl@0: it can be any 32-bit value. sl@0: sl@0: @return KErrNone, if successful; KErrArgument, if anId is invalid; sl@0: KErrInUse, if the ISR is already bound to this interrupt. sl@0: */ sl@0: IMPORT_C static TInt Bind(TInt anId, TIsr anIsr, TAny* aPtr); sl@0: sl@0: sl@0: /** sl@0: Unbinds the interrupt service routine (ISR) function from sl@0: the specified interrupt id. sl@0: sl@0: @param anId The interrupt Id. sl@0: sl@0: @return KErrNone, if successful; KErrArgument, if anId is invalid; sl@0: KErrGeneral, if there is no ISR bound to this interrupt. sl@0: */ sl@0: IMPORT_C static TInt Unbind(TInt anId); sl@0: sl@0: sl@0: /** sl@0: Enables the specified interrupt. sl@0: sl@0: After enabling the interrupt, the ISR will run if the interrupt signals. sl@0: sl@0: @param anId The interrupt Id. sl@0: sl@0: @return KErrNone, if successful; KErrArgument, if anId is invalid; sl@0: KErrGeneral, if there is no ISR bound to this interrupt. sl@0: */ sl@0: IMPORT_C static TInt Enable(TInt anId); sl@0: sl@0: sl@0: /** sl@0: Disables the specified interrupt. sl@0: sl@0: After calling this function, the interrupt source cannot generate sl@0: an interrupt to the CPU. sl@0: sl@0: @param anId The interrupt Id. sl@0: sl@0: @return KErrNone, if successful; KErrArgument, if anId is invalid; sl@0: KErrGeneral, if there is no ISR bound to this interrupt. sl@0: */ sl@0: IMPORT_C static TInt Disable(TInt anId); sl@0: sl@0: sl@0: /** sl@0: Clears any pending signal on the specified interrupt. sl@0: sl@0: @param anId The interrupt Id. sl@0: sl@0: @return KErrNone, if successful; KErrArgument, if anId is invalid; sl@0: KErrGeneral, if there is no ISR bound to this interrupt. sl@0: */ sl@0: IMPORT_C static TInt Clear(TInt anId); sl@0: sl@0: sl@0: /** sl@0: Changes the priority of the specified interrupt to the new specified value. sl@0: sl@0: The meaning of the priority value is determined by the baseport. sl@0: The function returns KErrNotSupported if the hardware or the baseport sl@0: does not support configurable interrupt priorities. sl@0: sl@0: @param anId The interrupt Id. sl@0: @param aPriority The new priority value. sl@0: sl@0: @return KErrNone, if successful; KErrArgument, if anId is invalid; sl@0: KErrNotSuppported, if configurable interrupt priorities sl@0: are not supported. sl@0: */ sl@0: IMPORT_C static TInt SetPriority(TInt anId, TInt aPriority); sl@0: }; sl@0: sl@0: struct SInterruptHandler sl@0: { sl@0: TAny* iPtr; sl@0: TIsr iIsr; sl@0: }; sl@0: sl@0: #endif