|
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: |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef __SYBORG_H__ |
|
19 #define __SYBORG_H__ |
|
20 |
|
21 #include <e32const.h> |
|
22 #include <platform.h> |
|
23 #include <e32hal.h> |
|
24 #include <assp.h> |
|
25 #include <kern_priv.h> |
|
26 #include <mmboot.h> // KPrimaryIOBase |
|
27 |
|
28 #ifndef __SYBORG__ |
|
29 #define __SYBORG__ |
|
30 #endif |
|
31 |
|
32 const TUint KHwBasePeripherals = KPrimaryIOBase; |
|
33 const TUint KHwLinSeparation = 0x1000; |
|
34 |
|
35 const TUint KHwBaseSic = KHwBasePeripherals + 0x00*KHwLinSeparation; |
|
36 // intended for use as a free-running counter. Reading the value register of a free-running syborg counter returns a microsec value |
|
37 const TUint KHwBaseRtc = KHwBasePeripherals + 0x01*KHwLinSeparation; |
|
38 // intended for use as an alarm generating timer with a resolution of 1 microsecond |
|
39 const TUint KHwBaseCounterTimer = KHwBasePeripherals + 0x02*KHwLinSeparation; |
|
40 const TUint KHwBaseKmiKeyboard = KHwBasePeripherals + 0x03*KHwLinSeparation; |
|
41 const TUint KHwBaseKmiMouse = KHwBasePeripherals + 0x04*KHwLinSeparation; |
|
42 const TUint KHwBaseKmiPointer = KHwBasePeripherals + 0x04*KHwLinSeparation; |
|
43 const TUint KHwBaseClcd = KHwBasePeripherals + 0x05*KHwLinSeparation; |
|
44 const TUint KHwBaseUart0 = KHwBasePeripherals + 0x06*KHwLinSeparation; |
|
45 const TUint KHwBaseUart1 = KHwBasePeripherals + 0x07*KHwLinSeparation; |
|
46 const TUint KHwBaseUart2 = KHwBasePeripherals + 0x08*KHwLinSeparation; |
|
47 const TUint KHwBaseUart3 = KHwBasePeripherals + 0x09*KHwLinSeparation; |
|
48 const TUint KHwSVPHostFileSystemDevice = KHwBasePeripherals + 0x0a*KHwLinSeparation; |
|
49 const TUint KHwSVPSnapDevice = KHwBasePeripherals + 0x0b*KHwLinSeparation; |
|
50 const TUint KHwSVPNetDevice = KHwBasePeripherals + 0x0c*KHwLinSeparation; |
|
51 const TUint KHwSVPNandDevice = KHwBasePeripherals + 0x0d*KHwLinSeparation; |
|
52 const TUint KHwSVPAudioDevice = KHwBasePeripherals + 0x0e*KHwLinSeparation; |
|
53 const TUint KHwSVPPlatformDevice = KHwBasePeripherals + 0x0f*KHwLinSeparation; |
|
54 |
|
55 |
|
56 enum TSyborgInterruptId |
|
57 { |
|
58 EIntTimer0 = 0, /* RTC -- not used */ |
|
59 EIntTimer1 = 1, /* Interval Timer */ |
|
60 EIntKeyboard = 2, |
|
61 EIntPointer = 3, |
|
62 // EIntMouse = 3, |
|
63 EIntFb = 4, |
|
64 EIntSerial0 = 5, |
|
65 EIntSerial1 = 6, |
|
66 EIntSerial2 = 7, |
|
67 EIntSerial3 = 8 |
|
68 }; |
|
69 |
|
70 // Timer Mode |
|
71 const TUint KPeriodic = 0x0; |
|
72 const TUint KOneShot = 0x1; |
|
73 |
|
74 class TSyborg |
|
75 { |
|
76 public: |
|
77 // generic enums |
|
78 enum TState |
|
79 { |
|
80 EEnable, |
|
81 EDisable |
|
82 }; |
|
83 enum TLock |
|
84 { |
|
85 ELocked=0, |
|
86 EUnlocked=0xA05F |
|
87 }; |
|
88 enum TTimerMode |
|
89 { |
|
90 ETimerModePeriodic=KPeriodic, |
|
91 ETimerModeOneShot=KOneShot, |
|
92 }; |
|
93 public: |
|
94 // Initialisation of class |
|
95 static void Init3(); |
|
96 |
|
97 // Accessor methods for timers |
|
98 IMPORT_C static void EnableTimerInterrupt(TUint aTimerBase); // Enable the timer interrupt |
|
99 IMPORT_C static void DisableTimerInterrupt(TUint aTimerBase); // Disable the timer interrupt |
|
100 IMPORT_C static void SetTimerLoad(TUint aTimerBase, TUint32 aValue); // Set the starting count value for a timer |
|
101 IMPORT_C static TUint TimerLoad(TUint aTimerBase); // Read the load register (starting count value) |
|
102 IMPORT_C static TUint TimerValue(TUint aTimerBase); // Read the actual timer value |
|
103 IMPORT_C static void ClearTimerInt(TUint aTimerBase); // Clear the timer interrupt |
|
104 IMPORT_C static TBool IsTimerEnabled(TUint aTimerBase); // Enquire as to whether the timer is enabled |
|
105 IMPORT_C static void EnableTimer(TUint aTimerBase, TState aState); // Enable/disable the timer (start/stop it running) |
|
106 IMPORT_C static TTimerMode TimerMode(TUint aTimerBase); // Find out what mode the timer is running in |
|
107 IMPORT_C static void SetTimerMode(TUint aTimerBase, TTimerMode aValue); // Set the timer mode (periodic or free running) |
|
108 |
|
109 // Accessor methods for interrupts |
|
110 IMPORT_C static void EnableInt(TUint anId); |
|
111 IMPORT_C static void DisableInt(TUint anId); |
|
112 |
|
113 IMPORT_C static TInt VideoRamSize(); |
|
114 IMPORT_C static TPhysAddr VideoRamPhys(); |
|
115 IMPORT_C static TPhysAddr VideoRamPhysSecure(); |
|
116 |
|
117 // Debug Port Specific |
|
118 IMPORT_C static TUint32 DebugPortAddr(); |
|
119 IMPORT_C static void MarkDebugPortOff(); |
|
120 }; |
|
121 |
|
122 static inline TUint32 ReadReg(TUint32 base, TUint8 aReg) |
|
123 { |
|
124 return *(volatile TUint32 *)(base + (aReg << 2)); |
|
125 } |
|
126 |
|
127 static inline void WriteReg(TUint32 base, TUint8 aReg, TUint32 aVal) |
|
128 { |
|
129 *(volatile TUint32*)(base + (aReg<<2)) = aVal; |
|
130 } |
|
131 |
|
132 #endif // __SYBORG_H__ |