os/kernelhwsrv/bsptemplate/asspandvariant/template_variant/specific/monitor.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/bsptemplate/asspandvariant/template_variant/specific/monitor.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,115 @@
     1.4 +// Copyright (c) 1994-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of the License "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// template\template_variant\specific\monitor.cpp
    1.18 +// Kernel crash debugger - Template specific
    1.19 +// 
    1.20 +//
    1.21 +
    1.22 +#include <kernel/monitor.h>
    1.23 +#include "variant.h"
    1.24 +
    1.25 +//
    1.26 +// UART code
    1.27 +//
    1.28 +void CrashDebugger::InitUart()
    1.29 +	{
    1.30 +	// Wait for last kernel trace to appear
    1.31 +	TTemplate::BootWaitMilliSeconds(100);
    1.32 +
    1.33 +	//
    1.34 +	// TO DO: (mandatory)
    1.35 +	//
    1.36 +	// Initialise the UART for outputing debug strings. Need to work with the following settings:
    1.37 +	//  - 115200Baud
    1.38 +	//  - 8 data bits, 1 stop bit
    1.39 +	//  - No parity
    1.40 +	// Obtain and use UART linear base address to access the UART registers, e.g.
    1.41 +	// TUint32 debugPortBase = TTemplate::DebugPortAddr();
    1.42 +	//
    1.43 +	}
    1.44 +
    1.45 +void CrashDebugger::UartOut(TUint aChar)
    1.46 +	{
    1.47 +	//
    1.48 +	// TO DO: (mandatory)
    1.49 +	//
    1.50 +	// Output aChar through debug UART
    1.51 +	// Obtain and use UART linear base address to access the UART register, e.g.
    1.52 +	// Should take in consideration software flow control and check if Power is stable as per example below (pseudo-code):
    1.53 +	//
    1.54 +	TUint c=0;
    1.55 +	// TUint32 debugPortBase = TTemplate::DebugPortAddr();		TO DO: (mandatory): Uncomment this
    1.56 +	// while (!(input FIFO empty))								TO DO: (mandatory): Implement
    1.57 +		{ 
    1.58 +		if (CheckPower())
    1.59 +			return;
    1.60 +	//	c=(read received char);									TO DO: (mandatory): Implement
    1.61 +		if (c==19)            // XOFF
    1.62 +			{
    1.63 +			FOREVER
    1.64 +				{
    1.65 +				// wait for XON
    1.66 +	//			while((input FIFO empty))						TO DO: (mandatory): Implement
    1.67 +					{
    1.68 +					if (CheckPower())
    1.69 +						return;
    1.70 +					}
    1.71 +	//			c=(read received char);							TO DO: (mandatory): Implement
    1.72 +				if (c==17)    // XON
    1.73 +					break;
    1.74 +				else if (c==3)		// Ctrl C
    1.75 +					Leave(KErrCancel);
    1.76 +				}
    1.77 +			}
    1.78 +		
    1.79 +		// coverity[dead_error_condition]
    1.80 +		// The next line should be reachable when this template file is edited for use
    1.81 +		else if (c==3)		// Ctrl C
    1.82 +			Leave(KErrCancel);
    1.83 +		}
    1.84 +
    1.85 +	// while ((output FIFO full))					TO DO: (mandatory): wait for last char to leave the FIFO (Implement)
    1.86 +		CheckPower();
    1.87 +	// (write aChar to output port - or FIFO);					TO DO: (mandatory): Implement
    1.88 +	}
    1.89 +
    1.90 +TUint8 CrashDebugger::UartIn()
    1.91 +	{
    1.92 +	//
    1.93 +	// TO DO: (mandatory)
    1.94 +	//
    1.95 +	// Wait for a char to arrive at input port, read it and return its value
    1.96 +	// Use the UART linear base address obtained as in below example to access the UART registers
    1.97 +	// Example below is pseudo-code:
    1.98 +	//
    1.99 +	// TUint32 debugPortBase = TTemplate::DebugPortAddr();		TO DO: (mandatory): Uncomment this
   1.100 +	// while ((input FIFO empty))					TO DO: (mandatory): wait for a character to arrive (Implement)
   1.101 +		{
   1.102 +		if (CheckPower())
   1.103 +			return 0x0d;
   1.104 +		}
   1.105 +	// return (read received char);								TO DO: (mandatory): Implement
   1.106 +	return 0;	// EXAMPLE ONLY
   1.107 +	}
   1.108 +
   1.109 +TBool CrashDebugger::CheckPower()
   1.110 +	{
   1.111 +	//
   1.112 +	// TO DO: (mandatory)
   1.113 +	//
   1.114 +	// Check if power supply is stable and return ETrue if not
   1.115 +	//
   1.116 +	return EFalse;	// EXAMPLE ONLY
   1.117 +	}
   1.118 +