Update contrib.
1 // Copyright (c) 1994-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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // template\template_assp\assp.cpp
18 #include <template_assp_priv.h>
20 TemplateAssp* TemplateAssp::Variant=NULL;
21 TPhysAddr TemplateAssp::VideoRamPhys;
23 DECLARE_STANDARD_ASSP()
25 EXPORT_C TemplateAssp::TemplateAssp()
27 TemplateAssp::Variant=this;
30 extern void MsTimerTick(TAny* aPtr);
32 EXPORT_C TMachineStartupType TemplateAssp::StartupReason()
34 __KTRACE_OPT(KBOOT,Kern::Printf("TemplateAssp::StartupReason"));
35 #ifdef _DEBUG // REMOVE THIS
36 TUint s = Kern::SuperPage().iHwStartupReason;
37 __KTRACE_OPT(KBOOT,Kern::Printf("CPU page value %08x", s));
42 // Map the startup reason read from the Super Page to one of TMachineStartupType enumerated values
45 return EStartupCold; // EXAMPLE ONLY
48 EXPORT_C void TemplateAssp::Init1()
50 __KTRACE_OPT(KBOOT,Kern::Printf("TemplateAssp::Init1()"));
54 TemplateInterrupt::Init1(); // initialise the ASSP interrupt controller
59 // Initialises any hardware blocks which require early initialisation, e.g. enable and power the LCD, set up
60 // RTC clocks, disable DMA controllers. etc.
64 EXPORT_C void TemplateAssp::Init3()
66 __KTRACE_OPT(KBOOT,Kern::Printf("TemplateAssp::Init3()"));
70 NTimerQ& m=*(NTimerQ*)NTimerQ::TimerAddress();
75 // If Hardware Timer used for System Ticks cannot give exactly the period required store the initial rounding value
76 // here which is updated every time a match occurrs. Note this leads to "wobbly" timers whose exact period change
77 // but averages exactly the required value
82 TInt r=Interrupt::Bind(KIntIdOstMatchMsTimer,MsTimerTick,&m); // bind the System Tick interrupt
84 Kern::Fault("BindMsTick",r);
89 // Clear any pending OST interrupts and enable any OST match registers.
90 // If possible may reset the OST here (to start counting from a full period). Set the harwdare to produce an
91 // interrupt on full count
94 r=Interrupt::Enable(KIntIdOstMatchMsTimer); // enable the System Tick interrupt
96 Kern::Fault("EnbMsTick",r);
101 // Allocate physical RAM for video buffer, as per example below. However with some hardware, the Video Buffer
102 // may not reside in main System memory, it may be dedicated memory.
105 TInt vSize=VideoRamSize();
106 r=Epoc::AllocPhysicalRam(2*vSize,TemplateAssp::VideoRamPhys);
108 Kern::Fault("AllocVRam",r);
111 EXPORT_C TInt TemplateAssp::MsTickPeriod()
114 // TO DO: (mandatory)
116 // Return the OST tick period (System Tick) in microseconds ( 10E-06 s ).
118 return 1000; // EXAMPLE ONLY
121 EXPORT_C TInt TemplateAssp::SystemTimeInSecondsFrom2000(TInt& aTime)
123 aTime=(TInt)TTemplate::RtcData();
124 __KTRACE_OPT(KHARDWARE,Kern::Printf("RTC READ: %d",aTime));
128 EXPORT_C TInt TemplateAssp::SetSystemTimeInSecondsFrom2000(TInt aTime)
133 // Check if the RTC is running and is stable
135 __KTRACE_OPT(KHARDWARE,Kern::Printf("Set RTC: %d",aTime));
136 TTemplate::SetRtcData(aTime);
137 __KTRACE_OPT(KHARDWARE,Kern::Printf("RTC: %d",TTemplate::RtcData()));
141 EXPORT_C TUint32 TemplateAssp::NanoWaitCalibration()
144 // TO DO: (mandatory)
146 // Return the minimum time in nano-seconds that it takes to execute the following code:
151 // If accurate timings are required by the Base Port, then it should provide it's own implementation
152 // of NanoWait which uses a hardware counter. (See Kern::SetNanoWaitHandler)
155 return 0; // EXAMPLE ONLY