1 // Copyright (c) 1997-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 "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // template\template_assp\template_assp.h
15 // Definitions for Template ASSP
21 #ifndef __A32TEMPLATEV1_H__
22 #define __A32TEMPLATEV1_H__
27 #include <kern_priv.h>
29 //----------------------------------------------------------------------------
30 // Constant conventions:
31 //----------------------------------------------------------------------------
33 // KH Hardware definition
34 // KHw 4-byte word definition prefix
35 // KHb Byte definition prefix
36 // KHt Bit definition prefix
37 // KHm Mask definition prefix
38 // KHs Shift definition prefix
39 // KHo Offset definition prefix
40 // KHwRo Read-only register
41 // KHwWo Write-only register
42 // KHwRw Read/write register
43 // KHwBase Base address within memory map
46 // _b Input/output suffix
48 //----------------------------------------------------------------------------
49 // Memory map: physical addresses
50 //----------------------------------------------------------------------------
51 // NB: these are just examples
53 const TUint KHwBaseCs0 = 0x00000000;
54 const TUint KHwBaseCs1 = KHwBaseCs0 + 128*KMega;
55 const TUint KHwBaseCs2 = KHwBaseCs1 + 128*KMega;
56 const TUint KHwBaseCs3 = KHwBaseCs2 + 128*KMega;
58 const TUint KHwBaseMemBank0 = 0x20000000;
59 const TUint KHwBaseMemBank1 = KHwBaseMemBank0 + 256*KMega;
61 const TUint KHwBaseRegisters = 0x80000000;
62 const TUint KHwBasePeripherals = KHwBaseRegisters; // 8000.0000
63 const TUint KHwBasePeripheralsA = KHwBasePeripherals + 256*KMega; // 9000.0000
64 const TUint KHwBasePeripheralsB = KHwBasePeripheralsA + 256*KMega; // A000.0000
65 const TUint KHwBasePeripheralsC = KHwBasePeripheralsB + 256*KMega; // B000.0000
69 //----------------------------------------------------------------------------
70 // Memory map: linear addresses
71 //----------------------------------------------------------------------------
73 #if defined (__MEMMODEL_MULTIPLE__)
74 const TUint KHwLinBaseRegisters = 0xc6000000; // as mapped by bootstrap
75 const TUint KHwLinSeparation = 0x1000;
76 #elif defined(__MEMMODEL_DIRECT__)
77 const TUint KHwLinBaseRegisters = 0x10000000; // physical address (example only)
78 const TUint KHwLinSeparation = 0x01000000; // physical offsets (example only)
80 const TUint KHwLinBaseRegisters = 0x63000000; // as mapped by bootstrap
81 const TUint KHwLinSeparation = 0x1000;
85 const TUint KHwLinBasePeriphGroupA = KHwLinBaseRegisters;
86 const TUint KHwLinBasePeripheral1 = KHwLinBasePeriphGroupA + 0x00*KHwLinSeparation;
87 const TUint KHwLinBasePeripheral2 = KHwLinBasePeriphGroupA + 0x01*KHwLinSeparation;
88 const TUint KHwLinBasePeripheral3 = KHwLinBasePeriphGroupA + 0x02*KHwLinSeparation;
89 const TUint KHwLinBasePeripheral4 = KHwLinBasePeriphGroupA + 0x03*KHwLinSeparation;
91 const TUint KHwLinBasePeriphGroupB = KHwLinBaseRegisters + 0x20*KHwLinSeparation;
93 const TUint KHwBaseSerial1 = KHwLinBasePeriphGroupB + 0x00*KHwLinSeparation;
94 const TUint KHwBaseSerial2 = KHwLinBasePeriphGroupB + 0x01*KHwLinSeparation;
95 const TUint KHwBaseSerial3 = KHwLinBasePeriphGroupB + 0x02*KHwLinSeparation;
97 const TUint KHwLinBasePeriphGroupC = KHwLinBaseRegisters + 0x30*KHwLinSeparation;
99 const TUint KHwBaseInterrupts = KHwLinBasePeriphGroupC + 0x00*KHwLinSeparation;
100 const TUint KHwInterruptsMaskRo = KHwBaseInterrupts + 0x00;
101 const TUint KHwInterruptsMaskSet = KHwBaseInterrupts + 0x04;
102 const TUint KHwInterruptsMaskClear = KHwBaseInterrupts + 0x08;
103 const TUint KHoInterruptsIrqPending = 0x0C;
104 const TUint KHwInterruptsIrqPending = KHwBaseInterrupts + KHoInterruptsIrqPending;
105 const TUint KHoInterruptsFiqPending = 0x10;
106 const TUint KHwInterruptsFiqending = KHwBaseInterrupts + KHoInterruptsFiqPending;
109 // Other device specifc constants, register offsets, bit masks, general-purpose I/O allocations,
110 // interrupt sources, Memory settings and geometries, etc
116 * Accessor functions to hardware resources managed by ASSP (ASIC). Auxiliary and information functions which
117 * are commonly used by Device Drivers or ASSP/Variant code.
118 * Some examples below. These examples assume that the hardware blocks they access (e.g. Interrupt controller
119 * RTC, Clock Control Module, UART, etc) are part of the ASSP.
127 * Active waiting loop (not to be used after System Tick timer has been set up - Init3()
128 * @param aDuration A wait time in milliseconds
130 IMPORT_C static void BootWaitMilliSeconds(TInt aDuration);
132 * Read and return the Startup reason of the Hardware
133 * @return A TMachineStartupType enumerated value
135 IMPORT_C static TMachineStartupType StartupReason();
137 * Read and return the the CPU ID
138 * @return An integer containing the CPU ID string read off the hardware
140 IMPORT_C static TInt CpuVersionId();
142 * Read Linear base address of debug UART (as selected in obey file or with eshell debugport command).
143 * @return An integer containing the Linear address of debug Serial Port
145 IMPORT_C static TUint DebugPortAddr();
147 * Read CPU clock period in picoseconds
148 * @return An integer containing the CPU clock period in picoseconds
150 IMPORT_C static TUint ProcessorPeriodInPs();
152 * Set the Hardware Interrupt masks
153 * @param aValue A new interrupt mask value
155 IMPORT_C static void SetIntMask(TUint aValue);
157 * Modify the Hardware Interrupt masks
158 * @param aClearMask A mask with interrupt source bits to clear (disable)
159 * @param aSetMask A mask with interrupt source bits to set (enable)
161 IMPORT_C static void ModifyIntMask(TUint aClearMask,TUint aSetMask);
163 * Read the state of pending interrupts
164 * @return A mask containing bits set for all pending interrupts
166 IMPORT_C static TUint IntsPending();
168 * Read the current time of the RTC
169 * @return A value that is the real time as given by a RTC
171 IMPORT_C static TUint RtcData();
174 * @param aValue The real time to set the RTC
176 IMPORT_C static void SetRtcData(TUint aValue);
178 * Obtain the physical start address of Video Buffer
179 * @return the physical start address of Video Buffer
181 IMPORT_C static TPhysAddr VideoRamPhys();
184 * Auxiliary accessor functions for Hardware registers (used by functions above)
186 static inline TUint Register32(TUint aAddr);
187 static inline void SetRegister32(TUint aValue, TUint aAddr);
188 static void ModifyRegister32(TUint aClearMask, TUint aSetMask, TUint aAddr);
190 * Assp-specific implementation for Kern::NanoWait function
192 static void NanoWait(TUint32 aInterval);
197 // Enumerate here all ASSP interrupt souces. It could be a good idea to enumerate them in a way that facilitates
198 // operating on the corresponding interrupt controller registers (e.g using their value as a shift count)
201 enum TTemplateAsspInterruptId
203 // ASSP or first-level Interrupt IDs
219 // Define here some commonly used ASSP interrupts
222 const TInt KIntIdExpansion=EAsspIntIdA; // this is the ASSP interrupt which connects to second-level (Variant)
223 // Interrupt controller: all 2nd level interrupts come through this interrupt
224 const TInt KIntIdOstMatchMsTimer=EAsspIntIdB;
225 const TInt KIntIdDigitiser=EAsspIntIdC;
226 const TInt KIntIdSound=EAsspIntIdD;
227 const TInt KIntIdTimer1=EAsspIntIdE;