sl@0
|
1 |
// Copyright (c) 2003-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\personality\example\isr.cpp
|
sl@0
|
15 |
// Test code for example RTOS personality.
|
sl@0
|
16 |
//
|
sl@0
|
17 |
//
|
sl@0
|
18 |
|
sl@0
|
19 |
#include "plat_priv.h"
|
sl@0
|
20 |
#include <personality/example/personality.h>
|
sl@0
|
21 |
|
sl@0
|
22 |
#if defined(__MAWD__)
|
sl@0
|
23 |
#include <windermere.h>
|
sl@0
|
24 |
#elif defined(__MISA__)
|
sl@0
|
25 |
#define __ISR_SUPPORTED__
|
sl@0
|
26 |
#include <sa1100.h>
|
sl@0
|
27 |
#elif defined(__MCOT__)
|
sl@0
|
28 |
#define __ISR_SUPPORTED__
|
sl@0
|
29 |
#include <cotulla.h>
|
sl@0
|
30 |
#elif defined(__MI920__) || defined(__NI1136__)
|
sl@0
|
31 |
#include <integratorap.h>
|
sl@0
|
32 |
#elif defined(__EPOC32__) && defined(__CPU_X86)
|
sl@0
|
33 |
#include <x86.h>
|
sl@0
|
34 |
#endif
|
sl@0
|
35 |
|
sl@0
|
36 |
#ifdef __ISR_SUPPORTED__
|
sl@0
|
37 |
#include "../../misc/prbs.h"
|
sl@0
|
38 |
#endif
|
sl@0
|
39 |
|
sl@0
|
40 |
extern "C" void stop_random_isr(void);
|
sl@0
|
41 |
|
sl@0
|
42 |
typedef void (*isr_entry)(unsigned);
|
sl@0
|
43 |
|
sl@0
|
44 |
volatile TUint RandomSeed[2] = {0xb504f333u, 0xf9de6484u};
|
sl@0
|
45 |
volatile isr_entry IsrVector = 0;
|
sl@0
|
46 |
volatile TUint IsrCount = 0;
|
sl@0
|
47 |
|
sl@0
|
48 |
void timer_isr(void*)
|
sl@0
|
49 |
{
|
sl@0
|
50 |
#if defined(__MISA__)
|
sl@0
|
51 |
TUint interval = Random((TUint*)RandomSeed);
|
sl@0
|
52 |
interval &= 0x3ff;
|
sl@0
|
53 |
interval += 256; // 256-1279 ticks = approx 69 to 347 microseconds
|
sl@0
|
54 |
TUint oscr=TSa1100::OstData();
|
sl@0
|
55 |
TSa1100::SetOstMatch(KHwOstMatchGeneral, oscr + interval);
|
sl@0
|
56 |
TSa1100::SetOstMatchEOI(KHwOstMatchGeneral);
|
sl@0
|
57 |
#elif defined(__MCOT__)
|
sl@0
|
58 |
TUint interval = Random((TUint*)RandomSeed);
|
sl@0
|
59 |
interval &= 0x3ff;
|
sl@0
|
60 |
interval += 256; // 256-1279 ticks = approx 69 to 347 microseconds
|
sl@0
|
61 |
TUint oscr=TCotulla::OstData();
|
sl@0
|
62 |
TCotulla::SetOstMatch(KHwOstMatchGeneral, oscr + interval);
|
sl@0
|
63 |
TCotulla::SetOstMatchEOI(KHwOstMatchGeneral);
|
sl@0
|
64 |
#endif
|
sl@0
|
65 |
(*IsrVector)(IsrCount++);
|
sl@0
|
66 |
}
|
sl@0
|
67 |
|
sl@0
|
68 |
#ifdef __ISR_SUPPORTED__
|
sl@0
|
69 |
void start_timer(void)
|
sl@0
|
70 |
{
|
sl@0
|
71 |
#if defined(__MISA__)
|
sl@0
|
72 |
// for SA11x0 use OST match 0
|
sl@0
|
73 |
TInt r=Interrupt::Bind(KIntIdOstMatchGeneral, &timer_isr, 0);
|
sl@0
|
74 |
assert(r==KErrNone);
|
sl@0
|
75 |
TSa1100::ModifyIntLevels(0,KHtIntsOstMatchGeneral); // route new timer interrupt to FIQ
|
sl@0
|
76 |
TSa1100::SetOstMatchEOI(KHwOstMatchGeneral);
|
sl@0
|
77 |
TUint oscr=TSa1100::OstData();
|
sl@0
|
78 |
TSa1100::SetOstMatch(KHwOstMatchGeneral, oscr + 5000);
|
sl@0
|
79 |
TSa1100::EnableOstInterrupt(KHwOstMatchGeneral);
|
sl@0
|
80 |
Interrupt::Enable(KIntIdOstMatchGeneral);
|
sl@0
|
81 |
#elif defined(__MCOT__)
|
sl@0
|
82 |
// for SA11x0 use OST match 0
|
sl@0
|
83 |
TInt r=Interrupt::Bind(KIntIdOstMatchGeneral, &timer_isr, 0);
|
sl@0
|
84 |
assert(r==KErrNone);
|
sl@0
|
85 |
TCotulla::ModifyIntLevels(0,KHtIntsOstMatchGeneral); // route new timer interrupt to FIQ
|
sl@0
|
86 |
TCotulla::SetOstMatchEOI(KHwOstMatchGeneral);
|
sl@0
|
87 |
TUint oscr=TCotulla::OstData();
|
sl@0
|
88 |
TCotulla::SetOstMatch(KHwOstMatchGeneral, oscr + 5000);
|
sl@0
|
89 |
TCotulla::EnableOstInterrupt(KHwOstMatchGeneral);
|
sl@0
|
90 |
Interrupt::Enable(KIntIdOstMatchGeneral);
|
sl@0
|
91 |
#endif
|
sl@0
|
92 |
}
|
sl@0
|
93 |
#endif
|
sl@0
|
94 |
|
sl@0
|
95 |
extern "C" int start_random_isr(isr_entry vector)
|
sl@0
|
96 |
{
|
sl@0
|
97 |
stop_random_isr();
|
sl@0
|
98 |
IsrVector = vector;
|
sl@0
|
99 |
#ifdef __ISR_SUPPORTED__
|
sl@0
|
100 |
start_timer();
|
sl@0
|
101 |
return OK;
|
sl@0
|
102 |
#else
|
sl@0
|
103 |
return KErrNotSupported;
|
sl@0
|
104 |
#endif
|
sl@0
|
105 |
}
|
sl@0
|
106 |
|
sl@0
|
107 |
extern "C" void stop_random_isr(void)
|
sl@0
|
108 |
{
|
sl@0
|
109 |
#if defined(__MISA__)
|
sl@0
|
110 |
Interrupt::Disable(KIntIdOstMatchGeneral);
|
sl@0
|
111 |
Interrupt::Unbind(KIntIdOstMatchGeneral);
|
sl@0
|
112 |
#elif defined(__MCOT__)
|
sl@0
|
113 |
Interrupt::Disable(KIntIdOstMatchGeneral);
|
sl@0
|
114 |
Interrupt::Unbind(KIntIdOstMatchGeneral);
|
sl@0
|
115 |
#endif
|
sl@0
|
116 |
IsrVector = 0;
|
sl@0
|
117 |
}
|
sl@0
|
118 |
|