epoc32/include/assp/template_assp/template_assp.h
branchSymbian2
changeset 2 2fe1408b6811
equal deleted inserted replaced
1:666f914201fb 2:2fe1408b6811
       
     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".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // template\template_assp\template_assp.h
       
    15 // Definitions for Template ASSP
       
    16 // 
       
    17 //
       
    18 
       
    19 
       
    20 
       
    21 #ifndef __A32TEMPLATEV1_H__
       
    22 #define __A32TEMPLATEV1_H__
       
    23 #include <e32const.h>
       
    24 #include <platform.h>
       
    25 #include <e32hal.h>
       
    26 #include <assp.h>
       
    27 #include <kern_priv.h>
       
    28 
       
    29 //----------------------------------------------------------------------------
       
    30 // Constant conventions:
       
    31 //----------------------------------------------------------------------------
       
    32 
       
    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
       
    44 // _i		Input suffix
       
    45 // _o		Output suffix
       
    46 // _b		Input/output suffix
       
    47 
       
    48 //----------------------------------------------------------------------------
       
    49 // Memory map: physical addresses
       
    50 //----------------------------------------------------------------------------
       
    51 // NB: these are just examples
       
    52 
       
    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;
       
    57 
       
    58 const TUint KHwBaseMemBank0		=	0x20000000;
       
    59 const TUint KHwBaseMemBank1		=	KHwBaseMemBank0 + 256*KMega;
       
    60 
       
    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
       
    66 
       
    67 // etc...
       
    68 
       
    69 //----------------------------------------------------------------------------
       
    70 // Memory map: linear addresses
       
    71 //----------------------------------------------------------------------------
       
    72 
       
    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)
       
    79 #else
       
    80 const TUint KHwLinBaseRegisters = 0x63000000;			// as mapped by bootstrap
       
    81 const TUint KHwLinSeparation	= 0x1000;
       
    82 #endif
       
    83 
       
    84 // EXAMPLE ONLY:
       
    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;
       
    90 
       
    91 const TUint KHwLinBasePeriphGroupB	=	KHwLinBaseRegisters + 0x20*KHwLinSeparation;
       
    92 
       
    93 const TUint KHwBaseSerial1	=	KHwLinBasePeriphGroupB + 0x00*KHwLinSeparation;
       
    94 const TUint KHwBaseSerial2	=	KHwLinBasePeriphGroupB + 0x01*KHwLinSeparation;
       
    95 const TUint KHwBaseSerial3	=	KHwLinBasePeriphGroupB + 0x02*KHwLinSeparation;
       
    96 
       
    97 const TUint KHwLinBasePeriphGroupC	=	KHwLinBaseRegisters + 0x30*KHwLinSeparation;
       
    98 
       
    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;
       
   107 
       
   108 
       
   109 // Other device specifc constants, register offsets, bit masks, general-purpose I/O allocations,
       
   110 // interrupt sources, Memory settings and geometries, etc
       
   111 
       
   112 
       
   113 class TTemplate
       
   114 	{
       
   115 	/**
       
   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.
       
   120 	 */
       
   121 public:
       
   122 	/**
       
   123 	 * initialisation
       
   124 	 */
       
   125 	static void Init3();
       
   126 	/**
       
   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
       
   129 	 */	
       
   130 	IMPORT_C static void BootWaitMilliSeconds(TInt aDuration);
       
   131 	/**
       
   132 	 * Read and return the Startup reason of the Hardware
       
   133 	 * @return A TMachineStartupType enumerated value
       
   134 	 */	
       
   135 	IMPORT_C static TMachineStartupType StartupReason();
       
   136 	/**
       
   137 	 * Read and return the the CPU ID
       
   138 	 * @return An integer containing the CPU ID string read off the hardware
       
   139 	 */	
       
   140 	IMPORT_C static TInt CpuVersionId();
       
   141 	/**
       
   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
       
   144 	 */	
       
   145 	IMPORT_C static TUint DebugPortAddr();
       
   146 	/**
       
   147 	 * Read CPU clock period in picoseconds
       
   148 	 * @return An integer containing the CPU clock period in picoseconds
       
   149 	 */	
       
   150 	IMPORT_C static TUint ProcessorPeriodInPs();
       
   151 	/**
       
   152 	 * Set the Hardware Interrupt masks
       
   153 	 * @param aValue A new interrupt mask value
       
   154 	 */	
       
   155 	IMPORT_C static void SetIntMask(TUint aValue);
       
   156 	/**
       
   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)
       
   160 	 */
       
   161 	IMPORT_C static void ModifyIntMask(TUint aClearMask,TUint aSetMask);
       
   162 	/**
       
   163 	 * Read the state of pending interrupts
       
   164 	 * @return A mask containing bits set for all pending interrupts
       
   165 	 */	
       
   166 	IMPORT_C static TUint IntsPending();
       
   167 	/**
       
   168 	 * Read the current time of the RTC
       
   169 	 * @return A value that is the real time as given by a RTC
       
   170 	 */	
       
   171 	IMPORT_C static TUint RtcData();
       
   172 	/**
       
   173 	 * Set the RTC time 
       
   174 	 * @param aValue The real time to set the RTC
       
   175 	 */	
       
   176 	IMPORT_C static void SetRtcData(TUint aValue);
       
   177 	/**
       
   178 	 * Obtain the physical start address of Video Buffer
       
   179 	 * @return the physical start address of Video Buffer
       
   180 	 */	
       
   181 	IMPORT_C static TPhysAddr VideoRamPhys();
       
   182 private:
       
   183 	/**
       
   184 	 * Auxiliary accessor functions for Hardware registers (used by functions above)
       
   185 	 */	
       
   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);
       
   189 	/**
       
   190 	 * Assp-specific implementation for Kern::NanoWait function
       
   191 	 */
       
   192 	static void NanoWait(TUint32 aInterval);
       
   193 	};
       
   194 
       
   195 // TO DO: (optional)
       
   196 //
       
   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)
       
   199 //
       
   200 // EXAMPLE ONLY
       
   201 enum TTemplateAsspInterruptId
       
   202 	{
       
   203 	// ASSP or first-level Interrupt IDs
       
   204 	EAsspIntIdA=0,
       
   205 	EAsspIntIdB=1,
       
   206 	EAsspIntIdC=2,
       
   207 	EAsspIntIdD=3,
       
   208 	EAsspIntIdE=4,
       
   209 	// ...
       
   210 	EAsspIntIdUsb=11,
       
   211 	EAsspIntIdDma=12,
       
   212 	// ...
       
   213 	EAsspIntIdZ=25
       
   214 	};
       
   215 
       
   216 //
       
   217 // TO DO: (optional)
       
   218 //
       
   219 // Define here some commonly used ASSP interrupts
       
   220 //
       
   221 // EXAMPLE ONLY
       
   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;	
       
   228 
       
   229 
       
   230 #endif