bsptemplate/asspandvariant/template_assp/assp.cpp
changeset 0 a41df078684a
equal deleted inserted replaced
-1:000000000000 0:a41df078684a
       
     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".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // template\template_assp\assp.cpp
       
    15 // 
       
    16 //
       
    17 
       
    18 #include <template_assp_priv.h>
       
    19 
       
    20 TemplateAssp* TemplateAssp::Variant=NULL;
       
    21 TPhysAddr TemplateAssp::VideoRamPhys;
       
    22 
       
    23 DECLARE_STANDARD_ASSP()
       
    24 
       
    25 EXPORT_C TemplateAssp::TemplateAssp()
       
    26 	{
       
    27 	TemplateAssp::Variant=this;
       
    28 	}
       
    29 
       
    30 extern void MsTimerTick(TAny* aPtr);
       
    31 
       
    32 EXPORT_C TMachineStartupType TemplateAssp::StartupReason()
       
    33 	{
       
    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));
       
    38 #endif																	// REMOVE THIS
       
    39 	//
       
    40 	// TO DO: (mandatory)
       
    41 	//
       
    42 	// Map the startup reason read from the Super Page to one of TMachineStartupType enumerated values
       
    43 	// and return this
       
    44 	//
       
    45 	return EStartupCold;   // EXAMPLE ONLY
       
    46 	}
       
    47 
       
    48 EXPORT_C void TemplateAssp::Init1()
       
    49 	{
       
    50 	__KTRACE_OPT(KBOOT,Kern::Printf("TemplateAssp::Init1()"));
       
    51 	//
       
    52 	// TO DO: (optional)
       
    53 	//
       
    54 	TemplateInterrupt::Init1();			// initialise the ASSP interrupt controller
       
    55 
       
    56 	//
       
    57 	// TO DO: (optional)
       
    58 	//
       
    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.
       
    61 	//
       
    62 	}
       
    63 
       
    64 EXPORT_C void TemplateAssp::Init3()
       
    65 	{
       
    66 	__KTRACE_OPT(KBOOT,Kern::Printf("TemplateAssp::Init3()"));
       
    67 
       
    68 	TTemplate::Init3();
       
    69 
       
    70 	NTimerQ& m=*(NTimerQ*)NTimerQ::TimerAddress();
       
    71 	iTimerQ=&m;
       
    72 	//
       
    73 	// TO DO: (mandatory)
       
    74 	//
       
    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
       
    78 	// e.g.
       
    79 	// m.iRounding=-5;
       
    80 	//
       
    81 	
       
    82 	TInt r=Interrupt::Bind(KIntIdOstMatchMsTimer,MsTimerTick,&m);	// bind the System Tick interrupt
       
    83 	if (r!=KErrNone)
       
    84 		Kern::Fault("BindMsTick",r);
       
    85 
       
    86 	// 
       
    87 	// TO DO: (mandatory)
       
    88 	//
       
    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
       
    92 	//
       
    93 
       
    94 	r=Interrupt::Enable(KIntIdOstMatchMsTimer);	// enable the System Tick interrupt
       
    95 	if (r!=KErrNone)
       
    96 		Kern::Fault("EnbMsTick",r);
       
    97 
       
    98 	// 
       
    99 	// TO DO: (optional)
       
   100 	//
       
   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.
       
   103 	//
       
   104 	// EXAMPLE ONLY
       
   105 	TInt vSize=VideoRamSize();
       
   106 	r=Epoc::AllocPhysicalRam(2*vSize,TemplateAssp::VideoRamPhys);
       
   107 	if (r!=KErrNone)
       
   108 		Kern::Fault("AllocVRam",r);
       
   109 	}
       
   110 
       
   111 EXPORT_C TInt TemplateAssp::MsTickPeriod()
       
   112 	{
       
   113 	// 
       
   114 	// TO DO: (mandatory)
       
   115 	//
       
   116 	// Return the OST tick period (System Tick) in microseconds ( 10E-06 s ).
       
   117 	//
       
   118 	return 1000;   // EXAMPLE ONLY
       
   119 	}
       
   120 
       
   121 EXPORT_C TInt TemplateAssp::SystemTimeInSecondsFrom2000(TInt& aTime)
       
   122 	{
       
   123 	aTime=(TInt)TTemplate::RtcData();
       
   124 	__KTRACE_OPT(KHARDWARE,Kern::Printf("RTC READ: %d",aTime));
       
   125 	return KErrNone;
       
   126 	}
       
   127 
       
   128 EXPORT_C TInt TemplateAssp::SetSystemTimeInSecondsFrom2000(TInt aTime)
       
   129 	{
       
   130 	//
       
   131 	// TO DO: (optional)
       
   132 	//
       
   133 	// Check if the RTC is running and is stable
       
   134 	//
       
   135 	__KTRACE_OPT(KHARDWARE,Kern::Printf("Set RTC: %d",aTime));
       
   136 	TTemplate::SetRtcData(aTime);
       
   137 	__KTRACE_OPT(KHARDWARE,Kern::Printf("RTC: %d",TTemplate::RtcData()));
       
   138 	return KErrNone;
       
   139 	}
       
   140 
       
   141 EXPORT_C TUint32 TemplateAssp::NanoWaitCalibration()
       
   142 	{
       
   143 	// 
       
   144 	// TO DO: (mandatory)
       
   145 	//
       
   146 	// Return the minimum time in nano-seconds that it takes to execute the following code:
       
   147 	//	 nanowait_loop:
       
   148 	//	 		  subs r0, r0, r1
       
   149 	//	 		  bhi nanowait_loop
       
   150 	//
       
   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)
       
   153 	//
       
   154 	
       
   155 	return 0;   // EXAMPLE ONLY
       
   156 	}
       
   157