os/kernelhwsrv/bsptemplate/asspandvariant/template_assp/assp.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 1994-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of the License "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// template\template_assp\assp.cpp
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
#include <template_assp_priv.h>
sl@0
    19
sl@0
    20
TemplateAssp* TemplateAssp::Variant=NULL;
sl@0
    21
TPhysAddr TemplateAssp::VideoRamPhys;
sl@0
    22
sl@0
    23
DECLARE_STANDARD_ASSP()
sl@0
    24
sl@0
    25
EXPORT_C TemplateAssp::TemplateAssp()
sl@0
    26
	{
sl@0
    27
	TemplateAssp::Variant=this;
sl@0
    28
	}
sl@0
    29
sl@0
    30
extern void MsTimerTick(TAny* aPtr);
sl@0
    31
sl@0
    32
EXPORT_C TMachineStartupType TemplateAssp::StartupReason()
sl@0
    33
	{
sl@0
    34
	__KTRACE_OPT(KBOOT,Kern::Printf("TemplateAssp::StartupReason"));
sl@0
    35
#ifdef _DEBUG															// REMOVE THIS
sl@0
    36
	TUint s = Kern::SuperPage().iHwStartupReason;
sl@0
    37
	__KTRACE_OPT(KBOOT,Kern::Printf("CPU page value %08x", s));
sl@0
    38
#endif																	// REMOVE THIS
sl@0
    39
	//
sl@0
    40
	// TO DO: (mandatory)
sl@0
    41
	//
sl@0
    42
	// Map the startup reason read from the Super Page to one of TMachineStartupType enumerated values
sl@0
    43
	// and return this
sl@0
    44
	//
sl@0
    45
	return EStartupCold;   // EXAMPLE ONLY
sl@0
    46
	}
sl@0
    47
sl@0
    48
EXPORT_C void TemplateAssp::Init1()
sl@0
    49
	{
sl@0
    50
	__KTRACE_OPT(KBOOT,Kern::Printf("TemplateAssp::Init1()"));
sl@0
    51
	//
sl@0
    52
	// TO DO: (optional)
sl@0
    53
	//
sl@0
    54
	TemplateInterrupt::Init1();			// initialise the ASSP interrupt controller
sl@0
    55
sl@0
    56
	//
sl@0
    57
	// TO DO: (optional)
sl@0
    58
	//
sl@0
    59
	// Initialises any hardware blocks which require early initialisation, e.g. enable and power the LCD, set up
sl@0
    60
	// RTC clocks, disable DMA controllers. etc.
sl@0
    61
	//
sl@0
    62
	}
sl@0
    63
sl@0
    64
EXPORT_C void TemplateAssp::Init3()
sl@0
    65
	{
sl@0
    66
	__KTRACE_OPT(KBOOT,Kern::Printf("TemplateAssp::Init3()"));
sl@0
    67
sl@0
    68
	TTemplate::Init3();
sl@0
    69
sl@0
    70
	NTimerQ& m=*(NTimerQ*)NTimerQ::TimerAddress();
sl@0
    71
	iTimerQ=&m;
sl@0
    72
	//
sl@0
    73
	// TO DO: (mandatory)
sl@0
    74
	//
sl@0
    75
	// If Hardware Timer used for System Ticks cannot give exactly the period required store the initial rounding value
sl@0
    76
	// here which is updated every time a match occurrs. Note this leads to "wobbly" timers whose exact period change
sl@0
    77
	// but averages exactly the required value
sl@0
    78
	// e.g.
sl@0
    79
	// m.iRounding=-5;
sl@0
    80
	//
sl@0
    81
	
sl@0
    82
	TInt r=Interrupt::Bind(KIntIdOstMatchMsTimer,MsTimerTick,&m);	// bind the System Tick interrupt
sl@0
    83
	if (r!=KErrNone)
sl@0
    84
		Kern::Fault("BindMsTick",r);
sl@0
    85
sl@0
    86
	// 
sl@0
    87
	// TO DO: (mandatory)
sl@0
    88
	//
sl@0
    89
	// Clear any pending OST interrupts and enable any OST match registers.
sl@0
    90
	// If possible may reset the OST here (to start counting from a full period). Set the harwdare to produce an 
sl@0
    91
	// interrupt on full count
sl@0
    92
	//
sl@0
    93
sl@0
    94
	r=Interrupt::Enable(KIntIdOstMatchMsTimer);	// enable the System Tick interrupt
sl@0
    95
	if (r!=KErrNone)
sl@0
    96
		Kern::Fault("EnbMsTick",r);
sl@0
    97
sl@0
    98
	// 
sl@0
    99
	// TO DO: (optional)
sl@0
   100
	//
sl@0
   101
	// Allocate physical RAM for video buffer, as per example below. However with some hardware, the Video Buffer
sl@0
   102
	// may not reside in main System memory, it may be dedicated memory.
sl@0
   103
	//
sl@0
   104
	// EXAMPLE ONLY
sl@0
   105
	TInt vSize=VideoRamSize();
sl@0
   106
	r=Epoc::AllocPhysicalRam(2*vSize,TemplateAssp::VideoRamPhys);
sl@0
   107
	if (r!=KErrNone)
sl@0
   108
		Kern::Fault("AllocVRam",r);
sl@0
   109
	}
sl@0
   110
sl@0
   111
EXPORT_C TInt TemplateAssp::MsTickPeriod()
sl@0
   112
	{
sl@0
   113
	// 
sl@0
   114
	// TO DO: (mandatory)
sl@0
   115
	//
sl@0
   116
	// Return the OST tick period (System Tick) in microseconds ( 10E-06 s ).
sl@0
   117
	//
sl@0
   118
	return 1000;   // EXAMPLE ONLY
sl@0
   119
	}
sl@0
   120
sl@0
   121
EXPORT_C TInt TemplateAssp::SystemTimeInSecondsFrom2000(TInt& aTime)
sl@0
   122
	{
sl@0
   123
	aTime=(TInt)TTemplate::RtcData();
sl@0
   124
	__KTRACE_OPT(KHARDWARE,Kern::Printf("RTC READ: %d",aTime));
sl@0
   125
	return KErrNone;
sl@0
   126
	}
sl@0
   127
sl@0
   128
EXPORT_C TInt TemplateAssp::SetSystemTimeInSecondsFrom2000(TInt aTime)
sl@0
   129
	{
sl@0
   130
	//
sl@0
   131
	// TO DO: (optional)
sl@0
   132
	//
sl@0
   133
	// Check if the RTC is running and is stable
sl@0
   134
	//
sl@0
   135
	__KTRACE_OPT(KHARDWARE,Kern::Printf("Set RTC: %d",aTime));
sl@0
   136
	TTemplate::SetRtcData(aTime);
sl@0
   137
	__KTRACE_OPT(KHARDWARE,Kern::Printf("RTC: %d",TTemplate::RtcData()));
sl@0
   138
	return KErrNone;
sl@0
   139
	}
sl@0
   140
sl@0
   141
EXPORT_C TUint32 TemplateAssp::NanoWaitCalibration()
sl@0
   142
	{
sl@0
   143
	// 
sl@0
   144
	// TO DO: (mandatory)
sl@0
   145
	//
sl@0
   146
	// Return the minimum time in nano-seconds that it takes to execute the following code:
sl@0
   147
	//	 nanowait_loop:
sl@0
   148
	//	 		  subs r0, r0, r1
sl@0
   149
	//	 		  bhi nanowait_loop
sl@0
   150
	//
sl@0
   151
	// If accurate timings are required by the Base Port, then it should provide it's own implementation 
sl@0
   152
	// of NanoWait which uses a hardware counter. (See Kern::SetNanoWaitHandler)
sl@0
   153
	//
sl@0
   154
	
sl@0
   155
	return 0;   // EXAMPLE ONLY
sl@0
   156
	}
sl@0
   157