omap3530/shared/monitor/monitor.cpp
author arunabha
Fri, 16 Jul 2010 16:19:24 +0100
changeset 42 7bf4e70b6d9e
parent 0 6663340f3fc9
child 63 8cf16be5c3dd
permissions -rwxr-xr-x
Umbrella changes to use different display and serial-key-board drivers for UI and Texshell
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
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    31
		// Ensure UART clocks are running
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    32
		Prcm::SetClockState( uart.PrcmInterfaceClk(),Prcm::EClkOn );
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    33
		Prcm::SetClockState( uart.PrcmFunctionClk(), Prcm::EClkOn );
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    34
	
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    35
		// 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
    36
		uart.Init();
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    37
		uart.DefineMode( Omap3530Uart::TUart::EUart );
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    38
		uart.SetBaud( Omap3530Uart::TUart::E115200 );
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    39
		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
    40
		uart.Enable();
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    41
		}
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    42
	}
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    43
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    44
void CrashDebugger::UartOut(TUint aChar)
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
	const Omap3530Uart::TUartNumber portNumber( Omap3530Assp::DebugPortNumber() );
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    47
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    48
	if( portNumber >= 0 )
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    49
		{
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    50
		Omap3530Uart::TUart uart( portNumber );
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    51
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    52
		TUint c=0;
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    53
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    54
		while ( !uart.RxFifoEmpty() )
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    55
			{ 
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    56
			if ( CheckPower() )
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    57
				{
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    58
				return;
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    59
				}
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
			c = uart.Read();
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
			if ( c == 19 )            // XOFF
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    64
				{
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    65
				FOREVER
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    66
					{
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    67
					while( uart.RxFifoEmpty() )
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    68
						{
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    69
						if ( CheckPower() )
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    70
							{
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    71
							return;
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    72
							}
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
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    75
					c = uart.Read();
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
					if ( c == 17 )    // XON
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    78
						{
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    79
						break;
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    80
						}
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    81
					else if ( c == 3 )		// Ctrl C
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    82
						{
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    83
						Leave(KErrCancel);
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    84
						}
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
				}
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    87
			else if ( c == 3 )		// Ctrl C
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
				Leave(KErrCancel);
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    90
				}
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
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    93
		while ( uart.TxFifoFull() )
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
			CheckPower();
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
    96
			}
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
		uart.Write( aChar );
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
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
   102
TUint8 CrashDebugger::UartIn()
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
	const Omap3530Uart::TUartNumber portNumber( Omap3530Assp::DebugPortNumber() );
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
   105
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
   106
	if( portNumber >= 0 )
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
   107
		{
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
   108
		Omap3530Uart::TUart uart( portNumber );
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
   109
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
   110
		while ( uart.RxFifoEmpty() )
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
   111
			{
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
   112
			if ( CheckPower() )
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
   113
				{
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
   114
				return 0x0d;
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
   115
				}
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 uart.Read();
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 0;
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
TBool CrashDebugger::CheckPower()
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
	// 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
   127
	//
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
   128
	return EFalse;	// EXAMPLE ONLY
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
   129
	}
6663340f3fc9 Add EPL'd beagleboard code
Pat Downey <patd@symbian.org>
parents:
diff changeset
   130