os/kernelhwsrv/kerneltest/e32test/personality/example/isr.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kerneltest/e32test/personality/example/isr.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,118 @@
     1.4 +// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of the License "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// e32test\personality\example\isr.cpp
    1.18 +// Test code for example RTOS personality.
    1.19 +// 
    1.20 +//
    1.21 +
    1.22 +#include "plat_priv.h"
    1.23 +#include <personality/example/personality.h>
    1.24 +
    1.25 +#if defined(__MAWD__)
    1.26 +#include <windermere.h>
    1.27 +#elif defined(__MISA__)
    1.28 +#define __ISR_SUPPORTED__
    1.29 +#include <sa1100.h>
    1.30 +#elif defined(__MCOT__)
    1.31 +#define __ISR_SUPPORTED__
    1.32 +#include <cotulla.h>
    1.33 +#elif defined(__MI920__) || defined(__NI1136__)
    1.34 +#include <integratorap.h>
    1.35 +#elif defined(__EPOC32__) && defined(__CPU_X86)
    1.36 +#include <x86.h>
    1.37 +#endif
    1.38 +
    1.39 +#ifdef __ISR_SUPPORTED__
    1.40 +#include "../../misc/prbs.h"
    1.41 +#endif
    1.42 +
    1.43 +extern "C" void stop_random_isr(void);
    1.44 +
    1.45 +typedef void (*isr_entry)(unsigned);
    1.46 +
    1.47 +volatile TUint RandomSeed[2] = {0xb504f333u, 0xf9de6484u};
    1.48 +volatile isr_entry IsrVector = 0;
    1.49 +volatile TUint IsrCount = 0;
    1.50 +
    1.51 +void timer_isr(void*)
    1.52 +	{
    1.53 +#if defined(__MISA__) 
    1.54 +	TUint interval = Random((TUint*)RandomSeed);
    1.55 +	interval &= 0x3ff;
    1.56 +	interval += 256;	// 256-1279 ticks = approx 69 to 347 microseconds
    1.57 +	TUint oscr=TSa1100::OstData();
    1.58 +	TSa1100::SetOstMatch(KHwOstMatchGeneral, oscr + interval);
    1.59 +	TSa1100::SetOstMatchEOI(KHwOstMatchGeneral);
    1.60 +#elif defined(__MCOT__)
    1.61 +	TUint interval = Random((TUint*)RandomSeed);
    1.62 +	interval &= 0x3ff;
    1.63 +	interval += 256;	// 256-1279 ticks = approx 69 to 347 microseconds
    1.64 +	TUint oscr=TCotulla::OstData();
    1.65 +	TCotulla::SetOstMatch(KHwOstMatchGeneral, oscr + interval);
    1.66 +	TCotulla::SetOstMatchEOI(KHwOstMatchGeneral);
    1.67 +#endif
    1.68 +	(*IsrVector)(IsrCount++);
    1.69 +	}
    1.70 +
    1.71 +#ifdef __ISR_SUPPORTED__
    1.72 +void start_timer(void)
    1.73 +	{
    1.74 +#if defined(__MISA__) 
    1.75 +	// for SA11x0 use OST match 0
    1.76 +	TInt r=Interrupt::Bind(KIntIdOstMatchGeneral, &timer_isr, 0);
    1.77 +	assert(r==KErrNone);
    1.78 +	TSa1100::ModifyIntLevels(0,KHtIntsOstMatchGeneral);	// route new timer interrupt to FIQ
    1.79 +	TSa1100::SetOstMatchEOI(KHwOstMatchGeneral);
    1.80 +	TUint oscr=TSa1100::OstData();
    1.81 +	TSa1100::SetOstMatch(KHwOstMatchGeneral, oscr + 5000);
    1.82 +	TSa1100::EnableOstInterrupt(KHwOstMatchGeneral);
    1.83 +	Interrupt::Enable(KIntIdOstMatchGeneral);
    1.84 +#elif defined(__MCOT__)
    1.85 +	// for SA11x0 use OST match 0
    1.86 +	TInt r=Interrupt::Bind(KIntIdOstMatchGeneral, &timer_isr, 0);
    1.87 +	assert(r==KErrNone);
    1.88 +	TCotulla::ModifyIntLevels(0,KHtIntsOstMatchGeneral);	// route new timer interrupt to FIQ
    1.89 +	TCotulla::SetOstMatchEOI(KHwOstMatchGeneral);
    1.90 +	TUint oscr=TCotulla::OstData();
    1.91 +	TCotulla::SetOstMatch(KHwOstMatchGeneral, oscr + 5000);
    1.92 +	TCotulla::EnableOstInterrupt(KHwOstMatchGeneral);
    1.93 +	Interrupt::Enable(KIntIdOstMatchGeneral);
    1.94 +#endif
    1.95 +	}
    1.96 +#endif
    1.97 +
    1.98 +extern "C" int start_random_isr(isr_entry vector)
    1.99 +	{
   1.100 +	stop_random_isr();
   1.101 +	IsrVector = vector;
   1.102 +#ifdef __ISR_SUPPORTED__
   1.103 +	start_timer();
   1.104 +	return OK;
   1.105 +#else
   1.106 +	return KErrNotSupported;
   1.107 +#endif
   1.108 +	}
   1.109 +
   1.110 +extern "C" void stop_random_isr(void)
   1.111 +	{
   1.112 +#if defined(__MISA__) 
   1.113 +	Interrupt::Disable(KIntIdOstMatchGeneral);
   1.114 +	Interrupt::Unbind(KIntIdOstMatchGeneral);
   1.115 +#elif defined(__MCOT__)
   1.116 +	Interrupt::Disable(KIntIdOstMatchGeneral);
   1.117 +	Interrupt::Unbind(KIntIdOstMatchGeneral);
   1.118 +#endif
   1.119 +	IsrVector = 0;
   1.120 +	}
   1.121 +