os/kernelhwsrv/bsptemplate/asspandvariant/template_variant/specific/monitor.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
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_variant\specific\monitor.cpp
sl@0
    15
// Kernel crash debugger - Template specific
sl@0
    16
// 
sl@0
    17
//
sl@0
    18
sl@0
    19
#include <kernel/monitor.h>
sl@0
    20
#include "variant.h"
sl@0
    21
sl@0
    22
//
sl@0
    23
// UART code
sl@0
    24
//
sl@0
    25
void CrashDebugger::InitUart()
sl@0
    26
	{
sl@0
    27
	// Wait for last kernel trace to appear
sl@0
    28
	TTemplate::BootWaitMilliSeconds(100);
sl@0
    29
sl@0
    30
	//
sl@0
    31
	// TO DO: (mandatory)
sl@0
    32
	//
sl@0
    33
	// Initialise the UART for outputing debug strings. Need to work with the following settings:
sl@0
    34
	//  - 115200Baud
sl@0
    35
	//  - 8 data bits, 1 stop bit
sl@0
    36
	//  - No parity
sl@0
    37
	// Obtain and use UART linear base address to access the UART registers, e.g.
sl@0
    38
	// TUint32 debugPortBase = TTemplate::DebugPortAddr();
sl@0
    39
	//
sl@0
    40
	}
sl@0
    41
sl@0
    42
void CrashDebugger::UartOut(TUint aChar)
sl@0
    43
	{
sl@0
    44
	//
sl@0
    45
	// TO DO: (mandatory)
sl@0
    46
	//
sl@0
    47
	// Output aChar through debug UART
sl@0
    48
	// Obtain and use UART linear base address to access the UART register, e.g.
sl@0
    49
	// Should take in consideration software flow control and check if Power is stable as per example below (pseudo-code):
sl@0
    50
	//
sl@0
    51
	TUint c=0;
sl@0
    52
	// TUint32 debugPortBase = TTemplate::DebugPortAddr();		TO DO: (mandatory): Uncomment this
sl@0
    53
	// while (!(input FIFO empty))								TO DO: (mandatory): Implement
sl@0
    54
		{ 
sl@0
    55
		if (CheckPower())
sl@0
    56
			return;
sl@0
    57
	//	c=(read received char);									TO DO: (mandatory): Implement
sl@0
    58
		if (c==19)            // XOFF
sl@0
    59
			{
sl@0
    60
			FOREVER
sl@0
    61
				{
sl@0
    62
				// wait for XON
sl@0
    63
	//			while((input FIFO empty))						TO DO: (mandatory): Implement
sl@0
    64
					{
sl@0
    65
					if (CheckPower())
sl@0
    66
						return;
sl@0
    67
					}
sl@0
    68
	//			c=(read received char);							TO DO: (mandatory): Implement
sl@0
    69
				if (c==17)    // XON
sl@0
    70
					break;
sl@0
    71
				else if (c==3)		// Ctrl C
sl@0
    72
					Leave(KErrCancel);
sl@0
    73
				}
sl@0
    74
			}
sl@0
    75
		
sl@0
    76
		// coverity[dead_error_condition]
sl@0
    77
		// The next line should be reachable when this template file is edited for use
sl@0
    78
		else if (c==3)		// Ctrl C
sl@0
    79
			Leave(KErrCancel);
sl@0
    80
		}
sl@0
    81
sl@0
    82
	// while ((output FIFO full))					TO DO: (mandatory): wait for last char to leave the FIFO (Implement)
sl@0
    83
		CheckPower();
sl@0
    84
	// (write aChar to output port - or FIFO);					TO DO: (mandatory): Implement
sl@0
    85
	}
sl@0
    86
sl@0
    87
TUint8 CrashDebugger::UartIn()
sl@0
    88
	{
sl@0
    89
	//
sl@0
    90
	// TO DO: (mandatory)
sl@0
    91
	//
sl@0
    92
	// Wait for a char to arrive at input port, read it and return its value
sl@0
    93
	// Use the UART linear base address obtained as in below example to access the UART registers
sl@0
    94
	// Example below is pseudo-code:
sl@0
    95
	//
sl@0
    96
	// TUint32 debugPortBase = TTemplate::DebugPortAddr();		TO DO: (mandatory): Uncomment this
sl@0
    97
	// while ((input FIFO empty))					TO DO: (mandatory): wait for a character to arrive (Implement)
sl@0
    98
		{
sl@0
    99
		if (CheckPower())
sl@0
   100
			return 0x0d;
sl@0
   101
		}
sl@0
   102
	// return (read received char);								TO DO: (mandatory): Implement
sl@0
   103
	return 0;	// EXAMPLE ONLY
sl@0
   104
	}
sl@0
   105
sl@0
   106
TBool CrashDebugger::CheckPower()
sl@0
   107
	{
sl@0
   108
	//
sl@0
   109
	// TO DO: (mandatory)
sl@0
   110
	//
sl@0
   111
	// Check if power supply is stable and return ETrue if not
sl@0
   112
	//
sl@0
   113
	return EFalse;	// EXAMPLE ONLY
sl@0
   114
	}
sl@0
   115