bsptemplate/asspandvariant/template_variant/specific/monitor.cpp
author Tom Cosgrove <tom.cosgrove@nokia.com>
Fri, 28 May 2010 16:29:07 +0100
changeset 137 8aab599e3476
parent 0 a41df078684a
permissions -rw-r--r--
Fix for bug 2283 (RVCT 4.0 support is missing from PDK 3.0.h) Have multiple extension sections in the bld.inf, one for each version of the compiler. The RVCT version building the tools will build the runtime libraries for its version, but make sure we extract all the other versions from zip archives. Also add the archive for RVCT4.

// Copyright (c) 1994-2009 Nokia Corporation and/or its subsidiary(-ies).
// All rights reserved.
// This component and the accompanying materials are made available
// under the terms of the License "Eclipse Public License v1.0"
// which accompanies this distribution, and is available
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
//
// Initial Contributors:
// Nokia Corporation - initial contribution.
//
// Contributors:
//
// Description:
// template\template_variant\specific\monitor.cpp
// Kernel crash debugger - Template specific
// 
//

#include <kernel/monitor.h>
#include "variant.h"

//
// UART code
//
void CrashDebugger::InitUart()
	{
	// Wait for last kernel trace to appear
	TTemplate::BootWaitMilliSeconds(100);

	//
	// TO DO: (mandatory)
	//
	// Initialise the UART for outputing debug strings. Need to work with the following settings:
	//  - 115200Baud
	//  - 8 data bits, 1 stop bit
	//  - No parity
	// Obtain and use UART linear base address to access the UART registers, e.g.
	// TUint32 debugPortBase = TTemplate::DebugPortAddr();
	//
	}

void CrashDebugger::UartOut(TUint aChar)
	{
	//
	// TO DO: (mandatory)
	//
	// Output aChar through debug UART
	// Obtain and use UART linear base address to access the UART register, e.g.
	// Should take in consideration software flow control and check if Power is stable as per example below (pseudo-code):
	//
	TUint c=0;
	// TUint32 debugPortBase = TTemplate::DebugPortAddr();		TO DO: (mandatory): Uncomment this
	// while (!(input FIFO empty))								TO DO: (mandatory): Implement
		{ 
		if (CheckPower())
			return;
	//	c=(read received char);									TO DO: (mandatory): Implement
		if (c==19)            // XOFF
			{
			FOREVER
				{
				// wait for XON
	//			while((input FIFO empty))						TO DO: (mandatory): Implement
					{
					if (CheckPower())
						return;
					}
	//			c=(read received char);							TO DO: (mandatory): Implement
				if (c==17)    // XON
					break;
				else if (c==3)		// Ctrl C
					Leave(KErrCancel);
				}
			}
		
		// coverity[dead_error_condition]
		// The next line should be reachable when this template file is edited for use
		else if (c==3)		// Ctrl C
			Leave(KErrCancel);
		}

	// while ((output FIFO full))					TO DO: (mandatory): wait for last char to leave the FIFO (Implement)
		CheckPower();
	// (write aChar to output port - or FIFO);					TO DO: (mandatory): Implement
	}

TUint8 CrashDebugger::UartIn()
	{
	//
	// TO DO: (mandatory)
	//
	// Wait for a char to arrive at input port, read it and return its value
	// Use the UART linear base address obtained as in below example to access the UART registers
	// Example below is pseudo-code:
	//
	// TUint32 debugPortBase = TTemplate::DebugPortAddr();		TO DO: (mandatory): Uncomment this
	// while ((input FIFO empty))					TO DO: (mandatory): wait for a character to arrive (Implement)
		{
		if (CheckPower())
			return 0x0d;
		}
	// return (read received char);								TO DO: (mandatory): Implement
	return 0;	// EXAMPLE ONLY
	}

TBool CrashDebugger::CheckPower()
	{
	//
	// TO DO: (mandatory)
	//
	// Check if power supply is stable and return ETrue if not
	//
	return EFalse;	// EXAMPLE ONLY
	}