|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Syborg interrupt control and dispatch |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <e32cia.h> |
|
19 #include <syborg_priv.h> |
|
20 #include <cpudefs.h> |
|
21 |
|
22 // CIA symbols for ASSP code? |
|
23 #if defined(__GCC32__) |
|
24 // CIA symbol macros for Gcc98r2 |
|
25 #define CSM_ZN7NTimerQ4TickEv " Tick__7NTimerQ" |
|
26 #elif defined(__ARMCC__) |
|
27 // CIA symbol macros for RVCT |
|
28 #define CSM_ZN7NTimerQ4TickEv " __cpp(NTimerQ::Tick)" |
|
29 #else |
|
30 // CIA symbol macros for EABI assemblers |
|
31 #define CSM_ZN7NTimerQ4TickEv " _ZN7NTimerQ4TickEv" |
|
32 #endif |
|
33 |
|
34 /******************************************************************** |
|
35 * Wait for interrupt idle routine which does not disable interrupts |
|
36 ********************************************************************/ |
|
37 |
|
38 __NAKED__ void SyborgWFIIdle() |
|
39 { |
|
40 // Enter an idle state and wait for interrupts |
|
41 asm("mov r0, #0"); |
|
42 asm("mcr p15, 0, r0, c7, c0, 4"); |
|
43 asm("bx lr"); |
|
44 } |
|
45 |
|
46 /******************************************************************** |
|
47 * Service 1ms tick interrupt & timer 1 interrupt |
|
48 ********************************************************************/ |
|
49 |
|
50 __NAKED__ void SyborgInterrupt::MsTimerTick(TAny* /*aPtr*/) |
|
51 { |
|
52 // Service 1ms tick interrupt |
|
53 asm("ldr r1, __KHwCounterTimer"); |
|
54 asm("push {r0}"); |
|
55 asm("mov r0, #1"); |
|
56 asm("str r0, [r1, #24]"); |
|
57 asm("pop {r0}"); |
|
58 asm("b "CSM_ZN7NTimerQ4TickEv); |
|
59 asm("bx lr"); |
|
60 |
|
61 asm("__KHwCounterTimer:"); |
|
62 asm(".word %a0" : : "i" ((TInt)KHwBaseCounterTimer)); |
|
63 } |
|
64 |
|
65 /******************************************************************** |
|
66 * Interrupt handling/dispatch |
|
67 ********************************************************************/ |
|
68 // IRQ dispatcher |
|
69 // Enter with r0-r3, r12 and return address on IRQ stack |
|
70 // Must preserve r4-r11 |
|
71 // Uses r4,r5,r12 |
|
72 __NAKED__ void SyborgInterrupt::IrqDispatch() |
|
73 { |
|
74 asm("push {r4,r5,lr} "); |
|
75 asm("ldr r4, __KHwBaseSic"); |
|
76 asm("ldr r12, __SicHandlerStart"); |
|
77 asm("ldr r5, [r4, #8]"); // r5 - pending interrupt |
|
78 asm("adr lr, Clear"); |
|
79 asm("add r12, r5, lsl #3"); |
|
80 asm("ldm r12, {r0, pc}"); |
|
81 |
|
82 asm("Clear:"); |
|
83 // asm("str r5, [r4, #16]"); // TODO: error |
|
84 asm("pop {r4,r5,pc}"); |
|
85 |
|
86 asm("__KHwBaseSic:"); |
|
87 asm(".word %a0" : : "i" ((TInt)KHwBaseSic)); |
|
88 asm("__SicHandlerStart:"); |
|
89 asm(".word %a0" : : "i" ((TInt)&Handlers[0])); |
|
90 } |
|
91 |
|
92 __NAKED__ void SyborgInterrupt::FiqDispatch() |
|
93 { |
|
94 // FIQ dispatcher |
|
95 // Enter with return address on FIQ stack |
|
96 // We may use r8-r12, but must preserve other registers |
|
97 // NOTE: STACK IS MISALIGNED ON ENTRY (1 WORD PUSHED) |
|
98 asm("push {r0-r3,lr}"); |
|
99 // FIQ Handler to go in here. |
|
100 // Not needed because no FIQs are currently used |
|
101 asm("pop {r0-r3,pc}"); |
|
102 } |