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