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