omap3530/shared/monitor/monitor.cpp
author Lukasz Forynski <lukasz.forynski@gmail.com>
Tue, 07 Sep 2010 08:40:04 +0100
changeset 63 8cf16be5c3dd
parent 0 6663340f3fc9
child 69 39ed99121282
permissions -rwxr-xr-x
Bug 3674 fix
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
     1
// Copyright (c) 1994-2009 Nokia Corporation and/or its subsidiary(-ies).
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
     2
// All rights reserved.
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
     3
// This component and the accompanying materials are made available
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
     4
// under the terms of the License "Eclipse Public License v1.0"
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
     5
// which accompanies this distribution, and is available
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
     7
//
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
     8
// Initial Contributors:
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
     9
// Nokia Corporation - initial contribution.
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    10
//
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    11
// Contributors:
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    12
//
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    13
// Description:
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    14
// omap3530/shared/monitor/monitor.cpp
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    15
// 
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    16
//
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    17
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    18
#include <monitor.h>
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    19
#include <assp/omap3530_assp/omap3530_assp_priv.h>
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    20
#include <assp/omap3530_assp/omap3530_uart.h>
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    21
#include <assp/omap3530_assp/omap3530_prcm.h>
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    22
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    23
void CrashDebugger::InitUart()
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    24
	{
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    25
	const Omap3530Uart::TUartNumber portNumber( Omap3530Assp::DebugPortNumber() );
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    26
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    27
	if( portNumber >= 0 )
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    28
		{
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    29
		Omap3530Uart::TUart uart( portNumber );
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    30
63
8cf16be5c3dd Bug 3674 fix
Lukasz Forynski <lukasz.forynski@gmail.com>
parents: 0
diff changeset
    31
		// wait for uart to fihish any transmission that could be started (i.e. crash info)
8cf16be5c3dd Bug 3674 fix
Lukasz Forynski <lukasz.forynski@gmail.com>
parents: 0
diff changeset
    32
		while(!uart.TxFifoEmpty());
8cf16be5c3dd Bug 3674 fix
Lukasz Forynski <lukasz.forynski@gmail.com>
parents: 0
diff changeset
    33
0
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    34
		// Ensure UART clocks are running
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    35
		Prcm::SetClockState( uart.PrcmInterfaceClk(),Prcm::EClkOn );
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    36
		Prcm::SetClockState( uart.PrcmFunctionClk(), Prcm::EClkOn );
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    37
	
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    38
		// We don't know what state the UART is in, so reinitialize it
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    39
		uart.Init();
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    40
		uart.DefineMode( Omap3530Uart::TUart::EUart );
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    41
		uart.SetBaud( Omap3530Uart::TUart::E115200 );
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    42
		uart.SetDataFormat( Omap3530Uart::TUart::E8Data, Omap3530Uart::TUart::E1Stop, Omap3530Uart::TUart::ENone );
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    43
		uart.Enable();
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    44
		}
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    45
	}
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    46
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    47
void CrashDebugger::UartOut(TUint aChar)
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    48
	{
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    49
	const Omap3530Uart::TUartNumber portNumber( Omap3530Assp::DebugPortNumber() );
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    50
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    51
	if( portNumber >= 0 )
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    52
		{
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    53
		Omap3530Uart::TUart uart( portNumber );
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    54
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    55
		TUint c=0;
63
8cf16be5c3dd Bug 3674 fix
Lukasz Forynski <lukasz.forynski@gmail.com>
parents: 0
diff changeset
    56
			
0
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    57
		while ( !uart.RxFifoEmpty() )
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    58
			{ 
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    59
			if ( CheckPower() )
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    60
				{
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    61
				return;
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    62
				}
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    63
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    64
			c = uart.Read();
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    65
			
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    66
			if ( c == 19 )            // XOFF
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    67
				{
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    68
				FOREVER
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    69
					{
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    70
					while( uart.RxFifoEmpty() )
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    71
						{
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    72
						if ( CheckPower() )
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    73
							{
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    74
							return;
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    75
							}
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    76
						}
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    77
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    78
					c = uart.Read();
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    79
					
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    80
					if ( c == 17 )    // XON
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    81
						{
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    82
						break;
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    83
						}
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    84
					else if ( c == 3 )		// Ctrl C
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    85
						{
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    86
						Leave(KErrCancel);
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    87
						}
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    88
					}
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    89
				}
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    90
			else if ( c == 3 )		// Ctrl C
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    91
				{
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    92
				Leave(KErrCancel);
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    93
				}
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    94
			}
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    95
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    96
		while ( uart.TxFifoFull() )
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    97
			{
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    98
			CheckPower();
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    99
			}
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
   100
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
   101
		uart.Write( aChar );
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
   102
		}
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
   103
	}
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
   104
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
   105
TUint8 CrashDebugger::UartIn()
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
   106
	{
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
   107
	const Omap3530Uart::TUartNumber portNumber( Omap3530Assp::DebugPortNumber() );
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
   108
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
   109
	if( portNumber >= 0 )
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
   110
		{
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
   111
		Omap3530Uart::TUart uart( portNumber );
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
   112
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
   113
		while ( uart.RxFifoEmpty() )
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
   114
			{
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
   115
			if ( CheckPower() )
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
   116
				{
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
   117
				return 0x0d;
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
   118
				}
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
   119
			}
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
   120
		return uart.Read();
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
   121
		}
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
   122
	
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
   123
	return 0;
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
   124
	}
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
   125
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
   126
TBool CrashDebugger::CheckPower()
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
   127
	{
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
   128
	//
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
   129
	// Check if power supply is stable and return ETrue if not
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
   130
	//
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
   131
	return EFalse;	// EXAMPLE ONLY
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
   132
	}
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
   133